diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/mysql/plansubdetail/PlanSubDetailMapper.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/mysql/plansubdetail/PlanSubDetailMapper.java index b97744f3..b2fd04d4 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/mysql/plansubdetail/PlanSubDetailMapper.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/mysql/plansubdetail/PlanSubDetailMapper.java @@ -18,6 +18,7 @@ import com.chanko.yunxi.mes.module.system.dal.dataobject.user.AdminUserDO; import com.github.yulichang.wrapper.MPJLambdaWrapper; import org.apache.ibatis.annotations.Mapper; import com.chanko.yunxi.mes.module.heli.controller.admin.plansubdetail.vo.*; +import org.apache.ibatis.annotations.Param; import org.apache.poi.ss.formula.functions.T; import org.springframework.util.StringUtils; @@ -39,6 +40,8 @@ public interface PlanSubDetailMapper extends BaseMapperX { return selectPage(reqVO, query); } + + int deletedSubById(@Param("id")Long id); default PageResult selectPage(PlanSubDetailPageReqVO reqVO) { MPJLambdaWrapper query = new MPJLambdaWrapper<>(); diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/plansub/PlanSubServiceImpl.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/plansub/PlanSubServiceImpl.java index 01664bc3..10715bec 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/plansub/PlanSubServiceImpl.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/plansub/PlanSubServiceImpl.java @@ -125,10 +125,10 @@ public class PlanSubServiceImpl implements PlanSubService { in2DDO.setTwoDimDate(planSubSaveReqVO.getTwoDimDate()); in2DDO.setProjectPlanId(planSubSaveReqVO.getProjectPlanId()); in2DDO.setStartTwoDimDate(planSubSaveReqVO.getStartTwoDimDate()); - in2DDO.setTwoDimOwner(Long.valueOf(planSubSaveReqVO.getBlankOwner())); + in2DDO.setTwoDimOwner(Long.valueOf(planSubSaveReqVO.getTwoDimOwner())); in2DDO.setSubType("BLUEPRINT_2D"); in2DDO.setSeqNo(1L); - in2DDO.setDesignNum(Long.valueOf(planSubSaveReqVO.getBlankNum())); + in2DDO.setDesignNum(Long.valueOf(planSubSaveReqVO.getTwoDimNum())); in2DDO.setName(planSubSaveReqVO.getName()); in2DDO.setCode(projectOrderDO.getCode()); details.add(in2DDO); @@ -144,10 +144,10 @@ public class PlanSubServiceImpl implements PlanSubService { in3DDO.setProjectSubCode(planSubSaveReqVO.getProjectSubCode()); in3DDO.setTwoDimDate(planSubSaveReqVO.getThreeDimDate()); in3DDO.setStartTwoDimDate(planSubSaveReqVO.getStartThreeDimDate()); - in3DDO.setTwoDimOwner(Long.valueOf(planSubSaveReqVO.getBlankOwner())); + in3DDO.setTwoDimOwner(Long.valueOf(planSubSaveReqVO.getThreeDimOwner())); in3DDO.setSubType("BLUEPRINT_3D"); in3DDO.setSeqNo(1L); - in3DDO.setDesignNum(Long.valueOf(planSubSaveReqVO.getBlankNum())); + in3DDO.setDesignNum(Long.valueOf(planSubSaveReqVO.getThreeDimNum())); in3DDO.setName(planSubSaveReqVO.getName()); in3DDO.setCode(projectOrderDO.getCode()); details.add(in3DDO); diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/plansubdetail/PlanSubDetailServiceImpl.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/plansubdetail/PlanSubDetailServiceImpl.java index a9c20303..0e040975 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/plansubdetail/PlanSubDetailServiceImpl.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/plansubdetail/PlanSubDetailServiceImpl.java @@ -87,8 +87,9 @@ public class PlanSubDetailServiceImpl implements PlanSubDetailService { PlanSubDetailDO planSubDetailDO = planSubDetailMapper.selectById(id); // 获取当前日期时间 LocalDateTime now = LocalDateTime.now(); + LocalDateTime startDate = now.with(LocalTime.MIN); // 判断 当前时间是否在startTwoDimDate之后 - boolean isGreaterThanCurrent = now.isAfter(planSubDetailDO.getStartTwoDimDate()); + boolean isGreaterThanCurrent = startDate.compareTo(planSubDetailDO.getStartTwoDimDate()) > 0; if (isGreaterThanCurrent) return CommonResult.error(400,"当前日期>开始日期,不允许删除"); if (ObjectUtil.isNotEmpty(planSubDetailDO.getIsOverProcess()) && planSubDetailDO.getIsOverProcess() == 2 && planSubDetailDO.getSeqNo()==1){ return CommonResult.error(400,"该设计已报工,不允许删除"); @@ -155,7 +156,7 @@ public class PlanSubDetailServiceImpl implements PlanSubDetailService { } } planSubMapper.update(lambdaUpdateWrapper); - planSubDetailMapper.delete(new LambdaUpdateWrapper().eq(PlanSubDetailDO::getId,id)); + planSubDetailMapper.deletedSubById(id); return CommonResult.success(true); } @@ -301,9 +302,9 @@ public class PlanSubDetailServiceImpl implements PlanSubDetailService { wrapper.gt(PlanSubDetailDO::getSeqNo,updateReqVO.getSeqNo()); if (planSubDetailMapper.selectCount(wrapper)>0) return CommonResult.error(400,"该子项目存在多时间段派工,不允许从中间修改!"); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); -// queryWrapper.eq(PlanSubDetailDO::getProjectSubId,updateReqVO.getProjectSubId()); - queryWrapper.eq(PlanSubDetailDO::getTwoDimOwner,updateReqVO.getTwoDimOwner()); -// queryWrapper.eq(PlanSubDetailDO::getSubType,updateReqVO.getSubType()); + queryWrapper.eq(PlanSubDetailDO::getProjectSubId,updateReqVO.getProjectSubId()); +// queryWrapper.eq(PlanSubDetailDO::getTwoDimOwner,updateReqVO.getTwoDimOwner()); + queryWrapper.eq(PlanSubDetailDO::getSubType,updateReqVO.getSubType()); if (ObjectUtil.isNotEmpty(updateReqVO.getId())){ queryWrapper.ne(PlanSubDetailDO::getId,updateReqVO.getId()); } @@ -362,7 +363,7 @@ public class PlanSubDetailServiceImpl implements PlanSubDetailService { } } } - if (change || ObjectUtil.isEmpty(list) || (list.get(0).getStartTwoDimDate().compareTo(updateReqVO.getTwoDimDate()) > 0 )){ + if (change || ObjectUtil.isEmpty(list) ||(CollUtil.isNotEmpty(noSelfList)&& (noSelfList.get(0).getStartTwoDimDate().compareTo(updateReqVO.getTwoDimDate()) > 0 ))){ List newList = new ArrayList<>(); newList.addAll(list); if (ObjectUtil.isNotEmpty(updateReqVO.getId())){ @@ -390,13 +391,25 @@ public class PlanSubDetailServiceImpl implements PlanSubDetailService { planSubDetailDO.setDesignNum(updateReqVO.getDesignNum()); planSubDetailDO.setCode(updateReqVO.getCode()); newList.add(planSubDetailDO); - newList.sort(Comparator.comparing(PlanSubDetailDO::getStartTwoDimDate, Comparator.nullsLast(Comparator.naturalOrder()))); - for (int i = 0; i < newList.size(); i++) { - newList.get(i).setSeqNo(Long.valueOf(i + 1)); // 设置顺序为 1, 2, 3 - } + // newList.sort(Comparator.comparing(PlanSubDetailDO::getStartTwoDimDate, Comparator.nullsLast(Comparator.naturalOrder()))); planSubDetailMapper.insertOrUpdateBatch(newList); - - Map> collect = newList.stream().collect(Collectors.groupingBy(PlanSubDetailDO::getProjectSubId)); + LambdaQueryWrapper lambdaQueryWrapper1 = new LambdaQueryWrapper<>(); + lambdaQueryWrapper1.eq(PlanSubDetailDO::getProjectSubId,updateReqVO.getProjectSubId()); + lambdaQueryWrapper1.ge(PlanSubDetailDO::getSubType,updateReqVO.getSubType()); + lambdaQueryWrapper1.eq(PlanSubDetailDO::getTwoDimOwner,updateReqVO.getTwoDimOwner()); + lambdaQueryWrapper1.orderByAsc(PlanSubDetailDO::getStartTwoDimDate); + List planSubDetailDOS1 = planSubDetailMapper.selectList(lambdaQueryWrapper1); + Map> collect = planSubDetailDOS1.stream().collect(Collectors.groupingBy(PlanSubDetailDO::getProjectSubId)); + collect.forEach((id,detailList) -> { + Map> collect2 = detailList.stream().collect(Collectors.groupingBy(PlanSubDetailDO::getSubType)); + collect2.forEach((type,list2) ->{ + int i = 1; + for (PlanSubDetailDO planSubDetailDO1 : list2) { + planSubDetailDO1.setSeqNo(Long.valueOf(i++)); + } + }); + }); + planSubDetailMapper.updateBatch(planSubDetailDOS1); for (Map.Entry> entry : collect.entrySet()) { Long subId = entry.getKey(); List subList = entry.getValue(); @@ -485,6 +498,16 @@ public class PlanSubDetailServiceImpl implements PlanSubDetailService { } } + Map> groupBySubId = list.stream().collect(Collectors.groupingBy(PlanSubDetailDO::getProjectSubId)); + groupBySubId.forEach((id,detailList) -> { + Map> collect2 = detailList.stream().collect(Collectors.groupingBy(PlanSubDetailDO::getSubType)); + collect2.forEach((type,list2) ->{ + int i = 1; + for (PlanSubDetailDO planSubDetailDO : list2) { + planSubDetailDO.setSeqNo(Long.valueOf(i++)); + } + }); + }); planSubDetailMapper.updateBatch(list); //更新表主表数据 //先看有多少个子项目 @@ -1064,6 +1087,9 @@ public class PlanSubDetailServiceImpl implements PlanSubDetailService { return CommonResult.success(updateReqVO); } + /** + * 执行插活逻辑 + */ private List performInsertLogic(List baseList, List insertList, List holidayList) { @@ -1245,7 +1271,7 @@ public class PlanSubDetailServiceImpl implements PlanSubDetailService { remainingItem.setProjectPlanSubId(interruptedItem.getProjectPlanSubId()); remainingItem.setProjectSubCode(interruptedItem.getProjectSubCode()); remainingItem.setTwoDimOwner(interruptedItem.getTwoDimOwner()); - remainingItem.setProjectSubId(interruptedItem.getProjectPlanSubId()); + remainingItem.setProjectSubId(interruptedItem.getProjectSubId()); remainingItem.setSubType(interruptedItem.getSubType()); remainingItem.setName(interruptedItem.getName()); remainingItem.setCode(interruptedItem.getCode()); @@ -1260,8 +1286,12 @@ public class PlanSubDetailServiceImpl implements PlanSubDetailService { // 12. 添加剩余的插活数据(未被合并的) resultList.addAll(remainingInsertList); - // 13. 处理剩余的baseList - if (!remainingBaseList.isEmpty() || !afterInsertList.isEmpty()) { + // 13. 处理剩余的baseList(被打断的剩余部分 + 原本在插活数据之后的) + List allRemainingList = new ArrayList<>(); + allRemainingList.addAll(remainingBaseList); + allRemainingList.addAll(afterInsertList); + + if (!allRemainingList.isEmpty()) { // 获取插活数据的最后结束时间 final LocalDateTime lastInsertEndTime; if (mergedBaseItem != null) { @@ -1273,21 +1303,23 @@ public class PlanSubDetailServiceImpl implements PlanSubDetailService { .orElse(null); } - // 处理被打断的剩余部分 - for (PlanSubDetailDO baseItem : remainingBaseList) { - // 从插活数据的下一天开始计算 - LocalDateTime newStartTime = lastInsertEndTime.plusDays(1); - // 如果遇到节假日,继续跳过 - newStartTime = findNextNonHoliday(newStartTime, holidayList); + // 从插活数据的下一天开始顺延 + LocalDateTime baseStartTime = lastInsertEndTime.plusDays(1); + + for (PlanSubDetailDO baseItem : allRemainingList) { + // 找到下一个非节假日开始时间 + LocalDateTime newStartTime = findNextNonHoliday(baseStartTime, holidayList); + + // 根据designNum计算结束日期(包含节假日) LocalDateTime newEndTime = calculateEndDateByWorkDays(newStartTime, baseItem.getDesignNum(), holidayList); PlanSubDetailDO newBaseItem = createBaseItem(baseItem, newStartTime, newEndTime); newBaseItem.setDesignNum(baseItem.getDesignNum()); // 保持原始designNum resultList.add(newBaseItem); - } - // 处理原本在插活数据之后的baseList(保持原样) - resultList.addAll(afterInsertList); + // 更新下一个baseItem的开始时间 + baseStartTime = newEndTime.plusDays(1); + } } // 14. 按开始时间排序 @@ -1295,7 +1327,6 @@ public class PlanSubDetailServiceImpl implements PlanSubDetailService { return resultList; } - private LocalDateTime findNextNonHoliday(LocalDateTime startDate, List holidayList) { LocalDateTime current = startDate; while (holidayList.contains(current)) { diff --git a/mes-module-heli/mes-module-heli-biz/src/main/resources/mapper/plansubdetail/PlanSubMapper.xml b/mes-module-heli/mes-module-heli-biz/src/main/resources/mapper/plansubdetail/PlanSubMapper.xml new file mode 100644 index 00000000..97f208c4 --- /dev/null +++ b/mes-module-heli/mes-module-heli-biz/src/main/resources/mapper/plansubdetail/PlanSubMapper.xml @@ -0,0 +1,14 @@ + + + + + + + delete from project_plan_sub_detail where id = #{id} + + diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/interrupt/index.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/interrupt/index.vue index bf87c939..ecbfa59a 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/heli/interrupt/index.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/interrupt/index.vue @@ -597,7 +597,7 @@ const saveForm = async () => { } getList() } catch (error) { - message.error('失败:' + error.message) + // message.error('失败:' + error.message) } finally { loading.value = false } @@ -632,12 +632,14 @@ const modification = async (row) => { if (res.list) { //弹框 currentRow.value = row - beforeList.value = res.list + res.list.forEach(item =>{ + beforeList.value.push(item) + }) insertList.value = res.list dialogVisible.value = true dialogTitle.value = '插活前' } else { - await getList() + getList() message.success('修改成功') } }