diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesProdOrgExtService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesProdOrgExtService.java index e5b08f3..e9049d1 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesProdOrgExtService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesProdOrgExtService.java @@ -1,11 +1,13 @@ package cn.estsh.i3plus.ext.mes.pcn.api.base; +import cn.estsh.i3plus.pojo.mes.bean.MesCraft; import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell; import cn.estsh.i3plus.pojo.mes.bean.MesWorkCellExtendCfg; import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter; import io.swagger.annotations.ApiOperation; import java.util.List; +import java.util.Map; public interface IMesProdOrgExtService { @@ -24,6 +26,24 @@ public interface IMesProdOrgExtService { @ApiOperation(value = "根据生产线代码查询工位信息") List getWorkCellList(String organizeCode, String workCenterCode); + @ApiOperation(value = "根据生产线代码查询生产线信息") + List getWorkCenterList(String organizeCode, List workCenterCodeList); + + @ApiOperation(value = "根据生产线代码查询生产线信息") + Map getWorkCenterCodeMap(String organizeCode, List workCenterCodeList); + + @ApiOperation(value = "根据工位代码查询工位信息") + List getWorkCellList(String organizeCode, List workCellCodeList); + + @ApiOperation(value = "根据工位代码查询工位信息") + Map getWorkCellCodeMap(String organizeCode, List workCellCodeList); + + @ApiOperation(value = "根据工艺代码查询工艺信息") + List getCraftList(String organizeCode, List craftCodeList); + + @ApiOperation(value = "根据工艺代码查询工艺信息") + Map getCraftCodeMap(String organizeCode, List craftCodeList); + @ApiOperation(value = "根据子生产线代码,子工位代码,关系类型查询主子工位关系信息") MesWorkCellExtendCfg getWorkCellExtendCfg(String organizeCode, String workCenterCodeBak, String workCellCodeBak, Integer extendType); diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProduceSnExtService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProduceSnExtService.java index 9d89691..3948785 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProduceSnExtService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProduceSnExtService.java @@ -18,6 +18,9 @@ public interface IMesProduceSnExtService { @ApiOperation(value = "根据零件条码查询零件条码信息") List getProduceSnList(String organizeCode, String productSn); + @ApiOperation(value = "根据零件条码查询零件条码信息, 创建时间倒序") + List getProduceSnListCreateDatetimeDesc(String organizeCode, String productSn); + @ApiOperation(value = "根据客户条码查询零件条码信息[排序]") MesProduceSn getProduceSnByCustSn(String organizeCode, String custSn); diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionRecordService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionRecordService.java index 7d1aad7..3717001 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionRecordService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionRecordService.java @@ -2,6 +2,7 @@ package cn.estsh.i3plus.ext.mes.pcn.api.busi; import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord; import cn.estsh.i3plus.pojo.mes.model.MesProductionRecordModel; +import cn.estsh.impp.framework.boot.util.ResultBean; import io.swagger.annotations.ApiOperation; import java.util.List; @@ -18,6 +19,9 @@ public interface IMesProductionRecordService { @ApiOperation(value = "根据零件条码查询加工记录信息") List findProductionRecordList(String organizeCode, String productSn); + @ApiOperation(value = "查询加工记录, 根据完成时间倒序") + List findProductionRecordListCompleteDateTimeDesc(String organizeCode, String productSn); + @ApiOperation(value = "根据零件条码,零件编码查询加工记录信息") List findProductionRecordList(String organizeCode, String productSn, String partNo); @@ -34,8 +38,8 @@ public interface IMesProductionRecordService { void updateProductionRecord(String organizeCode, String userName, Long id, String errorMsg); - @ApiOperation(value = "根据零件条码查询加工记录信息") - List findMesProductionRecordList(String organizeCode, String productSn); + @ApiOperation(value = "查询加工记录信息PDA报表") + ResultBean queryMesProductionRecordReport(String organizeCode, String productSn); @ApiOperation(value = "更新加工记录") void updateProductionRecord(List recordList,String userName,Integer reportStatus,String msg); 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 bf6f2ae..03f802d 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 @@ -63,12 +63,12 @@ public class MesBusiController { } @GetMapping("/mesProductionRecord/query") - @ApiOperation(value = "查询加工记录信息") - public ResultBean queryMesProductionRecord(MesProductionRecord mesProductionRecord) { + @ApiOperation(value = "查询加工记录信息PDA报表") + public ResultBean queryMesProductionRecordReport(MesProductionRecord mesProductionRecord) { try { ValidatorBean.checkNotNull(mesProductionRecord.getOrganizeCode(), "工厂代码不能为空"); ValidatorBean.checkNotNull(mesProductionRecord.getProductSn(), "零件条码不能为空"); - return ResultBean.success("查询成功").setResultList(mesProductionRecordService.findMesProductionRecordList(mesProductionRecord.getOrganizeCode(), mesProductionRecord.getProductSn())); + return mesProductionRecordService.queryMesProductionRecordReport(mesProductionRecord.getOrganizeCode(), mesProductionRecord.getProductSn()); } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); } catch (Exception e) { diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesProdOrgExtService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesProdOrgExtService.java index 77b33e0..30749c1 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesProdOrgExtService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesProdOrgExtService.java @@ -2,11 +2,14 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base; import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdOrgExtService; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; +import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; -import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable; +import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; +import cn.estsh.i3plus.pojo.mes.bean.MesCraft; import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell; import cn.estsh.i3plus.pojo.mes.bean.MesWorkCellExtendCfg; import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter; +import cn.estsh.i3plus.pojo.mes.repository.MesCraftRepository; import cn.estsh.i3plus.pojo.mes.repository.MesWorkCellExtendCfgRepository; import cn.estsh.i3plus.pojo.mes.repository.MesWorkCellRepository; import cn.estsh.i3plus.pojo.mes.repository.MesWorkCenterRepository; @@ -31,6 +34,9 @@ public class MesProdOrgExtService implements IMesProdOrgExtService { private MesWorkCellRepository workCellRepository; @Autowired + private MesCraftRepository craftRepository; + + @Autowired private MesWorkCellExtendCfgRepository workCellExtendCfgRepository; @Override @@ -77,6 +83,71 @@ public class MesProdOrgExtService implements IMesProdOrgExtService { } @Override + public List getWorkCenterList(String organizeCode, List workCenterCodeList) { + if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(workCenterCodeList)) return null; + if (workCenterCodeList.size() != 1) workCenterCodeList = workCenterCodeList.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList()); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + if (workCenterCodeList.size() == 1) DdlPreparedPack.getStringEqualPack(workCenterCodeList.get(0), MesPcnExtConstWords.WORK_CENTER_CODE, packBean); + else DdlPreparedPack.getInPackList(workCenterCodeList, MesPcnExtConstWords.WORK_CENTER_CODE, packBean); + return workCenterRepository.findByHqlWhere(packBean); + } + + @Override + public Map getWorkCenterCodeMap(String organizeCode, List workCenterCodeList) { + if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(workCenterCodeList)) return null; + List workCenterList = getWorkCenterList(organizeCode, workCenterCodeList); + if (CollectionUtils.isEmpty(workCenterList)) return null; + workCenterList = workCenterList.stream().filter(o -> null != o).distinct().collect( + Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(MesWorkCenter::getWorkCenterCode))), ArrayList::new) + ); + return workCenterList.stream().filter(o -> null != o).collect(Collectors.toMap(MesWorkCenter::getWorkCenterCode, MesWorkCenter::getWorkCenterName)); + } + + @Override + public List getWorkCellList(String organizeCode, List workCellCodeList) { + if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(workCellCodeList)) return null; + if (workCellCodeList.size() != 1) workCellCodeList = workCellCodeList.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList()); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + if (workCellCodeList.size() == 1) DdlPreparedPack.getStringEqualPack(workCellCodeList.get(0), MesPcnExtConstWords.WORK_CELL_CODE, packBean); + else DdlPreparedPack.getInPackList(workCellCodeList, MesPcnExtConstWords.WORK_CELL_CODE, packBean); + return workCellRepository.findByHqlWhere(packBean); + } + + @Override + public Map getWorkCellCodeMap(String organizeCode, List workCellCodeList) { + if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(workCellCodeList)) return null; + List workCellList = getWorkCellList(organizeCode, workCellCodeList); + if (CollectionUtils.isEmpty(workCellList)) return null; + workCellList = workCellList.stream().filter(o -> null != o).distinct().collect( + Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing( + o -> new StringJoiner(MesPcnExtConstWords.AND).add(o.getWorkCenterCode()).add(o.getWorkCellCode()).toString()))), ArrayList::new) + ); + return workCellList.stream().filter(o -> null != o).collect(Collectors.toMap( + o -> new StringJoiner(MesPcnExtConstWords.AND).add(o.getWorkCenterCode()).add(o.getWorkCellCode()).toString(), MesWorkCell::getWorkCellName)); + } + + @Override + public List getCraftList(String organizeCode, List craftCodeList) { + if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(craftCodeList)) return null; + if (craftCodeList.size() != 1) craftCodeList = craftCodeList.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList()); + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + if (craftCodeList.size() == 1) DdlPreparedPack.getStringEqualPack(craftCodeList.get(0), MesPcnExtConstWords.CRAFT_CODE, packBean); + else DdlPreparedPack.getInPackList(craftCodeList, MesPcnExtConstWords.CRAFT_CODE, packBean); + return craftRepository.findByHqlWhere(packBean); + } + + @Override + public Map getCraftCodeMap(String organizeCode, List craftCodeList) { + if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(craftCodeList)) return null; + List craftList = getCraftList(organizeCode, craftCodeList); + if (CollectionUtils.isEmpty(craftList)) return null; + craftList = craftList.stream().filter(o -> null != o).distinct().collect( + Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(MesCraft::getCraftCode))), ArrayList::new) + ); + return craftList.stream().filter(o -> null != o).collect(Collectors.toMap(MesCraft::getCraftCode, MesCraft::getCraftName)); + } + + @Override public MesWorkCellExtendCfg getWorkCellExtendCfg(String organizeCode, String workCenterCodeBak, String workCellCodeBak, Integer extendType) { if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workCenterCodeBak) || StringUtils.isEmpty(workCellCodeBak) || StringUtils.isEmpty(extendType)) return null; return workCellExtendCfgRepository.getByProperty( diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnExtService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnExtService.java index 0708879..724d978 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnExtService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnExtService.java @@ -11,6 +11,7 @@ import cn.estsh.i3plus.pojo.base.common.PagerHelper; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn; +import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord; import cn.estsh.i3plus.pojo.mes.bean.MesQueueOrder; import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository; @@ -49,6 +50,7 @@ public class MesProduceSnExtService implements IMesProduceSnExtService { return produceSnRepository.findByHqlWhere(packBean); } + //根据零件条码查询零件条码信息 @Override public List getProduceSnList(String organizeCode, String productSn) { @@ -60,6 +62,15 @@ public class MesProduceSnExtService implements IMesProduceSnExtService { return produceSnRepository.findByHqlWhere(packBean); } + //根据零件条码查询零件条码信息, 创建时间倒序 + @Override + public List getProduceSnListCreateDatetimeDesc(String organizeCode, String productSn) { + List produceSnList = getProduceSnList(organizeCode, productSn); + if (CollectionUtils.isEmpty(produceSnList)) return produceSnList; + return produceSnList.stream().filter(o -> null != o).sorted(Comparator.comparing(MesProduceSn::getCreateDatetime).reversed()).collect(Collectors.toList()); + } + + //根据客户条码查询零件条码信息[排序] @Override public MesProduceSn getProduceSnByCustSn(String organizeCode, String custSn) { @@ -71,6 +82,7 @@ public class MesProduceSnExtService implements IMesProduceSnExtService { return produceSnRepository.getByProperty(packBean); } + //根据产品条码查询零件条码信息[排序] @Override public MesProduceSn getProduceSn(String organizeCode, String productSn, String workOrderNo) { 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 ffd667b..37a5864 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 @@ -1,5 +1,7 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi; +import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdOrgExtService; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionRecordService; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.platform.common.convert.ConvertBean; @@ -7,11 +9,11 @@ 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.*; -import cn.estsh.i3plus.pojo.mes.model.MesProductionRecordModel; +import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn; +import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord; import cn.estsh.i3plus.pojo.mes.repository.*; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; -import org.springframework.beans.BeanUtils; +import cn.estsh.impp.framework.boot.util.ResultBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -31,6 +33,12 @@ import java.util.stream.Collectors; public class MesProductionRecordService implements IMesProductionRecordService { @Autowired + private IMesProduceSnExtService produceSnExtService; + + @Autowired + private IMesProdOrgExtService prodOrgExtService; + + @Autowired private MesTimeEfficientCfgRepository timeEfficientCfgRepository; @Autowired @@ -59,6 +67,14 @@ public class MesProductionRecordService implements IMesProductionRecordService { new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), productSn}); } + //查询加工记录, 根据完成时间倒序 + @Override + public List findProductionRecordListCompleteDateTimeDesc(String organizeCode, String productSn) { + List productionRecordList = findProductionRecordList(organizeCode, productSn); + if (CollectionUtils.isEmpty(productionRecordList)) return productionRecordList; + return productionRecordList.stream().filter(o -> null != o).sorted(Comparator.comparing(MesProductionRecord::getCompleteDateTime).reversed()).collect(Collectors.toList()); + } + @Override public List findProductionRecordList(String organizeCode, String productSn, String partNo) { if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn) || StringUtils.isEmpty(partNo)) return null; @@ -114,30 +130,113 @@ public class MesProductionRecordService implements IMesProductionRecordService { } @Override - public List findMesProductionRecordList(String organizeCode, String 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 = getStringMesProduceSnMap(organizeCode, productSn); - 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); - 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); + public ResultBean queryMesProductionRecordReport(String organizeCode, String productSn) { + + //查询条码信息, 根据创建时间倒序 + List produceSnList = produceSnExtService.getProduceSnListCreateDatetimeDesc(organizeCode, productSn); + + if (CollectionUtils.isEmpty(produceSnList)) return ResultBean.fail(String.format("零件条码[%s]信息不存在!", productSn)); + + MesProduceSn produceSnDb = produceSnList.get(0); + + //查询加工记录, 根据完成时间倒序 + List productionRecordList = findProductionRecordListCompleteDateTimeDesc(organizeCode, productSn); + + //查询生产线名称 + Map workCenterCodeMap = getProductionRecordReportCenterMap(organizeCode, produceSnDb.getWorkCenterCode(), productionRecordList); + //查询工位名称 + Map workCellCodeMap = getProductionRecordReportCellMap(organizeCode, produceSnDb.getWorkCellCode(), productionRecordList); + //查询工艺名称 + Map craftCodeMap = getProductionRecordReportCraftMap(organizeCode, produceSnDb.getCraftCode(), productionRecordList); + + Map produceSnMap = new HashMap<>(); + produceSnMap.put(MesPcnExtConstWords.PRODUCT_SN, productSn); + produceSnMap.put(MesPcnExtConstWords.PART_NO, produceSnDb.getPartNo()); + produceSnMap.put(MesPcnExtConstWords.PART_NAME, produceSnDb.getPartName()); + produceSnMap.put(MesPcnExtConstWords.WORK_CENTER_CODE, produceSnDb.getWorkCenterCode()); + produceSnMap.put(MesPcnExtConstWords.WORK_CELL_CODE, produceSnDb.getWorkCellCode()); + produceSnMap.put(MesPcnExtConstWords.CRAFT_CODE, produceSnDb.getCraftCode()); + produceSnMap.put(MesPcnExtConstWords.WORK_CENTER_NAME, getMap2Value(workCenterCodeMap, produceSnDb.getWorkCenterCode())); + produceSnMap.put(MesPcnExtConstWords.WORK_CELL_NAME, getMap2Value(workCellCodeMap, getCellCodeSuffix(produceSnDb.getWorkCenterCode(), produceSnDb.getWorkCellCode()))); + produceSnMap.put(MesPcnExtConstWords.CRAFT_NAME, getMap2Value(craftCodeMap, produceSnDb.getCraftCode())); + produceSnMap.put(MesPcnExtConstWords.SN_STATUS, produceSnDb.getSnStatus()); + produceSnMap.put(MesPcnExtConstWords.QC_STATUS, produceSnDb.getQcStatus()); + produceSnMap.put(MesPcnExtConstWords.SN_STATUS_NAME, MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(produceSnDb.getSnStatus())); + produceSnMap.put(MesPcnExtConstWords.QC_STATUS_NAME, MesExtEnumUtil.PRODUCE_QC_STATUS.valueOfDescription(produceSnDb.getQcStatus())); + produceSnMap.put(MesPcnExtConstWords.MODIFY_USER, produceSnDb.getModifyUser()); + produceSnMap.put(MesPcnExtConstWords.MODIFY_DATE_TIME, produceSnDb.getModifyDatetime()); + + ResultBean resultBean = ResultBean.success("查询成功!").setResultObject(produceSnMap); + + if (CollectionUtils.isEmpty(productionRecordList)) return resultBean; + + Map> produceSnMap2Part = produceSnList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPartNo()))).collect(Collectors.groupingBy(MesProduceSn::getPartNo)); + + List> productionRecordMapList = new ArrayList<>(); + + MesProduceSn produceSnItem; + for (MesProductionRecord productionRecord : productionRecordList) { + if (null == productionRecord) continue; + Map productionRecordMap = new HashMap<>(); + productionRecordMap.put(MesPcnExtConstWords.PRODUCT_SN, productSn); + productionRecordMap.put(MesPcnExtConstWords.PART_NO, productionRecord.getPartNo()); + productionRecordMap.put(MesPcnExtConstWords.PART_NAME, productionRecord.getPartName()); + productionRecordMap.put(MesPcnExtConstWords.WORK_CENTER_CODE, productionRecord.getWorkCenterCode()); + productionRecordMap.put(MesPcnExtConstWords.WORK_CELL_CODE, productionRecord.getWorkCellCode()); + productionRecordMap.put(MesPcnExtConstWords.CRAFT_CODE, productionRecord.getCraftCode()); + productionRecordMap.put(MesPcnExtConstWords.WORK_CENTER_NAME, getMap2Value(workCenterCodeMap, productionRecord.getWorkCenterCode())); + productionRecordMap.put(MesPcnExtConstWords.WORK_CELL_NAME, getMap2Value(workCellCodeMap, getCellCodeSuffix(productionRecord.getWorkCenterCode(), productionRecord.getWorkCellCode()))); + productionRecordMap.put(MesPcnExtConstWords.CRAFT_NAME, getMap2Value(craftCodeMap, productionRecord.getCraftCode())); + if (!CollectionUtils.isEmpty(produceSnMap2Part) && !StringUtils.isEmpty(productionRecord.getPartNo()) && produceSnMap2Part.containsKey(productionRecord.getPartNo())) { + produceSnItem = produceSnMap2Part.get(productionRecord.getPartNo()).get(0); + productionRecordMap.put(MesPcnExtConstWords.SN_STATUS, produceSnItem.getSnStatus()); + productionRecordMap.put(MesPcnExtConstWords.QC_STATUS, produceSnItem.getQcStatus()); + productionRecordMap.put(MesPcnExtConstWords.SN_STATUS_NAME, !StringUtils.isEmpty(produceSnItem.getSnStatus()) ? MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(produceSnItem.getSnStatus()) : MesPcnExtConstWords.EMPTY); + productionRecordMap.put(MesPcnExtConstWords.QC_STATUS_NAME, !StringUtils.isEmpty(produceSnItem.getQcStatus()) ? MesExtEnumUtil.PRODUCE_QC_STATUS.valueOfDescription(produceSnItem.getQcStatus()) : MesPcnExtConstWords.EMPTY); } + productionRecordMap.put(MesPcnExtConstWords.COMPLETE_DATE_TIME, productionRecord.getCompleteDateTime()); + productionRecordMap.put(MesPcnExtConstWords.CREATE_USER, productionRecord.getCreateUser()); + productionRecordMap.put(MesPcnExtConstWords.REPORT_STATUS, productionRecord.getReportStatus()); + productionRecordMap.put(MesPcnExtConstWords.REPORT_STATUS_NAME, !StringUtils.isEmpty(productionRecord.getReportStatus()) ? MesExtEnumUtil.REPORT_STATUS.valueOfDescription(productionRecord.getReportStatus()) : MesPcnExtConstWords.EMPTY); + productionRecordMapList.add(productionRecordMap); } - return mesProductionRecordModelList; + + return resultBean.setResultList(productionRecordMapList); + } + + private String getCellCodeSuffix(String workCenterCode, String workCellCode) { + if (StringUtils.isEmpty(workCenterCode) || StringUtils.isEmpty(workCellCode)) return null; + return new StringJoiner(MesPcnExtConstWords.AND).add(workCenterCode).add(workCellCode).toString(); + } + + private String getMap2Value(Map map, String key) { + if (StringUtils.isEmpty(key)) return MesPcnExtConstWords.EMPTY; + if (CollectionUtils.isEmpty(map) || !map.containsKey(key)) return MesPcnExtConstWords.EMPTY; + return map.get(key); + } + + private Map getProductionRecordReportCenterMap(String organizeCode, String workCenterCode, List productionRecordList) { + List workCenterCodeList = CollectionUtils.isEmpty(productionRecordList) ? null : + productionRecordList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getWorkCenterCode()))).map(MesProductionRecord::getWorkCenterCode).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(workCenterCodeList) && !StringUtils.isEmpty(workCenterCode)) workCenterCodeList = new ArrayList<>(); + if (!StringUtils.isEmpty(workCenterCode)) workCenterCodeList.add(workCenterCode); + return prodOrgExtService.getWorkCenterCodeMap(organizeCode, workCenterCodeList); + } + + private Map getProductionRecordReportCellMap(String organizeCode, String workCellCode, List productionRecordList) { + List workCellCodeList = CollectionUtils.isEmpty(productionRecordList) ? null : + productionRecordList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getWorkCellCode()))).map(MesProductionRecord::getWorkCellCode).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(workCellCodeList) && !StringUtils.isEmpty(workCellCode)) workCellCodeList = new ArrayList<>(); + if (!StringUtils.isEmpty(workCellCode)) workCellCodeList.add(workCellCode); + return prodOrgExtService.getWorkCellCodeMap(organizeCode, workCellCodeList); + } + + private Map getProductionRecordReportCraftMap(String organizeCode, String craftCode, List productionRecordList) { + List craftCodeList = CollectionUtils.isEmpty(productionRecordList) ? null : + productionRecordList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getCraftCode()))).map(MesProductionRecord::getCraftCode).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(craftCodeList) && !StringUtils.isEmpty(craftCode)) craftCodeList = new ArrayList<>(); + if (!StringUtils.isEmpty(craftCode)) craftCodeList.add(craftCode); + return prodOrgExtService.getCraftCodeMap(organizeCode, craftCodeList); } @Override @@ -152,68 +251,4 @@ public class MesProductionRecordService implements IMesProductionRecordService { productionRecordRepository.saveAll(recordList); } - private Map getStringMesCraftMap(String organizeCode, List craftCodeList) { - DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); - DdlPreparedPack.getInPackList(craftCodeList, MesPcnExtConstWords.CRAFT_CODE,packBean); - List craftList = mesCraftRepository.findByHqlWhere(packBean); - Map craftMap = null; - if(!CollectionUtils.isEmpty(craftList)){ - craftMap = craftList.stream().collect(Collectors.toMap(MesCraft::getCraftCode, t -> t)); - } - return craftMap; - } - - private Map getStringMesProduceSnMap(String organizeCode, String productSn) { - DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); - DdlPreparedPack.getStringEqualPack(productSn, MesPcnExtConstWords.PRODUCT_SN,packBean); - List mesProduceSns = mesProduceSnRepository.findByHqlWhere(packBean); - Map mesProduceSnMap = new HashMap<>(); - if(!CollectionUtils.isEmpty(mesProduceSns)){ - 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-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java index b6d4793..575d766 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java @@ -188,8 +188,12 @@ public class MesPcnExtConstWords { public static final String CUST_SN = "custSn"; // 条码状态 public static final String SN_STATUS = "snStatus"; + // 条码状态 + public static final String SN_STATUS_NAME = "snStatusName"; // 质量状态 public static final String QC_STATUS = "qcStatus"; + // 质量状态 + public static final String QC_STATUS_NAME = "qcStatusName"; // 过程标签模板 public static final String PROCESS_LABEL_TEMPLATE = "processLabelTemplate"; // 产品标签模板 @@ -288,6 +292,12 @@ public class MesPcnExtConstWords { public static final String SPOT_CHECK_ORDER_ID = "spotCheckOrderId"; //零件条码参数 public static final String PART_SN_PARAM = "partSnParam"; + //完成时间 + public static final String COMPLETE_DATE_TIME = "completeDateTime"; + //汇报状态 + public static final String REPORT_STATUS = "reportStatus"; + //汇报状态 + public static final String REPORT_STATUS_NAME = "reportStatusName"; //BaseBean字段不包含工厂, 用于对象复制剔除属性BeanUtils.copyProperties(Object source, Object target, String... ignoreProperties) @@ -730,6 +740,8 @@ public class MesPcnExtConstWords { // 产线名称 public static final String WORK_CENTER_NAME = "workCenterName"; + // 工位名称 + public static final String WORK_CELL_NAME = "workCellName"; // public static final int PALLET_CODE_93_WIDTH = 93;