|
@@ -1,6 +1,8 @@
|
|
|
package com.jd.service.impl;
|
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.jd.client.ThreeApiClient;
|
|
|
import com.jd.code.ConstString;
|
|
|
import com.jd.entity.SafetyInfo;
|
|
|
import com.jd.mapper.*;
|
|
@@ -58,6 +60,9 @@ public class SafetyInfoServiceImpl implements SafetyInfoService {
|
|
|
@Autowired
|
|
|
private BasicDataMapper basicDataMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ThreeApiClient threeApiClient;
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Object> getSafetyInfo(Map<String, Object> param) {
|
|
|
Integer count = safetyInfoMapper.getCountSafetyInfo(param);
|
|
@@ -248,7 +253,39 @@ public class SafetyInfoServiceImpl implements SafetyInfoService {
|
|
|
safetyLevel = 1;
|
|
|
}
|
|
|
//计算风险系数
|
|
|
+ Integer riskCoefficient = 0;
|
|
|
+ //获取风险系数计算规则
|
|
|
+ // 风险系数规则分割值1
|
|
|
+ Integer riskFlag_1 = 0;
|
|
|
+ // 风险系数规则分割值2
|
|
|
+ Integer riskFlag_2 = 0;
|
|
|
+ //获取风险系数计算规则
|
|
|
+ List<Map<String, Object>> riskBasicMap = basicDataMapper.vagBasicDataByType("FXXS");
|
|
|
+ for (Map<String, Object> map : riskBasicMap) {
|
|
|
+ if (map.get("data_key").equals("FXXS_001")){
|
|
|
+ riskFlag_1 = Convert.toInt(map.get("data_value").toString());
|
|
|
+ }else if (map.get("data_key").equals("FXXS_002")){
|
|
|
+ riskFlag_2 = Convert.toInt(map.get("data_value").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String urlCode = "AQZX_";
|
|
|
+ String params = "{\"sex\":\"男\",\"name\":\"赵云\"," +
|
|
|
+ "\"project\":\"pe_powerup_prod\"}";
|
|
|
+ //通过threeAPI调用第三方接口
|
|
|
+ Map<String, Object> apiMap = threeApiClient.sendApiUrlAndParam(urlCode, params);
|
|
|
+ Map<String, Object> attackInfoMap = JSONObject.parseObject(apiMap.get("data").toString());
|
|
|
+ Map<String, Object> attackMap = JSONObject.parseObject(attackInfoMap.get("data").toString());
|
|
|
+ //风险系数
|
|
|
+ Integer attackHighNum = Convert.toInt(attackMap.get("High").toString());
|
|
|
+ if(attackHighNum < riskFlag_1){
|
|
|
+ riskCoefficient = 1;
|
|
|
+ }else if (attackHighNum > riskFlag_1 && attackHighNum < riskFlag_2){
|
|
|
+ riskCoefficient = 2;
|
|
|
+ }else {
|
|
|
+ riskCoefficient = 3;
|
|
|
+ }
|
|
|
resultMap.put("safetyLevel", safetyLevel);
|
|
|
+ resultMap.put("riskCoefficient", riskCoefficient);
|
|
|
return SendUtil.send(resultMap);
|
|
|
}
|
|
|
|