|
@@ -5,13 +5,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.xy.dto.DeviceErrorsRecordDto;
|
|
|
import com.xy.dto.DeviceInfoDto;
|
|
|
-import com.xy.dto.DeviceSysinfoDto;
|
|
|
import com.xy.entity.DeviceErrorsRecord;
|
|
|
+import com.xy.entity.DeviceInfo;
|
|
|
+import com.xy.entity.SysCodeConfigureRedis;
|
|
|
import com.xy.mapper.DeviceErrorsRecordMapper;
|
|
|
-import com.xy.utils.Emptys;
|
|
|
-import com.xy.utils.MybatisPlusQuery;
|
|
|
-import com.xy.utils.PageBean;
|
|
|
-import com.xy.utils.R;
|
|
|
+import com.xy.utils.*;
|
|
|
+import com.xy.utils.enums.SysCodeConfigureEnum;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -51,13 +50,19 @@ public class DeviceErrorsRecordServiceImpl extends ServiceImpl<DeviceErrorsRecor
|
|
|
if (deviceInfo == null) {
|
|
|
return R.fail("设备不存在");
|
|
|
}
|
|
|
- DeviceSysinfoDto.Vo deviceSysinfo = deviceInfo.getDeviceSysinfo();
|
|
|
+ //添加故障记录
|
|
|
save.setMercId(deviceInfo.getMercId());
|
|
|
- save.setAppUpmVersion(deviceSysinfo.getAppUpmVersion());
|
|
|
- save.setAppDownmVersion(deviceSysinfo.getAppDownmVersion());
|
|
|
DeviceErrorsRecord deviceErrorsRecord = copy(DeviceErrorsRecord.class, save)
|
|
|
.setCreateTime(LocalDateTime.now());
|
|
|
save(deviceErrorsRecord);
|
|
|
+ SysCodeConfigureRedis sysCodeConfigureRedis = SysCodeConfigureUtils.get(SysCodeConfigureEnum.D01.getCode(), save.getCode());
|
|
|
+ //修改设备当前故障等级
|
|
|
+ if (Emptys.check(sysCodeConfigureRedis.getExpand())) {
|
|
|
+ DeviceInfo updateDeviceInfo = new DeviceInfo()
|
|
|
+ .setDeviceId(deviceInfo.getDeviceId())
|
|
|
+ .setFaultLevel(Integer.valueOf(sysCodeConfigureRedis.getExpand()));
|
|
|
+ deviceInfoService.updateById(updateDeviceInfo);
|
|
|
+ }
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
@@ -73,11 +78,16 @@ public class DeviceErrorsRecordServiceImpl extends ServiceImpl<DeviceErrorsRecor
|
|
|
IPage<DeviceErrorsRecord> iPage = page(toIPage(pageBean), lambdaQueryWrapper);
|
|
|
PageBean<DeviceErrorsRecordDto.Vo> voPageBean = toPageBean(DeviceErrorsRecordDto.Vo.class, iPage);
|
|
|
//反显设备名称
|
|
|
- if(Emptys.check(voPageBean.getRecords())){
|
|
|
+ if (Emptys.check(voPageBean.getRecords())) {
|
|
|
List<Long> deviceIdList = voPageBean.getRecords().stream().map(DeviceErrorsRecordDto.Vo::getDeviceId).collect(Collectors.toList());
|
|
|
Map<Long, String> deviceMap = deviceInfoService.getDeviceNameList(new DeviceInfoDto.DeviceIdDto().setDeviceId(deviceIdList)).getData();
|
|
|
- voPageBean.getRecords().forEach(i->{
|
|
|
+ Map<String, SysCodeConfigureRedis> stringSysCodeConfigureRedisMap = SysCodeConfigureUtils.get(SysCodeConfigureEnum.D01.getCode());
|
|
|
+ voPageBean.getRecords().forEach(i -> {
|
|
|
i.setDeviceName(deviceMap.get(i.getDeviceId()));
|
|
|
+ SysCodeConfigureRedis sysCodeConfigureRedis = stringSysCodeConfigureRedisMap.get(i.getCode());
|
|
|
+ if (sysCodeConfigureRedis != null) {
|
|
|
+ i.setSysCodeConfigureRedis(sysCodeConfigureRedis);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
return R.ok(voPageBean);
|
|
@@ -91,7 +101,15 @@ public class DeviceErrorsRecordServiceImpl extends ServiceImpl<DeviceErrorsRecor
|
|
|
.in(DeviceErrorsRecord::getDeviceId, selectList.getDeviceIds())
|
|
|
.build();
|
|
|
List<DeviceErrorsRecord> list = list(lambdaQueryWrapper);
|
|
|
- return R.ok(copy(DeviceErrorsRecordDto.Vo.class, list));
|
|
|
+ Map<String, SysCodeConfigureRedis> stringSysCodeConfigureRedisMap = SysCodeConfigureUtils.get(SysCodeConfigureEnum.D01.getCode());
|
|
|
+ List<DeviceErrorsRecordDto.Vo> vos = copy(DeviceErrorsRecordDto.Vo.class, list);
|
|
|
+ vos.forEach(vo -> {
|
|
|
+ SysCodeConfigureRedis sysCodeConfigureRedis = stringSysCodeConfigureRedisMap.get(vo.getCode());
|
|
|
+ if (sysCodeConfigureRedis != null) {
|
|
|
+ vo.setSysCodeConfigureRedis(sysCodeConfigureRedis);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return R.ok(vos);
|
|
|
}
|
|
|
|
|
|
}
|