Commit b437c0ec authored by 田涛's avatar 田涛

数字预案增删改查/启停用接口

parent 153973f9
...@@ -38,7 +38,8 @@ public class PlanDetail extends BasicEntity { ...@@ -38,7 +38,8 @@ public class PlanDetail extends BasicEntity {
/** /**
* 适用范围 * 适用范围
*/ */
private String range; @Column(name="plan_range")
private String planRange;
/** /**
* 编写部门 * 编写部门
......
...@@ -22,20 +22,20 @@ public class PlanDoc extends BasicEntity { ...@@ -22,20 +22,20 @@ public class PlanDoc extends BasicEntity {
/** /**
* 预案ID * 预案ID
*/ */
@Column(name="plan_name") @Column(name="plan_id")
private Long planId; private Long planId;
/** /**
* 文档ID * 文档ID
*/ */
@Column(name="plan_name") @Column(name="doc_id")
private Long docId; private Long docId;
/** /**
* 删除状态 * 删除状态
*/ */
@Column(name="plan_name") @Column(name="is_delete")
private Boolean isDelete; private Boolean isDelete;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -3,17 +3,20 @@ package com.yeejoin.amos.fas.business.service.impl; ...@@ -3,17 +3,20 @@ package com.yeejoin.amos.fas.business.service.impl;
import com.yeejoin.amos.fas.business.dao.mapper.PlanDetailMapper; import com.yeejoin.amos.fas.business.dao.mapper.PlanDetailMapper;
import com.yeejoin.amos.fas.business.dao.repository.*; import com.yeejoin.amos.fas.business.dao.repository.*;
import com.yeejoin.amos.fas.business.service.intfc.ContingencyPlanService; 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.business.vo.PlanDetailVo;
import com.yeejoin.amos.fas.common.enums.ContingencyPlanStatusEnum; import com.yeejoin.amos.fas.common.enums.ContingencyPlanStatusEnum;
import com.yeejoin.amos.fas.dao.entity.*; import com.yeejoin.amos.fas.dao.entity.*;
import com.yeejoin.amos.fas.exception.YeeException; import com.yeejoin.amos.fas.exception.YeeException;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* @program: YeeAmosFireAutoSysRoot * @program: YeeAmosFireAutoSysRoot
...@@ -61,7 +64,10 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService { ...@@ -61,7 +64,10 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService {
}); });
// 状态为草稿 // 状态为草稿
planDetail.setStatus(ContingencyPlanStatusEnum.DRAFT.getCode()); planDetail.setStatus(ContingencyPlanStatusEnum.DRAFT.getCode());
long planId = planDetailDao.save(planDetail).getId(); planDetail.setIsDelete(false);
PlanDetail planEntity = new PlanDetail();
BeanUtils.copyProperties(planDetail, planEntity);
long planId = planDetailDao.save(planEntity).getId();
planDetail.setId(planId); planDetail.setId(planId);
planDoc.setPlanId(planId); planDoc.setPlanId(planId);
planDocDao.save(planDoc); planDocDao.save(planDoc);
...@@ -89,7 +95,7 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService { ...@@ -89,7 +95,7 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService {
} }
}); });
long planId = planDetail.getId(); long planId = planDetail.getId();
PlanDetail oldPlan = planDetailDao.getOne(planId); PlanDetail oldPlan = planDetailDao.findById(planId).orElse(null);
if (null == oldPlan) { if (null == oldPlan) {
throw new YeeException("数据不存在"); throw new YeeException("数据不存在");
} }
...@@ -100,12 +106,18 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService { ...@@ -100,12 +106,18 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService {
} else { } else {
throw new YeeException("不可编辑的状态"); throw new YeeException("不可编辑的状态");
} }
PlanDetail planEntity = new PlanDetail();
BeanUtils.copyProperties(planDetail, planEntity);
planDetailDao.saveAndFlush(planEntity);
planDoc.setPlanId(planId); planDoc.setPlanId(planId);
planDocDao.deleteByPlanId(planId); planDocDao.deleteByPlanId(planId);
planDocDao.save(planDoc); planDocDao.save(planDoc);
planRule.setPlanId(planId); planRule.setPlanId(planId);
planRuleDao.deleteByPlanId(planId); planRuleDao.deleteByPlanId(planId);
planRuleDao.save(planRule); planRuleDao.save(planRule);
planEquipment.forEach(equipment -> equipment.setPlanId(planId)); planEquipment.forEach(equipment -> equipment.setPlanId(planId));
planEquipmentDao.deleteByPlanId(planId); planEquipmentDao.deleteByPlanId(planId);
planEquipmentDao.saveAll(planEquipment); planEquipmentDao.saveAll(planEquipment);
...@@ -114,11 +126,12 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService { ...@@ -114,11 +126,12 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService {
@Override @Override
public PlanDetailVo detail(Long id) { public PlanDetailVo detail(Long id) {
PlanDetail detail = planDetailDao.getOne(id); PlanDetail detail = planDetailDao.findById(id).orElse(null);
if (null == detail) { if (null == detail) {
throw new YeeException("数据不存在"); throw new YeeException("数据不存在");
} }
PlanDetailVo detailVo = (PlanDetailVo) detail; PlanDetailVo detailVo = new PlanDetailVo();
BeanUtils.copyProperties(detail, detailVo);
List<PlanDoc> docs = planDocDao.getPlanDocsByPlanId(id); List<PlanDoc> docs = planDocDao.getPlanDocsByPlanId(id);
if (!docs.isEmpty()) { if (!docs.isEmpty()) {
detailVo.setPlanDoc(docs.get(0)); detailVo.setPlanDoc(docs.get(0));
...@@ -131,7 +144,7 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService { ...@@ -131,7 +144,7 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService {
detailVo.setPlanEquipment(equipments); detailVo.setPlanEquipment(equipments);
//TODO-设置执行次数 //TODO-设置执行次数
detailVo.setExecutionTimes(0); detailVo.setExecutionTimes(0);
PlanClassifyTree classifyTree = classifyTreeDao.getOne(detailVo.getClassifyId()); PlanClassifyTree classifyTree = classifyTreeDao.findById(detailVo.getClassifyId()).orElse(null);
if (null != classifyTree) { if (null != classifyTree) {
detailVo.setClassifyName(classifyTree.getClassifyName()); detailVo.setClassifyName(classifyTree.getClassifyName());
} }
......
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