Commit 78e962aa09858d8625f6392612dd5575c9372b4e
1 parent
ea62f287
利润分析接口和首页数据展示接口
Showing
5 changed files
with
19 additions
and
30 deletions
src/main/java/com/order/erp/controller/IndexController.java
@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMapping; | @@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMapping; | ||
12 | import org.springframework.web.bind.annotation.RestController; | 12 | import org.springframework.web.bind.annotation.RestController; |
13 | 13 | ||
14 | import javax.annotation.Resource; | 14 | import javax.annotation.Resource; |
15 | +import java.util.List; | ||
16 | +import java.util.Map; | ||
15 | 17 | ||
16 | /** | 18 | /** |
17 | * @author zhongnanhuang | 19 | * @author zhongnanhuang |
@@ -56,8 +58,6 @@ public class IndexController { | @@ -56,8 +58,6 @@ public class IndexController { | ||
56 | long orderReport = orderCompletionReportService.countByOrderStatus(OrderStatusEnum.REPORT_WAIT_AUDIT.getStatus()); | 58 | long orderReport = orderCompletionReportService.countByOrderStatus(OrderStatusEnum.REPORT_WAIT_AUDIT.getStatus()); |
57 | long orderYearReport = orderCompletionReportService.countYearByOrderStatus(OrderStatusEnum.REPORT_WAIT_AUDIT.getStatus()); | 59 | long orderYearReport = orderCompletionReportService.countYearByOrderStatus(OrderStatusEnum.REPORT_WAIT_AUDIT.getStatus()); |
58 | 60 | ||
59 | - //当天订单数据 | ||
60 | - IndexDataVO.ChartData chartData = orderBaseInfoService.countHoursFromDay(); | ||
61 | 61 | ||
62 | IndexDataVO indexDataVo = new IndexDataVO(); | 62 | IndexDataVO indexDataVo = new IndexDataVO(); |
63 | indexDataVo.setOrderFinishedCount(orderTotalFinished); | 63 | indexDataVo.setOrderFinishedCount(orderTotalFinished); |
@@ -68,8 +68,14 @@ public class IndexController { | @@ -68,8 +68,14 @@ public class IndexController { | ||
68 | indexDataVo.setOrderRecentWeekProfitWaitAuditCount(orderRecentWeekProfitWaitAudit); | 68 | indexDataVo.setOrderRecentWeekProfitWaitAuditCount(orderRecentWeekProfitWaitAudit); |
69 | indexDataVo.setOrderReportWaitAuditCount(orderReport); | 69 | indexDataVo.setOrderReportWaitAuditCount(orderReport); |
70 | indexDataVo.setOrderReportRecentYearWaitAuditCount(orderYearReport); | 70 | indexDataVo.setOrderReportRecentYearWaitAuditCount(orderYearReport); |
71 | - indexDataVo.setChartData(chartData); | ||
72 | 71 | ||
73 | return ServerResult.success(indexDataVo); | 72 | return ServerResult.success(indexDataVo); |
74 | } | 73 | } |
74 | + | ||
75 | + @GetMapping("/chartData") | ||
76 | + public ServerResult getChartData(){ | ||
77 | + //订单趋势数据 | ||
78 | + List<Map<String,Integer>> chartData = orderBaseInfoService.countDaysOrder(); | ||
79 | + return ServerResult.success(chartData); | ||
80 | + } | ||
75 | } | 81 | } |
src/main/java/com/order/erp/domain/vo/IndexDataVO.java
@@ -33,13 +33,4 @@ public class IndexDataVO { | @@ -33,13 +33,4 @@ public class IndexDataVO { | ||
33 | 33 | ||
34 | private Long orderReportRecentYearWaitAuditCount; | 34 | private Long orderReportRecentYearWaitAuditCount; |
35 | 35 | ||
36 | - private ChartData chartData; | ||
37 | - | ||
38 | - @Data | ||
39 | - @AllArgsConstructor | ||
40 | - @NoArgsConstructor | ||
41 | - public static class ChartData{ | ||
42 | - private String[] x;//小时 | ||
43 | - private int[] y;//订单量 | ||
44 | - } | ||
45 | } | 36 | } |
src/main/java/com/order/erp/mapper/order/OrderBaseInfoMapper.java
@@ -7,6 +7,7 @@ import com.order.erp.domain.vo.OrderCountVO; | @@ -7,6 +7,7 @@ import com.order.erp.domain.vo.OrderCountVO; | ||
7 | import org.apache.ibatis.annotations.Select; | 7 | import org.apache.ibatis.annotations.Select; |
8 | 8 | ||
9 | import java.util.List; | 9 | import java.util.List; |
10 | +import java.util.Map; | ||
10 | 11 | ||
11 | /** | 12 | /** |
12 | * 订单基础信息表(OrderBaseInfo)表数据库访问层 | 13 | * 订单基础信息表(OrderBaseInfo)表数据库访问层 |
@@ -20,7 +21,7 @@ public interface OrderBaseInfoMapper extends BaseMapper<OrderBaseInfoDO> { | @@ -20,7 +21,7 @@ public interface OrderBaseInfoMapper extends BaseMapper<OrderBaseInfoDO> { | ||
20 | @Select("SELECT count(*) FROM order_base_info WHERE order_status=#{orderStatus} and DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= date(create_time);") | 21 | @Select("SELECT count(*) FROM order_base_info WHERE order_status=#{orderStatus} and DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= date(create_time);") |
21 | long countRecentMonthByOrderStatus(Integer orderStatus); | 22 | long countRecentMonthByOrderStatus(Integer orderStatus); |
22 | 23 | ||
23 | - @Select("SELECT HOUR(create_time) AS hour, COUNT(*) AS count FROM order_base_info WHERE create_time >= DATE_SUB(NOW(), INTERVAL 1 DAY) GROUP BY HOUR(create_time);") | ||
24 | - List<OrderCountVO> countHoursFromDay(); | 24 | + @Select("SELECT DATE(create_time) AS dateTime, COUNT(*) AS orderCount FROM order_base_info GROUP BY dateTime;") |
25 | + List<Map<String, Integer>> countDaysOrder(); | ||
25 | } | 26 | } |
26 | 27 |
src/main/java/com/order/erp/service/order/OrderBaseInfoService.java
@@ -9,6 +9,8 @@ import com.order.erp.domain.vo.order.*; | @@ -9,6 +9,8 @@ import com.order.erp.domain.vo.order.*; | ||
9 | 9 | ||
10 | import javax.servlet.http.HttpServletResponse; | 10 | import javax.servlet.http.HttpServletResponse; |
11 | import java.io.IOException; | 11 | import java.io.IOException; |
12 | +import java.util.List; | ||
13 | +import java.util.Map; | ||
12 | 14 | ||
13 | /** | 15 | /** |
14 | * 订单基础信息表(OrderBaseInfo)表服务接口 | 16 | * 订单基础信息表(OrderBaseInfo)表服务接口 |
@@ -85,5 +87,6 @@ public interface OrderBaseInfoService extends IService<OrderBaseInfoDO> { | @@ -85,5 +87,6 @@ public interface OrderBaseInfoService extends IService<OrderBaseInfoDO> { | ||
85 | 87 | ||
86 | long countRecentMonthByOrderStatus(Integer orderFinish); | 88 | long countRecentMonthByOrderStatus(Integer orderFinish); |
87 | 89 | ||
88 | - IndexDataVO.ChartData countHoursFromDay(); | 90 | + |
91 | + List<Map<String, Integer>> countDaysOrder(); | ||
89 | } | 92 | } |
src/main/java/com/order/erp/service/order/impl/OrderBaseInfoServiceImpl.java
@@ -616,21 +616,9 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O | @@ -616,21 +616,9 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O | ||
616 | } | 616 | } |
617 | 617 | ||
618 | @Override | 618 | @Override |
619 | - public IndexDataVO.ChartData countHoursFromDay() { | ||
620 | - List<OrderCountVO> orderCountVOS = this.baseMapper.countHoursFromDay(); | ||
621 | - Map<String,Integer> countValueMap = new HashMap<>(); | ||
622 | - if (orderCountVOS!=null&& orderCountVOS.size()>0){ | ||
623 | - for (OrderCountVO orderCountVO : orderCountVOS) { | ||
624 | - countValueMap.put(orderCountVO.getHour(),orderCountVO.getCount()); | ||
625 | - } | ||
626 | - } | ||
627 | - String[] x = new String[24]; | ||
628 | - int[] y = new int[24]; | ||
629 | - for (int i = 0; i < 24; i++) { | ||
630 | - x[i] = i+":00"; | ||
631 | - y[i] = countValueMap.get(i+"")==null?0:countValueMap.get(i+""); | ||
632 | - } | ||
633 | - return new IndexDataVO.ChartData(x,y); | 619 | + public List<Map<String, Integer>> countDaysOrder() { |
620 | + return this.baseMapper.countDaysOrder(); | ||
634 | } | 621 | } |
635 | 622 | ||
623 | + | ||
636 | } | 624 | } |