package com.siwei.apply.controller; import com.siwei.apply.domain.res.TjyydhxRes; import com.siwei.apply.domain.vo.TjyydhxUpdateVo; import com.siwei.apply.domain.vo.TjyydhxVo; import com.siwei.apply.service.ProjectService; import com.siwei.apply.service.TjyydhxService; import com.siwei.common.core.domain.R; import com.siwei.common.core.web.controller.BaseController; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.HashMap; import java.util.Map; /** * 规划条件与用地红线出具 控制器 * 批次报批第一步 */ @RestController @RequestMapping("/tjyydhx") public class TjyydhxController extends BaseController { @Autowired private TjyydhxService tjyydhxService; @Autowired private ProjectService projectService; /** * 添加规划条件与用地红线出具 */ @PostMapping() public R Add(@RequestBody TjyydhxVo tjyydhxVo) { try { Boolean b = tjyydhxService.isExit(tjyydhxVo.getProjectId()); if (b == true) { return R.fail("此项目已添加规划条件与用地红线出具"); } String id = tjyydhxService.add(tjyydhxVo); 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(tjyydhxService.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(tjyydhxService.getById(id)); } catch (Exception e) { return R.fail(e.getMessage()); } } /** * 更新规划条件与用地红线出具 * * @param tjyydhxUpdateVo 规划条件与用地红线出具 * @return 操作结果 */ @PutMapping() public R Update(@RequestBody TjyydhxUpdateVo tjyydhxUpdateVo) { try { tjyydhxService.update(tjyydhxUpdateVo); return R.ok(); } catch (Exception e) { return R.fail(e.getMessage()); } } /** * 这里没有校验空间数据,是因为(流程第二项t_ydbp 表中对应的地块信息,如果按顺序流程,则第一项未上链,则第二一定无值,校验没有意义) * 更新规划条件与用地红线出具的上链状态 */ @PutMapping("/onchain") public R updateHasOnchain(@RequestBody Map params) { try { String id = (String) params.get("id"); String projectId = (String) params.get("projectId"); Boolean hasOnchain = (Boolean) params.get("hasOnchain"); if (StringUtils.isBlank(id)) { return R.fail("nodeId不能为空"); } tjyydhxService.updateHasOnchain(id, hasOnchain); // 更新项目表的上链数量 projectService.countOnChinaNum(projectId); return R.ok(); } catch (Exception e) { return R.fail(e.getMessage()); } } }