1.数据方案修改
This commit is contained in:
@@ -112,7 +112,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.njcn</groupId>
|
<groupId>com.njcn</groupId>
|
||||||
<artifactId>pqs-influx</artifactId>
|
<artifactId>pqs-influx</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>1.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ import com.njcn.csdevice.pojo.param.WlRecordParam;
|
|||||||
import com.njcn.csdevice.pojo.po.WlRecord;
|
import com.njcn.csdevice.pojo.po.WlRecord;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -41,4 +43,8 @@ public interface WlRecordFeignClient {
|
|||||||
|
|
||||||
@PostMapping("/updateTestRecord")
|
@PostMapping("/updateTestRecord")
|
||||||
HttpResult<Boolean> updateTestRecord(@RequestBody @Validated WlRecordParam.UpdateRecord record);
|
HttpResult<Boolean> updateTestRecord(@RequestBody @Validated WlRecordParam.UpdateRecord record);
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/dayDealNoEndTimeEvent")
|
||||||
|
void dayDealNoEndTimeEvent(@RequestParam String date);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,12 @@ public class WlRecordClientFallbackFactory implements FallbackFactory<WlRecordFe
|
|||||||
log.error("{}异常,降级处理,异常为:{}","修改测试项",cause.toString());
|
log.error("{}异常,降级处理,异常为:{}","修改测试项",cause.toString());
|
||||||
throw new BusinessException(finalExceptionEnum);
|
throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dayDealNoEndTimeEvent(String date) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","每日处理没有结束时间的测试基础数据",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,9 +203,9 @@ public class WlRecordController extends BaseController {
|
|||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
@PostMapping("/dayDealNoEndTimeEvent")
|
@PostMapping("/dayDealNoEndTimeEvent")
|
||||||
@ApiOperation("每日处理没有结束时间的测试基础数据")
|
@ApiOperation("每日处理没有结束时间的测试基础数据")
|
||||||
public void dayDealNoEndTimeEvent() {
|
public void dayDealNoEndTimeEvent(@RequestParam("date") String date) {
|
||||||
String methodDescribe = getMethodDescribe("dayDealNoEndTimeEvent");
|
String methodDescribe = getMethodDescribe("dayDealNoEndTimeEvent");
|
||||||
wlRecordService.dayDealNoEndTimeEvent();
|
wlRecordService.dayDealNoEndTimeEvent(date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,6 @@ public interface IWlRecordService extends IService<WlRecord> {
|
|||||||
/**
|
/**
|
||||||
* 每日处理没有结束时间的测试基础数据
|
* 每日处理没有结束时间的测试基础数据
|
||||||
*/
|
*/
|
||||||
void dayDealNoEndTimeEvent();
|
void dayDealNoEndTimeEvent(String date);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,12 @@ package com.njcn.csdevice.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.date.DatePattern;
|
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.date.LocalDateTimeUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
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.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
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.api.EquipmentFeignClient;
|
||||||
import com.njcn.csdevice.constant.DataParam;
|
import com.njcn.csdevice.constant.DataParam;
|
||||||
import com.njcn.csdevice.enums.LineBaseEnum;
|
import com.njcn.csdevice.enums.LineBaseEnum;
|
||||||
import com.njcn.csdevice.mapper.CsDeviceUserPOMapper;
|
import com.njcn.csdevice.mapper.*;
|
||||||
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
|
|
||||||
import com.njcn.csdevice.mapper.CsLinePOMapper;
|
|
||||||
import com.njcn.csdevice.mapper.WlRecordMapper;
|
|
||||||
import com.njcn.csdevice.param.WlRecordPageParam;
|
import com.njcn.csdevice.param.WlRecordPageParam;
|
||||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||||
import com.njcn.csdevice.pojo.dto.CsEquipmentProcessDTO;
|
import com.njcn.csdevice.pojo.dto.CsEquipmentProcessDTO;
|
||||||
import com.njcn.csdevice.pojo.param.WlRecordParam;
|
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.CsEquipmentDeliveryPO;
|
||||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||||
import com.njcn.csdevice.pojo.po.WlRecord;
|
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.pojo.vo.RecordVo;
|
||||||
import com.njcn.csdevice.service.IWlRecordService;
|
import com.njcn.csdevice.service.IWlRecordService;
|
||||||
import com.njcn.csdevice.util.InfluxDbParamUtil;
|
import com.njcn.csdevice.util.InfluxDbParamUtil;
|
||||||
|
import com.njcn.csdevice.utils.DataChangeUtil;
|
||||||
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
||||||
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
||||||
import com.njcn.influx.imapper.CommonMapper;
|
import com.njcn.influx.imapper.CommonMapper;
|
||||||
@@ -43,6 +46,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.cglib.core.Local;
|
import net.sf.cglib.core.Local;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -77,6 +81,8 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
|||||||
|
|
||||||
private final CommonMapper commonMapper;
|
private final CommonMapper commonMapper;
|
||||||
|
|
||||||
|
private final CsDataSetMapper csDataSetMapper;
|
||||||
|
|
||||||
private final InfluxDbParamUtil influxDbParamUtil;
|
private final InfluxDbParamUtil influxDbParamUtil;
|
||||||
|
|
||||||
private final CsLinePOMapper csLinePOMapper;
|
private final CsLinePOMapper csLinePOMapper;
|
||||||
@@ -373,8 +379,17 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
|
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
|
||||||
|
|
||||||
for(WlRecord wl : data){
|
for(WlRecord wl : data){
|
||||||
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(wl.getLineId())).getData();
|
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();
|
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(wl.getDevId()).collect(Collectors.toList())).getData();
|
||||||
eleEpdPqds.forEach(epdPqd->{
|
eleEpdPqds.forEach(epdPqd->{
|
||||||
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
|
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
|
||||||
@@ -391,6 +406,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
|||||||
return commonQueryParam;
|
return commonQueryParam;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
|
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
|
||||||
|
deviceRtData.get(deviceRtData.size()-1).setValue(null);
|
||||||
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
||||||
ThdDataVO vo = new ThdDataVO();
|
ThdDataVO vo = new ThdDataVO();
|
||||||
vo.setLineId(temp.getLineId());
|
vo.setLineId(temp.getLineId());
|
||||||
@@ -399,7 +415,22 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
|||||||
vo.setPosition(position);
|
vo.setPosition(position);
|
||||||
vo.setTime(temp.getTime());
|
vo.setTime(temp.getTime());
|
||||||
vo.setStatMethod(temp.getValueType());
|
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.setStatisticalIndex(epdPqd.getId());
|
||||||
vo.setUnit(epdPqd.getUnit());
|
vo.setUnit(epdPqd.getUnit());
|
||||||
vo.setStatisticalName(epdPqd.getName());
|
vo.setStatisticalName(epdPqd.getName());
|
||||||
@@ -427,9 +458,13 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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<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);
|
List<WlRecord> wlRecordList = this.list(lambdaQueryWrapper);
|
||||||
if(CollUtil.isNotEmpty(wlRecordList)){
|
if(CollUtil.isNotEmpty(wlRecordList)){
|
||||||
|
|
||||||
@@ -508,8 +543,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
|||||||
});
|
});
|
||||||
|
|
||||||
if(CollUtil.isNotEmpty(poList)){
|
if(CollUtil.isNotEmpty(poList)){
|
||||||
System.out.println("444");
|
this.updateBatchById(poList);
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.njcn</groupId>
|
<groupId>com.njcn</groupId>
|
||||||
<artifactId>pqs-influx</artifactId>
|
<artifactId>pqs-influx</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>1.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ public class CommonStatisticalQueryParam {
|
|||||||
private String statisticalId;
|
private String statisticalId;
|
||||||
@ApiModelProperty(value = "取值类型(Max,Min,cp95,avg)")
|
@ApiModelProperty(value = "取值类型(Max,Min,cp95,avg)")
|
||||||
private String valueType;
|
private String valueType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "一次值:Primary;二次值:Secondary")
|
||||||
|
private String dataLevel;
|
||||||
|
|
||||||
@ApiModelProperty(value = "频次2-50")
|
@ApiModelProperty(value = "频次2-50")
|
||||||
private String frequency;
|
private String frequency;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.mybatis.spring.annotation.MapperScan;
|
|||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
import org.springframework.context.annotation.DependsOn;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,6 +17,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
|||||||
@MapperScan("com.njcn.**.mapper")
|
@MapperScan("com.njcn.**.mapper")
|
||||||
@EnableFeignClients(basePackages = "com.njcn")
|
@EnableFeignClients(basePackages = "com.njcn")
|
||||||
@SpringBootApplication(scanBasePackages = "com.njcn")
|
@SpringBootApplication(scanBasePackages = "com.njcn")
|
||||||
|
@DependsOn("proxyMapperRegister")
|
||||||
public class CsSystemBootApplication {
|
public class CsSystemBootApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
Reference in New Issue
Block a user