| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- package com.siwei.apply.controller;
- import com.siwei.apply.domain.NodeLand;
- import com.siwei.apply.domain.res.JsgcghxkRes;
- import com.siwei.apply.domain.res.JsgcghxkSinglRes;
- import com.siwei.apply.domain.vo.JsgcghxkUpdateVo;
- import com.siwei.apply.domain.vo.JsgcghxkVo;
- import com.siwei.apply.domain.vo.OnChainVo;
- import com.siwei.apply.service.JsgcghxkService;
- import com.siwei.apply.service.NodeLandService;
- import com.siwei.common.core.domain.R;
- import com.siwei.common.core.web.controller.BaseController;
- import org.apache.commons.collections4.CollectionUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Objects;
- /**
- * 建设工程规划许可 控制器
- * 单独选址第六步
- * 批次报批第五步
- */
- @RestController
- @RequestMapping("/jsgcghxk")
- public class JsgcghxkController extends BaseController {
- @Autowired
- private JsgcghxkService jsgcghxkService;
- @Autowired
- NodeLandService nodeLandService;
- /**
- * 添加建设工程规划许可
- */
- @PostMapping()
- public R<Map> Add(@RequestBody JsgcghxkVo jsgcghxkVo) {
- try {
- // Boolean b = jsgcghxkService.isExit(jsgcghxkVo.getProjectId());
- // if (b == true) {
- // return R.fail("此项目已添加建设工程规划许可");
- // }
- // TODO 这里可以添加多个
- String id = jsgcghxkService.add(jsgcghxkVo);
- Map<String, String> map = new HashMap<>();
- map.put("id", id);
- return R.ok(map);
- } catch (Exception e) {
- return R.fail(e.getMessage());
- }
- }
- /**
- * 获取建设工程规划许可信息
- *
- * @param projectId 项目ID
- * @return 建设工程规划许可信息
- */
- @GetMapping("/{projectId}")
- public R<JsgcghxkRes> Get(@PathVariable String projectId) {
- try {
- return R.ok(jsgcghxkService.get(projectId));
- } catch (Exception e) {
- return R.fail(e.getMessage());
- }
- }
- /**
- * 通过主键id获取建设工程规划许可,返回结果与按projectId查询一致(单条结构)
- */
- @GetMapping("/id/{id}")
- public R<JsgcghxkSinglRes> GetById(@PathVariable String id) {
- try {
- return R.ok(jsgcghxkService.getById(id));
- } catch (Exception e) {
- return R.fail(e.getMessage());
- }
- }
- /**
- * 更新建设工程规划许可
- *
- * @param jsgcghxkUpdateVo 建设工程规划许可
- * @return 操作结果
- */
- @PutMapping()
- public R<Void> Update(@RequestBody JsgcghxkUpdateVo jsgcghxkUpdateVo) {
- try {
- jsgcghxkService.update(jsgcghxkUpdateVo);
- return R.ok();
- } catch (Exception e) {
- return R.fail(e.getMessage());
- }
- }
- /**
- * 更新建设工程规划许可的上链状态
- */
- @PutMapping("/onchain")
- public R<Void> updateHasOnchain(@RequestBody OnChainVo onChainVo) {
- try {
- if(CollectionUtils.isEmpty(onChainVo.getIds())){
- return R.fail(502,"节点为空,确保基本数据填写完毕");
- }
- for (String id : onChainVo.getIds()) {
- NodeLand nodeLand = nodeLandService.getNodeLandByNodeId(id);
- if(Objects.isNull(nodeLand)){
- return R.fail(502,"数据空间信息不存在,请检查先导入空间数据");
- }
- }
- for (String id : onChainVo.getIds()) {
- jsgcghxkService.updateHasOnchain(id, onChainVo.getHasOnchain());
- }
- return R.ok();
- } catch (Exception e) {
- return R.fail(e.getMessage());
- }
- }
- }
|