gushoubang 8 сар өмнө
parent
commit
98a38fa6a2

+ 29 - 14
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/config/FileObjTypeHandler.java

@@ -2,61 +2,76 @@ package com.onemap.apply.config;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.onemap.apply.domain.tdgy.dto.FileObj;
 import org.apache.ibatis.type.BaseTypeHandler;
 import org.apache.ibatis.type.JdbcType;
 import org.apache.ibatis.type.MappedTypes;
 import org.postgresql.util.PGobject;
+import com.fasterxml.jackson.core.type.TypeReference;
 
 import java.sql.CallableStatement;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.List;
 
-@MappedTypes({Object.class})
-public class FileObjTypeHandler extends BaseTypeHandler<Object> {
+@MappedTypes({FileObj.class})
+public class FileObjTypeHandler extends BaseTypeHandler<List<FileObj>> {
     private static final PGobject jsonObject = new PGobject();
     private static final ObjectMapper objectMapper = new ObjectMapper();  // 使用 Jackson 的 ObjectMapper
 
     @Override
-    public void setNonNullParameter(PreparedStatement preparedStatement, int i, Object o, JdbcType jdbcType) throws SQLException {
+    public void setNonNullParameter(PreparedStatement preparedStatement, int i, List<FileObj> files, JdbcType jdbcType) throws SQLException {
         if (preparedStatement != null) {
             jsonObject.setType("jsonb");
             try {
-                jsonObject.setValue(objectMapper.writeValueAsString(o));  // 使用 Jackson 进行序列化
+                jsonObject.setValue(objectMapper.writeValueAsString(files));  // 使用 Jackson 进行序列化
             } catch (JsonProcessingException e) {
-                throw new SQLException("Error converting Object to JSON", e);
+                throw new SQLException("Error converting List<FileObj> to JSON", e);
             }
             preparedStatement.setObject(i, jsonObject);
         }
     }
 
     @Override
-    public Object getNullableResult(ResultSet resultSet, String s) throws SQLException {
+    public List<FileObj> getNullableResult(ResultSet resultSet, String s) throws SQLException {
         String json = resultSet.getString(s);
+        if (json == null) {
+            return null;
+        }
         try {
-            return objectMapper.readValue(json, Object.class);  // 使用 Jackson 进行反序列化
+            return objectMapper.readValue(json, new TypeReference<List<FileObj>>() {
+            });  // 使用 Jackson 进行反序列化
         } catch (JsonProcessingException e) {
-            throw new SQLException("Error converting JSON to Object", e);
+            throw new SQLException("Error converting JSON to List<FileObj>", e);
         }
     }
 
     @Override
-    public Object getNullableResult(ResultSet resultSet, int i) throws SQLException {
+    public List<FileObj> getNullableResult(ResultSet resultSet, int i) throws SQLException {
         String json = resultSet.getString(i);
+        if (json == null) {
+            return null;
+        }
         try {
-            return objectMapper.readValue(json, Object.class);  // 使用 Jackson 进行反序列化
+            return objectMapper.readValue(json, new TypeReference<List<FileObj>>() {
+            });  // 使用 Jackson 进行反序列化
         } catch (JsonProcessingException e) {
-            throw new SQLException("Error converting JSON to Object", e);
+            throw new SQLException("Error converting JSON to List<FileObj>", e);
         }
     }
 
     @Override
-    public Object getNullableResult(CallableStatement callableStatement, int i) throws SQLException {
+    public List<FileObj> getNullableResult(CallableStatement callableStatement, int i) throws SQLException {
         String json = callableStatement.getString(i);
+        if (json == null) {
+            return null;
+        }
         try {
-            return objectMapper.readValue(json, Object.class);  // 使用 Jackson 进行反序列化
+            return objectMapper.readValue(json, new TypeReference<List<FileObj>>() {
+            });  // 使用 Jackson 进行反序列化
         } catch (JsonProcessingException e) {
-            throw new SQLException("Error converting JSON to Object", e);
+            throw new SQLException("Error converting JSON to List<FileObj>", e);
         }
     }
 }

+ 3 - 2
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/controller/tdgy/TdgyController.java

@@ -1,5 +1,6 @@
 package com.onemap.apply.controller.tdgy;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.onemap.apply.domain.tdgy.vo.IdleLandListVo;
 import com.onemap.apply.domain.tdgy.vo.LandIdleConfirmVo;
 import com.onemap.apply.domain.tdgy.vo.LandIdleDisposalVo;
@@ -84,7 +85,7 @@ public class TdgyController {
      * 获取闲置土地处置详情
      */
     @GetMapping("/idleLandDisposal/{landId}")
-    public RequestResult getIdleLandDisposalDetail(@PathVariable String landId) {
+    public RequestResult getIdleLandDisposalDetail(@PathVariable String landId) throws JsonProcessingException {
         RequestResult requestResult = tdgyService.getIdleLandDisposal(landId);
         return requestResult;
     }
@@ -92,7 +93,7 @@ public class TdgyController {
      * 获取闲置土地判定详情
      */
     @GetMapping("/idleLandConfirm/{landId}")
-    public RequestResult getIdleLandConfirmDetail(@PathVariable String landId) {
+    public RequestResult getIdleLandConfirmDetail(@PathVariable String landId) throws JsonProcessingException {
         RequestResult requestResult = tdgyService.getIdleLandConfirm(landId);
         return requestResult;
     }

+ 6 - 2
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/domain/tdgy/dto/LandIdleConfirmDTO.java

@@ -3,8 +3,8 @@ package com.onemap.apply.domain.tdgy.dto;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.onemap.apply.config.FileObjTypeHandler;
-import com.onemap.apply.config.StringListTypeHandler;
 import lombok.Data;
 
 import java.util.Date;
@@ -25,7 +25,7 @@ public class LandIdleConfirmDTO {
     private Boolean isIdle;
     //  是否处置
     @TableField("is_disposal")
-    private Boolean isDisposal=false;
+    private Boolean isDisposal = false;
     // 闲置原因
     @TableField("idle_reason")
     private String idleReason;
@@ -43,4 +43,8 @@ public class LandIdleConfirmDTO {
     // 认定文件
     @TableField(value = "files", typeHandler = FileObjTypeHandler.class)
     private List<FileObj> files;
+
+    @JsonIgnore
+    @TableField(exist = false)
+    private String filesStr;
 }

+ 4 - 0
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/domain/tdgy/dto/LandIdleDisposalDTO.java

@@ -3,6 +3,7 @@ package com.onemap.apply.domain.tdgy.dto;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.onemap.apply.config.FileObjTypeHandler;
 import lombok.Data;
 
@@ -32,4 +33,7 @@ public class LandIdleDisposalDTO {
     // 处置文件
     @TableField(value = "files", typeHandler = FileObjTypeHandler.class)
     private List<FileObj> files;
+
+    @JsonIgnore
+    private String filesStr;
 }

+ 3 - 0
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/mapper/tdgy/LandIdleConfirmMapper.java

@@ -3,6 +3,7 @@ package com.onemap.apply.mapper.tdgy;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.onemap.apply.domain.tdgy.dto.LandIdleConfirmDTO;
 import com.onemap.apply.domain.tdgy.vo.IdleLandListVo;
+import com.onemap.common.datasource.annotation.Slave;
 import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
@@ -13,4 +14,6 @@ public interface LandIdleConfirmMapper extends BaseMapper<LandIdleConfirmDTO> {
     List<Map> getIdleLandList(IdleLandListVo idleLandListVo);
 
     Integer getIdleLandListCount(IdleLandListVo idleLandListVo);
+
+    LandIdleConfirmDTO getByLandId(String landId);
 }

+ 2 - 1
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/mapper/tdgy/LandIdleDisposalMapper.java

@@ -1,10 +1,11 @@
 package com.onemap.apply.mapper.tdgy;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.onemap.apply.domain.tdgy.dto.LandIdleConfirmDTO;
 import com.onemap.apply.domain.tdgy.dto.LandIdleDisposalDTO;
 import org.apache.ibatis.annotations.Mapper;
 
 @Mapper
 public interface LandIdleDisposalMapper extends BaseMapper<LandIdleDisposalDTO> {
-
+    LandIdleDisposalDTO getByLandId(String landId);
 }

+ 31 - 16
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/impl/tdgy/TdgyServiceImp.java

@@ -2,26 +2,27 @@ package com.onemap.apply.service.impl.tdgy;
 
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.onemap.apply.domain.tdgy.dto.FileObj;
 import com.onemap.apply.domain.tdgy.dto.LandIdleConfirmDTO;
 import com.onemap.apply.domain.tdgy.dto.LandIdleDisposalDTO;
+import com.onemap.apply.domain.tdgy.dto.TdgySjDTO;
+import com.onemap.apply.domain.tdgy.res.TdgySjRes;
 import com.onemap.apply.domain.tdgy.vo.IdleLandListVo;
 import com.onemap.apply.domain.tdgy.vo.LandIdleConfirmVo;
 import com.onemap.apply.domain.tdgy.vo.LandIdleDisposalVo;
+import com.onemap.apply.domain.tdgy.vo.UpdateTdgyVo;
 import com.onemap.apply.mapper.tdgy.LandIdleConfirmMapper;
 import com.onemap.apply.mapper.tdgy.LandIdleDisposalMapper;
-import com.onemap.apply.utils.DozerUtils;
-import com.onemap.common.core.utils.uuid.IdUtils;
-import com.onemap.common.datasource.annotation.Master;
-
-import com.onemap.apply.domain.tdgy.dto.TdgySjDTO;
-import com.onemap.apply.domain.tdgy.res.TdgySjRes;
-import com.onemap.apply.domain.tdgy.vo.UpdateTdgyVo;
 import com.onemap.apply.mapper.tdgy.TdgyMapper;
 import com.onemap.apply.service.tdgy.TdgyService;
+import com.onemap.apply.utils.DozerUtils;
+import com.onemap.common.core.utils.uuid.IdUtils;
 import com.onemap.common.core.web.domain.RequestResult;
+import com.onemap.common.datasource.annotation.Master;
 import com.onemap.common.datasource.annotation.Slave;
-
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -162,9 +163,16 @@ public class TdgyServiceImp implements TdgyService {
      * @return
      */
     @Override
-    public RequestResult getIdleLandConfirm(String landId) {
+    public RequestResult getIdleLandConfirm(String landId) throws JsonProcessingException {
         // 根据landId查询判定信息
-        LandIdleConfirmDTO landIdleConfirmDTO = landIdleConfirmMapper.selectOne(new UpdateWrapper<LandIdleConfirmDTO>().eq("land_id", landId));
+        LandIdleConfirmDTO landIdleConfirmDTO = landIdleConfirmMapper.getByLandId(landId);
+        if (landIdleConfirmDTO.getFilesStr() != null && !landIdleConfirmDTO.getFilesStr().equals("")) {
+            ObjectMapper objectMapper = new ObjectMapper();
+            List<FileObj> files = objectMapper.readValue(landIdleConfirmDTO.getFilesStr(), new TypeReference<List<FileObj>>() {
+            });
+            landIdleConfirmDTO.setFiles(files);
+        }
+
         return RequestResult.success(landIdleConfirmDTO);
     }
 
@@ -217,9 +225,7 @@ public class TdgyServiceImp implements TdgyService {
 
         // 根据landId更新表t_land_idle_confirm的is_disposal字段
         if (landIdleDisposalDTO.getDisposalTime() != null) {
-            Wrapper<LandIdleConfirmDTO> wrapperConfirm = new UpdateWrapper<LandIdleConfirmDTO>().eq("land_id", landId);
-
-            LandIdleConfirmDTO landIdleConfirmDTO = landIdleConfirmMapper.selectOne(wrapperConfirm);
+            LandIdleConfirmDTO landIdleConfirmDTO = landIdleConfirmMapper.getByLandId(landId);
             landIdleConfirmDTO.setIsDisposal(true);
             landIdleConfirmMapper.updateById(landIdleConfirmDTO);
         }
@@ -231,9 +237,18 @@ public class TdgyServiceImp implements TdgyService {
      * 获取闲置土地处置详情
      */
     @Override
-    public RequestResult getIdleLandDisposal(String landId) {
+    public RequestResult getIdleLandDisposal(String landId) throws JsonProcessingException {
         // 根据landId查询处置信息
-        LandIdleDisposalDTO landIdleDisposalDTO = landIdleDisposalMapper.selectOne(new UpdateWrapper<LandIdleDisposalDTO>().eq("land_id", landId));
+        // LandIdleDisposalDTO landIdleDisposalDTO = landIdleDisposalMapper.selectOne(new UpdateWrapper<LandIdleDisposalDTO>().eq("land_id", landId));
+        // 根据landId查询判定信息
+        LandIdleDisposalDTO landIdleDisposalDTO = landIdleDisposalMapper.getByLandId(landId);
+        if (landIdleDisposalDTO.getFilesStr() != null && !landIdleDisposalDTO.getFilesStr().equals("")) {
+            ObjectMapper objectMapper = new ObjectMapper();
+            List<FileObj> files = objectMapper.readValue(landIdleDisposalDTO.getFilesStr(), new TypeReference<List<FileObj>>() {
+            });
+            landIdleDisposalDTO.setFiles(files);
+        }
+
         return RequestResult.success(landIdleDisposalDTO);
     }
 

+ 3 - 2
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/tdgy/TdgyService.java

@@ -1,5 +1,6 @@
 package com.onemap.apply.service.tdgy;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.onemap.apply.domain.tdgy.vo.IdleLandListVo;
 import com.onemap.apply.domain.tdgy.vo.LandIdleConfirmVo;
 import com.onemap.apply.domain.tdgy.vo.LandIdleDisposalVo;
@@ -19,7 +20,7 @@ public interface TdgyService {
 
     RequestResult idleLandList(IdleLandListVo idleLandListVo);
 
-    RequestResult getIdleLandDisposal(String landId);
+    RequestResult getIdleLandDisposal(String landId) throws JsonProcessingException;
 
-    RequestResult getIdleLandConfirm(String landId);
+    RequestResult getIdleLandConfirm(String landId) throws JsonProcessingException;
 }

+ 19 - 0
onemap-modules/onemap-apply/src/main/resources/mapper/postgresql/tdgy/LandIdelConfirmMapper.xml

@@ -1,6 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.onemap.apply.mapper.tdgy.LandIdleConfirmMapper">
+
+
     <select id="getIdleLandList" resultType="Map">
         SELECT td.id, td.srf, td.crmj, td.cqzh, public.st_asewkt(public.st_union(tb.geom))
         FROM base.t_land_idle_confirm AS confirm
@@ -35,4 +37,21 @@
             AND confirm.idle_reason = #{idleReason}
         </if>
     </select>
+
+    <select id="getByLandId" resultType="com.onemap.apply.domain.tdgy.dto.LandIdleConfirmDTO">
+        SELECT
+            id,
+            land_id AS landId,
+            is_idle AS isIdle,
+            is_disposal AS isDisposal,
+            idle_reason AS idleReason,
+            idle_time AS idleTime,
+            confirm_time AS confirmTime,
+            confirm_basis AS confirmBasis,
+            files::VARCHAR as filesStr
+        FROM
+            t_land_idle_confirm
+        WHERE
+            land_id = #{landId}
+    </select>
 </mapper>

+ 14 - 19
onemap-modules/onemap-apply/src/main/resources/mapper/postgresql/tdgy/LandIdelDisposalMapper.xml

@@ -1,24 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.onemap.apply.mapper.tdgy.LandIdleDisposalMapper">
-<!--    <select id="getSuspectedIdleLand" resultType="map">-->
-<!--        SELECT id, xmmc, crmj, ydkgsj-->
-<!--        from tdgy_sj-->
-<!--        WHERE (sfjg!=true or sfjg is null)-->
-<!--        and (NOW() - sjkgsj > INTERVAL '365 days')-->
-<!--        <if test="key != null and key != ''">-->
-<!--            and (xmmc like '%'||#{key}||'%' or srf like '%'||#{key}||'%')-->
-<!--        </if>-->
-<!--        <if test="xzqh != null and xzqh != ''">-->
-<!--            and xzqh = #{xzqh}-->
-<!--        </if>-->
-<!--        limit #{limit} offset #{offset};-->
-<!--    </select>-->
 
-<!--    <select id="getLandGeometry" resultType="String">-->
-<!--        public.st_asewkt(public.st_union(geom))-->
-<!--        from "TB_TDGY_SJ"-->
-<!--        WHERE pid=-->
-<!--        #{pid};-->
-<!--    </select>-->
+
+    <select id="getByLandId" resultType="com.onemap.apply.domain.tdgy.dto.LandIdleDisposalDTO">
+        SELECT
+            id,
+            land_id AS landId,
+            disposal_time AS disposalTime,
+            disposal_method AS disposalMethod,
+            disposal_info AS disposalInfo,
+            files AS filesStr
+        FROM
+            t_land_idle_disposal
+        WHERE
+            land_id = #{landId}
+    </select>
 </mapper>