|
@@ -1,237 +0,0 @@
|
|
|
-package com.onemap.analyse.service.impl;
|
|
|
-
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.onemap.analyse.task.PythonExecute;
|
|
|
-import com.onemap.analyse.utils.DownloadUtils;
|
|
|
-import com.onemap.analyse.utils.EsriJsonUtils;
|
|
|
-import com.onemap.analyse.utils.FileUtils;
|
|
|
-import com.onemap.analyse.utils.HttpUtil;
|
|
|
-import com.onemap.analyse.domain.*;
|
|
|
-import com.onemap.analyse.mapper.*;
|
|
|
-import com.onemap.analyse.service.IChscService;
|
|
|
-import com.onemap.common.core.domain.R;
|
|
|
-import com.onemap.common.core.utils.FileStreamUtils;
|
|
|
-import com.onemap.common.core.utils.StringUtils;
|
|
|
-import com.onemap.common.core.utils.ZipUtils;
|
|
|
-import com.onemap.common.core.web.domain.WebResult;
|
|
|
-import com.onemap.system.api.RemoteAuthService;
|
|
|
-import org.python.modules._marshal;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.*;
|
|
|
-import java.nio.file.Paths;
|
|
|
-import java.util.*;
|
|
|
-
|
|
|
-// @Service
|
|
|
-// public class ChscServiceImpl implements IChscService {
|
|
|
-public class ChscServiceImpl {
|
|
|
-
|
|
|
- // @Autowired
|
|
|
- // private RemoteAuthService remoteAuthService;
|
|
|
- // @Autowired
|
|
|
- // private FzssSystemMapper fzssSystemMapper;
|
|
|
- // @Resource
|
|
|
- // private FzssChscMapper fzssChscMapper;
|
|
|
- // @Resource
|
|
|
- // private HgxfxMapper hgxfxMapper;
|
|
|
- // @Resource
|
|
|
- // private FzxzMapper fzxzMapper;
|
|
|
- // @Resource
|
|
|
- // private FzssChscFileMapper fzssChscFileMapper;
|
|
|
- // private RwztDTO rwztDTO = new RwztDTO();
|
|
|
- // private XzlbDTO xzlbDTO = new XzlbDTO();
|
|
|
- // private FxfwDictDTO fxfwDictDTO = new FxfwDictDTO();
|
|
|
- // @Value("${Hgxfx.temp}")
|
|
|
- // private String temp;
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public R<?> authorize(String appid, HttpServletRequest request, HttpServletResponse response) {
|
|
|
- // QueryWrapper<FzssSystemDTO> wrapper = new QueryWrapper<>();
|
|
|
- // wrapper.eq("id", appid);
|
|
|
- // FzssSystemDTO system = fzssSystemMapper.selectOne(wrapper);
|
|
|
- // if (system != null) {
|
|
|
- // String requestIp = HttpUtil.getRequestIp(request);
|
|
|
- // if (!system.getIp().contains(requestIp)) {
|
|
|
- // return R.fail(500, "访问ip与申请ip不一致");
|
|
|
- // }
|
|
|
- // R<?> r = remoteAuthService.empoweruser(system.getUsername());
|
|
|
- // return r;
|
|
|
- // }
|
|
|
- // return R.fail(500, "未检索到appid相关信息");
|
|
|
- // }
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public WebResult download(String bsm, HttpServletRequest request, HttpServletResponse response) {
|
|
|
- // QueryWrapper<FzxzChscDTO> wrapper = new QueryWrapper<>();
|
|
|
- // wrapper.eq("bsm", bsm);
|
|
|
- // FzxzChscDTO chsc = fzssChscMapper.selectOne(wrapper);
|
|
|
- // if (chsc != null && rwztDTO.getComplete().equals(chsc.getRwzt())) {
|
|
|
- // //选址类别(0意向范围筛选,1指定空间位置)
|
|
|
- // if (xzlbDTO.getHgxfx() == chsc.getXzlb()) {
|
|
|
- // HgxfxDTO hgxfx = hgxfxMapper.selectOne(new QueryWrapper<HgxfxDTO>().eq("bsm", bsm));
|
|
|
- // if (hgxfx != null) {
|
|
|
- // DownloadUtils.download(response, hgxfx.getFxbg().replace(".docx", ".pdf"), "选址报告");
|
|
|
- // return null;
|
|
|
- // } else {
|
|
|
- // return WebResult.error("查询报告为空");
|
|
|
- // }
|
|
|
- // } else if (xzlbDTO.getXmxz() == chsc.getXzlb()) {
|
|
|
- // FzxzDTO fzxz = fzxzMapper.selectOne(new QueryWrapper<FzxzDTO>().eq("bsm", bsm));
|
|
|
- // if (fzxz != null) {
|
|
|
- // DownloadUtils.download(response, fzxz.getFxbg(), "选址报告");
|
|
|
- // return null;
|
|
|
- // } else {
|
|
|
- // return WebResult.error("查询报告为空");
|
|
|
- // }
|
|
|
- // }
|
|
|
- // return WebResult.error("查询报告为空");
|
|
|
- // }
|
|
|
- // return WebResult.error("项目不存在或分析未完成");
|
|
|
- // }
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public WebResult getProgress(String bsm, HttpServletRequest request, HttpServletResponse response) {
|
|
|
- // QueryWrapper<FzxzChscDTO> wrapper = new QueryWrapper<>();
|
|
|
- // wrapper.eq("bsm", bsm);
|
|
|
- // FzxzChscDTO chsc = fzssChscMapper.selectOne(wrapper);
|
|
|
- // if (chsc != null) {
|
|
|
- // FzxzChscProgressDTO res = new FzxzChscProgressDTO();
|
|
|
- // res.setBsm(chsc.getBsm());
|
|
|
- // res.setJd(chsc.getRwjd());
|
|
|
- // res.setMsg(chsc.getRwzt() == rwztDTO.getNoJX() ? "未解析" : chsc.getRwjg());
|
|
|
- // res.setState(chsc.getRwzt());
|
|
|
- // return WebResult.success("操作成功", res);
|
|
|
- // } else {
|
|
|
- // return WebResult.error("项目不存在");
|
|
|
- // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public WebResult xmjg(FzssChscXmgxDTO fzssChscXmgxDTO) {
|
|
|
- // QueryWrapper<FzxzChscDTO> wrapper = new QueryWrapper<>();
|
|
|
- // wrapper.eq("bsm", fzssChscXmgxDTO.getBsm());
|
|
|
- // FzxzChscDTO chsc = fzssChscMapper.selectOne(wrapper);
|
|
|
- // if (chsc != null) {
|
|
|
- // chsc.setChzt(String.valueOf(fzssChscXmgxDTO.getChzt()));
|
|
|
- // chsc.setChjg(fzssChscXmgxDTO.getChjg());
|
|
|
- // chsc.setChbz(fzssChscXmgxDTO.getChjg());
|
|
|
- // try {
|
|
|
- // fzssChscMapper.update(chsc, wrapper);
|
|
|
- // return WebResult.success("操作成功", true);
|
|
|
- // } catch (Exception e) {
|
|
|
- // e.printStackTrace();
|
|
|
- // }
|
|
|
- // return WebResult.error("数据更新失败");
|
|
|
- // }
|
|
|
- // return WebResult.error("项目编码错误");
|
|
|
- // }
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public WebResult create(FzxzChscDTO fzxzChscDTO) {
|
|
|
- // if (!fzxzChscDTO.paramsChecked()) {
|
|
|
- // return WebResult.error("必输入参数不能为空");
|
|
|
- // }
|
|
|
- // if (fzxzChscDTO.getFwlx() == fxfwDictDTO.getShp()) {
|
|
|
- // FzssChscFileDTO fileDTO = fzssChscFileMapper.selectOne(new QueryWrapper<FzssChscFileDTO>().eq("bsm", fzxzChscDTO.getXzfw()));
|
|
|
- // if (fileDTO == null) {
|
|
|
- // return WebResult.error("选址范围错误,请检查参数是否正确");
|
|
|
- // }
|
|
|
- // if (!FileUtils.check(fileDTO.getWj())) {
|
|
|
- // return WebResult.error("选址范围未找到,请重新上传范围文件");
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // return WebResult.error("FWLX暂不支持" + fzxzChscDTO.getFwlx());
|
|
|
- // }
|
|
|
- // //插入策划生成数据库表
|
|
|
- // String uuid = StringUtils.getUUID();
|
|
|
- // fzxzChscDTO.setBsm(uuid);
|
|
|
- // fzxzChscDTO.setRwzt(rwztDTO.getNoJX());
|
|
|
- // fzxzChscDTO.setCjsj(new Date());
|
|
|
- // fzssChscMapper.insert(fzxzChscDTO);
|
|
|
- // return WebResult.success("操作成功", uuid);
|
|
|
- // }
|
|
|
- //
|
|
|
- // @Override
|
|
|
- // public WebResult txt2shp(MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
|
|
|
- // //将txt文件保存到本地
|
|
|
- // long timeMillis = System.currentTimeMillis();
|
|
|
- // String targetfolder = temp + "\\" + timeMillis + "\\";
|
|
|
- // String targetfile = targetfolder + file.getOriginalFilename();
|
|
|
- // String jsonpath = targetfolder + "esrijson.json";
|
|
|
- // String shppath = targetfolder + "shape.shp";
|
|
|
- // try {
|
|
|
- // FileUtils.makedir(targetfolder);
|
|
|
- // file.transferTo(Paths.get(targetfile));
|
|
|
- // } catch (IOException e) {
|
|
|
- // e.printStackTrace();
|
|
|
- // }
|
|
|
- // List<String> strlist = new ArrayList<>();
|
|
|
- // BufferedReader br = null;
|
|
|
- // try {
|
|
|
- // br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(targetfile)), "UTF-8"));//GBK
|
|
|
- // String str = null;
|
|
|
- // int i = 0;
|
|
|
- // while ((str = br.readLine()) != null) {
|
|
|
- // if (!StringUtils.isEmpty(str) && !str.startsWith("#")) {
|
|
|
- // strlist.add(str);
|
|
|
- // }
|
|
|
- // i++;
|
|
|
- // }
|
|
|
- // } catch (IOException e) {
|
|
|
- // e.printStackTrace();
|
|
|
- // } finally {
|
|
|
- // try {
|
|
|
- // br.close();
|
|
|
- // } catch (IOException e) {
|
|
|
- // e.printStackTrace();
|
|
|
- // }
|
|
|
- // }
|
|
|
- // //将文本字符串进行转换,生成esrijson并保存到本地
|
|
|
- // String esrijson = EsriJsonUtils.arrayToJson(strlist);
|
|
|
- // //写入文件
|
|
|
- // FileOutputStream fos = null;
|
|
|
- // try {
|
|
|
- // fos = new FileOutputStream(jsonpath, true);
|
|
|
- // //true表示在文件末尾追加
|
|
|
- // fos.write(esrijson.toString().getBytes());
|
|
|
- // fos.close();
|
|
|
- // } catch (IOException e) {
|
|
|
- // e.printStackTrace();
|
|
|
- // }
|
|
|
- // try {
|
|
|
- // //调用Python执行esrijson转shp
|
|
|
- // String msg = PythonExecute.EsriJson2shp(jsonpath, shppath);
|
|
|
- // if (!StringUtils.isEmpty(msg) && msg.contains("OK")) {
|
|
|
- // //将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[] kzm = {".sbn",".shx", ".dbf", ".cpg", ".prj"};
|
|
|
- // 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);
|
|
|
- // }
|
|
|
- // ZipUtils.zipFiles(fileList,response);
|
|
|
- // } else {
|
|
|
- // WebResult.error("json转shape失败", false);
|
|
|
- // }
|
|
|
- // }catch (Exception e){
|
|
|
- // e.printStackTrace();
|
|
|
- // }
|
|
|
- // //当初当前临时文件夹
|
|
|
- // FileUtils.deldir(targetfolder);
|
|
|
- // return null;
|
|
|
- // }
|
|
|
-}
|