using WmsMobileServe.Annotation;
using WmsMobileServe.ApiServe.Mobile.Vo;
using WmsMobileServe.DataBase.Base.Dao;
using WmsMobileServe.DataBase.Base.Po;
using WmsMobileServe.Utils;

namespace WmsMobileServe.ApiServe.Mobile.Service;

[Component]
public class StockOutService(TPickingGoodsDao pickingGoodsDao)
{

    /// <summary>
    /// 出一个空托
    /// </summary>
    /// <returns></returns>
    public MobileApiResponse OutEmptyVehicle()
    {
        //查询有无空托
        var emptyBoxes = pickingGoodsDao.SelectEmptyBox(null); // You might need to pass the correct CTL parameter here

        if (emptyBoxes == null || emptyBoxes.Count == 0)
        {
            return MobileApiResponse.Fail("库内没有找到可用的空载具");
        }

        TPickGoods pickGoods = new()
        {
            PickingId = UUIDUtils.GetNewUUID2(),
            GoodsId = "000000",
            GoodsName = "空载具（移动端出空托）",
            VehicleNo = "",
            Location = "-",
            MiStockNum = 0,
            PickingNum = 0,
            GoodsNumSj = 0,
            Status = "0",
            OutStand = "113"
        };
        var insertResult = pickingGoodsDao.InsertReturnErr(pickGoods);
        if (insertResult == "") return MobileApiResponse.Success(string.Format("空载具产生出库任务成功"));
        return MobileApiResponse.Fail(string.Format("空载具产生出库任务失败，异常信息：{0}", insertResult));
    }

}
