1
0
chenendian 2 месяцев назад
Родитель
Сommit
c9eadcdebd

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

@@ -24,6 +24,7 @@ public class CadastreFile extends BaseId {
     private String fileType;
     private String storage;
 
+    //状态(0-正在入库,1-入库成功,2-入库失败,3-校验通过)
     private String status;
     //1 为全量,2 为增量
     private String readStatus;

+ 59 - 35
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/impl/CadastreManageServiceImpl.java

@@ -9,12 +9,12 @@ import com.siwei.apply.mapper.FzssFxrwrzMapper;
 import com.siwei.apply.service.cadastre.CadastreManageService;
 
 import com.siwei.apply.utils.FileExtractUtil;
+import com.siwei.apply.utils.MdbUtil;
 import com.siwei.common.core.exception.ServiceException;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.MapUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.ibatis.annotations.Param;
 import org.gdal.ogr.*;
 import org.gdal.osr.SpatialReference;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -131,12 +131,18 @@ public class CadastreManageServiceImpl implements CadastreManageService {
             //成功则更新状态
             CadastreFile updateCadastreFile = new CadastreFile();
             updateCadastreFile.setId(cadastreFile.getId());
-            updateCadastreFile.setStatus("2");//校验通过
-            updateCadastreFile.setReadMessage("入库成功");//校验通过
+            updateCadastreFile.setStatus("1");//入库成功
+            updateCadastreFile.setReadMessage("入库成功");//入库成功
             cadastreFileMapper.update(updateCadastreFile);
             fzssFxrwrzHandleService.insertFxrwrz(uploadId, "地籍库管理", "当前批次-"+cadastreFile.getId()+"-入库成功", "info");
         } catch (Exception e) {
             log.error("矢量数据入库异常,uploadId: {}", uploadId, e);
+            //更新状态
+            CadastreFile updateCadastreFile = new CadastreFile();
+            updateCadastreFile.setId(uploadId);
+            updateCadastreFile.setStatus("2");//入库成功
+            updateCadastreFile.setReadMessage("入库失败");//入库成功
+            cadastreFileMapper.update(updateCadastreFile);
             fzssFxrwrzHandleService.insertFxrwrz(uploadId, "地籍库管理", "当前批次-"+uploadId+"-入库失败", "info");
             throw new ServiceException("矢量数据入库异常," + e.getMessage());
         }
@@ -310,45 +316,63 @@ public class CadastreManageServiceImpl implements CadastreManageService {
             //入库成功
             fzssFxrwrzHandleService.insertFxrwrz(uploadFile.getId(), "地籍库管理", "上传文件成功", "info");
             checkInfoResult.setUploadId(uploadFile.getId());
-
             String gdbPath = uploadFile.getUnzipPath();
             theFileName = uploadFile.getName();//这里需要使用解压处理后的文件名称进行读取
-            DataSource ds = ogr.Open(gdbPath + "/" + theFileName, 0); // 0 = 只读
-            if (ds == null) {
-                log.warn("无法打开 gdb");
-                return checkInfoResult;
-            }
-            log.info("图层数量: {}", ds.GetLayerCount());
 
-            //获取库中表名
-            List<String> allTableList = cadastreFileMapper.selectAllTable();
-            //这里进行遍历每个图层
-            for (int i = 0; i < ds.GetLayerCount(); i++) {
-                Layer layer = ds.GetLayer(i);
-                //todo 相关代码
-                if (
-                        !layer.GetName().equalsIgnoreCase("T_CGZJ_CWTC_M") &&
-                        !layer.GetName().equalsIgnoreCase("T_FZSS_FXRW_GIS")
-                ) {
-                    continue;
+            //这里区分文件类型,矢量还是表格的读取方式不一样
+            if(uploadFile.getFileType().equals("1")) { //矢量数据读取方式
+                DataSource ds = ogr.Open(gdbPath + "/" + theFileName, 0); // 0 = 只读
+                if (ds == null) {
+                    log.warn("无法打开 gdb");
+                    return checkInfoResult;
+                }
+                log.info("图层数量: {}", ds.GetLayerCount());
+                //获取库中表名
+                List<String> allTableList = cadastreFileMapper.selectAllTable();
+                //这里进行遍历每个图层
+                for (int i = 0; i < ds.GetLayerCount(); i++) {
+                    Layer layer = ds.GetLayer(i);
+                    //todo 相关代码
+                    if (
+                            !layer.GetName().equalsIgnoreCase("T_CGZJ_CWTC_M") &&
+                                    !layer.GetName().equalsIgnoreCase("T_FZSS_FXRW_GIS")
+                    ) {
+                        continue;
+                    }
+                    //todo 测试代码
+                    //这里做质量检查
+                    CheckInfoVo checkRes = checkLayerInfo(layer, allTableList, uploadFile.getId());
+                    if (checkRes.getCheckStatus().equals(false)) { //检查出错
+                        checkInfoFailList.add(checkRes);
+                        checkInfoResult.setResultStatus(false);
+                    } else if (checkRes.getCheckStatus().equals(true)) {
+                        //成功则更新文件上传状态
+                        CadastreFile cadastreFile = new CadastreFile();
+                        cadastreFile.setId(uploadFile.getId());
+                        cadastreFile.setStatus("3");//校验通过
+                        cadastreFileMapper.update(cadastreFile);
+                        checkInfoSuccessList.add(checkRes);
+                    }
                 }
+                ds.delete();
+            } else if (uploadFile.getFileType().equals("2")) {//处理表格类型
 
-                //todo 测试代码
-                //这里做质量检查
-                CheckInfoVo checkRes = checkLayerInfo(layer, allTableList,uploadFile.getId());
-                if (checkRes.getCheckStatus().equals(false)) { //检查出错
-                    checkInfoFailList.add(checkRes);
-                    checkInfoResult.setResultStatus(false);
-                } else if (checkRes.getCheckStatus().equals(true)) {
-                    //成功则更新文件上传状态
-                    CadastreFile cadastreFile = new CadastreFile();
-                    cadastreFile.setId(uploadFile.getId());
-                    cadastreFile.setStatus("3");//校验通过
-                    cadastreFileMapper.update(cadastreFile);
-                    checkInfoSuccessList.add(checkRes);
+                try {
+
+
+
+                    MdbUtil.MdbTables(gdbPath + "/" + theFileName, "", "");
+
+
+
+
+                } catch (Exception e) {
+                    throw new ServiceException("可能入库失败或没有历史版本,无法回退");
                 }
             }
-            ds.delete();
+
+
+
             checkInfoResult.setCheckFailList(checkInfoFailList);
             checkInfoResult.setCheckSuccessList(checkInfoSuccessList);
         }