Merge remote-tracking branch 'origin/dev' into dev

dev
weilin.zhu 2023-07-15 11:40:50 +08:00
commit 91d91e0712
3 changed files with 233 additions and 120 deletions

View File

@ -1,4 +1,33 @@
(function runJs() { (function runJs() {
function findReact(dom, traverseUp = 0) {
const key = Object.keys(dom).find(key => {
return key.startsWith("__reactFiber$")
|| key.startsWith("__reactInternalInstance$")
|| key.startsWith("__reactEventHandlers$");
});
const domFiber = dom[key];
if (domFiber == null) return null;
if (domFiber._currentElement) {
let compFiber = domFiber._currentElement._owner;
for (let i = 0; i < traverseUp; i++) {
compFiber = compFiber._currentElement._owner;
}
return compFiber._instance;
}
const GetCompFiber = fiber => {
let parentFiber = fiber.return;
while (typeof parentFiber.type == "string") {
parentFiber = parentFiber.return;
}
return parentFiber;
};
let compFiber = GetCompFiber(domFiber);
for (let i = 0; i < traverseUp; i++) {
compFiber = GetCompFiber(compFiber);
}
return compFiber.stateNode;
}
let currentYear = new Date().getFullYear(); let currentYear = new Date().getFullYear();
let currentMonth = new Date().getMonth() + 1; let currentMonth = new Date().getMonth() + 1;
let currentDate = new Date().getDate(); let currentDate = new Date().getDate();
@ -23,9 +52,13 @@
wf.changeFieldValue("100003720000000611", {value: "外出技术支持"}); wf.changeFieldValue("100003720000000611", {value: "外出技术支持"});
wf.changeFieldValue("100003720000008715", {value: '2'}); wf.changeFieldValue("100003720000008715", {value: '2'});
wf.changeFieldValue("877132351682273302", {value: '1'}); wf.changeFieldValue("877132351682273302", {value: '1'});
let workflowTitleObj = document.querySelector('input[weid="3rdcst_oxa9w7_i8bbvp_vc1wev_kc1m3l_r1vh81_snhw9p_3r9w93_g28s4n_abfe5k_a9abii"]'); let workflowTitleObj = document.querySelector('.weapp-form-flowpage-content-FlowPageSysFieldReqName input');
let workflowTitle = workflowTitleObj.value; let workflowTitle = workflowTitleObj.value;
workflowTitleObj.value = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay; let newValue = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay;
workflowTitleObj.setAttribute("value", newValue);
workflowTitleObj.value = newValue;
let input = findReact(workflowTitleObj);
input.props.onChange(newValue);
const container = document.getElementById("widget_100003720000000664"); const container = document.getElementById("widget_100003720000000664");
const svgIcon = container.querySelector(".associative-search-icon svg"); const svgIcon = container.querySelector(".associative-search-icon svg");
if (svgIcon) { if (svgIcon) {
@ -43,6 +76,35 @@
})() })()
(function runJs() { (function runJs() {
function findReact(dom, traverseUp = 0) {
const key = Object.keys(dom).find(key => {
return key.startsWith("__reactFiber$")
|| key.startsWith("__reactInternalInstance$")
|| key.startsWith("__reactEventHandlers$");
});
const domFiber = dom[key];
if (domFiber == null) return null;
if (domFiber._currentElement) {
let compFiber = domFiber._currentElement._owner;
for (let i = 0; i < traverseUp; i++) {
compFiber = compFiber._currentElement._owner;
}
return compFiber._instance;
}
const GetCompFiber = fiber => {
let parentFiber = fiber.return;
while (typeof parentFiber.type == "string") {
parentFiber = parentFiber.return;
}
return parentFiber;
};
let compFiber = GetCompFiber(domFiber);
for (let i = 0; i < traverseUp; i++) {
compFiber = GetCompFiber(compFiber);
}
return compFiber.stateNode;
}
let currentYear = new Date().getFullYear(); let currentYear = new Date().getFullYear();
let currentMonth = new Date().getMonth() + 1; let currentMonth = new Date().getMonth() + 1;
let currentDate = new Date().getDate(); let currentDate = new Date().getDate();
@ -62,9 +124,13 @@
wf.changeFieldValue("100003720000000611", {value: "外出技术支持"}); wf.changeFieldValue("100003720000000611", {value: "外出技术支持"});
wf.changeFieldValue("100003720000008715", {value: '4'}); wf.changeFieldValue("100003720000008715", {value: '4'});
wf.changeFieldValue("877132351682273302", {value: '1'}); wf.changeFieldValue("877132351682273302", {value: '1'});
let workflowTitleObj = document.querySelector('input[weid="3rdcst_oxa9w7_i8bbvp_vc1wev_kc1m3l_r1vh81_snhw9p_3r9w93_g28s4n_abfe5k_a9abii"]'); let workflowTitleObj = document.querySelector('.weapp-form-flowpage-content-FlowPageSysFieldReqName input');
let workflowTitle = workflowTitleObj.value; let workflowTitle = workflowTitleObj.value;
workflowTitleObj.value = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay; let newValue = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay;
workflowTitleObj.setAttribute("value", newValue);
workflowTitleObj.value = newValue;
let input = findReact(workflowTitleObj);
input.props.onChange(newValue);
window.open("/sp/workflow/flowpage/fullCreate/100003460000000746?workflowId=100003460000000746&isCreate=1", "_blank"); window.open("/sp/workflow/flowpage/fullCreate/100003460000000746?workflowId=100003460000000746&isCreate=1", "_blank");
document.querySelector("button[weid='3rdcst_oxa9w7_i8bbvp_vc1wev_kc1m3l_r1vh81_t03ihg@0_xomsa1@0']").click(); document.querySelector("button[weid='3rdcst_oxa9w7_i8bbvp_vc1wev_kc1m3l_r1vh81_t03ihg@0_xomsa1@0']").click();
})() })()

View File

@ -52,41 +52,66 @@ public class ResponseMappingDeal {
public void doResponseSync(String uniqueCode, ResponeVo responeVo) { public void doResponseSync(String uniqueCode, ResponeVo responeVo) {
Map<String, Object> responseMap = responeVo.getResponseMap(); Map<String, Object> responseMap = responeVo.getResponseMap();
ResponseUtil.parameterJudgment(responseMap,"接口返回都为空 你处理个勾"); ResponseUtil.parameterJudgment(responseMap, "接口返回都为空 你处理个勾");
this.doResponseSync(uniqueCode,responseMap); this.doResponseSync(uniqueCode, responseMap);
} }
/**
* <h2> note by youhong.ai</h2>
*
* @param uniqueCode
* @param responseMap map
*/
public void doResponseSync(String uniqueCode, Map<String, Object> responseMap) { public void doResponseSync(String uniqueCode, Map<String, Object> responseMap) {
// note by youhong.ai 查询配置表
List<ResponseConfig> responseConfigList = configMapper.queryResponseConfigByUnique(uniqueCode); List<ResponseConfig> responseConfigList = configMapper.queryResponseConfigByUnique(uniqueCode);
logger.info(String.format("%s 相关响应配置信息==> %s",uniqueCode, JSON.toJSONString(responseConfigList))); logger.info(String.format("%s 相关响应配置信息==> %s", uniqueCode, JSON.toJSONString(responseConfigList)));
ResponseUtil.parameterJudgment(responseConfigList,"response config is empty please check!!! "); // note by youhong.ai 自定义校验
ResponseUtil.parameterJudgment(responseConfigList, "response config is empty please check!!! ");
Map<String, ResponseConfig> tableNameConfig; Map<String, ResponseConfig> tableNameConfig;
try { try {
// note by youhong.ai 对查询到的多个配置进行整合以同步表表名作为key 配置作为value
tableNameConfig = responseConfigList.stream().collect(Collectors.toMap(ResponseConfig::getModelTableName, v -> v)); tableNameConfig = responseConfigList.stream().collect(Collectors.toMap(ResponseConfig::getModelTableName, v -> v));
} catch (Exception e) { } catch (Exception e) {
logger.error("response config error please check!!! " + Util.getErrString(e)); logger.error("response config error please check!!! " + Util.getErrString(e));
throw new ResponseException("response config error please check!!! "); throw new ResponseException("response config error please check!!! ");
} }
ResponseUtil.parameterJudgment(responseMap,"接口返回都为空 你处理个勾"); ResponseUtil.parameterJudgment(responseMap, "接口返回都为空 你处理个勾");
// note by youhong.ai 循环同步每一个表
tableNameConfig.forEach((key, value) -> doResponseSync(value, responseMap)); tableNameConfig.forEach((key, value) -> doResponseSync(value, responseMap));
} }
public void doResponseSync(ResponseConfig responseConfig, Map<String, Object> responseMap){ /**
* <h2>note by youhong.ai </h2>
*
* @param responseConfig
* @param responseMap
*/
public void doResponseSync(ResponseConfig responseConfig, Map<String, Object> responseMap) {
// note by youhong.ai 获取别名配置明细数据
List<ResponseConfigAlias> responseConfigAliasList = responseConfig.getResponseConfigAliasList(); List<ResponseConfigAlias> responseConfigAliasList = responseConfig.getResponseConfigAliasList();
ResponseUtil.parameterJudgment(responseConfigAliasList,"responseConfigAliasList config is empty please check!!!"); ResponseUtil.parameterJudgment(responseConfigAliasList, "responseConfigAliasList config is empty please check!!!");
// note by youhong.ai 获取转换值配置明细
List<ResponseConfigValueChange> valueChangeList = responseConfig.getValueChangeList(); List<ResponseConfigValueChange> valueChangeList = responseConfig.getValueChangeList();
ResponseUtil.parameterJudgment(valueChangeList,"valueChangeList config is empty please check!!!"); ResponseUtil.parameterJudgment(valueChangeList, "valueChangeList config is empty please check!!!");
//数据信息按是否主表分组 // 数据信息按是否主表分组
Map<Integer, List<ResponseConfigAlias>> aliasMap = responseConfigAliasList.stream().collect(Collectors.groupingBy(ResponseConfigAlias::getTableType)); Map<Integer, List<ResponseConfigAlias>> aliasMap = responseConfigAliasList.stream().collect(Collectors.groupingBy(ResponseConfigAlias::getTableType));
// note by youhong.ai 获取主表别名配置数据
List<ResponseConfigAlias> mainConfigList = aliasMap.get(ResponseConfigConstant.MAIN_TABLE); List<ResponseConfigAlias> mainConfigList = aliasMap.get(ResponseConfigConstant.MAIN_TABLE);
// note by youhong.ai 按照表类型分组
Map<Integer, List<ResponseConfigValueChange>> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType)); Map<Integer, List<ResponseConfigValueChange>> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType));
// note by youhong.ai 获取主表值配置
List<ResponseConfigValueChange> mainValueChangeList = mainOrDetail.get(ResponseConfigConstant.MAIN_TABLE); List<ResponseConfigValueChange> mainValueChangeList = mainOrDetail.get(ResponseConfigConstant.MAIN_TABLE);
TableDefinition tableDefinition; TableDefinition tableDefinition;
if(ResponseUtil.parameterIsNotNull(mainConfigList)) { // note by youhong.ai 如果有主表配置
if (ResponseUtil.parameterIsNotNull(mainConfigList)) {
// note by youhong.ai 解析json为表描述对象
tableDefinition = this.parsingJsonToTable(responseConfig.getModelTableName(), responseConfig, mainConfigList, mainValueChangeList, responseMap, true, this::detailTableDeal); tableDefinition = this.parsingJsonToTable(responseConfig.getModelTableName(), responseConfig, mainConfigList, mainValueChangeList, responseMap, true, this::detailTableDeal);
}else{ } else {
Map<String,TableDefinition> detailTable = new HashMap<>(); // note by youhong.ai 如果没有主表配置,纯配置明细同步
this.detailTableDeal(responseConfig,responseMap,detailTable); Map<String, TableDefinition> detailTable = new HashMap<>();
// note by youhong.ai 处理明细表
this.detailTableDeal(responseConfig, responseMap, detailTable);
tableDefinition = TableDefinition.builder() tableDefinition = TableDefinition.builder()
.detailTableMap(detailTable) .detailTableMap(detailTable)
.tableDefinitionCallback(this.tableCallback) .tableDefinitionCallback(this.tableCallback)
@ -94,11 +119,23 @@ public class ResponseMappingDeal {
.assignType(ResponseConfigConstant.NO_HANDLE) .assignType(ResponseConfigConstant.NO_HANDLE)
.assignTable(responseConfig.getModelTableName()).build(); .assignTable(responseConfig.getModelTableName()).build();
} }
//做数据处理 // 做数据处理
tableDefinition.setDefaultState(stateClassKey); tableDefinition.setDefaultState(stateClassKey);
tableDefinition.dataProcess(); tableDefinition.dataProcess();
} }
/**
* <h2>note by youhon.ai json</h2>
*
* @param tableName
* @param responseConfig
* @param responseConfigAliasList
* @param valueChangeList
* @param responseMap
* @param isMainTable
* @param detailCallBack
* @return
*/
public TableDefinition parsingJsonToTable( public TableDefinition parsingJsonToTable(
String tableName, String tableName,
ResponseConfig responseConfig, ResponseConfig responseConfig,
@ -106,30 +143,33 @@ public class ResponseMappingDeal {
List<ResponseConfigValueChange> valueChangeList, List<ResponseConfigValueChange> valueChangeList,
Map<String, Object> responseMap, Map<String, Object> responseMap,
boolean isMainTable, boolean isMainTable,
Bi3Function<ResponseConfig,Map<String, Object>,Map<String,TableDefinition>,String> detailCallBack) { Bi3Function<ResponseConfig, Map<String, Object>, Map<String, TableDefinition>, String> detailCallBack) {
// note by youhong.ai 过滤出主表别名主数据配置
List<ResponseConfigAlias> mainAliasList = responseConfigAliasList.stream().filter(item -> item.getMainData() == ResponseConfigConstant.MAIN_DATA).collect(Collectors.toList()); List<ResponseConfigAlias> mainAliasList = responseConfigAliasList.stream().filter(item -> item.getMainData() == ResponseConfigConstant.MAIN_DATA).collect(Collectors.toList());
if(responseConfigAliasList.size() > 1) { // note by youhong.ai 主表别名有且只能有一个主数据
if (responseConfigAliasList.size() > 1) {
throw new ResponseException("The master data cannot be multiple please check !!! "); throw new ResponseException("The master data cannot be multiple please check !!! ");
} }
if(responseConfigAliasList.isEmpty()){ if (responseConfigAliasList.isEmpty()) {
throw new ResponseException("The configuration is missing master data please check !!! "); throw new ResponseException("The configuration is missing master data please check !!! ");
} }
Map<String,Object> aliasData = new HashMap<>(responseMap); Map<String, Object> aliasData = new HashMap<>(responseMap);
//处理别名数据 // 处理别名数据
responseConfigAliasList.forEach(item -> { responseConfigAliasList.forEach(item -> {
String dataPath = item.getDataPath(); String dataPath = item.getDataPath();
String dataAlias = item.getDataAlias(); String dataAlias = item.getDataAlias();
// node by youhong.ai 通过路径获取对应的值
Object parsingData = Util.getValueByKeyStr(dataPath, responseMap); Object parsingData = Util.getValueByKeyStr(dataPath, responseMap);
aliasData.put(dataAlias,parsingData); // node by youhong.ai 别名->值
aliasData.put(dataAlias, parsingData);
}); });
//Map<Integer, List<ResponseConfigValueChange>> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType)); // Map<Integer, List<ResponseConfigValueChange>> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType));
//List<ResponseConfigValueChange> mainValueChangeList = mainOrDetail.get(ResponseConfigConstant.MAIN_TABLE); // List<ResponseConfigValueChange> mainValueChangeList = mainOrDetail.get(ResponseConfigConstant.MAIN_TABLE);
ResponseUtil.parameterJudgment(valueChangeList,"main table valueChangeList config is empty please check!!!"); ResponseUtil.parameterJudgment(valueChangeList, "main table valueChangeList config is empty please check!!!");
//获取主表的主数据信息 // 获取主表的主数据信息
ResponseConfigAlias mainDataAlias = mainAliasList.get(0); ResponseConfigAlias mainDataAlias = mainAliasList.get(0);
int tableMainOrDetail = isMainTable ? ResponseConfigConstant.MAIN_TABLE : ResponseConfigConstant.DETAIL_TABLE; int tableMainOrDetail = isMainTable ? ResponseConfigConstant.MAIN_TABLE : ResponseConfigConstant.DETAIL_TABLE;
//构建表信息 // 构建表信息
TableDefinition tableDefinition = TableDefinition.builder().assignTable(tableName) TableDefinition tableDefinition = TableDefinition.builder().assignTable(tableName)
.conditionScript(mainDataAlias.getConditionScript()) .conditionScript(mainDataAlias.getConditionScript())
.judgmentScript(mainDataAlias.getJudgmentScript()) .judgmentScript(mainDataAlias.getJudgmentScript())
@ -139,39 +179,40 @@ public class ResponseMappingDeal {
.assignType(mainDataAlias.getAssignType()).build(); .assignType(mainDataAlias.getAssignType()).build();
String dataPath = mainDataAlias.getDataPath(); String dataPath = mainDataAlias.getDataPath();
List<RowDefinition> rowDefinitionList = new ArrayList<>(); List<RowDefinition> rowDefinitionList = new ArrayList<>();
Map<String,TableDefinition> detailTable = isMainTable ? new HashMap<>() : null; Map<String, TableDefinition> detailTable = isMainTable ? new HashMap<>() : null;
if(mainDataAlias.getDataType() == ResponseConfigConstant.JSON_ARRAY){ // note by youhong.ai 如果是json数组
List<Map<String,Object>> mainList = (List<Map<String,Object>>) Util.getValueByKeyStr(dataPath, aliasData); if (mainDataAlias.getDataType() == ResponseConfigConstant.JSON_ARRAY) {
List<Map<String, Object>> mainList = (List<Map<String, Object>>) Util.getValueByKeyStr(dataPath, aliasData);
for (Map<String, Object> mainItem : mainList) { for (Map<String, Object> mainItem : mainList) {
aliasData.put(mainDataAlias.getDataAlias(),mainItem); aliasData.put(mainDataAlias.getDataAlias(), mainItem);
//处理配置信息 // 处理配置信息
List<FieldDefinition> fieldDefinitions = parsingJsonToConfig(valueChangeList, aliasData); List<FieldDefinition> fieldDefinitions = parsingJsonToConfig(valueChangeList, aliasData);
RowDefinition rowDefinition = this.buildRowDefinition(fieldDefinitions,tableName, mainDataAlias.getAssignType(), mainDataAlias.getConditionScript(), mainDataAlias.getJudgmentScript()); RowDefinition rowDefinition = this.buildRowDefinition(fieldDefinitions, tableName, mainDataAlias.getAssignType(), mainDataAlias.getConditionScript(), mainDataAlias.getJudgmentScript());
rowDefinition.setMainOrDetail(ResponseConfigConstant.DETAIL_TABLE); rowDefinition.setMainOrDetail(ResponseConfigConstant.DETAIL_TABLE);
if(isMainTable) { if (isMainTable) {
rowDefinition.setMainOrDetail(ResponseConfigConstant.MAIN_TABLE); rowDefinition.setMainOrDetail(ResponseConfigConstant.MAIN_TABLE);
detailCallBack.apply(responseConfig,aliasData,detailTable); detailCallBack.apply(responseConfig, aliasData, detailTable);
rowDefinition.setDetailTableMap(detailTable); rowDefinition.setDetailTableMap(detailTable);
} }
rowDefinitionList.add(rowDefinition); rowDefinitionList.add(rowDefinition);
} }
}else if(mainDataAlias.getDataType() == ResponseConfigConstant.JSON_OBJECT){ } else if (mainDataAlias.getDataType() == ResponseConfigConstant.JSON_OBJECT) {
Map<String,Object> jsonObj = (Map<String, Object>) Util.getValueByKeyStr(dataPath, aliasData); Map<String, Object> jsonObj = (Map<String, Object>) Util.getValueByKeyStr(dataPath, aliasData);
aliasData.put(mainDataAlias.getDataAlias(),jsonObj); aliasData.put(mainDataAlias.getDataAlias(), jsonObj);
//处理配置信息 // 处理配置信息
List<FieldDefinition> fieldDefinitions = parsingJsonToConfig(valueChangeList, aliasData); List<FieldDefinition> fieldDefinitions = parsingJsonToConfig(valueChangeList, aliasData);
RowDefinition rowDefinition = this.buildRowDefinition(fieldDefinitions,tableName,mainDataAlias.getAssignType(), mainDataAlias.getConditionScript(), mainDataAlias.getJudgmentScript()); RowDefinition rowDefinition = this.buildRowDefinition(fieldDefinitions, tableName, mainDataAlias.getAssignType(), mainDataAlias.getConditionScript(), mainDataAlias.getJudgmentScript());
rowDefinition.setMainOrDetail(ResponseConfigConstant.DETAIL_TABLE); rowDefinition.setMainOrDetail(ResponseConfigConstant.DETAIL_TABLE);
if(isMainTable) { if (isMainTable) {
rowDefinition.setMainOrDetail(ResponseConfigConstant.MAIN_TABLE); rowDefinition.setMainOrDetail(ResponseConfigConstant.MAIN_TABLE);
detailCallBack.apply(responseConfig,aliasData,detailTable); detailCallBack.apply(responseConfig, aliasData, detailTable);
rowDefinition.setDetailTableMap(detailTable); rowDefinition.setDetailTableMap(detailTable);
} }
rowDefinitionList.add(rowDefinition); rowDefinitionList.add(rowDefinition);
}else { } else {
throw new ResponseException("please set the primary data type !!!"); throw new ResponseException("please set the primary data type !!!");
} }
//设置表的行信息 // 设置表的行信息
tableDefinition.setRowDefinitionList(rowDefinitionList); tableDefinition.setRowDefinitionList(rowDefinitionList);
return tableDefinition; return tableDefinition;
} }
@ -180,16 +221,16 @@ public class ResponseMappingDeal {
String tableName, String tableName,
int assignType, int assignType,
String conditionScript, String conditionScript,
String judgmentScript){ String judgmentScript) {
Map<String,Object> updateParam = new HashMap<>(); Map<String, Object> updateParam = new HashMap<>();
Map<String,Object> wherePram = new HashMap<>(); Map<String, Object> wherePram = new HashMap<>();
fieldDefinitionList.forEach(fieldDefinition -> { fieldDefinitionList.forEach(fieldDefinition -> {
int fieldType = fieldDefinition.getFieldType(); int fieldType = fieldDefinition.getFieldType();
if(fieldType == ResponseConfigConstant.WHERE_FIELD){ if (fieldType == ResponseConfigConstant.WHERE_FIELD) {
wherePram.put(fieldDefinition.getFieldName(),fieldDefinition.getFieldValue()); wherePram.put(fieldDefinition.getFieldName(), fieldDefinition.getFieldValue());
}else { } else {
updateParam.put(fieldDefinition.getFieldName(),fieldDefinition.getFieldValue()); updateParam.put(fieldDefinition.getFieldName(), fieldDefinition.getFieldValue());
wherePram.put(fieldDefinition.getFieldName(),fieldDefinition.getFieldValue()); wherePram.put(fieldDefinition.getFieldName(), fieldDefinition.getFieldValue());
} }
}); });
return RowDefinition.builder().assignType(assignType) return RowDefinition.builder().assignType(assignType)
@ -202,48 +243,49 @@ public class ResponseMappingDeal {
.judgmentScript(judgmentScript).build(); .judgmentScript(judgmentScript).build();
} }
private String detailTableDeal(ResponseConfig responseConfig,Map<String, Object> param,Map<String,TableDefinition> detailTable){ private String detailTableDeal(ResponseConfig responseConfig, Map<String, Object> param, Map<String, TableDefinition> detailTable) {
List<ResponseConfigAlias> responseConfigAliasList = responseConfig.getResponseConfigAliasList(); List<ResponseConfigAlias> responseConfigAliasList = responseConfig.getResponseConfigAliasList();
List<ResponseConfigValueChange> valueChangeList = responseConfig.getValueChangeList(); List<ResponseConfigValueChange> valueChangeList = responseConfig.getValueChangeList();
//数据信息按是否主表分组 // 数据信息按是否主表分组
Map<Integer, List<ResponseConfigAlias>> aliasMap = responseConfigAliasList.stream().collect(Collectors.groupingBy(ResponseConfigAlias::getTableType)); Map<Integer, List<ResponseConfigAlias>> aliasMap = responseConfigAliasList.stream().collect(Collectors.groupingBy(ResponseConfigAlias::getTableType));
List<ResponseConfigAlias> detailAliases = aliasMap.get(ResponseConfigConstant.DETAIL_TABLE); List<ResponseConfigAlias> detailAliases = aliasMap.get(ResponseConfigConstant.DETAIL_TABLE);
//没有明细相关配置不处理 // 没有明细相关配置不处理
if(ResponseUtil.parameterIsNull(detailAliases)){ if (ResponseUtil.parameterIsNull(detailAliases)) {
return ""; return "";
} }
Map<String, List<ResponseConfigAlias>> detailAliasMap = detailAliases.stream().collect(Collectors.groupingBy(ResponseConfigAlias::getDetailTableName)); Map<String, List<ResponseConfigAlias>> detailAliasMap = detailAliases.stream().collect(Collectors.groupingBy(ResponseConfigAlias::getDetailTableName));
Map<String, List<ResponseConfigValueChange>> detailValueChangeMap = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getAssignTable)); Map<String, List<ResponseConfigValueChange>> detailValueChangeMap = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getAssignTable));
detailAliasMap.forEach((key,value) ->{ detailAliasMap.forEach((key, value) -> {
List<ResponseConfigValueChange> detailValueChangeList = detailValueChangeMap.get(key); List<ResponseConfigValueChange> detailValueChangeList = detailValueChangeMap.get(key);
TableDefinition tableDefinition = parsingJsonToTable(key, responseConfig, value, detailValueChangeList, param, false, this::detailTableDeal); TableDefinition tableDefinition = parsingJsonToTable(key, responseConfig, value, detailValueChangeList, param, false, this::detailTableDeal);
detailTable.put(key,tableDefinition); detailTable.put(key, tableDefinition);
}); });
return ""; return "";
} }
/** /**
* json * json
*
* @param responseConfigValueChangeList * @param responseConfigValueChangeList
* @param parsingData json * @param parsingData json
* @return * @return
*/ */
public List<FieldDefinition> parsingJsonToConfig(List<ResponseConfigValueChange> responseConfigValueChangeList, public List<FieldDefinition> parsingJsonToConfig(List<ResponseConfigValueChange> responseConfigValueChangeList,
Map<String,Object> parsingData){ Map<String, Object> parsingData) {
Map<String,Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
responseConfigValueChangeList.forEach(item ->{ responseConfigValueChangeList.forEach(item -> {
Object value = item.getDataChange() == ResponseConfigConstant.DEFAULT_VALUE Object value = item.getDataChange() == ResponseConfigConstant.DEFAULT_VALUE
? null ? null
: Util.getValueByKeyStr(Util.null2String(item.getValuePath()), parsingData); : Util.getValueByKeyStr(Util.null2String(item.getValuePath()), parsingData);
item.setJsonData(value); item.setJsonData(value);
param.put(item.getAssignFieldName(),value); param.put(item.getAssignFieldName(), value);
}); });
return responseConfigValueChangeList.stream().map(item ->{ return responseConfigValueChangeList.stream().map(item -> {
BiFunction<ResponseConfigValueChange, Map<String, Object>, String> dataChangeFunction = DataChangeProcess.MODE_METHOD_MAP.get(item.getDataChange()); BiFunction<ResponseConfigValueChange, Map<String, Object>, String> dataChangeFunction = DataChangeProcess.MODE_METHOD_MAP.get(item.getDataChange());
ResponseUtil.parameterJudgment(dataChangeFunction,"The corresponding data conversion mode processing method is not found !!!"); ResponseUtil.parameterJudgment(dataChangeFunction, "The corresponding data conversion mode processing method is not found !!!");
dataChangeFunction.apply(item,param); dataChangeFunction.apply(item, param);
Function<Object, Object> typeChangeFunction = TypeChangeProcess.MODE_METHOD_MAP.get(item.getTypeChange()); Function<Object, Object> typeChangeFunction = TypeChangeProcess.MODE_METHOD_MAP.get(item.getTypeChange());
ResponseUtil.parameterJudgment(typeChangeFunction,"The corresponding type conversion method could not be found !!!"); ResponseUtil.parameterJudgment(typeChangeFunction, "The corresponding type conversion method could not be found !!!");
Object targetValue = typeChangeFunction.apply(item.getJsonData()); Object targetValue = typeChangeFunction.apply(item.getJsonData());
return FieldDefinition.builder().fieldType(item.getFieldType()) return FieldDefinition.builder().fieldType(item.getFieldType())
.tableType(item.getTableType()) .tableType(item.getTableType())

View File

@ -27,7 +27,6 @@ import java.util.Objects;
public class SsoGuoXiaoJunPocImpl { public class SsoGuoXiaoJunPocImpl {
public static final String API_SSO_URL = "/api/aiyh/guoxiaojun/sso"; public static final String API_SSO_URL = "/api/aiyh/guoxiaojun/sso";
public static final String LOGIN_URL = "/wui/index.html";
public static final String API_CHECK_OUT_URI = "/api/hrm/login/checkLogout"; public static final String API_CHECK_OUT_URI = "/api/hrm/login/checkLogout";
private final Logger log = Util.getLogger(); private final Logger log = Util.getLogger();
@ -55,20 +54,24 @@ public class SsoGuoXiaoJunPocImpl {
if (requestURI.equals(API_CHECK_OUT_URI)) { if (requestURI.equals(API_CHECK_OUT_URI)) {
// 退出登录 // 退出登录
session.removeAttribute("outUserId"); session.removeAttribute("outUserId");
String logOutUrl = Util.getCusConfigValue("oauth2-proxy-logout-url");
response.setHeader("logOutUrl", logOutUrl);
return; return;
} }
// sso 认证 // sso 认证
if (session.getAttribute("outUserId") == null) { if (session.getAttribute("outUserId") == null) {
authorSso(response, session); authorSso(response);
} }
} catch (IOException e) { } catch (IOException e) {
log.error("重定地址失败!" + Util.getErrString(e)); log.error("重定地址失败!" + Util.getErrString(e));
} }
} }
// /**
* <h2>oa</h2>
*
* @param request
* @param response
* @throws IOException
*/
private void loginOa(HttpServletRequest request, HttpServletResponse response) throws IOException { private void loginOa(HttpServletRequest request, HttpServletResponse response) throws IOException {
HttpSession session; HttpSession session;
String outUserId = request.getHeader("X-Credential-Identifier"); String outUserId = request.getHeader("X-Credential-Identifier");
@ -84,11 +87,13 @@ public class SsoGuoXiaoJunPocImpl {
response.sendRedirect(Util.getCusConfigValueNullOrEmpty("SSO_SUCCESS_REDIRECT_URL", "/wui/index.html")); response.sendRedirect(Util.getCusConfigValueNullOrEmpty("SSO_SUCCESS_REDIRECT_URL", "/wui/index.html"));
} }
private void authorSso(HttpServletResponse response, HttpSession session) throws IOException { /**
Object outUserId = session.getAttribute("outUserId"); * <h2></h2>
if (Objects.nonNull(outUserId)) { *
return; * @param response
} * @throws IOException
*/
private void authorSso(HttpServletResponse response) throws IOException {
// 地址重定向到国小君aut2认证地址 // 地址重定向到国小君aut2认证地址
response.sendRedirect(Util.getCusConfigValue("oauth2-proxy-url") + "?url=" response.sendRedirect(Util.getCusConfigValue("oauth2-proxy-url") + "?url="
+ URLEncoder.encode(Util.getCusConfigValue("OA_URL") + API_SSO_URL, "UTF-8")); + URLEncoder.encode(Util.getCusConfigValue("OA_URL") + API_SSO_URL, "UTF-8"));