缺陷录入

tags/yfai-pcn-ext-v1.0
jun 11 months ago
parent 9464ef33a7
commit cce62542f3

@ -6,6 +6,7 @@ import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskRequestModel;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
@ -140,12 +141,15 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(AuthUtil.getOrganizeCode());
DdlPreparedPack.getNumEqualPack(detailId, "partInspectionDetailId", packBean);
MesReworkTaskDetail mesReworkTaskDetail = mesReworkTaskDetailRepository.getByProperty(packBean);
if (mesReworkTaskDetail == null) {
List<MesReworkTaskDetail> mesReworkTaskDetailList = mesReworkTaskDetailRepository.findByHqlWhere(packBean);
if (CollectionUtils.isEmpty(mesReworkTaskDetailList)) {
MesPcnException.throwFlowException("返工单详情不存在");
}
mesReworkTaskDetail.setStatus(MesExtEnumUtil.REWORK_TASK_DETAIL_STATUS.REWORK_TASK_DETAIL_STATUS_20.getValue());
mesReworkTaskDetailRepository.save(mesReworkTaskDetail);
mesReworkTaskDetailList.forEach(mesReworkTaskDetail->{
mesReworkTaskDetail.setStatus(MesExtEnumUtil.REWORK_TASK_DETAIL_STATUS.REWORK_TASK_DETAIL_STATUS_20.getValue());
ConvertBean.serviceModelUpdate(mesReworkTaskDetail,AuthUtil.getSessionUser().getUserName());
});
mesReworkTaskDetailRepository.saveAll(mesReworkTaskDetailList);
}

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

@ -1,5 +1,6 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.model;
import cn.estsh.i3plus.pojo.mes.bean.MesDefectWarnConfig;
import cn.estsh.i3plus.pojo.mes.bean.MesLocationConfig;
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
import cn.estsh.i3plus.pojo.mes.bean.MesPartTypePicture;
@ -31,6 +32,9 @@ public class MesPartInspectionViewModel {
@ApiParam("NC-零件检测详情")
private List<MesPartInspectionDetail> partInspectionDetailList;
@ApiParam("缺陷告警配置")
private List<MesDefectWarnConfig> mesDefectWarnConfigList;
@ApiParam("图片")
private MesPartTypePicture partTypePicture;

Loading…
Cancel
Save