rain
2024-07-10 3afaf1a21f47b6f9b46dd8e089e15e1e325c810a
src/main/java/com/dji/sample/patches/service/impl/ShpToDataSourceServiceImpl.java
@@ -1,7 +1,9 @@
package com.dji.sample.patches.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dji.sample.patches.config.pojo.PatchesConfigPojo;
import com.dji.sample.patches.dao.ShpToDataSourceMapper;
import com.dji.sample.patches.model.dto.ShpDTO;
import com.dji.sample.patches.model.entity.LotInfo;
import com.dji.sample.patches.service.ShpToDataSourceService;
import com.dji.sample.patches.utils.*;
@@ -18,6 +20,7 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
@@ -45,9 +48,10 @@
    public MultipartFile insertGeo(MultipartFile file, String workspaceId, String waylineName, double airportLat, double airportLon) throws Exception {
        List<LotInfo> list = new ArrayList<>();
        File file1 = MultipartFileTOFileUtil.multipartFile2File(file, patchesConfigPojo.getUnzip());
        List<String> s = ShapeFileUtil.shpToGeoJson(file1);
        String[] arr1 = FormatConversionUtil.formatConversion(s);
        for (int i = 0; i < arr1.length; i++) {
        List<ShpDTO> shpData = ShapeFileUtil.shpToGeoJson(file1);
        String s=null;
        for (int i = 0; i < shpData.size(); i++) {
            String[] arr1 = FormatConversionUtil.formatConversion(Collections.singletonList(s));
            LotInfo lotInfo = new LotInfo();
            String temp = arr1[i].trim();
            temp = FormatConversionUtil.modifySpacesAndCommas(temp);
@@ -78,14 +82,17 @@
    }
    @Transactional
    public void savaInMysql(List<TbDkjbxxEntity> list, String workspaceId) {
    public void savaInMysql(List<TbDkjbxxEntity> list, String workspaceId,String id,String name) {
        for (int i = 0; i < list.size(); i++) {
            LotInfo lotInfo = new LotInfo();
            lotInfo.setWorkspaceId(workspaceId);
            lotInfo = dbConvertToEntity(list.get(i), workspaceId);
            lotInfo.setTaskId(id);
            lotInfo.setTaskName(name);
            lotInfo = dbConvertToEntity(list.get(i), workspaceId, id, name);
            shpToDataSourceMapper.insert(lotInfo);
        }
    }
    /**
     * 将SQlite数据库中DKJBXX对象转换为LotInfo对象。
@@ -93,27 +100,32 @@
     * @param file 需要转换的DKJBXX对象。
     * @return 返回一个构建好的LotInfo对象,包含从数据库实体中转换来的信息。
     */
    private LotInfo dbConvertToEntity(TbDkjbxxEntity file, String workspaceId) {
        double[] coordinates = extractCoordinates(pointCGCStoWGS(file.getXzb(), file.getYzb()));
    private LotInfo dbConvertToEntity(TbDkjbxxEntity file, String workspaceId,String id,String name) {
        LotInfo.LotInfoBuilder builder = LotInfo.builder();
        builder.bsm(file.getBsm())
                .bz(file.getBz())
                .dkmj(file.getDkmj())
                .dkmc(file.getDkmc())
                .dkbh(file.getDkbh())
                .xmc(file.getXmc())
                .xzb(coordinates[0])
                .sfbhzdk(file.getSfbhzdk())
                .sjlx(file.getSjlx())
                .dkfw(poylonCGCStoWGS(file.getDkfw()))
                .xzqdm(file.getXzqdm())
                .yzb(coordinates[1])
                .kzxx(file.getKzxx())
                .dklx(file.getDklx())
        builder.bsm(file.getFId())
                .xzqdm(file.getFXzqdm())
                .dkbh(file.getFTbbh())
                .dkfw(file.getFShape())
                .workspaceId(workspaceId)
                .isPlan(0)
                .isPush(0)
                .xmc(DistrictCodeUtils.nameToCode(file.getFXzqdm()))
                .investigate(0)
                .taskId(id)
                .taskName(name)
                .build();
        return builder.build();
    }
//    private LotInfo shpDtoToLotInfo(ShpDTO shpDTO){
//        LotInfo.LotInfoBuilder builder=LotInfo.builder();
//        builder.
//
//    }
    public List<LotInfo> getNoPlan(){
   return shpToDataSourceMapper.selectList(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getIsPlan,0));
    }
}