package com.hw.wms.service.impl;

import com.hw.common.core.constant.WmsConstants;
import com.hw.wms.domain.WmsBaseWarehouse;
import com.hw.wms.domain.WmsProductStock;
import com.hw.wms.domain.WmsRawStock;
import com.hw.wms.domain.vo.WmsMoveMergeVo;
import com.hw.wms.mapper.*;
import com.hw.wms.service.IWmsMoveMergeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description: 移库合库服务Service业务层处理
 * @ClassName: WmsMoveServiceImpl
 * @Author  : xins
 * @Date    :2023-12-27  10:54
 * @Version :1.0
 */

@Service
public class WmsMoveMergeServiceImpl implements IWmsMoveMergeService {
    @Autowired
    private WmsRawStockMapper wmsRawStockMapper;

    @Autowired
    private WmsRawInstockMapper wmsRawInstockMapper;

    @Autowired
    private WmsRawOutstockMapper wmsRawOutstockMapper;

    @Autowired
    private WmsProductStockMapper wmsProductStockMapper;

    @Autowired
    private WmsProductInstockMapper wmsProductInstockMapper;

    @Autowired
    private WmsProductOutstockMapper wmsProductOutstockMapper;

    @Autowired
    private WmsBaseWarehouseMapper wmsBaseWarehouseMapper;

    /**
     * 人工移库
     * @param wmsMoveMergeVo
     * @return
     */
    @Override
    public int manualMove(WmsMoveMergeVo wmsMoveMergeVo,String manualMergeType){
        Long warehouseId = wmsMoveMergeVo.getWarehouseId();
        String oriLocationCode = wmsMoveMergeVo.getOriLocationCode();
        String targetLocationCode = wmsMoveMergeVo.getTargetLocationCode();
        WmsBaseWarehouse warehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId);
        String warehouseInstockType = warehouse.getWarehouseInstockType();

        //仓库类型为人工仓库

        //原库位需要有库存,没有占用数量和冻结数量
        WmsRawStock queryRawStock = new WmsRawStock();

        WmsProductStock queryProductStock = new WmsProductStock();

        //移库时目标库位为空

        //合库是目标库位不为空

        //移库中，锁库位，移库结束解锁库位


        return 1;
    }


    /**
     * 人工合库
     * @param wmsMoveMergeVo
     * @return
     */
    public int manualMerge(WmsMoveMergeVo wmsMoveMergeVo){
        Long warehouseId = wmsMoveMergeVo.getWarehouseId();
        String oriLocationCode = wmsMoveMergeVo.getOriLocationCode();
        String targetLocationCode = wmsMoveMergeVo.getTargetLocationCode();
        WmsBaseWarehouse warehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId);
        String warehouseInstockType = warehouse.getWarehouseInstockType();


        return 1;
    }



    private void manualRawMoveMerge(){


    }
}
