/** 获取订单分析数据 */ public Map<String, Object> getAnalysesData(HttpServletRequest request, SysUnits loginUnit) { // 结果集 Map<String, Object> gridData = new HashMap<String, Object>(); // 订单分析数据总集 List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>(); // 分析订单的 条件 String longitude = request.getParameter("longitude").trim(); // 经度 String latitude = request.getParameter("latitude").trim(); // 纬度 String radius = request.getParameter("radius").trim(); // 范围半径 // 时间条件 Date today = DateUtil.getToday(); // 今天 时间 Date tomorrow = DateUtil.getTomorrow(today); // 明天 时间 Date lastWeek = DateUtil.getLastWeek(today); // 上一周 时刻 Date lastMonth = DateUtil.getLastMonth(today); // 上一月 时刻 Date lastQuarter = DateUtil.getLastQuarter(today); // 前三月 时刻 Date halfYear = DateUtil.getHalfYear(today); // 半年之前 时刻 Date nineMonthEarlier = DateUtil.getNineMonthEarlier(today); // 九个月之前 时刻 Date lastYear = DateUtil.getLastYear(today); // 一年之前 时刻 // 单位信息条件 String unitName = request.getParameter("unitName"); if (unitName != null && !"".equals(unitName)) { unitName = "%" + unitName + "%"; } long unitId = loginUnit.getId(); String zoneCode = loginUnit.getZoneCode() + "%"; int unitType = loginUnit.getUnitType(); Map<String, Object> paraMap = new HashMap<String, Object>(); paraMap.put("longitude", longitude); paraMap.put("latitude", latitude); paraMap.put("radius", radius); paraMap.put("unitName", unitName); paraMap.put("unitId", unitId); paraMap.put("zoneCode", zoneCode); paraMap.put("unitType", unitType); paraMap.put("endDate", tomorrow); // 当天的订单分析数据 paraMap.put("startDate", today); List<Map<String, Object>> todayData = analysesData(paraMap, "今天"); if (!todayData.isEmpty()) { dataList.addAll(todayData); } // 一周的订单分析数据 paraMap.put("startDate", lastWeek); List<Map<String, Object>> weekData = analysesData(paraMap, "一周之内"); if (!weekData.isEmpty()) { dataList.addAll(weekData); } // 一个月的订单分析数据 paraMap.put("startDate", lastMonth); List<Map<String, Object>> monthData = analysesData(paraMap, "一个月之内"); if (!monthData.isEmpty()) { dataList.addAll(monthData); } // 三个月的订单分析数据 paraMap.put("startDate", lastQuarter); List<Map<String, Object>> quarterData = analysesData(paraMap, "三个月之内"); if (!quarterData.isEmpty()) { dataList.addAll(quarterData); } // 半年之内的订单分析数据 paraMap.put("startDate", halfYear); List<Map<String, Object>> halfYearData = analysesData(paraMap, "半年之内"); if (!halfYearData.isEmpty()) { dataList.addAll(halfYearData); } // 九个月之内的订单分析数据 paraMap.put("startDate", nineMonthEarlier); List<Map<String, Object>> nineMonthData = analysesData(paraMap, "九个月之内"); if (!nineMonthData.isEmpty()) { dataList.addAll(nineMonthData); } // 一年之内的订单分析数据 paraMap.put("startDate", lastYear); List<Map<String, Object>> oneYearData = analysesData(paraMap, "一年之内"); if (!oneYearData.isEmpty()) { dataList.addAll(oneYearData); } int rowsCount = dataList.isEmpty() ? 0 : dataList.size(); gridData.put("Rows", dataList); gridData.put("Total", rowsCount); return gridData; }
public Map<String, Object> getGridData(HttpServletRequest request, SysUnits sysUnits) { Map<String, Object> gridData = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>(); map.put("unitId", sysUnits.getId()); map.put("unitType", sysUnits.getUnitType()); map.put("zoneCode", sysUnits.getZoneCode() + "%"); String startDay_str = request.getParameter("startDay"); String endDay_str = request.getParameter("endDay"); String unitName = request.getParameter("unitName"); List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>(); if (null != startDay_str && !startDay_str.equals("") && null != endDay_str && !endDay_str.equals("")) { map.put("startDay", DateUtil.toDate(startDay_str, DateUtil.YYYY_MM_DD)); map.put("endDay", DateUtil.toDate(endDay_str, DateUtil.YYYY_MM_DD)); if (null != unitName && !"".equals(unitName)) { map.put("unitName", "%" + unitName + "%"); } dataList = orderCountDao.getListMap(map); } if (null != dataList && !dataList.isEmpty()) { for (Map<String, Object> countData : dataList) { List<OrderCountInfo> infoList = orderCountInfoDao.getListByCountId(Long.valueOf(countData.get("ID") + "")); countData.put( "AVG_AMOUNT", Arith.div( null == countData.get("GOODS_AMOUNT") ? 0d : Double.valueOf(countData.get("GOODS_AMOUNT") + ""), null == countData.get("ORDER_COUNT") ? 0d : Double.valueOf(countData.get("ORDER_COUNT") + ""))); if (null != infoList && !infoList.isEmpty()) { for (OrderCountInfo orderCountInfo : infoList) { int infoType = orderCountInfo.getInfoType(); countData.put("ORDER_COUNT_" + infoType, orderCountInfo.getOrderCount()); countData.put("REAL_AMOUNT_" + infoType, orderCountInfo.getRealAmount()); countData.put("GOODS_AMOUNT_" + infoType, orderCountInfo.getGoodsAmount()); countData.put("COIN_AMOUNT_" + infoType, orderCountInfo.getCoinAmount()); countData.put( "GOODS_TRANSPORT_AMOUNT_" + infoType, orderCountInfo.getGoodsTransportAmount()); countData.put("COUPONS_AMOUNT_" + infoType, orderCountInfo.getCouponsAmount()); countData.put( "AVG_AMOUNT_" + infoType, Arith.div( orderCountInfo.getGoodsAmount(), Double.valueOf(orderCountInfo.getOrderCount()))); } } } } long totalRows = null == dataList ? 0 : dataList.size(); gridData.put("Rows", dataList); gridData.put("Total", totalRows); return gridData; }
public Map<String, Object> getTodayGridData(HttpServletRequest request, SysUnits sysUnits) { Map<String, Object> map = new HashMap<String, Object>(); map.put("unitId", sysUnits.getId()); String startTime = request.getParameter("startTime"); String endTime = request.getParameter("endTime"); map.put("startTime", startTime); map.put("endTime", endTime); List<Order> orderList = orderDao.getTodayCountList(map); List<OrderCountInfo> dataList = new ArrayList<OrderCountInfo>(); //// 汇总方式 0:有效订单、1:在线支付、2:线下支付、3:电话外卖、4:拒收订单 OrderCountInfo orderCountInfo = new OrderCountInfo(); // 总订单 orderCountInfo.setInfoType(-1); OrderCountInfo valiCountInfo = new OrderCountInfo(); // 有效订单 valiCountInfo.setInfoType(0); OrderCountInfo jushouCountInfo = new OrderCountInfo(); // 拒收订单 jushouCountInfo.setInfoType(4); OrderCountInfo onlineCountInfo = new OrderCountInfo(); // 线上订单 onlineCountInfo.setInfoType(1); OrderCountInfo offlineCountInfo = new OrderCountInfo(); // 线下订单 offlineCountInfo.setInfoType(2); if (null != orderList && !orderList.isEmpty()) { for (Order order : orderList) { setOrderCountInfo(orderCountInfo, order); if (order.getDeliveryerStatus() == 12) { // 有效订单 setOrderCountInfo(valiCountInfo, order); } else if (order.getDeliveryerStatus() == -11) { // 拒收订单 setOrderCountInfo(jushouCountInfo, order); } if (order.getPayType() == 0) { // 线下支付 setOrderCountInfo(offlineCountInfo, order); } else if (order.getPayType() == 1) { setOrderCountInfo(onlineCountInfo, order); } } } dataList.add(orderCountInfo); dataList.add(valiCountInfo); dataList.add(jushouCountInfo); dataList.add(onlineCountInfo); dataList.add(offlineCountInfo); Map<String, Object> countData = new HashMap<String, Object>(); countData.put("Rows", dataList); countData.put("Total", null != dataList ? dataList.size() : 0); return countData; }