Commit 833d6cd5 authored by 刘凡's avatar 刘凡

*)增加显隐逻辑

parent 481ce6a3
...@@ -28,6 +28,7 @@ import javax.script.ScriptEngine; ...@@ -28,6 +28,7 @@ import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager; import javax.script.ScriptEngineManager;
import java.net.URI; import java.net.URI;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -71,45 +72,160 @@ public class DPSubServiceImpl { ...@@ -71,45 +72,160 @@ public class DPSubServiceImpl {
Object api = JsonValueUtils.getValueByKey(tab, "dataConfig", "dataConfig.api"); Object api = JsonValueUtils.getValueByKey(tab, "dataConfig", "dataConfig.api");
JSONObject map = content.getJSONObject(tab.getString("key")); JSONObject map = content.getJSONObject(tab.getString("key"));
ResponseModel apiResult = null; JSONObject apiResult = new JSONObject();
if (!ValidationUtil.isEmpty(api)){ if (!ValidationUtil.isEmpty(api)){
apiResult = this.getApiResult((JSONObject) api, !ValidationUtil.isEmpty(resultConvert) ? resultConvert.toString() : null); ResponseModel responseModel = this.getApiResult((JSONObject) api, !ValidationUtil.isEmpty(resultConvert) ? resultConvert.toString() : null);
// log.info("查询结果:{}", apiResult); if (!ValidationUtil.isEmpty(responseModel)) {
apiResult = JSONObject.parseObject(responseModel.getResult().toString());
}
} }
if (!ValidationUtil.isEmpty(formSeq)){ if (!ValidationUtil.isEmpty(formSeq)){
FormSceneModel formPage = Morphic.formSceneClient.seleteOne(formSeq).getResult(); FormSceneModel formPage = Morphic.formSceneClient.seleteOne(formSeq).getResult();
// 1、排除表单隐藏字段 // 1、排除表单隐藏字段
JSONArray children = (JSONArray)JsonValueUtils.getValueByKey(JSONObject.parseObject(formPage.getContent()), "children", "children"); JSONArray children = (JSONArray)JsonValueUtils.getValueByKey(JSONObject.parseObject(formPage.getContent()), "children", "children");
Object showHideRules = JsonValueUtils.getValueByKey(JSONObject.parseObject(formPage.getContent()), "formConfig", "formConfig.showHideRules");
// 处理显隐逻辑
this.processShowHideRules(children, showHideRules, apiResult);
List<Object> noHiddenChildren = children.stream().filter(x -> !"hidden".equals(JsonValueUtils.getValueByKey(x, "visualParams", "visualParams.behavior"))).collect(Collectors.toList()); List<Object> noHiddenChildren = children.stream().filter(x -> !"hidden".equals(JsonValueUtils.getValueByKey(x, "visualParams", "visualParams.behavior"))).collect(Collectors.toList());
ResponseModel finalApiResult = apiResult;
for (int i = 0; i < noHiddenChildren.size(); i++) { for (int i = 0; i < noHiddenChildren.size(); i++) {
JSONObject yObj = (JSONObject) noHiddenChildren.get(i); JSONObject yObj = (JSONObject) noHiddenChildren.get(i);
if ("pageSection".equals(yObj.get("componentKey")) || "columnsLayout".equals(yObj.get("componentKey"))) { // 分组或者布局容器 if ("pageSection".equals(yObj.get("componentKey")) || "columnsLayout".equals(yObj.get("componentKey"))) { // 分组或者布局容器
List<Object> mergedArray = mergedList(yObj.getJSONArray("children")); List<Object> mergedArray = mergedList(yObj.getJSONArray("children"));
// 第一组去除标题 // 第一组去除标题
if (i == 0){ if (i == 0 || ValidationUtil.isEmpty(map.get("datas"))){
this.buildContentData(map, mergedArray, finalApiResult); this.buildContentData(map, mergedArray, apiResult);
} else { } else {
this.buildSubContentData(map, i, yObj, mergedArray, finalApiResult); this.buildSubContentData(map, i, yObj, mergedArray, apiResult);
} }
} else if("subForm".equals(yObj.get("componentKey"))) { // 子表单 } else if("subForm".equals(yObj.get("componentKey"))) { // 子表单
} else if("formTable".equals(yObj.get("componentKey"))){ } else if("formTable".equals(yObj.get("componentKey"))){
map = new JSONObject(); map = new JSONObject();
map.put("columns", JsonValueUtils.getValueByKey(yObj, "visualParams", "visualParams.modelTableColumns")); map.put("columns", JsonValueUtils.getValueByKey(yObj, "visualParams", "visualParams.modelTableColumns"));
map.put("dataList", apiResult.getResult()); map.put("dataList", apiResult);
content.put(tab.getString("key"), map); content.put(tab.getString("key"), map);
} }
} }
} else { } else {
if (ValidationUtil.isEmpty(map)){ if (ValidationUtil.isEmpty(map)){
content.put(tab.getString("key"), apiResult.getResult()); content.put(tab.getString("key"), apiResult);
}
}
}
private JSONArray processShowHideRules(JSONArray children, Object showHideRules, JSONObject apiResult) {
if (!ValidationUtil.isEmpty(showHideRules)){
((JSONArray)showHideRules).stream().forEach(x -> {
JSONObject xObj = (JSONObject) x;
boolean hide = true;
JSONArray conditions = xObj.getJSONArray("condition");
String relation = null;
boolean lastConditionResult = false;
for (int i = 0; i < conditions.size(); i++) {
JSONObject conditionObj = conditions.getJSONObject(i);
String value = conditionObj.getString("value");
String condition = conditionObj.getString("condition");
JSONObject item = this.findByEid(children, JsonValueUtils.getValueByKey(conditionObj, "name", "name.key").toString());
Object fieldvalue = apiResult.get(JsonValueUtils.getValueByKey(item, "visualParams", "visualParams.fieldKey"));
if (ValidationUtil.isEmpty(relation)){
if (condition.equals("notUndefined") && !ValidationUtil.isEmpty(fieldvalue)){
lastConditionResult = !ValidationUtil.isEmpty(fieldvalue);
hide = false;
} else if (condition.equals("unequal") && !ValidationUtil.isEmpty(fieldvalue) && !fieldvalue.equals(value)){
lastConditionResult = !fieldvalue.equals(value);
hide = false;
} else if (condition.equals("equal") && !ValidationUtil.isEmpty(fieldvalue) && fieldvalue.equals(value)){
lastConditionResult = fieldvalue.equals(value);
hide = false;
}
} else {
if (lastConditionResult && condition.equals("notUndefined") && !ValidationUtil.isEmpty(fieldvalue)){
lastConditionResult = !ValidationUtil.isEmpty(fieldvalue);
hide = false;
} else if (lastConditionResult && condition.equals("unequal") && !ValidationUtil.isEmpty(fieldvalue) && !fieldvalue.equals(value)){
lastConditionResult = !fieldvalue.equals(value);
hide = false;
} else if(lastConditionResult && condition.equals("equal") && !ValidationUtil.isEmpty(fieldvalue) && fieldvalue.equals(value)){
lastConditionResult = fieldvalue.equals(value);
hide = false;
} else {
hide = true;
}
}
relation = conditionObj.getString("relation");
}
if (hide) {
JSONArray showColumns = xObj.getJSONArray("showColumns");
showColumns.stream().forEach(showColumn -> {
boolean match = false; // 是否匹配标识
List<Object> collect = children.stream().filter(y -> showColumn.equals(JsonValueUtils.getValueByKey(y, "eid", "eid"))).collect(Collectors.toList());
if (ValidationUtil.isEmpty(collect)){
for (int i = 0; i < children.size(); i++) {
if (match){ break; }
JSONArray subChildren = children.getJSONObject(i).getJSONArray("children");
for (int j = 0; j < subChildren.size(); j++) {
if (match){ break; }
Object cchildren = JsonValueUtils.getValueByKey(subChildren.get(j), "children", "children");
if (!ValidationUtil.isEmpty(cchildren)){
List<Object> ccollect = ((JSONArray)cchildren).stream().filter(y -> showColumn.equals(JsonValueUtils.getValueByKey(y, "eid", "eid"))).collect(Collectors.toList());
if (!ValidationUtil.isEmpty(ccollect)){
JSONObject groupObj = (JSONObject) ccollect.get(0);
JSONObject visualParams = groupObj.getJSONObject("visualParams");
visualParams.put("behavior", "hidden");
match = true;
break;
}
}
}
}
} else {
JSONObject groupObj = (JSONObject) collect.get(0);
JSONObject visualParams = groupObj.getJSONObject("visualParams");
visualParams.put("behavior", "hidden");
}
});
}
});
}
return children;
}
private JSONObject findByEid(JSONArray children, String eid) {
List<Object> collect = children.stream().filter(x -> eid.equals(JsonValueUtils.getValueByKey(x, "eid", "eid"))).collect(Collectors.toList());
if (ValidationUtil.isEmpty(collect)){
for (int i = 0; i < children.size(); i++) {
JSONArray subChildren = children.getJSONObject(i).getJSONArray("children");
for (int j = 0; j < subChildren.size(); j++) {
if (ValidationUtil.isEmpty(subChildren.getJSONObject(j).get("children"))){
List<Object> ccollect = subChildren.stream().filter(y -> eid.equals(JsonValueUtils.getValueByKey(y, "eid", "eid"))).collect(Collectors.toList());
if (!ValidationUtil.isEmpty(ccollect)){
return (JSONObject) ccollect.get(0);
}
} else {
Object cchildren = JsonValueUtils.getValueByKey(subChildren.get(j), "children", "children");
if (!ValidationUtil.isEmpty(cchildren)){
List<Object> ccollect = ((JSONArray)cchildren).stream().filter(y -> eid.equals(JsonValueUtils.getValueByKey(y, "eid", "eid"))).collect(Collectors.toList());
if (!ValidationUtil.isEmpty(ccollect)){
return (JSONObject) ccollect.get(0);
}
}
}
}
} }
} }
return (JSONObject) collect.get(0);
} }
/** /**
* 合并分组组件下的所有组件 * 合并分组组件下的所有组件
* @param children * @param children
...@@ -143,16 +259,14 @@ public class DPSubServiceImpl { ...@@ -143,16 +259,14 @@ public class DPSubServiceImpl {
return mergedArray; return mergedArray;
} }
public JSONObject buildContentData(JSONObject map, List<Object> mergedArray, ResponseModel apiResult){ public JSONObject buildContentData(JSONObject map, List<Object> mergedArray, JSONObject apiResult){
JSONObject result = new JSONObject();
if (!ValidationUtil.isEmpty(apiResult)){
result = JSONObject.parseObject(apiResult.getResult().toString());
}
JSONArray datas = new JSONArray(); JSONArray datas = new JSONArray();
JSONObject finalResult = result;
// 二维码 // 二维码
mergedArray.stream().filter(x -> "QRCode".equals(JsonValueUtils.getValueByKey(x, "visualParams", "visualParams.componentKey"))).findFirst().ifPresent(x -> { mergedArray.stream().filter(x -> "QRCode".equals(JsonValueUtils.getValueByKey(x, "componentKey", null))).findFirst().ifPresent(x -> {
JSONObject qrcode = map.getJSONObject("qrcode");
qrcode.put("text", apiResult.get("problemTime"));
qrcode.put("value", !ValidationUtil.isEmpty(apiResult.get("userCode")) ? apiResult.get("userCode") : apiResult.get("USE_ORG_CODE"));
qrcode.put("status", apiResult.get("problemStatus"));
}); });
mergedArray = mergedArray.stream().filter(x -> !"QRCode".equals(JsonValueUtils.getValueByKey(x, "visualParams", "visualParams.componentKey"))).collect(Collectors.toList()); mergedArray = mergedArray.stream().filter(x -> !"QRCode".equals(JsonValueUtils.getValueByKey(x, "visualParams", "visualParams.componentKey"))).collect(Collectors.toList());
...@@ -164,7 +278,7 @@ public class DPSubServiceImpl { ...@@ -164,7 +278,7 @@ public class DPSubServiceImpl {
if (!ValidationUtil.isEmpty(fieldKey)){ if (!ValidationUtil.isEmpty(fieldKey)){
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("label", visualParams.getString("label")); jsonObject.put("label", visualParams.getString("label"));
Object value = finalResult.get(fieldKey); Object value = apiResult.get(fieldKey);
if ("upload".equals(xObj.getString("componentKey"))){ if ("upload".equals(xObj.getString("componentKey"))){
jsonObject.put("type", "img"); jsonObject.put("type", "img");
if (!ValidationUtil.isEmpty(value)){ if (!ValidationUtil.isEmpty(value)){
...@@ -191,13 +305,8 @@ public class DPSubServiceImpl { ...@@ -191,13 +305,8 @@ public class DPSubServiceImpl {
return map; return map;
} }
public JSONObject buildSubContentData(JSONObject map, int i, JSONObject yObj, List<Object> mergedArray, ResponseModel apiResult){ public JSONObject buildSubContentData(JSONObject map, int i, JSONObject yObj, List<Object> mergedArray, JSONObject apiResult){
JSONArray jsonArray = map.getJSONArray("subs"); JSONArray jsonArray = map.getJSONArray("subs");
JSONObject result = new JSONObject();
if (!ValidationUtil.isEmpty(apiResult)){
result = JSONObject.parseObject(apiResult.getResult().toString());
}
JSONArray children = yObj.getJSONArray("children"); JSONArray children = yObj.getJSONArray("children");
List<Object> columnsArray = children.stream().filter(x -> { List<Object> columnsArray = children.stream().filter(x -> {
JSONObject xObj = (JSONObject) x; JSONObject xObj = (JSONObject) x;
...@@ -211,7 +320,6 @@ public class DPSubServiceImpl { ...@@ -211,7 +320,6 @@ public class DPSubServiceImpl {
subObj.put("columns", columnsArray.size()); subObj.put("columns", columnsArray.size());
JSONArray datas = new JSONArray(); JSONArray datas = new JSONArray();
JSONObject finalResult = result;
mergedArray.stream().forEach(x -> { mergedArray.stream().forEach(x -> {
JSONObject xObj = (JSONObject) x; JSONObject xObj = (JSONObject) x;
JSONObject visualParams = xObj.getJSONObject("visualParams"); JSONObject visualParams = xObj.getJSONObject("visualParams");
...@@ -220,7 +328,7 @@ public class DPSubServiceImpl { ...@@ -220,7 +328,7 @@ public class DPSubServiceImpl {
if (!ValidationUtil.isEmpty(fieldKey)){ if (!ValidationUtil.isEmpty(fieldKey)){
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("label", visualParams.getString("label")); jsonObject.put("label", visualParams.getString("label"));
Object value = finalResult.get(fieldKey); Object value = apiResult.get(fieldKey);
if ("upload".equals(xObj.getString("componentKey"))){ if ("upload".equals(xObj.getString("componentKey"))){
jsonObject.put("type", "img"); jsonObject.put("type", "img");
if (!ValidationUtil.isEmpty(value)){ if (!ValidationUtil.isEmpty(value)){
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
"dataConfig": { "dataConfig": {
"api": { "api": {
"httpMethod":"GET", "httpMethod":"GET",
"apiPath":"/tcm/baseEnterprise/getInfoByUseCode", "apiPath":"/tcm/baseEnterprise/getInfoByUseCode/map",
"params": { "params": {
"useCode": "{useUnitCode}" "useCode": "{useUnitCode}"
} }
......
...@@ -20,6 +20,24 @@ ...@@ -20,6 +20,24 @@
} }
}, },
{ {
"key": "gl",
"displayName": "锅炉技术参数",
"renderType": "basic",
"formSeq": "1734819004637278210",
"dataConfig": {
"api": {
"httpMethod":"GET",
"apiPath":"/jg/equipment-register/{record}",
"params": {
"record": "{record}"
},
"ruleData": {
"responseSuccess": "data.result.equipParams"
}
}
}
},
{
"key": "reghistory", "key": "reghistory",
"displayName": "监管履历信息", "displayName": "监管履历信息",
"renderType": "timeline", "renderType": "timeline",
...@@ -63,9 +81,10 @@ ...@@ -63,9 +81,10 @@
"qrcode": {}, "qrcode": {},
"subs": [] "subs": []
}, },
"dianti": { "gl": {
"columns": 3, "columns": 4,
"datas": [] "datas": [],
"subs": []
} }
} }
} }
\ No newline at end of file
...@@ -20,6 +20,24 @@ ...@@ -20,6 +20,24 @@
} }
}, },
{ {
"key": "ylrq",
"displayName": "压力容器技术参数",
"renderType": "basic",
"formSeq": "1734818687287848961",
"dataConfig": {
"api": {
"httpMethod":"GET",
"apiPath":"/jg/equipment-register/{record}",
"params": {
"record": "{record}"
},
"ruleData": {
"responseSuccess": "data.result.equipParams"
}
}
}
},
{
"key": "reghistory", "key": "reghistory",
"displayName": "监管履历信息", "displayName": "监管履历信息",
"renderType": "timeline", "renderType": "timeline",
...@@ -63,9 +81,10 @@ ...@@ -63,9 +81,10 @@
"qrcode": {}, "qrcode": {},
"subs": [] "subs": []
}, },
"dianti": { "ylrq": {
"columns": 3, "columns": 4,
"datas": [] "datas": [],
"subs": []
} }
} }
} }
\ No newline at end of file
...@@ -20,6 +20,24 @@ ...@@ -20,6 +20,24 @@
} }
}, },
{ {
"key": "dt",
"displayName": "电梯技术参数",
"renderType": "basic",
"formSeq": "1734504628768239617",
"dataConfig": {
"api": {
"httpMethod":"GET",
"apiPath":"/jg/equipment-register/{record}",
"params": {
"record": "{record}"
},
"ruleData": {
"responseSuccess": "data.result.equipParams"
}
}
}
},
{
"key": "reghistory", "key": "reghistory",
"displayName": "监管履历信息", "displayName": "监管履历信息",
"renderType": "timeline", "renderType": "timeline",
...@@ -63,9 +81,10 @@ ...@@ -63,9 +81,10 @@
"qrcode": {}, "qrcode": {},
"subs": [] "subs": []
}, },
"dianti": { "dt": {
"columns": 3, "columns": 4,
"datas": [] "datas": [],
"subs": []
} }
} }
} }
\ No newline at end of file
...@@ -20,6 +20,24 @@ ...@@ -20,6 +20,24 @@
} }
}, },
{ {
"key": "qzqx",
"displayName": "起重机械技术参数",
"renderType": "basic",
"formSeq": "1734818709194698753",
"dataConfig": {
"api": {
"httpMethod":"GET",
"apiPath":"/jg/equipment-register/{record}",
"params": {
"record": "{record}"
},
"ruleData": {
"responseSuccess": "data.result.equipParams"
}
}
}
},
{
"key": "reghistory", "key": "reghistory",
"displayName": "监管履历信息", "displayName": "监管履历信息",
"renderType": "timeline", "renderType": "timeline",
...@@ -63,9 +81,10 @@ ...@@ -63,9 +81,10 @@
"qrcode": {}, "qrcode": {},
"subs": [] "subs": []
}, },
"dianti": { "qzqx": {
"columns": 3, "columns": 4,
"datas": [] "datas": [],
"subs": []
} }
} }
} }
\ No newline at end of file
...@@ -20,6 +20,24 @@ ...@@ -20,6 +20,24 @@
} }
}, },
{ {
"key": "cnjdc",
"displayName": "场(厂)内机动车技术参数",
"renderType": "basic",
"formSeq": "1734818684284727297",
"dataConfig": {
"api": {
"httpMethod":"GET",
"apiPath":"/jg/equipment-register/{record}",
"params": {
"record": "{record}"
},
"ruleData": {
"responseSuccess": "data.result.equipParams"
}
}
}
},
{
"key": "reghistory", "key": "reghistory",
"displayName": "监管履历信息", "displayName": "监管履历信息",
"renderType": "timeline", "renderType": "timeline",
...@@ -63,9 +81,10 @@ ...@@ -63,9 +81,10 @@
"qrcode": {}, "qrcode": {},
"subs": [] "subs": []
}, },
"dianti": { "cnjdc": {
"columns": 3, "columns": 4,
"datas": [] "datas": [],
"subs": []
} }
} }
} }
\ No newline at end of file
...@@ -20,6 +20,24 @@ ...@@ -20,6 +20,24 @@
} }
}, },
{ {
"key": "dxylss",
"displayName": "大型游乐设施技术参数",
"renderType": "basic",
"formSeq": "1734818700369883137",
"dataConfig": {
"api": {
"httpMethod":"GET",
"apiPath":"/jg/equipment-register/{record}",
"params": {
"record": "{record}"
},
"ruleData": {
"responseSuccess": "data.result.equipParams"
}
}
}
},
{
"key": "reghistory", "key": "reghistory",
"displayName": "监管履历信息", "displayName": "监管履历信息",
"renderType": "timeline", "renderType": "timeline",
...@@ -63,9 +81,10 @@ ...@@ -63,9 +81,10 @@
"qrcode": {}, "qrcode": {},
"subs": [] "subs": []
}, },
"dianti": { "dxylss": {
"columns": 3, "columns": 4,
"datas": [] "datas": [],
"subs": []
} }
} }
} }
\ No newline at end of file
...@@ -20,6 +20,24 @@ ...@@ -20,6 +20,24 @@
} }
}, },
{ {
"key": "ylgd",
"displayName": "压力管道",
"renderType": "basic",
"formSeq": "1734818687287848961",
"dataConfig": {
"api": {
"httpMethod":"GET",
"apiPath":"/jg/equipment-register/{record}",
"params": {
"record": "{record}"
},
"ruleData": {
"responseSuccess": "data.result.equipParams"
}
}
}
},
{
"key": "reghistory", "key": "reghistory",
"displayName": "监管履历信息", "displayName": "监管履历信息",
"renderType": "timeline", "renderType": "timeline",
...@@ -63,9 +81,10 @@ ...@@ -63,9 +81,10 @@
"qrcode": {}, "qrcode": {},
"subs": [] "subs": []
}, },
"dianti": { "ylgd": {
"columns": 3, "columns": 4,
"datas": [] "datas": [],
"subs": []
} }
} }
} }
\ No newline at end of file
...@@ -20,6 +20,24 @@ ...@@ -20,6 +20,24 @@
} }
}, },
{ {
"key": "kysd",
"displayName": "客运索道",
"renderType": "basic",
"formSeq": "1734818694514634753",
"dataConfig": {
"api": {
"httpMethod":"GET",
"apiPath":"/jg/equipment-register/{record}",
"params": {
"record": "{record}"
},
"ruleData": {
"responseSuccess": "data.result.equipParams"
}
}
}
},
{
"key": "reghistory", "key": "reghistory",
"displayName": "监管履历信息", "displayName": "监管履历信息",
"renderType": "timeline", "renderType": "timeline",
...@@ -63,9 +81,10 @@ ...@@ -63,9 +81,10 @@
"qrcode": {}, "qrcode": {},
"subs": [] "subs": []
}, },
"dianti": { "kysd": {
"columns": 3, "columns": 4,
"datas": [] "datas": [],
"subs": []
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment