src/main/java/com/lf/server/controller/data/PublishController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/entity/all/StaticData.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/mapper/data/MetaMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/service/data/MetaService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/service/data/RasterService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/mapper/data/MetaMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
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") src/main/java/com/lf/server/entity/all/StaticData.java
@@ -210,6 +210,11 @@ public static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; /** * æ æ ¼æ°æ®æ©å±å */ public final static List<String> RASTER_EXT = new ArrayList<>(Arrays.asList(".img", ".tif", ".tiff", "jpg", "jp2")); /** * å¯ç æ£åè¡¨è¾¾å¼ */ public final static String PWD_REG = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W!@#$%^&*`~()\\-_+=,.?;<>]+$)(?![a-z0-9]+$)(?![a-z\\W!@#$%^&*`~()\\-_+=,.?;<>]+$)(?![0-9\\W!@#$%^&*`~()\\-_+=,.?;<>]+$)[a-zA-Z0-9\\W!@#$%^&*`~()\\-_+=,.?;<>]{12,20}$"; src/main/java/com/lf/server/mapper/data/MetaMapper.java
@@ -130,12 +130,20 @@ /** * æ ¹æ®å¤ä¸ªIDæ¥è¯¢å æ°æ®ï¼æ°æ®è¡¨ï¼ * * @param ids * @return * @param ids IDå符串 * @return å æ°æ®éå */ public List<MetaEntity> selectByIdsForTab(String ids); /** * æ ¹æ®å¤ä¸ªIDæ¥è¯¢å æ°æ® * * @param ids IDå符串 * @return å æ°æ®éå */ public List<MetaEntity> selectByIds(String ids); /** * æ¥è¯¢å æ°æ®æä»¶ * * @param ids å æ°æ®IDéå src/main/java/com/lf/server/service/data/MetaService.java
@@ -130,6 +130,11 @@ } @Override public List<MetaEntity> selectByIds(String ids) { return metaMapper.selectByIds(ids); } @Override public List<MetaEntity> selectMetaFiles(List<Integer> ids) { return metaMapper.selectMetaFiles(ids); } src/main/java/com/lf/server/service/data/RasterService.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,58 @@ package com.lf.server.service.data; import com.lf.server.helper.StringHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.gdal.gdal.Dataset; import org.gdal.gdal.gdal; import org.gdal.gdalconst.gdalconst; import org.springframework.stereotype.Service; import java.io.File; /** * æ æ ¼æå¡ * @author WWW * @date 2023-08-27 */ @Service public class RasterService { private final static Log log = LogFactory.getLog(RasterService.class); /** * è·åæ æ ¼æ°æ®çEPSGç¼ç */ public Integer getRaterEpsg(String file) { Dataset ds = null; try { File f = new File(file); if (!f.exists() || f.isDirectory()) { return null; } ds = gdal.Open(file, gdalconst.GA_ReadOnly); if (null == ds || 0 == ds.getRasterCount()) { return null; } if (null == ds.GetSpatialRef()) { return null; } // PROJCSã GEOGCSãGEOGCS æ NULL String code = ds.GetSpatialRef().GetAuthorityCode(null); if (StringHelper.isEmpty(code)) { return null; } return Integer.parseInt(code); } catch (Exception ex) { log.error(ex.getMessage(), ex); return null; } finally { if (null != ds) { ds.delete(); } } } } src/main/resources/mapper/data/MetaMapper.xml
@@ -162,6 +162,12 @@ order by a.tab; </select> <select id="selectByIds" resultType="com.lf.server.entity.data.MetaEntity"> select a.* from lf.sys_meta a where id in (${ids}) order by id desc; </select> <select id="selectMetaFiles" resultType="com.lf.server.entity.data.MetaEntity"> select a.*,fn_uname(a.create_user) uname,fn_get_fullname(a.depcode, 1) depName,fn_ver(a.verid) verName,fn_get_fullname(a.dircode, 2) dirName from lf.sys_meta a