|
|
@@ -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()) {
|