|
|
@@ -12,14 +12,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.xunmei.common.core.constant.ErrorMsgConstants;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
-import com.xunmei.common.core.domain.DateRange;
|
|
|
import com.xunmei.common.core.domain.R;
|
|
|
-import com.xunmei.common.core.enums.CycleCommonEnum;
|
|
|
+import com.xunmei.common.core.enums.OrgTypeEnum;
|
|
|
+import com.xunmei.common.core.enums.PlanStatus;
|
|
|
+import com.xunmei.common.core.enums.resumption.ResumptionTaskStatus;
|
|
|
import com.xunmei.common.core.exception.ServiceException;
|
|
|
import com.xunmei.common.core.domain.registerbook.domain.CoreRegisterBookPdf;
|
|
|
import com.xunmei.common.core.enums.RegisterBookType;
|
|
|
import com.xunmei.common.core.exception.SystemException;
|
|
|
import com.xunmei.common.core.utils.DateUtils;
|
|
|
+import com.xunmei.common.core.utils.IDHelper;
|
|
|
import com.xunmei.common.core.web.domain.AjaxResult;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
import com.xunmei.core.registerbook.service.ICoreRegisterBookPdfService;
|
|
|
@@ -30,6 +32,7 @@ import com.xunmei.core.resumption.dto.plan.CoreResumptionPlanPageDto;
|
|
|
import com.xunmei.core.resumption.mapper.*;
|
|
|
import com.xunmei.core.resumption.service.AppPlanService;
|
|
|
import com.xunmei.core.resumption.service.IResumptionRecordService;
|
|
|
+import com.xunmei.core.resumption.task.ResumptionTaskBusinessService;
|
|
|
import com.xunmei.core.resumption.vo.appPlan.AppPlanVo;
|
|
|
import com.xunmei.core.resumption.vo.appPlan.ResumptionPlanPageVo;
|
|
|
import com.xunmei.core.resumption.vo.appPlan.RuleItemVo;
|
|
|
@@ -44,14 +47,13 @@ import com.xunmei.system.api.domain.ResumptionPdf;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
import com.xunmei.system.api.function.RemoteCallHandlerExecutor;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.omg.IOP.TransactionService;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
@@ -91,6 +93,9 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
@Qualifier(ThreadPoolConfig.SOC_EXECUTOR)
|
|
|
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ResumptionTaskBusinessService resumptionTaskBusiness;
|
|
|
+
|
|
|
@Override
|
|
|
public List<Long> selectItemIdsByPlanId(Long id) {
|
|
|
return appPlanToItemMapper.selectItemIdsByPlanId(id);
|
|
|
@@ -171,22 +176,48 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void distributeToOrg(DistributeDto dto) {
|
|
|
+ @Transactional
|
|
|
+ public void distributeToOrg(DistributeDto dto, Boolean immediateEffect) {
|
|
|
+ AppPlan oldPlan = baseMapper.selectById(dto.getId());
|
|
|
+ Long parentId = IDHelper.id();
|
|
|
+ List<Object> hsPlans = new ArrayList<>();
|
|
|
//如果计划所属机构类型为省联社,生成下发子计划
|
|
|
- if (baseMapper.selectById(dto.getId()).getPlanOfOrgType() == 1) {
|
|
|
+ if (ObjectUtil.equal(oldPlan.getPlanOfOrgType(), 1L)) {
|
|
|
for (DistributeStatusDto d :
|
|
|
dto.getOrgAndStatus()) {
|
|
|
|
|
|
-
|
|
|
- AppPlan tempplan = baseMapper.selectOne(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getPlanOfOrgId, d.getOrgId()).eq(AppPlan::getParentId, dto.getId()));
|
|
|
+ AppPlan tempplan = baseMapper.selectOne(new LambdaQueryWrapper<AppPlan>()
|
|
|
+ .eq(AppPlan::getPlanOfOrgId, d.getOrgId())
|
|
|
+ .eq(AppPlan::getParentId, dto.getId()));
|
|
|
//如果子计划已存在
|
|
|
if (tempplan != null) {
|
|
|
tempplan.setPlanStatus(d.getStatus() > 0 ? 1 : 2);
|
|
|
tempplan.setDistributePlanStatus(d.getStatus().toString());
|
|
|
tempplan.setDistributeStatus("1");
|
|
|
- baseMapper.updateById(tempplan);
|
|
|
+ if (immediateEffect) {
|
|
|
+ //停用状态下发,逻辑删除旧的计划,并生成一份副本
|
|
|
+ baseMapper.updateById(tempplan);
|
|
|
+ baseMapper.deleteById(tempplan);
|
|
|
+
|
|
|
+ Long hsPlanId = IDHelper.id();
|
|
|
+ baseMapper.copyChildren(tempplan.getId(), hsPlanId, parentId);
|
|
|
+ baseMapper.copyPlanOrgs(tempplan.getId(), hsPlanId);
|
|
|
+ baseMapper.copyPlanRoles(tempplan.getId(), hsPlanId);
|
|
|
+ baseMapper.copyPlanPoints(tempplan.getId(), hsPlanId);
|
|
|
+
|
|
|
+ AppPlan newPlan = baseMapper.selectById(hsPlanId);
|
|
|
+ hsPlans.add(newPlan);
|
|
|
+ } else {
|
|
|
+ baseMapper.updateById(tempplan);
|
|
|
+ }
|
|
|
} else {
|
|
|
- AppPlan plan = baseMapper.selectById(dto.getId());
|
|
|
+ AppPlan plan = new AppPlan();
|
|
|
+ BeanUtils.copyProperties(oldPlan, plan);
|
|
|
+ if (immediateEffect) {
|
|
|
+ hsPlans.add(plan);
|
|
|
+ }
|
|
|
+ plan.setSolidId(IDHelper.id());
|
|
|
+ plan.setParentSolidId(oldPlan.getSolidId());
|
|
|
plan.setOrgId(d.getOrgId().toString());
|
|
|
plan.setDistributeStatus("1");
|
|
|
plan.setPlanOfOrgId(d.getOrgId());
|
|
|
@@ -198,6 +229,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
// plan.setPlanName(plan.getPlanName()+"下发"+orgService.selectOrgById(d.getOrgId(),SecurityConstants.INNER).getName());
|
|
|
plan.setPlanName(plan.getPlanName());
|
|
|
plan.setParentId(dto.getId());
|
|
|
+
|
|
|
baseMapper.insert(plan);
|
|
|
Long id = plan.getId();
|
|
|
|
|
|
@@ -219,7 +251,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
item.setPointScan(ruleItemVo.isPointScan());
|
|
|
item.setRequired(ruleItemVo.isRequired());
|
|
|
item.setOfOrgId(ruleItemVo.getOfOrgId());
|
|
|
- item.setEffectiveDate(ruleItemVo.getEffectiveDate());
|
|
|
+// item.setEffectiveDate(ruleItemVo.getEffectiveDate());
|
|
|
appPlanToItemMapper.insert(item);
|
|
|
}
|
|
|
}
|
|
|
@@ -232,51 +264,31 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
plan.setDistribute("1");
|
|
|
//设置计划状态为使用中
|
|
|
plan.setPlanStatus(1);
|
|
|
- plan.setBuildTaskNow(null);
|
|
|
- baseMapper.updateById(plan);
|
|
|
- }
|
|
|
+// plan.setBuildTaskNow(null);
|
|
|
|
|
|
- @Override
|
|
|
- public void cheHui(Long id) {
|
|
|
- AppPlan plan = baseMapper.selectById(id);
|
|
|
- //修改所有子计划
|
|
|
- List<AppPlan> appPlans = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, id));
|
|
|
- List<Long> deleteByPlanIds = new ArrayList<>();//如果计划没有已完成 ,则删除该计划所有任务
|
|
|
- for (AppPlan ap :
|
|
|
- appPlans) {
|
|
|
-//修改计划状态为停用
|
|
|
- ap.setBuildTaskNow(0);
|
|
|
- ap.setPlanStatus(2);
|
|
|
- baseMapper.updateById(ap);
|
|
|
-
|
|
|
- if (ObjectUtil.notEqual(plan.getTaskHasCompleted(), 1)) {
|
|
|
- deleteByPlanIds.add(ap.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- //设置下发状态为未下发
|
|
|
- plan.setDistribute("0");
|
|
|
- plan.setPlanStatus(2);
|
|
|
- plan.setBuildTaskNow(0);
|
|
|
- baseMapper.updateById(plan);
|
|
|
-
|
|
|
- if (ObjectUtil.notEqual(plan.getTaskHasCompleted(), 1)) {
|
|
|
- deleteByPlanIds.add(plan.getId());
|
|
|
- }
|
|
|
+ if (immediateEffect && ObjectUtil.equal(oldPlan.getPlanStatus(), PlanStatus.DELETED.getCode())) {
|
|
|
+ //停用时下发且立即生效,逻辑删除旧计划并生成新计划
|
|
|
+ baseMapper.updateById(plan);
|
|
|
|
|
|
- deleteTaskByPlanId(deleteByPlanIds);
|
|
|
- }
|
|
|
+ baseMapper.copySelf(plan.getId(), parentId);
|
|
|
+ baseMapper.copyPlanPoints(plan.getId(), parentId);
|
|
|
+ baseMapper.copyPlanRoles(plan.getId(), parentId);
|
|
|
+ baseMapper.copyPlanOrgs(plan.getId(), parentId);
|
|
|
|
|
|
- @Async
|
|
|
- protected void deleteTaskByPlanId(List<Long> planIds) {
|
|
|
- if(CollectionUtils.isEmpty(planIds)){
|
|
|
- return;
|
|
|
+ baseMapper.deleteById(plan);
|
|
|
+ } else {
|
|
|
+ baseMapper.updateById(plan);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (immediateEffect) {
|
|
|
+ resumptionTaskBusiness.rebuildCurrentCycleTask(hsPlans);
|
|
|
}
|
|
|
- resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().in(Resumption::getPlanId, planIds));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public AppPlan distributeCheHui(Long id) {
|
|
|
+ public AppPlan distributeHS(Long id, Boolean immediateEffect) {
|
|
|
AppPlan plan = baseMapper.selectById(id);
|
|
|
+ Integer planStatus = plan.getPlanStatus();
|
|
|
//设置计划状态
|
|
|
plan.setPlanStatus(1);
|
|
|
//如果是行社撤回需要修改下发状态
|
|
|
@@ -286,10 +298,125 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
} else {
|
|
|
plan.setDistribute("0");
|
|
|
}
|
|
|
- baseMapper.updateById(plan);
|
|
|
+
|
|
|
+ //
|
|
|
+ if (immediateEffect) {
|
|
|
+ List<Object> newlist = new ArrayList<>();
|
|
|
+ if (ObjectUtil.equal(planStatus, PlanStatus.DRAFT.getCode())) {
|
|
|
+ //草稿状态下发,立即生效则生成任务
|
|
|
+ newlist.add(plan);
|
|
|
+ baseMapper.updateById(plan);
|
|
|
+ } else if (ObjectUtil.equal(planStatus, PlanStatus.DELETED.getCode())) {
|
|
|
+ //停用状态下发,逻辑删除旧计划,并生成计划的副本,并更新任务名称和关联的计划id
|
|
|
+ baseMapper.updateById(plan);
|
|
|
+ baseMapper.deleteById(plan.getId());
|
|
|
+ Long newPlanId = IDHelper.id();
|
|
|
+ copyHsPlan(id, newPlanId);
|
|
|
+
|
|
|
+ AppPlan newPlan = baseMapper.selectById(newPlanId);
|
|
|
+ newlist.add(newPlan);
|
|
|
+ }
|
|
|
+
|
|
|
+ resumptionTaskBusiness.rebuildCurrentCycleTask(newlist);
|
|
|
+ } else {
|
|
|
+ baseMapper.updateById(plan);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return plan;
|
|
|
}
|
|
|
|
|
|
+ private void copyHsPlan(Long id, Long newPlanId) {
|
|
|
+ baseMapper.copySelf(id, newPlanId);
|
|
|
+ baseMapper.copyPlanPoints(id, newPlanId);
|
|
|
+ baseMapper.copyPlanRoles(id, newPlanId);
|
|
|
+ baseMapper.copyPlanOrgs(id, newPlanId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void cheHui(Long id) {
|
|
|
+ AppPlan plan = baseMapper.selectById(id);
|
|
|
+ if (ObjectUtil.equal(plan.getTaskHasCompleted(), 1)) {
|
|
|
+ //有已完成时,计划及子计划状态变为停用,不删除任务
|
|
|
+ LambdaUpdateWrapper<AppPlan> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(AppPlan::getPlanStatus, 2)
|
|
|
+ .eq(AppPlan::getParentId, id);
|
|
|
+ baseMapper.update(null, updateWrapper);
|
|
|
+
|
|
|
+ updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(AppPlan::getPlanStatus, 2)
|
|
|
+ .set(AppPlan::getDistribute, 0)
|
|
|
+ .eq(AppPlan::getId, id);
|
|
|
+ baseMapper.update(null, updateWrapper);
|
|
|
+ } else {
|
|
|
+ //无已完成时,删除子计划,计划本身变为草稿
|
|
|
+ LambdaUpdateWrapper<AppPlan> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(AppPlan::getPlanStatus, 0)
|
|
|
+ .set(AppPlan::getDistribute, 0)
|
|
|
+ .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);
|
|
|
+
|
|
|
+ childrenPlanIds.add(plan.getSolidId());
|
|
|
+ deleteAllTaskByPlanId(childrenPlanIds);
|
|
|
+ }
|
|
|
+//
|
|
|
+// //修改所有子计划
|
|
|
+// List<AppPlan> appPlans = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, id));
|
|
|
+// List<Long> deleteByPlanIds = new ArrayList<>();//如果计划没有已完成 ,则删除该计划所有任务
|
|
|
+// for (AppPlan ap :
|
|
|
+// appPlans) {
|
|
|
+////修改计划状态为停用
|
|
|
+// ap.setBuildTaskNow(0);
|
|
|
+// ap.setPlanStatus(2);
|
|
|
+// baseMapper.updateById(ap);
|
|
|
+//
|
|
|
+// if (ObjectUtil.notEqual(plan.getTaskHasCompleted(), 1)) {
|
|
|
+// deleteByPlanIds.add(ap.getId());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //设置下发状态为未下发
|
|
|
+// plan.setDistribute("0");
|
|
|
+// plan.setPlanStatus(2);
|
|
|
+// plan.setBuildTaskNow(0);
|
|
|
+// baseMapper.updateById(plan);
|
|
|
+//
|
|
|
+// if (ObjectUtil.notEqual(plan.getTaskHasCompleted(), 1)) {
|
|
|
+// deleteByPlanIds.add(plan.getId());
|
|
|
+// }
|
|
|
+//
|
|
|
+// deleteTaskByPlanId(deleteByPlanIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Async
|
|
|
+ protected void deleteTaskByPlanId(List<Long> solidPlanIds) {
|
|
|
+ if (CollectionUtils.isEmpty(solidPlanIds)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Date date = DateUtil.beginOfDay(new Date());
|
|
|
+ resumptionMapper.delete(new LambdaQueryWrapper<Resumption>()
|
|
|
+ .in(Resumption::getSolidId, solidPlanIds)
|
|
|
+ .ne(Resumption::getStatus, ResumptionTaskStatus.Completed.getCode())
|
|
|
+ .and(w ->
|
|
|
+ w.ge(Resumption::getYmdDate, date)
|
|
|
+ .or(w1 -> w1.le(Resumption::getPlanEndTime, date))
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Async
|
|
|
+ protected void deleteAllTaskByPlanId(List<Long> solidPlanIds) {
|
|
|
+ if (CollectionUtils.isEmpty(solidPlanIds)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ resumptionMapper.delete(new LambdaQueryWrapper<Resumption>()
|
|
|
+ .in(Resumption::getSolidId, solidPlanIds));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取检查要点分页
|
|
|
*
|
|
|
@@ -327,7 +454,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void saveOrUpdatePlan(AppPlanVo app) throws Exception {
|
|
|
+ public void saveOrUpdatePlan(AppPlanVo app, Boolean immediateEffect) throws Exception {
|
|
|
AppPlan plan = convertToAppPlan(app);
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.set(2000, 0, 1);
|
|
|
@@ -335,6 +462,8 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
if (app.getId() == null) {
|
|
|
plan.setParentId(-1L);
|
|
|
plan.setDeleted(0);
|
|
|
+ plan.setSolidId(IDHelper.id());
|
|
|
+ plan.setParentSolidId(-1L);
|
|
|
plan.setCreateTime(new Date());
|
|
|
//新增
|
|
|
plan.setPlanOfOrgId(app.getPlanCreateOrgId());
|
|
|
@@ -349,7 +478,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
throw new RuntimeException("计划名称重复,请确认!");
|
|
|
}
|
|
|
|
|
|
- plan.setBuildTaskNow(app.getBuildTaskNow());
|
|
|
+// plan.setBuildTaskNow(app.getBuildTaskNow());
|
|
|
plan.setDistribute("0");
|
|
|
plan.setPlanStatus(0);
|
|
|
//设置计划所属机构类型
|
|
|
@@ -388,7 +517,6 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
item.setPointScan(ruleItemVo.isPointScan());
|
|
|
item.setRequired(ruleItemVo.isRequired());
|
|
|
item.setOfOrgId(ruleItemVo.getOfOrgId());
|
|
|
- item.setEffectiveDate(calendar.getTime());
|
|
|
appPlanToItemMapper.insert(item);
|
|
|
}
|
|
|
} else {
|
|
|
@@ -396,40 +524,58 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
app.setRoleList(new ArrayList<>());
|
|
|
}
|
|
|
|
|
|
+ Long newPlanID = IDHelper.id();
|
|
|
AppPlan existPlan = baseMapper.selectById(app.getId());
|
|
|
LambdaQueryWrapper<AppPlanToPoint> pointWrapper = new LambdaQueryWrapper<>();
|
|
|
pointWrapper.eq(AppPlanToPoint::getPlanId, app.getId());
|
|
|
|
|
|
-
|
|
|
+ Boolean needCopy = immediateEffect
|
|
|
+ && ObjectUtil.equal(existPlan.getPlanStatus(), PlanStatus.USING.getCode());
|
|
|
+ List<Object> needRebuildPlans = new ArrayList<>();
|
|
|
//修改所有子计划
|
|
|
List<AppPlan> appPlans = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, plan.getId()));
|
|
|
+
|
|
|
for (AppPlan ap :
|
|
|
appPlans) {
|
|
|
+ AppPlan child = ap;
|
|
|
+ if (needCopy) {
|
|
|
+ //使用中状态且立即生效,复制副本
|
|
|
+ Long newChildPlanId = IDHelper.id();
|
|
|
+ baseMapper.copyChildren(ap.getId(), newChildPlanId, newPlanID);
|
|
|
+ baseMapper.copyPlanOrgs(ap.getId(), newChildPlanId);
|
|
|
+ baseMapper.copyPlanRoles(ap.getId(), newChildPlanId);
|
|
|
+ baseMapper.copyPlanPoints(ap.getId(), newChildPlanId);
|
|
|
+
|
|
|
+ baseMapper.updateById(ap);
|
|
|
+ baseMapper.deleteById(ap.getId());
|
|
|
+ child = baseMapper.selectById(newChildPlanId);
|
|
|
+ needRebuildPlans.add(child);
|
|
|
+ }
|
|
|
Map<Long, AppPlanToPoint> planPoints = appPlanToItemMapper.selectList(pointWrapper).stream()
|
|
|
.collect(Collectors.toMap(AppPlanToPoint::getPointId, p -> p));
|
|
|
- Date defaultEffectiveDate = calendar.getTime();
|
|
|
- if (ObjectUtil.equal(ap.getTaskHasCompleted(), 1)) {
|
|
|
- DateRange range = DateUtils.getStartAndEnd(new Date(), CycleCommonEnum.getEnum(app.getPlanCycle()));
|
|
|
- defaultEffectiveDate = DateUtil.beginOfDay(DateUtils.addDays(range.getEndTime(), 1));
|
|
|
- }
|
|
|
+// Date defaultEffectiveDate = calendar.getTime();
|
|
|
+// if (ObjectUtil.equal(ap.getTaskHasCompleted(), 1)) {
|
|
|
+// DateRange range = DateUtils.getStartAndEnd(new Date(), CycleCommonEnum.getEnum(app.getPlanCycle()));
|
|
|
+// defaultEffectiveDate = DateUtil.beginOfDay(DateUtils.addDays(range.getEndTime(), 1));
|
|
|
+// }
|
|
|
|
|
|
- ap.setPlanType(plan.getPlanType());
|
|
|
- ap.setPlanCycle(plan.getPlanCycle());
|
|
|
- ap.setExecOrgType(plan.getExecOrgType());
|
|
|
- ap.setPlanExec(plan.getPlanExec());
|
|
|
- ap.setModifiedBy(SecurityUtils.getUserId());
|
|
|
- ap.setPlanName(plan.getPlanName());
|
|
|
- ap.setCount(plan.getCount());
|
|
|
- baseMapper.updateById(ap);
|
|
|
+ child.setPlanType(plan.getPlanType());
|
|
|
+ child.setPlanCycle(plan.getPlanCycle());
|
|
|
+ child.setExecOrgType(plan.getExecOrgType());
|
|
|
+ child.setPlanExec(plan.getPlanExec());
|
|
|
+ child.setModifiedBy(SecurityUtils.getUserId());
|
|
|
+ child.setPlanName(plan.getPlanName());
|
|
|
+ child.setCount(plan.getCount());
|
|
|
+ baseMapper.updateById(child);
|
|
|
|
|
|
if (app.getRoleList().size() > 0) {
|
|
|
QueryWrapper<AppPlanToRole> apr = new QueryWrapper<>();
|
|
|
- apr.lambda().eq(AppPlanToRole::getPlanId, ap.getId());
|
|
|
+ apr.lambda().eq(AppPlanToRole::getPlanId, child.getId());
|
|
|
appPlanToRoleMapper.delete(apr);
|
|
|
}
|
|
|
|
|
|
QueryWrapper<AppPlanToPoint> api = new QueryWrapper<>();
|
|
|
- api.lambda().eq(AppPlanToPoint::getPlanId, ap.getId()).eq(AppPlanToPoint::getOfOrgId, app.getPlanCreateOrgId());
|
|
|
+ api.lambda().eq(AppPlanToPoint::getPlanId, child.getId()).eq(AppPlanToPoint::getOfOrgId, app.getPlanCreateOrgId());
|
|
|
appPlanToItemMapper.delete(api);
|
|
|
|
|
|
List<Long> roleList = app.getRoleList();
|
|
|
@@ -437,7 +583,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
for (Long roleId : roleList) {
|
|
|
atr = new AppPlanToRole();
|
|
|
atr.setRoleId(roleId);
|
|
|
- atr.setPlanId(ap.getId());
|
|
|
+ atr.setPlanId(child.getId());
|
|
|
appPlanToRoleMapper.insert(atr);
|
|
|
}
|
|
|
|
|
|
@@ -454,28 +600,39 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
for (RuleItemVo ruleItemVo : itemList) {
|
|
|
item = new AppPlanToPoint();
|
|
|
item.setPointId(ruleItemVo.getId());
|
|
|
- item.setPlanId(ap.getId());
|
|
|
+ item.setPlanId(child.getId());
|
|
|
item.setPointScan(ruleItemVo.isPointScan());
|
|
|
item.setRequired(ruleItemVo.isRequired());
|
|
|
item.setOfOrgId(ruleItemVo.getOfOrgId());
|
|
|
- if (planPoints.containsKey(ruleItemVo.getId())) {
|
|
|
- item.setEffectiveDate(planPoints.get(ruleItemVo.getId()).getEffectiveDate());
|
|
|
- } else {
|
|
|
- item.setEffectiveDate(defaultEffectiveDate);
|
|
|
- }
|
|
|
+// if (planPoints.containsKey(ruleItemVo.getId())) {
|
|
|
+// item.setEffectiveDate(planPoints.get(ruleItemVo.getId()).getEffectiveDate());
|
|
|
+// } else {
|
|
|
+// item.setEffectiveDate(defaultEffectiveDate);
|
|
|
+// }
|
|
|
|
|
|
appPlanToItemMapper.insert(item);
|
|
|
}
|
|
|
//如果计划是编辑全部,代表不存在已完成或者逾期的任务,需要删除重新生成
|
|
|
- if (app.getHasEdit() == null) {
|
|
|
- resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, ap.getId()));
|
|
|
- } else {
|
|
|
- //否则代表编辑名称,需要同步未进行的任务名称
|
|
|
- resumptionMapper.updateNameByPlanId(existPlan.getPlanName(),app.getPlanName(), ap.getId());
|
|
|
- }
|
|
|
-
|
|
|
+// if (app.getHasEdit() == null) {
|
|
|
+// resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, ap.getId()));
|
|
|
+// } else {
|
|
|
+// //否则代表编辑名称,需要同步未进行的任务名称
|
|
|
+// resumptionMapper.updateNameByPlanId(existPlan.getPlanName(), app.getPlanName(), ap.getId());
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
+ if (needCopy) {
|
|
|
+ baseMapper.copySelf(existPlan.getId(), newPlanID);
|
|
|
+ baseMapper.copyPlanOrgs(existPlan.getId(), newPlanID);
|
|
|
+ baseMapper.copyPlanRoles(existPlan.getId(), newPlanID);
|
|
|
+ baseMapper.copyPlanPoints(existPlan.getId(), newPlanID);
|
|
|
+
|
|
|
+ baseMapper.deleteById(app.getId());
|
|
|
+
|
|
|
+ plan.setId(newPlanID);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
//处理本计划关联
|
|
|
Long id = plan.getId();
|
|
|
@@ -520,7 +677,6 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
item.setPointScan(ruleItemVo.isPointScan());
|
|
|
item.setRequired(ruleItemVo.isRequired());
|
|
|
item.setOfOrgId(ruleItemVo.getOfOrgId());
|
|
|
- item.setEffectiveDate(calendar.getTime());
|
|
|
appPlanToItemMapper.insert(item);
|
|
|
}
|
|
|
|
|
|
@@ -534,7 +690,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
appPlanToExecOrgMapper.insert(execOrg);
|
|
|
}
|
|
|
//更新任务的名称
|
|
|
- resumptionMapper.updateNameByPlanId(existPlan.getPlanName(),app.getPlanName(), app.getId());
|
|
|
+ resumptionMapper.updateNameByPlanId(existPlan.getPlanName(), app.getPlanName(), app.getId());
|
|
|
|
|
|
//最后处理本计划
|
|
|
plan.setUpdateTime(new Date());
|
|
|
@@ -545,6 +701,11 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
plan.setPlanCreateOrgId(null);
|
|
|
plan.setPlanCreateOrgName(null);
|
|
|
baseMapper.updateById(plan);
|
|
|
+
|
|
|
+ if (needCopy && ObjectUtil.equal(plan.getPlanOfOrgType(), OrgTypeEnum.HANG_SHE.getCode().longValue())) {
|
|
|
+ needRebuildPlans.add(baseMapper.selectById(plan.getId()));
|
|
|
+ }
|
|
|
+ resumptionTaskBusiness.rebuildCurrentCycleTask(needRebuildPlans);
|
|
|
// //如果计划是编辑全部,代表不存在已完成或者逾期的任务,需要删除重新生成
|
|
|
// if (ObjectUtil.notEqual(existPlan.getTaskHasCompleted(),1)) {
|
|
|
// resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, plan.getId()));
|
|
|
@@ -554,7 +715,6 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
|
|
|
@Override
|
|
|
public AppPlanVo findById(Long id) {
|
|
|
-
|
|
|
AppPlan appPlan = baseMapper.selectById(id);
|
|
|
|
|
|
AppPlanVo appPlanVo = convertToAppPlanVo(appPlan);
|
|
|
@@ -626,69 +786,49 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void deleted(Long id) throws Exception {
|
|
|
- /**
|
|
|
- * 验证计划是否被应用
|
|
|
- */
|
|
|
- Long num = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", id).in("status", 3, 4));
|
|
|
- if (num > 0) {
|
|
|
- throw new RuntimeException("计划有已完成或者已逾期的任务,不能被删除。");
|
|
|
- }
|
|
|
- //查找子计划
|
|
|
- List<AppPlan> childrens = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, id));
|
|
|
-
|
|
|
- //删除子计划
|
|
|
- for (AppPlan ap :
|
|
|
- childrens) {
|
|
|
- Long nums = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", ap.getId()).eq("status", 3));
|
|
|
- if (nums > 0) {
|
|
|
- throw new RuntimeException("子计划有已完成或者已逾期的任务,不能被删除。");
|
|
|
- }
|
|
|
- //删除计划对应的任务
|
|
|
- resumptionMapper.delete(new QueryWrapper<Resumption>().eq("plan_id", ap.getId()));
|
|
|
- //删除对应的角色关系
|
|
|
- QueryWrapper<AppPlanToRole> qw = new QueryWrapper<>();
|
|
|
- qw.lambda().eq(AppPlanToRole::getPlanId, ap.getId());
|
|
|
- appPlanToRoleMapper.delete(qw);
|
|
|
-
|
|
|
- //删除对应的要点关系
|
|
|
- QueryWrapper<AppPlanToPoint> aw = new QueryWrapper<>();
|
|
|
- aw.lambda().eq(AppPlanToPoint::getPlanId, ap.getId());
|
|
|
- appPlanToItemMapper.delete(aw);
|
|
|
-
|
|
|
- //删除机构关系
|
|
|
- QueryWrapper<AppPlanToExecOrg> apo = new QueryWrapper<>();
|
|
|
- apo.lambda().eq(AppPlanToExecOrg::getPlanId, ap.getId());
|
|
|
- appPlanToExecOrgMapper.delete(apo);
|
|
|
-
|
|
|
- //删除本尊
|
|
|
- baseMapper.deleteById(ap.getId());
|
|
|
+ AppPlan plan = baseMapper.selectById(id);
|
|
|
+ List<AppPlan> plans = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>()
|
|
|
+ .eq(AppPlan::getId, id).or().eq(AppPlan::getParentId, id)
|
|
|
+ .select(AppPlan::getId, AppPlan::getSolidId));
|
|
|
|
|
|
+ if (ObjectUtil.equal(plan.getTaskHasCompleted(), 1)) {
|
|
|
+ //有已完成时,计划逻辑删除,删除当前轮次及之后未完成的任务
|
|
|
+ LambdaQueryWrapper<AppPlan> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(AppPlan::getId, plans.stream().map(AppPlan::getId).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ baseMapper.delete(wrapper);
|
|
|
+ deleteTaskByPlanId(plans.stream().map(AppPlan::getSolidId).collect(Collectors.toList()));
|
|
|
+ } else {
|
|
|
+ //无已完成时,计划物理删除,删除所有任务
|
|
|
+
|
|
|
+
|
|
|
+ delete(plans.stream().map(AppPlan::getId).collect(Collectors.toList()));
|
|
|
+ deleteAllTaskByPlanId(plans.stream().map(AppPlan::getSolidId).collect(Collectors.toList()));
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- //删除计划对应的任务
|
|
|
- resumptionMapper.delete(new QueryWrapper<Resumption>().eq("plan_id", id));
|
|
|
+ private void delete(List<Long> planIds) {
|
|
|
+ if (ObjectUtil.isEmpty(planIds)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
//删除对应的角色关系
|
|
|
QueryWrapper<AppPlanToRole> qw = new QueryWrapper<>();
|
|
|
- qw.lambda().eq(AppPlanToRole::getPlanId, id);
|
|
|
+ qw.lambda().in(AppPlanToRole::getPlanId, planIds);
|
|
|
appPlanToRoleMapper.delete(qw);
|
|
|
|
|
|
//删除对应的要点关系
|
|
|
QueryWrapper<AppPlanToPoint> aw = new QueryWrapper<>();
|
|
|
- aw.lambda().eq(AppPlanToPoint::getPlanId, id);
|
|
|
+ aw.lambda().in(AppPlanToPoint::getPlanId, planIds);
|
|
|
appPlanToItemMapper.delete(aw);
|
|
|
|
|
|
//删除机构关系
|
|
|
QueryWrapper<AppPlanToExecOrg> apo = new QueryWrapper<>();
|
|
|
- apo.lambda().eq(AppPlanToExecOrg::getPlanId, id);
|
|
|
+ apo.lambda().in(AppPlanToExecOrg::getPlanId, planIds);
|
|
|
appPlanToExecOrgMapper.delete(apo);
|
|
|
|
|
|
- //删除本尊
|
|
|
- baseMapper.deleteById(id);
|
|
|
-
|
|
|
-
|
|
|
+ baseMapper.physicsDeleteById(planIds);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private AppPlanVo convertToAppPlanVo(AppPlan app) {
|
|
|
AppPlanVo plan = new AppPlanVo();
|
|
|
plan.setExecType(app.getExecType());
|
|
|
@@ -704,11 +844,10 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
plan.setExecOrgType(app.getExecOrgType());
|
|
|
plan.setDistributePlanStatus(app.getDistributePlanStatus());
|
|
|
plan.setCount(app.getCount());
|
|
|
- plan.setBuildTaskNow(app.getBuildTaskNow());
|
|
|
+// plan.setBuildTaskNow(app.getBuildTaskNow());
|
|
|
plan.setPlanCreateOrgId(app.getPlanCreateOrgId());
|
|
|
plan.setPlanOfOrgId(app.getPlanOfOrgId());
|
|
|
plan.setPlanOfOrgType(app.getPlanOfOrgType());
|
|
|
- plan.setHasEdit(app.getTaskHasCompleted());
|
|
|
return plan;
|
|
|
}
|
|
|
|
|
|
@@ -741,7 +880,8 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
|
|
|
plan.setId(app.getId());
|
|
|
plan.setNotResumptionOnRest(app.getNotResumptionOnRest());
|
|
|
- plan.setBuildTaskNow(app.getBuildTaskNow());
|
|
|
+ plan.setPlanOfOrgType(app.getPlanOfOrgType());
|
|
|
+// plan.setBuildTaskNow(app.getBuildTaskNow());
|
|
|
|
|
|
return plan;
|
|
|
}
|
|
|
@@ -784,7 +924,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
|
|
|
SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectOrgById(orgid, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
String fileOrgName = registerBookPdfService.getFileOrgName(orgid);
|
|
|
- String fileName = fileOrgName + "_" + RegisterBookType.SECURITY_PERFORMANCE.getText()+ "_"+ DateUtil.format(new Date(), "yyyyMMddHHmmss") + ".pdf";
|
|
|
+ String fileName = fileOrgName + "_" + RegisterBookType.SECURITY_PERFORMANCE.getText() + "_" + DateUtil.format(new Date(), "yyyyMMddHHmmss") + ".pdf";
|
|
|
Map<String, Object> data = this.getFtlResumption(orgid);
|
|
|
data.put("fileName", fileName);
|
|
|
data.put("orgName", sysOrg.getShortName());
|
|
|
@@ -806,7 +946,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
registerBookPdf.setFileUrl(pdfUrl);
|
|
|
//registerBookPdf.setFileName(StringUtils.substringAfterLast(pdfUrl, "\\"));
|
|
|
registerBookPdf.setFileName(StringUtils.substringAfterLast(pdfUrl, File.separator));
|
|
|
- if(StringUtils.isEmpty(registerBookPdf.getFileName())||StringUtils.isEmpty(pdfUrl)){
|
|
|
+ if (StringUtils.isEmpty(registerBookPdf.getFileName()) || StringUtils.isEmpty(pdfUrl)) {
|
|
|
throw new SystemException(ErrorMsgConstants.GENERATE_PDF_ERROR);
|
|
|
}
|
|
|
registerBookPdfService.save(registerBookPdf);
|
|
|
@@ -871,13 +1011,13 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
|
|
|
public List<ResumptionPdf> getResult(Map<Long, List<AppResumptionDataInfoVo>> bef) {
|
|
|
List<ResumptionPdf> befs = new ArrayList<>();
|
|
|
- // for (Long l :bef.keySet()) {
|
|
|
- for(Map.Entry<Long, List<AppResumptionDataInfoVo>> map: bef.entrySet()){
|
|
|
+ // for (Long l :bef.keySet()) {
|
|
|
+ for (Map.Entry<Long, List<AppResumptionDataInfoVo>> map : bef.entrySet()) {
|
|
|
String pointName = "";
|
|
|
StringBuilder submitName = new StringBuilder();
|
|
|
int result = 0;
|
|
|
- // for (AppResumptionDataInfoVo vo :bef.get(l)) {
|
|
|
- for (AppResumptionDataInfoVo vo :map.getValue()) {
|
|
|
+ // for (AppResumptionDataInfoVo vo :bef.get(l)) {
|
|
|
+ for (AppResumptionDataInfoVo vo : map.getValue()) {
|
|
|
pointName = vo.getPointName();
|
|
|
result += vo.getResValue();
|
|
|
submitName.append(vo.getSubmitName());
|