需求背景:待续
1:数据格式:
{"dataTimes":["201904"],"labelConditions":[{"exacts":["14","12"],"exclude":["11.008","12.08"],"fuzzy":["17","16"],"fuzzyExclude":["12.9","14.9"],"labelName":"summileagePerDay_workingDay","range":[["11","11.01"],["13","13.5"]]},{"exacts":["14","12"],"exclude":["12.007936","12.0508"],"fuzzy":["10","16"],"fuzzyExclude":["12.9","14.9"],"labelName":"summileageYear","range":[["11","12.01"],["13","14.5"]]}]}
2:前端table 显示
3:代码实现
/**
* 新建任务:请求大叔平台(车辆数与开始任务)
*
* @param dto
* @return
*/
private SearchVinsDto queryBigDataPlatByVehData(VehNumsDto dto) {
/**
* 1 格式化标签table(列表精确/范围匹配查询)
*/
SearchVinsDto svd = new SearchVinsDto();
String body = JSON.toJSONString(dto.getTableData());
System.out.println(dto.getTableData());
System.err.println(body);
List fmList = JSON.parseArray(body, FieldsMatchInfo.class);
System.err.println(JSON.toJSONString(fmList));
/* *
* 1.1 根据表格每一行组合标签条件(LabelCondition);根据labelName进行分组:把各条件参数组合一个{}对象里面
* branchMapList:封装的组合标签条件map
*/
Map>>> branchMapList = new HashMap>>>();//标签名的map
/* *
* 1.1.2 fmList: 最基本的table列表data list
*/
for (FieldsMatchInfo fm: fmList) {
/* *
* 1.1.3 groupBranchMap: 各分支的分组的map
* 把列表项组合到map分组map中
*/
Map> groupBranchMap = new HashMap>();//精确查询分支map
if (StringUtils.isNotBlank(fm.getExtractMode())) {//存在取值方式
/* *
* 1.1.3 取值方式两种条件: 1: range是范围: 上下限 2: 其他:精确(exacts是精确 exclude是排除 fuzzy是模糊查询,fuzzyExclude模糊排除)
*/
if(Consts.LABEL_MODE_RANGE.equals(fm.getExtractMode())){
// List cc=new ArrayList(2);
// cc.add(fm.getLowerLimit());
// cc.add(fm.getUpperLimit());
// String[] str=new String[]{fm.getLowerLimit(),fm.getUpperLimit()};
// String cc=Arrays.toString(str);
// String cc= JSON.toJSONString(str)
String str=fm.getLowerLimit()+","+fm.getUpperLimit();
this.putAdd(groupBranchMap,fm.getExtractMode(),str);// 封装一key对数组value
}else{
this.putAdd(groupBranchMap,fm.getExtractMode(), fm.getExactMatch());// 封装一key对多数组value
}
}
/* *
* 1.2 组合groupBranchMap: 到集合branchMapList里
* branchMapList封装整个条件列表属性,colName作为key,根据key分组
*/
putAddMapList(branchMapList,fm.getColName(),groupBranchMap);//单个标签名
}
/* *
* 1.3 遍历:集合branchMapList,查询组合groupBranchMap的条件项进行 restful body数据格式的组合
* labelConditions 参数传递集合类
*/
List labelConditions=new ArrayList();
for (String labelName : branchMapList.keySet()) {// -级循环
/* *
* 1.3.1 groupBranchMap(各分支的分组的map):一级遍历map中;
* 把列表项拆分到map分组map中
* new List: 组合参数类型
*/
System.out.println("一级遍历map中的labelName|"+labelName);
LabelCondition lc=new LabelCondition();
lc.setLabelName(labelName);
List