1
0
Просмотр исходного кода

手动同步国有建设用地数据兼容多次同步

chenendian 8 часов назад
Родитель
Сommit
3675e5ef1d

+ 19 - 1
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/third/TakeDataController.java

@@ -1,6 +1,7 @@
 package com.siwei.apply.controller.third;
 
 import com.siwei.apply.domain.vo.ThirdRecordStatusParamVo;
+import com.siwei.apply.enums.AloneWorkFlowEnum;
 import com.siwei.apply.service.third.TakeDataService;
 import com.siwei.common.core.domain.R;
 import com.siwei.common.core.utils.StringUtils;
@@ -93,7 +94,24 @@ public class TakeDataController extends BaseController {
     }
 
 
-
+    /**
+     * 手动同步不动产数据
+     * @param paramMap
+     * @return
+     */
+    @PostMapping("/third/syncOneNode")
+    public R<String> runSyncOneNode(@RequestBody Map<String,String> paramMap) {
+        String projectId = paramMap.get("projectId");
+        String nodeTableName = paramMap.get("nodeTableName");
+        if(StringUtils.isNotBlank(projectId) && StringUtils.isNotBlank(nodeTableName)){
+            if(AloneWorkFlowEnum.NODE_3.getTableName().equalsIgnoreCase(nodeTableName)){
+                takeDataService.syncLandNodeInfo(projectId,nodeTableName);
+            }else if(AloneWorkFlowEnum.NODE_7.getTableName().equalsIgnoreCase(nodeTableName)){
+                takeDataService.syncHouseNodeInfo(projectId,nodeTableName);
+            }
+        }
+        return R.ok("syncOneNode success");
+    }
 
 
 

+ 3 - 2
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/ThirdRecordStatusMapper.java

@@ -4,6 +4,8 @@ import com.siwei.apply.domain.vo.ThirdRecordStatusParamVo;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
  * 不动产登簿状态表 Mapper 接口
  */
@@ -26,8 +28,7 @@ public interface ThirdRecordStatusMapper {
     ThirdRecordStatusParamVo selectByYfbdcdyhAndYwhAndYwlx(@Param("yfbdcdyh") String yfbdcdyh,
                                                    @Param("ywh") String ywh, @Param("ywlx") String ywlx);
 
-
-
+    List<ThirdRecordStatusParamVo> selectByProjectIdAndType(@Param("projectId") String projectId, @Param("ywlx") String ywlx);
 
 
     /**

+ 5 - 25
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/TakeDataService.java

@@ -1,9 +1,5 @@
 package com.siwei.apply.service.third;
 
-import com.siwei.apply.domain.res.GyjsydscdjRes;
-import com.siwei.apply.domain.res.GyjsydscdjSinglRes;
-import com.siwei.apply.domain.vo.GyjsydscdjUpdateVo;
-import com.siwei.apply.domain.vo.GyjsydscdjVo;
 
 import com.siwei.apply.domain.vo.TakeDataAddVo;
 import com.siwei.apply.domain.vo.ThirdRecordStatusParamVo;
@@ -16,7 +12,6 @@ import java.util.Map;
 public interface TakeDataService {
 
     Map<String, String> getImmobileCode(String projectId);
-
     /**
      * 添加数据
      * 
@@ -25,26 +20,6 @@ public interface TakeDataService {
      */
     String add(TakeDataAddVo takeDataAddVo);
 
-    /**
-     * 获取国有建设用地使用权首次登记信息
-     *
-     * @param projectId 项目ID
-     * @return 国有建设用地使用权首次登记结果对象
-     */
-    GyjsydscdjRes get(String projectId);
-
-    /**
-     * 根据主键id获取国有建设用地使用权首次登记信息,返回结构与 get(projectId) 一致
-     */
-    GyjsydscdjSinglRes getById(String id);
-
-    /**
-     * 更新国有建设用地使用权首次登记信息
-     *
-     * @param gyjsydscdjUpdateVo 国有建设用地使用权首次登记更新视图对象
-     */
-    void update(GyjsydscdjUpdateVo gyjsydscdjUpdateVo);
-
 
     /**
      * 获取三方数据最大序列号
@@ -59,6 +34,11 @@ public interface TakeDataService {
 
     Map<String, Object> remoteHouseFirstRegistration(ThirdRecordStatusParamVo paramVo);
 
+    void syncLandNodeInfo(String projectId,String nodeTableName);
+
+    void syncHouseNodeInfo(String projectId,String nodeTableName);
+
+    void syncRemoteData(ThirdRecordStatusParamVo body);
 
 
 }

+ 2 - 28
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/impl/OfferDataServiceImpl.java

@@ -188,41 +188,15 @@ public class OfferDataServiceImpl implements OfferDataService {
             tbztFlag = "0";
         }
         log.info("登簿数据入库成功: {}" , id);
-        //tbztFlag = "1"; //todo 这里暂时不同步数据
         if("0".equals(tbztFlag)) {
-            //todo 需要进行数据的抓取,并且需要异步处理,否则下载文件会阻塞接口的返回,导致超时。
-            CompletableFuture.supplyAsync(()-> {
-                if("1".equals(ywlx)){ //房屋首次登记(后来类型变更)
-                    takeDataService.remoteHouseFirstRegistration(body);
-                }else if("2".equals(ywlx)){ //土地首次登记
-                    takeDataService.remoteLandFirstRegistration(body);
-                }
-                ThirdRecordStatusParamVo updateVo = new ThirdRecordStatusParamVo();
-                updateVo.setId(body.getId());
-                updateVo.setTbzt("1");
-                thirdRecordStatusMapper.updateById(updateVo);
-
-                //这里需要更新绑定关系
-                ProjectImmobileCode  updateImmobileCode = new ProjectImmobileCode();
-                updateImmobileCode.setCode(bdcdyh);
-                updateImmobileCode.setPreAssignCode(yfbdcdyh);
-                projectImmobileCodeMapper.updateByPreCode(updateImmobileCode);
-                return body.getId();
-            }).exceptionally(e -> {
-                log.error("不动产远程抓取数据失败: ywh={}, ywlx={}", ywh, ywlx, e);
-                e.printStackTrace();
-                return null;
-            });
+            //数据同步
+            takeDataService.syncRemoteData(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();

+ 143 - 12
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/impl/TakeDataServiceImpl.java

@@ -11,10 +11,7 @@ import com.siwei.apply.domain.res.GyjsydscdjSinglRes;
 import com.siwei.apply.domain.vo.*;
 import com.siwei.apply.enums.AloneWorkFlowEnum;
 
-import com.siwei.apply.mapper.LandTypeMapper;
-import com.siwei.apply.mapper.ProjectImmobileCodeMapper;
-import com.siwei.apply.mapper.ProjectMapper;
-import com.siwei.apply.mapper.ProjectWorkflowMapper;
+import com.siwei.apply.mapper.*;
 import com.siwei.apply.service.GyjsydjfwscdjService;
 import com.siwei.apply.service.GyjsydscdjService;
 import com.siwei.apply.service.NodeAttachmentService;
@@ -29,11 +26,11 @@ import com.siwei.spatial.api.RemoteSpatialFilesDbService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.MapUtils;
-import org.apache.commons.lang3.RandomStringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
 
 import static com.siwei.apply.service.third.impl.DealExcelServiceImpl.allLandTypeList;
 
@@ -73,6 +70,11 @@ public class TakeDataServiceImpl implements TakeDataService {
     private LandTypeMapper landTypeMapper;
 
 
+    @Autowired
+    private ThirdRecordStatusMapper thirdRecordStatusMapper;
+
+
+
     @Override
     public String add(TakeDataAddVo takeDataAddVo) {
         // TODO: Implement add logic
@@ -80,21 +82,58 @@ public class TakeDataServiceImpl implements TakeDataService {
     }
 
 
-    @Override
-    public GyjsydscdjRes get(String projectId) {
-        return null;
-    }
 
+
+    /**
+     * 同步土地首次登记数据
+     * @param projectId
+     * @param nodeTableName
+     */
     @Override
-    public GyjsydscdjSinglRes getById(String id) {
-        return null;
+    public void syncLandNodeInfo(String projectId,String nodeTableName) {
+        Project project = projectMapper.get(projectId);
+        if (Objects.isNull(project) || StringUtils.isBlank(project.getCode())) {
+            throw new ServiceException("当前项目不具备同步条件,请检查项目代码是否存在");
+        }
+        List<ThirdRecordStatusParamVo> syncRecordList =  thirdRecordStatusMapper.selectByProjectIdAndType(projectId,"2");
+        if (CollectionUtils.isEmpty(syncRecordList)) {
+            throw new ServiceException("当前项目不具备同步条件,检查不动产是否已推送完成数据");
+        }
+        for(ThirdRecordStatusParamVo  paramVo : syncRecordList){
+            //这里调用相关同步方法
+            syncRemoteData(paramVo);
+        }
     }
 
+
+
+    /**
+     * 同步房屋首次登记数据
+     * @param projectId
+     * @param nodeTableName
+     */
     @Override
-    public void update(GyjsydscdjUpdateVo gyjsydscdjUpdateVo) {
+    public void syncHouseNodeInfo(String projectId,String nodeTableName) {
+        Project project = projectMapper.get(projectId);
+        if (Objects.isNull(project) || StringUtils.isBlank(project.getCode())) {
+            throw new ServiceException("当前项目不具备同步条件,请检查项目代码是否存在");
+        }
 
+        List<Object> constructList = null;
+        if (CollectionUtils.isEmpty(constructList)) {
+            return;
+        }
+        //todo 这里最多支持8条数据
+        if (constructList.size() > 8) {
+            constructList = constructList.subList(0, 8);
+        }
     }
 
+
+
+
+
+
     /**
      * 远程获取第三方最大序号
      * 然后根据规则生成预赋不动产单元号
@@ -223,6 +262,8 @@ public class TakeDataServiceImpl implements TakeDataService {
                 if (Objects.isNull(immobileCodeRes)) {
                     throw new ServiceException("检查预赋不动产单元号是否正确");
                 }
+                //todo  这里根据 sourceId 确认是修改还是新增
+                //
 
                 String projectId = immobileCodeRes.getProjectId();
                 //Project project = projectMapper.get(projectId);
@@ -264,6 +305,52 @@ public class TakeDataServiceImpl implements TakeDataService {
     }
 
 
+
+    public String  addOrUpdateLandFirstRegistration( LandFirstParamVo body ,String projectId,String needUpdateNodeId,String ywh ) {
+        String addNodeId = "";
+        if (StringUtils.isNotBlank(needUpdateNodeId)) {
+            GyjsydscdjVo gyjsydscdjVo = new GyjsydscdjVo();
+            gyjsydscdjVo.setProjectId(projectId);
+            gyjsydscdjVo.setQlr(body.getQlr());
+
+            gyjsydscdjVo.setGyqk(body.getGyqk());
+            gyjsydscdjVo.setZl(body.getZl());
+            gyjsydscdjVo.setQllx(body.getQllx());
+            gyjsydscdjVo.setQlxz(body.getQlxz());
+
+            //土地用途转化
+            if (StringUtils.isNotBlank(body.getTdyt())) {
+                String code = null;
+                gyjsydscdjVo.setTdyt(code);
+            }
+
+            if (StringUtils.isNotBlank(body.getTdmj())) {
+                gyjsydscdjVo.setArea(Float.valueOf(body.getTdmj()));
+            }
+            gyjsydscdjVo.setAreaUnit(body.getTdmjdw());
+            gyjsydscdjVo.setBdcdyh(StringUtils.isNotBlank(body.getBdcdyh()) ? body.getBdcdyh() : body.getYfbdcdyh());
+            gyjsydscdjVo.setBdczh(body.getBdczh());
+            gyjsydscdjVo.setDjjg(body.getDjjg());
+            gyjsydscdjVo.setDjDate(body.getDjrq());
+            gyjsydscdjVo.setSourceId(ywh);
+            String nodeId = gyjsydscdjService.add(gyjsydscdjVo);
+            addNodeId = nodeId;
+        }
+
+        return addNodeId;
+    }
+
+
+
+
+
+
+
+
+
+
+
+
     @Override
     public Map<String, Object> remoteHouseFirstRegistration(ThirdRecordStatusParamVo paramVo) {
         String yfbdcdyh = paramVo.getYfbdcdyh();
@@ -357,5 +444,49 @@ public class TakeDataServiceImpl implements TakeDataService {
     }
 
 
+    /**
+     * 根据登簿数据同步不动产数据
+     * 异步执行
+     * @param body
+     */
+    @Override
+    public void syncRemoteData(ThirdRecordStatusParamVo body) {
+        String yfbdcdyh = body.getYfbdcdyh();
+        String bdcdyh = body.getBdcdyh();
+        String ywh = body.getYwh();
+        String ywlx = body.getYwlx();
+
+        CompletableFuture.supplyAsync(() -> {
+            if ("1".equals(ywlx)) { //房屋首次登记(后来类型变更)
+                this.remoteHouseFirstRegistration(body);
+            } else if ("2".equals(ywlx)) { //土地首次登记
+                this.remoteLandFirstRegistration(body);
+            }
+
+            ThirdRecordStatusParamVo updateVo = new ThirdRecordStatusParamVo();
+            updateVo.setId(body.getId());
+            updateVo.setTbzt("1");
+            thirdRecordStatusMapper.updateById(updateVo);
+
+            //这里需要更新绑定关系
+            ProjectImmobileCode updateImmobileCode = new ProjectImmobileCode();
+            updateImmobileCode.setCode(bdcdyh);
+            updateImmobileCode.setPreAssignCode(yfbdcdyh);
+            projectImmobileCodeMapper.updateByPreCode(updateImmobileCode);
+            return body.getId();
+        }).exceptionally(e -> {
+            log.error("不动产远程抓取数据失败: ywh={}, ywlx={}", ywh, ywlx, e);
+            e.printStackTrace();
+            return null;
+        });
+
+
+    }
+
+
+
+
+
+
 
 }

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

@@ -100,6 +100,18 @@
         LIMIT 1
     </select>
 
+    <!-- 根据项目号查询列表 -->
+    <select id="selectByProjectIdAndType" resultMap="BaseResultMap">
+        SELECT  ttrs.*  from   t_project_immobile_code tpic
+        INNER JOIN  t_third_record_status  ttrs  on tpic.pre_assign_code = ttrs.yfbdcdyh
+        WHERE 	tpic.valid_flag=1
+        <if test="projectId != null and projectId != ''">
+            AND tpic.project_id = #{projectId}
+        </if>
+        <if test="ywlx != null and ywlx != ''">
+            AND ttrs.ywlx = #{ywlx}
+        </if>
+    </select>
 
     <!-- 根据主键 ID 覆盖更新登簿状态信息 -->
     <update id="updateById" parameterType="com.siwei.apply.domain.vo.ThirdRecordStatusParamVo">