TjyydhxController.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package com.siwei.apply.controller;
  2. import com.siwei.apply.domain.res.TjyydhxRes;
  3. import com.siwei.apply.domain.vo.TjyydhxUpdateVo;
  4. import com.siwei.apply.domain.vo.TjyydhxVo;
  5. import com.siwei.apply.service.ProjectService;
  6. import com.siwei.apply.service.TjyydhxService;
  7. import com.siwei.common.core.domain.R;
  8. import com.siwei.common.core.web.controller.BaseController;
  9. import org.apache.commons.lang3.StringUtils;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.*;
  12. import java.util.HashMap;
  13. import java.util.Map;
  14. /**
  15. * 规划条件与用地红线出具 控制器
  16. * 批次报批第一步
  17. */
  18. @RestController
  19. @RequestMapping("/tjyydhx")
  20. public class TjyydhxController extends BaseController {
  21. @Autowired
  22. private TjyydhxService tjyydhxService;
  23. @Autowired
  24. private ProjectService projectService;
  25. /**
  26. * 添加规划条件与用地红线出具
  27. */
  28. @PostMapping()
  29. public R<Map> Add(@RequestBody TjyydhxVo tjyydhxVo) {
  30. try {
  31. Boolean b = tjyydhxService.isExit(tjyydhxVo.getProjectId());
  32. if (b == true) {
  33. return R.fail("此项目已添加规划条件与用地红线出具");
  34. }
  35. String id = tjyydhxService.add(tjyydhxVo);
  36. Map<String, String> map = new HashMap<>();
  37. map.put("id", id);
  38. return R.ok(map);
  39. } catch (Exception e) {
  40. return R.fail(e.getMessage());
  41. }
  42. }
  43. /**
  44. * 获取规划条件与用地红线出具
  45. *
  46. * @param projectId 项目ID
  47. * @return 规划条件与用地红线出具
  48. */
  49. @GetMapping("/{projectId}")
  50. public R<TjyydhxRes> Get(@PathVariable String projectId) {
  51. try {
  52. return R.ok(tjyydhxService.get(projectId));
  53. } catch (Exception e) {
  54. return R.fail(e.getMessage());
  55. }
  56. }
  57. /**
  58. * 通过主键id获取规划条件与用地红线出具,返回结果与按projectId查询一致
  59. */
  60. @GetMapping("/id/{id}")
  61. public R<TjyydhxRes> GetById(@PathVariable String id) {
  62. try {
  63. return R.ok(tjyydhxService.getById(id));
  64. } catch (Exception e) {
  65. return R.fail(e.getMessage());
  66. }
  67. }
  68. /**
  69. * 更新规划条件与用地红线出具
  70. *
  71. * @param tjyydhxUpdateVo 规划条件与用地红线出具
  72. * @return 操作结果
  73. */
  74. @PutMapping()
  75. public R<Void> Update(@RequestBody TjyydhxUpdateVo tjyydhxUpdateVo) {
  76. try {
  77. tjyydhxService.update(tjyydhxUpdateVo);
  78. return R.ok();
  79. } catch (Exception e) {
  80. return R.fail(e.getMessage());
  81. }
  82. }
  83. /**
  84. * 这里没有校验空间数据,是因为(流程第二项t_ydbp 表中对应的地块信息,如果按顺序流程,则第一项未上链,则第二一定无值,校验没有意义)
  85. * 更新规划条件与用地红线出具的上链状态
  86. */
  87. @PutMapping("/onchain")
  88. public R<Void> updateHasOnchain(@RequestBody Map<String, Object> params) {
  89. try {
  90. String id = (String) params.get("id");
  91. String projectId = (String) params.get("projectId");
  92. Boolean hasOnchain = (Boolean) params.get("hasOnchain");
  93. if (StringUtils.isBlank(id)) {
  94. return R.fail("nodeId不能为空");
  95. }
  96. tjyydhxService.updateHasOnchain(id, hasOnchain);
  97. // 更新项目表的上链数量
  98. projectService.countOnChinaNum(projectId);
  99. return R.ok();
  100. } catch (Exception e) {
  101. return R.fail(e.getMessage());
  102. }
  103. }
  104. }