|
|
@@ -11,21 +11,29 @@ import com.dk.common.response.ResponseCodeEnum;
|
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
|
import com.dk.common.response.ResponseResultVO;
|
|
|
import com.dk.mdm.infrastructure.convert.ivt.InOutRecordConvert;
|
|
|
+import com.dk.mdm.infrastructure.convert.ivt.InboundConvert;
|
|
|
+import com.dk.mdm.infrastructure.convert.ivt.InventoryBatchConvert;
|
|
|
+import com.dk.mdm.infrastructure.convert.ivt.InventoryConvert;
|
|
|
import com.dk.mdm.mapper.ivt.InOutRecordMapper;
|
|
|
import com.dk.mdm.mapper.ivt.InventoryBatchMapper;
|
|
|
+import com.dk.mdm.mapper.ivt.OutboundItemCostMapper;
|
|
|
import com.dk.mdm.model.pojo.ivt.InOutRecord;
|
|
|
import com.dk.mdm.model.pojo.ivt.Inventory;
|
|
|
import com.dk.mdm.mapper.ivt.InventoryMapper;
|
|
|
import com.dk.common.service.BaseService;
|
|
|
import com.dk.common.mapper.BaseMapper;
|
|
|
import com.dk.mdm.model.pojo.ivt.InventoryBatch;
|
|
|
+import com.dk.mdm.model.pojo.ivt.OutboundItemCost;
|
|
|
import com.dk.mdm.model.query.ivt.InboundQuery;
|
|
|
+import com.dk.mdm.model.query.ivt.InventoryBatchQuery;
|
|
|
import com.dk.mdm.model.query.ivt.InventoryQuery;
|
|
|
import com.dk.mdm.model.response.ivt.InboundResponse;
|
|
|
+import com.dk.mdm.model.response.ivt.InventoryBatchResponse;
|
|
|
import com.dk.mdm.model.response.ivt.InventoryResponse;
|
|
|
import com.dk.mdm.model.query.ivt.InventoryQuery;
|
|
|
import com.dk.mdm.model.response.ivt.InventoryResponse;
|
|
|
import com.dk.mdm.model.vo.ivt.InOutRecordVO;
|
|
|
+import com.dk.mdm.model.vo.ivt.InventoryBatchVO;
|
|
|
import com.dk.mdm.model.vo.ivt.InventoryVO;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -56,6 +64,9 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
private InventoryMapper inventoryMapper;
|
|
|
|
|
|
@Autowired
|
|
|
+ private InventoryConvert inventoryConvert;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private InOutRecordMapper inOutRecordMapper;
|
|
|
|
|
|
@Autowired
|
|
|
@@ -64,11 +75,17 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
@Autowired
|
|
|
private InventoryBatchMapper inventoryBatchMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private InventoryBatchConvert inventoryBatchConvert;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OutboundItemCostMapper outboundItemCostMapper;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
- * @desc : 条件查询
|
|
|
+ * @desc : 条件查询
|
|
|
* @author : 姜永辉
|
|
|
- * @date : 2024/3/8 10:58
|
|
|
+ * @date : 2024/3/8 10:58
|
|
|
*/
|
|
|
@Pagination
|
|
|
public ResponseResultVO<PageList<InventoryResponse>> selectByCond(InventoryQuery inboundQuery) {
|
|
|
@@ -83,9 +100,8 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
@Transactional(
|
|
|
rollbackFor = {Exception.class}
|
|
|
)
|
|
|
- public ResponseResultVO<?> insertInbound(Map<String, Object> map) {
|
|
|
+ public ResponseResultVO<?> updateInventoryInformation(Map<String, Object> map) {
|
|
|
//region map转json
|
|
|
- JSONObject total = (JSONObject) JSON.toJSON(map.get("total"));
|
|
|
JSONArray intoDetail = new JSONArray();
|
|
|
JSONArray outDetail = new JSONArray();
|
|
|
//入库
|
|
|
@@ -109,16 +125,16 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
//赋值并校验库存流水数据
|
|
|
intoList = intoDetail.toJavaList(InOutRecordVO.class);
|
|
|
intoList = this.setInOutRecordMessageByInto(intoList);
|
|
|
- //新建库存流水
|
|
|
- this.insertInboundRecord(intoList);
|
|
|
+ //新建库存、库存批次,库存流水,出库成本
|
|
|
+ this.insertAllInventory(intoList);
|
|
|
}
|
|
|
//出库操作库存
|
|
|
else if (outDetail.size() > 0 && intoDetail.size() == 0) {
|
|
|
//赋值并校验库存流水数据
|
|
|
outList = outDetail.toJavaList(InOutRecordVO.class);
|
|
|
outList = this.setInOutRecordMessageByOut(outList);
|
|
|
- //新建库存流水
|
|
|
- this.insertInboundRecord(outList);
|
|
|
+ //新建库存、库存批次,库存流水,出库成本
|
|
|
+ this.insertAllInventory(outList);
|
|
|
}
|
|
|
//库位移动操作库存
|
|
|
else if (intoDetail.size() > 0 && outDetail.size() > 0) {
|
|
|
@@ -128,27 +144,14 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
//赋值并校验库存流水数据
|
|
|
outList = outDetail.toJavaList(InOutRecordVO.class);
|
|
|
outList = this.setInOutRecordMessageByOut(outList);
|
|
|
- //新建库存流水
|
|
|
- this.insertInboundRecord(intoList);
|
|
|
- this.insertInboundRecord(outList);
|
|
|
+ //新建库存、库存批次,库存流水,出库成本
|
|
|
+ this.insertAllInventory(intoList);
|
|
|
+ this.insertAllInventory(outList);
|
|
|
} else {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.NO_MESSAGE_OPERATE_INVENTORY.getMessage());
|
|
|
}
|
|
|
//endregion
|
|
|
//endregion
|
|
|
-
|
|
|
-
|
|
|
- //region 操作库存
|
|
|
-
|
|
|
- //endregion
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //2,库存明细插入
|
|
|
-
|
|
|
- //3.库存批次明细插入
|
|
|
-
|
|
|
- //4.存货流水插入
|
|
|
return ResponseResultUtil.success();
|
|
|
}
|
|
|
|
|
|
@@ -265,32 +268,14 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @desc : 新建库存流水
|
|
|
+ * @desc : 新建库存、库存批次,库存流水,出库成本
|
|
|
* @date : 2024/3/21 14:47
|
|
|
* @author : 寇珊珊
|
|
|
*/
|
|
|
@Transactional(
|
|
|
rollbackFor = {Exception.class}
|
|
|
)
|
|
|
- public void insertInboundRecord(List<InOutRecordVO> inOutRecordVOList) {
|
|
|
- //循环传入的明细
|
|
|
- for (InOutRecordVO inventoryBatchVO : inOutRecordVOList) {
|
|
|
- //实体转换
|
|
|
- InOutRecord inOutRecord = inOutRecordConvert.convertToPo(inventoryBatchVO);
|
|
|
- //新建
|
|
|
- inOutRecordMapper.insert(inOutRecord);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @desc : 新建库存
|
|
|
- * @date : 2024/3/21 14:47
|
|
|
- * @author : 寇珊珊
|
|
|
- */
|
|
|
- @Transactional(
|
|
|
- rollbackFor = {Exception.class}
|
|
|
- )
|
|
|
- public List<InOutRecordVO> insertInventory(List<InOutRecordVO> inOutRecordVOList) {
|
|
|
+ public List<InOutRecordVO> insertAllInventory(List<InOutRecordVO> inOutRecordVOList) {
|
|
|
//判断库存数据是否存在,存在更细,不存在新建
|
|
|
for (InOutRecordVO inOutRecordVO : inOutRecordVOList) {
|
|
|
//根据sku,仓库,非标号查询
|
|
|
@@ -300,39 +285,97 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
.setNonStdCode(inOutRecordVO.getNonStdCode()));
|
|
|
//不存在 新建
|
|
|
if (inventoryResponse == null) {
|
|
|
- Inventory inventory = new Inventory();
|
|
|
+ //采购退货入库 或者 是出库但不是销售退货出库
|
|
|
+ if(Constant.InventoryDocCode.PURCHASE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()) ||
|
|
|
+ (Constant.InventoryType.OUTBOUND.getName().equals(inOutRecordVO.getInventoryType()) &&
|
|
|
+ ! Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()))
|
|
|
+ ){
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.SKU_IS_NOT_IN_INVENTORY.getMessage());
|
|
|
+ }
|
|
|
+ Inventory inventory = new Inventory();
|
|
|
//仓库Id
|
|
|
inventory.setWhId(inOutRecordVO.getWhId());
|
|
|
//商品id
|
|
|
inventory.setSkuId(inOutRecordVO.getSkuId());
|
|
|
//非标号
|
|
|
inventory.setNonStdCode(inOutRecordVO.getNonStdCode());
|
|
|
- //库存数量
|
|
|
- inventory.setInvQty(inOutRecordVO.getIntoQty());
|
|
|
- //可售数量(可用量)
|
|
|
- inventory.setUsableQty(inOutRecordVO.getIntoQty());
|
|
|
- //库存资产
|
|
|
- inventory.setCostAmt(inOutRecordVO.getIntoAmt());
|
|
|
- //库存单价 存货资产/存货数量
|
|
|
- inventory.setCostPrice(inventory.getCostAmt().divide(inventory.getInvQty()).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ //销售退货出库也是新建 但是数量要取反 因为传过来的时候负数
|
|
|
+ if(Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode())){
|
|
|
+ //库存数量
|
|
|
+ inventory.setInvQty(inOutRecordVO.getIntoQty().negate());
|
|
|
+ //可售数量(可用量)
|
|
|
+ inventory.setUsableQty(inOutRecordVO.getIntoQty().negate());
|
|
|
+ //库存资产
|
|
|
+ inventory.setCostAmt(inOutRecordVO.getIntoAmt().negate());
|
|
|
+ //库存单价 存货资产/存货数量
|
|
|
+ inventory.setCostPrice(inventory.getCostAmt().negate().divide(inventory.getInvQty().negate()).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }else{
|
|
|
+ //库存数量
|
|
|
+ inventory.setInvQty(inOutRecordVO.getIntoQty());
|
|
|
+ //可售数量(可用量)
|
|
|
+ inventory.setUsableQty(inOutRecordVO.getIntoQty());
|
|
|
+ //库存资产
|
|
|
+ inventory.setCostAmt(inOutRecordVO.getIntoAmt());
|
|
|
+ //库存单价 存货资产/存货数量
|
|
|
+ inventory.setCostPrice(inventory.getCostAmt().divide(inventory.getInvQty()).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
//新建
|
|
|
inventoryMapper.insert(inventory);
|
|
|
//仓库Id赋值
|
|
|
inOutRecordVO.setInvId(inventory.getInvId());
|
|
|
//新建批次明细
|
|
|
+ this.insertInventoryBatch(inOutRecordVO);
|
|
|
+ //新建库存流水
|
|
|
+ this.insertInboundRecord(inOutRecordVO);
|
|
|
}
|
|
|
//存在 出库校验库存是否充足重写updateById,入库加入数据
|
|
|
else {
|
|
|
//仓库Id赋值
|
|
|
inOutRecordVO.setInvId(inventoryResponse.getInvId());
|
|
|
- //新建库存批次明细
|
|
|
- this.insertInventoryBatch(inOutRecordVO);
|
|
|
+ //新建库存流水
|
|
|
+ this.insertInboundRecord(inOutRecordVO);
|
|
|
//跟新库存数据
|
|
|
- Inventory inventory = new Inventory();
|
|
|
+ Inventory inventory = new Inventory();
|
|
|
//库存资产
|
|
|
inventory.setCostAmt(inOutRecordVO.getIntoAmt());
|
|
|
- //新建
|
|
|
- int countRow = inventoryMapper.updateById(inventory);
|
|
|
+ //实体转换
|
|
|
+ InventoryVO inventoryVO = inventoryConvert.convertToVO(inventory);
|
|
|
+ //如果是出库 需要在出库成本插入数据
|
|
|
+ if (Constant.InventoryType.OUTBOUND.getName().equals(inOutRecordVO.getInventoryType())) {
|
|
|
+ //出库成本
|
|
|
+ this.insertOutboundItemCost(inOutRecordVO);
|
|
|
+ }
|
|
|
+ //采购退货入库 或者 是出库但不是销售退货出库
|
|
|
+ if(Constant.InventoryDocCode.PURCHASE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()) ||
|
|
|
+ (Constant.InventoryType.OUTBOUND.getName().equals(inOutRecordVO.getInventoryType()) && ! Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()))
|
|
|
+ ){
|
|
|
+ //更新库存 判断是否是库存数量和本次出库的数量一致,一致直接为0
|
|
|
+ if (inOutRecordVO.getIntoQty().abs().compareTo(inventoryResponse.getUsableQty()) == 0) {
|
|
|
+ inventory.setCostPrice(BigDecimal.ZERO);
|
|
|
+ inventory.setCostAmt(BigDecimal.ZERO);
|
|
|
+ inventoryVO.setZeroFlag(true);
|
|
|
+ } else {
|
|
|
+ //根据上面的过滤如果是出库 数量取反(传值为正数改成负数)
|
|
|
+ if(Constant.InventoryType.OUTBOUND.getName().equals(inOutRecordVO.getInventoryType())){
|
|
|
+ //库存数量
|
|
|
+ inventory.setInvQty(inOutRecordVO.getIntoQty().negate());
|
|
|
+ //库存资产
|
|
|
+ inventory.setCostAmt(inOutRecordVO.getIntoAmt().negate());
|
|
|
+ }
|
|
|
+ inventoryVO.setZeroFlag(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果是销售退货出库 数量取反 (传值为负数改成正数)
|
|
|
+ if( Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode())){
|
|
|
+ //库存数量
|
|
|
+ inventory.setInvQty(inOutRecordVO.getIntoQty().negate());
|
|
|
+ //库存资产
|
|
|
+ inventory.setCostAmt(inOutRecordVO.getIntoAmt().negate());
|
|
|
+ }
|
|
|
+ //根据类型判断是新建库存批次还是更新库存批次
|
|
|
+ this.checkInsertOrUpdateInventoryBatch(inOutRecordVO);
|
|
|
+ //修改库存金额、数量相关字段
|
|
|
+ int countRow = inventoryMapper.updateAmountAndQuantity(inventoryVO);
|
|
|
//数量超出
|
|
|
if (countRow == 0) {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_HAS_EXCEEDED.getMessage());
|
|
|
@@ -343,6 +386,93 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
return inOutRecordVOList;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /*
|
|
|
+ * @desc : 判断是新建还是更新库存流水
|
|
|
+ * @date : 2024/3/22 11:49
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Transactional(
|
|
|
+ rollbackFor = {Exception.class}
|
|
|
+ )
|
|
|
+ public void checkInsertOrUpdateInventoryBatch(InOutRecordVO inOutRecordVO) {
|
|
|
+ //region 新建 入库并且不是采购退货入库 或者是销售退货出库 走新建
|
|
|
+ if(Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()) ||
|
|
|
+ (Constant.InventoryType.INBOUND.getName().equals(inOutRecordVO.getInventoryType()) &&
|
|
|
+ !Constant.InventoryDocCode.PURCHASE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()))
|
|
|
+ ){
|
|
|
+ //新建库存批次明细
|
|
|
+ this.insertInventoryBatch(inOutRecordVO);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region编辑 出库并且不是销售退货出库 入库是采购退货入库
|
|
|
+ if (Constant.InventoryDocCode.PURCHASE_ORDER.getValue().equals(inOutRecordVO.getInventoryDocCode()) ||
|
|
|
+ (Constant.InventoryType.OUTBOUND.getName().equals(inOutRecordVO.getInventoryType()) &&
|
|
|
+ !Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()))
|
|
|
+ ) {
|
|
|
+ //查询库存批次明细 按照时间排序(正序)
|
|
|
+ List<InventoryBatchResponse> inventoryBatchResponseList = inventoryBatchMapper.selectAmountAndQuantity(new InventoryBatchQuery().setInvId(inOutRecordVO.getInvId()));
|
|
|
+ if (inventoryBatchResponseList.size() > 0) {
|
|
|
+ BigDecimal qty = inOutRecordVO.getIntoQty();
|
|
|
+ BigDecimal amt = inOutRecordVO.getIntoAmt();
|
|
|
+ for (InventoryBatchResponse inventoryBatchResponse : inventoryBatchResponseList) {
|
|
|
+ InventoryBatchVO inventoryBatchVO = new InventoryBatchVO();
|
|
|
+ //判断是否为最后一次扣减当前条库存
|
|
|
+ //是
|
|
|
+ if(qty.abs().compareTo(inventoryBatchResponse.getInvQty())==0){
|
|
|
+ //主键赋值
|
|
|
+ inventoryBatchVO.setBatchId(inventoryBatchResponse.getBatchId());
|
|
|
+ //库存数量
|
|
|
+ inventoryBatchVO.setInvQty(BigDecimal.ZERO);
|
|
|
+ //存货资产
|
|
|
+ inventoryBatchVO.setCostAmt(BigDecimal.ZERO);
|
|
|
+ //清零标识
|
|
|
+ inventoryBatchVO.setZeroFlag(true);
|
|
|
+ inventoryBatchMapper.updateAmountAndQuantity(inventoryBatchVO);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //不是
|
|
|
+ else {
|
|
|
+ //当前条库存批次明细够出库
|
|
|
+ if(qty.abs().compareTo(inventoryBatchResponse.getInvQty())<0){
|
|
|
+ //主键赋值
|
|
|
+ inventoryBatchVO.setBatchId(inventoryBatchResponse.getBatchId());
|
|
|
+ //库存数量
|
|
|
+ inventoryBatchVO.setInvQty(inOutRecordVO.getIntoQty());
|
|
|
+ //存货资产
|
|
|
+ inventoryBatchVO.setCostAmt(inOutRecordVO.getIntoAmt());
|
|
|
+ //清零标识
|
|
|
+ inventoryBatchVO.setZeroFlag(true);
|
|
|
+ inventoryBatchMapper.updateAmountAndQuantity(inventoryBatchVO);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //当前条库存批次明细不够出库
|
|
|
+ if(qty.abs().compareTo(inventoryBatchResponse.getInvQty())>0){
|
|
|
+ //主键赋值
|
|
|
+ inventoryBatchVO.setBatchId(inventoryBatchResponse.getBatchId());
|
|
|
+ //库存数量
|
|
|
+ inventoryBatchVO.setInvQty(inOutRecordVO.getIntoQty());
|
|
|
+ //存货资产
|
|
|
+ inventoryBatchVO.setCostAmt(inOutRecordVO.getIntoAmt());
|
|
|
+ //清零标识
|
|
|
+ inventoryBatchVO.setZeroFlag(true);
|
|
|
+ //修改数量金额
|
|
|
+ inventoryBatchMapper.updateAmountAndQuantity(inventoryBatchVO);
|
|
|
+ //数量、金额每次更新完要重新运算
|
|
|
+ qty = qty.subtract(inventoryBatchResponse.getInvQty());
|
|
|
+ amt = amt.subtract(inventoryBatchResponse.getCostAmt());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CAN_OUTBOUND_QUANTITY_INSUFFICIENT.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @desc : 新建库存批次明细
|
|
|
* @date : 2024/3/21 14:47
|
|
|
@@ -352,7 +482,7 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
rollbackFor = {Exception.class}
|
|
|
)
|
|
|
public InOutRecordVO insertInventoryBatch(InOutRecordVO inOutRecordVO) {
|
|
|
- InventoryBatch inventoryBatch = new InventoryBatch();
|
|
|
+ InventoryBatch inventoryBatch = new InventoryBatch();
|
|
|
//库存Id
|
|
|
inventoryBatch.setInvId(inOutRecordVO.getInvId());
|
|
|
//来源Id
|
|
|
@@ -365,12 +495,22 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
inventoryBatch.setSkuId(inOutRecordVO.getSkuId());
|
|
|
//非标号
|
|
|
inventoryBatch.setNonStdCode(inOutRecordVO.getNonStdCode());
|
|
|
- //库存数量
|
|
|
- inventoryBatch.setInvQty(inOutRecordVO.getIntoQty());
|
|
|
- //库存单价
|
|
|
- inventoryBatch.setCostPrice(inOutRecordVO.getPriceInto());
|
|
|
- //货物资产
|
|
|
- inventoryBatch.setCostAmt(inOutRecordVO.getIntoAmt());
|
|
|
+ //销售退货出库也是新建 但是数量要取反 因为传过来的时候负数
|
|
|
+ if(Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode())) {
|
|
|
+ //库存数量
|
|
|
+ inventoryBatch.setInvQty(inOutRecordVO.getIntoQty().negate());
|
|
|
+ //库存单价
|
|
|
+ inventoryBatch.setCostPrice(inOutRecordVO.getPriceInto().negate());
|
|
|
+ //货物资产
|
|
|
+ inventoryBatch.setCostAmt(inOutRecordVO.getIntoAmt().negate());
|
|
|
+ }else{
|
|
|
+ //库存数量
|
|
|
+ inventoryBatch.setInvQty(inOutRecordVO.getIntoQty());
|
|
|
+ //库存单价
|
|
|
+ inventoryBatch.setCostPrice(inOutRecordVO.getPriceInto());
|
|
|
+ //货物资产
|
|
|
+ inventoryBatch.setCostAmt(inOutRecordVO.getIntoAmt());
|
|
|
+ }
|
|
|
//账务日期
|
|
|
inventoryBatch.setAccDate(LocalDate.now());
|
|
|
//新建
|
|
|
@@ -378,4 +518,44 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
return inOutRecordVO;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @desc : 新建库存流水
|
|
|
+ * @date : 2024/3/21 14:47
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Transactional(
|
|
|
+ rollbackFor = {Exception.class}
|
|
|
+ )
|
|
|
+ public void insertInboundRecord(InOutRecordVO inventoryBatchVO) {
|
|
|
+ //实体转换
|
|
|
+ InOutRecord inOutRecord = inOutRecordConvert.convertToPo(inventoryBatchVO);
|
|
|
+ //新建
|
|
|
+ inOutRecordMapper.insert(inOutRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 出库成本
|
|
|
+ * @date : 2024/3/22 9:33
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Transactional(
|
|
|
+ rollbackFor = {Exception.class}
|
|
|
+ )
|
|
|
+ public void insertOutboundItemCost(InOutRecordVO inOutRecordVO) {
|
|
|
+ OutboundItemCost outboundItemCost = new OutboundItemCost();
|
|
|
+ //出库明细ID
|
|
|
+ outboundItemCost.setOutItemId(inOutRecordVO.getItemId());
|
|
|
+ //库存ID
|
|
|
+ outboundItemCost.setInvId(inOutRecordVO.getInvId());
|
|
|
+ //出库数量
|
|
|
+ outboundItemCost.setOutQty(inOutRecordVO.getOutQty());
|
|
|
+ //出库单价
|
|
|
+ outboundItemCost.setCostPrice(inOutRecordVO.getPriceOut());
|
|
|
+ //出库成本
|
|
|
+ outboundItemCost.setCostAmt(inOutRecordVO.getOutAmt());
|
|
|
+ //新建
|
|
|
+ outboundItemCostMapper.insert(outboundItemCost);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|