Commit c13c7a25 authored by 田涛's avatar 田涛

数字预案查询已绑定的对象ID

parent 06e6034f
......@@ -138,4 +138,21 @@ public class ContingencyPlanController extends BaseController {
}
return CommonResponseUtil.success(contingencyPlanService.delete(idList));
}
@Permission
@ApiOperation(value = "获取数字预案绑定的资源Id", notes = "查看数字预案详情")
@GetMapping(value = "/bind-source/{type}", produces = "application/json;charset=UTF-8")
public CommonResponse getPlanBindSource(@PathVariable(value = "type") String type) {
switch (type) {
case "doc":
return CommonResponseUtil.success(contingencyPlanService.getPlanUsedDocs());
case "rule":
return CommonResponseUtil.success(contingencyPlanService.getPlanUsedRules());
case "equipment":
return CommonResponseUtil.success(contingencyPlanService.getPlanUsedEquipments());
default:
throw new YeeException("无效的类型参数");
}
}
}
package com.yeejoin.amos.fas.business.dao.mapper;
import org.springframework.stereotype.Repository;
@Repository
public interface PlanClassifyTreeMapper extends BaseMapper {
}
......@@ -16,13 +16,32 @@ import java.util.List;
@Repository
public interface PlanDetailMapper {
/**
* 更新预案状态
* @param idList id
* @param status 状态
* @return
*/
int updatePlanStatusByIdList(@Param("idList") List<Long> idList, @Param("status") Integer status);
/**
* 更新删除状态
* @param idList id
* @param isDelete 是否删除
* @return
*/
int updateIsDeleteByIdList(@Param("idList") List<Long> idList, @Param("isDelete") Boolean isDelete);
/**
* 筛选预案获得总数
* @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);
/**
* 筛选预案获得分页记录
* @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);
}
package com.yeejoin.amos.fas.business.dao.mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* <h1><h1>
*
......@@ -10,4 +14,17 @@ import org.springframework.stereotype.Repository;
*/
@Repository
public interface PlanDocMapper {
/**
* 更新删除状态
* @param idList id
* @param isDelete 是否删除
* @return
*/
int updateIsDeleteByPlanIdList(@Param("planIdList") List<Long> idList, @Param("isDelete") Boolean isDelete);
/**
* 获取预案已使用的文档id
*/
Map<String, Long> getUsedDocId();
}
package com.yeejoin.amos.fas.business.dao.mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* <h1><h1>
*
......@@ -10,4 +13,13 @@ import org.springframework.stereotype.Repository;
*/
@Repository
public interface PlanEquipmentMapper {
/**
* 更新删除状态
* @param idList id
* @param isDelete 是否删除
* @return
*/
int updateIsDeleteByPlanIdList(@Param("planIdList") List<Long> idList, @Param("isDelete") Boolean isDelete);
}
package com.yeejoin.amos.fas.business.dao.mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* <h1><h1>
*
......@@ -10,4 +13,14 @@ import org.springframework.stereotype.Repository;
*/
@Repository
public interface PlanRuleMapper {
/**
* 更新删除状态
* @param idList id
* @param isDelete 是否删除
* @return
*/
int updateIsDeleteByPlanIdList(@Param("planIdList") List<Long> idList, @Param("isDelete") Boolean isDelete);
}
......@@ -17,4 +17,6 @@ public interface IPlanDocDao extends BaseDao<PlanDoc, Long> {
void deleteByPlanId(Long planId);
List<PlanDoc> getPlanDocsByPlanId(Long planId);
List<PlanDoc> findAllByIsDelete(Boolean isDelete);
}
......@@ -17,4 +17,6 @@ public interface IPlanEquipmentDao extends BaseDao<PlanEquipment, Long> {
void deleteByPlanId(long planId);
List<PlanEquipment> getPlanDocsByPlanId(Long planId);
List<PlanEquipment> findAllByIsDelete(Boolean isDelete);
}
......@@ -4,6 +4,7 @@ import com.yeejoin.amos.fas.dao.entity.PlanRule;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* <h1><h1>
......@@ -17,4 +18,6 @@ public interface IPlanRuleDao extends BaseDao<PlanRule, Long>{
void deleteByPlanId(long planId);
List<PlanRule> getPlanDocsByPlanId(Long planId);
List<PlanRule> findAllByIsDelete(Boolean isDelete);
}
package com.yeejoin.amos.fas.business.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.fas.business.dao.mapper.PlanDetailMapper;
import com.yeejoin.amos.fas.business.dao.mapper.*;
import com.yeejoin.amos.fas.business.dao.repository.*;
import com.yeejoin.amos.fas.business.service.intfc.ContingencyPlanService;
import com.yeejoin.amos.fas.business.util.Bean;
import com.yeejoin.amos.fas.business.vo.PlanDetailVo;
import com.yeejoin.amos.fas.common.enums.ContingencyPlanStatusEnum;
import com.yeejoin.amos.fas.dao.entity.*;
......@@ -15,10 +14,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.Bean;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.*;
/**
* @program: YeeAmosFireAutoSysRoot
......@@ -35,20 +33,26 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService {
private final IPlanRuleDao planRuleDao;
private final IPlanClassifyTreeDao classifyTreeDao;
private final PlanDetailMapper planDetailMapper;
PlanEquipmentMapper planEquipmentMapper;
PlanRuleMapper planRuleMapper;
PlanDocMapper planDocMapper;
@Autowired
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) {
this.planDetailDao = planDetailDao;
this.planDocDao = planDocDao;
this.planEquipmentDao = planEquipmentDao;
this.planRuleDao = planRuleDao;
this.classifyTreeDao = classifyTreeDao;
this.planDetailMapper = planDetailMapper;
this.planEquipmentMapper = planEquipmentMapper;
this.planRuleMapper = planRuleMapper;
this.planDocMapper = planDocMapper;
}
@Override
@Transactional(rollbackFor = {YeeException.class, Exception.class})
public PlanDetailVo createPlan(PlanDetailVo planDetail) {
PlanDoc planDoc = planDetail.getPlanDoc();
PlanRule planRule = planDetail.getPlanRule();
......@@ -72,10 +76,15 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService {
long planId = planDetailDao.save(planEntity).getId();
planDetail.setId(planId);
planDoc.setPlanId(planId);
planDoc.setIsDelete(false);
planDocDao.save(planDoc);
planRule.setPlanId(planId);
planRule.setIsDelete(false);
planRuleDao.save(planRule);
planEquipment.forEach(equipment -> equipment.setPlanId(planId));
planEquipment.forEach(equipment -> {
equipment.setPlanId(planId);
equipment.setIsDelete(false);
});
planEquipmentDao.saveAll(planEquipment);
return planDetail;
}
......@@ -113,14 +122,19 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService {
planDetailDao.saveAndFlush(planEntity);
planDoc.setPlanId(planId);
planDoc.setIsDelete(false);
planDocDao.deleteByPlanId(planId);
planDocDao.save(planDoc);
planRule.setPlanId(planId);
planDoc.setIsDelete(false);
planRuleDao.deleteByPlanId(planId);
planRuleDao.save(planRule);
planEquipment.forEach(equipment -> equipment.setPlanId(planId));
planEquipment.forEach(equipment -> {
equipment.setPlanId(planId);
planDoc.setIsDelete(false);
});
planEquipmentDao.deleteByPlanId(planId);
planEquipmentDao.saveAll(planEquipment);
return planDetail;
......@@ -189,6 +203,9 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService {
@Override
public Boolean delete(List<Long> idList) {
planDetailMapper.updateIsDeleteByIdList(idList, true);
planDocMapper.updateIsDeleteByPlanIdList(idList, true);
planEquipmentMapper.updateIsDeleteByPlanIdList(idList, true);
planRuleMapper.updateIsDeleteByPlanIdList(idList, true);
return true;
}
......@@ -209,4 +226,34 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService {
}
return page;
}
@Override
public Map<Long, Long> getPlanUsedDocs() {
Map<Long, Long> resMap = new HashMap<>(64);
List<PlanDoc> usedList = planDocDao.findAllByIsDelete(false);
if (!usedList.isEmpty()) {
usedList.forEach(planDoc -> resMap.put(planDoc.getId(), planDoc.getPlanId()));
}
return resMap;
}
@Override
public Map<Long, Long> getPlanUsedRules() {
Map<Long, Long> resMap = new HashMap<>(64);
List<PlanRule> usedList = planRuleDao.findAllByIsDelete(false);
if (!usedList.isEmpty()) {
usedList.forEach(planRule -> resMap.put(planRule.getId(), planRule.getPlanId()));
}
return resMap;
}
@Override
public Map<Long, Long> getPlanUsedEquipments() {
Map<Long, Long> resMap = new HashMap<>(64);
List<PlanEquipment> usedList = planEquipmentDao.findAllByIsDelete(false);
if (!usedList.isEmpty()) {
usedList.forEach(planEquipment -> resMap.put(planEquipment.getId(), planEquipment.getPlanId()));
}
return resMap;
}
}
\ No newline at end of file
......@@ -3,9 +3,12 @@ package com.yeejoin.amos.fas.business.service.intfc;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.fas.business.vo.PlanDetailVo;
import com.yeejoin.amos.fas.dao.entity.PlanDetail;
import com.yeejoin.amos.fas.exception.YeeException;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author wjk
......@@ -19,6 +22,7 @@ public interface ContingencyPlanService {
* @param planDetail
* @return
*/
@Transactional(rollbackFor = {YeeException.class, Exception.class})
PlanDetailVo createPlan(PlanDetailVo planDetail);
/**
......@@ -26,6 +30,7 @@ public interface ContingencyPlanService {
* @param planDetail
* @return
*/
@Transactional(rollbackFor = {YeeException.class, Exception.class})
PlanDetailVo editPlan(PlanDetailVo planDetail);
/**
......@@ -54,6 +59,7 @@ public interface ContingencyPlanService {
* @param idList
* @return
*/
@Transactional(rollbackFor = {YeeException.class, Exception.class})
Boolean delete(List<Long> idList);
/**
......@@ -69,4 +75,21 @@ public interface ContingencyPlanService {
*/
Page<PlanDetailVo> pageFilter(Page page, String planName, Long[] classifyId, String[] planRange, String editOrgName, Date implementationTimeLeft, Date implementationTimeRight);
/**
* 查询预案使用的文档ID
* @return
*/
Map<Long, Long> getPlanUsedDocs();
/**
* 查询预案使用的规则ID
* @return
*/
Map<Long, Long> getPlanUsedRules();
/**
* 查询预案使用的装备ID
* @return
*/
Map<Long, Long> getPlanUsedEquipments();
}
......@@ -2,4 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.fas.business.dao.mapper.PlanDocMapper">
<update id="updateIsDeleteByPlanIdList" parameterType="list">
UPDATE c_plan_doc SET is_delete = #{isDelete} WHERE plan_id IN
<foreach collection="planIdList" separator="," item="planId" open="(" close=")">
#{planId}
</foreach>
</update>
</mapper>
\ No newline at end of file
......@@ -2,4 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.fas.business.dao.mapper.PlanEquipmentMapper">
<update id="updateIsDeleteByPlanIdList" parameterType="list">
UPDATE c_plan_equipment SET is_delete = #{isDelete} WHERE plan_id IN
<foreach collection="planIdList" separator="," item="planId" open="(" close=")">
#{planId}
</foreach>
</update>
</mapper>
\ No newline at end of file
......@@ -2,4 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.fas.business.dao.mapper.PlanRuleMapper">
<update id="updateIsDeleteByPlanIdList" parameterType="list">
UPDATE c_plan_rule SET is_delete = #{isDelete} WHERE plan_id IN
<foreach collection="planIdList" separator="," item="planId" open="(" close=")">
#{planId}
</foreach>
</update>
</mapper>
\ No newline at end of file
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