Browse Source

fix:调整加液审计记录

master
白凤吉 3 days ago
parent
commit
320aa63ce0
  1. 14
      src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java

14
src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java

@ -304,17 +304,20 @@ public class ChannelCtrlService {
Formulation formulation = formulationService.getOne(new LambdaQueryWrapper<Formulation>().eq(Formulation::getSolutionId, channelState.getSolutionId()) 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")); .eq(Formulation::getConcentration, channelState.getConcentration()).eq(Formulation::getVolume, channelState.getTargetVolume()).last("limit 1"));
double dispensedVolume = calculateActualSolutionDispensedVolume(channelState.getPumpPositionCache(), currentPosition, formulation); 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("旧位置与新位置:{},{}", channelState.getPumpPositionCache(), currentPosition);
log.info("实际加液量:{}", dispensedVolume); 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); channelState.setCurrentVolume(roundedCurrentVolume);
Channel channel = channelService.getOne(new LambdaQueryWrapper<>(new Channel()).eq(Channel::getCode, channelState.getChannelCode())); Channel channel = channelService.getOne(new LambdaQueryWrapper<>(new Channel()).eq(Channel::getCode, channelState.getChannelCode()));
channel.setCurrentVolume(roundedCurrentVolume); channel.setCurrentVolume(roundedCurrentVolume);
channelService.updateById(channel); channelService.updateById(channel);
AuditRecord auditRecord = new AuditRecord(deviceState.getCurrentUser().getId(), deviceState.getCurrentUser().getNickname(), channelState.getSolutionId(), 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); auditRecordService.saveOrUpdate(auditRecord);
} }
} }
@ -346,7 +349,8 @@ public class ChannelCtrlService {
throw new IllegalArgumentException("Formulation.revolutions 不能为 0"); 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();
} }

Loading…
Cancel
Save