Beispiel #1
0
        public static OpResult Receiver(STHouseMove obj)
        {
            var op = new OpResult();

            try
            {
                var house = DiaoboService.FindById(obj.Id);
                house.State          = (short)HouseMoveState.已收货;
                house.ActualUID      = Sys.CurrentUser.UID;
                house.ActualQuantity = obj.ActualQuantity;
                op = DiaoboService.Update(house);
                if (op.Successed)
                {
                    InventoryRecordService.SaveLog(new List <InventoryRecord>()
                    {
                        new InventoryRecord()
                        {
                            Barcode = house.Barcode, StoreId = house.InStoreId, Source = 3, Number = house.ActualQuantity
                        },
                        new InventoryRecord()
                        {
                            Barcode = house.Barcode, StoreId = house.OutStoreId, Source = 4, Number = house.ActualQuantity
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                op.Message = ex.Message;
            }
            return(op);
        }
Beispiel #2
0
        /// <summary>
        /// 设置报损单为已审状态
        /// </summary>
        /// <param name="Ids"></param>
        /// <returns></returns>
        public static OpResult SetBreakageGoodsStateToChecked(string Ids)
        {
            var re = new OpResult();

            try
            {
                var ids   = Ids.Split(',').Select(o => o.ToString());
                var goods = BaseService <BreakageGoods> .FindList(o => ids.Contains(o.Id.ToString()));

                var breakageGoodsIds = goods.Select(o => o.BreakageGoodsId).ToList();
                var list             = BaseService <BreakageList> .FindList(o => breakageGoodsIds.Contains(o.BreakageGoodsId));

                if (goods.Any(o => o.State == 1))
                {
                    var goodsChecked = goods.Where(o => o.State == 1).FirstOrDefault();
                    re.Message = string.Format("报损单:{0} 已为已审状态", goodsChecked.BreakageGoodsId);
                    return(re);
                }
                var invents = new List <InventoryRecord>();
                var query   = from a in goods
                              join b in list on a.BreakageGoodsId equals b.BreakageGoodsId
                              from c in ProductService.CurrentRepository.QueryEntity
                              where b.Barcode == c.Barcode || ("," + c.Barcodes + ",").Contains("," + b.Barcode + ",")
                              group new { a, b, c } by new { a.StoreId, c.Barcode } into g
                    select new
                {
                    g.Key.StoreId,
                    g.Key.Barcode,
                    ReturnNum = g.Sum(o => o.b.BreakageNumber)
                };
                var datas = query.ToList();
                datas.Each(o =>
                {
                    invents.Add(new InventoryRecord()
                    {
                        Barcode = o.Barcode, StoreId = o.StoreId, Number = o.ReturnNum, Source = 16
                    });
                });
                goods.ForEach(o => { o.State = 1; o.VerifyTime = DateTime.Now; });
                list.ForEach(o => { o.State = 1; });
                re = BaseService <BreakageGoods> .Update(goods);

                if (re.Successed)
                {
                    InventoryRecordService.SaveLog(invents);
                }
            }
            catch (Exception ex)
            {
                re.Message = ex.Message;
            }
            return(re);
        }
        /// <summary>
        /// 修改主表退货状态(及其明细表)
        /// </summary>
        /// <param name="Ids">一组Id</param>
        /// <param name="state">状态</param>
        /// <returns>修改后的列表</returns>
        public static OpResult SetStates(string Ids, short state)
        {
            var re   = OpResult.Fail("操作失败");
            var ids  = Ids.Split(',').Select(o => int.Parse(o)).ToList();
            var list = CommodityReturnsBLL.FindList(o => ids.Contains(o.Id));

            list.ForEach(o => { o.State = state; });

            var returnId = CommodityReturnsBLL.FindList(o => ids.Contains(o.Id)).Select(o => o.ReturnId);
            var detail   = BaseService <CommodityReturnsDetail> .FindList(o => returnId.Contains(o.ReturnId));

            var invents = new List <InventoryRecord>();

            if (state == 2)
            {//转为已完成状态
                #region 从商品库中扣除相应库存
                var query = from a in list
                            join b in detail on a.ReturnId equals b.ReturnId
                            from c in ProductService.CurrentRepository.QueryEntity
                            where b.Barcode == c.Barcode || ("," + c.Barcodes + ",").Contains("," + b.Barcode + ",")
                            group new { a, b, c } by new { a.StoreId, c.Barcode } into g
                    select new
                {
                    g.Key.StoreId,
                    g.Key.Barcode,
                    ReturnNum = g.Sum(o => o.b.ReturnNum)
                };
                var datas = query.ToList();
                datas.Each(o => {
                    invents.Add(new InventoryRecord()
                    {
                        Barcode = o.Barcode, StoreId = o.StoreId, Number = o.ReturnNum, Source = 14
                    });
                });
                list.Each(o => o.VerifyTime = DateTime.Now);
            }
            detail.ForEach(o => { o.State = state; });
            CommodityReturnsBLL.Update(list, false);
            re = BaseService <CommodityReturnsDetail> .Update(detail, true);

            if (re.Successed)
            {
                InventoryRecordService.SaveLog(invents);
            }

            #endregion
            return(re);
        }
        /// <summary>
        /// 设置出库单为已审状态
        /// </summary>
        /// <param name="Ids"></param>
        /// <returns></returns>
        public static OpResult SetOutboundStateToChecked(string Ids)
        {
            var re = new OpResult();

            try
            {
                var ids   = Ids.Split(',').Select(o => int.Parse(o)).ToList();
                var goods = BaseService <OutboundGoods> .FindList(o => ids.Contains(o.Id));

                var outboundGoodIds = goods.Select(o => o.OutboundId).ToList();
                var list            = BaseService <OutboundList> .FindList(o => outboundGoodIds.Contains(o.OutboundId));

                if (goods.Any(o => o.State == 1))
                {
                    var goodsChecked = goods.Where(o => o.State == 1).FirstOrDefault();
                    re.Message = string.Format("出库单:{0} 已为已审状态", goodsChecked.OutboundId);
                    return(re);
                }
                #region 从商品库中扣除相应库存
                var storeIds = goods.GroupBy(o => o.StoreId).Select(o => o.Key).ToList();
                var invents  = new List <InventoryRecord>();
                foreach (var storeId in storeIds)
                {
                    foreach (var oid in outboundGoodIds)
                    {
                        var outgoodsGroupbyStore        = goods.Where(o => o.StoreId == storeId && o.OutboundId == oid).ToList();
                        var outboundGoodIdsGroupbyStore = outgoodsGroupbyStore.Select(o => o.OutboundId).ToList();
                        var outgoods                 = outgoodsGroupbyStore.FirstOrDefault();
                        var source                   = outgoods.Channel == 0 ? 2 : 13;
                        var outboundType             = outgoods.OutboundType;
                        var applyOrg                 = !outgoods.ApplyOrgId.IsNullOrEmpty();
                        var outBoundListGroupbyStore = list.Where(o => o.OutboundId == oid).ToList();
                        var datas = (from a in outBoundListGroupbyStore
                                     group a by a.Barcode into g
                                     select new
                        {
                            g.Key,
                            OutboundNum = g.Sum(o => o.OutboundNumber)
                        }).ToDictionary(o => o.Key, o => o.OutboundNum);
                        //判断出库的商品是否有库存记录
                        var stockNums = CommodityService.GetStockNumsByStoreId(storeId);
                        foreach (var d in datas)
                        {
                            //var stockNum = stockNums.FirstOrDefault(o => o.Key == d.Key);
                            //if (stockNum.Value == 0 && string.IsNullOrEmpty(stockNum.Key))
                            //{
                            //    re.Message = string.Format("条码:{0} 不存在库存记录,无法出库", d.Key);
                            //    return re;
                            //}
                            var bar = outBoundListGroupbyStore.FirstOrDefault(o => o.Barcode == d.Key);

                            invents.Add(new InventoryRecord()
                            {
                                Barcode = bar.Barcode, StoreId = storeId, Number = d.Value, Source = source, OperatId = oid
                            });
                            if ((source == 2 && outboundType == 1) || (source == 2 && outboundType == 2 && outgoods.ApplyOrgId != "-1"))//出库
                            {
                                invents.Add(new InventoryRecord()
                                {
                                    Barcode = bar.Barcode, StoreId = outgoods.ApplyOrgId, Number = d.Value, Source = 1, OperatId = oid
                                });
                            }
                        }
                    }
                }
                goods.ForEach(o => { o.State = 1; o.VerifyTime = DateTime.Now; });
                re = BaseService <OutboundGoods> .Update(goods);

                if (re.Successed)
                {
                    InventoryRecordService.SaveLog(invents);
                }

                #endregion
                //re.Successed = true;
            }
            catch (Exception ex)
            {
                re.Message = ex.Message;
            }
            return(re);
        }
Beispiel #5
0
        /// <summary>
        /// 收货
        /// </summary>
        /// <param name="moveId"></param>
        /// <param name="updated"></param>
        /// <param name="updated2"></param>
        /// <returns></returns>
        public static OpResult MoveinReceive(string moveId, string updated, string updated2)
        {
            var op = new OpResult();

            try
            {
                int IndexofA = updated.IndexOf('[');
                int IndexofB = updated.IndexOf(']');

                int IndexofC = updated2.IndexOf('[');
                int IndexofD = updated2.IndexOf(']');

                if (updated != "[]" || !updated.IsNullOrEmpty())
                {
                    updated = updated.Substring(IndexofA, IndexofB - IndexofA + 1);
                    if (updated.Contains("\\"))
                    {
                        updated = updated.Replace("\\", "");
                    }
                }
                if (updated2 != "[]" || !updated2.IsNullOrEmpty())
                {
                    updated2 = updated2.Substring(IndexofC, IndexofD - IndexofC + 1);
                    if (updated2.Contains("\\"))
                    {
                        updated2 = updated2.Replace("\\", "");
                    }
                }

                var dists  = updated.ToObject <List <HouseMoveList> >();
                var dists2 = updated2.ToObject <List <HouseMoveList> >();

                if (!updated2.IsNullOrEmpty())
                {
                    if (dists2.Any())
                    {
                        var barcodes = dists2.Select(o => o.Barcode);
                        dists.RemoveAll(o => barcodes.Contains(o.Barcode));
                        dists.AddRange(dists2);
                    }
                }
                dists = dists.Where(o => o.ActualQuantity > 0).ToList();

                if (!dists.Any())
                {
                    op.Message = "收获量必须大于0!";
                }
                else
                {
                    var details = BaseService <HouseMoveList> .FindList(o => o.MoveId == moveId);

                    var order   = STHouseMoveService.Find(o => o.MoveId == moveId);
                    var records = new List <InventoryRecord>();
                    foreach (var dt in details)
                    {
                        var obj = dists.FirstOrDefault(o => o.Barcode == dt.Barcode);
                        if (obj == null)
                        {
                            continue;
                        }
                        else
                        {
                            dt.ActualQuantity = obj.ActualQuantity;
                            dt.State          = 4;
                            dt.Memo           = obj.Memo;
                            var pro = ProductService.Find(o => o.Barcode == dt.Barcode || ("," + o.Barcodes + ",").Contains("," + dt.Barcode + ","));
                            records.Add(new InventoryRecord()
                            {
                                Barcode = pro != null ? pro.Barcode : dt.Barcode, StoreId = order.InStoreId, Source = 3, Number = dt.ActualQuantity, OperatId = order.MoveId
                            });
                        }
                    }
                    order.ActualUID = Sys.CurrentUser.UID;
                    order.ActualDT  = DateTime.Now;
                    order.State     = 4;
                    //增库存
                    BaseService <HouseMove> .Update(order);

                    op = BaseService <HouseMoveList> .Update(details);

                    if (op.Successed)
                    {
                        InventoryRecordService.SaveLog(records);
                    }
                }
            }

            catch (Exception ex)
            {
                op.Message = ex.Message;
                Log.WriteError(ex);
            }
            return(op);
        }
        /// <summary>
        /// 更新收货数量
        /// </summary>
        /// <param name="id"></param>
        /// <param name="num">null-设为已收货插入库存表</param>
        /// <returns></returns>
        public static OpResult Update(string id, decimal?num, string returnBarcode = "")
        {
            var ids = id.Split(',');
            var op  = new OpResult();

            try
            {
                var list = BaseService <OrderDistribution> .CurrentRepository.QueryEntity.Include(o => o.OrderDistributionGifts).Where(o => ids.Contains(o.DistributionId)).ToList();

                var orderIds      = list.Select(o => o.IndentOrderId).ToList();
                var orderDistrIds = list.Select(o => o.Id).ToList();
                var orderList     = OrderService.FindList(o => orderIds.Contains(o.IndentOrderId));
                var updated       = System.Web.HttpContext.Current.Request["Updated"];
                var gifts         = new List <OrderDistributionGift>();
                if (!updated.IsNullOrEmpty())
                {
                    gifts = updated.ToObject <List <OrderDistributionGift> >();
                }
                var records = new List <InventoryRecord>();
                list.Each(obj =>
                {
                    if (!num.HasValue)
                    {
                        obj.State = 5;
                    }
                    else
                    {
                        obj.ReceivedNum = num;
                        obj.ReceivedDT  = DateTime.Now;
                    }
                    var store = orderList.FirstOrDefault(o => o.IndentOrderId == obj.IndentOrderId);
                    foreach (var g in gifts)
                    {
                        var gift = obj.OrderDistributionGifts.FirstOrDefault(o => o.Barcode == g.Barcode);
                        if (gift != null)
                        {
                            gift.ReceivedNum = g.ReceivedNum;
                        }
                        else
                        {
                            obj.OrderDistributionGifts.Add(g);
                        }
                    }
                    foreach (var gift in obj.OrderDistributionGifts)
                    {
                        var pro = ProductService.Find(o => o.Barcode == gift.Barcode || ("," + o.Barcodes + ",").Contains("," + gift.Barcode + ","));
                        records.Add(new InventoryRecord()
                        {
                            Barcode = (pro != null?pro.Barcode: gift.Barcode), StoreId = Sys.CurrentUser.StoreId, Number = gift.ReceivedNum.GetValueOrDefault(), Source = 11, OperatId = obj.DistributionId
                        });
                    }
                });
                if (num.HasValue)
                {
                    op = BaseService <OrderDistribution> .Update(list);
                }
                else//影响库存
                {
                    var detailList = BaseService <IndentOrderList> .FindList(o => orderIds.Contains(o.IndentOrderId) && o.Nature == 0);

                    foreach (var dist in list)
                    {
                        var obj = detailList.FirstOrDefault(o => o.IndentOrderId == dist.IndentOrderId && (o.Barcode == dist.Barcode || o.AssistBarcode == dist.Barcode));
                        if (obj == null)
                        {
                            continue;
                        }
                        var store = orderList.FirstOrDefault(o => o.IndentOrderId == obj.IndentOrderId);
                        records.Add(new InventoryRecord()
                        {
                            Barcode = obj.Barcode, StoreId = store.StoreId, Number = dist.ReceivedNum.GetValueOrDefault(), OperatType = 1, Source = 11, OperatId = dist.DistributionId
                        });
                        obj.AcceptNum += dist.ReceivedNum.GetValueOrDefault();
                        if (obj.AcceptNum >= obj.IndentNum || obj.Barcode == returnBarcode)
                        {
                            obj.State = 5;
                        }
                    }
                    foreach (var order in orderList)
                    {
                        int count   = 0;
                        var details = detailList.Where(o => o.IndentOrderId == order.IndentOrderId);
                        foreach (var detail in details)
                        {
                            if (detail.State == 5)
                            {
                                count++;
                            }
                        }
                        if (details.Count() == count)//都为已收货时,更新订单主表状态
                        {
                            order.State      = 5;
                            order.ReceivedDT = DateTime.Now;
                        }
                    }
                    var returnIds = list.Where(o => o.OrderReturnId.HasValue).Select(o => o.OrderReturnId).ToList();
                    if (returnIds.Any())//已完成换
                    {
                        var rtns = OrderReturnBLL.FindList(o => returnIds.Contains(o.Id));
                        rtns.Each(o => o.State = 2);
                    }
                    BaseService <OrderDistribution> .Update(list, false);

                    BaseService <IndentOrderList> .Update(detailList, false);

                    op = BaseService <IndentOrder> .Update(orderList);

                    if (op.Successed)
                    {
                        InventoryRecordService.SaveLog(records);
                    }
                    //op = CommodityService.AddRange(commoditys);
                }
            }
            catch (Exception e)
            {
                op.Message = e.Message;
                new Sys.LogEngine().WriteError(e);
            }
            return(op);
        }
Beispiel #7
0
        /// <summary>
        /// 设置入库单为已验状态
        /// </summary>
        /// <param name="Ids"></param>
        /// <returns></returns>
        public static OpResult SetInboundStateToChecked(string Ids)
        {
            var re = new OpResult()
            {
                Successed = false
            };

            try
            {
                var ids   = Ids.Split(',').Select(o => int.Parse(o));
                var goods = BaseService <InboundGoods> .FindList(o => ids.Contains(o.Id));

                var inboundGoodIds = goods.Select(o => o.InboundGoodsId).ToList();
                var list           = BaseService <InboundList> .FindList(o => inboundGoodIds.Contains(o.InboundGoodsId));

                if (goods.Any(o => o.State == 1))
                {
                    var goodChecked = goods.Where(o => o.State == 1).FirstOrDefault();
                    re.Message = string.Format("入库单:{0} 已为已验状态", goodChecked.InboundGoodsId);
                    return(re);
                }
                else
                {
                    goods.ForEach(o => { o.State = 1; o.VerifyTime = DateTime.Now; o.Details = list.Where(i => i.InboundGoodsId == o.InboundGoodsId).ToList(); });
                    list.ForEach(o => { o.State = 1; });
                    #region 更新采购单状态
                    var orderIds = goods.Where(o => o.Source == 1).Select(o => o.IndentOrderId).ToList();
                    var orders   = BaseService <IndentOrder> .FindList(o => orderIds.Contains(o.IndentOrderId));

                    var orderlist = BaseService <IndentOrderList> .FindList(o => orderIds.Contains(o.IndentOrderId));

                    foreach (var good in goods.Where(o => o.Source == 1))
                    {
                        good.Details.ForEach(o =>
                        {
                            var obj = orderlist.FirstOrDefault(i => i.IndentOrderId == good.IndentOrderId && i.Barcode == o.Barcode);
                            if (obj != null && o.InboundNumber >= obj.IndentNum)
                            {
                                obj.State = 5;
                            }
                        });
                        if (!orderlist.Any(i => i.IndentOrderId == good.IndentOrderId && i.State != 5))
                        {
                            var od = orders.FirstOrDefault(o => o.IndentOrderId == good.IndentOrderId);
                            if (od != null)
                            {
                                od.State = 5;
                            }
                        }
                    }
                    #endregion
                    #region 写入库存变化记录
                    //List<Commodity> commodities = new List<Commodity>();
                    var invents = new List <InventoryRecord>();
                    goods.ForEach(o =>
                    {
                        //var tempCommodities = BaseService<Commodity>.FindList(c => c.StockNumber < 0 && c.StoreId == o.StoreId);
                        //var commodityDict = tempCommodities.GroupBy(c => c.Barcode).ToDictionary(c => c.Key, c => c.Sum(p => p.StockNumber));


                        var records = list.Where(p => p.InboundGoodsId == o.InboundGoodsId);
                        foreach (var item in records)
                        {
                            invents.Add(new InventoryRecord()
                            {
                                Barcode = item.Barcode, StoreId = o.StoreId, Number = item.InboundNumber, Source = 1, OperatId = item.InboundGoodsId
                            });
                        }
                    });
                    re = BaseService <InboundGoods> .Update(goods);

                    if (re.Successed)
                    {
                        InventoryRecordService.SaveLog(invents);
                    }

                    #endregion
                }
            }
            catch (Exception ex)
            {
                re.Message = ex.Message;
                Log.WriteError(ex);
            }
            return(re);
        }
        /// <summary>
        /// 操作栏_修改明细表退货状态(及其主表)
        /// </summary>
        /// <param name="id">当前行id</param>
        /// <param name="state">要修改成这个状态</param>
        /// <returns>修改后的列表</returns>
        public static OpResult setState_Editor(int id, short state)
        {
            var re  = OpResult.Fail("操作失败");
            var obj = BaseService <CommodityReturnsDetail> .Find(o => o.Id == id);

            obj.State = state;
            var returnId  = obj.ReturnId;
            var comReturn = CommodityReturnsBLL.Find(o => o.ReturnId == returnId);
            var invents   = new List <InventoryRecord>();

            if (state == 2)
            {//转为已完成
                #region 从商品库中扣除相应库存
                var datas = new Dictionary <string, decimal>();
                datas.Add(obj.Barcode, obj.ReturnNum);
                //判断出库的商品是否有库存记录
                //var stockNums = CommodityService.GetStockNumsByStoreId(comReturn.StoreId);
                //foreach (var d in datas)
                //{
                //    var stockNum = stockNums.FirstOrDefault(o => o.Key == d.Key);
                //    if (stockNum.Value == 0 && string.IsNullOrEmpty(stockNum.Key))
                //    {
                //        re.Message = string.Format("条码:{0} 不存在库存记录,无法退货", d.Key);
                //        return re;
                //    }
                //}
                //扣除库存
                //var updateReusult = CommodityService.OutBoundReduceStock(datas, comReturn.StoreId);
                var pro = ProductService.Find(o => o.Barcode == obj.Barcode || ("," + o.Barcodes + ",").Contains("," + obj.Barcode + ","));
                if (pro != null)
                {
                    invents.Add(new InventoryRecord()
                    {
                        Barcode = pro.Barcode, StoreId = comReturn.StoreId, Number = obj.ReturnNum, Source = 14
                    });
                }
                //var updateReusult = BaseService<CommodityReturnsDetail>.Update(obj);

                ////更新状态
                //if (updateReusult.Successed)
                //{

                //}
                //else
                //{
                //    re.Message = updateReusult.Message;
                //    return re;
                //}
                #endregion
            }

            re = BaseService <CommodityReturnsDetail> .Update(obj);

            var minstate = BaseService <CommodityReturnsDetail> .CurrentRepository.QueryEntity.Where(o => o.ReturnId == returnId).Min(o => o.State);

            //int detailCount = detail.Count();
            //int countState = 0;
            //foreach (var d in detail)
            //{
            //    if (d.State == state)
            //    {
            //        countState = countState + 1;
            //    }
            //}
            //if (countState == detailCount)
            //{
            //    comReturn.State = state;
            //    re = CommodityReturnsBLL.Update(comReturn);
            //}
            comReturn.State = minstate;
            re = CommodityReturnsBLL.Update(comReturn);
            if (re.Successed)
            {
                InventoryRecordService.SaveLog(invents);
            }
            return(re);
        }
        public static OpResult ApprovalPass(string checkBatch)
        {
            var op = new OpResult();
            var tl = BaseService <TreasuryLocks> .Find(o => o.CheckBatch == checkBatch && o.CompanyId == CommonService.CompanyId);

            if (tl.State == 1)
            {
                op.Message = "该批次已审核通过!";
                return(op);
            }
            tl.State = 1;
            var stocks = FindList(o => o.CheckBatch == checkBatch && o.CompanyId == tl.CompanyId);//经过纠正记录

            stocks.Each(o => o.Sure = 1);
            var nvl = new System.Collections.Specialized.NameValueCollection();

            nvl.Add("checkBatch", checkBatch);
            nvl.Add("dispType", "1");//差异则纠正
            nvl.Add("state", "0");
            nvl["rows"] = int.MaxValue.ToString();
            int count = 0;
            var dt    = dal.FindTakeStockPages(nvl, out count).Tables[0];

            var logs = new List <InventoryRecord>();

            if (dt != null && dt.Rows.Count > 0)
            {
                var result    = AutoInventoryBalance();
                var bars      = string.Join(",", dt.AsEnumerable().Select(o => o["Barcode"]));
                var outInNums = dal.FindOutInNumDetails(bars, tl.LockDate, dt.Rows[0]["LockStoreId"].ToString(), CommonService.CompanyId);
                //var barcodes = dt.AsEnumerable().Select(o => o["barcode"].ToString()).ToList();
                //var invents = BaseService<Inventory>.FindList(o => barcodes.Contains(o.Barcode) && o.StoreId == tl.LockStoreID && o.CompanyId == CommonService.CompanyId);
                //var commoditys = dal.GetInventoryBalanceLast(tl.LockStoreID, string.Join(",", barcodes));
                foreach (DataRow dr in dt.Rows)
                {
                    var barcode      = dr["Barcode"].ToString();
                    var actualNumber = dr["ActualNumber"].ToType <decimal>();//盘点数量
                    if (outInNums != null && outInNums.Rows.Count > 0)
                    {
                        var where = string.Format("Barcode='{0}' and StoreId='{1}'", barcode, dr["LockStoreId"]);
                        var drs = outInNums.Select(where);
                        var num = drs.Sum(o => (decimal?)o["Num"]);
                        if (num.HasValue)
                        {
                            actualNumber += num.Value;              //加上盘点之后未审核有库存操作的数量
                        }
                    }
                    //var iy = invents.FirstOrDefault(o => o.Barcode == barcode);
                    //decimal number = 0;
                    //var commd= commoditys.FirstOrDefault(o => o.Barcode == barcode);
                    //if (commd != null) number = commd.Number;
                    //if (iy == null)
                    //{
                    //    iy=new Inventory()
                    //    {
                    //        StoreId = tl.LockStoreID,
                    //        Barcode = barcode,
                    //        StockNumber = actualNumber,
                    //        CompanyId=CommonService.CompanyId
                    //    };
                    //    BaseService<Inventory>.Add(iy, false);
                    //}
                    //else
                    //{
                    //    iy.StockNumber = actualNumber;
                    //}
                    logs.Add(new InventoryRecord()
                    {
                        Barcode   = barcode,
                        CreateDT  = DateTime.Now,
                        CreateUID = Sys.CurrentUser.UID,
                        Number    = actualNumber, //actualNumber - number,
                        StoreId   = tl.LockStoreID,
                        Source    = 15,
                        OperatId  = checkBatch,
                        CompanyId = CommonService.CompanyId
                    });
                }
            }
            op = BaseService <TreasuryLocks> .Update(tl);

            if (op.Successed)
            {
                InventoryRecordService.SaveLog(logs);
                Log.WriteInfo("库存纠正:" + logs.ToJson());
            }
            return(op);
        }