diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesCraftRouteDetailServiceImpl.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesCraftRouteDetailServiceImpl.java index 7f321d6..c72043b 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesCraftRouteDetailServiceImpl.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/MesCraftRouteDetailServiceImpl.java @@ -23,6 +23,7 @@ import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @@ -58,7 +59,7 @@ public class MesCraftRouteDetailServiceImpl extends BaseMesService mesCraftRouteDetailList) { //校验数据 - checkData(mesCraftRouteDetailList, true); + checkData(mesCraftRouteDetailList); //校验工艺 checkCraft(mesCraftRouteDetailList, mesCraftRouteDetailList.iterator().next().getRouteCode()); //保存数据 @@ -81,7 +82,7 @@ public class MesCraftRouteDetailServiceImpl extends BaseMesService insertMesCraftRouteDetails = mesCraftRouteDetailList.stream().filter(t -> Objects.isNull(t.getId())).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(insertMesCraftRouteDetails)) { isCheckCraft = true; - insertMesCraftRouteDetails.forEach(t -> { - ConvertBean.serviceModelInitialize(t, userName); - }); routeCode = insertMesCraftRouteDetails.iterator().next().getRouteCode(); } //判断是否修改工艺代码 @@ -109,13 +107,26 @@ public class MesCraftRouteDetailServiceImpl extends BaseMesService routeDetailMap = mesCraftRouteDetailList.stream().filter(t -> !Objects.isNull(t.getId())) + .collect(Collectors.toMap(MesCraftRouteDetail::getId, t -> t)); //修改或者删除 for (MesCraftRouteDetail mesCraftRouteDetail : oldMesCraftRouteDetailList) { //判断是否删除数据 - boolean exist = mesCraftRouteDetailList.stream().anyMatch(t -> mesCraftRouteDetail.getId().equals(t.getId())); - if (!exist) { - deleteWeaklyById(mesCraftRouteDetail.getId(), mesCraftRouteDetail.getModifyUser()); + MesCraftRouteDetail newRouteDetail = routeDetailMap.get(mesCraftRouteDetail.getId()); + if (Objects.isNull(newRouteDetail)) { + deleteWeaklyById(mesCraftRouteDetail.getId(), userName); } else { + //修改 + mesCraftRouteDetail.setCraftCode(newRouteDetail.getCraftCode()); + mesCraftRouteDetail.setCraftName(newRouteDetail.getCraftName()); + mesCraftRouteDetail.setSeq(newRouteDetail.getSeq()); + mesCraftRouteDetail.setIsChoose(newRouteDetail.getIsChoose()); + mesCraftRouteDetail.setAtMostProcess(newRouteDetail.getAtMostProcess()); + mesCraftRouteDetail.setIsBindNextCraft(newRouteDetail.getIsBindNextCraft()); + mesCraftRouteDetail.setRepeatTimes(newRouteDetail.getRepeatTimes()); + mesCraftRouteDetail.setDescription(newRouteDetail.getDescription()); + ConvertBean.serviceModelUpdate(mesCraftRouteDetail, userName); update(mesCraftRouteDetail); } } @@ -142,7 +153,7 @@ public class MesCraftRouteDetailServiceImpl extends BaseMesService { if (!craftCodeList.contains(mesCraftRouteDetail.getCraftCode())) { - MesException.throwMesBusiException("工艺【%s】与其他工艺不属于同一流程【%s】", mesCraftRouteDetail.getCraftName(),routeCode); + MesException.throwMesBusiException("工艺【%s】与其他工艺不属于同一流程【%s】", mesCraftRouteDetail.getCraftName(), routeCode); } }); //非排序 @@ -151,7 +162,7 @@ public class MesCraftRouteDetailServiceImpl extends BaseMesService mesCraftRouteDetailList, boolean isInsert) { + private void checkData(List mesCraftRouteDetailList) { List seqList = new ArrayList<>(); List craftCodeList = new ArrayList<>(); String userName = AuthUtilExt.getUserName(); @@ -178,12 +189,7 @@ public class MesCraftRouteDetailServiceImpl extends BaseMesService mesCraftList = mesCraftService.findMesCraft(mesCraft, pager).getObjectList(); if (CollectionUtils.isEmpty(mesCraftList)) { - MesException.throwMesBusiException("工艺流程【%s】没有对应的工艺信息",routeCode); + MesException.throwMesBusiException("工艺流程【%s】没有对应的工艺信息", routeCode); } return mesCraftList.stream().map(MesCraft::getCraftCode).collect(Collectors.toList()); }