diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/mapper/AbnormalBillMapper.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/mapper/AbnormalBillMapper.java index b9793b22..5db8d7bb 100644 --- a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/mapper/AbnormalBillMapper.java +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/mapper/AbnormalBillMapper.java @@ -28,6 +28,6 @@ public interface AbnormalBillMapper extends BaseMapper { */ AbnormalBillDto findAllByAbnormalNoDevice(@Param("abnormalBill")AbnormalBill abnormalBill, @Param("language")String language); - + List findCountBySfc(@Param("site")String site,@Param("type")String type,@Param("sfc")String sfc,@Param("status")List status); } \ No newline at end of file diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java index 61d45599..624e7312 100644 --- a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java @@ -186,12 +186,32 @@ public class AbnormalBillServiceImpl extends ServiceImpl ncByNG = ncCodeService.findNcByNG(abnormalBill.getMessageType(), abnormalBill.getNcCode()); // if(ncByNG == null || ncByNG.size() <= 0){ // throw BusinessException.build("该消息类型下没有该不良代码"); // } + this.saveOrUpdate(abnormalBill); abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose); + if(!StringUtil.isBlank(abnormalBill.getSfc()) ){ + List status = new ArrayList<>(); + status.add(Constants.PROGRAM_CONFIRM); + status.add(Constants.CANCEL); + status.add(Constants.SHUT_DOWN); + List abnormalBillList = abnormalBillMapper.findCountBySfc(abnormalBill.getSite(), abnormalBill.getType(), abnormalBill.getSfc(), status); + + if(abnormalBillList.size() > 1 && !"更新成功".equals(message)){ + throw BusinessException.build("设备异常有未处理完成的sfc"); + }else if(abnormalBillList.size() > 1 ){ + throw BusinessException.build("设备异常有未处理完成的sfc"); + } + } + + + + return message; } @@ -485,9 +505,21 @@ public class AbnormalBillServiceImpl extends ServiceImpl abnormalBills = this.selectList(abnormalBill2); +// if(abnormalBills.size() > 0 && !"更新成功".equals(message)){ +// throw BusinessException.build("设备异常有未处理完成的sfc"); +// }else if(abnormalBills.size() > 1){ +// throw BusinessException.build("设备异常有未处理完成的sfc"); +// } +// } // if(StringUtil.isBlank(abnormalBill.getResrce())){ // throw BusinessException.build("设备编号不能为空"); // } diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/FileUploadedServiceImpl.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/FileUploadedServiceImpl.java index e05bc4f9..4004752c 100644 --- a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/FileUploadedServiceImpl.java +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/FileUploadedServiceImpl.java @@ -1,11 +1,11 @@ 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.fileupload.FileItem; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPReply; @@ -164,7 +164,7 @@ public class FileUploadedServiceImpl implements FileUploadedService { } } - public void uploadImage(MultipartFile fileItem, HttpServletRequest request){ + public void uploadImage(FileItem fileItem, HttpServletRequest request){ String site = request.getParameter("site"); String taskNo = request.getParameter("taskNo"); String fileType = request.getParameter("fileType"); @@ -175,7 +175,7 @@ public class FileUploadedServiceImpl implements FileUploadedService { //上传附件目录:年/月/日 String path = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd"))+"/"+taskNo; //上传附件名称 - String fileName = fileItem.getOriginalFilename(); + String fileName = fileItem.getName(); try { Ftp ftp = new Ftp(host, port,username,password); diff --git a/anomaly/src/main/resources/mapper/AbnormalBillMapper.xml b/anomaly/src/main/resources/mapper/AbnormalBillMapper.xml index a20c99ff..a24e04ea 100644 --- a/anomaly/src/main/resources/mapper/AbnormalBillMapper.xml +++ b/anomaly/src/main/resources/mapper/AbnormalBillMapper.xml @@ -885,4 +885,27 @@ + + diff --git a/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java b/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java index 2aed35ca..cd842f93 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java @@ -125,7 +125,8 @@ public enum HandleEnum { /**检验任务明细**/ INSPECTION_TASK_DETAIL("InspectionTaskDetailBO:","InspectionTaskDetailBO:{0},{1}"), - + /**自报任务**/ + SELF_REPORT("SelfReportBO:","SelfReportBO:{0},{1}"), /**上料**/ LOAD_INVENTORY("LoadInventoryBO:","LoadInventoryBO:{0},{1}"), diff --git a/quality/src/main/java/com/foreverwin/mesnac/quality/dto/SelfReportRequest.java b/quality/src/main/java/com/foreverwin/mesnac/quality/dto/SelfReportRequest.java new file mode 100644 index 00000000..c167a5fa --- /dev/null +++ b/quality/src/main/java/com/foreverwin/mesnac/quality/dto/SelfReportRequest.java @@ -0,0 +1,40 @@ +package com.foreverwin.mesnac.quality.dto; + +public class SelfReportRequest { + private String type; + private String shopOrder; + private String ncGroup; + private String ncCode; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getShopOrder() { + return shopOrder; + } + + public void setShopOrder(String shopOrder) { + this.shopOrder = shopOrder; + } + + public String getNcGroup() { + return ncGroup; + } + + public void setNcGroup(String ncGroup) { + this.ncGroup = ncGroup; + } + + public String getNcCode() { + return ncCode; + } + + public void setNcCode(String ncCode) { + this.ncCode = ncCode; + } +} diff --git a/quality/src/main/java/com/foreverwin/mesnac/quality/model/SelfReport.java b/quality/src/main/java/com/foreverwin/mesnac/quality/model/SelfReport.java index 250d00dd..98467c1f 100644 --- a/quality/src/main/java/com/foreverwin/mesnac/quality/model/SelfReport.java +++ b/quality/src/main/java/com/foreverwin/mesnac/quality/model/SelfReport.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; import java.io.Serializable; +import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; @@ -79,7 +80,7 @@ public class SelfReport extends Model { * 不良数量 */ @TableField("NC_QTY") - private Double ncQty; + private BigDecimal ncQty; /** * 设备位置 */ @@ -237,11 +238,11 @@ public class SelfReport extends Model { this.ncCode = ncCode; } - public Double getNcQty() { + public BigDecimal getNcQty() { return ncQty; } - public void setNcQty(Double ncQty) { + public void setNcQty(BigDecimal ncQty) { this.ncQty = ncQty; } diff --git a/quality/src/main/java/com/foreverwin/mesnac/quality/service/impl/SelfReportServiceImpl.java b/quality/src/main/java/com/foreverwin/mesnac/quality/service/impl/SelfReportServiceImpl.java index 22ca9064..0f049064 100644 --- a/quality/src/main/java/com/foreverwin/mesnac/quality/service/impl/SelfReportServiceImpl.java +++ b/quality/src/main/java/com/foreverwin/mesnac/quality/service/impl/SelfReportServiceImpl.java @@ -3,8 +3,16 @@ package com.foreverwin.mesnac.quality.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.foreverwin.mesnac.common.constant.Constants; +import com.foreverwin.mesnac.common.enums.HandleEnum; +import com.foreverwin.mesnac.common.service.AnomalyService; +import com.foreverwin.mesnac.common.service.CommonService; +import com.foreverwin.mesnac.common.util.StringUtil; import com.foreverwin.mesnac.meapi.dto.SfcDto; import com.foreverwin.mesnac.production.mapper.SfcCrossMapper; +import com.foreverwin.mesnac.quality.dto.SelfReportRequest; import com.foreverwin.mesnac.quality.mapper.SelfReportMapper; import com.foreverwin.mesnac.quality.model.SelfReport; import com.foreverwin.mesnac.quality.service.SelfReportService; @@ -16,10 +24,13 @@ import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; /** *

@@ -38,6 +49,10 @@ public class SelfReportServiceImpl extends ServiceImpl map) { String site = CommonMethods.getSite(); + String user = CommonMethods.getUser(); String sfc = (String)map.get("sfc"); String resrce = (String)map.get("resrce"); - List list = (List)map.get("ncList"); + String ncQty = (String)map.get("ncQty"); + String comments = (String)map.get("comments"); + String location=(String)map.get("location"); + List list = (List)map.get("ncList"); + ObjectMapper mapper = new ObjectMapper(); + list = mapper.convertValue(list, new TypeReference>() {}); SfcDto sfcDto = new SfcDto(); sfcDto.setSfc(sfc); sfcDto.setResrce(resrce); - Map sfcMapper = sfcCorssMapper.querySfcData(site, LocaleContextHolder.getLocale().getLanguage(), sfcDto); - - + Map sfcData = sfcCorssMapper.querySfcData(site, LocaleContextHolder.getLocale().getLanguage(), sfcDto); + + String operationStep = (String)sfcData.get("OPERATION_STEP"); + String shopOrder = (String)sfcData.get("SHOP_ORDER"); + String item = (String)sfcData.get("ITEM"); + List resrceAbnormalList = list.stream().filter(selfReportRequest -> selfReportRequest.getType().equals(Constants.ABNORMAL_RESRCE)).collect(Collectors.toList()); + if (resrceAbnormalList.size()>0){ + StringBuilder stringBuilder = new StringBuilder(); + for (int i=0;i otherAbnormalList = list.stream().filter(selfReportRequest -> selfReportRequest.getType().equals(Constants.ABNORMAL_OTHER)).collect(Collectors.toList()); + if (otherAbnormalList.size()>0){ + anomalyService.createAnomalyTask(Constants.ABNORMAL_RESRCE,resrce,shopOrder,sfc,"",location,ncQty,comments); + } + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.eq(SelfReport.SFC,sfc); + queryWrapper.eq(SelfReport.OP_STEP,operationStep); + queryWrapper.eq(SelfReport.STATE,Constants.NEW); + List selfReports = list(queryWrapper); + if (selfReports.size()>0){ + throw new BaseException("存在未处理的自报任务"); + } + List selfReportList = list.stream().filter(selfReportRequest -> selfReportRequest.getType().equals("Z")).collect(Collectors.toList()); + if (selfReportList.size()>0){ + StringBuilder stringBuilder = new StringBuilder(); + for (int i=0;i