package com.bizmatics.service.impl; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.bizmatics.common.core.exception.BusinessException; import com.bizmatics.common.core.util.Arith; import com.bizmatics.common.core.util.BeanMapperUtils; import com.bizmatics.common.core.util.DateUtils; import com.bizmatics.common.core.util.FileUtils; import com.bizmatics.common.mvc.base.AbstractCrudService; import com.bizmatics.common.spring.util.GlobalUtils; import com.bizmatics.common.spring.util.JsonUtils; import com.bizmatics.model.*; import com.bizmatics.model.vo.*; import com.bizmatics.persistence.mapper.HtAnalogDataMapper; import com.bizmatics.service.*; import com.bizmatics.service.util.FieldEscapeUtils; import com.bizmatics.service.util.SecurityUtils; import com.bizmatics.service.vo.*; import com.fasterxml.jackson.core.type.TypeReference; import org.apache.ibatis.annotations.Select; import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.math.BigDecimal; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import java.util.stream.Stream; import static com.bizmatics.service.impl.RtAnalogDataServiceImpl.getLastDayOfMonth; /** * @author yq * @date 2021/7/20 16:49 */ @Service public class HtAnalogDataServiceImpl extends AbstractCrudService implements HtAnalogDataService { @Autowired private HadSiteStaticService hadSiteStaticService; @Autowired private RtAnalogDataService rtAnalogDataService; @Autowired private DeviceService deviceService; @Autowired private SiteDynamicPropertiesService siteDynamicPropertiesService; @Autowired private DeviceAttributeService deviceAttributeService; @Autowired private HtAnalogDataMapper htAnalogDataMapper; @Override public HadCountVO selectCount() { HadCountVO hadCountVO = new HadCountVO(); Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue(); Date date = new Date(); hadCountVO.setDayCount(hadSiteStaticService.getCount(userId, DateUtils.getDayStartTime(date), date, null)); hadCountVO.setMonthCount(hadSiteStaticService.getCount(userId, DateUtils.getFirstDayOfMonth(date), date, null)); hadCountVO.setYearCount(hadSiteStaticService.getCount(userId, DateUtils.getBeginDayOfYear(date), date, null)); return hadCountVO; } @Override public List selectTrendByDate(Integer siteId) { Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue(); Date date = new Date(); Date sTime = DateUtils.getDayStartTime(date); Date eTime = DateUtils.getDayEndTime(date); Date ysTime = DateUtils.addDays(sTime, -1); Date yeTime = DateUtils.addDays(eTime, -1); List list = new ArrayList<>(); if (null != siteId) { list.add(getTreedBySite("昨日", siteId, ysTime, yeTime)); list.add(getTreedBySite("今日", siteId, sTime, eTime)); } else { list.add(getTrendOne("昨日", userId, ysTime, yeTime)); list.add(getTrendOne("今日", userId, sTime, eTime)); } return list; } public CommonIcoVO getTrendOne(String name, Integer userId, Date startTime, Date endTime) { List list = hadSiteStaticService.list(null, startTime, endTime, userId); List objects = new ArrayList<>(); objects.add(0.0); List dates = new ArrayList<>(); dates.add("00:00:00"); for (int i = 2; i < 24; i += 2) { // 结束时间 Date hours = DateUtils.setHours(startTime, i); startTime = hours; dates.add(DateUtils.getTime(hours)); Double hourCount = 0.00; for (HadSiteStatic hadSiteStatic : list) { CommonIcoVO commonIcoVO = JsonUtils.fromJson(hadSiteStatic.getLoadIco(), CommonIcoVO.class); List dataList = (List) commonIcoVO.getList(); hourCount += dataList.get(i / 2); } objects.add(Arith.div(hourCount, 1, 2)); } return CommonIcoVO.builder().name(name).list(objects).listDate(dates).build(); } CommonIcoVO getTreedBySite(String name, Integer siteId, Date startTime, Date endTime) { Date sTime = DateUtils.getDayStartTime(startTime); Date eTime = DateUtils.getDayEndTime(endTime); HadSiteStatic hadSiteStatic = hadSiteStaticService.oneBySite(siteId, sTime, eTime); CommonIcoVO commonIcoVO = null; if (null != hadSiteStatic) { commonIcoVO = JsonUtils.fromJson(hadSiteStatic.getLoadIco(), CommonIcoVO.class); commonIcoVO.setName(name); } else { List objects = new ArrayList<>(); objects.add(0.0); List dates = new ArrayList<>(); dates.add("00:00:00"); for (int i = 2; i < 24; i += 2) { // 结束时间 Date hours = DateUtils.setHours(startTime, i); objects.add(0.0); startTime = hours; dates.add(DateUtils.getTime(hours)); } commonIcoVO = CommonIcoVO.builder().name(name).list(objects).listDate(dates).build(); } return commonIcoVO; } @Override public List selectTrendByMonth() { Date date = new Date(); Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue(); List list = new ArrayList<>(); list.add(selectTreedMonthOne(DateUtils.getLastDayOfMonth(DateUtils.addMonths(date, -1)), userId, "上月趋势图")); list.add(selectTreedMonthOne(DateUtils.getLastDayOfMonth(date), userId, "当月趋势图")); return list; } public CommonIcoVO selectTreedMonthOne(Date date, Integer userId, String name) { List objects = new ArrayList<>(); List dateList = new ArrayList<>(); for (int i = 1; i <= Integer.parseInt(DateUtils.getDay(date)); i++) { Date setDays = DateUtils.setDays(date, i); Date dayStartTime = DateUtils.getDayStartTime(setDays); Date dayEndTime = DateUtils.getDayEndTime(setDays); objects.add(hadSiteStaticService.getCount(userId, dayStartTime, dayEndTime, null)); dateList.add(DateUtils.getDay(setDays)); } return CommonIcoVO.builder().name(name).list(objects).listDate(dateList).build(); } @Override public HadCountVO getCountBySite(Integer siteId) { Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue(); Date date = new Date(); // 当日开始时间 Date firstDayOfDate = DateUtils.getDayStartTime(date); // 当月开始时间 Date firstDayOfMonth = DateUtils.getFirstDayOfMonth(date); // 当年开始时间 Date firstDayOfYear = DateUtils.getBeginDayOfYear(date); HadCountVO hadCountVO = new HadCountVO(); hadCountVO.setDayCount(hadSiteStaticService.getCount(userId, DateUtils.getDayStartTime(date), date, siteId)); hadCountVO.setMonthCount(hadSiteStaticService.getCount(userId, DateUtils.getFirstDayOfMonth(date), date, siteId)); hadCountVO.setYearCount(hadSiteStaticService.getCount(userId, DateUtils.getBeginDayOfYear(date), date, siteId)); hadCountVO.setLastDayCount(hadSiteStaticService.getCount(userId, DateUtils.addDays(firstDayOfDate, -1), DateUtils.addDays(date, -1), siteId)); hadCountVO.setLastMonthCount(hadSiteStaticService.getCount(userId, DateUtils.addMonths(firstDayOfMonth, -1), DateUtils.addMonths(date, -1), siteId)); hadCountVO.setLastYearCount(hadSiteStaticService.getCount(userId, DateUtils.addYears(firstDayOfYear, -1), DateUtils.addYears(date, -1), siteId)); hadCountVO.setDayRadio(Optional.ofNullable(hadCountVO.getDayCount()) .filter(dayCount -> 0.00 != dayCount) .map(dayCount -> Arith.div(hadCountVO.getLastDayCount(), dayCount)) .orElse(0.00)); hadCountVO.setMonthRadio(Optional.ofNullable(hadCountVO.getMonthCount()) .filter(dayCount -> 0.00 != dayCount) .map(dayCount -> Arith.div(hadCountVO.getLastMonthCount(), dayCount)) .orElse(0.00)); hadCountVO.setYearRadio(Optional.ofNullable(hadCountVO.getYearCount()) .filter(dayCount -> 0.00 != dayCount) .map(dayCount -> Arith.div(hadCountVO.getLastYearCount(), dayCount)) .orElse(0.00)); return hadCountVO; } @Override public TimeShareVO getTimeShare(Integer siteId, Integer type) { AtomicReference timeShareVO = new AtomicReference<>(new TimeShareVO()); Date date = new Date(); if (0 == type) { Date yeDay = DateUtils.addDays(date, -1); Date yeStartDay = DateUtils.getDayStartTime(yeDay); HadSiteStatic hadSiteStatic = hadSiteStaticService.oneBySite(siteId, yeStartDay, yeDay); Optional.ofNullable(hadSiteStatic).ifPresent(hads -> { timeShareVO.set(JsonUtils.fromJson(hads.getTimeShare(), TimeShareVO.class)); }); } else { List list = hadSiteStaticService.list(siteId, DateUtils.getFirstDayOfMonth(date), date); for (HadSiteStatic hadSiteStatic : list) { Optional.ofNullable(hadSiteStatic.getTimeShare()) .ifPresent(has -> { TimeShareVO ts = JsonUtils.fromJson(has, TimeShareVO.class); timeShareVO.get().setFlat(Arith.add(timeShareVO.get().getFlat(), ts.getFlat())); timeShareVO.get().setPeak(Arith.add(timeShareVO.get().getPeak(), ts.getPeak())); timeShareVO.get().setNeed(Arith.add(timeShareVO.get().getNeed(), ts.getNeed())); timeShareVO.get().setGrain(Arith.add(timeShareVO.get().getGrain(), ts.getGrain())); }); } } return timeShareVO.get(); } @Override public List getDemandIco(Integer siteId) { Date date = new Date(); List maxList = new ArrayList<>(); List minList = new ArrayList<>(); List avgList = new ArrayList<>(); List dateList = new ArrayList<>(); List hadSiteStatics = hadSiteStaticService.list(siteId, DateUtils.getFirstDayOfMonth(date), date); for (int i = 1; i <= Integer.parseInt(DateUtils.getDay(date)); i++) { Date setDays = DateUtils.setDays(date, i); Date dayStartTime = DateUtils.getDayStartTime(setDays); Date dayEndTime = DateUtils.getDayEndTime(setDays); maxList.add(hadSiteStatics.stream() .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(), dayStartTime, dayEndTime) ).findFirst().map(HadSiteStatic::getMaxDemand).orElse(0.00)); minList.add(hadSiteStatics.stream() .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(), dayStartTime, dayEndTime) ).findFirst().map(HadSiteStatic::getMinDemand).orElse(0.00)); avgList.add(hadSiteStatics.stream() .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(), dayStartTime, dayEndTime) ).findFirst().map(HadSiteStatic::getAvgDemand).orElse(0.00)); dateList.add(DateUtils.getDay(setDays)); } List list = new ArrayList<>(); list.add(CommonIcoVO.builder().name("最大值").list(maxList).listDate(dateList).build()); list.add(CommonIcoVO.builder().name("最小值").list(minList).listDate(dateList).build()); list.add(CommonIcoVO.builder().name("平均值").list(avgList).listDate(dateList).build()); return list; } @Override public List getElectricIco(Integer siteId, Date date) { List iaList = new ArrayList<>(); iaList.add(0.00); List ibList = new ArrayList<>(); ibList.add(0.00); List icList = new ArrayList<>(); icList.add(0.00); List uaList = new ArrayList<>(); uaList.add(0.00); List ubList = new ArrayList<>(); ubList.add(0.00); List ucList = new ArrayList<>(); ucList.add(0.00); List dateList = new ArrayList<>(); dateList.add("00:00:00"); HadSiteStatic hadSiteStatic = hadSiteStaticService.oneBySite(siteId, date, date); List htList = Optional.ofNullable(hadSiteStatic) .map(HadSiteStatic::getHisIco) .map(his -> JsonUtils.fromJson(hadSiteStatic.getHisIco(), new TypeReference>() { })) .orElse(null); for (int i = 2; i < 24; i += 2) { Date hours = DateUtils.setHours(date, i); date = hours; Date finalDate = date; Optional htAnalogData = Optional.ofNullable(htList).flatMap(hts -> hts.stream() .filter(hads -> DateUtils.isEffectiveDate(hads.getDataTime(), finalDate, hours)) .findFirst()); iaList.add(htAnalogData.map(HtAnalogData::getIa).orElse(0.00)); ibList.add(htAnalogData.map(HtAnalogData::getIb).orElse(0.00)); icList.add(htAnalogData.map(HtAnalogData::getIc).orElse(0.00)); uaList.add(htAnalogData.map(HtAnalogData::getUa).orElse(0.00)); ubList.add(htAnalogData.map(HtAnalogData::getUb).orElse(0.00)); ucList.add(htAnalogData.map(HtAnalogData::getUc).orElse(0.00)); dateList.add(htAnalogData.map(HtAnalogData::getDataTime).map(s -> DateUtils.getTime(hours)).orElse(DateUtils.getTime(hours))); } List list = new ArrayList<>(); list.add(CommonIcoVO.builder().name("IA").list(iaList).listDate(dateList).build()); list.add(CommonIcoVO.builder().name("IB").list(ibList).listDate(dateList).build()); list.add(CommonIcoVO.builder().name("IC").list(icList).listDate(dateList).build()); list.add(CommonIcoVO.builder().name("UA").list(uaList).listDate(dateList).build()); list.add(CommonIcoVO.builder().name("UB").list(ubList).listDate(dateList).build()); list.add(CommonIcoVO.builder().name("UC").list(ucList).listDate(dateList).build()); return list; } @Override public List rtRealScore(String deviceCode, Date startTime, Date endTime) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 查询设备 LambdaQueryWrapper deviceQuery = Wrappers.lambdaQuery(); deviceQuery.eq(Device::getDeviceCode, deviceCode); Device device = deviceService.getOne(deviceQuery); Optional.ofNullable(device).orElseThrow(() -> new BusinessException("设备不存在")); String table = "ht_analog_data"; if (device.getDeviceType().equals("1")) { table = "ht_analog_data"; } else if (device.getDeviceType().equals("4")) { table = "ht_analog_173_data"; } List list = baseMapper.getDemandAnalysisList(deviceCode, formatter.format(startTime), formatter.format(endTime), table); // 查询sd LambdaQueryWrapper sdQuery = Wrappers.lambdaQuery(); sdQuery.eq(SiteDynamicProperties::getSiteId, device.getSiteId()); SiteDynamicProperties siteDynamicProperties = siteDynamicPropertiesService.getOne(sdQuery); Optional.ofNullable(siteDynamicProperties).orElseThrow(() -> new BusinessException("sd不存在")); LambdaQueryWrapper adQuery = Wrappers.lambdaQuery(); adQuery.eq(DeviceAttribute::getSiteId, device.getSiteId()); List deviceAttributes = deviceAttributeService.list(adQuery); if (CollectionUtils.isEmpty(deviceAttributes)) { throw new BusinessException("da不存在"); } DeviceAttribute deviceAttribute = deviceAttributes.stream().min(Comparator.comparing(DeviceAttribute::getId)).get(); List realScoreVOS = new ArrayList<>(); for (HtAnalogData htAnalogData : list) { RtAnalogData rtAnalogData = BeanMapperUtils.map(htAnalogData, RtAnalogData.class); realScoreVOS.add(rtAnalogDataService.fillRealScoreData(rtAnalogData, siteDynamicProperties, deviceAttribute)); } return realScoreVOS; } // public List rtRealScore(String deviceCode, Date startTime, Date endTime) { // LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); // queryWrapper.select(HtAnalogData::getIa, HtAnalogData::getIb, HtAnalogData::getIc, // HtAnalogData::getUa, HtAnalogData::getUb, HtAnalogData::getUc, HtAnalogData::getDataTime, // HtAnalogData::getCos) // .eq(HtAnalogData::getDeviceName, deviceCode) // .between(HtAnalogData::getDataTime, startTime, endTime); // List list = this.list(queryWrapper); // //查询设备 // LambdaQueryWrapper deviceQuery = Wrappers.lambdaQuery(); // deviceQuery.eq(Device::getDeviceCode, deviceCode); // Device device = deviceService.getOne(deviceQuery); // Optional.ofNullable(device).orElseThrow(() -> new BusinessException("设备不存在")); // //查询sd // LambdaQueryWrapper sdQuery = Wrappers.lambdaQuery(); // sdQuery.eq(SiteDynamicProperties::getSiteId, device.getSiteId()); // SiteDynamicProperties siteDynamicProperties = siteDynamicPropertiesService.getOne(sdQuery); // Optional.ofNullable(siteDynamicProperties).orElseThrow(() -> new BusinessException("sd不存在")); // LambdaQueryWrapper adQuery = Wrappers.lambdaQuery(); // adQuery.eq(DeviceAttribute::getSiteId, device.getSiteId()); // List deviceAttributes = deviceAttributeService.list(adQuery); // if (CollectionUtils.isEmpty(deviceAttributes)) { // throw new BusinessException("da不存在"); // } // DeviceAttribute deviceAttribute = deviceAttributes.stream().min(Comparator.comparing(DeviceAttribute::getId)).get(); // List realScoreVOS = new ArrayList<>(); // for (HtAnalogData htAnalogData : list) { // RtAnalogData rtAnalogData = BeanMapperUtils.map(htAnalogData, RtAnalogData.class); // realScoreVOS.add(rtAnalogDataService.fillRealScoreData(rtAnalogData, siteDynamicProperties, deviceAttribute)); // } // return realScoreVOS; // } @Override public List yearOnYearList(DataManagementOneVO dataManagementOneVO) { List dataManagementVOList = new ArrayList<>(); List newListOne = new ArrayList<>(); List newListTwo = new ArrayList<>(); List newListThree = new ArrayList<>(); List variableCodingList = new LinkedList<>(); List fieldDisplay = new ArrayList<>(); Integer type = dataManagementOneVO.getType(); Integer valueCalculation = dataManagementOneVO.getValueCalculation(); newListOne.add("dataTime"); for (int i = 0; i < dataManagementOneVO.getDisplayField().size(); i++) { DataManagementVO dataManagementVO = new DataManagementVO(); dataManagementVO.setDisplayField(dataManagementOneVO.getDisplayField().get(i).split("_")[0]); dataManagementVOList.add(dataManagementVO); newListOne.add(dataManagementOneVO.getDisplayField().get(i).split("_")[1]); newListTwo.add(dataManagementOneVO.getDisplayField().get(i).split("_")[2]); fieldDisplay.add(dataManagementOneVO.getDisplayField().get(i).split("_")[1]); newListThree.add(dataManagementOneVO.getDisplayField().get(i).split("_")[1] + "_" + dataManagementOneVO.getDisplayField().get(i).split("_")[2]); DeviceAnalogVariableList deviceAnalogVariableList = new DeviceAnalogVariableList(); deviceAnalogVariableList.setVariableCoding(dataManagementOneVO.getDisplayField().get(i).split("_")[0] + "_" + dataManagementOneVO.getDisplayField().get(i).split("_")[1]); variableCodingList.add(deviceAnalogVariableList); } // 通信设备编号 Set set = new HashSet(); List newList = new ArrayList(); set.addAll(dataManagementVOList); newList.addAll(set); // 显示的字段名 Set set1 = new HashSet(); List list = new ArrayList(); set1.addAll(newListOne); list.addAll(set1); // 监控ID Set set2 = new HashSet(); List monitor_list = new ArrayList(); set2.addAll(newListTwo); monitor_list.addAll(set2); // 查询字段 Set set3 = new HashSet(); List fieldDisplayOne = new ArrayList(); set3.addAll(fieldDisplay); fieldDisplayOne.addAll(set3); List fieldDisplayOne183 = new ArrayList(); List fieldDisplayOne171 = new ArrayList(); List fieldDisplayOne173 = new ArrayList(); List deviceList = baseMapper.getDeviceList(newList); for (int i = 0; i < dataManagementOneVO.getDisplayField().size(); i++) { String device_code = dataManagementOneVO.getDisplayField().get(i).split("_")[0]; String display_field = dataManagementOneVO.getDisplayField().get(i).split("_")[1]; for (int j = 0; j < deviceList.size(); j++) { if (device_code.equals(deviceList.get(j).getDeviceCode())) { if (deviceList.get(j).getDeviceType().equals("1")) { fieldDisplayOne183.add(display_field); } else if (deviceList.get(j).getDeviceType().equals("3")) { fieldDisplayOne171.add(display_field); } else if (deviceList.get(j).getDeviceType().equals("4")) { fieldDisplayOne173.add(display_field); } } } } List yearOnYearList1 = new ArrayList<>(); List yearOnYearList2 = new ArrayList<>(); List yearOnYearList3 = new ArrayList<>(); if (fieldDisplayOne183.size() > 0) { List fieldDisplayList = FieldEscapeUtils.getSyllable(type, valueCalculation, fieldDisplayOne183); yearOnYearList1 = baseMapper.getYearOnYearThree(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList, fieldDisplayList, "ht_analog_data", 0, type); } if (fieldDisplayOne171.size() > 0) { List fieldDisplayList = FieldEscapeUtils.getSyllable(type, valueCalculation, fieldDisplayOne171); yearOnYearList2 = baseMapper.getYearOnYearThree(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList, fieldDisplayList, "ht_analog_171_data", 0, type); } if (fieldDisplayOne173.size() > 0) { List fieldDisplayList = FieldEscapeUtils.getSyllable(type, valueCalculation, fieldDisplayOne173); yearOnYearList3 = baseMapper.getYearOnYearThree(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList, fieldDisplayList, "ht_analog_173_data", 0, type); } List yearOnYearList4 = Stream.of(yearOnYearList1, yearOnYearList2).flatMap(Collection::stream).distinct().collect(Collectors.toList()); List yearOnYearList = Stream.of(yearOnYearList3, yearOnYearList4).flatMap(Collection::stream).distinct().collect(Collectors.toList()); FieldEscapeUtils.remove1(list); List reListOne = new ArrayList<>(); if (yearOnYearList != null && !yearOnYearList.isEmpty()) { for (int i = 0; i < monitor_list.size(); i++) { for (int j = 0; j < list.size(); j++) { List data = new ArrayList<>(); String name = null; List time = new ArrayList<>(); for (int k = 0; k < yearOnYearList.size(); k++) { String variable_one = list.get(j) + "_" + monitor_list.get(i); String variable_two = list.get(j) + "_" + yearOnYearList.get(k).getDeviceAttributeId(); System.out.println("variable_one:" + variable_one + "---variable_two:" + variable_two); if (variable_one.equals(variable_two)) { String variable_three = list.get(j) + "_" + yearOnYearList.get(k).getDeviceAttributeId(); System.out.println("variable_one_a:" + newListThree + "---variable_two_b:" + variable_three + "---value:" + newListThree.contains(variable_three)); if (newListThree.contains(variable_three)) { name = yearOnYearList.get(k).getMonitorDeviceName() + "/" + FieldEscapeUtils.fieldEscapeUtils(list.get(j)); time.add(yearOnYearList.get(k).getDataTime()); // System.out.println(); data.add(FieldEscapeUtils.transformation1(yearOnYearList.get(k), list.get(j))); } } } if (data != null && !data.isEmpty()) { reListOne.add(CommonIcoVO.builder().name(name).list(data).listDate(time).build()); } } } } return reListOne; } // public List yearOnYearList(DataManagementOneVO dataManagementOneVO) { // List yearOnYearList = null; // List dataManagementVOList = new ArrayList<>(); // List newListOne = new ArrayList<>(); // List newListTwo = new ArrayList<>(); // List newListThree = new ArrayList<>(); // List variableCodingList = new LinkedList<>(); // List fieldDisplay = new ArrayList<>(); // newListOne.add("dataTime"); // for (int i = 0; i < dataManagementOneVO.getDisplayField().size(); i++) { // DataManagementVO dataManagementVO = new DataManagementVO(); // dataManagementVO.setDisplayField(dataManagementOneVO.getDisplayField().get(i).split("_")[0]); // dataManagementVOList.add(dataManagementVO); // newListOne.add(dataManagementOneVO.getDisplayField().get(i).split("_")[1]); // newListTwo.add(dataManagementOneVO.getDisplayField().get(i).split("_")[2]); // fieldDisplay.add(dataManagementOneVO.getDisplayField().get(i).split("_")[1]); // newListThree.add(dataManagementOneVO.getDisplayField().get(i).split("_")[1] + "_" + dataManagementOneVO.getDisplayField().get(i).split("_")[2]); // DeviceAnalogVariableList deviceAnalogVariableList = new DeviceAnalogVariableList(); // deviceAnalogVariableList.setVariableCoding(dataManagementOneVO.getDisplayField().get(i).split("_")[0] + "_" + dataManagementOneVO.getDisplayField().get(i).split("_")[1]); // variableCodingList.add(deviceAnalogVariableList); // } // Set set = new HashSet(); // List newList = new ArrayList(); // set.addAll(dataManagementVOList); // newList.addAll(set); // // //通信设备编号 // Set set1 = new HashSet(); // List list = new ArrayList(); // set1.addAll(newListOne); // list.addAll(set1); // // //显示的字段名 // Set set2 = new HashSet(); // List monitor_list = new ArrayList(); // set2.addAll(newListTwo); // monitor_list.addAll(set2); // // //查询字段 // Set set3 = new HashSet(); // List fieldDisplayOne = new ArrayList(); // set3.addAll(fieldDisplay); // fieldDisplayOne.addAll(set3); // // if (dataManagementOneVO.getType() == 1) { // if (dataManagementOneVO.getValueCalculation() == 1) { // yearOnYearList = baseMapper.yearOnYearOne(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } else if (dataManagementOneVO.getValueCalculation() == 2) { // yearOnYearList = baseMapper.dayMaxDataList(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } else if (dataManagementOneVO.getValueCalculation() == 3) { // yearOnYearList = baseMapper.dayMinDataList(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } else if (dataManagementOneVO.getValueCalculation() == 4) { // yearOnYearList = baseMapper.daySumDataList(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } // } else if (dataManagementOneVO.getType() == 2) { // if (dataManagementOneVO.getValueCalculation() == 1) { // yearOnYearList = baseMapper.yearOnYearTwo(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } else if (dataManagementOneVO.getValueCalculation() == 2) { // yearOnYearList = baseMapper.monthMaxDataList(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } else if (dataManagementOneVO.getValueCalculation() == 3) { // yearOnYearList = baseMapper.monthMinDataList(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } else if (dataManagementOneVO.getValueCalculation() == 4) { // yearOnYearList = baseMapper.monthSumDataList(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } // } else { // yearOnYearList = baseMapper.yearOnYearThree(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList, fieldDisplayOne); // } // FieldEscapeUtils.remove1(list); // List reListOne = new ArrayList<>(); // if (yearOnYearList != null && !yearOnYearList.isEmpty()) { // for (int i = 0; i < monitor_list.size(); i++) { // for (int j = 0; j < list.size(); j++) { // List data = new ArrayList<>(); // String name = null; // List time = new ArrayList<>(); // for (int k = 0; k < yearOnYearList.size(); k++) { // String variable_one = list.get(j) + "_" + monitor_list.get(i); // String variable_two = list.get(j) + "_" + yearOnYearList.get(k).getDeviceAttributeId(); // System.out.println("variable_one:" + variable_one + "---variable_two:" + variable_two); // if (variable_one.equals(variable_two)) { // String variable_three = list.get(j) + "_" + yearOnYearList.get(k).getDeviceAttributeId(); // System.out.println("variable_one_a:" + newListThree + "---variable_two_b:" + variable_three + "---value:" + newListThree.contains(variable_three)); // if (newListThree.contains(variable_three)) { // name = yearOnYearList.get(k).getMonitorDeviceName() + "/" + FieldEscapeUtils.fieldEscapeUtils(list.get(j)); // time.add(yearOnYearList.get(k).getDataTime()); //// System.out.println(); // data.add(FieldEscapeUtils.transformation(yearOnYearList.get(k), list.get(j))); // } // } // } // if (data != null && !data.isEmpty()) { // reListOne.add(CommonIcoVO.builder().name(name).list(data).listDate(time).build()); // } // // } // } // } // return reListOne; // } @Override public List ringRatioList(DataManagementOneVO dataManagementOneVO) { List dataManagementVOList = new ArrayList<>(); List newListOne = new ArrayList<>(); List newListTwo = new ArrayList<>(); List newListThree = new ArrayList<>(); List fieldDisplay = new ArrayList<>(); Integer type = dataManagementOneVO.getType(); Integer valueCalculation = dataManagementOneVO.getValueCalculation(); newListOne.add("dataTime"); List variableCodingList = new LinkedList<>(); for (int i = 0; i < dataManagementOneVO.getDisplayField().size(); i++) { DataManagementVO dataManagementVO = new DataManagementVO(); dataManagementVO.setDisplayField(dataManagementOneVO.getDisplayField().get(i).split("_")[0]); dataManagementVOList.add(dataManagementVO); newListOne.add(dataManagementOneVO.getDisplayField().get(i).split("_")[1]); fieldDisplay.add(dataManagementOneVO.getDisplayField().get(i).split("_")[1]); newListTwo.add(dataManagementOneVO.getDisplayField().get(i).split("_")[2]); newListThree.add(dataManagementOneVO.getDisplayField().get(i).split("_")[1] + "_" + dataManagementOneVO.getDisplayField().get(i).split("_")[2]); DeviceAnalogVariableList deviceAnalogVariableList = new DeviceAnalogVariableList(); deviceAnalogVariableList.setVariableCoding(dataManagementOneVO.getDisplayField().get(i).split("_")[0] + "_" + dataManagementOneVO.getDisplayField().get(i).split("_")[1]); variableCodingList.add(deviceAnalogVariableList); } Set set = new HashSet(); List newList = new ArrayList(); set.addAll(dataManagementVOList); newList.addAll(set); Set set1 = new HashSet(); List list = new ArrayList(); set1.addAll(newListOne); list.addAll(set1); Set set2 = new HashSet(); List monitor_list = new ArrayList(); set2.addAll(newListTwo); monitor_list.addAll(set2); Set set3 = new HashSet(); List fieldDisplayOne = new ArrayList(); set3.addAll(fieldDisplay); fieldDisplayOne.addAll(set3); List fieldDisplayOne183 = new ArrayList(); List fieldDisplayOne171 = new ArrayList(); List fieldDisplayOne173 = new ArrayList(); List deviceList = baseMapper.getDeviceList(newList); for (int i = 0; i < dataManagementOneVO.getDisplayField().size(); i++) { String device_code = dataManagementOneVO.getDisplayField().get(i).split("_")[0]; String display_field = dataManagementOneVO.getDisplayField().get(i).split("_")[1]; for (int j = 0; j < deviceList.size(); j++) { if (device_code.equals(deviceList.get(j).getDeviceCode())) { if (deviceList.get(j).getDeviceType().equals("1")) { fieldDisplayOne183.add(display_field); } else if (deviceList.get(j).getDeviceType().equals("3")) { fieldDisplayOne171.add(display_field); } else if (deviceList.get(j).getDeviceType().equals("4")) { fieldDisplayOne173.add(display_field); } } } } List yearOnYearList1 = new ArrayList<>(); List yearOnYearList2 = new ArrayList<>(); List yearOnYearList3 = new ArrayList<>(); if (fieldDisplayOne183.size() > 0) { List fieldDisplayList = FieldEscapeUtils.getSyllable(type, valueCalculation, fieldDisplayOne183); yearOnYearList1 = baseMapper.getYearOnYearThree(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList, fieldDisplayList, "ht_analog_data", 0, type); } if (fieldDisplayOne171.size() > 0) { List fieldDisplayList = FieldEscapeUtils.getSyllable(type, valueCalculation, fieldDisplayOne171); yearOnYearList2 = baseMapper.getYearOnYearThree(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList, fieldDisplayList, "ht_analog_171_data", 0, type); } if (fieldDisplayOne173.size() > 0) { List fieldDisplayList = FieldEscapeUtils.getSyllable(type, valueCalculation, fieldDisplayOne173); yearOnYearList3 = baseMapper.getYearOnYearThree(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList, fieldDisplayList, "ht_analog_173_data", 0, type); } List yearOnYearList4 = Stream.of(yearOnYearList1, yearOnYearList2).flatMap(Collection::stream).distinct().collect(Collectors.toList()); List currentPeriodRingRatioList = Stream.of(yearOnYearList3, yearOnYearList4).flatMap(Collection::stream).distinct().collect(Collectors.toList()); FieldEscapeUtils.remove1(list); List reListOne = new ArrayList<>(); if (currentPeriodRingRatioList != null && !currentPeriodRingRatioList.isEmpty()) { for (int i = 0; i < monitor_list.size(); i++) { for (int j = 0; j < list.size(); j++) { List data = new ArrayList<>(); String name = null; List time = new ArrayList<>(); for (int k = 0; k < currentPeriodRingRatioList.size(); k++) { String variable_one = list.get(j) + "_" + monitor_list.get(i); String variable_two = list.get(j) + "_" + currentPeriodRingRatioList.get(k).getDeviceAttributeId(); System.out.println("variable_one:" + variable_one + "---variable_two:" + variable_two); if (variable_one.equals(variable_two)) { String variable_three = list.get(j) + "_" + currentPeriodRingRatioList.get(k).getDeviceAttributeId(); System.out.println("variable_one_a:" + newListThree + "---variable_two_b:" + variable_three + "---value:" + newListThree.contains(variable_three)); if (newListThree.contains(variable_three)) { name = currentPeriodRingRatioList.get(k).getMonitorDeviceName() + "/" + FieldEscapeUtils.fieldEscapeUtils(list.get(j)); time.add(currentPeriodRingRatioList.get(k).getDataTime()); // System.out.println(); data.add(FieldEscapeUtils.transformation1(currentPeriodRingRatioList.get(k), list.get(j))); } } } if (data != null && !data.isEmpty()) { reListOne.add(CommonIcoVO.builder().name(name).list(data).listDate(time).build()); } } } } return reListOne; } // public List ringRatioList(DataManagementOneVO dataManagementOneVO) { // List currentPeriodRingRatioList = null; //// List lastPeriodRingRatioList = null; // List dataManagementVOList = new ArrayList<>(); // List newListOne = new ArrayList<>(); // List newListTwo = new ArrayList<>(); // List newListThree = new ArrayList<>(); // List fieldDisplay = new ArrayList<>(); // newListOne.add("dataTime"); // List variableCodingList = new LinkedList<>(); // for (int i = 0; i < dataManagementOneVO.getDisplayField().size(); i++) { // DataManagementVO dataManagementVO = new DataManagementVO(); // dataManagementVO.setDisplayField(dataManagementOneVO.getDisplayField().get(i).split("_")[0]); // dataManagementVOList.add(dataManagementVO); // newListOne.add(dataManagementOneVO.getDisplayField().get(i).split("_")[1]); // fieldDisplay.add(dataManagementOneVO.getDisplayField().get(i).split("_")[1]); // newListTwo.add(dataManagementOneVO.getDisplayField().get(i).split("_")[2]); // newListThree.add(dataManagementOneVO.getDisplayField().get(i).split("_")[1] + "_" + dataManagementOneVO.getDisplayField().get(i).split("_")[2]); // DeviceAnalogVariableList deviceAnalogVariableList = new DeviceAnalogVariableList(); // deviceAnalogVariableList.setVariableCoding(dataManagementOneVO.getDisplayField().get(i).split("_")[0] + "_" + dataManagementOneVO.getDisplayField().get(i).split("_")[1]); // variableCodingList.add(deviceAnalogVariableList); // } // Set set = new HashSet(); // List newList = new ArrayList(); // set.addAll(dataManagementVOList); // newList.addAll(set); // // Set set1 = new HashSet(); // List list = new ArrayList(); // set1.addAll(newListOne); // list.addAll(set1); // // Set set2 = new HashSet(); // List monitor_list = new ArrayList(); // set2.addAll(newListTwo); // monitor_list.addAll(set2); // // Set set3 = new HashSet(); // List fieldDisplayOne = new ArrayList(); // set3.addAll(fieldDisplay); // fieldDisplayOne.addAll(set3); // // //旧数据时间计算 //// SimpleDateFormat sfOne = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //// long startLong = DateUtils.toDate(DateUtils.toLocalDateTime(dataManagementOneVO.getStartTime(), "yyyy-MM-dd HH:mm:ss")).getTime(); //// long endLong = DateUtils.toDate(DateUtils.toLocalDateTime(dataManagementOneVO.getEndTime(), "yyyy-MM-dd HH:mm:ss")).getTime(); //// long interval = (endLong - startLong) / 13; //// String lastPeriodStartTime = sfOne.format(new Date(startLong - (interval * 14))); // if (dataManagementOneVO.getType() == 1) { // if (dataManagementOneVO.getValueCalculation() == 1) { // currentPeriodRingRatioList = baseMapper.yearOnYearOne(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } else if (dataManagementOneVO.getValueCalculation() == 2) { // currentPeriodRingRatioList = baseMapper.dayMaxDataList(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } else if (dataManagementOneVO.getValueCalculation() == 3) { // currentPeriodRingRatioList = baseMapper.dayMinDataList(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } else if (dataManagementOneVO.getValueCalculation() == 4) { // currentPeriodRingRatioList = baseMapper.daySumDataList(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } // } else if (dataManagementOneVO.getType() == 2) { // if (dataManagementOneVO.getValueCalculation() == 1) { // currentPeriodRingRatioList = baseMapper.yearOnYearTwo(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } else if (dataManagementOneVO.getValueCalculation() == 2) { // currentPeriodRingRatioList = baseMapper.monthMaxDataList(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } else if (dataManagementOneVO.getValueCalculation() == 3) { // currentPeriodRingRatioList = baseMapper.monthMinDataList(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } else if (dataManagementOneVO.getValueCalculation() == 4) { // currentPeriodRingRatioList = baseMapper.monthSumDataList(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList); // } // } else { //// String[] a={"Epn3","Epp"}; // currentPeriodRingRatioList = baseMapper.yearOnYearThree(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList, fieldDisplayOne); // } // // FieldEscapeUtils.remove1(list); // List reListOne = new ArrayList<>(); // if (currentPeriodRingRatioList != null && !currentPeriodRingRatioList.isEmpty()) { // for (int i = 0; i < monitor_list.size(); i++) { // for (int j = 0; j < list.size(); j++) { // List data = new ArrayList<>(); // String name = null; // List time = new ArrayList<>(); // for (int k = 0; k < currentPeriodRingRatioList.size(); k++) { // String variable_one = list.get(j) + "_" + monitor_list.get(i); // String variable_two = list.get(j) + "_" + currentPeriodRingRatioList.get(k).getDeviceAttributeId(); // System.out.println("variable_one:" + variable_one + "---variable_two:" + variable_two); // if (variable_one.equals(variable_two)) { // String variable_three = list.get(j) + "_" + currentPeriodRingRatioList.get(k).getDeviceAttributeId(); // System.out.println("variable_one_a:" + newListThree + "---variable_two_b:" + variable_three + "---value:" + newListThree.contains(variable_three)); // if (newListThree.contains(variable_three)) { // name = currentPeriodRingRatioList.get(k).getMonitorDeviceName() + "/" + FieldEscapeUtils.fieldEscapeUtils(list.get(j)); // time.add(currentPeriodRingRatioList.get(k).getDataTime()); //// System.out.println(); // data.add(FieldEscapeUtils.transformation(currentPeriodRingRatioList.get(k), list.get(j))); // } // } // } // if (data != null && !data.isEmpty()) { // reListOne.add(CommonIcoVO.builder().name(name).list(data).listDate(time).build()); // } // // } // } // } // return reListOne; // } @Override public List monthlyReport(String deviceCode, int cycle, String startTime, String endTime) { List eppList = new ArrayList<>(); List freezingTimesList = new ArrayList<>(); LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); queryWrapper.eq(Device::getDeviceCode, deviceCode); List deviceList = deviceService.list(queryWrapper); String table = "ht_analog_data"; if (deviceList.size() > 0) { if (deviceList.get(0).getDeviceType().equals("1")) { table = "ht_analog_data"; } else if (deviceList.get(0).getDeviceType().equals("4")) { table = "ht_analog_173_data"; } else { throw new BusinessException("173用电设备无用电数据采集"); } } else { throw new BusinessException("错误数据,设备不存在"); } List maxMonthlyReport = baseMapper.getEnergyUseList(deviceCode, startTime, endTime, cycle, 1, table); List minMonthlyReport = baseMapper.getEnergyUseList(deviceCode, startTime, endTime, cycle, 2, table); if (maxMonthlyReport.size() > 0) { for (int i = 0; i < maxMonthlyReport.size(); i++) { BigDecimal b1 = new BigDecimal(maxMonthlyReport.get(i).getEpp().toString()); BigDecimal b2 = new BigDecimal(minMonthlyReport.get(i).getEpp().toString()); eppList.add(b1.subtract(b2).doubleValue()); freezingTimesList.add(maxMonthlyReport.get(i).getFreezingTimes()); } } List list = new ArrayList<>(); list.add(CommonIcoVO.builder().name("电量").list(eppList).listDate(freezingTimesList).build()); return list; } // public List monthlyReport(String deviceCode, int cycle, String startTime, String endTime) { // List eppList = new ArrayList<>(); // List freezingTimesList = new ArrayList<>(); // List maxMonthlyReport = baseMapper.energyUseList(deviceCode, startTime, endTime, cycle, 1); // List minMonthlyReport = baseMapper.energyUseList(deviceCode, startTime, endTime, cycle, 2); // if (maxMonthlyReport.size() > 0) { // for (int i = 0; i < maxMonthlyReport.size(); i++) { // BigDecimal b1 = new BigDecimal(maxMonthlyReport.get(i).getEpp().toString()); // BigDecimal b2 = new BigDecimal(minMonthlyReport.get(i).getEpp().toString()); // eppList.add(b1.subtract(b2).doubleValue()); // freezingTimesList.add(maxMonthlyReport.get(i).getFreezingTimes()); // } // } // List list = new ArrayList<>(); // list.add(CommonIcoVO.builder().name("电量").list(eppList).listDate(freezingTimesList).build()); // return list; // } @Override public List demandAnalysis(String deviceCode, String monthDate, int cycle) { SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd"); String date = FieldEscapeUtils.getLastDayOfMonth(monthDate); String date1 = monthDate + "-01 00:00:00"; String date2 = date + " 23:59:59"; LambdaQueryWrapper queryWrapper1 = Wrappers.lambdaQuery(); queryWrapper1.eq(Device::getDeviceCode, deviceCode); List deviceList = deviceService.list(queryWrapper1); String table = "ht_analog_data"; if (deviceList.size() > 0) { if (deviceList.get(0).getDeviceType().equals("1")) { table = "ht_analog_data"; } else if (deviceList.get(0).getDeviceType().equals("4")) { table = "ht_analog_173_data"; } } List list1 = baseMapper.getDemandAnalysisList1(deviceCode, date1, date2, table); List demandList = new ArrayList<>(); List freezingTimesList = new ArrayList<>(); for (int i = 0; i < list1.size(); i++) { demandList.add(list1.get(i).getDemand()); freezingTimesList.add(formatter1.format(list1.get(i).getFreezingTime())); } List list = new ArrayList<>(); list.add(CommonIcoVO.builder().name("实时有功需量").list(demandList).listDate(freezingTimesList).build()); return list; } // public List demandAnalysis(String deviceCode, String monthDate, int cycle) { // SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd"); // String date = FieldEscapeUtils.getLastDayOfMonth(monthDate); // String date1 = monthDate + "-01 00:00:00"; // String date2 = date + " 23:59:59"; // Date startTime; // Date endTime; // try { // startTime = formatter.parse(date1); // endTime = formatter.parse(date2); // } catch (Exception e) { // throw new BusinessException("时间错误"); // } // // LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); // queryWrapper.select(HtAnalogData::getDemand, HtAnalogData::getFreezingTime) // .eq(HtAnalogData::getDeviceName, deviceCode) // .between(HtAnalogData::getFreezingTime, startTime, endTime) // .groupBy(HtAnalogData::getFreezingTime); // List list1 = this.list(queryWrapper); // List demandList = new ArrayList<>(); // List freezingTimesList = new ArrayList<>(); // for (int i = 0; i < list1.size(); i++) { // demandList.add(list1.get(i).getDemand()); // freezingTimesList.add(formatter1.format(list1.get(i).getFreezingTime())); // } // // //// List demandList = new ArrayList<>(); //// List freezingTimesList = new ArrayList<>(); //// List maxdemandAnalysis = baseMapper.demandAnalysisList(deviceCode, monthDate); //// for (int i = 0; i < maxdemandAnalysis.size(); i++){ //// demandList.add(maxdemandAnalysis.get(i).getDemand()); //// freezingTimesList.add(maxdemandAnalysis.get(i).getFreezingTimes()); //// } // List list = new ArrayList<>(); // list.add(CommonIcoVO.builder().name("实时有功需量").list(demandList).listDate(freezingTimesList).build()); // return list; // } @Override public String monthlyReportExport(String deviceCode, String startTime, String endTime, int cycle) { DateFormat dFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒"); Workbook workbook = null; File file = null; try { ExportParams params = new ExportParams(null, "用能月报"); workbook = ExcelExportUtil.exportBigExcel(params, HtAnalogDataTwoExportVo.class, (o, i) -> { int startCurrent = (i - 1) * 10000; List listOne = this.monthlyReportlist(deviceCode, startTime, endTime, cycle, startCurrent); return new ArrayList<>(BeanMapperUtils.mapList(listOne, HtAnalogDataOneVo.class, HtAnalogDataTwoExportVo.class)); }, null); if (null != workbook) { file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "用能月报", dFormat.format(System.currentTimeMillis()) + "")); FileUtils.createFile(file.getAbsolutePath()); FileOutputStream allListingFileOutputStream = new FileOutputStream(file); workbook.write(allListingFileOutputStream); } else { throw new BusinessException("表格数据为空"); } } catch (Exception e) { log.error("导出文件失败", e); throw new BusinessException("导出文件失败"); } finally { if (workbook != null) { try { workbook.close(); } catch (IOException e) { log.error("===export spec=== 关闭workbook失败", e); } } } return file.getName(); } @Override public List monthlyReportlist(String deviceCode, String startTime, String endTime, int cycle, Integer startCurrent) { List listOne = new ArrayList<>(); LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); queryWrapper.eq(Device::getDeviceCode, deviceCode); List deviceList = deviceService.list(queryWrapper); String table = "ht_analog_data"; if (deviceList.size() > 0) { if (deviceList.get(0).getDeviceType().equals("1")) { table = "ht_analog_data"; } else if (deviceList.get(0).getDeviceType().equals("4")) { table = "ht_analog_173_data"; } else { throw new BusinessException("173用电设备无用电数据采集"); } } else { throw new BusinessException("错误数据,设备不存在"); } List maxMonthlyReport = baseMapper.getEnergyUseListOne(deviceCode, startTime, endTime, cycle, 1, 10000, startCurrent, table); List minMonthlyReport = baseMapper.getEnergyUseListOne(deviceCode, startTime, endTime, cycle, 2, 10000, startCurrent, table); if (maxMonthlyReport.size() > 0) { Double epp = 0.00; for (int j = 0; j < maxMonthlyReport.size() + 1; j++) { HtAnalogDataOneVo htAnalogDataOneVo = new HtAnalogDataOneVo(); if (j == maxMonthlyReport.size()) { htAnalogDataOneVo.setEpp(epp); htAnalogDataOneVo.setFreezingTime("合计"); } else { BigDecimal b1 = new BigDecimal(maxMonthlyReport.get(j).getEpp().toString()); BigDecimal b2 = new BigDecimal(minMonthlyReport.get(j).getEpp().toString()); epp += b1.subtract(b2).doubleValue(); htAnalogDataOneVo.setEpp(b1.subtract(b2).doubleValue()); htAnalogDataOneVo.setFreezingTime(maxMonthlyReport.get(j).getFreezingTime()); } listOne.add(htAnalogDataOneVo); } } return listOne; } @Override public SingleLoopReportOneVo SingleLoopReportData(String deviceCode, 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("时间错误"); } } LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); queryWrapper.eq(Device::getDeviceCode, deviceCode); List deviceList = deviceService.list(queryWrapper); String table = "ht_analog_data"; if (deviceList.size() > 0) { if (deviceList.get(0).getDeviceType().equals("1")) { table = "ht_analog_data"; } else if (deviceList.get(0).getDeviceType().equals("4")) { table = "ht_analog_173_data"; } } List SingleLoopReportList = baseMapper.getSingleLoopReportData(deviceCode, startTime, endtime, table); if (CollectionUtils.isEmpty(SingleLoopReportList)) { SingleLoopReportOneVo singleLoopReportOneVo = new SingleLoopReportOneVo(); return singleLoopReportOneVo; } List RtAnalogDataList = baseMapper.getHtAnalogDataList(deviceCode, startTime, endtime, table); if (CollectionUtils.isEmpty(RtAnalogDataList)) { throw new BusinessException("da不存在"); } return analysisCalculation(SingleLoopReportList, RtAnalogDataList); } // public SingleLoopReportOneVo SingleLoopReportData(String deviceCode, 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 SingleLoopReportList = baseMapper.SingleLoopReportData(deviceCode, startTime, endtime); // if (CollectionUtils.isEmpty(SingleLoopReportList)) { // SingleLoopReportOneVo singleLoopReportOneVo = null; // return singleLoopReportOneVo; //// throw new BusinessException("暂无数据"); // } // LambdaQueryWrapper adQuery = Wrappers.lambdaQuery(); // adQuery.eq(HtAnalogData::getDeviceName, deviceCode) // .between(HtAnalogData::getDataTime, startTime, endtime); // List RtAnalogDataList = this.list(adQuery); // if (CollectionUtils.isEmpty(RtAnalogDataList)) { // throw new BusinessException("da不存在"); // } // // // return analysisCalculation(SingleLoopReportList, RtAnalogDataList); // } public SingleLoopReportOneVo analysisCalculation(List SingleLoopReportList, List RtAnalogDataList) { DecimalFormat df = new DecimalFormat("######0.00"); List checkList = new ArrayList<>(); SingleLoopReportOneVo singleLoopReportOneVo = BeanMapperUtils.map(SingleLoopReportList.get(0), SingleLoopReportOneVo.class); checkList.add(SingleLoopReportList.get(0).getAvgIa()); checkList.add(SingleLoopReportList.get(0).getAvgIb()); checkList.add(SingleLoopReportList.get(0).getAvgIc()); // 电流不平衡(平均) Double AvgElBalun = checkBalun(checkList) * 100; singleLoopReportOneVo.setAvgElBalun(Double.valueOf(df.format(AvgElBalun))); if (AvgElBalun < 15) { singleLoopReportOneVo.setAvgElBalunStatus(true); } else { singleLoopReportOneVo.setAvgElBalunStatus(false); } checkList.clear(); checkList.add(SingleLoopReportList.get(0).getMaxIa()); checkList.add(SingleLoopReportList.get(0).getMaxIb()); checkList.add(SingleLoopReportList.get(0).getMaxIc()); // 电流不平衡(最大) Double MaxElBalun = checkBalun(checkList) * 100; singleLoopReportOneVo.setMaxElBalun(Double.valueOf(df.format(MaxElBalun))); if (MaxElBalun < 15) { singleLoopReportOneVo.setMaxElBalunStatus(true); } else { singleLoopReportOneVo.setMaxElBalunStatus(false); } checkList.clear(); checkList.add(SingleLoopReportList.get(0).getMinIa()); checkList.add(SingleLoopReportList.get(0).getMinIb()); checkList.add(SingleLoopReportList.get(0).getMinIc()); // 电流不平衡(最小) Double MinElBalun = checkBalun(checkList) * 100; singleLoopReportOneVo.setMinElBalun(Double.valueOf(df.format(MinElBalun))); if (MinElBalun < 15) { singleLoopReportOneVo.setMinElBalunStatus(true); } else { singleLoopReportOneVo.setMinElBalunStatus(false); } if (AvgElBalun < 15 && MaxElBalun < 15 && MinElBalun < 15) { singleLoopReportOneVo.setElBalunStatus(true); } else { singleLoopReportOneVo.setElBalunStatus(false); } checkList.clear(); checkList.add(SingleLoopReportList.get(0).getAvgUa()); checkList.add(SingleLoopReportList.get(0).getAvgUb()); checkList.add(SingleLoopReportList.get(0).getAvgUc()); // 电压不平衡(平均) Double AvgVtBalun = checkBalun(checkList) * 100; singleLoopReportOneVo.setAvgVtBalun(Double.valueOf(df.format(AvgVtBalun))); if (AvgVtBalun < 15) { singleLoopReportOneVo.setAvgVtBalunStatus(true); } else { singleLoopReportOneVo.setAvgVtBalunStatus(false); } checkList.clear(); checkList.add(SingleLoopReportList.get(0).getMaxUa()); checkList.add(SingleLoopReportList.get(0).getMaxUb()); checkList.add(SingleLoopReportList.get(0).getMaxUc()); // 电压不平衡(最大) Double MaxVtBalun = checkBalun(checkList) * 100; singleLoopReportOneVo.setMaxVtBalun(Double.valueOf(df.format(MaxVtBalun))); if (MaxVtBalun < 15) { singleLoopReportOneVo.setMaxVtBalunStatus(true); } else { singleLoopReportOneVo.setMaxVtBalunStatus(false); } checkList.clear(); checkList.add(SingleLoopReportList.get(0).getMinUa()); checkList.add(SingleLoopReportList.get(0).getMinUb()); checkList.add(SingleLoopReportList.get(0).getMinUc()); // 电压不平衡(最小) Double MinVtBalun = checkBalun(checkList) * 100; singleLoopReportOneVo.setMinVtBalun(Double.valueOf(df.format(MinVtBalun))); if (MinVtBalun < 15) { singleLoopReportOneVo.setMinVtBalunStatus(true); } else { singleLoopReportOneVo.setMinVtBalunStatus(false); } if (AvgVtBalun < 15 && MaxVtBalun < 15 && MinVtBalun < 15) { singleLoopReportOneVo.setVtBalunStatus(true); } else { singleLoopReportOneVo.setVtBalunStatus(false); } double voltageLevel = Double.parseDouble(singleLoopReportOneVo.getVoltageLevel()); double voltageLevelWanting = voltageLevel / 100 * 7; // A相电压合格率(平均) checkList.clear(); checkList.add(SingleLoopReportList.get(0).getAvgUa()); checkList.add(voltageLevel); Double AvgUaQR = Double.valueOf(df.format(VoltageQr(checkList, voltageLevel))); singleLoopReportOneVo.setAvgUa(df.format(SingleLoopReportList.get(0).getAvgUa()) + "kV(" + AvgUaQR + "%)"); if (AvgUaQR < 7.00) { singleLoopReportOneVo.setAvgUaStatus(true); } else { singleLoopReportOneVo.setAvgUaStatus(false); } // B相电压合格率(平均) checkList.clear(); checkList.add(SingleLoopReportList.get(0).getAvgUb()); checkList.add(voltageLevel); Double AvgUbQR = Double.valueOf(df.format(VoltageQr(checkList, voltageLevel))); singleLoopReportOneVo.setAvgUb(df.format(SingleLoopReportList.get(0).getAvgUb()) + "kV(" + AvgUbQR + "%)"); if (AvgUbQR < 7.00) { singleLoopReportOneVo.setAvgUbStatus(true); } else { singleLoopReportOneVo.setAvgUbStatus(false); } // C相电压合格率(平均) checkList.clear(); checkList.add(SingleLoopReportList.get(0).getAvgUc()); checkList.add(voltageLevel); Double AvgUcQR = Double.valueOf(df.format(VoltageQr(checkList, voltageLevel))); singleLoopReportOneVo.setAvgUc(df.format(SingleLoopReportList.get(0).getAvgUc()) + "kV(" + AvgUcQR + "%)"); if (AvgUcQR < 7.00) { singleLoopReportOneVo.setAvgUcStatus(true); } else { singleLoopReportOneVo.setAvgUcStatus(false); } // A相电压合格率(最大) checkList.clear(); checkList.add(SingleLoopReportList.get(0).getMaxUa()); checkList.add(voltageLevel); Double MaxUaQR = Double.valueOf(df.format(VoltageQr(checkList, voltageLevel))); singleLoopReportOneVo.setMaxUa(df.format(SingleLoopReportList.get(0).getMaxUa()) + "kV(" + MaxUaQR + "%)"); if (MaxUaQR < 7.00) { singleLoopReportOneVo.setMaxUaStatus(true); } else { singleLoopReportOneVo.setMaxUaStatus(false); } // B相电压合格率(最大) checkList.clear(); checkList.add(SingleLoopReportList.get(0).getMaxUb()); checkList.add(voltageLevel); Double MaxUbQR = Double.valueOf(df.format(VoltageQr(checkList, voltageLevel))); singleLoopReportOneVo.setMaxUb(df.format(SingleLoopReportList.get(0).getMaxUb()) + "kV(" + MaxUbQR + "%)"); if (MaxUbQR < 7.00) { singleLoopReportOneVo.setMaxUbStatus(true); } else { singleLoopReportOneVo.setMaxUbStatus(false); } // C相电压合格率(最大) checkList.clear(); checkList.add(SingleLoopReportList.get(0).getMaxUc()); checkList.add(voltageLevel); Double MaxUcQR = Double.valueOf(df.format(VoltageQr(checkList, voltageLevel))); singleLoopReportOneVo.setMaxUc(df.format(SingleLoopReportList.get(0).getMaxUc()) + "kV(" + MaxUcQR + "%)"); if (MaxUcQR < 7.00) { singleLoopReportOneVo.setMaxUcStatus(true); } else { singleLoopReportOneVo.setMaxUcStatus(false); } // A相电压合格率(最小) checkList.clear(); checkList.add(SingleLoopReportList.get(0).getMinUa()); checkList.add(voltageLevel); Double MinUaQR = Double.valueOf(df.format(VoltageQr(checkList, voltageLevel))); singleLoopReportOneVo.setMinUa(df.format(SingleLoopReportList.get(0).getMinUa()) + "kV(" + MinUaQR + "%)"); if (MinUaQR < 7.00) { singleLoopReportOneVo.setMinUaStatus(true); } else { singleLoopReportOneVo.setMinUaStatus(false); } // B相电压合格率(最小) checkList.clear(); checkList.add(SingleLoopReportList.get(0).getMinUb()); checkList.add(voltageLevel); Double MinUbQR = Double.valueOf(df.format(VoltageQr(checkList, voltageLevel))); singleLoopReportOneVo.setMinUb(df.format(SingleLoopReportList.get(0).getMinUb()) + "kV(" + MinUbQR + "%)"); if (MinUbQR < 7.00) { singleLoopReportOneVo.setMinUbStatus(true); } else { singleLoopReportOneVo.setMinUbStatus(false); } // C相电压合格率(最小) checkList.clear(); checkList.add(SingleLoopReportList.get(0).getMinUc()); checkList.add(voltageLevel); Double MinUcQR = Double.valueOf(df.format(VoltageQr(checkList, voltageLevel))); singleLoopReportOneVo.setMinUc(df.format(SingleLoopReportList.get(0).getMinUc()) + "kV(" + MinUcQR + "%)"); if (MinUcQR < 7.00) { singleLoopReportOneVo.setMinUcStatus(true); } else { singleLoopReportOneVo.setMinUcStatus(false); } if (AvgUaQR < 7.00 && MaxUaQR < 7.00 && MinUaQR < 7.00) { singleLoopReportOneVo.setUaStatus(true); } else { singleLoopReportOneVo.setUaStatus(false); } if (AvgUbQR < 7.00 && MaxUbQR < 7.00 && MinUbQR < 7.00) { singleLoopReportOneVo.setUbStatus(true); } else { singleLoopReportOneVo.setUbStatus(false); } if (AvgUcQR < 7.00 && MaxUcQR < 7.00 && MinUcQR < 7.00) { singleLoopReportOneVo.setUcStatus(true); } else { singleLoopReportOneVo.setUcStatus(false); } // 频率(平均) Double cAvgF = 0.00; if (SingleLoopReportList.get(0).getAvgF() >= 50) { cAvgF = Double.valueOf(df.format(SingleLoopReportList.get(0).getAvgF() - 50.00)); } else { cAvgF = Double.valueOf(df.format(50.00 - SingleLoopReportList.get(0).getAvgF())); } singleLoopReportOneVo.setAvgF(df.format(SingleLoopReportList.get(0).getAvgF()) + "Hz(" + cAvgF + "Hz)"); if (SingleLoopReportList.get(0).getAvgF() < 50.2 && SingleLoopReportList.get(0).getAvgF() > 49.8) { singleLoopReportOneVo.setAvgFStatus(true); } else { singleLoopReportOneVo.setAvgFStatus(false); } // 频率(最大) Double cMaxF = 0.00; if (SingleLoopReportList.get(0).getAvgF() >= 50) { cMaxF = Double.valueOf(df.format(SingleLoopReportList.get(0).getMaxF() - 50.00)); } else { cMaxF = Double.valueOf(df.format(50.00 - SingleLoopReportList.get(0).getMaxF())); } singleLoopReportOneVo.setMaxF(df.format(SingleLoopReportList.get(0).getMaxF()) + "Hz(" + cMaxF + "Hz)"); if (SingleLoopReportList.get(0).getMaxF() < 50.2 && SingleLoopReportList.get(0).getMaxF() > 49.8) { singleLoopReportOneVo.setMaxFStatus(true); } else { singleLoopReportOneVo.setMaxFStatus(false); } // 频率(最小) Double cMinF = 0.00; if (SingleLoopReportList.get(0).getAvgF() >= 50) { cMinF = Double.valueOf(df.format(SingleLoopReportList.get(0).getMinF() - 50.00)); } else { cMinF = Double.valueOf(df.format(50.00 - SingleLoopReportList.get(0).getMinF())); } singleLoopReportOneVo.setMinF(df.format(SingleLoopReportList.get(0).getMinF()) + "Hz(" + cMinF + "Hz)"); if (SingleLoopReportList.get(0).getMinF() < 50.2 && SingleLoopReportList.get(0).getMinF() > 49.8) { singleLoopReportOneVo.setMinFStatus(true); } else { singleLoopReportOneVo.setMinFStatus(false); } if (singleLoopReportOneVo.getAvgFStatus() == true && singleLoopReportOneVo.getMaxFStatus() == true && singleLoopReportOneVo.getMaxFStatus() == true) { singleLoopReportOneVo.setFStatus(true); } else { singleLoopReportOneVo.setFStatus(false); } if (SingleLoopReportList.get(0).getCos() > 0.85) { singleLoopReportOneVo.setCosStatus(true); } else { singleLoopReportOneVo.setCosStatus(false); } int OverrunUa = 0; int OverrunUb = 0; int OverrunUc = 0; int OverrunF = 0; int OverrunElBalun = 0; int OverrunVtBalun = 0; if (RtAnalogDataList.size() > 0) { for (int i = 0; i < RtAnalogDataList.size(); i++) { checkList.clear(); checkList.add(RtAnalogDataList.get(i).getUa()); checkList.add(voltageLevel); Double maxUa = checkList.stream().max(Double::compareTo).get(); Double minUa = checkList.stream().min(Double::compareTo).get(); Double wantingUa = Arith.sub(maxUa, minUa); if (wantingUa < voltageLevelWanting) { OverrunUa++; } checkList.clear(); checkList.add(RtAnalogDataList.get(i).getUb()); checkList.add(voltageLevel); Double maxUb = checkList.stream().max(Double::compareTo).get(); Double minUb = checkList.stream().min(Double::compareTo).get(); Double wantingUb = Arith.sub(maxUb, minUb); if (wantingUb < voltageLevelWanting) { OverrunUb++; } checkList.clear(); checkList.add(RtAnalogDataList.get(i).getUc()); checkList.add(voltageLevel); Double maxUc = checkList.stream().max(Double::compareTo).get(); Double minUc = checkList.stream().min(Double::compareTo).get(); Double wantingUc = Arith.sub(maxUc, minUc); if (wantingUc < voltageLevelWanting) { OverrunUc++; } if (RtAnalogDataList.get(i).getF() < 50.2 && RtAnalogDataList.get(i).getF() > 49.8) { OverrunF++; } checkList.clear(); checkList.add(RtAnalogDataList.get(i).getIa()); checkList.add(RtAnalogDataList.get(i).getIb()); checkList.add(RtAnalogDataList.get(i).getIc()); // 电流不平衡 Double ElBalun = checkBalun(checkList); if (ElBalun < 0.15) { OverrunElBalun++; } checkList.clear(); checkList.add(RtAnalogDataList.get(i).getUa()); checkList.add(RtAnalogDataList.get(i).getUb()); checkList.add(RtAnalogDataList.get(i).getUc()); // 电压不平衡 Double VtBalunQ = checkBalun(checkList); if (VtBalunQ < 0.15) { OverrunVtBalun++; } } } singleLoopReportOneVo.setProportionUa(singleLoopReportOneVo.getMeasuringPoints() - OverrunUa + "/" + singleLoopReportOneVo.getMeasuringPoints()); singleLoopReportOneVo.setProportionUb(singleLoopReportOneVo.getMeasuringPoints() - OverrunUb + "/" + singleLoopReportOneVo.getMeasuringPoints()); singleLoopReportOneVo.setProportionUc(singleLoopReportOneVo.getMeasuringPoints() - OverrunUc + "/" + singleLoopReportOneVo.getMeasuringPoints()); singleLoopReportOneVo.setProportionF(singleLoopReportOneVo.getMeasuringPoints() - OverrunF + "/" + singleLoopReportOneVo.getMeasuringPoints()); singleLoopReportOneVo.setProportionElBalun(singleLoopReportOneVo.getMeasuringPoints() - OverrunElBalun + "/" + singleLoopReportOneVo.getMeasuringPoints()); singleLoopReportOneVo.setProportionVtBalun(singleLoopReportOneVo.getMeasuringPoints() - OverrunVtBalun + "/" + singleLoopReportOneVo.getMeasuringPoints()); singleLoopReportOneVo.setQrUa(OverrunUa == 0 ? 00.00 : Double.valueOf(df.format(Double.valueOf(OverrunUa) / Double.valueOf(singleLoopReportOneVo.getMeasuringPoints()) * 100))); singleLoopReportOneVo.setQrUb(OverrunUb == 0 ? 00.00 : Double.valueOf(df.format(Double.valueOf(OverrunUb) / Double.valueOf(singleLoopReportOneVo.getMeasuringPoints()) * 100))); singleLoopReportOneVo.setQrUc(OverrunUc == 0 ? 00.00 : Double.valueOf(df.format(Double.valueOf(OverrunUc) / Double.valueOf(singleLoopReportOneVo.getMeasuringPoints()) * 100))); singleLoopReportOneVo.setQrF(OverrunF == 0 ? 00.00 : Double.valueOf(df.format(Double.valueOf(OverrunF) / Double.valueOf(singleLoopReportOneVo.getMeasuringPoints()) * 100))); singleLoopReportOneVo.setQrElBalun(OverrunElBalun == 0 ? 00.00 : Double.valueOf(df.format(Double.valueOf(OverrunElBalun) / Double.valueOf(singleLoopReportOneVo.getMeasuringPoints())))); singleLoopReportOneVo.setQrVtBalun(OverrunVtBalun == 0 ? 00.00 : Double.valueOf(df.format(Double.valueOf(OverrunVtBalun) / Double.valueOf(singleLoopReportOneVo.getMeasuringPoints())))); singleLoopReportOneVo.setVoltageLevelToplimit(voltageLevel + voltageLevelWanting); singleLoopReportOneVo.setVoltageLevelLowerLimit(voltageLevel - voltageLevelWanting); singleLoopReportOneVo.setMhz(50.00); singleLoopReportOneVo.setFToplimit(50.2); singleLoopReportOneVo.setFLowerLimit(49.8); singleLoopReportOneVo.setAppraise(0.85); singleLoopReportOneVo.setBalanceToplimit(15.00); singleLoopReportOneVo.setBalanceLowerLimit(15.00); return singleLoopReportOneVo; } public Double VoltageQr(List checkList, Double voltageLevel) { Double max = checkList.stream().max(Double::compareTo).get(); Double min = checkList.stream().min(Double::compareTo).get(); Double wanting = Arith.sub(max, min); Double QR = wanting / voltageLevel * 100; return QR; } public Double checkBalun(List list) { long count = list.stream().filter(code -> 0.00 == code).count(); if (3 == count) { return 0.00; } Double max = list.stream().max(Double::compareTo).get(); Double min = list.stream().min(Double::compareTo).get(); return Arith.div(Arith.sub(max, min), max); } // 获取设备三相总有功功率值 @Override public List getP(List deviceCodes) { return htAnalogDataMapper.getP(deviceCodes); } }