From 3884696c7d9d8f174ee34fe06a3d9090cb62bb5c Mon Sep 17 00:00:00 2001 From: Strange <3304393868@qq.com> Date: Tue, 13 Feb 2024 20:42:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=BE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + RuoYi-Vue/pom.xml | 2 + RuoYi-Vue/ruoyi-admin/pom.xml | 6 ++- .../com/ruoyi/web/controller/chart/chat.java | 39 ++++++++++++++++ .../src/main/resources/application-druid.yml | 2 +- .../src/main/resources/application.yml | 7 +++ .../main/resources/templates/polyline.html | 46 +++++++++++++++++++ RuoYi-Vue/ruoyi-homejizhang/pom.xml | 1 + .../ruoyi/app/system/domain/ChatDomain.java | 35 ++++++++++++++ .../ruoyi/app/system/mapper/ChatMapper.java | 19 ++++++++ 10 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/chart/chat.java create mode 100644 RuoYi-Vue/ruoyi-admin/src/main/resources/templates/polyline.html create mode 100644 RuoYi-Vue/ruoyi-homejizhang/src/main/java/com/ruoyi/app/system/domain/ChatDomain.java create mode 100644 RuoYi-Vue/ruoyi-homejizhang/src/main/java/com/ruoyi/app/system/mapper/ChatMapper.java diff --git a/.gitignore b/.gitignore index 3ef92c4..d38b47f 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,4 @@ nbdist/ !*/build/*.java !*/build/*.html !*/build/*.xml + diff --git a/RuoYi-Vue/pom.xml b/RuoYi-Vue/pom.xml index df0e5ca..208eeab 100644 --- a/RuoYi-Vue/pom.xml +++ b/RuoYi-Vue/pom.xml @@ -177,6 +177,8 @@ ${ruoyi.version} + + diff --git a/RuoYi-Vue/ruoyi-admin/pom.xml b/RuoYi-Vue/ruoyi-admin/pom.xml index b021fcc..3f51442 100644 --- a/RuoYi-Vue/ruoyi-admin/pom.xml +++ b/RuoYi-Vue/ruoyi-admin/pom.xml @@ -64,7 +64,11 @@ com.ruoyi ruoyi-generator - + + + org.springframework.boot + spring-boot-starter-thymeleaf + diff --git a/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/chart/chat.java b/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/chart/chat.java new file mode 100644 index 0000000..555bad4 --- /dev/null +++ b/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/chart/chat.java @@ -0,0 +1,39 @@ +package com.ruoyi.web.controller.chart; + +import com.ruoyi.app.system.domain.ChatDomain; +import com.ruoyi.app.system.mapper.ChatMapper; +import com.ruoyi.common.annotation.Anonymous; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +@Controller +@Anonymous +@RequestMapping("/chat") +public class chat { + + @Resource + private ChatMapper chatMapper; + + + @GetMapping("/PolylineChat") +// @ResponseBody + public String Polyline(Model model){ + List dataList = chatMapper.pyline(); + List moneyList = new ArrayList<>(); + List monthList = new ArrayList<>(); + for (ChatDomain chatDomain:dataList){ + moneyList.add(chatDomain.getTotal_money()); + monthList.add(chatDomain.getMonth()); + } + model.addAttribute("moneyList",moneyList); + model.addAttribute("monthList",monthList); + return "/polyline"; + } +} diff --git a/RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml b/RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml index c6f21e5..7b28d9e 100644 --- a/RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml +++ b/RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml @@ -8,7 +8,7 @@ spring: master: url: jdbc:mysql://localhost:3306/jizhang?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root - password: jieyi123 + password: 336699 # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/RuoYi-Vue/ruoyi-admin/src/main/resources/application.yml b/RuoYi-Vue/ruoyi-admin/src/main/resources/application.yml index 0fcb0e7..74e961e 100644 --- a/RuoYi-Vue/ruoyi-admin/src/main/resources/application.yml +++ b/RuoYi-Vue/ruoyi-admin/src/main/resources/application.yml @@ -60,11 +60,18 @@ spring: max-file-size: 10MB # 设置总上传的文件大小 max-request-size: 20MB + thymeleaf: + cache: false + prefix: classpath:/templates/ + encoding: UTF-8 #编码 + suffix: .html #模板后缀 + mode: HTML #模板 # 服务模块 devtools: restart: # 热部署开关 enabled: true + # redis 配置 redis: # 地址 diff --git a/RuoYi-Vue/ruoyi-admin/src/main/resources/templates/polyline.html b/RuoYi-Vue/ruoyi-admin/src/main/resources/templates/polyline.html new file mode 100644 index 0000000..4ae2302 --- /dev/null +++ b/RuoYi-Vue/ruoyi-admin/src/main/resources/templates/polyline.html @@ -0,0 +1,46 @@ + + + + + + Line Chart + + + + + + + + + + diff --git a/RuoYi-Vue/ruoyi-homejizhang/pom.xml b/RuoYi-Vue/ruoyi-homejizhang/pom.xml index 1791678..c5d8aa9 100644 --- a/RuoYi-Vue/ruoyi-homejizhang/pom.xml +++ b/RuoYi-Vue/ruoyi-homejizhang/pom.xml @@ -24,5 +24,6 @@ com.ruoyi ruoyi-system + diff --git a/RuoYi-Vue/ruoyi-homejizhang/src/main/java/com/ruoyi/app/system/domain/ChatDomain.java b/RuoYi-Vue/ruoyi-homejizhang/src/main/java/com/ruoyi/app/system/domain/ChatDomain.java new file mode 100644 index 0000000..32c1e76 --- /dev/null +++ b/RuoYi-Vue/ruoyi-homejizhang/src/main/java/com/ruoyi/app/system/domain/ChatDomain.java @@ -0,0 +1,35 @@ +package com.ruoyi.app.system.domain; + + +import java.math.BigDecimal; +public class ChatDomain { + private Integer id; + + private BigDecimal total_money; + + private Integer month; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public BigDecimal getTotal_money() { + return total_money; + } + + public void setTotal_money(BigDecimal total_money) { + this.total_money = total_money; + } + + public Integer getMonth() { + return month; + } + + public void setMonth(Integer month) { + this.month = month; + } +} diff --git a/RuoYi-Vue/ruoyi-homejizhang/src/main/java/com/ruoyi/app/system/mapper/ChatMapper.java b/RuoYi-Vue/ruoyi-homejizhang/src/main/java/com/ruoyi/app/system/mapper/ChatMapper.java new file mode 100644 index 0000000..964ab94 --- /dev/null +++ b/RuoYi-Vue/ruoyi-homejizhang/src/main/java/com/ruoyi/app/system/mapper/ChatMapper.java @@ -0,0 +1,19 @@ +package com.ruoyi.app.system.mapper; + +import com.ruoyi.app.system.domain.ChatDomain; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + + +@Mapper +public interface ChatMapper { + + @Select("SELECT SUM(money) AS total_money, month \n" + + "FROM accounttb \n" + + "WHERE `month` IS NOT NULL\n" + + "GROUP BY month \n" + + "ORDER BY month;\n") + public List pyline(); +}