Commit eabbf0fd by zhangkb

添加系统分析接口

parent 88a82232
......@@ -2,7 +2,6 @@ package com.keymobile.tagmanager.api;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletResponse;
......@@ -339,6 +338,12 @@ public class TagCtrl {
return tagService.getDimensionRootTag(orgIds);
}
@ApiOperation(value = "(2020-8-14)分析系统", notes = "(2020-8-14)分析系统")
@PostMapping(value = "/analysisSystem")
public Map<String,Map<String,Object>> analysisSystem(@RequestParam Long domainId)throws Exception{
return tagService.analysisSystem(domainId);
}
//---------------以下为导入系统的时候用到------------------
@ApiOperation(value = "查询系统标签", notes = "查询系统标签")
@GetMapping(value = "/listSystems")
......
......@@ -24,4 +24,7 @@ public interface AuthServiceClient {
@GetMapping(value = "/domains/{domainId}/scopes/{scopeId}")
public Map<String,Object> getScopes(@PathVariable("domainId") Long domainId,
@PathVariable("scopeId") Long scopeId);
@GetMapping(value = "/domains/{domainId}/scopes")
public List<Map<String,Object>> getScopesList(@PathVariable("domainId") Long domainId);
}
package com.keymobile.tagmanager.service;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
......@@ -1025,4 +1026,90 @@ public class TagService {
mongoOperations.save(sysTag);
return sysTag;
}
private Map<String,Object> analysisSystemInfo(String plate,List<Map<String,Object>> systemDetail){
Map<String,Object> systemInfo = new HashMap<>();
systemInfo.put("total", 0);//属于某个板块的系统数
systemInfo.put("totalRate", 0.0);//属于某个板块的系统数和板块系统总数比值
systemInfo.put("unExtract", 0);//属于某个板块未抽取系统数
systemInfo.put("unExtractRate", 0.0);//属于某个板块未抽取系统数和某个板块总系统数比值
systemInfo.put("extract", 0);//属于某个板块已抽取系统数
systemInfo.put("extractRate", 0.0);//属于某个板块已抽取系统数和某个板块总系统数比值
systemInfo.put("extractTable", 0);//属于某个板块系统抽取的表数量
systemInfo.put("extractColumn", 0);//属于某个板块系统抽取的字段数量
if(!systemDetail.isEmpty()) {
int plateSystemNum = 0;
int unExtractSysNum = 0;
int extractTable = 0;
int extractColumn = 0;
for(Map<String,Object> map : systemDetail) {
if(plate.equals(map.get("plate"))) {
plateSystemNum+=1;
if(!(boolean)map.get("hasExtract")) {
unExtractSysNum+=1;
}
extractTable+=Integer.parseInt(map.get("tableNum").toString());
extractColumn+=Integer.parseInt(map.get("columnNum").toString());
}
}
if(plateSystemNum>0) {
systemInfo.put("total", plateSystemNum);
systemInfo.put("totalRate", new DecimalFormat("#.00")
.format(plateSystemNum*1.0/systemDetail.size()*100));
systemInfo.put("unExtract", unExtractSysNum);
systemInfo.put("unExtractRate", new DecimalFormat("#.00")
.format(unExtractSysNum*1.0/plateSystemNum*100));
systemInfo.put("extract", plateSystemNum-unExtractSysNum);
systemInfo.put("extractRate", new DecimalFormat("#.00")
.format((plateSystemNum-unExtractSysNum)*1.0/plateSystemNum*100));
}
systemInfo.put("extractTable", extractTable);
systemInfo.put("extractColumn", extractColumn);
}
return systemInfo;
}
//系统分析
@SuppressWarnings("unchecked")
public Map<String,Map<String,Object>> analysisSystem(Long domainId)throws Exception{
//初始化result
Map<String,Map<String,Object>> result = new HashMap<>();
//获取所有系统
List<Map<String,Object>> systems = authService.getScopesList(domainId);
List<Map<String,Object>> systemDetail = new ArrayList<>();
for(Map<String,Object> map : systems) {
if(map.get("options")!=null) {
Map<String,Object> options = (Map<String,Object>)map.get("options");
if(options.get("plate")!=null) {
Map<String,Object> detail = new HashMap<>();
detail.put("plate",options.get("plate"));
//是否抽取
if(options.get("hasExtract")!=null) {
detail.put("hasExtract",options.get("hasExtract"));
}else {
detail.put("hasExtract",false);
}
//表数量
if(options.get("tableNum")!=null) {
detail.put("tableNum",options.get("tableNum"));
}else {
detail.put("tableNum",0);
}
//字段数量
if(options.get("columnNum")!=null) {
detail.put("columnNum",options.get("columnNum"));
}else {
detail.put("columnNum",0);
}
systemDetail.add(detail);
}
}
}
result.put("E", this.analysisSystemInfo("E", systemDetail));
result.put("P", this.analysisSystemInfo("P", systemDetail));
result.put("C", this.analysisSystemInfo("C", systemDetail));
result.put("S", this.analysisSystemInfo("S", systemDetail));
result.put("M", this.analysisSystemInfo("M", systemDetail));
return result;
}
}
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