diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesEquipmentLogExtService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesEquipmentLogExtService.java index 644a5d6..97be0cd 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesEquipmentLogExtService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesEquipmentLogExtService.java @@ -28,4 +28,7 @@ public interface IMesEquipmentLogExtService { @ApiOperation(value = "验证设备通信质量") Boolean checkEquipQuality(Integer quality); + @ApiOperation(value = "根据设备ID 查询设备ID分表所有采集数据") + MesEquipmentLog queryMesEquipmentLog( Integer equipId, Long equipVariableId); + } diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesInputDefectRecordService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesInputDefectRecordService.java index 2d2f9e5..bbe797e 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesInputDefectRecordService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesInputDefectRecordService.java @@ -19,15 +19,15 @@ public interface IMesInputDefectRecordService { @ApiOperation(value = "查询页面信息") - public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel model, String org); + MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel model, String org); @ApiOperation(value = "零件类型缺陷类型对应关系信息") - public List queryPartTypeDefect(String serialNumber, String defectLocation, boolean flg, Integer frontBack, String org); + List queryPartTypeDefect(String serialNumber, String defectLocation, boolean flg, Integer frontBack, String org); @ApiOperation(value = "完成质检") - public void savePartInspection(MesPartInspectionInputModel model, String org); + void savePartInspection(MesPartInspectionInputModel model, String org); @ApiOperation(value = "可疑品录入") - public void saveSusPartInspection(MesPartInspectionInputModel model, String org); + void saveSusPartInspection(MesPartInspectionInputModel model, String org); } diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesWorkOrderExtService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesWorkOrderExtService.java index f8d2e4e..f1e34f2 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesWorkOrderExtService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesWorkOrderExtService.java @@ -20,4 +20,7 @@ public interface IMesWorkOrderExtService { MesWorkOrder insert(MesWorkOrder item); void update(MesWorkOrder item); + + @ApiOperation(value = "根据生产工单ID查询生产工单信息") + List getWorkOrderListByShiftCode(String organizeCode, String workCenterCode, String shiftCode); } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/config/MqttConfig.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/config/MqttConfig.java index 7e5ac44..61d0416 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/config/MqttConfig.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/config/MqttConfig.java @@ -34,8 +34,6 @@ public class MqttConfig { @Value("${mqtt.clearSession}") public boolean clearSession; - @Value("${mqtt.topic}") - public String topic; @Value("${mqtt.topic.list}") private String topicList; diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesNcProcessingController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesNcProcessingController.java index 7c62e61..1fc4490 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesNcProcessingController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesNcProcessingController.java @@ -37,7 +37,7 @@ public class MesNcProcessingController { try { - partInspection.setOrganizeCode(AuthUtil.getOrganizeCode()); + partInspection.setOrganizeCode(partInspection.getOrganizeCode()); ListPager partInspectionListPager = ncProcessingService.queryPartInspectionByPager(partInspection, pager); return ResultBean.success("查询成功").setListPager(partInspectionListPager); } catch (ImppBusiException imppException) { @@ -88,6 +88,9 @@ public class MesNcProcessingController { if (model.getType() == MesExtEnumUtil.NC_TYPE.REWORK.getValue() || model.getType() == MesExtEnumUtil.NC_TYPE.SCRAP.getValue()) { ValidatorBean.checkNotNull(model.getPerson(), "责任人不能为空"); + if (model.getPerson().getId() == null) { + throw new ImppBusiException("责任人不能为空"); + } ValidatorBean.checkNotNull(model.getInventoryLocationCode(), "区域代码不能为空"); } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/TestController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/TestController.java index 29616a3..82b6dc9 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/TestController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/TestController.java @@ -5,6 +5,7 @@ import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipmentLogExtService; import cn.estsh.i3plus.ext.mes.pcn.apiservice.schedulejob.MesReportNoSortJob; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderService; import cn.estsh.i3plus.ext.mes.pcn.apiservice.schedulejob.MesReportWorkByPreDayJob; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.test.TestService; import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; import cn.estsh.i3plus.platform.common.convert.ConvertBean; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; @@ -50,6 +51,9 @@ public class TestController { @Autowired private IMesConfigService configService; + @Autowired + private TestService testService; + @GetMapping("/equipment/log/query") @ApiOperation(value = "查询设备交互") public ResultBean queryReworkTaskByPager(String organizeCode, Integer equipId) { @@ -123,4 +127,11 @@ public class TestController { mesReportWorkByPreDayJob.executeMesJob(null, null); } + + @GetMapping("/testInsert") + @ApiOperation(value = "批量") + public void testInsert() { + testService.insertList(); + + } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/mqtt/PcnMqttCallback.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/mqtt/PcnMqttCallback.java index 1f8ab8c..e8144a8 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/mqtt/PcnMqttCallback.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/mqtt/PcnMqttCallback.java @@ -4,6 +4,7 @@ import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesEquipmentLogService; import cn.estsh.i3plus.ext.mes.pcn.apiservice.config.MqttConfig; import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.SpringUtils; import cn.estsh.i3plus.ext.mes.pcn.pojo.mqtt.EquipLogMqttMsg; +import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesEquipmentLogService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesEquipmentLogService.java index bb441fa..16eb0e1 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesEquipmentLogService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesEquipmentLogService.java @@ -15,7 +15,9 @@ import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentLogDetail; import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentRecord; import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable; import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentLogDetailRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentLogRepository; import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentRecordRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentVariableRepository; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import cn.estsh.impp.framework.boot.util.ImppRedis; import lombok.extern.slf4j.Slf4j; @@ -39,12 +41,17 @@ public class MesEquipmentLogService implements IMesEquipmentLogService { public static final Logger LOGGER = LoggerFactory.getLogger(CommonConstWords.SYSTEM_LOG); @Autowired + private MesEquipmentVariableRepository equipmentVariableRepository; + + @Autowired private MesEquipmentLogExtService mesEquipmentLogExtService; @Autowired private MesEquipmentExtService mesEquipmentExtService; @Autowired private MesEquipmentLogDetailRepository mesEquipmentLogDetailRepository; @Autowired + private MesEquipmentLogRepository mesEquipmentLogRepository; + @Autowired private MesEquipmentRecordRepository mesEquipmentRecordRepository; @Autowired private SnowflakeIdMaker snowflakeIdMaker; @@ -148,6 +155,20 @@ public class MesEquipmentLogService implements IMesEquipmentLogService { @Override public void updateValue(EquipLogMqttMsg equipLogMqttMsg) { - mesEquipmentLogExtService.updateEquipmentLogValue("CK01", Integer.valueOf(equipLogMqttMsg.getPTCode()), Long.valueOf(equipLogMqttMsg.getTagAddress()), equipLogMqttMsg.getValue()); + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(); + DdlPreparedPack.getStringEqualPack(equipLogMqttMsg.getTagAddress(), "tagAddress", ddlPackBean); + MesEquipmentVariable mesEquipmentVariable = equipmentVariableRepository.getByProperty(ddlPackBean); + if (mesEquipmentVariable == null) { + LOGGER.info("tagAddress 不存在【{}】", equipLogMqttMsg.getTagAddress()); + } + MesEquipmentLog equipmentLog = mesEquipmentLogExtService.queryMesEquipmentLog(Integer.valueOf(equipLogMqttMsg.getPTCode()), mesEquipmentVariable.getId()); + ConvertBean.serviceModelUpdate(equipmentLog, "mqtt"); + mesEquipmentLogRepository.update(equipmentLog); + + MesEquipmentLogDetail mesEquipmentLogDetail = new MesEquipmentLogDetail(); + BeanUtils.copyProperties(equipmentLog, mesEquipmentLogDetail); + mesEquipmentLogDetail.setId(null); + mesEquipmentLogDetailRepository.save(mesEquipmentLogDetail); + } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesReworkTaskServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesReworkTaskServiceImpl.java index 5e92795..ddb636d 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesReworkTaskServiceImpl.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesReworkTaskServiceImpl.java @@ -301,6 +301,7 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { mesProductionRepeatAssembly.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_10.getValue()); mesProductionRepeatAssembly.setId(null); mesProductionRepeatAssembly.setIsOrigSn(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); + mesProductionRepeatAssembly.setFid(UUID.randomUUID().toString()); mesProductionAssembly.setRepeatAssemblySn(sn); mesProductionAssemblyRepository.update(mesProductionAssembly); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java index f670e31..dd148d4 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java @@ -89,6 +89,9 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService @Autowired private IMesProduceSnExtService produceSnExtService; + @Autowired + private MesProductVersionRepository productVersionRepository; + @Override public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel inputModel, String org) { @@ -821,8 +824,25 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService partInspectionRepository.save(partInspection); // + String source = configService.getCfgValue(org, "LGORT"); //移库 - MesMove move = createMove(model, configService.getCfgValue(org, "LGORT"), configService.getCfgValue(org, "UMLGO"), org); + String partNo = model.getPartNo(); + // 查询生产版本 + String workCenterCode = model.getWorkCenterCode(); + String productVersion = model.getProductVersion(); + + if (!StringUtils.isEmpty(productVersion)) { + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(); + DdlPreparedPack.getStringEqualPack(partNo, "partNo", ddlPackBean); + DdlPreparedPack.getStringEqualPack(workCenterCode, "workCenterCode", ddlPackBean); + DdlPreparedPack.getStringEqualPack(productVersion, "productVersion", ddlPackBean); + + MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); + if (version != null) { + source = version.getShipInventoryPoint(); + } + } + MesMove move = createMove(model, source, configService.getCfgValue(org, "UMLGO"), org); moveRepository.save(move); } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java index aa8188b..d533e33 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java @@ -95,6 +95,9 @@ public class MesNcProcessingService implements IMesNcProcessingService { private MesOrgRepository mesOrgRDao; @Autowired + private MesProductVersionRepository productVersionRepository; + + @Autowired private IMesProduceSnExtService produceSnExtService; @Override public ListPager queryPartInspectionByPager(MesPartInspection partInspection, Pager pager) { @@ -106,6 +109,8 @@ public class MesNcProcessingService implements IMesNcProcessingService { DdlPreparedPack.getStringEqualPack(partInspection.getLotNo(), "lotNo", packBean); DdlPreparedPack.getNumEqualPack(partInspection.getQty(), "qty", packBean); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), "inspectionStatus", packBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue(), "ncStatus", packBean); + DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean); pager = PagerHelper.getPager(pager, partInspectionRepository.findByHqlWhereCount(packBean)); @@ -327,6 +332,19 @@ public class MesNcProcessingService implements IMesNcProcessingService { private void saveDate(MesNcProcessingInputModel model, MesPartSap part, Integer type, MesDefectType person, String org,String areaCode, boolean isOrder) { + String source = configService.getCfgValue(org, "LGORT"); + if (!StringUtils.isEmpty(model.getProductVersion())) { + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(); + DdlPreparedPack.getStringEqualPack(model.getPart().getPartNo(), "partNo", ddlPackBean); + DdlPreparedPack.getStringEqualPack(model.getPartInspection().getWorkCenterCode(), "workCenterCode", ddlPackBean); + DdlPreparedPack.getStringEqualPack(model.getProductVersion(), "productVersion", ddlPackBean); + + MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); + if (version != null) { + source = version.getShipInventoryPoint(); + } + } + if (type == MesExtEnumUtil.NC_TYPE.NORMAL.getValue()) { //更新条码质量状态 @@ -419,13 +437,14 @@ public class MesNcProcessingService implements IMesNcProcessingService { ConvertBean.serviceModelUpdate(sn, model.getPartInspection().getModifyUser()); partInspectionRepository.save(model.getPartInspection()); if (isOrder) { - MesMove move = createMove(model, configService.getCfgValue(org, "UMLGO"), configService.getCfgValue(org, "SCRAP"), org,MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE); + MesMove move = createMove(model, source, configService.getCfgValue(org, "SCRAP"), org,MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE); moveRepository.save(move); - } - //移库 转报废 根据责任方库区对应关系的主数据,选择哪个责任方,就移动到哪个库区(8000移至8002/8003) - MesMove move = createMove(model, configService.getCfgValue(org, "UMLGO"), areaCode, org,MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE); + } else { + //移库 转报废 根据责任方库区对应关系的主数据,选择哪个责任方,就移动到哪个库区(8000移至8002/8003) + MesMove move = createMove(model, configService.getCfgValue(org, "UMLGO"), areaCode, org, MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE); // MesMove move = createMove(model, configService.getCfgValue(org, "UMLGO"), configService.getCfgValue(org, "SCRAP"), org); - moveRepository.save(move); + moveRepository.save(move); + } } else if (type == MesExtEnumUtil.NC_TYPE.RELEASE.getValue()) { diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkCellScanMonitorLogServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkCellScanMonitorLogServiceImpl.java index 6799e1e..677d642 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkCellScanMonitorLogServiceImpl.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkCellScanMonitorLogServiceImpl.java @@ -57,6 +57,7 @@ public class MesWorkCellScanMonitorLogServiceImpl implements IMesWorkCellScanMon for (Long mouldRecordId : mouldRecordIdList) { DdlPackBean recordPackBean = DdlPackBean.getDdlPackBean(organizeCode); DdlPreparedPack.getNumEqualPack(mouldRecordId, "mouldRecordId", recordPackBean); + List recordList = productionRecordRao.findByHqlWhere(recordPackBean); //需要补录如下字段 DdlPackBean monitorLogPackBean = DdlPackBean.getDdlPackBean(organizeCode); @@ -73,7 +74,6 @@ public class MesWorkCellScanMonitorLogServiceImpl implements IMesWorkCellScanMon new Object[]{workOrderNoStr, serialNoStr, productSnStr, custSnStr, partNoStr, partNameStr, TimeTool.getNowTime(true), "JOB", MesExtEnumUtil.MES_LOG_DEAL_STATUS.DEAL_SUCCESS.getValue(), newTimes}, monitorLogPackBean); } else { if (newTimes > times) { - monitorLogRao.updateByProperties(new String[]{"modifyDatetime", "modifyUser", "times"}, new Object[]{TimeTool.getNowTime(true), "JOB", newTimes}, monitorLogPackBean); } else { monitorLogRao.updateByProperties(new String[]{"modifyDatetime", "modifyUser", "times", "dealStatus"}, new Object[]{TimeTool.getNowTime(true), "JOB", newTimes, MesExtEnumUtil.MES_LOG_DEAL_STATUS.DEAL_FAILURE.getValue()}, monitorLogPackBean); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderExtService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderExtService.java index 140dc56..705e9a7 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderExtService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderExtService.java @@ -74,4 +74,12 @@ public class MesWorkOrderExtService implements IMesWorkOrderExtService { public void update(MesWorkOrder item) { workOrderRepository.update(item); } + + @Override + public List getWorkOrderListByShiftCode(String organizeCode, String workCenterCode, String shiftCode) { + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getStringEqualPack(workCenterCode, MesPcnExtConstWords.WORK_CENTER_CODE, packBean); + DdlPreparedPack.getStringEqualPack(shiftCode, MesPcnExtConstWords.SHIFT_CODE, packBean); + return workOrderRepository.findByHqlWhere(packBean); + } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java index e068f8a..ba7272b 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java @@ -554,8 +554,15 @@ public class MesWorkOrderService implements IMesWorkOrderService { //保存数据 List mesProductOffLineList = new ArrayList<>(); MesProductOffLine newMesProductOffLine; - - for (MesBom mesBom : mesBoms) { + // 排除重复的数据 + Map> map = mesBoms.stream().collect(Collectors.groupingBy(mesBom -> { + MesBom bom = new MesBom(); + bom.setPartNo(mesBom.getPartNo()); + bom.setItemPartNo(mesBom.getItemPartNo()); + return bom; + })); + for (Map.Entry> entry : map.entrySet()) { + MesBom mesBom = entry.getValue().get(0); newMesProductOffLine = new MesProductOffLine(); newMesProductOffLine.setReportPartNo(oldMesWorkOrder.getPartNo()); newMesProductOffLine.setReportPartNameRdd(oldMesWorkOrder.getPartName()); @@ -580,7 +587,6 @@ public class MesWorkOrderService implements IMesWorkOrderService { ConvertBean.serviceModelInitialize(newMesProductOffLine, userName); mesProductOffLineList.add(newMesProductOffLine); } - mesProductOffLineRDao.saveAll(mesProductOffLineList); // 同步工单信息给加工记录、条码信息 DdlPackBean snDdlPackBean = DdlPackBean.getDdlPackBean(); @@ -678,6 +684,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode); DdlPreparedPack.getStringEqualPack(productionRecord.getPartNo(), "partNo", ddlPackBean); + DdlPreparedPack.getStringEqualPack(productionRecord.getWorkCenterCode(), "workCenterCode", ddlPackBean); if (!StringUtils.isEmpty(productionRecord.getWorkOrderNo())) { DdlPreparedPack.getStringEqualPack(productionRecord.getWorkOrderNo(), "workOrderNo", ddlPackBean); @@ -687,7 +694,9 @@ public class MesWorkOrderService implements IMesWorkOrderService { // 新增班次逻辑 //DdlPreparedPack. List oldMesWorkOrders = workOrderRepository.findByHqlWhere(ddlPackBean); - + if (!CollectionUtils.isEmpty(oldMesWorkOrders)) { + oldMesWorkOrders = oldMesWorkOrders.stream().filter(mesWorkOrder -> !Objects.equals(MesExtEnumUtil.ORDER_TYPE_IDENTIFICATION.P.getValue(), mesWorkOrder.getOrderFlag())).collect(Collectors.toList()); + } return oldMesWorkOrders; } @@ -748,14 +757,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { if(!CollectionUtils.isEmpty(mesProductionRecordList)) { Map> map = mesProductionRecordList.stream().collect(Collectors.groupingBy(MesProductionRecord::getPartNo)); map.forEach((k, v) -> { - DdlPackBean packBean = DdlPackBean.getDdlPackBean(); - DdlPreparedPack.getStringEqualPack(k, "partNo", packBean); - // 排除掉试制造件 - MesPartSap part = partSapRepository.getByProperty(packBean); - if (part != null && !Objects.equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), part.getIsTestPiece())) { - recordList.add(v.get(0)); - } - LOGGER.info("sap物料中不存在该物料号【{}】, 或者是试制件,不进行报工"); + recordList.add(v.get(0)); }); } @@ -791,7 +793,6 @@ public class MesWorkOrderService implements IMesWorkOrderService { if (part != null && !Objects.equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), part.getIsTestPiece())) { recordList.add(v.get(0)); } - LOGGER.info("sap物料中不存在该物料号【{}】, 或者是试制件,不进行报工"); }); } return recordList; diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/equiplog/MesEquipmentLogExtService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/equiplog/MesEquipmentLogExtService.java index 3693f3e..ee4c111 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/equiplog/MesEquipmentLogExtService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/equiplog/MesEquipmentLogExtService.java @@ -67,7 +67,7 @@ public class MesEquipmentLogExtService implements IMesEquipmentLogExtService { DdlPreparedPack.getNumEqualPack(equipId, MesPcnExtConstWords.EQUIP_ID, packBean); DdlPreparedPack.getNumEqualPack(equipVariableId, MesPcnExtConstWords.EQUIP_VARIABLE_ID, packBean); - equipmentLogRepository.updateByProperties(new String[]{"equipVariableValue",MesPcnExtConstWords.EQUIP_VARIABLE_STATUS}, new Object[]{value, MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getValue()}, packBean); + equipmentLogRepository.updateByProperties(new String[]{"equipVariableValue",MesPcnExtConstWords.EQUIP_VARIABLE_STATUS}, new Object[]{value, MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getEquipVariableStatus()}, packBean); } @Override public Boolean checkEquipQuality(Integer quality) { @@ -87,8 +87,8 @@ public class MesEquipmentLogExtService implements IMesEquipmentLogExtService { //标记当前设备通信默认正常 cellEquipContext.setQuality(MesExtEnumUtil.EQUIP_LOG_QUALITY.defaultQuality()); //根据常变值分别获取设备ID分表的采集数据 - Map needNewValue2Collect = getEquipmentLog(equipLogDispatchContext, cellEquipContext, collectContextList, MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getValue()); - Map unNeedNewValue2Collect = getEquipmentLog(equipLogDispatchContext, cellEquipContext, collectContextList, MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.FALSE.getValue()); + Map> needNewValue2Collect = getEquipmentLog(equipLogDispatchContext, cellEquipContext, collectContextList, MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getValue()); + Map> unNeedNewValue2Collect = getEquipmentLog(equipLogDispatchContext, cellEquipContext, collectContextList, MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.FALSE.getValue()); //根据设备ID,设备数据变量ID集合 修改设备ID分表采集数据的状态 【修改常变值配置对应的设备ID分表的采集数据的状态为1】 【isResetEquipVariable = false 标记需要修改的设备数据变量ID, 后续匹配成功后再调用updateEquipmentLogList进行修改】 if (!CollectionUtils.isEmpty(needNewValue2Collect) && checkEquipQuality(cellEquipContext.getQuality())) { @@ -133,16 +133,16 @@ public class MesEquipmentLogExtService implements IMesEquipmentLogExtService { } - private MesEquipmentLog filterEquipmentLog(Map needNewValue2Collect, Map unNeedNewValue2Collect, Long equipVariableId, Integer needNewValue) { + private MesEquipmentLog filterEquipmentLog(Map> needNewValue2Collect, Map> unNeedNewValue2Collect, Long equipVariableId, Integer needNewValue) { if (!StringUtils.isEmpty(needNewValue) && MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getValue() == needNewValue) return filterEquipmentLog(needNewValue2Collect, equipVariableId); else return filterEquipmentLog(unNeedNewValue2Collect, equipVariableId); } - private MesEquipmentLog filterEquipmentLog(Map collectMap, Long equipVariableId) { - return !CollectionUtils.isEmpty(collectMap) ? collectMap.get(equipVariableId) : null; + private MesEquipmentLog filterEquipmentLog(Map> collectMap, Long equipVariableId) { + return (!CollectionUtils.isEmpty(collectMap) && collectMap.containsKey(equipVariableId)) ? collectMap.get(equipVariableId).get(0) : null; } - private Map getEquipmentLog(MesEquipLogDispatchContext equipLogDispatchContext, MesCellEquipContext cellEquipContext, List equipVariableCollectContextList, Integer needNewValue) { + private Map> getEquipmentLog(MesEquipLogDispatchContext equipLogDispatchContext, MesCellEquipContext cellEquipContext, List equipVariableCollectContextList, Integer needNewValue) { List filterList = equipVariableCollectContextList.stream().filter(o -> (null != o && o.getNeedNewValue().compareTo(needNewValue) == 0)).collect(Collectors.toList()); if (CollectionUtils.isEmpty(filterList)) return null; List equipmentLogList = getEquipmentLogList(cellEquipContext.getOrganizeCode(), cellEquipContext.getEquipId(), needNewValue, collectEquipVariableIdList(filterList)); @@ -152,7 +152,7 @@ public class MesEquipmentLogExtService implements IMesEquipmentLogExtService { //【已经采集到任何数据 或者 (equipmentLogList有数据且是长变值方式获取的 或者 不是常变值方式获取的但必须有value) 】 情况下isCollectValue标记为true if (equipLogDispatchContext.getIsCollectValue() || (!CollectionUtils.isEmpty(equipmentLogList) && (needNewValue == MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getValue() || checkEquipmentLogHasValue(equipmentLogList)))) equipLogDispatchContext.isCollectValue(); - return CollectionUtils.isEmpty(equipmentLogList) ? null : equipmentLogList.stream().filter(o -> null != o).collect(Collectors.toMap(MesEquipmentLog::getEquipVariableId, o -> o)); + return CollectionUtils.isEmpty(equipmentLogList) ? null : equipmentLogList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesEquipmentLog::getEquipVariableId)); } private Boolean checkEquipmentLogHasValue(List equipmentLogList) { @@ -170,4 +170,13 @@ public class MesEquipmentLogExtService implements IMesEquipmentLogExtService { return CollectionUtils.isEmpty(equipVariableIdList) ? null : equipVariableIdList.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList()); } + @Override + public MesEquipmentLog queryMesEquipmentLog(Integer equipId, Long equipVariableId) { + + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(); + DdlPreparedPack.getNumEqualPack(equipId, "equipId", ddlPackBean); + DdlPreparedPack.getNumEqualPack(equipVariableId, "equipVariableId", ddlPackBean); + + return equipmentLogRepository.getByProperty(ddlPackBean); + } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/MesProductionNoSortModuleService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/MesProductionNoSortModuleService.java index db1175e..089d2c4 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/MesProductionNoSortModuleService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/MesProductionNoSortModuleService.java @@ -4,6 +4,7 @@ import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdShiftRecordService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderExtService; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext; @@ -15,10 +16,7 @@ import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; -import cn.estsh.i3plus.pojo.mes.bean.MesFile; -import cn.estsh.i3plus.pojo.mes.bean.MesProdShiftRecord; -import cn.estsh.i3plus.pojo.mes.bean.MesStateMachineStatus; -import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell; +import cn.estsh.i3plus.pojo.mes.bean.*; import cn.estsh.i3plus.pojo.mes.model.AttrBean; import cn.estsh.i3plus.pojo.mes.model.StationKvBean; import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; @@ -40,6 +38,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.StringJoiner; +import java.util.function.BinaryOperator; /** * @Description : 展示组件:非排序生产 @@ -62,6 +61,9 @@ public class MesProductionNoSortModuleService extends BaseModuleService { private IMesProdShiftRecordService mesProdShiftRecordService; @Autowired + private IMesWorkOrderExtService workOrderExtService; + + @Autowired private MesFileRepository mesFileRepository; @Override @@ -93,7 +95,7 @@ public class MesProductionNoSortModuleService extends BaseModuleService { productionStatisticsContext = StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(), new StationKvBean(new StringJoiner(MesPcnExtConstWords.AND).add(mesProdShiftKvBean.getShiftGroup()).add(mesProdShiftKvBean.getShiftCode()).toString(), "加工数", "0"), new StationKvBean("color", "颜色", MesExtEnumUtil.COLOR.BLACK.getValue())); } - StationResultBean shiftCountBean = getStationResultBean(reqBean, productionStatisticsContext,mesWorkCell); + StationResultBean shiftCountBean = getStationResultBean(reqBean, productionStatisticsContext,mesWorkCell, mesProdShiftKvBean); this.sendMessage(reqBean, shiftCountBean); //验证工位是否锁定 @@ -143,7 +145,7 @@ public class MesProductionNoSortModuleService extends BaseModuleService { return attrBeanList; } - private StationResultBean getStationResultBean(StationRequestBean reqBean, List productionStatisticsContext, MesWorkCell mesWorkCell) { + private StationResultBean getStationResultBean(StationRequestBean reqBean, List productionStatisticsContext, MesWorkCell mesWorkCell, MesProdShiftContext mesProdShiftKvBean) { StationResultBean resultBean = new StationResultBean(); resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.MODULE_CUSTOM_CONTENT.getValue()); String dataType = MesPcnEnumUtil.STATION_DATA_TYPE.ECHART.getValue(); @@ -164,11 +166,21 @@ public class MesProductionNoSortModuleService extends BaseModuleService { } if (Objects.equal(MesExtEnumUtil.WORK_FILE_TYPE.HISTOGRAM.getValue(), mesWorkCell.getIsShowMsg())) { dataType = MesPcnEnumUtil.STATION_DATA_TYPE.ECHART.getValue(); + List workOrderList = workOrderExtService.getWorkOrderListByShiftCode(reqBean.getOrganizeCode(), mesWorkCell.getWorkCenterCode(), mesProdShiftKvBean.getShiftCode()); + if (CollectionUtils.isEmpty(workOrderList)) { + StationKvBeanUtil.addStationKvBeanList(orderQtyKvBeans, new ArrayList<>(), + new StationKvBean(MesPcnExtConstWords.QTY, "工单计划数", 0 + ""), + new StationKvBean(MesPcnExtConstWords.COMPLATED_QTY, "工单完成数", 0 + "")); + } else { + double qty = workOrderList.stream().map(MesWorkOrder::getQty).reduce((a, b) -> a + b).get(); + double complateQty = workOrderList.stream().map(MesWorkOrder::getCompleteQty).reduce((a, b) -> a + b).get(); + + StationKvBeanUtil.addStationKvBeanList(orderQtyKvBeans, new ArrayList<>(), + new StationKvBean(MesPcnExtConstWords.QTY, "工单计划数", qty + ""), + new StationKvBean(MesPcnExtConstWords.COMPLATED_QTY, "工单完成数", complateQty + "")); + } if (!CollectionUtils.isEmpty(productionPartContextList)) { - productionPartContextList.forEach(o -> StationKvBeanUtil.addStationKvBeanList(orderQtyKvBeans, new ArrayList<>(), - new StationKvBean(MesPcnExtConstWords.WORK_ORDER_NO, "工单号", o.getWorkOrderNo() + ""), - new StationKvBean(MesPcnExtConstWords.QTY, "工单计划数", o.getQty() + ""), - new StationKvBean(MesPcnExtConstWords.COMPLATED_QTY, "工单完成数", o.getCompleteQty() + ""))); + } resultBean.setResultList(orderQtyKvBeans); @@ -203,7 +215,7 @@ public class MesProductionNoSortModuleService extends BaseModuleService { return StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(), new StationKvBean("shiftGroup", "班组", record.getShiftGroup()), - new StationKvBean("shiftGroupName", "班组名称", record.getShiftGroup()), + new StationKvBean("shiftGroupName", "班组名称", record.getShiftGroupName()), new StationKvBean("shiftCode", "班次", record.getShiftCode()), new StationKvBean("shiftName", "班次名称", record.getShiftName())) ; diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblySaveNosortStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblySaveNosortStepService.java index 02019d6..d4d7bf1 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblySaveNosortStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblySaveNosortStepService.java @@ -25,6 +25,7 @@ import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.UUID; import java.util.stream.Collectors; /** @@ -139,6 +140,8 @@ public class MesAssemblySaveNosortStepService extends BaseStepService { productionAssembly.setOrganizeCode(reqBean.getOrganizeCode()); ConvertBean.serviceModelInitialize(productionAssembly, reqBean.getUserInfo()); + productionAssembly.setFid(UUID.randomUUID().toString()); + productionAssemblyRepository.insert(productionAssembly); if (!StringUtils.isEmpty(productionAssemblyNosortContext.getProductSnId())) productSnId.add(productionAssemblyNosortContext.getProductSnId()); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyShowNosortStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyShowNosortStepService.java index 0be8cde..3899344 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyShowNosortStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyShowNosortStepService.java @@ -484,7 +484,11 @@ public class MesAssemblyShowNosortStepService extends BaseStepService { productionDispatchContextStepService.deleteProductionPartContext(reqBean); productionDispatchContextStepService.deleteProdRuleDataContext(reqBean); productionProcessContextStepService.deleteFunctionChooseCavityOrderContext(reqBean); - productionDispatchContextStepService.deleteFirstMouldNoContext(reqBean); + if (productionDispatchContextStepService.checkFirstMouldNoIsExistContext(reqBean)) { + //存在头道模具号场景下 必须抛出异常 因为头道模具号的接口逻辑会配置非常变值,也就是每次返回回去都会拿到头道模具号 就会出现死循环线程 + productionDispatchContextStepService.deleteFirstMouldNoContext(reqBean); + foundExThrowNoShowMsg(); + } } return true; } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductResultErrorHandleStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductResultErrorHandleStepService.java index 02d0735..82e60a7 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductResultErrorHandleStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductResultErrorHandleStepService.java @@ -5,6 +5,7 @@ import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesInputDefectRecordService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNcProcessingService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService; +import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingInputModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionInputModel; @@ -28,6 +29,7 @@ import com.google.common.base.Objects; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.util.Arrays; @@ -35,6 +37,7 @@ import java.util.Date; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; /** * @Description : 加工异常处理工步 注释调整 @@ -76,8 +79,11 @@ public class MesProductResultErrorHandleStepService extends BaseStepService { } // 获取条码列表 List mesProduceSns = mesProductionDispatchContextStepService.getProductionPsOutContext(reqBean); + + List productionPartContexts = mesProductionDispatchContextStepService.getProductionPartContext(reqBean); + // 保存加工异常记录(NC判断记录) - saveProductResultException(reqBean, mesProduceSns, result); + saveProductResultException(reqBean, mesProduceSns,productionPartContexts, result); return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "加工异常处理成功"); @@ -90,9 +96,14 @@ public class MesProductResultErrorHandleStepService extends BaseStepService { * @param reqBean * @param mesProduceSns */ - private void saveProductResultException(StationRequestBean reqBean, List mesProduceSns, String result) { + private void saveProductResultException(StationRequestBean reqBean, List mesProduceSns, List productionPartContexts, String result) { String defectTypeCode = MesEnumUtil.DEFECT_TYPE_CODE.DETERMIND.getValue(); mesProduceSns.forEach(mesProduceSn -> { + String productVersion = null; + List mesProductionPartContextList = productionPartContexts.stream().filter(mesProductionPartContext -> Objects.equal(mesProduceSn.getForeignKey(),mesProductionPartContext.getForeignKey())).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(mesProductionPartContextList)) { + productVersion = mesProductionPartContextList.get(0).getProductVersion(); + } MesNcProcessingInputModel model = new MesNcProcessingInputModel(); MesDefectType mesDefectType = new MesDefectType(); mesDefectType.setBackDefect(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); @@ -135,6 +146,7 @@ public class MesProductResultErrorHandleStepService extends BaseStepService { mesPartInspectionDetail.setDefectTypeName(mesDefectType.getDefectTypeName()); model.setPartInspection(partInspection); model.setType(partInspection.getSourceType()); + model.setProductVersion(productVersion); if (Objects.equal(MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.PRODUCT_SCRAP.getValue(), result)) { model.setType(MesExtEnumUtil.NC_TYPE.SCRAP.getValue()); @@ -156,6 +168,8 @@ public class MesProductResultErrorHandleStepService extends BaseStepService { inspectModel.setWorkCenterCode(mesProduceSn.getWorkCenterCode()); inspectModel.setPartInspection(partInspection); inspectModel.setShiftCode(mesProduceSn.getShiftCode()); + inspectModel.setProductVersion(productVersion); + inputDefectRecordService.saveSusPartInspection(inspectModel, reqBean.getOrganizeCode()); } }); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepService.java index 447df49..d7370c2 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepService.java @@ -31,6 +31,7 @@ import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.UUID; import java.util.stream.Collectors; /** @@ -197,8 +198,10 @@ public class MesProductSnGenerateStepService extends BaseStepService { if (StringUtils.isEmpty(produceSn.getInWorkCenterTime())) produceSn.setInWorkCenterTime(produceSn.getModifyDatetime()); produceSn.setLotNo(produceSn.getModifyDatetime().substring(0, 10)); - if (StringUtils.isEmpty(produceSn.getId())) produceSn = produceSnExtService.insert(produceSn); - else produceSnExtService.update(produceSn); + if (StringUtils.isEmpty(produceSn.getId())) { + produceSn.setFid(UUID.randomUUID().toString()); + produceSn = produceSnExtService.insert(produceSn); + } else produceSnExtService.update(produceSn); return new MesProductionPsOutContext().copy(produceSn, prodRuleContext.getForeignKey()).isCalcCompleteQty(!StringUtils.isEmpty(produceSn.getWorkOrderNo()) && !isSamePart); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductionRecordGenerateStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductionRecordGenerateStepService.java index 32c5ff2..2951877 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductionRecordGenerateStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductionRecordGenerateStepService.java @@ -27,6 +27,7 @@ import org.springframework.util.StringUtils; import java.util.List; import java.util.Map; +import java.util.UUID; import java.util.stream.Collectors; /** @@ -144,6 +145,9 @@ public class MesProductionRecordGenerateStepService extends BaseStepService { ConvertBean.serviceModelInitialize(productionRecord, reqBean.getUserInfo()); productionRecord.setCompleteDateTime(productionRecord.getModifyDatetime()); + productionRecord.setFid(UUID.randomUUID().toString()); + productionRecord.setOneMouldMoreId(UUID.randomUUID().toString()); + productionRecord = productionRecordRepository.insert(productionRecord); if (null != prodRuleContext) prodRuleContextList.stream().filter(o -> (null != o && diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/test/TestService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/test/TestService.java new file mode 100644 index 0000000..dad2a25 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/test/TestService.java @@ -0,0 +1,6 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.test; + +public interface TestService { + + void insertList(); +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/test/TestServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/test/TestServiceImpl.java new file mode 100644 index 0000000..e07d598 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/test/TestServiceImpl.java @@ -0,0 +1,100 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.test; + +import cn.estsh.i3plus.platform.common.convert.ConvertBean; +import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker; +import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentLogDetail; +import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentLogDetailRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentLogRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.logging.Logger; + +@Service +public class TestServiceImpl implements TestService{ + + @Autowired + private MesEquipmentLogRepository equipmentLogRepository; + @Autowired + private MesEquipmentLogDetailRepository equipmentLogDetailRepository; + @Autowired + private SnowflakeIdMaker snowflakeIdMaker; + + private static ExecutorService executorService = new ThreadPoolExecutor(1, 10, + 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<>(200), r -> { + Thread thread = new Thread(r); + thread.setName("executorService--"+r.hashCode()); + return thread; + },new ThreadPoolExecutor.DiscardPolicy()); + + private static ExecutorService executorService2 = new ThreadPoolExecutor(1, 10, + 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<>(200), r -> { + Thread thread = new Thread(r); + thread.setName("executorService--"+r.hashCode()); + return thread; + },new ThreadPoolExecutor.DiscardPolicy()); + public void insertList() { + executorService = new ThreadPoolExecutor(1, 10, + 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<>(200), r -> { + Thread thread = new Thread(r); + thread.setName("executorService--"+r.hashCode()); + return thread; + },new ThreadPoolExecutor.DiscardPolicy()); + + executorService2 = new ThreadPoolExecutor(1, 10, + 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<>(200), r -> { + Thread thread = new Thread(r); + thread.setName("executorService--"+r.hashCode()); + return thread; + },new ThreadPoolExecutor.DiscardPolicy()); + List list = new ArrayList<>(); + + for (int i= 1; i< 10; i ++) { + executorService.execute(new Runnable() { + @Override + public void run() { + for (int j = 1; j < 500; j++) { + + executorService2.execute(new Runnable() { + @Override + public void run() { + MesEquipmentLogDetail equipmentLogDetail = new MesEquipmentLogDetail(); + ConvertBean.serviceModelInitialize(equipmentLogDetail, "test"); + equipmentLogDetail.setId(snowflakeIdMaker.nextId()); + equipmentLogDetail.setEquipVariableId(123123l); + equipmentLogDetail.setEquipVariableName("aaa"); + equipmentLogDetail.setReadWriteFlag(1); + equipmentLogDetail.setDataType("40"); + equipmentLogDetail.setEquipId(7); + equipmentLogDetail.setEquipmentCode("Foaming5#"); + list.add(equipmentLogDetail); + /* try { + Thread.sleep(50); + } catch (InterruptedException e) { + e.printStackTrace(); + }*/ + } + }); + } + } + }); + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + equipmentLogDetailRepository.saveAll(list); + + } + } +} diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionPartContext.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionPartContext.java index 74ee50a..8e3cede 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionPartContext.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionPartContext.java @@ -45,6 +45,9 @@ public class MesProductionPartContext implements Serializable { @ApiParam("完成数量【不能用于业务计算】") private Double completeQty; + @ApiParam("生产版本") + private String productVersion; + @ApiParam("设备代码") private String equipmentCode; diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesNcProcessingInputModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesNcProcessingInputModel.java index 0d8dae0..0e89103 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesNcProcessingInputModel.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesNcProcessingInputModel.java @@ -38,6 +38,9 @@ public class MesNcProcessingInputModel { @ApiParam("物料") private MesPartSap part; + @ApiParam("版本号") + private String productVersion; + @ApiParam("NC-零件检测详情") private List partInspectionDetailList; diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionInputModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionInputModel.java index 2c04b6f..edcad96 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionInputModel.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionInputModel.java @@ -49,6 +49,8 @@ public class MesPartInspectionInputModel { @ApiParam("是否返工单完成单据") private boolean transferFlg = false; + @ApiParam("版本号") + private String productVersion; @ApiParam("NC-零件检测-单据") private MesPartInspection partInspection;