Commit 7dace73fc857f29aeb2b36648d469ed8e956d988
1 parent
907a1201
fix: fix some bug【DEFECT-745 、DEFECT-744、DEFECT-743、DEFECT-742】 on teambition
Showing
21 changed files
with
216 additions
and
100 deletions
... | ... | @@ -62,12 +62,14 @@ public class YtConfigurationCenterController extends BaseController { |
62 | 62 | if (null != orderType) { |
63 | 63 | queryMap.put(ORDER_TYPE, orderType.name()); |
64 | 64 | } |
65 | - return ytConfigurationCenterService.page(queryMap); | |
65 | + queryMap.put("userId",getCurrentUser().getCurrentUserId()); | |
66 | + return ytConfigurationCenterService.page(queryMap, getCurrentUser().isTenantAdmin()); | |
66 | 67 | } |
67 | 68 | |
68 | 69 | @PostMapping |
69 | 70 | @ApiOperation("新增") |
70 | - @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:configuration:center:post'})") | |
71 | + @PreAuthorize( | |
72 | + "@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:configuration:center:post'})") | |
71 | 73 | public ResponseEntity<ConfigurationCenterDTO> save( |
72 | 74 | @Validated({AddGroup.class}) @RequestBody ConfigurationCenterDTO configurationCenterDTO) |
73 | 75 | throws ThingsboardException { |
... | ... | @@ -78,7 +80,8 @@ public class YtConfigurationCenterController extends BaseController { |
78 | 80 | |
79 | 81 | @PutMapping |
80 | 82 | @ApiOperation("修改") |
81 | - @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:configuration:center:update'})") | |
83 | + @PreAuthorize( | |
84 | + "@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:configuration:center:update'})") | |
82 | 85 | public ResponseEntity<ConfigurationCenterDTO> update( |
83 | 86 | @Validated({UpdateGroup.class}) @RequestBody ConfigurationCenterDTO configurationCenterDTO) |
84 | 87 | throws ThingsboardException { |
... | ... | @@ -89,7 +92,8 @@ public class YtConfigurationCenterController extends BaseController { |
89 | 92 | |
90 | 93 | @DeleteMapping |
91 | 94 | @ApiOperation("删除") |
92 | - @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:configuration:center:delete'})") | |
95 | + @PreAuthorize( | |
96 | + "@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:configuration:center:delete'})") | |
93 | 97 | public ResponseEntity<Boolean> delete( |
94 | 98 | @Validated({DeleteGroup.class}) @RequestBody DeleteDTO deleteDTO) |
95 | 99 | throws ThingsboardException { |
... | ... | @@ -99,7 +103,8 @@ public class YtConfigurationCenterController extends BaseController { |
99 | 103 | |
100 | 104 | @GetMapping("/get_configuration_info/{id}") |
101 | 105 | @ApiOperation("获取组态信息") |
102 | - @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:configuration:center:get_configuration_info:get'})") | |
106 | + @PreAuthorize( | |
107 | + "@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:configuration:center:get_configuration_info:get'})") | |
103 | 108 | public ResponseEntity<ConfigurationContentInfoDTO> getConfigurationInfos( |
104 | 109 | @PathVariable("id") String id) throws ThingsboardException { |
105 | 110 | return ResponseEntity.ok( | ... | ... |
... | ... | @@ -43,7 +43,9 @@ public class YtDataBoardController extends BaseController { |
43 | 43 | @RequestParam(PAGE_SIZE) int pageSize, |
44 | 44 | @RequestParam(PAGE) int page, |
45 | 45 | @RequestParam(value = ORDER_FILED, required = false) String orderBy, |
46 | - @RequestParam(value = ORDER_TYPE, required = false) OrderTypeEnum orderType) | |
46 | + @RequestParam(value = ORDER_TYPE, required = false) OrderTypeEnum orderType, | |
47 | + @RequestParam(value = "organizationId", required = false) String organizationId, | |
48 | + @RequestParam(value = "name", required = false) String name) | |
47 | 49 | throws ThingsboardException { |
48 | 50 | Map<String, Object> queryMap = new HashMap<>(); |
49 | 51 | queryMap.put(PAGE_SIZE, pageSize); |
... | ... | @@ -51,7 +53,14 @@ public class YtDataBoardController extends BaseController { |
51 | 53 | queryMap.put(ORDER_FILED, orderBy); |
52 | 54 | queryMap.put(ORDER_TYPE, orderType); |
53 | 55 | queryMap.put(TENANT_ID, getCurrentUser().getCurrentTenantId()); |
54 | - return ytDataBoardService.dataBoardPage(queryMap); | |
56 | + if (StringUtils.isNotBlank(organizationId)) { | |
57 | + queryMap.put("organizationId", organizationId); | |
58 | + } | |
59 | + if (StringUtils.isNotBlank(name)) { | |
60 | + queryMap.put("name", name); | |
61 | + } | |
62 | + queryMap.put("userId",getCurrentUser().getCurrentUserId()); | |
63 | + return ytDataBoardService.dataBoardPage(queryMap, getCurrentUser().isTenantAdmin()); | |
55 | 64 | } |
56 | 65 | |
57 | 66 | @DeleteMapping | ... | ... |
... | ... | @@ -63,6 +63,7 @@ public class YtReportFormConfigController extends BaseController { |
63 | 63 | if (orderType != null) { |
64 | 64 | queryMap.put(ORDER_TYPE, orderType.name()); |
65 | 65 | } |
66 | + queryMap.put("userId",getCurrentUser().getCurrentUserId()); | |
66 | 67 | if (null != startTime && null != endTime) { |
67 | 68 | if (startTime > endTime) { |
68 | 69 | throw new YtDataValidationException( |
... | ... | @@ -71,7 +72,7 @@ public class YtReportFormConfigController extends BaseController { |
71 | 72 | queryMap.put("startTime", new Timestamp(startTime).toLocalDateTime()); |
72 | 73 | queryMap.put("endTime", new Timestamp(endTime).toLocalDateTime()); |
73 | 74 | } |
74 | - return reportFormConfigService.page(queryMap); | |
75 | + return reportFormConfigService.page(queryMap, getCurrentUser().isTenantAdmin()); | |
75 | 76 | } |
76 | 77 | |
77 | 78 | @PostMapping | ... | ... |
... | ... | @@ -75,12 +75,14 @@ public class YtReportGenerateRecordController extends BaseController { |
75 | 75 | if (orderType != null) { |
76 | 76 | queryMap.put(ORDER_TYPE, orderType.name()); |
77 | 77 | } |
78 | - return reportFormGenerateRecordService.page(queryMap); | |
78 | + queryMap.put("userId", getCurrentUser().getCurrentUserId()); | |
79 | + return reportFormGenerateRecordService.page(queryMap, getCurrentUser().isTenantAdmin()); | |
79 | 80 | } |
80 | 81 | |
81 | 82 | @DeleteMapping |
82 | 83 | @ApiOperation("删除") |
83 | - @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:report:generate:record:delete'})") | |
84 | + @PreAuthorize( | |
85 | + "@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:report:generate:record:delete'})") | |
84 | 86 | public ResponseResult<Boolean> deleteReportGenerateRecord( |
85 | 87 | @Validated({DeleteGroup.class}) @RequestBody DeleteDTO deleteDTO) { |
86 | 88 | return reportFormGenerateRecordService.deleteReportGenerateRecord(deleteDTO) | ... | ... |
... | ... | @@ -28,46 +28,51 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant. |
28 | 28 | @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{})") |
29 | 29 | public class YtVideoPlatformController extends BaseController { |
30 | 30 | |
31 | - private final YtVideoPlatformService videoPlatformService; | |
31 | + private final YtVideoPlatformService videoPlatformService; | |
32 | 32 | |
33 | - @GetMapping(params = {PAGE_SIZE, PAGE}) | |
34 | - @ApiOperation("分页") | |
35 | - public YtPageData<YtVideoPlatformDTO> pageVideoPlatform( | |
36 | - @RequestParam(PAGE_SIZE) int pageSize, | |
37 | - @RequestParam(PAGE) int page, | |
38 | - @RequestParam(value = "host", required = false) String host, | |
39 | - @RequestParam(value = ORDER_FILED, required = false) String orderBy, | |
40 | - @RequestParam(value = ORDER_TYPE, required = false) OrderTypeEnum orderType) | |
41 | - throws ThingsboardException { | |
33 | + @GetMapping(params = {PAGE_SIZE, PAGE}) | |
34 | + @ApiOperation("分页") | |
35 | + public YtPageData<YtVideoPlatformDTO> pageVideoPlatform( | |
36 | + @RequestParam(PAGE_SIZE) int pageSize, | |
37 | + @RequestParam(PAGE) int page, | |
38 | + @RequestParam(value = "host", required = false) String host, | |
39 | + @RequestParam(value = ORDER_FILED, required = false) String orderBy, | |
40 | + @RequestParam(value = ORDER_TYPE, required = false) OrderTypeEnum orderType) | |
41 | + throws ThingsboardException { | |
42 | 42 | |
43 | + IPage<YtVideoPlatformEntity> pageInfo = | |
44 | + videoPlatformService.getPage(page, pageSize, orderBy, orderType); | |
45 | + return videoPlatformService.page( | |
46 | + pageInfo, | |
47 | + getCurrentUser().isPtTenantAdmin(), | |
48 | + getCurrentUser().getCurrentTenantId(), | |
49 | + getCurrentUser().getCurrentUserId(), | |
50 | + host); | |
51 | + } | |
43 | 52 | |
44 | - IPage<YtVideoPlatformEntity> pageInfo = videoPlatformService.getPage(page, pageSize, orderBy, orderType); | |
45 | - return videoPlatformService.page(pageInfo, getCurrentUser().isPtTenantAdmin(), | |
46 | - getCurrentUser().getCurrentTenantId(), | |
47 | - getCurrentUser().getCurrentUserId(), host); | |
48 | - } | |
53 | + @PostMapping | |
54 | + @ApiOperation("新增|编辑") | |
55 | + @PreAuthorize( | |
56 | + "@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:video:platform:post','api:yt:video:platform:update'})") | |
57 | + public YtVideoPlatformDTO saveOrUpdateVideoPlatform( | |
58 | + @Validated @RequestBody YtVideoPlatformDTO dto) throws ThingsboardException { | |
59 | + dto.setTenantId(getCurrentUser().getCurrentTenantId()); | |
60 | + return videoPlatformService.saveOrUpdate(dto); | |
61 | + } | |
49 | 62 | |
50 | - @PostMapping | |
51 | - @ApiOperation("新增|编辑") | |
52 | - @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:video:platform:post','api:yt:video:platform:update'})") | |
53 | - public YtVideoPlatformDTO saveOrUpdateVideoPlatform( | |
54 | - @Validated @RequestBody YtVideoPlatformDTO dto) throws ThingsboardException { | |
55 | - dto.setTenantId(getCurrentUser().getCurrentTenantId()); | |
56 | - return videoPlatformService.saveOrUpdate(dto); | |
57 | - } | |
63 | + @DeleteMapping | |
64 | + @ApiOperation("删除") | |
65 | + @PreAuthorize( | |
66 | + "@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:video:platform:delete'})") | |
67 | + public boolean deleteVideoPlatform(@Validated(DeleteGroup.class) @RequestBody DeleteDTO deleteDTO) | |
68 | + throws ThingsboardException { | |
69 | + deleteDTO.setTenantId(getCurrentUser().getCurrentTenantId()); | |
70 | + return videoPlatformService.deleteDataByIds(deleteDTO); | |
71 | + } | |
58 | 72 | |
59 | - @DeleteMapping | |
60 | - @ApiOperation("删除") | |
61 | - @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:video:platform:delete'})") | |
62 | - public boolean deleteVideoPlatform(@Validated(DeleteGroup.class) @RequestBody DeleteDTO deleteDTO) | |
63 | - throws ThingsboardException { | |
64 | - deleteDTO.setTenantId(getCurrentUser().getCurrentTenantId()); | |
65 | - return videoPlatformService.deleteDataByIds(deleteDTO); | |
66 | - } | |
67 | - @GetMapping | |
68 | - @ApiOperation("获取当前用户的流媒体配置列表") | |
69 | - public List<YtVideoPlatformDTO> getVideoPlatformsByUser() throws ThingsboardException { | |
70 | - return videoPlatformService.getVideoPlatformsByUser(getCurrentUser().isTenantAdmin(), | |
71 | - getCurrentUser().getCurrentTenantId(), getCurrentUser().getCurrentUserId()); | |
72 | - } | |
73 | + @GetMapping | |
74 | + @ApiOperation("获取当前用户的流媒体配置列表") | |
75 | + public List<YtVideoPlatformDTO> getVideoPlatformsByUser() throws ThingsboardException { | |
76 | + return videoPlatformService.getVideoPlatformsByUser(getCurrentUser().getCurrentTenantId()); | |
77 | + } | |
73 | 78 | } | ... | ... |
... | ... | @@ -17,6 +17,10 @@ public class DataBoardDTO extends TenantDTO { |
17 | 17 | @NotEmpty(message = "数据看板名称不能为空或者空字符串",groups = AddGroup.class) |
18 | 18 | private String name; |
19 | 19 | |
20 | + @ApiModelProperty(value = "组织ID", required = true) | |
21 | + @NotEmpty(message = "组织ID不能为空或者空字符串",groups = AddGroup.class) | |
22 | + private String organizationId; | |
23 | + | |
20 | 24 | @ApiModelProperty(value = "视图类型") |
21 | 25 | private ViewType viewType = ViewType.PRIVATE_VIEW; |
22 | 26 | ... | ... |
... | ... | @@ -19,6 +19,9 @@ public class ReportGenerateRecordDTO extends TenantDTO { |
19 | 19 | @ApiModelProperty(value = "组织名称") |
20 | 20 | private String organizationName; |
21 | 21 | |
22 | + @ApiModelProperty(value = "组织ID") | |
23 | + private String organizationId; | |
24 | + | |
22 | 25 | @ApiModelProperty(value = "数据对比:0历史数据 1环比 2同比") |
23 | 26 | private Integer dataCompare; |
24 | 27 | ... | ... |
... | ... | @@ -4,9 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
4 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
5 | 5 | import lombok.RequiredArgsConstructor; |
6 | 6 | import lombok.extern.slf4j.Slf4j; |
7 | -import org.apache.commons.lang3.ObjectUtils; | |
8 | 7 | import org.apache.commons.lang3.StringUtils; |
9 | -import org.jetbrains.annotations.Nullable; | |
10 | 8 | import org.springframework.stereotype.Service; |
11 | 9 | import org.springframework.transaction.annotation.Transactional; |
12 | 10 | import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; |
... | ... | @@ -44,7 +42,7 @@ public class UserOrganizationMappingServiceImpl implements UserOrganizationMappi |
44 | 42 | organizationMapper.findOrganizationTreeList(tenantId, List.of(ids)).stream() |
45 | 43 | .map(OrganizationDTO::getId) |
46 | 44 | .collect(Collectors.toList()); |
47 | - if (null == collect || collect.size()==0) { | |
45 | + if (null == collect || collect.size() == 0) { | |
48 | 46 | return new ArrayList<>(); |
49 | 47 | } else { |
50 | 48 | Set<String> clearList = new HashSet<>(); |
... | ... | @@ -76,8 +74,6 @@ public class UserOrganizationMappingServiceImpl implements UserOrganizationMappi |
76 | 74 | batchInsert(userId, organizationIds); |
77 | 75 | } |
78 | 76 | |
79 | - | |
80 | - | |
81 | 77 | @Override |
82 | 78 | public List<String> getOrganizationIdsByUserId(String userId) { |
83 | 79 | if (StringUtils.isEmpty(userId)) { |
... | ... | @@ -104,15 +100,18 @@ public class UserOrganizationMappingServiceImpl implements UserOrganizationMappi |
104 | 100 | } |
105 | 101 | |
106 | 102 | @Override |
107 | - public List<String> getEnableOrganizationIds(boolean isPtTenantAdmin, String tenantId, String userId, String organizationId) { | |
103 | + public List<String> getEnableOrganizationIds( | |
104 | + boolean isPtTenantAdmin, String tenantId, String userId, String organizationId) { | |
108 | 105 | List<String> organizationIds = null; |
109 | 106 | if (StringUtils.isNotEmpty(organizationId)) { |
110 | - List<OrganizationDTO> organizationList = organizationMapper.findOrganizationTreeList(tenantId, new HashSet<>(List.of(organizationId))); | |
111 | - if(organizationList.size()== FastIotConstants.MagicNumber.ZERO){ | |
107 | + List<OrganizationDTO> organizationList = | |
108 | + organizationMapper.findOrganizationTreeList( | |
109 | + tenantId, new HashSet<>(List.of(organizationId))); | |
110 | + if (organizationList.size() == FastIotConstants.MagicNumber.ZERO) { | |
112 | 111 | throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); |
113 | 112 | } |
114 | - organizationIds = organizationList.stream() | |
115 | - .map(BaseDTO::getId).distinct().collect(Collectors.toList()); | |
113 | + organizationIds = | |
114 | + organizationList.stream().map(BaseDTO::getId).distinct().collect(Collectors.toList()); | |
116 | 115 | } else { |
117 | 116 | if (!isPtTenantAdmin) { |
118 | 117 | organizationIds = getOrganizationIdsByUserId(userId); |
... | ... | @@ -120,4 +119,23 @@ public class UserOrganizationMappingServiceImpl implements UserOrganizationMappi |
120 | 119 | } |
121 | 120 | return organizationIds; |
122 | 121 | } |
122 | + | |
123 | + @Override | |
124 | + public List<String> compareOrganizationIdsByCustomerId( | |
125 | + List<String> organizationIds, String userId) { | |
126 | + int zero = FastIotConstants.MagicNumber.ZERO; | |
127 | + List<String> list = getOrganizationIdsByUserId(userId); | |
128 | + if (organizationIds != null && organizationIds.size() > zero && list.size() > zero) { | |
129 | + List<String> result = new ArrayList<>(); | |
130 | + for (String id : organizationIds) { | |
131 | + if (list.contains(id)) { | |
132 | + result.add(id); | |
133 | + } | |
134 | + } | |
135 | + if (result.size() > zero) { | |
136 | + return result; | |
137 | + } | |
138 | + } | |
139 | + return list; | |
140 | + } | |
123 | 141 | } | ... | ... |
... | ... | @@ -16,9 +16,9 @@ import org.thingsboard.server.dao.yunteng.entities.ConfigurationCenter; |
16 | 16 | import org.thingsboard.server.dao.yunteng.mapper.ConfigurationCenterMapper; |
17 | 17 | import org.thingsboard.server.dao.yunteng.mapper.OrganizationMapper; |
18 | 18 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
19 | +import org.thingsboard.server.dao.yunteng.service.UserOrganizationMappingService; | |
19 | 20 | import org.thingsboard.server.dao.yunteng.service.YtConfigurationCenterService; |
20 | 21 | import org.thingsboard.server.dao.yunteng.service.YtConfigurationContentService; |
21 | - | |
22 | 22 | import java.util.HashSet; |
23 | 23 | import java.util.List; |
24 | 24 | import java.util.Map; |
... | ... | @@ -32,9 +32,12 @@ public class YtConfigurationCenterServiceImpl |
32 | 32 | implements YtConfigurationCenterService { |
33 | 33 | private final OrganizationMapper organizationMapper; |
34 | 34 | private final YtConfigurationContentService ytConfigurationContentService; |
35 | + private final UserOrganizationMappingService userOrganizationMappingService; | |
35 | 36 | |
36 | 37 | @Override |
37 | - public YtPageData<ConfigurationCenterDTO> page(Map<String, Object> queryMap) { | |
38 | + public YtPageData<ConfigurationCenterDTO> page( | |
39 | + Map<String, Object> queryMap, boolean tenantAdmin) { | |
40 | + List<String> organizationIds = null; | |
38 | 41 | if (null != queryMap.get("organizationId")) { |
39 | 42 | String organizationId = (String) queryMap.get("organizationId"); |
40 | 43 | List<OrganizationDTO> organizationList = |
... | ... | @@ -43,11 +46,16 @@ public class YtConfigurationCenterServiceImpl |
43 | 46 | if (organizationList.size() == FastIotConstants.MagicNumber.ZERO) { |
44 | 47 | throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); |
45 | 48 | } |
46 | - List<String> organizationIds = | |
49 | + organizationIds = | |
47 | 50 | organizationList.stream().map(BaseDTO::getId).distinct().collect(Collectors.toList()); |
48 | - if (organizationIds.size() > FastIotConstants.MagicNumber.ZERO) { | |
49 | - queryMap.put("organizationIds", organizationIds); | |
50 | - } | |
51 | + } | |
52 | + if (!tenantAdmin && null != queryMap.get("userId")) { | |
53 | + // 获取客户的组织关系 | |
54 | + String userId = (String) queryMap.get("userId"); | |
55 | + organizationIds = userOrganizationMappingService.compareOrganizationIdsByCustomerId(organizationIds,userId); | |
56 | + } | |
57 | + if (null != organizationIds && organizationIds.size() > FastIotConstants.MagicNumber.ZERO) { | |
58 | + queryMap.put("organizationIds", organizationIds); | |
51 | 59 | } |
52 | 60 | IPage<ConfigurationCenter> page = |
53 | 61 | getPage(queryMap, FastIotConstants.DefaultOrder.CREATE_TIME, false); |
... | ... | @@ -59,14 +67,16 @@ public class YtConfigurationCenterServiceImpl |
59 | 67 | @Override |
60 | 68 | @Transactional |
61 | 69 | public ConfigurationCenterDTO saveConfiguration(ConfigurationCenterDTO configurationCenterDTO) { |
62 | - ConfigurationCenter configurationCenter = configurationCenterDTO.getEntity(ConfigurationCenter.class); | |
70 | + ConfigurationCenter configurationCenter = | |
71 | + configurationCenterDTO.getEntity(ConfigurationCenter.class); | |
63 | 72 | baseMapper.insert(configurationCenter); |
64 | 73 | ConfigurationContentDTO contentDTO = new ConfigurationContentDTO(); |
65 | 74 | contentDTO.setTenantId(configurationCenter.getTenantId()); |
66 | 75 | contentDTO.setType(FastIotConstants.PC_TYPE); |
67 | 76 | contentDTO.setName(FastIotConstants.FIRST_PAGE_NAME); |
68 | 77 | contentDTO.setConfigurationId(configurationCenter.getId()); |
69 | - contentDTO.setContent("<mxGraphModel><root><mxCell id=\"0\"/><mxCell id=\"1\" parent=\"0\"/></root></mxGraphModel>"); | |
78 | + contentDTO.setContent( | |
79 | + "<mxGraphModel><root><mxCell id=\"0\"/><mxCell id=\"1\" parent=\"0\"/></root></mxGraphModel>"); | |
70 | 80 | ytConfigurationContentService.saveConfigurationContent(contentDTO); |
71 | 81 | return configurationCenterDTO; |
72 | 82 | } | ... | ... |
... | ... | @@ -3,43 +3,78 @@ package org.thingsboard.server.dao.yunteng.impl; |
3 | 3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
4 | 4 | import com.baomidou.mybatisplus.core.metadata.IPage; |
5 | 5 | import com.fasterxml.jackson.databind.JsonNode; |
6 | +import lombok.RequiredArgsConstructor; | |
6 | 7 | import org.apache.commons.lang3.StringUtils; |
7 | 8 | import org.springframework.stereotype.Service; |
8 | 9 | import org.springframework.transaction.annotation.Transactional; |
9 | 10 | import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; |
10 | 11 | import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException; |
11 | 12 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; |
13 | +import org.thingsboard.server.common.data.yunteng.dto.BaseDTO; | |
12 | 14 | import org.thingsboard.server.common.data.yunteng.dto.DataBoardDTO; |
13 | 15 | import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO; |
16 | +import org.thingsboard.server.common.data.yunteng.dto.OrganizationDTO; | |
14 | 17 | import org.thingsboard.server.common.data.yunteng.dto.board.ComponentLayoutDTO; |
15 | 18 | import org.thingsboard.server.common.data.yunteng.utils.JacksonUtil; |
16 | 19 | import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; |
17 | 20 | import org.thingsboard.server.dao.yunteng.entities.DataBoard; |
18 | 21 | import org.thingsboard.server.dao.yunteng.mapper.DataBoardMapper; |
22 | +import org.thingsboard.server.dao.yunteng.mapper.OrganizationMapper; | |
19 | 23 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
24 | +import org.thingsboard.server.dao.yunteng.service.UserOrganizationMappingService; | |
20 | 25 | import org.thingsboard.server.dao.yunteng.service.YtDataBoardService; |
21 | 26 | |
22 | -import java.util.ArrayList; | |
23 | -import java.util.List; | |
24 | -import java.util.Map; | |
25 | -import java.util.Optional; | |
27 | +import java.util.*; | |
28 | +import java.util.stream.Collectors; | |
26 | 29 | |
27 | 30 | @Service |
31 | +@RequiredArgsConstructor | |
28 | 32 | public class YtDataBoardServiceImpl extends AbstractBaseService<DataBoardMapper, DataBoard> |
29 | 33 | implements YtDataBoardService { |
34 | + private final OrganizationMapper organizationMapper; | |
35 | + private final UserOrganizationMappingService userOrganizationMappingService; | |
36 | + | |
30 | 37 | @Override |
31 | - public YtPageData<DataBoardDTO> dataBoardPage(Map<String, Object> queryMap) { | |
38 | + public YtPageData<DataBoardDTO> dataBoardPage(Map<String, Object> queryMap, boolean tenantAdmin) { | |
39 | + int zero = FastIotConstants.MagicNumber.ZERO; | |
40 | + String name = null != queryMap.get("name") ? queryMap.get("name").toString() : null; | |
32 | 41 | String tenantId = |
33 | 42 | Optional.ofNullable(queryMap.get("tenantId")) |
34 | - .map(obj -> queryMap.get("tenantId").toString()) | |
43 | + .map(Object::toString) | |
35 | 44 | .orElseThrow( |
36 | 45 | () -> { |
37 | 46 | throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); |
38 | 47 | }); |
48 | + String organizationId = | |
49 | + null != queryMap.get("organizationId") ? queryMap.get("organizationId").toString() : null; | |
50 | + List<String> organizationIds = null; | |
51 | + if (null != organizationId) { | |
52 | + List<OrganizationDTO> list = | |
53 | + organizationMapper.findOrganizationTreeList( | |
54 | + (String) queryMap.get("tenantId"), new HashSet<>(List.of(organizationId))); | |
55 | + if (list.size() == zero) { | |
56 | + throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); | |
57 | + } | |
58 | + organizationIds = list.stream().map(BaseDTO::getId).distinct().collect(Collectors.toList()); | |
59 | + } | |
60 | + | |
61 | + if (!tenantAdmin && null != queryMap.get("userId")) { | |
62 | + // 获取客户的组织关系 | |
63 | + String userId = (String) queryMap.get("userId"); | |
64 | + organizationIds = | |
65 | + userOrganizationMappingService.compareOrganizationIdsByCustomerId( | |
66 | + organizationIds, userId); | |
67 | + } | |
39 | 68 | IPage<DataBoard> page = |
40 | 69 | baseMapper.selectPage( |
41 | 70 | getPage(queryMap, FastIotConstants.DefaultOrder.CREATE_TIME, false), |
42 | - new LambdaQueryWrapper<DataBoard>().eq(DataBoard::getTenantId, tenantId)); | |
71 | + new LambdaQueryWrapper<DataBoard>() | |
72 | + .eq(DataBoard::getTenantId, tenantId) | |
73 | + .like(StringUtils.isNotEmpty(name), DataBoard::getName, name) | |
74 | + .in( | |
75 | + null != organizationIds && organizationIds.size() > zero, | |
76 | + DataBoard::getOrganizationId, | |
77 | + organizationIds)); | |
43 | 78 | return getPageData(page, DataBoardDTO.class); |
44 | 79 | } |
45 | 80 | |
... | ... | @@ -127,5 +162,5 @@ public class YtDataBoardServiceImpl extends AbstractBaseService<DataBoardMapper, |
127 | 162 | @Override |
128 | 163 | public boolean updateDataBoardComponentNum(String id, String tenantId, int count) { |
129 | 164 | return baseMapper.updateDataBoardComponentNum(id, tenantId, count); |
130 | - } | |
165 | + } | |
131 | 166 | } | ... | ... |
... | ... | @@ -22,10 +22,8 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; |
22 | 22 | import org.thingsboard.server.dao.yunteng.entities.ReportFormConfig; |
23 | 23 | import org.thingsboard.server.dao.yunteng.mapper.OrganizationMapper; |
24 | 24 | import org.thingsboard.server.dao.yunteng.mapper.ReportFormConfigMapper; |
25 | -import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; | |
26 | -import org.thingsboard.server.dao.yunteng.service.YtReportFormConfigService; | |
27 | -import org.thingsboard.server.dao.yunteng.service.YtReportGenerateRecordService; | |
28 | -import org.thingsboard.server.dao.yunteng.service.YtSysJobService; | |
25 | +import org.thingsboard.server.dao.yunteng.service.*; | |
26 | + | |
29 | 27 | import java.util.*; |
30 | 28 | import java.util.stream.Collectors; |
31 | 29 | |
... | ... | @@ -38,9 +36,9 @@ public class YtReportFromConfigServiceImpl |
38 | 36 | private final OrganizationMapper organizationMapper; |
39 | 37 | private final YtSysJobService ytSysJobService; |
40 | 38 | private final YtReportGenerateRecordService ytReportGenerateRecordService; |
41 | - | |
39 | + private final UserOrganizationMappingService userOrganizationMappingService; | |
42 | 40 | @Override |
43 | - public YtPageData<ReportFormConfigDTO> page(Map<String, Object> queryMap) { | |
41 | + public YtPageData<ReportFormConfigDTO> page(Map<String, Object> queryMap,boolean tenantAdmin) { | |
44 | 42 | String tenantId = |
45 | 43 | Optional.ofNullable(queryMap.get("tenantId")).map(Object::toString).orElse(null); |
46 | 44 | List<String> organizationIds = |
... | ... | @@ -58,6 +56,10 @@ public class YtReportFromConfigServiceImpl |
58 | 56 | return null; |
59 | 57 | }) |
60 | 58 | .orElse(null); |
59 | + if(!tenantAdmin && null != queryMap.get("userId")){ | |
60 | + String userId = queryMap.get("userId").toString(); | |
61 | + organizationIds = userOrganizationMappingService.compareOrganizationIdsByCustomerId(organizationIds,userId); | |
62 | + } | |
61 | 63 | queryMap.put("organizationIds", organizationIds); |
62 | 64 | IPage<ReportFormConfigDTO> page = |
63 | 65 | baseMapper.getReportFormConfigPage( | ... | ... |
... | ... | @@ -37,6 +37,7 @@ import org.thingsboard.server.dao.timeseries.TimeseriesService; |
37 | 37 | import org.thingsboard.server.dao.yunteng.entities.ReportGenerateRecord; |
38 | 38 | import org.thingsboard.server.dao.yunteng.mapper.ReportGenerateRecordMapper; |
39 | 39 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
40 | +import org.thingsboard.server.dao.yunteng.service.UserOrganizationMappingService; | |
40 | 41 | import org.thingsboard.server.dao.yunteng.service.YtOrganizationService; |
41 | 42 | import org.thingsboard.server.dao.yunteng.service.YtReportGenerateRecordService; |
42 | 43 | |
... | ... | @@ -62,9 +63,11 @@ public class YtReportGenerateRecordServiceImpl |
62 | 63 | private final YtOrganizationService ytOrganizationService; |
63 | 64 | private final TimeseriesService tsService; |
64 | 65 | private final FileStorageService fileStorageService; |
66 | + private final UserOrganizationMappingService userOrganizationMappingService; | |
65 | 67 | |
66 | 68 | @Override |
67 | - public YtPageData<ReportGenerateRecordDTO> page(Map<String, Object> queryMap) { | |
69 | + public YtPageData<ReportGenerateRecordDTO> page( | |
70 | + Map<String, Object> queryMap, boolean tenantAdmin) { | |
68 | 71 | String reportConfigName = |
69 | 72 | Optional.ofNullable(queryMap.get("reportConfigName")).map(Object::toString).orElse(null); |
70 | 73 | LocalDateTime startTime = |
... | ... | @@ -75,6 +78,12 @@ public class YtReportGenerateRecordServiceImpl |
75 | 78 | Optional.ofNullable(queryMap.get("executeStatus")) |
76 | 79 | .map(obj -> Integer.valueOf(obj.toString())) |
77 | 80 | .orElse(null); |
81 | + List<String> organizationIds = null; | |
82 | + if (!tenantAdmin && null != queryMap.get("userId")) { | |
83 | + organizationIds = | |
84 | + userOrganizationMappingService.getOrganizationIdsByUserId( | |
85 | + queryMap.get("userId").toString()); | |
86 | + } | |
78 | 87 | IPage<ReportGenerateRecord> iPage = |
79 | 88 | baseMapper.selectPage( |
80 | 89 | getPage(queryMap, "execute_time", false), |
... | ... | @@ -89,7 +98,11 @@ public class YtReportGenerateRecordServiceImpl |
89 | 98 | null != startTime && null != endTime, |
90 | 99 | ReportGenerateRecord::getExecuteTime, |
91 | 100 | startTime, |
92 | - endTime)); | |
101 | + endTime) | |
102 | + .in( | |
103 | + organizationIds != null && organizationIds.size() > 0, | |
104 | + ReportGenerateRecord::getOrganizationId, | |
105 | + organizationIds)); | |
93 | 106 | return getPageData(iPage, ReportGenerateRecordDTO.class); |
94 | 107 | } |
95 | 108 | |
... | ... | @@ -144,6 +157,7 @@ public class YtReportGenerateRecordServiceImpl |
144 | 157 | dto.setJobId(jobId); |
145 | 158 | dto.setReportConfigName(reportFormConfigDTO.getName()); |
146 | 159 | dto.setOrganizationName(null != organizationDTO ? organizationDTO.getName() : null); |
160 | + dto.setOrganizationId(null != organizationDTO ? organizationDTO.getId() : null); | |
147 | 161 | dto.setDataCompare(reportFormConfigDTO.getDataType()); |
148 | 162 | dto.setExecuteTime(time); |
149 | 163 | dto.setCreateTime(time); | ... | ... |
... | ... | @@ -79,11 +79,9 @@ public class YtVideoPlatformServiceImpl extends AbstractBaseService<YtVideoPlatf |
79 | 79 | } |
80 | 80 | |
81 | 81 | @Override |
82 | - public List<YtVideoPlatformDTO> getVideoPlatformsByUser(boolean isTenantAdmin, String tenantId, | |
83 | - String customerUserId) { | |
82 | + public List<YtVideoPlatformDTO> getVideoPlatformsByUser(String tenantId) { | |
84 | 83 | return baseMapper.selectList(new LambdaQueryWrapper<YtVideoPlatformEntity>(). |
85 | - eq(YtVideoPlatformEntity::getTenantId, tenantId) | |
86 | - .eq(!isTenantAdmin, YtVideoPlatformEntity::getCreator, customerUserId)).stream() | |
84 | + eq(YtVideoPlatformEntity::getTenantId, tenantId)).stream() | |
87 | 85 | .map(ytVideoPlatformEntity -> ytVideoPlatformEntity |
88 | 86 | .getDTO(YtVideoPlatformDTO.class)).collect(Collectors.toList()); |
89 | 87 | } | ... | ... |
... | ... | @@ -42,4 +42,12 @@ public interface UserOrganizationMappingService { |
42 | 42 | * @return |
43 | 43 | */ |
44 | 44 | List<String> getEnableOrganizationIds(boolean isPtTenantAdmin, String tenantId, String userId, String organizationId); |
45 | + | |
46 | + /** | |
47 | + * 比较一个组织与另一个用户查出来的组织相同的数据结果 | |
48 | + * @param organizationIds 源组织 | |
49 | + * @param userId 用户ID | |
50 | + * @return 返回相同的组织 | |
51 | + */ | |
52 | + List<String> compareOrganizationIdsByCustomerId(List<String> organizationIds,String userId); | |
45 | 53 | } | ... | ... |
... | ... | @@ -8,7 +8,7 @@ import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; |
8 | 8 | import java.util.Map; |
9 | 9 | |
10 | 10 | public interface YtConfigurationCenterService { |
11 | - YtPageData<ConfigurationCenterDTO> page(Map<String, Object> queryMap); | |
11 | + YtPageData<ConfigurationCenterDTO> page(Map<String, Object> queryMap,boolean tenantAdmin); | |
12 | 12 | |
13 | 13 | ConfigurationCenterDTO saveConfiguration(ConfigurationCenterDTO configurationCenterDTO); |
14 | 14 | ... | ... |
... | ... | @@ -15,7 +15,7 @@ public interface YtDataBoardService { |
15 | 15 | * @param queryMap 分页查询条件 |
16 | 16 | * @return 分页数据 |
17 | 17 | */ |
18 | - YtPageData<DataBoardDTO> dataBoardPage(Map<String, Object> queryMap); | |
18 | + YtPageData<DataBoardDTO> dataBoardPage(Map<String, Object> queryMap,boolean tenantAdmin); | |
19 | 19 | |
20 | 20 | /** |
21 | 21 | * 修改或保存数据看板 | ... | ... |
... | ... | @@ -11,7 +11,7 @@ import java.util.List; |
11 | 11 | import java.util.Map; |
12 | 12 | |
13 | 13 | public interface YtReportFormConfigService { |
14 | - YtPageData<ReportFormConfigDTO> page(Map<String, Object> queryMap); | |
14 | + YtPageData<ReportFormConfigDTO> page(Map<String, Object> queryMap,boolean tenantAdmin); | |
15 | 15 | |
16 | 16 | ReportFormConfigDTO saveOrUpdateReportFormConfig(ReportFormConfigDTO report) throws SchedulerException; |
17 | 17 | ... | ... |
... | ... | @@ -11,7 +11,7 @@ import java.util.Map; |
11 | 11 | |
12 | 12 | public interface YtReportGenerateRecordService { |
13 | 13 | |
14 | - YtPageData<ReportGenerateRecordDTO> page(Map<String, Object> queryMap); | |
14 | + YtPageData<ReportGenerateRecordDTO> page(Map<String, Object> queryMap,boolean tenantAdmin); | |
15 | 15 | |
16 | 16 | ReportGenerateRecordDTO saveOrUpdateReportGenerateRecord(ReportGenerateRecordDTO recordDTO); |
17 | 17 | ... | ... |
... | ... | @@ -16,30 +16,27 @@ public interface YtVideoPlatformService extends BaseService<YtVideoPlatformEntit |
16 | 16 | * @param tenantId 租户ID |
17 | 17 | * @param currentUserId 用户ID |
18 | 18 | * @param host 流媒体地址 |
19 | - * @return | |
20 | 19 | */ |
21 | 20 | YtPageData<YtVideoPlatformDTO> page(IPage<YtVideoPlatformEntity> pageInfo, |
22 | 21 | boolean isPtTenantAdmin, String tenantId, String currentUserId, String host); |
23 | 22 | |
24 | - /** | |
25 | - * @param dto | |
26 | - * @return | |
23 | + /** 保存或更新流媒体配置 | |
24 | + * @param dto 流媒体配置信息 | |
25 | + * @return 流媒体信息 | |
27 | 26 | */ |
28 | 27 | YtVideoPlatformDTO saveOrUpdate(YtVideoPlatformDTO dto); |
29 | 28 | |
30 | - /** | |
31 | - * @param deleteDTO | |
32 | - * @return | |
29 | + /** 删除流媒体配置 | |
30 | + * @param deleteDTO 删除参数 | |
31 | + * @return true成功 false失败 | |
33 | 32 | */ |
34 | 33 | boolean deleteDataByIds(DeleteDTO deleteDTO); |
35 | 34 | |
36 | 35 | /** |
37 | 36 | * 获取当前用户的流媒体配置信息列表 |
38 | - * @param isTenantAdmin 是否租户管理员 | |
39 | 37 | * @param tenantId 租户ID |
40 | - * @param customerUserId 客户ID | |
41 | - * @return | |
38 | + * @return 流媒体配置列表 | |
42 | 39 | */ |
43 | - List<YtVideoPlatformDTO> getVideoPlatformsByUser(boolean isTenantAdmin, String tenantId,String customerUserId); | |
40 | + List<YtVideoPlatformDTO> getVideoPlatformsByUser(String tenantId); | |
44 | 41 | |
45 | 42 | } | ... | ... |