Showing
17 changed files
with
370 additions
and
239 deletions
application/src/main/java/org/thingsboard/server/controller/yunteng/AlarmProfileController.java
0 → 100644
1 | +package org.thingsboard.server.controller.yunteng; | ||
2 | + | ||
3 | +import io.swagger.annotations.Api; | ||
4 | +import io.swagger.annotations.ApiOperation; | ||
5 | +import lombok.RequiredArgsConstructor; | ||
6 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
7 | +import org.springframework.validation.annotation.Validated; | ||
8 | +import org.springframework.web.bind.annotation.*; | ||
9 | +import org.thingsboard.server.common.data.StringUtils; | ||
10 | +import org.thingsboard.server.common.data.exception.ThingsboardException; | ||
11 | +import org.thingsboard.server.common.data.yunteng.common.DeleteGroup; | ||
12 | +import org.thingsboard.server.common.data.yunteng.dto.AlarmProfileDTO; | ||
13 | +import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO; | ||
14 | +import org.thingsboard.server.common.data.yunteng.dto.MailLogDTO; | ||
15 | +import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum; | ||
16 | +import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; | ||
17 | +import org.thingsboard.server.controller.BaseController; | ||
18 | +import org.thingsboard.server.dao.yunteng.service.AlarmProfileService; | ||
19 | + | ||
20 | +import java.util.HashMap; | ||
21 | + | ||
22 | +import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*; | ||
23 | +import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.ORDER_TYPE; | ||
24 | + | ||
25 | +@RestController | ||
26 | +@RequestMapping("api/yt/alarm/profile") | ||
27 | +@Api(tags = {"告警配置"}) | ||
28 | +@RequiredArgsConstructor | ||
29 | +@PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | ||
30 | +public class AlarmProfileController extends BaseController { | ||
31 | + | ||
32 | + private final AlarmProfileService alarmProfileService; | ||
33 | + | ||
34 | + @GetMapping(params = {PAGE_SIZE, PAGE}) | ||
35 | + @ApiOperation("分页") | ||
36 | + public YtPageData<AlarmProfileDTO> pageAlarmProfile( | ||
37 | + @RequestParam(PAGE_SIZE) int pageSize, | ||
38 | + @RequestParam(PAGE) int page, | ||
39 | + @RequestParam(value = "status", required = false) Integer status, | ||
40 | + @RequestParam(value = "name", required = false) String name, | ||
41 | + @RequestParam(value = "organizationId", required = false) String organizationId, | ||
42 | + @RequestParam(value = ORDER_FILED, required = false) String orderBy, | ||
43 | + @RequestParam(value = ORDER_TYPE, required = false) OrderTypeEnum orderType) | ||
44 | + throws ThingsboardException { | ||
45 | + | ||
46 | + HashMap<String, Object> queryMap = new HashMap<>(); | ||
47 | + queryMap.put(PAGE_SIZE, pageSize); | ||
48 | + queryMap.put(PAGE, page); | ||
49 | + queryMap.put(ORDER_FILED, orderBy); | ||
50 | + queryMap.put("status", status); | ||
51 | + queryMap.put("name", name); | ||
52 | + queryMap.put("organizationId", organizationId); | ||
53 | + if (orderType != null) { | ||
54 | + queryMap.put(ORDER_TYPE, orderType.name()); | ||
55 | + } | ||
56 | + return alarmProfileService.page( | ||
57 | + getCurrentUser().isPtTenantAdmin(), | ||
58 | + getCurrentUser().getCurrentTenantId(), | ||
59 | + getCurrentUser().getCurrentUserId(), | ||
60 | + queryMap); | ||
61 | + } | ||
62 | + | ||
63 | + @PostMapping | ||
64 | + @ApiOperation("新增|编辑") | ||
65 | + public AlarmProfileDTO saveOrUpdateAlarmProfile(@Validated @RequestBody AlarmProfileDTO alarmProfileDTO) | ||
66 | + throws ThingsboardException { | ||
67 | + alarmProfileDTO.setTenantId(getCurrentUser().getCurrentTenantId()); | ||
68 | + return alarmProfileService.saveOrUpdateAlarmProfile(alarmProfileDTO); | ||
69 | + } | ||
70 | + | ||
71 | + @DeleteMapping | ||
72 | + @ApiOperation("删除") | ||
73 | + public boolean deleteAlarmProfile(@Validated(DeleteGroup.class) @RequestBody DeleteDTO deleteDTO) { | ||
74 | + return alarmProfileService.deleteAlarmProFile(deleteDTO); | ||
75 | + } | ||
76 | + | ||
77 | + @GetMapping("{alarmProfileId}/{status}") | ||
78 | + @ApiOperation("更新状态") | ||
79 | + public AlarmProfileDTO saveOrUpdateAlarmProfile( | ||
80 | + @PathVariable("alarmProfileId") String alarmProfileId, @PathVariable("status") Integer status) | ||
81 | + throws ThingsboardException { | ||
82 | + return alarmProfileService.updateAlarmProFileStatus( | ||
83 | + alarmProfileId, getCurrentUser().getCurrentTenantId(), status); | ||
84 | + } | ||
85 | +} |
@@ -4,12 +4,10 @@ import io.swagger.annotations.Api; | @@ -4,12 +4,10 @@ import io.swagger.annotations.Api; | ||
4 | import io.swagger.annotations.ApiOperation; | 4 | import io.swagger.annotations.ApiOperation; |
5 | import lombok.RequiredArgsConstructor; | 5 | import lombok.RequiredArgsConstructor; |
6 | import org.apache.commons.lang3.StringUtils; | 6 | import org.apache.commons.lang3.StringUtils; |
7 | -import org.springframework.http.HttpStatus; | ||
8 | import org.springframework.http.ResponseEntity; | 7 | import org.springframework.http.ResponseEntity; |
9 | import org.springframework.security.access.prepost.PreAuthorize; | 8 | import org.springframework.security.access.prepost.PreAuthorize; |
10 | import org.springframework.validation.annotation.Validated; | 9 | import org.springframework.validation.annotation.Validated; |
11 | import org.springframework.web.bind.annotation.*; | 10 | import org.springframework.web.bind.annotation.*; |
12 | -import org.springframework.web.servlet.support.ServletUriComponentsBuilder; | ||
13 | import org.thingsboard.server.common.data.DeviceProfile; | 11 | import org.thingsboard.server.common.data.DeviceProfile; |
14 | import org.thingsboard.server.common.data.DeviceProfileProvisionType; | 12 | import org.thingsboard.server.common.data.DeviceProfileProvisionType; |
15 | import org.thingsboard.server.common.data.DeviceProfileType; | 13 | import org.thingsboard.server.common.data.DeviceProfileType; |
@@ -33,8 +31,6 @@ import org.thingsboard.server.controller.BaseController; | @@ -33,8 +31,6 @@ import org.thingsboard.server.controller.BaseController; | ||
33 | import org.thingsboard.server.dao.yunteng.service.YtDeviceProfileService; | 31 | import org.thingsboard.server.dao.yunteng.service.YtDeviceProfileService; |
34 | import org.thingsboard.server.service.security.permission.Operation; | 32 | import org.thingsboard.server.service.security.permission.Operation; |
35 | 33 | ||
36 | -import java.net.URI; | ||
37 | -import java.sql.ResultSet; | ||
38 | import java.time.LocalDateTime; | 34 | import java.time.LocalDateTime; |
39 | import java.time.ZoneOffset; | 35 | import java.time.ZoneOffset; |
40 | import java.util.*; | 36 | import java.util.*; |
@@ -65,23 +61,9 @@ public class YtDeviceProfileController extends BaseController { | @@ -65,23 +61,9 @@ public class YtDeviceProfileController extends BaseController { | ||
65 | 61 | ||
66 | deviceProfileDTO.setTenantId(getCurrentUser().getCurrentTenantId()); | 62 | deviceProfileDTO.setTenantId(getCurrentUser().getCurrentTenantId()); |
67 | DeviceProfile tbDeviceProfile = buildTbDeviceProfileFromDeviceProfileDTO(deviceProfileDTO); | 63 | DeviceProfile tbDeviceProfile = buildTbDeviceProfileFromDeviceProfileDTO(deviceProfileDTO); |
68 | - DeviceProfile savedDeviceProfile = updateTbDeviceProfile(tbDeviceProfile, created); | 64 | + updateTbDeviceProfile(tbDeviceProfile, created); |
69 | 65 | ||
70 | - | ||
71 | - | ||
72 | - | ||
73 | - DeviceProfileDTO newDeviceProfileDTO = ytDeviceProfileService.insertOrUpdate(savedDeviceProfile.getId().getId().toString(), deviceProfileDTO); | ||
74 | - return Optional.ofNullable(newDeviceProfileDTO) | ||
75 | - .map( | ||
76 | - dto -> { | ||
77 | - URI location = | ||
78 | - ServletUriComponentsBuilder.fromCurrentRequest() | ||
79 | - .path("/{id}") | ||
80 | - .buildAndExpand(newDeviceProfileDTO.getId()) | ||
81 | - .toUri(); | ||
82 | - return ResponseEntity.created(location).body(newDeviceProfileDTO); | ||
83 | - }) | ||
84 | - .orElse(ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build()); | 66 | + return ResponseEntity.ok(deviceProfileDTO); |
85 | } | 67 | } |
86 | 68 | ||
87 | /** | 69 | /** |
@@ -151,7 +133,7 @@ public class YtDeviceProfileController extends BaseController { | @@ -151,7 +133,7 @@ public class YtDeviceProfileController extends BaseController { | ||
151 | @DeleteMapping | 133 | @DeleteMapping |
152 | @ApiOperation("删除") | 134 | @ApiOperation("删除") |
153 | public void deleteDevices(@Validated({DeleteGroup.class}) @RequestBody DeleteDTO deleteDTO) throws ThingsboardException { | 135 | public void deleteDevices(@Validated({DeleteGroup.class}) @RequestBody DeleteDTO deleteDTO) throws ThingsboardException { |
154 | - ytDeviceProfileService.deleteDeviceProfiles(getCurrentUser().getCurrentTenantId(), deleteDTO.getIds()); | 136 | + ytDeviceProfileService.checkDeviceProfiles(getCurrentUser().getCurrentTenantId(), deleteDTO.getIds()); |
155 | 137 | ||
156 | for (String id : deleteDTO.getIds()) { | 138 | for (String id : deleteDTO.getIds()) { |
157 | deleteTbDeviceProfile(id); | 139 | deleteTbDeviceProfile(id); |
@@ -244,11 +226,6 @@ public class YtDeviceProfileController extends BaseController { | @@ -244,11 +226,6 @@ public class YtDeviceProfileController extends BaseController { | ||
244 | && deviceProfileDTO.getProfileData().getAlarms() !=null){ | 226 | && deviceProfileDTO.getProfileData().getAlarms() !=null){ |
245 | deviceProfileData.setAlarms(deviceProfileDTO.getProfileData().getAlarms()); | 227 | deviceProfileData.setAlarms(deviceProfileDTO.getProfileData().getAlarms()); |
246 | } | 228 | } |
247 | -// if (null != deviceProfileDTO.getAlarms()) { | ||
248 | -// List<DeviceProfileAlarm> list = new ArrayList<>(); | ||
249 | -// DeviceProfileAlarm deviceProfileAlarm = JacksonUtil.convertValue(deviceProfileDTO.getAlarms(),DeviceProfileAlarm.class); | ||
250 | -// list.add(deviceProfileAlarm); | ||
251 | -// } | ||
252 | tbDeviceProfile.setProfileData(deviceProfileData); | 229 | tbDeviceProfile.setProfileData(deviceProfileData); |
253 | 230 | ||
254 | return tbDeviceProfile; | 231 | return tbDeviceProfile; |
@@ -54,7 +54,7 @@ public enum ErrorMessage { | @@ -54,7 +54,7 @@ public enum ErrorMessage { | ||
54 | EXIST_LEADER_MEMBER_RELATION(400035,"上下级之间有一种关系"), | 54 | EXIST_LEADER_MEMBER_RELATION(400035,"上下级之间有一种关系"), |
55 | FILE_NOT_FOUND(400036,"文件未找到"), | 55 | FILE_NOT_FOUND(400036,"文件未找到"), |
56 | STORE_FILE_FAILED(400037,"文件存储失败"), | 56 | STORE_FILE_FAILED(400037,"文件存储失败"), |
57 | - NOT_BELONG_CURRENT_TENANT(400038,"该用户不属于当前租户"), | 57 | + NOT_BELONG_CURRENT_TENANT(400038,"不属于当前租户"), |
58 | HAVE_NO_PERMISSION(500002,"没有修改权限"); | 58 | HAVE_NO_PERMISSION(500002,"没有修改权限"); |
59 | private final int code; | 59 | private final int code; |
60 | private String message; | 60 | private String message; |
1 | package org.thingsboard.server.common.data.yunteng.dto; | 1 | package org.thingsboard.server.common.data.yunteng.dto; |
2 | 2 | ||
3 | +import io.swagger.annotations.ApiModelProperty; | ||
3 | import lombok.Data; | 4 | import lombok.Data; |
4 | 5 | ||
6 | +import javax.validation.constraints.NotEmpty; | ||
7 | + | ||
5 | @Data | 8 | @Data |
6 | public class AlarmProfileDTO extends TenantDTO { | 9 | public class AlarmProfileDTO extends TenantDTO { |
7 | - /** 告警联系人 通知多人“,”号分隔 */ | 10 | + @ApiModelProperty(value = "告警联系人 通知多人“,”号分隔",required = true) |
11 | + @NotEmpty(message = "告警联系人不能为空或空字符串") | ||
8 | private String alarmContactId; | 12 | private String alarmContactId; |
9 | - /** 设备配置ID */ | ||
10 | - private String deviceProfileId; | ||
11 | - /** 消息通知方式:多种方式“,”号分隔 MessageTypeEnum */ | 13 | + |
14 | + @ApiModelProperty(value ="消息通知方式:多种方式“,”号分隔 MessageTypeEnum",required = true) | ||
15 | + @NotEmpty(message = "消息通知方式不能为空或空字符串") | ||
12 | private String messageMode; | 16 | private String messageMode; |
17 | + | ||
18 | + @ApiModelProperty(value ="组织ID",required = true) | ||
19 | + @NotEmpty(message = "组织ID不能为空或空字符串") | ||
20 | + private String organizationId; | ||
21 | + | ||
22 | + @ApiModelProperty("状态:0禁用 1启用") | ||
23 | + private Integer status; | ||
24 | + | ||
25 | + @ApiModelProperty(value ="告警配置名称",required = true) | ||
26 | + @NotEmpty(message = "告警配置名称不能为空或空字符串") | ||
27 | + private String name; | ||
28 | + | ||
29 | + @ApiModelProperty("告警配置备注") | ||
30 | + private String remark; | ||
13 | } | 31 | } |
1 | package org.thingsboard.server.common.data.yunteng.dto; | 1 | package org.thingsboard.server.common.data.yunteng.dto; |
2 | 2 | ||
3 | +import io.swagger.annotations.ApiModelProperty; | ||
3 | import lombok.Data; | 4 | import lombok.Data; |
4 | import org.thingsboard.server.common.data.yunteng.common.DeleteGroup; | 5 | import org.thingsboard.server.common.data.yunteng.common.DeleteGroup; |
5 | 6 | ||
@@ -18,4 +19,7 @@ public class DeleteDTO { | @@ -18,4 +19,7 @@ public class DeleteDTO { | ||
18 | message = "删除至少需要一个id", | 19 | message = "删除至少需要一个id", |
19 | groups = {DeleteGroup.class}) | 20 | groups = {DeleteGroup.class}) |
20 | private Set<String> ids; | 21 | private Set<String> ids; |
22 | + | ||
23 | + @ApiModelProperty("租户ID") | ||
24 | + private String tenantId; | ||
21 | } | 25 | } |
@@ -8,27 +8,23 @@ import org.thingsboard.server.common.data.yunteng.enums.ActionTypeEnum; | @@ -8,27 +8,23 @@ import org.thingsboard.server.common.data.yunteng.enums.ActionTypeEnum; | ||
8 | 8 | ||
9 | import java.util.List; | 9 | import java.util.List; |
10 | 10 | ||
11 | -/** | ||
12 | - * @Description 场景联动执行动作数据传输表 | ||
13 | - * @Author cxy | ||
14 | - * @Date 2021/11/24 17:32 | ||
15 | - */ | 11 | +/** @Description 场景联动执行动作数据传输表 @Author cxy @Date 2021/11/24 17:32 */ |
16 | @Data | 12 | @Data |
17 | @EqualsAndHashCode(callSuper = true) | 13 | @EqualsAndHashCode(callSuper = true) |
18 | -public class DoActionDTO extends TenantDTO{ | 14 | +public class DoActionDTO extends TenantDTO { |
19 | 15 | ||
20 | - @ApiModelProperty(value = "所属设备id") | ||
21 | - private String deviceId; | 16 | + @ApiModelProperty(value = "所属设备id") |
17 | + private String deviceId; | ||
22 | 18 | ||
19 | + @ApiModelProperty(value = "场景联动内容") | ||
20 | + private JsonNode doContext; | ||
23 | 21 | ||
22 | + @ApiModelProperty(value = "输出目标:设备,告警,其他") | ||
23 | + private ActionTypeEnum outTarget; | ||
24 | 24 | ||
25 | - @ApiModelProperty(value = "场景联动内容") | ||
26 | - private JsonNode doContext; | ||
27 | - | ||
28 | - @ApiModelProperty(value = "输出目标:设备,场景,其他") | ||
29 | - private ActionTypeEnum outTarget; | ||
30 | - | ||
31 | - @ApiModelProperty(value = "场景联动id") | ||
32 | - private String sceneLinkageId; | 25 | + @ApiModelProperty(value = "场景联动id") |
26 | + private String sceneLinkageId; | ||
33 | 27 | ||
28 | + @ApiModelProperty(value = "输出目标为告警才进行配置") | ||
29 | + private String alarmProfileId; | ||
34 | } | 30 | } |
@@ -12,6 +12,10 @@ public class AlarmProfile extends TenantBaseEntity { | @@ -12,6 +12,10 @@ public class AlarmProfile extends TenantBaseEntity { | ||
12 | 12 | ||
13 | private static final long serialVersionUID = -4922707705163155569L; | 13 | private static final long serialVersionUID = -4922707705163155569L; |
14 | private String alarmContactId; | 14 | private String alarmContactId; |
15 | - private String deviceProfileId; | 15 | + private String organizationId; |
16 | private String messageMode; | 16 | private String messageMode; |
17 | + private Integer status; | ||
18 | + private String name; | ||
19 | + private String remark; | ||
20 | + | ||
17 | } | 21 | } |
@@ -10,27 +10,24 @@ import org.apache.ibatis.type.EnumTypeHandler; | @@ -10,27 +10,24 @@ import org.apache.ibatis.type.EnumTypeHandler; | ||
10 | import org.thingsboard.server.common.data.yunteng.constant.ModelConstants; | 10 | import org.thingsboard.server.common.data.yunteng.constant.ModelConstants; |
11 | import org.thingsboard.server.common.data.yunteng.enums.ActionTypeEnum; | 11 | import org.thingsboard.server.common.data.yunteng.enums.ActionTypeEnum; |
12 | 12 | ||
13 | -/** | ||
14 | - * @Description 执行动作 @Author cxy @Date 2021/11/24 17:24 | ||
15 | - */ | 13 | +/** @Description 执行动作 @Author cxy @Date 2021/11/24 17:24 */ |
16 | @Data | 14 | @Data |
17 | @TableName(value = ModelConstants.Table.IOTFS_DO_ACTION_TABLE_NAME, autoResultMap = true) | 15 | @TableName(value = ModelConstants.Table.IOTFS_DO_ACTION_TABLE_NAME, autoResultMap = true) |
18 | @EqualsAndHashCode(callSuper = true) | 16 | @EqualsAndHashCode(callSuper = true) |
19 | public class DoAction extends TenantBaseEntity { | 17 | public class DoAction extends TenantBaseEntity { |
20 | 18 | ||
21 | - private static final long serialVersionUID = -5459834451418047957L; | 19 | + private static final long serialVersionUID = -5459834451418047957L; |
22 | 20 | ||
23 | - private String deviceId; | ||
24 | - @TableField(typeHandler = EnumTypeHandler.class) | ||
25 | - private ActionTypeEnum outTarget; | ||
26 | - /** | ||
27 | - * 场景联动内容 | ||
28 | - */ | ||
29 | - @TableField(typeHandler = JacksonTypeHandler.class) | ||
30 | - private JsonNode doContext; | 21 | + private String deviceId; |
31 | 22 | ||
32 | - /** | ||
33 | - * 场景联动id | ||
34 | - */ | ||
35 | - private String sceneLinkageId; | 23 | + @TableField(typeHandler = EnumTypeHandler.class) |
24 | + private ActionTypeEnum outTarget; | ||
25 | + /** 场景联动内容 */ | ||
26 | + @TableField(typeHandler = JacksonTypeHandler.class) | ||
27 | + private JsonNode doContext; | ||
28 | + | ||
29 | + /** 场景联动id */ | ||
30 | + private String sceneLinkageId; | ||
31 | + | ||
32 | + private String alarmProfileId; | ||
36 | } | 33 | } |
1 | package org.thingsboard.server.dao.yunteng.impl; | 1 | package org.thingsboard.server.dao.yunteng.impl; |
2 | 2 | ||
3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
4 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
5 | +import com.baomidou.mybatisplus.core.metadata.IPage; | ||
4 | import lombok.RequiredArgsConstructor; | 6 | import lombok.RequiredArgsConstructor; |
5 | import lombok.extern.slf4j.Slf4j; | 7 | import lombok.extern.slf4j.Slf4j; |
6 | import org.springframework.stereotype.Service; | 8 | import org.springframework.stereotype.Service; |
9 | +import org.springframework.transaction.annotation.Transactional; | ||
10 | +import org.thingsboard.server.common.data.StringUtils; | ||
11 | +import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; | ||
12 | +import org.thingsboard.server.common.data.yunteng.core.exception.NoneTenantAssetException; | ||
13 | +import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException; | ||
14 | +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | ||
7 | import org.thingsboard.server.common.data.yunteng.dto.AlarmProfileDTO; | 15 | import org.thingsboard.server.common.data.yunteng.dto.AlarmProfileDTO; |
16 | +import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO; | ||
17 | +import org.thingsboard.server.common.data.yunteng.dto.DoActionDTO; | ||
18 | +import org.thingsboard.server.common.data.yunteng.dto.OrganizationDTO; | ||
19 | +import org.thingsboard.server.common.data.yunteng.enums.RoleEnum; | ||
8 | import org.thingsboard.server.common.data.yunteng.utils.ReflectUtils; | 20 | import org.thingsboard.server.common.data.yunteng.utils.ReflectUtils; |
21 | +import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; | ||
9 | import org.thingsboard.server.dao.yunteng.entities.AlarmProfile; | 22 | import org.thingsboard.server.dao.yunteng.entities.AlarmProfile; |
23 | +import org.thingsboard.server.dao.yunteng.entities.Role; | ||
10 | import org.thingsboard.server.dao.yunteng.mapper.AlarmProfileMapper; | 24 | import org.thingsboard.server.dao.yunteng.mapper.AlarmProfileMapper; |
25 | +import org.thingsboard.server.dao.yunteng.mapper.OrganizationMapper; | ||
11 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; | 26 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
12 | import org.thingsboard.server.dao.yunteng.service.AlarmProfileService; | 27 | import org.thingsboard.server.dao.yunteng.service.AlarmProfileService; |
28 | +import org.thingsboard.server.dao.yunteng.service.DoActionService; | ||
29 | +import org.thingsboard.server.dao.yunteng.service.YtOrganizationService; | ||
13 | 30 | ||
14 | -import java.util.List; | 31 | +import java.util.*; |
32 | +import java.util.stream.Collectors; | ||
15 | 33 | ||
16 | @Slf4j | 34 | @Slf4j |
17 | @Service | 35 | @Service |
18 | @RequiredArgsConstructor | 36 | @RequiredArgsConstructor |
19 | public class AlarmProfileServiceImpl extends AbstractBaseService<AlarmProfileMapper, AlarmProfile> | 37 | public class AlarmProfileServiceImpl extends AbstractBaseService<AlarmProfileMapper, AlarmProfile> |
20 | implements AlarmProfileService { | 38 | implements AlarmProfileService { |
39 | + | ||
40 | + private final DoActionService doActionService; | ||
41 | + | ||
42 | + private final UserOrganizationMappingServiceImpl userOrganizationMappingService; | ||
43 | + | ||
44 | + private final OrganizationMapper ytOrganizationMapper; | ||
45 | + | ||
46 | + @Override | ||
47 | + public YtPageData<AlarmProfileDTO> page( | ||
48 | + boolean isPtTenantAdmin, | ||
49 | + String tenantId, | ||
50 | + String currentUserId, | ||
51 | + Map<String, Object> queryMap) { | ||
52 | + List<String> organizationIds = null; | ||
53 | + if (null != queryMap.get("organizationId")) { | ||
54 | + String organizationId = (String) queryMap.get("organizationId"); | ||
55 | + List<OrganizationDTO> organizationList = | ||
56 | + ytOrganizationMapper.findOrganizationTreeList( | ||
57 | + tenantId, new HashSet<>(Arrays.asList(organizationId))); | ||
58 | + Set<String> ids = | ||
59 | + organizationList.stream() | ||
60 | + .map(organizationDTO -> organizationDTO.getId()) | ||
61 | + .collect(Collectors.toSet()); | ||
62 | + organizationIds = new ArrayList<>(ids); | ||
63 | + } else { | ||
64 | + if (!isPtTenantAdmin) { | ||
65 | + organizationIds = userOrganizationMappingService.getOrganizationIdsByUserId(currentUserId); | ||
66 | + } | ||
67 | + } | ||
68 | + IPage<AlarmProfile> alarmProfileIPage = | ||
69 | + baseMapper.selectPage( | ||
70 | + getPage(queryMap, "create_time", false), | ||
71 | + new QueryWrapper<AlarmProfile>() | ||
72 | + .lambda() | ||
73 | + .eq(queryMap.get("status") != null, AlarmProfile::getStatus, queryMap.get("status")) | ||
74 | + .eq(AlarmProfile::getTenantId, tenantId) | ||
75 | + .in(organizationIds != null, AlarmProfile::getOrganizationId, organizationIds) | ||
76 | + .like( | ||
77 | + queryMap.get("name") != null, | ||
78 | + AlarmProfile::getName, | ||
79 | + String.valueOf(queryMap.get("name")))); | ||
80 | + return getPageData(alarmProfileIPage, AlarmProfileDTO.class); | ||
81 | + } | ||
82 | + | ||
21 | @Override | 83 | @Override |
22 | public List<AlarmProfileDTO> findAlarmProfilesByContactId(String contactId, String tenantId) { | 84 | public List<AlarmProfileDTO> findAlarmProfilesByContactId(String contactId, String tenantId) { |
23 | return ReflectUtils.sourceToTarget( | 85 | return ReflectUtils.sourceToTarget( |
@@ -27,4 +89,47 @@ public class AlarmProfileServiceImpl extends AbstractBaseService<AlarmProfileMap | @@ -27,4 +89,47 @@ public class AlarmProfileServiceImpl extends AbstractBaseService<AlarmProfileMap | ||
27 | .like(AlarmProfile::getAlarmContactId, contactId)), | 89 | .like(AlarmProfile::getAlarmContactId, contactId)), |
28 | AlarmProfileDTO.class); | 90 | AlarmProfileDTO.class); |
29 | } | 91 | } |
92 | + | ||
93 | + @Override | ||
94 | + @Transactional | ||
95 | + public AlarmProfileDTO saveOrUpdateAlarmProfile(AlarmProfileDTO alarmProfileDTO) { | ||
96 | + if (StringUtils.isNotEmpty(alarmProfileDTO.getId())) { | ||
97 | + AlarmProfile alarmProfile = baseMapper.selectById(alarmProfileDTO.getId()); | ||
98 | + if (null == alarmProfile) { | ||
99 | + throw new YtDataValidationException(ErrorMessage.INTERNAL_ERROR.getMessage()); | ||
100 | + } | ||
101 | + baseMapper.updateById(alarmProfileDTO.getEntity(AlarmProfile.class)); | ||
102 | + } else { | ||
103 | + baseMapper.insert(alarmProfileDTO.getEntity(AlarmProfile.class)); | ||
104 | + } | ||
105 | + return alarmProfileDTO; | ||
106 | + } | ||
107 | + | ||
108 | + @Override | ||
109 | + @Transactional | ||
110 | + public AlarmProfileDTO updateAlarmProFileStatus( | ||
111 | + String alarmProfileId, String tenantId, Integer status) { | ||
112 | + AlarmProfile alarmProfile = baseMapper.selectById(alarmProfileId); | ||
113 | + if (null == alarmProfile) { | ||
114 | + throw new YtDataValidationException(ErrorMessage.INTERNAL_ERROR.getMessage()); | ||
115 | + } | ||
116 | + if (!alarmProfile.getTenantId().equals(tenantId)) { | ||
117 | + throw new NoneTenantAssetException(ErrorMessage.NOT_BELONG_CURRENT_TENANT); | ||
118 | + } | ||
119 | + alarmProfile.setStatus(status); | ||
120 | + baseMapper.updateById(alarmProfile); | ||
121 | + return alarmProfile.getDTO(AlarmProfileDTO.class); | ||
122 | + } | ||
123 | + | ||
124 | + @Override | ||
125 | + @Transactional | ||
126 | + public boolean deleteAlarmProFile(DeleteDTO deleteDTO) { | ||
127 | + // 如果有场景联动使用告警配置,则不能删除 | ||
128 | + List<DoActionDTO> list = | ||
129 | + doActionService.findDoActionByAlarmProfileIds(deleteDTO.getTenantId(), deleteDTO.getIds()); | ||
130 | + if (list.size() > FastIotConstants.MagicNumber.ZERO) { | ||
131 | + throw new YtDataValidationException(ErrorMessage.EXIST_LEADER_MEMBER_RELATION.getMessage()); | ||
132 | + } | ||
133 | + return baseMapper.deleteBatchIds(deleteDTO.getIds()) > 0; | ||
134 | + } | ||
30 | } | 135 | } |
1 | package org.thingsboard.server.dao.yunteng.impl; | 1 | package org.thingsboard.server.dao.yunteng.impl; |
2 | + | ||
2 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
4 | import lombok.RequiredArgsConstructor; | 5 | import lombok.RequiredArgsConstructor; |
6 | +import org.springframework.cglib.core.ReflectUtils; | ||
5 | import org.springframework.stereotype.Service; | 7 | import org.springframework.stereotype.Service; |
8 | +import org.thingsboard.server.common.data.yunteng.dto.DoActionDTO; | ||
6 | import org.thingsboard.server.dao.yunteng.entities.DoAction; | 9 | import org.thingsboard.server.dao.yunteng.entities.DoAction; |
10 | +import org.thingsboard.server.dao.yunteng.entities.TenantBaseEntity; | ||
7 | import org.thingsboard.server.dao.yunteng.mapper.DoActionMapper; | 11 | import org.thingsboard.server.dao.yunteng.mapper.DoActionMapper; |
8 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; | 12 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
9 | import org.thingsboard.server.dao.yunteng.service.DoActionService; | 13 | import org.thingsboard.server.dao.yunteng.service.DoActionService; |
10 | 14 | ||
11 | import java.util.List; | 15 | import java.util.List; |
16 | +import java.util.Optional; | ||
17 | +import java.util.Set; | ||
18 | +import java.util.stream.Collectors; | ||
12 | 19 | ||
13 | -/** | ||
14 | - * @Description | ||
15 | - * @Author cxy | ||
16 | - * @Date 2021/12/6 20:23 | ||
17 | - */ | 20 | +/** @Description @Author cxy @Date 2021/12/6 20:23 */ |
18 | @Service | 21 | @Service |
19 | @RequiredArgsConstructor | 22 | @RequiredArgsConstructor |
20 | public class DoActionServiceImpl extends AbstractBaseService<DoActionMapper, DoAction> | 23 | public class DoActionServiceImpl extends AbstractBaseService<DoActionMapper, DoAction> |
21 | - implements DoActionService { | ||
22 | - private final DoActionMapper actionMapper; | ||
23 | - @Override | ||
24 | - public List<DoAction> getActions(String sceneId) { | ||
25 | - LambdaQueryWrapper filter = new QueryWrapper<DoAction>().lambda() | ||
26 | - .eq(DoAction::getSceneLinkageId,sceneId); | ||
27 | - return actionMapper.selectList(filter); | ||
28 | - } | 24 | + implements DoActionService { |
25 | + @Override | ||
26 | + public List<DoAction> getActions(String sceneId) { | ||
27 | + LambdaQueryWrapper filter = | ||
28 | + new QueryWrapper<DoAction>().lambda().eq(DoAction::getSceneLinkageId, sceneId); | ||
29 | + return baseMapper.selectList(filter); | ||
30 | + } | ||
29 | 31 | ||
32 | + @Override | ||
33 | + public List<DoActionDTO> findDoActionByAlarmProfileIds( | ||
34 | + String tenantId, Set<String> alarmProfileIds) { | ||
35 | + List<DoAction> doActions = | ||
36 | + baseMapper.selectList( | ||
37 | + new LambdaQueryWrapper<DoAction>() | ||
38 | + .eq(TenantBaseEntity::getTenantId, tenantId) | ||
39 | + .in(DoAction::getAlarmProfileId, alarmProfileIds)); | ||
40 | + return doActions.stream() | ||
41 | + .map(doAction -> doAction.getDTO(DoActionDTO.class)) | ||
42 | + .collect(Collectors.toList()); | ||
43 | + } | ||
30 | } | 44 | } |
@@ -21,10 +21,7 @@ import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; | @@ -21,10 +21,7 @@ import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; | ||
21 | import org.thingsboard.server.dao.yunteng.service.UserOrganizationMappingService; | 21 | import org.thingsboard.server.dao.yunteng.service.UserOrganizationMappingService; |
22 | import org.thingsboard.server.dao.yunteng.service.YtAlarmContactService; | 22 | import org.thingsboard.server.dao.yunteng.service.YtAlarmContactService; |
23 | 23 | ||
24 | -import java.util.ArrayList; | ||
25 | -import java.util.List; | ||
26 | -import java.util.Map; | ||
27 | -import java.util.Set; | 24 | +import java.util.*; |
28 | import java.util.stream.Collectors; | 25 | import java.util.stream.Collectors; |
29 | 26 | ||
30 | /** | 27 | /** |
@@ -165,7 +162,7 @@ public class YtAlarmContactServiceImpl extends AbstractBaseService<AlarmContactM | @@ -165,7 +162,7 @@ public class YtAlarmContactServiceImpl extends AbstractBaseService<AlarmContactM | ||
165 | String organizationId = (String) queryMap.get("organizationId"); | 162 | String organizationId = (String) queryMap.get("organizationId"); |
166 | queryMap.put("tenantId", tenantId); | 163 | queryMap.put("tenantId", tenantId); |
167 | if (StringUtils.isNotEmpty(organizationId)) { | 164 | if (StringUtils.isNotEmpty(organizationId)) { |
168 | - List<String> ids = new ArrayList<>(); | 165 | + Set<String> ids = new HashSet<>(); |
169 | ids.add(organizationId); | 166 | ids.add(organizationId); |
170 | // 查询该组织的所有子类 | 167 | // 查询该组织的所有子类 |
171 | List<OrganizationDTO> organizationDTOS = | 168 | List<OrganizationDTO> organizationDTOS = |
@@ -35,158 +35,76 @@ import java.util.*; | @@ -35,158 +35,76 @@ import java.util.*; | ||
35 | @Service | 35 | @Service |
36 | @RequiredArgsConstructor | 36 | @RequiredArgsConstructor |
37 | @Slf4j | 37 | @Slf4j |
38 | -public class YtDeviceProfileServiceImpl | ||
39 | - implements YtDeviceProfileService { | ||
40 | - | ||
41 | - private final DeviceMapper deviceMapper; | ||
42 | - private final AlarmProfileMapper alarmProfileMapper; | ||
43 | - private final CacheUtils cacheUtils; | ||
44 | - | ||
45 | - private final YtJpaDeviceProfileDao deviceProfileDao; | ||
46 | - | ||
47 | - @Override | ||
48 | - @Transactional | ||
49 | - public DeviceProfileDTO insertOrUpdate(String deviceProfileId, DeviceProfileDTO deviceProfileDTO) { | ||
50 | - if (StringUtils.isBlank(deviceProfileDTO.getId())) { | ||
51 | - return insert(deviceProfileId, deviceProfileDTO); | ||
52 | - } else { | ||
53 | - return update(deviceProfileDTO); | ||
54 | - } | ||
55 | - } | ||
56 | - | ||
57 | - private DeviceProfileDTO update(DeviceProfileDTO deviceProfileDTO) { | ||
58 | - | ||
59 | - // 如果原来不是TCP或者更新也不是TCP 那就需要check | ||
60 | -// if (!deviceProfile.getTransportType().equals(TransportTypeEnum.TCP) | ||
61 | -// || !deviceProfileDTO.getTransportType().equals(TransportTypeEnum.TCP)) { | ||
62 | -// checkDeviceProfile(deviceProfileDTO, deviceProfile); | ||
63 | -// } | ||
64 | - LambdaQueryWrapper<AlarmProfile> filter = new QueryWrapper<AlarmProfile>().lambda() | ||
65 | - .eq(AlarmProfile::getTenantId, deviceProfileDTO.getTenantId()) | ||
66 | - .eq(AlarmProfile::getDeviceProfileId, deviceProfileDTO.getId()); | ||
67 | - List<AlarmProfile> oldAlarms = alarmProfileMapper.selectList(filter); | ||
68 | - List<String> oldIds = new ArrayList<>(); | ||
69 | - for (AlarmProfile item : oldAlarms) { | ||
70 | - oldIds.add(item.getId()); | ||
71 | - } | ||
72 | - | ||
73 | - | ||
74 | - Optional.ofNullable(deviceProfileDTO.getAlarmProfile()) | ||
75 | -// .filter(alarmProfileDTO -> StringUtils.isNotBlank(alarmProfileDTO.getId())) | ||
76 | - .ifPresent(alarmProfileDTO -> { | ||
77 | - AlarmProfile alarmProfile = buildAlarmDto2Entity(deviceProfileDTO.getId(), deviceProfileDTO.getTenantId(), alarmProfileDTO); | ||
78 | - String alarmId = alarmProfileDTO.getId(); | ||
79 | - if (StringUtils.isNotBlank(alarmId)) { | ||
80 | - alarmProfileMapper.updateById(alarmProfile); | ||
81 | - oldIds.remove(alarmId); | ||
82 | - } | ||
83 | - { | ||
84 | - alarmProfileMapper.insert(alarmProfile); | ||
85 | - } | ||
86 | - }); | ||
87 | - if(!oldIds.isEmpty()){ | ||
88 | - alarmProfileMapper.deleteBatchIds(oldIds); | ||
89 | - } | ||
90 | - return deviceProfileDTO; | 38 | +public class YtDeviceProfileServiceImpl implements YtDeviceProfileService { |
39 | + | ||
40 | + private final DeviceMapper deviceMapper; | ||
41 | + | ||
42 | + private final YtJpaDeviceProfileDao deviceProfileDao; | ||
43 | + | ||
44 | + @Override | ||
45 | + public boolean validateFormdata(DeviceProfileDTO ytDeviceProfileDTO) { | ||
46 | + TenantId tenantId = new TenantId(UUID.fromString(ytDeviceProfileDTO.getTenantId())); | ||
47 | + if (StringUtils.isBlank(ytDeviceProfileDTO.getId())) { | ||
48 | + // 判断数据库是否已存在名字相同的设备配置 | ||
49 | + | ||
50 | + DeviceProfile profile = deviceProfileDao.findByName(tenantId, ytDeviceProfileDTO.getName()); | ||
51 | + if (profile != null) { | ||
52 | + throw new YtDataValidationException(ErrorMessage.NAME_ALREADY_EXISTS.getMessage()); | ||
53 | + } | ||
54 | + } else { | ||
55 | + UUID profileId = UUID.fromString(ytDeviceProfileDTO.getId()); | ||
56 | + DeviceProfile profile = deviceProfileDao.findById(tenantId, profileId); | ||
57 | + if (profile == null) { | ||
58 | + throw new YtDataValidationException(ErrorMessage.TENANT_MISMATCHING.getMessage()); | ||
59 | + } | ||
91 | } | 60 | } |
92 | 61 | ||
93 | - private DeviceProfileDTO insert(String deviceProfileId, DeviceProfileDTO deviceProfileDTO) { | ||
94 | - Optional.ofNullable(deviceProfileDTO.getAlarmProfile()) | ||
95 | - .map( | ||
96 | - alarmProfileDTO -> { | ||
97 | - AlarmProfile alarmProfile = buildAlarmDto2Entity(deviceProfileId, deviceProfileDTO.getTenantId(), alarmProfileDTO); | ||
98 | - alarmProfileMapper.insert(alarmProfile); | ||
99 | - alarmProfile.copyToDTO(alarmProfileDTO); | ||
100 | - return alarmProfileDTO; | ||
101 | - }); | ||
102 | - return deviceProfileDTO; | 62 | + return false; |
63 | + } | ||
64 | + | ||
65 | + @Override | ||
66 | + @Transactional | ||
67 | + public void checkDeviceProfiles(String tenantId, Set<String> ids) { | ||
68 | + // check if ids bind to device | ||
69 | + int count = | ||
70 | + deviceMapper.selectCount( | ||
71 | + new QueryWrapper<YtDevice>().lambda().in(YtDevice::getProfileId, ids)); | ||
72 | + if (count > 0) { | ||
73 | + throw new YtDataValidationException("有设备使用待删除配置,请先删除设备或者修改设备配置"); | ||
103 | } | 74 | } |
104 | - | ||
105 | - @NotNull | ||
106 | - private AlarmProfile buildAlarmDto2Entity(String deviceProfileId, String tenantId, AlarmProfileDTO alarmProfileDTO) { | ||
107 | - alarmProfileDTO.setDeviceProfileId(deviceProfileId); | ||
108 | - alarmProfileDTO.setTenantId(tenantId); | ||
109 | - AlarmProfile alarmProfile = new AlarmProfile(); | ||
110 | - alarmProfileDTO.copyToEntity(alarmProfile, ModelConstants.TablePropertyMapping.UPDATE_TIME, | ||
111 | - ModelConstants.TablePropertyMapping.UPDATER); | ||
112 | - return alarmProfile; | ||
113 | - } | ||
114 | - | ||
115 | - @Override | ||
116 | - public boolean validateFormdata(DeviceProfileDTO ytDeviceProfileDTO) { | ||
117 | - TenantId tenantId = new TenantId(UUID.fromString(ytDeviceProfileDTO.getTenantId())); | ||
118 | - if (StringUtils.isBlank(ytDeviceProfileDTO.getId())) { | ||
119 | - // 判断数据库是否已存在名字相同的设备配置 | ||
120 | - | ||
121 | - DeviceProfile profile = deviceProfileDao.findByName(tenantId, ytDeviceProfileDTO.getName()); | ||
122 | - if (profile != null) { | ||
123 | - throw new YtDataValidationException(ErrorMessage.NAME_ALREADY_EXISTS.getMessage()); | ||
124 | - } | ||
125 | - } else { | ||
126 | - UUID profileId = UUID.fromString(ytDeviceProfileDTO.getId()); | ||
127 | - DeviceProfile profile = deviceProfileDao.findById(tenantId, profileId); | ||
128 | - if (profile == null) { | ||
129 | - throw new YtDataValidationException(ErrorMessage.TENANT_MISMATCHING.getMessage()); | ||
130 | - } | ||
131 | - } | ||
132 | - | ||
133 | - return false; | ||
134 | - } | ||
135 | - | ||
136 | - @Override | ||
137 | - @Transactional | ||
138 | - public void deleteDeviceProfiles(String tenantId, Set<String> ids) { | ||
139 | - // check if ids bind to device | ||
140 | - int count = | ||
141 | - deviceMapper.selectCount(new QueryWrapper<YtDevice>().lambda().in(YtDevice::getProfileId, ids)); | ||
142 | - if (count > 0) { | ||
143 | - throw new YtDataValidationException("有设备使用待删除配置,请先删除设备或者修改设备配置"); | ||
144 | - } | ||
145 | - | ||
146 | - for (String id : ids) { | ||
147 | - Validator.validateId(UUID.fromString(id),"Incorrect device profile id to deal."); | ||
148 | - LambdaQueryWrapper filter = new LambdaQueryWrapper<AlarmProfile>() | ||
149 | - .eq(AlarmProfile::getTenantId, tenantId) | ||
150 | - .in(AlarmProfile::getDeviceProfileId, id); | ||
151 | - alarmProfileMapper.delete(filter); | ||
152 | - } | ||
153 | - | ||
154 | - } | ||
155 | - | ||
156 | - @Override | ||
157 | - public Optional<DeviceProfileDTO> getDeviceProfile(String tenantId, String id) { | ||
158 | - TenantId tenant = new TenantId(UUID.fromString(tenantId)); | ||
159 | - DeviceProfile profile = deviceProfileDao.findById(tenant, UUID.fromString(id)); | ||
160 | - return Optional.ofNullable(profile).map(entity -> { | ||
161 | - DeviceProfileDTO result = ReflectUtils.getDeviceProfileDTO(entity); | ||
162 | - AlarmProfile alarmProfile = alarmProfileMapper.selectOne(new QueryWrapper<AlarmProfile>().lambda().eq(AlarmProfile::getDeviceProfileId, result.getId())); | ||
163 | - Optional.ofNullable(alarmProfile).ifPresent(alarmProfile1 -> { | ||
164 | - AlarmProfileDTO alarmProfileDTO = new AlarmProfileDTO(); | ||
165 | - BeanUtils.copyProperties(alarmProfile, alarmProfileDTO); | ||
166 | - result.setAlarmProfile(alarmProfileDTO); | 75 | + } |
76 | + | ||
77 | + @Override | ||
78 | + public Optional<DeviceProfileDTO> getDeviceProfile(String tenantId, String id) { | ||
79 | + TenantId tenant = new TenantId(UUID.fromString(tenantId)); | ||
80 | + DeviceProfile profile = deviceProfileDao.findById(tenant, UUID.fromString(id)); | ||
81 | + return Optional.ofNullable(profile) | ||
82 | + .map( | ||
83 | + entity -> { | ||
84 | + DeviceProfileDTO result = ReflectUtils.getDeviceProfileDTO(entity); | ||
85 | + return result; | ||
167 | }); | 86 | }); |
168 | - | ||
169 | - return result; | ||
170 | - }); | ||
171 | - } | ||
172 | - | ||
173 | - @Override | ||
174 | - public YtPageData<DeviceProfileDTO> page(PageLink pageLink, String tenantIdStr, String transportType) { | ||
175 | - | ||
176 | - | ||
177 | - TenantId tenantId = new TenantId(UUID.fromString(tenantIdStr)); | ||
178 | - Validator.validatePageLink(pageLink); | ||
179 | - PageData<DeviceProfileDTO> tbDatas = deviceProfileDao.findDeviceProfileInfos(pageLink, tenantId, transportType); | ||
180 | - YtPageData<DeviceProfileDTO> result = new YtPageData<>(tbDatas.getData(), tbDatas.getTotalElements()); | ||
181 | - | ||
182 | - return result; | ||
183 | - } | ||
184 | - | ||
185 | - | ||
186 | - @Override | ||
187 | - public List<DeviceProfileDTO> findDeviceProfile(String tenantId) { | ||
188 | - UUID profileId = UUID.fromString(tenantId); | ||
189 | - List<DeviceProfileDTO> results = deviceProfileDao.findDeviceProfileByTenantId(new TenantId(profileId)); | ||
190 | - return results; | ||
191 | - } | 87 | + } |
88 | + | ||
89 | + @Override | ||
90 | + public YtPageData<DeviceProfileDTO> page( | ||
91 | + PageLink pageLink, String tenantIdStr, String transportType) { | ||
92 | + | ||
93 | + TenantId tenantId = new TenantId(UUID.fromString(tenantIdStr)); | ||
94 | + Validator.validatePageLink(pageLink); | ||
95 | + PageData<DeviceProfileDTO> tbDatas = | ||
96 | + deviceProfileDao.findDeviceProfileInfos(pageLink, tenantId, transportType); | ||
97 | + YtPageData<DeviceProfileDTO> result = | ||
98 | + new YtPageData<>(tbDatas.getData(), tbDatas.getTotalElements()); | ||
99 | + | ||
100 | + return result; | ||
101 | + } | ||
102 | + | ||
103 | + @Override | ||
104 | + public List<DeviceProfileDTO> findDeviceProfile(String tenantId) { | ||
105 | + UUID profileId = UUID.fromString(tenantId); | ||
106 | + List<DeviceProfileDTO> results = | ||
107 | + deviceProfileDao.findDeviceProfileByTenantId(new TenantId(profileId)); | ||
108 | + return results; | ||
109 | + } | ||
192 | } | 110 | } |
@@ -69,8 +69,9 @@ public class YtNoticeServiceImpl implements YtNoticeService { | @@ -69,8 +69,9 @@ public class YtNoticeServiceImpl implements YtNoticeService { | ||
69 | Organization organization = organizationMapper.selectOne(organizationQueryWrapper); | 69 | Organization organization = organizationMapper.selectOne(organizationQueryWrapper); |
70 | 70 | ||
71 | QueryWrapper<AlarmProfile> alarmProfileQueryWrapper = new QueryWrapper<AlarmProfile>(); | 71 | QueryWrapper<AlarmProfile> alarmProfileQueryWrapper = new QueryWrapper<AlarmProfile>(); |
72 | - alarmProfileQueryWrapper.lambda() | ||
73 | - .eq(AlarmProfile::getDeviceProfileId, device.getProfileId()); | 72 | + //TODO junlianglee 修改通知 |
73 | +// alarmProfileQueryWrapper.lambda() | ||
74 | +// .eq(AlarmProfile::getDeviceProfileId, device.getProfileId()); | ||
74 | AlarmProfile alarmProfile = alarmProfileMapper.selectOne(alarmProfileQueryWrapper); | 75 | AlarmProfile alarmProfile = alarmProfileMapper.selectOne(alarmProfileQueryWrapper); |
75 | 76 | ||
76 | 77 |
1 | package org.thingsboard.server.dao.yunteng.service; | 1 | package org.thingsboard.server.dao.yunteng.service; |
2 | 2 | ||
3 | import org.thingsboard.server.common.data.yunteng.dto.AlarmProfileDTO; | 3 | import org.thingsboard.server.common.data.yunteng.dto.AlarmProfileDTO; |
4 | +import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO; | ||
5 | +import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; | ||
4 | import org.thingsboard.server.dao.yunteng.entities.AlarmProfile; | 6 | import org.thingsboard.server.dao.yunteng.entities.AlarmProfile; |
5 | 7 | ||
6 | import java.util.List; | 8 | import java.util.List; |
9 | +import java.util.Map; | ||
7 | 10 | ||
8 | public interface AlarmProfileService extends BaseService<AlarmProfile> { | 11 | public interface AlarmProfileService extends BaseService<AlarmProfile> { |
12 | + | ||
13 | + YtPageData<AlarmProfileDTO> page( | ||
14 | + boolean isPtTenantAdmin, String tenantId, String currentUserId, Map<String, Object> queryMap); | ||
15 | + | ||
9 | List<AlarmProfileDTO> findAlarmProfilesByContactId(String contactId, String tenantId); | 16 | List<AlarmProfileDTO> findAlarmProfilesByContactId(String contactId, String tenantId); |
17 | + | ||
18 | + AlarmProfileDTO saveOrUpdateAlarmProfile(AlarmProfileDTO alarmProfileDTO); | ||
19 | + | ||
20 | + AlarmProfileDTO updateAlarmProFileStatus(String alarmProfileId, String tenantId, Integer status); | ||
21 | + | ||
22 | + boolean deleteAlarmProFile(DeleteDTO deleteDTO); | ||
10 | } | 23 | } |
1 | package org.thingsboard.server.dao.yunteng.service; | 1 | package org.thingsboard.server.dao.yunteng.service; |
2 | 2 | ||
3 | -import org.thingsboard.server.common.data.id.EntityId; | ||
4 | -import org.thingsboard.server.common.data.yunteng.dto.TriggerDTO; | 3 | +import org.thingsboard.server.common.data.yunteng.dto.DoActionDTO; |
5 | import org.thingsboard.server.dao.yunteng.entities.DoAction; | 4 | import org.thingsboard.server.dao.yunteng.entities.DoAction; |
6 | 5 | ||
7 | import java.util.List; | 6 | import java.util.List; |
7 | +import java.util.Set; | ||
8 | 8 | ||
9 | /** | 9 | /** |
10 | * @Description | 10 | * @Description |
@@ -14,4 +14,6 @@ import java.util.List; | @@ -14,4 +14,6 @@ import java.util.List; | ||
14 | public interface DoActionService extends BaseService<DoAction>{ | 14 | public interface DoActionService extends BaseService<DoAction>{ |
15 | 15 | ||
16 | List<DoAction> getActions(String sceneId); | 16 | List<DoAction> getActions(String sceneId); |
17 | + | ||
18 | + List<DoActionDTO> findDoActionByAlarmProfileIds(String tenantId, Set<String> alarmProfileIds); | ||
17 | } | 19 | } |
@@ -9,9 +9,8 @@ import java.util.Optional; | @@ -9,9 +9,8 @@ import java.util.Optional; | ||
9 | import java.util.Set; | 9 | import java.util.Set; |
10 | 10 | ||
11 | public interface YtDeviceProfileService { | 11 | public interface YtDeviceProfileService { |
12 | - DeviceProfileDTO insertOrUpdate(String deviceProfileId, DeviceProfileDTO deviceProfileDTO); | ||
13 | 12 | ||
14 | - void deleteDeviceProfiles(String tenantId, Set<String> ids); | 13 | + void checkDeviceProfiles(String tenantId, Set<String> ids); |
15 | 14 | ||
16 | Optional<DeviceProfileDTO> getDeviceProfile(String tenantId, String id); | 15 | Optional<DeviceProfileDTO> getDeviceProfile(String tenantId, String id); |
17 | 16 |
@@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
8 | <result property="doContext" column="do_context" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/> | 8 | <result property="doContext" column="do_context" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/> |
9 | <result property="outTarget" column="out_target" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/> | 9 | <result property="outTarget" column="out_target" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/> |
10 | <result property="sceneLinkageId" column="scene_linkage_id"/> | 10 | <result property="sceneLinkageId" column="scene_linkage_id"/> |
11 | + <result property="alarmProfileId" column="alarm_profile_id"/> | ||
11 | <result property="description" column="description"/> | 12 | <result property="description" column="description"/> |
12 | <result property="tenantId" column="tenant_id"/> | 13 | <result property="tenantId" column="tenant_id"/> |
13 | <result property="updater" column="updater"/> | 14 | <result property="updater" column="updater"/> |