From 320aa63ce0ff4310f02f61dfdc86965ffd0af753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Fri, 1 Aug 2025 16:39:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E5=8A=A0=E6=B6=B2?= =?UTF-8?q?=E5=AE=A1=E8=AE=A1=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iflytop/handacid/app/service/ChannelCtrlService.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java b/src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java index a321614..00a6a7b 100644 --- a/src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java +++ b/src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java @@ -304,17 +304,20 @@ public class ChannelCtrlService { Formulation formulation = formulationService.getOne(new LambdaQueryWrapper().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(); }