From 33c488497230548c25c4246955cbfee7d92a8791 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Thu, 10 Apr 2025 15:06:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E6=AD=A3=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/OfflineZipUnpackServiceImpl.java | 82 +++++++++++++------ .../QualificationApplicationServiceImpl.java | 15 ++-- 2 files changed, 66 insertions(+), 31 deletions(-) diff --git a/src/com/engine/secret/service/impl/OfflineZipUnpackServiceImpl.java b/src/com/engine/secret/service/impl/OfflineZipUnpackServiceImpl.java index f94b87e..b6a1734 100644 --- a/src/com/engine/secret/service/impl/OfflineZipUnpackServiceImpl.java +++ b/src/com/engine/secret/service/impl/OfflineZipUnpackServiceImpl.java @@ -73,6 +73,15 @@ public class OfflineZipUnpackServiceImpl extends Service implements UnpackZipSer @Override public Map reviewResubmittedMaterials(String requestId, JsonNode rootNode, Map imageFileMap) { // TODO 逻辑待完善 + try { + this.imageFileMap = imageFileMap; + this.relatedFlowId = requestId; + // 写入补正文件数据 + updateCorrectedMaterials(rootNode); + } catch (Exception e) { + baseBean.writeLog(e); + throw new RuntimeException(e); + } return returnMap; } @@ -112,16 +121,12 @@ public class OfflineZipUnpackServiceImpl extends Service implements UnpackZipSer String relatedField = dataConfig.getRelatedField(); String rootPath = dataConfig.getRootPath(); baseBean.writeLog("rootPath==" + rootPath); + List childDataConfigList = dataConfig.getChildDataConfig(); // 字段对照关系 List fieldDetailList = dataConfig.getDetailList(); // 获取明细表相关信息 - List childDataConfigList = dataConfig.getChildDataConfig(); List fileList = dataConfig.getFileList(); - List formFieldList = ModeUtil.getFieldList(mainTableName); - Map mainTableFieldMap = formFieldList.stream().filter(item -> item.getViewtype() == 0).collect(Collectors.toMap(Formfield::getFieldname, item -> item, (k1, k2) -> k1)); - - if (CollectionUtils.isNotEmpty(fieldDetailList)) { // 根据RequestId获取对应建模表单的billId String sql = "select id from " + mainTableName + " where " + relatedField + " =?"; @@ -131,7 +136,23 @@ public class OfflineZipUnpackServiceImpl extends Service implements UnpackZipSer if (billId < 0) { continue; } - dealFileList(billId, fileList, mainTableName, false); + updateFileList(billId, fileList, mainTableName, false); + + // 处理明细表补正文件 + if (CollectionUtils.isNotEmpty(childDataConfigList)) { + for (DataConfig childDataConfig : childDataConfigList) { + String detailTableName = childDataConfig.getDetailTableName(); + // 获取字段对照关系数据 + List fieldList = childDataConfig.getDetailList(); + List childFileList = childDataConfig.getFileList(); + // 明细表文件配置不为空的情况下,只处理文件,不做其他数据插入处理 + if (CollectionUtils.isNotEmpty(childFileList)) { + baseBean.writeLog("开始解析文件,写入明细数据"); + updateFileList(billId, childFileList, detailTableName, true); + + } + } + } } } @@ -151,30 +172,34 @@ public class OfflineZipUnpackServiceImpl extends Service implements UnpackZipSer */ private void updateFileList(int mainId, List fileConfigList, String tableName, boolean isDetail) throws Exception { Map dataMap = new IgnoreCaseHashMap<>(); - Map defaultDataMap = new IgnoreCaseHashMap<>(); + + //StringBuilder whereSql = new StringBuilder(" where 1=1 "); + String fileTypeField = ""; + String fileTypeValue = ""; for (FileConfig fileConfig : fileConfigList) { String fieldName = fileConfig.getFieldName(); + + // 文件标识ID + String fileId = fileConfig.getFileId(); + String fixedValue = fileConfig.getFixedValue(); + String attachments = fileConfig.getAttachments(); + if (StringUtils.isNotBlank(fixedValue)) { + continue; + } + + // 附件清单不为空,则写入对应的浏览按钮ID + if (StringUtils.isNotBlank(attachments)) { + fileTypeField = fieldName; + fileTypeValue = attachments; + continue; + } + // 是否更正文件 String isFilled = fileConfig.getIsFilled(); if (!"2".equals(isFilled)) { // 如果类型不是更正文件,跳过不做处理 continue; } - // 文件标识ID - String fileId = fileConfig.getFileId(); - String fixedValue = fileConfig.getFixedValue(); - String attachments = fileConfig.getAttachments(); - if (StringUtils.isNotBlank(fixedValue)) { - // 默认值,直接写入表单对应的字段 - defaultDataMap.put(fieldName, fixedValue); - continue; - } - - // 附件清单不为空,则写入对应的浏览按钮ID - if (StringUtils.isNotBlank(attachments)) { - defaultDataMap.put(fieldName, attachments); - } - List applicationResources = applicationResourceMap.get(fileId); if (CollectionUtils.isEmpty(applicationResources)) { @@ -209,15 +234,22 @@ public class OfflineZipUnpackServiceImpl extends Service implements UnpackZipSer baseBean.writeLog("dataMap集合为空"); return; } + if (StringUtils.isBlank(fileTypeField) || StringUtils.isBlank(fileTypeValue)) { + baseBean.writeLog("fileTypeField==" + fileTypeField); + baseBean.writeLog("fileTypeValue==" + fileTypeValue); + return; + } + // defaultDataMap.get() // 合并默认值数据,如果文件集合为空,则不单独插入默认值 - //dataMap.putAll(defaultDataMap); - baseBean.writeLog("文件插入集合,dataMap==" + JSON.toJSONString(dataMap)); + baseBean.writeLog("文件更新集合,dataMap==" + JSON.toJSONString(dataMap)); // 根据主表、明细表,区分数据处理方式 if (isDetail) { dataMap.put("mainid", mainId); - ModeUtil.insertData(dataMap, tableName); + String whereSql = " where mainid = " + mainId + " and " + fileTypeField + "=" + fileTypeValue; + baseBean.writeLog("whereSql===" + whereSql); + ModeUtil.updateData(dataMap, tableName, whereSql); } else { dataMap.put("id", mainId); // 根据ID更新主表数据 diff --git a/src/com/engine/secret/service/impl/QualificationApplicationServiceImpl.java b/src/com/engine/secret/service/impl/QualificationApplicationServiceImpl.java index 17444f6..94622c9 100644 --- a/src/com/engine/secret/service/impl/QualificationApplicationServiceImpl.java +++ b/src/com/engine/secret/service/impl/QualificationApplicationServiceImpl.java @@ -53,6 +53,7 @@ public class QualificationApplicationServiceImpl extends Service implements Qual String docId = Util.null2String(param.get("docId")); String requestId = Util.null2String(param.get("requestId")); + String isCorrection = Util.null2String(param.get("isCorrection")); if (StringUtils.isBlank(docId)) { throw new CustomizeRunTimeException("文件获取失败,请确认文件是否上传"); } @@ -95,7 +96,7 @@ public class QualificationApplicationServiceImpl extends Service implements Qual //解压文件,处理压缩包 baseBean.writeLog("开始解压文件,处理压缩包"); - returnMap = unzipWithPassword(tempZipFile, Paths.get("output"), unzipPwd, requestId); + returnMap = unzipWithPassword(tempZipFile, Paths.get("output"), unzipPwd, requestId, isCorrection); baseBean.writeLog("压缩包处理完成"); return returnMap; } catch (Exception e) { @@ -111,7 +112,7 @@ public class QualificationApplicationServiceImpl extends Service implements Qual * @param outputDir * @param password */ - private Map unzipWithPassword(Path zipFilePath, Path outputDir, String password, String requestId) { + private Map unzipWithPassword(Path zipFilePath, Path outputDir, String password, String requestId, String isCorrection) { try { ZipFile zipFile = new ZipFile(zipFilePath.toFile()); if (zipFile.isEncrypted()) { @@ -153,14 +154,16 @@ public class QualificationApplicationServiceImpl extends Service implements Qual if (dataJsonImageId != null && dataJsonImageId > 0) { // 离线端方式 JsonNode rootNode = parseJsonContent(dataJsonImageId); - //buildFormFields(rootNode); - //offline(rootNode); - return ServiceUtil.getService(OfflineZipUnpackServiceImpl.class, user).registerAcceptance(requestId, rootNode, imageFileMap); + OfflineZipUnpackServiceImpl offlineZipUnpackService = ServiceUtil.getService(OfflineZipUnpackServiceImpl.class, user); + if ("true".equals(isCorrection)) { + return offlineZipUnpackService.reviewResubmittedMaterials(requestId, rootNode, imageFileMap); + } + return offlineZipUnpackService.registerAcceptance(requestId, rootNode, imageFileMap); } - return new HashMap<>(); // TODO 兼容其他方式 + return new HashMap<>(); } catch (Exception e) { if (e.getMessage().contains("Wrong password")) {