|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesReworkTaskService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesConfigService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesInputDefectRecordService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
|
|
|
|
@ -16,6 +17,7 @@ import cn.estsh.i3plus.pojo.mes.bean.*;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.rework.MesReworkTask;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.rework.MesReworkTaskDetail;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.*;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
@ -83,6 +85,9 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesDefectTypeRepository defectTypeRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesReworkTaskDetailRepository mesReworkTaskDetailRDao;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel inputModel, String org) {
|
|
|
|
|
|
|
|
|
@ -125,7 +130,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
MesPartTypePicture partTypePicture = checkPartTypePicture(part, org);
|
|
|
|
|
|
|
|
|
|
//构造返回信息
|
|
|
|
|
MesPartInspectionViewModel model = getModel(partInspection, part, partTypePicture, inputModel.getFrontBack(), sourceType, org);
|
|
|
|
|
MesPartInspectionViewModel model = getModel(partInspection, part, partTypePicture, inputModel, sourceType, org);
|
|
|
|
|
model.setSourceType(sourceType);
|
|
|
|
|
model.setTransferFlg(inputModel.isTransferFlg());
|
|
|
|
|
|
|
|
|
@ -488,7 +493,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
//返修单 进行返修
|
|
|
|
|
inputModel.setTransferFlg(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return partInspection;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -698,14 +703,18 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
return alarmConfigList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MesPartInspectionViewModel getModel(MesPartInspection partInspection, MesPart part, MesPartTypePicture partTypePicture, Integer frontBack,
|
|
|
|
|
private MesPartInspectionViewModel getModel(MesPartInspection partInspection, MesPart part,MesPartTypePicture partTypePicture, MesPartInspectionInputModel inputModel ,
|
|
|
|
|
Integer sourceType, String org) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integer frontBack = inputModel.getFrontBack();
|
|
|
|
|
List<MesPartInspectionDetail> detailList = new ArrayList<>();
|
|
|
|
|
if (!StringUtils.isEmpty(partInspection) && partInspection.getInspectionStatus() != MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue()) {
|
|
|
|
|
|
|
|
|
|
detailList = checkPartInspectionDetail(partInspection, org);
|
|
|
|
|
if(!CollectionUtils.isEmpty(detailList)){
|
|
|
|
|
//判断是否返工完成
|
|
|
|
|
checkReworkFinished(org, detailList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//位置
|
|
|
|
|
List<MesLocationConfig> locationConfigList = checkLocationConfig(org);
|
|
|
|
@ -721,23 +730,53 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
//根据不良类型+位置 若有数据,则表示需要标黄
|
|
|
|
|
Map<String, List<MesDefectWarnConfig>> alarmConfigMap = alarmConfigList.stream().collect(Collectors.groupingBy(MesDefectWarnConfig::getDefectLocation));
|
|
|
|
|
|
|
|
|
|
//返修完成需要标记绿色
|
|
|
|
|
Map<String, List<MesPartInspectionDetail>> detailMap = detailList.stream().collect(Collectors.groupingBy(MesPartInspectionDetail::getDefectLocation));
|
|
|
|
|
|
|
|
|
|
locationConfigList.forEach(k -> {
|
|
|
|
|
k.setFrontBack(frontBack);
|
|
|
|
|
if (alarmConfigMap.containsKey(k.getDefectLocation())) {
|
|
|
|
|
k.setIsflg(true);
|
|
|
|
|
k.setColour(MesExtEnumUtil.COLOR.YELLOW.getValue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(detailMap.containsKey(k.getDefectLocation()) &&
|
|
|
|
|
detailMap.get(k.getDefectLocation()).stream().allMatch(MesPartInspectionDetail::getReworkFinished)){
|
|
|
|
|
k.setIsflg(true);
|
|
|
|
|
k.setColour(MesExtEnumUtil.COLOR.GREEN.getValue());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
MesPartInspectionViewModel model = new MesPartInspectionViewModel();
|
|
|
|
|
model.setPart(part);
|
|
|
|
|
model.setPartInspectionDetailList(detailList);
|
|
|
|
|
if (partInspection.getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()
|
|
|
|
|
&& partInspection.getNcStatus() == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue()) {
|
|
|
|
|
model.setPartInspectionDetailList(detailList);
|
|
|
|
|
}
|
|
|
|
|
model.setPartTypePicture(partTypePicture);
|
|
|
|
|
model.setLocationConfigList(locationConfigList);
|
|
|
|
|
model.setPartInspection(partInspection);
|
|
|
|
|
model.setMesDefectWarnConfigList(alarmConfigList);
|
|
|
|
|
return model;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkReworkFinished(String org, List<MesPartInspectionDetail> detailList) {
|
|
|
|
|
List<Long> idList = detailList.stream().map(MesPartInspectionDetail::getId).collect(Collectors.toList());
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getInPackList(idList, "partInspectionDetailId", packBean);
|
|
|
|
|
List<MesReworkTaskDetail> mesReworkTaskDetailList = mesReworkTaskDetailRDao.findByHqlWhere(packBean);
|
|
|
|
|
if (!CollectionUtils.isEmpty(mesReworkTaskDetailList)){
|
|
|
|
|
Map<Long, List<MesReworkTaskDetail>> mesReworkTaskDetailMap = mesReworkTaskDetailList.stream().collect(Collectors.groupingBy(MesReworkTaskDetail::getPartInspectionDetailId));
|
|
|
|
|
detailList.forEach(d->{
|
|
|
|
|
if(mesReworkTaskDetailMap.containsKey(d.getId()) &&
|
|
|
|
|
mesReworkTaskDetailMap.get(d.getId()).stream().allMatch(t->MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue() == t.getStatus())){
|
|
|
|
|
d.setReworkFinished(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<MesPartInspectionDetail> checkPartInspectionDetail(MesPartInspection partInspection, String org) {
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(partInspection.getId(), "pid", packBean);
|
|
|
|
|