|
|
|
|
@@ -2,8 +2,12 @@ package com.njcn.csdevice.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
@@ -13,14 +17,12 @@ import com.njcn.csdevice.api.CsLineFeignClient;
|
|
|
|
|
import com.njcn.csdevice.api.EquipmentFeignClient;
|
|
|
|
|
import com.njcn.csdevice.constant.DataParam;
|
|
|
|
|
import com.njcn.csdevice.enums.LineBaseEnum;
|
|
|
|
|
import com.njcn.csdevice.mapper.CsDeviceUserPOMapper;
|
|
|
|
|
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
|
|
|
|
|
import com.njcn.csdevice.mapper.CsLinePOMapper;
|
|
|
|
|
import com.njcn.csdevice.mapper.WlRecordMapper;
|
|
|
|
|
import com.njcn.csdevice.mapper.*;
|
|
|
|
|
import com.njcn.csdevice.param.WlRecordPageParam;
|
|
|
|
|
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
|
|
|
|
import com.njcn.csdevice.pojo.dto.CsEquipmentProcessDTO;
|
|
|
|
|
import com.njcn.csdevice.pojo.param.WlRecordParam;
|
|
|
|
|
import com.njcn.csdevice.pojo.po.CsDataSet;
|
|
|
|
|
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
|
|
|
|
import com.njcn.csdevice.pojo.po.CsLinePO;
|
|
|
|
|
import com.njcn.csdevice.pojo.po.WlRecord;
|
|
|
|
|
@@ -29,6 +31,7 @@ import com.njcn.csdevice.pojo.vo.RecordTreeVo;
|
|
|
|
|
import com.njcn.csdevice.pojo.vo.RecordVo;
|
|
|
|
|
import com.njcn.csdevice.service.IWlRecordService;
|
|
|
|
|
import com.njcn.csdevice.util.InfluxDbParamUtil;
|
|
|
|
|
import com.njcn.csdevice.utils.DataChangeUtil;
|
|
|
|
|
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
|
|
|
|
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
|
|
|
|
import com.njcn.influx.imapper.CommonMapper;
|
|
|
|
|
@@ -43,6 +46,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import net.sf.cglib.core.Local;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
@@ -77,6 +81,8 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
|
|
|
|
|
|
|
|
|
private final CommonMapper commonMapper;
|
|
|
|
|
|
|
|
|
|
private final CsDataSetMapper csDataSetMapper;
|
|
|
|
|
|
|
|
|
|
private final InfluxDbParamUtil influxDbParamUtil;
|
|
|
|
|
|
|
|
|
|
private final CsLinePOMapper csLinePOMapper;
|
|
|
|
|
@@ -373,8 +379,17 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
|
|
|
|
|
|
|
|
|
|
for(WlRecord wl : data){
|
|
|
|
|
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(wl.getLineId())).getData();
|
|
|
|
|
CsDataSet csDataSet = csDataSetMapper.selectOne(new LambdaQueryWrapper<CsDataSet>().eq(CsDataSet::getId,finalCsLinePOList.get(0).getDataSetId()));
|
|
|
|
|
if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())){
|
|
|
|
|
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
|
|
|
|
|
}
|
|
|
|
|
Double ct = finalCsLinePOList.get(0).getCtRatio();
|
|
|
|
|
Double pt = finalCsLinePOList.get(0).getPtRatio();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(wl.getDevId()).collect(Collectors.toList())).getData();
|
|
|
|
|
eleEpdPqds.forEach(epdPqd->{
|
|
|
|
|
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
|
|
|
|
|
@@ -391,6 +406,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
|
|
|
|
return commonQueryParam;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
|
|
|
|
|
deviceRtData.get(deviceRtData.size()-1).setValue(null);
|
|
|
|
|
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
|
|
|
|
ThdDataVO vo = new ThdDataVO();
|
|
|
|
|
vo.setLineId(temp.getLineId());
|
|
|
|
|
@@ -399,7 +415,22 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
|
|
|
|
vo.setPosition(position);
|
|
|
|
|
vo.setTime(temp.getTime());
|
|
|
|
|
vo.setStatMethod(temp.getValueType());
|
|
|
|
|
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
|
|
|
|
|
|
|
|
|
if(temp.getValue()!=null) {
|
|
|
|
|
if (ObjectUtil.isNotNull(epdPqd.getPrimaryFormula()) && !Objects.equals(csDataSet.getDataLevel(), commonStatisticalQueryParam.getDataLevel())) {
|
|
|
|
|
Double re;
|
|
|
|
|
if ("Primary".equals(csDataSet.getDataLevel())) {
|
|
|
|
|
re = DataChangeUtil.primaryToSecondary(epdPqd.getPrimaryFormula(), temp.getValue(), pt, ct);
|
|
|
|
|
} else {
|
|
|
|
|
re = DataChangeUtil.secondaryToPrimary(epdPqd.getPrimaryFormula(), temp.getValue(), pt, ct);
|
|
|
|
|
}
|
|
|
|
|
vo.setStatisticalData(Double.valueOf(df.format(re)));
|
|
|
|
|
} else {
|
|
|
|
|
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
vo.setStatisticalData(null);
|
|
|
|
|
}
|
|
|
|
|
vo.setStatisticalIndex(epdPqd.getId());
|
|
|
|
|
vo.setUnit(epdPqd.getUnit());
|
|
|
|
|
vo.setStatisticalName(epdPqd.getName());
|
|
|
|
|
@@ -427,9 +458,13 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void dayDealNoEndTimeEvent() {
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void dayDealNoEndTimeEvent(String date) {
|
|
|
|
|
DateTime dateEnd = DateUtil.parse(date,DatePattern.NORM_DATE_PATTERN);
|
|
|
|
|
DateTime dateStart = DateUtil.offsetDay(dateEnd,-30);
|
|
|
|
|
System.out.println("进入定时任务");
|
|
|
|
|
LambdaQueryWrapper<WlRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
lambdaQueryWrapper.eq(WlRecord::getType,1).eq(WlRecord::getState,DataStateEnum.ENABLE.getCode());
|
|
|
|
|
lambdaQueryWrapper.between(WlRecord::getStartTime,dateStart,dateEnd).eq(WlRecord::getType,1).eq(WlRecord::getState,DataStateEnum.ENABLE.getCode());
|
|
|
|
|
List<WlRecord> wlRecordList = this.list(lambdaQueryWrapper);
|
|
|
|
|
if(CollUtil.isNotEmpty(wlRecordList)){
|
|
|
|
|
|
|
|
|
|
@@ -508,8 +543,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(poList)){
|
|
|
|
|
System.out.println("444");
|
|
|
|
|
//
|
|
|
|
|
this.updateBatchById(poList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|