|
@@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.onemap.apply.domain.cggl.*;
|
|
|
import com.onemap.apply.domain.sbjk.XzczghcgsbDTO;
|
|
|
import com.onemap.apply.mapper.cggl.*;
|
|
@@ -47,9 +49,9 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
-import static com.onemap.common.core.utils.StringUtils.FileSearch;
|
|
|
-import static com.onemap.common.core.utils.StringUtils.readTxt;
|
|
|
+import static com.onemap.common.core.utils.StringUtils.*;
|
|
|
|
|
|
|
|
|
@Service
|
|
@@ -71,6 +73,8 @@ public class CgglServiceImpl implements CgglService {
|
|
|
private ScmxRecordMapper scmxRecordMapper;
|
|
|
@Autowired
|
|
|
private XzczghcgsbMapper xzczghcgsbMapper;
|
|
|
+ @Autowired
|
|
|
+ private TCgglSjbzmlwjMapper tCgglSjbzmlwjMapper;
|
|
|
|
|
|
@Value("${Cggl.temp}")
|
|
|
private static String platform;
|
|
@@ -151,7 +155,7 @@ public class CgglServiceImpl implements CgglService {
|
|
|
//TODO wanger 总体规划跳过机器审查,原始赋值是9(待审查),现在改为1(审查结束)
|
|
|
curdto.setStatus("9");
|
|
|
curdto.setPath(temppath);
|
|
|
- curdto.setUnzippath(unzippath + "/" + StringUtils.getFileRelName(filename));
|
|
|
+ curdto.setUnzippath(unzippath + "/" + getFileRelName(filename));
|
|
|
escalationFileMapper.update(curdto, wrapper);
|
|
|
} catch (Exception r) {
|
|
|
r.printStackTrace();
|
|
@@ -209,27 +213,93 @@ public class CgglServiceImpl implements CgglService {
|
|
|
{
|
|
|
escalationDTO.setSczt("4");
|
|
|
}
|
|
|
- //TODO wanger 处理规划成果名称
|
|
|
- QueryWrapper<EscalationFileDTO> filewrapper = new QueryWrapper<EscalationFileDTO>();
|
|
|
- filewrapper.eq("id", escalationDTO.getFileid());
|
|
|
- EscalationFileDTO fileDto = escalationFileMapper.selectOne(filewrapper);
|
|
|
- if (fileDto != null) {
|
|
|
- String filepath = fileDto.getUnzippath();
|
|
|
+ //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(filepath, "基本信息.txt");
|
|
|
- if (StringUtils.isNotEmpty(txtFilePath)) {
|
|
|
- System.out.println("txtFilePath===" + txtFilePath);
|
|
|
- Map<String, String> txtMap = null;
|
|
|
- try {
|
|
|
- txtMap = readTxt(txtFilePath, charset);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- System.out.println("txtMap===" + txtMap);
|
|
|
- if (StringUtils.isNotEmpty(txtMap.get("xmmc"))) {
|
|
|
- escalationDTO.setName(txtMap.get("xmmc"));
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ //记录缺失的文件列表 字符串类型
|
|
|
+ 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);
|
|
|
}
|
|
|
escalationMapper.insert(escalationDTO);
|
|
|
addCgglRz(escalationDTO);
|
|
@@ -244,6 +314,63 @@ public class CgglServiceImpl implements CgglService {
|
|
|
return RequestResult.success("保存成功!", id);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 检查缺失的成果文件 递归调用 非常重要
|
|
|
+ *
|
|
|
+ * @param unzippath 文件路径
|
|
|
+ * @param sjbzlist 约定的数据标准检查项
|
|
|
+ * @param parentname 递归遍历用 父节点
|
|
|
+ * @param missfiles 缺失的文件列表
|
|
|
+ * @param xzqdm 行政区代码
|
|
|
+ * @param xzqmc 行政区名称
|
|
|
+ * @return List<String> missfiles 缺失的文件列表
|
|
|
+ */
|
|
|
+ public List<String> checkMustFiles(String unzippath, List<TCgglSjbzmlwjDto> sjbzlist, String parentname, List<String> missfiles, String xzqdm, String xzqmc) {
|
|
|
+ List<TCgglSjbzmlwjDto> filteredList = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotEmpty(parentname)) {
|
|
|
+ filteredList = sjbzlist.stream()
|
|
|
+ .filter(cur -> parentname.equals(cur.getSjml()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ filteredList = sjbzlist.stream()
|
|
|
+ .filter(cur -> cur.getSjml() == null)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ for (TCgglSjbzmlwjDto dto : filteredList) {
|
|
|
+ if ("O".equals(dto.getYstj()) || "C".equals(dto.getYstj())) {//跳过非必要审查项
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Integer lx = dto.getLx();
|
|
|
+ String gzmc = dto.getGzmc();
|
|
|
+ String mlmc = dto.getMlmc();
|
|
|
+ String curpath = "";//当前的文件或文件夹路径地址
|
|
|
+ if (StringUtils.isNotEmpty(gzmc)) {
|
|
|
+ curpath = getAbFilepath(gzmc, xzqdm, xzqmc, unzippath);
|
|
|
+ } else {
|
|
|
+ curpath = unzippath + "\\" + mlmc;
|
|
|
+ }
|
|
|
+ if (curpath.contains("不符")) {
|
|
|
+ missfiles.add(curpath);
|
|
|
+ return missfiles;
|
|
|
+ }
|
|
|
+ File folder = new File(curpath);
|
|
|
+ if (lx == 0) {//文件夹
|
|
|
+ if (folder.exists() && folder.isDirectory()) {
|
|
|
+ if (!curpath.endsWith(".gdb")) {
|
|
|
+ checkMustFiles(curpath, sjbzlist, dto.getBsm(), missfiles, xzqdm, xzqmc);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ missfiles.add(StringUtils.isNotEmpty(gzmc) ? gzmc : mlmc);
|
|
|
+ }
|
|
|
+ } else if (lx == 1) {//文件
|
|
|
+ if (!folder.exists()) {
|
|
|
+ missfiles.add(StringUtils.isNotEmpty(gzmc) ? gzmc : mlmc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return missfiles;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public RequestResult startcgsc(String scmodel, String jqscmodel, String cgid) {
|
|
|
try {
|
|
@@ -295,16 +422,29 @@ public class CgglServiceImpl implements CgglService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<EscalationInfoDTO> cgInfoList(String year, String xzqdm, String uploadstatus, String username, String cglevel, String plantype) {
|
|
|
+ public List<EscalationInfoDTO> cgInfoList(String year, String xzqdm, String uploadstatus, String username, String cglevel, String plantype, String name) {
|
|
|
//判断是否为市级用户查看旗县数据,需要过滤uploadstatus != '0'
|
|
|
String userlevel = "0";
|
|
|
if (SecurityUtils.getLoginUserXzq().length() == 4 && !"1".equals(cglevel)) {
|
|
|
userlevel = "1";
|
|
|
}
|
|
|
- List<EscalationInfoDTO> res = escalationMapper.selectInfoList(year, xzqdm, uploadstatus, username, cglevel, plantype, userlevel);
|
|
|
+ List<EscalationInfoDTO> res = escalationMapper.selectInfoList(year, xzqdm, uploadstatus, username, cglevel, plantype, userlevel, name);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新上报错误日志
|
|
|
+ *
|
|
|
+ * @param validateEscalationDTO
|
|
|
+ * @param loginfo
|
|
|
+ */
|
|
|
+ public void updateLogInfo(EscalationDTO validateEscalationDTO, String loginfo) {
|
|
|
+ QueryWrapper<EscalationDTO> wrapper = new QueryWrapper<EscalationDTO>();
|
|
|
+ wrapper.eq("id", validateEscalationDTO.getId());
|
|
|
+ validateEscalationDTO.setLoginfo(loginfo);
|
|
|
+ escalationMapper.update(validateEscalationDTO, wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public RequestResult updateCgInfo(EscalationDTO escalationDTO) {
|
|
|
QueryWrapper<EscalationDTO> wrapper = new QueryWrapper<EscalationDTO>();
|
|
@@ -416,6 +556,7 @@ public class CgglServiceImpl implements CgglService {
|
|
|
dto.setId(escalationDTO.getId());
|
|
|
dto.setRemark(reStrFileUpload.toJSONString());
|
|
|
addCgglRz(dto);
|
|
|
+ updateLogInfo(validateEscalationDTO, reStrFileUpload.toJSONString());
|
|
|
return RequestResult.error("上传规划成果数据分片失败:" + reStrFileUpload.getString("msg") + ",分片数: " + i + " !", false);
|
|
|
} else {//记录分片个数及上传状态
|
|
|
setSbjd(escalationDTO.getId(), (i + 1) + "/" + totalSliceNum);
|
|
@@ -442,11 +583,13 @@ public class CgglServiceImpl implements CgglService {
|
|
|
validateEscalationDTO.setInstid(validateEscalationDTO.getInstid() + "#");
|
|
|
}
|
|
|
} else {
|
|
|
+ updateLogInfo(validateEscalationDTO, mergeResult.toJSONString());
|
|
|
return RequestResult.error("上传规划成果数据接口-合包失败!" + (mergeResult == null ? "" : mergeResult.getString("message")), false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
+ updateLogInfo(validateEscalationDTO, reStrMd5.toJSONString());
|
|
|
System.out.println("上传规划成果数据接口-查询MD5值接口失败!");
|
|
|
return RequestResult.error("上传规划成果数据接口-查询MD5值接口失败!", false);
|
|
|
}
|
|
@@ -456,10 +599,12 @@ public class CgglServiceImpl implements CgglService {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
+ updateLogInfo(validateEscalationDTO, tokenJson.toJSONString());
|
|
|
System.out.println(tokenJson);
|
|
|
return RequestResult.error("市级系统token信息获取失败,请检查token获取地址、appid!", false);
|
|
|
}
|
|
|
} else {
|
|
|
+ updateLogInfo(validateEscalationDTO, tokenJson.toJSONString());
|
|
|
System.out.println(tokenJson);
|
|
|
return RequestResult.error("市级系统token信息获取失败,请检查token获取地址、appid!", false);
|
|
|
}
|