|
|
@@ -191,10 +191,11 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
.eq(AppPlan::getParentId, dto.getId()));
|
|
|
//如果子计划已存在
|
|
|
if (tempplan != null) {
|
|
|
+ //从停用状态下发,才会有已存在的子计划;
|
|
|
tempplan.setPlanStatus(d.getStatus() > 0 ? 1 : 2);
|
|
|
tempplan.setDistributePlanStatus(d.getStatus().toString());
|
|
|
tempplan.setDistributeStatus("1");
|
|
|
- if (immediateEffect) {
|
|
|
+ if (!immediateEffect) {
|
|
|
//停用状态下发,逻辑删除旧的计划,并生成一份副本
|
|
|
baseMapper.updateById(tempplan);
|
|
|
baseMapper.deleteById(tempplan);
|
|
|
@@ -204,9 +205,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
baseMapper.copyPlanOrgs(tempplan.getId(), hsPlanId);
|
|
|
baseMapper.copyPlanRoles(tempplan.getId(), hsPlanId);
|
|
|
baseMapper.copyPlanPoints(tempplan.getId(), hsPlanId);
|
|
|
-
|
|
|
- AppPlan newPlan = baseMapper.selectById(hsPlanId);
|
|
|
- hsPlans.add(newPlan);
|
|
|
+// AppPlan newPlan = baseMapper.selectById(hsPlanId);
|
|
|
} else {
|
|
|
baseMapper.updateById(tempplan);
|
|
|
}
|
|
|
@@ -266,18 +265,15 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
plan.setPlanStatus(1);
|
|
|
// plan.setBuildTaskNow(null);
|
|
|
|
|
|
- if (immediateEffect && ObjectUtil.equal(oldPlan.getPlanStatus(), PlanStatus.DELETED.getCode())) {
|
|
|
+ baseMapper.updateById(plan);
|
|
|
+ if (ObjectUtil.equal(oldPlan.getPlanStatus(), PlanStatus.DELETED.getCode())) {
|
|
|
//停用时下发且立即生效,逻辑删除旧计划并生成新计划
|
|
|
- baseMapper.updateById(plan);
|
|
|
-
|
|
|
baseMapper.copySelf(plan.getId(), parentId);
|
|
|
baseMapper.copyPlanPoints(plan.getId(), parentId);
|
|
|
baseMapper.copyPlanRoles(plan.getId(), parentId);
|
|
|
baseMapper.copyPlanOrgs(plan.getId(), parentId);
|
|
|
|
|
|
baseMapper.deleteById(plan);
|
|
|
- } else {
|
|
|
- baseMapper.updateById(plan);
|
|
|
}
|
|
|
|
|
|
if (immediateEffect) {
|
|
|
@@ -356,12 +352,12 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
.eq(AppPlan::getId, id);
|
|
|
baseMapper.update(null, updateWrapper);
|
|
|
|
|
|
- List<Long> childrenPlanIds = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>()
|
|
|
- .eq(AppPlan::getParentId, id)
|
|
|
- .select(AppPlan::getSolidId))
|
|
|
- .stream().map(AppPlan::getSolidId).collect(Collectors.toList());
|
|
|
- delete(childrenPlanIds);
|
|
|
+ List<AppPlan> childrenPlan = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>()
|
|
|
+ .eq(AppPlan::getParentId, id)
|
|
|
+ .select(AppPlan::getSolidId, AppPlan::getId));
|
|
|
+ delete(childrenPlan.stream().map(AppPlan::getId).collect(Collectors.toList()));
|
|
|
|
|
|
+ List<Long> childrenPlanIds = childrenPlan.stream().map(AppPlan::getSolidId).collect(Collectors.toList());
|
|
|
childrenPlanIds.add(plan.getSolidId());
|
|
|
deleteAllTaskByPlanId(childrenPlanIds);
|
|
|
}
|
|
|
@@ -452,6 +448,13 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * immediateEffect:参数无效
|
|
|
+ *
|
|
|
+ * @param app
|
|
|
+ * @param immediateEffect
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void saveOrUpdatePlan(AppPlanVo app, Boolean immediateEffect) throws Exception {
|
|
|
@@ -529,8 +532,9 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
LambdaQueryWrapper<AppPlanToPoint> pointWrapper = new LambdaQueryWrapper<>();
|
|
|
pointWrapper.eq(AppPlanToPoint::getPlanId, app.getId());
|
|
|
|
|
|
- Boolean needCopy = immediateEffect
|
|
|
- && ObjectUtil.equal(existPlan.getPlanStatus(), PlanStatus.USING.getCode());
|
|
|
+ //任务为使用中且有已完成或停用,则下个周期生效,需要副本;任务为使用中且无已完成,则删除所有任务,并重新生成任务
|
|
|
+ Boolean needCopy = (ObjectUtil.equal(app.getTaskHasCompleted(), 1)
|
|
|
+ && ObjectUtil.equal(existPlan.getPlanStatus(), PlanStatus.USING.getCode())) || ObjectUtil.equal(existPlan.getPlanStatus(), PlanStatus.DELETED.getCode());
|
|
|
List<Object> needRebuildPlans = new ArrayList<>();
|
|
|
//修改所有子计划
|
|
|
List<AppPlan> appPlans = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, plan.getId()));
|
|
|
@@ -548,7 +552,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
|
|
|
baseMapper.updateById(ap);
|
|
|
baseMapper.deleteById(ap.getId());
|
|
|
- child = baseMapper.selectById(newChildPlanId);
|
|
|
+ } else {
|
|
|
needRebuildPlans.add(child);
|
|
|
}
|
|
|
Map<Long, AppPlanToPoint> planPoints = appPlanToItemMapper.selectList(pointWrapper).stream()
|
|
|
@@ -630,8 +634,6 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
baseMapper.deleteById(app.getId());
|
|
|
|
|
|
plan.setId(newPlanID);
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//处理本计划关联
|
|
|
@@ -848,6 +850,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
plan.setPlanCreateOrgId(app.getPlanCreateOrgId());
|
|
|
plan.setPlanOfOrgId(app.getPlanOfOrgId());
|
|
|
plan.setPlanOfOrgType(app.getPlanOfOrgType());
|
|
|
+ plan.setTaskHasCompleted(app.getTaskHasCompleted());
|
|
|
return plan;
|
|
|
}
|
|
|
|