|
@@ -218,29 +218,65 @@ public class CommonBtnController extends BaseController {
|
|
|
((ArrayList) relationJsonMap.get("subFormList")).forEach(rtem -> {
|
|
|
((Map) rtem).put("showTemplate", commonEntityList.stream().filter(ctem -> ctem.getResultMap().get("formKey").equals(((Map) rtem).get("formKey"))).findFirst().get().getResultMap());
|
|
|
});
|
|
|
- // 表单组回显数据
|
|
|
- String tableName = commonEntity.getBasicMap().get("tableName").toString();
|
|
|
- // 通用查询方法
|
|
|
- CommonEntity common = new CommonEntity();
|
|
|
- common.getBasicMap().put("tableName", tableName);
|
|
|
- commonEntity.getConditionMap().entrySet().forEach(item -> {
|
|
|
- common.getQueryMap().put(item.getKey(), item.getValue());
|
|
|
- });
|
|
|
- // 主
|
|
|
- List<CommonEntity> retCommonEntityList = commonService.selectList(common);
|
|
|
- ((Map) relationJsonMap.get("mainForm")).put("showValue", retCommonEntityList);
|
|
|
-
|
|
|
- // 从
|
|
|
- ((ArrayList) relationJsonMap.get("subFormList")).forEach(item -> {
|
|
|
- String[] congTableOInfo = ((Map) item).get("formItem").toString().split("\\.");
|
|
|
- String[] zhuTableOWhere = ((Map) item).get("relateMainItem").toString().split("\\.");
|
|
|
- CommonEntity congCommon = new CommonEntity();
|
|
|
- congCommon.getBasicMap().put("tableName", congTableOInfo[0]);
|
|
|
- Object val = retCommonEntityList.get(0).getResultMap().get(StringUtils.toCamelCase(zhuTableOWhere[1]));
|
|
|
- congCommon.getQueryMap().put(congTableOInfo[1], val);
|
|
|
- ((Map) item).put("showValue", commonService.selectList(congCommon));
|
|
|
- });
|
|
|
-
|
|
|
+ if (!dragTableBtn.getBtnType().equals("INSERT")) {
|
|
|
+ // 表单组回显数据
|
|
|
+ String zhuTableName = commonEntity.getBasicMap().get("tableName").toString();
|
|
|
+ // 通用查询方法
|
|
|
+ CommonEntity common = new CommonEntity();
|
|
|
+ common.getBasicMap().put("tableName", zhuTableName);
|
|
|
+ commonEntity.getConditionMap().entrySet().forEach(item -> {
|
|
|
+ common.getQueryMap().put(item.getKey(), item.getValue());
|
|
|
+ });
|
|
|
+ // 主
|
|
|
+ List<CommonEntity> retCommonEntityList = commonService.selectList(common);
|
|
|
+ ((Map) relationJsonMap.get("mainForm")).put("showValue", retCommonEntityList);
|
|
|
+
|
|
|
+ // 从
|
|
|
+ ArrayList subFormList = ((ArrayList) relationJsonMap.get("subFormList"));
|
|
|
+
|
|
|
+ subFormList.forEach(item -> {
|
|
|
+ String[] congTableOInfo = ((Map) item).get("formItem").toString().split("\\.");
|
|
|
+ String[] zhuTableOWhere = ((Map) item).get("relateMainItem").toString().split("\\.");
|
|
|
+ CommonEntity congCommon = new CommonEntity();
|
|
|
+ congCommon.getBasicMap().put("tableName", congTableOInfo[0]);
|
|
|
+ Object val = retCommonEntityList.get(0).getResultMap().get(StringUtils.toCamelCase(zhuTableOWhere[1]));
|
|
|
+ congCommon.getQueryMap().put(congTableOInfo[1], val);
|
|
|
+
|
|
|
+ List<Map<String, Object>> queryListMap = (List<Map<String, Object>>) ((Map) item).get("queryMap");
|
|
|
+ queryListMap.forEach(qtem -> {
|
|
|
+ if (qtem.get("type").equals("defaultValue")) { // 当前查询条件是默认的
|
|
|
+ congCommon.getQueryMap().put(qtem.get("fieldName").toString(), qtem.get("refValue"));
|
|
|
+ }
|
|
|
+ if (qtem.get("type").equals("relateValue")) {
|
|
|
+ if (qtem.get("tableName").equals(zhuTableName)) { // 当前关联条件是主表单
|
|
|
+ Object queryVal = retCommonEntityList.get(0).getResultMap().get(qtem.get("relaField").toString().split("\\.")[1]);
|
|
|
+ congCommon.getQueryMap().put(qtem.get("fieldName").toString(), queryVal);
|
|
|
+ } else { // 关联从表单
|
|
|
+ String tableWhere[] = qtem.get("relaField").toString().split("\\.");
|
|
|
+ Map<String, Object> getCurrentMap = (Map<String, Object>) subFormList.stream().filter(stem -> ((Map) stem).get("dfTableName").equals(
|
|
|
+ tableWhere[0]
|
|
|
+ )).findFirst().get();
|
|
|
+// ((Map) getCurrentMap.get("showValue")).get(tableWhere[1]);
|
|
|
+ CommonEntity common1 = (CommonEntity) ((ArrayList) getCurrentMap.get("showValue")).get(0);
|
|
|
+ Object queryVal = common1.getResultMap().get(tableWhere[1]);
|
|
|
+
|
|
|
+ congCommon.getQueryMap().put(qtem.get("fieldName").toString(), queryVal);
|
|
|
+ }
|
|
|
+
|
|
|
+ // retCommonEntityList.get(0).getResultMap().get(StringUtils.toCamelCase(zhuTableOWhere[1]));
|
|
|
+
|
|
|
+ // ((Map<?, ?>) item).get("dfTableName").equals(qtem.get("tableName"));
|
|
|
+
|
|
|
+ // zhuTableName
|
|
|
+
|
|
|
+ // qtem.get("refValue") 某张表的某个字段值
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ ((Map) item).put("showValue", commonService.selectList(congCommon));
|
|
|
+ });
|
|
|
+ }
|
|
|
//得到【df_form_sql】
|
|
|
String dfFormSql = ((Map) ((Map) relationJsonMap.get("mainForm")).get("showTemplate")).get("dfFormSql").toString();
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
@@ -258,6 +294,7 @@ public class CommonBtnController extends BaseController {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
((ArrayList) relationJsonMap.get("subFormList")).forEach(rtem -> {
|
|
|
String dfFormSql1 = ((Map) ((Map) rtem).get("showTemplate")).get("dfFormSql").toString();
|
|
|
ObjectMapper objectMapper1 = new ObjectMapper();
|