luojun před 2 roky
rodič
revize
33b47795f1

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

@@ -1052,6 +1052,14 @@ END IF;
         ALTER TABLE `core_resumption_plan` ADD COLUMN `distribute` VARCHAR ( 2 ) DEFAULT NULL COMMENT '是否已下发';
 
     END IF;
+
+    -- 履职计划立即生效标识
+    IF
+        NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'core_resumption_plan' AND COLUMN_NAME = 'build_task_now' ) THEN
+        ALTER TABLE `core_resumption_plan` ADD COLUMN `build_task_now` VARCHAR ( 2 ) DEFAULT NULL COMMENT '立即生效';
+
+    END IF;
+
 	-- 履职任务NFC表增加submitby
     IF
         NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'core_resumption_data_nfc' AND COLUMN_NAME = 'submit_by' ) THEN

+ 33 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/controller/ApiPlanController.java

@@ -60,11 +60,44 @@ public class ApiPlanController {
         return TableDataInfo.success(appPlanService.selectPage(info));
     }
 
+    /**
+     * 下发
+     * @param dto
+     * @return
+     */
     @PostMapping("/distribute")
     @RequiresPermissions("core:plan:distribute")
     public AjaxResult distribute(@RequestBody DistributeDto dto) {
         try {
             appPlanService.distributeToOrg(dto);
+            AppPlanVo plan = appPlanService.findById(dto.getId());
+            //如果选择了计划立即生效
+            if (plan.isBuildTaskNow()) {
+                DateTime datetime = new DateTime();
+                datetime.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+                //当有周期存在时保持原有接口不变(doTask),否则按照新的接口创建
+                Integer plancycle = plan.getPlanCycle();
+                if (plancycle != null) {
+                    if (plancycle == 2) {
+                        taskBusiness.syncDay(datetime, plancycle);
+                    }
+                    if (plancycle == 3) {
+                        taskBusiness.syncWeek(datetime, plancycle);
+                    }
+                    if (plancycle == 4) {
+                        taskBusiness.syncMonth(datetime, plancycle);
+                    }
+                    if (plancycle == 5) {
+                        taskBusiness.syncQuarter(datetime, plancycle);
+                    }
+                    if (plancycle == 6) {
+                        taskBusiness.syncHalfYear(datetime, plancycle);
+                    }
+                    if (plancycle == 7) {
+                        taskBusiness.syncYear(datetime, plancycle);
+                    }
+                }
+            }
             return AjaxResult.success();
         } catch (Exception e) {
             e.printStackTrace();

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

@@ -158,7 +158,7 @@ public class AppPlan extends Model<AppPlan> implements Serializable {
 
     @TableField(exist = false)
     private String orgId;
-
+    private boolean buildTaskNow;
 
     @TableLogic(value = "0", delval = "1")
     @ApiModelProperty(value = "是否删除 1是 0否")

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

@@ -285,6 +285,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             } else {
                 plan.setPlanStatus(0);
             }
+            plan.setBuildTaskNow(app.isBuildTaskNow());
             plan.setDistribute("0");
             baseMapper.insert(plan);
             Long id = plan.getId();

+ 2 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/safetyCheck/job/SafetyCheckJobBusiness.java

@@ -23,6 +23,7 @@ import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.domain.SysOrg;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -99,6 +100,7 @@ public class SafetyCheckJobBusiness {
      * @param end
      * @throws Exception
      */
+    @Async
     public void createTask(Date dateTime, int planCycle, Date start, Date end) throws Exception {
         QueryWrapper<CoreSafecheckPlan> qw = new QueryWrapper<>();
         qw.lambda().eq(CoreSafecheckPlan::getPlanCycle, planCycle);