多监测点趋势对比
This commit is contained in:
@@ -4,8 +4,11 @@ import com.alibaba.nacos.client.naming.utils.CollectionUtils;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||||
|
import com.njcn.csdevice.mapper.CsLedgerMapper;
|
||||||
import com.njcn.csdevice.pojo.param.CsTouristDataParm;
|
import com.njcn.csdevice.pojo.param.CsTouristDataParm;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsLedger;
|
||||||
import com.njcn.csdevice.pojo.vo.CsTouristDataParmVO;
|
import com.njcn.csdevice.pojo.vo.CsTouristDataParmVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -29,23 +32,32 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
* @version V1.0.0
|
* @version V1.0.0
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class CsTouristDataPOServiceImpl extends ServiceImpl<CsTouristDataPOMapper, CsTouristDataPO> implements CsTouristDataPOService{
|
public class CsTouristDataPOServiceImpl extends ServiceImpl<CsTouristDataPOMapper, CsTouristDataPO> implements CsTouristDataPOService{
|
||||||
|
private final CsLedgerMapper csLedgerMapper;
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public Boolean add(List<CsTouristDataParm> csTouristDataParms) {
|
public Boolean add(List<CsTouristDataParm> csTouristDataParms) {
|
||||||
QueryWrapper<CsTouristDataPO> QueryWrapper = new QueryWrapper<>();
|
QueryWrapper<CsTouristDataPO> QueryWrapper = new QueryWrapper<>();
|
||||||
|
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>();
|
||||||
|
this.getBaseMapper().delete(null);
|
||||||
List<CsTouristDataPO> list = new ArrayList<>();
|
List<CsTouristDataPO> list = new ArrayList<>();
|
||||||
csTouristDataParms.forEach(temp->{
|
csTouristDataParms.forEach(temp->{
|
||||||
QueryWrapper.clear();
|
QueryWrapper.clear();
|
||||||
QueryWrapper.eq(CsTouristDataPO.COL_DEVICE_ID,temp.getDeviceId());
|
QueryWrapper.eq(CsTouristDataPO.COL_DEVICE_ID,temp.getDeviceId());
|
||||||
CsTouristDataPO csTouristDataPO = this.getBaseMapper().selectOne(QueryWrapper);
|
CsTouristDataPO csTouristDataPO = this.getBaseMapper().selectOne(QueryWrapper);
|
||||||
if(Objects.isNull(csTouristDataPO)){
|
if(!Objects.isNull(csTouristDataPO)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CsTouristDataPO csTouristDataPO1 = new CsTouristDataPO();
|
csTouristDataPO = new CsTouristDataPO();
|
||||||
BeanUtils.copyProperties(temp, csTouristDataPO1);
|
csTouristDataPO.setDeviceId(temp.getDeviceId());
|
||||||
list.add(csTouristDataPO1);
|
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);
|
boolean b = this.saveBatch(list);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description:
|
* Description:
|
||||||
@@ -14,8 +15,9 @@ import javax.validation.constraints.NotBlank;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class CommonStatisticalQueryParam {
|
public class CommonStatisticalQueryParam {
|
||||||
|
@ApiModelProperty(value = "监测点集")
|
||||||
|
private List<String> lineList;
|
||||||
@ApiModelProperty(value = "设备id")
|
@ApiModelProperty(value = "设备id")
|
||||||
@NotBlank(message="设备id不能为空")
|
|
||||||
private String DevId;
|
private String DevId;
|
||||||
@ApiModelProperty(value = "指标id")
|
@ApiModelProperty(value = "指标id")
|
||||||
@NotBlank(message="指标id不能为空")
|
@NotBlank(message="指标id不能为空")
|
||||||
|
|||||||
@@ -103,4 +103,14 @@ public class StableDataController extends BaseController {
|
|||||||
List<ThdDataVO> result = stableDataService.queryCommonStatisticalByTime(commonStatisticalQueryParam);
|
List<ThdDataVO> result = stableDataService.queryCommonStatisticalByTime(commonStatisticalQueryParam);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -34,4 +34,6 @@ public interface StableDataService {
|
|||||||
List<ThdDataVO> queryFisrtCommonStatistical(CommonStatisticalQueryParam commonStatisticalQueryParam);
|
List<ThdDataVO> queryFisrtCommonStatistical(CommonStatisticalQueryParam commonStatisticalQueryParam);
|
||||||
|
|
||||||
List<ThdDataVO> queryCommonStatisticalByTime(CommonStatisticalQueryParam commonStatisticalQueryParam);
|
List<ThdDataVO> queryCommonStatisticalByTime(CommonStatisticalQueryParam commonStatisticalQueryParam);
|
||||||
|
|
||||||
|
List<ThdDataVO> queryLineCommonStatistical(CommonStatisticalQueryParam commonStatisticalQueryParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ public class StableDataServiceImpl implements StableDataService {
|
|||||||
|
|
||||||
|
|
||||||
EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData();
|
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("");
|
String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse("");
|
||||||
|
|
||||||
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtData(collect, data.getClassId(), data.getName()+frequency, data.getPhase(), commonStatisticalQueryParam.getValueType());
|
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();
|
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("");
|
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<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(collect, data.getClassId(), data.getName()+frequency, data.getPhase(), commonStatisticalQueryParam.getValueType(),commonStatisticalQueryParam.getStartTime(),commonStatisticalQueryParam.getEndTime());
|
||||||
|
|||||||
Reference in New Issue
Block a user