响应结果处理

dev
ic_excellent 2023-07-05 23:30:08 +08:00
parent ff69438198
commit 585c1ba700
13 changed files with 502 additions and 8 deletions

View File

@ -101,6 +101,12 @@ public class ExamineSchedule extends CusBaseCronJob {
Util.commitTransMapper(ScoreMapper.class); 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 * @param queryParam
@ -115,11 +121,11 @@ public class ExamineSchedule extends CusBaseCronJob {
List<Integer> scoreIdList = new ArrayList<>(); List<Integer> scoreIdList = new ArrayList<>();
if(Objects.nonNull(scoreList) && !scoreList.isEmpty()){ if(Objects.nonNull(scoreList) && !scoreList.isEmpty()){
for (Map<String, Object> scoreMap : scoreList) { for (Map<String, Object> scoreMap : scoreList) {
int dataId = Util.getModeDataId(tableName, Util.getIntValue(scoreModeId), 1); int dataId = Util.getModeDataId("uf_examine_score", Util.getIntValue(scoreModeId), 1);
scoreIdList.add(dataId); scoreIdList.add(dataId);
Map<String,Object> whereParam = new HashMap<>(); Map<String,Object> whereParam = new HashMap<>();
whereParam.put("id",dataId); whereParam.put("id",dataId);
String updateSql = CommonUtil.getCusUpdateSql("", scoreMap, whereParam); String updateSql = CommonUtil.getCusUpdateSql("uf_examine_score", scoreMap, whereParam);
scoreMapper.executeUpdateCusSql(updateSql,scoreMap,whereParam); scoreMapper.executeUpdateCusSql(updateSql,scoreMap,whereParam);
} }
Util.rebuildModeDataShareByAsyncList(1,Util.getIntValue(scoreModeId),scoreIdList); Util.rebuildModeDataShareByAsyncList(1,Util.getIntValue(scoreModeId),scoreIdList);

View File

@ -58,7 +58,7 @@ public class JudgmentRuleProcess {
return StringUtils.isNotBlank(conditionValue); return StringUtils.isNotBlank(conditionValue);
} }
@MethodRuleNo(value = 0,desc = "sql判断") @MethodRuleNo(value = 1,desc = "sql判断")
public static boolean cusSql(ExamineConfigDetail examineConfigDetail,Map<String, Object> param){ public static boolean cusSql(ExamineConfigDetail examineConfigDetail,Map<String, Object> param){
boolean result = false; boolean result = false;
String conditionScript = examineConfigDetail.getConditionScript(); String conditionScript = examineConfigDetail.getConditionScript();

View File

@ -23,7 +23,7 @@ public interface SourceTrackingMapper {
* @param param * @param param
* @return * @return
*/ */
@Select("select id,xydh,bjkssj,bjjzsj from uf_src_rfq where bjjzsj < #{endDate} and (sfypf = 1 or sfypf is null)") @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 ")
@CollectionMappings({ @CollectionMappings({
@CollectionMapping(property = "sourceVendorList", column = "id", id = @Id(value = Integer.class, methodId = 1)), @CollectionMapping(property = "sourceVendorList", column = "id", id = @Id(value = Integer.class, methodId = 1)),
@CollectionMapping(property = "sourceMaterialList", column = "id", id = @Id(value = Integer.class, methodId = 2)), @CollectionMapping(property = "sourceMaterialList", column = "id", id = @Id(value = Integer.class, methodId = 2)),

View File

@ -38,9 +38,9 @@ public class GenerateReportSchedule extends CusBaseCronJob {
@PrintParamMark @PrintParamMark
private String dataSource; private String dataSource;
private SourceTrackingMapper sourceTrackingMapper = Util.getMapper(SourceTrackingMapper.class); private final SourceTrackingMapper sourceTrackingMapper = Util.getMapper(SourceTrackingMapper.class);
private VendorReportMapper vendorReportMapper = Util.getTransMapper(VendorReportMapper.class); private final VendorReportMapper vendorReportMapper = Util.getTransMapper(VendorReportMapper.class);
@Override @Override
public void runCode() { public void runCode() {

View File

@ -5,7 +5,6 @@ import aiyh.utils.ScriptUtil;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils; import aiyh.utils.httpUtil.util.HttpUtils;
import aiyh.utils.tool.org.apache.commons.jexl3.*;
import basetest.BaseTest; import basetest.BaseTest;
import bokang.xiao.entity.CourseEntity; import bokang.xiao.entity.CourseEntity;
import bokang.xiao.entity.StudentEntity; import bokang.xiao.entity.StudentEntity;
@ -16,6 +15,7 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.annotation.ExcelProperty; 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.porsche_review.mapper.ReviewMapper;
import com.api.bokang.xiao.wx_report.mapper.ReportMapper; import com.api.bokang.xiao.wx_report.mapper.ReportMapper;
@ -100,10 +100,14 @@ public class NormalTest extends BaseTest {
param.put("zzgxd",4); param.put("zzgxd",4);
param.put("hjjb","A"); param.put("hjjb","A");
param.put("hjdj",1); param.put("hjdj",1);
Map<String,String> map = new HashMap<>();
map.put("item","kkkgg");
List<Object> list = new ArrayList<>(); List<Object> list = new ArrayList<>();
list.add("jjgjg"); list.add("jjgjg");
param.put("list",list); param.put("list",list);
String script = " list != null && list.size() > 0"; param.put("map",map);
//String script = " list != null && list.size() > 0";
String script = "map.containsKey('item')";
//String script = " if (hjjb == 'A' && hjdj == 1) {x = 4}"; //String script = " if (hjjb == 'A' && hjdj == 1) {x = 4}";
boolean invokeVar = (Boolean) ScriptUtil.invokeScript(script, param); boolean invokeVar = (Boolean) ScriptUtil.invokeScript(script, param);
System.out.println(invokeVar); System.out.println(invokeVar);
@ -116,6 +120,30 @@ public class NormalTest extends BaseTest {
examineSchedule.runCode(); 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 @Test
public void testReport1() throws FileNotFoundException { public void testReport1() throws FileNotFoundException {
BankService bankService = new BankService(); BankService bankService = new BankService();

View File

@ -0,0 +1,20 @@
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 {
}

View File

@ -0,0 +1,68 @@
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;
}
}

View File

@ -0,0 +1,92 @@
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);
}
}

View File

@ -0,0 +1,43 @@
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;
}

View File

@ -0,0 +1,38 @@
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;
}

View File

@ -0,0 +1,76 @@
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;
}
}

View File

@ -0,0 +1,61 @@
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);
}

View File

@ -0,0 +1,62 @@
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();
}
}