diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java index ffbe4f4..c150296 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java @@ -12,8 +12,10 @@ import com.cowr.model.OrderclusterTruck; import com.cowr.model.Sysuser; import com.cowr.model.Transport; import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService; +import com.cowr.ssjygl.transport.TransportService; import com.cowr.ssjygl.transprice.TransPriceService; import com.jfinal.kit.StrKit; +import com.jfinal.log.Log; import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Page; import com.jfinal.plugin.activerecord.Record; @@ -29,7 +31,8 @@ import java.util.*; *
*/ public class OrderclusterService extends BaseService { - public static final OrderclusterService me = new OrderclusterService(); + private static Log log = Log.getLog(OrderclusterService.class); + public static final OrderclusterService me = new OrderclusterService(); public Result get(Integer id, Sysuser sysuser) { Ordercluster ordercluster = Ordercluster.dao.findById(id); @@ -582,53 +585,50 @@ public class OrderclusterService extends BaseService { } public BigDecimal getTotalPriceByLicense(int supermarket_id, String truck_license, double weight) { - Transport transport = Transport.dao.findFirst("select * from transport t \n" + - " where t.state < ? \n" + - " and t.supermarket_id = ? \n" + - " and t.truck_license = ? \n" + - " and t.out_time like ? ", - OrderStateEnum.RECEIVED.getStateid(), - supermarket_id, - truck_license, - DateTimeUtil.sdf.get().format(new Date()) + "%" - ); + Transport transport = TransportService.me.undoneTransport(supermarket_id, truck_license); if (transport == null) { + log.debug("没有找到运输记录"); return null; } - if (transport.getFirstWeight() == null || transport.getSecondWeight() == null) { + if (transport.getFirstWeight() == null) { + log.debug("没有入场重量"); return null; } OrderclusterTruck ot = OrderclusterTruckService.me.checkValidLicense(transport.getSupermarketId(), transport.getTruckLicense()); if (ot == null) { + log.debug("没有配车记录"); return null; } Ordercluster ordercluster = Ordercluster.dao.findById(ot.getOrderclusterId()); if (ordercluster == null) { + log.debug("没有找到关联的集团订单信息"); return null; } BigDecimal up = ordercluster.getUnitPrice(); // 集团订单是每天创建的,可以使用集团订单中确定的单价 if (up == null) { + log.debug("集团订单单价信息错误"); return null; } - BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()).abs(); + BigDecimal net_weight = new BigDecimal(weight).subtract(transport.getFirstWeight()).abs(); BigDecimal total_price = TransPriceService.me.caleTotalPrice(up, net_weight); - if(total_price == null){ + if (total_price == null) { + log.debug("总价计算错误"); return null; } // 零散购砂总价四舍五入 - if(ordercluster.getCustomerId() == null){ + if (ordercluster.getCustomerId() == null) { total_price = total_price.setScale(0, BigDecimal.ROUND_HALF_UP); } 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 fb11774..df3059a 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 @@ -94,7 +94,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 = "20201029"; + public static final String CLINET_VERSION = "20201029.2"; public static String getRootPath() { return PathKit.getWebRootPath() diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportDeviceService.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportDeviceService.java index 3c7c077..7cf1126 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportDeviceService.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportDeviceService.java @@ -286,11 +286,26 @@ public class TransportDeviceService { return Result.failed("记录已完成或者已取消"); } - Double weight = Config.deviceThread.scale(which); + Double weight = null; + int tryCount = 0; // 称重失败,在称一次 - if (weight == null || weight == 0) { - weight = Config.deviceThread.scale(which); + while (tryCount < 4) { + try { + weight = Config.deviceThread.scale(which); + + if (weight != null && weight > 0) { + break; + } + + Thread.sleep(500); + }catch (Exception e){ + log.error(e.getMessage(), e); + }finally { + tryCount++; + + log.debug("%s 第 %s 次,重 %s", transport.getTruckLicense(), tryCount, weight); + } } if (weight == null || weight == 0) {