Procházet zdrojové kódy

土地核验与规划核实修改

gushoubang před 2 měsíci
rodič
revize
6f1c82d2f7

+ 25 - 13
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/TdhyhsController.java

@@ -1,8 +1,11 @@
 package com.siwei.apply.controller;
 
-import com.siwei.apply.domain.Tdhyhs;
+import com.siwei.apply.domain.res.TdhyhsRes;
+import com.siwei.apply.domain.vo.TdhyhsUpdateVo;
+import com.siwei.apply.domain.vo.TdhyhsVo;
 import com.siwei.apply.service.TdhyhsService;
 import com.siwei.common.core.domain.R;
+import com.siwei.common.core.web.controller.BaseController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -16,17 +19,21 @@ import java.util.Map;
  */
 @RestController
 @RequestMapping("/tdhyhs")
-public class TdhyhsController {
+public class TdhyhsController extends BaseController {
     @Autowired
     private TdhyhsService tdhyhsService;
 
     /**
-     * 添加土地核验与规划核实信息
+     * 添加土地核验与规划核实
      */
     @PostMapping()
-    public R<Map> add(@RequestBody Tdhyhs tdhyhs) {
+    public R<Map> Add(@RequestBody TdhyhsVo tdhyhsVo) {
         try {
-            String id = tdhyhsService.add(tdhyhs);
+            Boolean b = tdhyhsService.isExit(tdhyhsVo.getProjectId());
+            if (b == true) {
+                return R.fail("此项目已添加土地核验与规划核实");
+            }
+            String id = tdhyhsService.add(tdhyhsVo);
             Map<String, String> map = new HashMap<>();
             map.put("id", id);
             return R.ok(map);
@@ -36,25 +43,30 @@ public class TdhyhsController {
     }
 
     /**
-     * 根据 ID 获取土地核验与规划核实信息
+     * 获取土地核验与规划核实
+     *
+     * @param projectId 项目ID
+     * @return 土地核验与规划核实
      */
-    @GetMapping("/{id}")
-    public R<Tdhyhs> get(@PathVariable("id") String id) {
+    @GetMapping("/{projectId}")
+    public R<TdhyhsRes> Get(@PathVariable String projectId) {
         try {
-            Tdhyhs tdhyhs = tdhyhsService.get(id);
-            return R.ok(tdhyhs);
+            return R.ok(tdhyhsService.get(projectId));
         } catch (Exception e) {
             return R.fail(e.getMessage());
         }
     }
 
     /**
-     * 更新土地核验与规划核实信息(按非空字段更新)
+     * 更新土地核验与规划核实
+     *
+     * @param tdhyhsUpdateVo 土地核验与规划核实
+     * @return 操作结果
      */
     @PutMapping()
-    public R<Void> update(@RequestBody Tdhyhs tdhyhs) {
+    public R<Void> Update(@RequestBody TdhyhsUpdateVo tdhyhsUpdateVo) {
         try {
-            tdhyhsService.update(tdhyhs);
+            tdhyhsService.update(tdhyhsUpdateVo);
             return R.ok();
         } catch (Exception e) {
             return R.fail(e.getMessage());

+ 1 - 2
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/Tdhyhs.java

@@ -19,8 +19,7 @@ public class Tdhyhs implements Serializable {
     private String hgzh;                // 合格证号
     private String fzjg;                // 发证机关
 
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    private Date fzDate;                // 发证日期
+    private String fzDate;                // 发证日期
 
     private Map<String, Object> attachment; // 附件
     private Boolean hasOnchain;         // 是否上链

+ 13 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/res/TdhyhsRes.java

@@ -0,0 +1,13 @@
+package com.siwei.apply.domain.res;
+
+import com.siwei.apply.domain.Tdhyhs;
+import lombok.Data;
+
+/**
+ * 土地核验与规划核实 结果对象
+ */
+@Data
+public class TdhyhsRes extends Tdhyhs {
+    String projectName;// 项目名称
+    String projectCode;// 项目代码
+}

+ 12 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/vo/TdhyhsUpdateVo.java

@@ -0,0 +1,12 @@
+package com.siwei.apply.domain.vo;
+
+import lombok.Data;
+
+/**
+ * 土地核验与规划核实 更新对象
+ */
+@Data
+public class TdhyhsUpdateVo extends TdhyhsVo {
+    private String id;
+    private Boolean hasOnchain;    // 是否上链
+}

+ 15 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/vo/TdhyhsVo.java

@@ -0,0 +1,15 @@
+package com.siwei.apply.domain.vo;
+
+import lombok.Data;
+
+/**
+ * 土地核验与规划核实 视图对象
+ */
+@Data
+public class TdhyhsVo {
+    private String projectId;           // 项目ID
+    private String ydwz;                // 用地位置
+    private String hgzh;                // 合格证号
+    private String fzjg;                // 发证机关
+    private String fzDate;                // 发证日期
+}

+ 16 - 13
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/TdhyhsMapper.java

@@ -1,33 +1,36 @@
 package com.siwei.apply.mapper;
 
 import com.siwei.apply.domain.Tdhyhs;
+import com.siwei.apply.domain.vo.TdhyhsUpdateVo;
 import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
 
+// 土地核验与规划核实 Mapper 接口
 @Mapper
 public interface TdhyhsMapper {
+    /**
+     * 根据项目id查询是否存在
+     */
+    Boolean isExit(String projectId);
 
     /**
-     * 添加记录
+     * 添加土地核验与规划核实信息
      *
-     * @param tdhyhs 实体
-     * @return 插入成功条数
+     * @param tdhyhs
      */
-    String add(Tdhyhs tdhyhs);
+    void add(Tdhyhs tdhyhs);
 
     /**
-     * 根据ID获取记录
+     * 获取土地核验与规划核实信息
      *
-     * @param id 主键ID
-     * @return Tdhyhs 对象
+     * @param projectId
+     * @return
      */
-    Tdhyhs get(@Param("id") String id);
+    Tdhyhs get(String projectId);
 
     /**
-     * 更新记录
+     * 更新土地核验与规划核实信息
      *
-     * @param tdhyhs 实体
-     * @return 更新成功条数
+     * @param tdhyhsUpdateVo
      */
-    void update(Tdhyhs tdhyhs);
+    void update(TdhyhsUpdateVo tdhyhsUpdateVo);
 }

+ 21 - 12
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/TdhyhsService.java

@@ -1,29 +1,38 @@
 package com.siwei.apply.service;
 
-import com.siwei.apply.domain.Tdhyhs;
+import com.siwei.apply.domain.res.TdhyhsRes;
+import com.siwei.apply.domain.vo.TdhyhsUpdateVo;
+import com.siwei.apply.domain.vo.TdhyhsVo;
 
+/**
+ * 土地核验与规划核实 服务接口
+ */
 public interface TdhyhsService {
     /**
-     * 添加一条土地核验与规划核实记录
+     * 根据项目projectId查询是否存在
+     */
+    Boolean isExit(String projectId);
+
+    /**
+     * 添加土地核验与规划核实信息
      *
-     * @param tdhyhs Tdhyhs 对象
-     * @return 插入是否成功
+     * @param tdhyhsVo 土地核验与规划核实视图对象
+     * @return 土地核验与规划核实ID
      */
-    String add(Tdhyhs tdhyhs);
+    String add(TdhyhsVo tdhyhsVo);
 
     /**
-     * 根据 ID 获取土地核验与规划核实信息
+     * 获取土地核验与规划核实信息
      *
-     * @param id 主键
-     * @return Tdhyhs 对象
+     * @param projectId 项目ID
+     * @return 土地核验与规划核实结果对象
      */
-    Tdhyhs get(String id);
+    TdhyhsRes get(String projectId);
 
     /**
      * 更新土地核验与规划核实信息
      *
-     * @param tdhyhs Tdhyhs 对象
-     * @return 更新是否成功
+     * @param tdhyhsUpdateVo 土地核验与规划核实更新视图对象
      */
-    void update(Tdhyhs tdhyhs);
+    void update(TdhyhsUpdateVo tdhyhsUpdateVo);
 }

+ 27 - 5
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/impl/TdhyhsImpl.java

@@ -1,8 +1,14 @@
 package com.siwei.apply.service.impl;
 
+import com.siwei.apply.domain.Project;
 import com.siwei.apply.domain.Tdhyhs;
+import com.siwei.apply.domain.res.TdhyhsRes;
+import com.siwei.apply.domain.vo.TdhyhsUpdateVo;
+import com.siwei.apply.domain.vo.TdhyhsVo;
+import com.siwei.apply.mapper.ProjectMapper;
 import com.siwei.apply.mapper.TdhyhsMapper;
 import com.siwei.apply.service.TdhyhsService;
+import com.siwei.common.core.utils.bean.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -15,9 +21,18 @@ import static com.siwei.apply.common.Common.UserId;
 public class TdhyhsImpl implements TdhyhsService {
     @Autowired
     private TdhyhsMapper tdhyhsMapper;
+    @Autowired
+    private ProjectMapper projectMapper;
 
     @Override
-    public String add(Tdhyhs tdhyhs) {
+    public Boolean isExit(String projectId) {
+        return tdhyhsMapper.isExit(projectId);
+    }
+
+    @Override
+    public String add(TdhyhsVo tdhyhsVo) {
+        Tdhyhs tdhyhs = new Tdhyhs();
+        BeanUtils.copyProperties(tdhyhsVo, tdhyhs);
         tdhyhs.generateId();
         tdhyhs.setCreatorId(UserId);
         tdhyhsMapper.add(tdhyhs);
@@ -25,12 +40,19 @@ public class TdhyhsImpl implements TdhyhsService {
     }
 
     @Override
-    public Tdhyhs get(String id) {
-        return tdhyhsMapper.get(id);
+    public TdhyhsRes get(String projectId) {
+        Tdhyhs tdhyhs = tdhyhsMapper.get(projectId);
+        Project project = projectMapper.get(projectId);
+
+        TdhyhsRes tdhyhsRes = new TdhyhsRes();
+        BeanUtils.copyProperties(tdhyhs, tdhyhsRes);
+        tdhyhsRes.setProjectName(project.getName());
+        tdhyhsRes.setProjectCode(project.getCode());
+        return tdhyhsRes;
     }
 
     @Override
-    public void update(Tdhyhs tdhyhs) {
-        tdhyhsMapper.update(tdhyhs);
+    public void update(TdhyhsUpdateVo tdhyhsUpdateVo) {
+        tdhyhsMapper.update(tdhyhsUpdateVo);
     }
 }

+ 10 - 5
siwei-modules/siwei-apply/src/main/resources/mapper/TdhyhsMapper.xml

@@ -19,6 +19,12 @@
         <result property="updatedAt" column="updated_at"/>
     </resultMap>
 
+    <select id="isExit" resultType="Boolean">
+        SELECT COUNT(1) > 0
+        FROM t_tdhyhs
+        WHERE project_id = #{projectId}
+    </select>
+
     <!-- 添加记录 -->
     <insert id="add" parameterType="com.siwei.apply.domain.Tdhyhs">
         INSERT INTO t_tdhyhs (id, project_id, ydwz, hgzh, fzjg, fz_date,
@@ -29,15 +35,15 @@
                 now(), now())
     </insert>
 
-    <!-- 根据ID获取记录 -->
+    <!-- 根据项目ID获取记录 -->
     <select id="get" resultMap="BaseResultMap" parameterType="String">
         SELECT *
         FROM t_tdhyhs
-        WHERE id = #{id}
+        WHERE project_id = #{projectId}
     </select>
 
-    <!-- 根据ID更新记录 -->
-    <update id="update" parameterType="com.siwei.apply.domain.Tdhyhs">
+    <!-- 更新记录 -->
+    <update id="update" parameterType="com.siwei.apply.domain.vo.TdhyhsUpdateVo">
         UPDATE t_tdhyhs
         <set>
             <if test="projectId != null">project_id = #{projectId},</if>
@@ -46,7 +52,6 @@
             <if test="fzjg != null">fzjg = #{fzjg},</if>
             <if test="fzDate != null">fz_date = #{fzDate},</if>
             <if test="hasOnchain != null">has_onchain = #{hasOnchain},</if>
-            <if test="creatorId != null">creator_id = #{creatorId},</if>
             updated_at = now()
         </set>
         WHERE id = #{id}