|
@@ -11,6 +11,7 @@ import com.bizmatics.common.core.util.*;
|
|
|
import com.bizmatics.common.mvc.base.AbstractCrudService;
|
|
|
import com.bizmatics.common.spring.util.GlobalUtils;
|
|
|
import com.bizmatics.model.*;
|
|
|
+import com.bizmatics.model.vo.ContextualDataVo;
|
|
|
import com.bizmatics.model.vo.EvaluationReporVo;
|
|
|
import com.bizmatics.persistence.mapper.RtAnalogDataMapper;
|
|
|
import com.bizmatics.service.DeviceAttributeService;
|
|
@@ -34,6 +35,8 @@ import java.text.DateFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -148,15 +151,26 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
|
|
|
|
|
|
@Override
|
|
|
public RealScoreVO realScore(String deviceCode) {
|
|
|
- LambdaQueryWrapper<RtAnalogData> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.eq(RtAnalogData::getDeviceName, deviceCode);
|
|
|
- RtAnalogData rtAnalogData = getOne(queryWrapper);
|
|
|
- Optional.ofNullable(rtAnalogData).orElseThrow(() -> new BusinessException("设备实时信息不存在"));
|
|
|
//查询设备
|
|
|
LambdaQueryWrapper<Device> deviceQuery = Wrappers.lambdaQuery();
|
|
|
deviceQuery.eq(Device::getDeviceCode, deviceCode);
|
|
|
Device device = deviceService.getOne(deviceQuery);
|
|
|
Optional.ofNullable(device).orElseThrow(() -> new BusinessException("设备不存在"));
|
|
|
+
|
|
|
+ String table = "rt_analog_data";
|
|
|
+ if (device.getDeviceType().equals("1")){
|
|
|
+ table = "rt_analog_data";
|
|
|
+ }else if (device.getDeviceType().equals("4")){
|
|
|
+ table = "rt_analog_173_data";
|
|
|
+ }
|
|
|
+
|
|
|
+ List<RtAnalogData> rtAnalogDataList = baseMapper.getRtAnalogDataList(deviceCode,table);
|
|
|
+ RtAnalogData rtAnalogData = new RtAnalogData();
|
|
|
+ if (rtAnalogDataList.size()>0){
|
|
|
+ rtAnalogData = rtAnalogDataList.get(0);
|
|
|
+ }else {
|
|
|
+ new BusinessException("设备实时信息不存在");
|
|
|
+ }
|
|
|
//查询sd
|
|
|
LambdaQueryWrapper<SiteDynamicProperties> sdQuery = Wrappers.lambdaQuery();
|
|
|
sdQuery.eq(SiteDynamicProperties::getSiteId, device.getSiteId());
|
|
@@ -171,18 +185,55 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
|
|
|
DeviceAttribute deviceAttribute = deviceAttributes.stream().min(Comparator.comparing(DeviceAttribute::getId)).get();
|
|
|
return fillRealScoreData(rtAnalogData, siteDynamicProperties, deviceAttribute);
|
|
|
}
|
|
|
+// public RealScoreVO realScore(String deviceCode) {
|
|
|
+// LambdaQueryWrapper<RtAnalogData> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+// queryWrapper.eq(RtAnalogData::getDeviceName, deviceCode);
|
|
|
+// RtAnalogData rtAnalogData = getOne(queryWrapper);
|
|
|
+// Optional.ofNullable(rtAnalogData).orElseThrow(() -> new BusinessException("设备实时信息不存在"));
|
|
|
+// //查询设备
|
|
|
+// LambdaQueryWrapper<Device> deviceQuery = Wrappers.lambdaQuery();
|
|
|
+// deviceQuery.eq(Device::getDeviceCode, deviceCode);
|
|
|
+// Device device = deviceService.getOne(deviceQuery);
|
|
|
+// Optional.ofNullable(device).orElseThrow(() -> new BusinessException("设备不存在"));
|
|
|
+// //查询sd
|
|
|
+// LambdaQueryWrapper<SiteDynamicProperties> sdQuery = Wrappers.lambdaQuery();
|
|
|
+// sdQuery.eq(SiteDynamicProperties::getSiteId, device.getSiteId());
|
|
|
+// SiteDynamicProperties siteDynamicProperties = siteDynamicPropertiesService.getOne(sdQuery);
|
|
|
+// Optional.ofNullable(siteDynamicProperties).orElseThrow(() -> new BusinessException("sd不存在"));
|
|
|
+// LambdaQueryWrapper<DeviceAttribute> adQuery = Wrappers.lambdaQuery();
|
|
|
+// adQuery.eq(DeviceAttribute::getSiteId, device.getSiteId());
|
|
|
+// List<DeviceAttribute> deviceAttributes = deviceAttributeService.list(adQuery);
|
|
|
+// if (CollectionUtils.isEmpty(deviceAttributes)) {
|
|
|
+// throw new BusinessException("da不存在");
|
|
|
+// }
|
|
|
+// DeviceAttribute deviceAttribute = deviceAttributes.stream().min(Comparator.comparing(DeviceAttribute::getId)).get();
|
|
|
+// return fillRealScoreData(rtAnalogData, siteDynamicProperties, deviceAttribute);
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
public RealScoreOneVO realScoreOne(String deviceCode) {
|
|
|
- LambdaQueryWrapper<RtAnalogData> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.eq(RtAnalogData::getDeviceName, deviceCode);
|
|
|
- RtAnalogData rtAnalogData = getOne(queryWrapper);
|
|
|
- Optional.ofNullable(rtAnalogData).orElseThrow(() -> new BusinessException("设备实时信息不存在"));
|
|
|
//查询设备
|
|
|
LambdaQueryWrapper<Device> deviceQuery = Wrappers.lambdaQuery();
|
|
|
deviceQuery.eq(Device::getDeviceCode, deviceCode);
|
|
|
Device device = deviceService.getOne(deviceQuery);
|
|
|
Optional.ofNullable(device).orElseThrow(() -> new BusinessException("设备不存在"));
|
|
|
+
|
|
|
+
|
|
|
+ String table = "rt_analog_data";
|
|
|
+ if (device.getDeviceType().equals("1")){
|
|
|
+ table = "rt_analog_data";
|
|
|
+ }else if (device.getDeviceType().equals("4")){
|
|
|
+ table = "rt_analog_173_data";
|
|
|
+ }
|
|
|
+
|
|
|
+ List<RtAnalogData> rtAnalogDataList = baseMapper.getRtAnalogDataList(deviceCode,table);
|
|
|
+ RtAnalogData rtAnalogData = new RtAnalogData();
|
|
|
+ if (rtAnalogDataList.size()>0){
|
|
|
+ rtAnalogData = rtAnalogDataList.get(0);
|
|
|
+ }else {
|
|
|
+ new BusinessException("设备实时信息不存在");
|
|
|
+ }
|
|
|
+
|
|
|
//查询sd
|
|
|
LambdaQueryWrapper<SiteDynamicProperties> sdQuery = Wrappers.lambdaQuery();
|
|
|
sdQuery.eq(SiteDynamicProperties::getSiteId, device.getSiteId());
|
|
@@ -191,6 +242,24 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
|
|
|
return fillRealScoreDataOne(rtAnalogData, siteDynamicProperties);
|
|
|
}
|
|
|
|
|
|
+// public RealScoreOneVO realScoreOne(String deviceCode) {
|
|
|
+// LambdaQueryWrapper<RtAnalogData> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+// queryWrapper.eq(RtAnalogData::getDeviceName, deviceCode);
|
|
|
+// RtAnalogData rtAnalogData = getOne(queryWrapper);
|
|
|
+// Optional.ofNullable(rtAnalogData).orElseThrow(() -> new BusinessException("设备实时信息不存在"));
|
|
|
+// //查询设备
|
|
|
+// LambdaQueryWrapper<Device> deviceQuery = Wrappers.lambdaQuery();
|
|
|
+// deviceQuery.eq(Device::getDeviceCode, deviceCode);
|
|
|
+// Device device = deviceService.getOne(deviceQuery);
|
|
|
+// Optional.ofNullable(device).orElseThrow(() -> new BusinessException("设备不存在"));
|
|
|
+// //查询sd
|
|
|
+// LambdaQueryWrapper<SiteDynamicProperties> sdQuery = Wrappers.lambdaQuery();
|
|
|
+// sdQuery.eq(SiteDynamicProperties::getSiteId, device.getSiteId());
|
|
|
+// SiteDynamicProperties siteDynamicProperties = siteDynamicPropertiesService.getOne(sdQuery);
|
|
|
+// Optional.ofNullable(siteDynamicProperties).orElseThrow(() -> new BusinessException("sd不存在"));
|
|
|
+// return fillRealScoreDataOne(rtAnalogData, siteDynamicProperties);
|
|
|
+// }
|
|
|
+
|
|
|
@Override
|
|
|
public RealScoreOneVO fillRealScoreDataOne(RtAnalogData rtAnalogData, SiteDynamicProperties siteDynamicProperties) {
|
|
|
List<Double> checkList = new ArrayList<>();
|
|
@@ -1133,11 +1202,59 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
|
|
|
throw new BusinessException("时间错误");
|
|
|
}
|
|
|
}
|
|
|
+ LambdaQueryWrapper<Device> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.eq(Device::getSiteId,siteId);
|
|
|
+ List<Device> deviceList = deviceService.list(queryWrapper1);
|
|
|
+ List<String> fieldDisplayOne183 = new ArrayList();
|
|
|
+ List<String> fieldDisplayOne171 = new ArrayList();
|
|
|
+ List<String> fieldDisplayOne173 = new ArrayList();
|
|
|
+ if (deviceList.size() > 0) {
|
|
|
+ for(int j = 0; j < deviceList.size(); j++){
|
|
|
+ if (deviceList.get(j).getDeviceType().equals("1")) {
|
|
|
+ fieldDisplayOne183.add(deviceList.get(j).getDeviceCode());
|
|
|
+ } else if (deviceList.get(j).getDeviceType().equals("3")) {
|
|
|
+ fieldDisplayOne171.add(deviceList.get(j).getDeviceCode());
|
|
|
+ } else if (deviceList.get(j).getDeviceType().equals("4")) {
|
|
|
+ fieldDisplayOne173.add(deviceList.get(j).getDeviceCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<EvaluationReporVo> evaluationReporVo1 = new ArrayList<>();
|
|
|
+ List<EvaluationReporVo> evaluationReporVo2 = new ArrayList<>();
|
|
|
+ if (fieldDisplayOne183.size()>0){
|
|
|
+ evaluationReporVo1 = baseMapper.getEvaluationReportList(siteId, startTime, endtime,"ht_analog_data",fieldDisplayOne183);
|
|
|
+ }
|
|
|
+ if (fieldDisplayOne173.size()>0){
|
|
|
+ evaluationReporVo2 = baseMapper.getEvaluationReportList(siteId, startTime, endtime,"ht_analog_173_data",fieldDisplayOne173);
|
|
|
+ }
|
|
|
|
|
|
- List<EvaluationReporVo> evaluationReporVo = baseMapper.evaluationReportList(siteId, startTime, endtime);
|
|
|
+ List<EvaluationReporVo> evaluationReporVo = Stream.of(evaluationReporVo1, evaluationReporVo2).flatMap(Collection::stream).distinct().collect(Collectors.toList());
|
|
|
return fillRealScoreDataTwo(evaluationReporVo);
|
|
|
}
|
|
|
|
|
|
+// public List<RealScoreVO> evaluationReport(int siteId, Date time, int type) {
|
|
|
+// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+// SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM");
|
|
|
+// String startTime = null;
|
|
|
+// String endtime = null;
|
|
|
+// if (type == 1) {
|
|
|
+// startTime = sdf.format(time) + " 00:00:00";
|
|
|
+// endtime = sdf.format(time) + " 23:59:59";
|
|
|
+// } else {
|
|
|
+// startTime = sdf1.format(time) + "-01 00:00:00";
|
|
|
+// String time1 = sdf1.format(time) + "-01";
|
|
|
+// try {
|
|
|
+// Date yq = getLastDayOfMonth(sdf.parse(time1));
|
|
|
+// endtime = sdf.format(yq) + " 23:59:59";
|
|
|
+// } catch (Exception e) {
|
|
|
+// throw new BusinessException("时间错误");
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<EvaluationReporVo> evaluationReporVo = baseMapper.evaluationReportList(siteId, startTime, endtime);
|
|
|
+// return fillRealScoreDataTwo(evaluationReporVo);
|
|
|
+// }
|
|
|
+
|
|
|
/**
|
|
|
* 计算电压分数2
|
|
|
*
|