Sfoglia il codice sorgente

入库更新优化

chenendian 1 giorno fa
parent
commit
6d373eb29a

+ 4 - 5
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/cadastre/CadastreManageController.java

@@ -50,16 +50,15 @@ public class CadastreManageController extends BaseController {
 
     /**
      * 宗地变化情况表
-     * @param theFileName
      * @param theFilePath
      * @param landRightType
      * @param landChangeMode
      * @return
      */
     @PostMapping("/addLandChangeData")
-    public R<String> landChange(String theFileName, String theFilePath, String landRightType, String landChangeMode) {
+    public R<String> landChange(String theFilePath, String landRightType, String landChangeMode) {
         try {
-            String res = cadastreManageService.addLandChange(theFileName, theFilePath, landRightType, landChangeMode);
+            String res = cadastreManageService.addLandChange(theFilePath, landRightType, landChangeMode);
             return R.ok("success");
         } catch (Exception e) {
             e.printStackTrace();
@@ -83,9 +82,9 @@ public class CadastreManageController extends BaseController {
      * @return
      */
     @PostMapping("/checkUploadDquality")
-    public R<CheckInfoResultVo> checkData(String theFileName, String theFilePath, String fileType, String updateType) {
+    public R<CheckInfoResultVo> checkData(String theFileName, String theFilePath, String fileType, String updateType, @RequestParam(required = false,defaultValue = "") String landRightType) {
         try {
-            CheckInfoResultVo res = cadastreManageService.checkFileData(theFileName, theFilePath, fileType, updateType);
+            CheckInfoResultVo res = cadastreManageService.checkFileData(theFileName, theFilePath, fileType, updateType, landRightType);
             return R.ok(res);
         } catch (Exception e) {
             e.printStackTrace();

+ 2 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/CadastreFile.java

@@ -33,4 +33,6 @@ public class CadastreFile extends BaseId {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date updateTime;
     private Long fileSize;
+    private String landRightType;
+
 }

+ 3 - 3
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/CadastreManageService.java

@@ -14,17 +14,17 @@ import java.util.Map;
 
 public interface CadastreManageService {
 
-    String addLandChange(String theFileName, String theFilePath, String landRightType,String landChangeMode);
+    String addLandChange(String theFilePath, String landRightType,String landChangeMode);
 
     CompareResultVo getCompareData(String uploadId) ;
 
-    CadastreFile saveUploadFile(String theFileName, String theFilePath, String fileType,String updateType);
+    CadastreFile saveUploadFile(String theFileName, String theFilePath, String fileType,String updateType,String landRightType);
 
     String addBatchGdbData(String uploadId);
 
     String addBatchMdbData(String uploadId);
 
-    CheckInfoResultVo checkFileData(String theFileName, String theFilePath, String fileType,String updateType);
+    CheckInfoResultVo checkFileData(String theFileName, String theFilePath, String fileType,String updateType,String landRightType);
 
     /**
      * 获取列表

+ 46 - 24
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/impl/CadastreManageServiceImpl.java

@@ -57,10 +57,9 @@ public class CadastreManageServiceImpl implements CadastreManageService {
     @Autowired
     private FzssFxrwrzMapper fzssFxrwrzMapper;
 
-
     /**
      * 解压文件并且根据情况进行拆分或合并的处理
-     * @param theFileName 上传文件名
+     * @param  上传文件名
      * @param theFilePath 文件路径
      * @param landRightType 宗地权利类型
      * @param landChangeMode 宗地变更模式
@@ -68,7 +67,7 @@ public class CadastreManageServiceImpl implements CadastreManageService {
      */
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public String addLandChange(String theFileName, String theFilePath, String landRightType,String landChangeMode) {
+    public String addLandChange(String theFilePath, String landRightType,String landChangeMode) {
         String result = "success";
         /**
          *
@@ -77,10 +76,9 @@ public class CadastreManageServiceImpl implements CadastreManageService {
          * 3.能够获取到相关数据,并且数据都合规。
          * 4.无日志,无对比文件,直接入库,返回变化和变更多少条
          *
-         *
-         *
          */
         try {
+                String theFileName = "";
                 if (StringUtils.isBlank(theFilePath)) {
                     log.warn("处理文件失败:filePath不能为空");
                     throw new ServiceException("处理文件失败:filePath不能为空");
@@ -162,17 +160,16 @@ public class CadastreManageServiceImpl implements CadastreManageService {
                         // 判断是否包含相同的元素(不考虑顺序)
                         boolean areCollectionsEqual = CollectionUtils.containsAll(layerFieldNameList,dbFieldNameList);
                         if (!areCollectionsEqual) {
-                            throw new ServiceException(name + ":字段数据不一致!-" + dbFieldNameList);
+                            List<String> missingFields = (List<String>) CollectionUtils.subtract(dbFieldNameList, layerFieldNameList);
+                            if (CollectionUtils.isNotEmpty(missingFields)) {
+                                throw new ServiceException(name + ":图层缺失数据库字段!缺失字段列表=" + missingFields);
+                            }
+                            //throw new ServiceException(name + ":字段数据不一致!-" + dbFieldNameList);
                         }
                         // -----------------第三部分遍历图层进行数据处理 -------------------------------
 
 
 
-
-
-
-
-
                     }
                 }
             } catch (Exception e) {
@@ -241,16 +238,19 @@ public class CadastreManageServiceImpl implements CadastreManageService {
                 ));
                 List<Map<String, Object>> theValueList = getValueList(layer, dbFieldNameAndTypeMap, haveGeom);
                 fzssFxrwrzHandleService.insertFxrwrz(uploadId, "地籍库管理", "正在执行-" + layerName + "-入库", "info");
-                //这里直接数据入库,区分增量或者全量
+
+                //宗地权利类型(1-使用权;2-所有权)
+                String landRightType = cadastreFile.getLandRightType();
                 Boolean addRes;
+                //这里直接数据入库,区分增量或者全量
                 if ("2".equalsIgnoreCase(cadastreFile.getReadStatus())) {
                     //增量更新
-                    addRes = incrementDataStorage(layerName, theValueList);
+                    addRes = incrementDataStorage(landRightType,layerName, theValueList);
                     if (addRes.equals(true)) {
                         fzssFxrwrzHandleService.insertFxrwrz(uploadId, "地籍库管理", "增量更新-" + layerName + "-成功", "info");
                     }
                 } else {
-                    addRes = fullDataStorage(layerName, theValueList);
+                    addRes = fullDataStorage(landRightType,layerName, theValueList);
                     if (addRes.equals(true)) {
                         fzssFxrwrzHandleService.insertFxrwrz(uploadId, "地籍库管理", "增量更新-" + layerName + "-成功", "info");
                     }
@@ -302,6 +302,10 @@ public class CadastreManageServiceImpl implements CadastreManageService {
             }
 
             fzssFxrwrzHandleService.insertFxrwrz(uploadId, "地籍库管理", "正在执行入库操作。。。", "info");
+
+            //如果是宗地需要区分权利类型(1.使用权数据,2.所有权数据)
+            String landRightType =  cadastreFile.getLandRightType();
+
             for (Map<String, Object> tableMap : allMdbTableList) {
                 String talbleName = String.valueOf(tableMap.get("name"));
                 Map<String, Object> allMdbTableFieldMap = MdbUtil.MdbTableContent(gdbPath + "/" + cadastreFile.getName(), talbleName, "", "", 1, 1000);
@@ -310,12 +314,12 @@ public class CadastreManageServiceImpl implements CadastreManageService {
                 fzssFxrwrzHandleService.insertFxrwrz(uploadId, "地籍库管理", "正在执行-" + talbleName + "-入库", "info");
                 Boolean addRes;
                 if ("2".equalsIgnoreCase(cadastreFile.getReadStatus())) {
-                    addRes = incrementDataStorage(talbleName, theValueList);
+                    addRes = incrementDataStorage(landRightType,talbleName, theValueList);
                     if (addRes.equals(true)) {
                         fzssFxrwrzHandleService.insertFxrwrz(uploadId, "地籍库管理", "增量更新-" + talbleName + "-成功", "info");
                     }
                 } else {
-                    addRes = fullDataStorage(talbleName, theValueList);
+                    addRes = fullDataStorage(landRightType,talbleName, theValueList);
                     if (addRes.equals(true)) {
                         fzssFxrwrzHandleService.insertFxrwrz(uploadId, "地籍库管理", "全量更新-" + talbleName + "-成功", "info");
                     }
@@ -402,7 +406,7 @@ public class CadastreManageServiceImpl implements CadastreManageService {
      * @return
      */
     @Override
-    public CadastreFile saveUploadFile(String theFileName, String theFilePath, String fileType, String updateType) {
+    public CadastreFile saveUploadFile(String theFileName, String theFilePath, String fileType, String updateType,String landRightType) {
         try {
             if (theFilePath == null || theFilePath.trim().isEmpty()) {
                 log.warn("处理文件失败:filePath不能为空");
@@ -470,11 +474,14 @@ public class CadastreManageServiceImpl implements CadastreManageService {
                     if (StringUtils.isNotBlank(fileType)) {
                         cadastreFile.setFileType(fileType);
                     }
-
                     //0 为全量更新,1为增量更新
                     if (StringUtils.isNotBlank(updateType)) {
                         cadastreFile.setReadStatus(updateType);
                     }
+                    //0 为全量更新,1为增量更新
+                    if (StringUtils.isNotBlank(landRightType)) {
+                        cadastreFile.setLandRightType(landRightType);
+                    }
                     cadastreFile.setFileSize(fileSize);
                     cadastreFile.setStatus("0");
                     cadastreFile.setUploadUser("admin");
@@ -508,13 +515,13 @@ public class CadastreManageServiceImpl implements CadastreManageService {
      * @return
      */
     @Override
-    public CheckInfoResultVo checkFileData(String theFileName, String theFilePath, String fileType, String updateType) {
+    public CheckInfoResultVo checkFileData(String theFileName, String theFilePath, String fileType, String updateType,String landRightType) {
         CheckInfoResultVo checkInfoResult = new CheckInfoResultVo();
         checkInfoResult.setResultStatus(true);
         List<CheckInfoVo> checkInfoSuccessList = new ArrayList<>();
         List<CheckInfoVo> checkInfoFailList = new ArrayList<>();
 
-        CadastreFile uploadFile = this.saveUploadFile(theFileName, theFilePath, fileType, updateType);
+        CadastreFile uploadFile = this.saveUploadFile(theFileName, theFilePath, fileType, updateType,landRightType);
 
         if (Objects.nonNull(uploadFile)) {
             //入库成功
@@ -629,7 +636,11 @@ public class CadastreManageServiceImpl implements CadastreManageService {
         // 判断是否包含相同的元素(不考虑顺序)
         boolean areCollectionsEqual = CollectionUtils.containsAll(layerFieldNameList,dbFieldNameList);
         if (!areCollectionsEqual) {
-            checkInfoList.add(name + ":字段数据不一致!-" + dbFieldNameList);
+            List<String> missingFields = (List<String>) CollectionUtils.subtract(dbFieldNameList, layerFieldNameList);
+            if (CollectionUtils.isNotEmpty(missingFields)) {
+                throw new ServiceException(name + ":图层缺失数据库字段!缺失字段列表=" + missingFields);
+            }
+            //checkInfoList.add(name + ":字段数据不一致!-" + dbFieldNameList);
             fzssFxrwrzHandleService.insertFxrwrz(uploadId, "地籍库管理", name + ":字段数据不一致!-" + dbFieldNameList, "info");
             checkInfoVo.setCheckStatus(false);
         }
@@ -699,7 +710,11 @@ public class CadastreManageServiceImpl implements CadastreManageService {
         // 判断是否包含相同的元素(不考虑顺序)
         boolean areCollectionsEqual = CollectionUtils.containsAll(lowerCaseMdbTableFieldNameList,dbFieldNameList);
         if (!areCollectionsEqual) {
-            checkInfoList.add(mdbTableName + ":字段数据不一致!-" + dbFieldNameList);
+            List<String> missingFields = (List<String>) CollectionUtils.subtract(dbFieldNameList, lowerCaseMdbTableFieldNameList);
+            if (CollectionUtils.isNotEmpty(missingFields)) {
+                throw new ServiceException(mdbTableName + ":图层缺失数据库字段!缺失字段列表=" + missingFields);
+            }
+            //checkInfoList.add(mdbTableName + ":字段数据不一致!-" + dbFieldNameList);
             fzssFxrwrzHandleService.insertFxrwrz(uploadId, "地籍库管理", mdbTableName + ":字段数据不一致!-" + dbFieldNameList, "info");
             checkInfoVo.setCheckStatus(false);
         }
@@ -1068,7 +1083,7 @@ public class CadastreManageServiceImpl implements CadastreManageService {
      * @return
      */
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public Boolean fullDataStorage(String tableName, List<Map<String, Object>> theValueList) {
+    public Boolean fullDataStorage(String landRightType,String tableName, List<Map<String, Object>> theValueList) {
         boolean addRes = false;
         Integer shpDbSRID = 4326;
         if (!CollectionUtils.isEmpty(theValueList)) {
@@ -1100,6 +1115,9 @@ public class CadastreManageServiceImpl implements CadastreManageService {
                 cleanDataForInsert(map, columnTypeMap);
                 if(tableName.equalsIgnoreCase("zdjbxx")){//这里使用主键自增
                     map.put("bsm", "DEFAULT");
+                    if(StringUtils.isNotBlank(landRightType)){
+                        map.put("sm", landRightType.trim());
+                    }
                 }
                 cadastreFileMapper.insertTableData(tableName, map, shpDbSRID);
             }
@@ -1243,7 +1261,7 @@ public class CadastreManageServiceImpl implements CadastreManageService {
      * @return
      */
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public Boolean incrementDataStorage(String tableName, List<Map<String, Object>> theValueList) {
+    public Boolean incrementDataStorage(String landRightType ,String tableName, List<Map<String, Object>> theValueList) {
         boolean addRes = false;
         Integer shpDbSRID = 4326;
         if (!CollectionUtils.isEmpty(theValueList)) {
@@ -1278,6 +1296,10 @@ public class CadastreManageServiceImpl implements CadastreManageService {
                 cleanDataForInsert(map, columnTypeMap);
                 if(tableName.equalsIgnoreCase("zdjbxx")){//这里使用主键自增
                     map.put("bsm", "DEFAULT");
+                    //宗地权利类型(1-使用权;2-所有权)
+                    if(StringUtils.isNotBlank(landRightType)){
+                        map.put("sm", landRightType.trim());
+                    }
                 }
                 cadastreFileMapper.insertTableData(tableName, map, shpDbSRID);
             }