master
ljw 2025-12-31 15:45:46 +08:00
parent caddd9eed1
commit 1fc09bb9d3
4 changed files with 98 additions and 15 deletions

View File

@ -125,12 +125,12 @@ public class OrderController {
/** /**
* *
*//* */
@PostMapping("/truck_leaving") @PostMapping("/truck_leaving")
public R<?> truckLeaving(@RequestBody TruckLeavingOrderParam truckLeavingOrderParam) { public R<?> truckLeaving(@RequestBody TruckLeavingParam leavingParam) {
// orderInfoService.truckLeaving(truckLeavingOrderParam, 1); orderService.truckLeaving(leavingParam);
return R.success(); return R.success();
} */ }
} }

View File

@ -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;
}

View File

@ -305,8 +305,9 @@ public class OrderService extends ServiceImpl<OrderMapper, OrderEntity> {
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void truckComing(TruckComingParam comingParam) { public void truckComing(TruckComingParam comingParam) {
Integer weight = comingParam.getWeight();
Assert.notNull(comingParam.getOrderTransId(), () -> Exceptions.clierr("订单运输ID不可为空")); Assert.notNull(comingParam.getOrderTransId(), () -> Exceptions.clierr("订单运输ID不可为空"));
Assert.notNull(comingParam.getWeight(), () -> Exceptions.clierr("磅重不可为空")); Assert.notNull(weight, () -> Exceptions.clierr("磅重不可为空"));
OrderTransResult result = orderTransMapper.getById(comingParam.getOrderTransId()); OrderTransResult result = orderTransMapper.getById(comingParam.getOrderTransId());
Assert.notNull(result, () -> Exceptions.clierr("订单不存在")); Assert.notNull(result, () -> Exceptions.clierr("订单不存在"));
@ -315,7 +316,7 @@ public class OrderService extends ServiceImpl<OrderMapper, OrderEntity> {
TransStatus transStatus = result.getTransStatus(); TransStatus transStatus = result.getTransStatus();
Assert.isTrue(Objects.equals(orderStatus, OrderStatus.JinXingZhong) && Assert.isTrue(Objects.equals(orderStatus, OrderStatus.JinXingZhong) &&
Objects.equals(transStatus, TransStatus.YunShuZhong), () -> Exceptions.clierr("当前订单状态,无法进场")); 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(); OrderTransEntity transEntity = new OrderTransEntity();
@ -323,17 +324,11 @@ public class OrderService extends ServiceImpl<OrderMapper, OrderEntity> {
transEntity.setTransStatus(TransStatus.YiJinChang); transEntity.setTransStatus(TransStatus.YiJinChang);
// 根据订单类型区分毛重皮重 // 根据订单类型区分毛重皮重
if (OrderCategory.HuiShouYuYue.equals(result.getOrderCategory())) { if (OrderCategory.HuiShouYuYue.equals(result.getOrderCategory())) {
transEntity.setRoughWeight(comingParam.getWeight()); transEntity.setRoughWeight(weight);
} else if (OrderCategory.XiaoShouYuYue.equals(result.getOrderCategory())) { } else if (OrderCategory.XiaoShouYuYue.equals(result.getOrderCategory())) {
transEntity.setTareWeight(comingParam.getWeight()); transEntity.setTareWeight(weight);
// 更新车辆皮重 // 更新车辆皮重
TruckEntity truckEntity = truckMapper.selectById(result.getTruckId()); this.updateTruckHisTareWeight(result.getTruckId(), weight);
Assert.notNull(truckEntity, () -> Exceptions.clierr("车辆不存在"));
TruckEntity truck = new TruckEntity();
truck.setId(truckEntity.getId());
truck.setTareWeight(comingParam.getWeight());
truckMapper.updateById(truck);
} }
transEntity.setInFrontPhoto(comingParam.getFrontPhoto()); transEntity.setInFrontPhoto(comingParam.getFrontPhoto());
transEntity.setInBodyPhoto(comingParam.getBodyPhoto()); transEntity.setInBodyPhoto(comingParam.getBodyPhoto());
@ -362,7 +357,51 @@ public class OrderService extends ServiceImpl<OrderMapper, OrderEntity> {
transEntity.setCheckPhoto(checkGoodsParam.getCheckPhoto()); transEntity.setCheckPhoto(checkGoodsParam.getCheckPhoto());
transEntity.setCheckerMemo(checkGoodsParam.getCheckerMemo()); transEntity.setCheckerMemo(checkGoodsParam.getCheckerMemo());
orderTransMapper.updateById(transEntity); 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);
} }
/** /**

View File

@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.PageParam;
import com.njzscloud.common.mp.support.PageResult; import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.dispose.wh.mapper.InventoryMapper; import com.njzscloud.dispose.wh.mapper.InventoryMapper;
@ -33,6 +34,11 @@ public class InventoryService extends ServiceImpl<InventoryMapper, InventoryEnti
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void add(AddInventoryParam addInventoryParam) { public void add(AddInventoryParam addInventoryParam) {
if (this.exists(Wrappers.<InventoryEntity>lambdaQuery().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); InventoryEntity entity = BeanUtil.copyProperties(addInventoryParam, InventoryEntity.class);
this.save(entity); this.save(entity);
} }