|
|
@ -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.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.MesCraft;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.*;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
|
|
|
|
|
|
|
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.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;
|
|
|
@ -18,10 +16,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -49,6 +44,12 @@ public class MesProductionRecordService implements IMesProductionRecordService {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MesProduceSnRepository mesProduceSnRepository;
|
|
|
|
private MesProduceSnRepository mesProduceSnRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesWorkCenterRepository mesWorkCenterRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesWorkCellRepository mesWorkCellRepository;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn) {
|
|
|
|
public List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn) {
|
|
|
|
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn)) return null;
|
|
|
|
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn)) return null;
|
|
|
@ -103,18 +104,22 @@ public class MesProductionRecordService implements IMesProductionRecordService {
|
|
|
|
List<MesProductionRecord> productionRecordList = findProductionRecordList(organizeCode, productSn);
|
|
|
|
List<MesProductionRecord> productionRecordList = findProductionRecordList(organizeCode, productSn);
|
|
|
|
List<MesProductionRecordModel> mesProductionRecordModelList = new ArrayList<>();
|
|
|
|
List<MesProductionRecordModel> mesProductionRecordModelList = new ArrayList<>();
|
|
|
|
if (!CollectionUtils.isEmpty(productionRecordList)) {
|
|
|
|
if (!CollectionUtils.isEmpty(productionRecordList)) {
|
|
|
|
|
|
|
|
//数据查询
|
|
|
|
Map<String, MesCraft> craftMap = getStringMesCraftMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getCraftCode).distinct().collect(Collectors.toList()));
|
|
|
|
Map<String, MesCraft> craftMap = getStringMesCraftMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getCraftCode).distinct().collect(Collectors.toList()));
|
|
|
|
Map<String, MesProduceSn> produceSnMap = getStringMesProduceSn(organizeCode, productionRecordList.stream().map(MesProductionRecord::getSerialNumber).distinct().collect(Collectors.toList()));
|
|
|
|
Map<String, MesProduceSn> produceSnMap = getStringMesProduceSnMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getSerialNumber).distinct().collect(Collectors.toList()));
|
|
|
|
|
|
|
|
Map<String, MesWorkCenter> mesWorkCenterMap = getStringMesWorkCenterMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getWorkCenterCode).distinct().collect(Collectors.toList()));
|
|
|
|
|
|
|
|
Map<String, MesWorkCell> workCellMap = getStringMesWorkCellMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getWorkCellCode).distinct().collect(Collectors.toList()));
|
|
|
|
|
|
|
|
//数据组装
|
|
|
|
MesProductionRecordModel mesProductionRecordModel = null;
|
|
|
|
MesProductionRecordModel mesProductionRecordModel = null;
|
|
|
|
for (MesProductionRecord mesProductionRecord : productionRecordList) {
|
|
|
|
for (MesProductionRecord mesProductionRecord : productionRecordList) {
|
|
|
|
mesProductionRecordModel = new MesProductionRecordModel();
|
|
|
|
mesProductionRecordModel = new MesProductionRecordModel();
|
|
|
|
BeanUtils.copyProperties(mesProductionRecord, mesProductionRecordModel);
|
|
|
|
BeanUtils.copyProperties(mesProductionRecord, mesProductionRecordModel);
|
|
|
|
MesCraft mesCraft = Objects.isNull(craftMap) ? null : craftMap.get(mesProductionRecord.getCraftCode());
|
|
|
|
mesProductionRecordModel.setCraftName(Objects.isNull(craftMap) || Objects.isNull(craftMap.get(mesProductionRecord.getCraftCode())) || StringUtils.isEmpty(mesProductionRecord.getCraftCode()) ? "" : craftMap.get(mesProductionRecord.getCraftCode()).getCraftName());
|
|
|
|
mesProductionRecordModel.setCraftName(Objects.isNull(mesCraft) ? "" : mesCraft.getCraftName());
|
|
|
|
mesProductionRecordModel.setSnStatus(Objects.isNull(produceSnMap.get(mesProductionRecord.getSerialNumber())) || StringUtils.isEmpty(mesProductionRecord.getSerialNumber()) ? 0 : produceSnMap.get(mesProductionRecord.getSerialNumber()).getSnStatus());
|
|
|
|
MesProduceSn produceSn = Objects.isNull(produceSnMap) ? null : produceSnMap.get(mesProductionRecord.getSerialNumber());
|
|
|
|
mesProductionRecordModel.setSnStatusDesc(0 == mesProductionRecordModel.getSnStatus() ?"" : MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(mesProductionRecordModel.getSnStatus()));
|
|
|
|
mesProductionRecordModel.setSnStatus(Objects.isNull(produceSn) ? 0 : produceSn.getSnStatus());
|
|
|
|
|
|
|
|
mesProductionRecordModel.setSnStatusDesc(Objects.isNull(produceSn) ? "" :MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(produceSn.getSnStatus()));
|
|
|
|
|
|
|
|
mesProductionRecordModel.setReportStatusDesc(MesExtEnumUtil.REPORT_STATUS.valueOfDescription(mesProductionRecordModel.getReportStatus()));
|
|
|
|
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);
|
|
|
|
mesProductionRecordModelList.add(mesProductionRecordModel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -123,7 +128,7 @@ public class MesProductionRecordService implements IMesProductionRecordService {
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, MesCraft> getStringMesCraftMap(String organizeCode, List<String> craftCodeList) {
|
|
|
|
private Map<String, MesCraft> getStringMesCraftMap(String organizeCode, List<String> craftCodeList) {
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
DdlPreparedPack.getInPackList(craftCodeList, "craftCode",packBean);
|
|
|
|
DdlPreparedPack.getInPackList(craftCodeList, MesPcnExtConstWords.CRAFT_CODE,packBean);
|
|
|
|
List<MesCraft> craftList = mesCraftRepository.findByHqlWhere(packBean);
|
|
|
|
List<MesCraft> craftList = mesCraftRepository.findByHqlWhere(packBean);
|
|
|
|
Map<String, MesCraft> craftMap = null;
|
|
|
|
Map<String, MesCraft> craftMap = null;
|
|
|
|
if(!CollectionUtils.isEmpty(craftList)){
|
|
|
|
if(!CollectionUtils.isEmpty(craftList)){
|
|
|
@ -132,13 +137,48 @@ public class MesProductionRecordService implements IMesProductionRecordService {
|
|
|
|
return craftMap;
|
|
|
|
return craftMap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, MesProduceSn> getStringMesProduceSn(String organizeCode, List<String> snList) {
|
|
|
|
private Map<String, MesProduceSn> getStringMesProduceSnMap(String organizeCode, List<String> snList) {
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
DdlPreparedPack.getInPackList(snList, "serialNumber",packBean);
|
|
|
|
DdlPreparedPack.getInPackList(snList, MesPcnExtConstWords.SERIAL_NUMBER,packBean);
|
|
|
|
List<MesProduceSn> mesProduceSns = mesProduceSnRepository.findByHqlWhere(packBean);
|
|
|
|
List<MesProduceSn> mesProduceSns = mesProduceSnRepository.findByHqlWhere(packBean);
|
|
|
|
Map<String, MesProduceSn> mesProduceSnMap = null;
|
|
|
|
Map<String, MesProduceSn> mesProduceSnMap = new HashMap<>();
|
|
|
|
if(!CollectionUtils.isEmpty(mesProduceSns)){
|
|
|
|
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<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;
|
|
|
|
return mesProduceSnMap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|