helongyang
5 天以前 ac8813cde64f7bf9882657416a1d102191aae960
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesProductService.cs
@@ -172,17 +172,18 @@
                newTask.TaskId = taskId;
                Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
                //上传ERP
                //WebResponseContent responseContent = _inboundOrderService.FeedbackProIn(mesProInOrder);
                WebResponseContent responseContent = _inboundOrderService.FeedbackProIn(mesProInOrder);
                _proInStatisticsService.SaveStatic(bagInfoModel);
                //if (!responseContent.Status)
                //{
                //    mesProInOrder.UpErpStatus = WhetherEnum.False.ObjToInt();
                //    mesProInOrder.Remark = responseContent.Message;
                //}
                //else
                //{
                if (!responseContent.Status)
                {
                    //mesProInOrder.UpErpStatus = WhetherEnum.False.ObjToInt();
                    //mesProInOrder.Remark = responseContent.Message;
                    throw new Exception(responseContent.Message);
                }
                else
                {
                    mesProInOrder.UpErpStatus = WhetherEnum.True.ObjToInt();
                //}
                }
                Db.InsertNav(mesProInOrder).Include(x => x.Details).ExecuteCommand();
                _unitOfWorkManage.CommitTran();
                //推送任务
@@ -281,18 +282,19 @@
            };
            
            _unitOfWorkManage.BeginTran();
            Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
            ////上传ERP
            //WebResponseContent responseContent = _inboundOrderService.FeedbackProIn(mesProInOrder);
            //if (!responseContent.Status)
            //{
            //    mesProInOrder.UpErpStatus = WhetherEnum.False.ObjToInt();
            //    mesProInOrder.Remark = responseContent.Message;
            //}
            //else
            //{
            //上传ERP
            WebResponseContent responseContent = _inboundOrderService.FeedbackProIn(mesProInOrder);
            if (!responseContent.Status)
            {
                //mesProInOrder.UpErpStatus = WhetherEnum.False.ObjToInt();
                //mesProInOrder.Remark = responseContent.Message;
                return WebResponseContent.Instance.Error($"{responseContent.Message}");
            }
            else
            {
                mesProInOrder.UpErpStatus = WhetherEnum.True.ObjToInt();
            //}
            }
            Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
            Db.InsertNav(mesProInOrder).Include(x => x.Details).ExecuteCommand();
            _unitOfWorkManage.CommitTran();
            return WebResponseContent.Instance.OK("接收成功");
@@ -529,7 +531,7 @@
            MesResponseContent content = new MesResponseContent();
            try
            {
                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA72.ToString());
                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == model.WarehouseCode);
                if (warehouse == null)
                {
                    return content.Error($"尾数仓信息未配置");
@@ -539,25 +541,68 @@
                {
                    return content.Error($"提库任务单{model.TaskNo}已存在");
                }
                //生成提库单
                Dt_MesRworkOutboundOrder mesRworkOutboundOrder = new Dt_MesRworkOutboundOrder()
                {
                    WarehouseId = warehouse.WarehouseId,
                    TaskNo = model.TaskNo,
                    OrderStatus = OutOrderStatusEnum.未开始.ObjToInt(),
                    OrderStatus = OutOrderStatusEnum.出库中.ObjToInt(),
                    CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(),
                    ProductCode = model.ProductCode,
                    ProductName = model.ProductName,
                    ProductName = model.ProductCode,
                    ProductVersion = model.ProductVersion,
                    DateCode = model.DateCode,
                    RequiredQuantity = model.RequiredQuantity,
                    RequiredSetCount=model.RequiredSetCount,
                    FactoryCode = model.FactoryCode,
                    SaleOrder = model.SaleOrder,
                    SaleOrder = model.SaleOrder ?? "",
                    OrderType = model.InventoryType
                };
                if (model.DateCode.IndexOf("平库")>0 || warehouse.WarehouseCode==WarehouseEnum.HA101.ToString())
                {
                    Dt_Warehouse warehousePing = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString());
                    mesRworkOutboundOrder.WarehouseId = warehousePing.WarehouseId;
                    mesRworkOutboundOrder.OrderStatus = OutOrderStatusEnum.出库完成.ObjToInt();
                    _unitOfWorkManage.BeginTran();
                    _outboundService.RworkOutboundOrderService.Repository.AddData(mesRworkOutboundOrder);
                    MesInventoryInfo mesInventoryInfo = new MesInventoryInfo()
                    {
                        Warhouseno = warehousePing.WarehouseCode,
                        InternalPackageNumber = model.ProductCode,
                        SetCount = (int)model.RequiredSetCount,
                        EligiblePcsCount = (int)model.RequiredQuantity
                    };
                    MesProductOutBound mesProductOutBound = new MesProductOutBound()
                    {
                        TaskNo = mesRworkOutboundOrder.TaskNo,
                        ProductCode = mesRworkOutboundOrder.ProductCode,
                        ProductVersion = mesRworkOutboundOrder.ProductVersion,
                        DateCode = mesRworkOutboundOrder.DateCode,
                        SaleOrder = mesRworkOutboundOrder.SaleOrder,
                        InventoryInfo = new List<MesInventoryInfo> { mesInventoryInfo  }
                    };
                    if (model.ReceiveDown==EnableEnum.Enable.ObjToInt())
                    {
                        _unitOfWorkManage.RollbackTran();
                    }
                    else
                    {
                        //MES成品库存板出库同步
                        WebResponseContent responseContentPing = _outboundService.RworkOutboundOrderService.ProductOutBoundSync(mesProductOutBound);
                        if (!responseContentPing.Status)
                        {
                            throw new Exception("同步MES库存板出库失败,错误:" + responseContentPing.Message);
                        }
                        _unitOfWorkManage.CommitTran();
                    }
                    return content.OK($"提供返库单接收成功,ReceiveDown:{model.ReceiveDown}");
                }
                List<Dt_Task> tasks = new List<Dt_Task>();
                List<Dt_ProStockInfo>? proStockInfos = null;
                List<Dt_OutProStockInfo>? outProStockInfos = null;
                List<Dt_LocationInfo>? locationInfos = null;
                List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>();
                //分配库存生成提库任务
                (List<Dt_ProStockInfo>?, Dt_MesRworkOutboundOrder?, List<Dt_OutProStockInfo>?, List<Dt_LocationInfo>) result = _outboundService.RworkOutboundOrderService.AssignMesStocks(mesRworkOutboundOrder);
                if (result.Item1 != null && result.Item1.Count > 0)
@@ -583,6 +628,10 @@
                    x.TargetAddress = "5236";
                    x.OrderNo = mesRworkOutboundOrder.TaskNo;
                });
                proStockInfos.ForEach(x =>
                {
                    proStockInfoDetails.AddRange(x.proStockInfoDetails);
                });
                _unitOfWorkManage.BeginTran();
                int id = BaseDal.AddData(tasks);
@@ -597,13 +646,25 @@
                    if (!updateContent.Status)
                    {
                        _unitOfWorkManage.RollbackTran();
                        return content.Error(updateContent.Message);
                        throw new Exception(updateContent.Message);
                    }
                }
                _outboundService.RworkOutboundOrderService.Repository.AddData(mesRworkOutboundOrder);
                _unitOfWorkManage.CommitTran();
                return content.OK("提供返库单接收成功");
                if (model.ReceiveDown == EnableEnum.Enable.ObjToInt())
                {
                    _unitOfWorkManage.RollbackTran();
                }
                else
                {
                    //MES成品库存板出库同步
                    WebResponseContent responseContent = _outboundService.RworkOutboundOrderService.ProductOutBoundSync(_outboundService.RworkOutboundOrderService.MesProOutBound(mesRworkOutboundOrder, proStockInfoDetails));
                    if (!responseContent.Status)
                    {
                        throw new Exception("同步MES库存板出库失败,错误:" + responseContent.Message);
                    }
                    _unitOfWorkManage.CommitTran();
                }
                return content.OK($"提供返库单接收成功,ReceiveDown:{model.ReceiveDown}");
            }
            catch (Exception ex)
            {