|
@@ -202,122 +202,127 @@ public class CgglServiceImpl implements CgglService {
|
|
|
// if (escalationDTO.getName().getBytes().length > 100) {
|
|
|
// return RequestResult.error("成果名称不能大于100个字节!", false);
|
|
|
// }
|
|
|
- String id = StringUtils.getUUID();
|
|
|
- escalationDTO.setUploadstatus("0");
|
|
|
- escalationDTO.setUploadtime(new Date());
|
|
|
- escalationDTO.setId(id);
|
|
|
- escalationDTO.setUsername(SecurityUtils.getUsername());
|
|
|
- String xzqdm = SecurityUtils.getLoginUserXzq(); //当前用户 点击获取市级审查结果
|
|
|
- escalationDTO.setXzqdm(xzqdm);
|
|
|
- if (xzqdm.length() == 4) //市级上传 则为市级待审
|
|
|
- {
|
|
|
- escalationDTO.setSczt("4");
|
|
|
- }
|
|
|
- //TODO wanger 根据成果目录要求进行审查和记录
|
|
|
- String plantype = escalationDTO.getPlantype();
|
|
|
- if (!"6".equals(plantype)) {
|
|
|
- QueryWrapper<EscalationFileDTO> filewrapper = new QueryWrapper<EscalationFileDTO>();
|
|
|
- filewrapper.eq("id", escalationDTO.getFileid());
|
|
|
- EscalationFileDTO fileDto = escalationFileMapper.selectOne(filewrapper);
|
|
|
- File zipFile = new File(fileDto.getPath());
|
|
|
- String fileRelName = getFileRelName(fileDto.getPath());
|
|
|
- //解析txt
|
|
|
- String txtFilePath = FileSearch(fileDto.getUnzippath(), "基本信息.txt");
|
|
|
- if (StringUtils.isEmpty(txtFilePath)) {
|
|
|
- deleteCurDirectory(zipFile.getParent());
|
|
|
- escalationFileMapper.delete(filewrapper);
|
|
|
- return RequestResult.error("1----成果包中必须包含“xxx基本信息.txt”文件,同时注意成果包中应包含“xxx规划成果”的根目录");
|
|
|
- }
|
|
|
- System.out.println("txtFilePath===" + txtFilePath);
|
|
|
- Map<String, String> txtMap = null;
|
|
|
- try {
|
|
|
- txtMap = readTxt(txtFilePath, charset);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- deleteCurDirectory(zipFile.getParent());
|
|
|
- escalationFileMapper.delete(filewrapper);
|
|
|
- return RequestResult.error("2---解析规划文本txt错误,请检查格式!");
|
|
|
- }
|
|
|
- System.out.println("txtMap===" + txtMap);
|
|
|
- String xmmc = txtMap.get("xmmc") != null ? txtMap.get("xmmc") : fileRelName;
|
|
|
- xzqdm = txtMap.get("行政区代码");
|
|
|
- String xzqmc = txtMap.get("行政区名称");
|
|
|
- String ghlxtext = txtMap.get("规划类型");
|
|
|
- String ghcjtext = txtMap.get("规划层级");
|
|
|
- String ghxstext = txtMap.get("成果形式");
|
|
|
- //TODO wanger 对成果包进行校验
|
|
|
- System.out.println("xmmc===" + xmmc);
|
|
|
- System.out.println("ghlxtext===" + ghlxtext);
|
|
|
- System.out.println("ghxstext===" + ghxstext);
|
|
|
- System.out.println("ghcjtext===" + ghcjtext);
|
|
|
- String sjbz_bsm = "";
|
|
|
- ObjectMapper objectMapper = new ObjectMapper();
|
|
|
- String txtjson = "";
|
|
|
- try {
|
|
|
- txtjson = objectMapper.writeValueAsString(txtMap);
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- sjbz_bsm = ghcjtext + "" + ghlxtext;
|
|
|
- QueryWrapper<TCgglSjbzmlwjDto> sjbzwrapper = new QueryWrapper();
|
|
|
- sjbzwrapper.eq("sjbz_bsm", sjbz_bsm);
|
|
|
- sjbzwrapper.orderByAsc("px");
|
|
|
- List<TCgglSjbzmlwjDto> sjbzlist = tCgglSjbzmlwjMapper.selectList(sjbzwrapper);
|
|
|
- if (sjbzlist.size() == 0) {
|
|
|
- deleteCurDirectory(zipFile.getParent());
|
|
|
- escalationFileMapper.delete(filewrapper);
|
|
|
- return RequestResult.error(String.format("3-----未授权的数据类型:%s,请联系管理人员!", sjbz_bsm));
|
|
|
+ try {
|
|
|
+ String id = StringUtils.getUUID();
|
|
|
+ escalationDTO.setUploadstatus("0");
|
|
|
+ escalationDTO.setUploadtime(new Date());
|
|
|
+ escalationDTO.setId(id);
|
|
|
+ escalationDTO.setUsername(SecurityUtils.getUsername());
|
|
|
+ String xzqdm = SecurityUtils.getLoginUserXzq(); //当前用户 点击获取市级审查结果
|
|
|
+ escalationDTO.setXzqdm(xzqdm);
|
|
|
+ if (xzqdm.length() == 4) //市级上传 则为市级待审
|
|
|
+ {
|
|
|
+ escalationDTO.setSczt("4");
|
|
|
}
|
|
|
- //TODO wanger 处理那些根目录带有“_报审”等的数据项
|
|
|
- if (fileRelName.contains("_")) {
|
|
|
- System.out.println("Important contains _");
|
|
|
- int count = fileRelName.split("_").length;
|
|
|
- for (TCgglSjbzmlwjDto sjbzmlwjDto : sjbzlist) {
|
|
|
- String bz = sjbzmlwjDto.getBz();
|
|
|
- if (StringUtils.isNotEmpty(bz) && bz.contains("根目录")) {
|
|
|
- String rule = sjbzmlwjDto.getGzmc();
|
|
|
- int rulecount = rule.split("_").length;
|
|
|
- if (rulecount == count) {
|
|
|
- //相等就代表命名规则一样,不需要处理
|
|
|
- } else {
|
|
|
- sjbzmlwjDto.setGzmc(rule + "_" + fileRelName.split("_")[fileRelName.split("_").length - 1]);
|
|
|
+ //TODO wanger 根据成果目录要求进行审查和记录
|
|
|
+ String plantype = escalationDTO.getPlantype();
|
|
|
+ if (!"6".equals(plantype)) {
|
|
|
+ QueryWrapper<EscalationFileDTO> filewrapper = new QueryWrapper<EscalationFileDTO>();
|
|
|
+ filewrapper.eq("id", escalationDTO.getFileid());
|
|
|
+ EscalationFileDTO fileDto = escalationFileMapper.selectOne(filewrapper);
|
|
|
+ File zipFile = new File(fileDto.getPath());
|
|
|
+ String fileRelName = getFileRelName(fileDto.getPath());
|
|
|
+ //解析txt
|
|
|
+ String txtFilePath = FileSearch(fileDto.getUnzippath(), "基本信息.txt");
|
|
|
+ if (StringUtils.isEmpty(txtFilePath)) {
|
|
|
+ deleteCurDirectory(zipFile.getParent());
|
|
|
+ escalationFileMapper.delete(filewrapper);
|
|
|
+ return RequestResult.error("1----成果包中必须包含“xxx基本信息.txt”文件,同时注意成果包中应包含“xxx规划成果”的根目录");
|
|
|
+ }
|
|
|
+ System.out.println("txtFilePath===" + txtFilePath);
|
|
|
+ Map<String, String> txtMap = null;
|
|
|
+ try {
|
|
|
+ txtMap = readTxt(txtFilePath, charset);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ deleteCurDirectory(zipFile.getParent());
|
|
|
+ escalationFileMapper.delete(filewrapper);
|
|
|
+ return RequestResult.error("2---解析规划文本txt错误,请检查格式!");
|
|
|
+ }
|
|
|
+ System.out.println("txtMap===" + txtMap);
|
|
|
+ String xmmc = txtMap.get("xmmc") != null ? txtMap.get("xmmc") : fileRelName;
|
|
|
+ xzqdm = txtMap.get("行政区代码");
|
|
|
+ String xzqmc = txtMap.get("行政区名称");
|
|
|
+ String ghlxtext = txtMap.get("规划类型");
|
|
|
+ String ghcjtext = txtMap.get("规划层级");
|
|
|
+ String ghxstext = txtMap.get("成果形式");
|
|
|
+ //TODO wanger 对成果包进行校验
|
|
|
+ System.out.println("xmmc===" + xmmc);
|
|
|
+ System.out.println("ghlxtext===" + ghlxtext);
|
|
|
+ System.out.println("ghxstext===" + ghxstext);
|
|
|
+ System.out.println("ghcjtext===" + ghcjtext);
|
|
|
+ String sjbz_bsm = "";
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ String txtjson = "";
|
|
|
+ try {
|
|
|
+ txtjson = objectMapper.writeValueAsString(txtMap);
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ sjbz_bsm = ghcjtext + "" + ghlxtext;
|
|
|
+ QueryWrapper<TCgglSjbzmlwjDto> sjbzwrapper = new QueryWrapper();
|
|
|
+ sjbzwrapper.eq("sjbz_bsm", sjbz_bsm);
|
|
|
+ sjbzwrapper.orderByAsc("px");
|
|
|
+ List<TCgglSjbzmlwjDto> sjbzlist = tCgglSjbzmlwjMapper.selectList(sjbzwrapper);
|
|
|
+ if (sjbzlist.size() == 0) {
|
|
|
+ deleteCurDirectory(zipFile.getParent());
|
|
|
+ escalationFileMapper.delete(filewrapper);
|
|
|
+ return RequestResult.error(String.format("3-----未授权的数据类型:%s,请联系管理人员!", sjbz_bsm));
|
|
|
+ }
|
|
|
+ //TODO wanger 处理那些根目录带有“_报审”等的数据项
|
|
|
+ if (fileRelName.contains("_")) {
|
|
|
+ System.out.println("Important contains _");
|
|
|
+ int count = fileRelName.split("_").length;
|
|
|
+ for (TCgglSjbzmlwjDto sjbzmlwjDto : sjbzlist) {
|
|
|
+ String bz = sjbzmlwjDto.getBz();
|
|
|
+ if (StringUtils.isNotEmpty(bz) && bz.contains("根目录")) {
|
|
|
+ String rule = sjbzmlwjDto.getGzmc();
|
|
|
+ int rulecount = rule.split("_").length;
|
|
|
+ if (rulecount == count) {
|
|
|
+ //相等就代表命名规则一样,不需要处理
|
|
|
+ } else {
|
|
|
+ sjbzmlwjDto.setGzmc(rule + "_" + fileRelName.split("_")[fileRelName.split("_").length - 1]);
|
|
|
+ }
|
|
|
+ System.out.println("Important handle end _" + "----" + sjbzmlwjDto.getGzmc());
|
|
|
+ break;
|
|
|
}
|
|
|
- System.out.println("Important handle end _" + "----" + sjbzmlwjDto.getGzmc());
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
+ //记录缺失的文件列表 字符串类型
|
|
|
+ List<String> missfiles = new ArrayList<>();
|
|
|
+ missfiles = checkMustFiles(zipFile.getParent(), sjbzlist, "", missfiles, xzqdm, xzqmc);
|
|
|
+ if (missfiles.size() > 0) {
|
|
|
+ deleteCurDirectory(zipFile.getParent());
|
|
|
+ escalationFileMapper.delete(filewrapper);
|
|
|
+ return RequestResult.error(String.format("4------成果数据缺少以下目录或文件:%s", String.join("\n", missfiles)), missfiles);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(xmmc)) {
|
|
|
+ escalationDTO.setName(xmmc);
|
|
|
+ }
|
|
|
+ fileDto.setRemark(txtjson);
|
|
|
+ escalationFileMapper.update(fileDto, filewrapper);
|
|
|
+ if (StringUtils.isNotEmpty(xzqdm)) {
|
|
|
+ escalationDTO.setXzqdm(xzqdm);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(xzqmc)) {
|
|
|
+ escalationDTO.setXzqmc(xzqmc);
|
|
|
+ }
|
|
|
}
|
|
|
- //记录缺失的文件列表 字符串类型
|
|
|
- List<String> missfiles = new ArrayList<>();
|
|
|
- missfiles = checkMustFiles(zipFile.getParent(), sjbzlist, "", missfiles, xzqdm, xzqmc);
|
|
|
- if (missfiles.size() > 0) {
|
|
|
- deleteCurDirectory(zipFile.getParent());
|
|
|
- escalationFileMapper.delete(filewrapper);
|
|
|
- return RequestResult.error(String.format("4------成果数据缺少以下目录或文件:%s", String.join("\n", missfiles)), missfiles);
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(xmmc)) {
|
|
|
- escalationDTO.setName(xmmc);
|
|
|
- }
|
|
|
- fileDto.setRemark(txtjson);
|
|
|
- escalationFileMapper.update(fileDto, filewrapper);
|
|
|
- if (StringUtils.isNotEmpty(xzqdm)) {
|
|
|
- escalationDTO.setXzqdm(xzqdm);
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(xzqmc)) {
|
|
|
- escalationDTO.setXzqmc(xzqmc);
|
|
|
- }
|
|
|
- }
|
|
|
- escalationMapper.insert(escalationDTO);
|
|
|
- addCgglRz(escalationDTO);
|
|
|
+ escalationMapper.insert(escalationDTO);
|
|
|
+ addCgglRz(escalationDTO);
|
|
|
// FixedThreadUtil.FIXED_THREAD_POOL.execute(() -> {
|
|
|
// String getUrl = cgscUrl + "cgid=" + id;
|
|
|
// System.out.println("开始进行成果审查,调用地址" + getUrl);
|
|
|
// HttpClientUtil.doGet(getUrl);
|
|
|
// });
|
|
|
- //TODO wanger 临时主动插入审查项数据表
|
|
|
- String taskid = StringUtils.getUUID();
|
|
|
- escalationMapper.insertScx(id, taskid);
|
|
|
- return RequestResult.success("保存成功!", id);
|
|
|
+ //TODO wanger 临时主动插入审查项数据表
|
|
|
+ String taskid = StringUtils.getUUID();
|
|
|
+ escalationMapper.insertScx(id, taskid);
|
|
|
+ return RequestResult.success("保存成功!", id);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return RequestResult.error("保存失败!", e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|