Compare commits

...

No commits in common. 'main' and 'master' have entirely different histories.
main ... master

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ApifoxUploaderProjectSetting">
<option name="apiAccessToken" value="APS-jypWPSEx9vrD2XNCHYYQnIv8CAFfmMum" />
</component>
</project>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="exercise" />
</profile>
</annotationProcessing>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="exercise" options="-parameters" />
</option>
</component>
</project>

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="远程mysql数据库" uuid="8a8ed4eb-9b24-489c-b26e-b4705aafb513">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<imported>true</imported>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://47.122.61.54:3306/?useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=false&amp;serverTimezone=UTC</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -1,2 +1,4 @@
# exercise_back
# 解析excel 然后设置定时任务发送给前端消息内容
使用websocket和前端进行连接 websocket地址
ws://localhost:8080/exercise
# 这个行的顺序是从0开始的

@ -0,0 +1,277 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.gary</groupId>
<artifactId>exercise-vision</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>体育直播可视化系统</name>
<packaging>jar</packaging>
<properties>
<java.version>17</java.version>
<jjwt.version>0.11.5</jjwt.version>
<spring.version>6.0.0</spring.version>
</properties>
<dependencies>
<!-- Spring Boot Web Starter -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Apache POI Dependency for Excel file handling -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<!-- Spring Boot Starter Data JPA -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- Spring Boot Mail Starter -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!-- Redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- MyBatis Plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
<version>3.5.7</version>
</dependency>
<!-- MySQL Connector -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
<!-- PDFBox for PDF creation -->
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.28</version>
</dependency>
<!-- JWT Dependencies -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>${jjwt.version}</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>${jjwt.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>${jjwt.version}</version>
<scope>runtime</scope>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.34</version>
<scope>provided</scope>
</dependency>
<!-- Spring Boot Test Dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mssqlserver</artifactId>
<scope>test</scope>
</dependency>
<!-- SpringDoc OpenAPI -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.2.0</version>
</dependency>
<!-- Other dependencies -->
<dependency>
<groupId>com.baidubce</groupId>
<artifactId>qianfan</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>8.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>com.github.chrislusf</groupId>
<artifactId>seaweedfs-client</artifactId>
<version>3.55</version>
</dependency>
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.5.5</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.5.0</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<version>3.0.0</version>
</dependency>
<!-- JSON Processing -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.78</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>3.2.6</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.17</version>
</dependency>
<!-- Tomcat Embed Core -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>10.1.26</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
</plugins>
</build>
</project>

@ -0,0 +1,13 @@
package com.gary.exercise;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ExerciseApplication {
public static void main(String[] args) {
SpringApplication.run(ExerciseApplication.class, args);
}
}

@ -0,0 +1,20 @@
package com.gary.exercise.config;
import cn.hutool.core.io.resource.ClassPathResource;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
/**
*
*/
@Data
@Component
@ConfigurationProperties(prefix ="excel" )
public class FileConfig {
private final String fileName="exercise.xlsx";
private final String sheetNumber="Sheet1";
private final String filePath=new ClassPathResource(fileName).getFile().getAbsolutePath();
}

@ -0,0 +1,28 @@
package com.gary.exercise.config;
import com.gary.exercise.service.ExerciseService;
import com.gary.exercise.socket.ExerciseWebSocketHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
/**
* websocket
*/
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
private final ExerciseService exerciseService;
public WebSocketConfig(ExerciseService exerciseService) {
this.exerciseService = exerciseService;
}
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
// 注册 WebSocket 的处理器
registry.addHandler(new ExerciseWebSocketHandler(exerciseService), "/exercise") // 定义路径 /exercise
.setAllowedOrigins("*"); // 设置允许的跨域请求
}
}

@ -0,0 +1,4 @@
package com.gary.exercise.controller;
public class ExerciseController {
}

@ -0,0 +1,4 @@
package com.gary.exercise.controller;
public class TestController {
}

@ -0,0 +1,19 @@
package com.gary.exercise.dto;
import cn.hutool.json.JSONUtil;
import lombok.Data;
/**
*
*/
@Data
public class ActionDto {
private String leftMinute;
private String leftSecond;
private String whichTeamAttack;
private int lakerScore;
private int wolfScore;
private String action;
private String getScoreType;
private Boolean isGetSocre;
}

@ -0,0 +1,19 @@
package com.gary.exercise.dto;
import lombok.Data;
/**
*
*/
@Data
public class GameEvent {
private String classMessage;//节数信息
LeftTime time;//剩余时间
ActionDto lakerActionDto;//湖人队动作
ActionDto wolvesActionDto;//森林狼队动作
}

@ -0,0 +1,20 @@
package com.gary.exercise.dto;
import lombok.Data;
/**
*
*/
@Data
public class Human {
private String name; //姓名
private int points; // 得分
private int rebounds; // 篮板
private int assists; // 助攻
private int blocks; // 盖帽
private int steals; // 抢断
private int fouls; // 犯规
private int twoPoints; // 2分球数
private int threePoints; // 3分球数
private int freeThrows; // 罚球数
}

@ -0,0 +1,13 @@
package com.gary.exercise.dto;
import lombok.Data;
/**
*
*/
@Data
public class LeftTime {
int minute;
int second;
}

@ -0,0 +1,12 @@
package com.gary.exercise.dto;
import lombok.Data;
@Data
public class ScoreDto {
private int laker_score;//湖人对比分
private int wolf_score;//森林狼队比分
}

@ -0,0 +1,34 @@
package com.gary.exercise.enums;
import lombok.Data;
import java.util.Arrays;
public enum LakerPlayer {
AUSTIN_REAVES("奥斯汀-里维斯"),
DANGELO_RUSSELL("德安杰洛-拉塞尔"),
LEBRON_JAMES("勒布朗-詹姆斯"),
RUI_HACHIMURA("八村塁"),
ANTHONY_DAVIS("安东尼-戴维斯"),
GABE_VINCENT("盖布文森特"),
TORIAN_PRINCE("道尔顿-克内克特"),
MAXWELL_HEIDT("马克斯-克里斯蒂"),
BRONNY_JAMES("布朗尼-詹姆斯");
private final String chineseName;
LakerPlayer(String chineseName) {
this.chineseName = chineseName;
}
public String getChineseName() {
return chineseName;
}
public static LakerPlayer searchLakerPlayerFormText(String text) {
return Arrays.stream(values())
.filter(player -> text.contains(player.getChineseName()))
.findFirst()
.orElse(null); // 返回 null 表示未找到匹配项
}
}

@ -0,0 +1,4 @@
package com.gary.exercise.enums;
public class WolfPlayer {
}

@ -0,0 +1,7 @@
package com.gary.exercise.exception;
public class ReadExcelException extends RuntimeException{
public ReadExcelException(String message) {
super(message);
}
}

@ -0,0 +1,75 @@
package com.gary.exercise.service;
import com.gary.exercise.dto.ActionDto;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public interface ExerciseService {
/**
*0
*/
List<String> readRow( int rowIndex) throws IOException;
/**
*
*/
Map<String, String> processRow(int rowIndex) throws IOException;
/**
*
*/
String getLakerAction(ArrayList<String> rowData);
/**
*
*/
String getWolfAction(ArrayList<String> rowData);
/**
* 1 0 rowIndex
*/
String getActionTeam(int rowIndex) throws IOException;
/**
*
*/
String getLeftMinute(int rowIndex) throws IOException;
/**
*
*/
String getLeftSecond(int rowIndex) throws IOException;
/**
*
*/
ActionDto getResult(int rowIndex) throws IOException;
/**
*
*/
int getLakerScore(int rowIndex) throws IOException;
/**
*
*/
int getWolfScore(int rowIndex) throws IOException;
/**
*
*/
String getScoreType(int rowIndex) throws IOException;
/**
*
*/
Boolean isGetScore(int rowIndex) throws IOException;
/**
*action
*/
String getAction(int rowIndex) throws IOException;
}

@ -0,0 +1,300 @@
package com.gary.exercise.service.impl;
import com.gary.exercise.config.FileConfig;
import com.gary.exercise.dto.ActionDto;
import com.gary.exercise.service.ExerciseService;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class ExerciseServiceImpl implements ExerciseService {
private final FileConfig fileConfig;
public ExerciseServiceImpl(FileConfig fileConfig) {
this.fileConfig = fileConfig;
}
/**
*
*/
private String getCellValue(Cell cell) {
if (cell == null) {
return "";
}
return switch (cell.getCellType()) {
case STRING -> cell.getStringCellValue();
case BOOLEAN -> String.valueOf(cell.getBooleanCellValue());
case FORMULA -> cell.getCellFormula();
case BLANK -> "";
case NUMERIC -> {
// 检查是否为日期格式
if (DateUtil.isCellDateFormatted(cell)) {
// 将日期格式化为字符串
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm");
yield dateFormat.format(cell.getDateCellValue());
} else {
// 处理数字类型
yield String.valueOf(cell.getNumericCellValue());
}
}
default -> "UNKNOWN";
};
}
/**
* Excel 使List
*
* @param rowIndex 0
* @return
* @throws IOException
*/
@Override
public List<String> readRow(int rowIndex) throws IOException {
List<String> rowData = new ArrayList<>();
String filePath = fileConfig.getFilePath();
String sheetName = fileConfig.getSheetNumber();
try (FileInputStream fileInputStream = new FileInputStream(new File(filePath));
Workbook workbook = new XSSFWorkbook(fileInputStream)) {
Sheet sheet = workbook.getSheet(sheetName);
if (sheet == null) {
throw new IllegalArgumentException("Sheet " + sheetName + " does not exist.");
}
Row row = sheet.getRow(rowIndex);
if (row == null) {
throw new IllegalArgumentException("Row " + rowIndex + " does not exist.");
}
for (Cell cell : row) {
rowData.add(getCellValue(cell));
}
}
return rowData;
}
@Override
public Map<String, String> processRow(int rowIndex) throws IOException {
return Map.of();
}
@Override
public String getLakerAction(ArrayList<String> rowData) {
if (rowData.size() != 4)
return null;//说明表示第一节 第二节 没有数据
else {
if (rowData.get(3).isEmpty() && rowData.get(1).isEmpty()) {
//第一行和第二行的数据都是空 说明没有动作
return null;
}
return rowData.get(1);//直接返回第一行的数据
}
}
@Override
public String getWolfAction(ArrayList<String> rowData) {
if (rowData.size() != 4)
return null;//说明表示第一节 第二节 没有数据
else {
if (rowData.get(3).isEmpty() && rowData.get(2).isEmpty()) {
//第一行和第二行的数据都是空 说明没有动作
return null;
}
return rowData.get(3);//直接返回第三行的数据
}
}
@Override
public String getActionTeam(int rowIndex) throws IOException {
ArrayList<String> rowData = (ArrayList<String>) this.readRow(rowIndex);
String lakerAction = this.getLakerAction(rowData);
System.out.println(lakerAction);
String wolfAction = this.getWolfAction(rowData);
System.out.println(wolfAction);
if(Objects.equals(lakerAction, " ") &&!wolfAction.isEmpty()){
return "wolf";
}else if (!lakerAction.isEmpty()&& Objects.equals(wolfAction, " ")){
return "laker";
}
return "null";
}
/**
*
*
* @param rowIndex
*/
@Override
public String getLeftMinute(int rowIndex) throws IOException {
ArrayList<String> rowData = (ArrayList<String>) this.readRow(rowIndex);
String time = rowData.get(0); // 假设时间在第一列
String minute = "";
// 使用 ":" 分割时间字符串
String[] parts = time.split(":");
if (parts.length > 0) {
minute = parts[0]; // 提取分钟部分
}
return minute; // 返回分钟
}
/**
*
*
* @param rowIndex
*/
@Override
public String getLeftSecond(int rowIndex) throws IOException {
ArrayList<String> rowData = (ArrayList<String>) this.readRow(rowIndex);
String time = rowData.get(0); // 假设时间在第一列
String second = "";
// 使用 ":" 分割时间字符串
String[] parts = time.split(":");
if (parts.length > 1) {
second = parts[1]; // 提取秒数部分
}
return second; // 返回秒数
}
/**
*
*
* @param rowIndex
*/
@Override
public ActionDto getResult(int rowIndex) throws IOException {
ActionDto actionDto = new ActionDto();
String leftMinute = this.getLeftMinute(rowIndex);
System.out.println(leftMinute);
String leftSecond = this.getLeftSecond(rowIndex);
System.out.println(leftSecond);
String whichTeamAttack = this.getActionTeam(rowIndex);
System.out.println(whichTeamAttack);
String action = this.getLakerAction((ArrayList<String>) this.readRow(rowIndex));
System.out.println(action);
int lakerScore=this.getLakerScore(rowIndex);
System.out.println(lakerScore);
int wolfScore=this.getWolfScore(rowIndex);
System.out.println(wolfScore);
String getScoreType = this.getScoreType(rowIndex);
System.out.println(getScoreType);
Boolean isGetSocre = this.isGetScore(rowIndex);
System.out.println(isGetSocre);
actionDto.setIsGetSocre(isGetSocre);
actionDto.setGetScoreType(getScoreType);
actionDto.setLakerScore(lakerScore);
actionDto.setWolfScore(wolfScore);
actionDto.setLeftMinute(leftMinute);
actionDto.setLeftSecond(leftSecond);
actionDto.setWhichTeamAttack(whichTeamAttack);
actionDto.setAction(action);
System.out.println(actionDto);
return actionDto;
}
/**
*
*
* @param rowIndex
*/
@Override
public int getLakerScore(int rowIndex) throws IOException {
List<String> rowData = this.readRow(rowIndex); // 读取 Excel 数据
System.out.println(rowData);
String data=rowData.get(2);
System.out.println(data);
// 使用 "- 分割时间字符串
String[] parts = data.split("-");
if (parts.length > 1) {
return Integer.parseInt(parts[0]); // 提取湖人队比分
}
return 0;
}
/**
*
*
* @param rowIndex
*/
@Override
public int getWolfScore(int rowIndex) throws IOException {
List<String> rowData = this.readRow(rowIndex); // 读取 Excel 数据
System.out.println(rowData);
String data=rowData.get(2);
System.out.println(data);
// 使用 "- 分割时间字符串
String[] parts = data.split("-");
if (parts.length > 1) {
return Integer.parseInt(parts[1]); // 提取森林狼队比分
}
return 0;
}
/**
*
*
*/
@Override
public String getScoreType(int rowIndex) throws IOException {
String action = this.getAction(rowIndex);
// 检查是否包含 "三分" 或 "两分"
if (action.contains("三分")) {
return "三分";
} else if (action.contains("两分")) {
return "两分"; // 如果有明确的两分投篮
}
// 其他得分类型
if (action.contains("篮板")) {
return "篮板";
} else if (action.contains("抢断")) {
return "抢断";
} else if (action.contains("罚球")) {
return "罚球";
} else if (action.contains("盖帽")) {
return "盖帽";
} else if (action.contains("犯规")) {
return "犯规";
}
return "未知"; // 如果没有匹配的类型
}
/**
*
*
*/
@Override
public Boolean isGetScore(int rowIndex) throws IOException {
String action = this.getAction(rowIndex);
return action.contains("命中") && !action.contains("不中");
}
/**
* action
*
* @param rowIndex
*/
@Override
public String getAction(int rowIndex) throws IOException {
String whichTeamAttack = this.getActionTeam(rowIndex);
if (whichTeamAttack.equals("laker")) {
return this.getLakerAction((ArrayList<String>) this.readRow(rowIndex));
}else if (whichTeamAttack.equals("wolf")) {
return this.getWolfAction((ArrayList<String>) this.readRow(rowIndex));
}
else return "";
}
}

@ -0,0 +1,137 @@
package com.gary.exercise.socket;
import com.gary.exercise.service.ExerciseService;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.socket.*;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
public class ExerciseWebSocketHandler implements WebSocketHandler {
private static final Logger log = LoggerFactory.getLogger(ExerciseWebSocketHandler.class);
private final ExerciseService exerciseService;
//存储webSocket的消息对话ID
private static final ConcurrentHashMap<String, WebSocketSession> sessions = new ConcurrentHashMap<>();
public ExerciseWebSocketHandler(ExerciseService exerciseService) {
this.exerciseService = exerciseService;
}
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
// 当连接建立时触发
String sessionId = session.getId();
sessions.put(sessionId, session);
System.out.println("WebSocket连接已建立: " + sessionId);
// 发送欢迎消息
session.sendMessage(new TextMessage("欢迎连接到 WebSocket 服务,您的会话 ID 是: " + sessionId));
}
@Override
public void handleMessage(@NotNull WebSocketSession session, @NotNull WebSocketMessage<?> message) throws Exception {
if (message instanceof TextMessage) {
// 接收客户端的消息
String clientMessage = ((TextMessage) message).getPayload();
System.out.println("收到消息: " + clientMessage);
if(clientMessage.equals("可以发送消息!!!")){
// 启动一个线程来每秒发送一行数据
new Thread(() -> {
try {
int rowIndex = 0; // 从第 0 行开始
while (true) {
List<String> rowData = exerciseService.readRow(rowIndex); // 读取 Excel 数据
String rowString = String.join(", ", rowData); // 格式化为字符串
session.sendMessage(new TextMessage(rowString)); // 发送给客户端
rowIndex++; // 移动到下一行
Thread.sleep(3000); // 每秒发送一次
// 停止条件:到达 Excel 文件的末尾
if (rowData.isEmpty()) {
session.sendMessage(new TextMessage("已到达文件末尾"));
break;
}
}
} catch (Exception e) {
log.error("发生错误: {}", e.getMessage());
try {
session.sendMessage(new TextMessage("发生错误: " + e.getMessage()));
} catch (IOException ioException) {
log.error("发生错误: {}", e.getMessage());
}
}
}).start();
}
} else {
System.out.println("不支持的消息类型: " + message.getClass().getName());
}
}
@Override
public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
// 处理传输错误
String sessionId = session.getId();
System.out.println("WebSocket 传输错误Session ID: " + sessionId + ", 错误: " + exception.getMessage());
// 关闭会话
if (session.isOpen()) {
session.close(CloseStatus.SERVER_ERROR);
}
// 从存储中移除会话
sessions.remove(sessionId);
}
@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
// 当连接关闭时触发
String sessionId = session.getId();
System.out.println("WebSocket连接已关闭Session ID: " + sessionId + ", 状态: " + closeStatus);
// 从存储中移除会话
sessions.remove(sessionId);
}
@Override
public boolean supportsPartialMessages() {
// 不支持部分消息
return false;
}
// 广播消息给所有连接的客户端
public void broadcastMessage(String message) {
for (WebSocketSession session : sessions.values()) {
if (session.isOpen()) {
try {
session.sendMessage(new TextMessage(message));
} catch (IOException e) {
System.out.println("广播消息失败Session ID: " + session.getId() + ", 错误: " + e.getMessage());
}
}
}
}
}

@ -0,0 +1,15 @@
server:
port: 9090
# 数据库
spring:
datasource:
url: jdbc:mysql://47.122.61.54:3306/nba_visualization?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC
username: root
password: GHLgjw168168+
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
max-lifetime: 27000000 # 7.5 小时(毫秒)

Binary file not shown.

@ -0,0 +1,37 @@
package com.gary.exercise;
import com.gary.exercise.config.FileConfig;
import com.gary.exercise.dto.ActionDto;
import com.gary.exercise.enums.LakerPlayer;
import com.gary.exercise.service.ExerciseService;
import com.gary.exercise.service.impl.ExerciseServiceImpl;
import org.springframework.boot.test.context.SpringBootTest;
import java.io.IOException;
import java.util.ArrayList;
@SpringBootTest
class ExerciseApplicationTests {
private final ExerciseService exerciseService;
private final int hang =1;
ExerciseApplicationTests(ExerciseService exerciseService) {
this.exerciseService = exerciseService;
}
public static void main(String[] args) throws IOException {
FileConfig fileConfig =new FileConfig();
ExerciseService exerciseService = new ExerciseServiceImpl(fileConfig);
ArrayList<String> list= (ArrayList<String>) exerciseService.readRow(12);
/* String whichTeamAttack= exerciseService.getActionTeam(6);
System.out.println(whichTeamAttack);*/
ActionDto result= exerciseService.getResult(6);
System.out.println(result);
}
}

@ -0,0 +1,15 @@
server:
port: 9090
# 数据库
spring:
datasource:
url: jdbc:mysql://47.122.61.54:3306/nba_visualization?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC
username: root
password: GHLgjw168168+
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
max-lifetime: 27000000 # 7.5 小时(毫秒)

Binary file not shown.
Loading…
Cancel
Save