public DataResult GetMaterialBatch([FromQuery] bool log, int pId, string pIds,
                                           bool menu, int qId, string qIds, int batchId, string batchIds, int bId, string bIds, int sId, string sIds, bool zero, int itemId, int logId, bool con)
        {
            var result    = new DataResult();
            var pIdList   = !pIds.IsNullOrEmpty() ? pIds.Split(",").Select(int.Parse) : null;
            var qIdList   = !qIds.IsNullOrEmpty() ? qIds.Split(",").Select(int.Parse) : null;
            var batchList = !batchIds.IsNullOrEmpty() ? batchIds.Split(",").Select(int.Parse) : null;
            var bIdList   = !bIds.IsNullOrEmpty() ? bIds.Split(",").Select(int.Parse) : null;
            var sIdList   = !sIds.IsNullOrEmpty() ? sIds.Split(",").Select(int.Parse) : null;

            if (itemId != 0)
            {
                var data = ServerConfig.ApiDb.Query <MaterialBatch>(
                    "SELECT b.* FROM `material_log` a JOIN `material_batch` b ON a.BIds = b.Id WHERE Type = @type AND ItemId = @itemId;",
                    new
                {
                    type = MaterialOp.入库,
                    itemId
                });
                var supplierIds = data.Select(x => x.SupplierId).Distinct();
                if (supplierIds.Any())
                {
                    var suppliers = MaterialSupplierHelper.Instance.GetByIds <MaterialSupplier>(supplierIds).ToDictionary(x => x.Id);
                    foreach (var d in data)
                    {
                        if (suppliers.ContainsKey(d.SupplierId))
                        {
                            d.Supplier = suppliers[d.SupplierId].Supplier;
                        }
                    }
                }

                result.datas.AddRange(data);
            }
            else if (log)
            {
                IEnumerable <MaterialBatch> data;
                if (logId != 0)
                {
                    var lg = MaterialLogHelper.Instance.Get <MaterialLog>(logId);
                    if (!lg.BIdList.Any())
                    {
                        result.errno = Error.MaterialBatchNotExist;
                        return(result);
                    }

                    var batches = lg.BatchesList.ToDictionary(x => x.Id);
                    data = MaterialBatchHelper.GetDetails(lg.BIdList);
                    foreach (var d in data)
                    {
                        d.Number = batches.ContainsKey(d.Id) ? batches[d.Id].Number : 0;
                    }
                }
                else if (pId != 0)
                {
                    data = ServerConfig.ApiDb.Query <MaterialBatch>(
                        "SELECT b.*, a.Number `Left` FROM `material_log` a JOIN `material_batch` b ON a.BIds = b.Id WHERE Type = @type AND PlanId = @pId AND a.BillId = @bId;",
                        new
                    {
                        type = MaterialOp.出库,
                        pId,
                        bId
                    });
                }
                else
                {
                    data = ServerConfig.ApiDb.Query <MaterialBatch>(
                        "SELECT b.*, a.Number `Left` FROM `material_log` a JOIN `material_batch` b ON a.BIds = b.Id WHERE Type = @type AND PlanId = 0 AND a.BillId = @bId;",
                        new
                    {
                        type = MaterialOp.出库,
                        bId
                    });
                }
                var supplierIds = data.Select(x => x.SupplierId).Distinct();
                if (supplierIds.Any())
                {
                    var suppliers = MaterialSupplierHelper.Instance.GetByIds <MaterialSupplier>(supplierIds).ToDictionary(x => x.Id);
                    foreach (var d in data)
                    {
                        if (suppliers.ContainsKey(d.SupplierId))
                        {
                            d.Supplier = suppliers[d.SupplierId].Supplier;
                        }
                    }
                }
                result.datas.AddRange(data);
            }
            else if (zero)
            {
                result.datas.AddRange(MaterialBatchHelper.GetDetailsNoZero(new List <int> {
                    bId
                }));
            }
            //物料扫码 批次
            else if (con)
            {
                var batch = MaterialBatchHelper.GetDetail(qId);
                if (batch == null)
                {
                    result.errno = Error.MaterialBatchNotExist;
                    return(result);
                }

                var bill = MaterialHelper.GetDetail(batch.BillId);
                if (bill == null)
                {
                    result.errno = Error.MaterialBillNotExist;
                    return(result);
                }

                var res = ClassExtension.CopyTo <Material, MaterialManagementBatch>(bill);
                res.Supplier = batch.Supplier;
                res.Left     = batch.Left;
                res.Batch    = batch.Batch;
                result.datas.Add(res);
            }
            else
            {
                result.datas.AddRange(menu
                    ? MaterialBatchHelper.GetMenus(qId, qIdList, batchId, batchList, bId, bIdList, sId, sIdList, zero)
                    : MaterialBatchHelper.GetDetails(qId, qIdList, batchId, batchList, bId, bIdList, sId, sIdList, zero));
                if (qId != 0 && !result.datas.Any())
                {
                    result.errno = Error.MaterialBatchNotExist;
                    return(result);
                }
            }
            return(result);
        }