Skip to content

Commit

Permalink
WeBankPartners#562 The system result
Browse files Browse the repository at this point in the history
  • Loading branch information
xuxuzhesi committed Jan 3, 2020
1 parent bca4bb1 commit 4df1bdf
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
/target/
*.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class UIProperties {
private Integer ciTypeIdOfUnitDesign = 3;
private Integer ciTypeIdOfUnit = 9;
private Integer ciTypeIdOfSubsys = 8;
private Integer ciTypeIdOfSystem = 7;
private String ciTypeCodeOfSubsys = "subsys";
private Integer ciTypeIdOfHost = 15;
private Integer ciTypeIdOfInstance = 14;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ public Object queryCiData(@PathVariable(value = "ci-type-id") int ciTypeId,
@PostMapping("/ci-types/{ci-type-id}/ci-data/query-by-type")
@ResponseBody
public Object queryCiDataByType(@PathVariable(value = "ci-type-id") int ciTypeId,
@RequestBody QueryRequest queryObject) {
return wrapperService.queryCiDataByType(ciTypeId, queryObject);
@RequestBody QueryRequest queryObject) {
return wrapperService.queryCiDataByType(ciTypeId, queryObject);
}

@PostMapping("/referenceCiData/{reference-attr-id}/query")
Expand Down Expand Up @@ -355,6 +355,13 @@ public List<ZoneLinkDto> getAllZoneLinkGroupByIdc() {
public Object getSystemDesigns() {
return wrapperService.getSystemDesigns();
}

@RolesAllowed({ MENU_APPLICATION_ARCHITECTURE_DESIGN, MENU_APPLICATION_DEPLOYMENT_DESIGN })
@GetMapping("/system")
@ResponseBody
public Object getSystems() {
return wrapperService.getSystems();
}

@RolesAllowed({ MENU_APPLICATION_ARCHITECTURE_DESIGN })
@PutMapping("/ci-types/{ci-type-id}/ci-data/{ci-data-id}")
Expand Down Expand Up @@ -410,19 +417,19 @@ public Object getDeployCiData(@RequestParam(value = "code-id") Integer codeId,
public Object getDeployDesignTabs() {
return wrapperService.getDeployDesignTabs();
}

@RolesAllowed({ MENU_APPLICATION_DEPLOYMENT_DESIGN })
@GetMapping("/trees/all-deploy-trees/from-subsys")
@GetMapping("/trees/all-deploy-trees/from-system")
@ResponseBody
public List<ResourceTreeDto> getAllDeployTreesFromSubSys(@RequestParam(value = "env-code") String envCode, @RequestParam(value = "system-design-guid") String systemDesignGuid) {
return wrapperService.getAllDeployTreesFromSubSys(envCode, systemDesignGuid);
public List<ResourceTreeDto> getAllDeployTreesFromSystem(@RequestParam(value = "system-guid") String systemGuid) {
return wrapperService.getAllDeployTreesFromSystem(systemGuid);
}

@RolesAllowed({ MENU_APPLICATION_DEPLOYMENT_DESIGN })
@GetMapping("/data-tree/application-deployment-design")
@GetMapping("/data-tree/application-deployment")
@ResponseBody
public List<ResourceTreeDto> getApplicationDeploymentDesignDataTree(@RequestParam(value = "system-design-guid") String systemDesignGuid, @RequestParam(value = "env-code") Integer envCodeId) {
return wrapperService.getApplicationDeploymentDesignDataTreeBySystemDesignGuidAndEnvCode(systemDesignGuid, envCodeId);
public List<ResourceTreeDto> getApplicationDeploymentDataTree(@RequestParam(value = "system-guid") String systemGuid) {
return wrapperService.getApplicationDeploymentDesignDataTreeBySystemDesignGuidAndEnvCode(systemGuid);
}

@RolesAllowed({ MENU_APPLICATION_ARCHITECTURE_DESIGN })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,9 @@ public Object getSystemDesigns() {
defaultQueryObject.getDialect().setShowCiHistory(true);
return queryCiData(uiProperties.getCiTypeIdOfSystemDesign(), defaultQueryObject);
}
public Object getSystems() {
return queryCiData(uiProperties.getCiTypeIdOfSystem(), defaultQueryObject());
}

public List<ResourceTreeDto> getAllDesignTreesFromSystemDesign(String systemDesignGuid) {
List<ResourceTreeDto> designTrees = new ArrayList<>();
Expand All @@ -1010,7 +1013,9 @@ public List<ResourceTreeDto> getAllDesignTreesFromSystemDesign(String systemDesi
}

private Filter getFixDateFilter(int systemDesignCiTypeId, QueryRequest defaultQueryRequest) {
defaultQueryRequest.getDialect().setShowCiHistory(true);
List<CiData> ciDatas = queryCiData(systemDesignCiTypeId, defaultQueryRequest).getContents();

String fixDate = (String)ciDatas.get(0).getData().get(CONSTANT_FIXED_DATE);

Filter fixDateFilter = null;
Expand Down Expand Up @@ -1296,39 +1301,39 @@ public Object getDeployDesignTabs() {
return getEnumCodesByCategoryName(uiProperties.getCatNameOfDeployDesign());
}

public List<ResourceTreeDto> getAllDeployTreesFromSubSys(String envCode, String systemDesignGuid) {
List<String> guid = Arrays.asList(systemDesignGuid.split(","));
public List<ResourceTreeDto> getAllDeployTreesFromSystem(String systemGuid) {
List<String> guid = Arrays.asList(systemGuid.split(","));
List<ResourceTreeDto> deployTrees = new ArrayList<>();
int systemDesignCiTypeId = uiProperties.getCiTypeIdOfSystemDesign();
int systemDesignCiTypeId = uiProperties.getCiTypeIdOfSystem();
int subsysCiTypeId = uiProperties.getCiTypeIdOfSubsys();
int envEnumCat = getEnumCategoryByName(uiProperties.getEnumCategoryNameOfEnv()).getCatId();


String stateEnumCode = uiProperties.getEnumCodeOfStateDelete();

int envEnumCat = getEnumCategoryByName(uiProperties.getEnumCategoryNameOfEnv()).getCatId();

String routine = null;
List<CatCodeDto> codeOfRoutines = getEnumCodeByCodeAndCategoryName(
uiProperties.getCodeOfDeployDetail(), uiProperties.getCatNameOfQueryDeployDesign());
if (codeOfRoutines.size() > 0) {
routine = codeOfRoutines.get(0).getValue();
}

if (routine == null) {
return null;
}

List<Map<String, Object>> ciDatas = getAllCiDataOfRootCi(subsysCiTypeId, envEnumCat, envCode, systemDesignCiTypeId, guid, routine);

List<Map<String, Object>> ciDatas = getAllCiDataOfRootCi(subsysCiTypeId, envEnumCat, null, systemDesignCiTypeId, guid, routine);
List<CiTypeAttrDto> attrOfSubsys = getCiTypeAttributesByCiTypeIdAndPropertyName(subsysCiTypeId, uiProperties.getPropertyNameOfState());
if (attrOfSubsys.size() == 0) {
return null;
}

int stateEnumCatOfSubsys = attrOfSubsys.get(0).getReferenceId();

for (int i = 0; i < ciDatas.size(); i++) {
Object ciData = ciDatas.get(i);
Map ciDataMap = (Map) ciData;

QueryRequest defaultQueryRequest = QueryRequest.defaultQueryObject();
defaultQueryRequest.addEqualsFilter(CmdbConstants.GUID, ciDataMap.get(CONSTANT_GUID_PATH).toString());

Expand All @@ -1338,7 +1343,7 @@ public List<ResourceTreeDto> getAllDeployTreesFromSubSys(String envCode, String
recursiveGetChildrenDataFilterState(subsysCiTypeId, stateEnumCatOfSubsys, stateEnumCode, resourceTrees, defaultQueryRequest, fixDateFilter);
deployTrees.addAll(resourceTrees);
}

return deployTrees;
}

Expand All @@ -1355,31 +1360,24 @@ private List<CatCodeDto> getEnumCodeByCodeAndCategoryName(String code, String ca
return response != null ? response.getContents() : null;
}

public List<ResourceTreeDto> getApplicationDeploymentDesignDataTreeBySystemDesignGuidAndEnvCode(String systemDesignGuid, Integer envCodeId) {
public List<ResourceTreeDto> getApplicationDeploymentDesignDataTreeBySystemDesignGuidAndEnvCode(String systemGuid) {
List<ResourceTreeDto> instanceData = new ArrayList<>();

QueryRequest systemDesignfilter = QueryRequest.defaultQueryObject();

// QueryRequest subsystemfilter = QueryRequest.defaultQueryObject();
Map<String,Object> subsystemfilter = Maps.newHashMap();

List<Integer> limitedCiTypeIdsOfGetInstanceData = Lists.newArrayList(uiProperties.getCiTypeIdOfSystemDesign(),
uiProperties.getCiTypeIdOfSubsystemDesign(),
uiProperties.getCiTypeIdOfSubsys(),
uiProperties.getCiTypeIdOfUnit(),
uiProperties.getCiTypeIdOfInstance());

systemDesignfilter.addEqualsFilter(CmdbConstants.GUID, systemDesignGuid);
// subsystemfilter.addEqualsFilter(uiProperties.getEnumCategoryNameOfEnv(), envCodeId);
Filter fixDateFilter = getFixDateFilter(uiProperties.getCiTypeIdOfSystemDesign(), systemDesignfilter);
subsystemfilter.put(uiProperties.getEnumCategoryNameOfEnv(), envCodeId);
systemDesignfilter.addEqualsFilter(CmdbConstants.GUID, systemGuid);
getBottomChildrenDataByBottomCiTypeId(uiProperties.getCiTypeIdOfSystemDesign(),
uiProperties.getCiTypeIdOfInstance(),
instanceData,
limitedCiTypeIdsOfGetInstanceData,
systemDesignfilter,
subsystemfilter,
fixDateFilter);
null);

List<CiTypeAttrDto> relateCiAttrDtoList = getRefToAttrByCiTypeIdAndRefName(uiProperties.getCiTypeIdOfInstance(), uiProperties.getReferenceCodeOfRunning());
if (relateCiAttrDtoList.size() == 0 || relateCiAttrDtoList.get(0) == null) {
Expand All @@ -1406,12 +1404,7 @@ public List<ResourceTreeDto> getApplicationDeploymentDesignDataTreeBySystemDesig
}

private void getBottomChildrenDataByBottomCiTypeId(Integer ciTypeId, Integer bottomCiTypeId, List<ResourceTreeDto> bottomChildrenData, List<Integer> limitedCiTypeIds, QueryRequest queryRequest,
Map<String, Object> subsystemFilters,Filter fixDateFilter) {
AdmCiType admCiType = staticEntityRepository.findEntityById(AdmCiType.class,
ciTypeId);
if (uiProperties.getCiTypeCodeOfSubsys().equals(admCiType.getTableName())) {
queryRequest.addEqualsFilters(subsystemFilters);
}
Filter fixDateFilter) {
setQueryRequest(queryRequest, fixDateFilter);
List<CiData> ciDatas = queryCiData(ciTypeId, queryRequest).getContents();
if (ciTypeId.equals(bottomCiTypeId)) {
Expand All @@ -1427,28 +1420,28 @@ private void getBottomChildrenDataByBottomCiTypeId(Integer ciTypeId, Integer bot
Map<String, Object> ciDataMap = ciData.getData();
List<CiTypeAttrDto> childrenCiTypeRelativeAttributes = findChildrenCiTypeRelativeAttributes(ciTypeId, uiProperties.getReferenceCodeOfBelong());
if (childrenCiTypeRelativeAttributes.size() != 0 && ciDataMap.get(CmdbConstants.GUID) != null) {
findBelongCi = getBottomChildrenDataByRelativeAttributes(childrenCiTypeRelativeAttributes, limitedCiTypeIds, ciDataMap.get(CmdbConstants.GUID).toString(), bottomChildrenData, bottomCiTypeId, subsystemFilters, fixDateFilter);
findBelongCi = getBottomChildrenDataByRelativeAttributes(childrenCiTypeRelativeAttributes, limitedCiTypeIds, ciDataMap.get(CmdbConstants.GUID).toString(), bottomChildrenData, bottomCiTypeId, fixDateFilter);
}

if (!findBelongCi) {
List<CiTypeAttrDto> realizeCiTypeRelativeAttributes = findRealizeCiAttributesByCiTypeId(ciTypeId);
if (realizeCiTypeRelativeAttributes.size() != 0 && ciDataMap.get(CmdbConstants.GUID) != null) {
getBottomChildrenDataByRealizeAttributes(realizeCiTypeRelativeAttributes, limitedCiTypeIds, ciDataMap.get(CmdbConstants.GUID).toString(), bottomChildrenData, bottomCiTypeId, subsystemFilters, fixDateFilter);
getBottomChildrenDataByRealizeAttributes(realizeCiTypeRelativeAttributes, limitedCiTypeIds, ciDataMap.get(CmdbConstants.GUID).toString(), bottomChildrenData, bottomCiTypeId, fixDateFilter);
}
}
}
}

private void getBottomChildrenDataByRealizeAttributes(List<CiTypeAttrDto> realizeCiTypeRelativeAttributes, List<Integer> limitedCiTypeIds, String guid, List<ResourceTreeDto> bottomChildrenData, Integer bottomCiTypeId,
Map<String, Object> subsystemFilters, Filter fixDateFilter) {
Filter fixDateFilter) {
for (CiTypeAttrDto realizeCiTypeRelativeAttribute : realizeCiTypeRelativeAttributes) {
if (!limitedCiTypeIds.contains(realizeCiTypeRelativeAttribute.getCiTypeId())) {
continue;
}

QueryRequest filter = QueryRequest.defaultQueryObject();
filter.addEqualsFilter(realizeCiTypeRelativeAttribute.getPropertyName(), guid);
getBottomChildrenDataByBottomCiTypeId(realizeCiTypeRelativeAttribute.getCiTypeId(), bottomCiTypeId, bottomChildrenData, limitedCiTypeIds, filter, subsystemFilters, fixDateFilter);
getBottomChildrenDataByBottomCiTypeId(realizeCiTypeRelativeAttribute.getCiTypeId(), bottomCiTypeId, bottomChildrenData, limitedCiTypeIds, filter, fixDateFilter);
}
}

Expand All @@ -1465,17 +1458,14 @@ private List<CiTypeAttrDto> findRealizeCiAttributesByCiTypeId(Integer ciTypeId)
}

private boolean getBottomChildrenDataByRelativeAttributes(List<CiTypeAttrDto> childrenCiTypeRelativeAttributes, List<Integer> limitedCiTypeIds, String guid, List<ResourceTreeDto> bottomChildrenData, Integer bottomCiTypeId,
Map<String, Object> subsystemFilters, Filter fixDateFilter) {
Filter fixDateFilter) {
for (CiTypeAttrDto childrenCiTypeRelativeAttribute : childrenCiTypeRelativeAttributes) {
QueryRequest filter = QueryRequest.defaultQueryObject();
if (!limitedCiTypeIds.contains(childrenCiTypeRelativeAttribute.getCiTypeId())) {
continue;
}
if (childrenCiTypeRelativeAttribute.getCiTypeId().equals(uiProperties.getCiTypeIdOfSubsys())) {
filter.addEqualsFilters(subsystemFilters);
}
filter.addEqualsFilter(childrenCiTypeRelativeAttribute.getPropertyName(), guid);
getBottomChildrenDataByBottomCiTypeId(childrenCiTypeRelativeAttribute.getCiTypeId(), bottomCiTypeId, bottomChildrenData, limitedCiTypeIds, filter, subsystemFilters, fixDateFilter);
getBottomChildrenDataByBottomCiTypeId(childrenCiTypeRelativeAttribute.getCiTypeId(), bottomCiTypeId, bottomChildrenData, limitedCiTypeIds, filter, fixDateFilter);
return true;
}
return false;
Expand Down Expand Up @@ -1591,7 +1581,6 @@ public List<ResourceTreeDto> getApplicationFrameworkDesignDataTreeBySystemDesign
unitDesignDatas,
getSameCiTypesByCiTypeId(uiProperties.getCiTypeIdOfSystemDesign()),
defaultQueryObject,
new HashMap<>(),
fixDateFilter);

List<ResourceTreeDto> allIdcDesignDatas = getAllIdcDesignTrees();
Expand Down

0 comments on commit 4df1bdf

Please sign in to comment.