Compare commits

...

17 Commits

193 changed files with 5174 additions and 572 deletions

View File

@ -77,7 +77,7 @@ public class SysLoginService {
} }
LoginUser userInfo = userResult.getData(); LoginUser userInfo = userResult.getData();
SysUser user = userResult.getData().getSysUser(); SysUser user = userInfo.getSysUser();
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除"); recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); throw new ServiceException("对不起,您的账号:" + username + " 已被删除");

View File

@ -21,9 +21,9 @@ public class SysPasswordService {
@Autowired @Autowired
private RedisService redisService; private RedisService redisService;
private int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT; private final int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT;
private Long lockTime = CacheConstants.PASSWORD_LOCK_TIME; private final Long lockTime = CacheConstants.PASSWORD_LOCK_TIME;
@Autowired @Autowired
private SysRecordLogService recordLogService; private SysRecordLogService recordLogService;

View File

@ -21,134 +21,134 @@ public @interface Excel {
/** /**
* excel * excel
*/ */
public int sort () default Integer.MAX_VALUE; int sort() default Integer.MAX_VALUE;
/** /**
* Excel. * Excel.
*/ */
public String name () default ""; String name() default "";
/** /**
* , : yyyy-MM-dd * , : yyyy-MM-dd
*/ */
public String dateFormat () default ""; String dateFormat() default "";
/** /**
* (: 0=,1=,2=) * (: 0=,1=,2=)
*/ */
public String readConverterExp () default ""; String readConverterExp() default "";
/** /**
* *
*/ */
public String separator () default ","; String separator() default ",";
/** /**
* BigDecimal :-1(BigDecimal) * BigDecimal :-1(BigDecimal)
*/ */
public int scale () default -1; int scale() default -1;
/** /**
* BigDecimal :BigDecimal.ROUND_HALF_EVEN * BigDecimal :BigDecimal.ROUND_HALF_EVEN
*/ */
public int roundingMode () default BigDecimal.ROUND_HALF_EVEN; int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
/** /**
* excel * excel
*/ */
public double height () default 14; double height() default 14;
/** /**
* excel * excel
*/ */
public double width () default 16; double width() default 16;
/** /**
* ,% 90 90% * ,% 90 90%
*/ */
public String suffix () default ""; String suffix() default "";
/** /**
* , * ,
*/ */
public String defaultValue () default ""; String defaultValue() default "";
/** /**
* *
*/ */
public String prompt () default ""; String prompt() default "";
/** /**
* . * .
*/ */
public String[] combo () default {}; String[] combo() default {};
/** /**
* ,:list) * ,:list)
*/ */
public boolean needMerge () default false; boolean needMerge() default false;
/** /**
* ,:,. * ,:,.
*/ */
public boolean isExport () default true; boolean isExport() default true;
/** /**
* ,, * ,,
*/ */
public String targetAttr () default ""; String targetAttr() default "";
/** /**
* , * ,
*/ */
public boolean isStatistics () default false; boolean isStatistics() default false;
/** /**
* 0 1 * 0 1
*/ */
public ColumnType cellType () default ColumnType.STRING; ColumnType cellType() default ColumnType.STRING;
/** /**
* *
*/ */
public IndexedColors headerBackgroundColor () default IndexedColors.GREY_50_PERCENT; IndexedColors headerBackgroundColor() default IndexedColors.GREY_50_PERCENT;
/** /**
* *
*/ */
public IndexedColors headerColor () default IndexedColors.WHITE; IndexedColors headerColor() default IndexedColors.WHITE;
/** /**
* *
*/ */
public IndexedColors backgroundColor () default IndexedColors.WHITE; IndexedColors backgroundColor() default IndexedColors.WHITE;
/** /**
* *
*/ */
public IndexedColors color () default IndexedColors.BLACK; IndexedColors color() default IndexedColors.BLACK;
/** /**
* *
*/ */
public HorizontalAlignment align () default HorizontalAlignment.CENTER; HorizontalAlignment align() default HorizontalAlignment.CENTER;
/** /**
* *
*/ */
public Class<?> handler () default ExcelHandlerAdapter.class; Class<?> handler() default ExcelHandlerAdapter.class;
/** /**
* *
*/ */
public String[] args () default {}; String[] args() default {};
/** /**
* 012 * 012
*/ */
Type type () default Type.ALL; Type type () default Type.ALL;
public enum Type { enum Type {
ALL(0), EXPORT(1), IMPORT(2); ALL(0), EXPORT(1), IMPORT(2);
private final int value; private final int value;
@ -161,7 +161,7 @@ public @interface Excel {
} }
} }
public enum ColumnType { enum ColumnType {
NUMERIC(0), STRING(1), IMAGE(2); NUMERIC(0), STRING(1), IMAGE(2);
private final int value; private final int value;

View File

@ -43,9 +43,9 @@ public class ScheduleConstants {
*/ */
PAUSE("1"); PAUSE("1");
private String value; private final String value;
private Status (String value) { Status(String value) {
this.value = value; this.value = value;
} }

View File

@ -41,6 +41,10 @@ public class SecurityConstants {
*/ */
public static final String LOGIN_USER = "login_user"; public static final String LOGIN_USER = "login_user";
/**
*
*/
public static final String SYS_USER = "sys_user";
/** /**
* *
*/ */

View File

@ -20,4 +20,7 @@ public class ServiceNameConstants {
* serviceid * serviceid
*/ */
public static final String FILE_SERVICE = "muyu-file"; public static final String FILE_SERVICE = "muyu-file";
// public static final String SYSTEM_BUSINESS = "muyu-business";
public static final String DATASOURCE_SERVICE = "muyu-net-working";
} }

View File

@ -39,6 +39,10 @@ public class Result<T> implements Serializable {
private T data; private T data;
public static <T> Result<T> buildCode(int code, String msg, T data){
return restResult(data, code, msg);
}
public static <T> Result<T> success () { public static <T> Result<T> success () {
return restResult(null, SUCCESS, null); return restResult(null, SUCCESS, null);
} }
@ -50,7 +54,6 @@ public class Result<T> implements Serializable {
public static <T> Result<T> success (T data, String msg) { public static <T> Result<T> success (T data, String msg) {
return restResult(data, SUCCESS, msg); return restResult(data, SUCCESS, msg);
} }
public static <T> Result<T> error () { public static <T> Result<T> error () {
return restResult(null, FAIL, null); return restResult(null, FAIL, null);
} }

View File

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

View File

@ -11,22 +11,22 @@ public class BaseException extends RuntimeException {
/** /**
* *
*/ */
private String module; private final String module;
/** /**
* *
*/ */
private String code; private final String code;
/** /**
* *
*/ */
private Object[] args; private final Object[] args;
/** /**
* *
*/ */
private String defaultMessage; private final String defaultMessage;
public BaseException (String module, String code, Object[] args, String defaultMessage) { public BaseException (String module, String code, Object[] args, String defaultMessage) {
this.module = module; this.module = module;

View File

@ -10,9 +10,9 @@ import java.util.Arrays;
public class InvalidExtensionException extends FileUploadException { public class InvalidExtensionException extends FileUploadException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String[] allowedExtension; private final String[] allowedExtension;
private String extension; private final String extension;
private String filename; private final String filename;
public InvalidExtensionException (String[] allowedExtension, String extension, String filename) { public InvalidExtensionException (String[] allowedExtension, String extension, String filename) {
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]"); super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]");

View File

@ -8,7 +8,7 @@ package com.muyu.common.core.exception.job;
public class TaskException extends Exception { public class TaskException extends Exception {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Code code; private final Code code;
public TaskException (String msg, Code code) { public TaskException (String msg, Code code) {
this(msg, code, null); this(msg, code, null);

View File

@ -27,11 +27,11 @@ public class CharsetKit {
/** /**
* ISO-8859-1 * ISO-8859-1
*/ */
public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1); public static final Charset CHARSET_ISO_8859_1 = StandardCharsets.ISO_8859_1;
/** /**
* UTF-8 * UTF-8
*/ */
public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8); public static final Charset CHARSET_UTF_8 = StandardCharsets.UTF_8;
/** /**
* GBK * GBK
*/ */

View File

@ -24,7 +24,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
private static String[] parsePatterns = { private static final String[] parsePatterns = {
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"}; "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};

View File

@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Collections; import java.util.Collections;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
@ -212,11 +213,7 @@ public class ServletUtils {
* @return * @return
*/ */
public static String urlEncode (String str) { public static String urlEncode (String str) {
try { return URLEncoder.encode(str, StandardCharsets.UTF_8);
return URLEncoder.encode(str, Constants.UTF8);
} catch (UnsupportedEncodingException e) {
return StringUtils.EMPTY;
}
} }
/** /**
@ -227,11 +224,7 @@ public class ServletUtils {
* @return * @return
*/ */
public static String urlDecode (String str) { public static String urlDecode (String str) {
try { return URLDecoder.decode(str, StandardCharsets.UTF_8);
return URLDecoder.decode(str, Constants.UTF8);
} catch (UnsupportedEncodingException e) {
return StringUtils.EMPTY;
}
} }
/** /**

View File

@ -43,7 +43,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
* @throws org.springframework.beans.BeansException * @throws org.springframework.beans.BeansException
*/ */
public static <T> T getBean (Class<T> clz) throws BeansException { public static <T> T getBean (Class<T> clz) throws BeansException {
T result = (T) beanFactory.getBean(clz); T result = beanFactory.getBean(clz);
return result; return result;
} }

View File

@ -125,17 +125,17 @@ public class FileUtils {
String filename = fileName; String filename = fileName;
if (agent.contains("MSIE")) { if (agent.contains("MSIE")) {
// IE浏览器 // IE浏览器
filename = URLEncoder.encode(filename, "utf-8"); filename = URLEncoder.encode(filename, StandardCharsets.UTF_8);
filename = filename.replace("+", " "); filename = filename.replace("+", " ");
} else if (agent.contains("Firefox")) { } else if (agent.contains("Firefox")) {
// 火狐浏览器 // 火狐浏览器
filename = new String(fileName.getBytes(), "ISO8859-1"); filename = new String(fileName.getBytes(), "ISO8859-1");
} else if (agent.contains("Chrome")) { } else if (agent.contains("Chrome")) {
// google浏览器 // google浏览器
filename = URLEncoder.encode(filename, "utf-8"); filename = URLEncoder.encode(filename, StandardCharsets.UTF_8);
} else { } else {
// 其它浏览器 // 其它浏览器
filename = URLEncoder.encode(filename, "utf-8"); filename = URLEncoder.encode(filename, StandardCharsets.UTF_8);
} }
return filename; return filename;
} }
@ -197,15 +197,14 @@ public class FileUtils {
public static void setAttachmentResponseHeader (HttpServletResponse response, String realFileName) throws UnsupportedEncodingException { public static void setAttachmentResponseHeader (HttpServletResponse response, String realFileName) throws UnsupportedEncodingException {
String percentEncodedFileName = percentEncode(realFileName); String percentEncodedFileName = percentEncode(realFileName);
StringBuilder contentDispositionValue = new StringBuilder(); String contentDispositionValue = "attachment; filename=" +
contentDispositionValue.append("attachment; filename=") percentEncodedFileName +
.append(percentEncodedFileName) ";" +
.append(";") "filename*=" +
.append("filename*=") "utf-8''" +
.append("utf-8''") percentEncodedFileName;
.append(percentEncodedFileName);
response.setHeader("Content-disposition", contentDispositionValue.toString()); response.setHeader("Content-disposition", contentDispositionValue);
response.setHeader("download-filename", percentEncodedFileName); response.setHeader("download-filename", percentEncodedFileName);
} }
@ -217,7 +216,7 @@ public class FileUtils {
* @return * @return
*/ */
public static String percentEncode (String s) throws UnsupportedEncodingException { public static String percentEncode (String s) throws UnsupportedEncodingException {
String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString()); String encode = URLEncoder.encode(s, StandardCharsets.UTF_8);
return encode.replaceAll("\\+", "%20"); return encode.replaceAll("\\+", "%20");
} }
} }

View File

@ -124,7 +124,7 @@ public class EscapeUtil {
tmp.append(content.substring(lastPos)); tmp.append(content.substring(lastPos));
lastPos = content.length(); lastPos = content.length();
} else { } else {
tmp.append(content.substring(lastPos, pos)); tmp.append(content, lastPos, pos);
lastPos = pos; lastPos = pos;
} }
} }

View File

@ -225,7 +225,7 @@ public class IpUtils {
if (ip != null && ip.indexOf(",") > 0) { if (ip != null && ip.indexOf(",") > 0) {
final String[] ips = ip.trim().split(","); final String[] ips = ip.trim().split(",");
for (String subIp : ips) { for (String subIp : ips) {
if (false == isUnknown(subIp)) { if (!isUnknown(subIp)) {
ip = subIp; ip = subIp;
break; break;
} }

View File

@ -121,7 +121,7 @@ public class ExcelUtil<T> {
/** /**
* *
*/ */
private Map<Integer, Double> statistics = new HashMap<Integer, Double>(); private final Map<Integer, Double> statistics = new HashMap<Integer, Double>();
public ExcelUtil (Class<T> clazz) { public ExcelUtil (Class<T> clazz) {
this.clazz = clazz; this.clazz = clazz;
@ -531,7 +531,7 @@ public class ExcelUtil<T> {
rowNo = isSubList() ? (i > 1 ? rowNo + 1 : rowNo + i) : i + 1 + rownum - startNo; rowNo = isSubList() ? (i > 1 ? rowNo + 1 : rowNo + i) : i + 1 + rownum - startNo;
row = sheet.createRow(rowNo); row = sheet.createRow(rowNo);
// 得到导出对象. // 得到导出对象.
T vo = (T) list.get(i); T vo = list.get(i);
Collection<?> subList = null; Collection<?> subList = null;
if (isSubList()) { if (isSubList()) {
if (isSubListValue(vo)) { if (isSubListValue(vo)) {
@ -913,7 +913,7 @@ public class ExcelUtil<T> {
public String dataFormatHandlerAdapter (Object value, Excel excel, Cell cell) { public String dataFormatHandlerAdapter (Object value, Excel excel, Cell cell) {
try { try {
Object instance = excel.handler().newInstance(); Object instance = excel.handler().newInstance();
Method formatMethod = excel.handler().getMethod("format", new Class[]{Object.class, String[].class, Cell.class, Workbook.class}); Method formatMethod = excel.handler().getMethod("format", Object.class, String[].class, Cell.class, Workbook.class);
value = formatMethod.invoke(instance, value, excel.args(), cell, this.wb); value = formatMethod.invoke(instance, value, excel.args(), cell, this.wb);
} catch (Exception e) { } catch (Exception e) {
log.error("不能格式化数据 " + excel.handler(), e.getMessage()); log.error("不能格式化数据 " + excel.handler(), e.getMessage());
@ -1200,7 +1200,7 @@ public class ExcelUtil<T> {
public Collection<?> getListCellValue (Object obj) { public Collection<?> getListCellValue (Object obj) {
Object value; Object value;
try { try {
value = subMethod.invoke(obj, new Object[]{}); value = subMethod.invoke(obj);
} catch (Exception e) { } catch (Exception e) {
return new ArrayList<Object>(); return new ArrayList<Object>();
} }
@ -1221,7 +1221,7 @@ public class ExcelUtil<T> {
getMethodName.append(name.substring(1)); getMethodName.append(name.substring(1));
Method method = null; Method method = null;
try { try {
method = pojoClass.getMethod(getMethodName.toString(), new Class[]{}); method = pojoClass.getMethod(getMethodName.toString());
} catch (Exception e) { } catch (Exception e) {
log.error("获取对象异常{}", e.getMessage()); log.error("获取对象异常{}", e.getMessage());
} }

View File

@ -24,7 +24,7 @@ public class ReflectUtils {
private static final String CGLIB_CLASS_SEPARATOR = "$$"; private static final String CGLIB_CLASS_SEPARATOR = "$$";
private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class); private static final Logger logger = LoggerFactory.getLogger(ReflectUtils.class);
/** /**
* Getter. * Getter.
@ -113,7 +113,7 @@ public class ReflectUtils {
try { try {
return (E) method.invoke(obj, args); return (E) method.invoke(obj, args);
} catch (Exception e) { } catch (Exception e) {
String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; String msg = "method: " + method + ", obj: " + obj + ", args: " + args;
throw convertReflectionExceptionToUnchecked(msg, e); throw convertReflectionExceptionToUnchecked(msg, e);
} }
} }
@ -162,7 +162,7 @@ public class ReflectUtils {
} }
return (E) method.invoke(obj, args); return (E) method.invoke(obj, args);
} catch (Exception e) { } catch (Exception e) {
String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; String msg = "method: " + method + ", obj: " + obj + ", args: " + args;
throw convertReflectionExceptionToUnchecked(msg, e); throw convertReflectionExceptionToUnchecked(msg, e);
} }
} }

View File

@ -46,8 +46,8 @@ public final class Base64 {
for (int i = 52, j = 0 ; i <= 61 ; i++, j++) { for (int i = 52, j = 0 ; i <= 61 ; i++, j++) {
lookUpBase64Alphabet[i] = (char) ('0' + j); lookUpBase64Alphabet[i] = (char) ('0' + j);
} }
lookUpBase64Alphabet[62] = (char) '+'; lookUpBase64Alphabet[62] = '+';
lookUpBase64Alphabet[63] = (char) '/'; lookUpBase64Alphabet[63] = '/';
} }
private static boolean isWhiteSpace (char octect) { private static boolean isWhiteSpace (char octect) {
@ -82,7 +82,7 @@ public final class Base64 {
int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP; int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP; int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets; int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets;
char encodedData[] = null; char[] encodedData = null;
encodedData = new char[numberQuartet * 4]; encodedData = new char[numberQuartet * 4];
@ -161,7 +161,7 @@ public final class Base64 {
return new byte[0]; return new byte[0];
} }
byte decodedData[] = null; byte[] decodedData = null;
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0; byte b1 = 0, b2 = 0, b3 = 0, b4 = 0;
char d1 = 0, d2 = 0, d3 = 0, d4 = 0; char d1 = 0, d2 = 0, d3 = 0, d4 = 0;

View File

@ -17,9 +17,9 @@ public class Seq {
// 机器标识 // 机器标识
private static final String machineCode = "A"; private static final String machineCode = "A";
// 通用接口序列数 // 通用接口序列数
private static AtomicInteger commSeq = new AtomicInteger(1); private static final AtomicInteger commSeq = new AtomicInteger(1);
// 上传接口序列数 // 上传接口序列数
private static AtomicInteger uploadSeq = new AtomicInteger(1); private static final AtomicInteger uploadSeq = new AtomicInteger(1);
/** /**
* *

View File

@ -353,22 +353,22 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36); final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36);
// time_low // time_low
builder.append(digits(mostSigBits >> 32, 8)); builder.append(digits(mostSigBits >> 32, 8));
if (false == isSimple) { if (!isSimple) {
builder.append('-'); builder.append('-');
} }
// time_mid // time_mid
builder.append(digits(mostSigBits >> 16, 4)); builder.append(digits(mostSigBits >> 16, 4));
if (false == isSimple) { if (!isSimple) {
builder.append('-'); builder.append('-');
} }
// time_high_and_version // time_high_and_version
builder.append(digits(mostSigBits, 4)); builder.append(digits(mostSigBits, 4));
if (false == isSimple) { if (!isSimple) {
builder.append('-'); builder.append('-');
} }
// variant_and_sequence // variant_and_sequence
builder.append(digits(leastSigBits >> 48, 4)); builder.append(digits(leastSigBits >> 48, 4));
if (false == isSimple) { if (!isSimple) {
builder.append('-'); builder.append('-');
} }
// node // node

View File

@ -14,15 +14,15 @@ public @interface DataScope {
/** /**
* *
*/ */
public String deptAlias () default ""; String deptAlias() default "";
/** /**
* *
*/ */
public String userAlias () default ""; String userAlias() default "";
/** /**
* @RequiresPermissions * @RequiresPermissions
*/ */
public String permission () default ""; String permission() default "";
} }

View File

@ -109,8 +109,7 @@ public class DataScopeAspect {
if (StringUtils.isNotBlank(sqlString.toString())) { if (StringUtils.isNotBlank(sqlString.toString())) {
Object params = joinPoint.getArgs()[0]; Object params = joinPoint.getArgs()[0];
if (StringUtils.isNotNull(params) && params instanceof BaseEntity) { if (StringUtils.isNotNull(params) && params instanceof BaseEntity baseEntity) {
BaseEntity baseEntity = (BaseEntity) params;
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")"); baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
} }
} }
@ -141,8 +140,7 @@ public class DataScopeAspect {
*/ */
private void clearDataScope (final JoinPoint joinPoint) { private void clearDataScope (final JoinPoint joinPoint) {
Object params = joinPoint.getArgs()[0]; Object params = joinPoint.getArgs()[0];
if (StringUtils.isNotNull(params) && params instanceof BaseEntity) { if (StringUtils.isNotNull(params) && params instanceof BaseEntity baseEntity) {
BaseEntity baseEntity = (BaseEntity) params;
baseEntity.getParams().put(DATA_SCOPE, ""); baseEntity.getParams().put(DATA_SCOPE, "");
} }
} }

View File

@ -17,30 +17,30 @@ public @interface Log {
/** /**
* *
*/ */
public String title () default ""; String title() default "";
/** /**
* *
*/ */
public BusinessType businessType () default BusinessType.OTHER; BusinessType businessType() default BusinessType.OTHER;
/** /**
* *
*/ */
public OperatorType operatorType () default OperatorType.MANAGE; OperatorType operatorType() default OperatorType.MANAGE;
/** /**
* *
*/ */
public boolean isSaveRequestData () default true; boolean isSaveRequestData() default true;
/** /**
* *
*/ */
public boolean isSaveResponseData () default true; boolean isSaveResponseData() default true;
/** /**
* *
*/ */
public String[] excludeParamNames () default {}; String[] excludeParamNames() default {};
} }

View File

@ -169,12 +169,12 @@ public class LogAspect {
*/ */
private String argsArrayToString (Object[] paramsArray, String[] excludeParamNames) { private String argsArrayToString (Object[] paramsArray, String[] excludeParamNames) {
String params = ""; String params = "";
if (paramsArray != null && paramsArray.length > 0) { if (paramsArray != null) {
for (Object o : paramsArray) { for (Object o : paramsArray) {
if (StringUtils.isNotNull(o) && !isFilterObject(o)) { if (StringUtils.isNotNull(o) && !isFilterObject(o)) {
try { try {
String jsonObj = JSON.toJSONString(o, excludePropertyPreFilter(excludeParamNames)); String jsonObj = JSON.toJSONString(o, excludePropertyPreFilter(excludeParamNames));
params += jsonObj.toString() + " "; params += jsonObj + " ";
} catch (Exception e) { } catch (Exception e) {
} }
} }

View File

@ -9,6 +9,7 @@ import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.SerializationException; import org.springframework.data.redis.serializer.SerializationException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
/** /**
* Redis使FastJson * Redis使FastJson
@ -16,11 +17,11 @@ import java.nio.charset.Charset;
* @author muyu * @author muyu
*/ */
public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T> { public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T> {
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
static final Filter AUTO_TYPE_FILTER = JSONReader.autoTypeFilter(Constants.JSON_WHITELIST_STR); static final Filter AUTO_TYPE_FILTER = JSONReader.autoTypeFilter(Constants.JSON_WHITELIST_STR);
private Class<T> clazz; private final Class<T> clazz;
public FastJson2JsonRedisSerializer (Class<T> clazz) { public FastJson2JsonRedisSerializer (Class<T> clazz) {
super(); super();

View File

@ -10,6 +10,7 @@ import com.muyu.common.core.utils.uuid.IdUtils;
import com.muyu.common.redis.service.RedisService; import com.muyu.common.redis.service.RedisService;
import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.LoginUser; import com.muyu.common.system.domain.LoginUser;
import com.muyu.common.system.domain.SysUser;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -48,6 +49,7 @@ public class TokenService {
loginUser.setUserid(userId); loginUser.setUserid(userId);
loginUser.setUsername(userName); loginUser.setUsername(userName);
loginUser.setIpaddr(IpUtils.getIpAddr()); loginUser.setIpaddr(IpUtils.getIpAddr());
SysUser sysUser = loginUser.getSysUser();
refreshToken(loginUser); refreshToken(loginUser);
// Jwt存储信息 // Jwt存储信息

View File

@ -6,6 +6,7 @@ import com.muyu.common.core.annotation.Excel.Type;
import com.muyu.common.core.annotation.Excels; import com.muyu.common.core.annotation.Excels;
import com.muyu.common.core.web.domain.BaseEntity; import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.common.core.xss.Xss; import com.muyu.common.core.xss.Xss;
//import com.muyu.net.working.domain.Enterprise;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -138,15 +139,19 @@ public class SysUser extends BaseEntity {
private Long roleId; private Long roleId;
/** /**
* * id
*/
private String type;
/**
* ID
*/ */
private Integer enterpriseId; private Integer enterpriseId;
public Integer getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public SysUser (Long userId) { public SysUser (Long userId) {
this.userId = userId; this.userId = userId;
} }
@ -333,6 +338,8 @@ public class SysUser extends BaseEntity {
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.append("remark", getRemark()) .append("remark", getRemark())
.append("dept", getDept()) .append("dept", getDept())
.append("enterpriseId", getEnterpriseId())
.toString(); .toString();
} }
} }

View File

@ -25,5 +25,5 @@ public interface RemoteFileService {
* @return * @return
*/ */
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public Result<SysFile> upload (@RequestPart(value = "file") MultipartFile file); Result<SysFile> upload(@RequestPart(value = "file") MultipartFile file);
} }

View File

@ -27,7 +27,7 @@ public interface RemoteLogService {
* @return * @return
*/ */
@PostMapping("/operlog") @PostMapping("/operlog")
public Result<Boolean> saveLog (@RequestBody SysOperLog sysOperLog, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception; Result<Boolean> saveLog(@RequestBody SysOperLog sysOperLog, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception;
/** /**
* 访 * 访
@ -38,5 +38,5 @@ public interface RemoteLogService {
* @return * @return
*/ */
@PostMapping("/logininfor") @PostMapping("/logininfor")
public Result<Boolean> saveLogininfor (@RequestBody SysLogininfor sysLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); Result<Boolean> saveLogininfor(@RequestBody SysLogininfor sysLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
} }

View File

@ -0,0 +1,32 @@
package com.muyu.common.system.remote;
import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result;
import com.muyu.common.system.domain.SysDept;
import com.muyu.common.system.remote.factory.RemoteSysDeptFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* RemoteSysDeptService
*
* @author DeKangLiu
* Date 2024/6/7 09:00
*/
@FeignClient(
contextId = "remoteSysDeptService",
value = ServiceNameConstants.SYSTEM_SERVICE,
fallbackFactory = RemoteSysDeptFactory.class,
path = "/dept"
)
public interface RemoteSysDeptService {
@GetMapping("/selectDeptByName")
Result<SysDept> selectDeptByName(@RequestParam("name") String name);
@PostMapping
Result add(@Validated @RequestBody SysDept dept);
}

View File

@ -0,0 +1,32 @@
package com.muyu.common.system.remote;
import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.factory.RemoteSysUserFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* RemoteSysUserService
*
* @author DeKangLiu
* Date 2024/6/7 08:51
*/
@FeignClient(
contextId = "remoteSysUserService",
value = ServiceNameConstants.SYSTEM_SERVICE,
fallbackFactory = RemoteSysUserFactory.class,
path = "/user"
)
public interface RemoteSysUserService {
/**
*
* @param user
* @return Result
*/
@PostMapping
Result add(@Validated @RequestBody SysUser user);
}

View File

@ -25,7 +25,7 @@ public interface RemoteUserService {
* @return * @return
*/ */
@GetMapping("/user/info/{username}") @GetMapping("/user/info/{username}")
public Result<LoginUser> getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); Result<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/** /**
* *
@ -36,5 +36,5 @@ public interface RemoteUserService {
* @return * @return
*/ */
@PostMapping("/user/register") @PostMapping("/user/register")
public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); Result<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
} }

View File

@ -0,0 +1,42 @@
package com.muyu.common.system.remote.factory;
import com.muyu.common.core.domain.Result;
import com.muyu.common.system.domain.SysDept;
import com.muyu.common.system.remote.RemoteSysDeptService;
import lombok.extern.log4j.Log4j2;
import org.springframework.cloud.openfeign.FallbackFactory;
/**
* RemoteSysDeptFactory
*
* @author DeKangLiu
* Date 2024/6/7 09:00
*/
@Log4j2
public class RemoteSysDeptFactory implements FallbackFactory<RemoteSysDeptService> {
@Override
public RemoteSysDeptService create(Throwable cause) {
return new RemoteSysDeptService() {
/**
*
* @param name
* @return
*/
@Override
public Result<SysDept> selectDeptByName(String name) {
return Result.error(cause.getMessage());
}
/**
*
* @param dept
* @return
*/
@Override
public Result add(SysDept dept) {
return Result.error(cause.getMessage());
}
};
}
}

View File

@ -0,0 +1,31 @@
package com.muyu.common.system.remote.factory;
import com.muyu.common.core.domain.Result;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.RemoteSysUserService;
import org.springframework.cloud.openfeign.FallbackFactory;
/**
* RemoteSysUserFactory
*
* @author DeKangLiu
* Date 2024/6/7 08:54
*/
public class RemoteSysUserFactory implements FallbackFactory<RemoteSysUserService> {
@Override
public RemoteSysUserService create(Throwable cause) {
return new RemoteSysUserService() {
/**
*
* @param user
* @return
*/
@Override
public Result add(SysUser user) {
return Result.error(cause.getMessage());
}
};
}
}

View File

@ -1,3 +1,5 @@
com.muyu.common.system.remote.factory.RemoteUserFallbackFactory com.muyu.common.system.remote.factory.RemoteUserFallbackFactory
com.muyu.common.system.remote.factory.RemoteLogFallbackFactory com.muyu.common.system.remote.factory.RemoteLogFallbackFactory
com.muyu.common.system.remote.factory.RemoteFileFallbackFactory com.muyu.common.system.remote.factory.RemoteFileFallbackFactory
com.muyu.common.system.remote.factory.RemoteSysDeptFactory
com.muyu.common.system.remote.factory.RemoteSysUserFactory

View File

@ -36,7 +36,7 @@ public class BlackListUrlFilter extends AbstractGatewayFilterFactory<BlackListUr
public static class Config { public static class Config {
private List<String> blacklistUrl; private List<String> blacklistUrl;
private List<Pattern> blacklistUrlPattern = new ArrayList<>(); private final List<Pattern> blacklistUrlPattern = new ArrayList<>();
public boolean matchBlacklist (String url) { public boolean matchBlacklist (String url) {
return !blacklistUrlPattern.isEmpty() && blacklistUrlPattern.stream().anyMatch(p -> p.matcher(url).find()); return !blacklistUrlPattern.isEmpty() && blacklistUrlPattern.stream().anyMatch(p -> p.matcher(url).find());

View File

@ -34,8 +34,7 @@ public class GatewayExceptionHandler implements ErrorWebExceptionHandler {
if (ex instanceof NotFoundException) { if (ex instanceof NotFoundException) {
msg = "服务未找到"; msg = "服务未找到";
} else if (ex instanceof ResponseStatusException) { } else if (ex instanceof ResponseStatusException responseStatusException) {
ResponseStatusException responseStatusException = (ResponseStatusException) ex;
msg = responseStatusException.getMessage(); msg = responseStatusException.getMessage();
} else { } else {
msg = "内部服务器错误"; msg = "内部服务器错误";

View File

@ -14,10 +14,10 @@ public interface ValidateCodeService {
/** /**
* *
*/ */
public Result createCaptcha () throws IOException, CaptchaException; Result createCaptcha() throws IOException, CaptchaException;
/** /**
* *
*/ */
public void checkCaptcha (String key, String value) throws CaptchaException; void checkCaptcha(String key, String value) throws CaptchaException;
} }

View File

@ -0,0 +1,28 @@
package com.muyu.customer.business.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* Atlas
*
* @author DeKangLiu
* Date 2024/6/2 22:35
*/
@Data
@SuperBuilder
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Atlas {
private String Q;
private String R;
private String lat;
private String lng;
}

View File

@ -0,0 +1,52 @@
package com.muyu.customer.business.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 io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* DataSource
*
* @author DeKangLiu
* Date 2024/6/22 22:56
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName("datasource")
public class DataSource extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(name = "主键", value = "主键")
private Long id;
/** 数据源key */
@Excel(name = "数据源key")
@ApiModelProperty(name = "数据源key", value = "数据源key")
private String enterpriseCode;
/** 数据源端口 */
@Excel(name = "数据源端口")
@ApiModelProperty(name = "数据源端口", value = "数据源端口")
private Integer port;
/** 数据源ip */
@Excel(name = "数据源ip")
@ApiModelProperty(name = "数据源ip", value = "数据源ip")
private String ip;
}

View File

@ -0,0 +1,94 @@
package com.muyu.customer.business.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.customer.business.domain.req.FaultCodeEditReq;
import com.muyu.customer.business.domain.req.FaultCodeQueryReq;
import com.muyu.customer.business.domain.req.FaultCodeSaveReq;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* fault_code
*
* @author muyu
* @date 2024-06-20
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("fault_code")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "FaultCode", description = "车辆故障码")
public class FaultCode extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(name = "主键", value = "主键")
private Long id;
/** 故障码 */
@Excel(name = "故障码")
@ApiModelProperty(name = "故障码", value = "故障码")
private String faultCode;
/** 故障标签 */
@Excel(name = "故障标签")
@ApiModelProperty(name = "故障标签", value = "故障标签")
private String faultLabel;
/** 故障位 */
@Excel(name = "故障位")
@ApiModelProperty(name = "故障位", value = "故障位")
private Long faultBit;
/** 故障值 */
@Excel(name = "故障值")
@ApiModelProperty(name = "故障值", value = "故障值")
private Long faultValue;
/**
*
*/
public static FaultCode queryBuild( FaultCodeQueryReq faultCodeQueryReq){
return FaultCode.builder()
.faultCode(faultCodeQueryReq.getFaultCode())
.build();
}
/**
*
*/
public static FaultCode saveBuild(FaultCodeSaveReq faultCodeSaveReq){
return FaultCode.builder()
.faultCode(faultCodeSaveReq.getFaultCode())
.faultLabel(faultCodeSaveReq.getFaultLabel())
.faultBit(faultCodeSaveReq.getFaultBit())
.faultValue(faultCodeSaveReq.getFaultValue())
.build();
}
/**
*
*/
public static FaultCode editBuild(Long id, FaultCodeEditReq faultCodeEditReq){
return FaultCode.builder()
.id(id)
.faultCode(faultCodeEditReq.getFaultCode())
.faultLabel(faultCodeEditReq.getFaultLabel())
.faultBit(faultCodeEditReq.getFaultBit())
.faultValue(faultCodeEditReq.getFaultValue())
.build();
}
}

View File

@ -0,0 +1,114 @@
package com.muyu.customer.business.domain;
import java.util.Date;
import com.muyu.customer.business.domain.req.FaultRecordSaveReq;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.customer.business.domain.req.FaultRecordEditReq;
import com.muyu.customer.business.domain.req.FaultRecordQueryReq;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* fault_record
*
* @author muyu
* @date 2024-06-20
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("fault_record")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "FaultRecord", description = "故障记录")
public class FaultRecord extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(name = "主键", value = "主键")
private Long id;
/** 故障码 */
@Excel(name = "故障码")
@ApiModelProperty(name = "故障码", value = "故障码")
private String faultCode;
/** 车辆vin */
@Excel(name = "车辆vin")
@ApiModelProperty(name = "车辆vin", value = "车辆vin")
private String vin;
/** 故障开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "故障开始时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty(name = "故障开始时间", value = "故障开始时间")
private Date startTime;
/** 故障结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "故障结束时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty(name = "故障结束时间", value = "故障结束时间")
private Date endTime;
/** 故障级别 */
@Excel(name = "故障级别")
@ApiModelProperty(name = "故障级别", value = "故障级别")
private String faultLevel;
/** 故障是否处理 */
@Excel(name = "故障是否处理")
@ApiModelProperty(name = "故障是否处理", value = "故障是否处理")
private String faultHandle;
/**
*
*/
public static FaultRecord queryBuild( FaultRecordQueryReq faultRecordQueryReq){
return FaultRecord.builder()
.faultCode(faultRecordQueryReq.getFaultCode())
.vin(faultRecordQueryReq.getVin())
.build();
}
/**
*
*/
public static FaultRecord saveBuild(FaultRecordSaveReq faultRecordSaveReq){
return FaultRecord.builder()
.faultCode(faultRecordSaveReq.getFaultCode())
.vin(faultRecordSaveReq.getVin())
.startTime(faultRecordSaveReq.getStartTime())
.endTime(faultRecordSaveReq.getEndTime())
.faultLevel(faultRecordSaveReq.getFaultLevel())
.faultHandle(faultRecordSaveReq.getFaultHandle())
.build();
}
/**
*
*/
public static FaultRecord editBuild(Long id, FaultRecordEditReq faultRecordEditReq){
return FaultRecord.builder()
.id(id)
.faultCode(faultRecordEditReq.getFaultCode())
.vin(faultRecordEditReq.getVin())
.startTime(faultRecordEditReq.getStartTime())
.endTime(faultRecordEditReq.getEndTime())
.faultLevel(faultRecordEditReq.getFaultLevel())
.faultHandle(faultRecordEditReq.getFaultHandle())
.build();
}
}

View File

@ -0,0 +1,89 @@
package com.muyu.customer.business.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.customer.business.domain.req.FenceEditReq;
import com.muyu.customer.business.domain.req.FenceQueryReq;
import com.muyu.customer.business.domain.req.FenceSaveReq;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* fence
*
* @author muyu
* @date 2024-05-31
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("fence")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Fence", description = "电子围栏")
public class Fence extends BaseEntity {
private static final long serialVersionUID = 1L;
/** id */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(name = "id", value = "id")
private Long id;
/** 电子围栏名称 */
@Excel(name = "电子围栏名称")
@ApiModelProperty(name = "电子围栏名称", value = "电子围栏名称")
private String name;
/** 围栏类型 */
@Excel(name = "围栏类型")
@ApiModelProperty(name = "围栏类型", value = "围栏类型")
private String fenceType;
/** 经纬度信息 */
@Excel(name = "经纬度信息")
@ApiModelProperty(name = "经纬度信息", value = "经纬度信息")
private String longitudeAndLatitude;
/**
*
*/
public static Fence queryBuild( FenceQueryReq fenceQueryReq){
return Fence.builder()
.name(fenceQueryReq.getName())
.fenceType(fenceQueryReq.getFenceType())
.longitudeAndLatitude(fenceQueryReq.getLongitudeAndLatitude())
.build();
}
/**
*
*/
public static Fence saveBuild(FenceSaveReq fenceSaveReq){
return Fence.builder()
.name(fenceSaveReq.getName())
.fenceType(fenceSaveReq.getFenceType())
.longitudeAndLatitude(fenceSaveReq.getLongitudeAndLatitude())
.build();
}
/**
*
*/
public static Fence editBuild(Long id, FenceEditReq fenceEditReq){
return Fence.builder()
.id(id)
.name(fenceEditReq.getName())
.fenceType(fenceEditReq.getFenceType())
.longitudeAndLatitude(fenceEditReq.getLongitudeAndLatitude())
.build();
}
}

View File

@ -0,0 +1,108 @@
package com.muyu.customer.business.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.customer.business.domain.req.IndexConfigurationEditReq;
import com.muyu.customer.business.domain.req.IndexConfigurationQueryReq;
import com.muyu.customer.business.domain.req.IndexConfigurationSaveReq;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
/**
* index_configuration
*
* @author muyu
* @date 2024-06-28
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("index_configuration")
@ApiModel(value = "IndexConfiguration", description = "车辆指标预警配置")
public class IndexConfiguration {
private static final long serialVersionUID = 1L;
/** 主键id */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(name = "主键id", value = "主键id")
private Long id;
/** 车辆vin */
@Excel(name = "车辆vin")
@ApiModelProperty(name = "车辆vin", value = "车辆vin")
private String vin;
/** 指标项key */
@Excel(name = "指标项key")
@ApiModelProperty(name = "指标项key", value = "指标项key")
private String keyCode;
/** 滑窗范围(秒) */
@Excel(name = "滑窗范围(秒)")
@ApiModelProperty(name = "滑窗范围(秒)", value = "滑窗范围(秒)")
private Long intervalRange;
/** 滑窗时机(秒) */
@Excel(name = "滑窗时机(秒)")
@ApiModelProperty(name = "滑窗时机(秒)", value = "滑窗时机(秒)")
private Long opportunity;
/** 类型1 上升 2 波动 3 下降 */
@Excel(name = "类型1 上升 2 波动 3 下降")
@ApiModelProperty(name = "类型1 上升 2 波动 3 下降", value = "类型1 上升 2 波动 3 下降")
private Long attributeType;
/** 指标值 */
@Excel(name = "指标值")
@ApiModelProperty(name = "指标值", value = "指标值")
private String attributeValue;
/**
*
*/
public static IndexConfiguration queryBuild( IndexConfigurationQueryReq indexConfigurationQueryReq){
return IndexConfiguration.builder()
.vin(indexConfigurationQueryReq.getVin())
.build();
}
/**
*
*/
public static IndexConfiguration saveBuild(IndexConfigurationSaveReq indexConfigurationSaveReq){
return IndexConfiguration.builder()
.vin(indexConfigurationSaveReq.getVin())
.keyCode(indexConfigurationSaveReq.getKeyCode())
.intervalRange(indexConfigurationSaveReq.getIntervalRange())
.opportunity(indexConfigurationSaveReq.getOpportunity())
.attributeType(indexConfigurationSaveReq.getAttributeType())
.attributeValue(indexConfigurationSaveReq.getAttributeValue())
.build();
}
/**
*
*/
public static IndexConfiguration editBuild(Long id, IndexConfigurationEditReq indexConfigurationEditReq){
return IndexConfiguration.builder()
.id(id)
.vin(indexConfigurationEditReq.getVin())
.keyCode(indexConfigurationEditReq.getKeyCode())
.intervalRange(indexConfigurationEditReq.getIntervalRange())
.opportunity(indexConfigurationEditReq.getOpportunity())
.attributeType(indexConfigurationEditReq.getAttributeType())
.attributeValue(indexConfigurationEditReq.getAttributeValue())
.build();
}
}

View File

@ -0,0 +1,104 @@
package com.muyu.customer.business.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.customer.business.domain.req.MessageDetailEditReq;
import com.muyu.customer.business.domain.req.MessageDetailQueryReq;
import com.muyu.customer.business.domain.req.MessageDetailSaveReq;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* message_detail
*
* @author muyu
* @date 2024-06-28
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("message_detail")
@ApiModel(value = "MessageDetail", description = "报文详情")
public class MessageDetail {
/** 报文id */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(name = "报文id", value = "报文id")
private Long id;
/** 数据项key */
@Excel(name = "数据项key")
@ApiModelProperty(name = "数据项key", value = "数据项key")
private String keyCode;
/** 起始位 */
@Excel(name = "起始位")
@ApiModelProperty(name = "起始位", value = "起始位")
private String startBit;
/** 结束位 */
@Excel(name = "结束位")
@ApiModelProperty(name = "结束位", value = "结束位")
private String stopBit;
/** 标签 */
@Excel(name = "标签")
@ApiModelProperty(name = "标签", value = "标签")
private String label;
/** 类型 */
@Excel(name = "类型")
@ApiModelProperty(name = "类型", value = "类型")
private String type;
// private String vin;
/**
*
*/
public static MessageDetail queryBuild( MessageDetailQueryReq messageDetailQueryReq){
return MessageDetail.builder()
.keyCode(messageDetailQueryReq.getKeyCode())
.startBit(messageDetailQueryReq.getStartBit())
.stopBit(messageDetailQueryReq.getStopBit())
.label(messageDetailQueryReq.getLabel())
.type(messageDetailQueryReq.getType())
.build();
}
/**
*
*/
public static MessageDetail saveBuild(MessageDetailSaveReq messageDetailSaveReq){
return MessageDetail.builder()
.keyCode(messageDetailSaveReq.getKeyCode())
.startBit(messageDetailSaveReq.getStartBit())
.stopBit(messageDetailSaveReq.getStopBit())
.label(messageDetailSaveReq.getLabel())
.type(messageDetailSaveReq.getType())
.build();
}
/**
*
*/
public static MessageDetail editBuild(Long id, MessageDetailEditReq messageDetailEditReq){
return MessageDetail.builder()
.id(id)
.keyCode(messageDetailEditReq.getKeyCode())
.startBit(messageDetailEditReq.getStartBit())
.stopBit(messageDetailEditReq.getStopBit())
.label(messageDetailEditReq.getLabel())
.type(messageDetailEditReq.getType())
.build();
}
}

View File

@ -2,11 +2,15 @@ package com.muyu.customer.business.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import com.muyu.customer.business.domain.req.VehicleQueryReq;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.customer.business.domain.req.VehicleEditReq;
import com.muyu.customer.business.domain.req.VehicleSaveReq;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -14,9 +18,6 @@ import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import com.muyu.common.core.annotation.Excel; import com.muyu.common.core.annotation.Excel;
import com.muyu.customer.business.domain.req.VehicleQueryReq;
import com.muyu.customer.business.domain.req.VehicleSaveReq;
import com.muyu.customer.business.domain.req.VehicleEditReq;
import com.muyu.common.core.web.domain.BaseEntity; import com.muyu.common.core.web.domain.BaseEntity;
/** /**
@ -118,6 +119,9 @@ public class Vehicle extends BaseEntity {
@ApiModelProperty(name = "车辆类型", value = "车辆类型") @ApiModelProperty(name = "车辆类型", value = "车辆类型")
private String vehicleType; private String vehicleType;
// /** 报文详情对象 */
// private MessageDetail messageDetail;
/** /**
* *
*/ */

View File

@ -0,0 +1,25 @@
package com.muyu.customer.business.domain.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.List;
/**
* MessDetaiModel
*
* @author DeKangLiu
* Date 2024/6/28 21:39
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class MessageDetailModel {
private String vin;
private List<Integer> ids;
}

View File

@ -0,0 +1,25 @@
package com.muyu.customer.business.domain.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* VehicleMiddle
*
* @author DeKangLiu
* Date 2024/6/27 09:53
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class VehicleMiddle {
private Integer id;
private Integer vehicleId;
private Integer messageId;
}

View File

@ -0,0 +1,80 @@
package com.muyu.customer.business.domain.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* VehicleModel
*
* @author DeKangLiu
* Date 2024/6/27 08:18
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class VehicleModel {
/** 车辆id */
private Long id;
/** 车辆vin */
private String vin;
/** 品牌 */
private String brand;
/** 型号 */
private String model;
/** 生产日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date productionDate;
/** 车身类型 */
private String bodyType;
/** 车身颜色 */
private String color;
/** 发动机排量 */
private BigDecimal engineCapacity;
/** 燃油类型 */
private String fuelType;
/** 变速器类型 */
private String transmission;
/** 驱动方式 */
private String driveType;
/** 行驶里程 */
private BigDecimal mileage;
/** 注册日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date registrationDate;
/** 车牌号码 */
private String licenseNumber;
/** 持有者 */
private String holder;
/** 车辆类型 */
private String vehicleType;
/** 报文详情对象 */
private List<Integer> messageDetail;
}

View File

@ -0,0 +1,42 @@
package com.muyu.customer.business.domain.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* fault_code
*
* @author muyu
* @date 2024-06-20
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "FaultCodeEditReq", description = "车辆故障码")
public class FaultCodeEditReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 故障码 */
@ApiModelProperty(name = "故障码", value = "故障码")
private String faultCode;
/** 故障标签 */
@ApiModelProperty(name = "故障标签", value = "故障标签")
private String faultLabel;
/** 故障位 */
@ApiModelProperty(name = "故障位", value = "故障位")
private Long faultBit;
/** 故障值 */
@ApiModelProperty(name = "故障值", value = "故障值")
private Long faultValue;
}

View File

@ -0,0 +1,30 @@
package com.muyu.customer.business.domain.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* fault_code
*
* @author muyu
* @date 2024-06-20
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "FaultCodeQueryReq", description = "车辆故障码")
public class FaultCodeQueryReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 故障码 */
@ApiModelProperty(name = "故障码", value = "故障码")
private String faultCode;
}

View File

@ -0,0 +1,51 @@
package com.muyu.customer.business.domain.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* fault_code
*
* @author muyu
* @date 2024-06-20
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "FaultCodeSaveReq", description = "车辆故障码")
public class FaultCodeSaveReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
@ApiModelProperty(name = "主键", value = "主键")
private Long id;
/** 故障码 */
@ApiModelProperty(name = "故障码", value = "故障码")
private String faultCode;
/** 故障标签 */
@ApiModelProperty(name = "故障标签", value = "故障标签")
private String faultLabel;
/** 故障位 */
@ApiModelProperty(name = "故障位", value = "故障位")
private Long faultBit;
/** 故障值 */
@ApiModelProperty(name = "故障值", value = "故障值")
private Long faultValue;
}

View File

@ -0,0 +1,54 @@
package com.muyu.customer.business.domain.req;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* fault_record
*
* @author muyu
* @date 2024-06-20
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "FaultRecordEditReq", description = "故障记录")
public class FaultRecordEditReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 故障码 */
@ApiModelProperty(name = "故障码", value = "故障码")
private String faultCode;
/** 车辆vin */
@ApiModelProperty(name = "车辆vin", value = "车辆vin")
private String vin;
/** 故障开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(name = "故障开始时间", value = "故障开始时间")
private Date startTime;
/** 故障结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(name = "故障结束时间", value = "故障结束时间")
private Date endTime;
/** 故障级别 */
@ApiModelProperty(name = "故障级别", value = "故障级别")
private String faultLevel;
/** 故障是否处理 */
@ApiModelProperty(name = "故障是否处理", value = "故障是否处理")
private String faultHandle;
}

View File

@ -0,0 +1,36 @@
package com.muyu.customer.business.domain.req;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* fault_record
*
* @author muyu
* @date 2024-06-20
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "FaultRecordQueryReq", description = "故障记录")
public class FaultRecordQueryReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 故障码 */
@ApiModelProperty(name = "故障码", value = "故障码")
private String faultCode;
/** 车辆vin */
@ApiModelProperty(name = "车辆vin", value = "车辆vin")
private String vin;
}

View File

@ -0,0 +1,65 @@
package com.muyu.customer.business.domain.req;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* fault_record
*
* @author muyu
* @date 2024-06-20
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "FaultRecordSaveReq", description = "故障记录")
public class FaultRecordSaveReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
@ApiModelProperty(name = "主键", value = "主键")
private Long id;
/** 故障码 */
@ApiModelProperty(name = "故障码", value = "故障码")
private String faultCode;
/** 车辆vin */
@ApiModelProperty(name = "车辆vin", value = "车辆vin")
private String vin;
/** 故障开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(name = "故障开始时间", value = "故障开始时间")
private Date startTime;
/** 故障结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(name = "故障结束时间", value = "故障结束时间")
private Date endTime;
/** 故障级别 */
@ApiModelProperty(name = "故障级别", value = "故障级别")
private String faultLevel;
/** 故障是否处理 */
@ApiModelProperty(name = "故障是否处理", value = "故障是否处理")
private String faultHandle;
}

View File

@ -0,0 +1,38 @@
package com.muyu.customer.business.domain.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* fence
*
* @author muyu
* @date 2024-05-31
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "FenceEditReq", description = "电子围栏")
public class FenceEditReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 电子围栏名称 */
@ApiModelProperty(name = "电子围栏名称", value = "电子围栏名称")
private String name;
/** 围栏类型 */
@ApiModelProperty(name = "围栏类型", value = "围栏类型")
private String fenceType;
/** 经纬度信息 */
@ApiModelProperty(name = "经纬度信息", value = "经纬度信息")
private String longitudeAndLatitude;
}

View File

@ -0,0 +1,38 @@
package com.muyu.customer.business.domain.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* fence
*
* @author muyu
* @date 2024-05-31
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "FenceQueryReq", description = "电子围栏")
public class FenceQueryReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 电子围栏名称 */
@ApiModelProperty(name = "电子围栏名称", value = "电子围栏名称")
private String name;
/** 围栏类型 */
@ApiModelProperty(name = "围栏类型", value = "围栏类型")
private String fenceType;
/** 经纬度信息 */
@ApiModelProperty(name = "经纬度信息", value = "经纬度信息")
private String longitudeAndLatitude;
}

View File

@ -0,0 +1,46 @@
package com.muyu.customer.business.domain.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* fence
*
* @author muyu
* @date 2024-05-31
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "FenceSaveReq", description = "电子围栏")
public class FenceSaveReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** id */
@ApiModelProperty(name = "id", value = "id")
private Long id;
/** 电子围栏名称 */
@ApiModelProperty(name = "电子围栏名称", value = "电子围栏名称")
private String name;
/** 围栏类型 */
@ApiModelProperty(name = "围栏类型", value = "围栏类型")
private String fenceType;
/** 经纬度信息 */
@ApiModelProperty(name = "经纬度信息", value = "经纬度信息")
private String longitudeAndLatitude;
}

View File

@ -0,0 +1,49 @@
package com.muyu.customer.business.domain.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
/**
* index_configuration
*
* @author muyu
* @date 2024-06-28
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "IndexConfigurationEditReq", description = "车辆指标预警配置")
public class IndexConfigurationEditReq {
private static final long serialVersionUID = 1L;
/** 车辆vin */
@ApiModelProperty(name = "车辆vin", value = "车辆vin")
private String vin;
/** 指标项key */
@ApiModelProperty(name = "指标项key", value = "指标项key")
private String keyCode;
/** 滑窗范围(秒) */
@ApiModelProperty(name = "滑窗范围(秒)", value = "滑窗范围(秒)")
private Long intervalRange;
/** 滑窗时机(秒) */
@ApiModelProperty(name = "滑窗时机(秒)", value = "滑窗时机(秒)")
private Long opportunity;
/** 类型1 上升 2 波动 3 下降 */
@ApiModelProperty(name = "类型1 上升 2 波动 3 下降", value = "类型1 上升 2 波动 3 下降")
private Long attributeType;
/** 指标值 */
@ApiModelProperty(name = "指标值", value = "指标值")
private String attributeValue;
}

View File

@ -0,0 +1,30 @@
package com.muyu.customer.business.domain.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
/**
* index_configuration
*
* @author muyu
* @date 2024-06-28
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "IndexConfigurationQueryReq", description = "车辆指标预警配置")
public class IndexConfigurationQueryReq {
private static final long serialVersionUID = 1L;
/** 车辆vin */
@ApiModelProperty(name = "车辆vin", value = "车辆vin")
private String vin;
}

View File

@ -0,0 +1,61 @@
package com.muyu.customer.business.domain.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
/**
* index_configuration
*
* @author muyu
* @date 2024-06-28
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "IndexConfigurationSaveReq", description = "车辆指标预警配置")
public class IndexConfigurationSaveReq {
private static final long serialVersionUID = 1L;
/** 主键id */
@ApiModelProperty(name = "主键id", value = "主键id")
private Long id;
/** 车辆vin */
@ApiModelProperty(name = "车辆vin", value = "车辆vin")
private String vin;
/** 指标项key */
@ApiModelProperty(name = "指标项key", value = "指标项key")
private String keyCode;
/** 滑窗范围(秒) */
@ApiModelProperty(name = "滑窗范围(秒)", value = "滑窗范围(秒)")
private Long intervalRange;
/** 滑窗时机(秒) */
@ApiModelProperty(name = "滑窗时机(秒)", value = "滑窗时机(秒)")
private Long opportunity;
/** 类型1 上升 2 波动 3 下降 */
@ApiModelProperty(name = "类型1 上升 2 波动 3 下降", value = "类型1 上升 2 波动 3 下降")
private Long attributeType;
/** 指标值 */
@ApiModelProperty(name = "指标值", value = "指标值")
private String attributeValue;
}

View File

@ -0,0 +1,46 @@
package com.muyu.customer.business.domain.req;
import com.muyu.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* message_detail
*
* @author muyu
* @date 2024-06-28
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "MessageDetailEditReq", description = "报文详情")
public class MessageDetailEditReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 数据项key */
@ApiModelProperty(name = "数据项key", value = "数据项key")
private String keyCode;
/** 起始位 */
@ApiModelProperty(name = "起始位", value = "起始位")
private String startBit;
/** 结束位 */
@ApiModelProperty(name = "结束位", value = "结束位")
private String stopBit;
/** 标签 */
@ApiModelProperty(name = "标签", value = "标签")
private String label;
/** 类型 */
@ApiModelProperty(name = "类型", value = "类型")
private String type;
}

View File

@ -0,0 +1,46 @@
package com.muyu.customer.business.domain.req;
import com.muyu.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* message_detail
*
* @author muyu
* @date 2024-06-28
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "MessageDetailQueryReq", description = "报文详情")
public class MessageDetailQueryReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 数据项key */
@ApiModelProperty(name = "数据项key", value = "数据项key")
private String keyCode;
/** 起始位 */
@ApiModelProperty(name = "起始位", value = "起始位")
private String startBit;
/** 结束位 */
@ApiModelProperty(name = "结束位", value = "结束位")
private String stopBit;
/** 标签 */
@ApiModelProperty(name = "标签", value = "标签")
private String label;
/** 类型 */
@ApiModelProperty(name = "类型", value = "类型")
private String type;
}

View File

@ -0,0 +1,58 @@
package com.muyu.customer.business.domain.req;
import com.muyu.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* message_detail
*
* @author muyu
* @date 2024-06-28
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "MessageDetailSaveReq", description = "报文详情")
public class MessageDetailSaveReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 报文id */
@ApiModelProperty(name = "报文id", value = "报文id")
private Long id;
/** 数据项key */
@ApiModelProperty(name = "数据项key", value = "数据项key")
private String keyCode;
/** 起始位 */
@ApiModelProperty(name = "起始位", value = "起始位")
private String startBit;
/** 结束位 */
@ApiModelProperty(name = "结束位", value = "结束位")
private String stopBit;
/** 标签 */
@ApiModelProperty(name = "标签", value = "标签")
private String label;
/** 类型 */
@ApiModelProperty(name = "类型", value = "类型")
private String type;
private String vin;
}

View File

@ -0,0 +1,27 @@
package com.muyu.customer.business.domain.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* FaultRecordVo
*
* @author DeKangLiu
* Date 2024/6/24 19:32
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FaultRecordVo {
/**
*
*/
private String faultCode;
/**
* vin
*/
private String vin;
private String count;
private String faultLabel;
}

View File

@ -16,5 +16,17 @@
<maven.compiler.target>17</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-core</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-net-working-common</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project> </project>

View File

@ -72,6 +72,11 @@
<groupId>com.muyu</groupId> <groupId>com.muyu</groupId>
<artifactId>muyu-common-datascope</artifactId> <artifactId>muyu-common-datascope</artifactId>
</dependency> </dependency>
<!-- rabbitmq -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!-- MuYu Common Log --> <!-- MuYu Common Log -->
<dependency> <dependency>
@ -84,7 +89,29 @@
<groupId>com.muyu</groupId> <groupId>com.muyu</groupId>
<artifactId>muyu-common-swagger</artifactId> <artifactId>muyu-common-swagger</artifactId>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.muyu</groupId>-->
<!-- <artifactId>muyu-customer-business-remote</artifactId>-->
<!-- <version>3.6.3</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-net-working-common</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-net-working-remote</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -1,10 +1,13 @@
package com.muyu.customer.business; package com.muyu.customer.business;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
import com.muyu.common.security.annotation.EnableCustomConfig; import com.muyu.common.security.annotation.EnableCustomConfig;
import com.muyu.common.security.annotation.EnableMyFeignClients; import com.muyu.common.security.annotation.EnableMyFeignClients;
import com.muyu.common.swagger.annotation.EnableCustomSwagger2; import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling;
/** /**
* MuYuCustomerBusinessApplication * MuYuCustomerBusinessApplication
@ -15,7 +18,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableCustomConfig @EnableCustomConfig
@EnableCustomSwagger2 @EnableCustomSwagger2
@EnableMyFeignClients @EnableMyFeignClients
@SpringBootApplication @SpringBootApplication(exclude = {DynamicDataSourceAutoConfiguration.class, DataSourceAutoConfiguration.class })
public class MuYuCustomerBusinessApplication { public class MuYuCustomerBusinessApplication {
public static void main (String[] args) { public static void main (String[] args) {
SpringApplication.run(MuYuCustomerBusinessApplication.class, args); SpringApplication.run(MuYuCustomerBusinessApplication.class, args);

View File

@ -0,0 +1,48 @@
package com.muyu.customer.business.config;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
*
*/
@Component
public class ConfirmCallbackConfig implements RabbitTemplate.ConfirmCallback {
@Autowired
private RabbitTemplate rabbitTemplate;
/**
* @PostContructspringspring
* @PostConstruct bean
* @PreDestory bean
*/
@PostConstruct
public void init() {
rabbitTemplate.setConfirmCallback(this);
}
/**
*
*
* @param correlationData
* @param ack
* @param cause
*/
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
if (ack) {
// 消息投递到 broker 的状态true表示成功
System.out.println("消息发送成功!");
} else {
// 发送异常
System.out.println("发送异常原因 = " + cause);
// TODO 可以将消息 内容 以及 失败的原因 记录到 日志表中
}
}
}

View File

@ -0,0 +1,53 @@
package com.muyu.customer.business.config;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* RabbitAdminRabbitMQJavaRabbitMQRabbitMQ
*/
@Configuration
public class RabbitAdminConfig {
@Value("${spring.rabbitmq.host}")
private String host;
@Value("${spring.rabbitmq.username}")
private String username;
@Value("${spring.rabbitmq.password}")
private String password;
@Value("${spring.rabbitmq.virtualhost}")
private String virtualhost;
/**
* RabbitMQ
* @return
*/
@Bean
public ConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
connectionFactory.setAddresses(host);
connectionFactory.setUsername(username);
connectionFactory.setPassword(password);
connectionFactory.setVirtualHost(virtualhost);
// 配置发送确认回调时次配置必须配置否则即使在RabbitTemplate配置了ConfirmCallback也不会生效
connectionFactory.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED);
connectionFactory.setPublisherReturns(true);
return connectionFactory;
}
/**
* RabbitAdmin
* @param connectionFactory
* @return
*/
@Bean
public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
rabbitAdmin.setAutoStartup(true);
return rabbitAdmin;
}
}

View File

@ -0,0 +1,15 @@
package com.muyu.customer.business.config;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitmqConfig {
// 消息转换配置
@Bean
public MessageConverter jsonMessageConverter() {
return new Jackson2JsonMessageConverter();
}
}

View File

@ -0,0 +1,20 @@
package com.muyu.customer.business.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {
/**
* RestTemplateRestTemplate
* @return
*/
@ConditionalOnMissingBean(RestTemplate.class)
@Bean
public RestTemplate restTemplate(){
RestTemplate restTemplate = new RestTemplate();
return restTemplate;
}
}

View File

@ -0,0 +1,34 @@
package com.muyu.customer.business.config;
import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
* returnedMessage
*/
@Component
public class ReturnCallbackConfig implements RabbitTemplate.ReturnsCallback {
@Autowired
private RabbitTemplate rabbitTemplate;
@PostConstruct // @PostContruct是spring框架的注解在⽅法上加该注解会在项⽬启动的时候执⾏该⽅法也可以理解为在spring容器初始化的时候执
public void init() {
rabbitTemplate.setReturnsCallback(this);
}
/**
*
* @param returnedMessage the returned message and metadata.
*/
@Override
public void returnedMessage(ReturnedMessage returnedMessage) {
System.out.println("消息" + returnedMessage.getMessage().toString() + "被交换机" + returnedMessage.getExchange() + "回退!"
+ "退回原因为:" + returnedMessage.getReplyText());
// 回退了所有的信息,可做补偿机制 记录到 数据库
}
}

View File

@ -0,0 +1,112 @@
package com.muyu.customer.business.consumer;
import com.muyu.customer.business.domain.FaultRecord;
import com.muyu.customer.business.saas.holder.DynamicDataSourceHolder;
import com.muyu.customer.business.service.FaultRecordService;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.core.Message;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* rabbitMQ Task
*
* @author DeKangLiu
* Date 2024/6/20 22:33
*/
@Component
@Log4j2
public class RabbitConsumer {
@Autowired
private FaultRecordService faultRecordService;
@Autowired
private StringRedisTemplate redisTemplate;
@RabbitListener(bindings = {@QueueBinding(value = @Queue(name = "error"),
exchange = @Exchange(name = "carnet_fault_event", type = ExchangeTypes.DIRECT))})
public void consumptionStartMessage(Message message, Channel channel) {
try {
// DynamicDataSourceHolder.setDynamicDataSourceKey("liu_"+42);
log.info("接收到消息:{}", new String(message.getBody()));
String body= new String(message.getBody());
String[] split = body.split("_");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = dateFormat.parse(split[3]);
String s = redisTemplate.opsForValue().get(split[0]+"1");
System.out.println(s);
//选择数据源,切换数据源,
DynamicDataSourceHolder.setDynamicDataSourceKey("liu_"+s);
FaultRecord build = FaultRecord.builder()
.vin(split[0])
.faultCode(split[1])
.faultLevel(split[2])
.startTime(date)
.build();
log.info("123{}",build);
faultRecordService.save(build);
// 移除数据源,
DynamicDataSourceHolder.removeDynamicDataSourceKey();
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
log.info("消费成功!数据源为:{}",message);
} catch (Exception e) {
log.info("消费失败,{}",e.getMessage());
try {
//回退消息
channel.basicReject(message.getMessageProperties().getDeliveryTag(),false);
log.info("回退成功");
}catch (IOException ex){
log.info("回退失败:{}",ex.getMessage());
}
throw new RuntimeException(e);
}
}
@RabbitListener(bindings = {@QueueBinding(value = @Queue(name = "success"),
exchange = @Exchange(name = "carnet_fault_event", type = ExchangeTypes.DIRECT))})
public void successMessage(Message message, Channel channel) {
try {
log.info("恢复正常消息:{}", new String(message.getBody()));
String body= new String(message.getBody());
String[] split = body.split("_");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = dateFormat.parse(split[3]);
String s = redisTemplate.opsForValue().get(split[0]+"1");
System.out.println(s);
//选择数据源,切换数据源,
DynamicDataSourceHolder.setDynamicDataSourceKey("liu_"+s);
FaultRecord build = FaultRecord.builder()
.vin(split[0])
.faultCode(split[1])
.faultLevel(split[2])
.endTime(date)
.build();
FaultRecord faultRecordOne = faultRecordService.selectFault(build);
log.info("查询到的故障为:{}",faultRecordOne);
faultRecordOne.setEndTime(build.getEndTime());
// 进行修改故障表
faultRecordService.updateFault(faultRecordOne);
// 移除数据源,
DynamicDataSourceHolder.removeDynamicDataSourceKey();
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
try {
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}

View File

@ -0,0 +1,111 @@
package com.muyu.customer.business.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.muyu.customer.business.domain.FaultCode;
import com.muyu.customer.business.domain.req.FaultCodeEditReq;
import com.muyu.customer.business.domain.req.FaultCodeQueryReq;
import com.muyu.customer.business.domain.req.FaultCodeSaveReq;
import com.muyu.customer.business.service.FaultCodeService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author muyu
* @date 2024-06-20
*/
@Api(tags = "车辆故障码")
@RestController
@RequestMapping("/faultCode")
public class FaultCodeController extends BaseController {
@Autowired
private FaultCodeService faultCodeService;
/**
*
*/
@ApiOperation("获取车辆故障码列表")
@RequiresPermissions("customerBusiness:faultCode:list")
@GetMapping("/list")
public Result<TableDataInfo<FaultCode>> list(FaultCodeQueryReq faultCodeQueryReq) {
startPage();
List<FaultCode> list = faultCodeService.list(FaultCode.queryBuild(faultCodeQueryReq));
return getDataTable(list);
}
/**
*
*/
@ApiOperation("导出车辆故障码列表")
@RequiresPermissions("customerBusiness:faultCode:export")
@Log(title = "车辆故障码", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, FaultCode faultCode) {
List<FaultCode> list = faultCodeService.list(faultCode);
ExcelUtil<FaultCode> util = new ExcelUtil<FaultCode>(FaultCode.class);
util.exportExcel(response, list, "车辆故障码数据");
}
/**
*
*/
@ApiOperation("获取车辆故障码详细信息")
@RequiresPermissions("customerBusiness:faultCode:query")
@GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<FaultCode> getInfo(@PathVariable("id") Long id) {
return Result.success(faultCodeService.getById(id));
}
/**
*
*/
@RequiresPermissions("customerBusiness:faultCode:add")
@Log(title = "车辆故障码", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("新增车辆故障码")
public Result<String> add(@RequestBody FaultCodeSaveReq faultCodeSaveReq) {
return toAjax(faultCodeService.save(FaultCode.saveBuild(faultCodeSaveReq)));
}
/**
*
*/
@RequiresPermissions("customerBusiness:faultCode:edit")
@Log(title = "车辆故障码", businessType = BusinessType.UPDATE)
@PutMapping("/{id}")
@ApiOperation("修改车辆故障码")
public Result<String> edit(@PathVariable Long id, @RequestBody FaultCodeEditReq faultCodeEditReq) {
return toAjax(faultCodeService.updateById(FaultCode.editBuild(id,faultCodeEditReq)));
}
/**
*
*/
@RequiresPermissions("customerBusiness:faultCode:remove")
@Log(title = "车辆故障码", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@ApiOperation("删除车辆故障码")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result<String> remove(@PathVariable List<Long> ids) {
return toAjax(faultCodeService.removeBatchByIds(ids));
}
}

View File

@ -0,0 +1,119 @@
package com.muyu.customer.business.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.muyu.customer.business.domain.FaultRecord;
import com.muyu.customer.business.domain.req.FaultRecordEditReq;
import com.muyu.customer.business.domain.req.FaultRecordQueryReq;
import com.muyu.customer.business.domain.req.FaultRecordSaveReq;
import com.muyu.customer.business.domain.vo.FaultRecordVo;
import com.muyu.customer.business.service.FaultRecordService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author muyu
* @date 2024-06-20
*/
@Api(tags = "故障记录")
@RestController
@RequestMapping("/faultRecord")
public class FaultRecordController extends BaseController {
@Autowired
private FaultRecordService faultRecordService;
/**
*
*/
@ApiOperation("获取故障记录列表")
@RequiresPermissions("customerBusiness:faultRecord:list")
@GetMapping("/list")
public Result<TableDataInfo<FaultRecord>> list(FaultRecordQueryReq faultRecordQueryReq) {
startPage();
List<FaultRecord> list = faultRecordService.list(FaultRecord.queryBuild(faultRecordQueryReq));
return getDataTable(list);
}
/**
*
*/
@ApiOperation("导出故障记录列表")
@RequiresPermissions("customerBusiness:faultRecord:export")
@Log(title = "故障记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, FaultRecord faultRecord) {
List<FaultRecord> list = faultRecordService.list(faultRecord);
ExcelUtil<FaultRecord> util = new ExcelUtil<FaultRecord>(FaultRecord.class);
util.exportExcel(response, list, "故障记录数据");
}
/**
*
*/
@ApiOperation("获取故障记录详细信息")
@RequiresPermissions("customerBusiness:faultRecord:query")
@GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<FaultRecord> getInfo(@PathVariable("id") Long id) {
return Result.success(faultRecordService.getById(id));
}
/**
*
*/
@RequiresPermissions("customerBusiness:faultRecord:add")
@Log(title = "故障记录", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("新增故障记录")
public Result<String> add(@RequestBody FaultRecordSaveReq faultRecordSaveReq) {
return toAjax(faultRecordService.save(FaultRecord.saveBuild(faultRecordSaveReq)));
}
/**
*
*/
@RequiresPermissions("customerBusiness:faultRecord:edit")
@Log(title = "故障记录", businessType = BusinessType.UPDATE)
@PutMapping("/{id}")
@ApiOperation("修改故障记录")
public Result<String> edit(@PathVariable Long id, @RequestBody FaultRecordEditReq faultRecordEditReq) {
return toAjax(faultRecordService.updateById(FaultRecord.editBuild(id,faultRecordEditReq)));
}
/**
*
*/
@RequiresPermissions("customerBusiness:faultRecord:remove")
@Log(title = "故障记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@ApiOperation("删除故障记录")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result<String> remove(@PathVariable List<Long> ids) {
return toAjax(faultRecordService.removeBatchByIds(ids));
}
@Log(title = "柱状图",businessType = BusinessType.DELETE)
@GetMapping("/countList")
@ApiOperation("柱状图展示")
public Result<List<FaultRecordVo>> countList( ) {
return Result.success(faultRecordService.countList());
}
}

View File

@ -0,0 +1,111 @@
package com.muyu.customer.business.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.muyu.customer.business.domain.Vehicle;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.customer.business.domain.Fence;
import com.muyu.customer.business.domain.req.FenceQueryReq;
import com.muyu.customer.business.domain.req.FenceSaveReq;
import com.muyu.customer.business.domain.req.FenceEditReq;
import com.muyu.customer.business.service.FenceService;
import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author muyu
* @date 2024-05-31
*/
@Api(tags = "电子围栏")
@RestController
@RequestMapping("/fence")
public class FenceController extends BaseController {
@Autowired
private FenceService fenceService;
/**
*
*/
@ApiOperation("获取电子围栏列表")
@RequiresPermissions("customerBusiness:fence:list")
@GetMapping("/list")
public Result<TableDataInfo<Fence>> list(FenceQueryReq fenceQueryReq) {
startPage();
List<Fence> list = fenceService.list(Fence.queryBuild(fenceQueryReq));
return getDataTable(list);
}
/**
*
*/
@ApiOperation("导出电子围栏列表")
@RequiresPermissions("customerBusiness:fence:export")
@Log(title = "电子围栏", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Fence fence) {
List<Fence> list = fenceService.list(fence);
ExcelUtil<Fence> util = new ExcelUtil<Fence>(Fence.class);
util.exportExcel(response, list, "电子围栏数据");
}
/**
*
*/
@ApiOperation("获取电子围栏详细信息")
@RequiresPermissions("customerBusiness:fence:query")
@GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<Fence> getInfo(@PathVariable("id") Long id) {
return Result.success(fenceService.getById(id));
}
/**
*
*/
@RequiresPermissions("customerBusiness:fence:add")
@Log(title = "电子围栏", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("新增电子围栏")
public Result<String> add(@RequestBody FenceSaveReq fenceSaveReq) {
return toAjax(fenceService.save(Fence.saveBuild(fenceSaveReq)));
}
/**
*
*/
@RequiresPermissions("customerBusiness:fence:edit")
@Log(title = "电子围栏", businessType = BusinessType.UPDATE)
@PutMapping("/{id}")
@ApiOperation("修改电子围栏")
public Result<String> edit(@PathVariable Long id, @RequestBody FenceEditReq fenceEditReq) {
return toAjax(fenceService.updateById(Fence.editBuild(id,fenceEditReq)));
}
/**
*
*/
@RequiresPermissions("customerBusiness:fence:remove")
@Log(title = "电子围栏", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@ApiOperation("删除电子围栏")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result<String> remove(@PathVariable List<Long> ids) {
return toAjax(fenceService.removeBatchByIds(ids));
}
// @Scheduled(cron = "*/1 * * * * ?")
@PostMapping("/getConn")
public Result getConn(@RequestBody Vehicle vehicle) {
return fenceService.getConn(vehicle);
}
}

View File

@ -0,0 +1,154 @@
package com.muyu.customer.business.controller;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSON;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.customer.business.domain.IndexConfiguration;
import com.muyu.customer.business.domain.MessageDetail;
import com.muyu.customer.business.domain.Vehicle;
import com.muyu.customer.business.domain.req.IndexConfigurationEditReq;
import com.muyu.customer.business.domain.req.IndexConfigurationQueryReq;
import com.muyu.customer.business.domain.req.IndexConfigurationSaveReq;
import com.muyu.customer.business.mapper.MessageDetailMapper;
import com.muyu.customer.business.mapper.VehicleMapper;
import com.muyu.customer.business.service.IndexConfigurationService;
import com.muyu.customer.business.service.MessageDetailService;
import com.muyu.customer.business.service.VehicleService;
import io.swagger.annotations.*;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Controller
*
* @author muyu
* @date 2024-06-28
*/
@Api(tags = "车辆指标预警配置")
@RestController
@Log4j2
@RequestMapping("/indexConfiguration")
public class IndexConfigurationController extends BaseController {
@Autowired
private IndexConfigurationService indexConfigurationService;
// @Autowired
// private VehicleMapper vehicleMapper;
@Autowired
private MessageDetailMapper messageDetailMapper;
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private StringRedisTemplate redisTemplate;
/**
*
*/
@ApiOperation("获取车辆指标预警配置列表")
@GetMapping("/list")
public Result<TableDataInfo<IndexConfiguration>> list(IndexConfigurationQueryReq indexConfigurationQueryReq) {
startPage();
List<IndexConfiguration> list = indexConfigurationService.list(IndexConfiguration.queryBuild(indexConfigurationQueryReq));
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("customerBusiness:indexConfiguration:list")
@ApiOperation("导出车辆指标预警配置列表")
@Log(title = "车辆指标预警配置", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, IndexConfiguration indexConfiguration) {
List<IndexConfiguration> list = indexConfigurationService.list(indexConfiguration);
ExcelUtil<IndexConfiguration> util = new ExcelUtil<IndexConfiguration>(IndexConfiguration.class);
util.exportExcel(response, list, "车辆指标预警配置数据");
}
/**
*
*/
@ApiOperation("获取车辆指标预警配置详细信息")
@RequiresPermissions("customerBusiness:indexConfiguration:query")
@GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<IndexConfiguration> getInfo(@PathVariable("id") Long id) {
return Result.success(indexConfigurationService.getById(id));
}
/**
*
*/
@RequiresPermissions("customerBusiness:indexConfiguration:add")
@Log(title = "车辆指标预警配置", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("新增车辆指标预警配置")
public Result<String> add(@RequestBody IndexConfigurationSaveReq indexConfigurationSaveReq) {
indexConfigurationSaveReq.setOpportunity(indexConfigurationSaveReq.getIntervalRange()/indexConfigurationSaveReq.getOpportunity());
boolean save = indexConfigurationService.save(IndexConfiguration.saveBuild(indexConfigurationSaveReq));
redis(indexConfigurationSaveReq);
return toAjax(save);
}
/**
*
*/
@RequiresPermissions("customerBusiness:indexConfiguration:edit")
@Log(title = "车辆指标预警配置", businessType = BusinessType.UPDATE)
@PutMapping("/{id}")
@ApiOperation("修改车辆指标预警配置")
public Result<String> edit(@PathVariable Long id, @RequestBody IndexConfigurationEditReq indexConfigurationEditReq) {
indexConfigurationEditReq.setOpportunity(indexConfigurationEditReq.getIntervalRange()/indexConfigurationEditReq.getOpportunity());
boolean update = indexConfigurationService.updateById(IndexConfiguration.editBuild(id, indexConfigurationEditReq));
// redis(indexConfigurationEditReq);
return toAjax(update);
}
/**
*
*/
@RequiresPermissions("customerBusiness:indexConfiguration:remove")
@Log(title = "车辆指标预警配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@ApiOperation("删除车辆指标预警配置")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result<String> remove(@PathVariable List<Long> ids) {
return toAjax(indexConfigurationService.removeBatchByIds(ids));
}
private void redis(IndexConfigurationSaveReq indexConfigurationSaveReq) {
List<IndexConfiguration> list = indexConfigurationService.selectByVin(indexConfigurationSaveReq.getVin());
// list.add(IndexConfiguration.saveBuild(indexConfigurationSaveReq));
// list.stream().distinct();
redisTemplate.opsForHash().put("indexConfiguration", indexConfigurationSaveReq.getVin(), JSON.toJSONString(list));
}
}

View File

@ -0,0 +1,122 @@
package com.muyu.customer.business.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.muyu.customer.business.domain.model.MessageDetailModel;
import com.muyu.customer.business.domain.req.MessageDetailEditReq;
import com.muyu.customer.business.domain.req.MessageDetailQueryReq;
import com.muyu.customer.business.domain.req.MessageDetailSaveReq;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.customer.business.domain.MessageDetail;
import com.muyu.customer.business.service.MessageDetailService;
import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author muyu
* @date 2024-06-28
*/
@Api(tags = "报文详情")
@RestController
@RequestMapping("/detail")
public class MessageDetailController extends BaseController {
@Autowired
private MessageDetailService messageDetailService;
/**
*
*/
@ApiOperation("获取报文详情列表")
@RequiresPermissions("customerBusiness:detail:list")
@GetMapping("/list")
public Result<TableDataInfo<MessageDetail>> list(MessageDetailQueryReq messageDetailQueryReq) {
startPage();
List<MessageDetail> list = messageDetailService.list(MessageDetail.queryBuild(messageDetailQueryReq));
return getDataTable(list);
}
/**
*
*/
@ApiOperation("导出报文详情列表")
@RequiresPermissions("customerBusiness:detail:export")
@Log(title = "报文详情", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, MessageDetail messageDetail) {
List<MessageDetail> list = messageDetailService.list(messageDetail);
ExcelUtil<MessageDetail> util = new ExcelUtil<MessageDetail>(MessageDetail.class);
util.exportExcel(response, list, "报文详情数据");
}
@GetMapping("/selectByVin/{vin}")
public Result<List<MessageDetail>> selectByVin(@PathVariable String vin) {
return Result.success(messageDetailService.selectMessage(vin));
}
/**
*
*/
@ApiOperation("获取报文详情详细信息")
@RequiresPermissions("customerBusiness:detail:query")
@GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<MessageDetail> getInfo(@PathVariable("id") Long id) {
return Result.success(messageDetailService.getById(id));
}
/**
*
*/
@RequiresPermissions("customerBusiness:detail:add")
@Log(title = "报文详情", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("新增报文详情")
public Result<String> add(@RequestBody MessageDetailModel messageDetailModel) {
return messageDetailService.add(messageDetailModel);
}
/**
*
*/
@RequiresPermissions("customerBusiness:detail:edit")
@Log(title = "报文详情", businessType = BusinessType.UPDATE)
@PutMapping("/{id}")
@ApiOperation("修改报文详情")
public Result<String> edit(@PathVariable Long id, @RequestBody MessageDetailEditReq messageDetailEditReq) {
return toAjax(messageDetailService.updateById(MessageDetail.editBuild(id,messageDetailEditReq)));
}
@PostMapping("/updateMessage")
public Result<String> updateMessage(@RequestBody MessageDetailModel messageDetailModel) {
return messageDetailService.updateVehicle(messageDetailModel);
}
/**
*
*/
@RequiresPermissions("customerBusiness:detail:remove")
@Log(title = "报文详情", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@ApiOperation("删除报文详情")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result<String> remove(@PathVariable List<Long> ids) {
return toAjax(messageDetailService.removeBatchByIds(ids));
}
}

View File

@ -1,18 +1,20 @@
package com.muyu.customer.business.controller; package com.muyu.customer.business.controller;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.muyu.common.redis.service.RedisService;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.customer.business.domain.MessageDetail;
import com.muyu.customer.business.domain.model.VehicleModel;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil; import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController; import com.muyu.common.core.web.controller.BaseController;
@ -21,8 +23,6 @@ import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions; import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.customer.business.domain.Vehicle; import com.muyu.customer.business.domain.Vehicle;
import com.muyu.customer.business.domain.req.VehicleQueryReq; import com.muyu.customer.business.domain.req.VehicleQueryReq;
import com.muyu.customer.business.domain.req.VehicleSaveReq;
import com.muyu.customer.business.domain.req.VehicleEditReq;
import com.muyu.customer.business.service.VehicleService; import com.muyu.customer.business.service.VehicleService;
import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.common.core.web.page.TableDataInfo;
@ -38,6 +38,12 @@ import com.muyu.common.core.web.page.TableDataInfo;
public class VehicleController extends BaseController { public class VehicleController extends BaseController {
@Autowired @Autowired
private VehicleService vehicleService; private VehicleService vehicleService;
@Autowired
private HttpServletRequest request;
@Autowired
private StringRedisTemplate redisTemplate;
@Autowired
private RedisService redisService;
/** /**
* *
@ -47,7 +53,23 @@ public class VehicleController extends BaseController {
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<Vehicle>> list(VehicleQueryReq vehicleQueryReq) { public Result<TableDataInfo<Vehicle>> list(VehicleQueryReq vehicleQueryReq) {
startPage(); startPage();
List<Vehicle> list = vehicleService.list(Vehicle.queryBuild(vehicleQueryReq)); List<Vehicle> list = vehicleService.list(Vehicle.queryBuild(vehicleQueryReq));
ExecutorService executor = Executors.newFixedThreadPool(list.size());
list.forEach(vehicle -> {
executor.submit(new Runnable() {
@Override
public void run() {
redisTemplate
.opsForValue()
.set(vehicle.getVin()+"1",
String.valueOf(SecurityUtils.getLoginUser().getSysUser().getEnterpriseId()),
24,
TimeUnit.HOURS);
}
});
});
return getDataTable(list); return getDataTable(list);
} }
@ -71,8 +93,8 @@ public class VehicleController extends BaseController {
@RequiresPermissions("customerBusiness:vehicle:query") @RequiresPermissions("customerBusiness:vehicle:query")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<Vehicle> getInfo(@PathVariable("id") Long id) { public Result<VehicleModel> getInfo(@PathVariable("id") Long id) {
return Result.success(vehicleService.getById(id)); return Result.success(vehicleService.selectById(id));
} }
/** /**
@ -82,8 +104,9 @@ public class VehicleController extends BaseController {
@Log(title = "车辆录入", businessType = BusinessType.INSERT) @Log(title = "车辆录入", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
@ApiOperation("新增车辆录入") @ApiOperation("新增车辆录入")
public Result<String> add(@RequestBody VehicleSaveReq vehicleSaveReq) { public Result add(@RequestBody VehicleModel vehicleModel) {
return toAjax(vehicleService.save(Vehicle.saveBuild(vehicleSaveReq)));
return Result.success(vehicleService.add(vehicleModel));
} }
/** /**
@ -93,8 +116,8 @@ public class VehicleController extends BaseController {
@Log(title = "车辆录入", businessType = BusinessType.UPDATE) @Log(title = "车辆录入", businessType = BusinessType.UPDATE)
@PutMapping("/{id}") @PutMapping("/{id}")
@ApiOperation("修改车辆录入") @ApiOperation("修改车辆录入")
public Result<String> edit(@PathVariable Long id, @RequestBody VehicleEditReq vehicleEditReq) { public Result<String> edit(@PathVariable Long id, @RequestBody VehicleModel vehicleModel) {
return toAjax(vehicleService.updateById(Vehicle.editBuild(id,vehicleEditReq))); return vehicleService.updateVehicle(id, vehicleModel);
} }
/** /**
@ -108,4 +131,23 @@ public class VehicleController extends BaseController {
public Result<String> remove(@PathVariable List<Long> ids) { public Result<String> remove(@PathVariable List<Long> ids) {
return toAjax(vehicleService.removeBatchByIds(ids)); return toAjax(vehicleService.removeBatchByIds(ids));
} }
/**
*
*/
@GetMapping("/MessageList")
public Result<List<MessageDetail>> MessageList() {
return Result.success(vehicleService.MessageList());
}
// @Autowired
// private VehicleMapper vehicleMapper;
//
// @GetMapping("/list/all")
// public Result<List<Vehicle>> findAll () {
// return Result.success(vehicleMapper.selectList(new QueryWrapper<>()));
// }
} }

View File

@ -0,0 +1,39 @@
package com.muyu.customer.business.controller;
import com.alibaba.fastjson2.JSON;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.customer.business.domain.Vehicle;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* VehicleInfoController
*
* @author DeKangLiu
* Date 2024/6/22 20:31
*/
@Log4j2
@RestController
@RequestMapping("/vehicleInfo")
public class VehicleInfoController extends BaseController {
@Autowired
private RedisTemplate<String,String> redisTemplate;
@GetMapping("/list/{vin}")
public Result vehicleInfoAllList(@PathVariable String vin){
if (redisTemplate.hasKey(vin)){
String lastElement = redisTemplate.opsForList().index(vin, -1);
Vehicle vehicleInfo = JSON.parseObject(lastElement, Vehicle.class);
return Result.success(vehicleInfo);
}
return null;
}
}

View File

@ -0,0 +1,14 @@
package com.muyu.customer.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.customer.business.domain.FaultCode;
/**
* Mapper
*
* @author muyu
* @date 2024-06-20
*/
public interface FaultCodeMapper extends BaseMapper<FaultCode> {
}

View File

@ -0,0 +1,22 @@
package com.muyu.customer.business.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.customer.business.domain.FaultRecord;
import com.muyu.customer.business.domain.vo.FaultRecordVo;
/**
* Mapper
*
* @author muyu
* @date 2024-06-20
*/
public interface FaultRecordMapper extends BaseMapper<FaultRecord> {
FaultRecord selectFault(FaultRecord build);
void updateFault(FaultRecord faultRecordOne);
List<FaultRecordVo> countList();
}

View File

@ -0,0 +1,14 @@
package com.muyu.customer.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.customer.business.domain.Fence;
/**
* Mapper
*
* @author muyu
* @date 2024-05-31
*/
public interface FenceMapper extends BaseMapper<Fence> {
}

View File

@ -0,0 +1,20 @@
package com.muyu.customer.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.customer.business.domain.IndexConfiguration;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Mapper
*
* @author chx
* @date 2024-06-28
*/
public interface IndexConfigurationMapper extends BaseMapper<IndexConfiguration> {
List<IndexConfiguration> selectByVin(@Param("vin") String vin);
}

View File

@ -0,0 +1,24 @@
package com.muyu.customer.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.customer.business.domain.MessageDetail;
import com.muyu.customer.business.domain.Vehicle;
import com.muyu.customer.business.domain.model.VehicleMiddle;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Mapper
*
* @author muyu
* @date 2024-06-28
*/
public interface MessageDetailMapper extends BaseMapper<MessageDetail> {
Vehicle selectByVin(@Param("vin") String vin);
List<Integer> selectByVehicleId(@Param("id") Long id);
List<MessageDetail> selectMessage(@Param("list") List<Integer> vehicleMiddleList);
}

View File

@ -2,7 +2,10 @@ package com.muyu.customer.business.mapper;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.customer.business.domain.MessageDetail;
import com.muyu.customer.business.domain.Vehicle; import com.muyu.customer.business.domain.Vehicle;
import com.muyu.customer.business.domain.model.VehicleModel;
import org.apache.ibatis.annotations.Param;
/** /**
* Mapper * Mapper
@ -12,4 +15,21 @@ import com.muyu.customer.business.domain.Vehicle;
*/ */
public interface VehicleMapper extends BaseMapper<Vehicle> { public interface VehicleMapper extends BaseMapper<Vehicle> {
List<MessageDetail> MessageList();
void add(VehicleModel vehicleModel);
void addMiddle(@Param("id") Long id, @Param("integer") Integer integer);
List<Integer> selectMessageList(@Param("id") Long id);
VehicleModel selectId(@Param("id") Long id);
List<MessageDetail> selectMessage(@Param("id") Long id);
int updateVehicle(@Param("id") Long id, @Param("vehicleModel") VehicleModel vehicleModel);
MessageDetail selectDetail(@Param("s") Integer s);
void deleteMiddle(@Param("id") Long id);
} }

View File

@ -0,0 +1,15 @@
package com.muyu.customer.business.saas.contents;
/**
* @author DongZl
* @description:
* @Date 2023-8-1 11:02
*/
public class DatasourceContent {
public final static String DATASOURCE_URL = "jdbc:mysql://{}:{}/vehicle_networking?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
public final static String USER_NAME = "root";
public final static String PASSWORD = "L041120D";
}

View File

@ -0,0 +1,12 @@
package com.muyu.customer.business.saas.contents;
/**
* SaaS SaaSConstant
*
* @author DeKangLiu
* Date 2024/6/4 18:34
*/
public class SaaSConstant {
public final static String SAAS_KEY="enterprise-code";
}

View File

@ -0,0 +1,120 @@
package com.muyu.customer.business.saas.datasource;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fastjson.JSON;
import com.muyu.common.core.utils.SpringUtils;
import com.muyu.common.redis.service.RedisService;
import com.muyu.customer.business.saas.factory.DruidDataSourceFactory;
import com.muyu.customer.business.saas.domain.model.DataSourceInfo;
import com.muyu.customer.business.saas.role.DynamicDataSource;
import com.muyu.net.working.remote.RemoteDatasourceService;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import com.muyu.net.working.domain.DataSource;
import java.io.IOException;
import java.util.*;
/**
* ManyDataSource
*
* @author DeKangLiu
* Date 2024/6/3 20:01
*/
@Component
@Log4j2
@AutoConfigureBefore(RedisService.class)
public class ManyDataSource {
@Autowired
private StringRedisTemplate redisTemplate;
@Autowired
private RemoteDatasourceService remoteDatasourceService;
@Autowired
private RabbitTemplate rabbitTemplate;
@RabbitListener(queuesToDeclare = {@Queue(name = "liu-vehicle-exchange")})
public void smsConfig(String msg, Message message, Channel channel){
//获取消息的ID
String messageId = message.getMessageProperties().getMessageId();
try {
//添加消息id到redis set集合中 添加成功返回1 表示未消费 添加失败返回0 表示已消费
Long count = redisTemplate.opsForSet().add("messageId", messageId);
//添加成功 正常消费信息
if (count == 1) {
log.info("开始消费");
druidData(msg);
//确认消费
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
log.info("消费成功");
}
} catch (Exception e) {
log.info("消费失败,尝试重连");
try {
//回退消息,尝试重连
druidData(msg);
channel.basicReject(message.getMessageProperties().getDeliveryTag(),false);
log.info("消费失败");
} catch (IOException ex) {
//回退失败
log.info("消费异常");
}
}
}
private void druidData(String msg) {
DataSource entInfo= JSON.parseObject(msg, DataSource.class);
log.info("消息为:{}",entInfo);
DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class);
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(entInfo.getEnterpriseCode(), entInfo.getIp(), entInfo.getPort());
DruidDataSource druidDataSource = druidDataSourceFactory.create(dataSourceInfo);
dynamicDataSource.put(dataSourceInfo.getKey(), druidDataSource);
}
@Lazy
private List<DataSource> dataSourceInfoList(){
List<DataSource> databaseNameList = new ArrayList<>(){{
add(DataSource.builder()
.enterpriseCode("liu_44")
.ip("192.168.116.129")
.port(3350)
.build());
}};
List<DataSource> list = remoteDatasourceService.listAll();
System.out.println(list);
databaseNameList.addAll(list);
return databaseNameList;
}
@Bean
@Primary
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
//查企业
Map<Object, Object> dataSourceMap = new HashMap<>();
dataSourceInfoList()
.stream()
.map(entInfo-> DataSourceInfo.hostAndPortBuild(entInfo.getEnterpriseCode(),entInfo.getIp(),entInfo.getPort()))
.forEach(dataSourceInfo -> {
dataSourceMap.put(dataSourceInfo.getKey(), druidDataSourceFactory.create(dataSourceInfo));
});
//设置动态数据源
DynamicDataSource dynamicDataSource = new DynamicDataSource();
// dynamicDataSource.setDefaultTargetDataSource(masterDataSource());
dynamicDataSource.setTargetDataSources(dataSourceMap);
//将数据源信息备份在defineTargetDataSources中
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
return dynamicDataSource;
}
}

View File

@ -0,0 +1,52 @@
package com.muyu.customer.business.saas.domain.model;
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 io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* DataSource
*
* @author DeKangLiu
* Date 2024/6/22 22:56
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName("datasource")
public class DataSource extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(name = "主键", value = "主键")
private Long id;
/** 数据源key */
@Excel(name = "数据源key")
@ApiModelProperty(name = "数据源key", value = "数据源key")
private String enterpriseCode;
/** 数据源端口 */
@Excel(name = "数据源端口")
@ApiModelProperty(name = "数据源端口", value = "数据源端口")
private Integer port;
/** 数据源ip */
@Excel(name = "数据源ip")
@ApiModelProperty(name = "数据源ip", value = "数据源ip")
private String ip;
}

View File

@ -0,0 +1,52 @@
package com.muyu.customer.business.saas.domain.model;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.customer.business.saas.contents.DatasourceContent;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author DongZl
* @description:
* @Date 2023-8-1 11:15
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DataSourceInfo {
/**
*
*/
private String key;
/**
*
*/
private String url;
/**
*
*/
private String userName;
/**
*
*/
private String password;
public static DataSourceInfo hostAndPortBuild(String key,String host, Integer port){
return DataSourceInfo.builder()
.key(key)
.url(StringUtils.format(DatasourceContent.DATASOURCE_URL, host,port))
.password(DatasourceContent.PASSWORD)
.userName(DatasourceContent.USER_NAME)
.build();
}
}

View File

@ -0,0 +1,39 @@
package com.muyu.customer.business.saas.factory;
import com.alibaba.druid.pool.DruidDataSource;
import com.muyu.customer.business.saas.domain.model.DataSourceInfo;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;
import java.sql.SQLException;
/**
* Druid DruidDataSourceFactory
*
* @author DeKangLiu
* Date 2024/6/3 20:12
*/
@Log4j2
@Component
public class DruidDataSourceFactory {
/**
* @Description:
* @Author Dongzl
*/
public DruidDataSource create(DataSourceInfo dataSourceInfo) {
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setUrl(dataSourceInfo.getUrl());
druidDataSource.setUsername(dataSourceInfo.getUserName());
druidDataSource.setPassword(dataSourceInfo.getPassword());
druidDataSource.setBreakAfterAcquireFailure(true);
druidDataSource.setConnectionErrorRetryAttempts(0);
try {
druidDataSource.getConnection(2000);
log.info("{} -> 数据源连接成功", dataSourceInfo.getKey());
return druidDataSource;
} catch (SQLException throwables) {
log.error("数据源 {} 连接失败,用户名:{},密码 {}",dataSourceInfo.getUrl(),dataSourceInfo.getUserName(),dataSourceInfo.getPassword());
return null;
}
}
}

View File

@ -0,0 +1,42 @@
package com.muyu.customer.business.saas.holder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
/**
*
*
* @author Dongzl
*/
@Slf4j
public class DynamicDataSourceHolder {
/**
*
*/
private static final ThreadLocal<String> DYNAMIC_DATASOURCE_KEY = new ThreadLocal<>();
/**
* /线使
*/
public static void setDynamicDataSourceKey(String key){
log.info("数据源切换为:{}",key);
DYNAMIC_DATASOURCE_KEY.set(key);
}
/**
* 使mater
*/
public static String getDynamicDataSourceKey(){
String key = DYNAMIC_DATASOURCE_KEY.get();
Assert.notNull(key, "请携带数据标识");
return key;
}
/**
*
*/
public static void removeDynamicDataSourceKey(){
log.info("移除数据源:{}",DYNAMIC_DATASOURCE_KEY.get());
DYNAMIC_DATASOURCE_KEY.remove();
}
}

View File

@ -0,0 +1,51 @@
package com.muyu.customer.business.saas.role;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.RemoteUserService;
import com.muyu.customer.business.saas.holder.DynamicDataSourceHolder;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
*
*
* @author DeKangLiu
* Date 2024/6/3 20:12
*/
@Aspect
@Component
public class DataSourceAsp {
@Lazy
@Autowired
private RemoteUserService remoteUserService;
@Pointcut("execution(public * com.muyu.customer.business.controller.*Controller.*(..))")
public void pointcut () {
}
/**
*
*/
@Before("pointcut()")
public void beforeMethod() {
Integer enterpriseId = SecurityUtils.getLoginUser().getSysUser().getEnterpriseId();
DynamicDataSourceHolder.setDynamicDataSourceKey("liu_"+enterpriseId);
}
/**
*
*
*
*/
@After("pointcut()")
public void afterMethod() {
DynamicDataSourceHolder.removeDynamicDataSourceKey();
}
}

View File

@ -0,0 +1,52 @@
package com.muyu.customer.business.saas.role;
import com.alibaba.druid.pool.DruidDataSource;
import com.muyu.customer.business.saas.holder.DynamicDataSourceHolder;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import java.util.Map;
/**
*
* AddDefineDataSourceaddDefineDynamicDataSourcetargetdatasourcesmapmaptargetdatasourcesmap
* 使@DataSource(value = "数据源名称")DynamicDataSourceContextHolder.setContextKey("数据源名称")
* @author Dongzl
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DynamicDataSource extends AbstractRoutingDataSource {
//备份所有数据源信息,备份的是个 指针!!!
private Map<Object, Object> defineTargetDataSources;
/**
*
* @param key
* @return true false
*/
public boolean hashKye(String key){
return defineTargetDataSources.containsKey(key);
}
/**
*
* @param key
* @param value
*/
public void put(String key, DruidDataSource value){
defineTargetDataSources.put(key,value);
this.afterPropertiesSet();
}
/**
* 线使
*/
@Override
protected Object determineCurrentLookupKey() {
return DynamicDataSourceHolder.getDynamicDataSourceKey();
}
}

View File

@ -0,0 +1,22 @@
package com.muyu.customer.business.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.customer.business.domain.FaultCode;
/**
* Service
*
* @author muyu
* @date 2024-06-20
*/
public interface FaultCodeService extends IService<FaultCode> {
/**
*
*
* @param faultCode
* @return
*/
public List<FaultCode> list(FaultCode faultCode);
}

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