Compare commits

...

25 Commits

Author SHA1 Message Date
ruyaxie ee6da76129 Merge remote-tracking branch 'origin/dev' into dev
# Conflicts:
#	cloud-modules/cloud-modules-enterprise/enterpise-cache/pom.xml
#	cloud-modules/cloud-modules-enterprise/enterpise-common/pom.xml
#	cloud-modules/cloud-modules-enterprise/enterpise-service/pom.xml
#	cloud-modules/cloud-modules-parse/pom.xml
#	cloud-modules/cloud-modules-parse/src/main/resources/bootstrap.yml
#	cloud-modules/cloud-modules-vehicle-gateway/src/main/resources/bootstrap.yml
#	pom.xml
2024-10-09 16:55:09 +08:00
ruyaxie 89c2fc33fa Merge branch 'dev.parse' into dev
# Conflicts:
#	pom.xml
2024-10-09 16:54:48 +08:00
王鑫 5c4e0cde3e fix():修改saas结构 2024-10-09 16:33:33 +08:00
ruyaxie 4f0fa2e95c Merge branch 'dev.parse' into dev
# Conflicts:
#	cloud-modules/cloud-modules-enterprise/enterpise-cache/pom.xml
#	cloud-modules/cloud-modules-enterprise/enterpise-common/pom.xml
#	cloud-modules/cloud-modules-enterprise/enterpise-service/pom.xml
#	cloud-modules/cloud-modules-vehicle-gateway/src/main/resources/bootstrap.yml
#	pom.xml
2024-10-08 19:51:47 +08:00
DongZeLiang dcd9ce68df fix(): 修复包名等格式规范问题 2024-10-08 19:12:42 +08:00
王鑫 65d7fb3de1 fix():重新构建结构 2024-10-08 19:12:42 +08:00
王鑫 a993b30e6e fix():重新构建结构 2024-10-08 19:12:39 +08:00
YangPeng 92c2d7b11b feat():添加剩余注释 2024-10-08 19:12:19 +08:00
YangPeng 75b6097fed feat():添加缓存注释 2024-10-08 19:12:19 +08:00
YangPeng c86f2732b0 fix():bootstrap.yml其他名字改成yp启动,防止端口占用 2024-10-08 19:12:13 +08:00
王鑫 553d5933ed fix():重新构建结构 2024-10-08 19:10:32 +08:00
YangPeng ff98f1cc1b fix():添加车辆全部缓存 2024-10-08 19:10:32 +08:00
YangPeng 1468206f1d Merge branch 'dev' of https://gitea.qinmian.online/wuzudaniu/cloud-plus-server into dev.saas.yp 2024-10-08 16:34:34 +08:00
DongZeLiang 47222f5f68 fix(): 修复包名等格式规范问题 2024-10-08 16:25:15 +08:00
王鑫 0c8a13439f fix():重新构建结构 2024-10-08 16:17:38 +08:00
YangPeng 492be37314 feat():添加剩余注释 2024-10-08 16:08:45 +08:00
王鑫 5a0f5e28d2 fix():重新构建结构 2024-10-08 16:05:18 +08:00
YangPeng e1d45db36e Merge branch 'dev.saas.yp' into dev
# Conflicts:
#	cloud-modules/cloud-modules-enterprise/enterpise-service/src/main/resources/bootstrap.yml
#	cloud-modules/cloud-modules-parse/src/main/resources/bootstrap.yml
#	cloud-modules/cloud-modules-vehicle-gateway/src/main/resources/bootstrap.yml
2024-10-08 16:02:04 +08:00
YangPeng e50219f9fb feat():添加缓存注释 2024-10-08 15:58:28 +08:00
王鑫 54d216b144 fix():重新构建结构 2024-10-08 15:58:18 +08:00
王鑫 293cb42bcf Merge remote-tracking branch 'origin/dev' into dev 2024-10-08 15:56:00 +08:00
王鑫 9ba5f8e14a fix():重新构建结构 2024-10-08 15:54:50 +08:00
YangPeng 83756518ad fix():bootstrap.yml其他名字改成yp启动,防止端口占用 2024-10-07 22:37:39 +08:00
YangPeng 44ec3e9eed Merge branch 'dev.saas.yp' into dev 2024-10-07 22:10:46 +08:00
YangPeng 45cb6b2a17 fix():添加车辆全部缓存 2024-10-07 22:05:38 +08:00
223 changed files with 2008 additions and 1784 deletions

View File

@ -34,7 +34,7 @@ public class TokenController {
@PostMapping("login")
public Result<?> login (@RequestBody LoginBody form) {
// 用户登录
LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword(), form.getFirmId());
// 获取登录token
return Result.success(tokenService.createToken(userInfo));
}

View File

@ -1,10 +1,20 @@
package com.muyu.auth.form;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
*
*
* @author muyu
*/
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class LoginBody {
/**
*
@ -16,19 +26,9 @@ public class LoginBody {
*/
private String password;
public String getUsername () {
return username;
}
/**
* id
*/
private Long firmId;
public void setUsername (String username) {
this.username = username;
}
public String getPassword () {
return password;
}
public void setPassword (String password) {
this.password = password;
}
}

View File

@ -40,9 +40,9 @@ public class SysLoginService {
/**
*
*/
public LoginUser login (String username, String password) {
public LoginUser login(String username, String password, Long firmId) {
// 用户名或密码为空 错误
if (StringUtils.isAnyBlank(username, password)) {
if (StringUtils.isAnyBlank(username, password, String.valueOf(firmId))) {
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
throw new ServiceException("用户/密码必须填写");
}
@ -65,7 +65,9 @@ public class SysLoginService {
throw new ServiceException("很遗憾访问IP已被列入系统黑名单");
}
// 查询用户信息
Result<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
Result<LoginUser> userResult = null;
// 查询用户信息
userResult = remoteUserService.getUserInfo(username, firmId, SecurityConstants.INNER);
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
@ -91,14 +93,14 @@ public class SysLoginService {
return userInfo;
}
public void logout (String loginName) {
public void logout(String loginName) {
recordLogService.recordLogininfor(loginName, Constants.LOGOUT, "退出成功");
}
/**
*
*/
public void register (String username, String password) {
public void register(String username, String password) {
// 用户名或密码为空 错误
if (StringUtils.isAnyBlank(username, password)) {
throw new ServiceException("用户/密码必须填写");

View File

@ -1,6 +1,6 @@
# Tomcat
server:
port: 9500
port: 19500
# nacos线上地址
nacos:

View File

@ -27,11 +27,6 @@
<groupId>com.muyu</groupId>
<artifactId>cloud-common-redis</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>enterpise-common</artifactId>
<version>${muyu.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -9,29 +9,32 @@ package com.muyu.common.cache;
* * @Version: 1.0
* * @description:
*/
public interface PrimaryKeyBasic <K>{
public interface PrimaryKeyBasic<K> {
/**
*
*
* @return
*/
public String keyPre();
/**
*
*
* @param key
* @return
*/
public default String encode(K key){
return keyPre() + key.toString();
public default String encode(K key) {
return key.toString() + keyPre();
}
/**
*
*
* @param key
* @return
*/
public default K decode(String key) {
return (K) key.substring(keyPre().length());
return (K) key.substring(0, key.lastIndexOf(keyPre()));
}
}

View File

@ -9,12 +9,12 @@ public class CacheConstants {
/**
* 720
*/
public final static long EXPIRATION = 720;
public final static Long EXPIRATION = 720L;
/**
* 120
*/
public final static long REFRESH_TIME = 120;
public final static Long REFRESH_TIME = 120L;
/**
*
@ -24,7 +24,7 @@ public class CacheConstants {
/**
* 10
*/
public final static long PASSWORD_LOCK_TIME = 10;
public final static Long PASSWORD_LOCK_TIME = 10L;
/**
*

View File

@ -109,7 +109,7 @@ public class Constants {
/**
*
*/
public static final long CAPTCHA_EXPIRATION = 2;
public static final Long CAPTCHA_EXPIRATION = 2L;
/**
*

View File

@ -54,7 +54,7 @@ public class GenConstants {
/**
*
*/
public static final String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext"};
public static final String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "Longtext"};
/**
*

View File

@ -45,4 +45,13 @@ public class SecurityConstants {
*
*/
public static final String ROLE_PERMISSION = "role_permission";
/**
* key
*/
public static final String FIRM_KEY = "firm_key";
/**
* Id
*/
public static final String FIRM_ID = "firm_id";
}

View File

@ -24,6 +24,6 @@ public class ServiceNameConstants {
/**
* serviceid
*/
public static final String ENTERPRISE_SERVICE = "cloud-saas";
public static final String ENTERPRISE_SERVICE = "cloud-enterprise";
}

View File

@ -32,7 +32,7 @@ public class Result<T> implements Serializable {
*/
public static final int WARN = HttpStatus.WARN;
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
private int code;

View File

@ -6,7 +6,7 @@ package com.muyu.common.core.exception;
* @author muyu
*/
public class CaptchaException extends RuntimeException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public CaptchaException (String msg) {
super(msg);

View File

@ -6,7 +6,7 @@ package com.muyu.common.core.exception;
* @author muyu
*/
public class CheckedException extends RuntimeException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public CheckedException (String message) {
super(message);

View File

@ -6,7 +6,7 @@ package com.muyu.common.core.exception;
* @author muyu
*/
public class DemoModeException extends RuntimeException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public DemoModeException () {
}

View File

@ -6,7 +6,7 @@ package com.muyu.common.core.exception;
* @author muyu
*/
public class GlobalException extends RuntimeException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/**
*

View File

@ -6,7 +6,7 @@ package com.muyu.common.core.exception;
* @author muyu
*/
public class InnerAuthException extends RuntimeException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public InnerAuthException (String message) {
super(message);

View File

@ -6,7 +6,7 @@ package com.muyu.common.core.exception;
* @author muyu
*/
public class PreAuthorizeException extends RuntimeException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public PreAuthorizeException () {
}

View File

@ -6,7 +6,7 @@ package com.muyu.common.core.exception;
* @author muyu
*/
public class ServiceException extends RuntimeException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/**
*

View File

@ -6,7 +6,7 @@ package com.muyu.common.core.exception;
* @author muyu
*/
public class UtilException extends RuntimeException {
private static final long serialVersionUID = 8247610319171014183L;
private static final Long serialVersionUID = 8247610319171014183L;
public UtilException (Throwable e) {
super(e.getMessage(), e);

View File

@ -6,7 +6,7 @@ package com.muyu.common.core.exception.auth;
* @author muyu
*/
public class NotLoginException extends RuntimeException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public NotLoginException (String message) {
super(message);

View File

@ -8,7 +8,7 @@ import org.apache.commons.lang3.StringUtils;
* @author muyu
*/
public class NotPermissionException extends RuntimeException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public NotPermissionException (String permission) {
super(permission);

View File

@ -8,7 +8,7 @@ import org.apache.commons.lang3.StringUtils;
* @author muyu
*/
public class NotRoleException extends RuntimeException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public NotRoleException (String role) {
super(role);

View File

@ -6,7 +6,7 @@ package com.muyu.common.core.exception.base;
* @author muyu
*/
public class BaseException extends RuntimeException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/**
*

View File

@ -8,7 +8,7 @@ import com.muyu.common.core.exception.base.BaseException;
* @author muyu
*/
public class FileException extends BaseException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public FileException (String code, Object[] args, String msg) {
super("file", code, args, msg);

View File

@ -6,9 +6,9 @@ package com.muyu.common.core.exception.file;
* @author muyu
*/
public class FileNameLengthLimitExceededException extends FileException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public FileNameLengthLimitExceededException (int defaultFileNameLength) {
super("upload.filename.exceed.length", new Object[]{defaultFileNameLength}, "the filename is too long");
super("upload.filename.exceed.length", new Object[]{defaultFileNameLength}, "the filename is too Long");
}
}

View File

@ -6,9 +6,9 @@ package com.muyu.common.core.exception.file;
* @author muyu
*/
public class FileSizeLimitExceededException extends FileException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public FileSizeLimitExceededException (long defaultMaxSize) {
public FileSizeLimitExceededException (Long defaultMaxSize) {
super("upload.exceed.maxSize", new Object[]{defaultMaxSize}, "the filesize is too large");
}
}

View File

@ -10,7 +10,7 @@ import java.io.PrintWriter;
*/
public class FileUploadException extends Exception {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
private final Throwable cause;

View File

@ -8,7 +8,7 @@ import java.util.Arrays;
* @author muyu
*/
public class InvalidExtensionException extends FileUploadException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
private String[] allowedExtension;
private String extension;
@ -34,7 +34,7 @@ public class InvalidExtensionException extends FileUploadException {
}
public static class InvalidImageExtensionException extends InvalidExtensionException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public InvalidImageExtensionException (String[] allowedExtension, String extension, String filename) {
super(allowedExtension, extension, filename);
@ -42,7 +42,7 @@ public class InvalidExtensionException extends FileUploadException {
}
public static class InvalidFlashExtensionException extends InvalidExtensionException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public InvalidFlashExtensionException (String[] allowedExtension, String extension, String filename) {
super(allowedExtension, extension, filename);
@ -50,7 +50,7 @@ public class InvalidExtensionException extends FileUploadException {
}
public static class InvalidMediaExtensionException extends InvalidExtensionException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public InvalidMediaExtensionException (String[] allowedExtension, String extension, String filename) {
super(allowedExtension, extension, filename);
@ -58,7 +58,7 @@ public class InvalidExtensionException extends FileUploadException {
}
public static class InvalidVideoExtensionException extends InvalidExtensionException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public InvalidVideoExtensionException (String[] allowedExtension, String extension, String filename) {
super(allowedExtension, extension, filename);

View File

@ -6,7 +6,7 @@ package com.muyu.common.core.exception.job;
* @author muyu
*/
public class TaskException extends Exception {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
private Code code;

View File

@ -6,7 +6,7 @@ package com.muyu.common.core.exception.user;
* @author muyu
*/
public class CaptchaExpireException extends UserException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public CaptchaExpireException () {
super("user.jcaptcha.expire", null);

View File

@ -8,7 +8,7 @@ import com.muyu.common.core.exception.base.BaseException;
* @author muyu
*/
public class UserException extends BaseException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public UserException (String code, Object[] args) {
super("user", code, args, null);

View File

@ -6,7 +6,7 @@ package com.muyu.common.core.exception.user;
* @author muyu
*/
public class UserPasswordNotMatchException extends UserException {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
public UserPasswordNotMatchException () {
super("user.password.not.match", null);

View File

@ -313,12 +313,12 @@ public class Convert {
return new Long[]{};
}
String[] arr = str.split(split);
final Long[] longs = new Long[arr.length];
final Long[] Longs = new Long[arr.length];
for (int i = 0 ; i < arr.length ; i++) {
final Long v = toLong(arr[i], null);
longs[i] = v;
Longs[i] = v;
}
return longs;
return Longs;
}
/**
@ -345,7 +345,7 @@ public class Convert {
}
/**
* long<br>
* Long<br>
* <br>
*
*
@ -377,7 +377,7 @@ public class Convert {
}
/**
* long<br>
* Long<br>
* <code>null</code><code>null</code><br>
*
*

View File

@ -109,7 +109,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
*
*/
public static Date getServerStartDate () {
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
Long time = ManagementFactory.getRuntimeMXBean().getStartTime();
return new Date(time);
}
@ -122,20 +122,20 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
* @return //
*/
public static String timeDistance (Date endDate, Date startTime) {
long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;
// long ns = 1000;
Long nd = 1000 * 24 * 60 * 60L;
Long nh = 1000 * 60 * 60L;
Long nm = 1000 * 60L;
// Long ns = 1000;
// 获得两个时间的毫秒时间差异
long diff = endDate.getTime() - startTime.getTime();
Long diff = endDate.getTime() - startTime.getTime();
// 计算差多少天
long day = diff / nd;
Long day = diff / nd;
// 计算差多少小时
long hour = diff % nd / nh;
Long hour = diff % nd / nh;
// 计算差多少分钟
long min = diff % nd % nh / nm;
Long min = diff % nd % nh / nm;
// 计算差多少秒//输出结果
// long sec = diff % nd % nh % nm / ns;
// Long sec = diff % nd % nh % nm / ns;
return day + "天" + hour + "小时" + min + "分钟";
}

View File

@ -162,4 +162,21 @@ public class JwtUtils {
public static String getValue (Claims claims, String key) {
return Convert.toStr(claims.get(key), "");
}
/**
*
* @param claims
* @return
*/
public static String getFirmKey(Claims claims) {
return getValue(claims, SecurityConstants.FIRM_KEY);
}
/**
*
* @param claims
* @return
*/
public static String getFirmId(Claims claims) {
return getValue(claims, SecurityConstants.FIRM_ID);
}
}

View File

@ -45,7 +45,7 @@ public final class HTMLFilter {
private static final ConcurrentMap<String, Pattern> P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<>();
/**
* set of allowed html elements, along with allowed attributes for each element
* set of allowed html elements, aLong with allowed attributes for each element
**/
private final Map<String, List<String>> vAllowed;
/**

View File

@ -127,7 +127,7 @@ public class IpUtils {
byte[] bytes = new byte[4];
String[] elements = text.split("\\.", -1);
try {
long l;
Long l;
int i;
switch (elements.length) {
case 1:
@ -141,12 +141,12 @@ public class IpUtils {
bytes[3] = (byte) (int) (l & 0xFF);
break;
case 2:
l = Integer.parseInt(elements[0]);
l = (long) Integer.parseInt(elements[0]);
if ((l < 0L) || (l > 255L)) {
return null;
}
bytes[0] = (byte) (int) (l & 0xFF);
l = Integer.parseInt(elements[1]);
l = (long) Integer.parseInt(elements[1]);
if ((l < 0L) || (l > 16777215L)) {
return null;
}
@ -156,13 +156,13 @@ public class IpUtils {
break;
case 3:
for (i = 0; i < 2 ; ++i) {
l = Integer.parseInt(elements[i]);
l = (long) Integer.parseInt(elements[i]);
if ((l < 0L) || (l > 255L)) {
return null;
}
bytes[i] = (byte) (int) (l & 0xFF);
}
l = Integer.parseInt(elements[2]);
l = (long) Integer.parseInt(elements[2]);
if ((l < 0L) || (l > 65535L)) {
return null;
}
@ -171,7 +171,7 @@ public class IpUtils {
break;
case 4:
for (i = 0; i < 4 ; ++i) {
l = Integer.parseInt(elements[i]);
l = (long) Integer.parseInt(elements[i]);
if ((l < 0L) || (l > 255L)) {
return null;
}
@ -290,14 +290,14 @@ public class IpUtils {
String[] sips = iparea.substring(0, idx).split("\\.");
String[] sipe = iparea.substring(idx + 1).split("\\.");
String[] sipt = ip.split("\\.");
long ips = 0L, ipe = 0L, ipt = 0L;
Long ips = 0L, ipe = 0L, ipt = 0L;
for (int i = 0 ; i < 4 ; ++i) {
ips = ips << 8 | Integer.parseInt(sips[i]);
ipe = ipe << 8 | Integer.parseInt(sipe[i]);
ipt = ipt << 8 | Integer.parseInt(sipt[i]);
}
if (ips > ipe) {
long t = ips;
Long t = ips;
ips = ipe;
ipe = t;
}

View File

@ -30,8 +30,8 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
* @param data
*/
private UUID (byte[] data) {
long msb = 0;
long lsb = 0;
long msb = 0L;
long lsb = 0L;
assert data.length == 16 : "data must be 16 bytes in length";
for (int i = 0 ; i < 8 ; i++) {
msb = (msb << 8) | (data[i] & 0xff);
@ -131,15 +131,15 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
components[i] = "0x" + components[i];
}
long mostSigBits = Long.decode(components[0]).longValue();
long mostSigBits = Long.decode(components[0]);
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[1]).longValue();
mostSigBits |= Long.decode(components[1]);
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[2]).longValue();
mostSigBits |= Long.decode(components[2]);
long leastSigBits = Long.decode(components[3]).longValue();
long leastSigBits = Long.decode(components[3]);
leastSigBits <<= 48;
leastSigBits |= Long.decode(components[4]).longValue();
leastSigBits |= Long.decode(components[4]);
return new UUID(mostSigBits, leastSigBits);
}

View File

@ -24,7 +24,7 @@ import java.util.Map;
@NoArgsConstructor
@AllArgsConstructor
public class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/**
*

View File

@ -17,7 +17,7 @@ import java.util.List;
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class TreeEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/**
*

View File

@ -20,12 +20,12 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
public class TableDataInfo<T> implements Serializable {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/**
*
*/
private long total;
private Long total;
/**
*

View File

@ -71,7 +71,7 @@ public class IotDBSessionConfig {
* @param value
*/
public void insertRecord(SessionPool sessionPool,String deviceId,
long time, List<String> measurements,List<TSDataType> dataTypeList, JSONObject value) {
Long time, List<String> measurements,List<TSDataType> dataTypeList, JSONObject value) {
try {
log.info("iotdb数据入库device_id:[{}], measurements:[{}], values:[{}]", deviceId, measurements, value);
sessionPool.insertRecord(deviceId, time, measurements,dataTypeList,new Object[]{value.toJSONString()});
@ -153,26 +153,26 @@ public class IotDBSessionConfig {
SessionDataSet sessionDataSet = iotDBSessionConfig.selectRecord(sessionPool,SELECT_ROOT_DATA_DATAJSON_DATASOURCE);
HashMap<Long, Map<String, String>> longMapHashMap = new HashMap<>();
HashMap<Long, Map<String, String>> LongMapHashMap = new HashMap<>();
try {
while (sessionDataSet.hasNext()){
RowRecord next = sessionDataSet.next();
long timestamp = next.getTimestamp();
Long timestamp = next.getTimestamp();
Map<String, String> fieldMap = new HashMap<>();
for (Field field : next.getFields()) {
TSDataType dataType = field.getDataType();
String stringValue = field.getStringValue();
fieldMap.put(dataType.name(), stringValue);
}
longMapHashMap.put(timestamp, fieldMap);
LongMapHashMap.put(timestamp, fieldMap);
}
} catch (StatementExecutionException e) {
throw new RuntimeException(e);
} catch (IoTDBConnectionException e) {
throw new RuntimeException(e);
}
log.info("数据为:{}", JSONObject.toJSONString(longMapHashMap));
log.info("数据为:{}", JSONObject.toJSONString(LongMapHashMap));
}
}

View File

@ -23,9 +23,9 @@ public interface IotDBService {
void insertTablets(Map<String, Tablet> tablets);
void insertStringRecord(String deviceId, long time, List<String> measurements, List<String> values);
void insertStringRecord(String deviceId, Long time, List<String> measurements, List<String> values);
void insertRecord(String deviceId, long time, List<String> measurements, List<TSDataType> types, List<Object> values);
void insertRecord(String deviceId, Long time, List<String> measurements, List<TSDataType> types, List<Object> values);
void insertStringRecords(List<String> deviceIds, List<Long> times, List<List<String>> measurementsList, List<List<String>> valuesList);
@ -35,17 +35,17 @@ public interface IotDBService {
void insertRecordsOfOneDevice(String deviceId, List<Long> times, List<List<String>> measurementsList, List<List<TSDataType>> typesList, List<List<Object>> valuesList);
void deleteData(String path, long endTime);
void deleteData(String path, Long endTime);
void deleteData(List<String> paths, long endTime);
void deleteData(List<String> paths, Long endTime);
SessionDataSet executeRawDataQuery(List<String> paths, long startTime, long endTime, long timeOut);
SessionDataSet executeRawDataQuery(List<String> paths, Long startTime, Long endTime, Long timeOut);
<T> List<T> executeRawDataQuery(List<String> paths, long startTime, long endTime, long timeOut, Class<? extends IotDbRecordAble> clazz);
<T> List<T> executeRawDataQuery(List<String> paths, Long startTime, Long endTime, Long timeOut, Class<? extends IotDbRecordAble> clazz);
SessionDataSet executeLastDataQuery(List<String> paths, long lastTime);
SessionDataSet executeLastDataQuery(List<String> paths, Long lastTime);
<T> List<T> executeLastDataQuery(List<String> paths, long lastTime, Class<? extends IotDbRecordAble> clazz);
<T> List<T> executeLastDataQuery(List<String> paths, Long lastTime, Class<? extends IotDbRecordAble> clazz);
SessionDataSet executeLastDataQueryForOneDevice(String db, String device, List<String> sensors, boolean isLegalPathNodes);
@ -53,11 +53,11 @@ public interface IotDBService {
SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations);
SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, long startTime, long endTime);
SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, Long startTime, Long endTime);
SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, long startTime, long endTime, long interval);
SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, Long startTime, Long endTime, Long interval);
SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, long startTime, long endTime, long interval, long slidingStep);
SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, Long startTime, Long endTime, Long interval, Long slidingStep);
SessionDataSet executeQueryStatement(String sql);

View File

@ -77,7 +77,7 @@ public class IotDBServiceImpl implements IotDBService {
* @param values
*/
@Override
public void insertStringRecord(String deviceId, long time, List<String> measurements, List<String> values) {
public void insertStringRecord(String deviceId, Long time, List<String> measurements, List<String> values) {
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
try {
log.info("iotdb数据入库device_id:[{}], measurements:[{}], values:[{}]", deviceId, measurements, values);
@ -98,7 +98,7 @@ public class IotDBServiceImpl implements IotDBService {
* @param values
*/
@Override
public void insertRecord(String deviceId, long time, List<String> measurements, List<TSDataType> types, List<Object> values) {
public void insertRecord(String deviceId, Long time, List<String> measurements, List<TSDataType> types, List<Object> values) {
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
try {
log.info("iotdb数据入库device_id:[{}], measurements:[{}], types:[{}], values:[{}]", deviceId, measurements, types, values);
@ -198,7 +198,7 @@ public class IotDBServiceImpl implements IotDBService {
* @param endTime
*/
@Override
public void deleteData(String path, long endTime) {
public void deleteData(String path, Long endTime) {
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
try {
log.info("iotdb数据删除path:[{}], endTime:[{}]", path, endTime);
@ -215,7 +215,7 @@ public class IotDBServiceImpl implements IotDBService {
* @param endTime
*/
@Override
public void deleteData(List<String> paths, long endTime) {
public void deleteData(List<String> paths, Long endTime) {
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
try {
log.info("iotdb数据删除paths:[{}], endTime:[{}]", paths, endTime);
@ -235,7 +235,7 @@ public class IotDBServiceImpl implements IotDBService {
* @return SessionDataSet (Time,paths)
*/
@Override
public SessionDataSet executeRawDataQuery(List<String> paths, long startTime, long endTime, long outTime) {
public SessionDataSet executeRawDataQuery(List<String> paths, Long startTime, Long endTime, Long outTime) {
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
SessionDataSetWrapper sessionDataSetWrapper = null;
try {
@ -262,7 +262,7 @@ public class IotDBServiceImpl implements IotDBService {
* @return
*/
@Override
public <T> List<T> executeRawDataQuery(List<String> paths, long startTime, long endTime, long outTime, Class<? extends IotDbRecordAble> clazz) {
public <T> List<T> executeRawDataQuery(List<String> paths, Long startTime, Long endTime, Long outTime, Class<? extends IotDbRecordAble> clazz) {
SessionDataSet sessionDataSet = executeRawDataQuery(paths, startTime, endTime, outTime);
List<String> columnNames = sessionDataSet.getColumnNames();
List<T> resultEntities = null;
@ -282,7 +282,7 @@ public class IotDBServiceImpl implements IotDBService {
* @return SessionDataSet
*/
@Override
public SessionDataSet executeLastDataQuery(List<String> paths, long lastTime) {
public SessionDataSet executeLastDataQuery(List<String> paths, Long lastTime) {
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
SessionDataSetWrapper sessionDataSetWrapper = null;
try {
@ -307,7 +307,7 @@ public class IotDBServiceImpl implements IotDBService {
* @return
*/
@Override
public <T> List<T> executeLastDataQuery(List<String> paths, long lastTime, Class<? extends IotDbRecordAble> clazz) {
public <T> List<T> executeLastDataQuery(List<String> paths, Long lastTime, Class<? extends IotDbRecordAble> clazz) {
SessionDataSet sessionDataSet = executeLastDataQuery(paths, lastTime);
List<String> columnNames = sessionDataSet.getColumnNames();
List<T> resultEntities = null;
@ -399,7 +399,7 @@ public class IotDBServiceImpl implements IotDBService {
* @return SessionDataSet
*/
@Override
public SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, long startTime, long endTime) {
public SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, Long startTime, Long endTime) {
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
SessionDataSetWrapper sessionDataSetWrapper = null;
try {
@ -425,7 +425,7 @@ public class IotDBServiceImpl implements IotDBService {
* @return SessionDataSet
*/
@Override
public SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, long startTime, long endTime, long interval) {
public SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, Long startTime, Long endTime, Long interval) {
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
SessionDataSetWrapper sessionDataSetWrapper = null;
try {
@ -452,7 +452,7 @@ public class IotDBServiceImpl implements IotDBService {
* @return SessionDataSet
*/
@Override
public SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, long startTime, long endTime, long interval, long slidingStep) {
public SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, Long startTime, Long endTime, Long interval, Long slidingStep) {
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
SessionDataSetWrapper sessionDataSetWrapper = null;
@ -648,7 +648,7 @@ public class IotDBServiceImpl implements IotDBService {
return TSDataType.DOUBLE;
} else if ("int".equals(typeName) || "integer".equals(typeName)) {
return TSDataType.INT32;
} else if ("long".equals(typeName)) {
} else if ("Long".equals(typeName)) {
return TSDataType.INT64;
} else if ("float".equals(typeName)) {
return TSDataType.FLOAT;

View File

@ -7,9 +7,17 @@ package com.muyu.common.rabbit.constants;
* @Description: rabbit
* @Version 1.0.0
*/
public class RabbitConstants {
public final static String GO_ONLINE_QUEUE= "GoOnline";
public final static String DOWNLINE_QUEUE= "Downline";
public interface RabbitConstants {
/**
* 线
*/
String GO_ONLINE_QUEUE= "GoOnline";
/**
* 线
*/
String DOWN_LINE_QUEUE= "DownLine";
/**
*
*/
String ONLINE_EXCHANGE = "online_exchange";
}

View File

@ -53,7 +53,7 @@ public class RedisService {
*
* @return true=false=
*/
public boolean expire (final String key, final long timeout) {
public boolean expire (final String key, final Long timeout) {
return expire(key, timeout, TimeUnit.SECONDS);
}
@ -66,7 +66,7 @@ public class RedisService {
*
* @return true=false=
*/
public boolean expire (final String key, final long timeout, final TimeUnit unit) {
public boolean expire (final String key, final Long timeout, final TimeUnit unit) {
return redisTemplate.expire(key, timeout, unit);
}
@ -77,7 +77,7 @@ public class RedisService {
*
* @return
*/
public long getExpire (final String key) {
public Long getExpire (final String key) {
return redisTemplate.getExpire(key);
}
@ -132,7 +132,7 @@ public class RedisService {
*
* @return
*/
public <T> long setCacheList (final String key, final List<T> dataList) {
public <T> Long setCacheList (final String key, final List<T> dataList) {
Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
return count == null ? 0 : count;
}

View File

@ -17,6 +17,10 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<description>
cloud-common-saas saas公共模块
</description>
<dependencies>
<!-- 多数据源依赖 -->
<dependency>

View File

@ -3,18 +3,15 @@ package com.muyu.cloud.common.many.datasource;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
import com.muyu.cloud.common.many.datasource.constents.DatasourceContent;
import com.muyu.cloud.common.saas.domain.model.EntInfo;
import com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory;
import com.muyu.cloud.common.many.datasource.domain.model.DataSourceInfo;
import com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory;
import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
import com.muyu.cloud.common.saas.domain.model.EntInfo;
import com.muyu.cloud.common.saas.exception.SaaSException;
import com.muyu.common.core.constant.SecurityConstants;
import com.muyu.common.core.constant.UserConstants;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.SpringUtils;
import com.muyu.common.system.domain.SysDept;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.domain.SysFirmDatasource;
import com.muyu.common.system.remote.RemoteUserService;
import lombok.extern.log4j.Log4j2;
import org.springframework.boot.ApplicationArguments;
@ -23,10 +20,7 @@ import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @Author: DongZeLiang
@ -42,49 +36,47 @@ public class ManyDataSource implements ApplicationRunner {
private List<EntInfo> dataSourceInfoList(){
RemoteUserService RemoteUserService = SpringUtils.getBean(RemoteUserService.class);
Result<List<String>> listResult = RemoteUserService.selectFirmDatabaseList(SecurityConstants.INNER);
Result<List<SysFirmDatasource>> listResult = RemoteUserService.selectFirmDatabaseList(SecurityConstants.INNER);
if (listResult==null){
throw new SaaSException("saas远调数据源错误");
}
List<String> data = listResult.getData();
List<SysFirmDatasource> data = listResult.getData();
if (listResult.getCode() ==Result.SUCCESS && data !=null){
List<EntInfo> list = new ArrayList<>();
for (String row : data) {
for (SysFirmDatasource row : data) {
list.add(
EntInfo.builder()
.entCode(row)
.ip(DatasourceContent.IP)
.port(DatasourceContent.PORT)
.entCode(row.getDatabaseName())
.ip(row.getIp())
.port(row.getPort())
.userName(row.getUsername())
.password(row.getPassword())
.build()
);
}
return list;
}else {
log.error("远调数据源错误,远调数据为:{}", JSON.toJSONString(data));
throw new RuntimeException("远调数据源错误,远调--》 companyList ");
throw new RuntimeException("远调数据源错误,远调--》 firmList ");
}
}
// private List<EntInfo> dataPrimarySourceInfoList(){
// List<EntInfo> list = new ArrayList<>();
// list.add(
// EntInfo.builder()
// .entCode()
// .ip(DatasourceContent.IP)
// .port(DatasourceContent.PORT)
// .build()
// );
// return list;
// }
@Bean
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
public DynamicDataSource dynamicDataSource() {
// 企业列表 企业CODE端口IP
Map<Object, Object> dataSourceMap = new HashMap<>();
dataSourceInfoList()
.stream()
.map(entInfo -> DataSourceInfo.hostAndPortBuild(entInfo.getEntCode(), entInfo.getIp(), entInfo.getPort()))
.forEach(dataSourceInfo -> {
dataSourceMap.put(dataSourceInfo.getKey(), druidDataSourceFactory.create(dataSourceInfo));
.map(entInfo -> DataSourceInfo.hostAndPortBuild(
entInfo.getEntCode(),
entInfo.getIp(),
entInfo.getPort(),
entInfo.getUserName(),
entInfo.getPassword()))
.map(DruidDataSourceFactory::create)
.filter(Objects::nonNull)
.forEach(druidDataSource -> {
dataSourceMap.put(druidDataSource.getName(), druidDataSource);
});
//设置动态数据源
DynamicDataSource dynamicDataSource = new DynamicDataSource();
@ -97,15 +89,19 @@ public class ManyDataSource implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class);
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
for (EntInfo entInfo : dataSourceInfoList()) {
DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(
entInfo.getEntCode(), entInfo.getIp(), entInfo.getPort()
);
DruidDataSource druidDataSource = druidDataSourceFactory.create(dataSourceInfo);
dynamicDataSource.put(dataSourceInfo.getKey(), druidDataSource);
log.info("存储数据连接池为key:{}",dataSourceInfo.getKey());
}
dataSourceInfoList()
.stream()
.map(entInfo -> DataSourceInfo.hostAndPortBuild(
entInfo.getEntCode(),
entInfo.getIp(),
entInfo.getPort(),
entInfo.getUserName(),
entInfo.getPassword()))
.map(DruidDataSourceFactory::create)
.filter(Objects::nonNull)
.forEach(druidDataSource -> {
dynamicDataSource.put(druidDataSource.getName(), druidDataSource);
});
}
}

View File

@ -9,11 +9,4 @@ public class DatasourceContent {
public final static String DATASOURCE_URL = "jdbc:mysql://{}:{}/{}?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
public final static String USER_NAME = "root";
public final static String PASSWORD = "wx0713101x";
public final static String IP = "127.0.0.1";
public final static Integer PORT = 3307;
}

View File

@ -39,12 +39,12 @@ public class DataSourceInfo {
private String password;
public static DataSourceInfo hostAndPortBuild(String key, String host, Integer port) {
public static DataSourceInfo hostAndPortBuild(String key, String host, Integer port,String userName,String password) {
return DataSourceInfo.builder()
.key(key)
.url(StringUtils.format(DatasourceContent.DATASOURCE_URL, host, port, key))
.password(DatasourceContent.PASSWORD)
.userName(DatasourceContent.USER_NAME)
.password(password)
.userName(userName)
.build();
}
}

View File

@ -20,8 +20,9 @@ public class DruidDataSourceFactory {
/**
* @Description:
*/
public DruidDataSource create(DataSourceInfo dataSourceInfo) {
public static DruidDataSource create(DataSourceInfo dataSourceInfo) {
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setName(dataSourceInfo.getKey());
druidDataSource.setUrl(dataSourceInfo.getUrl());
druidDataSource.setUsername(dataSourceInfo.getUserName());
druidDataSource.setPassword(dataSourceInfo.getPassword());

View File

@ -22,4 +22,8 @@ public class EntInfo {
private String ip;
private Integer port;
private String userName;
private String password;
}

View File

@ -5,6 +5,7 @@ import com.muyu.cloud.common.saas.contents.SaaSConstant;
import com.muyu.cloud.common.many.datasource.holder.DynamicDataSourceHolder;
import com.muyu.cloud.common.saas.exception.SaaSException;
import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
import com.muyu.common.core.constant.SecurityConstants;
import com.muyu.common.core.utils.ServletUtils;
import com.muyu.common.core.utils.SpringUtils;
import jakarta.servlet.http.HttpServletRequest;
@ -33,11 +34,11 @@ public class SaaSInterceptor implements AsyncHandlerInterceptor {
if (!(handler instanceof HandlerMethod)) {
return true;
}
String SaaSKey = ServletUtils.getHeader(request, SaaSConstant.SAAS_KEY);
String SaaSKey = ServletUtils.getHeader(request, SecurityConstants.FIRM_KEY);
if (SaaSKey == null) {
throw new SaaSException("SaaS非法访问");
}
if (SaaSKey.equals("-")){
if (SaaSKey.equals("1")){
log.info("使用 [ nacos ] 配置数据库 ");
flag = true;
return true;

View File

@ -27,11 +27,11 @@ import java.util.concurrent.TimeUnit;
*/
@Component
public class TokenService {
protected static final long MILLIS_SECOND = 1000;
protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND;
protected static final Long MILLIS_SECOND = 1000L;
protected static final Long MILLIS_MINUTE = 60 * MILLIS_SECOND;
private final static Long MILLIS_MINUTE_TEN = CacheConstants.REFRESH_TIME * MILLIS_MINUTE;
private static final Logger log = LoggerFactory.getLogger(TokenService.class);
private final static long expireTime = CacheConstants.EXPIRATION;
private final static Long expireTime = CacheConstants.EXPIRATION;
private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY;
@Autowired
@ -43,6 +43,7 @@ public class TokenService {
public Map<String, Object> createToken (LoginUser loginUser) {
String token = IdUtils.fastUUID();
Long userId = loginUser.getSysUser().getUserId();
Long firmId = loginUser.getSysUser().getFirmId();
String userName = loginUser.getSysUser().getUserName();
loginUser.setToken(token);
loginUser.setUserid(userId);
@ -55,7 +56,8 @@ public class TokenService {
claimsMap.put(SecurityConstants.USER_KEY, token);
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
claimsMap.put(SecurityConstants.FIRM_KEY, loginUser.getSysUser().getDatabaseName());
claimsMap.put(SecurityConstants.FIRM_ID, loginUser.getSysUser().getFirmId());
// 接口返回信息
Map<String, Object> rspMap = new HashMap<String, Object>();
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
@ -127,8 +129,8 @@ public class TokenService {
* @param loginUser
*/
public void verifyToken (LoginUser loginUser) {
long expireTime = loginUser.getExpireTime();
long currentTime = System.currentTimeMillis();
Long expireTime = loginUser.getExpireTime();
Long currentTime = System.currentTimeMillis();
if (expireTime - currentTime <= MILLIS_MINUTE_TEN) {
refreshToken(loginUser);
}

View File

@ -16,7 +16,7 @@ import java.util.Set;
@NoArgsConstructor
@AllArgsConstructor
public class LoginUser implements Serializable {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/**
*

View File

@ -22,7 +22,7 @@ import java.util.List;
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class SysDept extends BaseEntity {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/**
* ID
@ -79,6 +79,11 @@ public class SysDept extends BaseEntity {
*/
private String parentName;
/**
* Id
*/
private Long firmId;
/**
*
*/

View File

@ -21,7 +21,7 @@ import jakarta.validation.constraints.Size;
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class SysDictData extends BaseEntity {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/**
*

View File

@ -21,7 +21,7 @@ import jakarta.validation.constraints.Size;
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class SysDictType extends BaseEntity {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/**
*

View File

@ -0,0 +1,60 @@
package com.muyu.common.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
*
*
* @Author WangXin
* @Data 2024/10/9
* @Version 1.0.0
*/
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@Tag(name = "公司信息")
@TableName("sys_firm")
public class SysFirm {
/**
* Id
*/
@TableId(type = IdType.AUTO)
@Schema(name = "公司Id")
private Long id;
/**
*
*/
@Schema(name = "公司名称")
private String name;
/**
*
*/
@Schema(name = "公司数据源")
private Long did;
/**
* logo
*/
@Schema(name = "公司logo")
private String logo;
/**
*
*/
@Schema(name = "唯一标识")
private String sole;
/**
*
*/
@Schema(name = "车辆状态")
private String status;
}

View File

@ -23,7 +23,7 @@ import java.util.Date;
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class SysLogininfor extends BaseEntity {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/**
* ID

View File

@ -23,7 +23,7 @@ import java.util.Date;
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class SysOperLog extends BaseEntity {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/**
*

View File

@ -22,7 +22,7 @@ import java.util.Set;
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class SysRole extends BaseEntity {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/**
* ID

View File

@ -29,7 +29,7 @@ import java.util.List;
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class SysUser extends BaseEntity {
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/**
* ID
@ -134,6 +134,15 @@ public class SysUser extends BaseEntity {
* ID
*/
private Long roleId;
/**
* Id
*/
private Long firmId;
/**
*
*/
private String databaseName;
public SysUser (Long userId) {
this.userId = userId;

View File

@ -0,0 +1,36 @@
package com.muyu.common.system.domain.resp;
import com.muyu.common.system.domain.SysFirm;
import com.muyu.common.system.domain.SysFirmDatasource;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
*
*
* @Author WangXin
* @Data 2024/10/9
* @Version 1.0.0
*/
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@Tag(name = "公司信息响应对象")
public class SysFirmResp {
/**
*
*/
@Schema(name = "公司信息")
private SysFirm firm;
/**
*
*/
@Schema(name = "公司数据源信息")
private SysFirmDatasource firmDatasource;
}

View File

@ -3,6 +3,7 @@ package com.muyu.common.system.remote;
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.system.domain.SysFirmDatasource;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
import com.muyu.common.system.domain.LoginUser;
@ -22,12 +23,12 @@ public interface RemoteUserService {
*
*
* @param username
* @param firmId
* @param source
*
* @return
*/
@GetMapping("/user/info/{username}")
public Result<LoginUser> getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@GetMapping("/user/info/{username}/{firmId}")
public Result<LoginUser> getUserInfo (@PathVariable("username") String username,@PathVariable("firmId") Long firmId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
*
@ -40,6 +41,12 @@ public interface RemoteUserService {
@PostMapping("/user/register")
public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@GetMapping("/")
Result<List<String>> selectFirmDatabaseList(@RequestHeader(SecurityConstants.FROM_SOURCE) String inner);
/**
*
* @param inner
* @return
*/
@GetMapping("/firmDatasource/firmDatasourceList")
Result<List<SysFirmDatasource>> selectFirmDatabaseList(@RequestHeader(SecurityConstants.FROM_SOURCE) String inner);
}

View File

@ -1,6 +1,7 @@
package com.muyu.common.system.remote.factory;
import com.muyu.common.core.domain.Result;
import com.muyu.common.system.domain.SysFirmDatasource;
import com.muyu.common.system.remote.RemoteUserService;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.domain.LoginUser;
@ -25,7 +26,7 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
log.error("用户服务调用失败:{}", throwable.getMessage());
return new RemoteUserService() {
@Override
public Result<LoginUser> getUserInfo (String username, String source) {
public Result<LoginUser> getUserInfo (String username, Long firmId, String source) {
return Result.error("获取用户失败:" + throwable.getMessage());
}
@ -35,7 +36,7 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
}
@Override
public Result<List<String>> selectFirmDatabaseList(String inner) {
public Result<List<SysFirmDatasource>> selectFirmDatabaseList(String inner) {
return Result.error("注册用户失败:" + throwable.getMessage());
}
};

View File

@ -192,7 +192,7 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
@Override
public HttpHeaders getHeaders() {
long contentLength = headers.getContentLength();
Long contentLength = headers.getContentLength();
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.putAll(super.getHeaders());
if (contentLength > 0) {

View File

@ -10,6 +10,7 @@ import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.redis.service.RedisService;
import com.muyu.gateway.config.properties.IgnoreWhiteProperties;
import io.jsonwebtoken.Claims;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -37,7 +38,6 @@ public class AuthFilter implements GlobalFilter, Ordered {
@Autowired
private RedisService redisService;
@Override
public Mono<Void> filter (ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest();
@ -63,6 +63,8 @@ public class AuthFilter implements GlobalFilter, Ordered {
}
String userid = JwtUtils.getUserId(claims);
String username = JwtUtils.getUserName(claims);
String firmKey = JwtUtils.getFirmKey(claims);
String firmId = JwtUtils.getFirmId(claims);
if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) {
return unauthorizedResponse(exchange, "令牌验证失败");
}
@ -71,6 +73,8 @@ public class AuthFilter implements GlobalFilter, Ordered {
addHeader(mutate, SecurityConstants.USER_KEY, userkey);
addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid);
addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username);
addHeader(mutate, SecurityConstants.FIRM_KEY, firmKey);
addHeader(mutate, SecurityConstants.FIRM_ID, firmId);
// 内部请求来源参数清除
removeHeader(mutate, SecurityConstants.FROM_SOURCE);
return chain.filter(exchange.mutate().request(mutate.build()).build());

View File

@ -1,6 +1,6 @@
# Tomcat
server:
port: 8080
port: 18080
# nacos线上地址
nacos:

View File

@ -27,6 +27,7 @@ public class IotdbStrategy
private static ConcurrentHashMap<EventEnum,EventStrategyRouter<Information,Information>> map = new ConcurrentHashMap<>();
private static ExecutorService executor = Executors.newFixedThreadPool(3);
@Override
public Information apply(Information param) {
return applyStrategy(param);
@ -39,23 +40,12 @@ public class IotdbStrategy
if (isEventMapSize()){
log.info("[没有事件执行]");
}else {
ExecutorService executor = Executors.newFixedThreadPool(map.size());
for (EventEnum eventEnum : map.keySet()) {
executor.submit(() -> {
log.info("开始执行 [{}] ",eventEnum.getEventName());
return map.get(eventEnum);
});
}
// 关闭线程池
executor.shutdown();
try {
// 等待所有任务完成
if (!executor.awaitTermination(60, TimeUnit.SECONDS)) {
executor.shutdownNow();
}
} catch (InterruptedException e) {
executor.shutdownNow();
}
}
return new EndStrategy();
};

View File

@ -7,7 +7,9 @@ import lombok.NoArgsConstructor;
import java.util.List;
/**
*
* @version 1.0
* @Author xie ya ru
* @Date 2024/10/6 20:21

View File

@ -8,7 +8,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@EnableCustomConfig
@EnableMyFeignClients
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@SpringBootApplication
public class DataProcessApplication {
public static void main(String[] args) {
SpringApplication.run(DataProcessApplication.class, args);

View File

@ -70,14 +70,14 @@ public class TestController {
@GetMapping("/testRabbit/Downline")
public void testRabbitDownline(@RequestParam("msg") String msg) {
rabbitTemplate.convertAndSend(RabbitConstants.DOWNLINE_QUEUE, msg, message -> {
rabbitTemplate.convertAndSend(RabbitConstants.DOWN_LINE_QUEUE, msg, message -> {
message.getMessageProperties().setMessageId(UUID.randomUUID().toString().replace("-",""));
return message;
});
}
@GetMapping("/insertData")
public void insertData(@RequestParam("deviceId") String deviceId, @RequestParam("time") long time, @RequestParam("value") double value) throws Exception {
public void insertData(@RequestParam("deviceId") String deviceId, @RequestParam("time") Long time, @RequestParam("value") double value) throws Exception {
String sql = String.format("insert into root.one.%s(timestamp, temperature) values (%d, %f)", deviceId, time, value);
iotDBConfig.getSessionPool().executeNonQueryStatement(sql);
}

View File

@ -31,12 +31,12 @@ public class DownlineRabbitConsumer {
@Resource
private CacheManager cacheManager;
@RabbitListener(queuesToDeclare = {@Queue(RabbitConstants.DOWNLINE_QUEUE)})
@RabbitListener(queuesToDeclare = {@Queue(RabbitConstants.DOWN_LINE_QUEUE)})
public void downline(String vin, Message message, Channel channel) {
log.info("车辆 {} 下线, 配置信息准备中。。。",vin);
try {
// 重复性校验
Long add = redisTemplate.opsForSet().add(RabbitConstants.DOWNLINE_QUEUE, message.getMessageProperties().getMessageId());
Long add = redisTemplate.opsForSet().add(RabbitConstants.DOWN_LINE_QUEUE, message.getMessageProperties().getMessageId());
if (add>0) {
deleteCarCache(vin);
log.info("车辆 {} 下线, 消息已确认。。。",vin);

View File

@ -10,6 +10,10 @@ import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import java.util.ArrayList;
import java.util.List;
/**
*IoTDB
*/
public class Iotdb {
public static void main(String[] args) throws IoTDBConnectionException, StatementExecutionException {

View File

@ -2,6 +2,9 @@ package com.muyu.data.util;
import org.eclipse.paho.client.mqttv3.*;
/**
* MQTT
*/
public class Receive {
public static void main(String[] args) {

View File

@ -1,15 +1,14 @@
package com.muyu.data.warn;
import com.muyu.domain.SysCar;
import com.muyu.enterpise.cache.SysCarCacheService;
import com.muyu.enterpise.cache.SysCarTypeCacheService;
import com.muyu.enterprise.cache.SysCarCacheService;
import com.muyu.enterprise.cache.SysCarTypeCacheService;
import org.springframework.stereotype.Component;
import org.apache.catalina.mapper.*;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
/**
*
* @version 1.0
* @Author xie ya ru
* @Date 2024/10/6 15:21

View File

@ -1,6 +1,6 @@
# Tomcat
server:
port: 9701
port: 29701
# nacos线上地址
nacos:

View File

@ -30,8 +30,6 @@
<artifactId>cloud-common-cache</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,33 @@
package com.muyu.enterprise.cache;
import com.muyu.common.cache.CacheAbsBasic;
import com.muyu.enterprise.cache.domain.InformationData;
import org.springframework.stereotype.Component;
import java.util.List;
/**
*
* @className: InformationDataService
* @author: Yang 🦅
* @date: 2024/10/7 21:50
* @Version: 1.0
* @description:
*/
@Component
public class InformationDataService extends CacheAbsBasic<String, List<InformationData>> {
@Override
public String keyPre() {
return "";
}
@Override
public String encode(String key) {
return super.encode(key);
}
@Override
public String decode(String key) {
return super.decode(key);
}
}

View File

@ -1,4 +1,4 @@
package com.muyu.enterpise.cache;
package com.muyu.enterprise.cache;
import com.muyu.common.cache.CacheAbsBasic;
import com.muyu.domain.MessageValue;
@ -7,6 +7,7 @@ import org.springframework.stereotype.Component;
import java.util.List;
/**
*
* @version 1.0
* @Author xie ya ru
* @Date 2024/9/29 20:04
@ -21,7 +22,7 @@ public class MessageValueCacheService extends CacheAbsBasic<String, List<Message
*/
@Override
public String keyPre() {
return"messageValue:info:";
return "messageValue:info:";
}

View File

@ -1,4 +1,4 @@
package com.muyu.enterpise.cache;
package com.muyu.enterprise.cache;
import com.muyu.common.cache.CacheAbsBasic;
import com.muyu.domain.SysCar;
@ -7,6 +7,7 @@ import org.springframework.stereotype.Component;
import java.util.List;
/**
*
* @version 1.0
* @Author xie ya ru
* @Date 2024/9/30 11:06
@ -17,7 +18,7 @@ public class SysCarCacheService extends CacheAbsBasic<String, SysCar> {
@Override
public String keyPre() {
return "sysCar:info:";
return ":sysCar";
}
@Override

View File

@ -1,10 +1,11 @@
package com.muyu.enterpise.cache;
package com.muyu.enterprise.cache;
import com.muyu.common.cache.CacheAbsBasic;
import com.muyu.domain.SysCarType;
import org.springframework.stereotype.Component;
/**
*
* @version 1.0
* @Author xie ya ru
* @Date 2024/9/30 11:18

View File

@ -1,10 +1,11 @@
package com.muyu.enterpise.cache;
package com.muyu.enterprise.cache;
import com.muyu.common.cache.CacheAbsBasic;
import com.muyu.domain.WarnStrategy;
import org.springframework.stereotype.Component;
/**
*
* @Authoryan
* @Packagecom.muyu.enterpise.cache
* @Projectplus
@ -17,7 +18,7 @@ public class WarnStrategyCacjeService extends CacheAbsBasic<String, WarnStrateg
@Override
public String keyPre() {
return "sysCarType:info:";
return ":sysCarType";
}
@Override

View File

@ -1,4 +1,4 @@
package com.muyu.common.domain;
package com.muyu.enterprise.cache.domain;
import com.muyu.common.system.domain.SysDept;
import com.muyu.domain.SysCar;

View File

@ -1,5 +1,5 @@
com.muyu.enterpise.cache.MessageValueCacheService
com.muyu.enterpise.cache.SysCarCacheService
com.muyu.enterpise.cache.SysCarTypeCacheService
com.muyu.enterpise.cache.WarnStrategyCacjeService
com.muyu.enterprise.cache.MessageValueCacheService
com.muyu.enterprise.cache.SysCarCacheService
com.muyu.enterprise.cache.SysCarTypeCacheService
com.muyu.enterprise.cache.WarnStrategyCacjeService

View File

@ -41,9 +41,10 @@
<artifactId>swagger-annotations-jakarta</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-system</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -37,12 +37,12 @@ public class CarFaultRule {
*
*/
@Schema(name = "车辆类型Id")
private long timestamp;
private Long timestamp;
/**
*
*/
@Schema(name = "车速")
private double longitude;
private double Longitude;
/**
*
*/
@ -57,7 +57,7 @@ public class CarFaultRule {
*
*/
@Schema(name = "加速踏板行程值")
private long TM;
private Long TM;
/**
*
*/

View File

@ -30,7 +30,7 @@ public class CarType {
*/
@TableId(value = "car_type_id",type = IdType.AUTO)
@Schema(name = "车辆类型ID")
private long carTypeId;
private Long carTypeId;
/**
*
*/
@ -40,5 +40,5 @@ public class CarType {
* ID
*/
@Schema(name = "车辆规则外键ID")
private long carTypeRules;
private Long carTypeRules;
}

View File

@ -35,12 +35,12 @@ public class FaultCode {
*/
@TableId(value = "faultcode_id", type = IdType.AUTO)
@Schema(name = "故障码Id")
private long faultcodeId;
private Long faultcodeId;
/**
* Id
*/
@Schema(name = "故障名称Id")
private long messageTypeId;
private Long messageTypeId;
/**
*
*/
@ -86,11 +86,11 @@ public class FaultCode {
*
*/
@Schema(name = "故障类型所属")
private String messageTypeBelongs;
private String messageTypeBeLongs;
public static FaultCode addfaultcode(FaultCodeAddReq faultCodeAddReq) {
return FaultCode.builder()
.faultcodeId(0)
.faultcodeId(0L)
.messageTypeId(faultCodeAddReq.getMessageTypeId())
.faultcodeNumber(faultCodeAddReq.getFaultcodeNumber())
.faultGroup(faultCodeAddReq.getFaultGroup())

View File

@ -35,17 +35,17 @@ public class FaultCondition {
*/
@TableId(value = "carcondition_id",type = IdType.AUTO)
@Schema(name = "故障规则表Id")
private long carconditionId;
private Long carconditionId;
/**
* Id
*/
@Schema(name = "车辆类型Id")
private long carTypeId;
private Long carTypeId;
/**
*Id
*/
@Schema(name = "故障名称Id")
private long messageTypeId;
private Long messageTypeId;
/**
*
*/

View File

@ -46,6 +46,6 @@ public class FaultLabel {
*
*/
@Schema(name = "报文所属类别")
private String messageTypeBelongs;
private String messageTypeBeLongs;
}

View File

@ -34,17 +34,17 @@ public class FaultLog {
*/
@TableId(value = "log_id",type = IdType.AUTO)
@Schema(name = "故障日志Id")
private long logId;
private Long logId;
/**
* Id
*/
@Schema(name = "故障码Id")
private long faultcodeId;
private Long faultcodeId;
/**
* Id
*/
@Schema(name = "车辆Id")
private long carInformationId;
private Long carInformationId;
/**
* VIN
*/

View File

@ -32,13 +32,13 @@ public class FaultRule {
*/
@TableId(value = "condition_id",type = IdType.AUTO)
@Schema(name = "触发条件Id")
private long conditionId;
private Long conditionId;
/**
* Id
*/
@Schema(name = "故障码Id")
private long faultcodeId;
private Long faultcodeId;
/**
*

View File

@ -30,7 +30,7 @@ public class FaultType {
*/
@TableId(value = "faulttype_id",type = IdType.AUTO)
@Schema(name = "故障类型Id")
private long faulttypeId;
private Long faulttypeId;
/**
*
*/

View File

@ -27,7 +27,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
@TableName(value = "sys_car_fault", autoResultMap = true)
@Tag(name = "车辆故障对象")
public class SysCarFault extends BaseEntity{
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/** 自增主键 */
@TableId( type = IdType.AUTO,value = "id")

View File

@ -32,7 +32,7 @@ import java.util.Date;
@TableName("warn_logs")
@Tag(name = "预警日志管理")
public class WarnLogs extends BaseEntity{
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/** 预警日志id */
@TableId( type = IdType.AUTO)

View File

@ -28,7 +28,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
@TableName("warn_rule")
@Tag(name = "预警规则管理")
public class WarnRule extends BaseEntity{
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/** 规则id */
@TableId( type = IdType.AUTO)

View File

@ -29,7 +29,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
@TableName("warn_strategy")
@Tag(name = "预警策略管理")
public class WarnStrategy extends BaseEntity{
private static final long serialVersionUID = 1L;
private static final Long serialVersionUID = 1L;
/** 策略id */
@TableId( type = IdType.AUTO)

Some files were not shown because too many files have changed in this diff Show More