From 8cdbb365ba849c283e0d3f6cf53fc46ca00b0f62 Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Thu, 11 Nov 2021 01:11:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=87=8D=E9=87=8F=E7=B2=BE?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devicectrl/controllers/Controller.java | 3 ++- .../com/cowr/local/ssjygl/main/Config.java | 2 +- .../local/ssjygl/order/LocalOrderService.java | 25 +++++++++++++------ .../order/ordertemp/OrderTempSyncService.java | 4 +-- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/controllers/Controller.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/controllers/Controller.java index a4ac1d8..b83518e 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/controllers/Controller.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/controllers/Controller.java @@ -161,7 +161,8 @@ public abstract class Controller implements Runnable { } public Boolean postWeight(int supermarket_id, String license, Double weight, String which) { - return TransportSyncService.me.postWeigh(supermarket_id, license, weight, which); + // 控制硬件上传的重量是两位小数 + return TransportSyncService.me.postWeigh(supermarket_id, license, Math.round(weight * 100) / 100.0, which); } void postLicenseQueue(String which, BlockingQueue licenseQueue) { diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java index be2762f..e53d9e6 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java @@ -103,7 +103,7 @@ public class Config extends JFinalConfig { public static DeviceThread deviceThread = new DeviceThread(); public static SocketIOService socketio = null; private static boolean client_run = true; - public static final String CLINET_VERSION = "20211108"; + public static final String CLINET_VERSION = "20211111"; public static String getRootPath() { return PathKit.getWebRootPath() diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/LocalOrderService.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/LocalOrderService.java index 76283bf..6192dc9 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/LocalOrderService.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/LocalOrderService.java @@ -5,6 +5,7 @@ import com.cowr.common.enums.Enums; import com.cowr.common.enums.OrderStateEnum; import com.cowr.common.enums.OrderTypeEnum; import com.cowr.common.utils.ChineseNumberUtil; +import com.cowr.common.utils.MathUtil; import com.cowr.common.utils.StrUtil; import com.cowr.common.view.Result; import com.cowr.local.ssjygl.actioncmdlog.ActionCmdLogSyncService; @@ -201,8 +202,7 @@ public class LocalOrderService { } - double goodsNetWeight = Math.abs(order.getDouble("weight")); - + String goodsNetWeight = ""; String goodsTareWeight = ""; String goodsGrossWeight = ""; String clientName = ""; @@ -225,6 +225,7 @@ public class LocalOrderService { if (sntype == OrderTypeEnum.SALE.getTypeid()) { + goodsNetWeight = String.format("%.2f", Math.abs(order.getDouble("weight"))); // 净重 goodsTareWeight = String.format("%.2f", first_weight); // 皮重 goodsGrossWeight = String.format("%.2f", second_weight); // 毛重 @@ -261,7 +262,7 @@ public class LocalOrderService { } // 运输单价,车辆载重对应的起步价 - priceTrans = TransPriceService.me.getOrderStartTransPrice(order.getInt("trans_co_id"), goodsNetWeight) + ""; + priceTrans = TransPriceService.me.getOrderStartTransPrice(order.getInt("trans_co_id"), Math.abs(order.getDouble("weight"))) + ""; priceGoods = StrUtil.getRecordStr(order, "unit_price"); // 商品单价 transDistance = StrUtil.getRecordStr(order, "trans_distance"); // 运输距离 @@ -273,6 +274,7 @@ public class LocalOrderService { priceTransTotalUpper = ""; // 运输总价大写 } } else if (sntype == OrderTypeEnum.TRANSFER.getTypeid()) { + goodsNetWeight = String.format("%.2f", Math.abs(order.getDouble("weight"))); // 净重 goodsTareWeight = String.format("%.2f", second_weight); // 皮重 goodsGrossWeight = String.format("%.2f", first_weight); // 毛重 @@ -300,7 +302,7 @@ public class LocalOrderService { } // 运输单价,车辆载重对应的起步价 - priceTrans = TransPriceService.me.getOrderStartTransPrice(order.getInt("trans_co_id"), goodsNetWeight) + ""; + priceTrans = TransPriceService.me.getOrderStartTransPrice(order.getInt("trans_co_id"), Math.abs(order.getDouble("weight"))) + ""; priceGoods = StrUtil.getRecordStr(order, "unit_price"); // 商品单价 transDistance = StrUtil.getRecordStr(order, "trans_distance"); // 运输距离 @@ -312,8 +314,15 @@ public class LocalOrderService { priceTransTotalUpper = ""; // 运输总价大写 } } else if (sntype == OrderTypeEnum.TEMP.getTypeid()) { - goodsTareWeight = String.format("%.2f", first_weight); // 皮重 - goodsGrossWeight = String.format("%.2f", second_weight); // 毛重 + int decimal = 0; + double total_weight = order.getDouble("weight"); + if (total_weight > 0 && String.valueOf(total_weight).indexOf(".") > 0) { + decimal = MathUtil.getNumberDecimalDigits(total_weight); + } + + goodsNetWeight = String.format("%." + decimal + "f", Math.abs(order.getDouble("weight"))); // 净重 + goodsTareWeight = String.format("%." + decimal + "f", first_weight); // 皮重 + goodsGrossWeight = String.format("%." + decimal + "f", second_weight); // 毛重 clientName = StrUtil.getRecordStr(order, "customer_texpayer_name"); @@ -362,6 +371,7 @@ public class LocalOrderService { priceGoods = StrUtil.getRecordStr(order, "unit_price"); // 商品单价 } else if (sntype == OrderTypeEnum.TRASH.getTypeid()) { + goodsNetWeight = String.format("%.2f", Math.abs(order.getDouble("weight"))); // 净重 goodsTareWeight = String.format("%.2f", second_weight); // 皮重 goodsGrossWeight = String.format("%.2f", first_weight); // 毛重 @@ -377,6 +387,7 @@ public class LocalOrderService { remark = "废料订单:" + sn; } else if (sntype == OrderTypeEnum.PURCHASE.getTypeid()) { + goodsNetWeight = String.format("%.2f", Math.abs(order.getDouble("weight"))); // 净重 goodsTareWeight = String.format("%.2f", second_weight); // 皮重 goodsGrossWeight = String.format("%.2f", first_weight); // 毛重 @@ -430,7 +441,7 @@ public class LocalOrderService { out.put("origin", origin); out.put("dest", dest); out.put("goodsName", StrUtil.getRecordStr(order, "product_name")); - out.put("goodsNetWeight", String.format("%.2f", goodsNetWeight)); + out.put("goodsNetWeight", goodsNetWeight); out.put("transDistance", transDistance); out.put("priceGoods", priceGoods); out.put("priceGoodsTotal", paid); // ? 重量总价? diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java index 2108cdf..142bece 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java @@ -859,7 +859,7 @@ public class OrderTempSyncService { transport.setType(OrderTypeEnum.TEMP.getTypeid()); // 客户账户可用余额要可以支付本次订单 - if (availableBalance.compareTo(order.getTotalPrice()) < 1) { + if (availableBalance.compareTo(order.getTotalPrice().setScale(2, BigDecimal.ROUND_HALF_UP)) < 0) { return Result.failedstr("总价 %.2f,客户可用余额(%.2f)不足以支付", order.getTotalPrice(), availableBalance); } @@ -877,7 +877,7 @@ public class OrderTempSyncService { order.setPaid(new BigDecimal(0)); // 预付费的实际支付为 0 order.setPrepayCustomerId(prepayCustomer.getId()); - if (prepayCustomer.getSurplus().compareTo(order.getTotalPrice()) < 1) { + if (prepayCustomer.getSurplus().compareTo(order.getTotalPrice().setScale(2, BigDecimal.ROUND_HALF_UP)) < 0) { return false; }