|
|
@@ -75,7 +75,7 @@ public class IotDvrDiskServiceImpl extends ServiceImpl<IotDvrDiskMapper, IotDvrD
|
|
|
}
|
|
|
final Optional<IotDvrDisk> first = list.stream().filter(disk -> ObjectUtil.equal(disk.getDiskIndex(), String.valueOf(index))).findFirst();
|
|
|
if (!first.isPresent()) {
|
|
|
- LogUtils.STATUS_INFO_DISKS.error("硬盘检测上报消息处理磁盘状态时未找到对应磁盘,主机code:{},磁盘号:{}",equipmentCode,index);
|
|
|
+ LogUtils.STATUS_INFO_DISKS.info("硬盘检测上报消息处理磁盘状态时未找到对应磁盘,主机code:{},磁盘号:{}", equipmentCode, index);
|
|
|
continue;
|
|
|
}
|
|
|
final IotDvrDisk iotDvrDisk = first.get();
|
|
|
@@ -112,21 +112,21 @@ public class IotDvrDiskServiceImpl extends ServiceImpl<IotDvrDiskMapper, IotDvrD
|
|
|
List<NorthError> errors = (List<NorthError>) map.get("errors");
|
|
|
|
|
|
List<IotDvrDisk> dvrdisks = (List<IotDvrDisk>) map.get("dvrdisks");
|
|
|
- final List<Long> orgIdLIst = dvrdisks.stream().map(IotDvrDisk::getOrgId).distinct().collect(Collectors.toList());
|
|
|
this.northStatisticsSyncService.saveOrUpdateBaseCountByDataType(DataType.dvrdiskCount.getIndex(), dvrdisks.size(), false);
|
|
|
|
|
|
northErrorService.saveErrorData(errors);
|
|
|
if (ObjectUtil.isNotEmpty(dvrdisks)) {
|
|
|
- LambdaQueryWrapper<IotDvrDisk> wrapper = new LambdaQueryWrapper<IotDvrDisk>();
|
|
|
- wrapper.in(IotDvrDisk::getOrgId, orgIdLIst);
|
|
|
- this.remove(wrapper);
|
|
|
this.saveOrUpdateBatch(dvrdisks);
|
|
|
+ List<IotDvrDiskLog> list = new ArrayList<>();
|
|
|
for (IotDvrDisk dvrdisk : dvrdisks) {
|
|
|
final IotDvrDiskLog diskLog = new IotDvrDiskLog();
|
|
|
BeanUtils.copyProperties(dvrdisk, diskLog, "id");
|
|
|
diskLog.setIotDvrDiskId(dvrdisk.getId());
|
|
|
- diskLogService.save(diskLog);
|
|
|
+ diskLog.setCreateTime(LocalDateTime.now());
|
|
|
+ diskLog.setUpdateTime(LocalDateTime.now());
|
|
|
+ list.add(diskLog);
|
|
|
}
|
|
|
+ diskLogService.saveBatch(list);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
@@ -142,10 +142,12 @@ public class IotDvrDiskServiceImpl extends ServiceImpl<IotDvrDiskMapper, IotDvrD
|
|
|
List<NorthError> errors = new ArrayList<>();
|
|
|
|
|
|
List<IotDvrDisk> dvrdisks = new ArrayList<>();
|
|
|
-
|
|
|
+ final List<String> list = deviceListAll.stream().map(IotDevice::getEquipmentCode).collect(Collectors.toList());
|
|
|
+ final List<IotDvrDisk> allDiskList = baseMapper.selectByEquipmentCode(list);
|
|
|
+ final Map<String, List<IotDvrDisk>> listMap = allDiskList.stream().collect(Collectors.groupingBy(IotDvrDisk::getHostCode));
|
|
|
for (DvrDiskPageDto pageDto : dvrdiskPageLists) {
|
|
|
NorthError error = null;
|
|
|
- SysOrgVO org = null;
|
|
|
+ SysOrgVO org;
|
|
|
//验证DvrdiskPageDto对象中是否有参数为null
|
|
|
error = CheckDataUtil.checkObjFieldIsNull(pageDto, msgId, "/api/data/dvrDiskList", null);
|
|
|
if (error != null) {
|
|
|
@@ -155,31 +157,29 @@ public class IotDvrDiskServiceImpl extends ServiceImpl<IotDvrDiskMapper, IotDvrD
|
|
|
//验证机构是否存在
|
|
|
final Optional<SysOrgVO> optional = orgList.stream().filter(r -> r.getCode().equals(pageDto.getOrganizationGuid())).findFirst();
|
|
|
if (!optional.isPresent()) {
|
|
|
- error = new NorthError(msgId, "/api/data/dvrDiskList"
|
|
|
- , pageDto, "OrganizationGuid:" + pageDto.getOrganizationGuid() + "不正确");
|
|
|
+ error = new NorthError(msgId, "/api/data/dvrDiskList", pageDto, "OrganizationGuid:" + pageDto.getOrganizationGuid() + "不正确");
|
|
|
errors.add(error);
|
|
|
continue;
|
|
|
} else {
|
|
|
org = optional.get();
|
|
|
}
|
|
|
//验证监控主机是否存在
|
|
|
- SysOrgVO finalOrg = org;
|
|
|
- List<IotDevice> deviceList = deviceListAll.stream().filter(r -> r.getEquipmentCode().equals(pageDto.getEquipmentCode())
|
|
|
- && r.getOrgId().equals(finalOrg.getId())).collect(Collectors.toList());
|
|
|
+ final Optional<IotDevice> hostDeviceOptional = deviceListAll.stream()
|
|
|
+ .filter(r -> r.getEquipmentCode().equals(pageDto.getEquipmentCode()))
|
|
|
+ .filter(r -> r.getOrgId().equals(org.getId()))
|
|
|
+ .findFirst();
|
|
|
|
|
|
- if (deviceList.size() == 0) {
|
|
|
- error = new NorthError(msgId, "/api/data/dvrDiskList"
|
|
|
- , pageDto, "EquipmentCode:" + pageDto.getEquipmentCode() + "不正确");
|
|
|
+ if (!hostDeviceOptional.isPresent()) {
|
|
|
+ error = new NorthError(msgId, "/api/data/dvrDiskList", pageDto, "EquipmentCode:" + pageDto.getEquipmentCode() + "不正确");
|
|
|
errors.add(error);
|
|
|
continue;
|
|
|
}
|
|
|
+ final List<IotDvrDisk> diskList = listMap.get(hostDeviceOptional.get().getEquipmentCode());
|
|
|
List<DvrdiskDto> diskSpaces = pageDto.getDiskSpace();
|
|
|
-
|
|
|
- if (ObjectUtil.isEmpty(diskSpaces)) {
|
|
|
+ if (ObjectUtil.hasEmpty(diskSpaces, diskList)) {
|
|
|
return map;
|
|
|
}
|
|
|
for (DvrdiskDto dto : diskSpaces) {
|
|
|
- //验证DvrdiskDto是否有字段为null
|
|
|
List<String> fields = new ArrayList<>();
|
|
|
fields.add("name");
|
|
|
error = CheckDataUtil.checkObjFieldIsNull(dto, msgId, "/api/data/dvrDiskList", fields);
|
|
|
@@ -187,25 +187,28 @@ public class IotDvrDiskServiceImpl extends ServiceImpl<IotDvrDiskMapper, IotDvrD
|
|
|
errors.add(error);
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
- IotDvrDisk dvrdisk = IotDvrDisk.builder()
|
|
|
- .available(NumberUtil.parseInt(dto.getAvailable().substring(0, dto.getAvailable().length() - 2)))
|
|
|
- .diskIndex(dto.getDiskSerialNum())
|
|
|
- .hostCode(pageDto.getEquipmentCode())
|
|
|
- .diskName(dto.getName())
|
|
|
- .id(IDHelper.id())
|
|
|
- .total(NumberUtil.parseInt(dto.getTotal().substring(0, dto.getTotal().length() - 2)))
|
|
|
- .orgId(org.getId())
|
|
|
- .orgName(org.getShortName())
|
|
|
- .orgPath(org.getPath())
|
|
|
- .deleted(0)
|
|
|
- .source(1)
|
|
|
- .createTime(LocalDateTime.now())
|
|
|
- .updateTime(LocalDateTime.now())
|
|
|
- .stateUpdateTime(LocalDateTime.now())
|
|
|
- .build();
|
|
|
-
|
|
|
- dvrdisks.add(dvrdisk);
|
|
|
+ IotDvrDisk dvrDisk;
|
|
|
+ final Optional<IotDvrDisk> diskOptional = diskList.stream().filter(r -> ObjectUtil.equal(r.getDiskIndex(), dto.getDiskSerialNum())).findFirst();
|
|
|
+ if (!diskOptional.isPresent()) {
|
|
|
+ dvrDisk = new IotDvrDisk();
|
|
|
+ dvrDisk.setId(IDHelper.id());
|
|
|
+ dvrDisk.setOrgId(org.getId());
|
|
|
+ dvrDisk.setOrgName(org.getShortName());
|
|
|
+ dvrDisk.setOrgPath(org.getPath());
|
|
|
+ dvrDisk.setHostCode(pageDto.getEquipmentCode());
|
|
|
+ dvrDisk.setDiskIndex(dto.getDiskSerialNum());
|
|
|
+ dvrDisk.setDeleted(0);
|
|
|
+ dvrDisk.setSource(1);
|
|
|
+ dvrDisk.setCreateTime(LocalDateTime.now());
|
|
|
+ } else {
|
|
|
+ dvrDisk = diskOptional.get();
|
|
|
+ }
|
|
|
+ dvrDisk.setAvailable(NumberUtil.parseInt(dto.getAvailable().substring(0, dto.getAvailable().length() - 2)));
|
|
|
+ dvrDisk.setDiskName(dto.getName());
|
|
|
+ dvrDisk.setTotal(NumberUtil.parseInt(dto.getTotal().substring(0, dto.getTotal().length() - 2)));
|
|
|
+ dvrDisk.setStateUpdateTime(LocalDateTime.now());
|
|
|
+ dvrDisk.setUpdateTime(LocalDateTime.now());
|
|
|
+ dvrdisks.add(dvrDisk);
|
|
|
}
|
|
|
}
|
|
|
map.put("errors", errors);
|