异常bug修改,附件上传

赵嘉伟 4 years ago
parent 9147a662ec
commit e8d3818f99

@ -167,7 +167,8 @@ public class AbnormalBillController {
/**
*
* @param messageType
* @param messageType
* @param type
* @return
*/
@GetMapping("/init")

@ -13,7 +13,7 @@ import java.util.List;
/**
*
* @author Leon.L
* @author
* @since 2021-07-11
*/
@RestController

@ -28,4 +28,6 @@ public interface AbnormalBillMapper extends BaseMapper<AbnormalBill> {
*/
AbnormalBillDto findAllByAbnormalNoDevice(@Param("abnormalBill")AbnormalBill abnormalBill, @Param("language")String language);
}

@ -97,6 +97,9 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Autowired
private SfcMapper sfcMapper;
@Autowired
private NcCodeMapper ncCodeMapper;
@Override
@ -183,10 +186,10 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
public String anomalyReportDevice(AbnormalBill abnormalBill,AbnormalBillDispose abnormalBillDispose) {
String message = this.generateAbnormalBill(abnormalBill, abnormalBillDispose, null, null);
List<NcCode> ncByNG = ncCodeService.findNcByNG(abnormalBill.getMessageType(), abnormalBill.getNcCode());
if(ncByNG == null || ncByNG.size() <= 0){
throw BusinessException.build("该消息类型下没有该不良代码");
}
// List<NcCode> ncByNG = ncCodeService.findNcByNG(abnormalBill.getMessageType(), abnormalBill.getNcCode());
// if(ncByNG == null || ncByNG.size() <= 0){
// throw BusinessException.build("该消息类型下没有该不良代码");
// }
this.saveOrUpdate(abnormalBill);
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
return message;
@ -197,10 +200,9 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
HashMap<String, Object> hashMap = new HashMap<>();
String site = CommonMethods.getSite();
//消息类型
if(!StringUtil.isBlank(messageType)){
List<NcCode> ncByNG = ncCodeService.findNcByNG(messageType,null);
hashMap.put("ncByNG",ncByNG);
if("Z".equals(type)){
List<NcCode> category = ncCodeService.findNcByCategory(messageType,null);
hashMap.put("ncByNG",category);
}
//工作中心
WorkCenter workCenter = new WorkCenter();
@ -405,7 +407,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalBillDispose.setDutyDateTime(currentTime);
ArrayList<AbnormalCause> causeTypes = new ArrayList<>();
//判断原因分类是否为空
//判断原因分类是否为空,如果不为空把它放进Z_ABNORMAL_CAUSE表里面
if(dutyCauseType != null && dutyCauseType.size() >= 1){
for(String cause:dutyCauseType){
AbnormalCause abnormalCause = new AbnormalCause();
@ -428,8 +430,21 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
causeTypes.add(abnormalCause);
}
}
/**
*
*/
if(!StringUtil.isBlank(abnormalBill.getNcCode()) && Constants.ABNORMAL_RESRCE.equals(abnormalBill.getType())){
List<String> ncCodes = Arrays.asList(abnormalBill.getNcCode().split(","));
Integer length = ncCodeMapper.checkNcCode(ncCodes,site,"FAILURE");
if(ncCodes.size() != length){
throw BusinessException.build("不良代码传递有误");
}
}
ArrayList<AbnormalDuty> dutyTypes = new ArrayList<>();
//判断责任分类是否为空
//判断责任分类是否为空,如果不为空把它放进Z_ABNORMAL_DUTY表里面
if(dutyType != null && dutyType.size() >= 1){
for(String duty:dutyType){
AbnormalDuty abnormalDuty = new AbnormalDuty();
@ -465,24 +480,30 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalBillDispose.setModifiedDateTime(currentTime);
abnormalBillDispose.setModifiedUser(user);
//判断SFC、设备编号、消息类型是否不正确或为空
if(StringUtil.isBlank(abnormalBill.getSfc()) && !"S".equals(abnormalBill.getType())){
/**
* SFC sfc
*
*
*/
if(StringUtil.isBlank(abnormalBill.getSfc()) && !Constants.ABNORMAL_RESRCE.equals(abnormalBill.getType())){
throw BusinessException.build("产品条码不能为空");
}
// if(StringUtil.isBlank(abnormalBill.getResrce())){
// throw BusinessException.build("设备编号不能为空");
// }
if(!StringUtil.isBlank(abnormalBill.getMessageType())){
NcGroup messageType = ncGroupMapper.selectById(HandleEnum.NC_GROUP.getHandle(site, abnormalBill.getMessageType()));
if(messageType == null){
throw BusinessException.build("该消息类型不存在");
// if(!StringUtil.isBlank(abnormalBill.getMessageType())){
// NcGroup messageType = ncGroupMapper.selectById(HandleEnum.NC_GROUP.getHandle(site, abnormalBill.getMessageType()));
// if(messageType == null){
// throw BusinessException.build("该消息类型不存在");
// }
// }
if(!StringUtil.isBlank(abnormalBill.getResrce()) && Constants.ABNORMAL_RESRCE.equals(abnormalBill.getType())){
Resrce resrce = resrceMapper.selectById(HandleEnum.RESOURCE.getHandle(site, abnormalBill.getResrce()));
if(resrce == null){
throw BusinessException.build("该设备编号不存在");
}
}
// Resrce resrce = resrceMapper.selectById(HandleEnum.RESOURCE.getHandle(site, abnormalBill.getResrce()));
// if(resrce == null){
// throw BusinessException.build("该设备编号不存在");
// }
//判断不良品数量和问题数量是否为正整数
try {
if(!StringUtil.isBlank(abnormalBill.getNcQty()) && Integer.parseInt(abnormalBill.getNcQty()) < 0) {
@ -503,7 +524,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
if(causeTypes.size() > 0){
abnormalCauseService.saveOrUpdateBatch(causeTypes);
}
if(StringUtil.isBlank(abnormalBill.getFileName())){
if(!StringUtil.isBlank(abnormalBill.getFileName())){
//放置图片
this.fileUpload(abnormalBill);
}
@ -626,16 +647,16 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
//判断工单sfc资源是否传递正确
Sfc sfc1 = sfcMapper.selectById(HandleEnum.SFC.getHandle(site, sfc));
if(sfc == null){
if(sfc1 == null){
throw new BaseException("sfc传递有误");
}else {
if(!HandleEnum.SHOP_ORDER.getHandle(site,shopOrder).equals(sfc1.getShopOrderBo())){
throw new BaseException("工单传递有误");
}
Resrce resrce = resrceMapper.selectById(HandleEnum.RESOURCE.getHandle(site, resource));
if(resrce == null){
throw new BaseException("资源传递有误");
}
// Resrce resrce = resrceMapper.selectById(HandleEnum.RESOURCE.getHandle(site, resource));
// if(resrce == null){
// throw new BaseException("资源传递有误");
// }
}
this.saveOrUpdate(abnormalBill);
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);

@ -3,6 +3,7 @@ package com.foreverwin.mesnac.anomaly.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.ftp.Ftp;
import com.foreverwin.mesnac.anomaly.service.FileUploadedService;
import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.modular.core.exception.BusinessException;
import com.foreverwin.modular.core.util.CommonMethods;
import org.apache.commons.net.ftp.FTP;
@ -54,7 +55,7 @@ public class FileUploadedServiceImpl implements FileUploadedService {
*/
@Override
public void uploadAttachment(MultipartFile fileItem,String site,String taskNo,String fileType) {
if (StrUtil.isBlank(site)) {
if (StringUtil.isBlank(site)) {
site = CommonMethods.getSite();
}
//上传附件目录:年/月/日
@ -163,5 +164,28 @@ public class FileUploadedServiceImpl implements FileUploadedService {
}
}
public void uploadImage(MultipartFile fileItem, HttpServletRequest request){
String site = request.getParameter("site");
String taskNo = request.getParameter("taskNo");
String fileType = request.getParameter("fileType");
if (StringUtil.isBlank(site)) {
site = CommonMethods.getSite();
}
//上传附件目录:年/月/日
String path = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd"))+"/"+taskNo;
//上传附件名称
String fileName = fileItem.getOriginalFilename();
try {
Ftp ftp = new Ftp(host, port,username,password);
ftp.upload(path, fileName, fileItem.getInputStream());
ftp.close();
} catch (IOException e) {
logger.info(e.getMessage());
throw BusinessException.build("" + e.getMessage());
}
}
}

@ -135,9 +135,9 @@ public class NcCodeController {
/**
*
*/
@GetMapping("/findNcByNG")
public R findNcByNG(String messageType,String ncCode){
return R.ok(ncCodeService.findNcByNG(messageType,ncCode));
@GetMapping("/findNcByCategory")
public R findNcByCategory(String category,String code){
return R.ok(ncCodeService.findNcByCategory(category,code));
}
@GetMapping("findSecondaryNcByNc")

@ -20,12 +20,18 @@ import java.util.List;
*/
@Repository
public interface NcCodeMapper extends BaseMapper<NcCode> {
List<NcCode> findNcByNG(@Param("site")String site,
List<NcCode> findNcByCategory(@Param("site")String site,
@Param("locale")String locale,
@Param("messageType")String messageType,
@Param("ncCode")String ncCode);
@Param("code")String code);
List<NcCode> findSecondaryNcByNc(@Param("site")String site,@Param("locale")String locale,@Param("ncCode")String ncCode);
IPage selectPageByNcGroup(Page<NcGroup> pagePlus,@Param("ncGroupBO") String ncGroupBO,@Param("globalQuery") String globalQuery,@Param("locale") String locale);
/**
*
* @return
*/
Integer checkNcCode(@Param("NcCodeList")List<String> ncCodes,@Param("site")String site,@Param("category")String category);
}

@ -28,7 +28,7 @@ public interface NcCodeService extends IService<NcCode> {
List<NcCode> selectList(NcCode ncCode);
List<NcCode> findNcByNG(String messageType,String ncCode);
List<NcCode> findNcByCategory(String category,String code);
List<NcCode> findSecondaryNcByNc(String ncCode);

@ -51,10 +51,10 @@ public class NcCodeServiceImpl extends ServiceImpl<NcCodeMapper, NcCode> impleme
}
@Override
public List<NcCode> findNcByNG(String messageType,String ncCode) {
public List<NcCode> findNcByCategory(String messageType,String code) {
String site = CommonMethods.getSite();
String locale = LocaleContextHolder.getLocale().getLanguage();
return ncCodeMapper.findNcByNG(site,locale,messageType,ncCode);
return ncCodeMapper.findNcByCategory(site,locale,messageType,code);
}
@Override

@ -346,20 +346,19 @@
<!-- BaseMapper标准查询/修改/删除 -->
<select id="findNcByNG" resultMap="BaseResultMap">
<select id="findNcByCategory" resultMap="BaseResultMap">
SELECT NC.NC_CODE , NCT.DESCRIPTION
FROM NC_GROUP NG
INNER JOIN NC_GROUP_MEMBER NGM ON NG.HANDLE = NGM.NC_GROUP_BO
INNER JOIN NC_CODE NC ON NC.HANDLE = NGM.NC_CODE_OR_GROUP_GBO
INNER JOIN NC_CODE_DEF NCD ON NC.HANDLE = NCD.NC_CODE_OR_GROUP_GBO AND NCD.CAN_BE_PRIMARY_CODE = 'true'
INNER JOIN NC_CODE_T NCT ON NCT.NC_CODE_BO = NC.HANDLE AND NCT.LOCALE = #{locale}
FROM NC_CODE NC
INNER JOIN NC_CODE_DEF NCD ON NC.HANDLE = NCD.NC_CODE_OR_GROUP_GBO AND NCD.CAN_BE_PRIMARY_CODE = 'true'
INNER JOIN NC_CODE_T NCT ON NCT.NC_CODE_BO = NC.HANDLE AND NCT.LOCALE = #{locale}
<where>
NG.SITE = #{site}
NC.SITE = #{site}
AND NCD.CAN_BE_PRIMARY_CODE = 'true'
<if test="messageType != null and messageType != ''">
AND NG.NC_GROUP =#{messageType}
AND NC.NC_CATEGORY =#{messageType}
</if>
<if test="ncCode != null and ncCode != ''">
AND NC.NC_CODE = #{ncCode}
<if test="code != null and code != ''">
AND NC.NC_CDDE = #{code}
</if>
</where>
</select>
@ -382,4 +381,19 @@
AND (nc.NC_CODE LIKE '%${globalQuery}%' or nct.DESCRIPTION LIKE '%${globalQuery}%')
</if>
</select>
<select id="checkNcCode" resultType="integer">
SELECT count(*)
FROM NC_CODE
WHERE NC_CODE IN
<foreach collection="NcCodeList" index="index" item="item" separator="," open="(" close=")">
UPPER(#{item})
</foreach>
<if test="site != null and site != ''">
AND SITE = #{site}
</if>
<if test="category != null and category != ''">
AND NC_CATEGORY = #{category}
</if>
</select>
</mapper>

Loading…
Cancel
Save