修改速度计算

parent 40d7e42c
...@@ -557,10 +557,10 @@ public class LanuchServiceImpl implements LanuchService { ...@@ -557,10 +557,10 @@ public class LanuchServiceImpl implements LanuchService {
prodProcessExec.setSpeed( prodProcessExec.setSpeed(
Optional.ofNullable(detail.getSingleOut()) Optional.ofNullable(detail.getRuntime())
.filter(out -> detail.getRuntime() != null) .filter(out -> detail.getSingleOut() != null)
.filter(out -> detail.getRuntime().compareTo(BigDecimal.ZERO) != 0) .filter(out -> detail.getSingleOut().compareTo(BigDecimal.ZERO) != 0)
.map(out -> out.divide(detail.getRuntime(), 6, RoundingMode.HALF_UP)) .map(out -> out.divide(detail.getSingleOut(), 6, RoundingMode.HALF_UP))
.map(BigDecimal::doubleValue) // 关键转换 .map(BigDecimal::doubleValue) // 关键转换
.orElse(0.0) .orElse(0.0)
); );
...@@ -762,12 +762,18 @@ public class LanuchServiceImpl implements LanuchService { ...@@ -762,12 +762,18 @@ public class LanuchServiceImpl implements LanuchService {
prodEquipment.setEquipName(routingDetailEquip.getName()); prodEquipment.setEquipName(routingDetailEquip.getName());
prodEquipment.setResourceId(routingDetailEquip.getType1()); prodEquipment.setResourceId(routingDetailEquip.getType1());
double duration = routingDetailEquip.getDuration() != null ? routingDetailEquip.getDuration().doubleValue() : 0.0;
double outputQuantity = routingDetailEquip.getOutputQuantity() != null ? routingDetailEquip.getOutputQuantity().doubleValue() : 0.0;
double speed = (outputQuantity > 0) ? duration / outputQuantity : 0.0; prodEquipment.setSpeed(
prodEquipment.setSpeed(speed); Optional.ofNullable(routingDetailEquip.getDuration())
// 从映射中获取execId,避免额外的数据库查询 .filter(out -> routingDetailEquip.getOutputQuantity() != null)
// 修复:使用equals比较,并处理null值 .filter(out -> routingDetailEquip.getOutputQuantity().compareTo(BigDecimal.ZERO) != 0)
.map(out -> out.divide(routingDetailEquip.getOutputQuantity(), 6, RoundingMode.HALF_UP))
.map(BigDecimal::doubleValue) // 关键转换
.orElse(0.0)
);
String execId = processExecList.stream() String execId = processExecList.stream()
.filter(exec -> { .filter(exec -> {
Long execRoutingDetailId = exec.getRoutingDetailId(); Long execRoutingDetailId = exec.getRoutingDetailId();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment