Showing
5 changed files
with
18 additions
and
67 deletions
@@ -62,14 +62,14 @@ class YtDeviceProfileControllerTest extends BaseControllerTest{ | @@ -62,14 +62,14 @@ class YtDeviceProfileControllerTest extends BaseControllerTest{ | ||
62 | public static DeviceProfileDTO profileNoAlarm(String tenantId, DeviceTransportType type){ | 62 | public static DeviceProfileDTO profileNoAlarm(String tenantId, DeviceTransportType type){ |
63 | DeviceProfileDTO profile =new DeviceProfileDTO(); | 63 | DeviceProfileDTO profile =new DeviceProfileDTO(); |
64 | profile.setTenantId(tenantId); | 64 | profile.setTenantId(tenantId); |
65 | - profile.setTransportType(type); | 65 | + profile.setTransportType(type.name()); |
66 | return profile; | 66 | return profile; |
67 | } | 67 | } |
68 | 68 | ||
69 | public static DeviceProfileDTO profileAlarm(String tenantId, DeviceTransportType type){ | 69 | public static DeviceProfileDTO profileAlarm(String tenantId, DeviceTransportType type){ |
70 | DeviceProfileDTO profile =new DeviceProfileDTO(); | 70 | DeviceProfileDTO profile =new DeviceProfileDTO(); |
71 | profile.setTenantId(tenantId); | 71 | profile.setTenantId(tenantId); |
72 | - profile.setTransportType(type); | 72 | + profile.setTransportType(type.name()); |
73 | return profile; | 73 | return profile; |
74 | } | 74 | } |
75 | } | 75 | } |
common/data/src/main/java/org/thingsboard/server/common/data/yunteng/utils/tools/TBPageData.java
deleted
100644 → 0
1 | -package org.thingsboard.server.common.data.yunteng.utils.tools; | ||
2 | - | ||
3 | -import com.fasterxml.jackson.annotation.JsonProperty; | ||
4 | -import lombok.Data; | ||
5 | -import lombok.NoArgsConstructor; | ||
6 | -import org.thingsboard.common.util.JacksonUtil; | ||
7 | - | ||
8 | -import java.io.Serializable; | ||
9 | -import java.util.ArrayList; | ||
10 | -import java.util.Collection; | ||
11 | -import java.util.List; | ||
12 | - | ||
13 | -@Data | ||
14 | -@NoArgsConstructor | ||
15 | -public class TBPageData<T> implements Serializable { | ||
16 | - | ||
17 | - private static final long serialVersionUID = -914237744254466700L; | ||
18 | - | ||
19 | - private Collection<T> data; | ||
20 | - private int totalPages; | ||
21 | - private long totalElements; | ||
22 | - | ||
23 | - @JsonProperty("hasNext") | ||
24 | - private boolean hasNext; | ||
25 | - | ||
26 | - public TBPageData(Collection<T> data, int totalPages, long totalElements, boolean hasNext) { | ||
27 | - this.data = data; | ||
28 | - this.totalPages = totalPages; | ||
29 | - this.totalElements = totalElements; | ||
30 | - this.hasNext = hasNext; | ||
31 | - } | ||
32 | - | ||
33 | - public <D> TBPageData<D> getPageData(TBPageData<T> data, Class<D> target){ | ||
34 | - List<D> targetList = new ArrayList<>(); | ||
35 | - for(T t:data.getData()){ | ||
36 | - targetList.add(JacksonUtil.convertValue(t,target)); | ||
37 | - } | ||
38 | - return new TBPageData<>(targetList,data.totalPages,data.totalElements,data.hasNext); | ||
39 | - } | ||
40 | -} |
@@ -8,7 +8,6 @@ import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | @@ -8,7 +8,6 @@ import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | ||
8 | import org.thingsboard.server.common.data.yunteng.dto.AlarmInfoDTO; | 8 | import org.thingsboard.server.common.data.yunteng.dto.AlarmInfoDTO; |
9 | import org.thingsboard.server.common.data.yunteng.utils.ReflectUtils; | 9 | import org.thingsboard.server.common.data.yunteng.utils.ReflectUtils; |
10 | import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; | 10 | import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; |
11 | -import org.thingsboard.server.common.data.yunteng.utils.tools.TBPageData; | ||
12 | import org.thingsboard.server.dao.yunteng.service.YtAlarmInfoService; | 11 | import org.thingsboard.server.dao.yunteng.service.YtAlarmInfoService; |
13 | 12 | ||
14 | import java.util.List; | 13 | import java.util.List; |
@@ -120,20 +119,21 @@ public class YtAlarmInfoServiceImpl implements YtAlarmInfoService { | @@ -120,20 +119,21 @@ public class YtAlarmInfoServiceImpl implements YtAlarmInfoService { | ||
120 | IPage<AlarmInfo> page = getPage(queryMap, FastIotConstants.DefaultOrder.CREATE_TIME,false); | 119 | IPage<AlarmInfo> page = getPage(queryMap, FastIotConstants.DefaultOrder.CREATE_TIME,false); |
121 | IPage<AlarmInfo> alarmInfoIPage = alarmInfoBaseMapper.selectPage(page,queryMap);*/ | 120 | IPage<AlarmInfo> alarmInfoIPage = alarmInfoBaseMapper.selectPage(page,queryMap);*/ |
122 | 121 | ||
123 | - try { | ||
124 | - TBPageData tbPageData = null;//tbConnectService.getAlarmInfos(queryMap).get(); | ||
125 | - System.out.println("==================tbPageData:" + tbPageData); | ||
126 | - List<AlarmInfoDTO> alarmInfoDTOS = ReflectUtils.sourceToTarget(tbPageData.getData(), AlarmInfoDTO.class); | ||
127 | - YtPageData<AlarmInfoDTO> ytPageData = new YtPageData(); | ||
128 | - ytPageData.setItems(alarmInfoDTOS); | ||
129 | - | ||
130 | - System.out.println("==================alarmInfoDTOS:" + alarmInfoDTOS); | ||
131 | - return ytPageData; | ||
132 | - } catch (Exception e) { | ||
133 | - log.error("create TBAlarmInfo error {}", e.getMessage()); | ||
134 | - throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); | ||
135 | - } | 122 | +// try { |
123 | +// TBPageData tbPageData = null;//tbConnectService.getAlarmInfos(queryMap).get(); | ||
124 | +// System.out.println("==================tbPageData:" + tbPageData); | ||
125 | +// List<AlarmInfoDTO> alarmInfoDTOS = ReflectUtils.sourceToTarget(tbPageData.getData(), AlarmInfoDTO.class); | ||
126 | +// YtPageData<AlarmInfoDTO> ytPageData = new YtPageData(); | ||
127 | +// ytPageData.setItems(alarmInfoDTOS); | ||
128 | +// | ||
129 | +// System.out.println("==================alarmInfoDTOS:" + alarmInfoDTOS); | ||
130 | +// return ytPageData; | ||
131 | +// } catch (Exception e) { | ||
132 | +// log.error("create TBAlarmInfo error {}", e.getMessage()); | ||
133 | +// throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); | ||
134 | +// } | ||
136 | //return getPageData(alarmInfoIPage,AlarmInfoDTO.class); | 135 | //return getPageData(alarmInfoIPage,AlarmInfoDTO.class); |
136 | + return null; | ||
137 | } | 137 | } |
138 | 138 | ||
139 | 139 |
@@ -6,7 +6,6 @@ import lombok.RequiredArgsConstructor; | @@ -6,7 +6,6 @@ import lombok.RequiredArgsConstructor; | ||
6 | import lombok.extern.slf4j.Slf4j; | 6 | import lombok.extern.slf4j.Slf4j; |
7 | import org.apache.commons.lang3.StringUtils; | 7 | import org.apache.commons.lang3.StringUtils; |
8 | import org.jetbrains.annotations.NotNull; | 8 | import org.jetbrains.annotations.NotNull; |
9 | -import org.springframework.beans.BeanUtils; | ||
10 | import org.springframework.stereotype.Service; | 9 | import org.springframework.stereotype.Service; |
11 | import org.springframework.transaction.annotation.Transactional; | 10 | import org.springframework.transaction.annotation.Transactional; |
12 | import org.thingsboard.server.common.data.DeviceProfile; | 11 | import org.thingsboard.server.common.data.DeviceProfile; |
@@ -142,8 +141,7 @@ public class YtDeviceProfileServiceImpl | @@ -142,8 +141,7 @@ public class YtDeviceProfileServiceImpl | ||
142 | 141 | ||
143 | for (String id : ids) { | 142 | for (String id : ids) { |
144 | Validator.validateId(UUID.fromString(id),"Incorrect device profile id to deal."); | 143 | Validator.validateId(UUID.fromString(id),"Incorrect device profile id to deal."); |
145 | - LambdaQueryWrapper filter = new QueryWrapper<AlarmProfile>() | ||
146 | - .lambda() | 144 | + LambdaQueryWrapper filter = new LambdaQueryWrapper<AlarmProfile>() |
147 | .eq(AlarmProfile::getTenantId, tenantId) | 145 | .eq(AlarmProfile::getTenantId, tenantId) |
148 | .in(AlarmProfile::getDeviceProfileId, id); | 146 | .in(AlarmProfile::getDeviceProfileId, id); |
149 | alarmProfileMapper.delete(filter); | 147 | alarmProfileMapper.delete(filter); |
@@ -16,11 +16,11 @@ import org.mybatis.spring.SqlSessionUtils; | @@ -16,11 +16,11 @@ import org.mybatis.spring.SqlSessionUtils; | ||
16 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
17 | import org.springframework.transaction.annotation.Transactional; | 17 | import org.springframework.transaction.annotation.Transactional; |
18 | import org.thingsboard.server.cluster.TbClusterService; | 18 | import org.thingsboard.server.cluster.TbClusterService; |
19 | +import org.thingsboard.server.common.data.page.PageData; | ||
19 | import org.thingsboard.server.common.data.yunteng.constant.ModelConstants; | 20 | import org.thingsboard.server.common.data.yunteng.constant.ModelConstants; |
20 | import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum; | 21 | import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum; |
21 | import org.thingsboard.server.common.data.yunteng.utils.ReflectUtils; | 22 | import org.thingsboard.server.common.data.yunteng.utils.ReflectUtils; |
22 | import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; | 23 | import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; |
23 | -import org.thingsboard.server.common.data.yunteng.utils.tools.TBPageData; | ||
24 | import org.thingsboard.server.dao.yunteng.entities.BaseEntity; | 24 | import org.thingsboard.server.dao.yunteng.entities.BaseEntity; |
25 | 25 | ||
26 | import java.util.Collection; | 26 | import java.util.Collection; |
@@ -75,13 +75,6 @@ public abstract class AbstractBaseService<M extends BaseMapper<T>, T extends Bas | @@ -75,13 +75,6 @@ public abstract class AbstractBaseService<M extends BaseMapper<T>, T extends Bas | ||
75 | List<D> targetList = ReflectUtils.sourceToTarget(iPage.getRecords(), target); | 75 | List<D> targetList = ReflectUtils.sourceToTarget(iPage.getRecords(), target); |
76 | return new YtPageData<>(targetList, iPage.getTotal()); | 76 | return new YtPageData<>(targetList, iPage.getTotal()); |
77 | } | 77 | } |
78 | - | ||
79 | - protected <D> YtPageData<D> getPageData(TBPageData<T> tbPageData, Class<D> target){ | ||
80 | - List<D> targetList = ReflectUtils.sourceToTarget(tbPageData.getData(),target); | ||
81 | - return new YtPageData<>(targetList, tbPageData.getTotalElements()); | ||
82 | - } | ||
83 | - | ||
84 | - | ||
85 | /** | 78 | /** |
86 | * 批量插入 | 79 | * 批量插入 |
87 | * | 80 | * |