ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/StockInfoRepository.cs
@@ -24,7 +24,7 @@
    public class StockInfoRepository : RepositoryBase<Dt_StockInfo>, IStockInfoRepository
    {
        private readonly ILabelMasterRepository _labelMasterRepository;
        public StockInfoRepository(IUnitOfWorkManage unitOfWorkManage,ILabelMasterRepository labelMasterRepository) : base(unitOfWorkManage)
        public StockInfoRepository(IUnitOfWorkManage unitOfWorkManage, ILabelMasterRepository labelMasterRepository) : base(unitOfWorkManage)
        {
            _labelMasterRepository = labelMasterRepository;
        }
@@ -78,14 +78,15 @@
        /// </summary>
        /// <param name="materielCode"></param>
        /// <returns></returns>
        public List<Dt_StockInfo> GetStockInfos(string materielCode,string batchNo)
        public List<Dt_StockInfo> GetStockInfos(string materielCode, string batchNo)
        {
            return Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode&&v.BatchNo==batchNo)).ToList();
            return Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode && v.BatchNo == batchNo)).ToList();
        }
        public List<Dt_StockInfo> GetStockInfos(string materielCode, List<string> locationCodes)
        {
            return Db.Queryable<Dt_StockInfo>().Where(x => locationCodes.Contains(x.LocationCode)).Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode)).ToList();
            //修改只获取已上架状态的库存
            return Db.Queryable<Dt_StockInfo>().Where(x => locationCodes.Contains(x.LocationCode) && x.StockStatus == (int)StockStatusEmun.已上架).Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode)).ToList();
            //ISugarQueryable<Dt_LocationInfo> sugarQueryable = Db.Queryable<Dt_LocationInfo>().Where(x => locationCodes.Contains(x.LocationCode));
@@ -100,6 +101,7 @@
        public List<Dt_StockInfo> GetStockInfosByPalletCodes(List<string> palletCodes)
        {
            return Db.Queryable<Dt_StockInfo>().Where(x => palletCodes.Contains(x.PalletCode)).Includes(x => x.Details).ToList();
        }
@@ -116,9 +118,9 @@
        {
            //ISugarQueryable<string> locationCodes = Db.Queryable<Dt_LocationInfo>().Where(x => x.RoadwayNo == roadwayNo && x.LocationStatus == LocationStatusEnum.Pallet.ObjToInt() && (x.EnalbeStatus == LocationEnalbeStatusEnum.OnlyOut.ObjToInt() || LocationEnalbeStatusEnum.Normal.ObjToInt() == x.EnalbeStatus)).Select(x => x.LocationCode);
            return Db.Queryable<Dt_StockInfo>().Where(x => x.StockStatus == StockStatusEmun.已入库.ObjToInt() && SqlFunc.Subqueryable<Dt_LocationInfo>().Where(v => v.LocationCode == x.LocationCode && v.RoadwayNo == roadwayNo && v.LocationStatus == LocationStatusEnum.Pallet.ObjToInt() && (EnableStatusEnum.Normal.ObjToInt() == v.EnableStatus)).Any()).OrderBy(x => x.ModifyDate).First();
        }
        public Dt_StockInfo GetPalletStockInfo(string roadwayNo,string strayType)
        public Dt_StockInfo GetPalletStockInfo(string roadwayNo, string strayType)
        {
            //ISugarQueryable<string> locationCodes = Db.Queryable<Dt_LocationInfo>().Where(x => x.RoadwayNo == roadwayNo && x.LocationStatus == LocationStatusEnum.Pallet.ObjToInt() && (x.EnalbeStatus == LocationEnalbeStatusEnum.OnlyOut.ObjToInt() || LocationEnalbeStatusEnum.Normal.ObjToInt() == x.EnalbeStatus)).Select(x => x.LocationCode);
            if (strayType == "1")
@@ -159,7 +161,7 @@
                            stockItem.LGORT = "0030";//库位
                            if (labelMaster != null)
                            {
                                if (labelMaster.WH_NUMBER == inventoryQueryRequest.DATA[0].WH_NUMBER && labelMaster.WERKS == inventoryQueryRequest.DATA[0].WH_NUMBER)
                                if (labelMaster.WH_NUMBER == inventoryQueryRequest.DATA[0].WH_NUMBER && labelMaster.WERKS == inventoryQueryRequest.DATA[0].WERKS)
                                {
                                    stockItem.LIFNR = labelMaster.LIFNR;
                                    stockItem.LIKTX = labelMaster.LIKTX;
@@ -168,7 +170,20 @@
                                    stockItem.MATNR = labelMaster.MATNR;
                                    stockItem.MEINS = labelMaster.UNIT;
                                    stockItem.QTY = labelMaster.BOX_QTY;
                                    stockItem.SOBKZ = labelMaster.SOBKZ;
                                    var sobkz = "非限制";
                                    if (labelMaster.SOBKZ == "0")
                                    {
                                        sobkz = "非限制";
                                    }
                                    else if (labelMaster.SOBKZ == "1")
                                    {
                                        sobkz = "冻结";
                                    }
                                    else if (labelMaster.SOBKZ == "2")
                                    {
                                        sobkz = "待质检";
                                    }
                                    stockItem.SOBKZ = sobkz;
                                    stockItem.TPNUM = view.PalletCode;
                                    stockItem.WERKS = labelMaster.WERKS;//工厂
                                    stockItem.WH_NUMBER = labelMaster.WH_NUMBER;//仓库号
@@ -204,18 +219,20 @@
        /// </summary>
        /// <param name="freezeByCustomerResponse"></param>
        /// <returns></returns>
        public freezeByCustomerResponse freezeByCustomer(string  freezeRequeststr)
        public freezeByCustomerResponse freezeByCustomer(string freezeRequeststr)
        {
            freezeByCustomerResponse freezeResponse = new freezeByCustomerResponse();
            try
            {
                freezeByCustomerRequest freezeRequest = JsonConvert.DeserializeObject<freezeByCustomerRequest>(freezeRequeststr);
                if (freezeRequest.WERKS == AppSettings.Configuration["WERKS"] && freezeRequest.WH_NUMBER == AppSettings.Configuration["SYSNO"])
                if (freezeRequest.WERKS == AppSettings.Configuration["WERKS"] && freezeRequest.WH_NUMBER == AppSettings.Configuration["WERKS"])
                {
                    //根据批次和物料号查找对应的托盘号,冻结库存,只有入库成功了,才能被冻结
                    List<Dt_StockInfo> stockInfos = GetStockInfos(freezeRequest.MATNR, freezeRequest.BATCH);
                    if (freezeRequest.FREEZE_TYPE == "00")//00冻结
                    List<Dt_LabelMaster> labelInfos = _labelMasterRepository.QueryData(x => x.MATNR == freezeRequest.MATNR && x.BATCH == freezeRequest.BATCH);
                    if (freezeRequest.YWLX == "00")//00冻结
                    {
                        foreach (var item in stockInfos)
                        {
@@ -225,10 +242,17 @@
                                UpdateData(item);
                            }
                        }
                        foreach (var li in labelInfos)
                        {
                            li.SOBKZ = "1";
                        }
                        _labelMasterRepository.UpdateData(labelInfos);
                        freezeResponse.MSGTY = "S";
                        freezeResponse.MSGTX = "";
                    }
                    else if (freezeRequest.FREEZE_TYPE == "01") //01解冻
                    else if (freezeRequest.YWLX == "01") //01解冻
                    {
                        foreach (var item in stockInfos)
                        {
@@ -238,6 +262,20 @@
                                UpdateData(item);
                            }
                        }
                        foreach (var li in labelInfos)
                        {
                            //if (li.LABEL_STATUS == "01")
                            //{
                            //    li.SOBKZ = "2";
                            //}
                            //else
                            //{
                            li.SOBKZ = "0";
                            //}
                        }
                        _labelMasterRepository.UpdateData(labelInfos);
                        freezeResponse.MSGTY = "S";
                        freezeResponse.MSGTX = "";