diff --git a/njzscloud-svr/src/main/java/com/njzscloud/dispose/cst/order/controller/OrderController.java b/njzscloud-svr/src/main/java/com/njzscloud/dispose/cst/order/controller/OrderController.java index 94e1ae0..d6cdb43 100644 --- a/njzscloud-svr/src/main/java/com/njzscloud/dispose/cst/order/controller/OrderController.java +++ b/njzscloud-svr/src/main/java/com/njzscloud/dispose/cst/order/controller/OrderController.java @@ -125,12 +125,12 @@ public class OrderController { /** * 车辆出场 - *//* + */ @PostMapping("/truck_leaving") - public R truckLeaving(@RequestBody TruckLeavingOrderParam truckLeavingOrderParam) { - // orderInfoService.truckLeaving(truckLeavingOrderParam, 1); + public R truckLeaving(@RequestBody TruckLeavingParam leavingParam) { + orderService.truckLeaving(leavingParam); return R.success(); - } */ + } } diff --git a/njzscloud-svr/src/main/java/com/njzscloud/dispose/cst/order/pojo/param/TruckLeavingParam.java b/njzscloud-svr/src/main/java/com/njzscloud/dispose/cst/order/pojo/param/TruckLeavingParam.java new file mode 100644 index 0000000..93859d4 --- /dev/null +++ b/njzscloud-svr/src/main/java/com/njzscloud/dispose/cst/order/pojo/param/TruckLeavingParam.java @@ -0,0 +1,38 @@ +package com.njzscloud.dispose.cst.order.pojo.param; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * 车辆进出场信息 + * @author ljw + */ +@Getter +@Setter +@ToString +@Accessors(chain = true) +public class TruckLeavingParam { + + /** + * 运输信息Id + */ + private Long orderTransId; + + /** + * 磅重; 单位:千克 + */ + private Integer weight; + + /** + * 出场车头照片 + */ + private String frontPhoto; + + /** + * 出场车斗照片 + */ + private String bodyPhoto; + +} diff --git a/njzscloud-svr/src/main/java/com/njzscloud/dispose/cst/order/service/OrderService.java b/njzscloud-svr/src/main/java/com/njzscloud/dispose/cst/order/service/OrderService.java index 33a4e88..fa72647 100644 --- a/njzscloud-svr/src/main/java/com/njzscloud/dispose/cst/order/service/OrderService.java +++ b/njzscloud-svr/src/main/java/com/njzscloud/dispose/cst/order/service/OrderService.java @@ -305,8 +305,9 @@ public class OrderService extends ServiceImpl { */ @Transactional(rollbackFor = Exception.class) public void truckComing(TruckComingParam comingParam) { + Integer weight = comingParam.getWeight(); Assert.notNull(comingParam.getOrderTransId(), () -> Exceptions.clierr("订单运输ID不可为空")); - Assert.notNull(comingParam.getWeight(), () -> Exceptions.clierr("磅重不可为空")); + Assert.notNull(weight, () -> Exceptions.clierr("磅重不可为空")); OrderTransResult result = orderTransMapper.getById(comingParam.getOrderTransId()); Assert.notNull(result, () -> Exceptions.clierr("订单不存在")); @@ -315,7 +316,7 @@ public class OrderService extends ServiceImpl { TransStatus transStatus = result.getTransStatus(); Assert.isTrue(Objects.equals(orderStatus, OrderStatus.JinXingZhong) && Objects.equals(transStatus, TransStatus.YunShuZhong), () -> Exceptions.clierr("当前订单状态,无法进场")); - Assert.isTrue(comingParam.getWeight() != null && comingParam.getWeight() > 0, () -> Exceptions.clierr("磅重错误")); + Assert.isTrue(weight != null && weight > 0, () -> Exceptions.clierr("磅重错误")); // 更新运输信息 OrderTransEntity transEntity = new OrderTransEntity(); @@ -323,17 +324,11 @@ public class OrderService extends ServiceImpl { transEntity.setTransStatus(TransStatus.YiJinChang); // 根据订单类型区分毛重皮重 if (OrderCategory.HuiShouYuYue.equals(result.getOrderCategory())) { - transEntity.setRoughWeight(comingParam.getWeight()); + transEntity.setRoughWeight(weight); } else if (OrderCategory.XiaoShouYuYue.equals(result.getOrderCategory())) { - transEntity.setTareWeight(comingParam.getWeight()); + transEntity.setTareWeight(weight); // 更新车辆皮重 - TruckEntity truckEntity = truckMapper.selectById(result.getTruckId()); - Assert.notNull(truckEntity, () -> Exceptions.clierr("车辆不存在")); - - TruckEntity truck = new TruckEntity(); - truck.setId(truckEntity.getId()); - truck.setTareWeight(comingParam.getWeight()); - truckMapper.updateById(truck); + this.updateTruckHisTareWeight(result.getTruckId(), weight); } transEntity.setInFrontPhoto(comingParam.getFrontPhoto()); transEntity.setInBodyPhoto(comingParam.getBodyPhoto()); @@ -362,7 +357,51 @@ public class OrderService extends ServiceImpl { transEntity.setCheckPhoto(checkGoodsParam.getCheckPhoto()); transEntity.setCheckerMemo(checkGoodsParam.getCheckerMemo()); orderTransMapper.updateById(transEntity); + } + /** + * 车辆出场 + */ + @Transactional(rollbackFor = Exception.class) + public void truckLeaving(TruckLeavingParam leavingParam) { + Integer weight = leavingParam.getWeight(); + Assert.notNull(leavingParam.getOrderTransId(), () -> Exceptions.clierr("订单运输ID不可为空")); + Assert.isTrue(weight != null && weight > 0, () -> Exceptions.clierr("磅重错误")); + + OrderTransResult result = orderTransMapper.getById(leavingParam.getOrderTransId()); + Assert.notNull(result, () -> Exceptions.clierr("订单不存在")); + + Assert.isTrue(OrderStatus.JinXingZhong.equals(result.getOrderStatus()) + && TransStatus.YiJinChang.equals(result.getTransStatus()) && CheckStatus.YiKanLiao.equals(result.getCheckStatus()), + () -> Exceptions.clierr("当前订单状态,无法出厂")); + + // 更新运输信息 + OrderTransEntity transEntity = new OrderTransEntity(); + transEntity.setId(result.getId()); + transEntity.setTransStatus(TransStatus.YiChuChang); + // 根据订单类型区分毛重皮重 + if (OrderCategory.HuiShouYuYue.equals(result.getOrderCategory())) { + transEntity.setTareWeight(weight); + // 更新车辆皮重 + this.updateTruckHisTareWeight(result.getTruckId(), weight); + } else if (OrderCategory.XiaoShouYuYue.equals(result.getOrderCategory())) { + transEntity.setRoughWeight(weight); + } + transEntity.setSettleWeight(transEntity.getRoughWeight() - transEntity.getTareWeight()); + transEntity.setOutFrontPhoto(leavingParam.getFrontPhoto()); + transEntity.setOutBodyPhoto(leavingParam.getBodyPhoto()); + transEntity.setOutTime(LocalDateTime.now()); + orderTransMapper.updateById(transEntity); + } + + public void updateTruckHisTareWeight(Long truckId, Integer weight) { + TruckEntity truckEntity = truckMapper.selectById(truckId); + Assert.notNull(truckEntity, () -> Exceptions.clierr("车辆不存在")); + + TruckEntity truck = new TruckEntity(); + truck.setId(truckEntity.getId()); + truck.setTareWeight(weight); + truckMapper.updateById(truck); } /** diff --git a/njzscloud-svr/src/main/java/com/njzscloud/dispose/wh/service/InventoryService.java b/njzscloud-svr/src/main/java/com/njzscloud/dispose/wh/service/InventoryService.java index 9340434..443587c 100644 --- a/njzscloud-svr/src/main/java/com/njzscloud/dispose/wh/service/InventoryService.java +++ b/njzscloud-svr/src/main/java/com/njzscloud/dispose/wh/service/InventoryService.java @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njzscloud.common.core.ex.Exceptions; import com.njzscloud.common.mp.support.PageParam; import com.njzscloud.common.mp.support.PageResult; import com.njzscloud.dispose.wh.mapper.InventoryMapper; @@ -33,6 +34,11 @@ public class InventoryService extends ServiceImpllambdaQuery().eq(InventoryEntity::getWarehouseId, addInventoryParam.getWarehouseId()) + .eq(InventoryEntity::getGoodsId, addInventoryParam.getGoodsId()) + .eq(InventoryEntity::getDeleted, Boolean.FALSE))) { + throw Exceptions.clierr("该产品已存在仓库,无需新增"); + } InventoryEntity entity = BeanUtil.copyProperties(addInventoryParam, InventoryEntity.class); this.save(entity); }