初始化

new-master
dongzeliang 2023-11-10 08:43:20 +08:00
commit 71fa076269
28 changed files with 2874 additions and 0 deletions

38
.gitignore vendored 100644
View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

8
.idea/.gitignore vendored 100644
View File

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

View File

@ -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>

13
.idea/misc.xml 100644
View File

@ -0,0 +1,13 @@
<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="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -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>

6
.idea/vcs.xml 100644
View File

@ -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>

File diff suppressed because it is too large Load Diff

66
pom.xml 100644
View File

@ -0,0 +1,66 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.muyu</groupId>
<artifactId>VehicleSimulation</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mybatisplus.version>3.5.1</mybatisplus.version>
<freemaker.version>2.3.31</freemaker.version>
<mysql.version>8.0.28</mysql.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.15</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- mybatis-plus 所需依赖 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatisplus.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>${mybatisplus.version}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<!-- 使用h2内存数据库 -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,20 @@
package com.muyu;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author DongZeLiang
* @version 1.0
* @description
* @date 2023/11/9
*/
@SpringBootApplication
@MapperScan(value = "com.muyu.mapper")
public class VehicleSimulationApplication {
public static void main(String[] args) {
SpringApplication.run(VehicleSimulationApplication.class, args);
}
}

View File

@ -0,0 +1,93 @@
package com.muyu.common;
/**
*
*
* @author ruoyi
*/
public class HttpStatus {
/**
*
*/
public static final int SUCCESS = 200;
/**
*
*/
public static final int CREATED = 201;
/**
*
*/
public static final int ACCEPTED = 202;
/**
*
*/
public static final int NO_CONTENT = 204;
/**
*
*/
public static final int MOVED_PERM = 301;
/**
*
*/
public static final int SEE_OTHER = 303;
/**
*
*/
public static final int NOT_MODIFIED = 304;
/**
*
*/
public static final int BAD_REQUEST = 400;
/**
*
*/
public static final int UNAUTHORIZED = 401;
/**
* 访
*/
public static final int FORBIDDEN = 403;
/**
*
*/
public static final int NOT_FOUND = 404;
/**
* http
*/
public static final int BAD_METHOD = 405;
/**
*
*/
public static final int CONFLICT = 409;
/**
*
*/
public static final int UNSUPPORTED_TYPE = 415;
/**
*
*/
public static final int ERROR = 500;
/**
*
*/
public static final int NOT_IMPLEMENTED = 501;
/**
*
*/
public static final int WARN = 601;
}

View File

@ -0,0 +1,101 @@
package com.muyu.common;
import lombok.Data;
import java.io.Serializable;
/**
*
*
* @author ruoyi
*/
@Data
public class Result<T> implements Serializable {
/**
*
*/
public static final int SUCCESS = HttpStatus.SUCCESS;
/**
*
*/
public static final int FAIL = HttpStatus.ERROR;
private static final long serialVersionUID = 1L;
/**
*
*/
private static final int WARN = HttpStatus.WARN;
private int code;
private String msg;
private T data;
public static <T> Result<T> success () {
return restResult(null, SUCCESS, "操作成功");
}
public static <T> Result<T> success (T data) {
return restResult(data, SUCCESS, "操作成功");
}
public static <T> Result<T> success (T data, String msg) {
return restResult(data, SUCCESS, msg);
}
public static <T> Result<T> error () {
return restResult(null, FAIL, "操作失败");
}
public static <T> Result<T> error (String msg) {
return restResult(null, FAIL, msg);
}
public static <T> Result<T> error (T data) {
return restResult(data, FAIL, "操作失败");
}
public static <T> Result<T> error (T data, String msg) {
return restResult(data, FAIL, msg);
}
public static <T> Result<T> error (int code, String msg) {
return restResult(null, code, msg);
}
public static <T> Result<T> warn () {
return restResult(null, WARN, "操作失败");
}
public static <T> Result<T> warn (String msg) {
return restResult(null, WARN, msg);
}
public static <T> Result<T> warn (T data) {
return restResult(data, WARN, "操作失败");
}
public static <T> Result<T> warn (T data, String msg) {
return restResult(data, WARN, msg);
}
public static <T> Result<T> warn (int code, String msg) {
return restResult(null, code, msg);
}
private static <T> Result<T> restResult (T data, int code, String msg) {
Result<T> apiResult = new Result<>();
apiResult.setCode(code);
apiResult.setData(data);
apiResult.setMsg(msg);
return apiResult;
}
public static <T> Boolean isError (Result<T> ret) {
return !isSuccess(ret);
}
public static <T> Boolean isSuccess (Result<T> ret) {
return Result.SUCCESS == ret.getCode();
}
}

View File

@ -0,0 +1,29 @@
package com.muyu.config;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
*
*
*/
@Slf4j
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
log.info("start insert fill...");
this.setFieldValByName("createTime", new Date(), metaObject);
this.setFieldValByName("updateTime", new Date(), metaObject);
}
@Override
public void updateFill(MetaObject metaObject) {
log.info("start update fill...");
this.setFieldValByName("updateTime", new Date(), metaObject);
}
}

View File

@ -0,0 +1,34 @@
package com.muyu.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* mybatisplus
*/
@Configuration
public class MybatisPlusConfig {
/**
*
* @return
*/
/**@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
return paginationInterceptor;
}*/
/**
* ,mybatis,
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
return interceptor;
}
}

View File

@ -0,0 +1,143 @@
package com.muyu.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.muyu.common.Result;
import com.muyu.domain.User;
import com.muyu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* com.muyu.controller
*
*/
@RestController
@RequestMapping("/user")
public class UserController {
/**
*
*/
@Autowired
UserService userService;
@PostMapping("/login")
public Result login(){
return Result.success();
}
@PostMapping("/info")
public Result info(){
return Result.success();
}
/**
*
*
* @return
*/
@GetMapping("/save")
public Result save() {
User user = new User();
user.setId(10);
user.setUsername("miaolinlin");
user.setPwd("121212");
userService.save(user);
return Result.success(user);
}
/**
*
*
* @param id
* @return
*/
@GetMapping("/update")
public Result update(Integer id) {
User user = new User();
user.setId(id);
user.setPwd("1111111111");
userService.updateById(user);
return Result.success("{}");
}
@GetMapping("/list")
public Result list() {
// 返回所有
List<User> list = userService.list();
return Result.success(list);
}
@GetMapping("/listByContion")
public Result listByContion() {
/**
* QueryWrapper
* eq:
* like:
* orderBy:
* in, notin
* between
*/
List<User> list = userService.list(new LambdaQueryWrapper<User>()
// 查询年龄=11的
.eq(User::getUsername, "miao")
// 模糊匹配
.like(User::getPwd, "%111%")
// 排序,按照创建时间
.orderByDesc(User::getCreateTime)
);
return Result.success(list);
}
/**
* id
*
* @param id
* @return
*/
@GetMapping("/getById")
public Result getById(Integer id) {
User user = userService.getById(id);
return Result.success(user);
}
/**
*
*
* @param id
* @return
*/
@GetMapping("/delete")
public Result delete(Integer id) {
userService.removeById(id);
return Result.success("success");
}
/**
*
*
* @param pageNum
* @param pageSize
* @param name
* @return
*/
@GetMapping("/page")
public Result page(int pageNum, int pageSize, String name) {
IPage<User> page = new Page<>(pageNum, pageSize);
IPage<User> page1 = userService.page(page, new LambdaQueryWrapper<User>()
// 主要演示这里可以加条件。在name不为空的时候执行
.like(StringUtils.isNotEmpty(name), User::getUsername, "%" + name + "%"));
return Result.success(page1);
}
}

View File

@ -0,0 +1,30 @@
package com.muyu.controller;
import com.muyu.common.Result;
import com.muyu.domain.Vehicle;
import com.muyu.service.VehicleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author DongZeLiang
* @version 1.0
* @description
* @date 2023/11/9
*/
@RestController
@RequestMapping("/vehicle")
public class VehicleController {
@Autowired
private VehicleService vehicleService;
@GetMapping("/list")
public Result<List<Vehicle>> list(){
return Result.success(vehicleService.list());
}
}

View File

@ -0,0 +1,98 @@
package com.muyu.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author Leo825
* @since 2022-07-05
*/
@TableName("t_user")
public class User implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
*
*/
private String username;
/**
*
*/
private String pwd;
/**
* MyMetaObjectHandler 使
*/
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
* MyMetaObjectHandler 使
*/
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
@Override
public String toString() {
return "User{" +
"id=" + id +
", username=" + username +
", pwd=" + pwd +
", createTime=" + createTime +
", updateTime=" + updateTime +
"}";
}
}

View File

@ -0,0 +1,31 @@
package com.muyu.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @author DongZeLiang
* @version 1.0
* @description
* @date 2023/11/9
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("vehicle")
public class Vehicle {
@TableId(value = "vin")
private String vin;
@TableField("create_time")
private Date createTime;
}

View File

@ -0,0 +1,16 @@
package com.muyu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.domain.User;
/**
* <p>
* Mapper
* </p>
*
* @author Leo825
* @since 2022-07-05
*/
public interface UserMapper extends BaseMapper<User> {
}

View File

@ -0,0 +1,16 @@
package com.muyu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.domain.Vehicle;
/**
* <p>
* Mapper
* </p>
*
* @author Leo825
* @since 2022-07-05
*/
public interface VehicleMapper extends BaseMapper<Vehicle> {
}

View File

@ -0,0 +1,16 @@
package com.muyu.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.domain.User;
/**
* <p>
*
* </p>
*
* @author Leo825
* @since 2022-07-05
*/
public interface UserService extends IService<User> {
}

View File

@ -0,0 +1,16 @@
package com.muyu.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.domain.Vehicle;
/**
* <p>
*
* </p>
*
* @author Leo825
* @since 2022-07-05
*/
public interface VehicleService extends IService<Vehicle> {
}

View File

@ -0,0 +1,20 @@
package com.muyu.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.domain.User;
import com.muyu.mapper.UserMapper;
import com.muyu.service.UserService;
import org.springframework.stereotype.Service;
/**
* <p>
*
* </p>
*
* @author Leo825
* @since 2022-07-05
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
}

View File

@ -0,0 +1,20 @@
package com.muyu.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.domain.Vehicle;
import com.muyu.mapper.VehicleMapper;
import com.muyu.service.VehicleService;
import org.springframework.stereotype.Service;
/**
* <p>
*
* </p>
*
* @author Leo825
* @since 2022-07-05
*/
@Service
public class VechileServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> implements VehicleService {
}

View File

@ -0,0 +1,484 @@
package com.muyu.vehicle;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author
* @Classname VehicleData
* @Description
* @Date 2021/8/5
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class VehicleData {
/**
* VIN
*/
private String vin;
/**
* 线
*/
private String drivingRoute;
/**
*
*/
private String longitude;
/**
*
*/
private String latitude;
/**
*
*/
private String speed;
/**
*
*/
private String mileage;
/**
*
*/
private String voltage;
/**
*
*/
private String current;
/**
*
*/
private String resistance;
/**
*
*/
private String gear;
/**
*
*/
private String accelerationPedal;
/**
*
*/
private String brakePedal;
/**
*
*/
private String fuelConsumptionRate;
/**
*
*/
private String motorControllerTemperature;
/**
*
*/
private String motorSpeed;
/**
*
*/
private String motorTorque;
/**
*
*/
private String motorTemperature;
/**
*
*/
private String motorVoltage;
/**
*
*/
private String motorCurrent;
/**
* SOC
*/
private String remainingBattery;
/**
*
*/
private String maximumFeedbackPower;
/**
*
*/
private String maximumDischargePower;
/**
* BMS
*/
private String selfCheckCounter;
/**
*
*/
private String totalBatteryCurrent;
/**
* V3
*/
private String totalBatteryVoltage;
/**
*
*/
private String singleBatteryMaxVoltage;
/**
*
*/
private String singleBatteryMinVoltage;
/**
*
*/
private String singleBatteryMaxTemperature;
/**
*
*/
private String singleBatteryMinTemperature;
/**
*
*/
private String availableBatteryCapacity;
/**
*
*/
private int vehicleStatus;
/**
*
*/
private int chargingStatus;
/**
*
*/
private int operatingStatus;
/**
* SOC
*/
private int socStatus;
/**
*
*/
private int chargingEnergyStorageStatus;
/**
*
*/
private int driveMotorStatus;
/**
*
*/
private int positionStatus;
/**
* EAS()
*/
private int easStatus;
/**
* PTC()
*/
private int ptcStatus;
/**
* EPS()
*/
private int epsStatus;
/**
* ABS()
*/
private int absStatus;
/**
* MCU(/)
*/
private int mcuStatus;
/**
*
*/
private int heatingStatus;
/**
*
*/
private int batteryStatus;
/**
*
*/
private int batteryInsulationStatus;
/**
* DCDC()
*/
private int dcdcStatus;
/**
* CHG()
*/
private int chgStatus;
/**
*
*/
private String vehicleStatusMsg;
/**
*
*/
private String smartHardwareMsg;
/**
*
*/
private String batteryMsg;
public String getMsg(){
StringBuilder sb = new StringBuilder();
//第一位VIN
sb.append(vin);
//第二位经度 longitude latitude
sb.append(getValue(longitude ,11));
//第三位维度 longitude latitude
sb.append(getValue(latitude ,10));
//车速
sb.append(getValue(speed,6));
//总里程
sb.append(getValue(mileage,11));
// 总电压
sb.append(getValue(voltage,6));
//总电流
sb.append(getValue(current,5));
//绝缘电阻 79 - 87
sb.append(getValue(resistance,9));
//档位
sb.append(gear);
// 加速踏板行程值
sb.append(getValue(accelerationPedal,2));
// 制动踏板行程值
sb.append(getValue(brakePedal,2));
// 燃料消耗率
sb.append(getValue(fuelConsumptionRate,5));
//电机控制器温度
sb.append(getValue(motorControllerTemperature,6));
//电机转速
sb.append(getValue(motorSpeed,5));
//点击转矩
sb.append(getValue(motorTorque,4));
//电机温度
sb.append(getValue(motorTemperature,6));
//电机电压
sb.append(getValue(motorVoltage,5));
//电机电流
sb.append(getValue(motorCurrent,8));
//动力电池剩余电量SOC
sb.append(getValue(remainingBattery,6));
//当前状态允许的最大反馈功率
sb.append(getValue(maximumFeedbackPower,6));
//当前状态允许最大放电功率
sb.append(getValue(maximumDischargePower,6));
//BMS自检计数器
sb.append(getValue(selfCheckCounter,2));
//动力电池充放电电流
sb.append(getValue(totalBatteryCurrent,5));
//动力电池负载端总电压V3
sb.append(getValue(totalBatteryVoltage,6));
//单次最大电压
sb.append(getValue(singleBatteryMaxVoltage,4));
//单体电池最低电压
sb.append(getValue(singleBatteryMinVoltage,4));
//单体电池最高温度
sb.append(getValue(singleBatteryMaxTemperature,6));
//单体电池最低温度
sb.append(getValue(singleBatteryMinTemperature,6));
//动力电池可用容量
sb.append(getValue(availableBatteryCapacity,6));
//车辆状态
sb.append(vehicleStatus);
//充电状态
sb.append(chargingStatus);
//运行状态
sb.append(operatingStatus);
//SOC
sb.append(socStatus);
//可充电储能装置工作状态
sb.append(chargingEnergyStorageStatus);
//驱动电机状态
sb.append(driveMotorStatus);
//定位是否有效
sb.append(positionStatus);
//EAS
sb.append(easStatus);
//PTC
sb.append(ptcStatus);
//EPS
sb.append(epsStatus);
//ABS
sb.append(absStatus);
//MCU
sb.append(mcuStatus);
//动力电池加热状态
sb.append(heatingStatus);
//动力电池当前状态
sb.append(batteryStatus);
//动力电池保温状态
sb.append(batteryInsulationStatus);
//DCDC
sb.append(dcdcStatus);
//CHG
sb.append(chgStatus);
return sb.toString();
}
public String getValue(String val , int valLength){
int length = val.length();
if (length > valLength){
return val.substring( 0 , valLength);
}
val = val + "0".repeat(valLength - length);
return val;
}
/**
VIN
vin;
线
drivingRoute;
longitude;
latitude;
speed;
mileage;
voltage;
current;
resistance;
gear;
accelerationPedal;
brakePedal;
fuelConsumptionRate;
*/
/**
motorControllerTemperature;
motorSpeed;
motorTorque;
motorTemperature;
motorVoltage;
motorCurrent;
*/
/**
SOC
remainingBattery;
maximumFeedbackPower;
maximumDischargePower;
BMS
selfCheckCounter;
totalBatteryCurrent;
V3
totalBatteryVoltage;
singleBatteryMaxVoltage;
singleBatteryMinVoltage;
singleBatteryMaxTemperature;
singleBatteryMinTemperature;
availableBatteryCapacity;
*/
/**
vehicleStatus;
chargingStatus;
operatingStatus;
SOC
socStatus;
chargingEnergyStorageStatus;
driveMotorStatus;
positionStatus;
*/
/**
EAS()
easStatus;
PTC()
ptcStatus;
EPS()
epsStatus;
ABS()
absStatus;
MCU(/)
mcuStatus;
*/
/**
heatingStatus;
batteryStatus;
batteryInsulationStatus;
DCDC()
dcdcStatus;
CHG()
chgStatus;
*/
}

View File

@ -0,0 +1,10 @@
package com.muyu.vehicle.core;
/**
* @author DongZeLiang
* @version 1.0
* @description
* @date 2023/11/9
*/
public class Config {
}

View File

@ -0,0 +1,71 @@
server:
port: 81
servlet:
context-path: /vehicle
spring:
datasource:
username: muyu
password: 123456
# 如果需要数据本地化,则改成 file 方式
# jdbc:h2:mem:testDB;DB_CLOSE_DELAY=-1
url: jdbc:h2:file:~/vehicle/db;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1
driver-class-name: org.h2.Driver
# 开启这个配置就可以通过 web 页面访问了例如http://localhost:8080/springboot-h2/h2-console
h2:
console:
enabled: true
settings:
# 开启h2 console 跟踪 方便调试 默认 false
trace: true
# 允许console 远程访问 默认false
web-allow-others: true
# h2 访问路径上下文
path: /h2-console
sql:
init:
schema-locations: classpath:schema.sql
data-locations: classpath:data.sql
mode: always
continue-on-error: true
# mybatis-plus 配置
mybatis-plus:
mapper-locations: classpath*:/com.muyu.mapper/**/*.xml
#实体扫描多个package用逗号或者分号分隔
typeAliasesPackage: com.dmo.entity
global-config:
#数据库相关配置
db-config:
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
id-type: AUTO
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"
field-strategy: NOT_NULL
#驼峰下划线转换
column-underline: true
logic-delete-value: -1
logic-not-delete-value: 0
banner: false
#原生配置
configuration:
# 打印sql
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
# 日志输出配置
logging:
level:
root: INFO
org:
springframework:
security: WARN
web: ERROR
file:
path: ./logs
name: './logs/springboot-h2.log'
pattern:
file: '%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n'
console: '%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n'

View File

@ -0,0 +1,4 @@
insert into t_user(id, username, pwd, create_time, update_time) values (0,'zhhangsan','1222', {ts '2022-07-27 18:47:52.69'}, {ts '2022-07-27 18:47:52.69'})
insert into vehicle(id,vin, create_time) values (1,'vin123456789123456',{ts '2022-07-27 18:47:52.69'})

View File

@ -0,0 +1,13 @@
create table if not exists t_user (
`id` int primary key not null ,
`username` char (50) not null,
`pwd` char(50) not null,
`create_time` datetime not null,
`update_time` datetime
) ;
create table if not exists vehicle (
`id` int primary key not null ,
`vin` char (50) not null,
`create_time` datetime not null
) ;