PDA产品加工记录查询

tags/yfai-pcn-ext-v1.4
jun 9 months ago
parent 23b8e9fc51
commit 1ff40a34c4

@ -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);

@ -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<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn) {
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<MesProductionRecordModel> mesProductionRecordModelList = new ArrayList<>();
if (!CollectionUtils.isEmpty(productionRecordList)) {
//数据查询
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;
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<String, MesCraft> getStringMesCraftMap(String organizeCode, List<String> craftCodeList) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(craftCodeList, "craftCode",packBean);
DdlPreparedPack.getInPackList(craftCodeList, MesPcnExtConstWords.CRAFT_CODE,packBean);
List<MesCraft> craftList = mesCraftRepository.findByHqlWhere(packBean);
Map<String, MesCraft> craftMap = null;
if(!CollectionUtils.isEmpty(craftList)){
@ -132,13 +137,48 @@ public class MesProductionRecordService implements IMesProductionRecordService {
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);
DdlPreparedPack.getInPackList(snList, "serialNumber",packBean);
DdlPreparedPack.getInPackList(snList, MesPcnExtConstWords.SERIAL_NUMBER,packBean);
List<MesProduceSn> mesProduceSns = mesProduceSnRepository.findByHqlWhere(packBean);
Map<String, MesProduceSn> mesProduceSnMap = null;
Map<String, MesProduceSn> 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<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;
}

@ -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())){
//保存数据

Loading…
Cancel
Save