|
|
@ -304,17 +304,20 @@ public class ChannelCtrlService { |
|
|
|
Formulation formulation = formulationService.getOne(new LambdaQueryWrapper<Formulation>().eq(Formulation::getSolutionId, channelState.getSolutionId()) |
|
|
|
.eq(Formulation::getConcentration, channelState.getConcentration()).eq(Formulation::getVolume, channelState.getTargetVolume()).last("limit 1")); |
|
|
|
double dispensedVolume = calculateActualSolutionDispensedVolume(channelState.getPumpPositionCache(), currentPosition, formulation); |
|
|
|
double currentVolume = channelState.getCurrentVolume() - dispensedVolume; |
|
|
|
BigDecimal bd = BigDecimal.valueOf(currentVolume); |
|
|
|
double roundedCurrentVolume = bd.setScale(2, RoundingMode.HALF_UP).doubleValue(); |
|
|
|
double currentVolume = channelState.getCurrentVolume() - dispensedVolume;//剩余 |
|
|
|
log.info("旧位置与新位置:{},{}", channelState.getPumpPositionCache(), currentPosition); |
|
|
|
log.info("实际加液量:{}", dispensedVolume); |
|
|
|
BigDecimal bd = BigDecimal.valueOf(currentVolume); |
|
|
|
double roundedCurrentVolume = bd.setScale(2, RoundingMode.HALF_UP).doubleValue();//剩余保留2位 |
|
|
|
if(roundedCurrentVolume < 0){ |
|
|
|
roundedCurrentVolume = 0; |
|
|
|
} |
|
|
|
channelState.setCurrentVolume(roundedCurrentVolume); |
|
|
|
Channel channel = channelService.getOne(new LambdaQueryWrapper<>(new Channel()).eq(Channel::getCode, channelState.getChannelCode())); |
|
|
|
channel.setCurrentVolume(roundedCurrentVolume); |
|
|
|
channelService.updateById(channel); |
|
|
|
AuditRecord auditRecord = new AuditRecord(deviceState.getCurrentUser().getId(), deviceState.getCurrentUser().getNickname(), channelState.getSolutionId(), |
|
|
|
channelState.getSolutionName(), formulation.getConcentration(), channelState.getChannelCode().name(), roundedCurrentVolume); |
|
|
|
channelState.getSolutionName(), formulation.getConcentration(), channelState.getChannelCode().name(), dispensedVolume);//记录审计 |
|
|
|
auditRecordService.saveOrUpdate(auditRecord); |
|
|
|
} |
|
|
|
} |
|
|
@ -346,7 +349,8 @@ public class ChannelCtrlService { |
|
|
|
throw new IllegalArgumentException("Formulation.revolutions 不能为 0"); |
|
|
|
} |
|
|
|
// 实际出液量 = 差值圈数 * (目标加液量 ÷ 目标圈数) |
|
|
|
return deltaRevolutions * (targetVolume / targetRevs); |
|
|
|
BigDecimal bd = BigDecimal.valueOf(deltaRevolutions * (targetVolume / targetRevs)); |
|
|
|
return bd.setScale(2, RoundingMode.HALF_UP).doubleValue(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|