wangxinhui
2025-11-21 5336bfc54525253a30f1f8238806d3a67f388e14
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs
@@ -25,6 +25,7 @@
using WIDESEA_DTO.MES;
using WIDESEA_DTO.Outbound;
using Microsoft.IdentityModel.Tokens;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
namespace WIDESEA_TaskInfoService
{
@@ -189,7 +190,22 @@
                                x.Status=OutLockStockStatusEnum.出库完成.ObjToInt();
                            });
                            _outboundRepository.OutStockLockInfoRepository.UpdateData(outStockLockInfos);
                            _outboundService.OutLineViewService.SaveLineView(outStockLockInfos);
                            List<Dt_OutStockLockInfo> outStockLockInfosSG = outStockLockInfos.Where(x => x.OrderType == OutOrderTypeEnum.OutSGPick.ObjToInt()).ToList();
                            List<Dt_OutStockLockInfo> outStockLockInfosMES = outStockLockInfos.Where(x => x.OrderType == OutOrderTypeEnum.OutMESPick.ObjToInt()).ToList();
                            if (outStockLockInfosSG !=null && outStockLockInfosSG.Count()>0)
                            {
                                _outboundService.OutLineViewService.SaveLineView(outStockLockInfosSG);
                            }
                            if (outStockLockInfosMES != null && outStockLockInfosMES.Count() > 0)
                            {
                                Dt_AGVStationInfo aGVStationInfo = _basicRepository.AGVStationInfoRepository.QueryFirst(x=>x.AGVStationCode==task.TargetAddress);
                                MESDeliveryModel mESDeliveryModel = MESDeliveryUp(outStockLockInfosMES, aGVStationInfo.MESPointCode);
                                MESResponse response = _invokeMESService.MESDelivery(mESDeliveryModel).DeserializeObject<MESResponse>() ?? throw new Exception("未获取到返回信息");
                                if (!response.Result)
                                {
                                    throw new Exception($"MES配送出发接口调用报错,MES返回信息{DecodeUnicode(response.Msg)}");
                                }
                            }
                        }
                        _basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId);
                        BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.人工完成 : OperateTypeEnum.自动完成);
@@ -207,6 +223,34 @@
                _unitOfWorkManage.RollbackTran();
                return content.Error(ex.Message);
            }
        }
        /// <summary>
        /// é…é€é€è¾¾ä¿¡æ¯
        /// </summary>
        /// <returns></returns>
        public MESDeliveryModel MESDeliveryUp(List<Dt_OutStockLockInfo> outStockLockInfos,string address)
        {
            MESDeliveryModel mESDeliveryModel = new MESDeliveryModel()
            {
                PRO_DispatchPlanMaterialsInfoNew= new List<MESDeliveryInfo>()
            };
            foreach (var item in outStockLockInfos)
            {
                MESDeliveryInfo mESDeliveryInfo = new MESDeliveryInfo()
                {
                    InvItemCode=item.MaterielCode,
                    DispatchPlanMaterialId=item.OrderDetailId,
                    UnitCode=item.Unit,
                    GradeCode="001",
                    MainQuantity=item.AssignQuantity,
                    AssistUnitCode=item.AssistUnit,
                    LocationCode= address,
                    LotNumber=item.BatchNo,
                    MaterialBarCode=item.PalletCode
                };
                mESDeliveryModel.PRO_DispatchPlanMaterialsInfoNew.Add(mESDeliveryInfo);
            }
            return mESDeliveryModel;
        }
        /// <summary>
        /// åº“存数据转出库任务(原料/半成品)
@@ -294,7 +338,9 @@
                            MaterielCode = stockInfo.MaterielCode,
                            RfidCode = stockInfo.RfidCode,
                            Quantity = stockInfo.StockLength,
                            OrderNo= outStockLockInfo.OrderNo
                            OrderNo= outStockLockInfo.OrderNo,
                            DispatchPlanId=outStockLockInfo.OrderDetailId,
                            WorkCentreCode=outStockLockInfo.MakeCode
                        };
                        if (stockInfo.MaterielWide > 0)
                        {
@@ -842,6 +888,8 @@
                    Dt_MakeCenterInfo makeCenterInfo=makeCenterInfos.FirstOrDefault(x => x.MakeCode == item.MakeCode);
                    item.MakeArea = makeCenterInfo.MakeArea;
                    item.WarehouseId = materielInfo.WarehouseId;
                    item.MaterielUnit = materielInfo.MaterielUnit;
                    item.AssistUnitCode = materielInfo.AssistUnitCode;
                }
                
                _unitOfWorkManage.BeginTran();