| | |
| | | @TableField("record_day") |
| | | private String recordDay; |
| | | |
| | | @Schema(description = "油品类型:92,95,98,柴油") |
| | | @TableField("oil_type") |
| | | private String oilType; |
| | | |
| | | @Schema(description = "总金额") |
| | | @TableField("total_amount") |
| | | private java.math.BigDecimal totalAmount; |
| | | |
| | | @Schema(description = "创建时间") |
| | | @TableField("create_time") |
| | | private Date createTime; |
| | |
| | | } |
| | | |
| | | public enum TrendType { |
| | | TRAFFIC(1, StatDataTableVo::getCarCount, StatDataTableVo::getEntryRate, "车流量", "拐入率"), |
| | | OIL(2, StatDataTableVo::getOilCount, StatDataTableVo::getOilVolume, "加油数", "油品销量"), |
| | | OIL_vOLUME(3, StatDataTableVo::getOilVolume, t -> 100 * (t.getOilVolume() - t.getPreStatVo().getOilVolume()) / (t.getPreStatVo().getOilVolume() + 1), "油品销量", "环比"), |
| | | SPAND_AVG(4, StatDataTableVo::getSpandAvg, t -> 100 * (t.getSpandAvg() - t.getPreStatVo().getSpandAvg()) / (t.getPreStatVo().getSpandAvg() + 1), "通过率", "环比"), |
| | | CLIENT(5, null), |
| | | LOSE_CLIENT(6, null); |
| | | TRAFFIC(0, StatDataTableVo::getCarCount, StatDataTableVo::getEntryRate, "车流量", "拐入率"), |
| | | OIL(1, StatDataTableVo::getOilCount, StatDataTableVo::getOilVolume, "加油数", "油品销量"), |
| | | OIL_vOLUME(2, StatDataTableVo::getOilVolume, t -> 100 * (t.getOilVolume() - t.getPreStatVo().getOilVolume()) / (t.getPreStatVo().getOilVolume() + 1), "油品销量", "环比"), |
| | | SPAND_AVG(3, StatDataTableVo::getSpandAvg, t -> 100 * (t.getSpandAvg() - t.getPreStatVo().getSpandAvg()) / (t.getPreStatVo().getSpandAvg() + 1), "通过率", "环比"), |
| | | CLIENT(4, null), |
| | | LOSE_CLIENT(5, null), |
| | | SALES_AMOUNT(6, StatDataTableVo::getTotalAmount, t -> { |
| | | java.math.BigDecimal current = t.getTotalAmount(); |
| | | java.math.BigDecimal previous = t.getPreStatVo().getTotalAmount(); |
| | | if (previous.compareTo(java.math.BigDecimal.ZERO) == 0) { |
| | | return java.math.BigDecimal.ZERO; |
| | | } |
| | | return current.subtract(previous).multiply(new java.math.BigDecimal(100)).divide(previous, 2, java.math.RoundingMode.HALF_UP); |
| | | }, "销售金额", "环比"); |
| | | |
| | | int val; |
| | | |
| | |
| | | @Schema(description = "回头率") |
| | | private String rebackRate; |
| | | |
| | | @Schema(description = "销售金额") |
| | | private java.math.BigDecimal totalAmount; |
| | | |
| | | |
| | | |
| | | @Schema(description = "加油位") |
| | |
| | | |
| | | @Schema(description = "车型") |
| | | private String modelName; |
| | | |
| | | @Schema(description = "油品类型") |
| | | private String oilType; |
| | | |
| | | @Schema(description = "时间轴") |
| | | private LocalDateTime statTime; |
| | |
| | | this.sumSpand += sumSpand; |
| | | } |
| | | |
| | | public void addTotalAmount(java.math.BigDecimal totalAmount) { |
| | | if (this.totalAmount == null) { |
| | | this.totalAmount = java.math.BigDecimal.ZERO; |
| | | } |
| | | if (totalAmount != null) { |
| | | this.totalAmount = this.totalAmount.add(totalAmount); |
| | | } |
| | | } |
| | | |
| | | public java.math.BigDecimal getTotalAmount() { |
| | | if (totalAmount == null) { |
| | | totalAmount = java.math.BigDecimal.ZERO; |
| | | } |
| | | return totalAmount; |
| | | } |
| | | |
| | | public int getSpandAvg() { |
| | | if (spandAvg == null) { |
| | | spandAvg = appearCount == 0 ? 0 : sumSpand / appearCount; |
| | |
| | | |
| | | List<StatDataTableVo> statFanByPosition(DataStatisReqVo param); |
| | | |
| | | List<StatDataTableVo> statFanByOilType(DataStatisReqVo param); |
| | | |
| | | List<StatDataTableVo> statBarByModel(DataStatisReqVo param); |
| | | |
| | | Map getVehicleFrequencyBeforeActivity(@Param("startTime") String startTime, @Param("orgCodes") List<String> orgCodes); |
| | |
| | | JSONObject res; |
| | | List<StatDataTableVo> dataList = new ArrayList<>(); |
| | | Function<StatDataTableVo, ?> xfunc = null; |
| | | Function<StatDataTableVo, Integer> barfunc = null; |
| | | Function<StatDataTableVo, ?> barfunc = null; |
| | | switch(param.getType()) { |
| | | case 1 : |
| | | dataList = oilRecordMapper.statFanByModel(param); |
| | |
| | | dataList = oilRecordMapper.statFanByPosition(param); |
| | | xfunc = StatDataTableVo::getOilPosition; |
| | | barfunc = StatDataTableVo::getOilVolume; |
| | | break; |
| | | case 5 : |
| | | dataList = oilRecordMapper.statFanByOilType(param); |
| | | xfunc = StatDataTableVo::getOilType; |
| | | barfunc = StatDataTableVo::getOilVolume; |
| | | break; |
| | | case 6 : |
| | | dataList = oilRecordMapper.statFanByOilType(param); |
| | | xfunc = StatDataTableVo::getOilType; |
| | | barfunc = StatDataTableVo::getTotalAmount; |
| | | break; |
| | | } |
| | | res = dataTransLists(dataList, xfunc, barfunc, null, "", ""); |
| | |
| | | .minus(timeUnit.value(), ChronoUnit.valueOf(timeUnit.name())) |
| | | .with(timeUnit.initField(), 1); |
| | | LocalDateTime timeLimitRight = LocalDateTime.now().with(timeUnit.initField(), 1); |
| | | log.info("打印时间开始: {}, 打印时间结束: {}", timeLimit.toString(), timeLimitRight.toString()); |
| | | LambdaQueryWrapper wrapper = new LambdaQueryWrapper<OilRecord>() |
| | | .ge(OilRecord::getStartTime, timeLimit.toString()) |
| | | .le(OilRecord::getStartTime, timeLimitRight.toString()) |
| | |
| | | statVo.addAppearCount(1); |
| | | if (record.getBehavior().intValue() == SystemConstant.BEHAVIOR_TYPE_OIL) statVo.addOilCount(1); |
| | | if (record.getBehavior().intValue() == SystemConstant.BEHAVIOR_TYPE_OIL) statVo.addOilVolume(record.getOilVolume()); |
| | | if (record.getBehavior().intValue() == SystemConstant.BEHAVIOR_TYPE_OIL) statVo.addTotalAmount(record.getTotalAmount()); |
| | | statVo.addSumSpand(record.getSpandTime()); |
| | | } |
| | | |
| | |
| | | && (oilRecord.getBehavior() == null || oilRecord.getBehavior().intValue() != SystemConstant.BEHAVIOR_TYPE_OIL)) { |
| | | continue; |
| | | } |
| | | if (trendType == DataStatisReqVo.TrendType.SALES_AMOUNT |
| | | && (oilRecord.getBehavior() == null || oilRecord.getBehavior().intValue() != SystemConstant.BEHAVIOR_TYPE_OIL)) { |
| | | continue; |
| | | } |
| | | Map<String, Object> row = new LinkedHashMap<>(); |
| | | row.put("id", oilRecord.getId()); |
| | | row.put("startTime", oilRecord.getStartTime()); |
| | |
| | | row.put("behaviorText", behaviorText(oilRecord.getBehavior())); |
| | | row.put("oilPosition", oilRecord.getOilPosition()); |
| | | row.put("oilVolume", oilRecord.getOilVolume()); |
| | | row.put("totalAmount", oilRecord.getTotalAmount()); |
| | | row.put("spandTime", oilRecord.getSpandTime()); |
| | | detailList.add(row); |
| | | } |
| | |
| | | String barName, |
| | | String lineName) { |
| | | List xDatas = new ArrayList(); |
| | | List<Integer> barDatas = new ArrayList<>(); |
| | | List<Object> barDatas = new ArrayList<>(); |
| | | List lineDatas = new ArrayList<>(); |
| | | int sum = 0; |
| | | double sum = 0; |
| | | for (E statVo : dataList) { |
| | | Object xData = ""; |
| | | int barData = 0; |
| | | Object barData = 0; |
| | | Object lineData = 0; |
| | | try { |
| | | xData = xDataMapper.apply(statVo); |
| | | barData = Integer.valueOf(barDataMapper.apply(statVo).toString()); |
| | | Object barValue = barDataMapper.apply(statVo); |
| | | if (barValue instanceof java.math.BigDecimal) { |
| | | barData = ((java.math.BigDecimal) barValue).doubleValue(); |
| | | } else { |
| | | barData = Integer.valueOf(barValue.toString()); |
| | | } |
| | | if (lineDataMapper != null) lineData = lineDataMapper.apply(statVo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | xDatas.add(xData); |
| | | barDatas.add(barData); |
| | | lineDatas.add(lineData); |
| | | sum += barData; |
| | | if (barData instanceof Number) { |
| | | sum += ((Number) barData).doubleValue(); |
| | | } |
| | | } |
| | | if (lineDataMapper == null) { |
| | | int finalSum = sum; |
| | | lineDatas = barDatas.stream().map(n -> n*100/ finalSum).collect(Collectors.toList()); |
| | | double finalSum = sum; |
| | | lineDatas = barDatas.stream().map(n -> { |
| | | if (n instanceof Number) { |
| | | return ((Number) n).doubleValue() * 100 / finalSum; |
| | | } |
| | | return 0; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | JSONObject res = new JSONObject(); |
| | | res.put("xData", xDatas); |
| | |
| | | count(if(behavior=1,1,null)) oilCount, |
| | | sum(oil_volume) oilVolume, |
| | | sum(spand_time) sumSpand, |
| | | count(DISTINCT if(behavior=1, r.license_num, null)) onceOilCount |
| | | count(DISTINCT if(behavior=1, r.license_num, null)) onceOilCount, |
| | | sum(if(behavior=1, total_amount, 0)) totalAmount |
| | | from t_oil_record r |
| | | join ( |
| | | select sum(car_count) carCount from t_traffic_flow |
| | |
| | | ) f on m.model_code = f.model_code |
| | | </select> |
| | | |
| | | <select id="statFanByOilType" resultType="com.tievd.jyz.entity.vo.StatDataTableVo" parameterType="com.tievd.jyz.entity.vo.DataStatisReqVo"> |
| | | select |
| | | count(if(behavior=1,1,null)) oilCount, |
| | | sum(oil_volume) oilVolume, |
| | | sum(if(behavior=1, total_amount, 0)) totalAmount, |
| | | oil_type oilType |
| | | from t_oil_record |
| | | <include refid="statRecordCondition" /> |
| | | and oil_type is not null and oil_type != '' |
| | | GROUP BY oil_type |
| | | </select> |
| | | |
| | | <select id="getVehicleFrequencyBeforeActivity" resultType="java.util.Map"> |
| | | SELECT |
| | | COUNT(DISTINCT license_num) as totalVehicles, |