Showing
11 changed files
with
202 additions
and
8 deletions
... | ... | @@ -38,6 +38,7 @@ public class TkInspectionRecordController extends BaseController { |
38 | 38 | @RequestParam(PAGE_SIZE) int pageSize, |
39 | 39 | @RequestParam(PAGE) int page, |
40 | 40 | @RequestParam(value = "inspectionPlanId", required = false) String inspectionPlanId, |
41 | + @RequestParam(value = "inspectionPlanName", required = false) String inspectionPlanName, | |
41 | 42 | @RequestParam(value = "inspectorId", required = false) String inspectorId, |
42 | 43 | @RequestParam(value = "startTime", required = false) Long startTime, |
43 | 44 | @RequestParam(value = "endTime", required = false) Long endTime, |
... | ... | @@ -50,6 +51,10 @@ public class TkInspectionRecordController extends BaseController { |
50 | 51 | queryMap.put("inspectionPlanId", inspectionPlanId); |
51 | 52 | } |
52 | 53 | |
54 | + if (StringUtils.isNotBlank(inspectionPlanName)) { | |
55 | + queryMap.put("inspectionPlanName", inspectionPlanName); | |
56 | + } | |
57 | + | |
53 | 58 | if (StringUtils.isNotBlank(inspectorId)) { |
54 | 59 | queryMap.put("inspectorId", inspectorId); |
55 | 60 | } | ... | ... |
common/data/src/main/java/org/thingsboard/server/common/data/yunteng/dto/TkInspectionDetailsDTO.java
... | ... | @@ -14,6 +14,9 @@ public class TkInspectionDetailsDTO extends TenantDTO { |
14 | 14 | @ApiModelProperty("巡检设备") |
15 | 15 | private String checkDeviceId; |
16 | 16 | |
17 | + @ApiModelProperty("设备详情") | |
18 | + private TkDeviceAccountDTO tkDeviceAccountDTO; | |
19 | + | |
17 | 20 | @ApiModelProperty("巡检内容") |
18 | 21 | private String planDetails; |
19 | 22 | ... | ... |
... | ... | @@ -42,4 +42,10 @@ public class TkInspectionPlanDTO extends TenantDTO { |
42 | 42 | |
43 | 43 | @ApiModelProperty("巡检明细") |
44 | 44 | private List<TkCheckDetailsDTO> tkCheckDetailsDTOList; |
45 | + | |
46 | + @ApiModelProperty("巡检记录") | |
47 | + private List<TkInspectionRecordDTO> tkInspectionRecordDTOList; | |
48 | + | |
49 | + @ApiModelProperty("巡检计划id集合") | |
50 | + private List<String> inspectionPlanIdList; | |
45 | 51 | } | ... | ... |
... | ... | @@ -23,9 +23,15 @@ public class TkInspectionRecordDTO extends TenantDTO { |
23 | 23 | @ApiModelProperty("巡检计划") |
24 | 24 | private String inspectionPlanId; |
25 | 25 | |
26 | + @ApiModelProperty("巡检计划实体") | |
27 | + private TkInspectionPlanDTO tkInspectionPlanDTO; | |
28 | + | |
26 | 29 | @ApiModelProperty("巡检人") |
27 | 30 | private String inspectorId; |
28 | 31 | |
32 | + @ApiModelProperty("巡检人实体") | |
33 | + private UserDTO userDTO; | |
34 | + | |
29 | 35 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
30 | 36 | @ApiModelProperty(value = "巡检日期") |
31 | 37 | @JsonSerialize(using = LocalDateTimeSerializer.class) | ... | ... |
... | ... | @@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; |
10 | 10 | import com.google.common.collect.Sets; |
11 | 11 | import lombok.RequiredArgsConstructor; |
12 | 12 | import lombok.extern.slf4j.Slf4j; |
13 | +import org.apache.commons.collections4.CollectionUtils; | |
13 | 14 | import org.apache.commons.lang3.RandomStringUtils; |
14 | 15 | import org.apache.commons.lang3.StringUtils; |
15 | 16 | import org.springframework.context.ApplicationEventPublisher; |
... | ... | @@ -40,6 +41,7 @@ import org.thingsboard.server.common.data.yunteng.enums.UserStatusEnum; |
40 | 41 | import org.thingsboard.server.common.data.yunteng.utils.ReflectUtils; |
41 | 42 | import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils; |
42 | 43 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; |
44 | +import org.thingsboard.server.dao.model.sql.UserEntity; | |
43 | 45 | import org.thingsboard.server.dao.user.UserService; |
44 | 46 | import org.thingsboard.server.dao.yunteng.entities.*; |
45 | 47 | import org.thingsboard.server.dao.yunteng.mapper.*; |
... | ... | @@ -940,6 +942,25 @@ public class SysUserServiceImpl extends AbstractBaseService<UserMapper, SysUserE |
940 | 942 | return entities.stream().map(entity->entity.getId()).collect(Collectors.toList()); |
941 | 943 | } |
942 | 944 | |
945 | + @Override | |
946 | + public List<UserDTO> findUserByUserIdList(List<String> userIdList) { | |
947 | + if (CollectionUtils.isEmpty(userIdList)) { | |
948 | + return new ArrayList<>(0); | |
949 | + } | |
950 | + | |
951 | + List<SysUserEntity> entities = | |
952 | + baseMapper.selectList( | |
953 | + new LambdaQueryWrapper<SysUserEntity>() | |
954 | + .in(SysUserEntity::getId, userIdList)); | |
955 | + if (null != entities && !entities.isEmpty()) { | |
956 | + return entities.stream() | |
957 | + .map(entity -> entity.getDTO(UserDTO.class)) | |
958 | + .collect(Collectors.toList()); | |
959 | + } | |
960 | + | |
961 | + return null; | |
962 | + } | |
963 | + | |
943 | 964 | private void checkPassword(AccountReqDTO accountReqDTO, SysUserEntity user) { |
944 | 965 | if (null == user |
945 | 966 | || StringUtils.isEmpty(accountReqDTO.getPassword()) | ... | ... |
... | ... | @@ -7,10 +7,13 @@ import lombok.extern.slf4j.Slf4j; |
7 | 7 | import org.apache.commons.collections4.CollectionUtils; |
8 | 8 | import org.apache.commons.lang3.StringUtils; |
9 | 9 | import org.springframework.stereotype.Service; |
10 | +import org.thingsboard.server.common.data.exception.ThingsboardException; | |
11 | +import org.thingsboard.server.common.data.yunteng.dto.TkDeviceAccountDTO; | |
10 | 12 | import org.thingsboard.server.common.data.yunteng.dto.TkInspectionDetailsDTO; |
11 | 13 | import org.thingsboard.server.dao.yunteng.entities.TkInspectionDetailsEntity; |
12 | 14 | import org.thingsboard.server.dao.yunteng.mapper.TkInspectionDetailsMapper; |
13 | 15 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
16 | +import org.thingsboard.server.dao.yunteng.service.TkDeviceAccountService; | |
14 | 17 | import org.thingsboard.server.dao.yunteng.service.TkInspectionDetailsService; |
15 | 18 | |
16 | 19 | import java.util.ArrayList; |
... | ... | @@ -22,6 +25,8 @@ import java.util.stream.Collectors; |
22 | 25 | @Slf4j |
23 | 26 | public class TkInspectionDetailsServiceImpl extends AbstractBaseService<TkInspectionDetailsMapper, TkInspectionDetailsEntity> |
24 | 27 | implements TkInspectionDetailsService { |
28 | + private TkDeviceAccountService tkDeviceAccountService; | |
29 | + | |
25 | 30 | @Override |
26 | 31 | public List<TkInspectionDetailsDTO> batchSave(List<TkInspectionDetailsDTO> tkInspectionDetailsDTOList, String inspectionRecordId) { |
27 | 32 | List<TkInspectionDetailsDTO> oldTkInspectionDetailsDTOList = listByInspectionRecordId(inspectionRecordId); |
... | ... | @@ -97,6 +102,13 @@ public class TkInspectionDetailsServiceImpl extends AbstractBaseService<TkInspec |
97 | 102 | return CollectionUtils.emptyIfNull(tkInspectionDetailsEntityList).stream().map(entity -> { |
98 | 103 | TkInspectionDetailsDTO tkInspectionDetailsDTO = new TkInspectionDetailsDTO(); |
99 | 104 | entity.copyToDTO(tkInspectionDetailsDTO); |
105 | + try { | |
106 | + TkDeviceAccountDTO tkDeviceAccountDTO = tkDeviceAccountService.load(tkInspectionDetailsDTO.getCheckDeviceId()); | |
107 | + tkInspectionDetailsDTO.setTkDeviceAccountDTO(tkDeviceAccountDTO); | |
108 | + } catch (ThingsboardException e) { | |
109 | + throw new RuntimeException(e); | |
110 | + } | |
111 | + | |
100 | 112 | return tkInspectionDetailsDTO; |
101 | 113 | }).collect(Collectors.toList()); |
102 | 114 | } | ... | ... |
... | ... | @@ -6,11 +6,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
6 | 6 | import lombok.RequiredArgsConstructor; |
7 | 7 | import lombok.extern.slf4j.Slf4j; |
8 | 8 | import org.apache.commons.collections4.CollectionUtils; |
9 | +import org.apache.commons.collections4.MapUtils; | |
9 | 10 | import org.apache.commons.lang3.StringUtils; |
10 | 11 | import org.springframework.stereotype.Service; |
11 | 12 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; |
12 | 13 | import org.thingsboard.server.common.data.yunteng.dto.TkCheckDetailsDTO; |
13 | 14 | import org.thingsboard.server.common.data.yunteng.dto.TkInspectionPlanDTO; |
15 | +import org.thingsboard.server.common.data.yunteng.dto.TkInspectionRecordDTO; | |
14 | 16 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; |
15 | 17 | import org.thingsboard.server.dao.yunteng.entities.TkInspectionPlanEntity; |
16 | 18 | import org.thingsboard.server.dao.yunteng.mapper.TkInspectionPlanMapper; |
... | ... | @@ -23,6 +25,7 @@ import java.time.LocalDateTime; |
23 | 25 | import java.util.ArrayList; |
24 | 26 | import java.util.List; |
25 | 27 | import java.util.Map; |
28 | +import java.util.stream.Collectors; | |
26 | 29 | |
27 | 30 | @Service |
28 | 31 | @RequiredArgsConstructor |
... | ... | @@ -68,7 +71,25 @@ public class TkInspectionPlanServiceImpl extends AbstractBaseService<TkInspectio |
68 | 71 | IPage<TkInspectionPlanEntity> page = baseMapper.selectPage(getPage(queryMap, "create_time", false), |
69 | 72 | wrapper); |
70 | 73 | |
71 | - return getPageData(page, TkInspectionPlanDTO.class); | |
74 | + if (CollectionUtils.isEmpty(page.getRecords())) { | |
75 | + return getPageData(page, TkInspectionPlanDTO.class); | |
76 | + } | |
77 | + | |
78 | + List<TkInspectionPlanEntity> inspectionPlanEntityList = page.getRecords(); | |
79 | + List<String> inspectionPlanIdList = inspectionPlanEntityList.stream().map(TkInspectionPlanEntity::getId).collect(Collectors.toList()); | |
80 | + Map<String, List<TkInspectionRecordDTO>> recordDtoMap = tkInspectionRecordService.mapByInspectionPlanId(inspectionPlanIdList); | |
81 | + if (MapUtils.isEmpty(recordDtoMap)) { | |
82 | + return getPageData(page, TkInspectionPlanDTO.class); | |
83 | + } | |
84 | + | |
85 | + TkPageData<TkInspectionPlanDTO> dtoPage = getPageData(page, TkInspectionPlanDTO.class); | |
86 | + List<TkInspectionPlanDTO> tkInspectionPlanDTOList = new ArrayList<>(dtoPage.getItems()); | |
87 | + tkInspectionPlanDTOList.forEach(tkInspectionPlanDTO -> { | |
88 | + tkInspectionPlanDTO.setTkInspectionRecordDTOList(recordDtoMap.get(tkInspectionPlanDTO.getId())); | |
89 | + }); | |
90 | + | |
91 | + dtoPage.setItems(tkInspectionPlanDTOList); | |
92 | + return dtoPage; | |
72 | 93 | } |
73 | 94 | |
74 | 95 | @Override |
... | ... | @@ -124,6 +145,34 @@ public class TkInspectionPlanServiceImpl extends AbstractBaseService<TkInspectio |
124 | 145 | return count > 0; |
125 | 146 | } |
126 | 147 | |
148 | + @Override | |
149 | + public List<TkInspectionPlanDTO> selectByCondition(TkInspectionPlanDTO tkInspectionPlanDTO) { | |
150 | + if (tkInspectionPlanDTO == null || StringUtils.isBlank(tkInspectionPlanDTO.getTenantId())) { | |
151 | + return new ArrayList<>(0); | |
152 | + } | |
153 | + | |
154 | + QueryWrapper<TkInspectionPlanEntity> wrapper = new QueryWrapper<>(); | |
155 | + LambdaQueryWrapper<TkInspectionPlanEntity> lambda = wrapper.lambda(); | |
156 | + lambda.eq(TkInspectionPlanEntity::getTenantId, tkInspectionPlanDTO.getTenantId()); | |
157 | + if (StringUtils.isNotBlank(tkInspectionPlanDTO.getName())) { | |
158 | + lambda.like(TkInspectionPlanEntity::getName, tkInspectionPlanDTO.getName()); | |
159 | + } | |
160 | + | |
161 | + if (CollectionUtils.isNotEmpty(tkInspectionPlanDTO.getInspectionPlanIdList())) { | |
162 | + lambda.in(TkInspectionPlanEntity::getId, tkInspectionPlanDTO.getInspectionPlanIdList()); | |
163 | + } | |
164 | + | |
165 | + // todo ymk 后续有什么查询条件再加 | |
166 | + | |
167 | + lambda.orderByAsc(TkInspectionPlanEntity::getCreateTime); | |
168 | + List<TkInspectionPlanEntity> inspectionPlanEntityList = baseMapper.selectList(wrapper); | |
169 | + return CollectionUtils.emptyIfNull(inspectionPlanEntityList).stream().map(inspectionPlanEntity -> { | |
170 | + TkInspectionPlanDTO dto = new TkInspectionPlanDTO(); | |
171 | + inspectionPlanEntity.copyToDTO(dto); | |
172 | + return dto; | |
173 | + }).collect(Collectors.toList()); | |
174 | + } | |
175 | + | |
127 | 176 | private void checkDto(TkInspectionPlanDTO dto) { |
128 | 177 | if (StringUtils.isBlank(dto.getTenantId())) { |
129 | 178 | throw new TkDataValidationException("租户id为空!"); | ... | ... |
... | ... | @@ -7,21 +7,22 @@ import lombok.RequiredArgsConstructor; |
7 | 7 | import lombok.extern.slf4j.Slf4j; |
8 | 8 | import org.apache.commons.collections4.CollectionUtils; |
9 | 9 | import org.apache.commons.lang3.StringUtils; |
10 | +import org.springframework.context.annotation.Lazy; | |
10 | 11 | import org.springframework.stereotype.Service; |
11 | 12 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; |
12 | 13 | import org.thingsboard.server.common.data.yunteng.dto.TkInspectionDetailsDTO; |
14 | +import org.thingsboard.server.common.data.yunteng.dto.TkInspectionPlanDTO; | |
13 | 15 | import org.thingsboard.server.common.data.yunteng.dto.TkInspectionRecordDTO; |
16 | +import org.thingsboard.server.common.data.yunteng.dto.UserDTO; | |
14 | 17 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; |
15 | 18 | import org.thingsboard.server.dao.yunteng.entities.TkInspectionRecordEntity; |
16 | 19 | import org.thingsboard.server.dao.yunteng.mapper.TkInspectionRecordMapper; |
17 | -import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; | |
18 | -import org.thingsboard.server.dao.yunteng.service.TkInspectionDetailsService; | |
19 | -import org.thingsboard.server.dao.yunteng.service.TkInspectionRecordService; | |
20 | +import org.thingsboard.server.dao.yunteng.service.*; | |
20 | 21 | |
21 | 22 | import java.time.LocalDateTime; |
22 | -import java.util.ArrayList; | |
23 | -import java.util.List; | |
24 | -import java.util.Map; | |
23 | +import java.util.*; | |
24 | +import java.util.function.Function; | |
25 | +import java.util.stream.Collectors; | |
25 | 26 | |
26 | 27 | @Service |
27 | 28 | @RequiredArgsConstructor |
... | ... | @@ -29,6 +30,9 @@ import java.util.Map; |
29 | 30 | public class TkInspectionRecordServiceImpl extends AbstractBaseService<TkInspectionRecordMapper, TkInspectionRecordEntity> |
30 | 31 | implements TkInspectionRecordService { |
31 | 32 | private final TkInspectionDetailsService tkInspectionDetailsService; |
33 | + @Lazy | |
34 | + private final TkInspectionPlanService tkInspectionPlanService; | |
35 | + private final TkUserService tkUserService; | |
32 | 36 | |
33 | 37 | @Override |
34 | 38 | public TkPageData<TkInspectionRecordDTO> page(Map<String, Object> queryMap, String tenantId) { |
... | ... | @@ -39,6 +43,20 @@ public class TkInspectionRecordServiceImpl extends AbstractBaseService<TkInspect |
39 | 43 | lambda.eq(TkInspectionRecordEntity::getInspectionPlanId, queryMap.get("inspectionPlanId").toString()); |
40 | 44 | } |
41 | 45 | |
46 | + if (queryMap != null && queryMap.get("inspectionPlanName") != null) { | |
47 | + String inspectionPlanName = queryMap.get("inspectionPlanName").toString(); | |
48 | + TkInspectionPlanDTO condition = new TkInspectionPlanDTO(); | |
49 | + condition.setName(inspectionPlanName); | |
50 | + condition.setTenantId(tenantId); | |
51 | + List<TkInspectionPlanDTO> tkInspectionPlanDTOList = tkInspectionPlanService.selectByCondition(condition); | |
52 | + if (CollectionUtils.isEmpty(tkInspectionPlanDTOList)) { | |
53 | + return new TkPageData<>(); | |
54 | + } | |
55 | + | |
56 | + List<String> inspectionPlanIdList = tkInspectionPlanDTOList.stream().map(TkInspectionPlanDTO::getId).collect(Collectors.toList()); | |
57 | + lambda.in(TkInspectionRecordEntity::getInspectionPlanId, inspectionPlanIdList); | |
58 | + } | |
59 | + | |
42 | 60 | if (queryMap != null && queryMap.get("inspectorId") != null) { |
43 | 61 | lambda.eq(TkInspectionRecordEntity::getInspectorId, queryMap.get("inspectorId").toString()); |
44 | 62 | } |
... | ... | @@ -57,7 +75,34 @@ public class TkInspectionRecordServiceImpl extends AbstractBaseService<TkInspect |
57 | 75 | IPage<TkInspectionRecordEntity> page = baseMapper.selectPage(getPage(queryMap, "create_time", false), |
58 | 76 | wrapper); |
59 | 77 | |
60 | - return getPageData(page, TkInspectionRecordDTO.class); | |
78 | + TkPageData<TkInspectionRecordDTO> pageData = getPageData(page, TkInspectionRecordDTO.class); | |
79 | + if (pageData == null || CollectionUtils.isEmpty(pageData.getItems())) { | |
80 | + return pageData; | |
81 | + } | |
82 | + | |
83 | + List<TkInspectionRecordDTO> tkInspectionRecordDTOList = new ArrayList<>(pageData.getItems()); | |
84 | + List<String> inspectionPlanIdList = tkInspectionRecordDTOList.stream().map(TkInspectionRecordDTO::getInspectionPlanId).collect(Collectors.toList()); | |
85 | + Set<String> inspectorIds = tkInspectionRecordDTOList.stream().map(TkInspectionRecordDTO::getInspectorId).collect(Collectors.toSet()); | |
86 | + TkInspectionPlanDTO condition = new TkInspectionPlanDTO(); | |
87 | + condition.setTenantId(tenantId); | |
88 | + condition.setInspectionPlanIdList(inspectionPlanIdList); | |
89 | + List<TkInspectionPlanDTO> inspectionPlanDTOLst = tkInspectionPlanService.selectByCondition(condition); | |
90 | + List<UserDTO> userDTOList = tkUserService.findUserByUserIdList(new ArrayList<>(inspectorIds)); | |
91 | + Map<String, TkInspectionPlanDTO> tkInspectionPlanDTOMap = CollectionUtils.emptyIfNull(inspectionPlanDTOLst) | |
92 | + .stream() | |
93 | + .collect(Collectors.toMap(TkInspectionPlanDTO::getId, Function.identity(), (a, b) -> a)); | |
94 | + Map<String, UserDTO> userDTOMap = CollectionUtils.emptyIfNull(userDTOList) | |
95 | + .stream() | |
96 | + .collect(Collectors.toMap(UserDTO::getId, Function.identity(), (a, b) -> a)); | |
97 | + tkInspectionRecordDTOList.forEach(tkInspectionRecordDTO -> { | |
98 | + TkInspectionPlanDTO tkInspectionPlanDTO = tkInspectionPlanDTOMap.get(tkInspectionRecordDTO.getInspectionPlanId()); | |
99 | + tkInspectionRecordDTO.setTkInspectionPlanDTO(tkInspectionPlanDTO); | |
100 | + UserDTO userDTO = userDTOMap.get(tkInspectionRecordDTO.getInspectorId()); | |
101 | + tkInspectionRecordDTO.setUserDTO(userDTO); | |
102 | + }); | |
103 | + | |
104 | + pageData.setItems(tkInspectionRecordDTOList); | |
105 | + return pageData; | |
61 | 106 | } |
62 | 107 | |
63 | 108 | @Override |
... | ... | @@ -99,10 +144,18 @@ public class TkInspectionRecordServiceImpl extends AbstractBaseService<TkInspect |
99 | 144 | } |
100 | 145 | |
101 | 146 | TkInspectionRecordEntity entity = baseMapper.selectById(id); |
147 | + if (entity == null) { | |
148 | + return new TkInspectionRecordDTO(); | |
149 | + } | |
150 | + | |
102 | 151 | TkInspectionRecordDTO tkInspectionRecordDTO = new TkInspectionRecordDTO(); |
103 | 152 | entity.copyToDTO(tkInspectionRecordDTO); |
104 | 153 | List<TkInspectionDetailsDTO> tkInspectionDetailsDTOList = tkInspectionDetailsService.listByInspectionRecordId(id); |
105 | 154 | tkInspectionRecordDTO.setTkInspectionDetailsDTOList(tkInspectionDetailsDTOList); |
155 | + TkInspectionPlanDTO tkInspectionPlanDTO = tkInspectionPlanService.get(tkInspectionRecordDTO.getInspectionPlanId()); | |
156 | + tkInspectionRecordDTO.setTkInspectionPlanDTO(tkInspectionPlanDTO); | |
157 | + UserDTO userDTO = tkUserService.findUserInfoById(tkInspectionRecordDTO.getInspectorId()); | |
158 | + tkInspectionRecordDTO.setUserDTO(userDTO); | |
106 | 159 | return tkInspectionRecordDTO; |
107 | 160 | } |
108 | 161 | |
... | ... | @@ -113,6 +166,37 @@ public class TkInspectionRecordServiceImpl extends AbstractBaseService<TkInspect |
113 | 166 | return count > 0; |
114 | 167 | } |
115 | 168 | |
169 | + @Override | |
170 | + public Map<String, List<TkInspectionRecordDTO>> mapByInspectionPlanId(List<String> inspectionPlanIdList) { | |
171 | + if (CollectionUtils.isEmpty(inspectionPlanIdList)) { | |
172 | + return new HashMap<>(0); | |
173 | + } | |
174 | + | |
175 | + QueryWrapper<TkInspectionRecordEntity> wrapper = new QueryWrapper<>(); | |
176 | + LambdaQueryWrapper<TkInspectionRecordEntity> lambda = wrapper.lambda(); | |
177 | + lambda.in(TkInspectionRecordEntity::getInspectionPlanId, inspectionPlanIdList); | |
178 | + lambda.orderByAsc(TkInspectionRecordEntity::getCreateTime); | |
179 | + List<TkInspectionRecordEntity> tkInspectionRecordEntityList = baseMapper.selectList(wrapper); | |
180 | + if (CollectionUtils.isEmpty(tkInspectionRecordEntityList)) { | |
181 | + return new HashMap<>(0); | |
182 | + } | |
183 | + | |
184 | + Map<String, List<TkInspectionRecordDTO>> map = new HashMap<>(inspectionPlanIdList.size()); | |
185 | + tkInspectionRecordEntityList.forEach(entity -> { | |
186 | + TkInspectionRecordDTO dto = new TkInspectionRecordDTO(); | |
187 | + entity.copyToDTO(dto); | |
188 | + List<TkInspectionRecordDTO> dtoList = map.get(dto.getInspectionPlanId()); | |
189 | + if (CollectionUtils.isEmpty(dtoList)) { | |
190 | + dtoList = new ArrayList<>(1); | |
191 | + } | |
192 | + | |
193 | + dtoList.add(dto); | |
194 | + map.put(dto.getInspectionPlanId(), dtoList); | |
195 | + }); | |
196 | + | |
197 | + return map; | |
198 | + } | |
199 | + | |
116 | 200 | private void checkDto(TkInspectionRecordDTO dto) { |
117 | 201 | if (StringUtils.isBlank(dto.getTenantId())) { |
118 | 202 | throw new TkDataValidationException("租户id为空!"); | ... | ... |
... | ... | @@ -4,6 +4,7 @@ import org.thingsboard.server.common.data.yunteng.dto.TkInspectionPlanDTO; |
4 | 4 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; |
5 | 5 | import org.thingsboard.server.dao.yunteng.entities.TkInspectionPlanEntity; |
6 | 6 | |
7 | +import java.util.List; | |
7 | 8 | import java.util.Map; |
8 | 9 | |
9 | 10 | public interface TkInspectionPlanService extends BaseService<TkInspectionPlanEntity> { |
... | ... | @@ -15,4 +16,6 @@ public interface TkInspectionPlanService extends BaseService<TkInspectionPlanEnt |
15 | 16 | TkInspectionPlanDTO get(String id); |
16 | 17 | |
17 | 18 | boolean delete(String id); |
19 | + | |
20 | + List<TkInspectionPlanDTO> selectByCondition(TkInspectionPlanDTO tkInspectionPlanDTO); | |
18 | 21 | } | ... | ... |
... | ... | @@ -4,6 +4,7 @@ import org.thingsboard.server.common.data.yunteng.dto.TkInspectionRecordDTO; |
4 | 4 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; |
5 | 5 | import org.thingsboard.server.dao.yunteng.entities.TkInspectionRecordEntity; |
6 | 6 | |
7 | +import java.util.List; | |
7 | 8 | import java.util.Map; |
8 | 9 | |
9 | 10 | public interface TkInspectionRecordService extends BaseService<TkInspectionRecordEntity> { |
... | ... | @@ -15,4 +16,6 @@ public interface TkInspectionRecordService extends BaseService<TkInspectionRecor |
15 | 16 | TkInspectionRecordDTO get(String id); |
16 | 17 | |
17 | 18 | boolean delete(String id); |
19 | + | |
20 | + Map<String, List<TkInspectionRecordDTO>> mapByInspectionPlanId(List<String> inspectionPlanIdList); | |
18 | 21 | } | ... | ... |