diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesBusiController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesBusiController.java index 74311eb..dd51915 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesBusiController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesBusiController.java @@ -9,6 +9,7 @@ import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord; import cn.estsh.impp.framework.boot.exception.ImppBusiException; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.util.ResultBean; +import cn.estsh.impp.framework.boot.util.ValidatorBean; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -52,6 +53,8 @@ public class MesBusiController { @ApiOperation(value = "查询加工记录信息") public ResultBean queryMesProductionRecord(MesProductionRecord mesProductionRecord) { try { + ValidatorBean.checkNotNull(mesProductionRecord.getOrganizeCode(), "工厂代码不能为空"); + ValidatorBean.checkNotNull(mesProductionRecord.getProductSn(), "零件条码不能为空"); return ResultBean.success("查询成功").setResultList(mesProductionRecordService.findMesProductionRecordList(mesProductionRecord.getOrganizeCode(), mesProductionRecord.getProductSn())); } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProductionRecordService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProductionRecordService.java index 2856d62..ca22f8a 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProductionRecordService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProductionRecordService.java @@ -6,9 +6,7 @@ import cn.estsh.i3plus.platform.common.tool.TimeTool; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; -import cn.estsh.i3plus.pojo.mes.bean.MesCraft; -import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn; -import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord; +import cn.estsh.i3plus.pojo.mes.bean.*; import cn.estsh.i3plus.pojo.mes.model.MesProductionRecordModel; import cn.estsh.i3plus.pojo.mes.repository.*; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; @@ -18,10 +16,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -49,6 +44,12 @@ public class MesProductionRecordService implements IMesProductionRecordService { @Autowired private MesProduceSnRepository mesProduceSnRepository; + @Autowired + private MesWorkCenterRepository mesWorkCenterRepository; + + @Autowired + private MesWorkCellRepository mesWorkCellRepository; + @Override public List findProductionRecordList(String organizeCode, String productSn) { if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn)) return null; @@ -100,21 +101,25 @@ public class MesProductionRecordService implements IMesProductionRecordService { @Override public List findMesProductionRecordList(String organizeCode, String productSn) { - List productionRecordList = findProductionRecordList(organizeCode, productSn); + List productionRecordList = findProductionRecord(organizeCode, productSn); List mesProductionRecordModelList = new ArrayList<>(); if (!CollectionUtils.isEmpty(productionRecordList)) { + //数据查询 Map craftMap = getStringMesCraftMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getCraftCode).distinct().collect(Collectors.toList())); - Map produceSnMap = getStringMesProduceSn(organizeCode, productionRecordList.stream().map(MesProductionRecord::getSerialNumber).distinct().collect(Collectors.toList())); + Map produceSnMap = getStringMesProduceSnMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getSerialNumber).distinct().collect(Collectors.toList())); + Map mesWorkCenterMap = getStringMesWorkCenterMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getWorkCenterCode).distinct().collect(Collectors.toList())); + Map workCellMap = getStringMesWorkCellMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getWorkCellCode).distinct().collect(Collectors.toList())); + //数据组装 MesProductionRecordModel mesProductionRecordModel = null; for (MesProductionRecord mesProductionRecord : productionRecordList) { mesProductionRecordModel = new MesProductionRecordModel(); BeanUtils.copyProperties(mesProductionRecord, mesProductionRecordModel); - MesCraft mesCraft = Objects.isNull(craftMap) ? null : craftMap.get(mesProductionRecord.getCraftCode()); - mesProductionRecordModel.setCraftName(Objects.isNull(mesCraft) ? "" : mesCraft.getCraftName()); - MesProduceSn produceSn = Objects.isNull(produceSnMap) ? null : produceSnMap.get(mesProductionRecord.getSerialNumber()); - mesProductionRecordModel.setSnStatus(Objects.isNull(produceSn) ? 0 : produceSn.getSnStatus()); - mesProductionRecordModel.setSnStatusDesc(Objects.isNull(produceSn) ? "" :MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(produceSn.getSnStatus())); + mesProductionRecordModel.setCraftName(Objects.isNull(craftMap) || Objects.isNull(craftMap.get(mesProductionRecord.getCraftCode())) || StringUtils.isEmpty(mesProductionRecord.getCraftCode()) ? "" : craftMap.get(mesProductionRecord.getCraftCode()).getCraftName()); + mesProductionRecordModel.setSnStatus(Objects.isNull(produceSnMap.get(mesProductionRecord.getSerialNumber())) || StringUtils.isEmpty(mesProductionRecord.getSerialNumber()) ? 0 : produceSnMap.get(mesProductionRecord.getSerialNumber()).getSnStatus()); + mesProductionRecordModel.setSnStatusDesc(0 == mesProductionRecordModel.getSnStatus() ?"" : MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(mesProductionRecordModel.getSnStatus())); mesProductionRecordModel.setReportStatusDesc(MesExtEnumUtil.REPORT_STATUS.valueOfDescription(mesProductionRecordModel.getReportStatus())); + mesProductionRecordModel.setWorkCenterName(Objects.isNull(mesWorkCenterMap.get(mesProductionRecord.getWorkCenterCode())) || StringUtils.isEmpty(mesProductionRecord.getWorkCenterCode()) ? "" : mesWorkCenterMap.get(mesProductionRecord.getWorkCenterCode()).getWorkCenterName()); + mesProductionRecordModel.setWorkCellName(Objects.isNull(workCellMap.get(mesProductionRecord.getWorkCellCode())) || StringUtils.isEmpty(mesProductionRecord.getWorkCellCode()) ? "" : workCellMap.get(mesProductionRecord.getWorkCellCode()).getWorkCellName()); mesProductionRecordModelList.add(mesProductionRecordModel); } } @@ -123,7 +128,7 @@ public class MesProductionRecordService implements IMesProductionRecordService { private Map getStringMesCraftMap(String organizeCode, List craftCodeList) { DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); - DdlPreparedPack.getInPackList(craftCodeList, "craftCode",packBean); + DdlPreparedPack.getInPackList(craftCodeList, MesPcnExtConstWords.CRAFT_CODE,packBean); List craftList = mesCraftRepository.findByHqlWhere(packBean); Map craftMap = null; if(!CollectionUtils.isEmpty(craftList)){ @@ -132,14 +137,57 @@ public class MesProductionRecordService implements IMesProductionRecordService { return craftMap; } - private Map getStringMesProduceSn(String organizeCode, List snList) { + private Map getStringMesProduceSnMap(String organizeCode, List snList) { DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); - DdlPreparedPack.getInPackList(snList, "serialNumber",packBean); + DdlPreparedPack.getInPackList(snList, MesPcnExtConstWords.SERIAL_NUMBER,packBean); List mesProduceSns = mesProduceSnRepository.findByHqlWhere(packBean); - Map mesProduceSnMap = null; + Map mesProduceSnMap = new HashMap<>(); if(!CollectionUtils.isEmpty(mesProduceSns)){ - mesProduceSnMap = mesProduceSns.stream().collect(Collectors.toMap(MesProduceSn::getSerialNumber, t -> t)); + for (MesProduceSn mesProduceSn : mesProduceSns) { + if(!mesProduceSnMap.containsKey(mesProduceSn.getSerialNumber())){ + mesProduceSnMap.put(mesProduceSn.getSerialNumber(),mesProduceSn); + } + } } return mesProduceSnMap; } + + + private Map getStringMesWorkCenterMap(String organizeCode, List workCenterNoList) { + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getInPackList(workCenterNoList, MesPcnExtConstWords.WORK_CENTER_CODE,packBean); + List mesWorkCenterList = mesWorkCenterRepository.findByHqlWhere(packBean); + Map mesWorkCenterMap = new HashMap<>(); + if(!CollectionUtils.isEmpty(mesWorkCenterList)){ + for (MesWorkCenter workCenter : mesWorkCenterList) { + if(!mesWorkCenterMap.containsKey(workCenter.getWorkCenterCode())){ + mesWorkCenterMap.put(workCenter.getWorkCenterCode(),workCenter); + } + } + } + return mesWorkCenterMap; + } + + private Map getStringMesWorkCellMap(String organizeCode, List workCenterNoList) { + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getInPackList(workCenterNoList, MesPcnExtConstWords.WORK_CELL_CODE,packBean); + List mesWorkCellList = mesWorkCellRepository.findByHqlWhere(packBean); + Map mesProduceSnMap = new HashMap<>(); + if(!CollectionUtils.isEmpty(mesWorkCellList)){ + for (MesWorkCell mesWorkCell : mesWorkCellList) { + if(!mesProduceSnMap.containsKey(mesWorkCell.getWorkCellCode())){ + mesProduceSnMap.put(mesWorkCell.getWorkCellCode(),mesWorkCell); + } + } + } + return mesProduceSnMap; + } + + public List findProductionRecord(String organizeCode, String productSn) { + if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn)) return null; + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getStringEqualPack(productSn,MesPcnExtConstWords.PRODUCT_SN,packBean); + DdlPreparedPack.getOrderBy(MesPcnExtConstWords.CREATE_DATE_TIME,CommonEnumUtil.ASC_OR_DESC.DESC.getValue(),packBean); + return productionRecordRepository.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 39aaeaa..3b47972 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 @@ -977,7 +977,8 @@ public class MesWorkOrderService implements IMesWorkOrderService { //更新工单 updateMesWorkOrder(mesWorkOrderDb,userName); //记录条码表&加工记录表 - insertMesProductionRecord(insertMesProduceSn(mesPart, sn, userName, mesWorkOrder),mesWorkOrderDb); + //insertMesProductionRecord(insertMesProduceSn(mesPart, sn, userName, mesWorkOrder),mesWorkOrderDb); + insertMesProduceSn(mesPart, sn, userName, mesWorkOrder); //试制单不报工 if(Objects.isNull(mesWorkOrderDb.getOrderFlag()) || !MesExtEnumUtil.ORDER_TYPE_IDENTIFICATION.P.getValue().equals(mesWorkOrderDb.getOrderFlag())){ //保存数据