1
0

JsgcghxkController.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. package com.siwei.apply.controller;
  2. import com.siwei.apply.domain.NodeLand;
  3. import com.siwei.apply.domain.res.JsgcghxkRes;
  4. import com.siwei.apply.domain.res.JsgcghxkSinglRes;
  5. import com.siwei.apply.domain.vo.JsgcghxkUpdateVo;
  6. import com.siwei.apply.domain.vo.JsgcghxkVo;
  7. import com.siwei.apply.domain.vo.OnChainVo;
  8. import com.siwei.apply.service.JsgcghxkService;
  9. import com.siwei.apply.service.NodeLandService;
  10. import com.siwei.common.core.domain.R;
  11. import com.siwei.common.core.web.controller.BaseController;
  12. import org.apache.commons.collections4.CollectionUtils;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.web.bind.annotation.*;
  15. import java.util.HashMap;
  16. import java.util.Map;
  17. import java.util.Objects;
  18. /**
  19. * 建设工程规划许可 控制器
  20. * 单独选址第六步
  21. * 批次报批第五步
  22. */
  23. @RestController
  24. @RequestMapping("/jsgcghxk")
  25. public class JsgcghxkController extends BaseController {
  26. @Autowired
  27. private JsgcghxkService jsgcghxkService;
  28. @Autowired
  29. NodeLandService nodeLandService;
  30. /**
  31. * 添加建设工程规划许可
  32. */
  33. @PostMapping()
  34. public R<Map> Add(@RequestBody JsgcghxkVo jsgcghxkVo) {
  35. try {
  36. // Boolean b = jsgcghxkService.isExit(jsgcghxkVo.getProjectId());
  37. // if (b == true) {
  38. // return R.fail("此项目已添加建设工程规划许可");
  39. // }
  40. // TODO 这里可以添加多个
  41. String id = jsgcghxkService.add(jsgcghxkVo);
  42. Map<String, String> map = new HashMap<>();
  43. map.put("id", id);
  44. return R.ok(map);
  45. } catch (Exception e) {
  46. return R.fail(e.getMessage());
  47. }
  48. }
  49. /**
  50. * 获取建设工程规划许可信息
  51. *
  52. * @param projectId 项目ID
  53. * @return 建设工程规划许可信息
  54. */
  55. @GetMapping("/{projectId}")
  56. public R<JsgcghxkRes> Get(@PathVariable String projectId) {
  57. try {
  58. return R.ok(jsgcghxkService.get(projectId));
  59. } catch (Exception e) {
  60. return R.fail(e.getMessage());
  61. }
  62. }
  63. /**
  64. * 通过主键id获取建设工程规划许可,返回结果与按projectId查询一致(单条结构)
  65. */
  66. @GetMapping("/id/{id}")
  67. public R<JsgcghxkSinglRes> GetById(@PathVariable String id) {
  68. try {
  69. return R.ok(jsgcghxkService.getById(id));
  70. } catch (Exception e) {
  71. return R.fail(e.getMessage());
  72. }
  73. }
  74. /**
  75. * 更新建设工程规划许可
  76. *
  77. * @param jsgcghxkUpdateVo 建设工程规划许可
  78. * @return 操作结果
  79. */
  80. @PutMapping()
  81. public R<Void> Update(@RequestBody JsgcghxkUpdateVo jsgcghxkUpdateVo) {
  82. try {
  83. jsgcghxkService.update(jsgcghxkUpdateVo);
  84. return R.ok();
  85. } catch (Exception e) {
  86. return R.fail(e.getMessage());
  87. }
  88. }
  89. /**
  90. * 更新建设工程规划许可的上链状态
  91. */
  92. @PutMapping("/onchain")
  93. public R<Void> updateHasOnchain(@RequestBody OnChainVo onChainVo) {
  94. try {
  95. if(CollectionUtils.isEmpty(onChainVo.getIds())){
  96. return R.fail(502,"节点为空,确保基本数据填写完毕");
  97. }
  98. for (String id : onChainVo.getIds()) {
  99. NodeLand nodeLand = nodeLandService.getNodeLandByNodeId(id);
  100. if(Objects.isNull(nodeLand)){
  101. return R.fail(502,"数据空间信息不存在,请检查先导入空间数据");
  102. }
  103. }
  104. for (String id : onChainVo.getIds()) {
  105. jsgcghxkService.updateHasOnchain(id, onChainVo.getHasOnchain());
  106. }
  107. return R.ok();
  108. } catch (Exception e) {
  109. return R.fail(e.getMessage());
  110. }
  111. }
  112. }