|
@@ -687,48 +687,42 @@ public class TrialDetectionController extends BladeController {
|
|
|
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);
|
|
|
+ }
|
|
|
}
|