package com.bizmatics.service.impl; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; 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.*; import com.bizmatics.common.mvc.base.AbstractCrudService; import com.bizmatics.common.spring.util.GlobalUtils; import com.bizmatics.model.*; import com.bizmatics.model.vo.EvaluationReporVo; import com.bizmatics.persistence.mapper.RtAnalogDataMapper; import com.bizmatics.service.DeviceAttributeService; import com.bizmatics.service.DeviceService; import com.bizmatics.service.RtAnalogDataService; import com.bizmatics.service.SiteDynamicPropertiesService; import com.bizmatics.service.util.SecurityUtils; import com.bizmatics.service.vo.RadCountVO; import com.bizmatics.service.vo.RealScoreOneVO; import com.bizmatics.service.vo.RealScoreVO; import org.apache.commons.lang3.ArrayUtils; 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.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.atomic.AtomicReference; /** *

* 服务实现类 *

* * @author ya * @since 2021-07-07 */ @Service public class RtAnalogDataServiceImpl extends AbstractCrudService implements RtAnalogDataService { @Autowired private DeviceService deviceService; @Autowired private SiteDynamicPropertiesService siteDynamicPropertiesService; @Autowired private DeviceAttributeService deviceAttributeService; @Override public RadCountVO selectCount() { Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue(); AtomicReference heavyLoad = new AtomicReference<>(0); AtomicReference easyLoad = new AtomicReference<>(0); AtomicReference norMalLoad = new AtomicReference<>(0); AtomicReference count = new AtomicReference<>(0); List deviceList = deviceService.list(userId, null, null, null, null, null); List list = baseMapper.list(userId); for (Device device : deviceList) { list.stream() .filter(rtAnalogData -> device.getDeviceCode().equals(rtAnalogData.getDeviceName())).findAny() .ifPresent(rtAnalogData -> { String installedCapacity = device.getInstalledCapacity(); double installedCapacityDouble = 0.00; if (StringUtils.isNotBlank(installedCapacity)) { installedCapacityDouble = Double.parseDouble(installedCapacity); if (installedCapacityDouble > 0) { installedCapacityDouble = Arith.div(rtAnalogData.getP(), installedCapacityDouble); } } if (installedCapacityDouble < 0.4) { easyLoad.getAndSet(easyLoad.get() + 1); } else if (installedCapacityDouble >= 0.4 && installedCapacityDouble <= 0.8) { norMalLoad.getAndSet(norMalLoad.get() + 1); } else { heavyLoad.getAndSet(heavyLoad.get() + 1); } count.getAndSet(count.get() + 1); }); } RadCountVO radCountVO = new RadCountVO(); radCountVO.setHeavyLoad(subRadio(heavyLoad.get(), count.get())); radCountVO.setEasyLoad(subRadio(easyLoad.get(), count.get())); radCountVO.setNorMalLoad(Arith.sub(1, Arith.add(radCountVO.getEasyLoad(), radCountVO.getHeavyLoad()))); return radCountVO; } public Double subRadio(Integer typeCount, Integer count) { return Optional.of(count).filter(total -> total != 0).map(sub -> Arith.div(typeCount, sub)).orElse(0.00); } public String addUnitOne(String name) { if (name.endsWith("电压")) { return "V"; } else if (name.endsWith("电流")) { return "A"; } else if (name.endsWith("温度")) { return "℃"; } else if (name.endsWith("频率")) { return "Hz"; } else if (name.endsWith("有功功率") || name.endsWith("需量")) { return "KW"; } else if (name.endsWith("无功功率")) { return "KVar"; } else if (name.endsWith("不平衡度") || name.endsWith("电压畸变率")) { return "%"; } else if (name.endsWith("次数")) { return "次"; } else if (name.endsWith("电度") || name.endsWith("有功")) { return "KWh"; } else if (name.endsWith("THD")) { return "%"; } return ""; } @Override public List> getOne(Integer siteId) { List> list = new ArrayList<>(); Map radMap = baseMapper.getOneMap(siteId); Optional.ofNullable(radMap).ifPresent(rad -> { for (String name : rad.keySet()) { Map map = new HashMap<>(); map.put("name", name); map.put("value", rad.get(name) + "" + addUnitOne(name)); list.add(map); } }); return list; } @Override public Double getEpLoad(Integer siteId) { Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue(); return baseMapper.selectTotalLoad(userId, siteId); } @Override public RealScoreVO realScore(String deviceCode) { LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); queryWrapper.eq(RtAnalogData::getDeviceName, deviceCode); RtAnalogData rtAnalogData = getOne(queryWrapper); Optional.ofNullable(rtAnalogData).orElseThrow(() -> new BusinessException("设备实时信息不存在")); //查询设备 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(); return fillRealScoreData(rtAnalogData, siteDynamicProperties, deviceAttribute); } @Override public RealScoreOneVO realScoreOne(String deviceCode) { LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); queryWrapper.eq(RtAnalogData::getDeviceName, deviceCode); RtAnalogData rtAnalogData = getOne(queryWrapper); Optional.ofNullable(rtAnalogData).orElseThrow(() -> new BusinessException("设备实时信息不存在")); //查询设备 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不存在")); return fillRealScoreDataOne(rtAnalogData, siteDynamicProperties); } @Override public RealScoreOneVO fillRealScoreDataOne(RtAnalogData rtAnalogData, SiteDynamicProperties siteDynamicProperties) { List checkList = new ArrayList<>(); RealScoreOneVO realScoreVo = BeanMapperUtils.map(rtAnalogData, RealScoreOneVO.class); checkList.add(realScoreVo.getIa()); checkList.add(realScoreVo.getIb()); checkList.add(realScoreVo.getIc()); //电流不平衡 realScoreVo.setElBalun(checkBalun(checkList)); checkList.clear(); checkList.add(realScoreVo.getUa()); checkList.add(realScoreVo.getUb()); checkList.add(realScoreVo.getUc()); //ABC三相电压占比 Double max = checkList.stream().max(Double::compareTo).get(); if (max == 0.00) { realScoreVo.setUaPercentage(0.00); realScoreVo.setUbPercentage(0.00); realScoreVo.setUcPercentage(0.00); } else { realScoreVo.setUaPercentage(Arith.div(realScoreVo.getUa(), (max / 100 * 20 + max) * 100)); realScoreVo.setUbPercentage(Arith.div(realScoreVo.getUb(), (max / 100 * 20 + max) * 100)); realScoreVo.setUcPercentage(Arith.div(realScoreVo.getUc(), (max / 100 * 20 + max) * 100)); } //电压不平衡 realScoreVo.setVtBalun(checkBalun(checkList)); //当前频率 realScoreVo.setF(realScoreVo.getF()); //频率偏差 if (realScoreVo.getF() == 0.00) { realScoreVo.setFdeviation(0.00); } else { checkList.clear(); checkList.add(50.00); checkList.add(realScoreVo.getF()); Double max1 = checkList.stream().max(Double::compareTo).get(); Double min1 = checkList.stream().min(Double::compareTo).get(); realScoreVo.setFdeviation(Arith.sub(max1, min1) / 50 * 100); } if (realScoreVo.getP() == 0.00) { realScoreVo.setPpercentage(0.00); } else { realScoreVo.setPpercentage(Arith.div(realScoreVo.getP(), realScoreVo.getP() / 100 * 20 + realScoreVo.getP())); } if (realScoreVo.getQ() == 0.00) { realScoreVo.setQpercentage(0.00); } else { realScoreVo.setQpercentage(Arith.div(realScoreVo.getQ(), realScoreVo.getQ() / 100 * 20 + realScoreVo.getQ())); } realScoreVo.setVoltageLevel(siteDynamicProperties.getVoltageLevel()); return realScoreVo; } /** * 填充实时数据 */ @Override public RealScoreVO fillRealScoreData(RtAnalogData rtAnalogData, SiteDynamicProperties siteDynamicProperties, DeviceAttribute deviceAttribute) { List checkList = new ArrayList<>(); Integer score = 0; RealScoreVO realScoreVo = BeanMapperUtils.map(rtAnalogData, RealScoreVO.class); if (null == realScoreVo.getCos()) { realScoreVo.setCos(0.00); } checkList.add(realScoreVo.getIa()); checkList.add(realScoreVo.getIb()); checkList.add(realScoreVo.getIc()); //电流不平衡 realScoreVo.setElBalun(checkBalun(checkList)); checkList.clear(); checkList.add(realScoreVo.getUa()); checkList.add(realScoreVo.getUb()); checkList.add(realScoreVo.getUc()); //电压不平衡 realScoreVo.setVtBalun(checkBalun(checkList)); //电压合格率 double voltageLevel = Double.parseDouble(siteDynamicProperties.getVoltageLevel()); realScoreVo.setUaQualified(Arith.sub(rtAnalogData.getUa(), voltageLevel)); realScoreVo.setUbQualified(Arith.sub(rtAnalogData.getUb(), voltageLevel)); realScoreVo.setUcQualified(Arith.sub(rtAnalogData.getUc(), voltageLevel)); //电流负载率 Double ratedCurrent = deviceAttribute.getRatedCurrent(); realScoreVo.setIaLoad(Arith.div(realScoreVo.getIa(), ratedCurrent)); realScoreVo.setIbLoad(Arith.div(realScoreVo.getIb(), ratedCurrent)); realScoreVo.setIcLoad(Arith.div(realScoreVo.getIc(), ratedCurrent)); //计算分数 //电压分数 realScoreVo.setUaQ(computeUScore(realScoreVo.getUaQualified(), voltageLevel)); realScoreVo.setUbQ(computeUScore(realScoreVo.getUbQualified(), voltageLevel)); realScoreVo.setUcQ(computeUScore(realScoreVo.getUcQualified(), voltageLevel)); if (realScoreVo.getUaQ() && realScoreVo.getUbQ() && realScoreVo.getUcQ()) { realScoreVo.setUQ(true); score += 20; } else { realScoreVo.setUQ(false); } //电流分数 realScoreVo.setIaLoadQ(realScoreVo.getIaLoad() <= 0.8); realScoreVo.setIbLoadQ(realScoreVo.getIbLoad() <= 0.8); realScoreVo.setIcLoadQ(realScoreVo.getIcLoad() <= 0.8); if (realScoreVo.getIaLoadQ() && realScoreVo.getIbLoadQ() && realScoreVo.getIcLoadQ()) { realScoreVo.setILoadQ(true); score += 20; } else { realScoreVo.setILoadQ(false); } //电压平衡分数 realScoreVo.setElBalunQ(realScoreVo.getElBalun() <= 0.15); if (realScoreVo.getElBalunQ()) { score += 20; } //电流平衡分数 realScoreVo.setVtBalunQ(realScoreVo.getVtBalun() <= 0.15); if (realScoreVo.getVtBalunQ()) { score += 20; } //功率 realScoreVo.setCosQ(realScoreVo.getCos() <= 0.15); if (realScoreVo.getCosQ()) { score += 20; } realScoreVo.setScore(score); return realScoreVo; } /** * 计算电压分数 * * @return */ public Boolean computeUScore(Double qualified, Double voltageLevel) { double mul = Arith.mul(qualified, voltageLevel); if (mul <= 0.07 && mul >= -0.07) { return true; } return false; } /** * 计算电流/电压不平衡 * * @param list * @return */ 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); } /** * 添加数据单位 * * @return */ public String addUnit(String name, String value) { if (name.endsWith("电压")) { return value + "V"; } else if (name.endsWith("电流")) { return value + "A"; } else if (name.endsWith("温度")) { return value + "C"; } else if (name.endsWith("频率")) { return value + "Hz"; } else if (name.endsWith("有功功率") || name.endsWith("需量")) { return value + "KW"; } else if (name.endsWith("无功功率")) { return value + "KVar"; } else if (name.endsWith("不平衡度") || name.endsWith("电压畸变率")) { return value + "%"; } else if (name.endsWith("次数")) { return value + "次"; } else if (name.endsWith("电度") || name.endsWith("有功")) { return value + "KWh"; } return value; } @Override public List> getDataReport(Integer siteId, Date startTime, Date endTime, String queryType) { List> list = new ArrayList<>(); List rtAnalogDataList = null; long diff = endTime.getTime() - startTime.getTime(); long days = diff / (1000 * 60 * 60); if (days <= 24) { rtAnalogDataList = baseMapper.getDataReportMap(siteId, startTime, endTime); } else if (days < 360 && days > 24) { List device_list = baseMapper.getDeviceListMap(siteId); rtAnalogDataList = baseMapper.getDataReportMMap(device_list, startTime, endTime); } else if (days >= 360) { List device_list = baseMapper.getDeviceListMap(siteId); rtAnalogDataList = baseMapper.getDataReportDMap(device_list, startTime, endTime); } String[] result = queryType.split(","); if (rtAnalogDataList.size() > 0) { rtAnalogDataList.forEach(rtAnalogData -> { Map map = new HashMap<>(); if (ArrayUtils.contains(result, "I")) { map.put("Ia", rtAnalogData.getIa()); map.put("Ib", rtAnalogData.getIb()); map.put("Ic", rtAnalogData.getIc()); if (ArrayUtils.contains(result, "P")) { map.put("P", rtAnalogData.getP()); map.put("Q", rtAnalogData.getQ()); map.put("Pa", rtAnalogData.getPa()); map.put("Pb", rtAnalogData.getPb()); map.put("Pc", rtAnalogData.getPc()); map.put("Qa", rtAnalogData.getQa()); map.put("Qb", rtAnalogData.getQb()); map.put("Qc", rtAnalogData.getQc()); map.put("Demand", rtAnalogData.getDemand()); if (ArrayUtils.contains(result, "KWh")) { map.put("Epn", rtAnalogData.getEpn()); map.put("Epp", rtAnalogData.getEpp()); map.put("Eqn", rtAnalogData.getEqn()); map.put("Eqp", rtAnalogData.getEqp()); if (ArrayUtils.contains(result, "V")) { map.put("Ua", rtAnalogData.getUa()); map.put("Ub", rtAnalogData.getUb()); map.put("Uc", rtAnalogData.getUc()); map.put("Uab", rtAnalogData.getUab()); map.put("Ubc", rtAnalogData.getUbc()); map.put("Uca", rtAnalogData.getUca()); map.put("Ul", rtAnalogData.getUl()); if (ArrayUtils.contains(result, "C")) { map.put("T1", rtAnalogData.getT1()); map.put("T2", rtAnalogData.getT2()); map.put("T3", rtAnalogData.getT3()); map.put("T4", rtAnalogData.getT4()); map.put("DeviceTemp", rtAnalogData.getDeviceTemp()); if (ArrayUtils.contains(result, "HZ")) { map.put("F", rtAnalogData.getF()); if (ArrayUtils.contains(result, "PS")) { map.put("COSa", rtAnalogData.getCOSa()); map.put("COSb", rtAnalogData.getCOSb()); map.put("COSc", rtAnalogData.getCOSc()); map.put("COS", rtAnalogData.getCos()); if (ArrayUtils.contains(result, "RMS")) { map.put("IHa", rtAnalogData.getIHa()); map.put("IHb", rtAnalogData.getIHb()); map.put("IHc", rtAnalogData.getIHc()); if (ArrayUtils.contains(result, "DDB")) { map.put("SignalIntensity", rtAnalogData.getSignalIntensity()); if (ArrayUtils.contains(result, "VT")) { map.put("Upt", rtAnalogData.getUpt()); map.put("Udt", rtAnalogData.getUdt()); map.put("Ust", rtAnalogData.getUst()); } } } } } } } } } } if (days <= 24) { map.put("dataTime", DateUtils.format(rtAnalogData.getDataTime(), "MM-dd HH:mm")); } else if (days < 360 && days > 24) { map.put("dataTime", DateUtils.format(rtAnalogData.getDataTime(), "MM-dd HH:mm")); } else if (days >= 360) { map.put("dataTime", DateUtils.format(rtAnalogData.getDataTime(), DateUtils.PARSE_PATTERNS[8])); } list.add(map); }); } return list; } @Override public List> getHistoricalCurve(Integer siteId, Date startTime, Date endTime, String queryType) { List> list = new ArrayList<>(); List> listdataTime = new ArrayList<>(); List> list1 = new ArrayList<>(); List> list2 = new ArrayList<>(); List> list3 = new ArrayList<>(); List> list4 = new ArrayList<>(); List> list5 = new ArrayList<>(); List> list6 = new ArrayList<>(); List> list7 = new ArrayList<>(); List> list8 = new ArrayList<>(); List> list9 = new ArrayList<>(); List rtAnalogDataList = null; long diff = endTime.getTime() - startTime.getTime(); long days = diff / (1000 * 60 * 60); if (days <= 24) { rtAnalogDataList = baseMapper.getDataReportMap(siteId, startTime, endTime); } else if (days < 360 && days > 24) { List device_list = baseMapper.getDeviceListMap(siteId); rtAnalogDataList = baseMapper.getDataReportMMap(device_list, startTime, endTime); } else if (days >= 360) { List device_list = baseMapper.getDeviceListMap(siteId); rtAnalogDataList = baseMapper.getDataReportDMap(device_list, startTime, endTime); } String[] result = queryType.split(","); if (rtAnalogDataList.size() > 0) { Map mapIe1 = new HashMap<>(); Map mapIe2 = new HashMap<>(); Map mapIe3 = new HashMap<>(); Map mapIe4 = new HashMap<>(); Map mapIe5 = new HashMap<>(); Map mapIe6 = new HashMap<>(); Map mapIe7 = new HashMap<>(); Map mapIe8 = new HashMap<>(); Map mapIe9 = new HashMap<>(); for (int i = 0; i < rtAnalogDataList.size(); i++) { Map map = new HashMap<>(); Map map1 = new HashMap<>(); Map map2 = new HashMap<>(); Map map3 = new HashMap<>(); Map map4 = new HashMap<>(); Map map5 = new HashMap<>(); Map map6 = new HashMap<>(); Map map7 = new HashMap<>(); Map map8 = new HashMap<>(); Map map9 = new HashMap<>(); HtAnalogData rtAnalogData = (HtAnalogData) rtAnalogDataList.get(i); // if (days<=24){ // map.put("dataTime",DateUtils.format(rtAnalogData.getDataTime(),"MM-dd HH:mm")); // }else if (days<360&&days>24){ // map.put("dataTime", DateUtils.format(rtAnalogData.getDataTime(),"MM-dd HH:mm")); // }else if (days>=360){ // map.put("dataTime",DateUtils.format(rtAnalogData.getDataTime(),DateUtils.PARSE_PATTERNS[8])); // } map.put("dataTime", rtAnalogData.getDataTime()); if (ArrayUtils.contains(result, "I")) { map1.put("Ia", rtAnalogData.getIa()); map2.put("Ib", rtAnalogData.getIb()); map3.put("Ic", rtAnalogData.getIc()); } else if (ArrayUtils.contains(result, "P")) { map1.put("P", rtAnalogData.getP()); map2.put("Q", rtAnalogData.getQ()); map3.put("Pa", rtAnalogData.getPa()); map4.put("Pb", rtAnalogData.getPb()); map5.put("Pc", rtAnalogData.getPc()); map6.put("Qa", rtAnalogData.getQa()); map7.put("Qb", rtAnalogData.getQb()); map8.put("Qc", rtAnalogData.getQc()); map9.put("Demand", rtAnalogData.getDemand()); } else if (ArrayUtils.contains(result, "KWh")) { map1.put("Epn", rtAnalogData.getEpn()); map2.put("Epp", rtAnalogData.getEpp()); map3.put("Eqn", rtAnalogData.getEqn()); map4.put("Eqp", rtAnalogData.getEqp()); } else if (ArrayUtils.contains(result, "V")) { map1.put("Ua", rtAnalogData.getUa()); map2.put("Ub", rtAnalogData.getUb()); map3.put("Uc", rtAnalogData.getUc()); map4.put("Uab", rtAnalogData.getUab()); map5.put("Ubc", rtAnalogData.getUbc()); map6.put("Uca", rtAnalogData.getUca()); map7.put("Ul", rtAnalogData.getUl()); } else if (ArrayUtils.contains(result, "C")) { map1.put("T1", rtAnalogData.getT1()); map2.put("T2", rtAnalogData.getT2()); map3.put("T3", rtAnalogData.getT3()); map4.put("T4", rtAnalogData.getT4()); map5.put("DeviceTemp", rtAnalogData.getDeviceTemp()); } else if (ArrayUtils.contains(result, "HZ")) { map1.put("F", rtAnalogData.getF()); } else if (ArrayUtils.contains(result, "PS")) { map1.put("COSa", rtAnalogData.getCOSa()); map2.put("COSb", rtAnalogData.getCOSb()); map3.put("COSc", rtAnalogData.getCOSc()); map4.put("COS", rtAnalogData.getCos()); } else if (ArrayUtils.contains(result, "RMS")) { map1.put("IHa", rtAnalogData.getIHa()); map2.put("IHb", rtAnalogData.getIHb()); map3.put("IHc", rtAnalogData.getIHc()); } else if (ArrayUtils.contains(result, "DDB")) { map1.put("SignalIntensity", rtAnalogData.getSignalIntensity()); } else if (ArrayUtils.contains(result, "VT")) { map1.put("Upt", rtAnalogData.getUpt()); map2.put("Udt", rtAnalogData.getUdt()); map3.put("Ust", rtAnalogData.getUst()); } listdataTime.add(map); list1.add(map1); list2.add(map2); list3.add(map3); list4.add(map4); list5.add(map5); list6.add(map6); list7.add(map7); list8.add(map8); list9.add(map9); } Object arre1[][] = new Object[listdataTime.size()][2]; Object arre2[][] = new Object[listdataTime.size()][2]; Object arre3[][] = new Object[listdataTime.size()][2]; Object arre4[][] = new Object[listdataTime.size()][2]; Object arre5[][] = new Object[listdataTime.size()][2]; Object arre6[][] = new Object[listdataTime.size()][2]; Object arre7[][] = new Object[listdataTime.size()][2]; Object arre8[][] = new Object[listdataTime.size()][2]; Object arre9[][] = new Object[listdataTime.size()][2]; if (ArrayUtils.contains(result, "I")) { for (int i = 0; i < listdataTime.size(); i++) { arre1[i][0] = listdataTime.get(i).get("dataTime"); arre1[i][1] = list1.get(i).get("Ia"); arre2[i][0] = listdataTime.get(i).get("dataTime"); arre2[i][1] = list2.get(i).get("Ib"); arre3[i][0] = listdataTime.get(i).get("dataTime"); arre3[i][1] = list3.get(i).get("Ic"); } mapIe1.put("name", "A相电流"); mapIe1.put("arr", arre1); mapIe2.put("name", "B相电流"); mapIe2.put("arr", arre2); mapIe3.put("name", "C相电流"); mapIe3.put("arr", arre3); list.add(mapIe1); list.add(mapIe2); list.add(mapIe3); } else if (ArrayUtils.contains(result, "P")) { for (int i = 0; i < listdataTime.size(); i++) { arre1[i][0] = listdataTime.get(i).get("dataTime"); arre1[i][1] = list1.get(i).get("P"); arre2[i][0] = listdataTime.get(i).get("dataTime"); arre2[i][1] = list2.get(i).get("Q"); arre3[i][0] = listdataTime.get(i).get("dataTime"); arre3[i][1] = list3.get(i).get("Pa"); arre4[i][0] = listdataTime.get(i).get("dataTime"); arre4[i][1] = list4.get(i).get("Pb"); arre5[i][0] = listdataTime.get(i).get("dataTime"); arre5[i][1] = list5.get(i).get("Pc"); arre6[i][0] = listdataTime.get(i).get("dataTime"); arre6[i][1] = list6.get(i).get("Qa"); arre7[i][0] = listdataTime.get(i).get("dataTime"); arre7[i][1] = list7.get(i).get("Qb"); arre8[i][0] = listdataTime.get(i).get("dataTime"); arre8[i][1] = list8.get(i).get("Qc"); arre9[i][0] = listdataTime.get(i).get("dataTime"); arre9[i][1] = list9.get(i).get("Demand"); } mapIe1.put("name", "总有功功率"); mapIe1.put("arr", arre1); mapIe2.put("name", "总无功功率"); mapIe2.put("arr", arre2); mapIe3.put("name", "A相有功功率"); mapIe3.put("arr", arre3); mapIe4.put("name", "B相有功功率"); mapIe4.put("arr", arre4); mapIe5.put("name", "C相有功功率"); mapIe5.put("arr", arre5); mapIe6.put("name", "A相无功功率"); mapIe6.put("arr", arre6); mapIe7.put("name", "B相无功功率"); mapIe7.put("arr", arre7); mapIe8.put("name", "C相无功功率"); mapIe8.put("arr", arre8); mapIe9.put("name", "实时需量"); mapIe9.put("arr", arre9); list.add(mapIe1); list.add(mapIe2); list.add(mapIe3); list.add(mapIe4); list.add(mapIe5); list.add(mapIe6); list.add(mapIe7); list.add(mapIe8); list.add(mapIe9); } else if (ArrayUtils.contains(result, "KWh")) { for (int i = 0; i < listdataTime.size(); i++) { arre1[i][0] = listdataTime.get(i).get("dataTime"); arre1[i][1] = list1.get(i).get("Epn"); arre2[i][0] = listdataTime.get(i).get("dataTime"); arre2[i][1] = list2.get(i).get("Epp"); arre3[i][0] = listdataTime.get(i).get("dataTime"); arre3[i][1] = list3.get(i).get("Eqn"); arre4[i][0] = listdataTime.get(i).get("dataTime"); arre4[i][1] = list4.get(i).get("Eqp"); } mapIe1.put("name", "负有功电度"); mapIe1.put("arr", arre1); mapIe2.put("name", "正有功电度"); mapIe2.put("arr", arre2); mapIe3.put("name", "负无功电度"); mapIe3.put("arr", arre3); mapIe4.put("name", "正无功电度"); mapIe4.put("arr", arre4); list.add(mapIe1); list.add(mapIe2); list.add(mapIe3); list.add(mapIe4); } else if (ArrayUtils.contains(result, "V")) { for (int i = 0; i < listdataTime.size(); i++) { arre1[i][0] = listdataTime.get(i).get("dataTime"); arre1[i][1] = list1.get(i).get("Ua"); arre2[i][0] = listdataTime.get(i).get("dataTime"); arre2[i][1] = list2.get(i).get("Ub"); arre3[i][0] = listdataTime.get(i).get("dataTime"); arre3[i][1] = list3.get(i).get("Uc"); arre4[i][0] = listdataTime.get(i).get("dataTime"); arre4[i][1] = list4.get(i).get("Uab"); arre5[i][0] = listdataTime.get(i).get("dataTime"); arre5[i][1] = list5.get(i).get("Ubc"); arre6[i][0] = listdataTime.get(i).get("dataTime"); arre6[i][1] = list6.get(i).get("Uca"); arre7[i][0] = listdataTime.get(i).get("dataTime"); arre7[i][1] = list7.get(i).get("Ul"); } mapIe1.put("name", "A相电压"); mapIe1.put("arr", arre1); mapIe2.put("name", "B相电压"); mapIe2.put("arr", arre2); mapIe3.put("name", "C相电压"); mapIe3.put("arr", arre3); mapIe4.put("name", "AB线电压"); mapIe4.put("arr", arre4); mapIe5.put("name", "BC线电压"); mapIe5.put("arr", arre5); mapIe6.put("name", "CA线电压"); mapIe6.put("arr", arre6); mapIe7.put("name", "回路电压"); mapIe7.put("arr", arre7); list.add(mapIe1); list.add(mapIe2); list.add(mapIe3); list.add(mapIe4); list.add(mapIe5); list.add(mapIe6); list.add(mapIe7); } else if (ArrayUtils.contains(result, "C")) { for (int i = 0; i < listdataTime.size(); i++) { arre1[i][0] = listdataTime.get(i).get("dataTime"); arre1[i][1] = list1.get(i).get("T1"); arre2[i][0] = listdataTime.get(i).get("dataTime"); arre2[i][1] = list2.get(i).get("T2"); arre3[i][0] = listdataTime.get(i).get("dataTime"); arre3[i][1] = list3.get(i).get("T3"); arre4[i][0] = listdataTime.get(i).get("dataTime"); arre4[i][1] = list4.get(i).get("T4"); arre5[i][0] = listdataTime.get(i).get("dataTime"); arre5[i][1] = list5.get(i).get("DeviceTemp"); } mapIe1.put("name", "外接温度1"); mapIe1.put("arr", arre1); mapIe2.put("name", "外接温度1"); mapIe2.put("arr", arre2); mapIe3.put("name", "外接温度1"); mapIe3.put("arr", arre3); mapIe4.put("name", "外接温度1"); mapIe4.put("arr", arre4); mapIe5.put("name", "环境温度"); mapIe5.put("arr", arre5); list.add(mapIe1); list.add(mapIe2); list.add(mapIe3); list.add(mapIe4); list.add(mapIe5); } else if (ArrayUtils.contains(result, "HZ")) { for (int i = 0; i < listdataTime.size(); i++) { arre1[i][0] = listdataTime.get(i).get("dataTime"); arre1[i][1] = list1.get(i).get("F"); } mapIe1.put("name", "频率"); mapIe1.put("arr", arre1); list.add(mapIe1); } else if (ArrayUtils.contains(result, "PS")) { for (int i = 0; i < listdataTime.size(); i++) { arre1[i][0] = listdataTime.get(i).get("dataTime"); arre1[i][1] = list1.get(i).get("COSa"); arre2[i][0] = listdataTime.get(i).get("dataTime"); arre2[i][1] = list2.get(i).get("COSb"); arre3[i][0] = listdataTime.get(i).get("dataTime"); arre3[i][1] = list3.get(i).get("COSc"); arre4[i][0] = listdataTime.get(i).get("dataTime"); arre4[i][1] = list4.get(i).get("COS"); } mapIe1.put("name", "A相功率因数"); mapIe1.put("arr", arre1); mapIe2.put("name", "B相功率因数"); mapIe2.put("arr", arre2); mapIe3.put("name", "C相功率因数"); mapIe3.put("arr", arre3); mapIe4.put("name", "功率因数"); mapIe4.put("arr", arre4); list.add(mapIe1); list.add(mapIe2); list.add(mapIe3); list.add(mapIe4); } else if (ArrayUtils.contains(result, "RMS")) { for (int i = 0; i < listdataTime.size(); i++) { arre1[i][0] = listdataTime.get(i).get("dataTime"); arre1[i][1] = list1.get(i).get("IHa"); arre2[i][0] = listdataTime.get(i).get("dataTime"); arre2[i][1] = list2.get(i).get("IHb"); arre3[i][0] = listdataTime.get(i).get("dataTime"); arre3[i][1] = list3.get(i).get("IHc"); } mapIe1.put("name", "Ia总谐波电流"); mapIe1.put("arr", arre1); mapIe2.put("name", "Ib总谐波电流"); mapIe2.put("arr", arre2); mapIe3.put("name", "Ic总谐波电流"); mapIe3.put("arr", arre3); list.add(mapIe1); list.add(mapIe2); list.add(mapIe3); } else if (ArrayUtils.contains(result, "DDB")) { for (int i = 0; i < listdataTime.size(); i++) { arre1[i][0] = listdataTime.get(i).get("dataTime"); arre1[i][1] = list1.get(i).get("SignalIntensity"); } mapIe1.put("name", "设备信号强度"); mapIe1.put("arr", arre1); list.add(mapIe1); } else if (ArrayUtils.contains(result, "VT")) { for (int i = 0; i < listdataTime.size(); i++) { arre1[i][0] = listdataTime.get(i).get("dataTime"); arre1[i][1] = list1.get(i).get("Upt"); arre2[i][0] = listdataTime.get(i).get("dataTime"); arre2[i][1] = list2.get(i).get("Udt"); arre3[i][0] = listdataTime.get(i).get("dataTime"); arre3[i][1] = list3.get(i).get("Ust"); } mapIe1.put("name", "电压暂升次数"); mapIe1.put("arr", arre1); mapIe2.put("name", "电压暂降次数"); mapIe2.put("arr", arre2); mapIe3.put("name", "电压中断次数"); mapIe3.put("arr", arre3); list.add(mapIe1); list.add(mapIe2); list.add(mapIe3); } } return list; } @Override public String DataReportExport(Integer siteId, Date startTime, Date endTime, String queryType) { DateFormat dFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒"); Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue(); Workbook workbook = null; File file = null; long diff = endTime.getTime() - startTime.getTime(); long days = diff / (1000 * 60 * 60); ExportParams params = new ExportParams("数据报表", "数据报表"); List page1 = null; if (days <= 24) { page1 = baseMapper.getDataReportMap(siteId, startTime, endTime); } else if (days < 360 && days > 24) { List device_list = baseMapper.getDeviceListMap(siteId); page1 = baseMapper.getDataReportMMap(device_list, startTime, endTime); } else if (days >= 360) { List device_list = baseMapper.getDeviceListMap(siteId); page1 = baseMapper.getDataReportDMap(device_list, startTime, endTime); } String[] result = queryType.split(","); try { List colList = new ArrayList(); ExcelExportEntity colEntity = new ExcelExportEntity("序号", "xh"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("时间", "dataTime"); colEntity.setNeedMerge(true); colList.add(colEntity); if (ArrayUtils.contains(result, "I")) { colEntity = new ExcelExportEntity("A相电流", "Ia"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("B相电流", "Ib"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("C相电流", "Ic"); colEntity.setNeedMerge(true); colList.add(colEntity); if (ArrayUtils.contains(result, "P")) { colEntity = new ExcelExportEntity("总有功功率", "P"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("总无功功率", "Q"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("A相有功功率", "Pa"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("B相有功功率", "Pb"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("C相有功功率", "Pc"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("A相无功功率", "Qa"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("B相无功功率", "Qb"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("C相无功功率", "Qc"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("实时需量", "Demand"); colEntity.setNeedMerge(true); colList.add(colEntity); if (ArrayUtils.contains(result, "KWh")) { colEntity = new ExcelExportEntity("负有功电度", "Epn"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("正有功电度", "Epp"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("负无功电度", "Eqn"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("正无功电度", "Eqp"); colEntity.setNeedMerge(true); colList.add(colEntity); if (ArrayUtils.contains(result, "V")) { colEntity = new ExcelExportEntity("A相电压", "Ua"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("B相电压", "Ub"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("C相电压", "Ub"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("AB线电压", "Uab"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("BC线电压", "Ubc"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("CA线电压", "Uca"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("回路电压", "Ul"); colEntity.setNeedMerge(true); colList.add(colEntity); if (ArrayUtils.contains(result, "C")) { colEntity = new ExcelExportEntity("外接温度1", "T1"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("外接温度2", "T2"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("外接温度3", "T3"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("外接温度4", "T4"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("环境温度", "DeviceTemp"); colEntity.setNeedMerge(true); colList.add(colEntity); if (ArrayUtils.contains(result, "HZ")) { colEntity = new ExcelExportEntity("频率", "F"); colEntity.setNeedMerge(true); colList.add(colEntity); // map.put("F",rtAnalogData.getF()); if (ArrayUtils.contains(result, "PS")) { colEntity = new ExcelExportEntity("A相功率因数", "COSa"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("B相功率因数", "COSb"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("C相功率因数", "COSc"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("功率因数", "COS"); colEntity.setNeedMerge(true); colList.add(colEntity); if (ArrayUtils.contains(result, "RMS")) { colEntity = new ExcelExportEntity("Ia总谐波电流", "IHa"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("Ib总谐波电流", "IHb"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("Ic总谐波电流", "IHc"); colEntity.setNeedMerge(true); colList.add(colEntity); if (ArrayUtils.contains(result, "DDB")) { colEntity = new ExcelExportEntity("设备信号强度", "SignalIntensity"); colEntity.setNeedMerge(true); colList.add(colEntity); if (ArrayUtils.contains(result, "VT")) { colEntity = new ExcelExportEntity("电压暂升次数", "Upt"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("电压暂降次数", "Udt"); colEntity.setNeedMerge(true); colList.add(colEntity); colEntity = new ExcelExportEntity("电压中断次数", "Ust"); colEntity.setNeedMerge(true); colList.add(colEntity); } } } } } } } } } } List> list = new ArrayList>(); for (int i = 0; i < page1.size(); i++) { Map valMap = new HashMap(); valMap.put("xh", i + 1); if (days <= 24) { valMap.put("dataTime", DateUtils.format(page1.get(i).getDataTime(), "MM-dd HH:mm")); } else if (days < 360 && days > 24) { valMap.put("dataTime", DateUtils.format(page1.get(i).getDataTime(), "MM-dd HH:mm")); } else if (days >= 360) { valMap.put("dataTime", DateUtils.format(page1.get(i).getDataTime(), DateUtils.PARSE_PATTERNS[8])); } if (ArrayUtils.contains(result, "I")) { valMap.put("Ia", page1.get(i).getIa()); valMap.put("Ib", page1.get(i).getIb()); valMap.put("Ic", page1.get(i).getIc()); if (ArrayUtils.contains(result, "P")) { valMap.put("P", page1.get(i).getP()); valMap.put("Q", page1.get(i).getQ()); valMap.put("Pa", page1.get(i).getPa()); valMap.put("Pb", page1.get(i).getPb()); valMap.put("Pc", page1.get(i).getPc()); valMap.put("Qa", page1.get(i).getQa()); valMap.put("Qb", page1.get(i).getQb()); valMap.put("Qc", page1.get(i).getQc()); valMap.put("Demand", page1.get(i).getDemand()); if (ArrayUtils.contains(result, "KWh")) { valMap.put("Epn", page1.get(i).getEpn()); valMap.put("Epp", page1.get(i).getEpp()); valMap.put("Eqn", page1.get(i).getEqn()); valMap.put("Eqp", page1.get(i).getEqp()); if (ArrayUtils.contains(result, "V")) { valMap.put("Ua", page1.get(i).getUa()); valMap.put("Ub", page1.get(i).getUb()); valMap.put("Uc", page1.get(i).getUc()); valMap.put("Uab", page1.get(i).getUab()); valMap.put("Ubc", page1.get(i).getUbc()); valMap.put("Uca", page1.get(i).getUca()); valMap.put("Ul", page1.get(i).getUl()); if (ArrayUtils.contains(result, "C")) { valMap.put("T1", page1.get(i).getT1()); valMap.put("T2", page1.get(i).getT2()); valMap.put("T3", page1.get(i).getT3()); valMap.put("T4", page1.get(i).getT4()); valMap.put("DeviceTemp", page1.get(i).getDeviceTemp()); if (ArrayUtils.contains(result, "HZ")) { valMap.put("F", page1.get(i).getF()); if (ArrayUtils.contains(result, "PS")) { valMap.put("COSa", page1.get(i).getCOSa()); valMap.put("COSb", page1.get(i).getCOSb()); valMap.put("COSc", page1.get(i).getCOSc()); valMap.put("COS", page1.get(i).getCos()); if (ArrayUtils.contains(result, "RMS")) { valMap.put("IHa", page1.get(i).getIHa()); valMap.put("IHb", page1.get(i).getIHb()); valMap.put("IHc", page1.get(i).getIHc()); if (ArrayUtils.contains(result, "DDB")) { valMap.put("SignalIntensity", page1.get(i).getSignalIntensity()); if (ArrayUtils.contains(result, "VT")) { valMap.put("Upt", page1.get(i).getUpt()); valMap.put("Udt", page1.get(i).getUdt()); valMap.put("Ust", page1.get(i).getUst()); } } } } } } } } } } list.add(valMap); } workbook = ExcelExportUtil.exportExcel(params, colList, list); 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 (FileNotFoundException e) { log.error("导出文件失败", e); throw new BusinessException("导出文件失败"); } catch (IOException e) { e.printStackTrace(); } return file.getName(); } public static Date getLastDayOfMonth(Date sDate1) { Calendar cDay1 = Calendar.getInstance(); cDay1.setTime(sDate1); final int lastDay = cDay1.getActualMaximum(Calendar.DAY_OF_MONTH); Date lastDate = cDay1.getTime(); lastDate.setDate(lastDay); return lastDate; } @Override public List 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 = baseMapper.evaluationReportList(siteId, startTime, endtime); return fillRealScoreDataTwo(evaluationReporVo); } /** * 计算电压分数2 * * @return */ public Boolean computeUScoreOne(Double qualified, Double voltageLevel) { // double mul = Arith.mul(qualified, voltageLevel); Double voltageLevels = voltageLevel+(voltageLevel / 100 * 7); Double voltageLevelx = voltageLevel-(voltageLevel / 100 * 7); if (voltageLevelx <= qualified && voltageLevels >= qualified) { return true; } return false; } @Override public List fillRealScoreDataTwo(List evaluationReporVo) { List realScoreVoList = new ArrayList<>(); if (evaluationReporVo.size() > 0) { for (int i = 0; i < evaluationReporVo.size(); i++) { List checkList = new ArrayList<>(); Integer score = 0; RealScoreVO realScoreVo = BeanMapperUtils.map(evaluationReporVo.get(i), RealScoreVO.class); if (null == realScoreVo.getCos()) { realScoreVo.setCos(0.00); } checkList.clear(); checkList.add(realScoreVo.getIa()); checkList.add(realScoreVo.getIb()); checkList.add(realScoreVo.getIc()); //电流不平衡 realScoreVo.setElBalun(checkBalun(checkList)); checkList.clear(); checkList.add(realScoreVo.getUa()); checkList.add(realScoreVo.getUb()); checkList.add(realScoreVo.getUc()); //电压不平衡 realScoreVo.setVtBalun(checkBalun(checkList)); //电压合格率 double voltageLevel = Double.parseDouble(evaluationReporVo.get(i).getVoltageLevel()); realScoreVo.setUaQualified(Arith.sub(evaluationReporVo.get(i).getUa(), voltageLevel)); realScoreVo.setUbQualified(Arith.sub(evaluationReporVo.get(i).getUb(), voltageLevel)); realScoreVo.setUcQualified(Arith.sub(evaluationReporVo.get(i).getUc(), voltageLevel)); //电流负载率 Double ratedCurrent = evaluationReporVo.get(i).getRatedCurrent(); realScoreVo.setIaLoad(Arith.div(realScoreVo.getIa(), ratedCurrent)); realScoreVo.setIbLoad(Arith.div(realScoreVo.getIb(), ratedCurrent)); realScoreVo.setIcLoad(Arith.div(realScoreVo.getIc(), ratedCurrent)); //计算分数 //电压分数 realScoreVo.setUaQ(computeUScoreOne(realScoreVo.getUaQualified(), voltageLevel)); realScoreVo.setUbQ(computeUScoreOne(realScoreVo.getUbQualified(), voltageLevel)); realScoreVo.setUcQ(computeUScoreOne(realScoreVo.getUcQualified(), voltageLevel)); if (realScoreVo.getUaQ() && realScoreVo.getUbQ() && realScoreVo.getUcQ()) { realScoreVo.setUQ(true); score += 20; } else { realScoreVo.setUQ(false); } //电流分数 realScoreVo.setIaLoadQ(realScoreVo.getIaLoad() <= 0.8); realScoreVo.setIbLoadQ(realScoreVo.getIbLoad() <= 0.8); realScoreVo.setIcLoadQ(realScoreVo.getIcLoad() <= 0.8); if (realScoreVo.getIaLoadQ() && realScoreVo.getIbLoadQ() && realScoreVo.getIcLoadQ()) { realScoreVo.setILoadQ(true); score += 20; } else { realScoreVo.setILoadQ(false); } //电压平衡分数 realScoreVo.setElBalunQ(realScoreVo.getElBalun() <= 0.15); if (realScoreVo.getElBalunQ()) { score += 20; } //电流平衡分数 realScoreVo.setVtBalunQ(realScoreVo.getVtBalun() <= 0.15); if (realScoreVo.getVtBalunQ()) { score += 20; } //功率 realScoreVo.setCosQ(realScoreVo.getCos() <= 0.15); if (realScoreVo.getCosQ()) { score += 20; } realScoreVo.setScore(score); realScoreVoList.add(realScoreVo); } } return realScoreVoList; } // @Override // public String DataReportExport(Integer siteId,Date startTime, Date endTime,String queryType){ // Integer userId = UserUtil.getUserId(); // Workbook workbook = null; // File file = null; // long diff = endTime.getTime() - startTime.getTime(); // long days = diff / (1000 * 60 * 60); // try { // ExportParams params = new ExportParams(null, "数据报表"); // workbook = ExcelExportUtil.exportBigExcel(params, HtAnalogDataExportVO.class, // (o, i) -> { // Page page = new Page<>(i, 30); // if (days<=24){ // page = baseMapper.getDataReportMap1(page,siteId, startTime, endTime); // }else if (days<360&&days>24){ // List device_list = baseMapper.getDeviceListMap(siteId); // page = baseMapper.getDataReportMMap1(page,device_list,startTime, endTime); // }else if (days>=360){ // List device_list = baseMapper.getDeviceListMap(siteId); // page = baseMapper.getDataReportDMap1(page,device_list,startTime, endTime); // } // // return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), HtAnalogData.class, HtAnalogDataExportVO.class)); // },null); // if (null != workbook) { // file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "数据报表", 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(); // } }