|
|
@@ -23,6 +23,7 @@ import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -43,6 +44,9 @@ public class CadastreManageServiceImpl implements CadastreManageService {
|
|
|
|
|
|
|
|
|
/**
|
|
|
+ *
|
|
|
+ * 解析文件内容,insert 到表中
|
|
|
+ *
|
|
|
*
|
|
|
* 1.进行解析数据成为list<map></map>
|
|
|
* 2.进行调用方法动态插入到当前表中
|
|
|
@@ -84,9 +88,17 @@ public class CadastreManageServiceImpl implements CadastreManageService {
|
|
|
if (dbFieldNameList.contains("geom")) {
|
|
|
haveGeom = true;
|
|
|
}
|
|
|
- List<Map<String, String>> theValueList = getValueList(layer, haveGeom);
|
|
|
+
|
|
|
+ List<Map<String,String>> dbFieldNameAndTypeList = cadastreFileMapper.selectTableCollumAndType(layerName.toLowerCase(Locale.ROOT));
|
|
|
+ Map<String,String> dbFieldNameAndTypeMap = dbFieldNameAndTypeList.stream().collect(Collectors.toMap(
|
|
|
+ s -> s.get("column_name"),
|
|
|
+ s -> s.get("data_type"),
|
|
|
+ (existing, replacement) -> existing // 如果有重复键,保留第一个值
|
|
|
+ ));
|
|
|
+
|
|
|
+ List<Map<String, Object>> theValueList = getValueList(layer,dbFieldNameAndTypeMap, haveGeom);
|
|
|
//这里直接数据入库,区分增量或者全量
|
|
|
- Boolean addRes = fullDataStorage(layerName,theValueList);
|
|
|
+ Boolean addRes = fullDataStorage(layerName, theValueList);
|
|
|
log.error("当前图层{},入库结果 {}", layerName, addRes);
|
|
|
//Boolean checkRes2 = incrementalDataStorage(layer);
|
|
|
}
|
|
|
@@ -110,6 +122,19 @@ public class CadastreManageServiceImpl implements CadastreManageService {
|
|
|
CompareResultVo compareResultVo = new CompareResultVo();
|
|
|
compareResultVo.setUploadId(uploadId);
|
|
|
compareResultVo.setResultStatus(true);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// //todo 这里进行
|
|
|
+// List<Map<String,String>> collumTypes = cadastreFileMapper.selectTableCollumAndType("mzdzw");
|
|
|
+// if(true){
|
|
|
+// log.info(collumTypes.toString());
|
|
|
+// return compareResultVo;
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
try {
|
|
|
List<CompareGemoVo> gemos = new ArrayList<>();
|
|
|
CadastreFile cadastreFile = cadastreFileMapper.get(uploadId);
|
|
|
@@ -146,15 +171,15 @@ public class CadastreManageServiceImpl implements CadastreManageService {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 文件入库
|
|
|
+ * 文件upload入库
|
|
|
*
|
|
|
* @param theFileName
|
|
|
* @param theFilePath
|
|
|
- * @param fromRoute
|
|
|
+ * @param fileType
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public CadastreFile saveUploadFile(String theFileName, String theFilePath, String fromRoute) {
|
|
|
+ public CadastreFile saveUploadFile(String theFileName, String theFilePath, String fileType, String updateType) {
|
|
|
try {
|
|
|
if (theFilePath == null || theFilePath.trim().isEmpty()) {
|
|
|
log.warn("处理文件失败:filePath不能为空");
|
|
|
@@ -180,6 +205,15 @@ public class CadastreManageServiceImpl implements CadastreManageService {
|
|
|
cadastreFile.setFilePath(theFilePath);
|
|
|
cadastreFile.setUnzipPath(unZipPath);
|
|
|
cadastreFile.setFileType("1");//矢量/表格
|
|
|
+ if (StringUtils.isNotBlank(fileType)) {
|
|
|
+ cadastreFile.setFileType(fileType);
|
|
|
+ }
|
|
|
+
|
|
|
+ //0 为全量更新,1为增量更新
|
|
|
+ if (StringUtils.isNotBlank(updateType)) {
|
|
|
+ cadastreFile.setStatus(updateType);
|
|
|
+ }
|
|
|
+
|
|
|
cadastreFile.setUploadUser("admin");
|
|
|
cadastreFile.setUploadTime(new Date());
|
|
|
cadastreFile.setReadMessage("入库成功");
|
|
|
@@ -207,17 +241,19 @@ public class CadastreManageServiceImpl implements CadastreManageService {
|
|
|
*
|
|
|
* @param theFileName
|
|
|
* @param theFilePath
|
|
|
- * @param fromRoute
|
|
|
+ * @param fileType
|
|
|
+ * @param updateType
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public CheckInfoResultVo checkFileData(String theFileName, String theFilePath, String fromRoute) {
|
|
|
+ public CheckInfoResultVo checkFileData(String theFileName, String theFilePath, String fileType, String updateType) {
|
|
|
CheckInfoResultVo checkInfoResult = new CheckInfoResultVo();
|
|
|
checkInfoResult.setResultStatus(true);
|
|
|
List<CheckInfoVo> checkInfoSuccessList = new ArrayList<>();
|
|
|
List<CheckInfoVo> checkInfoFailList = new ArrayList<>();
|
|
|
|
|
|
- CadastreFile uploadFile = this.saveUploadFile(theFileName, theFilePath, fromRoute);
|
|
|
+ CadastreFile uploadFile = this.saveUploadFile(theFileName, theFilePath, fileType, updateType);
|
|
|
+
|
|
|
if (Objects.nonNull(uploadFile)) {
|
|
|
//入库成功
|
|
|
fzssFxrwrzHandleService.insertFxrwrz(uploadFile.getId(), "地籍库管理", "上传文件成功", "info");
|
|
|
@@ -294,7 +330,7 @@ public class CadastreManageServiceImpl implements CadastreManageService {
|
|
|
haveGeom = true;
|
|
|
}
|
|
|
|
|
|
- List<String> layerFieldNameList = getFieldName(layer, haveGeom);
|
|
|
+ List<String> layerFieldNameList = this.getFieldName(layer, haveGeom);
|
|
|
// 判断是否包含相同的元素(不考虑顺序)
|
|
|
boolean areCollectionsEqual = CollectionUtils.isEqualCollection(dbFieldNameList, layerFieldNameList);
|
|
|
if (!areCollectionsEqual) {
|
|
|
@@ -302,22 +338,23 @@ public class CadastreManageServiceImpl implements CadastreManageService {
|
|
|
checkInfoVo.setCheckStatus(false);
|
|
|
}
|
|
|
|
|
|
- //todo 检查字段数据是否为空
|
|
|
- //仅仅获取图层属性
|
|
|
- List<Map<String, String>> theValueList = getValueList(layer, false);
|
|
|
+ //检查字段数据是否为空
|
|
|
//todo 这里根据表名获取相关校验字段信息
|
|
|
List<String> checkFieldList = new ArrayList<>();
|
|
|
//checkFieldList.add("111");
|
|
|
checkFieldList.add("bz");
|
|
|
- for (Map<String, String> theMap : theValueList) {
|
|
|
+ //仅获取图层属性
|
|
|
+ List<Map<String, Object>> theValueList = getValueList(layer,new LinkedHashMap<>(), false);
|
|
|
+ for (Map<String, Object> theMap : theValueList) {
|
|
|
for (String fieldName : checkFieldList) {
|
|
|
- if (com.siwei.common.core.utils.StringUtils.isBlank(theMap.get(fieldName))) {
|
|
|
+ if (Objects.isNull(theMap.get(fieldName))) {
|
|
|
checkInfoList.add(name + "--" + fieldName + "字段不能为空!");
|
|
|
checkInfoVo.setCheckStatus(false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
checkInfoVo.setCheckInfoList(checkInfoList);
|
|
|
+ //todo 这里需要放入到缓存中,并且可以下载为txt内容
|
|
|
return checkInfoVo;
|
|
|
}
|
|
|
|
|
|
@@ -349,15 +386,33 @@ public class CadastreManageServiceImpl implements CadastreManageService {
|
|
|
* @param layer
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<Map<String, String>> getValueList(Layer layer, Boolean haveGeom) {
|
|
|
- List<Map<String, String>> list = new ArrayList<>();
|
|
|
- Map<String, String> map = new LinkedHashMap<>();
|
|
|
+ private List<Map<String, Object>> getValueList(Layer layer,Map<String,String> fieldNameAndTypeMap , Boolean haveGeom) {
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ Map<String, Object> map = new LinkedHashMap<>();
|
|
|
layer.ResetReading();
|
|
|
Feature feature;
|
|
|
while ((feature = layer.GetNextFeature()) != null) {
|
|
|
for (int i = 0; i < feature.GetFieldCount(); i++) {
|
|
|
- map.put(feature.GetFieldDefnRef(i).GetName(), feature.GetFieldAsString(i));
|
|
|
+ String fieldName = feature.GetFieldDefnRef(i).GetName();
|
|
|
+ if(fieldNameAndTypeMap.containsKey(fieldName.toLowerCase())) {
|
|
|
+ String fieldType = fieldNameAndTypeMap.get(fieldName);
|
|
|
+ if (StringUtils.containsIgnoreCase(fieldType, "character")) {
|
|
|
+ map.put(fieldName, feature.GetFieldAsString(i));
|
|
|
+ } else if (StringUtils.containsIgnoreCase(fieldType, "integer")) {
|
|
|
+ map.put(fieldName, feature.GetFieldAsInteger(i));
|
|
|
+ } else if (StringUtils.containsIgnoreCase(fieldType, "date")) {
|
|
|
+ //todo 日期转化
|
|
|
+ map.put(fieldName, feature.GetFieldAsString(i));
|
|
|
+ } else if (StringUtils.containsIgnoreCase(fieldType, "numeric")) {
|
|
|
+ map.put(fieldName, feature.GetFieldAsDouble(i));
|
|
|
+ } else {
|
|
|
+ map.put(fieldName, feature.GetFieldAsString(i));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ map.put(fieldName, feature.GetFieldAsString(i));
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
if (haveGeom.equals(true)) {
|
|
|
String wkt = null;
|
|
|
Geometry geom = feature.GetGeometryRef();
|
|
|
@@ -462,30 +517,27 @@ public class CadastreManageServiceImpl implements CadastreManageService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 这里需要开启事务
|
|
|
* 数据全量入库
|
|
|
+ *
|
|
|
* @param tableName
|
|
|
* @param theValueList
|
|
|
* @return
|
|
|
*/
|
|
|
- private Boolean fullDataStorage(String tableName,List<Map<String, String>> theValueList) {
|
|
|
+ private Boolean fullDataStorage(String tableName, List<Map<String, Object>> theValueList) {
|
|
|
boolean addRes = false;
|
|
|
if (!CollectionUtils.isEmpty(theValueList)) {
|
|
|
- for (Map<String, String> map : theValueList) {
|
|
|
- Collection<String> values = map.values();
|
|
|
+ for (Map<String, Object> map : theValueList) {
|
|
|
+ Collection<Object> values = map.values();
|
|
|
Collection<String> keys = map.keySet();
|
|
|
- cadastreFileMapper.insertTableData(tableName,keys,values);
|
|
|
+ cadastreFileMapper.insertTableData(tableName, keys, values);
|
|
|
}
|
|
|
}
|
|
|
return addRes;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 数据增量入库
|
|
|
*
|