Browse Source

Merge remote-tracking branch 'origin/V0.0.2' into V0.0.2

jingyuanchao 2 years ago
parent
commit
da4e8d6892

+ 4 - 3
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteRetrievalTaskService.java

@@ -6,9 +6,7 @@ import com.xunmei.common.core.domain.R;
 import com.xunmei.common.core.web.domain.AjaxResult;
 import com.xunmei.system.api.factory.RemoteRetrievalTaskFallbackFactory;
 import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
 
 import java.time.LocalDate;
 
@@ -59,4 +57,7 @@ public interface RemoteRetrievalTaskService {
 
     @GetMapping("/retrievalTask/initializationAccessTask")
     AjaxResult initializationAccessTask(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
+    @PostMapping("/retrievalTask/rebuildTask")
+    AjaxResult rebuild(@RequestBody String event, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
 }

+ 5 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/factory/RemoteRetrievalTaskFallbackFactory.java

@@ -50,6 +50,11 @@ public class RemoteRetrievalTaskFallbackFactory implements FallbackFactory<Remot
             public AjaxResult initializationAccessTask(String source) {
                 return AjaxResult.error("初始化未完成任务的状态为未调阅服务调用失败,失败原因:" + throwable.getMessage());
             }
+
+            @Override
+            public AjaxResult rebuild(String event, String source) {
+                return AjaxResult.error("根据作息变更修改调阅任务识别,失败原因:" + throwable.getMessage());
+            }
         };
     }
 }

+ 100 - 83
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/controller/ApiPlanController.java

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

+ 12 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/retrieval/controller/CoreMonitoringRetrievalTaskController.java

@@ -1,5 +1,7 @@
 package com.xunmei.core.retrieval.controller;
 
+import com.alibaba.nacos.shaded.com.google.gson.Gson;
+import com.xunmei.common.core.event.WorkTimeChangeEvent;
 import com.xunmei.common.core.web.controller.BaseController;
 import com.xunmei.common.core.web.domain.AjaxResult;
 import com.xunmei.common.core.web.page.TableDataInfo;
@@ -169,6 +171,16 @@ public class CoreMonitoringRetrievalTaskController extends BaseController {
             return AjaxResult.error("修改任务状态失败" + e.getMessage());
         }
     }
+    @InnerAuth
+    @PostMapping("/rebuildTask")
+    public AjaxResult rebuildTask(@RequestBody String event) {
+        try {
+            coreMonitoringRetrievalTaskService.taskChangeForTimeWorkChange(new Gson().fromJson(event, WorkTimeChangeEvent.class));
+            return AjaxResult.success("变更任务成功");
+        } catch (Exception e) {
+            return AjaxResult.error("变更任务失败" + e.getMessage());
+        }
+    }
 
     /**
      * 初始化当天未完成任务

+ 4 - 5
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/retrieval/service/impl/CoreMonitoringRetrievalTaskServiceImpl.java

@@ -105,7 +105,6 @@ public class CoreMonitoringRetrievalTaskServiceImpl extends ServiceImpl<CoreMoni
         }
         //获取数据
         page = coreMonitoringRetrievalTaskMapper.selectPageList(page, request);
-        this.taskChangeForTimeWorkChange(null);
         //抓换为TableDataInfo适配前端
         return TableDataInfo.build(page);
     }
@@ -606,7 +605,7 @@ public class CoreMonitoringRetrievalTaskServiceImpl extends ServiceImpl<CoreMoni
     @Transactional(rollbackFor = Exception.class)
    public void taskChangeForTimeWorkChange(WorkTimeChangeEvent event) {
         //修改的作息的日期
-        Date ymdDate  =  event.getDataList().get(0).getDate();
+        Date ymdDate  =  event.getDataList().get(0).getYmdDate();
 
         //受影响的机构
         List<Long> orgIds = event.getOrgIds();
@@ -689,7 +688,7 @@ public class CoreMonitoringRetrievalTaskServiceImpl extends ServiceImpl<CoreMoni
         queryWrapper.lambda().in(TMonitoringRetrievalPlan::getOrgId, orgParentIds);
         queryWrapper.lambda().eq(TMonitoringRetrievalPlan::getPlanStatus, 1);
         queryWrapper.lambda().eq(TMonitoringRetrievalPlan::getIsDeleted, 0);
-        /*queryWrapper.lambda().eq(TMonitoringRetrievalPlan::getCreateType, 1);*/
+        queryWrapper.lambda().eq(TMonitoringRetrievalPlan::getCreateType, 1);
         List<TMonitoringRetrievalPlan> plans = itMonitoringRetrievalPlanService.list(queryWrapper);
         List<TMonitoringRetrievalPlan> planList = new ArrayList<>();
 
@@ -701,8 +700,8 @@ public class CoreMonitoringRetrievalTaskServiceImpl extends ServiceImpl<CoreMoni
                         continue;
                     }
                 }
-                //计划的机构id不是当前机构的直属父机构,不生成任务
-                if(!p.getOrgId().equals(s.getParentId())){
+                //计划的机构id不是当前机构的直属父机构,不生成任务,计划的机构类型不是当前机构的机构类型不生成任务
+                if(!p.getOrgId().equals(s.getParentId())||!p.getOrgType().equals(s.getOrgType())){
                     continue;
                 }
                 TMonitoringRetrievalPlan plan = new TMonitoringRetrievalPlan();

+ 4 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/listener/WorkTimeChangeEventListener.java

@@ -5,6 +5,7 @@ import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.event.WorkTimeChangeEvent;
 import com.xunmei.system.api.RemoteEduTrainingService;
 import com.xunmei.system.api.RemoteResumptionTaskService;
+import com.xunmei.system.api.RemoteRetrievalTaskService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationListener;
@@ -23,6 +24,8 @@ public class WorkTimeChangeEventListener implements ApplicationListener<WorkTime
     RemoteResumptionTaskService remoteResumptionTaskService;
     @Autowired
     RemoteEduTrainingService eduTrainingService;
+    @Autowired
+    RemoteRetrievalTaskService remoteRetrievalTaskService;
     @Override
     @EventListener(WorkTimeChangeEvent.class)
     @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = false)
@@ -30,6 +33,7 @@ public class WorkTimeChangeEventListener implements ApplicationListener<WorkTime
 
         //remoteResumptionTaskService.rebuild(JSON.toJSONString(event), SecurityConstants.INNER);
         eduTrainingService.rebuild(JSON.toJSONString(event), SecurityConstants.INNER);
+        remoteRetrievalTaskService.rebuild(JSON.toJSONString(event), SecurityConstants.INNER);
 
     }
 }