This commit is contained in:
huangzj
2023-06-15 13:34:43 +08:00
parent 83b6087427
commit 72d0b68d2d
8 changed files with 173 additions and 8 deletions

View File

@@ -21,6 +21,7 @@ public enum AlgorithmResponseEnum {
DATA_ERROR("A00503","存在相同的数据"),
LINE_DATA_ERROR ("A00504","设备下监测点数据缺失"),
ENGINEERING_DATA_ERROR ("A00505","工程数据数据缺失"),
ELEEPDPQD_DATA_ERROR ("A00505","统计指标据数据缺失"),
;

View File

@@ -37,7 +37,7 @@ public class CsEngineeringPO extends BaseEntity {
/**
* 用户id
*/
@TableField(value = "user_id")
@TableField(exist =false)
private String userId;
/**

View File

@@ -1,16 +1,19 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.mapper.CsEngineeringMapper;
import com.njcn.csdevice.mapper.CsEngineeringUserMapper;
import com.njcn.csdevice.mapper.CsLedgerMapper;
import com.njcn.csdevice.pojo.param.CsEngineeringAddParm;
import com.njcn.csdevice.pojo.param.CsEngineeringAuditParm;
import com.njcn.csdevice.pojo.param.CsEngineeringQueryPageParm;
import com.njcn.csdevice.pojo.param.CsEngineeringQueryParm;
import com.njcn.csdevice.pojo.po.CsEngineeringPO;
import com.njcn.csdevice.pojo.po.CsEngineeringUserPO;
import com.njcn.csdevice.pojo.po.CsLedger;
import com.njcn.csdevice.pojo.vo.CsEngineeringVO;
import com.njcn.csdevice.service.CsEngineeringService;
@@ -45,6 +48,12 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
private final AreaFeignClient areaFeignClient;
private final RedisUtil redisUtil;
private final CsLedgerMapper csLedgerMapper;
private final CsEngineeringUserMapper csEngineeringUserMapper;
@Override
@Transactional(rollbackFor = {Exception.class})
@@ -62,7 +71,12 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
csLedger1.setState(1);
csLedger1.setSort(0);
csLedgerMapper.insert(csLedger1);
//绑定用户
CsEngineeringUserPO po = new CsEngineeringUserPO();
po.setEngineeringId(csEngineeringPO.getId());
po.setUserId(csEngineeringAddParm.getUserId());
csEngineeringUserMapper.insert(po);
return save;
}
@@ -92,8 +106,17 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
public List<CsEngineeringVO> queryEngineering(CsEngineeringQueryParm csEngineeringQueryParm) {
List<CsEngineeringVO> csEngineeringVOList = new ArrayList<> ();
QueryWrapper<CsEngineeringPO> queryWrapper = new QueryWrapper<> ();
queryWrapper.eq (StringUtils.isNotBlank (csEngineeringQueryParm.getUserId ()),"user_id",csEngineeringQueryParm.getUserId ()).
eq (StringUtils.isNotBlank (csEngineeringQueryParm.getProvince ()),"province",csEngineeringQueryParm.getProvince ()).
if(StringUtils.isNotBlank (csEngineeringQueryParm.getUserId ())){
QueryWrapper<CsEngineeringUserPO> csEngineeringUserPOQueryWrapper = new QueryWrapper<> ();
csEngineeringUserPOQueryWrapper.lambda().eq(CsEngineeringUserPO::getUserId,csEngineeringQueryParm.getUserId ());
List<CsEngineeringUserPO> csEngineeringUserPOS = csEngineeringUserMapper.selectList(csEngineeringUserPOQueryWrapper);
List<String> collect = csEngineeringUserPOS.stream().map(CsEngineeringUserPO::getEngineeringId).collect(Collectors.toList());
if(CollectionUtil.isEmpty(collect)){
return csEngineeringVOList;
}
queryWrapper.in("id",collect);
}
queryWrapper.eq (StringUtils.isNotBlank (csEngineeringQueryParm.getProvince ()),"province",csEngineeringQueryParm.getProvince ()).
eq (StringUtils.isNotBlank (csEngineeringQueryParm.getCity ()),"city",csEngineeringQueryParm.getCity ()).
eq ("status","1" ).
like (StringUtils.isNotBlank (csEngineeringQueryParm.getName ()),"name",csEngineeringQueryParm.getName ()).orderByDesc("create_time");
@@ -115,8 +138,17 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
Page<CsEngineeringVO> returnPage = new Page<> (csEngineeringQueryPageParm.getPageNum ( ), csEngineeringQueryPageParm.getPageSize ( ));
QueryWrapper<CsEngineeringPO> queryWrapper = new QueryWrapper<> ();
queryWrapper.eq (StringUtils.isNotBlank (csEngineeringQueryPageParm.getUserId ()),"user_id",csEngineeringQueryPageParm.getUserId ()).
eq (StringUtils.isNotBlank (csEngineeringQueryPageParm.getProvince ()),"province",csEngineeringQueryPageParm.getProvince ()).
if(StringUtils.isNotBlank (csEngineeringQueryPageParm.getUserId ())){
QueryWrapper<CsEngineeringUserPO> csEngineeringUserPOQueryWrapper = new QueryWrapper<> ();
csEngineeringUserPOQueryWrapper.lambda().eq(CsEngineeringUserPO::getUserId,csEngineeringQueryPageParm.getUserId ());
List<CsEngineeringUserPO> csEngineeringUserPOS = csEngineeringUserMapper.selectList(csEngineeringUserPOQueryWrapper);
List<String> collect = csEngineeringUserPOS.stream().map(CsEngineeringUserPO::getEngineeringId).collect(Collectors.toList());
if(CollectionUtil.isEmpty(collect)){
return returnPage;
}
queryWrapper.in("id",collect);
}
queryWrapper.eq (StringUtils.isNotBlank (csEngineeringQueryPageParm.getProvince ()),"province",csEngineeringQueryPageParm.getProvince ()).
eq (StringUtils.isNotBlank (csEngineeringQueryPageParm.getCity ()),"city",csEngineeringQueryPageParm.getCity ()).
eq ("status","1" ).
like (StringUtils.isNotBlank (csEngineeringQueryPageParm.getName ()),"name",csEngineeringQueryPageParm.getName ()).orderByDesc("create_time");

View File

@@ -0,0 +1,37 @@
package com.njcn.csharmonic.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* Description:
* Date: 2023/6/14 15:09【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
public class CommonStatisticalQueryParam {
@ApiModelProperty(value = "设备id")
@NotBlank(message="设备id不能为空")
private String DevId;
@ApiModelProperty(value = "指标id")
@NotBlank(message="指标id不能为空")
private String statisticalId;
@ApiModelProperty(value = "取值类型MaxMincp95avg")
private String valueType;
@ApiModelProperty(value = "频次20-50")
private String frequency;
@ApiModelProperty(value = "开始时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
}

View File

@@ -18,11 +18,11 @@ public class ThdDataVO {
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private LocalDateTime time;
private String LineId;
private String lineId;
private String position;
private String Phase;
private String StatMethod;
private String phase;
private String statMethod;
private String statisticalIndex;
private String statisticalName;

View File

@@ -5,7 +5,9 @@ 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.csharmonic.param.CommonStatisticalQueryParam;
import com.njcn.csharmonic.service.StableDataService;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -36,6 +38,7 @@ public class StableDataController extends BaseController {
private final StableDataService stableDataService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryFisrtThdData")
@ApiOperation("查询谐波畸变率实时数据")
@@ -83,4 +86,21 @@ public class StableDataController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryFisrtCommonStatistical")
@ApiOperation("查询实时数据")
public HttpResult<List<ThdDataVO>> queryFisrtCommonStatistical(@RequestBody CommonStatisticalQueryParam commonStatisticalQueryParam) {
String methodDescribe = getMethodDescribe("queryFisrtCommonStatistical");
List<ThdDataVO> result = stableDataService.queryFisrtCommonStatistical(commonStatisticalQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryCommonStatisticalByTime")
@ApiOperation("查询时间段实时数据")
public HttpResult<List<ThdDataVO>> queryCommonStatisticalByTime(@RequestBody CommonStatisticalQueryParam commonStatisticalQueryParam) {
String methodDescribe = getMethodDescribe("queryFisrtCommonStatistical");
List<ThdDataVO> result = stableDataService.queryCommonStatisticalByTime(commonStatisticalQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -2,8 +2,10 @@ package com.njcn.csharmonic.service;
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
import com.njcn.csharmonic.param.ThdDataQueryParm;
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import java.util.List;
@@ -28,4 +30,8 @@ public interface StableDataService {
List<ThdDataVO> queryFisrtThdContent(String devId, String statisticalName);
List<ThdDataVO> queryThdContentByTime(ThdDataQueryParm thdDataQueryParm);
List<ThdDataVO> queryFisrtCommonStatistical(CommonStatisticalQueryParam commonStatisticalQueryParam);
List<ThdDataVO> queryCommonStatisticalByTime(CommonStatisticalQueryParam commonStatisticalQueryParam);
}

View File

@@ -1,12 +1,18 @@
package com.njcn.csharmonic.service.impl;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.api.CsLedgerFeignClient;
import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.utils.ReflectUtils;
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
import com.njcn.csharmonic.service.StableDataService;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import com.njcn.influx.service.CommonService;
import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.pojo.po.EleEpdPqd;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@@ -16,6 +22,9 @@ import com.njcn.influx.pojo.po.HarmonicRatioData;
import com.njcn.influx.pojo.po.PowerQualityData;
import com.njcn.influx.service.HaronicRatioService;
import com.njcn.influx.service.PowerQualityService;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.List;
@@ -37,6 +46,9 @@ public class StableDataServiceImpl implements StableDataService {
private final CsLineFeignClient csLineFeignClient;
private final PowerQualityService powerQualityService;
private final HaronicRatioService harmonicRatioService;
private final CsLedgerFeignClient csLedgerFeignClient;
private final EpdFeignClient epdFeignClient;
private final CommonService commonService;
@Override
public List<ThdDataVO> queryThdData(String devId, String statisticalName) {
@@ -140,4 +152,61 @@ public class StableDataServiceImpl implements StableDataService {
return thdDataVOList;
}
@Override
public List<ThdDataVO> queryFisrtCommonStatistical(CommonStatisticalQueryParam commonStatisticalQueryParam) {
List<CsLinePO> csLinePOList = csLineFeignClient.queryLineByDevId(commonStatisticalQueryParam.getDevId()).getData();
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData();
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.ELEEPDPQD_DATA_ERROR));
String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse("");
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtData(collect, data.getClassId(), data.getName()+frequency, data.getPhase(), commonStatisticalQueryParam.getValueType());
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(temp.getPhaseType());
String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime());
vo.setStatMethod(temp.getValueType());
vo.setStatisticalData(BigDecimal.valueOf(temp.getValue()).setScale(4, RoundingMode.UP).doubleValue());
vo.setStatisticalIndex(data.getId());
return vo;
}).collect(Collectors.toList());
return collect1;
}
@Override
public List<ThdDataVO> queryCommonStatisticalByTime(CommonStatisticalQueryParam commonStatisticalQueryParam) {
List<CsLinePO> csLinePOList = csLineFeignClient.queryLineByDevId(commonStatisticalQueryParam.getDevId()).getData();
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData();
List<CsLinePO> csLinePOList1 = Optional.ofNullable(csLinePOList).orElseThrow(() -> new BusinessException(AlgorithmResponseEnum.ELEEPDPQD_DATA_ERROR));
String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse("");
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(collect, data.getClassId(), data.getName()+frequency, data.getPhase(), commonStatisticalQueryParam.getValueType(),commonStatisticalQueryParam.getStartTime(),commonStatisticalQueryParam.getEndTime());
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(temp.getPhaseType());
String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime());
vo.setStatMethod(temp.getValueType());
vo.setStatisticalData(BigDecimal.valueOf(temp.getValue()).setScale(4, RoundingMode.UP).doubleValue());
vo.setStatisticalIndex(data.getId());
return vo;
}).collect(Collectors.toList());
return collect1;
}
}