diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java index 75ddcb7..cc3aca0 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java @@ -5,7 +5,6 @@ import com.cowr.common.view.Result; import com.cowr.model.OrderclusterTruck; import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckPKValidator; import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService; -import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckValidator; import com.jfinal.aop.Before; import com.jfinal.core.Controller; diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportSyncService.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportSyncService.java index 7e69dbe..e086172 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportSyncService.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportSyncService.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.enums.TruckRodState; +import com.cowr.common.utils.DateTimeUtil; import com.cowr.common.view.Result; import com.cowr.local.ssjygl.devicectrl.common.Const; import com.cowr.local.ssjygl.main.CliCacheData; @@ -279,6 +280,30 @@ public class TransportSyncService { } // 判断是否有配额、是否在有效时间段内 + Ordercluster ordercluster = Ordercluster.dao.findById(ot.getOrderclusterId()); + if (ordercluster == null) { + log.error("未找到集团订单信息"); + Config.socketio.pubMessage(new Record().set("truck_license", result.getLicense()).set("msg", "未找到集团订单信息")); + return result; + } + + BigDecimal total_weight = ordercluster.getTotalWeight(); + Date start_time = ordercluster.getStartTime(); + Date cutoff_time = ordercluster.getCutoffTime(); + String query_start_time = DateTimeUtil.sdf.get().format(start_time); + String query_cutoff_time = DateTimeUtil.sdf.get().format(cutoff_time); + + if (total_weight != null && total_weight.compareTo(BigDecimal.ZERO) == 0) { + log.error("【%s】无配额", ordercluster.getCustomerName()); + Config.socketio.pubMessage(new Record().set("truck_license", result.getLicense()).set("msg", ordercluster.getCustomerName() + " 无配额")); + return result; + } + + if (new Date().getTime() < start_time.getTime() || new Date().getTime() > cutoff_time.getTime()) { + log.error("【%s】有效入场时间为【%s】至【%s】", result.getLicense(), query_start_time, query_cutoff_time); + Config.socketio.pubMessage(new Record().set("truck_license", result.getLicense()).set("msg", result.getLicense() + " 有效入场时间为" + query_start_time + "至" + query_cutoff_time)); + return result; + } Transport transport = new Transport(); transport.setId(StrKit.getRandomUUID()); @@ -437,8 +462,33 @@ public class TransportSyncService { OrderclusterTruck ot = OrderclusterTruckService.me.checkValidLicense(supermarket_id, result.getLicense()); if (ot == null) { - log.error("车牌【%s】未授权,可能是在黑名单中", result.getLicense()); - //TODO: 发消息到web端? + log.error("【%s】未授权,可能是在黑名单中", result.getLicense()); + Config.socketio.pubMessage(new Record().set("truck_license", result.getLicense()).set("msg", result.getLicense() + " 未授权。可能是在黑名单中")); + return result; + } + // 判断是否有配额、是否在有效时间段内 + Ordercluster ordercluster = Ordercluster.dao.findById(ot.getOrderclusterId()); + if (ordercluster == null) { + log.error("未找到集团订单信息"); + Config.socketio.pubMessage(new Record().set("truck_license", result.getLicense()).set("msg", "未找到集团订单信息")); + return result; + } + + BigDecimal total_weight = ordercluster.getTotalWeight(); + Date start_time = ordercluster.getStartTime(); + Date cutoff_time = ordercluster.getCutoffTime(); + String query_start_time = DateTimeUtil.sdf.get().format(start_time); + String query_cutoff_time = DateTimeUtil.sdf.get().format(cutoff_time); + + if (total_weight != null && total_weight.compareTo(BigDecimal.ZERO) == 0) { + log.error("【%s】无配额", ordercluster.getCustomerName()); + Config.socketio.pubMessage(new Record().set("truck_license", result.getLicense()).set("msg", ordercluster.getCustomerName() + " 无配额")); + return result; + } + + if (new Date().getTime() < start_time.getTime() || new Date().getTime() > cutoff_time.getTime()) { + log.error("【%s】有效入场时间为【%s】至【%s】", result.getLicense(), query_start_time, query_cutoff_time); + Config.socketio.pubMessage(new Record().set("truck_license", result.getLicense()).set("msg", result.getLicense() + " 有效入场时间为" + query_start_time + "至" + query_cutoff_time)); return result; } @@ -727,6 +777,26 @@ public class TransportSyncService { return Result.failedstr("车辆【%s】有未完成的入场记录,请先处理完毕!", truck_license); } + // 判断是否有配额、是否在有效时间段内 + Ordercluster ordercluster = Ordercluster.dao.findById(ot.getOrderclusterId()); + if (ordercluster == null) { + return Result.failedstr("车辆【%s】未找到集团订单信息!", truck_license); + } + + BigDecimal total_weight = ordercluster.getTotalWeight(); + Date start_time = ordercluster.getStartTime(); + Date cutoff_time = ordercluster.getCutoffTime(); + String query_start_time = DateTimeUtil.sdf.get().format(start_time); + String query_cutoff_time = DateTimeUtil.sdf.get().format(cutoff_time); + + if (total_weight != null && total_weight.compareTo(BigDecimal.ZERO) == 0) { + return Result.failedstr("【%s】无配额!", ordercluster.getCustomerName()); + } + + if (new Date().getTime() < start_time.getTime() || new Date().getTime() > cutoff_time.getTime()) { + return Result.failedstr("【%s】有效入场时间为【%s】至【%s】", truck_license, query_start_time, query_cutoff_time); + } + Date now = new Date(); Transport transport = new Transport(); @@ -816,6 +886,27 @@ public class TransportSyncService { return Result.failedstr("车辆【%s】有未完成的入场记录,请先处理完毕!", truck_license); } + + // 判断是否有配额、是否在有效时间段内 + Ordercluster ordercluster = Ordercluster.dao.findById(ot.getOrderclusterId()); + if (ordercluster == null) { + return Result.failedstr("车辆【%s】未找到集团订单信息!", truck_license); + } + + BigDecimal total_weight = ordercluster.getTotalWeight(); + Date start_time = ordercluster.getStartTime(); + Date cutoff_time = ordercluster.getCutoffTime(); + String query_start_time = DateTimeUtil.sdf.get().format(start_time); + String query_cutoff_time = DateTimeUtil.sdf.get().format(cutoff_time); + + if (total_weight != null && total_weight.compareTo(BigDecimal.ZERO) == 0) { + return Result.failedstr("【%s】无配额!", ordercluster.getCustomerName()); + } + + if (new Date().getTime() < start_time.getTime() || new Date().getTime() > cutoff_time.getTime()) { + return Result.failedstr("【%s】有效入场时间为【%s】至【%s】", truck_license, query_start_time, query_cutoff_time); + } + Transport transport = new Transport(); transport.setId(StrKit.getRandomUUID()); transport.setSupermarketId(supermarket_id);