|
@@ -8,16 +8,25 @@ import com.siwei.apply.domain.vo.LandSupplyProjectVO;
|
|
|
import com.siwei.apply.mapper.GjShijiShouchuMapper;
|
|
import com.siwei.apply.mapper.GjShijiShouchuMapper;
|
|
|
import com.siwei.apply.mapper.GjShouchuJihuaMapper;
|
|
import com.siwei.apply.mapper.GjShouchuJihuaMapper;
|
|
|
import com.siwei.apply.mapper.TdgyMapper;
|
|
import com.siwei.apply.mapper.TdgyMapper;
|
|
|
|
|
+import com.siwei.common.core.constant.SecurityConstants;
|
|
|
|
|
+import com.siwei.common.core.domain.R;
|
|
|
|
|
+import com.siwei.common.core.exception.ServiceException;
|
|
|
import com.siwei.common.core.utils.StringUtils;
|
|
import com.siwei.common.core.utils.StringUtils;
|
|
|
|
|
+import com.siwei.spatial.api.RemoteSpatialFilesDbService;
|
|
|
|
|
+import com.siwei.spatial.api.domain.file.TGeomDb;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
+import org.apache.commons.collections4.MapUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
public class StorageServiceImpl {
|
|
public class StorageServiceImpl {
|
|
|
|
|
|
|
@@ -31,6 +40,11 @@ public class StorageServiceImpl {
|
|
|
private TdgyMapper tdgyMapper;
|
|
private TdgyMapper tdgyMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private RemoteSpatialFilesDbService remoteSpatialFilesDbService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
public LandStorageInOutReportDTO inOutDetails() {
|
|
public LandStorageInOutReportDTO inOutDetails() {
|
|
|
LandStorageInOutReportDTO report = new LandStorageInOutReportDTO();
|
|
LandStorageInOutReportDTO report = new LandStorageInOutReportDTO();
|
|
|
report.setTitle("收储出入库分析报表");
|
|
report.setTitle("收储出入库分析报表");
|
|
@@ -664,4 +678,104 @@ public class StorageServiceImpl {
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public Map<String, Object> importSchedule(String shpFilePath,String sourceType , String addType) {
|
|
|
|
|
+ Map<String, Object> retMap = new LinkedHashMap<>();
|
|
|
|
|
+ if(StringUtils.isBlank(shpFilePath)){
|
|
|
|
|
+ throw new ServiceException("文件不存在请重新上传!");
|
|
|
|
|
+ }
|
|
|
|
|
+ File file = new File(shpFilePath);
|
|
|
|
|
+ if (!file.exists()) {
|
|
|
|
|
+ throw new ServiceException("文件不存在请重新上传!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ R<List<Map<String, Object>>> shpGeomResult = remoteSpatialFilesDbService.readShpFile(shpFilePath, SecurityConstants.INNER);
|
|
|
|
|
+ List<Map<String, Object>> shpDataList = shpGeomResult.getData();
|
|
|
|
|
+ log.info("远程调用geom获取,返回结果:{}", shpDataList);
|
|
|
|
|
+
|
|
|
|
|
+ //数据字段进行校验
|
|
|
|
|
+ int count = 1;
|
|
|
|
|
+ for (Map<String, Object> shpData : shpDataList){
|
|
|
|
|
+ String sccb = shpData.get("sccb").toString();
|
|
|
|
|
+ String scfs = shpData.get("scnf").toString();
|
|
|
|
|
+ String ghyt = shpData.get("ghyt").toString();
|
|
|
|
|
+ String mj_m = shpData.get("mj_m").toString();
|
|
|
|
|
+ if(StringUtils.isBlank(sccb)|| StringUtils.isBlank(scfs) || StringUtils.isBlank(ghyt) || StringUtils.isBlank(mj_m)){
|
|
|
|
|
+ throw new ServiceException("关键字段不能为空(sccb,scnf,ghyt,mj_m),请检查第"+count+"条数据");
|
|
|
|
|
+ }
|
|
|
|
|
+ count++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if("0".equals(addType)){
|
|
|
|
|
+ //这里把当前表清空,重新写入;
|
|
|
|
|
+ gjShouchuJihuaMapper.deleteByTable("gj_shouchu_xiangmu","",sourceType);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 收储项目表 geom 列的 SRID(参考建表语句 vector.gj_shouchu_xiangmu)
|
|
|
|
|
+ int shpDbSRID = 4326;
|
|
|
|
|
+ // 日期字段:shp 读取出来是 ISO8601 字符串(例如 2025-12-24T00:00:00.000+08:00),入库仅保留到 "T" 之前
|
|
|
|
|
+ Set<String> dateFields = new HashSet<>(Arrays.asList("scsj", "ngysj", "qdrq"));
|
|
|
|
|
+ // 数值字段:建表语句中为 numeric(18,4)
|
|
|
|
|
+ Set<String> numericFields = new HashSet<>(Arrays.asList(
|
|
|
|
|
+ "sccb", "mj_m", "jhxzmj", "yscmj", "bndscmj", "bndkfmj", "ngymj", "yjgysr", "mj_12"));
|
|
|
|
|
+
|
|
|
|
|
+ for (Map<String, Object> shpData : shpDataList) {
|
|
|
|
|
+ Map<String, Object> insertData = new LinkedHashMap<>();
|
|
|
|
|
+ for (Map.Entry<String, Object> e : shpData.entrySet()) {
|
|
|
|
|
+ String key = e.getKey();
|
|
|
|
|
+ Object val = e.getValue();
|
|
|
|
|
+ if (val == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 字符串做一次清洗:空白置为 null
|
|
|
|
|
+ if (val instanceof String) {
|
|
|
|
|
+ String s = ((String) val).trim();
|
|
|
|
|
+ if (s.isEmpty()) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (dateFields.contains(key)) {
|
|
|
|
|
+ int t = s.indexOf('T');
|
|
|
|
|
+ if (t > 0) {
|
|
|
|
|
+ s = s.substring(0, t);
|
|
|
|
|
+ }
|
|
|
|
|
+ insertData.put(key, s);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (numericFields.contains(key)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ insertData.put(key, new BigDecimal(s));
|
|
|
|
|
+ } catch (NumberFormatException ex) {
|
|
|
|
|
+ log.warn("字段 {} 数值转换失败,原值:{}", key, s);
|
|
|
|
|
+ }
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ insertData.put(key, s);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ insertData.put(key, val);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (MapUtils.isEmpty(insertData)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ //区分收储和转接
|
|
|
|
|
+ if(sourceType.equals("0")){
|
|
|
|
|
+ insertData.put("source_type","0");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ insertData.put("source_type","1");
|
|
|
|
|
+ }
|
|
|
|
|
+ gjShouchuJihuaMapper.insertTableData(
|
|
|
|
|
+ "gj_shouchu_xiangmu", insertData, shpDbSRID);
|
|
|
|
|
+ }
|
|
|
|
|
+ retMap.put("status","success");
|
|
|
|
|
+ retMap.put("path",shpFilePath);
|
|
|
|
|
+ return retMap;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|