This commit is contained in:
Ledo 2025-10-10 00:38:41 +08:00
parent 630c2dec38
commit 0c167b4e0a
5 changed files with 82 additions and 32 deletions

View File

@ -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<PlanSubDetailDO> {
return selectPage(reqVO, query);
}
int deletedSubById(@Param("id")Long id);
default PageResult<PlanSubDetailDO> selectPage(PlanSubDetailPageReqVO reqVO) {
MPJLambdaWrapper<PlanSubDetailDO> query = new MPJLambdaWrapper<>();

View File

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

View File

@ -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<PlanSubDetailDO>().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<PlanSubDetailDO> 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<PlanSubDetailDO> 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<Long, List<PlanSubDetailDO>> collect = newList.stream().collect(Collectors.groupingBy(PlanSubDetailDO::getProjectSubId));
LambdaQueryWrapper<PlanSubDetailDO> 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<PlanSubDetailDO> planSubDetailDOS1 = planSubDetailMapper.selectList(lambdaQueryWrapper1);
Map<Long, List<PlanSubDetailDO>> collect = planSubDetailDOS1.stream().collect(Collectors.groupingBy(PlanSubDetailDO::getProjectSubId));
collect.forEach((id,detailList) -> {
Map<String, List<PlanSubDetailDO>> 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<Long, List<PlanSubDetailDO>> entry : collect.entrySet()) {
Long subId = entry.getKey();
List<PlanSubDetailDO> subList = entry.getValue();
@ -485,6 +498,16 @@ public class PlanSubDetailServiceImpl implements PlanSubDetailService {
}
}
Map<Long, List<PlanSubDetailDO>> groupBySubId = list.stream().collect(Collectors.groupingBy(PlanSubDetailDO::getProjectSubId));
groupBySubId.forEach((id,detailList) -> {
Map<String, List<PlanSubDetailDO>> 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<PlanSubDetailDO> performInsertLogic(List<PlanSubDetailDO> baseList,
List<PlanSubDetailDO> insertList,
List<LocalDateTime> 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<PlanSubDetailDO> 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<LocalDateTime> holidayList) {
LocalDateTime current = startDate;
while (holidayList.contains(current)) {

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chanko.yunxi.mes.module.heli.dal.mysql.plansubdetail.PlanSubDetailMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<delete id="deletedSubById" parameterType="java.lang.Long">
delete from project_plan_sub_detail where id = #{id}
</delete>
</mapper>

View File

@ -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('修改成功')
}
}