Pārlūkot izejas kodu

修复履职、安全检查缺陷

jiawuxian 1 gadu atpakaļ
vecāks
revīzija
9c0b17a8bb

+ 3 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/registerbook/service/impl/CoreRegisterBookPdfServiceImpl.java

@@ -288,6 +288,9 @@ public class CoreRegisterBookPdfServiceImpl extends ServiceImpl<CoreRegisterBook
     @Override
     public Integer deleteWithFile(Long id) {
         final CoreRegisterBookPdf record = getById(id);
+        if(ObjectUtil.isNull(record)){
+            return 0;
+        }
         final String fileUrl = record.getFileUrl();
         if (ObjectUtil.isNotEmpty(fileUrl)){
             String localPathPrefix = fileService.getLocalPathPrefix().getData();

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

@@ -19,6 +19,7 @@ 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;
@@ -99,6 +100,9 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
     @Autowired
     ResumptionTaskBusinessService resumptionTaskBusiness;
 
+    @Autowired
+    ICoreRegisterBookPdfService coreRegisterBookPdfService;
+
     @Override
     public List<Long> selectItemIdsByPlanId(Long id) {
         return appPlanToItemMapper.selectItemIdsByPlanId(id);
@@ -191,7 +195,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
                 } else {
                     AppPlan plan = new AppPlan();
                     BeanUtils.copyProperties(oldPlan, plan);
-                    if (immediateEffect && d.getStatus()==1) {
+                    if (immediateEffect && d.getStatus() == 1) {
                         hsPlans.add(plan);
                     }
                     plan.setSolidId(IDHelper.id());
@@ -324,13 +328,13 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 
     @Override
     public void cheHui(Long id) {
-        Date now =new Date();
+        Date now = new Date();
         AppPlan plan = baseMapper.selectById(id);
         if (ObjectUtil.equal(plan.getTaskHasCompleted(), 1)) {
             //有已完成时,计划及子计划状态变为停用,不删除任务
             LambdaUpdateWrapper<AppPlan> updateWrapper = new LambdaUpdateWrapper<>();
             updateWrapper.set(AppPlan::getPlanStatus, 2)
-                    .set(AppPlan::getWithdrawTime,now)
+                    .set(AppPlan::getWithdrawTime, now)
                     .eq(AppPlan::getParentId, id);
 
             baseMapper.update(null, updateWrapper);
@@ -338,7 +342,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             updateWrapper = new LambdaUpdateWrapper<>();
             updateWrapper.set(AppPlan::getPlanStatus, 2)
                     .set(AppPlan::getDistribute, 0)
-                    .set(AppPlan::getWithdrawTime,now)
+                    .set(AppPlan::getWithdrawTime, now)
                     .eq(AppPlan::getId, id);
             baseMapper.update(null, updateWrapper);
         } else {
@@ -346,7 +350,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             LambdaUpdateWrapper<AppPlan> updateWrapper = new LambdaUpdateWrapper<>();
             updateWrapper.set(AppPlan::getPlanStatus, 0)
                     .set(AppPlan::getDistribute, 0)
-                    .set(AppPlan::getWithdrawTime,now)
+                    .set(AppPlan::getWithdrawTime, now)
                     .eq(AppPlan::getId, id);
             baseMapper.update(null, updateWrapper);
 
@@ -372,16 +376,18 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             return;
         }
         Date date = DateUtil.beginOfDay(new Date());
-        resumptionMapper.delete(new LambdaQueryWrapper<Resumption>()
-                .in(Resumption::getSolidId, solidPlanIds)
+        LambdaQueryWrapper<Resumption> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(Resumption::getSolidId, solidPlanIds)
                 .and(w ->
                         w.ge(Resumption::getYmdDate, date)
                                 .or(w1 -> w1.ge(Resumption::getPlanEndTime, date))
-                ));
+                );
+        deleteTask(wrapper);
     }
 
     /**
      * 按固定id删除计划所有任务
+     *
      * @param solidPlanIds
      */
     @Async
@@ -389,8 +395,21 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
         if (CollectionUtils.isEmpty(solidPlanIds)) {
             return;
         }
-        resumptionMapper.delete(new LambdaQueryWrapper<Resumption>()
-                .in(Resumption::getSolidId, solidPlanIds));
+        LambdaQueryWrapper<Resumption> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(Resumption::getSolidId, solidPlanIds);
+        deleteTask(wrapper);
+    }
+
+    private void deleteTask(LambdaQueryWrapper<Resumption> wrapper) {
+        List<Long> completedIds = resumptionMapper.selectList(
+                wrapper.clone().eq(Resumption::getStatus, ResumptionTaskStatus.Completed.getCode())
+                        .select(Resumption::getId)
+        ).stream().map(Resumption::getId).collect(Collectors.toList());
+
+        resumptionMapper.delete(wrapper);
+        for (Long completedId : completedIds) {
+            coreRegisterBookPdfService.deleteWithFile(completedId);
+        }
     }
 
     /**
@@ -959,7 +978,6 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
     @Override
     @Transactional(rollbackFor = Exception.class)
     public AjaxResult buildResumptionPdf(Long orgid) {
-
         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";
@@ -973,9 +991,13 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             if (null == r || null == r.getData()) {
                 throw new SystemException(ErrorMsgConstants.GENERATE_PDF_ERROR);
             }
+            Long id= (Long)data.get("id");
+            if(ObjectUtil.isNull(id)){
+                throw new SystemException(ErrorMsgConstants.GENERATE_PDF_ERROR);
+            }
             String pdfUrl = r.getData();
             CoreRegisterBookPdf registerBookPdf = new CoreRegisterBookPdf();
-            registerBookPdf.setId(IdWorker.getId());
+            registerBookPdf.setId(id);
             registerBookPdf.setRegisterBookType(RegisterBookType.SECURITY_PERFORMANCE.getNum());
             registerBookPdf.setDate(new Date());
             registerBookPdf.setOrgId(orgid);
@@ -1026,6 +1048,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
         Map<Long, List<AppResumptionDataInfoVo>> ingf = ingvos.stream().collect(Collectors.groupingBy(AppResumptionDataInfoVo::getItemId));
         Map<Long, List<AppResumptionDataInfoVo>> afterf = aftervos.stream().collect(Collectors.groupingBy(AppResumptionDataInfoVo::getItemId));
 
+        data.put("id", CollectionUtil.isNotEmpty(before) ? before.get(0).getId() : (CollectionUtil.isNotEmpty(ing) ? ing.get(0).getId() : (CollectionUtil.isNotEmpty(after) ? after.get(0).getId() : null)));
         data.put("营业前", getResult(bef));
         data.put("营业期间", getResult(ingf));
         data.put("营业终了", getResult(afterf));

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

@@ -21,6 +21,7 @@ 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.RegisterBookType;
+import com.xunmei.common.core.enums.resumption.ResumptionTaskStatus;
 import com.xunmei.common.core.exception.ServiceException;
 import com.xunmei.common.core.exception.SystemException;
 import com.xunmei.common.core.utils.DateHelper;
@@ -28,11 +29,13 @@ import com.xunmei.common.core.utils.DateUtils;
 import com.xunmei.common.security.utils.SecurityUtils;
 import com.xunmei.core.registerbook.service.ICoreRegisterBookPdfService;
 import com.xunmei.core.resumption.domain.AppPlan;
+import com.xunmei.core.resumption.domain.Resumption;
 import com.xunmei.core.resumption.dto.DistributeDto;
 import com.xunmei.core.resumption.dto.DistributeStatusDto;
 import com.xunmei.core.resumption.mapper.AppPlanMapper;
 import com.xunmei.core.resumption.vo.appPlan.ResumptionPlanPageVo;
 import com.xunmei.core.safetyCheck.domain.*;
+import com.xunmei.core.safetyCheck.enums.SafetyCheckTaskStatus;
 import com.xunmei.core.safetyCheck.enums.SafetyPlanCycle;
 import com.xunmei.core.safetyCheck.job.SafetyCheckJobBusiness;
 import com.xunmei.core.safetyCheck.mapper.*;
@@ -90,6 +93,10 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
     private AppPlanMapper appPlanMapper;
     @Autowired
     private RemoteFileService fileService;
+
+    @Autowired
+    ICoreRegisterBookPdfService coreRegisterBookPdfService;
+
     @Autowired
     private CoreSafecheckPlanToCheckOrgTypeMapper coreSafecheckPlanToCheckOrgTypeMapper;
 
@@ -431,12 +438,14 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
             return;
         }
         Date date = DateUtil.beginOfDay(new Date());
-        coreSafetyTaskMapper.delete(new LambdaQueryWrapper<CoreSafetyTask>()
-                .in(CoreSafetyTask::getSolidId, solidPlanIds)
+        LambdaQueryWrapper<CoreSafetyTask> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(CoreSafetyTask::getSolidId, solidPlanIds)
                 .and(w ->
                         w.ge(CoreSafetyTask::getYmdDate, date)
                                 .or(w1 -> w1.ge(CoreSafetyTask::getPlanEndTime, date))
-                ));
+                );
+
+        deleteTask(wrapper);
     }
 
     @Async
@@ -444,10 +453,22 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
         if (CollectionUtils.isEmpty(solidPlanIds)) {
             return;
         }
-        coreSafetyTaskMapper.delete(new LambdaQueryWrapper<CoreSafetyTask>()
-                .in(CoreSafetyTask::getSolidId, solidPlanIds));
+        LambdaQueryWrapper<CoreSafetyTask> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(CoreSafetyTask::getSolidId, solidPlanIds);
+        deleteTask(wrapper);
     }
 
+    private void deleteTask(LambdaQueryWrapper<CoreSafetyTask> wrapper) {
+        List<Long> completedIds = coreSafetyTaskMapper.selectList(
+                wrapper.clone().eq(CoreSafetyTask::getStatus, SafetyCheckTaskStatus.Completed.getValue())
+                        .select(CoreSafetyTask::getId)
+        ).stream().map(CoreSafetyTask::getId).collect(Collectors.toList());
+
+        coreSafetyTaskMapper.delete(wrapper);
+        for (Long completedId : completedIds) {
+            coreRegisterBookPdfService.deleteWithFile(completedId);
+        }
+    }
 
     /**
      * 查询常规安全检查计划
@@ -613,7 +634,7 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
         //处理子计划
         //拿到所有子计划
         List<CoreSafecheckPlan> children = baseMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlan>()
-                .eq(CoreSafecheckPlan::getParentId, newPlanId));
+                .eq(CoreSafecheckPlan::getParentId, oldPlanId));
 //        List<Long> planIds = children.stream().map(CoreSafecheckPlan::getId).collect(Collectors.toList());
 //        planIds.add(id);
 //        Long hasEdit = coreSafetyTaskMapper.selectCount(new LambdaQueryWrapper<CoreSafetyTask>().in(CoreSafetyTask::getPlanId, planIds).in(CoreSafetyTask::getStatus, 3, 4));
@@ -636,18 +657,18 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
             if (needRebuildOnEdit(p, p.getPlanStatus())) {
                 needRebuildPlans.add(child);
             }
-            p.setUpdateTime(DateUtils.getNowDate());
-            p.setModifiedBy(SecurityUtils.getUserId());
-            p.setPlanName(coreSafecheckPlan.getPlanName());
+            child.setUpdateTime(DateUtils.getNowDate());
+            child.setModifiedBy(SecurityUtils.getUserId());
+            child.setPlanName(coreSafecheckPlan.getPlanName());
 //            p.setCheckOrgType(coreSafecheckPlan.getCheckOrgType());
-            p.setCheckType(coreSafecheckPlan.getCheckType());
-            p.setCount(p.getCount() > coreSafecheckPlan.getCount() ? p.getCount() : coreSafecheckPlan.getCount());
-            p.setDescription(coreSafecheckPlan.getDescription());
-            p.setExecOrgType(coreSafecheckPlan.getExecOrgType());
-            p.setPlanCycle(coreSafecheckPlan.getPlanCycle());
+            child.setCheckType(coreSafecheckPlan.getCheckType());
+            child.setCount(child.getCount() > coreSafecheckPlan.getCount() ? child.getCount() : coreSafecheckPlan.getCount());
+            child.setDescription(coreSafecheckPlan.getDescription());
+            child.setExecOrgType(coreSafecheckPlan.getExecOrgType());
+            child.setPlanCycle(coreSafecheckPlan.getPlanCycle());
 //                p.setPlanStatus(coreSafecheckPlan.getPlanStatus());
-            p.setSourceType(coreSafecheckPlan.getSourceType());
-            baseMapper.updateById(p);
+            child.setSourceType(coreSafecheckPlan.getSourceType());
+            baseMapper.updateById(child);
 
 
             //拿到父计划的所有角色映射
@@ -655,49 +676,49 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
             //再处理角色关系
             if (roleList != null) {
                 //删除子计划原角色映射
-                coreSafecheckPlanToRoleMapper.deleteCoreSafecheckPlanToRoleByPlanId(p.getId());
+                coreSafecheckPlanToRoleMapper.deleteCoreSafecheckPlanToRoleByPlanId(child.getId());
                 for (CoreSafecheckPlanToRole r :
                         roleList) {
                     //添加来自父计划的角色映射
-                    coreSafecheckPlanToRoleMapper.insert(new CoreSafecheckPlanToRole(p.getId(), r.getRoleId()));
+                    coreSafecheckPlanToRoleMapper.insert(new CoreSafecheckPlanToRole(child.getId(), r.getRoleId()));
                 }
             }
             //再处理检查机构关系
             List<CoreSafecheckPlanToExecOrg> execOrgList = coreSafecheckPlanToExecOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToExecOrg>().eq(CoreSafecheckPlanToExecOrg::getPlanId, coreSafecheckPlan.getId()));
             if (execOrgList != null) {
-                coreSafecheckPlanToExecOrgMapper.deleteCoreSafecheckPlanToExecOrgByPlanId(p.getId());
+                coreSafecheckPlanToExecOrgMapper.deleteCoreSafecheckPlanToExecOrgByPlanId(child.getId());
                 for (CoreSafecheckPlanToExecOrg org :
                         execOrgList) {
-                    coreSafecheckPlanToExecOrgMapper.insert(new CoreSafecheckPlanToExecOrg(p.getId(), org.getOrgId()));
+                    coreSafecheckPlanToExecOrgMapper.insert(new CoreSafecheckPlanToExecOrg(child.getId(), org.getOrgId()));
                 }
             }
             //再处理受检机构关系
             List<CoreSafecheckPlanToCheckOrg> checkOrgList = coreSafecheckPlanToCheckOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrg>().eq(CoreSafecheckPlanToCheckOrg::getPlanId, coreSafecheckPlan.getId()));
             if (checkOrgList != null) {
-                coreSafecheckPlanToCheckOrgMapper.deleteCoreSafecheckPlanToCheckOrgByPlanId(p.getId());
+                coreSafecheckPlanToCheckOrgMapper.deleteCoreSafecheckPlanToCheckOrgByPlanId(child.getId());
                 for (CoreSafecheckPlanToCheckOrg org :
                         checkOrgList) {
-                    coreSafecheckPlanToCheckOrgMapper.insert(new CoreSafecheckPlanToCheckOrg(p.getId(), org.getOrgId()));
+                    coreSafecheckPlanToCheckOrgMapper.insert(new CoreSafecheckPlanToCheckOrg(child.getId(), org.getOrgId()));
                 }
             }
             //再处理受检机构类型
             List<CoreSafecheckPlanToCheckOrgType> checkOrgTypes = coreSafecheckPlanToCheckOrgTypeMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrgType>().eq(CoreSafecheckPlanToCheckOrgType::getPlanId, coreSafecheckPlan.getId()));
             if (checkOrgTypes != null) {
                 //删除当前计划的受检机构类型
-                coreSafecheckPlanToCheckOrgTypeMapper.delete(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrgType>().eq(CoreSafecheckPlanToCheckOrgType::getPlanId, p.getId()));
+                coreSafecheckPlanToCheckOrgTypeMapper.delete(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrgType>().eq(CoreSafecheckPlanToCheckOrgType::getPlanId, child.getId()));
                 for (CoreSafecheckPlanToCheckOrgType type :
                         checkOrgTypes) {
-                    coreSafecheckPlanToCheckOrgTypeMapper.insert(new CoreSafecheckPlanToCheckOrgType(p.getId(), type.getTypeId()));
+                    coreSafecheckPlanToCheckOrgTypeMapper.insert(new CoreSafecheckPlanToCheckOrgType(child.getId(), type.getTypeId()));
                 }
             }
             //再处理子计划检查要点关系
             //查询计划id为当前父计划的id,所属机构id为当前父计划所属机构id的数据
             List<CoreSafecheckPlanToPoint> rpList = coreSafecheckPlanToPointMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToPoint>().eq(CoreSafecheckPlanToPoint::getPlanId, coreSafecheckPlan.getId()).eq(CoreSafecheckPlanToPoint::getOfOrgId, coreSafecheckPlan.getPlanOfOrgId()));
             if (rpList != null) {
-                coreSafecheckPlanToPointMapper.delete(new LambdaQueryWrapper<CoreSafecheckPlanToPoint>().eq(CoreSafecheckPlanToPoint::getPlanId, p.getId()).eq(CoreSafecheckPlanToPoint::getOfOrgId, coreSafecheckPlan.getPlanOfOrgId()));
+                coreSafecheckPlanToPointMapper.delete(new LambdaQueryWrapper<CoreSafecheckPlanToPoint>().eq(CoreSafecheckPlanToPoint::getPlanId, child.getId()).eq(CoreSafecheckPlanToPoint::getOfOrgId, coreSafecheckPlan.getPlanOfOrgId()));
                 for (CoreSafecheckPlanToPoint s :
                         rpList) {
-                    coreSafecheckPlanToPointMapper.insert(new CoreSafecheckPlanToPoint(p.getId(), s.getPointId(), s.isPointScan(), s.isRequired(), s.getOfOrgId()));
+                    coreSafecheckPlanToPointMapper.insert(new CoreSafecheckPlanToPoint(child.getId(), s.getPointId(), s.isPointScan(), s.isRequired(), s.getOfOrgId()));
                 }
             }
 

+ 10 - 9
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/listener/WorkTimeChangeEventListener.java

@@ -35,15 +35,16 @@ RemoteDrillService drillService;
     @EventListener(WorkTimeChangeEvent.class)
     @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = false)
     public void onApplicationEvent(WorkTimeChangeEvent event) {
-        CompletableFuture.supplyAsync(() ->
-                {
-                    remoteResumptionTaskService.rebuild(new Gson().toJson(event), SecurityConstants.INNER);
-                    eduTrainingService.rebuild(new Gson().toJson(event), SecurityConstants.INNER);
-                    remoteRetrievalTaskService.rebuild(new Gson().toJson(event), SecurityConstants.INNER);
-                    drillService.rebuild(new Gson().toJson(event), SecurityConstants.INNER);
-                    return null;
-                }
-        );
+        //此需求已无,保存代码
+//        CompletableFuture.supplyAsync(() ->
+//                {
+//                    remoteResumptionTaskService.rebuild(new Gson().toJson(event), SecurityConstants.INNER);
+//                    eduTrainingService.rebuild(new Gson().toJson(event), SecurityConstants.INNER);
+//                    remoteRetrievalTaskService.rebuild(new Gson().toJson(event), SecurityConstants.INNER);
+//                    drillService.rebuild(new Gson().toJson(event), SecurityConstants.INNER);
+//                    return null;
+//                }
+//        );
 
 //        remoteSafetyCheckService.rebuild(JSON.toJSONString(event), SecurityConstants.INNER);
     }