Commit 897b8d6d authored by 吴俊凯's avatar 吴俊凯

Merge branch 'dev_upgrade-1225' into dev_upgrade-1225-wjk

# Conflicts: # YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/dao/repository/IPlanOperationRecordDao.java # YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ContingencyPlanServiceImpl.java 冲突解决
parents 42f8ab70 8ad9e5cd
...@@ -36,5 +36,17 @@ public class PlanRule extends BasicEntity { ...@@ -36,5 +36,17 @@ public class PlanRule extends BasicEntity {
@Column(name="is_delete") @Column(name="is_delete")
private Boolean isDelete; private Boolean isDelete;
/**
* 是否删除
*/
@Column(name="rule_name")
private String ruleName;
/**
* 是否删除
*/
@Column(name="pic_url")
private String picUrl;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
\ No newline at end of file
...@@ -78,8 +78,8 @@ public class ContingencyPlanController extends BaseController { ...@@ -78,8 +78,8 @@ public class ContingencyPlanController extends BaseController {
@GetMapping(value = "/page", produces = "application/json;charset=UTF-8") @GetMapping(value = "/page", produces = "application/json;charset=UTF-8")
public ResponseModel pageFilter(@RequestParam(value = "current") int current, public ResponseModel pageFilter(@RequestParam(value = "current") int current,
@RequestParam(value = "planName", required = false) String planName, @RequestParam(value = "planName", required = false) String planName,
@RequestParam(value = "classifyId", required = false) Long[] classifyId, @RequestParam(value = "classifyId", required = false) Long classifyId,
@RequestParam(value = "planRange", required = false) String[] planRange, @RequestParam(value = "planRange", required = false) List<String> planRange,
@RequestParam(value = "editOrgName", required = false) String editOrgName, @RequestParam(value = "editOrgName", required = false) String editOrgName,
@RequestParam(value = "implementationTimeLeft", required = false) Date implementationTimeLeft, @RequestParam(value = "implementationTimeLeft", required = false) Date implementationTimeLeft,
@RequestParam(value = "implementationTimeRight", required = false) Date implementationTimeRight, @RequestParam(value = "implementationTimeRight", required = false) Date implementationTimeRight,
......
package com.yeejoin.amos.fas.business.controller; package com.yeejoin.amos.fas.business.controller;
import com.yeejoin.amos.fas.business.service.intfc.PlanClassifyTreeService; import com.yeejoin.amos.fas.business.service.intfc.IPlanClassifyTreeService;
import com.yeejoin.amos.fas.business.vo.PlanClassifyTreeVo; import com.yeejoin.amos.fas.business.vo.PlanClassifyTreeVo;
import com.yeejoin.amos.fas.business.vo.ReginParams; import com.yeejoin.amos.fas.business.vo.ReginParams;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil2; import com.yeejoin.amos.fas.core.util.CommonResponseUtil2;
...@@ -20,7 +20,7 @@ import java.util.Collection; ...@@ -20,7 +20,7 @@ import java.util.Collection;
public class PlanClassifyTreeController extends BaseController { public class PlanClassifyTreeController extends BaseController {
@Autowired @Autowired
private PlanClassifyTreeService planClassifyTreeService; private IPlanClassifyTreeService planClassifyTreeService;
@ApiOperation(value = "创建分类") @ApiOperation(value = "创建分类")
@RequestMapping(value = "/save", method = RequestMethod.POST) @RequestMapping(value = "/save", method = RequestMethod.POST)
......
...@@ -36,12 +36,12 @@ public interface PlanDetailMapper { ...@@ -36,12 +36,12 @@ public interface PlanDetailMapper {
* 筛选预案获得总数 * 筛选预案获得总数
* @return * @return
*/ */
Integer filterCount(@Param("planName") String planName, @Param("classifyId") Long[] classifyId, @Param("planRange") String[] planRange, @Param("editOrgName") String editOrgName, @Param("implementationTimeLeft") Date implementationTimeLeft, @Param("implementationTimeRight") Date implementationTimeRight); Integer filterCount(@Param("planName") String planName, @Param("classifyId") List<Long> classifyId, @Param("planRange") List<String> planRange, @Param("editOrgName") String editOrgName, @Param("implementationTimeLeft") Date implementationTimeLeft, @Param("implementationTimeRight") Date implementationTimeRight);
/** /**
* 筛选预案获得分页记录 * 筛选预案获得分页记录
* @return * @return
*/ */
List<PlanDetailVo> filterList(@Param("planName") String planName, @Param("classifyId") Long[] classifyId, @Param("planRange") String[] planRange, @Param("editOrgName") String editOrgName, @Param("implementationTimeLeft") Date implementationTimeLeft, @Param("implementationTimeRight") Date implementationTimeRight, @Param("start") int start, @Param("size") int size); List<PlanDetailVo> filterList(@Param("planName") String planName, @Param("classifyId") List<Long> classifyId, @Param("planRange") List<String> planRange, @Param("editOrgName") String editOrgName, @Param("implementationTimeLeft") Date implementationTimeLeft, @Param("implementationTimeRight") Date implementationTimeRight, @Param("start") int start, @Param("size") int size);
} }
package com.yeejoin.amos.fas.business.dao.repository; package com.yeejoin.amos.fas.business.dao.repository;
import com.yeejoin.amos.fas.business.vo.PlanClassifyTreeVo;
import com.yeejoin.amos.fas.dao.entity.PlanClassifyTree; import com.yeejoin.amos.fas.dao.entity.PlanClassifyTree;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -13,4 +14,6 @@ public interface IPlanClassifyTreeDao extends BaseDao<PlanClassifyTree, Long> { ...@@ -13,4 +14,6 @@ public interface IPlanClassifyTreeDao extends BaseDao<PlanClassifyTree, Long> {
@Query(value = "select * from c_plan_classify_tree where parent_id = ?1",nativeQuery = true) @Query(value = "select * from c_plan_classify_tree where parent_id = ?1",nativeQuery = true)
List<PlanClassifyTree> findByParentId(Long parentId); List<PlanClassifyTree> findByParentId(Long parentId);
@Query(value = "select * from c_plan_classify_tree",nativeQuery = true)
List<PlanClassifyTree> getAll();
} }
...@@ -18,5 +18,7 @@ public interface IPlanDocDao extends BaseDao<PlanDoc, Long> { ...@@ -18,5 +18,7 @@ public interface IPlanDocDao extends BaseDao<PlanDoc, Long> {
List<PlanDoc> getPlanDocsByPlanId(Long planId); List<PlanDoc> getPlanDocsByPlanId(Long planId);
List<PlanDoc> findAllByPlanIdIn(List<Long> planId);
List<PlanDoc> findAllByIsDelete(Boolean isDelete); List<PlanDoc> findAllByIsDelete(Boolean isDelete);
} }
...@@ -24,4 +24,6 @@ public interface IPlanEquipmentDao extends BaseDao<PlanEquipment, Long> { ...@@ -24,4 +24,6 @@ public interface IPlanEquipmentDao extends BaseDao<PlanEquipment, Long> {
List<PlanEquipment> findByPlanId(Long planId); List<PlanEquipment> findByPlanId(Long planId);
List<PlanEquipment> findAllByIsDelete(Boolean isDelete); List<PlanEquipment> findAllByIsDelete(Boolean isDelete);
List<PlanEquipment> findAllByPlanIdIn(List<Long> planId);
} }
...@@ -16,6 +16,11 @@ import java.util.List; ...@@ -16,6 +16,11 @@ import java.util.List;
public interface IPlanOperationRecordDao extends BaseDao<PlanOperationRecord, Long> { public interface IPlanOperationRecordDao extends BaseDao<PlanOperationRecord, Long> {
@Query(value="SELECT * from c_plan_operation_record where batch_no = ?1 AND is_delete = 0 ", nativeQuery = true) @Query(value="SELECT * from c_plan_operation_record where batch_no = ?1 AND is_delete = 0 ", nativeQuery = true)
PlanOperationRecord findByBatchNo(String batchNo); PlanOperationRecord findByBatchNo(String batchNo);
@Query(value="SELECT * from c_plan_operation_record where plan_id = ?1 AND is_delete = 0 AND status = 0 ORDER BY create_date DESC", nativeQuery = true) @Query(value="SELECT * from c_plan_operation_record where plan_id = ?1 AND is_delete = 0 AND status = 0 ORDER BY create_date DESC", nativeQuery = true)
List<PlanOperationRecord> findByPlanId(Long planId); List<PlanOperationRecord> findByPlanId1(Long planId);
int countByPlanId(Long planId);
} }
package com.yeejoin.amos.fas.business.dao.repository; package com.yeejoin.amos.fas.business.dao.repository;
import com.yeejoin.amos.fas.dao.entity.PlanDoc;
import com.yeejoin.amos.fas.dao.entity.PlanRule; import com.yeejoin.amos.fas.dao.entity.PlanRule;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -20,4 +21,6 @@ public interface IPlanRuleDao extends BaseDao<PlanRule, Long>{ ...@@ -20,4 +21,6 @@ public interface IPlanRuleDao extends BaseDao<PlanRule, Long>{
List<PlanRule> getPlanDocsByPlanId(Long planId); List<PlanRule> getPlanDocsByPlanId(Long planId);
List<PlanRule> findAllByIsDelete(Boolean isDelete); List<PlanRule> findAllByIsDelete(Boolean isDelete);
List<PlanRule> findAllByPlanIdIn(List<Long> planIds);
} }
...@@ -5,10 +5,8 @@ import com.yeejoin.amos.component.rule.config.ClazzUtils; ...@@ -5,10 +5,8 @@ import com.yeejoin.amos.component.rule.config.ClazzUtils;
import com.yeejoin.amos.fas.business.dao.mapper.*; import com.yeejoin.amos.fas.business.dao.mapper.*;
import com.yeejoin.amos.fas.business.dao.repository.*; import com.yeejoin.amos.fas.business.dao.repository.*;
import com.yeejoin.amos.fas.business.param.AlarmParam; import com.yeejoin.amos.fas.business.param.AlarmParam;
import com.yeejoin.amos.fas.business.service.intfc.IContingencyPlanService; import com.yeejoin.amos.fas.business.service.intfc.*;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentHandlerService; import com.yeejoin.amos.fas.business.util.TreeUtil;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService;
import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService;
import com.yeejoin.amos.fas.business.vo.*; import com.yeejoin.amos.fas.business.vo.*;
import com.yeejoin.amos.fas.common.enums.ContingencyPlanStatusEnum; import com.yeejoin.amos.fas.common.enums.ContingencyPlanStatusEnum;
import com.yeejoin.amos.fas.common.enums.EquipmentRiskTypeEnum; import com.yeejoin.amos.fas.common.enums.EquipmentRiskTypeEnum;
...@@ -29,6 +27,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -29,6 +27,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.*; import java.util.*;
...@@ -74,12 +73,14 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -74,12 +73,14 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
private final PlanRuleMapper planRuleMapper; private final PlanRuleMapper planRuleMapper;
private final PlanDocMapper planDocMapper; private final PlanDocMapper planDocMapper;
private final EmqKeeper emqKeeper; private final EmqKeeper emqKeeper;
private final IPlanClassifyTreeService planClassifyTreeService;
@Autowired @Autowired
public ContingencyPlanServiceImpl(IPlanDetailDao planDetailDao, IPlanDocDao planDocDao, IPlanEquipmentDao planEquipmentDao, public ContingencyPlanServiceImpl(IPlanDetailDao planDetailDao, IPlanDocDao planDocDao, IPlanEquipmentDao planEquipmentDao,
IPlanRuleDao planRuleDao, IPlanClassifyTreeDao classifyTreeDao, PlanDetailMapper planDetailMapper, IPlanRuleDao planRuleDao, IPlanClassifyTreeDao classifyTreeDao, PlanDetailMapper planDetailMapper,
PlanEquipmentMapper planEquipmentMapper, PlanRuleMapper planRuleMapper, PlanDocMapper planDocMapper, PlanEquipmentMapper planEquipmentMapper, PlanRuleMapper planRuleMapper, PlanDocMapper planDocMapper,
PlanOperationRecordMapper planOperationRecordMapper, EmqKeeper emqKeeper) { PlanOperationRecordMapper planOperationRecordMapper, IPlanClassifyTreeService planClassifyTreeService,
EmqKeeper emqKeeper) {
this.planDetailDao = planDetailDao; this.planDetailDao = planDetailDao;
this.planDocDao = planDocDao; this.planDocDao = planDocDao;
this.planEquipmentDao = planEquipmentDao; this.planEquipmentDao = planEquipmentDao;
...@@ -90,6 +91,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -90,6 +91,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
this.planRuleMapper = planRuleMapper; this.planRuleMapper = planRuleMapper;
this.planDocMapper = planDocMapper; this.planDocMapper = planDocMapper;
this.planOperationRecordMapper = planOperationRecordMapper; this.planOperationRecordMapper = planOperationRecordMapper;
this.planClassifyTreeService = planClassifyTreeService;
this.emqKeeper = emqKeeper; this.emqKeeper = emqKeeper;
} }
...@@ -100,7 +102,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -100,7 +102,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
//状态校验 //状态校验
ReserveEnum reserveEnum = this.runCheck(vo); ReserveEnum reserveEnum = this.runCheck(vo);
if(ReserveEnum.THISRUNNING.getStatus() ==reserveEnum.getStatus()){ if(ReserveEnum.THISRUNNING.getStatus() ==reserveEnum.getStatus()){
List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId(Long.valueOf(vo.getPlanId())); List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId()));
result.setMessage(ReserveEnum.THISRUNNING.getText()); result.setMessage(ReserveEnum.THISRUNNING.getText());
result.setBatchNo(recordList.get(0).getBatchNo()); result.setBatchNo(recordList.get(0).getBatchNo());
return result; return result;
...@@ -220,7 +222,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -220,7 +222,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
public ReserveEnum runCheck(ContingencyPlanParamVo vo){ public ReserveEnum runCheck(ContingencyPlanParamVo vo){
if(EquipmentRiskTypeEnum.HZGJ.getCode().equals(vo.getRiskType()) || StringUtils.isBlank(vo.getRiskType())) { if(EquipmentRiskTypeEnum.HZGJ.getCode().equals(vo.getRiskType()) || StringUtils.isBlank(vo.getRiskType())) {
List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId(Long.valueOf(vo.getPlanId())); List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId()));
if(recordList.size()>0){ if(recordList.size()>0){
return ReserveEnum.THISRUNNING; return ReserveEnum.THISRUNNING;
} }
...@@ -269,13 +271,13 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -269,13 +271,13 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
} }
@Override @Override
public Page recordListByPage(int current, int pageSize,String planName) { public Page recordListByPage(int current, int pageSize, String planName) {
Map<String,Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("planName",planName); params.put("planName", planName);
params.put("offset",(current-1)*pageSize); params.put("offset", (current - 1) * pageSize);
params.put("pageSize",pageSize); params.put("pageSize", pageSize);
List<HashMap<String,Object>> result = planOperationRecordMapper.PlanOperationRecordListByPage(params); List<HashMap<String, Object>> result = planOperationRecordMapper.PlanOperationRecordListByPage(params);
Integer count = planOperationRecordMapper.PlanOperationRecordListByCount(params); Integer count = planOperationRecordMapper.PlanOperationRecordListByCount(params);
Page page = new Page(); Page page = new Page();
page.setRecords(result); page.setRecords(result);
page.setTotal(count); page.setTotal(count);
...@@ -349,6 +351,9 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -349,6 +351,9 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
} else { } else {
throw new YeeException("不可编辑的状态"); throw new YeeException("不可编辑的状态");
} }
if (planDetail.getIsDelete() == null) {
planDetail.setIsDelete(false);
}
PlanDetail planEntity = new PlanDetail(); PlanDetail planEntity = new PlanDetail();
BeanUtils.copyProperties(planDetail, planEntity); BeanUtils.copyProperties(planDetail, planEntity);
planDetailDao.saveAndFlush(planEntity); planDetailDao.saveAndFlush(planEntity);
...@@ -359,13 +364,13 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -359,13 +364,13 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
planDocDao.save(planDoc); planDocDao.save(planDoc);
planRule.setPlanId(planId); planRule.setPlanId(planId);
planDoc.setIsDelete(false); planRule.setIsDelete(false);
planRuleDao.deleteByPlanId(planId); planRuleDao.deleteByPlanId(planId);
planRuleDao.save(planRule); planRuleDao.save(planRule);
planEquipment.forEach(equipment -> { planEquipment.forEach(equipment -> {
equipment.setPlanId(planId); equipment.setPlanId(planId);
planDoc.setIsDelete(false); equipment.setIsDelete(false);
}); });
planEquipmentDao.deleteByPlanId(planId); planEquipmentDao.deleteByPlanId(planId);
planEquipmentDao.saveAll(planEquipment); planEquipmentDao.saveAll(planEquipment);
...@@ -390,8 +395,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -390,8 +395,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
} }
List<PlanEquipment> equipments = planEquipmentDao.getPlanDocsByPlanId(id); List<PlanEquipment> equipments = planEquipmentDao.getPlanDocsByPlanId(id);
detailVo.setPlanEquipment(equipments); detailVo.setPlanEquipment(equipments);
//TODO-设置执行次数 // 设置执行次数
detailVo.setExecutionTimes(0); detailVo.setExecutionTimes(planOperationRecordDao.countByPlanId(id));
PlanClassifyTree classifyTree = classifyTreeDao.findById(detailVo.getClassifyId()).orElse(null); PlanClassifyTree classifyTree = classifyTreeDao.findById(detailVo.getClassifyId()).orElse(null);
if (null != classifyTree) { if (null != classifyTree) {
detailVo.setClassifyName(classifyTree.getClassifyName()); detailVo.setClassifyName(classifyTree.getClassifyName());
...@@ -404,9 +409,10 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -404,9 +409,10 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
List<PlanDetail> planDetailList = planDetailDao.getPlanDetailsByIdInAndIsDelete(idList, false); List<PlanDetail> planDetailList = planDetailDao.getPlanDetailsByIdInAndIsDelete(idList, false);
if (!planDetailList.isEmpty()) { if (!planDetailList.isEmpty()) {
planDetailList.forEach(plan -> { planDetailList.forEach(plan -> {
if (ContingencyPlanStatusEnum.getEnum(plan.getStatus()) != ContingencyPlanStatusEnum.DRAFT ContingencyPlanStatusEnum status = ContingencyPlanStatusEnum.getEnum(plan.getStatus());
&& ContingencyPlanStatusEnum.getEnum(plan.getStatus()) != ContingencyPlanStatusEnum.AVAILABLE if (status != ContingencyPlanStatusEnum.DRAFT
&& ContingencyPlanStatusEnum.getEnum(plan.getStatus()) != ContingencyPlanStatusEnum.NOAVAILABLE) { && status != ContingencyPlanStatusEnum.AVAILABLE
&& status != ContingencyPlanStatusEnum.NOAVAILABLE) {
throw new YeeException("包含不可启用的状态"); throw new YeeException("包含不可启用的状态");
} }
plan.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode()); plan.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
...@@ -442,8 +448,16 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -442,8 +448,16 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
} }
@Override @Override
public Page<PlanDetailVo> pageFilter(Page page, String planName, Long[] classifyId, String[] planRange, String editOrgName, Date implementationTimeLeft, Date implementationTimeRight) { public Page<PlanDetailVo> pageFilter(Page page, String planName, Long classifyId, List<String> planRange, String editOrgName, Date implementationTimeLeft, Date implementationTimeRight) {
int total = planDetailMapper.filterCount(planName, classifyId, planRange, editOrgName, implementationTimeLeft, implementationTimeRight); List<Long> classifyIdList = new ArrayList<>();
if (classifyId != null) {
Collection<PlanClassifyTreeVo> classifyTreeList = planClassifyTreeService.getAllChildIncludeMe(classifyId);
if (!classifyTreeList.isEmpty()) {
List<PlanClassifyTreeVo> allChildren = TreeUtil.getAllChildren(classifyTreeList);
allChildren.forEach(e -> classifyIdList.add(e.getId()));
}
}
int total = planDetailMapper.filterCount(planName, classifyIdList, planRange, editOrgName, implementationTimeLeft, implementationTimeRight);
page.setTotal(total); page.setTotal(total);
long start = (page.getCurrent() - 1) * page.getSize(); long start = (page.getCurrent() - 1) * page.getSize();
if (total == 0) { if (total == 0) {
...@@ -453,12 +467,51 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -453,12 +467,51 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
page.setCurrent(1); page.setCurrent(1);
start = 0; start = 0;
} }
List<PlanDetailVo> planList = planDetailMapper.filterList(planName, classifyId, planRange, editOrgName, implementationTimeLeft, implementationTimeRight, (int) start, (int) page.getSize()); List<PlanDetailVo> planList = planDetailMapper.filterList(planName, classifyIdList, planRange, editOrgName, implementationTimeLeft, implementationTimeRight, (int) start, (int) page.getSize());
// 查询并插入绑定数据的信息
fillBindingInfo(planList);
page.setRecords(planList); page.setRecords(planList);
} }
return page; return page;
} }
private void fillBindingInfo(List<PlanDetailVo> planList) {
if (ValidationUtil.isEmpty(planList)) {
return;
}
List<Long> idList = new ArrayList<>();
planList.forEach(e -> idList.add(e.getId()));
Map<Object, List<PlanDoc>> docMapList = null;
Map<Object, List<PlanRule>> ruleMapList = null;
Map<Object, List<PlanEquipment>> equipMapList = null;
List<PlanDoc> docs = planDocDao.findAllByPlanIdIn(idList);
if (!docs.isEmpty()) {
docMapList = Bean.list2MapList(docs, "planId");
}
List<PlanRule> rules = planRuleDao.findAllByPlanIdIn(idList);
if (!rules.isEmpty()) {
ruleMapList = Bean.list2MapList(rules, "planId");
}
List<PlanEquipment> equips = planEquipmentDao.findAllByPlanIdIn(idList);
if (!equips.isEmpty()) {
equipMapList = Bean.list2MapList(equips, "planId");
}
Map<Object, List<PlanDoc>> finalDocMapList = docMapList;
Map<Object, List<PlanRule>> finalRuleMapList = ruleMapList;
Map<Object, List<PlanEquipment>> finalEquipMapList = equipMapList;
planList.forEach(plan -> {
if (finalDocMapList != null && finalDocMapList.get(plan.getId()) != null) {
plan.setPlanDoc(finalDocMapList.get(plan.getId()).get(0));
}
if (finalRuleMapList != null && finalRuleMapList.get(plan.getId()) != null) {
plan.setPlanRule(finalRuleMapList.get(plan.getId()).get(0));
}
if (finalEquipMapList != null && finalEquipMapList.get(plan.getId()) != null) {
plan.setPlanEquipment(finalEquipMapList.get(plan.getId()));
}
});
}
@Override @Override
public Map<Long, Long> getPlanUsedDocs() { public Map<Long, Long> getPlanUsedDocs() {
Map<Long, Long> resMap = new HashMap<>(64); Map<Long, Long> resMap = new HashMap<>(64);
......
package com.yeejoin.amos.fas.business.service.impl; package com.yeejoin.amos.fas.business.service.impl;
import com.yeejoin.amos.fas.business.dao.repository.IPlanClassifyTreeDao; import com.yeejoin.amos.fas.business.dao.repository.IPlanClassifyTreeDao;
import com.yeejoin.amos.fas.business.service.intfc.PlanClassifyTreeService; import com.yeejoin.amos.fas.business.service.intfc.IPlanClassifyTreeService;
import com.yeejoin.amos.fas.business.vo.PlanClassifyTreeVo; import com.yeejoin.amos.fas.business.vo.PlanClassifyTreeVo;
import com.yeejoin.amos.fas.dao.entity.PlanClassifyTree; import com.yeejoin.amos.fas.dao.entity.PlanClassifyTree;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -15,13 +15,13 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil; ...@@ -15,13 +15,13 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.*; import java.util.*;
/** /**
*@program: YeeAmosFireAutoSysRoot * @program: YeeAmosFireAutoSysRoot
*@description: 预案分类树实现类 * @description: 预案分类树实现类
*@author: wujunkai * @author: wujunkai
*@create: 2021-01-14 14:59 * @create: 2021-01-14 14:59
*/ */
@Service("PlanClassifyTreeService") @Service("PlanClassifyTreeService")
public class PlanClassifyTreeServiceImpl implements PlanClassifyTreeService { public class PlanClassifyTreeServiceImpl implements IPlanClassifyTreeService {
public static final Long ROOT = 0L; public static final Long ROOT = 0L;
@Autowired @Autowired
...@@ -36,7 +36,7 @@ public class PlanClassifyTreeServiceImpl implements PlanClassifyTreeService { ...@@ -36,7 +36,7 @@ public class PlanClassifyTreeServiceImpl implements PlanClassifyTreeService {
public void delete(String ids) { public void delete(String ids) {
List<Long> seqs = StringUtil.String2LongList(ids); List<Long> seqs = StringUtil.String2LongList(ids);
for (Long seq : seqs) { for (Long seq : seqs) {
Optional<PlanClassifyTree> PlanClassifyTreeOpt = planClassifyTreeDao.findById(seq); Optional<PlanClassifyTree> PlanClassifyTreeOpt = planClassifyTreeDao.findById(seq);
//所有子分类 //所有子分类
List<PlanClassifyTree> childGroupSequenceList = getChildSequenceList(PlanClassifyTreeOpt.get()); List<PlanClassifyTree> childGroupSequenceList = getChildSequenceList(PlanClassifyTreeOpt.get());
planClassifyTreeDao.deleteAll(childGroupSequenceList); planClassifyTreeDao.deleteAll(childGroupSequenceList);
...@@ -45,11 +45,11 @@ public class PlanClassifyTreeServiceImpl implements PlanClassifyTreeService { ...@@ -45,11 +45,11 @@ public class PlanClassifyTreeServiceImpl implements PlanClassifyTreeService {
@Override @Override
public Collection<PlanClassifyTreeVo> getTree() { public Collection<PlanClassifyTreeVo> getTree() {
List<PlanClassifyTree> list =planClassifyTreeDao.findAll(); List<PlanClassifyTree> list = planClassifyTreeDao.findAll();
List<PlanClassifyTreeVo> voList = new ArrayList<>(); List<PlanClassifyTreeVo> voList = new ArrayList<>();
for (PlanClassifyTree planClassifyTree:list) { for (PlanClassifyTree planClassifyTree : list) {
PlanClassifyTreeVo planClassifyTreeVo = new PlanClassifyTreeVo(); PlanClassifyTreeVo planClassifyTreeVo = new PlanClassifyTreeVo();
BeanUtils.copyProperties(planClassifyTree,planClassifyTreeVo); BeanUtils.copyProperties(planClassifyTree, planClassifyTreeVo);
voList.add(planClassifyTreeVo); voList.add(planClassifyTreeVo);
} }
Map<Object, PlanClassifyTreeVo> map = Bean.listToMap(voList, "id", PlanClassifyTree.class); Map<Object, PlanClassifyTreeVo> map = Bean.listToMap(voList, "id", PlanClassifyTree.class);
...@@ -117,4 +117,18 @@ public class PlanClassifyTreeServiceImpl implements PlanClassifyTreeService { ...@@ -117,4 +117,18 @@ public class PlanClassifyTreeServiceImpl implements PlanClassifyTreeService {
resList.add(currentPlanClassifyTree); resList.add(currentPlanClassifyTree);
} }
@Override
public Collection<PlanClassifyTreeVo> getAllChildIncludeMe(Long root) {
List<PlanClassifyTreeVo> treeDaoAll = Bean.toModels(planClassifyTreeDao.getAll(), PlanClassifyTreeVo.class);
Collection<PlanClassifyTreeVo> treeList = TreeBuilder.bulid(treeDaoAll, root);
if (!ROOT.equals(root)) {
PlanClassifyTree classifyTree = planClassifyTreeDao.findById(root).orElse(null);
if (null != classifyTree) {
PlanClassifyTreeVo classifyTreeVo = Bean.toModel(classifyTree, new PlanClassifyTreeVo());
classifyTreeVo.setChildren(treeList);
return Arrays.asList(classifyTreeVo);
}
}
return treeList;
}
} }
\ No newline at end of file
...@@ -22,7 +22,7 @@ import java.util.Map; ...@@ -22,7 +22,7 @@ import java.util.Map;
public interface IContingencyPlanService { public interface IContingencyPlanService {
String DELETE_SYNC_PLAN_DOC = "DELETE_SYNC_PLAN_DOC"; String DELETE_SYNC_PLAN_DOC = "DELETE_SYNC_PLAN_DOC";
String DELETE_SYNC_PLAN_RULE = "DELETE_SYNC_PLAN_RULE"; String DELETE_SYNC_PLAN_RULE = "urule/package/remove";
String DELETE_SYNC_PLAN_EQUIP = "DELETE_SYNC_PLAN_EQUIP"; String DELETE_SYNC_PLAN_EQUIP = "DELETE_SYNC_PLAN_EQUIP";
ContingencyPlanResponseVo planStart(ContingencyPlanParamVo vo, Toke toke); ContingencyPlanResponseVo planStart(ContingencyPlanParamVo vo, Toke toke);
...@@ -86,7 +86,7 @@ public interface IContingencyPlanService { ...@@ -86,7 +86,7 @@ public interface IContingencyPlanService {
* @param implementationTimeRight 实施时间右界限 * @param implementationTimeRight 实施时间右界限
* @return Page * @return Page
*/ */
Page<PlanDetailVo> pageFilter(Page page, String planName, Long[] classifyId, String[] planRange, String editOrgName, Date implementationTimeLeft, Date implementationTimeRight); Page<PlanDetailVo> pageFilter(Page page, String planName, Long classifyId, List<String> planRange, String editOrgName, Date implementationTimeLeft, Date implementationTimeRight);
/** /**
* 查询预案使用的文档ID * 查询预案使用的文档ID
......
...@@ -4,17 +4,25 @@ import com.yeejoin.amos.fas.business.vo.PlanClassifyTreeVo; ...@@ -4,17 +4,25 @@ import com.yeejoin.amos.fas.business.vo.PlanClassifyTreeVo;
import com.yeejoin.amos.fas.dao.entity.PlanClassifyTree; import com.yeejoin.amos.fas.dao.entity.PlanClassifyTree;
import java.util.Collection; import java.util.Collection;
import java.util.List;
/** /**
* @author wjk * @author wjk
* @date 2021-01-14 * @date 2021-01-14
* 预案分类树 * 预案分类树
*/ */
public interface PlanClassifyTreeService { public interface IPlanClassifyTreeService {
PlanClassifyTree save(PlanClassifyTree model); PlanClassifyTree save(PlanClassifyTree model);
void delete(String ids); void delete(String ids);
Collection<PlanClassifyTreeVo> getTree(); Collection<PlanClassifyTreeVo> getTree();
/**
* 获取所有子项(包含自身)
* @param root 根节点ID
* @return
*/
Collection<PlanClassifyTreeVo> getAllChildIncludeMe(Long root);
} }
package com.yeejoin.amos.fas.business.util;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* <h1><h1>
*
* @author tiantao
* @date 2020/12/7 14:23
*/
public class TreeUtil {
public static<T extends TreeNode> List<T> getAllChildren(Collection<T> trees) {
List<T> childrenNodes = new ArrayList<>();
if (!ValidationUtil.isEmpty(trees)) {
trees.forEach(node->{
childrenNodes.add(node);
if (!ValidationUtil.isEmpty(node.getChildren())) {
childrenNodes.addAll(getAllChildren(node.getChildren()));
}
});
}
return childrenNodes;
}
}
...@@ -33,7 +33,7 @@ public class PlanClassifyTreeVo extends PlanClassifyTree implements TreeNode<Pla ...@@ -33,7 +33,7 @@ public class PlanClassifyTreeVo extends PlanClassifyTree implements TreeNode<Pla
@Override @Override
public void setChildren(Collection<PlanClassifyTreeVo> collection) { public void setChildren(Collection<PlanClassifyTreeVo> collection) {
this.children = children; this.children = collection;
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment