Compare commits
No commits in common. "839505b9bb95198eda451602d966585d35cf0ad1" and "3c3382f1d2a85eb655a16a7b397dcce94f24a8d9" have entirely different histories.
839505b9bb
...
3c3382f1d2
|
@ -101,12 +101,6 @@ public class ExamineSchedule extends CusBaseCronJob {
|
|||
Util.commitTransMapper(ScoreMapper.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCallback(Throwable e) {
|
||||
log.error("execute cronJon failure! error detail msg \n" + Util.getErrString(e));
|
||||
Util.rollbackTransMapper(ScoreMapper.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算专技岗分数
|
||||
* @param queryParam 查询参数
|
||||
|
@ -121,11 +115,11 @@ public class ExamineSchedule extends CusBaseCronJob {
|
|||
List<Integer> scoreIdList = new ArrayList<>();
|
||||
if(Objects.nonNull(scoreList) && !scoreList.isEmpty()){
|
||||
for (Map<String, Object> scoreMap : scoreList) {
|
||||
int dataId = Util.getModeDataId("uf_examine_score", Util.getIntValue(scoreModeId), 1);
|
||||
int dataId = Util.getModeDataId(tableName, Util.getIntValue(scoreModeId), 1);
|
||||
scoreIdList.add(dataId);
|
||||
Map<String,Object> whereParam = new HashMap<>();
|
||||
whereParam.put("id",dataId);
|
||||
String updateSql = CommonUtil.getCusUpdateSql("uf_examine_score", scoreMap, whereParam);
|
||||
String updateSql = CommonUtil.getCusUpdateSql("", scoreMap, whereParam);
|
||||
scoreMapper.executeUpdateCusSql(updateSql,scoreMap,whereParam);
|
||||
}
|
||||
Util.rebuildModeDataShareByAsyncList(1,Util.getIntValue(scoreModeId),scoreIdList);
|
||||
|
|
|
@ -58,7 +58,7 @@ public class JudgmentRuleProcess {
|
|||
return StringUtils.isNotBlank(conditionValue);
|
||||
}
|
||||
|
||||
@MethodRuleNo(value = 1,desc = "sql判断")
|
||||
@MethodRuleNo(value = 0,desc = "sql判断")
|
||||
public static boolean cusSql(ExamineConfigDetail examineConfigDetail,Map<String, Object> param){
|
||||
boolean result = false;
|
||||
String conditionScript = examineConfigDetail.getConditionScript();
|
||||
|
|
|
@ -23,7 +23,7 @@ public interface SourceTrackingMapper {
|
|||
* @param param 条件参数
|
||||
* @return 询价信息列表
|
||||
*/
|
||||
@Select("select id,xydh,bjkssj,bjjzsj from uf_src_rfq where bjjzsj < #{endDate} and (sfypf = 1 or sfypf is null) and xydh is not null ")
|
||||
@Select("select id,xydh,bjkssj,bjjzsj from uf_src_rfq where bjjzsj < #{endDate} and (sfypf = 1 or sfypf is null)")
|
||||
@CollectionMappings({
|
||||
@CollectionMapping(property = "sourceVendorList", column = "id", id = @Id(value = Integer.class, methodId = 1)),
|
||||
@CollectionMapping(property = "sourceMaterialList", column = "id", id = @Id(value = Integer.class, methodId = 2)),
|
||||
|
|
|
@ -38,9 +38,9 @@ public class GenerateReportSchedule extends CusBaseCronJob {
|
|||
@PrintParamMark
|
||||
private String dataSource;
|
||||
|
||||
private final SourceTrackingMapper sourceTrackingMapper = Util.getMapper(SourceTrackingMapper.class);
|
||||
private SourceTrackingMapper sourceTrackingMapper = Util.getMapper(SourceTrackingMapper.class);
|
||||
|
||||
private final VendorReportMapper vendorReportMapper = Util.getTransMapper(VendorReportMapper.class);
|
||||
private VendorReportMapper vendorReportMapper = Util.getTransMapper(VendorReportMapper.class);
|
||||
|
||||
@Override
|
||||
public void runCode() {
|
||||
|
|
|
@ -5,6 +5,7 @@ import aiyh.utils.ScriptUtil;
|
|||
import aiyh.utils.Util;
|
||||
import aiyh.utils.httpUtil.ResponeVo;
|
||||
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||
import aiyh.utils.tool.org.apache.commons.jexl3.*;
|
||||
import basetest.BaseTest;
|
||||
import bokang.xiao.entity.CourseEntity;
|
||||
import bokang.xiao.entity.StudentEntity;
|
||||
|
@ -15,7 +16,6 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper;
|
||||
|
||||
import com.api.bokang.xiao.wx_report.mapper.ReportMapper;
|
||||
|
@ -100,14 +100,10 @@ public class NormalTest extends BaseTest {
|
|||
param.put("zzgxd",4);
|
||||
param.put("hjjb","A");
|
||||
param.put("hjdj",1);
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("item","kkkgg");
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add("jjgjg");
|
||||
param.put("list",list);
|
||||
param.put("map",map);
|
||||
//String script = " list != null && list.size() > 0";
|
||||
String script = "map.containsKey('item')";
|
||||
String script = " list != null && list.size() > 0";
|
||||
//String script = " if (hjjb == 'A' && hjdj == 1) {x = 4}";
|
||||
boolean invokeVar = (Boolean) ScriptUtil.invokeScript(script, param);
|
||||
System.out.println(invokeVar);
|
||||
|
@ -120,30 +116,6 @@ public class NormalTest extends BaseTest {
|
|||
examineSchedule.runCode();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void paramGet(){
|
||||
Map<String,Object> param = new HashMap<>();
|
||||
|
||||
List<Map<String ,Object>> list = new ArrayList<>();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Map<String,Object> obj = new HashMap<>();
|
||||
obj.put("obj1",21);
|
||||
obj.put("objstr","jjgjgk");
|
||||
obj.put("objsttr2","jjggk");
|
||||
list.add(obj);
|
||||
}
|
||||
Map<String,Object> obj = new HashMap<>();
|
||||
obj.put("obj1",21);
|
||||
obj.put("objstr","jjgjgk");
|
||||
obj.put("objsttr2","jjggk");
|
||||
param.put("param1",12);
|
||||
param.put("paramStr","gkgkkg");
|
||||
param.put("paramObj",obj);
|
||||
param.put("param1",12);
|
||||
param.put("list",list);
|
||||
System.out.println(JSON.toJSON(param));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReport1() throws FileNotFoundException {
|
||||
BankService bankService = new BankService();
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
package bokang.xiao.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
|
||||
/**
|
||||
* @ClassName FieldDefinition
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/7/5 16:28
|
||||
* @Description <h1></h1>
|
||||
**/
|
||||
@Data
|
||||
//@NoArgsConstructor
|
||||
//@AllArgsConstructor
|
||||
//@Builder
|
||||
public class FieldDefinition {
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package bokang.xiao.exception;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @ClassName ResponseException
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/7/5 16:03
|
||||
* @Description <h1></h1>
|
||||
**/
|
||||
public class ResponseException extends RuntimeException{
|
||||
|
||||
private final Logger logger = Util.getLogger();
|
||||
private final String msg;
|
||||
private Throwable throwable;
|
||||
private Integer code = -1;
|
||||
|
||||
public ResponseException(Throwable throwable) {
|
||||
super(throwable);
|
||||
this.msg = throwable.getMessage();
|
||||
}
|
||||
|
||||
public ResponseException(String msg) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public ResponseException(String msg, String... obj) {
|
||||
super(Util.logStr(msg, obj));
|
||||
this.msg = Util.logStr(msg, obj);
|
||||
}
|
||||
|
||||
public ResponseException(String msg, Integer code) {
|
||||
super(msg);
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public ResponseException(String msg, Integer code, Throwable throwable) {
|
||||
super(msg, throwable);
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public ResponseException(String msg, Throwable throwable) {
|
||||
super(msg, throwable);
|
||||
this.msg = msg;
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printStackTrace() {
|
||||
logger.error("二开自定义异常:" + this.msg);
|
||||
if (this.throwable != null) {
|
||||
logger.error("异常信息: " + Util.getErrString(this.throwable));
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return this.msg;
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
package bokang.xiao.response_deal;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import aiyh.utils.httpUtil.ResponeVo;
|
||||
import bokang.xiao.entity.FieldDefinition;
|
||||
import bokang.xiao.exception.ResponseException;
|
||||
import bokang.xiao.response_deal.entity.ResponseConfig;
|
||||
import bokang.xiao.response_deal.entity.ResponseConfigValueChange;
|
||||
import bokang.xiao.response_deal.mapper.ConfigMapper;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName ResponseMappingDeal
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/7/4 17:42
|
||||
* @Description <h1>响应信息处理类</h1>
|
||||
**/
|
||||
public class ResponseMappingDeal {
|
||||
|
||||
private final Logger logger = Util.getLogger("json-util");
|
||||
|
||||
private final ConfigMapper configMapper = Util.getMapper(ConfigMapper.class);
|
||||
|
||||
|
||||
public void getConfig(String uniqueCode,ResponeVo responeVo){
|
||||
List<ResponseConfig> responseConfigList = configMapper.queryResponseConfigByUnique(uniqueCode);
|
||||
if(Objects.isNull(responseConfigList) || responseConfigList.isEmpty()){
|
||||
throw new ResponseException("response config is empty please check!!! ");
|
||||
}
|
||||
Map<String, ResponseConfig> tableNameConfig;
|
||||
try {
|
||||
tableNameConfig = responseConfigList.stream().collect(Collectors.toMap(ResponseConfig::getModelTableName, v -> v));
|
||||
}catch (Exception e){
|
||||
logger.error("response config error please check!!! "+Util.getErrString(e));
|
||||
throw new ResponseException("response config error please check!!! ");
|
||||
}
|
||||
tableNameConfig.entrySet().stream().forEach(item ->{
|
||||
dealConfig(item.getValue(),responeVo);
|
||||
});
|
||||
}
|
||||
|
||||
public void dealConfig(ResponseConfig responseConfig, ResponeVo responeVo){
|
||||
List<ResponseConfigValueChange> valueChangeList = responseConfig.getValueChangeList();
|
||||
if(Objects.isNull(valueChangeList) || valueChangeList.isEmpty()){
|
||||
throw new ResponseException("valueChangeList config is empty please check!!!");
|
||||
}
|
||||
Map<Integer, List<ResponseConfigValueChange>> tableTypeMap = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType));
|
||||
List<ResponseConfigValueChange> mainConfig = tableTypeMap.get(0);
|
||||
Map<String, List<ResponseConfigValueChange>> collect = mainConfig.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getAssignTable));
|
||||
if(collect.size() > 1){
|
||||
throw new ResponseException("The primary table cannot have details please check!!! ");
|
||||
}
|
||||
//Map<String, Object> responseMap = responeVo.getResponseMap();
|
||||
//Map<Util.ValueOrList,List<FieldDefinition>> mainFieldMap = new HashMap<>();
|
||||
//for (ResponseConfigValueChange responseConfigValueChange : mainConfig) {
|
||||
// String valuePath = responseConfigValueChange.getValuePath();
|
||||
// Util.ValueOrList valueOrListByKeyStr = Util.getValueOrListByKeyStr(valuePath, responseMap);
|
||||
// if(valueOrListByKeyStr.isArray() && !mainFieldMap.isEmpty() && !mainFieldMap.containsKey(valueOrListByKeyStr)){
|
||||
// throw new ResponseException("The primary table cannot contain multiple List data please check!!!");
|
||||
// }else if(valueOrListByKeyStr.isArray() && mainFieldMap.isEmpty()){
|
||||
// List<Map<String, Object>> listValue = (List<Map<String, Object>>) valueOrListByKeyStr.getValue();
|
||||
// List<FieldDefinition> fieldDefinitions = listValue.stream().map(item -> FieldDefinition.builder().build()).collect(Collectors.toList());
|
||||
// mainFieldMap.put(valueOrListByKeyStr,fieldDefinitions);
|
||||
// }else if(valueOrListByKeyStr.isArray()){
|
||||
// List<FieldDefinition> fieldDefinitions = mainFieldMap.get(valueOrListByKeyStr);
|
||||
// }
|
||||
//}
|
||||
//mainConfig.stream().map(item ->{
|
||||
//
|
||||
//})
|
||||
List<ResponseConfigValueChange> detail = tableTypeMap.get(1);
|
||||
Map<String, List<ResponseConfigValueChange>> tableValueMap = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getAssignTable));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void responseToEntity(ResponseConfigValueChange responseConfigValueChange,Map<String,Object> param){
|
||||
String valuePath = responseConfigValueChange.getValuePath();
|
||||
Util.ValueOrList valueOrListByKeyStr = Util.getValueOrListByKeyStr(valuePath, param);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package bokang.xiao.response_deal.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @ClassName ResponseConfigMain
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/7/4 17:16
|
||||
* @Description <h1>响应值处理配置</h1>
|
||||
**/
|
||||
|
||||
@Data
|
||||
public class ResponseConfig {
|
||||
|
||||
/** 请求唯一标识 */
|
||||
@SqlOracleDbFieldAnn("request_unique")
|
||||
private String requestUnique;
|
||||
|
||||
/** 配置描述 */
|
||||
@SqlOracleDbFieldAnn("config_desc")
|
||||
private String configDesc;
|
||||
|
||||
/** 表类型 */
|
||||
@SqlOracleDbFieldAnn("table_type")
|
||||
private String tableType;
|
||||
|
||||
/** 模型表 */
|
||||
@SqlOracleDbFieldAnn("model_table")
|
||||
private String modelTable;
|
||||
|
||||
/** 模型表名称 */
|
||||
@SqlOracleDbFieldAnn("model_table_name")
|
||||
private String modelTableName;
|
||||
|
||||
private List<ResponseConfigAlias> responseConfigAliasList;
|
||||
|
||||
private List<ResponseConfigValueChange> valueChangeList;
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package bokang.xiao.response_deal.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn;
|
||||
|
||||
/**
|
||||
* @ClassName ResponseConfigDtAlias
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/7/4 17:17
|
||||
* @Description <h1>别名配置</h1>
|
||||
**/
|
||||
@Data
|
||||
public class ResponseConfigAlias {
|
||||
|
||||
/** 数据路径 */
|
||||
@SqlOracleDbFieldAnn("data_path")
|
||||
private String dataPath;
|
||||
|
||||
/** 数据类型 */
|
||||
@SqlOracleDbFieldAnn("data_type")
|
||||
private String dataType;
|
||||
|
||||
/** 数据别名 */
|
||||
@SqlOracleDbFieldAnn("data_alias")
|
||||
private String dataAlias;
|
||||
|
||||
/** 数据变更 */
|
||||
@SqlOracleDbFieldAnn("data_change")
|
||||
private String dataChange;
|
||||
|
||||
/** 自定义文本 */
|
||||
@SqlOracleDbFieldAnn("cus_text")
|
||||
private String cusText;
|
||||
|
||||
/** 类型变更 */
|
||||
@SqlOracleDbFieldAnn("type_change")
|
||||
private String typeChange;
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
package bokang.xiao.response_deal.entity;
|
||||
|
||||
import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @ClassName ResponseConfigValueChange
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/7/4 17:19
|
||||
* @Description <h1>值转换配置</h1>
|
||||
**/
|
||||
@Data
|
||||
public class ResponseConfigValueChange {
|
||||
|
||||
/** 值路径 */
|
||||
@SqlOracleDbFieldAnn("value_path")
|
||||
private String valuePath;
|
||||
|
||||
/** 字段类型 */
|
||||
@SqlOracleDbFieldAnn("field_type")
|
||||
private int fieldType;
|
||||
|
||||
/** 分配字段 */
|
||||
@SqlOracleDbFieldAnn("assign_field")
|
||||
private String assignField;
|
||||
|
||||
/** 分配表 */
|
||||
@SqlOracleDbFieldAnn("assign_table")
|
||||
private String assignTable;
|
||||
|
||||
/** 表类型 */
|
||||
@SqlOracleDbFieldAnn("table_type")
|
||||
private int tableType;
|
||||
|
||||
public void setTableType(int tableType){
|
||||
this.tableType = tableType == -1 ? this.judgmentIsDetail(this.assignTable) : tableType;
|
||||
}
|
||||
|
||||
/** 分配字段名 */
|
||||
@SqlOracleDbFieldAnn("assign_field_name")
|
||||
private String assignFieldName;
|
||||
|
||||
/** 分配类型 */
|
||||
@SqlOracleDbFieldAnn("assign_type")
|
||||
private int assignType;
|
||||
|
||||
/** 数据变更 */
|
||||
@SqlOracleDbFieldAnn("data_change")
|
||||
private int dataChange;
|
||||
|
||||
/** 类型变更 */
|
||||
@SqlOracleDbFieldAnn("type_change")
|
||||
private int typeChange;
|
||||
|
||||
/** 自定义文本 */
|
||||
@SqlOracleDbFieldAnn("cus_text")
|
||||
private String cusText;
|
||||
|
||||
/** 判断脚本 */
|
||||
@SqlOracleDbFieldAnn("judgment_script")
|
||||
private String judgmentScript;
|
||||
|
||||
/** 条件脚本 */
|
||||
@SqlOracleDbFieldAnn("condition_script")
|
||||
private String conditionScript;
|
||||
|
||||
public int judgmentIsDetail(String tableName){
|
||||
Pattern compiledPattern = Pattern.compile("dt_\\d+$");
|
||||
Matcher matcher = compiledPattern.matcher(tableName);
|
||||
return matcher.find() ? 1 : 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package bokang.xiao.response_deal.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.*;
|
||||
import bokang.xiao.response_deal.entity.ResponseConfig;
|
||||
import bokang.xiao.response_deal.entity.ResponseConfigAlias;
|
||||
import bokang.xiao.response_deal.entity.ResponseConfigValueChange;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName ConfigMapper
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/7/4 17:26
|
||||
* @Description <h1>配置信息-数据库处理类</h1>
|
||||
**/
|
||||
@SqlMapper
|
||||
public interface ConfigMapper {
|
||||
|
||||
/**
|
||||
* <h2>通过请求唯一标识查询响应配置信息</h2>
|
||||
* @param requestUnique 唯一标识
|
||||
* @return 响应配置信息
|
||||
*/
|
||||
@Select("select * from uf_response_config where request_unique = #{requestUnique}")
|
||||
@CollectionMappings({
|
||||
@CollectionMapping(property = "responseConfigAliasList", column = "id", id = @Id(value = Integer.class, methodId = 1)),
|
||||
@CollectionMapping(property = "valueChangeList", column = "id", id = @Id(value = Integer.class, methodId = 2)),
|
||||
})
|
||||
List<ResponseConfig> queryResponseConfigByUnique(@ParamMapper("requestUnique") String requestUnique);
|
||||
|
||||
/**
|
||||
* <h2>通过请求唯一标识查询响应配置信息</h2>
|
||||
* @return 响应配置信息
|
||||
*/
|
||||
@Select("select * from uf_response_config")
|
||||
@CollectionMappings({
|
||||
@CollectionMapping(property = "responseConfigAliasList", column = "id", id = @Id(value = Integer.class, methodId = 1)),
|
||||
@CollectionMapping(property = "valueChangeList", column = "id", id = @Id(value = Integer.class, methodId = 2)),
|
||||
})
|
||||
List<ResponseConfig> queryResponseConfig();
|
||||
|
||||
/**
|
||||
* <h2>查询响应数据别名配置信息</h2>
|
||||
* @param mainId 主数据id
|
||||
* @return 响应数据别名配置信息列表
|
||||
*/
|
||||
@Select("select * from uf_response_config_dt1 where mainid = #{mainId}")
|
||||
@CollectionMethod(1)
|
||||
List<ResponseConfigAlias> queryResponseConfigAlias(@ParamMapper("mainId")int mainId);
|
||||
|
||||
|
||||
/**
|
||||
* <h2>查询响应数据转换配置信息</h2>
|
||||
* @param mainId 主数据id
|
||||
* @return 响应数据转换配置信息列表
|
||||
*/
|
||||
@Select("select * from uf_response_config_dt2 where mainid = #{mainId}")
|
||||
@CollectionMethod(2)
|
||||
List<ResponseConfigValueChange> queryResponseConfigValueChange(@ParamMapper("mainId")int mainId);
|
||||
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package bokang.xiao.response_deal.store;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import bokang.xiao.response_deal.entity.ResponseConfig;
|
||||
import bokang.xiao.response_deal.mapper.ConfigMapper;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.Getter;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName VendorStore
|
||||
* @Author 肖博亢
|
||||
* @Date 2023/3/17 18:31
|
||||
* @Description <h1></h1>
|
||||
**/
|
||||
|
||||
@Getter
|
||||
public class ResponseStore {
|
||||
|
||||
private final Logger logger = Util.getLogger();
|
||||
|
||||
private List<ResponseConfig> responseConfigList = new ArrayList<>();
|
||||
|
||||
private Map<String,List<ResponseConfig>> responseConfigMap = new HashMap<>();
|
||||
|
||||
private final ConfigMapper configMapper = Util.getMapper(ConfigMapper.class);
|
||||
|
||||
private ResponseStore(){
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init(){
|
||||
try {
|
||||
List<ResponseConfig> responseConfigs = configMapper.queryResponseConfig();
|
||||
if (Objects.nonNull(responseConfigs) && !responseConfigs.isEmpty()) {
|
||||
this.responseConfigList = responseConfigs;
|
||||
this.responseConfigMap = responseConfigs.stream().collect(Collectors.groupingBy(ResponseConfig::getRequestUnique));
|
||||
}
|
||||
logger.info(String.format("ResponseStore init success !!! responseConfigMap ==> %s", JSON.toJSONString(this.responseConfigMap)));
|
||||
}catch (Exception exception){
|
||||
logger.error("ResponseStore init fail !!! "+Util.getErrString(exception));
|
||||
}
|
||||
}
|
||||
|
||||
public void refresh(){
|
||||
this.init();
|
||||
}
|
||||
|
||||
public static ResponseStore getInstance(){
|
||||
return ResponseStoreHolder.RESPONSE_STORE;
|
||||
}
|
||||
|
||||
private static class ResponseStoreHolder{
|
||||
private ResponseStoreHolder(){
|
||||
|
||||
}
|
||||
private static final ResponseStore RESPONSE_STORE = new ResponseStore();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue