|
|
@@ -12,10 +12,10 @@ 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;
|
|
|
@@ -32,7 +32,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.task.ResumptionTaskBusinessService;
|
|
|
import com.xunmei.core.resumption.vo.appPlan.AppPlanVo;
|
|
|
import com.xunmei.core.resumption.vo.appPlan.ResumptionPlanPageVo;
|
|
|
@@ -48,7 +47,6 @@ 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;
|
|
|
@@ -56,7 +54,6 @@ 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;
|
|
|
@@ -199,8 +196,9 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
tempplan.setDistributeStatus("1");
|
|
|
if (immediateEffect) {
|
|
|
//停用状态下发,逻辑删除旧的计划,并生成一份副本
|
|
|
- tempplan.setDeleted(1);
|
|
|
baseMapper.updateById(tempplan);
|
|
|
+ baseMapper.deleteById(tempplan);
|
|
|
+
|
|
|
Long hsPlanId = IDHelper.id();
|
|
|
baseMapper.copyChildren(tempplan.getId(), hsPlanId, parentId);
|
|
|
baseMapper.copyPlanOrgs(tempplan.getId(), hsPlanId);
|
|
|
@@ -218,7 +216,8 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
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());
|
|
|
@@ -230,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();
|
|
|
|
|
|
@@ -268,13 +268,18 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
|
|
|
if (immediateEffect && ObjectUtil.equal(oldPlan.getPlanStatus(), PlanStatus.DELETED.getCode())) {
|
|
|
//停用时下发且立即生效,逻辑删除旧计划并生成新计划
|
|
|
- plan.setDeleted(1);
|
|
|
+ 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);
|
|
|
}
|
|
|
- baseMapper.updateById(plan);
|
|
|
+
|
|
|
if (immediateEffect) {
|
|
|
resumptionTaskBusiness.rebuildCurrentCycleTask(hsPlans);
|
|
|
}
|
|
|
@@ -300,9 +305,11 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
if (ObjectUtil.equal(planStatus, PlanStatus.DRAFT.getCode())) {
|
|
|
//草稿状态下发,立即生效则生成任务
|
|
|
newlist.add(plan);
|
|
|
+ baseMapper.updateById(plan);
|
|
|
} else if (ObjectUtil.equal(planStatus, PlanStatus.DELETED.getCode())) {
|
|
|
//停用状态下发,逻辑删除旧计划,并生成计划的副本,并更新任务名称和关联的计划id
|
|
|
- plan.setDeleted(1);
|
|
|
+ baseMapper.updateById(plan);
|
|
|
+ baseMapper.deleteById(plan.getId());
|
|
|
Long newPlanId = IDHelper.id();
|
|
|
copyHsPlan(id, newPlanId);
|
|
|
|
|
|
@@ -311,9 +318,11 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
}
|
|
|
|
|
|
resumptionTaskBusiness.rebuildCurrentCycleTask(newlist);
|
|
|
+ } else {
|
|
|
+ baseMapper.updateById(plan);
|
|
|
}
|
|
|
|
|
|
- baseMapper.updateById(plan);
|
|
|
+
|
|
|
return plan;
|
|
|
}
|
|
|
|
|
|
@@ -348,12 +357,13 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
baseMapper.update(null, updateWrapper);
|
|
|
|
|
|
List<Long> childrenPlanIds = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>()
|
|
|
- .eq(AppPlan::getParentId, id).select(AppPlan::getId))
|
|
|
- .stream().map(AppPlan::getId).collect(Collectors.toList());
|
|
|
+ .eq(AppPlan::getParentId, id)
|
|
|
+ .select(AppPlan::getSolidId))
|
|
|
+ .stream().map(AppPlan::getSolidId).collect(Collectors.toList());
|
|
|
delete(childrenPlanIds);
|
|
|
|
|
|
- childrenPlanIds.add(plan.getId());
|
|
|
- deleteTaskByPlanId(childrenPlanIds);
|
|
|
+ childrenPlanIds.add(plan.getSolidId());
|
|
|
+ deleteAllTaskByPlanId(childrenPlanIds);
|
|
|
}
|
|
|
//
|
|
|
// //修改所有子计划
|
|
|
@@ -384,11 +394,27 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
}
|
|
|
|
|
|
@Async
|
|
|
- protected void deleteTaskByPlanId(List<Long> planIds) {
|
|
|
- if (CollectionUtils.isEmpty(planIds)) {
|
|
|
+ protected void deleteTaskByPlanId(List<Long> solidPlanIds) {
|
|
|
+ if (CollectionUtils.isEmpty(solidPlanIds)) {
|
|
|
return;
|
|
|
}
|
|
|
- resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().in(Resumption::getPlanId, planIds));
|
|
|
+ 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));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -503,7 +529,8 @@ 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 = 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()));
|
|
|
@@ -519,8 +546,8 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
baseMapper.copyPlanRoles(ap.getId(), newChildPlanId);
|
|
|
baseMapper.copyPlanPoints(ap.getId(), newChildPlanId);
|
|
|
|
|
|
- ap.setDeleted(1);
|
|
|
baseMapper.updateById(ap);
|
|
|
+ baseMapper.deleteById(ap.getId());
|
|
|
child = baseMapper.selectById(newChildPlanId);
|
|
|
needRebuildPlans.add(child);
|
|
|
}
|
|
|
@@ -600,10 +627,11 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
baseMapper.copyPlanRoles(existPlan.getId(), newPlanID);
|
|
|
baseMapper.copyPlanPoints(existPlan.getId(), newPlanID);
|
|
|
|
|
|
- plan.setDeleted(1);
|
|
|
- baseMapper.updateById(plan);
|
|
|
+ baseMapper.deleteById(app.getId());
|
|
|
|
|
|
plan.setId(newPlanID);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//处理本计划关联
|
|
|
@@ -674,6 +702,9 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
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)) {
|
|
|
@@ -756,24 +787,28 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void deleted(Long id) throws Exception {
|
|
|
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)) {
|
|
|
- //有已完成时,计划逻辑删除
|
|
|
- LambdaUpdateWrapper<AppPlan> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.set(AppPlan::getDeleted, 1);
|
|
|
- updateWrapper.eq(AppPlan::getId, id).or().eq(AppPlan::getParentId, id);
|
|
|
+ //有已完成时,计划逻辑删除,删除当前轮次及之后未完成的任务
|
|
|
+ LambdaQueryWrapper<AppPlan> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(AppPlan::getId, plans.stream().map(AppPlan::getId).collect(Collectors.toList()));
|
|
|
|
|
|
- baseMapper.update(null, updateWrapper);
|
|
|
+ baseMapper.delete(wrapper);
|
|
|
+ deleteTaskByPlanId(plans.stream().map(AppPlan::getSolidId).collect(Collectors.toList()));
|
|
|
} else {
|
|
|
- //无已完成时,计划物理删除
|
|
|
- List<Long> planIds = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>()
|
|
|
- .eq(AppPlan::getId, id).or().eq(AppPlan::getParentId, id).select(AppPlan::getId))
|
|
|
- .stream().map(AppPlan::getId).collect(Collectors.toList());
|
|
|
- delete(planIds);
|
|
|
+ //无已完成时,计划物理删除,删除所有任务
|
|
|
+
|
|
|
+
|
|
|
+ delete(plans.stream().map(AppPlan::getId).collect(Collectors.toList()));
|
|
|
+ deleteAllTaskByPlanId(plans.stream().map(AppPlan::getSolidId).collect(Collectors.toList()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void delete(List<Long> planIds) {
|
|
|
- if(ObjectUtil.isEmpty(planIds)){
|
|
|
+ if (ObjectUtil.isEmpty(planIds)) {
|
|
|
return;
|
|
|
}
|
|
|
//删除对应的角色关系
|
|
|
@@ -791,9 +826,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
apo.lambda().in(AppPlanToExecOrg::getPlanId, planIds);
|
|
|
appPlanToExecOrgMapper.delete(apo);
|
|
|
|
|
|
- LambdaQueryWrapper<AppPlan> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.in(AppPlan::getId, planIds);
|
|
|
- baseMapper.delete(queryWrapper);
|
|
|
+ baseMapper.physicsDeleteById(planIds);
|
|
|
}
|
|
|
|
|
|
private AppPlanVo convertToAppPlanVo(AppPlan app) {
|
|
|
@@ -847,6 +880,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
|
|
|
plan.setId(app.getId());
|
|
|
plan.setNotResumptionOnRest(app.getNotResumptionOnRest());
|
|
|
+ plan.setPlanOfOrgType(app.getPlanOfOrgType());
|
|
|
// plan.setBuildTaskNow(app.getBuildTaskNow());
|
|
|
|
|
|
return plan;
|