|
|
@@ -1,10 +1,8 @@
|
|
|
package com.xunmei.core.resumption.controller;
|
|
|
|
|
|
-import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
-import com.xunmei.common.core.domain.R;
|
|
|
import com.xunmei.common.core.web.domain.AjaxResult;
|
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
import com.xunmei.common.security.annotation.RequiresPermissions;
|
|
|
@@ -23,9 +21,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.TimeZone;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author : 高雄
|
|
|
@@ -37,13 +33,10 @@ import java.util.TimeZone;
|
|
|
@RequestMapping("/api/plan")
|
|
|
@Slf4j
|
|
|
public class ApiPlanController {
|
|
|
-
|
|
|
@Autowired
|
|
|
private AppPlanService appPlanService;
|
|
|
@Autowired
|
|
|
- private RemoteOrgService remoteOrgService;
|
|
|
- @Autowired
|
|
|
- ResumptionTaskBusiness taskBusiness;
|
|
|
+ ResumptionTaskBusiness resumptionTaskBusiness;
|
|
|
|
|
|
/**
|
|
|
* 计划分页查询
|
|
|
@@ -62,6 +55,7 @@ public class ApiPlanController {
|
|
|
|
|
|
/**
|
|
|
* 下发
|
|
|
+ *
|
|
|
* @param dto
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -72,30 +66,35 @@ public class ApiPlanController {
|
|
|
appPlanService.distributeToOrg(dto);
|
|
|
AppPlan plan = appPlanService.getById(dto.getId());
|
|
|
//如果选择了计划立即生效
|
|
|
- if (plan.getBuildTaskNow()==1) {
|
|
|
- DateTime datetime = new DateTime();
|
|
|
- datetime.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
|
- Integer plancycle = plan.getPlanCycle();
|
|
|
- if (plancycle != null) {
|
|
|
- if (plancycle == 2) {
|
|
|
- taskBusiness.syncDay(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 3) {
|
|
|
- taskBusiness.syncWeek(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 4) {
|
|
|
- taskBusiness.syncMonth(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 5) {
|
|
|
- taskBusiness.syncQuarter(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 6) {
|
|
|
- taskBusiness.syncHalfYear(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 7) {
|
|
|
- taskBusiness.syncYear(datetime, plancycle);
|
|
|
- }
|
|
|
- }
|
|
|
+ if (plan.getBuildTaskNow() == 1) {
|
|
|
+ List<AppPlan> list = appPlanService.list(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, plan.getId()).eq(AppPlan::getDeleted, 0));
|
|
|
+ list.add(plan);
|
|
|
+ List<Object> newlist = new ArrayList<>(list);
|
|
|
+ resumptionTaskBusiness.rebuildCurrentCycleTask(newlist);
|
|
|
+
|
|
|
+// DateTime datetime = new DateTime();
|
|
|
+// datetime.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
|
+// Integer plancycle = plan.getPlanCycle();
|
|
|
+// if (plancycle != null) {
|
|
|
+// if (plancycle == 2) {
|
|
|
+// taskBusiness.syncDay(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 3) {
|
|
|
+// taskBusiness.syncWeek(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 4) {
|
|
|
+// taskBusiness.syncMonth(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 5) {
|
|
|
+// taskBusiness.syncQuarter(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 6) {
|
|
|
+// taskBusiness.syncHalfYear(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 7) {
|
|
|
+// taskBusiness.syncYear(datetime, plancycle);
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
return AjaxResult.success();
|
|
|
} catch (Exception e) {
|
|
|
@@ -146,42 +145,45 @@ public class ApiPlanController {
|
|
|
public AjaxResult edit(@RequestBody AppPlanVo info) {
|
|
|
try {
|
|
|
appPlanService.saveOrUpdatePlan(info);
|
|
|
+ AppPlan plan = null;
|
|
|
+ plan = appPlanService.getById(info.getId());
|
|
|
Long planOfOrgType = null;
|
|
|
- if (info.getId()==null){
|
|
|
- Long orgId = info.getPlanCreateOrgId();
|
|
|
- planOfOrgType = Long.valueOf(remoteOrgService.selectSysOrgById(orgId, SecurityConstants.INNER).getType());
|
|
|
- }else {
|
|
|
- AppPlan plan = appPlanService.getById(info.getId());
|
|
|
+ if(info.getId()!=null) {
|
|
|
planOfOrgType = plan.getPlanOfOrgType();
|
|
|
}
|
|
|
//判断是否是编辑并且计划所属任务不存在已完成或者逾期,需要删除所有任务重新生成
|
|
|
- boolean isEditAll = info.getHasEdit() == null&&info.getId()!=null;
|
|
|
+ boolean isEditAll = info.getHasEdit() == null && info.getId() != null;
|
|
|
//如果计划所属机构类型为行社并且勾选立即执行,新增的时候立即生成任务
|
|
|
- if ((info.getId()==null&&planOfOrgType==3&&info.getBuildTaskNow()==1)||isEditAll){
|
|
|
- DateTime datetime = new DateTime();
|
|
|
- datetime.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
|
- //当有周期存在时保持原有接口不变(doTask),否则按照新的接口创建
|
|
|
- Integer plancycle = info.getPlanCycle();
|
|
|
- if (plancycle != null) {
|
|
|
- if (plancycle == 2) {
|
|
|
- taskBusiness.syncDay(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 3) {
|
|
|
- taskBusiness.syncWeek(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 4) {
|
|
|
- taskBusiness.syncMonth(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 5) {
|
|
|
- taskBusiness.syncQuarter(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 6) {
|
|
|
- taskBusiness.syncHalfYear(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 7) {
|
|
|
- taskBusiness.syncYear(datetime, plancycle);
|
|
|
- }
|
|
|
- }
|
|
|
+ if ((info.getId() == null &&planOfOrgType!=null&& planOfOrgType == 3 && info.getBuildTaskNow() == 1) || isEditAll) {
|
|
|
+// DateTime datetime = new DateTime();
|
|
|
+// datetime.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
|
+// //当有周期存在时保持原有接口不变(doTask),否则按照新的接口创建
|
|
|
+// Integer plancycle = info.getPlanCycle();
|
|
|
+// if (plancycle != null) {
|
|
|
+// if (plancycle == 2) {
|
|
|
+// taskBusiness.syncDay(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 3) {
|
|
|
+// taskBusiness.syncWeek(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 4) {
|
|
|
+// taskBusiness.syncMonth(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 5) {
|
|
|
+// taskBusiness.syncQuarter(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 6) {
|
|
|
+// taskBusiness.syncHalfYear(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 7) {
|
|
|
+// taskBusiness.syncYear(datetime, plancycle);
|
|
|
+// }
|
|
|
+// }
|
|
|
+ //如果编辑
|
|
|
+ List<AppPlan> list = appPlanService.list(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, plan.getId()).eq(AppPlan::getDeleted, 0));
|
|
|
+ list.add(plan);
|
|
|
+ List<Object> newlist = new ArrayList<>(list);
|
|
|
+ resumptionTaskBusiness.rebuildCurrentCycleTask(newlist);
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -245,6 +247,7 @@ public class ApiPlanController {
|
|
|
// }
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
+
|
|
|
@ApiOperation(value = "撤回后下发")
|
|
|
@GetMapping(value = "/distributeCheHui/{id}")
|
|
|
// @RequiresPermissions("core:plan:findById")
|
|
|
@@ -252,31 +255,36 @@ public class ApiPlanController {
|
|
|
int i = appPlanService.distributeCheHui(id);
|
|
|
AppPlan plan = appPlanService.getById(id);
|
|
|
//撤回后的下发如果存在子计划并且勾选立即执行也需要生成任务
|
|
|
- if(plan.getBuildTaskNow()==1){
|
|
|
- DateTime datetime = new DateTime();
|
|
|
- datetime.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
|
- //当有周期存在时保持原有接口不变(doTask),否则按照新的接口创建
|
|
|
- Integer plancycle = plan.getPlanCycle();
|
|
|
- if (plancycle != null) {
|
|
|
- if (plancycle == 2) {
|
|
|
- taskBusiness.syncDay(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 3) {
|
|
|
- taskBusiness.syncWeek(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 4) {
|
|
|
- taskBusiness.syncMonth(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 5) {
|
|
|
- taskBusiness.syncQuarter(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 6) {
|
|
|
- taskBusiness.syncHalfYear(datetime, plancycle);
|
|
|
- }
|
|
|
- if (plancycle == 7) {
|
|
|
- taskBusiness.syncYear(datetime, plancycle);
|
|
|
- }
|
|
|
- }
|
|
|
+ if (plan.getBuildTaskNow() == 1) {
|
|
|
+// DateTime datetime = new DateTime();
|
|
|
+// datetime.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
|
+// //当有周期存在时保持原有接口不变(doTask),否则按照新的接口创建
|
|
|
+// Integer plancycle = plan.getPlanCycle();
|
|
|
+// if (plancycle != null) {
|
|
|
+// if (plancycle == 2) {
|
|
|
+// taskBusiness.syncDay(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 3) {
|
|
|
+// taskBusiness.syncWeek(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 4) {
|
|
|
+// taskBusiness.syncMonth(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 5) {
|
|
|
+// taskBusiness.syncQuarter(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 6) {
|
|
|
+// taskBusiness.syncHalfYear(datetime, plancycle);
|
|
|
+// }
|
|
|
+// if (plancycle == 7) {
|
|
|
+// taskBusiness.syncYear(datetime, plancycle);
|
|
|
+// }
|
|
|
+// }
|
|
|
+ List<AppPlan> list = appPlanService.list(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, plan.getId()).eq(AppPlan::getDeleted, 0));
|
|
|
+ list.add(plan);
|
|
|
+ List<Object> newlist = new ArrayList<>(list);
|
|
|
+ resumptionTaskBusiness.rebuildCurrentCycleTask(newlist);
|
|
|
+
|
|
|
}
|
|
|
return AjaxResult.success(i);
|
|
|
}
|