国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì)

這篇具有很好參考價(jià)值的文章主要介紹了Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

前言

主要是以下四項(xiàng)的統(tǒng)計(jì),以不同形式的圖形進(jìn)行展示
Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts

Apache ECharts

介紹

Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts

Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts

Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts

Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts

入門案例

Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts
自己去網(wǎng)站上看一哈,我不太懂前端

營(yíng)業(yè)額統(tǒng)計(jì)

需求分析

Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts
Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts

代碼開發(fā)

com.sky.controller.admin.ReportController

@RestController
@RequestMapping("/admin/report")
@Api(tags = "數(shù)據(jù)統(tǒng)計(jì)相關(guān)接口")
@Slf4j
public class ReportController {
    @Autowired
    private ReportService reportService;

    /**
     * 營(yíng)業(yè)額統(tǒng)計(jì)
     * @param begin
     * @param end
     * @return
     */
    @GetMapping("/turnoverStatistics")
    @ApiOperation("營(yíng)業(yè)額統(tǒng)計(jì)")
    public Result<TurnoverReportVO> turnoverStatistics(
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
        log.info("營(yíng)業(yè)額數(shù)據(jù)統(tǒng)計(jì):{},{}",begin,end);
        TurnoverReportVO turnoverStatistics = reportService.getTurnoverStatistics(begin,end);
        return Result.success(turnoverStatistics);
    }
}

com.sky.service.impl.ReportServiceImpl.java


@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private OrderMapper orderMapper;
    /**
     * 統(tǒng)計(jì)指定時(shí)間內(nèi)的營(yíng)業(yè)額
     * @param begin
     * @param end
     * @return
     */
    public TurnoverReportVO getTurnoverStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
                                                  @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end) {
        //存放從begin到end的日期
        List<LocalDate> dateList = new ArrayList<>();
        //范圍是[begin,end)
        dateList.add(begin);
        while(!begin.equals(end)){//相同是最后一天,也有isbefore這種方法,注意plusDays是返回值
            begin = begin.plusDays(1);
            dateList.add(begin);
        }

        //存放明天的營(yíng)業(yè)額
        List<Double> turnoverList = new ArrayList<>();

        for (LocalDate date : dateList) {
            //查詢date日期對(duì)應(yīng)的營(yíng)業(yè)額,營(yíng)業(yè)額值 status=已完成 的金額合計(jì)
            LocalDateTime beginOfDay = LocalDateTime.of(date, LocalTime.MIN);
            LocalDateTime endOfDay = LocalDateTime.of(date, LocalTime.MAX);

            //select sum(Amount) from where order_time > ? and order_time < ? and status = 5
            Map map = new HashMap();
            map.put("begin",beginOfDay);
            map.put("end",endOfDay);
            map.put("status", Orders.COMPLETED);
            Double turnover =orderMapper.sumByMap(map);
            turnover = turnover == null ? 0.0 : turnover;
            turnoverList.add(turnover);
        }


        return TurnoverReportVO.builder()
                .dateList(StringUtils.join(dateList,","))
                .turnoverList(StringUtils.join(turnoverList,","))
                .build();
    }
}

orderMapper

    /**
     *  根據(jù)動(dòng)態(tài)條件統(tǒng)計(jì)營(yíng)業(yè)額數(shù)據(jù)
     * @param map
     * @return
     */
    Double sumByMap(Map map);

orderMapper.xml

<select id="sumByMap" resultType="java.lang.Double">
        select sum(amount) from orders
        <where>
            <if test="begin != null">
                and order_time &gt; #{begin}
            </if>
            <if test="end != null">
                and order_time &lt; #{end}
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
        </where>
    </select>

功能測(cè)試

Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts

訂單統(tǒng)計(jì)

需求分析

Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts
Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts

代碼開發(fā)

Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts
Reportcontroller

    /**
     * 統(tǒng)計(jì)訂單
     * @param begin
     * @param end
     * @return
     */
    @GetMapping("/ordersStatistics")
    public Result<OrderReportVO> orderStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
                                                 @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
        log.info("統(tǒng)計(jì)訂單");
        OrderReportVO orderReportVO = reportService.getOrderStatistics(begin,end);
        return Result.success(orderReportVO);
    }

ReportServiceImpl

   /**
     * 統(tǒng)計(jì)訂單數(shù)量
     * @param begin
     * @param end
     * @return
     */
    public OrderReportVO getOrderStatistics(LocalDate begin, LocalDate end) {
        //這個(gè)獲取dateList是相同的,復(fù)制上面的就可以

        //存放從begin到end的日期
        List<LocalDate> dateList = new ArrayList<>();
        //范圍是[begin,end)
        dateList.add(begin);
        while(!begin.equals(end)){//相同是最后一天,也有isbefore這種方法,注意plusDays是返回值
            begin = begin.plusDays(1);
            dateList.add(begin);
        }

        List<Integer> orderCountList = new ArrayList<>();
        List<Integer> validOrderCountList = new ArrayList<>();

        //遍歷dateList查詢有效訂單數(shù)和訂單總數(shù)
        for (LocalDate date : dateList) {
            //查詢每天的訂單數(shù)量 select count(id) from orders where order_time < end and order_time >begin;
            LocalDateTime beginTime = LocalDateTime.of(date, LocalTime.MIN);
            LocalDateTime endTime = LocalDateTime.of(date, LocalTime.MAX);
            Integer orderCount = getOrderCount(beginTime, endTime, null);
            //查詢每天的有效訂單數(shù) select count() from orders where status = 5 and order_time < end and order_time >begin
            Integer validOrderCount = getOrderCount(beginTime, endTime, Orders.COMPLETED);
            orderCountList.add(orderCount);
            validOrderCountList.add(validOrderCount);
        }
        //計(jì)算閉區(qū)間的訂單總數(shù)量
        Integer totalOrderCount = orderCountList.stream().reduce(Integer::sum).get();
        //計(jì)算時(shí)間區(qū)間內(nèi)的有效訂單數(shù)量
        Integer validOrderCount = validOrderCountList.stream().reduce(Integer::sum).get();
        //計(jì)算訂單完成率
        Double orderCompletionRate =  0.0;
        if(totalOrderCount != 0) {
          orderCompletionRate =  validOrderCount.doubleValue() / totalOrderCount;
        }

        return OrderReportVO.builder()
                .dateList(StringUtils.join(dateList,","))
                .orderCountList(StringUtils.join(orderCountList,","))
                .validOrderCountList(StringUtils.join(validOrderCountList,","))
                .validOrderCount(validOrderCount)
                .totalOrderCount(totalOrderCount)
                .orderCompletionRate(orderCompletionRate)
                .build();
    }

    /**
     * 根據(jù)條件統(tǒng)計(jì)訂單數(shù)量
     * @param begin
     * @param end
     * @param status
     * @return
     */
    private Integer getOrderCount(LocalDateTime begin,LocalDateTime end,Integer status){
        Map map = new HashMap();
        map.put("begin",begin);
        map.put("end",end);
        map.put("status",status);
        return orderMapper.countByMap(map);
    }

orderMapper.xml

    <select id="countByMap" resultType="java.lang.Integer">
        select count(id) from orders
        <where>
            <if test="begin != null">
                and order_time &gt; #{begin}
            </if>
            <if test="end != null">
                and order_time &lt; #{end}
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
        </where>
    </select>

功能測(cè)試

Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts

銷量排名統(tǒng)計(jì)

需求分析

Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts
Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts

代碼開發(fā)

Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts
reportController

    /**
     * 銷量排名
     * @param begin
     * @param end
     * @return
     */
    @ApiOperation("銷量排名top10")
    @GetMapping("/top10")
    public Result<SalesTop10ReportVO> top10(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
                                                      @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
        log.info("銷量排名top10:{},{}",begin,end);
        return Result.success(reportService.getSalesTop10(begin,end));
    }

ReportServiceImpl

    /**
     * 統(tǒng)計(jì)銷量排名前十
     * @param begin
     * @param end
     * @return
     */
    public SalesTop10ReportVO getSalesTop10(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
                                            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end) {
        //select od.name,sum(od.number) number from order_detail od,orders o where od.order_id = o.id
        // and o.status = 5 and o.order_time > ? and o.order_time < ?
        //group by od.name order by number desc
        //limit 0,10
        LocalDateTime beginOfDay = LocalDateTime.of(begin, LocalTime.MIN);
        LocalDateTime endOfDay = LocalDateTime.of(end, LocalTime.MAX);

        List<GoodsSalesDTO> salesTop10 = orderMapper.getSalesTop10(beginOfDay, endOfDay);

        List<String> names = salesTop10.stream().map(GoodsSalesDTO::getName).collect(Collectors.toList());
        String nameList = StringUtils.join(names, ",");
        List<Integer> numbers = salesTop10.stream().map(GoodsSalesDTO::getNumber).collect(Collectors.toList());
        String numberList = StringUtils.join(numbers, ",");


        return SalesTop10ReportVO.builder()
                .nameList(nameList)
                .numberList(numberList)
                .build();
    }

orderMapper.xml

    <select id="getSalesTop10" resultType="com.sky.dto.GoodsSalesDTO">
        select od.name,sum(od.number) number
        from order_detail od,orders o
        where od.order_id = o.id and o.status = 5
        <if test="begin != null">
        and o.order_time &gt; #{begin}
        </if>
        <if test="end != null">
        and o.order_time &lt; #{end}
        </if>
        group by od.name
        order by number desc
        limit 0,10
    </select>

功能測(cè)試

Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì),項(xiàng)目記錄,java,apache,echarts文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-707293.html

到了這里,關(guān)于Java項(xiàng)目-蒼穹外賣-Day11-Apache ECharts數(shù)據(jù)統(tǒng)計(jì)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 【學(xué)習(xí)筆記】java項(xiàng)目—蒼穹外賣day11

    【學(xué)習(xí)筆記】java項(xiàng)目—蒼穹外賣day11

    Apache ECharts 營(yíng)業(yè)額統(tǒng)計(jì) 用戶統(tǒng)計(jì) 訂單統(tǒng)計(jì) 銷量排名Top10 功能實(shí)現(xiàn): 數(shù)據(jù)統(tǒng)計(jì) 數(shù)據(jù)統(tǒng)計(jì)效果圖: 1.1 介紹 Apache ECharts 是一款基于 Javascript 的數(shù)據(jù)可視化圖表庫(kù),提供直觀,生動(dòng),可交互,可個(gè)性化定制的數(shù)據(jù)可視化圖表。 官網(wǎng)地址:https://echarts.apache.org/zh/index.html 常見(jiàn)效果

    2024年04月09日
    瀏覽(29)
  • 項(xiàng)目實(shí)戰(zhàn)————蒼穹外賣(DAY11)

    項(xiàng)目實(shí)戰(zhàn)————蒼穹外賣(DAY11)

    Apache ECharts 營(yíng)業(yè)額統(tǒng)計(jì) 用戶統(tǒng)計(jì) 訂單統(tǒng)計(jì) 銷量排名Top10 功能實(shí)現(xiàn): 數(shù)據(jù)統(tǒng)計(jì) 數(shù)據(jù)統(tǒng)計(jì)效果圖: 1.1 介紹 Apache ECharts 是一款基于 Javascript 的數(shù)據(jù)可視化圖表庫(kù),提供直觀,生動(dòng),可交互,可個(gè)性化定制的數(shù)據(jù)可視化圖表。 官網(wǎng)地址:Apache ECharts 常見(jiàn)效果展示: 1). 柱形圖

    2024年01月20日
    瀏覽(25)
  • Java項(xiàng)目-蒼穹外賣-Day10-SpirngTask及WebSocket

    Java項(xiàng)目-蒼穹外賣-Day10-SpirngTask及WebSocket

    本章實(shí)現(xiàn)的業(yè)務(wù)功能 超時(shí)未支付訂單自動(dòng)取消,配送中訂單商家忘點(diǎn)完成自動(dòng)再固定時(shí)間檢查且修改成完成狀態(tài) 來(lái)單提醒功能 催單提醒功能 一般的話周幾和第幾日是不能同時(shí)出現(xiàn)的 因?yàn)楸热?4月15日 周四 可能4月15日不是周四 可能沖突的 所以周和日一般只能有一個(gè) 現(xiàn)在有

    2024年02月09日
    瀏覽(18)
  • 蒼穹外賣day11筆記

    蒼穹外賣day11筆記

    今日首先介紹前端技術(shù)Apache ECharts,說(shuō)明后端需要準(zhǔn)備的數(shù)據(jù),然后講解具體統(tǒng)計(jì)功能的實(shí)現(xiàn),包括營(yíng)業(yè)額統(tǒng)計(jì)、用戶統(tǒng)計(jì)、訂單統(tǒng)計(jì)、銷量排名。 ECharts是一款基于 Javascript 的數(shù)據(jù)可視化圖表庫(kù)。我們用它來(lái)展示圖表數(shù)據(jù)。 步驟 1). 引入echarts.js 文件 2). 為 ECharts 準(zhǔn)備一個(gè)設(shè)

    2024年02月13日
    瀏覽(25)
  • 《蒼穹外賣》知識(shí)梳理P11-Apache POI導(dǎo)出報(bào)表

    《蒼穹外賣》知識(shí)梳理P11-Apache POI導(dǎo)出報(bào)表

    可以通過(guò)Apache POI處理excel文件,核心操作是讀和寫 應(yīng)用場(chǎng)景 銀行網(wǎng)銀交易明細(xì) 各種業(yè)務(wù)系統(tǒng)導(dǎo)出Excel報(bào)表 批量導(dǎo)入業(yè)務(wù)數(shù)據(jù) 使用步驟 1.導(dǎo)入maven坐標(biāo) 2.測(cè)試代碼(寫操作) 3.運(yùn)行結(jié)果(寫操作) 4.測(cè)試代碼(讀操作) 5.運(yùn)行結(jié)果(讀操作) 由于實(shí)際業(yè)務(wù)中可能會(huì)有復(fù)雜的報(bào)

    2024年02月19日
    瀏覽(20)
  • 蒼穹外賣day02項(xiàng)目日志

    蒼穹外賣day02項(xiàng)目日志

    參考產(chǎn)品原型,設(shè)計(jì)表和接口。 1.1.1設(shè)計(jì)表 看員工管理的產(chǎn)品原型: 有員工姓名、賬號(hào)、手機(jī)號(hào)、賬號(hào)狀態(tài)、最后操作時(shí)間等。 注意,操作一欄不是字段,其中的啟用禁用才是。 再看添加員工的原型: ?可以發(fā)現(xiàn)還有性別和身份證號(hào)。 不要忘了旁邊: 還有密碼。 總結(jié)出了

    2024年02月14日
    瀏覽(26)
  • SpringBoot+SSM項(xiàng)目實(shí)戰(zhàn) 蒼穹外賣(12) Apache POI

    SpringBoot+SSM項(xiàng)目實(shí)戰(zhàn) 蒼穹外賣(12) Apache POI

    繼續(xù)上一節(jié)的內(nèi)容,本節(jié)是蒼穹外賣后端開發(fā)的最后一節(jié),本節(jié)學(xué)習(xí)Apache POI,完成工作臺(tái)、數(shù)據(jù)導(dǎo)出功能。 工作臺(tái)是系統(tǒng)運(yùn)營(yíng)的數(shù)據(jù)看板,并提供快捷操作入口,可以有效提高商家的工作效率。 工作臺(tái)展示的數(shù)據(jù):今日數(shù)據(jù)、訂單管理、菜品總覽、套餐總覽、訂單信息 營(yíng)業(yè)

    2024年01月16日
    瀏覽(23)
  • itheima蒼穹外賣項(xiàng)目學(xué)習(xí)筆記--Day9: 訂單模塊

    (1). 查詢歷史訂單 在OrderController中,創(chuàng)建查詢方法 在OrderServiceImpl中,創(chuàng)建分頁(yè)查詢方法,及其父類接口 在OrderMapper中,添加查詢方法,并在映射文件中寫入動(dòng)態(tài)SQL語(yǔ)句 在OrderDetailMapper中,實(shí)現(xiàn)根據(jù)訂單id查詢訂單明細(xì) (2). 查詢訂單詳細(xì) 在OrderController中,創(chuàng)建查詢訂單詳細(xì)方

    2024年02月16日
    瀏覽(184)
  • itheima蒼穹外賣項(xiàng)目學(xué)習(xí)筆記--Day1:項(xiàng)目介紹與開發(fā)環(huán)境搭建

    itheima蒼穹外賣項(xiàng)目學(xué)習(xí)筆記--Day1:項(xiàng)目介紹與開發(fā)環(huán)境搭建

    (1). 前端環(huán)境搭建 前端工程基于 nginx 運(yùn)行 啟動(dòng)nginx:雙擊 nginx.exe 即可啟動(dòng) nginx 服務(wù),訪問(wèn)端口號(hào)為 80 (2). 后端環(huán)境搭建 后端工程基于 maven 進(jìn)行項(xiàng)目構(gòu)建,并且進(jìn)行分模塊開發(fā) (3). 前后端聯(lián)調(diào) 修改數(shù)據(jù)庫(kù)中明文密碼,改為MD5加密后的密文 修改Java代碼,前端提交的密碼進(jìn)行

    2024年02月15日
    瀏覽(28)
  • 蒼穹外賣集成 Apache POI Java實(shí)現(xiàn)Excel文件的讀寫下載

    蒼穹外賣集成 Apache POI Java實(shí)現(xiàn)Excel文件的讀寫下載

    Apache POI - the Java API for Microsoft Documents Project News 16 September 2022 - POI 5.2.3 available The Apache POI team is pleased to announce the release of 5.2.3. Several dependencies were updated to their latest versions to pick up security fixes and other improvements. A summary of changes is available in the Release Notes. A full list of changes is a

    2024年02月09日
    瀏覽(31)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包