多监测点趋势对比

This commit is contained in:
huangzj
2023-07-03 08:58:55 +08:00
parent e4f441fb85
commit 26a14a7c6b
5 changed files with 62 additions and 8 deletions

View File

@@ -4,8 +4,11 @@ import com.alibaba.nacos.client.naming.utils.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.mapper.CsLedgerMapper;
import com.njcn.csdevice.pojo.param.CsTouristDataParm;
import com.njcn.csdevice.pojo.po.CsLedger;
import com.njcn.csdevice.pojo.vo.CsTouristDataParmVO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@@ -29,23 +32,32 @@ import org.springframework.transaction.annotation.Transactional;
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class CsTouristDataPOServiceImpl extends ServiceImpl<CsTouristDataPOMapper, CsTouristDataPO> implements CsTouristDataPOService{
private final CsLedgerMapper csLedgerMapper;
@Override
@Transactional(rollbackFor = {Exception.class})
public Boolean add(List<CsTouristDataParm> csTouristDataParms) {
QueryWrapper<CsTouristDataPO> QueryWrapper = new QueryWrapper<>();
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>();
this.getBaseMapper().delete(null);
List<CsTouristDataPO> list = new ArrayList<>();
csTouristDataParms.forEach(temp->{
QueryWrapper.clear();
QueryWrapper.eq(CsTouristDataPO.COL_DEVICE_ID,temp.getDeviceId());
CsTouristDataPO csTouristDataPO = this.getBaseMapper().selectOne(QueryWrapper);
if(Objects.isNull(csTouristDataPO)){
if(!Objects.isNull(csTouristDataPO)){
return;
}
CsTouristDataPO csTouristDataPO1 = new CsTouristDataPO();
BeanUtils.copyProperties(temp, csTouristDataPO1);
list.add(csTouristDataPO1);
csTouristDataPO = new CsTouristDataPO();
csTouristDataPO.setDeviceId(temp.getDeviceId());
csLedgerQueryWrapper.clear();
csLedgerQueryWrapper.eq("id",temp.getDeviceId());
CsLedger csLedger = csLedgerMapper.selectOne(csLedgerQueryWrapper);
String[] split = csLedger.getPids().split(",");
csTouristDataPO.setEnginerId(split[1]);
csTouristDataPO.setProjectId(split[2]);
list.add(csTouristDataPO);
});
boolean b = this.saveBatch(list);

View File

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* Description:
@@ -14,8 +15,9 @@ import javax.validation.constraints.NotBlank;
*/
@Data
public class CommonStatisticalQueryParam {
@ApiModelProperty(value = "监测点集")
private List<String> lineList;
@ApiModelProperty(value = "设备id")
@NotBlank(message="设备id不能为空")
private String DevId;
@ApiModelProperty(value = "指标id")
@NotBlank(message="指标id不能为空")

View File

@@ -103,4 +103,14 @@ public class StableDataController extends BaseController {
List<ThdDataVO> result = stableDataService.queryCommonStatisticalByTime(commonStatisticalQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryLineCommonStatistical")
@ApiOperation("多监测点数据比较")
public HttpResult<List<ThdDataVO>> queryLineCommonStatistical(@RequestBody CommonStatisticalQueryParam commonStatisticalQueryParam) {
String methodDescribe = getMethodDescribe("queryFisrtCommonStatistical");
List<ThdDataVO> result = stableDataService.queryLineCommonStatistical(commonStatisticalQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -34,4 +34,6 @@ public interface StableDataService {
List<ThdDataVO> queryFisrtCommonStatistical(CommonStatisticalQueryParam commonStatisticalQueryParam);
List<ThdDataVO> queryCommonStatisticalByTime(CommonStatisticalQueryParam commonStatisticalQueryParam);
List<ThdDataVO> queryLineCommonStatistical(CommonStatisticalQueryParam commonStatisticalQueryParam);
}

View File

@@ -161,7 +161,7 @@ public class StableDataServiceImpl implements StableDataService {
EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData();
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.ELEEPDPQD_DATA_ERROR));
Optional.ofNullable(data).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());
@@ -189,7 +189,35 @@ public class StableDataServiceImpl implements StableDataService {
EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData();
List<CsLinePO> csLinePOList1 = Optional.ofNullable(csLinePOList).orElseThrow(() -> new BusinessException(AlgorithmResponseEnum.ELEEPDPQD_DATA_ERROR));
Optional.ofNullable(data).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;
}
@Override
public List<ThdDataVO> queryLineCommonStatistical(CommonStatisticalQueryParam commonStatisticalQueryParam) {
List<CsLinePO> csLinePOList = csLineFeignClient.queryLineById(commonStatisticalQueryParam.getLineList()).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(data).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());