字段转换逻辑,反填表单字段
This commit is contained in:
parent
fdd5d50de6
commit
42bb66d19d
|
|
@ -1,9 +1,11 @@
|
|||
package com.engine.secret.entity.unpack;
|
||||
|
||||
import com.engine.secret.util.ModeUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
|
|
@ -18,4 +20,12 @@ public class DataConfigDetail {
|
|||
private String fieldName;
|
||||
private String path;
|
||||
private String condition;
|
||||
private String convertSql;
|
||||
|
||||
public String getConvertSql() {
|
||||
if (StringUtils.isBlank(convertSql)) {
|
||||
return "";
|
||||
}
|
||||
return ModeUtil.ToDBC(convertSql);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,5 +18,6 @@ public class FileConfig {
|
|||
private String fieldName;
|
||||
private String fileId;
|
||||
private String isFilled;
|
||||
private String isDefault;
|
||||
private String fixedValue;
|
||||
private String attachments;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
package com.engine.secret.enums;
|
||||
|
||||
/**
|
||||
* 申请类别
|
||||
*
|
||||
* @author:dxfeng
|
||||
* @createTime: 2025/04/07
|
||||
* @version: 1.0
|
||||
*/
|
||||
public enum ApplicationCategory {
|
||||
// 涉密信息系统集成资质、国家秘密载体印制资质、武器装备科研生产单位保密资质、涉密军事设施建设保密资质
|
||||
CLASSIFIED_INFO_SYSTEM_INTEGRATION_QUALIFICATION("涉密信息系统集成资质", 0),
|
||||
NATIONAL_SECRET_CARRIER_PRINTING_QUALIFICATION("国家秘密载体印制资质", 1),
|
||||
WEAPON_EQUIPMENT_RESEARCH_SECURITY_QUALIFICATION("武器装备科研生产单位保密资质", 2),
|
||||
CLASSIFIED_MILITARY_FACILITY_CONSTRUCTION_QUALIFICATION("涉密军事设施建设保密资质", 3);
|
||||
|
||||
ApplicationCategory(String name, Integer value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private String name;
|
||||
private Integer value;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.engine.secret.enums;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2025/04/07
|
||||
* @version: 1.0
|
||||
*/
|
||||
public interface CategoryValue {
|
||||
/**
|
||||
* 获取值
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getSelectValue();
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.engine.secret.enums;
|
||||
|
||||
/**
|
||||
* 集成资质
|
||||
*
|
||||
* @author:dxfeng
|
||||
* @createTime: 2025/04/07
|
||||
* @version: 1.0
|
||||
*/
|
||||
public enum IntegrateCategory implements CategoryValue {
|
||||
// 总体集成、系统咨询、软件开发、安防监控、屏蔽室建设、运行维护、数据恢复、工程监理
|
||||
SYSTEM_INTEGRATION("总体集成", 0),
|
||||
SYSTEM_CONSULTING("系统咨询", 1),
|
||||
SOFTWARE_DEVELOPMENT("软件开发", 2),
|
||||
SECURITY_SURVEILLANCE("安防监控", 3),
|
||||
SHIELDED_ROOM_CONSTRUCTION("屏蔽室建设", 4),
|
||||
OPERATION_MAINTENANCE("运行维护", 5),
|
||||
DATA_RECOVERY("数据恢复", 6),
|
||||
PROJECT_SUPERVISION("工程监理", 7);
|
||||
|
||||
IntegrateCategory(String name, Integer value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private String name;
|
||||
private Integer value;
|
||||
|
||||
public static IntegrateCategory getValue(String name) {
|
||||
for (IntegrateCategory item : IntegrateCategory.values()) {
|
||||
if (item.name.equalsIgnoreCase(name)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
//throw new RuntimeException("不支持的操作类型");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSelectValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.engine.secret.enums;
|
||||
|
||||
/**
|
||||
* 印制资质
|
||||
*
|
||||
* @author:dxfeng
|
||||
* @createTime: 2025/04/07
|
||||
* @version: 1.0
|
||||
*/
|
||||
public enum PrintCategory implements CategoryValue {
|
||||
// 涉密文件资料、国家统一考试试卷、涉密防伪票据证书、涉密光电磁介质、涉密档案数字化加工
|
||||
CLASSIFIED_DOCUMENTS("涉密文件资料", 0),
|
||||
NATIONAL_EXAM_PAPERS("国家统一考试试卷", 1),
|
||||
CLASSIFIED_VOUCHERS("涉密防伪票据证书", 2),
|
||||
SECURE_ELECTRONIC_STORAGE("涉密光电磁介质", 3),
|
||||
CLASSIFIED_DIGITIZATION("涉密档案数字化加工", 4);
|
||||
|
||||
PrintCategory(String name, Integer value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private String name;
|
||||
private Integer value;
|
||||
|
||||
public static PrintCategory getValue(String name) {
|
||||
for (PrintCategory item : PrintCategory.values()) {
|
||||
if (item.name.equalsIgnoreCase(name)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
//throw new RuntimeException("不支持的操作类型");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSelectValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,10 @@ 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.QualificationApplicationService;
|
||||
import com.engine.secret.util.ConfigUtil;
|
||||
|
|
@ -33,6 +37,7 @@ 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;
|
||||
|
||||
/**
|
||||
|
|
@ -58,6 +63,8 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
|
||||
String relatedFlowId;
|
||||
|
||||
Map<String, Object> returnMap = new HashMap<>();
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> parsingFiles(Map<String, Object> param) {
|
||||
|
|
@ -115,8 +122,7 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
baseBean.writeLog("开始解压文件,处理压缩包");
|
||||
unzipWithPassword(tempZipFile, Paths.get("output"), unzipPwd);
|
||||
baseBean.writeLog("压缩包处理完成");
|
||||
|
||||
return new HashMap<>();
|
||||
return returnMap;
|
||||
} catch (Exception e) {
|
||||
throw new CustomizeRunTimeException(e.getMessage(), e);
|
||||
}
|
||||
|
|
@ -171,6 +177,7 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
if (dataJsonImageId != null && dataJsonImageId > 0) {
|
||||
// 离线端方式
|
||||
JsonNode rootNode = parseJsonContent(dataJsonImageId);
|
||||
buildFormFields(rootNode);
|
||||
offline(rootNode);
|
||||
}
|
||||
|
||||
|
|
@ -200,6 +207,9 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
* @throws JsonProcessingException
|
||||
*/
|
||||
private void offline(JsonNode rootNode) throws Exception {
|
||||
// 解析基本信息并反写到流程表单
|
||||
|
||||
|
||||
List<DataConfig> dataConfigList = getDataConfig("0");
|
||||
baseBean.writeLog("dataConfigList==" + JSON.toJSONString(dataConfigList));
|
||||
|
||||
|
|
@ -340,6 +350,7 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
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();
|
||||
|
|
@ -352,7 +363,12 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
if (null == formfield) {
|
||||
continue;
|
||||
}
|
||||
Object reallyValue = FieldConvertUtil.getReallyValue(formfield, value);
|
||||
Object reallyValue;
|
||||
if (StringUtils.isNotBlank(convertSql)) {
|
||||
reallyValue = FieldConvertUtil.executeConvertSql(convertSql, value);
|
||||
} else {
|
||||
reallyValue = FieldConvertUtil.getReallyValue(formfield, value);
|
||||
}
|
||||
insertMap.put(fieldName, reallyValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -392,6 +408,7 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
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();
|
||||
|
|
@ -404,7 +421,13 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
if (null == formfield) {
|
||||
continue;
|
||||
}
|
||||
Object reallyValue = FieldConvertUtil.getReallyValue(formfield, value);
|
||||
Object reallyValue;
|
||||
if (StringUtils.isNotBlank(convertSql)) {
|
||||
reallyValue = FieldConvertUtil.executeConvertSql(convertSql, value);
|
||||
} else {
|
||||
reallyValue = FieldConvertUtil.getReallyValue(formfield, value);
|
||||
}
|
||||
|
||||
insertMap.put(fieldName, reallyValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -437,15 +460,25 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
String fieldName = fileConfig.getFieldName();
|
||||
// 是否更正文件
|
||||
String isFilled = fileConfig.getIsFilled();
|
||||
if ("2".equals(isFilled)) {
|
||||
// 如果为更正文件,跳过不做处理
|
||||
continue;
|
||||
}
|
||||
// 文件标识ID
|
||||
String fileId = fileConfig.getFileId();
|
||||
String isDefault = fileConfig.getIsDefault();
|
||||
if ("1".equals(isDefault)) {
|
||||
// 默认值条件,直接写入表单对应的字段
|
||||
defaultDataMap.put(fieldName, fileId);
|
||||
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)) {
|
||||
|
|
@ -573,7 +606,12 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
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")).build());
|
||||
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;
|
||||
}
|
||||
|
|
@ -593,7 +631,8 @@ public class QualificationApplicationServiceImpl extends Service implements Qual
|
|||
.fieldName(rs.getString("field_name"))
|
||||
.fileId(rs.getString("file_id"))
|
||||
.isFilled(rs.getString("file_type"))
|
||||
.isDefault(rs.getString("is_default"))
|
||||
.fixedValue(rs.getString("fixed_value"))
|
||||
.attachments(rs.getString("attachments"))
|
||||
.build());
|
||||
}
|
||||
return fileList;
|
||||
|
|
@ -678,5 +717,78 @@ 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(","));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,6 +128,23 @@ public class FieldConvertUtil {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 执行转换SQL
|
||||
*
|
||||
* @param convertSql
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static String executeConvertSql(String convertSql, String value) {
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery(convertSql, value);
|
||||
if (rs.next()) {
|
||||
return rs.getString(1);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验字符串是否为纯数字或逗号分隔的数字
|
||||
*
|
||||
|
|
|
|||
|
|
@ -389,7 +389,7 @@ public class ModeUtil {
|
|||
String selectValue = "";
|
||||
RecordSet rs = new RecordSet();
|
||||
String detailTable = formfield.getDetailtable();
|
||||
rs.executeQuery("select selectvalue from workflow_selectitem where fieldid =( select id from workflow_billfield where billid = ? and fieldname = ? and detailtable = ? ) and selectname = ?", formfield.getBillid(), formfield.getFieldname(), Util.null2String(detailTable),selectName);
|
||||
rs.executeQuery("select selectvalue from workflow_selectitem where fieldid =( select id from workflow_billfield where billid = ? and fieldname = ? and detailtable = ? ) and selectname = ?", formfield.getBillid(), formfield.getFieldname(), Util.null2String(detailTable), selectName);
|
||||
if (rs.next()) {
|
||||
selectValue = rs.getString("selectvalue");
|
||||
}
|
||||
|
|
@ -397,4 +397,30 @@ public class ModeUtil {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 全角转半角
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static String ToDBC(String input) {
|
||||
if (input == null) {
|
||||
input = "";
|
||||
}
|
||||
char[] c = input.toCharArray();
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if (c[i] == 12288) {
|
||||
//全角空格为12288,半角空格为32
|
||||
c[i] = (char) 32;
|
||||
continue;
|
||||
}
|
||||
if (c[i] > 65280 && c[i] < 65375) {
|
||||
//其他字符半角(33-126)与全角(65281-65374)的对应关系是:均相差65248
|
||||
c[i] = (char) (c[i] - 65248);
|
||||
}
|
||||
}
|
||||
return new String(c);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue