| @@ -92,7 +92,7 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| } | |||
| //车流数据 | |||
| if (chart.equals(EnumChart.CLSJ.getCode())) { | |||
| return getCarMonthly(tenantId); | |||
| return getCarHistoryAndTodayAndHB(tenantId, false); | |||
| } | |||
| //券交易数据 | |||
| if (chart.equals(EnumChart.QJYSJ.getCode())) { | |||
| @@ -123,7 +123,7 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| } | |||
| // 历史车流量+今日车流量 + 上周同期 | |||
| if (chart.equals(EnumChart.LSCLL.getCode())) { | |||
| return getCarHistoryAndTodayAndHB(tenantId); | |||
| return getCarHistoryAndTodayAndHB(tenantId, true); | |||
| } | |||
| //近一周新增停车会员 | |||
| if (chart.equals(EnumChart.JYZXXZTCHY.getCode())) { | |||
| @@ -422,11 +422,11 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| } | |||
| /** | |||
| * 历史车流量 + 今日车流量 + 上周同期 | |||
| * 数据塔台-数据总览-车流数据 | 数据塔台-车流数据-(历史车流量 + 今日车流量 + 上周同期) | |||
| * @param tenantId | |||
| * @return | |||
| */ | |||
| private ResultData getCarHistoryAndTodayAndHB(String tenantId) { | |||
| private ResultData getCarHistoryAndTodayAndHB(String tenantId, boolean withOthers ) { | |||
| String startdate; | |||
| HashMap<String, Object> datamap = new HashMap<>(); | |||
| HashMap<String, Object> params = new HashMap<>(); | |||
| @@ -464,33 +464,35 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| map.put("val", valList); | |||
| datamap.put("history", map); | |||
| //今日车流量 | |||
| long todaycar = ((Long) valList.get(valList.size()-1)).longValue(); | |||
| datamap.put("todaycar", todaycar); | |||
| //环比 | |||
| long yesterdaycar = (long) ((Long) valList.get(valList.size()-2)).longValue(); | |||
| 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 lastweekcar = ((Long) valList.get(valList.size()-8)).longValue(); | |||
| if (lastweekcar > 0) { | |||
| double lasthbd = (double) (todaycar - lastweekcar) / lastweekcar * 100; | |||
| double lasthb = new BigDecimal(lasthbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |||
| datamap.put("lasthb", lasthb + "%"); | |||
| } else { | |||
| datamap.put("lasthb", "--"); | |||
| } | |||
| // 周入场数量 | |||
| long carWeekCount = 0L; | |||
| for(int i=0;i<7;i++) { | |||
| carWeekCount += ((Long)valList.get(valList.size()-1-i)).longValue(); | |||
| if(withOthers) { | |||
| //今日车流量 | |||
| long todaycar = ((Long) valList.get(valList.size()-1)).longValue(); | |||
| datamap.put("todaycar", todaycar); | |||
| //环比 | |||
| long yesterdaycar = (long) ((Long) valList.get(valList.size()-2)).longValue(); | |||
| 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 lastweekcar = ((Long) valList.get(valList.size()-8)).longValue(); | |||
| if (lastweekcar > 0) { | |||
| double lasthbd = (double) (todaycar - lastweekcar) / lastweekcar * 100; | |||
| double lasthb = new BigDecimal(lasthbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |||
| datamap.put("lasthb", lasthb + "%"); | |||
| } else { | |||
| datamap.put("lasthb", "--"); | |||
| } | |||
| // 周入场数量 | |||
| long carWeekCount = 0L; | |||
| for(int i=0;i<7;i++) { | |||
| carWeekCount += ((Long)valList.get(valList.size()-1-i)).longValue(); | |||
| } | |||
| datamap.put("carWeekCount", carWeekCount); | |||
| } | |||
| datamap.put("carWeekCount", carWeekCount); | |||
| return new ResultData(datamap); | |||
| } | |||
| @@ -924,10 +926,6 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| return new ResultData(datamap); | |||
| } | |||
| private ResultData getNewMemberInWeek(String tenantId) { | |||
| return getNewMemberCount(tenantId, 7, "weekVos"); | |||
| } | |||
| private ResultData getNewMemberCount(String tenantId, int days, String returnName) { | |||
| HashMap<String, Object> datamap = new HashMap<>(); | |||
| WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | |||
| @@ -956,6 +954,15 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| return new ResultData(datamap); | |||
| } | |||
| /** | |||
| * 近一周新增用户数 | |||
| * @param tenantId | |||
| * @return | |||
| */ | |||
| private ResultData getNewMemberInWeek(String tenantId) { | |||
| return getNewMemberCount(tenantId, 7, "weekVos"); | |||
| } | |||
| /** | |||
| * 近一周活跃用户数 | |||
| * @param tenantId | |||
| @@ -1131,7 +1138,7 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| } | |||
| /** | |||
| * 新增用户趋势 | |||
| * 新增用户趋势-月 | |||
| * @param tenantId | |||
| * @return | |||
| */ | |||
| @@ -1421,6 +1428,40 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| return new ResultData(datamap); | |||
| } | |||
| /** | |||
| * 拓客渠道 | |||
| * @param tenantId | |||
| * @return | |||
| */ | |||
| private ResultData getFromChannelAnalysis(String tenantId) { | |||
| HashMap<String, Object> datamap = new HashMap<>(); | |||
| List<WxUserChannel> channelStructureList = new ArrayList<>(); | |||
| WxCUser wxCUser = new WxCUser(); | |||
| wxCUser.setTenantId(tenantId); | |||
| List<WxUserChannel> channels = wxUserChannelMapper.findDistinctChannel(); | |||
| for (WxUserChannel w : channels) { | |||
| WxUserChannel c = new WxUserChannel(); | |||
| c.setChannelName(w.getChannelName()); | |||
| PageInfo<WxUserChannel> page = PageHelper.startPage(1, 1000).doSelectPageInfo(() -> wxUserChannelMapper.findList(c)); | |||
| if (page.getSize() > 0) { | |||
| List<String> sceneList = new ArrayList<>(); | |||
| for (WxUserChannel uc : page.getList()) { | |||
| List<String> scene = new ArrayList<>(); | |||
| scene.add(uc.getSceneAddress()); | |||
| wxCUser.setSceneList(scene); | |||
| sceneList.add(uc.getSceneAddress()); | |||
| } | |||
| wxCUser.setSceneList(sceneList); | |||
| WxUserChannel channelStructure = new WxUserChannel(); | |||
| channelStructure.setChannelName(w.getChannelName()); | |||
| channelStructure.setCount(wxCUserMapper.countByChannel(wxCUser)); | |||
| channelStructureList.add(channelStructure); | |||
| } | |||
| } | |||
| datamap.put("channelList", channelStructureList); | |||
| return new ResultData(datamap); | |||
| } | |||
| /** | |||
| * 微信用户新增趋势 | |||
| * @param tenantId | |||
| @@ -1457,40 +1498,6 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| return new ResultData(datamap); | |||
| } | |||
| /** | |||
| * 拓客渠道 | |||
| * @param tenantId | |||
| * @return | |||
| */ | |||
| private ResultData getFromChannelAnalysis(String tenantId) { | |||
| HashMap<String, Object> datamap = new HashMap<>(); | |||
| List<WxUserChannel> channelStructureList = new ArrayList<>(); | |||
| WxCUser wxCUser = new WxCUser(); | |||
| wxCUser.setTenantId(tenantId); | |||
| List<WxUserChannel> channels = wxUserChannelMapper.findDistinctChannel(); | |||
| for (WxUserChannel w : channels) { | |||
| WxUserChannel c = new WxUserChannel(); | |||
| c.setChannelName(w.getChannelName()); | |||
| PageInfo<WxUserChannel> page = PageHelper.startPage(1, 1000).doSelectPageInfo(() -> wxUserChannelMapper.findList(c)); | |||
| if (page.getSize() > 0) { | |||
| List<String> sceneList = new ArrayList<>(); | |||
| for (WxUserChannel uc : page.getList()) { | |||
| List<String> scene = new ArrayList<>(); | |||
| scene.add(uc.getSceneAddress()); | |||
| wxCUser.setSceneList(scene); | |||
| sceneList.add(uc.getSceneAddress()); | |||
| } | |||
| wxCUser.setSceneList(sceneList); | |||
| WxUserChannel channelStructure = new WxUserChannel(); | |||
| channelStructure.setChannelName(w.getChannelName()); | |||
| channelStructure.setCount(wxCUserMapper.countByChannel(wxCUser)); | |||
| channelStructureList.add(channelStructure); | |||
| } | |||
| } | |||
| datamap.put("channelList", channelStructureList); | |||
| return new ResultData(datamap); | |||
| } | |||
| /** | |||
| * 会员新增趋势 | |||
| * @param tenantId | |||
| @@ -1775,13 +1782,7 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| //默认时间本月第一天,截止到当天 | |||
| if (StringUtils.isEmpty(paramsMap.get("startdate"))) { | |||
| Calendar c = Calendar.getInstance(); | |||
| c.add(Calendar.MONTH, 0); | |||
| c.set(Calendar.DAY_OF_MONTH,1); | |||
| c.set(Calendar.HOUR_OF_DAY, 0); | |||
| c.set(Calendar.MINUTE, 0); | |||
| c.set(Calendar.SECOND, 0); | |||
| wxCoupon.setStartdate(c.getTime()); | |||
| wxCoupon.setStartdate(getMonthFirstDay()); | |||
| }else{ | |||
| Date startTime = DateUtils.stringToDate(startdate); | |||
| wxCoupon.setStartdate(startTime); | |||
| @@ -1826,13 +1827,7 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| //默认时间本月第一天,截止到当天 | |||
| if (StringUtils.isEmpty(paramsMap.get("startdate"))) { | |||
| Calendar c = Calendar.getInstance(); | |||
| c.add(Calendar.MONTH, 0); | |||
| c.set(Calendar.DAY_OF_MONTH,1); | |||
| c.set(Calendar.HOUR_OF_DAY, 0); | |||
| c.set(Calendar.MINUTE, 0); | |||
| c.set(Calendar.SECOND, 0); | |||
| wxCoupon.setStartdate(c.getTime()); | |||
| wxCoupon.setStartdate(getMonthFirstDay()); | |||
| }else{ | |||
| Date startTime = DateUtils.stringToDate(startdate); | |||
| wxCoupon.setStartdate(startTime); | |||
| @@ -1890,13 +1885,7 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| //默认时间本月第一天,截止到当天 | |||
| if (StringUtils.isEmpty(paramsMap.get("startdate"))) { | |||
| Calendar c = Calendar.getInstance(); | |||
| c.add(Calendar.MONTH, 0); | |||
| c.set(Calendar.DAY_OF_MONTH,1); | |||
| c.set(Calendar.HOUR_OF_DAY, 0); | |||
| c.set(Calendar.MINUTE, 0); | |||
| c.set(Calendar.SECOND, 0); | |||
| wxCoupon.setStartdate(c.getTime()); | |||
| wxCoupon.setStartdate(getMonthFirstDay()); | |||
| }else{ | |||
| Date startTime = DateUtils.stringToDate(startdate); | |||
| wxCoupon.setStartdate(startTime); | |||
| @@ -1934,6 +1923,16 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| return new ResultData(result); | |||
| } | |||
| private Date getMonthFirstDay() { | |||
| Calendar c = Calendar.getInstance(); | |||
| c.add(Calendar.MONTH, 0); | |||
| c.set(Calendar.DAY_OF_MONTH,1); | |||
| c.set(Calendar.HOUR_OF_DAY, 0); | |||
| c.set(Calendar.MINUTE, 0); | |||
| c.set(Calendar.SECOND, 0); | |||
| return c.getTime(); | |||
| } | |||
| /** | |||
| * 拼团营销数据 | |||
| * @param paramsMap | |||
| @@ -1949,13 +1948,7 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| Date startTime = new Date(); | |||
| Date endTime = startTime; | |||
| if (StringUtils.isEmpty(paramsMap.get("startdate"))) { | |||
| Calendar c = Calendar.getInstance(); | |||
| c.add(Calendar.MONTH, 0); | |||
| c.set(Calendar.DAY_OF_MONTH, 1); | |||
| c.set(Calendar.HOUR_OF_DAY, 0); | |||
| c.set(Calendar.MINUTE, 0); | |||
| c.set(Calendar.SECOND, 0); | |||
| startTime = c.getTime(); | |||
| startTime = getMonthFirstDay(); | |||
| params.put("startdate", startTime); | |||
| } else { | |||
| startTime = DateUtils.stringToDate(startdate + " 00:00:00"); | |||
| @@ -2008,46 +2001,6 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| return new ResultData(result); | |||
| } | |||
| /** | |||
| * 车流数据 | |||
| * @param tenantId | |||
| * @return | |||
| */ | |||
| private ResultData getCarMonthly(String tenantId) { | |||
| String startdate; | |||
| HashMap<String, Object> datamap = new HashMap<>(); | |||
| HashMap<String, Object> params = new HashMap<>(); | |||
| params.put("tenantId", tenantId); | |||
| params.put("cmdType", EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); | |||
| startdate = DateUtils.getTimeBefore(30, new Date()); | |||
| 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); | |||
| Map<Object, Object> collect = historylist.stream().collect(Collectors.toMap(m -> { | |||
| return m.get("create_date"); | |||
| }, m -> { | |||
| return m.get("carcount"); | |||
| })); | |||
| Map<Object, Object> historymap = new LinkedHashMap<>(); | |||
| for (String date : tjTimeList) { | |||
| Object o = collect.get(date); | |||
| if (o == null) { | |||
| historymap.put(date.substring(5).replace("-", "/"), 0L); | |||
| } else { | |||
| historymap.put(date.substring(5).replace("-", "/"), o); | |||
| } | |||
| } | |||
| datamap.put("history", historymap); | |||
| return new ResultData(datamap); | |||
| } | |||
| /** | |||
| * 昨日解单率 | |||
| * @param tenantId | |||
| @@ -2172,29 +2125,6 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| return result; | |||
| } | |||
| public TreeMap getTimeTreeMap() { | |||
| TreeMap<Object, Object> timemap = new TreeMap(); | |||
| timemap.put("06:00", 0); | |||
| timemap.put("07:00", 0); | |||
| timemap.put("08:00", 0); | |||
| timemap.put("09:00", 0); | |||
| timemap.put("10:00", 0); | |||
| timemap.put("11:00", 0); | |||
| timemap.put("12:00", 0); | |||
| timemap.put("13:00", 0); | |||
| timemap.put("14:00", 0); | |||
| timemap.put("15:00", 0); | |||
| timemap.put("16:00", 0); | |||
| timemap.put("17:00", 0); | |||
| timemap.put("18:00", 0); | |||
| timemap.put("19:00", 0); | |||
| timemap.put("20:00", 0); | |||
| timemap.put("21:00", 0); | |||
| timemap.put("22:00", 0); | |||
| timemap.put("23:00", 0); | |||
| return timemap; | |||
| } | |||
| private long getCountByAge(EnumAgeInfo a, Calendar c, WxCUserBasicInfoDto dto) { | |||
| if (a.getStart() != 0 || a.getEnd() != 0) { | |||
| c.add(Calendar.YEAR, -a.getEnd()); | |||