Browse Source

fix:null保存到数据库

master
白凤吉 2 days ago
parent
commit
17e43e0676
  1. 16
      src/main/java/com/iflytop/handacid/common/service/ReceiveRecordService.java

16
src/main/java/com/iflytop/handacid/common/service/ReceiveRecordService.java

@ -1,6 +1,7 @@
package com.iflytop.handacid.common.service; package com.iflytop.handacid.common.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iflytop.handacid.app.core.state.ChannelState; import com.iflytop.handacid.app.core.state.ChannelState;
import com.iflytop.handacid.app.core.state.DeviceState; import com.iflytop.handacid.app.core.state.DeviceState;
@ -33,13 +34,14 @@ public class ReceiveRecordService extends ServiceImpl<ReceiveRecordMapper, Recei
receiveRecord.setSolutionName(solution.getName()); receiveRecord.setSolutionName(solution.getName());
this.save(receiveRecord); this.save(receiveRecord);
Channel channel = channelService.getOne(new LambdaQueryWrapper<>(new Channel()).eq(Channel::getCode, receiveRecord.getChannelCode()));
channel.setCurrentVolume(receiveRecord.getReceivedVolume());
channel.setReceivedVolume(receiveRecord.getReceivedVolume());
channel.setConcentration(receiveRecord.getConcentration());
channel.setSolutionId(receiveRecord.getSolutionId());
channel.setTargetVolume(null);
channelService.updateById(channel);
LambdaUpdateWrapper<Channel> uw = new LambdaUpdateWrapper<Channel>()
.eq(Channel::getCode, receiveRecord.getChannelCode())
.set(Channel::getCurrentVolume, receiveRecord.getReceivedVolume())
.set(Channel::getReceivedVolume, receiveRecord.getReceivedVolume())
.set(Channel::getConcentration, receiveRecord.getConcentration())
.set(Channel::getSolutionId, receiveRecord.getSolutionId())
.set(Channel::getTargetVolume, null);
channelService.update(uw);
ChannelState channelState = deviceState.getChannelStateMap().get(receiveRecord.getChannelCode()); ChannelState channelState = deviceState.getChannelStateMap().get(receiveRecord.getChannelCode());
channelState.setCurrentVolume(receiveRecord.getReceivedVolume()); channelState.setCurrentVolume(receiveRecord.getReceivedVolume());

Loading…
Cancel
Save