|
@@ -1,16 +1,18 @@
|
|
|
package com.onemap.file.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.onemap.common.core.constant.ServiceConstants;
|
|
|
import com.onemap.common.core.utils.StringUtils;
|
|
|
import com.onemap.common.core.web.domain.AjaxResult;
|
|
|
import com.onemap.common.core.web.domain.RequestResult;
|
|
|
+import com.onemap.common.security.utils.SecurityUtils;
|
|
|
import com.onemap.file.domain.SpaceFileRecordDTO;
|
|
|
+import com.onemap.file.domain.TUploadGeomDTO;
|
|
|
+import com.onemap.file.domain.TUploadGeomDetailsDTO;
|
|
|
import com.onemap.file.mapper.SpaceFileRecordMapper;
|
|
|
+import com.onemap.file.mapper.TUploadGeomDetailsMapper;
|
|
|
+import com.onemap.file.mapper.TUploadGeomMapper;
|
|
|
import com.onemap.file.service.ISpaceFileRecordService;
|
|
|
-import com.onemap.file.service.SaveFileService;
|
|
|
import com.onemap.file.utils.FileUtils;
|
|
|
import com.onemap.file.utils.UnPackageUtils;
|
|
|
import com.onemap.system.api.AnalyseService;
|
|
@@ -21,14 +23,15 @@ import com.onemap.system.api.domain.RawTableVo;
|
|
|
import com.onemap.file.domain.res.ApiTTable;
|
|
|
import com.onemap.file.domain.res.ApiTTableFiled;
|
|
|
import com.onemap.file.domain.res.TableDataVo;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.annotation.processing.FilerException;
|
|
|
import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
@@ -39,10 +42,14 @@ import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
public class SpaceFileRecordServiceImpl implements ISpaceFileRecordService {
|
|
|
+ @Resource
|
|
|
+ private TUploadGeomMapper tUploadGeomMapper;
|
|
|
+ @Resource
|
|
|
+ private TUploadGeomDetailsMapper tUploadGeomDetailsMapper;
|
|
|
+ @Resource
|
|
|
+ private ShpFileSaveService shpFileSaveService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private SaveFileService saveFileService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SpatialService spatialService;
|
|
|
@Value("${businessType.shp}")
|
|
|
private String shpLocalFilePath;
|
|
@@ -52,9 +59,10 @@ public class SpaceFileRecordServiceImpl implements ISpaceFileRecordService {
|
|
|
private TableFiledRelationService tableFiledRelationService;
|
|
|
@Resource
|
|
|
private AnalyseService analyseService;
|
|
|
+ private final int sridArea = 4525;
|
|
|
|
|
|
@Override
|
|
|
- public String saveSpaceFileRecord(SpaceFileRecordDTO spaceFileRecordDTO) throws Exception {
|
|
|
+ public String saveSpaceFileRecord(SpaceFileRecordDTO spaceFileRecordDTO) {
|
|
|
if (StringUtils.isEmpty(spaceFileRecordDTO.getId())) {
|
|
|
spaceFileRecordDTO.setId(StringUtils.getUUID());
|
|
|
}
|
|
@@ -235,4 +243,125 @@ public class SpaceFileRecordServiceImpl implements ISpaceFileRecordService {
|
|
|
}
|
|
|
return retList;
|
|
|
}
|
|
|
+
|
|
|
+ public String uploadAddShpFileV1(MultipartFile file, String fromRoute, Integer fromtype, String storeStats) throws Exception {
|
|
|
+ //获得文件名称
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ //获得文件后缀名
|
|
|
+ String type = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
|
|
+ //判断上传的是否是压缩包
|
|
|
+ if (!type.equals("zip")) {
|
|
|
+ throw new Exception("请上传压缩包");
|
|
|
+ }
|
|
|
+ // 获取当前时间的时间戳
|
|
|
+ long timeMillis = System.currentTimeMillis();
|
|
|
+ //生成SHP解压文件路径
|
|
|
+ String unzipPath = shpLocalFilePath + "/temp" + "/" + timeMillis;
|
|
|
+ //解压文件
|
|
|
+ uploadDestMultipartFile(file, unzipPath);
|
|
|
+
|
|
|
+ String newShpPath = null;
|
|
|
+ List<File> shpFiles = new ArrayList<>();
|
|
|
+ FileUtils.findShpFiles(new File(unzipPath), shpFiles);
|
|
|
+ if (shpFiles.size() > 0) {
|
|
|
+ newShpPath = shpFiles.get(0).getPath();
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(newShpPath)) {
|
|
|
+ throw new Exception("未读取到SHP文件");
|
|
|
+ }
|
|
|
+// File newShpFile = new File(newShpPath);
|
|
|
+ TUploadGeomDTO dto = new TUploadGeomDTO();
|
|
|
+ dto.setId(StringUtils.getUUID());
|
|
|
+ dto.setUploaduser(SecurityUtils.getUsername());
|
|
|
+ dto.setSridarea(sridArea);
|
|
|
+ dto.setFromtype(fromtype);
|
|
|
+ dto.setFromroute(fromRoute);
|
|
|
+ dto.setName(fileName);
|
|
|
+ dto.setFiletype(type);
|
|
|
+ dto.setUnzippath(unzipPath.replace("\\", "/"));
|
|
|
+ if (newShpPath != null) {
|
|
|
+ dto.setShppath(newShpPath.replace("\\", "/"));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> shpFeaturesList = shpFileSaveService.readShapeFile(newShpPath);
|
|
|
+ int sort = 0;
|
|
|
+ for (Map<String, Object> shpFeatures : shpFeaturesList) {
|
|
|
+ TUploadGeomDetailsDTO detailsDTO = new TUploadGeomDetailsDTO();
|
|
|
+ detailsDTO.setId(StringUtils.getUUID());
|
|
|
+ detailsDTO.setUploadId(dto.getId());
|
|
|
+ detailsDTO.setGeom((String) shpFeatures.get("the_geom"));
|
|
|
+ shpFeatures.remove("the_geom");
|
|
|
+ detailsDTO.setSridarea(sridArea);
|
|
|
+ detailsDTO.setSort(sort);
|
|
|
+ detailsDTO.setGeomJson(JSON.toJSONString(shpFeatures));
|
|
|
+ tUploadGeomDetailsMapper.insertTUploadGeomDetails(detailsDTO);
|
|
|
+ sort++;
|
|
|
+ }
|
|
|
+
|
|
|
+ TUploadGeomDTO retDto = tUploadGeomDetailsMapper.sumTUploadGeomDetailsByUploadId(dto.getId());
|
|
|
+ dto.setGeom(retDto.getGeom());
|
|
|
+ dto.setSpotsnumber(retDto.getSpotsnumber());
|
|
|
+ tUploadGeomMapper.insertTUploadGeom(dto);
|
|
|
+ return dto.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ public String uploadAddShpDrawV1(String geom, String fromRoute, Integer fromtype, String storeStats) {
|
|
|
+ String ewkt = "SRID=4326;" + geom;
|
|
|
+ if (geom.toLowerCase().indexOf("srid") >= 0) {
|
|
|
+ ewkt = geom;
|
|
|
+ }
|
|
|
+ TUploadGeomDTO dto = new TUploadGeomDTO();
|
|
|
+ dto.setId(StringUtils.getUUID());
|
|
|
+ dto.setUploaduser(SecurityUtils.getUsername());
|
|
|
+ dto.setGeom(ewkt);
|
|
|
+ dto.setSpotsnumber(1);
|
|
|
+ dto.setSridarea(sridArea);
|
|
|
+ dto.setFromtype(fromtype);
|
|
|
+ dto.setFromroute(fromRoute);
|
|
|
+ tUploadGeomMapper.insertTUploadGeom(dto);
|
|
|
+
|
|
|
+ TUploadGeomDetailsDTO detailsDTO = new TUploadGeomDetailsDTO();
|
|
|
+ detailsDTO.setId(StringUtils.getUUID());
|
|
|
+ detailsDTO.setUploadId(dto.getId());
|
|
|
+ detailsDTO.setGeom(ewkt);
|
|
|
+ detailsDTO.setGeom(ewkt);
|
|
|
+ detailsDTO.setSridarea(sridArea);
|
|
|
+ detailsDTO.setGeomJson("{\"id\":\"" + detailsDTO.getId() + "\"}");
|
|
|
+ tUploadGeomDetailsMapper.insertTUploadGeomDetails(detailsDTO);
|
|
|
+ return dto.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public int deleteTUploadGeomById(String id) {
|
|
|
+ tUploadGeomDetailsMapper.deleteTUploadGeomDetailsByUploadId(id);
|
|
|
+ return tUploadGeomMapper.deleteTUploadGeomById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TUploadGeomDTO selectTUploadGeomById(String id, Integer isDetail) {
|
|
|
+ TUploadGeomDTO dto = tUploadGeomMapper.selectTUploadGeomById(id);
|
|
|
+ if (dto == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (isDetail != null && isDetail == 1) {
|
|
|
+ TUploadGeomDetailsDTO uploadGeomDetailsDTO = new TUploadGeomDetailsDTO();
|
|
|
+ uploadGeomDetailsDTO.setUploadId(dto.getId());
|
|
|
+ List<TUploadGeomDetailsDTO> dataList = tUploadGeomDetailsMapper.selectTUploadGeomDetailsList(uploadGeomDetailsDTO);
|
|
|
+ dto.settUploadGeomDetailsDTOList(dataList);
|
|
|
+ }
|
|
|
+ return dto;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TUploadGeomDetailsDTO selectTUploadGeomDetailsById(String id) {
|
|
|
+ return tUploadGeomDetailsMapper.selectTUploadGeomDetailsById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void handleUploadGeomFollowUp(String id, Integer followup) {
|
|
|
+ System.out.println("handleUploadGeomFollowUp!!!!!!!");
|
|
|
+ }
|
|
|
+
|
|
|
}
|