From 7c97de738bcc6ca7c052bf3f00e56b4636a50196 Mon Sep 17 00:00:00 2001 From: chenhui <1204351172@qq.com> Date: Fri, 7 Jul 2023 22:23:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?iot-common=E6=A8=A1=E5=9D=97=E7=9A=84=20Son?= =?UTF-8?q?arLint=20&=20clean=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cc/iotkit/common/enums/UserType.java | 3 +- .../common/exception/user/UserException.java | 1 - .../cc/iotkit/common/utils/CodecUtil.java | 5 +- .../cc/iotkit/common/utils/DateUtils.java | 6 +- .../cc/iotkit/common/utils/JsonUtils.java | 3 +- .../iotkit/common/utils/MapstructUtils.java | 3 +- .../iotkit/common/utils/TreeBuildUtils.java | 3 +- .../iotkit/data/manager/IOtaPackageData.java | 2 - .../cc/iotkit/data/system/ISysDeptData.java | 1 - .../cc/iotkit/data/system/ISysDictData.java | 2 - .../iotkit/data/system/ISysDictTypeData.java | 3 +- .../iotkit/data/system/ISysOssConfigData.java | 1 - .../data/service/CategoryDataCache.java | 11 +- .../data/service/DeviceInfoDataCache.java | 4 +- .../data/service/OauthClientDataCache.java | 13 +- .../data/dao/DeviceGroupRepository.java | 2 - .../iotkit/data/dao/DeviceInfoRepository.java | 2 - .../java/cc/iotkit/data/dao/IJPACommData.java | 4 +- .../data/dao/SysRoleDeptRepository.java | 1 - .../data/dao/SysRoleMenuRepository.java | 1 - .../cc/iotkit/data/model/TbAlertRecord.java | 14 +- .../data/model/TbDeviceGroupMapping.java | 1 - .../cc/iotkit/data/model/TbDeviceSubUser.java | 1 - .../cc/iotkit/data/model/TbDeviceTag.java | 1 - .../java/cc/iotkit/data/model/TbRuleInfo.java | 1 - .../cc/iotkit/data/model/TbSysConfig.java | 6 +- .../cc/iotkit/data/model/TbSysDictType.java | 2 - .../java/cc/iotkit/data/model/TbSysOss.java | 1 - .../cc/iotkit/data/model/TbSysOssConfig.java | 1 - .../data/service/AlertConfigDataImpl.java | 9 +- .../data/service/AlertRecordDataImpl.java | 8 +- .../iotkit/data/service/CategoryDataImpl.java | 8 +- .../data/service/ChannelTemplateDataImpl.java | 3 +- .../data/service/DeviceConfigDataImpl.java | 9 +- .../data/service/DeviceGroupDataImpl.java | 6 +- .../data/service/DeviceInfoDataImpl.java | 4 +- .../cc/iotkit/data/service/HomeDataImpl.java | 5 +- .../data/service/IOtaDeviceDataImpl.java | 10 -- .../data/service/IOtaPackageDataImpl.java | 5 - .../data/service/OauthClientDataImpl.java | 7 +- .../data/service/ProductModelDataImpl.java | 8 +- .../service/ProtocolComponentDataImpl.java | 5 +- .../service/ProtocolConverterDataImpl.java | 8 +- .../cc/iotkit/data/service/SpaceDataImpl.java | 6 +- .../data/service/SpaceDeviceDataImpl.java | 6 +- .../iotkit/data/service/SysMenuDataImpl.java | 3 +- .../data/service/SysNoticeDataImpl.java | 5 - .../data/service/SysOssConfigDataImpl.java | 13 -- .../iotkit/data/service/SysOssDataImpl.java | 2 - .../iotkit/data/service/SysPostDataImpl.java | 1 - .../data/service/SysRoleDeptDataImpl.java | 2 - .../data/service/SysTenantDataImpl.java | 1 - .../service/SysTenantPackageDataImpl.java | 1 - .../data/service/SysUserPostDataImpl.java | 1 - .../iotkit/data/service/UserInfoDataImpl.java | 3 +- .../java/cc/iotkit/data/util/PageBuilder.java | 11 +- .../temporal/es/document/DocTaskLog.java | 1 - .../temporal/es/service/RuleLogDataImpl.java | 4 +- .../temporal/es/service/TaskLogDataImpl.java | 2 +- .../es/service/VirtualDeviceLogDataImpl.java | 1 - .../temporal/ts/service/TaskLogDataImpl.java | 10 +- .../ts/service/ThingModelMessageDataImpl.java | 2 +- .../iotkit/temporal/td/dm/TableManager.java | 2 +- .../td/service/DbStructureDataImpl.java | 6 +- .../temporal/td/service/RuleLogDataImpl.java | 6 +- .../temporal/td/service/TaskLogDataImpl.java | 6 +- .../td/service/ThingModelMessageDataImpl.java | 6 +- .../iotkit/swagger/config/SwaggerConfig.java | 12 +- .../common/excel/annotation/CellMerge.java | 2 + .../common/excel/core/CellMergeStrategy.java | 126 +++++++++--------- .../excel/core/DefaultExcelListener.java | 3 +- .../common/excel/core/DefaultExcelResult.java | 1 - .../iotkit/common/log/aspect/LogAspect.java | 2 +- .../cc/iotkit/common/oss/core/OssClient.java | 6 +- .../common/oss/enumd/AccessPolicyType.java | 3 +- .../core/service/SaPermissionImpl.java | 2 +- .../common/satoken/utils/LoginHelper.java | 3 +- .../common/tenant/helper/TenantHelper.java | 2 - .../web/handler/ResponseResultHandler.java | 1 - .../PlusWebInvokeTimeInterceptor.java | 2 +- .../java/cc/iotkit/vertx/VertxMqProducer.java | 2 - .../cc/iotkit/rocketmq/RocketMqConsumer.java | 1 - 82 files changed, 170 insertions(+), 293 deletions(-) diff --git a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/enums/UserType.java b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/enums/UserType.java index b3a2c761..7eb2fd04 100644 --- a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/enums/UserType.java +++ b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/enums/UserType.java @@ -1,5 +1,6 @@ package cc.iotkit.common.enums; +import cc.iotkit.common.exception.BizException; import cc.iotkit.common.utils.StringUtils; import lombok.AllArgsConstructor; import lombok.Getter; @@ -32,6 +33,6 @@ public enum UserType { return value; } } - throw new RuntimeException("'UserType' not found By " + str); + throw new BizException("'UserType' not found By " + str); } } diff --git a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/exception/user/UserException.java b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/exception/user/UserException.java index b5e16c62..1af89aee 100644 --- a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/exception/user/UserException.java +++ b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/exception/user/UserException.java @@ -10,7 +10,6 @@ package cc.iotkit.common.exception.user; import cc.iotkit.common.enums.ErrCode; -import cc.iotkit.common.exception.BaseException; import cc.iotkit.common.exception.BizException; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/CodecUtil.java b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/CodecUtil.java index c4ace539..bce9482f 100644 --- a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/CodecUtil.java +++ b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/CodecUtil.java @@ -16,6 +16,7 @@ import org.apache.commons.lang3.StringUtils; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.StandardCharsets; public class CodecUtil { @@ -38,7 +39,7 @@ public class CodecUtil { * @return 解码后的byte[] * @throws Exception 抛出异常 */ - private static byte[] base64Decode(String base64Code) throws Exception { + private static byte[] base64Decode(String base64Code) { return StringUtils.isEmpty(base64Code) ? null : new Base64().decode(base64Code); } @@ -56,7 +57,7 @@ public class CodecUtil { Cipher cipher = Cipher.getInstance(ALGORITHMSTR); cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(encryptKey.getBytes(), "AES")); - return cipher.doFinal(content.getBytes("utf-8")); + return cipher.doFinal(content.getBytes(StandardCharsets.UTF_8)); } diff --git a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/DateUtils.java b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/DateUtils.java index 9f22e60e..1a5835a5 100644 --- a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/DateUtils.java +++ b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/DateUtils.java @@ -128,9 +128,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { * 计算两个时间差 */ public static String getDatePoor(Date endDate, Date nowDate) { - long nd = 1000 * 24 * 60 * 60; - long nh = 1000 * 60 * 60; - long nm = 1000 * 60; + long nd = 1000 * 24 * 60 * 60L; + long nh = 1000 * 60 * 60L; + long nm = 1000 * 60L; // long ns = 1000; // 获得两个时间的毫秒时间差异 long diff = endDate.getTime() - nowDate.getTime(); diff --git a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/JsonUtils.java b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/JsonUtils.java index 03f1a1e7..fe102af2 100644 --- a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/JsonUtils.java +++ b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/JsonUtils.java @@ -12,6 +12,7 @@ import lombok.NoArgsConstructor; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -98,7 +99,7 @@ public class JsonUtils { public static List parseArrayMap(String text) { if (StringUtils.isBlank(text)) { - return null; + return Collections.emptyList(); } try { return OBJECT_MAPPER.readValue(text, OBJECT_MAPPER.getTypeFactory().constructCollectionType(List.class, Dict.class)); diff --git a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/MapstructUtils.java b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/MapstructUtils.java index ab0e9f39..f9a31e74 100644 --- a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/MapstructUtils.java +++ b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/MapstructUtils.java @@ -10,6 +10,7 @@ import lombok.NoArgsConstructor; import org.springframework.util.Assert; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -65,7 +66,7 @@ public class MapstructUtils { */ public static List convert(List sourceList, Class desc) { if (ObjectUtil.isNull(sourceList)) { - return null; + return Collections.emptyList(); } if (CollUtil.isEmpty(sourceList)) { return CollUtil.newArrayList(); diff --git a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/TreeBuildUtils.java b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/TreeBuildUtils.java index 01657aee..3be2d5f1 100644 --- a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/TreeBuildUtils.java +++ b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/utils/TreeBuildUtils.java @@ -8,6 +8,7 @@ import cn.hutool.core.lang.tree.parser.NodeParser; import lombok.AccessLevel; import lombok.NoArgsConstructor; +import java.util.Collections; import java.util.List; /** @@ -25,7 +26,7 @@ public class TreeBuildUtils extends TreeUtil { public static List> build(List list, NodeParser nodeParser) { if (CollUtil.isEmpty(list)) { - return null; + return Collections.emptyList(); } K k = ReflectUtils.invokeGetter(list.get(0), "parentId"); return TreeUtil.build(list, k, DEFAULT_CONFIG, nodeParser); diff --git a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/manager/IOtaPackageData.java b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/manager/IOtaPackageData.java index 4fa1c7c4..5b35b145 100644 --- a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/manager/IOtaPackageData.java +++ b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/manager/IOtaPackageData.java @@ -3,8 +3,6 @@ package cc.iotkit.data.manager; import cc.iotkit.data.ICommonData; import cc.iotkit.model.ota.OtaPackage; -import java.util.List; - /** * @Author: 石恒 * @Date: 2023/5/19 21:46 diff --git a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDeptData.java b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDeptData.java index a5be7d42..bdbc2a10 100644 --- a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDeptData.java +++ b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDeptData.java @@ -1,7 +1,6 @@ package cc.iotkit.data.system; -import cc.iotkit.common.api.Paging; import cc.iotkit.data.ICommonData; import cc.iotkit.model.system.SysDept; diff --git a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDictData.java b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDictData.java index f9f13b7c..5d319b32 100644 --- a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDictData.java +++ b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDictData.java @@ -1,9 +1,7 @@ package cc.iotkit.data.system; import cc.iotkit.data.ICommonData; -import cc.iotkit.common.api.Paging; import cc.iotkit.model.system.SysDictData; -import cc.iotkit.model.system.SysDictType; import java.util.List; diff --git a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDictTypeData.java b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDictTypeData.java index b4e5b5f5..4ce27bac 100644 --- a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDictTypeData.java +++ b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDictTypeData.java @@ -1,9 +1,8 @@ package cc.iotkit.data.system; -import cc.iotkit.data.ICommonData; import cc.iotkit.common.api.Paging; +import cc.iotkit.data.ICommonData; import cc.iotkit.model.system.SysDictType; -import cc.iotkit.model.system.SysUser; import java.util.List; diff --git a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysOssConfigData.java b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysOssConfigData.java index 15779b87..49629834 100644 --- a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysOssConfigData.java +++ b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysOssConfigData.java @@ -1,7 +1,6 @@ package cc.iotkit.data.system; import cc.iotkit.data.ICommonData; -import cc.iotkit.model.system.SysOperLog; import cc.iotkit.model.system.SysOssConfig; /** diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/CategoryDataCache.java b/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/CategoryDataCache.java index 56a9fe26..cb2cf7f7 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/CategoryDataCache.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/CategoryDataCache.java @@ -1,10 +1,10 @@ package cc.iotkit.data.service; import cc.iotkit.common.api.PageRequest; -import cc.iotkit.common.constant.Constants; -import cc.iotkit.data.manager.ICategoryData; -import cc.iotkit.data.cache.CategoryCacheEvict; import cc.iotkit.common.api.Paging; +import cc.iotkit.common.constant.Constants; +import cc.iotkit.data.cache.CategoryCacheEvict; +import cc.iotkit.data.manager.ICategoryData; import cc.iotkit.model.product.Category; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -12,6 +12,7 @@ import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import java.util.Collection; +import java.util.Collections; import java.util.List; @Service @@ -31,7 +32,7 @@ public class CategoryDataCache implements ICategoryData { @Override public List findByIds(Collection id) { - return null; + return Collections.emptyList(); } @Override @@ -73,7 +74,7 @@ public class CategoryDataCache implements ICategoryData { @Override public List findAllByCondition(Category data) { - return null; + return Collections.emptyList(); } @Override diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/DeviceInfoDataCache.java b/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/DeviceInfoDataCache.java index 43f5b7d8..6766566c 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/DeviceInfoDataCache.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/DeviceInfoDataCache.java @@ -65,7 +65,7 @@ public class DeviceInfoDataCache implements IDeviceInfoData, SmartInitializingSi pageRequest.setPageSize(1000); pageRequest.setPageNum(page); - while ((paged = deviceInfoData.findAll(pageRequest)).getRows().size() > 0) { + while (!(paged = deviceInfoData.findAll(pageRequest)).getRows().isEmpty()) { pageRequest.setPageNum(page++); List devices = paged.getRows(); for (DeviceInfo device : devices) { @@ -282,7 +282,7 @@ public class DeviceInfoDataCache implements IDeviceInfoData, SmartInitializingSi @Override public List findAllByCondition(DeviceInfo data) { - return null; + return Collections.emptyList(); } @Override diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/OauthClientDataCache.java b/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/OauthClientDataCache.java index af764ef2..16ddd38a 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/OauthClientDataCache.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/OauthClientDataCache.java @@ -10,17 +10,18 @@ package cc.iotkit.data.service; import cc.iotkit.common.api.PageRequest; -import cc.iotkit.common.constant.Constants; -import cc.iotkit.data.manager.IOauthClientData; -import cc.iotkit.data.cache.OauthClientCacheEvict; -import cc.iotkit.model.OauthClient; import cc.iotkit.common.api.Paging; +import cc.iotkit.common.constant.Constants; +import cc.iotkit.data.cache.OauthClientCacheEvict; +import cc.iotkit.data.manager.IOauthClientData; +import cc.iotkit.model.OauthClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import java.util.Collection; +import java.util.Collections; import java.util.List; @Service @@ -45,7 +46,7 @@ public class OauthClientDataCache implements IOauthClientData { @Override public List findByIds(Collection id) { - return null; + return Collections.emptyList(); } @Override @@ -88,7 +89,7 @@ public class OauthClientDataCache implements IOauthClientData { @Override public List findAllByCondition(OauthClient data) { - return null; + return Collections.emptyList(); } @Override diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/DeviceGroupRepository.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/DeviceGroupRepository.java index 67be92cb..b08983b4 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/DeviceGroupRepository.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/DeviceGroupRepository.java @@ -14,8 +14,6 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import java.util.List; - public interface DeviceGroupRepository extends JpaRepository { Page findByNameLike(String name, Pageable pageable); diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/DeviceInfoRepository.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/DeviceInfoRepository.java index ddd935fb..dd348a42 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/DeviceInfoRepository.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/DeviceInfoRepository.java @@ -1,8 +1,6 @@ package cc.iotkit.data.dao; import cc.iotkit.data.model.TbDeviceInfo; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.querydsl.QuerydslPredicateExecutor; diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/IJPACommData.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/IJPACommData.java index a2bf6ad5..49e70876 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/IJPACommData.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/IJPACommData.java @@ -5,11 +5,8 @@ import cc.iotkit.common.api.Paging; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.ICommonData; import cc.iotkit.data.util.PageBuilder; -import cc.iotkit.data.util.PredicateBuilder; import cc.iotkit.model.Id; -import com.querydsl.core.types.Predicate; import org.springframework.data.domain.Example; -import org.springframework.data.domain.ExampleMatcher; import org.springframework.data.domain.Page; import org.springframework.data.jpa.repository.JpaRepository; @@ -33,6 +30,7 @@ public interface IJPACommData< T extends Id, ID> extends ICommonData { diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/AlertRecordDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/AlertRecordDataImpl.java index 32a3c55b..24b23ade 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/AlertRecordDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/AlertRecordDataImpl.java @@ -1,17 +1,13 @@ package cc.iotkit.data.service; import cc.iotkit.common.api.PageRequest; +import cc.iotkit.common.api.Paging; import cc.iotkit.common.utils.MapstructUtils; +import cc.iotkit.data.dao.AlertRecordRepository; import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.manager.IAlertRecordData; -import cc.iotkit.data.dao.AlertRecordRepository; import cc.iotkit.data.model.TbAlertRecord; -import cc.iotkit.common.api.Paging; import cc.iotkit.model.alert.AlertRecord; - -import java.util.Collection; -import java.util.List; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.data.domain.Page; diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/CategoryDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/CategoryDataImpl.java index fc08f6d2..f4fdf393 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/CategoryDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/CategoryDataImpl.java @@ -9,21 +9,19 @@ */ package cc.iotkit.data.service; -import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; +import cc.iotkit.data.dao.CategoryRepository; import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.manager.ICategoryData; -import cc.iotkit.data.dao.CategoryRepository; import cc.iotkit.data.model.TbCategory; -import cc.iotkit.common.api.Paging; import cc.iotkit.model.product.Category; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; -import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -56,7 +54,7 @@ public class CategoryDataImpl implements ICategoryData, IJPACommData findByIds(Collection id) { - return null; + return Collections.emptyList(); } @Override diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelTemplateDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelTemplateDataImpl.java index f4ec7ca2..98c919a7 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelTemplateDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelTemplateDataImpl.java @@ -11,6 +11,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -61,7 +62,7 @@ public class ChannelTemplateDataImpl implements IChannelTemplateData, IJPACommDa @Override public List findAllByCondition(ChannelTemplate data) { - return null; + return Collections.emptyList(); } @Override diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceConfigDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceConfigDataImpl.java index e74912d0..e0c19b8f 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceConfigDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceConfigDataImpl.java @@ -9,25 +9,18 @@ */ package cc.iotkit.data.service; -import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; +import cc.iotkit.data.dao.DeviceConfigRepository; import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.manager.IDeviceConfigData; -import cc.iotkit.data.dao.DeviceConfigRepository; import cc.iotkit.data.model.TbDeviceConfig; -import cc.iotkit.common.api.Paging; import cc.iotkit.model.device.DeviceConfig; -import org.apache.commons.collections.IteratorUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; -import java.util.Collection; -import java.util.List; import java.util.UUID; @Primary diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceGroupDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceGroupDataImpl.java index 7b27b403..283c5ab1 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceGroupDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceGroupDataImpl.java @@ -1,12 +1,11 @@ package cc.iotkit.data.service; -import cc.iotkit.common.api.PageRequest; +import cc.iotkit.common.api.Paging; import cc.iotkit.common.utils.MapstructUtils; +import cc.iotkit.data.dao.DeviceGroupRepository; import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.manager.IDeviceGroupData; -import cc.iotkit.data.dao.DeviceGroupRepository; import cc.iotkit.data.model.TbDeviceGroup; -import cc.iotkit.common.api.Paging; import cc.iotkit.model.device.DeviceGroup; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -16,7 +15,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; -import java.util.Collection; import java.util.List; import java.util.UUID; diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java index 98202636..f234eb49 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java @@ -298,7 +298,7 @@ public class DeviceInfoDataImpl implements IDeviceInfoData, IJPACommData "'" + d.getDeviceId() + "'").collect(Collectors.joining(",")); //取设备所属分组 - List groups = list.size() == 0 ? new ArrayList<>() : + List groups = list.isEmpty() ? new ArrayList<>() : jdbcTemplate.query("SELECT \n" + "a.id,\n" + "a.name, \n" + @@ -537,7 +537,7 @@ public class DeviceInfoDataImpl implements IDeviceInfoData, IJPACommData findAllByCondition(DeviceInfo data) { - return null; + return Collections.emptyList(); } @Override diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/HomeDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/HomeDataImpl.java index 5025c0f0..274e0a52 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/HomeDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/HomeDataImpl.java @@ -1,12 +1,10 @@ package cc.iotkit.data.service; -import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; +import cc.iotkit.data.dao.HomeRepository; import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.manager.IHomeData; -import cc.iotkit.data.dao.HomeRepository; import cc.iotkit.data.model.TbHome; -import cc.iotkit.common.api.Paging; import cc.iotkit.model.space.Home; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -14,7 +12,6 @@ import org.springframework.context.annotation.Primary; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; -import java.util.Collection; import java.util.List; import java.util.UUID; diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/IOtaDeviceDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/IOtaDeviceDataImpl.java index 2f6e2c4c..6d769789 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/IOtaDeviceDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/IOtaDeviceDataImpl.java @@ -1,25 +1,15 @@ package cc.iotkit.data.service; -import cc.iotkit.common.api.PageRequest; -import cc.iotkit.common.api.Paging; -import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.IOtaDeviceRepository; import cc.iotkit.data.manager.IOtaDeviceData; import cc.iotkit.data.model.TbOtaDevice; import cc.iotkit.model.ota.OtaDevice; -import cc.iotkit.model.space.Home; -import org.apache.commons.lang3.StringUtils; import org.springframework.context.annotation.Primary; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.List; -import java.util.UUID; -import java.util.stream.Collectors; /** * @Author: 石恒 diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/IOtaPackageDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/IOtaPackageDataImpl.java index a7887041..c346f048 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/IOtaPackageDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/IOtaPackageDataImpl.java @@ -6,21 +6,16 @@ import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.IOtaPackageRepository; import cc.iotkit.data.manager.IOtaPackageData; -import cc.iotkit.data.model.TbOtaDevice; import cc.iotkit.data.model.TbOtaPackage; -import cc.iotkit.model.ota.OtaDevice; import cc.iotkit.model.ota.OtaPackage; import lombok.RequiredArgsConstructor; -import org.apache.commons.lang3.StringUtils; import org.springframework.context.annotation.Primary; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.List; -import java.util.UUID; import java.util.stream.Collectors; /** diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/OauthClientDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/OauthClientDataImpl.java index 26f64ce2..ab282f65 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/OauthClientDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/OauthClientDataImpl.java @@ -9,23 +9,18 @@ */ package cc.iotkit.data.service; -import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.dao.IJPACommData; -import cc.iotkit.data.manager.IOauthClientData; import cc.iotkit.data.dao.OauthClientRepository; +import cc.iotkit.data.manager.IOauthClientData; import cc.iotkit.data.model.TbOauthClient; import cc.iotkit.model.OauthClient; -import cc.iotkit.common.api.Paging; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; import java.util.UUID; @Primary diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProductModelDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProductModelDataImpl.java index 96ea2c62..838280f4 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProductModelDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProductModelDataImpl.java @@ -1,12 +1,10 @@ package cc.iotkit.data.service; -import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.dao.IJPACommData; -import cc.iotkit.data.manager.IProductModelData; import cc.iotkit.data.dao.ProductModelRepository; +import cc.iotkit.data.manager.IProductModelData; import cc.iotkit.data.model.TbProductModel; -import cc.iotkit.common.api.Paging; import cc.iotkit.model.product.ProductModel; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -14,8 +12,8 @@ import org.springframework.context.annotation.Primary; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; -import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.UUID; @@ -59,7 +57,7 @@ public class ProductModelDataImpl implements IProductModelData, IJPACommData findByIds(Collection id) { - return null; + return Collections.emptyList(); } @Override diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolComponentDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolComponentDataImpl.java index 2869c7cd..32171a09 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolComponentDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolComponentDataImpl.java @@ -20,6 +20,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.UUID; @@ -80,7 +81,7 @@ public class ProtocolComponentDataImpl implements IProtocolComponentData, IJPACo @Override public List findByIds(Collection id) { - return null; + return Collections.emptyList(); } @Override @@ -105,7 +106,7 @@ public class ProtocolComponentDataImpl implements IProtocolComponentData, IJPACo @Override public Paging findAll(PageRequest pageRequest) { - ProtocolComponent query = pageRequest.getData(); + Predicate predicate = PredicateBuilder.instance() .build(); Page all = protocolComponentRepository.findAll(predicate, PageBuilder.toPageable(pageRequest)); diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolConverterDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolConverterDataImpl.java index 031b7b62..c25ef3b6 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolConverterDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolConverterDataImpl.java @@ -9,13 +9,12 @@ */ package cc.iotkit.data.service; -import cc.iotkit.common.api.PageRequest; +import cc.iotkit.common.api.Paging; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.dao.IJPACommData; -import cc.iotkit.data.manager.IProtocolConverterData; import cc.iotkit.data.dao.ProtocolConverterRepository; +import cc.iotkit.data.manager.IProtocolConverterData; import cc.iotkit.data.model.TbProtocolConverter; -import cc.iotkit.common.api.Paging; import cc.iotkit.model.protocol.ProtocolConverter; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -26,6 +25,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.UUID; @@ -79,7 +79,7 @@ public class ProtocolConverterDataImpl implements IProtocolConverterData, IJPACo @Override public List findByIds(Collection id) { - return null; + return Collections.emptyList(); } @Override diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDataImpl.java index cec9ad06..39ae8482 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDataImpl.java @@ -1,12 +1,11 @@ package cc.iotkit.data.service; -import cc.iotkit.common.api.PageRequest; +import cc.iotkit.common.api.Paging; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.dao.IJPACommData; -import cc.iotkit.data.manager.ISpaceData; import cc.iotkit.data.dao.SpaceRepository; +import cc.iotkit.data.manager.ISpaceData; import cc.iotkit.data.model.TbSpace; -import cc.iotkit.common.api.Paging; import cc.iotkit.model.space.Space; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -16,7 +15,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; -import java.util.Collection; import java.util.List; import java.util.UUID; diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDeviceDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDeviceDataImpl.java index 0104ddaa..b3822dd1 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDeviceDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDeviceDataImpl.java @@ -9,13 +9,12 @@ */ package cc.iotkit.data.service; -import cc.iotkit.common.api.PageRequest; +import cc.iotkit.common.api.Paging; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.dao.IJPACommData; -import cc.iotkit.data.manager.ISpaceDeviceData; import cc.iotkit.data.dao.SpaceDeviceRepository; +import cc.iotkit.data.manager.ISpaceDeviceData; import cc.iotkit.data.model.TbSpaceDevice; -import cc.iotkit.common.api.Paging; import cc.iotkit.model.space.SpaceDevice; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -23,7 +22,6 @@ import org.springframework.context.annotation.Primary; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; -import java.util.Collection; import java.util.List; import java.util.UUID; diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java index 1e99822a..e9f9e71e 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java @@ -134,7 +134,7 @@ public class SysMenuDataImpl implements ISysMenuData, IJPACommData selectMenuPermsByUserId(Long userId) { - List menuIds = jpaQueryFactory.select(tbSysMenu.perms) + return jpaQueryFactory.select(tbSysMenu.perms) .from(tbSysMenu) .leftJoin(tbSysRoleMenu).on(tbSysMenu.id.eq(tbSysRoleMenu.menuId)) .leftJoin(tbSysUserRole).on(tbSysRoleMenu.roleId.eq(tbSysUserRole.roleId)) @@ -144,7 +144,6 @@ public class SysMenuDataImpl implements ISysMenuData, IJPACommData findByRuleId(String ruleId, int page, int size) { Page paged = ruleLogRepository.findByRuleId(ruleId, Pageable.ofSize(size).withPage(page - 1)); return new Paging<>(paged.getTotalElements(), - paged.getContent().stream().map(o->{ - return MapstructUtils.convert(o, RuleLog.class); - }) + paged.getContent().stream().map(o -> MapstructUtils.convert(o, RuleLog.class)) .collect(Collectors.toList())); } diff --git a/iot-common/iot-common-dao/iot-temporal-serviceImpl-es/src/main/java/cc/iotkit/temporal/es/service/TaskLogDataImpl.java b/iot-common/iot-common-dao/iot-temporal-serviceImpl-es/src/main/java/cc/iotkit/temporal/es/service/TaskLogDataImpl.java index c753ac7e..798250f6 100644 --- a/iot-common/iot-common-dao/iot-temporal-serviceImpl-es/src/main/java/cc/iotkit/temporal/es/service/TaskLogDataImpl.java +++ b/iot-common/iot-common-dao/iot-temporal-serviceImpl-es/src/main/java/cc/iotkit/temporal/es/service/TaskLogDataImpl.java @@ -37,7 +37,7 @@ public class TaskLogDataImpl implements ITaskLogData { public Paging findByTaskId(String taskId, int page, int size) { Page paged = taskLogRepository.findByTaskId(taskId, Pageable.ofSize(size).withPage(page - 1)); return new Paging<>(paged.getTotalElements(), - paged.getContent().stream().map(o->{return MapstructUtils.convert(o, TaskLog.class);}) + paged.getContent().stream().map(o -> MapstructUtils.convert(o, TaskLog.class)) .collect(Collectors.toList())); } diff --git a/iot-common/iot-common-dao/iot-temporal-serviceImpl-es/src/main/java/cc/iotkit/temporal/es/service/VirtualDeviceLogDataImpl.java b/iot-common/iot-common-dao/iot-temporal-serviceImpl-es/src/main/java/cc/iotkit/temporal/es/service/VirtualDeviceLogDataImpl.java index 5e9fd9e5..a59f264d 100644 --- a/iot-common/iot-common-dao/iot-temporal-serviceImpl-es/src/main/java/cc/iotkit/temporal/es/service/VirtualDeviceLogDataImpl.java +++ b/iot-common/iot-common-dao/iot-temporal-serviceImpl-es/src/main/java/cc/iotkit/temporal/es/service/VirtualDeviceLogDataImpl.java @@ -20,7 +20,6 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; -import java.util.Map; import java.util.stream.Collectors; @Service diff --git a/iot-common/iot-common-dao/iot-temporal-serviceImpl-ts/src/main/java/cc/iotkit/temporal/ts/service/TaskLogDataImpl.java b/iot-common/iot-common-dao/iot-temporal-serviceImpl-ts/src/main/java/cc/iotkit/temporal/ts/service/TaskLogDataImpl.java index 1b4b88ef..a6b1ca22 100644 --- a/iot-common/iot-common-dao/iot-temporal-serviceImpl-ts/src/main/java/cc/iotkit/temporal/ts/service/TaskLogDataImpl.java +++ b/iot-common/iot-common-dao/iot-temporal-serviceImpl-ts/src/main/java/cc/iotkit/temporal/ts/service/TaskLogDataImpl.java @@ -31,8 +31,6 @@ import java.util.stream.Collectors; import static org.jooq.impl.DSL.field; import static org.jooq.impl.DSL.table; -//import cc.iotkit.temporal.ts.dm.TableManager; - @Service public class TaskLogDataImpl implements ITaskLogData { @@ -62,9 +60,9 @@ public class TaskLogDataImpl implements ITaskLogData { .where(field("task_id").eq(taskId)).getSQL(ParamType.INLINED); Long count = tsTemplate.queryForObject(whereSql, new BeanPropertyRowMapper<>(Long.class)); - return new Paging<>(count , taskLogs.stream().map(r -> - new TaskLog(r.getTime().toString(), taskId, - r.getContent(), r.getSuccess(), r.getTime())) + return new Paging<>(count, taskLogs.stream().map(r -> + new TaskLog(r.getTime().toString(), taskId, + r.getContent(), r.getSuccess(), r.getTime())) .collect(Collectors.toList())); } @@ -76,7 +74,7 @@ public class TaskLogDataImpl implements ITaskLogData { field("time"), field("task_id"), field("content"), field("success")).values( - new Date(), + new Date(), log.getTaskId(), log.getContent(), log.getSuccess()); diff --git a/iot-common/iot-common-dao/iot-temporal-serviceImpl-ts/src/main/java/cc/iotkit/temporal/ts/service/ThingModelMessageDataImpl.java b/iot-common/iot-common-dao/iot-temporal-serviceImpl-ts/src/main/java/cc/iotkit/temporal/ts/service/ThingModelMessageDataImpl.java index 7a0abfd8..7cbab640 100644 --- a/iot-common/iot-common-dao/iot-temporal-serviceImpl-ts/src/main/java/cc/iotkit/temporal/ts/service/ThingModelMessageDataImpl.java +++ b/iot-common/iot-common-dao/iot-temporal-serviceImpl-ts/src/main/java/cc/iotkit/temporal/ts/service/ThingModelMessageDataImpl.java @@ -47,7 +47,7 @@ public class ThingModelMessageDataImpl implements IThingModelMessageData { Condition whereConditions = field("device_id").eq(deviceId); SelectJoinStep> step = TableManager.getSqlBuilder().select(field("time"), field("mid"), field("product_key"), field("device_name"), field("type"), - field("identifier"), field("code"), field("data"), + field(zhe "identifier"), field("code"), field("data"), field("report_time")).from(table); diff --git a/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/dm/TableManager.java b/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/dm/TableManager.java index 95908880..2d2a664c 100644 --- a/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/dm/TableManager.java +++ b/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/dm/TableManager.java @@ -47,7 +47,7 @@ public class TableManager { * 获取创建表sql */ public static String getCreateSTableSql(String tbName, List fields, TdField... tags) { - if (fields.size() == 0) { + if (fields.isEmpty()) { return null; } diff --git a/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/DbStructureDataImpl.java b/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/DbStructureDataImpl.java index e8143cdc..3a8748db 100644 --- a/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/DbStructureDataImpl.java +++ b/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/DbStructureDataImpl.java @@ -78,7 +78,7 @@ public class DbStructureDataImpl implements IDbStructureData { List addFields = newFields.stream().filter((f) -> oldFields.stream() .noneMatch(old -> old.getName().equals(f.getName()))) .collect(Collectors.toList()); - if (addFields.size() > 0) { + if (!addFields.isEmpty()) { sql = TableManager.getAddSTableColumnSql(tbName, addFields); response = tdRestApi.execSql(sql); if (response.getCode() != TdResponse.CODE_SUCCESS) { @@ -95,7 +95,7 @@ public class DbStructureDataImpl implements IDbStructureData { )) .collect(Collectors.toList()); - if (modifyFields.size() > 0) { + if (!modifyFields.isEmpty()) { sql = TableManager.getModifySTableColumnSql(tbName, modifyFields); response = tdRestApi.execSql(sql); if (response.getCode() != TdResponse.CODE_SUCCESS) { @@ -110,7 +110,7 @@ public class DbStructureDataImpl implements IDbStructureData { //字段名不是time且没有相同字段名的 .noneMatch(n -> n.getName().equals(f.getName()))) .collect(Collectors.toList()); - if (dropFields.size() > 0) { + if (!dropFields.isEmpty()) { sql = TableManager.getDropSTableColumnSql(tbName, dropFields); response = tdRestApi.execSql(sql); if (response.getCode() != TdResponse.CODE_SUCCESS) { diff --git a/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/RuleLogDataImpl.java b/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/RuleLogDataImpl.java index e5ba93b6..d2cc30ec 100644 --- a/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/RuleLogDataImpl.java +++ b/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/RuleLogDataImpl.java @@ -43,9 +43,9 @@ public class RuleLogDataImpl implements IRuleLogData { sql = "select count(*) from rule_log where rule_id=?"; List counts = tdTemplate.queryForList(sql, Long.class, ruleId); - return new Paging<>(counts.size() > 0 ? counts.get(0) : 0, ruleLogs.stream().map(r -> - new RuleLog(r.getTime().toString(), ruleId, r.getState1(), - r.getContent(), r.getSuccess(), r.getTime())) + return new Paging<>(!counts.isEmpty() ? counts.get(0) : 0, ruleLogs.stream().map(r -> + new RuleLog(r.getTime().toString(), ruleId, r.getState1(), + r.getContent(), r.getSuccess(), r.getTime())) .collect(Collectors.toList())); } diff --git a/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/TaskLogDataImpl.java b/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/TaskLogDataImpl.java index a2f476fc..a754011f 100644 --- a/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/TaskLogDataImpl.java +++ b/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/TaskLogDataImpl.java @@ -42,9 +42,9 @@ public class TaskLogDataImpl implements ITaskLogData { sql = "select count(*) from task_log where task_id=?"; List counts = tdTemplate.queryForList(sql, Long.class, taskId); - return new Paging<>(counts.size() > 0 ? counts.get(0) : 0, taskLogs.stream().map(r -> - new TaskLog(r.getTime().toString(), taskId, - r.getContent(), r.getSuccess(), r.getTime())) + return new Paging<>(!counts.isEmpty() ? counts.get(0) : 0, taskLogs.stream().map(r -> + new TaskLog(r.getTime().toString(), taskId, + r.getContent(), r.getSuccess(), r.getTime())) .collect(Collectors.toList())); } diff --git a/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/ThingModelMessageDataImpl.java b/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/ThingModelMessageDataImpl.java index 50440f64..84ed0a8d 100644 --- a/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/ThingModelMessageDataImpl.java +++ b/iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/ThingModelMessageDataImpl.java @@ -9,8 +9,8 @@ */ package cc.iotkit.temporal.td.service; -import cc.iotkit.common.utils.JsonUtils; import cc.iotkit.common.api.Paging; +import cc.iotkit.common.utils.JsonUtils; import cc.iotkit.model.device.message.ThingModelMessage; import cc.iotkit.model.stats.TimeData; import cc.iotkit.temporal.IThingModelMessageData; @@ -61,7 +61,7 @@ public class ThingModelMessageDataImpl implements IThingModelMessageData { sql = String.format("select count(*) from thing_model_message where device_id=? %s", sbCond.toString()); List counts = tdTemplate.queryForList(sql, Long.class, args.toArray()); - long count = counts.size() > 0 ? counts.get(0) : 0; + long count = !counts.isEmpty() ? counts.get(0) : 0; return new Paging<>(count, ruleLogs.stream().map(r -> new ThingModelMessage(r.getTime().toString(), r.getMid(), @@ -110,6 +110,6 @@ public class ThingModelMessageDataImpl implements IThingModelMessageData { @Override public long count() { List counts = tdTemplate.queryForList("select count(*) from thing_model_message", Long.class); - return counts.size() > 0 ? counts.get(0) : 0; + return !counts.isEmpty() ? counts.get(0) : 0; } } diff --git a/iot-common/iot-common-doc/src/main/java/cc/iotkit/swagger/config/SwaggerConfig.java b/iot-common/iot-common-doc/src/main/java/cc/iotkit/swagger/config/SwaggerConfig.java index 0b09af70..ad57d232 100644 --- a/iot-common/iot-common-doc/src/main/java/cc/iotkit/swagger/config/SwaggerConfig.java +++ b/iot-common/iot-common-doc/src/main/java/cc/iotkit/swagger/config/SwaggerConfig.java @@ -1,8 +1,5 @@ package cc.iotkit.swagger.config; -import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.Value; @@ -10,18 +7,17 @@ import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Component; import org.springframework.util.ReflectionUtils; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping; -import springfox.documentation.builders.*; -import springfox.documentation.service.*; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider; import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; - import java.lang.reflect.Field; -import java.util.ArrayList; import java.util.List; /** diff --git a/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/annotation/CellMerge.java b/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/annotation/CellMerge.java index 82bd3329..91d6a47f 100644 --- a/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/annotation/CellMerge.java +++ b/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/annotation/CellMerge.java @@ -1,6 +1,8 @@ package cc.iotkit.common.excel.annotation; +import cc.iotkit.common.excel.core.CellMergeStrategy; + import java.lang.annotation.*; /** diff --git a/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/core/CellMergeStrategy.java b/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/core/CellMergeStrategy.java index 702c8b3f..392a9de2 100644 --- a/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/core/CellMergeStrategy.java +++ b/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/core/CellMergeStrategy.java @@ -28,8 +28,8 @@ import java.util.Map; @Slf4j public class CellMergeStrategy extends AbstractMergeStrategy { - private final List list; - private final boolean hasTitle; + private final List list; + private final boolean hasTitle; private int rowIndex; public CellMergeStrategy(List list, boolean hasTitle) { @@ -40,83 +40,79 @@ public class CellMergeStrategy extends AbstractMergeStrategy { } @Override - protected void merge(Sheet sheet, Cell cell, Head head, Integer relativeRowIndex) { - List cellList = handle(list, hasTitle); - // judge the list is not null - if (CollUtil.isNotEmpty(cellList)) { - // the judge is necessary - if (cell.getRowIndex() == rowIndex && cell.getColumnIndex() == 0) { - for (CellRangeAddress item : cellList) { - sheet.addMergedRegion(item); - } - } - } - } + protected void merge(Sheet sheet, Cell cell, Head head, Integer relativeRowIndex) { + List cellList = handle(list, hasTitle); + // the judge is necessary + if (CollUtil.isNotEmpty(cellList) && cell.getRowIndex() == rowIndex && cell.getColumnIndex() == 0) { + for (CellRangeAddress item : cellList) { + sheet.addMergedRegion(item); + } + } + } - @SneakyThrows - private List handle(List list, boolean hasTitle) { - List cellList = new ArrayList<>(); - if (CollUtil.isEmpty(list)) { - return cellList; - } + @SneakyThrows + private List handle(List list, boolean hasTitle) { + List cellList = new ArrayList<>(); + if (CollUtil.isEmpty(list)) { + return cellList; + } Field[] fields = ReflectUtils.getFields(list.get(0).getClass(), field -> !"serialVersionUID".equals(field.getName())); - // 有注解的字段 - List mergeFields = new ArrayList<>(); - List mergeFieldsIndex = new ArrayList<>(); - for (int i = 0; i < fields.length; i++) { - Field field = fields[i]; - if (field.isAnnotationPresent(CellMerge.class)) { - CellMerge cm = field.getAnnotation(CellMerge.class); + // 有注解的字段 + List mergeFields = new ArrayList<>(); + List mergeFieldsIndex = new ArrayList<>(); + for (int i = 0; i < fields.length; i++) { + Field field = fields[i]; + if (field.isAnnotationPresent(CellMerge.class)) { + CellMerge cm = field.getAnnotation(CellMerge.class); mergeFields.add(field); mergeFieldsIndex.add(cm.index() == -1 ? i : cm.index()); if (hasTitle) { ExcelProperty property = field.getAnnotation(ExcelProperty.class); rowIndex = Math.max(rowIndex, property.value().length); } - } - } + } + } - Map map = new HashMap<>(); - // 生成两两合并单元格 - for (int i = 0; i < list.size(); i++) { - for (int j = 0; j < mergeFields.size(); j++) { - Field field = mergeFields.get(j); + Map map = new HashMap<>(); + // 生成两两合并单元格 + for (int i = 0; i < list.size(); i++) { + for (int j = 0; j < mergeFields.size(); j++) { + Field field = mergeFields.get(j); Object val = ReflectUtils.invokeGetter(list.get(i), field.getName()); - int colNum = mergeFieldsIndex.get(j); - if (!map.containsKey(field)) { - map.put(field, new RepeatCell(val, i)); - } else { - RepeatCell repeatCell = map.get(field); - Object cellValue = repeatCell.getValue(); - if (cellValue == null || "".equals(cellValue)) { - // 空值跳过不合并 - continue; - } - if (!cellValue.equals(val)) { - if (i - repeatCell.getCurrent() > 1) { - cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex - 1, colNum, colNum)); - } - map.put(field, new RepeatCell(val, i)); - } else if (i == list.size() - 1) { - if (i > repeatCell.getCurrent()) { - cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex, colNum, colNum)); - } - } - } - } - } - return cellList; - } + int colNum = mergeFieldsIndex.get(j); + if (!map.containsKey(field)) { + map.put(field, new RepeatCell(val, i)); + } else { + RepeatCell repeatCell = map.get(field); + Object cellValue = repeatCell.getValue(); + if (cellValue == null || "".equals(cellValue)) { + // 空值跳过不合并 + continue; + } + if (!cellValue.equals(val)) { + if (i - repeatCell.getCurrent() > 1) { + cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex - 1, colNum, colNum)); + } + map.put(field, new RepeatCell(val, i)); + } else if ((i == list.size() - 1) && (i > repeatCell.getCurrent())) { + cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex, colNum, colNum)); - @Data - @AllArgsConstructor - static class RepeatCell { + } + } + } + } + return cellList; + } - private Object value; + @Data + @AllArgsConstructor + static class RepeatCell { - private int current; + private Object value; - } + private int current; + + } } diff --git a/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/core/DefaultExcelListener.java b/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/core/DefaultExcelListener.java index 9e7381d0..8c937288 100644 --- a/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/core/DefaultExcelListener.java +++ b/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/core/DefaultExcelListener.java @@ -4,7 +4,6 @@ import cc.iotkit.common.utils.JsonUtils; import cc.iotkit.common.utils.StreamUtils; import cc.iotkit.common.utils.ValidatorUtils; import cn.hutool.core.text.CharSequenceUtil; -import cn.hutool.core.util.StrUtil; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.exception.ExcelAnalysisException; @@ -88,7 +87,7 @@ public class DefaultExcelListener extends AnalysisEventListener implements @Override public void invoke(T data, AnalysisContext context) { - if (isValidate) { + if (Boolean.TRUE.equals(isValidate)) { ValidatorUtils.validate(data); } excelResult.getList().add(data); diff --git a/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/core/DefaultExcelResult.java b/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/core/DefaultExcelResult.java index 2a6d5396..571d3bac 100644 --- a/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/core/DefaultExcelResult.java +++ b/iot-common/iot-common-excel/src/main/java/cc/iotkit/common/excel/core/DefaultExcelResult.java @@ -1,7 +1,6 @@ package cc.iotkit.common.excel.core; import cn.hutool.core.text.CharSequenceUtil; -import cn.hutool.core.util.StrUtil; import lombok.Setter; import java.util.ArrayList; diff --git a/iot-common/iot-common-log/src/main/java/cc/iotkit/common/log/aspect/LogAspect.java b/iot-common/iot-common-log/src/main/java/cc/iotkit/common/log/aspect/LogAspect.java index f3088ccf..1f224c6e 100644 --- a/iot-common/iot-common-log/src/main/java/cc/iotkit/common/log/aspect/LogAspect.java +++ b/iot-common/iot-common-log/src/main/java/cc/iotkit/common/log/aspect/LogAspect.java @@ -152,7 +152,7 @@ public class LogAspect { * @param operLog 操作日志 * @throws Exception 异常 */ - private void setRequestValue(JoinPoint joinPoint, OperLogEvent operLog, String[] excludeParamNames) throws Exception { + private void setRequestValue(JoinPoint joinPoint, OperLogEvent operLog, String[] excludeParamNames) { Map paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest()); String requestMethod = operLog.getRequestMethod(); if (MapUtil.isEmpty(paramsMap) diff --git a/iot-common/iot-common-oss/src/main/java/cc/iotkit/common/oss/core/OssClient.java b/iot-common/iot-common-oss/src/main/java/cc/iotkit/common/oss/core/OssClient.java index 1b5b863d..fc22cb80 100644 --- a/iot-common/iot-common-oss/src/main/java/cc/iotkit/common/oss/core/OssClient.java +++ b/iot-common/iot-common-oss/src/main/java/cc/iotkit/common/oss/core/OssClient.java @@ -1,6 +1,9 @@ package cc.iotkit.common.oss.core; import cc.iotkit.common.oss.constant.OssConstant; +import cc.iotkit.common.oss.entity.UploadResult; +import cc.iotkit.common.oss.enumd.AccessPolicyType; +import cc.iotkit.common.oss.enumd.PolicyType; import cc.iotkit.common.oss.exception.OssException; import cc.iotkit.common.oss.properties.OssProperties; import cc.iotkit.common.utils.DateUtils; @@ -19,9 +22,6 @@ import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.AmazonS3ClientBuilder; import com.amazonaws.services.s3.model.*; -import cc.iotkit.common.oss.entity.UploadResult; -import cc.iotkit.common.oss.enumd.AccessPolicyType; -import cc.iotkit.common.oss.enumd.PolicyType; import java.io.ByteArrayInputStream; import java.io.InputStream; diff --git a/iot-common/iot-common-oss/src/main/java/cc/iotkit/common/oss/enumd/AccessPolicyType.java b/iot-common/iot-common-oss/src/main/java/cc/iotkit/common/oss/enumd/AccessPolicyType.java index 533cc412..b3c60182 100644 --- a/iot-common/iot-common-oss/src/main/java/cc/iotkit/common/oss/enumd/AccessPolicyType.java +++ b/iot-common/iot-common-oss/src/main/java/cc/iotkit/common/oss/enumd/AccessPolicyType.java @@ -1,5 +1,6 @@ package cc.iotkit.common.oss.enumd; +import cc.iotkit.common.exception.BizException; import com.amazonaws.services.s3.model.CannedAccessControlList; import lombok.AllArgsConstructor; import lombok.Getter; @@ -49,7 +50,7 @@ public enum AccessPolicyType { return value; } } - throw new RuntimeException("'type' not found By " + type); + throw new BizException("'type' not found By " + type); } } diff --git a/iot-common/iot-common-satoken/src/main/java/cc/iotkit/common/satoken/core/service/SaPermissionImpl.java b/iot-common/iot-common-satoken/src/main/java/cc/iotkit/common/satoken/core/service/SaPermissionImpl.java index 9c421b08..544696fd 100644 --- a/iot-common/iot-common-satoken/src/main/java/cc/iotkit/common/satoken/core/service/SaPermissionImpl.java +++ b/iot-common/iot-common-satoken/src/main/java/cc/iotkit/common/satoken/core/service/SaPermissionImpl.java @@ -1,8 +1,8 @@ package cc.iotkit.common.satoken.core.service; -import cc.iotkit.common.undefined.LoginUser; import cc.iotkit.common.enums.UserType; import cc.iotkit.common.satoken.utils.LoginHelper; +import cc.iotkit.common.undefined.LoginUser; import cn.dev33.satoken.stp.StpInterface; import java.util.ArrayList; diff --git a/iot-common/iot-common-satoken/src/main/java/cc/iotkit/common/satoken/utils/LoginHelper.java b/iot-common/iot-common-satoken/src/main/java/cc/iotkit/common/satoken/utils/LoginHelper.java index bea9fbbe..89707ca9 100644 --- a/iot-common/iot-common-satoken/src/main/java/cc/iotkit/common/satoken/utils/LoginHelper.java +++ b/iot-common/iot-common-satoken/src/main/java/cc/iotkit/common/satoken/utils/LoginHelper.java @@ -2,14 +2,13 @@ package cc.iotkit.common.satoken.utils; import cc.iotkit.common.constant.TenantConstants; import cc.iotkit.common.constant.UserConstants; -import cc.iotkit.common.undefined.LoginUser; import cc.iotkit.common.enums.DeviceType; import cc.iotkit.common.enums.UserType; +import cc.iotkit.common.undefined.LoginUser; import cn.dev33.satoken.context.SaHolder; import cn.dev33.satoken.context.model.SaStorage; import cn.dev33.satoken.stp.SaLoginModel; import cn.dev33.satoken.stp.StpUtil; -import cn.hutool.core.convert.Convert; import cn.hutool.core.util.ObjectUtil; import lombok.AccessLevel; import lombok.NoArgsConstructor; diff --git a/iot-common/iot-common-tenant/src/main/java/cc/iotkit/common/tenant/helper/TenantHelper.java b/iot-common/iot-common-tenant/src/main/java/cc/iotkit/common/tenant/helper/TenantHelper.java index 86231d77..6151e8df 100644 --- a/iot-common/iot-common-tenant/src/main/java/cc/iotkit/common/tenant/helper/TenantHelper.java +++ b/iot-common/iot-common-tenant/src/main/java/cc/iotkit/common/tenant/helper/TenantHelper.java @@ -13,8 +13,6 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; -import java.util.function.Supplier; - /** * 租户助手 * diff --git a/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/handler/ResponseResultHandler.java b/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/handler/ResponseResultHandler.java index d0bd31b8..63c5263b 100644 --- a/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/handler/ResponseResultHandler.java +++ b/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/handler/ResponseResultHandler.java @@ -10,7 +10,6 @@ package cc.iotkit.common.web.handler; import cc.iotkit.common.api.Response; -import cc.iotkit.common.utils.JsonUtils; import cn.dev33.satoken.util.SaResult; import cn.hutool.core.util.IdUtil; import org.springframework.core.MethodParameter; diff --git a/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/interceptor/PlusWebInvokeTimeInterceptor.java b/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/interceptor/PlusWebInvokeTimeInterceptor.java index 7a5d02ff..d6de8145 100644 --- a/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/interceptor/PlusWebInvokeTimeInterceptor.java +++ b/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/interceptor/PlusWebInvokeTimeInterceptor.java @@ -30,7 +30,7 @@ import java.util.Map; @Slf4j public class PlusWebInvokeTimeInterceptor implements HandlerInterceptor { - private final String prodProfile = "prod"; + private final static String prodProfile = "prod"; private final TransmittableThreadLocal invokeTimeTL = new TransmittableThreadLocal<>(); diff --git a/iot-common/iot-message-bus/iot-message-event-bus/src/main/java/cc/iotkit/vertx/VertxMqProducer.java b/iot-common/iot-message-bus/iot-message-event-bus/src/main/java/cc/iotkit/vertx/VertxMqProducer.java index 531ed616..60e78cf1 100644 --- a/iot-common/iot-message-bus/iot-message-event-bus/src/main/java/cc/iotkit/vertx/VertxMqProducer.java +++ b/iot-common/iot-message-bus/iot-message-event-bus/src/main/java/cc/iotkit/vertx/VertxMqProducer.java @@ -2,8 +2,6 @@ package cc.iotkit.vertx; import cc.iotkit.mq.MqProducer; import io.vertx.core.AbstractVerticle; -import io.vertx.core.AsyncResult; -import io.vertx.core.Handler; import io.vertx.core.eventbus.DeliveryOptions; import io.vertx.core.eventbus.EventBus; import lombok.SneakyThrows; diff --git a/iot-common/iot-message-bus/iot-message-rocketmq/src/main/java/cc/iotkit/rocketmq/RocketMqConsumer.java b/iot-common/iot-message-bus/iot-message-rocketmq/src/main/java/cc/iotkit/rocketmq/RocketMqConsumer.java index e630be08..d95f685e 100644 --- a/iot-common/iot-message-bus/iot-message-rocketmq/src/main/java/cc/iotkit/rocketmq/RocketMqConsumer.java +++ b/iot-common/iot-message-bus/iot-message-rocketmq/src/main/java/cc/iotkit/rocketmq/RocketMqConsumer.java @@ -8,7 +8,6 @@ import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; import org.apache.rocketmq.common.message.MessageExt; -import org.springframework.beans.factory.annotation.Value; import java.nio.charset.StandardCharsets; From 2fc754bf87b1ef92c94029c09800ea39f2803084 Mon Sep 17 00:00:00 2001 From: xiwa Date: Fri, 7 Jul 2023 23:27:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=E5=90=88=E5=B9=B6pr=5F15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ts/service/ThingModelMessageDataImpl.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/iot-common/iot-common-dao/iot-temporal-serviceImpl-ts/src/main/java/cc/iotkit/temporal/ts/service/ThingModelMessageDataImpl.java b/iot-common/iot-common-dao/iot-temporal-serviceImpl-ts/src/main/java/cc/iotkit/temporal/ts/service/ThingModelMessageDataImpl.java index 7cbab640..3d01bfa2 100644 --- a/iot-common/iot-common-dao/iot-temporal-serviceImpl-ts/src/main/java/cc/iotkit/temporal/ts/service/ThingModelMessageDataImpl.java +++ b/iot-common/iot-common-dao/iot-temporal-serviceImpl-ts/src/main/java/cc/iotkit/temporal/ts/service/ThingModelMessageDataImpl.java @@ -47,7 +47,7 @@ public class ThingModelMessageDataImpl implements IThingModelMessageData { Condition whereConditions = field("device_id").eq(deviceId); SelectJoinStep> step = TableManager.getSqlBuilder().select(field("time"), field("mid"), field("product_key"), field("device_name"), field("type"), - field(zhe "identifier"), field("code"), field("data"), + field("identifier"), field("code"), field("data"), field("report_time")).from(table); @@ -68,11 +68,11 @@ public class ThingModelMessageDataImpl implements IThingModelMessageData { Long count = tsTemplate.queryForObject(countSql, Long.class); return new Paging<>(count, ruleLogs.stream().map(r -> - new ThingModelMessage(r.getTime().toString(), r.getMid(), - deviceId, r.getProductKey(), r.getDeviceName(), - r.getUid(), r.getType(), r.getIdentifier(), r.getCode(), - r.getData(), - r.getTime().getTime(), r.getReportTime())) + new ThingModelMessage(r.getTime().toString(), r.getMid(), + deviceId, r.getProductKey(), r.getDeviceName(), + r.getUid(), r.getType(), r.getIdentifier(), r.getCode(), + r.getData(), + r.getTime().getTime(), r.getReportTime())) .collect(Collectors.toList())); } @@ -82,11 +82,11 @@ public class ThingModelMessageDataImpl implements IThingModelMessageData { Table table = table("thing_model_message"); Condition con = field("time").greaterOrEqual(new Date(start)).and(field("time").lessOrEqual(new Date(end))); - if(StringUtils.isNotBlank(uid)){ + if (StringUtils.isNotBlank(uid)) { con.and(field("uid").eq(uid)); } - String sql = TableManager.getSqlBuilder().select(field("date_trunc('hour', \"time\")").as("time"),field("count(*)").as("data")) + String sql = TableManager.getSqlBuilder().select(field("date_trunc('hour', \"time\")").as("time"), field("count(*)").as("data")) .from(table).where(con).groupBy(field("date_trunc('hour', \"time\")")).orderBy(field("time").asc()).getSQL(ParamType.INLINED); @@ -105,16 +105,16 @@ public class ThingModelMessageDataImpl implements IThingModelMessageData { Table table = table("thing_model_message"); String sql = TableManager.getSqlBuilder().insertInto(table, - field("time"), - field("device_id"), - field("mid"), - field("product_key"), - field("device_name"), - field("uid"), - field("type"), - field("identifier"), - field("code"), - field("data"), field("report_time")) + field("time"), + field("device_id"), + field("mid"), + field("product_key"), + field("device_name"), + field("uid"), + field("type"), + field("identifier"), + field("code"), + field("data"), field("report_time")) .values(new Date(msg.getOccurred()), msg.getDeviceId(), msg.getMid(), msg.getProductKey(), msg.getDeviceName(), msg.getUid(), msg.getType(),