数据解析 校验表单填写字段一致性

This commit is contained in:
dxfeng 2025-05-12 10:56:43 +08:00
parent 8fb7de056e
commit fd505e8a9d
2 changed files with 34 additions and 3 deletions

View File

@ -410,6 +410,7 @@ public class OfflineZipUnpackServiceImpl extends Service implements UnpackZipSer
rs.executeQuery("select * from " + tableNameByRequestId + " where requestId = ?", requestId); rs.executeQuery("select * from " + tableNameByRequestId + " where requestId = ?", requestId);
IgnoreCaseHashMap<String, Object> flowDataMap = ModeUtil.getSingleRecordMap(rs); IgnoreCaseHashMap<String, Object> flowDataMap = ModeUtil.getSingleRecordMap(rs);
baseBean.writeLog("flowDataMap==="+JSON.toJSONString(flowDataMap));
// 根据根结点获取配置 // 根据根结点获取配置
String rootPath = dataConfig.getRootPath(); String rootPath = dataConfig.getRootPath();
@ -788,19 +789,46 @@ public class OfflineZipUnpackServiceImpl extends Service implements UnpackZipSer
private boolean processFieldForCheck(JsonNode jsonNode, DataConfigDetail fieldDetail, Map<String, Formfield> fieldMap, String flowData) throws Exception { private boolean processFieldForCheck(JsonNode jsonNode, DataConfigDetail fieldDetail, Map<String, Formfield> fieldMap, String flowData) throws Exception {
String fieldName = fieldDetail.getFieldName(); String fieldName = fieldDetail.getFieldName();
JsonNode atNode = jsonNode.at(fieldDetail.getPath()); JsonNode atNode = jsonNode.at(fieldDetail.getPath());
baseBean.writeLog("fieldName==" + fieldName);
if (atNode != null) { if (atNode != null) {
String value = atNode.asText(); String value = atNode.asText();
if (StringUtils.isNotBlank(fieldDetail.getCondition()) && !value.equals(fieldDetail.getCondition())) { if (StringUtils.isNotBlank(fieldDetail.getCondition()) && !value.equals(fieldDetail.getCondition())) {
baseBean.writeLog("Condition==" + fieldDetail.getCondition());
baseBean.writeLog("Condition value==" + value);
return false; return false;
} }
Formfield formfield = fieldMap.get(fieldName.toLowerCase()); Formfield formfield = fieldMap.get(fieldName.toLowerCase());
if (formfield == null) { if (formfield == null) {
baseBean.writeLog("formfield is null");
return false; return false;
} }
String parseValue = Util.null2String(getFieldValue(fieldDetail, value, formfield));
baseBean.writeLog("parseValue==" + parseValue);
baseBean.writeLog("flowData==" + flowData);
// 根据不同的字段类型处理比较方式
String fieldHtmlType = formfield.getFieldhtmltype();
baseBean.writeLog("fieldHtmlType==" + fieldHtmlType);
return flowData.equals(Util.null2String(getFieldValue(fieldDetail, value, formfield))); // 下拉框选择框浏览按钮比较时排序处理
if ("3".equals(fieldHtmlType) || "5".equals(fieldHtmlType)) {
// 分割字符串为数组
String[] aArray = parseValue.split(",");
String[] bArray = flowData.split(",");
// 如果长度不同直接返回false
if (aArray.length != bArray.length) {
return false;
}
// 排序数组
Arrays.sort(aArray);
Arrays.sort(bArray);
// 比较排序后的数组内容
return Arrays.equals(aArray, bArray);
}
return flowData.equals(parseValue);
} }
return false; return false;
} }

View File

@ -96,7 +96,10 @@ public class FieldConvertUtil {
} }
String[] split = value.split(separator); String[] split = value.split(separator);
for (String s : split) { for (String s : split) {
selectValues.add(ModeUtil.getSelectValue(formfield, s)); String selectValue = ModeUtil.getSelectValue(formfield, s);
if (StringUtils.isNotBlank(selectValue)) {
selectValues.add(selectValue);
}
} }
object = StringUtils.join(selectValues, ","); object = StringUtils.join(selectValues, ",");
if (StringUtils.isBlank(Util.null2String(object))) { if (StringUtils.isBlank(Util.null2String(object))) {