package com.sunda.spmswms.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sunda.spmscommon.ResponseResult;
import com.sunda.spmswms.entity.WhsInventoryInfo;

import java.util.Map;

/**
 * <p>
 * 仓库库存信息表 服务类
 * </p>
 *
 * @author Wayne
 * @since 2021-01-28
 */
public interface IWhsInventoryInfoService extends IService<WhsInventoryInfo> {

    /** 根据工厂代码查询全部仓库分页库存信息 */
    Map<String,Object> getWhsInventory(String werks, int pageNo, int pageSize);

    /** 备件货验收成功时，箱码信息进入到仓库库存 */
    void addBoxNoteToWhsInventoryInfo(JSONObject sapDeliveryNote, JSONArray sapBoxNote, String userId);

    /**  备件货扣减仓库库存，直接删除*/
    ResponseResult deductWhsInventoryInfoX(String werks, String whsLocationCode, String boxNote, String userId);

    /** 备件货检查boxNote是否存在*/
    WhsInventoryInfo getWhsInventoryInfoByBoxNote(String boxNote, String werks, String whsLocationCode);

    /** 根据工厂代码、仓库地点代码、箱码查询数量 */
    String getQuantityByBoxNote(String werks, String whsLocationCode, String boxNote);

    /** 根据工厂代码、仓库地点代码、箱码删除对影箱码仓库库存数据 */
    int deleteBoxNoteWhsInventory(String werks, String whsLocationCode, String boxNote);

    /** 根据工厂代码、仓库地点代码、箱码新增箱码仓库库存。新增之前先做一次删除操作。 */
    int addWhsInventory(String werks, String whsLocationCode, String boxNote, double quantity, String userId);



    /** 线程安全控制————备件货仓库库存操作，包括库存校验，operateType = add 加库存；operateType = sub 减库存；加减库存时 qty 都取1；此法不带操作日志； */
    ResponseResult updateWhsInventoryX(String werks, String whsLocationCode, String boxNote, double qty, String operateType, String userId);
}
