package com.siwei.apply.controller; import com.siwei.apply.domain.NodeLand; import com.siwei.apply.domain.res.GyjsydscdjRes; import com.siwei.apply.domain.res.GyjsydscdjSinglRes; import com.siwei.apply.domain.vo.GyjsydscdjUpdateVo; import com.siwei.apply.domain.vo.GyjsydscdjVo; import com.siwei.apply.domain.vo.OnChainVo; import com.siwei.apply.service.GyjsydscdjService; 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("/gyjsydscdj") public class GyjsydscdjController extends BaseController { @Autowired private GyjsydscdjService gyjsydscdjService; @Autowired NodeLandService nodeLandService; /** * 添加国有建设用地使用权首次登记 */ @PostMapping() public R Add(@RequestBody GyjsydscdjVo gyjsydscdjVo) { try { // Boolean b = gyjsydscdjService.isExit(gyjsydscdjVo.getProjectId()); // if (b == true) { // return R.fail("此项目已添加国有建设用地使用权首次登记"); // } String id = gyjsydscdjService.add(gyjsydscdjVo); Map 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 Get(@PathVariable String projectId) { try { return R.ok(gyjsydscdjService.get(projectId)); } catch (Exception e) { return R.fail(e.getMessage()); } } /** * 通过主键id获取国有建设用地使用权首次登记,返回结果与按projectId查询一致 */ @GetMapping("/id/{id}") public R GetById(@PathVariable String id) { try { return R.ok(gyjsydscdjService.getById(id)); } catch (Exception e) { return R.fail(e.getMessage()); } } /** * 更新国有建设用地使用权首次登记 * * @param gyjsydscdjUpdateVo 国有建设用地使用权首次登记 * @return 操作结果 */ @PutMapping() public R Update(@RequestBody GyjsydscdjUpdateVo gyjsydscdjUpdateVo) { try { gyjsydscdjService.update(gyjsydscdjUpdateVo); return R.ok(); } catch (Exception e) { return R.fail(e.getMessage()); } } /** * 更新国有建设用地使用权首次登记的上链状态 */ @PutMapping("/onchain") public R 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()) { gyjsydscdjService.updateHasOnchain(id, onChainVo.getHasOnchain()); } return R.ok(); } catch (Exception e) { return R.fail(e.getMessage()); } } }