| | |
| | | data.setGasQuantity(getDefaultData());//上月用气 |
| | | data.setMonthElectricity(getDefaultData());//本月用电 |
| | | data.setYesterdayElectricity(getDefaultData());//昨日用电 |
| | | getMonthElectricityData(data.getMonthElectricity());//通过安防平获取本月数据 |
| | | getMonthElectricityData(data.getMonthElectricity());//通过安防平获取本月用电量数据 |
| | | carbonElec = new BigDecimal(StringUtils.defaultString(data.getMonthElectricity().getTotal(), "0")); |
| | | getLastMonthElectricityData(data.getElectricityQuantity());//通过安防平获取上月数据 |
| | | String firstDate = DateUtil.getFirstDayOfThisMonth() +" 00:00:00"; |
| | | getLastMonthElectricityData(data.getElectricityQuantity());//通过安防平获取上月用电量数据 |
| | | getCurrentDateElectircityData(data.getTodayElectricity(),0);//通过安防平获取今日用电量数据 |
| | | getCurrentDateElectircityData(data.getYesterdayElectricity(),-1);//通过安防平获取昨日用电量数据 |
| | | String firstDate = DateUtil.getFirstDayCurrentMonth() +" 00:00:00"; |
| | | Date month0 = DateUtil.getDateFromString(firstDate); |
| | | Date month1 = DateUtil.increaseMonth(month0,-1);//上月 |
| | | Date month2 = DateUtil.increaseMonth(month0,-2);//上上月 |
| | |
| | | } |
| | | 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 +""); |
| | | data.getGasQuantity().setSameRate(Constants.formatBigdecimal4Float(data.getGasQuantity().getSameNum().divide(data.getGasQuantity().getTotalNum(),4,BigDecimal.ROUND_HALF_UP)).doubleValue()*100 +""); |
| | | data.getGasQuantity().setRingRate(Constants.formatBigdecimal4Float(data.getGasQuantity().getRingNum().divide(data.getGasQuantity().getTotalNum(),4,BigDecimal.ROUND_HALF_UP)).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 +""); |
| | | data.getWaterQuantity().setSameRate(Constants.formatBigdecimal4Float(data.getWaterQuantity().getSameNum().divide(data.getWaterQuantity().getTotalNum(),4,BigDecimal.ROUND_HALF_UP)).doubleValue()*100 +""); |
| | | data.getWaterQuantity().setRingRate(Constants.formatBigdecimal4Float(data.getWaterQuantity().getRingNum().divide(data.getWaterQuantity().getTotalNum(),4,BigDecimal.ROUND_HALF_UP)).doubleValue()*100 +""); |
| | | } |
| | | |
| | | /*计算碳排量,以下三个因素之和 |
| | |
| | | */ |
| | | private void getMonthElectricityData(EnergyModelDataVO data) { |
| | | BaseResponse<MonthDataByMeterTypeResponse> response = HKService.getCurrentMonthDataByMeterType("1"); |
| | | if(response != null && !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) && response.getData()!=null ){ |
| | | 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 void getLastMonthElectricityData(EnergyModelDataVO data) { |
| | | BaseResponse<LastMonthFeeByMeterTypeResponse> response = HKService.lastMonthFeeByMeterType("1"); |
| | | if(response != null && !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) && response.getData()!=null ){ |
| | | 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 getCurrentDateElectircityData(EnergyModelDataVO data,int days) { |
| | | EnergyTrendRequest param = new EnergyTrendRequest(); |
| | | param.setDate(DateUtil.getFomartDate(DateUtil.addDaysToDate(new Date(),days),"yyyy-MM-dd"));//日期 |
| | | param.setMeterType(1); |
| | | param.setShowType("4"); |
| | | param.setNodeType(2); |
| | | param.setNodeId("root000000"); |
| | | param.setPeriodType("day"); |
| | | BigDecimal total = new BigDecimal(0); |
| | | 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 < response.getData().getYvalues().get(0).getValue().length; i++) { |
| | | total = total.add(new BigDecimal(StringUtils.defaultString( response.getData().getYvalues().get(0).getValue()[i],"0"))); |
| | | } |
| | | |
| | | } |
| | | data.setTotal(Constants.formatBigdecimal2Float(total).toString()); |
| | | } |
| | | |
| | | private EnergyModelDataVO getDefaultData() { |
| | |
| | | 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 ){ |
| | | if(response != null && StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) && response.getData()!=null ){ |
| | | data = response.getData(); |
| | | } |
| | | if(data == null){ |
| | |
| | | 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") |
| | | .select("DATE_FORMAT(TIME_INFO,'%Y-%m') 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')") |
| | | .last(" group by DATE_FORMAT(TIME_INFO,'%Y-%m')") |
| | | ); |
| | | for (int i = 0; i < 12; i++) { |
| | | Date tempDate = DateUtil.increaseMonth(lastMonth,i); |
| | |
| | | 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 ){ |
| | | 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])); |
| | | energyDataVOList.get(i).setEnergy(new BigDecimal(StringUtils.defaultString(response.getData().getYvalues().get(0).getValue()[i],"0"))); |
| | | } |
| | | } |
| | | |
| | |
| | | if(jobList==null || jobList.size()==0){ |
| | | return workEfficiencyVOList; |
| | | } |
| | | /* List<PlatformWmsDetail> jobList = platformWmsDetailMapper.selectJoinList(PlatformWmsDetail.class, new MPJLambdaWrapper<PlatformWmsDetail>() |
| | | .selectAll( PlatformWmsDetail.class) |
| | | .selectAs( PlatformJob::getDoneDate,PlatformWmsDetail::getDoneDate) |
| | | .leftJoin(PlatformJob.class,PlatformJob::getId,PlatformWmsDetail::getJobId) |
| | | .eq(PlatformWmsDetail::getIsdeleted, Constants.ZERO) |
| | | .eq(PlatformJob::getIsdeleted, Constants.ZERO) |
| | | .in(Constants.equalsInteger(type,Constants.ZERO),PlatformJob::getType,new Integer[]{0,2,4}) |
| | | .in(Constants.equalsInteger(type,Constants.ONE),PlatformJob::getType,new Integer[]{1,3}) |
| | | .in(PlatformJob::getStatus, Constants.PlatformJobStatus.DONE.getKey() |
| | | , Constants.PlatformJobStatus.AUTHED_LEAVE.getKey() |
| | | , Constants.PlatformJobStatus.LEAVED.getKey()) |
| | | .apply("to_days(t1.create_date) = to_days(now())") |
| | | );*/ |
| | | int curtotalNum = 0; |
| | | Date today = Utils.Date.getStart(new Date()); |
| | | long curTime=0, lastTime=0; |
| | |
| | | public List<PlatformWarnEvent> warningList(int limit){ |
| | | List<PlatformWarnEvent> platformLogList = platformWarnEventMapper.selectList(new QueryWrapper<PlatformWarnEvent>().lambda() |
| | | .eq(PlatformWarnEvent::getIsdeleted,Constants.ZERO) |
| | | .apply("to_days(create_date) = to_days(now())") |
| | | .orderByDesc(PlatformWarnEvent::getCreateDate) |
| | | .last(" limit "+limit) |
| | | ); |