方法整合
This commit is contained in:
parent
3bf6ad29f6
commit
da8970a861
|
|
@ -0,0 +1,67 @@
|
|||
let enable = true;
|
||||
let isRun = false;
|
||||
|
||||
const config = {
|
||||
58: {}
|
||||
}
|
||||
|
||||
|
||||
const viewSwitch = () => {
|
||||
var ids = ModeList.getCheckedID();
|
||||
var customId = ModeList.getCustomID();
|
||||
if (!ids || ids.length === 0) {
|
||||
ModeForm.showMessage("请至少选择一条数据");
|
||||
} else {
|
||||
const idArrays = ids.split(',');
|
||||
const count = idArrays.length;
|
||||
const msg = `是否将${count}条申请更改为省级事权?`;
|
||||
|
||||
ModeList.showConfirm(msg, function () {
|
||||
|
||||
$.ajax({
|
||||
url: '/api/secret/authority/change/delegateToProvincialAuthority',
|
||||
type: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
data: {
|
||||
"ids": ids,
|
||||
"customId": customId
|
||||
},
|
||||
async: false,
|
||||
success: function (res) {
|
||||
if (res.api_status && res.data) {
|
||||
ModeForm.showModalMsg("系统提示", "操作完成", 3);
|
||||
} else {
|
||||
ModeForm.showModalMsg("系统提示", res.errormsg, 2);
|
||||
}
|
||||
},
|
||||
error: function (error) {
|
||||
ModeForm.showModalMsg("系统提示", "接口请求异常,请联系管理员处理", 2);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ecodeSDK.overwritePropsFnQueueMapSet('WeaTop', {
|
||||
fn: (newProps) => {
|
||||
if (!enable) return;
|
||||
const {hash} = window.location;
|
||||
if (!hash.startsWith('#/main/cube/search')) return;
|
||||
if (!ModeForm) return;
|
||||
const customId = ModeList.getCustomID();
|
||||
;
|
||||
if (!config[customId]) return;
|
||||
const {Button} = antd;
|
||||
if (newProps.buttons.length >= 1) newProps.buttons[0] = (
|
||||
<Button type="primary" onClick={() => viewSwitch()
|
||||
}> 事权变更 < /Button>);
|
||||
return newProps;
|
||||
},
|
||||
order: 1,
|
||||
desc: '事权变更按钮'
|
||||
});
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
"保密资质电子申请工具问题反馈": "a10b01ed-cc95-4803-a3eb-b8fbfd9a3eea",
|
||||
"单位法定代表人承诺书": "f189cd72-fe6c-456a-976f-b87f506f7391",
|
||||
"保密资质申请单位廉政告知书": "99ca4d34-9ede-4c8c-9309-6b56184e5fe7",
|
||||
"企业营业执照或事业单位法人证书": "d1d0d687-fede-4e68-9a7e-478b6aac0b1f",
|
||||
"单位章程": "68884b49-a5a8-446a-b0f7-37628d8ebfe1",
|
||||
"注册资本以货币资金实缴额": "e3d4386d-503c-4f29-b936-f8d0efa80aa1",
|
||||
"申请单位股东持股比例情况": "e8a37daf-34a7-4e90-82c2-75020f21bea3",
|
||||
"申请单位实际控制人为中方的证明材料": "41fe5bbe-01ed-47dc-8fcf-f1ce7e08ff21",
|
||||
"申请单位自然人股东情况": "38678a86-0054-400b-aab7-91ce9c61026e",
|
||||
"申请单位法人股东的单位章程及营业执照": "d58bbe86-ff01-4395-9c2c-8fe017a69ddc",
|
||||
"申请单位法人股东的单位性质和股权结构": "2d8f49a6-439e-409b-abef-68f13aaf90f8",
|
||||
"通过间接方式外国投资者在申请单位的出资比例": "914abaec-4228-4a39-bf6b-e0a3abb73704",
|
||||
"外国投资者在申请单位母公司的出资比例情况": "83c64e5a-acd3-4eb7-bd5b-80a9325c98a2",
|
||||
"申请单位所有股东的实际控制人为中方的证明材料": "99d5feef-5121-440d-b06a-51bee67ced47",
|
||||
"上市(含新三板挂牌)母公司实际控制人为中方的证明材料": "76f3516e-f6fa-4cfd-8884-061bcb6a6a3b",
|
||||
"上市(含新三板挂牌)母公司控制措施": "ed8bdbd1-a5bc-4fbb-8306-305f07453f5e",
|
||||
"上市(含新三板挂牌)母公司当前股份构成情况": "0e528376-3cec-4e4f-ba87-bf7dd88365f0",
|
||||
"上市(含新三板挂牌)母公司外国投资者投资情况": "77c57d44-dcbf-4664-9e30-f9998bf446ae",
|
||||
"上市(含新三板挂牌)母公司信息披露制度": "d488faae-6f4b-494c-88b3-0ed18cd342e2",
|
||||
"上市(含新三板挂牌)母公司和申请单位的承诺": "5b5540d0-4751-4704-9698-1a89b0af36b8",
|
||||
"在新三板挂牌申请单位当前参与挂牌交易的股份比例情况": "c25245a7-d444-4b28-8952-e3e1f5d68294",
|
||||
"在新三板挂牌申请单位的控制措施": "16667323-3e59-4394-859e-fbc8d606e071",
|
||||
"在新三板挂牌申请单位信息披露制度": "cc2c20d5-9196-479b-a284-c5ca09a6b961",
|
||||
"公司组织架构图": "1a3580b1-cf10-4936-9d68-47b44d72678e",
|
||||
"保密组织机构图": "acfc4b35-ac81-4f7b-a9fd-30257f957a54",
|
||||
"设立保密组织机构和人员任命的有关证明材料": "0abd8ffd-26b0-49ad-b060-e5b3690bf612",
|
||||
"管理制度": "daf1a632-f3b7-40f1-ba07-b9494a9c2215",
|
||||
"保密管理制度目录清单": "268165a3-498a-437c-972d-757bf32da8c3",
|
||||
"高级管理人员情况": "e3754e0b-a54f-4ffc-aec4-21bb8ad7052e",
|
||||
"从事集成资质业务的相关人员名单": "0913f71d-de2c-4371-987c-2ff95981a79d",
|
||||
"从事集成资质业务相关的涉密人员名单及身份情况声明": "3fa96ce4-dd29-4e8c-b450-4fa3ff43ff71",
|
||||
"依法缴纳社保证明": "bacd44b5-bc53-4643-9af5-3ecd5e53921a",
|
||||
"相关高级职称或者相应执业资格人员情况": "e640a4fb-190a-4312-b0f1-6caafeb7c19d",
|
||||
"生产经营和办公场所(含涉密业务场所)自有产权证书或租赁合同": "e1aabcd1-1907-4d46-8cf7-ecf0b9135087",
|
||||
"涉密集成业务场所平面图": "e8b9d303-2120-45ff-80fd-e1ded313baa6",
|
||||
"涉密集成业务场所安全保密防护情况": "6b325933-9ed9-4e90-ad13-a893be1e1fb3",
|
||||
"屏蔽室建设类资质自主研发的屏蔽产品检测证书或相关证明材料(仅适用于屏蔽室建设申请单位)": "91d7da56-c7c3-495d-8152-defa85b8d474",
|
||||
"保密设施、设备清单": "99aba9be-2ce8-447a-ae68-9954677c951a",
|
||||
"近三年与所申请集成资质相关的业务合同清单": "924f4a28-15d9-4627-9557-94ce01cc07ea",
|
||||
"工程监理业务投资总值证明材料": "6c527abd-9e19-43ca-8a46-6ec2b338498f",
|
||||
"系统咨询业务投资总值证明材料": "eaaa8296-b4e0-404f-b33c-caf71f812680",
|
||||
"获得资质(资格)证明材料": "bec82acf-62ae-47ed-b3c4-af321ceb0080",
|
||||
"可能影响申请单位保密管理和涉密业务开展的相关说明": "c4b751f1-8cb1-4885-b12c-d2c41f8553bc",
|
||||
"一次性告知书回执": "2ea76b52-d196-4e51-8c17-3037c5084854",
|
||||
"涉密信息系统集成资质申请单位申请条件对照自查表": "a857a387-7ed0-453d-a4e3-d17d1bd51eb6",
|
||||
"上一个会计年度净资产相关证明材料": "8a4141f2-aa5f-4d50-9411-08358574a7f1",
|
||||
"申请单位控股股东情况(仅申请国家统一考试试卷、涉密防伪票据证书资质单位填写)": "7091c0ee-3555-4b4e-80f5-01d74be44284",
|
||||
"申请单位控股股东实际控制人为中方的证明材料(本项仅申请国家统一考试试卷、涉密防伪票据证书资质填写)": "056ab4de-82d9-4a9b-8509-8c980e027978",
|
||||
"风险提示知悉确认单": "d7691b7a-6eac-4718-af63-3ee8f5da3e01",
|
||||
"保密管理制度目录清单": "e2fd7412-6aff-43fa-975f-a17647ae409c",
|
||||
"从事印制资质业务的相关人员名单": "e176a4c2-1b80-4b1a-91bb-d3bb30e5d356",
|
||||
"从事印制资质业务相关的涉密人员名单及身份情况声明": "e2aecd68-9ad6-414a-a0ba-aa588cae2f15",
|
||||
"生产经营场所(含涉密业务场所和独立保密室)平面图": "d9b72776-e43b-4ecb-bcd8-f267b848ed08",
|
||||
"涉密印制业务场所安全保密防护情况": "90133051-6851-43aa-9bb6-2d82a5458799",
|
||||
"近三年与所申请印制资质相关的业务合同清单": "c0b4c4ff-2769-4f1a-a2eb-95d07a588b80",
|
||||
"上一年度企业年度报告": "dc64d42f-8e5a-4735-838f-2789a9381bfa",
|
||||
"从事印刷、复制等经营活动的许可证明": "fe01b9d0-d8b9-413f-9016-3124afed1051",
|
||||
"国家秘密载体印制资质申请单位申请条件对照自查表": "65265437-d9ed-4ac6-acf0-499e7922baab"
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package com.engine.secret.service;
|
||||
|
||||
import net.lingala.zip4j.model.FileHeader;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
|
|
@ -11,8 +11,22 @@ import java.util.zip.ZipFile;
|
|||
*/
|
||||
public interface UnpackZipService {
|
||||
|
||||
void dataUnpack(ZipFile zipFile, FileHeader jsonFileHeader);
|
||||
/**
|
||||
* 材料收件
|
||||
*
|
||||
* @param requestId
|
||||
* @param rootNode
|
||||
* @param imageFileMap
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
Map<String, Object> registerAcceptance(String requestId, JsonNode rootNode, Map<String, Integer> imageFileMap) throws Exception;
|
||||
|
||||
void fileUnpack();
|
||||
/**
|
||||
* 材料补正
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> reviewResubmittedMaterials(String requestId, JsonNode rootNode, Map<String, Integer> imageFileMap);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,36 @@
|
|||
package com.engine.secret.service.impl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.secret.entity.unpack.*;
|
||||
import com.engine.secret.enums.ApplicationCategory;
|
||||
import com.engine.secret.enums.CategoryValue;
|
||||
import com.engine.secret.enums.IntegrateCategory;
|
||||
import com.engine.secret.enums.PrintCategory;
|
||||
import com.engine.secret.exception.CustomizeRunTimeException;
|
||||
import com.engine.secret.service.UnpackZipService;
|
||||
import com.engine.secret.util.ConfigUtil;
|
||||
import com.engine.secret.util.FieldConvertUtil;
|
||||
import com.engine.secret.util.ModeUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.weaver.formmodel.data.model.Formfield;
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
import net.lingala.zip4j.model.FileHeader;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.formmode.IgnoreCaseHashMap;
|
||||
import weaver.general.BaseBean;
|
||||
|
||||
import java.util.zip.ZipFile;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
|
|
@ -12,13 +38,632 @@ import java.util.zip.ZipFile;
|
|||
* @version: 1.0
|
||||
*/
|
||||
public class OfflineZipUnpackServiceImpl extends Service implements UnpackZipService {
|
||||
@Override
|
||||
public void dataUnpack(ZipFile zipFile, FileHeader jsonFileHeader) {
|
||||
|
||||
int uploadCatalogue;
|
||||
|
||||
BaseBean baseBean = new BaseBean();
|
||||
|
||||
Map<String, List<ApplicationResource>> applicationResourceMap;
|
||||
|
||||
Map<String, Map<String, ResourceInfo>> resourceInfoMap;
|
||||
|
||||
Map<String, Integer> imageFileMap;
|
||||
|
||||
String relatedFlowId;
|
||||
|
||||
Map<String, Object> returnMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Map<String, Object> registerAcceptance(String requestId, JsonNode rootNode, Map<String, Integer> imageFileMap) {
|
||||
try {
|
||||
this.imageFileMap = imageFileMap;
|
||||
this.relatedFlowId = requestId;
|
||||
buildFormFields(rootNode);
|
||||
offline(rootNode);
|
||||
} catch (Exception e) {
|
||||
baseBean.writeLog(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileUnpack() {
|
||||
public Map<String, Object> reviewResubmittedMaterials(String requestId, JsonNode rootNode, Map<String, Integer> imageFileMap) {
|
||||
// TODO 逻辑待完善
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 离线解析方式
|
||||
*
|
||||
* @param rootNode
|
||||
* @throws JsonProcessingException
|
||||
*/
|
||||
private void offline(JsonNode rootNode) throws Exception {
|
||||
String uploadCatalogueStr = ConfigUtil.getConfig("UPLOAD_CATALOGUE");
|
||||
if (StringUtils.isBlank(uploadCatalogueStr)) {
|
||||
throw new CustomizeRunTimeException("未获取到解析文件目录设置,检查配置[uf_config]");
|
||||
}
|
||||
uploadCatalogue = Convert.toInt(uploadCatalogueStr, -1);
|
||||
baseBean.writeLog("uploadCatalogue==" + uploadCatalogue);
|
||||
List<DataConfig> dataConfigList = getDataConfig("0");
|
||||
baseBean.writeLog("dataConfigList==" + JSON.toJSONString(dataConfigList));
|
||||
|
||||
// 处理文件数据
|
||||
List<ApplicationResource> applicationResourceList = getApplicationResourceList(rootNode);
|
||||
// key是fid 集合是该同一个fid下的文件ID信息
|
||||
applicationResourceMap = applicationResourceList.stream().collect(Collectors.groupingBy(ApplicationResource::getFid));
|
||||
baseBean.writeLog("applicationResourceMap==" + JSON.toJSONString(applicationResourceMap));
|
||||
List<ResourceInfo> resourceInfoList = getResourceInfoList(rootNode);
|
||||
// key是fid 集合是该同一个fid下的文件ID信息
|
||||
resourceInfoMap = resourceInfoList.stream().collect(Collectors.groupingBy(ResourceInfo::getVirtualPath, Collectors.toMap(ResourceInfo::getId, item -> item)));
|
||||
baseBean.writeLog("resourceInfoMap==" + JSON.toJSONString(resourceInfoMap));
|
||||
|
||||
|
||||
if (CollectionUtils.isNotEmpty(dataConfigList)) {
|
||||
// 遍历配置,读取配置文件,并插入数据
|
||||
for (DataConfig dataConfig : dataConfigList) {
|
||||
String mainTableName = dataConfig.getMainTableName();
|
||||
String relatedField = dataConfig.getRelatedField();
|
||||
String rootPath = dataConfig.getRootPath();
|
||||
baseBean.writeLog("rootPath==" + rootPath);
|
||||
// 字段对照关系
|
||||
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)) {
|
||||
if (StringUtils.isNotBlank(rootPath)) {
|
||||
if (rootPath.contains("[*]")) {
|
||||
rootPath = rootPath.replace("[*]", "");
|
||||
JsonNode jsonNode = rootNode.at(rootPath);
|
||||
if (null == jsonNode) {
|
||||
throw new CustomizeRunTimeException("数据解析失败,未找到对应字段:[" + rootPath + "]");
|
||||
}
|
||||
if (!jsonNode.isArray()) {
|
||||
throw new CustomizeRunTimeException("数据解析失败,未找到对应字段集合:[" + rootPath + "]");
|
||||
}
|
||||
for (JsonNode node : jsonNode) {
|
||||
int billId = insertMainTable(node, mainTableName, relatedField, fieldDetailList, mainTableFieldMap);
|
||||
if (billId < 0) {
|
||||
continue;
|
||||
}
|
||||
dealDetailData(rootNode, billId, childDataConfigList, formFieldList);
|
||||
dealFileList(billId, fileList, mainTableName, false);
|
||||
}
|
||||
} else {
|
||||
JsonNode jsonNode = rootNode.at(rootPath);
|
||||
int billId = insertMainTable(jsonNode, mainTableName, relatedField, fieldDetailList, mainTableFieldMap);
|
||||
if (billId < 0) {
|
||||
continue;
|
||||
}
|
||||
dealDetailData(rootNode, billId, childDataConfigList, formFieldList);
|
||||
dealFileList(billId, fileList, mainTableName, false);
|
||||
}
|
||||
} else {
|
||||
int billId = insertMainTable(rootNode, mainTableName, relatedField, fieldDetailList, mainTableFieldMap);
|
||||
if (billId < 0) {
|
||||
continue;
|
||||
}
|
||||
dealDetailData(rootNode, billId, childDataConfigList, formFieldList);
|
||||
dealFileList(billId, fileList, mainTableName, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理明细表数据
|
||||
*
|
||||
* @param rootNode
|
||||
* @param mainId
|
||||
* @param childDataConfigList
|
||||
*/
|
||||
private void dealDetailData(JsonNode rootNode, int mainId, List<DataConfig> childDataConfigList, List<Formfield> formFieldList) throws Exception {
|
||||
if (CollectionUtils.isEmpty(childDataConfigList)) {
|
||||
return;
|
||||
}
|
||||
for (DataConfig childDataConfig : childDataConfigList) {
|
||||
String detailTableName = childDataConfig.getDetailTableName();
|
||||
Map<String, Formfield> detailTableFieldMap = formFieldList.stream().filter(item -> detailTableName.equals(item.getDetailtable())).collect(Collectors.toMap(Formfield::getFieldname, item -> item, (k1, k2) -> k1));
|
||||
|
||||
// 获取字段对照关系数据
|
||||
List<DataConfigDetail> fieldList = childDataConfig.getDetailList();
|
||||
List<FileConfig> fileList = childDataConfig.getFileList();
|
||||
// 明细表文件配置不为空的情况下,只处理文件,不做其他数据插入处理
|
||||
if (CollectionUtils.isNotEmpty(fileList)) {
|
||||
baseBean.writeLog("开始解析文件,写入明细数据");
|
||||
dealFileList(mainId, fileList, detailTableName, true);
|
||||
|
||||
} else {
|
||||
String rootPath = childDataConfig.getRootPath();
|
||||
if (StringUtils.isNotBlank(rootPath)) {
|
||||
if (rootPath.contains("[*]")) {
|
||||
rootPath = rootPath.replace("[*]", "");
|
||||
JsonNode jsonNode = rootNode.at(rootPath);
|
||||
if (null == jsonNode) {
|
||||
throw new CustomizeRunTimeException("数据解析失败,未找到对应字段:[" + rootPath + "]");
|
||||
}
|
||||
if (!jsonNode.isArray()) {
|
||||
throw new CustomizeRunTimeException("数据解析失败,未找到对应字段集合:[" + rootPath + "]");
|
||||
}
|
||||
for (JsonNode node : jsonNode) {
|
||||
insertDetailTable(node, detailTableName, mainId, fieldList, detailTableFieldMap);
|
||||
}
|
||||
} else {
|
||||
JsonNode jsonNode = rootNode.at(rootPath);
|
||||
insertDetailTable(jsonNode, detailTableName, mainId, fieldList, detailTableFieldMap);
|
||||
|
||||
}
|
||||
} else {
|
||||
insertDetailTable(rootNode, detailTableName, mainId, fieldList, detailTableFieldMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建主表数据,插入数据并返回数据ID
|
||||
*
|
||||
* @param jsonNode
|
||||
* @param mainTableName
|
||||
* @param relatedField
|
||||
* @param fieldList
|
||||
* @return
|
||||
*/
|
||||
private int insertMainTable(JsonNode jsonNode, String mainTableName, String relatedField, List<DataConfigDetail> fieldList, Map<String, Formfield> mainTableFieldMap) throws Exception {
|
||||
Map<String, Object> insertMap = new IgnoreCaseHashMap<>();
|
||||
|
||||
for (DataConfigDetail fieldDetail : fieldList) {
|
||||
String fieldName = fieldDetail.getFieldName();
|
||||
String path = fieldDetail.getPath();
|
||||
String condition = fieldDetail.getCondition();
|
||||
String convertSql = fieldDetail.getConvertSql();
|
||||
JsonNode atNode = jsonNode.at(path);
|
||||
if (null != atNode) {
|
||||
String value = atNode.asText();
|
||||
// 判断是否满足条件
|
||||
if (StringUtils.isNotBlank(condition) && !value.equals(condition)) {
|
||||
return -1;
|
||||
}
|
||||
// 根据字段类型 转换Value的值
|
||||
Formfield formfield = mainTableFieldMap.get(fieldName.toLowerCase());
|
||||
if (null == formfield) {
|
||||
continue;
|
||||
}
|
||||
Object reallyValue;
|
||||
if (StringUtils.isNotBlank(convertSql)) {
|
||||
reallyValue = FieldConvertUtil.executeConvertSql(convertSql, value);
|
||||
} else {
|
||||
reallyValue = FieldConvertUtil.getReallyValue(formfield, value);
|
||||
}
|
||||
insertMap.put(fieldName, reallyValue);
|
||||
}
|
||||
}
|
||||
|
||||
int size = insertMap.size();
|
||||
if (size == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (StringUtils.isNotBlank(relatedField)) {
|
||||
insertMap.put(relatedField, relatedFlowId);
|
||||
}
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
insertMap.put("modeuuid", uuid);
|
||||
int formModeId = ModeUtil.getModeIdByTableName(mainTableName);
|
||||
insertMap.put("formmodeid", formModeId);
|
||||
// 构建主表数据插入基本字段
|
||||
ModeUtil.buildModeInsertFields(insertMap, user.getUID());
|
||||
baseBean.writeLog("insertMainTable: " + JSON.toJSONString(insertMap));
|
||||
// 插入数据
|
||||
ModeUtil.insertData(insertMap, mainTableName);
|
||||
// 数据权限重构,返回数据ID
|
||||
return ModeUtil.refreshRight(uuid, mainTableName, formModeId, user.getUID());
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入明细表数据
|
||||
*
|
||||
* @param jsonNode
|
||||
* @param detailTableName
|
||||
* @param mainId
|
||||
* @param fieldList
|
||||
*/
|
||||
private void insertDetailTable(JsonNode jsonNode, String detailTableName, int mainId, List<DataConfigDetail> fieldList, Map<String, Formfield> mainTableFieldMap) throws Exception {
|
||||
Map<String, Object> insertMap = new IgnoreCaseHashMap<>();
|
||||
|
||||
for (DataConfigDetail fieldDetail : fieldList) {
|
||||
String fieldName = fieldDetail.getFieldName();
|
||||
String path = fieldDetail.getPath();
|
||||
String condition = fieldDetail.getCondition();
|
||||
String convertSql = fieldDetail.getConvertSql();
|
||||
JsonNode atNode = jsonNode.at(path);
|
||||
if (null != atNode) {
|
||||
String value = atNode.asText();
|
||||
// 判断是否满足条件
|
||||
if (StringUtils.isNotBlank(condition) && !value.equals(condition)) {
|
||||
return;
|
||||
}
|
||||
// 根据字段类型 转换Value的值
|
||||
Formfield formfield = mainTableFieldMap.get(fieldName.toLowerCase());
|
||||
if (null == formfield) {
|
||||
continue;
|
||||
}
|
||||
Object reallyValue;
|
||||
if (StringUtils.isNotBlank(convertSql)) {
|
||||
reallyValue = FieldConvertUtil.executeConvertSql(convertSql, value);
|
||||
} else {
|
||||
reallyValue = FieldConvertUtil.getReallyValue(formfield, value);
|
||||
}
|
||||
|
||||
insertMap.put(fieldName, reallyValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int size = insertMap.size();
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
insertMap.put("mainId", mainId);
|
||||
baseBean.writeLog("insertDetailTable: " + JSON.toJSONString(insertMap));
|
||||
// 插入数据
|
||||
ModeUtil.insertData(insertMap, detailTableName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理文件数据
|
||||
*
|
||||
* @param mainId
|
||||
* @param fileConfigList
|
||||
* @param tableName
|
||||
* @param isDetail
|
||||
* @throws Exception
|
||||
*/
|
||||
private void dealFileList(int mainId, List<FileConfig> fileConfigList, String tableName, boolean isDetail) throws Exception {
|
||||
Map<String, Object> dataMap = new IgnoreCaseHashMap<>();
|
||||
Map<String, Object> defaultDataMap = new IgnoreCaseHashMap<>();
|
||||
for (FileConfig fileConfig : fileConfigList) {
|
||||
String fieldName = fileConfig.getFieldName();
|
||||
// 是否更正文件
|
||||
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)) {
|
||||
baseBean.writeLog("根据fid未获取到数据,fileId==" + fileId);
|
||||
continue;
|
||||
}
|
||||
|
||||
Map<String, ResourceInfo> fileResourceMap = resourceInfoMap.get(isFilled);
|
||||
if (null == fileResourceMap || fileResourceMap.size() == 0) {
|
||||
baseBean.writeLog("根据文件类型未获取到数据,isFilled==" + isFilled);
|
||||
continue;
|
||||
}
|
||||
|
||||
List<String> fileRidList = applicationResources.stream().map(ApplicationResource::getRid).collect(Collectors.toList());
|
||||
List<Integer> docIds = new ArrayList<>();
|
||||
for (String rid : fileRidList) {
|
||||
ResourceInfo resourceInfo = fileResourceMap.get(rid);
|
||||
if (resourceInfo == null) {
|
||||
baseBean.writeLog("根据文件rid未获取到数据,rid==" + rid + ",isFilled==" + isFilled);
|
||||
continue;
|
||||
}
|
||||
String fileName = resourceInfo.getFileName();
|
||||
Integer imageFileId = imageFileMap.get(fileName);
|
||||
// 生成文档ID
|
||||
int docId = ModeUtil.createDocId(uploadCatalogue, imageFileId, user);
|
||||
docIds.add(docId);
|
||||
}
|
||||
dataMap.put(fieldName, StringUtils.join(docIds, ","));
|
||||
}
|
||||
|
||||
if (dataMap.size() == 0) {
|
||||
baseBean.writeLog("dataMap集合为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 合并默认值数据,如果文件集合为空,则不单独插入默认值
|
||||
dataMap.putAll(defaultDataMap);
|
||||
baseBean.writeLog("文件插入集合,dataMap==" + JSON.toJSONString(dataMap));
|
||||
// 根据主表、明细表,区分数据处理方式
|
||||
if (isDetail) {
|
||||
dataMap.put("mainid", mainId);
|
||||
ModeUtil.insertData(dataMap, tableName);
|
||||
} else {
|
||||
dataMap.put("id", mainId);
|
||||
// 根据ID更新主表数据
|
||||
ModeUtil.updateDataById(dataMap, tableName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取数据配置
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
private List<DataConfig> getDataConfig(String type) {
|
||||
// 获取离线包的先关配置
|
||||
List<DataConfig> dataConfigList = new ArrayList<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select * from uf_config_package where main_table is not null and source_type = ?", type);
|
||||
while (rs.next()) {
|
||||
DataConfig dataConfig = new DataConfig();
|
||||
dataConfig.setId(rs.getString("id"));
|
||||
dataConfig.setMainTableName(rs.getString("main_table"));
|
||||
dataConfig.setRelatedField(rs.getString("related_field"));
|
||||
dataConfig.setDetailTableName(rs.getString("detail_tables"));
|
||||
dataConfig.setRootPath(rs.getString("root_path"));
|
||||
// 获取字段对照关系数据
|
||||
List<DataConfigDetail> detailList = getDetailList(dataConfig.getId());
|
||||
dataConfig.setDetailList(detailList);
|
||||
dataConfig.setFileList(getFileList(dataConfig.getId()));
|
||||
// 获取明细表相关信息
|
||||
String detailTableName = dataConfig.getDetailTableName();
|
||||
if (StringUtils.isNotBlank(detailTableName)) {
|
||||
List<DataConfig> childDataConfig = getChildDataConfig(detailTableName, type);
|
||||
dataConfig.setChildDataConfig(childDataConfig);
|
||||
}
|
||||
|
||||
dataConfigList.add(dataConfig);
|
||||
}
|
||||
return dataConfigList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联的明细表配置
|
||||
*
|
||||
* @param detailTableName
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
private List<DataConfig> getChildDataConfig(String detailTableName, String type) {
|
||||
String[] detailNameArray = detailTableName.split(",");
|
||||
List<DataConfig> dataConfigList = new ArrayList<>();
|
||||
|
||||
for (String dtName : detailNameArray) {
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select * from " + QualificationApplicationServiceImpl.CONFIG_TABLE_NAME + " where main_table is null and detail_tables = ? and source_type = ?", dtName, type);
|
||||
while (rs.next()) {
|
||||
DataConfig dataConfig = new DataConfig();
|
||||
dataConfig.setId(rs.getString("id"));
|
||||
dataConfig.setDetailTableName(rs.getString("detail_tables"));
|
||||
dataConfig.setRootPath(rs.getString("root_path"));
|
||||
// 获取字段对照关系数据
|
||||
List<DataConfigDetail> detailList = getDetailList(dataConfig.getId());
|
||||
dataConfig.setDetailList(detailList);
|
||||
dataConfig.setFileList(getFileList(dataConfig.getId()));
|
||||
dataConfigList.add(dataConfig);
|
||||
}
|
||||
}
|
||||
return dataConfigList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取字段对照关系
|
||||
*
|
||||
* @param mainId
|
||||
* @return
|
||||
*/
|
||||
private List<DataConfigDetail> getDetailList(String mainId) {
|
||||
List<DataConfigDetail> detailList = new ArrayList<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select * from " + QualificationApplicationServiceImpl.CONFIG_DETAIL_TABLE_NAME + " where mainId = ?", mainId);
|
||||
while (rs.next()) {
|
||||
detailList.add(DataConfigDetail.builder()
|
||||
.fieldName(rs.getString("field_name"))
|
||||
.path(rs.getString("config_path"))
|
||||
.condition(rs.getString("conditions"))
|
||||
.convertSql(rs.getString("convert_sql"))
|
||||
.build());
|
||||
}
|
||||
return detailList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件对照关系
|
||||
*
|
||||
* @param mainId
|
||||
* @return
|
||||
*/
|
||||
private List<FileConfig> getFileList(String mainId) {
|
||||
List<FileConfig> fileList = new ArrayList<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select * from " + QualificationApplicationServiceImpl.FILE_DETAIL_TABLE_NAME + " where mainId = ?", mainId);
|
||||
while (rs.next()) {
|
||||
fileList.add(FileConfig.builder()
|
||||
.fieldName(rs.getString("field_name"))
|
||||
.fileId(rs.getString("file_id"))
|
||||
.isFilled(rs.getString("file_type"))
|
||||
.fixedValue(rs.getString("fixed_value"))
|
||||
.attachments(rs.getString("attachments"))
|
||||
.build());
|
||||
}
|
||||
return fileList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取JSON文件中applicationResourceList数组
|
||||
*
|
||||
* @param rootNode
|
||||
* @return
|
||||
*/
|
||||
private List<ApplicationResource> getApplicationResourceList(JsonNode rootNode) {
|
||||
List<ApplicationResource> applicationResourceList = new ArrayList<>();
|
||||
JsonNode applicationResourceListNode = rootNode.at("/applicationResourceList");
|
||||
if (applicationResourceListNode != null && applicationResourceListNode.isArray()) {
|
||||
for (JsonNode jsonNode : applicationResourceListNode) {
|
||||
String id = jsonNode.at("/id").asText();
|
||||
String aid = jsonNode.at("/aid").asText();
|
||||
String fid = jsonNode.at("/fid").asText();
|
||||
String rid = jsonNode.at("/rid").asText();
|
||||
String createdTime = jsonNode.at("/createdTime").asText();
|
||||
String isDelete = jsonNode.at("/isDelete").asText();
|
||||
applicationResourceList.add(ApplicationResource.builder().id(id).aid(aid).fid(fid).rid(rid).createdTime(createdTime).isDelete(isDelete).build());
|
||||
}
|
||||
}
|
||||
return applicationResourceList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取JSON文件中resourceInfoList数组
|
||||
*
|
||||
* @param rootNode
|
||||
* @return
|
||||
*/
|
||||
private List<ResourceInfo> getResourceInfoList(JsonNode rootNode) {
|
||||
List<ResourceInfo> resourceInfoList = new ArrayList<>();
|
||||
JsonNode resourceInfoListNode = rootNode.at("/resourceInfoList");
|
||||
if (resourceInfoListNode != null && resourceInfoListNode.isArray()) {
|
||||
for (JsonNode jsonNode : resourceInfoListNode) {
|
||||
String id = jsonNode.at("/id").asText();
|
||||
String fileName = jsonNode.at("/fileName").asText();
|
||||
String filePath = jsonNode.at("/filePath").asText();
|
||||
String fileSuffix = jsonNode.at("/fileSuffix").asText();
|
||||
String virtualPath = jsonNode.at("/virtualPath").asText();
|
||||
String createdTime = jsonNode.at("/createdTime").asText();
|
||||
String updatedTime = jsonNode.at("/updatedTime").asText();
|
||||
String isDelete = jsonNode.at("/isDelete").asText();
|
||||
resourceInfoList.add(ResourceInfo.builder().id(id).fileName(fileName).filePath(filePath).fileSuffix(fileSuffix).virtualPath(virtualPath).createdTime(createdTime).updatedTime(updatedTime).isDelete(isDelete).build());
|
||||
}
|
||||
}
|
||||
return resourceInfoList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取JSON文件内容
|
||||
*
|
||||
* @param imageFieldId
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
private static JsonNode parseJsonContent(Integer imageFieldId) throws IOException {
|
||||
ImageFileManager manager = new ImageFileManager();
|
||||
manager.getImageFileInfoById(imageFieldId);
|
||||
InputStream inputStream = manager.getInputStream();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
return mapper.readTree(inputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件 返回imageFileId
|
||||
*
|
||||
* @param zipFile
|
||||
* @param header
|
||||
* @return
|
||||
*/
|
||||
private int generateImageFileId(ZipFile zipFile, FileHeader header, String fileName) {
|
||||
try (InputStream is = zipFile.getInputStream(header)) {
|
||||
return ModeUtil.generateImageFileId(is, fileName);
|
||||
} catch (Exception e) {
|
||||
throw new CustomizeRunTimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建反写表单的字段
|
||||
*
|
||||
* @param rootNode
|
||||
*/
|
||||
private void buildFormFields(JsonNode rootNode) {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
//
|
||||
processQualification(rootNode, "typeIntegrateList",
|
||||
ApplicationCategory.CLASSIFIED_INFO_SYSTEM_INTEGRATION_QUALIFICATION, data, IntegrateCategory::getValue);
|
||||
|
||||
processQualification(rootNode, "typePrintList",
|
||||
ApplicationCategory.NATIONAL_SECRET_CARRIER_PRINTING_QUALIFICATION, data, PrintCategory::getValue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提取资格类型
|
||||
*
|
||||
* @param rootNode
|
||||
* @param nodeName
|
||||
* @param category
|
||||
* @param data
|
||||
* @param resolver
|
||||
*/
|
||||
private void processQualification(JsonNode rootNode, String nodeName,
|
||||
ApplicationCategory category, Map<String, Object> data, Function<String, ? extends Enum<? extends CategoryValue>> resolver) {
|
||||
JsonNode typeList = rootNode.get(nodeName);
|
||||
if (isValidArrayNode(typeList)) {
|
||||
data.put("category_name", category.getName());
|
||||
data.put("category_value", category.getValue());
|
||||
|
||||
JsonNode applicationInfo = rootNode.get("applicationInfo");
|
||||
JsonNode applicationLevel = applicationInfo.get("applicationLevel");
|
||||
JsonNode companyName = applicationInfo.get("companyName");
|
||||
// 集成/印制级别
|
||||
data.put("level", applicationLevel.asInt());
|
||||
data.put("companyName", companyName.asText());
|
||||
|
||||
JsonNode applicationQualification = applicationInfo.get("applicationQualification");
|
||||
String values = extractQualificationValues(applicationQualification, resolver);
|
||||
data.put("types", values);
|
||||
returnMap.put("data", data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断节点是否存在
|
||||
*
|
||||
* @param node
|
||||
* @return
|
||||
*/
|
||||
private boolean isValidArrayNode(JsonNode node) {
|
||||
return !node.isMissingNode() && node.isArray() && !node.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为资格类型为对应的值
|
||||
*
|
||||
* @param applicationQualification
|
||||
* @param resolver
|
||||
* @return
|
||||
*/
|
||||
private String extractQualificationValues(JsonNode applicationQualification, Function<String, ? extends Enum<? extends CategoryValue>> resolver) {
|
||||
String asText = applicationQualification.asText();
|
||||
|
||||
return Arrays.stream(asText.split("、"))
|
||||
.map(resolver)
|
||||
.filter(Objects::nonNull)
|
||||
.map(category -> ((CategoryValue) category).getSelectValue())
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,20 @@
|
|||
package com.engine.secret.service.impl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.secret.entity.unpack.*;
|
||||
import com.engine.secret.enums.ApplicationCategory;
|
||||
import com.engine.secret.enums.CategoryValue;
|
||||
import com.engine.secret.enums.IntegrateCategory;
|
||||
import com.engine.secret.enums.PrintCategory;
|
||||
import com.engine.secret.exception.CustomizeRunTimeException;
|
||||
import com.engine.secret.service.QualificationApplicationService;
|
||||
import com.engine.secret.util.ConfigUtil;
|
||||
import com.engine.secret.util.FieldConvertUtil;
|
||||
import com.engine.secret.util.ModeUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.wbi.util.Util;
|
||||
import com.weaver.formmodel.data.model.Formfield;
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
import net.lingala.zip4j.model.FileHeader;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.docs.docs.DocImageManager;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.formmode.IgnoreCaseHashMap;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.GCONST;
|
||||
|
||||
|
|
@ -36,9 +25,9 @@ import java.nio.file.Files;
|
|||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
|
|
@ -47,28 +36,21 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public class QualificationApplicationServiceImpl extends Service implements QualificationApplicationService {
|
||||
|
||||
private static int uploadCatalogue;
|
||||
|
||||
private static final String CONFIG_TABLE_NAME = "uf_config_package";
|
||||
private static final String CONFIG_DETAIL_TABLE_NAME = "uf_config_package_dt1";
|
||||
private static final String FILE_DETAIL_TABLE_NAME = "uf_config_package_dt2";
|
||||
public static final String CONFIG_TABLE_NAME = "uf_config_package";
|
||||
public static final String CONFIG_DETAIL_TABLE_NAME = "uf_config_package_dt1";
|
||||
public static final String FILE_DETAIL_TABLE_NAME = "uf_config_package_dt2";
|
||||
|
||||
BaseBean baseBean = new BaseBean();
|
||||
|
||||
Map<String, List<ApplicationResource>> applicationResourceMap;
|
||||
|
||||
Map<String, Map<String, ResourceInfo>> resourceInfoMap;
|
||||
|
||||
Map<String, Integer> imageFileMap;
|
||||
|
||||
String relatedFlowId;
|
||||
|
||||
Map<String, Object> returnMap = new HashMap<>();
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> parsingFiles(Map<String, Object> param) {
|
||||
try {
|
||||
Map<String, Object> returnMap = new HashMap<>();
|
||||
|
||||
String docId = Util.null2String(param.get("docId"));
|
||||
String requestId = Util.null2String(param.get("requestId"));
|
||||
if (StringUtils.isBlank(docId)) {
|
||||
|
|
@ -81,7 +63,6 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
}
|
||||
|
||||
baseBean.writeLog("requestId==" + requestId);
|
||||
relatedFlowId = requestId;
|
||||
|
||||
// docId 转为换imageFileId
|
||||
DocImageManager imgManger = new DocImageManager();
|
||||
|
|
@ -99,12 +80,6 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
String unzipPwd = ConfigUtil.getConfig("UNZIP_PWD");
|
||||
baseBean.writeLog("unzipPwd==" + unzipPwd);
|
||||
|
||||
String uploadCatalogueStr = ConfigUtil.getConfig("UPLOAD_CATALOGUE");
|
||||
if (StringUtils.isBlank(uploadCatalogueStr)) {
|
||||
throw new CustomizeRunTimeException("未获取到解析文件目录设置,检查配置[uf_config]");
|
||||
}
|
||||
uploadCatalogue = Convert.toInt(uploadCatalogueStr, -1);
|
||||
baseBean.writeLog("uploadCatalogue==" + uploadCatalogue);
|
||||
|
||||
// 根据文件id获取文件流
|
||||
ImageFileManager manager = new ImageFileManager();
|
||||
|
|
@ -120,10 +95,11 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
|
||||
//解压文件,处理压缩包
|
||||
baseBean.writeLog("开始解压文件,处理压缩包");
|
||||
unzipWithPassword(tempZipFile, Paths.get("output"), unzipPwd);
|
||||
returnMap = unzipWithPassword(tempZipFile, Paths.get("output"), unzipPwd, requestId);
|
||||
baseBean.writeLog("压缩包处理完成");
|
||||
return returnMap;
|
||||
} catch (Exception e) {
|
||||
baseBean.writeLog(e);
|
||||
throw new CustomizeRunTimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
|
@ -135,7 +111,7 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
* @param outputDir
|
||||
* @param password
|
||||
*/
|
||||
private void unzipWithPassword(Path zipFilePath, Path outputDir, String password) {
|
||||
private Map<String, Object> unzipWithPassword(Path zipFilePath, Path outputDir, String password, String requestId) {
|
||||
try {
|
||||
ZipFile zipFile = new ZipFile(zipFilePath.toFile());
|
||||
if (zipFile.isEncrypted()) {
|
||||
|
|
@ -177,9 +153,11 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
if (dataJsonImageId != null && dataJsonImageId > 0) {
|
||||
// 离线端方式
|
||||
JsonNode rootNode = parseJsonContent(dataJsonImageId);
|
||||
buildFormFields(rootNode);
|
||||
offline(rootNode);
|
||||
//buildFormFields(rootNode);
|
||||
//offline(rootNode);
|
||||
return ServiceUtil.getService(OfflineZipUnpackServiceImpl.class, user).registerAcceptance(requestId, rootNode, imageFileMap);
|
||||
}
|
||||
return new HashMap<>();
|
||||
|
||||
// TODO 兼容其他方式
|
||||
|
||||
|
|
@ -200,492 +178,6 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 离线解析方式
|
||||
*
|
||||
* @param rootNode
|
||||
* @throws JsonProcessingException
|
||||
*/
|
||||
private void offline(JsonNode rootNode) throws Exception {
|
||||
// 解析基本信息并反写到流程表单
|
||||
|
||||
|
||||
List<DataConfig> dataConfigList = getDataConfig("0");
|
||||
baseBean.writeLog("dataConfigList==" + JSON.toJSONString(dataConfigList));
|
||||
|
||||
// 处理文件数据
|
||||
List<ApplicationResource> applicationResourceList = getApplicationResourceList(rootNode);
|
||||
// key是fid 集合是该同一个fid下的文件ID信息
|
||||
applicationResourceMap = applicationResourceList.stream().collect(Collectors.groupingBy(ApplicationResource::getFid));
|
||||
baseBean.writeLog("applicationResourceMap==" + JSON.toJSONString(applicationResourceMap));
|
||||
List<ResourceInfo> resourceInfoList = getResourceInfoList(rootNode);
|
||||
// key是fid 集合是该同一个fid下的文件ID信息
|
||||
resourceInfoMap = resourceInfoList.stream().collect(Collectors.groupingBy(ResourceInfo::getVirtualPath, Collectors.toMap(ResourceInfo::getId, item -> item)));
|
||||
baseBean.writeLog("resourceInfoMap==" + JSON.toJSONString(resourceInfoMap));
|
||||
|
||||
|
||||
if (CollectionUtils.isNotEmpty(dataConfigList)) {
|
||||
// 遍历配置,读取配置文件,并插入数据
|
||||
for (DataConfig dataConfig : dataConfigList) {
|
||||
String mainTableName = dataConfig.getMainTableName();
|
||||
String relatedField = dataConfig.getRelatedField();
|
||||
String rootPath = dataConfig.getRootPath();
|
||||
baseBean.writeLog("rootPath==" + rootPath);
|
||||
// 字段对照关系
|
||||
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)) {
|
||||
if (StringUtils.isNotBlank(rootPath)) {
|
||||
if (rootPath.contains("[*]")) {
|
||||
rootPath = rootPath.replace("[*]", "");
|
||||
JsonNode jsonNode = rootNode.at(rootPath);
|
||||
if (null == jsonNode) {
|
||||
throw new CustomizeRunTimeException("数据解析失败,未找到对应字段:[" + rootPath + "]");
|
||||
}
|
||||
if (!jsonNode.isArray()) {
|
||||
throw new CustomizeRunTimeException("数据解析失败,未找到对应字段集合:[" + rootPath + "]");
|
||||
}
|
||||
for (JsonNode node : jsonNode) {
|
||||
int billId = insertMainTable(node, mainTableName, relatedField, fieldDetailList, mainTableFieldMap);
|
||||
if (billId < 0) {
|
||||
continue;
|
||||
}
|
||||
dealDetailData(rootNode, billId, childDataConfigList, formFieldList);
|
||||
dealFileList(billId, fileList, mainTableName, false);
|
||||
}
|
||||
} else {
|
||||
JsonNode jsonNode = rootNode.at(rootPath);
|
||||
int billId = insertMainTable(jsonNode, mainTableName, relatedField, fieldDetailList, mainTableFieldMap);
|
||||
if (billId < 0) {
|
||||
continue;
|
||||
}
|
||||
dealDetailData(rootNode, billId, childDataConfigList, formFieldList);
|
||||
dealFileList(billId, fileList, mainTableName, false);
|
||||
}
|
||||
} else {
|
||||
int billId = insertMainTable(rootNode, mainTableName, relatedField, fieldDetailList, mainTableFieldMap);
|
||||
if (billId < 0) {
|
||||
continue;
|
||||
}
|
||||
dealDetailData(rootNode, billId, childDataConfigList, formFieldList);
|
||||
dealFileList(billId, fileList, mainTableName, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理明细表数据
|
||||
*
|
||||
* @param rootNode
|
||||
* @param mainId
|
||||
* @param childDataConfigList
|
||||
*/
|
||||
private void dealDetailData(JsonNode rootNode, int mainId, List<DataConfig> childDataConfigList, List<Formfield> formFieldList) throws Exception {
|
||||
if (CollectionUtils.isEmpty(childDataConfigList)) {
|
||||
return;
|
||||
}
|
||||
for (DataConfig childDataConfig : childDataConfigList) {
|
||||
String detailTableName = childDataConfig.getDetailTableName();
|
||||
Map<String, Formfield> detailTableFieldMap = formFieldList.stream().filter(item -> detailTableName.equals(item.getDetailtable())).collect(Collectors.toMap(Formfield::getFieldname, item -> item, (k1, k2) -> k1));
|
||||
|
||||
// 获取字段对照关系数据
|
||||
List<DataConfigDetail> fieldList = childDataConfig.getDetailList();
|
||||
List<FileConfig> fileList = childDataConfig.getFileList();
|
||||
// 明细表文件配置不为空的情况下,只处理文件,不做其他数据插入处理
|
||||
if (CollectionUtils.isNotEmpty(fileList)) {
|
||||
baseBean.writeLog("开始解析文件,写入明细数据");
|
||||
dealFileList(mainId, fileList, detailTableName, true);
|
||||
|
||||
} else {
|
||||
String rootPath = childDataConfig.getRootPath();
|
||||
if (StringUtils.isNotBlank(rootPath)) {
|
||||
if (rootPath.contains("[*]")) {
|
||||
rootPath = rootPath.replace("[*]", "");
|
||||
JsonNode jsonNode = rootNode.at(rootPath);
|
||||
if (null == jsonNode) {
|
||||
throw new CustomizeRunTimeException("数据解析失败,未找到对应字段:[" + rootPath + "]");
|
||||
}
|
||||
if (!jsonNode.isArray()) {
|
||||
throw new CustomizeRunTimeException("数据解析失败,未找到对应字段集合:[" + rootPath + "]");
|
||||
}
|
||||
for (JsonNode node : jsonNode) {
|
||||
insertDetailTable(node, detailTableName, mainId, fieldList, detailTableFieldMap);
|
||||
}
|
||||
} else {
|
||||
JsonNode jsonNode = rootNode.at(rootPath);
|
||||
insertDetailTable(jsonNode, detailTableName, mainId, fieldList, detailTableFieldMap);
|
||||
|
||||
}
|
||||
} else {
|
||||
insertDetailTable(rootNode, detailTableName, mainId, fieldList, detailTableFieldMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建主表数据,插入数据并返回数据ID
|
||||
*
|
||||
* @param jsonNode
|
||||
* @param mainTableName
|
||||
* @param relatedField
|
||||
* @param fieldList
|
||||
* @return
|
||||
*/
|
||||
private int insertMainTable(JsonNode jsonNode, String mainTableName, String relatedField, List<DataConfigDetail> fieldList, Map<String, Formfield> mainTableFieldMap) throws Exception {
|
||||
Map<String, Object> insertMap = new IgnoreCaseHashMap<>();
|
||||
|
||||
for (DataConfigDetail fieldDetail : fieldList) {
|
||||
String fieldName = fieldDetail.getFieldName();
|
||||
String path = fieldDetail.getPath();
|
||||
String condition = fieldDetail.getCondition();
|
||||
String convertSql = fieldDetail.getConvertSql();
|
||||
JsonNode atNode = jsonNode.at(path);
|
||||
if (null != atNode) {
|
||||
String value = atNode.asText();
|
||||
// 判断是否满足条件
|
||||
if (StringUtils.isNotBlank(condition) && !value.equals(condition)) {
|
||||
return -1;
|
||||
}
|
||||
// 根据字段类型 转换Value的值
|
||||
Formfield formfield = mainTableFieldMap.get(fieldName.toLowerCase());
|
||||
if (null == formfield) {
|
||||
continue;
|
||||
}
|
||||
Object reallyValue;
|
||||
if (StringUtils.isNotBlank(convertSql)) {
|
||||
reallyValue = FieldConvertUtil.executeConvertSql(convertSql, value);
|
||||
} else {
|
||||
reallyValue = FieldConvertUtil.getReallyValue(formfield, value);
|
||||
}
|
||||
insertMap.put(fieldName, reallyValue);
|
||||
}
|
||||
}
|
||||
|
||||
int size = insertMap.size();
|
||||
if (size == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (StringUtils.isNotBlank(relatedField)) {
|
||||
insertMap.put(relatedField, relatedFlowId);
|
||||
}
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
insertMap.put("modeuuid", uuid);
|
||||
int formModeId = ModeUtil.getModeIdByTableName(mainTableName);
|
||||
insertMap.put("formmodeid", formModeId);
|
||||
// 构建主表数据插入基本字段
|
||||
ModeUtil.buildModeInsertFields(insertMap, user.getUID());
|
||||
baseBean.writeLog("insertMainTable: " + JSON.toJSONString(insertMap));
|
||||
// 插入数据
|
||||
ModeUtil.insertData(insertMap, mainTableName);
|
||||
// 数据权限重构,返回数据ID
|
||||
return ModeUtil.refreshRight(uuid, mainTableName, formModeId, user.getUID());
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入明细表数据
|
||||
*
|
||||
* @param jsonNode
|
||||
* @param detailTableName
|
||||
* @param mainId
|
||||
* @param fieldList
|
||||
*/
|
||||
private void insertDetailTable(JsonNode jsonNode, String detailTableName, int mainId, List<DataConfigDetail> fieldList, Map<String, Formfield> mainTableFieldMap) throws Exception {
|
||||
Map<String, Object> insertMap = new IgnoreCaseHashMap<>();
|
||||
|
||||
for (DataConfigDetail fieldDetail : fieldList) {
|
||||
String fieldName = fieldDetail.getFieldName();
|
||||
String path = fieldDetail.getPath();
|
||||
String condition = fieldDetail.getCondition();
|
||||
String convertSql = fieldDetail.getConvertSql();
|
||||
JsonNode atNode = jsonNode.at(path);
|
||||
if (null != atNode) {
|
||||
String value = atNode.asText();
|
||||
// 判断是否满足条件
|
||||
if (StringUtils.isNotBlank(condition) && !value.equals(condition)) {
|
||||
return;
|
||||
}
|
||||
// 根据字段类型 转换Value的值
|
||||
Formfield formfield = mainTableFieldMap.get(fieldName.toLowerCase());
|
||||
if (null == formfield) {
|
||||
continue;
|
||||
}
|
||||
Object reallyValue;
|
||||
if (StringUtils.isNotBlank(convertSql)) {
|
||||
reallyValue = FieldConvertUtil.executeConvertSql(convertSql, value);
|
||||
} else {
|
||||
reallyValue = FieldConvertUtil.getReallyValue(formfield, value);
|
||||
}
|
||||
|
||||
insertMap.put(fieldName, reallyValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int size = insertMap.size();
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
insertMap.put("mainId", mainId);
|
||||
baseBean.writeLog("insertDetailTable: " + JSON.toJSONString(insertMap));
|
||||
// 插入数据
|
||||
ModeUtil.insertData(insertMap, detailTableName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理文件数据
|
||||
*
|
||||
* @param mainId
|
||||
* @param fileConfigList
|
||||
* @param tableName
|
||||
* @param isDetail
|
||||
* @throws Exception
|
||||
*/
|
||||
private void dealFileList(int mainId, List<FileConfig> fileConfigList, String tableName, boolean isDetail) throws Exception {
|
||||
Map<String, Object> dataMap = new IgnoreCaseHashMap<>();
|
||||
Map<String, Object> defaultDataMap = new IgnoreCaseHashMap<>();
|
||||
for (FileConfig fileConfig : fileConfigList) {
|
||||
String fieldName = fileConfig.getFieldName();
|
||||
// 是否更正文件
|
||||
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)) {
|
||||
baseBean.writeLog("根据fid未获取到数据,fileId==" + fileId);
|
||||
continue;
|
||||
}
|
||||
|
||||
Map<String, ResourceInfo> fileResourceMap = resourceInfoMap.get(isFilled);
|
||||
if (null == fileResourceMap || fileResourceMap.size() == 0) {
|
||||
baseBean.writeLog("根据文件类型未获取到数据,isFilled==" + isFilled);
|
||||
continue;
|
||||
}
|
||||
|
||||
List<String> fileRidList = applicationResources.stream().map(ApplicationResource::getRid).collect(Collectors.toList());
|
||||
List<Integer> docIds = new ArrayList<>();
|
||||
for (String rid : fileRidList) {
|
||||
ResourceInfo resourceInfo = fileResourceMap.get(rid);
|
||||
if (resourceInfo == null) {
|
||||
baseBean.writeLog("根据文件rid未获取到数据,rid==" + rid + ",isFilled==" + isFilled);
|
||||
continue;
|
||||
}
|
||||
String fileName = resourceInfo.getFileName();
|
||||
Integer imageFileId = imageFileMap.get(fileName);
|
||||
// 生成文档ID
|
||||
int docId = ModeUtil.createDocId(uploadCatalogue, imageFileId, user);
|
||||
docIds.add(docId);
|
||||
}
|
||||
dataMap.put(fieldName, StringUtils.join(docIds, ","));
|
||||
}
|
||||
|
||||
if (dataMap.size() == 0) {
|
||||
baseBean.writeLog("dataMap集合为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 合并默认值数据,如果文件集合为空,则不单独插入默认值
|
||||
dataMap.putAll(defaultDataMap);
|
||||
baseBean.writeLog("文件插入集合,dataMap==" + JSON.toJSONString(dataMap));
|
||||
// 根据主表、明细表,区分数据处理方式
|
||||
if (isDetail) {
|
||||
dataMap.put("mainid", mainId);
|
||||
ModeUtil.insertData(dataMap, tableName);
|
||||
} else {
|
||||
dataMap.put("id", mainId);
|
||||
// 根据ID更新主表数据
|
||||
ModeUtil.updateDataById(dataMap, tableName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取数据配置
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
private List<DataConfig> getDataConfig(String type) {
|
||||
// 获取离线包的先关配置
|
||||
List<DataConfig> dataConfigList = new ArrayList<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select * from uf_config_package where main_table is not null and source_type = ?", type);
|
||||
while (rs.next()) {
|
||||
DataConfig dataConfig = new DataConfig();
|
||||
dataConfig.setId(rs.getString("id"));
|
||||
dataConfig.setMainTableName(rs.getString("main_table"));
|
||||
dataConfig.setRelatedField(rs.getString("related_field"));
|
||||
dataConfig.setDetailTableName(rs.getString("detail_tables"));
|
||||
dataConfig.setRootPath(rs.getString("root_path"));
|
||||
// 获取字段对照关系数据
|
||||
List<DataConfigDetail> detailList = getDetailList(dataConfig.getId());
|
||||
dataConfig.setDetailList(detailList);
|
||||
dataConfig.setFileList(getFileList(dataConfig.getId()));
|
||||
// 获取明细表相关信息
|
||||
String detailTableName = dataConfig.getDetailTableName();
|
||||
if (StringUtils.isNotBlank(detailTableName)) {
|
||||
List<DataConfig> childDataConfig = getChildDataConfig(detailTableName, type);
|
||||
dataConfig.setChildDataConfig(childDataConfig);
|
||||
}
|
||||
|
||||
dataConfigList.add(dataConfig);
|
||||
}
|
||||
return dataConfigList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联的明细表配置
|
||||
*
|
||||
* @param detailTableName
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
private List<DataConfig> getChildDataConfig(String detailTableName, String type) {
|
||||
String[] detailNameArray = detailTableName.split(",");
|
||||
List<DataConfig> dataConfigList = new ArrayList<>();
|
||||
|
||||
for (String dtName : detailNameArray) {
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select * from " + CONFIG_TABLE_NAME + " where main_table is null and detail_tables = ? and source_type = ?", dtName, type);
|
||||
while (rs.next()) {
|
||||
DataConfig dataConfig = new DataConfig();
|
||||
dataConfig.setId(rs.getString("id"));
|
||||
dataConfig.setDetailTableName(rs.getString("detail_tables"));
|
||||
dataConfig.setRootPath(rs.getString("root_path"));
|
||||
// 获取字段对照关系数据
|
||||
List<DataConfigDetail> detailList = getDetailList(dataConfig.getId());
|
||||
dataConfig.setDetailList(detailList);
|
||||
dataConfig.setFileList(getFileList(dataConfig.getId()));
|
||||
dataConfigList.add(dataConfig);
|
||||
}
|
||||
}
|
||||
return dataConfigList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取字段对照关系
|
||||
*
|
||||
* @param mainId
|
||||
* @return
|
||||
*/
|
||||
private List<DataConfigDetail> getDetailList(String mainId) {
|
||||
List<DataConfigDetail> detailList = new ArrayList<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select * from " + CONFIG_DETAIL_TABLE_NAME + " where mainId = ?", mainId);
|
||||
while (rs.next()) {
|
||||
detailList.add(DataConfigDetail.builder()
|
||||
.fieldName(rs.getString("field_name"))
|
||||
.path(rs.getString("config_path"))
|
||||
.condition(rs.getString("conditions"))
|
||||
.convertSql(rs.getString("convert_sql"))
|
||||
.build());
|
||||
}
|
||||
return detailList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件对照关系
|
||||
*
|
||||
* @param mainId
|
||||
* @return
|
||||
*/
|
||||
private List<FileConfig> getFileList(String mainId) {
|
||||
List<FileConfig> fileList = new ArrayList<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select * from " + FILE_DETAIL_TABLE_NAME + " where mainId = ?", mainId);
|
||||
while (rs.next()) {
|
||||
fileList.add(FileConfig.builder()
|
||||
.fieldName(rs.getString("field_name"))
|
||||
.fileId(rs.getString("file_id"))
|
||||
.isFilled(rs.getString("file_type"))
|
||||
.fixedValue(rs.getString("fixed_value"))
|
||||
.attachments(rs.getString("attachments"))
|
||||
.build());
|
||||
}
|
||||
return fileList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取JSON文件中applicationResourceList数组
|
||||
*
|
||||
* @param rootNode
|
||||
* @return
|
||||
*/
|
||||
private List<ApplicationResource> getApplicationResourceList(JsonNode rootNode) {
|
||||
List<ApplicationResource> applicationResourceList = new ArrayList<>();
|
||||
JsonNode applicationResourceListNode = rootNode.at("/applicationResourceList");
|
||||
if (applicationResourceListNode != null && applicationResourceListNode.isArray()) {
|
||||
for (JsonNode jsonNode : applicationResourceListNode) {
|
||||
String id = jsonNode.at("/id").asText();
|
||||
String aid = jsonNode.at("/aid").asText();
|
||||
String fid = jsonNode.at("/fid").asText();
|
||||
String rid = jsonNode.at("/rid").asText();
|
||||
String createdTime = jsonNode.at("/createdTime").asText();
|
||||
String isDelete = jsonNode.at("/isDelete").asText();
|
||||
applicationResourceList.add(ApplicationResource.builder().id(id).aid(aid).fid(fid).rid(rid).createdTime(createdTime).isDelete(isDelete).build());
|
||||
}
|
||||
}
|
||||
return applicationResourceList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取JSON文件中resourceInfoList数组
|
||||
*
|
||||
* @param rootNode
|
||||
* @return
|
||||
*/
|
||||
private List<ResourceInfo> getResourceInfoList(JsonNode rootNode) {
|
||||
List<ResourceInfo> resourceInfoList = new ArrayList<>();
|
||||
JsonNode resourceInfoListNode = rootNode.at("/resourceInfoList");
|
||||
if (resourceInfoListNode != null && resourceInfoListNode.isArray()) {
|
||||
for (JsonNode jsonNode : resourceInfoListNode) {
|
||||
String id = jsonNode.at("/id").asText();
|
||||
String fileName = jsonNode.at("/fileName").asText();
|
||||
String filePath = jsonNode.at("/filePath").asText();
|
||||
String fileSuffix = jsonNode.at("/fileSuffix").asText();
|
||||
String virtualPath = jsonNode.at("/virtualPath").asText();
|
||||
String createdTime = jsonNode.at("/createdTime").asText();
|
||||
String updatedTime = jsonNode.at("/updatedTime").asText();
|
||||
String isDelete = jsonNode.at("/isDelete").asText();
|
||||
resourceInfoList.add(ResourceInfo.builder().id(id).fileName(fileName).filePath(filePath).fileSuffix(fileSuffix).virtualPath(virtualPath).createdTime(createdTime).updatedTime(updatedTime).isDelete(isDelete).build());
|
||||
}
|
||||
}
|
||||
return resourceInfoList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取JSON文件内容
|
||||
|
|
@ -717,78 +209,4 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建反写表单的字段
|
||||
*
|
||||
* @param rootNode
|
||||
*/
|
||||
private void buildFormFields(JsonNode rootNode) {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
//
|
||||
processQualification(rootNode, "typeIntegrateList",
|
||||
ApplicationCategory.CLASSIFIED_INFO_SYSTEM_INTEGRATION_QUALIFICATION, data, IntegrateCategory::getValue);
|
||||
|
||||
processQualification(rootNode, "typePrintList",
|
||||
ApplicationCategory.NATIONAL_SECRET_CARRIER_PRINTING_QUALIFICATION, data, PrintCategory::getValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取资格类型
|
||||
*
|
||||
* @param rootNode
|
||||
* @param nodeName
|
||||
* @param category
|
||||
* @param data
|
||||
* @param resolver
|
||||
*/
|
||||
private void processQualification(JsonNode rootNode, String nodeName,
|
||||
ApplicationCategory category, Map<String, Object> data, Function<String, ? extends Enum<? extends CategoryValue>> resolver) {
|
||||
JsonNode typeList = rootNode.get(nodeName);
|
||||
if (isValidArrayNode(typeList)) {
|
||||
data.put("category_name", category.getName());
|
||||
data.put("category_value", category.getValue());
|
||||
|
||||
JsonNode applicationInfo = rootNode.get("applicationInfo");
|
||||
JsonNode applicationLevel = applicationInfo.get("applicationLevel");
|
||||
JsonNode companyName = applicationInfo.get("companyName");
|
||||
// 集成/印制级别
|
||||
data.put("level", applicationLevel.asInt());
|
||||
data.put("companyName", companyName.asText());
|
||||
|
||||
JsonNode applicationQualification = applicationInfo.get("applicationQualification");
|
||||
String values = extractQualificationValues(applicationQualification, resolver);
|
||||
data.put("types", values);
|
||||
returnMap.put("data", data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断节点是否存在
|
||||
*
|
||||
* @param node
|
||||
* @return
|
||||
*/
|
||||
private boolean isValidArrayNode(JsonNode node) {
|
||||
return !node.isMissingNode() && node.isArray() && !node.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为资格类型为对应的值
|
||||
*
|
||||
* @param applicationQualification
|
||||
* @param resolver
|
||||
* @return
|
||||
*/
|
||||
private String extractQualificationValues(JsonNode applicationQualification, Function<String, ? extends Enum<? extends CategoryValue>> resolver) {
|
||||
String asText = applicationQualification.asText();
|
||||
|
||||
return Arrays.stream(asText.split("、"))
|
||||
.map(resolver)
|
||||
.filter(Objects::nonNull)
|
||||
.map(category -> ((CategoryValue) category).getSelectValue())
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue