|
@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
|
|
+import com.xunmei.common.core.domain.DateRange;
|
|
|
|
|
+import com.xunmei.common.core.utils.DateUtils;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
import com.xunmei.core.resumption.domain.*;
|
|
import com.xunmei.core.resumption.domain.*;
|
|
|
import com.xunmei.core.resumption.dto.DistributeDto;
|
|
import com.xunmei.core.resumption.dto.DistributeDto;
|
|
@@ -138,47 +140,53 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void distributeToOrg(DistributeDto dto) {
|
|
public void distributeToOrg(DistributeDto dto) {
|
|
|
- for (DistributeStatusDto d :
|
|
|
|
|
- dto.getOrgAndStatus()) {
|
|
|
|
|
-
|
|
|
|
|
- AppPlan plan = baseMapper.selectById(dto.getId());
|
|
|
|
|
- plan.setOrgId(d.getOrgId().toString());
|
|
|
|
|
- plan.setDistributeStatus("1");
|
|
|
|
|
- plan.setPlanOfOrgId(d.getOrgId());
|
|
|
|
|
- plan.setPlanStatus(d.getStatus());
|
|
|
|
|
- plan.setDistributePlanStatus(d.getStatus().toString());
|
|
|
|
|
- plan.setCreateTime(new Date());
|
|
|
|
|
- plan.setId(null);
|
|
|
|
|
|
|
+ //如果计划所属机构类型为省联社,生成下发子计划
|
|
|
|
|
+ if (baseMapper.selectById(dto.getId()).getPlanOfOrgType() == 1) {
|
|
|
|
|
+ for (DistributeStatusDto d :
|
|
|
|
|
+ dto.getOrgAndStatus()) {
|
|
|
|
|
+
|
|
|
|
|
+ AppPlan plan = baseMapper.selectById(dto.getId());
|
|
|
|
|
+ plan.setOrgId(d.getOrgId().toString());
|
|
|
|
|
+ plan.setDistributeStatus("1");
|
|
|
|
|
+ plan.setPlanOfOrgId(d.getOrgId());
|
|
|
|
|
+ plan.setPlanOfOrgType(Long.valueOf(orgService.selectSysOrgById(d.getOrgId(), SecurityConstants.INNER).getType()));
|
|
|
|
|
+ plan.setPlanStatus(d.getStatus());
|
|
|
|
|
+ plan.setDistributePlanStatus(d.getStatus().toString());
|
|
|
|
|
+ plan.setCreateTime(new Date());
|
|
|
|
|
+ plan.setId(null);
|
|
|
// plan.setPlanName(plan.getPlanName()+"下发"+orgService.selectOrgById(d.getOrgId(),SecurityConstants.INNER).getName());
|
|
// 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();
|
|
|
|
|
|
|
+ plan.setPlanName(plan.getPlanName());
|
|
|
|
|
+ plan.setParentId(dto.getId());
|
|
|
|
|
+ baseMapper.insert(plan);
|
|
|
|
|
+ Long id = plan.getId();
|
|
|
|
|
|
|
|
- List<Long> roleList = appPlanToRoleMapper.selectList(new LambdaQueryWrapper<AppPlanToRole>().eq(AppPlanToRole::getPlanId, dto.getId())).stream().map(AppPlanToRole::getRoleId).collect(Collectors.toList());
|
|
|
|
|
- AppPlanToRole atr = null;
|
|
|
|
|
- for (Long roleId : roleList) {
|
|
|
|
|
- atr = new AppPlanToRole();
|
|
|
|
|
- atr.setRoleId(roleId);
|
|
|
|
|
- atr.setPlanId(id);
|
|
|
|
|
- appPlanToRoleMapper.insert(atr);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ List<Long> roleList = appPlanToRoleMapper.selectList(new LambdaQueryWrapper<AppPlanToRole>().eq(AppPlanToRole::getPlanId, dto.getId())).stream().map(AppPlanToRole::getRoleId).collect(Collectors.toList());
|
|
|
|
|
+ AppPlanToRole atr = null;
|
|
|
|
|
+ for (Long roleId : roleList) {
|
|
|
|
|
+ atr = new AppPlanToRole();
|
|
|
|
|
+ atr.setRoleId(roleId);
|
|
|
|
|
+ atr.setPlanId(id);
|
|
|
|
|
+ appPlanToRoleMapper.insert(atr);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- List<AppPlanToPoint> itemList = appPlanToItemMapper.selectList(new LambdaQueryWrapper<AppPlanToPoint>().eq(AppPlanToPoint::getPlanId, dto.getId()));
|
|
|
|
|
- AppPlanToPoint item = null;
|
|
|
|
|
- for (AppPlanToPoint ruleItemVo : itemList) {
|
|
|
|
|
- item = new AppPlanToPoint();
|
|
|
|
|
- item.setPointId(ruleItemVo.getPointId());
|
|
|
|
|
- item.setPlanId(id);
|
|
|
|
|
- item.setPointScan(ruleItemVo.isPointScan());
|
|
|
|
|
- item.setRequired(ruleItemVo.isRequired());
|
|
|
|
|
- appPlanToItemMapper.insert(item);
|
|
|
|
|
|
|
+ List<AppPlanToPoint> itemList = appPlanToItemMapper.selectList(new LambdaQueryWrapper<AppPlanToPoint>().eq(AppPlanToPoint::getPlanId, dto.getId()));
|
|
|
|
|
+ AppPlanToPoint item = null;
|
|
|
|
|
+ for (AppPlanToPoint ruleItemVo : itemList) {
|
|
|
|
|
+ item = new AppPlanToPoint();
|
|
|
|
|
+ item.setPointId(ruleItemVo.getPointId());
|
|
|
|
|
+ item.setPlanId(id);
|
|
|
|
|
+ item.setPointScan(ruleItemVo.isPointScan());
|
|
|
|
|
+ item.setRequired(ruleItemVo.isRequired());
|
|
|
|
|
+ appPlanToItemMapper.insert(item);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- //修改下发标识
|
|
|
|
|
|
|
+ //更新下发标识
|
|
|
AppPlan plan = new AppPlan();
|
|
AppPlan plan = new AppPlan();
|
|
|
plan.setId(dto.getId());
|
|
plan.setId(dto.getId());
|
|
|
|
|
+ //设置下发状态1
|
|
|
plan.setDistribute("1");
|
|
plan.setDistribute("1");
|
|
|
|
|
+ //设置计划状态为使用中
|
|
|
plan.setPlanStatus(1);
|
|
plan.setPlanStatus(1);
|
|
|
plan.setBuildTaskNow(null);
|
|
plan.setBuildTaskNow(null);
|
|
|
baseMapper.updateById(plan);
|
|
baseMapper.updateById(plan);
|
|
@@ -194,12 +202,19 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
//修改计划状态为停用
|
|
//修改计划状态为停用
|
|
|
ap.setPlanStatus(2);
|
|
ap.setPlanStatus(2);
|
|
|
baseMapper.updateById(ap);
|
|
baseMapper.updateById(ap);
|
|
|
|
|
+ //撤回需要删除本周期所有任务
|
|
|
|
|
+ DateRange dateRange = DateUtils.getStartAndEnd(new Date(), plan.getPlanCycle());
|
|
|
|
|
+ resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, plan.getId()).between(Resumption::getYmdDate, dateRange.getStartTime(), dateRange.getEndTime()));
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
//设置下发状态为未下发
|
|
//设置下发状态为未下发
|
|
|
plan.setDistribute("0");
|
|
plan.setDistribute("0");
|
|
|
- plan.setPlanStatus(0);
|
|
|
|
|
|
|
+ plan.setPlanStatus(2);
|
|
|
baseMapper.updateById(plan);
|
|
baseMapper.updateById(plan);
|
|
|
|
|
|
|
|
|
|
+//撤回需要删除本周期所有任务
|
|
|
|
|
+ DateRange dateRange = DateUtils.getStartAndEnd(new Date(), plan.getPlanCycle());
|
|
|
|
|
+ resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, plan.getId()).between(Resumption::getYmdDate, dateRange.getStartTime(), dateRange.getEndTime()));
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -281,14 +296,17 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
if (size > 0) {
|
|
if (size > 0) {
|
|
|
throw new RuntimeException("计划名称重复,请确认!");
|
|
throw new RuntimeException("计划名称重复,请确认!");
|
|
|
}
|
|
}
|
|
|
- //如果计划为行社并且勾选立即生效
|
|
|
|
|
- if (app.getExecOrgType() == 3 && app.getBuildTaskNow()==1) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ plan.setBuildTaskNow(app.getBuildTaskNow());
|
|
|
|
|
+ plan.setDistribute("0");
|
|
|
|
|
+ //设置计划所属机构类型
|
|
|
|
|
+ plan.setPlanOfOrgType(Long.valueOf(orgService.selectSysOrgById(app.getPlanCreateOrgId(), SecurityConstants.INNER).getType()));
|
|
|
|
|
+ //如果计划所属机构类型为行社并且勾选立即生效
|
|
|
|
|
+ if (plan.getPlanOfOrgType() == 3 && plan.getBuildTaskNow() == 1) {
|
|
|
plan.setPlanStatus(1);
|
|
plan.setPlanStatus(1);
|
|
|
} else {
|
|
} else {
|
|
|
plan.setPlanStatus(0);
|
|
plan.setPlanStatus(0);
|
|
|
}
|
|
}
|
|
|
- plan.setBuildTaskNow(app.getBuildTaskNow());
|
|
|
|
|
- plan.setDistribute("0");
|
|
|
|
|
baseMapper.insert(plan);
|
|
baseMapper.insert(plan);
|
|
|
Long id = plan.getId();
|
|
Long id = plan.getId();
|
|
|
|
|
|
|
@@ -342,33 +360,34 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
app.setRoleList(new ArrayList<>());
|
|
app.setRoleList(new ArrayList<>());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //获取计划对应的已完成任务数量
|
|
|
|
|
- Long num = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", app.getId()).eq("status", 3));
|
|
|
|
|
- if (num > 0) {
|
|
|
|
|
- //如果状态为已禁用
|
|
|
|
|
- if (app.getPlanStatus() == 0) {
|
|
|
|
|
- throw new RuntimeException("计划已生成任务,不能禁用!");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// //获取计划对应的已完成任务数量
|
|
|
|
|
+// Long num = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", app.getId()).eq("status", 3));
|
|
|
|
|
+// if (num > 0) {
|
|
|
|
|
+// //如果状态为已禁用
|
|
|
|
|
+// if (app.getPlanStatus() == 0) {
|
|
|
|
|
+// throw new RuntimeException("计划已生成任务,不能禁用!");
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
//修改所有子计划
|
|
//修改所有子计划
|
|
|
List<AppPlan> appPlans = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, plan.getId()));
|
|
List<AppPlan> appPlans = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, plan.getId()));
|
|
|
for (AppPlan ap :
|
|
for (AppPlan ap :
|
|
|
appPlans) {
|
|
appPlans) {
|
|
|
- Long nums = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", ap.getId()).eq("status", 3));
|
|
|
|
|
- if (nums > 0) {
|
|
|
|
|
- if (app.getPlanStatus() == 0) {
|
|
|
|
|
- throw new RuntimeException("计划已生成任务,不能禁用!");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- ap.setPlanName(plan.getPlanName());
|
|
|
|
|
|
|
+// Long nums = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", ap.getId()).eq("status", 3));
|
|
|
|
|
+// if (nums > 0) {
|
|
|
|
|
+// if (app.getPlanStatus() == 0) {
|
|
|
|
|
+// throw new RuntimeException("计划已生成任务,不能禁用!");
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
ap.setPlanType(plan.getPlanType());
|
|
ap.setPlanType(plan.getPlanType());
|
|
|
ap.setPlanCycle(plan.getPlanCycle());
|
|
ap.setPlanCycle(plan.getPlanCycle());
|
|
|
// ap.setPlanStatus(plan.getPlanStatus());
|
|
// ap.setPlanStatus(plan.getPlanStatus());
|
|
|
ap.setExecOrgType(plan.getExecOrgType());
|
|
ap.setExecOrgType(plan.getExecOrgType());
|
|
|
ap.setPlanExec(plan.getPlanExec());
|
|
ap.setPlanExec(plan.getPlanExec());
|
|
|
ap.setModifiedBy(SecurityUtils.getUserId());
|
|
ap.setModifiedBy(SecurityUtils.getUserId());
|
|
|
|
|
+ ap.setPlanName(plan.getPlanName());
|
|
|
|
|
+
|
|
|
baseMapper.updateById(ap);
|
|
baseMapper.updateById(ap);
|
|
|
|
|
|
|
|
if (app.getRoleList().size() > 0) {
|
|
if (app.getRoleList().size() > 0) {
|
|
@@ -404,7 +423,13 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
item.setRequired(ruleItemVo.isRequired());
|
|
item.setRequired(ruleItemVo.isRequired());
|
|
|
appPlanToItemMapper.insert(item);
|
|
appPlanToItemMapper.insert(item);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ //如果计划是编辑全部,代表不存在已完成或者逾期的任务,需要删除重新生成
|
|
|
|
|
+ if (app.getHasEdit() == null) {
|
|
|
|
|
+ resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, ap.getId()));
|
|
|
|
|
+ }else {
|
|
|
|
|
+ //否则代表编辑名称,需要同步未进行的任务名称
|
|
|
|
|
+ resumptionMapper.updateNameByPlanId(app.getPlanName(),ap.getId());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -473,6 +498,10 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
plan.setPlanCreateOrgId(null);
|
|
plan.setPlanCreateOrgId(null);
|
|
|
plan.setPlanCreateOrgName(null);
|
|
plan.setPlanCreateOrgName(null);
|
|
|
baseMapper.updateById(plan);
|
|
baseMapper.updateById(plan);
|
|
|
|
|
+ //如果计划是编辑全部,代表不存在已完成或者逾期的任务,需要删除重新生成
|
|
|
|
|
+ if (app.getHasEdit() == null) {
|
|
|
|
|
+ resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, plan.getId()));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -482,6 +511,27 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
AppPlan appPlan = baseMapper.selectById(id);
|
|
AppPlan appPlan = baseMapper.selectById(id);
|
|
|
|
|
|
|
|
AppPlanVo appPlanVo = convertToAppPlanVo(appPlan);
|
|
AppPlanVo appPlanVo = convertToAppPlanVo(appPlan);
|
|
|
|
|
+ //查询计划是否存在对应的状态为完成或者逾期的任务
|
|
|
|
|
+ List<Integer> status = new ArrayList<>();
|
|
|
|
|
+ status.add(3);
|
|
|
|
|
+ status.add(4);
|
|
|
|
|
+ Long sum = resumptionMapper.selectCount(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, id).in(Resumption::getStatus, status));
|
|
|
|
|
+ if (sum > 0) {
|
|
|
|
|
+ //如果存在完成或者逾期的任务设置编辑状态为1
|
|
|
|
|
+ appPlanVo.setHasEdit(1);
|
|
|
|
|
+ }
|
|
|
|
|
+ //查找子计划是否存在完成或者逾期的任务
|
|
|
|
|
+ List<AppPlan> appPlans = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, id));
|
|
|
|
|
+ for (AppPlan p :
|
|
|
|
|
+ appPlans) {
|
|
|
|
|
+ Long csum = resumptionMapper.selectCount(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, p.getId()).in(Resumption::getStatus, status));
|
|
|
|
|
+ if (csum > 0) {
|
|
|
|
|
+ //如果存在完成或者逾期的任务设置编辑状态为1
|
|
|
|
|
+ appPlanVo.setHasEdit(1);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
SysOrg org = orgService.selectSysOrgById(appPlan.getPlanCreateOrgId(), SecurityConstants.INNER);
|
|
SysOrg org = orgService.selectSysOrgById(appPlan.getPlanCreateOrgId(), SecurityConstants.INNER);
|
|
|
appPlanVo.setPlanCreateOrgType(org.getType());
|
|
appPlanVo.setPlanCreateOrgType(org.getType());
|
|
|
QueryWrapper<AppPlanToRole> apr = new QueryWrapper<>();
|
|
QueryWrapper<AppPlanToRole> apr = new QueryWrapper<>();
|
|
@@ -531,9 +581,9 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
/**
|
|
/**
|
|
|
* 验证计划是否被应用
|
|
* 验证计划是否被应用
|
|
|
*/
|
|
*/
|
|
|
- Long num = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", id).eq("status", 3));
|
|
|
|
|
|
|
+ Long num = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", id).in("status", 3,4));
|
|
|
if (num > 0) {
|
|
if (num > 0) {
|
|
|
- throw new RuntimeException("计划已生成任务,不能删除!");
|
|
|
|
|
|
|
+ throw new RuntimeException("计划有已完成或者已逾期的任务,不能被删除。");
|
|
|
}
|
|
}
|
|
|
//查找子计划
|
|
//查找子计划
|
|
|
List<AppPlan> childrens = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, id));
|
|
List<AppPlan> childrens = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, id));
|
|
@@ -543,7 +593,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
childrens) {
|
|
childrens) {
|
|
|
Long nums = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", ap.getId()).eq("status", 3));
|
|
Long nums = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", ap.getId()).eq("status", 3));
|
|
|
if (nums > 0) {
|
|
if (nums > 0) {
|
|
|
- throw new RuntimeException("子计划已生成任务,不能删除!");
|
|
|
|
|
|
|
+ throw new RuntimeException("子计划有已完成或者已逾期的任务,不能被删除。");
|
|
|
}
|
|
}
|
|
|
//删除计划对应的任务
|
|
//删除计划对应的任务
|
|
|
resumptionMapper.delete(new QueryWrapper<Resumption>().eq("plan_id", ap.getId()));
|
|
resumptionMapper.delete(new QueryWrapper<Resumption>().eq("plan_id", ap.getId()));
|