Commit 4ab95f48 authored by KeYong's avatar KeYong

更新

parent 7236b3fe
......@@ -51,6 +51,7 @@ public class GatewayIdAutowiredAspect {
if (args.length == 1) {
Object arg = args[0];
List<String> ids = permissionService.getCurrentUserPermissions();
// List<String> ids = Arrays.asList("1668801435891929089");
//获取字段域
Field[] fields = arg.getClass().getDeclaredFields();
log.info("getDeclaredFields: {}", JSON.toJSONString(fields));
......
package com.yeejoin.amos.boot.module.jxiop.api.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* @author keyong
* @title: BaseCondition
* <pre>
* @description: TODO
* </pre>
* @date 2024/2/20 18:06
*/
public class BaseCondition {
private String field;
private Operate operator;
private Object value;
@JsonIgnore
private String sqlOp;
public String getField() {
return this.field;
}
public void setField(String field) {
this.field = field;
}
public Operate getOperator() {
return this.operator;
}
public void setOperator(Operate operator) {
this.operator = operator;
}
public Object getValue() {
return this.value;
}
public void setValue(Object value) {
this.value = value;
}
public String getSqlOp() {
return this.operator.getSqlOp();
}
public void setSqlOp(String sqlOp) {
this.sqlOp = sqlOp;
}
}
package com.yeejoin.amos.boot.module.jxiop.api.dto;
/**
* @author keyong
* @title: Operate
* <pre>
* @description: TODO
* </pre>
* @date 2024/2/20 18:07
*/
public enum Operate {
eq("="),
like("like"),
likeLeft("like"),
likeRight("like"),
in("in");
private String sqlOp;
Operate(String sqlOp) {
this.sqlOp = sqlOp;
}
public String getSqlOp() {
return this.sqlOp;
}
}
package com.yeejoin.amos.boot.module.jxiop.api.dto;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.warning.feign.model.BaseCondition;
import java.util.List;
import java.util.Objects;
public class RectificationUnitClassifyTreeDto extends BaseDto {
private String name;
private String code;
private String parentId;
private Integer sort;
private String nodeType;
List<BaseCondition> conditions;
private List<com.yeejoin.amos.boot.module.jxiop.api.dto.RectificationUnitClassifyTreeDto> children;
public void setName(String name) {
this.name = name;
}
public void setCode(String code) {
this.code = code;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public void setNodeType(String nodeType) {
this.nodeType = nodeType;
}
public void setConditions(List<BaseCondition> conditions) {
this.conditions = conditions;
}
public void setChildren(List<com.yeejoin.amos.boot.module.jxiop.api.dto.RectificationUnitClassifyTreeDto> children) {
this.children = children;
}
public String toString() {
return "RectificationUnitClassifyTreeDto(name=" + getName() + ", code=" + getCode() + ", parentId=" + getParentId() + ", sort=" + getSort() + ", nodeType=" + getNodeType() + ", conditions=" + getConditions() + ", children=" + getChildren() + ")";
}
public String getName() {
return this.name;
}
public String getCode() {
return this.code;
}
public String getParentId() {
return this.parentId;
}
public Integer getSort() {
return this.sort;
}
public String getNodeType() {
return this.nodeType;
}
public List<BaseCondition> getConditions() {
return this.conditions;
}
public List<com.yeejoin.amos.boot.module.jxiop.api.dto.RectificationUnitClassifyTreeDto> getChildren() {
return this.children;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RectificationUnitClassifyTreeDto r = (RectificationUnitClassifyTreeDto) o;
return Objects.equals(code, r.code);
}
}
package com.yeejoin.amos.boot.module.jxiop.api.feign;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.dto.RectificationUnitClassifyTreeDto;
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -12,7 +13,7 @@ import java.util.List;
import java.util.Map;
@FeignClient(name = "${mcb.warning.name:MCB-SERVER}", path = "warning", configuration = {FeignConfiguration.class})
@FeignClient(name = "${mcb.warning.name:MCB-SERVER}", path = "warning", configuration = {FeignConfiguration.class}, url = "http://10.20.1.160:10005")
public interface McbWarningFeign {
/**
......@@ -57,7 +58,7 @@ public interface McbWarningFeign {
* 任务详情、问题记录左侧树
*/
@GetMapping("/warning-warning-info/tree")
FeignClientResult getWarnTree(@RequestParam Map<String, Object> map);
FeignClientResult<List<RectificationUnitClassifyTreeDto>> getWarnTree();
/**
* 任务详情列表统计
......@@ -71,4 +72,12 @@ public interface McbWarningFeign {
@GetMapping("/warning-question-info/questionPageTopStatistics")
FeignClientResult getQuestionRecordStatistic(@RequestParam Map<String, Object> map);
/**
* 任务总览地图信息数据
*/
@GetMapping("/monitor/overview/getMapRouteInfoByCodes")
FeignClientResult getMapRouteInfoByCodes(@RequestParam String province,
@RequestParam("codes") List<String> codes,
@RequestParam(value = "operator", defaultValue = "=") String operator);
}
......@@ -75,7 +75,7 @@ public interface IMcbWarningService {
/**
* 任务详情、问题记录左侧树
*/
Object getWarnTree(Map<String, Object> map);
Object getWarnTree();
/**
* 任务详情列表统计
......@@ -87,4 +87,6 @@ public interface IMcbWarningService {
*/
Object getQuestionRecordStatistic(Map<String, Object> map);
Object getMapRouteInfoByCodes(String province, List<String> codes, String operator);
}
......@@ -24,10 +24,10 @@
<select id="queryWeekCount" resultType="java.util.Map">
SELECT
DATE_FORMAT(b.alarmDate, '%m/%d') AS alarmDate,
DATE_FORMAT(b.alarmDate, '%m/%d') AS axisData,
b.code AS code,
b.province AS province,
IFNULL(count(log.SEQUENCE_NBR), 0) AS countNum
IFNULL(count(log.SEQUENCE_NBR), 0) AS seriesData
FROM
(
SELECT
......
......@@ -81,8 +81,8 @@ public class McbWarningController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "任务详情、问题记录左侧树", notes = "任务详情、问题记录左侧树")
@GetMapping(value = "/warning-warning-info/tree")
public ResponseModel getWarnTree(@RequestParam Map<String, Object> map) {
return ResponseHelper.buildResponse(mcbWarningService.getWarnTree(map));
public ResponseModel getWarnTree() {
return ResponseHelper.buildResponse(mcbWarningService.getWarnTree());
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
......@@ -131,4 +131,12 @@ public class McbWarningController {
return ResponseHelper.buildResponse(mcbWarningService.queryMapRoutes(province));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "任务总览地图数据", notes = "任务总览地图数据")
@GetMapping(value = "/monitor/overview/getMapRouteInfoByCodes")
public ResponseModel getMapRouteInfoByCodes(@RequestParam String province,
@RequestParam("codes") List<String> codes,
@RequestParam(value = "operator", defaultValue = "=") String operator) {
return ResponseHelper.buildResponse(mcbWarningService.getMapRouteInfoByCodes(province, codes, operator));
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.dto.RectificationUnitClassifyTreeDto;
import com.yeejoin.amos.boot.module.jxiop.api.feign.McbWarningFeign;
import com.yeejoin.amos.boot.module.jxiop.api.service.IMcbWarningService;
import com.yeejoin.amos.boot.module.jxiop.api.service.IPermissionService;
import com.yeejoin.amos.boot.module.jxiop.biz.mcbwarningmapper.McbWarningMapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.warning.feign.model.BaseCondition;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class McbWarningServiceImpl implements IMcbWarningService {
......@@ -126,27 +135,72 @@ public class McbWarningServiceImpl implements IMcbWarningService {
*/
@Override
public Page<Map<String, Object>> getTaskDetailPage(Map<String, Object> map) {
map.put("GATEWAY_ID", String.format("[%s]", buildGateWayIdsParam()));
map.put("projectOrgCodes", this.getProjectOrgCodes());
FeignClientResult<Page<Map<String, Object>>> page = mcbWarningFeign.getTaskDetailPage(map);
return page.getResult();
}
/**
* 问题记录分页列表
*/
@Override
public Page<Map<String, Object>> getQuestionRecordPage(Map<String, Object> map) {
map.put("GATEWAY_ID", String.format("[%s]", buildGateWayIdsParam()));
map.put("projectOrgCodes", this.getProjectOrgCodes());
FeignClientResult<Page<Map<String, Object>>> page = mcbWarningFeign.getQuestionRecordPage(map);
return page.getResult();
}
public List<RectificationUnitClassifyTreeDto> treeToList (List<RectificationUnitClassifyTreeDto> source, List<RectificationUnitClassifyTreeDto> object){
source.stream().forEach(v ->{
RectificationUnitClassifyTreeDto t = new RectificationUnitClassifyTreeDto();
BeanUtils.copyProperties(v, t);
t.setChildren(new ArrayList());
object.add(t);
//判断该对象的getChildren()是否为空
if(!CollectionUtils.isEmpty(v.getChildren())){
treeToList(v.getChildren(), object);
}
});
return object;
}
/**
* 任务详情、问题记录左侧树
*
*/
@Override
public Object getWarnTree(Map<String, Object> map) {
map.put("GATEWAY_ID", String.format("[%s]", buildGateWayIdsParam()));
FeignClientResult result = mcbWarningFeign.getWarnTree(map);
return result.getResult();
public Object getWarnTree() {
FeignClientResult<List<RectificationUnitClassifyTreeDto>> allUnitList = mcbWarningFeign.getWarnTree();
List<RectificationUnitClassifyTreeDto> res = allUnitList.getResult();
if (CollectionUtils.isEmpty(res)) {
return new ArrayList<>();
}
List<RectificationUnitClassifyTreeDto> targetList = new ArrayList<>();
List<RectificationUnitClassifyTreeDto> tempList = treeToList(res, targetList);
List<String> codes = getProjectOrgCodes();
targetList = tempList.stream().filter(x -> {
if (CollectionUtil.isNotEmpty(codes)) {
for (String str : codes) {
if (x.getCode().startsWith(str)){
return true;
}
}
}
return false;
}).collect(Collectors.toList());
List<RectificationUnitClassifyTreeDto> listDate = new ArrayList<>();
for (RectificationUnitClassifyTreeDto t : targetList) {
if (StringUtils.isBlank(t.getParentId()) || "0".equals(t.getParentId())) {
t.setChildren(getChild(t, targetList));
}
listDate.add(t);
}
return listDate;
}
private List<RectificationUnitClassifyTreeDto> getChild(RectificationUnitClassifyTreeDto dto, List<RectificationUnitClassifyTreeDto> listDto) {
return (List<RectificationUnitClassifyTreeDto>)listDto.stream().filter(t -> t.getParentId().equals(dto.getSequenceNbr().toString())).peek(m -> m.setChildren(getChild(m, listDto))).collect(Collectors.toList());
}
/**
......@@ -155,25 +209,34 @@ public class McbWarningServiceImpl implements IMcbWarningService {
*/
@Override
public Object getTaskDetailStatistic(Map<String, Object> map) {
map.put("GATEWAY_ID", String.format("[%s]", buildGateWayIdsParam()));
map.put("projectOrgCodes", this.getProjectOrgCodes());
FeignClientResult result = mcbWarningFeign.getTaskDetailStatistic(map);
return result.getResult();
}
/**
* 问题记录统计
* 问题记录列表统计
*
*/
@Override
public Object getQuestionRecordStatistic(Map<String, Object> map) {
map.put("GATEWAY_ID", String.format("[%s]", buildGateWayIdsParam()));
map.put("projectOrgCodes", this.getProjectOrgCodes());
FeignClientResult result = mcbWarningFeign.getQuestionRecordStatistic(map);
return result.getResult();
}
/**
* 获取用户权限(此处使用projectOrgCode)
* 问题记录列表统计
*
*/
@Override
public Object getMapRouteInfoByCodes(String province, List<String> codes, String operator) {
FeignClientResult result = mcbWarningFeign.getMapRouteInfoByCodes(province, this.getProjectOrgCodes(), operator);
return result.getResult();
}
/**
* 获取用户权限(此处使用projectOrgCode)
* @return gatewayIds
*/
private List<String> getProjectOrgCodes() {
......@@ -184,16 +247,4 @@ public class McbWarningServiceImpl implements IMcbWarningService {
return projectOrgCodes;
}
private String buildGateWayIdsParam() {
List<String> currentUserPermissions = permissionService.getCurrentUserPermissions();
if (Objects.isNull(currentUserPermissions)) {
currentUserPermissions = new ArrayList<>();
}
String gatewayIds = String.join(",", currentUserPermissions);
if (!gatewayIds.isEmpty()) {
gatewayIds = String.format("[%s]", gatewayIds);
}
return Optional.ofNullable(gatewayIds).orElse("[]");
}
}
......@@ -63,7 +63,11 @@
<artifactId>amos-feign-privilege</artifactId>
<version>1.9.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>mcb-feign-warning</artifactId>
<version>2.0.2-SNAPSHOT</version>
</dependency>
<!-- druid -->
<dependency>
......
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