|
|
|
@ -2,13 +2,19 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesConfigService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNcProcessingService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.dao.IMesNcProcessingDao;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingInputModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingPartAndLotModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingViewModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
|
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.*;
|
|
|
|
@ -63,95 +69,79 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesMoveRepository moveRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesNcProcessingDao ncProcessingDao;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public MesNcProcessingModel queryProduceSn(String serialNumber, String org) {
|
|
|
|
|
public MesNcProcessingModel queryProduceSn(String serialNumber, String partNo, String lot, String org) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//检查不良条码
|
|
|
|
|
List<MesDefectRecord> defectRecordList = queryDefectRecord(serialNumber, org);
|
|
|
|
|
if (!StringUtils.isEmpty(serialNumber)) {
|
|
|
|
|
//检查不良条码
|
|
|
|
|
List<MesDefectRecord> defectRecordList = queryDefectRecordBySerialNumber(serialNumber, org);
|
|
|
|
|
|
|
|
|
|
//检查物料
|
|
|
|
|
MesPart part = checkPart(defectRecordList, org);
|
|
|
|
|
//检查物料
|
|
|
|
|
MesPart part = checkPart(defectRecordList, org);
|
|
|
|
|
|
|
|
|
|
//todo 图片暂时放空
|
|
|
|
|
//检查零件类型与图片对应关系
|
|
|
|
|
MesPartTypePicture partTypePicture = checkPartTypePicture(part, org);
|
|
|
|
|
//构造返回结果
|
|
|
|
|
MesNcProcessingModel model = getModel(part, defectRecordList, org);
|
|
|
|
|
return model;
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
//位置
|
|
|
|
|
List<MesLocationConfig> locationConfigList = checkLocationConfig(org);
|
|
|
|
|
//检查不良条码
|
|
|
|
|
List<MesDefectRecord> defectRecordList = queryDefectRecordByPartAndLot(partNo, lot, org);
|
|
|
|
|
|
|
|
|
|
Map<String, List<MesDefectRecord>> defectRecordMap = defectRecordList.stream().collect(Collectors.groupingBy(k -> k.getDefectLocationCode()));
|
|
|
|
|
//检查物料
|
|
|
|
|
MesPart part = checkPartByPartNo(partNo, org);
|
|
|
|
|
|
|
|
|
|
//构造返回结果
|
|
|
|
|
MesNcProcessingModel model = getModel(part, defectRecordList, org);
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, List<MesDefectRecord>> defectMap = defectRecordList.stream().collect(Collectors.groupingBy(k -> k.getDefectCode()));
|
|
|
|
|
@Override
|
|
|
|
|
public ListPager<MesNcProcessingPartAndLotModel> queryPartLot(String partNo, String lot, String org, Pager pager) {
|
|
|
|
|
|
|
|
|
|
//位置是否标黄Map,key:位置,value:标黄标识
|
|
|
|
|
locationConfigList.forEach(k -> {
|
|
|
|
|
if (defectRecordMap.containsKey(k.getDefectLocationCode())) {
|
|
|
|
|
k.setIsflg(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
pager = PagerHelper.getPager(pager, ncProcessingDao.queryDefectRecordByPagerCount(partNo, lot, org));
|
|
|
|
|
|
|
|
|
|
List<MesNcProcessingInputModel> defectModelList = new ArrayList<>();
|
|
|
|
|
defectMap.forEach((k, v) -> {
|
|
|
|
|
MesNcProcessingInputModel model = new MesNcProcessingInputModel();
|
|
|
|
|
model.setDefectCode(k);
|
|
|
|
|
model.setQty(v.size());
|
|
|
|
|
model.setDefectName(v.get(0).getDefectName());
|
|
|
|
|
defectModelList.add(model);
|
|
|
|
|
});
|
|
|
|
|
List<MesNcProcessingPartAndLotModel> modelList = ncProcessingDao.queryDefectRecordByPager(partNo, lot, org, pager);
|
|
|
|
|
|
|
|
|
|
MesNcProcessingModel model = new MesNcProcessingModel();
|
|
|
|
|
model.setDefectModelList(defectModelList);
|
|
|
|
|
model.setPartTypePicture(partTypePicture);
|
|
|
|
|
model.setLocationConfigList(locationConfigList);
|
|
|
|
|
return model;
|
|
|
|
|
return new ListPager(modelList, pager);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void saveNc(String serialNumber, Integer person, Integer type, String org) {
|
|
|
|
|
public void saveNc(MesNcProcessingInputModel model, String org) {
|
|
|
|
|
|
|
|
|
|
//检查不良条码
|
|
|
|
|
List<MesDefectRecord> defectRecordList = queryDefectRecord(serialNumber, org);
|
|
|
|
|
if (!StringUtils.isEmpty(model.getSerialNumber())) {
|
|
|
|
|
String serialNumber = model.getSerialNumber();
|
|
|
|
|
Integer type = model.getType();
|
|
|
|
|
Integer person = model.getPerson();
|
|
|
|
|
|
|
|
|
|
//检查不良条码
|
|
|
|
|
List<MesDefectRecord> defectRecordList = queryDefectRecordBySerialNumber(serialNumber, org);
|
|
|
|
|
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(defectRecordList.get(0).getPartNo(), "partNo", packBean);
|
|
|
|
|
MesPart part = partRepository.getByProperty(packBean);
|
|
|
|
|
//检查物料
|
|
|
|
|
MesPart part = checkPartByPartNo(defectRecordList.get(0).getPartNo(), org);
|
|
|
|
|
|
|
|
|
|
GenSerialNoModel serialNoModel = new GenSerialNoModel("NC_DEFECT_ZRSUM");
|
|
|
|
|
serialNoModel.setPartNo(part.getPartNo());
|
|
|
|
|
ResultBean rb = syncFuncService.syncSerialNo(serialNoModel, AuthUtil.getSessionUser().getUserName(), org, 1);
|
|
|
|
|
String zrsum = "";
|
|
|
|
|
if (null != rb && !CollectionUtils.isEmpty(rb.getResultList())) {
|
|
|
|
|
zrsum = (rb.getResultList().get(0)).toString();
|
|
|
|
|
}
|
|
|
|
|
//保存数据
|
|
|
|
|
saveDate(part, defectRecordList, type, person, org);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
if (type == MesPcnExtEnumUtil.NC_TYPE.NORMAL.getValue()) {
|
|
|
|
|
MesMove move = new MesMove();
|
|
|
|
|
move.setMatnr(part.getPartNo());
|
|
|
|
|
move.setOrganizeCode(org);
|
|
|
|
|
move.setFactoryCode(org);
|
|
|
|
|
move.setLgort(configService.getCfgValue(org, "UMLGO"));
|
|
|
|
|
move.setUmlgo(configService.getCfgValue(org, "LGORT"));
|
|
|
|
|
move.setMenge(defectRecordList.size());
|
|
|
|
|
move.setMeins(part.getUnit());
|
|
|
|
|
move.setZrsum(zrsum);
|
|
|
|
|
move.setPostDate(TimeTool.getToday());
|
|
|
|
|
move.setPostTime(TimeTool.getTimeShortWithColon());
|
|
|
|
|
// ConvertBean.serviceModelInitialize(move, "LML");
|
|
|
|
|
ConvertBean.serviceModelInitialize(move, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
String partNo = model.getPartNo();
|
|
|
|
|
String lot = model.getLot();
|
|
|
|
|
Integer type = model.getType();
|
|
|
|
|
Integer person = model.getPerson();
|
|
|
|
|
|
|
|
|
|
defectRecordList.forEach(k -> {
|
|
|
|
|
k.setNcType(type);
|
|
|
|
|
k.setPerson(person);
|
|
|
|
|
// ConvertBean.serviceModelUpdate(k, "LML");
|
|
|
|
|
ConvertBean.serviceModelUpdate(k, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
});
|
|
|
|
|
//检查不良条码
|
|
|
|
|
List<MesDefectRecord> defectRecordList = queryDefectRecordByPartAndLot(partNo, lot, org);
|
|
|
|
|
|
|
|
|
|
defectRecordRepository.saveAll(defectRecordList);
|
|
|
|
|
//检查物料
|
|
|
|
|
MesPart part = checkPartByPartNo(partNo, org);
|
|
|
|
|
|
|
|
|
|
//保存数据
|
|
|
|
|
saveDate(part, defectRecordList, type, person, org);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MesPart checkPart(List<MesDefectRecord> defectRecordList, String org) {
|
|
|
|
@ -174,12 +164,27 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
return part;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MesPart checkPartByPartNo(String partNo, String org) {
|
|
|
|
|
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean);
|
|
|
|
|
MesPart part = partRepository.getByProperty(packBean);
|
|
|
|
|
|
|
|
|
|
private List<MesDefectRecord> queryDefectRecord(String serialNumber, String org) {
|
|
|
|
|
//若不存在则提示物料信息不存在
|
|
|
|
|
if (StringUtils.isEmpty(part)) {
|
|
|
|
|
throw new ImppBusiException(String.format("【%s】物料号不存在,请检查数据", partNo));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return part;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<MesDefectRecord> queryDefectRecordBySerialNumber(String serialNumber, String org) {
|
|
|
|
|
|
|
|
|
|
//查询扫描的条码
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(serialNumber, "serialNumber", packBean);
|
|
|
|
|
// DdlPreparedPack.getNumEqualPack(0, "ncType", packBean);
|
|
|
|
|
List<MesDefectRecord> defectRecordList = defectRecordRepository.findByHqlWhere(packBean);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(defectRecordList)) {
|
|
|
|
@ -196,6 +201,29 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
return defectRecordList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<MesDefectRecord> queryDefectRecordByPartAndLot(String partNo, String Lot, String org) {
|
|
|
|
|
|
|
|
|
|
//查询扫描的条码
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(Lot, "Lot", packBean);
|
|
|
|
|
// DdlPreparedPack.getNumEqualPack(0, "ncType", packBean);
|
|
|
|
|
List<MesDefectRecord> defectRecordList = defectRecordRepository.findByHqlWhere(packBean);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(defectRecordList)) {
|
|
|
|
|
throw new ImppBusiException(String.format("【%s】此物料号+【%s】批次不存在可疑品记录,请检查数据", partNo, Lot));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defectRecordList.forEach(k -> {
|
|
|
|
|
if (k.getNcType() != 0) {
|
|
|
|
|
throw new ImppBusiException(String.format("【%s】此物料号+【%s】批次已经过NC处理,请检查数据", partNo, Lot));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return defectRecordList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MesPartTypePicture checkPartTypePicture(MesPart part, String org) {
|
|
|
|
|
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
@ -243,4 +271,92 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
|
|
|
|
|
return configList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构造返回数据
|
|
|
|
|
*
|
|
|
|
|
* @param part
|
|
|
|
|
* @param defectRecordList
|
|
|
|
|
* @param org
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private MesNcProcessingModel getModel(MesPart part, List<MesDefectRecord> defectRecordList, String org) {
|
|
|
|
|
//todo 图片暂时放空
|
|
|
|
|
//检查零件类型与图片对应关系
|
|
|
|
|
MesPartTypePicture partTypePicture = checkPartTypePicture(part, org);
|
|
|
|
|
|
|
|
|
|
//位置
|
|
|
|
|
List<MesLocationConfig> locationConfigList = checkLocationConfig(org);
|
|
|
|
|
|
|
|
|
|
Map<String, List<MesDefectRecord>> defectRecordMap = defectRecordList.stream().collect(Collectors.groupingBy(k -> k.getDefectLocationCode()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, List<MesDefectRecord>> defectMap = defectRecordList.stream().collect(Collectors.groupingBy(k -> k.getDefectCode()));
|
|
|
|
|
|
|
|
|
|
//位置是否标黄Map,key:位置,value:标黄标识
|
|
|
|
|
locationConfigList.forEach(k -> {
|
|
|
|
|
if (defectRecordMap.containsKey(k.getDefectLocationCode())) {
|
|
|
|
|
k.setIsflg(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
List<MesNcProcessingViewModel> defectModelList = new ArrayList<>();
|
|
|
|
|
defectMap.forEach((k, v) -> {
|
|
|
|
|
MesNcProcessingViewModel model = new MesNcProcessingViewModel();
|
|
|
|
|
model.setDefectCode(k);
|
|
|
|
|
model.setQty(v.size());
|
|
|
|
|
model.setDefectName(v.get(0).getDefectName());
|
|
|
|
|
defectModelList.add(model);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
MesNcProcessingModel model = new MesNcProcessingModel();
|
|
|
|
|
model.setDefectModelList(defectModelList);
|
|
|
|
|
model.setPartTypePicture(partTypePicture);
|
|
|
|
|
model.setLocationConfigList(locationConfigList);
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存数据
|
|
|
|
|
*
|
|
|
|
|
* @param part
|
|
|
|
|
* @param defectRecordList
|
|
|
|
|
* @param type
|
|
|
|
|
* @param person
|
|
|
|
|
* @param org
|
|
|
|
|
*/
|
|
|
|
|
private void saveDate(MesPart part, List<MesDefectRecord> defectRecordList, Integer type, Integer person, String org) {
|
|
|
|
|
GenSerialNoModel serialNoModel = new GenSerialNoModel("NC_DEFECT_ZRSUM");
|
|
|
|
|
serialNoModel.setPartNo(part.getPartNo());
|
|
|
|
|
ResultBean rb = syncFuncService.syncSerialNo(serialNoModel, AuthUtil.getSessionUser().getUserName(), org, 1);
|
|
|
|
|
String zrsum = "";
|
|
|
|
|
if (null != rb && !CollectionUtils.isEmpty(rb.getResultList())) {
|
|
|
|
|
zrsum = (rb.getResultList().get(0)).toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type == MesPcnExtEnumUtil.NC_TYPE.NORMAL.getValue()) {
|
|
|
|
|
MesMove move = new MesMove();
|
|
|
|
|
move.setMatnr(part.getPartNo());
|
|
|
|
|
move.setOrganizeCode(org);
|
|
|
|
|
move.setFactoryCode(org);
|
|
|
|
|
move.setLgort(configService.getCfgValue(org, "UMLGO"));
|
|
|
|
|
move.setUmlgo(configService.getCfgValue(org, "LGORT"));
|
|
|
|
|
move.setMenge(defectRecordList.size());
|
|
|
|
|
move.setMeins(part.getUnit());
|
|
|
|
|
move.setZrsum(zrsum);
|
|
|
|
|
move.setPostDate(TimeTool.getToday());
|
|
|
|
|
move.setPostTime(TimeTool.getTimeShortWithColon());
|
|
|
|
|
ConvertBean.serviceModelInitialize(move, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defectRecordList.forEach(k -> {
|
|
|
|
|
k.setNcType(type);
|
|
|
|
|
k.setPerson(person);
|
|
|
|
|
ConvertBean.serviceModelUpdate(k, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
defectRecordRepository.saveAll(defectRecordList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|