wangxinhui
2 天以前 2c889b38311883ceb703c4e0034c798fdaa2e21c
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesTaskService.cs
@@ -100,10 +100,12 @@
                    };
                    string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
                    float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
                    if (MaterielCode != null && Quantity != null)
                    string BatchNo = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo;
                    if (MaterielCode != null && Quantity != null && BatchNo != null)
                    {
                        taskOut.MaterielCode = MaterielCode;
                        taskOut.Quantity = Quantity;
                        taskOut.BatchNo = BatchNo;
                    }
                    stockInfo.StockStatus = (int)StockStatusEmun.出库锁定;
                    LocationStatusEnum locationStatus = (LocationStatusEnum)locationInfo.LocationStatus;
@@ -181,10 +183,12 @@
                    };
                    string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
                    float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
                    if (MaterielCode != null && Quantity != null)
                    string BatchNo = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo;
                    if (MaterielCode != null && Quantity != null && BatchNo != null)
                    {
                        taskOut.MaterielCode = MaterielCode;
                        taskOut.Quantity = Quantity;
                        taskOut.BatchNo = BatchNo;
                    }
                    stockInfo.StockStatus = (int)StockStatusEmun.出库锁定;
                    LocationStatusEnum locationStatus = (LocationStatusEnum)locationInfo.LocationStatus;
@@ -264,10 +268,12 @@
                    };
                    string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
                    float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
                    if (MaterielCode != null && Quantity != null)
                    string BatchNo = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo;
                    if (MaterielCode != null && Quantity != null && BatchNo != null)
                    {
                        taskOut.MaterielCode = MaterielCode;
                        taskOut.Quantity = Quantity;
                        taskOut.BatchNo = BatchNo;
                    }
                    stockInfo.StockStatus = (int)StockStatusEmun.出库锁定;
                    LocationStatusEnum locationStatus = (LocationStatusEnum)locationInfo.LocationStatus;
@@ -333,10 +339,12 @@
                };
                string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
                float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
                if (MaterielCode != null && Quantity != null)
                string BatchNo = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo;
                if (MaterielCode != null && Quantity != null && BatchNo != null)
                {
                    taskIn.MaterielCode = MaterielCode;
                    taskIn.Quantity = Quantity;
                    taskIn.BatchNo = BatchNo;
                }
                //更改库存状态
                stockInfo.StockStatus = StockStatusEmun.退库.ObjToInt();
@@ -517,6 +525,7 @@
        /// <returns></returns>
        public MesResponseContent SubstrateOut(SubstrateOutModel model)
        {
            MesResponseContent content = new MesResponseContent();
            try
            {
                string line = string.Empty;
@@ -531,15 +540,15 @@
                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == line);
                if (warehouse == null)
                {
                    return MesResponseContent.Instance.Error($"仓库基础信息未配置");
                    return content.Error($"仓库基础信息未配置");
                }
                Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == model.MaterialCode);
                if (materielInfo == null)
                {
                    return MesResponseContent.Instance.Error($"未找到该物料信息");
                    return content.Error($"未找到该物料信息");
                }
                //生成MES板料出库单据
                Dt_MesOutboundOrder mesOutboundOrder = new Dt_MesOutboundOrder()
                {
                    CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(),
@@ -555,14 +564,15 @@
                };
                List<Dt_Task> tasks = new List<Dt_Task>();
                List<Dt_StockInfo>? stockInfos = null;
                List<Dt_OutStockLockInfo>? outStockLockInfos = null;
                List<Dt_LocationInfo>? locationInfos = null;
                {
                    //分配库存
                    (List<Dt_StockInfo>, Dt_MesOutboundOrder, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesOutboundOrderService.AssignStockOutbound(mesOutboundOrder);
                    if (result.Item1 != null && result.Item1.Count > 0)
                    {
                        //创建任务
                        tasks = GetTasks(result.Item1, TaskTypeEnum.MesOutbound);
                        result.Item2.OrderStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
                        result.Item3.ForEach(x =>
@@ -596,23 +606,26 @@
                _outboundService.MesOutboundOrderService.Repository.AddData(mesOutboundOrder);
                if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0)
                {
                    WebResponseContent content = _outboundService.MesOutboundOrderService.LockOutboundStockDataUpdate(stockInfos, outStockLockInfos, locationInfos, tasks: tasks);
                    WebResponseContent contentResponse = _outboundService.MesOutboundOrderService.LockOutboundStockDataUpdate(stockInfos, outStockLockInfos, locationInfos, tasks: tasks);
                    if (!content.Status)
                    if (!contentResponse.Status)
                    {
                        _unitOfWorkManage.RollbackTran();
                        return MesResponseContent.Instance.Error(content.Message);
                        return content.Error(contentResponse.Message);
                    }
                }
                _unitOfWorkManage.CommitTran();
                PushTasksToWCS(tasks);
                return MesResponseContent.Instance.OK();
                //将开料分配的库存托盘返回给MES
                content.Content = new
                {
                    VehicleCode = stockInfos?.Select(x => x.PalletCode).ToList()
                };
                return content.OK();
            }
            catch (Exception ex)
            {
                return MesResponseContent.Instance.Error(ex.Message);
                return content.Error(ex.Message);
            }
        }
@@ -1057,10 +1070,12 @@
                };
                string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
                float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
                if (MaterielCode != null && Quantity != null)
                string BatchNo = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo;
                if (MaterielCode != null && Quantity != null && BatchNo != null)
                {
                    newTask.MaterielCode = MaterielCode;
                    newTask.Quantity = Quantity;
                    newTask.BatchNo = BatchNo;
                }
                LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus;
                _unitOfWorkManage.BeginTran();