Merge remote-tracking branch 'origin/master'

This commit is contained in:
Lee
2023-04-11 16:25:14 +08:00
13 changed files with 202 additions and 78 deletions

View File

@@ -0,0 +1,28 @@
package com.njcn.algorithm.api;
import com.njcn.algorithm.api.fallback.DevModelFeignClientFallbackFactory;
import com.njcn.algorithm.pojo.param.CsDevModelAddParm;
import com.njcn.algorithm.pojo.param.CsDevModelQueryListParm;
import com.njcn.algorithm.pojo.vo.CsDevModelPageVO;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.ALGORITHM_BOOT, path = "/devmodel", fallbackFactory = DevModelFeignClientFallbackFactory.class,contextId = "devmodel")
public interface DevModelFeignClient {
@PostMapping("/addDevModel")
HttpResult<Boolean> addDevModel(@RequestBody @Validated CsDevModelAddParm csDevModelAddParm);
@PostMapping("/queryEquipmentByProject")
HttpResult<List<CsDevModelPageVO>> queryEquipmentByProject(@RequestBody CsDevModelQueryListParm csDevModelQueryListParm);
}

View File

@@ -0,0 +1,52 @@
package com.njcn.algorithm.api.fallback;
import com.njcn.algorithm.api.DevModelFeignClient;
import com.njcn.algorithm.api.EquipmentFeignClient;
import com.njcn.algorithm.pojo.param.CsDevModelAddParm;
import com.njcn.algorithm.pojo.param.CsDevModelQueryListParm;
import com.njcn.algorithm.pojo.vo.CsDevModelPageVO;
import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/4/10 20:09
*/
@Slf4j
@Component
public class DevModelFeignClientFallbackFactory implements FallbackFactory<DevModelFeignClient> {
@Override
public DevModelFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
// exceptionEnum = UserEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new DevModelFeignClient() {
@Override
public HttpResult<Boolean> addDevModel(CsDevModelAddParm csDevModelAddParm) {
log.error("{}异常,降级处理,异常为:{}","新增装置模板版本信息",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsDevModelPageVO>> queryEquipmentByProject(CsDevModelQueryListParm csDevModelQueryListParm) {
log.error("{}异常,降级处理,异常为:{}","查询模板版本信息",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -19,7 +19,7 @@ import lombok.Setter;
@Getter @Getter
@Setter @Setter
@TableName("r_stat_onlinerate_d") @TableName("r_stat_onlinerate_d")
public class RStatOnlinerateD extends BaseEntity { public class RStatOnlinerateD {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@MppMultiId @MppMultiId

View File

@@ -113,7 +113,11 @@
OR dev.name LIKE #{searchValueLike} OR dev.name LIKE #{searchValueLike}
OR line.NAME LIKE #{searchValueLike} OR line.NAME LIKE #{searchValueLike}
</if> </if>
ORDER BY areaId.NAME ORDER BY
gdName,
bdName,
devNAME,
objName;
</select> </select>
<select id="getRunManageDevList" resultType="com.njcn.device.pq.pojo.vo.RunTimeVO"> <select id="getRunManageDevList" resultType="com.njcn.device.pq.pojo.vo.RunTimeVO">
@@ -184,7 +188,9 @@
OR device.IP LIKE #{searchValueLike} OR device.IP LIKE #{searchValueLike}
</if> </if>
ORDER BY ORDER BY
areaId.NAME gdName,
bdName,
devName;
</select> </select>
<select id="getOnlineEvaluate" resultType="com.njcn.device.pq.pojo.vo.LineInfluxDbOnlineVO"> <select id="getOnlineEvaluate" resultType="com.njcn.device.pq.pojo.vo.LineInfluxDbOnlineVO">
SELECT SELECT

View File

@@ -167,7 +167,14 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
groupLine = childrenData.stream().collect(Collectors.groupingBy(TerminalTree::getPid)); groupLine = childrenData.stream().collect(Collectors.groupingBy(TerminalTree::getPid));
} }
targetData = targetData.stream().peek(terminalTree -> { targetData = targetData.stream().peek(terminalTree -> {
if(isLine){
//监测点的数量
int size = groupLine.get(terminalTree.getId()).size();
terminalTree.setName(terminalTree.getName()+""+size+"台装置)");
terminalTree.setChildren(groupLine.get(terminalTree.getId())); terminalTree.setChildren(groupLine.get(terminalTree.getId()));
}else{
terminalTree.setChildren(groupLine.get(terminalTree.getId()));
}
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }

View File

@@ -232,7 +232,12 @@ public class LargeScreenServiceImpl implements LargeScreenService {
downTimeVO.setCount(resultMap.get(s)); downTimeVO.setCount(resultMap.get(s));
result.add(downTimeVO); result.add(downTimeVO);
} }
return result; //集合反向循环
List<DownTimeVO> list = new ArrayList<>();
for (int i = result.size() - 1; i >= 0; i--) {
list.add(result.get(i));
}
return list;
} }
/** /**

View File

@@ -21,6 +21,12 @@
<groupId>com.njcn</groupId> <groupId>com.njcn</groupId>
<artifactId>common-core</artifactId> <artifactId>common-core</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.njcn</groupId> <groupId>com.njcn</groupId>
@@ -35,20 +41,44 @@
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId> <artifactId>spring-cloud-starter-gateway</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<!-- Sentinel流量控制、熔断降级 --> <!-- Sentinel流量控制、熔断降级 -->
<dependency> <dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId> <artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.alibaba.csp</groupId> <groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId> <artifactId>sentinel-datasource-nacos</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<!-- OAuth2资源服务器--> <!-- OAuth2资源服务器-->
@@ -63,11 +93,23 @@
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId> <artifactId>spring-security-oauth2-jose</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<!-- Api文档 --> <!-- Api文档 -->
<dependency> <dependency>
<groupId>com.github.xiaoymin</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId> <artifactId>knife4j-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -17,6 +17,7 @@ public interface THDistortionService {
/** /**
* 功能描述: 获取谐波总畸变率 * 功能描述: 获取谐波总畸变率
*
* @param thDistortionParam * @param thDistortionParam
* @return * @return
*/ */
@@ -25,10 +26,12 @@ public interface THDistortionService {
/** /**
* 功能描述: 获取总畸变率图表 * 功能描述: 获取总畸变率图表
*
* @param thDistortionCensusParam * @param thDistortionCensusParam
* @return * @return
*/ */
THDistortionCensusVO getTHDistortionCensus(DeviceInfoParam.BusinessParam thDistortionCensusParam); THDistortionCensusVO getTHDistortionCensus(DeviceInfoParam.BusinessParam thDistortionCensusParam);
/** /**
* @Description: 谐波总畸变率前topNum列表 * @Description: 谐波总畸变率前topNum列表
* @Param: [statisticsBizBaseParam] * @Param: [statisticsBizBaseParam]

View File

@@ -57,6 +57,7 @@ public class THDistortionServiceImpl implements THDistortionService {
private final RMpVThdMapper rMpVThdMapper; private final RMpVThdMapper rMpVThdMapper;
private final LineFeignClient lineFeignClient; private final LineFeignClient lineFeignClient;
private final IRStatDataVDService statDataVDService; private final IRStatDataVDService statDataVDService;
@Override @Override
public List<THDistortionVO> getTHDistortionData(DeviceInfoParam.BusinessParam thDistortionParam) { public List<THDistortionVO> getTHDistortionData(DeviceInfoParam.BusinessParam thDistortionParam) {
List<THDistortionVO> thDistortionVOS = new ArrayList<>(); List<THDistortionVO> thDistortionVOS = new ArrayList<>();
@@ -135,9 +136,10 @@ public class THDistortionServiceImpl implements THDistortionService {
/*监测点ID扁平化*/ /*监测点ID扁平化*/
List<String> collect = deviceList.stream().map(GeneralDeviceDTO::getLineIndexes).flatMap(Collection::stream).distinct().collect(Collectors.toList()); List<String> collect = deviceList.stream().map(GeneralDeviceDTO::getLineIndexes).flatMap(Collection::stream).distinct().collect(Collectors.toList());
QueryWrapper<RMpVThd> wrapper = new QueryWrapper<>(); QueryWrapper<RMpVThd> wrapper = new QueryWrapper<>();
wrapper.in ("measurement_point_id",collect). wrapper.in("measurement_point_id", collect)
between ("data_date", statisticsBizBaseParam.getStartTime (), statisticsBizBaseParam.getEndTime ()). .between("data_date", statisticsBizBaseParam.getStartTime(), statisticsBizBaseParam.getEndTime())
orderByDesc ("v_thd"); .eq("data_type", 1)
.orderByDesc("v_thd");
List<RMpVThd> rMpVThdList = rMpVThdMapper.selectList(wrapper); List<RMpVThd> rMpVThdList = rMpVThdMapper.selectList(wrapper);
rMpVThdVOList = rMpVThdList.stream().limit(topNum).map(rMpVThd -> { rMpVThdVOList = rMpVThdList.stream().limit(topNum).map(rMpVThd -> {
RMpVThdVO rMpVThdVO = new RMpVThdVO(); RMpVThdVO rMpVThdVO = new RMpVThdVO();
@@ -173,6 +175,7 @@ public class THDistortionServiceImpl implements THDistortionService {
private List<THDistortionVO> getChildCategoryList(THDistortionVO item, List<THDistortionVO> child) { private List<THDistortionVO> getChildCategoryList(THDistortionVO item, List<THDistortionVO> child) {
return child.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList()); return child.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
} }
private void setChildesList(List<THDistortionVO> item, List<THDistortionVO> childes) { private void setChildesList(List<THDistortionVO> item, List<THDistortionVO> childes) {
//groupLine变电站索引和监测点集合 //groupLine变电站索引和监测点集合
Map<String, List<THDistortionVO>> groupLine; Map<String, List<THDistortionVO>> groupLine;
@@ -226,6 +229,7 @@ public class THDistortionServiceImpl implements THDistortionService {
/** /**
* influxDB查询畸变率 * influxDB查询畸变率
*
* @param lineIndexes * @param lineIndexes
* @param startTime * @param startTime
* @param endTime * @param endTime
@@ -259,43 +263,6 @@ public class THDistortionServiceImpl implements THDistortionService {
} }
} }
return publicDTOList; return publicDTOList;
//组装sql语句
// StringBuilder string = new StringBuilder();
// string.append(Param.QualityFlag + "='1' and (" + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEA + "' or " + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEB + "' or " + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEC + "') and "+ Param.VALUETYPE + "='AVG' and ");
// StringBuilder timeId = new StringBuilder();
// timeId.append(Param.TIME + " >= '" + startTime + Param.START_TIME + "' and " + Param.TIME + " <= '" + endTime + Param.END_TIME + "' and (");
// for (int i = 0; i < lineIndexes.size(); i++) {
// if (lineIndexes.size() - i != 1) {
// timeId.append(Param.LINE_ID + "='").append(lineIndexes.get(i)).append("' or ");
// } else {
// timeId.append(Param.LINE_ID + "='").append(lineIndexes.get(i)).append("')");
// }
// }
// // String a = "SELECT MEAN(V_THD) AS distortion FROM Data_V WHERE QualityFlag='1' and (phasic_type='A' or phasic_type='B' or phasic_type='C')and value_type='AVG' and time >= '2022-03-20 00:00:00' and time <= '2022-03-21 23:59:59' and (lineid ='1e3b8531483b2a8cbee6747f1f641cf9') group by lineid;";
// //sql语句
// String sql = "SELECT MEAN(" + Param.V_THD + ")*100 AS distortion FROM Data_V WHERE " + string + timeId + " group by " + Param.LINE_ID;
// //结果集
// QueryResult result = influxDbUtils.query(sql);
// //处理结果集
// List<QueryResult.Series> list = result.getResults().get(0).getSeries();
// if (!CollectionUtils.isEmpty(list)){
// list.forEach(po->{
// PublicDTO publicDTO = new PublicDTO();
// List<List<Object>> valueList = po.getValues();
// String index = po.getTags().get(Param.LINE_ID);
// if (!CollectionUtils.isEmpty(valueList)){
// for (List<Object> value : valueList) {
// //谐波畸变率 保留两位小数
// Double distortion = value.get(1) == null ? null : BigDecimal.valueOf(Double.parseDouble(value.get(1).toString())).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
// publicDTO.setId(index);
// publicDTO.setData(distortion);
// }
// }
// publicDTOList.add(publicDTO);
// });
// }
// return publicDTOList;
} }

View File

@@ -27,6 +27,12 @@
<groupId>com.njcn</groupId> <groupId>com.njcn</groupId>
<artifactId>common-core</artifactId> <artifactId>common-core</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.njcn</groupId> <groupId>com.njcn</groupId>

View File

@@ -28,6 +28,12 @@
<groupId>com.njcn</groupId> <groupId>com.njcn</groupId>
<artifactId>common-core</artifactId> <artifactId>common-core</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.njcn</groupId> <groupId>com.njcn</groupId>

View File

@@ -85,7 +85,8 @@ public class IntegrityServiceImpl extends MppServiceImpl<RStatIntegrityDMapper,
@Async("asyncExecutor") @Async("asyncExecutor")
public void dataIntegrity(LineParam lineParam,String time) { public void dataIntegrity(LineParam lineParam,String time) {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime dateTime = LocalDateTime.parse(time,df); String data = time + " 00:00:00";
LocalDateTime dateTime = LocalDateTime.parse(data,df);
List<LineDetail> lineDetailList = new ArrayList<>(); List<LineDetail> lineDetailList = new ArrayList<>();
if (CollUtil.isEmpty(lineParam.getLineIds())){ if (CollUtil.isEmpty(lineParam.getLineIds())){
List<Overlimit> overLimitList = getAllLinesLimitData(); List<Overlimit> overLimitList = getAllLinesLimitData();

View File

@@ -84,7 +84,8 @@ public class OnlineRateServiceImpl extends MppServiceImpl<RStatOnlineRateDMapper
@Async("asyncExecutor") @Async("asyncExecutor")
public void onlineRateData(LineParam lineParam,String time) { public void onlineRateData(LineParam lineParam,String time) {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime dateTime = LocalDateTime.parse(time,df); String data = time + " 00:00:00";
LocalDateTime dateTime = LocalDateTime.parse(data,df);
List<String> lineIdList = lineParam.getLineIds(); List<String> lineIdList = lineParam.getLineIds();
if (CollUtil.isEmpty(lineParam.getLineIds())){ if (CollUtil.isEmpty(lineParam.getLineIds())){
lineIdList = lineFeignClient.getDeviceList().getData(); lineIdList = lineFeignClient.getDeviceList().getData();