Bladeren bron

调整计划

luojun 2 jaren geleden
bovenliggende
commit
d299bd15cd

+ 30 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/controller/ApiPlanController.java

@@ -221,7 +221,36 @@ public class ApiPlanController {
     @GetMapping(value = "/distributeCheHui/{id}")
 //    @RequiresPermissions("core:plan:findById")
     public AjaxResult distributeCheHui(@PathVariable Long id) {
-        return AjaxResult.success(appPlanService.distributeCheHui(id));
+        int i = appPlanService.distributeCheHui(id);
+        AppPlan plan = appPlanService.getById(id);
+        //撤回后的下发如果存在子计划并且勾选立即执行也需要生成任务
+        if(i>0&&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);
+                }
+            }
+        }
+        return AjaxResult.success(i);
     }
 
     @ApiOperation(value = "获取详情")

+ 9 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/impl/AppPlanServiceImpl.java

@@ -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.service.impl.ServiceImpl;
 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.core.resumption.domain.*;
 import com.xunmei.core.resumption.dto.DistributeDto;
@@ -200,12 +202,19 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 //修改计划状态为停用
             ap.setPlanStatus(2);
             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.setPlanStatus(2);
         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()));
 
     }