|
@ -838,7 +838,16 @@ public class HuzhouPlaninfoServiceImpl extends ServiceImpl<HuzhouPlaninfoMapper, |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void modifyPlaninfo(MultipartFile multipartFile, String projectid) throws Exception { |
|
|
public void modifyPlaninfo(MultipartFile multipartFile, String projectid) throws Exception { |
|
|
////解析项目计划文件
|
|
|
//增加文件修改条件:项目立项阶段全部完成之后才可以修改项目计划
|
|
|
|
|
|
LambdaQueryWrapper<HuzhouPlaninfo> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
queryWrapper.eq(HuzhouPlaninfo::getProjectId,projectid); |
|
|
|
|
|
queryWrapper.eq(HuzhouPlaninfo::getTaskName,"项目立项阶段"); |
|
|
|
|
|
queryWrapper.eq(HuzhouPlaninfo::getIsfinish,"2"); |
|
|
|
|
|
if ( this.list(queryWrapper).size()<1){ |
|
|
|
|
|
throw new EasyException("项目立项阶段未完成,无法修改项目计划!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//解析项目计划文件
|
|
|
HashMap<String, Object> hashMap = getPlanInfoListFromFile(multipartFile, projectid); |
|
|
HashMap<String, Object> hashMap = getPlanInfoListFromFile(multipartFile, projectid); |
|
|
//res是true 表示项目计划文件没有问题,如果是false说明文件有问题,需要抛出异常
|
|
|
//res是true 表示项目计划文件没有问题,如果是false说明文件有问题,需要抛出异常
|
|
|
boolean res = (boolean) hashMap.get("res"); |
|
|
boolean res = (boolean) hashMap.get("res"); |
|
@ -847,6 +856,7 @@ public class HuzhouPlaninfoServiceImpl extends ServiceImpl<HuzhouPlaninfoMapper, |
|
|
} |
|
|
} |
|
|
// List<HuzhouPlaninfo> excelList =(ArrayList<HuzhouPlaninfo>) hashMap.get("arr");
|
|
|
// List<HuzhouPlaninfo> excelList =(ArrayList<HuzhouPlaninfo>) hashMap.get("arr");
|
|
|
List<HuzhouPlaninfo> huzhouPlaninfoArrayList = (ArrayList<HuzhouPlaninfo>) hashMap.get("arr"); |
|
|
List<HuzhouPlaninfo> huzhouPlaninfoArrayList = (ArrayList<HuzhouPlaninfo>) hashMap.get("arr"); |
|
|
|
|
|
// 深克隆备份Excel重点计划以供后续做差集操作
|
|
|
List<HuzhouPlaninfo> excelList = SerializationUtils.clone((ArrayList<HuzhouPlaninfo>) hashMap.get("arr")); |
|
|
List<HuzhouPlaninfo> excelList = SerializationUtils.clone((ArrayList<HuzhouPlaninfo>) hashMap.get("arr")); |
|
|
String isAllow = IsAllowModifyPlaninfo(projectid, huzhouPlaninfoArrayList); |
|
|
String isAllow = IsAllowModifyPlaninfo(projectid, huzhouPlaninfoArrayList); |
|
|
if (!"1".equals(isAllow)) { |
|
|
if (!"1".equals(isAllow)) { |
|
@ -858,45 +868,9 @@ public class HuzhouPlaninfoServiceImpl extends ServiceImpl<HuzhouPlaninfoMapper, |
|
|
List<HuzhouPlaninfo> planinfoHistory = getListByProjectId(projectid); |
|
|
List<HuzhouPlaninfo> planinfoHistory = getListByProjectId(projectid); |
|
|
planinfoHistoryService.savePlanInfoToHistory(planinfoHistory); |
|
|
planinfoHistoryService.savePlanInfoToHistory(planinfoHistory); |
|
|
// 获取审批中和已完成的计划列表进行更新操作
|
|
|
// 获取审批中和已完成的计划列表进行更新操作
|
|
|
// 计算差集
|
|
|
updatePlanForShenPiAndFinished(huzhouPlaninfoArrayList, excelList, planinfoHistory); |
|
|
Set<String> keysFromHuzhouPlaninfoArrayList = huzhouPlaninfoArrayList.stream() |
|
|
|
|
|
.map(item ->item.getProjectId() + "-" + item.getTaskLevel()) |
|
|
|
|
|
.collect(Collectors.toSet()); |
|
|
|
|
|
|
|
|
|
|
|
List<HuzhouPlaninfo> tmpDifList = planinfoHistory.stream() |
|
|
|
|
|
.filter(item -> !keysFromHuzhouPlaninfoArrayList.contains(item.getProjectId() + "-" + item.getTaskLevel())) |
|
|
|
|
|
.filter(item -> { |
|
|
|
|
|
try { |
|
|
|
|
|
// 过滤条件:只保留 taskLevel 大于 2 的记录
|
|
|
|
|
|
BigDecimal taskLevel = new BigDecimal(item.getTaskLevel()); |
|
|
|
|
|
return taskLevel.compareTo(BigDecimal.valueOf(1.7)) >= 0; |
|
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
|
// 如果转换失败,可以选择处理异常或忽略这条记录
|
|
|
|
|
|
throw new EasyException("无法将 taskLevel 转换为数字: " + item.getTaskLevel()); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
// isFinish为0表示未开始,1审批中,2表示已完成 scheduledStartTime scheduledEndTime
|
|
|
|
|
|
Map<String, HuzhouPlaninfo> excelMap = excelList.stream() |
|
|
|
|
|
.collect(Collectors.toMap( |
|
|
|
|
|
item -> item.getTaskLevel(), |
|
|
|
|
|
item -> item |
|
|
|
|
|
)); |
|
|
|
|
|
// 遍历 tmpDifList,并根据 projectId 和 taskLevel 查找对应的 excelItem
|
|
|
|
|
|
tmpDifList.forEach(tmpItem -> { |
|
|
|
|
|
String key = tmpItem.getTaskLevel(); |
|
|
|
|
|
Optional.ofNullable(excelMap.get(key)).ifPresent(excelItem -> { |
|
|
|
|
|
tmpItem.setScheduledEndTime(excelItem.getScheduledEndTime()); |
|
|
|
|
|
tmpItem.setScheduledStartTime(excelItem.getScheduledStartTime()); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
huzhouPlaninfoArrayList.addAll(tmpDifList); |
|
|
//删除未开始 已完成 和审批中且taskLevel >= 1.7的项目
|
|
|
for (HuzhouPlaninfo huzhouPlaninfo : huzhouPlaninfoArrayList) { |
|
|
|
|
|
log.info("修改后的计划信息为{}",huzhouPlaninfo.getTaskLevel()); |
|
|
|
|
|
} |
|
|
|
|
|
//删除未开始 已完成 和审批中且taskLevel>2的项目
|
|
|
|
|
|
removeByProjectId(projectid); |
|
|
removeByProjectId(projectid); |
|
|
//将之前的分组id修改为最新的分组id
|
|
|
//将之前的分组id修改为最新的分组id
|
|
|
LambdaUpdateWrapper<HuzhouPlaninfo> wrapper = new LambdaUpdateWrapper<>(); |
|
|
LambdaUpdateWrapper<HuzhouPlaninfo> wrapper = new LambdaUpdateWrapper<>(); |
|
@ -905,6 +879,7 @@ public class HuzhouPlaninfoServiceImpl extends ServiceImpl<HuzhouPlaninfoMapper, |
|
|
update(null,wrapper); |
|
|
update(null,wrapper); |
|
|
//批量新增
|
|
|
//批量新增
|
|
|
saveBatch(huzhouPlaninfoArrayList); |
|
|
saveBatch(huzhouPlaninfoArrayList); |
|
|
|
|
|
|
|
|
//创建流程
|
|
|
//创建流程
|
|
|
WorkFlow workFlow = workflowService.createFlow("createPlaninfo",projectid); |
|
|
WorkFlow workFlow = workflowService.createFlow("createPlaninfo",projectid); |
|
|
Task task = workFlow.getTask(); |
|
|
Task task = workFlow.getTask(); |
|
@ -946,6 +921,47 @@ public class HuzhouPlaninfoServiceImpl extends ServiceImpl<HuzhouPlaninfoMapper, |
|
|
projectinfoService.modifyStageById(projectid,"4"); |
|
|
projectinfoService.modifyStageById(projectid,"4"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void updatePlanForShenPiAndFinished(List<HuzhouPlaninfo> huzhouPlaninfoArrayList, List<HuzhouPlaninfo> excelList, List<HuzhouPlaninfo> planinfoHistory) { |
|
|
|
|
|
// 计算差集
|
|
|
|
|
|
Set<String> keysFromHuzhouPlaninfoArrayList = huzhouPlaninfoArrayList.stream() |
|
|
|
|
|
.map(item ->item.getProjectId() + "-" + item.getTaskLevel()) |
|
|
|
|
|
.collect(Collectors.toSet()); |
|
|
|
|
|
|
|
|
|
|
|
List<HuzhouPlaninfo> tmpDifList = planinfoHistory.stream() |
|
|
|
|
|
.filter(item -> !keysFromHuzhouPlaninfoArrayList.contains(item.getProjectId() + "-" + item.getTaskLevel())) |
|
|
|
|
|
.filter(item -> { |
|
|
|
|
|
try { |
|
|
|
|
|
// 过滤条件:只保留 taskLevel 大于 2 的记录
|
|
|
|
|
|
BigDecimal taskLevel = new BigDecimal(item.getTaskLevel()); |
|
|
|
|
|
return taskLevel.compareTo(BigDecimal.valueOf(1.7)) >= 0; |
|
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
|
// 如果转换失败,可以选择处理异常或忽略这条记录
|
|
|
|
|
|
throw new EasyException("无法将 taskLevel 转换为数字: " + item.getTaskLevel()); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
// isFinish为0表示未开始,1审批中,2表示已完成 scheduledStartTime scheduledEndTime
|
|
|
|
|
|
Map<String, HuzhouPlaninfo> excelMap = excelList.stream() |
|
|
|
|
|
.collect(Collectors.toMap( |
|
|
|
|
|
item -> item.getTaskLevel(), |
|
|
|
|
|
item -> item |
|
|
|
|
|
)); |
|
|
|
|
|
// 遍历 tmpDifList,并根据 projectId 和 taskLevel 查找对应的 excelItem
|
|
|
|
|
|
tmpDifList.forEach(tmpItem -> { |
|
|
|
|
|
String key = tmpItem.getTaskLevel(); |
|
|
|
|
|
Optional.ofNullable(excelMap.get(key)).ifPresent(excelItem -> { |
|
|
|
|
|
tmpItem.setScheduledEndTime(excelItem.getScheduledEndTime()); |
|
|
|
|
|
tmpItem.setScheduledStartTime(excelItem.getScheduledStartTime()); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
huzhouPlaninfoArrayList.addAll(tmpDifList); |
|
|
|
|
|
// for (HuzhouPlaninfo huzhouPlaninfo : huzhouPlaninfoArrayList) {
|
|
|
|
|
|
// log.info("修改后的计划信息为{}",huzhouPlaninfo.getTaskLevel());
|
|
|
|
|
|
// }
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void downloadPlanInfo(HttpServletResponse response, String projectid) { |
|
|
public void downloadPlanInfo(HttpServletResponse response, String projectid) { |
|
|
LambdaQueryWrapper<HuzhouPlaninfo> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
LambdaQueryWrapper<HuzhouPlaninfo> queryWrapper = new LambdaQueryWrapper<>(); |
|
|