luojun 2 lat temu
rodzic
commit
4b8cd12883

+ 9 - 3
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/controller/ApiPlanController.java

@@ -167,10 +167,16 @@ public class ApiPlanController {
 
     @ApiOperation(value = "撤回")
     @GetMapping(value = "/cheHui/{id}")
-    @RequiresPermissions("core:plan:findById")
+//    @RequiresPermissions("core:plan:findById")
     public AjaxResult cheHui(@PathVariable Long id) {
-
-        return AjaxResult.success(appPlanService.cheHui(id));
+        appPlanService.cheHui(id);
+        return AjaxResult.success();
+    }
+    @ApiOperation(value = "撤回")
+    @GetMapping(value = "/distributeCheHui/{id}")
+//    @RequiresPermissions("core:plan:findById")
+    public AjaxResult distributeCheHui(@PathVariable Long id) {
+        return AjaxResult.success(appPlanService.distributeCheHui(id));
     }
 
     @ApiOperation(value = "获取详情")

+ 3 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/AppPlanService.java

@@ -83,5 +83,7 @@ public interface AppPlanService extends IService<AppPlan> {
 
     void distributeToOrg(DistributeDto dto);
 
-    int cheHui(Long id);
+    void cheHui(Long id);
+
+    int distributeCheHui(Long id);
 }

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

@@ -184,41 +184,46 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
     }
 
     @Override
-    public int cheHui(Long id) {
+    public void cheHui(Long id) {
         AppPlan plan = baseMapper.selectById(id);
-
         //修改所有子计划
         List<AppPlan> appPlans = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, id));
         for (AppPlan ap :
                 appPlans) {
 //修改计划状态为停用
-            //如果是已经撤回的计划
-            if("2".equals(plan.getDistribute())){
-                //修改计划状态到进行中,下发状态到1
-                plan.setDistribute("1");
-                plan.setPlanStatus(1);
-            }else {
-                ap.setPlanStatus(2);
-            }
+            ap.setPlanStatus(2);
             baseMapper.updateById(ap);
         }
-        //如果是已经撤回的计划
-        if("2".equals(plan.getDistribute())){
-            //修改计划状态到进行中,下发状态到1
-            plan.setDistribute("3");
-            plan.setPlanStatus(1);
-            baseMapper.updateById(plan);
-            return 2;
-        }else{
-            plan.setDistribute("2");
-            plan.setPlanStatus(0);
-            baseMapper.updateById(plan);
-            return 1;
-        }
+        //设置下发状态为未下发
+        plan.setDistribute("0");
+        plan.setPlanStatus(0);
+        baseMapper.updateById(plan);
 
 
     }
 
+    @Override
+    public int distributeCheHui(Long id) {
+        AppPlan plan = baseMapper.selectById(id);
+        //修改所有子计划
+        List<AppPlan> appPlans = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, id));
+        //如果不存在子计划直接返回
+        if(appPlans==null||appPlans.size()==0){
+            return 0;
+        }
+        for (AppPlan ap :
+                appPlans) {
+//修改计划状态为停用
+            ap.setPlanStatus(1);
+            baseMapper.updateById(ap);
+        }
+        //设置下发状态为下发
+        plan.setDistribute("1");
+        plan.setPlanStatus(1);
+        baseMapper.updateById(plan);
+        return 1;
+    }
+
     /**
      * 获取检查要点分页
      *
@@ -267,7 +272,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             plan.setPlanOfOrgName(app.getPlanCreateOrgName());
             //验证名称是否重复
             QueryWrapper<AppPlan> qw = new QueryWrapper<>();
-            qw.lambda().eq(AppPlan::getPlanName, app.getPlanName()).eq(AppPlan::getDeleted,0);
+            qw.lambda().eq(AppPlan::getPlanName, app.getPlanName()).eq(AppPlan::getDeleted, 0);
 
             Long size = baseMapper.selectCount(qw);
 
@@ -275,7 +280,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                 throw new RuntimeException("计划名称重复,请确认!");
             }
 
-
+            plan.setDistribute("0");
             baseMapper.insert(plan);
             Long id = plan.getId();
 
@@ -305,7 +310,6 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             }
 
 
-
 //            Integer orgId = app.getExecOrgType();
 //            if (orgId != null) {
 //                AppPlanToCheckOrg checkOrg = new AppPlanToCheckOrg();
@@ -331,10 +335,10 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             }
 
             //获取计划对应的已完成任务数量
-            Long num = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", app.getId()).eq("status",3));
+            Long num = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", app.getId()).eq("status", 3));
             if (num > 0) {
                 //如果状态为已禁用
-                if(app.getPlanStatus()==0){
+                if (app.getPlanStatus() == 0) {
                     throw new RuntimeException("计划已生成任务,不能禁用!");
                 }
 
@@ -344,7 +348,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             List<AppPlan> appPlans = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, plan.getId()));
             for (AppPlan ap :
                     appPlans) {
-                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 (app.getPlanStatus() == 0) {
                         throw new RuntimeException("计划已生成任务,不能禁用!");
@@ -450,7 +454,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                 appPlanToExecOrgMapper.insert(execOrg);
             }
             //更新任务的名称
-            resumptionMapper.updateNameByPlanId(app.getPlanName(),app.getId());
+            resumptionMapper.updateNameByPlanId(app.getPlanName(), app.getId());
 
             //最后处理本计划
             plan.setUpdateTime(new Date());
@@ -519,17 +523,17 @@ 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).eq("status", 3));
         if (num > 0) {
             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));
 
         //删除子计划
         for (AppPlan ap :
                 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) {
                 throw new RuntimeException("子计划已生成任务,不能删除!");
             }