| | |
| | | @Autowired |
| | | private PlatformLogMapper platformLogMapper; |
| | | @Autowired |
| | | private PlatformWaterGasMapper platformWaterGasMapper; |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Autowired |
| | | private PlatformWarnEventMapper platformWarnEventMapper; |
| | |
| | | return null; |
| | | } |
| | | @Override |
| | | public List<EnergyDataVO> loadEnergyCurve(){ |
| | | List<EnergyDataVO> loadCurveList = new ArrayList<>(); |
| | | try { |
| | | BaseResponse<List<EnergyTodayLoadDataResponse>> response = HKService.energyTodayLoadData(); |
| | | if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) || response.getData()==null ){ |
| | | for (EnergyTodayLoadDataResponse model :response.getData()) { |
| | | EnergyDataVO data = new EnergyDataVO(); |
| | | data.setTimeData(model.getName()); |
| | | data.setEnergy(new BigDecimal(model.getName())); |
| | | loadCurveList.add(data); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return loadCurveList; |
| | | } |
| | | @Override |
| | | public List<OilDataVO> energyLastMonthOilSort(){ |
| | | List<OilDataVO> oilDataVOList = new ArrayList<>(); |
| | | //上月油耗 |
| | | List<PlatformWaterGas> list = platformWaterGasMapper.selectList(new QueryWrapper<PlatformWaterGas>().lambda() |
| | | .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO) |
| | | .eq(PlatformWaterGas::getType,Constants.TWO) |
| | | .apply("DATE_FORMAT(time_info, '%Y-%m') = DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y-%m')") |
| | | .orderByDesc(PlatformWaterGas::getNum) |
| | | .last("limit 30" ) |
| | | ); |
| | | for (PlatformWaterGas model :list) { |
| | | OilDataVO oilDataVO = new OilDataVO(); |
| | | oilDataVO.setCarNo(model.getCarCode()); |
| | | oilDataVO.setQuantity(model.getNum()); |
| | | oilDataVOList.add(oilDataVO); |
| | | } |
| | | return oilDataVOList; |
| | | } |
| | | |
| | | /** |
| | | * 用电总能耗同比、环比和区域用电量集合 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public EnergyBoardVO centerEnergyData(){ |
| | | EnergyBoardVO data = new EnergyBoardVO(); |
| | | Random random = new Random(); |
| | | PlatformWaterGas smoke= platformWaterGasMapper.selectOne(new QueryWrapper<PlatformWaterGas>() |
| | | .select("sum(num) as num") |
| | | .lambda() |
| | | .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO) |
| | | .eq(PlatformWaterGas::getType,Constants.THREE) |
| | | .apply("year(time_info) = year(now())") |
| | | .last("limit 1 " )); |
| | | |
| | | data.setSmokeBoxTotal(0); |
| | | if(smoke!=null){ |
| | | data.setSmokeBoxTotal(Constants.formatBigdecimal(smoke.getNum()).intValue());//当年烟箱数 |
| | | } |
| | | BigDecimal carbonGas = new BigDecimal(0);//本月用气 |
| | | BigDecimal carbonWater = new BigDecimal(0);//本月用水 |
| | | BigDecimal carbonElec = new BigDecimal(0);//用电 |
| | | |
| | | data.setTodayElectricity(getDefaultData());//今日用电 |
| | | data.setElectricityQuantity(getDefaultData());//上月用电 |
| | | data.setWaterQuantity(getDefaultData());//上月用水 |
| | | data.setGasQuantity(getDefaultData());//上月用气 |
| | | data.setMonthElectricity(getDefaultData());//本月用电 |
| | | data.setYesterdayElectricity(getDefaultData());//昨日用电 |
| | | getMonthElectricityData(data.getMonthElectricity());//通过安防平获取本月数据 |
| | | carbonElec = new BigDecimal(StringUtils.defaultString(data.getMonthElectricity().getTotal(), "0")); |
| | | getLastMonthElectricityData(data.getElectricityQuantity());//通过安防平获取上月数据 |
| | | String firstDate = DateUtil.getFirstDayOfThisMonth() +" 00:00:00"; |
| | | Date month0 = DateUtil.getDateFromString(firstDate); |
| | | Date month1 = DateUtil.increaseMonth(month0,-1);//上月 |
| | | Date month2 = DateUtil.increaseMonth(month0,-2);//上上月 |
| | | Date month3 = DateUtil.increaseMonth(month0,-12);//去年同月 |
| | | |
| | | List<PlatformWaterGas> list = platformWaterGasMapper.selectList(new QueryWrapper<PlatformWaterGas>() |
| | | .lambda() |
| | | .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO) |
| | | .in(PlatformWaterGas::getType,Constants.ZERO,Constants.ONE) |
| | | .in(PlatformWaterGas::getTimeInfo,month0,month1,month3,month2) |
| | | ); |
| | | |
| | | if(list!=null){ |
| | | //类型 0用水 1用气 2用油 |
| | | for(PlatformWaterGas model : list){ |
| | | if(Constants.equalsInteger(model.getType(),Constants.ONE)){ |
| | | if(model.getTimeInfo().getTime() == month0.getTime()){ |
| | | carbonGas = Constants.formatBigdecimal(model.getNum()); |
| | | } |
| | | if(model.getTimeInfo().getTime() == month1.getTime()){ |
| | | data.getGasQuantity().setTotalNum(Constants.formatBigdecimal(model.getNum()) ); |
| | | data.getGasQuantity().setTotal(Constants.formatBigdecimal(model.getNum())+""); |
| | | } |
| | | if(model.getTimeInfo().getTime() == month2.getTime()){ |
| | | data.getGasQuantity().setSameNum(Constants.formatBigdecimal(model.getNum()) ); |
| | | } |
| | | if(model.getTimeInfo().getTime() == month3.getTime()){ |
| | | data.getGasQuantity().setRingNum(Constants.formatBigdecimal(model.getNum()) ); |
| | | } |
| | | |
| | | }else if(Constants.equalsInteger(model.getType(),Constants.ZERO)){ |
| | | if(model.getTimeInfo().getTime() == month0.getTime()){ |
| | | carbonWater = Constants.formatBigdecimal(model.getNum()); |
| | | } |
| | | if(model.getTimeInfo().getTime() == month1.getTime()){ |
| | | data.getWaterQuantity().setTotalNum(Constants.formatBigdecimal(model.getNum()) ); |
| | | data.getWaterQuantity().setTotal(Constants.formatBigdecimal(model.getNum())+""); |
| | | } |
| | | if(model.getTimeInfo().getTime() == month2.getTime()){ |
| | | data.getWaterQuantity().setSameNum(Constants.formatBigdecimal(model.getNum()) ); |
| | | } |
| | | if(model.getTimeInfo().getTime() == month3.getTime()){ |
| | | data.getWaterQuantity().setRingNum(Constants.formatBigdecimal(model.getNum()) ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if( data.getGasQuantity().getTotalNum().compareTo(new BigDecimal(0)) !=0){ |
| | | //计算用气同比环比 |
| | | data.getGasQuantity().setSameRate(Constants.formatBigdecimal4Float(data.getGasQuantity().getSameNum().divide(data.getGasQuantity().getTotalNum())).doubleValue()*100 +""); |
| | | data.getGasQuantity().setRingRate(Constants.formatBigdecimal4Float(data.getGasQuantity().getRingNum().divide(data.getGasQuantity().getTotalNum())).doubleValue()*100 +""); |
| | | } |
| | | if( data.getWaterQuantity().getTotalNum().compareTo(new BigDecimal(0)) !=0){ |
| | | // //计算用水同比环比 |
| | | data.getWaterQuantity().setSameRate(Constants.formatBigdecimal4Float(data.getWaterQuantity().getSameNum().divide(data.getWaterQuantity().getTotalNum())).doubleValue()*100 +""); |
| | | data.getWaterQuantity().setRingRate(Constants.formatBigdecimal4Float(data.getWaterQuantity().getRingNum().divide(data.getWaterQuantity().getTotalNum())).doubleValue()*100 +""); |
| | | } |
| | | |
| | | /*计算碳排量,以下三个因素之和 |
| | | 1)用电的二氧化碳排放量(kg)=耗电量(kWh)x0.785; |
| | | 2) 天然气二氧化碳排放量(kg)=天然气使用量(m3)×0.19; |
| | | 3) 自来水二氧化碳排放量(kg)=自来水使用量(m3)×0.91;*/ |
| | | data.setCarbon(Constants.formatBigdecimal2Float((carbonElec.multiply(new BigDecimal(0.785))) |
| | | .add(carbonGas.multiply(new BigDecimal(0.19))) |
| | | .add(carbonWater.multiply(new BigDecimal(0.91))))); |
| | | return data; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 通过安防平获取本月数据 |
| | | * @param data |
| | | */ |
| | | private void getMonthElectricityData(EnergyModelDataVO data) { |
| | | BaseResponse<MonthDataByMeterTypeResponse> response = HKService.getCurrentMonthDataByMeterType("1"); |
| | | if(response != null && !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) && response.getData()!=null ){ |
| | | data.setRingRate(StringUtils.defaultString(response.getData().getRingPercent(),"0")); |
| | | data.setSameRate(StringUtils.defaultString(response.getData().getSamePercent(),"0")); |
| | | data.setTotal(StringUtils.defaultString(response.getData().getValue(),"0")); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 通过安防平获取上月数据 |
| | | * @param data |
| | | */ |
| | | private void getLastMonthElectricityData(EnergyModelDataVO data) { |
| | | BaseResponse<LastMonthFeeByMeterTypeResponse> response = HKService.lastMonthFeeByMeterType("1"); |
| | | if(response != null && !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) && response.getData()!=null ){ |
| | | data.setRingRate(StringUtils.defaultString(response.getData().getRingPercent(),"0")); |
| | | data.setSameRate(StringUtils.defaultString(response.getData().getSamePercent(),"0")); |
| | | data.setTotal(StringUtils.defaultString(response.getData().getValue(),"0")); |
| | | } |
| | | } |
| | | |
| | | private EnergyModelDataVO getDefaultData() { |
| | | EnergyModelDataVO data = new EnergyModelDataVO(); |
| | | data.setTotal("0"); |
| | | data.setSameRate("0"); |
| | | data.setRingRate("0"); |
| | | data.setTotalNum(new BigDecimal(0)); |
| | | data.setSameNum(new BigDecimal(0)); |
| | | data.setRingNum(new BigDecimal(0)); |
| | | return data; |
| | | } |
| | | |
| | | /** |
| | | * 用电总能耗同比、环比和区域用电量集合 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public RegionEnergyListResponse energyRegionData(){ |
| | | RegionEnergyListResponse data = null; |
| | | BaseResponse<RegionEnergyListResponse> response = HKService.regionEnergyList("1"); |
| | | if(response != null && !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) && response.getData()!=null ){ |
| | | data = response.getData(); |
| | | } |
| | | if(data == null){ |
| | | data = new RegionEnergyListResponse(); |
| | | data.setSecondRegionDataList(new ArrayList<>()); |
| | | data.setRootValue("0"); |
| | | data.setSamePercent("0"); |
| | | data.setRingPercent("0"); |
| | | data.setSecondRegionDataList(new ArrayList<>()); |
| | | } |
| | | return data; |
| | | |
| | | } |
| | | /** |
| | | * 近12个水电气油耗数据统计 |
| | | * @param type |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<EnergyDataVO> energyDataList(Integer type){ |
| | | List<EnergyDataVO> energyDataVOList = new ArrayList<>(); |
| | | List<OilDataVO> oilDataVOList = new ArrayList<>(); |
| | | Date lastMonth = DateUtil.increaseMonth(new Date(),-11); |
| | | if(type >=0 && type <=2){ |
| | | //用水用电用气 |
| | | List<PlatformWaterGas> list = platformWaterGasMapper.selectList(new QueryWrapper<PlatformWaterGas>() |
| | | .select("DATE_FORMAT(TIME_INFO,'yyyy-MM') as time_info_str,sum(num) as num") |
| | | .lambda() |
| | | .eq(PlatformWaterGas::getIsdeleted,Constants.ZERO) |
| | | .eq(PlatformWaterGas::getType,type) |
| | | .apply("time_info BETWEEN DATE_SUB(CURDATE(), INTERVAL 12 MONTH) AND CURDATE()")//近12个月 |
| | | .last(" groupby DATE_FORMAT(TIME_INFO,'yyyy-MM')") |
| | | ); |
| | | for (int i = 0; i < 12; i++) { |
| | | Date tempDate = DateUtil.increaseMonth(lastMonth,i); |
| | | EnergyDataVO data = new EnergyDataVO(); |
| | | data.setTimeData(DateUtil.getFomartDate(tempDate,"YYYY-MM")); |
| | | data.setEnergy(new BigDecimal(0)); |
| | | if(list!=null){ |
| | | for(PlatformWaterGas m : list){ |
| | | if(StringUtils.equals(m.getTimeInfoStr(),data.getTimeData())){ |
| | | data.setEnergy(Constants.formatBigdecimal(m.getNum())); |
| | | } |
| | | } |
| | | } |
| | | energyDataVOList.add(data); |
| | | } |
| | | }else{ |
| | | for (int i = 0; i < 12; i++) { |
| | | Date tempDate = DateUtil.increaseMonth(lastMonth,i); |
| | | EnergyDataVO data = new EnergyDataVO(); |
| | | data.setTimeData(DateUtil.getFomartDate(tempDate,(i+1)+"月")); |
| | | data.setEnergy(new BigDecimal(0)); |
| | | energyDataVOList.add(data); |
| | | } |
| | | //如果是用电数据 |
| | | EnergyTrendRequest param = new EnergyTrendRequest(); |
| | | param.setDate(DateUtil.getFomartDate(new Date(),"yyyy"));//年份 |
| | | param.setMeterType(1); |
| | | param.setNodeType(2); |
| | | param.setNodeId("root000000"); |
| | | param.setPeriodType("year"); |
| | | BaseResponse<EnergyTrendResponse> response = HKService.energyTrend(param); |
| | | if(response != null && !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) && response.getData()!=null&& response.getData().getYvalues()!=null ){ |
| | | for (int i = 0; i < 12; i++) { |
| | | if(response.getData().getYvalues().size()>0 &&response.getData().getYvalues().get(0).getValue().length>i){ |
| | | //取相应的参数值 |
| | | energyDataVOList.get(0).setEnergy(new BigDecimal(response.getData().getYvalues().get(0).getValue()[i])); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | return energyDataVOList; |
| | | } |
| | | @Override |
| | | public VisitDataVO visitSecurityData(){ |
| | | //待访问、已登记、已离开 |
| | | |
| | |
| | | |
| | | SecurityBoardVO data = new SecurityBoardVO(); |
| | | getParkingCarsNum(data);//获取车位数据 |
| | | Random random = new Random(); |
| | | |
| | | List<Retention> retentionList = retentionMapper.selectJoinList(Retention.class, |
| | | new MPJLambdaWrapper<Retention>() |
| | | .selectAll(Retention.class) |