|
|
@@ -41,6 +41,8 @@ import com.xunmei.core.question.service.IQuestionService;
|
|
|
import com.xunmei.core.registerbook.service.ICoreRegisterBookPdfService;
|
|
|
import com.xunmei.core.reminder.service.ICoreReminderConfigurationService;
|
|
|
import com.xunmei.core.reminder.service.ICoreReminderScheduleService;
|
|
|
+import com.xunmei.core.resumption.domain.AppPlanToExecOrg;
|
|
|
+import com.xunmei.core.resumption.domain.AppPlanToRole;
|
|
|
import com.xunmei.core.resumption.dto.DistributeDto;
|
|
|
import com.xunmei.core.resumption.dto.DistributeStatusDto;
|
|
|
import com.xunmei.core.safetyCheck.domain.*;
|
|
|
@@ -182,6 +184,152 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
return coreSafecheckPlanMapper.selectItemIdsByPlanId(id);
|
|
|
}
|
|
|
|
|
|
+// @Override
|
|
|
+// public void distributeToOrg(DistributeDto dto, Boolean immediateEffect) {
|
|
|
+// CoreSafecheckPlan oldPlan = baseMapper.selectById(dto.getId());
|
|
|
+// throwIfNoCycleOverdue(oldPlan);
|
|
|
+// Long parentId = IdWorker.getId(oldPlan);
|
|
|
+// Date now = new Date();
|
|
|
+// List<CoreSafecheckPlan> hsPlans = new ArrayList<>();
|
|
|
+// Date effectiveTime = getEffectiveTime(oldPlan, immediateEffect);
|
|
|
+// for (DistributeStatusDto d :
|
|
|
+// dto.getOrgAndStatus()) {
|
|
|
+// CoreSafecheckPlan plan = baseMapper.selectOne(new LambdaQueryWrapper<CoreSafecheckPlan>()
|
|
|
+// .eq(CoreSafecheckPlan::getPlanOfOrgId, d.getOrgId())
|
|
|
+// .eq(CoreSafecheckPlan::getParentId, dto.getId()));
|
|
|
+// //如果子计划已存在
|
|
|
+// if (plan != null) {
|
|
|
+// //从停用状态下发,才会有已存在的子计划;
|
|
|
+// if (d.getStatus() > 0) {
|
|
|
+// plan.setPlanStatus(1);
|
|
|
+// plan.setPublishTime(now);
|
|
|
+// plan.setEffectiveTime(effectiveTime);
|
|
|
+// } else {
|
|
|
+// plan.setPlanStatus(2);
|
|
|
+// plan.setPublishTime(null);
|
|
|
+// plan.setEffectiveTime(null);
|
|
|
+// }
|
|
|
+// plan.setDistributePlanStatus(d.getStatus().toString());
|
|
|
+// plan.setDistributeStatus("1");
|
|
|
+// if (!immediateEffect) {
|
|
|
+// //停用状态下发,逻辑删除旧的计划,并生成一份副本
|
|
|
+// baseMapper.updateById(plan);
|
|
|
+// baseMapper.deleteById(plan);
|
|
|
+//
|
|
|
+// Long hsPlanId = IdWorker.getId(plan);
|
|
|
+// copyChildPlan(plan.getId(), hsPlanId, parentId);
|
|
|
+// } else {
|
|
|
+// baseMapper.updateById(plan);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// CoreSafecheckPlan coreSafecheckPlan = new CoreSafecheckPlan();
|
|
|
+// BeanUtils.copyProperties(oldPlan, coreSafecheckPlan);
|
|
|
+// if (immediateEffect) {
|
|
|
+// hsPlans.add(coreSafecheckPlan);
|
|
|
+// }
|
|
|
+// Long childPlanId = IdWorker.getId(coreSafecheckPlan);
|
|
|
+// coreSafecheckPlan.setId(childPlanId);
|
|
|
+// coreSafecheckPlan.setParentId(dto.getId());
|
|
|
+// coreSafecheckPlan.setSolidId(childPlanId);
|
|
|
+// coreSafecheckPlan.setParentSolidId(oldPlan.getSolidId());
|
|
|
+// coreSafecheckPlan.setDistributeStatus("1");
|
|
|
+// coreSafecheckPlan.setPlanOfOrgId(d.getOrgId());
|
|
|
+// coreSafecheckPlan.setPlanStatus(d.getStatus() > 0 ? 1 : 0);
|
|
|
+// coreSafecheckPlan.setDistributePlanStatus(d.getStatus().toString());
|
|
|
+// coreSafecheckPlan.setCreateTime(new Date());
|
|
|
+// if (ObjectUtil.equal(d.getStatus(), 1)) {
|
|
|
+// coreSafecheckPlan.setPublishTime(now);
|
|
|
+// coreSafecheckPlan.setEffectiveTime(effectiveTime);
|
|
|
+// }
|
|
|
+// //下发所属机构类型
|
|
|
+// coreSafecheckPlan.setPlanOfOrgType(orgService.selectSysOrgById(coreSafecheckPlan.getPlanOfOrgId(), SecurityConstants.INNER).getType());
|
|
|
+//
|
|
|
+//// if (coreSafecheckPlan.getPlanCycle()==6){
|
|
|
+//// coreSafecheckPlan.setStartDate();
|
|
|
+//// }
|
|
|
+//// plan.setPlanName(plan.getPlanName()+"下发"+orgService.selectOrgById(d.getOrgId(),SecurityConstants.INNER).getName());
|
|
|
+// coreSafecheckPlan.setPlanName(coreSafecheckPlan.getPlanName());
|
|
|
+// baseMapper.insert(coreSafecheckPlan);
|
|
|
+//
|
|
|
+// List<CoreSafecheckPlanToRole> roleList = coreSafecheckPlanToRoleMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToRole>()
|
|
|
+// .eq(CoreSafecheckPlanToRole::getPlanId, dto.getId()));
|
|
|
+// //再处理角色关系
|
|
|
+// if (roleList != null) {
|
|
|
+// coreSafecheckPlanToRoleMapper.deleteCoreSafecheckPlanToRoleByPlanId(coreSafecheckPlan.getId());
|
|
|
+// for (CoreSafecheckPlanToRole r :
|
|
|
+// roleList) {
|
|
|
+// coreSafecheckPlanToRoleMapper.insert(new CoreSafecheckPlanToRole(coreSafecheckPlan.getId(), r.getRoleId()));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //再处理检查机构关系
|
|
|
+// List<CoreSafecheckPlanToExecOrg> execOrgList = coreSafecheckPlanToExecOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToExecOrg>()
|
|
|
+// .eq(CoreSafecheckPlanToExecOrg::getPlanId, dto.getId()));
|
|
|
+// if (execOrgList != null) {
|
|
|
+// coreSafecheckPlanToExecOrgMapper.deleteCoreSafecheckPlanToExecOrgByPlanId(coreSafecheckPlan.getId());
|
|
|
+// for (CoreSafecheckPlanToExecOrg org :
|
|
|
+// execOrgList) {
|
|
|
+// coreSafecheckPlanToExecOrgMapper.insert(new CoreSafecheckPlanToExecOrg(coreSafecheckPlan.getId(), org.getOrgId()));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //再处理受检机构关系
|
|
|
+// List<CoreSafecheckPlanToCheckOrg> checkOrgList = coreSafecheckPlanToCheckOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrg>()
|
|
|
+// .eq(CoreSafecheckPlanToCheckOrg::getPlanId, dto.getId()));
|
|
|
+// if (checkOrgList != null) {
|
|
|
+// coreSafecheckPlanToCheckOrgMapper.deleteCoreSafecheckPlanToCheckOrgByPlanId(coreSafecheckPlan.getId());
|
|
|
+// for (CoreSafecheckPlanToCheckOrg org :
|
|
|
+// checkOrgList) {
|
|
|
+// coreSafecheckPlanToCheckOrgMapper.insert(new CoreSafecheckPlanToCheckOrg(coreSafecheckPlan.getId(), org.getOrgId()));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //再处理受检机构类型
|
|
|
+// List<CoreSafecheckPlanToCheckOrgType> checkOrgTypes = coreSafecheckPlanToCheckOrgTypeMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrgType>()
|
|
|
+// .eq(CoreSafecheckPlanToCheckOrgType::getPlanId, dto.getId()));
|
|
|
+// if (checkOrgTypes != null) {
|
|
|
+// //删除当前计划的受检机构类型
|
|
|
+// coreSafecheckPlanToCheckOrgTypeMapper.delete(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrgType>()
|
|
|
+// .eq(CoreSafecheckPlanToCheckOrgType::getPlanId, coreSafecheckPlan.getId()));
|
|
|
+// for (CoreSafecheckPlanToCheckOrgType type :
|
|
|
+// checkOrgTypes) {
|
|
|
+// coreSafecheckPlanToCheckOrgTypeMapper.insert(new CoreSafecheckPlanToCheckOrgType(coreSafecheckPlan.getId(), type.getTypeId()));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //再处理检查要点关系
|
|
|
+//
|
|
|
+// //查询父计划的所有检查要点
|
|
|
+// List<CoreSafecheckPlanToPoint> rpList = coreSafecheckPlanToPointMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToPoint>()
|
|
|
+// .eq(CoreSafecheckPlanToPoint::getPlanId, dto.getId()));
|
|
|
+// if (rpList != null) {
|
|
|
+// //删除父计划创建的检查要点
|
|
|
+// coreSafecheckPlanToPointMapper.delete(new LambdaQueryWrapper<CoreSafecheckPlanToPoint>()
|
|
|
+// .eq(CoreSafecheckPlanToPoint::getPlanId, coreSafecheckPlan.getId()));
|
|
|
+// for (CoreSafecheckPlanToPoint s :
|
|
|
+// rpList) {
|
|
|
+// //插入父计划的所有检查要点
|
|
|
+// coreSafecheckPlanToPointMapper.insert(new CoreSafecheckPlanToPoint(coreSafecheckPlan.getId(), s.getPointId(), s.isPointScan(), s.isRequired(), s.getOfOrgId()));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //更改下发状态
|
|
|
+// CoreSafecheckPlan coreSafecheckPlan = new CoreSafecheckPlan();
|
|
|
+// coreSafecheckPlan.setId(dto.getId());
|
|
|
+// coreSafecheckPlan.setDistribute("1");
|
|
|
+// coreSafecheckPlan.setPlanStatus(1);
|
|
|
+// coreSafecheckPlan.setPublishTime(now);
|
|
|
+// coreSafecheckPlan.setEffectiveTime(effectiveTime);
|
|
|
+// baseMapper.updateById(coreSafecheckPlan);
|
|
|
+//// coreSafecheckPlan.setBuildTaskNow(coreSafecheckPlanMapper.selectById(dto.getId()).isBuildTaskNow());
|
|
|
+// if (ObjectUtil.equal(oldPlan.getPlanStatus(), PlanStatus.DELETED.getCode())) {
|
|
|
+// //停用时下发且立即生效,逻辑删除旧计划并生成新计划
|
|
|
+// baseMapper.deleteById(coreSafecheckPlan);
|
|
|
+// copySelfPlan(oldPlan.getId(), parentId);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (immediateEffect) {
|
|
|
+// safetyCheckJobBusiness.createTaskByPlans(hsPlans, dto.getId());
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
@Override
|
|
|
public void distributeToOrg(DistributeDto dto, Boolean immediateEffect) {
|
|
|
CoreSafecheckPlan oldPlan = baseMapper.selectById(dto.getId());
|
|
|
@@ -190,6 +338,26 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
Date now = new Date();
|
|
|
List<CoreSafecheckPlan> hsPlans = new ArrayList<>();
|
|
|
Date effectiveTime = getEffectiveTime(oldPlan, immediateEffect);
|
|
|
+
|
|
|
+ List<CoreSafecheckPlanToExecOrg> execOrgs = coreSafecheckPlanToExecOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToExecOrg>().eq(CoreSafecheckPlanToExecOrg::getPlanId, dto.getId()));
|
|
|
+ List<Long> parentPlanExceOrgIds=new ArrayList<>();
|
|
|
+ List<SysOrg> parentPlanExecOrgs =null;
|
|
|
+ List<SysOrg> hsOrgs =null;
|
|
|
+ if(ObjectUtil.isNotEmpty(execOrgs))
|
|
|
+ {
|
|
|
+ parentPlanExceOrgIds= execOrgs.stream().map(x->x.getOrgId()).collect(toList());
|
|
|
+ parentPlanExecOrgs = orgService.selectByOrgIdList(parentPlanExceOrgIds, SecurityConstants.INNER);
|
|
|
+ hsOrgs = orgService.selectParentHs(parentPlanExceOrgIds, SecurityConstants.INNER);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysOrg> parentPlanCheckOrgs =null;
|
|
|
+ List<CoreSafecheckPlanToCheckOrg> checkOrgs = coreSafecheckPlanToCheckOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrg>().eq(CoreSafecheckPlanToCheckOrg::getPlanId, dto.getId()));
|
|
|
+ if(ObjectUtil.isNotEmpty(checkOrgs))
|
|
|
+ {
|
|
|
+ parentPlanCheckOrgs = orgService.selectByOrgIdList(checkOrgs.stream().map(x->x.getOrgId()).collect(toList()), SecurityConstants.INNER);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
for (DistributeStatusDto d :
|
|
|
dto.getOrgAndStatus()) {
|
|
|
CoreSafecheckPlan plan = baseMapper.selectOne(new LambdaQueryWrapper<CoreSafecheckPlan>()
|
|
|
@@ -209,22 +377,34 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
}
|
|
|
plan.setDistributePlanStatus(d.getStatus().toString());
|
|
|
plan.setDistributeStatus("1");
|
|
|
- if (!immediateEffect) {
|
|
|
- //停用状态下发,逻辑删除旧的计划,并生成一份副本
|
|
|
- baseMapper.updateById(plan);
|
|
|
- baseMapper.deleteById(plan);
|
|
|
+ baseMapper.updateById(plan);
|
|
|
+// if (!immediateEffect) {
|
|
|
+// //停用状态下发,逻辑删除旧的计划,并生成一份副本
|
|
|
+// baseMapper.updateById(plan);
|
|
|
+// baseMapper.deleteById(plan);
|
|
|
+//
|
|
|
+// Long hsPlanId = IdWorker.getId(plan);
|
|
|
+// copyChildPlan(plan.getId(), hsPlanId, parentId);
|
|
|
+// } else {
|
|
|
+// baseMapper.updateById(plan);
|
|
|
+// }
|
|
|
|
|
|
- Long hsPlanId = IdWorker.getId(plan);
|
|
|
- copyChildPlan(plan.getId(), hsPlanId, parentId);
|
|
|
- } else {
|
|
|
- baseMapper.updateById(plan);
|
|
|
- }
|
|
|
} else {
|
|
|
+ // 子计划不存在 新增子计划
|
|
|
+
|
|
|
+ List<Long> childPlanCheckOrgIds =null;
|
|
|
+ if(ObjectUtil.isNotEmpty(parentPlanCheckOrgs))
|
|
|
+ {
|
|
|
+ childPlanCheckOrgIds = getChildPlanCheckOrgIds(d.getOrgId(), hsOrgs, parentPlanCheckOrgs);
|
|
|
+ // 主计划选择了具体受检机构,但是该子计划对应的受检机构为空, 此种子计划不生成
|
|
|
+ if(ObjectUtil.isEmpty(childPlanCheckOrgIds))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
CoreSafecheckPlan coreSafecheckPlan = new CoreSafecheckPlan();
|
|
|
BeanUtils.copyProperties(oldPlan, coreSafecheckPlan);
|
|
|
- if (immediateEffect) {
|
|
|
- hsPlans.add(coreSafecheckPlan);
|
|
|
- }
|
|
|
Long childPlanId = IdWorker.getId(coreSafecheckPlan);
|
|
|
coreSafecheckPlan.setId(childPlanId);
|
|
|
coreSafecheckPlan.setParentId(dto.getId());
|
|
|
@@ -239,58 +419,48 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
coreSafecheckPlan.setPublishTime(now);
|
|
|
coreSafecheckPlan.setEffectiveTime(effectiveTime);
|
|
|
}
|
|
|
+
|
|
|
+ if (immediateEffect) {
|
|
|
+ hsPlans.add(coreSafecheckPlan);
|
|
|
+ }
|
|
|
+
|
|
|
//下发所属机构类型
|
|
|
coreSafecheckPlan.setPlanOfOrgType(orgService.selectSysOrgById(coreSafecheckPlan.getPlanOfOrgId(), SecurityConstants.INNER).getType());
|
|
|
|
|
|
-// if (coreSafecheckPlan.getPlanCycle()==6){
|
|
|
-// coreSafecheckPlan.setStartDate();
|
|
|
-// }
|
|
|
-// plan.setPlanName(plan.getPlanName()+"下发"+orgService.selectOrgById(d.getOrgId(),SecurityConstants.INNER).getName());
|
|
|
coreSafecheckPlan.setPlanName(coreSafecheckPlan.getPlanName());
|
|
|
baseMapper.insert(coreSafecheckPlan);
|
|
|
|
|
|
- List<CoreSafecheckPlanToRole> roleList = coreSafecheckPlanToRoleMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToRole>()
|
|
|
- .eq(CoreSafecheckPlanToRole::getPlanId, dto.getId()));
|
|
|
+ List<Long> roleIdList = coreSafecheckPlanToRoleMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToRole>()
|
|
|
+ .eq(CoreSafecheckPlanToRole::getPlanId, dto.getId())).stream().map(CoreSafecheckPlanToRole::getRoleId).collect(Collectors.toList());;
|
|
|
//再处理角色关系
|
|
|
- if (roleList != null) {
|
|
|
- coreSafecheckPlanToRoleMapper.deleteCoreSafecheckPlanToRoleByPlanId(coreSafecheckPlan.getId());
|
|
|
- for (CoreSafecheckPlanToRole r :
|
|
|
- roleList) {
|
|
|
- coreSafecheckPlanToRoleMapper.insert(new CoreSafecheckPlanToRole(coreSafecheckPlan.getId(), r.getRoleId()));
|
|
|
- }
|
|
|
- }
|
|
|
+ addPlanRole(coreSafecheckPlan.getId(), roleIdList);
|
|
|
+
|
|
|
//再处理检查机构关系
|
|
|
- List<CoreSafecheckPlanToExecOrg> execOrgList = coreSafecheckPlanToExecOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToExecOrg>()
|
|
|
- .eq(CoreSafecheckPlanToExecOrg::getPlanId, dto.getId()));
|
|
|
- if (execOrgList != null) {
|
|
|
- coreSafecheckPlanToExecOrgMapper.deleteCoreSafecheckPlanToExecOrgByPlanId(coreSafecheckPlan.getId());
|
|
|
- for (CoreSafecheckPlanToExecOrg org :
|
|
|
- execOrgList) {
|
|
|
- coreSafecheckPlanToExecOrgMapper.insert(new CoreSafecheckPlanToExecOrg(coreSafecheckPlan.getId(), org.getOrgId()));
|
|
|
- }
|
|
|
- }
|
|
|
+// List<Long> execOrgIdList = coreSafecheckPlanToExecOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToExecOrg>()
|
|
|
+// .eq(CoreSafecheckPlanToExecOrg::getPlanId, dto.getId())).stream().map(CoreSafecheckPlanToExecOrg::getOrgId).collect(Collectors.toList());
|
|
|
+ List<Long> childPlanExecOrgIds = getChildPlanExecOrgIds(coreSafecheckPlan, hsOrgs, parentPlanExecOrgs);
|
|
|
+ addPlanExecOrg(coreSafecheckPlan.getId(),childPlanExecOrgIds);
|
|
|
+
|
|
|
+
|
|
|
//再处理受检机构关系
|
|
|
- List<CoreSafecheckPlanToCheckOrg> checkOrgList = coreSafecheckPlanToCheckOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrg>()
|
|
|
- .eq(CoreSafecheckPlanToCheckOrg::getPlanId, dto.getId()));
|
|
|
- if (checkOrgList != null) {
|
|
|
- coreSafecheckPlanToCheckOrgMapper.deleteCoreSafecheckPlanToCheckOrgByPlanId(coreSafecheckPlan.getId());
|
|
|
- for (CoreSafecheckPlanToCheckOrg org :
|
|
|
- checkOrgList) {
|
|
|
- coreSafecheckPlanToCheckOrgMapper.insert(new CoreSafecheckPlanToCheckOrg(coreSafecheckPlan.getId(), org.getOrgId()));
|
|
|
- }
|
|
|
- }
|
|
|
+// List<Long> checkOrgIdList = coreSafecheckPlanToCheckOrgMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrg>()
|
|
|
+// .eq(CoreSafecheckPlanToCheckOrg::getPlanId, dto.getId())).stream().map(CoreSafecheckPlanToCheckOrg::getOrgId).collect(Collectors.toList());
|
|
|
+// List<Long> childPlanCheckOrgIds = getChildPlanExecOrgIds(coreSafecheckPlan, hsOrgs, parentPlanCheckOrgs);
|
|
|
+ addPlanCheckOrg(coreSafecheckPlan.getId(),childPlanCheckOrgIds);
|
|
|
+
|
|
|
//再处理受检机构类型
|
|
|
- List<CoreSafecheckPlanToCheckOrgType> checkOrgTypes = coreSafecheckPlanToCheckOrgTypeMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrgType>()
|
|
|
- .eq(CoreSafecheckPlanToCheckOrgType::getPlanId, dto.getId()));
|
|
|
- if (checkOrgTypes != null) {
|
|
|
- //删除当前计划的受检机构类型
|
|
|
- coreSafecheckPlanToCheckOrgTypeMapper.delete(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrgType>()
|
|
|
- .eq(CoreSafecheckPlanToCheckOrgType::getPlanId, coreSafecheckPlan.getId()));
|
|
|
- for (CoreSafecheckPlanToCheckOrgType type :
|
|
|
- checkOrgTypes) {
|
|
|
- coreSafecheckPlanToCheckOrgTypeMapper.insert(new CoreSafecheckPlanToCheckOrgType(coreSafecheckPlan.getId(), type.getTypeId()));
|
|
|
- }
|
|
|
- }
|
|
|
+ List<Integer> checkOrgTypes = coreSafecheckPlanToCheckOrgTypeMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrgType>()
|
|
|
+ .eq(CoreSafecheckPlanToCheckOrgType::getPlanId, dto.getId())).stream().map(CoreSafecheckPlanToCheckOrgType::getTypeId).collect(Collectors.toList());
|
|
|
+ addPlanCheckOrgType(coreSafecheckPlan.getId(),checkOrgTypes);
|
|
|
+// if (checkOrgTypes != null) {
|
|
|
+// //删除当前计划的受检机构类型
|
|
|
+// coreSafecheckPlanToCheckOrgTypeMapper.delete(new LambdaQueryWrapper<CoreSafecheckPlanToCheckOrgType>()
|
|
|
+// .eq(CoreSafecheckPlanToCheckOrgType::getPlanId, coreSafecheckPlan.getId()));
|
|
|
+// for (CoreSafecheckPlanToCheckOrgType type :
|
|
|
+// checkOrgTypes) {
|
|
|
+// coreSafecheckPlanToCheckOrgTypeMapper.insert(new CoreSafecheckPlanToCheckOrgType(coreSafecheckPlan.getId(), type.getTypeId()));
|
|
|
+// }
|
|
|
+// }
|
|
|
//再处理检查要点关系
|
|
|
|
|
|
//查询父计划的所有检查要点
|
|
|
@@ -298,8 +468,8 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
.eq(CoreSafecheckPlanToPoint::getPlanId, dto.getId()));
|
|
|
if (rpList != null) {
|
|
|
//删除父计划创建的检查要点
|
|
|
- coreSafecheckPlanToPointMapper.delete(new LambdaQueryWrapper<CoreSafecheckPlanToPoint>()
|
|
|
- .eq(CoreSafecheckPlanToPoint::getPlanId, coreSafecheckPlan.getId()));
|
|
|
+// coreSafecheckPlanToPointMapper.delete(new LambdaQueryWrapper<CoreSafecheckPlanToPoint>()
|
|
|
+// .eq(CoreSafecheckPlanToPoint::getPlanId, coreSafecheckPlan.getId()));
|
|
|
for (CoreSafecheckPlanToPoint s :
|
|
|
rpList) {
|
|
|
//插入父计划的所有检查要点
|
|
|
@@ -317,17 +487,18 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
coreSafecheckPlan.setEffectiveTime(effectiveTime);
|
|
|
baseMapper.updateById(coreSafecheckPlan);
|
|
|
// coreSafecheckPlan.setBuildTaskNow(coreSafecheckPlanMapper.selectById(dto.getId()).isBuildTaskNow());
|
|
|
- if (ObjectUtil.equal(oldPlan.getPlanStatus(), PlanStatus.DELETED.getCode())) {
|
|
|
- //停用时下发且立即生效,逻辑删除旧计划并生成新计划
|
|
|
- baseMapper.deleteById(coreSafecheckPlan);
|
|
|
- copySelfPlan(oldPlan.getId(), parentId);
|
|
|
- }
|
|
|
+// if (ObjectUtil.equal(oldPlan.getPlanStatus(), PlanStatus.DELETED.getCode())) {
|
|
|
+// //停用时下发且立即生效,逻辑删除旧计划并生成新计划
|
|
|
+// baseMapper.deleteById(coreSafecheckPlan);
|
|
|
+// copySelfPlan(oldPlan.getId(), parentId);
|
|
|
+// }
|
|
|
|
|
|
if (immediateEffect) {
|
|
|
safetyCheckJobBusiness.createTaskByPlans(hsPlans, dto.getId());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 获取生效日期
|
|
|
*
|
|
|
@@ -386,12 +557,12 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
} else if (ObjectUtil.equal(planStatus, PlanStatus.DELETED.getCode())) {
|
|
|
//停用状态下发,逻辑删除旧计划,并生成计划的副本,并更新任务名称和关联的计划id
|
|
|
baseMapper.updateById(plan);
|
|
|
- baseMapper.deleteById(plan.getId());
|
|
|
- Long newPlanId = IdWorker.getId(plan);
|
|
|
- copySelfPlan(id, newPlanId);
|
|
|
-
|
|
|
- CoreSafecheckPlan newPlan = baseMapper.selectById(newPlanId);
|
|
|
- newlist.add(newPlan);
|
|
|
+// baseMapper.deleteById(plan.getId());
|
|
|
+// Long newPlanId = IdWorker.getId(plan);
|
|
|
+// copySelfPlan(id, newPlanId);
|
|
|
+//
|
|
|
+// CoreSafecheckPlan newPlan = baseMapper.selectById(newPlanId);
|
|
|
+// newlist.add(newPlan);
|
|
|
}
|
|
|
} else {
|
|
|
baseMapper.updateById(plan);
|
|
|
@@ -555,6 +726,462 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
return coreSafecheckPlanMapper.selectList(new QueryWrapper<>(coreSafecheckPlan));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public int saveCoreSafecheckPlan(CoreSafecheckPlan coreSafecheckPlan) {
|
|
|
+ if (coreSafecheckPlan.getRulePointList().size() == 0) {
|
|
|
+ throw new RuntimeException("未选择检查项!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ObjectUtil.isNull(coreSafecheckPlan.getId()))
|
|
|
+ {
|
|
|
+ insertPlan(coreSafecheckPlan);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ Long planId = coreSafecheckPlan.getId();
|
|
|
+ Long returnId = updatePlan(coreSafecheckPlan);
|
|
|
+// childrenPlan(planId, returnId);
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改计划下的检查内容
|
|
|
+ * @param existPlan 当前已存在的计划
|
|
|
+ * @param itemList 新增的计划/编辑后新计划 后的检查内容
|
|
|
+ */
|
|
|
+ private void updatePlanPoint(CoreSafecheckPlan existPlan, List<SafetyCheckRulePointVo> itemList)
|
|
|
+ {
|
|
|
+ deletePlanPoint(existPlan.getId(),existPlan.getPlanCreateOrgId());
|
|
|
+ addPlanPoint(existPlan.getId(),itemList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deletePlanPoint(Long planId,Long createOrgId){
|
|
|
+// QueryWrapper<AppPlanToPoint> api = new QueryWrapper<>();
|
|
|
+// api.lambda().eq(AppPlanToPoint::getPlanId, planId).eq(AppPlanToPoint::getOfOrgId, createOrgId);
|
|
|
+ coreSafecheckPlanToPointMapper.deleteCoreSafecheckPlanToPointByPlanId(planId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addPlanPoint(Long planId,List<SafetyCheckRulePointVo> itemList)
|
|
|
+ {
|
|
|
+ if (CollectionUtil.isEmpty(itemList)) {
|
|
|
+ throw new RuntimeException("请选择检查要点");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CoreSafecheckPlanToPoint> planToPoints = new ArrayList<>();
|
|
|
+ for (SafetyCheckRulePointVo ruleItemVo : itemList) {
|
|
|
+ CoreSafecheckPlanToPoint item = new CoreSafecheckPlanToPoint();
|
|
|
+ item.setPointId(ruleItemVo.getId());
|
|
|
+ item.setPlanId(planId);
|
|
|
+ item.setPointScan(ruleItemVo.isPointScan());
|
|
|
+ item.setRequired(ruleItemVo.isRequired());
|
|
|
+ item.setOfOrgId(ruleItemVo.getOfOrgId());
|
|
|
+ planToPoints.add(item);
|
|
|
+// appPlanToItemMapper.insert(item);
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotEmpty(planToPoints))
|
|
|
+ {
|
|
|
+ coreSafecheckPlanToPointMapper.batchInsertData(planToPoints);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改计划下的检查角色
|
|
|
+ * @param plan 计划
|
|
|
+ * @param roleList 新增的计划/编辑后新计划 的角色
|
|
|
+ */
|
|
|
+ private void updatePlanRole(CoreSafecheckPlan plan,List<Long> roleList)
|
|
|
+ {
|
|
|
+ deletePlanRole(plan.getId());
|
|
|
+ addPlanRole(plan.getId(),roleList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deletePlanRole(Long planId){
|
|
|
+ coreSafecheckPlanToRoleMapper.deleteCoreSafecheckPlanToRoleByPlanId(planId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addPlanRole(Long planId,List<Long> roleList)
|
|
|
+ {
|
|
|
+ if(ObjectUtil.isEmpty(roleList)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<CoreSafecheckPlanToRole> planToRoles = new ArrayList<>();
|
|
|
+ for (Long roleId : roleList) {
|
|
|
+ CoreSafecheckPlanToRole temp = new CoreSafecheckPlanToRole();
|
|
|
+ temp.setRoleId(roleId);
|
|
|
+ temp.setPlanId(planId);
|
|
|
+ planToRoles.add(temp);
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotEmpty(planToRoles))
|
|
|
+ {
|
|
|
+ coreSafecheckPlanToRoleMapper.batchInsertData(planToRoles);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取子计划 对应的检查机构
|
|
|
+ *
|
|
|
+ * @param childPlan
|
|
|
+ * @param hsOrgs
|
|
|
+ * @param parentPlanCheckOrgs
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<Long> getChildPlanCheckOrgIds(CoreSafecheckPlan childPlan,List<SysOrg> hsOrgs,List<SysOrg> parentPlanCheckOrgs)
|
|
|
+ {
|
|
|
+ if(ObjectUtil.isEmpty(parentPlanCheckOrgs))
|
|
|
+ {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ SysOrg planOrg =null;
|
|
|
+ if(ObjectUtil.isNotEmpty(hsOrgs))
|
|
|
+ {
|
|
|
+ final Optional<SysOrg> planOrgOpt = hsOrgs.stream().filter(x -> ObjectUtil.equal(x.getId(), childPlan.getPlanOfOrgId())).findFirst();
|
|
|
+ if(planOrgOpt.isPresent())
|
|
|
+ {
|
|
|
+ planOrg = planOrgOpt.get();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ planOrg = orgService.selectSysOrgById(childPlan.getPlanOfOrgId(), SecurityConstants.INNER);
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNull(planOrg))
|
|
|
+ {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ String path =planOrg.getPath();
|
|
|
+ return parentPlanCheckOrgs.stream().filter(x -> x.getPath().contains(path)).map(x -> x.getId()).collect(toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Long> getChildPlanCheckOrgIds(Long planOfOrgId,List<SysOrg> hsOrgs,List<SysOrg> parentPlanCheckOrgs)
|
|
|
+ {
|
|
|
+ if(ObjectUtil.isEmpty(parentPlanCheckOrgs))
|
|
|
+ {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ SysOrg planOrg =null;
|
|
|
+ if(ObjectUtil.isNotEmpty(hsOrgs)){
|
|
|
+ final Optional<SysOrg> planOrgOpt = hsOrgs.stream().filter(x -> ObjectUtil.equal(x.getId(), planOfOrgId)).findFirst();
|
|
|
+ if(planOrgOpt.isPresent())
|
|
|
+ {
|
|
|
+ planOrg = planOrgOpt.get();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ planOrg = orgService.selectSysOrgById(planOfOrgId, SecurityConstants.INNER);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ObjectUtil.isNull(planOrg))
|
|
|
+ {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ String path =planOrg.getPath();
|
|
|
+ return parentPlanCheckOrgs.stream().filter(x -> x.getPath().contains(path)).map(x -> x.getId()).collect(toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取子计划 对应的具体检查机构
|
|
|
+ *
|
|
|
+ * @param childPlan
|
|
|
+ * @param hsOrgs
|
|
|
+ * @param parentPlanExecOrgs
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<Long> getChildPlanExecOrgIds(CoreSafecheckPlan childPlan,List<SysOrg> hsOrgs,List<SysOrg> parentPlanExecOrgs)
|
|
|
+ {
|
|
|
+ if(ObjectUtil.isEmpty(parentPlanExecOrgs) || ObjectUtil.isEmpty(hsOrgs))
|
|
|
+ {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ SysOrg planOrg =null;
|
|
|
+ final Optional<SysOrg> planOrgOpt = hsOrgs.stream().filter(x -> ObjectUtil.equal(x.getId(), childPlan.getPlanOfOrgId())).findFirst();
|
|
|
+ if(planOrgOpt.isPresent())
|
|
|
+ {
|
|
|
+ planOrg = planOrgOpt.get();
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ planOrg = orgService.selectSysOrgById(childPlan.getPlanOfOrgId(), SecurityConstants.INNER);
|
|
|
+ }
|
|
|
+ String path =planOrg.getPath();
|
|
|
+ return parentPlanExecOrgs.stream().filter(x -> x.getPath().contains(path)).map(x -> x.getId()).collect(toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改计划下的检查主体机构
|
|
|
+ * @param plan 计划
|
|
|
+ * @param orgList 新增的计划/编辑后新计划 的检查主体机构
|
|
|
+ */
|
|
|
+ private void updatePlanExecOrg(CoreSafecheckPlan plan,List<Long> orgList)
|
|
|
+ {
|
|
|
+ deletePlanExecOrg(plan.getId());
|
|
|
+ addPlanExecOrg(plan.getId(),orgList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deletePlanExecOrg(Long planId){
|
|
|
+ coreSafecheckPlanToExecOrgMapper.deleteCoreSafecheckPlanToExecOrgByPlanId(planId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addPlanExecOrg(Long planId,List<Long> orgList)
|
|
|
+ {
|
|
|
+ if(ObjectUtil.isEmpty(orgList)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<CoreSafecheckPlanToExecOrg> planToExecOrgs = new ArrayList<>();
|
|
|
+ for (Long orgId : orgList) {
|
|
|
+ CoreSafecheckPlanToExecOrg execOrg = new CoreSafecheckPlanToExecOrg();
|
|
|
+ execOrg.setOrgId(orgId);
|
|
|
+ execOrg.setPlanId(planId);
|
|
|
+ planToExecOrgs.add(execOrg);
|
|
|
+// appPlanToExecOrgMapper.insert(execOrg);
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotEmpty(planToExecOrgs))
|
|
|
+ {
|
|
|
+ coreSafecheckPlanToExecOrgMapper.batchInsertData(planToExecOrgs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改计划下的受检机构
|
|
|
+ * @param plan 计划
|
|
|
+ * @param orgList 新增的计划/编辑后新计划 的受检机构
|
|
|
+ */
|
|
|
+ private void updatePlanCheckOrg(CoreSafecheckPlan plan,List<Long> orgList)
|
|
|
+ {
|
|
|
+ deletePlanCheckOrg(plan.getId());
|
|
|
+ addPlanCheckOrg(plan.getId(),orgList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deletePlanCheckOrg(Long planId){
|
|
|
+ coreSafecheckPlanToCheckOrgMapper.deleteCoreSafecheckPlanToCheckOrgByPlanId(planId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addPlanCheckOrg(Long planId,List<Long> orgList)
|
|
|
+ {
|
|
|
+ if(ObjectUtil.isEmpty(orgList)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<CoreSafecheckPlanToCheckOrg> planToCheckOrgs = new ArrayList<>();
|
|
|
+ for (Long orgId : orgList) {
|
|
|
+ CoreSafecheckPlanToCheckOrg execOrg = new CoreSafecheckPlanToCheckOrg();
|
|
|
+ execOrg.setOrgId(orgId);
|
|
|
+ execOrg.setPlanId(planId);
|
|
|
+ planToCheckOrgs.add(execOrg);
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotEmpty(planToCheckOrgs))
|
|
|
+ {
|
|
|
+ coreSafecheckPlanToCheckOrgMapper.batchInsertData(planToCheckOrgs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改计划下的受检机构类型
|
|
|
+ * @param plan 计划
|
|
|
+ * @param typeList 新增的计划/编辑后新计划 的受检机构类型
|
|
|
+ */
|
|
|
+ private void updatePlanCheckOrgType(CoreSafecheckPlan plan,List<Integer> typeList)
|
|
|
+ {
|
|
|
+ deletePlanCheckOrgType(plan.getId());
|
|
|
+ addPlanCheckOrgType(plan.getId(),typeList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deletePlanCheckOrgType(Long planId){
|
|
|
+ coreSafecheckPlanToCheckOrgTypeMapper.deleteCoreSafecheckPlanToCheckOrgTypeByPlanId(planId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addPlanCheckOrgType(Long planId,List<Integer> typeList)
|
|
|
+ {
|
|
|
+ if(ObjectUtil.isEmpty(typeList)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<CoreSafecheckPlanToCheckOrgType> planToCheckOrgTypes = new ArrayList<>();
|
|
|
+ for (Integer typeId : typeList) {
|
|
|
+ CoreSafecheckPlanToCheckOrgType type = new CoreSafecheckPlanToCheckOrgType();
|
|
|
+ type.setTypeId(typeId);
|
|
|
+ type.setPlanId(planId);
|
|
|
+ planToCheckOrgTypes.add(type);
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotEmpty(planToCheckOrgTypes))
|
|
|
+ {
|
|
|
+ coreSafecheckPlanToCheckOrgTypeMapper.batchInsertData(planToCheckOrgTypes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Long insertPlan(CoreSafecheckPlan coreSafecheckPlan)
|
|
|
+ {
|
|
|
+ Long returnId = 0L;
|
|
|
+ Long id = IdWorker.getId(coreSafecheckPlan);
|
|
|
+ coreSafecheckPlan.setId(id);
|
|
|
+ coreSafecheckPlan.setSolidId(id);
|
|
|
+ coreSafecheckPlan.setParentSolidId(-1L);
|
|
|
+ //先处理检查计划
|
|
|
+ coreSafecheckPlan.setPlanOfOrgId(coreSafecheckPlan.getPlanCreateOrgId());
|
|
|
+ coreSafecheckPlan.setIsDeleted("0");
|
|
|
+ coreSafecheckPlan.setCreateTime(DateUtils.getNowDate());
|
|
|
+ coreSafecheckPlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ coreSafecheckPlan.setModifiedBy(SecurityUtils.getUserId());
|
|
|
+ coreSafecheckPlan.setDistribute("0");
|
|
|
+ coreSafecheckPlan.setPlanStatus(0);
|
|
|
+
|
|
|
+ //计划所属机构类型
|
|
|
+ coreSafecheckPlan.setPlanOfOrgType(orgService.selectSysOrgById(coreSafecheckPlan.getPlanOfOrgId(), SecurityConstants.INNER).getType());
|
|
|
+ coreSafecheckPlanMapper.insert(coreSafecheckPlan);
|
|
|
+ returnId = coreSafecheckPlan.getId();
|
|
|
+
|
|
|
+ //计划检查人员
|
|
|
+ addPlanRole(returnId,coreSafecheckPlan.getRoleIds());
|
|
|
+ //检查内容
|
|
|
+ addPlanPoint(returnId,coreSafecheckPlan.getRulePointList());
|
|
|
+ //检查主体
|
|
|
+ addPlanExecOrg(returnId,coreSafecheckPlan.getExecOrgIds());
|
|
|
+ //受检机构类型
|
|
|
+ addPlanCheckOrgType(returnId,coreSafecheckPlan.getCheckOrgTypes());
|
|
|
+ //受检机构
|
|
|
+ addPlanCheckOrg(returnId,coreSafecheckPlan.getCheckOrgIds());
|
|
|
+
|
|
|
+ return returnId;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Long updatePlan(CoreSafecheckPlan coreSafecheckPlan)
|
|
|
+ {
|
|
|
+ CoreSafecheckPlan oldPlan = baseMapper.get(coreSafecheckPlan.getId());
|
|
|
+ Integer planStatus = oldPlan.getPlanStatus();
|
|
|
+ //先克隆旧的数据
|
|
|
+ if (needCopyOnEdit(oldPlan)) {
|
|
|
+ baseMapper.deleteById(coreSafecheckPlan.getId());
|
|
|
+
|
|
|
+ Long newPlanId = IdWorker.getId(coreSafecheckPlan);
|
|
|
+ copySelfPlan(coreSafecheckPlan.getId(), newPlanId);
|
|
|
+ coreSafecheckPlan.setId(newPlanId);
|
|
|
+ }
|
|
|
+
|
|
|
+ coreSafecheckPlan.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ coreSafecheckPlan.setModifiedBy(SecurityUtils.getUserId());
|
|
|
+ coreSafecheckPlan.setPlanStatus(null);
|
|
|
+ coreSafecheckPlan.setPlanCreateOrgId(null);
|
|
|
+ coreSafecheckPlanMapper.updateById(coreSafecheckPlan);
|
|
|
+
|
|
|
+ updatePlanRole(coreSafecheckPlan,coreSafecheckPlan.getRoleIds());
|
|
|
+ updatePlanPoint(coreSafecheckPlan,coreSafecheckPlan.getRulePointList());
|
|
|
+ updatePlanExecOrg(coreSafecheckPlan,coreSafecheckPlan.getExecOrgIds());
|
|
|
+ updatePlanCheckOrgType(coreSafecheckPlan,coreSafecheckPlan.getCheckOrgTypes());
|
|
|
+ updatePlanCheckOrg(coreSafecheckPlan,coreSafecheckPlan.getCheckOrgIds());
|
|
|
+
|
|
|
+ if (needRebuildOnEdit(coreSafecheckPlan, planStatus, coreSafecheckPlan.getTaskHasCompleted())) {
|
|
|
+ CoreSafecheckPlan plan = baseMapper.selectById(coreSafecheckPlan.getId());
|
|
|
+ safetyCheckJobBusiness.createTaskByPlans(Arrays.asList(plan));
|
|
|
+ }
|
|
|
+ updatePlanChildren(oldPlan.getId(),coreSafecheckPlan.getId(),oldPlan,coreSafecheckPlan);
|
|
|
+
|
|
|
+ return coreSafecheckPlan.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void updatePlanChildren(Long oldPlanId, Long newPlanId,CoreSafecheckPlan oldParentPlan,CoreSafecheckPlan newParentPlan) {
|
|
|
+
|
|
|
+ List<CoreSafecheckPlan> childrenList = baseMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlan>()
|
|
|
+ .eq(CoreSafecheckPlan::getParentId, oldPlanId));
|
|
|
+
|
|
|
+ // 草稿状态下编辑主计划 、 行社计划、 执行机构是省联社/办事处 时没有子计划
|
|
|
+ if(ObjectUtil.isEmpty(childrenList))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改后 受检机构对应的行社机构
|
|
|
+ List<SysOrg> hsOrgs =null;
|
|
|
+ //修改后 主计划检查机构对象
|
|
|
+ List<SysOrg> parentPlanExecOrgs =null;
|
|
|
+
|
|
|
+ //修改后 主计划受检机构对象
|
|
|
+ List<SysOrg> parentPlanCheckOrgs =null;
|
|
|
+
|
|
|
+ if(ObjectUtil.isNotEmpty(newParentPlan.getExecOrgIds()))
|
|
|
+ {
|
|
|
+ hsOrgs= orgService.selectParentHs(newParentPlan.getExecOrgIds(), SecurityConstants.INNER);
|
|
|
+ parentPlanExecOrgs = orgService.selectByOrgIdList(newParentPlan.getExecOrgIds(), SecurityConstants.INNER);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ObjectUtil.isNotEmpty(newParentPlan.getCheckOrgIds()))
|
|
|
+ {
|
|
|
+ parentPlanCheckOrgs= orgService.selectByOrgIdList(newParentPlan.getCheckOrgIds(), SecurityConstants.INNER);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<CoreSafecheckPlan> needRebuildPlans = new ArrayList<>();
|
|
|
+ for (CoreSafecheckPlan p : childrenList) {
|
|
|
+
|
|
|
+ // 找出历史子计划在修改后应创建子计划列表中不存在的删除掉
|
|
|
+ if(ObjectUtil.isNotEmpty(hsOrgs) && !hsOrgs.stream().anyMatch(y -> ObjectUtil.equal(y.getId(), p.getPlanOfOrgId())))
|
|
|
+ {
|
|
|
+ baseMapper.deleteById(p.getId());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //计划选择了具体受检机构,但是根据检查主体获取的行社子计划下没有对应的受检机构,应删除该条子计划
|
|
|
+ if(ObjectUtil.isNotEmpty(parentPlanCheckOrgs))
|
|
|
+ {
|
|
|
+ List<Long> childPlanCheckOrgIds = getChildPlanCheckOrgIds(p, hsOrgs, parentPlanCheckOrgs);
|
|
|
+ if(ObjectUtil.isEmpty(childPlanCheckOrgIds))
|
|
|
+ {
|
|
|
+ baseMapper.deleteById(p.getId());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CoreSafecheckPlan child = p;
|
|
|
+ if (needCopyOnEdit(oldParentPlan)) {
|
|
|
+ //使用中状态且立即生效,复制副本
|
|
|
+ Long newChildPlanId = IdWorker.getId(p);
|
|
|
+ copyChildPlan(p.getId(), newChildPlanId, newPlanId);
|
|
|
+
|
|
|
+// baseMapper.updateById(p);
|
|
|
+ baseMapper.deleteById(p.getId());
|
|
|
+
|
|
|
+ child = baseMapper.selectById(newChildPlanId);
|
|
|
+ }
|
|
|
+ if (needRebuildOnEdit(p, p.getPlanStatus(), oldParentPlan.getTaskHasCompleted())) {
|
|
|
+ needRebuildPlans.add(child);
|
|
|
+ }
|
|
|
+ child.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ child.setModifiedBy(SecurityUtils.getUserId());
|
|
|
+ child.setPlanName(newParentPlan.getPlanName());
|
|
|
+// p.setCheckOrgType(coreSafecheckPlan.getCheckOrgType());
|
|
|
+ child.setCheckType(newParentPlan.getCheckType());
|
|
|
+ child.setCount(child.getCount() > newParentPlan.getCount() ? child.getCount() : newParentPlan.getCount());
|
|
|
+ child.setDescription(newParentPlan.getDescription());
|
|
|
+ child.setExecOrgType(newParentPlan.getExecOrgType());
|
|
|
+ child.setPlanCycle(newParentPlan.getPlanCycle());
|
|
|
+// p.setPlanStatus(coreSafecheckPlan.getPlanStatus());
|
|
|
+ child.setSourceType(newParentPlan.getSourceType());
|
|
|
+ baseMapper.updateById(child);
|
|
|
+
|
|
|
+
|
|
|
+ //拿到父计划的所有角色映射
|
|
|
+ updatePlanRole(child,newParentPlan.getRoleIds());
|
|
|
+
|
|
|
+ //再处理检查机构关系
|
|
|
+ List<Long> childPlanExecOrgIds = getChildPlanExecOrgIds(child, hsOrgs, parentPlanExecOrgs);
|
|
|
+ updatePlanExecOrg(child,childPlanExecOrgIds);
|
|
|
+
|
|
|
+ //再处理受检机构关系
|
|
|
+ List<Long> childPlanCheckOrgIds = getChildPlanCheckOrgIds(child, hsOrgs, parentPlanCheckOrgs);
|
|
|
+ updatePlanCheckOrg(child,childPlanCheckOrgIds);
|
|
|
+
|
|
|
+ //再处理受检机构类型
|
|
|
+ updatePlanCheckOrgType(child,newParentPlan.getCheckOrgTypes());
|
|
|
+
|
|
|
+ //再处理子计划检查要点关系
|
|
|
+ //查询计划id为当前父计划的id,所属机构id为当前父计划所属机构id的数据
|
|
|
+ updatePlanPoint(child,newParentPlan.getRulePointList());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(needRebuildPlans)) {
|
|
|
+ safetyCheckJobBusiness.createTaskByPlans(needRebuildPlans);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 新增常规安全检查计划
|
|
|
*
|
|
|
@@ -678,10 +1305,6 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
//拿到所有子计划
|
|
|
List<CoreSafecheckPlan> children = baseMapper.selectList(new LambdaQueryWrapper<CoreSafecheckPlan>()
|
|
|
.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));
|
|
|
-
|
|
|
CoreSafecheckPlan coreSafecheckPlan = baseMapper.selectById(newPlanId);
|
|
|
List<CoreSafecheckPlan> needRebuildPlans = new ArrayList<>();
|
|
|
for (CoreSafecheckPlan p :
|
|
|
@@ -808,7 +1431,8 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
* <p>
|
|
|
* 4.停用,本周期之前停用,不需要
|
|
|
* 5.停用,本周期停用,需要
|
|
|
- * 6.草稿,不需要
|
|
|
+ * 6.停用,本周期停用 且 生效时间大于当前时间 ,不需要(证明已经编辑过了)
|
|
|
+ * 7.草稿,不需要
|
|
|
*
|
|
|
* @param plan
|
|
|
* @return
|
|
|
@@ -834,9 +1458,17 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
|
|
|
return false;
|
|
|
} else if (ObjectUtil.equal(plan.getPlanStatus(), PlanStatus.DELETED.getCode())
|
|
|
&& dateRange.getStartTime().before(plan.getWithdrawTime())
|
|
|
- && dateRange.getEndTime().after(plan.getWithdrawTime())) {
|
|
|
+ && dateRange.getEndTime().after(plan.getWithdrawTime())
|
|
|
+ && new Date().after(plan.getEffectiveTime())) {
|
|
|
return true;
|
|
|
- } else if (ObjectUtil.equal(plan.getPlanStatus(), PlanStatus.DRAFT.getCode())) {
|
|
|
+ } else if (ObjectUtil.equal(plan.getPlanStatus(), PlanStatus.DELETED.getCode())
|
|
|
+ && dateRange.getStartTime().before(plan.getWithdrawTime())
|
|
|
+ && dateRange.getEndTime().after(plan.getWithdrawTime())
|
|
|
+ && new Date().before(plan.getEffectiveTime())
|
|
|
+ ) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else if (ObjectUtil.equal(plan.getPlanStatus(), PlanStatus.DRAFT.getCode())) {
|
|
|
return false;
|
|
|
} else {
|
|
|
return false;
|