Sfoglia il codice sorgente

Merge branch 'V0.0.4' of http://10.87.21.221:8000/jzyd_yyds/soc into V0.0.4

zhulu 1 anno fa
parent
commit
c361feb590
28 ha cambiato i file con 626 aggiunte e 290 eliminazioni
  1. 18 0
      project_data/sql/0.0.4/soc/soc.sql
  2. 16 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/enums/PlanStatus.java
  3. 19 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/enums/resumption/ResumptionTaskStatus.java
  4. 0 38
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/utils/ResumptionStatus.java
  5. 1 1
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/board/service/impl/AppCockpitServiceImpl.java
  6. 1 1
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/question/service/impl/QuestionReformServiceImpl.java
  7. 48 58
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/controller/ApiPlanController.java
  8. 16 7
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/domain/AppPlan.java
  9. 7 5
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/domain/AppPlanToPoint.java
  10. 8 1
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/domain/Resumption.java
  11. 1 1
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/gx/service/ResumptionServiceImpl.java
  12. 26 1
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/mapper/AppPlanMapper.java
  13. 1 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/mapper/AppRulePointMapper.java
  14. 2 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/mapper/ResumptionMapper.java
  15. 3 3
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/AppPlanService.java
  16. 2 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/IAppRulePointService.java
  17. 280 140
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/impl/AppPlanServiceImpl.java
  18. 5 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/impl/AppRulePointServiceImpl.java
  19. 2 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/impl/ResumptionServiceImpl.java
  20. 33 23
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/task/ResumptionTaskBusiness.java
  21. 7 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/task/ResumptionTaskBusinessService.java
  22. 6 3
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/vo/appPlan/AppPlanVo.java
  23. 2 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/vo/appPlan/ResumptionPlanPageVo.java
  24. 2 0
      soc-modules/soc-modules-core/src/main/java/com/xunmei/core/safetybook/service/impl/CoreSafetyBookNewServiceImpl.java
  25. 106 4
      soc-modules/soc-modules-core/src/main/resources/mapper/resumption/AppPlanMapper.xml
  26. 7 0
      soc-modules/soc-modules-core/src/main/resources/mapper/resumption/AppRulePointMapper.xml
  27. 3 0
      soc-modules/soc-modules-core/src/main/resources/mapper/resumption/ResumptionMapper.xml
  28. 4 4
      soc-modules/soc-modules-file/src/main/java/com/xunmei/file/utils/PdfUtil.java

+ 18 - 0
project_data/sql/0.0.4/soc/soc.sql

@@ -264,6 +264,24 @@ END IF;
     END IF;
 
 
+	IF
+        NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE () AND TABLE_NAME = 'core_resumption_plan' AND COLUMN_NAME = 'solid_id' ) THEN
+        ALTER TABLE  `core_resumption_plan` 
+			MODIFY COLUMN `parent_id` bigint NULL DEFAULT -1 COMMENT '下发父计划id' AFTER `id`,
+			ADD COLUMN `solid_id` bigint NULL COMMENT '固定的id,用于识别多个副本是否属于同一个计划' AFTER `parent_id`,
+			ADD COLUMN `parent_solid_id` bigint NULL COMMENT '固定的parentid,用于识别多个副本是否属于同一个计划' AFTER `solid_id`;
+    END IF;
+	IF
+        NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE () AND TABLE_NAME = 'core_resumption' AND COLUMN_NAME = 'solid_id' ) THEN
+        ALTER TABLE  `core_resumption` 
+			ADD COLUMN `solid_id` bigint NULL COMMENT '固定的id,用于识别多个副本是否属于同一个计划' AFTER `plan_id`,
+			ADD COLUMN `parent_solid_id` bigint NULL COMMENT '固定的parentid,用于识别多个副本是否属于同一个计划' AFTER `solid_id`;
+    END IF;
+	IF
+        EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE () AND TABLE_NAME = 'core_resumption_plan_to_point' AND COLUMN_NAME = 'effective_date' ) THEN
+        ALTER TABLE `core_resumption_plan_to_point` 
+			DROP COLUMN `effective_date`;
+    END IF;
 END ??
 DELIMITER;
 CALL schema_change ();

+ 16 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/enums/PlanStatus.java

@@ -0,0 +1,16 @@
+package com.xunmei.common.core.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@AllArgsConstructor
+@Getter
+public enum PlanStatus {
+    DRAFT(0, "草稿"),
+    USING(1, "使用中"),
+    DELETED(2, "停用"),
+    ;
+    private final Integer code;
+
+    private final String desc;
+}

+ 19 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/enums/resumption/ResumptionTaskStatus.java

@@ -0,0 +1,19 @@
+package com.xunmei.common.core.enums.resumption;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 任务状态
+ */
+@Getter
+@AllArgsConstructor
+public enum ResumptionTaskStatus {
+    Waiting(1, "待履职"),
+    UnderWay(2, "进行中"),
+    Completed(3, "已完成"),
+    Overdue(4, "已过期");
+
+    private final Integer code;
+    private final String name;
+}

+ 0 - 38
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/utils/ResumptionStatus.java

@@ -1,38 +0,0 @@
-package com.xunmei.common.core.utils;
-
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.ser.std.EnumSerializer;
-import lombok.Getter;
-
-/**
- * 履职状态
- */
-@JsonSerialize(using = EnumSerializer.class)
-public enum ResumptionStatus {
-    WAIT("履职中"),
-    NORMAL("按时完成"),
-    ERROR("按时完成"),
-    NOT("未完成"),
-    NA("无需履职"),
-    DELAY("补登完成");
-
-    /*
-    public static class ResumptionStatusListConverter implements AttributeConverter<List<ResumptionStatus>, String> {
-        @Override
-        public String convertToDatabaseColumn(final List<ResumptionStatus> attribute) {
-            return attribute == null ? "[]" : JSON.toJSONString(attribute);
-        }
-        @Override
-        public List<ResumptionStatus> convertToEntityAttribute(final String dbData) {
-            return JSON.parseArray(dbData, ResumptionStatus.class);
-        }
-    }
-    */
-
-    @Getter
-    private final String text;
-
-    ResumptionStatus(final String text) {
-        this.text = text;
-    }
-}

+ 1 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/board/service/impl/AppCockpitServiceImpl.java

@@ -341,7 +341,7 @@ public class AppCockpitServiceImpl implements AppCockpitService {
         AppSyntheticQuestionVo vo = new AppSyntheticQuestionVo();
         vo.getRateByState().put("已确认", (float) questionDto.getConfirmedCount());
         vo.getRateByState().put("有异议", (float) questionDto.getDissentCount());
-        vo.getRateByState().put("已取消", (float) questionDto.getCancelCount());
+        vo.getRateByState().put("已关闭", (float) questionDto.getCancelCount());
         vo.getRateByState().put("待整改", (float) questionDto.getWaitReformCount());
         vo.getRateByState().put("已逾期", (float) overdueCount);
         vo.getRateByState().put("已整改", (float) questionDto.getReformedCount());

+ 1 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/question/service/impl/QuestionReformServiceImpl.java

@@ -48,7 +48,7 @@ import java.util.stream.Collectors;
  * @date 2023-09-12
  */
 @Service
-public class QuestionReformServiceImpl extends ServiceImpl<QuestionMapper, Question> implements IQuestionReformService {
+public class  QuestionReformServiceImpl extends ServiceImpl<QuestionMapper, Question> implements IQuestionReformService {
     @Autowired
     private QuestionFlowMapper questionFlowMapper;
     @Autowired

+ 48 - 58
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/controller/ApiPlanController.java

@@ -39,8 +39,6 @@ import java.util.*;
 public class ApiPlanController {
     @Autowired
     private AppPlanService appPlanService;
-    @Autowired
-    ResumptionTaskBusiness resumptionTaskBusiness;
 
     /**
      * 计划分页查询
@@ -63,20 +61,20 @@ public class ApiPlanController {
      * @param dto
      * @return
      */
-    @PostMapping("/distribute")
+    @PostMapping("/distribute/{immediateEffect}")
     @RequiresPermissions("core:plan:distribute")
-    public AjaxResult distribute(@RequestBody DistributeDto dto) {
+    public AjaxResult distribute(@RequestBody DistributeDto dto, @PathVariable Boolean immediateEffect) {
         try {
-            appPlanService.distributeToOrg(dto);
-            AppPlan plan = appPlanService.getById(dto.getId());
-            //如果选择了计划立即生效
-            if (plan.getBuildTaskNow() == 1) {
-                LambdaQueryWrapper<AppPlan> wrapper=new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, plan.getId()).eq(AppPlan::getDeleted, 0);
-                List<AppPlan> list = appPlanService.list(wrapper);
-                list.add(plan);
-                List<Object> newlist = new ArrayList<>(list);
-                resumptionTaskBusiness.rebuildCurrentCycleTask(newlist);
-            }
+            appPlanService.distributeToOrg(dto, immediateEffect);
+//            AppPlan plan = appPlanService.getById(dto.getId());
+//            //如果选择了计划立即生效
+//            if (plan.getBuildTaskNow() == 1) {
+//                LambdaQueryWrapper<AppPlan> wrapper = new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, plan.getId()).eq(AppPlan::getDeleted, 0);
+//                List<AppPlan> list = appPlanService.list(wrapper);
+//                list.add(plan);
+//                List<Object> newlist = new ArrayList<>(list);
+//                resumptionTaskBusiness.rebuildCurrentCycleTask(newlist);
+//            }
             return AjaxResult.success();
         } catch (Exception e) {
             e.printStackTrace();
@@ -126,36 +124,36 @@ public class ApiPlanController {
      * @author 高雄
      * @time 2022/5/5 16:37
      */
-    @RequestMapping("/edit")
+    @RequestMapping("/edit/{immediateEffect}")
     @RequiresPermissions("core:plan:edit")
-    public AjaxResult edit(@RequestBody AppPlanVo info) {
+    public AjaxResult edit(@RequestBody AppPlanVo info, @PathVariable Boolean immediateEffect) {
         try {
-            appPlanService.saveOrUpdatePlan(info);
-            AppPlan plan = null;
-            plan = appPlanService.getById(info.getId());
-            if (info.getId() != null) {
-                //判断是否是编辑并且计划所属任务不存在已完成或者逾期,需要删除所有任务重新生成
-                //因为找的是子计划,所以是已经下发了
-                //如果是创建日期的周期就编辑,立即生效则生成任务;如果是之后的周期,则生成任务
-                DateRange range = DateUtils.getStartAndEnd(new Date(), CycleCommonEnum.getEnum(plan.getPlanCycle()));
-                Date nextBeginDate = range.getStartTime();
-                Date createDate = DateUtil.beginOfDay(plan.getCreateTime());
-                boolean generateTask = info.getId() != null && (nextBeginDate.after(createDate) || (!nextBeginDate.after(createDate) && plan.getBuildTaskNow() > 0));
-                //如果计划所属机构类型为行社并且勾选立即执行,新增的时候立即生成任务
-                if (generateTask) {
-                    //如果编辑
-                    List<AppPlan> list = appPlanService.list(new LambdaQueryWrapper<AppPlan>()
-                            .eq(AppPlan::getParentId, plan.getId())
-                            .eq(AppPlan::getDeleted, 0)
-                            .eq(AppPlan::getPlanStatus,1));
-                    if(ObjectUtil.equal(plan.getPlanStatus(),1)){
-                        list.add(plan);
-                    }
-
-                    List<Object> newlist = new ArrayList<>(list);
-                    resumptionTaskBusiness.rebuildCurrentCycleTask(newlist);
-                }
-            }
+            appPlanService.saveOrUpdatePlan(info, immediateEffect);
+//            AppPlan plan = null;
+//            plan = appPlanService.getById(info.getId());
+//            if (info.getId() != null) {
+//                //判断是否是编辑并且计划所属任务不存在已完成或者逾期,需要删除所有任务重新生成
+//                //因为找的是子计划,所以是已经下发了
+//                //如果是创建日期的周期就编辑,立即生效则生成任务;如果是之后的周期,则生成任务
+//                DateRange range = DateUtils.getStartAndEnd(new Date(), CycleCommonEnum.getEnum(plan.getPlanCycle()));
+//                Date nextBeginDate = range.getStartTime();
+//                Date createDate = DateUtil.beginOfDay(plan.getCreateTime());
+//                boolean generateTask = info.getId() != null && (nextBeginDate.after(createDate) || (!nextBeginDate.after(createDate) && plan.getBuildTaskNow() > 0));
+//                //如果计划所属机构类型为行社并且勾选立即执行,新增的时候立即生成任务
+//                if (generateTask) {
+//                    //如果编辑
+//                    List<AppPlan> list = appPlanService.list(new LambdaQueryWrapper<AppPlan>()
+//                            .eq(AppPlan::getParentId, plan.getId())
+//                            .eq(AppPlan::getDeleted, 0)
+//                            .eq(AppPlan::getPlanStatus, 1));
+//                    if (ObjectUtil.equal(plan.getPlanStatus(), 1)) {
+//                        list.add(plan);
+//                    }
+//
+//                    List<Object> newlist = new ArrayList<>(list);
+//                    resumptionTaskBusiness.rebuildCurrentCycleTask(newlist);
+//                }
+//            }
 
             return AjaxResult.success();
         } catch (Exception e) {
@@ -189,22 +187,14 @@ public class ApiPlanController {
         return AjaxResult.success();
     }
 
-    @ApiOperation(value = "下发计划")
-    @GetMapping(value = "/distributeCheHui/{id}")
+    @ApiOperation(value = "下发所属机构为行社的计划")
+    @GetMapping(value = "/distributehs/{id}/{immediateEffect}")
 //    @RequiresPermissions("core:plan:findById")
-    public AjaxResult distributeChild(@PathVariable Long id) {
-        AppPlan planOld =appPlanService.getById(id);
-        AppPlan planNew = appPlanService.distributeCheHui(id);
-        //撤回后下发,不重新生成任务
-
-        //行社的第一次下发也是走这里,如果是所属机构是行社且第一次下发,则要生成任务
-        if (planOld.getBuildTaskNow() == 1 && ObjectUtil.equal(planOld.getPlanOfOrgType().intValue(), OrgTypeEnum.HANG_SHE.getCode())
-                && ObjectUtil.equal(planOld.getPlanStatus(),0)) {
-            List<Object> newlist = new ArrayList<>();
-            newlist.add(planNew);
-            resumptionTaskBusiness.rebuildCurrentCycleTask(newlist);
-        }
-        return AjaxResult.success(planNew!=null);
+    public AjaxResult distributeHS(@PathVariable Long id, @PathVariable Boolean immediateEffect) {
+        //停用状态时
+        AppPlan planNew = appPlanService.distributeHS(id, immediateEffect);
+
+        return AjaxResult.success(planNew != null);
     }
 
     @ApiOperation(value = "获取详情")
@@ -223,7 +213,7 @@ public class ApiPlanController {
      * @time 2022/5/5 17:38
      */
     @ApiOperation(value = "删除计划")
-    @GetMapping(value = "/delete/{id}")
+    @DeleteMapping(value = "/delete/{id}")
     @RequiresPermissions("core:plan:delete")
     public AjaxResult deleted(@PathVariable Long id) {
         try {

+ 16 - 7
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/domain/AppPlan.java

@@ -10,6 +10,7 @@ import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
+import org.apache.http.annotation.Obsolete;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -39,6 +40,18 @@ public class AppPlan extends Model<AppPlan> implements Serializable {
     @TableId(type = IdType.AUTO)
     private Long id;
     /**
+     * 计划父id(下发机构独有)
+     */
+    private Long parentId;
+    /**
+     * 固定的id,用于识别多个副本是否属于同一个计划
+     */
+    private Long solidId;
+    /**
+     * 固定的parentid,用于识别多个副本是否属于同一个计划
+     */
+    private Long parentSolidId;
+    /**
      * 计划名称
      */
 
@@ -119,12 +132,6 @@ public class AppPlan extends Model<AppPlan> implements Serializable {
      */
     private String distributePlanStatus;
     /**
-     * 计划父id(下发机构独有)
-     */
-    private Long parentId;
-
-
-    /**
      * 备注
      */
     private String description;
@@ -163,11 +170,13 @@ public class AppPlan extends Model<AppPlan> implements Serializable {
 
     @TableField(exist = false)
     private String orgId;
-    private Integer buildTaskNow;
+//    @Obsolete
+//    private Integer buildTaskNow;
 
     @TableLogic(value = "0", delval = "1")
     @ApiModelProperty(value = "是否删除 1是 0否")
     private int deleted;
+
     @ApiModelProperty(value = "1:表示有已完成的任务")
     private Integer taskHasCompleted;
 //    public static ObjectDataClass planTo(AppPlan appPlan) {

+ 7 - 5
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/domain/AppPlanToPoint.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
+import org.apache.http.annotation.Obsolete;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -41,9 +42,10 @@ public class AppPlanToPoint extends Model<AppPlanToPoint> implements Serializabl
      */
     private boolean required;
     private Long ofOrgId;
-
-    /**
-     * 生效日期
-     */
-    private Date effectiveDate;
+//
+//    /**
+//     * 生效日期
+//     */
+//    @Obsolete
+//    private Date effectiveDate;
 }

+ 8 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/domain/Resumption.java

@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.xunmei.common.core.utils.FormType;
-import com.xunmei.common.core.utils.ResumptionStatus;
 import com.xunmei.common.core.utils.ResumptionType;
 import com.xunmei.common.core.utils.Ymd;
 import com.xunmei.common.core.web.domain.BaseEntity;
@@ -105,6 +104,14 @@ public class Resumption extends BaseEntity {
 
     private Long parentPlanId;
     private Long planId;
+    /**
+     * 固定的id,用于识别多个副本是否属于同一个计划
+     */
+    private Long solidId;
+    /**
+     * 固定的parentid,用于识别多个副本是否属于同一个计划
+     */
+    private Long parentSolidId;
     private Date startTime;
     private Date endTime;
     private Date planStartTime;

+ 1 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/gx/service/ResumptionServiceImpl.java

@@ -106,7 +106,7 @@ public class ResumptionServiceImpl implements ResumptionService {
         if (status == 1 || status == 4) {
             //待履职 和已过期的数据是没有保存过数据的只能根据计划获取
             Long planId = resumption.getPlanId();
-            resumptionPlanVos = appPlanMapper.selectResumptionPlan(planId, resumption.getPlanStartTime());
+            resumptionPlanVos = appPlanMapper.selectResumptionPlan(planId);
             isExist = false;
         } else {
             resumptionPlanVos = resumptionMapper.selectResumptionPlan(taskDetailVo.getTaskId());

+ 26 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/mapper/AppPlanMapper.java

@@ -91,7 +91,32 @@ public interface AppPlanMapper extends BaseMapper<AppPlan> {
      * @param startDate 任务的开始日期
      * @return
      */
-    List<ResumptionPlanVo> selectResumptionPlan(@Param("planId") Long planId, @Param("startDate") Date startDate);
+    List<ResumptionPlanVo> selectResumptionPlan(@Param("planId") Long planId);
 
     Integer updateParentPlanCompletedState(@Param("planId") Long planId);
+
+    /**
+     * 复制一份自己
+     * @param planId
+     * @param newPlanId
+     * @return
+     */
+    Integer copySelf(@Param("planId") Long planId, @Param("newPlanId")Long newPlanId);
+
+    /**
+     * 复制子计划
+     * @param planId
+     * @param newPlanId
+     * @param newParentId
+     * @return
+     */
+    Integer copyChildren(@Param("planId") Long planId,@Param("newPlanId")Long newPlanId,@Param("newParentId")Long newParentId);
+
+    Integer copyPlanPoints(@Param("planId") Long planId, @Param("newPlanId")Long newPlanId);
+
+    Integer copyPlanRoles(@Param("planId") Long planId, @Param("newPlanId")Long newPlanId);
+
+    Integer copyPlanOrgs(@Param("planId") Long planId, @Param("newPlanId")Long newPlanId);
+
+    Integer physicsDeleteById(@Param("ids") List<Long> ids);
 }

+ 1 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/mapper/AppRulePointMapper.java

@@ -34,6 +34,7 @@ public interface AppRulePointMapper extends BaseMapper<AppRulePoint> {
 
     List<AppRulePointTaskVo> findPointByPlan(Long planid);
 
+    Integer countPointByPlan(Long planid);
     List<Map<String, Object>> findAreaListPlan(Long planid);
 
     Map<String, Object> findByName(Map<String, Object> param);

+ 2 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/mapper/ResumptionMapper.java

@@ -101,4 +101,6 @@ public interface ResumptionMapper extends BaseMapper<Resumption> {
     void batchInsertResumptionImg(@Param("list") List<AppResumptionDataRemarkimg> list);
 
     void batchInsertResumptionNfc(@Param("list") List<AppResumptionDataNfc> list);
+
+//    int updatePlanId(@Param("oldPlanId")Long oldPlanId,@Param("newPlanId")Long newPlanId,@Param("newPlanParentId")Long newPlanParentId);
 }

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

@@ -56,7 +56,7 @@ public interface AppPlanService extends IService<AppPlan> {
      * @author 高雄
      * @time 2022/5/5 16:38
      */
-    void saveOrUpdatePlan(AppPlanVo app) throws Exception;
+    void saveOrUpdatePlan(AppPlanVo app, Boolean immediateEffect) throws Exception;
 
     /**
      * 获取计划详情数据
@@ -82,11 +82,11 @@ public interface AppPlanService extends IService<AppPlan> {
      */
     List<Long> findRoleByPlan(Long id);
 
-    void distributeToOrg(DistributeDto dto);
+    void distributeToOrg(DistributeDto dto, Boolean immediateEffect);
 
     void cheHui(Long id);
 
-    AppPlan distributeCheHui(Long id);
+    AppPlan distributeHS(Long id, Boolean immediateEffect);
 
     AjaxResult buildPdf();
     AjaxResult buildResumptionPdf(Long id);

+ 2 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/IAppRulePointService.java

@@ -20,6 +20,8 @@ public interface IAppRulePointService extends IService<AppRulePoint> {
 
     List<AppRulePointTaskVo> findPointByPlan(Long id);
 
+    Integer countPointByPlan(Long id);
+
     List<Map<String, Object>> findAreaListPlan(Long planid);
 
     Map<String, Object> findByName(String name,Long ruleId);

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

@@ -12,14 +12,16 @@ 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;
 import com.xunmei.common.core.exception.SystemException;
 import com.xunmei.common.core.utils.DateUtils;
+import com.xunmei.common.core.utils.IDHelper;
 import com.xunmei.common.core.web.domain.AjaxResult;
 import com.xunmei.common.security.utils.SecurityUtils;
 import com.xunmei.core.registerbook.service.ICoreRegisterBookPdfService;
@@ -30,6 +32,7 @@ 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.ResumptionTaskBusinessService;
 import com.xunmei.core.resumption.vo.appPlan.AppPlanVo;
 import com.xunmei.core.resumption.vo.appPlan.ResumptionPlanPageVo;
 import com.xunmei.core.resumption.vo.appPlan.RuleItemVo;
@@ -44,14 +47,13 @@ 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;
 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;
@@ -91,6 +93,9 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
     @Qualifier(ThreadPoolConfig.SOC_EXECUTOR)
     private ThreadPoolTaskExecutor threadPoolTaskExecutor;
 
+    @Autowired
+    ResumptionTaskBusinessService resumptionTaskBusiness;
+
     @Override
     public List<Long> selectItemIdsByPlanId(Long id) {
         return appPlanToItemMapper.selectItemIdsByPlanId(id);
@@ -171,22 +176,48 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
     }
 
     @Override
-    public void distributeToOrg(DistributeDto dto) {
+    @Transactional
+    public void distributeToOrg(DistributeDto dto, Boolean immediateEffect) {
+        AppPlan oldPlan = baseMapper.selectById(dto.getId());
+        Long parentId = IDHelper.id();
+        List<Object> hsPlans = new ArrayList<>();
         //如果计划所属机构类型为省联社,生成下发子计划
-        if (baseMapper.selectById(dto.getId()).getPlanOfOrgType() == 1) {
+        if (ObjectUtil.equal(oldPlan.getPlanOfOrgType(), 1L)) {
             for (DistributeStatusDto d :
                     dto.getOrgAndStatus()) {
 
-
-                AppPlan tempplan = baseMapper.selectOne(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getPlanOfOrgId, d.getOrgId()).eq(AppPlan::getParentId, dto.getId()));
+                AppPlan tempplan = baseMapper.selectOne(new LambdaQueryWrapper<AppPlan>()
+                        .eq(AppPlan::getPlanOfOrgId, d.getOrgId())
+                        .eq(AppPlan::getParentId, dto.getId()));
                 //如果子计划已存在
                 if (tempplan != null) {
                     tempplan.setPlanStatus(d.getStatus() > 0 ? 1 : 2);
                     tempplan.setDistributePlanStatus(d.getStatus().toString());
                     tempplan.setDistributeStatus("1");
-                    baseMapper.updateById(tempplan);
+                    if (immediateEffect) {
+                        //停用状态下发,逻辑删除旧的计划,并生成一份副本
+                        baseMapper.updateById(tempplan);
+                        baseMapper.deleteById(tempplan);
+
+                        Long hsPlanId = IDHelper.id();
+                        baseMapper.copyChildren(tempplan.getId(), hsPlanId, parentId);
+                        baseMapper.copyPlanOrgs(tempplan.getId(), hsPlanId);
+                        baseMapper.copyPlanRoles(tempplan.getId(), hsPlanId);
+                        baseMapper.copyPlanPoints(tempplan.getId(), hsPlanId);
+
+                        AppPlan newPlan = baseMapper.selectById(hsPlanId);
+                        hsPlans.add(newPlan);
+                    } else {
+                        baseMapper.updateById(tempplan);
+                    }
                 } else {
-                    AppPlan plan = baseMapper.selectById(dto.getId());
+                    AppPlan plan = new AppPlan();
+                    BeanUtils.copyProperties(oldPlan, plan);
+                    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());
@@ -198,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();
 
@@ -219,7 +251,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                         item.setPointScan(ruleItemVo.isPointScan());
                         item.setRequired(ruleItemVo.isRequired());
                         item.setOfOrgId(ruleItemVo.getOfOrgId());
-                        item.setEffectiveDate(ruleItemVo.getEffectiveDate());
+//                        item.setEffectiveDate(ruleItemVo.getEffectiveDate());
                         appPlanToItemMapper.insert(item);
                     }
                 }
@@ -232,51 +264,31 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
         plan.setDistribute("1");
         //设置计划状态为使用中
         plan.setPlanStatus(1);
-        plan.setBuildTaskNow(null);
-        baseMapper.updateById(plan);
-    }
+//        plan.setBuildTaskNow(null);
 
-    @Override
-    public void cheHui(Long id) {
-        AppPlan plan = baseMapper.selectById(id);
-        //修改所有子计划
-        List<AppPlan> appPlans = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, id));
-        List<Long> deleteByPlanIds = new ArrayList<>();//如果计划没有已完成 ,则删除该计划所有任务
-        for (AppPlan ap :
-                appPlans) {
-//修改计划状态为停用
-            ap.setBuildTaskNow(0);
-            ap.setPlanStatus(2);
-            baseMapper.updateById(ap);
-
-            if (ObjectUtil.notEqual(plan.getTaskHasCompleted(), 1)) {
-                deleteByPlanIds.add(ap.getId());
-            }
-        }
-        //设置下发状态为未下发
-        plan.setDistribute("0");
-        plan.setPlanStatus(2);
-        plan.setBuildTaskNow(0);
-        baseMapper.updateById(plan);
-
-        if (ObjectUtil.notEqual(plan.getTaskHasCompleted(), 1)) {
-            deleteByPlanIds.add(plan.getId());
-        }
+        if (immediateEffect && ObjectUtil.equal(oldPlan.getPlanStatus(), PlanStatus.DELETED.getCode())) {
+            //停用时下发且立即生效,逻辑删除旧计划并生成新计划
+            baseMapper.updateById(plan);
 
-        deleteTaskByPlanId(deleteByPlanIds);
-    }
+            baseMapper.copySelf(plan.getId(), parentId);
+            baseMapper.copyPlanPoints(plan.getId(), parentId);
+            baseMapper.copyPlanRoles(plan.getId(), parentId);
+            baseMapper.copyPlanOrgs(plan.getId(), parentId);
 
-    @Async
-    protected void deleteTaskByPlanId(List<Long> planIds) {
-        if(CollectionUtils.isEmpty(planIds)){
-            return;
+            baseMapper.deleteById(plan);
+        } else {
+            baseMapper.updateById(plan);
+        }
+
+        if (immediateEffect) {
+            resumptionTaskBusiness.rebuildCurrentCycleTask(hsPlans);
         }
-        resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().in(Resumption::getPlanId, planIds));
     }
 
     @Override
-    public AppPlan distributeCheHui(Long id) {
+    public AppPlan distributeHS(Long id, Boolean immediateEffect) {
         AppPlan plan = baseMapper.selectById(id);
+        Integer planStatus = plan.getPlanStatus();
         //设置计划状态
         plan.setPlanStatus(1);
         //如果是行社撤回需要修改下发状态
@@ -286,10 +298,125 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
         } else {
             plan.setDistribute("0");
         }
-        baseMapper.updateById(plan);
+
+        //
+        if (immediateEffect) {
+            List<Object> newlist = new ArrayList<>();
+            if (ObjectUtil.equal(planStatus, PlanStatus.DRAFT.getCode())) {
+                //草稿状态下发,立即生效则生成任务
+                newlist.add(plan);
+                baseMapper.updateById(plan);
+            } else if (ObjectUtil.equal(planStatus, PlanStatus.DELETED.getCode())) {
+                //停用状态下发,逻辑删除旧计划,并生成计划的副本,并更新任务名称和关联的计划id
+                baseMapper.updateById(plan);
+                baseMapper.deleteById(plan.getId());
+                Long newPlanId = IDHelper.id();
+                copyHsPlan(id, newPlanId);
+
+                AppPlan newPlan = baseMapper.selectById(newPlanId);
+                newlist.add(newPlan);
+            }
+
+            resumptionTaskBusiness.rebuildCurrentCycleTask(newlist);
+        } else {
+            baseMapper.updateById(plan);
+        }
+
+
         return plan;
     }
 
+    private void copyHsPlan(Long id, Long newPlanId) {
+        baseMapper.copySelf(id, newPlanId);
+        baseMapper.copyPlanPoints(id, newPlanId);
+        baseMapper.copyPlanRoles(id, newPlanId);
+        baseMapper.copyPlanOrgs(id, newPlanId);
+    }
+
+    @Override
+    public void cheHui(Long id) {
+        AppPlan plan = baseMapper.selectById(id);
+        if (ObjectUtil.equal(plan.getTaskHasCompleted(), 1)) {
+            //有已完成时,计划及子计划状态变为停用,不删除任务
+            LambdaUpdateWrapper<AppPlan> updateWrapper = new LambdaUpdateWrapper<>();
+            updateWrapper.set(AppPlan::getPlanStatus, 2)
+                    .eq(AppPlan::getParentId, id);
+            baseMapper.update(null, updateWrapper);
+
+            updateWrapper = new LambdaUpdateWrapper<>();
+            updateWrapper.set(AppPlan::getPlanStatus, 2)
+                    .set(AppPlan::getDistribute, 0)
+                    .eq(AppPlan::getId, id);
+            baseMapper.update(null, updateWrapper);
+        } else {
+            //无已完成时,删除子计划,计划本身变为草稿
+            LambdaUpdateWrapper<AppPlan> updateWrapper = new LambdaUpdateWrapper<>();
+            updateWrapper.set(AppPlan::getPlanStatus, 0)
+                    .set(AppPlan::getDistribute, 0)
+                    .eq(AppPlan::getId, id);
+            baseMapper.update(null, updateWrapper);
+
+            List<Long> childrenPlanIds = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>()
+                            .eq(AppPlan::getParentId, id)
+                            .select(AppPlan::getSolidId))
+                    .stream().map(AppPlan::getSolidId).collect(Collectors.toList());
+            delete(childrenPlanIds);
+
+            childrenPlanIds.add(plan.getSolidId());
+            deleteAllTaskByPlanId(childrenPlanIds);
+        }
+//
+//        //修改所有子计划
+//        List<AppPlan> appPlans = baseMapper.selectList(new LambdaQueryWrapper<AppPlan>().eq(AppPlan::getParentId, id));
+//        List<Long> deleteByPlanIds = new ArrayList<>();//如果计划没有已完成 ,则删除该计划所有任务
+//        for (AppPlan ap :
+//                appPlans) {
+////修改计划状态为停用
+//            ap.setBuildTaskNow(0);
+//            ap.setPlanStatus(2);
+//            baseMapper.updateById(ap);
+//
+//            if (ObjectUtil.notEqual(plan.getTaskHasCompleted(), 1)) {
+//                deleteByPlanIds.add(ap.getId());
+//            }
+//        }
+//        //设置下发状态为未下发
+//        plan.setDistribute("0");
+//        plan.setPlanStatus(2);
+//        plan.setBuildTaskNow(0);
+//        baseMapper.updateById(plan);
+//
+//        if (ObjectUtil.notEqual(plan.getTaskHasCompleted(), 1)) {
+//            deleteByPlanIds.add(plan.getId());
+//        }
+//
+//        deleteTaskByPlanId(deleteByPlanIds);
+    }
+
+    @Async
+    protected void deleteTaskByPlanId(List<Long> solidPlanIds) {
+        if (CollectionUtils.isEmpty(solidPlanIds)) {
+            return;
+        }
+        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));
+    }
+
     /**
      * 获取检查要点分页
      *
@@ -327,7 +454,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void saveOrUpdatePlan(AppPlanVo app) throws Exception {
+    public void saveOrUpdatePlan(AppPlanVo app, Boolean immediateEffect) throws Exception {
         AppPlan plan = convertToAppPlan(app);
         Calendar calendar = Calendar.getInstance();
         calendar.set(2000, 0, 1);
@@ -335,6 +462,8 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
         if (app.getId() == null) {
             plan.setParentId(-1L);
             plan.setDeleted(0);
+            plan.setSolidId(IDHelper.id());
+            plan.setParentSolidId(-1L);
             plan.setCreateTime(new Date());
             //新增
             plan.setPlanOfOrgId(app.getPlanCreateOrgId());
@@ -349,7 +478,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                 throw new RuntimeException("计划名称重复,请确认!");
             }
 
-            plan.setBuildTaskNow(app.getBuildTaskNow());
+//            plan.setBuildTaskNow(app.getBuildTaskNow());
             plan.setDistribute("0");
             plan.setPlanStatus(0);
             //设置计划所属机构类型
@@ -388,7 +517,6 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                 item.setPointScan(ruleItemVo.isPointScan());
                 item.setRequired(ruleItemVo.isRequired());
                 item.setOfOrgId(ruleItemVo.getOfOrgId());
-                item.setEffectiveDate(calendar.getTime());
                 appPlanToItemMapper.insert(item);
             }
         } else {
@@ -396,40 +524,58 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                 app.setRoleList(new ArrayList<>());
             }
 
+            Long newPlanID = IDHelper.id();
             AppPlan existPlan = baseMapper.selectById(app.getId());
             LambdaQueryWrapper<AppPlanToPoint> pointWrapper = new LambdaQueryWrapper<>();
             pointWrapper.eq(AppPlanToPoint::getPlanId, app.getId());
 
-
+            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()));
+
             for (AppPlan ap :
                     appPlans) {
+                AppPlan child = ap;
+                if (needCopy) {
+                    //使用中状态且立即生效,复制副本
+                    Long newChildPlanId = IDHelper.id();
+                    baseMapper.copyChildren(ap.getId(), newChildPlanId, newPlanID);
+                    baseMapper.copyPlanOrgs(ap.getId(), newChildPlanId);
+                    baseMapper.copyPlanRoles(ap.getId(), newChildPlanId);
+                    baseMapper.copyPlanPoints(ap.getId(), newChildPlanId);
+
+                    baseMapper.updateById(ap);
+                    baseMapper.deleteById(ap.getId());
+                    child = baseMapper.selectById(newChildPlanId);
+                    needRebuildPlans.add(child);
+                }
                 Map<Long, AppPlanToPoint> planPoints = appPlanToItemMapper.selectList(pointWrapper).stream()
                         .collect(Collectors.toMap(AppPlanToPoint::getPointId, p -> p));
-                Date defaultEffectiveDate = calendar.getTime();
-                if (ObjectUtil.equal(ap.getTaskHasCompleted(), 1)) {
-                    DateRange range = DateUtils.getStartAndEnd(new Date(), CycleCommonEnum.getEnum(app.getPlanCycle()));
-                    defaultEffectiveDate = DateUtil.beginOfDay(DateUtils.addDays(range.getEndTime(), 1));
-                }
+//                Date defaultEffectiveDate = calendar.getTime();
+//                if (ObjectUtil.equal(ap.getTaskHasCompleted(), 1)) {
+//                    DateRange range = DateUtils.getStartAndEnd(new Date(), CycleCommonEnum.getEnum(app.getPlanCycle()));
+//                    defaultEffectiveDate = DateUtil.beginOfDay(DateUtils.addDays(range.getEndTime(), 1));
+//                }
 
-                ap.setPlanType(plan.getPlanType());
-                ap.setPlanCycle(plan.getPlanCycle());
-                ap.setExecOrgType(plan.getExecOrgType());
-                ap.setPlanExec(plan.getPlanExec());
-                ap.setModifiedBy(SecurityUtils.getUserId());
-                ap.setPlanName(plan.getPlanName());
-                ap.setCount(plan.getCount());
-                baseMapper.updateById(ap);
+                child.setPlanType(plan.getPlanType());
+                child.setPlanCycle(plan.getPlanCycle());
+                child.setExecOrgType(plan.getExecOrgType());
+                child.setPlanExec(plan.getPlanExec());
+                child.setModifiedBy(SecurityUtils.getUserId());
+                child.setPlanName(plan.getPlanName());
+                child.setCount(plan.getCount());
+                baseMapper.updateById(child);
 
                 if (app.getRoleList().size() > 0) {
                     QueryWrapper<AppPlanToRole> apr = new QueryWrapper<>();
-                    apr.lambda().eq(AppPlanToRole::getPlanId, ap.getId());
+                    apr.lambda().eq(AppPlanToRole::getPlanId, child.getId());
                     appPlanToRoleMapper.delete(apr);
                 }
 
                 QueryWrapper<AppPlanToPoint> api = new QueryWrapper<>();
-                api.lambda().eq(AppPlanToPoint::getPlanId, ap.getId()).eq(AppPlanToPoint::getOfOrgId, app.getPlanCreateOrgId());
+                api.lambda().eq(AppPlanToPoint::getPlanId, child.getId()).eq(AppPlanToPoint::getOfOrgId, app.getPlanCreateOrgId());
                 appPlanToItemMapper.delete(api);
 
                 List<Long> roleList = app.getRoleList();
@@ -437,7 +583,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                 for (Long roleId : roleList) {
                     atr = new AppPlanToRole();
                     atr.setRoleId(roleId);
-                    atr.setPlanId(ap.getId());
+                    atr.setPlanId(child.getId());
                     appPlanToRoleMapper.insert(atr);
                 }
 
@@ -454,28 +600,39 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                 for (RuleItemVo ruleItemVo : itemList) {
                     item = new AppPlanToPoint();
                     item.setPointId(ruleItemVo.getId());
-                    item.setPlanId(ap.getId());
+                    item.setPlanId(child.getId());
                     item.setPointScan(ruleItemVo.isPointScan());
                     item.setRequired(ruleItemVo.isRequired());
                     item.setOfOrgId(ruleItemVo.getOfOrgId());
-                    if (planPoints.containsKey(ruleItemVo.getId())) {
-                        item.setEffectiveDate(planPoints.get(ruleItemVo.getId()).getEffectiveDate());
-                    } else {
-                        item.setEffectiveDate(defaultEffectiveDate);
-                    }
+//                    if (planPoints.containsKey(ruleItemVo.getId())) {
+//                        item.setEffectiveDate(planPoints.get(ruleItemVo.getId()).getEffectiveDate());
+//                    } else {
+//                        item.setEffectiveDate(defaultEffectiveDate);
+//                    }
 
                     appPlanToItemMapper.insert(item);
                 }
                 //如果计划是编辑全部,代表不存在已完成或者逾期的任务,需要删除重新生成
-                if (app.getHasEdit() == null) {
-                    resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, ap.getId()));
-                } else {
-                    //否则代表编辑名称,需要同步未进行的任务名称
-                    resumptionMapper.updateNameByPlanId(existPlan.getPlanName(),app.getPlanName(), ap.getId());
-                }
-
+//                if (app.getHasEdit() == null) {
+//                    resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, ap.getId()));
+//                } else {
+//                    //否则代表编辑名称,需要同步未进行的任务名称
+//                    resumptionMapper.updateNameByPlanId(existPlan.getPlanName(), app.getPlanName(), ap.getId());
+//                }
             }
 
+            if (needCopy) {
+                baseMapper.copySelf(existPlan.getId(), newPlanID);
+                baseMapper.copyPlanOrgs(existPlan.getId(), newPlanID);
+                baseMapper.copyPlanRoles(existPlan.getId(), newPlanID);
+                baseMapper.copyPlanPoints(existPlan.getId(), newPlanID);
+
+                baseMapper.deleteById(app.getId());
+
+                plan.setId(newPlanID);
+
+
+            }
 
 //处理本计划关联
             Long id = plan.getId();
@@ -520,7 +677,6 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                 item.setPointScan(ruleItemVo.isPointScan());
                 item.setRequired(ruleItemVo.isRequired());
                 item.setOfOrgId(ruleItemVo.getOfOrgId());
-                item.setEffectiveDate(calendar.getTime());
                 appPlanToItemMapper.insert(item);
             }
 
@@ -534,7 +690,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                 appPlanToExecOrgMapper.insert(execOrg);
             }
             //更新任务的名称
-            resumptionMapper.updateNameByPlanId(existPlan.getPlanName(),app.getPlanName(), app.getId());
+            resumptionMapper.updateNameByPlanId(existPlan.getPlanName(), app.getPlanName(), app.getId());
 
             //最后处理本计划
             plan.setUpdateTime(new Date());
@@ -545,6 +701,11 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             plan.setPlanCreateOrgId(null);
             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)) {
 //                resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, plan.getId()));
@@ -554,7 +715,6 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 
     @Override
     public AppPlanVo findById(Long id) {
-
         AppPlan appPlan = baseMapper.selectById(id);
 
         AppPlanVo appPlanVo = convertToAppPlanVo(appPlan);
@@ -626,69 +786,49 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void deleted(Long id) throws Exception {
-        /**
-         * 验证计划是否被应用
-         */
-        Long num = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", id).in("status", 3, 4));
-        if (num > 0) {
-            throw new RuntimeException("计划有已完成或者已逾期的任务,不能被删除。");
-        }
-        //查找子计划
-        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));
-            if (nums > 0) {
-                throw new RuntimeException("子计划有已完成或者已逾期的任务,不能被删除。");
-            }
-            //删除计划对应的任务
-            resumptionMapper.delete(new QueryWrapper<Resumption>().eq("plan_id", ap.getId()));
-            //删除对应的角色关系
-            QueryWrapper<AppPlanToRole> qw = new QueryWrapper<>();
-            qw.lambda().eq(AppPlanToRole::getPlanId, ap.getId());
-            appPlanToRoleMapper.delete(qw);
-
-            //删除对应的要点关系
-            QueryWrapper<AppPlanToPoint> aw = new QueryWrapper<>();
-            aw.lambda().eq(AppPlanToPoint::getPlanId, ap.getId());
-            appPlanToItemMapper.delete(aw);
-
-            //删除机构关系
-            QueryWrapper<AppPlanToExecOrg> apo = new QueryWrapper<>();
-            apo.lambda().eq(AppPlanToExecOrg::getPlanId, ap.getId());
-            appPlanToExecOrgMapper.delete(apo);
-
-            //删除本尊
-            baseMapper.deleteById(ap.getId());
+        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)) {
+            //有已完成时,计划逻辑删除,删除当前轮次及之后未完成的任务
+            LambdaQueryWrapper<AppPlan> wrapper = new LambdaQueryWrapper<>();
+            wrapper.in(AppPlan::getId, plans.stream().map(AppPlan::getId).collect(Collectors.toList()));
+
+            baseMapper.delete(wrapper);
+            deleteTaskByPlanId(plans.stream().map(AppPlan::getSolidId).collect(Collectors.toList()));
+        } else {
+            //无已完成时,计划物理删除,删除所有任务
+
+
+            delete(plans.stream().map(AppPlan::getId).collect(Collectors.toList()));
+            deleteAllTaskByPlanId(plans.stream().map(AppPlan::getSolidId).collect(Collectors.toList()));
         }
+    }
 
-        //删除计划对应的任务
-        resumptionMapper.delete(new QueryWrapper<Resumption>().eq("plan_id", id));
+    private void delete(List<Long> planIds) {
+        if (ObjectUtil.isEmpty(planIds)) {
+            return;
+        }
         //删除对应的角色关系
         QueryWrapper<AppPlanToRole> qw = new QueryWrapper<>();
-        qw.lambda().eq(AppPlanToRole::getPlanId, id);
+        qw.lambda().in(AppPlanToRole::getPlanId, planIds);
         appPlanToRoleMapper.delete(qw);
 
         //删除对应的要点关系
         QueryWrapper<AppPlanToPoint> aw = new QueryWrapper<>();
-        aw.lambda().eq(AppPlanToPoint::getPlanId, id);
+        aw.lambda().in(AppPlanToPoint::getPlanId, planIds);
         appPlanToItemMapper.delete(aw);
 
         //删除机构关系
         QueryWrapper<AppPlanToExecOrg> apo = new QueryWrapper<>();
-        apo.lambda().eq(AppPlanToExecOrg::getPlanId, id);
+        apo.lambda().in(AppPlanToExecOrg::getPlanId, planIds);
         appPlanToExecOrgMapper.delete(apo);
 
-        //删除本尊
-        baseMapper.deleteById(id);
-
-
+        baseMapper.physicsDeleteById(planIds);
     }
 
-
     private AppPlanVo convertToAppPlanVo(AppPlan app) {
         AppPlanVo plan = new AppPlanVo();
         plan.setExecType(app.getExecType());
@@ -704,11 +844,10 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
         plan.setExecOrgType(app.getExecOrgType());
         plan.setDistributePlanStatus(app.getDistributePlanStatus());
         plan.setCount(app.getCount());
-        plan.setBuildTaskNow(app.getBuildTaskNow());
+//        plan.setBuildTaskNow(app.getBuildTaskNow());
         plan.setPlanCreateOrgId(app.getPlanCreateOrgId());
         plan.setPlanOfOrgId(app.getPlanOfOrgId());
         plan.setPlanOfOrgType(app.getPlanOfOrgType());
-        plan.setHasEdit(app.getTaskHasCompleted());
         return plan;
     }
 
@@ -741,7 +880,8 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 
         plan.setId(app.getId());
         plan.setNotResumptionOnRest(app.getNotResumptionOnRest());
-        plan.setBuildTaskNow(app.getBuildTaskNow());
+        plan.setPlanOfOrgType(app.getPlanOfOrgType());
+//        plan.setBuildTaskNow(app.getBuildTaskNow());
 
         return plan;
     }
@@ -784,7 +924,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 
         SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectOrgById(orgid, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
         String fileOrgName = registerBookPdfService.getFileOrgName(orgid);
-        String fileName = fileOrgName + "_" + RegisterBookType.SECURITY_PERFORMANCE.getText()+ "_"+ DateUtil.format(new Date(), "yyyyMMddHHmmss") + ".pdf";
+        String fileName = fileOrgName + "_" + RegisterBookType.SECURITY_PERFORMANCE.getText() + "_" + DateUtil.format(new Date(), "yyyyMMddHHmmss") + ".pdf";
         Map<String, Object> data = this.getFtlResumption(orgid);
         data.put("fileName", fileName);
         data.put("orgName", sysOrg.getShortName());
@@ -806,7 +946,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             registerBookPdf.setFileUrl(pdfUrl);
             //registerBookPdf.setFileName(StringUtils.substringAfterLast(pdfUrl, "\\"));
             registerBookPdf.setFileName(StringUtils.substringAfterLast(pdfUrl, File.separator));
-            if(StringUtils.isEmpty(registerBookPdf.getFileName())||StringUtils.isEmpty(pdfUrl)){
+            if (StringUtils.isEmpty(registerBookPdf.getFileName()) || StringUtils.isEmpty(pdfUrl)) {
                 throw new SystemException(ErrorMsgConstants.GENERATE_PDF_ERROR);
             }
             registerBookPdfService.save(registerBookPdf);
@@ -871,13 +1011,13 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 
     public List<ResumptionPdf> getResult(Map<Long, List<AppResumptionDataInfoVo>> bef) {
         List<ResumptionPdf> befs = new ArrayList<>();
-       // for (Long l :bef.keySet()) {
-        for(Map.Entry<Long, List<AppResumptionDataInfoVo>> map: bef.entrySet()){
+        // for (Long l :bef.keySet()) {
+        for (Map.Entry<Long, List<AppResumptionDataInfoVo>> map : bef.entrySet()) {
             String pointName = "";
             StringBuilder submitName = new StringBuilder();
             int result = 0;
-           // for (AppResumptionDataInfoVo vo :bef.get(l)) {
-            for (AppResumptionDataInfoVo vo :map.getValue()) {
+            // for (AppResumptionDataInfoVo vo :bef.get(l)) {
+            for (AppResumptionDataInfoVo vo : map.getValue()) {
                 pointName = vo.getPointName();
                 result += vo.getResValue();
                 submitName.append(vo.getSubmitName());

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

@@ -29,6 +29,11 @@ public class AppRulePointServiceImpl extends ServiceImpl<AppRulePointMapper, App
     }
 
     @Override
+    public Integer countPointByPlan(Long planid) {
+        return baseMapper.countPointByPlan(planid);
+    }
+
+    @Override
     public List<Map<String, Object>> findAreaListPlan(Long planid) {
         return baseMapper.findAreaListPlan(planid);
     }

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

@@ -158,6 +158,8 @@ public class ResumptionServiceImpl extends ServiceImpl<ResumptionMapper, Resumpt
             resumption.setYmdHalfyear(Long.valueOf(ymd.getHalfyear()));
             resumption.setParentPlanId((ObjectUtil.equal(appPlan.getParentId(), -1L) || ObjectUtil.isNull(appPlan.getParentId())) ? appPlan.getId() : appPlan.getParentId());
             resumption.setPlanId(appPlan.getId());
+            resumption.setSolidId(appPlan.getSolidId());
+            resumption.setParentSolidId((ObjectUtil.equal(appPlan.getParentSolidId(), -1L) || ObjectUtil.isNull(appPlan.getParentSolidId())) ? appPlan.getSolidId() : appPlan.getParentSolidId());
             resumption.setOrgId(orgId);
             resumption.setType(type.getValue());
             resumption.setRoleId(roleId);

+ 33 - 23
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/task/ResumptionTaskBusiness.java

@@ -14,7 +14,7 @@ import com.xunmei.common.core.domain.DateRange;
 import com.xunmei.common.core.domain.worktime.domain.SysWorkTime;
 import com.xunmei.common.core.enums.CycleCommonEnum;
 import com.xunmei.common.core.enums.ExecTimeCommonEnum;
-import com.xunmei.common.core.enums.OrgTypeEnum;
+import com.xunmei.common.core.enums.resumption.ResumptionTaskStatus;
 import com.xunmei.common.core.utils.DateUtils;
 import com.xunmei.common.core.utils.StringUtils;
 import com.xunmei.common.core.utils.Ymd;
@@ -23,7 +23,6 @@ import com.xunmei.core.resumption.domain.AppPlan;
 import com.xunmei.core.resumption.domain.Resumption;
 import com.xunmei.core.resumption.mapper.AppPlanMapper;
 import com.xunmei.core.resumption.mapper.ResumptionMapper;
-import com.xunmei.core.resumption.service.AppPlanService;
 import com.xunmei.core.resumption.service.IAppRulePointService;
 import com.xunmei.core.resumption.service.ResumptionService;
 import com.xunmei.core.resumption.vo.AppRulePointTaskVo;
@@ -42,7 +41,8 @@ import java.util.stream.Collectors;
 
 @Component
 @Slf4j
-public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<ResumptionMapper, Resumption> {
+public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<ResumptionMapper, Resumption>
+        implements ResumptionTaskBusinessService {
     @Autowired
     private AppPlanMapper appPlanMapper;
 
@@ -53,9 +53,6 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
     private IAppRulePointService appRulePointService;
 
     @Autowired
-    private AppPlanService appPlanService;
-
-    @Autowired
     private ResumptionService resumptionService;
 
     /**
@@ -98,14 +95,14 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
                 continue;
             }
             //获取履职计划中对应的检查要点
-            List<AppRulePointTaskVo> pointList = appRulePointService.findPointByPlan(appPlan.getId());
-            if (pointList.size() <= 0) {//没有检查项不生成履职任务
+            Integer pointCount = appRulePointService.countPointByPlan(appPlan.getId());
+            if (ObjectUtil.equal(pointCount, 0)) {//没有检查项不生成履职任务
                 log.info("error:该计划ID:" + appPlan.getId() + "没有检查项");
                 continue;
             }
 
             //获取履职角色
-            List<Long> roleIds = appPlanService.findRoleByPlan(appPlan.getId());
+            List<Long> roleIds = appPlanMapper.findRoleByPlan(appPlan.getId());
             if (CollectionUtils.isEmpty(roleIds)) {//没有检查项不生成履职任务
                 log.info("error:该计划ID:{}没有履职角色", appPlan.getId());
                 continue;
@@ -121,12 +118,15 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
             DateRange range = DateUtils.getStartAndEnd(date, cycleCommonEnum);
             Map<Long, List<SysWorkTime>> workTimes = orgDutyOrWorkTimes(new Date(), cycleCommonEnum, orgs.stream().map(SysOrg::getId).collect(Collectors.toList()));
 
+            List<Resumption> existTasks = queryTask(range.getStartTime(), range.getEndTime(), CycleCommonEnum.getEnum(appPlan.getPlanCycle()), execOrgIds, Arrays.asList(appPlan.getSolidId()));
+
             for (SysOrg org : orgs) {
                 List<Resumption> tasks;
+                List<Short> executedTimes = existTasks.stream().filter(t -> ObjectUtil.equal(t.getOrgId(), org.getId())).map(t -> t.getTimes()).collect(Collectors.toList());
                 if (ObjectUtil.equal(CycleCommonEnum.DAILY.getCode(), appPlan.getPlanCycle())) {
-                    tasks = buildResumptions(appPlan, org, null, new Date(), workTimes);
+                    tasks = buildResumptions(appPlan, org, executedTimes, new Date(), workTimes);
                 } else {
-                    tasks = buildResumptions(appPlan, org, range.getStartTime(), range.getEndTime(), null, workTimes);
+                    tasks = buildResumptions(appPlan, org, range.getStartTime(), range.getEndTime(), executedTimes, workTimes);
                 }
 
                 if (CollectionUtils.isNotEmpty(tasks)) {
@@ -161,7 +161,7 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
         }
         List<Long> hsOrgIds = getHangsheOrgIds();
         Set<Long> sOrgIds = new HashSet<>();
-        if(ObjectUtil.isNotEmpty(hsOrgIds)){
+        if (ObjectUtil.isNotEmpty(hsOrgIds)) {
             sOrgIds.addAll(hsOrgIds);
         }
         List<AppPlan> appPlans = new ArrayList<>();
@@ -174,10 +174,12 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
             if (!sOrgIds.contains(p.getPlanOfOrgId())) {
                 continue;
             }
-            if (ObjectUtil.equal(p.getTaskHasCompleted(), 1)) {
+//            if (ObjectUtil.equal(p.getTaskHasCompleted(), 1)) {
+//                continue;
+//            }
+            if (ObjectUtil.isNull(p.getPlanStatus()) || ObjectUtil.equal(p.getPlanStatus(), 0)) {
                 continue;
             }
-
             appPlans.add(p);
         }
 
@@ -185,14 +187,19 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
             return;
         }
 
-
-        //删除没有已完成计划下的所有任务
+        //删除本周期未完成任务
+        Date workDate = new Date();
+        DateRange dr = DateUtils.getStartAndEnd(workDate, appPlans.stream().findFirst().get().getPlanCycle());
         LambdaUpdateWrapper<Resumption> wrapper = new LambdaUpdateWrapper<>();
-        wrapper.in(Resumption::getPlanId, appPlans.stream().map(p -> p.getId()).collect(Collectors.toList()));
+        wrapper.ge(Resumption::getYmdDate, dr.getStartTime())
+                .le(Resumption::getYmdDate, dr.getEndTime())
+                .ne(Resumption::getStatus, ResumptionTaskStatus.Completed.getCode())
+                .in(Resumption::getSolidId, appPlans.stream().map(p -> p.getSolidId()).collect(Collectors.toList()));
         baseMapper.delete(wrapper);
 
+
 //        AppPlan plan = appPlans.get(0);
-        Date workDate = new Date();
+
 //        CycleCommonEnum cycle = CycleCommonEnum.getEnum(plan.getPlanCycle());
 //        DateRange range = DateUtils.getStartAndEnd(workDate, cycle);
 
@@ -204,6 +211,7 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
 //            baseMapper.deleteBatchIds(deleteIds);
 //        }
 
+
         buildTask(null, appPlans, workDate);
     }
 
@@ -341,7 +349,7 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
 //                List<AppPlanToRole> planToRoles = appPlanToRoles.stream().filter(item -> item.getPlanId().equals(plan.getId())).collect(Collectors.toList());
 
                 List<Short> executedOrders = executedResumptionList.stream()
-                        .filter(r -> ObjectUtil.equal(r.getOrgId(), orgId) && ObjectUtil.equal(r.getPlanId(), plan.getId()))
+                        .filter(r -> ObjectUtil.equal(r.getOrgId(), orgId) && ObjectUtil.equal(r.getSolidId(), plan.getSolidId()))
                         .map(Resumption::getTimes)
                         .collect(Collectors.toList());
 
@@ -513,7 +521,7 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
 
         short realOrder = 0;
         Set<Short> ex = new HashSet<>();
-        if(ObjectUtil.isNotEmpty(executedOrders)){
+        if (ObjectUtil.isNotEmpty(executedOrders)) {
             ex.addAll(executedOrders);
         }
         for (Short i = 1; i <= count; i++) {
@@ -543,6 +551,8 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
             resumption.setYmdHalfyear(Long.valueOf(ymd.getHalfyear()));
             resumption.setParentPlanId((ObjectUtil.equal(appPlan.getParentId(), -1L) || ObjectUtil.isNull(appPlan.getParentId())) ? appPlan.getId() : appPlan.getParentId());
             resumption.setPlanId(appPlan.getId());
+            resumption.setSolidId(appPlan.getSolidId());
+            resumption.setParentSolidId((ObjectUtil.equal(appPlan.getParentSolidId(), -1L) || ObjectUtil.isNull(appPlan.getParentSolidId())) ? appPlan.getSolidId() : appPlan.getParentSolidId());
             resumption.setOrgId(execOrg.getId());
             resumption.setOrgPath(execOrg.getPath());
             resumption.setOrgName(execOrg.getShortName());
@@ -557,7 +567,7 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
         return resumptionList;
     }
 
-    private List<Resumption> queryTask(Date startDate, Date endDate, CycleCommonEnum cycle, List<Long> orgIds, List<Long> planIds) {
+    private List<Resumption> queryTask(Date startDate, Date endDate, CycleCommonEnum cycle, List<Long> orgIds, List<Long> planSolidIds) {
         QueryWrapper<Resumption> queryWrapper = new QueryWrapper<>();
         Date start = DateUtil.beginOfDay(startDate);
         Date end = DateUtil.endOfDay(endDate);
@@ -566,8 +576,8 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
         if (CollectionUtils.isNotEmpty(orgIds)) {
             queryWrapper.lambda().in(Resumption::getOrgId, orgIds);
         }
-        if (CollectionUtils.isNotEmpty(planIds)) {
-            queryWrapper.lambda().in(Resumption::getPlanId, planIds);
+        if (CollectionUtils.isNotEmpty(planSolidIds)) {
+            queryWrapper.lambda().in(Resumption::getSolidId, planSolidIds);
         }
         queryWrapper.lambda().eq(Resumption::getType, cycle.getCode());
 

+ 7 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/task/ResumptionTaskBusinessService.java

@@ -0,0 +1,7 @@
+package com.xunmei.core.resumption.task;
+
+import java.util.List;
+
+public interface ResumptionTaskBusinessService {
+    void rebuildCurrentCycleTask(List<Object> plans);
+}

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

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.xunmei.common.core.web.domain.PageDto;
 import com.xunmei.core.resumption.domain.AppPlan;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -23,9 +24,11 @@ public class AppPlanVo extends PageDto<AppPlan> {
     private Integer parentCount;
     private List<Long> ids;
     private Long id;
-    private Integer buildTaskNow;
-    //涉及编辑内容
-    private Integer hasEdit;
+    //    private Integer buildTaskNow;
+//    //涉及编辑内容
+//    private Integer hasEdit;
+    @ApiModelProperty(value = "1:表示有已完成的任务")
+    private Integer taskHasCompleted;
     /**
      * 计划名称
      */

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

@@ -129,6 +129,8 @@ public class ResumptionPlanPageVo {
     @TableField(exist = false)
     private String orgId;
 
+    @ApiModelProperty(value = "1:表示有已完成的任务")
+    private Integer taskHasCompleted;
 
 //    private List<ResumptionPlanPageVo> children;
 }

+ 2 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/safetybook/service/impl/CoreSafetyBookNewServiceImpl.java

@@ -92,6 +92,8 @@ public class CoreSafetyBookNewServiceImpl extends ServiceImpl<CoreSafetyBookNewM
     @Override
     public CoreSafetyBookNew selectCoreSafetyBookNewById(Long id) {
         CoreSafetyBookNew coreSafetyBookNew = coreSafetyBookNewMapper.selectSafetyBookById(id);
+        coreSafetyBookNew.setPartyAOrgName(!coreSafetyBookNew.getType().equals(2L) ? coreSafetyBookNew.getPartyAOrgName() : orgService.selectOrgById(coreSafetyBookNew.getPartyAOrg(), SecurityConstants.INNER).getShortName());
+        coreSafetyBookNew.setPartyBOrgName(!coreSafetyBookNew.getType().equals(2L) ? orgService.selectOrgById(coreSafetyBookNew.getPartyBOrg(), SecurityConstants.INNER).getShortName():coreSafetyBookNew.getPartyBOrgName());
         coreSafetyBookNew.setFiles(coreSafetyBookBookFilesMapper.selecVotList(id));
         return coreSafetyBookNew;
     }

+ 106 - 4
soc-modules/soc-modules-core/src/main/resources/mapper/resumption/AppPlanMapper.xml

@@ -421,16 +421,118 @@
               from core_resumption_plan_to_point a
                        LEFT JOIN core_resumption_rule_point b on a.point_id = b.id
                        LEFT JOIN core_resumption_rule_item c on b.item_id = c.id
-              where a.plan_id = #{planId}
-                and a.effective_date &lt; #{startDate}) q
+              where a.plan_id = #{planId}) q
                  LEFT JOIN sys_area w on q.area_id = w.id
     </select>
     <update id="updateParentPlanCompletedState">
         UPDATE core_resumption_plan
-        SET task_has_completed = (SELECT c
+        SET task_has_completed = (SELECT if(c>0,1,0)
                                   from (SELECT count(0) as c
                                         from core_resumption_plan
-                                        WHERE parent_id = #{planId} and task_has_completed = 1) a)
+                                        WHERE parent_id = #{planId}
+                                          and task_has_completed = 1) a)
         WHERE id = #{planId}
     </update>
+
+    <insert id="copySelf">
+        INSERT INTO core_resumption_plan
+        SELECT #{newPlanId},
+               `parent_id`,
+               `solid_id`,
+               `parent_solid_id`,
+               `plan_name`,
+               `plan_type`,
+               `plan_cycle`,
+               `plan_exec`,
+               `exec_org_type`,
+               `exec_type`,
+               `plan_status`,
+               `not_resumption_on_rest`,
+               `description`,
+               `create_time`,
+               `modified_name`,
+               `update_time`,
+               `modified_by`,
+               `plan_create_org_id`,
+               `plan_of_org_id`,
+               `count`,
+               `distribute_status`,
+               `check_org_type`,
+               `check_type`,
+               `distribute_plan_status`,
+               0,
+               `distribute`,
+               `build_task_now`,
+               `plan_of_org_type`,
+               `pdf_url`,
+               `task_has_completed`
+        FROM core_resumption_plan
+        WHERE id = #{planId}
+    </insert>
+    <insert id="copyChildren">
+        INSERT INTO core_resumption_plan
+        SELECT #{newPlanId},
+               #{newParentId},
+               `solid_id`,
+               `parent_solid_id`,
+               `plan_name`,
+               `plan_type`,
+               `plan_cycle`,
+               `plan_exec`,
+               `exec_org_type`,
+               `exec_type`,
+               `plan_status`,
+               `not_resumption_on_rest`,
+               `description`,
+               `create_time`,
+               `modified_name`,
+               `update_time`,
+               `modified_by`,
+               `plan_create_org_id`,
+               `plan_of_org_id`,
+               `count`,
+               `distribute_status`,
+               `check_org_type`,
+               `check_type`,
+               `distribute_plan_status`,
+               0,
+               `distribute`,
+               `build_task_now`,
+               `plan_of_org_type`,
+               `pdf_url`,
+               `task_has_completed`
+        FROM core_resumption_plan
+        WHERE id = #{planId}
+    </insert>
+
+    <insert id="copyPlanPoints">
+        INSERT INTO core_resumption_plan_to_point
+        SELECT #{newPlanId},
+               `point_id`,
+               `point_scan`,
+               `required`,
+               `of_org_id`
+        FROM core_resumption_plan_to_point
+        WHERE plan_id =#{planId}
+    </insert>
+    <insert id="copyPlanRoles">
+        INSERT INTO core_resumption_plan_to_role
+        SELECT #{newPlanId},
+               `role_id`
+        FROM core_resumption_plan_to_role
+        WHERE plan_id =#{planId}
+    </insert>
+    <insert id="copyPlanOrgs">
+        INSERT INTO core_resumption_plan_to_exec_org
+        SELECT #{newPlanId},
+               `org_id`
+        FROM core_resumption_plan_to_exec_org
+        WHERE plan_id =#{planId}
+    </insert>
+    <delete id="physicsDeleteById">
+        delete  from core_resumption_plan where id  in
+        <foreach collection="ids" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>;
+    </delete>
 </mapper>

+ 7 - 0
soc-modules/soc-modules-core/src/main/resources/mapper/resumption/AppRulePointMapper.xml

@@ -59,6 +59,13 @@
                  LEFT JOIN core_resumption_plan c ON b.plan_id = c.id
         WHERE c.id = #{planid}
     </select>
+    <select id="countPointByPlan" parameterType="Long" resultType="Integer">
+        SELECT count(0)
+        from core_resumption_rule_point a
+                 LEFT JOIN core_resumption_plan_to_point b ON a.id = b.point_id
+                 LEFT JOIN core_resumption_plan c ON b.plan_id = c.id
+        WHERE c.id = #{planid}
+    </select>
     <select id="selectPointListByIdList" resultType="com.xunmei.core.resumption.dto.rulePoint.AppRulePointInfoDto"
             parameterType="java.util.List">
         select

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

@@ -492,4 +492,7 @@
     <insert id="batchInsertResumptionNfc" parameterType="java.util.List">
 
     </insert>
+    <update id="updatePlanId">
+        update core_resumption set parent_plan_id=#{newPlanParentId},plan_id=#{newPlanId} where plan_id=#{oldPlanId} and (status=0 or status=1)
+    </update>
 </mapper>

+ 4 - 4
soc-modules/soc-modules-file/src/main/java/com/xunmei/file/utils/PdfUtil.java

@@ -499,11 +499,11 @@ public class PdfUtil {
 //        List<Object> dataList = (List<Object>) data.get("content");
         for (int i = 1; i <= data.size(); i++) {
             PdfUtil.createPDFCell(tableFont, table, String.valueOf(i), Element.ALIGN_MIDDLE, 2, 0, 10);
-            PdfUtil.createPDFCell(tableFont, table, data.get(i - 1).getItemName(), Element.ALIGN_LEFT, 5, 0, 10);
-            PdfUtil.createPDFCell(tableFont, table, data.get(i - 1).getPointName(), Element.ALIGN_LEFT, 17, 0, 10);
+            PdfUtil.createPDFCell(tableFont, table, data.get(i - 1).getItemName(), Element.ALIGN_MIDDLE, 5, 0, 10);
+            PdfUtil.createPDFCell(tableFont, table, data.get(i - 1).getPointName(), Element.ALIGN_MIDDLE, 17, 0, 10);
             PdfUtil.createPDFCell(tableFont, table, StringUtils.isEmpty(data.get(i - 1).getResRemark()) ? "√" : "×", Element.ALIGN_MIDDLE, 5, 0, 10);
-            PdfUtil.createPDFCell(tableFont, table, StringUtils.isEmpty(data.get(i - 1).getResRemark()) ? "" : data.get(i - 1).getResRemark(), Element.ALIGN_LEFT, 15, 0, 10);
-            PdfUtil.createPDFCell(tableFont, table, data.get(i - 1).getRectificationDeadline(), Element.ALIGN_MIDDLE, 2, 0, 25);
+            PdfUtil.createPDFCell(tableFont, table, StringUtils.isEmpty(data.get(i - 1).getResRemark()) ? "" : data.get(i - 1).getResRemark(), Element.ALIGN_MIDDLE, 15, 0, 10);
+            PdfUtil.createPDFCell(tableFont, table, data.get(i - 1).getRectificationDeadline(), Element.ALIGN_MIDDLE, 2, 0, 10);
         }
         document.add(table);
     }