From 77b8304de0d6ac8f6a8e9113595df525feaec5a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E7=AC=91=E7=9D=80=E9=9D=A2=E5=AF=B9=E6=98=8E?= =?UTF-8?q?=E5=A4=A9?= <752558143@qq.com> Date: Sun, 14 Jul 2024 14:06:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E5=B7=A5=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pcn/api/busi/IMesInputDefectRecordService.java | 8 +- .../ext/mes/pcn/apiservice/config/MqttConfig.java | 2 - .../apiservice/controller/busi/TestController.java | 11 +++ .../busi/MesInputDefectRecordService.java | 22 ++++- .../serviceimpl/busi/MesNcProcessingService.java | 27 ++++-- .../busi/MesWorkCellScanMonitorLogServiceImpl.java | 2 +- .../serviceimpl/busi/MesWorkOrderService.java | 27 +++--- .../equiplog/MesEquipmentLogExtService.java | 2 +- .../station/MesProductionNoSortModuleService.java | 2 +- .../MesProductResultErrorHandleStepService.java | 18 +++- .../apiservice/serviceimpl/test/TestService.java | 6 ++ .../serviceimpl/test/TestServiceImpl.java | 100 +++++++++++++++++++++ .../pcn/pojo/context/MesProductionPartContext.java | 3 + .../pcn/pojo/model/MesNcProcessingInputModel.java | 3 + .../pojo/model/MesPartInspectionInputModel.java | 2 + 15 files changed, 205 insertions(+), 30 deletions(-) create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/test/TestService.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/test/TestServiceImpl.java 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-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/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/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 ab2cdb5..7bbaf1b 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) { @@ -327,6 +330,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()) { //更新条码质量状态 @@ -417,13 +433,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/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 ca5a385..98c7557 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) { 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..c713094 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 @@ -203,7 +203,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/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/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;