| | |
| | | return service.getEnergyStatistics(year); |
| | | } |
| | | |
| | | @GetMapping("getEnergyStatistics_nj") |
| | | @ApiOperation(value = "能效统计--南京websocket首页") |
| | | public Response getEnergyStatistics_nj(@RequestParam int year,@RequestParam int userId) { |
| | | return service.getEnergyStatistics_nj(year,userId); |
| | | } |
| | | |
| | | @GetMapping("getEnergyStatisticsInBaojiGroup") |
| | | @ApiOperation(value = "能效统计分班组") |
| | | public Response getEnergyStatisticsInBaojiGroup(@RequestParam int year) { |
| | |
| | | List<GroupTestCapRes> getEnergyStatistics(Date testStartTime,Date testEndTime); |
| | | //能效统计分班组 |
| | | List<GroupTestCapRes> getEnergyStatisticsInBaojiGroup(Date testStartTime, Date testEndTime, Long bjGroupId); |
| | | |
| | | //能效统计--南京websocket首页 |
| | | List<GroupTestCapRes> getEnergyStatistics_nj(Date testStartTime, Date testEndTime, int userId); |
| | | } |
| | |
| | | } |
| | | return new Response().setIII(1, true, sCountMap,sCapMap, "能效统计"); |
| | | } |
| | | |
| | | //能效统计--南京websocket首页 |
| | | public Response getEnergyStatistics_nj(int year,int userId) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | int nowYear= calendar.get(Calendar.YEAR); |
| | | int lastYear=nowYear-year+1; |
| | | Date date1 = ThreadLocalUtil.parse(lastYear+"-01-01 00:00:00",1 ); |
| | | Date date2 = ThreadLocalUtil.parse(nowYear+"-12-31 23:59:59",1 ); |
| | | List<GroupTestCapRes> list=mapper.getEnergyStatistics_nj(date1,date2,userId); |
| | | Map<Integer,Integer> sCountMap=new HashMap<>(); |
| | | Map<Integer,String> sCapMap=new HashMap<>(); |
| | | for (int i=0;i<year;i++){ |
| | | sCountMap.put(lastYear+i,0); |
| | | sCapMap.put(lastYear+i,"0"); |
| | | } |
| | | Map<Integer, List<GroupTestCapRes>> yearMap = list.stream().collect(Collectors.groupingBy(GroupTestCapRes::getYearTime)); |
| | | for (Integer yearTime : yearMap.keySet()) { |
| | | sCountMap.put(yearTime,yearMap.get(yearTime).size()); |
| | | List<GroupTestCapRes> groupList=yearMap.get(yearTime); |
| | | Double sum = groupList.stream().collect(Collectors.summingDouble(GroupTestCapRes::getTestCap)); |
| | | sCapMap.put(yearTime,String.format("%.3f",sum)); |
| | | } |
| | | return new Response().setIII(1, true, sCountMap,sCapMap, "能效统计"); |
| | | } |
| | | } |
| | |
| | | //8.统计:TODO 能效统计,默认取五年的能效 |
| | | Response resNX = new Response(); |
| | | try { |
| | | resNX=testInfService.getEnergyStatisticsInBaojiGroup(5); |
| | | resNX=testInfService.getEnergyStatistics_nj(5,userId); |
| | | }catch (Exception e){ |
| | | resNX.set(1,false,"发生异常:"+e.getCause()); |
| | | } |
| | |
| | | where baoji_group_id=#{bjGroupId} |
| | | ) |
| | | </select> |
| | | <select id="getEnergyStatistics_nj" resultType="com.whyc.dto.result.GroupTestCapRes"> |
| | | SELECT DISTINCT |
| | | stationId,IFNULL(test_starttime,0) as testStartTime,IFNULL(YEAR(test_starttime),0) AS yearTime |
| | | , stationName1,stationName2,stationName3,stationName5,ifnull(truncate(abs(test_cap),3),0) as test_cap |
| | | from db_battinf.tb_battinf,db_batt_testdata.tb_batttestdata_inf |
| | | where tb_battinf.BattGroupId=tb_batttestdata_inf.BattGroupId |
| | | and test_type=3 and test_starttype=3 |
| | | and tb_batttestdata_inf.test_starttime>=#{testStartTime} and tb_batttestdata_inf.test_starttime<=#{testEndTime} |
| | | and db_battinf.tb_battinf.battgroupid in ( |
| | | select distinct db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId |
| | | from db_user.tb_user_battgroup_baojigroup_battgroup, |
| | | db_user.tb_user_battgroup_baojigroup_usr, |
| | | db_user.tb_user_inf |
| | | where db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id = |
| | | db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id |
| | | and db_user.tb_user_inf.uid = db_user.tb_user_battgroup_baojigroup_usr.uid |
| | | and db_user.tb_user_inf.uid = #{userId} |
| | | ) |
| | | </select> |
| | | </mapper> |