Commit 84833a54 by zhangkb

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

parent a7423b56
......@@ -22,8 +22,7 @@ public class IndicatorsRelCtrl {
@ApiOperation(value = "根据指标id获取指标关系,type:0 基础指标 1考核指标", notes = "根据指标id获取指标关系,type:0 基础指标 1考核指标")
@PostMapping(value = "/getRelByIndId")
public Map<String,Object> getRelByIndId(@RequestParam String indId,@RequestParam String type,
@RequestParam String incluSelf){
return indRelService.getRelByIndId(indId, type, incluSelf);
public Map<String,Object> getRelByIndId(@RequestParam String indId,@RequestParam String type){
return indRelService.getRelByIndId(indId, type);
}
}
package com.keymobile.indicators.model.entity.indicators;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.Id;
import javax.persistence.Table;
......@@ -34,4 +36,6 @@ public class BaseIndDef {
private String version;//版本号
private Integer catalogId;//挂靠目录id
private String catalogIdPath;//挂靠目录idPath,方便用目录类别找到对应的挂靠指标
private List<BaseIndDef> children = new ArrayList<>();//子基础项
}
......@@ -33,82 +33,45 @@ public class IndicatorsRelService {
@Autowired
private IndicatorsRelMapper indicatorsRelMapper;
//incluSelf:表示是否包含自己 0:否 1:是
//type:0 基础指标 1:考核指标
@SuppressWarnings("unchecked")
public Map<String,Object> getRelByIndId(String indId,String type,String incluSelf){
public Map<String,Object> getRelByIndId(String indId,String type){
Map<String,Object> resultMap = new HashMap<>();
List<BaseIndDef> resultList = new ArrayList<>();
//先从库里找,找不到再分析公式然后保存进库里
List<IndicatorsRel> indRels = indicatorsRelMapper.findByIndId(indId);
if(indRels.isEmpty()) {
resultMap = this.getRelFromFormula(indId, type, incluSelf);
resultList = this.getRelFromFormula(indId,type);
}else {
String formula = null;
String formulaDesc = null;
List<String> resultIndIdList = new ArrayList<>();
//根据类型查找指标
if("0".equals(type)) {//基础指标
BaseIndDef baseIndDef = baseIndDefMapper.selectByPrimaryKey(indId);
for(IndicatorsRel indRel : indRels) {//基础指标
BaseIndDef baseIndDef = baseIndDefMapper.selectByPrimaryKey(indRel.getRelIndId());
if(baseIndDef!=null) {
formula = baseIndDef.getIndFormat();
formulaDesc = baseIndDef.getIndFormatDesc();
}
}else {//考核指标
DriveIndDef driveIndDef = driveIndDefMapper.selectByPrimaryKey(indId);
if(driveIndDef!=null) {
formula = driveIndDef.getIndFormat();
formulaDesc = driveIndDef.getIndFormatDesc();
}
}
for(IndicatorsRel indRel : indRels) {
resultIndIdList.add(indRel.getRelIndId());
//判断数据项是否包含子数据项
List<IndicatorsRel> childIndRels = indicatorsRelMapper.findByIndId(baseIndDef.getIndId());
if(!childIndRels.isEmpty()) {
List<BaseIndDef> childIndList = new ArrayList<>();
for(IndicatorsRel childIndRel : childIndRels) {
BaseIndDef childBaseIndDef = baseIndDefMapper.selectByPrimaryKey(
childIndRel.getRelIndId());
if(childBaseIndDef!=null) {
childIndList.add(childBaseIndDef);
}
}
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;
}
@SuppressWarnings("unchecked")
public Map<String,Object> getBaseIndRel(List<String> resultIndIdList,String formula){
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){
public List<BaseIndDef> getRelFromFormula(String indId,String type){
List<BaseIndDef> resultList = new ArrayList<>();
String formula = 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)) {//基础指标
BaseIndDef baseIndDef = baseIndDefMapper.selectByPrimaryKey(indId);
......@@ -123,14 +86,6 @@ public class IndicatorsRelService {
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)) {
List<String> indIdList = new ArrayList<>();
......@@ -146,17 +101,54 @@ public class IndicatorsRelService {
indRel.setIndFormatDesc(formulaDesc);
indRel.setIndType(type);
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)) {
resultIndIdList.add(indId);
}else {
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);
resultMap.put("formulaDesc", formulaDesc);
return resultMap;
}
baseIndDef.setChildren(childList);
resultList.add(baseIndDef);
}
}
}else {
if("0".equals(type)) {//基础指标
resultList.add(baseIndDefMapper.selectByPrimaryKey(indId));
}
}
return resultList;
}
//type:0 基础指标 1:考核指标
......
......@@ -45,6 +45,18 @@ eureka:
prefer-ip-address: true
hostname: 192.168.0.230
ribbon:
ReadTimeout: 180000
ConnectTimeout: 180000
OkToRetryOnAllOperations: true
MaxAutoRetries: 3
feign:
client:
config:
default:
connectTimeout: 180000
ReadTimeout: 180000
security:
permit: true
authUser: root
......@@ -57,5 +69,5 @@ mybatis:
logging:
level:
com.keymobile.indicators: debug
com.keymobile.indicators: info
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