mirror of
https://github.com/zccbbg/wms-ruoyi.git
synced 2024-11-10 09:02:51 +08:00
feat: 暂存出库单
This commit is contained in:
parent
e29ed2d21e
commit
8a645003a0
5 changed files with 51 additions and 12 deletions
|
@ -2,6 +2,7 @@ package com.ruoyi.wms.controller;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.core.constant.ServiceConstants;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
@ -76,6 +77,7 @@ public class ShipmentOrderController extends BaseController {
|
|||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ShipmentOrderBo bo) {
|
||||
bo.setShipmentOrderStatus(ServiceConstants.ShipmentOrderStatus.PENDING);
|
||||
shipmentOrderService.insertByBo(bo);
|
||||
return R.ok();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import jakarta.validation.constraints.*;
|
|||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 出库单业务对象 wms_shipment_order
|
||||
|
@ -24,15 +25,15 @@ import java.math.BigDecimal;
|
|||
public class ShipmentOrderBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@NotNull(message = "不能为空", groups = { EditGroup.class })
|
||||
@NotNull(message = "id不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 出库单号,系统自动生成
|
||||
*/
|
||||
@NotBlank(message = "出库单号,系统自动生成不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotBlank(message = "出库单号不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String shipmentOrderNo;
|
||||
|
||||
/**
|
||||
|
@ -44,38 +45,32 @@ public class ShipmentOrderBo extends BaseEntity {
|
|||
/**
|
||||
* 出库订单
|
||||
*/
|
||||
@NotBlank(message = "出库订单不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 客户
|
||||
*/
|
||||
@NotNull(message = "客户不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long merchantId;
|
||||
|
||||
/**
|
||||
* 订单金额
|
||||
*/
|
||||
@NotNull(message = "订单金额不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private BigDecimal receivableAmount;
|
||||
|
||||
/**
|
||||
* 出库数量
|
||||
*/
|
||||
@NotNull(message = "出库数量不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private BigDecimal totalQuantity;
|
||||
|
||||
/**
|
||||
* 出库单状态
|
||||
*/
|
||||
@NotNull(message = "出库单状态不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Integer shipmentOrderStatus;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@NotBlank(message = "备注不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String remark;
|
||||
|
||||
|
||||
private List<ShipmentOrderDetailBo> details;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.ruoyi.wms.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.utils.MapstructUtils;
|
||||
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
||||
|
@ -13,6 +15,7 @@ import com.ruoyi.wms.domain.bo.ShipmentOrderDetailBo;
|
|||
import com.ruoyi.wms.domain.vo.ShipmentOrderDetailVo;
|
||||
import com.ruoyi.wms.domain.entity.ShipmentOrderDetail;
|
||||
import com.ruoyi.wms.mapper.ShipmentOrderDetailMapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -26,7 +29,7 @@ import java.util.Collection;
|
|||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class ShipmentOrderDetailService {
|
||||
public class ShipmentOrderDetailService extends ServiceImpl<ShipmentOrderDetailMapper, ShipmentOrderDetail> {
|
||||
|
||||
private final ShipmentOrderDetailMapper shipmentOrderDetailMapper;
|
||||
|
||||
|
@ -88,4 +91,12 @@ public class ShipmentOrderDetailService {
|
|||
public void deleteByIds(Collection<Long> ids) {
|
||||
shipmentOrderDetailMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveDetails(List<ShipmentOrderDetail> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
saveBatch(list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.wms.service;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.ruoyi.common.core.utils.GenerateNoUtil;
|
||||
import com.ruoyi.common.core.utils.MapstructUtils;
|
||||
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
|
@ -8,13 +9,16 @@ import com.ruoyi.common.core.utils.StringUtils;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.wms.domain.bo.ShipmentOrderDetailBo;
|
||||
import com.ruoyi.wms.domain.entity.ReceiptOrder;
|
||||
import com.ruoyi.wms.domain.entity.ShipmentOrderDetail;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.wms.domain.bo.ShipmentOrderBo;
|
||||
import com.ruoyi.wms.domain.vo.ShipmentOrderVo;
|
||||
import com.ruoyi.wms.domain.entity.ShipmentOrder;
|
||||
import com.ruoyi.wms.mapper.ShipmentOrderMapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -36,6 +40,7 @@ import java.util.stream.Collectors;
|
|||
public class ShipmentOrderService {
|
||||
|
||||
private final ShipmentOrderMapper shipmentOrderMapper;
|
||||
private final ShipmentOrderDetailService shipmentOrderDetailService;
|
||||
|
||||
/**
|
||||
* 查询出库单
|
||||
|
@ -75,13 +80,30 @@ public class ShipmentOrderService {
|
|||
}
|
||||
|
||||
/**
|
||||
* 新增出库单
|
||||
* 暂存出库单
|
||||
*/
|
||||
@Transactional
|
||||
public void insertByBo(ShipmentOrderBo bo) {
|
||||
// 校验出库单号唯一性
|
||||
validateShipmentOrderNo(bo.getShipmentOrderNo());
|
||||
// 创建出库单
|
||||
ShipmentOrder add = MapstructUtils.convert(bo, ShipmentOrder.class);
|
||||
shipmentOrderMapper.insert(add);
|
||||
bo.setId(add.getId());
|
||||
List<ShipmentOrderDetailBo> detailBoList = bo.getDetails();
|
||||
List<ShipmentOrderDetail> addDetailList = MapstructUtils.convert(detailBoList, ShipmentOrderDetail.class);
|
||||
addDetailList.forEach(it -> it.setShipmentOrderId(add.getId()));
|
||||
shipmentOrderDetailService.saveDetails(addDetailList);
|
||||
}
|
||||
|
||||
public void validateShipmentOrderNo(String shipmentOrderNo) {
|
||||
LambdaQueryWrapper<ShipmentOrder> receiptOrderLqw = Wrappers.lambdaQuery();
|
||||
receiptOrderLqw.eq(ShipmentOrder::getShipmentOrderNo, shipmentOrderNo);
|
||||
ShipmentOrder shipmentOrder = shipmentOrderMapper.selectOne(receiptOrderLqw);
|
||||
Assert.isNull(shipmentOrder, "出库单号重复,请手动修改");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改出库单
|
||||
*/
|
||||
|
|
|
@ -19,4 +19,13 @@ public class ServiceConstants {
|
|||
public static final Integer CHECK = 3;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 入库单状态
|
||||
*/
|
||||
public class ShipmentOrderStatus {
|
||||
public static final Integer INVALID = -1;
|
||||
public static final Integer PENDING = 0;
|
||||
public static final Integer FINISH = 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue