Ver Fonte

保存图片修改路径

gushoubang há 9 meses atrás
pai
commit
74c869238a

+ 1 - 1
onemap-api/onemap-api-system/src/main/java/com/onemap/system/api/SpatialService.java

@@ -13,6 +13,6 @@ import org.springframework.web.bind.annotation.RequestBody;
  */
 @FeignClient(contextId = "spatialService", value = ServiceNameConstants.SPATIAL_SERVICE, fallbackFactory = SpatialFallbackFactory.class)
 public interface SpatialService {
-    @PostMapping("/spatial/image/sensing")
+    @PostMapping("/image/sensing")
     RequestResult getImage(@RequestBody WktsVo wktsVo);
 }

+ 1 - 1
onemap-common/onemap-common-core/src/main/java/com/onemap/common/core/constant/ServiceNameConstants.java

@@ -30,5 +30,5 @@ public class ServiceNameConstants
     /**
      * 空间服务的serviceid
      */
-    public static final String SPATIAL_SERVICE = "spatial-analyse";
+    public static final String SPATIAL_SERVICE = "onemap-spatial";
 }

+ 3 - 1
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/mapper/base/FzxzResMapper.java

@@ -2,6 +2,7 @@ package com.onemap.analyse.mapper.base;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.onemap.analyse.domain.SelectionResDTO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -11,5 +12,6 @@ import java.util.List;
 public interface FzxzResMapper extends BaseMapper<SelectionResDTO> {
     void saveOne(SelectionResDTO fzxzResDTO);
 
-    List<SelectionResDTO> getListByRwbsm(String rwbsm);
+    List<SelectionResDTO> getListByRwbsm(@Param("rwbsm") String rwbsm,
+                                         @Param("bsms") List<String> bsmList);
 }

+ 1 - 1
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/impl/FzssServiceImpl.java

@@ -466,7 +466,7 @@ public class FzssServiceImpl implements IFzssService {
         result.setGeom(geomRes.getGeom());
 
         // 3.查询分析结果地块信息
-        List<SelectionResDTO> selectionResList = fzxzResMapper.getListByRwbsm(result.getBsm());
+        List<SelectionResDTO> selectionResList = fzxzResMapper.getListByRwbsm(result.getBsm(),null);
         List<Map<String, Object>> dkMaps = new ArrayList<>();
         for (SelectionResDTO selectionRes : selectionResList) {
             // 查询地块信息

+ 29 - 35
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/impl/ReportServiceImpl.java

@@ -20,6 +20,9 @@ import com.onemap.analyse.utils.NpoiHelper;
 import com.onemap.analyse.utils.NumberUtil;
 import com.onemap.analyse.utils.UnitsUtil;
 import com.onemap.common.core.utils.StringUtils;
+import com.onemap.common.core.web.domain.RequestResult;
+import com.onemap.system.api.SpatialService;
+import com.onemap.system.api.domain.WktsVo;
 import org.apache.commons.io.FileUtils;
 import org.apache.poi.util.Units;
 import org.apache.poi.xwpf.usermodel.*;
@@ -57,6 +60,9 @@ public class ReportServiceImpl implements IReportService {
     @Resource
     GhdkaMapper ghdkaMapper;
 
+    @Resource
+    SpatialService spatialService;
+
     // 根据选址任务生成报告
     public FzxzReport createReport(String bsm, List<String> dkIds) {
         // 保存生成报告日志
@@ -233,13 +239,7 @@ public class ReportServiceImpl implements IReportService {
             tabYztbTitles.add(tableTitleTb);
             XWPFTable tableYztb = NpoiHelper.setComTable(document, tabYztbTitles, fztable, "表2:地类分析统计表", pos++);
             // 查询结果
-            QueryWrapper<SelectionResDTO> giswrapper = new QueryWrapper<>();
-            giswrapper.eq("rwbsm", res.getBsm());
-            // 筛选方案,根据传参或者预选方案
-            if (dkIds != null && dkIds.size() > 0) {
-                giswrapper.in("bsm", dkIds);
-            }
-            List<SelectionResDTO> fzxzJgGisDTOList = fzxzResMapper.selectList(giswrapper);
+            List<SelectionResDTO> fzxzJgGisDTOList = fzxzResMapper.getListByRwbsm(res.getBsm(), dkIds);
             NpoiHelper.catalog(document, "三、选址分析", pos++);
             String ydmc = res.getYdmc();
             if (!StringUtils.isEmpty(ydmc)) {
@@ -294,12 +294,16 @@ public class ReportServiceImpl implements IReportService {
                     cell.removeParagraph(0);
                 }
 
+                String geomWkt = item.getGeom();
+                String path = reportImg(geomWkt);
+
                 // 在合并后的单元格中创建一个新的段落
                 XWPFParagraph paraImag = row.getCell(0).addParagraph();
                 paraImag.setAlignment(ParagraphAlignment.CENTER); // 居中对齐
 
                 XWPFRun run = paraImag.createRun();
-                File imageFile = new File("states.png");
+                // File imageFile = new File("states.png");
+                File imageFile = new File(path);
                 BufferedImage bufferedImage = ImageIO.read(imageFile);
 
                 int originalWidth = bufferedImage.getWidth();
@@ -458,35 +462,25 @@ public class ReportServiceImpl implements IReportService {
     }
 
     /**
-     * TODO 待定
      * 导出报告图片
      *
-     * @param res
-     * @param xzbsmList 没有导出全部的地块
+     * @param wkt
      * @return
      */
-//     private List<String> ReportImg(FzxzEntityDTO res, List<String> xzbsmList) {
-//         // 查询分析结果图斑信息
-//         QueryWrapper<FzxzResDTO> giswrapper = new QueryWrapper<>();
-//         giswrapper.eq("rwbsm", res.getBsm());
-//         // 筛选方案,根据传参或者预选方案
-// //            giswrapper.ne("yxfa", "0");
-//         if (xzbsmList != null) {
-//             giswrapper.in("bsm", xzbsmList);
-//         }
-//         List<FzxzResDTO> fzxzJgGisDTOList = fzxzResMapper.selectList(giswrapper);
-//         // SDE转SHP
-//         String inShp = fzxzShp;
-//         List objidlist = new ArrayList<>();
-//         for (FzxzResDTO cur : fzxzJgGisDTOList) {
-//             // objidlist.add(cur.getObjectid());
-//         }
-//         String objids = Joiner.on(",").join(objidlist);
-//         // sde2Shp("KJGH.T_FZSS_FZXZ_JG_GIS", inShp, "\"OBJECTID\" IN (" + objids + ")");
-//         // 执行python
-//         Map<String, String> params = new HashMap<>();
-//         // List<String> result = PythonExecute.RunFzxzMap(mapFunctionId, params);
-//         List<String> result = new ArrayList<>();
-//         return result;
-//     }
+    private String reportImg(String wkt) {
+        String path = "";
+
+        WktsVo wktsVo = new WktsVo();
+
+        WktsVo.WktInfo wktInfo = new WktsVo.WktInfo();
+        wktInfo.setWkt(wkt);
+        wktsVo.getWktInfos().add(wktInfo);
+
+        RequestResult requestResult = spatialService.getImage(wktsVo);
+        if (requestResult.isSuccess()) {
+            Map<String, String> map = (Map<String, String>) requestResult.get("data");
+            path=map.get("path");
+        }
+        return path;
+    }
 }

+ 4 - 0
onemap-modules/onemap-analyse/src/main/resources/mapper/oracle/base/FzxzResMapper.xml

@@ -22,5 +22,9 @@
                land_price
         FROM t_fzss_fzxz_res
         WHERE rwbsm = #{rwbsm}
+        <if test="bsms != null and bsms.size()>0 ">
+            and (bsm::VARCHAR) in
+            <foreach collection="bsms" item="id" open="(" close=")" separator=",">#{id}</foreach>
+        </if>
     </select>
 </mapper>

+ 6 - 1
onemap-modules/onemap-spatial/src/main/java/com/onemap/spatial/controller/ImageController.java

@@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/image")
@@ -18,6 +20,9 @@ public class ImageController {
 
     @PostMapping("/sensing")
     public RequestResult getImage(@RequestBody WktsVo wktsVo) throws Exception {
-        return RequestResult.success(imageService.getSensingImage(wktsVo));
+        String path = imageService.getSensingImage(wktsVo);
+        Map<String, String> map = new HashMap<>();
+        map.put("path", path);
+        return RequestResult.success(map);
     }
 }

+ 5 - 2
onemap-modules/onemap-spatial/src/main/java/com/onemap/spatial/service/impl/ImageServiceImpl.java

@@ -83,7 +83,10 @@ public class ImageServiceImpl implements IImageService {
         for (WktsVo.WktInfo wktInfo : wktsVo.getWktInfos()) {
             // 将 WKT 转换为几何对象并添加到图层
             WKTReader wktReader = new WKTReader(JTSFactoryFinder.getGeometryFactory());
-            Geometry geometry = wktReader.read(wktInfo.getWkt());
+
+            String wkt = wktInfo.getWkt().replaceFirst("^SRID=\\d+;", "");
+
+            Geometry geometry = wktReader.read(wkt);
 
             SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
             typeBuilder.setName("geometry");
@@ -114,7 +117,7 @@ public class ImageServiceImpl implements IImageService {
         File outputFile = new File(filePath);
         try (FileOutputStream fileOutputStream = new FileOutputStream(outputFile); ImageOutputStream outputImageFile = ImageIO.createImageOutputStream(fileOutputStream);) {
 
-            int w = 600;
+            int w = 400;
             int h = (int) (w * (combinedBounds.getHeight() / combinedBounds.getWidth()));
             BufferedImage bufferedImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
             Graphics2D g2d = bufferedImage.createGraphics();

+ 5 - 1
sql/pgsql/0_init.sql

@@ -24,4 +24,8 @@ vector."AFTER_JCSH"
 vector."AFTER_BJXM_SZ"
 
 -- 只同步数据
-base."t_fzss_fzxz_factor"
+base."t_fzss_fzxz_factor"
+
+-- 需要修改的nacos
+-- onemap-spatial-dev.yml
+-- onemap-analyse-dev.yml