| @@ -124,23 +124,58 @@ public class DataTowerServiceImpl implements DataTowerService { | |||||
| params.put("tenantId",tenantId); | params.put("tenantId",tenantId); | ||||
| params.put("cmdType",EnumCarCmd.CAR_ETCP_CALLBACK_PARK_OUT.getCode()); | params.put("cmdType",EnumCarCmd.CAR_ETCP_CALLBACK_PARK_OUT.getCode()); | ||||
| String startdate = DateUtils.getTimeBefore(7, new Date()); | String startdate = DateUtils.getTimeBefore(7, new Date()); | ||||
| String enddate = DateUtils.getSystemTime("yyyy-MM-dd"); | |||||
| params.put("startdate",startdate); | |||||
| params.put("enddate",enddate); | |||||
| String systemTime = DateUtils.getSystemTime("yyyy-MM-dd"); | |||||
| List<String> tjTimeList = DateUtils.getTjTimeList(startdate, systemTime, "0"); | |||||
| params.put("startdate",startdate+" 00:00:00"); | |||||
| params.put("enddate",systemTime+" 23:59:59"); | |||||
| List<Map<String,Object>> historylist=wxCarCmdLogMapper.queryHistory(params); | List<Map<String,Object>> historylist=wxCarCmdLogMapper.queryHistory(params); | ||||
| Map<Object, Object> collect = historylist.stream().collect(Collectors.toMap(m -> { | Map<Object, Object> collect = historylist.stream().collect(Collectors.toMap(m -> { | ||||
| return m.get("create_date"); | return m.get("create_date"); | ||||
| }, m -> { | }, m -> { | ||||
| return m.get("carcount"); | return m.get("carcount"); | ||||
| })); | })); | ||||
| for(String date:tjTimeList){ | |||||
| Object o = collect.get(date); | |||||
| if(o==null){ | |||||
| collect.put(date,0l); | |||||
| } | |||||
| } | |||||
| TreeMap<Object, Object> historymap = new TreeMap<>(); | TreeMap<Object, Object> historymap = new TreeMap<>(); | ||||
| historymap.putAll(collect); | historymap.putAll(collect); | ||||
| Map<String, Object> datamap = new HashMap<>(); | Map<String, Object> datamap = new HashMap<>(); | ||||
| datamap.put("history",historymap); | datamap.put("history",historymap); | ||||
| //今日车流量 | |||||
| long todaycar = (long) collect.get(systemTime); | |||||
| datamap.put("todaycar",todaycar); | |||||
| //环比 | |||||
| long yesterdaycar = (long) collect.get(tjTimeList.get(8 - 2)); | |||||
| if(yesterdaycar>0){ | |||||
| double hbd = (double) (todaycar - yesterdaycar) / yesterdaycar *100; | |||||
| double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |||||
| datamap.put("hb",hb); | |||||
| }else{ | |||||
| datamap.put("hb","--"); | |||||
| } | |||||
| //上周同期 | |||||
| long last = (long) collect.get(tjTimeList.get(0)); | |||||
| if(last>0){ | |||||
| double lasthbd = (double) (todaycar - last) / last *100; | |||||
| double lasthb = new BigDecimal(lasthbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |||||
| datamap.put("lasthb",lasthb); | |||||
| }else{ | |||||
| datamap.put("lasthb","--"); | |||||
| } | |||||
| return datamap; | return datamap; | ||||
| } | } | ||||