1.无线设bug修改
2.添加测试项每日扫描功能
This commit is contained in:
@@ -195,5 +195,17 @@ public class WlRecordController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, record, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 每日处理没有结束时间的测试基础数据
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/dayDealNoEndTimeEvent")
|
||||
@ApiOperation("每日处理没有结束时间的测试基础数据")
|
||||
public void dayDealNoEndTimeEvent() {
|
||||
String methodDescribe = getMethodDescribe("dayDealNoEndTimeEvent");
|
||||
wlRecordService.dayDealNoEndTimeEvent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
<if test="wlRecordPageParam.isTrueFlag == 0">
|
||||
select a.dev_id as id,b.name as name from wl_record a
|
||||
left join cs_equipment_delivery b on a.dev_id = b.id
|
||||
where a.type=1 and a.state =1 and
|
||||
where a.type=1 and a.state =1 and a.end_time is not null
|
||||
and
|
||||
(select count(1) from wl_record wl where wl.dev_id = a.dev_id) >
|
||||
(select count(1) from wl_record_test_data wd where wd.test_item_id = #{wlRecordPageParam.id}
|
||||
and data_id in (select w.id from wl_record w where w.dev_id = a.dev_id))
|
||||
@@ -32,7 +33,8 @@
|
||||
<if test="wlRecordPageParam.isTrueFlag == 1">
|
||||
select a.dev_id as id,b.name as name from wl_record a
|
||||
left join cs_equipment_delivery b on a.dev_id = b.id
|
||||
where a.type=1 and a.state =1 and exists
|
||||
where a.type=1 and a.state =1 and a.end_time is not null
|
||||
and exists
|
||||
(select 1 from wl_record wl where wl.dev_id = a.dev_id and wl.type=1 and wl.state =1
|
||||
and exists (select 1 from wl_record_test_data wd where wd.test_item_id = #{wlRecordPageParam.id} and wd.data_id = wl.id))
|
||||
group by a.dev_id,b.name having a.dev_id is not null and b.name is not null
|
||||
@@ -55,7 +57,7 @@
|
||||
<select id="getRecordAllTime" resultType="com.njcn.csdevice.pojo.vo.RecordAllDevTreeVo$RecordAllTimeTreeVo">
|
||||
select a.id as id,concat(a.start_time,'-',a.end_time) as name, concat(#{wlRecordPageParam.lineId},'-',#{wlRecordPageParam.devId}) as pid from wl_record a
|
||||
left join cs_line c on a.line_id = c.line_id
|
||||
where a.type=1 and a.state =1 and a.dev_id=#{wlRecordPageParam.devId} and a.line_id=#{wlRecordPageParam.lineId}
|
||||
where a.type=1 and a.state =1 and a.end_time is not null and a.dev_id=#{wlRecordPageParam.devId} and a.line_id=#{wlRecordPageParam.lineId}
|
||||
and
|
||||
<if test="wlRecordPageParam.isTrueFlag == 0">
|
||||
not
|
||||
|
||||
@@ -102,4 +102,10 @@ public interface IWlRecordService extends IService<WlRecord> {
|
||||
*/
|
||||
WlRecord findDevBaseData(WlRecordParam.Record param);
|
||||
|
||||
|
||||
/**
|
||||
* 每日处理没有结束时间的测试基础数据
|
||||
*/
|
||||
void dayDealNoEndTimeEvent();
|
||||
|
||||
}
|
||||
|
||||
@@ -392,6 +392,8 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
csEventUserQueryPage.setPageNum(commonStatisticalQueryParam.getPageNum());
|
||||
csEventUserQueryPage.setPageSize(commonStatisticalQueryParam.getPageSize());
|
||||
csEventUserQueryPage.setLineId(commonStatisticalQueryParam.getLineId());
|
||||
csEventUserQueryPage.setStartTime(commonStatisticalQueryParam.getStartTime());
|
||||
csEventUserQueryPage.setEndTime(commonStatisticalQueryParam.getEndTime());
|
||||
Page<DataGroupEventVO> csEventVOPage = eventFeignClient.pageQueryByLineId(csEventUserQueryPage).getData();
|
||||
|
||||
csEventVOPage.getRecords().forEach(temp->{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -30,19 +31,23 @@ import com.njcn.csdevice.service.IWlRecordService;
|
||||
import com.njcn.csdevice.util.InfluxDbParamUtil;
|
||||
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
||||
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
||||
import com.njcn.influx.imapper.CommonMapper;
|
||||
import com.njcn.influx.pojo.bo.CommonQueryParam;
|
||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||
import com.njcn.influx.service.CommonService;
|
||||
import com.njcn.system.api.CsStatisticalSetFeignClient;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.cglib.core.Local;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
@@ -70,6 +75,8 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
||||
|
||||
private final CommonService commonService;
|
||||
|
||||
private final CommonMapper commonMapper;
|
||||
|
||||
private final InfluxDbParamUtil influxDbParamUtil;
|
||||
|
||||
private final CsLinePOMapper csLinePOMapper;
|
||||
@@ -157,13 +164,13 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
||||
public RecordVo.RecordItemVo getTestRecordById(String testRecordId) {
|
||||
RecordVo.RecordItemVo recordItemVo = new RecordVo.RecordItemVo();
|
||||
List<RecordVo> recordVoList = new ArrayList<>();
|
||||
LambdaQueryWrapper<WlRecord> qw = new LambdaQueryWrapper();
|
||||
LambdaQueryWrapper<WlRecord> qw = new LambdaQueryWrapper<>();
|
||||
qw.eq(WlRecord::getId,testRecordId).eq(WlRecord::getType,0).eq(WlRecord::getState,1);
|
||||
List<WlRecord> list = this.baseMapper.selectList(qw);
|
||||
WlRecord wlRecord = list.get(0);
|
||||
//当前ID就是测试项ID直接返回
|
||||
if(wlRecord.getPId()!=null){
|
||||
qw = new LambdaQueryWrapper();
|
||||
qw.clear();
|
||||
qw.eq(WlRecord::getId,wlRecord.getPId()).eq(WlRecord::getType,0).eq(WlRecord::getState,1);
|
||||
List<WlRecord> wlRecordList = this.baseMapper.selectList(qw);
|
||||
recordItemVo.setDescribe(wlRecordList.get(0).getDescribe());
|
||||
@@ -177,9 +184,10 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
||||
//反之则是方案ID 则返回该方案下所有的测试项信息
|
||||
recordItemVo.setDescribe(wlRecord.getDescribe());
|
||||
recordItemVo.setItemName(wlRecord.getItemName());
|
||||
qw = new LambdaQueryWrapper();
|
||||
qw.clear();
|
||||
qw.eq(WlRecord::getPId,testRecordId).eq(WlRecord::getType,0).eq(WlRecord::getState,1).orderByAsc(WlRecord::getCreateTime);;
|
||||
for (WlRecord wl : this.baseMapper.selectList(qw)){
|
||||
List<WlRecord> wlRecordList = this.baseMapper.selectList(qw);
|
||||
for (WlRecord wl : wlRecordList){
|
||||
RecordVo recordVo = new RecordVo();
|
||||
wl.setStartTime(getFirstTimeById(wl.getId()));
|
||||
wl.setEndTime(getLastTimeById(wl.getId()));
|
||||
@@ -418,6 +426,96 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
||||
return this.getOne(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dayDealNoEndTimeEvent() {
|
||||
LambdaQueryWrapper<WlRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(WlRecord::getType,1).eq(WlRecord::getState,DataStateEnum.ENABLE.getCode());
|
||||
List<WlRecord> wlRecordList = this.list(lambdaQueryWrapper);
|
||||
if(CollUtil.isNotEmpty(wlRecordList)){
|
||||
|
||||
//需要处理的基础数据
|
||||
List<WlRecord> needDealList = wlRecordList.stream().filter(it->Objects.isNull(it.getEndTime())).collect(Collectors.toList());
|
||||
List<String> needIds = needDealList.stream().map(WlRecord::getLineId).distinct().collect(Collectors.toList());
|
||||
|
||||
Map<String,List<WlRecord>> lineMap = wlRecordList.stream().collect(Collectors.groupingBy(WlRecord::getLineId));
|
||||
|
||||
List<WlRecord> poList = new ArrayList<>();
|
||||
lineMap.forEach((lineId,list)->{
|
||||
if(needIds.contains(lineId)){
|
||||
//选择起始时间进行倒序
|
||||
list = list.stream().sorted(Comparator.comparing(WlRecord::getStartTime)).collect(Collectors.toList());
|
||||
for(int i=0;i<list.size();i++){
|
||||
LocalDateTime start = list.get(i).getStartTime();
|
||||
String startSql = start.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
|
||||
if(i==list.size()-1){
|
||||
//判断最迟时间的数据是否没有结束时间
|
||||
if(Objects.isNull(list.get(i).getEndTime())){
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String sqlNow = now.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("pqd_data",StatisticalDataDTO.class);
|
||||
influxQueryWrapper.select(StatisticalDataDTO::getLineId)
|
||||
.select(StatisticalDataDTO::getPhaseType)
|
||||
.select(StatisticalDataDTO::getValueType)
|
||||
.last("Pq_Freq")
|
||||
.eq(InfluxDBTableConstant.LINE_ID,lineId)
|
||||
.eq(InfluxDBTableConstant.PHASIC_TYPE,"M")
|
||||
.between(InfluxDBTableConstant.TIME,startSql,sqlNow);
|
||||
System.out.println(influxQueryWrapper.generateSql());
|
||||
StatisticalDataDTO statisticalDataDTO = commonMapper.getLineRtData(influxQueryWrapper);
|
||||
if(Objects.nonNull(statisticalDataDTO)){
|
||||
LocalDateTime endTime = statisticalDataDTO.getTime().atOffset(ZoneOffset.ofHours(0)).toLocalDateTime();
|
||||
Duration duration = Duration.between(now, endTime);
|
||||
long hour = duration.toHours();
|
||||
if(hour>6){
|
||||
WlRecord wlRecord = new WlRecord();
|
||||
wlRecord.setId(list.get(i).getId());
|
||||
wlRecord.setEndTime(endTime);
|
||||
poList.add(wlRecord);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}else {
|
||||
//如果不存在结束时间,则取后面一条的起始时间作为结束判断标识
|
||||
if(Objects.isNull(list.get(i).getEndTime())){
|
||||
String end = list.get(i+1).getStartTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("pqd_data",StatisticalDataDTO.class);
|
||||
influxQueryWrapper.select(StatisticalDataDTO::getLineId)
|
||||
.select(StatisticalDataDTO::getPhaseType)
|
||||
.select(StatisticalDataDTO::getValueType)
|
||||
.last("Pq_Freq")
|
||||
.eq(InfluxDBTableConstant.LINE_ID,lineId)
|
||||
.eq(InfluxDBTableConstant.PHASIC_TYPE,"M")
|
||||
.between(InfluxDBTableConstant.TIME,startSql,end);
|
||||
System.out.println(influxQueryWrapper.generateSql());
|
||||
StatisticalDataDTO statisticalDataDTO = commonMapper.getLineRtData(influxQueryWrapper);
|
||||
WlRecord wlRecord = new WlRecord();
|
||||
wlRecord.setId(list.get(i).getId());
|
||||
|
||||
if(Objects.nonNull(statisticalDataDTO)){
|
||||
LocalDateTime endTime = statisticalDataDTO.getTime().atOffset(ZoneOffset.ofHours(0)).toLocalDateTime();
|
||||
wlRecord.setEndTime(endTime);
|
||||
}else {
|
||||
//TODO 如果查询时间段内无数据,说明装置可能时间段内掉线,出错,需要标识出来
|
||||
wlRecord.setEndTime(list.get(i+1).getStartTime());
|
||||
}
|
||||
poList.add(wlRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if(CollUtil.isNotEmpty(poList)){
|
||||
System.out.println("444");
|
||||
//
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据项内的时间进行覆盖:解决多个数据项的startTime及endTime之间存在时间冲突
|
||||
* @param data 数据项
|
||||
@@ -538,7 +636,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
||||
if(recordIds.isEmpty()){
|
||||
recordIds.add("-1");
|
||||
}
|
||||
qw.eq(WlRecord::getState,"1").in(WlRecord::getId,recordIds).orderByAsc(WlRecord::getEndTime);
|
||||
qw.eq(WlRecord::getState,"1").in(WlRecord::getId,recordIds).orderByDesc(WlRecord::getEndTime);
|
||||
List<WlRecord> list = this.baseMapper.selectList(qw);
|
||||
if(list.isEmpty()){
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user