Merge branch 'pr_15' into dev-V0.4.5

V0.5.x
xiwa 2023-07-07 23:29:18 +08:00
commit cab2c85d81
82 changed files with 186 additions and 309 deletions

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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));
}

View File

@ -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();

View File

@ -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<Dict> 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));

View File

@ -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 <T, V> List<V> convert(List<T> sourceList, Class<V> desc) {
if (ObjectUtil.isNull(sourceList)) {
return null;
return Collections.emptyList();
}
if (CollUtil.isEmpty(sourceList)) {
return CollUtil.newArrayList();

View File

@ -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 <T, K> List<Tree<K>> build(List<T> list, NodeParser<T, K> 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);

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
/**

View File

@ -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<Category> findByIds(Collection<String> id) {
return null;
return Collections.emptyList();
}
@Override
@ -73,7 +74,7 @@ public class CategoryDataCache implements ICategoryData {
@Override
public List<Category> findAllByCondition(Category data) {
return null;
return Collections.emptyList();
}
@Override

View File

@ -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<DeviceInfo> devices = paged.getRows();
for (DeviceInfo device : devices) {
@ -282,7 +282,7 @@ public class DeviceInfoDataCache implements IDeviceInfoData, SmartInitializingSi
@Override
public List<DeviceInfo> findAllByCondition(DeviceInfo data) {
return null;
return Collections.emptyList();
}
@Override

View File

@ -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<OauthClient> findByIds(Collection<String> id) {
return null;
return Collections.emptyList();
}
@Override
@ -88,7 +89,7 @@ public class OauthClientDataCache implements IOauthClientData {
@Override
public List<OauthClient> findAllByCondition(OauthClient data) {
return null;
return Collections.emptyList();
}
@Override

View File

@ -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<TbDeviceGroup, String> {
Page<TbDeviceGroup> findByNameLike(String name, Pageable pageable);

View File

@ -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;

View File

@ -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>, ID> extends ICommonData<T , ID
Class getTClass();
@Override
default T findById(ID id) {
return (T) MapstructUtils.convert(getBaseRepository().findById(id).orElse(null), getTClass());
}

View File

@ -9,7 +9,6 @@
*/
package cc.iotkit.data.dao;
import cc.iotkit.data.model.TbSysRole;
import cc.iotkit.data.model.TbSysRoleDept;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;

View File

@ -9,7 +9,6 @@
*/
package cc.iotkit.data.dao;
import cc.iotkit.data.model.TbSysRoleDept;
import cc.iotkit.data.model.TbSysRoleMenu;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;

View File

@ -1,18 +1,16 @@
package cc.iotkit.data.model;
import cc.iotkit.model.alert.AlertConfig;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import cc.iotkit.model.alert.AlertConfig;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
@Data
@Entity
//@ApiModel(value = "告警记录")

View File

@ -1,6 +1,5 @@
package cc.iotkit.data.model;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;

View File

@ -9,7 +9,6 @@
*/
package cc.iotkit.data.model;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

View File

@ -9,7 +9,6 @@
*/
package cc.iotkit.data.model;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;

View File

@ -10,7 +10,6 @@
package cc.iotkit.data.model;
import cc.iotkit.model.rule.RuleInfo;
import cc.iotkit.model.rule.RuleLog;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMapping;
import io.github.linpeilie.annotations.ReverseAutoMapping;

View File

@ -1,18 +1,16 @@
package cc.iotkit.data.model;
import cc.iotkit.data.model.BaseEntity;
import cc.iotkit.model.system.SysConfig;
import io.github.linpeilie.annotations.AutoMapper;
import javax.persistence.GeneratedValue;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
/**
* sys_config

View File

@ -1,7 +1,5 @@
package cc.iotkit.data.model;
import cc.iotkit.data.model.BaseEntity;
import cc.iotkit.model.system.SysDictData;
import cc.iotkit.model.system.SysDictType;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModel;

View File

@ -1,6 +1,5 @@
package cc.iotkit.data.model;
import cc.iotkit.data.model.BaseEntity;
import cc.iotkit.model.system.SysOss;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModel;

View File

@ -1,6 +1,5 @@
package cc.iotkit.data.model;
import cc.iotkit.data.model.BaseEntity;
import cc.iotkit.model.system.SysOssConfig;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModel;

View File

@ -1,14 +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.AlertConfigRepository;
import cc.iotkit.data.dao.IJPACommData;
import cc.iotkit.data.manager.IAlertConfigData;
import cc.iotkit.data.dao.AlertConfigRepository;
import cc.iotkit.data.model.TbAlertConfig;
import cc.iotkit.common.api.Paging;
import cc.iotkit.model.alert.AlertConfig;
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;
@ -16,10 +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;
@Primary
@Service
public class AlertConfigDataImpl implements IAlertConfigData, IJPACommData<AlertConfig, Long> {

View File

@ -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;

View File

@ -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<Category, S
@Override
public List<Category> findByIds(Collection<String> id) {
return null;
return Collections.emptyList();
}
@Override

View File

@ -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<ChannelTemplate> findAllByCondition(ChannelTemplate data) {
return null;
return Collections.emptyList();
}
@Override

View File

@ -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

View File

@ -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;

View File

@ -298,7 +298,7 @@ public class DeviceInfoDataImpl implements IDeviceInfoData, IJPACommData<DeviceI
String deviceIds = list.stream().map(d -> "'" + d.getDeviceId() + "'").collect(Collectors.joining(","));
//取设备所属分组
List<DeviceIdGroup> groups = list.size() == 0 ? new ArrayList<>() :
List<DeviceIdGroup> 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<DeviceI
@Override
public List<DeviceInfo> findAllByCondition(DeviceInfo data) {
return null;
return Collections.emptyList();
}
@Override

View File

@ -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;

View File

@ -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:

View File

@ -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;
/**

View File

@ -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

View File

@ -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<Pro
@Override
public List<ProductModel> findByIds(Collection<String> id) {
return null;
return Collections.emptyList();
}
@Override

View File

@ -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<ProtocolComponent> findByIds(Collection<String> id) {
return null;
return Collections.emptyList();
}
@Override
@ -105,7 +106,7 @@ public class ProtocolComponentDataImpl implements IProtocolComponentData, IJPACo
@Override
public Paging<ProtocolComponent> findAll(PageRequest<ProtocolComponent> pageRequest) {
ProtocolComponent query = pageRequest.getData();
Predicate predicate = PredicateBuilder.instance()
.build();
Page<TbProtocolComponent> all = protocolComponentRepository.findAll(predicate, PageBuilder.toPageable(pageRequest));

View File

@ -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<ProtocolConverter> findByIds(Collection<String> id) {
return null;
return Collections.emptyList();
}
@Override

View File

@ -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;

View File

@ -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;

View File

@ -134,7 +134,7 @@ public class SysMenuDataImpl implements ISysMenuData, IJPACommData<SysMenu, Long
@Override
public List<String> selectMenuPermsByUserId(Long userId) {
List<String> 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<SysMenu, Long
.and(tbSysRole.status.eq("0"))
.and(tbSysUserRole.userId.eq(userId))
.build()).fetch();
return menuIds;
}
@Override

View File

@ -5,14 +5,11 @@ import cc.iotkit.common.api.Paging;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.common.utils.StringUtils;
import cc.iotkit.data.dao.IJPACommData;
import cc.iotkit.data.dao.SysDeptRepository;
import cc.iotkit.data.dao.SysNoticRepository;
import cc.iotkit.data.model.TbSysNotice;
import cc.iotkit.data.system.ISysNoticeData;
import cc.iotkit.data.util.PageBuilder;
import cc.iotkit.data.util.PredicateBuilder;
import cc.iotkit.model.system.SysNotice;
import cc.iotkit.model.system.SysUser;
import com.querydsl.core.QueryResults;
import com.querydsl.core.types.Predicate;
import com.querydsl.jpa.impl.JPAQueryFactory;
@ -22,8 +19,6 @@ import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;
import java.util.List;
import static cc.iotkit.data.model.QTbSysNotice.tbSysNotice;
/**

View File

@ -1,29 +1,16 @@
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.common.utils.StringUtils;
import cc.iotkit.data.dao.IJPACommData;
import cc.iotkit.data.dao.SysOssConfigRepository;
import cc.iotkit.data.model.TbSysOssConfig;
import cc.iotkit.data.system.ISysOssConfigData;
import cc.iotkit.data.util.PageBuilder;
import cc.iotkit.data.util.PredicateBuilder;
import cc.iotkit.model.system.SysOssConfig;
import cn.hutool.core.util.ArrayUtil;
import com.querydsl.core.types.Predicate;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import static cc.iotkit.data.model.QTbSysOssConfig.tbSysOssConfig;
/**
* @Authortfd
* @Date2023/5/31 15:24

View File

@ -1,8 +1,6 @@
package cc.iotkit.data.service;
import cc.iotkit.common.api.Paging;
import cc.iotkit.data.dao.IJPACommData;
import cc.iotkit.data.dao.SysDeptRepository;
import cc.iotkit.data.dao.SysOssRepository;
import cc.iotkit.data.model.TbSysOss;
import cc.iotkit.data.system.ISysOssData;

View File

@ -12,7 +12,6 @@ import cc.iotkit.data.util.PageBuilder;
import cc.iotkit.data.util.PredicateBuilder;
import cc.iotkit.model.system.SysPost;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.Projections;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Primary;

View File

@ -3,7 +3,6 @@ package cc.iotkit.data.service;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.data.dao.IJPACommData;
import cc.iotkit.data.dao.SysRoleDeptRepository;
import cc.iotkit.data.model.TbSysDept;
import cc.iotkit.data.model.TbSysRoleDept;
import cc.iotkit.data.system.ISysRoleDeptData;
import cc.iotkit.data.util.PredicateBuilder;
@ -16,7 +15,6 @@ import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import static cc.iotkit.data.model.QTbSysRoleDept.tbSysRoleDept;

View File

@ -14,7 +14,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 static cc.iotkit.data.model.QTbSysTenant.tbSysTenant;

View File

@ -1,7 +1,6 @@
package cc.iotkit.data.service;
import cc.iotkit.data.dao.IJPACommData;
import cc.iotkit.data.dao.SysDeptRepository;
import cc.iotkit.data.dao.SysOssRepository;
import cc.iotkit.data.model.TbSysTenantPackage;
import cc.iotkit.data.system.ISysTenantPackageData;

View File

@ -7,7 +7,6 @@ import cc.iotkit.data.model.TbSysUserPost;
import cc.iotkit.data.system.ISysUserPostData;
import cc.iotkit.model.system.SysUserPost;
import lombok.RequiredArgsConstructor;
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;

View File

@ -11,8 +11,8 @@ package cc.iotkit.data.service;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.data.dao.IJPACommData;
import cc.iotkit.data.manager.IUserInfoData;
import cc.iotkit.data.dao.UserInfoRepository;
import cc.iotkit.data.manager.IUserInfoData;
import cc.iotkit.data.model.TbUserInfo;
import cc.iotkit.model.UserInfo;
import lombok.RequiredArgsConstructor;
@ -24,7 +24,6 @@ import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@Primary

View File

@ -4,25 +4,18 @@ import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.PageRequestEmpty;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.data.model.TbSysConfig;
import cc.iotkit.model.product.Product;
import cc.iotkit.model.system.SysConfig;
import cc.iotkit.model.system.SysNotice;
import cn.hutool.core.collection.CollUtil;
import com.querydsl.core.QueryResults;
import com.querydsl.core.types.OrderSpecifier;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
/**
* @author: Longjun.Tu
* @description:

View File

@ -11,7 +11,6 @@ package cc.iotkit.temporal.es.document;
import cc.iotkit.model.rule.TaskLog;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMapping;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

View File

@ -37,9 +37,7 @@ public class RuleLogDataImpl implements IRuleLogData {
public Paging<RuleLog> findByRuleId(String ruleId, int page, int size) {
Page<DocRuleLog> 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()));
}

View File

@ -37,7 +37,7 @@ public class TaskLogDataImpl implements ITaskLogData {
public Paging<TaskLog> findByTaskId(String taskId, int page, int size) {
Page<DocTaskLog> 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()));
}

View File

@ -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

View File

@ -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());

View File

@ -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<Record> 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<Record> 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(),

View File

@ -47,7 +47,7 @@ public class TableManager {
* sql
*/
public static String getCreateSTableSql(String tbName, List<TdField> fields, TdField... tags) {
if (fields.size() == 0) {
if (fields.isEmpty()) {
return null;
}

View File

@ -78,7 +78,7 @@ public class DbStructureDataImpl implements IDbStructureData {
List<TdField> 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) {

View File

@ -43,9 +43,9 @@ public class RuleLogDataImpl implements IRuleLogData {
sql = "select count(*) from rule_log where rule_id=?";
List<Long> 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()));
}

View File

@ -42,9 +42,9 @@ public class TaskLogDataImpl implements ITaskLogData {
sql = "select count(*) from task_log where task_id=?";
List<Long> 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()));
}

View File

@ -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<Long> 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<Long> 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;
}
}

View File

@ -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;
/**

View File

@ -1,6 +1,8 @@
package cc.iotkit.common.excel.annotation;
import cc.iotkit.common.excel.core.CellMergeStrategy;
import java.lang.annotation.*;
/**

View File

@ -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<CellRangeAddress> 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<CellRangeAddress> 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<CellRangeAddress> handle(List<?> list, boolean hasTitle) {
List<CellRangeAddress> cellList = new ArrayList<>();
if (CollUtil.isEmpty(list)) {
return cellList;
}
@SneakyThrows
private List<CellRangeAddress> handle(List<?> list, boolean hasTitle) {
List<CellRangeAddress> cellList = new ArrayList<>();
if (CollUtil.isEmpty(list)) {
return cellList;
}
Field[] fields = ReflectUtils.getFields(list.get(0).getClass(), field -> !"serialVersionUID".equals(field.getName()));
// 有注解的字段
List<Field> mergeFields = new ArrayList<>();
List<Integer> 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<Field> mergeFields = new ArrayList<>();
List<Integer> 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<Field, RepeatCell> 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<Field, RepeatCell> 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;
}
}

View File

@ -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<T> extends AnalysisEventListener<T> implements
@Override
public void invoke(T data, AnalysisContext context) {
if (isValidate) {
if (Boolean.TRUE.equals(isValidate)) {
ValidatorUtils.validate(data);
}
excelResult.getList().add(data);

View File

@ -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;

View File

@ -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<String, String> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
String requestMethod = operLog.getRequestMethod();
if (MapUtil.isEmpty(paramsMap)

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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;

View File

@ -13,8 +13,6 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.util.function.Supplier;
/**
*
*

View File

@ -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;

View File

@ -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<StopWatch> invokeTimeTL = new TransmittableThreadLocal<>();

View File

@ -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;

View File

@ -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;