diff --git a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/pojo/dto/PqReasonableRangeDto.java b/algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/dto/PqReasonableRangeDto.java similarity index 97% rename from data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/pojo/dto/PqReasonableRangeDto.java rename to algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/dto/PqReasonableRangeDto.java index 9fb64e0..c5d682a 100644 --- a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/pojo/dto/PqReasonableRangeDto.java +++ b/algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/dto/PqReasonableRangeDto.java @@ -1,4 +1,4 @@ -package com.njcn.dataProcess.pojo.dto; +package com.njcn.algorithm.pojo.dto; import lombok.Data; diff --git a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/pojo/po/PqReasonableRange.java b/algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/po/PqReasonableRange.java similarity index 98% rename from data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/pojo/po/PqReasonableRange.java rename to algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/po/PqReasonableRange.java index aafb2cc..cd8b580 100644 --- a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/pojo/po/PqReasonableRange.java +++ b/algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/po/PqReasonableRange.java @@ -1,4 +1,4 @@ -package com.njcn.dataProcess.pojo.po; +package com.njcn.algorithm.pojo.po; import com.baomidou.mybatisplus.annotation.TableName; import com.njcn.db.bo.BaseEntity; diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/PqReasonableRangeController.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/PqReasonableRangeController.java new file mode 100644 index 0000000..1a841cc --- /dev/null +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/PqReasonableRangeController.java @@ -0,0 +1,91 @@ +package com.njcn.algorithm.controller; + + +import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto; +import com.njcn.algorithm.service.line.IPqReasonableRangeService; +import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.constant.OperateType; +import com.njcn.common.pojo.enums.common.LogEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.HttpResultUtil; +import com.njcn.csdevice.enums.DeviceOperate; +import com.njcn.dataProcess.param.DataCleanParam; +import com.njcn.web.advice.DeviceLog; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Controller; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + *

+ * 前端控制器 + *

+ * + * @author xy + * @since 2025-02-13 + */ +@Validated +@Slf4j +@Controller +@RestController +@RequestMapping("/pqReasonableRange") +@Api(tags = "数据清洗标准库") +public class PqReasonableRangeController extends BaseController { + + @Resource + private IPqReasonableRangeService pqReasonableRangeService; + + @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.QUERY) + @PostMapping("/getData") + @ApiOperation("按条件获取数据合理范围") + public HttpResult> getData(@RequestBody DataCleanParam param) { + String methodDescribe = getMethodDescribe("getData"); + List list = pqReasonableRangeService.getReasonableRangeList(param); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD) + @PostMapping("/save") + @ApiOperation("新增数据合理范围") + public HttpResult save(@RequestBody @Validated PqReasonableRangeDto dto) { + String methodDescribe = getMethodDescribe("save"); + boolean result = pqReasonableRangeService.savePqReasonableRange(dto); + if (result) { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "新增成功", methodDescribe); + } + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "新增失败", methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPDATE) + @PostMapping("/update") + @ApiOperation("更新数据合理范围") + public HttpResult update(@RequestBody @Validated PqReasonableRangeDto dto) { + String methodDescribe = getMethodDescribe("update"); + boolean result = pqReasonableRangeService.updatePqReasonableRange(dto); + if (result) { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "更新成功", methodDescribe); + } + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "更新失败", methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/delete") + @ApiOperation("删除数据合理范围") + @DeviceLog(operateType = DeviceOperate.DELETE) + public HttpResult delete(@RequestParam("id") String id) { + String methodDescribe = getMethodDescribe("delete"); + boolean result = pqReasonableRangeService.deletePqReasonableRange(id); + if (result) { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "删除成功", methodDescribe); + } + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "删除失败", methodDescribe); + } +} + diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/dao/relation/mapper/PqReasonableRangeMapper.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/mapper/PqReasonableRangeMapper.java similarity index 53% rename from data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/dao/relation/mapper/PqReasonableRangeMapper.java rename to algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/mapper/PqReasonableRangeMapper.java index 036e7a8..32878ff 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/dao/relation/mapper/PqReasonableRangeMapper.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/mapper/PqReasonableRangeMapper.java @@ -1,10 +1,7 @@ -package com.njcn.dataProcess.dao.relation.mapper; +package com.njcn.algorithm.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto; -import com.njcn.dataProcess.pojo.po.PqReasonableRange; - -import java.util.List; +import com.njcn.algorithm.pojo.po.PqReasonableRange; /** *

diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/line/FlowAsyncService.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/line/FlowAsyncService.java index 9fb3e9d..7da42b9 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/line/FlowAsyncService.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/line/FlowAsyncService.java @@ -1,7 +1,7 @@ package com.njcn.algorithm.service.line; import com.njcn.algorithm.pojo.bo.CalculatedParam; -import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto; +import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto; import com.njcn.device.pq.pojo.vo.LineDetailVO; import com.njcn.system.pojo.po.DictData; diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/IPqReasonableRangeService.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/line/IPqReasonableRangeService.java similarity index 59% rename from data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/IPqReasonableRangeService.java rename to algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/line/IPqReasonableRangeService.java index 502a118..3fb2ec9 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/IPqReasonableRangeService.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/line/IPqReasonableRangeService.java @@ -1,9 +1,9 @@ -package com.njcn.dataProcess.service; +package com.njcn.algorithm.service.line; import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto; +import com.njcn.algorithm.pojo.po.PqReasonableRange; import com.njcn.dataProcess.param.DataCleanParam; -import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto; -import com.njcn.dataProcess.pojo.po.PqReasonableRange; import java.util.List; @@ -24,4 +24,10 @@ public interface IPqReasonableRangeService extends IService { */ List getReasonableRangeList(DataCleanParam param); + boolean savePqReasonableRange(PqReasonableRangeDto dto); + + boolean updatePqReasonableRange(PqReasonableRangeDto dto); + + boolean deletePqReasonableRange(String id); + } diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataCleanServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataCleanServiceImpl.java index 68e3cff..e3154e4 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataCleanServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataCleanServiceImpl.java @@ -3,8 +3,10 @@ package com.njcn.algorithm.serviceimpl.line; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import com.njcn.algorithm.pojo.bo.CalculatedParam; +import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto; import com.njcn.algorithm.service.line.FlowAsyncService; import com.njcn.algorithm.service.line.IDataCleanService; +import com.njcn.algorithm.service.line.IPqReasonableRangeService; import com.njcn.algorithm.utils.MemorySizeUtil; import com.njcn.dataProcess.api.*; import com.njcn.dataProcess.dto.RmpEventDetailDTO; @@ -33,7 +35,9 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.lang.reflect.Method; -import java.time.*; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.function.Function; @@ -80,7 +84,7 @@ public class DataCleanServiceImpl implements IDataCleanService { @Resource private PqDataVerifyFeignClient pqDataVerifyFeignClient; @Resource - private PqReasonableRangeFeignClient pqReasonableRangeFeignClient; + private IPqReasonableRangeService pqReasonableRangeService; @Resource private LineFeignClient lineFeignClient; @Resource @@ -644,7 +648,7 @@ public class DataCleanServiceImpl implements IDataCleanService { DataCleanParam param = new DataCleanParam(); param.setSystemType(DataCleanEnum.Pqs.getCode()); // param.setDataSource(DataCleanEnum.InfluxDB.getCode()); - List list = pqReasonableRangeFeignClient.getData(param).getData(); + List list = pqReasonableRangeService.getReasonableRangeList(param); if (CollUtil.isNotEmpty(list)) { pqReasonableRangeDtoMap = list.stream().collect(Collectors.groupingBy(PqReasonableRangeDto::getInfluxdbTableName)); } @@ -662,7 +666,7 @@ public class DataCleanServiceImpl implements IDataCleanService { if (ObjectUtil.isNotNull(tableName)) { param.setTableName(tableName); } - List list = pqReasonableRangeFeignClient.getData(param).getData(); + List list = pqReasonableRangeService.getReasonableRangeList(param); if (CollUtil.isNotEmpty(list)) { pqReasonableRangeDtoMap = list.stream().collect(Collectors.toMap(PqReasonableRangeDto::getIndexCode, Function.identity())); } diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/FlowAsyncServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/FlowAsyncServiceImpl.java index b5e6cb1..51acadd 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/FlowAsyncServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/FlowAsyncServiceImpl.java @@ -7,6 +7,7 @@ import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.njcn.algorithm.pojo.bo.CalculatedParam; +import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto; import com.njcn.algorithm.service.line.FlowAsyncService; import com.njcn.dataProcess.api.*; import com.njcn.dataProcess.dto.DataCleanJsonDTO; @@ -92,7 +93,7 @@ public class FlowAsyncServiceImpl implements FlowAsyncService { @Override @Async("asyncExecutor") - public void lineDataClean(LineDetailVO.Detail line, Map> map, String dataDate,DictData dip,DictData rise,int size,int i) { + public void lineDataClean(LineDetailVO.Detail line, Map> map, String dataDate, DictData dip, DictData rise, int size, int i) { LineDetailVO.Detail item = line; List> resultData = new ArrayList<>(); Set allTimeSet = new HashSet<>(); diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/relation/PqReasonableRangeServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/PqReasonableRangeServiceImpl.java similarity index 59% rename from data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/relation/PqReasonableRangeServiceImpl.java rename to algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/PqReasonableRangeServiceImpl.java index 2845ac9..926ab6b 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/relation/PqReasonableRangeServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/PqReasonableRangeServiceImpl.java @@ -1,14 +1,16 @@ -package com.njcn.dataProcess.service.impl.relation; +package com.njcn.algorithm.serviceimpl.line; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.njcn.dataProcess.dao.relation.mapper.PqReasonableRangeMapper; +import com.njcn.algorithm.mapper.PqReasonableRangeMapper; +import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto; +import com.njcn.algorithm.pojo.po.PqReasonableRange; +import com.njcn.algorithm.service.line.IPqReasonableRangeService; import com.njcn.dataProcess.param.DataCleanParam; -import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto; -import com.njcn.dataProcess.pojo.po.PqReasonableRange; -import com.njcn.dataProcess.service.IPqReasonableRangeService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -23,7 +25,9 @@ import java.util.List; * @author xy * @since 2025-02-13 */ +@Slf4j @Service +@RequiredArgsConstructor public class PqReasonableRangeServiceImpl extends ServiceImpl implements IPqReasonableRangeService { @Override @@ -48,4 +52,29 @@ public class PqReasonableRangeServiceImpl extends ServiceImpl> getData(@RequestBody DataCleanParam param); - -} diff --git a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/api/fallback/PqReasonableRangeFeignClientFallbackFactory.java b/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/api/fallback/PqReasonableRangeFeignClientFallbackFactory.java deleted file mode 100644 index 79caf91..0000000 --- a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/api/fallback/PqReasonableRangeFeignClientFallbackFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.njcn.dataProcess.api.fallback; - -import com.njcn.common.pojo.enums.response.CommonResponseEnum; -import com.njcn.common.pojo.exception.BusinessException; -import com.njcn.common.pojo.response.HttpResult; -import com.njcn.dataProcess.api.PqReasonableRangeFeignClient; -import com.njcn.dataProcess.param.DataCleanParam; -import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto; -import com.njcn.dataProcess.util.DataProcessingEnumUtil; -import feign.hystrix.FallbackFactory; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * @author xy - * @version 1.0.0 - * @date 2025年02月13日 20:13 - */ -@Slf4j -@Component -public class PqReasonableRangeFeignClientFallbackFactory implements FallbackFactory { - - /** - * 输出远程请求接口异常日志 - * @param cause RPC请求异常 - */ - @Override - public PqReasonableRangeFeignClient create(Throwable cause) { - //判断抛出异常是否为解码器抛出的业务异常 - Enum exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK; - if(cause.getCause() instanceof BusinessException){ - BusinessException businessException = (BusinessException) cause.getCause(); - exceptionEnum = DataProcessingEnumUtil.getExceptionEnum(businessException.getResult()); - } - Enum finalExceptionEnum = exceptionEnum; - return new PqReasonableRangeFeignClient() { - - @Override - public HttpResult> getData(DataCleanParam param) { - log.error("{}异常,降级处理,异常为:{}","按条件获取数据合理范围",cause.toString()); - throw new BusinessException(finalExceptionEnum); - } - }; - } -} diff --git a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/constant/InfluxDBTableConstant.java b/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/constant/InfluxDBTableConstant.java index 60a113f..cfe26ae 100644 --- a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/constant/InfluxDBTableConstant.java +++ b/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/constant/InfluxDBTableConstant.java @@ -196,5 +196,8 @@ public interface InfluxDBTableConstant { String NORMAL = "0"; String UN_NORMAL = "1"; - + /** + * 数据清洗标志 0:正常 1:异常 + */ + String ABNORMAL_FLAG = "abnormal_flag"; } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/controller/PqReasonableRangeController.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/controller/PqReasonableRangeController.java deleted file mode 100644 index d819545..0000000 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/controller/PqReasonableRangeController.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.njcn.dataProcess.controller; - - -import com.njcn.common.pojo.annotation.OperateInfo; -import com.njcn.common.pojo.constant.OperateType; -import com.njcn.common.pojo.enums.common.LogEnum; -import com.njcn.common.pojo.enums.response.CommonResponseEnum; -import com.njcn.common.pojo.response.HttpResult; -import com.njcn.common.utils.HttpResultUtil; -import com.njcn.dataProcess.param.DataCleanParam; -import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto; -import com.njcn.dataProcess.service.IPqReasonableRangeService; -import com.njcn.web.controller.BaseController; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Controller; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -/** - *

- * 前端控制器 - *

- * - * @author xy - * @since 2025-02-13 - */ -@Validated -@Slf4j -@Controller -@RestController -@RequestMapping("/pqReasonableRange") -@Api(tags = "数据清洗标准库") -public class PqReasonableRangeController extends BaseController { - - @Resource - private IPqReasonableRangeService pqReasonableRangeService; - - @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.QUERY) - @PostMapping("/getData") - @ApiOperation("按条件获取数据合理范围") - public HttpResult> getData(@RequestBody DataCleanParam param) { - String methodDescribe = getMethodDescribe("getData"); - List list = pqReasonableRangeService.getReasonableRangeList(param); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); - } - -} - diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlickerImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlickerImpl.java index de218a7..e9e804e 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlickerImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlickerImpl.java @@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.api.EquipmentFeignClient; -import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.dataProcess.dao.imapper.DataFlickerMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataFlickerRelationMapper; import com.njcn.dataProcess.dto.DataFlickerDTO; @@ -24,12 +20,10 @@ import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -47,10 +41,6 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl PHASE_MAPPING = new HashMap() {{ put("AB", "A"); put("BC", "B"); @@ -80,12 +70,7 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl getRawData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List list; - if (Objects.equals(lineParam.getType(), 2)) { - list = getWlMinuteData(lineParam); - } else { - list = getMinuteData(lineParam); - } + List list = getMinuteData(lineParam); list.forEach(item -> { DataFlickerDto dto = new DataFlickerDto(); BeanUtils.copyProperties(item, dto); @@ -98,12 +83,7 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl getBaseData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List dataIList; - if (Objects.equals(lineParam.getType(), 2)) { - dataIList = getWlMinuteData(lineParam); - } else { - dataIList = getMinuteData(lineParam); - } + List dataIList = getMinuteData(lineParam); if (CollectionUtil.isNotEmpty(dataIList)) { String time = TimeUtils.StringTimeToString(lineParam.getStartTime()); //以监测点分组 @@ -261,64 +241,13 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl getWlMinuteData(LineCountEvaluateParam lineParam) { - List result = new ArrayList<>(); - if (CollectionUtil.isNotEmpty(lineParam.getLineId())) { - //获取监测点信息 - List line = csLineFeignClient.queryLineById(lineParam.getLineId()).getData(); - Map lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity())); - //获取设备信息 - List devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList()); - List dev = equipmentFeignClient.queryDeviceById(devList).getData(); - Map devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity())); - - lineParam.getLineId().forEach(lineId -> { - String devId = lineMap.get(lineId).getDeviceId(); - CsLinePO po = lineMap.get(lineId); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataFlicker.class); - influxQueryWrapper.eq(DataFlicker::getLineId, lineId) - .eq(DataFlicker::getProcess,Integer.toString(devsMap.get(devId).getProcess())) - .select(DataFlicker::getLineId) - .select(DataFlicker::getPhasicType) - .between(DataFlicker::getTime, lineParam.getStartTime(), lineParam.getEndTime()) - .eq(DataFlicker::getQualityFlag, "0"); - if (CollUtil.isNotEmpty(lineParam.getPhasicType())) { - influxQueryWrapper.regular(DataFlicker::getPhasicType, lineParam.getPhasicType()); + if (CollectionUtil.isNotEmpty(result)) { + result.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); } - if (Objects.isNull(po.getLineNo())) { - influxQueryWrapper.eq(DataFlicker::getCldid,Integer.toString(po.getClDid())); - } else { - influxQueryWrapper.eq(DataFlicker::getCldid,Integer.toString(po.getLineNo())); - } - //判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压 - if (Objects.equals(po.getConType(),0)) { - //相电压电压变动幅度 - influxQueryWrapper.select("Pq_Fluct","fluc"); - //相电压长时闪变 - influxQueryWrapper.select("Pq_Plt","plt"); - //相电压短时闪变 - influxQueryWrapper.select("Pq_Pst","pst"); - } else { - //线电压电压变动幅度 - influxQueryWrapper.select("Pq_LFluct","fluc"); - //相电压长时闪变 - influxQueryWrapper.select("Pq_LPlt","plt"); - //相电压短时闪变 - influxQueryWrapper.select("Pq_LPst","pst"); - } - result.addAll(dataFlickerMapper.selectByQueryWrapper(influxQueryWrapper)); }); - if (CollectionUtil.isNotEmpty(result)) { - result.forEach(item -> { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); - } } return result; } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlucImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlucImpl.java index b701ad3..4b7ac26 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlucImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlucImpl.java @@ -2,10 +2,6 @@ package com.njcn.dataProcess.service.impl.influxdb; import cn.hutool.core.collection.CollectionUtil; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.api.EquipmentFeignClient; -import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.dataProcess.dao.imapper.DataFlucMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataFlucRelationMapper; import com.njcn.dataProcess.dto.DataFlucDTO; @@ -22,12 +18,10 @@ import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -45,11 +39,6 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl PHASE_MAPPING = new HashMap() {{ put("AB", "A"); put("BC", "B"); @@ -78,12 +67,7 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl getRawData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List list; - if (Objects.equals(lineParam.getType(), 2)) { - list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); list.forEach(item->{ DataFlucDto dto = new DataFlucDto(); BeanUtils.copyProperties(item,dto); @@ -96,12 +80,7 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl getBaseData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List dataIList; - if (Objects.equals(lineParam.getType(), 2)) { - dataIList = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - dataIList = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List dataIList = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); if (CollectionUtil.isNotEmpty(dataIList)) { String time = TimeUtils.StringTimeToString(lineParam.getStartTime()); //以监测点分组 @@ -215,53 +194,13 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl getWlMinuteData(List lineList, String startTime, String endTime, Map> timeMap, Boolean dataType) { - //todo FLUCCF电压波动频度原先oracle表存储的是0,写死的,这边暂不取值 - List result = new ArrayList<>(); - if (CollectionUtil.isNotEmpty(lineList)) { - //获取监测点信息 - List line = csLineFeignClient.queryLineById(lineList).getData(); - Map lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity())); - //获取设备信息 - List devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList()); - List dev = equipmentFeignClient.queryDeviceById(devList).getData(); - Map devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity())); - lineList.forEach(lineId -> { - String devId = lineMap.get(lineId).getDeviceId(); - CsLinePO po = lineMap.get(lineId); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataFluc.class); - influxQueryWrapper.eq(DataFluc::getLineId, lineId) - .eq(DataFluc::getProcess,Integer.toString(devsMap.get(devId).getProcess())) - .select(DataFluc::getLineId) - .select(DataFluc::getPhasicType) - .between(DataFluc::getTime, startTime, endTime) - .eq(DataFluc::getQualityFlag, "0"); - if (Objects.isNull(po.getLineNo())) { - influxQueryWrapper.eq(DataFluc::getCldid,Integer.toString(po.getClDid())); - } else { - influxQueryWrapper.eq(DataFluc::getCldid,Integer.toString(po.getLineNo())); + if (CollectionUtil.isNotEmpty(result)) { + result.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); } - //判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压 - if (Objects.equals(po.getConType(),0)) { - //相电压电压变动幅度 - influxQueryWrapper.select("Pq_Fluct","fluc"); - } else { - //线电压电压变动幅度 - influxQueryWrapper.select("Pq_LFluct","fluc"); - } - result.addAll(dataFlucMapper.selectByQueryWrapper(influxQueryWrapper)); }); - if (CollectionUtil.isNotEmpty(result)) { - result.forEach(item -> { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); - } } return result; } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmRateIImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmRateIImpl.java index da21b90..9fc3b33 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmRateIImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmRateIImpl.java @@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.utils.HarmonicTimesUtil; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.api.EquipmentFeignClient; -import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.dataProcess.dao.imapper.DataHarmRateIMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmRateIRelationMapper; import com.njcn.dataProcess.param.LineCountEvaluateParam; @@ -28,7 +24,6 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -40,10 +35,6 @@ public class InfluxdbDataHarmRateIImpl extends MppServiceImpl PHASE_MAPPING = new HashMap() {{ put("AB", "A"); @@ -55,12 +46,7 @@ public class InfluxdbDataHarmRateIImpl extends MppServiceImpl getRawData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List list; - if (Objects.equals(lineParam.getType(), 2)) { - list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); list.forEach(item->{ DataHarmRateIDto dto = new DataHarmRateIDto(); BeanUtils.copyProperties(item,dto); @@ -73,12 +59,7 @@ public class InfluxdbDataHarmRateIImpl extends MppServiceImpl getBaseData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List data; - if (Objects.equals(lineParam.getType(), 2)) { - data = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); if (CollectionUtil.isNotEmpty(data)) { String time = TimeUtils.StringTimeToString(lineParam.getStartTime()); //以监测点分组 @@ -246,48 +227,13 @@ public class InfluxdbDataHarmRateIImpl extends MppServiceImpl getWlMinuteData(List lineList, String startTime, String endTime, Map> timeMap, Boolean dataType) { - List result = new ArrayList<>(); - if (CollectionUtil.isNotEmpty(lineList)) { - //获取监测点信息 - List line = csLineFeignClient.queryLineById(lineList).getData(); - Map lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity())); - //获取设备信息 - List devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList()); - List dev = equipmentFeignClient.queryDeviceById(devList).getData(); - Map devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity())); - lineList.forEach(lineId -> { - String devId = lineMap.get(lineId).getDeviceId(); - CsLinePO po = lineMap.get(lineId); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmrateI.class); - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmRI_", "i_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - influxQueryWrapper.eq(DataHarmrateI::getLineId, lineId) - .eq(DataHarmrateI::getProcess,Integer.toString(devsMap.get(devId).getProcess())) - .select(DataHarmrateI::getLineId) - .select(DataHarmrateI::getPhasicType) - .select(DataHarmrateI::getValueType) - //电流基波有效值 - .select("Pq_RmsFundI_","i_1") - .between(DataHarmrateI::getTime, startTime, endTime) - .eq(DataHarmrateI::getQualityFlag, "0"); - if (Objects.isNull(po.getLineNo())) { - influxQueryWrapper.eq(DataHarmrateI::getCldid,Integer.toString(po.getClDid())); - } else { - influxQueryWrapper.eq(DataHarmrateI::getCldid,Integer.toString(po.getLineNo())); + if (CollectionUtil.isNotEmpty(result)) { + result.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); } - result.addAll(dataHarmRateIMapper.selectByQueryWrapper(influxQueryWrapper)); }); - if (CollectionUtil.isNotEmpty(result)) { - result.forEach(item -> { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); - } } return result; } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmRateVImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmRateVImpl.java index 2ef58b4..052e359 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmRateVImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmRateVImpl.java @@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.utils.HarmonicTimesUtil; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.api.EquipmentFeignClient; -import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.dataProcess.constant.InfluxDBTableConstant; import com.njcn.dataProcess.dao.imapper.DataHarmRateVMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmRateVRelationMapper; @@ -28,12 +24,10 @@ import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -46,10 +40,6 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl PHASE_MAPPING = new HashMap() {{ put("AB", "A"); @@ -61,12 +51,7 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl getRawData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List list; - if (Objects.equals(lineParam.getType(), 2)) { - list = getWlMinuteData(lineParam); - } else { - list = getMinuteData(lineParam);; - } + List list = getMinuteData(lineParam); list.forEach(item->{ DataHarmDto dto = new DataHarmDto(); BeanUtils.copyProperties(item,dto); @@ -97,12 +82,7 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl getBaseData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List data; - if (Objects.equals(lineParam.getType(), 2)) { - data = getWlMinuteData(lineParam); - } else { - data = getMinuteData(lineParam);; - } + List data = getMinuteData(lineParam); if (CollectionUtil.isNotEmpty(data)) { String time = TimeUtils.StringTimeToString(lineParam.getStartTime()); //以监测点分组 @@ -314,59 +294,14 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl getWlMinuteData(LineCountEvaluateParam lineParam) { - List result = new ArrayList<>(); - if (CollectionUtil.isNotEmpty(lineParam.getLineId())) { - //获取监测点信息 - List line = csLineFeignClient.queryLineById(lineParam.getLineId()).getData(); - Map lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity())); - //获取设备信息 - List devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList()); - List dev = equipmentFeignClient.queryDeviceById(devList).getData(); - Map devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity())); - lineParam.getLineId().forEach(lineId -> { - String devId = lineMap.get(lineId).getDeviceId(); - CsLinePO po = lineMap.get(lineId); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmrateV.class); - influxQueryWrapper.eq(DataHarmrateV::getLineId, lineId) - .eq(DataHarmrateV::getProcess,Integer.toString(devsMap.get(devId).getProcess())) - .select(DataHarmrateV::getLineId) - .select(DataHarmrateV::getPhasicType) - .select(DataHarmrateV::getValueType) - .between(DataHarmrateV::getTime, lineParam.getStartTime(), lineParam.getEndTime()) - .eq(DataHarmrateV::getQualityFlag, "0"); - if (Objects.isNull(po.getLineNo())) { - influxQueryWrapper.eq(DataHarmrateV::getCldid,Integer.toString(po.getClDid())); - } else { - influxQueryWrapper.eq(DataHarmrateV::getCldid,Integer.toString(po.getLineNo())); + if (CollectionUtil.isNotEmpty(result)) { + result.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); } - //判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压 - if (Objects.equals(po.getConType(),0)) { - //相电压基波有效值 - influxQueryWrapper.select("Pq_RmsFundU_","v_1"); - //2-50次 相电压谐波含有率 - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmU_", "v_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - } else { - //线电压基波有效值 - influxQueryWrapper.select("Pq_RmsFundLU_","v_1"); - //2-50次 线电压谐波含有率 - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmLU_", "v_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - } - result.addAll(dataHarmRateVMapper.selectByQueryWrapper(influxQueryWrapper)); }); - if (CollectionUtil.isNotEmpty(result)) { - result.forEach(item -> { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); - } } return result; } - } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmphasicIImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmphasicIImpl.java index b42d322..6a3b1b7 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmphasicIImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmphasicIImpl.java @@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.utils.HarmonicTimesUtil; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.api.EquipmentFeignClient; -import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.dataProcess.dao.imapper.DataHarmphasicIMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmPhasicIRelationMapper; import com.njcn.dataProcess.dto.DataHarmphasicIDTO; @@ -25,12 +21,10 @@ import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -46,10 +40,6 @@ public class InfluxdbDataHarmphasicIImpl extends MppServiceImpl PHASE_MAPPING = new HashMap() {{ put("AB", "A"); @@ -78,12 +68,7 @@ public class InfluxdbDataHarmphasicIImpl extends MppServiceImpl getRawData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List list; - if (Objects.equals(lineParam.getType(), 2)) { - list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); list.forEach(item->{ DataHarmPhasicIDto dto = new DataHarmPhasicIDto(); BeanUtils.copyProperties(item,dto); @@ -96,12 +81,7 @@ public class InfluxdbDataHarmphasicIImpl extends MppServiceImpl getBaseData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List data; - if (Objects.equals(lineParam.getType(), 2)) { - data = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); if (CollectionUtil.isNotEmpty(data)) { String time = TimeUtils.StringTimeToString(lineParam.getStartTime()); //以监测点分组 @@ -269,50 +249,15 @@ public class InfluxdbDataHarmphasicIImpl extends MppServiceImpl getWlMinuteData(List lineList, String startTime, String endTime, Map> timeMap,Boolean dataType) { - List result = new ArrayList<>(); - if (CollectionUtil.isNotEmpty(lineList)) { - //获取监测点信息 - List line = csLineFeignClient.queryLineById(lineList).getData(); - Map lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity())); - //获取设备信息 - List devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList()); - List dev = equipmentFeignClient.queryDeviceById(devList).getData(); - Map devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity())); - lineList.forEach(lineId -> { - String devId = lineMap.get(lineId).getDeviceId(); - CsLinePO po = lineMap.get(lineId); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmphasicI.class); - //谐波电流幅值相角 - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmIAng_", "i_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - influxQueryWrapper.eq(DataHarmphasicI::getLineId, lineId) - .eq(DataHarmphasicI::getProcess,Integer.toString(devsMap.get(devId).getProcess())) - .select(DataHarmphasicI::getLineId) - .select(DataHarmphasicI::getPhasicType) - .select(DataHarmphasicI::getValueType) - //基波电流相角 - .select("Pq_FundIAng","i_1") - .between(DataHarmphasicI::getTime, startTime, endTime) - .eq(DataHarmphasicI::getQualityFlag, "0"); - if (Objects.isNull(po.getLineNo())) { - influxQueryWrapper.eq(DataHarmphasicI::getCldid,Integer.toString(po.getClDid())); - } else { - influxQueryWrapper.eq(DataHarmphasicI::getCldid,Integer.toString(po.getLineNo())); + if (CollectionUtil.isNotEmpty(result)) { + result.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); } - result.addAll(dataHarmphasicIMapper.selectByQueryWrapper(influxQueryWrapper)); }); - if (CollectionUtil.isNotEmpty(result)) { - result.forEach(item -> { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); - } } return result; } + } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmphasicVImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmphasicVImpl.java index 5d9e2d0..8e297c5 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmphasicVImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmphasicVImpl.java @@ -4,15 +4,10 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.utils.HarmonicTimesUtil; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.api.EquipmentFeignClient; -import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.dataProcess.dao.imapper.DataHarmphasicVMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmPhasicVRelationMapper; import com.njcn.dataProcess.dto.DataHarmphasicVDTO; import com.njcn.dataProcess.param.LineCountEvaluateParam; -import com.njcn.dataProcess.po.influx.DataHarmphasicI; import com.njcn.dataProcess.po.influx.DataHarmphasicV; import com.njcn.dataProcess.pojo.dto.CommonMinuteDto; import com.njcn.dataProcess.pojo.dto.DataHarmDto; @@ -27,12 +22,10 @@ import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -47,12 +40,7 @@ import java.util.stream.Collectors; public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl implements IDataHarmphasicV { private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault()); - private final DataHarmphasicVMapper dataHarmphasicVMapper; - @Resource - private CsLineFeignClient csLineFeignClient; - @Resource - private EquipmentFeignClient equipmentFeignClient; private static final Map PHASE_MAPPING = new HashMap() {{ put("AB", "A"); @@ -83,12 +71,7 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl getRawData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List list; - if (Objects.equals(lineParam.getType(), 2)) { - list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); list.forEach(item->{ DataHarmDto dto = new DataHarmDto(); BeanUtils.copyProperties(item,dto); @@ -101,12 +84,7 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl getBaseData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List data; - if (Objects.equals(lineParam.getType(), 2)) { - data = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); if (CollectionUtil.isNotEmpty(data)) { String time = TimeUtils.StringTimeToString(lineParam.getStartTime()); //以监测点分组 @@ -274,58 +252,13 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl getWlMinuteData(List lineList, String startTime, String endTime, Map> timeMap, Boolean dataType) { - List result = new ArrayList<>(); - if (CollectionUtil.isNotEmpty(lineList)) { - //获取监测点信息 - List line = csLineFeignClient.queryLineById(lineList).getData(); - Map lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity())); - //获取设备信息 - List devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList()); - List dev = equipmentFeignClient.queryDeviceById(devList).getData(); - Map devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity())); - lineList.forEach(lineId -> { - String devId = lineMap.get(lineId).getDeviceId(); - CsLinePO po = lineMap.get(lineId); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmphasicV.class); - influxQueryWrapper.eq(DataHarmphasicV::getLineId, lineId) - .eq(DataHarmphasicV::getProcess,Integer.toString(devsMap.get(devId).getProcess())) - .select(DataHarmphasicV::getLineId) - .select(DataHarmphasicV::getPhasicType) - .select(DataHarmphasicV::getValueType) - .between(DataHarmphasicV::getTime, startTime, endTime) - .eq(DataHarmphasicV::getQualityFlag, "0"); - if (Objects.isNull(po.getLineNo())) { - influxQueryWrapper.eq(DataHarmphasicV::getCldid,Integer.toString(po.getClDid())); - } else { - influxQueryWrapper.eq(DataHarmphasicV::getCldid,Integer.toString(po.getLineNo())); + if (CollectionUtil.isNotEmpty(result)) { + result.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); } - //判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压 - if (Objects.equals(po.getConType(),0)) { - //相电压基波有效值相角 - influxQueryWrapper.select("Pq_FundUAng","v_1"); - //2-50次 相电压谐波相角 - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmUAng_", "v_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - } else { - //线电压基波有效值相角 - influxQueryWrapper.select("Pq_FundLUAng","v_1"); - //2-50次 线电压谐波相角 - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmLUAng_", "v_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - } - result.addAll(dataHarmphasicVMapper.selectByQueryWrapper(influxQueryWrapper)); }); - if (CollectionUtil.isNotEmpty(result)) { - result.forEach(item -> { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); - } } return result; } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java index 20c75b8..9b567a4 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java @@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.utils.HarmonicTimesUtil; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.api.EquipmentFeignClient; -import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.dataProcess.dao.imapper.DataHarmpowerPMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmPowerPRelationMapper; import com.njcn.dataProcess.dto.DataHarmpowerPDTO; @@ -26,13 +22,11 @@ import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.lang.reflect.Method; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -47,12 +41,7 @@ import java.util.stream.Collectors; public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl implements IDataHarmpowerP { private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault()); - private final DataHarmpowerPMapper dataHarmpowerPMapper; - @Resource - private CsLineFeignClient csLineFeignClient; - @Resource - private EquipmentFeignClient equipmentFeignClient; private static final Map PHASE_MAPPING = new HashMap() {{ put("AB", "A"); @@ -82,12 +71,7 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl getRawData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List list; - if (Objects.equals(lineParam.getType(), 2)) { - list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); list.forEach(item->{ DataPowerPDto dto = new DataPowerPDto(); BeanUtils.copyProperties(item,dto); @@ -100,12 +84,7 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl getBaseData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List data; - if (Objects.equals(lineParam.getType(), 2)) { - data = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); if (CollectionUtil.isNotEmpty(data)) { String time = TimeUtils.StringTimeToString(lineParam.getStartTime()); //以监测点分组 @@ -261,65 +240,13 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl getWlMinuteData(List lineList, String startTime, String endTime, Map> timeMap, Boolean dataType) { - List result = new ArrayList<>(); - if (CollectionUtil.isNotEmpty(lineList)) { - //获取监测点信息 - List line = csLineFeignClient.queryLineById(lineList).getData(); - Map lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity())); - //获取设备信息 - List devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList()); - List dev = equipmentFeignClient.queryDeviceById(devList).getData(); - Map devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity())); - lineList.forEach(lineId -> { - String devId = lineMap.get(lineId).getDeviceId(); - CsLinePO po = lineMap.get(lineId); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerP.class); - //A、B、C谐波有功功率有效值 - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmP_", "p_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - //三相总 谐波有功功率有效值 - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmTP_", "totP_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - InfluxQueryWrapper eq = influxQueryWrapper.eq(DataHarmpowerP::getLineId, lineId) - .eq(DataHarmpowerP::getProcess, Integer.toString(devsMap.get(devId).getProcess())) - .select(DataHarmpowerP::getLineId) - .select(DataHarmpowerP::getPhasicType) - .select(DataHarmpowerP::getValueType) - //位移功率因数 - .select("Pq_DF", "df") - //视在功率因素 - .select("Pq_PF", "pf") - //A、B、C三相有功功率 - .select("Pq_P", "p") - //基波有功功率 - .select("Pq_FundP", "p_1") - //三相总视在功率因数 - .select("Pq_TotPF", "totPf") - //三相总位移功率因数 - .select("Pq_TotDF", "totDf") - //三相总功率因数 - .select("Pq_TotP", "totP") - //三相总基波有功功率 - .select("Pq_TotHarmP", "totP1") - .between(DataHarmpowerP::getTime, startTime, endTime) - .eq(DataHarmpowerP::getQualityFlag, "0"); - if (Objects.isNull(po.getLineNo())) { - influxQueryWrapper.eq(DataHarmpowerP::getCldid,Integer.toString(po.getClDid())); - } else { - influxQueryWrapper.eq(DataHarmpowerP::getCldid,Integer.toString(po.getLineNo())); + if (CollectionUtil.isNotEmpty(result)) { + result.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); } - result.addAll(dataHarmpowerPMapper.selectByQueryWrapper(influxQueryWrapper)); }); - if (CollectionUtil.isNotEmpty(result)) { - result.forEach(item -> { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); - } } return result; } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerQImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerQImpl.java index 160abab..4d77559 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerQImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerQImpl.java @@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.utils.HarmonicTimesUtil; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.api.EquipmentFeignClient; -import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.dataProcess.dao.imapper.DataHarmpowerQMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmPowerQRelationMapper; import com.njcn.dataProcess.dto.DataHarmpowerQDTO; @@ -25,13 +21,11 @@ import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.lang.reflect.Method; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -47,10 +41,6 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl PHASE_MAPPING = new HashMap() {{ put("AB", "A"); @@ -80,12 +70,7 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl getRawData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List list; - if (Objects.equals(lineParam.getType(), 2)) { - list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); list.forEach(item->{ DataHarmPowerQDto dto = new DataHarmPowerQDto(); BeanUtils.copyProperties(item,dto); @@ -98,12 +83,7 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl getBaseData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List data; - if (Objects.equals(lineParam.getType(), 2)) { - data = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); if (CollectionUtil.isNotEmpty(data)) { String time = TimeUtils.StringTimeToString(lineParam.getStartTime()); //以监测点分组 @@ -254,57 +234,13 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl getWlMinuteData(List lineList, String startTime, String endTime, Map> timeMap, Boolean dataType) { - List result = new ArrayList<>(); - if (CollectionUtil.isNotEmpty(lineList)) { - //获取监测点信息 - List line = csLineFeignClient.queryLineById(lineList).getData(); - Map lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity())); - //获取设备信息 - List devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList()); - List dev = equipmentFeignClient.queryDeviceById(devList).getData(); - Map devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity())); - lineList.forEach(lineId -> { - String devId = lineMap.get(lineId).getDeviceId(); - CsLinePO po = lineMap.get(lineId); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerQ.class); - //A、B、C谐波无功功率有效值 - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmQ_", "q_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - //三相总 谐波有功功率有效值 - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmTQ_", "totQ_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - influxQueryWrapper.eq(DataHarmpowerQ::getLineId, lineId) - .eq(DataHarmpowerQ::getProcess,Integer.toString(devsMap.get(devId).getProcess())) - .select(DataHarmpowerQ::getLineId) - .select(DataHarmpowerQ::getPhasicType) - .select(DataHarmpowerQ::getValueType) - //A、B、C三相无功功率 - .select("Pq_Q", "q") - //基波无功功率 - .select("Pq_FundQ","q_1") - //总无功功率 - .select("Pq_TotQ","totQ") - //基波无功功率(T) - .select("Pq_TotHarmQ","totQ1") - .between(DataHarmpowerQ::getTime, startTime, endTime) - .eq(DataHarmpowerQ::getQualityFlag, "0"); - if (Objects.isNull(po.getLineNo())) { - influxQueryWrapper.eq(DataHarmpowerQ::getCldid,Integer.toString(po.getClDid())); - } else { - influxQueryWrapper.eq(DataHarmpowerQ::getCldid,Integer.toString(po.getLineNo())); + if (CollectionUtil.isNotEmpty(result)) { + result.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); } - result.addAll(dataHarmpowerQMapper.selectByQueryWrapper(influxQueryWrapper)); }); - if (CollectionUtil.isNotEmpty(result)) { - result.forEach(item -> { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); - } } return result; } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java index b288bff..11df88a 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java @@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.utils.HarmonicTimesUtil; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.api.EquipmentFeignClient; -import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.dataProcess.dao.imapper.DataHarmpowerSMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmPowerSRelationMapper; import com.njcn.dataProcess.dto.DataHarmpowerSDTO; @@ -25,13 +21,11 @@ import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.lang.reflect.Method; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -47,10 +41,6 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl PHASE_MAPPING = new HashMap() {{ put("AB", "A"); @@ -80,12 +70,7 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl getRawData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List list; - if (Objects.equals(lineParam.getType(), 2)) { - list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); list.forEach(item->{ DataHarmPowerSDto dto = new DataHarmPowerSDto(); BeanUtils.copyProperties(item,dto); @@ -98,12 +83,7 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl getBaseData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List data; - if (Objects.equals(lineParam.getType(), 2)) { - data = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType()); if (CollectionUtil.isNotEmpty(data)) { String time = TimeUtils.StringTimeToString(lineParam.getStartTime()); //以监测点分组 @@ -253,59 +233,14 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl getWlMinuteData(List lineList, String startTime, String endTime, Map> timeMap,Boolean dataType) { - List result = new ArrayList<>(); - if (CollectionUtil.isNotEmpty(lineList)) { - //获取监测点信息 - List line = csLineFeignClient.queryLineById(lineList).getData(); - Map lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity())); - //获取设备信息 - List devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList()); - List dev = equipmentFeignClient.queryDeviceById(devList).getData(); - Map devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity())); - lineList.forEach(lineId -> { - String devId = lineMap.get(lineId).getDeviceId(); - CsLinePO po = lineMap.get(lineId); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerS.class); - //A、B、C谐波视在功率有效值 - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmS_", "s_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - //三相总 谐波视在功率有效值 - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmTS_", "totS_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - influxQueryWrapper.eq(DataHarmpowerS::getLineId, lineId) - .eq(DataHarmpowerS::getProcess,Integer.toString(devsMap.get(devId).getProcess())) - .select(DataHarmpowerS::getLineId) - .select(DataHarmpowerS::getPhasicType) - .select(DataHarmpowerS::getValueType) - //A、B、C视在功率 - .select("Pq_S","s") - //基波视在功率 - .select("Pq_FundS","s_1") - //总视在功率 - .select("Pq_TotS","totS") - //基波视在功率(T) - .select("Pq_TotHarmS","totS1") - .between(DataHarmpowerS::getTime, startTime, endTime) - .eq(DataHarmpowerS::getQualityFlag, "0"); - if (Objects.isNull(po.getLineNo())) { - influxQueryWrapper.eq(DataHarmpowerS::getCldid,Integer.toString(po.getClDid())); - } else { - influxQueryWrapper.eq(DataHarmpowerS::getCldid,Integer.toString(po.getLineNo())); + if (CollectionUtil.isNotEmpty(result)) { + result.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); } - result.addAll(dataHarmpowerSMapper.selectByQueryWrapper(influxQueryWrapper)); }); - if (CollectionUtil.isNotEmpty(result)) { - result.forEach(item -> { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); - } } return result; } - } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataIImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataIImpl.java index e1dd2e9..4a12556 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataIImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataIImpl.java @@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.utils.HarmonicTimesUtil; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.api.EquipmentFeignClient; -import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.dataProcess.constant.InfluxDBTableConstant; import com.njcn.dataProcess.dao.imapper.DataIMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataIRelationMapper; @@ -26,12 +22,10 @@ import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -49,11 +43,6 @@ public class InfluxdbDataIImpl extends MppServiceImpl PHASE_MAPPING = new HashMap() {{ put("AB", "A"); put("BC", "B"); @@ -82,12 +71,7 @@ public class InfluxdbDataIImpl extends MppServiceImpl getRawData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List list; - if (Objects.equals(lineParam.getType(), 2)) { - list = getWlMinuteDataI(lineParam); - } else { - list = getMinuteDataI(lineParam); - } + List list = getMinuteDataI(lineParam);; list.forEach(item->{ DataIDto dto = new DataIDto(); BeanUtils.copyProperties(item,dto); @@ -100,12 +84,7 @@ public class InfluxdbDataIImpl extends MppServiceImpl getBaseData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List dataIList; - if (Objects.equals(lineParam.getType(), 2)) { - dataIList = getWlMinuteDataI(lineParam); - } else { - dataIList = getMinuteDataI(lineParam); - } + List dataIList = getMinuteDataI(lineParam); if (CollectionUtil.isNotEmpty(dataIList)) { String time = TimeUtils.StringTimeToString(lineParam.getStartTime()); //以监测点分组 @@ -314,65 +293,13 @@ public class InfluxdbDataIImpl extends MppServiceImpl getWlMinuteDataI(LineCountEvaluateParam lineParam) { - List result = new ArrayList<>(); - if (CollectionUtil.isNotEmpty(lineParam.getLineId())) { - //获取监测点信息 - List line = csLineFeignClient.queryLineById(lineParam.getLineId()).getData(); - Map lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity())); - //获取设备信息 - List devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList()); - List dev = equipmentFeignClient.queryDeviceById(devList).getData(); - Map devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity())); - - lineParam.getLineId().forEach(lineId -> { - String devId = lineMap.get(lineId).getDeviceId(); - CsLinePO po = lineMap.get(lineId); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class); - //2-50次 谐波电流有效值 - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmI_", "i_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - influxQueryWrapper.eq(DataI::getLineId, lineId) - .eq(DataI::getProcess,Integer.toString(devsMap.get(devId).getProcess())) - .select(DataI::getLineId) - .select(DataI::getPhasicType) - .select(DataI::getValueType) - //电流负序 - .select("Pq_SeqNegI","i_neg") - //电流正序 - .select("Pq_SeqPosI","i_pos") - //电流总谐波畸变率 - .select("Pq_ThdI","i_thd") - //电流负序不平衡度 - .select("Pq_UnbalNegI","i_unbalance") - //电流零序 - .select("Pq_SeqZeroI","i_zero") - //电流总有效值 - .select("Pq_RmsI","rms") - //电流基波有效值 - .select("Pq_RmsFundI","i_1") - .between(DataI::getTime, lineParam.getStartTime(), lineParam.getEndTime()) - .eq(DataI::getQualityFlag, "0"); - if (CollUtil.isNotEmpty(lineParam.getPhasicType())) { - influxQueryWrapper.regular(DataI::getPhasicType, lineParam.getPhasicType()); + if (CollectionUtil.isNotEmpty(result)) { + result.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); } - if (Objects.isNull(po.getLineNo())) { - influxQueryWrapper.eq(DataI::getCldid,Integer.toString(po.getClDid())); - } else { - influxQueryWrapper.eq(DataI::getCldid,Integer.toString(po.getLineNo())); - } - result.addAll(dataIMapper.selectByQueryWrapper(influxQueryWrapper)); }); - if (CollectionUtil.isNotEmpty(result)) { - result.forEach(item -> { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); - } } return result; } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataInharmIImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataInharmIImpl.java index 42d3b40..d2f9f0d 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataInharmIImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataInharmIImpl.java @@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.utils.HarmonicTimesUtil; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.api.EquipmentFeignClient; -import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.dataProcess.dao.imapper.DataInharmIMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataInHarmIRelationMapper; import com.njcn.dataProcess.dto.DataInharmIDTO; @@ -25,12 +21,10 @@ import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -46,10 +40,6 @@ public class InfluxdbDataInharmIImpl extends MppServiceImpl PHASE_MAPPING = new HashMap() {{ put("AB", "A"); @@ -79,12 +69,7 @@ public class InfluxdbDataInharmIImpl extends MppServiceImpl getRawData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List list; - if (Objects.equals(lineParam.getType(), 2)) { - list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType()); list.forEach(item->{ DataInHarmIDto dto = new DataInHarmIDto(); BeanUtils.copyProperties(item,dto); @@ -97,12 +82,7 @@ public class InfluxdbDataInharmIImpl extends MppServiceImpl getBaseData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List data; - if (Objects.equals(lineParam.getType(), 2)) { - data = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType()); - } else { - data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType()); - } + List data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType()); if (CollectionUtil.isNotEmpty(data)) { String time = TimeUtils.StringTimeToString(lineParam.getStartTime()); //以监测点分组 @@ -270,49 +250,14 @@ public class InfluxdbDataInharmIImpl extends MppServiceImpl getWlMinuteData(List lineList, String startTime, String endTime, Map> timeMap, Boolean dataType) { - List result = new ArrayList<>(); - if (CollectionUtil.isNotEmpty(lineList)) { - //获取监测点信息 - List line = csLineFeignClient.queryLineById(lineList).getData(); - Map lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity())); - //获取设备信息 - List devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList()); - List dev = equipmentFeignClient.queryDeviceById(devList).getData(); - Map devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity())); - lineList.forEach(lineId -> { - String devId = lineMap.get(lineId).getDeviceId(); - CsLinePO po = lineMap.get(lineId); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataInharmI.class); - //2-50次 间谐波电流有效值 - influxQueryWrapper.samePrefixAndSuffix("Pq_InHarmIAmp_", "i_", HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); - influxQueryWrapper.eq(DataInharmI::getLineId, lineId) - .eq(DataInharmI::getProcess,Integer.toString(devsMap.get(devId).getProcess())) - .select(DataInharmI::getLineId) - .select(DataInharmI::getPhasicType) - .select(DataInharmI::getValueType) - .between(DataInharmI::getTime, startTime, endTime) - .eq(DataInharmI::getQualityFlag, "0"); - if (Objects.isNull(po.getLineNo())) { - influxQueryWrapper.eq(DataInharmI::getCldid,Integer.toString(po.getClDid())); - } else { - influxQueryWrapper.eq(DataInharmI::getCldid,Integer.toString(po.getLineNo())); + if (CollectionUtil.isNotEmpty(result)) { + result.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); } - result.addAll(dataInharmIMapper.selectByQueryWrapper(influxQueryWrapper)); }); - if (CollectionUtil.isNotEmpty(result)) { - result.forEach(item -> { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); - } } return result; } - } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataInharmVImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataInharmVImpl.java index 1eaa67c..aaedb63 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataInharmVImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataInharmVImpl.java @@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.utils.HarmonicTimesUtil; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.api.EquipmentFeignClient; -import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.dataProcess.dao.imapper.DataInharmVMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataInHarmVRelationMapper; import com.njcn.dataProcess.dto.DataInharmVDTO; @@ -26,12 +22,10 @@ import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; @@ -47,12 +41,7 @@ import java.util.stream.Collectors; public class InfluxdbDataInharmVImpl extends MppServiceImpl implements IDataInharmV { private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault()); - private final DataInharmVMapper dataInharmVMapper; - @Resource - private CsLineFeignClient csLineFeignClient; - @Resource - private EquipmentFeignClient equipmentFeignClient; private static final Map PHASE_MAPPING = new HashMap() {{ put("AB", "A"); @@ -81,12 +70,7 @@ public class InfluxdbDataInharmVImpl extends MppServiceImpl getRawData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List list; - if (Objects.equals(lineParam.getType(), 2)) { - list = getWlMinuteData(lineParam); - } else { - list = getMinuteData(lineParam); - } + List list = getMinuteData(lineParam); list.forEach(item->{ DataHarmDto dto = new DataHarmDto(); BeanUtils.copyProperties(item,dto); @@ -99,12 +83,7 @@ public class InfluxdbDataInharmVImpl extends MppServiceImpl getBaseData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List data; - if (Objects.equals(lineParam.getType(), 2)) { - data = getWlMinuteData(lineParam); - } else { - data = getMinuteData(lineParam); - } + List data = getMinuteData(lineParam); if (CollectionUtil.isNotEmpty(data)) { String time = TimeUtils.StringTimeToString(lineParam.getStartTime()); //以监测点分组 @@ -275,56 +254,14 @@ public class InfluxdbDataInharmVImpl extends MppServiceImpl getWlMinuteData(LineCountEvaluateParam lineParam) { - List result = new ArrayList<>(); - if (CollectionUtil.isNotEmpty(lineParam.getLineId())) { - //获取监测点信息 - List line = csLineFeignClient.queryLineById(lineParam.getLineId()).getData(); - Map lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity())); - //获取设备信息 - List devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList()); - List dev = equipmentFeignClient.queryDeviceById(devList).getData(); - Map devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity())); - lineParam.getLineId().forEach(lineId -> { - String devId = lineMap.get(lineId).getDeviceId(); - CsLinePO po = lineMap.get(lineId); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataInharmV.class); - //2-50次 间谐波电流有效值 - influxQueryWrapper.eq(DataInharmV::getLineId, lineId) - .eq(DataInharmV::getProcess,Integer.toString(devsMap.get(devId).getProcess())) - .select(DataInharmV::getLineId) - .select(DataInharmV::getPhasicType) - .select(DataInharmV::getValueType) - .between(DataInharmV::getTime, lineParam.getStartTime(), lineParam.getEndTime()) - .eq(DataInharmV::getQualityFlag, "0"); - if (Objects.isNull(po.getLineNo())) { - influxQueryWrapper.eq(DataInharmV::getCldid,Integer.toString(po.getClDid())); - } else { - influxQueryWrapper.eq(DataInharmV::getCldid,Integer.toString(po.getLineNo())); + if (CollectionUtil.isNotEmpty(result)) { + result.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); } - //判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压 - if (Objects.equals(po.getConType(),0)) { - //0.5-49.5次 间谐波相电压有效值 - influxQueryWrapper.samePrefixAndSuffix("Pq_InHarmURV_", "v_", HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); - } else { - //0.5-49.5次 间谐波线电压有效值 - influxQueryWrapper.samePrefixAndSuffix("Pq_InHarmLURV_", "v_", HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); - } - result.addAll(dataInharmVMapper.selectByQueryWrapper(influxQueryWrapper)); }); - if (CollectionUtil.isNotEmpty(result)) { - result.forEach(item -> { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); - } } return result; } - } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataPltImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataPltImpl.java index 848eac7..960dbcc 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataPltImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataPltImpl.java @@ -3,10 +3,6 @@ package com.njcn.dataProcess.service.impl.influxdb; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.api.EquipmentFeignClient; -import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.dataProcess.dao.imapper.DataPltMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataPltRelationMapper; import com.njcn.dataProcess.dto.DataPltDTO; @@ -24,12 +20,10 @@ import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -44,12 +38,7 @@ import java.util.stream.Collectors; public class InfluxdbDataPltImpl extends MppServiceImpl implements IDataPlt { private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault()); - private final DataPltMapper dataPltMapper; - @Resource - private CsLineFeignClient csLineFeignClient; - @Resource - private EquipmentFeignClient equipmentFeignClient; private static final Map PHASE_MAPPING = new HashMap() {{ put("AB", "A"); @@ -79,12 +68,7 @@ public class InfluxdbDataPltImpl extends MppServiceImpl getRawData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List list; - if (Objects.equals(lineParam.getType(), 2)) { - list = getWlMinuteDataPlt(lineParam); - } else { - list = getMinuteDataPlt(lineParam); - } + List list = getMinuteDataPlt(lineParam); list.forEach(item->{ DataPltDto dto = new DataPltDto(); BeanUtils.copyProperties(item,dto); @@ -97,12 +81,7 @@ public class InfluxdbDataPltImpl extends MppServiceImpl getBaseData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List data; - if (Objects.equals(lineParam.getType(), 2)) { - data = getWlMinuteDataPlt(lineParam); - } else { - data = getMinuteDataPlt(lineParam); - } + List data = getMinuteDataPlt(lineParam); if (CollectionUtil.isNotEmpty(data)) { String time = TimeUtils.StringTimeToString(lineParam.getStartTime()); //以监测点分组 @@ -222,59 +201,14 @@ public class InfluxdbDataPltImpl extends MppServiceImpl getWlMinuteDataPlt(LineCountEvaluateParam lineParam) { - List result = new ArrayList<>(); - if (CollectionUtil.isNotEmpty(lineParam.getLineId())) { - //获取监测点信息 - List line = csLineFeignClient.queryLineById(lineParam.getLineId()).getData(); - Map lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity())); - //获取设备信息 - List devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList()); - List dev = equipmentFeignClient.queryDeviceById(devList).getData(); - Map devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity())); - - lineParam.getLineId().forEach(lineId -> { - String devId = lineMap.get(lineId).getDeviceId(); - CsLinePO po = lineMap.get(lineId); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataPlt.class); - influxQueryWrapper.eq(DataPlt::getLineId, lineId) - .eq(DataPlt::getProcess,Integer.toString(devsMap.get(devId).getProcess())) - .select(DataPlt::getLineId) - .select(DataPlt::getPhasicType) - .select(DataPlt::getValueType) - .between(DataPlt::getTime, lineParam.getStartTime(), lineParam.getEndTime()) - .eq(DataPlt::getQualityFlag, "0"); - if (CollUtil.isNotEmpty(lineParam.getPhasicType())) { - influxQueryWrapper.regular(DataPlt::getPhasicType, lineParam.getPhasicType()); + if (CollectionUtil.isNotEmpty(result)) { + result.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); } - if (Objects.isNull(po.getLineNo())) { - influxQueryWrapper.eq(DataPlt::getCldid,Integer.toString(po.getClDid())); - } else { - influxQueryWrapper.eq(DataPlt::getCldid,Integer.toString(po.getLineNo())); - } - //判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压 - if (Objects.equals(po.getConType(),0)) { - //相电压长时闪变 - influxQueryWrapper.select("Pq_Plt","plt"); - } else { - //线电压长时闪变 - influxQueryWrapper.select("Pq_LPlt","plt"); - } - result.addAll(dataPltMapper.selectByQueryWrapper(influxQueryWrapper)); }); - if (CollectionUtil.isNotEmpty(result)) { - result.forEach(item -> { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); - } } return result; } - } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataVImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataVImpl.java index 1a6083c..89e91e6 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataVImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataVImpl.java @@ -6,10 +6,6 @@ import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.ObjectUtil; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.utils.HarmonicTimesUtil; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.api.EquipmentFeignClient; -import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.dataProcess.constant.InfluxDBTableConstant; import com.njcn.dataProcess.constant.PhaseType; import com.njcn.dataProcess.dao.imapper.DataVMapper; @@ -38,7 +34,6 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -51,10 +46,6 @@ import java.util.stream.Collectors; public class InfluxdbDataVImpl extends MppServiceImpl implements IDataV { private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault()); - @Resource - private CsLineFeignClient csLineFeignClient; - @Resource - private EquipmentFeignClient equipmentFeignClient; private static final Map PHASE_MAPPING = new HashMap() {{ put("AB", "A"); @@ -137,12 +128,7 @@ public class InfluxdbDataVImpl extends MppServiceImpl getRawData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List list; - if (Objects.equals(lineParam.getType(), 2)) { - list = getWlMinuteDataV(lineParam); - } else { - list = getMinuteDataV(lineParam); - } + List list = getMinuteDataV(lineParam); if (CollectionUtil.isNotEmpty(list)) { list.forEach(item -> { DataVDto dto = new DataVDto(); @@ -226,12 +212,7 @@ public class InfluxdbDataVImpl extends MppServiceImpl getBaseData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); - List dataVList; - if (Objects.equals(lineParam.getType(), 2)) { - dataVList = getWlMinuteDataV(lineParam); - } else { - dataVList = getMinuteDataV(lineParam); - } + List dataVList = getMinuteDataV(lineParam); if (CollectionUtil.isNotEmpty(dataVList)) { String time = TimeUtils.StringTimeToString(lineParam.getStartTime()); //以监测点分组 @@ -481,89 +462,13 @@ public class InfluxdbDataVImpl extends MppServiceImpl getWlMinuteDataV(LineCountEvaluateParam lineParam) { - List result = new ArrayList<>(); - if (CollectionUtil.isNotEmpty(lineParam.getLineId())) { - //fixme 这边查询的数据可以缓存起来,因为日表计算时可以使用 - //获取监测点信息 - List line = csLineFeignClient.queryLineById(lineParam.getLineId()).getData(); - Map lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity())); - //获取设备信息 - List devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList()); - List dev = equipmentFeignClient.queryDeviceById(devList).getData(); - Map devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity())); - lineParam.getLineId().forEach(lineId -> { - String devId = lineMap.get(lineId).getDeviceId(); - CsLinePO po = lineMap.get(lineId); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataV.class); - influxQueryWrapper.eq(DataV::getLineId, lineId) - .eq(DataV::getProcess, Integer.toString(devsMap.get(devId).getProcess())) - .select(DataV::getLineId) - .select(DataV::getPhasicType) - .select(DataV::getValueType) - //频率 - .select("Pq_Freq", "freq") - //频率偏差 - .select("Pq_FreqDev", "freq_dev") - //相电压有效值 - .select("Pq_RmsU", "rms") - //线电压有效值 - .select("Pq_RmsLU", "rms_lvr") - //电压负序 - .select("Pq_SeqNegU", "v_neg") - //电压正序 - .select("Pq_SeqPosU", "v_pos") - //电压零序 - .select("Pq_SeqZeroU", "v_zero") - //电压负序不平衡度 - .select("Pq_UnbalNegU", "v_unbalance") - .between(DataV::getTime, lineParam.getStartTime(), lineParam.getEndTime()) - .eq(DataV::getQualityFlag, "0"); - if (CollUtil.isNotEmpty(lineParam.getPhasicType())) { - influxQueryWrapper.regular(DataV::getPhasicType, lineParam.getPhasicType()); + if (CollectionUtil.isNotEmpty(result)) { + result.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); } - if (Objects.isNull(po.getLineNo())) { - influxQueryWrapper.eq(DataV::getCldid, Integer.toString(po.getClDid())); - } else { - influxQueryWrapper.eq(DataV::getCldid, Integer.toString(po.getLineNo())); - } - //判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压 - if (Objects.equals(po.getConType(), 0)) { - //相电压偏差 - influxQueryWrapper.select("Pq_UDev", "vu_dev"); - //相电压谐波总畸变率 - influxQueryWrapper.select("Pq_ThdU", "v_thd"); - //相电压基波有效值 - influxQueryWrapper.select("Pq_RmsFundU", "v_1"); - //2-50次 相电压谐波有效值 - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmUV_", "v_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - } else { - //线电压偏差 - influxQueryWrapper.select("Pq_LUDev", "vu_dev"); - //线电压谐波总畸变率 - influxQueryWrapper.select("Pq_ThdLU", "v_thd"); - //线电压基波有效值 - influxQueryWrapper.select("Pq_RmsFundLU", "v_1"); - //2-50次 线电压谐波有效值 - influxQueryWrapper.samePrefixAndSuffix("Pq_HarmLUV_", "v_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1)); - } - result.addAll(dataVMapper.selectByQueryWrapper(influxQueryWrapper)); }); - if (CollectionUtil.isNotEmpty(result)) { - result.forEach(item -> { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); - } } return result; }