luojun пре 2 година
родитељ
комит
1776532785

+ 6 - 0
project_data/sql/0.0.2/soc/soc.sql

@@ -1068,6 +1068,12 @@ END IF;
 
     END IF;
 
+    -- 履职计划所属机构类型
+    IF
+        NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'core_resumption_plan' AND COLUMN_NAME = 'plan_of_org_type' ) THEN
+        ALTER TABLE `core_resumption_plan` ADD COLUMN `plan_of_org_type` INT NULL DEFAULT NULL COMMENT '所属机构类型';
+
+    END IF;
 	-- 履职任务NFC表增加submitby
     IF
         NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'core_resumption_data_nfc' AND COLUMN_NAME = 'submit_by' ) THEN

+ 39 - 27
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/controller/ApiPlanController.java

@@ -70,12 +70,11 @@ public class ApiPlanController {
     public AjaxResult distribute(@RequestBody DistributeDto dto) {
         try {
             appPlanService.distributeToOrg(dto);
-            AppPlanVo plan = appPlanService.findById(dto.getId());
+            AppPlan plan = appPlanService.getById(dto.getId());
             //如果选择了计划立即生效
             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) {
@@ -147,33 +146,46 @@ public class ApiPlanController {
     public AjaxResult edit(@RequestBody AppPlanVo info) {
         try {
             appPlanService.saveOrUpdatePlan(info);
-            //立即执行
-            if (info.getExecOrgType()==3&&info.getBuildTaskNow()==1) {
-                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);
+            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());
+                planOfOrgType = plan.getPlanOfOrgType();
+            }
+            //判断是否是编辑并且计划所属任务不存在已完成或者逾期,需要删除所有任务重新生成
+            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);
+                        }
                     }
-                }
+
             }
+
+
             return AjaxResult.success();
         } catch (Exception e) {
             e.printStackTrace();

+ 4 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/domain/AppPlan.java

@@ -102,6 +102,10 @@ public class AppPlan extends Model<AppPlan> implements Serializable {
      */
     private Long planOfOrgId;
     /**
+     * 计划所属机构类型
+     */
+    private Long planOfOrgType;
+    /**
      * 计划执行次数
      */
     private String count;

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

@@ -138,47 +138,53 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 
     @Override
     public void distributeToOrg(DistributeDto dto) {
-        for (DistributeStatusDto d :
-                dto.getOrgAndStatus()) {
-
-            AppPlan plan = baseMapper.selectById(dto.getId());
-            plan.setOrgId(d.getOrgId().toString());
-            plan.setDistributeStatus("1");
-            plan.setPlanOfOrgId(d.getOrgId());
-            plan.setPlanStatus(d.getStatus());
-            plan.setDistributePlanStatus(d.getStatus().toString());
-            plan.setCreateTime(new Date());
-            plan.setId(null);
+        //如果计划所属机构类型为省联社,生成下发子计划
+        if (baseMapper.selectById(dto.getId()).getPlanOfOrgType() == 1) {
+            for (DistributeStatusDto d :
+                    dto.getOrgAndStatus()) {
+
+                AppPlan plan = baseMapper.selectById(dto.getId());
+                plan.setOrgId(d.getOrgId().toString());
+                plan.setDistributeStatus("1");
+                plan.setPlanOfOrgId(d.getOrgId());
+                plan.setPlanOfOrgType(Long.valueOf(orgService.selectSysOrgById(d.getOrgId(), SecurityConstants.INNER).getType()));
+                plan.setPlanStatus(d.getStatus());
+                plan.setDistributePlanStatus(d.getStatus().toString());
+                plan.setCreateTime(new Date());
+                plan.setId(null);
 //            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();
+                plan.setPlanName(plan.getPlanName());
+                plan.setParentId(dto.getId());
+                baseMapper.insert(plan);
+                Long id = plan.getId();
 
-            List<Long> roleList = appPlanToRoleMapper.selectList(new LambdaQueryWrapper<AppPlanToRole>().eq(AppPlanToRole::getPlanId, dto.getId())).stream().map(AppPlanToRole::getRoleId).collect(Collectors.toList());
-            AppPlanToRole atr = null;
-            for (Long roleId : roleList) {
-                atr = new AppPlanToRole();
-                atr.setRoleId(roleId);
-                atr.setPlanId(id);
-                appPlanToRoleMapper.insert(atr);
-            }
+                List<Long> roleList = appPlanToRoleMapper.selectList(new LambdaQueryWrapper<AppPlanToRole>().eq(AppPlanToRole::getPlanId, dto.getId())).stream().map(AppPlanToRole::getRoleId).collect(Collectors.toList());
+                AppPlanToRole atr = null;
+                for (Long roleId : roleList) {
+                    atr = new AppPlanToRole();
+                    atr.setRoleId(roleId);
+                    atr.setPlanId(id);
+                    appPlanToRoleMapper.insert(atr);
+                }
 
-            List<AppPlanToPoint> itemList = appPlanToItemMapper.selectList(new LambdaQueryWrapper<AppPlanToPoint>().eq(AppPlanToPoint::getPlanId, dto.getId()));
-            AppPlanToPoint item = null;
-            for (AppPlanToPoint ruleItemVo : itemList) {
-                item = new AppPlanToPoint();
-                item.setPointId(ruleItemVo.getPointId());
-                item.setPlanId(id);
-                item.setPointScan(ruleItemVo.isPointScan());
-                item.setRequired(ruleItemVo.isRequired());
-                appPlanToItemMapper.insert(item);
+                List<AppPlanToPoint> itemList = appPlanToItemMapper.selectList(new LambdaQueryWrapper<AppPlanToPoint>().eq(AppPlanToPoint::getPlanId, dto.getId()));
+                AppPlanToPoint item = null;
+                for (AppPlanToPoint ruleItemVo : itemList) {
+                    item = new AppPlanToPoint();
+                    item.setPointId(ruleItemVo.getPointId());
+                    item.setPlanId(id);
+                    item.setPointScan(ruleItemVo.isPointScan());
+                    item.setRequired(ruleItemVo.isRequired());
+                    appPlanToItemMapper.insert(item);
+                }
             }
         }
-        //修改下发标识
+        //更新下发标识
         AppPlan plan = new AppPlan();
         plan.setId(dto.getId());
+        //设置下发状态1
         plan.setDistribute("1");
+        //设置计划状态为使用中
         plan.setPlanStatus(1);
         plan.setBuildTaskNow(null);
         baseMapper.updateById(plan);
@@ -197,7 +203,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
         }
         //设置下发状态为未下发
         plan.setDistribute("0");
-        plan.setPlanStatus(0);
+        plan.setPlanStatus(2);
         baseMapper.updateById(plan);
 
 
@@ -281,14 +287,17 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             if (size > 0) {
                 throw new RuntimeException("计划名称重复,请确认!");
             }
-            //如果计划为行社并且勾选立即生效
-            if (app.getExecOrgType() == 3 && app.getBuildTaskNow()==1) {
+
+            plan.setBuildTaskNow(app.getBuildTaskNow());
+            plan.setDistribute("0");
+            //设置计划所属机构类型
+            plan.setPlanOfOrgType(Long.valueOf(orgService.selectSysOrgById(app.getPlanCreateOrgId(), SecurityConstants.INNER).getType()));
+            //如果计划所属机构类型为行社并且勾选立即生效
+            if (plan.getPlanOfOrgType() == 3 && plan.getBuildTaskNow() == 1) {
                 plan.setPlanStatus(1);
             } else {
                 plan.setPlanStatus(0);
             }
-            plan.setBuildTaskNow(app.getBuildTaskNow());
-            plan.setDistribute("0");
             baseMapper.insert(plan);
             Long id = plan.getId();
 
@@ -342,33 +351,34 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                 app.setRoleList(new ArrayList<>());
             }
 
-            //获取计划对应的已完成任务数量
-            Long num = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", app.getId()).eq("status", 3));
-            if (num > 0) {
-                //如果状态为已禁用
-                if (app.getPlanStatus() == 0) {
-                    throw new RuntimeException("计划已生成任务,不能禁用!");
-                }
-
-            }
+//            //获取计划对应的已完成任务数量
+//            Long num = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", app.getId()).eq("status", 3));
+//            if (num > 0) {
+//                //如果状态为已禁用
+//                if (app.getPlanStatus() == 0) {
+//                    throw new RuntimeException("计划已生成任务,不能禁用!");
+//                }
+//
+//            }
 
             //修改所有子计划
             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));
-                if (nums > 0) {
-                    if (app.getPlanStatus() == 0) {
-                        throw new RuntimeException("计划已生成任务,不能禁用!");
-                    }
-                }
-                ap.setPlanName(plan.getPlanName());
+//                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("计划已生成任务,不能禁用!");
+//                    }
+//                }
                 ap.setPlanType(plan.getPlanType());
                 ap.setPlanCycle(plan.getPlanCycle());
 //                ap.setPlanStatus(plan.getPlanStatus());
                 ap.setExecOrgType(plan.getExecOrgType());
                 ap.setPlanExec(plan.getPlanExec());
                 ap.setModifiedBy(SecurityUtils.getUserId());
+                ap.setPlanName(plan.getPlanName());
+
                 baseMapper.updateById(ap);
 
                 if (app.getRoleList().size() > 0) {
@@ -404,7 +414,13 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                     item.setRequired(ruleItemVo.isRequired());
                     appPlanToItemMapper.insert(item);
                 }
-
+                //如果计划是编辑全部,代表不存在已完成或者逾期的任务,需要删除重新生成
+                if (app.getHasEdit() == null) {
+                    resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, ap.getId()));
+                }else {
+                    //否则代表编辑名称,需要同步未进行的任务名称
+                    resumptionMapper.updateNameByPlanId(app.getPlanName(),ap.getId());
+                }
 
             }
 
@@ -473,6 +489,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()));
+            }
         }
     }
 
@@ -482,6 +502,27 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
         AppPlan appPlan = baseMapper.selectById(id);
 
         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<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());
         QueryWrapper<AppPlanToRole> apr = new QueryWrapper<>();
@@ -531,9 +572,9 @@ 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).in("status", 3,4));
         if (num > 0) {
-            throw new RuntimeException("计划已生成任务,不能删除!");
+            throw new RuntimeException("计划有已完成或者已逾期的任务,不能被删除。");
         }
         //查找子计划
         List<AppPlan> childrens = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, id));
@@ -543,7 +584,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                 childrens) {
             Long nums = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", ap.getId()).eq("status", 3));
             if (nums > 0) {
-                throw new RuntimeException("子计划已生成任务,不能删除!");
+                throw new RuntimeException("子计划有已完成或者已逾期的任务,不能被删除。");
             }
             //删除计划对应的任务
             resumptionMapper.delete(new QueryWrapper<Resumption>().eq("plan_id", ap.getId()));

+ 0 - 4
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/task/ResumptionTaskBusiness.java

@@ -200,15 +200,11 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<AppPlanM
      */
     @Async
     public void syncDay(final DateTime dateTime, int plancycle) {//plancycle==0
-//        R<SysConfig> officeBuilding_open_allhours = systemParameService.findFirstByCode("officeBuilding_open_allhours", SecurityConstants.INNER);
-//        SysConfig officeAllHourParam = officeBuilding_open_allhours.getData();
         //获取履职计划
         List<AppPlan> AppPlanList = appPlanService.list((new QueryWrapper<AppPlan>()).lambda()
                 .eq(AppPlan::getPlanStatus, 1)
                 .eq(AppPlan::getPlanCycle, plancycle)
                 .in(AppPlan::getPlanOfOrgId, getHangsheOrgIds()));
-//                .eq(AppPlan::getPlanType, 1)
-//                .notIn(AppPlan::getPlanExec, canteenPlanExec));
         for (AppPlan appPlan : AppPlanList) {
             //获取履职计划中对应的检查要点
             List<AppRulePointTaskVo> pointList = appRulePointService.findPointByPlan(appPlan.getId());

+ 2 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/vo/appPlan/AppPlanVo.java

@@ -24,6 +24,8 @@ public class AppPlanVo extends PageDto<AppPlan> {
     private List<Long> ids;
     private Long id;
     private Integer buildTaskNow;
+    //涉及编辑内容
+    private Integer hasEdit;
     /**
      * 计划名称
      */

+ 1 - 1
soc-modules/soc-modules-core/src/main/resources/mapper/resumption/ResumptionMapper.xml

@@ -15,7 +15,7 @@
         <!--          and ymd_quarter = #{resumption.ymd.quarter}-->
     </update>
     <update id="updateNameByPlanId">
-update   core_resumption set name=#{planName} where plan_id =#{planId}
+update   core_resumption set name=#{planName} where plan_id =#{planId} and status in (1,2)
 
 
     </update>