|
@@ -45,6 +45,7 @@ import javax.annotation.Resource;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.FileNotFoundException;
|
|
import java.io.FileNotFoundException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -573,13 +574,17 @@ public class TrialDetectionController extends BladeController {
|
|
if (record != null) {
|
|
if (record != null) {
|
|
String baseInfo = record.getBaseInfo();
|
|
String baseInfo = record.getBaseInfo();
|
|
if (baseInfo != null) {
|
|
if (baseInfo != null) {
|
|
- try {
|
|
|
|
- TrialSeleInspectionRecordInfoDTO info = JSON.parseObject(baseInfo, TrialSeleInspectionRecordInfoDTO.class);
|
|
|
|
- if (info != null) {
|
|
|
|
- BeanUtil.copyProperties(info, vo);
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ TrialSeleInspectionRecordInfoDTO info = JSON.parseObject(baseInfo, TrialSeleInspectionRecordInfoDTO.class);
|
|
|
|
+ if (info != null) {
|
|
|
|
+ vo.setEntrustId(info.getEntrustId());
|
|
|
|
+ vo.setEntrustNo(info.getEntrustNo());
|
|
|
|
+ vo.setProjectName(info.getProjectName());
|
|
|
|
+ vo.setConstructionUnit(info.getConstructionUnit());
|
|
|
|
+ vo.setSupervisionUnit(info.getSupervisionUnit());
|
|
|
|
+ vo.setLabName(info.getLabName());
|
|
|
|
+ vo.setContractName(info.getContractName());
|
|
|
|
+ vo.setProjectPosition(info.getProjectPosition());
|
|
|
|
+ vo.setTrialSampleInfo(info.getTrialSampleInfo());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 取样
|
|
// 取样
|
|
@@ -631,7 +636,7 @@ public class TrialDetectionController extends BladeController {
|
|
List<TrailDeviceUseInfoDTO> trialDeviceUseList = jdbcTemplate.query("select * from u_trial_device_use where self_inspection_record_id = " + id, new BeanPropertyRowMapper<>(TrailDeviceUseInfoDTO.class));
|
|
List<TrailDeviceUseInfoDTO> trialDeviceUseList = jdbcTemplate.query("select * from u_trial_device_use where self_inspection_record_id = " + id, new BeanPropertyRowMapper<>(TrailDeviceUseInfoDTO.class));
|
|
if (!trialDeviceUseList.isEmpty()) {
|
|
if (!trialDeviceUseList.isEmpty()) {
|
|
Set<Long> ids = trialDeviceUseList.stream().map(TrailDeviceUseInfoDTO::getDeviceInfoId).collect(Collectors.toSet());
|
|
Set<Long> ids = trialDeviceUseList.stream().map(TrailDeviceUseInfoDTO::getDeviceInfoId).collect(Collectors.toSet());
|
|
- List<TrialDeviceInfo> deviceInfoList = jdbcTemplate.query("select * from u_device_info where id in (" + org.apache.commons.lang.StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(TrialDeviceInfo.class));
|
|
|
|
|
|
+ List<TrialDeviceInfo> deviceInfoList = jdbcTemplate.query("select * from u_trial_device_info where id in (" + org.apache.commons.lang.StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(TrialDeviceInfo.class));
|
|
Map<Long, TrialDeviceInfo> trialDeviceInfoMap = deviceInfoList.stream().collect(Collectors.toMap(TrialDeviceInfo::getId, trailDeviceInfo -> trailDeviceInfo));
|
|
Map<Long, TrialDeviceInfo> trialDeviceInfoMap = deviceInfoList.stream().collect(Collectors.toMap(TrialDeviceInfo::getId, trailDeviceInfo -> trailDeviceInfo));
|
|
trialDeviceUseList.forEach(trailDeviceUseInfoDTO -> {
|
|
trialDeviceUseList.forEach(trailDeviceUseInfoDTO -> {
|
|
TrialDeviceInfo deviceInfo = trialDeviceInfoMap.get(trailDeviceUseInfoDTO.getDeviceInfoId());
|
|
TrialDeviceInfo deviceInfo = trialDeviceInfoMap.get(trailDeviceUseInfoDTO.getDeviceInfoId());
|
|
@@ -639,11 +644,18 @@ public class TrialDetectionController extends BladeController {
|
|
trailDeviceUseInfoDTO.setMeasuringRange(deviceInfo.getMeasuringRange());
|
|
trailDeviceUseInfoDTO.setMeasuringRange(deviceInfo.getMeasuringRange());
|
|
trailDeviceUseInfoDTO.setAccuracy(deviceInfo.getAccuracy());
|
|
trailDeviceUseInfoDTO.setAccuracy(deviceInfo.getAccuracy());
|
|
// 计算使用时长
|
|
// 计算使用时长
|
|
- trailDeviceUseInfoDTO.setUseDuration(DateUtils.dateDiff(trailDeviceUseInfoDTO.getStartDate(), trailDeviceUseInfoDTO.getEndDate()));
|
|
|
|
- // 从开始时间中获取日期
|
|
|
|
- trailDeviceUseInfoDTO.setUseDate(DateUtils.getDateStr(trailDeviceUseInfoDTO.getStartDate()));
|
|
|
|
- trailDeviceUseInfoDTO.setUseStartTime(DateUtils.getTimeStr(trailDeviceUseInfoDTO.getStartDate()).substring(11));
|
|
|
|
- trailDeviceUseInfoDTO.setUseEndTime(DateUtils.getTimeStr(trailDeviceUseInfoDTO.getStartDate()).substring(11));
|
|
|
|
|
|
+ if (trailDeviceUseInfoDTO.getStartDate() != null && trailDeviceUseInfoDTO.getEndDate() != null) {
|
|
|
|
+ trailDeviceUseInfoDTO.setUseDuration(DateUtils.dateDiff(trailDeviceUseInfoDTO.getStartDate(), trailDeviceUseInfoDTO.getEndDate()));
|
|
|
|
+ }
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
|
|
|
+ if (trailDeviceUseInfoDTO.getStartDate() != null) {
|
|
|
|
+ // 从开始时间中获取日期
|
|
|
|
+ trailDeviceUseInfoDTO.setUseDate(DateUtils.getDateStr(trailDeviceUseInfoDTO.getStartDate()));
|
|
|
|
+ trailDeviceUseInfoDTO.setUseEndTime(sdf.format(trailDeviceUseInfoDTO.getStartDate()));
|
|
|
|
+ }
|
|
|
|
+ if (trailDeviceUseInfoDTO.getEndDate() != null) {
|
|
|
|
+ trailDeviceUseInfoDTO.setUseStartTime(sdf.format(trailDeviceUseInfoDTO.getEndDate()));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -716,62 +728,78 @@ public class TrialDetectionController extends BladeController {
|
|
@GetMapping("/self/getStandardInfoByStandardId")
|
|
@GetMapping("/self/getStandardInfoByStandardId")
|
|
@ApiOperationSupport(order = 30)
|
|
@ApiOperationSupport(order = 30)
|
|
@ApiOperation(value = "根据 standardId 查询 样品品种,代号和强度等级", notes = "standardId")
|
|
@ApiOperation(value = "根据 standardId 查询 样品品种,代号和强度等级", notes = "standardId")
|
|
- public R<Map<String, List<StandardInfo>>> getStandardInfoByStandardId( @RequestParam Long standardId) {
|
|
|
|
- List<StandardInfo> list = uStandardInfoService.list(Wrappers.<StandardInfo>lambdaQuery().eq(StandardInfo::getStandardId, standardId).eq(StandardInfo::getType, 1));
|
|
|
|
|
|
+ public R<List<StandardInfoDTO>> getStandardInfoByStandardId( @RequestParam Long standardId) {
|
|
|
|
+ List<StandardInfo> list = uStandardInfoService.list(Wrappers.<StandardInfo>lambdaQuery().eq(StandardInfo::getStandardId, standardId).eq(StandardInfo::getType, 1).eq(StandardInfo::getIsDeleted, 0));
|
|
if (list == null || list.isEmpty()) {
|
|
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<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<StandardInfo> standardInfos = map.get(0L);
|
|
|
|
+ List<StandardInfoDTO> result = new ArrayList<>();
|
|
if (standardInfos != null) {
|
|
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);
|
|
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_trial_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));
|
|
|
|
+ TrailDeviceUseInfoDTO dto = new TrailDeviceUseInfoDTO();
|
|
|
|
+ if (!trialDeviceUseList.isEmpty()) {
|
|
|
|
+ dto = trialDeviceUseList.get(0);
|
|
|
|
+ // 计算使用时长
|
|
|
|
+ if (dto.getStartDate() != null && dto.getEndDate() != null) {
|
|
|
|
+ dto.setUseDuration(DateUtils.dateDiff(dto.getStartDate(), dto.getEndDate()));
|
|
|
|
+ }
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
|
|
|
+ if (dto.getStartDate() != null) {
|
|
|
|
+ dto.setUseEndTime(sdf.format(dto.getStartDate()));
|
|
|
|
+ }
|
|
|
|
+ if (dto.getEndDate() != null) {
|
|
|
|
+ dto.setUseStartTime(sdf.format(dto.getEndDate()));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ dto.setDeviceName(deviceInfo.getDeviceName());
|
|
|
|
+ dto.setDeviceNumber(deviceInfo.getDeviceNumber());
|
|
|
|
+ dto.setDeviceModel(deviceInfo.getDeviceModel());
|
|
|
|
+ dto.setRemarks(deviceInfo.getRemarks());
|
|
|
|
+ dto.setDeviceInfoId(deviceInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ dto.setMeasuringRange(deviceInfo.getMeasuringRange());
|
|
|
|
+ dto.setAccuracy(deviceInfo.getAccuracy());
|
|
|
|
+ trailDeviceUseInfoDTOS.add(dto);
|
|
|
|
+ });
|
|
|
|
+ return R.data(trailDeviceUseInfoDTOS);
|
|
|
|
+ }
|
|
}
|
|
}
|