Sfoglia il codice sorgente

添加判定,处置

gushoubang 6 mesi fa
parent
commit
b0bf8e9b2c

+ 62 - 0
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/config/FileObjTypeHandler.java

@@ -0,0 +1,62 @@
+package com.onemap.apply.config;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.ibatis.type.BaseTypeHandler;
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.MappedTypes;
+import org.postgresql.util.PGobject;
+
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+@MappedTypes({Object.class})
+public class FileObjTypeHandler extends BaseTypeHandler<Object> {
+    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 {
+        if (preparedStatement != null) {
+            jsonObject.setType("jsonb");
+            try {
+                jsonObject.setValue(objectMapper.writeValueAsString(o));  // 使用 Jackson 进行序列化
+            } catch (JsonProcessingException e) {
+                throw new SQLException("Error converting Object to JSON", e);
+            }
+            preparedStatement.setObject(i, jsonObject);
+        }
+    }
+
+    @Override
+    public Object getNullableResult(ResultSet resultSet, String s) throws SQLException {
+        String json = resultSet.getString(s);
+        try {
+            return objectMapper.readValue(json, Object.class);  // 使用 Jackson 进行反序列化
+        } catch (JsonProcessingException e) {
+            throw new SQLException("Error converting JSON to Object", e);
+        }
+    }
+
+    @Override
+    public Object getNullableResult(ResultSet resultSet, int i) throws SQLException {
+        String json = resultSet.getString(i);
+        try {
+            return objectMapper.readValue(json, Object.class);  // 使用 Jackson 进行反序列化
+        } catch (JsonProcessingException e) {
+            throw new SQLException("Error converting JSON to Object", e);
+        }
+    }
+
+    @Override
+    public Object getNullableResult(CallableStatement callableStatement, int i) throws SQLException {
+        String json = callableStatement.getString(i);
+        try {
+            return objectMapper.readValue(json, Object.class);  // 使用 Jackson 进行反序列化
+        } catch (JsonProcessingException e) {
+            throw new SQLException("Error converting JSON to Object", e);
+        }
+    }
+}

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

@@ -6,8 +6,6 @@ import com.onemap.apply.domain.tdgy.vo.LandIdleDisposalVo;
 import com.onemap.apply.domain.tdgy.vo.UpdateTdgyVo;
 import com.onemap.apply.service.tdgy.TdgyService;
 import com.onemap.common.core.web.domain.RequestResult;
-import com.onemap.common.security.utils.SecurityUtils;
-import org.apache.ibatis.annotations.Param;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;

+ 9 - 0
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/domain/tdgy/dto/FileObj.java

@@ -0,0 +1,9 @@
+package com.onemap.apply.domain.tdgy.dto;
+
+import lombok.Data;
+
+@Data
+public class FileObj {
+    private String fileName;
+    private String fileUrl;
+}

+ 3 - 2
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/domain/tdgy/dto/LandIdleConfirmDTO.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.onemap.apply.config.FileObjTypeHandler;
 import com.onemap.apply.config.StringListTypeHandler;
 import lombok.Data;
 
@@ -40,6 +41,6 @@ public class LandIdleConfirmDTO {
     private String confirmBasis;
 
     // 认定文件
-    @TableField(value = "files", typeHandler = StringListTypeHandler.class)
-    private List<String> files;
+    @TableField(value = "files", typeHandler = FileObjTypeHandler.class)
+    private List<FileObj> files;
 }

+ 3 - 6
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/domain/tdgy/dto/LandIdleDisposalDTO.java

@@ -3,7 +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.onemap.apply.config.StringListTypeHandler;
+import com.onemap.apply.config.FileObjTypeHandler;
 import lombok.Data;
 
 import java.util.Date;
@@ -19,9 +19,6 @@ public class LandIdleDisposalDTO {
     // 土地id
     @TableField("land_id")
     private String landId;
-    // //  是否处置
-    // @TableField("is_disposal")
-    // private Boolean isDisposal;
     // 处置时间
     @TableField("disposal_time")
     @JsonFormat(pattern = "yyyy/MM/dd")
@@ -33,6 +30,6 @@ public class LandIdleDisposalDTO {
     @TableField("disposal_info")
     private String disposalInfo;
     // 处置文件
-    @TableField(value = "files", typeHandler = StringListTypeHandler.class)
-    private List<String> files;
+    @TableField(value = "files", typeHandler = FileObjTypeHandler.class)
+    private List<FileObj> files;
 }

+ 2 - 1
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/domain/tdgy/vo/LandIdleConfirmVo.java

@@ -1,6 +1,7 @@
 package com.onemap.apply.domain.tdgy.vo;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.onemap.apply.domain.tdgy.dto.FileObj;
 import lombok.Data;
 
 import javax.validation.constraints.NotNull;
@@ -23,5 +24,5 @@ public class LandIdleConfirmVo {
     private Date confirmTime;
     // 认定依据
     private String confirmBasis;
-    private List<String> files;
+    private List<FileObj> files;
 }

+ 2 - 1
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/domain/tdgy/vo/LandIdleDisposalVo.java

@@ -1,6 +1,7 @@
 package com.onemap.apply.domain.tdgy.vo;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.onemap.apply.domain.tdgy.dto.FileObj;
 import lombok.Data;
 
 import javax.validation.constraints.NotNull;
@@ -21,7 +22,7 @@ public class LandIdleDisposalVo {
     private String disposalMethod;
     // 处置情况
     private String disposalInfo;
-    private List<String> files;
+    private List<FileObj> files;
 
     // TODO,重置约定开工时间
 }

+ 23 - 19
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/impl/tdgy/TdgyServiceImp.java

@@ -137,16 +137,16 @@ public class TdgyServiceImp implements TdgyService {
      */
     @Master
     @Override
+    @Transactional
     public RequestResult addIdleLandConfirm(LandIdleConfirmVo landIdleConfirmVo) {
         String landId = landIdleConfirmVo.getLandId();
-        // 查询认定信息是否存在
-        LandIdleConfirmDTO landIdleConfirmDTO = landIdleConfirmMapper.selectById(landId);
-        if (landIdleConfirmDTO != null) {
-            return RequestResult.error("认定信息已存在");
-        }
+
+        // 根据landId删除处置信息
+        Wrapper<LandIdleConfirmDTO> wrapper = new UpdateWrapper<LandIdleConfirmDTO>().eq("land_id", landId);
+        landIdleConfirmMapper.delete(wrapper);
 
         // 添加认定信息
-        landIdleConfirmDTO = new LandIdleConfirmDTO();
+        LandIdleConfirmDTO landIdleConfirmDTO = new LandIdleConfirmDTO();
         DozerUtils.map(landIdleConfirmVo, landIdleConfirmDTO);
 
         String uuid = IdUtils.simpleUUID();
@@ -155,6 +155,19 @@ public class TdgyServiceImp implements TdgyService {
         return RequestResult.success();
     }
 
+    /**
+     * 获取闲置土地判定详情
+     *
+     * @param landId
+     * @return
+     */
+    @Override
+    public RequestResult getIdleLandConfirm(String landId) {
+        // 根据landId查询判定信息
+        LandIdleConfirmDTO landIdleConfirmDTO = landIdleConfirmMapper.selectOne(new UpdateWrapper<LandIdleConfirmDTO>().eq("land_id", landId));
+        return RequestResult.success(landIdleConfirmDTO);
+    }
+
     /**
      * 获取闲置土地
      */
@@ -204,7 +217,9 @@ public class TdgyServiceImp implements TdgyService {
 
         // 根据landId更新表t_land_idle_confirm的is_disposal字段
         if (landIdleDisposalDTO.getDisposalTime() != null) {
-            LandIdleConfirmDTO landIdleConfirmDTO = landIdleConfirmMapper.selectById(landId);
+            Wrapper<LandIdleConfirmDTO> wrapperConfirm = new UpdateWrapper<LandIdleConfirmDTO>().eq("land_id", landId);
+
+            LandIdleConfirmDTO landIdleConfirmDTO = landIdleConfirmMapper.selectOne(wrapperConfirm);
             landIdleConfirmDTO.setIsDisposal(true);
             landIdleConfirmMapper.updateById(landIdleConfirmDTO);
         }
@@ -222,16 +237,5 @@ public class TdgyServiceImp implements TdgyService {
         return RequestResult.success(landIdleDisposalDTO);
     }
 
-    /**
-     * 获取闲置土地判定详情
-     *
-     * @param landId
-     * @return
-     */
-    @Override
-    public RequestResult getIdleLandConfirm(String landId) {
-        // 根据landId查询判定信息
-        LandIdleConfirmDTO landIdleConfirmDTO = landIdleConfirmMapper.selectOne(new UpdateWrapper<LandIdleConfirmDTO>().eq("land_id", landId));
-        return RequestResult.success(landIdleConfirmDTO);
-    }
+
 }