|
|
@@ -1,12 +1,12 @@
|
|
|
package com.xunmei.core.safetyCheck.service.impl;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.xunmei.common.core.utils.DateHelper;
|
|
|
import com.xunmei.common.core.utils.DateUtils;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
import com.xunmei.core.resumption.domain.AppPlan;
|
|
|
@@ -16,6 +16,7 @@ import com.xunmei.core.resumption.dto.DistributeDto;
|
|
|
import com.xunmei.core.resumption.dto.DistributeStatusDto;
|
|
|
import com.xunmei.core.resumption.vo.appPlan.ResumptionPlanPageVo;
|
|
|
import com.xunmei.core.safetyCheck.domain.*;
|
|
|
+import com.xunmei.core.safetyCheck.job.SafetyCheckJobBusiness;
|
|
|
import com.xunmei.core.safetyCheck.mapper.*;
|
|
|
import com.xunmei.core.safetyCheck.service.ICoreSafecheckPlanService;
|
|
|
import com.xunmei.core.safetyCheck.vo.ruleItem.SafetyCheckRulePointSelectVo;
|
|
|
@@ -25,7 +26,6 @@ import com.xunmei.system.api.domain.SysOrg;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
@@ -53,6 +53,8 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
private CoreSafecheckPlanToCheckOrgMapper coreSafecheckPlanToCheckOrgMapper;
|
|
|
@Autowired
|
|
|
private CoreSafecheckPlanToPointMapper coreSafecheckPlanToPointMapper;
|
|
|
+ @Autowired
|
|
|
+ private SafetyCheckJobBusiness safetyCheckJobBusiness;
|
|
|
|
|
|
@Override
|
|
|
public TableDataInfo<CoreSafecheckPlan> selectPage(CoreSafecheckPlan coreSafecheckPlan) {
|
|
|
@@ -70,9 +72,6 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
page = coreSafecheckPlanMapper.selectCoreSafecheckPlanPage(page, coreSafecheckPlan);
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
coreSafecheckPlan.setParentIds(page.getRecords().stream().map(CoreSafecheckPlan::getId).collect(Collectors.toList()));
|
|
|
List<CoreSafecheckPlan> allChildren = new ArrayList<>();
|
|
|
if (CollectionUtil.isNotEmpty(coreSafecheckPlan.getParentIds())) {
|
|
|
@@ -117,7 +116,7 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
coreSafecheckPlan.setParentId(dto.getId());
|
|
|
baseMapper.insert(coreSafecheckPlan);
|
|
|
|
|
|
- List<CoreSafecheckPlanToRole> roleList = coreSafecheckPlanToRoleMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToRole>().eq(CoreSafecheckPlanToRole::getPlanId,dto.getId()));
|
|
|
+ List<CoreSafecheckPlanToRole> roleList = coreSafecheckPlanToRoleMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToRole>().eq(CoreSafecheckPlanToRole::getPlanId, dto.getId()));
|
|
|
//再处理角色关系
|
|
|
if (roleList != null) {
|
|
|
coreSafecheckPlanToRoleMapper.deleteCoreSafecheckPlanToRoleByPlanId(coreSafecheckPlan.getId());
|
|
|
@@ -128,7 +127,7 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
}
|
|
|
}
|
|
|
//再处理检查机构关系
|
|
|
- List<CoreSafecheckPlanToExecOrg> execOrgList = coreSafecheckPlanToExecOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToExecOrg>().eq(CoreSafecheckPlanToExecOrg::getPlanId,dto.getId()));
|
|
|
+ List<CoreSafecheckPlanToExecOrg> execOrgList = coreSafecheckPlanToExecOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToExecOrg>().eq(CoreSafecheckPlanToExecOrg::getPlanId, dto.getId()));
|
|
|
if (execOrgList != null) {
|
|
|
coreSafecheckPlanToExecOrgMapper.deleteCoreSafecheckPlanToExecOrgByPlanId(coreSafecheckPlan.getId());
|
|
|
for (CoreSafecheckPlanToExecOrg org :
|
|
|
@@ -138,7 +137,7 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
}
|
|
|
}
|
|
|
//再处理受检机构关系
|
|
|
- List<CoreSafecheckPlanToCheckOrg> checkOrgList = coreSafecheckPlanToCheckOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrg>().eq(CoreSafecheckPlanToCheckOrg::getPlanId,dto.getId()));
|
|
|
+ List<CoreSafecheckPlanToCheckOrg> checkOrgList = coreSafecheckPlanToCheckOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrg>().eq(CoreSafecheckPlanToCheckOrg::getPlanId, dto.getId()));
|
|
|
if (checkOrgList != null) {
|
|
|
coreSafecheckPlanToCheckOrgMapper.deleteCoreSafecheckPlanToCheckOrgByPlanId(coreSafecheckPlan.getId());
|
|
|
for (CoreSafecheckPlanToCheckOrg org :
|
|
|
@@ -148,12 +147,12 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
}
|
|
|
}
|
|
|
//再处理检查要点关系
|
|
|
- List<CoreSafecheckPlanToPoint> rpList = coreSafecheckPlanToPointMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToPoint>().eq(CoreSafecheckPlanToPoint::getPlanId,dto.getId()));
|
|
|
+ List<CoreSafecheckPlanToPoint> rpList = coreSafecheckPlanToPointMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToPoint>().eq(CoreSafecheckPlanToPoint::getPlanId, dto.getId()));
|
|
|
if (rpList != null) {
|
|
|
coreSafecheckPlanToPointMapper.deleteCoreSafecheckPlanToPointByPlanId(coreSafecheckPlan.getId());
|
|
|
for (CoreSafecheckPlanToPoint s :
|
|
|
rpList) {
|
|
|
- coreSafecheckPlanToPointMapper.insert(new CoreSafecheckPlanToPoint(coreSafecheckPlan.getId(), s.getPointId(),s.isPointScan(),s.isRequired()));
|
|
|
+ coreSafecheckPlanToPointMapper.insert(new CoreSafecheckPlanToPoint(coreSafecheckPlan.getId(), s.getPointId(), s.isPointScan(), s.isRequired()));
|
|
|
|
|
|
}
|
|
|
}
|
|
|
@@ -191,7 +190,7 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
*/
|
|
|
@Override
|
|
|
public void insertCoreSafecheckPlan(CoreSafecheckPlan coreSafecheckPlan) {
|
|
|
-
|
|
|
+ Long pid = coreSafecheckPlan.getId();
|
|
|
if (coreSafecheckPlan.getId() == null) {
|
|
|
//先处理检查计划
|
|
|
coreSafecheckPlan.setPlanOfOrgId(coreSafecheckPlan.getPlanCreateOrgId());
|
|
|
@@ -199,15 +198,17 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
coreSafecheckPlan.setCreateTime(DateUtils.getNowDate());
|
|
|
coreSafecheckPlan.setModifiedBy(SecurityUtils.getUserId());
|
|
|
coreSafecheckPlanMapper.insert(coreSafecheckPlan);
|
|
|
- }else {
|
|
|
+
|
|
|
+ } else {
|
|
|
coreSafecheckPlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
coreSafecheckPlan.setModifiedBy(SecurityUtils.getUserId());
|
|
|
coreSafecheckPlanMapper.updateById(coreSafecheckPlan);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//再处理角色关系
|
|
|
if (coreSafecheckPlan.getRoleIds() != null) {
|
|
|
- coreSafecheckPlanToRoleMapper.deleteCoreSafecheckPlanToRoleByPlanId(coreSafecheckPlan.getId());
|
|
|
+ coreSafecheckPlanToRoleMapper.deleteCoreSafecheckPlanToRoleByPlanId(coreSafecheckPlan.getId());
|
|
|
for (Long id :
|
|
|
coreSafecheckPlan.getRoleIds()) {
|
|
|
coreSafecheckPlanToRoleMapper.insert(new CoreSafecheckPlanToRole(coreSafecheckPlan.getId(), id));
|
|
|
@@ -216,7 +217,7 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
}
|
|
|
//再处理检查机构关系
|
|
|
if (coreSafecheckPlan.getExecOrgIds() != null) {
|
|
|
- coreSafecheckPlanToExecOrgMapper.deleteCoreSafecheckPlanToExecOrgByPlanId(coreSafecheckPlan.getId());
|
|
|
+ coreSafecheckPlanToExecOrgMapper.deleteCoreSafecheckPlanToExecOrgByPlanId(coreSafecheckPlan.getId());
|
|
|
for (Long org :
|
|
|
coreSafecheckPlan.getExecOrgIds()) {
|
|
|
coreSafecheckPlanToExecOrgMapper.insert(new CoreSafecheckPlanToExecOrg(coreSafecheckPlan.getId(), org));
|
|
|
@@ -225,7 +226,7 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
}
|
|
|
//再处理受检机构关系
|
|
|
if (coreSafecheckPlan.getCheckOrgIds() != null) {
|
|
|
- coreSafecheckPlanToCheckOrgMapper.deleteCoreSafecheckPlanToCheckOrgByPlanId(coreSafecheckPlan.getId());
|
|
|
+ coreSafecheckPlanToCheckOrgMapper.deleteCoreSafecheckPlanToCheckOrgByPlanId(coreSafecheckPlan.getId());
|
|
|
for (Long org :
|
|
|
coreSafecheckPlan.getCheckOrgIds()) {
|
|
|
coreSafecheckPlanToCheckOrgMapper.insert(new CoreSafecheckPlanToCheckOrg(coreSafecheckPlan.getId(), org));
|
|
|
@@ -234,17 +235,32 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
}
|
|
|
//再处理检查要点关系
|
|
|
if (coreSafecheckPlan.getRulePointList() != null) {
|
|
|
- coreSafecheckPlanToPointMapper.deleteCoreSafecheckPlanToPointByPlanId(coreSafecheckPlan.getId());
|
|
|
+ coreSafecheckPlanToPointMapper.deleteCoreSafecheckPlanToPointByPlanId(coreSafecheckPlan.getId());
|
|
|
for (SafetyCheckRulePointVo s :
|
|
|
coreSafecheckPlan.getRulePointList()) {
|
|
|
- coreSafecheckPlanToPointMapper.insert(new CoreSafecheckPlanToPoint(coreSafecheckPlan.getId(), s.getId(),s.isPointScan(),s.isRequired()));
|
|
|
+ coreSafecheckPlanToPointMapper.insert(new CoreSafecheckPlanToPoint(coreSafecheckPlan.getId(), s.getId(), s.isPointScan(), s.isRequired()));
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //如果是新增计划并且勾选立即执行
|
|
|
+ if (pid==null&&coreSafecheckPlan.isBuildTaskNow()) {
|
|
|
+ DateTime datetime = new DateTime();
|
|
|
+ datetime.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
|
+ DateHelper dateHelper = new DateHelper(datetime);
|
|
|
+// SCHEDULEDTASKSLOG.info("开始生成每周常规安全检查任务!");
|
|
|
+ try {
|
|
|
+ Map<String, Date> map = DateHelper.getStartAndEnd(dateHelper, 1);
|
|
|
+ safetyCheckJobBusiness.createTask(datetime, 1, map.get("start"), map.get("end"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException("生成每周常规安全检查任务失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//处理子计划
|
|
|
//拿到所有子计划
|
|
|
- List<CoreSafecheckPlan> children = baseMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlan>().eq(CoreSafecheckPlan::getParentId,coreSafecheckPlan.getId()));
|
|
|
+ List<CoreSafecheckPlan> children = baseMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlan>().eq(CoreSafecheckPlan::getParentId, coreSafecheckPlan.getId()));
|
|
|
coreSafecheckPlan = baseMapper.selectById(coreSafecheckPlan.getId());
|
|
|
for (CoreSafecheckPlan p :
|
|
|
children) {
|
|
|
@@ -262,7 +278,7 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
|
|
|
|
|
|
//拿到父计划的所有角色映射
|
|
|
- List<CoreSafecheckPlanToRole> roleList = coreSafecheckPlanToRoleMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToRole>().eq(CoreSafecheckPlanToRole::getPlanId,coreSafecheckPlan.getId()));
|
|
|
+ List<CoreSafecheckPlanToRole> roleList = coreSafecheckPlanToRoleMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToRole>().eq(CoreSafecheckPlanToRole::getPlanId, coreSafecheckPlan.getId()));
|
|
|
//再处理角色关系
|
|
|
if (roleList != null) {
|
|
|
//删除子计划原角色映射
|
|
|
@@ -275,7 +291,7 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
}
|
|
|
}
|
|
|
//再处理检查机构关系
|
|
|
- List<CoreSafecheckPlanToExecOrg> execOrgList = coreSafecheckPlanToExecOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToExecOrg>().eq(CoreSafecheckPlanToExecOrg::getPlanId,coreSafecheckPlan.getId()));
|
|
|
+ List<CoreSafecheckPlanToExecOrg> execOrgList = coreSafecheckPlanToExecOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToExecOrg>().eq(CoreSafecheckPlanToExecOrg::getPlanId, coreSafecheckPlan.getId()));
|
|
|
if (execOrgList != null) {
|
|
|
coreSafecheckPlanToExecOrgMapper.deleteCoreSafecheckPlanToExecOrgByPlanId(p.getId());
|
|
|
for (CoreSafecheckPlanToExecOrg org :
|
|
|
@@ -285,7 +301,7 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
}
|
|
|
}
|
|
|
//再处理受检机构关系
|
|
|
- List<CoreSafecheckPlanToCheckOrg> checkOrgList = coreSafecheckPlanToCheckOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrg>().eq(CoreSafecheckPlanToCheckOrg::getPlanId,coreSafecheckPlan.getId()));
|
|
|
+ List<CoreSafecheckPlanToCheckOrg> checkOrgList = coreSafecheckPlanToCheckOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrg>().eq(CoreSafecheckPlanToCheckOrg::getPlanId, coreSafecheckPlan.getId()));
|
|
|
if (checkOrgList != null) {
|
|
|
coreSafecheckPlanToCheckOrgMapper.deleteCoreSafecheckPlanToCheckOrgByPlanId(p.getId());
|
|
|
for (CoreSafecheckPlanToCheckOrg org :
|
|
|
@@ -295,12 +311,12 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
}
|
|
|
}
|
|
|
//再处理检查要点关系
|
|
|
- List<CoreSafecheckPlanToPoint> rpList = coreSafecheckPlanToPointMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToPoint>().eq(CoreSafecheckPlanToPoint::getPlanId,coreSafecheckPlan.getId()));
|
|
|
+ List<CoreSafecheckPlanToPoint> rpList = coreSafecheckPlanToPointMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToPoint>().eq(CoreSafecheckPlanToPoint::getPlanId, coreSafecheckPlan.getId()));
|
|
|
if (rpList != null) {
|
|
|
coreSafecheckPlanToPointMapper.deleteCoreSafecheckPlanToPointByPlanId(p.getId());
|
|
|
for (CoreSafecheckPlanToPoint s :
|
|
|
rpList) {
|
|
|
- coreSafecheckPlanToPointMapper.insert(new CoreSafecheckPlanToPoint(p.getId(), s.getPointId(),s.isPointScan(),s.isRequired()));
|
|
|
+ coreSafecheckPlanToPointMapper.insert(new CoreSafecheckPlanToPoint(p.getId(), s.getPointId(), s.isPointScan(), s.isRequired()));
|
|
|
|
|
|
}
|
|
|
}
|
|
|
@@ -341,7 +357,14 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
*/
|
|
|
@Override
|
|
|
public int deleteCoreSafecheckPlanByIds(Long[] ids) {
|
|
|
- return coreSafecheckPlanMapper.deleteBatchIds(Arrays.asList((ids)));
|
|
|
+ List<Long> list = Arrays.asList((ids));
|
|
|
+ //清理关联数据
|
|
|
+ coreSafecheckPlanToRoleMapper.deleteCoreSafecheckPlanToRoleByPlanIds(ids);
|
|
|
+ coreSafecheckPlanToExecOrgMapper.deleteCoreSafecheckPlanToExecOrgByPlanIds(ids);
|
|
|
+ coreSafecheckPlanToCheckOrgMapper.deleteCoreSafecheckPlanToCheckOrgByPlanIds(ids);
|
|
|
+ coreSafecheckPlanToPointMapper.deleteCoreSafecheckPlanToPointByPlanIds(ids);
|
|
|
+ //生成的任务删除逻辑待定
|
|
|
+ return coreSafecheckPlanMapper.deleteBatchIds(list);
|
|
|
}
|
|
|
|
|
|
/**
|