Commit d3043d3b authored by 田涛's avatar 田涛

预案接口优化

parent 812509cc
...@@ -22,7 +22,7 @@ public class PlanRule extends BasicEntity { ...@@ -22,7 +22,7 @@ public class PlanRule extends BasicEntity {
* 规则ID * 规则ID
*/ */
@Column(name="rule_id") @Column(name="rule_id")
private Long ruleId; private String ruleId;
/** /**
* 预案ID * 预案ID
......
...@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.fas.business.service.intfc.ContingencyPlanService; import com.yeejoin.amos.fas.business.service.intfc.ContingencyPlanService;
import com.yeejoin.amos.fas.business.vo.PlanDetailVo; import com.yeejoin.amos.fas.business.vo.PlanDetailVo;
import com.yeejoin.amos.fas.config.Permission; import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.util.CommonResponse; import com.yeejoin.amos.fas.core.util.CommonResponseUtil2;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil; import com.yeejoin.amos.fas.core.util.ResponseModel;
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 io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -32,14 +32,14 @@ public class ContingencyPlanController extends BaseController { ...@@ -32,14 +32,14 @@ public class ContingencyPlanController extends BaseController {
@Permission @Permission
@ApiOperation(value = "创建数字预案", notes = "创建数字预案") @ApiOperation(value = "创建数字预案", notes = "创建数字预案")
@PostMapping(value = "", produces = "application/json;charset=UTF-8") @PostMapping(value = "", produces = "application/json;charset=UTF-8")
public CommonResponse createPlan(@RequestBody PlanDetailVo planDetail) { public ResponseModel createPlan(@RequestBody PlanDetailVo planDetail) {
if (null == planDetail) { if (null == planDetail) {
return CommonResponseUtil.failure("参数有误"); return CommonResponseUtil2.failure("参数有误");
} }
AgencyUserModel curUser = getUserInfo(); AgencyUserModel curUser = getUserInfo();
planDetail.setCreator(curUser.getUserId()); planDetail.setCreator(curUser.getUserId());
planDetail.setOrgCode(getOrgCode(getSelectedOrgInfo())); planDetail.setOrgCode(getOrgCode(getSelectedOrgInfo()));
return CommonResponseUtil.success(contingencyPlanService.createPlan(planDetail)); return CommonResponseUtil2.success(contingencyPlanService.createPlan(planDetail));
} }
/** /**
...@@ -48,14 +48,14 @@ public class ContingencyPlanController extends BaseController { ...@@ -48,14 +48,14 @@ public class ContingencyPlanController extends BaseController {
@Permission @Permission
@ApiOperation(value = "修改数字预案", notes = "修改数字预案") @ApiOperation(value = "修改数字预案", notes = "修改数字预案")
@PutMapping(value = "", produces = "application/json;charset=UTF-8") @PutMapping(value = "", produces = "application/json;charset=UTF-8")
public CommonResponse editPlan(@RequestBody PlanDetailVo planDetail) { public ResponseModel editPlan(@RequestBody PlanDetailVo planDetail) {
if (null == planDetail) { if (null == planDetail) {
return CommonResponseUtil.failure("参数有误"); return CommonResponseUtil2.failure("参数有误");
} }
AgencyUserModel curUser = getUserInfo(); AgencyUserModel curUser = getUserInfo();
planDetail.setReviser(curUser.getUserId()); planDetail.setReviser(curUser.getUserId());
planDetail.setUpdateTime(new Date()); planDetail.setUpdateTime(new Date());
return CommonResponseUtil.success(contingencyPlanService.editPlan(planDetail)); return CommonResponseUtil2.success(contingencyPlanService.editPlan(planDetail));
} }
/** /**
...@@ -64,11 +64,11 @@ public class ContingencyPlanController extends BaseController { ...@@ -64,11 +64,11 @@ public class ContingencyPlanController extends BaseController {
@Permission @Permission
@ApiOperation(value = "查看数字预案详情", notes = "查看数字预案详情") @ApiOperation(value = "查看数字预案详情", notes = "查看数字预案详情")
@GetMapping(value = "/{id}", produces = "application/json;charset=UTF-8") @GetMapping(value = "/{id}", produces = "application/json;charset=UTF-8")
public CommonResponse createPlan(@PathVariable(value = "id") Long id) { public ResponseModel createPlan(@PathVariable(value = "id") Long id) {
if (null == id) { if (null == id) {
return CommonResponseUtil.failure("参数有误"); return CommonResponseUtil2.failure("参数有误");
} }
return CommonResponseUtil.success(contingencyPlanService.detail(id)); return CommonResponseUtil2.success(contingencyPlanService.detail(id));
} }
/** /**
...@@ -77,7 +77,7 @@ public class ContingencyPlanController extends BaseController { ...@@ -77,7 +77,7 @@ public class ContingencyPlanController extends BaseController {
@Permission @Permission
@ApiOperation(value = "数字预案分页查询", notes = "数字预案分页查询") @ApiOperation(value = "数字预案分页查询", notes = "数字预案分页查询")
@GetMapping(value = "/page", produces = "application/json;charset=UTF-8") @GetMapping(value = "/page", produces = "application/json;charset=UTF-8")
public CommonResponse 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) String[] planRange,
...@@ -89,7 +89,7 @@ public class ContingencyPlanController extends BaseController { ...@@ -89,7 +89,7 @@ public class ContingencyPlanController extends BaseController {
throw new YeeException("分页参数有误"); throw new YeeException("分页参数有误");
} }
Page page = new Page(current, size); Page page = new Page(current, size);
return CommonResponseUtil.success(contingencyPlanService.pageFilter(page, planName, classifyId, planRange, editOrgName, implementationTimeLeft, implementationTimeRight)); return CommonResponseUtil2.success(contingencyPlanService.pageFilter(page, planName, classifyId, planRange, editOrgName, implementationTimeLeft, implementationTimeRight));
} }
/** /**
...@@ -98,11 +98,11 @@ public class ContingencyPlanController extends BaseController { ...@@ -98,11 +98,11 @@ public class ContingencyPlanController extends BaseController {
@Permission @Permission
@ApiOperation(value = "启用预案", notes = "启用预案") @ApiOperation(value = "启用预案", notes = "启用预案")
@PutMapping(value = "/activate", produces = "application/json;charset=UTF-8") @PutMapping(value = "/activate", produces = "application/json;charset=UTF-8")
public CommonResponse activatePlan(@RequestBody List<Long> idList) { public ResponseModel activatePlan(@RequestBody List<Long> idList) {
if (null == idList || idList.isEmpty()) { if (null == idList || idList.isEmpty()) {
return CommonResponseUtil.failure("参数有误"); return CommonResponseUtil2.failure("参数有误");
} }
return CommonResponseUtil.success(contingencyPlanService.activatePlan(idList)); return CommonResponseUtil2.success(contingencyPlanService.activatePlan(idList));
} }
/** /**
...@@ -111,11 +111,11 @@ public class ContingencyPlanController extends BaseController { ...@@ -111,11 +111,11 @@ public class ContingencyPlanController extends BaseController {
@Permission @Permission
@ApiOperation(value = "停用预案", notes = "停用预案") @ApiOperation(value = "停用预案", notes = "停用预案")
@PutMapping(value = "/deactivate", produces = "application/json;charset=UTF-8") @PutMapping(value = "/deactivate", produces = "application/json;charset=UTF-8")
public CommonResponse deactivatePlan(@RequestBody List<Long> idList) { public ResponseModel deactivatePlan(@RequestBody List<Long> idList) {
if (null == idList || idList.isEmpty()) { if (null == idList || idList.isEmpty()) {
return CommonResponseUtil.failure("参数有误"); return CommonResponseUtil2.failure("参数有误");
} }
return CommonResponseUtil.success(contingencyPlanService.deactivatePlan(idList)); return CommonResponseUtil2.success(contingencyPlanService.deactivatePlan(idList));
} }
...@@ -125,9 +125,9 @@ public class ContingencyPlanController extends BaseController { ...@@ -125,9 +125,9 @@ public class ContingencyPlanController extends BaseController {
@Permission @Permission
@ApiOperation(value = "删除预案", notes = "删除预案") @ApiOperation(value = "删除预案", notes = "删除预案")
@DeleteMapping(value = "/{ids}", produces = "application/json;charset=UTF-8") @DeleteMapping(value = "/{ids}", produces = "application/json;charset=UTF-8")
public CommonResponse deletePlan(@PathVariable(value = "ids") String idStr) { public ResponseModel deletePlan(@PathVariable(value = "ids") String idStr) {
if (StringUtils.isBlank(idStr)) { if (StringUtils.isBlank(idStr)) {
return CommonResponseUtil.failure("参数有误"); return CommonResponseUtil2.failure("参数有误");
} }
String[] idArr = idStr.split(","); String[] idArr = idStr.split(",");
List<Long> idList = new ArrayList(); List<Long> idList = new ArrayList();
...@@ -136,20 +136,20 @@ public class ContingencyPlanController extends BaseController { ...@@ -136,20 +136,20 @@ public class ContingencyPlanController extends BaseController {
idList.add(Long.valueOf(id.trim())); idList.add(Long.valueOf(id.trim()));
} }
} }
return CommonResponseUtil.success(contingencyPlanService.delete(idList)); return CommonResponseUtil2.success(contingencyPlanService.delete(idList));
} }
@Permission @Permission
@ApiOperation(value = "获取数字预案绑定的资源Id", notes = "查看数字预案详情") @ApiOperation(value = "获取数字预案绑定的资源Id", notes = "查看数字预案详情")
@GetMapping(value = "/bind-source/{type}", produces = "application/json;charset=UTF-8") @GetMapping(value = "/bind-source/{type}", produces = "application/json;charset=UTF-8")
public CommonResponse getPlanBindSource(@PathVariable(value = "type") String type) { public ResponseModel getPlanBindSource(@PathVariable(value = "type") String type) {
switch (type) { switch (type) {
case "doc": case "doc":
return CommonResponseUtil.success(contingencyPlanService.getPlanUsedDocs()); return CommonResponseUtil2.success(contingencyPlanService.getPlanUsedDocs());
case "rule": case "rule":
return CommonResponseUtil.success(contingencyPlanService.getPlanUsedRules()); return CommonResponseUtil2.success(contingencyPlanService.getPlanUsedRules());
case "equipment": case "equipment":
return CommonResponseUtil.success(contingencyPlanService.getPlanUsedEquipments()); return CommonResponseUtil2.success(contingencyPlanService.getPlanUsedEquipments());
default: default:
throw new YeeException("无效的类型参数"); throw new YeeException("无效的类型参数");
} }
......
...@@ -232,17 +232,17 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService { ...@@ -232,17 +232,17 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService {
Map<Long, Long> resMap = new HashMap<>(64); Map<Long, Long> resMap = new HashMap<>(64);
List<PlanDoc> usedList = planDocDao.findAllByIsDelete(false); List<PlanDoc> usedList = planDocDao.findAllByIsDelete(false);
if (!usedList.isEmpty()) { if (!usedList.isEmpty()) {
usedList.forEach(planDoc -> resMap.put(planDoc.getId(), planDoc.getPlanId())); usedList.forEach(planDoc -> resMap.put(planDoc.getDocId(), planDoc.getPlanId()));
} }
return resMap; return resMap;
} }
@Override @Override
public Map<Long, Long> getPlanUsedRules() { public Map<String, Long> getPlanUsedRules() {
Map<Long, Long> resMap = new HashMap<>(64); Map<String, Long> resMap = new HashMap<>(64);
List<PlanRule> usedList = planRuleDao.findAllByIsDelete(false); List<PlanRule> usedList = planRuleDao.findAllByIsDelete(false);
if (!usedList.isEmpty()) { if (!usedList.isEmpty()) {
usedList.forEach(planRule -> resMap.put(planRule.getId(), planRule.getPlanId())); usedList.forEach(planRule -> resMap.put(planRule.getRuleId(), planRule.getPlanId()));
} }
return resMap; return resMap;
} }
...@@ -252,7 +252,7 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService { ...@@ -252,7 +252,7 @@ public class ContingencyPlanServiceImpl implements ContingencyPlanService {
Map<Long, Long> resMap = new HashMap<>(64); Map<Long, Long> resMap = new HashMap<>(64);
List<PlanEquipment> usedList = planEquipmentDao.findAllByIsDelete(false); List<PlanEquipment> usedList = planEquipmentDao.findAllByIsDelete(false);
if (!usedList.isEmpty()) { if (!usedList.isEmpty()) {
usedList.forEach(planEquipment -> resMap.put(planEquipment.getId(), planEquipment.getPlanId())); usedList.forEach(planEquipment -> resMap.put(planEquipment.getFireEquipmentId(), planEquipment.getPlanId()));
} }
return resMap; return resMap;
} }
......
...@@ -85,7 +85,7 @@ public interface ContingencyPlanService { ...@@ -85,7 +85,7 @@ public interface ContingencyPlanService {
* 查询预案使用的规则ID * 查询预案使用的规则ID
* @return * @return
*/ */
Map<Long, Long> getPlanUsedRules(); Map<String, Long> getPlanUsedRules();
/** /**
* 查询预案使用的装备ID * 查询预案使用的装备ID
......
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