Jelajahi Sumber

Merge branch 'dev-excel0521' into dev-to-user-1

# Conflicts:
#	siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/ProjectMapper.java
#	siwei-modules/siwei-apply/src/main/resources/mapper/ProjectMapper.xml
chenendian 2 minggu lalu
induk
melakukan
8a85d7c5ed
21 mengubah file dengan 807 tambahan dan 42 penghapusan
  1. 68 0
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/config/GeoToolsEpsgRuntimeCheck.java
  2. 45 11
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/third/OfferDataController.java
  3. 12 0
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/ProjectImmobileCode.java
  4. 46 0
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/vo/ThirdProjectParamVo.java
  5. 100 0
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/vo/ThirdRecordStatusParamVo.java
  6. 4 0
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/NodeLandMapper.java
  7. 7 1
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/ProjectImmobileCodeMapper.java
  8. 16 0
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/ProjectMapper.java
  9. 29 0
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/ThirdRecordStatusMapper.java
  10. 1 0
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/NodeLandService.java
  11. 1 2
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/impl/ParcelServiceImpl.java
  12. 7 0
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/impl/NodeLandImpl.java
  13. 17 1
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/impl/ProjectImpl.java
  14. 15 2
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/OfferDataService.java
  15. 10 0
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/TakeDataService.java
  16. 124 19
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/impl/OfferDataServiceImpl.java
  17. 55 1
      siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/impl/TakeDataServiceImpl.java
  18. 22 0
      siwei-modules/siwei-apply/src/main/resources/mapper/NodeLandMapper.xml
  19. 48 5
      siwei-modules/siwei-apply/src/main/resources/mapper/ProjectImmobileCodeMapper.xml
  20. 85 0
      siwei-modules/siwei-apply/src/main/resources/mapper/ProjectMapper.xml
  21. 95 0
      siwei-modules/siwei-apply/src/main/resources/mapper/ThirdRecordStatusMapper.xml

+ 68 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/config/GeoToolsEpsgRuntimeCheck.java

@@ -0,0 +1,68 @@
+package com.siwei.apply.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.geotools.referencing.CRS;
+import org.geotools.referencing.ReferencingFactoryFinder;
+import org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Component;
+
+import java.util.Set;
+
+@Slf4j
+@Component
+public class GeoToolsEpsgRuntimeCheck implements ApplicationRunner {
+    private static final String EPSG_FACTORY_CLASS =
+            "org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory";
+
+//    @Override
+//    public void run(ApplicationArguments args) {
+//        try {
+//            Class.forName(EPSG_FACTORY_CLASS);
+//            ThreadedHsqlEpsgFactory hsqlFactory = new ThreadedHsqlEpsgFactory();
+//            ReferencingFactoryFinder.addAuthorityFactory(hsqlFactory);
+//            ReferencingFactoryFinder.scanForPlugins();
+//            Set<String> codes = CRS.getSupportedCodes("EPSG");
+//            Object authorityFactory = CRS.getAuthorityFactory(true);
+//            CoordinateReferenceSystem crs = CRS.decode("EPSG:4490");
+//            CoordinateReferenceSystem hsqlCrs = hsqlFactory.createCoordinateReferenceSystem("4490");
+//            log.info("GeoTools EPSG运行时检查通过:factoryClass={}, authorityFactory={}, has4490={}, crs={}, hsqlCrs={}",
+//                    EPSG_FACTORY_CLASS, authorityFactory.getClass().getName(), codes.contains("4490"),
+//                    crs.getName(), hsqlCrs.getName());
+//        } catch (Exception e) {
+//            log.error("GeoTools EPSG:4490运行时检查失败,请确认运行包包含gt-epsg-hsql、hsqldb,且没有通过loader.path或外部lib混入其他版本GeoTools依赖", e);
+//        }
+
+//
+//    }
+
+
+
+    @Override
+    public void run(ApplicationArguments args) {
+        try {
+            // 1. 检查工厂是否可用
+            boolean available = CRS.getAuthorityFactory(true) != null;
+
+            // 2. 解码目标坐标系(这一步会触发 HSQL backing store 的惰性初始化)
+            CoordinateReferenceSystem crs = CRS.decode("EPSG:4490");
+
+            // 3. 检查支持的编码列表
+            Set<String> codes = CRS.getSupportedCodes("EPSG");
+            boolean has4490 = codes.contains("4490");
+
+            log.info("GeoTools EPSG运行时检查通过:factoryAvailable={}, has4490={}, crs={}",
+                    available, has4490, crs.getName());
+
+        } catch (Exception e) {
+            // 降级为 WARN,不阻断启动 —— CRS 在真正用到时会再次惰性尝试
+            log.warn("GeoTools EPSG:4490运行时检查失败,请确认运行包包含gt-epsg-hsql、hsqldb," +
+                    "且Temp目录无残留锁文件。应用将继续启动,CRS将在使用时惰性重试。错误:{}", e.getMessage());
+        }
+    }
+
+
+
+}

+ 45 - 11
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/third/OfferDataController.java

@@ -2,9 +2,7 @@ package com.siwei.apply.controller.third;
 
 import com.siwei.apply.domain.LandOneCode;
 import com.siwei.apply.domain.NodeAttachment;
-import com.siwei.apply.domain.vo.AttachmentParamVo;
-import com.siwei.apply.domain.vo.HouseFirstParamVo;
-import com.siwei.apply.domain.vo.LandFirstParamVo;
+import com.siwei.apply.domain.vo.*;
 import com.siwei.apply.service.third.OfferDataService;
 import com.siwei.apply.utils.ServiceUtil;
 import com.siwei.common.core.domain.R;
@@ -28,6 +26,7 @@ import java.net.URLEncoder;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 
@@ -47,6 +46,43 @@ public class OfferDataController extends BaseController {
     private RedisService redisService;
 
 
+
+    /**
+     *  接收推送的登簿状体数据
+     * @param body
+     * @return
+     */
+    @PostMapping("/third/receiveRecordStatusData")
+    public R<Map<String, Object>> addRecordStatusData(@RequestBody ThirdRecordStatusParamVo body) {
+        try {
+            Map<String, Object> map = offerDataService.addRecordStatusData(body);
+            map.put("id", map.get("id"));
+            return R.ok(map);
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+
+
+    /**
+     *
+     * 获取土地供应和项目信息
+     * @param body
+     * @return
+     */
+    @PostMapping("/third/getLandSupplyList")
+    public R<List<Map<String, Object>>> landSupplyList(@RequestBody ThirdProjectParamVo body) {
+        try {
+            List<Map<String, Object>> map = offerDataService.landSupplyAndProjectList(body);
+            return R.ok(map);
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+
+
     /**
      * 国有建设用地使用权首次登记
      * 不动产土地登记完成后入参使用
@@ -54,8 +90,6 @@ public class OfferDataController extends BaseController {
     @PostMapping("/third/landFirstRegistration")
     public R<Map<String, Object>> landFirstRegistration(@RequestBody LandFirstParamVo body) {
         try {
-//             landFirstParamVo
-//             houseFirstParamVo
             Map<String, Object> map = offerDataService.landFirstRegistration(body);
             map.put("id", map.get("id"));
             return R.ok(map);
@@ -116,18 +150,18 @@ public class OfferDataController extends BaseController {
     public R<NodeAttachment> attachmentList(@RequestBody AttachmentParamVo paramVo) {
         try {
             String projectId = paramVo.getYwbh();
-            String immobileCode = paramVo.getYfbdcdyh();
+            String preImmobileCode = paramVo.getYfbdcdyh();
             String dqjd = paramVo.getDqjd();
-            if (StringUtils.isBlank(immobileCode)) {
+            if (StringUtils.isBlank(preImmobileCode)) {
                 return R.fail(502, "不动产号为空,请填充");
             }
             if (StringUtils.isBlank(dqjd)) {
                 return R.fail(502, "标识阶段为空,请填充");
             }
-            if (StringUtils.isBlank(projectId)) {
-                return R.fail(502, "项目id为空,请填充");
-            }
-            NodeAttachment nodeAttachment = offerDataService.getThirdNodeAttachment(immobileCode, projectId, dqjd);
+//            if (StringUtils.isBlank(projectId)) {
+//                return R.fail(502, "项目id为空,请填充");
+//            }
+            NodeAttachment nodeAttachment = offerDataService.getThirdNodeAttachment(preImmobileCode, projectId, dqjd);
             return R.ok(nodeAttachment);
         } catch (Exception e) {
             return R.fail(502, "获取附件材料失败");

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

@@ -20,5 +20,17 @@ public class ProjectImmobileCode extends BaseId {
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date updatedAt;
+
+    /** 环节id */
+    private String nodeId;
+
+    /** 矢量批次 */
+    private Integer geomDbId;
+
+    /** 数据id */
+    private Integer geomDetailsId;
+
+    /** 预赋不动产单元号 */
+    private String preAssignCode;
 }
 

+ 46 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/vo/ThirdProjectParamVo.java

@@ -0,0 +1,46 @@
+package com.siwei.apply.domain.vo;
+
+import lombok.Data;
+
+/**
+ * 第三方项目参数 Vo
+ */
+@Data
+public class ThirdProjectParamVo {
+
+    /**
+     * 项目名称
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String xmmc;
+
+    /**
+     * 项目代码(例: 2211-360090-04-01-897353)
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String xmdm;
+
+    /**
+     * 受让方
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String srf;
+
+    /**
+     * 预赋不动产单元号(19位)
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String yfbdcdyh;
+
+    /**
+     * 空间地块矢量图数据(EWKT格式)
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String geom;
+
+}

+ 100 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/vo/ThirdRecordStatusParamVo.java

@@ -0,0 +1,100 @@
+package com.siwei.apply.domain.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 第三方项目参数 Vo
+ */
+@Data
+public class ThirdRecordStatusParamVo {
+
+    /**
+     * 主键
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String id;
+
+    /**
+     * 是否完成同步(0未同步,1.已同步)
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String tbzt;
+
+    /**
+     * 创建时间
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createdAt;
+
+    /**
+     * 更新时间
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updatedAt;
+
+    /**
+     * 不动产单元号
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String bdydyh;
+
+    /**
+     * 预赋不动产单元号
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String yfbdydyh;
+
+    /**
+     * 业务类型(1-国有建设用地使用权首次登记,2-国有建设用地使用权及房屋所有权首次登记)
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String ywlx;
+
+    /**
+     * 是否登簿(Y-是,N-否)
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String sfdengbu;
+
+    /**
+     * 登簿日期(yyyy-MM-dd)sfdengbu=Y时必传
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String dengburq;
+
+    /**
+     * 权利人名称
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String qlrmc;
+
+    /**
+     * 权利人证件号
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String qlrzjh;
+
+    /**
+     * 业务号(告知单等关联号,房屋登记建议传)
+     * 必选: 否
+     * 业务类型: 业务
+     */
+    private String ywh;
+
+}

+ 4 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/NodeLandMapper.java

@@ -59,6 +59,10 @@ public interface NodeLandMapper {
 
     List<Map<String, Object>> selectGeomDetailsByGeomDbId( @Param("geomDbId")String geomDbId);
 
+    List<NodeLand> selectByGeom(@Param("ewkt") String ewkt);
+
+    Map<String, String> selectDjzqContainsNodeList(@Param("detailsId")String detailsId);
+
 
 
 }

+ 7 - 1
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/ProjectImmobileCodeMapper.java

@@ -32,13 +32,19 @@ public interface ProjectImmobileCodeMapper {
      */
     List<ProjectImmobileCode> selectByBusinessIdList(@Param("businessIdList") List<String> businessIdList);
 
+
+    /**
+     * 根据业务ID查询(只返回一条)
+     */
+    ProjectImmobileCode selectByPreAssignCode(@Param("preAssignCode") String preAssignCode);
+
     /**
      * 插入记录
      */
     void insert(ProjectImmobileCode projectImmobileCode);
 
     /**
-     * 根据业务ID更新记录(更新 code, validFlag, updatedAt)
+     * 根据业务ID更新记录(更新 code, validFlag, updatedAt, nodeId, geomDbId, geomDetailsId, preAssignCode
      */
     void update(ProjectImmobileCode projectImmobileCode);
 

+ 16 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/ProjectMapper.java

@@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 @Mapper
 public interface ProjectMapper {
@@ -86,6 +87,13 @@ public interface ProjectMapper {
 
     Integer getSearchGraphicLayerCount(ProjectFilterVo projectFilterVo);
 
+    /**
+     * 获取工改同步项目信息
+     * @param nodeTableName
+     * @return
+     */
+    List<Project> getZrzysiteProjectList(String nodeTableName);
+
 
     /**
      * 获取工改同步项目信息
@@ -100,6 +108,14 @@ public interface ProjectMapper {
 
 
 
+    String getNodeSourceIdByTable(@Param("nodeId")String nodeId,@Param("tableName") String tableName);
+
+
+    List<Map<String,Object>> getTdyProjectList(@Param("xmmc") String xmmc,
+                                                @Param("xmdm") String xmdm,
+                                                @Param("srf") String srf,
+                                                @Param("yfbdcdyh") String yfbdcdyh,
+                                                @Param("ewkt") String ewkt);
 
 
 }

+ 29 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/ThirdRecordStatusMapper.java

@@ -0,0 +1,29 @@
+package com.siwei.apply.mapper;
+
+import com.siwei.apply.domain.vo.ThirdRecordStatusParamVo;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 不动产登簿状态表 Mapper 接口
+ */
+@Mapper
+public interface ThirdRecordStatusMapper {
+
+    /**
+     * 插入登簿状态记录
+     */
+    void insert(ThirdRecordStatusParamVo record);
+
+    /**
+     * 根据预赋不动产单元号 或 业务号 查询已存在的记录(用于判重/覆盖更新)
+     * 匹配优先级:yfbdydyh 命中优先,其次 ywh
+     */
+    ThirdRecordStatusParamVo selectByYfbdydyhOrYwh(@Param("yfbdydyh") String yfbdydyh,
+                                                   @Param("ywh") String ywh);
+
+    /**
+     * 根据主键 ID 更新登簿状态信息(覆盖更新)
+     */
+    void updateById(ThirdRecordStatusParamVo record);
+}

+ 1 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/NodeLandService.java

@@ -53,6 +53,7 @@ public interface NodeLandService {
 
     Map<String, Object> selectGeomByDbId(String geomDetailsId) ;
 
+    Map<String, String> getDjzqContainsNodeList(String geomDetailsId);
 
 
 

+ 1 - 2
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/impl/ParcelServiceImpl.java

@@ -57,12 +57,12 @@ public class ParcelServiceImpl implements IParcelService {
     }
 
 
-
     @Override
     public List<Map<String, Object>> djzqList() {
         return zdjbxxMapper.getDjzqWithDjqList();
     }
 
+
     /**
      * type 1,使用权数据多。
      * type 2,所有权数据少。
@@ -72,7 +72,6 @@ public class ParcelServiceImpl implements IParcelService {
      */
     @Override
     public ParcelStatisticsRes statistics(String djzqdm,String type) {
-
         if(StringUtils.isBlank(djzqdm) || djzqdm.matches("[0]+")){
             djzqdm = "";
         }

+ 7 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/impl/NodeLandImpl.java

@@ -230,5 +230,12 @@ public class NodeLandImpl implements NodeLandService {
     }
 
 
+    @Override
+    public Map<String, String> getDjzqContainsNodeList(String geomDetailsId) {
+        return nodeLandMapper.selectDjzqContainsNodeList(geomDetailsId);
+    }
+
+
+
 
 }

+ 17 - 1
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/impl/ProjectImpl.java

@@ -26,6 +26,7 @@ import org.geotools.data.shapefile.ShapefileDataStore;
 import org.geotools.data.shapefile.ShapefileDataStoreFactory;
 import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
 import org.geotools.referencing.CRS;
+import org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory;
 import org.locationtech.jts.geom.Geometry;
 import org.locationtech.jts.geom.MultiPolygon;
 import org.locationtech.jts.geom.Polygon;
@@ -1105,7 +1106,7 @@ public class ProjectImpl implements ProjectService {
     private void writeCycleShapefile(File shpFile, List<CycleShpRow> rows, List<String> fields) throws Exception {
         SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
         typeBuilder.setName("project_cycle");
-        CoordinateReferenceSystem crs = CRS.decode("EPSG:4490");
+        CoordinateReferenceSystem crs = decodeCgcs2000Crs();
         typeBuilder.setCRS(crs);
         typeBuilder.add("the_geom", MultiPolygon.class);
 
@@ -1152,6 +1153,21 @@ public class ProjectImpl implements ProjectService {
         }
     }
 
+    private CoordinateReferenceSystem decodeCgcs2000Crs() throws Exception {
+        try {
+            return CRS.decode("EPSG:4490");
+        } catch (Exception e) {
+            log.warn("CRS.decode解析EPSG:4490失败,改用gt-epsg-hsql权威库直接解析", e);
+            try {
+                return new ThreadedHsqlEpsgFactory().createCoordinateReferenceSystem("4490");
+            } catch (Exception hsqlException) {
+                hsqlException.addSuppressed(e);
+                log.error("项目生命周期SHP导出解析EPSG:4490失败,请确认运行包已加载gt-epsg-hsql和hsqldb,且运行时没有混入其他版本GeoTools依赖", hsqlException);
+                throw hsqlException;
+            }
+        }
+    }
+
     private Geometry parseEwkt(String ewkt, WKTReader reader) {
         if (StringUtils.isBlank(ewkt)) {
             return null;

+ 15 - 2
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/OfferDataService.java

@@ -3,7 +3,10 @@ package com.siwei.apply.service.third;
 import com.siwei.apply.domain.NodeAttachment;
 import com.siwei.apply.domain.vo.HouseFirstParamVo;
 import com.siwei.apply.domain.vo.LandFirstParamVo;
+import com.siwei.apply.domain.vo.ThirdProjectParamVo;
+import com.siwei.apply.domain.vo.ThirdRecordStatusParamVo;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -27,10 +30,20 @@ public interface OfferDataService {
 
     String  getTheFile(String attachmentId, String dirName,String fileName) ;
 
-    NodeAttachment getThirdNodeAttachment(String immobileCode, String projectId, String dqjd) throws Exception;
+    NodeAttachment getThirdNodeAttachment(String preImmobileCode, String projectId, String dqjd) throws Exception;
 
     Map<String, Object> landFirstRegistration(LandFirstParamVo body);
 
     Map<String, Object> houseFirstRegistration(HouseFirstParamVo body);
 
-}
+    List<Map<String, Object>> landSupplyAndProjectList(ThirdProjectParamVo body) ;
+
+
+    Map<String, Object> addRecordStatusData(ThirdRecordStatusParamVo body);
+
+
+
+
+
+
+    }

+ 10 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/TakeDataService.java

@@ -43,4 +43,14 @@ public interface TakeDataService {
      */
     void update(GyjsydscdjUpdateVo gyjsydscdjUpdateVo);
 
+
+    /**
+     * 获取三方数据最大序列号
+     * @param projectId
+     * @param tableName
+     * @return
+     */
+    Map<String, String> getThirdMaxSequence(String projectId,String tableName);
+
+
 }

+ 124 - 19
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/impl/OfferDataServiceImpl.java

@@ -1,13 +1,14 @@
 package com.siwei.apply.service.third.impl;
 
 import com.siwei.apply.domain.NodeAttachment;
+import com.siwei.apply.domain.ProjectImmobileCode;
 import com.siwei.apply.domain.ProjectWorkflow;
-import com.siwei.apply.domain.vo.GyjsydjfwscdjVo;
-import com.siwei.apply.domain.vo.GyjsydscdjVo;
-import com.siwei.apply.domain.vo.HouseFirstParamVo;
-import com.siwei.apply.domain.vo.LandFirstParamVo;
+import com.siwei.apply.domain.vo.*;
 import com.siwei.apply.enums.AloneWorkFlowEnum;
+import com.siwei.apply.mapper.ProjectImmobileCodeMapper;
+import com.siwei.apply.mapper.ProjectMapper;
 import com.siwei.apply.mapper.ProjectWorkflowMapper;
+import com.siwei.apply.mapper.ThirdRecordStatusMapper;
 import com.siwei.apply.service.GyjsydjfwscdjService;
 import com.siwei.apply.service.GyjsydscdjService;
 import com.siwei.apply.service.NodeAttachmentService;
@@ -16,6 +17,7 @@ import com.siwei.apply.service.third.OfferDataService;
 import com.siwei.apply.utils.ServiceUtil;
 import com.siwei.common.core.domain.R;
 import com.siwei.common.core.exception.ServiceException;
+import com.siwei.common.core.utils.uuid.IdUtils;
 import com.siwei.spatial.api.RemoteSpatialFilesDbService;
 import com.siwei.spatial.api.domain.file.TGeomDb;
 import lombok.extern.slf4j.Slf4j;
@@ -54,6 +56,18 @@ public class OfferDataServiceImpl implements OfferDataService {
     @Autowired
     private NodeLandService nodeLandService;
 
+    @Autowired
+    private ProjectMapper projectMapper;
+
+    @Autowired
+    private ThirdRecordStatusMapper thirdRecordStatusMapper;
+
+
+    @Autowired
+    private ProjectImmobileCodeMapper projectImmobileCodeMapper;
+
+
+
     @Override
     public Map<String, String> get(String projectId) {
         return Map.of();
@@ -61,9 +75,95 @@ public class OfferDataServiceImpl implements OfferDataService {
 
     @Override
     public Map<String, String> getById(String id) {
-        return Map.of();
+        Map<String, String> map = new HashMap<>();
+        map.put("code", "200");
+        map.put("msg", "查询成功111");
+        return map;
+    }
+
+    /**
+     *         获取 1.项目与土地供应,两个表进行关联。
+     *         并且为上链的,并且不动产单元号不经存在的数据。
+     * 根据入参数据,多个取并集,获取项目的相关数据
+     * @param body
+     * @return
+     */
+    @Override
+    public List<Map<String, Object>> landSupplyAndProjectList(ThirdProjectParamVo body) {
+       String projectName =  body.getXmmc();
+       String projectCode =  body.getXmdm();
+       String srf =  body.getSrf();
+       String yfbdcdyh =  body.getYfbdcdyh();
+       String ewktString =  body.getGeom();
+        List<Map<String,Object>>  result = projectMapper.getTdyProjectList(
+                projectName, projectCode, srf, yfbdcdyh, ewktString);
+        return result;
+    }
+
+    @Override
+    public Map<String, Object> addRecordStatusData(ThirdRecordStatusParamVo body) {
+
+        // 字段校验:参考 landFirstRegistration 的校验方式
+        String yfbdydyh = body.getYfbdydyh();
+        if (StringUtils.isBlank(yfbdydyh)) {
+            throw new ServiceException("预赋不动产单元号为空");
+        }
+        if (yfbdydyh.length() != 19) {
+            throw new ServiceException("预赋不动产单元号长度必须为19位");
+        }
+
+        String ywlx = body.getYwlx();
+        if (StringUtils.isBlank(ywlx)) {
+            throw new ServiceException("业务类型为空");
+        }
+        if (!"1".equals(ywlx) && !"2".equals(ywlx)) {
+            throw new ServiceException("业务类型只能为1或2");
+        }
+
+        String sfdengbu = body.getSfdengbu();
+        if (StringUtils.isBlank(sfdengbu)) {
+            throw new ServiceException("是否登簿为空");
+        }
+        if (!"Y".equals(sfdengbu) && !"N".equals(sfdengbu)) {
+            throw new ServiceException("是否登簿只能为Y或N");
+        }
+
+        String dengburq = body.getDengburq();
+        if ("Y".equals(sfdengbu)) {
+            if (StringUtils.isBlank(dengburq)) {
+                throw new ServiceException("登簿日期为空");
+            }
+            if (!dengburq.matches("^\\d{4}-\\d{2}-\\d{2}$")) {
+                throw new ServiceException("登簿日期格式必须为yyyy-MM-dd");
+            }
+        }
+
+        String ywh = body.getYwh();
+        if (StringUtils.isBlank(ywh)) {
+            throw new ServiceException("业务号为空");
+        }
+
+        // 入库:以 yfbdydyh 或 ywh 判重,已存在则按主键覆盖更新,避免重复插入
+        ThirdRecordStatusParamVo existing = thirdRecordStatusMapper.selectByYfbdydyhOrYwh(yfbdydyh, ywh);
+        String id;
+        if (existing != null) {
+            // 复用原主键,覆盖更新业务字段
+            id = existing.getId();
+            body.setId(id);
+            thirdRecordStatusMapper.updateById(body);
+        } else {
+            id = IdUtils.fastSimpleUUID();
+            body.setId(id);
+            body.setTbzt("0");
+            thirdRecordStatusMapper.insert(body);
+        }
+
+        Map<String, Object> map = new HashMap<>();
+        map.put("id", id);
+        return map;
     }
 
+
     @Override
     public Map<String, Object> landFirstRegistration(LandFirstParamVo body) {
         String yfbdcdyh = body.getYfbdcdyh();
@@ -133,11 +233,9 @@ public class OfferDataServiceImpl implements OfferDataService {
             throw new ServiceException("geom信息为空");
         }
         //todo 这里进行文件下载入库:
-
         try {
             GyjsydjfwscdjVo gyjsydjfwscdjVo = new GyjsydjfwscdjVo();
             gyjsydjfwscdjVo.setProjectId(body.getXmbh());
-
 //            gyjsydjfwscdjVo.setYwh(body.getYwh());
 //            gyjsydjfwscdjVo.setGzdgzsj(body.getGzdgzsj());
 //            gyjsydjfwscdjVo.setKfdw(body.getKfdw());
@@ -171,8 +269,6 @@ public class OfferDataServiceImpl implements OfferDataService {
     }
 
 
-
-
     @Override
     public String getTheFile(String attachmentId, String dirName, String fileName) {
         String fileAndPath = "";
@@ -192,17 +288,26 @@ public class OfferDataServiceImpl implements OfferDataService {
     }
 
     @Override
-    public NodeAttachment getThirdNodeAttachment(String immobileCode, String projectId, String dqjd) throws Exception {
-        String nodeTableName = dqjd.equals("00") ? AloneWorkFlowEnum.NODE_2.getTableName() : dqjd.equals("01") ? AloneWorkFlowEnum.NODE_6.getTableName() : "";
+    public NodeAttachment getThirdNodeAttachment(String preImmobileCode, String projectId, String dqjd) throws Exception {
         NodeAttachment nodeAttachment = null;
-        List<ProjectWorkflow> projectWorkflows = projectWorkflowMapper.selectByProjectIdAndNodeTableName(projectId, nodeTableName);
-        Optional<ProjectWorkflow> res = projectWorkflows.stream().findFirst();
-        if (res.isPresent()) {
-            String nodeId = res.get().getNodeId();
-            log.info("-------getAttachmentByProjectIdAndTable-----" + nodeId);
-            nodeAttachment = nodeAttachmentService.getNodeAttachmentData(nodeId, null);
-            //这里获取到所有附件文件路径进行转化拼接为新的
-            ServiceUtil.convertFilePath(nodeAttachment);
+        //这里根据预赋不动产单元号获取项目id
+        if(StringUtils.isBlank(projectId)){
+            ProjectImmobileCode existing = projectImmobileCodeMapper.selectByPreAssignCode(preImmobileCode);
+            if (Objects.nonNull(existing)) {
+                projectId = existing.getProjectId();
+            }
+        }
+        if(StringUtils.isNotBlank(projectId)){
+            String nodeTableName = dqjd.equals("00") ? AloneWorkFlowEnum.NODE_2.getTableName() : dqjd.equals("01") ? AloneWorkFlowEnum.NODE_6.getTableName() : "";
+            List<ProjectWorkflow> projectWorkflows = projectWorkflowMapper.selectByProjectIdAndNodeTableName(projectId, nodeTableName);
+            Optional<ProjectWorkflow> res = projectWorkflows.stream().findFirst();
+            if (res.isPresent()) {
+                String nodeId = res.get().getNodeId();
+                log.info("-------getAttachmentByProjectIdAndTable-----" + nodeId);
+                nodeAttachment = nodeAttachmentService.getNodeAttachmentData(nodeId, null);
+                //这里获取到所有附件文件路径进行转化拼接为新的
+                ServiceUtil.convertFilePath(nodeAttachment);
+            }
         }
         return nodeAttachment;
     }

+ 55 - 1
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/impl/TakeDataServiceImpl.java

@@ -13,8 +13,10 @@ import com.siwei.apply.service.NodeLandService;
 import com.siwei.apply.service.ProjectService;
 import com.siwei.apply.service.third.TakeDataService;
 import com.siwei.apply.utils.HttpClientUtil;
+import com.siwei.common.core.utils.StringUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -45,9 +47,54 @@ public class TakeDataServiceImpl implements TakeDataService {
     }
 
     @Override
-    public Map<String, String> getImmobileCode(String projectId) {
+    public Map<String, String> getThirdMaxSequence(String projectId,String tableName) {
         Map<String, String> retMap = new LinkedHashMap<>();
+        Project project = projectService.get(projectId);
+        String firstPlotCode = project.getFirstPlotCode();
+        String secondPlotCode = project.getSecondPlotCode();
+        if(StringUtils.isEmpty(firstPlotCode)){
+            firstPlotCode = "G";
+        }
+        if(StringUtils.isEmpty(secondPlotCode)){
+            secondPlotCode = "B";
+        }
+
+        //获取地籍子区的代码
+        String regionCode = "";
+        List<ProjectWorkflow> projectWorkflows = projectWorkflowMapper.selectByProjectIdAndNodeTableName(projectId, tableName);
+        if (CollectionUtils.isNotEmpty(projectWorkflows)) {
+            String nodeId = projectWorkflows.get(0).getNodeId();
+            //这里查询出来所有的geometryId,然后循环查询某个区域的
+            List<Map<String, String>> geomDetailsList = nodeLandService.selectTGeomDbDetailsByNodeId(nodeId);
+            for (Map<String, String> geomDetailsMap : geomDetailsList) {
+                String geomDetailsId = geomDetailsMap.get("id");
+                //当前地块所属地籍子区编号
+                Map<String, String>  detailGeomBelongToDjzqMap = nodeLandService.getDjzqContainsNodeList(geomDetailsId);
+                if(!MapUtils.isEmpty(detailGeomBelongToDjzqMap)){
+                    String djzqdm = detailGeomBelongToDjzqMap.get("djzqdm");
+                    regionCode = djzqdm + firstPlotCode + secondPlotCode;
+                }
+            }
+        }
+
+        if(StringUtils.isNotBlank(regionCode)){
+            Map<String, Object> paramMap = new LinkedHashMap<>();
+            paramMap.put("regionCode", regionCode);
+            // todo 这里调用 httpClient 进行远程调用
+            String result = HttpClientUtil.doGet("https://www.baidu.com", paramMap);
+            log.info("获取解析数据为:{}", result);
+            String maxSequence = "";
+            retMap.put("maxSequence", maxSequence);
+            retMap.put("state", "success");
+        }
+        return retMap;
+    }
 
+
+
+    @Override
+    public Map<String, String> getImmobileCode(String projectId) {
+        Map<String, String> retMap = new LinkedHashMap<>();
         Project project = projectService.get(projectId);
         String firstPlotCode = project.getFirstPlotCode();
         String secondPlotCode = project.getSecondPlotCode();
@@ -71,11 +118,15 @@ public class TakeDataServiceImpl implements TakeDataService {
             log.info("获取解析数据为:{}", result);
             // 构造结果进行入库
         }
+
         retMap.put("code", "12345678");
         retMap.put("projectId", projectId);
         return retMap;
     }
 
+
+
+
     @Override
     public GyjsydscdjRes get(String projectId) {
         return null;
@@ -90,4 +141,7 @@ public class TakeDataServiceImpl implements TakeDataService {
     public void update(GyjsydscdjUpdateVo gyjsydscdjUpdateVo) {
 
     }
+
+
+
 }

+ 22 - 0
siwei-modules/siwei-apply/src/main/resources/mapper/NodeLandMapper.xml

@@ -146,5 +146,27 @@
         WHERE details.upload_id = #{geomDbId}
     </select>
 
+    <select id="selectByGeom"  parameterType="String"  resultMap="BaseResultMap">
+         SELECT  bb.*   from  t_geom_db_details aa
+         LEFT JOIN t_node_land bb  on aa.upload_id = bb.geom_db_id
+         LEFT JOIN t_tdgy  cc
+         on  bb.node_id=cc.id
+         where  public.ST_Intersects(aa.geom,public.ST_GeomFromEWKT(#{ewkt})) and   cc.id is not null
+    </select>
+
+    <select id="selectDjzqContainsNodeList" resultType="Map">
+        SELECT
+            djzq.bsm,
+            djzq.ysdm,
+            djzq.djzqdm,
+            djzq.djzqmc,
+            djzq.bz,
+            djq.djqmc,
+            djq.djqdm
+        FROM vector.djzq
+        WHERE (djzq.valid_flag IS NULL OR djzq.valid_flag = 0)
+            and st_contains(ST_Buffer(djzq.geom::geography, 0.1)::geometry, (SELECT geom FROM   "public".t_geom_db_details   WHERE id = #{detailsId})) )
+            limit 1
+        </select>
 
 </mapper>

+ 48 - 5
siwei-modules/siwei-apply/src/main/resources/mapper/ProjectImmobileCodeMapper.xml

@@ -14,11 +14,16 @@
         <result property="validFlag" column="valid_flag"/>
         <result property="createdAt" column="created_at"/>
         <result property="updatedAt" column="updated_at"/>
+        <result property="nodeId" column="node_id"/>
+        <result property="geomDbId" column="geom_db_id"/>
+        <result property="geomDetailsId" column="geom_details_id"/>
+        <result property="preAssignCode" column="preAssignCode"/>
     </resultMap>
 
     <!-- 基础查询字段 -->
     <sql id="Base_Column_List">
-        id, project_id, business_id, code, valid_flag, created_at, updated_at
+        id, project_id, business_id, code, valid_flag, created_at, updated_at,
+        node_id, geom_db_id, geom_details_id, "preAssignCode"
     </sql>
 
     <!-- 根据ID查询 -->
@@ -61,6 +66,20 @@
         </where>
     </select>
 
+    <select id="selectByPreAssignCode" parameterType="String" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM t_project_immobile_code
+        <where>
+            <if test="preAssignCode != null and preAssignCode != ''">
+                pre_assign_code = #{preAssignCode}
+            </if>
+            And  valid_flag = 1
+        </where>
+        LIMIT 1
+    </select>
+
+
     <!-- 插入记录 -->
     <insert id="insert" parameterType="com.siwei.apply.domain.ProjectImmobileCode">
         INSERT INTO t_project_immobile_code (
@@ -70,7 +89,11 @@
             code,
             valid_flag,
             created_at,
-            updated_at
+            updated_at,
+            node_id,
+            geom_db_id,
+            geom_details_id,
+            "preAssignCode"
         ) VALUES (
             #{id},
             #{projectId},
@@ -78,16 +101,24 @@
             #{code},
             #{validFlag},
             #{createdAt},
-            #{updatedAt}
+            #{updatedAt},
+            #{nodeId},
+            #{geomDbId},
+            #{geomDetailsId},
+            #{preAssignCode}
         )
     </insert>
 
-    <!-- 根据业务ID更新记录(更新 code, valid_flag, updated_at) -->
+    <!-- 根据业务ID更新记录(更新 code, valid_flag, updated_at, node_id, geom_db_id, geom_details_id, preAssignCode) -->
     <update id="update" parameterType="com.siwei.apply.domain.ProjectImmobileCode">
         UPDATE t_project_immobile_code
         SET code = #{code},
             valid_flag = #{validFlag},
-            updated_at = #{updatedAt}
+            updated_at = #{updatedAt},
+            node_id = #{nodeId},
+            geom_db_id = #{geomDbId},
+            geom_details_id = #{geomDetailsId},
+            "preAssignCode" = #{preAssignCode}
         WHERE business_id = #{businessId}
     </update>
 
@@ -99,6 +130,10 @@
             <if test="businessId != null">business_id = #{businessId},</if>
             <if test="code != null">code = #{code},</if>
             <if test="validFlag != null">valid_flag = #{validFlag},</if>
+            <if test="nodeId != null">node_id = #{nodeId},</if>
+            <if test="geomDbId != null">geom_db_id = #{geomDbId},</if>
+            <if test="geomDetailsId != null">geom_details_id = #{geomDetailsId},</if>
+            <if test="preAssignCode != null">"preAssignCode" = #{preAssignCode},</if>
             <if test="updatedAt != null">updated_at = #{updatedAt}</if>
         </set>
         WHERE id = #{id}
@@ -121,5 +156,13 @@
         DELETE FROM t_project_immobile_code WHERE business_id = #{businessId}
     </delete>
 
+
+
+
+
+
+
+
+
 </mapper>
 

+ 85 - 0
siwei-modules/siwei-apply/src/main/resources/mapper/ProjectMapper.xml

@@ -832,4 +832,89 @@
         where  LENGTH(TRIM(p.code))>0   and  node.has_onchain=false  and  node.source_id is null
     </select>
 
+
+    <!-- 1.查询不动产单元号未赋值的,没有与不动产交互的。2.前置阶段已经上链的-->
+    <select id="getTdyProjectList" resultType="map">
+        SELECT
+            pro."id"          as xmbh,
+            pro."name"        as xmmc,
+            pro."code"        as xmdm,
+            td.srf            as srf,
+            td.tdyt           as tdyt,
+            td.jswz           as jswz,
+            td.gd_area        as gdmj,
+            td.gd_unit        as mjdw,
+            td.gd_type        as gdfs,
+            td.has_zz         as bzzt,
+            td.hbcrhtbh       as hbcrhtbh,
+            td.hbcrht_date    as hbcrhtrq,
+            (SELECT immobile."preAssignCode"
+               FROM t_project_immobile_code immobile
+              WHERE immobile.project_id = pro.id
+                AND immobile.valid_flag = 1
+                AND immobile."preAssignCode" IS NOT NULL
+              LIMIT 1) as yfbdcdyh,
+            (SELECT array_to_string(array_agg(ST_AsEWKT(gd.geom)), '|')
+               FROM t_node_land nl
+               LEFT JOIN t_geom_db_details gd ON nl.geom_db_id = gd.upload_id
+              WHERE nl.node_id = td.id
+                AND gd.geom IS NOT NULL) as geom
+        FROM "t_tdgy" td
+        LEFT JOIN "t_project" pro ON td.project_id = pro."id"
+        WHERE td.has_onchain = 't'
+          AND pro."id" IS NOT NULL
+          AND NOT EXISTS (
+              SELECT 1 FROM t_project_immobile_code immobile2
+               WHERE immobile2.project_id = pro.id
+                 AND immobile2.valid_flag = 1
+                 AND immobile2.code IS NOT NULL
+          )
+        <trim prefix="AND (" suffix=")" prefixOverrides="OR">
+            <if test="xmmc != null and xmmc != ''">
+                OR pro."name" LIKE '%' || #{xmmc} || '%'
+            </if>
+            <if test="xmdm != null and xmdm != ''">
+                OR pro."code" LIKE '%' || #{xmdm} || '%'
+            </if>
+            <if test="srf != null and srf != ''">
+                OR td.srf LIKE '%' || #{srf} || '%'
+            </if>
+            <if test="yfbdcdyh != null and yfbdcdyh != ''">
+                OR EXISTS (
+                    SELECT 1 FROM t_project_immobile_code immobile3
+                     WHERE immobile3.project_id = pro.id
+                       AND immobile3.valid_flag = 1
+                       AND immobile3."preAssignCode" LIKE '%' || #{yfbdcdyh} || '%'
+                )
+            </if>
+            <if test="ewkt != null and ewkt != ''">
+                OR EXISTS (
+                    SELECT 1
+                      FROM t_node_land nl2
+                      LEFT JOIN t_geom_db_details gd2 ON nl2.geom_db_id = gd2.upload_id
+                     WHERE nl2.node_id = td.id
+                       AND gd2.geom IS NOT NULL
+                       AND public.ST_Intersects(gd2.geom, public.ST_GeomFromEWKT(#{ewkt}))
+                )
+            </if>
+        </trim>
+    </select>
+
+    <select id="getNodeSourceIdByTable"   resultType="string" >
+        SELECT source_id FROM ${tableName}
+        WHERE id = #{nodeId}
+    </select>
+
+
+    <!-- 1.查询项目代码存在的所有项目,并且工程建设环节无新增数据的条数。2.查询当前环节已经新增数据但是未上链并且未同步过的数据(source_id-同步数据id)) -->
+    <select id="getZrzysiteProjectList" resultMap="projectMap">
+        SELECT    p.id,p.name,p.code ,p.project_type,  '1'  as creator_id
+        from "public"."t_project" p  LEFT JOIN  "public"."t_project_workflow"  w on p.id = w.project_id     and w.node_table_name=#{tableName}
+        where    LENGTH(TRIM(p.code))>0   and   w.id is  null
+        union
+        SELECT DISTINCT  p.id,p.name,p.code ,p.project_type ,'2' as  creator_id
+        from "public"."t_project"  p  LEFT JOIN "public".${tableName}  node  on  p.id=node.project_id
+        where  LENGTH(TRIM(p.code))>0   and  node.has_onchain=false  and  node.source_id is null
+    </select>
+
 </mapper>

+ 95 - 0
siwei-modules/siwei-apply/src/main/resources/mapper/ThirdRecordStatusMapper.xml

@@ -0,0 +1,95 @@
+<?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.siwei.apply.mapper.ThirdRecordStatusMapper">
+
+    <!-- 结果映射 -->
+    <resultMap id="BaseResultMap" type="com.siwei.apply.domain.vo.ThirdRecordStatusParamVo">
+        <id property="id" column="id"/>
+        <result property="tbzt" column="tbzt"/>
+        <result property="createdAt" column="created_at"/>
+        <result property="updatedAt" column="updated_at"/>
+        <result property="bdydyh" column="bdydyh"/>
+        <result property="yfbdydyh" column="yfbdydyh"/>
+        <result property="ywlx" column="ywlx"/>
+        <result property="sfdengbu" column="sfdengbu"/>
+        <result property="dengburq" column="dengburq"/>
+        <result property="qlrmc" column="qlrmc"/>
+        <result property="qlrzjh" column="qlrzjh"/>
+        <result property="ywh" column="ywh"/>
+    </resultMap>
+
+    <!-- 插入记录 -->
+    <insert id="insert" parameterType="com.siwei.apply.domain.vo.ThirdRecordStatusParamVo">
+        INSERT INTO t_third_record_status (
+            id,
+            tbzt,
+            created_at,
+            updated_at,
+            bdydyh,
+            yfbdydyh,
+            ywlx,
+            sfdengbu,
+            dengburq,
+            qlrmc,
+            qlrzjh,
+            ywh
+        ) VALUES (
+            #{id},
+            #{tbzt},
+            now(),
+            now(),
+            #{bdydyh},
+            #{yfbdydyh},
+            #{ywlx},
+            #{sfdengbu},
+            #{dengburq},
+            #{qlrmc},
+            #{qlrzjh},
+            #{ywh}
+        )
+    </insert>
+
+    <!-- 根据预赋不动产单元号 或 业务号 查询已存在的记录(yfbdydyh 优先) -->
+    <select id="selectByYfbdydyhOrYwh" resultMap="BaseResultMap">
+        SELECT
+            id, tbzt, created_at, updated_at, bdydyh, yfbdydyh, ywlx,
+            sfdengbu, dengburq, qlrmc, qlrzjh, ywh
+        FROM t_third_record_status
+        <where>
+            <choose>
+                <when test="yfbdydyh != null and yfbdydyh != ''">
+                    yfbdydyh = #{yfbdydyh}
+                </when>
+                <when test="ywh != null and ywh != ''">
+                    ywh = #{ywh}
+                </when>
+            </choose>
+        </where>
+        ORDER BY
+            CASE WHEN yfbdydyh = #{yfbdydyh} THEN 0 ELSE 1 END,
+            updated_at DESC
+        LIMIT 1
+    </select>
+
+    <!-- 根据主键 ID 覆盖更新登簿状态信息 -->
+    <update id="updateById" parameterType="com.siwei.apply.domain.vo.ThirdRecordStatusParamVo">
+        UPDATE t_third_record_status
+        <set>
+            <if test="tbzt != null">tbzt = #{tbzt},</if>
+            <if test="bdydyh != null">bdydyh = #{bdydyh},</if>
+            <if test="yfbdydyh != null">yfbdydyh = #{yfbdydyh},</if>
+            <if test="ywlx != null">ywlx = #{ywlx},</if>
+            <if test="sfdengbu != null">sfdengbu = #{sfdengbu},</if>
+            <if test="dengburq != null">dengburq = #{dengburq},</if>
+            <if test="qlrmc != null">qlrmc = #{qlrmc},</if>
+            <if test="qlrzjh != null">qlrzjh = #{qlrzjh},</if>
+            <if test="ywh != null">ywh = #{ywh},</if>
+            updated_at = now()
+        </set>
+        WHERE id = #{id}
+    </update>
+
+</mapper>