产品加工记录 查询 报表 页面数据展示优化 (增加当前条码的最新状态工位质量等信息, 修复加工记录列表零件状态空的问题)

dev-temp-nht-202502180000-customprint
王杰 5 months ago
parent b775ab0fa1
commit dd3dddd97f

@ -1,11 +1,13 @@
package cn.estsh.i3plus.ext.mes.pcn.api.base; 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.MesWorkCell;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCellExtendCfg; import cn.estsh.i3plus.pojo.mes.bean.MesWorkCellExtendCfg;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter; import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.List; import java.util.List;
import java.util.Map;
public interface IMesProdOrgExtService { public interface IMesProdOrgExtService {
@ -24,6 +26,24 @@ public interface IMesProdOrgExtService {
@ApiOperation(value = "根据生产线代码查询工位信息") @ApiOperation(value = "根据生产线代码查询工位信息")
List<MesWorkCell> getWorkCellList(String organizeCode, String workCenterCode); List<MesWorkCell> getWorkCellList(String organizeCode, String workCenterCode);
@ApiOperation(value = "根据生产线代码查询生产线信息")
List<MesWorkCenter> getWorkCenterList(String organizeCode, List<String> workCenterCodeList);
@ApiOperation(value = "根据生产线代码查询生产线信息")
Map<String, String> getWorkCenterCodeMap(String organizeCode, List<String> workCenterCodeList);
@ApiOperation(value = "根据工位代码查询工位信息")
List<MesWorkCell> getWorkCellList(String organizeCode, List<String> workCellCodeList);
@ApiOperation(value = "根据工位代码查询工位信息")
Map<String, String> getWorkCellCodeMap(String organizeCode, List<String> workCellCodeList);
@ApiOperation(value = "根据工艺代码查询工艺信息")
List<MesCraft> getCraftList(String organizeCode, List<String> craftCodeList);
@ApiOperation(value = "根据工艺代码查询工艺信息")
Map<String, String> getCraftCodeMap(String organizeCode, List<String> craftCodeList);
@ApiOperation(value = "根据子生产线代码,子工位代码,关系类型查询主子工位关系信息") @ApiOperation(value = "根据子生产线代码,子工位代码,关系类型查询主子工位关系信息")
MesWorkCellExtendCfg getWorkCellExtendCfg(String organizeCode, String workCenterCodeBak, String workCellCodeBak, Integer extendType); MesWorkCellExtendCfg getWorkCellExtendCfg(String organizeCode, String workCenterCodeBak, String workCellCodeBak, Integer extendType);

@ -18,6 +18,9 @@ public interface IMesProduceSnExtService {
@ApiOperation(value = "根据零件条码查询零件条码信息") @ApiOperation(value = "根据零件条码查询零件条码信息")
List<MesProduceSn> getProduceSnList(String organizeCode, String productSn); List<MesProduceSn> getProduceSnList(String organizeCode, String productSn);
@ApiOperation(value = "根据零件条码查询零件条码信息, 创建时间倒序")
List<MesProduceSn> getProduceSnListCreateDatetimeDesc(String organizeCode, String productSn);
@ApiOperation(value = "根据客户条码查询零件条码信息[排序]") @ApiOperation(value = "根据客户条码查询零件条码信息[排序]")
MesProduceSn getProduceSnByCustSn(String organizeCode, String custSn); MesProduceSn getProduceSnByCustSn(String organizeCode, String custSn);

@ -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.bean.MesProductionRecord;
import cn.estsh.i3plus.pojo.mes.model.MesProductionRecordModel; import cn.estsh.i3plus.pojo.mes.model.MesProductionRecordModel;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.List; import java.util.List;
@ -18,6 +19,9 @@ public interface IMesProductionRecordService {
@ApiOperation(value = "根据零件条码查询加工记录信息") @ApiOperation(value = "根据零件条码查询加工记录信息")
List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn); List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn);
@ApiOperation(value = "查询加工记录, 根据完成时间倒序")
List<MesProductionRecord> findProductionRecordListCompleteDateTimeDesc(String organizeCode, String productSn);
@ApiOperation(value = "根据零件条码,零件编码查询加工记录信息") @ApiOperation(value = "根据零件条码,零件编码查询加工记录信息")
List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn, String partNo); List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn, String partNo);
@ -34,8 +38,8 @@ public interface IMesProductionRecordService {
void updateProductionRecord(String organizeCode, String userName, Long id, String errorMsg); void updateProductionRecord(String organizeCode, String userName, Long id, String errorMsg);
@ApiOperation(value = "根据零件条码查询加工记录信息") @ApiOperation(value = "查询加工记录信息PDA报表")
List<MesProductionRecordModel> findMesProductionRecordList(String organizeCode, String productSn); ResultBean queryMesProductionRecordReport(String organizeCode, String productSn);
@ApiOperation(value = "更新加工记录") @ApiOperation(value = "更新加工记录")
void updateProductionRecord(List<MesProductionRecord> recordList,String userName,Integer reportStatus,String msg); void updateProductionRecord(List<MesProductionRecord> recordList,String userName,Integer reportStatus,String msg);

@ -63,12 +63,12 @@ public class MesBusiController {
} }
@GetMapping("/mesProductionRecord/query") @GetMapping("/mesProductionRecord/query")
@ApiOperation(value = "查询加工记录信息") @ApiOperation(value = "查询加工记录信息PDA报表")
public ResultBean queryMesProductionRecord(MesProductionRecord mesProductionRecord) { public ResultBean queryMesProductionRecordReport(MesProductionRecord mesProductionRecord) {
try { try {
ValidatorBean.checkNotNull(mesProductionRecord.getOrganizeCode(), "工厂代码不能为空"); ValidatorBean.checkNotNull(mesProductionRecord.getOrganizeCode(), "工厂代码不能为空");
ValidatorBean.checkNotNull(mesProductionRecord.getProductSn(), "零件条码不能为空"); ValidatorBean.checkNotNull(mesProductionRecord.getProductSn(), "零件条码不能为空");
return ResultBean.success("查询成功").setResultList(mesProductionRecordService.findMesProductionRecordList(mesProductionRecord.getOrganizeCode(), mesProductionRecord.getProductSn())); return mesProductionRecordService.queryMesProductionRecordReport(mesProductionRecord.getOrganizeCode(), mesProductionRecord.getProductSn());
} catch (ImppBusiException imppException) { } catch (ImppBusiException imppException) {
return ResultBean.fail(imppException); return ResultBean.fail(imppException);
} catch (Exception e) { } catch (Exception e) {

@ -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.api.base.IMesProdOrgExtService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; 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.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.MesWorkCell;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCellExtendCfg; import cn.estsh.i3plus.pojo.mes.bean.MesWorkCellExtendCfg;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter; 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.MesWorkCellExtendCfgRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesWorkCellRepository; import cn.estsh.i3plus.pojo.mes.repository.MesWorkCellRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesWorkCenterRepository; import cn.estsh.i3plus.pojo.mes.repository.MesWorkCenterRepository;
@ -31,6 +34,9 @@ public class MesProdOrgExtService implements IMesProdOrgExtService {
private MesWorkCellRepository workCellRepository; private MesWorkCellRepository workCellRepository;
@Autowired @Autowired
private MesCraftRepository craftRepository;
@Autowired
private MesWorkCellExtendCfgRepository workCellExtendCfgRepository; private MesWorkCellExtendCfgRepository workCellExtendCfgRepository;
@Override @Override
@ -77,6 +83,71 @@ public class MesProdOrgExtService implements IMesProdOrgExtService {
} }
@Override @Override
public List<MesWorkCenter> getWorkCenterList(String organizeCode, List<String> 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<String, String> getWorkCenterCodeMap(String organizeCode, List<String> workCenterCodeList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(workCenterCodeList)) return null;
List<MesWorkCenter> 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<MesWorkCell> getWorkCellList(String organizeCode, List<String> 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<String, String> getWorkCellCodeMap(String organizeCode, List<String> workCellCodeList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(workCellCodeList)) return null;
List<MesWorkCell> 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<MesCraft> getCraftList(String organizeCode, List<String> 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<String, String> getCraftCodeMap(String organizeCode, List<String> craftCodeList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(craftCodeList)) return null;
List<MesCraft> 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) { 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; if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workCenterCodeBak) || StringUtils.isEmpty(workCellCodeBak) || StringUtils.isEmpty(extendType)) return null;
return workCellExtendCfgRepository.getByProperty( return workCellExtendCfgRepository.getByProperty(

@ -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.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn; 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.bean.MesQueueOrder;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository; import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository;
@ -49,6 +50,7 @@ public class MesProduceSnExtService implements IMesProduceSnExtService {
return produceSnRepository.findByHqlWhere(packBean); return produceSnRepository.findByHqlWhere(packBean);
} }
//根据零件条码查询零件条码信息
@Override @Override
public List<MesProduceSn> getProduceSnList(String organizeCode, String productSn) { public List<MesProduceSn> getProduceSnList(String organizeCode, String productSn) {
@ -60,6 +62,15 @@ public class MesProduceSnExtService implements IMesProduceSnExtService {
return produceSnRepository.findByHqlWhere(packBean); return produceSnRepository.findByHqlWhere(packBean);
} }
//根据零件条码查询零件条码信息, 创建时间倒序
@Override
public List<MesProduceSn> getProduceSnListCreateDatetimeDesc(String organizeCode, String productSn) {
List<MesProduceSn> 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 @Override
public MesProduceSn getProduceSnByCustSn(String organizeCode, String custSn) { public MesProduceSn getProduceSnByCustSn(String organizeCode, String custSn) {
@ -71,6 +82,7 @@ public class MesProduceSnExtService implements IMesProduceSnExtService {
return produceSnRepository.getByProperty(packBean); return produceSnRepository.getByProperty(packBean);
} }
//根据产品条码查询零件条码信息[排序]
@Override @Override
public MesProduceSn getProduceSn(String organizeCode, String productSn, String workOrderNo) { public MesProduceSn getProduceSn(String organizeCode, String productSn, String workOrderNo) {

@ -1,5 +1,7 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi; 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.api.busi.IMesProductionRecordService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean; 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.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.*; import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.i3plus.pojo.mes.model.MesProductionRecordModel; import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord;
import cn.estsh.i3plus.pojo.mes.repository.*; import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -31,6 +33,12 @@ import java.util.stream.Collectors;
public class MesProductionRecordService implements IMesProductionRecordService { public class MesProductionRecordService implements IMesProductionRecordService {
@Autowired @Autowired
private IMesProduceSnExtService produceSnExtService;
@Autowired
private IMesProdOrgExtService prodOrgExtService;
@Autowired
private MesTimeEfficientCfgRepository timeEfficientCfgRepository; private MesTimeEfficientCfgRepository timeEfficientCfgRepository;
@Autowired @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}); new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), productSn});
} }
//查询加工记录, 根据完成时间倒序
@Override
public List<MesProductionRecord> findProductionRecordListCompleteDateTimeDesc(String organizeCode, String productSn) {
List<MesProductionRecord> 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 @Override
public List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn, String partNo) { public List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn, String partNo) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn) || StringUtils.isEmpty(partNo)) return null; if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn) || StringUtils.isEmpty(partNo)) return null;
@ -114,30 +130,113 @@ public class MesProductionRecordService implements IMesProductionRecordService {
} }
@Override @Override
public List<MesProductionRecordModel> findMesProductionRecordList(String organizeCode, String productSn) { public ResultBean queryMesProductionRecordReport(String organizeCode, String productSn) {
List<MesProductionRecord> productionRecordList = findProductionRecord(organizeCode, productSn);
List<MesProductionRecordModel> mesProductionRecordModelList = new ArrayList<>(); //查询条码信息, 根据创建时间倒序
if (!CollectionUtils.isEmpty(productionRecordList)) { List<MesProduceSn> produceSnList = produceSnExtService.getProduceSnListCreateDatetimeDesc(organizeCode, productSn);
//数据查询
Map<String, MesCraft> craftMap = getStringMesCraftMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getCraftCode).distinct().collect(Collectors.toList())); if (CollectionUtils.isEmpty(produceSnList)) return ResultBean.fail(String.format("零件条码[%s]信息不存在!", productSn));
Map<String, MesProduceSn> produceSnMap = getStringMesProduceSnMap(organizeCode, productSn);
Map<String, MesWorkCenter> mesWorkCenterMap = getStringMesWorkCenterMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getWorkCenterCode).distinct().collect(Collectors.toList())); MesProduceSn produceSnDb = produceSnList.get(0);
Map<String, MesWorkCell> workCellMap = getStringMesWorkCellMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getWorkCellCode).distinct().collect(Collectors.toList()));
//数据组装 //查询加工记录, 根据完成时间倒序
MesProductionRecordModel mesProductionRecordModel = null; List<MesProductionRecord> productionRecordList = findProductionRecordListCompleteDateTimeDesc(organizeCode, productSn);
for (MesProductionRecord mesProductionRecord : productionRecordList) {
mesProductionRecordModel = new MesProductionRecordModel(); //查询生产线名称
BeanUtils.copyProperties(mesProductionRecord, mesProductionRecordModel); Map<String, String> workCenterCodeMap = getProductionRecordReportCenterMap(organizeCode, produceSnDb.getWorkCenterCode(), productionRecordList);
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()); Map<String, String> workCellCodeMap = getProductionRecordReportCellMap(organizeCode, produceSnDb.getWorkCellCode(), productionRecordList);
mesProductionRecordModel.setSnStatusDesc(0 == mesProductionRecordModel.getSnStatus() ?"" : MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(mesProductionRecordModel.getSnStatus())); //查询工艺名称
mesProductionRecordModel.setReportStatusDesc(MesExtEnumUtil.REPORT_STATUS.valueOfDescription(mesProductionRecordModel.getReportStatus())); Map<String, String> craftCodeMap = getProductionRecordReportCraftMap(organizeCode, produceSnDb.getCraftCode(), productionRecordList);
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()); Map<String, Object> produceSnMap = new HashMap<>();
mesProductionRecordModelList.add(mesProductionRecordModel); produceSnMap.put(MesPcnExtConstWords.PRODUCT_SN, productSn);
} produceSnMap.put(MesPcnExtConstWords.PART_NO, produceSnDb.getPartNo());
} produceSnMap.put(MesPcnExtConstWords.PART_NAME, produceSnDb.getPartName());
return mesProductionRecordModelList; 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<String, List<MesProduceSn>> produceSnMap2Part = produceSnList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPartNo()))).collect(Collectors.groupingBy(MesProduceSn::getPartNo));
List<Map<String, Object>> productionRecordMapList = new ArrayList<>();
MesProduceSn produceSnItem;
for (MesProductionRecord productionRecord : productionRecordList) {
if (null == productionRecord) continue;
Map<String, Object> 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 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<String, String> 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<String, String> getProductionRecordReportCenterMap(String organizeCode, String workCenterCode, List<MesProductionRecord> productionRecordList) {
List<String> 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<String, String> getProductionRecordReportCellMap(String organizeCode, String workCellCode, List<MesProductionRecord> productionRecordList) {
List<String> 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<String, String> getProductionRecordReportCraftMap(String organizeCode, String craftCode, List<MesProductionRecord> productionRecordList) {
List<String> 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 @Override
@ -152,68 +251,4 @@ public class MesProductionRecordService implements IMesProductionRecordService {
productionRecordRepository.saveAll(recordList); productionRecordRepository.saveAll(recordList);
} }
private Map<String, MesCraft> getStringMesCraftMap(String organizeCode, List<String> craftCodeList) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(craftCodeList, MesPcnExtConstWords.CRAFT_CODE,packBean);
List<MesCraft> craftList = mesCraftRepository.findByHqlWhere(packBean);
Map<String, MesCraft> craftMap = null;
if(!CollectionUtils.isEmpty(craftList)){
craftMap = craftList.stream().collect(Collectors.toMap(MesCraft::getCraftCode, t -> t));
}
return craftMap;
}
private Map<String, MesProduceSn> getStringMesProduceSnMap(String organizeCode, String productSn) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(productSn, MesPcnExtConstWords.PRODUCT_SN,packBean);
List<MesProduceSn> mesProduceSns = mesProduceSnRepository.findByHqlWhere(packBean);
Map<String, MesProduceSn> 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<String, MesWorkCenter> getStringMesWorkCenterMap(String organizeCode, List<String> workCenterNoList) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(workCenterNoList, MesPcnExtConstWords.WORK_CENTER_CODE,packBean);
List<MesWorkCenter> mesWorkCenterList = mesWorkCenterRepository.findByHqlWhere(packBean);
Map<String, MesWorkCenter> 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<String, MesWorkCell> getStringMesWorkCellMap(String organizeCode, List<String> workCenterNoList) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(workCenterNoList, MesPcnExtConstWords.WORK_CELL_CODE,packBean);
List<MesWorkCell> mesWorkCellList = mesWorkCellRepository.findByHqlWhere(packBean);
Map<String, MesWorkCell> 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<MesProductionRecord> 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);
}
} }

@ -187,8 +187,12 @@ public class MesPcnExtConstWords {
public static final String CUST_SN = "custSn"; public static final String CUST_SN = "custSn";
// 条码状态 // 条码状态
public static final String SN_STATUS = "snStatus"; 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 = "qcStatus";
// 质量状态
public static final String QC_STATUS_NAME = "qcStatusName";
// 过程标签模板 // 过程标签模板
public static final String PROCESS_LABEL_TEMPLATE = "processLabelTemplate"; public static final String PROCESS_LABEL_TEMPLATE = "processLabelTemplate";
// 产品标签模板 // 产品标签模板
@ -279,6 +283,12 @@ public class MesPcnExtConstWords {
public static final String REPORT_TYPE = "reportType"; public static final String REPORT_TYPE = "reportType";
//发运时间 //发运时间
public static final String SHIPPING_TIME = "shippingTime"; public static final String SHIPPING_TIME = "shippingTime";
//完成时间
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) //BaseBean字段不包含工厂, 用于对象复制剔除属性BeanUtils.copyProperties(Object source, Object target, String... ignoreProperties)
@ -717,6 +727,8 @@ public class MesPcnExtConstWords {
// 产线名称 // 产线名称
public static final String WORK_CENTER_NAME = "workCenterName"; 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; public static final int PALLET_CODE_93_WIDTH = 93;

Loading…
Cancel
Save