管道基础大数据平台系统开发-【后端】-Server
13693261870
2023-08-27 126a156beabb3e61bc5ba888f8915adc8e974c2a
src/main/java/com/lf/server/controller/data/PublishController.java
@@ -3,14 +3,19 @@
import com.lf.server.annotation.SysLog;
import com.lf.server.controller.all.BaseController;
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.entity.all.StaticData;
import com.lf.server.entity.ctrl.PubEntity;
import com.lf.server.entity.data.MetaEntity;
import com.lf.server.entity.data.MetaFileEntity;
import com.lf.server.entity.data.PublishEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.PathHelper;
import com.lf.server.helper.StringHelper;
import com.lf.server.helper.WebHelper;
import com.lf.server.service.data.LayerService;
import com.lf.server.service.data.MetaService;
import com.lf.server.service.data.PublishService;
import com.lf.server.service.data.RasterService;
import com.lf.server.service.sys.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -20,6 +25,8 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -39,6 +46,15 @@
    @Resource
    LayerService layerService;
    @Resource
    MetaService metaService;
    @Resource
    RasterService rasterService;
    @Resource
    PathHelper pathHelper;
    @SysLog()
    @ApiOperation(value = "分页查询元数据")
@@ -231,6 +247,53 @@
    }
    @SysLog()
    @ApiOperation(value = "查询栅格数据的坐标系ID")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "元数据ID集合", dataType = "Integer[]", paramType = "query", example = "10531,10527,10526")
    })
    @GetMapping(value = "/selectRasterCs")
    public ResponseMsg<Object> selectRasterCs(Integer[] ids, HttpServletRequest req) {
        try {
            if (null == ids || ids.length == 0) {
                return fail("元数据ID集合不能为空");
            }
            List<MetaEntity> list = metaService.selectByIds(StringHelper.join(Arrays.asList(ids), ","));
            if (null == list || list.isEmpty()) {
                return fail("查无数据");
            }
            String basePath = pathHelper.getConfig().getUploadPath() + File.separator;
            List<MetaEntity> errList = new ArrayList<>();
            for (MetaEntity me : list) {
                if (!StaticData.RASTER_EXT.contains("." + me.getType())) {
                    me.setBak("不是栅格数据");
                    errList.add(me);
                    continue;
                }
                String filePath = basePath + me.getPath();
                File f = new File(filePath);
                if (!f.exists() || f.isDirectory()) {
                    me.setBak("文件不存在");
                    errList.add(me);
                    continue;
                }
                Integer epsg = rasterService.getRaterEpsg(filePath);
                if (null == epsg || epsg < 1) {
                    me.setBak("坐标系ID无效");
                    errList.add(me);
                }
            }
            return success(errList.size(), errList);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "插入发布数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "PubEntity", paramType = "body")
@@ -251,11 +314,9 @@
                entity.setToken(WebHelper.getToken(req));
            }
            layerService.clearCache();
            String method = getConvertMethod(entity.getType());
            long count = publishService.postForPub(entity, method, req);
            if (count > 0) {
                layerService.clearCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -279,7 +340,7 @@
            case "BIM":
                return "/Convert/ToTileset";
            case "LAS":
                return "/Convert/ToLas";
                return "/Convert/ToLasByPy";
            case "OSGB":
                return "/Convert/ToOsgb";
            default:
@@ -306,12 +367,10 @@
            }
            // publishService.deleteFiles(list)
            layerService.clearCache();
            publishService.deleteFiles(ids, req);
            int count = publishService.deletes(ids, req);
            if (count > 0) {
                layerService.clearCache();
            }
            return success(count);
        } catch (Exception ex) {
@@ -333,10 +392,8 @@
                entity.setUpdateUser(ue.getId());
            }
            layerService.clearCache();
            int count = publishService.update(entity);
            if (count > 0) {
                layerService.clearCache();
            }
            return success(count);
        } catch (Exception ex) {