浏览代码

调整计划

luojun 2 年之前
父节点
当前提交
14c03d91a3

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

@@ -146,14 +146,14 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                     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);
+                if (tempplan != null) {
+                    tempplan.setPlanStatus(d.getStatus() > 0 ? 1 : 2);
                     tempplan.setDistributePlanStatus(d.getStatus().toString());
                     tempplan.setDistributeStatus("1");
                     baseMapper.updateById(tempplan);
-                }else {
+                } else {
                     AppPlan plan = baseMapper.selectById(dto.getId());
                     plan.setOrgId(d.getOrgId().toString());
                     plan.setDistributeStatus("1");
@@ -234,7 +234,13 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
         AppPlan plan = baseMapper.selectById(id);
         //设置计划状态
         plan.setPlanStatus(1);
-
+        //如果是行社撤回需要修改下发状态
+        //行社下发
+        if (plan.getPlanOfOrgType() == 3 && plan.getDistribute().equals("0")) {
+            plan.setDistribute("1");
+        } else {
+            plan.setDistribute("0");
+        }
         baseMapper.updateById(plan);
         return 1;
     }
@@ -359,7 +365,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                 }
 
                 QueryWrapper<AppPlanToPoint> api = new QueryWrapper<>();
-                api.lambda().eq(AppPlanToPoint::getPlanId, ap.getId()).eq(AppPlanToPoint::getOfOrgId,app.getPlanCreateOrgId());
+                api.lambda().eq(AppPlanToPoint::getPlanId, ap.getId()).eq(AppPlanToPoint::getOfOrgId, app.getPlanCreateOrgId());
                 appPlanToItemMapper.delete(api);
 
                 List<Long> roleList = app.getRoleList();
@@ -373,7 +379,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 
 
                 List<RuleItemVo> valitemList = app.getItemList();
-                List<RuleItemVo> itemList = valitemList.stream().filter(e-> e.getOfOrgId().equals(app.getPlanCreateOrgId())).collect(Collectors.toList());
+                List<RuleItemVo> itemList = valitemList.stream().filter(e -> e.getOfOrgId().equals(app.getPlanCreateOrgId())).collect(Collectors.toList());
 
                 if (valitemList.size() == 0) {
                     throw new RuntimeException("请选择履职要点");
@@ -391,9 +397,9 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                 //如果计划是编辑全部,代表不存在已完成或者逾期的任务,需要删除重新生成
                 if (app.getHasEdit() == null) {
                     resumptionMapper.delete(new LambdaQueryWrapper<Resumption>().eq(Resumption::getPlanId, ap.getId()));
-                }else {
+                } else {
                     //否则代表编辑名称,需要同步未进行的任务名称
-                    resumptionMapper.updateNameByPlanId(app.getPlanName(),ap.getId());
+                    resumptionMapper.updateNameByPlanId(app.getPlanName(), ap.getId());
                 }
 
             }
@@ -409,7 +415,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 
 
             QueryWrapper<AppPlanToPoint> api = new QueryWrapper<>();
-            api.lambda().eq(AppPlanToPoint::getPlanId, id).eq(AppPlanToPoint::getOfOrgId,app.getPlanCreateOrgId());
+            api.lambda().eq(AppPlanToPoint::getPlanId, id).eq(AppPlanToPoint::getOfOrgId, app.getPlanCreateOrgId());
             appPlanToItemMapper.delete(api);
 
 
@@ -429,7 +435,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             }
 
             List<RuleItemVo> valitemList = app.getItemList();
-            List<RuleItemVo> itemList = valitemList.stream().filter(e-> e.getOfOrgId().equals(app.getPlanCreateOrgId())).collect(Collectors.toList());
+            List<RuleItemVo> itemList = valitemList.stream().filter(e -> e.getOfOrgId().equals(app.getPlanCreateOrgId())).collect(Collectors.toList());
 
             if (valitemList.size() == 0) {
                 throw new RuntimeException("请选择履职要点");
@@ -549,7 +555,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
         /**
          * 验证计划是否被应用
          */
-        Long num = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", id).in("status", 3,4));
+        Long num = resumptionMapper.selectCount(new QueryWrapper<Resumption>().eq("plan_id", id).in("status", 3, 4));
         if (num > 0) {
             throw new RuntimeException("计划有已完成或者已逾期的任务,不能被删除。");
         }

+ 27 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/safetyCheck/job/SafetyCheckJobBusiness.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.utils.DateHelper;
 import com.xunmei.common.core.utils.IDHelper;
+import com.xunmei.core.retrieval.service.ICoreMonitoringRetrievalTaskService;
 import com.xunmei.core.safetyCheck.domain.*;
 import com.xunmei.core.safetyCheck.domain.CoreSafecheckPlan;
 import com.xunmei.core.safetyCheck.dto.SafetyTaskBuildDto;
@@ -20,6 +21,7 @@ import com.xunmei.core.safetyCheck.mapper.CoreSafecheckPlanToRoleMapper;
 import com.xunmei.core.safetyCheck.service.ICoreSafetyTaskService;
 import com.xunmei.core.safetyCheck.vo.PlanTaskBuildVo;
 import com.xunmei.system.api.RemoteOrgService;
+import com.xunmei.system.api.RemoteWorkTimeService;
 import com.xunmei.system.api.domain.SysOrg;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -55,7 +57,8 @@ public class SafetyCheckJobBusiness {
     CoreSafecheckPlanToRoleMapper planToRoleMapper;
     @Autowired
     private RemoteOrgService orgService;
-
+    @Autowired
+    RemoteWorkTimeService workTimeService;
 
     @Transactional(rollbackFor = Exception.class)
     public void createTaskForNow(Long planId, Date start, Date end, Boolean isNeedSendTodo, Integer sourceType) throws Exception {
@@ -90,6 +93,19 @@ public class SafetyCheckJobBusiness {
         buildTask(dateTime, planTask, start, end, isNeedSendTodo, sourceType);
     }
 
+//检查指定机构有无作息
+    private boolean checkWorkTime(Date workstartTime, Date workendTime,Long orgId){
+        Map<String,Object> map = new HashMap<>();
+        map.put("workstartTime",DateUtil.format(workstartTime,"yyyy-MM-dd"));
+        map.put("workendTime",DateUtil.format(workendTime,"yyyy-MM-dd"));
+        map.put("orgId",orgId);
+        Integer num = workTimeService.checkWorkTime(map,SecurityConstants.INNER);
+        if(num>0){
+            return true;
+        }else {
+            return  false;
+        }
+    }
 
     /**
      * 有周期计划生成任务
@@ -107,6 +123,16 @@ public class SafetyCheckJobBusiness {
         qw.lambda().eq(CoreSafecheckPlan::getIsDeleted, 0);
         qw.lambda().eq(CoreSafecheckPlan::getPlanStatus, 1);
         List<CoreSafecheckPlan> plans = planMapper.selectByCycle((long) planCycle);
+
+        //检查计划所属机构是否存在当前周期内的作息
+        Iterator<CoreSafecheckPlan> iterator = plans.iterator();
+        while (iterator.hasNext()){
+            boolean hasWorkTime = checkWorkTime(start, end, iterator.next().getPlanOfOrgId());
+            if (!hasWorkTime){
+                iterator.remove();
+            }
+        }
+
         List<PlanTaskBuildVo> tasks = new ArrayList<>();
         for (CoreSafecheckPlan plan : plans) {
             List<PlanTaskBuildVo> planTask = createPlanTask(plan);

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

@@ -287,6 +287,11 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
             coreSafecheckPlan.setDistribute("0");
             //计划所属机构类型
             coreSafecheckPlan.setPlanOfOrgType(orgService.selectSysOrgById(coreSafecheckPlan.getPlanOfOrgId(), SecurityConstants.INNER).getType());
+            if (coreSafecheckPlan.getPlanOfOrgType()==3){
+                coreSafecheckPlan.setPlanStatus(1L);
+            }else{
+                coreSafecheckPlan.setPlanStatus(0L);
+            }
             coreSafecheckPlanMapper.insert(coreSafecheckPlan);
 
         } else {