补正文件上传

This commit is contained in:
dxfeng 2025-04-10 15:06:11 +08:00
parent b68ab60bf2
commit 33c4884972
2 changed files with 66 additions and 31 deletions

View File

@ -73,6 +73,15 @@ public class OfflineZipUnpackServiceImpl extends Service implements UnpackZipSer
@Override
public Map<String, Object> reviewResubmittedMaterials(String requestId, JsonNode rootNode, Map<String, Integer> 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<DataConfig> childDataConfigList = dataConfig.getChildDataConfig();
// 字段对照关系
List<DataConfigDetail> fieldDetailList = dataConfig.getDetailList();
// 获取明细表相关信息
List<DataConfig> childDataConfigList = dataConfig.getChildDataConfig();
List<FileConfig> fileList = dataConfig.getFileList();
List<Formfield> formFieldList = ModeUtil.getFieldList(mainTableName);
Map<String, Formfield> 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<DataConfigDetail> fieldList = childDataConfig.getDetailList();
List<FileConfig> 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<FileConfig> fileConfigList, String tableName, boolean isDetail) throws Exception {
Map<String, Object> dataMap = new IgnoreCaseHashMap<>();
Map<String, Object> 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<ApplicationResource> 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更新主表数据

View File

@ -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<String, Object> unzipWithPassword(Path zipFilePath, Path outputDir, String password, String requestId) {
private Map<String, Object> 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")) {