多单位版国产化地质资料管理系统
zs
2026-02-04 fe02f176b512a9d6a4e12437d929e04e99bb7567
src/main/java/com/zbooksoft/gdmis/controller/CatAjjxxController.java
@@ -9,9 +9,7 @@
import com.ruili.wcp.web.model.AjaxResponse;
import com.ruili.wcp.web.model.ErrorInfo;
import com.zbooksoft.gdmis.config.ArchivesCustomConfig;
import com.zbooksoft.gdmis.data.entity.CatCgwjxx;
import com.zbooksoft.gdmis.data.entity.CatCheck;
import com.zbooksoft.gdmis.data.entity.CatYswjxx;
import com.zbooksoft.gdmis.data.entity.*;
import com.zbooksoft.gdmis.service.*;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
@@ -37,7 +35,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipFile;
import static cn.hutool.core.util.ZipUtil.unzip;
import static com.zbooksoft.gdmis.common.XmlUtil.getDocument;
@@ -64,6 +64,10 @@
    UpdateXml2023Service updateXml2023Service;
    @Autowired
    XmlService xmlService;
    @Autowired
    CheckQuestionService checkQuestionService;
    @Autowired
    SaveQuestionService saveQuestionService;
    @Autowired
    CustomConfigUtil customConfigUtil;
@@ -101,10 +105,34 @@
    @RequiresUser
    public Object importXML(@RequestParam(value = "file", required = false) MultipartFile file, String startData, String endData) {
        try {
            Document document = getDocument(file);
            Element rootElement = document.getRootElement();
            String rootName = rootElement.getName();
            xmlService.readXml(document, startData, endData);
            ArchivesCustomConfig archivesCustomConfig = customConfigUtil.getConfigObj(ArchivesCustomConfig.class);
            String uploadPath = archivesCustomConfig.getOriginalPath();
            //判断传过来的文件是不是压缩包
            if (file.getOriginalFilename().endsWith(".zip")) {
                String tempDir = System.getProperty("java.io.tmpdir");
                String extractPath = tempDir + File.separator + "temp_" + System.currentTimeMillis();
                File extractDir = new File(extractPath);
                extractDir.mkdirs();
                String originalFilename = file.getOriginalFilename().substring(0, file.getOriginalFilename().lastIndexOf("."));
                try {
                    // 保存上传的 ZIP 文件到临时位置
                    File zipFile = new File(extractPath + File.separator + file.getOriginalFilename());
                    file.transferTo(zipFile);
                    // 解压 ZIP 文件
                    unzip(zipFile.getAbsolutePath(), uploadPath);
                    String xmlPath = uploadPath + File.separator + originalFilename + File.separator + "管理性文件" + File.separator + "资料文件目录.xml";
                    Document document = getDocument(xmlPath);
                    xmlService.readXml(document, startData, endData);
                } finally {
                    // 清理临时文件
                    deleteDir(extractDir);
                }
            } else {
                Document document = getDocument(file);
                xmlService.readXml(document, startData, endData);
            }
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
@@ -355,7 +383,7 @@
            String uploadPath = archivesCustomConfig.getOriginalPath();
            for (Map<String, Object> map : list) {
//                String dh = map.get("DH").toString();
                String dh = map.get("XMKYQBH").toString();
                String dh = map.get("XMKYQBH").toString()+"["+map.get("XMKYQMC")+"]";
                //d/省馆档号
                String filePath = uploadPath + dh + File.separator + "电子文件" + File.separator;
                Long id = Long.parseLong(map.get("ID").toString());
@@ -531,6 +559,47 @@
    }
    /**
     * 添加验收问题
     *
     * @return
     */
    @RequestMapping({"/SaveQuestion"})
    @ResponseBody
    @RequiresUser
    public Object SaveQuestion(@RequestBody Map<String, Object> postData) {
        try {
            Long id = Long.parseLong(postData.get("id").toString());
            String selectSql = "SELECT * FROM BUS_TRANSFER_LOG WHERE ID =" + id;
            Map<String, Object> map = jdbcTemplate.queryForMap(selectSql);
            Object ajId = map.get("AJ_ID");
            List<String> ids= (List<String>) postData.get("ids");
            for (String questionId : ids) {
                CheckQuestion question= checkQuestionService.getById(questionId);
                if (question != null) {
                    QueryWrapper<SaveQuestion> queryWrapper=new QueryWrapper<>();
                    queryWrapper.eq("TRANSFER_ID",id).eq("CHECK_ID",question.getId());
                    List<SaveQuestion> saveQuestionList=saveQuestionService.list(queryWrapper);
                    if (saveQuestionList.size()==0){
                        SaveQuestion saveQuestion=new SaveQuestion();
                        saveQuestion.setQuestion(question.getQuestion());
                        saveQuestion.setRequirements(question.getRequirements());
                        saveQuestion.setTranslation(question.getTranslation());
                        saveQuestion.setTransferId(id);
                        saveQuestion.setCheckId(question.getId());
                        saveQuestionService.saveOrUpdate(saveQuestion);
                    }
                }
            }
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
    /**
     * 资料验收
     *
     * @return
@@ -554,18 +623,23 @@
            CatCheck catCheck = new CatCheck();
            catCheck.setItemId(id);
            catCheck.setAjId(Long.parseLong(ajId.toString()));
            catCheck.setQuestion(postData.get("question").toString());
//            catCheck.setQuestion(postData.get("question").toString());
            catCheck.setIsPass(checkState);
            catCheck.setCreateTime(new Date());
            catCheck.setCreateUserName(user.getUserName());
            catCheck.setCreateUserId(user.getUserId());
            catCheck.setCheckQuestion(postData.get("checkQuestion") == null ? "" : postData.get("checkQuestion").toString());
//            catCheck.setCheckQuestion(postData.get("checkQuestion") == null ? "" : postData.get("checkQuestion").toString());
            catCheckService.saveOrUpdate(catCheck);
            String updateSql = "update BUS_TRANSFER_LOG set YSZT = '" + checkState + "' where ID = " + id;
            jdbcTemplate.execute(updateSql);
            String updateSqlY = "update CAT_ITEM_YSWJXX set YSZT = '" + checkState + "' where YJ_ID = " + id;
            jdbcTemplate.execute(updateSqlY);
            if (checkState==1){
                String updateSqlY = "update CAT_ITEM_YSWJXX set YSZT = '" + checkState + "' where YJ_ID = " + id;
                jdbcTemplate.execute(updateSqlY);
            }else if (checkState==3){
                String updateSqlY = "update CAT_FILE_AJJXX set YSWSJ = '" + postData.get("checkData") + "' where ID = " + ajId;
                jdbcTemplate.execute(updateSqlY);
            }
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
@@ -603,5 +677,17 @@
        }
        return totalSize;
    }
    private void deleteDir(File dir) {
        if (dir.isDirectory()) {
            File[] files = dir.listFiles();
            if (files != null) {
                for (File file : files) {
                    deleteDir(file);
                }
            }
        }
        dir.delete();
    }
}