wangxinhui
2025-03-07 7d173d42cba04b4243f13c6ce013b04e1be4dc95
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesTaskService.cs
@@ -654,11 +654,14 @@
                //}
                #endregion
                _unitOfWorkManage.BeginTran();
                Db.InsertNav(mesOutboundOrder).Include(x => x.Details).ExecuteCommand();
                _unitOfWorkManage.CommitTran();
                return MesResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                return MesResponseContent.Instance.Error(ex.Message);
            }
@@ -774,6 +777,7 @@
        {
            try
            {
                //一次只发一卷物料入库明细
                foreach (var item in model.MaterialLotInfo)
                {
                    //获取物料信息
@@ -1029,28 +1033,23 @@
                    StockStatus = StockStatusEmun.入库确认.ObjToInt(),
                    proStockInfoDetails = proStockInfoDetails
                };
                //分配货位
                locationInfo = _basicService.LocationInfoService.AssignLocation(locationInfo.RoadwayNo, ((PalletTypeEnum)proStockInfo.PalletType).ObjToInt(), proStockInfo.WarehouseId);
                Dt_Task newTask = new Dt_Task()
                {
                    CurrentAddress = bagInfoModel.WorkCenter,
                    Grade = 0,
                    NextAddress = locationInfo.LocationCode,
                    NextAddress = "",
                    PalletCode = proStockInfo.PalletCode,
                    Roadway = locationInfo.RoadwayNo,
                    SourceAddress = bagInfoModel.WorkCenter,
                    TargetAddress = locationInfo.LocationCode,
                    TargetAddress = "",
                    TaskType = TaskTypeEnum.InProduct.ObjToInt(),
                    TaskStatus = TaskStatusEnum.New.ObjToInt(),
                    WarehouseId = warehouse.WarehouseId,
                    PalletType = proStockInfo.PalletType
                };
                locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt();
                _unitOfWorkManage.BeginTran();
                int taskId = BaseDal.AddData(newTask);
                newTask.TaskId = taskId;
                _basicRepository.LocationInfoRepository.UpdateData(locationInfo);
                Db.InsertNav(mesProInOrder).Include(x => x.Details).ExecuteCommand();
                Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
                _unitOfWorkManage.CommitTran();
@@ -1129,28 +1128,40 @@
        /// <returns></returns>
        public MesResponseContent RworkTask(RworkTaskModel model)
        {
            MesResponseContent content = new MesResponseContent();
            try
            {
                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA72.ToString());
                //获取库存记录
                List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x =>
                  x.WarehouseId == warehouse.WarehouseId &&
                  x.StockStatus == (int)StockStatusEmun.入库完成).Includes(x => x.Details).ToList();
                Dt_StockInfo? stockInfo = stockInfos.FirstOrDefault(x => x.Details.Any(x => x.BatchNo == model.ProductVersion));
                if (stockInfo == null)
                if (warehouse==null)
                {
                    return MesResponseContent.Instance.Error($"尾数仓:{model.ProductVersion}无可用库存");
                    return MesResponseContent.Instance.Error("未找到此仓库");
                }
                Dt_Task exsit2 = Repository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode);
                Dt_MesRworkOutboundOrder mesRworkOutboundOrder = new Dt_MesRworkOutboundOrder()
                {
                    WarehouseId=warehouse.WarehouseId,
                    TaskNo=model.TaskNo,
                    OrderStatus = InOrderStatusEnum.未开始.ObjToInt(),
                    CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(),
                    ProductCode=model.ProductCode,
                    ProductName=model.ProductName,
                    ProductVersion=model.ProductVersion,
                    DateCode=model.DateCode,
                    RequiredQuantity=model.RequiredQuantity,
                    FactoryCode= model.FactoryCode,
                    SaleOrder=model.SaleOrder,
                    InventoryType=model.InventoryType,
                };
                _unitOfWorkManage.BeginTran();
                _outboundService.RworkOutboundOrderService.AddData(mesRworkOutboundOrder);
                _unitOfWorkManage.CommitTran();
                return content.OK("提供返库单接收成功");
            }
            catch (Exception ex)
            {
                throw;
                _unitOfWorkManage.RollbackTran();
                content.Error(ex.Message);
            }
            return MesResponseContent.Instance.OK();
            return content;
        }