fix:太阳能网控,校准,走缓存逻辑。

This commit is contained in:
tianyongbao
2026-07-01 23:16:47 +08:00
parent 4207a6582f
commit ac9ea07328

View File

@@ -1960,6 +1960,58 @@ public class IotController extends BaseController {
return R.fail("设备已到期"); return R.fail("设备已到期");
} }
// 太阳能网控设备:缓存校准指令,等设备上线后自动补发
boolean isSolarDevice = Integer.valueOf(3).equals(device.getDeviceType());
if (isSolarDevice) {
if (device.getIotId() == null || device.getIotId().isBlank()) {
return R.fail("设备 iotId 为空,无法缓存校准指令");
}
if (device.getSerialNum() == null || device.getSerialNum().isBlank()) {
return R.fail("设备编号为空,无法缓存校准指令");
}
Map<String, Object> calibrateProperties = new LinkedHashMap<>();
calibrateProperties.put("correct", 1);
if (!cachePendingSolarProperties(device, calibrateProperties)) {
return R.fail("校准指令缓存失败,请稍后重试");
}
// 更新设备警告码:清除未校准标记
int warnCode = device.getWarnCode() != null ? device.getWarnCode() : 0;
if ((warnCode & DefineDeviceWarnCode.OxyDetectorNoCorrect) != 0) {
warnCode &= ~DefineDeviceWarnCode.OxyDetectorNoCorrect;
}
deviceMapper.update(null,
new com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper<Device>()
.eq(Device::getId, request.getId())
.set(Device::getWarnCode, warnCode)
);
// 创建校准记录
if (deviceCorrectRecordMapper != null) {
DeviceCorrectRecord correctRecord = new DeviceCorrectRecord();
correctRecord.setDeviceId(device.getId());
correctRecord.setUserId(userId);
correctRecord.setSerialNum(device.getSerialNum());
correctRecord.setDeviceType(device.getDeviceType());
correctRecord.setValueDissolvedOxygen(device.getValueDissolvedOxygen());
correctRecord.setValueTemperature(device.getValueTemperature());
correctRecord.setValueSaturability(device.getValueSaturability());
deviceCorrectRecordMapper.insert(correctRecord);
}
MessageOpRecordUtil.addMessageOpRecordUser(
device.getUserId(),
userId,
"设备操作",
String.format("%s(%s),设备校准。", device.getDeviceName(), device.getSerialNum())
);
log.info("太阳能网控校准指令已缓存: userId={}, deviceId={}, deviceName={}, serialNum={}",
userId, device.getId(), device.getDeviceName(), device.getSerialNum());
return R.ok("设置成功");
}
// 查询设备状态 // 查询设备状态
if (iotDeviceService == null) { if (iotDeviceService == null) {
return R.fail("飞燕平台配置未启用"); return R.fail("飞燕平台配置未启用");