diff --git a/cs-device/cs-device-api/pom.xml b/cs-device/cs-device-api/pom.xml
index c3b9ca2..5903da0 100644
--- a/cs-device/cs-device-api/pom.xml
+++ b/cs-device/cs-device-api/pom.xml
@@ -35,12 +35,6 @@
common-microservice
${project.version}
-
- com.njcn
- cs-warn-api
- 1.0.0
- compile
-
com.njcn
user-api
@@ -59,6 +53,12 @@
common-device-biz
1.0.0
+
+ cn.afterturn
+ easypoi-base
+ 4.4.0
+ compile
+
UTF-8
diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/CsLineFeignClient.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/CsLineFeignClient.java
index 9a997af..7c17ac7 100644
--- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/CsLineFeignClient.java
+++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/CsLineFeignClient.java
@@ -50,6 +50,10 @@ public interface CsLineFeignClient {
@PostMapping("/updateLineDataByList")
HttpResult updateDataByList(@RequestParam("list") List list, @RequestParam("id") String id, @RequestParam("setId") String setId);
+ @PostMapping("/getLineByName")
+ HttpResult> getLineByName(@RequestParam("lineName") String lineName);
+
+
@PostMapping("/getAllLine")
HttpResult> getAllLine();
diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/CsLineClientFallbackFactory.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/CsLineClientFallbackFactory.java
index 695f34b..a2835c3 100644
--- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/CsLineClientFallbackFactory.java
+++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/CsLineClientFallbackFactory.java
@@ -99,6 +99,11 @@ public class CsLineClientFallbackFactory implements FallbackFactory> getLineByName(String lineName) {
+ log.error("{}异常,降级处理,异常为:{}","根据名称查询监测点异常",cause.toString());
+ throw new BusinessException(finalExceptionEnum);
+ }
};
}
}
diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsLinePO.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsLinePO.java
index c54b44a..5ba456b 100644
--- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsLinePO.java
+++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsLinePO.java
@@ -122,4 +122,14 @@ public class CsLinePO extends BaseEntity {
*/
@TableField(value = "line_no")
private Integer lineNo;
-}
\ No newline at end of file
+ /**
+ * 监测对象类型
+ */
+ @TableField(value = "monitor_obj")
+ private String monitorObj;
+ /**
+ * 是否治理(0:未治理 1:已治理)
+ */
+ @TableField(value = "is_govern")
+ private Integer govern;
+}
diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DevCountVO.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DevCountVO.java
index fce640a..58b941b 100644
--- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DevCountVO.java
+++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DevCountVO.java
@@ -1,7 +1,6 @@
package com.njcn.csdevice.pojo.vo;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
-import com.njcn.cswarn.pojo.vo.CsEquipmentAlarmVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
diff --git a/cs-device/cs-device-boot/pom.xml b/cs-device/cs-device-boot/pom.xml
index 12390a5..66138e4 100644
--- a/cs-device/cs-device-boot/pom.xml
+++ b/cs-device/cs-device-boot/pom.xml
@@ -88,11 +88,6 @@
hutool-all
5.8.5
-
- com.njcn
- cs-warn-api
- ${project.version}
-
@@ -153,12 +148,21 @@
access-api
${project.version}
-
- com.njcn
- common-mq
- 1.0.0
- compile
-
+
+ com.njcn
+ common-mq
+ 1.0.0
+
+
+ org.apache.rocketmq
+ rocketmq-spring-boot-starter
+ 2.2.2
+
+
+ com.njcn.platform
+ message-api
+ 1.0.0
+
diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/CsGroupController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/CsGroupController.java
index 2b9c546..fae53c2 100644
--- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/CsGroupController.java
+++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/CsGroupController.java
@@ -12,7 +12,9 @@ import com.njcn.csdevice.pojo.vo.CsGroupVO;
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
import com.njcn.csdevice.service.ICsGroupService;
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
+import com.njcn.csharmonic.param.TrendDataQueryParam;
import com.njcn.csharmonic.pojo.vo.ThdDataTdVO;
+import com.njcn.csharmonic.pojo.vo.ThdDataVO;
import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
@@ -21,6 +23,7 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -143,5 +146,15 @@ public class CsGroupController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
+ @OperateInfo(info = LogEnum.BUSINESS_COMMON)
+ @PostMapping("/trendData")
+ @ApiOperation("查询趋势数据")
+ @ApiImplicitParam(name = "param",required = true)
+ public HttpResult> trendData(@RequestBody @Validated TrendDataQueryParam param){
+ String methodDescribe = getMethodDescribe("trendData");
+ List list = csGroupService.trendData(param);
+ return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
+ }
+
}
diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java
index 57c5b5b..499a607 100644
--- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java
+++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java
@@ -229,4 +229,24 @@ public class CslineController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
+
+ @OperateInfo(info = LogEnum.BUSINESS_COMMON)
+ @PostMapping("/getLineByName")
+ @ApiOperation("根据名称获取监测点")
+ @ApiImplicitParam(name = "lineName", value = "监测点名称", required = true)
+ public HttpResult> getLineByName(@RequestParam("lineName") String lineName) {
+ String methodDescribe = getMethodDescribe("getLineByName");
+ List list = csLinePOService.getLineByName(lineName);
+ return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
+ }
+
+ @OperateInfo(info = LogEnum.BUSINESS_COMMON)
+ @PostMapping("/list")
+ @ApiOperation("查询监测点列表")
+ public HttpResult> list() {
+ String methodDescribe = getMethodDescribe("list");
+ List list = csLinePOService.list(new LambdaQueryWrapper().orderByAsc(CsLinePO::getName));
+ return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
+ }
+
}
diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/ICsGroupService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/ICsGroupService.java
index 90b06b7..450bf08 100644
--- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/ICsGroupService.java
+++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/ICsGroupService.java
@@ -7,10 +7,10 @@ import com.njcn.csdevice.pojo.po.CsGroup;
import com.njcn.csdevice.pojo.vo.CsGroupVO;
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
+import com.njcn.csharmonic.param.TrendDataQueryParam;
import com.njcn.csharmonic.pojo.vo.ThdDataTdVO;
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
import com.njcn.system.pojo.po.EleEpdPqd;
-import com.njcn.system.pojo.vo.EleEpdPqdListVO;
import java.util.List;
@@ -78,4 +78,11 @@ public interface ICsGroupService extends IService {
*/
void deleteGroup(String groupId);
+
+ /**
+ * 查询趋势数据
+ * @return
+ */
+ List trendData(TrendDataQueryParam trendDataQueryParam);
+
}
diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java
index 580337f..1d32dc4 100644
--- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java
+++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java
@@ -33,6 +33,7 @@ import com.njcn.csharmonic.api.EventFeignClient;
import com.njcn.csharmonic.constant.HarmonicConstant;
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
import com.njcn.csharmonic.param.CsEventUserQueryPage;
+import com.njcn.csharmonic.param.TrendDataQueryParam;
import com.njcn.csharmonic.pojo.vo.ThdDataTdVO;
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
import com.njcn.device.biz.pojo.po.Overlimit;
@@ -784,6 +785,154 @@ public class CsGroupServiceImpl extends ServiceImpl impl
}
}
+ @Override
+ public List trendData(TrendDataQueryParam trendDataQueryParam) {
+ List result = new ArrayList();
+ CsLinePO finalCsLinePO = csLineFeignClient.getById(trendDataQueryParam.getLineId()).getData();
+ CsDataSet csDataSet = csDataSetMapper.selectOne(new LambdaQueryWrapper().eq(CsDataSet::getId,finalCsLinePO.getDataSetId()));
+ if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())){
+ throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
+ }
+ Double ct = finalCsLinePO.getCtRatio();
+ Double pt = finalCsLinePO.getPtRatio();
+ if(CollectionUtil.isNotEmpty(trendDataQueryParam.getList())) {
+ for (TrendDataQueryParam param : trendDataQueryParam.getList()) {
+
+ List eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
+ eleEpdPqds.forEach(epdPqd -> {
+ CommonQueryParam commonQueryParam = new CommonQueryParam();
+ commonQueryParam.setLineId(finalCsLinePO.getLineId());
+ commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
+ commonQueryParam.setColumnName(epdPqd.getName() + (StringUtils.isEmpty(param.getFrequency()) ? "" : "_" + param.getFrequency()));
+ commonQueryParam.setPhasic(epdPqd.getPhase());
+
+ commonQueryParam.setStartTime(DateUtil.format(DateUtil.parse(trendDataQueryParam.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN), DatePattern.NORM_DATETIME_PATTERN));
+ commonQueryParam.setEndTime(DateUtil.format(DateUtil.endOfDay(DateUtil.parse(trendDataQueryParam.getSearchEndTime(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATETIME_PATTERN));
+
+ commonQueryParam.setDataType(trendDataQueryParam.getValueType());
+
+ commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(finalCsLinePO.getLineId()));
+
+ List deviceRtData = commonService.getDeviceRtDataByTime(Collections.singletonList(commonQueryParam));
+ List collect1 = deviceRtData.stream().map(temp -> {
+ String unit;
+ ThdDataVO vo = new ThdDataVO();
+ vo.setLineId(temp.getLineId());
+ vo.setPhase(Objects.equals("M", temp.getPhaseType()) ? null : temp.getPhaseType());
+ String position = finalCsLinePO.getPosition();
+ vo.setPosition(position);
+ vo.setTime(temp.getTime());
+ vo.setStatMethod(temp.getValueType());
+ vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
+ if (temp.getValue() != null) {
+ double re = 0;
+ if (Objects.equals("Primary", trendDataQueryParam.getDataLevel())) {
+ if (Objects.equals("Primary", csDataSet.getDataLevel())) {
+ if (HarmonicConstant.POWER_LIST.contains(epdPqd.getShowName())) {
+ re = Objects.isNull(temp.getValue()) ? 3.14159 : Double.parseDouble(df.format(temp.getValue() / 1000));
+ vo.setStatisticalData(re);
+ unit = "k" + epdPqd.getUnit();
+ } else {
+ vo.setStatisticalData(Objects.isNull(temp.getValue()) ? 3.14159 : Double.parseDouble(df.format(temp.getValue())));
+ unit = epdPqd.getUnit();
+ }
+ } else {
+ if (Objects.nonNull(epdPqd.getPrimaryFormula())) {
+ switch (epdPqd.getPrimaryFormula()) {
+ case "*PT":
+ re = temp.getValue() * pt / 1000;
+ unit = "k" + epdPqd.getUnit();
+ break;
+ case "*CT":
+ re = temp.getValue() * ct;
+ unit = epdPqd.getUnit();
+ break;
+ case "*PT*CT":
+ re = temp.getValue() * pt * ct / 1000;
+ unit = "k" + epdPqd.getUnit();
+ break;
+ default:
+ re = temp.getValue();
+ unit = epdPqd.getUnit();
+ break;
+ }
+ vo.setStatisticalData(Double.valueOf(df.format(re)));
+ } else {
+ re = temp.getValue();
+ unit = epdPqd.getUnit();
+ vo.setStatisticalData(Double.valueOf(df.format(re)));
+ }
+
+ }
+ } else {
+ if (Objects.equals("Primary", csDataSet.getDataLevel())) {
+ if (Objects.nonNull(epdPqd.getPrimaryFormula())) {
+ switch (epdPqd.getPrimaryFormula()) {
+ case "*PT":
+ re = temp.getValue() / pt;
+ break;
+ case "*CT":
+ re = temp.getValue() / ct;
+ break;
+ case "*PT*CT":
+ re = temp.getValue() / pt / ct;
+ break;
+ default:
+ re = temp.getValue();
+ break;
+ }
+ vo.setStatisticalData(Double.valueOf(df.format(re)));
+ } else {
+ re = temp.getValue();
+ vo.setStatisticalData(Double.valueOf(df.format(re)));
+ }
+ } else {
+ vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
+ }
+ unit = epdPqd.getUnit();
+ }
+ } else {
+ vo.setStatisticalData(null);
+ if (Objects.equals("Primary", trendDataQueryParam.getDataLevel())) {
+ if (Objects.equals("Primary", csDataSet.getDataLevel())) {
+ unit = epdPqd.getUnit();
+ } else {
+ if (Objects.nonNull(epdPqd.getPrimaryFormula())) {
+ switch (epdPqd.getPrimaryFormula()) {
+ case "*PT":
+ unit = "k" + epdPqd.getUnit();
+ break;
+ case "*CT":
+ unit = epdPqd.getUnit();
+ break;
+ case "*PT*CT":
+ unit = "k" + epdPqd.getUnit();
+ break;
+ default:
+ unit = epdPqd.getUnit();
+ break;
+ }
+ } else {
+ unit = epdPqd.getUnit();
+ }
+ }
+ } else {
+ unit = epdPqd.getUnit();
+ }
+ }
+ vo.setUnit(unit);
+ vo.setStatisticalIndex(epdPqd.getId());
+ vo.setStatisticalName(epdPqd.getName());
+ vo.setAnotherName(epdPqd.getShowName());
+ return vo;
+ }).collect(Collectors.toList());
+ result.addAll(collect1);
+ });
+ }
+ }
+ return result;
+ }
+
private List getChildren(String tabId, List all) {
return all.stream().filter(item -> item.getPid().equals(tabId)).collect(Collectors.toList());
}
diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/param/TrendDataQueryParam.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/param/TrendDataQueryParam.java
new file mode 100644
index 0000000..0960ac0
--- /dev/null
+++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/param/TrendDataQueryParam.java
@@ -0,0 +1,40 @@
+package com.njcn.csharmonic.param;
+
+
+import com.njcn.web.pojo.annotation.DateTimeStrValid;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.util.List;
+
+@Data
+public class TrendDataQueryParam {
+
+ @ApiModelProperty(value = "监测点")
+ @NotBlank(message = "监测点ID不可为空")
+ private String lineId;
+
+ @ApiModelProperty(name = "searchBeginTime", value = "开始时间")
+ @NotBlank(message = "起始时间不可为空")
+ @DateTimeStrValid(message = "起始时间格式出错")
+ private String searchBeginTime;
+
+ @ApiModelProperty(name = "searchEndTime", value = "结束时间")
+ @NotBlank(message = "结束时间不可为空")
+ private String searchEndTime;
+
+ @ApiModelProperty(value = "用于选择多个指标及谐波次数")
+ List list;
+ @ApiModelProperty(value = "指标组id")
+ private String statisticalId;
+ @ApiModelProperty(value = "取值类型(Max,Min,cp95,avg)")
+ private String valueType;
+
+ @ApiModelProperty(value = "一次值:Primary;二次值:Secondary")
+ private String dataLevel;
+
+ @ApiModelProperty(value = "频次2-50")
+ private String frequency;
+
+}