| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalTime; |
| | | import java.util.*; |
| | | import java.util.concurrent.CountDownLatch; |
| | | import java.util.concurrent.ThreadPoolExecutor; |
| | |
| | | private BatttestdataIdService battTestDataIdService; |
| | | |
| | | |
| | | |
| | | public Response getAll(Integer userId) { |
| | | Response response = new Response(); |
| | | Map<String,Object> map = new HashMap<>(); |
| | |
| | | testDataInfoStatistics(userId, map); |
| | | latch.countDown(); |
| | | }); |
| | | //TODO 设备数量信息统计 |
| | | //10类基础资产信息统计 |
| | | poolExecutor.execute(() -> { |
| | | //deviceInfoStatistics(userId, map); |
| | | deviceInfoStatistics(userId, map); |
| | | latch.countDown(); |
| | | }); |
| | | |
| | |
| | | |
| | | return response; |
| | | } |
| | | |
| | | private void deviceInfoStatistics(Integer userId, Map<String, Object> map) { |
| | | NameValueIntDto baseDto = new NameValueIntDto(); |
| | | int powerCount = powerInfService.getListByUserId(userId).size(); |
| | | map.put("powerCount", powerCount); |
| | | List<BattInf> battInfList = battInfService.getListByUserId(userId); |
| | | int battCount = battInfList.size(); |
| | | Map<Integer, List<BattInf>> devIdMap = battInfList.stream().collect(Collectors.groupingBy(BattInf::getDevId)); |
| | | map.put("devCount", devIdMap.size()); |
| | | map.put("battCount",battCount); |
| | | int monCountTotal = 0; |
| | | for (int i = 0; i < battCount; i++) { |
| | | int monCount = battInfList.get(i).getMoncount().intValue(); |
| | | monCountTotal += monCount; |
| | | } |
| | | map.put("monCount", monCountTotal); |
| | | |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | //本年第一天 |
| | | LocalDateTime yearStart = now.withDayOfYear(1).withHour(0).withMinute(0).withSecond(0).withNano(0); |
| | | Date yearStartTime = DateUtil.convertToDate(yearStart); |
| | | //去年的第一天 |
| | | LocalDateTime lastYearStart = now.minusYears(1).withDayOfYear(1).withHour(0).withMinute(0).withSecond(0).withNano(0); |
| | | //去年的最后一天 |
| | | int lastYear = now.minusYears(1).getYear(); |
| | | LocalDate lastDayOfLastYear = LocalDate.of(lastYear, 12, 31); |
| | | LocalDateTime lastYearEnd = lastDayOfLastYear.atTime(LocalTime.MAX); |
| | | Date lastYearStartTime = DateUtil.convertToDate(lastYearStart); |
| | | Date lastYearEndTime = DateUtil.convertToDate(lastYearEnd); |
| | | |
| | | //本年已放电电池数量 |
| | | //本年未放电电池数量 |
| | | //去年已放电电池数量 |
| | | //去年未放电电池数量 |
| | | int hrDisBattCount = battTestDataInfService.getHrDisCount(userId,yearStartTime,null); |
| | | int hrNoDisBattCount = battCount - hrDisBattCount; |
| | | int hrDisBattCountLastYear = battTestDataInfService.getHrDisCount(userId,lastYearStartTime,lastYearEndTime); |
| | | int hrNoDisBattCountLastYear = battCount - hrDisBattCountLastYear; |
| | | map.put("hrDisBattCount", hrDisBattCount); |
| | | map.put("hrNoDisBattCount", hrNoDisBattCount); |
| | | map.put("hrDisBattCountLastYear", hrDisBattCountLastYear); |
| | | map.put("hrNoDisBattCountLastYear", hrNoDisBattCountLastYear); |
| | | |
| | | //本年优良劣化损坏数量 |
| | | List<BattCapInfoDto> battCapInfoList = getBattCapInfo(battInfList,yearStartTime,null); |
| | | long battGoodCount = battCapInfoList.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_1.getStateName())).count(); |
| | | long battBadCount = battCapInfoList.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_2.getStateName())).count(); |
| | | long battDamageCount = battCapInfoList.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_3.getStateName())).count(); |
| | | //去年优良劣化损坏数量 |
| | | List<BattCapInfoDto> battCapInfoListLastYear = getBattCapInfo(battInfList,lastYearStartTime,lastYearEndTime); |
| | | long battGoodCountLastYear = battCapInfoListLastYear.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_1.getStateName())).count(); |
| | | long battBadCountLastYear = battCapInfoListLastYear.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_2.getStateName())).count(); |
| | | long battDamageCountLastYear = battCapInfoListLastYear.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_3.getStateName())).count(); |
| | | map.put("battGoodCount", battGoodCount); |
| | | map.put("battBadCount", battBadCount); |
| | | map.put("battDamageCount", battDamageCount); |
| | | map.put("battGoodCountLastYear", battGoodCountLastYear); |
| | | map.put("battBadCountLastYear", battBadCountLastYear); |
| | | map.put("battDamageCountLastYear", battDamageCountLastYear); |
| | | //TODO 优良电源数量 |
| | | map.put("powerGoodCount","优良判定标准待确定" ); |
| | | } |
| | | |
| | | |
| | | private void alarmRealtimeStatistics(Integer userId, Map<String, Object> map) { |
| | | //电池告警信息统计 |
| | |
| | | battInf.setProduct(brand); |
| | | //查询满足条件的蓄电池列表 |
| | | List<BattInf> battInfList = battInfService.getListByCondition(userId,battInf); |
| | | List<BattCapInfoDto> battCapInfoList = getBattCapInfo(battInfList); |
| | | List<BattCapInfoDto> battCapInfoList = getBattCapInfo(battInfList,null,null); |
| | | //data,和data2分别返回 统计数量和 站点优良,劣化,损坏 前二的信息 |
| | | List<NameValueIntDto> data = new ArrayList<>(); |
| | | List<NameValueListDto> data2 = new ArrayList<>(); |
| | |
| | | battInf.setInuseTime(inuseTimeStart); |
| | | //查询满足条件的蓄电池列表 |
| | | List<BattInf> battInfList = battInfService.getListByCondition(userId,battInf); |
| | | List<BattCapInfoDto> battCapInfoList = getBattCapInfo(battInfList); |
| | | List<BattCapInfoDto> battCapInfoList = getBattCapInfo(battInfList,null,null); |
| | | |
| | | //data,根据品牌分组统计百分比 |
| | | Map<String, List<BattCapInfoDto>> brandMap = battCapInfoList.stream().collect(Collectors.groupingBy(BattCapInfoDto::getProduct)); |
| | |
| | | battInf.setProduct(brand); |
| | | //查询满足条件的蓄电池列表 |
| | | List<BattInf> battInfList = battInfService.getListByCondition(userId,battInf); |
| | | List<BattCapInfoDto> battCapInfoList = getBattCapInfo(battInfList); |
| | | List<BattCapInfoDto> battCapInfoList = getBattCapInfo(battInfList,null,null); |
| | | |
| | | //data,TODO 投运时间的维度参数,先固定变量,后续从数据库获取 |
| | | //time1和time2的单位为年 |
| | |
| | | |
| | | } |
| | | |
| | | public List<BattCapInfoDto> getBattCapInfo(List<BattInf> battInfList) { |
| | | public List<BattCapInfoDto> getBattCapInfo(List<BattInf> battInfList,Date startTime, Date endTime) { |
| | | //获取核容优劣,损坏参数 |
| | | List<AppParam> paramList=appParamService.getHrParam(); |
| | | Float badValue=0f; |
| | |
| | | capInfo.setInuseTime(battInf.getInuseTime()); |
| | | |
| | | //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) |
| | | BatttestdataInf testInf = battTestDataInfService.getLastStandardTestDataByTime(battInf.getBattgroupId(), battInf.getInuseTime(),null); |
| | | //BatttestdataInf testInf = battTestDataInfService.getLastStandardTestDataByTime(battInf.getBattgroupId(), battInf.getInuseTime(),null); |
| | | BatttestdataInf testInf = battTestDataInfService.getLastStandardTestDataByTime(battInf.getBattgroupId(), startTime,endTime); |
| | | if (testInf == null) { |
| | | capInfo.setRealCap(0f); |
| | | capInfo.setCapPercentage("0"); |