Commit 84833a54 by zhangkb

修改标签关系接口和配置文件添加接口调用超时配置

parent a7423b56
...@@ -22,8 +22,7 @@ public class IndicatorsRelCtrl { ...@@ -22,8 +22,7 @@ public class IndicatorsRelCtrl {
@ApiOperation(value = "根据指标id获取指标关系,type:0 基础指标 1考核指标", notes = "根据指标id获取指标关系,type:0 基础指标 1考核指标") @ApiOperation(value = "根据指标id获取指标关系,type:0 基础指标 1考核指标", notes = "根据指标id获取指标关系,type:0 基础指标 1考核指标")
@PostMapping(value = "/getRelByIndId") @PostMapping(value = "/getRelByIndId")
public Map<String,Object> getRelByIndId(@RequestParam String indId,@RequestParam String type, public Map<String,Object> getRelByIndId(@RequestParam String indId,@RequestParam String type){
@RequestParam String incluSelf){ return indRelService.getRelByIndId(indId, type);
return indRelService.getRelByIndId(indId, type, incluSelf);
} }
} }
package com.keymobile.indicators.model.entity.indicators; package com.keymobile.indicators.model.entity.indicators;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
...@@ -34,4 +36,6 @@ public class BaseIndDef { ...@@ -34,4 +36,6 @@ public class BaseIndDef {
private String version;//版本号 private String version;//版本号
private Integer catalogId;//挂靠目录id private Integer catalogId;//挂靠目录id
private String catalogIdPath;//挂靠目录idPath,方便用目录类别找到对应的挂靠指标 private String catalogIdPath;//挂靠目录idPath,方便用目录类别找到对应的挂靠指标
private List<BaseIndDef> children = new ArrayList<>();//子基础项
} }
...@@ -33,82 +33,45 @@ public class IndicatorsRelService { ...@@ -33,82 +33,45 @@ public class IndicatorsRelService {
@Autowired @Autowired
private IndicatorsRelMapper indicatorsRelMapper; private IndicatorsRelMapper indicatorsRelMapper;
//incluSelf:表示是否包含自己 0:否 1:是
//type:0 基础指标 1:考核指标 //type:0 基础指标 1:考核指标
@SuppressWarnings("unchecked") public Map<String,Object> getRelByIndId(String indId,String type){
public Map<String,Object> getRelByIndId(String indId,String type,String incluSelf){
Map<String,Object> resultMap = new HashMap<>(); Map<String,Object> resultMap = new HashMap<>();
List<BaseIndDef> resultList = new ArrayList<>();
//先从库里找,找不到再分析公式然后保存进库里 //先从库里找,找不到再分析公式然后保存进库里
List<IndicatorsRel> indRels = indicatorsRelMapper.findByIndId(indId); List<IndicatorsRel> indRels = indicatorsRelMapper.findByIndId(indId);
if(indRels.isEmpty()) { if(indRels.isEmpty()) {
resultMap = this.getRelFromFormula(indId, type, incluSelf); resultList = this.getRelFromFormula(indId,type);
}else { }else {
String formula = null; for(IndicatorsRel indRel : indRels) {//基础指标
String formulaDesc = null; BaseIndDef baseIndDef = baseIndDefMapper.selectByPrimaryKey(indRel.getRelIndId());
List<String> resultIndIdList = new ArrayList<>();
//根据类型查找指标
if("0".equals(type)) {//基础指标
BaseIndDef baseIndDef = baseIndDefMapper.selectByPrimaryKey(indId);
if(baseIndDef!=null) { if(baseIndDef!=null) {
formula = baseIndDef.getIndFormat(); //判断数据项是否包含子数据项
formulaDesc = baseIndDef.getIndFormatDesc(); List<IndicatorsRel> childIndRels = indicatorsRelMapper.findByIndId(baseIndDef.getIndId());
} if(!childIndRels.isEmpty()) {
}else {//考核指标 List<BaseIndDef> childIndList = new ArrayList<>();
DriveIndDef driveIndDef = driveIndDefMapper.selectByPrimaryKey(indId); for(IndicatorsRel childIndRel : childIndRels) {
if(driveIndDef!=null) { BaseIndDef childBaseIndDef = baseIndDefMapper.selectByPrimaryKey(
formula = driveIndDef.getIndFormat(); childIndRel.getRelIndId());
formulaDesc = driveIndDef.getIndFormatDesc(); if(childBaseIndDef!=null) {
} childIndList.add(childBaseIndDef);
} }
for(IndicatorsRel indRel : indRels) { }
resultIndIdList.add(indRel.getRelIndId()); baseIndDef.setChildren(childIndList);
resultList.add(baseIndDef);
}else {
resultList.addAll(this.getRelFromFormula(baseIndDef.getIndId(),"0"));
} }
//循环找出基础指标包含的指标
Map<String,Object> resultBaseRelMap = this.getBaseIndRel(resultIndIdList, formula);
resultIndIdList.addAll((List<String>)resultBaseRelMap.get("resultIndIdList"));
if(resultBaseRelMap.get("formula")!=null &&
!"".equals(resultBaseRelMap.get("formula"))) {
formula = resultBaseRelMap.get("formula").toString();
} }
if("1".equals(incluSelf)) {
resultIndIdList.add(indId);
} }
resultMap.put("ind_type", type);
resultMap.put("formula", formula);
resultMap.put("formulaDesc", formulaDesc);
resultMap.put("indIdList",resultIndIdList);
} }
resultMap.put("indList", resultList);
return resultMap; return resultMap;
} }
@SuppressWarnings("unchecked") public List<BaseIndDef> getRelFromFormula(String indId,String type){
public Map<String,Object> getBaseIndRel(List<String> resultIndIdList,String formula){ List<BaseIndDef> resultList = new ArrayList<>();
Map<String,Object> result = new HashMap<>();
List<String> resultRelIndList = new ArrayList<>();
for(String indId : resultIndIdList) {
Map<String,Object> relIndIdMap = this.getRelFromFormula(indId, "0", "0");
if(relIndIdMap.get("formula")!=null && !"".equals(relIndIdMap.get("formula"))) {
String relIndFormula = relIndIdMap.get("formula").toString();
List<String> relIndList = (List<String>)relIndIdMap.get("indIdList");
resultRelIndList.addAll(relIndList);
formula = formula.replace("["+indId+"]", "("+relIndFormula+")");
}
}
result.put("resultIndIdList", resultRelIndList);
result.put("formula", formula);
return result;
}
public Map<String,Object> getRelFromFormula(String indId,String type,String incluSelf){
String formula = null; String formula = null;
String formulaDesc = null; String formulaDesc = null;
List<String> resultIndIdList = new ArrayList<>();
Map<String,Object> resultMap = new HashMap<>();
resultMap.put("indIdList",new ArrayList<>());
resultMap.put("formula", formula);
resultMap.put("formulaDesc", formulaDesc);
//判断该指标有没有保存了关联指标
List<IndicatorsRel> indRels = indicatorsRelMapper.findByIndId(indId);
//根据类型查找指标 //根据类型查找指标
if("0".equals(type)) {//基础指标 if("0".equals(type)) {//基础指标
BaseIndDef baseIndDef = baseIndDefMapper.selectByPrimaryKey(indId); BaseIndDef baseIndDef = baseIndDefMapper.selectByPrimaryKey(indId);
...@@ -123,14 +86,6 @@ public class IndicatorsRelService { ...@@ -123,14 +86,6 @@ public class IndicatorsRelService {
formulaDesc = driveIndDef.getIndFormatDesc(); formulaDesc = driveIndDef.getIndFormatDesc();
} }
} }
if(!indRels.isEmpty()) {
for(IndicatorsRel rel : indRels) {
resultIndIdList.add(rel.getRelIndId());
}
if("1".equals(incluSelf)) {
resultIndIdList.add(indId);
}
}else {
//解析公式关系 //解析公式关系
if(StringUtils.isNotBlank(formula)) { if(StringUtils.isNotBlank(formula)) {
List<String> indIdList = new ArrayList<>(); List<String> indIdList = new ArrayList<>();
...@@ -146,17 +101,54 @@ public class IndicatorsRelService { ...@@ -146,17 +101,54 @@ public class IndicatorsRelService {
indRel.setIndFormatDesc(formulaDesc); indRel.setIndFormatDesc(formulaDesc);
indRel.setIndType(type); indRel.setIndType(type);
indicatorsRelMapper.insert(indRel); indicatorsRelMapper.insert(indRel);
resultIndIdList.add(relIndId);
BaseIndDef baseIndDef = baseIndDefMapper.selectByPrimaryKey(relIndId);
if(baseIndDef!=null) {
//解析基础项关联的子基础项
//判断该指标有没有保存了关联指标
List<IndicatorsRel> indRels = indicatorsRelMapper.findByIndId(baseIndDef.getIndId());
List<BaseIndDef> childList = new ArrayList<>();
if(!indRels.isEmpty()) {
for(IndicatorsRel indR : indRels) {
BaseIndDef childBaseIndDef = baseIndDefMapper.selectByPrimaryKey(indR.getRelIndId());
if(childBaseIndDef!=null) {
childList.add(childBaseIndDef);
}
} }
if("1".equals(incluSelf)) { }else {
resultIndIdList.add(indId); if(StringUtils.isNotBlank(baseIndDef.getIndFormat())) {
//解析基础指标公式
List<String> indIdList1 = new ArrayList<>();
Matcher m1 = P.matcher(baseIndDef.getIndFormat());
while(m1.find()){
indIdList1.add(m1.group().substring(1, m1.group().length()-1));
}
for(String relIndId1 : indIdList1) {
IndicatorsRel indRel1 = new IndicatorsRel();
indRel1.setIndId(baseIndDef.getIndId());
indRel1.setRelIndId(relIndId1);
indRel1.setIndFormat(baseIndDef.getIndFormat());
indRel1.setIndFormatDesc(baseIndDef.getIndFormatDesc());
indRel1.setIndType("0");
indicatorsRelMapper.insert(indRel1);
BaseIndDef childBaseIndDef = baseIndDefMapper.selectByPrimaryKey(relIndId1);
if(childBaseIndDef!=null) {
childList.add(childBaseIndDef);
} }
} }
} }
resultMap.put("indIdList",resultIndIdList); }
resultMap.put("formula", formula); baseIndDef.setChildren(childList);
resultMap.put("formulaDesc", formulaDesc); resultList.add(baseIndDef);
return resultMap; }
}
}else {
if("0".equals(type)) {//基础指标
resultList.add(baseIndDefMapper.selectByPrimaryKey(indId));
}
}
return resultList;
} }
//type:0 基础指标 1:考核指标 //type:0 基础指标 1:考核指标
......
...@@ -45,6 +45,18 @@ eureka: ...@@ -45,6 +45,18 @@ eureka:
prefer-ip-address: true prefer-ip-address: true
hostname: 192.168.0.230 hostname: 192.168.0.230
ribbon:
ReadTimeout: 180000
ConnectTimeout: 180000
OkToRetryOnAllOperations: true
MaxAutoRetries: 3
feign:
client:
config:
default:
connectTimeout: 180000
ReadTimeout: 180000
security: security:
permit: true permit: true
authUser: root authUser: root
...@@ -57,5 +69,5 @@ mybatis: ...@@ -57,5 +69,5 @@ mybatis:
logging: logging:
level: level:
com.keymobile.indicators: debug com.keymobile.indicators: info
config: classpath:logback-custom.xml config: classpath:logback-custom.xml
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment