diff --git a/fastbee-admin/src/main/java/com/fastbee/web/controller/common/CommonController.java b/fastbee-admin/src/main/java/com/fastbee/web/controller/common/CommonController.java index e2210c8f..02ec14fc 100644 --- a/fastbee-admin/src/main/java/com/fastbee/web/controller/common/CommonController.java +++ b/fastbee-admin/src/main/java/com/fastbee/web/controller/common/CommonController.java @@ -40,12 +40,10 @@ import java.util.List; @RequestMapping("/common") public class CommonController { private static final Logger log = LoggerFactory.getLogger(CommonController.class); - + private static final String FILE_DELIMETER = ","; @Autowired private ServerConfig serverConfig; - private static final String FILE_DELIMETER = ","; - /** * 通用下载请求 * diff --git a/fastbee-admin/src/main/java/com/fastbee/web/controller/monitor/CacheController.java b/fastbee-admin/src/main/java/com/fastbee/web/controller/monitor/CacheController.java index 7856ca18..16a8d700 100644 --- a/fastbee-admin/src/main/java/com/fastbee/web/controller/monitor/CacheController.java +++ b/fastbee-admin/src/main/java/com/fastbee/web/controller/monitor/CacheController.java @@ -23,11 +23,10 @@ import java.util.*; @RestController @RequestMapping("/monitor/cache") public class CacheController { + private final static List caches = new ArrayList(); @Autowired private RedisTemplate redisTemplate; - private final static List caches = new ArrayList(); - { caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息")); caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "配置信息")); diff --git a/fastbee-common/src/main/java/com/fastbee/common/annotation/Anonymous.java b/fastbee-common/src/main/java/com/fastbee/common/annotation/Anonymous.java index 78cd1f42..90cc7d67 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/annotation/Anonymous.java +++ b/fastbee-common/src/main/java/com/fastbee/common/annotation/Anonymous.java @@ -4,12 +4,11 @@ import java.lang.annotation.*; /** * 匿名访问不鉴权注解 - * + * * @author ruoyi */ -@Target({ ElementType.METHOD, ElementType.TYPE }) +@Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented -public @interface Anonymous -{ +public @interface Anonymous { } diff --git a/fastbee-common/src/main/java/com/fastbee/common/annotation/DataScope.java b/fastbee-common/src/main/java/com/fastbee/common/annotation/DataScope.java index 675c4636..1166e68f 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/annotation/DataScope.java +++ b/fastbee-common/src/main/java/com/fastbee/common/annotation/DataScope.java @@ -1,10 +1,6 @@ package com.fastbee.common.annotation; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** * 数据权限过滤注解 @@ -18,15 +14,15 @@ public @interface DataScope { /** * 部门表的别名 */ - public String deptAlias() default ""; + String deptAlias() default ""; /** * 用户表的别名 */ - public String userAlias() default ""; + String userAlias() default ""; /** * 权限字符(用于多个角色匹配符合要求的权限)默认根据权限注解@ss获取,多个权限用逗号分隔开来 */ - public String permission() default ""; + String permission() default ""; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/annotation/DataSource.java b/fastbee-common/src/main/java/com/fastbee/common/annotation/DataSource.java index 02d4531b..4253ff56 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/annotation/DataSource.java +++ b/fastbee-common/src/main/java/com/fastbee/common/annotation/DataSource.java @@ -1,28 +1,23 @@ package com.fastbee.common.annotation; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; import com.fastbee.common.enums.DataSourceType; +import java.lang.annotation.*; + /** * 自定义多数据源切换注解 - * + *

* 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准 * * @author ruoyi */ -@Target({ ElementType.METHOD, ElementType.TYPE }) +@Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited -public @interface DataSource -{ +public @interface DataSource { /** * 切换数据源名称 */ - public DataSourceType value() default DataSourceType.master; + DataSourceType value() default DataSourceType.master; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/annotation/DictFormat.java b/fastbee-common/src/main/java/com/fastbee/common/annotation/DictFormat.java index 5536474f..152e2092 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/annotation/DictFormat.java +++ b/fastbee-common/src/main/java/com/fastbee/common/annotation/DictFormat.java @@ -4,7 +4,7 @@ import java.lang.annotation.*; /** * 字典格式化 - * + *

* 实现将字典数据的值,格式化成字典数据的标签 */ @Target({ElementType.FIELD}) diff --git a/fastbee-common/src/main/java/com/fastbee/common/annotation/Excel.java b/fastbee-common/src/main/java/com/fastbee/common/annotation/Excel.java index d184c1e9..827bb728 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/annotation/Excel.java +++ b/fastbee-common/src/main/java/com/fastbee/common/annotation/Excel.java @@ -12,176 +12,169 @@ import java.math.BigDecimal; /** * 自定义导出Excel数据注解 - * + * * @author ruoyi */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) -public @interface Excel -{ +public @interface Excel { /** * 导出时在excel中排序 */ - public int sort() default Integer.MAX_VALUE; + int sort() default Integer.MAX_VALUE; /** * 导出到Excel中的名字. */ - public String name() default ""; + String name() default ""; /** * 日期格式, 如: yyyy-MM-dd */ - public String dateFormat() default ""; + String dateFormat() default ""; /** * 如果是字典类型,请设置字典的type值 (如: sys_user_sex) */ - public String dictType() default ""; + String dictType() default ""; /** * 读取内容转表达式 (如: 0=男,1=女,2=未知) */ - public String readConverterExp() default ""; + String readConverterExp() default ""; /** * 分隔符,读取字符串组内容 */ - public String separator() default ","; + String separator() default ","; /** * BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化) */ - public int scale() default -1; + int scale() default -1; /** * BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN */ - public int roundingMode() default BigDecimal.ROUND_HALF_EVEN; + int roundingMode() default BigDecimal.ROUND_HALF_EVEN; /** * 导出时在excel中每个列的高度 单位为字符 */ - public double height() default 14; + double height() default 14; /** * 导出时在excel中每个列的宽 单位为字符 */ - public double width() default 16; + double width() default 16; /** * 文字后缀,如% 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集合单元格) */ - 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字符串 2图片) */ - 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 {}; /** * 字段类型(0:导出导入;1:仅导出;2:仅导入) */ Type type() default Type.ALL; - public enum Type - { + enum Type { ALL(0), EXPORT(1), IMPORT(2); private final int value; - Type(int value) - { + Type(int value) { this.value = value; } - public int value() - { + public int value() { return this.value; } } - public enum ColumnType - { + enum ColumnType { NUMERIC(0), STRING(1), IMAGE(2); private final int value; - ColumnType(int value) - { + ColumnType(int value) { this.value = value; } - public int value() - { + public int value() { return this.value; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/annotation/Excels.java b/fastbee-common/src/main/java/com/fastbee/common/annotation/Excels.java index b258cd0d..32cd8278 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/annotation/Excels.java +++ b/fastbee-common/src/main/java/com/fastbee/common/annotation/Excels.java @@ -7,12 +7,11 @@ import java.lang.annotation.Target; /** * Excel注解集 - * + * * @author ruoyi */ @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) -public @interface Excels -{ - public Excel[] value(); +public @interface Excels { + Excel[] value(); } diff --git a/fastbee-common/src/main/java/com/fastbee/common/annotation/Log.java b/fastbee-common/src/main/java/com/fastbee/common/annotation/Log.java index 622cd16c..cc12cff3 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/annotation/Log.java +++ b/fastbee-common/src/main/java/com/fastbee/common/annotation/Log.java @@ -7,37 +7,35 @@ import java.lang.annotation.*; /** * 自定义操作日志记录注解 - * - * @author ruoyi * + * @author ruoyi */ -@Target({ ElementType.PARAMETER, ElementType.METHOD }) +@Target({ElementType.PARAMETER, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Documented -public @interface Log -{ +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; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/annotation/RateLimiter.java b/fastbee-common/src/main/java/com/fastbee/common/annotation/RateLimiter.java index a41daf17..3cbae90e 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/annotation/RateLimiter.java +++ b/fastbee-common/src/main/java/com/fastbee/common/annotation/RateLimiter.java @@ -1,40 +1,36 @@ package com.fastbee.common.annotation; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; import com.fastbee.common.constant.CacheConstants; import com.fastbee.common.enums.LimitType; +import java.lang.annotation.*; + /** * 限流注解 - * + * * @author ruoyi */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @Documented -public @interface RateLimiter -{ +public @interface RateLimiter { /** * 限流key */ - public String key() default CacheConstants.RATE_LIMIT_KEY; + String key() default CacheConstants.RATE_LIMIT_KEY; /** * 限流时间,单位秒 */ - public int time() default 60; + int time() default 60; /** * 限流次数 */ - public int count() default 100; + int count() default 100; /** * 限流类型 */ - public LimitType limitType() default LimitType.DEFAULT; + LimitType limitType() default LimitType.DEFAULT; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/annotation/RepeatSubmit.java b/fastbee-common/src/main/java/com/fastbee/common/annotation/RepeatSubmit.java index 1785e572..f2edf026 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/annotation/RepeatSubmit.java +++ b/fastbee-common/src/main/java/com/fastbee/common/annotation/RepeatSubmit.java @@ -1,31 +1,24 @@ package com.fastbee.common.annotation; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** * 自定义注解防止表单重复提交 - * - * @author ruoyi * + * @author ruoyi */ @Inherited @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @Documented -public @interface RepeatSubmit -{ +public @interface RepeatSubmit { /** * 间隔时间(ms),小于此时间视为重复提交 */ - public int interval() default 5000; + int interval() default 5000; /** * 提示消息 */ - public String message() default "不允许重复提交,请稍候再试"; + String message() default "不允许重复提交,请稍候再试"; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/annotation/SysProtocol.java b/fastbee-common/src/main/java/com/fastbee/common/annotation/SysProtocol.java index 19d4a71d..f8f73057 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/annotation/SysProtocol.java +++ b/fastbee-common/src/main/java/com/fastbee/common/annotation/SysProtocol.java @@ -4,6 +4,7 @@ import java.lang.annotation.*; /** * 表示系统内部协议解析器 + * * @author gsb * @date 2022/10/24 10:33 */ @@ -14,8 +15,10 @@ public @interface SysProtocol { /*协议名*/ String name() default ""; + /*协议编码*/ String protocolCode() default ""; + //协议描述 String description() default ""; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/config/DeviceTask.java b/fastbee-common/src/main/java/com/fastbee/common/config/DeviceTask.java index 718582ab..a9fe5c20 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/config/DeviceTask.java +++ b/fastbee-common/src/main/java/com/fastbee/common/config/DeviceTask.java @@ -13,6 +13,7 @@ import java.util.concurrent.ThreadPoolExecutor; /** * 设备报文处理线程池 + * * @author bill */ @Configuration @@ -27,12 +28,12 @@ public class DeviceTask { private int queueCapacity; - private int keepAlive; + private int keepAlive; /*设备状态池*/ @Bean(FastBeeConstant.TASK.DEVICE_STATUS_TASK) public Executor deviceStatusTaskExecutor() { - return builder(FastBeeConstant.TASK.DEVICE_STATUS_TASK); + return builder(FastBeeConstant.TASK.DEVICE_STATUS_TASK); } /*平台自动获取线程池(例如定时获取设备信息)*/ @@ -66,33 +67,33 @@ public class DeviceTask { } @Bean(FastBeeConstant.TASK.MESSAGE_CONSUME_TASK_PUB) - public Executor messageConsumePubTaskExecutor(){ + public Executor messageConsumePubTaskExecutor() { return builder(FastBeeConstant.TASK.MESSAGE_CONSUME_TASK_PUB); } @Bean(FastBeeConstant.TASK.MESSAGE_CONSUME_TASK_FETCH) - public Executor messageConsumeFetchTaskExecutor(){ + public Executor messageConsumeFetchTaskExecutor() { return builder(FastBeeConstant.TASK.MESSAGE_CONSUME_TASK_FETCH); } @Bean(FastBeeConstant.TASK.DELAY_UPGRADE_TASK) - public Executor delayedTaskExecutor(){ + public Executor delayedTaskExecutor() { return builder(FastBeeConstant.TASK.DELAY_UPGRADE_TASK); } /*设备其他消息处理*/ @Bean(FastBeeConstant.TASK.DEVICE_OTHER_TASK) - public Executor deviceOtherTaskExecutor(){ + public Executor deviceOtherTaskExecutor() { return builder(FastBeeConstant.TASK.DEVICE_OTHER_TASK); } @Bean(FastBeeConstant.TASK.DEVICE_TEST_TASK) - public Executor deviceTestTaskExecutor(){ + public Executor deviceTestTaskExecutor() { return builder(FastBeeConstant.TASK.DEVICE_TEST_TASK); } /*组装线程池*/ - private ThreadPoolTaskExecutor builder(String threadNamePrefix){ + private ThreadPoolTaskExecutor builder(String threadNamePrefix) { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(coreSize); executor.setMaxPoolSize(maxSize); diff --git a/fastbee-common/src/main/java/com/fastbee/common/config/RuoYiConfig.java b/fastbee-common/src/main/java/com/fastbee/common/config/RuoYiConfig.java index f8e1cb77..a3c24622 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/config/RuoYiConfig.java +++ b/fastbee-common/src/main/java/com/fastbee/common/config/RuoYiConfig.java @@ -5,91 +5,54 @@ import org.springframework.stereotype.Component; /** * 读取项目相关配置 - * + * * @author ruoyi */ @Component @ConfigurationProperties(prefix = "fastbee") -public class RuoYiConfig -{ - /** 项目名称 */ +public class RuoYiConfig { + /** + * 上传路径 + */ + private static String profile; + /** + * 获取地址开关 + */ + private static boolean addressEnabled; + /** + * 验证码类型 + */ + private static String captchaType; + /** + * 项目名称 + */ private String name; - - /** 版本 */ + /** + * 版本 + */ private String version; - - /** 版权年份 */ + /** + * 版权年份 + */ private String copyrightYear; - - /** 实例演示开关 */ + /** + * 实例演示开关 + */ private boolean demoEnabled; - /** 上传路径 */ - private static String profile; - - /** 获取地址开关 */ - private static boolean addressEnabled; - - /** 验证码类型 */ - private static String captchaType; - - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - public String getVersion() - { - return version; - } - - public void setVersion(String version) - { - this.version = version; - } - - public String getCopyrightYear() - { - return copyrightYear; - } - - public void setCopyrightYear(String copyrightYear) - { - this.copyrightYear = copyrightYear; - } - - public boolean isDemoEnabled() - { - return demoEnabled; - } - - public void setDemoEnabled(boolean demoEnabled) - { - this.demoEnabled = demoEnabled; - } - - public static String getProfile() - { + public static String getProfile() { return profile; } - public void setProfile(String profile) - { + public void setProfile(String profile) { RuoYiConfig.profile = profile; } - public static boolean isAddressEnabled() - { + public static boolean isAddressEnabled() { return addressEnabled; } - public void setAddressEnabled(boolean addressEnabled) - { + public void setAddressEnabled(boolean addressEnabled) { RuoYiConfig.addressEnabled = addressEnabled; } @@ -104,32 +67,60 @@ public class RuoYiConfig /** * 获取导入上传路径 */ - public static String getImportPath() - { + public static String getImportPath() { return getProfile() + "/import"; } /** * 获取头像上传路径 */ - public static String getAvatarPath() - { + public static String getAvatarPath() { return getProfile() + "/avatar"; } /** * 获取下载路径 */ - public static String getDownloadPath() - { + public static String getDownloadPath() { return getProfile() + "/download/"; } /** * 获取上传路径 */ - public static String getUploadPath() - { + public static String getUploadPath() { return getProfile() + "/upload"; } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getCopyrightYear() { + return copyrightYear; + } + + public void setCopyrightYear(String copyrightYear) { + this.copyrightYear = copyrightYear; + } + + public boolean isDemoEnabled() { + return demoEnabled; + } + + public void setDemoEnabled(boolean demoEnabled) { + this.demoEnabled = demoEnabled; + } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/constant/CacheConstants.java b/fastbee-common/src/main/java/com/fastbee/common/constant/CacheConstants.java index 922e0efb..cd9717aa 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/constant/CacheConstants.java +++ b/fastbee-common/src/main/java/com/fastbee/common/constant/CacheConstants.java @@ -5,8 +5,7 @@ package com.fastbee.common.constant; * * @author ruoyi */ -public class CacheConstants -{ +public class CacheConstants { /** * 登录用户 redis key */ @@ -67,6 +66,8 @@ public class CacheConstants */ public static final String REGISTER_SMS_CAPTCHA_PHONE = "register_sms_captcha_phone:"; - /**设备OTA升级实时数据*/ + /** + * 设备OTA升级实时数据 + */ public static final String DEVICE_OTA_DATA = "device:ota:"; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/constant/Constants.java b/fastbee-common/src/main/java/com/fastbee/common/constant/Constants.java index fbea9580..07fd3f46 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/constant/Constants.java +++ b/fastbee-common/src/main/java/com/fastbee/common/constant/Constants.java @@ -7,8 +7,7 @@ import io.jsonwebtoken.Claims; * * @author ruoyi */ -public class Constants -{ +public class Constants { /** * UTF-8 字符集 */ @@ -132,13 +131,13 @@ public class Constants /** * 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加) */ - public static final String[] JOB_WHITELIST_STR = { "com.fastbee" }; + public static final String[] JOB_WHITELIST_STR = {"com.fastbee"}; /** * 定时任务违规的字符 */ - public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml", - "org.springframework", "org.apache", "com.fastbee.common.utils.file", "com.fastbee.common.config" }; + public static final String[] JOB_ERROR_STR = {"java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml", + "org.springframework", "org.apache", "com.fastbee.common.utils.file", "com.fastbee.common.config"}; /** * 语言类型 diff --git a/fastbee-common/src/main/java/com/fastbee/common/constant/GenConstants.java b/fastbee-common/src/main/java/com/fastbee/common/constant/GenConstants.java index 028d3a1c..0b28110f 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/constant/GenConstants.java +++ b/fastbee-common/src/main/java/com/fastbee/common/constant/GenConstants.java @@ -2,116 +2,185 @@ package com.fastbee.common.constant; /** * 代码生成通用常量 - * + * * @author ruoyi */ -public class GenConstants -{ - /** 单表(增删改查) */ +public class GenConstants { + /** + * 单表(增删改查) + */ public static final String TPL_CRUD = "crud"; - /** 树表(增删改查) */ + /** + * 树表(增删改查) + */ public static final String TPL_TREE = "tree"; - /** 主子表(增删改查) */ + /** + * 主子表(增删改查) + */ public static final String TPL_SUB = "sub"; - /** 树编码字段 */ + /** + * 树编码字段 + */ public static final String TREE_CODE = "treeCode"; - /** 树父编码字段 */ + /** + * 树父编码字段 + */ public static final String TREE_PARENT_CODE = "treeParentCode"; - /** 树名称字段 */ + /** + * 树名称字段 + */ public static final String TREE_NAME = "treeName"; - /** 上级菜单ID字段 */ + /** + * 上级菜单ID字段 + */ public static final String PARENT_MENU_ID = "parentMenuId"; - /** 上级菜单名称字段 */ + /** + * 上级菜单名称字段 + */ public static final String PARENT_MENU_NAME = "parentMenuName"; - /** 数据库字符串类型 */ - public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" }; + /** + * 数据库字符串类型 + */ + public static final String[] COLUMNTYPE_STR = {"char", "varchar", "nvarchar", "varchar2"}; - /** 数据库文本类型 */ - public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" }; + /** + * 数据库文本类型 + */ + public static final String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext"}; - /** 数据库时间类型 */ - public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" }; + /** + * 数据库时间类型 + */ + public static final String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp"}; - /** 数据库数字类型 */ - public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer", - "bit", "bigint", "float", "double", "decimal" }; + /** + * 数据库数字类型 + */ + public static final String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer", + "bit", "bigint", "float", "double", "decimal"}; - /** 页面不需要编辑字段 */ - public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" }; + /** + * 页面不需要编辑字段 + */ + public static final String[] COLUMNNAME_NOT_EDIT = {"id", "create_by", "create_time", "del_flag"}; - /** 页面不需要显示的列表字段 */ - public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by", - "update_time" }; + /** + * 页面不需要显示的列表字段 + */ + public static final String[] COLUMNNAME_NOT_LIST = {"id", "create_by", "create_time", "del_flag", "update_by", + "update_time"}; - /** 页面不需要查询字段 */ - public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by", - "update_time", "remark" }; + /** + * 页面不需要查询字段 + */ + public static final String[] COLUMNNAME_NOT_QUERY = {"id", "create_by", "create_time", "del_flag", "update_by", + "update_time", "remark"}; - /** Entity基类字段 */ - public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" }; + /** + * Entity基类字段 + */ + public static final String[] BASE_ENTITY = {"createBy", "createTime", "updateBy", "updateTime", "remark"}; - /** Tree基类字段 */ - public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" }; + /** + * Tree基类字段 + */ + public static final String[] TREE_ENTITY = {"parentName", "parentId", "orderNum", "ancestors", "children"}; - /** 文本框 */ + /** + * 文本框 + */ public static final String HTML_INPUT = "input"; - /** 文本域 */ + /** + * 文本域 + */ public static final String HTML_TEXTAREA = "textarea"; - /** 下拉框 */ + /** + * 下拉框 + */ public static final String HTML_SELECT = "select"; - /** 单选框 */ + /** + * 单选框 + */ public static final String HTML_RADIO = "radio"; - /** 复选框 */ + /** + * 复选框 + */ public static final String HTML_CHECKBOX = "checkbox"; - /** 日期控件 */ + /** + * 日期控件 + */ public static final String HTML_DATETIME = "datetime"; - /** 图片上传控件 */ + /** + * 图片上传控件 + */ public static final String HTML_IMAGE_UPLOAD = "imageUpload"; - /** 文件上传控件 */ + /** + * 文件上传控件 + */ public static final String HTML_FILE_UPLOAD = "fileUpload"; - /** 富文本控件 */ + /** + * 富文本控件 + */ public static final String HTML_EDITOR = "editor"; - /** 字符串类型 */ + /** + * 字符串类型 + */ public static final String TYPE_STRING = "String"; - /** 整型 */ + /** + * 整型 + */ public static final String TYPE_INTEGER = "Integer"; - /** 长整型 */ + /** + * 长整型 + */ public static final String TYPE_LONG = "Long"; - /** 浮点型 */ + /** + * 浮点型 + */ public static final String TYPE_DOUBLE = "Double"; - /** 高精度计算类型 */ + /** + * 高精度计算类型 + */ public static final String TYPE_BIGDECIMAL = "BigDecimal"; - /** 时间类型 */ + /** + * 时间类型 + */ public static final String TYPE_DATE = "Date"; - /** 模糊查询 */ + /** + * 模糊查询 + */ public static final String QUERY_LIKE = "LIKE"; - /** 相等查询 */ + /** + * 相等查询 + */ public static final String QUERY_EQ = "EQ"; - /** 需要 */ + /** + * 需要 + */ public static final String REQUIRE = "1"; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/constant/HttpStatus.java b/fastbee-common/src/main/java/com/fastbee/common/constant/HttpStatus.java index e54d8790..4dced143 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/constant/HttpStatus.java +++ b/fastbee-common/src/main/java/com/fastbee/common/constant/HttpStatus.java @@ -5,8 +5,7 @@ package com.fastbee.common.constant; * * @author ruoyi */ -public class HttpStatus -{ +public class HttpStatus { /** * 操作成功 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/constant/MagicValueConstants.java b/fastbee-common/src/main/java/com/fastbee/common/constant/MagicValueConstants.java index a810c6e2..f051772f 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/constant/MagicValueConstants.java +++ b/fastbee-common/src/main/java/com/fastbee/common/constant/MagicValueConstants.java @@ -5,8 +5,7 @@ package com.fastbee.common.constant; * * @author ruoyi */ -public class MagicValueConstants -{ +public class MagicValueConstants { /** * 3600 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/constant/ProductAuthConstant.java b/fastbee-common/src/main/java/com/fastbee/common/constant/ProductAuthConstant.java index fa487e44..b6ac659d 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/constant/ProductAuthConstant.java +++ b/fastbee-common/src/main/java/com/fastbee/common/constant/ProductAuthConstant.java @@ -1,7 +1,6 @@ package com.fastbee.common.constant; /** - * * @author fastb * @date 2023-08-03 10:20 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/constant/ScheduleConstants.java b/fastbee-common/src/main/java/com/fastbee/common/constant/ScheduleConstants.java index 62d07f01..8d524fc1 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/constant/ScheduleConstants.java +++ b/fastbee-common/src/main/java/com/fastbee/common/constant/ScheduleConstants.java @@ -2,30 +2,38 @@ package com.fastbee.common.constant; /** * 任务调度通用常量 - * + * * @author ruoyi */ -public class ScheduleConstants -{ +public class ScheduleConstants { public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME"; - /** 执行目标key */ + /** + * 执行目标key + */ public static final String TASK_PROPERTIES = "TASK_PROPERTIES"; - /** 默认 */ + /** + * 默认 + */ public static final String MISFIRE_DEFAULT = "0"; - /** 立即触发执行 */ + /** + * 立即触发执行 + */ public static final String MISFIRE_IGNORE_MISFIRES = "1"; - /** 触发一次执行 */ + /** + * 触发一次执行 + */ public static final String MISFIRE_FIRE_AND_PROCEED = "2"; - /** 不触发立即执行 */ + /** + * 不触发立即执行 + */ public static final String MISFIRE_DO_NOTHING = "3"; - public enum Status - { + public enum Status { /** * 正常 */ @@ -35,15 +43,13 @@ public class ScheduleConstants */ PAUSE("1"); - private String value; + private final String value; - private Status(String value) - { + Status(String value) { this.value = value; } - public String getValue() - { + public String getValue() { return value; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/constant/UserConstants.java b/fastbee-common/src/main/java/com/fastbee/common/constant/UserConstants.java index ad6f4a3d..8540c5f2 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/constant/UserConstants.java +++ b/fastbee-common/src/main/java/com/fastbee/common/constant/UserConstants.java @@ -2,65 +2,98 @@ package com.fastbee.common.constant; /** * 用户常量信息 - * + * * @author ruoyi */ -public class UserConstants -{ +public class UserConstants { /** * 平台内系统用户的唯一标志 */ public static final String SYS_USER = "SYS_USER"; - /** 正常状态 */ + /** + * 正常状态 + */ public static final String NORMAL = "0"; - /** 异常状态 */ + /** + * 异常状态 + */ public static final String EXCEPTION = "1"; - /** 用户封禁状态 */ + /** + * 用户封禁状态 + */ public static final String USER_DISABLE = "1"; - /** 角色封禁状态 */ + /** + * 角色封禁状态 + */ public static final String ROLE_DISABLE = "1"; - /** 部门正常状态 */ + /** + * 部门正常状态 + */ public static final String DEPT_NORMAL = "0"; - /** 部门停用状态 */ + /** + * 部门停用状态 + */ public static final String DEPT_DISABLE = "1"; - /** 字典正常状态 */ + /** + * 字典正常状态 + */ public static final String DICT_NORMAL = "0"; - /** 是否为系统默认(是) */ + /** + * 是否为系统默认(是) + */ public static final String YES = "Y"; - /** 是否菜单外链(是) */ + /** + * 是否菜单外链(是) + */ public static final String YES_FRAME = "0"; - /** 是否菜单外链(否) */ + /** + * 是否菜单外链(否) + */ public static final String NO_FRAME = "1"; - /** 菜单类型(目录) */ + /** + * 菜单类型(目录) + */ public static final String TYPE_DIR = "M"; - /** 菜单类型(菜单) */ + /** + * 菜单类型(菜单) + */ public static final String TYPE_MENU = "C"; - /** 菜单类型(按钮) */ + /** + * 菜单类型(按钮) + */ public static final String TYPE_BUTTON = "F"; - /** Layout组件标识 */ + /** + * Layout组件标识 + */ public final static String LAYOUT = "Layout"; - - /** ParentView组件标识 */ + + /** + * ParentView组件标识 + */ public final static String PARENT_VIEW = "ParentView"; - /** InnerLink组件标识 */ + /** + * InnerLink组件标识 + */ public final static String INNER_LINK = "InnerLink"; - /** 校验返回结果码 */ + /** + * 校验返回结果码 + */ public final static String UNIQUE = "0"; public final static String NOT_UNIQUE = "1"; diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/controller/BaseController.java b/fastbee-common/src/main/java/com/fastbee/common/core/controller/BaseController.java index 6414a030..f7523c22 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/controller/BaseController.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/controller/BaseController.java @@ -85,8 +85,7 @@ public class BaseController { return rspData; } - protected TableDataInfo getDataTable(List list, Long total) - { + protected TableDataInfo getDataTable(List list, Long total) { TableDataInfo rspData = new TableDataInfo(); rspData.setCode(HttpStatus.SUCCESS); rspData.setMsg("查询成功"); diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/AjaxResult.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/AjaxResult.java index e9dc93ef..c5e32515 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/AjaxResult.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/AjaxResult.java @@ -7,54 +7,52 @@ import java.util.HashMap; /** * 操作消息提醒 - * + * * @author ruoyi */ -public class AjaxResult extends HashMap -{ - private static final long serialVersionUID = 1L; - - /** 状态码 */ +public class AjaxResult extends HashMap { + /** + * 状态码 + */ public static final String CODE_TAG = "code"; - - /** 返回内容 */ + /** + * 返回内容 + */ public static final String MSG_TAG = "msg"; - - /** 数据对象 */ + /** + * 数据对象 + */ public static final String DATA_TAG = "data"; + private static final long serialVersionUID = 1L; /** * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 */ - public AjaxResult() - { + public AjaxResult() { } /** * 初始化一个新创建的 AjaxResult 对象 - * + * * @param code 状态码 - * @param msg 返回内容 + * @param msg 返回内容 */ - public AjaxResult(int code, String msg) - { + public AjaxResult(int code, String msg) { super.put(CODE_TAG, code); super.put(MSG_TAG, msg); } /** * 初始化一个新创建的 AjaxResult 对象 - * + * * @param code 状态码 - * @param msg 返回内容 + * @param msg 返回内容 * @param data 数据对象 */ - public AjaxResult(int code, String msg, Object data) - { + public AjaxResult(int code, String msg, Object data) { super.put(CODE_TAG, code); super.put(MSG_TAG, msg); - if (StringUtils.isNotNull(data)) - { + if (StringUtils.isNotNull(data)) { super.put(DATA_TAG, data); } } @@ -64,37 +62,33 @@ public class AjaxResult extends HashMap * 初始化一个新创建的 AjaxResult 对象 * * @param code 状态码 - * @param msg 返回内容 + * @param msg 返回内容 * @param data 数据对象 */ - public AjaxResult(int code, String msg, Object data,int total) - { + public AjaxResult(int code, String msg, Object data, int total) { super.put(CODE_TAG, code); super.put(MSG_TAG, msg); - if (StringUtils.isNotNull(data)) - { + if (StringUtils.isNotNull(data)) { super.put(DATA_TAG, data); } - super.put("total",total); + super.put("total", total); } /** * 返回成功消息 - * + * * @return 成功消息 */ - public static AjaxResult success() - { + public static AjaxResult success() { return AjaxResult.success("操作成功"); } /** * 返回成功数据 - * + * * @return 成功消息 */ - public static AjaxResult success(Object data) - { + public static AjaxResult success(Object data) { return AjaxResult.success("操作成功", data); } @@ -103,31 +97,28 @@ public class AjaxResult extends HashMap * * @return 成功消息 */ - public static AjaxResult success(Object data,int total) - { - return new AjaxResult(HttpStatus.SUCCESS, "操作成功", data,total); + public static AjaxResult success(Object data, int total) { + return new AjaxResult(HttpStatus.SUCCESS, "操作成功", data, total); } /** * 返回成功消息 - * + * * @param msg 返回内容 * @return 成功消息 */ - public static AjaxResult success(String msg) - { + public static AjaxResult success(String msg) { return AjaxResult.success(msg, null); } /** * 返回成功消息 - * - * @param msg 返回内容 + * + * @param msg 返回内容 * @param data 数据对象 * @return 成功消息 */ - public static AjaxResult success(String msg, Object data) - { + public static AjaxResult success(String msg, Object data) { return new AjaxResult(HttpStatus.SUCCESS, msg, data); } @@ -137,78 +128,71 @@ public class AjaxResult extends HashMap * @param msg 返回内容 * @return 警告消息 */ - public static AjaxResult warn(String msg) - { + public static AjaxResult warn(String msg) { return AjaxResult.warn(msg, null); } /** * 返回警告消息 * - * @param msg 返回内容 + * @param msg 返回内容 * @param data 数据对象 * @return 警告消息 */ - public static AjaxResult warn(String msg, Object data) - { + public static AjaxResult warn(String msg, Object data) { return new AjaxResult(HttpStatus.WARN, msg, data); } /** * 返回错误消息 - * + * * @return 错误消息 */ - public static AjaxResult error() - { + public static AjaxResult error() { return AjaxResult.error("操作失败"); } /** * 返回错误消息 - * + * * @param msg 返回内容 * @return 错误消息 */ - public static AjaxResult error(String msg) - { + public static AjaxResult error(String msg) { return AjaxResult.error(msg, null); } /** * 返回错误消息 - * - * @param msg 返回内容 + * + * @param msg 返回内容 * @param data 数据对象 * @return 错误消息 */ - public static AjaxResult error(String msg, Object data) - { + public static AjaxResult error(String msg, Object data) { return new AjaxResult(HttpStatus.ERROR, msg, data); } /** * 返回错误消息 - * + * * @param code 状态码 - * @param msg 返回内容 + * @param msg 返回内容 * @return 错误消息 */ - public static AjaxResult error(int code, String msg) - { + public static AjaxResult error(int code, String msg) { return new AjaxResult(code, msg, null); } /** * 方便链式调用 * - * @param key 键 + * @param key 键 * @param value 值 * @return 数据对象 */ @Override - public AjaxResult put(String key, Object value) - { + public AjaxResult put(String key, Object value) { super.put(key, value); return this; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/BaseDO.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/BaseDO.java index be3e6486..74825fa7 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/BaseDO.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/BaseDO.java @@ -10,6 +10,7 @@ import java.time.LocalDateTime; /** * 基类,时间类型改为LocalDateTime + * * @author fastb * @date 2023-08-22 9:11 */ @@ -17,25 +18,35 @@ import java.time.LocalDateTime; public class BaseDO implements Serializable { private static final long serialVersionUID = 1L; - /** 创建者 */ + /** + * 创建者 + */ @ApiModelProperty("创建者") private String createBy; - /** 创建时间 */ + /** + * 创建时间 + */ @ApiModelProperty("创建时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime createTime; - /** 更新者 */ + /** + * 更新者 + */ @ApiModelProperty("更新者") private String updateBy; - /** 更新时间 */ + /** + * 更新时间 + */ @ApiModelProperty("更新时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime updateTime; - /** 逻辑删除 */ + /** + * 逻辑删除 + */ @ApiModelProperty("逻辑删除") @TableLogic private Boolean delFlag; diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/BaseEntity.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/BaseEntity.java index f084a2cf..96aadf41 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/BaseEntity.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/BaseEntity.java @@ -16,38 +16,60 @@ import java.util.Map; * * @author ruoyi */ -public class BaseEntity implements Serializable -{ +public class BaseEntity implements Serializable { private static final long serialVersionUID = 1L; - /** 搜索值 */ + /** + * 搜索值 + */ @TableField(exist = false) @ApiModelProperty("搜索值") @JsonIgnore private String searchValue; - /** 创建者 */ + /** + * 创建者 + */ @ApiModelProperty("创建者") private String createBy; - /** 创建时间 */ + /** + * 创建时间 + */ @ApiModelProperty("创建时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; - /** 更新者 */ + /** + * 更新者 + */ @ApiModelProperty("更新者") private String updateBy; - /** 更新时间 */ + /** + * 更新时间 + */ @ApiModelProperty("更新时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date updateTime; - /** 备注 */ + /** + * 备注 + */ @ApiModelProperty("备注") @TableField(exist = false) private String remark; + @TableField(exist = false) + private Integer pageNum; + @TableField(exist = false) + private Integer pageSize; + /** + * 请求参数 + */ + @TableField(exist = false) + @ApiModelProperty("请求参数") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private Map params; public Integer getPageNum() { return pageNum; @@ -65,89 +87,62 @@ public class BaseEntity implements Serializable this.pageSize = pageSize; } - @TableField(exist = false) - private Integer pageNum; - - @TableField(exist = false) - private Integer pageSize; - - /** 请求参数 */ - @TableField(exist = false) - @ApiModelProperty("请求参数") - @JsonInclude(JsonInclude.Include.NON_EMPTY) - private Map params; - - public String getSearchValue() - { + public String getSearchValue() { return searchValue; } - public void setSearchValue(String searchValue) - { + public void setSearchValue(String searchValue) { this.searchValue = searchValue; } - public String getCreateBy() - { + public String getCreateBy() { return createBy; } - public void setCreateBy(String createBy) - { + public void setCreateBy(String createBy) { this.createBy = createBy; } - public Date getCreateTime() - { + public Date getCreateTime() { return createTime; } - public void setCreateTime(Date createTime) - { + public void setCreateTime(Date createTime) { this.createTime = createTime; } - public String getUpdateBy() - { + public String getUpdateBy() { return updateBy; } - public void setUpdateBy(String updateBy) - { + public void setUpdateBy(String updateBy) { this.updateBy = updateBy; } - public Date getUpdateTime() - { + public Date getUpdateTime() { return updateTime; } - public void setUpdateTime(Date updateTime) - { + public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } - public String getRemark() - { + public String getRemark() { return remark; } - public void setRemark(String remark) - { + public void setRemark(String remark) { this.remark = remark; } - public Map getParams() - { - if (params == null) - { + public Map getParams() { + if (params == null) { params = new HashMap<>(); } return params; } - public void setParams(Map params) - { + public void setParams(Map params) { this.params = params; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/CommonResult.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/CommonResult.java index 0ce5b111..8c571e65 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/CommonResult.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/CommonResult.java @@ -37,11 +37,11 @@ public class CommonResult implements Serializable { /** * 将传入的 result 对象,转换成另外一个泛型结果的对象 - * + *

* 因为 A 方法返回的 CommonResult 对象,不满足调用其的 B 方法的返回,所以需要进行转换。 * * @param result 传入的 result 对象 - * @param 返回的泛型 + * @param 返回的泛型 * @return 新的 CommonResult 对象 */ public static CommonResult error(CommonResult result) { @@ -72,18 +72,22 @@ public class CommonResult implements Serializable { return Objects.equals(code, GlobalErrorCodeConstants.SUCCESS.getCode()); } + public static CommonResult error(ServiceException serviceException) { + return error(serviceException.getCode(), serviceException.getMessage()); + } + @JsonIgnore // 避免 jackson 序列化 public boolean isSuccess() { return isSuccess(code); } + // ========= 和 Exception 异常体系集成 ========= + @JsonIgnore // 避免 jackson 序列化 public boolean isError() { return !isSuccess(); } - // ========= 和 Exception 异常体系集成 ========= - /** * 判断是否有异常。如果有,则抛出 {@link ServiceException} 异常 */ @@ -105,8 +109,4 @@ public class CommonResult implements Serializable { return data; } - public static CommonResult error(ServiceException serviceException) { - return error(serviceException.getCode(), serviceException.getMessage()); - } - } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/R.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/R.java index e0a26039..16a6c1a0 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/R.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/R.java @@ -9,64 +9,55 @@ import java.io.Serializable; * * @author ruoyi */ -public class R implements Serializable -{ - private static final long serialVersionUID = 1L; - - /** 成功 */ +public class R implements Serializable { + /** + * 成功 + */ public static final int SUCCESS = HttpStatus.SUCCESS; - - /** 失败 */ + /** + * 失败 + */ public static final int FAIL = HttpStatus.ERROR; - + private static final long serialVersionUID = 1L; private int code; private String msg; private T data; - public static R ok() - { + public static R ok() { return restResult(null, SUCCESS, "操作成功"); } - public static R ok(T data) - { + public static R ok(T data) { return restResult(data, SUCCESS, "操作成功"); } - public static R ok(T data, String msg) - { + public static R ok(T data, String msg) { return restResult(data, SUCCESS, msg); } - public static R fail() - { + public static R fail() { return restResult(null, FAIL, "操作失败"); } - public static R fail(String msg) - { + public static R fail(String msg) { return restResult(null, FAIL, msg); } - public static R fail(T data) - { + public static R fail(T data) { return restResult(data, FAIL, "操作失败"); } - public static R fail(T data, String msg) - { + public static R fail(T data, String msg) { return restResult(data, FAIL, msg); } - public static R fail(int code, String msg) - { + public static R fail(int code, String msg) { return restResult(null, code, msg); } - private static R restResult(T data, int code, String msg) - { + private static R restResult(T data, int code, String msg) { R apiResult = new R<>(); apiResult.setCode(code); apiResult.setData(data); @@ -74,43 +65,35 @@ public class R implements Serializable return apiResult; } - public int getCode() - { - return code; - } - - public void setCode(int code) - { - this.code = code; - } - - public String getMsg() - { - return msg; - } - - public void setMsg(String msg) - { - this.msg = msg; - } - - public T getData() - { - return data; - } - - public void setData(T data) - { - this.data = data; - } - - public static Boolean isError(R ret) - { + public static Boolean isError(R ret) { return !isSuccess(ret); } - public static Boolean isSuccess(R ret) - { + public static Boolean isSuccess(R ret) { return R.SUCCESS == ret.getCode(); } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/SortingField.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/SortingField.java index 685d73ff..b18135c0 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/SortingField.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/SortingField.java @@ -4,7 +4,7 @@ import java.io.Serializable; /** * 排序字段 DTO - * + *

* 类名加了 ing 的原因是,避免和 ES SortField 重名。 */ public class SortingField implements Serializable { diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/TreeEntity.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/TreeEntity.java index 11e3b667..159ba3ae 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/TreeEntity.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/TreeEntity.java @@ -5,75 +5,74 @@ import java.util.List; /** * Tree基类 - * + * * @author ruoyi */ -public class TreeEntity extends BaseEntity -{ +public class TreeEntity extends BaseEntity { private static final long serialVersionUID = 1L; - /** 父菜单名称 */ + /** + * 父菜单名称 + */ private String parentName; - /** 父菜单ID */ + /** + * 父菜单ID + */ private Long parentId; - /** 显示顺序 */ + /** + * 显示顺序 + */ private Integer orderNum; - /** 祖级列表 */ + /** + * 祖级列表 + */ private String ancestors; - /** 子部门 */ + /** + * 子部门 + */ private List children = new ArrayList<>(); - public String getParentName() - { + public String getParentName() { return parentName; } - public void setParentName(String parentName) - { + public void setParentName(String parentName) { this.parentName = parentName; } - public Long getParentId() - { + public Long getParentId() { return parentId; } - public void setParentId(Long parentId) - { + public void setParentId(Long parentId) { this.parentId = parentId; } - public Integer getOrderNum() - { + public Integer getOrderNum() { return orderNum; } - public void setOrderNum(Integer orderNum) - { + public void setOrderNum(Integer orderNum) { this.orderNum = orderNum; } - public String getAncestors() - { + public String getAncestors() { return ancestors; } - public void setAncestors(String ancestors) - { + public void setAncestors(String ancestors) { this.ancestors = ancestors; } - public List getChildren() - { + public List getChildren() { return children; } - public void setChildren(List children) - { + public void setChildren(List children) { this.children = children; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/TreeSelect.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/TreeSelect.java index 253fabec..d8e0fd32 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/TreeSelect.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/TreeSelect.java @@ -10,69 +10,65 @@ import java.util.stream.Collectors; /** * Treeselect树结构实体类 - * + * * @author ruoyi */ -public class TreeSelect implements Serializable -{ +public class TreeSelect implements Serializable { private static final long serialVersionUID = 1L; - /** 节点ID */ + /** + * 节点ID + */ private Long id; - /** 节点名称 */ + /** + * 节点名称 + */ private String label; - /** 子节点 */ + /** + * 子节点 + */ @JsonInclude(JsonInclude.Include.NON_EMPTY) private List children; - public TreeSelect() - { + public TreeSelect() { } - public TreeSelect(SysDept dept) - { + public TreeSelect(SysDept dept) { this.id = dept.getDeptId(); this.label = dept.getDeptName(); this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); } - public TreeSelect(SysMenu menu) - { + public TreeSelect(SysMenu menu) { this.id = menu.getMenuId(); this.label = menu.getMenuName(); this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); } - public Long getId() - { + public Long getId() { return id; } - public void setId(Long id) - { + public void setId(Long id) { this.id = id; } - public String getLabel() - { + public String getLabel() { return label; } - public void setLabel(String label) - { + public void setLabel(String label) { this.label = label; } - public List getChildren() - { + public List getChildren() { return children; } - public void setChildren(List children) - { + public void setChildren(List children) { this.children = children; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysDept.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysDept.java index 9c929cd3..d3d700dc 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysDept.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysDept.java @@ -19,11 +19,12 @@ import java.util.List; * @author ruoyi */ @ApiModel(value = "SysDept", description = "部门表 sys_dept") -public class SysDept extends BaseEntity -{ +public class SysDept extends BaseEntity { private static final long serialVersionUID = 1L; - /** 部门ID */ + /** + * 部门ID + */ @ApiModelProperty("部门ID") private Long deptId; @@ -32,47 +33,69 @@ public class SysDept extends BaseEntity */ private Long deptUserId; - /** 父部门ID */ + /** + * 父部门ID + */ @ApiModelProperty("父部门ID") private Long parentId; - /** 祖级列表 */ + /** + * 祖级列表 + */ @ApiModelProperty("祖级列表") private String ancestors; - /** 部门名称 */ + /** + * 部门名称 + */ @ApiModelProperty("部门名称") private String deptName; - /** 显示顺序 */ + /** + * 显示顺序 + */ @ApiModelProperty("显示顺序") private Integer orderNum; - /** 负责人 */ + /** + * 负责人 + */ @ApiModelProperty("负责人") private String leader; - /** 联系电话 */ + /** + * 联系电话 + */ @ApiModelProperty("联系电话") private String phone; - /** 邮箱 */ + /** + * 邮箱 + */ @ApiModelProperty("邮箱") private String email; - /** 部门状态:0正常,1停用 */ + /** + * 部门状态:0正常,1停用 + */ @ApiModelProperty("部门状态:0正常,1停用") private String status; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ @ApiModelProperty("删除标志(0代表存在 2代表删除)") private String delFlag; - /** 父部门名称 */ + /** + * 父部门名称 + */ @ApiModelProperty("父部门名称") private String parentName; - /** 子部门 */ + /** + * 子部门 + */ @ApiModelProperty("子部门") private List children = new ArrayList(); @@ -95,6 +118,14 @@ public class SysDept extends BaseEntity * 机构类型 */ private Integer deptType; + /** + * 是否显示自己 + */ + private Boolean showOwner; + /** + * 管理员姓名 + */ + private String deptUserName; public Boolean getShowOwner() { return showOwner; @@ -104,16 +135,6 @@ public class SysDept extends BaseEntity this.showOwner = showOwner; } - /** - * 是否显示自己 - */ - private Boolean showOwner; - - /** - * 管理员姓名 - */ - private String deptUserName; - public String getDeptUserName() { return deptUserName; } @@ -162,150 +183,126 @@ public class SysDept extends BaseEntity this.deptUserId = deptUserId; } - public Long getDeptId() - { + public Long getDeptId() { return deptId; } - public void setDeptId(Long deptId) - { + public void setDeptId(Long deptId) { this.deptId = deptId; } - public Long getParentId() - { + public Long getParentId() { return parentId; } - public void setParentId(Long parentId) - { + public void setParentId(Long parentId) { this.parentId = parentId; } - public String getAncestors() - { + public String getAncestors() { return ancestors; } - public void setAncestors(String ancestors) - { + public void setAncestors(String ancestors) { this.ancestors = ancestors; } @NotBlank(message = "部门名称不能为空") @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符") - public String getDeptName() - { + public String getDeptName() { return deptName; } - public void setDeptName(String deptName) - { + public void setDeptName(String deptName) { this.deptName = deptName; } @NotNull(message = "显示顺序不能为空") - public Integer getOrderNum() - { + public Integer getOrderNum() { return orderNum; } - public void setOrderNum(Integer orderNum) - { + public void setOrderNum(Integer orderNum) { this.orderNum = orderNum; } - public String getLeader() - { + public String getLeader() { return leader; } - public void setLeader(String leader) - { + public void setLeader(String leader) { this.leader = leader; } @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符") - public String getPhone() - { + public String getPhone() { return phone; } - public void setPhone(String phone) - { + public void setPhone(String phone) { this.phone = phone; } @Email(message = "邮箱格式不正确") @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") - public String getEmail() - { + public String getEmail() { return email; } - public void setEmail(String email) - { + public void setEmail(String email) { this.email = email; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - public String getDelFlag() - { + public String getDelFlag() { return delFlag; } - public void setDelFlag(String delFlag) - { + public void setDelFlag(String delFlag) { this.delFlag = delFlag; } - public String getParentName() - { + public String getParentName() { return parentName; } - public void setParentName(String parentName) - { + public void setParentName(String parentName) { this.parentName = parentName; } - public List getChildren() - { + public List getChildren() { return children; } - public void setChildren(List children) - { + public void setChildren(List children) { this.children = children; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("deptId", getDeptId()) - .append("deptUserId", getDeptUserId()) - .append("parentId", getParentId()) - .append("ancestors", getAncestors()) - .append("deptName", getDeptName()) - .append("orderNum", getOrderNum()) - .append("leader", getLeader()) - .append("phone", getPhone()) - .append("email", getEmail()) - .append("status", getStatus()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("deptId", getDeptId()) + .append("deptUserId", getDeptUserId()) + .append("parentId", getParentId()) + .append("ancestors", getAncestors()) + .append("deptName", getDeptName()) + .append("orderNum", getOrderNum()) + .append("leader", getLeader()) + .append("phone", getPhone()) + .append("email", getEmail()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysDictData.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysDictData.java index 72f12f7b..cf3f511c 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysDictData.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysDictData.java @@ -20,57 +20,78 @@ import javax.validation.constraints.Size; */ @Data @ApiModel(value = "SysDictData", description = "字典数据表 sys_dict_data") -public class SysDictData extends BaseEntity -{ +public class SysDictData extends BaseEntity { private static final long serialVersionUID = 1L; - /** 字典编码 */ + /** + * 字典编码 + */ @ApiModelProperty("字典编码") @Excel(name = "字典编码", cellType = ColumnType.NUMERIC) private Long dictCode; - /** 字典排序 */ + /** + * 字典排序 + */ @ApiModelProperty("字典排序") @Excel(name = "字典排序", cellType = ColumnType.NUMERIC) private Long dictSort; - /** 字典标签 */ + /** + * 字典标签 + */ @ApiModelProperty("字典标签") @Excel(name = "字典标签") private String dictLabel; - /** 字典标签 */ + /** + * 字典标签 + */ @ApiModelProperty("中文字典标签") private String dictLabel_zh_CN; - /** 字典标签 */ + /** + * 字典标签 + */ @ApiModelProperty("英文字典标签") private String dictLabel_en_US; - /** 字典键值 */ + /** + * 字典键值 + */ @ApiModelProperty("字典键值") @Excel(name = "字典键值") private String dictValue; - /** 字典类型 */ + /** + * 字典类型 + */ @ApiModelProperty("字典类型") @Excel(name = "字典类型") private String dictType; - /** 样式属性(其他样式扩展) */ + /** + * 样式属性(其他样式扩展) + */ @ApiModelProperty("样式属性(其他样式扩展)") private String cssClass; - /** 表格字典样式 */ + /** + * 表格字典样式 + */ @ApiModelProperty("表格字典样式") private String listClass; - /** 是否默认(Y是 N否) */ + /** + * 是否默认(Y是 N否) + */ @ApiModelProperty("是否默认(Y是 N否)") @Excel(name = "是否默认", readConverterExp = "Y=是,N=否") private String isDefault; - /** 状态(0正常 1停用) */ + /** + * 状态(0正常 1停用) + */ @ApiModelProperty("状态(0正常 1停用)") @Excel(name = "状态", readConverterExp = "0=正常,1=停用") private String status; @@ -78,105 +99,86 @@ public class SysDictData extends BaseEntity @Deprecated private String language; - public Long getDictCode() - { + public Long getDictCode() { return dictCode; } - public void setDictCode(Long dictCode) - { + public void setDictCode(Long dictCode) { this.dictCode = dictCode; } - public Long getDictSort() - { + public Long getDictSort() { return dictSort; } - public void setDictSort(Long dictSort) - { + public void setDictSort(Long dictSort) { this.dictSort = dictSort; } @NotBlank(message = "字典标签不能为空") @Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符") - public String getDictLabel() - { + public String getDictLabel() { return dictLabel; } - public void setDictLabel(String dictLabel) - { + public void setDictLabel(String dictLabel) { this.dictLabel = dictLabel; } @NotBlank(message = "字典键值不能为空") @Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符") - public String getDictValue() - { + public String getDictValue() { return dictValue; } - public void setDictValue(String dictValue) - { + public void setDictValue(String dictValue) { this.dictValue = dictValue; } @NotBlank(message = "字典类型不能为空") @Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符") - public String getDictType() - { + public String getDictType() { return dictType; } - public void setDictType(String dictType) - { + public void setDictType(String dictType) { this.dictType = dictType; } @Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符") - public String getCssClass() - { + public String getCssClass() { return cssClass; } - public void setCssClass(String cssClass) - { + public void setCssClass(String cssClass) { this.cssClass = cssClass; } - public String getListClass() - { + public String getListClass() { return listClass; } - public void setListClass(String listClass) - { + public void setListClass(String listClass) { this.listClass = listClass; } - public boolean getDefault() - { + public boolean getDefault() { return UserConstants.YES.equals(this.isDefault); } - public String getIsDefault() - { + public String getIsDefault() { return isDefault; } - public void setIsDefault(String isDefault) - { + public void setIsDefault(String isDefault) { this.isDefault = isDefault; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } @@ -190,7 +192,7 @@ public class SysDictData extends BaseEntity @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) .append("dictCode", getDictCode()) .append("dictSort", getDictSort()) .append("dictLabel", getDictLabel()) diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysDictType.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysDictType.java index 6bdaf961..baa750d8 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysDictType.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysDictType.java @@ -18,26 +18,33 @@ import javax.validation.constraints.Size; * @author ruoyi */ @ApiModel(value = "SysDictType", description = "字典类型表 sys_dict_type") -public class SysDictType extends BaseEntity -{ +public class SysDictType extends BaseEntity { private static final long serialVersionUID = 1L; - /** 字典主键 */ + /** + * 字典主键 + */ @ApiModelProperty("字典主键") @Excel(name = "字典主键", cellType = ColumnType.NUMERIC) private Long dictId; - /** 字典名称 */ + /** + * 字典名称 + */ @ApiModelProperty("字典名称") @Excel(name = "字典名称") private String dictName; - /** 字典类型 */ + /** + * 字典类型 + */ @ApiModelProperty("字典类型") @Excel(name = "字典类型") private String dictType; - /** 状态(0正常 1停用) */ + /** + * 状态(0正常 1停用) + */ @ApiModelProperty("状态(0正常 1停用)") @Excel(name = "状态", readConverterExp = "0=正常,1=停用") private String status; @@ -46,48 +53,40 @@ public class SysDictType extends BaseEntity private String language; - public Long getDictId() - { + public Long getDictId() { return dictId; } - public void setDictId(Long dictId) - { + public void setDictId(Long dictId) { this.dictId = dictId; } @NotBlank(message = "字典名称不能为空") @Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符") - public String getDictName() - { + public String getDictName() { return dictName; } - public void setDictName(String dictName) - { + public void setDictName(String dictName) { this.dictName = dictName; } @NotBlank(message = "字典类型不能为空") @Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符") @Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)") - public String getDictType() - { + public String getDictType() { return dictType; } - public void setDictType(String dictType) - { + public void setDictType(String dictType) { this.dictType = dictType; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } @@ -103,16 +102,16 @@ public class SysDictType extends BaseEntity @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("dictId", getDictId()) - .append("dictName", getDictName()) - .append("dictType", getDictType()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("dictId", getDictId()) + .append("dictName", getDictName()) + .append("dictType", getDictType()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysMenu.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysMenu.java index 400d8f52..028bfe52 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysMenu.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysMenu.java @@ -14,75 +14,106 @@ import java.util.List; /** * 菜单权限表 sys_menu - * + * * @author ruoyi */ @ApiModel(value = "SysMenu", description = "菜单权限表 sys_menu") -public class SysMenu extends BaseEntity -{ +public class SysMenu extends BaseEntity { private static final long serialVersionUID = 1L; - /** 菜单ID */ + /** + * 菜单ID + */ @ApiModelProperty("菜单ID") private Long menuId; - /** 菜单名称 */ + /** + * 菜单名称 + */ @ApiModelProperty("菜单名称") private String menuName; - /** 父菜单名称 */ + /** + * 父菜单名称 + */ @ApiModelProperty("父菜单名称") private String parentName; - /** 父菜单ID */ + /** + * 父菜单ID + */ @ApiModelProperty("父菜单ID") private Long parentId; - /** 显示顺序 */ + /** + * 显示顺序 + */ @ApiModelProperty("显示顺序") private Integer orderNum; - /** 路由地址 */ + /** + * 路由地址 + */ @ApiModelProperty("路由地址") private String path; - /** 组件路径 */ + /** + * 组件路径 + */ @ApiModelProperty("组件路径") private String component; - /** 路由参数 */ + /** + * 路由参数 + */ @ApiModelProperty("路由参数") private String query; - /** 是否为外链(0是 1否) */ + /** + * 是否为外链(0是 1否) + */ @ApiModelProperty("是否为外链(0是 1否)") private String isFrame; - /** 是否缓存(0缓存 1不缓存) */ + /** + * 是否缓存(0缓存 1不缓存) + */ @ApiModelProperty("是否缓存(0缓存 1不缓存)") private String isCache; - /** 类型(M目录 C菜单 F按钮) */ + /** + * 类型(M目录 C菜单 F按钮) + */ @ApiModelProperty("类型(M目录 C菜单 F按钮)") private String menuType; - /** 显示状态(0显示 1隐藏) */ + /** + * 显示状态(0显示 1隐藏) + */ @ApiModelProperty("显示状态(0显示 1隐藏)") private String visible; - - /** 菜单状态(0正常 1停用) */ + + /** + * 菜单状态(0正常 1停用) + */ @ApiModelProperty("菜单状态(0正常 1停用)") private String status; - /** 权限字符串 */ + /** + * 权限字符串 + */ @ApiModelProperty("权限字符串") private String perms; - /** 菜单图标 */ + /** + * 菜单图标 + */ @ApiModelProperty("菜单图标") private String icon; - /** 子菜单 */ + /** + * 子菜单 + */ @ApiModelProperty("子菜单") private List children = new ArrayList(); @@ -91,18 +122,19 @@ public class SysMenu extends BaseEntity */ private Long deptId; - /** 菜单语言 */ + /** + * 菜单语言 + */ @Deprecated private String language; - public void setLanguage(String language) { - this.language = language; - } - public String getLanguage() { return language; } + public void setLanguage(String language) { + this.language = language; + } public Long getDeptId() { return deptId; @@ -112,194 +144,162 @@ public class SysMenu extends BaseEntity this.deptId = deptId; } - public Long getMenuId() - { + public Long getMenuId() { return menuId; } - public void setMenuId(Long menuId) - { + public void setMenuId(Long menuId) { this.menuId = menuId; } @NotBlank(message = "菜单名称不能为空") @Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符") - public String getMenuName() - { + public String getMenuName() { return menuName; } - public void setMenuName(String menuName) - { + public void setMenuName(String menuName) { this.menuName = menuName; } - public String getParentName() - { + public String getParentName() { return parentName; } - public void setParentName(String parentName) - { + public void setParentName(String parentName) { this.parentName = parentName; } - public Long getParentId() - { + public Long getParentId() { return parentId; } - public void setParentId(Long parentId) - { + public void setParentId(Long parentId) { this.parentId = parentId; } @NotNull(message = "显示顺序不能为空") - public Integer getOrderNum() - { + public Integer getOrderNum() { return orderNum; } - public void setOrderNum(Integer orderNum) - { + public void setOrderNum(Integer orderNum) { this.orderNum = orderNum; } @Size(min = 0, max = 200, message = "路由地址不能超过200个字符") - public String getPath() - { + public String getPath() { return path; } - public void setPath(String path) - { + public void setPath(String path) { this.path = path; } @Size(min = 0, max = 200, message = "组件路径不能超过255个字符") - public String getComponent() - { + public String getComponent() { return component; } - public void setComponent(String component) - { + public void setComponent(String component) { this.component = component; } - public String getQuery() - { + public String getQuery() { return query; } - public void setQuery(String query) - { + public void setQuery(String query) { this.query = query; } - public String getIsFrame() - { + public String getIsFrame() { return isFrame; } - public void setIsFrame(String isFrame) - { + public void setIsFrame(String isFrame) { this.isFrame = isFrame; } - public String getIsCache() - { + public String getIsCache() { return isCache; } - public void setIsCache(String isCache) - { + public void setIsCache(String isCache) { this.isCache = isCache; } @NotBlank(message = "菜单类型不能为空") - public String getMenuType() - { + public String getMenuType() { return menuType; } - public void setMenuType(String menuType) - { + public void setMenuType(String menuType) { this.menuType = menuType; } - public String getVisible() - { + public String getVisible() { return visible; } - public void setVisible(String visible) - { + public void setVisible(String visible) { this.visible = visible; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符") - public String getPerms() - { + public String getPerms() { return perms; } - public void setPerms(String perms) - { + public void setPerms(String perms) { this.perms = perms; } - public String getIcon() - { + public String getIcon() { return icon; } - public void setIcon(String icon) - { + public void setIcon(String icon) { this.icon = icon; } - public List getChildren() - { + public List getChildren() { return children; } - public void setChildren(List children) - { + public void setChildren(List children) { this.children = children; } - + @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("menuId", getMenuId()) - .append("menuName", getMenuName()) - .append("parentId", getParentId()) - .append("orderNum", getOrderNum()) - .append("path", getPath()) - .append("component", getComponent()) - .append("isFrame", getIsFrame()) - .append("IsCache", getIsCache()) - .append("menuType", getMenuType()) - .append("visible", getVisible()) - .append("status ", getStatus()) - .append("perms", getPerms()) - .append("icon", getIcon()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("menuId", getMenuId()) + .append("menuName", getMenuName()) + .append("parentId", getParentId()) + .append("orderNum", getOrderNum()) + .append("path", getPath()) + .append("component", getComponent()) + .append("isFrame", getIsFrame()) + .append("IsCache", getIsCache()) + .append("menuType", getMenuType()) + .append("visible", getVisible()) + .append("status ", getStatus()) + .append("perms", getPerms()) + .append("icon", getIcon()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysRole.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysRole.java index 7b7c488d..8fd0fdfe 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysRole.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysRole.java @@ -19,64 +19,89 @@ import java.util.Set; * @author ruoyi */ @ApiModel(value = "SysRole", description = "角色表 sys_role") -public class SysRole extends BaseEntity -{ +public class SysRole extends BaseEntity { private static final long serialVersionUID = 1L; - /** 角色ID */ + /** + * 角色ID + */ @ApiModelProperty("角色ID") @Excel(name = "角色序号", cellType = ColumnType.NUMERIC) private Long roleId; - /** 角色名称 */ + /** + * 角色名称 + */ @ApiModelProperty("角色名称") @Excel(name = "角色名称") private String roleName; - /** 角色权限 */ + /** + * 角色权限 + */ @ApiModelProperty("角色权限") @Excel(name = "角色权限") private String roleKey; - /** 角色排序 */ + /** + * 角色排序 + */ @ApiModelProperty("角色排序") @Excel(name = "角色排序") private Integer roleSort; - /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */ + /** + * 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) + */ @ApiModelProperty(value = "数据范围", notes = "(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)") @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限") private String dataScope; - /** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */ + /** + * 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) + */ @ApiModelProperty(value = "菜单树选择项是否关联显示", notes = "( 0:父子不互相关联显示 1:父子互相关联显示)") private boolean menuCheckStrictly; - /** 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) */ + /** + * 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) + */ @ApiModelProperty(value = "部门树选择项是否关联显示", notes = "(0:父子不互相关联显示 1:父子互相关联显示 )") private boolean deptCheckStrictly; - /** 角色状态(0正常 1停用) */ + /** + * 角色状态(0正常 1停用) + */ @ApiModelProperty("角色状态(0正常 1停用)") @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") private String status; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ @ApiModelProperty("删除标志") private String delFlag; - /** 用户是否存在此角色标识 默认不存在 */ + /** + * 用户是否存在此角色标识 默认不存在 + */ private boolean flag = false; - /** 菜单组 */ + /** + * 菜单组 + */ @ApiModelProperty("菜单组") private Long[] menuIds; - /** 部门组(数据权限) */ + /** + * 部门组(数据权限) + */ @ApiModelProperty("部门组") private Long[] deptIds; - /** 角色菜单权限 */ + /** + * 角色菜单权限 + */ @ApiModelProperty("角色菜单权限") private Set permissions; @@ -105,6 +130,18 @@ public class SysRole extends BaseEntity */ private Boolean manager; + public SysRole() { + + } + + public SysRole(Long roleId) { + this.roleId = roleId; + } + + public static boolean isAdmin(Long roleId) { + return roleId != null && 1L == roleId; + } + public Boolean getManager() { return manager; } @@ -145,178 +182,136 @@ public class SysRole extends BaseEntity this.deptName = deptName; } - public SysRole() - { - - } - - public SysRole(Long roleId) - { - this.roleId = roleId; - } - - public Long getRoleId() - { + public Long getRoleId() { return roleId; } - public void setRoleId(Long roleId) - { + public void setRoleId(Long roleId) { this.roleId = roleId; } - public boolean isAdmin() - { + public boolean isAdmin() { return isAdmin(this.roleId); } - public static boolean isAdmin(Long roleId) - { - return roleId != null && 1L == roleId; - } - @NotBlank(message = "角色名称不能为空") @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符") - public String getRoleName() - { + public String getRoleName() { return roleName; } - public void setRoleName(String roleName) - { + public void setRoleName(String roleName) { this.roleName = roleName; } @NotBlank(message = "权限字符不能为空") @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符") - public String getRoleKey() - { + public String getRoleKey() { return roleKey; } - public void setRoleKey(String roleKey) - { + public void setRoleKey(String roleKey) { this.roleKey = roleKey; } @NotNull(message = "显示顺序不能为空") - public Integer getRoleSort() - { + public Integer getRoleSort() { return roleSort; } - public void setRoleSort(Integer roleSort) - { + public void setRoleSort(Integer roleSort) { this.roleSort = roleSort; } - public String getDataScope() - { + public String getDataScope() { return dataScope; } - public void setDataScope(String dataScope) - { + public void setDataScope(String dataScope) { this.dataScope = dataScope; } - public boolean isMenuCheckStrictly() - { + public boolean isMenuCheckStrictly() { return menuCheckStrictly; } - public void setMenuCheckStrictly(boolean menuCheckStrictly) - { + public void setMenuCheckStrictly(boolean menuCheckStrictly) { this.menuCheckStrictly = menuCheckStrictly; } - public boolean isDeptCheckStrictly() - { + public boolean isDeptCheckStrictly() { return deptCheckStrictly; } - public void setDeptCheckStrictly(boolean deptCheckStrictly) - { + public void setDeptCheckStrictly(boolean deptCheckStrictly) { this.deptCheckStrictly = deptCheckStrictly; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - public String getDelFlag() - { + public String getDelFlag() { return delFlag; } - public void setDelFlag(String delFlag) - { + public void setDelFlag(String delFlag) { this.delFlag = delFlag; } - public boolean isFlag() - { + public boolean isFlag() { return flag; } - public void setFlag(boolean flag) - { + public void setFlag(boolean flag) { this.flag = flag; } - public Long[] getMenuIds() - { + public Long[] getMenuIds() { return menuIds; } - public void setMenuIds(Long[] menuIds) - { + public void setMenuIds(Long[] menuIds) { this.menuIds = menuIds; } - public Long[] getDeptIds() - { + public Long[] getDeptIds() { return deptIds; } - public void setDeptIds(Long[] deptIds) - { + public void setDeptIds(Long[] deptIds) { this.deptIds = deptIds; } - public Set getPermissions() - { + public Set getPermissions() { return permissions; } - public void setPermissions(Set permissions) - { + public void setPermissions(Set permissions) { this.permissions = permissions; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("roleId", getRoleId()) - .append("roleName", getRoleName()) - .append("roleKey", getRoleKey()) - .append("roleSort", getRoleSort()) - .append("dataScope", getDataScope()) - .append("menuCheckStrictly", isMenuCheckStrictly()) - .append("deptCheckStrictly", isDeptCheckStrictly()) - .append("status", getStatus()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("roleId", getRoleId()) + .append("roleName", getRoleName()) + .append("roleKey", getRoleKey()) + .append("roleSort", getRoleSort()) + .append("dataScope", getDataScope()) + .append("menuCheckStrictly", isMenuCheckStrictly()) + .append("deptCheckStrictly", isDeptCheckStrictly()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysTranslate.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysTranslate.java index 6cd3f9bf..1052d6fc 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysTranslate.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysTranslate.java @@ -10,23 +10,30 @@ import lombok.Data; * @author ruoyi */ @Data -public class SysTranslate extends BaseEntity -{ +public class SysTranslate extends BaseEntity { private static final long serialVersionUID = 1L; - /** ID */ + /** + * ID + */ @Excel(name = "ID") private Long id; - /** zh_CN */ + /** + * zh_CN + */ @Excel(name = "zh-CN") private String zh_CN; - /** en_US */ + /** + * en_US + */ @Excel(name = "en-US") private String en_US; - /** 物模型翻译表使用 */ + /** + * 物模型翻译表使用 + */ private Long productId; private String tableName; diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysUser.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysUser.java index 6c72d5ac..afd091fc 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysUser.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/entity/SysUser.java @@ -23,93 +23,128 @@ import java.util.List; * @author ruoyi */ @ApiModel(value = "SysUser", description = "用户对象 sys_user") -public class SysUser extends BaseEntity -{ +public class SysUser extends BaseEntity { private static final long serialVersionUID = 1L; - /** 用户ID */ + /** + * 用户ID + */ @ApiModelProperty("用户ID") @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号") private Long userId; - /** 部门ID */ + /** + * 部门ID + */ @ApiModelProperty("部门ID") @Excel(name = "部门编号", type = Type.IMPORT) private Long deptId; - /** 用户账号 */ + /** + * 用户账号 + */ @ApiModelProperty("用户账号") @Excel(name = "登录名称") private String userName; - /** 用户昵称 */ + /** + * 用户昵称 + */ @ApiModelProperty("用户昵称") @Excel(name = "用户名称") private String nickName; - /** 用户邮箱 */ + /** + * 用户邮箱 + */ @ApiModelProperty("用户邮箱") @Excel(name = "用户邮箱") private String email; - /** 手机号码 */ + /** + * 手机号码 + */ @ApiModelProperty("手机号码") @Excel(name = "手机号码") private String phonenumber; - /** 用户性别 */ + /** + * 用户性别 + */ @ApiModelProperty("用户性别") @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") private String sex; - /** 用户头像 */ + /** + * 用户头像 + */ @ApiModelProperty("用户头像") private String avatar; - /** 密码 */ + /** + * 密码 + */ @ApiModelProperty("密码") private String password; - /** 帐号状态(0正常 1停用) */ + /** + * 帐号状态(0正常 1停用) + */ @ApiModelProperty("帐号状态(0正常 1停用)") @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用") private String status; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ @ApiModelProperty("删除标志") private String delFlag; - /** 最后登录IP */ + /** + * 最后登录IP + */ @ApiModelProperty("最后登录IP") @Excel(name = "最后登录IP", type = Type.EXPORT) private String loginIp; - /** 最后登录时间 */ + /** + * 最后登录时间 + */ @ApiModelProperty("最后登录时间") @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) private Date loginDate; - /** 部门对象 */ + /** + * 部门对象 + */ @ApiModelProperty("部门对象") @Excels({ - @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), - @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) + @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), + @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) }) private SysDept dept; - /** 角色对象 */ + /** + * 角色对象 + */ @ApiModelProperty("角色对象") private List roles; - /** 角色组 */ + /** + * 角色组 + */ @ApiModelProperty("角色组") private Long[] roleIds; - /** 岗位组 */ + /** + * 岗位组 + */ @ApiModelProperty("岗位组") private Long[] postIds; - /** 角色ID */ + /** + * 角色ID + */ @ApiModelProperty("角色ID") private Long roleId; @@ -131,6 +166,18 @@ public class SysUser extends BaseEntity */ private String timeZone; + public SysUser() { + + } + + public SysUser(Long userId) { + this.userId = userId; + } + + public static boolean isAdmin(Long userId) { + return userId != null && 1L == userId; + } + public String getLanguage() { return language; } @@ -163,236 +210,184 @@ public class SysUser extends BaseEntity this.showChild = showChild; } - public SysUser() - { - - } - - public SysUser(Long userId) - { - this.userId = userId; - } - - public Long getUserId() - { + public Long getUserId() { return userId; } - public void setUserId(Long userId) - { + public void setUserId(Long userId) { this.userId = userId; } - public boolean isAdmin() - { + public boolean isAdmin() { return isAdmin(this.userId); } - public static boolean isAdmin(Long userId) - { - return userId != null && 1L == userId; - } - - public Long getDeptId() - { + public Long getDeptId() { return deptId; } - public void setDeptId(Long deptId) - { + public void setDeptId(Long deptId) { this.deptId = deptId; } @Xss(message = "用户昵称不能包含脚本字符") @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符") - public String getNickName() - { + public String getNickName() { return nickName; } - public void setNickName(String nickName) - { + public void setNickName(String nickName) { this.nickName = nickName; } @Xss(message = "用户账号不能包含脚本字符") @NotBlank(message = "用户账号不能为空") @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符") - public String getUserName() - { + public String getUserName() { return userName; } - public void setUserName(String userName) - { + public void setUserName(String userName) { this.userName = userName; } @Email(message = "邮箱格式不正确") @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") - public String getEmail() - { + public String getEmail() { return email; } - public void setEmail(String email) - { + public void setEmail(String email) { this.email = email; } @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符") - public String getPhonenumber() - { + public String getPhonenumber() { return phonenumber; } - public void setPhonenumber(String phonenumber) - { + public void setPhonenumber(String phonenumber) { this.phonenumber = phonenumber; } - public String getSex() - { + public String getSex() { return sex; } - public void setSex(String sex) - { + public void setSex(String sex) { this.sex = sex; } - public String getAvatar() - { + public String getAvatar() { return avatar; } - public void setAvatar(String avatar) - { + public void setAvatar(String avatar) { this.avatar = avatar; } - public String getPassword() - { + public String getPassword() { return password; } - public void setPassword(String password) - { + public void setPassword(String password) { this.password = password; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - public String getDelFlag() - { + public String getDelFlag() { return delFlag; } - public void setDelFlag(String delFlag) - { + public void setDelFlag(String delFlag) { this.delFlag = delFlag; } - public String getLoginIp() - { + public String getLoginIp() { return loginIp; } - public void setLoginIp(String loginIp) - { + public void setLoginIp(String loginIp) { this.loginIp = loginIp; } - public Date getLoginDate() - { + public Date getLoginDate() { return loginDate; } - public void setLoginDate(Date loginDate) - { + public void setLoginDate(Date loginDate) { this.loginDate = loginDate; } - public SysDept getDept() - { + public SysDept getDept() { return dept; } - public void setDept(SysDept dept) - { + public void setDept(SysDept dept) { this.dept = dept; } - public List getRoles() - { + public List getRoles() { return roles; } - public void setRoles(List roles) - { + public void setRoles(List roles) { this.roles = roles; } - public Long[] getRoleIds() - { + public Long[] getRoleIds() { return roleIds; } - public void setRoleIds(Long[] roleIds) - { + public void setRoleIds(Long[] roleIds) { this.roleIds = roleIds; } - public Long[] getPostIds() - { + public Long[] getPostIds() { return postIds; } - public void setPostIds(Long[] postIds) - { + public void setPostIds(Long[] postIds) { this.postIds = postIds; } - public Long getRoleId() - { + public Long getRoleId() { return roleId; } - public void setRoleId(Long roleId) - { + public void setRoleId(Long roleId) { this.roleId = roleId; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("userId", getUserId()) - .append("deptId", getDeptId()) - .append("userName", getUserName()) - .append("nickName", getNickName()) - .append("email", getEmail()) - .append("phonenumber", getPhonenumber()) - .append("sex", getSex()) - .append("avatar", getAvatar()) - .append("password", getPassword()) - .append("status", getStatus()) - .append("delFlag", getDelFlag()) - .append("loginIp", getLoginIp()) - .append("loginDate", getLoginDate()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .append("dept", getDept()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("deptId", getDeptId()) + .append("userName", getUserName()) + .append("nickName", getNickName()) + .append("email", getEmail()) + .append("phonenumber", getPhonenumber()) + .append("sex", getSex()) + .append("avatar", getAvatar()) + .append("password", getPassword()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("loginIp", getLoginIp()) + .append("loginDate", getLoginDate()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("dept", getDept()) + .toString(); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/BindLoginBody.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/BindLoginBody.java index 806c615d..a478f7c4 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/BindLoginBody.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/BindLoginBody.java @@ -2,15 +2,14 @@ package com.fastbee.common.core.domain.model; /** * 用户登录对象 - * + * * @author ruoyi */ -public class BindLoginBody extends LoginBody -{ +public class BindLoginBody extends LoginBody { /** * 绑定id */ - private String bindId; + private String bindId; public String getBindId() { return bindId; diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/LoginBody.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/LoginBody.java index 27a08bc3..701f1dc0 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/LoginBody.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/LoginBody.java @@ -5,8 +5,7 @@ package com.fastbee.common.core.domain.model; * * @author ruoyi */ -public class LoginBody -{ +public class LoginBody { /** * 用户名 */ @@ -67,43 +66,35 @@ public class LoginBody this.phonenumber = phonenumber; } - public String getUsername() - { + public String getUsername() { return username; } - public void setUsername(String username) - { + public void setUsername(String username) { this.username = username; } - public String getPassword() - { + public String getPassword() { return password; } - public void setPassword(String password) - { + public void setPassword(String password) { this.password = password; } - public String getCode() - { + public String getCode() { return code; } - public void setCode(String code) - { + public void setCode(String code) { this.code = code; } - public String getUuid() - { + public String getUuid() { return uuid; } - public void setUuid(String uuid) - { + public void setUuid(String uuid) { this.uuid = uuid; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/LoginUser.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/LoginUser.java index fda5315f..e5d5f00e 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/LoginUser.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/LoginUser.java @@ -13,8 +13,7 @@ import java.util.Set; * * @author ruoyi */ -public class LoginUser implements UserDetails -{ +public class LoginUser implements UserDetails { private static final long serialVersionUID = 1L; /** @@ -78,6 +77,22 @@ public class LoginUser implements UserDetails private Boolean neverExpire = Boolean.FALSE; + public LoginUser() { + } + + public LoginUser(SysUser user, Set permissions) { + this.user = user; + this.permissions = permissions; + } + + public LoginUser(Long userId, Long deptId, String language, SysUser user, Set permissions) { + this.userId = userId; + this.deptId = deptId; + this.user = user; + this.language = language; + this.permissions = permissions; + } + public Boolean getNeverExpire() { return neverExpire; } @@ -90,6 +105,10 @@ public class LoginUser implements UserDetails return language; } + public void setLanguage(String language) { + this.language = language; + } + public Long getDeptUserId() { return deptUserId; } @@ -98,69 +117,38 @@ public class LoginUser implements UserDetails this.deptUserId = deptUserId; } - public void setLanguage(String language) { - this.language = language; - } - - public Long getUserId() - { + public Long getUserId() { return userId; } - public void setUserId(Long userId) - { + public void setUserId(Long userId) { this.userId = userId; } - public Long getDeptId() - { + public Long getDeptId() { return deptId; } - public void setDeptId(Long deptId) - { + public void setDeptId(Long deptId) { this.deptId = deptId; } - public String getToken() - { + public String getToken() { return token; } - public void setToken(String token) - { + public void setToken(String token) { this.token = token; } - public LoginUser() - { - } - - public LoginUser(SysUser user, Set permissions) - { - this.user = user; - this.permissions = permissions; - } - - public LoginUser(Long userId, Long deptId,String language, SysUser user, Set permissions) - { - this.userId = userId; - this.deptId = deptId; - this.user = user; - this.language = language; - this.permissions = permissions; - } - @JSONField(serialize = false) @Override - public String getPassword() - { + public String getPassword() { return user.getPassword(); } @Override - public String getUsername() - { + public String getUsername() { return user.getUserName(); } @@ -169,8 +157,7 @@ public class LoginUser implements UserDetails */ @JSONField(serialize = false) @Override - public boolean isAccountNonExpired() - { + public boolean isAccountNonExpired() { return true; } @@ -181,8 +168,7 @@ public class LoginUser implements UserDetails */ @JSONField(serialize = false) @Override - public boolean isAccountNonLocked() - { + public boolean isAccountNonLocked() { return true; } @@ -193,8 +179,7 @@ public class LoginUser implements UserDetails */ @JSONField(serialize = false) @Override - public boolean isCredentialsNonExpired() - { + public boolean isCredentialsNonExpired() { return true; } @@ -205,94 +190,76 @@ public class LoginUser implements UserDetails */ @JSONField(serialize = false) @Override - public boolean isEnabled() - { + public boolean isEnabled() { return true; } - public Long getLoginTime() - { + public Long getLoginTime() { return loginTime; } - public void setLoginTime(Long loginTime) - { + public void setLoginTime(Long loginTime) { this.loginTime = loginTime; } - public String getIpaddr() - { + public String getIpaddr() { return ipaddr; } - public void setIpaddr(String ipaddr) - { + public void setIpaddr(String ipaddr) { this.ipaddr = ipaddr; } - public String getLoginLocation() - { + public String getLoginLocation() { return loginLocation; } - public void setLoginLocation(String loginLocation) - { + public void setLoginLocation(String loginLocation) { this.loginLocation = loginLocation; } - public String getBrowser() - { + public String getBrowser() { return browser; } - public void setBrowser(String browser) - { + public void setBrowser(String browser) { this.browser = browser; } - public String getOs() - { + public String getOs() { return os; } - public void setOs(String os) - { + public void setOs(String os) { this.os = os; } - public Long getExpireTime() - { + public Long getExpireTime() { return expireTime; } - public void setExpireTime(Long expireTime) - { + public void setExpireTime(Long expireTime) { this.expireTime = expireTime; } - public Set getPermissions() - { + public Set getPermissions() { return permissions; } - public void setPermissions(Set permissions) - { + public void setPermissions(Set permissions) { this.permissions = permissions; } - public SysUser getUser() - { + public SysUser getUser() { return user; } - public void setUser(SysUser user) - { + public void setUser(SysUser user) { this.user = user; } @Override - public Collection getAuthorities() - { + public Collection getAuthorities() { return null; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/RegisterBody.java b/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/RegisterBody.java index 750f0e2c..05b41a1b 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/RegisterBody.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/domain/model/RegisterBody.java @@ -2,10 +2,9 @@ package com.fastbee.common.core.domain.model; /** * 用户注册对象 - * + * * @author ruoyi */ -public class RegisterBody extends LoginBody -{ +public class RegisterBody extends LoginBody { } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/iot/response/DashDeviceTotalDto.java b/fastbee-common/src/main/java/com/fastbee/common/core/iot/response/DashDeviceTotalDto.java index 53fd0041..7ac50989 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/iot/response/DashDeviceTotalDto.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/iot/response/DashDeviceTotalDto.java @@ -4,6 +4,7 @@ import lombok.Data; /** * 大屏设备总览数据 + * * @author bill */ @Data diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/iot/response/DeCodeBo.java b/fastbee-common/src/main/java/com/fastbee/common/core/iot/response/DeCodeBo.java index 87c57d9e..8c041337 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/iot/response/DeCodeBo.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/iot/response/DeCodeBo.java @@ -9,18 +9,32 @@ import lombok.Data; @Data public class DeCodeBo { - /**原始报文*/ + /** + * 原始报文 + */ private String payload; - /**从机编号*/ + /** + * 从机编号 + */ private Integer slaveId; - /**寄存器地址*/ + /** + * 寄存器地址 + */ private Integer address; - /**功能码*/ + /** + * 功能码 + */ private Integer code; - /**读取个数*/ + /** + * 读取个数 + */ private Integer count; - /**写入值*/ + /** + * 写入值 + */ private Integer writeData; - /**读写类型 1-解析 2-读指令 3-写指令 */ + /** + * 读写类型 1-解析 2-读指令 3-写指令 + */ private Integer type; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/iot/response/IdentityAndName.java b/fastbee-common/src/main/java/com/fastbee/common/core/iot/response/IdentityAndName.java index 3ef267c7..b97e4980 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/iot/response/IdentityAndName.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/iot/response/IdentityAndName.java @@ -13,41 +13,28 @@ import lombok.NoArgsConstructor; @NoArgsConstructor @AllArgsConstructor @Data -public class IdentityAndName -{ +public class IdentityAndName { - public IdentityAndName(String id,String value){ - this.id=id; - this.value=value; - } - - public IdentityAndName(String id,Integer isHistory){ - this.id=id; - this.isHistory=isHistory; - } - - public IdentityAndName(String id, Integer isHistory, String specs, String name, Integer type){ - this.id = id; - this.isHistory = isHistory; - this.dataType = specs; - this.name = name; - this.type = type; - } - - /** 物模型唯一标识符 */ + /** + * 物模型唯一标识符 + */ private String id; - /** 物模型值 */ + /** + * 物模型值 + */ private Object value; - private Integer isChart; - - /**是否监控*/ + /** + * 是否监控 + */ private Integer isHistory; /** * 数据定义 */ private String dataType; - /**物模型名称*/ + /** + * 物模型名称 + */ private String name; /** * 物模型类型 @@ -57,14 +44,27 @@ public class IdentityAndName * 是否是参数 */ private Integer isParams; - private String formula; - private Integer slaveId; - private Integer tempSlaveId; - private Integer quantity; - private String code; + + public IdentityAndName(String id, String value) { + this.id = id; + this.value = value; + } + + public IdentityAndName(String id, Integer isHistory) { + this.id = id; + this.isHistory = isHistory; + } + + public IdentityAndName(String id, Integer isHistory, String specs, String name, Integer type) { + this.id = id; + this.isHistory = isHistory; + this.dataType = specs; + this.name = name; + this.type = type; + } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceReplyBo.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceReplyBo.java index 21b0a62f..b4b44f79 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceReplyBo.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceReplyBo.java @@ -12,6 +12,8 @@ public class DeviceReplyBo { private String messageId; /*标识符*/ private String id; - /**下发值*/ + /** + * 下发值 + */ private String value; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceReport.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceReport.java index 382407eb..95b835b3 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceReport.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceReport.java @@ -37,7 +37,9 @@ public class DeviceReport extends Message { */ private String messageId; - /** 设备物模型值的集合 **/ + /** + * 设备物模型值的集合 + **/ private List thingsModelSimpleItem; /** diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceReportBo.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceReportBo.java index 54abbc11..2841be67 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceReportBo.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceReportBo.java @@ -15,6 +15,7 @@ import java.util.List; /** * 设备上报 + * * @author bill */ @Data @@ -46,7 +47,9 @@ public class DeviceReportBo { /* modbus协议消息回调,记录数据*/ private PropRead prop; - /** 设备物模型值的集合 **/ + /** + * 设备物模型值的集合 + **/ private List thingsModelSimpleItem; /*处理的消息服务类型*/ private ServerType serverType; diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceStatusBo.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceStatusBo.java index 160e7263..d217209c 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceStatusBo.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/DeviceStatusBo.java @@ -10,6 +10,7 @@ import java.util.Date; /** * 设备状态 + * * @author bill */ @AllArgsConstructor @@ -21,9 +22,13 @@ public class DeviceStatusBo { * 设备客户端id */ private String serialNumber; - /**是否活跃*/ + /** + * 是否活跃 + */ private DeviceStatus status; - /**消息时间*/ + /** + * 消息时间 + */ private Date timestamp; /*host*/ private String hostName; diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/InvokeReqDto.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/InvokeReqDto.java index 5bcb04b2..d3879ab0 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/InvokeReqDto.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/InvokeReqDto.java @@ -23,13 +23,19 @@ public class InvokeReqDto { @NotNull(message = "标识符不能为空") @ApiModelProperty(value = "标识符") private String identifier; - /**消息体*/ + /** + * 消息体 + */ @ApiModelProperty(value = "消息体") private JSONObject params; - /**远程消息体*/ + /** + * 远程消息体 + */ @ApiModelProperty(value = "远程调用消息体") - private Map remoteCommand; - /**设备超时时间*/ + private Map remoteCommand; + /** + * 设备超时时间 + */ @ApiModelProperty(value = "设备超时响应时间,默认10s") private Integer timeOut = 10; @@ -37,7 +43,7 @@ public class InvokeReqDto { private Integer type = ThingsModelType.SERVICE.getCode(); @ApiModelProperty(value = "是否是影子模式") - private String isShadow ; + private String isShadow; @ApiModelProperty(value = "产品id") private Long productId; diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/MQSendMessageBo.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/MQSendMessageBo.java index 12611e0d..e64d10a4 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/MQSendMessageBo.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/MQSendMessageBo.java @@ -14,6 +14,9 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class MQSendMessageBo { + public Boolean isShadow; + public Long userId; + public Long delay; /** * 设备编号 */ @@ -26,7 +29,6 @@ public class MQSendMessageBo { * 下发参数 */ private JSONObject params; - /** * 下发的值 */ @@ -39,7 +41,6 @@ public class MQSendMessageBo { * 协议产品相关信息 */ private DeviceAndProtocol dp; - /** * 物模型 */ @@ -48,14 +49,6 @@ public class MQSendMessageBo { * 主题 */ private String topicName; - - - public Boolean isShadow; - - public Long userId; - - public Long delay; - private String parentSerialNumber; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceData.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceData.java index aa35cdd9..bd37850a 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceData.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceData.java @@ -10,6 +10,7 @@ import lombok.EqualsAndHashCode; /** * 消息解析model + * * @author gsb * @date 2022/10/10 15:53 */ @@ -34,7 +35,9 @@ public class DeviceData extends Message { private int type; /*Modbus*/ private ModbusCode code; - /**产品id*/ + /** + * 产品id + */ private Long productId; private OtaPackageCode netModbusCode; diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceDownMessage.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceDownMessage.java index 47369aab..acecd7fe 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceDownMessage.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceDownMessage.java @@ -50,7 +50,7 @@ public class DeviceDownMessage { private String subCode; private ServerType serverType; - public DeviceDownMessage(List values, String topic, String subCode,String transport) { + public DeviceDownMessage(List values, String topic, String subCode, String transport) { this.values = values; this.topic = topic; this.subCode = subCode; diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceFunctionMessage.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceFunctionMessage.java index df0d5784..6367f425 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceFunctionMessage.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceFunctionMessage.java @@ -4,6 +4,7 @@ import lombok.Data; /** * 平台下发指令数据model + * * @author bill */ @Data diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceMessage.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceMessage.java index f0e3a37c..ef426912 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceMessage.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/DeviceMessage.java @@ -8,24 +8,33 @@ import java.util.Date; /** * 设备消息 + * * @author bill */ @Data @JsonInclude(JsonInclude.Include.NON_NULL) public class DeviceMessage { - /** 下发的数据*/ + /** + * 下发的数据 + */ private Object message; - /** 下发的topic*/ + /** + * 下发的topic + */ private String topicName; - /** 设备编号*/ + /** + * 设备编号 + */ private String serialNumber; private String dataType; - /** 时间 */ - @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss:SSS") + /** + * 时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss:SSS") private Date time; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/FunctionCallBackBo.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/FunctionCallBackBo.java index de6b3528..af086718 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/FunctionCallBackBo.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/FunctionCallBackBo.java @@ -4,6 +4,7 @@ import lombok.Data; /** * 指令下发组将的model + * * @author bill */ @Data diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/InstructionsMessage.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/InstructionsMessage.java index 78b3a0d0..1e49b487 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/InstructionsMessage.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/InstructionsMessage.java @@ -4,6 +4,7 @@ import lombok.Data; /** * 指令下发组将的model + * * @author bill */ @Data diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/PropRead.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/PropRead.java index 9f949e08..0e679df9 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/PropRead.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/PropRead.java @@ -10,15 +10,21 @@ import lombok.Data; @Data public class PropRead { - /**设备编号*/ + /** + * 设备编号 + */ private String serialNumber; - /**寄存器起始地址*/ + /** + * 寄存器起始地址 + */ private int address; /** * 读取寄存器个数 */ private int count; - /**数据结果长度计算值*/ + /** + * 数据结果长度计算值 + */ private int length; /** * 从机地址 diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/ProtocolDto.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/ProtocolDto.java index 8e45f222..65a8c8df 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/ProtocolDto.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/ProtocolDto.java @@ -4,18 +4,23 @@ import lombok.Data; /** * 协议bean + * * @author gsb * @date 2022/10/25 14:54 */ @Data public class ProtocolDto { - /**协议编号*/ + /** + * 协议编号 + */ private String code; private String name; /*外部协议url*/ private String protocolUrl; private String description; - /**协议类型 协议类型 0:系统协议 1:jar,2.js,3.c*/ + /** + * 协议类型 协议类型 0:系统协议 1:jar,2.js,3.c + */ private Integer protocolType; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/ReportDataBo.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/ReportDataBo.java index ae3f89a5..c4eec915 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/ReportDataBo.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/ReportDataBo.java @@ -9,40 +9,55 @@ import java.util.List; /** * 上报数据模型bo + * * @author bill */ @Data @Accessors(chain = true) public class ReportDataBo { - /**产品id*/ - private Long productId; - /**设备编号*/ - private String serialNumber; - /**上报消息*/ - private String message; - /**上报的数据*/ - private List dataList; - /**设备影子*/ - private boolean isShadow; - /** - * 物模型类型 - * 1=属性,2=功能,3=事件,4=设备升级,5=设备上线,6=设备下线 - */ - private int type; - /**是否执行规则引擎*/ - private boolean isRuleEngine; - /**从机编号*/ - private Integer slaveId; - /** - * 上报原数据包 - */ - private Object sources; + /** + * 产品id + */ + private Long productId; + /** + * 设备编号 + */ + private String serialNumber; + /** + * 上报消息 + */ + private String message; + /** + * 上报的数据 + */ + private List dataList; + /** + * 设备影子 + */ + private boolean isShadow; + /** + * 物模型类型 + * 1=属性,2=功能,3=事件,4=设备升级,5=设备上线,6=设备下线 + */ + private int type; + /** + * 是否执行规则引擎 + */ + private boolean isRuleEngine; + /** + * 从机编号 + */ + private Integer slaveId; + /** + * 上报原数据包 + */ + private Object sources; - private GwDeviceBo gwDeviceBo; + private GwDeviceBo gwDeviceBo; - private Long userId; - private String userName; - private String deviceName; + private Long userId; + private String userName; + private String deviceName; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/SubDeviceMessage.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/SubDeviceMessage.java index 47940924..eca4067c 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/SubDeviceMessage.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/message/SubDeviceMessage.java @@ -4,6 +4,7 @@ import lombok.Data; /** * 网关子设备model + * * @author gsb * @date 2022/10/10 10:18 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/ota/OtaReplyMessage.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/ota/OtaReplyMessage.java index 0d539f5d..5e395ba8 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/ota/OtaReplyMessage.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/ota/OtaReplyMessage.java @@ -7,6 +7,7 @@ import java.math.BigDecimal; /** * OTA升级回复model + * * @author gsb * @date 2022/10/24 17:20 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/mq/ota/OtaUpgradeBo.java b/fastbee-common/src/main/java/com/fastbee/common/core/mq/ota/OtaUpgradeBo.java index 460ff444..21540e43 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/mq/ota/OtaUpgradeBo.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/mq/ota/OtaUpgradeBo.java @@ -8,6 +8,7 @@ import java.math.BigDecimal; /** * OTA远程升级 + * * @author gsb * @date 2022/10/10 10:22 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/notify/AppGeTuiParams.java b/fastbee-common/src/main/java/com/fastbee/common/core/notify/AppGeTuiParams.java index c18fdf11..f4e5e0cc 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/notify/AppGeTuiParams.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/notify/AppGeTuiParams.java @@ -7,6 +7,7 @@ import org.dromara.sms4j.provider.config.BaseConfig; /** * 个推参数配置 + * * @author gsb * @date 2023/12/11 17:14 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/notify/EnterpriseWeChatAPPParams.java b/fastbee-common/src/main/java/com/fastbee/common/core/notify/EnterpriseWeChatAPPParams.java index eeeb6a9d..12dbd68d 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/notify/EnterpriseWeChatAPPParams.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/notify/EnterpriseWeChatAPPParams.java @@ -7,6 +7,7 @@ import org.dromara.sms4j.provider.config.BaseConfig; /** * 企业微信(应用消息) + * * @author gsb * @date 2023/12/11 17:25 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/notify/WeChatServerParams.java b/fastbee-common/src/main/java/com/fastbee/common/core/notify/WeChatServerParams.java index 1f66e0c1..2f6b354e 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/notify/WeChatServerParams.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/notify/WeChatServerParams.java @@ -6,6 +6,7 @@ import lombok.experimental.Accessors; /** * 微信服务号推送参数 + * * @author gsb * @date 2023/12/11 17:11 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/notify/alertPush/AlertPushItem.java b/fastbee-common/src/main/java/com/fastbee/common/core/notify/alertPush/AlertPushItem.java index 1207c9ee..1ed952a4 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/notify/alertPush/AlertPushItem.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/notify/alertPush/AlertPushItem.java @@ -4,6 +4,7 @@ import lombok.Data; /** * 推送项item + * * @author bill */ @Data diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/notify/alertPush/PushMsg.java b/fastbee-common/src/main/java/com/fastbee/common/core/notify/alertPush/PushMsg.java index 26e24212..141ece17 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/notify/alertPush/PushMsg.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/notify/alertPush/PushMsg.java @@ -6,6 +6,7 @@ import java.util.List; /** * 推送配置信息 + * * @author bill */ @Data diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/notify/config/EmailConfigParams.java b/fastbee-common/src/main/java/com/fastbee/common/core/notify/config/EmailConfigParams.java index ae425504..2fec1a94 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/notify/config/EmailConfigParams.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/notify/config/EmailConfigParams.java @@ -5,6 +5,7 @@ import lombok.Data; /** * 邮箱配置参数 + * * @author gsb * @date 2023/12/11 17:17 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/notify/config/VoiceConfigParams.java b/fastbee-common/src/main/java/com/fastbee/common/core/notify/config/VoiceConfigParams.java index 1ce4c616..935593cf 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/notify/config/VoiceConfigParams.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/notify/config/VoiceConfigParams.java @@ -4,6 +4,7 @@ import lombok.Data; /** * 语音配置 + * * @author fastb * @date 2023-12-09 17:32 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/notify/config/WeChatConfigParams.java b/fastbee-common/src/main/java/com/fastbee/common/core/notify/config/WeChatConfigParams.java index d3b3ed2a..a20651de 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/notify/config/WeChatConfigParams.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/notify/config/WeChatConfigParams.java @@ -4,6 +4,7 @@ import lombok.Data; /** * 微信推送配置参数 + * * @author gsb * @date 2023/12/11 17:11 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/ota/OtaPackageCode.java b/fastbee-common/src/main/java/com/fastbee/common/core/ota/OtaPackageCode.java index 3980b5c3..a8c72b71 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/ota/OtaPackageCode.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/ota/OtaPackageCode.java @@ -8,16 +8,15 @@ import lombok.Getter; @AllArgsConstructor public enum OtaPackageCode { - OTA_01("查询产品工装号",(byte) 0x01), - OTA_0A("OTA升级启动",(byte) 0x0A), - OTA_0B("OTA升级包传输",(byte) 0x0B) - ; + OTA_01("查询产品工装号", (byte) 0x01), + OTA_0A("OTA升级启动", (byte) 0x0A), + OTA_0B("OTA升级包传输", (byte) 0x0B); private String desc; private byte code; public static OtaPackageCode getInstance(int code) { - switch ((byte)code) { + switch ((byte) code) { case 0x01: return OTA_01; case 0x0A: @@ -29,8 +28,8 @@ public enum OtaPackageCode { } } - public static String getDes(int code){ - switch ((byte)code) { + public static String getDes(int code) { + switch ((byte) code) { case 0x01: return OTA_01.desc; case 0x0A: diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/page/PageDomain.java b/fastbee-common/src/main/java/com/fastbee/common/core/page/PageDomain.java index 6d2cd75d..c090d721 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/page/PageDomain.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/page/PageDomain.java @@ -4,98 +4,90 @@ import com.fastbee.common.utils.StringUtils; /** * 分页数据 - * + * * @author ruoyi */ -public class PageDomain -{ - /** 当前记录起始索引 */ +public class PageDomain { + /** + * 当前记录起始索引 + */ private Integer pageNum; - /** 每页显示记录数 */ + /** + * 每页显示记录数 + */ private Integer pageSize; - /** 排序列 */ + /** + * 排序列 + */ private String orderByColumn; - /** 排序的方向desc或者asc */ + /** + * 排序的方向desc或者asc + */ private String isAsc = "asc"; - /** 分页参数合理化 */ + /** + * 分页参数合理化 + */ private Boolean reasonable = true; - public String getOrderBy() - { - if (StringUtils.isEmpty(orderByColumn)) - { + public String getOrderBy() { + if (StringUtils.isEmpty(orderByColumn)) { return ""; } return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc; } - public Integer getPageNum() - { + public Integer getPageNum() { return pageNum; } - public void setPageNum(Integer pageNum) - { + public void setPageNum(Integer pageNum) { this.pageNum = pageNum; } - public Integer getPageSize() - { + public Integer getPageSize() { return pageSize; } - public void setPageSize(Integer pageSize) - { + public void setPageSize(Integer pageSize) { this.pageSize = pageSize; } - public String getOrderByColumn() - { + public String getOrderByColumn() { return orderByColumn; } - public void setOrderByColumn(String orderByColumn) - { + public void setOrderByColumn(String orderByColumn) { this.orderByColumn = orderByColumn; } - public String getIsAsc() - { + public String getIsAsc() { return isAsc; } - public void setIsAsc(String isAsc) - { - if (StringUtils.isNotEmpty(isAsc)) - { + public void setIsAsc(String isAsc) { + if (StringUtils.isNotEmpty(isAsc)) { // 兼容前端排序类型 - if ("ascending".equals(isAsc)) - { + if ("ascending".equals(isAsc)) { isAsc = "asc"; - } - else if ("descending".equals(isAsc)) - { + } else if ("descending".equals(isAsc)) { isAsc = "desc"; } this.isAsc = isAsc; } } - public Boolean getReasonable() - { - if (StringUtils.isNull(reasonable)) - { + public Boolean getReasonable() { + if (StringUtils.isNull(reasonable)) { return Boolean.TRUE; } return reasonable; } - public void setReasonable(Boolean reasonable) - { + public void setReasonable(Boolean reasonable) { this.reasonable = reasonable; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/page/TableDataExtendInfo.java b/fastbee-common/src/main/java/com/fastbee/common/core/page/TableDataExtendInfo.java index feb17817..38bd00a5 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/page/TableDataExtendInfo.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/page/TableDataExtendInfo.java @@ -9,20 +9,27 @@ import java.util.List; * * @author ruoyi */ -public class TableDataExtendInfo implements Serializable -{ +public class TableDataExtendInfo implements Serializable { private static final long serialVersionUID = 1L; - /** 总记录数 */ + /** + * 总记录数 + */ private long total; - /** 列表数据 */ + /** + * 列表数据 + */ private List rows; - /** 消息状态码 */ + /** + * 消息状态码 + */ private int code; - /** 消息内容 */ + /** + * 消息内容 + */ private String msg; /** @@ -30,6 +37,23 @@ public class TableDataExtendInfo implements Serializable */ private Integer allEnable; + /** + * 表格数据对象 + */ + public TableDataExtendInfo() { + } + + /** + * 分页 + * + * @param list 列表数据 + * @param total 总记录数 + */ + public TableDataExtendInfo(List list, int total) { + this.rows = list; + this.total = total; + } + public Integer getAllEnable() { return allEnable; } @@ -38,62 +62,35 @@ public class TableDataExtendInfo implements Serializable this.allEnable = allEnable; } - /** - * 表格数据对象 - */ - public TableDataExtendInfo() - { - } - - /** - * 分页 - * - * @param list 列表数据 - * @param total 总记录数 - */ - public TableDataExtendInfo(List list, int total) - { - this.rows = list; - this.total = total; - } - - public long getTotal() - { + public long getTotal() { return total; } - public void setTotal(long total) - { + public void setTotal(long total) { this.total = total; } - public List getRows() - { + public List getRows() { return rows; } - public void setRows(List rows) - { + public void setRows(List rows) { this.rows = rows; } - public int getCode() - { + public int getCode() { return code; } - public void setCode(int code) - { + public void setCode(int code) { this.code = code; } - public String getMsg() - { + public String getMsg() { return msg; } - public void setMsg(String msg) - { + public void setMsg(String msg) { this.msg = msg; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/page/TableDataInfo.java b/fastbee-common/src/main/java/com/fastbee/common/core/page/TableDataInfo.java index d84cb2c0..a68a57ba 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/page/TableDataInfo.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/page/TableDataInfo.java @@ -5,81 +5,78 @@ import java.util.List; /** * 表格分页数据对象 - * + * * @author ruoyi */ -public class TableDataInfo implements Serializable -{ +public class TableDataInfo implements Serializable { private static final long serialVersionUID = 1L; - /** 总记录数 */ + /** + * 总记录数 + */ private long total; - /** 列表数据 */ + /** + * 列表数据 + */ private List rows; - /** 消息状态码 */ + /** + * 消息状态码 + */ private int code; - /** 消息内容 */ + /** + * 消息内容 + */ private String msg; /** * 表格数据对象 */ - public TableDataInfo() - { + public TableDataInfo() { } /** * 分页 - * - * @param list 列表数据 + * + * @param list 列表数据 * @param total 总记录数 */ - public TableDataInfo(List list, int total) - { + public TableDataInfo(List list, int total) { this.rows = list; this.total = total; } - public long getTotal() - { + public long getTotal() { return total; } - public void setTotal(long total) - { + public void setTotal(long total) { this.total = total; } - public List getRows() - { + public List getRows() { return rows; } - public void setRows(List rows) - { + public void setRows(List rows) { this.rows = rows; } - public int getCode() - { + public int getCode() { return code; } - public void setCode(int code) - { + public void setCode(int code) { this.code = code; } - public String getMsg() - { + public String getMsg() { return msg; } - public void setMsg(String msg) - { + public void setMsg(String msg) { this.msg = msg; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/page/TableSupport.java b/fastbee-common/src/main/java/com/fastbee/common/core/page/TableSupport.java index 3bb552f4..48b543c5 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/page/TableSupport.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/page/TableSupport.java @@ -5,11 +5,10 @@ import com.fastbee.common.utils.ServletUtils; /** * 表格数据处理 - * + * * @author ruoyi */ -public class TableSupport -{ +public class TableSupport { /** * 当前记录起始索引 */ @@ -38,8 +37,7 @@ public class TableSupport /** * 封装分页对象 */ - public static PageDomain getPageDomain() - { + public static PageDomain getPageDomain() { PageDomain pageDomain = new PageDomain(); pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1)); pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10)); @@ -49,8 +47,7 @@ public class TableSupport return pageDomain; } - public static PageDomain buildPageRequest() - { + public static PageDomain buildPageRequest() { return getPageDomain(); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/protocol/Message.java b/fastbee-common/src/main/java/com/fastbee/common/core/protocol/Message.java index 741e1241..ccdf825a 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/protocol/Message.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/protocol/Message.java @@ -14,12 +14,14 @@ import java.io.Serializable; public class Message implements Serializable { /*获取客户端id*/ - public String clientId; + public String clientId; /*消息类型*/ public String messageId; /*消息流水号*/ public String serNo; - /**消息通道id*/ + /** + * 消息通道id + */ public String channelId; public ByteBuf payload; diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/protocol/modbus/ModbusCode.java b/fastbee-common/src/main/java/com/fastbee/common/core/protocol/modbus/ModbusCode.java index 383ac3bc..87c4cd9f 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/protocol/modbus/ModbusCode.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/protocol/modbus/ModbusCode.java @@ -6,38 +6,38 @@ import lombok.Getter; /** * Modbus功能码 - * @author bill * + * @author bill + *

* {bit 位操作} * 线圈寄存器: bit对应一个信号的开关状态。功能码里面又分为写单个线圈寄存器和写多个线圈寄存器。对应上面的功能码也就是:0x01 0x05 0x0f * 离散输入寄存器:离散输入寄存器就 是 只读线圈寄存器,每个bit表示一个开关量,是不能够写的。 功能码: 0x02 - * + *

* {byte 字节操作} * 保持寄存器: 两个byte,可读写的 写也分为单个写和多个写对应的三个:0x03 0x06 0x10 * 输入寄存器: 和保持寄存器类似,只支持读而不能写,一般是读取各种实时数据。一个寄存器也是占据两个byte的空间。对应的功能码: 0x04 - * */ @Getter @AllArgsConstructor public enum ModbusCode { - Read01("读线圈",(byte) 0x01,"1"), // 读线圈(读写位模式) - Read02("读离散量输入",(byte) 0x02,"2"), // 读离散量输入(位只读模式) - Read03("读保持寄存器",(byte) 0x03,"3"), // 读保持寄存器(字节读写模式) - Read04("读输入寄存器",(byte) 0x04,"4"), // 读输入寄存器(字节只读模式) + Read01("读线圈", (byte) 0x01, "1"), // 读线圈(读写位模式) + Read02("读离散量输入", (byte) 0x02, "2"), // 读离散量输入(位只读模式) + Read03("读保持寄存器", (byte) 0x03, "3"), // 读保持寄存器(字节读写模式) + Read04("读输入寄存器", (byte) 0x04, "4"), // 读输入寄存器(字节只读模式) - Write05("写单个线圈(读写位模式)",(byte) 0x05,"5"), // 写单个线圈(读写位模式) - Write06("写多个线圈",(byte) 0x06,"6"), // 写单个保持寄存器 - Write0F("写多个线圈",(byte) 0x0F,"15"), // 写多个线圈 - Write10("写多个保持寄存器",(byte) 0x10,"16"), // 写多个保持寄存器 - UnKnow("未知功能码",(byte)0x0000,"100"); + Write05("写单个线圈(读写位模式)", (byte) 0x05, "5"), // 写单个线圈(读写位模式) + Write06("写多个线圈", (byte) 0x06, "6"), // 写单个保持寄存器 + Write0F("写多个线圈", (byte) 0x0F, "15"), // 写多个线圈 + Write10("写多个保持寄存器", (byte) 0x10, "16"), // 写多个保持寄存器 + UnKnow("未知功能码", (byte) 0x0000, "100"); private String desc; private byte code; private String hex; public static ModbusCode getInstance(int code) { - switch ((byte)code) { + switch ((byte) code) { case 0x01: return Read01; case 0x02: @@ -61,8 +61,8 @@ public enum ModbusCode { } } - public static String getDes(int code){ - switch ((byte)code) { + public static String getDes(int code) { + switch ((byte) code) { case 0x01: return Read01.desc; case 0x02: diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/redis/RedisCache.java b/fastbee-common/src/main/java/com/fastbee/common/core/redis/RedisCache.java index 2ae525d8..555b4702 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/redis/RedisCache.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/redis/RedisCache.java @@ -385,7 +385,7 @@ public class RedisCache { public boolean zRem(String key, Object... values) { try { Long aLong = stringRedisTemplate.opsForZSet().remove(key, values); - return aLong != null ? true : false; + return aLong != null; } catch (Exception e) { e.printStackTrace(); return false; @@ -469,7 +469,7 @@ public class RedisCache { public Set zRange(String key, long start, long end) { try { return stringRedisTemplate.opsForZSet().range(key, start, end); - }catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return null; } @@ -630,7 +630,7 @@ public class RedisCache { /** * 批量获取匹配触发器的物模型值 * - * @param productId productId + * @param productId productId * @param operator 操作符 * @param triggerValue 触发的值 * @return @@ -642,9 +642,9 @@ public class RedisCache { Map mapList = new HashMap<>(); while (it.hasNext()) { String key = it.next(); - String value = CheckMatchByCacheKey(key,operator,id,triggerValue); - if(!Objects.equals(value, "")) { - mapList.put(key,value); + String value = CheckMatchByCacheKey(key, operator, id, triggerValue); + if (!Objects.equals(value, "")) { + mapList.put(key, value); } } return mapList; @@ -694,7 +694,7 @@ public class RedisCache { if (result == null) { return new HashMap<>(0); } - String ans = new String((byte[]) result); + String ans = new String(result); mapList.put(key, ans); } return mapList; @@ -778,10 +778,7 @@ public class RedisCache { private boolean isNumeric(String str) { Pattern pattern = compile("[0-9]*\\.?[0-9]+"); Matcher isNum = pattern.matcher(str); - if (!isNum.matches()) { - return false; - } - return true; + return isNum.matches(); } public void publish(Object message, String channel) { diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/redis/RedisKeyBuilder.java b/fastbee-common/src/main/java/com/fastbee/common/core/redis/RedisKeyBuilder.java index 83e77d17..d0634bb7 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/redis/RedisKeyBuilder.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/redis/RedisKeyBuilder.java @@ -10,30 +10,38 @@ import com.fastbee.common.constant.FastBeeConstant; */ public class RedisKeyBuilder { - /**设备在线列表缓存key*/ - public static String buildDeviceOnlineListKey(){ - return FastBeeConstant.REDIS.DEVICE_ONLINE_LIST; + /** + * 设备在线列表缓存key + */ + public static String buildDeviceOnlineListKey() { + return FastBeeConstant.REDIS.DEVICE_ONLINE_LIST; } - /**设备实时数据key*/ - public static String buildDeviceRtCacheKey(String serialNumber){ + /** + * 设备实时数据key + */ + public static String buildDeviceRtCacheKey(String serialNumber) { return FastBeeConstant.REDIS.DEVICE_RUNTIME_DATA + serialNumber; } /** * 设备通讯协议参数 */ - public static String buildDeviceRtParamsKey(String serialNumber){ + public static String buildDeviceRtParamsKey(String serialNumber) { return FastBeeConstant.REDIS.DEVICE_PROTOCOL_PARAM + serialNumber; } - /**固件版本缓存key*/ - public static String buildFirmwareCachedKey(Long firmwareId){ - return FastBeeConstant.REDIS.FIRMWARE_VERSION + firmwareId; + /** + * 固件版本缓存key + */ + public static String buildFirmwareCachedKey(Long firmwareId) { + return FastBeeConstant.REDIS.FIRMWARE_VERSION + firmwareId; } - /**属性读取回调缓存key*/ - public static String buildPropReadCacheKey(String serialNumber){ + /** + * 属性读取回调缓存key + */ + public static String buildPropReadCacheKey(String serialNumber) { return FastBeeConstant.REDIS.PROP_READ_STORE + serialNumber; } @@ -41,7 +49,7 @@ public class RedisKeyBuilder { * 物模型值命名缓存key * Key:TSLV:{productId}_{deviceNumber} HKey:{identity#V/identity#S/identity#M/identity#N} */ - public static String buildTSLVCacheKey(Long productId,String serialNumber){ + public static String buildTSLVCacheKey(Long productId, String serialNumber) { return FastBeeConstant.REDIS.DEVICE_PRE_KEY + productId + "_" + serialNumber.toUpperCase(); } @@ -49,88 +57,104 @@ public class RedisKeyBuilder { * 物模型缓存key * 物模型命名空间:Key:TSL:{productId} hkey: identity value: thingsModel */ - public static String buildTSLCacheKey(Long productId){ + public static String buildTSLCacheKey(Long productId) { return FastBeeConstant.REDIS.TSL_PRE_KEY + productId; } - public static String buildModbusKey(Long productId){ + public static String buildModbusKey(Long productId) { return FastBeeConstant.REDIS.MODBUS_PRE_KEY + productId; } - /**录像缓存key*/ - public static String buildSipRecordinfoCacheKey(String recordKey){ + /** + * 录像缓存key + */ + public static String buildSipRecordinfoCacheKey(String recordKey) { return FastBeeConstant.REDIS.RECORDINFO_KEY + recordKey; } - /**设备id缓存key*/ - public static String buildSipDeviceidCacheKey(String id){ + /** + * 设备id缓存key + */ + public static String buildSipDeviceidCacheKey(String id) { return FastBeeConstant.REDIS.DEVICEID_KEY + id; } - /**ipCSEQ缓存key*/ - public static String buildStreamCacheKey(String steamId){ + + /** + * ipCSEQ缓存key + */ + public static String buildStreamCacheKey(String steamId) { return FastBeeConstant.REDIS.STREAM_KEY + steamId; } - public static String buildStreamCacheKey(String deviceId, String channelId, String stream, String ssrc){ + public static String buildStreamCacheKey(String deviceId, String channelId, String stream, String ssrc) { return FastBeeConstant.REDIS.STREAM_KEY + deviceId + ":" + channelId + ":" + stream + ":" + ssrc; } - public static String buildInviteCacheKey(String type, String deviceId, String channelId, String stream, String ssrc){ - return FastBeeConstant.REDIS.INVITE_KEY + type + ":"+ deviceId + ":" + channelId + ":" + stream + ":" + ssrc; + public static String buildInviteCacheKey(String type, String deviceId, String channelId, String stream, String ssrc) { + return FastBeeConstant.REDIS.INVITE_KEY + type + ":" + deviceId + ":" + channelId + ":" + stream + ":" + ssrc; } - /**ipCSEQ缓存key*/ - public static String buildSipCSEQCacheKey(String CSEQ){ + /** + * ipCSEQ缓存key + */ + public static String buildSipCSEQCacheKey(String CSEQ) { return FastBeeConstant.REDIS.SIP_CSEQ_PREFIX + CSEQ; } - /**rule静默时间缓存key*/ - public static String buildSilentTimeacheKey(String key){ + /** + * rule静默时间缓存key + */ + public static String buildSilentTimeacheKey(String key) { return FastBeeConstant.REDIS.RULE_SILENT_TIME + key; } - /**modbus指令缓存key*/ - public static String buildModbusPollCacheKey(String serialNumebr){ + /** + * modbus指令缓存key + */ + public static String buildModbusPollCacheKey(String serialNumebr) { return FastBeeConstant.REDIS.POLL_MODBUS_KEY + serialNumebr; } + /*缓存设备下发指令消息ID*/ - public static String buildDownMessageIdCacheKey(String serialNumber){ + public static String buildDownMessageIdCacheKey(String serialNumber) { return FastBeeConstant.REDIS.DEVICE_MESSAGE_ID + serialNumber; } /** * 缓存产品id,设备编号,协议编号 */ - public static String buildDeviceMsgCacheKey(String serialNumber){ + public static String buildDeviceMsgCacheKey(String serialNumber) { return FastBeeConstant.REDIS.DEVICE_MSG + serialNumber; } /** * 缓存产品id,设备编号,协议编号 */ - public static String buildSceneModelTagCacheKey(Long sceneModelId){ + public static String buildSceneModelTagCacheKey(Long sceneModelId) { return FastBeeConstant.REDIS.SCENE_MODEL_TAG_ID + sceneModelId; } - public static String buildModbusRuntimeCacheKey(String serialNumber){ + public static String buildModbusRuntimeCacheKey(String serialNumber) { return FastBeeConstant.REDIS.MODBUS_RUNTIME + serialNumber; } - public static String buildModbusLockCacheKey(String serialNumber){ + public static String buildModbusLockCacheKey(String serialNumber) { return FastBeeConstant.REDIS.MODBUS_LOCK + serialNumber; } - public static String buildModbusTcpCacheKey(String serialNumber){ + public static String buildModbusTcpCacheKey(String serialNumber) { return FastBeeConstant.REDIS.MODBUS_TCP + serialNumber; } - public static String buildModbusTcpRuntimeCacheKey(String serialNumber){ + public static String buildModbusTcpRuntimeCacheKey(String serialNumber) { return FastBeeConstant.REDIS.MODBUS_TCP_RUNTIME + serialNumber; } - /**设备OTA升级实时数据*/ - public static String buildDeviceOtaKey(String serialNumber){ + /** + * 设备OTA升级实时数据 + */ + public static String buildDeviceOtaKey(String serialNumber) { return CacheConstants.DEVICE_OTA_DATA + serialNumber; } @@ -138,7 +162,7 @@ public class RedisKeyBuilder { * 设备上电触发指令缓存key * 用于存储设备上电触发任务下发的指令片段(索引2到11位) */ - public static String buildPowerOnTriggerCommandKey(String serialNumber){ + public static String buildPowerOnTriggerCommandKey(String serialNumber) { return FastBeeConstant.REDIS.POWER_ON_TRIGGER_COMMAND + serialNumber.toUpperCase(); } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/redis/RedisKeyDefine.java b/fastbee-common/src/main/java/com/fastbee/common/core/redis/RedisKeyDefine.java index d550069a..a9991fb0 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/redis/RedisKeyDefine.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/redis/RedisKeyDefine.java @@ -15,6 +15,63 @@ import java.time.Duration; @Data public class RedisKeyDefine { + /** + * Key 模板 + */ + private final String keyTemplate; + /** + * Key 类型的枚举 + */ + private final KeyTypeEnum keyType; + /** + * Value 类型 + *

+ * 如果是使用分布式锁,设置为 {@link java.util.concurrent.locks.Lock} 类型 + */ + private final Class valueType; + /** + * 超时类型 + */ + private final TimeoutTypeEnum timeoutType; + /** + * 过期时间 + */ + private final Duration timeout; + /** + * 备注 + */ + private final String memo; + private RedisKeyDefine(String memo, String keyTemplate, KeyTypeEnum keyType, Class valueType, + TimeoutTypeEnum timeoutType, Duration timeout) { + this.memo = memo; + this.keyTemplate = keyTemplate; + this.keyType = keyType; + this.valueType = valueType; + this.timeout = timeout; + this.timeoutType = timeoutType; + // 添加注册表 + RedisKeyRegistry.add(this); + } + public RedisKeyDefine(String memo, String keyTemplate, KeyTypeEnum keyType, Class valueType, Duration timeout) { + this(memo, keyTemplate, keyType, valueType, TimeoutTypeEnum.FIXED, timeout); + } + + public RedisKeyDefine(String memo, String keyTemplate, KeyTypeEnum keyType, Class valueType, TimeoutTypeEnum timeoutType) { + this(memo, keyTemplate, keyType, valueType, timeoutType, Duration.ZERO); + } + + /** + * 格式化 Key + *

+ * 注意,内部采用 {@link String#format(String, Object...)} 实现 + * + * @param args 格式化的参数 + * @return Key + */ + public String formatKey(Object... args) { + return String.format(keyTemplate, args); + } + @Getter @AllArgsConstructor public enum KeyTypeEnum { @@ -51,63 +108,4 @@ public class RedisKeyDefine { } - /** - * Key 模板 - */ - private final String keyTemplate; - /** - * Key 类型的枚举 - */ - private final KeyTypeEnum keyType; - /** - * Value 类型 - * - * 如果是使用分布式锁,设置为 {@link java.util.concurrent.locks.Lock} 类型 - */ - private final Class valueType; - /** - * 超时类型 - */ - private final TimeoutTypeEnum timeoutType; - /** - * 过期时间 - */ - private final Duration timeout; - /** - * 备注 - */ - private final String memo; - - private RedisKeyDefine(String memo, String keyTemplate, KeyTypeEnum keyType, Class valueType, - TimeoutTypeEnum timeoutType, Duration timeout) { - this.memo = memo; - this.keyTemplate = keyTemplate; - this.keyType = keyType; - this.valueType = valueType; - this.timeout = timeout; - this.timeoutType = timeoutType; - // 添加注册表 - RedisKeyRegistry.add(this); - } - - public RedisKeyDefine(String memo, String keyTemplate, KeyTypeEnum keyType, Class valueType, Duration timeout) { - this(memo, keyTemplate, keyType, valueType, TimeoutTypeEnum.FIXED, timeout); - } - - public RedisKeyDefine(String memo, String keyTemplate, KeyTypeEnum keyType, Class valueType, TimeoutTypeEnum timeoutType) { - this(memo, keyTemplate, keyType, valueType, timeoutType, Duration.ZERO); - } - - /** - * 格式化 Key - * - * 注意,内部采用 {@link String#format(String, Object...)} 实现 - * - * @param args 格式化的参数 - * @return Key - */ - public String formatKey(Object... args) { - return String.format(keyTemplate, args); - } - } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/text/CharsetKit.java b/fastbee-common/src/main/java/com/fastbee/common/core/text/CharsetKit.java index fcf26811..9c8627b5 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/text/CharsetKit.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/text/CharsetKit.java @@ -7,71 +7,76 @@ import java.nio.charset.StandardCharsets; /** * 字符集工具类 - * + * * @author ruoyi */ -public class CharsetKit -{ - /** ISO-8859-1 */ +public class CharsetKit { + /** + * ISO-8859-1 + */ public static final String ISO_8859_1 = "ISO-8859-1"; - /** UTF-8 */ + /** + * UTF-8 + */ public static final String UTF_8 = "UTF-8"; - /** GBK */ + /** + * GBK + */ public static final String GBK = "GBK"; - /** ISO-8859-1 */ - public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1); - /** UTF-8 */ - public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8); - /** GBK */ + /** + * ISO-8859-1 + */ + public static final Charset CHARSET_ISO_8859_1 = StandardCharsets.ISO_8859_1; + /** + * UTF-8 + */ + public static final Charset CHARSET_UTF_8 = StandardCharsets.UTF_8; + /** + * GBK + */ public static final Charset CHARSET_GBK = Charset.forName(GBK); /** * 转换为Charset对象 - * + * * @param charset 字符集,为空则返回默认字符集 * @return Charset */ - public static Charset charset(String charset) - { + public static Charset charset(String charset) { return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset); } /** * 转换字符串的字符集编码 - * - * @param source 字符串 - * @param srcCharset 源字符集,默认ISO-8859-1 + * + * @param source 字符串 + * @param srcCharset 源字符集,默认ISO-8859-1 * @param destCharset 目标字符集,默认UTF-8 * @return 转换后的字符集 */ - public static String convert(String source, String srcCharset, String destCharset) - { + public static String convert(String source, String srcCharset, String destCharset) { return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset)); } /** * 转换字符串的字符集编码 - * - * @param source 字符串 - * @param srcCharset 源字符集,默认ISO-8859-1 + * + * @param source 字符串 + * @param srcCharset 源字符集,默认ISO-8859-1 * @param destCharset 目标字符集,默认UTF-8 * @return 转换后的字符集 */ - public static String convert(String source, Charset srcCharset, Charset destCharset) - { - if (null == srcCharset) - { + public static String convert(String source, Charset srcCharset, Charset destCharset) { + if (null == srcCharset) { srcCharset = StandardCharsets.ISO_8859_1; } - if (null == destCharset) - { + if (null == destCharset) { destCharset = StandardCharsets.UTF_8; } - if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) - { + if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) { return source; } return new String(source.getBytes(srcCharset), destCharset); @@ -80,8 +85,7 @@ public class CharsetKit /** * @return 系统字符集编码 */ - public static String systemCharset() - { + public static String systemCharset() { return Charset.defaultCharset().name(); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/text/Convert.java b/fastbee-common/src/main/java/com/fastbee/common/core/text/Convert.java index 75ea7349..a8840850 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/text/Convert.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/text/Convert.java @@ -15,25 +15,21 @@ import java.util.Set; * * @author ruoyi */ -public class Convert -{ +public class Convert { /** * 转换为字符串
* 如果给定的值为null,或者转换失败,返回默认值
* 转换失败不会报错 * - * @param value 被转换的值 + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static String toStr(Object value, String defaultValue) - { - if (null == value) - { + public static String toStr(Object value, String defaultValue) { + if (null == value) { return defaultValue; } - if (value instanceof String) - { + if (value instanceof String) { return (String) value; } return value.toString(); @@ -47,8 +43,7 @@ public class Convert * @param value 被转换的值 * @return 结果 */ - public static String toStr(Object value) - { + public static String toStr(Object value) { return toStr(value, null); } @@ -57,18 +52,15 @@ public class Convert * 如果给定的值为null,或者转换失败,返回默认值
* 转换失败不会报错 * - * @param value 被转换的值 + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Character toChar(Object value, Character defaultValue) - { - if (null == value) - { + public static Character toChar(Object value, Character defaultValue) { + if (null == value) { return defaultValue; } - if (value instanceof Character) - { + if (value instanceof Character) { return (Character) value; } @@ -84,8 +76,7 @@ public class Convert * @param value 被转换的值 * @return 结果 */ - public static Character toChar(Object value) - { + public static Character toChar(Object value) { return toChar(value, null); } @@ -94,35 +85,27 @@ public class Convert * 如果给定的值为null,或者转换失败,返回默认值
* 转换失败不会报错 * - * @param value 被转换的值 + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Byte toByte(Object value, Byte defaultValue) - { - if (value == null) - { + public static Byte toByte(Object value, Byte defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Byte) - { + if (value instanceof Byte) { return (Byte) value; } - if (value instanceof Number) - { + if (value instanceof Number) { return ((Number) value).byteValue(); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return Byte.parseByte(valueStr); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -135,8 +118,7 @@ public class Convert * @param value 被转换的值 * @return 结果 */ - public static Byte toByte(Object value) - { + public static Byte toByte(Object value) { return toByte(value, null); } @@ -145,35 +127,27 @@ public class Convert * 如果给定的值为null,或者转换失败,返回默认值
* 转换失败不会报错 * - * @param value 被转换的值 + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Short toShort(Object value, Short defaultValue) - { - if (value == null) - { + public static Short toShort(Object value, Short defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Short) - { + if (value instanceof Short) { return (Short) value; } - if (value instanceof Number) - { + if (value instanceof Number) { return ((Number) value).shortValue(); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return Short.parseShort(valueStr.trim()); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -186,8 +160,7 @@ public class Convert * @param value 被转换的值 * @return 结果 */ - public static Short toShort(Object value) - { + public static Short toShort(Object value) { return toShort(value, null); } @@ -196,31 +169,24 @@ public class Convert * 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 * - * @param value 被转换的值 + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Number toNumber(Object value, Number defaultValue) - { - if (value == null) - { + public static Number toNumber(Object value, Number defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Number) - { + if (value instanceof Number) { return (Number) value; } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return NumberFormat.getInstance().parse(valueStr); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -233,8 +199,7 @@ public class Convert * @param value 被转换的值 * @return 结果 */ - public static Number toNumber(Object value) - { + public static Number toNumber(Object value) { return toNumber(value, null); } @@ -243,35 +208,27 @@ public class Convert * 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 * - * @param value 被转换的值 + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Integer toInt(Object value, Integer defaultValue) - { - if (value == null) - { + public static Integer toInt(Object value, Integer defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Integer) - { + if (value instanceof Integer) { return (Integer) value; } - if (value instanceof Number) - { + if (value instanceof Number) { return ((Number) value).intValue(); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return Integer.parseInt(valueStr.trim()); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -284,8 +241,7 @@ public class Convert * @param value 被转换的值 * @return 结果 */ - public static Integer toInt(Object value) - { + public static Integer toInt(Object value) { return toInt(value, null); } @@ -295,8 +251,7 @@ public class Convert * @param str 被转换的值 * @return 结果 */ - public static Integer[] toIntArray(String str) - { + public static Integer[] toIntArray(String str) { return toIntArray(",", str); } @@ -306,8 +261,7 @@ public class Convert * @param str 被转换的值 * @return 结果 */ - public static Long[] toLongArray(String str) - { + public static Long[] toLongArray(String str) { return toLongArray(",", str); } @@ -318,16 +272,13 @@ public class Convert * @param split 被转换的值 * @return 结果 */ - public static Integer[] toIntArray(String split, String str) - { - if (StringUtils.isEmpty(str)) - { - return new Integer[] {}; + public static Integer[] toIntArray(String split, String str) { + if (StringUtils.isEmpty(str)) { + return new Integer[]{}; } String[] arr = str.split(split); final Integer[] ints = new Integer[arr.length]; - for (int i = 0; i < arr.length; i++) - { + for (int i = 0; i < arr.length; i++) { final Integer v = toInt(arr[i], 0); ints[i] = v; } @@ -338,19 +289,16 @@ public class Convert * 转换为Long数组
* * @param split 分隔符 - * @param str 被转换的值 + * @param str 被转换的值 * @return 结果 */ - public static Long[] toLongArray(String split, String str) - { - if (StringUtils.isEmpty(str)) - { - return new Long[] {}; + public static Long[] toLongArray(String split, String str) { + if (StringUtils.isEmpty(str)) { + return new Long[]{}; } String[] arr = str.split(split); final Long[] longs = new Long[arr.length]; - for (int i = 0; i < arr.length; i++) - { + for (int i = 0; i < arr.length; i++) { final Long v = toLong(arr[i], null); longs[i] = v; } @@ -363,8 +311,7 @@ public class Convert * @param str 被转换的值 * @return 结果 */ - public static String[] toStrArray(String str) - { + public static String[] toStrArray(String str) { return toStrArray(",", str); } @@ -375,8 +322,7 @@ public class Convert * @param split 被转换的值 * @return 结果 */ - public static String[] toStrArray(String split, String str) - { + public static String[] toStrArray(String split, String str) { return str.split(split); } @@ -385,36 +331,28 @@ public class Convert * 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 * - * @param value 被转换的值 + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Long toLong(Object value, Long defaultValue) - { - if (value == null) - { + public static Long toLong(Object value, Long defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Long) - { + if (value instanceof Long) { return (Long) value; } - if (value instanceof Number) - { + if (value instanceof Number) { return ((Number) value).longValue(); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { // 支持科学计数法 return new BigDecimal(valueStr.trim()).longValue(); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -427,8 +365,7 @@ public class Convert * @param value 被转换的值 * @return 结果 */ - public static Long toLong(Object value) - { + public static Long toLong(Object value) { return toLong(value, null); } @@ -437,36 +374,28 @@ public class Convert * 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 * - * @param value 被转换的值 + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Double toDouble(Object value, Double defaultValue) - { - if (value == null) - { + public static Double toDouble(Object value, Double defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Double) - { + if (value instanceof Double) { return (Double) value; } - if (value instanceof Number) - { + if (value instanceof Number) { return ((Number) value).doubleValue(); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { // 支持科学计数法 return new BigDecimal(valueStr.trim()).doubleValue(); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -479,8 +408,7 @@ public class Convert * @param value 被转换的值 * @return 结果 */ - public static Double toDouble(Object value) - { + public static Double toDouble(Object value) { return toDouble(value, null); } @@ -489,35 +417,27 @@ public class Convert * 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 * - * @param value 被转换的值 + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Float toFloat(Object value, Float defaultValue) - { - if (value == null) - { + public static Float toFloat(Object value, Float defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Float) - { + if (value instanceof Float) { return (Float) value; } - if (value instanceof Number) - { + if (value instanceof Number) { return ((Number) value).floatValue(); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return Float.parseFloat(valueStr.trim()); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -530,8 +450,7 @@ public class Convert * @param value 被转换的值 * @return 结果 */ - public static Float toFloat(Object value) - { + public static Float toFloat(Object value) { return toFloat(value, null); } @@ -540,28 +459,23 @@ public class Convert * String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 * - * @param value 被转换的值 + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static Boolean toBool(Object value, Boolean defaultValue) - { - if (value == null) - { + public static Boolean toBool(Object value, Boolean defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof Boolean) - { + if (value instanceof Boolean) { return (Boolean) value; } String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } valueStr = valueStr.trim().toLowerCase(); - switch (valueStr) - { + switch (valueStr) { case "true": case "yes": case "ok": @@ -584,8 +498,7 @@ public class Convert * @param value 被转换的值 * @return 结果 */ - public static Boolean toBool(Object value) - { + public static Boolean toBool(Object value) { return toBool(value, null); } @@ -593,34 +506,27 @@ public class Convert * 转换为Enum对象
* 如果给定的值为空,或者转换失败,返回默认值
* - * @param clazz Enum的Class - * @param value 值 + * @param clazz Enum的Class + * @param value 值 * @param defaultValue 默认值 * @return Enum */ - public static > E toEnum(Class clazz, Object value, E defaultValue) - { - if (value == null) - { + public static > E toEnum(Class clazz, Object value, E defaultValue) { + if (value == null) { return defaultValue; } - if (clazz.isAssignableFrom(value.getClass())) - { + if (clazz.isAssignableFrom(value.getClass())) { @SuppressWarnings("unchecked") E myE = (E) value; return myE; } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return Enum.valueOf(clazz, valueStr); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -633,8 +539,7 @@ public class Convert * @param value 值 * @return Enum */ - public static > E toEnum(Class clazz, Object value) - { + public static > E toEnum(Class clazz, Object value) { return toEnum(clazz, value, null); } @@ -643,35 +548,27 @@ public class Convert * 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 * - * @param value 被转换的值 + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static BigInteger toBigInteger(Object value, BigInteger defaultValue) - { - if (value == null) - { + public static BigInteger toBigInteger(Object value, BigInteger defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof BigInteger) - { + if (value instanceof BigInteger) { return (BigInteger) value; } - if (value instanceof Long) - { + if (value instanceof Long) { return BigInteger.valueOf((Long) value); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return new BigInteger(valueStr); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -684,8 +581,7 @@ public class Convert * @param value 被转换的值 * @return 结果 */ - public static BigInteger toBigInteger(Object value) - { + public static BigInteger toBigInteger(Object value) { return toBigInteger(value, null); } @@ -694,43 +590,33 @@ public class Convert * 如果给定的值为空,或者转换失败,返回默认值
* 转换失败不会报错 * - * @param value 被转换的值 + * @param value 被转换的值 * @param defaultValue 转换错误时的默认值 * @return 结果 */ - public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) - { - if (value == null) - { + public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) { + if (value == null) { return defaultValue; } - if (value instanceof BigDecimal) - { + if (value instanceof BigDecimal) { return (BigDecimal) value; } - if (value instanceof Long) - { + if (value instanceof Long) { return new BigDecimal((Long) value); } - if (value instanceof Double) - { + if (value instanceof Double) { return BigDecimal.valueOf((Double) value); } - if (value instanceof Integer) - { + if (value instanceof Integer) { return new BigDecimal((Integer) value); } final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { + if (StringUtils.isEmpty(valueStr)) { return defaultValue; } - try - { + try { return new BigDecimal(valueStr); - } - catch (Exception e) - { + } catch (Exception e) { return defaultValue; } } @@ -743,8 +629,7 @@ public class Convert * @param value 被转换的值 * @return 结果 */ - public static BigDecimal toBigDecimal(Object value) - { + public static BigDecimal toBigDecimal(Object value) { return toBigDecimal(value, null); } @@ -755,8 +640,7 @@ public class Convert * @param obj 对象 * @return 字符串 */ - public static String utf8Str(Object obj) - { + public static String utf8Str(Object obj) { return str(obj, CharsetKit.CHARSET_UTF_8); } @@ -764,12 +648,11 @@ public class Convert * 将对象转为字符串
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 * - * @param obj 对象 + * @param obj 对象 * @param charsetName 字符集 * @return 字符串 */ - public static String str(Object obj, String charsetName) - { + public static String str(Object obj, String charsetName) { return str(obj, Charset.forName(charsetName)); } @@ -777,32 +660,23 @@ public class Convert * 将对象转为字符串
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 * - * @param obj 对象 + * @param obj 对象 * @param charset 字符集 * @return 字符串 */ - public static String str(Object obj, Charset charset) - { - if (null == obj) - { + public static String str(Object obj, Charset charset) { + if (null == obj) { return null; } - if (obj instanceof String) - { + if (obj instanceof String) { return (String) obj; - } - else if (obj instanceof byte[]) - { + } else if (obj instanceof byte[]) { return str((byte[]) obj, charset); - } - else if (obj instanceof Byte[]) - { + } else if (obj instanceof Byte[]) { byte[] bytes = ArrayUtils.toPrimitive((Byte[]) obj); return str(bytes, charset); - } - else if (obj instanceof ByteBuffer) - { + } else if (obj instanceof ByteBuffer) { return str((ByteBuffer) obj, charset); } return obj.toString(); @@ -811,31 +685,27 @@ public class Convert /** * 将byte数组转为字符串 * - * @param bytes byte数组 + * @param bytes byte数组 * @param charset 字符集 * @return 字符串 */ - public static String str(byte[] bytes, String charset) - { + public static String str(byte[] bytes, String charset) { return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset)); } /** * 解码字节码 * - * @param data 字符串 + * @param data 字符串 * @param charset 字符集,如果此字段为空,则解码的结果取决于平台 * @return 解码后的字符串 */ - public static String str(byte[] data, Charset charset) - { - if (data == null) - { + public static String str(byte[] data, Charset charset) { + if (data == null) { return null; } - if (null == charset) - { + if (null == charset) { return new String(data); } return new String(data, charset); @@ -844,14 +714,12 @@ public class Convert /** * 将编码的byteBuffer数据转换为字符串 * - * @param data 数据 + * @param data 数据 * @param charset 字符集,如果为空使用当前系统字符集 * @return 字符串 */ - public static String str(ByteBuffer data, String charset) - { - if (data == null) - { + public static String str(ByteBuffer data, String charset) { + if (data == null) { return null; } @@ -861,55 +729,47 @@ public class Convert /** * 将编码的byteBuffer数据转换为字符串 * - * @param data 数据 + * @param data 数据 * @param charset 字符集,如果为空使用当前系统字符集 * @return 字符串 */ - public static String str(ByteBuffer data, Charset charset) - { - if (null == charset) - { + public static String str(ByteBuffer data, Charset charset) { + if (null == charset) { charset = Charset.defaultCharset(); } return charset.decode(data).toString(); } // ----------------------------------------------------------------------- 全角半角转换 + /** * 半角转全角 * * @param input String. * @return 全角字符串. */ - public static String toSBC(String input) - { + public static String toSBC(String input) { return toSBC(input, null); } /** * 半角转全角 * - * @param input String + * @param input String * @param notConvertSet 不替换的字符集合 * @return 全角字符串. */ - public static String toSBC(String input, Set notConvertSet) - { + public static String toSBC(String input, Set notConvertSet) { char[] c = input.toCharArray(); - for (int i = 0; i < c.length; i++) - { - if (null != notConvertSet && notConvertSet.contains(c[i])) - { + for (int i = 0; i < c.length; i++) { + if (null != notConvertSet && notConvertSet.contains(c[i])) { // 跳过不替换的字符 continue; } - if (c[i] == ' ') - { + if (c[i] == ' ') { c[i] = '\u3000'; - } - else if (c[i] < '\177') - { + } else if (c[i] < '\177') { c[i] = (char) (c[i] + 65248); } @@ -923,35 +783,28 @@ public class Convert * @param input String. * @return 半角字符串 */ - public static String toDBC(String input) - { + public static String toDBC(String input) { return toDBC(input, null); } /** * 替换全角为半角 * - * @param text 文本 + * @param text 文本 * @param notConvertSet 不替换的字符集合 * @return 替换后的字符 */ - public static String toDBC(String text, Set notConvertSet) - { + public static String toDBC(String text, Set notConvertSet) { char[] c = text.toCharArray(); - for (int i = 0; i < c.length; i++) - { - if (null != notConvertSet && notConvertSet.contains(c[i])) - { + for (int i = 0; i < c.length; i++) { + if (null != notConvertSet && notConvertSet.contains(c[i])) { // 跳过不替换的字符 continue; } - if (c[i] == '\u3000') - { + if (c[i] == '\u3000') { c[i] = ' '; - } - else if (c[i] > '\uFF00' && c[i] < '\uFF5F') - { + } else if (c[i] > '\uFF00' && c[i] < '\uFF5F') { c[i] = (char) (c[i] - 65248); } } @@ -966,31 +819,26 @@ public class Convert * @param n 数字 * @return 中文大写数字 */ - public static String digitUppercase(double n) - { - String[] fraction = { "角", "分" }; - String[] digit = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; - String[][] unit = { { "元", "万", "亿" }, { "", "拾", "佰", "仟" } }; + public static String digitUppercase(double n) { + String[] fraction = {"角", "分"}; + String[] digit = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"}; + String[][] unit = {{"元", "万", "亿"}, {"", "拾", "佰", "仟"}}; String head = n < 0 ? "负" : ""; n = Math.abs(n); String s = ""; - for (int i = 0; i < fraction.length; i++) - { + for (int i = 0; i < fraction.length; i++) { s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", ""); } - if (s.length() < 1) - { + if (s.length() < 1) { s = "整"; } int integerPart = (int) Math.floor(n); - for (int i = 0; i < unit[0].length && integerPart > 0; i++) - { + for (int i = 0; i < unit[0].length && integerPart > 0; i++) { String p = ""; - for (int j = 0; j < unit[1].length && n > 0; j++) - { + for (int j = 0; j < unit[1].length && n > 0; j++) { p = digit[integerPart % 10] + unit[1][j] + p; integerPart = integerPart / 10; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/text/StrFormatter.java b/fastbee-common/src/main/java/com/fastbee/common/core/text/StrFormatter.java index 5453375c..48dd849f 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/text/StrFormatter.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/text/StrFormatter.java @@ -4,11 +4,10 @@ import com.fastbee.common.utils.StringUtils; /** * 字符串格式化 - * + * * @author ruoyi */ -public class StrFormatter -{ +public class StrFormatter { public static final String EMPTY_JSON = "{}"; public static final char C_BACKSLASH = '\\'; public static final char C_DELIM_START = '{'; @@ -22,15 +21,13 @@ public class StrFormatter * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b
- * + * * @param strPattern 字符串模板 - * @param argArray 参数列表 + * @param argArray 参数列表 * @return 结果 */ - public static String format(final String strPattern, final Object... argArray) - { - if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) - { + public static String format(final String strPattern, final Object... argArray) { + if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) { return strPattern; } final int strPatternLength = strPattern.length(); @@ -40,43 +37,30 @@ public class StrFormatter int handledPosition = 0; int delimIndex;// 占位符所在位置 - for (int argIndex = 0; argIndex < argArray.length; argIndex++) - { + for (int argIndex = 0; argIndex < argArray.length; argIndex++) { delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition); - if (delimIndex == -1) - { - if (handledPosition == 0) - { + if (delimIndex == -1) { + if (handledPosition == 0) { return strPattern; - } - else - { // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果 + } else { // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果 sbuf.append(strPattern, handledPosition, strPatternLength); return sbuf.toString(); } - } - else - { - if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH) - { - if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH) - { + } else { + if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH) { + if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH) { // 转义符之前还有一个转义符,占位符依旧有效 sbuf.append(strPattern, handledPosition, delimIndex - 1); sbuf.append(Convert.utf8Str(argArray[argIndex])); handledPosition = delimIndex + 2; - } - else - { + } else { // 占位符被转义 argIndex--; sbuf.append(strPattern, handledPosition, delimIndex - 1); sbuf.append(C_DELIM_START); handledPosition = delimIndex + 1; } - } - else - { + } else { // 正常占位符 sbuf.append(strPattern, handledPosition, delimIndex); sbuf.append(Convert.utf8Str(argArray[argIndex])); diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/NeuronModel.java b/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/NeuronModel.java index f5d877f5..7de2cbb6 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/NeuronModel.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/NeuronModel.java @@ -8,6 +8,7 @@ import java.util.List; /** * Neuron-JSON格式协议 + * * @author gsb * @date 2023/5/31 16:36 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/SceneThingsModelItem.java b/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/SceneThingsModelItem.java index 7d47659f..d2c633b8 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/SceneThingsModelItem.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/SceneThingsModelItem.java @@ -13,27 +13,40 @@ import lombok.Data; @AllArgsConstructor @Builder @Data -public class SceneThingsModelItem -{ - /** 物模型唯一标识符 */ +public class SceneThingsModelItem { + /** + * 物模型唯一标识符 + */ private String id; - /** 物模型值 */ + /** + * 物模型值 + */ private String value; - /** 类型:1=属性, 2=功能,3=事件, 4=设备升级,5=设备上线,6=设备下线 ,*/ + /** + * 类型:1=属性, 2=功能,3=事件, 4=设备升级,5=设备上线,6=设备下线 , + */ private int type; - /** 脚本ID */ + /** + * 脚本ID + */ private String stripId; - /** 场景ID*/ + /** + * 场景ID + */ private Long sceneId; - /** 产品ID */ + /** + * 产品ID + */ private Long productId; - /** 设备编号 */ + /** + * 设备编号 + */ private String DeviceNumber; /** diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/ThingsModelRuleItem.java b/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/ThingsModelRuleItem.java index f0803c0a..43ccb327 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/ThingsModelRuleItem.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/ThingsModelRuleItem.java @@ -5,13 +5,18 @@ import lombok.Builder; import lombok.Data; import java.util.Date; + @Data @Builder public class ThingsModelRuleItem { - /** 物模型唯一标识符 */ + /** + * 物模型唯一标识符 + */ private String id; - /** 物模型值 */ + /** + * 物模型值 + */ private String value; private String operator; private String triggerValue; @@ -22,7 +27,9 @@ public class ThingsModelRuleItem { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date ts; - /** 备注 **/ + /** + * 备注 + **/ private String remark; private String timestamp; diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/ThingsModelSimpleItem.java b/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/ThingsModelSimpleItem.java index df14a563..0fe2ebd0 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/ThingsModelSimpleItem.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/ThingsModelSimpleItem.java @@ -15,12 +15,15 @@ import java.util.Date; */ @AllArgsConstructor @Builder -public class ThingsModelSimpleItem -{ - /** 物模型唯一标识符 */ +public class ThingsModelSimpleItem { + /** + * 物模型唯一标识符 + */ private String id; - /** 物模型值 */ + /** + * 物模型值 + */ private String value; private String name; @@ -31,14 +34,19 @@ public class ThingsModelSimpleItem @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date ts; - /** 备注 **/ + /** + * 备注 + **/ private String remark; - public ThingsModelSimpleItem(String id, String value , String remark){ - this.id=id; - this.value=value; - this.remark=remark; + public ThingsModelSimpleItem(String id, String value, String remark) { + this.id = id; + this.value = value; + this.remark = remark; + } + + public ThingsModelSimpleItem() { } public Date getTs() { @@ -46,11 +54,9 @@ public class ThingsModelSimpleItem } public void setTs(Date ts) { - this.ts = ts != null ? ts : DateUtils.getNowDate(); + this.ts = ts != null ? ts : DateUtils.getNowDate(); } - public ThingsModelSimpleItem(){} - public String getRemark() { return remark; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/ThingsModelValuesInput.java b/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/ThingsModelValuesInput.java index 4d14b8f9..51cf6000 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/ThingsModelValuesInput.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/thingsModel/ThingsModelValuesInput.java @@ -8,21 +8,28 @@ import java.util.List; * @author kerwincui * @date 2021-12-16 */ -public class ThingsModelValuesInput -{ - /** 产品ID **/ +public class ThingsModelValuesInput { + /** + * 产品ID + **/ private Long productId; private Long deviceId; - /** 设备ID **/ + /** + * 设备ID + **/ private String deviceNumber; private Integer deviceType; - /** 设备物模型值的集合 **/ + /** + * 设备物模型值的集合 + **/ private List thingsModelSimpleItem; - /** 原始消息数据包(用于判断设备上电触发回包等) **/ + /** + * 原始消息数据包(用于判断设备上电触发回包等) + **/ private Object sources; public Long getDeviceId() { diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/BusinessStatus.java b/fastbee-common/src/main/java/com/fastbee/common/enums/BusinessStatus.java index 4c5bb7fe..3b496d0f 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/BusinessStatus.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/BusinessStatus.java @@ -2,12 +2,10 @@ package com.fastbee.common.enums; /** * 操作状态 - * - * @author ruoyi * + * @author ruoyi */ -public enum BusinessStatus -{ +public enum BusinessStatus { /** * 成功 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/BusinessType.java b/fastbee-common/src/main/java/com/fastbee/common/enums/BusinessType.java index 01aca531..d66d79fb 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/BusinessType.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/BusinessType.java @@ -2,11 +2,10 @@ package com.fastbee.common.enums; /** * 业务操作类型 - * + * * @author ruoyi */ -public enum BusinessType -{ +public enum BusinessType { /** * 其它 */ @@ -51,7 +50,7 @@ public enum BusinessType * 生成代码 */ GENCODE, - + /** * 清空数据 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/CommonStatusEnum.java b/fastbee-common/src/main/java/com/fastbee/common/enums/CommonStatusEnum.java index 111808f6..f3ed4dbf 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/CommonStatusEnum.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/CommonStatusEnum.java @@ -8,7 +8,6 @@ import java.util.Arrays; /** * 通用状态枚举 - */ @Getter @AllArgsConstructor diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/DataEnum.java b/fastbee-common/src/main/java/com/fastbee/common/enums/DataEnum.java index 485a234a..d00600ab 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/DataEnum.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/DataEnum.java @@ -15,19 +15,19 @@ public enum DataEnum { DECIMAL("decimal", "十进制"), DOUBLE("double", "双精度"), - ENUM("enum","枚举"), - BOOLEAN("bool","布尔类型"), - INTEGER("integer","整形"), + ENUM("enum", "枚举"), + BOOLEAN("bool", "布尔类型"), + INTEGER("integer", "整形"), OBJECT("object", "对象"), - STRING("string","字符串"), - ARRAY("array","数组"); + STRING("string", "字符串"), + ARRAY("array", "数组"); String type; String msg; - public static DataEnum convert(String type){ + public static DataEnum convert(String type) { for (DataEnum value : DataEnum.values()) { - if (Objects.equals(value.type, type)){ + if (Objects.equals(value.type, type)) { return value; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/DataSourceType.java b/fastbee-common/src/main/java/com/fastbee/common/enums/DataSourceType.java index 9c251511..b2019023 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/DataSourceType.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/DataSourceType.java @@ -5,8 +5,7 @@ package com.fastbee.common.enums; * * @author ruoyi */ -public enum DataSourceType -{ +public enum DataSourceType { /** * 主库 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceDistributeTypeEnum.java b/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceDistributeTypeEnum.java index 7804f8f2..4f68707b 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceDistributeTypeEnum.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceDistributeTypeEnum.java @@ -5,10 +5,10 @@ import lombok.AllArgsConstructor; import lombok.Getter; /** - * @description: * @author admin - * @date 2024-07-18 14:52 * @version 1.0 + * @description: + * @date 2024-07-18 14:52 */ @Getter @AllArgsConstructor @@ -18,7 +18,7 @@ public enum DeviceDistributeTypeEnum { * 确保唯一,不能重复 */ SELECT(1, "选择分配"), - IMPORT(2,"导入分配"); + IMPORT(2, "导入分配"); /** * 渠道类型 diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceLogTypeEnum.java b/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceLogTypeEnum.java index 961851ac..fb4eb702 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceLogTypeEnum.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceLogTypeEnum.java @@ -7,9 +7,10 @@ import lombok.Getter; * 场景管理物模型、变量类型枚举 * 注意:以下4张表下的variable_type相关字段统一用该枚举,保持一致 * scene_model_tag表、scene_tag_points表、scene_model_device表、scene_model_data表 + * * @author fastb - * @date 2024-05-22 10:01 * @version 1.0 + * @date 2024-05-22 10:01 */ @Getter @AllArgsConstructor @@ -23,7 +24,7 @@ public enum DeviceLogTypeEnum { DEVICE_OFFLINE(6, "设备离线"), SCENE_VARIABLE_REPORT(7, "场景录入、运算变量上报下发"), DATA_PARSE_ERROR(8, "数据解析错误"), - COMMAND_SEND_ERROR(9, "指令发送错误");; + COMMAND_SEND_ERROR(9, "指令发送错误"); private final Integer type; diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceRecordTypeEnum.java b/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceRecordTypeEnum.java index 0d9167b9..e392023d 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceRecordTypeEnum.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceRecordTypeEnum.java @@ -5,10 +5,10 @@ import lombok.AllArgsConstructor; import lombok.Getter; /** - * @description: * @author admin - * @date 2024-07-18 14:52 * @version 1.0 + * @description: + * @date 2024-07-18 14:52 */ @Getter @AllArgsConstructor @@ -18,9 +18,9 @@ public enum DeviceRecordTypeEnum { * 确保唯一,不能重复 */ IMPORT(1, "导入记录"), - RECOVERY(2,"回收记录"), - ASSIGNMENT(3,"分配记录"), - ASSIGNMENT_DETAIL(4,"分配详细记录"); + RECOVERY(2, "回收记录"), + ASSIGNMENT(3, "分配记录"), + ASSIGNMENT_DETAIL(4, "分配详细记录"); /** diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceStatus.java b/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceStatus.java index 7528d752..ed384bdf 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceStatus.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/DeviceStatus.java @@ -7,27 +7,27 @@ import lombok.Getter; @AllArgsConstructor public enum DeviceStatus { - UNACTIVATED(1,"NOTACTIVE","未激活"), - FORBIDDEN(2,"DISABLE","禁用"), - ONLINE(3,"ONLINE","在线"), - OFFLINE(4,"OFFLINE","离线"); + UNACTIVATED(1, "NOTACTIVE", "未激活"), + FORBIDDEN(2, "DISABLE", "禁用"), + ONLINE(3, "ONLINE", "在线"), + OFFLINE(4, "OFFLINE", "离线"); private int type; private String code; private String description; - public static DeviceStatus convert(int type){ + public static DeviceStatus convert(int type) { for (DeviceStatus value : DeviceStatus.values()) { - if (value.type == type){ + if (value.type == type) { return value; } } return null; } - public static DeviceStatus convert(String code){ + public static DeviceStatus convert(String code) { for (DeviceStatus value : DeviceStatus.values()) { - if (value.code.equals(code)){ + if (value.code.equals(code)) { return value; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/ExceptionCode.java b/fastbee-common/src/main/java/com/fastbee/common/enums/ExceptionCode.java index 8ef863db..72fa087e 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/ExceptionCode.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/ExceptionCode.java @@ -11,11 +11,10 @@ import lombok.Getter; @AllArgsConstructor public enum ExceptionCode { - SUCCESS(200,"成功"), - TIMEOUT(400,"超时"), - OFFLINE(404,"设备断线"), - FAIL(500,"失败"); - ; + SUCCESS(200, "成功"), + TIMEOUT(400, "超时"), + OFFLINE(404, "设备断线"), + FAIL(500, "失败"); public int code; public String desc; diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/FunctionReplyStatus.java b/fastbee-common/src/main/java/com/fastbee/common/enums/FunctionReplyStatus.java index 26ebf530..78a963cc 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/FunctionReplyStatus.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/FunctionReplyStatus.java @@ -5,14 +5,15 @@ import lombok.Getter; /** * 设备回调状态 + * * @author bill */ @Getter @AllArgsConstructor public enum FunctionReplyStatus { - SUCCESS(200,"设备执行成功"), - FAIl(201,"指令执行失败"), - UNKNOWN(204,"设备超时未回复"), + SUCCESS(200, "设备执行成功"), + FAIl(201, "指令执行失败"), + UNKNOWN(204, "设备超时未回复"), NORELY(203, "指令下发成功"); int code; diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/GlobalErrorCodeConstants.java b/fastbee-common/src/main/java/com/fastbee/common/enums/GlobalErrorCodeConstants.java index db80a3b9..9a414e3e 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/GlobalErrorCodeConstants.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/GlobalErrorCodeConstants.java @@ -6,7 +6,7 @@ import com.fastbee.common.exception.ErrorCode; /** * 全局错误码枚举 * 0-999 系统异常编码保留 - * + *

* 一般情况下,使用 HTTP 响应状态码 https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Status * 虽然说,HTTP 响应状态码作为业务使用表达能力偏弱,但是使用在系统层面还是非常不错的 * 比较特殊的是,因为之前一直使用 0 作为成功,就不使用 200 啦。 @@ -44,9 +44,9 @@ public interface GlobalErrorCodeConstants { * @param code 错误码 * @return 是否 */ - static boolean isServerErrorCode(Integer code) { - return code != null - && code >= INTERNAL_SERVER_ERROR.getCode() && code <= INTERNAL_SERVER_ERROR.getCode() + 99; - } + static boolean isServerErrorCode(Integer code) { + return code != null + && code >= INTERNAL_SERVER_ERROR.getCode() && code <= INTERNAL_SERVER_ERROR.getCode() + 99; + } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/HttpMethod.java b/fastbee-common/src/main/java/com/fastbee/common/enums/HttpMethod.java index f705502b..9e222df1 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/HttpMethod.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/HttpMethod.java @@ -10,28 +10,23 @@ import java.util.Map; * * @author ruoyi */ -public enum HttpMethod -{ +public enum HttpMethod { GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE; private static final Map mappings = new HashMap<>(16); - static - { - for (HttpMethod httpMethod : values()) - { + static { + for (HttpMethod httpMethod : values()) { mappings.put(httpMethod.name(), httpMethod); } } @Nullable - public static HttpMethod resolve(@Nullable String method) - { + public static HttpMethod resolve(@Nullable String method) { return (method != null ? mappings.get(method) : null); } - public boolean matches(String method) - { + public boolean matches(String method) { return (this == resolve(method)); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/IErrorCode.java b/fastbee-common/src/main/java/com/fastbee/common/enums/IErrorCode.java index becbc41f..692e5713 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/IErrorCode.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/IErrorCode.java @@ -5,10 +5,14 @@ package com.fastbee.common.enums; */ public interface IErrorCode { - /**返回码*/ + /** + * 返回码 + */ int getCode(); - /**返回信息*/ + /** + * 返回信息 + */ String getMessage(); } \ No newline at end of file diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/LimitType.java b/fastbee-common/src/main/java/com/fastbee/common/enums/LimitType.java index 82d8d484..8f6900af 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/LimitType.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/LimitType.java @@ -6,8 +6,7 @@ package com.fastbee.common.enums; * @author ruoyi */ -public enum LimitType -{ +public enum LimitType { /** * 默认策略全局限流 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/ModbusDataType.java b/fastbee-common/src/main/java/com/fastbee/common/enums/ModbusDataType.java index e719614d..8f881b61 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/ModbusDataType.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/ModbusDataType.java @@ -14,22 +14,22 @@ import java.util.Objects; public enum ModbusDataType { - U_SHORT("ushort","16位 无符号"), - SHORT("short","16位 有符号"), - LONG_ABCD("long-ABCD","32位 有符号(ABCD)"), - LONG_CDAB("long-CDAB","32位 有符号(CDAB)"), - U_LONG_ABCD("ulong-ABCD","32位 无符号(ABCD)"), - U_LONG_CDAB("ulong-CDAB","32位 无符号(CDAB)"), - FLOAT_ABCD("float-ABCD","32位 浮点数(ABCD)"), - FLOAT_CDAB("float-CDAB","32位 浮点数(CDAB)"), - BIT("bit","位"); + U_SHORT("ushort", "16位 无符号"), + SHORT("short", "16位 有符号"), + LONG_ABCD("long-ABCD", "32位 有符号(ABCD)"), + LONG_CDAB("long-CDAB", "32位 有符号(CDAB)"), + U_LONG_ABCD("ulong-ABCD", "32位 无符号(ABCD)"), + U_LONG_CDAB("ulong-CDAB", "32位 无符号(CDAB)"), + FLOAT_ABCD("float-ABCD", "32位 浮点数(ABCD)"), + FLOAT_CDAB("float-CDAB", "32位 浮点数(CDAB)"), + BIT("bit", "位"); String type; String msg; - public static ModbusDataType convert(String type){ + public static ModbusDataType convert(String type) { for (ModbusDataType value : ModbusDataType.values()) { - if (Objects.equals(value.type,type)){ + if (Objects.equals(value.type, type)) { return value; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/NotifyChannelEnum.java b/fastbee-common/src/main/java/com/fastbee/common/enums/NotifyChannelEnum.java index 0dff5dd6..b57afd15 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/NotifyChannelEnum.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/NotifyChannelEnum.java @@ -5,10 +5,10 @@ import lombok.AllArgsConstructor; import lombok.Getter; /** - * @description: 通知渠道枚举 * @author fastb - * @date 2023-12-16 17:00 * @version 1.0 + * @description: 通知渠道枚举 + * @date 2023-12-16 17:00 */ @Getter @AllArgsConstructor @@ -18,9 +18,9 @@ public enum NotifyChannelEnum { * 确保唯一,不能重复 */ SMS("sms", "短信"), - VOICE("voice","语音"), - WECHAT("wechat","微信"), - DING_TALK("dingtalk","钉钉"), + VOICE("voice", "语音"), + WECHAT("wechat", "微信"), + DING_TALK("dingtalk", "钉钉"), EMAIL("email", "邮箱"); diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/NotifyChannelProviderEnum.java b/fastbee-common/src/main/java/com/fastbee/common/enums/NotifyChannelProviderEnum.java index 79e3c63c..dd093540 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/NotifyChannelProviderEnum.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/NotifyChannelProviderEnum.java @@ -40,11 +40,11 @@ public enum NotifyChannelProviderEnum { /**** 短信 ******/ SMS_ALIBABA("sms", "alibaba", "阿里云短信", AlibabaConfig.class, AlibabaConfig.class), SMS_TENCENT("sms", "tencent", "腾讯云短信", TencentConfig.class, TencentConfig.class), - SMS_CTYUN("sms", "ctyun","天翼云短信", CtyunConfig.class, CtyunConfig.class), + SMS_CTYUN("sms", "ctyun", "天翼云短信", CtyunConfig.class, CtyunConfig.class), SMS_HUAWEI("sms", "huawei", "华为云短信", HuaweiConfig.class, HuaweiConfig.class), SMS_YUNPIAN("sms", "yunpian", "云片短信", YunpianConfig.class, YunpianConfig.class), - SMS_EMAY("sms", "emay","亿美软通短信", EmayConfig.class, EmayConfig.class), - SMS_CLOOPEN("sms", "cloopen","容连云短信", CloopenConfig.class, CloopenConfig.class), + SMS_EMAY("sms", "emay", "亿美软通短信", EmayConfig.class, EmayConfig.class), + SMS_CLOOPEN("sms", "cloopen", "容连云短信", CloopenConfig.class, CloopenConfig.class), SMS_JDCLOUD("sms", "jdcloud", "京东云短信", JdCloudConfig.class, JdCloudConfig.class), SMS_NETEASE("sms", "netease", "网易云短信", NeteaseConfig.class, NeteaseConfig.class), @@ -151,10 +151,10 @@ public enum NotifyChannelProviderEnum { case EMAIL_QQ: case EMAIL_163: if (EMAIL_QQ.equals(type)) { - configVOList.add(new NotifyConfigVO("smtpServer", "服务器地址", "string","smtp.qq.com")); + configVOList.add(new NotifyConfigVO("smtpServer", "服务器地址", "string", "smtp.qq.com")); } if (EMAIL_163.equals(type)) { - configVOList.add(new NotifyConfigVO("smtpServer", "服务器地址", "string","smtp.163.com")); + configVOList.add(new NotifyConfigVO("smtpServer", "服务器地址", "string", "smtp.163.com")); } configVOList.add(new NotifyConfigVO("port", "端口号", "string", "465")); configVOList.add(new NotifyConfigVO("username", "发件人账号", "string", "")); @@ -162,28 +162,28 @@ public enum NotifyChannelProviderEnum { configVOList.add(new NotifyConfigVO("sslEnable", "是否启动ssl", "boolean", "true")); configVOList.add(new NotifyConfigVO("authEnable", "开启验证", "boolean", "true")); configVOList.add(new NotifyConfigVO("retryInterval", "重试间隔(秒)", "int", "5")); - configVOList.add(new NotifyConfigVO("maxRetries", "重试次数", "int","1")); + configVOList.add(new NotifyConfigVO("maxRetries", "重试次数", "int", "1")); break; case WECHAT_MINI_PROGRAM: case WECHAT_PUBLIC_ACCOUNT: - configVOList.add(new NotifyConfigVO("appId", "appId", "string","")); - configVOList.add(new NotifyConfigVO("appSecret", "appSecret", "string","")); + configVOList.add(new NotifyConfigVO("appId", "appId", "string", "")); + configVOList.add(new NotifyConfigVO("appSecret", "appSecret", "string", "")); break; case WECHAT_WECOM_APPLY: - configVOList.add(new NotifyConfigVO("corpId", "企业ID", "string","")); - configVOList.add(new NotifyConfigVO("corpSecret", "应用Secret", "string","")); - configVOList.add(new NotifyConfigVO("agentId", "应用agentId", "string","")); + configVOList.add(new NotifyConfigVO("corpId", "企业ID", "string", "")); + configVOList.add(new NotifyConfigVO("corpSecret", "应用Secret", "string", "")); + configVOList.add(new NotifyConfigVO("agentId", "应用agentId", "string", "")); break; case WECHAT_WECOM_ROBOT: - configVOList.add(new NotifyConfigVO("webHook", "webHook", "string","")); + configVOList.add(new NotifyConfigVO("webHook", "webHook", "string", "")); break; case DING_TALK_WORK: - configVOList.add(new NotifyConfigVO("appKey", "appKey", "string","")); - configVOList.add(new NotifyConfigVO("appSecret", "appSecret", "string","")); - configVOList.add(new NotifyConfigVO("agentId", "agentId", "string","")); + configVOList.add(new NotifyConfigVO("appKey", "appKey", "string", "")); + configVOList.add(new NotifyConfigVO("appSecret", "appSecret", "string", "")); + configVOList.add(new NotifyConfigVO("agentId", "agentId", "string", "")); break; case DING_TALK_GROUP_ROBOT: - configVOList.add(new NotifyConfigVO("webHook", "webHook", "string","")); + configVOList.add(new NotifyConfigVO("webHook", "webHook", "string", "")); break; default: return configVOList; @@ -201,56 +201,56 @@ public enum NotifyChannelProviderEnum { switch (type) { // 短信:配置参数来源于sms4j,务必属性字段名和sms4j配置参数字段名一致 case SMS_ALIBABA: - configVOList.add(new NotifyConfigVO("sendAccount", "发送电话号", "string","")); - configVOList.add(new NotifyConfigVO("templateId", "模板CODE", "string","")); - configVOList.add(new NotifyConfigVO("signature", "签名", "string","")); - configVOList.add(new NotifyConfigVO("content", "模板内容", "string","")); + configVOList.add(new NotifyConfigVO("sendAccount", "发送电话号", "string", "")); + configVOList.add(new NotifyConfigVO("templateId", "模板CODE", "string", "")); + configVOList.add(new NotifyConfigVO("signature", "签名", "string", "")); + configVOList.add(new NotifyConfigVO("content", "模板内容", "string", "")); break; case SMS_TENCENT: - configVOList.add(new NotifyConfigVO("sendAccount", "发送电话号", "string","")); - configVOList.add(new NotifyConfigVO("templateId", "模板ID", "string","")); - configVOList.add(new NotifyConfigVO("signature", "签名", "string","")); - configVOList.add(new NotifyConfigVO("sdkAppId", "应用SDKAppID", "string","")); - configVOList.add(new NotifyConfigVO("content", "模板内容", "string","")); + configVOList.add(new NotifyConfigVO("sendAccount", "发送电话号", "string", "")); + configVOList.add(new NotifyConfigVO("templateId", "模板ID", "string", "")); + configVOList.add(new NotifyConfigVO("signature", "签名", "string", "")); + configVOList.add(new NotifyConfigVO("sdkAppId", "应用SDKAppID", "string", "")); + configVOList.add(new NotifyConfigVO("content", "模板内容", "string", "")); break; // 邮箱 case EMAIL_QQ: case EMAIL_163: - configVOList.add(new NotifyConfigVO("sendAccount", "发送邮箱号", "string","")); - configVOList.add(new NotifyConfigVO("title", "标题", "string","")); - configVOList.add(new NotifyConfigVO("attachment", "附件", "file","")); - configVOList.add(new NotifyConfigVO("content", "邮箱正文", "text","")); + configVOList.add(new NotifyConfigVO("sendAccount", "发送邮箱号", "string", "")); + configVOList.add(new NotifyConfigVO("title", "标题", "string", "")); + configVOList.add(new NotifyConfigVO("attachment", "附件", "file", "")); + configVOList.add(new NotifyConfigVO("content", "邮箱正文", "text", "")); break; case WECHAT_MINI_PROGRAM: - configVOList.add(new NotifyConfigVO("sendAccount", "发送用户ID", "string","")); - configVOList.add(new NotifyConfigVO("templateId", "模板ID", "string","")); - configVOList.add(new NotifyConfigVO("redirectUrl", "跳转链接", "string","")); - configVOList.add(new NotifyConfigVO("content", "模板内容", "string","")); + configVOList.add(new NotifyConfigVO("sendAccount", "发送用户ID", "string", "")); + configVOList.add(new NotifyConfigVO("templateId", "模板ID", "string", "")); + configVOList.add(new NotifyConfigVO("redirectUrl", "跳转链接", "string", "")); + configVOList.add(new NotifyConfigVO("content", "模板内容", "string", "")); break; case WECHAT_PUBLIC_ACCOUNT: - configVOList.add(new NotifyConfigVO("templateId", "模板ID", "string","")); - configVOList.add(new NotifyConfigVO("redirectUrl", "跳转链接", "string","")); - configVOList.add(new NotifyConfigVO("appid", "跳转小程序appid", "string","")); - configVOList.add(new NotifyConfigVO("pagePath", "跳转小程序路径", "string","")); - configVOList.add(new NotifyConfigVO("content", "模板内容", "string","")); + configVOList.add(new NotifyConfigVO("templateId", "模板ID", "string", "")); + configVOList.add(new NotifyConfigVO("redirectUrl", "跳转链接", "string", "")); + configVOList.add(new NotifyConfigVO("appid", "跳转小程序appid", "string", "")); + configVOList.add(new NotifyConfigVO("pagePath", "跳转小程序路径", "string", "")); + configVOList.add(new NotifyConfigVO("content", "模板内容", "string", "")); case WECHAT_WECOM_APPLY: case WECHAT_WECOM_ROBOT: if (StringUtils.isEmpty(msgType)) { return configVOList; } if (type.equals(WECHAT_WECOM_APPLY)) { - configVOList.add(new NotifyConfigVO("sendAccount", "发送成员账号", "string","")); + configVOList.add(new NotifyConfigVO("sendAccount", "发送成员账号", "string", "")); } switch (msgType) { case "text": case "markdown": - configVOList.add(new NotifyConfigVO("content", "消息内容", "string","")); + configVOList.add(new NotifyConfigVO("content", "消息内容", "string", "")); break; case "news": - configVOList.add(new NotifyConfigVO("title", "消息标题", "string","")); - configVOList.add(new NotifyConfigVO("content", "消息内容", "string","")); - configVOList.add(new NotifyConfigVO("url", "跳转链接", "string","")); - configVOList.add(new NotifyConfigVO("picUrl", "图片链接", "file","")); + configVOList.add(new NotifyConfigVO("title", "消息标题", "string", "")); + configVOList.add(new NotifyConfigVO("content", "消息内容", "string", "")); + configVOList.add(new NotifyConfigVO("url", "跳转链接", "string", "")); + configVOList.add(new NotifyConfigVO("picUrl", "图片链接", "file", "")); break; default: break; @@ -258,18 +258,18 @@ public enum NotifyChannelProviderEnum { break; // 语音 case VOICE_ALIBABA: - configVOList.add(new NotifyConfigVO("sendAccount", "发送电话号", "string","")); - configVOList.add(new NotifyConfigVO("templateId", "模板ID", "string","")); - configVOList.add(new NotifyConfigVO("content", "模板内容", "string","")); - configVOList.add(new NotifyConfigVO("playTimes", "播放次数 (1~3)", "int","2")); - configVOList.add(new NotifyConfigVO("volume", "播放音量 (0-100)", "string","50")); - configVOList.add(new NotifyConfigVO("speed", "语速控制 (-500-500)", "string","0")); + configVOList.add(new NotifyConfigVO("sendAccount", "发送电话号", "string", "")); + configVOList.add(new NotifyConfigVO("templateId", "模板ID", "string", "")); + configVOList.add(new NotifyConfigVO("content", "模板内容", "string", "")); + configVOList.add(new NotifyConfigVO("playTimes", "播放次数 (1~3)", "int", "2")); + configVOList.add(new NotifyConfigVO("volume", "播放音量 (0-100)", "string", "50")); + configVOList.add(new NotifyConfigVO("speed", "语速控制 (-500-500)", "string", "0")); break; case VOICE_TENCENT: - configVOList.add(new NotifyConfigVO("sendAccount", "发送电话号", "string","")); - configVOList.add(new NotifyConfigVO("sdkAppId", "应用SDKAppID", "string","")); - configVOList.add(new NotifyConfigVO("templateId", "模板ID", "string","")); - configVOList.add(new NotifyConfigVO("content", "模板内容", "string","")); + configVOList.add(new NotifyConfigVO("sendAccount", "发送电话号", "string", "")); + configVOList.add(new NotifyConfigVO("sdkAppId", "应用SDKAppID", "string", "")); + configVOList.add(new NotifyConfigVO("templateId", "模板ID", "string", "")); + configVOList.add(new NotifyConfigVO("content", "模板内容", "string", "")); break; // 钉钉 case DING_TALK_WORK: @@ -280,31 +280,31 @@ public enum NotifyChannelProviderEnum { switch (msgType) { case "text": if (NotifyChannelProviderEnum.DING_TALK_WORK.equals(type)) { - configVOList.add(new NotifyConfigVO("deptId", "部门id", "string","")); - configVOList.add(new NotifyConfigVO("sendAllEnable", "发送所有人", "boolean","false")); - configVOList.add(new NotifyConfigVO("sendAccount", "员工UserID", "string","")); + configVOList.add(new NotifyConfigVO("deptId", "部门id", "string", "")); + configVOList.add(new NotifyConfigVO("sendAllEnable", "发送所有人", "boolean", "false")); + configVOList.add(new NotifyConfigVO("sendAccount", "员工UserID", "string", "")); } - configVOList.add(new NotifyConfigVO("content", "消息内容", "string","")); + configVOList.add(new NotifyConfigVO("content", "消息内容", "string", "")); break; case "link": if (NotifyChannelProviderEnum.DING_TALK_WORK.equals(type)) { - configVOList.add(new NotifyConfigVO("deptId", "部门id", "string","")); - configVOList.add(new NotifyConfigVO("sendAllEnable", "发送所有人", "boolean","false")); - configVOList.add(new NotifyConfigVO("sendAccount", "员工UserID", "string","")); + configVOList.add(new NotifyConfigVO("deptId", "部门id", "string", "")); + configVOList.add(new NotifyConfigVO("sendAllEnable", "发送所有人", "boolean", "false")); + configVOList.add(new NotifyConfigVO("sendAccount", "员工UserID", "string", "")); } - configVOList.add(new NotifyConfigVO("title", "消息标题", "string","")); - configVOList.add(new NotifyConfigVO("content", "消息内容", "string","")); - configVOList.add(new NotifyConfigVO("messageUrl", "消息链接", "string","")); - configVOList.add(new NotifyConfigVO("picUrl", "图片链接", "file","")); + configVOList.add(new NotifyConfigVO("title", "消息标题", "string", "")); + configVOList.add(new NotifyConfigVO("content", "消息内容", "string", "")); + configVOList.add(new NotifyConfigVO("messageUrl", "消息链接", "string", "")); + configVOList.add(new NotifyConfigVO("picUrl", "图片链接", "file", "")); break; case "markdown": if (NotifyChannelProviderEnum.DING_TALK_WORK.equals(type)) { - configVOList.add(new NotifyConfigVO("deptId", "部门id", "string","")); - configVOList.add(new NotifyConfigVO("sendAllEnable", "发送所有人", "boolean","false")); - configVOList.add(new NotifyConfigVO("sendAccount", "员工UserID", "string","")); + configVOList.add(new NotifyConfigVO("deptId", "部门id", "string", "")); + configVOList.add(new NotifyConfigVO("sendAllEnable", "发送所有人", "boolean", "false")); + configVOList.add(new NotifyConfigVO("sendAccount", "员工UserID", "string", "")); } - configVOList.add(new NotifyConfigVO("title", "消息标题", "string","")); - configVOList.add(new NotifyConfigVO("content", "消息内容", "string","")); + configVOList.add(new NotifyConfigVO("title", "消息标题", "string", "")); + configVOList.add(new NotifyConfigVO("content", "消息内容", "string", "")); break; default: break; diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/NotifyServiceCodeEnum.java b/fastbee-common/src/main/java/com/fastbee/common/enums/NotifyServiceCodeEnum.java index a288fd38..59442476 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/NotifyServiceCodeEnum.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/NotifyServiceCodeEnum.java @@ -5,10 +5,10 @@ import lombok.AllArgsConstructor; import lombok.Getter; /** - * @description: 通知业务编码枚举 * @author fastb - * @date 2023-12-16 17:00 * @version 1.0 + * @description: 通知业务编码枚举 + * @date 2023-12-16 17:00 */ @Getter @AllArgsConstructor @@ -18,7 +18,7 @@ public enum NotifyServiceCodeEnum { * 确保唯一,不能重复 */ ALERT("alert", "设备告警"), - CAPTCHA("captcha","验证码"), + CAPTCHA("captcha", "验证码"), MARKETING("marketing", "营销通知"); diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/OTAUpgrade.java b/fastbee-common/src/main/java/com/fastbee/common/enums/OTAUpgrade.java index 3fa10a01..f3009b97 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/OTAUpgrade.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/OTAUpgrade.java @@ -5,6 +5,7 @@ import lombok.Getter; /** * OTA升级状态 + * * @author gsb * @date 2022/10/24 17:29 */ @@ -13,24 +14,24 @@ import lombok.Getter; public enum OTAUpgrade { - AWAIT(0, "等待升级","等待升级"), - SEND(1, "发送中","发送中"), - REPLY(2, "升级中","升级中"), - SUCCESS(3, "成功","升级成功"), - FAILED(4, "失败","升级失败"), - FAILED_PULL(4, "失败","拉取固件包失败"), - FAILED_PACKAGE_SIZE(4, "失败","获取固件包分包大小失败"), - FAILED_PUSH(4, "失败","推送固件包失败"), - STOP(5, "停止","设备重复升级停止推送"), - STOP_OFFLINE(5, "停止","设备离线停止推送"), - UNKNOWN(404, "未知","未知错误码"); + AWAIT(0, "等待升级", "等待升级"), + SEND(1, "发送中", "发送中"), + REPLY(2, "升级中", "升级中"), + SUCCESS(3, "成功", "升级成功"), + FAILED(4, "失败", "升级失败"), + FAILED_PULL(4, "失败", "拉取固件包失败"), + FAILED_PACKAGE_SIZE(4, "失败", "获取固件包分包大小失败"), + FAILED_PUSH(4, "失败", "推送固件包失败"), + STOP(5, "停止", "设备重复升级停止推送"), + STOP_OFFLINE(5, "停止", "设备离线停止推送"), + UNKNOWN(404, "未知", "未知错误码"); Integer status; String subMsg; String des; - public static OTAUpgrade parse(Integer code){ - for (OTAUpgrade item: OTAUpgrade.values()){ - if(item.status.equals(code)){ + public static OTAUpgrade parse(Integer code) { + for (OTAUpgrade item : OTAUpgrade.values()) { + if (item.status.equals(code)) { return item; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/OperatorType.java b/fastbee-common/src/main/java/com/fastbee/common/enums/OperatorType.java index 934801b0..f97ac5d5 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/OperatorType.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/OperatorType.java @@ -2,11 +2,10 @@ package com.fastbee.common.enums; /** * 操作人类别 - * + * * @author ruoyi */ -public enum OperatorType -{ +public enum OperatorType { /** * 其它 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/PushType.java b/fastbee-common/src/main/java/com/fastbee/common/enums/PushType.java index a9271eb3..fa259e1f 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/PushType.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/PushType.java @@ -5,13 +5,14 @@ import lombok.Getter; /** * 推送类型 + * * @author bill */ @Getter @AllArgsConstructor public enum PushType { - WECHAT_SERVER_PUSH("wechat_server_push","微信小程序服务号推送"); + WECHAT_SERVER_PUSH("wechat_server_push", "微信小程序服务号推送"); /** diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/ResultCode.java b/fastbee-common/src/main/java/com/fastbee/common/enums/ResultCode.java index 86b293c9..71c16284 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/ResultCode.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/ResultCode.java @@ -9,13 +9,13 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public enum ResultCode implements IErrorCode { - SUCCESS(HttpStatus.SUCCESS,"请求成功"), - FAILED(HttpStatus.ERROR,"系统内部错误"), - ACCEPTED(HttpStatus.ACCEPTED,"请求已接收"), - REDIRECT(HttpStatus.SEE_OTHER,"重定向"), - UNAUTHORIZED(HttpStatus.UNAUTHORIZED,"暂未登录或token过期"), - FORBIDDEN(HttpStatus.FORBIDDEN,"没有相关权限或授权过期"), - NOT_FOUND(HttpStatus.NOT_FOUND,"资源未找到"), + SUCCESS(HttpStatus.SUCCESS, "请求成功"), + FAILED(HttpStatus.ERROR, "系统内部错误"), + ACCEPTED(HttpStatus.ACCEPTED, "请求已接收"), + REDIRECT(HttpStatus.SEE_OTHER, "重定向"), + UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "暂未登录或token过期"), + FORBIDDEN(HttpStatus.FORBIDDEN, "没有相关权限或授权过期"), + NOT_FOUND(HttpStatus.NOT_FOUND, "资源未找到"), PARSE_MSG_EXCEPTION(4018, "解析协议异常"), TIMEOUT(502, "响应超时!"), FIRMWARE_VERSION_UNIQUE_ERROR(4022, "产品下已存在该版本固件"), @@ -30,8 +30,12 @@ public enum ResultCode implements IErrorCode { private int code; private String message; - public int getCode(){return code;} + public int getCode() { + return code; + } - public String getMessage(){return message;} + public String getMessage() { + return message; + } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/ServerType.java b/fastbee-common/src/main/java/com/fastbee/common/enums/ServerType.java index 7894a6b8..9a74544d 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/ServerType.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/ServerType.java @@ -11,21 +11,20 @@ import lombok.Getter; @AllArgsConstructor public enum ServerType { - MQTT(1, "MQTT","MQTT-BROKER"), - COAP(2, "COAP","COAP-SERVER"), - TCP(3, "TCP","TCP-SERVER"), - UDP(4, "UDP","UDP-SERVER"), - WEBSOCKET(5,"WEBSOCKET","WEBSOCKET-SERVER"), - GB28181(6,"GB28181","SIP-SERVER"), - HTTP(6,"HTTP","HTTP-SERVER"), - OTHER(999,"WEBSOCKET","MQTT-BROKER"); + MQTT(1, "MQTT", "MQTT-BROKER"), + COAP(2, "COAP", "COAP-SERVER"), + TCP(3, "TCP", "TCP-SERVER"), + UDP(4, "UDP", "UDP-SERVER"), + WEBSOCKET(5, "WEBSOCKET", "WEBSOCKET-SERVER"), + GB28181(6, "GB28181", "SIP-SERVER"), + HTTP(6, "HTTP", "HTTP-SERVER"), + OTHER(999, "WEBSOCKET", "MQTT-BROKER"); private int type; private String code; private String des; - public static ServerType explain(String code) { for (ServerType value : ServerType.values()) { if (value.code.equals(code)) { @@ -34,9 +33,10 @@ public enum ServerType { } return ServerType.MQTT; } + public static ServerType explainByType(int type) { for (ServerType value : ServerType.values()) { - if (value.type == type) { + if (value.type == type) { return value; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/SocialPlatformType.java b/fastbee-common/src/main/java/com/fastbee/common/enums/SocialPlatformType.java index 81f5f4a2..6f2a6001 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/SocialPlatformType.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/SocialPlatformType.java @@ -21,8 +21,9 @@ public enum SocialPlatformType { // ALIPAY_OPEN_APP("alipay_open_app", ""), // ALIPAY_OPEN_MINI_PROGRAM("alipay_open_mini_program", ""); + // 查询微信绑定来源集合 + public static final List listWechatPlatform = Arrays.asList(WECHAT_OPEN_WEB.sourceClient, WECHAT_OPEN_MOBILE.sourceClient, WECHAT_OPEN_MINI_PROGRAM.sourceClient); public String sourceClient; - public String desc; SocialPlatformType(String sourceClient, String desc) { @@ -30,9 +31,6 @@ public enum SocialPlatformType { this.desc = desc; } - // 查询微信绑定来源集合 - public static final List listWechatPlatform = Arrays.asList(WECHAT_OPEN_WEB.sourceClient, WECHAT_OPEN_MOBILE.sourceClient, WECHAT_OPEN_MINI_PROGRAM.sourceClient); - public static String getDesc(String sourceClient) { for (SocialPlatformType socialPlatformType : SocialPlatformType.values()) { if (socialPlatformType.getSourceClient().equals(sourceClient)) { diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/StatusEnum.java b/fastbee-common/src/main/java/com/fastbee/common/enums/StatusEnum.java index 625489d7..fe5f5675 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/StatusEnum.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/StatusEnum.java @@ -5,7 +5,6 @@ import lombok.Getter; /** * 通用状态枚举 - */ @Getter @AllArgsConstructor diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/ThingsModelType.java b/fastbee-common/src/main/java/com/fastbee/common/enums/ThingsModelType.java index ed0c3330..af3f39cf 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/ThingsModelType.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/ThingsModelType.java @@ -12,9 +12,10 @@ import lombok.Getter; @AllArgsConstructor public enum ThingsModelType { - PROP(1, "PROPERTY", "属性","properties"), - SERVICE(2, "FUNCTION", "服务","functions"), - EVENT(3, "EVENT", "事件","events"),; + PROP(1, "PROPERTY", "属性", "properties"), + SERVICE(2, "FUNCTION", "服务", "functions"), + EVENT(3, "EVENT", "事件", "events"), + ; int code; String type; diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/TopicType.java b/fastbee-common/src/main/java/com/fastbee/common/enums/TopicType.java index 8cb8ca95..a44fcc1f 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/TopicType.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/TopicType.java @@ -5,6 +5,7 @@ import lombok.Getter; /** * topic类型 + * * @author gsb */ @Getter @@ -19,41 +20,40 @@ public enum TopicType { */ /*** 通用设备上报主题(平台订阅) ***/ - PROPERTY_POST(0,1,"/property/post", "订阅属性"), - EVENT_POST(0,2,"/event/post", "订阅事件"), - FUNCTION_POST(0,3,"/function/post", "订阅功能"), - INFO_POST(0,4,"/info/post","订阅设备信息"), - NTP_POST(0,5,"/ntp/post","订阅时钟同步"), - SERVICE_INVOKE_REPLY(0,8,"/service/reply", "订阅功能调用返回结果"), - MESSAGE_POST(0,26,"/message/post","订阅设备上报消息"), + PROPERTY_POST(0, 1, "/property/post", "订阅属性"), + EVENT_POST(0, 2, "/event/post", "订阅事件"), + FUNCTION_POST(0, 3, "/function/post", "订阅功能"), + INFO_POST(0, 4, "/info/post", "订阅设备信息"), + NTP_POST(0, 5, "/ntp/post", "订阅时钟同步"), + SERVICE_INVOKE_REPLY(0, 8, "/service/reply", "订阅功能调用返回结果"), + MESSAGE_POST(0, 26, "/message/post", "订阅设备上报消息"), /*** 通用设备订阅主题(平台下发)***/ - FUNCTION_GET(1,17,"/function/get", "发布功能"), - PROPERTY_GET(1,12,"/property/get" ,"发布设备属性读取"), - PROPERTY_SET(1,15,"/property/set" ,"设置设备属性读取"), - STATUS_POST(1,11,"/status/post","发布状态"), - NTP_GET(1,15,"/ntp/get","发布时钟同步"), - INFO_GET(1,18,"/info/get","发布设备信息"), + FUNCTION_GET(1, 17, "/function/get", "发布功能"), + PROPERTY_GET(1, 12, "/property/get", "发布设备属性读取"), + PROPERTY_SET(1, 15, "/property/set", "设置设备属性读取"), + STATUS_POST(1, 11, "/status/post", "发布状态"), + NTP_GET(1, 15, "/ntp/get", "发布时钟同步"), + INFO_GET(1, 18, "/info/get", "发布设备信息"), /*** 视频监控设备转协议发布 ***/ - DEV_INFO_POST(3,19,"/info/post","设备端发布设备信息"), - DEV_EVENT_POST(3,20,"/event/post","设备端发布事件"), - DEV_PROPERTY_POST(3,22,"/property/post", "设备端发布属性"), + DEV_INFO_POST(3, 19, "/info/post", "设备端发布设备信息"), + DEV_EVENT_POST(3, 20, "/event/post", "设备端发布事件"), + DEV_PROPERTY_POST(3, 22, "/property/post", "设备端发布属性"), /*** webSocket转发前端使用 ***/ - WS_SERVICE_INVOKE(2,16,"/ws/service", "WS服务调用"), + WS_SERVICE_INVOKE(2, 16, "/ws/service", "WS服务调用"), /** * OTA升级 */ - WS_OTA_STATUS(2,18,"/ws/ota/status","OTA升级状态"), - HTTP_FIRMWARE_SET(1,14, "/http/upgrade/set","http推送发布OTA升级"), - FETCH_FIRMWARE_SET(1,19, "/fetch/upgrade/set","分包拉取方式发布OTA升级"), - FETCH_UPGRADE_REPLY(0,9,"/fetch/upgrade/reply", "分包拉取方式OTA升级回调"), - HTTP_UPGRADE_REPLY(0,9,"/http/upgrade/reply", "http推送方式OTA升级回调") - ; + WS_OTA_STATUS(2, 18, "/ws/ota/status", "OTA升级状态"), + HTTP_FIRMWARE_SET(1, 14, "/http/upgrade/set", "http推送发布OTA升级"), + FETCH_FIRMWARE_SET(1, 19, "/fetch/upgrade/set", "分包拉取方式发布OTA升级"), + FETCH_UPGRADE_REPLY(0, 9, "/fetch/upgrade/reply", "分包拉取方式OTA升级回调"), + HTTP_UPGRADE_REPLY(0, 9, "/http/upgrade/reply", "http推送方式OTA升级回调"); Integer type; Integer order; diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/UserStatus.java b/fastbee-common/src/main/java/com/fastbee/common/enums/UserStatus.java index 7ea86c2d..5a0da404 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/UserStatus.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/UserStatus.java @@ -2,29 +2,25 @@ package com.fastbee.common.enums; /** * 用户状态 - * + * * @author ruoyi */ -public enum UserStatus -{ +public enum UserStatus { OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除"); private final String code; private final String info; - UserStatus(String code, String info) - { + UserStatus(String code, String info) { this.code = code; this.info = info; } - public String getCode() - { + public String getCode() { return code; } - public String getInfo() - { + public String getInfo() { return info; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/VerifyTypeEnum.java b/fastbee-common/src/main/java/com/fastbee/common/enums/VerifyTypeEnum.java index 74202c25..b778caa3 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/VerifyTypeEnum.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/VerifyTypeEnum.java @@ -6,6 +6,7 @@ import lombok.NoArgsConstructor; /** * 验证类型枚举 + * * @author fastb * @date 2023-08-30 15:04 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/scenemodel/SceneModelTagOpreationEnum.java b/fastbee-common/src/main/java/com/fastbee/common/enums/scenemodel/SceneModelTagOpreationEnum.java index b9312ff6..2ac2d35d 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/scenemodel/SceneModelTagOpreationEnum.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/scenemodel/SceneModelTagOpreationEnum.java @@ -5,9 +5,10 @@ import lombok.Getter; /** * 场景变量统计方式 + * * @author fastb - * @date 2024-06-05 10:42 * @version 1.0 + * @date 2024-06-05 10:42 */ @AllArgsConstructor @Getter @@ -31,7 +32,7 @@ public enum SceneModelTagOpreationEnum { /** * 最小值 */ - MIN_VALUE(5,"最小值"); + MIN_VALUE(5, "最小值"); private final Integer code; private final String desc; diff --git a/fastbee-common/src/main/java/com/fastbee/common/enums/scenemodel/SceneModelVariableTypeEnum.java b/fastbee-common/src/main/java/com/fastbee/common/enums/scenemodel/SceneModelVariableTypeEnum.java index 0992756a..fbe8efee 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/enums/scenemodel/SceneModelVariableTypeEnum.java +++ b/fastbee-common/src/main/java/com/fastbee/common/enums/scenemodel/SceneModelVariableTypeEnum.java @@ -10,9 +10,10 @@ import java.util.List; * 场景管理物模型、变量类型枚举 * 注意:以下4张表下的variable_type相关字段统一用该枚举,保持一致 * scene_model_tag表、scene_tag_points表、scene_model_device表、scene_model_data表 + * * @author fastb - * @date 2024-05-22 10:01 * @version 1.0 + * @date 2024-05-22 10:01 */ @Getter @AllArgsConstructor diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/DemoModeException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/DemoModeException.java index ca1872f2..ca7b6ecf 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/DemoModeException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/DemoModeException.java @@ -2,14 +2,12 @@ package com.fastbee.common.exception; /** * 演示模式异常 - * + * * @author ruoyi */ -public class DemoModeException extends RuntimeException -{ +public class DemoModeException extends RuntimeException { private static final long serialVersionUID = 1L; - public DemoModeException() - { + public DemoModeException() { } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/ErrorCode.java b/fastbee-common/src/main/java/com/fastbee/common/exception/ErrorCode.java index 5d145d73..c3c94b76 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/ErrorCode.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/ErrorCode.java @@ -5,7 +5,6 @@ import lombok.experimental.Accessors; /** * 错误码对象 - * */ @Data @Accessors(chain = true) diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/GlobalException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/GlobalException.java index f6bf8e42..4e44a347 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/GlobalException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/GlobalException.java @@ -2,11 +2,10 @@ package com.fastbee.common.exception; /** * 全局异常 - * + * * @author ruoyi */ -public class GlobalException extends RuntimeException -{ +public class GlobalException extends RuntimeException { private static final long serialVersionUID = 1L; /** @@ -16,7 +15,7 @@ public class GlobalException extends RuntimeException /** * 错误明细,内部调试错误 - * + *

* 和 {@link CommonResult#getDetailMessage()} 一致的设计 */ private String detailMessage; @@ -24,34 +23,28 @@ public class GlobalException extends RuntimeException /** * 空构造方法,避免反序列化问题 */ - public GlobalException() - { + public GlobalException() { } - public GlobalException(String message) - { + public GlobalException(String message) { this.message = message; } - public String getDetailMessage() - { + public String getDetailMessage() { return detailMessage; } - public GlobalException setDetailMessage(String detailMessage) - { + public GlobalException setDetailMessage(String detailMessage) { this.detailMessage = detailMessage; return this; } @Override - public String getMessage() - { + public String getMessage() { return message; } - public GlobalException setMessage(String message) - { + public GlobalException setMessage(String message) { this.message = message; return this; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/ServiceException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/ServiceException.java index 2cab2144..c3c69a39 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/ServiceException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/ServiceException.java @@ -5,8 +5,7 @@ package com.fastbee.common.exception; * * @author ruoyi */ -public final class ServiceException extends RuntimeException -{ +public final class ServiceException extends RuntimeException { private static final long serialVersionUID = 1L; /** @@ -21,7 +20,7 @@ public final class ServiceException extends RuntimeException /** * 错误明细,内部调试错误 - * + *

* 和 {@link CommonResult#getDetailMessage()} 一致的设计 */ private String detailMessage; @@ -29,52 +28,43 @@ public final class ServiceException extends RuntimeException /** * 空构造方法,避免反序列化问题 */ - public ServiceException() - { + public ServiceException() { } - public ServiceException(String message) - { + public ServiceException(String message) { this.message = message; } - public ServiceException(String message, Integer code) - { + public ServiceException(String message, Integer code) { this.message = message; this.code = code; } - public ServiceException(Integer code, String message) - { + public ServiceException(Integer code, String message) { this.code = code; this.message = message; } - public String getDetailMessage() - { + public String getDetailMessage() { return detailMessage; } + public ServiceException setDetailMessage(String detailMessage) { + this.detailMessage = detailMessage; + return this; + } + @Override - public String getMessage() - { + public String getMessage() { return message; } - public Integer getCode() - { - return code; - } - - public ServiceException setMessage(String message) - { + public ServiceException setMessage(String message) { this.message = message; return this; } - public ServiceException setDetailMessage(String detailMessage) - { - this.detailMessage = detailMessage; - return this; + public Integer getCode() { + return code; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/ServiceExceptionUtil.java b/fastbee-common/src/main/java/com/fastbee/common/exception/ServiceExceptionUtil.java index 0fe5b4db..984d5714 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/ServiceExceptionUtil.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/ServiceExceptionUtil.java @@ -10,12 +10,12 @@ import java.util.concurrent.ConcurrentMap; /** * {@link ServiceException} 工具类 - * + *

* 目的在于,格式化异常信息提示。 * 考虑到 String.format 在参数不正确时会报错,因此使用 {} 作为占位符,并使用 {@link #doFormat(int, String, Object...)} 方法来格式化 - * + *

* 因为 {@link #MESSAGES} 里面默认是没有异常信息提示的模板的,所以需要使用方自己初始化进去。目前想到的有几种方式: - * + *

* 1. 异常提示信息,写在枚举类中,例如说,cn.iocoder.oceans.user.api.constants.ErrorCodeEnum 类 + ServiceExceptionConfiguration * 2. 异常提示信息,写在 .properties 等等配置文件 * 3. 异常提示信息,写在 Apollo 等等配置中心中,从而实现可动态刷新 @@ -66,7 +66,7 @@ public class ServiceExceptionUtil { /** * 创建指定编号的 ServiceException 的异常 * - * @param code 编号 + * @param code 编号 * @param params 消息提示的占位符对应的参数 * @return 异常 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/UtilException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/UtilException.java index c39a5337..8484697f 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/UtilException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/UtilException.java @@ -2,25 +2,21 @@ package com.fastbee.common.exception; /** * 工具类异常 - * + * * @author ruoyi */ -public class UtilException extends RuntimeException -{ +public class UtilException extends RuntimeException { private static final long serialVersionUID = 8247610319171014183L; - public UtilException(Throwable e) - { + public UtilException(Throwable e) { super(e.getMessage(), e); } - public UtilException(String message) - { + public UtilException(String message) { super(message); } - public UtilException(String message, Throwable throwable) - { + public UtilException(String message, Throwable throwable) { super(message, throwable); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/base/BaseException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/base/BaseException.java index 6f6005d4..767b120c 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/base/BaseException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/base/BaseException.java @@ -5,93 +5,80 @@ import com.fastbee.common.utils.StringUtils; /** * 基础异常 - * + * * @author ruoyi */ -public class BaseException extends RuntimeException -{ +public class BaseException extends RuntimeException { private static final long serialVersionUID = 1L; /** * 所属模块 */ - 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.code = code; this.args = args; this.defaultMessage = defaultMessage; } - public BaseException(String module, String code, Object[] args) - { + public BaseException(String module, String code, Object[] args) { this(module, code, args, null); } - public BaseException(String module, String defaultMessage) - { + public BaseException(String module, String defaultMessage) { this(module, null, null, defaultMessage); } - public BaseException(String code, Object[] args) - { + public BaseException(String code, Object[] args) { this(null, code, args, null); } - public BaseException(String defaultMessage) - { + public BaseException(String defaultMessage) { this(null, null, null, defaultMessage); } @Override - public String getMessage() - { + public String getMessage() { String message = null; - if (!StringUtils.isEmpty(code)) - { + if (!StringUtils.isEmpty(code)) { message = MessageUtils.message(code, args); } - if (message == null) - { + if (message == null) { message = defaultMessage; } return message; } - public String getModule() - { + public String getModule() { return module; } - public String getCode() - { + public String getCode() { return code; } - public Object[] getArgs() - { + public Object[] getArgs() { return args; } - public String getDefaultMessage() - { + public String getDefaultMessage() { return defaultMessage; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/file/FileException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/file/FileException.java index e7fbb650..4776516e 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/file/FileException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/file/FileException.java @@ -4,15 +4,13 @@ import com.fastbee.common.exception.base.BaseException; /** * 文件信息异常类 - * + * * @author ruoyi */ -public class FileException extends BaseException -{ +public class FileException extends BaseException { private static final long serialVersionUID = 1L; - public FileException(String code, Object[] args) - { + public FileException(String code, Object[] args) { super("file", code, args, null); } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/file/FileNameLengthLimitExceededException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/file/FileNameLengthLimitExceededException.java index b2ad8db2..e5453a00 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/file/FileNameLengthLimitExceededException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/file/FileNameLengthLimitExceededException.java @@ -2,15 +2,13 @@ package com.fastbee.common.exception.file; /** * 文件名称超长限制异常类 - * + * * @author ruoyi */ -public class FileNameLengthLimitExceededException extends FileException -{ +public class FileNameLengthLimitExceededException extends FileException { private static final long serialVersionUID = 1L; - public FileNameLengthLimitExceededException(int defaultFileNameLength) - { - super("upload.filename.exceed.length", new Object[] { defaultFileNameLength }); + public FileNameLengthLimitExceededException(int defaultFileNameLength) { + super("upload.filename.exceed.length", new Object[]{defaultFileNameLength}); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/file/FileSizeLimitExceededException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/file/FileSizeLimitExceededException.java index cca7413d..eb935000 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/file/FileSizeLimitExceededException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/file/FileSizeLimitExceededException.java @@ -2,15 +2,13 @@ package com.fastbee.common.exception.file; /** * 文件名大小限制异常类 - * + * * @author ruoyi */ -public class FileSizeLimitExceededException extends FileException -{ +public class FileSizeLimitExceededException extends FileException { private static final long serialVersionUID = 1L; - public FileSizeLimitExceededException(long defaultMaxSize) - { - super("upload.exceed.maxSize", new Object[] { defaultMaxSize }); + public FileSizeLimitExceededException(long defaultMaxSize) { + super("upload.exceed.maxSize", new Object[]{defaultMaxSize}); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/file/InvalidExtensionException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/file/InvalidExtensionException.java index b923390f..03fdaf9e 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/file/InvalidExtensionException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/file/InvalidExtensionException.java @@ -6,76 +6,63 @@ import java.util.Arrays; /** * 文件上传 误异常类 - * + * * @author ruoyi */ -public class InvalidExtensionException extends FileUploadException -{ +public class InvalidExtensionException extends FileUploadException { private static final long serialVersionUID = 1L; - private String[] allowedExtension; - private String extension; - private String filename; + private final String[] allowedExtension; + private final String extension; + private final String filename; - public InvalidExtensionException(String[] allowedExtension, String extension, String filename) - { + public InvalidExtensionException(String[] allowedExtension, String extension, String filename) { super("文件[" + filename + "]后缀[" + extension + "]不正确,请上传" + Arrays.toString(allowedExtension) + "格式"); this.allowedExtension = allowedExtension; this.extension = extension; this.filename = filename; } - public String[] getAllowedExtension() - { + public String[] getAllowedExtension() { return allowedExtension; } - public String getExtension() - { + public String getExtension() { return extension; } - public String getFilename() - { + public String getFilename() { return filename; } - public static class InvalidImageExtensionException extends InvalidExtensionException - { + public static class InvalidImageExtensionException extends InvalidExtensionException { private static final long serialVersionUID = 1L; - public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) - { + public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) { super(allowedExtension, extension, filename); } } - public static class InvalidFlashExtensionException extends InvalidExtensionException - { + public static class InvalidFlashExtensionException extends InvalidExtensionException { private static final long serialVersionUID = 1L; - public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) - { + public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) { super(allowedExtension, extension, filename); } } - public static class InvalidMediaExtensionException extends InvalidExtensionException - { + public static class InvalidMediaExtensionException extends InvalidExtensionException { private static final long serialVersionUID = 1L; - public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) - { + public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) { super(allowedExtension, extension, filename); } } - public static class InvalidVideoExtensionException extends InvalidExtensionException - { + public static class InvalidVideoExtensionException extends InvalidExtensionException { private static final long serialVersionUID = 1L; - public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename) - { + public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename) { super(allowedExtension, extension, filename); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/iot/MqttAuthorizationException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/iot/MqttAuthorizationException.java index d2644a50..3dc440f5 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/iot/MqttAuthorizationException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/iot/MqttAuthorizationException.java @@ -5,13 +5,14 @@ import lombok.NoArgsConstructor; /** * mqtt客户端权限校验异常 + * * @author gsb * @date 2022/10/8 14:11 */ @NoArgsConstructor public class MqttAuthorizationException extends GlobalException { - public MqttAuthorizationException(String messageId){ + public MqttAuthorizationException(String messageId) { super(messageId); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/iot/MqttClientUserNameOrPassException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/iot/MqttClientUserNameOrPassException.java index 683f7e39..e511a7d7 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/iot/MqttClientUserNameOrPassException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/iot/MqttClientUserNameOrPassException.java @@ -5,13 +5,14 @@ import lombok.NoArgsConstructor; /** * mqtt客户端校验 用户名或密码错误 + * * @author gsb * @date 2022/10/8 14:15 */ @NoArgsConstructor public class MqttClientUserNameOrPassException extends GlobalException { - public MqttClientUserNameOrPassException(String message){ + public MqttClientUserNameOrPassException(String message) { super(message); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/job/TaskException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/job/TaskException.java index 60cb410f..692a0021 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/job/TaskException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/job/TaskException.java @@ -2,33 +2,28 @@ package com.fastbee.common.exception.job; /** * 计划策略异常 - * + * * @author ruoyi */ -public class TaskException extends Exception -{ +public class TaskException extends Exception { 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); } - public TaskException(String msg, Code code, Exception nestedEx) - { + public TaskException(String msg, Code code, Exception nestedEx) { super(msg, nestedEx); this.code = code; } - public Code getCode() - { + public Code getCode() { return code; } - public enum Code - { + public enum Code { TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE } } \ No newline at end of file diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/user/CaptchaException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/user/CaptchaException.java index f8d1544d..246eae68 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/user/CaptchaException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/user/CaptchaException.java @@ -2,15 +2,13 @@ package com.fastbee.common.exception.user; /** * 验证码错误异常类 - * + * * @author ruoyi */ -public class CaptchaException extends UserException -{ +public class CaptchaException extends UserException { private static final long serialVersionUID = 1L; - public CaptchaException() - { + public CaptchaException() { super("user.jcaptcha.error", null); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/user/CaptchaExpireException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/user/CaptchaExpireException.java index fd6401d6..7b93469d 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/user/CaptchaExpireException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/user/CaptchaExpireException.java @@ -2,15 +2,13 @@ package com.fastbee.common.exception.user; /** * 验证码失效异常类 - * + * * @author ruoyi */ -public class CaptchaExpireException extends UserException -{ +public class CaptchaExpireException extends UserException { private static final long serialVersionUID = 1L; - public CaptchaExpireException() - { + public CaptchaExpireException() { super("user.jcaptcha.expire", null); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/user/UserException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/user/UserException.java index d1d180f6..0a933c34 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/user/UserException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/user/UserException.java @@ -4,15 +4,13 @@ import com.fastbee.common.exception.base.BaseException; /** * 用户信息异常类 - * + * * @author ruoyi */ -public class UserException extends BaseException -{ +public class UserException extends BaseException { private static final long serialVersionUID = 1L; - public UserException(String code, Object[] args) - { + public UserException(String code, Object[] args) { super("user", code, args, null); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/user/UserPasswordNotMatchException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/user/UserPasswordNotMatchException.java index 54333f1a..88b325ea 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/user/UserPasswordNotMatchException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/user/UserPasswordNotMatchException.java @@ -2,15 +2,13 @@ package com.fastbee.common.exception.user; /** * 用户密码不正确或不符合规范异常类 - * + * * @author ruoyi */ -public class UserPasswordNotMatchException extends UserException -{ +public class UserPasswordNotMatchException extends UserException { private static final long serialVersionUID = 1L; - public UserPasswordNotMatchException() - { + public UserPasswordNotMatchException() { super("user.password.not.match", null); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/exception/user/UserPasswordRetryLimitExceedException.java b/fastbee-common/src/main/java/com/fastbee/common/exception/user/UserPasswordRetryLimitExceedException.java index c5d1812d..27c216a8 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/exception/user/UserPasswordRetryLimitExceedException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/exception/user/UserPasswordRetryLimitExceedException.java @@ -2,15 +2,13 @@ package com.fastbee.common.exception.user; /** * 用户错误最大次数异常类 - * + * * @author ruoyi */ -public class UserPasswordRetryLimitExceedException extends UserException -{ +public class UserPasswordRetryLimitExceedException extends UserException { private static final long serialVersionUID = 1L; - public UserPasswordRetryLimitExceedException(int retryLimitCount, int lockTime) - { - super("user.password.retry.limit.exceed", new Object[] { retryLimitCount, lockTime }); + public UserPasswordRetryLimitExceedException(int retryLimitCount, int lockTime) { + super("user.password.retry.limit.exceed", new Object[]{retryLimitCount, lockTime}); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/filter/PropertyPreExcludeFilter.java b/fastbee-common/src/main/java/com/fastbee/common/filter/PropertyPreExcludeFilter.java index e8fbcd5c..f2dc78f4 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/filter/PropertyPreExcludeFilter.java +++ b/fastbee-common/src/main/java/com/fastbee/common/filter/PropertyPreExcludeFilter.java @@ -4,19 +4,15 @@ import com.alibaba.fastjson2.filter.SimplePropertyPreFilter; /** * 排除JSON敏感属性 - * + * * @author ruoyi */ -public class PropertyPreExcludeFilter extends SimplePropertyPreFilter -{ - public PropertyPreExcludeFilter() - { +public class PropertyPreExcludeFilter extends SimplePropertyPreFilter { + public PropertyPreExcludeFilter() { } - public PropertyPreExcludeFilter addExcludes(String... filters) - { - for (int i = 0; i < filters.length; i++) - { + public PropertyPreExcludeFilter addExcludes(String... filters) { + for (int i = 0; i < filters.length; i++) { this.getExcludes().add(filters[i]); } return this; diff --git a/fastbee-common/src/main/java/com/fastbee/common/filter/RepeatableFilter.java b/fastbee-common/src/main/java/com/fastbee/common/filter/RepeatableFilter.java index 09dc9fa7..82cfa2d6 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/filter/RepeatableFilter.java +++ b/fastbee-common/src/main/java/com/fastbee/common/filter/RepeatableFilter.java @@ -9,40 +9,32 @@ import java.io.IOException; /** * Repeatable 过滤器 - * + * * @author ruoyi */ -public class RepeatableFilter implements Filter -{ +public class RepeatableFilter implements Filter { @Override - public void init(FilterConfig filterConfig) throws ServletException - { + public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException - { + throws IOException, ServletException { ServletRequest requestWrapper = null; if (request instanceof HttpServletRequest - && StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) - { + && StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) { requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response); } - if (null == requestWrapper) - { + if (null == requestWrapper) { chain.doFilter(request, response); - } - else - { + } else { chain.doFilter(requestWrapper, response); } } @Override - public void destroy() - { + public void destroy() { } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/filter/RepeatedlyRequestWrapper.java b/fastbee-common/src/main/java/com/fastbee/common/filter/RepeatedlyRequestWrapper.java index 89ee884d..3f08e3ef 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/filter/RepeatedlyRequestWrapper.java +++ b/fastbee-common/src/main/java/com/fastbee/common/filter/RepeatedlyRequestWrapper.java @@ -12,64 +12,55 @@ import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; /** * 构建可重复读取inputStream的request - * + * * @author ruoyi */ -public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper -{ +public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper { private final byte[] body; - public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException - { + public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException { super(request); request.setCharacterEncoding(Constants.UTF8); response.setCharacterEncoding(Constants.UTF8); - body = HttpHelper.getBodyString(request).getBytes(Constants.UTF8); + body = HttpHelper.getBodyString(request).getBytes(StandardCharsets.UTF_8); } @Override - public BufferedReader getReader() throws IOException - { + public BufferedReader getReader() throws IOException { return new BufferedReader(new InputStreamReader(getInputStream())); } @Override - public ServletInputStream getInputStream() throws IOException - { + public ServletInputStream getInputStream() throws IOException { final ByteArrayInputStream bais = new ByteArrayInputStream(body); - return new ServletInputStream() - { + return new ServletInputStream() { @Override - public int read() throws IOException - { + public int read() throws IOException { return bais.read(); } @Override - public int available() throws IOException - { + public int available() throws IOException { return body.length; } @Override - public boolean isFinished() - { + public boolean isFinished() { return false; } @Override - public boolean isReady() - { + public boolean isReady() { return false; } @Override - public void setReadListener(ReadListener readListener) - { + public void setReadListener(ReadListener readListener) { } }; diff --git a/fastbee-common/src/main/java/com/fastbee/common/filter/XssFilter.java b/fastbee-common/src/main/java/com/fastbee/common/filter/XssFilter.java index 435d69e8..f08aacda 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/filter/XssFilter.java +++ b/fastbee-common/src/main/java/com/fastbee/common/filter/XssFilter.java @@ -12,25 +12,21 @@ import java.util.List; /** * 防止XSS攻击的过滤器 - * + * * @author ruoyi */ -public class XssFilter implements Filter -{ +public class XssFilter implements Filter { /** * 排除链接 */ public List excludes = new ArrayList<>(); @Override - public void init(FilterConfig filterConfig) throws ServletException - { + public void init(FilterConfig filterConfig) throws ServletException { String tempExcludes = filterConfig.getInitParameter("excludes"); - if (StringUtils.isNotEmpty(tempExcludes)) - { + if (StringUtils.isNotEmpty(tempExcludes)) { String[] url = tempExcludes.split(","); - for (int i = 0; url != null && i < url.length; i++) - { + for (int i = 0; url != null && i < url.length; i++) { excludes.add(url[i]); } } @@ -38,12 +34,10 @@ public class XssFilter implements Filter @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException - { + throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse resp = (HttpServletResponse) response; - if (handleExcludeURL(req, resp)) - { + if (handleExcludeURL(req, resp)) { chain.doFilter(request, response); return; } @@ -51,21 +45,18 @@ public class XssFilter implements Filter chain.doFilter(xssRequest, response); } - private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) - { + private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) { String url = request.getServletPath(); String method = request.getMethod(); // GET DELETE 不过滤 - if (method == null || HttpMethod.GET.matches(method) || HttpMethod.DELETE.matches(method)) - { + if (method == null || HttpMethod.GET.matches(method) || HttpMethod.DELETE.matches(method)) { return true; } return StringUtils.matches(url, excludes); } @Override - public void destroy() - { + public void destroy() { } } \ No newline at end of file diff --git a/fastbee-common/src/main/java/com/fastbee/common/filter/XssHttpServletRequestWrapper.java b/fastbee-common/src/main/java/com/fastbee/common/filter/XssHttpServletRequestWrapper.java index 9065de54..49e91d9f 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/filter/XssHttpServletRequestWrapper.java +++ b/fastbee-common/src/main/java/com/fastbee/common/filter/XssHttpServletRequestWrapper.java @@ -12,32 +12,28 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import java.io.ByteArrayInputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; /** * XSS过滤处理 - * + * * @author ruoyi */ -public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper -{ +public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { /** * @param request */ - public XssHttpServletRequestWrapper(HttpServletRequest request) - { + public XssHttpServletRequestWrapper(HttpServletRequest request) { super(request); } @Override - public String[] getParameterValues(String name) - { + public String[] getParameterValues(String name) { String[] values = super.getParameterValues(name); - if (values != null) - { + if (values != null) { int length = values.length; String[] escapesValues = new String[length]; - for (int i = 0; i < length; i++) - { + for (int i = 0; i < length; i++) { // 防xss攻击和过滤前后空格 escapesValues[i] = EscapeUtil.clean(values[i]).trim(); } @@ -47,53 +43,44 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper } @Override - public ServletInputStream getInputStream() throws IOException - { + public ServletInputStream getInputStream() throws IOException { // 非json类型,直接返回 - if (!isJsonRequest()) - { + if (!isJsonRequest()) { return super.getInputStream(); } // 为空,直接返回 - String json = IOUtils.toString(super.getInputStream(), "utf-8"); - if (StringUtils.isEmpty(json)) - { + String json = IOUtils.toString(super.getInputStream(), StandardCharsets.UTF_8); + if (StringUtils.isEmpty(json)) { return super.getInputStream(); } // xss过滤 json = EscapeUtil.clean(json).trim(); - byte[] jsonBytes = json.getBytes("utf-8"); + byte[] jsonBytes = json.getBytes(StandardCharsets.UTF_8); final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes); - return new ServletInputStream() - { + return new ServletInputStream() { @Override - public boolean isFinished() - { + public boolean isFinished() { return true; } @Override - public boolean isReady() - { + public boolean isReady() { return true; } @Override - public int available() throws IOException - { + public int available() throws IOException { return jsonBytes.length; } @Override - public void setReadListener(ReadListener readListener) - { + public void setReadListener(ReadListener readListener) { } @Override - public int read() throws IOException - { + public int read() throws IOException { return bis.read(); } }; @@ -101,11 +88,10 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper /** * 是否是Json请求 - * + * * @param request */ - public boolean isJsonRequest() - { + public boolean isJsonRequest() { String header = super.getHeader(HttpHeaders.CONTENT_TYPE); return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE); } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/SecurityUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/SecurityUtils.java index fce4e052..0bebb6ba 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/SecurityUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/SecurityUtils.java @@ -12,19 +12,14 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; * * @author ruoyi */ -public class SecurityUtils -{ +public class SecurityUtils { /** * 用户ID **/ - public static Long getUserId() - { - try - { + public static Long getUserId() { + try { return getLoginUser().getUserId(); - } - catch (Exception e) - { + } catch (Exception e) { throw new ServiceException("获取用户ID异常", HttpStatus.UNAUTHORIZED); } } @@ -32,14 +27,10 @@ public class SecurityUtils /** * 获取部门ID **/ - public static Long getDeptId() - { - try - { + public static Long getDeptId() { + try { return getLoginUser().getDeptId(); - } - catch (Exception e) - { + } catch (Exception e) { throw new ServiceException("获取部门ID异常", HttpStatus.UNAUTHORIZED); } } @@ -47,14 +38,10 @@ public class SecurityUtils /** * 获取用户账户 **/ - public static String getUsername() - { - try - { + public static String getUsername() { + try { return getLoginUser().getUsername(); - } - catch (Exception e) - { + } catch (Exception e) { throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED); } } @@ -62,14 +49,10 @@ public class SecurityUtils /** * 获取用户 **/ - public static LoginUser getLoginUser() - { - try - { + public static LoginUser getLoginUser() { + try { return (LoginUser) getAuthentication().getPrincipal(); - } - catch (Exception e) - { + } catch (Exception e) { throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED); } } @@ -77,8 +60,7 @@ public class SecurityUtils /** * 获取Authentication */ - public static Authentication getAuthentication() - { + public static Authentication getAuthentication() { return SecurityContextHolder.getContext().getAuthentication(); } @@ -88,8 +70,7 @@ public class SecurityUtils * @param password 密码 * @return 加密字符串 */ - public static String encryptPassword(String password) - { + public static String encryptPassword(String password) { BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); return passwordEncoder.encode(password); } @@ -97,12 +78,11 @@ public class SecurityUtils /** * 判断密码是否相同 * - * @param rawPassword 真实密码 + * @param rawPassword 真实密码 * @param encodedPassword 加密后字符 * @return 结果 */ - public static boolean matchesPassword(String rawPassword, String encodedPassword) - { + public static boolean matchesPassword(String rawPassword, String encodedPassword) { BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); return passwordEncoder.matches(rawPassword, encodedPassword); } @@ -113,26 +93,23 @@ public class SecurityUtils * @param userId 用户ID * @return 结果 */ - public static boolean isAdmin(Long userId) - { + public static boolean isAdmin(Long userId) { return userId != null && 1L == userId; } /** * 获取语言 + * * @return */ - public static String getLanguage(){ - try - { + public static String getLanguage() { + try { String language = getLoginUser().getLanguage(); - if (StringUtils.isEmpty(language)){ + if (StringUtils.isEmpty(language)) { return "en-US"; } return language; - } - catch (Exception e) - { + } catch (Exception e) { return "en-US"; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/bean/BeanUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/bean/BeanUtils.java index f0917602..62e50314 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/bean/BeanUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/bean/BeanUtils.java @@ -8,46 +8,46 @@ import java.util.regex.Pattern; /** * Bean 工具类 - * + * * @author ruoyi */ -public class BeanUtils extends org.springframework.beans.BeanUtils -{ - /** Bean方法名中属性名开始的下标 */ +public class BeanUtils extends org.springframework.beans.BeanUtils { + /** + * Bean方法名中属性名开始的下标 + */ private static final int BEAN_METHOD_PROP_INDEX = 3; - /** * 匹配getter方法的正则表达式 */ + /** + * 匹配getter方法的正则表达式 + */ private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)"); - /** * 匹配setter方法的正则表达式 */ + /** + * 匹配setter方法的正则表达式 + */ private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)"); /** * Bean属性复制工具方法。 - * + * * @param dest 目标对象 - * @param src 源对象 + * @param src 源对象 */ - public static void copyBeanProp(Object dest, Object src) - { - try - { + public static void copyBeanProp(Object dest, Object src) { + try { copyProperties(src, dest); - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); } } /** * 获取对象的setter方法。 - * + * * @param obj 对象 * @return 对象的setter方法列表 */ - public static List getSetterMethods(Object obj) - { + public static List getSetterMethods(Object obj) { // setter方法列表 List setterMethods = new ArrayList(); @@ -56,11 +56,9 @@ public class BeanUtils extends org.springframework.beans.BeanUtils // 查找setter方法 - for (Method method : methods) - { + for (Method method : methods) { Matcher m = SET_PATTERN.matcher(method.getName()); - if (m.matches() && (method.getParameterTypes().length == 1)) - { + if (m.matches() && (method.getParameterTypes().length == 1)) { setterMethods.add(method); } } @@ -70,23 +68,20 @@ public class BeanUtils extends org.springframework.beans.BeanUtils /** * 获取对象的getter方法。 - * + * * @param obj 对象 * @return 对象的getter方法列表 */ - public static List getGetterMethods(Object obj) - { + public static List getGetterMethods(Object obj) { // getter方法列表 List getterMethods = new ArrayList(); // 获取所有方法 Method[] methods = obj.getClass().getMethods(); // 查找getter方法 - for (Method method : methods) - { + for (Method method : methods) { Matcher m = GET_PATTERN.matcher(method.getName()); - if (m.matches() && (method.getParameterTypes().length == 0)) - { + if (m.matches() && (method.getParameterTypes().length == 0)) { getterMethods.add(method); } } @@ -97,14 +92,13 @@ public class BeanUtils extends org.springframework.beans.BeanUtils /** * 检查Bean方法名中的属性名是否相等。
* 如getName()和setName()属性名一样,getName()和setAge()属性名不一样。 - * + * * @param m1 方法名1 * @param m2 方法名2 * @return 属性名一样返回true,否则返回false */ - public static boolean isMethodPropEquals(String m1, String m2) - { + public static boolean isMethodPropEquals(String m1, String m2) { return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX)); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/bean/BeanValidators.java b/fastbee-common/src/main/java/com/fastbee/common/utils/bean/BeanValidators.java index 469509ae..40c96687 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/bean/BeanValidators.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/bean/BeanValidators.java @@ -7,17 +7,14 @@ import java.util.Set; /** * bean对象属性验证 - * + * * @author ruoyi */ -public class BeanValidators -{ +public class BeanValidators { public static void validateWithException(Validator validator, Object object, Class... groups) - throws ConstraintViolationException - { + throws ConstraintViolationException { Set> constraintViolations = validator.validate(object, groups); - if (!constraintViolations.isEmpty()) - { + if (!constraintViolations.isEmpty()) { throw new ConstraintViolationException(constraintViolations); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/collection/CollectionUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/collection/CollectionUtils.java index f3aab88d..a8960176 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/collection/CollectionUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/collection/CollectionUtils.java @@ -17,42 +17,37 @@ import java.util.stream.Collectors; public class CollectionUtils { /*数组复制*/ - public static String[] copy(String[] source){ - if(isEmpty(source)){ + public static String[] copy(String[] source) { + if (isEmpty(source)) { return null; } int len = source.length; String[] arr = new String[len]; - for(int i=0; i < len; i ++){ - arr[i] = source[i]; - } + System.arraycopy(source, 0, arr, 0, len); return arr; } /*数组连接*/ - public static String concat(String[] source, String split){ - if(isEmpty(source)){ + public static String concat(String[] source, String split) { + if (isEmpty(source)) { return null; } String result = ""; - for(int i=0; i < source.length; i ++){ + for (int i = 0; i < source.length; i++) { result = result.concat(source[i]); - if(i != source.length - 1){ + if (i != source.length - 1) { result = result.concat(split); } } return result; } - public static boolean isEmpty(String[] source){ - if(null == source){ + public static boolean isEmpty(String[] source) { + if (null == source) { return true; } - if(0 == source.length){ - return true; - } - return false; + return 0 == source.length; } public static boolean containsAny(Object source, Object... targets) { @@ -233,7 +228,7 @@ public class CollectionUtils { /** * 开始分页 * - * @param list 传入的list集合 + * @param list 传入的list集合 * @param pageNum 页码 * @param pageSize 每页多少条数据 * @return diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/date/LocalDateTimeUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/date/LocalDateTimeUtils.java index abb5f521..ad5d5ef9 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/date/LocalDateTimeUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/date/LocalDateTimeUtils.java @@ -53,7 +53,7 @@ public class LocalDateTimeUtils { * 判断当前时间是否在该时间范围内 * * @param startTime 开始时间 - * @param endTime 结束时间 + * @param endTime 结束时间 * @return 是否 */ public static boolean isBetween(LocalDateTime startTime, LocalDateTime endTime) { @@ -65,9 +65,10 @@ public class LocalDateTimeUtils { /** * 时间转字符串 + * * @param localDateTime 时间 - * @param: format 格式 * @return java.lang.String + * @param: format 格式 */ public static String localDateTimeToStr(LocalDateTime localDateTime, String format) { DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(format); diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/file/FileTypeUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/file/FileTypeUtils.java index cde7994a..5ac0f480 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/file/FileTypeUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/file/FileTypeUtils.java @@ -9,20 +9,17 @@ import java.io.File; * * @author ruoyi */ -public class FileTypeUtils -{ +public class FileTypeUtils { /** * 获取文件类型 *

* 例如: fastbee.txt, 返回: txt - * + * * @param file 文件名 * @return 后缀(不含".") */ - public static String getFileType(File file) - { - if (null == file) - { + public static String getFileType(File file) { + if (null == file) { return StringUtils.EMPTY; } return getFileType(file.getName()); @@ -36,11 +33,9 @@ public class FileTypeUtils * @param fileName 文件名 * @return 后缀(不含".") */ - public static String getFileType(String fileName) - { + public static String getFileType(String fileName) { int separatorIndex = fileName.lastIndexOf("."); - if (separatorIndex < 0) - { + if (separatorIndex < 0) { return ""; } return fileName.substring(separatorIndex + 1).toLowerCase(); @@ -48,28 +43,20 @@ public class FileTypeUtils /** * 获取文件类型 - * + * * @param photoByte 文件字节码 * @return 后缀(不含".") */ - public static String getFileExtendName(byte[] photoByte) - { + public static String getFileExtendName(byte[] photoByte) { String strFileExtendName = "JPG"; if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56) - && ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) - { + && ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) { strFileExtendName = "GIF"; - } - else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70)) - { + } else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70)) { strFileExtendName = "JPG"; - } - else if ((photoByte[0] == 66) && (photoByte[1] == 77)) - { + } else if ((photoByte[0] == 66) && (photoByte[1] == 77)) { strFileExtendName = "BMP"; - } - else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71)) - { + } else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71)) { strFileExtendName = "PNG"; } return strFileExtendName; diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/file/FileUploadUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/file/FileUploadUtils.java index 9c8bd045..321cfc64 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/file/FileUploadUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/file/FileUploadUtils.java @@ -21,8 +21,7 @@ import java.util.Objects; * * @author ruoyi */ -public class FileUploadUtils -{ +public class FileUploadUtils { /** * 默认大小 50M */ @@ -38,14 +37,12 @@ public class FileUploadUtils */ private static String defaultBaseDir = RuoYiConfig.getProfile(); - public static void setDefaultBaseDir(String defaultBaseDir) - { - FileUploadUtils.defaultBaseDir = defaultBaseDir; + public static String getDefaultBaseDir() { + return defaultBaseDir; } - public static String getDefaultBaseDir() - { - return defaultBaseDir; + public static void setDefaultBaseDir(String defaultBaseDir) { + FileUploadUtils.defaultBaseDir = defaultBaseDir; } /** @@ -55,14 +52,10 @@ public class FileUploadUtils * @return 文件名称 * @throws Exception */ - public static final String upload(MultipartFile file) throws IOException - { - try - { + public static final String upload(MultipartFile file) throws IOException { + try { return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); - } - catch (Exception e) - { + } catch (Exception e) { throw new IOException(e.getMessage(), e); } } @@ -71,18 +64,14 @@ public class FileUploadUtils * 根据文件路径上传 * * @param baseDir 相对应用的基目录 - * @param file 上传的文件 + * @param file 上传的文件 * @return 文件名称 * @throws IOException */ - public static final String upload(String baseDir, MultipartFile file) throws IOException - { - try - { + public static final String upload(String baseDir, MultipartFile file) throws IOException { + try { return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); - } - catch (Exception e) - { + } catch (Exception e) { throw new IOException(e.getMessage(), e); } } @@ -90,22 +79,20 @@ public class FileUploadUtils /** * 文件上传 * - * @param baseDir 相对应用的基目录 - * @param file 上传的文件 + * @param baseDir 相对应用的基目录 + * @param file 上传的文件 * @param allowedExtension 上传文件类型 * @return 返回上传成功的文件名 - * @throws FileSizeLimitExceededException 如果超出最大大小 + * @throws FileSizeLimitExceededException 如果超出最大大小 * @throws FileNameLengthLimitExceededException 文件名太长 - * @throws IOException 比如读写文件出错时 - * @throws InvalidExtensionException 文件校验异常 + * @throws IOException 比如读写文件出错时 + * @throws InvalidExtensionException 文件校验异常 */ public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, - InvalidExtensionException - { + InvalidExtensionException { int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length(); - if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) - { + if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) { throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); } @@ -121,28 +108,23 @@ public class FileUploadUtils /** * 编码文件名 */ - public static final String extractFilename(MultipartFile file) - { + public static final String extractFilename(MultipartFile file) { return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(), FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), getExtension(file)); } - public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException - { + public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException { File desc = new File(uploadDir + File.separator + fileName); - if (!desc.exists()) - { - if (!desc.getParentFile().exists()) - { + if (!desc.exists()) { + if (!desc.getParentFile().exists()) { desc.getParentFile().mkdirs(); } } return desc; } - public static final String getPathFileName(String uploadDir, String fileName) throws IOException - { + public static final String getPathFileName(String uploadDir, String fileName) throws IOException { int dirLastIndex = RuoYiConfig.getProfile().length() + 1; String currentDir = StringUtils.substring(uploadDir, dirLastIndex); return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName; @@ -157,40 +139,28 @@ public class FileUploadUtils * @throws InvalidExtensionException */ public static final void assertAllowed(MultipartFile file, String[] allowedExtension) - throws FileSizeLimitExceededException, InvalidExtensionException - { + throws FileSizeLimitExceededException, InvalidExtensionException { long size = file.getSize(); - if (size > DEFAULT_MAX_SIZE) - { + if (size > DEFAULT_MAX_SIZE) { throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024); } String fileName = file.getOriginalFilename(); String extension = getExtension(file); - if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) - { - if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) - { + if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) { + if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) { throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, fileName); - } - else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) - { + } else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) { throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, fileName); - } - else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) - { + } else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) { throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, fileName); - } - else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) - { + } else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) { throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension, fileName); - } - else - { + } else { throw new InvalidExtensionException(allowedExtension, extension, fileName); } } @@ -203,12 +173,9 @@ public class FileUploadUtils * @param allowedExtension * @return */ - public static final boolean isAllowedExtension(String extension, String[] allowedExtension) - { - for (String str : allowedExtension) - { - if (str.equalsIgnoreCase(extension)) - { + public static final boolean isAllowedExtension(String extension, String[] allowedExtension) { + for (String str : allowedExtension) { + if (str.equalsIgnoreCase(extension)) { return true; } } @@ -221,11 +188,9 @@ public class FileUploadUtils * @param file 表单文件 * @return 后缀名 */ - public static final String getExtension(MultipartFile file) - { + public static final String getExtension(MultipartFile file) { String extension = FilenameUtils.getExtension(file.getOriginalFilename()); - if (StringUtils.isEmpty(extension)) - { + if (StringUtils.isEmpty(extension)) { extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType())); } return extension; diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/file/FileUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/file/FileUtils.java index 02b6790a..ba97f147 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/file/FileUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/file/FileUtils.java @@ -22,41 +22,32 @@ import java.nio.charset.StandardCharsets; * * @author ruoyi */ -public class FileUtils -{ +public class FileUtils { public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; /** * 输出指定文件的byte数组 * * @param filePath 文件路径 - * @param os 输出流 + * @param os 输出流 * @return */ - public static void writeBytes(String filePath, OutputStream os) throws IOException - { + public static void writeBytes(String filePath, OutputStream os) throws IOException { FileInputStream fis = null; - try - { + try { File file = new File(filePath); - if (!file.exists()) - { + if (!file.exists()) { throw new FileNotFoundException(filePath); } fis = new FileInputStream(file); byte[] b = new byte[1024]; int length; - while ((length = fis.read(b)) > 0) - { + while ((length = fis.read(b)) > 0) { os.write(b, 0, length); } - } - catch (IOException e) - { + } catch (IOException e) { throw e; - } - finally - { + } finally { IOUtils.close(os); IOUtils.close(fis); } @@ -69,33 +60,28 @@ public class FileUtils * @return 目标文件 * @throws IOException IO异常 */ - public static String writeImportBytes(byte[] data) throws IOException - { + public static String writeImportBytes(byte[] data) throws IOException { return writeBytes(data, RuoYiConfig.getImportPath()); } /** * 写数据到文件中 * - * @param data 数据 + * @param data 数据 * @param uploadDir 目标文件 * @return 目标文件 * @throws IOException IO异常 */ - public static String writeBytes(byte[] data, String uploadDir) throws IOException - { + public static String writeBytes(byte[] data, String uploadDir) throws IOException { FileOutputStream fos = null; String pathName = ""; - try - { + try { String extension = getFileExtendName(data); pathName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension; File file = FileUploadUtils.getAbsoluteFile(uploadDir, pathName); fos = new FileOutputStream(file); fos.write(data); - } - finally - { + } finally { IOUtils.close(fos); } return FileUploadUtils.getPathFileName(uploadDir, pathName); @@ -107,13 +93,11 @@ public class FileUtils * @param filePath 文件 * @return */ - public static boolean deleteFile(String filePath) - { + public static boolean deleteFile(String filePath) { boolean flag = false; File file = new File(filePath); // 路径为文件且不为空则进行删除 - if (file.isFile() && file.exists()) - { + if (file.isFile() && file.exists()) { flag = file.delete(); } return flag; @@ -125,8 +109,7 @@ public class FileUtils * @param filename 文件名称 * @return true 正常 false 非法 */ - public static boolean isValidFilename(String filename) - { + public static boolean isValidFilename(String filename) { return filename.matches(FILENAME_PATTERN); } @@ -136,53 +119,39 @@ public class FileUtils * @param resource 需要下载的文件 * @return true 正常 false 非法 */ - public static boolean checkAllowDownload(String resource) - { + public static boolean checkAllowDownload(String resource) { // 禁止目录上跳级别 - if (StringUtils.contains(resource, "..")) - { + if (StringUtils.contains(resource, "..")) { return false; } // 检查允许下载的文件规则 - if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource))) - { - return true; - } + return ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource)); // 不在允许下载的文件规则 - return false; } /** * 下载文件名重新编码 * - * @param request 请求对象 + * @param request 请求对象 * @param fileName 文件名 * @return 编码后的文件名 */ - public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException - { + public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException { final String agent = request.getHeader("USER-AGENT"); String filename = fileName; - if (agent.contains("MSIE")) - { + if (agent.contains("MSIE")) { // IE浏览器 filename = URLEncoder.encode(filename, "utf-8"); filename = filename.replace("+", " "); - } - else if (agent.contains("Firefox")) - { + } else if (agent.contains("Firefox")) { // 火狐浏览器 filename = new String(fileName.getBytes(), "ISO8859-1"); - } - else if (agent.contains("Chrome")) - { + } else if (agent.contains("Chrome")) { // google浏览器 filename = URLEncoder.encode(filename, "utf-8"); - } - else - { + } else { // 其它浏览器 filename = URLEncoder.encode(filename, "utf-8"); } @@ -192,23 +161,21 @@ public class FileUtils /** * 下载文件名重新编码 * - * @param response 响应对象 + * @param response 响应对象 * @param realFileName 真实文件名 */ - public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException - { + public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException { String percentEncodedFileName = percentEncode(realFileName); - StringBuilder contentDispositionValue = new StringBuilder(); - contentDispositionValue.append("attachment; filename=") - .append(percentEncodedFileName) - .append(";") - .append("filename*=") - .append("utf-8''") - .append(percentEncodedFileName); + String contentDispositionValue = "attachment; filename=" + + percentEncodedFileName + + ";" + + "filename*=" + + "utf-8''" + + percentEncodedFileName; response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename"); - response.setHeader("Content-disposition", contentDispositionValue.toString()); + response.setHeader("Content-disposition", contentDispositionValue); response.setHeader("download-filename", percentEncodedFileName); } @@ -218,8 +185,7 @@ public class FileUtils * @param s 需要百分号编码的字符串 * @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()); return encode.replaceAll("\\+", "%20"); } @@ -230,24 +196,16 @@ public class FileUtils * @param photoByte 图像数据 * @return 后缀名 */ - public static String getFileExtendName(byte[] photoByte) - { + public static String getFileExtendName(byte[] photoByte) { String strFileExtendName = "jpg"; if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56) - && ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) - { + && ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) { strFileExtendName = "gif"; - } - else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70)) - { + } else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70)) { strFileExtendName = "jpg"; - } - else if ((photoByte[0] == 66) && (photoByte[1] == 77)) - { + } else if ((photoByte[0] == 66) && (photoByte[1] == 77)) { strFileExtendName = "bmp"; - } - else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71)) - { + } else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71)) { strFileExtendName = "png"; } return strFileExtendName; @@ -259,10 +217,8 @@ public class FileUtils * @param fileName 路径名称 * @return 没有文件路径的名称 */ - public static String getName(String fileName) - { - if (fileName == null) - { + public static String getName(String fileName) { + if (fileName == null) { return null; } int lastUnixPos = fileName.lastIndexOf('/'); @@ -277,10 +233,8 @@ public class FileUtils * @param fileName 路径名称 * @return 没有文件路径和后缀的名称 */ - public static String getNameNotSuffix(String fileName) - { - if (fileName == null) - { + public static String getNameNotSuffix(String fileName) { + if (fileName == null) { return null; } String baseName = FilenameUtils.getBaseName(fileName); diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/file/ImageUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/file/ImageUtils.java index 5fb9d591..b7d5cf7d 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/file/ImageUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/file/ImageUtils.java @@ -19,38 +19,27 @@ import java.util.Arrays; * * @author ruoyi */ -public class ImageUtils -{ +public class ImageUtils { private static final Logger log = LoggerFactory.getLogger(ImageUtils.class); - public static byte[] getImage(String imagePath) - { + public static byte[] getImage(String imagePath) { InputStream is = getFile(imagePath); - try - { + try { return IOUtils.toByteArray(is); - } - catch (Exception e) - { + } catch (Exception e) { log.error("图片加载异常 {}", e); return null; - } - finally - { + } finally { IOUtils.closeQuietly(is); } } - public static InputStream getFile(String imagePath) - { - try - { + public static InputStream getFile(String imagePath) { + try { byte[] result = readFile(imagePath); result = Arrays.copyOf(result, result.length); return new ByteArrayInputStream(result); - } - catch (Exception e) - { + } catch (Exception e) { log.error("获取图片异常 {}", e); } return null; @@ -58,17 +47,14 @@ public class ImageUtils /** * 读取文件为字节数据 - * + * * @param url 地址 * @return 字节数据 */ - public static byte[] readFile(String url) - { + public static byte[] readFile(String url) { InputStream in = null; - try - { - if (url.startsWith("http")) - { + try { + if (url.startsWith("http")) { // 网络地址 URL urlObj = new URL(url); URLConnection urlConnection = urlObj.openConnection(); @@ -76,23 +62,17 @@ public class ImageUtils urlConnection.setReadTimeout(60 * 1000); urlConnection.setDoInput(true); in = urlConnection.getInputStream(); - } - else - { + } else { // 本机地址 String localPath = RuoYiConfig.getProfile(); String downloadPath = localPath + StringUtils.substringAfter(url, Constants.RESOURCE_PREFIX); in = new FileInputStream(downloadPath); } return IOUtils.toByteArray(in); - } - catch (Exception e) - { + } catch (Exception e) { log.error("获取文件路径异常 {}", e); return null; - } - finally - { + } finally { IOUtils.closeQuietly(in); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/file/MimeTypeUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/file/MimeTypeUtils.java index 9d34f2ae..803911f3 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/file/MimeTypeUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/file/MimeTypeUtils.java @@ -5,8 +5,7 @@ package com.fastbee.common.utils.file; * * @author ruoyi */ -public class MimeTypeUtils -{ +public class MimeTypeUtils { public static final String IMAGE_PNG = "image/png"; public static final String IMAGE_JPG = "image/jpg"; @@ -17,14 +16,14 @@ public class MimeTypeUtils public static final String IMAGE_GIF = "image/gif"; - public static final String[] IMAGE_EXTENSION = { "bmp", "gif", "jpg", "jpeg", "png" }; + public static final String[] IMAGE_EXTENSION = {"bmp", "gif", "jpg", "jpeg", "png"}; - public static final String[] FLASH_EXTENSION = { "swf", "flv" }; + public static final String[] FLASH_EXTENSION = {"swf", "flv"}; - public static final String[] MEDIA_EXTENSION = { "swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg", - "asf", "rm", "rmvb" }; + public static final String[] MEDIA_EXTENSION = {"swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg", + "asf", "rm", "rmvb"}; - public static final String[] VIDEO_EXTENSION = { "mp4", "avi", "rmvb" }; + public static final String[] VIDEO_EXTENSION = {"mp4", "avi", "rmvb"}; public static final String[] DEFAULT_ALLOWED_EXTENSION = { // 图片 @@ -36,12 +35,10 @@ public class MimeTypeUtils // 视频格式 "mp4", "avi", "rmvb", // pdf - "pdf" }; + "pdf"}; - public static String getExtension(String prefix) - { - switch (prefix) - { + public static String getExtension(String prefix) { + switch (prefix) { case IMAGE_PNG: return "png"; case IMAGE_JPG: diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/file/QRCodeUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/file/QRCodeUtils.java index 3dc2eb6f..1d1a7a65 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/file/QRCodeUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/file/QRCodeUtils.java @@ -14,10 +14,11 @@ import java.util.Map; public class QRCodeUtils { /** - * 生成二维码 + * 生成二维码 + * * @param content 二维码的内容 * @return BitMatrix对象 - * */ + */ public static BitMatrix createCode(String content) throws IOException { //二维码的宽高 int width = 200; @@ -27,9 +28,9 @@ public class QRCodeUtils { Map hints = new HashMap(); hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); //容错级别为H - hints.put(EncodeHintType.ERROR_CORRECTION , ErrorCorrectionLevel.H); + hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); //白边的宽度,可取0~4 - hints.put(EncodeHintType.MARGIN , 0); + hints.put(EncodeHintType.MARGIN, 0); BitMatrix bitMatrix = null; try { @@ -46,10 +47,11 @@ public class QRCodeUtils { } /** - * 删除生成的二维码周围的白边,根据审美决定是否删除 + * 删除生成的二维码周围的白边,根据审美决定是否删除 + * * @param matrix BitMatrix对象 * @return BitMatrix对象 - * */ + */ private static BitMatrix deleteWhite(BitMatrix matrix) { int[] rec = matrix.getEnclosingRectangle(); int resWidth = rec[2] + 1; diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/CRC16Utils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/CRC16Utils.java index 75bc241d..8bc592be 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/CRC16Utils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/CRC16Utils.java @@ -7,14 +7,14 @@ import org.apache.commons.lang3.ArrayUtils; public class CRC16Utils { - //ff - private static int CRC_FF = 0x000000ff; - //01 - private static int CRC_01 = 0x00000001; //04 private static final int LENGTH_04 = 4; //16进制 private static final int OXFF = 0xff; + //ff + private static final int CRC_FF = 0x000000ff; + //01 + private static final int CRC_01 = 0x00000001; /** * 低位在前,高位在后 @@ -132,7 +132,7 @@ public class CRC16Utils { } - public static void main(String[] args)throws Exception { + public static void main(String[] args) throws Exception { String hex = "0103028000"; byte[] bytes = ByteUtils.hexToByte(hex); String crc = getCRC(bytes); @@ -140,7 +140,7 @@ public class CRC16Utils { String crc8 = "680868333701120008C100"; byte[] byte8 = ByteUtils.hexToByte(crc8); int b = CRC8(byte8); - System.out.println((int) b); + System.out.println(b); float v = CaculateUtils.toFloat32_DCBA(bytes); System.out.println(v); } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/CRC8Utils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/CRC8Utils.java index c36e6dcd..65dd281a 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/CRC8Utils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/CRC8Utils.java @@ -12,36 +12,33 @@ public class CRC8Utils { //TODO:-----------------根据C写法转译-------------------------------------- /* CRC-8, poly = x^8 + x^2 + x^1 + x^0, init = 0 */ + static byte[] crc8_tab = {(byte) 0, (byte) 94, (byte) 188, (byte) 226, (byte) 97, (byte) 63, (byte) 221, (byte) 131, (byte) 194, (byte) 156, (byte) 126, (byte) 32, (byte) 163, (byte) 253, (byte) 31, (byte) 65, (byte) 157, (byte) 195, (byte) 33, (byte) 127, (byte) 252, (byte) 162, (byte) 64, (byte) 30, (byte) 95, (byte) 1, (byte) 227, (byte) 189, (byte) 62, (byte) 96, (byte) 130, (byte) 220, (byte) 35, (byte) 125, (byte) 159, (byte) 193, (byte) 66, (byte) 28, (byte) 254, (byte) 160, (byte) 225, (byte) 191, (byte) 93, (byte) 3, (byte) 128, (byte) 222, (byte) 60, (byte) 98, (byte) 190, (byte) 224, (byte) 2, (byte) 92, (byte) 223, (byte) 129, (byte) 99, (byte) 61, (byte) 124, (byte) 34, (byte) 192, (byte) 158, (byte) 29, (byte) 67, (byte) 161, (byte) 255, (byte) 70, (byte) 24, + (byte) 250, (byte) 164, (byte) 39, (byte) 121, (byte) 155, (byte) 197, (byte) 132, (byte) 218, (byte) 56, (byte) 102, (byte) 229, (byte) 187, (byte) 89, (byte) 7, (byte) 219, (byte) 133, (byte) 103, (byte) 57, (byte) 186, (byte) 228, (byte) 6, (byte) 88, (byte) 25, (byte) 71, (byte) 165, (byte) 251, (byte) 120, (byte) 38, (byte) 196, (byte) 154, (byte) 101, (byte) 59, (byte) 217, (byte) 135, (byte) 4, (byte) 90, (byte) 184, (byte) 230, (byte) 167, (byte) 249, (byte) 27, (byte) 69, (byte) 198, (byte) 152, (byte) 122, (byte) 36, (byte) 248, (byte) 166, (byte) 68, (byte) 26, (byte) 153, (byte) 199, (byte) 37, (byte) 123, (byte) 58, (byte) 100, (byte) 134, (byte) 216, (byte) 91, (byte) 5, (byte) 231, (byte) 185, (byte) 140, (byte) 210, (byte) 48, (byte) 110, (byte) 237, + (byte) 179, (byte) 81, (byte) 15, (byte) 78, (byte) 16, (byte) 242, (byte) 172, (byte) 47, (byte) 113, (byte) 147, (byte) 205, (byte) 17, (byte) 79, (byte) 173, (byte) 243, (byte) 112, (byte) 46, (byte) 204, (byte) 146, (byte) 211, (byte) 141, (byte) 111, (byte) 49, (byte) 178, (byte) 236, (byte) 14, (byte) 80, (byte) 175, (byte) 241, (byte) 19, (byte) 77, (byte) 206, (byte) 144, (byte) 114, (byte) 44, (byte) 109, (byte) 51, (byte) 209, (byte) 143, (byte) 12, (byte) 82, (byte) 176, (byte) 238, (byte) 50, (byte) 108, (byte) 142, (byte) 208, (byte) 83, (byte) 13, (byte) 239, (byte) 177, (byte) 240, (byte) 174, (byte) 76, (byte) 18, (byte) 145, (byte) 207, (byte) 45, (byte) 115, (byte) 202, (byte) 148, (byte) 118, (byte) 40, (byte) 171, (byte) 245, (byte) 23, (byte) 73, (byte) 8, + (byte) 86, (byte) 180, (byte) 234, (byte) 105, (byte) 55, (byte) 213, (byte) 139, (byte) 87, (byte) 9, (byte) 235, (byte) 181, (byte) 54, (byte) 104, (byte) 138, (byte) 212, (byte) 149, (byte) 203, (byte) 41, (byte) 119, (byte) 244, (byte) 170, (byte) 72, (byte) 22, (byte) 233, (byte) 183, (byte) 85, (byte) 11, (byte) 136, (byte) 214, (byte) 52, (byte) 106, (byte) 43, (byte) 117, (byte) 151, (byte) 201, (byte) 74, (byte) 20, (byte) 246, (byte) 168, (byte) 116, (byte) 42, (byte) 200, (byte) 150, (byte) 21, (byte) 75, (byte) 169, (byte) 247, (byte) 182, (byte) 232, (byte) 10, (byte) 84, (byte) 215, (byte) 137, (byte) 107, 53}; + /** * CRC8 校验 多项式 x8+x2+x+1 + * * @param data - * @return 校验和 + * @return 校验和 */ - public static byte calcCrc8_E5(byte[] data){ + public static byte calcCrc8_E5(byte[] data) { byte crc = 0; for (int j = 0; j < data.length; j++) { crc ^= data[j]; for (int i = 0; i < 8; i++) { if ((crc & 0x80) != 0) { - crc = (byte) ((crc)<< 1); + crc = (byte) ((crc) << 1); crc ^= 0xE5; } else { - crc = (byte) ((crc)<< 1); + crc = (byte) ((crc) << 1); } } } return crc; } - - - - - static byte[] crc8_tab = {(byte) 0, (byte) 94, (byte) 188, (byte) 226, (byte) 97, (byte) 63, (byte) 221, (byte) 131, (byte) 194, (byte) 156, (byte) 126, (byte) 32, (byte) 163, (byte) 253, (byte) 31, (byte) 65, (byte) 157, (byte) 195, (byte) 33, (byte) 127, (byte) 252, (byte) 162, (byte) 64, (byte) 30, (byte) 95, (byte) 1, (byte) 227, (byte) 189, (byte) 62, (byte) 96, (byte) 130, (byte) 220, (byte) 35, (byte) 125, (byte) 159, (byte) 193, (byte) 66, (byte) 28, (byte) 254, (byte) 160, (byte) 225, (byte) 191, (byte) 93, (byte) 3, (byte) 128, (byte) 222, (byte) 60, (byte) 98, (byte) 190, (byte) 224, (byte) 2, (byte) 92, (byte) 223, (byte) 129, (byte) 99, (byte) 61, (byte) 124, (byte) 34, (byte) 192, (byte) 158, (byte) 29, (byte) 67, (byte) 161, (byte) 255, (byte) 70, (byte) 24, - (byte) 250, (byte) 164, (byte) 39, (byte) 121, (byte) 155, (byte) 197, (byte) 132, (byte) 218, (byte) 56, (byte) 102, (byte) 229, (byte) 187, (byte) 89, (byte) 7, (byte) 219, (byte) 133, (byte) 103, (byte) 57, (byte) 186, (byte) 228, (byte) 6, (byte) 88, (byte) 25, (byte) 71, (byte) 165, (byte) 251, (byte) 120, (byte) 38, (byte) 196, (byte) 154, (byte) 101, (byte) 59, (byte) 217, (byte) 135, (byte) 4, (byte) 90, (byte) 184, (byte) 230, (byte) 167, (byte) 249, (byte) 27, (byte) 69, (byte) 198, (byte) 152, (byte) 122, (byte) 36, (byte) 248, (byte) 166, (byte) 68, (byte) 26, (byte) 153, (byte) 199, (byte) 37, (byte) 123, (byte) 58, (byte) 100, (byte) 134, (byte) 216, (byte) 91, (byte) 5, (byte) 231, (byte) 185, (byte) 140, (byte) 210, (byte) 48, (byte) 110, (byte) 237, - (byte) 179, (byte) 81, (byte) 15, (byte) 78, (byte) 16, (byte) 242, (byte) 172, (byte) 47, (byte) 113, (byte) 147, (byte) 205, (byte) 17, (byte) 79, (byte) 173, (byte) 243, (byte) 112, (byte) 46, (byte) 204, (byte) 146, (byte) 211, (byte) 141, (byte) 111, (byte) 49, (byte) 178, (byte) 236, (byte) 14, (byte) 80, (byte) 175, (byte) 241, (byte) 19, (byte) 77, (byte) 206, (byte) 144, (byte) 114, (byte) 44, (byte) 109, (byte) 51, (byte) 209, (byte) 143, (byte) 12, (byte) 82, (byte) 176, (byte) 238, (byte) 50, (byte) 108, (byte) 142, (byte) 208, (byte) 83, (byte) 13, (byte) 239, (byte) 177, (byte) 240, (byte) 174, (byte) 76, (byte) 18, (byte) 145, (byte) 207, (byte) 45, (byte) 115, (byte) 202, (byte) 148, (byte) 118, (byte) 40, (byte) 171, (byte) 245, (byte) 23, (byte) 73, (byte) 8, - (byte) 86, (byte) 180, (byte) 234, (byte) 105, (byte) 55, (byte) 213, (byte) 139, (byte) 87, (byte) 9, (byte) 235, (byte) 181, (byte) 54, (byte) 104, (byte) 138, (byte) 212, (byte) 149, (byte) 203, (byte) 41, (byte) 119, (byte) 244, (byte) 170, (byte) 72, (byte) 22, (byte) 233, (byte) 183, (byte) 85, (byte) 11, (byte) 136, (byte) 214, (byte) 52, (byte) 106, (byte) 43, (byte) 117, (byte) 151, (byte) 201, (byte) 74, (byte) 20, (byte) 246, (byte) 168, (byte) 116, (byte) 42, (byte) 200, (byte) 150, (byte) 21, (byte) 75, (byte) 169, (byte) 247, (byte) 182, (byte) 232, (byte) 10, (byte) 84, (byte) 215, (byte) 137, (byte) 107, 53}; - /** * 计算数组的CRC8校验值 * @@ -86,7 +83,7 @@ public class CRC8Utils { String hex = "333701120008C100"; byte[] bytes = ByteUtils.hexToByte(hex); byte crc = CRC8Utils.calcCrc8_E5(bytes); - System.out.println("" + Integer.toHexString(0x00ff & crc)); + System.out.println(Integer.toHexString(0x00ff & crc)); } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/mq/Topics.java b/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/mq/Topics.java index 9eab9cf6..34507cc5 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/mq/Topics.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/mq/Topics.java @@ -10,7 +10,7 @@ public class Topics { private String topicName; - private Integer qos =0; + private Integer qos = 0; private String desc; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/mq/TopicsUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/mq/TopicsUtils.java index 593fce3e..06a7f587 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/mq/TopicsUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/mq/TopicsUtils.java @@ -24,94 +24,6 @@ public class TopicsUtils { @Value("${server.broker.enabled}") private Boolean enabled; - /** - * 拼接topic - * - * @param productId 产品id - * @param serialNumber 设备编号 - * @param type 主题类型 - * @return topic - */ - public String buildTopic(Long productId, String serialNumber, TopicType type) { - /* - * 订阅属性: - * 如果启动emq 则为 /+/+/property/post - * 如果启动netty的mqttBroker 则为 /{productId}/{serialNumber}/property/post - * - * 发布都为:/{productId}/{serialNumber}/property/get - */ - String product = String.valueOf(productId); - if (null == productId || productId == -1L || productId == 0L) { - product = "+"; - } - if (com.fastbee.common.utils.StringUtils.isEmpty(serialNumber)) { - serialNumber = "+"; - } - if (type.getType() == 0) { - if (enabled) { - return "/" + product + "/" + serialNumber + type.getTopicSuffix(); - } else { - if (TopicType.FETCH_UPGRADE_REPLY.equals(type) || TopicType.HTTP_UPGRADE_REPLY.equals(type)) { - return FastBeeConstant.MQTT.ONE_PREDIX + type.getTopicSuffix(); - } else { - return FastBeeConstant.MQTT.PREDIX + type.getTopicSuffix(); - } - } -// return enabled ? "/" + product + "/" + serialNumber + type.getTopicSuffix() : FastBeeConstant.MQTT.PREDIX + type.getTopicSuffix(); - } else { - return "/" + product + "/" + serialNumber + type.getTopicSuffix(); - } - } - - public String buildTopic(String serialNumber, TopicType type) { - /* - * 订阅属性: - * 如果启动emq 则为 /+/+/property/post - * 如果启动netty的mqttBroker 则为 /{productId}/{serialNumber}/property/post - * - * 发布都为:/{productId}/{serialNumber}/property/get - */ - - if (com.fastbee.common.utils.StringUtils.isEmpty(serialNumber)) { - serialNumber = "+"; - } - if (type.getType() == 0) { - if (enabled) { - return "/" + serialNumber + type.getTopicSuffix(); - } else { - if (TopicType.FETCH_UPGRADE_REPLY.equals(type) || TopicType.HTTP_UPGRADE_REPLY.equals(type)) { - return FastBeeConstant.MQTT.ONE_PREDIX + type.getTopicSuffix(); - } else { - return FastBeeConstant.MQTT.PREDIX + type.getTopicSuffix(); - } - } -// return enabled ? "/" + serialNumber + type.getTopicSuffix() : FastBeeConstant.MQTT.PREDIX + type.getTopicSuffix(); - } else { - return "/" + serialNumber + type.getTopicSuffix(); - } - } - /** - * 获取所有可订阅的主题 - * - * @return 订阅主题列表 - */ - public TopicsPost getAllPost() { - List qos = new ArrayList<>(); - List topics = new ArrayList<>(); - TopicsPost post = new TopicsPost(); - for (TopicType topicType : TopicType.values()) { - if (topicType.getType() == 0) { - String topic = this.buildTopic(0L, null, topicType); - topics.add(topic); - qos.add(1); - } - } - post.setTopics(topics.toArray(new String[0])); - int[] ints = Arrays.stream(qos.toArray(new Integer[0])).mapToInt(Integer::valueOf).toArray(); - post.setQos(ints); - return post; - } - /** * 获取所有get topic * @@ -135,93 +47,6 @@ public class TopicsUtils { return result; } - - /** - * 替换topic中的产品编码和设备编码,唯一作用是在系统收到来自网关设备上报子设备消息时将topic进行替换 - * - * @param orgTopic String 原始topic - * @param productId String 目标产品编码 - * @param serialNumber String 目标设备编码 - * @return 替换产品编码和设备编码后的新topic - */ - public String topicSubDevice(String orgTopic, Long productId, String serialNumber) { - if (com.fastbee.common.utils.StringUtils.isEmpty(orgTopic)) { - return orgTopic; - } - String[] splits = orgTopic.split("/"); - StringBuilder sb = new StringBuilder(splits[0]) - .append("/") - .append(productId) - .append("/") - .append(serialNumber); - for (int index = 3; index < splits.length; index++) { - sb.append("/").append(splits[index]); - } - return sb.toString(); - } - - /** - * 从topic中获取IMEI号 IMEI即是设备编号 - * - * @param topic /{productId}/{serialNumber}/property/post - * @return serialNumber - */ - @SneakyThrows - public Long parseProductId(String topic) { - String[] values = topic.split("/"); - return Long.parseLong(values[1]); - } - - - /** - * 从topic中获取IMEI号 IMEI即是设备编号 - * - * @param topic /{productId}/{serialNumber}/property/post - * @return serialNumber - */ - @SneakyThrows - public String parseSerialNumber(String topic) { - String[] split = topic.split("/"); - String sn = Arrays.stream(split).filter(imei -> imei.length() > 5).findFirst().get(); - return sn; - } - - /** - * 获取topic 判断字段 name - **/ - public String parseTopicName(String topic) { - String[] values = topic.split("/"); - if (values.length >2){ - if (topic.contains(TopicType.FETCH_UPGRADE_REPLY.getTopicSuffix()) || topic.contains(TopicType.HTTP_UPGRADE_REPLY.getTopicSuffix())) { - return "/" + values[2] + "/"+ values[3] + "/" + values[4]; - } else { - return "/"+ values[3] + "/" + values[4]; - } - }else { - return null; - } - } - - /** - * 获取topic 判断字段 name - **/ - public String parseTopicName4(String topic) { - String[] values = topic.split("/"); - return values[4]; - } - - /** - * 从topic解析物模型类型 - * - * @param topic /{productId}/{serialNumber}/property/post - * @return 物模型类型 - */ - @SneakyThrows - public String getThingsModel(String topic) { - String[] split = topic.split("/"); - return split[2].toUpperCase(); - } - /** * 检查topic的合法性 * @@ -328,7 +153,6 @@ public class TopicsUtils { } } - public static Map, Boolean> handle(int[] src) { int nCnt = src.length; int nBit = (0xFFFFFFFF >>> (32 - nCnt)); @@ -347,15 +171,190 @@ public class TopicsUtils { /** * 构建场景变量上报主题 + * * @param sceneModelId 场景id - * @param: sceneModelDeviceId 场景来源id * @return java.lang.String + * @param: sceneModelDeviceId 场景来源id */ public static String buildSceneReportTopic(Long sceneModelId, Long sceneModelDeviceId) { return "/" + sceneModelId + "/" + sceneModelDeviceId + "/scene/report"; } public static String buildRuleEngineTopic(String requestId) { - return "/" + requestId + "/ruleengine/test"; + return "/" + requestId + "/ruleengine/test"; + } + + /** + * 拼接topic + * + * @param productId 产品id + * @param serialNumber 设备编号 + * @param type 主题类型 + * @return topic + */ + public String buildTopic(Long productId, String serialNumber, TopicType type) { + /* + * 订阅属性: + * 如果启动emq 则为 /+/+/property/post + * 如果启动netty的mqttBroker 则为 /{productId}/{serialNumber}/property/post + * + * 发布都为:/{productId}/{serialNumber}/property/get + */ + String product = String.valueOf(productId); + if (null == productId || productId == -1L || productId == 0L) { + product = "+"; + } + if (com.fastbee.common.utils.StringUtils.isEmpty(serialNumber)) { + serialNumber = "+"; + } + if (type.getType() == 0) { + if (enabled) { + return "/" + product + "/" + serialNumber + type.getTopicSuffix(); + } else { + if (TopicType.FETCH_UPGRADE_REPLY.equals(type) || TopicType.HTTP_UPGRADE_REPLY.equals(type)) { + return FastBeeConstant.MQTT.ONE_PREDIX + type.getTopicSuffix(); + } else { + return FastBeeConstant.MQTT.PREDIX + type.getTopicSuffix(); + } + } +// return enabled ? "/" + product + "/" + serialNumber + type.getTopicSuffix() : FastBeeConstant.MQTT.PREDIX + type.getTopicSuffix(); + } else { + return "/" + product + "/" + serialNumber + type.getTopicSuffix(); + } + } + + public String buildTopic(String serialNumber, TopicType type) { + /* + * 订阅属性: + * 如果启动emq 则为 /+/+/property/post + * 如果启动netty的mqttBroker 则为 /{productId}/{serialNumber}/property/post + * + * 发布都为:/{productId}/{serialNumber}/property/get + */ + + if (com.fastbee.common.utils.StringUtils.isEmpty(serialNumber)) { + serialNumber = "+"; + } + if (type.getType() == 0) { + if (enabled) { + return "/" + serialNumber + type.getTopicSuffix(); + } else { + if (TopicType.FETCH_UPGRADE_REPLY.equals(type) || TopicType.HTTP_UPGRADE_REPLY.equals(type)) { + return FastBeeConstant.MQTT.ONE_PREDIX + type.getTopicSuffix(); + } else { + return FastBeeConstant.MQTT.PREDIX + type.getTopicSuffix(); + } + } +// return enabled ? "/" + serialNumber + type.getTopicSuffix() : FastBeeConstant.MQTT.PREDIX + type.getTopicSuffix(); + } else { + return "/" + serialNumber + type.getTopicSuffix(); + } + } + + /** + * 获取所有可订阅的主题 + * + * @return 订阅主题列表 + */ + public TopicsPost getAllPost() { + List qos = new ArrayList<>(); + List topics = new ArrayList<>(); + TopicsPost post = new TopicsPost(); + for (TopicType topicType : TopicType.values()) { + if (topicType.getType() == 0) { + String topic = this.buildTopic(0L, null, topicType); + topics.add(topic); + qos.add(1); + } + } + post.setTopics(topics.toArray(new String[0])); + int[] ints = Arrays.stream(qos.toArray(new Integer[0])).mapToInt(Integer::valueOf).toArray(); + post.setQos(ints); + return post; + } + + /** + * 替换topic中的产品编码和设备编码,唯一作用是在系统收到来自网关设备上报子设备消息时将topic进行替换 + * + * @param orgTopic String 原始topic + * @param productId String 目标产品编码 + * @param serialNumber String 目标设备编码 + * @return 替换产品编码和设备编码后的新topic + */ + public String topicSubDevice(String orgTopic, Long productId, String serialNumber) { + if (com.fastbee.common.utils.StringUtils.isEmpty(orgTopic)) { + return orgTopic; + } + String[] splits = orgTopic.split("/"); + StringBuilder sb = new StringBuilder(splits[0]) + .append("/") + .append(productId) + .append("/") + .append(serialNumber); + for (int index = 3; index < splits.length; index++) { + sb.append("/").append(splits[index]); + } + return sb.toString(); + } + + /** + * 从topic中获取IMEI号 IMEI即是设备编号 + * + * @param topic /{productId}/{serialNumber}/property/post + * @return serialNumber + */ + @SneakyThrows + public Long parseProductId(String topic) { + String[] values = topic.split("/"); + return Long.parseLong(values[1]); + } + + /** + * 从topic中获取IMEI号 IMEI即是设备编号 + * + * @param topic /{productId}/{serialNumber}/property/post + * @return serialNumber + */ + @SneakyThrows + public String parseSerialNumber(String topic) { + String[] split = topic.split("/"); + String sn = Arrays.stream(split).filter(imei -> imei.length() > 5).findFirst().get(); + return sn; + } + + /** + * 获取topic 判断字段 name + **/ + public String parseTopicName(String topic) { + String[] values = topic.split("/"); + if (values.length > 2) { + if (topic.contains(TopicType.FETCH_UPGRADE_REPLY.getTopicSuffix()) || topic.contains(TopicType.HTTP_UPGRADE_REPLY.getTopicSuffix())) { + return "/" + values[2] + "/" + values[3] + "/" + values[4]; + } else { + return "/" + values[3] + "/" + values[4]; + } + } else { + return null; + } + } + + /** + * 获取topic 判断字段 name + **/ + public String parseTopicName4(String topic) { + String[] values = topic.split("/"); + return values[4]; + } + + /** + * 从topic解析物模型类型 + * + * @param topic /{productId}/{serialNumber}/property/post + * @return 物模型类型 + */ + @SneakyThrows + public String getThingsModel(String topic) { + String[] split = topic.split("/"); + return split[2].toUpperCase(); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/protocol/ByteUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/protocol/ByteUtils.java index f5ee36db..c8e0a69a 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/protocol/ByteUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/protocol/ByteUtils.java @@ -20,702 +20,728 @@ import java.util.UUID; public class ByteUtils { - // public static Payload resolvePayload(byte[] content, short start, ModbusCode code) { - // Payload payload; - // switch (code) { - // case Read01: - // case Read02: - // payload = new RealCoilPayload(start, content); break; - // case Read03: - // case Read04: - // payload = new ReadPayload(content, start); break; - // default: - // payload = WritePayload.getInstance(); - // } - // - // return payload; - // } - - public static Write10Build write10Build(Object... args) { - int num = 0; List bytes = new ArrayList<>(); - for(Object arg : args) { - if(arg instanceof Integer) { - num += 2; - bytes.add(getBytes((Integer) arg)); - } else if(arg instanceof Long) { - num += 4; - bytes.add(getBytes((Long) arg)); - } else if(arg instanceof Float) { - num += 2; - bytes.add(getBytes((Float) arg)); - } else if(arg instanceof Double) { - num += 4; - bytes.add(getBytes((Double) arg)); - } else if(arg instanceof Short) { - num += 1; - bytes.add(getBytesOfReverse((Short) arg)); - } else if(arg instanceof Byte) { - num += 1; - bytes.add(new byte[]{0x00, (byte) arg}); - } else if(arg instanceof String) { - byte[] bytes1 = arg.toString().getBytes(StandardCharsets.UTF_8); - if(bytes1.length % 2 != 0) { - num += bytes1.length / 2 + 1; - byte[] addMessage = new byte[bytes1.length + 1]; - addBytes(addMessage, bytes1, 0); - bytes.add(addMessage); - } else { - num += bytes1.length / 2; - bytes.add(bytes1); - } - } else { - throw new ServiceException("不支持的数据类型"); - } - } - - Integer length = bytes.stream().map(item -> item.length).reduce((a, b) -> a + b).get(); - byte[] write = new byte[length]; - - int index = 0; - for(int i=0; i> 8); - return bytes; - } - - /** - * 将short数据类型转化成Byte数组 - * @see ByteOrder#BIG_ENDIAN - * @param data short值 - * @return byte[]数组 - */ - public static byte[] getBytesOfReverse(short data) { - byte[] bytes = new byte[2]; - bytes[1] = (byte) (data & 0xff); - bytes[0] = (byte) ((data & 0xff00) >> 8); - return bytes; - } - - /** - * @see ByteOrder#LITTLE_ENDIAN - * @param bytes - * @param offset - * @return - */ - public static short bytesToShort(byte[] bytes, int offset) { - return (short) ((0xff & bytes[0 + offset]) | (0xff00 & (bytes[1 + offset] << 8))); - } - - /** - * 将字节数组转换成short数据 - * @see ByteOrder#BIG_ENDIAN - * @param bytes 字节数组 - * @return short值 - */ - public static short bytesToShortOfReverse(byte[] bytes) { - return ByteUtils.bytesToShortOfReverse(bytes, 0); - } - - /** - * 将字节数组转换成short数据,采用倒序的表达方式 - * @param bytes 字节数组 - * @param offset 起始位置 - * @return short值 - */ - public static short bytesToShortOfReverse(byte[] bytes, int offset) { - return (short) ((0xff & bytes[1 + offset]) | (0xff00 & (bytes[0 + offset] << 8))); - } - - /** - * 将int数据类型转化成Byte数组 - * @see ByteOrder#LITTLE_ENDIAN - * @param data int值 - * @return byte[]数组 - */ - public static byte[] getBytes(int data) { - byte[] bytes = new byte[4]; - bytes[0] = (byte) (data & 0xff); - bytes[1] = (byte) ((data >> 8) & 0xff); - bytes[2] = (byte) ((data >> 16) & 0xff); - bytes[3] = (byte) ((data >> 24) & 0xff); - return bytes; - } - - /** - * 将int数据类型转化成Byte数组 倒序 - * @see ByteOrder#BIG_ENDIAN - * @param data int值 - * @return byte[]数组 - */ - public static byte[] getBytesOfReverse(int data) { - byte[] src = new byte[4]; - src[0] = (byte) ((data >> 24) & 0xFF); - src[1] = (byte) ((data >> 16) & 0xFF); - src[2] = (byte) ((data >> 8) & 0xFF); - src[3] = (byte) (data & 0xFF); - return src; - } - - /** - * 将long数据类型转化成Byte数组 - * @see ByteOrder#LITTLE_ENDIAN - * @param data long值 - * @return byte[]数组 - */ - public static byte[] getBytes(long data) { - byte[] bytes = new byte[8]; - bytes[0] = (byte) (data & 0xff); - bytes[1] = (byte) ((data >> 8) & 0xff); - bytes[2] = (byte) ((data >> 16) & 0xff); - bytes[3] = (byte) ((data >> 24) & 0xff); - bytes[4] = (byte) ((data >> 32) & 0xff); - bytes[5] = (byte) ((data >> 40) & 0xff); - bytes[6] = (byte) ((data >> 48) & 0xff); - bytes[7] = (byte) ((data >> 56) & 0xff); - return bytes; - } - - /** - * 将long数据类型转化成Byte数组 倒序 - * @see ByteOrder#BIG_ENDIAN - * @param data long值 - * @return byte[]数组 - */ - public static byte[] getBytesOfReverse(long data) { - byte[] bytes = new byte[8]; - bytes[7] = (byte) (data & 0xff); - bytes[6] = (byte) ((data >> 8) & 0xff); - bytes[5] = (byte) ((data >> 16) & 0xff); - bytes[4] = (byte) ((data >> 24) & 0xff); - bytes[3] = (byte) ((data >> 32) & 0xff); - bytes[2] = (byte) ((data >> 40) & 0xff); - bytes[1] = (byte) ((data >> 48) & 0xff); - bytes[0] = (byte) ((data >> 56) & 0xff); - return bytes; - } - - /** - * 将float数据类型转化成Byte数组 - * @see ByteOrder#LITTLE_ENDIAN - * @param data float值 - * @return byte[]数组 - */ - public static byte[] getBytes(float data) { - int intBits = Float.floatToIntBits(data); - return getBytes(intBits); - } - - /** - * 将float数据类型转化成Byte数组 倒序 - * @see ByteOrder#BIG_ENDIAN - * @param data float值 - * @return byte[]数组 - */ - public static byte[] getBytesOfReverse(float data) { - int intBits = Float.floatToIntBits(data); - return getBytesOfReverse(intBits); - } - - /** - * 将double数据类型转化成Byte数组 - * @see ByteOrder#LITTLE_ENDIAN - * @param data double值 - * @return byte[]数组 - */ - public static byte[] getBytes(double data) { - long intBits = Double.doubleToLongBits(data); - return getBytes(intBits); - } - - /** - * 将double数据类型转化成Byte数组 倒序 - * @see ByteOrder#BIG_ENDIAN - * @param data double值 - * @return byte[]数组 - */ - public static byte[] getBytesOfReverse(double data) { - long intBits = Double.doubleToLongBits(data); - return getBytesOfReverse(intBits); - } - - /** - * 字符串转字节数组(UTF-8) - * @param data - * @return - */ - public static byte[] getBytes(String data) { - return data.getBytes(StandardCharsets.UTF_8); - } - - /** - * 将字符串转换成byte[]数组 - * @param data 字符串值 - * @param charsetName 编码方式 - * @return 字节数组 - */ - public static byte[] getBytes(String data, String charsetName) { - Charset charset = Charset.forName(charsetName); - return data.getBytes(charset); - } - - /* - * 把16进制字符串转换成字节数组 - * @param hex - * @return - */ - public static byte[] hexToByte(String hexStr) { - if(StringUtils.isBlank(hexStr)) { - return null; - } - if(hexStr.length()%2 != 0) {//长度为单数 - hexStr = "0" + hexStr;//前面补0 - } - - char[] chars = hexStr.toCharArray(); - int len = chars.length/2; - byte[] bytes = new byte[len]; - for (int i = 0; i < len; i++) { - int x = i*2; - bytes[i] = (byte)Integer.parseInt(String.valueOf(new char[]{chars[x], chars[x+1]}), 16); - } - return bytes; - - } - - /** - * 将字符串转换为字节数组,强制按十六进制处理 - * 清理字符串后直接转换为十六进制字节数组 - * - * @param command 命令字符串 - * @return 字节数组,转换失败返回空数组 - */ - public static byte[] convertToHexByteArray(String command) { - if (command == null || command.isEmpty()) { - return new byte[0]; - } - try { - // 清理字符串:去除空格、去除0x前缀、补齐偶数长度 - String cleanedCommand = command.trim() - .replaceAll("\\s+", "") // 去除所有空格 - .replaceAll("(?i)^0x", ""); // 去除0x或0X前缀 - - // 如果长度为奇数,在前面补0 - if (cleanedCommand.length() % 2 != 0) { - cleanedCommand = "0" + cleanedCommand; - } - - // 使用现有的hexToByte方法 - byte[] result = hexToByte(cleanedCommand); - return result != null ? result : new byte[0]; - } catch (Exception e) { - // 如果标准方法失败,手动转换为十六进制字节数组 - try { - String cleanedCommand = command.trim() - .replaceAll("\\s+", "") - .replaceAll("(?i)^0x", ""); - - if (cleanedCommand.length() % 2 != 0) { - cleanedCommand = "0" + cleanedCommand; - } - - // 手动将每两个字符转换为一个字节 - byte[] result = new byte[cleanedCommand.length() / 2]; - for (int i = 0; i < cleanedCommand.length(); i += 2) { - String hexByte = cleanedCommand.substring(i, i + 2); - result[i / 2] = (byte) Integer.parseInt(hexByte, 16); - } - return result; - } catch (Exception e2) { - // 如果手动转换也失败,返回空数组 - return new byte[0]; - } - } - } - - public static byte getByte(byte[] src, int offset) { - return src[offset]; - } - - /** - * 字节数组转16进制 - * @param bArray - * @return - */ - public static final String bytesToHex(byte[] bArray) { - StringBuffer sb = new StringBuffer(bArray.length); - String sTemp; - for (int i = 0; i < bArray.length; i++) { - sTemp = Integer.toHexString(0xFF & bArray[i]); - if (sTemp.length() < 2) sb.append(0); - sb.append(sTemp.toUpperCase()); - } - return sb.toString(); - } - - /** - * 字节数组转16进制且格式化十六进制 - * @param bArray - * @return - */ - public static final String bytesToHexByFormat(byte[] bArray) { - StringBuffer sb = new StringBuffer(bArray.length); - String sTemp; - for (int i = 0; i < bArray.length; i++) { - sTemp = Integer.toHexString(0xFF & bArray[i]); - if (sTemp.length() < 2) sb.append(0); - sb.append(sTemp.toUpperCase()).append(' '); - } - return sb.toString(); - } - - /** - * 字节数组转16进制 - * @param src - * @return - */ - public static final String bytesToHex(byte[] src, int offset, int length) { - byte[] bArray = ArrayUtils.subarray(src, offset, offset + length); - return bytesToHex(bArray); - } - - public static final String byteToHex(byte value) { - String s = Integer.toHexString(0xff & value); - if(s.length() == 1) return "0"+s; - return s; - } - - public static final String shortToHex(short value) { - String s = Integer.toHexString(value); - switch (s.length()) { - case 1: return "000" + s; - case 2: return "00" + s; - case 3: return "0" + s; - default: return s; - } - } - - public static final String intToHex(int value) { - StringBuilder s = new StringBuilder(Integer.toHexString(value)); - String v1 = s.toString().replace("f",""); - if (v1.length() <4){ - for (int i = 0; i < 4 - v1.length(); i++) { - s.insert(0, "0"); - } - return s.toString().replace("f",""); - } - else return s.toString().replace("f",""); - } - - public static final String hexTo8Bit(int value,int index){ - String s = Integer.toBinaryString(value); - StringBuilder result = new StringBuilder(s); - if (s.length() < index){ - for (int i = 0; i < index - s.length(); i++) { - result.insert(0,"0"); - } - } - return result.toString(); - } - - /** - * @函数功能: BCD码转为10进制串(阿拉伯数据) - * @输入参数: BCD码 - * @输出结果: 10进制串 - */ - public static String bcdToStr(byte[] bytes){ - StringBuffer temp=new StringBuffer(bytes.length*2); - - for(int i=0;i>>4)); - temp.append((byte)(bytes[i] & 0x0f)); - } - - return temp.toString(); - } - - /** - * - * @param src 原报文 - * @param offset 起始位置 - * @param length 长度 - * @return - */ - public static String bcdToStr(byte[] src, int offset, int length){ - byte[] bArray = ArrayUtils.subarray(src, offset, offset + length); - return bcdToStr(bArray); - } - - public static byte[] str2Bcd(String asc) { - int len = asc.length(); - int mod = len % 2; - - if (mod != 0) { - asc = "0" + asc; - len = asc.length(); - } - - byte abt[]; - if (len >= 2) { - len = len / 2; - } - - byte bbt[] = new byte[len]; - abt = asc.getBytes(); - int j, k; - - for (int p = 0; p < asc.length()/2; p++) { - if ( (abt[2 * p] >= '0') && (abt[2 * p] <= '9')) { - j = abt[2 * p] - '0'; - } else if ( (abt[2 * p] >= 'a') && (abt[2 * p] <= 'z')) { - j = abt[2 * p] - 'a' + 0x0a; - } else { - j = abt[2 * p] - 'A' + 0x0a; - } - - if ( (abt[2 * p + 1] >= '0') && (abt[2 * p + 1] <= '9')) { - k = abt[2 * p + 1] - '0'; - } else if ( (abt[2 * p + 1] >= 'a') && (abt[2 * p + 1] <= 'z')) { - k = abt[2 * p + 1] - 'a' + 0x0a; - }else { - k = abt[2 * p + 1] - 'A' + 0x0a; - } - - int a = (j << 4) + k; - byte b = (byte) a; - bbt[p] = b; - } - return bbt; - } - - private static byte toByte(char c) { - return (byte) c; - } - - /** - * 将字节数组转换成 ushort 数据 - * @param bytes 字节数组 - * @param offset 起始位置 - * @return short值 - */ - public static int bytesToUShort(byte[] bytes, int offset) { - return ((0xff & bytes[0 + offset]) | (0xff00 & (bytes[1 + offset] << 8))); - } - - /** - * 将字节数组转换成 ushort 数据,采用倒序的方式 - * @param bytes 字节数组 - * @return short值 - */ - public static int bytesToUShortOfReverse(byte[] bytes) { - return ByteUtils.bytesToShortOfReverse(bytes, 0); - } - - /** - * 将字节数组转换成 ushort 数据,采用倒序的方式 - * @param bytes 字节数组 - * @param offset 起始位置 - * @return short值 - */ - public static int bytesToUShortOfReverse(byte[] bytes, int offset) { - return ((0xff & bytes[1 + offset]) | (0xff00 & (bytes[0 + offset] << 8))); - } - - /** - * byte数组中取int数值,本方法适用于(低位在前,高位在后)的顺序,和intToBytes配套使用 - * - * @param src - * byte数组 - * @param offset - * 从数组的第offset位开始 - * @return int数值 - */ - public static int bytesToInt(byte[] src, int offset) { - return ((src[offset] & 0xFF) | ((src[offset + 1] & 0xFF) << 8) - | ((src[offset + 2] & 0xFF) << 16) | ((src[offset + 3] & 0xFF) << 24)); - } - - /** - * byte数组中取int数值,本方法适用于(低位在前,高位在后)的顺序,和intToBytes配套使用 - * @param src byte数组 - * @return int数值 - */ - public static int bytesToInt(byte[] src) { - return ByteUtils.bytesToInt(src, 0); - } - - /** - * 将字节数组转换成int数据,采用倒序的方式 - * @param bytes 字节数组 - * @param offset 起始位置 - * @return int值 - */ - public static int bytesToIntOfReverse(byte[] bytes, int offset) { - return (0xff & bytes[3 + offset]) | - (0xff00 & (bytes[2 + offset] << 8)) | - (0xff0000 & (bytes[1 + offset] << 16)) | - (0xff000000 & (bytes[0 + offset] << 24)); - } - - /** - * 将字节数组转换成int数据,采用倒序的方式 - * @param bytes 字节数组 - * @return int值 - */ - public static int bytesToIntOfReverse(byte[] bytes) { - return ByteUtils.bytesToIntOfReverse(bytes, 0); - } - - /** - * 将字节数组转换成uint数据 - * @param bytes 字节数组 - * @param offset 起始位置 - * @return int值 - */ - public static long bytesToUInt(byte[] bytes, int offset) { - int value = bytesToInt(bytes, offset); - if (value >= 0) return value; - return 65536L * 65536L + value; - } - - /** - * 将字节数组转换成uint数据 - * @param bytes 字节数组 - * @return int值 - */ - public static long bytesToUInt(byte[] bytes) { - return ByteUtils.bytesToUInt(bytes, 0); - } - - /** - * 将字节数组转换成uint数据 - * @param bytes 字节数组 - * @param offset 起始位置 - * @return int值 - */ - public static long bytesToUIntOfReverse(byte[] bytes, int offset) { - int value = bytesToIntOfReverse(bytes, offset); - if (value >= 0) return value; - return 65536L * 65536L + value; - } - - /** - * 将字节数组转换成uint数据 倒序 - * @param bytes 字节数组 - * @return int值 - */ - public static long bytesToUIntOfReverse(byte[] bytes) { - return ByteUtils.bytesToUIntOfReverse(bytes, 0); - } - - /** - * 将字节数组转换成float数据 - * @param bytes 字节数组 - * @return float值 - */ - public static float bytesToFloat(byte[] bytes) { - return Float.intBitsToFloat(bytesToInt(bytes, 0)); - } - - /** - * 将字节数组转换成float数据 - * @param bytes 字节数组 - * @param offset 起始位置 - * @return float值 - */ - public static float bytesToFloat(byte[] bytes, int offset) { - return Float.intBitsToFloat(bytesToInt(bytes,offset)); - } - - /** - * 将字节数组转换成float数据 - * @param bytes 字节数组 - * @return float值 - */ - public static float bytesToFloatOfReverse(byte[] bytes) { - return bytesToFloatOfReverse(bytes, 0); - } - - /** - * 将字节数组转换成float数据 - * @param bytes 字节数组 - * @param offset 偏移量 - * @return float值 - */ - public static float bytesToFloatOfReverse(byte[] bytes, int offset) { - return Float.intBitsToFloat(bytesToIntOfReverse(bytes, offset)); - } - - - /** - * byte数组中取double数值 - * @param src byte数组 - * @return double数值 - */ - public static double bytesToDouble(byte[] src) { - return Double.longBitsToDouble(bytesToLong(src)); - } - - /** - * byte数组中取double数值 - * @param src byte数组 - * @param offset 从数组的第offset位开始 - * @return double数值 - */ - public static double bytesToDouble(byte[] src, int offset) { - return Double.longBitsToDouble(bytesToLong(src, offset)); - } - - /** - * byte数组中取double数值 - * @param src byte数组 - * @return double数值 - */ - public static double bytesToDoubleOfReverse(byte[] src) { - return bytesToDoubleOfReverse(src, 0); - } + // public static Payload resolvePayload(byte[] content, short start, ModbusCode code) { + // Payload payload; + // switch (code) { + // case Read01: + // case Read02: + // payload = new RealCoilPayload(start, content); break; + // case Read03: + // case Read04: + // payload = new ReadPayload(content, start); break; + // default: + // payload = WritePayload.getInstance(); + // } + // + // return payload; + // } + + public static Write10Build write10Build(Object... args) { + int num = 0; + List bytes = new ArrayList<>(); + for (Object arg : args) { + if (arg instanceof Integer) { + num += 2; + bytes.add(getBytes((Integer) arg)); + } else if (arg instanceof Long) { + num += 4; + bytes.add(getBytes((Long) arg)); + } else if (arg instanceof Float) { + num += 2; + bytes.add(getBytes((Float) arg)); + } else if (arg instanceof Double) { + num += 4; + bytes.add(getBytes((Double) arg)); + } else if (arg instanceof Short) { + num += 1; + bytes.add(getBytesOfReverse((Short) arg)); + } else if (arg instanceof Byte) { + num += 1; + bytes.add(new byte[]{0x00, (byte) arg}); + } else if (arg instanceof String) { + byte[] bytes1 = arg.toString().getBytes(StandardCharsets.UTF_8); + if (bytes1.length % 2 != 0) { + num += bytes1.length / 2 + 1; + byte[] addMessage = new byte[bytes1.length + 1]; + addBytes(addMessage, bytes1, 0); + bytes.add(addMessage); + } else { + num += bytes1.length / 2; + bytes.add(bytes1); + } + } else { + throw new ServiceException("不支持的数据类型"); + } + } + + Integer length = bytes.stream().map(item -> item.length).reduce((a, b) -> a + b).get(); + byte[] write = new byte[length]; + + int index = 0; + for (int i = 0; i < bytes.size(); i++) { + byte[] values = bytes.get(i); + addBytes(write, values, index); + index += values.length; + } + + return new Write10Build(num, write); + } + + public static byte[] create(byte b) { + return new byte[]{b}; + } + + /** + * 字节转成字节数组 + * + * @param data + * @return + */ + public static byte[] getBytes(byte data) { + return new byte[]{data}; + } + + /** + * 将short数据类型转化成Byte数组 + * + * @param data short值 + * @return byte[]数组 + * @see ByteOrder#LITTLE_ENDIAN + */ + public static byte[] getBytes(short data) { + byte[] bytes = new byte[2]; + bytes[0] = (byte) (data & 0xff); + bytes[1] = (byte) ((data & 0xff00) >> 8); + return bytes; + } + + /** + * 将short数据类型转化成Byte数组 + * + * @param data short值 + * @return byte[]数组 + * @see ByteOrder#BIG_ENDIAN + */ + public static byte[] getBytesOfReverse(short data) { + byte[] bytes = new byte[2]; + bytes[1] = (byte) (data & 0xff); + bytes[0] = (byte) ((data & 0xff00) >> 8); + return bytes; + } + + /** + * @param bytes + * @param offset + * @return + * @see ByteOrder#LITTLE_ENDIAN + */ + public static short bytesToShort(byte[] bytes, int offset) { + return (short) ((0xff & bytes[offset]) | (0xff00 & (bytes[1 + offset] << 8))); + } + + /** + * 将字节数组转换成short数据 + * + * @param bytes 字节数组 + * @return short值 + * @see ByteOrder#BIG_ENDIAN + */ + public static short bytesToShortOfReverse(byte[] bytes) { + return ByteUtils.bytesToShortOfReverse(bytes, 0); + } + + /** + * 将字节数组转换成short数据,采用倒序的表达方式 + * + * @param bytes 字节数组 + * @param offset 起始位置 + * @return short值 + */ + public static short bytesToShortOfReverse(byte[] bytes, int offset) { + return (short) ((0xff & bytes[1 + offset]) | (0xff00 & (bytes[offset] << 8))); + } + + /** + * 将int数据类型转化成Byte数组 + * + * @param data int值 + * @return byte[]数组 + * @see ByteOrder#LITTLE_ENDIAN + */ + public static byte[] getBytes(int data) { + byte[] bytes = new byte[4]; + bytes[0] = (byte) (data & 0xff); + bytes[1] = (byte) ((data >> 8) & 0xff); + bytes[2] = (byte) ((data >> 16) & 0xff); + bytes[3] = (byte) ((data >> 24) & 0xff); + return bytes; + } + + /** + * 将int数据类型转化成Byte数组 倒序 + * + * @param data int值 + * @return byte[]数组 + * @see ByteOrder#BIG_ENDIAN + */ + public static byte[] getBytesOfReverse(int data) { + byte[] src = new byte[4]; + src[0] = (byte) ((data >> 24) & 0xFF); + src[1] = (byte) ((data >> 16) & 0xFF); + src[2] = (byte) ((data >> 8) & 0xFF); + src[3] = (byte) (data & 0xFF); + return src; + } + + /** + * 将long数据类型转化成Byte数组 + * + * @param data long值 + * @return byte[]数组 + * @see ByteOrder#LITTLE_ENDIAN + */ + public static byte[] getBytes(long data) { + byte[] bytes = new byte[8]; + bytes[0] = (byte) (data & 0xff); + bytes[1] = (byte) ((data >> 8) & 0xff); + bytes[2] = (byte) ((data >> 16) & 0xff); + bytes[3] = (byte) ((data >> 24) & 0xff); + bytes[4] = (byte) ((data >> 32) & 0xff); + bytes[5] = (byte) ((data >> 40) & 0xff); + bytes[6] = (byte) ((data >> 48) & 0xff); + bytes[7] = (byte) ((data >> 56) & 0xff); + return bytes; + } + + /** + * 将long数据类型转化成Byte数组 倒序 + * + * @param data long值 + * @return byte[]数组 + * @see ByteOrder#BIG_ENDIAN + */ + public static byte[] getBytesOfReverse(long data) { + byte[] bytes = new byte[8]; + bytes[7] = (byte) (data & 0xff); + bytes[6] = (byte) ((data >> 8) & 0xff); + bytes[5] = (byte) ((data >> 16) & 0xff); + bytes[4] = (byte) ((data >> 24) & 0xff); + bytes[3] = (byte) ((data >> 32) & 0xff); + bytes[2] = (byte) ((data >> 40) & 0xff); + bytes[1] = (byte) ((data >> 48) & 0xff); + bytes[0] = (byte) ((data >> 56) & 0xff); + return bytes; + } + + /** + * 将float数据类型转化成Byte数组 + * + * @param data float值 + * @return byte[]数组 + * @see ByteOrder#LITTLE_ENDIAN + */ + public static byte[] getBytes(float data) { + int intBits = Float.floatToIntBits(data); + return getBytes(intBits); + } + + /** + * 将float数据类型转化成Byte数组 倒序 + * + * @param data float值 + * @return byte[]数组 + * @see ByteOrder#BIG_ENDIAN + */ + public static byte[] getBytesOfReverse(float data) { + int intBits = Float.floatToIntBits(data); + return getBytesOfReverse(intBits); + } + + /** + * 将double数据类型转化成Byte数组 + * + * @param data double值 + * @return byte[]数组 + * @see ByteOrder#LITTLE_ENDIAN + */ + public static byte[] getBytes(double data) { + long intBits = Double.doubleToLongBits(data); + return getBytes(intBits); + } + + /** + * 将double数据类型转化成Byte数组 倒序 + * + * @param data double值 + * @return byte[]数组 + * @see ByteOrder#BIG_ENDIAN + */ + public static byte[] getBytesOfReverse(double data) { + long intBits = Double.doubleToLongBits(data); + return getBytesOfReverse(intBits); + } + + /** + * 字符串转字节数组(UTF-8) + * + * @param data + * @return + */ + public static byte[] getBytes(String data) { + return data.getBytes(StandardCharsets.UTF_8); + } + + /** + * 将字符串转换成byte[]数组 + * + * @param data 字符串值 + * @param charsetName 编码方式 + * @return 字节数组 + */ + public static byte[] getBytes(String data, String charsetName) { + Charset charset = Charset.forName(charsetName); + return data.getBytes(charset); + } + + /* + * 把16进制字符串转换成字节数组 + * @param hex + * @return + */ + public static byte[] hexToByte(String hexStr) { + if (StringUtils.isBlank(hexStr)) { + return null; + } + if (hexStr.length() % 2 != 0) {//长度为单数 + hexStr = "0" + hexStr;//前面补0 + } + + char[] chars = hexStr.toCharArray(); + int len = chars.length / 2; + byte[] bytes = new byte[len]; + for (int i = 0; i < len; i++) { + int x = i * 2; + bytes[i] = (byte) Integer.parseInt(String.valueOf(new char[]{chars[x], chars[x + 1]}), 16); + } + return bytes; + + } + + /** + * 将字符串转换为字节数组,强制按十六进制处理 + * 清理字符串后直接转换为十六进制字节数组 + * + * @param command 命令字符串 + * @return 字节数组,转换失败返回空数组 + */ + public static byte[] convertToHexByteArray(String command) { + if (command == null || command.isEmpty()) { + return new byte[0]; + } + try { + // 清理字符串:去除空格、去除0x前缀、补齐偶数长度 + String cleanedCommand = command.trim() + .replaceAll("\\s+", "") // 去除所有空格 + .replaceAll("(?i)^0x", ""); // 去除0x或0X前缀 + + // 如果长度为奇数,在前面补0 + if (cleanedCommand.length() % 2 != 0) { + cleanedCommand = "0" + cleanedCommand; + } + + // 使用现有的hexToByte方法 + byte[] result = hexToByte(cleanedCommand); + return result != null ? result : new byte[0]; + } catch (Exception e) { + // 如果标准方法失败,手动转换为十六进制字节数组 + try { + String cleanedCommand = command.trim() + .replaceAll("\\s+", "") + .replaceAll("(?i)^0x", ""); + + if (cleanedCommand.length() % 2 != 0) { + cleanedCommand = "0" + cleanedCommand; + } + + // 手动将每两个字符转换为一个字节 + byte[] result = new byte[cleanedCommand.length() / 2]; + for (int i = 0; i < cleanedCommand.length(); i += 2) { + String hexByte = cleanedCommand.substring(i, i + 2); + result[i / 2] = (byte) Integer.parseInt(hexByte, 16); + } + return result; + } catch (Exception e2) { + // 如果手动转换也失败,返回空数组 + return new byte[0]; + } + } + } + + public static byte getByte(byte[] src, int offset) { + return src[offset]; + } + + /** + * 字节数组转16进制 + * + * @param bArray + * @return + */ + public static final String bytesToHex(byte[] bArray) { + StringBuffer sb = new StringBuffer(bArray.length); + String sTemp; + for (int i = 0; i < bArray.length; i++) { + sTemp = Integer.toHexString(0xFF & bArray[i]); + if (sTemp.length() < 2) sb.append(0); + sb.append(sTemp.toUpperCase()); + } + return sb.toString(); + } + + /** + * 字节数组转16进制且格式化十六进制 + * + * @param bArray + * @return + */ + public static final String bytesToHexByFormat(byte[] bArray) { + StringBuffer sb = new StringBuffer(bArray.length); + String sTemp; + for (int i = 0; i < bArray.length; i++) { + sTemp = Integer.toHexString(0xFF & bArray[i]); + if (sTemp.length() < 2) sb.append(0); + sb.append(sTemp.toUpperCase()).append(' '); + } + return sb.toString(); + } + + /** + * 字节数组转16进制 + * + * @param src + * @return + */ + public static final String bytesToHex(byte[] src, int offset, int length) { + byte[] bArray = ArrayUtils.subarray(src, offset, offset + length); + return bytesToHex(bArray); + } + + public static final String byteToHex(byte value) { + String s = Integer.toHexString(0xff & value); + if (s.length() == 1) return "0" + s; + return s; + } + + public static final String shortToHex(short value) { + String s = Integer.toHexString(value); + switch (s.length()) { + case 1: + return "000" + s; + case 2: + return "00" + s; + case 3: + return "0" + s; + default: + return s; + } + } + + public static final String intToHex(int value) { + StringBuilder s = new StringBuilder(Integer.toHexString(value)); + String v1 = s.toString().replace("f", ""); + if (v1.length() < 4) { + for (int i = 0; i < 4 - v1.length(); i++) { + s.insert(0, "0"); + } + return s.toString().replace("f", ""); + } else return s.toString().replace("f", ""); + } + + public static final String hexTo8Bit(int value, int index) { + String s = Integer.toBinaryString(value); + StringBuilder result = new StringBuilder(s); + if (s.length() < index) { + for (int i = 0; i < index - s.length(); i++) { + result.insert(0, "0"); + } + } + return result.toString(); + } + + /** + * @函数功能: BCD码转为10进制串(阿拉伯数据) + * @输入参数: BCD码 + * @输出结果: 10进制串 + */ + public static String bcdToStr(byte[] bytes) { + StringBuffer temp = new StringBuffer(bytes.length * 2); + + for (int i = 0; i < bytes.length; i++) { + temp.append((byte) ((bytes[i] & 0xf0) >>> 4)); + temp.append((byte) (bytes[i] & 0x0f)); + } + + return temp.toString(); + } + + /** + * @param src 原报文 + * @param offset 起始位置 + * @param length 长度 + * @return + */ + public static String bcdToStr(byte[] src, int offset, int length) { + byte[] bArray = ArrayUtils.subarray(src, offset, offset + length); + return bcdToStr(bArray); + } + + public static byte[] str2Bcd(String asc) { + int len = asc.length(); + int mod = len % 2; + + if (mod != 0) { + asc = "0" + asc; + len = asc.length(); + } + + byte[] abt; + if (len >= 2) { + len = len / 2; + } + + byte[] bbt = new byte[len]; + abt = asc.getBytes(); + int j, k; + + for (int p = 0; p < asc.length() / 2; p++) { + if ((abt[2 * p] >= '0') && (abt[2 * p] <= '9')) { + j = abt[2 * p] - '0'; + } else if ((abt[2 * p] >= 'a') && (abt[2 * p] <= 'z')) { + j = abt[2 * p] - 'a' + 0x0a; + } else { + j = abt[2 * p] - 'A' + 0x0a; + } + + if ((abt[2 * p + 1] >= '0') && (abt[2 * p + 1] <= '9')) { + k = abt[2 * p + 1] - '0'; + } else if ((abt[2 * p + 1] >= 'a') && (abt[2 * p + 1] <= 'z')) { + k = abt[2 * p + 1] - 'a' + 0x0a; + } else { + k = abt[2 * p + 1] - 'A' + 0x0a; + } + + int a = (j << 4) + k; + byte b = (byte) a; + bbt[p] = b; + } + return bbt; + } + + private static byte toByte(char c) { + return (byte) c; + } + + /** + * 将字节数组转换成 ushort 数据 + * + * @param bytes 字节数组 + * @param offset 起始位置 + * @return short值 + */ + public static int bytesToUShort(byte[] bytes, int offset) { + return ((0xff & bytes[offset]) | (0xff00 & (bytes[1 + offset] << 8))); + } + + /** + * 将字节数组转换成 ushort 数据,采用倒序的方式 + * + * @param bytes 字节数组 + * @return short值 + */ + public static int bytesToUShortOfReverse(byte[] bytes) { + return ByteUtils.bytesToShortOfReverse(bytes, 0); + } + + /** + * 将字节数组转换成 ushort 数据,采用倒序的方式 + * + * @param bytes 字节数组 + * @param offset 起始位置 + * @return short值 + */ + public static int bytesToUShortOfReverse(byte[] bytes, int offset) { + return ((0xff & bytes[1 + offset]) | (0xff00 & (bytes[offset] << 8))); + } + + /** + * byte数组中取int数值,本方法适用于(低位在前,高位在后)的顺序,和intToBytes配套使用 + * + * @param src byte数组 + * @param offset 从数组的第offset位开始 + * @return int数值 + */ + public static int bytesToInt(byte[] src, int offset) { + return ((src[offset] & 0xFF) | ((src[offset + 1] & 0xFF) << 8) + | ((src[offset + 2] & 0xFF) << 16) | ((src[offset + 3] & 0xFF) << 24)); + } + + /** + * byte数组中取int数值,本方法适用于(低位在前,高位在后)的顺序,和intToBytes配套使用 + * + * @param src byte数组 + * @return int数值 + */ + public static int bytesToInt(byte[] src) { + return ByteUtils.bytesToInt(src, 0); + } + + /** + * 将字节数组转换成int数据,采用倒序的方式 + * + * @param bytes 字节数组 + * @param offset 起始位置 + * @return int值 + */ + public static int bytesToIntOfReverse(byte[] bytes, int offset) { + return (0xff & bytes[3 + offset]) | + (0xff00 & (bytes[2 + offset] << 8)) | + (0xff0000 & (bytes[1 + offset] << 16)) | + (0xff000000 & (bytes[offset] << 24)); + } + + /** + * 将字节数组转换成int数据,采用倒序的方式 + * + * @param bytes 字节数组 + * @return int值 + */ + public static int bytesToIntOfReverse(byte[] bytes) { + return ByteUtils.bytesToIntOfReverse(bytes, 0); + } + + /** + * 将字节数组转换成uint数据 + * + * @param bytes 字节数组 + * @param offset 起始位置 + * @return int值 + */ + public static long bytesToUInt(byte[] bytes, int offset) { + int value = bytesToInt(bytes, offset); + if (value >= 0) return value; + return 65536L * 65536L + value; + } + + /** + * 将字节数组转换成uint数据 + * + * @param bytes 字节数组 + * @return int值 + */ + public static long bytesToUInt(byte[] bytes) { + return ByteUtils.bytesToUInt(bytes, 0); + } + + /** + * 将字节数组转换成uint数据 + * + * @param bytes 字节数组 + * @param offset 起始位置 + * @return int值 + */ + public static long bytesToUIntOfReverse(byte[] bytes, int offset) { + int value = bytesToIntOfReverse(bytes, offset); + if (value >= 0) return value; + return 65536L * 65536L + value; + } + + /** + * 将字节数组转换成uint数据 倒序 + * + * @param bytes 字节数组 + * @return int值 + */ + public static long bytesToUIntOfReverse(byte[] bytes) { + return ByteUtils.bytesToUIntOfReverse(bytes, 0); + } + + /** + * 将字节数组转换成float数据 + * + * @param bytes 字节数组 + * @return float值 + */ + public static float bytesToFloat(byte[] bytes) { + return Float.intBitsToFloat(bytesToInt(bytes, 0)); + } + + /** + * 将字节数组转换成float数据 + * + * @param bytes 字节数组 + * @param offset 起始位置 + * @return float值 + */ + public static float bytesToFloat(byte[] bytes, int offset) { + return Float.intBitsToFloat(bytesToInt(bytes, offset)); + } + + /** + * 将字节数组转换成float数据 + * + * @param bytes 字节数组 + * @return float值 + */ + public static float bytesToFloatOfReverse(byte[] bytes) { + return bytesToFloatOfReverse(bytes, 0); + } + + /** + * 将字节数组转换成float数据 + * + * @param bytes 字节数组 + * @param offset 偏移量 + * @return float值 + */ + public static float bytesToFloatOfReverse(byte[] bytes, int offset) { + return Float.intBitsToFloat(bytesToIntOfReverse(bytes, offset)); + } /** * byte数组中取double数值 + * * @param src byte数组 + * @return double数值 + */ + public static double bytesToDouble(byte[] src) { + return Double.longBitsToDouble(bytesToLong(src)); + } + + /** + * byte数组中取double数值 + * + * @param src byte数组 + * @param offset 从数组的第offset位开始 + * @return double数值 + */ + public static double bytesToDouble(byte[] src, int offset) { + return Double.longBitsToDouble(bytesToLong(src, offset)); + } + + /** + * byte数组中取double数值 + * + * @param src byte数组 + * @return double数值 + */ + public static double bytesToDoubleOfReverse(byte[] src) { + return bytesToDoubleOfReverse(src, 0); + } + + /** + * byte数组中取double数值 + * + * @param src byte数组 * @param offset 从数组的第offset位开始 * @return double数值 */ @@ -723,286 +749,308 @@ public class ByteUtils { return Double.longBitsToDouble(bytesToLongOfReverse(src, offset)); } - /** - * 去掉字节数组尾数为零的字节,并将其转成字符串 - * @param src - * @param charset - * @return - */ - public static String bytesToString(byte[] src, Charset charset){ - int search = Arrays.binarySearch(src, (byte) 0); - return new String(Arrays.copyOf(src, search), charset); - } + /** + * 去掉字节数组尾数为零的字节,并将其转成字符串 + * + * @param src + * @param charset + * @return + */ + public static String bytesToString(byte[] src, Charset charset) { + int search = Arrays.binarySearch(src, (byte) 0); + return new String(Arrays.copyOf(src, search), charset); + } - /** - * 去掉字节数组尾数为零的字节,并将其转成字符串 - * @param src - * @return - */ - public static String bytesToString(byte[] src){ - return new String(wipeLastZero(src)); - } + /** + * 去掉字节数组尾数为零的字节,并将其转成字符串 + * + * @param src + * @return + */ + public static String bytesToString(byte[] src) { + return new String(wipeLastZero(src)); + } - /** - * 去掉字节数组尾数为零的字节,并将其转成字符串 - * @param src - * @return - */ - public static String bytesToString(byte[] src, int startIndex, int endIndex){ - return new String(wipeLastZero(subBytes(src, startIndex, endIndex))); - } + /** + * 去掉字节数组尾数为零的字节,并将其转成字符串 + * + * @param src + * @return + */ + public static String bytesToString(byte[] src, int startIndex, int endIndex) { + return new String(wipeLastZero(subBytes(src, startIndex, endIndex))); + } - /** - * 去掉字节数组尾数为零的字节,并将其转成字符串 - * @param src - * @return - */ - public static String bytesToString(byte[] src, int startIndex, int endIndex, Charset charset){ - return new String(wipeLastZero(subBytes(src, startIndex, endIndex)), charset); - } + /** + * 去掉字节数组尾数为零的字节,并将其转成字符串 + * + * @param src + * @return + */ + public static String bytesToString(byte[] src, int startIndex, int endIndex, Charset charset) { + return new String(wipeLastZero(subBytes(src, startIndex, endIndex)), charset); + } - /** - * 将byte[]数组的数据进行翻转 - * @param reverse 等待反转的字符串 - */ - public static void bytesReverse(byte[] reverse) { - if (reverse != null) { - byte tmp = 0; - for (int i = 0; i < reverse.length / 2; i++) { - tmp = reverse[i]; - reverse[i] = reverse[reverse.length - 1 - i]; - reverse[reverse.length - 1 - i] = tmp; - } - } - } + /** + * 将byte[]数组的数据进行翻转 + * + * @param reverse 等待反转的字符串 + */ + public static void bytesReverse(byte[] reverse) { + if (reverse != null) { + byte tmp = 0; + for (int i = 0; i < reverse.length / 2; i++) { + tmp = reverse[i]; + reverse[i] = reverse[reverse.length - 1 - i]; + reverse[reverse.length - 1 - i] = tmp; + } + } + } - /** - * 去除包含0的字节 - * @param src - * @return - */ - private static byte[] wipeLastZero(byte[] src){ - int index = 0; - for(int i=0; i + * 源字节数组 + * + * @param targetBytes 添加对象数组 + * @param beginIndex 开始下标 + * @return + */ + public static byte[] addBytes(byte[] sourceBytes, byte[] targetBytes, int beginIndex) { + if (targetBytes == null) { + return sourceBytes; + } + int targetSize = targetBytes.length; + if (sourceBytes == null) { + beginIndex = 0; + sourceBytes = new byte[targetSize]; + } + int sourceSize = sourceBytes.length; + if (sourceSize - beginIndex < targetSize) { + return sourceBytes; + } else { + System.arraycopy(targetBytes, 0, sourceBytes, beginIndex + 0, targetSize); + } + return sourceBytes; - } + } - /** - * 将一个uuid对象转化成byte[] - * @param uuid uuid对象 - * @return 字节数组 - */ - public static byte[] UUID2Byte(UUID uuid) { - ByteArrayOutputStream ba = new ByteArrayOutputStream(16); - DataOutputStream da = new DataOutputStream(ba); - try { - da.writeLong(uuid.getMostSignificantBits()); - da.writeLong(uuid.getLeastSignificantBits()); - ba.close(); - da.close(); - } - catch (IOException e) { - e.printStackTrace(); - } + /** + * 将一个uuid对象转化成byte[] + * + * @param uuid uuid对象 + * @return 字节数组 + */ + public static byte[] UUID2Byte(UUID uuid) { + ByteArrayOutputStream ba = new ByteArrayOutputStream(16); + DataOutputStream da = new DataOutputStream(ba); + try { + da.writeLong(uuid.getMostSignificantBits()); + da.writeLong(uuid.getLeastSignificantBits()); + ba.close(); + da.close(); + } catch (IOException e) { + e.printStackTrace(); + } - byte[] buffer = ba.toByteArray(); - // 进行错位 - byte temp=buffer[0]; - buffer[0] = buffer[3]; - buffer[3] =temp; - temp=buffer[1]; - buffer[1]=buffer[2]; - buffer[2]=temp; + byte[] buffer = ba.toByteArray(); + // 进行错位 + byte temp = buffer[0]; + buffer[0] = buffer[3]; + buffer[3] = temp; + temp = buffer[1]; + buffer[1] = buffer[2]; + buffer[2] = temp; - temp = buffer[4]; - buffer[4]=buffer[5]; - buffer[5] =temp; + temp = buffer[4]; + buffer[4] = buffer[5]; + buffer[5] = temp; - temp = buffer[6]; - buffer[6]=buffer[7]; - buffer[7] =temp; + temp = buffer[6]; + buffer[6] = buffer[7]; + buffer[7] = temp; - return buffer; - } + return buffer; + } - /** - * 获取字节的指定位值 0 or 1 - * @param value - * @param index - * @return - */ - public static byte bitAtByte(byte value, int index) { - return (byte) ((value & (1 << index)) > 0 ? 1 : 0); - } + /** + * 获取字节的指定位值 0 or 1 + * + * @param value + * @param index + * @return + */ + public static byte bitAtByte(byte value, int index) { + return (byte) ((value & (1 << index)) > 0 ? 1 : 0); + } - /** - *将bool数组转换到byte数组
- * @param array bool数组 - * @return 字节数组 - */ - public static byte[] boolArrayToByte(boolean[] array) { - if (array == null) return null; + /** + * 将bool数组转换到byte数组
+ * + * @param array bool数组 + * @return 字节数组 + */ + public static byte[] boolArrayToByte(boolean[] array) { + if (array == null) return null; - int length = array.length % 8 == 0 ? array.length / 8 : array.length / 8 + 1; - byte[] buffer = new byte[length]; + int length = array.length % 8 == 0 ? array.length / 8 : array.length / 8 + 1; + byte[] buffer = new byte[length]; - for (int i = 0; i < array.length; i++) { - if (array[i]) { - buffer[i / 8] += (1 << i % 8); - } - } + for (int i = 0; i < array.length; i++) { + if (array[i]) { + buffer[i / 8] += (1 << i % 8); + } + } - return buffer; - } + return buffer; + } - public static Integer cutMessageHexTo(byte[] source, int startIndex, int endIndex){ - byte[] subarray = ArrayUtils.subarray(source, startIndex, endIndex); - String s = bytesToHexString(subarray); - return Integer.parseInt(s,16); - } + public static Integer cutMessageHexTo(byte[] source, int startIndex, int endIndex) { + byte[] subarray = ArrayUtils.subarray(source, startIndex, endIndex); + String s = bytesToHexString(subarray); + return Integer.parseInt(s, 16); + } - /** - * byte数组转换炒年糕十六进制字符串 - * - * @param bArray byte数组 - * @return hex字符串 - */ - public static String bytesToHexString(byte[] bArray) { - StringBuilder sb = new StringBuilder(bArray.length); - for (int i = 0; i < bArray.length; i++) { - String hexStr = Integer.toHexString(0xFF & bArray[i]); - if (hexStr.length() < 2) { - sb.append(0); - } - sb.append(hexStr.toUpperCase()); - } - return sb.toString(); - } + /** + * byte数组转换炒年糕十六进制字符串 + * + * @param bArray byte数组 + * @return hex字符串 + */ + public static String bytesToHexString(byte[] bArray) { + StringBuilder sb = new StringBuilder(bArray.length); + for (int i = 0; i < bArray.length; i++) { + String hexStr = Integer.toHexString(0xFF & bArray[i]); + if (hexStr.length() < 2) { + sb.append(0); + } + sb.append(hexStr.toUpperCase()); + } + return sb.toString(); + } + + public static class Write10Build { + public int num; + public byte[] message; + + public Write10Build(int num, byte[] message) { + this.num = num; + this.message = message; + } + } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/protocol/NettyUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/protocol/NettyUtils.java index 18c8e921..a861852c 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/protocol/NettyUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/gateway/protocol/NettyUtils.java @@ -11,10 +11,11 @@ public class NettyUtils { /** * ByteBuf转 byte[] + * * @param buf buffer * @return byte[] */ - public static byte[] readBytesFromByteBuf(ByteBuf buf){ + public static byte[] readBytesFromByteBuf(ByteBuf buf) { return ByteBufUtil.getBytes(buf); } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/html/EscapeUtil.java b/fastbee-common/src/main/java/com/fastbee/common/utils/html/EscapeUtil.java index 134127c3..961d28a3 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/html/EscapeUtil.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/html/EscapeUtil.java @@ -4,20 +4,17 @@ import com.fastbee.common.utils.StringUtils; /** * 转义和反转义工具类 - * + * * @author ruoyi */ -public class EscapeUtil -{ +public class EscapeUtil { public static final String RE_HTML_MARK = "(<[^<]*?>)|(<[\\s]*?/[^<]*?>)|(<[^<]*?/[\\s]*?>)"; private static final char[][] TEXT = new char[64][]; - static - { - for (int i = 0; i < 64; i++) - { - TEXT[i] = new char[] { (char) i }; + static { + for (int i = 0; i < 64; i++) { + TEXT[i] = new char[]{(char) i}; } // special HTML characters @@ -30,69 +27,58 @@ public class EscapeUtil /** * 转义文本中的HTML字符为安全的字符 - * + * * @param text 被转义的文本 * @return 转义后的文本 */ - public static String escape(String text) - { + public static String escape(String text) { return encode(text); } /** * 还原被转义的HTML特殊字符 - * + * * @param content 包含转义符的HTML内容 * @return 转换后的字符串 */ - public static String unescape(String content) - { + public static String unescape(String content) { return decode(content); } /** * 清除所有HTML标签,但是不删除标签内的内容 - * + * * @param content 文本 * @return 清除标签后的文本 */ - public static String clean(String content) - { + public static String clean(String content) { return new HTMLFilter().filter(content); } /** * Escape编码 - * + * * @param text 被编码的文本 * @return 编码后的字符 */ - private static String encode(String text) - { - if (StringUtils.isEmpty(text)) - { + private static String encode(String text) { + if (StringUtils.isEmpty(text)) { return StringUtils.EMPTY; } final StringBuilder tmp = new StringBuilder(text.length() * 6); char c; - for (int i = 0; i < text.length(); i++) - { + for (int i = 0; i < text.length(); i++) { c = text.charAt(i); - if (c < 256) - { + if (c < 256) { tmp.append("%"); - if (c < 16) - { + if (c < 16) { tmp.append("0"); } tmp.append(Integer.toString(c, 16)); - } - else - { + } else { tmp.append("%u"); - if (c <= 0xfff) - { + if (c <= 0xfff) { // issue#I49JU8@Gitee tmp.append("0"); } @@ -104,48 +90,36 @@ public class EscapeUtil /** * Escape解码 - * + * * @param content 被转义的内容 * @return 解码后的字符串 */ - public static String decode(String content) - { - if (StringUtils.isEmpty(content)) - { + public static String decode(String content) { + if (StringUtils.isEmpty(content)) { return content; } StringBuilder tmp = new StringBuilder(content.length()); int lastPos = 0, pos = 0; char ch; - while (lastPos < content.length()) - { + while (lastPos < content.length()) { pos = content.indexOf("%", lastPos); - if (pos == lastPos) - { - if (content.charAt(pos + 1) == 'u') - { + if (pos == lastPos) { + if (content.charAt(pos + 1) == 'u') { ch = (char) Integer.parseInt(content.substring(pos + 2, pos + 6), 16); tmp.append(ch); lastPos = pos + 6; - } - else - { + } else { ch = (char) Integer.parseInt(content.substring(pos + 1, pos + 3), 16); tmp.append(ch); lastPos = pos + 3; } - } - else - { - if (pos == -1) - { + } else { + if (pos == -1) { tmp.append(content.substring(lastPos)); lastPos = content.length(); - } - else - { - tmp.append(content.substring(lastPos, pos)); + } else { + tmp.append(content, lastPos, pos); lastPos = pos; } } @@ -153,8 +127,7 @@ public class EscapeUtil return tmp.toString(); } - public static void main(String[] args) - { + public static void main(String[] args) { String html = ""; String escape = EscapeUtil.escape(html); // String html = "ipt>alert(\"XSS\")ipt>"; diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/html/HTMLFilter.java b/fastbee-common/src/main/java/com/fastbee/common/utils/html/HTMLFilter.java index 9ddce986..b943b834 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/html/HTMLFilter.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/html/HTMLFilter.java @@ -11,8 +11,7 @@ import java.util.regex.Pattern; * * @author ruoyi */ -public final class HTMLFilter -{ +public final class HTMLFilter { /** * regex flag union representing /si modifiers in php **/ @@ -96,8 +95,7 @@ public final class HTMLFilter /** * Default constructor. */ - public HTMLFilter() - { + public HTMLFilter() { vAllowed = new HashMap<>(); final ArrayList a_atts = new ArrayList<>(); @@ -118,13 +116,13 @@ public final class HTMLFilter vAllowed.put("i", no_atts); vAllowed.put("em", no_atts); - vSelfClosingTags = new String[] { "img" }; - vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" }; - vDisallowed = new String[] {}; - vAllowedProtocols = new String[] { "http", "mailto", "https" }; // no ftp. - vProtocolAtts = new String[] { "src", "href" }; - vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" }; - vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" }; + vSelfClosingTags = new String[]{"img"}; + vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"}; + vDisallowed = new String[]{}; + vAllowedProtocols = new String[]{"http", "mailto", "https"}; // no ftp. + vProtocolAtts = new String[]{"src", "href"}; + vRemoveBlanks = new String[]{"a", "b", "strong", "i", "em"}; + vAllowedEntities = new String[]{"amp", "gt", "lt", "quot"}; stripComment = true; encodeQuotes = true; alwaysMakeTags = false; @@ -136,8 +134,7 @@ public final class HTMLFilter * @param conf map containing configuration. keys match field names. */ @SuppressWarnings("unchecked") - public HTMLFilter(final Map conf) - { + public HTMLFilter(final Map conf) { assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; @@ -161,20 +158,13 @@ public final class HTMLFilter alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true; } - private void reset() - { - vTagCounts.clear(); - } - // --------------------------------------------------------------- // my versions of some PHP library functions - public static String chr(final int decimal) - { + public static String chr(final int decimal) { return String.valueOf((char) decimal); } - public static String htmlSpecialChars(final String s) - { + public static String htmlSpecialChars(final String s) { String result = s; result = regexReplace(P_AMP, "&", result); result = regexReplace(P_QUOTE, """, result); @@ -183,16 +173,33 @@ public final class HTMLFilter return result; } + private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) { + Matcher m = regex_pattern.matcher(s); + return m.replaceAll(replacement); + } + // --------------------------------------------------------------- + private static boolean inArray(final String s, final String[] array) { + for (String item : array) { + if (item != null && item.equals(s)) { + return true; + } + } + return false; + } + + private void reset() { + vTagCounts.clear(); + } + /** * given a user submitted input String, filter out any invalid or restricted html. * * @param input text (i.e. submitted by a user) than may contain html * @return "clean" version of input, with only valid, whitelisted html elements allowed */ - public String filter(final String input) - { + public String filter(final String input) { reset(); String s = input; @@ -209,22 +216,18 @@ public final class HTMLFilter return s; } - public boolean isAlwaysMakeTags() - { + public boolean isAlwaysMakeTags() { return alwaysMakeTags; } - public boolean isStripComments() - { + public boolean isStripComments() { return stripComment; } - private String escapeComments(final String s) - { + private String escapeComments(final String s) { final Matcher m = P_COMMENTS.matcher(s); final StringBuffer buf = new StringBuffer(); - if (m.find()) - { + if (m.find()) { final String match = m.group(1); // (.*?) m.appendReplacement(buf, Matcher.quoteReplacement("")); } @@ -233,10 +236,8 @@ public final class HTMLFilter return buf.toString(); } - private String balanceHTML(String s) - { - if (alwaysMakeTags) - { + private String balanceHTML(String s) { + if (alwaysMakeTags) { // // try and form html // @@ -245,9 +246,7 @@ public final class HTMLFilter s = regexReplace(P_BODY_TO_END, "<$1>", s); s = regexReplace(P_XML_CONTENT, "$1<$2", s); - } - else - { + } else { // // escape stray brackets // @@ -265,13 +264,11 @@ public final class HTMLFilter return s; } - private String checkTags(String s) - { + private String checkTags(String s) { Matcher m = P_TAGS.matcher(s); final StringBuffer buf = new StringBuffer(); - while (m.find()) - { + while (m.find()) { String replaceStr = m.group(1); replaceStr = processTag(replaceStr); m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); @@ -281,10 +278,8 @@ public final class HTMLFilter // these get tallied in processTag // (remember to reset before subsequent calls to filter method) final StringBuilder sBuilder = new StringBuilder(buf.toString()); - for (String key : vTagCounts.keySet()) - { - for (int ii = 0; ii < vTagCounts.get(key); ii++) - { + for (String key : vTagCounts.keySet()) { + for (int ii = 0; ii < vTagCounts.get(key); ii++) { sBuilder.append(""); } } @@ -293,18 +288,14 @@ public final class HTMLFilter return s; } - private String processRemoveBlanks(final String s) - { + private String processRemoveBlanks(final String s) { String result = s; - for (String tag : vRemoveBlanks) - { - if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) - { + for (String tag : vRemoveBlanks) { + if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) { P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?>")); } result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); - if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) - { + if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) { P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); } result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); @@ -313,25 +304,14 @@ public final class HTMLFilter return result; } - private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) - { - Matcher m = regex_pattern.matcher(s); - return m.replaceAll(replacement); - } - - private String processTag(final String s) - { + private String processTag(final String s) { // ending tags Matcher m = P_END_TAG.matcher(s); - if (m.find()) - { + if (m.find()) { final String name = m.group(1).toLowerCase(); - if (allowed(name)) - { - if (!inArray(name, vSelfClosingTags)) - { - if (vTagCounts.containsKey(name)) - { + if (allowed(name)) { + if (!inArray(name, vSelfClosingTags)) { + if (vTagCounts.containsKey(name)) { vTagCounts.put(name, vTagCounts.get(name) - 1); return ""; } @@ -341,35 +321,30 @@ public final class HTMLFilter // starting tags m = P_START_TAG.matcher(s); - if (m.find()) - { + if (m.find()) { final String name = m.group(1).toLowerCase(); final String body = m.group(2); String ending = m.group(3); // debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" ); - if (allowed(name)) - { + if (allowed(name)) { final StringBuilder params = new StringBuilder(); final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); final List paramNames = new ArrayList<>(); final List paramValues = new ArrayList<>(); - while (m2.find()) - { + while (m2.find()) { paramNames.add(m2.group(1)); // ([a-z0-9]+) paramValues.add(m2.group(3)); // (.*?) } - while (m3.find()) - { + while (m3.find()) { paramNames.add(m3.group(1)); // ([a-z0-9]+) paramValues.add(m3.group(3)); // ([^\"\\s']+) } String paramName, paramValue; - for (int ii = 0; ii < paramNames.size(); ii++) - { + for (int ii = 0; ii < paramNames.size(); ii++) { paramName = paramNames.get(ii).toLowerCase(); paramValue = paramValues.get(ii); @@ -377,72 +352,55 @@ public final class HTMLFilter // debug( "paramValue='" + paramValue + "'" ); // debug( "allowed? " + vAllowed.get( name ).contains( paramName ) ); - if (allowedAttribute(name, paramName)) - { - if (inArray(paramName, vProtocolAtts)) - { + if (allowedAttribute(name, paramName)) { + if (inArray(paramName, vProtocolAtts)) { paramValue = processParamProtocol(paramValue); } params.append(' ').append(paramName).append("=\\\"").append(paramValue).append("\\\""); } } - if (inArray(name, vSelfClosingTags)) - { + if (inArray(name, vSelfClosingTags)) { ending = " /"; } - if (inArray(name, vNeedClosingTags)) - { + if (inArray(name, vNeedClosingTags)) { ending = ""; } - if (ending == null || ending.length() < 1) - { - if (vTagCounts.containsKey(name)) - { + if (ending == null || ending.length() < 1) { + if (vTagCounts.containsKey(name)) { vTagCounts.put(name, vTagCounts.get(name) + 1); - } - else - { + } else { vTagCounts.put(name, 1); } - } - else - { + } else { ending = " /"; } return "<" + name + params + ending + ">"; - } - else - { + } else { return ""; } } // comments m = P_COMMENT.matcher(s); - if (!stripComment && m.find()) - { + if (!stripComment && m.find()) { return "<" + m.group() + ">"; } return ""; } - private String processParamProtocol(String s) - { + private String processParamProtocol(String s) { s = decodeEntities(s); final Matcher m = P_PROTOCOL.matcher(s); - if (m.find()) - { + if (m.find()) { final String protocol = m.group(1); - if (!inArray(protocol, vAllowedProtocols)) - { + if (!inArray(protocol, vAllowedProtocols)) { // bad protocol, turn into local anchor link instead s = "#" + s.substring(protocol.length() + 1); - if (s.startsWith("#//")) - { + if (s.startsWith("#//")) { s = "#" + s.substring(3); } } @@ -451,13 +409,11 @@ public final class HTMLFilter return s; } - private String decodeEntities(String s) - { + private String decodeEntities(String s) { StringBuffer buf = new StringBuffer(); Matcher m = P_ENTITY.matcher(s); - while (m.find()) - { + while (m.find()) { final String match = m.group(1); final int decimal = Integer.decode(match).intValue(); m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); @@ -467,8 +423,7 @@ public final class HTMLFilter buf = new StringBuffer(); m = P_ENTITY_UNICODE.matcher(s); - while (m.find()) - { + while (m.find()) { final String match = m.group(1); final int decimal = Integer.valueOf(match, 16).intValue(); m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); @@ -478,8 +433,7 @@ public final class HTMLFilter buf = new StringBuffer(); m = P_ENCODE.matcher(s); - while (m.find()) - { + while (m.find()) { final String match = m.group(1); final int decimal = Integer.valueOf(match, 16).intValue(); m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); @@ -491,14 +445,12 @@ public final class HTMLFilter return s; } - private String validateEntities(final String s) - { + private String validateEntities(final String s) { StringBuffer buf = new StringBuffer(); // validate entities throughout the string Matcher m = P_VALID_ENTITIES.matcher(s); - while (m.find()) - { + while (m.find()) { final String one = m.group(1); // ([^&;]*) final String two = m.group(2); // (?=(;|&|$)) m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); @@ -508,14 +460,11 @@ public final class HTMLFilter return encodeQuotes(buf.toString()); } - private String encodeQuotes(final String s) - { - if (encodeQuotes) - { + private String encodeQuotes(final String s) { + if (encodeQuotes) { StringBuffer buf = new StringBuffer(); Matcher m = P_VALID_QUOTES.matcher(s); - while (m.find()) - { + while (m.find()) { final String one = m.group(1); // (>|^) final String two = m.group(2); // ([^<]+?) final String three = m.group(3); // (<|$) @@ -524,43 +473,25 @@ public final class HTMLFilter } m.appendTail(buf); return buf.toString(); - } - else - { + } else { return s; } } - private String checkEntity(final String preamble, final String term) - { + private String checkEntity(final String preamble, final String term) { return ";".equals(term) && isValidEntity(preamble) ? '&' + preamble : "&" + preamble; } - private boolean isValidEntity(final String entity) - { + private boolean isValidEntity(final String entity) { return inArray(entity, vAllowedEntities); } - private static boolean inArray(final String s, final String[] array) - { - for (String item : array) - { - if (item != null && item.equals(s)) - { - return true; - } - } - return false; - } - - private boolean allowed(final String name) - { + private boolean allowed(final String name) { return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed); } - private boolean allowedAttribute(final String name, final String paramName) - { + private boolean allowedAttribute(final String name, final String paramName) { return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName)); } } \ No newline at end of file diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/http/HttpHelper.java b/fastbee-common/src/main/java/com/fastbee/common/utils/http/HttpHelper.java index 3d5f1708..b6189e95 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/http/HttpHelper.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/http/HttpHelper.java @@ -13,40 +13,28 @@ import java.nio.charset.StandardCharsets; /** * 通用http工具封装 - * + * * @author ruoyi */ -public class HttpHelper -{ +public class HttpHelper { private static final Logger LOGGER = LoggerFactory.getLogger(HttpHelper.class); - public static String getBodyString(ServletRequest request) - { + public static String getBodyString(ServletRequest request) { StringBuilder sb = new StringBuilder(); BufferedReader reader = null; - try (InputStream inputStream = request.getInputStream()) - { + try (InputStream inputStream = request.getInputStream()) { reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); String line = ""; - while ((line = reader.readLine()) != null) - { + while ((line = reader.readLine()) != null) { sb.append(line); } - } - catch (IOException e) - { + } catch (IOException e) { LOGGER.warn("getBodyString出现问题!"); - } - finally - { - if (reader != null) - { - try - { + } finally { + if (reader != null) { + try { reader.close(); - } - catch (IOException e) - { + } catch (IOException e) { LOGGER.error(ExceptionUtils.getMessage(e)); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/http/HttpUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/http/HttpUtils.java index 5a0c219d..087596d0 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/http/HttpUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/http/HttpUtils.java @@ -19,8 +19,7 @@ import java.security.cert.X509Certificate; * * @author ruoyi */ -public class HttpUtils -{ +public class HttpUtils { private static final Logger log = LoggerFactory.getLogger(HttpUtils.class); /** @@ -29,37 +28,33 @@ public class HttpUtils * @param url 发送请求的 URL * @return 所代表远程资源的响应结果 */ - public static String sendGet(String url) - { + public static String sendGet(String url) { return sendGet(url, StringUtils.EMPTY); } /** * 向指定 URL 发送GET方法的请求 * - * @param url 发送请求的 URL + * @param url 发送请求的 URL * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 * @return 所代表远程资源的响应结果 */ - public static String sendGet(String url, String param) - { + public static String sendGet(String url, String param) { return sendGet(url, param, Constants.UTF8); } /** * 向指定 URL 发送GET方法的请求 * - * @param url 发送请求的 URL - * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @param url 发送请求的 URL + * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 * @param contentType 编码类型 * @return 所代表远程资源的响应结果 */ - public static String sendGet(String url, String param, String contentType) - { + public static String sendGet(String url, String param, String contentType) { StringBuilder result = new StringBuilder(); BufferedReader in = null; - try - { + try { String urlNameString = StringUtils.isNotBlank(param) ? url + "?" + param : url; log.info("sendGet - {}", urlNameString); URL realUrl = new URL(urlNameString); @@ -72,39 +67,24 @@ public class HttpUtils connection.connect(); in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType)); String line; - while ((line = in.readLine()) != null) - { + while ((line = in.readLine()) != null) { result.append(line); } log.info("recv - {}", result); - } - catch (ConnectException e) - { + } catch (ConnectException e) { log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e); - } - catch (SocketTimeoutException e) - { + } catch (SocketTimeoutException e) { log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e); - } - catch (IOException e) - { + } catch (IOException e) { log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e); - } - catch (Exception e) - { + } catch (Exception e) { log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e); - } - finally - { - try - { - if (in != null) - { + } finally { + try { + if (in != null) { in.close(); } - } - catch (Exception ex) - { + } catch (Exception ex) { log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); } } @@ -114,17 +94,15 @@ public class HttpUtils /** * 向指定 URL 发送POST方法的请求 * - * @param url 发送请求的 URL + * @param url 发送请求的 URL * @param param 请求参数,请求参数应该是 JSON String格式 的形式。 * @return 所代表远程资源的响应结果 */ - public static String sendPost(String url, String param) - { + public static String sendPost(String url, String param) { PrintWriter out = null; BufferedReader in = null; StringBuilder result = new StringBuilder(); - try - { + try { log.info("sendPost - {}", url); URL realUrl = new URL(url); URLConnection conn = realUrl.openConnection(); @@ -140,58 +118,40 @@ public class HttpUtils out.flush(); in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8)); String line; - while ((line = in.readLine()) != null) - { + while ((line = in.readLine()) != null) { result.append(line); } log.info("recv - {}", result); - } - catch (ConnectException e) - { + } catch (ConnectException e) { log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e); - } - catch (SocketTimeoutException e) - { + } catch (SocketTimeoutException e) { log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e); - } - catch (IOException e) - { + } catch (IOException e) { log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e); - } - catch (Exception e) - { + } catch (Exception e) { log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e); - } - finally - { - try - { - if (out != null) - { + } finally { + try { + if (out != null) { out.close(); } - if (in != null) - { + if (in != null) { in.close(); } - } - catch (IOException ex) - { + } catch (IOException ex) { log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); } } return result.toString(); } - public static String sendSSLPost(String url, String param) - { + public static String sendSSLPost(String url, String param) { StringBuilder result = new StringBuilder(); String urlNameString = url + "?" + param; - try - { + try { log.info("sendSSLPost - {}", urlNameString); SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom()); + sc.init(null, new TrustManager[]{new TrustAnyTrustManager()}, new java.security.SecureRandom()); URL console = new URL(urlNameString); HttpsURLConnection conn = (HttpsURLConnection) console.openConnection(); conn.setRequestProperty("accept", "*/*"); @@ -208,31 +168,21 @@ public class HttpUtils InputStream is = conn.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String ret = ""; - while ((ret = br.readLine()) != null) - { - if (ret != null && !"".equals(ret.trim())) - { + while ((ret = br.readLine()) != null) { + if (ret != null && !"".equals(ret.trim())) { result.append(new String(ret.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8)); } } log.info("recv - {}", result); conn.disconnect(); br.close(); - } - catch (ConnectException e) - { + } catch (ConnectException e) { log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e); - } - catch (SocketTimeoutException e) - { + } catch (SocketTimeoutException e) { log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e); - } - catch (IOException e) - { + } catch (IOException e) { log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e); - } - catch (Exception e) - { + } catch (Exception e) { log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e); } return result.toString(); @@ -242,8 +192,7 @@ public class HttpUtils PrintWriter out = null; BufferedReader in = null; StringBuilder result = new StringBuilder(); - try - { + try { log.info("sendPost - {}", url); URL realUrl = new URL(url); URLConnection conn = realUrl.openConnection(); @@ -259,73 +208,51 @@ public class HttpUtils out.flush(); in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8)); String line; - while ((line = in.readLine()) != null) - { + while ((line = in.readLine()) != null) { result.append(line); } log.info("recv - {}", result); - } - catch (ConnectException e) - { + } catch (ConnectException e) { log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + json, e); - } - catch (SocketTimeoutException e) - { + } catch (SocketTimeoutException e) { log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + json, e); - } - catch (IOException e) - { + } catch (IOException e) { log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + json, e); - } - catch (Exception e) - { + } catch (Exception e) { log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + json, e); - } - finally - { - try - { - if (out != null) - { + } finally { + try { + if (out != null) { out.close(); } - if (in != null) - { + if (in != null) { in.close(); } - } - catch (IOException ex) - { + } catch (IOException ex) { log.error("调用in.close Exception, url=" + url + ",param=" + json, ex); } } return result.toString(); } - private static class TrustAnyTrustManager implements X509TrustManager - { + private static class TrustAnyTrustManager implements X509TrustManager { @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) - { + public void checkClientTrusted(X509Certificate[] chain, String authType) { } @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) - { + public void checkServerTrusted(X509Certificate[] chain, String authType) { } @Override - public X509Certificate[] getAcceptedIssuers() - { - return new X509Certificate[] {}; + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[]{}; } } - private static class TrustAnyHostnameVerifier implements HostnameVerifier - { + private static class TrustAnyHostnameVerifier implements HostnameVerifier { @Override - public boolean verify(String hostname, SSLSession session) - { + public boolean verify(String hostname, SSLSession session) { return true; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/ip/AddressUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/ip/AddressUtils.java index 90c2230e..777cf672 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/ip/AddressUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/ip/AddressUtils.java @@ -11,33 +11,25 @@ import org.slf4j.LoggerFactory; /** * 获取地址类 - * + * * @author ruoyi */ -public class AddressUtils -{ - private static final Logger log = LoggerFactory.getLogger(AddressUtils.class); - +public class AddressUtils { // IP地址查询 public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp"; - // 未知地址 public static final String UNKNOWN = "XX XX"; + private static final Logger log = LoggerFactory.getLogger(AddressUtils.class); - public static String getRealAddressByIP(String ip) - { + public static String getRealAddressByIP(String ip) { // 内网不查询 - if (IpUtils.internalIp(ip)) - { + if (IpUtils.internalIp(ip)) { return "内网IP"; } - if (RuoYiConfig.isAddressEnabled()) - { - try - { + if (RuoYiConfig.isAddressEnabled()) { + try { String rspStr = HttpUtils.sendGet(IP_URL, "ip=" + ip + "&json=true", Constants.GBK); - if (StringUtils.isEmpty(rspStr)) - { + if (StringUtils.isEmpty(rspStr)) { log.error("获取地理位置异常 {}", ip); return UNKNOWN; } @@ -45,9 +37,7 @@ public class AddressUtils String region = obj.getString("pro"); String city = obj.getString("city"); return String.format("%s %s", region, city); - } - catch (Exception e) - { + } catch (Exception e) { log.error("获取地理位置异常 {}", ip); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/ip/IpUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/ip/IpUtils.java index ed81e99a..c7cf4d40 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/ip/IpUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/ip/IpUtils.java @@ -202,7 +202,7 @@ public class IpUtils { if (ip != null && ip.indexOf(",") > 0) { final String[] ips = ip.trim().split(","); for (String subIp : ips) { - if (false == isUnknown(subIp)) { + if (!isUnknown(subIp)) { ip = subIp; break; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/json/JsonUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/json/JsonUtils.java index b5fd0cdb..f1ce8676 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/json/JsonUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/json/JsonUtils.java @@ -90,7 +90,7 @@ public class JsonUtils { * 使用 {@link #parseObject(String, Class)} 时,在@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS) 的场景下, * 如果 text 没有 class 属性,则会报错。此时,使用这个方法,可以解决。 * - * @param text 字符串 + * @param text 字符串 * @param clazz 类型 * @return 对象 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/modbus/BitUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/modbus/BitUtils.java index b4df4d56..ca741f60 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/modbus/BitUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/modbus/BitUtils.java @@ -1,7 +1,6 @@ package com.fastbee.common.utils.modbus; /** - * * @description 位运算工具 * 用途:将二进制数中的每位数字1或0代表着某种开关标记,1为是,0为否,则一个数字可以代表N位的开关标记值,可有效减少过多的变量定义 或 过多的表字段 */ @@ -29,10 +28,10 @@ public class BitUtils { public static long updateBitValue(long num, int bit, boolean flagValue) { if (flagValue) { //将某位由0改为1 - return num | (1 << bit); + return num | (1L << bit); } else { //将某位由1改为0 - return num ^ (getBitFlag(num, bit) << bit); + return num ^ ((long) getBitFlag(num, bit) << bit); } } @@ -48,24 +47,26 @@ public class BitUtils { /** * 判断10进制数,某位是0还是1 - * @param num + * + * @param num * @param i * @return */ public static int deter(int num, int i) { // 先将数字右移指定第i位,然后再用&与1运算 i += 1; - return num >> (i-1) & 1; + return num >> (i - 1) & 1; } /** * 判断hex数据,某位的值 + * * @param hex * @param i * @return */ - public static int deterHex(String hex,int i){ - return deter(Integer.parseInt(hex,16),i); + public static int deterHex(String hex, int i) { + return deter(Integer.parseInt(hex, 16), i); } public static void main(String[] args) { diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/modbus/ModbusUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/modbus/ModbusUtils.java index 4d292340..8601db95 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/modbus/ModbusUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/modbus/ModbusUtils.java @@ -13,57 +13,61 @@ public class ModbusUtils { * isReadOnly: 0-读写 1-只读 * type: 1-IO寄存器 2-数据寄存器 * IO寄存器读写 05功能码 数据寄存器只读 06功能码 + * * @param type modbus数据类型 * @return modbus功能码 */ - public static ModbusCode getModbusCode(int type){ - if (type == 1){ - return ModbusCode.Write05; - }else { - return ModbusCode.Write06; - } + public static ModbusCode getModbusCode(int type) { + if (type == 1) { + return ModbusCode.Write05; + } else { + return ModbusCode.Write06; + } } - public static ModbusCode getReadModbusCode(int type,int isReadOnly){ - if (type == 1){ + public static ModbusCode getReadModbusCode(int type, int isReadOnly) { + if (type == 1) { return isReadOnly == 1 ? ModbusCode.Read01 : ModbusCode.Read02; - }else { + } else { return isReadOnly == 1 ? ModbusCode.Read03 : ModbusCode.Read04; } } /** * 获取modbus-hex字符串寄存器地址 + * * @param hexString hex字符串 * @return 寄存器地址-10进制 */ - public static int getModbusAddress(String hexString){ - return Integer.parseInt(hexString.substring(4, 8),16); + public static int getModbusAddress(String hexString) { + return Integer.parseInt(hexString.substring(4, 8), 16); } /** * 获取从机地址 + * * @param hexString * @return */ - public static int getModbusSlaveId(String hexString){ - return Integer.parseInt(hexString.substring(0,2),16); + public static int getModbusSlaveId(String hexString) { + return Integer.parseInt(hexString.substring(0, 2), 16); } /** * 获取功能码 + * * @param hexString * @return */ - public static int getModbusCode(String hexString){ - return Integer.parseInt(hexString.substring(2,4),16); + public static int getModbusCode(String hexString) { + return Integer.parseInt(hexString.substring(2, 4), 16); } - public static Mparams getModbusParams(String hexString){ + public static Mparams getModbusParams(String hexString) { Mparams mparams = new Mparams(); - mparams.setSlaveId(Integer.parseInt(hexString.substring(0,2),16)); - mparams.setCode(Integer.parseInt(hexString.substring(2,4),16)); - mparams.setAddress(Integer.parseInt(hexString.substring(4, 8),16)); + mparams.setSlaveId(Integer.parseInt(hexString.substring(0, 2), 16)); + mparams.setCode(Integer.parseInt(hexString.substring(2, 4), 16)); + mparams.setAddress(Integer.parseInt(hexString.substring(4, 8), 16)); return mparams; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/object/ObjectUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/object/ObjectUtils.java index 1fd4c1cc..69270bab 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/object/ObjectUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/object/ObjectUtils.java @@ -17,7 +17,7 @@ public class ObjectUtils { /** * 复制对象,并忽略 Id 编号 * - * @param object 被复制对象 + * @param object 被复制对象 * @param consumer 消费者,可以二次编辑被复制对象 * @return 复制后的对象 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/poi/ExcelHandlerAdapter.java b/fastbee-common/src/main/java/com/fastbee/common/utils/poi/ExcelHandlerAdapter.java index ca8f11d7..2d437d00 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/poi/ExcelHandlerAdapter.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/poi/ExcelHandlerAdapter.java @@ -2,17 +2,15 @@ package com.fastbee.common.utils.poi; /** * Excel数据格式处理适配器 - * + * * @author ruoyi */ -public interface ExcelHandlerAdapter -{ +public interface ExcelHandlerAdapter { /** * 格式化 - * - * @param value 单元格数据值 - * @param args excel注解args参数组 * + * @param value 单元格数据值 + * @param args excel注解args参数组 * @return 处理后的值 */ Object format(Object value, String[] args); diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/poi/ExcelUtil.java b/fastbee-common/src/main/java/com/fastbee/common/utils/poi/ExcelUtil.java index 40c1f23d..020f1b69 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/poi/ExcelUtil.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/poi/ExcelUtil.java @@ -48,129 +48,250 @@ import java.util.stream.Collectors; * * @author ruoyi */ -public class ExcelUtil -{ - private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class); - +public class ExcelUtil { public static final String FORMULA_REGEX_STR = "=|-|\\+|@"; - - public static final String[] FORMULA_STR = { "=", "-", "+", "@" }; - + public static final String[] FORMULA_STR = {"=", "-", "+", "@"}; /** * Excel sheet最大行数,默认65536 */ public static final int sheetSize = 65536; - - /** - * 工作表名称 - */ - private String sheetName; - - /** - * 导出类型(EXPORT:导出数据;IMPORT:导入模板) - */ - private Type type; - - /** - * 工作薄对象 - */ - private Workbook wb; - - /** - * 工作表对象 - */ - private Sheet sheet; - - /** - * 样式列表 - */ - private Map styles; - - /** - * 导入导出数据列表 - */ - private List list; - - /** - * 注解列表 - */ - private List fields; - - /** - * 当前行号 - */ - private int rownum; - - /** - * 标题 - */ - private String title; - - /** - * 最大高度 - */ - private short maxHeight; - - /** - * 合并后最后行数 - */ - private int subMergedLastRowNum = 0; - - /** - * 合并后开始行数 - */ - private int subMergedFirstRowNum = 1; - - /** - * 对象的子列表方法 - */ - private Method subMethod; - - /** - * 对象的子列表属性 - */ - private List subFields; - - /** - * 统计列表 - */ - private Map statistics = new HashMap(); - + private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class); /** * 数字格式 */ private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("######0.00"); - + /** + * 统计列表 + */ + private final Map statistics = new HashMap(); /** * 实体对象 */ public Class clazz; - + /** + * 工作表名称 + */ + private String sheetName; + /** + * 导出类型(EXPORT:导出数据;IMPORT:导入模板) + */ + private Type type; + /** + * 工作薄对象 + */ + private Workbook wb; + /** + * 工作表对象 + */ + private Sheet sheet; + /** + * 样式列表 + */ + private Map styles; + /** + * 导入导出数据列表 + */ + private List list; + /** + * 注解列表 + */ + private List fields; + /** + * 当前行号 + */ + private int rownum; + /** + * 标题 + */ + private String title; + /** + * 最大高度 + */ + private short maxHeight; + /** + * 合并后最后行数 + */ + private int subMergedLastRowNum = 0; + /** + * 合并后开始行数 + */ + private int subMergedFirstRowNum = 1; + /** + * 对象的子列表方法 + */ + private Method subMethod; + /** + * 对象的子列表属性 + */ + private List subFields; /** * 需要排除列属性 */ public String[] excludeFields; - public ExcelUtil(Class clazz) - { + public ExcelUtil(Class clazz) { this.clazz = clazz; } + /** + * 获取画布 + */ + public static Drawing getDrawingPatriarch(Sheet sheet) { + if (sheet.getDrawingPatriarch() == null) { + sheet.createDrawingPatriarch(); + } + return sheet.getDrawingPatriarch(); + } + + /** + * 解析导出值 0=男,1=女,2=未知 + * + * @param propertyValue 参数值 + * @param converterExp 翻译注解 + * @param separator 分隔符 + * @return 解析后值 + */ + public static String convertByExp(String propertyValue, String converterExp, String separator) { + StringBuilder propertyString = new StringBuilder(); + String[] convertSource = converterExp.split(","); + for (String item : convertSource) { + String[] itemArray = item.split("="); + if (StringUtils.containsAny(propertyValue, separator)) { + for (String value : propertyValue.split(separator)) { + if (itemArray[0].equals(value)) { + propertyString.append(itemArray[1] + separator); + break; + } + } + } else { + if (itemArray[0].equals(propertyValue)) { + return itemArray[1]; + } + } + } + return StringUtils.stripEnd(propertyString.toString(), separator); + } + + /** + * 反向解析值 男=0,女=1,未知=2 + * + * @param propertyValue 参数值 + * @param converterExp 翻译注解 + * @param separator 分隔符 + * @return 解析后值 + */ + public static String reverseByExp(String propertyValue, String converterExp, String separator) { + StringBuilder propertyString = new StringBuilder(); + String[] convertSource = converterExp.split(","); + for (String item : convertSource) { + String[] itemArray = item.split("="); + if (StringUtils.containsAny(propertyValue, separator)) { + for (String value : propertyValue.split(separator)) { + if (itemArray[1].equals(value)) { + propertyString.append(itemArray[0] + separator); + break; + } + } + } else { + if (itemArray[1].equals(propertyValue)) { + return itemArray[0]; + } + } + } + return StringUtils.stripEnd(propertyString.toString(), separator); + } + + /** + * 解析字典值 + * + * @param dictValue 字典值 + * @param dictType 字典类型 + * @param separator 分隔符 + * @param language 语言 + * @return 字典标签 + */ + public static String convertDictByExp(String dictValue, String dictType, String separator, String language) { + return DictUtils.getDictLabel(dictType, dictValue, separator, language); + } + + /** + * 反向解析值字典值 + * + * @param dictLabel 字典标签 + * @param dictType 字典类型 + * @param separator 分隔符 + * @return 字典值 + */ + public static String reverseDictByExp(String dictLabel, String dictType, String separator) { + return DictUtils.getDictValue(dictType, dictLabel, separator); + } + + /** + * 获取Excel2003图片 + * + * @param sheet 当前sheet对象 + * @param workbook 工作簿对象 + * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData + */ + public static Map getSheetPictures03(HSSFSheet sheet, HSSFWorkbook workbook) { + Map sheetIndexPicMap = new HashMap(); + List pictures = workbook.getAllPictures(); + if (!pictures.isEmpty()) { + for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) { + HSSFClientAnchor anchor = (HSSFClientAnchor) shape.getAnchor(); + if (shape instanceof HSSFPicture) { + HSSFPicture pic = (HSSFPicture) shape; + int pictureIndex = pic.getPictureIndex() - 1; + HSSFPictureData picData = pictures.get(pictureIndex); + String picIndex = anchor.getRow1() + "_" + String.valueOf(anchor.getCol1()); + sheetIndexPicMap.put(picIndex, picData); + } + } + return sheetIndexPicMap; + } else { + return sheetIndexPicMap; + } + } + + /** + * 获取Excel2007图片 + * + * @param sheet 当前sheet对象 + * @param workbook 工作簿对象 + * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData + */ + public static Map getSheetPictures07(XSSFSheet sheet, XSSFWorkbook workbook) { + Map sheetIndexPicMap = new HashMap(); + for (POIXMLDocumentPart dr : sheet.getRelations()) { + if (dr instanceof XSSFDrawing) { + XSSFDrawing drawing = (XSSFDrawing) dr; + List shapes = drawing.getShapes(); + for (XSSFShape shape : shapes) { + if (shape instanceof XSSFPicture) { + XSSFPicture pic = (XSSFPicture) shape; + XSSFClientAnchor anchor = pic.getPreferredSize(); + CTMarker ctMarker = anchor.getFrom(); + String picIndex = ctMarker.getRow() + "_" + ctMarker.getCol(); + sheetIndexPicMap.put(picIndex, pic.getPictureData()); + } + } + } + } + return sheetIndexPicMap; + } + /** * 隐藏Excel中列属性 * * @param fields 列属性名 示例[单个"name"/多个"id","name"] * @throws Exception */ - public void hideColumn(String... fields) - { + public void hideColumn(String... fields) { this.excludeFields = fields; } - public void init(List list, String sheetName, String title, Type type) - { - if (list == null) - { + public void init(List list, String sheetName, String title, Type type) { + if (list == null) { list = new ArrayList(); } this.list = list; @@ -186,15 +307,12 @@ public class ExcelUtil /** * 创建excel第一行标题 */ - public void createTitle() - { - if (StringUtils.isNotEmpty(title)) - { + public void createTitle() { + if (StringUtils.isNotEmpty(title)) { subMergedFirstRowNum++; subMergedLastRowNum++; int titleLastCol = this.fields.size() - 1; - if (isSubList()) - { + if (isSubList()) { titleLastCol = titleLastCol + subFields.size() - 1; } Row titleRow = sheet.createRow(rownum == 0 ? rownum++ : 0); @@ -209,16 +327,13 @@ public class ExcelUtil /** * 创建对象的子列表名称 */ - public void createSubHead() - { - if (isSubList()) - { + public void createSubHead() { + if (isSubList()) { subMergedFirstRowNum++; subMergedLastRowNum++; Row subRow = sheet.createRow(rownum); int excelNum = 0; - for (Object[] objects : fields) - { + for (Object[] objects : fields) { Excel attr = (Excel) objects[1]; Cell headCell1 = subRow.createCell(excelNum); headCell1.setCellValue(attr.name()); @@ -227,8 +342,7 @@ public class ExcelUtil } int headFirstRow = excelNum - 1; int headLastRow = headFirstRow + subFields.size() - 1; - if (headLastRow > headFirstRow) - { + if (headLastRow > headFirstRow) { sheet.addMergedRegion(new CellRangeAddress(rownum, rownum, headFirstRow, headLastRow)); } rownum++; @@ -241,20 +355,18 @@ public class ExcelUtil * @param is 输入流 * @return 转换后集合 */ - public List importExcel(InputStream is) throws Exception - { + public List importExcel(InputStream is) throws Exception { return importExcel(is, 0); } /** * 对excel表单默认第一个索引名转换成list * - * @param is 输入流 + * @param is 输入流 * @param titleNum 标题占用行数 * @return 转换后集合 */ - public List importExcel(InputStream is, int titleNum) throws Exception - { + public List importExcel(InputStream is, int titleNum) throws Exception { return importExcel(StringUtils.EMPTY, is, titleNum); } @@ -262,77 +374,62 @@ public class ExcelUtil * 对excel表单指定表格索引名转换成list * * @param sheetName 表格索引名 - * @param titleNum 标题占用行数 - * @param is 输入流 + * @param titleNum 标题占用行数 + * @param is 输入流 * @return 转换后集合 */ - public List importExcel(String sheetName, InputStream is, int titleNum) throws Exception - { + public List importExcel(String sheetName, InputStream is, int titleNum) throws Exception { this.type = Type.IMPORT; this.wb = WorkbookFactory.create(is); List list = new ArrayList(); // 如果指定sheet名,则取指定sheet中的内容 否则默认指向第1个sheet Sheet sheet = StringUtils.isNotEmpty(sheetName) ? wb.getSheet(sheetName) : wb.getSheetAt(0); - if (sheet == null) - { + if (sheet == null) { throw new IOException("文件sheet不存在"); } boolean isXSSFWorkbook = !(wb instanceof HSSFWorkbook); Map pictures; - if (isXSSFWorkbook) - { + if (isXSSFWorkbook) { pictures = getSheetPictures07((XSSFSheet) sheet, (XSSFWorkbook) wb); - } - else - { + } else { pictures = getSheetPictures03((HSSFSheet) sheet, (HSSFWorkbook) wb); } // 获取最后一个非空行的行下标,比如总行数为n,则返回的为n-1 int rows = sheet.getLastRowNum(); - if (rows > 0) - { + if (rows > 0) { // 定义一个map用于存放excel列的序号和field. Map cellMap = new HashMap(); // 获取表头 Row heard = sheet.getRow(titleNum); - for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) - { + for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) { Cell cell = heard.getCell(i); - if (StringUtils.isNotNull(cell)) - { + if (StringUtils.isNotNull(cell)) { String value = this.getCellValue(heard, i).toString(); cellMap.put(value, i); - } - else - { + } else { cellMap.put(null, i); } } // 有数据时才处理 得到类的所有field. List fields = this.getFields(); Map fieldsMap = new HashMap(); - for (Object[] objects : fields) - { + for (Object[] objects : fields) { Excel attr = (Excel) objects[1]; Integer column = cellMap.get(attr.name()); - if (column != null) - { + if (column != null) { fieldsMap.put(column, objects); } } - for (int i = titleNum + 1; i <= rows; i++) - { + for (int i = titleNum + 1; i <= rows; i++) { // 从第2行开始取数据,默认第一行是表头. Row row = sheet.getRow(i); // 判断当前行是否是空行 - if (isRowEmpty(row)) - { + if (isRowEmpty(row)) { continue; } T entity = null; - for (Map.Entry entry : fieldsMap.entrySet()) - { + for (Map.Entry entry : fieldsMap.entrySet()) { Object val = this.getCellValue(row, entry.getKey()); // 如果不存在实例则新建. @@ -342,89 +439,52 @@ public class ExcelUtil Excel attr = (Excel) entry.getValue()[1]; // 取得类型,并根据对象类型设置值. Class fieldType = field.getType(); - if (String.class == fieldType) - { + if (String.class == fieldType) { String s = Convert.toStr(val); - if (StringUtils.endsWith(s, ".0")) - { + if (StringUtils.endsWith(s, ".0")) { val = StringUtils.substringBefore(s, ".0"); - } - else - { + } else { String dateFormat = field.getAnnotation(Excel.class).dateFormat(); - if (StringUtils.isNotEmpty(dateFormat)) - { + if (StringUtils.isNotEmpty(dateFormat)) { val = parseDateToStr(dateFormat, val); - } - else - { + } else { val = Convert.toStr(val); } } - } - else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val))) - { + } else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val))) { val = Convert.toInt(val); - } - else if ((Long.TYPE == fieldType || Long.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val))) - { + } else if ((Long.TYPE == fieldType || Long.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val))) { val = Convert.toLong(val); - } - else if (Double.TYPE == fieldType || Double.class == fieldType) - { + } else if (Double.TYPE == fieldType || Double.class == fieldType) { val = Convert.toDouble(val); - } - else if (Float.TYPE == fieldType || Float.class == fieldType) - { + } else if (Float.TYPE == fieldType || Float.class == fieldType) { val = Convert.toFloat(val); - } - else if (BigDecimal.class == fieldType) - { + } else if (BigDecimal.class == fieldType) { val = Convert.toBigDecimal(val); - } - else if (Date.class == fieldType) - { - if (val instanceof String) - { + } else if (Date.class == fieldType) { + if (val instanceof String) { val = DateUtils.parseDate(val); - } - else if (val instanceof Double) - { + } else if (val instanceof Double) { val = DateUtil.getJavaDate((Double) val); } - } - else if (Boolean.TYPE == fieldType || Boolean.class == fieldType) - { + } else if (Boolean.TYPE == fieldType || Boolean.class == fieldType) { val = Convert.toBool(val, false); } - if (StringUtils.isNotNull(fieldType)) - { + if (StringUtils.isNotNull(fieldType)) { String propertyName = field.getName(); - if (StringUtils.isNotEmpty(attr.targetAttr())) - { + if (StringUtils.isNotEmpty(attr.targetAttr())) { propertyName = field.getName() + "." + attr.targetAttr(); - } - else if (StringUtils.isNotEmpty(attr.readConverterExp())) - { + } else if (StringUtils.isNotEmpty(attr.readConverterExp())) { val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator()); - } - else if (StringUtils.isNotEmpty(attr.dictType())) - { + } else if (StringUtils.isNotEmpty(attr.dictType())) { val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator()); - } - else if (!attr.handler().equals(ExcelHandlerAdapter.class)) - { + } else if (!attr.handler().equals(ExcelHandlerAdapter.class)) { val = dataFormatHandlerAdapter(val, attr); - } - else if (ColumnType.IMAGE == attr.cellType() && StringUtils.isNotEmpty(pictures)) - { + } else if (ColumnType.IMAGE == attr.cellType() && StringUtils.isNotEmpty(pictures)) { PictureData image = pictures.get(row.getRowNum() + "_" + entry.getKey()); - if (image == null) - { + if (image == null) { val = ""; - } - else - { + } else { byte[] data = image.getData(); val = FileUtils.writeImportBytes(data); } @@ -441,25 +501,23 @@ public class ExcelUtil /** * 对list数据源将其里面的数据导入到excel表单 * - * @param list 导出数据集合 + * @param list 导出数据集合 * @param sheetName 工作表的名称 * @return 结果 */ - public AjaxResult exportExcel(List list, String sheetName) - { + public AjaxResult exportExcel(List list, String sheetName) { return exportExcel(list, sheetName, StringUtils.EMPTY); } /** * 对list数据源将其里面的数据导入到excel表单 * - * @param list 导出数据集合 + * @param list 导出数据集合 * @param sheetName 工作表的名称 - * @param title 标题 + * @param title 标题 * @return 结果 */ - public AjaxResult exportExcel(List list, String sheetName, String title) - { + public AjaxResult exportExcel(List list, String sheetName, String title) { this.init(list, sheetName, title, Type.EXPORT); return exportExcel(); } @@ -467,27 +525,25 @@ public class ExcelUtil /** * 对list数据源将其里面的数据导入到excel表单 * - * @param response 返回数据 - * @param list 导出数据集合 + * @param response 返回数据 + * @param list 导出数据集合 * @param sheetName 工作表的名称 * @return 结果 */ - public void exportExcel(HttpServletResponse response, List list, String sheetName) - { + public void exportExcel(HttpServletResponse response, List list, String sheetName) { exportExcel(response, list, sheetName, StringUtils.EMPTY); } /** * 对list数据源将其里面的数据导入到excel表单 * - * @param response 返回数据 - * @param list 导出数据集合 + * @param response 返回数据 + * @param list 导出数据集合 * @param sheetName 工作表的名称 - * @param title 标题 + * @param title 标题 * @return 结果 */ - public void exportExcel(HttpServletResponse response, List list, String sheetName, String title) - { + public void exportExcel(HttpServletResponse response, List list, String sheetName, String title) { response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); this.init(list, sheetName, title, Type.EXPORT); @@ -500,8 +556,7 @@ public class ExcelUtil * @param sheetName 工作表的名称 * @return 结果 */ - public AjaxResult importTemplateExcel(String sheetName) - { + public AjaxResult importTemplateExcel(String sheetName) { return importTemplateExcel(sheetName, StringUtils.EMPTY); } @@ -509,11 +564,10 @@ public class ExcelUtil * 对list数据源将其里面的数据导入到excel表单 * * @param sheetName 工作表的名称 - * @param title 标题 + * @param title 标题 * @return 结果 */ - public AjaxResult importTemplateExcel(String sheetName, String title) - { + public AjaxResult importTemplateExcel(String sheetName, String title) { this.init(null, sheetName, title, Type.IMPORT); return exportExcel(); } @@ -524,8 +578,7 @@ public class ExcelUtil * @param sheetName 工作表的名称 * @return 结果 */ - public void importTemplateExcel(HttpServletResponse response, String sheetName) - { + public void importTemplateExcel(HttpServletResponse response, String sheetName) { importTemplateExcel(response, sheetName, StringUtils.EMPTY); } @@ -533,11 +586,10 @@ public class ExcelUtil * 对list数据源将其里面的数据导入到excel表单 * * @param sheetName 工作表的名称 - * @param title 标题 + * @param title 标题 * @return 结果 */ - public void importTemplateExcel(HttpServletResponse response, String sheetName, String title) - { + public void importTemplateExcel(HttpServletResponse response, String sheetName, String title) { response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); this.init(null, sheetName, title, Type.IMPORT); @@ -549,19 +601,13 @@ public class ExcelUtil * * @return 结果 */ - public void exportExcel(HttpServletResponse response) - { - try - { + public void exportExcel(HttpServletResponse response) { + try { writeSheet(); wb.write(response.getOutputStream()); - } - catch (Exception e) - { + } catch (Exception e) { log.error("导出Excel异常{}", e.getMessage()); - } - finally - { + } finally { IOUtils.closeQuietly(wb); } } @@ -571,24 +617,18 @@ public class ExcelUtil * * @return 结果 */ - public AjaxResult exportExcel() - { + public AjaxResult exportExcel() { OutputStream out = null; - try - { + try { writeSheet(); String filename = encodingFilename(sheetName); out = new FileOutputStream(getAbsoluteFile(filename)); wb.write(out); return AjaxResult.success(filename); - } - catch (Exception e) - { + } catch (Exception e) { log.error("导出Excel异常{}", e.getMessage()); throw new UtilException("导出Excel失败,请联系网站管理员!"); - } - finally - { + } finally { IOUtils.closeQuietly(wb); IOUtils.closeQuietly(out); } @@ -597,37 +637,29 @@ public class ExcelUtil /** * 创建写入数据到Sheet */ - public void writeSheet() - { + public void writeSheet() { // 取出一共有多少个sheet. int sheetNo = Math.max(1, (int) Math.ceil(list.size() * 1.0 / sheetSize)); - for (int index = 0; index < sheetNo; index++) - { + for (int index = 0; index < sheetNo; index++) { createSheet(sheetNo, index); // 产生一行 Row row = sheet.createRow(rownum); int column = 0; // 写入各个字段的列头名称 - for (Object[] os : fields) - { + for (Object[] os : fields) { Field field = (Field) os[0]; Excel excel = (Excel) os[1]; - if (Collection.class.isAssignableFrom(field.getType())) - { - for (Field subField : subFields) - { + if (Collection.class.isAssignableFrom(field.getType())) { + for (Field subField : subFields) { Excel subExcel = subField.getAnnotation(Excel.class); this.createHeadCell(subExcel, row, column++); } - } - else - { + } else { this.createHeadCell(excel, row, column++); } } - if (Type.EXPORT.equals(type)) - { + if (Type.EXPORT.equals(type)) { fillExcelData(index, row); addStatisticsRow(); } @@ -638,55 +670,43 @@ public class ExcelUtil * 填充excel数据 * * @param index 序号 - * @param row 单元格行 + * @param row 单元格行 */ @SuppressWarnings("unchecked") - public void fillExcelData(int index, Row row) - { + public void fillExcelData(int index, Row row) { int startNo = index * sheetSize; int endNo = Math.min(startNo + sheetSize, list.size()); int rowNo = (1 + rownum) - startNo; - for (int i = startNo; i < endNo; i++) - { + for (int i = startNo; i < endNo; i++) { rowNo = isSubList() ? (i > 1 ? rowNo + 1 : rowNo + i) : i + 1 + rownum - startNo; row = sheet.createRow(rowNo); // 得到导出对象. - T vo = (T) list.get(i); + T vo = list.get(i); Collection subList = null; - if (isSubList()) - { - if (isSubListValue(vo)) - { + if (isSubList()) { + if (isSubListValue(vo)) { subList = getListCellValue(vo); subMergedLastRowNum = subMergedLastRowNum + subList.size(); - } - else - { + } else { subMergedFirstRowNum++; subMergedLastRowNum++; } } int column = 0; - for (Object[] os : fields) - { + for (Object[] os : fields) { Field field = (Field) os[0]; Excel excel = (Excel) os[1]; - if (Collection.class.isAssignableFrom(field.getType()) && StringUtils.isNotNull(subList)) - { + if (Collection.class.isAssignableFrom(field.getType()) && StringUtils.isNotNull(subList)) { boolean subFirst = false; - for (Object obj : subList) - { - if (subFirst) - { + for (Object obj : subList) { + if (subFirst) { rowNo++; row = sheet.createRow(rowNo); } List subFields = FieldUtils.getFieldsListWithAnnotation(obj.getClass(), Excel.class); int subIndex = 0; - for (Field subField : subFields) - { - if (subField.isAnnotationPresent(Excel.class)) - { + for (Field subField : subFields) { + if (subField.isAnnotationPresent(Excel.class)) { subField.setAccessible(true); Excel attr = subField.getAnnotation(Excel.class); this.addCell(attr, row, (T) obj, subField, column + subIndex); @@ -696,9 +716,7 @@ public class ExcelUtil subFirst = true; } this.subMergedFirstRowNum = this.subMergedFirstRowNum + subList.size(); - } - else - { + } else { this.addCell(excel, row, vo, field, column++); } } @@ -711,8 +729,7 @@ public class ExcelUtil * @param wb 工作薄对象 * @return 样式列表 */ - private Map createStyles(Workbook wb) - { + private Map createStyles(Workbook wb) { // 写入各条记录,每条记录对应excel表中的一行 Map styles = new HashMap(); CellStyle style = wb.createCellStyle(); @@ -764,15 +781,12 @@ public class ExcelUtil * @param wb 工作薄对象 * @return 自定义样式列表 */ - private Map annotationHeaderStyles(Workbook wb, Map styles) - { + private Map annotationHeaderStyles(Workbook wb, Map styles) { Map headerStyles = new HashMap(); - for (Object[] os : fields) - { + for (Object[] os : fields) { Excel excel = (Excel) os[1]; String key = StringUtils.format("header_{}_{}", excel.headerColor(), excel.headerBackgroundColor()); - if (!headerStyles.containsKey(key)) - { + if (!headerStyles.containsKey(key)) { CellStyle style = wb.createCellStyle(); style.cloneStyleFrom(styles.get("data")); style.setAlignment(HorizontalAlignment.CENTER); @@ -797,15 +811,12 @@ public class ExcelUtil * @param wb 工作薄对象 * @return 自定义样式列表 */ - private Map annotationDataStyles(Workbook wb) - { + private Map annotationDataStyles(Workbook wb) { Map styles = new HashMap(); - for (Object[] os : fields) - { + for (Object[] os : fields) { Excel excel = (Excel) os[1]; String key = StringUtils.format("data_{}_{}_{}", excel.align(), excel.color(), excel.backgroundColor()); - if (!styles.containsKey(key)) - { + if (!styles.containsKey(key)) { CellStyle style = wb.createCellStyle(); style.setAlignment(excel.align()); style.setVerticalAlignment(VerticalAlignment.CENTER); @@ -833,20 +844,17 @@ public class ExcelUtil /** * 创建单元格 */ - public Cell createHeadCell(Excel attr, Row row, int column) - { + public Cell createHeadCell(Excel attr, Row row, int column) { // 创建列 Cell cell = row.createCell(column); // 写入列信息 cell.setCellValue(attr.name()); setDataValidation(attr, row, column); cell.setCellStyle(styles.get(StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor()))); - if (isSubList()) - { + if (isSubList()) { // 填充默认样式,防止合并单元格样式失效 sheet.setDefaultColumnStyle(column, styles.get(StringUtils.format("data_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor()))); - if (attr.needMerge()) - { + if (attr.needMerge()) { sheet.addMergedRegion(new CellRangeAddress(rownum - 1, rownum, column, column)); } } @@ -857,38 +865,28 @@ public class ExcelUtil * 设置单元格信息 * * @param value 单元格值 - * @param attr 注解相关 - * @param cell 单元格信息 + * @param attr 注解相关 + * @param cell 单元格信息 */ - public void setCellVo(Object value, Excel attr, Cell cell) - { - if (ColumnType.STRING == attr.cellType()) - { + public void setCellVo(Object value, Excel attr, Cell cell) { + if (ColumnType.STRING == attr.cellType()) { String cellValue = Convert.toStr(value); // 对于任何以表达式触发字符 =-+@开头的单元格,直接使用tab字符作为前缀,防止CSV注入。 - if (StringUtils.startsWithAny(cellValue, FORMULA_STR)) - { + if (StringUtils.startsWithAny(cellValue, FORMULA_STR)) { cellValue = RegExUtils.replaceFirst(cellValue, FORMULA_REGEX_STR, "\t$0"); } - if (value instanceof Collection && StringUtils.equals("[]", cellValue)) - { + if (value instanceof Collection && StringUtils.equals("[]", cellValue)) { cellValue = StringUtils.EMPTY; } cell.setCellValue(StringUtils.isNull(cellValue) ? attr.defaultValue() : cellValue + attr.suffix()); - } - else if (ColumnType.NUMERIC == attr.cellType()) - { - if (StringUtils.isNotNull(value)) - { + } else if (ColumnType.NUMERIC == attr.cellType()) { + if (StringUtils.isNotNull(value)) { cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : Convert.toInt(value)); } - } - else if (ColumnType.IMAGE == attr.cellType()) - { + } else if (ColumnType.IMAGE == attr.cellType()) { ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 1), cell.getRow().getRowNum() + 1); String imagePath = Convert.toStr(value); - if (StringUtils.isNotEmpty(imagePath)) - { + if (StringUtils.isNotEmpty(imagePath)) { byte[] data = ImageUtils.getImage(imagePath); getDrawingPatriarch(cell.getSheet()).createPicture(anchor, cell.getSheet().getWorkbook().addPicture(data, getImageType(data))); @@ -896,30 +894,14 @@ public class ExcelUtil } } - /** - * 获取画布 - */ - public static Drawing getDrawingPatriarch(Sheet sheet) - { - if (sheet.getDrawingPatriarch() == null) - { - sheet.createDrawingPatriarch(); - } - return sheet.getDrawingPatriarch(); - } - /** * 获取图片类型,设置图片插入类型 */ - public int getImageType(byte[] value) - { + public int getImageType(byte[] value) { String type = FileTypeUtils.getFileExtendName(value); - if ("JPG".equalsIgnoreCase(type)) - { + if ("JPG".equalsIgnoreCase(type)) { return Workbook.PICTURE_TYPE_JPEG; - } - else if ("PNG".equalsIgnoreCase(type)) - { + } else if ("PNG".equalsIgnoreCase(type)) { return Workbook.PICTURE_TYPE_PNG; } return Workbook.PICTURE_TYPE_JPEG; @@ -928,26 +910,18 @@ public class ExcelUtil /** * 创建表格样式 */ - public void setDataValidation(Excel attr, Row row, int column) - { - if (attr.name().indexOf("注:") >= 0) - { + public void setDataValidation(Excel attr, Row row, int column) { + if (attr.name().indexOf("注:") >= 0) { sheet.setColumnWidth(column, 6000); - } - else - { + } else { // 设置列宽 sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256)); } - if (StringUtils.isNotEmpty(attr.prompt()) || attr.combo().length > 0) - { - if (attr.combo().length > 15 || StringUtils.join(attr.combo()).length() > 255) - { + if (StringUtils.isNotEmpty(attr.prompt()) || attr.combo().length > 0) { + if (attr.combo().length > 15 || StringUtils.join(attr.combo()).length() > 255) { // 如果下拉数大于15或字符串长度大于255,则使用一个新sheet存储,避免生成的模板下拉值获取不到 setXSSFValidationWithHidden(sheet, attr.combo(), attr.prompt(), 1, 100, column, column); - } - else - { + } else { // 提示信息或只能选择不能输入的列内容. setPromptOrValidation(sheet, attr.combo(), attr.prompt(), 1, 100, column, column); } @@ -957,20 +931,16 @@ public class ExcelUtil /** * 添加单元格 */ - public Cell addCell(Excel attr, Row row, T vo, Field field, int column) - { + public Cell addCell(Excel attr, Row row, T vo, Field field, int column) { Cell cell = null; - try - { + try { // 设置行高 row.setHeight(maxHeight); // 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列. - if (attr.isExport()) - { + if (attr.isExport()) { // 创建cell cell = row.createCell(column); - if (isSubListValue(vo) && getListCellValue(vo).size() > 1 && attr.needMerge()) - { + if (isSubListValue(vo) && getListCellValue(vo).size() > 1 && attr.needMerge()) { CellRangeAddress cellAddress = new CellRangeAddress(subMergedFirstRowNum, subMergedLastRowNum, column, column); sheet.addMergedRegion(cellAddress); } @@ -982,36 +952,23 @@ public class ExcelUtil String readConverterExp = attr.readConverterExp(); String separator = attr.separator(); String dictType = attr.dictType(); - if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) - { + if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) { cell.setCellValue(parseDateToStr(dateFormat, value)); - } - else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) - { + } else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) { cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator)); - } - else if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotNull(value)) - { + } else if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotNull(value)) { cell.setCellValue(convertDictByExp(Convert.toStr(value), dictType, separator, SecurityUtils.getLanguage())); - } - else if (value instanceof BigDecimal && -1 != attr.scale()) - { + } else if (value instanceof BigDecimal && -1 != attr.scale()) { cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).doubleValue()); - } - else if (!attr.handler().equals(ExcelHandlerAdapter.class)) - { + } else if (!attr.handler().equals(ExcelHandlerAdapter.class)) { cell.setCellValue(dataFormatHandlerAdapter(value, attr)); - } - else - { + } else { // 设置列类型 setCellVo(value, attr, cell); } addStatisticsData(column, Convert.toStr(value), attr); } - } - catch (Exception e) - { + } catch (Exception e) { log.error("导出Excel失败{}", e); } return cell; @@ -1020,35 +977,30 @@ public class ExcelUtil /** * 设置 POI XSSFSheet 单元格提示或选择框 * - * @param sheet 表单 - * @param textlist 下拉框显示的内容 + * @param sheet 表单 + * @param textlist 下拉框显示的内容 * @param promptContent 提示内容 - * @param firstRow 开始行 - * @param endRow 结束行 - * @param firstCol 开始列 - * @param endCol 结束列 + * @param firstRow 开始行 + * @param endRow 结束行 + * @param firstCol 开始列 + * @param endCol 结束列 */ public void setPromptOrValidation(Sheet sheet, String[] textlist, String promptContent, int firstRow, int endRow, - int firstCol, int endCol) - { + int firstCol, int endCol) { DataValidationHelper helper = sheet.getDataValidationHelper(); DataValidationConstraint constraint = textlist.length > 0 ? helper.createExplicitListConstraint(textlist) : helper.createCustomConstraint("DD1"); CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); DataValidation dataValidation = helper.createValidation(constraint, regions); - if (StringUtils.isNotEmpty(promptContent)) - { + if (StringUtils.isNotEmpty(promptContent)) { // 如果设置了提示信息则鼠标放上去提示 dataValidation.createPromptBox("", promptContent); dataValidation.setShowPromptBox(true); } // 处理Excel兼容性问题 - if (dataValidation instanceof XSSFDataValidation) - { + if (dataValidation instanceof XSSFDataValidation) { dataValidation.setSuppressDropDownArrow(true); dataValidation.setShowErrorBox(true); - } - else - { + } else { dataValidation.setSuppressDropDownArrow(false); } sheet.addValidationData(dataValidation); @@ -1057,20 +1009,18 @@ public class ExcelUtil /** * 设置某些列的值只能输入预制的数据,显示下拉框(兼容超出一定数量的下拉框). * - * @param sheet 要设置的sheet. - * @param textlist 下拉框显示的内容 + * @param sheet 要设置的sheet. + * @param textlist 下拉框显示的内容 * @param promptContent 提示内容 - * @param firstRow 开始行 - * @param endRow 结束行 - * @param firstCol 开始列 - * @param endCol 结束列 + * @param firstRow 开始行 + * @param endRow 结束行 + * @param firstCol 开始列 + * @param endCol 结束列 */ - public void setXSSFValidationWithHidden(Sheet sheet, String[] textlist, String promptContent, int firstRow, int endRow, int firstCol, int endCol) - { + public void setXSSFValidationWithHidden(Sheet sheet, String[] textlist, String promptContent, int firstRow, int endRow, int firstCol, int endCol) { String hideSheetName = "combo_" + firstCol + "_" + endCol; Sheet hideSheet = wb.createSheet(hideSheetName); // 用于存储 下拉菜单数据 - for (int i = 0; i < textlist.length; i++) - { + for (int i = 0; i < textlist.length; i++) { hideSheet.createRow(i).createCell(0).setCellValue(textlist[i]); } // 创建名称,可被其他单元格引用 @@ -1084,20 +1034,16 @@ public class ExcelUtil CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); // 数据有效性对象 DataValidation dataValidation = helper.createValidation(constraint, regions); - if (StringUtils.isNotEmpty(promptContent)) - { + if (StringUtils.isNotEmpty(promptContent)) { // 如果设置了提示信息则鼠标放上去提示 dataValidation.createPromptBox("", promptContent); dataValidation.setShowPromptBox(true); } // 处理Excel兼容性问题 - if (dataValidation instanceof XSSFDataValidation) - { + if (dataValidation instanceof XSSFDataValidation) { dataValidation.setSuppressDropDownArrow(true); dataValidation.setShowErrorBox(true); - } - else - { + } else { dataValidation.setSuppressDropDownArrow(false); } @@ -1106,107 +1052,6 @@ public class ExcelUtil wb.setSheetHidden(wb.getSheetIndex(hideSheet), true); } - /** - * 解析导出值 0=男,1=女,2=未知 - * - * @param propertyValue 参数值 - * @param converterExp 翻译注解 - * @param separator 分隔符 - * @return 解析后值 - */ - public static String convertByExp(String propertyValue, String converterExp, String separator) - { - StringBuilder propertyString = new StringBuilder(); - String[] convertSource = converterExp.split(","); - for (String item : convertSource) - { - String[] itemArray = item.split("="); - if (StringUtils.containsAny(propertyValue, separator)) - { - for (String value : propertyValue.split(separator)) - { - if (itemArray[0].equals(value)) - { - propertyString.append(itemArray[1] + separator); - break; - } - } - } - else - { - if (itemArray[0].equals(propertyValue)) - { - return itemArray[1]; - } - } - } - return StringUtils.stripEnd(propertyString.toString(), separator); - } - - /** - * 反向解析值 男=0,女=1,未知=2 - * - * @param propertyValue 参数值 - * @param converterExp 翻译注解 - * @param separator 分隔符 - * @return 解析后值 - */ - public static String reverseByExp(String propertyValue, String converterExp, String separator) - { - StringBuilder propertyString = new StringBuilder(); - String[] convertSource = converterExp.split(","); - for (String item : convertSource) - { - String[] itemArray = item.split("="); - if (StringUtils.containsAny(propertyValue, separator)) - { - for (String value : propertyValue.split(separator)) - { - if (itemArray[1].equals(value)) - { - propertyString.append(itemArray[0] + separator); - break; - } - } - } - else - { - if (itemArray[1].equals(propertyValue)) - { - return itemArray[0]; - } - } - } - return StringUtils.stripEnd(propertyString.toString(), separator); - } - - /** - * 解析字典值 - * - * @param dictValue 字典值 - * @param dictType 字典类型 - * @param separator 分隔符 - * @param language 语言 - * @return 字典标签 - */ - public static String convertDictByExp(String dictValue, String dictType, String separator, String language) - { - return DictUtils.getDictLabel(dictType, dictValue, separator, language); - } - - /** - * 反向解析值字典值 - * - * @param dictLabel 字典标签 - * @param dictType 字典类型 - * @param separator 分隔符 - * @return 字典值 - */ - public static String reverseDictByExp(String dictLabel, String dictType, String separator) - { - return DictUtils.getDictValue(dictType, dictLabel, separator); - } - /** * 数据处理器 * @@ -1214,16 +1059,12 @@ public class ExcelUtil * @param excel 数据注解 * @return */ - public String dataFormatHandlerAdapter(Object value, Excel excel) - { - try - { + public String dataFormatHandlerAdapter(Object value, Excel excel) { + try { Object instance = excel.handler().newInstance(); - Method formatMethod = excel.handler().getMethod("format", new Class[] { Object.class, String[].class }); + Method formatMethod = excel.handler().getMethod("format", Object.class, String[].class); value = formatMethod.invoke(instance, value, excel.args()); - } - catch (Exception e) - { + } catch (Exception e) { log.error("不能格式化数据 " + excel.handler(), e.getMessage()); } return Convert.toStr(value); @@ -1232,21 +1073,15 @@ public class ExcelUtil /** * 合计统计信息 */ - private void addStatisticsData(Integer index, String text, Excel entity) - { - if (entity != null && entity.isStatistics()) - { + private void addStatisticsData(Integer index, String text, Excel entity) { + if (entity != null && entity.isStatistics()) { Double temp = 0D; - if (!statistics.containsKey(index)) - { + if (!statistics.containsKey(index)) { statistics.put(index, temp); } - try - { + try { temp = Double.valueOf(text); - } - catch (NumberFormatException e) - { + } catch (NumberFormatException e) { } statistics.put(index, statistics.get(index) + temp); } @@ -1255,18 +1090,15 @@ public class ExcelUtil /** * 创建统计行 */ - public void addStatisticsRow() - { - if (statistics.size() > 0) - { + public void addStatisticsRow() { + if (statistics.size() > 0) { Row row = sheet.createRow(sheet.getLastRowNum() + 1); Set keys = statistics.keySet(); Cell cell = row.createCell(0); cell.setCellStyle(styles.get("total")); cell.setCellValue("合计"); - for (Integer key : keys) - { + for (Integer key : keys) { cell = row.createCell(key); cell.setCellStyle(styles.get("total")); cell.setCellValue(DOUBLE_FORMAT.format(statistics.get(key))); @@ -1278,9 +1110,8 @@ public class ExcelUtil /** * 编码文件名 */ - public String encodingFilename(String filename) - { - filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx"; + public String encodingFilename(String filename) { + filename = UUID.randomUUID() + "_" + filename + ".xlsx"; return filename; } @@ -1289,12 +1120,10 @@ public class ExcelUtil * * @param filename 文件名称 */ - public String getAbsoluteFile(String filename) - { + public String getAbsoluteFile(String filename) { String downloadPath = RuoYiConfig.getDownloadPath() + filename; File desc = new File(downloadPath); - if (!desc.getParentFile().exists()) - { + if (!desc.getParentFile().exists()) { desc.getParentFile().mkdirs(); } return downloadPath; @@ -1303,28 +1132,22 @@ public class ExcelUtil /** * 获取bean中的属性值 * - * @param vo 实体对象 + * @param vo 实体对象 * @param field 字段 * @param excel 注解 * @return 最终的属性值 * @throws Exception */ - private Object getTargetValue(T vo, Field field, Excel excel) throws Exception - { + private Object getTargetValue(T vo, Field field, Excel excel) throws Exception { Object o = field.get(vo); - if (StringUtils.isNotEmpty(excel.targetAttr())) - { + if (StringUtils.isNotEmpty(excel.targetAttr())) { String target = excel.targetAttr(); - if (target.contains(".")) - { + if (target.contains(".")) { String[] targets = target.split("[.]"); - for (String name : targets) - { + for (String name : targets) { o = getValue(o, name); } - } - else - { + } else { o = getValue(o, target); } } @@ -1339,10 +1162,8 @@ public class ExcelUtil * @return value * @throws Exception */ - private Object getValue(Object o, String name) throws Exception - { - if (StringUtils.isNotNull(o) && StringUtils.isNotEmpty(name)) - { + private Object getValue(Object o, String name) throws Exception { + if (StringUtils.isNotNull(o) && StringUtils.isNotEmpty(name)) { Class clazz = o.getClass(); Field field = clazz.getDeclaredField(name); field.setAccessible(true); @@ -1354,8 +1175,7 @@ public class ExcelUtil /** * 得到所有定义字段 */ - private void createExcelField() - { + private void createExcelField() { this.fields = getFields(); this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList()); this.maxHeight = getRowHeight(); @@ -1364,27 +1184,21 @@ public class ExcelUtil /** * 获取字段注解信息 */ - public List getFields() - { + public List getFields() { List fields = new ArrayList(); List tempFields = new ArrayList<>(); tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields())); tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); - for (Field field : tempFields) - { - if (!ArrayUtils.contains(this.excludeFields, field.getName())) - { + for (Field field : tempFields) { + if (!ArrayUtils.contains(this.excludeFields, field.getName())) { // 单注解 - if (field.isAnnotationPresent(Excel.class)) - { + if (field.isAnnotationPresent(Excel.class)) { Excel attr = field.getAnnotation(Excel.class); - if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) - { + if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) { field.setAccessible(true); - fields.add(new Object[] { field, attr }); + fields.add(new Object[]{field, attr}); } - if (Collection.class.isAssignableFrom(field.getType())) - { + if (Collection.class.isAssignableFrom(field.getType())) { subMethod = getSubMethod(field.getName(), clazz); ParameterizedType pt = (ParameterizedType) field.getGenericType(); Class subClass = (Class) pt.getActualTypeArguments()[0]; @@ -1393,16 +1207,13 @@ public class ExcelUtil } // 多注解 - if (field.isAnnotationPresent(Excels.class)) - { + if (field.isAnnotationPresent(Excels.class)) { Excels attrs = field.getAnnotation(Excels.class); Excel[] excels = attrs.value(); - for (Excel attr : excels) - { - if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) - { + for (Excel attr : excels) { + if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) { field.setAccessible(true); - fields.add(new Object[] { field, attr }); + fields.add(new Object[]{field, attr}); } } } @@ -1414,11 +1225,9 @@ public class ExcelUtil /** * 根据注解获取最大行高 */ - public short getRowHeight() - { + public short getRowHeight() { double maxHeight = 0; - for (Object[] os : this.fields) - { + for (Object[] os : this.fields) { Excel excel = (Excel) os[1]; maxHeight = Math.max(maxHeight, excel.height()); } @@ -1428,8 +1237,7 @@ public class ExcelUtil /** * 创建一个工作簿 */ - public void createWorkbook() - { + public void createWorkbook() { this.wb = new SXSSFWorkbook(500); this.sheet = wb.createSheet(); wb.setSheetName(0, sheetName); @@ -1440,13 +1248,11 @@ public class ExcelUtil * 创建工作表 * * @param sheetNo sheet数量 - * @param index 序号 + * @param index 序号 */ - public void createSheet(int sheetNo, int index) - { + public void createSheet(int sheetNo, int index) { // 设置工作表的名称. - if (sheetNo > 1 && index > 0) - { + if (sheetNo > 1 && index > 0) { this.sheet = wb.createSheet(); this.createTitle(); wb.setSheetName(index, sheetName + index); @@ -1456,58 +1262,39 @@ public class ExcelUtil /** * 获取单元格值 * - * @param row 获取的行 + * @param row 获取的行 * @param column 获取单元格列号 * @return 单元格值 */ - public Object getCellValue(Row row, int column) - { - if (row == null) - { + public Object getCellValue(Row row, int column) { + if (row == null) { return row; } Object val = ""; - try - { + try { Cell cell = row.getCell(column); - if (StringUtils.isNotNull(cell)) - { - if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA) - { + if (StringUtils.isNotNull(cell)) { + if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA) { val = cell.getNumericCellValue(); - if (DateUtil.isCellDateFormatted(cell)) - { + if (DateUtil.isCellDateFormatted(cell)) { val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换 - } - else - { - if ((Double) val % 1 != 0) - { + } else { + if ((Double) val % 1 != 0) { val = new BigDecimal(val.toString()); - } - else - { + } else { val = new DecimalFormat("0").format(val); } } - } - else if (cell.getCellType() == CellType.STRING) - { + } else if (cell.getCellType() == CellType.STRING) { val = cell.getStringCellValue(); - } - else if (cell.getCellType() == CellType.BOOLEAN) - { + } else if (cell.getCellType() == CellType.BOOLEAN) { val = cell.getBooleanCellValue(); - } - else if (cell.getCellType() == CellType.ERROR) - { + } else if (cell.getCellType() == CellType.ERROR) { val = cell.getErrorCellValue(); } } - } - catch (Exception e) - { + } catch (Exception e) { return val; } return val; @@ -1519,116 +1306,38 @@ public class ExcelUtil * @param row 判断的行 * @return */ - private boolean isRowEmpty(Row row) - { - if (row == null) - { + private boolean isRowEmpty(Row row) { + if (row == null) { return true; } - for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) - { + for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) { Cell cell = row.getCell(i); - if (cell != null && cell.getCellType() != CellType.BLANK) - { + if (cell != null && cell.getCellType() != CellType.BLANK) { return false; } } return true; } - /** - * 获取Excel2003图片 - * - * @param sheet 当前sheet对象 - * @param workbook 工作簿对象 - * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData - */ - public static Map getSheetPictures03(HSSFSheet sheet, HSSFWorkbook workbook) - { - Map sheetIndexPicMap = new HashMap(); - List pictures = workbook.getAllPictures(); - if (!pictures.isEmpty()) - { - for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren()) - { - HSSFClientAnchor anchor = (HSSFClientAnchor) shape.getAnchor(); - if (shape instanceof HSSFPicture) - { - HSSFPicture pic = (HSSFPicture) shape; - int pictureIndex = pic.getPictureIndex() - 1; - HSSFPictureData picData = pictures.get(pictureIndex); - String picIndex = String.valueOf(anchor.getRow1()) + "_" + String.valueOf(anchor.getCol1()); - sheetIndexPicMap.put(picIndex, picData); - } - } - return sheetIndexPicMap; - } - else - { - return sheetIndexPicMap; - } - } - - /** - * 获取Excel2007图片 - * - * @param sheet 当前sheet对象 - * @param workbook 工作簿对象 - * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData - */ - public static Map getSheetPictures07(XSSFSheet sheet, XSSFWorkbook workbook) - { - Map sheetIndexPicMap = new HashMap(); - for (POIXMLDocumentPart dr : sheet.getRelations()) - { - if (dr instanceof XSSFDrawing) - { - XSSFDrawing drawing = (XSSFDrawing) dr; - List shapes = drawing.getShapes(); - for (XSSFShape shape : shapes) - { - if (shape instanceof XSSFPicture) - { - XSSFPicture pic = (XSSFPicture) shape; - XSSFClientAnchor anchor = pic.getPreferredSize(); - CTMarker ctMarker = anchor.getFrom(); - String picIndex = ctMarker.getRow() + "_" + ctMarker.getCol(); - sheetIndexPicMap.put(picIndex, pic.getPictureData()); - } - } - } - } - return sheetIndexPicMap; - } - /** * 格式化不同类型的日期对象 * * @param dateFormat 日期格式 - * @param val 被格式化的日期对象 + * @param val 被格式化的日期对象 * @return 格式化后的日期字符 */ - public String parseDateToStr(String dateFormat, Object val) - { - if (val == null) - { + public String parseDateToStr(String dateFormat, Object val) { + if (val == null) { return ""; } String str; - if (val instanceof Date) - { + if (val instanceof Date) { str = DateUtils.parseDateToStr(dateFormat, (Date) val); - } - else if (val instanceof LocalDateTime) - { + } else if (val instanceof LocalDateTime) { str = DateUtils.parseDateToStr(dateFormat, DateUtils.toDate((LocalDateTime) val)); - } - else if (val instanceof LocalDate) - { + } else if (val instanceof LocalDate) { str = DateUtils.parseDateToStr(dateFormat, DateUtils.toDate((LocalDate) val)); - } - else - { + } else { str = val.toString(); } return str; @@ -1637,31 +1346,25 @@ public class ExcelUtil /** * 是否有对象的子列表 */ - public boolean isSubList() - { + public boolean isSubList() { return StringUtils.isNotNull(subFields) && subFields.size() > 0; } /** * 是否有对象的子列表,集合不为空 */ - public boolean isSubListValue(T vo) - { + public boolean isSubListValue(T vo) { return StringUtils.isNotNull(subFields) && subFields.size() > 0 && StringUtils.isNotNull(getListCellValue(vo)) && getListCellValue(vo).size() > 0; } /** * 获取集合的值 */ - public Collection getListCellValue(Object obj) - { + public Collection getListCellValue(Object obj) { Object value; - try - { - value = subMethod.invoke(obj, new Object[] {}); - } - catch (Exception e) - { + try { + value = subMethod.invoke(obj); + } catch (Exception e) { return new ArrayList(); } return (Collection) value; @@ -1670,22 +1373,18 @@ public class ExcelUtil /** * 获取对象的子列表方法 * - * @param name 名称 + * @param name 名称 * @param pojoClass 类对象 * @return 子列表方法 */ - public Method getSubMethod(String name, Class pojoClass) - { + public Method getSubMethod(String name, Class pojoClass) { StringBuffer getMethodName = new StringBuffer("get"); getMethodName.append(name.substring(0, 1).toUpperCase()); getMethodName.append(name.substring(1)); Method method = null; - try - { - method = pojoClass.getMethod(getMethodName.toString(), new Class[] {}); - } - catch (Exception e) - { + try { + method = pojoClass.getMethod(getMethodName.toString()); + } catch (Exception e) { log.error("获取对象异常{}", e.getMessage()); } return method; diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/reflect/ReflectUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/reflect/ReflectUtils.java index 26e726ae..15bf8e0f 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/reflect/ReflectUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/reflect/ReflectUtils.java @@ -13,32 +13,29 @@ import java.util.Date; /** * 反射工具类. 提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数. - * + * * @author ruoyi */ @SuppressWarnings("rawtypes") -public class ReflectUtils -{ +public class ReflectUtils { private static final String SETTER_PREFIX = "set"; private static final String GETTER_PREFIX = "get"; 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方法. * 支持多级,如:对象名.对象名.方法 */ @SuppressWarnings("unchecked") - public static E invokeGetter(Object obj, String propertyName) - { + public static E invokeGetter(Object obj, String propertyName) { Object object = obj; - for (String name : StringUtils.split(propertyName, ".")) - { + for (String name : StringUtils.split(propertyName, ".")) { String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name); - object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); + object = invokeMethod(object, getterMethodName, new Class[]{}, new Object[]{}); } return (E) object; } @@ -47,21 +44,16 @@ public class ReflectUtils * 调用Setter方法, 仅匹配方法名。 * 支持多级,如:对象名.对象名.方法 */ - public static void invokeSetter(Object obj, String propertyName, E value) - { + public static void invokeSetter(Object obj, String propertyName, E value) { Object object = obj; String[] names = StringUtils.split(propertyName, "."); - for (int i = 0; i < names.length; i++) - { - if (i < names.length - 1) - { + for (int i = 0; i < names.length; i++) { + if (i < names.length - 1) { String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]); - object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); - } - else - { + object = invokeMethod(object, getterMethodName, new Class[]{}, new Object[]{}); + } else { String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]); - invokeMethodByName(object, setterMethodName, new Object[] { value }); + invokeMethodByName(object, setterMethodName, new Object[]{value}); } } } @@ -70,21 +62,16 @@ public class ReflectUtils * 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数. */ @SuppressWarnings("unchecked") - public static E getFieldValue(final Object obj, final String fieldName) - { + public static E getFieldValue(final Object obj, final String fieldName) { Field field = getAccessibleField(obj, fieldName); - if (field == null) - { + if (field == null) { logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 "); return null; } E result = null; - try - { + try { result = (E) field.get(obj); - } - catch (IllegalAccessException e) - { + } catch (IllegalAccessException e) { logger.error("不可能抛出的异常{}", e.getMessage()); } return result; @@ -93,21 +80,16 @@ public class ReflectUtils /** * 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数. */ - public static void setFieldValue(final Object obj, final String fieldName, final E value) - { + public static void setFieldValue(final Object obj, final String fieldName, final E value) { Field field = getAccessibleField(obj, fieldName); - if (field == null) - { + if (field == null) { // throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 "); logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 "); return; } - try - { + try { field.set(obj, value); - } - catch (IllegalAccessException e) - { + } catch (IllegalAccessException e) { logger.error("不可能抛出的异常: {}", e.getMessage()); } } @@ -119,25 +101,19 @@ public class ReflectUtils */ @SuppressWarnings("unchecked") public static E invokeMethod(final Object obj, final String methodName, final Class[] parameterTypes, - final Object[] args) - { - if (obj == null || methodName == null) - { + final Object[] args) { + if (obj == null || methodName == null) { return null; } Method method = getAccessibleMethod(obj, methodName, parameterTypes); - if (method == null) - { + if (method == null) { logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 "); return null; } - try - { + try { return (E) method.invoke(obj, args); - } - catch (Exception e) - { - String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; + } catch (Exception e) { + String msg = "method: " + method + ", obj: " + obj + ", args: " + args; throw convertReflectionExceptionToUnchecked(msg, e); } } @@ -148,69 +124,45 @@ public class ReflectUtils * 只匹配函数名,如果有多个同名函数调用第一个。 */ @SuppressWarnings("unchecked") - public static E invokeMethodByName(final Object obj, final String methodName, final Object[] args) - { + public static E invokeMethodByName(final Object obj, final String methodName, final Object[] args) { Method method = getAccessibleMethodByName(obj, methodName, args.length); - if (method == null) - { + if (method == null) { // 如果为空不报错,直接返回空。 logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 "); return null; } - try - { + try { // 类型转换(将参数数据类型转换为目标方法参数类型) Class[] cs = method.getParameterTypes(); - for (int i = 0; i < cs.length; i++) - { - if (args[i] != null && !args[i].getClass().equals(cs[i])) - { - if (cs[i] == String.class) - { + for (int i = 0; i < cs.length; i++) { + if (args[i] != null && !args[i].getClass().equals(cs[i])) { + if (cs[i] == String.class) { args[i] = Convert.toStr(args[i]); - if (StringUtils.endsWith((String) args[i], ".0")) - { + if (StringUtils.endsWith((String) args[i], ".0")) { args[i] = StringUtils.substringBefore((String) args[i], ".0"); } - } - else if (cs[i] == Integer.class) - { + } else if (cs[i] == Integer.class) { args[i] = Convert.toInt(args[i]); - } - else if (cs[i] == Long.class) - { + } else if (cs[i] == Long.class) { args[i] = Convert.toLong(args[i]); - } - else if (cs[i] == Double.class) - { + } else if (cs[i] == Double.class) { args[i] = Convert.toDouble(args[i]); - } - else if (cs[i] == Float.class) - { + } else if (cs[i] == Float.class) { args[i] = Convert.toFloat(args[i]); - } - else if (cs[i] == Date.class) - { - if (args[i] instanceof String) - { + } else if (cs[i] == Date.class) { + if (args[i] instanceof String) { args[i] = DateUtils.parseDate(args[i]); - } - else - { + } else { args[i] = DateUtil.getJavaDate((Double) args[i]); } - } - else if (cs[i] == boolean.class || cs[i] == Boolean.class) - { + } else if (cs[i] == boolean.class || cs[i] == Boolean.class) { args[i] = Convert.toBool(args[i]); } } } return (E) method.invoke(obj, args); - } - catch (Exception e) - { - String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; + } catch (Exception e) { + String msg = "method: " + method + ", obj: " + obj + ", args: " + args; throw convertReflectionExceptionToUnchecked(msg, e); } } @@ -219,24 +171,18 @@ public class ReflectUtils * 循环向上转型, 获取对象的DeclaredField, 并强制设置为可访问. * 如向上转型到Object仍无法找到, 返回null. */ - public static Field getAccessibleField(final Object obj, final String fieldName) - { + public static Field getAccessibleField(final Object obj, final String fieldName) { // 为空不报错。直接返回 null - if (obj == null) - { + if (obj == null) { return null; } Validate.notBlank(fieldName, "fieldName can't be blank"); - for (Class superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) - { - try - { + for (Class superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) { + try { Field field = superClass.getDeclaredField(fieldName); makeAccessible(field); return field; - } - catch (NoSuchFieldException e) - { + } catch (NoSuchFieldException e) { continue; } } @@ -250,24 +196,18 @@ public class ReflectUtils * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args) */ public static Method getAccessibleMethod(final Object obj, final String methodName, - final Class... parameterTypes) - { + final Class... parameterTypes) { // 为空不报错。直接返回 null - if (obj == null) - { + if (obj == null) { return null; } Validate.notBlank(methodName, "methodName can't be blank"); - for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) - { - try - { + for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) { + try { Method method = searchType.getDeclaredMethod(methodName, parameterTypes); makeAccessible(method); return method; - } - catch (NoSuchMethodException e) - { + } catch (NoSuchMethodException e) { continue; } } @@ -280,21 +220,16 @@ public class ReflectUtils * 只匹配函数名。 * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args) */ - public static Method getAccessibleMethodByName(final Object obj, final String methodName, int argsNum) - { + public static Method getAccessibleMethodByName(final Object obj, final String methodName, int argsNum) { // 为空不报错。直接返回 null - if (obj == null) - { + if (obj == null) { return null; } Validate.notBlank(methodName, "methodName can't be blank"); - for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) - { + for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) { Method[] methods = searchType.getDeclaredMethods(); - for (Method method : methods) - { - if (method.getName().equals(methodName) && method.getParameterTypes().length == argsNum) - { + for (Method method : methods) { + if (method.getName().equals(methodName) && method.getParameterTypes().length == argsNum) { makeAccessible(method); return method; } @@ -306,11 +241,9 @@ public class ReflectUtils /** * 改变private/protected的方法为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。 */ - public static void makeAccessible(Method method) - { + public static void makeAccessible(Method method) { if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) - && !method.isAccessible()) - { + && !method.isAccessible()) { method.setAccessible(true); } } @@ -318,11 +251,9 @@ public class ReflectUtils /** * 改变private/protected的成员变量为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。 */ - public static void makeAccessible(Field field) - { + public static void makeAccessible(Field field) { if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) - || Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) - { + || Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) { field.setAccessible(true); } } @@ -332,8 +263,7 @@ public class ReflectUtils * 如无法找到, 返回Object.class. */ @SuppressWarnings("unchecked") - public static Class getClassGenricType(final Class clazz) - { + public static Class getClassGenricType(final Class clazz) { return getClassGenricType(clazz, 0); } @@ -341,26 +271,22 @@ public class ReflectUtils * 通过反射, 获得Class定义中声明的父类的泛型参数的类型. * 如无法找到, 返回Object.class. */ - public static Class getClassGenricType(final Class clazz, final int index) - { + public static Class getClassGenricType(final Class clazz, final int index) { Type genType = clazz.getGenericSuperclass(); - if (!(genType instanceof ParameterizedType)) - { + if (!(genType instanceof ParameterizedType)) { logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType"); return Object.class; } Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); - if (index >= params.length || index < 0) - { + if (index >= params.length || index < 0) { logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: " + params.length); return Object.class; } - if (!(params[index] instanceof Class)) - { + if (!(params[index] instanceof Class)) { logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter"); return Object.class; } @@ -368,18 +294,14 @@ public class ReflectUtils return (Class) params[index]; } - public static Class getUserClass(Object instance) - { - if (instance == null) - { + public static Class getUserClass(Object instance) { + if (instance == null) { throw new RuntimeException("Instance must not be null"); } Class clazz = instance.getClass(); - if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) - { + if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) { Class superClass = clazz.getSuperclass(); - if (superClass != null && !Object.class.equals(superClass)) - { + if (superClass != null && !Object.class.equals(superClass)) { return superClass; } } @@ -390,15 +312,11 @@ public class ReflectUtils /** * 将反射时的checked exception转换为unchecked exception. */ - public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e) - { + public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e) { if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException - || e instanceof NoSuchMethodException) - { + || e instanceof NoSuchMethodException) { return new IllegalArgumentException(msg, e); - } - else if (e instanceof InvocationTargetException) - { + } else if (e instanceof InvocationTargetException) { return new RuntimeException(msg, ((InvocationTargetException) e).getTargetException()); } return new RuntimeException(msg, e); diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/sign/Base64.java b/fastbee-common/src/main/java/com/fastbee/common/utils/sign/Base64.java index ca1f4f6c..170da006 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/sign/Base64.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/sign/Base64.java @@ -2,75 +2,63 @@ package com.fastbee.common.utils.sign; /** * Base64工具类 - * + * * @author ruoyi */ -public final class Base64 -{ - static private final int BASELENGTH = 128; - static private final int LOOKUPLENGTH = 64; - static private final int TWENTYFOURBITGROUP = 24; - static private final int EIGHTBIT = 8; - static private final int SIXTEENBIT = 16; - static private final int FOURBYTE = 4; - static private final int SIGN = -128; - static private final char PAD = '='; - static final private byte[] base64Alphabet = new byte[BASELENGTH]; - static final private char[] lookUpBase64Alphabet = new char[LOOKUPLENGTH]; +public final class Base64 { + static private final int BASELENGTH = 128; + static private final int LOOKUPLENGTH = 64; + static private final int TWENTYFOURBITGROUP = 24; + static private final int EIGHTBIT = 8; + static private final int SIXTEENBIT = 16; + static private final int FOURBYTE = 4; + static private final int SIGN = -128; + static private final char PAD = '='; + static final private byte[] base64Alphabet = new byte[BASELENGTH]; + static final private char[] lookUpBase64Alphabet = new char[LOOKUPLENGTH]; - static - { - for (int i = 0; i < BASELENGTH; ++i) - { + static { + for (int i = 0; i < BASELENGTH; ++i) { base64Alphabet[i] = -1; } - for (int i = 'Z'; i >= 'A'; i--) - { + for (int i = 'Z'; i >= 'A'; i--) { base64Alphabet[i] = (byte) (i - 'A'); } - for (int i = 'z'; i >= 'a'; i--) - { + for (int i = 'z'; i >= 'a'; i--) { base64Alphabet[i] = (byte) (i - 'a' + 26); } - for (int i = '9'; i >= '0'; i--) - { + for (int i = '9'; i >= '0'; i--) { base64Alphabet[i] = (byte) (i - '0' + 52); } base64Alphabet['+'] = 62; base64Alphabet['/'] = 63; - for (int i = 0; i <= 25; i++) - { + for (int i = 0; i <= 25; i++) { lookUpBase64Alphabet[i] = (char) ('A' + i); } - for (int i = 26, j = 0; i <= 51; i++, j++) - { + for (int i = 26, j = 0; i <= 51; i++, j++) { lookUpBase64Alphabet[i] = (char) ('a' + j); } - 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[62] = (char) '+'; - lookUpBase64Alphabet[63] = (char) '/'; + lookUpBase64Alphabet[62] = '+'; + lookUpBase64Alphabet[63] = '/'; } - private static boolean isWhiteSpace(char octect) - { + private static boolean isWhiteSpace(char octect) { return (octect == 0x20 || octect == 0xd || octect == 0xa || octect == 0x9); } - private static boolean isPad(char octect) - { + private static boolean isPad(char octect) { return (octect == PAD); } - private static boolean isData(char octect) - { + private static boolean isData(char octect) { return (octect < BASELENGTH && base64Alphabet[octect] != -1); } @@ -80,23 +68,20 @@ public final class Base64 * @param binaryData Array containing binaryData * @return Encoded Base64 array */ - public static String encode(byte[] binaryData) - { - if (binaryData == null) - { + public static String encode(byte[] binaryData) { + if (binaryData == null) { return null; } int lengthDataBits = binaryData.length * EIGHTBIT; - if (lengthDataBits == 0) - { + if (lengthDataBits == 0) { return ""; } int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP; int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP; int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets; - char encodedData[] = null; + char[] encodedData = null; encodedData = new char[numberQuartet * 4]; @@ -105,8 +90,7 @@ public final class Base64 int encodedIndex = 0; int dataIndex = 0; - for (int i = 0; i < numberTriplets; i++) - { + for (int i = 0; i < numberTriplets; i++) { b1 = binaryData[dataIndex++]; b2 = binaryData[dataIndex++]; b3 = binaryData[dataIndex++]; @@ -125,8 +109,7 @@ public final class Base64 } // form integral number of 6-bit groups - if (fewerThan24bits == EIGHTBIT) - { + if (fewerThan24bits == EIGHTBIT) { b1 = binaryData[dataIndex]; k = (byte) (b1 & 0x03); byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); @@ -134,9 +117,7 @@ public final class Base64 encodedData[encodedIndex++] = lookUpBase64Alphabet[k << 4]; encodedData[encodedIndex++] = PAD; encodedData[encodedIndex++] = PAD; - } - else if (fewerThan24bits == SIXTEENBIT) - { + } else if (fewerThan24bits == SIXTEENBIT) { b1 = binaryData[dataIndex]; b2 = binaryData[dataIndex + 1]; l = (byte) (b2 & 0x0f); @@ -159,10 +140,8 @@ public final class Base64 * @param encoded string containing Base64 data * @return Array containind decoded data. */ - public static byte[] decode(String encoded) - { - if (encoded == null) - { + public static byte[] decode(String encoded) { + if (encoded == null) { return null; } @@ -170,19 +149,17 @@ public final class Base64 // remove white spaces int len = removeWhiteSpace(base64Data); - if (len % FOURBYTE != 0) - { + if (len % FOURBYTE != 0) { return null;// should be divisible by four } int numberQuadruple = (len / FOURBYTE); - if (numberQuadruple == 0) - { + if (numberQuadruple == 0) { return new byte[0]; } - byte decodedData[] = null; + byte[] decodedData = null; byte b1 = 0, b2 = 0, b3 = 0, b4 = 0; char d1 = 0, d2 = 0, d3 = 0, d4 = 0; @@ -191,12 +168,10 @@ public final class Base64 int dataIndex = 0; decodedData = new byte[(numberQuadruple) * 3]; - for (; i < numberQuadruple - 1; i++) - { + for (; i < numberQuadruple - 1; i++) { if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++])) - || !isData((d3 = base64Data[dataIndex++])) || !isData((d4 = base64Data[dataIndex++]))) - { + || !isData((d3 = base64Data[dataIndex++])) || !isData((d4 = base64Data[dataIndex++]))) { return null; } // if found "no data" just return null @@ -210,8 +185,7 @@ public final class Base64 decodedData[encodedIndex++] = (byte) (b3 << 6 | b4); } - if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))) - { + if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))) { return null;// if found "no data" just return null } @@ -220,10 +194,8 @@ public final class Base64 d3 = base64Data[dataIndex++]; d4 = base64Data[dataIndex++]; - if (!isData((d3)) || !isData((d4))) - {// Check if they are PAD characters - if (isPad(d3) && isPad(d4)) - { + if (!isData((d3)) || !isData((d4))) {// Check if they are PAD characters + if (isPad(d3) && isPad(d4)) { if ((b2 & 0xf) != 0)// last 4 bits should be zero { return null; @@ -232,9 +204,7 @@ public final class Base64 System.arraycopy(decodedData, 0, tmp, 0, i * 3); tmp[encodedIndex] = (byte) (b1 << 2 | b2 >> 4); return tmp; - } - else if (!isPad(d3) && isPad(d4)) - { + } else if (!isPad(d3) && isPad(d4)) { b3 = base64Alphabet[d3]; if ((b3 & 0x3) != 0)// last 2 bits should be zero { @@ -245,14 +215,10 @@ public final class Base64 tmp[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); tmp[encodedIndex] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf)); return tmp; - } - else - { + } else { return null; } - } - else - { // No PAD e.g 3cQl + } else { // No PAD e.g 3cQl b3 = base64Alphabet[d3]; b4 = base64Alphabet[d4]; decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); @@ -269,20 +235,16 @@ public final class Base64 * @param data the byte array of base64 data (with WS) * @return the new length */ - private static int removeWhiteSpace(char[] data) - { - if (data == null) - { + private static int removeWhiteSpace(char[] data) { + if (data == null) { return 0; } // count characters that's not whitespace int newSize = 0; int len = data.length; - for (int i = 0; i < len; i++) - { - if (!isWhiteSpace(data[i])) - { + for (int i = 0; i < len; i++) { + if (!isWhiteSpace(data[i])) { data[newSize++] = data[i]; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/sign/Md5Utils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/sign/Md5Utils.java index 38711b91..5fe272e4 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/sign/Md5Utils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/sign/Md5Utils.java @@ -8,44 +8,35 @@ import java.security.MessageDigest; /** * Md5加密方法 - * + * * @author ruoyi */ -public class Md5Utils -{ +public class Md5Utils { private static final Logger log = LoggerFactory.getLogger(Md5Utils.class); - private static byte[] md5(String s) - { + private static byte[] md5(String s) { MessageDigest algorithm; - try - { + try { algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); - algorithm.update(s.getBytes("UTF-8")); + algorithm.update(s.getBytes(StandardCharsets.UTF_8)); byte[] messageDigest = algorithm.digest(); return messageDigest; - } - catch (Exception e) - { + } catch (Exception e) { log.error("MD5 Error...", e); } return null; } - private static final String toHex(byte hash[]) - { - if (hash == null) - { + private static final String toHex(byte[] hash) { + if (hash == null) { return null; } StringBuffer buf = new StringBuffer(hash.length * 2); int i; - for (i = 0; i < hash.length; i++) - { - if ((hash[i] & 0xff) < 0x10) - { + for (i = 0; i < hash.length; i++) { + if ((hash[i] & 0xff) < 0x10) { buf.append("0"); } buf.append(Long.toString(hash[i] & 0xff, 16)); @@ -53,14 +44,10 @@ public class Md5Utils return buf.toString(); } - public static String hash(String s) - { - try - { + public static String hash(String s) { + try { return new String(toHex(md5(s)).getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8); - } - catch (Exception e) - { + } catch (Exception e) { log.error("not supported charset...{}", e); return s; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/sign/SignUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/sign/SignUtils.java index f4c9aeff..233bc1ec 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/sign/SignUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/sign/SignUtils.java @@ -15,9 +15,9 @@ public class SignUtils { /** * 验证签名 */ - public static boolean checkSignature(String token, String signature, String timestamp,String nonce) { + public static boolean checkSignature(String token, String signature, String timestamp, String nonce) { // 1.将token、timestamp、nonce三个参数进行字典序排序 - String[] arr = new String[] { token, timestamp, nonce }; + String[] arr = new String[]{token, timestamp, nonce}; Arrays.sort(arr); // 2. 将三个参数字符串拼接成一个字符串进行sha1加密 @@ -38,7 +38,7 @@ public class SignUtils { content = null; // 3.将sha1加密后的字符串可与signature对比,标识该请求来源于微信 - return tmpStr != null ? tmpStr.equals(signature.toUpperCase()) : false; + return tmpStr != null && tmpStr.equals(signature.toUpperCase()); } /** @@ -56,7 +56,7 @@ public class SignUtils { * 将字节转换为十六进制字符串 */ private static String byteToHexStr(byte mByte) { - char[] Digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A','B', 'C', 'D', 'E', 'F' }; + char[] Digit = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; char[] tempArr = new char[2]; tempArr[0] = Digit[(mByte >>> 4) & 0X0F]; tempArr[1] = Digit[mByte & 0X0F]; diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/spring/SpringUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/spring/SpringUtils.java index 4f2506ab..d5c89bc7 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/spring/SpringUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/spring/SpringUtils.java @@ -18,40 +18,27 @@ import java.util.Map; /** * spring工具类 方便在非spring管理环境中获取bean - * + * * @author ruoyi */ @Component -public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware -{ - /** Spring应用上下文环境 */ +public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware { + /** + * Spring应用上下文环境 + */ private static ConfigurableListableBeanFactory beanFactory; private static ApplicationContext applicationContext; - @Override - public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException - { - SpringUtils.beanFactory = beanFactory; - } - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException - { - SpringUtils.applicationContext = applicationContext; - } - /** * 获取对象 * * @param name * @return Object 一个以所给名字注册的bean的实例 * @throws org.springframework.beans.BeansException - * */ @SuppressWarnings("unchecked") - public static T getBean(String name) throws BeansException - { + public static T getBean(String name) throws BeansException { return (T) beanFactory.getBean(name); } @@ -61,11 +48,9 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * @param clz * @return * @throws org.springframework.beans.BeansException - * */ - public static T getBean(Class clz) throws BeansException - { - T result = (T) beanFactory.getBean(clz); + public static T getBean(Class clz) throws BeansException { + T result = beanFactory.getBean(clz); return result; } @@ -75,8 +60,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * @param name * @return boolean */ - public static boolean containsBean(String name) - { + public static boolean containsBean(String name) { return beanFactory.containsBean(name); } @@ -86,10 +70,8 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * @param name * @return boolean * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException - * */ - public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException - { + public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException { return beanFactory.isSingleton(name); } @@ -97,10 +79,8 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * @param name * @return Class 注册对象的类型 * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException - * */ - public static Class getType(String name) throws NoSuchBeanDefinitionException - { + public static Class getType(String name) throws NoSuchBeanDefinitionException { return beanFactory.getType(name); } @@ -110,22 +90,19 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * @param name * @return * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException - * */ - public static String[] getAliases(String name) throws NoSuchBeanDefinitionException - { + public static String[] getAliases(String name) throws NoSuchBeanDefinitionException { return beanFactory.getAliases(name); } /** * 获取aop代理对象 - * + * * @param invoker * @return */ @SuppressWarnings("unchecked") - public static T getAopProxy(T invoker) - { + public static T getAopProxy(T invoker) { return (T) AopContext.currentProxy(); } @@ -134,8 +111,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * * @return 当前的环境配置 */ - public static String[] getActiveProfiles() - { + public static String[] getActiveProfiles() { return applicationContext.getEnvironment().getActiveProfiles(); } @@ -144,8 +120,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * * @return 当前的环境配置 */ - public static String getActiveProfile() - { + public static String getActiveProfile() { final String[] activeProfiles = getActiveProfiles(); return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null; } @@ -155,29 +130,38 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC * * @param key 配置文件的key * @return 当前的配置文件的值 - * */ - public static String getRequiredProperty(String key) - { + public static String getRequiredProperty(String key) { return applicationContext.getEnvironment().getRequiredProperty(key); } /** * 获取带有annotation注解的所有bean集合 + * * @param annotation 注解 * @param * @return 集合 */ - public static Map getBeanWithAnnotation(Class annotation){ - Map resultMap = new HashMap<>(); + public static Map getBeanWithAnnotation(Class annotation) { + Map resultMap = new HashMap<>(); Map beanMap = applicationContext.getBeansWithAnnotation(annotation); - if (CollectionUtils.isEmpty(beanMap)){ + if (CollectionUtils.isEmpty(beanMap)) { return resultMap; } - beanMap.forEach((key,value)->{ - resultMap.put(key,(T) value); + beanMap.forEach((key, value) -> { + resultMap.put(key, (T) value); }); return resultMap; } + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { + SpringUtils.beanFactory = beanFactory; + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + SpringUtils.applicationContext = applicationContext; + } + } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/sql/SqlUtil.java b/fastbee-common/src/main/java/com/fastbee/common/utils/sql/SqlUtil.java index ddf3bc52..c1289d69 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/sql/SqlUtil.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/sql/SqlUtil.java @@ -5,11 +5,10 @@ import com.fastbee.common.utils.StringUtils; /** * sql操作工具类 - * + * * @author ruoyi */ -public class SqlUtil -{ +public class SqlUtil { /** * 定义常用的 sql关键字 */ @@ -23,10 +22,8 @@ public class SqlUtil /** * 检查字符,防止注入绕过 */ - public static String escapeOrderBySql(String value) - { - if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) - { + public static String escapeOrderBySql(String value) { + if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) { throw new UtilException("参数不符合规范,不能进行查询"); } return value; @@ -35,25 +32,20 @@ public class SqlUtil /** * 验证 order by 语法是否符合规范 */ - public static boolean isValidOrderBySql(String value) - { + public static boolean isValidOrderBySql(String value) { return value.matches(SQL_PATTERN); } /** * SQL关键字检查 */ - public static void filterKeyword(String value) - { - if (StringUtils.isEmpty(value)) - { + public static void filterKeyword(String value) { + if (StringUtils.isEmpty(value)) { return; } String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|"); - for (String sqlKeyword : sqlKeywords) - { - if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1) - { + for (String sqlKeyword : sqlKeywords) { + if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1) { throw new UtilException("参数存在SQL注入风险"); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/IdUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/IdUtils.java index ae8d5956..398c33e6 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/IdUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/IdUtils.java @@ -7,135 +7,128 @@ import java.util.Random; /** * ID生成器工具类 - * + * * @author ruoyi */ @Slf4j -public class IdUtils -{ +public class IdUtils { private static long lastTimestamp = -1L; - private long sequence = 0L; + private static final Integer startIndex = 0; + private static final Integer endIndex = 6; private final long workerId; private final long datacenterId; - private static Integer startIndex=0; - private static Integer endIndex=6; + private long sequence = 0L; public IdUtils(long workerId, long datacenterId) { - if(workerId <= 31L && workerId >= 0L) { + if (workerId <= 31L && workerId >= 0L) { this.workerId = workerId; } else { - if(workerId != -1L) { + if (workerId != -1L) { throw new IllegalArgumentException("worker Id can't be greater than %d or less than 0"); } - this.workerId = (long)(new Random()).nextInt(31); + this.workerId = (new Random()).nextInt(31); } - if(datacenterId <= 31L && datacenterId >= 0L) { + if (datacenterId <= 31L && datacenterId >= 0L) { this.datacenterId = datacenterId; } else { - if(datacenterId != -1L) { + if (datacenterId != -1L) { throw new IllegalArgumentException("datacenter Id can't be greater than %d or less than 0"); } - this.datacenterId = (long)(new Random()).nextInt(31); + this.datacenterId = (new Random()).nextInt(31); } } - public synchronized long nextId() { - long timestamp = this.timeGen(); - if(timestamp < lastTimestamp) { - try { - throw new Exception("Clock moved backwards. Refusing to generate id for " + (lastTimestamp - timestamp) + " milliseconds"); - } catch (Exception e) { - log.warn("生成ID异常", e); - } - } - - if(lastTimestamp == timestamp) { - // 修复:使用括号确保正确的运算顺序 - this.sequence = (this.sequence + 1L) & 4095L; - if(this.sequence == 0L) { - timestamp = this.tilNextMillis(lastTimestamp); - } - } else { - this.sequence = 0L; - } - - lastTimestamp = timestamp; - - // 修复:使用括号确保正确的运算符优先级,避免负数 - // 原代码:timestamp - 1288834974657L << 22 会被解析为 timestamp - (1288834974657L << 22) - // 修复后:((timestamp - 1288834974657L) << 22) 确保先减法后位移 - long id = ((timestamp - 1288834974657L) << 22) - | (this.datacenterId << 17) - | (this.workerId << 12) - | this.sequence; - - // 确保返回的ID为正数(通过清除符号位) - // 如果id为负数,说明计算结果超出了预期,使用绝对值 - return id < 0 ? Math.abs(id) : id; - } - - private long tilNextMillis(long lastTimestamp) { - long timestamp; - for(timestamp = this.timeGen(); timestamp <= lastTimestamp; timestamp = this.timeGen()) { - ; - } - return timestamp; - } - - private long timeGen() { - return System.currentTimeMillis(); - } - public static String uuid() { return java.util.UUID.randomUUID().toString().replaceAll("-", ""); } public static String getNextCode() { - return Md5Utils.md5(IdUtils.uuid() + System.currentTimeMillis()).substring(startIndex,endIndex); + return Md5Utils.md5(IdUtils.uuid() + System.currentTimeMillis()).substring(startIndex, endIndex); } - /** * 获取随机UUID - * + * * @return 随机UUID */ - public static String randomUUID() - { + public static String randomUUID() { return UUID.randomUUID().toString(); } /** * 简化的UUID,去掉了横线 - * + * * @return 简化的UUID,去掉了横线 */ - public static String simpleUUID() - { + public static String simpleUUID() { return UUID.randomUUID().toString(true); } /** * 获取随机UUID,使用性能更好的ThreadLocalRandom生成UUID - * + * * @return 随机UUID */ - public static String fastUUID() - { + public static String fastUUID() { return UUID.fastUUID().toString(); } /** * 简化的UUID,去掉了横线,使用性能更好的ThreadLocalRandom生成UUID - * + * * @return 简化的UUID,去掉了横线 */ - public static String fastSimpleUUID() - { + public static String fastSimpleUUID() { return UUID.fastUUID().toString(true); } + + public synchronized long nextId() { + long timestamp = this.timeGen(); + if (timestamp < lastTimestamp) { + try { + throw new Exception("Clock moved backwards. Refusing to generate id for " + (lastTimestamp - timestamp) + " milliseconds"); + } catch (Exception e) { + log.warn("生成ID异常", e); + } + } + + if (lastTimestamp == timestamp) { + // 修复:使用括号确保正确的运算顺序 + this.sequence = (this.sequence + 1L) & 4095L; + if (this.sequence == 0L) { + timestamp = this.tilNextMillis(lastTimestamp); + } + } else { + this.sequence = 0L; + } + + lastTimestamp = timestamp; + + // 修复:使用括号确保正确的运算符优先级,避免负数 + // 原代码:timestamp - 1288834974657L << 22 会被解析为 timestamp - (1288834974657L << 22) + // 修复后:((timestamp - 1288834974657L) << 22) 确保先减法后位移 + long id = ((timestamp - 1288834974657L) << 22) + | (this.datacenterId << 17) + | (this.workerId << 12) + | this.sequence; + + // 确保返回的ID为正数(通过清除符号位) + // 如果id为负数,说明计算结果超出了预期,使用绝对值 + return id < 0 ? Math.abs(id) : id; + } + + private long tilNextMillis(long lastTimestamp) { + long timestamp; + for (timestamp = this.timeGen(); timestamp <= lastTimestamp; timestamp = this.timeGen()) { + } + return timestamp; + } + + private long timeGen() { + return System.currentTimeMillis(); + } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/IdWorker.java b/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/IdWorker.java index ae1945cc..9d255b2d 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/IdWorker.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/IdWorker.java @@ -5,36 +5,48 @@ import lombok.extern.slf4j.Slf4j; /** * 系统编码生成器(改进版) * 修复了原版本中可能导致负数的问题 - * + * * @author fastbee * @date 2025-01-20 */ @Slf4j public class IdWorker { - private final long workerId; - /** 起始时间戳:2015-01-20 00:00:00 */ + /** + * 起始时间戳:2015-01-20 00:00:00 + */ private final static long twepoch = 1421976968066L; - private long sequence = 0L; - /** 机器ID占用的位数 */ + /** + * 机器ID占用的位数 + */ private final static long workerIdBits = 2L; - /** 支持的最大机器ID */ + /** + * 支持的最大机器ID + */ public final static long maxWorkerId = -1L ^ (-1L << workerIdBits); - /** 序列号占用的位数 */ + /** + * 序列号占用的位数 + */ private final static long sequenceBits = 9L; - - /** 机器ID向左移的位数 */ - private final static long workerIdShift = sequenceBits; - /** 时间戳向左移的位数 */ - private final static long timestampLeftShift = sequenceBits + workerIdBits; - /** 生成序列的掩码 */ + /** + * 生成序列的掩码 + */ public final static long sequenceMask = -1L ^ (-1L << sequenceBits); - + /** + * 机器ID向左移的位数 + */ + private final static long workerIdShift = sequenceBits; + /** + * 时间戳向左移的位数 + */ + private final static long timestampLeftShift = sequenceBits + workerIdBits; + private final long workerId; + private long sequence = 0L; private long lastTimestamp = -1L; /** * 构造函数 - * + * * @param workerId 机器ID (0-3) */ public IdWorker(final long workerId) { @@ -50,12 +62,12 @@ public class IdWorker { /** * 生成下一个ID * 修复了原代码中的运算符优先级问题,确保不会产生负数 - * + * * @return 生成的ID(始终为正数) */ public synchronized long nextId() { long timestamp = this.timeGen(); - + // 时钟回拨检查 if (timestamp < this.lastTimestamp) { long offset = this.lastTimestamp - timestamp; @@ -92,13 +104,13 @@ public class IdWorker { log.warn("Generated negative ID: {}, using absolute value", id); return Math.abs(id); } - + return id; } /** * 等待下一毫秒 - * + * * @param lastTimestamp 上次生成ID的时间戳 * @return 新的时间戳 */ @@ -112,7 +124,7 @@ public class IdWorker { /** * 获取当前时间戳(毫秒) - * + * * @return 当前时间戳 */ private long timeGen() { diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/Seq.java b/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/Seq.java index a240871e..5a434aee 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/Seq.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/Seq.java @@ -8,8 +8,7 @@ import java.util.concurrent.atomic.AtomicInteger; /** * @author ruoyi 序列生成类 */ -public class Seq -{ +public class Seq { // 通用序列类型 public static final String commSeqType = "COMMON"; @@ -17,34 +16,31 @@ public class Seq public static final String uploadSeqType = "UPLOAD"; // 通用接口序列数 - 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); // 机器标识 - private static String machineCode = "A"; + private static final String machineCode = "A"; /** * 获取通用序列号 - * + * * @return 序列值 */ - public static String getId() - { + public static String getId() { return getId(commSeqType); } - + /** * 默认16位序列号 yyMMddHHmmss + 一位机器标识 + 3长度循环递增字符串 - * + * * @return 序列值 */ - public static String getId(String type) - { + public static String getId(String type) { AtomicInteger atomicInt = commSeq; - if (uploadSeqType.equals(type)) - { + if (uploadSeqType.equals(type)) { atomicInt = uploadSeq; } return getId(atomicInt, 3); @@ -52,13 +48,12 @@ public class Seq /** * 通用接口序列号 yyMMddHHmmss + 一位机器标识 + length长度循环递增字符串 - * + * * @param atomicInt 序列数 - * @param length 数值长度 + * @param length 数值长度 * @return 序列值 */ - public static String getId(AtomicInteger atomicInt, int length) - { + public static String getId(AtomicInteger atomicInt, int length) { String result = DateUtils.dateTimeNow(); result += machineCode; result += getSeq(atomicInt, length); @@ -67,18 +62,16 @@ public class Seq /** * 序列循环递增字符串[1, 10 的 (length)幂次方), 用0左补齐length位数 - * + * * @return 序列值 */ - private synchronized static String getSeq(AtomicInteger atomicInt, int length) - { + private synchronized static String getSeq(AtomicInteger atomicInt, int length) { // 先取值再+1 int value = atomicInt.getAndIncrement(); // 如果更新后值>=10 的 (length)幂次方则重置为1 int maxSeq = (int) Math.pow(10, length); - if (atomicInt.get() >= maxSeq) - { + if (atomicInt.get() >= maxSeq) { atomicInt.set(1); } // 转字符串,用0左补齐 diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/UUID.java b/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/UUID.java index 47b29ee7..6681c18e 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/UUID.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/uuid/UUID.java @@ -13,41 +13,30 @@ import java.util.concurrent.ThreadLocalRandom; * * @author ruoyi */ -public final class UUID implements java.io.Serializable, Comparable -{ +public final class UUID implements java.io.Serializable, Comparable { private static final long serialVersionUID = -1185015143654744140L; - /** - * SecureRandom 的单例 - * + * 此UUID的最高64有效位 */ - private static class Holder - { - static final SecureRandom numberGenerator = getSecureRandom(); - } - - /** 此UUID的最高64有效位 */ private final long mostSigBits; - - /** 此UUID的最低64有效位 */ + /** + * 此UUID的最低64有效位 + */ private final long leastSigBits; /** * 私有构造 - * + * * @param data 数据 */ - private UUID(byte[] data) - { + private UUID(byte[] data) { long msb = 0; long lsb = 0; assert data.length == 16 : "data must be 16 bytes in length"; - for (int i = 0; i < 8; i++) - { + for (int i = 0; i < 8; i++) { msb = (msb << 8) | (data[i] & 0xff); } - for (int i = 8; i < 16; i++) - { + for (int i = 8; i < 16; i++) { lsb = (lsb << 8) | (data[i] & 0xff); } this.mostSigBits = msb; @@ -57,43 +46,39 @@ public final class UUID implements java.io.Serializable, Comparable /** * 使用指定的数据构造新的 UUID。 * - * @param mostSigBits 用于 {@code UUID} 的最高有效 64 位 + * @param mostSigBits 用于 {@code UUID} 的最高有效 64 位 * @param leastSigBits 用于 {@code UUID} 的最低有效 64 位 */ - public UUID(long mostSigBits, long leastSigBits) - { + public UUID(long mostSigBits, long leastSigBits) { this.mostSigBits = mostSigBits; this.leastSigBits = leastSigBits; } /** * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的本地线程伪随机数生成器生成该 UUID。 - * + * * @return 随机生成的 {@code UUID} */ - public static UUID fastUUID() - { + public static UUID fastUUID() { return randomUUID(false); } /** * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。 - * + * * @return 随机生成的 {@code UUID} */ - public static UUID randomUUID() - { + public static UUID randomUUID() { return randomUUID(true); } /** * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。 - * + * * @param isSecure 是否使用{@link SecureRandom}如果是可以获得更安全的随机码,否则可以得到更好的性能 * @return 随机生成的 {@code UUID} */ - public static UUID randomUUID(boolean isSecure) - { + public static UUID randomUUID(boolean isSecure) { final Random ng = isSecure ? Holder.numberGenerator : getRandom(); byte[] randomBytes = new byte[16]; @@ -109,18 +94,13 @@ public final class UUID implements java.io.Serializable, Comparable * 根据指定的字节数组获取类型 3(基于名称的)UUID 的静态工厂。 * * @param name 用于构造 UUID 的字节数组。 - * * @return 根据指定数组生成的 {@code UUID} */ - public static UUID nameUUIDFromBytes(byte[] name) - { + public static UUID nameUUIDFromBytes(byte[] name) { MessageDigest md; - try - { + try { md = MessageDigest.getInstance("MD5"); - } - catch (NoSuchAlgorithmException nsae) - { + } catch (NoSuchAlgorithmException nsae) { throw new InternalError("MD5 not supported"); } byte[] md5Bytes = md.digest(name); @@ -137,17 +117,13 @@ public final class UUID implements java.io.Serializable, Comparable * @param name 指定 {@code UUID} 字符串 * @return 具有指定值的 {@code UUID} * @throws IllegalArgumentException 如果 name 与 {@link #toString} 中描述的字符串表示形式不符抛出此异常 - * */ - public static UUID fromString(String name) - { + public static UUID fromString(String name) { String[] components = name.split("-"); - if (components.length != 5) - { + if (components.length != 5) { throw new IllegalArgumentException("Invalid UUID string: " + name); } - for (int i = 0; i < 5; i++) - { + for (int i = 0; i < 5; i++) { components[i] = "0x" + components[i]; } @@ -164,13 +140,47 @@ public final class UUID implements java.io.Serializable, Comparable return new UUID(mostSigBits, leastSigBits); } + /** + * 返回指定数字对应的hex值 + * + * @param val 值 + * @param digits 位 + * @return 值 + */ + private static String digits(long val, int digits) { + long hi = 1L << (digits * 4); + return Long.toHexString(hi | (val & (hi - 1))).substring(1); + } + + /** + * 获取{@link SecureRandom},类提供加密的强随机数生成器 (RNG) + * + * @return {@link SecureRandom} + */ + public static SecureRandom getSecureRandom() { + try { + return SecureRandom.getInstance("SHA1PRNG"); + } catch (NoSuchAlgorithmException e) { + throw new UtilException(e); + } + } + + /** + * 获取随机数生成器对象
+ * ThreadLocalRandom是JDK 7之后提供并发产生随机数,能够解决多个线程发生的竞争争夺。 + * + * @return {@link ThreadLocalRandom} + */ + public static ThreadLocalRandom getRandom() { + return ThreadLocalRandom.current(); + } + /** * 返回此 UUID 的 128 位值中的最低有效 64 位。 * * @return 此 UUID 的 128 位值中的最低有效 64 位。 */ - public long getLeastSignificantBits() - { + public long getLeastSignificantBits() { return leastSigBits; } @@ -179,8 +189,7 @@ public final class UUID implements java.io.Serializable, Comparable * * @return 此 UUID 的 128 位值中最高有效 64 位。 */ - public long getMostSignificantBits() - { + public long getMostSignificantBits() { return mostSigBits; } @@ -197,8 +206,7 @@ public final class UUID implements java.io.Serializable, Comparable * * @return 此 {@code UUID} 的版本号 */ - public int version() - { + public int version() { // Version is bits masked by 0x000000000000F000 in MS long return (int) ((mostSigBits >> 12) & 0x0f); } @@ -216,8 +224,7 @@ public final class UUID implements java.io.Serializable, Comparable * * @return 此 {@code UUID} 相关联的变体号 */ - public int variant() - { + public int variant() { // This field is composed of a varying number of bits. // 0 - - Reserved for NCS backward compatibility // 1 0 - The IETF aka Leach-Salz variant (used by this class) @@ -239,8 +246,7 @@ public final class UUID implements java.io.Serializable, Comparable * * @throws UnsupportedOperationException 如果此 {@code UUID} 不是 version 为 1 的 UUID。 */ - public long timestamp() throws UnsupportedOperationException - { + public long timestamp() throws UnsupportedOperationException { checkTimeBase(); return (mostSigBits & 0x0FFFL) << 48// | ((mostSigBits >> 16) & 0x0FFFFL) << 32// @@ -257,11 +263,9 @@ public final class UUID implements java.io.Serializable, Comparable * UnsupportedOperationException。 * * @return 此 {@code UUID} 的时钟序列 - * * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1 */ - public int clockSequence() throws UnsupportedOperationException - { + public int clockSequence() throws UnsupportedOperationException { checkTimeBase(); return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48); } @@ -276,11 +280,9 @@ public final class UUID implements java.io.Serializable, Comparable * 如果此 UUID 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。 * * @return 此 {@code UUID} 的节点值 - * * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1 */ - public long node() throws UnsupportedOperationException - { + public long node() throws UnsupportedOperationException { checkTimeBase(); return leastSigBits & 0x0000FFFFFFFFFFFFL; } @@ -290,7 +292,7 @@ public final class UUID implements java.io.Serializable, Comparable * *

* UUID 的字符串表示形式由此 BNF 描述: - * + * *

      * {@code
      * UUID                   = ----
@@ -303,15 +305,14 @@ public final class UUID implements java.io.Serializable, Comparable
      * hexDigit               = [0-9a-fA-F]
      * }
      * 
- * + * * * * @return 此{@code UUID} 的字符串表现形式 * @see #toString(boolean) */ @Override - public String toString() - { + public String toString() { return toString(false); } @@ -320,7 +321,7 @@ public final class UUID implements java.io.Serializable, Comparable * *

* UUID 的字符串表示形式由此 BNF 描述: - * + * *

      * {@code
      * UUID                   = ----
@@ -333,37 +334,32 @@ public final class UUID implements java.io.Serializable, Comparable
      * hexDigit               = [0-9a-fA-F]
      * }
      * 
- * + * * * * @param isSimple 是否简单模式,简单模式为不带'-'的UUID字符串 * @return 此{@code UUID} 的字符串表现形式 */ - public String toString(boolean isSimple) - { + public String toString(boolean isSimple) { final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36); // time_low builder.append(digits(mostSigBits >> 32, 8)); - if (!isSimple) - { + if (!isSimple) { builder.append('-'); } // time_mid builder.append(digits(mostSigBits >> 16, 4)); - if (!isSimple) - { + if (!isSimple) { builder.append('-'); } // time_high_and_version builder.append(digits(mostSigBits, 4)); - if (!isSimple) - { + if (!isSimple) { builder.append('-'); } // variant_and_sequence builder.append(digits(leastSigBits >> 48, 4)); - if (!isSimple) - { + if (!isSimple) { builder.append('-'); } // node @@ -372,40 +368,39 @@ public final class UUID implements java.io.Serializable, Comparable return builder.toString(); } + // Comparison Operations + /** * 返回此 UUID 的哈希码。 * * @return UUID 的哈希码值。 */ @Override - public int hashCode() - { + public int hashCode() { long hilo = mostSigBits ^ leastSigBits; return ((int) (hilo >> 32)) ^ (int) hilo; } + // ------------------------------------------------------------------------------------------------------------------- + // Private method start + /** * 将此对象与指定对象比较。 *

* 当且仅当参数不为 {@code null}、而是一个 UUID 对象、具有与此 UUID 相同的 varriant、包含相同的值(每一位均相同)时,结果才为 {@code true}。 * * @param obj 要与之比较的对象 - * * @return 如果对象相同,则返回 {@code true};否则返回 {@code false} */ @Override - public boolean equals(Object obj) - { - if ((null == obj) || (obj.getClass() != UUID.class)) - { + public boolean equals(Object obj) { + if ((null == obj) || (obj.getClass() != UUID.class)) { return false; } UUID id = (UUID) obj; return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits); } - // Comparison Operations - /** * 将此 UUID 与指定的 UUID 比较。 * @@ -413,13 +408,10 @@ public final class UUID implements java.io.Serializable, Comparable * 如果两个 UUID 不同,且第一个 UUID 的最高有效字段大于第二个 UUID 的对应字段,则第一个 UUID 大于第二个 UUID。 * * @param val 与此 UUID 比较的 UUID - * * @return 在此 UUID 小于、等于或大于 val 时,分别返回 -1、0 或 1。 - * */ @Override - public int compareTo(UUID val) - { + public int compareTo(UUID val) { // The ordering is intentionally set up so that the UUIDs // can simply be numerically compared as two numbers return (this.mostSigBits < val.mostSigBits ? -1 : // @@ -429,57 +421,19 @@ public final class UUID implements java.io.Serializable, Comparable 0)))); } - // ------------------------------------------------------------------------------------------------------------------- - // Private method start - /** - * 返回指定数字对应的hex值 - * - * @param val 值 - * @param digits 位 - * @return 值 - */ - private static String digits(long val, int digits) - { - long hi = 1L << (digits * 4); - return Long.toHexString(hi | (val & (hi - 1))).substring(1); - } - /** * 检查是否为time-based版本UUID */ - private void checkTimeBase() - { - if (version() != 1) - { + private void checkTimeBase() { + if (version() != 1) { throw new UnsupportedOperationException("Not a time-based UUID"); } } /** - * 获取{@link SecureRandom},类提供加密的强随机数生成器 (RNG) - * - * @return {@link SecureRandom} + * SecureRandom 的单例 */ - public static SecureRandom getSecureRandom() - { - try - { - return SecureRandom.getInstance("SHA1PRNG"); - } - catch (NoSuchAlgorithmException e) - { - throw new UtilException(e); - } - } - - /** - * 获取随机数生成器对象
- * ThreadLocalRandom是JDK 7之后提供并发产生随机数,能够解决多个线程发生的竞争争夺。 - * - * @return {@link ThreadLocalRandom} - */ - public static ThreadLocalRandom getRandom() - { - return ThreadLocalRandom.current(); + private static class Holder { + static final SecureRandom numberGenerator = getSecureRandom(); } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/AesException.java b/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/AesException.java index a98fa02c..7ea73ccd 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/AesException.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/AesException.java @@ -16,7 +16,12 @@ public class AesException extends Exception { //public final static int EncodeBase64Error = -40009; //public final static int DecodeBase64Error = -40010; //public final static int GenReturnXmlError = -40011; - private int code; + private final int code; + + AesException(int code) { + super(getMessage(code)); + this.code = code; + } private static String getMessage(int code) { switch (code) { @@ -46,11 +51,8 @@ public class AesException extends Exception { return null; // cannot be } } + public int getCode() { return code; } - AesException(int code) { - super(getMessage(code)); - this.code = code; - } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/PKCS7Encoder.java b/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/PKCS7Encoder.java index 620e7c92..5e940a74 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/PKCS7Encoder.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/PKCS7Encoder.java @@ -1,13 +1,14 @@ package com.fastbee.common.utils.wechat; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Arrays; /** * 提供基于PKCS7算法的加解密接口. */ class PKCS7Encoder { - static Charset CHARSET = Charset.forName("utf-8"); + static Charset CHARSET = StandardCharsets.UTF_8; static int BLOCK_SIZE = 32; /** @@ -24,7 +25,7 @@ class PKCS7Encoder { } // 获得补位所用的字符 char padChr = chr(amountToPad); - String tmp = new String(); + String tmp = ""; for (int index = 0; index < amountToPad; index++) { tmp += padChr; } @@ -38,7 +39,7 @@ class PKCS7Encoder { * @return 删除补位字符后的明文 */ static byte[] decode(byte[] decrypted) { - int pad = (int) decrypted[decrypted.length - 1]; + int pad = decrypted[decrypted.length - 1]; if (pad < 1 || pad > 32) { pad = 0; } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/SHA1.java b/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/SHA1.java index 0d0796ff..0e67d9f4 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/SHA1.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/SHA1.java @@ -7,26 +7,27 @@ import java.util.Arrays; * * @copyright Copyright (c) 1998-2014 Tencent Inc. */ + /** * SHA1 class - * + *

* 计算消息签名接口. */ public class SHA1 { /** * 用SHA1算法生成安全签名 - * @param token 票据 + * + * @param token 票据 * @param timestamp 时间戳 - * @param nonce 随机字符串 - * @param encrypt 密文 + * @param nonce 随机字符串 + * @param encrypt 密文 * @return 安全签名 * @throws AesException */ - public static String getSHA1(String token, String timestamp, String nonce, String encrypt) throws AesException - { + public static String getSHA1(String token, String timestamp, String nonce, String encrypt) throws AesException { try { - String[] array = new String[] { token, timestamp, nonce, encrypt }; + String[] array = new String[]{token, timestamp, nonce, encrypt}; StringBuffer sb = new StringBuffer(); // 字符串排序 Arrays.sort(array); diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/WXBizMsgCrypt.java b/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/WXBizMsgCrypt.java index 3e512c30..152a495f 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/WXBizMsgCrypt.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/WXBizMsgCrypt.java @@ -20,6 +20,7 @@ import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Random; @@ -39,7 +40,7 @@ import java.util.Random; * */ public class WXBizMsgCrypt { - static Charset CHARSET = Charset.forName("utf-8"); + static Charset CHARSET = StandardCharsets.UTF_8; Base64 base64 = new Base64(); byte[] aesKey; String token; @@ -47,10 +48,10 @@ public class WXBizMsgCrypt { /** * 构造函数 - * @param token 企业微信后台,开发者设置的token - * @param encodingAesKey 企业微信后台,开发者设置的EncodingAESKey - * @param receiveid, 不同场景含义不同,详见文档 * + * @param token 企业微信后台,开发者设置的token + * @param encodingAesKey 企业微信后台,开发者设置的EncodingAESKey + * @param receiveid, 不同场景含义不同,详见文档 * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息 */ public WXBizMsgCrypt(String token, String encodingAesKey, String receiveid) throws AesException { @@ -202,10 +203,9 @@ public class WXBizMsgCrypt { *

  • 将消息密文和安全签名打包成xml格式
  • * * - * @param replyMsg 企业微信待回复用户的消息,xml格式的字符串 + * @param replyMsg 企业微信待回复用户的消息,xml格式的字符串 * @param timeStamp 时间戳,可以自己生成,也可以用URL参数的timestamp - * @param nonce 随机串,可以自己生成,也可以用URL参数的nonce - * + * @param nonce 随机串,可以自己生成,也可以用URL参数的nonce * @return 加密后的可以直接回复用户的密文,包括msg_signature, timestamp, nonce, encrypt的xml格式的字符串 * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息 */ @@ -235,10 +235,9 @@ public class WXBizMsgCrypt { * * * @param msgSignature 签名串,对应URL参数的msg_signature - * @param timeStamp 时间戳,对应URL参数的timestamp - * @param nonce 随机串,对应URL参数的nonce - * @param postData 密文,对应POST请求的数据 - * + * @param timeStamp 时间戳,对应URL参数的timestamp + * @param nonce 随机串,对应URL参数的nonce + * @param postData 密文,对应POST请求的数据 * @return 解密后的原文 * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息 */ @@ -266,11 +265,11 @@ public class WXBizMsgCrypt { /** * 验证URL - * @param msgSignature 签名串,对应URL参数的msg_signature - * @param timeStamp 时间戳,对应URL参数的timestamp - * @param nonce 随机串,对应URL参数的nonce - * @param echoStr 随机串,对应URL参数的echostr * + * @param msgSignature 签名串,对应URL参数的msg_signature + * @param timeStamp 时间戳,对应URL参数的timestamp + * @param nonce 随机串,对应URL参数的nonce + * @param echoStr 随机串,对应URL参数的echostr * @return 解密之后的echostr * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/WechatUtils.java b/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/WechatUtils.java index 670481a2..9d1d9652 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/WechatUtils.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/WechatUtils.java @@ -26,8 +26,9 @@ public class WechatUtils { /** * 网站、移动应用获取微信用户accessToken - * @param code 用户登录code - * @param appId 微信平台appId + * + * @param code 用户登录code + * @param appId 微信平台appId * @param secret 微信平台密钥 * @return WeChatAppResult */ @@ -39,8 +40,9 @@ public class WechatUtils { /** * 获取微信用户信息 + * * @param accessToken 接口调用凭证 - * @param openId 用户唯一标识 + * @param openId 用户唯一标识 * @return WeChatUserInfo */ public static WeChatUserInfo getWeChatUserInfo(String accessToken, String openId) { @@ -51,8 +53,9 @@ public class WechatUtils { /** * 小程序获取微信用户登录信息 - * @param code 用户凭证 - * @param appId 微信平台appId + * + * @param code 用户凭证 + * @param appId 微信平台appId * @param secret 微信平台密钥 * @return 结果 */ @@ -64,7 +67,8 @@ public class WechatUtils { /** * 小程序获取微信用户手机号 - * @param code 凭证 + * + * @param code 凭证 * @param accessToken 微信用户token * @return 手机号信息 */ @@ -78,7 +82,8 @@ public class WechatUtils { /** * 小程序获、公众号取微信accessToken - * @param appId 微信平台appId + * + * @param appId 微信平台appId * @param secret 微信平台密钥 * @return WeChatAppResult */ @@ -99,8 +104,9 @@ public class WechatUtils { /** * 微信公众号获取微信用户信息 + * * @param accessToken 接口调用凭证 - * @param openId 用户唯一标识 + * @param openId 用户唯一标识 * @return WeChatUserInfo */ public static WeChatUserInfo getWeChatPublicAccountUserInfo(String accessToken, String openId) { @@ -110,14 +116,13 @@ public class WechatUtils { } public static String responseText(WxCallBackXmlBO wxCallBackXmlBO, String content) { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(""); - stringBuilder.append(""); - stringBuilder.append(""); - stringBuilder.append("" + (LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli() / 1000) + ""); - stringBuilder.append(""); - stringBuilder.append(""); //替换空格,文本信息内容不能包含有空格 .Replace(" ", string.Empty) - stringBuilder.append(""); - return stringBuilder.toString(); + String stringBuilder = "" + + "" + + "" + + "" + (LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli() / 1000) + "" + + "" + + "" + //替换空格,文本信息内容不能包含有空格 .Replace(" ", string.Empty) + ""; + return stringBuilder; } } diff --git a/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/XMLParse.java b/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/XMLParse.java index 74d3fd23..7a0121c8 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/XMLParse.java +++ b/fastbee-common/src/main/java/com/fastbee/common/utils/wechat/XMLParse.java @@ -19,18 +19,19 @@ import java.io.StringReader; /** * XMLParse class - * + *

    * 提供提取消息格式中的密文及生成回复消息格式的接口. */ class XMLParse { /** * 提取出xml数据包中的加密消息 + * * @param xmltext 待提取的xml字符串 * @return 提取出的加密消息字符串 * @throws AesException */ - public static Object[] extract(String xmltext) throws AesException { + public static Object[] extract(String xmltext) throws AesException { Object[] result = new Object[3]; try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -86,10 +87,11 @@ class XMLParse { /** * 生成xml消息 - * @param encrypt 加密后的消息密文 + * + * @param encrypt 加密后的消息密文 * @param signature 安全签名 * @param timestamp 时间戳 - * @param nonce 随机字符串 + * @param nonce 随机字符串 * @return 生成的xml字符串 */ public static String generate(String encrypt, String signature, String timestamp, String nonce) { diff --git a/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatAppResult.java b/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatAppResult.java index 931a23a0..ebe7b689 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatAppResult.java +++ b/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatAppResult.java @@ -5,6 +5,7 @@ import lombok.Data; /** * WeChat 调用api接口获取openid登信息后的返回类 + * * @author fastb * @date 2023-07-31 11:43 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatLoginBody.java b/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatLoginBody.java index 60a47673..5930348c 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatLoginBody.java +++ b/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatLoginBody.java @@ -5,6 +5,7 @@ import lombok.experimental.Accessors; /** * 微信端登录参数 + * * @author fastb * @date 2023-07-31 11:32 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatLoginResult.java b/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatLoginResult.java index 08c09ca9..a5f97150 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatLoginResult.java +++ b/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatLoginResult.java @@ -4,6 +4,7 @@ import lombok.Data; /** * 微信登录返回结果 + * * @author fastb * @date 2023-08-15 16:43 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatUserInfo.java b/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatUserInfo.java index 48a06c90..fcdc8dd5 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatUserInfo.java +++ b/fastbee-common/src/main/java/com/fastbee/common/wechat/WeChatUserInfo.java @@ -5,6 +5,7 @@ import lombok.Data; /** * 微信用户信息 + * * @author fastb * @date 2023-07-31 14:56 */ diff --git a/fastbee-common/src/main/java/com/fastbee/common/wechat/WxCallBackXmlBO.java b/fastbee-common/src/main/java/com/fastbee/common/wechat/WxCallBackXmlBO.java index 5cbba2fa..18068b18 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/wechat/WxCallBackXmlBO.java +++ b/fastbee-common/src/main/java/com/fastbee/common/wechat/WxCallBackXmlBO.java @@ -5,9 +5,10 @@ import lombok.Data; /** * 微信回调的时候入参XML解析节点封装BO + * * @author fastb - * @date 2024-03-12 15:24 * @version 1.0 + * @date 2024-03-12 15:24 */ @Data public class WxCallBackXmlBO { diff --git a/fastbee-common/src/main/java/com/fastbee/common/xss/Xss.java b/fastbee-common/src/main/java/com/fastbee/common/xss/Xss.java index 5f79e8a0..10a4504c 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/xss/Xss.java +++ b/fastbee-common/src/main/java/com/fastbee/common/xss/Xss.java @@ -9,17 +9,16 @@ import java.lang.annotation.Target; /** * 自定义xss校验注解 - * + * * @author ruoyi */ @Retention(RetentionPolicy.RUNTIME) -@Target(value = { ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER }) -@Constraint(validatedBy = { XssValidator.class }) -public @interface Xss -{ +@Target(value = {ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER}) +@Constraint(validatedBy = {XssValidator.class}) +public @interface Xss { String message() - default "不允许任何脚本运行"; + default "不允许任何脚本运行"; Class[] groups() default {}; diff --git a/fastbee-common/src/main/java/com/fastbee/common/xss/XssValidator.java b/fastbee-common/src/main/java/com/fastbee/common/xss/XssValidator.java index 780673c3..aa26d27b 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/xss/XssValidator.java +++ b/fastbee-common/src/main/java/com/fastbee/common/xss/XssValidator.java @@ -9,27 +9,23 @@ import java.util.regex.Pattern; /** * 自定义xss校验注解实现 - * + * * @author ruoyi */ -public class XssValidator implements ConstraintValidator -{ +public class XssValidator implements ConstraintValidator { private static final String HTML_PATTERN = "<(\\S*?)[^>]*>.*?|<.*? />"; - @Override - public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) - { - if (StringUtils.isBlank(value)) - { - return true; - } - return !containsHtml(value); - } - - public static boolean containsHtml(String value) - { + public static boolean containsHtml(String value) { Pattern pattern = Pattern.compile(HTML_PATTERN); Matcher matcher = pattern.matcher(value); return matcher.matches(); } + + @Override + public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) { + if (StringUtils.isBlank(value)) { + return true; + } + return !containsHtml(value); + } } \ No newline at end of file diff --git a/fastbee-framework/src/main/java/com/fastbee/framework/datasource/DynamicDataSource.java b/fastbee-framework/src/main/java/com/fastbee/framework/datasource/DynamicDataSource.java index 2830ffdc..95c9a197 100644 --- a/fastbee-framework/src/main/java/com/fastbee/framework/datasource/DynamicDataSource.java +++ b/fastbee-framework/src/main/java/com/fastbee/framework/datasource/DynamicDataSource.java @@ -1,11 +1,11 @@ package com.fastbee.framework.datasource; -import java.util.Map; -import javax.sql.DataSource; - import lombok.extern.slf4j.Slf4j; import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; +import javax.sql.DataSource; +import java.util.Map; + /** * 动态数据源 * diff --git a/fastbee-framework/src/main/java/com/fastbee/framework/interceptor/RepeatSubmitInterceptor.java b/fastbee-framework/src/main/java/com/fastbee/framework/interceptor/RepeatSubmitInterceptor.java index 0a5b875e..d9b92420 100644 --- a/fastbee-framework/src/main/java/com/fastbee/framework/interceptor/RepeatSubmitInterceptor.java +++ b/fastbee-framework/src/main/java/com/fastbee/framework/interceptor/RepeatSubmitInterceptor.java @@ -1,16 +1,16 @@ package com.fastbee.framework.interceptor; -import java.lang.reflect.Method; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.stereotype.Component; -import org.springframework.web.method.HandlerMethod; -import org.springframework.web.servlet.HandlerInterceptor; import com.alibaba.fastjson2.JSON; import com.fastbee.common.annotation.RepeatSubmit; import com.fastbee.common.core.domain.AjaxResult; import com.fastbee.common.utils.ServletUtils; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.HandlerInterceptor; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.lang.reflect.Method; /** * 防止重复提交拦截器 diff --git a/fastbee-framework/src/main/java/com/fastbee/framework/interceptor/impl/SameUrlDataInterceptor.java b/fastbee-framework/src/main/java/com/fastbee/framework/interceptor/impl/SameUrlDataInterceptor.java index 4ef709c7..610b1152 100644 --- a/fastbee-framework/src/main/java/com/fastbee/framework/interceptor/impl/SameUrlDataInterceptor.java +++ b/fastbee-framework/src/main/java/com/fastbee/framework/interceptor/impl/SameUrlDataInterceptor.java @@ -1,13 +1,5 @@ package com.fastbee.framework.interceptor.impl; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import javax.servlet.http.HttpServletRequest; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; import com.alibaba.fastjson2.JSON; import com.fastbee.common.annotation.RepeatSubmit; import com.fastbee.common.constant.CacheConstants; @@ -16,6 +8,14 @@ import com.fastbee.common.filter.RepeatedlyRequestWrapper; import com.fastbee.common.utils.StringUtils; import com.fastbee.common.utils.http.HttpHelper; import com.fastbee.framework.interceptor.RepeatSubmitInterceptor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; /** * 判断请求url和数据是否和上一次相同, diff --git a/fastbee-framework/src/main/java/com/fastbee/framework/manager/CaffeineCacheDecorator.java b/fastbee-framework/src/main/java/com/fastbee/framework/manager/CaffeineCacheDecorator.java index 8ad49357..884efb59 100644 --- a/fastbee-framework/src/main/java/com/fastbee/framework/manager/CaffeineCacheDecorator.java +++ b/fastbee-framework/src/main/java/com/fastbee/framework/manager/CaffeineCacheDecorator.java @@ -1,7 +1,7 @@ package com.fastbee.framework.manager; -import org.springframework.cache.Cache; import com.fastbee.common.utils.spring.SpringUtils; +import org.springframework.cache.Cache; import java.util.concurrent.Callable; diff --git a/fastbee-framework/src/main/java/com/fastbee/framework/security/context/PermissionContextHolder.java b/fastbee-framework/src/main/java/com/fastbee/framework/security/context/PermissionContextHolder.java index 99032482..1bbdf206 100644 --- a/fastbee-framework/src/main/java/com/fastbee/framework/security/context/PermissionContextHolder.java +++ b/fastbee-framework/src/main/java/com/fastbee/framework/security/context/PermissionContextHolder.java @@ -1,8 +1,8 @@ package com.fastbee.framework.security.context; +import com.fastbee.common.core.text.Convert; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; -import com.fastbee.common.core.text.Convert; /** * 权限信息 diff --git a/fastbee-framework/src/main/java/com/fastbee/framework/security/filter/JwtAuthenticationTokenFilter.java b/fastbee-framework/src/main/java/com/fastbee/framework/security/filter/JwtAuthenticationTokenFilter.java index 62beb477..4f9e7b3a 100644 --- a/fastbee-framework/src/main/java/com/fastbee/framework/security/filter/JwtAuthenticationTokenFilter.java +++ b/fastbee-framework/src/main/java/com/fastbee/framework/security/filter/JwtAuthenticationTokenFilter.java @@ -1,21 +1,21 @@ package com.fastbee.framework.security.filter; -import java.io.IOException; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - +import com.fastbee.common.core.domain.model.LoginUser; +import com.fastbee.common.utils.SecurityUtils; +import com.fastbee.common.utils.StringUtils; +import com.fastbee.framework.web.service.TokenService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; import org.springframework.stereotype.Component; import org.springframework.web.filter.OncePerRequestFilter; -import com.fastbee.common.core.domain.model.LoginUser; -import com.fastbee.common.utils.SecurityUtils; -import com.fastbee.common.utils.StringUtils; -import com.fastbee.framework.web.service.TokenService; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; /** * token过滤器 验证token有效性 diff --git a/fastbee-framework/src/main/java/com/fastbee/framework/security/handle/AuthenticationEntryPointImpl.java b/fastbee-framework/src/main/java/com/fastbee/framework/security/handle/AuthenticationEntryPointImpl.java index ea4b40ab..63b6ecd4 100644 --- a/fastbee-framework/src/main/java/com/fastbee/framework/security/handle/AuthenticationEntryPointImpl.java +++ b/fastbee-framework/src/main/java/com/fastbee/framework/security/handle/AuthenticationEntryPointImpl.java @@ -1,18 +1,18 @@ package com.fastbee.framework.security.handle; -import java.io.IOException; -import java.io.Serializable; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.web.AuthenticationEntryPoint; -import org.springframework.stereotype.Component; import com.alibaba.fastjson2.JSON; import com.fastbee.common.constant.HttpStatus; import com.fastbee.common.core.domain.AjaxResult; import com.fastbee.common.utils.ServletUtils; import com.fastbee.common.utils.StringUtils; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.Serializable; /** * 认证失败处理类 返回未授权 diff --git a/fastbee-framework/src/main/java/com/fastbee/framework/security/handle/LogoutSuccessHandlerImpl.java b/fastbee-framework/src/main/java/com/fastbee/framework/security/handle/LogoutSuccessHandlerImpl.java index 49fbcddd..93bdf616 100644 --- a/fastbee-framework/src/main/java/com/fastbee/framework/security/handle/LogoutSuccessHandlerImpl.java +++ b/fastbee-framework/src/main/java/com/fastbee/framework/security/handle/LogoutSuccessHandlerImpl.java @@ -1,14 +1,5 @@ package com.fastbee.framework.security.handle; -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.core.Authentication; -import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; import com.alibaba.fastjson2.JSON; import com.fastbee.common.constant.Constants; import com.fastbee.common.core.domain.AjaxResult; @@ -18,6 +9,15 @@ import com.fastbee.common.utils.StringUtils; import com.fastbee.framework.manager.AsyncManager; import com.fastbee.framework.manager.factory.AsyncFactory; import com.fastbee.framework.web.service.TokenService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; /** * 自定义退出处理类 返回成功 diff --git a/fastbee-record/src/main/java/com/fastbee/record/controller/bean/Result.java b/fastbee-record/src/main/java/com/fastbee/record/controller/bean/Result.java index b99719d5..99ae4b96 100644 --- a/fastbee-record/src/main/java/com/fastbee/record/controller/bean/Result.java +++ b/fastbee-record/src/main/java/com/fastbee/record/controller/bean/Result.java @@ -5,8 +5,10 @@ public class Result { private int code; private String msg; private T data; + public Result() { } + public Result(int code, String msg, T data) { this.code = code; this.msg = msg; diff --git a/fastbee-server/sip-server/src/main/java/com/fastbee/sip/model/SipDeviceSummary.java b/fastbee-server/sip-server/src/main/java/com/fastbee/sip/model/SipDeviceSummary.java index f2f193d2..2a7c76b0 100644 --- a/fastbee-server/sip-server/src/main/java/com/fastbee/sip/model/SipDeviceSummary.java +++ b/fastbee-server/sip-server/src/main/java/com/fastbee/sip/model/SipDeviceSummary.java @@ -11,6 +11,7 @@ public class SipDeviceSummary { private String streammode; private Integer port; private String hostaddress; + public SipDeviceSummary(SipDevice device) { this.manufacturer = device.getManufacturer(); this.firmware = device.getFirmware(); @@ -19,6 +20,7 @@ public class SipDeviceSummary { this.port = device.getPort(); this.hostaddress = device.getHostaddress(); } + public SipDeviceSummary() { } diff --git a/fastbee-server/sip-server/src/main/java/com/fastbee/sip/server/GBMsgParser.java b/fastbee-server/sip-server/src/main/java/com/fastbee/sip/server/GBMsgParser.java index 2613586c..c54f7ec4 100644 --- a/fastbee-server/sip-server/src/main/java/com/fastbee/sip/server/GBMsgParser.java +++ b/fastbee-server/sip-server/src/main/java/com/fastbee/sip/server/GBMsgParser.java @@ -275,18 +275,16 @@ public class GBMsgParser implements MessageParser { /** * Parse a host:port and return a parsed structure. * - * @param hostport - * is a String containing the host:port to be parsed + * @param hostport is a String containing the host:port to be parsed * @return a parsed address structure. + * @throws throws a ParseException when the address is badly formatted. + *

    + * public HostPort parseHostPort(String hostport) throws ParseException { + * Lexer lexer = new Lexer("charLexer", hostport); + * return new HostNameParser(lexer).hostPort(); + *

    + * } * @since v1.0 - * @exception throws - * a ParseException when the address is badly formatted. - * - public HostPort parseHostPort(String hostport) throws ParseException { - Lexer lexer = new Lexer("charLexer", hostport); - return new HostNameParser(lexer).hostPort(); - - } */ protected void processHeader(String header, SIPMessage message, ParseExceptionListener parseExceptionListener, byte[] rawMessage) throws ParseException { diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/IDeviceCache.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/IDeviceCache.java index e9963bb3..00c2407c 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/IDeviceCache.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/IDeviceCache.java @@ -8,18 +8,21 @@ import java.util.List; /** * 设备缓存 + * * @author bill */ public interface IDeviceCache { /** * 更新设备状态 + * * @param dto dto */ - public void updateDeviceStatusCache(DeviceStatusBo dto,Device device); + public void updateDeviceStatusCache(DeviceStatusBo dto, Device device); /** * 获取设备在线总数 + * * @return 设备在线总数 */ public long deviceOnlineTotal(); @@ -27,8 +30,9 @@ public interface IDeviceCache { /** * 批量更新redis缓存设备状态 + * * @param serialNumbers 设备列表 - * @param status 状态 + * @param status 状态 */ void updateBatchDeviceStatusCache(List serialNumbers, DeviceStatus status); diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/IFirmwareCache.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/IFirmwareCache.java index 64f786b1..1e0c2055 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/IFirmwareCache.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/IFirmwareCache.java @@ -2,6 +2,7 @@ package com.fastbee.iot.cache; /** * 固件版本缓存 + * * @author gsb * @date 2022/10/25 11:34 */ @@ -9,14 +10,16 @@ public interface IFirmwareCache { /** * 固件版本缓存 + * * @param firmwareId 固件ID - * @param urlName 升级URL + * @param urlName 升级URL * @return */ - public void setFirmwareCache(Long firmwareId,String urlName); + public void setFirmwareCache(Long firmwareId, String urlName); /** * 获取固件版本信息 + * * @param firmwareId 固件ID * @return 升级URL */ @@ -24,6 +27,7 @@ public interface IFirmwareCache { /** * 移除固件版本 + * * @param firmwareId 固件id */ public void remove(Long firmwareId); diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/IModbusConfigCache.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/IModbusConfigCache.java index 942d3ee3..20bfdcad 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/IModbusConfigCache.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/IModbusConfigCache.java @@ -7,6 +7,7 @@ import java.util.Map; /** * 产品对应modbus配置参数缓存 + * * @author gsb * @date 2024/6/13 9:44 */ @@ -15,32 +16,33 @@ public interface IModbusConfigCache { /** * 获取modbus参数 --返回 Map + * * @param productId - * @return - *

    - * 返回key-value - * key: 物模型标识符 - * value:ModbusConfig - *

    + * @return

    + * 返回key-value + * key: 物模型标识符 + * value:ModbusConfig + *

    */ Map> getModbusConfigCacheByProductId(Long productId); /** * 缓存modbus参数-返回Map - * @param productId - *

    - * 返回key-value - * key: 物模型标识符 - * value:ModbusConfig - *

    + * + * @param productId

    + * 返回key-value + * key: 物模型标识符 + * value:ModbusConfig + *

    */ Map> setModbusConfigCacheByProductId(Long productId); /** * 获取单个modbus参数缓存值 + * * @param productId 产品id - * @param identify 标识符 + * @param identify 标识符 * @return ModbusConfig */ public List getSingleModbusConfig(Long productId, String identify); diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/ITSLCache.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/ITSLCache.java index 31d100f1..3c512bbb 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/ITSLCache.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/ITSLCache.java @@ -7,6 +7,7 @@ import java.util.Map; /** * 物模型缓存 + * * @author gsb * @date 2024/6/12 15:57 */ @@ -15,37 +16,36 @@ public interface ITSLCache { /** * 获取JSON物模型 -组装的方式是为了兼容前端数据结构 + * * @param productId 产品id - * @return - *

    + * @return

    * { - * "functions": [ - * ], - * "events": [ - * ], - * "properties": [ - * { - * "datatype": { - * "max": 100, - * "min": 1, - * "step": 1, - * "type": "integer", - * "unit": "流明" - * }, - * "id": "light", - * "isChart": 1, - * "isHistory": 1, - * "isMonitor": 1, - * "isReadonly": 1, - * "name": "光强", - * "order": 0, - * "regId": "light", - * "type": 1 - * } - * ] + * "functions": [ + * ], + * "events": [ + * ], + * "properties": [ + * { + * "datatype": { + * "max": 100, + * "min": 1, + * "step": 1, + * "type": "integer", + * "unit": "流明" + * }, + * "id": "light", + * "isChart": 1, + * "isHistory": 1, + * "isMonitor": 1, + * "isReadonly": 1, + * "name": "光强", + * "order": 0, + * "regId": "light", + * "type": 1 + * } + * ] * } *

    - * */ String getCacheThingsModelByProductId(Long productId); @@ -65,13 +65,13 @@ public interface ITSLCache { /** * 获取map物模型 --返回 Map + * * @param productId - * @return - *

    - * 返回key-value - * key: 物模型标识符 - * value:PropertyDto - *

    + * @return

    + * 返回key-value + * key: 物模型标识符 + * value:PropertyDto + *

    */ Map getCacheThMapByProductId(Long productId); @@ -83,19 +83,20 @@ public interface ITSLCache { /** * 缓存物模型-返回Map - * @param productId - *

    - * 返回key-value - * key: 物模型标识符 - * value:PropertyDto - *

    + * + * @param productId

    + * 返回key-value + * key: 物模型标识符 + * value:PropertyDto + *

    */ public Map setCacheThMapByProductId(Long productId); /** * 获取单个物模型缓存 + * * @param productId 产品id - * @param identify 标识符 + * @param identify 标识符 * @return PropertyDto */ public ThingsModelValueItem getSingleThingModels(Long productId, String identify); diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/ITSLValueCache.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/ITSLValueCache.java index cfe0aafc..aec60571 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/ITSLValueCache.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/ITSLValueCache.java @@ -11,7 +11,6 @@ import java.util.List; public interface ITSLValueCache { - /** * 获取Redis缓存的设备物模型值 * @@ -31,19 +30,21 @@ public interface ITSLValueCache { /** * 获取单个物模型的值 + * * @param productId 产品id + * @return java.lang.String * @param: deviceNumber 设备编号 * @param: identifier 物模型标识 - * @return java.lang.String */ String getCacheIdentifierValue(Long productId, String serialNumber, String identifier); /** * 获取单个物模型的值 + * * @param productId 产品id + * @return java.lang.String * @param: deviceNumber 设备编号 * @param: identifier 物模型标识 - * @return java.lang.String */ ValueItem getCacheIdentifier(Long productId, String serialNumber, String identifier); } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/SceneModelTagCache.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/SceneModelTagCache.java index 994b0e93..a774df73 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/SceneModelTagCache.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/SceneModelTagCache.java @@ -10,14 +10,16 @@ public interface SceneModelTagCache { /** * 缓存场景运算型变量值 + * * @param sceneModelId 场景id - * @param: value 值 * @return void + * @param: value 值 */ void addSceneModelTagValue(Long sceneModelId, SceneModelTagCacheVO sceneModelTagCacheVO); /** * 获取场景运算型变量值 + * * @param sceneModelTagId 场景变量id * @return java.lang.String */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/DeviceCacheImpl.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/DeviceCacheImpl.java index 26cc1695..a7e37372 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/DeviceCacheImpl.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/DeviceCacheImpl.java @@ -39,7 +39,7 @@ public class DeviceCacheImpl implements IDeviceCache { * @param dto dto */ @Override - public void updateDeviceStatusCache(DeviceStatusBo dto,Device device) { + public void updateDeviceStatusCache(DeviceStatusBo dto, Device device) { Optional.ofNullable(device).orElseThrow(() -> new ServiceException("设备不存在" + "[{" + dto.getSerialNumber() + "}]")); if (dto.getStatus() == DeviceStatus.ONLINE) { @@ -91,7 +91,7 @@ public class DeviceCacheImpl implements IDeviceCache { * 系统停止时,更新所有设备为离线状态 */ @PreDestroy - public void resetDeviceStatus(){ + public void resetDeviceStatus() { deviceService.reSetDeviceStatus(); } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/FirmwareCacheImpl.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/FirmwareCacheImpl.java index bc8cef8f..7c640433 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/FirmwareCacheImpl.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/FirmwareCacheImpl.java @@ -11,6 +11,7 @@ import java.util.concurrent.TimeUnit; /** * 固件版本缓存 + * * @author gsb * @date 2022/10/25 11:37 */ @@ -23,33 +24,36 @@ public class FirmwareCacheImpl implements IFirmwareCache { /** * 固件版本缓存 + * * @param firmwareId 固件ID - * @param urlName 升级URL + * @param urlName 升级URL * @return */ @Override - public void setFirmwareCache(Long firmwareId,String urlName){ + public void setFirmwareCache(Long firmwareId, String urlName) { String cachedKey = RedisKeyBuilder.buildFirmwareCachedKey(firmwareId); - redisCache.setCacheObject(cachedKey,urlName,60*60*12, TimeUnit.SECONDS); + redisCache.setCacheObject(cachedKey, urlName, 60 * 60 * 12, TimeUnit.SECONDS); } /** * 获取固件版本信息 + * * @param firmwareId 固件ID * @return 升级URL */ @Override - public String getFirmwareCache(Long firmwareId){ + public String getFirmwareCache(Long firmwareId) { String cachedKey = RedisKeyBuilder.buildFirmwareCachedKey(firmwareId); return redisCache.getCacheObject(cachedKey); } /** * 移除固件版本 + * * @param firmwareId 固件id */ @Override - public void remove(Long firmwareId){ + public void remove(Long firmwareId) { String cachedKey = RedisKeyBuilder.buildFirmwareCachedKey(firmwareId); redisCache.deleteObject(cachedKey); } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/ModbusConfigCacheImpl.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/ModbusConfigCacheImpl.java index 2dde1ded..5d441339 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/ModbusConfigCacheImpl.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/ModbusConfigCacheImpl.java @@ -31,16 +31,16 @@ public class ModbusConfigCacheImpl implements IModbusConfigCache { /** * 获取modbus参数 --返回 Map + * * @param productId - * @return - *

    - * 返回key-value - * key: 物模型标识符 - * value:ModbusConfig - *

    + * @return

    + * 返回key-value + * key: 物模型标识符 + * value:ModbusConfig + *

    */ @Override - public Map> getModbusConfigCacheByProductId(Long productId){ + public Map> getModbusConfigCacheByProductId(Long productId) { // Map> resultMap = new HashMap<>(); // String modbusKey = RedisKeyBuilder.buildModbusKey(productId); // Map map = redisCache.hashEntity(modbusKey); @@ -51,21 +51,21 @@ public class ModbusConfigCacheImpl implements IModbusConfigCache { // } // return resultMap; // } - return setModbusConfigCacheByProductId(productId); + return setModbusConfigCacheByProductId(productId); } /** * 缓存modbus参数-返回Map - * @param productId - *

    - * 返回key-value - * key: 物模型标识符 - * value:ModbusConfig - *

    + * + * @param productId

    + * 返回key-value + * key: 物模型标识符 + * value:ModbusConfig + *

    */ @Override - public Map> setModbusConfigCacheByProductId(Long productId){ - Map resultMap = new HashMap<>(); + public Map> setModbusConfigCacheByProductId(Long productId) { + Map resultMap = new HashMap<>(); ModbusConfig modbusConfig = new ModbusConfig(); modbusConfig.setProductId(productId); List modbusConfigList = modbusConfigService.selectShortListByProductId(modbusConfig); @@ -73,30 +73,32 @@ public class ModbusConfigCacheImpl implements IModbusConfigCache { for (Map.Entry> entry : listMap.entrySet()) { List value = entry.getValue(); String valueStr = JSONObject.toJSONString(value); - resultMap.put(entry.getKey()+"", valueStr); + resultMap.put(entry.getKey() + "", valueStr); } String modbusKey = RedisKeyBuilder.buildModbusKey(productId); redisCache.hashPutAll(modbusKey, resultMap); return listMap; } + /** * 获取单个modbus参数缓存值 + * * @param productId 产品id - * @param address 标识符 + * @param address 标识符 * @return ModbusConfig */ @Override - public List getSingleModbusConfig(Long productId, String address){ + public List getSingleModbusConfig(Long productId, String address) { String modbusKey = RedisKeyBuilder.buildModbusKey(productId); String cacheMapValue = redisCache.getCacheMapValue(modbusKey, address); - if (!StringUtils.isEmpty(cacheMapValue)){ + if (!StringUtils.isEmpty(cacheMapValue)) { return JSON.parseArray(cacheMapValue, ModbusConfig.class); } ModbusConfig modbusConfig = new ModbusConfig(); modbusConfig.setProductId(productId); modbusConfig.setAddress(Integer.parseInt(address)); List modbusConfigList = modbusConfigService.selectShortListByProductId(modbusConfig); - if (!CollectionUtils.isEmpty(modbusConfigList)){ + if (!CollectionUtils.isEmpty(modbusConfigList)) { setModbusConfigCacheByProductId(productId); } return modbusConfigList; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/SceneModelTagCacheImpl.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/SceneModelTagCacheImpl.java index f2d4bf39..1edf1302 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/SceneModelTagCacheImpl.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/SceneModelTagCacheImpl.java @@ -12,6 +12,7 @@ import javax.annotation.Resource; /** * 物模型缓存和物模型值缓存 + * * @author gsb * @date 2024/3/22 16:37 */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/TSLCacheImpl.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/TSLCacheImpl.java index 9e5a1afa..229c36b3 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/TSLCacheImpl.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/TSLCacheImpl.java @@ -51,6 +51,44 @@ public class TSLCacheImpl implements ITSLCache { @Resource private IModbusConfigService modbusConfigService; + /** + * 将物模型名称转换为对应语言 + * + * @param item + * @param language + */ + private static void convertModelName(ThingsModelValueItem item, String language) { + switch (language) { + case EN_US: + if (StringUtils.isNotEmpty(item.getName_en_US())) { + item.setName(item.getName_en_US()); + } + break; + case ZH_CN: + if (StringUtils.isNotEmpty(item.getName_zh_CN())) { + item.setName(item.getName_zh_CN()); + } + break; + } + } + + /** + * 将物模型名称转换为对应语言 + * + * @param item + * @param language + */ + private static void convertModelName(PropertyDto item, String language) { + switch (language) { + case EN_US: + item.setName(item.getName_en_US()); + break; + case ZH_CN: + item.setName(item.getName_zh_CN()); + break; + } + } + /** * 根据产品ID获取JSON物模型 -组装的方式是为了兼容前端数据结构 * @@ -105,7 +143,6 @@ public class TSLCacheImpl implements ITSLCache { return setCacheThingsModelByProductId(productId); } - /** * 缓存物模型 -返回JSON字符串 * @@ -137,17 +174,15 @@ public class TSLCacheImpl implements ITSLCache { return jsonString; } - - /** * 获取map物模型 + * * @param productId - * @return - *

    - * 返回key-value - * key: 物模型标识符 - * value:PropertyDto - *

    + * @return

    + * 返回key-value + * key: 物模型标识符 + * value:PropertyDto + *

    */ public Map getCacheThMapByProductId(Long productId) { assert !Objects.isNull(productId) : "产品id为空"; @@ -168,7 +203,7 @@ public class TSLCacheImpl implements ITSLCache { * 获取List集合物模型 */ @Override - public List getThingsModelList(Long productId){ + public List getThingsModelList(Long productId) { Map thingsModelMap = this.getCacheThMapByProductId(productId); if (thingsModelMap != null) { for (ThingsModelValueItem item : thingsModelMap.values()) { @@ -178,15 +213,14 @@ public class TSLCacheImpl implements ITSLCache { return new ArrayList<>(thingsModelMap.values()); } - /** * 缓存物模型-返回Map - * @param productId - *

    - * 返回key-value - * key: 物模型标识符 - * value:PropertyDto - *

    + * + * @param productId

    + * 返回key-value + * key: 物模型标识符 + * value:PropertyDto + *

    */ public Map setCacheThMapByProductId(Long productId) { Map thingsModelMap = setThingModelAndModbusConfig(productId); @@ -201,12 +235,13 @@ public class TSLCacheImpl implements ITSLCache { /** * 获取单个物模型缓存值 + * * @param productId 产品id - * @param identify 标识符 + * @param identify 标识符 * @return PropertyDto */ @Override - public ThingsModelValueItem getSingleThingModels(Long productId, String identify){ + public ThingsModelValueItem getSingleThingModels(Long productId, String identify) { String cacheKey = RedisKeyBuilder.buildTSLCacheKey(productId); String itemStr; // 物模型缓存有变动,需要特殊处理一下 @@ -226,8 +261,10 @@ public class TSLCacheImpl implements ITSLCache { itemStr = redisCache.getCacheMapValue(cacheKey, substring); } } - if (StringUtils.isEmpty(itemStr)) {return null;} - ThingsModelValueItem item = JSONObject.parseObject(itemStr,ThingsModelValueItem.class); + if (StringUtils.isEmpty(itemStr)) { + return null; + } + ThingsModelValueItem item = JSONObject.parseObject(itemStr, ThingsModelValueItem.class); convertModelName(item, SecurityUtils.getLanguage()); // 处理数组、对象、数组对象 if (identifier.equals(item.getId())) { @@ -243,7 +280,6 @@ public class TSLCacheImpl implements ITSLCache { return resultItem; } - /** * 整合物模型 & 整合modbus配置参数 & redis缓存 * @@ -295,40 +331,4 @@ public class TSLCacheImpl implements ITSLCache { return thingsModelMap; } - /** - * 将物模型名称转换为对应语言 - * @param item - * @param language - */ - private static void convertModelName(ThingsModelValueItem item, String language) { - switch (language) { - case EN_US: - if (StringUtils.isNotEmpty(item.getName_en_US())){ - item.setName(item.getName_en_US()); - } - break; - case ZH_CN: - if (StringUtils.isNotEmpty(item.getName_zh_CN())){ - item.setName(item.getName_zh_CN()); - } - break; - } - } - - /** - * 将物模型名称转换为对应语言 - * @param item - * @param language - */ - private static void convertModelName(PropertyDto item, String language) { - switch (language) { - case EN_US: - item.setName(item.getName_en_US()); - break; - case ZH_CN: - item.setName(item.getName_zh_CN()); - break; - } - } - } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/TSLValueCacheImpl.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/TSLValueCacheImpl.java index 1a4c9834..c4e0bfae 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/TSLValueCacheImpl.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/cache/impl/TSLValueCacheImpl.java @@ -102,6 +102,7 @@ public class TSLValueCacheImpl implements ITSLValueCache { /** * 数组和对象类型额外处理 + * * @param maps * @param item * @param dataType diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/DeviceRecordConvert.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/DeviceRecordConvert.java index 654086e1..6dd20d78 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/DeviceRecordConvert.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/DeviceRecordConvert.java @@ -9,10 +9,10 @@ import org.mapstruct.factory.Mappers; import java.util.List; /** - * @description: 设备记录转换工具类 * @author admin - * @date 2024-07-19 16:14 * @version 1.0 + * @description: 设备记录转换工具类 + * @date 2024-07-19 16:14 */ @Mapper public interface DeviceRecordConvert { diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/FirmwareTaskConvert.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/FirmwareTaskConvert.java index 4b894f99..64fd3ad6 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/FirmwareTaskConvert.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/FirmwareTaskConvert.java @@ -8,10 +8,10 @@ import org.mapstruct.factory.Mappers; import java.util.List; /** - * @description: 网关与子产品关联对象 * @author admin - * @date 2024-07-19 16:14 * @version 1.0 + * @description: 网关与子产品关联对象 + * @date 2024-07-19 16:14 */ @Mapper public interface FirmwareTaskConvert { diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/ProductModbusJobConvert.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/ProductModbusJobConvert.java index 711b9a2f..c5ec65bf 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/ProductModbusJobConvert.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/ProductModbusJobConvert.java @@ -10,10 +10,10 @@ import org.mapstruct.factory.Mappers; import java.util.List; /** - * @description: 网关与子产品关联对象 * @author admin - * @date 2024-07-19 16:14 * @version 1.0 + * @description: 网关与子产品关联对象 + * @date 2024-07-19 16:14 */ @Mapper public interface ProductModbusJobConvert { diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/ProductSubGatewayConvert.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/ProductSubGatewayConvert.java index 223db89d..b7c6cef0 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/ProductSubGatewayConvert.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/convert/ProductSubGatewayConvert.java @@ -8,10 +8,10 @@ import org.mapstruct.factory.Mappers; import java.util.List; /** - * @description: 网关与子产品关联对象 * @author admin - * @date 2024-07-19 16:14 * @version 1.0 + * @description: 网关与子产品关联对象 + * @date 2024-07-19 16:14 */ @Mapper public interface ProductSubGatewayConvert { diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Alert.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Alert.java index ba9632f2..b67ceec7 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Alert.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Alert.java @@ -56,8 +56,14 @@ public class Alert extends BaseEntity { private List notifyTemplateList; - /** 租户id */ + /** + * 租户id + */ private Long tenantId; + /** + * 租户名称 + */ + private String tenantName; public Long getTenantId() { return tenantId; @@ -75,9 +81,6 @@ public class Alert extends BaseEntity { this.tenantName = tenantName; } - /** 租户名称 */ - private String tenantName; - public List getNotifyTemplateList() { return notifyTemplateList; } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/AlertLog.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/AlertLog.java index 07fce41b..757612fa 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/AlertLog.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/AlertLog.java @@ -14,44 +14,57 @@ import java.util.Date; * 设备告警对象 iot_alert_log * * @author kerwincui - * @date 2022-01-13 + * @date 2022-01-13 */ @Data @EqualsAndHashCode(callSuper = true) @ApiModel(value = "AlertLog", description = "设备告警日志实体 iot_alert_log") -public class AlertLog extends BaseEntity -{ +public class AlertLog extends BaseEntity { private static final long serialVersionUID = 1L; - /** 告警ID */ + /** + * 告警ID + */ @ApiModelProperty("告警ID") private Long alertLogId; - /** 告警名称 */ + /** + * 告警名称 + */ @ApiModelProperty("告警名称") @Excel(name = "告警名称") private String alertName; - /** 告警级别(1=提醒通知,2=轻微问题,3=严重警告,4=场景联动) */ + /** + * 告警级别(1=提醒通知,2=轻微问题,3=严重警告,4=场景联动) + */ @ApiModelProperty("告警级别(1=提醒通知,2=轻微问题,3=严重警告,4=场景联动)") @Excel(name = "告警级别", readConverterExp = "1==提醒通知,2=轻微问题,3=严重警告,4=场景联动") private Long alertLevel; - /** 处理状态(1=不需要处理,2=未处理,3=已处理) */ + /** + * 处理状态(1=不需要处理,2=未处理,3=已处理) + */ @ApiModelProperty("处理状态(1=不需要处理,2=未处理,3=已处理)") @Excel(name = "处理状态(1=不需要处理,2=未处理,3=已处理)") private Integer status; - /** 产品ID */ + /** + * 产品ID + */ @ApiModelProperty("产品ID") @Excel(name = "产品ID") private Long productId; - /** 设备编号 */ + /** + * 设备编号 + */ @ApiModelProperty("设备编号") private String serialNumber; - /** 告警详情 */ + /** + * 告警详情 + */ @ApiModelProperty("告警详情") private String detail; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/AlertNotifyTemplate.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/AlertNotifyTemplate.java index dc09f327..0aa50066 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/AlertNotifyTemplate.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/AlertNotifyTemplate.java @@ -7,46 +7,46 @@ import com.fastbee.common.core.domain.BaseEntity; /** * 告警通知模版关联对象 iot_alert_notify_template - * + * * @author kerwincui * @date 2024-01-29 */ -public class AlertNotifyTemplate extends BaseEntity -{ +public class AlertNotifyTemplate extends BaseEntity { private static final long serialVersionUID = 1L; - /** 告警id */ + /** + * 告警id + */ @Excel(name = "告警id") private Long alertId; - /** 通知模版id */ + /** + * 通知模版id + */ @Excel(name = "通知模版id") private Long notifyTemplateId; - public void setAlertId(Long alertId) - { + public Long getAlertId() { + return alertId; + } + + public void setAlertId(Long alertId) { this.alertId = alertId; } - public Long getAlertId() - { - return alertId; - } - public void setNotifyTemplateId(Long notifyTemplateId) - { - this.notifyTemplateId = notifyTemplateId; + public Long getNotifyTemplateId() { + return notifyTemplateId; } - public Long getNotifyTemplateId() - { - return notifyTemplateId; + public void setNotifyTemplateId(Long notifyTemplateId) { + this.notifyTemplateId = notifyTemplateId; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("alertId", getAlertId()) - .append("notifyTemplateId", getNotifyTemplateId()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("alertId", getAlertId()) + .append("notifyTemplateId", getNotifyTemplateId()) + .toString(); } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Bridge.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Bridge.java index 973f4bd8..ee94c637 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Bridge.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Bridge.java @@ -26,66 +26,94 @@ import java.util.Map; @ApiModel(value = "Bridge", description = "数据桥接 bridge") @Data -@TableName("bridge" ) -public class Bridge implements Serializable{ - private static final long serialVersionUID=1L; +@TableName("bridge") +public class Bridge implements Serializable { + private static final long serialVersionUID = 1L; - /** id唯一标识 */ + /** + * id唯一标识 + */ @TableId(value = "id", type = IdType.AUTO) @ApiModelProperty("id唯一标识") private Long id; - /** 桥接配置信息 */ + /** + * 桥接配置信息 + */ @ApiModelProperty("桥接配置信息") private String configJson; - /** 连接器名称 */ + /** + * 连接器名称 + */ @ApiModelProperty("连接器名称") private String name; - /** 是否生效(0-不生效,1-生效) */ + /** + * 是否生效(0-不生效,1-生效) + */ @ApiModelProperty("是否生效") private String enable; - /** 状态(0-未连接,1-连接中) */ + /** + * 状态(0-未连接,1-连接中) + */ @ApiModelProperty("状态") private String status; - /** 桥接类型(3=Http推送,4=Mqtt桥接,5=数据库存储) */ + /** + * 桥接类型(3=Http推送,4=Mqtt桥接,5=数据库存储) + */ @ApiModelProperty("桥接类型(3=Http推送,4=Mqtt桥接,5=数据库存储)") private Integer type; - /** 桥接方向(1=输入,2=输出) */ + /** + * 桥接方向(1=输入,2=输出) + */ @ApiModelProperty("桥接方向(1=输入,2=输出)") private Integer direction; - /** 转发路由(mqtt topic,http url) */ + /** + * 转发路由(mqtt topic,http url) + */ @ApiModelProperty("转发路由") private String route; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ @ApiModelProperty("删除标志") private String delFlag; - /** 创建者 */ + /** + * 创建者 + */ @ApiModelProperty("创建者") private String createBy; - /** 创建时间 */ + /** + * 创建时间 + */ @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("创建时间") private Date createTime; - /** 更新者 */ + /** + * 更新者 + */ @ApiModelProperty("更新者") private String updateBy; - /** 更新时间 */ + /** + * 更新时间 + */ @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("更新时间") private Date updateTime; - /** 备注 */ + /** + * 备注 + */ @ApiModelProperty("备注") private String remark; @@ -95,8 +123,8 @@ public class Bridge implements Serializable{ @JsonInclude(JsonInclude.Include.NON_EMPTY) private Map params; - public Map getParams(){ - if (params == null){ + public Map getParams() { + if (params == null) { params = new HashMap<>(); } return params; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Category.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Category.java index 7da9ef41..b53f62d5 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Category.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Category.java @@ -14,40 +14,53 @@ import com.fastbee.common.annotation.Excel; * @date 2021-12-16 */ @ApiModel(value = "Category", description = "产品分类对象 iot_category") -public class Category extends BaseEntity -{ +public class Category extends BaseEntity { private static final long serialVersionUID = 1L; - /** 产品分类ID */ + /** + * 产品分类ID + */ @ApiModelProperty("产品分类ID") private Long categoryId; - /** 产品分类名称 */ + /** + * 产品分类名称 + */ @ApiModelProperty("产品分类名称") @Excel(name = "产品分类名称") private String categoryName; - /** 租户ID */ + /** + * 租户ID + */ @ApiModelProperty("租户ID") @Excel(name = "租户ID") private Long tenantId; - /** 租户名称 */ + /** + * 租户名称 + */ @ApiModelProperty("租户名称") @Excel(name = "租户名称") private String tenantName; - /** 是否系统通用(0-否,1-是) */ + /** + * 是否系统通用(0-否,1-是) + */ @ApiModelProperty("是否系统通用(0-否,1-是)") @Excel(name = "是否系统通用", readConverterExp = "0=-否,1-是") private Integer isSys; - /** 显示顺序 */ + /** + * 显示顺序 + */ @ApiModelProperty("显示顺序") @Excel(name = "显示顺序") private Integer orderNum; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ @ApiModelProperty("删除标志(0代表存在 2代表删除)") private String delFlag; @@ -84,84 +97,77 @@ public class Category extends BaseEntity isAdmin = admin; } - public void setCategoryId(Long categoryId) - { + public Long getCategoryId() { + return categoryId; + } + + public void setCategoryId(Long categoryId) { this.categoryId = categoryId; } - public Long getCategoryId() - { - return categoryId; + public String getCategoryName() { + return categoryName; } - public void setCategoryName(String categoryName) - { + + public void setCategoryName(String categoryName) { this.categoryName = categoryName; } - public String getCategoryName() - { - return categoryName; + public Long getTenantId() { + return tenantId; } - public void setTenantId(Long tenantId) - { + + public void setTenantId(Long tenantId) { this.tenantId = tenantId; } - public Long getTenantId() - { - return tenantId; + public String getTenantName() { + return tenantName; } - public void setTenantName(String tenantName) - { + + public void setTenantName(String tenantName) { this.tenantName = tenantName; } - public String getTenantName() - { - return tenantName; - } - public void setIsSys(Integer isSys) - { - this.isSys = isSys; - } - public Integer getIsSys() - { + public Integer getIsSys() { return isSys; } - public void setOrderNum(Integer orderNum) - { - this.orderNum = orderNum; - } - public Integer getOrderNum() - { - return orderNum; - } - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; + public void setIsSys(Integer isSys) { + this.isSys = isSys; } - public String getDelFlag() - { + public Integer getOrderNum() { + return orderNum; + } + + public void setOrderNum(Integer orderNum) { + this.orderNum = orderNum; + } + + public String getDelFlag() { return delFlag; } + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } + @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("categoryId", getCategoryId()) - .append("categoryName", getCategoryName()) - .append("tenantId", getTenantId()) - .append("tenantName", getTenantName()) - .append("isSys", getIsSys()) - .append("orderNum", getOrderNum()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("categoryId", getCategoryId()) + .append("categoryName", getCategoryName()) + .append("tenantId", getTenantId()) + .append("tenantName", getTenantName()) + .append("isSys", getIsSys()) + .append("orderNum", getOrderNum()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/CommandPreferences.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/CommandPreferences.java index 2acb8749..0f05b946 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/CommandPreferences.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/CommandPreferences.java @@ -62,8 +62,8 @@ public class CommandPreferences { @JsonInclude(JsonInclude.Include.NON_EMPTY) private Map params; - public Map getParams(){ - if (params == null){ + public Map getParams() { + if (params == null) { params = new HashMap<>(); } return params; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Device.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Device.java index d9c8e5ab..3e7041b8 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Device.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Device.java @@ -29,145 +29,202 @@ import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) @Data @TableName("iot_device") -public class Device extends BaseEntity -{ +public class Device extends BaseEntity { private static final long serialVersionUID = 1L; - /** 设备ID */ + /** + * 设备ID + */ @ApiModelProperty("设备ID") private Long deviceId; - /** 设备名称 */ + /** + * 设备名称 + */ @ApiModelProperty("设备名称") @Excel(name = "设备名称") private String deviceName; - /** 产品ID */ + /** + * 产品ID + */ @ApiModelProperty("产品ID") @Excel(name = "产品ID") private Long productId; - /** 产品名称 */ + /** + * 产品名称 + */ @ApiModelProperty("产品名称") @Excel(name = "产品名称") private String productName; - /** 租户ID */ + /** + * 租户ID + */ @ApiModelProperty("租户ID") @Excel(name = "租户ID") private Long tenantId; - /** 租户名称 */ + /** + * 租户名称 + */ @ApiModelProperty("租户名称") @Excel(name = "租户名称") private String tenantName; - /** 设备编号 */ + /** + * 设备编号 + */ @ApiModelProperty("设备编号") @Excel(name = "设备编号") private String serialNumber; - /** 固件版本 */ + /** + * 固件版本 + */ @ApiModelProperty("固件版本") @Excel(name = "固件版本") private BigDecimal firmwareVersion; - /** WIFI固件版本 */ + /** + * WIFI固件版本 + */ @ApiModelProperty("HTTP推送固件版本") @Excel(name = "HTTP推送固件版本") private BigDecimal wirelessVersion; - /** 设备类型(1-直连设备、2-网关设备、3-监控设备) */ + /** + * 设备类型(1-直连设备、2-网关设备、3-监控设备) + */ @ApiModelProperty("设备类型(1-直连设备、2-网关设备、3-监控设备 4-网关子设备)") @TableField(exist = false) private Integer deviceType; - /** 设备状态(1-未激活,2-禁用,3-在线,4-离线) */ + /** + * 设备状态(1-未激活,2-禁用,3-在线,4-离线) + */ @ApiModelProperty("设备状态(1-未激活,2-禁用,3-在线,4-离线)") @Excel(name = "设备状态") private Integer status; - /** wifi信号强度(信号极好4格[-55— 0],信号好3格[-70— -55],信号一般2格[-85— -70],信号差1格[-100— -85]) */ + /** + * wifi信号强度(信号极好4格[-55— 0],信号好3格[-70— -55],信号一般2格[-85— -70],信号差1格[-100— -85]) + */ @ApiModelProperty("wifi信号强度(信号极好4格[-55— 0],信号好3格[-70— -55],信号一般2格[-85— -70],信号差1格[-100— -85])") @Excel(name = "wifi信号强度") private Integer rssi; - /** 设备影子 */ + /** + * 设备影子 + */ @ApiModelProperty("是否启用设备影子(0=禁用,1=启用)") @TableField(value = "is_shadow") private Integer isShadow; - /** 设备所在地址 */ + /** + * 设备所在地址 + */ @ApiModelProperty("设备所在地址") @Excel(name = "设备所在地址") private String networkAddress; - /** 设备入网IP */ + /** + * 设备入网IP + */ @ApiModelProperty("设备入网IP") @Excel(name = "设备入网IP") private String networkIp; - /** 设备经度 */ + /** + * 设备经度 + */ @ApiModelProperty("设备经度") @Excel(name = "设备经度") private BigDecimal longitude; - /** 设备纬度 */ + /** + * 设备纬度 + */ @ApiModelProperty("设备纬度") @Excel(name = "设备纬度") private BigDecimal latitude; - /** 激活时间 */ + /** + * 激活时间 + */ @ApiModelProperty("激活时间") @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "激活时间", width = 30, dateFormat = "yyyy-MM-dd") private Date activeTime; - /** 子设备网关编号 */ + /** + * 子设备网关编号 + */ @ApiModelProperty("子设备网关编号") @Excel(name = "网关设备编号(子设备使用)") private String gwDevCode; - /** 物模型值 */ + /** + * 物模型值 + */ @ApiModelProperty("物模型值") @Excel(name = "物模型") private String thingsModelValue; - /** 图片地址 */ + /** + * 图片地址 + */ @ApiModelProperty("图片地址") private String imgUrl; - /** 是否自定义位置 **/ + /** + * 是否自定义位置 + **/ @ApiModelProperty("定位方式(1=ip自动定位,2=设备定位,3=自定义)") private Integer locationWay; - /** 设备摘要 **/ + /** + * 设备摘要 + **/ @ApiModelProperty("设备摘要") private String summary; - /** 分组ID,用于分组查询 **/ + /** + * 分组ID,用于分组查询 + **/ @ApiModelProperty("分组ID,用于分组查询") @TableField(exist = false) private Long groupId; - /** 是否设备所有者,用于查询 **/ + /** + * 是否设备所有者,用于查询 + **/ @ApiModelProperty("是否设备所有者,用于查询") @TableField(exist = false) private Integer isOwner; - /**子设备数量*/ + /** + * 子设备数量 + */ @ApiModelProperty("子设备数量") @TableField(exist = false) private Integer subDeviceCount; - /**是否是模拟设备*/ + /** + * 是否是模拟设备 + */ @ApiModelProperty("是否是模拟设备") @TableField(value = "is_simulate") private Integer isSimulate; - /**子设备地址*/ + /** + * 子设备地址 + */ @ApiModelProperty("子设备地址") private Integer slaveId; - /**设备传输协议*/ + /** + * 设备传输协议 + */ @ApiModelProperty("设备传输协议") @TableField(exist = false) private String transport; @@ -185,7 +242,9 @@ public class Device extends BaseEntity @TableField(exist = false) private List subDeviceList; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ @ApiModelProperty("删除标志") private String delFlag; @@ -195,7 +254,7 @@ public class Device extends BaseEntity private Long userId; /** - * 协议 + * 协议 */ @TableField(exist = false) private String protocolCode; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceAlertUser.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceAlertUser.java index adb51b1f..a7aab1be 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceAlertUser.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceAlertUser.java @@ -13,13 +13,16 @@ import com.fastbee.common.core.domain.BaseEntity; * @date 2024-05-15 */ @Data -public class DeviceAlertUser -{ +public class DeviceAlertUser { - /** 设备id */ + /** + * 设备id + */ private Long deviceId; - /** 用户id */ + /** + * 用户id + */ private Long userId; private String userName; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceGroup.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceGroup.java index bf0cbb68..28ab54d6 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceGroup.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceGroup.java @@ -9,20 +9,23 @@ import org.apache.commons.lang3.builder.ToStringStyle; /** * 设备分组对象 iot_device_group - * + * * @author kerwincui * @date 2021-12-16 */ @ApiModel(value = "DeviceGroup", description = "设备分组对象 iot_device_group") -public class DeviceGroup -{ +public class DeviceGroup { private static final long serialVersionUID = 1L; - /** 分组ID */ + /** + * 分组ID + */ @ApiModelProperty("分组ID") private Long groupId; - /** 设备ID */ + /** + * 设备ID + */ @ApiModelProperty("设备ID") private Long deviceId; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceJob.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceJob.java index 68abeeac..a7cde9a8 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceJob.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceJob.java @@ -22,91 +22,126 @@ import java.util.Date; * @author kerwincui */ @ApiModel(value = "DeviceJob", description = "设备定时任务 iot_device_job") -public class DeviceJob extends BaseEntity -{ +public class DeviceJob extends BaseEntity { private static final long serialVersionUID = 1L; - /** 任务ID */ + /** + * 任务ID + */ @ApiModelProperty("任务ID") @Excel(name = "任务序号", cellType = ColumnType.NUMERIC) private Long jobId; - /** 任务名称 */ + /** + * 任务名称 + */ @ApiModelProperty("任务名称") @Excel(name = "任务名称") private String jobName; - /** 设备编号 */ + /** + * 设备编号 + */ @ApiModelProperty("设备编号") @Excel(name = "设备编号") private String serialNumber; - /** 设备id */ + /** + * 设备id + */ @ApiModelProperty("设备id") private Long deviceId; - /** 设备名称 */ + /** + * 设备名称 + */ @ApiModelProperty("设备名称") private String deviceName; - /** 执行动作 */ + /** + * 执行动作 + */ @ApiModelProperty("执行动作") private String actions; - /** 告警触发器 */ + /** + * 告警触发器 + */ @ApiModelProperty("告警触发器") private String alertTrigger; - /** 任务组名 */ + /** + * 任务组名 + */ @ApiModelProperty("任务组名") @Excel(name = "任务组名") private String jobGroup; - /** cron执行表达式 */ + /** + * cron执行表达式 + */ @ApiModelProperty("cron执行表达式") @Excel(name = "执行表达式 ") private String cronExpression; - /** cron计划策略 */ + /** + * cron计划策略 + */ @ApiModelProperty(value = "cron执行表达式", notes = "0=默认,1=立即触发执行,2=触发一次执行,3=不触发立即执行") @Excel(name = "计划策略 ", readConverterExp = "0=默认,1=立即触发执行,2=触发一次执行,3=不触发立即执行") private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT; - /** 是否并发执行(0允许 1禁止) */ + /** + * 是否并发执行(0允许 1禁止) + */ @ApiModelProperty(value = "是否并发执行", notes = "0=允许,1=禁止") @Excel(name = "并发执行", readConverterExp = "0=允许,1=禁止") private String concurrent; - /** 任务状态(0正常 1暂停) */ + /** + * 任务状态(0正常 1暂停) + */ @ApiModelProperty("任务状态(0正常 1暂停)") @Excel(name = "任务状态", readConverterExp = "0=正常,1=暂停") private String status; - /** 是否详细corn表达式 */ + /** + * 是否详细corn表达式 + */ @ApiModelProperty("是否详细corn表达式") private Integer isAdvance; - /** 定时类型(1=设备定时,2=设备告警,3=场景联动) */ + /** + * 定时类型(1=设备定时,2=设备告警,3=场景联动) + */ @ApiModelProperty(value = "定时类型", notes = "(1=设备定时,2=设备告警,3=场景联动)") @Excel(name = "定时类型", readConverterExp = "1==设备定时,2=设备告警,3=场景联动,5=modbus轮询任务") private Integer jobType; - /** 产品ID */ + /** + * 产品ID + */ @ApiModelProperty("产品ID") @Excel(name = "产品ID") private Long productId; - /** 产品名称 */ + /** + * 产品名称 + */ @ApiModelProperty("产品名称") @Excel(name = "产品名称") private String productName; - /** 场景联动ID */ + /** + * 场景联动ID + */ @ApiModelProperty("场景联动ID") @Excel(name = "场景联动ID") private Long sceneId; - /** 告警ID */ + /** + * 告警ID + */ @ApiModelProperty("告警ID") @Excel(name = "告警ID") private Long alertId; @@ -114,11 +149,14 @@ public class DeviceJob extends BaseEntity /** * 执行其他模块主键ID * 通过jobType区分 - * */ + */ @ApiModelProperty("执行其他模块主键ID") @Excel(name = "执行其他模块主键ID") private Long datasourceId; + public static long getSerialVersionUID() { + return serialVersionUID; + } public Long getDatasourceId() { return datasourceId; @@ -136,10 +174,6 @@ public class DeviceJob extends BaseEntity this.alertTrigger = alertTrigger; } - public static long getSerialVersionUID() { - return serialVersionUID; - } - public String getSerialNumber() { return serialNumber; } @@ -196,35 +230,29 @@ public class DeviceJob extends BaseEntity this.alertId = alertId; } - public Long getJobId() - { + public Long getJobId() { return jobId; } - public void setJobId(Long jobId) - { + public void setJobId(Long jobId) { this.jobId = jobId; } @NotBlank(message = "任务名称不能为空") @Size(min = 0, max = 64, message = "任务名称不能超过64个字符") - public String getJobName() - { + public String getJobName() { return jobName; } - public void setJobName(String jobName) - { + public void setJobName(String jobName) { this.jobName = jobName; } - public String getJobGroup() - { + public String getJobGroup() { return jobGroup; } - public void setJobGroup(String jobGroup) - { + public void setJobGroup(String jobGroup) { this.jobGroup = jobGroup; } @@ -254,72 +282,62 @@ public class DeviceJob extends BaseEntity @NotBlank(message = "Cron执行表达式不能为空") @Size(min = 0, max = 255, message = "Cron执行表达式不能超过255个字符") - public String getCronExpression() - { + public String getCronExpression() { return cronExpression; } - public void setCronExpression(String cronExpression) - { + public void setCronExpression(String cronExpression) { this.cronExpression = cronExpression; } @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - public Date getNextValidTime() - { - if (StringUtils.isNotEmpty(cronExpression)) - { + public Date getNextValidTime() { + if (StringUtils.isNotEmpty(cronExpression)) { return CronUtils.getNextExecution(cronExpression); } return null; } - public String getMisfirePolicy() - { + public String getMisfirePolicy() { return misfirePolicy; } - public void setMisfirePolicy(String misfirePolicy) - { + public void setMisfirePolicy(String misfirePolicy) { this.misfirePolicy = misfirePolicy; } - public String getConcurrent() - { + public String getConcurrent() { return concurrent; } - public void setConcurrent(String concurrent) - { + public void setConcurrent(String concurrent) { this.concurrent = concurrent; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("jobId", getJobId()) - .append("jobName", getJobName()) - .append("jobGroup", getJobGroup()) - .append("cronExpression", getCronExpression()) - .append("nextValidTime", getNextValidTime()) - .append("misfirePolicy", getMisfirePolicy()) - .append("concurrent", getConcurrent()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("jobId", getJobId()) + .append("jobName", getJobName()) + .append("jobGroup", getJobGroup()) + .append("cronExpression", getCronExpression()) + .append("nextValidTime", getNextValidTime()) + .append("misfirePolicy", getMisfirePolicy()) + .append("concurrent", getConcurrent()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceRecord.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceRecord.java index d02648a5..369495d8 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceRecord.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceRecord.java @@ -23,70 +23,101 @@ import lombok.experimental.Accessors; @AllArgsConstructor @NoArgsConstructor @TableName("iot_device_record") -public class DeviceRecord extends BaseEntity -{ +public class DeviceRecord extends BaseEntity { private static final long serialVersionUID = 1L; - /** 主键id */ + /** + * 主键id + */ @TableId(value = "id", type = IdType.AUTO) private Long id; - /** 操作者机构id */ + /** + * 操作者机构id + */ @Excel(name = "操作者机构id") private Long operateDeptId; - /** 目标机构id */ + /** + * 目标机构id + */ @Excel(name = "目标机构id") private Long targetDeptId; - /** 产品id */ + /** + * 产品id + */ @Excel(name = "产品id") private Long productId; - /** 设备id */ + /** + * 设备id + */ @Excel(name = "设备id") private Long deviceId; - /** 设备记录类型(1-导入记录;2-回收记录;3-分配记录;4-分配详细记录) */ + /** + * 设备记录类型(1-导入记录;2-回收记录;3-分配记录;4-分配详细记录) + */ @Excel(name = "设备记录类型", readConverterExp = "1=-导入记录;2-回收记录;3-分配记录;4-分配详细记录") private Integer type; - /** 分配类型(1-选择分配;2-导入分配) */ + /** + * 分配类型(1-选择分配;2-导入分配) + */ @Excel(name = "分配类型", readConverterExp = "1=-选择分配;2-导入分配") private Integer distributeType; - /** 总数 */ + /** + * 总数 + */ @Excel(name = "总数") private Integer total; - /** 成功数量 */ + /** + * 成功数量 + */ @Excel(name = "成功数量") private Integer successQuantity; - /** 失败数量 */ + /** + * 失败数量 + */ @Excel(name = "失败数量") private Integer failQuantity; - /** 状态 */ + /** + * 状态 + */ @Excel(name = "状态") private Integer status; - /** 租户id */ + /** + * 租户id + */ @Excel(name = "租户id") private Long tenantId; - /** 租户名称 */ + /** + * 租户名称 + */ @Excel(name = "租户名称") private String tenantName; - /** 逻辑删除标识 */ + /** + * 逻辑删除标识 + */ private Integer delFlag; - /** 设备编号 */ + /** + * 设备编号 + */ @Excel(name = "设备编号") private String serialNumber; - /** 父id */ + /** + * 父id + */ @Excel(name = "父id") private Long parentId; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceShare.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceShare.java index 83e8eba3..f718a790 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceShare.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceShare.java @@ -16,26 +16,35 @@ import org.springframework.data.annotation.Transient; @EqualsAndHashCode(callSuper = true) @Data @Accessors(chain = true) -public class DeviceShare extends BaseEntity -{ +public class DeviceShare extends BaseEntity { private static final long serialVersionUID = 1L; - /** 设备id */ + /** + * 设备id + */ @ApiModelProperty("设备ID") private Long deviceId; - /** 用户id */ + /** + * 用户id + */ private Long userId; - /** 手机 */ + /** + * 手机 + */ @Excel(name = "手机") private String phonenumber; - /** 用户物模型权限,多个以英文逗号分隔 */ + /** + * 用户物模型权限,多个以英文逗号分隔 + */ @Excel(name = "用户物模型权限,多个以英文逗号分隔") private String perms; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ private String delFlag; @Transient diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceUser.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceUser.java index 89c9d660..6fda1341 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceUser.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/DeviceUser.java @@ -21,23 +21,30 @@ import org.springframework.data.annotation.Transient; @ApiModel(value = "DeviceUser", description = "设备用户对象 iot_device_user") @Data @JsonInclude(JsonInclude.Include.NON_NULL) -public class DeviceUser extends BaseEntity -{ +public class DeviceUser extends BaseEntity { private static final long serialVersionUID = 1L; - /** 固件ID */ + /** + * 固件ID + */ @ApiModelProperty("设备ID") private Long deviceId; - /** 用户ID */ + /** + * 用户ID + */ @ApiModelProperty("用户ID") private Long userId; - /** 手机号码 */ + /** + * 手机号码 + */ @ApiModelProperty("手机号码") private String phonenumber; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ @ApiModelProperty("删除标志(0代表存在 2代表删除)") private String delFlag; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/EventLog.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/EventLog.java index 50d0f19a..6e5df767 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/EventLog.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/EventLog.java @@ -22,9 +22,9 @@ import java.util.Map; * @date 2024-08-16 */ -@ApiModel(value = "EventLog" , description = "事件日志 iot_event_log" ) +@ApiModel(value = "EventLog", description = "事件日志 iot_event_log") @Data -@TableName("iot_event_log" ) +@TableName("iot_event_log") public class EventLog { private static final long serialVersionUID = 1L; @@ -32,98 +32,98 @@ public class EventLog { /** * 设备事件日志ID */ - @TableId(value = "log_id" , type = IdType.AUTO) + @TableId(value = "log_id", type = IdType.AUTO) private Long logId; /** * 标识符 */ - @ApiModelProperty("标识符" ) + @ApiModelProperty("标识符") private String identity; /** * 物模型名称 */ - @ApiModelProperty("物模型名称" ) + @ApiModelProperty("物模型名称") private String modelName; /** * 类型(3=事件上报,5=设备上线,6=设备离线) */ - @ApiModelProperty("类型" ) + @ApiModelProperty("类型") private Integer logType; /** * 日志值 */ - @ApiModelProperty("日志值" ) + @ApiModelProperty("日志值") private String logValue; /** * 设备ID */ - @ApiModelProperty("设备ID" ) + @ApiModelProperty("设备ID") private Long deviceId; /** * 设备名称 */ - @ApiModelProperty("设备名称" ) + @ApiModelProperty("设备名称") private String deviceName; /** * 设备编号 */ - @ApiModelProperty("设备编号" ) + @ApiModelProperty("设备编号") private String serialNumber; /** * 是否监测数据(1=是,0=否) */ - @ApiModelProperty("是否监测数据" ) + @ApiModelProperty("是否监测数据") private Integer isMonitor; /** * 模式(1=影子模式,2=在线模式,3=其他) */ - @ApiModelProperty("模式(1=影子模式,2=在线模式,3=其他)" ) + @ApiModelProperty("模式(1=影子模式,2=在线模式,3=其他)") private Integer mode; /** * 用户ID */ - @ApiModelProperty("用户ID" ) + @ApiModelProperty("用户ID") private Long userId; /** * 用户昵称 */ - @ApiModelProperty("用户昵称" ) + @ApiModelProperty("用户昵称") private String userName; /** * 租户ID */ - @ApiModelProperty("租户ID" ) + @ApiModelProperty("租户ID") private Long tenantId; /** * 租户名称 */ - @ApiModelProperty("租户名称" ) + @ApiModelProperty("租户名称") private String tenantName; @@ -143,7 +143,7 @@ public class EventLog { /** * 备注 */ - @ApiModelProperty("备注" ) + @ApiModelProperty("备注") private String remark; @TableField(exist = false) @@ -155,17 +155,14 @@ public class EventLog { @JsonInclude(JsonInclude.Include.NON_EMPTY) private Map params; - public Map getParams() - { - if (params == null) - { + public Map getParams() { + if (params == null) { params = new HashMap<>(); } return params; } - public void setParams(Map params) - { + public void setParams(Map params) { this.params = params; } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Firmware.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Firmware.java index f0a0fdb9..c96b1320 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Firmware.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Firmware.java @@ -1,6 +1,7 @@ package com.fastbee.iot.domain; import java.math.BigDecimal; + import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -10,6 +11,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; + import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -21,103 +23,139 @@ import java.util.Map; * @date 2024-08-18 */ -@ApiModel(value = "Firmware" , description = "产品固件 iot_firmware" ) +@ApiModel(value = "Firmware", description = "产品固件 iot_firmware") @Data -@TableName("iot_firmware" ) +@TableName("iot_firmware") public class Firmware { -private static final long serialVersionUID=1L; + private static final long serialVersionUID = 1L; - /** 固件ID */ + /** + * 固件ID + */ @TableId(value = "firmware_id", type = IdType.AUTO) - @ApiModelProperty("固件ID" ) + @ApiModelProperty("固件ID") private Long firmwareId; - /** 固件名称 */ - @ApiModelProperty("固件名称" ) + /** + * 固件名称 + */ + @ApiModelProperty("固件名称") private String firmwareName; - /** 1,二进制包升级2.http升级 */ - @ApiModelProperty("1,二进制包升级2.http升级" ) + /** + * 1,二进制包升级2.http升级 + */ + @ApiModelProperty("1,二进制包升级2.http升级") private Integer firmwareType; - /** 产品ID */ - @ApiModelProperty("产品ID" ) + /** + * 产品ID + */ + @ApiModelProperty("产品ID") private Long productId; - /** 产品名称 */ - @ApiModelProperty("产品名称" ) + /** + * 产品名称 + */ + @ApiModelProperty("产品名称") private String productName; - /** 租户ID */ - @ApiModelProperty("租户ID" ) + /** + * 租户ID + */ + @ApiModelProperty("租户ID") private Long tenantId; - /** 租户名称 */ - @ApiModelProperty("租户名称" ) + /** + * 租户名称 + */ + @ApiModelProperty("租户名称") private String tenantName; - /** 是否系统通用(0-否,1-是) */ - @ApiModelProperty("是否系统通用" ) + /** + * 是否系统通用(0-否,1-是) + */ + @ApiModelProperty("是否系统通用") private Integer isSys; - /** 是否最新版本(0-否,1-是) */ - @ApiModelProperty("是否最新版本" ) + /** + * 是否最新版本(0-否,1-是) + */ + @ApiModelProperty("是否最新版本") private Integer isLatest; - /** 固件版本 */ - @ApiModelProperty("固件版本" ) + /** + * 固件版本 + */ + @ApiModelProperty("固件版本") private BigDecimal version; - /** 分包字节大小 */ - @ApiModelProperty("分包字节大小" ) + /** + * 分包字节大小 + */ + @ApiModelProperty("分包字节大小") private Integer byteSize; - /** 文件路径 */ - @ApiModelProperty("文件路径" ) + /** + * 文件路径 + */ + @ApiModelProperty("文件路径") private String filePath; - /** 删除标志(0代表存在 2代表删除) */ - @ApiModelProperty("删除标志" ) + /** + * 删除标志(0代表存在 2代表删除) + */ + @ApiModelProperty("删除标志") private String delFlag; - /** 创建者 */ - @ApiModelProperty("创建者" ) + /** + * 创建者 + */ + @ApiModelProperty("创建者") private String createBy; - /** 创建时间 */ - @JsonFormat(pattern = "yyyy-MM-dd" ) - @ApiModelProperty("创建时间" ) + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("创建时间") private Date createTime; - /** 更新者 */ - @ApiModelProperty("更新者" ) + /** + * 更新者 + */ + @ApiModelProperty("更新者") private String updateBy; - /** 更新时间 */ - @JsonFormat(pattern = "yyyy-MM-dd" ) - @ApiModelProperty("更新时间" ) + /** + * 更新时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("更新时间") private Date updateTime; - /** 备注 */ - @ApiModelProperty("备注" ) + /** + * 备注 + */ + @ApiModelProperty("备注") private String remark; @TableField(exist = false) @@ -125,16 +163,16 @@ private static final long serialVersionUID=1L; @JsonInclude(JsonInclude.Include.NON_EMPTY) private Map params; - public Map getParams(){ - if (params == null){ - params = new HashMap<>(); - } + public Map getParams() { + if (params == null) { + params = new HashMap<>(); + } return params; - } + } - public void setParams(Map params){ + public void setParams(Map params) { this.params = params; - } + } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/FirmwareTask.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/FirmwareTask.java index 97fd8e78..40d690d7 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/FirmwareTask.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/FirmwareTask.java @@ -1,6 +1,7 @@ package com.fastbee.iot.domain; import java.util.Date; + import com.fasterxml.jackson.annotation.JsonFormat; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; @@ -11,6 +12,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import com.fastbee.common.annotation.Excel; + import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -22,65 +24,84 @@ import java.util.Map; * @date 2024-08-18 */ -@ApiModel(value = "FirmwareTask" , description = "固件升级任务对象 iot_firmware_task" ) +@ApiModel(value = "FirmwareTask", description = "固件升级任务对象 iot_firmware_task") @Data -@TableName("iot_firmware_task" ) +@TableName("iot_firmware_task") public class FirmwareTask { -private static final long serialVersionUID=1L; + private static final long serialVersionUID = 1L; - - /** 主键 */ + /** + * 主键 + */ @TableId(value = "id", type = IdType.AUTO) - @ApiModelProperty("主键" ) + @ApiModelProperty("主键") private Long id; - /** 任务名称 */ - @ApiModelProperty("任务名称" ) + /** + * 任务名称 + */ + @ApiModelProperty("任务名称") private String taskName; - /** 关联固件ID */ - @ApiModelProperty("关联固件ID" ) + /** + * 关联固件ID + */ + @ApiModelProperty("关联固件ID") private Long firmwareId; - /** 1:指定设备 2:产品级别 */ - @ApiModelProperty("1:指定设备 2:产品级别" ) + /** + * 1:指定设备 2:产品级别 + */ + @ApiModelProperty("1:指定设备 2:产品级别") private Long upgradeType; - /** $column.columnComment */ - @ApiModelProperty("${comment}" ) + /** + * $column.columnComment + */ + @ApiModelProperty("${comment}") private String taskDesc; - /** 选中的设备总数 */ - @ApiModelProperty("选中的设备总数" ) + /** + * 选中的设备总数 + */ + @ApiModelProperty("选中的设备总数") private Long deviceAmount; - /** $column.columnComment */ - @ApiModelProperty("${comment}" ) + /** + * $column.columnComment + */ + @ApiModelProperty("${comment}") private Long delFlag; - /** $column.columnComment */ - @ApiModelProperty("${comment}" ) - @JsonFormat(pattern = "yyyy-MM-dd" ) + /** + * $column.columnComment + */ + @ApiModelProperty("${comment}") + @JsonFormat(pattern = "yyyy-MM-dd") private Date updateTime; - /** $column.columnComment */ - @ApiModelProperty("${comment}" ) - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ) + /** + * $column.columnComment + */ + @ApiModelProperty("${comment}") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; - /** 预定时间升级 */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ) - @ApiModelProperty("预定时间升级" ) + /** + * 预定时间升级 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("预定时间升级") private Date bookTime; @TableField(exist = false) @@ -88,16 +109,16 @@ private static final long serialVersionUID=1L; @JsonInclude(JsonInclude.Include.NON_EMPTY) private Map params; - public Map getParams(){ - if (params == null){ - params = new HashMap<>(); - } + public Map getParams() { + if (params == null) { + params = new HashMap<>(); + } return params; - } + } - public void setParams(Map params){ + public void setParams(Map params) { this.params = params; - } + } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/FirmwareTaskDetail.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/FirmwareTaskDetail.java index e5ca8fd0..7f7176ae 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/FirmwareTaskDetail.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/FirmwareTaskDetail.java @@ -10,6 +10,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import com.fastbee.common.annotation.Excel; + import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -21,54 +22,69 @@ import java.util.Map; * @date 2024-08-18 */ -@ApiModel(value = "FirmwareTaskDetail" , description = "固件升级任务详细对象 iot_firmware_task_detail" ) +@ApiModel(value = "FirmwareTaskDetail", description = "固件升级任务详细对象 iot_firmware_task_detail") @Data -@TableName("iot_firmware_task_detail" ) +@TableName("iot_firmware_task_detail") public class FirmwareTaskDetail { -private static final long serialVersionUID=1L; + private static final long serialVersionUID = 1L; - - /** 主键 */ + /** + * 主键 + */ @TableId(value = "id", type = IdType.AUTO) - @ApiModelProperty("主键" ) + @ApiModelProperty("主键") private Long id; - /** $column.columnComment */ - @ApiModelProperty("${comment}" ) + /** + * $column.columnComment + */ + @ApiModelProperty("${comment}") private Long taskId; - /** 设备编码 */ - @ApiModelProperty("设备编码" ) + /** + * 设备编码 + */ + @ApiModelProperty("设备编码") private String serialNumber; - /** 0:等待升级 1:已发送设备 2:设备收到 3:升级成功 4:升级失败 */ - @ApiModelProperty("0:等待升级 1:已发送设备 2:设备收到 3:升级成功 4:升级失败" ) + /** + * 0:等待升级 1:已发送设备 2:设备收到 3:升级成功 4:升级失败 + */ + @ApiModelProperty("0:等待升级 1:已发送设备 2:设备收到 3:升级成功 4:升级失败") private Integer upgradeStatus; - /** 描述 */ - @ApiModelProperty("描述" ) + /** + * 描述 + */ + @ApiModelProperty("描述") private String detailMsg; - /** $column.columnComment */ - @ApiModelProperty("${comment}" ) - @JsonFormat(pattern = "yyyy-MM-dd" ) + /** + * $column.columnComment + */ + @ApiModelProperty("${comment}") + @JsonFormat(pattern = "yyyy-MM-dd") private Date createTime; - /** 消息ID */ - @ApiModelProperty("消息ID" ) + /** + * 消息ID + */ + @ApiModelProperty("消息ID") private String messageId; - /** $column.columnComment */ - @ApiModelProperty("${comment}" ) - @JsonFormat(pattern = "yyyy-MM-dd" ) + /** + * $column.columnComment + */ + @ApiModelProperty("${comment}") + @JsonFormat(pattern = "yyyy-MM-dd") private Date updateTime; @TableField(exist = false) @@ -76,16 +92,16 @@ private static final long serialVersionUID=1L; @JsonInclude(JsonInclude.Include.NON_EMPTY) private Map params; - public Map getParams(){ - if (params == null){ - params = new HashMap<>(); - } + public Map getParams() { + if (params == null) { + params = new HashMap<>(); + } return params; - } + } - public void setParams(Map params){ + public void setParams(Map params) { this.params = params; - } + } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/FunctionLog.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/FunctionLog.java index 8f6f7140..6b2b5464 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/FunctionLog.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/FunctionLog.java @@ -23,32 +23,41 @@ import java.util.Map; */ @ApiModel(value = "FunctionLog", description = "设备服务下发日志对象 iot_function_log") @Data -public class FunctionLog -{ +public class FunctionLog { private static final long serialVersionUID = 1L; - /** 设备日志ID */ + /** + * 设备日志ID + */ @ApiModelProperty("设备日志ID") private Long id; - /** 标识符 */ + /** + * 标识符 + */ @ApiModelProperty("标识符") @Excel(name = "标识符") private String identify; - /** 仅用于查询时筛选条件 */ + /** + * 仅用于查询时筛选条件 + */ private String prefixIdentify; @ApiModelProperty("物模型名称") private String modelName; - /** 类型(1=服务下发,2=属性获取,3.OTA升级) */ + /** + * 类型(1=服务下发,2=属性获取,3.OTA升级) + */ @ApiModelProperty(value = "类型", notes = "(1=服务下发,2=属性获取,3.OTA升级,4=场景变量下发)") @Excel(name = "类型", readConverterExp = "1==服务下发,2=属性获取,3.OTA升级,4=场景变量下发") private Integer funType; - /** 日志值 */ + /** + * 日志值 + */ @ApiModelProperty("日志值") @Excel(name = "日志值") private String funValue; @@ -58,37 +67,51 @@ public class FunctionLog @ApiModelProperty("显示值") private String showValue; - /** 消息id */ + /** + * 消息id + */ @ApiModelProperty("消息id") @Excel(name = "消息id") private String messageId; - /** 设备名称 */ + /** + * 设备名称 + */ @ApiModelProperty("设备名称") @Excel(name = "设备名称") private String deviceName; - /** 设备编号 */ + /** + * 设备编号 + */ @ApiModelProperty("设备编号") @Excel(name = "设备编号") private String serialNumber; - /** 模式(1=影子模式,2=在线模式,3=其他) */ + /** + * 模式(1=影子模式,2=在线模式,3=其他) + */ @ApiModelProperty(value = "模式", notes = "(1=影子模式,2=在线模式,3=其他)") @Excel(name = "模式(1=影子模式,2=在线模式,3=其他)") private Integer mode; - /** 用户ID */ + /** + * 用户ID + */ @ApiModelProperty("用户ID") @Excel(name = "用户ID") private Long userId; - /** 下发结果描述 */ + /** + * 下发结果描述 + */ @ApiModelProperty("下发结果描述") @Excel(name = "下发结果描述") private String resultMsg; - /** 下发结果代码 */ + /** + * 下发结果代码 + */ @ApiModelProperty("下发结果代码") @Excel(name = "下发结果代码") private Integer resultCode; @@ -100,22 +123,32 @@ public class FunctionLog @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date replyTime; - /** 创建者 */ + /** + * 创建者 + */ @ApiModelProperty("创建者") private String createBy; - /** 创建时间 */ + /** + * 创建时间 + */ @ApiModelProperty("创建时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; - /** 创建时间 */ + /** + * 创建时间 + */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date beginTime; - /** 创建时间 */ + /** + * 创建时间 + */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date endTime; private List list; - /** 备注 */ + /** + * 备注 + */ private String remark; private List identifyList; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/GoviewProject.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/GoviewProject.java index 1d7d3718..9ef3f837 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/GoviewProject.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/GoviewProject.java @@ -14,42 +14,57 @@ import com.fastbee.common.core.domain.BaseEntity; * @date 2022-10-27 */ @ApiModel(value = "GoviewProject", description = "项目对象 iot_goview_project") -public class GoviewProject extends BaseEntity -{ +public class GoviewProject extends BaseEntity { private static final long serialVersionUID = 1L; - /** 主键 */ + /** + * 主键 + */ @ApiModelProperty("主键ID") private String id; - /** 项目名称 */ + /** + * 项目名称 + */ @ApiModelProperty("项目名称") @Excel(name = "项目名称") private String projectName; - /** 项目状态[-1未发布,1发布] */ + /** + * 项目状态[-1未发布,1发布] + */ @ApiModelProperty(value = "项目状态", notes = "[-1未发布,1发布]") @Excel(name = "项目状态[0未发布,1发布]") private Integer state; - /** 删除状态[1删除,-1未删除] */ + /** + * 删除状态[1删除,-1未删除] + */ @ApiModelProperty("删除状态") private Long delFlag; - /** 首页图片 */ + /** + * 首页图片 + */ @ApiModelProperty("首页图片") @Excel(name = "首页图片") private String indexImage; - /** 项目介绍 */ + /** + * 项目介绍 + */ @ApiModelProperty("项目介绍") @Excel(name = "项目介绍") private String remarks; - /** 租户id */ + /** + * 租户id + */ private Long tenantId; - /** 租户名称 */ + /** + * 租户名称 + */ private String tenantName; public Long getTenantId() { @@ -68,72 +83,65 @@ public class GoviewProject extends BaseEntity this.tenantName = tenantName; } - public void setId(String id) - { + public String getId() { + return id; + } + + public void setId(String id) { this.id = id; } - public String getId() - { - return id; + public String getProjectName() { + return projectName; } - public void setProjectName(String projectName) - { + + public void setProjectName(String projectName) { this.projectName = projectName; } - public String getProjectName() - { - return projectName; + public Integer getState() { + return state; } - public void setState(Integer state) - { + + public void setState(Integer state) { this.state = state; } - public Integer getState() - { - return state; + public Long getDelFlag() { + return delFlag; } - public void setDelFlag(Long delFlag) - { + + public void setDelFlag(Long delFlag) { this.delFlag = delFlag; } - public Long getDelFlag() - { - return delFlag; + public String getIndexImage() { + return indexImage; } - public void setIndexImage(String indexImage) - { + + public void setIndexImage(String indexImage) { this.indexImage = indexImage; } - public String getIndexImage() - { - return indexImage; - } - public void setRemarks(String remarks) - { - this.remarks = remarks; + public String getRemarks() { + return remarks; } - public String getRemarks() - { - return remarks; + public void setRemarks(String remarks) { + this.remarks = remarks; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("projectName", getProjectName()) - .append("state", getState()) - .append("createTime", getCreateTime()) - .append("createBy", getCreateBy()) - .append("delFlag", getDelFlag()) - .append("indexImage", getIndexImage()) - .append("remarks", getRemarks()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("projectName", getProjectName()) + .append("state", getState()) + .append("createTime", getCreateTime()) + .append("createBy", getCreateBy()) + .append("delFlag", getDelFlag()) + .append("indexImage", getIndexImage()) + .append("remarks", getRemarks()) + .toString(); } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/GoviewProjectData.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/GoviewProjectData.java index 851135cf..04bca37d 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/GoviewProjectData.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/GoviewProjectData.java @@ -8,7 +8,7 @@ import com.fastbee.common.core.domain.BaseEntity; /** * 项目数据关联对象 iot_goview_project_data - * + * * @author kami * @date 2022-10-27 */ @@ -17,35 +17,38 @@ public class GoviewProjectData extends BaseEntity { private static final long serialVersionUID = 1L; - /** 主键 */ + /** + * 主键 + */ @ApiModelProperty("主键ID") private String id; - /** 项目id */ + /** + * 项目id + */ @ApiModelProperty("项目id") private String projectId; - /** 存储数据 */ + /** + * 存储数据 + */ @ApiModelProperty("存储数据") private byte[] content; - public void setId(String id) - { + public String getId() { + return id; + } + + public void setId(String id) { this.id = id; } - public String getId() - { - return id; - } - public void setProjectId(String projectId) - { - this.projectId = projectId; + public String getProjectId() { + return projectId; } - public String getProjectId() - { - return projectId; + public void setProjectId(String projectId) { + this.projectId = projectId; } public byte[] getContent() { @@ -58,13 +61,13 @@ public class GoviewProjectData extends BaseEntity { @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("projectId", getProjectId()) - .append("createTime", getCreateTime()) - .append("createBy", getCreateBy()) - .append("content", getContent()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("projectId", getProjectId()) + .append("createTime", getCreateTime()) + .append("createBy", getCreateBy()) + .append("content", getContent()) + .toString(); } public String getDataToStr() { diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Group.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Group.java index 04e0f631..afee76f0 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Group.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Group.java @@ -9,112 +9,116 @@ import com.fastbee.common.core.domain.BaseEntity; /** * 设备分组对象 iot_group - * + * * @author kerwincui * @date 2021-12-16 */ @ApiModel(value = "Group", description = "设备分组对象 iot_group") -public class Group extends BaseEntity -{ +public class Group extends BaseEntity { private static final long serialVersionUID = 1L; - /** 分组ID */ + /** + * 分组ID + */ @ApiModelProperty("分组ID") private Long groupId; - /** 分组名称 */ + /** + * 分组名称 + */ @ApiModelProperty("分组名称") @Excel(name = "分组名称") private String groupName; - /** 分组排序 */ + /** + * 分组排序 + */ @ApiModelProperty("分组排序") @Excel(name = "分组排序") private Long groupOrder; - /** 用户ID */ + /** + * 用户ID + */ @ApiModelProperty("用户ID") @Excel(name = "用户ID") private Long userId; - /** 用户昵称 */ + /** + * 用户昵称 + */ @ApiModelProperty("用户昵称") @Excel(name = "用户昵称") private String userName; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ @ApiModelProperty("删除标志") private String delFlag; - public void setGroupId(Long groupId) - { + public Long getGroupId() { + return groupId; + } + + public void setGroupId(Long groupId) { this.groupId = groupId; } - public Long getGroupId() - { - return groupId; + public String getGroupName() { + return groupName; } - public void setGroupName(String groupName) - { + + public void setGroupName(String groupName) { this.groupName = groupName; } - public String getGroupName() - { - return groupName; + public Long getGroupOrder() { + return groupOrder; } - public void setGroupOrder(Long groupOrder) - { + + public void setGroupOrder(Long groupOrder) { this.groupOrder = groupOrder; } - public Long getGroupOrder() - { - return groupOrder; + public Long getUserId() { + return userId; } - public void setUserId(Long userId) - { + + public void setUserId(Long userId) { this.userId = userId; } - public Long getUserId() - { - return userId; + public String getUserName() { + return userName; } - public void setUserName(String userName) - { + + public void setUserName(String userName) { this.userName = userName; } - public String getUserName() - { - return userName; - } - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; + public String getDelFlag() { + return delFlag; } - public String getDelFlag() - { - return delFlag; + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("groupId", getGroupId()) - .append("groupName", getGroupName()) - .append("groupOrder", getGroupOrder()) - .append("userId", getUserId()) - .append("userName", getUserName()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("groupId", getGroupId()) + .append("groupName", getGroupName()) + .append("groupOrder", getGroupOrder()) + .append("userId", getUserId()) + .append("userName", getUserName()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/HttpClient.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/HttpClient.java index d364c95b..db5214c1 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/HttpClient.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/HttpClient.java @@ -11,31 +11,42 @@ import lombok.Data; * @date 2024-05-29 */ @Data -public class HttpClient extends BaseEntity -{ +public class HttpClient extends BaseEntity { private static final long serialVersionUID = 1L; - /** 请求方法 */ + /** + * 请求方法 + */ @Excel(name = "请求方法") private String method; - /** 桥接地址 */ + /** + * 桥接地址 + */ @Excel(name = "桥接地址") private String hostUrl; - /** 请求头 */ + /** + * 请求头 + */ @Excel(name = "请求头") private String requestHeaders; - /** 请求参数 */ + /** + * 请求参数 + */ @Excel(name = "请求参数") private String requestQuerys; - /** 请求参数 */ + /** + * 请求参数 + */ @Excel(name = "请求参数") private String requestConfig; - /** 请求体 */ + /** + * 请求体 + */ @Excel(name = "请求体") private String requestBody; } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ModbusConfig.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ModbusConfig.java index ccacc401..66fb898d 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ModbusConfig.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ModbusConfig.java @@ -9,45 +9,62 @@ import lombok.EqualsAndHashCode; /** * modbus配置对象 iot_modbus_config - ** @date 2024-05-22 + * * @date 2024-05-22 */ @EqualsAndHashCode(callSuper = true) @Data -public class ModbusConfig extends BaseEntity -{ +public class ModbusConfig extends BaseEntity { private static final long serialVersionUID = 1L; - /** 业务id */ + /** + * 业务id + */ private Long id; - /**所属产品id*/ + /** + * 所属产品id + */ @ApiModelProperty(value = "所属产品id") private Long productId; - /**从机地址*/ + /** + * 从机地址 + */ @ApiModelProperty(value = "从机地址") private Integer slave; - /** 关联属性 */ + /** + * 关联属性 + */ @ApiModelProperty(value = "关联属性") private String identifier; - /** 寄存器地址 */ + /** + * 寄存器地址 + */ @ApiModelProperty(value = "寄存器地址") private Integer address; - /** 是否只读(0-否,1-是) */ + /** + * 是否只读(0-否,1-是) + */ @ApiModelProperty(value = "是否只读(0-否,1-是)") private Integer isReadonly; - /** modbus数据类型 */ + /** + * modbus数据类型 + */ @ApiModelProperty(value = "modbus数据类型") private String dataType; - /** 读取个数 */ + /** + * 读取个数 + */ @ApiModelProperty(value = "读取个数") private Integer quantity; - /** 寄存器类型 1-IO寄存器 2-数据寄存器 */ + /** + * 寄存器类型 1-IO寄存器 2-数据寄存器 + */ @ApiModelProperty(value = "寄存器类型 1-IO寄存器 2-数据寄存器") private Integer type; @@ -57,7 +74,9 @@ public class ModbusConfig extends BaseEntity @ApiModelProperty(value = "排序") private Integer sort; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ private String delFlag; private ModbusCode modbusCode; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ModbusParams.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ModbusParams.java index 5e173195..623f0b60 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ModbusParams.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ModbusParams.java @@ -25,58 +25,82 @@ import java.util.Map; @ApiModel(value = "ModbusParams", description = "产品modbus配置参数 iot_modbus_params") @Data -@TableName("iot_modbus_params" ) -public class ModbusParams implements Serializable{ - private static final long serialVersionUID=1L; +@TableName("iot_modbus_params") +public class ModbusParams implements Serializable { + private static final long serialVersionUID = 1L; - /** 业务id */ + /** + * 业务id + */ @TableId(value = "id", type = IdType.AUTO) @ApiModelProperty("业务id") private Long id; - /** 产品id */ + /** + * 产品id + */ @ApiModelProperty("产品id") private Long productId; - /** 是否启动云端轮训(1-云端轮训,2-边缘采集) */ + /** + * 是否启动云端轮训(1-云端轮训,2-边缘采集) + */ @ApiModelProperty("是否启动云端轮训(0-云端轮训,1-边缘采集)") private Integer pollType; - /** 默认的子设备地址 */ + /** + * 默认的子设备地址 + */ @ApiModelProperty("默认的子设备地址") private Integer slaveId; - /** 子设备状态判断方式 1-设备数据 2- 网关 */ + /** + * 子设备状态判断方式 1-设备数据 2- 网关 + */ @ApiModelProperty("子设备状态判断方式 1-设备数据 2- 网关") private Integer statusDeter; - /** 设备数据来判断子设备状态的时长(s) */ + /** + * 设备数据来判断子设备状态的时长(s) + */ @ApiModelProperty("设备数据来判断子设备状态的时长(s)") private String deterTimer; - /** 批量读取的个数 */ + /** + * 批量读取的个数 + */ @ApiModelProperty("批量读取的个数") private Integer pollLength; - /** 创建者 */ + /** + * 创建者 + */ @ApiModelProperty("创建者") private String createBy; - /** 创建时间 */ + /** + * 创建时间 + */ @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("创建时间") private Date createTime; - /** 更新者 */ + /** + * 更新者 + */ @ApiModelProperty("更新者") private String updateBy; - /** 更新时间 */ + /** + * 更新时间 + */ @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("更新时间") private Date updateTime; - /** 备注 */ + /** + * 备注 + */ @ApiModelProperty("备注") private String remark; @@ -86,8 +110,8 @@ public class ModbusParams implements Serializable{ @JsonInclude(JsonInclude.Include.NON_EMPTY) private Map params; - public Map getParams(){ - if (params == null){ + public Map getParams() { + if (params == null) { params = new HashMap<>(); } return params; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/MqttClient.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/MqttClient.java index 27b2c0d7..4ea75262 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/MqttClient.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/MqttClient.java @@ -11,25 +11,34 @@ import com.fastbee.common.core.domain.BaseEntity; * @date 2024-06-03 */ @Data -public class MqttClient -{ - /** 连接器名称 */ +public class MqttClient { + /** + * 连接器名称 + */ @Excel(name = "连接器名称") private String name; - /** MQTT服务地址(broker.emqx.io:1883) */ + /** + * MQTT服务地址(broker.emqx.io:1883) + */ @Excel(name = "MQTT服务地址", readConverterExp = "b=roker.emqx.io:1883") private String hostUrl; - /** 用户名 */ + /** + * 用户名 + */ @Excel(name = "用户名") private String username; - /** 密码 */ + /** + * 密码 + */ @Excel(name = "密码") private String password; - /** 客户端ID */ + /** + * 客户端ID + */ @Excel(name = "客户端ID") private String clientId; } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/MultipleDataSource.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/MultipleDataSource.java index 99ae7a27..169fc338 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/MultipleDataSource.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/MultipleDataSource.java @@ -13,35 +13,48 @@ import com.fastbee.common.core.domain.BaseEntity; * @date 2024-06-17 */ @Data -public class MultipleDataSource extends BaseEntity -{ +public class MultipleDataSource extends BaseEntity { private static final long serialVersionUID = 1L; - /** 数据源 */ + /** + * 数据源 + */ @Excel(name = "数据源") private String databaseSource; - /** sql语句 */ + /** + * sql语句 + */ @Excel(name = "sql语句") private String sql; - /** 类型 */ + /** + * 类型 + */ @Excel(name = "类型") private String type; - /** 数据库名称 */ + /** + * 数据库名称 + */ @Excel(name = "数据库名称") private String dataBaseName; - /** 连接地址 */ + /** + * 连接地址 + */ @Excel(name = "连接地址") private String host; - /** 用户名 */ + /** + * 用户名 + */ @Excel(name = "用户名") private String userName; - /** 密码 */ + /** + * 密码 + */ @Excel(name = "密码") private String password; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/News.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/News.java index bbcadada..d57b3a79 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/News.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/News.java @@ -9,187 +9,196 @@ import com.fastbee.common.core.domain.BaseEntity; /** * 新闻资讯对象 news - * + * * @author kerwincui * @date 2022-04-09 */ @ApiModel(value = "News", description = "新闻资讯对象 news") -public class News extends BaseEntity -{ +public class News extends BaseEntity { private static final long serialVersionUID = 1L; - /** 新闻ID */ + /** + * 新闻ID + */ @ApiModelProperty("新闻ID") private Long newsId; - /** 标题 */ + /** + * 标题 + */ @ApiModelProperty("标题") @Excel(name = "标题") private String title; - /** 内容 */ + /** + * 内容 + */ @ApiModelProperty("内容") @Excel(name = "内容") private String content; - /** 图片 */ + /** + * 图片 + */ @ApiModelProperty("图片") @Excel(name = "图片") private String imgUrl; - /** 置顶 */ + /** + * 置顶 + */ @ApiModelProperty("是否置顶") @Excel(name = "置顶") private Integer isTop; - /** 广告 */ + /** + * 广告 + */ @ApiModelProperty("广告") @Excel(name = "广告") private Integer isBanner; - /** 分类ID */ + /** + * 分类ID + */ @ApiModelProperty("分类ID") @Excel(name = "分类ID") private Long categoryId; - /** 分类名称 */ + /** + * 分类名称 + */ @ApiModelProperty("分类名称") @Excel(name = "分类名称") private String categoryName; - /** 发布 */ + /** + * 发布 + */ @ApiModelProperty("新闻状态(0-未发布,1-已发布)") @Excel(name = "发布") private Integer status; - /** 作者 */ + /** + * 作者 + */ @ApiModelProperty("作者") @Excel(name = "作者") private String author; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ @ApiModelProperty("删除标志") private String delFlag; - public void setNewsId(Long newsId) - { + public Long getNewsId() { + return newsId; + } + + public void setNewsId(Long newsId) { this.newsId = newsId; } - public Long getNewsId() - { - return newsId; + public String getTitle() { + return title; } - public void setTitle(String title) - { + + public void setTitle(String title) { this.title = title; } - public String getTitle() - { - return title; + public String getContent() { + return content; } - public void setContent(String content) - { + + public void setContent(String content) { this.content = content; } - public String getContent() - { - return content; + public String getImgUrl() { + return imgUrl; } - public void setImgUrl(String imgUrl) - { + + public void setImgUrl(String imgUrl) { this.imgUrl = imgUrl; } - public String getImgUrl() - { - return imgUrl; + public Integer getIsTop() { + return isTop; } - public void setIsTop(Integer isTop) - { + + public void setIsTop(Integer isTop) { this.isTop = isTop; } - public Integer getIsTop() - { - return isTop; + public Integer getIsBanner() { + return isBanner; } - public void setIsBanner(Integer isBanner) - { + + public void setIsBanner(Integer isBanner) { this.isBanner = isBanner; } - public Integer getIsBanner() - { - return isBanner; + public Long getCategoryId() { + return categoryId; } - public void setCategoryId(Long categoryId) - { + + public void setCategoryId(Long categoryId) { this.categoryId = categoryId; } - public Long getCategoryId() - { - return categoryId; + public String getCategoryName() { + return categoryName; } - public void setCategoryName(String categoryName) - { + + public void setCategoryName(String categoryName) { this.categoryName = categoryName; } - public String getCategoryName() - { - return categoryName; + public Integer getStatus() { + return status; } - public void setStatus(Integer status) - { + + public void setStatus(Integer status) { this.status = status; } - public Integer getStatus() - { - return status; + public String getAuthor() { + return author; } - public void setAuthor(String author) - { + + public void setAuthor(String author) { this.author = author; } - public String getAuthor() - { - return author; - } - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; + public String getDelFlag() { + return delFlag; } - public String getDelFlag() - { - return delFlag; + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("newsId", getNewsId()) - .append("title", getTitle()) - .append("content", getContent()) - .append("imgUrl", getImgUrl()) - .append("isTop", getIsTop()) - .append("isBanner", getIsBanner()) - .append("categoryId", getCategoryId()) - .append("categoryName", getCategoryName()) - .append("status", getStatus()) - .append("author", getAuthor()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("newsId", getNewsId()) + .append("title", getTitle()) + .append("content", getContent()) + .append("imgUrl", getImgUrl()) + .append("isTop", getIsTop()) + .append("isBanner", getIsBanner()) + .append("categoryId", getCategoryId()) + .append("categoryName", getCategoryName()) + .append("status", getStatus()) + .append("author", getAuthor()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/NewsCategory.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/NewsCategory.java index dfdd8edd..941a8d6e 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/NewsCategory.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/NewsCategory.java @@ -9,83 +9,85 @@ import com.fastbee.common.core.domain.BaseEntity; /** * 新闻分类对象 news_category - * + * * @author kerwincui * @date 2022-04-09 */ @ApiModel(value = "NewsCategory", description = "新闻分类对象 news_category") -public class NewsCategory extends BaseEntity -{ +public class NewsCategory extends BaseEntity { private static final long serialVersionUID = 1L; - /** 分类ID */ + /** + * 分类ID + */ @ApiModelProperty("分类ID") @Excel(name = "分类ID") private Long categoryId; - /** 分类名字 */ + /** + * 分类名字 + */ @ApiModelProperty("分类名字") @Excel(name = "分类名字") private String categoryName; - /** 显示顺序 */ + /** + * 显示顺序 + */ @ApiModelProperty("显示顺序") @Excel(name = "显示顺序") private Integer orderNum; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ @ApiModelProperty("删除标志") private String delFlag; - public void setCategoryId(Long categoryId) - { + public Long getCategoryId() { + return categoryId; + } + + public void setCategoryId(Long categoryId) { this.categoryId = categoryId; } - public Long getCategoryId() - { - return categoryId; + public String getCategoryName() { + return categoryName; } - public void setCategoryName(String categoryName) - { + + public void setCategoryName(String categoryName) { this.categoryName = categoryName; } - public String getCategoryName() - { - return categoryName; + public Integer getOrderNum() { + return orderNum; } - public void setOrderNum(Integer orderNum) - { + + public void setOrderNum(Integer orderNum) { this.orderNum = orderNum; } - public Integer getOrderNum() - { - return orderNum; - } - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; + public String getDelFlag() { + return delFlag; } - public String getDelFlag() - { - return delFlag; + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("categoryId", getCategoryId()) - .append("categoryName", getCategoryName()) - .append("orderNum", getOrderNum()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("categoryId", getCategoryId()) + .append("categoryName", getCategoryName()) + .append("orderNum", getOrderNum()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Product.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Product.java index ecc0a7c8..506b1051 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Product.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Product.java @@ -17,58 +17,79 @@ import org.springframework.data.annotation.Transient; */ @ApiModel(value = "Product", description = "产品对象 iot_product") @JsonInclude(JsonInclude.Include.NON_NULL) -public class Product extends BaseEntity -{ +public class Product extends BaseEntity { private static final long serialVersionUID = 1L; - /** 产品ID */ + /** + * 产品ID + */ @ApiModelProperty("产品ID") private Long productId; - /** 产品名称 */ + /** + * 产品名称 + */ @ApiModelProperty("产品名称") @Excel(name = "产品名称") private String productName; - /** 产品分类ID */ + /** + * 产品分类ID + */ @ApiModelProperty("产品分类ID") @Excel(name = "产品分类ID") private Long categoryId; - /** 产品分类名称 */ + /** + * 产品分类名称 + */ @ApiModelProperty("产品分类名称") @Excel(name = "产品分类名称") private String categoryName; - /** 租户ID */ + /** + * 租户ID + */ @ApiModelProperty("租户ID") @Excel(name = "租户ID") private Long tenantId; - /** 租户名称 */ + /** + * 租户名称 + */ @ApiModelProperty("租户名称") @Excel(name = "租户名称") private String tenantName; - /** 是否私有产品(0-否,1-是)私有下级不能共享 */ + /** + * 是否私有产品(0-否,1-是)私有下级不能共享 + */ @ApiModelProperty(value = "是否私有产品", notes = "(0-否,1-是)") @Excel(name = "是否私有产品", readConverterExp = "0-否,1-是") private Integer isSys; - /** 是否启用授权码(0-否,1-是) */ + /** + * 是否启用授权码(0-否,1-是) + */ @ApiModelProperty(value = "是否启用授权码", notes = "(0-否,1-是)") @Excel(name = "是否启用授权码", readConverterExp = "0=-否,1-是") private Integer isAuthorize; - /** mqtt账号 */ + /** + * mqtt账号 + */ @ApiModelProperty("mqtt账号") private String mqttAccount; - /** mqtt密码 */ + /** + * mqtt密码 + */ @ApiModelProperty("mqtt密码") private String mqttPassword; - /** 产品秘钥 */ + /** + * 产品秘钥 + */ @ApiModelProperty("产品秘钥") private String mqttSecret; @@ -80,9 +101,73 @@ public class Product extends BaseEntity @ApiModelProperty("产品支持的传输协议,多个的选一个即可") private String transport; - /** 是否自定义位置 **/ + /** + * 是否自定义位置 + **/ @ApiModelProperty("定位方式(1=ip自动定位,2=设备定位,3=自定义)") private Integer locationWay; + /** + * 状态(1-未发布,2-已发布,不能修改) + */ + @ApiModelProperty(value = "状态", notes = "(1-未发布,2-已发布,不能修改)") + @Excel(name = "状态", readConverterExp = "1==未发布,2=已发布,不能修改") + private Integer status; + /** + * 设备类型(1-直连设备、2-网关子设备、3-网关设备) + */ + @ApiModelProperty(value = "设备类型", notes = "(1-直连设备、2-网关子设备、3-网关设备、4-网关子设备)") + @Excel(name = "设备类型", readConverterExp = "1=直连设备、2=网关设备、3=监控设备、4-网关子设备") + private Integer deviceType; + /** + * 联网方式(1=-wifi、2-蜂窝(2G/3G/4G/5G)、3-以太网、4-其他) + */ + @ApiModelProperty(value = "联网方式", notes = "(1=-wifi、2-蜂窝(2G/3G/4G/5G)、3-以太网、4-其他)") + @Excel(name = "联网方式", readConverterExp = "1=-wifi、2=蜂窝(2G/3G/4G/5G)、3=以太网、4=其他") + private Integer networkMethod; + /** + * 认证方式(1-账号密码、2-证书、3-Http) + */ + @ApiModelProperty(value = "认证方式", notes = "(1-账号密码、2-证书、3-Http)") + @Excel(name = "认证方式", readConverterExp = "1=账号密码、2=证书、3=Http") + private Integer vertificateMethod; + /** + * 图片地址 + */ + @ApiModelProperty("图片地址") + private String imgUrl; + /** + * 删除标志(0代表存在 2代表删除) + */ + @ApiModelProperty(value = "删除标志", notes = "(0代表存在 2代表删除)") + private String delFlag; + /** + * 物模型Json + **/ + @ApiModelProperty("物模型Json") + private String thingsModelsJson; + /** + * 采集点模板id + */ + @ApiModelProperty("采集点模板id") + private Long templateId; + @Transient + @ApiModelProperty("是否显示上级") + private Boolean showSenior; + @Transient + @ApiModelProperty("机构ID") + private Long deptId; + @Transient + @ApiModelProperty("是否属于本机构 1-是,0-否") + private Integer isOwner; + @Transient + private Boolean isAdmin; + @ApiModelProperty("关联组态guId") + private String guid; + /** + * 组态主键id + */ + @ApiModelProperty("关联组态id") + private Long scadaId; public String getTransport() { return transport; @@ -108,66 +193,6 @@ public class Product extends BaseEntity this.mqttSecret = mqttSecret; } - /** 状态(1-未发布,2-已发布,不能修改) */ - @ApiModelProperty(value = "状态", notes = "(1-未发布,2-已发布,不能修改)") - @Excel(name = "状态", readConverterExp = "1==未发布,2=已发布,不能修改") - private Integer status; - - /** 设备类型(1-直连设备、2-网关子设备、3-网关设备) */ - @ApiModelProperty(value = "设备类型", notes = "(1-直连设备、2-网关子设备、3-网关设备、4-网关子设备)") - @Excel(name = "设备类型", readConverterExp = "1=直连设备、2=网关设备、3=监控设备、4-网关子设备") - private Integer deviceType; - - /** 联网方式(1=-wifi、2-蜂窝(2G/3G/4G/5G)、3-以太网、4-其他) */ - @ApiModelProperty(value = "联网方式", notes = "(1=-wifi、2-蜂窝(2G/3G/4G/5G)、3-以太网、4-其他)") - @Excel(name = "联网方式", readConverterExp = "1=-wifi、2=蜂窝(2G/3G/4G/5G)、3=以太网、4=其他") - private Integer networkMethod; - - /** 认证方式(1-账号密码、2-证书、3-Http) */ - @ApiModelProperty(value = "认证方式", notes = "(1-账号密码、2-证书、3-Http)") - @Excel(name = "认证方式", readConverterExp = "1=账号密码、2=证书、3=Http") - private Integer vertificateMethod; - - /** 图片地址 */ - @ApiModelProperty("图片地址") - private String imgUrl; - - /** 删除标志(0代表存在 2代表删除) */ - @ApiModelProperty(value = "删除标志", notes = "(0代表存在 2代表删除)") - private String delFlag; - - /** 物模型Json **/ - @ApiModelProperty("物模型Json") - private String thingsModelsJson; - - /**采集点模板id*/ - @ApiModelProperty("采集点模板id") - private Long templateId; - - @Transient - @ApiModelProperty("是否显示上级") - private Boolean showSenior; - - @Transient - @ApiModelProperty("机构ID") - private Long deptId; - - @Transient - @ApiModelProperty("是否属于本机构 1-是,0-否") - private Integer isOwner; - - @Transient - private Boolean isAdmin; - - @ApiModelProperty("关联组态guId") - private String guid; - - /** - * 组态主键id - */ - @ApiModelProperty("关联组态id") - private Long scadaId; - public Long getScadaId() { return scadaId; } @@ -248,158 +273,147 @@ public class Product extends BaseEntity this.imgUrl = imgUrl; } - public void setProductId(Long productId) - { + public Long getProductId() { + return productId; + } + + public void setProductId(Long productId) { this.productId = productId; } - public Long getProductId() - { - return productId; + public String getProductName() { + return productName; } - public void setProductName(String productName) - { + + public void setProductName(String productName) { this.productName = productName; } - public String getProductName() - { - return productName; + public Long getCategoryId() { + return categoryId; } - public void setCategoryId(Long categoryId) - { + + public void setCategoryId(Long categoryId) { this.categoryId = categoryId; } - public Long getCategoryId() - { - return categoryId; + public String getCategoryName() { + return categoryName; } - public void setCategoryName(String categoryName) - { + + public void setCategoryName(String categoryName) { this.categoryName = categoryName; } - public String getCategoryName() - { - return categoryName; - } - public void setTenantId(Long tenantId) - { - this.tenantId = tenantId; - } - - public Long getTenantId() - { + public Long getTenantId() { return tenantId; } - public void setTenantName(String tenantName) - { - this.tenantName = tenantName; + public void setTenantId(Long tenantId) { + this.tenantId = tenantId; } - public String getTenantName() - { + + public String getTenantName() { return tenantName; } - public void setIsSys(Integer isSys) - { - this.isSys = isSys; + public void setTenantName(String tenantName) { + this.tenantName = tenantName; } - public Integer getIsSys() - { + + public Integer getIsSys() { return isSys; } - public void setIsAuthorize(Integer isAuthorize) {this.isAuthorize = isAuthorize;} - public Integer getIsAuthorize() {return isAuthorize;} - - public void setMqttAccount(String mqttAccount) - { - this.mqttAccount = mqttAccount; + public void setIsSys(Integer isSys) { + this.isSys = isSys; } - public String getMqttAccount() - { + + public Integer getIsAuthorize() { + return isAuthorize; + } + + public void setIsAuthorize(Integer isAuthorize) { + this.isAuthorize = isAuthorize; + } + + public String getMqttAccount() { return mqttAccount; } - public void setMqttPassword(String mqttPassword) - { - this.mqttPassword = mqttPassword; + public void setMqttAccount(String mqttAccount) { + this.mqttAccount = mqttAccount; } - public String getMqttPassword() - { + + public String getMqttPassword() { return mqttPassword; } - public void setStatus(Integer status) - { + public void setMqttPassword(String mqttPassword) { + this.mqttPassword = mqttPassword; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { this.status = status; } - public Integer getStatus() - { - return status; + public Integer getDeviceType() { + return deviceType; } - public void setDeviceType(Integer deviceType) - { + + public void setDeviceType(Integer deviceType) { this.deviceType = deviceType; } - public Integer getDeviceType() - { - return deviceType; + public Integer getNetworkMethod() { + return networkMethod; } - public void setNetworkMethod(Integer networkMethod) - { + + public void setNetworkMethod(Integer networkMethod) { this.networkMethod = networkMethod; } - public Integer getNetworkMethod() - { - return networkMethod; + public Integer getVertificateMethod() { + return vertificateMethod; } - public void setVertificateMethod(Integer vertificateMethod) - { + + public void setVertificateMethod(Integer vertificateMethod) { this.vertificateMethod = vertificateMethod; } - public Integer getVertificateMethod() - { - return vertificateMethod; - } - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; + public String getDelFlag() { + return delFlag; } - public String getDelFlag() - { - return delFlag; + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("productId", getProductId()) - .append("productName", getProductName()) - .append("categoryId", getCategoryId()) - .append("categoryName", getCategoryName()) - .append("tenantId", getTenantId()) - .append("tenantName", getTenantName()) - .append("isSys", getIsSys()) - .append("isAuthorize", getIsAuthorize()) - .append("status", getStatus()) - .append("deviceType", getDeviceType()) - .append("networkMethod", getNetworkMethod()) - .append("vertificateMethod", getVertificateMethod()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("productId", getProductId()) + .append("productName", getProductName()) + .append("categoryId", getCategoryId()) + .append("categoryName", getCategoryName()) + .append("tenantId", getTenantId()) + .append("tenantName", getTenantName()) + .append("isSys", getIsSys()) + .append("isAuthorize", getIsAuthorize()) + .append("status", getStatus()) + .append("deviceType", getDeviceType()) + .append("networkMethod", getNetworkMethod()) + .append("vertificateMethod", getVertificateMethod()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ProductAuthorize.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ProductAuthorize.java index 6a45e901..43a03f19 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ProductAuthorize.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ProductAuthorize.java @@ -9,55 +9,72 @@ import com.fastbee.common.core.domain.BaseEntity; /** * 产品授权码对象 iot_product_authorize - * + * * @author kami * @date 2022-04-11 */ @ApiModel(value = "ProductAuthorize", description = "产品授权码对象 iot_product_authorize") -public class ProductAuthorize extends BaseEntity -{ +public class ProductAuthorize extends BaseEntity { private static final long serialVersionUID = 1L; - /** 授权码ID */ + /** + * 授权码ID + */ @ApiModelProperty("授权码ID") private Long authorizeId; - /** 授权码 */ + /** + * 授权码 + */ @ApiModelProperty("授权码") @Excel(name = "授权码") private String authorizeCode; - /** 产品ID */ + /** + * 产品ID + */ @ApiModelProperty("产品ID") @Excel(name = "产品ID") private Long productId; - /** 设备ID */ + /** + * 设备ID + */ @ApiModelProperty("设备ID") @Excel(name = "设备ID") private Long deviceId; - /** 设备编号 */ + /** + * 设备编号 + */ @ApiModelProperty("设备编号") @Excel(name = "设备编号") private String serialNumber; - /** 用户ID */ + /** + * 用户ID + */ @ApiModelProperty("用户ID") @Excel(name = "用户ID") private Long userId; - /** 用户名称 */ + /** + * 用户名称 + */ @ApiModelProperty("用户名称") @Excel(name = "用户名称") private String userName; - /** 状态(1-未发布,2-已发布,不能修改) */ + /** + * 状态(1-未发布,2-已发布,不能修改) + */ @ApiModelProperty(value = "状态", notes = "(1-未发布,2-已发布,不能修改)") @Excel(name = "状态", readConverterExp = "1=未使用,2=已使用") private Integer status; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ @ApiModelProperty("删除标志") private String delFlag; @@ -69,103 +86,94 @@ public class ProductAuthorize extends BaseEntity this.productId = productId; } - public void setStatus(Integer status) - { - this.status = status; - } - public Integer getStatus() - { + public Integer getStatus() { return status; } - public void setAuthorizeId(Long authorizeId) - { + + public void setStatus(Integer status) { + this.status = status; + } + + public Long getAuthorizeId() { + return authorizeId; + } + + public void setAuthorizeId(Long authorizeId) { this.authorizeId = authorizeId; } - public Long getAuthorizeId() - { - return authorizeId; + public String getAuthorizeCode() { + return authorizeCode; } - public void setAuthorizeCode(String authorizeCode) - { + + public void setAuthorizeCode(String authorizeCode) { this.authorizeCode = authorizeCode; } - public String getAuthorizeCode() - { - return authorizeCode; + public Long getProductId() { + return productId; } - public void setProductId(Long productId) - { + + public void setProductId(Long productId) { this.productId = productId; } - public Long getProductId() - { - return productId; + public Long getDeviceId() { + return deviceId; } - public void setDeviceId(Long deviceId) - { + + public void setDeviceId(Long deviceId) { this.deviceId = deviceId; } - public Long getDeviceId() - { - return deviceId; + public String getSerialNumber() { + return serialNumber; } - public void setSerialNumber(String serialNumber) - { + + public void setSerialNumber(String serialNumber) { this.serialNumber = serialNumber; } - public String getSerialNumber() - { - return serialNumber; + public Long getUserId() { + return userId; } - public void setUserId(Long userId) - { + + public void setUserId(Long userId) { this.userId = userId; } - public Long getUserId() - { - return userId; + public String getUserName() { + return userName; } - public void setUserName(String userName) - { + + public void setUserName(String userName) { this.userName = userName; } - public String getUserName() - { - return userName; - } - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; + public String getDelFlag() { + return delFlag; } - public String getDelFlag() - { - return delFlag; + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("authorizeId", getAuthorizeId()) - .append("authorizeCode", getAuthorizeCode()) - .append("productId", getProductId()) - .append("deviceId", getDeviceId()) - .append("serialNumber", getSerialNumber()) - .append("userId", getUserId()) - .append("userName", getUserName()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("authorizeId", getAuthorizeId()) + .append("authorizeCode", getAuthorizeCode()) + .append("productId", getProductId()) + .append("deviceId", getDeviceId()) + .append("serialNumber", getSerialNumber()) + .append("userId", getUserId()) + .append("userName", getUserName()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ProductModbusJob.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ProductModbusJob.java index 78934234..96554625 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ProductModbusJob.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ProductModbusJob.java @@ -27,37 +27,51 @@ import java.util.Map; @ApiModel(value = "ProductModbusJob", description = "产品轮训任务列 iot_product_modbus_job") @Data -@TableName("iot_product_modbus_job" ) -public class ProductModbusJob implements Serializable{ - private static final long serialVersionUID=1L; +@TableName("iot_product_modbus_job") +public class ProductModbusJob implements Serializable { + private static final long serialVersionUID = 1L; - /** 任务id */ + /** + * 任务id + */ @TableId(value = "task_id", type = IdType.AUTO) @ApiModelProperty("任务id") private Long taskId; - /** 任务名称 */ + /** + * 任务名称 + */ @ApiModelProperty("任务名称") private String jobName; - /** 产品id */ + /** + * 产品id + */ @ApiModelProperty("产品id") private Long productId; - /** 指令 */ + /** + * 指令 + */ @ApiModelProperty("指令") private String command; - /** 创建者 */ + /** + * 创建者 + */ @ApiModelProperty("创建者") private String createBy; - /** 创建时间 */ + /** + * 创建时间 + */ @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("创建时间") private Date createTime; - /** 备注信息 */ + /** + * 备注信息 + */ @ApiModelProperty("备注信息") private String remark; @@ -73,8 +87,8 @@ public class ProductModbusJob implements Serializable{ @JsonInclude(JsonInclude.Include.NON_EMPTY) private Map params; - public Map getParams(){ - if (params == null){ + public Map getParams() { + if (params == null) { params = new HashMap<>(); } return params; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ProductSubGateway.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ProductSubGateway.java index 7963a7b3..61ba1a52 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ProductSubGateway.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ProductSubGateway.java @@ -26,46 +26,64 @@ import java.util.Map; @ApiModel(value = "ProductSubGateway", description = "网关与子产品关联 iot_product_sub_gateway") @Data -@TableName("iot_product_sub_gateway" ) -public class ProductSubGateway implements Serializable{ - private static final long serialVersionUID=1L; +@TableName("iot_product_sub_gateway") +public class ProductSubGateway implements Serializable { + private static final long serialVersionUID = 1L; - /** 业务id */ + /** + * 业务id + */ @TableId(value = "id", type = IdType.AUTO) @ApiModelProperty("业务id") private Long id; - /** 网关产品id */ + /** + * 网关产品id + */ @ApiModelProperty("网关产品id") private Long gwProductId; - /** 子产品id */ + /** + * 子产品id + */ @ApiModelProperty("子产品id") private Long subProductId; - /** 从机地址 */ + /** + * 从机地址 + */ @ApiModelProperty("从机地址") private Integer slaveId; - /** 创建者 */ + /** + * 创建者 + */ @ApiModelProperty("创建者") private String createBy; - /** 创建时间 */ + /** + * 创建时间 + */ @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("创建时间") private Date createTime; - /** 更新者 */ + /** + * 更新者 + */ @ApiModelProperty("更新者") private String updateBy; - /** 更新时间 */ + /** + * 更新时间 + */ @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("更新时间") private Date updateTime; - /** 备注 */ + /** + * 备注 + */ @ApiModelProperty("备注") private String remark; @@ -75,8 +93,8 @@ public class ProductSubGateway implements Serializable{ @JsonInclude(JsonInclude.Include.NON_EMPTY) private Map params; - public Map getParams(){ - if (params == null){ + public Map getParams() { + if (params == null) { params = new HashMap<>(); } return params; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Protocol.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Protocol.java index 98dfcebe..f122834d 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Protocol.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Protocol.java @@ -9,6 +9,7 @@ import java.util.Date; /** * 协议管理model + * * @author gsb * @date 2022/10/19 15:35 */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Scene.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Scene.java index ce177a05..e8a68429 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Scene.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Scene.java @@ -13,69 +13,98 @@ import java.util.List; * @date 2023-12-27 */ @Data -public class Scene extends BaseEntity -{ +public class Scene extends BaseEntity { private static final long serialVersionUID = 1L; - /** 场景ID */ + /** + * 场景ID + */ private Long sceneId; private Long recoverId; - /** 场景名称 */ + /** + * 场景名称 + */ @Excel(name = "场景名称") private String sceneName; - /** 规则名称 */ + /** + * 规则名称 + */ private String chainName; - /** 用户ID */ + /** + * 用户ID + */ @Excel(name = "用户ID") private Long userId; - /** 用户名称 */ + /** + * 用户名称 + */ @Excel(name = "用户名称") private String userName; - /** 执行条件(1=或、任一条件,2=且、所有条件,3=非,不满足) */ + /** + * 执行条件(1=或、任一条件,2=且、所有条件,3=非,不满足) + */ @Excel(name = "执行条件", readConverterExp = "1==或、任一条件,2=且、所有条件,3=非,不满足") private Integer cond; - /** 静默周期(分钟) */ + /** + * 静默周期(分钟) + */ @Excel(name = "静默周期", readConverterExp = "分=钟") private Integer silentPeriod; - /** 执行方式(1=串行,顺序执行,2=并行,同时执行) */ + /** + * 执行方式(1=串行,顺序执行,2=并行,同时执行) + */ @Excel(name = "执行方式", readConverterExp = "1==串行,顺序执行,2=并行,同时执行") private Integer executeMode; - /** 延时执行(秒钟) */ + /** + * 延时执行(秒钟) + */ @Excel(name = "延时执行", readConverterExp = "秒=钟") private Integer executeDelay; @Excel(name = "延时匹配", readConverterExp = "秒=钟") private Integer checkDelay; - /** 是否包含告警推送(1=包含,2=不包含) */ + /** + * 是否包含告警推送(1=包含,2=不包含) + */ @Excel(name = "是否包含告警推送", readConverterExp = "1==包含,2=不包含") private Integer hasAlert; - /** 场景状态(1-启动,2-停止) */ + /** + * 场景状态(1-启动,2-停止) + */ @Excel(name = "场景状态", readConverterExp = "1=-启动,2-停止") private Integer enable; - /** 规则数据 */ + /** + * 规则数据 + */ @Excel(name = "规则数据") private String elData; - /** 应用名称 */ + /** + * 应用名称 + */ @Excel(name = "应用名称") private String applicationName; - /** 接收的触发器列表 */ + /** + * 接收的触发器列表 + */ private List triggers; - /** 接收的执行动作列表 */ + /** + * 接收的执行动作列表 + */ private List actions; /** diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneDevice.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneDevice.java index ffb9ac50..7842a5db 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneDevice.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneDevice.java @@ -7,42 +7,57 @@ import com.fastbee.common.core.domain.BaseEntity; /** * 场景设备对象 iot_scene_device - * + * * @author kerwincui * @date 2023-12-28 */ -public class SceneDevice -{ +public class SceneDevice { private static final long serialVersionUID = 1L; - /** 场景设备ID */ + /** + * 场景设备ID + */ private Long sceneDeviceId; - /** 设备编号(产品触发的没有设备编号) */ + /** + * 设备编号(产品触发的没有设备编号) + */ @Excel(name = "设备编号", readConverterExp = "产=品触发的没有设备编号") private String serialNumber; - /** 产品ID */ + /** + * 产品ID + */ @Excel(name = "产品ID") private Long productId; - /** 产品ID */ + /** + * 产品ID + */ @Excel(name = "产品名称") private String productName; - /** 场景脚本ID */ + /** + * 场景脚本ID + */ @Excel(name = "场景脚本ID") private String scriptId; - /** 场景ID */ + /** + * 场景ID + */ @Excel(name = "场景ID") private Long sceneId; - /** 触发源(1=设备触发,3=产品触发) */ + /** + * 触发源(1=设备触发,3=产品触发) + */ @Excel(name = "触发源", readConverterExp = "1==设备触发,3=产品触发") private Integer source; - /** 类型(2=触发器,3=执行动作) */ + /** + * 类型(2=触发器,3=执行动作) + */ private Integer type; public Integer getType() { @@ -61,70 +76,63 @@ public class SceneDevice this.productName = productName; } - public void setSceneDeviceId(Long sceneDeviceId) - { + public Long getSceneDeviceId() { + return sceneDeviceId; + } + + public void setSceneDeviceId(Long sceneDeviceId) { this.sceneDeviceId = sceneDeviceId; } - public Long getSceneDeviceId() - { - return sceneDeviceId; + public String getSerialNumber() { + return serialNumber; } - public void setSerialNumber(String serialNumber) - { + + public void setSerialNumber(String serialNumber) { this.serialNumber = serialNumber; } - public String getSerialNumber() - { - return serialNumber; + public Long getProductId() { + return productId; } - public void setProductId(Long productId) - { + + public void setProductId(Long productId) { this.productId = productId; } - public Long getProductId() - { - return productId; + public String getScriptId() { + return scriptId; } - public void setScriptId(String scriptId) - { + + public void setScriptId(String scriptId) { this.scriptId = scriptId; } - public String getScriptId() - { - return scriptId; + public Long getSceneId() { + return sceneId; } - public void setSceneId(Long sceneId) - { + + public void setSceneId(Long sceneId) { this.sceneId = sceneId; } - public Long getSceneId() - { - return sceneId; - } - public void setSource(Integer source) - { - this.source = source; + public Integer getSource() { + return source; } - public Integer getSource() - { - return source; + public void setSource(Integer source) { + this.source = source; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("sceneDeviceId", getSceneDeviceId()) - .append("serialNumber", getSerialNumber()) - .append("productId", getProductId()) - .append("scriptId", getScriptId()) - .append("sceneId", getSceneId()) - .append("source", getSource()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("sceneDeviceId", getSceneDeviceId()) + .append("serialNumber", getSerialNumber()) + .append("productId", getProductId()) + .append("scriptId", getScriptId()) + .append("sceneId", getSceneId()) + .append("source", getSource()) + .toString(); } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModel.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModel.java index 1f6bbe2f..eedce00e 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModel.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModel.java @@ -20,34 +20,47 @@ import java.util.List; @Setter @Getter @ApiModel(value = "SceneModel", description = "场景管理") -public class SceneModel extends BaseEntity -{ +public class SceneModel extends BaseEntity { private static final long serialVersionUID = 1L; - /** 场景管理id */ + /** + * 场景管理id + */ private Long sceneModelId; - /** 所属租户id */ + /** + * 所属租户id + */ @ApiModelProperty(value = "所属租户id") private Long tenantId; - /** 场景管理名称 */ + /** + * 场景管理名称 + */ @ApiModelProperty(value = "场景管理名称") private String sceneModelName; - /** 场景状态 0-停用 1-启用 */ + /** + * 场景状态 0-停用 1-启用 + */ @ApiModelProperty(value = "场景状态 0-停用 1-启用") private Integer status; - /** 关联的组态id */ + /** + * 关联的组态id + */ @ApiModelProperty(value = "关联的组态id") private String guid; - /** 场景描述 */ + /** + * 场景描述 + */ @ApiModelProperty(value = "场景描述") private String desc; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ private String delFlag; /** @@ -92,20 +105,20 @@ public class SceneModel extends BaseEntity @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("sceneModelId", getSceneModelId()) - .append("tenantId", getTenantId()) - .append("sceneModelName", getSceneModelName()) - .append("status", getStatus()) - .append("guid", getGuid()) - .append("desc", getDesc()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("sceneModelId", getSceneModelId()) + .append("tenantId", getTenantId()) + .append("sceneModelName", getSceneModelName()) + .append("status", getStatus()) + .append("guid", getGuid()) + .append("desc", getDesc()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) .append("imgUrl", getImgUrl()) - .toString(); + .toString(); } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModelData.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModelData.java index b1a94526..9595ff51 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModelData.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModelData.java @@ -20,34 +20,47 @@ import com.fastbee.common.core.domain.BaseEntity; @EqualsAndHashCode(callSuper = true) @Data @ApiModel(value = "SceneModelData", description = "场景变量") -public class SceneModelData extends BaseEntity -{ +public class SceneModelData extends BaseEntity { private static final long serialVersionUID = 1L; - /** 主键id */ + /** + * 主键id + */ private Long id; - /** 场景管理id */ + /** + * 场景管理id + */ @ApiModelProperty(value = "场景管理id") private Long sceneModelId; - /** 场景关联数据来源id */ + /** + * 场景关联数据来源id + */ @ApiModelProperty(value = "场景关联数据来源id") private Long sceneModelDeviceId; - /** 来源类型(0设备 1录入型 2运算型) */ + /** + * 来源类型(0设备 1录入型 2运算型) + */ @ApiModelProperty(value = "来源类型(0设备 1录入型 2运算型)") private Integer variableType; - /** 数据源id */ + /** + * 数据源id + */ @ApiModelProperty(value = "物模型或变量id") private Long datasourceId; - /** 启用(0未启用 1启用) */ + /** + * 启用(0未启用 1启用) + */ @ApiModelProperty(value = "启用", notes = "0=未启用,1=启用") private Integer enable; - /** 删除标志(0代表存在 1代表删除) */ + /** + * 删除标志(0代表存在 1代表删除) + */ private String delFlag; /** diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModelDevice.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModelDevice.java index cc7b4188..62ab4433 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModelDevice.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModelDevice.java @@ -18,37 +18,52 @@ import com.fastbee.common.core.domain.BaseEntity; @EqualsAndHashCode(callSuper = true) @Data @ApiModel(value = "SceneModelDevice", description = "场景关联设备") -public class SceneModelDevice extends BaseEntity -{ +public class SceneModelDevice extends BaseEntity { private static final long serialVersionUID = 1L; - /** 主键id */ + /** + * 主键id + */ private Long id; - /** 场景id */ + /** + * 场景id + */ @ApiModelProperty(value = "场景id") private Long sceneModelId; - /** 关联设备id */ + /** + * 关联设备id + */ @ApiModelProperty(value = "关联设备id") private Long cusDeviceId; - /** 排序 */ + /** + * 排序 + */ @ApiModelProperty(value = "排序") private Integer sort; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ private String delFlag; - /** 类型(0设备 1录入型 2运算型) */ + /** + * 类型(0设备 1录入型 2运算型) + */ @ApiModelProperty(value = "类型", notes = "0=设备,1=录入型,2=运算型") private Integer variableType; - /** 全部启用(0否 1是) */ + /** + * 全部启用(0否 1是) + */ @ApiModelProperty(value = "全部启用", notes = "0=否,1=是") private Integer allEnable; - /** 名称 */ + /** + * 名称 + */ @ApiModelProperty(value = "名称") private String name; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModelTag.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModelTag.java index 894285e1..70c05c8a 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModelTag.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneModelTag.java @@ -21,65 +21,94 @@ import java.util.List; @Getter @Setter @ApiModel(value = "SceneModelTag", description = "场景录入运算变量") -public class SceneModelTag extends BaseEntity -{ +public class SceneModelTag extends BaseEntity { private static final long serialVersionUID = 1L; - /** 主键id */ + /** + * 主键id + */ private Long id; - /** 场景id */ + /** + * 场景id + */ @ApiModelProperty(value = "场景id") private Long sceneModelId; - /** 录入型变量名 */ + /** + * 录入型变量名 + */ @ApiModelProperty(value = "录入型变量名") private String name; - /** 单位 */ + /** + * 单位 + */ @ApiModelProperty(value = "单位") private String unit; - /** 数据类型 */ + /** + * 数据类型 + */ @ApiModelProperty(value = "数据类型") private String dataType; - /** 默认值 */ + /** + * 默认值 + */ @ApiModelProperty(value = "默认值") private String defaultValue; - /** 是否只读 0-否 1-是 */ + /** + * 是否只读 0-否 1-是 + */ @ApiModelProperty(value = "是否只读 0-否 1-是") private Integer isReadonly; - /** 存储方式 0-不存储 1-存储 */ + /** + * 存储方式 0-不存储 1-存储 + */ @ApiModelProperty(value = "存储方式 0-不存储 1-存储") private Integer storage; - /** 变量类型 1-运算型变量 2-输入型变量 */ + /** + * 变量类型 1-运算型变量 2-输入型变量 + */ @ApiModelProperty(value = "变量类型 1-设备物模型 2-运算型变量 3-输入型变量") private Integer variableType; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ private String delFlag; - /** 周期执行(0未执行 1执行) */ + /** + * 周期执行(0未执行 1执行) + */ @ApiModelProperty(value = "周期执行", notes = "0=未执行,1=执行") private Integer cycleExecuted; - /** 计算公式 ${id} + ${id} */ + /** + * 计算公式 ${id} + ${id} + */ @ApiModelProperty(value = "计算公式 ${id} + ${id}") private String formule; - /** 显示的计算公式 A+B */ + /** + * 显示的计算公式 A+B + */ @ApiModelProperty(value = "显示的计算公式 A+B") private String aliasFormule; - /** 时间周期方式 1-周期计算 2-自定义时间段 */ + /** + * 时间周期方式 1-周期计算 2-自定义时间段 + */ @ApiModelProperty(value = "时间周期方式 1-周期计算 2-自定义时间段") private Integer cycleType; - /** 时间周期内容 */ + /** + * 时间周期内容 + */ @ApiModelProperty(value = "时间周期内容") private String cycle; @@ -100,27 +129,27 @@ public class SceneModelTag extends BaseEntity @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("sceneModelId", getSceneModelId()) - .append("name", getName()) - .append("unit", getUnit()) - .append("dataType", getDataType()) - .append("defaultValue", getDefaultValue()) - .append("isReadonly", getIsReadonly()) - .append("storage", getStorage()) - .append("variableType", getVariableType()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .append("cycleExecuted", getCycleExecuted()) - .append("formule", getFormule()) - .append("aliasFormule", getAliasFormule()) - .append("cycleType", getCycleType()) - .append("cycle", getCycle()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("sceneModelId", getSceneModelId()) + .append("name", getName()) + .append("unit", getUnit()) + .append("dataType", getDataType()) + .append("defaultValue", getDefaultValue()) + .append("isReadonly", getIsReadonly()) + .append("storage", getStorage()) + .append("variableType", getVariableType()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("cycleExecuted", getCycleExecuted()) + .append("formule", getFormule()) + .append("aliasFormule", getAliasFormule()) + .append("cycleType", getCycleType()) + .append("cycle", getCycle()) + .toString(); } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneScript.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneScript.java index dce1631b..34b00b44 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneScript.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneScript.java @@ -13,93 +13,136 @@ import java.util.List; /** * 场景脚本对象 iot_scene_script - * + * * @author kerwincui * @date 2023-12-27 */ @ApiModel(value = "SceneScript", description = "场景脚本") -public class SceneScript -{ +public class SceneScript { private static final long serialVersionUID = 1L; - /** 场景脚本ID */ + /** + * 场景脚本ID + */ private String scriptId; - /** 脚本ID */ + /** + * 脚本ID + */ @Excel(name = "场景ID") private Long sceneId; - /** 触发源(1=设备触发,2=定时触发,3=产品触发,4=执行告警) */ + /** + * 触发源(1=设备触发,2=定时触发,3=产品触发,4=执行告警) + */ @Excel(name = "触发源", readConverterExp = "1=设备触发,2=定时触发,3=产品触发,4=执行告警") private Integer source; - /** 脚本用途(1=数据流,2=触发器,3=执行动作) */ + /** + * 脚本用途(1=数据流,2=触发器,3=执行动作) + */ private Integer scriptPurpose; - /** 物模型标识符 */ + /** + * 物模型标识符 + */ private String id; - /** 物模型名称 */ + /** + * 物模型名称 + */ @Excel(name = "物模型名称") private String name; - /** 物模型值 */ + /** + * 物模型值 + */ @Excel(name = "物模型值") private String value; - /** 操作符 */ + /** + * 操作符 + */ @Excel(name = "操作符") private String operator; - /** 物模型类别(1=属性,2=功能,3=事件,4=设备升级,5=设备上线,6=设备下线) */ + /** + * 物模型类别(1=属性,2=功能,3=事件,4=设备升级,5=设备上线,6=设备下线) + */ @Excel(name = "物模型类别", readConverterExp = "1==属性,2=功能,3=事件,4=设备升级,5=设备上线,6=设备下线") private Integer type; - /** 设备数量 */ + /** + * 设备数量 + */ @Excel(name = "设备数量") private Integer deviceCount; - /** 任务ID */ + /** + * 任务ID + */ @Excel(name = "任务ID") private Long jobId; - /** cron执行表达式 */ + /** + * cron执行表达式 + */ @Excel(name = "cron执行表达式") private String cronExpression; - /** 是否详细corn表达式(1=是,0=否) */ + /** + * 是否详细corn表达式(1=是,0=否) + */ @Excel(name = "是否详细corn表达式", readConverterExp = "1==是,0=否") private Integer isAdvance; - /** 父物模id */ + /** + * 父物模id + */ @Excel(name = "父物模id") private String parentId; - /** 父物模名称 */ + /** + * 父物模名称 + */ @Excel(name = "父物模名称") private String parentName; - /** 数组索引 */ + /** + * 数组索引 + */ @Excel(name = "数组索引") private String arrayIndex; - /** 数组索引名称(前端展示使用) */ + /** + * 数组索引名称(前端展示使用) + */ @Excel(name = "数组索引名称", readConverterExp = "前=端展示使用") private String arrayIndexName; - /** 产品ID*/ + /** + * 产品ID + */ private Long productId; - /** 产品名称*/ + /** + * 产品名称 + */ private String productName; - /** 设备编号,仅用于传递*/ + /** + * 设备编号,仅用于传递 + */ private String[] deviceNums; - /** 创建者 */ + /** + * 创建者 + */ private String createBy; - /** 创建时间 */ + /** + * 创建时间 + */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneTagPoints.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneTagPoints.java index fdaa42e2..52594e96 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneTagPoints.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SceneTagPoints.java @@ -16,38 +16,53 @@ import com.fastbee.common.core.domain.BaseEntity; */ @Getter @Setter -public class SceneTagPoints extends BaseEntity -{ +public class SceneTagPoints extends BaseEntity { private static final long serialVersionUID = 1L; - /** 运算型变量点id */ + /** + * 运算型变量点id + */ private Long id; - /** 变量点名称 */ + /** + * 变量点名称 + */ @ApiModelProperty(value = "变量点名称") private String name; - /** 点别名,如 A */ + /** + * 点别名,如 A + */ @ApiModelProperty(value = "点别名,如 A") private String alias; - /** 关联的变量id */ + /** + * 关联的变量id + */ @ApiModelProperty(value = "关联的变量id") private Long tagId; - /** 统计方式 ,用字典定义,暂时是”原值“ */ + /** + * 统计方式 ,用字典定义,暂时是”原值“ + */ @ApiModelProperty(value = "统计方式 ,用字典定义,暂时是”原值“") private Integer operation; - /** 数据来源方式 1-设备物模型 2-录入型变量 3-运算型变量 */ + /** + * 数据来源方式 1-设备物模型 2-录入型变量 3-运算型变量 + */ @ApiModelProperty(value = "数据来源方式 1-设备物模型 2-录入型变量 3-运算型变量") private Integer variableType; - /** 场景变量id */ + /** + * 场景变量id + */ @ApiModelProperty(value = "场景变量id") private Long sceneModelDataId; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ private String delFlag; /** @@ -62,20 +77,20 @@ public class SceneTagPoints extends BaseEntity @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("name", getName()) - .append("alias", getAlias()) - .append("tagId", getTagId()) - .append("operation", getOperation()) - .append("variableType", getVariableType()) - .append("sceneModelDataId", getSceneModelDataId()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("name", getName()) + .append("alias", getAlias()) + .append("tagId", getTagId()) + .append("operation", getOperation()) + .append("variableType", getVariableType()) + .append("sceneModelDataId", getSceneModelDataId()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Script.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Script.java index 7a668337..376dfcd7 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Script.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/Script.java @@ -11,70 +11,103 @@ import com.fastbee.common.core.domain.BaseEntity; * @date 2023-07-01 */ @Data -public class Script extends BaseEntity -{ +public class Script extends BaseEntity { private static final long serialVersionUID = 1L; - /** 脚本ID */ + /** + * 脚本ID + */ @Excel(name = "脚本ID") private String scriptId; - /** 用户ID */ + /** + * 用户ID + */ private Long userId; - /** 用名称 */ + /** + * 用名称 + */ private String userName; - /** 应用名 */ + /** + * 应用名 + */ @Excel(name = "应用名") private String applicationName; - /** 脚本名 */ + /** + * 脚本名 + */ @Excel(name = "脚本名") private String scriptName; - /** 脚本数据 */ + /** + * 脚本数据 + */ @Excel(name = "脚本数据") private String scriptData; - /** 脚本类型:script=普通脚本,switch_script=选择脚本,boolean_script=条件脚本,for_script=数量循环脚本 */ + /** + * 脚本类型:script=普通脚本,switch_script=选择脚本,boolean_script=条件脚本,for_script=数量循环脚本 + */ @Excel(name = "脚本类型") private String scriptType; - /** 场景ID */ + /** + * 场景ID + */ private Long sceneId; - /** 脚本类型(1=设备上报,2=平台下发,3=设备上线,4=设备离线,5=http桥接数据,6=mqtt桥接数据) */ + /** + * 脚本类型(1=设备上报,2=平台下发,3=设备上线,4=设备离线,5=http桥接数据,6=mqtt桥接数据) + */ private Integer scriptEvent; - /** 脚本动作(1=消息重发,2=消息通知,3=Http推送,4=Mqtt桥接,5=数据库存储) */ + /** + * 脚本动作(1=消息重发,2=消息通知,3=Http推送,4=Mqtt桥接,5=数据库存储) + */ private Integer scriptAction; - /** 脚本用途(1=数据流,2=触发器,3=执行动作) */ + /** + * 脚本用途(1=数据流,2=触发器,3=执行动作) + */ private Integer scriptPurpose; - /** 脚本执行顺序,值越大优先级越高 */ + /** + * 脚本执行顺序,值越大优先级越高 + */ private Integer scriptOrder; - /** 脚本语言(groovy | qlexpress | js | python | lua | aviator) */ + /** + * 脚本语言(groovy | qlexpress | js | python | lua | aviator) + */ @Excel(name = "脚本语言", readConverterExp = "groovy,qlexpress,js,python,lua,aviator") private String scriptLanguage; - /** 产品ID */ + /** + * 产品ID + */ private Long productId; - /** 产品名称 */ + /** + * 产品名称 + */ private String productName; - /**是否生效*/ + /** + * 是否生效 + */ private Integer enable; private Long bridgeId; private String bridgeName; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ private String delFlag; } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SimulateLog.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SimulateLog.java index 229ecc42..0a8466ae 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SimulateLog.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SimulateLog.java @@ -17,35 +17,46 @@ import lombok.EqualsAndHashCode; @ApiModel(value = "SimulateLog", description = "模拟设备日志对象 iot_simulate_log") @EqualsAndHashCode(callSuper = true) @Data -public class SimulateLog extends BaseEntity -{ +public class SimulateLog extends BaseEntity { private static final long serialVersionUID = 1L; - /** ID */ + /** + * ID + */ @ApiModelProperty("主键ID") private Long logId; - /** 云端发送指令 */ + /** + * 云端发送指令 + */ @ApiModelProperty("云端发送指令") @Excel(name = "云端发送指令") private String sendData; - /** 设备回复 */ + /** + * 设备回复 + */ @ApiModelProperty("设备回复") @Excel(name = "设备回复") private String callbackData; - /** 设备ID */ + /** + * 设备ID + */ @ApiModelProperty("设备ID") @Excel(name = "设备ID") private Long deviceId; - /** 设备名称 */ + /** + * 设备名称 + */ @ApiModelProperty("设备名称") @Excel(name = "设备名称") private String deviceName; - /** 设备编号 */ + /** + * 设备编号 + */ @ApiModelProperty("设备编号") @Excel(name = "设备编号") private String serialNumber; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SocialUser.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SocialUser.java index bcc51187..150227eb 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SocialUser.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SocialUser.java @@ -20,140 +20,191 @@ import com.fastbee.common.core.domain.BaseEntity; @ApiModel(value = "SocialUser", description = "用户第三方用户信息对象 iot_social_user") @Accessors(chain = true) @Data -public class SocialUser extends BaseEntity -{ +public class SocialUser extends BaseEntity { private static final long serialVersionUID = 1L; - /** 第三方系统用户表主键 */ + /** + * 第三方系统用户表主键 + */ @ApiModelProperty("第三方系统用户表主键") private Long socialUserId; - /** 第三方系统的唯一ID */ + /** + * 第三方系统的唯一ID + */ @ApiModelProperty("第三方系统的唯一ID") @Excel(name = "第三方系统的唯一ID") private String uuid; - /** 第三方用户来源 */ + /** + * 第三方用户来源 + */ @ApiModelProperty("第三方用户来源") @Excel(name = "第三方用户来源") private String source; - /** 用户的授权令牌 */ + /** + * 用户的授权令牌 + */ @ApiModelProperty("用户的授权令牌") @Excel(name = "用户的授权令牌") private String accessToken; - /** 第三方用户的授权令牌的有效期(部分平台可能没有) */ + /** + * 第三方用户的授权令牌的有效期(部分平台可能没有) + */ @ApiModelProperty(value = "第三方用户的授权令牌的有效期", notes = "(部分平台可能没有)") @Excel(name = "第三方用户的授权令牌的有效期", readConverterExp = "部=分平台可能没有") private Long expireIn; - /** 刷新令牌(部分平台可能没有) */ + /** + * 刷新令牌(部分平台可能没有) + */ @ApiModelProperty(value = "刷新令牌", notes = "(部分平台可能没有)") @Excel(name = "刷新令牌(部分平台可能没有)") private String refreshToken; - /** 第三方用户的 open id(部分平台可能没有) */ + /** + * 第三方用户的 open id(部分平台可能没有) + */ @ApiModelProperty(value = "第三方用户的 open id", notes = "(部分平台可能没有)") @Excel(name = "第三方用户的 open id", readConverterExp = "部=分平台可能没有") private String openId; - /** 第三方用户的 ID(部分平台可能没有) */ + /** + * 第三方用户的 ID(部分平台可能没有) + */ @ApiModelProperty(value = "第三方用户的 ID", notes = "(部分平台可能没有)") @Excel(name = "第三方用户的 ID(部分平台可能没有)") private String uid; - /** 个别平台的授权信息(部分平台可能没有) */ + /** + * 个别平台的授权信息(部分平台可能没有) + */ @ApiModelProperty(value = "个别平台的授权信息", notes = "(部分平台可能没有)") @Excel(name = "个别平台的授权信息", readConverterExp = "部=分平台可能没有") private String accessCode; - /** 第三方用户的 union id(部分平台可能没有) */ + /** + * 第三方用户的 union id(部分平台可能没有) + */ @ApiModelProperty(value = "第三方用户的 union id", notes = "(部分平台可能没有)") @Excel(name = "第三方用户的 union id(部分平台可能没有)") private String unionId; - /** 第三方用户授予的权限(部分平台可能没有) */ + /** + * 第三方用户授予的权限(部分平台可能没有) + */ @ApiModelProperty(value = "第三方用户授予的权限", notes = "(部分平台可能没有)") @Excel(name = "第三方用户授予的权限(部分平台可能没有)") private String scope; - /** 个别平台的授权信息(部分平台可能没有) */ + /** + * 个别平台的授权信息(部分平台可能没有) + */ @ApiModelProperty(value = "个别平台的授权信息", notes = "(部分平台可能没有)") @Excel(name = "个别平台的授权信息", readConverterExp = "部=分平台可能没有") private String tokenType; - /** id token(部分平台可能没有) */ + /** + * id token(部分平台可能没有) + */ @ApiModelProperty(value = "id token", notes = "(部分平台可能没有)") @Excel(name = "id token", readConverterExp = "部=分平台可能没有") private String idToken; - /** 小米平台用户的附带属性(部分平台可能没有) */ + /** + * 小米平台用户的附带属性(部分平台可能没有) + */ @ApiModelProperty(value = "小米平台用户的附带属性", notes = "(部分平台可能没有)") @Excel(name = "小米平台用户的附带属性", readConverterExp = "部=分平台可能没有") private String macAlgorithm; - /** 小米平台用户的附带属性(部分平台可能没有) */ + /** + * 小米平台用户的附带属性(部分平台可能没有) + */ @ApiModelProperty(value = "小米平台用户的附带属性", notes = "(部分平台可能没有) ") @Excel(name = "小米平台用户的附带属性(部分平台可能没有)") private String macKey; - /** 用户的授权code(部分平台可能没有) */ + /** + * 用户的授权code(部分平台可能没有) + */ @ApiModelProperty(value = "用户的授权code", notes = "(部分平台可能没有)") @Excel(name = "用户的授权code", readConverterExp = "部=分平台可能没有") private String code; - /** Twitter平台用户的附带属性(部分平台可能没有) */ + /** + * Twitter平台用户的附带属性(部分平台可能没有) + */ @ApiModelProperty(value = "Twitter平台用户的附带属性", notes = "(部分平台可能没有) ") @Excel(name = "Twitter平台用户的附带属性(部分平台可能没有)") private String oauthToken; - /** Twitter平台用户的附带属性(部分平台可能没有) */ + /** + * Twitter平台用户的附带属性(部分平台可能没有) + */ @ApiModelProperty(value = "Twitter平台用户的附带属性", notes = "(部分平台可能没有)") @Excel(name = "Twitter平台用户的附带属性(部分平台可能没有)") private String oauthTokenSecret; - /** 删除标记位(0代表存在,2代表删除) */ + /** + * 删除标记位(0代表存在,2代表删除) + */ @ApiModelProperty("删除标记位") private String delFlag; - /** 绑定状态(0:未绑定,1:绑定) */ + /** + * 绑定状态(0:未绑定,1:绑定) + */ @ApiModelProperty(value = "绑定状态", notes = "(0:未绑定,1:绑定)") @Excel(name = "绑定状态(0:未绑定,1:绑定)") private String status; - /** 用户ID */ + /** + * 用户ID + */ @ApiModelProperty("用户ID") @Excel(name = "用户ID") private Long sysUserId; - /** 用户名 */ + /** + * 用户名 + */ @ApiModelProperty("用户名") @Excel(name = "用户名") private String username; - /** 用户昵称 */ + /** + * 用户昵称 + */ @ApiModelProperty("用户昵称") @Excel(name = "用户昵称") private String nickname; - /** 用户头像 */ + /** + * 用户头像 + */ @ApiModelProperty("用户头像") @Excel(name = "用户头像") private String avatar; - /** 用户性别 */ + /** + * 用户性别 + */ @ApiModelProperty("用户性别") @Excel(name = "用户性别") private Integer gender; - /** 三方登录具体来源 */ + /** + * 三方登录具体来源 + */ @ApiModelProperty("三方登录具体来源") @Excel(name = "三方登录具体来源") private String sourceClient; @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) .append("socialUserId", getSocialUserId()) .append("uuid", getUuid()) .append("source", getSource()) diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SubGateway.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SubGateway.java index f2b6f124..0a7b5ca0 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SubGateway.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/SubGateway.java @@ -14,24 +14,31 @@ import lombok.EqualsAndHashCode; */ @EqualsAndHashCode(callSuper = true) @Data -public class SubGateway extends BaseEntity -{ +public class SubGateway extends BaseEntity { private static final long serialVersionUID = 1L; - /** 业务id */ + /** + * 业务id + */ private Long id; - /** 网关设备id */ + /** + * 网关设备id + */ @Excel(name = "网关设备id") @ApiModelProperty("网关设备id") private Long gwDeviceId; - /** 子设备id */ + /** + * 子设备id + */ @Excel(name = "子设备id") @ApiModelProperty("子设备id") private Long subDeviceId; - /** 从机地址 */ + /** + * 从机地址 + */ @Excel(name = "从机地址") @ApiModelProperty("从机地址") private Integer slaveId; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ThingsModel.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ThingsModel.java index 0668351d..6e12da96 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ThingsModel.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ThingsModel.java @@ -22,96 +22,133 @@ import java.util.List; @ApiModel(value = "ThingsModel", description = "物模型对象 iot_things_model") @JsonInclude(JsonInclude.Include.NON_NULL) @Data -public class ThingsModel extends BaseEntity -{ +public class ThingsModel extends BaseEntity { private static final long serialVersionUID = 1L; - /** 物模型ID */ + /** + * 物模型ID + */ @ApiModelProperty("物模型ID") private Long modelId; - /** 物模型名称 */ + /** + * 物模型名称 + */ @ApiModelProperty("物模型名称") - @Excel(name = "物模型名称" ,prompt = "必填") + @Excel(name = "物模型名称", prompt = "必填") private String modelName; - /** 物模型名称 */ + /** + * 物模型名称 + */ @ApiModelProperty("中文物模型名称_中文") private String modelName_zh_CN; - /** 物模型名称 */ + /** + * 物模型名称 + */ @ApiModelProperty("英文物模型名称") private String modelName_en_US; - /** 产品ID */ + /** + * 产品ID + */ @ApiModelProperty("产品ID") private Long productId; - /** 产品名称 */ + /** + * 产品名称 + */ @ApiModelProperty("产品名称") private String productName; - /** 租户ID */ + /** + * 租户ID + */ @ApiModelProperty("租户ID") private Long tenantId; - /** 租户名称 */ + /** + * 租户名称 + */ @ApiModelProperty("租户名称") private String tenantName; - /** 标识符,产品下唯一 */ + /** + * 标识符,产品下唯一 + */ @ApiModelProperty("标识符,产品下唯一") - @Excel(name = "标识符",prompt = "modbus不填默认为寄存器地址") + @Excel(name = "标识符", prompt = "modbus不填默认为寄存器地址") private String identifier; - /** 模型类别(1-属性,2-功能,3-事件) */ + /** + * 模型类别(1-属性,2-功能,3-事件) + */ @ApiModelProperty(value = "模型类别", notes = "(1-属性,2-功能,3-事件)") - @Excel(name = "模型类别", prompt ="1=属性,2-功能,3-事件") + @Excel(name = "模型类别", prompt = "1=属性,2-功能,3-事件") private Integer type; - /** 计算公式 */ + /** + * 计算公式 + */ @ApiModelProperty("计算公式") - @Excel(name = "计算公式",prompt = "选填,例如:%s*10,%s是占位符") + @Excel(name = "计算公式", prompt = "选填,例如:%s*10,%s是占位符") private String formula; - /** 数据定义 */ + /** + * 数据定义 + */ //@Excel(name = "数据定义") @ApiModelProperty("数据定义") private String specs; - /** 是否图表显示(0-否,1-是) */ + /** + * 是否图表显示(0-否,1-是) + */ @ApiModelProperty(value = "是否图表显示", notes = "(0-否,1-是)") @Excel(name = "是否图表显示", readConverterExp = "0=否,1=是") private Integer isChart; - /** 是否历史存储(0-否,1-是) */ + /** + * 是否历史存储(0-否,1-是) + */ @ApiModelProperty(value = "是否历史存储", notes = "(0-否,1-是)") @Excel(name = "是否历史存储", readConverterExp = "0=否,1=是") private Integer isHistory; - /** 是否实时监测(0-否,1-是) */ + /** + * 是否实时监测(0-否,1-是) + */ @ApiModelProperty(value = "是否实时监测", notes = "(0-否,1-是) ") @Excel(name = "是否实时监测", readConverterExp = "0=否,1=是") private Integer isMonitor; - /** 是否分享设备权限(0-否,1-是) */ + /** + * 是否分享设备权限(0-否,1-是) + */ @ApiModelProperty(value = "是否分享设备权限", notes = "(0-否,1-是) ") private Integer isSharePerm; - /** 是否分享设备权限(0-否,1-是) */ + /** + * 是否分享设备权限(0-否,1-是) + */ @ApiModelProperty(value = "是否分享设备权限", notes = "(0-否,1-是) ") @Excel(name = "是否分享设备权限", readConverterExp = "0=否,1=是") private Integer isApp; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ @ApiModelProperty("删除标志") private String delFlag; @Excel(name = "单位") private String unit; - /** 数据类型(integer、decimal、string、bool、array、enum) */ + /** + * 数据类型(integer、decimal、string、bool、array、enum) + */ @ApiModelProperty(value = "数据类型", notes = "(integer、decimal、string、bool、array、enum)") @Excel(name = "数据类型", prompt = "integer、decimal、string、bool、array、enum") private String datatype; @@ -119,7 +156,9 @@ public class ThingsModel extends BaseEntity @Excel(name = "有效值范围") private String limitValue; - /** 是否只读数据(0-否,1-是) */ + /** + * 是否只读数据(0-否,1-是) + */ @ApiModelProperty(value = "是否只读数据", notes = "(0-否,1-是)") @Excel(name = "是否只读", prompt = "0=否,1=是") private Integer isReadonly; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ThingsModelJsonTemplate.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ThingsModelJsonTemplate.java index 56edfa38..850b94c0 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ThingsModelJsonTemplate.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ThingsModelJsonTemplate.java @@ -15,31 +15,42 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = true) @Data @JsonInclude(JsonInclude.Include.NON_NULL) -public class ThingsModelJsonTemplate extends BaseEntity -{ +public class ThingsModelJsonTemplate extends BaseEntity { private static final long serialVersionUID = 1L; - /** 物模型ID */ + /** + * 物模型ID + */ private Long templateId; - /** 物模型名称 */ - @Excel(name = "物模型名称",prompt = "必填") + /** + * 物模型名称 + */ + @Excel(name = "物模型名称", prompt = "必填") private String templateName; - /** 标识符,产品下唯一 */ - @Excel(name = "标识符",prompt = "modbus不填,默认为寄存器地址") + /** + * 标识符,产品下唯一 + */ + @Excel(name = "标识符", prompt = "modbus不填,默认为寄存器地址") private String identifier; - /** 模型类别(1-属性,2-功能,3-事件) */ - @Excel(name = "模型类别", readConverterExp = "1=属性,2=功能,3=事件",prompt ="1=属性,2=功能,3=事件") + /** + * 模型类别(1-属性,2-功能,3-事件) + */ + @Excel(name = "模型类别", readConverterExp = "1=属性,2=功能,3=事件", prompt = "1=属性,2=功能,3=事件") private Integer type; - /** 数据类型(integer、decimal、string、bool、array、enum) */ + /** + * 数据类型(integer、decimal、string、bool、array、enum) + */ @Excel(name = "数据类型", prompt = "integer、decimal、string、bool、array、enum") private String datatype; - /** 计算公式 */ - @Excel(name = "计算公式",prompt = "选填,例如:%s*10,%s是占位符") + /** + * 计算公式 + */ + @Excel(name = "计算公式", prompt = "选填,例如:%s*10,%s是占位符") private String formula; @Excel(name = "有效值范围") @@ -48,19 +59,27 @@ public class ThingsModelJsonTemplate extends BaseEntity @Excel(name = "单位") private String unit; - /** 是否只读数据(0-否,1-是) */ - @Excel(name = "是否只读",readConverterExp = "0=否,1=是",prompt = "0=否,1=是") + /** + * 是否只读数据(0-否,1-是) + */ + @Excel(name = "是否只读", readConverterExp = "0=否,1=是", prompt = "0=否,1=是") private Integer isReadonly; - /** 是否历史存储(0-否,1-是) */ + /** + * 是否历史存储(0-否,1-是) + */ @Excel(name = "是否历史存储(0-否,1-是)") private Integer isHistory; - /** 是否首页显示(0-否,1-是) */ + /** + * 是否首页显示(0-否,1-是) + */ @Excel(name = "是否首页显示", readConverterExp = "0=否,1=是") private Integer isChart; - /** 是否实时监测(0-否,1-是) */ + /** + * 是否实时监测(0-否,1-是) + */ @Excel(name = "是否实时监测", readConverterExp = "0=否,1=是") private Integer isMonitor; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ThingsModelTemplate.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ThingsModelTemplate.java index c47847b3..cc38876c 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ThingsModelTemplate.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ThingsModelTemplate.java @@ -20,83 +20,114 @@ import com.fastbee.common.core.domain.BaseEntity; @ApiModel(value = "ThingsModelTemplate", description = "通用物模型对象 iot_things_model_template") @JsonInclude(JsonInclude.Include.NON_NULL) @Data -public class ThingsModelTemplate extends BaseEntity -{ +public class ThingsModelTemplate extends BaseEntity { private static final long serialVersionUID = 1L; - /** 物模型ID */ + /** + * 物模型ID + */ @ApiModelProperty("物模型ID") private Long templateId; - /** 物模型名称 */ + /** + * 物模型名称 + */ @ApiModelProperty("物模型名称") - @Excel(name = "物模型名称" ,prompt = "必填") + @Excel(name = "物模型名称", prompt = "必填") private String templateName; - /** 租户ID */ + /** + * 租户ID + */ @ApiModelProperty("租户ID") private Long tenantId; - /** 租户名称 */ + /** + * 租户名称 + */ @ApiModelProperty("租户名称") private String tenantName; - /** 标识符,产品下唯一 */ + /** + * 标识符,产品下唯一 + */ @ApiModelProperty("标识符,产品下唯一") - @Excel(name = "标识符",prompt = "modbus不填,默认为寄存器地址") + @Excel(name = "标识符", prompt = "modbus不填,默认为寄存器地址") private String identifier; - /** 模型类别(1-属性,2-功能,3-事件) */ + /** + * 模型类别(1-属性,2-功能,3-事件) + */ @ApiModelProperty(value = "模型类别", notes = "(1-属性,2-功能,3-事件)") - @Excel(name = "模型类别", readConverterExp = "1=属性,2=功能,3=事件",prompt ="1=属性,2-功能,3-事件") + @Excel(name = "模型类别", readConverterExp = "1=属性,2=功能,3=事件", prompt = "1=属性,2-功能,3-事件") private Integer type; - /** 计算公式 */ + /** + * 计算公式 + */ @ApiModelProperty("计算公式") - @Excel(name = "计算公式",prompt = "选填,例如:%s*10,%s是占位符") + @Excel(name = "计算公式", prompt = "选填,例如:%s*10,%s是占位符") private String formula; - /** 数据定义 */ + /** + * 数据定义 + */ @ApiModelProperty("数据定义") private String specs; - /** 是否系统通用(0-否,1-是) */ + /** + * 是否系统通用(0-否,1-是) + */ @ApiModelProperty("是否系统通用(0-否,1-是)") private Integer isSys; - /** 是否图表显示(0-否,1-是) */ + /** + * 是否图表显示(0-否,1-是) + */ @ApiModelProperty("是否图表显示(0-否,1-是)") //@Excel(name = "是否图表显示", readConverterExp = "0=否,1=是") private Integer isChart; - /** 是否历史存储(0-否,1-是) */ + /** + * 是否历史存储(0-否,1-是) + */ @ApiModelProperty("是否历史存储(0-否,1-是)") @Excel(name = "是否历史存储", readConverterExp = "0=否,1=是") private Integer isHistory; - /** 是否实时监测(0-否,1-是) */ + /** + * 是否实时监测(0-否,1-是) + */ @ApiModelProperty("是否实时监测(0-否,1-是)") private Integer isMonitor; - /** 是否分享设备权限(0-否,1-是) */ + /** + * 是否分享设备权限(0-否,1-是) + */ @ApiModelProperty(value = "是否分享设备权限", notes = "(0-否,1-是) ") private Integer isSharePerm; - /** 是否分享设备权限(0-否,1-是) */ + /** + * 是否分享设备权限(0-否,1-是) + */ @ApiModelProperty(value = "是否分享设备权限", notes = "(0-否,1-是) ") @Excel(name = "是否分享设备权限", readConverterExp = "0=否,1=是") private Integer isApp; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ @ApiModelProperty("删除标志(0代表存在 2代表删除)") private String delFlag; @Excel(name = "单位") private String unit; - /** 数据类型(integer、decimal、string、bool、array、enum) */ + /** + * 数据类型(integer、decimal、string、bool、array、enum) + */ @ApiModelProperty(value = "数据类型", notes = "(integer、decimal、string、bool、array、enum)") @Excel(name = "数据类型", prompt = "integer、decimal、string、bool、array、enum") private String datatype; @@ -105,9 +136,11 @@ public class ThingsModelTemplate extends BaseEntity @Excel(name = "有效值范围") private String limitValue; - /** 是否只读数据(0-否,1-是) */ + /** + * 是否只读数据(0-否,1-是) + */ @ApiModelProperty("是否只读数据(0-否,1-是)") - @Excel(name = "是否只读", readConverterExp = "0=否,1=是",prompt = "0=否,1=是") + @Excel(name = "是否只读", readConverterExp = "0=否,1=是", prompt = "0=否,1=是") private Integer isReadonly; private Integer modelOrder; diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ViewConfig.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ViewConfig.java index 5a21209a..669cef7a 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ViewConfig.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/domain/ViewConfig.java @@ -7,119 +7,124 @@ import com.fastbee.common.core.domain.BaseEntity; /** * 界面可视化配置对象 iot_view_config - * + * * @author kerwincui * @date 2022-11-15 */ -public class ViewConfig extends BaseEntity -{ +public class ViewConfig extends BaseEntity { private static final long serialVersionUID = 1L; - /** 可视化配置ID */ + /** + * 可视化配置ID + */ private Long viewId; - /** 可视化配置数据 */ + /** + * 可视化配置数据 + */ @Excel(name = "可视化配置数据") private String viewData; - /** 产品ID */ + /** + * 产品ID + */ @Excel(name = "产品ID") private Long productId; - /** 产品名称 */ + /** + * 产品名称 + */ @Excel(name = "产品名称") private String productName; - /** 租户ID */ + /** + * 租户ID + */ @Excel(name = "租户ID") private Long tenantId; - /** 租户名称 */ + /** + * 租户名称 + */ @Excel(name = "租户名称") private String tenantName; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ private String delFlag; - public void setViewId(Long viewId) - { + public Long getViewId() { + return viewId; + } + + public void setViewId(Long viewId) { this.viewId = viewId; } - public Long getViewId() - { - return viewId; + public String getViewData() { + return viewData; } - public void setViewData(String viewData) - { + + public void setViewData(String viewData) { this.viewData = viewData; } - public String getViewData() - { - return viewData; + public Long getProductId() { + return productId; } - public void setProductId(Long productId) - { + + public void setProductId(Long productId) { this.productId = productId; } - public Long getProductId() - { - return productId; + public String getProductName() { + return productName; } - public void setProductName(String productName) - { + + public void setProductName(String productName) { this.productName = productName; } - public String getProductName() - { - return productName; + public Long getTenantId() { + return tenantId; } - public void setTenantId(Long tenantId) - { + + public void setTenantId(Long tenantId) { this.tenantId = tenantId; } - public Long getTenantId() - { - return tenantId; + public String getTenantName() { + return tenantName; } - public void setTenantName(String tenantName) - { + + public void setTenantName(String tenantName) { this.tenantName = tenantName; } - public String getTenantName() - { - return tenantName; - } - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; + public String getDelFlag() { + return delFlag; } - public String getDelFlag() - { - return delFlag; + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("viewId", getViewId()) - .append("viewData", getViewData()) - .append("productId", getProductId()) - .append("productName", getProductName()) - .append("tenantId", getTenantId()) - .append("tenantName", getTenantName()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("viewId", getViewId()) + .append("viewData", getViewData()) + .append("productId", getProductId()) + .append("productName", getProductName()) + .append("tenantId", getTenantId()) + .append("tenantName", getTenantName()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/enums/DeviceType.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/enums/DeviceType.java index da19dd88..eb509db3 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/enums/DeviceType.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/enums/DeviceType.java @@ -25,14 +25,14 @@ public enum DeviceType { /** * 网关子设备 */ - SUB_GATEWAY(4,"网关子设备"); + SUB_GATEWAY(4, "网关子设备"); private int code; private String desc; - public static DeviceType transfer(Integer code){ + public static DeviceType transfer(Integer code) { for (DeviceType value : DeviceType.values()) { - if (value.code == code){ + if (value.code == code) { return value; } } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/helper/DataBaseHelper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/helper/DataBaseHelper.java index 61e791d2..6afd9164 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/helper/DataBaseHelper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/helper/DataBaseHelper.java @@ -64,13 +64,13 @@ public class DataBaseHelper { return String.format("charindex(',%s,' , ',%s,') <> 0", var, var2); } else if (dataBasyType == DataBaseType.POSTGRE_SQL) { // (select position(',100,' in ',0,100,101,')) <> 0 - return String.format("(select position(',%s,' in ','||%s||',')) <> 0",var, var2); + return String.format("(select position(',%s,' in ','||%s||',')) <> 0", var, var2); } else if (dataBasyType == DataBaseType.ORACLE) { // instr(',0,100,101,' , ',100,') <> 0 - return String.format("instr(','||%s||',' , ',%s,') <> 0",var2, var); + return String.format("instr(','||%s||',' , ',%s,') <> 0", var2, var); } // find_in_set(100 , '0,100,101') - return String.format("find_in_set('%s' , %s) <> 0",var, var2); + return String.format("find_in_set('%s' , %s) <> 0", var, var2); } /** diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/AlertLogMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/AlertLogMapper.java index 378a4027..080e570d 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/AlertLogMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/AlertLogMapper.java @@ -17,8 +17,7 @@ import java.util.List; * @date 2022-01-13 */ @Repository -public interface AlertLogMapper -{ +public interface AlertLogMapper { /** * 查询设备告警 * @@ -44,9 +43,13 @@ public interface AlertLogMapper public Long selectAlertLogListCount(AlertLog alertLog); public List selectDeviceAlertCount(@Param("serialNumberList") List serialNumberList); + public DeviceAlertCount selectDeviceAlertCountBySN(String serialNumber); + public List selectSceneAlertCount(); + public DeviceAlertCount selectSceneAlertCountBySceneId(String sceneId); + /** * 新增设备告警 * @@ -70,7 +73,9 @@ public interface AlertLogMapper * @return 结果 */ public int updateAlertLog(AlertLog alertLog); + public int updateAlertLogStatus(AlertLog alertLog); + /** * 删除设备告警 * @@ -97,6 +102,7 @@ public interface AlertLogMapper /** * 统计告警处理信息 + * * @param dataCenterParam 传参 * @return com.fastbee.iot.model.AlertCountVO */ @@ -104,6 +110,7 @@ public interface AlertLogMapper /** * 统计告警级别信息 + * * @param dataCenterParam 传参 * @return com.fastbee.iot.model.AlertCountVO */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/AlertMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/AlertMapper.java index 4bd97582..70acb8a1 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/AlertMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/AlertMapper.java @@ -19,8 +19,7 @@ import java.util.List; * @date 2022-01-13 */ @Repository -public interface AlertMapper -{ +public interface AlertMapper { /** * 查询设备告警 * @@ -39,6 +38,7 @@ public interface AlertMapper /** * 获取告警关联的场景列表 + * * @param alertId * @return */ @@ -78,14 +78,16 @@ public interface AlertMapper /** * 修改设备告警状态 + * * @param alertId 告警id - * @param status 状态 + * @param status 状态 * @return 结果 */ int updateAlertStatus(@Param("alertId") Long alertId, @Param("status") Integer status); /** * 批量插入告警场景 + * * @param alerts * @return */ @@ -93,13 +95,15 @@ public interface AlertMapper /** * 根据告警ID批量删除告警场景 + * * @param alertIds * @return */ - public int deleteAlertSceneByAlertIds(Long[] alertIds); + public int deleteAlertSceneByAlertIds(Long[] alertIds); /** * 根据场景ID批量删除告警场景 + * * @param sceneIds * @return */ @@ -107,6 +111,7 @@ public interface AlertMapper /** * 批量插入告警通知模版 + * * @param alertNotifyTemplateList * @return */ @@ -114,13 +119,15 @@ public interface AlertMapper /** * 根据告警ID批量删除告警场景 + * * @param alertIds * @return */ - public int deleteAlertNotifyTemplateByAlertIds(Long[] alertIds); + public int deleteAlertNotifyTemplateByAlertIds(Long[] alertIds); /** * 查询告警通知模版 + * * @param alertId 告警id * @return java.util.List */ @@ -128,6 +135,7 @@ public interface AlertMapper /** * 获取告警关联的通知模版列表 + * * @param alertId 告警id * @return */ @@ -135,6 +143,7 @@ public interface AlertMapper /** * 获取场景关联的告警列表 + * * @param sceneId 场景id * @return java.util.List */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/BridgeMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/BridgeMapper.java index e45ecad7..d303fb92 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/BridgeMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/BridgeMapper.java @@ -9,7 +9,6 @@ import com.fastbee.iot.domain.Bridge; * @author kerwincui * @date 2024-08-20 */ -public interface BridgeMapper extends BaseMapperX -{ +public interface BridgeMapper extends BaseMapperX { } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/CategoryMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/CategoryMapper.java index 94ad96d1..51b5e19e 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/CategoryMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/CategoryMapper.java @@ -14,8 +14,7 @@ import java.util.List; * @date 2021-12-16 */ @Repository -public interface CategoryMapper -{ +public interface CategoryMapper { /** * 查询产品分类 * diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/CommandPreferencesMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/CommandPreferencesMapper.java index 51bcdf30..fdf5c380 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/CommandPreferencesMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/CommandPreferencesMapper.java @@ -11,8 +11,7 @@ import com.fastbee.iot.domain.CommandPreferences; * @author kerwincui * @date 2024-06-29 */ -public interface CommandPreferencesMapper -{ +public interface CommandPreferencesMapper { /** * 查询指令偏好设置 * diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceAlertUserMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceAlertUserMapper.java index 7fda9d7b..82997bf1 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceAlertUserMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceAlertUserMapper.java @@ -12,8 +12,7 @@ import org.apache.ibatis.annotations.Param; * @author kerwincui * @date 2024-05-15 */ -public interface DeviceAlertUserMapper -{ +public interface DeviceAlertUserMapper { /** * 查询设备告警用户 * @@ -64,9 +63,10 @@ public interface DeviceAlertUserMapper /** * 删除设备告警用户 + * * @param deviceId 设备id - * @param: userId 用户id * @return int + * @param: userId 用户id */ int deleteByDeviceIdAndUserId(@Param("deviceId") Long deviceId, @Param("userId") Long userId); } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceJobMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceJobMapper.java index 28b69d1c..de78c802 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceJobMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceJobMapper.java @@ -13,8 +13,7 @@ import java.util.List; * @author kerwincui */ @Repository -public interface DeviceJobMapper -{ +public interface DeviceJobMapper { /** * 查询调度任务日志集合 * @@ -120,17 +119,19 @@ public interface DeviceJobMapper /** * 批量查询定时任务 + * * @param datasourceIds 源数据id集合 - * @param: jobType 定时任务类型 * @return java.util.List + * @param: jobType 定时任务类型 */ List selectListByJobTypeAndDatasourceIds(@Param("datasourceIds") Long[] datasourceIds, @Param("jobType") int jobType); /** * 批量删除定时任务 + * * @param datasourceIds 源数据id集合 - * @param: jobType 类型 * @return int + * @param: jobType 类型 */ int deleteJobByJobTypeAndDatasourceIds(@Param("datasourceIds") Long[] datasourceIds, @Param("jobType") int jobType); diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceLogMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceLogMapper.java index 25e0ed11..e2bc10bb 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceLogMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceLogMapper.java @@ -22,8 +22,7 @@ import java.util.List; * @date 2022-01-13 */ @Repository -public interface DeviceLogMapper -{ +public interface DeviceLogMapper { /** * 查询设备日志 * @@ -107,6 +106,7 @@ public interface DeviceLogMapper /** * 查询物模型历史数据 + * * @param deviceLog 设备日志 * @return java.util.List */ @@ -115,8 +115,10 @@ public interface DeviceLogMapper List listhistoryGroupByCreateTime(DeviceLog deviceLog); DeviceLog selectLastReport(DeviceLog deviceLog); + /** * 场景统计变量历史值 + * * @param deviceLog 实体类 * @return java.lang.String */ @@ -124,6 +126,7 @@ public interface DeviceLogMapper /** * 统计设备物模型指令下发数量 + * * @param dataCenterParam 传参 * @return com.fastbee.common.core.domain.AjaxResult */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceMapper.java index c6463923..8d1f1991 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceMapper.java @@ -22,8 +22,7 @@ import java.util.Set; * @date 2021-12-16 */ @Mapper -public interface DeviceMapper extends BaseMapperX -{ +public interface DeviceMapper extends BaseMapperX { /** * 查询设备 * @@ -67,6 +66,7 @@ public interface DeviceMapper extends BaseMapperX /** * 根据设备编号查询协议编号 + * * @param serialNumber 设备编号 * @return 协议编号 */ @@ -185,6 +185,7 @@ public interface DeviceMapper extends BaseMapperX /** * 更新固件版本 + * * @param device * @return */ @@ -216,6 +217,7 @@ public interface DeviceMapper extends BaseMapperX /** * 查询设备序列号的数量 + * * @param deviceNum * @return */ @@ -223,6 +225,7 @@ public interface DeviceMapper extends BaseMapperX /** * 根据设备IDS删除设备分组 + * * @param userDeviceGroupIdModel * @return */ @@ -230,12 +233,14 @@ public interface DeviceMapper extends BaseMapperX /** * 重置设备状态 + * * @return 结果 */ public int resetDeviceStatus(String deviceNum); /** * 根据设备编号查询协议编码 + * * @param serialNumber 设备编号 * @return */ @@ -243,19 +248,22 @@ public interface DeviceMapper extends BaseMapperX /** * 查询产品下所有设备,返回设备编号 + * * @param productId 产品id * @return */ - public List selectDevicesByProductId(@Param("productId") Long productId,@Param("hasSub") Integer hasSub); + public List selectDevicesByProductId(@Param("productId") Long productId, @Param("hasSub") Integer hasSub); /** * 批量更新设备上线 + * * @param devices 设备ids */ public void batchChangeOnline(List devices); /** * 批量更新设备下线 + * * @param devices 设备ids */ public void batchChangeOffline(List devices); @@ -263,6 +271,7 @@ public interface DeviceMapper extends BaseMapperX /** * 获取设备MQTT连接参数 + * * @param deviceId 设备id * @return */ @@ -270,6 +279,7 @@ public interface DeviceMapper extends BaseMapperX /** * 查询告警日志相关联信息 + * * @param deviceNumbers 设备编号集合 * @return */ @@ -277,6 +287,7 @@ public interface DeviceMapper extends BaseMapperX /** * 查询告警日志相关联信息 + * * @param deviceNumber 设备编号 * @return */ @@ -284,6 +295,7 @@ public interface DeviceMapper extends BaseMapperX /** * 根据产品ID获取产品下所有编号 + * * @param productId * @return */ @@ -291,13 +303,13 @@ public interface DeviceMapper extends BaseMapperX /** * 根据设备编号查询设备状态 + * * @param deviceNumbers 设备编号集合 * @return */ public List selectDeviceStatusByNumbers(String[] deviceNumbers); - /** * 重置设备状态 */ @@ -305,12 +317,14 @@ public interface DeviceMapper extends BaseMapperX /** * 获取所有已经激活并不是禁用的设备 + * * @return */ List selectDeviceActive(); /** * 批量添加设备 + * * @param deviceList 设备集合 * @return void */ @@ -318,6 +332,7 @@ public interface DeviceMapper extends BaseMapperX /** * 批量校验设备 + * * @param serialNumberList * @return java.util.List */ @@ -325,10 +340,11 @@ public interface DeviceMapper extends BaseMapperX /** * 更新设备绑定机构 + * * @param tenantId 机构管理员id + * @return int * @param: userName 管理员名称 * @param: deviceIdList 设备id集合 - * @return int */ int updateTenantIdByDeptIds(@Param("tenantId") Long tenantId, @Param("tenantName") String tenantName, @Param("deviceIdList") List deviceIdList); @@ -341,6 +357,7 @@ public interface DeviceMapper extends BaseMapperX /** * 设备数量 + * * @param tenantId * @return int */ @@ -352,8 +369,10 @@ public interface DeviceMapper extends BaseMapperX * @return: java.util.List */ List selectDeviceListByDeviceIds(@Param("deviceIdList") List deviceIdList); + /** * 根据监控设备channelId获取设备 + * * @param channelId * @return */ @@ -361,6 +380,7 @@ public interface DeviceMapper extends BaseMapperX /** * 查询设备状态以及传输协议 + * * @param serialNumber * @return */ @@ -377,6 +397,7 @@ public interface DeviceMapper extends BaseMapperX /** * 查询产品下所有设备,返回设备编号 + * * @param productId 产品id * @return */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceRecordMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceRecordMapper.java index 4c6accee..dd3e2d5c 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceRecordMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceRecordMapper.java @@ -13,8 +13,7 @@ import org.apache.ibatis.annotations.Mapper; * @date 2024-07-16 */ @Mapper -public interface DeviceRecordMapper extends BaseMapperX -{ +public interface DeviceRecordMapper extends BaseMapperX { /** * 查询设备记录 * diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceShareMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceShareMapper.java index 68b3880d..12073639 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceShareMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceShareMapper.java @@ -16,10 +16,10 @@ import org.springframework.stereotype.Repository; * @date 2024-04-03 */ @Repository -public interface DeviceShareMapper -{ +public interface DeviceShareMapper { /** * 根据用户id、设备Id获取分享详情 + * * @param deviceId * @param userId * @return @@ -84,6 +84,7 @@ public interface DeviceShareMapper /** * 删除分享设备 + * * @param deviceShare * @return int */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceUserMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceUserMapper.java index eb9af54f..372da972 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceUserMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/DeviceUserMapper.java @@ -16,8 +16,7 @@ import org.springframework.stereotype.Repository; * @date 2021-12-16 */ @Repository -public interface DeviceUserMapper -{ +public interface DeviceUserMapper { /** * 查询设备用户 * @@ -76,6 +75,7 @@ public interface DeviceUserMapper /** * 批量添加设备用户 + * * @param deviceUsers 设备用户 * @return 结果 */ @@ -83,9 +83,10 @@ public interface DeviceUserMapper /** * 根据deviceId 和 userId 查询 + * * @param deviceId 设备id * @param userId 用户id - * @return 结果 + * @return 结果 */ public DeviceUser selectDeviceUserByDeviceIdAndUserId(@Param("deviceId") Long deviceId, @Param("userId") Long userId); diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/EventLogMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/EventLogMapper.java index 1fa82072..87dc8d3b 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/EventLogMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/EventLogMapper.java @@ -1,6 +1,7 @@ package com.fastbee.iot.mapper; import java.util.List; + import com.fastbee.framework.mybatis.mapper.BaseMapperX; import com.fastbee.iot.domain.EventLog; import com.fastbee.iot.model.HistoryModel; @@ -11,11 +12,11 @@ import com.fastbee.iot.model.HistoryModel; * @author kerwincui * @date 2024-08-16 */ -public interface EventLogMapper extends BaseMapperX -{ +public interface EventLogMapper extends BaseMapperX { /** * 查询物模型历史数据 + * * @param eventLog 事件日志 * @return java.util.List */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FirmwareMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FirmwareMapper.java index 68ed4521..de1921c9 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FirmwareMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FirmwareMapper.java @@ -1,6 +1,7 @@ package com.fastbee.iot.mapper; import java.util.List; + import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.fastbee.iot.domain.Firmware; import org.apache.ibatis.annotations.Param; @@ -11,21 +12,22 @@ import org.apache.ibatis.annotations.Param; * @author kerwincui * @date 2024-08-18 */ -public interface FirmwareMapper extends BaseMapper -{ +public interface FirmwareMapper extends BaseMapper { /** * 查询设备最新固件 - * @param deviceId 产品固件主键 + * + * @param deviceId 产品固件主键 * @param firmwareType 固件类型 * @return 产品固件 */ - Firmware selectLatestFirmware(@Param("deviceId") Long deviceId, @Param("firmwareType") Long firmwareType); + Firmware selectLatestFirmware(@Param("deviceId") Long deviceId, @Param("firmwareType") Long firmwareType); /** * 查询待升级固件版本列表 + * * @param firmware * @return */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FirmwareTaskDetailMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FirmwareTaskDetailMapper.java index a7788324..aaa56f0e 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FirmwareTaskDetailMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FirmwareTaskDetailMapper.java @@ -1,6 +1,7 @@ package com.fastbee.iot.mapper; import java.util.List; + import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.fastbee.iot.domain.FirmwareTaskDetail; import com.fastbee.iot.model.FirmwareTaskDetailInput; @@ -14,11 +15,11 @@ import org.springframework.data.repository.query.Param; * @author kerwincui * @date 2024-08-18 */ -public interface FirmwareTaskDetailMapper extends BaseMapper -{ +public interface FirmwareTaskDetailMapper extends BaseMapper { /** * 根据固件id查询下属设备列表 + * * @param firmwareTaskDetailInput * @return */ @@ -27,6 +28,7 @@ public interface FirmwareTaskDetailMapper extends BaseMapper /** * 固件升级设备统计 + * * @param firmwareTaskDetailInput * @return */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FirmwareTaskMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FirmwareTaskMapper.java index 844c3753..8fe39936 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FirmwareTaskMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FirmwareTaskMapper.java @@ -1,6 +1,7 @@ package com.fastbee.iot.mapper; import java.util.List; + import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.fastbee.iot.domain.FirmwareTask; import org.apache.ibatis.annotations.Param; @@ -11,14 +12,14 @@ import org.apache.ibatis.annotations.Param; * @author kerwincui * @date 2024-08-18 */ -public interface FirmwareTaskMapper extends BaseMapper -{ +public interface FirmwareTaskMapper extends BaseMapper { /** * 根据任务名称查询固件升级任务总数 + * * @param firmwareId 固件id - * @param taskName 固件升级任务名称 + * @param taskName 固件升级任务名称 * @return 固件升级任务 */ public int selectCountFirmwareTaskByTaskName(@Param("firmwareId") Long firmwareId, @Param("taskName") String taskName); diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FunctionLogMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FunctionLogMapper.java index 3c8c98d3..d9cc91ef 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FunctionLogMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/FunctionLogMapper.java @@ -17,8 +17,7 @@ import org.springframework.stereotype.Repository; * @date 2022-10-22 */ @Repository -public interface FunctionLogMapper -{ +public interface FunctionLogMapper { /** * 查询设备服务下发日志 * @@ -45,6 +44,7 @@ public interface FunctionLogMapper /** * 批量插入数据 + * * @param list */ public void insertBatch(List list); @@ -91,18 +91,21 @@ public interface FunctionLogMapper /** * 批量更新日志状态值 + * * @param log 参数 */ public void updateFuncLogBatch(FunctionLog log); /** * 根据消息id更新指令下发状态 + * * @param log */ public void updateByMessageId(FunctionLog log); /** * 查询物模型历史数据 + * * @param functionLog 功能日志 * @return java.util.List */ @@ -110,6 +113,7 @@ public interface FunctionLogMapper /** * 统计设备物模型指令下发数量 + * * @param dataCenterParam 传参 * @return com.fastbee.common.core.domain.AjaxResult */ @@ -117,6 +121,7 @@ public interface FunctionLogMapper /** * 根据消息id获取指令日志 + * * @param messageId * @return */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/GoviewProjectDataMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/GoviewProjectDataMapper.java index 51431081..8179748b 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/GoviewProjectDataMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/GoviewProjectDataMapper.java @@ -14,8 +14,7 @@ import java.util.List; * @date 2022-10-27 */ @Repository -public interface GoviewProjectDataMapper -{ +public interface GoviewProjectDataMapper { /** * 查询项目数据关联 * @@ -64,10 +63,11 @@ public interface GoviewProjectDataMapper */ public int deleteGoviewProjectDataByIds(String[] ids); - GoviewProjectData selectGoviewProjectDataByProjectId(String projectId); + GoviewProjectData selectGoviewProjectDataByProjectId(String projectId); /** * 根据sql获取组件数据接口 + * * @param sql sql * @return 组件数据 */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/GoviewProjectMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/GoviewProjectMapper.java index a8dd80bd..47f859e9 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/GoviewProjectMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/GoviewProjectMapper.java @@ -13,8 +13,7 @@ import org.springframework.stereotype.Repository; * @date 2022-10-27 */ @Repository -public interface GoviewProjectMapper -{ +public interface GoviewProjectMapper { /** * 查询项目 * diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/GroupMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/GroupMapper.java index ec96ee9b..c7472a7b 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/GroupMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/GroupMapper.java @@ -16,8 +16,7 @@ import org.springframework.stereotype.Repository; * @date 2021-12-16 */ @Repository -public interface GroupMapper -{ +public interface GroupMapper { /** * 查询设备分组 * @@ -28,6 +27,7 @@ public interface GroupMapper /** * 通过分组ID查询关联的设备ID数组 + * * @param groupId * @return */ @@ -51,6 +51,7 @@ public interface GroupMapper /** * 分组下批量增加设备分组 + * * @param input * @return */ @@ -82,6 +83,7 @@ public interface GroupMapper /** * 批量删除设备分组 + * * @param groupIds * @return */ @@ -89,6 +91,7 @@ public interface GroupMapper /** * 根据用户Id查询分组列表 + * * @param userId 用户id * @return 分组列表 */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ModbusConfigMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ModbusConfigMapper.java index 881cd350..0d6ba2c7 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ModbusConfigMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ModbusConfigMapper.java @@ -12,8 +12,7 @@ import org.apache.ibatis.annotations.Param; * @author kerwincui * @date 2024-05-22 */ -public interface ModbusConfigMapper -{ +public interface ModbusConfigMapper { /** * 查询modbus配置 * @@ -48,6 +47,7 @@ public interface ModbusConfigMapper /** * 批量添加modbus配置 + * * @param list * @return */ @@ -55,6 +55,7 @@ public interface ModbusConfigMapper /** * 批量更新modbus配置 + * * @param list * @return */ @@ -78,6 +79,7 @@ public interface ModbusConfigMapper /** * 根据产品id和标识符获取modbus配置 + * * @param productId * @param identity * @return @@ -86,6 +88,7 @@ public interface ModbusConfigMapper /** * 获取modbus配置简要字段 + * * @param config * @return */ @@ -93,6 +96,7 @@ public interface ModbusConfigMapper /** * 根据产品id获取modbus配置 + * * @param productId * @return */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ModbusJobMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ModbusJobMapper.java index 39f94c49..b0ad1638 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ModbusJobMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ModbusJobMapper.java @@ -11,8 +11,7 @@ import com.fastbee.iot.domain.ModbusJob; * @author kerwincui * @date 2024-07-05 */ -public interface ModbusJobMapper -{ +public interface ModbusJobMapper { /** * 查询轮训任务列 * diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ModbusParamsMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ModbusParamsMapper.java index f88167aa..e3105f4d 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ModbusParamsMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ModbusParamsMapper.java @@ -5,12 +5,13 @@ import com.fastbee.iot.domain.ModbusParams; /** * 产品modbus配置参数Mapper接口 + * * @date 2024-08-20 */ -public interface ModbusParamsMapper extends BaseMapperX -{ +public interface ModbusParamsMapper extends BaseMapperX { /** * 根据产品io获取modbus配置 + * * @param productId * @return */ @@ -18,6 +19,7 @@ public interface ModbusParamsMapper extends BaseMapperX /** * 根据设备id获取modbus配置 + * * @param deviceId * @return */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/MqttClientMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/MqttClientMapper.java index 1db0ba82..b33905b7 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/MqttClientMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/MqttClientMapper.java @@ -1,19 +1,19 @@ package com.fastbee.iot.mapper; import java.util.List; + import com.fastbee.iot.domain.MqttClient; /** * mqtt桥接配置表Mapper接口 - * + * * @author gx_ma * @date 2024-06-03 */ -public interface MqttClientMapper -{ +public interface MqttClientMapper { /** * 查询mqtt桥接配置表 - * + * * @param id mqtt桥接配置表主键 * @return mqtt桥接配置表 */ @@ -21,7 +21,7 @@ public interface MqttClientMapper /** * 查询mqtt桥接配置表列表 - * + * * @param mqttClient mqtt桥接配置表 * @return mqtt桥接配置表集合 */ @@ -29,7 +29,7 @@ public interface MqttClientMapper /** * 新增mqtt桥接配置表 - * + * * @param mqttClient mqtt桥接配置表 * @return 结果 */ @@ -37,7 +37,7 @@ public interface MqttClientMapper /** * 修改mqtt桥接配置表 - * + * * @param mqttClient mqtt桥接配置表 * @return 结果 */ @@ -45,7 +45,7 @@ public interface MqttClientMapper /** * 删除mqtt桥接配置表 - * + * * @param id mqtt桥接配置表主键 * @return 结果 */ @@ -53,7 +53,7 @@ public interface MqttClientMapper /** * 批量删除mqtt桥接配置表 - * + * * @param ids 需要删除的数据主键集合 * @return 结果 */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/NewsCategoryMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/NewsCategoryMapper.java index 5b1c5b24..a08b385c 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/NewsCategoryMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/NewsCategoryMapper.java @@ -14,8 +14,7 @@ import org.springframework.stereotype.Repository; * @date 2022-04-09 */ @Repository -public interface NewsCategoryMapper -{ +public interface NewsCategoryMapper { /** * 查询新闻分类 * diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/NewsMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/NewsMapper.java index 0cb4ede1..d8a29ad8 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/NewsMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/NewsMapper.java @@ -13,8 +13,7 @@ import org.springframework.stereotype.Repository; * @date 2022-04-09 */ @Repository -public interface NewsMapper -{ +public interface NewsMapper { /** * 查询新闻资讯 * diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/OrderControlMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/OrderControlMapper.java index 604dd655..86d67a98 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/OrderControlMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/OrderControlMapper.java @@ -12,8 +12,7 @@ import org.apache.ibatis.annotations.Param; * @author kerwincui * @date 2024-07-01 */ -public interface OrderControlMapper -{ +public interface OrderControlMapper { /** * 查询指令权限控制 * @@ -64,8 +63,9 @@ public interface OrderControlMapper /** * 根据用户id获取 + * * @param userId * @return */ - List selectByUserId(@Param("userId") Long userId,@Param("deviceId") Long deviceId); + List selectByUserId(@Param("userId") Long userId, @Param("deviceId") Long deviceId); } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductAuthorizeMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductAuthorizeMapper.java index 7888c4e7..7dbc2685 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductAuthorizeMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductAuthorizeMapper.java @@ -13,8 +13,7 @@ import org.springframework.stereotype.Repository; * @date 2022-04-11 */ @Repository -public interface ProductAuthorizeMapper -{ +public interface ProductAuthorizeMapper { /** * 查询产品授权码 * @@ -73,6 +72,7 @@ public interface ProductAuthorizeMapper /** * 批量新增产品授权码 + * * @param list * @return */ @@ -80,6 +80,7 @@ public interface ProductAuthorizeMapper /** * 根据授权码查询一条未绑定的授权码 + * * @param authorize * @return */ @@ -87,6 +88,7 @@ public interface ProductAuthorizeMapper /** * 根据产品id查询产品授权码 + * * @param productId 产品id * @return */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductMapper.java index 2b4e705e..0fa4a710 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductMapper.java @@ -17,8 +17,7 @@ import java.util.List; * @date 2021-12-16 */ @Repository -public interface ProductMapper -{ +public interface ProductMapper { /** * 查询产品 * @@ -101,6 +100,7 @@ public interface ProductMapper /** * 产品下的固件数量 + * * @param productIds 需要删除的数据主键集合 * @return 结果 */ @@ -108,6 +108,7 @@ public interface ProductMapper /** * 产品下的设备数量 + * * @param productIds 需要删除的数据主键集合 * @return 结果 */ @@ -115,6 +116,7 @@ public interface ProductMapper /** * 产品下的物模型数量 + * * @param productId 需要删除的数据主键集合 * @return 结果 */ @@ -122,6 +124,7 @@ public interface ProductMapper /** * 产品下的物模型标识符重复数 + * * @param productId 需要删除的数据主键集合 * @return 结果 */ @@ -129,6 +132,7 @@ public interface ProductMapper /** * 根据产品id获取协议编号 + * * @param productId 产品id * @return 协议编号 */ @@ -136,6 +140,7 @@ public interface ProductMapper /** * 根据模板id查询所有使用的产品 + * * @param templeId 模板id * @return */ @@ -143,6 +148,7 @@ public interface ProductMapper /** * 查询产品图片 + * * @param productId 产品id * @return java.lang.String */ @@ -150,6 +156,7 @@ public interface ProductMapper /** * 查询终端用户产品 + * * @param product * @return java.util.List */ @@ -158,6 +165,7 @@ public interface ProductMapper /** * 根据产品id获取关联组态guid + * * @param productId * @return guid */ @@ -165,10 +173,12 @@ public interface ProductMapper /** * 查询组态信息 + * * @param guidList 组态id集合 * @return java.util.List */ List selectListScadaIdByGuidS(@Param("guidList") List guidList); + /** * @description: * @param: productIdList 产品id集合 diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductModbusJobMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductModbusJobMapper.java index 1a964b76..4f7b55b3 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductModbusJobMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductModbusJobMapper.java @@ -9,7 +9,6 @@ import com.fastbee.iot.domain.ProductModbusJob; * @author zhuangpeng.li * @date 2024-09-04 */ -public interface ProductModbusJobMapper extends BaseMapperX -{ +public interface ProductModbusJobMapper extends BaseMapperX { } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductSubGatewayMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductSubGatewayMapper.java index 2fbd5c10..284db7ae 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductSubGatewayMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProductSubGatewayMapper.java @@ -12,8 +12,7 @@ import java.util.List; * @author zhuangpeng.li * @date 2024-09-04 */ -public interface ProductSubGatewayMapper extends BaseMapperX -{ +public interface ProductSubGatewayMapper extends BaseMapperX { /** * @description: 查询网关 diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProtocolMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProtocolMapper.java index d042c795..98d19f5c 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProtocolMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ProtocolMapper.java @@ -9,6 +9,7 @@ import java.util.List; /** * 协议管理Mapper + * * @author gsb * @date 2022/10/19 15:46 */ @@ -66,16 +67,18 @@ public interface ProtocolMapper { /** * 获取所有唯一协议 + * * @param protocol * @return */ - public List selectByUnion(Protocol protocol); + public List selectByUnion(Protocol protocol); /** * 获取所有可用协议 + * * @param status * @param delFlag * @return */ - public List selectAll(@Param("status") Integer status, @Param("delFlag") Integer delFlag); + public List selectAll(@Param("status") Integer status, @Param("delFlag") Integer delFlag); } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneDeviceMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneDeviceMapper.java index 305f8aad..4618d720 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneDeviceMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneDeviceMapper.java @@ -16,8 +16,7 @@ import java.util.List; * @date 2023-12-28 */ @Repository -public interface SceneDeviceMapper -{ +public interface SceneDeviceMapper { /** * 查询场景设备 * @@ -92,6 +91,7 @@ public interface SceneDeviceMapper /** * 查询场景联动绑定产品 + * * @param productIds 产品id数组 * @return java.util.List */ @@ -99,6 +99,7 @@ public interface SceneDeviceMapper /** * 查询场景联动绑定设备 + * * @param serialNumber 设备编号 * @return java.util.List */ @@ -106,9 +107,10 @@ public interface SceneDeviceMapper /** * 查询设备用户对应的场景 + * * @param serialNumber 设备编号 - * @param: userIdList * @return java.lang.Long[] + * @param: userIdList */ Long[] listSceneIdByDeviceIdAndUserId(@Param("serialNumber") String serialNumber, @Param("userIdList") List userIdList); } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneMapper.java index 7ffda2a7..bd19a191 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneMapper.java @@ -15,8 +15,7 @@ import org.springframework.stereotype.Repository; * @date 2022-01-13 */ @Repository -public interface SceneMapper -{ +public interface SceneMapper { /** * 查询场景联动 * @@ -68,6 +67,7 @@ public interface SceneMapper /** * 根据ids批量查询场景联动 + * * @param sceneIds 场景联动id数组 * @return 集合 */ @@ -75,6 +75,7 @@ public interface SceneMapper /** * 查询场景用户信息 + * * @param sceneIdSet 场景id * @return java.util.List */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelDataMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelDataMapper.java index f964bd73..c545e046 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelDataMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelDataMapper.java @@ -15,8 +15,7 @@ import org.apache.ibatis.annotations.Param; * @author kerwincui * @date 2024-05-21 */ -public interface SceneModelDataMapper -{ +public interface SceneModelDataMapper { /** * 查询【请填写功能名称】 * @@ -67,6 +66,7 @@ public interface SceneModelDataMapper /** * 查询场景关联设备物模型变量 + * * @param datasourceId * @return */ @@ -74,6 +74,7 @@ public interface SceneModelDataMapper /** * 删除场景关联设备物模型变量 + * * @param datasourceIds * @return void */ @@ -81,6 +82,7 @@ public interface SceneModelDataMapper /** * 批量删除场景变量 + * * @param sceneModelIds * @return void */ @@ -88,6 +90,7 @@ public interface SceneModelDataMapper /** * 更新关联设备变量所有启用状态 + * * @param sceneModelData * @return int */ @@ -95,6 +98,7 @@ public interface SceneModelDataMapper /** * 删除设备关联变量 + * * @param sceneModelDeviceIds 设备关联id * @return void */ @@ -102,6 +106,7 @@ public interface SceneModelDataMapper /** * 统计统一关联来源未启用 + * * @param sceneModelDeviceId * @return int */ @@ -111,6 +116,7 @@ public interface SceneModelDataMapper /** * 批量插入 + * * @param sceneModelDataList 变量集合 * @return int */ @@ -118,14 +124,16 @@ public interface SceneModelDataMapper /** * 查询变量 + * * @param datasourceId - * @param: variableType * @return com.fastbee.iot.domain.SceneModelData + * @param: variableType */ SceneModelData selectNoDeviceBySourceIdAndVariableType(@Param("datasourceId") Long datasourceId, @Param("variableType") Integer variableType); /** * 查询关联设备 + * * @param idList 变量id集合 * @return com.fastbee.iot.model.scenemodel.SceneModelDeviceVO */ @@ -133,6 +141,7 @@ public interface SceneModelDataMapper /** * 查询单个物模型来源 + * * @param id 主键 * @return com.fastbee.iot.model.scenemodel.SceneDeviceThingsModelVO */ @@ -140,6 +149,7 @@ public interface SceneModelDataMapper /** * 查询录入型变量默认值 + * * @param id 主键id * @return java.lang.String */ @@ -147,14 +157,16 @@ public interface SceneModelDataMapper /** * 检查是否被应用到计算公式 - * @param datasourceId 数据源id - * @param: type + * + * @param datasourceId 数据源id * @return int + * @param: type */ int checkIsApplyAliasFormule(@Param("datasourceId") Long datasourceId, @Param("variableType") Integer variableType); /** * 批量查询 + * * @param ids id集合 * @return java.util.List */ @@ -162,6 +174,7 @@ public interface SceneModelDataMapper /** * 查询场景变量完整信息列表 + * * @param sceneModelData 场景变量类 * @return java.util.List */ @@ -169,6 +182,7 @@ public interface SceneModelDataMapper /** * 查询场景关联设备物模型 + * * @param datasourceId 数据源id * @return java.util.List */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelDeviceMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelDeviceMapper.java index 00da3ee9..d2cadbac 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelDeviceMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelDeviceMapper.java @@ -12,8 +12,7 @@ import org.apache.ibatis.annotations.Param; * @author kerwincui * @date 2024-05-21 */ -public interface SceneModelDeviceMapper -{ +public interface SceneModelDeviceMapper { /** * 查询场景管理关联设备 * @@ -64,12 +63,14 @@ public interface SceneModelDeviceMapper /** * 查询关联未关联设备的设备配置 + * * @return */ SceneModelDevice selectOneModelDevice(Long sceneModelId); /** * 批量删除场景关联 + * * @param sceneModelIds * @return void */ @@ -77,6 +78,7 @@ public interface SceneModelDeviceMapper /** * 更新全部启用状态 + * * @param updateSceneModelDevice * @return int */ @@ -84,14 +86,16 @@ public interface SceneModelDeviceMapper /** * 查询关联的录入、运算型 + * * @param sceneModelId 场景id - * @param: variableType 类型 * @return com.fastbee.iot.domain.SceneModelDevice + * @param: variableType 类型 */ SceneModelDevice selectOneNoDeviceBySceneModelId(@Param("sceneModelId") Long sceneModelId, @Param("variableType") Integer variableType); /** * 校验是否有使用计算公式 + * * @param id 主键 * @return int */ @@ -99,6 +103,7 @@ public interface SceneModelDeviceMapper /** * 查询场景关联设备 + * * @param productId 产品id * @return java.util.List */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelMapper.java index e1cd5fa6..56c57b66 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelMapper.java @@ -13,8 +13,7 @@ import org.apache.ibatis.annotations.Param; * @author kerwincui * @date 2024-05-20 */ -public interface SceneModelMapper -{ +public interface SceneModelMapper { /** * 查询场景管理 * @@ -65,6 +64,7 @@ public interface SceneModelMapper /** * 根据监控设备id获取场景 + * * @param channelId * @return */ @@ -72,6 +72,7 @@ public interface SceneModelMapper /** * 查询组态信息 + * * @param guidList 组态id集合 * @return java.util.List */ @@ -79,6 +80,7 @@ public interface SceneModelMapper /** * 查询场景信息 + * * @param sceneModelId 场景id * @return com.fastbee.iot.domain.SceneModel */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelTagMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelTagMapper.java index dbb0fc47..258b3c6a 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelTagMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneModelTagMapper.java @@ -13,8 +13,7 @@ import org.apache.ibatis.annotations.Param; * @author kerwincui * @date 2024-05-21 */ -public interface SceneModelTagMapper -{ +public interface SceneModelTagMapper { /** * 查询场景录入型变量 * @@ -65,6 +64,7 @@ public interface SceneModelTagMapper /** * 查询场景联动相关变量 + * * @param idList id * @return java.util.List */ @@ -72,6 +72,7 @@ public interface SceneModelTagMapper /** * 批量删除场景变量 + * * @param sceneModelIds * @return void */ @@ -79,6 +80,7 @@ public interface SceneModelTagMapper /** * 校验变量名称唯一 + * * @param sceneModelTag 场景变量 * @return com.fastbee.iot.domain.SceneModelTag */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneScriptMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneScriptMapper.java index cda9e5a4..cb93c4e3 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneScriptMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneScriptMapper.java @@ -14,8 +14,7 @@ import org.springframework.stereotype.Repository; * @date 2023-12-27 */ @Repository -public interface SceneScriptMapper -{ +public interface SceneScriptMapper { /** * 查询场景脚本 * @@ -82,9 +81,10 @@ public interface SceneScriptMapper /** * 通过脚本用途批量查询 + * * @param sceneIdList 场景id - * @param: scriptPurpose 脚本用途 * @return java.util.List + * @param: scriptPurpose 脚本用途 */ List listSceneScriptByPurpose(@Param("sceneIdList") List sceneIdList, @Param("scriptPurpose") Integer scriptPurpose); } diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneTagPointsMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneTagPointsMapper.java index 7034e0de..a0554edb 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneTagPointsMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/SceneTagPointsMapper.java @@ -11,8 +11,7 @@ import com.fastbee.iot.domain.SceneTagPoints; * @author kerwincui * @date 2024-05-21 */ -public interface SceneTagPointsMapper -{ +public interface SceneTagPointsMapper { /** * 查询运算型变量点 * @@ -63,6 +62,7 @@ public interface SceneTagPointsMapper /** * 批量删除场景变量运算 + * * @param sceneModelIds * @return void */ @@ -70,12 +70,14 @@ public interface SceneTagPointsMapper /** * 批量删除场景变量运算 + * * @param tagIds */ void deleteByTagIds(Long[] tagIds); /** * 查询变量运算列表 + * * @param id * @return java.util.List */ diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ScriptMapper.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ScriptMapper.java index 037ee8ab..e365a0dd 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ScriptMapper.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/mapper/ScriptMapper.java @@ -15,8 +15,7 @@ import org.springframework.stereotype.Repository; * @date 2023-07-01 */ @Repository -public interface ScriptMapper -{ +public interface ScriptMapper { /** * 查询规则引擎脚本 * @@ -32,6 +31,7 @@ public interface ScriptMapper * @return 规则引擎脚本集合 */ public List