|
@@ -1,17 +1,20 @@
|
|
|
-package com.hhwy.qbeqsjy.kafka.service;
|
|
|
+package com.hhwy.qbeqsjy.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.JSONPath;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.hhwy.qbeqsjy.common.CommonUtil;
|
|
|
import com.hhwy.qbeqsjy.common.Constants;
|
|
|
import com.hhwy.qbeqsjy.common.HttpClient;
|
|
|
import com.hhwy.qbeqsjy.common.TimeTool;
|
|
|
+import com.hhwy.qbeqsjy.dao.CtrlDao;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.NameValuePair;
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -43,17 +46,20 @@ public class SameTravelService {
|
|
|
private String fwkfptUniQueryUrl;
|
|
|
@Value("${tx.query.max.count}")
|
|
|
private String maxReturnNum;
|
|
|
+ @Autowired
|
|
|
+ private CtrlDao ctrlDao;
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 调用烽火同行类数据通查服务接口
|
|
|
+ * 调用烽火同行类数据通查服务接口,并将查询结果保存入库
|
|
|
+ * @param taskId 任务编号
|
|
|
* @param conditionFieldValue 条件查询的字段值
|
|
|
- * @param resourceName 条件查询的数据资源标识符(烽火标准)
|
|
|
+ * @param resourceIdentifier 条件查询的数据资源标识符(烽火盘古平台标准)
|
|
|
+ * @param resourceCode 条件查询的数据资源标识符对应的数据资源编码(烽火盘古平台标准)
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<Map<String, Object>> callFHUniQueryService(String conditionFieldValue, String resourceName){
|
|
|
- List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
- // ========== 获取烽火 - 服务开放平台token
|
|
|
+ public void callFHUniQueryService(String taskId, String conditionFieldValue, String resourceIdentifier, String resourceCode){
|
|
|
+ // ========== 1.获取烽火 - 服务开放平台认证token
|
|
|
Map<String, Object> tokenHeaderParamsMap = new HashMap<>();
|
|
|
tokenHeaderParamsMap.put("Content-Type", Constants.URLENCODED_RSP_TYPE);
|
|
|
Map<String, Object> userTokenMap = new HashMap<>();
|
|
@@ -84,8 +90,8 @@ public class SameTravelService {
|
|
|
log.info("获取【烽火 - 服务开放平台 # 权限认证令牌】 令牌创建成功,响应消息:{}", content);
|
|
|
}
|
|
|
|
|
|
+ // ========== 2.调用烽火 - 同行类数据通查服务接口
|
|
|
long start = System.currentTimeMillis();
|
|
|
- // ========== 构造请求头
|
|
|
Map<String, Object> headerParamsMap = new HashMap<>();
|
|
|
headerParamsMap.put("Content-Type", Constants.DEFAULT_RSP_TYPE);
|
|
|
headerParamsMap.put("app_token", appTokenId);
|
|
@@ -94,13 +100,12 @@ public class SameTravelService {
|
|
|
headerParamsMap.put("subid", fwkfptAppId);
|
|
|
headerParamsMap.put("serviceid", fwkfptServiceId);
|
|
|
headerParamsMap.put("SenderID", fwkfptSenderId);
|
|
|
- // ========== 构造请求体
|
|
|
Map<String, Object> reqBody = new HashMap<>();
|
|
|
reqBody.put("From", Constants.AREA_CODE_TJ);
|
|
|
reqBody.put("To", Constants.AREA_CODE_TJ);
|
|
|
reqBody.put("MessageSequence", TimeTool.timeStampToDateString4(TimeTool.getNowTimeStamp()));
|
|
|
Map<String, Object> requestParam = new HashMap<>();
|
|
|
- List<String> rspFieldNameList = Arrays.asList(CommonUtil.getConfValueByKey(resourceName).split(","));
|
|
|
+ List<String> rspFieldNameList = Arrays.asList(CommonUtil.getConfValueByKey(resourceIdentifier).split(","));
|
|
|
requestParam.put("Condition", rspFieldNameList.get(0) + "='" + conditionFieldValue + "'");
|
|
|
Map<String, Object> otherCondition = new HashMap<>();
|
|
|
otherCondition.put("AsyncBoolean", Constants.STR_NUM_0);
|
|
@@ -122,14 +127,14 @@ public class SameTravelService {
|
|
|
dataItemsList.add(dataItemMap);
|
|
|
}
|
|
|
resourceInfoMap.put("DataItems", dataItemsList);
|
|
|
- resourceInfoMap.put("ResourceName", resourceName);
|
|
|
+ resourceInfoMap.put("ResourceName", resourceIdentifier);
|
|
|
resourceInfosList.add(resourceInfoMap);
|
|
|
requestParam.put("ResourceInfos", resourceInfosList);
|
|
|
reqBody.put("RequestParam", requestParam);
|
|
|
- log.info(JSON.toJSONString(reqBody, SerializerFeature.WriteMapNullValue));
|
|
|
-
|
|
|
String rspStr = httpClient.postResource(fwkfptUniQueryUrl, JSON.toJSONString(reqBody, SerializerFeature.WriteMapNullValue), headerParamsMap);
|
|
|
+ // ========== 3.解析烽火 - 同行类数据通查服务接口响应信息
|
|
|
JSONObject rspJSONObj = JSON.parseObject(rspStr);
|
|
|
+ List<JSONObject> dataList = new ArrayList<>();
|
|
|
if(rspJSONObj != null){
|
|
|
String messageStatus = rspJSONObj.getString("MessageStatus");
|
|
|
if("0200".equals(messageStatus)){
|
|
@@ -144,27 +149,37 @@ public class SameTravelService {
|
|
|
JSONArray dataItems = jsonObject.getJSONArray("DataItems");
|
|
|
for (Object obj : dataInfo) {
|
|
|
JSONArray dataRow = (JSONArray) obj;
|
|
|
- Map<String, Object> rowMap = new HashMap<>();
|
|
|
+// Map<String, Object> rowData = new HashMap<>();
|
|
|
+ JSONObject rowData = new JSONObject();
|
|
|
for (int i = 0; i < dataRow.size(); i++) {
|
|
|
Object columnValue = dataRow.get(i);
|
|
|
JSONObject columnMap = dataItems.getJSONObject(i);
|
|
|
String name = columnMap.getString("Name");
|
|
|
- rowMap.put(name, columnValue);
|
|
|
+ rowData.put(name, columnValue);
|
|
|
}
|
|
|
- dataList.add(rowMap);
|
|
|
+ dataList.add(rowData);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
log.info("【烽火 - 服务开放平台 # 同行类数据通查服务接口 响应数据解析完成】 命中数据量:{}", dataList.size());
|
|
|
- return dataList;
|
|
|
+ // ========== 4.保存入库烽火 - 同行类查询结果数据
|
|
|
+ if(dataList.size() > 0){
|
|
|
+ // 通过数据资源编码动态获取每个数据资源对应的JSON数据解析公式
|
|
|
+ String parseFormula = CommonUtil.getConfValueByKey(resourceCode);
|
|
|
+ for (JSONObject item : dataList) {
|
|
|
+
|
|
|
+ Object titles = JSONPath.eval(item, "$.store.book[*].title");
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
SameTravelService sameTravelService = new SameTravelService();
|
|
|
- sameTravelService.callFHUniQueryService("120000xxxx", "R-120000000000-00000003");
|
|
|
+ sameTravelService.callFHUniQueryService("","120000xxxx", "R-120000000000-00000003", "");
|
|
|
}
|
|
|
|
|
|
|