zhanghonglin
2026-03-21 beb0b5d9e1bab1ace04b5860b5ca308b6f913d4f
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -23,6 +23,7 @@
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Basic;
using WIDESEA_Model.Models.Stock;
using WIDESEA_Model.View;
using WIDESEAWCS_DTO.Stock;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models.TaskInfo;
@@ -44,10 +45,12 @@
        private readonly IRepository<Dt_StockInfoDetail> _IStockInfoDetailRepository;
        private readonly IRepository<Dt_StockInfo_hty> _IStockInfohtyRepository;
        private readonly IRepository<Dt_StockInfoDetail_Hty> _IStockInfoDetailHtyRepository;
        private readonly IRepository<Dt_StockInfos> _IStockInfosRepository;
        private readonly IRepository<Dt_FillingOrder> _FillingOrderRepository;
        //WCS婊℃《鍑哄簱淇″彿
        private static bool kk = false;
        public TaskService(IRepository<Dt_Task> BaseDal, ILocationInfoService ILocationInfoService, IRepository<Dt_StockInfoDetail> IStockInfoDetailRepository, IRepository<Dt_StockInfo_hty> IStockInfohtyRepository, IRepository<Dt_StockInfoDetail_Hty> IStockInfoDetailHtyRepository, IRepository<Dt_Outstockinfo> IOutstockinfoService, IStockService IStockService, IRepository<Dt_Warehouse> WarehouseService, IRepository<Dt_Outstockinfo> OutstockinfoRepository, ILocationInfoService LocationInfoService, IRepository<Dt_StockInfo> StockInfoRepository, IRepository<Dt_LocationInfo> LocationInfoRepository, IRepository<Dt_Task_Hty> Task_HtyRepository, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal)
        public TaskService(IRepository<Dt_Task> BaseDal, IRepository<Dt_FillingOrder> FillingOrderRepository, IRepository<Dt_StockInfos> IStockInfosRepository, ILocationInfoService ILocationInfoService, IRepository<Dt_StockInfoDetail> IStockInfoDetailRepository, IRepository<Dt_StockInfo_hty> IStockInfohtyRepository, IRepository<Dt_StockInfoDetail_Hty> IStockInfoDetailHtyRepository, IRepository<Dt_Outstockinfo> IOutstockinfoService, IStockService IStockService, IRepository<Dt_Warehouse> WarehouseService, IRepository<Dt_Outstockinfo> OutstockinfoRepository, ILocationInfoService LocationInfoService, IRepository<Dt_StockInfo> StockInfoRepository, IRepository<Dt_LocationInfo> LocationInfoRepository, IRepository<Dt_Task_Hty> Task_HtyRepository, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal)
        {
            _LocationInfoService = LocationInfoService;
            _unitOfWorkManage = unitOfWorkManage;
@@ -62,6 +65,8 @@
            _IStockInfoDetailRepository = IStockInfoDetailRepository;
            _IStockInfohtyRepository = IStockInfohtyRepository;
            _IStockInfoDetailHtyRepository = IStockInfoDetailHtyRepository;
            _IStockInfosRepository = IStockInfosRepository;
            _FillingOrderRepository = FillingOrderRepository;
        }
        public IRepository<Dt_Task> Repository => BaseDal;
@@ -71,13 +76,8 @@
        public WebResponseContent ceshi()
        {
            WebResponseContent content = new WebResponseContent();
            string mes = AppSettings.Get("MSE");
            if (!string.IsNullOrEmpty(mes))
            {
                string k = "";
                HttpHelper.Get($"{mes}+{k}");
            }
                return content;
            Dt_StockInfos StockInfoss = _IStockInfosRepository.QueryFirst(x => x.Id == 7);
            return content;
        }
@@ -119,70 +119,23 @@
            WebResponseContent content = new WebResponseContent();
            Dt_Task task = new Dt_Task();
            List<Dt_StockInfoDetail> stockInfoDetail = new List<Dt_StockInfoDetail>();
            List<MESSockInfo> MESSocks = new List<MESSockInfo>();
            //List<MESSockInfo> MESSocks = new List<MESSockInfo>();
            string materielDetailedid = stock.MaterialCode1 + DateTime.Now.ToString("mmss").ObjToInt();
            //鍘籑ES鏌ヨ鐗╂枡缂栧彿璇︾粏淇℃伅
            int h = 0;
            string mes = AppSettings.Get("MSE");
            if (!string.IsNullOrEmpty(mes))
            {
                if (stock.MaterialCode1 != null && !stock.MaterialCode1.Equals(""))
                {
                    MESSocks[0] = JsonConvert.DeserializeObject<MESSockInfo>(HttpHelper.Get($"{mes}+{stock.MaterialCode1}"));
                    stockInfoDetail[0].MaterielCode = stock.MaterialCode1;
                }
                if (stock.MaterialCode2 != null && !stock.MaterialCode2.Equals(""))
                {
                    MESSocks[1] = JsonConvert.DeserializeObject<MESSockInfo>(HttpHelper.Get($"{mes}+{stock.MaterialCode2}"));
                    h++;
                    stockInfoDetail[1].MaterielCode = stock.MaterialCode2;
                }
                if (stock.MaterialCode3 != null && !stock.MaterialCode3.Equals(""))
                {
                    MESSocks[2] = JsonConvert.DeserializeObject<MESSockInfo>(HttpHelper.Get($"{mes}+{stock.MaterialCode3}"));
                    h++;
                    stockInfoDetail[2].MaterielCode = stock.MaterialCode3;
                }
                if (stock.MaterialCode4 != null && !stock.MaterialCode4.Equals(""))
                {
                    MESSocks[3] = JsonConvert.DeserializeObject<MESSockInfo>(HttpHelper.Get($"{mes}+{stock.MaterialCode4}"));
                    h++;
                    stockInfoDetail[3].MaterielCode = stock.MaterialCode4;
                }
            }
            //瀛樺偍鐗╂枡缂栧彿璇︾粏淇℃伅
            for(int m = 0; m <= h; m++)
            {
                stockInfoDetail[m].MaterielDetailedid = materielDetailedid;
                stockInfoDetail[m].BarcodeType = MESSocks[m].BarcodeType;
                stockInfoDetail[m].AuxQty = MESSocks[m].AuxQty;
                stockInfoDetail[m].Quantity = MESSocks[m].Quantity;
                stockInfoDetail[m].MaxQty = MESSocks[m].MaxQty;
                stockInfoDetail[m].BarWeight = MESSocks[m].BarWeight;
                stockInfoDetail[m].PackageQty = MESSocks[m].PackageQty;
                stockInfoDetail[m].QuantityIn = MESSocks[m].QuantityIn;
                stockInfoDetail[m].QuantityOut = MESSocks[m].QuantityOut;
                stockInfoDetail[m].Status = MESSocks[m].Status;
                stockInfoDetail[m].Materialld = MESSocks[m].Materialld;
                stockInfoDetail[m].BatchNum = MESSocks[m].BatchNum;
                stockInfoDetail[m].CreateEmpld = MESSocks[m].CreateEmpld;
                stockInfoDetail[m].Taskld = MESSocks[m].Taskld;
                stockInfoDetail[m].TaskSubld = MESSocks[m].TaskSubld;
            }
            //鍖哄垎璐у尯
            int k = 1;
            Dt_Warehouse warehouse = _WarehouseRepository.QueryFirst(x => x.MaterialName == "");
            if (warehouse.MaterialType == (int)WarehouseTypeEnum.Food)
            {
                k = 2;
            }
            else if (warehouse.MaterialType == (int)WarehouseTypeEnum.Industry)
            {
                k = 3;
            }
            //Dt_Warehouse warehouse = _WarehouseRepository.QueryFirst(x => x.MaterialName == "");
            ////鏌ヨ鐗╂枡浜岀淮缂栫爜
            //Dt_FillingOrder FillingOrder = _FillingOrderRepository.QueryFirst(x=>x.BarCode == stock.MaterialCode1);
            //if (warehouse.MaterialType == (int)WarehouseTypeEnum.Food)
            //{
            //    k = 2;
            //}
            //else if (warehouse.MaterialType == (int)WarehouseTypeEnum.Industry)
            //{
            //    k = 3;
            //}
            //鍏ュ簱鍒嗛厤璐т綅
            Dt_LocationInfo locations = _LocationInfoService.AllotLocationInfo(k);
@@ -536,6 +489,10 @@
            Dt_Task task = new Dt_Task();
            //鍑哄簱鍒嗛厤鐗╂枡
            Dt_LocationInfo locations = _LocationInfoService.AllotStock(1);
            if (locations ==null)
            {
                return content;
            }
            locations.LocationStatus = (int)LocationStatusEnum.Lock;
            task.SourceAddress = locations.LocationCode;