Procházet zdrojové kódy

导出合规性分析范围与管控数据不重叠的区域为shp压缩包

wanger před 2 měsíci
rodič
revize
b5a43c83dd

+ 14 - 0
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/controller/ChscController.java

@@ -114,5 +114,19 @@ public class ChscController extends BaseController {
         return res;
     }
 
+    /**
+     * 导出合规性分析范围与管控数据不重叠的区域为shp压缩包
+     *
+     * @param bsm
+     * @param response
+     * @return
+     */
+    @RequestMapping("/hgxfxExport")
+    public RequestResult hgxfxExport(String bsm,
+                                          HttpServletResponse response) {
+        RequestResult res = chscService.hgxfxExport(bsm, response);
+        return res;
+    }
+
 
 }

+ 9 - 0
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/domain/HgxfxDTO.java

@@ -21,8 +21,17 @@ public class HgxfxDTO {
     private Date rwjssj;
     private String cjyh;
     private String rwly;
+    private String fxfw;
     private Date cjsj;
 
+    public String getFxfw() {
+        return fxfw;
+    }
+
+    public void setFxfw(String fxfw) {
+        this.fxfw = fxfw;
+    }
+
     public String getBsm() {
         return bsm;
     }

+ 2 - 0
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/IChscService.java

@@ -25,4 +25,6 @@ public interface IChscService {
     WebResult txt2shp(MultipartFile file, HttpServletResponse response);
 
     WebResult GetXzdk(String bsm, Integer type);
+
+    RequestResult hgxfxExport(String bsm, HttpServletResponse response);
 }

+ 53 - 4
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/service/impl/ChscServiceImpl.java

@@ -51,6 +51,10 @@ public class ChscServiceImpl implements IChscService {
     private FxfwDictDTO fxfwDictDTO = new FxfwDictDTO();
     @Value("${Hgxfx.temp}")
     private String temp;
+    @Value("${Python.fileLocation}")
+    private String pyLocation;
+    @Value("${Hgxfx.exportFunctionId}")
+    private String exportFunctionId;
     //sde2shp方法标识码
     private String sde2shpPyFun = "sde2shp";
     //shp2geojson方法标识码
@@ -224,10 +228,13 @@ public class ChscServiceImpl implements IChscService {
                 String curkzm = ".shp";
                 for (int i = 0; i < kzm.length; i++) {
                     String curpath = shppath.replaceAll(curkzm, kzm[i]);
-                    Map cur = new HashMap();
-                    cur.put("fileName", FileStreamUtils.getFileName(curpath));
-                    cur.put("outByte", FileStreamUtils.getByteArrayOutputStream(curpath).toByteArray());
-                    fileList.add(cur);
+                    File curfile = new File(curpath);
+                    if (curfile.exists()) {
+                        Map cur = new HashMap();
+                        cur.put("fileName", FileStreamUtils.getFileName(curpath));
+                        cur.put("outByte", FileStreamUtils.getByteArrayOutputStream(curpath).toByteArray());
+                        fileList.add(cur);
+                    }
                 }
                 ZipUtils.zipFiles(fileList, response);
             } else {
@@ -302,6 +309,48 @@ public class ChscServiceImpl implements IChscService {
         return WebResult.error("操作失败", "不支持的type参数值");
     }
 
+    @Override
+    public RequestResult hgxfxExport(String bsm, HttpServletResponse response) {
+        try {
+            String pyfolder = pyLocation.substring(0, pyLocation.lastIndexOf("\\"));
+            String shppath = String.format("%s\\hgxfx\\out\\%s.shp", pyfolder, bsm);
+            File file = new File(shppath);
+            if (!file.exists()) {// shp文件如不存在,则调用python生成shp文件
+                System.out.println("shp文件不存在");
+                //调用Python执行命令
+                Map<String, String> params = new HashMap<>();
+                params.put("bsm", bsm);
+                String msg = PythonExecute.Run(exportFunctionId, params);
+                if (StringUtils.isNotEmpty(msg) && msg.contains("OK")) {
+
+                } else {
+                    return RequestResult.error("shp数据python导出失败!");
+                }
+            }
+            //将shp相关文件进行压缩并输入
+            List<Map> fileList = new ArrayList<>();
+            Map map = new HashMap();
+            map.put("fileName", FileStreamUtils.getFileName(shppath));
+            map.put("outByte", FileStreamUtils.getByteArrayOutputStream(shppath).toByteArray());
+            fileList.add(map);
+            String curkzm = ".shp";
+            for (int i = 0; i < kzm.length; i++) {
+                String curpath = shppath.replaceAll(curkzm, kzm[i]);
+                File curfile = new File(curpath);
+                if (curfile.exists()) {
+                    Map cur = new HashMap();
+                    cur.put("fileName", FileStreamUtils.getFileName(curpath));
+                    cur.put("outByte", FileStreamUtils.getByteArrayOutputStream(curpath).toByteArray());
+                    fileList.add(cur);
+                }
+            }
+            ZipUtils.zipFiles(fileList, response);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return RequestResult.success("导出成功!");
+    }
+
     public void checkAndMakeFolder(String path) {
         File dir = new File(path);
         if (!dir.exists()) {

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

@@ -73,6 +73,11 @@ public class FzssServiceImpl implements IFzssService {
         if (info != null) {
             return info;
         }
+        //TODO wanger 响应张科需求,保存下用户上传的shp数据用于赋值原始shp字段信息
+        String fxfw = hgxfxEntityDTO.getXzfw();
+        if(StringUtils.isNotEmpty(fxfw) && fxfw.contains(".shp")){
+            requestHgxfxDTO.setFxfw(fxfw);
+        }
         //查询审查项 默认把控制线级别等于0的也添加进去
         QueryWrapper<HgxfxScxDTO> wrapper = new QueryWrapper<HgxfxScxDTO>();
         wrapper.eq("kzxjb", 0).or().in("bsm", hgxfxEntityDTO.getScxs().split(",")).orderByAsc("xssx");