|
|
@@ -1,7 +1,5 @@
|
|
|
package com.xunmei.core.resumption.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.collection.CollectionUtil;
|
|
|
-import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -14,9 +12,7 @@ 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.domain.edu.domain.CoreEduTrainingTask;
|
|
|
-import com.xunmei.common.core.domain.edu.domain.CoreEduTrainingTaskToUser;
|
|
|
-import com.xunmei.common.core.domain.edu.vo.CoreEduTrainingTaskDetailVo;
|
|
|
+import com.xunmei.common.core.enums.CycleCommonEnum;
|
|
|
import com.xunmei.common.core.exception.ServiceException;
|
|
|
import com.xunmei.common.core.domain.registerbook.domain.CoreRegisterBookPdf;
|
|
|
import com.xunmei.common.core.enums.RegisterBookType;
|
|
|
@@ -32,7 +28,6 @@ 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.ResumptionTaskBusiness;
|
|
|
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,17 +39,17 @@ import com.xunmei.core.thread.ThreadPoolConfig;
|
|
|
import com.xunmei.system.api.RemoteFileService;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.domain.ResumptionPdf;
|
|
|
-import com.xunmei.system.api.domain.SysDept;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
import com.xunmei.system.api.function.RemoteCallHandlerExecutor;
|
|
|
-import io.netty.util.internal.StringUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.omg.IOP.TransactionService;
|
|
|
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;
|
|
|
@@ -62,8 +57,6 @@ import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static com.xunmei.common.core.constant.ErrorMsgConstants.QUERY_ORG_DATA_ERROR;
|
|
|
-
|
|
|
/**
|
|
|
* @author : 高雄
|
|
|
* @date :2022/4/27 17:44
|
|
|
@@ -223,6 +216,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());
|
|
|
appPlanToItemMapper.insert(item);
|
|
|
}
|
|
|
}
|
|
|
@@ -244,25 +238,32 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
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.setPlanStatus(2);
|
|
|
baseMapper.updateById(ap);
|
|
|
- //撤回需要删除本周期所有任务
|
|
|
- DateRange dateRange = DateUtils.getStartAndEnd(new Date(), plan.getPlanCycle());
|
|
|
- resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, ap.getId()).in(Resumption::getStatus, 1, 2).between(Resumption::getYmdDate, dateRange.getStartTime(), dateRange.getEndTime()));
|
|
|
|
|
|
+ if (ObjectUtil.notEqual(ap.getTaskHasCompleted(), 1)) {
|
|
|
+ deleteByPlanIds.add(ap.getId());
|
|
|
+ }
|
|
|
}
|
|
|
//设置下发状态为未下发
|
|
|
plan.setDistribute("0");
|
|
|
plan.setPlanStatus(2);
|
|
|
baseMapper.updateById(plan);
|
|
|
|
|
|
-//撤回需要删除本周期所有任务
|
|
|
- DateRange dateRange = DateUtils.getStartAndEnd(new Date(), plan.getPlanCycle());
|
|
|
- resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, plan.getId()).in(Resumption::getStatus, 1, 2).between(Resumption::getYmdDate, dateRange.getStartTime(), dateRange.getEndTime()));
|
|
|
+ if (ObjectUtil.notEqual(plan.getTaskHasCompleted(), 1)) {
|
|
|
+ deleteByPlanIds.add(plan.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ deleteTaskByPlanId(deleteByPlanIds);
|
|
|
+ }
|
|
|
|
|
|
+ @Async
|
|
|
+ protected void deleteTaskByPlanId(List<Long> planIds) {
|
|
|
+ resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().in(Resumption::getPlanId, planIds));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -320,6 +321,9 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void saveOrUpdatePlan(AppPlanVo app) throws Exception {
|
|
|
AppPlan plan = convertToAppPlan(app);
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.set(2000, 0, 1);
|
|
|
+
|
|
|
if (app.getId() == null) {
|
|
|
plan.setParentId(-1L);
|
|
|
plan.setDeleted(0);
|
|
|
@@ -376,6 +380,7 @@ 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 {
|
|
|
@@ -383,10 +388,22 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
app.setRoleList(new ArrayList<>());
|
|
|
}
|
|
|
|
|
|
+ AppPlan existPlan = baseMapper.selectById(app.getId());
|
|
|
+ LambdaQueryWrapper<AppPlanToPoint> pointWrapper = new LambdaQueryWrapper<>();
|
|
|
+ pointWrapper.eq(AppPlanToPoint::getPlanId, app.getId());
|
|
|
+
|
|
|
+
|
|
|
//修改所有子计划
|
|
|
List<AppPlan> appPlans = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, plan.getId()));
|
|
|
for (AppPlan ap :
|
|
|
appPlans) {
|
|
|
+ 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));
|
|
|
+ }
|
|
|
|
|
|
ap.setPlanType(plan.getPlanType());
|
|
|
ap.setPlanCycle(plan.getPlanCycle());
|
|
|
@@ -418,7 +435,9 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
|
|
|
|
|
|
List<RuleItemVo> valitemList = app.getItemList();
|
|
|
- List<RuleItemVo> itemList = valitemList.stream().filter(e -> e.getOfOrgId().equals(app.getPlanCreateOrgId())).collect(Collectors.toList());
|
|
|
+ List<RuleItemVo> itemList = valitemList.stream()
|
|
|
+ .filter(e -> e.getOfOrgId().equals(app.getPlanCreateOrgId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
if (valitemList.size() == 0) {
|
|
|
throw new RuntimeException("请选择履职要点");
|
|
|
@@ -431,6 +450,12 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
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);
|
|
|
+ }
|
|
|
+
|
|
|
appPlanToItemMapper.insert(item);
|
|
|
}
|
|
|
//如果计划是编辑全部,代表不存在已完成或者逾期的任务,需要删除重新生成
|
|
|
@@ -487,6 +512,7 @@ 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);
|
|
|
}
|
|
|
|
|
|
@@ -511,10 +537,10 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
plan.setPlanCreateOrgId(null);
|
|
|
plan.setPlanCreateOrgName(null);
|
|
|
baseMapper.updateById(plan);
|
|
|
- //如果计划是编辑全部,代表不存在已完成或者逾期的任务,需要删除重新生成
|
|
|
- if (app.getHasEdit() == null) {
|
|
|
- resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, plan.getId()));
|
|
|
- }
|
|
|
+// //如果计划是编辑全部,代表不存在已完成或者逾期的任务,需要删除重新生成
|
|
|
+// if (ObjectUtil.notEqual(existPlan.getTaskHasCompleted(),1)) {
|
|
|
+// resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, plan.getId()));
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -525,25 +551,25 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
|
|
|
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<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;
|
|
|
- }
|
|
|
- }
|
|
|
+// 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);
|
|
|
appPlanVo.setPlanCreateOrgType(org.getType());
|
|
|
@@ -674,6 +700,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
plan.setPlanCreateOrgId(app.getPlanCreateOrgId());
|
|
|
plan.setPlanOfOrgId(app.getPlanOfOrgId());
|
|
|
plan.setPlanOfOrgType(app.getPlanOfOrgType());
|
|
|
+ plan.setHasEdit(app.getTaskHasCompleted());
|
|
|
return plan;
|
|
|
}
|
|
|
|
|
|
@@ -707,6 +734,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
plan.setId(app.getId());
|
|
|
plan.setNotResumptionOnRest(app.getNotResumptionOnRest());
|
|
|
plan.setBuildTaskNow(app.getBuildTaskNow());
|
|
|
+
|
|
|
return plan;
|
|
|
}
|
|
|
|
|
|
@@ -740,6 +768,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
@Async
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -862,20 +891,24 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
*/
|
|
|
@Override
|
|
|
@Async
|
|
|
+ @Transactional
|
|
|
public void updatePlanCompletedState(Long planId, Integer state) {
|
|
|
if (ObjectUtil.notEqual(state, 1) && ObjectUtil.notEqual(state, 0) && ObjectUtil.isNotNull(state)) {
|
|
|
throw new ServiceException("state参数值无效");
|
|
|
}
|
|
|
|
|
|
+ AppPlan plan = baseMapper.selectById(planId);
|
|
|
+ if (ObjectUtil.isNull(plan)) {
|
|
|
+ throw new ServiceException("计划不存在");
|
|
|
+ }
|
|
|
+
|
|
|
LambdaUpdateWrapper<AppPlan> wrapper = new LambdaUpdateWrapper();
|
|
|
wrapper.eq(AppPlan::getId, planId)
|
|
|
- .eq(AppPlan::getTaskHasCompleted, state)
|
|
|
.set(AppPlan::getTaskHasCompleted, state);
|
|
|
- if (ObjectUtil.isNull(state)) {
|
|
|
- wrapper.isNull(AppPlan::getTaskHasCompleted);
|
|
|
- } else {
|
|
|
- wrapper.eq(AppPlan::getTaskHasCompleted, state);
|
|
|
- }
|
|
|
+
|
|
|
baseMapper.update(null, wrapper);
|
|
|
+ if (ObjectUtil.isNotNull(plan.getParentId()) && plan.getParentId() > 0) {
|
|
|
+ baseMapper.updateParentPlanCompletedState(plan.getParentId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|