Compare commits
34 Commits
d82ae07d37
...
a3613176f3
Author | SHA1 | Date |
---|---|---|
|
a3613176f3 | |
|
89825669dc | |
|
f56a0e8b7f | |
|
9846c72b3b | |
|
709878fbab | |
|
6dd3d73f62 | |
|
2623669eb0 | |
|
3a8b35b710 | |
|
cb8867d0ee | |
|
ba8009fd8d | |
|
954a8939c6 | |
|
3393804735 | |
|
59050208a0 | |
|
217af96abc | |
|
b5a2687491 | |
|
370a91773e | |
|
5589803de6 | |
|
708214b86e | |
|
476d6ae0b7 | |
|
4adb06459e | |
|
fe90a341ff | |
|
d99edc16d1 | |
|
50a655d888 | |
|
b879a1768d | |
|
78747b7d03 | |
|
d6ff8ad340 | |
|
8bc54f4662 | |
|
e6639bc7f9 | |
|
a0ddc45e67 | |
|
051fe490d6 | |
|
31df6d32db | |
|
798f509dec | |
|
7149ea8f1c | |
|
a6521e46c9 |
|
@ -57,6 +57,15 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-api-doc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-saas</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package com.muyu.auth.controller;
|
||||
|
||||
import com.muyu.auth.form.EnterpriseSettlement;
|
||||
import com.muyu.auth.form.Firm;
|
||||
import com.muyu.auth.form.LoginBody;
|
||||
import com.muyu.auth.form.RegisterBody;
|
||||
import com.muyu.auth.service.SysFirmService;
|
||||
import com.muyu.auth.service.SysLoginService;
|
||||
import com.muyu.cloud.common.many.datasource.constents.DatasourceContent;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.JwtUtils;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
|
@ -10,6 +14,7 @@ import com.muyu.common.security.auth.AuthUtil;
|
|||
import com.muyu.common.security.service.TokenService;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -18,11 +23,17 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
/**
|
||||
* token 控制
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
public class TokenController {
|
||||
@Autowired
|
||||
|
@ -31,8 +42,16 @@ public class TokenController {
|
|||
@Autowired
|
||||
private SysLoginService sysLoginService;
|
||||
|
||||
@Autowired
|
||||
private SysFirmService sysFirmService;
|
||||
|
||||
@PostMapping("login")
|
||||
public Result<?> login (@RequestBody LoginBody form) {
|
||||
//查询企业是否存在
|
||||
Firm firm = sysFirmService.findFirmByName(form.getFirmName());
|
||||
if (firm.getDatabaseName() == null){
|
||||
return Result.error(null,"企业不存在");
|
||||
}
|
||||
// 用户登录
|
||||
LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
|
||||
// 获取登录token
|
||||
|
@ -67,6 +86,42 @@ public class TokenController {
|
|||
public Result<?> register (@RequestBody RegisterBody registerBody) {
|
||||
// 用户注册
|
||||
sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业入入驻
|
||||
* @param settlement
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/enterprise")
|
||||
public Result<?> enterprise( @RequestBody EnterpriseSettlement settlement){
|
||||
|
||||
String createDatabaseUrl="jdbc:mysql://"+ DatasourceContent.IP+":"+DatasourceContent.PORT+"?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
|
||||
String createDatabaseSql = "CREATE DATABASE IF NOT EXISTS " + settlement.getDatabaseName() + ";";
|
||||
try (Connection adminConn = DriverManager.getConnection(createDatabaseUrl, DatasourceContent.USER_NAME, DatasourceContent.PASSWORD);
|
||||
Statement stmt = adminConn.createStatement()) {
|
||||
|
||||
boolean success = stmt.execute(createDatabaseSql);
|
||||
if (success) {
|
||||
log.info("数据库 {} 创建成功", settlement.getDatabaseName());
|
||||
|
||||
} else {
|
||||
log.warn("数据库 {} 创建失败", settlement.getDatabaseName());
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
log.error("连接数据库时发生错误或创建数据库失败", e);
|
||||
}
|
||||
//企业入组
|
||||
sysLoginService.enterprise(settlement.getDatabaseName(),settlement.getFirmName());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.muyu.auth.form;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 企业入驻
|
||||
* @author 袁子龙
|
||||
* @package com.muyu.auth.form
|
||||
* @name EnterpriseSettlement
|
||||
* @date 2024/9/30 11:25
|
||||
*/
|
||||
@Data
|
||||
public class EnterpriseSettlement {
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
private String firmName;
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
private String databaseName;
|
||||
|
||||
}
|
|
@ -3,15 +3,19 @@ package com.muyu.auth.form;
|
|||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 企业入驻对象
|
||||
* 企业登录对象
|
||||
* @author 袁子龙
|
||||
* @package com.muyu.auth.form
|
||||
* @name Enterprise
|
||||
* @date 2024/9/30 10:30
|
||||
*/
|
||||
@Data
|
||||
public class Enterprise {
|
||||
public class Firm {
|
||||
|
||||
/**
|
||||
* 企业id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
|
@ -1,10 +1,14 @@
|
|||
package com.muyu.auth.form;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户登录对象
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class LoginBody {
|
||||
/**
|
||||
* 用户名
|
||||
|
@ -16,20 +20,11 @@ public class LoginBody {
|
|||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
private String firmName;
|
||||
|
||||
public String getUsername () {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername (String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword () {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword (String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package com.muyu.auth.service;
|
||||
|
||||
import com.muyu.auth.form.Firm;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
|
||||
/**
|
||||
* 数据源
|
||||
* @author 袁子龙
|
||||
* @package com.muyu.auth.service
|
||||
* @name SysFirmService
|
||||
* @date 2024/9/30 11:05
|
||||
*/
|
||||
@Component
|
||||
public class SysFirmService {
|
||||
//数据库账号
|
||||
static final String USER="root";
|
||||
//数据库密码
|
||||
static final String PASSWORD="Lw030106";
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
public Firm findFirmByName(String firmName){
|
||||
Firm firm = new Firm();
|
||||
try {
|
||||
DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
|
||||
Connection connection= DriverManager.getConnection("jdbc:mysql://47.101.53.251:3306/datasource?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT&useSSL=false",USER,PASSWORD);
|
||||
String sql="select * from `datasource` where firm_name = '"+firmName+"'";
|
||||
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(sql);
|
||||
|
||||
|
||||
while (rs.next()){
|
||||
firm.setId(rs.getInt("id"));
|
||||
firm.setFirmName(rs.getString("firm_name"));
|
||||
firm.setDatabaseName(rs.getString("database_name"));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
//数据源不为空
|
||||
if (firm!=null){
|
||||
redisTemplate.opsForValue().set("datasource",firm.getDatabaseName());
|
||||
}
|
||||
return firm;
|
||||
};
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.auth.service;
|
||||
|
||||
import com.muyu.auth.form.EnterpriseSettlement;
|
||||
import com.muyu.common.core.constant.CacheConstants;
|
||||
import com.muyu.common.core.constant.Constants;
|
||||
import com.muyu.common.core.constant.SecurityConstants;
|
||||
|
@ -12,6 +13,7 @@ import com.muyu.common.core.utils.StringUtils;
|
|||
import com.muyu.common.core.utils.ip.IpUtils;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.Enterprise;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
|
@ -124,4 +126,29 @@ public class SysLoginService {
|
|||
}
|
||||
recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业入驻
|
||||
* @param databaseName
|
||||
* @param fileName
|
||||
*/
|
||||
public void enterprise (String databaseName,String fileName) {
|
||||
// 参数校验 数据库名或企业名称不能为空
|
||||
if (StringUtils.isAnyBlank(databaseName, fileName)) {
|
||||
throw new ServiceException("数据库名或企业名称不能为空");
|
||||
}
|
||||
|
||||
if (databaseName.length() < UserConstants.PASSWORD_MIN_LENGTH || databaseName.length() > UserConstants.PASSWORD_MAX_LENGTH) {
|
||||
throw new ServiceException("数据库名长度必须在5到20个字符之间");
|
||||
}
|
||||
if (fileName.length() < UserConstants.Firm_NAME_MIN_LENGTH || fileName.length() > UserConstants.Firm_NAME_MAX_LENGTH) {
|
||||
throw new ServiceException("企业名称长度必须在2到20个字符之间");
|
||||
}
|
||||
Enterprise settlement = new Enterprise();
|
||||
settlement.setDatabaseName(databaseName);
|
||||
settlement.setFirmName(fileName);
|
||||
|
||||
remoteUserService.settlementEnterpriseInfo(settlement, SecurityConstants.INNER);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,10 @@ package com.muyu.cache;/**
|
|||
import com.muyu.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static cn.hutool.core.lang.ansi.AnsiEncoder.encode;
|
||||
|
||||
/**
|
||||
|
@ -23,7 +27,7 @@ public abstract class CacheAbsBasic<K,V> implements CacheBasic<K,V>{
|
|||
|
||||
@Override
|
||||
public void put(K key, V value) {
|
||||
redisService.setCacheObject(encodeKey(key), value); // 编码 --> 缓存基础的对象 Integer String 实体类等
|
||||
redisService.setCacheObject(encodeKey(key), value,24L, TimeUnit.HOURS); // 编码 --> 缓存基础的对象 Integer String 实体类等
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.muyu.cache;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yuping
|
||||
* @package com.muyu.cache
|
||||
|
|
|
@ -110,4 +110,16 @@ public class UserConstants {
|
|||
public static final int PASSWORD_MIN_LENGTH = 5;
|
||||
|
||||
public static final int PASSWORD_MAX_LENGTH = 20;
|
||||
|
||||
/**
|
||||
* 企业名称长度限制
|
||||
*/
|
||||
public static final int Firm_NAME_MIN_LENGTH = 2;
|
||||
public static final int Firm_NAME_MAX_LENGTH = 20;
|
||||
|
||||
/**
|
||||
* 数据库名称长度限制
|
||||
*/
|
||||
public static final int DATABASE_NAME_MIN_LENGTH = 2;
|
||||
public static final int DATABASE_NAME_MAX_LENGTH = 20;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
<artifactId>cloud-common-saas</artifactId>
|
||||
|
||||
<description>
|
||||
cloud-common-saas 模块
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
|
@ -31,6 +35,11 @@
|
|||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.29</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
|
|
@ -40,7 +40,7 @@ import java.util.Map;
|
|||
public class ManyDataSource implements ApplicationRunner{
|
||||
private List<EntInfo> dataSourceInfoList(){
|
||||
RemoteSaaSService remoteSaaSService = SpringUtils.getBean(RemoteSaaSService.class);
|
||||
Result<List<Datasource>> tableDataInfoResult = remoteSaaSService.findDatabaseList();
|
||||
Result<List<Datasource>> tableDataInfoResult = remoteSaaSService.findDatabaseList();
|
||||
if (tableDataInfoResult==null){
|
||||
throw new SaaSException("saas远调数据源错误");
|
||||
}
|
||||
|
|
|
@ -16,4 +16,8 @@ public class DatasourceContent {
|
|||
public final static String IP = "47.101.53.251";
|
||||
|
||||
public final static Integer PORT = 3306;
|
||||
|
||||
public static String getDatasourceUrl(String databaseName) {
|
||||
return String.format(DATASOURCE_URL,USER_NAME,PASSWORD,IP,PORT, databaseName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package com.muyu.common.system.domain;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.annotation.Excel.ColumnType;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 企业对象
|
||||
* @author 袁子龙
|
||||
* @package com.muyu.common.system.domain
|
||||
* @name Enterprise
|
||||
* @date 2024/9/30 12:05
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Enterprise extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 企业Id
|
||||
*/
|
||||
@Excel(name = "企业序号",cellType = ColumnType.NUMERIC, prompt = "企业编号")
|
||||
private Integer id;
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
@Excel(name = "企业名称")
|
||||
private String firmName;
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
@Excel(name = "数据库名称")
|
||||
private String databaseName;
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.muyu.common.core.constant.SecurityConstants;
|
|||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.system.domain.Enterprise;
|
||||
import com.muyu.common.system.domain.SysFirmUser;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
|
||||
|
@ -44,4 +45,13 @@ public interface RemoteUserService {
|
|||
|
||||
@GetMapping("/user/companyList")
|
||||
Result<List<SysUser>> companyList();
|
||||
|
||||
/**
|
||||
* 入驻企业信息
|
||||
* @param enterprise
|
||||
* @param source
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/user/enterprise")
|
||||
Result<Boolean>settlementEnterpriseInfo(@RequestBody Enterprise enterprise, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.common.system.remote.factory;
|
|||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.system.domain.Enterprise;
|
||||
import com.muyu.common.system.domain.SysFirmUser;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
|
@ -41,6 +42,11 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
return Result.error("获取企业列表失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Boolean> settlementEnterpriseInfo(Enterprise enterprise, String source) {
|
||||
return Result.error("入驻企业失败");
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,4 +33,5 @@
|
|||
cloud-common通用模块
|
||||
</description>
|
||||
|
||||
|
||||
</project>
|
||||
|
|
|
@ -10,10 +10,7 @@ import com.muyu.common.log.enums.BusinessType;
|
|||
import com.muyu.common.security.annotation.InnerAuth;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.SysDept;
|
||||
import com.muyu.common.system.domain.SysRole;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.common.system.domain.*;
|
||||
import com.muyu.system.domain.resp.AuthRoleResp;
|
||||
import com.muyu.system.domain.resp.UserDetailInfoResp;
|
||||
import com.muyu.system.domain.resp.UserInfoResp;
|
||||
|
@ -136,6 +133,15 @@ public class SysUserController extends BaseController {
|
|||
return Result.success(userService.registerUser(sysUser));
|
||||
}
|
||||
|
||||
/**
|
||||
* 入驻企业信息
|
||||
*/
|
||||
@InnerAuth
|
||||
@PostMapping("/enterprise")
|
||||
public Result<Boolean> enterprise (@RequestBody Enterprise enterprise){
|
||||
|
||||
return Result.success(userService.enterprise(enterprise));
|
||||
}
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.common.system.domain.Enterprise;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
@ -66,6 +67,20 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
|||
*/
|
||||
int insertUser(SysUser user);
|
||||
|
||||
/**
|
||||
* 企业入驻
|
||||
* @param enterprise
|
||||
* @return
|
||||
*/
|
||||
int enterprise(Enterprise enterprise);
|
||||
|
||||
/**
|
||||
* 企业管理添加
|
||||
* @param enterprise
|
||||
* @return
|
||||
*/
|
||||
int enterPriseAdd(Enterprise enterprise);
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
*
|
||||
|
@ -142,4 +157,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
|||
|
||||
List<SysUser> selectCompanyList();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.muyu.system.domain.SysConfig;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 配置plus业务层
|
||||
* @author DongZl
|
||||
* @description: 配置plus业务层
|
||||
* @Date 2023-11-13 上午 10:06
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.system.domain.Enterprise;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -133,6 +134,7 @@ public interface SysUserService extends IService<SysUser> {
|
|||
*/
|
||||
boolean registerUser(SysUser user);
|
||||
|
||||
boolean enterprise(Enterprise enterprise);
|
||||
/**
|
||||
* 修改用户信息
|
||||
*
|
||||
|
@ -228,4 +230,5 @@ public interface SysUserService extends IService<SysUser> {
|
|||
|
||||
List<SysUser> selectCompanyList();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 配置plus业务实现层
|
||||
* @author DongZl
|
||||
* @description: 配置plus业务实现层
|
||||
* @Date 2023-11-13 上午 10:06
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.muyu.common.core.utils.StringUtils;
|
|||
import com.muyu.common.core.utils.bean.BeanValidators;
|
||||
import com.muyu.common.datascope.annotation.DataScope;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.Enterprise;
|
||||
import com.muyu.common.system.domain.SysRole;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.system.domain.SysPost;
|
||||
|
@ -257,6 +258,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
return userMapper.insertUser(user) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业入驻
|
||||
* @param enterprise
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean enterprise(Enterprise enterprise){
|
||||
userMapper.enterPriseAdd(enterprise);
|
||||
return userMapper.enterprise(enterprise) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存用户信息
|
||||
*
|
||||
|
|
|
@ -221,6 +221,13 @@
|
|||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
<insert id="enterprise">
|
||||
INSERT INTO `datasource`.`datasource` (`id`, `firm_name`, `database_name`) VALUES (NULL, #{firmName}, #{databaseName});
|
||||
</insert>
|
||||
<insert id="enterPriseAdd">
|
||||
INSERT INTO `saas`.`tb_enterprise` (`enterprise_id`, `enterprise_name`, `enterprise_car_count`, `enterprise_fence_count`, `enterprise_database_name`)
|
||||
VALUES (NULL, #{firmName}, 0, 0, #{databaseName});
|
||||
</insert>
|
||||
|
||||
<update id="updateUser" parameterType="com.muyu.common.system.domain.SysUser">
|
||||
update sys_user
|
||||
|
|
|
@ -5,9 +5,6 @@ import com.muyu.common.domain.MessageTemplateType;
|
|||
import com.muyu.common.domain.SysCar;
|
||||
import com.muyu.common.kafka.config.KafkaProducerConfig;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.server.service.MessageTemplateTypeService;
|
||||
import com.muyu.server.service.SysCarService;
|
||||
import com.muyu.server.service.impl.SysCarServiceImpl;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
|
@ -22,6 +19,7 @@ import javax.annotation.PostConstruct;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
/**
|
||||
*
|
||||
* @author liuxinyue
|
||||
* @Package:com.muyu.mqtt.configure
|
||||
* @Project:cloud-server
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package com.muyu.cache;
|
||||
|
||||
import com.muyu.common.domain.CarType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author YuPing
|
||||
* @Description 车辆类型缓存
|
||||
* @Version 1.0
|
||||
* @Data 2024-09-30 16:31:44
|
||||
*/
|
||||
@Component
|
||||
public class CarTypeCacheService extends CacheAbsBasic<String, List<CarType>> {
|
||||
/**
|
||||
* 缓存key前缀
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "carType:";
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码key
|
||||
* @param key 编码key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace(keyPre(), "");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.muyu.cache;
|
||||
|
||||
import com.muyu.common.domain.DataType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author YuPing
|
||||
* @Description 数据类型缓存
|
||||
* @Version 1.0
|
||||
* @Data 2024-09-30 10:57:24
|
||||
*/
|
||||
@Component
|
||||
public class DataTypeCacheService extends CacheAbsBasic<String, List<DataType>> {
|
||||
/**
|
||||
* key前缀
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "DataType";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解码
|
||||
* @param key 编码key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace(keyPre(), "");
|
||||
}
|
||||
}
|
|
@ -3,6 +3,8 @@ package com.muyu.cache;
|
|||
import com.muyu.common.domain.database.ElectronicFence;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author YuPing
|
||||
* @Description 电子围栏缓存
|
||||
|
@ -10,7 +12,7 @@ import org.springframework.stereotype.Component;
|
|||
* @Data 2024-09-29 20:53:46
|
||||
*/
|
||||
@Component
|
||||
public class ElectronicFenceCacheService extends CacheAbsBasic<String, ElectronicFence>{
|
||||
public class ElectronicFenceCacheService extends CacheAbsBasic<String, List<ElectronicFence>>{
|
||||
/**
|
||||
* key前缀
|
||||
* @return
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.cache;
|
|||
import com.muyu.common.domain.database.ElectronicFenceGroup;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author YuPing
|
||||
* @Description 围栏组缓存
|
||||
|
@ -10,7 +12,7 @@ import org.springframework.stereotype.Component;
|
|||
* @Data 2024-09-29 20:57:46
|
||||
*/
|
||||
@Component
|
||||
public class ElectronicFenceGroupCacheService extends CacheAbsBasic<String, ElectronicFenceGroup>{
|
||||
public class ElectronicFenceGroupCacheService extends CacheAbsBasic<String, List<ElectronicFenceGroup>>{
|
||||
/**
|
||||
* key前缀
|
||||
* @return
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.cache;
|
|||
import com.muyu.common.domain.Enterprise;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yuping
|
||||
* @package com.muyu.cache
|
||||
|
@ -10,7 +12,7 @@ import org.springframework.stereotype.Component;
|
|||
* @date 2024/9/29 20:21 企业缓存
|
||||
*/
|
||||
@Component
|
||||
public class EnterpriseCacheService extends CacheAbsBasic<String, Enterprise>{
|
||||
public class EnterpriseCacheService extends CacheAbsBasic<String, List<Enterprise>>{
|
||||
/**
|
||||
* 缓存前缀
|
||||
* @return
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package com.muyu.cache;
|
||||
|
||||
import com.muyu.common.domain.MessageTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author YuPing
|
||||
* @Description 报文缓存
|
||||
* @Version 1.0
|
||||
* @Data 2024-09-30 11:01:13
|
||||
*/
|
||||
@Component
|
||||
public class MessageTemplateCacheService extends CacheAbsBasic<String, List<MessageTemplate>>{
|
||||
/**
|
||||
* key前缀
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "message_template";
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码
|
||||
* @param key 编码key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace(keyPre(), "");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.muyu.cache;
|
||||
|
||||
import com.muyu.common.domain.MessageTemplateType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author YuPing
|
||||
* @Description 报文模版类型缓存
|
||||
* @Version 1.0
|
||||
* @Data 2024-09-30 11:04:43
|
||||
*/
|
||||
@Component
|
||||
public class MessageTemplateTypeCacheService extends CacheAbsBasic<String, List<MessageTemplateType>>{
|
||||
/**
|
||||
* 缓存key前缀
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "messageTemplateType";
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码
|
||||
* @param key 编码key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace(keyPre(), "");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.muyu.cache;
|
||||
|
||||
import com.muyu.common.domain.SysCar;
|
||||
import com.muyu.common.domain.resp.SysCarVo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author YuPing
|
||||
* @Description 车辆缓存
|
||||
* @Version 1.0
|
||||
* @Data 2024-09-30 16:35:14
|
||||
*/
|
||||
@Component
|
||||
public class SysCarCacheService extends CacheAbsBasic<String, List<SysCarVo>>{
|
||||
/**
|
||||
* key前缀
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "car";
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码
|
||||
* @param key 编码key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace(keyPre(), "");
|
||||
}
|
||||
}
|
|
@ -3,6 +3,8 @@ package com.muyu.cache;
|
|||
import com.muyu.common.domain.SysCarFault;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author YuPing
|
||||
* @Description 故障缓存
|
||||
|
@ -10,7 +12,7 @@ import org.springframework.stereotype.Component;
|
|||
* @Data 2024-09-29 21:10:31
|
||||
*/
|
||||
@Component
|
||||
public class SysCarFaultCacheService extends CacheAbsBasic<String, SysCarFault>{
|
||||
public class SysCarFaultCacheService extends CacheAbsBasic<String, List<SysCarFault>>{
|
||||
/**
|
||||
* 缓存前缀
|
||||
* @return
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.cache;
|
|||
import com.muyu.common.domain.SysCarFaultMessage;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author YuPing
|
||||
* @Description 站内信缓存
|
||||
|
@ -10,7 +12,7 @@ import org.springframework.stereotype.Component;
|
|||
* @Data 2024-09-29 21:13:19
|
||||
*/
|
||||
@Component
|
||||
public class SysCarFaultMessageCacheService extends CacheAbsBasic<String, SysCarFaultMessage>{
|
||||
public class SysCarFaultMessageCacheService extends CacheAbsBasic<String, List<SysCarFaultMessage>>{
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "sysCarFaultMessage";
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package com.muyu.cache;
|
||||
|
||||
import com.muyu.common.domain.Template;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author YuPing
|
||||
* @Description 报文模版缓存
|
||||
* @Version 1.0
|
||||
* @Data 2024-09-30 18:21:46
|
||||
*/
|
||||
@Component
|
||||
public class TemplateCacheService extends CacheAbsBasic<String, List<Template>>{
|
||||
/**
|
||||
* 缓存key前缀
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "template";
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码
|
||||
* @param key 编码key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace(keyPre(), "");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.muyu.cache;
|
||||
|
||||
import com.muyu.common.domain.resp.WarnRuleResp;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author YuPing
|
||||
* @Description 预警规则缓存
|
||||
* @Version 1.0
|
||||
* @Data 2024-09-30 16:37:09
|
||||
*/
|
||||
@Component
|
||||
public class WarnRuleCacheService extends CacheAbsBasic<String, List<WarnRuleResp>>{
|
||||
/**
|
||||
* 缓存key前缀
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "warnRule";
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码
|
||||
* @param key 编码key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace(keyPre(), "");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.muyu.cache;
|
||||
|
||||
import com.muyu.common.domain.resp.WarnStrategyResp;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author YuPing
|
||||
* @Description 预警策略缓存
|
||||
* @Version 1.0
|
||||
* @Data 2024-09-30 16:38:35
|
||||
*/
|
||||
@Component
|
||||
public class WarnStrategyCacheService extends CacheAbsBasic<String, List<WarnStrategyResp>> {
|
||||
/**
|
||||
* 缓存key前缀
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "warnStrategy";
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码key
|
||||
* @param key 编码key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace(keyPre(), "");
|
||||
}
|
||||
}
|
|
@ -1,5 +1,13 @@
|
|||
com.muyu.cache.CarTypeCacheService
|
||||
com.muyu.cache.DataTypeCacheService
|
||||
com.muyu.cache.ElectronicFenceCacheService
|
||||
com.muyu.cache.ElectronicFenceGroupCacheService
|
||||
com.muyu.cache.EnterpriseCacheService
|
||||
com.muyu.cache.MessageTemplateCacheService
|
||||
com.muyu.cache.MessageTemplateTypeCacheService
|
||||
com.muyu.cache.SysCarCacheService
|
||||
com.muyu.cache.SysCarFaultCacheService
|
||||
com.muyu.cache.SysCarFaultMessageCacheService
|
||||
com.muyu.cache.TemplateCacheService
|
||||
com.muyu.cache.WarnRuleCacheService
|
||||
com.muyu.cache.WarnStrategyCacheService
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.muyu.common.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -20,17 +22,27 @@ public class Enterprise {
|
|||
/**
|
||||
* 企业编号
|
||||
*/
|
||||
@Excel(name = "企业编号")
|
||||
private Integer enterpriseId;
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
@Excel(name = "企业名称")
|
||||
private String enterpriseName;
|
||||
/**
|
||||
* 企业车辆数量
|
||||
*/
|
||||
@Excel(name = "企业拥有车辆数据")
|
||||
private Integer enterpriseCarCount;
|
||||
/**
|
||||
* 企业电子围栏数量
|
||||
*/
|
||||
@Excel(name = "企业所属电子围栏")
|
||||
private Integer enterpriseFenceCount;
|
||||
|
||||
/**
|
||||
* 企业数据库名称
|
||||
*/
|
||||
@Excel(name = "企业所属数据库")
|
||||
private String enterpriseDatabaseName;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ import lombok.experimental.SuperBuilder;
|
|||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* 报文模版
|
||||
* @author liuxinyue
|
||||
* @Package:com.sheep.message.domain
|
||||
* @Project:cloud-server-c
|
||||
* @name:MessageTemplateType
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
package com.muyu.common.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 企业信息 sys_car_enterprise
|
||||
* @author 袁子龙
|
||||
* @package com.muyu.breakdown.domain
|
||||
* @name: SysCarEnterprise
|
||||
* @date: 2024/9/26 19:54
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("sys_car_enterprise")
|
||||
public class SysCarEnterprise extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 企业id*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 企业名称*/
|
||||
@Excel(name = "企业名称")
|
||||
private String enterpriseName;
|
||||
/** 用户姓名 */
|
||||
@Excel(name = "用户姓名")
|
||||
private String name;
|
||||
|
||||
@Excel(name = "用户职位")
|
||||
private String position;
|
||||
|
||||
@Excel(name = "公司所在省")
|
||||
private String province;
|
||||
|
||||
@Excel(name = "公司所在市")
|
||||
private String city;
|
||||
|
||||
@Excel(name = "公司所在县/区")
|
||||
private String county;
|
||||
|
||||
@Excel(name = "公司详细地址")
|
||||
private String address;
|
||||
|
||||
@Excel(name = "统一社会信用代码")
|
||||
private String creditCode;
|
||||
|
||||
@Excel(name = "营业执照")
|
||||
private String businessLicense;
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.server.controller;
|
||||
|
||||
import com.muyu.cache.DataTypeCacheService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.domain.DataType;
|
||||
import com.muyu.server.service.DataTypeService;
|
||||
|
@ -34,6 +35,9 @@ public class DataTypeController {
|
|||
@Autowired
|
||||
private DataTypeService dataTypeService;
|
||||
|
||||
@Autowired
|
||||
private DataTypeCacheService dataTypeCacheService;
|
||||
|
||||
|
||||
/**
|
||||
* 数据类型列表
|
||||
|
@ -42,7 +46,10 @@ public class DataTypeController {
|
|||
@PostMapping("/dataTypeList")
|
||||
@Operation(summary = "数据类型列表",description = "数据类型列表")
|
||||
public Result<List<DataType>> dataTypeList() {
|
||||
return Result.success(dataTypeService.list());
|
||||
|
||||
List<DataType> list = dataTypeService.list();
|
||||
dataTypeCacheService.put("List",list);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class SysCarController {
|
|||
return Result.success(sysCarService.addSysCar(sysCar));
|
||||
}
|
||||
|
||||
@PostMapping("/updateSysCar")
|
||||
@PutMapping
|
||||
@Operation(summary = "车辆修改",description = "车辆修改")
|
||||
public Result updateSysCar(@RequestBody SysCar sysCar){
|
||||
return Result.success(sysCarService.updateSysCar(sysCar));
|
||||
|
@ -90,7 +90,7 @@ public class SysCarController {
|
|||
* @param carVin
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/findFenceByCarVin/{carVin}")
|
||||
@PostMapping("/findFenceCarVin/{carVin}")
|
||||
@Operation(summary = "根据车辆的VIN码查询该车的故障记录",description = "根据车辆的VIN码查询该车的故障记录")
|
||||
public Result<List<SysCarFaultLogVo>> findFenceByCarVin(@PathVariable("carVin") String carVin){
|
||||
return Result.success(sysCarService.findFenceByCarVin(carVin));
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.server.controller;
|
||||
|
||||
import com.muyu.cache.TemplateCacheService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.domain.Template;
|
||||
import com.muyu.server.service.TemplateService;
|
||||
|
@ -17,7 +18,8 @@ import java.util.List;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* 报文模版管理
|
||||
* @author liuxinyue
|
||||
* @Package:com.template.controller
|
||||
* @Project:cloud-server-c
|
||||
* @name:TemplateController
|
||||
|
@ -33,6 +35,8 @@ public class TemplateController {
|
|||
@Autowired
|
||||
private TemplateService templateService;
|
||||
|
||||
@Autowired
|
||||
private TemplateCacheService templateCacheService;
|
||||
|
||||
/**
|
||||
* 报文模版列表
|
||||
|
@ -41,7 +45,12 @@ public class TemplateController {
|
|||
@PostMapping("/templateList")
|
||||
@Operation(summary = "报文模版列表",description = "报文模版列表")
|
||||
public Result<List<Template>> templateList() {
|
||||
return Result.success(templateService.list());
|
||||
|
||||
List<Template> list = templateService.list();
|
||||
|
||||
templateCacheService.put("List",list);
|
||||
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,4 +22,7 @@ public class InsertEnterprise {
|
|||
|
||||
@NotNull(message = "enterpriseFenceCount企业围栏组不能为空")
|
||||
private Integer enterpriseFenceCount;
|
||||
|
||||
@NotNull(message = "enterpriseDatabaseName企业数据库名称不能为空")
|
||||
private String enterpriseDatabaseName;
|
||||
}
|
||||
|
|
|
@ -28,4 +28,7 @@ public class UpdateEnterprise {
|
|||
|
||||
@NotNull(message = "enterpriseFenceCount企业围栏组不能为空")
|
||||
private Integer enterpriseFenceCount;
|
||||
|
||||
@NotNull(message = "enterpriseDatabaseName企业数据库名称不能为空")
|
||||
private String enterpriseDatabaseName;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.server.mapper;
|
|||
|
||||
import com.muyu.common.domain.Enterprise;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -33,5 +34,5 @@ public interface EnterpriseDao {
|
|||
|
||||
|
||||
//删除企业信息
|
||||
public int deleteByIds(Integer[] ids);
|
||||
public int deleteByIds(@Param("ids") Integer[] ids);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.server.mapper;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* kafka
|
||||
* @author liuxinyue
|
||||
* @Package:com.muyu.server.mapper
|
||||
* @name:KafkaMapper
|
||||
|
|
|
@ -19,8 +19,5 @@ import java.util.concurrent.ExecutionException;
|
|||
public interface TemplateService extends IService<Template> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void messageParsing(String templateMessage) throws SQLException, IoTDBConnectionException, ClassNotFoundException, StatementExecutionException, ExecutionException, InterruptedException;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.server.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.cache.CarTypeCacheService;
|
||||
import com.muyu.common.domain.CarType;
|
||||
import com.muyu.common.domain.resp.CarTypeResp;
|
||||
import com.muyu.server.mapper.CarTypeMapper;
|
||||
|
@ -20,17 +21,28 @@ import java.util.List;
|
|||
*/
|
||||
@Service
|
||||
public class CarTypeServiceImpl extends ServiceImpl<CarTypeMapper, CarType> implements CarTypeService{
|
||||
@Autowired
|
||||
private CarTypeMapper carTypeMapper;
|
||||
|
||||
@Autowired
|
||||
private CarTypeMapper carTypeMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private CarTypeCacheService carTypeCacheService;
|
||||
|
||||
@Override
|
||||
public List<CarType> selectCarTypeList() {
|
||||
QueryWrapper<CarType> carTypeQueryWrapper = new QueryWrapper<>();
|
||||
return carTypeMapper.selectList(carTypeQueryWrapper);
|
||||
List<CarType> list = carTypeMapper.selectList(carTypeQueryWrapper);
|
||||
|
||||
carTypeCacheService.put("List", list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarTypeResp selectCarTypeRespList(Long id) {
|
||||
return carTypeMapper.selectCarTypeRespList(id);
|
||||
CarTypeResp carTypeResp = carTypeMapper.selectCarTypeRespList(id);
|
||||
return carTypeResp;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,6 +55,7 @@ private CarTypeMapper carTypeMapper;
|
|||
|
||||
@Override
|
||||
public List<CarTypeResp> findAllCars() {
|
||||
return carTypeMapper.findAllCars();
|
||||
List<CarTypeResp> allCars = carTypeMapper.findAllCars();
|
||||
return allCars;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,9 +60,7 @@ public class ElectronicFenceGroupServiceImpl extends ServiceImpl<ElectronicFence
|
|||
);
|
||||
List<ElectronicFenceGroup> list = this.list(queryWrapper);
|
||||
|
||||
list.forEach(electronicFenceGroup -> {
|
||||
electronicFenceGroupCacheService.put(electronicFenceGroup.getId().toString(),electronicFenceGroup);
|
||||
});
|
||||
electronicFenceGroupCacheService.put("List",list);
|
||||
|
||||
return list;
|
||||
|
||||
|
@ -85,10 +83,6 @@ public class ElectronicFenceGroupServiceImpl extends ServiceImpl<ElectronicFence
|
|||
|
||||
electronicFenceGroupResp.setElectronicFenceRespList(electronicFenceRespList);
|
||||
}
|
||||
|
||||
electronicFenceGroupCacheService.put(electronicFenceGroup.getId().toString(),electronicFenceGroup);
|
||||
|
||||
|
||||
return electronicFenceGroupResp;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,12 @@ import lombok.extern.log4j.Log4j2;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 电子围栏 服务层处理
|
||||
*
|
||||
* @author yuping
|
||||
* @Package:com.muyu.fence.service.impl
|
||||
* @Project:cloud-server
|
||||
|
@ -43,123 +45,87 @@ public class ElectronicFenceServiceImpl extends ServiceImpl<ElectronicFenceMappe
|
|||
LambdaQueryWrapper<ElectronicFence> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
queryWrapper.like(
|
||||
StringUtils.isNotEmpty(electroicFenceListReq.getName()),ElectronicFence::getName, electroicFenceListReq.getName()
|
||||
StringUtils.isNotEmpty(electroicFenceListReq.getName()), ElectronicFence::getName, electroicFenceListReq.getName()
|
||||
);
|
||||
queryWrapper.eq(
|
||||
StringUtils.isNotEmpty(electroicFenceListReq.getFenceType()),ElectronicFence::getFenceType, electroicFenceListReq.getFenceType()
|
||||
StringUtils.isNotEmpty(electroicFenceListReq.getFenceType()), ElectronicFence::getFenceType, electroicFenceListReq.getFenceType()
|
||||
);
|
||||
queryWrapper.eq(
|
||||
StringUtils.isNotEmpty(electroicFenceListReq.getStatus()),ElectronicFence::getStatus, electroicFenceListReq.getStatus()
|
||||
StringUtils.isNotEmpty(electroicFenceListReq.getStatus()), ElectronicFence::getStatus, electroicFenceListReq.getStatus()
|
||||
);
|
||||
List<ElectronicFence> list = this.list(queryWrapper);
|
||||
|
||||
list.forEach(electronicFence -> {
|
||||
electronicFenceCacheService.put(electronicFence.getId().toString(),electronicFence);
|
||||
});
|
||||
electronicFenceCacheService.put("List", list);
|
||||
|
||||
List<ElectronicFence> electronicFenceList = electronicFenceCacheService.get("electronicFenceList");
|
||||
log.info("electronicFenceCacheService.get(electronicFenceList) = {}", electronicFenceList);
|
||||
|
||||
return list.stream().map(ElectronicFence::bullerResp).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddFence(ElectroicFenceAddReq electroicFenceAddReq) {
|
||||
|
||||
electronicFenceMapper.insert(ElectronicFence.buildElectroicAdd(electroicFenceAddReq));
|
||||
electronicFenceMapper.insert(ElectronicFence.buildElectroicAdd(electroicFenceAddReq));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectronicFence findElectronicByid(Long id) {
|
||||
|
||||
ElectronicFence electronicFence = electronicFenceMapper.selectById(id);
|
||||
|
||||
electronicFenceCacheService.put(id.toString(),electronicFence);
|
||||
|
||||
return electronicFence;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delElectronById(Long id) {
|
||||
|
||||
electronicFenceCacheService.remove(id.toString());
|
||||
|
||||
electronicFenceMapper.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void openFence(Long id) {
|
||||
|
||||
updateStatus(id,0);
|
||||
|
||||
updateStatus(id, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeFence(Long id) {
|
||||
updateStatus(id,1);
|
||||
updateStatus(id, 1);
|
||||
}
|
||||
|
||||
public void updateStatus (Long id,int status){
|
||||
public void updateStatus(Long id, int status) {
|
||||
UpdateWrapper<ElectronicFence> updateWrapper = new UpdateWrapper<>();
|
||||
|
||||
updateWrapper.eq("id",id).set("status",status);
|
||||
|
||||
updateWrapper.eq("id", id).set("status", status);
|
||||
this.update(updateWrapper);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setFenceWay(Long id, String longitudeLatitude) {
|
||||
|
||||
UpdateWrapper<ElectronicFence> updateWrapper = new UpdateWrapper<>();
|
||||
|
||||
updateWrapper.eq("id",id).set("longitude_latitude",longitudeLatitude);
|
||||
|
||||
updateWrapper.eq("id", id).set("longitude_latitude", longitudeLatitude);
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ElectronicFenceResp> fenceArray() {
|
||||
|
||||
LambdaQueryWrapper<ElectronicFence> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
LambdaQueryWrapper<ElectronicFence> wrapper = queryWrapper.eq(ElectronicFence::getStatus, 0);
|
||||
|
||||
List<ElectronicFence> list = this.list(wrapper);
|
||||
|
||||
list.forEach(electronicFence -> {
|
||||
electronicFenceCacheService.put(electronicFence.getId().toString(),electronicFence);
|
||||
});
|
||||
|
||||
return list.stream().map(ElectronicFence::bullerResp).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unquireFence(String name) {
|
||||
LambdaQueryWrapper<ElectronicFence> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
queryWrapper.eq(ElectronicFence::getName,name);
|
||||
|
||||
queryWrapper.eq(ElectronicFence::getName, name);
|
||||
List<ElectronicFence> fenceList = this.list(queryWrapper);
|
||||
|
||||
electronicFenceCacheService.remove(name);
|
||||
|
||||
if (fenceList.size()>0){
|
||||
if (fenceList.size() > 0) {
|
||||
throw new RuntimeException("电子围栏名不能重复");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ElectronicFenceResp> selectListByIds(List<Long> ids) {
|
||||
|
||||
List<ElectronicFence> electronicFenceList = this.list(Wrappers.<ElectronicFence>lambdaQuery().in(ElectronicFence::getId, ids));
|
||||
|
||||
electronicFenceList.forEach(electronicFence -> {
|
||||
electronicFenceCacheService.put(electronicFence.getId().toString(),electronicFence);
|
||||
});
|
||||
|
||||
return electronicFenceList.stream().map(ElectronicFence::bullerResp).toList();
|
||||
return electronicFenceList.stream().map(ElectronicFence::bullerResp).toList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class EnterpriseServiceImpl implements EnterpriseService {
|
|||
*/
|
||||
@Override
|
||||
public PageUtils selectEnterprise(Map param) {
|
||||
ArrayList<HashMap> list = new ArrayList<>();
|
||||
List<HashMap> list = new ArrayList<>();
|
||||
long count = enterpriseDao.selectEnterpriseCount();
|
||||
if (count > 0){
|
||||
list = enterpriseDao.selectEnterprise(param);
|
||||
|
@ -54,9 +54,6 @@ public class EnterpriseServiceImpl implements EnterpriseService {
|
|||
@Override
|
||||
public int insert(Enterprise enterprise) {
|
||||
int rows = enterpriseDao.insert(enterprise);
|
||||
if (rows > 0){
|
||||
enterpriseCacheService.put(String.valueOf(enterprise.getEnterpriseId()), enterprise);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
@ -69,12 +66,6 @@ public class EnterpriseServiceImpl implements EnterpriseService {
|
|||
@Override
|
||||
public HashMap searchById(int enterpriseId) {
|
||||
HashMap map = enterpriseDao.searchById(enterpriseId);
|
||||
if (map != null){
|
||||
Enterprise enterprise = enterpriseCacheService.get(String.valueOf(enterpriseId));
|
||||
if (enterprise != null){
|
||||
map.put("enterprise", enterprise);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -87,9 +78,6 @@ public class EnterpriseServiceImpl implements EnterpriseService {
|
|||
@Override
|
||||
public int updateEnterprise(Enterprise enterprise) {
|
||||
int rows = enterpriseDao.updateEnterprise(enterprise);
|
||||
if (rows > 0){
|
||||
enterpriseCacheService.put(String.valueOf(enterprise.getEnterpriseId()), enterprise);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
@ -104,10 +92,8 @@ public class EnterpriseServiceImpl implements EnterpriseService {
|
|||
if (ids == null || ids.length == 0) {
|
||||
throw new IllegalArgumentException("请选择要删除的企业名称编号");
|
||||
}
|
||||
|
||||
Integer[] idList = Arrays.asList(ids).toArray(new Integer[0]);
|
||||
int rows = enterpriseDao.deleteByIds(idList);
|
||||
enterpriseCacheService.remove(String.valueOf(idList));
|
||||
return rows;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.server.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.cache.MessageTemplateTypeCacheService;
|
||||
import com.muyu.common.domain.MessageTemplateType;
|
||||
import com.muyu.server.mapper.MessageTemplateTypeMapper;
|
||||
import com.muyu.server.service.MessageTemplateTypeService;
|
||||
|
@ -20,6 +21,9 @@ public class MessageTemplateTypeServiceImpl extends ServiceImpl<MessageTemplate
|
|||
@Autowired
|
||||
private MessageTemplateTypeMapper messageTemplateTypeMapper;
|
||||
|
||||
@Autowired
|
||||
private MessageTemplateTypeCacheService messageTemplateTypeCacheService;
|
||||
|
||||
|
||||
@Override
|
||||
public Integer addMessageType(MessageTemplateType messageTemplateType) {
|
||||
|
@ -33,6 +37,9 @@ public class MessageTemplateTypeServiceImpl extends ServiceImpl<MessageTemplate
|
|||
messageTemplateTypeQueryWrapper.eq("template_id",templatedId);
|
||||
messageTemplateTypeQueryWrapper.eq("message_class",code);
|
||||
List<MessageTemplateType> messageTemplateTypes = messageTemplateTypeMapper.selectList(messageTemplateTypeQueryWrapper);
|
||||
|
||||
messageTemplateTypeCacheService.put("List",messageTemplateTypes);
|
||||
|
||||
return messageTemplateTypes;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,7 @@ public class SysCarFaultMessageServiceImpl extends ServiceImpl<SysCarFaultMessag
|
|||
|
||||
List<SysCarFaultMessage> list = baseMapper.selectList(wrapper);
|
||||
|
||||
list.forEach(item->{
|
||||
sysCarFaultMessageCacheService.put(item.getContent(),item);
|
||||
});
|
||||
sysCarFaultMessageCacheService.put("List",list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
@ -53,11 +51,6 @@ public class SysCarFaultMessageServiceImpl extends ServiceImpl<SysCarFaultMessag
|
|||
public List<SysCarFaultMessage> listStatusOnt( ) {
|
||||
|
||||
List<SysCarFaultMessage> list = baseMapper.listStatusOnt();
|
||||
|
||||
list.forEach(item->{
|
||||
sysCarFaultMessageCacheService.put(item.getContent(),item);
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -67,13 +60,7 @@ public class SysCarFaultMessageServiceImpl extends ServiceImpl<SysCarFaultMessag
|
|||
*/
|
||||
@Override
|
||||
public List<SysCarFaultMessage> listStatusTwo( ) {
|
||||
|
||||
List<SysCarFaultMessage> list = baseMapper.listStatusTwo();
|
||||
|
||||
list.forEach(item->{
|
||||
sysCarFaultMessageCacheService.put(item.getContent(),item);
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,9 +43,6 @@ public class SysCarFaultServiceImpl
|
|||
LambdaQueryWrapper<SysCarFault> queryWrapper = new LambdaQueryWrapper<>();
|
||||
Assert.notNull(id, "id不可为空");
|
||||
queryWrapper.eq(SysCarFault::getId, id);
|
||||
|
||||
sysCarFaultCacheService.put(id.toString(),this.getOne(queryWrapper));
|
||||
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
|
@ -80,9 +77,7 @@ public class SysCarFaultServiceImpl
|
|||
|
||||
List<SysCarFault> list = this.list(queryWrapper);
|
||||
|
||||
list.forEach(sysCarFault1 -> {
|
||||
sysCarFaultCacheService.put(sysCarFault1.getId().toString(),sysCarFault1);
|
||||
});
|
||||
sysCarFaultCacheService.put("List",list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
@ -97,9 +92,6 @@ public class SysCarFaultServiceImpl
|
|||
|
||||
@Override
|
||||
public SysCarFault selectFaultByFaultCode(String faultCode) {
|
||||
|
||||
sysCarFaultCacheService.put(faultCode,mapper.selectFaultByFaultCode(faultCode));
|
||||
|
||||
return mapper.selectFaultByFaultCode(faultCode);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package com.muyu.server.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.cache.SysCarCacheService;
|
||||
import com.muyu.common.domain.SysCar;
|
||||
import com.muyu.common.domain.req.SysCarReq;
|
||||
import com.muyu.common.domain.resp.SysCarFaultLogVo;
|
||||
|
@ -11,41 +13,48 @@ import com.muyu.server.service.SysCarService;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 车辆管理 服务层处理
|
||||
* @author sx
|
||||
* @package com.muyu.server.service.impl
|
||||
* @name SysCarServiceImpl
|
||||
* @date 2024/9/22 14:36
|
||||
*/
|
||||
|
||||
@DS("lizzDB")
|
||||
@Service
|
||||
public class SysCarServiceImpl extends ServiceImpl<SysCarMapper, SysCar> implements SysCarService {
|
||||
@Autowired
|
||||
private SysCarMapper sysCarMapper;
|
||||
|
||||
@Autowired
|
||||
private SysCarCacheService sysCarCacheService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<SysCarVo> selectSysCarVoList(SysCarReq sysCarReq) {
|
||||
return sysCarMapper.selectSysCarVoList(sysCarReq);
|
||||
List<SysCarVo> sysCarVos = sysCarMapper.selectSysCarVoList(sysCarReq);
|
||||
sysCarCacheService.put("List", sysCarVos);
|
||||
return sysCarVos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysCarVo selectSysCarVoById(Long id) {
|
||||
return sysCarMapper.selectSysCarVoById(id);
|
||||
SysCarVo sysCarVo = sysCarMapper.selectSysCarVoById(id);
|
||||
return sysCarVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addSysCar(SysCar sysCar) {
|
||||
return sysCarMapper.insert(sysCar);
|
||||
int rows = sysCarMapper.insert(sysCar);
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteSysCarById(Long id) {
|
||||
return sysCarMapper.deleteById(id);
|
||||
int rows = sysCarMapper.deleteById(id);
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSysCar(SysCar sysCar) {
|
||||
return sysCarMapper.updateById(sysCar);
|
||||
int rows = sysCarMapper.updateById(sysCar);
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,7 +66,8 @@ public class SysCarServiceImpl extends ServiceImpl<SysCarMapper, SysCar> impleme
|
|||
public SysCar findCarByVin(String carVin) {
|
||||
QueryWrapper<SysCar> sysCarQueryWrapper = new QueryWrapper<>();
|
||||
sysCarQueryWrapper.eq("car_vin", carVin);
|
||||
SysCar sysCar = sysCarMapper.selectOne(sysCarQueryWrapper);
|
||||
return sysCar;
|
||||
List<SysCar> sysCars = sysCarMapper.selectList(sysCarQueryWrapper);
|
||||
return sysCars.isEmpty() ? null : sysCars.get(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.server.service.impl;
|
||||
|
||||
import com.muyu.cache.MessageTemplateTypeCacheService;
|
||||
import com.muyu.common.domain.MessageTemplateType;
|
||||
import com.muyu.server.mapper.TemplateNeedMapper;
|
||||
import com.muyu.server.service.TemplateNeedService;
|
||||
|
@ -21,9 +22,9 @@ public class TemplateNeedServiceImpl implements TemplateNeedService {
|
|||
@Autowired
|
||||
private TemplateNeedMapper templateNeedMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<MessageTemplateType> selectByTemplateId(Long templateId) {
|
||||
return templateNeedMapper.selectByTemplateId(templateId);
|
||||
List<MessageTemplateType> messageTemplateTypes = templateNeedMapper.selectByTemplateId(templateId);
|
||||
return messageTemplateTypes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.server.service.impl;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.cache.SysCarCacheService;
|
||||
import com.muyu.common.domain.MessageTemplateType;
|
||||
import com.muyu.common.domain.SysCar;
|
||||
import com.muyu.common.domain.Template;
|
||||
|
@ -17,9 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
|
@ -35,7 +34,80 @@ public class TemplateServiceImpl extends ServiceImpl<TemplateMapper, Template> i
|
|||
@Autowired
|
||||
private static TemplateMapper templateMapper;
|
||||
|
||||
@Autowired
|
||||
private SysCarService sysCarService;
|
||||
|
||||
@Autowired
|
||||
private MessageTemplateTypeService messageTemplateTypeService;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public void messageParsing(String templateMessage) throws SQLException, IoTDBConnectionException, ClassNotFoundException, StatementExecutionException, ExecutionException, InterruptedException {
|
||||
|
||||
//给一个JSON对象
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
//先截取出VIN码 然后根据VIN码查询这个车属于什么类型
|
||||
if (templateMessage.length() < 18) {
|
||||
throw new RuntimeException("The vehicle message is incorrect");
|
||||
}
|
||||
//将报文进行切割
|
||||
String[] hexArray = templateMessage.split(" ");
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (String hex : hexArray) {
|
||||
int decimal = Integer.parseInt(hex, 16);
|
||||
result.append((char) decimal);
|
||||
}
|
||||
//取出VIN码
|
||||
String carVin = result.substring(0, 18 - 1);
|
||||
log.info("carVin码为:" + carVin);
|
||||
//根据VIN码获取车辆信息
|
||||
SysCar carByVin = sysCarService.findCarByVin(carVin);
|
||||
log.info("车辆信息为:" + carByVin);
|
||||
//对应车辆所对应的报文模版
|
||||
Integer templateId = carByVin.getTemplateId();
|
||||
List<MessageTemplateType> templateTypeList;
|
||||
//key
|
||||
String redisKey = "messageTemplateType" + templateId;
|
||||
log.info("key为:" + redisKey);
|
||||
//key存在
|
||||
if (redisTemplate.hasKey(redisKey)) {
|
||||
|
||||
List list = redisTemplate.opsForList().range(redisKey, 0, -1);
|
||||
templateTypeList = list.stream().map(o -> JSON.parseObject(o.toString(), MessageTemplateType.class))
|
||||
.toList();
|
||||
} else {
|
||||
List<MessageTemplateType> templateTypeList1 = messageTemplateTypeService.findTemplateById(templateId);
|
||||
log.info("redis存入成功");
|
||||
templateTypeList = templateTypeList1;
|
||||
templateTypeList1.forEach(
|
||||
templateType ->
|
||||
redisTemplate.opsForList().rightPush(
|
||||
redisKey, com.alibaba.fastjson.JSON.toJSONString(templateType)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
log.info("哈哈哈哈哈哈哈"+templateTypeList);
|
||||
//将模版里面有的配置进行循环
|
||||
for (MessageTemplateType messageTemplateType : templateTypeList) {
|
||||
//开始位置
|
||||
Integer startIndex = messageTemplateType.getStartIndex() - 1;
|
||||
//结束位置
|
||||
Integer endIndex = messageTemplateType.getEndIndex();
|
||||
String substring = result.substring(startIndex, endIndex);
|
||||
log.info("截取后的字符1:" + substring);
|
||||
//将每个解析后的字段都存入到JSON对象中
|
||||
jsonObject.put(messageTemplateType.getMessageField(),substring );
|
||||
}
|
||||
|
||||
System.out.println("哈哈哈红红火火恍恍惚惚");
|
||||
log.info("解析后的报文是:" + jsonObject);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.server.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.cache.WarnRuleCacheService;
|
||||
import com.muyu.common.domain.WarnRule;
|
||||
import com.muyu.common.domain.resp.WarnRuleResp;
|
||||
import com.muyu.server.mapper.WarnRuleMapper;
|
||||
|
@ -24,6 +25,9 @@ public class WarnRuleServiceImpl
|
|||
@Autowired
|
||||
private WarnRuleMapper warnRuleMapper;
|
||||
|
||||
@Autowired
|
||||
private WarnRuleCacheService warnRuleCacheService;
|
||||
|
||||
/**
|
||||
* 精确查询预警规则
|
||||
*
|
||||
|
@ -33,7 +37,8 @@ public class WarnRuleServiceImpl
|
|||
@Override
|
||||
public WarnRule selectWarnRuleById(Long id)
|
||||
{
|
||||
return warnRuleMapper.selectById(id);
|
||||
WarnRule warnRule = warnRuleMapper.selectById(id);
|
||||
return warnRule;
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,23 +51,28 @@ public class WarnRuleServiceImpl
|
|||
@Override
|
||||
public List<WarnRuleResp> selectWarnRuleRespList()
|
||||
{
|
||||
return warnRuleMapper.selectWarnRuleRespList();
|
||||
List<WarnRuleResp> warnRuleResps = warnRuleMapper.selectWarnRuleRespList();
|
||||
warnRuleCacheService.put("List",warnRuleResps);
|
||||
return warnRuleResps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer addWarnRule(WarnRule warnRule) {
|
||||
return warnRuleMapper.insert(warnRule);
|
||||
int rows = warnRuleMapper.insert(warnRule);
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updWarnRule(WarnRule warnRule) {
|
||||
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||
return warnRuleMapper.update(queryWrapper);
|
||||
Integer update = warnRuleMapper.update(queryWrapper);
|
||||
return update;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WarnRuleResp> selectListByStrategyId(Long strategyId) {
|
||||
return warnRuleMapper.selectListByStrategyId(strategyId);
|
||||
List<WarnRuleResp> warnRuleResps = warnRuleMapper.selectListByStrategyId(strategyId);
|
||||
return warnRuleResps;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.server.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.cache.WarnStrategyCacheService;
|
||||
import com.muyu.common.domain.WarnStrategy;
|
||||
import com.muyu.common.domain.req.WarnStrategyReq;
|
||||
import com.muyu.common.domain.resp.WarnStrategyResp;
|
||||
|
@ -25,6 +26,9 @@ public class WarnStrategyServiceImpl
|
|||
@Autowired
|
||||
private WarnStrategyMapper warnStrategyMapper;
|
||||
|
||||
@Autowired
|
||||
private WarnStrategyCacheService warnStrategyCacheService;
|
||||
|
||||
/**
|
||||
* 精确查询预警策略
|
||||
*
|
||||
|
@ -34,7 +38,8 @@ public class WarnStrategyServiceImpl
|
|||
@Override
|
||||
public WarnStrategy selectWarnStrategyById(Long id)
|
||||
{
|
||||
return warnStrategyMapper.selectById(id);
|
||||
WarnStrategy warnStrategy = warnStrategyMapper.selectById(id);
|
||||
return warnStrategy;
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,12 +52,15 @@ public class WarnStrategyServiceImpl
|
|||
@Override
|
||||
public List<WarnStrategyResp> selectWarnStrategyList(WarnStrategyReq warnStrategyReq)
|
||||
{
|
||||
return warnStrategyMapper.selectWarnStrategyList(warnStrategyReq);
|
||||
List<WarnStrategyResp> warnStrategyResps = warnStrategyMapper.selectWarnStrategyList(warnStrategyReq);
|
||||
warnStrategyCacheService.put("List",warnStrategyResps);
|
||||
return warnStrategyResps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteWarnStrategy(Long id) {
|
||||
return warnStrategyMapper.deleteById(id);
|
||||
int rows = warnStrategyMapper.deleteById(id);
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +70,8 @@ public class WarnStrategyServiceImpl
|
|||
@Override
|
||||
public Integer updWarnStrategy(WarnStrategy warnStrategy){
|
||||
QueryWrapper<WarnStrategy> wrapper = new QueryWrapper<>(warnStrategy);
|
||||
return warnStrategyMapper.update(wrapper);
|
||||
Integer update = warnStrategyMapper.update(wrapper);
|
||||
return update;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +79,8 @@ public class WarnStrategyServiceImpl
|
|||
*/
|
||||
@Override
|
||||
public Integer addWarnStrategy(WarnStrategy warnStrategy){
|
||||
return warnStrategyMapper.insert(warnStrategy);
|
||||
int rows = warnStrategyMapper.insert(warnStrategy);
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,7 +90,8 @@ public class WarnStrategyServiceImpl
|
|||
*/
|
||||
@Override
|
||||
public List<WarnStrategyResp> selectListByCarType(Long carTypeId) {
|
||||
return warnStrategyMapper.selectListByCarType(carTypeId);
|
||||
List<WarnStrategyResp> warnStrategyResps = warnStrategyMapper.selectListByCarType(carTypeId);
|
||||
return warnStrategyResps;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ nacos:
|
|||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||
# Spring
|
||||
spring:
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
amqp:
|
||||
deserialization:
|
||||
trust:
|
||||
|
|
|
@ -31,14 +31,15 @@
|
|||
insert into tb_enterprise
|
||||
set enterprise_name = #{enterpriseName},
|
||||
enterprise_car_count = #{enterpriseCarCount},
|
||||
enterprise_fence_count = #{enterpriseFenceCount}
|
||||
enterprise_fence_count = #{enterpriseFenceCount},
|
||||
enterprise_database_name=#{enterpriseDatabaseName}
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
<!--根据编号查询企业信息-->
|
||||
<select id="searchById" resultType="java.util.HashMap">
|
||||
select enterprise_id,enterprise_name,enterprise_car_count,enterprise_fence_count
|
||||
select enterprise_id,enterprise_name,enterprise_car_count,enterprise_fence_count,enterprise_database_name
|
||||
from tb_enterprise
|
||||
where enterprise_id = #{enterpriseId}
|
||||
</select>
|
||||
|
@ -47,7 +48,8 @@
|
|||
update tb_enterprise
|
||||
set enterprise_name = #{enterpriseName},
|
||||
enterprise_car_count = #{enterpriseCarCount},
|
||||
enterprise_fence_count = #{enterpriseFenceCount}
|
||||
enterprise_fence_count = #{enterpriseFenceCount},
|
||||
enterprise_database_name=#{enterpriseDatabaseName}
|
||||
where enterprise_id = #{enterpriseId} and enterprise_id != 0
|
||||
</update>
|
||||
|
||||
|
|
Loading…
Reference in New Issue