1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474 |
- 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.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<HtAnalogDataMapper, HtAnalogData> implements HtAnalogDataService {
- @Autowired
- private HadSiteStaticService hadSiteStaticService;
- @Autowired
- private RtAnalogDataService rtAnalogDataService;
- @Autowired
- private DeviceService deviceService;
- @Autowired
- private SiteDynamicPropertiesService siteDynamicPropertiesService;
- @Autowired
- private DeviceAttributeService deviceAttributeService;
- @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<CommonIcoVO> 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<CommonIcoVO> 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<HadSiteStatic> list = hadSiteStaticService.list(null, startTime, endTime, userId);
- List<Object> objects = new ArrayList<>();
- objects.add(0.0);
- List<Object> 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<Double> dataList = (List<Double>) 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<Object> objects = new ArrayList<>();
- objects.add(0.0);
- List<Object> 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<CommonIcoVO> selectTrendByMonth() {
- Date date = new Date();
- Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
- List<CommonIcoVO> 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<Object> objects = new ArrayList<>();
- List<Object> 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> 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<HadSiteStatic> 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<CommonIcoVO> getDemandIco(Integer siteId) {
- Date date = new Date();
- List<Object> maxList = new ArrayList<>();
- List<Object> minList = new ArrayList<>();
- List<Object> avgList = new ArrayList<>();
- List<Object> dateList = new ArrayList<>();
- List<HadSiteStatic> 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<CommonIcoVO> 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<CommonIcoVO> getElectricIco(Integer siteId, Date date) {
- List<Object> iaList = new ArrayList<>();
- iaList.add(0.00);
- List<Object> ibList = new ArrayList<>();
- ibList.add(0.00);
- List<Object> icList = new ArrayList<>();
- icList.add(0.00);
- List<Object> uaList = new ArrayList<>();
- uaList.add(0.00);
- List<Object> ubList = new ArrayList<>();
- ubList.add(0.00);
- List<Object> ucList = new ArrayList<>();
- ucList.add(0.00);
- List<Object> dateList = new ArrayList<>();
- dateList.add("00:00:00");
- HadSiteStatic hadSiteStatic = hadSiteStaticService.oneBySite(siteId, date, date);
- List<HtAnalogData> htList = Optional.ofNullable(hadSiteStatic)
- .map(HadSiteStatic::getHisIco)
- .map(his -> JsonUtils.fromJson(hadSiteStatic.getHisIco(), new TypeReference<List<HtAnalogData>>() {
- }))
- .orElse(null);
- for (int i = 2; i < 24; i += 2) {
- Date hours = DateUtils.setHours(date, i);
- date = hours;
- Date finalDate = date;
- Optional<HtAnalogData> 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<CommonIcoVO> 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<RealScoreVO> rtRealScore(String deviceCode, Date startTime, Date endTime) {
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- //查询设备
- LambdaQueryWrapper<Device> 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<HtAnalogData> list = baseMapper.getDemandAnalysisList(deviceCode, formatter.format(startTime), formatter.format(endTime), table);
- //查询sd
- LambdaQueryWrapper<SiteDynamicProperties> sdQuery = Wrappers.lambdaQuery();
- sdQuery.eq(SiteDynamicProperties::getSiteId, device.getSiteId());
- SiteDynamicProperties siteDynamicProperties = siteDynamicPropertiesService.getOne(sdQuery);
- Optional.ofNullable(siteDynamicProperties).orElseThrow(() -> new BusinessException("sd不存在"));
- LambdaQueryWrapper<DeviceAttribute> adQuery = Wrappers.lambdaQuery();
- adQuery.eq(DeviceAttribute::getSiteId, device.getSiteId());
- List<DeviceAttribute> deviceAttributes = deviceAttributeService.list(adQuery);
- if (CollectionUtils.isEmpty(deviceAttributes)) {
- throw new BusinessException("da不存在");
- }
- DeviceAttribute deviceAttribute = deviceAttributes.stream().min(Comparator.comparing(DeviceAttribute::getId)).get();
- List<RealScoreVO> 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<RealScoreVO> rtRealScore(String deviceCode, Date startTime, Date endTime) {
- // LambdaQueryWrapper<HtAnalogData> 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<HtAnalogData> list = this.list(queryWrapper);
- // //查询设备
- // LambdaQueryWrapper<Device> deviceQuery = Wrappers.lambdaQuery();
- // deviceQuery.eq(Device::getDeviceCode, deviceCode);
- // Device device = deviceService.getOne(deviceQuery);
- // Optional.ofNullable(device).orElseThrow(() -> new BusinessException("设备不存在"));
- // //查询sd
- // LambdaQueryWrapper<SiteDynamicProperties> sdQuery = Wrappers.lambdaQuery();
- // sdQuery.eq(SiteDynamicProperties::getSiteId, device.getSiteId());
- // SiteDynamicProperties siteDynamicProperties = siteDynamicPropertiesService.getOne(sdQuery);
- // Optional.ofNullable(siteDynamicProperties).orElseThrow(() -> new BusinessException("sd不存在"));
- // LambdaQueryWrapper<DeviceAttribute> adQuery = Wrappers.lambdaQuery();
- // adQuery.eq(DeviceAttribute::getSiteId, device.getSiteId());
- // List<DeviceAttribute> deviceAttributes = deviceAttributeService.list(adQuery);
- // if (CollectionUtils.isEmpty(deviceAttributes)) {
- // throw new BusinessException("da不存在");
- // }
- // DeviceAttribute deviceAttribute = deviceAttributes.stream().min(Comparator.comparing(DeviceAttribute::getId)).get();
- // List<RealScoreVO> 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<CommonIcoVO> yearOnYearList(DataManagementOneVO dataManagementOneVO) {
- List<DataManagementVO> dataManagementVOList = new ArrayList<>();
- List<String> newListOne = new ArrayList<>();
- List<String> newListTwo = new ArrayList<>();
- List<String> newListThree = new ArrayList<>();
- List<DeviceAnalogVariableList> variableCodingList = new LinkedList<>();
- List<String> 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<DataManagementVO> newList = new ArrayList();
- set.addAll(dataManagementVOList);
- newList.addAll(set);
- //显示的字段名
- Set set1 = new HashSet();
- List<String> list = new ArrayList();
- set1.addAll(newListOne);
- list.addAll(set1);
- //监控ID
- Set set2 = new HashSet();
- List<String> monitor_list = new ArrayList();
- set2.addAll(newListTwo);
- monitor_list.addAll(set2);
- //查询字段
- Set set3 = new HashSet();
- List<String> fieldDisplayOne = new ArrayList();
- set3.addAll(fieldDisplay);
- fieldDisplayOne.addAll(set3);
- List<String> fieldDisplayOne183 = new ArrayList();
- List<String> fieldDisplayOne171 = new ArrayList();
- List<String> fieldDisplayOne173 = new ArrayList();
- List<Device> 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<ContextualDataVo> yearOnYearList1 = new ArrayList<>();
- List<ContextualDataVo> yearOnYearList2 = new ArrayList<>();
- List<ContextualDataVo> yearOnYearList3 = new ArrayList<>();
- if (fieldDisplayOne183.size() > 0) {
- List<String> 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<String> 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<String> fieldDisplayList = FieldEscapeUtils.getSyllable(type, valueCalculation, fieldDisplayOne173);
- yearOnYearList3 = baseMapper.getYearOnYearThree(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList, fieldDisplayList, "ht_analog_173_data", 0,type);
- }
- List<ContextualDataVo> yearOnYearList4 = Stream.of(yearOnYearList1, yearOnYearList2).flatMap(Collection::stream).distinct().collect(Collectors.toList());
- List<ContextualDataVo> yearOnYearList = Stream.of(yearOnYearList3, yearOnYearList4).flatMap(Collection::stream).distinct().collect(Collectors.toList());
- FieldEscapeUtils.remove1(list);
- List<CommonIcoVO> 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<Object> data = new ArrayList<>();
- String name = null;
- List<Object> 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<CommonIcoVO> yearOnYearList(DataManagementOneVO dataManagementOneVO) {
- // List<HtAnalogDataVo> yearOnYearList = null;
- // List<DataManagementVO> dataManagementVOList = new ArrayList<>();
- // List<String> newListOne = new ArrayList<>();
- // List<String> newListTwo = new ArrayList<>();
- // List<String> newListThree = new ArrayList<>();
- // List<DeviceAnalogVariableList> variableCodingList = new LinkedList<>();
- // List<String> 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<DataManagementVO> newList = new ArrayList();
- // set.addAll(dataManagementVOList);
- // newList.addAll(set);
- //
- // //通信设备编号
- // Set set1 = new HashSet();
- // List<String> list = new ArrayList();
- // set1.addAll(newListOne);
- // list.addAll(set1);
- //
- // //显示的字段名
- // Set set2 = new HashSet();
- // List<String> monitor_list = new ArrayList();
- // set2.addAll(newListTwo);
- // monitor_list.addAll(set2);
- //
- // //查询字段
- // Set set3 = new HashSet();
- // List<String> 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<CommonIcoVO> 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<Object> data = new ArrayList<>();
- // String name = null;
- // List<Object> 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<CommonIcoVO> ringRatioList(DataManagementOneVO dataManagementOneVO) {
- List<DataManagementVO> dataManagementVOList = new ArrayList<>();
- List<String> newListOne = new ArrayList<>();
- List<String> newListTwo = new ArrayList<>();
- List<String> newListThree = new ArrayList<>();
- List<String> fieldDisplay = new ArrayList<>();
- Integer type = dataManagementOneVO.getType();
- Integer valueCalculation = dataManagementOneVO.getValueCalculation();
- newListOne.add("dataTime");
- List<DeviceAnalogVariableList> 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<DataManagementVO> newList = new ArrayList();
- set.addAll(dataManagementVOList);
- newList.addAll(set);
- Set set1 = new HashSet();
- List<String> list = new ArrayList();
- set1.addAll(newListOne);
- list.addAll(set1);
- Set set2 = new HashSet();
- List<String> monitor_list = new ArrayList();
- set2.addAll(newListTwo);
- monitor_list.addAll(set2);
- Set set3 = new HashSet();
- List<String> fieldDisplayOne = new ArrayList();
- set3.addAll(fieldDisplay);
- fieldDisplayOne.addAll(set3);
- List<String> fieldDisplayOne183 = new ArrayList();
- List<String> fieldDisplayOne171 = new ArrayList();
- List<String> fieldDisplayOne173 = new ArrayList();
- List<Device> 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<ContextualDataVo> yearOnYearList1 = new ArrayList<>();
- List<ContextualDataVo> yearOnYearList2 = new ArrayList<>();
- List<ContextualDataVo> yearOnYearList3 = new ArrayList<>();
- if (fieldDisplayOne183.size() > 0) {
- List<String> 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<String> 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<String> fieldDisplayList = FieldEscapeUtils.getSyllable(type, valueCalculation, fieldDisplayOne173);
- yearOnYearList3 = baseMapper.getYearOnYearThree(newList, dataManagementOneVO.getStartTime(), dataManagementOneVO.getEndTime(), variableCodingList, fieldDisplayList, "ht_analog_173_data", 0,type);
- }
- List<ContextualDataVo> yearOnYearList4 = Stream.of(yearOnYearList1, yearOnYearList2).flatMap(Collection::stream).distinct().collect(Collectors.toList());
- List<ContextualDataVo> currentPeriodRingRatioList = Stream.of(yearOnYearList3, yearOnYearList4).flatMap(Collection::stream).distinct().collect(Collectors.toList());
- FieldEscapeUtils.remove1(list);
- List<CommonIcoVO> 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<Object> data = new ArrayList<>();
- String name = null;
- List<Object> 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<CommonIcoVO> ringRatioList(DataManagementOneVO dataManagementOneVO) {
- // List<HtAnalogDataVo> currentPeriodRingRatioList = null;
- //// List<HtAnalogDataVo> lastPeriodRingRatioList = null;
- // List<DataManagementVO> dataManagementVOList = new ArrayList<>();
- // List<String> newListOne = new ArrayList<>();
- // List<String> newListTwo = new ArrayList<>();
- // List<String> newListThree = new ArrayList<>();
- // List<String> fieldDisplay = new ArrayList<>();
- // newListOne.add("dataTime");
- // List<DeviceAnalogVariableList> 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<DataManagementVO> newList = new ArrayList();
- // set.addAll(dataManagementVOList);
- // newList.addAll(set);
- //
- // Set set1 = new HashSet();
- // List<String> list = new ArrayList();
- // set1.addAll(newListOne);
- // list.addAll(set1);
- //
- // Set set2 = new HashSet();
- // List<String> monitor_list = new ArrayList();
- // set2.addAll(newListTwo);
- // monitor_list.addAll(set2);
- //
- // Set set3 = new HashSet();
- // List<String> 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<CommonIcoVO> 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<Object> data = new ArrayList<>();
- // String name = null;
- // List<Object> 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<CommonIcoVO> monthlyReport(String deviceCode, int cycle, String startTime, String endTime) {
- List<Object> eppList = new ArrayList<>();
- List<Object> freezingTimesList = new ArrayList<>();
- LambdaQueryWrapper<Device> queryWrapper = Wrappers.lambdaQuery();
- queryWrapper.eq(Device::getDeviceCode, deviceCode);
- List<Device> 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<HtAnalogDataVo> maxMonthlyReport = baseMapper.getEnergyUseList(deviceCode, startTime, endTime, cycle, 1, table);
- List<HtAnalogDataVo> 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<CommonIcoVO> list = new ArrayList<>();
- list.add(CommonIcoVO.builder().name("电量").list(eppList).listDate(freezingTimesList).build());
- return list;
- }
- // public List<CommonIcoVO> monthlyReport(String deviceCode, int cycle, String startTime, String endTime) {
- // List<Object> eppList = new ArrayList<>();
- // List<Object> freezingTimesList = new ArrayList<>();
- // List<HtAnalogDataVo> maxMonthlyReport = baseMapper.energyUseList(deviceCode, startTime, endTime, cycle, 1);
- // List<HtAnalogDataVo> 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<CommonIcoVO> list = new ArrayList<>();
- // list.add(CommonIcoVO.builder().name("电量").list(eppList).listDate(freezingTimesList).build());
- // return list;
- // }
- @Override
- public List<CommonIcoVO> 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";
- LambdaQueryWrapper<Device> queryWrapper1 = Wrappers.lambdaQuery();
- queryWrapper1.eq(Device::getDeviceCode, deviceCode);
- List<Device> 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";
- } else {
- throw new BusinessException("173用电设备无用电数据采集");
- }
- } else {
- throw new BusinessException("错误数据,设备不存在");
- }
- List<HtAnalogData> list1 = baseMapper.getDemandAnalysisList(deviceCode, date1, date2, table);
- List<Object> demandList = new ArrayList<>();
- List<Object> 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<CommonIcoVO> list = new ArrayList<>();
- list.add(CommonIcoVO.builder().name("实时有功需量").list(demandList).listDate(freezingTimesList).build());
- return list;
- }
- // public List<CommonIcoVO> 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<HtAnalogData> queryWrapper = Wrappers.lambdaQuery();
- // queryWrapper.select(HtAnalogData::getDemand, HtAnalogData::getFreezingTime)
- // .eq(HtAnalogData::getDeviceName, deviceCode)
- // .between(HtAnalogData::getFreezingTime, startTime, endTime)
- // .groupBy(HtAnalogData::getFreezingTime);
- // List<HtAnalogData> list1 = this.list(queryWrapper);
- // List<Object> demandList = new ArrayList<>();
- // List<Object> 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<Object> demandList = new ArrayList<>();
- //// List<Object> freezingTimesList = new ArrayList<>();
- //// List<HtAnalogDataVo> 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<CommonIcoVO> 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<HtAnalogDataOneVo> 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<HtAnalogDataOneVo> monthlyReportlist(String deviceCode, String startTime, String endTime, int cycle, Integer startCurrent) {
- List<HtAnalogDataOneVo> listOne = new ArrayList<>();
- LambdaQueryWrapper<Device> queryWrapper = Wrappers.lambdaQuery();
- queryWrapper.eq(Device::getDeviceCode, deviceCode);
- List<Device> 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<HtAnalogDataOneVo> maxMonthlyReport = baseMapper.getEnergyUseListOne(deviceCode, startTime, endTime, cycle, 1, 10000, startCurrent, table);
- List<HtAnalogDataOneVo> 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<Device> queryWrapper = Wrappers.lambdaQuery();
- queryWrapper.eq(Device::getDeviceCode, deviceCode);
- List<Device> 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<SingleLoopReportVo> SingleLoopReportList = baseMapper.getSingleLoopReportData(deviceCode, startTime, endtime, table);
- if (CollectionUtils.isEmpty(SingleLoopReportList)) {
- SingleLoopReportOneVo singleLoopReportOneVo = new SingleLoopReportOneVo();
- return singleLoopReportOneVo;
- }
- List<HtAnalogData> 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<SingleLoopReportVo> SingleLoopReportList = baseMapper.SingleLoopReportData(deviceCode, startTime, endtime);
- // if (CollectionUtils.isEmpty(SingleLoopReportList)) {
- // SingleLoopReportOneVo singleLoopReportOneVo = null;
- // return singleLoopReportOneVo;
- //// throw new BusinessException("暂无数据");
- // }
- // LambdaQueryWrapper<HtAnalogData> adQuery = Wrappers.lambdaQuery();
- // adQuery.eq(HtAnalogData::getDeviceName, deviceCode)
- // .between(HtAnalogData::getDataTime, startTime, endtime);
- // List<HtAnalogData> RtAnalogDataList = this.list(adQuery);
- // if (CollectionUtils.isEmpty(RtAnalogDataList)) {
- // throw new BusinessException("da不存在");
- // }
- //
- //
- // return analysisCalculation(SingleLoopReportList, RtAnalogDataList);
- // }
- public SingleLoopReportOneVo analysisCalculation(List<SingleLoopReportVo> SingleLoopReportList, List<HtAnalogData> RtAnalogDataList) {
- DecimalFormat df = new DecimalFormat("######0.00");
- List<Double> 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<Double> 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<Double> 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);
- }
- }
|