|
@@ -668,62 +668,62 @@ public class TrialDetectionController extends BladeController {
|
|
|
@GetMapping("/self/getStandardInfoByStandardId")
|
|
|
@ApiOperationSupport(order = 30)
|
|
|
@ApiOperation(value = "根据 standardId 查询 样品品种,代号和强度等级", notes = "standardId")
|
|
|
- public R<Map<String, List<StandardInfo>>> getStandardInfoByStandardId( @RequestParam Long standardId) {
|
|
|
+ public R<List<StandardInfoDTO>> getStandardInfoByStandardId( @RequestParam Long standardId) {
|
|
|
List<StandardInfo> list = uStandardInfoService.list(Wrappers.<StandardInfo>lambdaQuery().eq(StandardInfo::getStandardId, standardId).eq(StandardInfo::getType, 1));
|
|
|
if (list == null || list.isEmpty()) {
|
|
|
- return R.data(new HashMap<>());
|
|
|
+ return R.data(new ArrayList<>());
|
|
|
}
|
|
|
Map<Long, List<StandardInfo>> map = list.stream().collect(Collectors.groupingBy(StandardInfo::getParentId));
|
|
|
- Map<String, List<StandardInfo>> result = new HashMap<>();
|
|
|
List<StandardInfo> standardInfos = map.get(0L);
|
|
|
+ List<StandardInfoDTO> result = new ArrayList<>();
|
|
|
if (standardInfos != null) {
|
|
|
- standardInfos.forEach(standardInfo -> result.put(standardInfo.getName(), map.get(standardInfo.getId()) == null ? new ArrayList<>() : map.get(standardInfo.getId())));
|
|
|
+ standardInfos.forEach(standardInfo -> {
|
|
|
+ StandardInfoDTO dto = BeanUtil.copy(standardInfo, StandardInfoDTO.class);
|
|
|
+ if (dto != null) {
|
|
|
+ dto.setInfo(map.get(standardInfo.getId()));
|
|
|
+ result.add(dto);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
return R.data(result);
|
|
|
}
|
|
|
|
|
|
-// /**
|
|
|
-// * 根据 设备id 查询 设备信息以及设备使用信息
|
|
|
-// */
|
|
|
-// @GetMapping("/self/getDeviceInfoByIds")
|
|
|
-// @ApiOperationSupport(order = 30)
|
|
|
-// @ApiOperation(value = "根据 设备id 查询 设备信息以及设备使用信息", notes = "standardId")
|
|
|
-// public R<List<TrailDeviceUseInfoDTO>> getDeviceInfoByIds( @RequestParam String deviceInfoIds) {
|
|
|
-// if (deviceInfoIds.isEmpty()) {
|
|
|
-// return R.data(new ArrayList<>());
|
|
|
-// }
|
|
|
-// // 校验设备id
|
|
|
-// try {
|
|
|
-// String[] split = deviceInfoIds.split(",");
|
|
|
-// for (String s : split) {
|
|
|
-// long id = Long.parseLong(s);
|
|
|
-// if (id <= 0) {
|
|
|
-// return R.fail("设备id格式错误");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// } catch (Exception e) {
|
|
|
-// return R.fail("设备id格式错误");
|
|
|
-// }
|
|
|
-// List<TrialDeviceInfo> deviceInfoList = jdbcTemplate.query("select * from u_device_info where id in (" + deviceInfoIds + ")", new BeanPropertyRowMapper<>(TrialDeviceInfo.class));
|
|
|
-// deviceInfoList.forEach(deviceInfo -> {
|
|
|
-//
|
|
|
-// });
|
|
|
-//
|
|
|
-// trialDeviceUseList.forEach(trailDeviceUseInfoDTO -> {
|
|
|
-// TrialDeviceInfo deviceInfo = trialDeviceInfoMap.get(trailDeviceUseInfoDTO.getDeviceInfoId());
|
|
|
-// if (deviceInfo != null) {
|
|
|
-// trailDeviceUseInfoDTO.setMeasuringRange(deviceInfo.getMeasuringRange());
|
|
|
-// trailDeviceUseInfoDTO.setAccuracy(deviceInfo.getAccuracy());
|
|
|
-// // 计算使用时长
|
|
|
-// trailDeviceUseInfoDTO.setUseDuration(DateUtils.dateDiff(trailDeviceUseInfoDTO.getStartDate(), trailDeviceUseInfoDTO.getEndDate()));
|
|
|
-// }
|
|
|
-// });
|
|
|
-//
|
|
|
-//// List<TrailDeviceUseInfoDTO> trialDeviceUseList = jdbcTemplate.query("select * from u_trial_device_use where self_inspection_record_id = " + id, new BeanPropertyRowMapper<>(TrailDeviceUseInfoDTO.class));
|
|
|
-//// if (!trialDeviceUseList.isEmpty()) {
|
|
|
-//// Set<Long> ids = trialDeviceUseList.stream().map(TrailDeviceUseInfoDTO::getDeviceInfoId).collect(Collectors.toSet());
|
|
|
-////
|
|
|
-//// }
|
|
|
-// return R.data(trialDeviceUseList);
|
|
|
-// }
|
|
|
+ /**
|
|
|
+ * 根据 设备id 查询 设备信息以及设备使用信息
|
|
|
+ */
|
|
|
+ @GetMapping("/self/getDeviceInfoByIds")
|
|
|
+ @ApiOperationSupport(order = 30)
|
|
|
+ @ApiOperation(value = "根据 设备ids 查询 设备信息以及设备使用信息", notes = "deviceInfoIds")
|
|
|
+ public R<List<TrailDeviceUseInfoDTO>> getDeviceInfoByIds( @RequestParam String deviceInfoIds) {
|
|
|
+ if (deviceInfoIds.isEmpty()) {
|
|
|
+ return R.data(new ArrayList<>());
|
|
|
+ }
|
|
|
+ // 校验设备id
|
|
|
+ try {
|
|
|
+ String[] split = deviceInfoIds.split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ long id = Long.parseLong(s);
|
|
|
+ if (id <= 0) {
|
|
|
+ return R.fail("设备id格式错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.fail("设备id格式错误");
|
|
|
+ }
|
|
|
+ List<TrialDeviceInfo> deviceInfoList = jdbcTemplate.query("select * from u_device_info where id in (" + deviceInfoIds + ")", new BeanPropertyRowMapper<>(TrialDeviceInfo.class));
|
|
|
+ List<TrailDeviceUseInfoDTO> trailDeviceUseInfoDTOS = new ArrayList<>();
|
|
|
+ deviceInfoList.forEach(deviceInfo -> {
|
|
|
+ // 查询该设备最近一次的使用信息
|
|
|
+ List<TrailDeviceUseInfoDTO> trialDeviceUseList = jdbcTemplate.query("select * from u_trial_device_use where device_info_id = " + deviceInfo.getId() + "limit 1", new BeanPropertyRowMapper<>(TrailDeviceUseInfoDTO.class));
|
|
|
+ if (!trialDeviceUseList.isEmpty()) {
|
|
|
+ TrailDeviceUseInfoDTO dto = trialDeviceUseList.get(0);
|
|
|
+ dto.setMeasuringRange(deviceInfo.getMeasuringRange());
|
|
|
+ dto.setAccuracy(deviceInfo.getAccuracy());
|
|
|
+ // 计算使用时长
|
|
|
+ dto.setUseDuration(DateUtils.dateDiff(dto.getStartDate(), dto.getEndDate()));
|
|
|
+ trailDeviceUseInfoDTOS.add(dto);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return R.data(trailDeviceUseInfoDTOS);
|
|
|
+ }
|
|
|
}
|