修复出库bug
This commit is contained in:
parent
b39bb183e7
commit
be9520e62b
|
|
@ -1,26 +1,54 @@
|
|||
package cn.qihangerp.oms.controller;
|
||||
|
||||
|
||||
import cn.qihangerp.common.AjaxResult;
|
||||
import cn.qihangerp.common.PageQuery;
|
||||
import cn.qihangerp.common.PageResult;
|
||||
import cn.qihangerp.common.ResultVo;
|
||||
import cn.qihangerp.common.TableDataInfo;
|
||||
|
||||
import cn.qihangerp.module.goods.domain.OGoodsSku;
|
||||
import cn.qihangerp.module.stock.domain.ErpStockOut;
|
||||
import cn.qihangerp.module.stock.request.StockOutCreateRequest;
|
||||
import cn.qihangerp.module.stock.request.StockOutItemRequest;
|
||||
import cn.qihangerp.module.stock.service.WmsStockOutService;
|
||||
import cn.qihangerp.security.common.BaseController;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/stockOut")
|
||||
public class StockOutController extends BaseController {
|
||||
private final WmsStockOutService stockOutService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(OGoodsSku bo, PageQuery pageQuery)
|
||||
public TableDataInfo list(ErpStockOut bo, PageQuery pageQuery)
|
||||
{
|
||||
// var pageList = goodsService.querySkuPageList(bo,pageQuery);
|
||||
return getDataTable(new PageResult<>());
|
||||
var pageList = stockOutService.queryPageList(bo,pageQuery);
|
||||
return getDataTable(pageList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/create")
|
||||
public AjaxResult createEntry(@RequestBody StockOutCreateRequest request)
|
||||
{
|
||||
ResultVo<Long> resultVo = stockOutService.createEntry(getUserId(), getUsername(), request);
|
||||
if(resultVo.getCode()==0)
|
||||
return AjaxResult.success();
|
||||
else return AjaxResult.error(resultVo.getMsg());
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
|
||||
ErpStockOut entry = stockOutService.getDetailAndItemById(id);
|
||||
return success(entry);
|
||||
}
|
||||
@PostMapping("/out")
|
||||
public AjaxResult out(@RequestBody StockOutItemRequest request)
|
||||
{
|
||||
ResultVo<Long> resultVo = stockOutService.stockOut(getUserId(), getUsername(), request);
|
||||
if(resultVo.getCode()==0)
|
||||
return AjaxResult.success();
|
||||
else return AjaxResult.error(resultVo.getMsg());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public class OGoodsInventoryBatch implements Serializable {
|
|||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
private Long inventoryId;
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
<resultMap id="BaseResultMap" type="cn.qihangerp.module.goods.domain.OGoodsInventoryBatch">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<id property="inventoryId" column="inventory_id" jdbcType="BIGINT"/>
|
||||
<result property="batchNum" column="batch_num" jdbcType="VARCHAR"/>
|
||||
<result property="originQty" column="origin_qty" jdbcType="BIGINT"/>
|
||||
<result property="currentQty" column="current_qty" jdbcType="BIGINT"/>
|
||||
|
|
@ -25,7 +26,7 @@
|
|||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,batch_num,origin_qty,
|
||||
id,batch_num,origin_qty,inventory_id,
|
||||
current_qty,pur_price,pur_id,
|
||||
pur_item_id,remark,sku_id,
|
||||
goods_id,sku_code,warehouse_id,
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ package cn.qihangerp.module.stock.domain;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
@ -12,7 +14,7 @@ import lombok.Data;
|
|||
* @TableName wms_stock_out
|
||||
*/
|
||||
@Data
|
||||
public class WmsStockOut implements Serializable {
|
||||
public class ErpStockOut implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
@ -92,7 +94,7 @@ public class WmsStockOut implements Serializable {
|
|||
/**
|
||||
* 出库操作人userid
|
||||
*/
|
||||
private Integer operatorId;
|
||||
private Long operatorId;
|
||||
|
||||
/**
|
||||
* 出库操作人
|
||||
|
|
@ -118,6 +120,7 @@ public class WmsStockOut implements Serializable {
|
|||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<ErpStockOutItem> itemList;
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import lombok.Data;
|
|||
* @TableName wms_stock_out_item
|
||||
*/
|
||||
@Data
|
||||
public class WmsStockOutItem implements Serializable {
|
||||
public class ErpStockOutItem implements Serializable {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
|
|
@ -47,12 +47,12 @@ public class WmsStockOutItem implements Serializable {
|
|||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Integer goodsId;
|
||||
private Long goodsId;
|
||||
|
||||
/**
|
||||
* 商品规格id
|
||||
*/
|
||||
private Integer specId;
|
||||
private Long specId;
|
||||
|
||||
/**
|
||||
* 规格编码
|
||||
|
|
@ -62,12 +62,12 @@ public class WmsStockOutItem implements Serializable {
|
|||
/**
|
||||
* 总数量
|
||||
*/
|
||||
private Long originalQuantity;
|
||||
private Integer originalQuantity;
|
||||
|
||||
/**
|
||||
* 已出库数量
|
||||
*/
|
||||
private Long outQuantity;
|
||||
private Integer outQuantity;
|
||||
|
||||
/**
|
||||
* 完成出库时间
|
||||
|
|
@ -94,5 +94,7 @@ public class WmsStockOutItem implements Serializable {
|
|||
*/
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import lombok.Data;
|
|||
* @TableName wms_stock_out_item_position
|
||||
*/
|
||||
@Data
|
||||
public class WmsStockOutItemPosition implements Serializable {
|
||||
public class ErpStockOutItemPosition implements Serializable {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
|
|
@ -42,17 +42,19 @@ public class WmsStockOutItemPosition implements Serializable {
|
|||
/**
|
||||
* 出库数量
|
||||
*/
|
||||
private Long quantity;
|
||||
private Integer quantity;
|
||||
|
||||
/**
|
||||
* 出库仓位ID
|
||||
*/
|
||||
private Integer locationId;
|
||||
private Long warehouseId;
|
||||
private Long positionId;
|
||||
private String positionNum;
|
||||
|
||||
/**
|
||||
* 出库操作人userid
|
||||
*/
|
||||
private Integer operatorId;
|
||||
private Long operatorId;
|
||||
|
||||
/**
|
||||
* 出库操作人
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package cn.qihangerp.module.stock.mapper;
|
||||
|
||||
|
||||
import cn.qihangerp.module.stock.domain.WmsStockOutItem;
|
||||
import cn.qihangerp.module.stock.domain.ErpStockOutItem;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
|
|
@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
* @createDate 2024-09-22 11:13:23
|
||||
* @Entity cn.qihangerp.wms.domain.WmsStockOutItem
|
||||
*/
|
||||
public interface WmsStockOutItemMapper extends BaseMapper<WmsStockOutItem> {
|
||||
public interface WmsStockOutItemMapper extends BaseMapper<ErpStockOutItem> {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package cn.qihangerp.module.stock.mapper;
|
||||
|
||||
|
||||
import cn.qihangerp.module.stock.domain.WmsStockOutItemPosition;
|
||||
import cn.qihangerp.module.stock.domain.ErpStockOutItemPosition;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
|
|
@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
* @createDate 2024-09-22 11:13:23
|
||||
* @Entity cn.qihangerp.wms.domain.WmsStockOutItemPosition
|
||||
*/
|
||||
public interface WmsStockOutItemPositionMapper extends BaseMapper<WmsStockOutItemPosition> {
|
||||
public interface WmsStockOutItemPositionMapper extends BaseMapper<ErpStockOutItemPosition> {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package cn.qihangerp.module.stock.mapper;
|
||||
|
||||
|
||||
import cn.qihangerp.module.stock.domain.WmsStockOut;
|
||||
import cn.qihangerp.module.stock.domain.ErpStockOut;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
|
|
@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
* @createDate 2024-09-22 11:13:23
|
||||
* @Entity cn.qihangerp.wms.domain.WmsStockOut
|
||||
*/
|
||||
public interface WmsStockOutMapper extends BaseMapper<WmsStockOut> {
|
||||
public interface WmsStockOutMapper extends BaseMapper<ErpStockOut> {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
package cn.qihangerp.module.stock.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class GoodsSkuInventoryVo {
|
||||
// private String batchId;
|
||||
private Long skuId;
|
||||
private Long goodsId;
|
||||
|
||||
/** 商品名称 */
|
||||
private String goodsName;
|
||||
private String skuName;
|
||||
private String goodsNum;
|
||||
private String goodsImg;
|
||||
private BigDecimal purPrice;
|
||||
|
||||
// /** 商品编号 */
|
||||
private String skuCode;
|
||||
// private String colorValue;
|
||||
// /** 商品图片地址 */
|
||||
// private String colorImage;
|
||||
// private String sizeValue;
|
||||
// private String styleValue;
|
||||
//
|
||||
// private String batchNum;
|
||||
// private Long currentQty;
|
||||
// private String warehouseName;
|
||||
// private String positionNum;
|
||||
// private Long positionId;
|
||||
private Integer quantity;//出库数量
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package cn.qihangerp.module.stock.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class StockOutCreateRequest {
|
||||
private String outNum;
|
||||
private Integer type;
|
||||
private String sourceNo;
|
||||
private String operator;
|
||||
private String remark;
|
||||
private List<GoodsSkuInventoryVo> itemList;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package cn.qihangerp.module.stock.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StockOutItemRequest {
|
||||
private Long entryItemId;
|
||||
private Long entryId;
|
||||
private Long skuId;
|
||||
private Long inventoryBatchId;
|
||||
private Integer outQty;
|
||||
// private Integer originalQuantity;
|
||||
// private Integer outQuantity;
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package cn.qihangerp.module.stock.service;
|
||||
|
||||
|
||||
import cn.qihangerp.module.stock.domain.WmsStockOutItemPosition;
|
||||
import cn.qihangerp.module.stock.domain.ErpStockOutItemPosition;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
|
|
@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
* @description 针对表【wms_stock_out_item_position(出库仓位详情)】的数据库操作Service
|
||||
* @createDate 2024-09-22 11:13:23
|
||||
*/
|
||||
public interface WmsStockOutItemPositionService extends IService<WmsStockOutItemPosition> {
|
||||
public interface WmsStockOutItemPositionService extends IService<ErpStockOutItemPosition> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package cn.qihangerp.module.stock.service;
|
||||
|
||||
|
||||
import cn.qihangerp.module.stock.domain.WmsStockOutItem;
|
||||
import cn.qihangerp.module.stock.domain.ErpStockOutItem;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
|
|
@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
* @description 针对表【wms_stock_out_item(出库单明细)】的数据库操作Service
|
||||
* @createDate 2024-09-22 11:13:23
|
||||
*/
|
||||
public interface WmsStockOutItemService extends IService<WmsStockOutItem> {
|
||||
public interface WmsStockOutItemService extends IService<ErpStockOutItem> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
package cn.qihangerp.module.stock.service;
|
||||
|
||||
|
||||
import cn.qihangerp.module.stock.domain.WmsStockOut;
|
||||
import cn.qihangerp.common.PageQuery;
|
||||
import cn.qihangerp.common.PageResult;
|
||||
import cn.qihangerp.common.ResultVo;
|
||||
import cn.qihangerp.module.stock.domain.ErpStockOut;
|
||||
import cn.qihangerp.module.stock.request.StockOutCreateRequest;
|
||||
import cn.qihangerp.module.stock.request.StockOutItemRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
|
|
@ -9,6 +14,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
* @description 针对表【wms_stock_out(出库单)】的数据库操作Service
|
||||
* @createDate 2024-09-22 11:13:23
|
||||
*/
|
||||
public interface WmsStockOutService extends IService<WmsStockOut> {
|
||||
public interface WmsStockOutService extends IService<ErpStockOut> {
|
||||
PageResult<ErpStockOut> queryPageList(ErpStockOut bo, PageQuery pageQuery);
|
||||
ResultVo<Long> createEntry(Long userId, String userName, StockOutCreateRequest request);
|
||||
|
||||
ErpStockOut getDetailAndItemById(Long id);
|
||||
|
||||
ResultVo<Long> stockOut(Long userId, String userName, StockOutItemRequest request);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package cn.qihangerp.module.stock.service.impl;
|
||||
|
||||
import cn.qihangerp.module.stock.domain.WmsStockOutItemPosition;
|
||||
import cn.qihangerp.module.stock.domain.ErpStockOutItemPosition;
|
||||
import cn.qihangerp.module.stock.mapper.WmsStockOutItemPositionMapper;
|
||||
import cn.qihangerp.module.stock.service.WmsStockOutItemPositionService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
|
@ -13,7 +13,7 @@ import org.springframework.stereotype.Service;
|
|||
* @createDate 2024-09-22 11:13:23
|
||||
*/
|
||||
@Service
|
||||
public class WmsStockOutItemPositionServiceImpl extends ServiceImpl<WmsStockOutItemPositionMapper, WmsStockOutItemPosition>
|
||||
public class WmsStockOutItemPositionServiceImpl extends ServiceImpl<WmsStockOutItemPositionMapper, ErpStockOutItemPosition>
|
||||
implements WmsStockOutItemPositionService {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package cn.qihangerp.module.stock.service.impl;
|
||||
|
||||
import cn.qihangerp.module.stock.domain.WmsStockOutItem;
|
||||
import cn.qihangerp.module.stock.domain.ErpStockOutItem;
|
||||
import cn.qihangerp.module.stock.mapper.WmsStockOutItemMapper;
|
||||
import cn.qihangerp.module.stock.service.WmsStockOutItemService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
|
@ -13,7 +13,7 @@ import org.springframework.stereotype.Service;
|
|||
* @createDate 2024-09-22 11:13:23
|
||||
*/
|
||||
@Service
|
||||
public class WmsStockOutItemServiceImpl extends ServiceImpl<WmsStockOutItemMapper, WmsStockOutItem>
|
||||
public class WmsStockOutItemServiceImpl extends ServiceImpl<WmsStockOutItemMapper, ErpStockOutItem>
|
||||
implements WmsStockOutItemService {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,246 @@
|
|||
package cn.qihangerp.module.stock.service.impl;
|
||||
|
||||
import cn.qihangerp.module.stock.domain.WmsStockOut;
|
||||
import cn.qihangerp.common.PageQuery;
|
||||
import cn.qihangerp.common.PageResult;
|
||||
import cn.qihangerp.common.ResultVo;
|
||||
import cn.qihangerp.common.ResultVoEnum;
|
||||
import cn.qihangerp.common.utils.DateUtils;
|
||||
import cn.qihangerp.module.goods.domain.OGoodsInventory;
|
||||
import cn.qihangerp.module.goods.domain.OGoodsInventoryBatch;
|
||||
import cn.qihangerp.module.goods.service.OGoodsInventoryBatchService;
|
||||
import cn.qihangerp.module.goods.service.OGoodsInventoryService;
|
||||
import cn.qihangerp.module.stock.domain.ErpStockOut;
|
||||
import cn.qihangerp.module.stock.domain.ErpStockOutItem;
|
||||
import cn.qihangerp.module.stock.domain.ErpStockOutItemPosition;
|
||||
import cn.qihangerp.module.stock.mapper.WmsStockOutItemPositionMapper;
|
||||
import cn.qihangerp.module.stock.mapper.WmsStockOutMapper;
|
||||
import cn.qihangerp.module.stock.request.GoodsSkuInventoryVo;
|
||||
import cn.qihangerp.module.stock.request.StockOutCreateRequest;
|
||||
import cn.qihangerp.module.stock.request.StockOutItemRequest;
|
||||
import cn.qihangerp.module.stock.service.WmsStockOutItemService;
|
||||
import cn.qihangerp.module.stock.service.WmsStockOutService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author qilip
|
||||
* @description 针对表【wms_stock_out(出库单)】的数据库操作Service实现
|
||||
* @createDate 2024-09-22 11:13:23
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Service
|
||||
public class WmsStockOutServiceImpl extends ServiceImpl<WmsStockOutMapper, WmsStockOut>
|
||||
public class WmsStockOutServiceImpl extends ServiceImpl<WmsStockOutMapper, ErpStockOut>
|
||||
implements WmsStockOutService {
|
||||
private final WmsStockOutMapper outMapper;
|
||||
private final WmsStockOutItemService outItemService;
|
||||
private final WmsStockOutItemPositionMapper outItemPositionMapper;
|
||||
private final OGoodsInventoryBatchService goodsInventoryBatchService;
|
||||
private final OGoodsInventoryService goodsInventoryService;
|
||||
|
||||
@Override
|
||||
public PageResult<ErpStockOut> queryPageList(ErpStockOut bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<ErpStockOut> queryWrapper = new LambdaQueryWrapper<ErpStockOut>()
|
||||
|
||||
.eq( bo.getStatus()!=null, ErpStockOut::getStatus, bo.getStatus())
|
||||
.eq( bo.getStockOutType()!=null, ErpStockOut::getStockOutType, bo.getStockOutType())
|
||||
.eq(StringUtils.isNotBlank(bo.getStockOutNum()), ErpStockOut::getStockOutNum, bo.getStockOutNum())
|
||||
.eq(StringUtils.isNotBlank(bo.getSourceNum()), ErpStockOut::getSourceNum, bo.getSourceNum())
|
||||
.eq(bo.getSourceId()!=null, ErpStockOut::getSourceId, bo.getSourceId())
|
||||
;
|
||||
|
||||
Page<ErpStockOut> pages = outMapper.selectPage(pageQuery.build(), queryWrapper);
|
||||
return PageResult.build(pages);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public ResultVo<Long> createEntry(Long userId, String userName, StockOutCreateRequest request) {
|
||||
if(request.getType() == null ) return ResultVo.error(ResultVoEnum.ParamsError,"缺少参数type");
|
||||
if(request.getItemList().isEmpty()) return ResultVo.error(ResultVoEnum.ParamsError,"缺少参数itemList");
|
||||
if(StringUtils.isBlank(request.getOutNum())){
|
||||
request.setOutNum(DateUtils.parseDateToStr("yyyyMMddHHmmss",new Date()));
|
||||
}
|
||||
if(StringUtils.isBlank(request.getOperator())){
|
||||
request.setOperator(userName);
|
||||
}
|
||||
|
||||
Map<Long, List<GoodsSkuInventoryVo>> goodsGroup = request.getItemList().stream().collect(Collectors.groupingBy(x -> x.getGoodsId()));
|
||||
Long total = request.getItemList().stream().mapToLong(GoodsSkuInventoryVo::getQuantity).sum();
|
||||
|
||||
//添加主表信息
|
||||
ErpStockOut insert = new ErpStockOut();
|
||||
|
||||
insert.setStockOutNum(request.getOutNum());
|
||||
insert.setStockOutType(request.getType());
|
||||
insert.setSourceNum(request.getSourceNo());
|
||||
insert.setSourceId(0L);
|
||||
insert.setRemark(request.getRemark());
|
||||
insert.setCreateBy(userName);
|
||||
insert.setCreateTime(new Date());
|
||||
insert.setGoodsUnit(goodsGroup.size());
|
||||
insert.setSpecUnit(request.getItemList().size());
|
||||
insert.setSpecUnitTotal(total.intValue());
|
||||
insert.setOutTotal(0);
|
||||
insert.setOperatorId(userId);
|
||||
insert.setOperatorName(StringUtils.isEmpty(request.getOperator())?userName:request.getOperator());
|
||||
insert.setPrintStatus(0);
|
||||
insert.setRemark(request.getRemark());
|
||||
insert.setStatus(0);//状态(0待入库1部分入库2全部入库)
|
||||
outMapper.insert(insert);
|
||||
|
||||
//添加子表信息
|
||||
List<ErpStockOutItem> itemList = new ArrayList<>();
|
||||
for(GoodsSkuInventoryVo item: request.getItemList()) {
|
||||
|
||||
ErpStockOutItem outItem = new ErpStockOutItem();
|
||||
|
||||
outItem.setEntryId(insert.getId());
|
||||
outItem.setStockOutType(request.getType());
|
||||
outItem.setSourceOrderId(0L);
|
||||
outItem.setSourceOrderItemId(0l);
|
||||
outItem.setSourceOrderNum("");
|
||||
outItem.setGoodsId(item.getGoodsId());
|
||||
outItem.setSpecId(item.getSkuId());
|
||||
outItem.setSpecNum(item.getSkuCode());
|
||||
// inItem.setPurPrice(item.getPurPrice());
|
||||
// inItem.setSkuId(item.getSkuId());
|
||||
// inItem.setSkuCode(item.getSkuCode());
|
||||
// inItem.setGoodsName(item.getGoodsName());
|
||||
// inItem.setGoodsNum(item.getGoodsNum());
|
||||
// inItem.setSkuName(item.getSkuName());
|
||||
// inItem.setGoodsImage(item.getGoodsImg());
|
||||
outItem.setOriginalQuantity(item.getQuantity());
|
||||
outItem.setOutQuantity(0);
|
||||
outItem.setStatus(0);
|
||||
outItem.setCreateTime(new Date());
|
||||
itemList.add(outItem);
|
||||
|
||||
|
||||
}
|
||||
outItemService.saveBatch(itemList);
|
||||
return ResultVo.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErpStockOut getDetailAndItemById(Long id) {
|
||||
ErpStockOut erpStockOut = outMapper.selectById(id);
|
||||
if(erpStockOut !=null){
|
||||
List<ErpStockOutItem> outItemList = outItemService.list(new LambdaQueryWrapper<ErpStockOutItem>().eq(ErpStockOutItem::getEntryId, id));
|
||||
if(outItemList!=null && outItemList.size()>0){
|
||||
// 查找outItem skuid相对应的库存批次list
|
||||
for(ErpStockOutItem item: outItemList){
|
||||
item.setOutQuantity(item.getOriginalQuantity()-item.getOutQuantity());
|
||||
// List<ErpGoodsInventoryBatch> erpGoodsInventoryBatches = goodsInventoryBatchService.querySkuBatchList(item.getSkuId());
|
||||
// item.setInventoryBatchList(erpGoodsInventoryBatches);
|
||||
}
|
||||
|
||||
}
|
||||
erpStockOut.setItemList(outItemList);
|
||||
}
|
||||
return erpStockOut;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public ResultVo<Long> stockOut(Long userId, String userName, StockOutItemRequest request) {
|
||||
if(request.getEntryItemId() == null) return ResultVo.error(1500,"缺少参数:outItemId");
|
||||
if(request.getOutQty()==null || request.getOutQty().longValue()<=0) return ResultVo.error(1500,"缺少参数:出库数量");
|
||||
|
||||
ErpStockOutItem outItem = outItemService.getById(request.getEntryItemId());
|
||||
if(outItem == null) return ResultVo.error(1500,"出库数据错误");
|
||||
// 判断库存够不够扣减的
|
||||
OGoodsInventoryBatch batch = goodsInventoryBatchService.getById(request.getInventoryBatchId());
|
||||
if(batch == null) return ResultVo.error(1500,"库存数据不存在");
|
||||
if(batch.getCurrentQty().longValue()< request.getOutQty().longValue())
|
||||
return ResultVo.error(1500,"库存不足");
|
||||
if(StringUtils.isEmpty(batch.getRemark())) batch.setRemark("");
|
||||
// 扣减库存
|
||||
// 1扣减批次库存
|
||||
OGoodsInventoryBatch updateBatch = new OGoodsInventoryBatch();
|
||||
updateBatch.setCurrentQty(batch.getCurrentQty() - request.getOutQty());
|
||||
updateBatch.setUpdateBy(userName);
|
||||
updateBatch.setUpdateTime(new Date());
|
||||
updateBatch.setRemark(batch.getRemark()+"出库扣减库存;");
|
||||
updateBatch.setId(batch.getId());
|
||||
goodsInventoryBatchService.updateById(updateBatch);
|
||||
// 2扣减总库存
|
||||
OGoodsInventory goodsInventory = goodsInventoryService.getById(batch.getInventoryId());
|
||||
OGoodsInventory updateInventory = new OGoodsInventory();
|
||||
updateInventory.setId(goodsInventory.getId());
|
||||
updateInventory.setQuantity(goodsInventory.getQuantity() - request.getOutQty());
|
||||
updateInventory.setUpdateBy(userName);
|
||||
updateInventory.setUpdateTime(new Date());
|
||||
goodsInventoryService.updateById(updateInventory);
|
||||
|
||||
|
||||
// 添加item
|
||||
ErpStockOutItemPosition outItemPosition = new ErpStockOutItemPosition();
|
||||
|
||||
outItemPosition.setEntryId(outItem.getEntryId());
|
||||
outItemPosition.setEntryItemId(outItem.getId());
|
||||
outItemPosition.setGoodsInventoryId(batch.getInventoryId());
|
||||
outItemPosition.setGoodsInventoryDetailId(batch.getId());
|
||||
outItemPosition.setQuantity(request.getOutQty());
|
||||
outItemPosition.setOperatorId(userId);
|
||||
outItemPosition.setOperatorName(userName);
|
||||
outItemPosition.setOutTime(new Date());
|
||||
outItemPosition.setWarehouseId(batch.getWarehouseId());
|
||||
outItemPosition.setPositionId(batch.getPositionId());
|
||||
outItemPosition.setPositionNum("");
|
||||
outItemPositionMapper.insert(outItemPosition);
|
||||
|
||||
|
||||
|
||||
// 更新自己的状态
|
||||
ErpStockOutItem outItemUpdate = new ErpStockOutItem();
|
||||
outItemUpdate.setId(outItem.getId());
|
||||
outItemUpdate.setStatus(2);
|
||||
outItemUpdate.setCompleteTime(new Date());
|
||||
outItemUpdate.setOutQuantity(outItem.getOutQuantity()+ request.getOutQty());
|
||||
outItemUpdate.setUpdateTime(new Date());
|
||||
outItemService.updateById(outItemUpdate);
|
||||
|
||||
// 更新主表单数据
|
||||
ErpStockOut erpStockOut = outMapper.selectById(outItem.getEntryId());
|
||||
if(erpStockOut.getOutTotal()==null) erpStockOut.setOutTotal(0);
|
||||
// 查询入库表单是否入库完成
|
||||
List<ErpStockOutItem> itemList = outItemService.list(new LambdaQueryWrapper<ErpStockOutItem>()
|
||||
.eq(ErpStockOutItem::getEntryId,outItem.getEntryId())
|
||||
.ne(ErpStockOutItem::getStatus, 2));
|
||||
ErpStockOut sUpdate = new ErpStockOut();
|
||||
if (itemList.isEmpty()) {
|
||||
// 全部入库完成了
|
||||
sUpdate.setStatus(2);
|
||||
sUpdate.setCompleteTime(new Date());
|
||||
} else {
|
||||
// 部分入库
|
||||
sUpdate.setStatus(1);
|
||||
}
|
||||
|
||||
sUpdate.setId(outItem.getEntryId());
|
||||
sUpdate.setOperatorId(userId);
|
||||
sUpdate.setOperatorName(userName);
|
||||
sUpdate.setOutTime(new Date());
|
||||
sUpdate.setOutTotal(erpStockOut.getOutTotal()+request.getOutQty().intValue());
|
||||
sUpdate.setUpdateBy(userName);
|
||||
sUpdate.setUpdateTime(new Date());
|
||||
outMapper.updateById(sUpdate);
|
||||
|
||||
return ResultVo.success();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.qihangerp.module.wms.mapper.WmsInventoryOperationMapper">
|
||||
<mapper namespace="cn.qihangerp.module.stock.mapper.WmsInventoryOperationMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.qihangerp.module.stock.domain.WmsInventoryOperation">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.qihangerp.module.wms.mapper.WmsStockInItemMapper">
|
||||
<mapper namespace="cn.qihangerp.module.stock.mapper.WmsStockInItemMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.qihangerp.module.stock.domain.ErpStockInItem">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.qihangerp.module.wms.mapper.WmsStockInMapper">
|
||||
<mapper namespace="cn.qihangerp.module.stock.mapper.WmsStockInMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.qihangerp.module.stock.domain.ErpStockIn">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.qihangerp.module.wms.mapper.WmsStockOutItemMapper">
|
||||
<mapper namespace="cn.qihangerp.module.stock.mapper.WmsStockOutItemMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.qihangerp.module.stock.domain.WmsStockOutItem">
|
||||
<resultMap id="BaseResultMap" type="cn.qihangerp.module.stock.domain.ErpStockOutItem">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="stockOutType" column="stock_out_type" jdbcType="INTEGER"/>
|
||||
<result property="entryId" column="entry_id" jdbcType="BIGINT"/>
|
||||
|
|
|
|||
|
|
@ -2,17 +2,19 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.qihangerp.module.wms.mapper.WmsStockOutItemPositionMapper">
|
||||
<mapper namespace="cn.qihangerp.module.stock.mapper.WmsStockOutItemPositionMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.qihangerp.module.stock.domain.WmsStockOutItemPosition">
|
||||
<resultMap id="BaseResultMap" type="cn.qihangerp.module.stock.domain.ErpStockOutItemPosition">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="entryId" column="entry_id" jdbcType="BIGINT"/>
|
||||
<result property="entryItemId" column="entry_item_id" jdbcType="BIGINT"/>
|
||||
<result property="goodsInventoryId" column="goods_inventory_id" jdbcType="BIGINT"/>
|
||||
<result property="goodsInventoryDetailId" column="goods_inventory_detail_id" jdbcType="BIGINT"/>
|
||||
<result property="quantity" column="quantity" jdbcType="BIGINT"/>
|
||||
<result property="locationId" column="location_id" jdbcType="INTEGER"/>
|
||||
<result property="operatorId" column="operator_id" jdbcType="INTEGER"/>
|
||||
<result property="quantity" column="quantity" jdbcType="INTEGER"/>
|
||||
<result property="warehouseId" column="warehouse_id" jdbcType="BIGINT"/>
|
||||
<result property="positionId" column="position_id" jdbcType="BIGINT"/>
|
||||
<result property="positionNum" column="position_num" jdbcType="VARCHAR"/>
|
||||
<result property="operatorId" column="operator_id" jdbcType="BIGINT"/>
|
||||
<result property="operatorName" column="operator_name" jdbcType="VARCHAR"/>
|
||||
<result property="outTime" column="out_time" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.qihangerp.module.wms.mapper.WmsStockOutMapper">
|
||||
<mapper namespace="cn.qihangerp.module.stock.mapper.WmsStockOutMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.qihangerp.module.stock.domain.WmsStockOut">
|
||||
<resultMap id="BaseResultMap" type="cn.qihangerp.module.stock.domain.ErpStockOut">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="stockOutNum" column="stock_out_num" jdbcType="VARCHAR"/>
|
||||
<result property="sourceNum" column="source_num" jdbcType="VARCHAR"/>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.qihangerp.module.wms.mapper.WmsWarehouseMapper">
|
||||
<mapper namespace="cn.qihangerp.module.stock.mapper.WmsWarehouseMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.qihangerp.module.stock.domain.WmsWarehouse">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.qihangerp.module.wms.mapper.WmsWarehousePositionMapper">
|
||||
<mapper namespace="cn.qihangerp.module.stock.mapper.WmsWarehousePositionMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.qihangerp.module.stock.domain.WmsWarehousePosition">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue