1
0

GyjsydscdjController.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package com.siwei.apply.controller;
  2. import com.siwei.apply.domain.NodeLand;
  3. import com.siwei.apply.domain.res.GyjsydscdjRes;
  4. import com.siwei.apply.domain.res.GyjsydscdjSinglRes;
  5. import com.siwei.apply.domain.vo.GyjsydscdjUpdateVo;
  6. import com.siwei.apply.domain.vo.GyjsydscdjVo;
  7. import com.siwei.apply.domain.vo.OnChainVo;
  8. import com.siwei.apply.service.GyjsydscdjService;
  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("/gyjsydscdj")
  25. public class GyjsydscdjController extends BaseController {
  26. @Autowired
  27. private GyjsydscdjService gyjsydscdjService;
  28. @Autowired
  29. NodeLandService nodeLandService;
  30. /**
  31. * 添加国有建设用地使用权首次登记
  32. */
  33. @PostMapping()
  34. public R<Map> Add(@RequestBody GyjsydscdjVo gyjsydscdjVo) {
  35. try {
  36. // Boolean b = gyjsydscdjService.isExit(gyjsydscdjVo.getProjectId());
  37. // if (b == true) {
  38. // return R.fail("此项目已添加国有建设用地使用权首次登记");
  39. // }
  40. String id = gyjsydscdjService.add(gyjsydscdjVo);
  41. Map<String, String> map = new HashMap<>();
  42. map.put("id", id);
  43. return R.ok(map);
  44. } catch (Exception e) {
  45. return R.fail(e.getMessage());
  46. }
  47. }
  48. /**
  49. * 获取国有建设用地使用权首次登记
  50. *
  51. * @param projectId 项目ID
  52. * @return 国有建设用地使用权首次登记
  53. */
  54. @GetMapping("/{projectId}")
  55. public R<GyjsydscdjRes> Get(@PathVariable String projectId) {
  56. try {
  57. return R.ok(gyjsydscdjService.get(projectId));
  58. } catch (Exception e) {
  59. return R.fail(e.getMessage());
  60. }
  61. }
  62. /**
  63. * 通过主键id获取国有建设用地使用权首次登记,返回结果与按projectId查询一致
  64. */
  65. @GetMapping("/id/{id}")
  66. public R<GyjsydscdjSinglRes> GetById(@PathVariable String id) {
  67. try {
  68. return R.ok(gyjsydscdjService.getById(id));
  69. } catch (Exception e) {
  70. return R.fail(e.getMessage());
  71. }
  72. }
  73. /**
  74. * 更新国有建设用地使用权首次登记
  75. *
  76. * @param gyjsydscdjUpdateVo 国有建设用地使用权首次登记
  77. * @return 操作结果
  78. */
  79. @PutMapping()
  80. public R<Void> Update(@RequestBody GyjsydscdjUpdateVo gyjsydscdjUpdateVo) {
  81. try {
  82. gyjsydscdjService.update(gyjsydscdjUpdateVo);
  83. return R.ok();
  84. } catch (Exception e) {
  85. return R.fail(e.getMessage());
  86. }
  87. }
  88. /**
  89. * 更新国有建设用地使用权首次登记的上链状态
  90. */
  91. @PutMapping("/onchain")
  92. public R<Void> updateHasOnchain(@RequestBody OnChainVo onChainVo) {
  93. try {
  94. if(CollectionUtils.isEmpty(onChainVo.getIds())){
  95. return R.fail(502,"节点为空,确保基本数据填写完毕");
  96. }
  97. for (String id : onChainVo.getIds()) {
  98. NodeLand nodeLand = nodeLandService.getNodeLandByNodeId(id);
  99. if(Objects.isNull(nodeLand)){
  100. return R.fail(502,"数据空间信息不存在,请检查先导入空间数据");
  101. }
  102. }
  103. for (String id : onChainVo.getIds()) {
  104. gyjsydscdjService.updateHasOnchain(id, onChainVo.getHasOnchain());
  105. }
  106. return R.ok();
  107. } catch (Exception e) {
  108. return R.fail(e.getMessage());
  109. }
  110. }
  111. }