huangxiaoqiang
2025-10-27 387731cab892804912e68cb91e6fb804411c4756
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -31,6 +31,8 @@
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Basic;
using WIDESEA_Model.Models.ERP;
using WIDESEA_OrderRepository;
using WIDESEA_StorageTaskRepository;
using WIDESEAWCS_BasicInfoRepository;
using WIDESEAWCS_QuartzJob.Models;
using static System.Collections.Specialized.BitVector32;
@@ -52,8 +54,6 @@
    private readonly IDt_AreaInfoRepository _areaInfoRepository; //区域
    private readonly IDt_StationManagerRepository _stationManagerRepository;
    private readonly ISys_ConfigService _configService;
    private readonly IDt_OutboundOrderRepository _outorderRepository;
    private readonly IDt_OutboundOrderDetailRepository _outorderdetailRepository;
    public Dt_TaskService(IDt_TaskRepository BaseDal,
                                IUnitOfWorkManage unitOfWorkManage,
@@ -67,9 +67,7 @@
                                IDt_AreaInfoRepository areaInfoRepository,
                                IStockInfoDetailRepository stockInfoDetailRepository,
                                IDt_StationManagerRepository stationManagerRepository,
                                ISys_ConfigService configService,
                                IDt_OutboundOrderRepository outorderRepository,
                                IDt_OutboundOrderDetailRepository outorderdetailRepository) : base(BaseDal)
                                ISys_ConfigService configService) : base(BaseDal)
    {
        _unitOfWorkManage = unitOfWorkManage;
        _stockInfoRepository = stockInfoRepository;
@@ -83,8 +81,6 @@
        _stockInfoDetailRepository = stockInfoDetailRepository;
        _stationManagerRepository = stationManagerRepository;
        _configService = configService;
        _outorderRepository = outorderRepository;
        _outorderdetailRepository = outorderdetailRepository;
    }
    #region å¤–部接口方法
@@ -104,20 +100,77 @@
            taskHty.FinishTime = DateTime.Now;
            taskHty.OperateType = App.User.UserName != null ? (int)OperateTypeEnum.人工完成 : (int)OperateTypeEnum.自动完成;
            taskHty.Creater = App.User.UserName != null ? App.User.UserName : "System";
            //DtStockInfo_Hty stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>();
            //stockInfo_Hty.ModifyDate = DateTime.Now;
            stock.ModifyDate = DateTime.Now;
            stock.LocationCode = task.TargetAddress;
            var result1 = UpdateLocationStatus(locationStart, LocationEnum.Free, task.TaskNum.Value, (int)StatusChangeTypeEnum.AutomaticOutbound);
            var result2 = UpdateLocationStatus(locationEnd, LocationEnum.InStock, task.TaskNum.Value, (int)StatusChangeTypeEnum.AutomaticOutbound);
            DtStockInfo_Hty stockInfo_Hty = null;
            if (task.TaskType != (int)TaskOutboundTypeEnum.Outbound)
            {
                var stockDetailsToRemove = new List<DtStockInfoDetail>();
                // å¤„理库存明细
                if (stock.StockInfoDetails == null || !stock.StockInfoDetails.Any())
                {
                    // å½“库存明细为空时,将整个库存移入历史表
                    stockInfo_Hty = CreateStockInfoHty(stock, null, true);
                }
                else
                {
                    foreach (var item in stock.StockInfoDetails.ToList())
                    {
                        if (item.OutboundQuantity <= 0 || item.OutboundQuantity > item.Quantity)
                        {
                            throw new Exception($"出库数量异常,物料 {item.MaterielCode} çš„出库数量 {item.OutboundQuantity} ä¸åˆæ³•");
                        }
                        if (item.OutboundQuantity == item.Quantity)
                        {
                            // å®Œå…¨å‡ºåº“,移入历史表
                            if (stockInfo_Hty == null)
                            {
                                stockInfo_Hty = CreateStockInfoHty(stock, new List<DtStockInfoDetail> { item }, false);
                            }
                            else
                            {
                                stockInfo_Hty.StockInfoDetails.Add(CreateStockInfoDetailHty(item));
                            }
                            stockDetailsToRemove.Add(item);
                        }
                        else if (item.OutboundQuantity < item.Quantity && item.OutboundQuantity > 0)
                        {
                            // éƒ¨åˆ†å‡ºåº“,更新数量
                            item.Quantity -= item.OutboundQuantity;
                            item.OutboundQuantity = 0; // é‡ç½®å‡ºåº“数量
                        }
                    }
                    // ç§»é™¤å·²å®Œå…¨å‡ºåº“的明细
                    foreach (var item in stockDetailsToRemove)
                    {
                        stock.StockInfoDetails.Remove(item);
                    }
                }
            }
            
            await _unitOfWorkManage.UseTranAsync(async () =>
            {
                //await DeleteStockInfoAsync(stock.Id);
                //await DeleteStockInfoDetailsAsync(stock.StockInfoDetails);
                //await AddStockInfoHtyAsync(stockInfo_Hty);
                _stockInfoRepository.UpdateData(stock);
                // å¦‚果库存明细全部出库完毕,删除原库存记录
                if (stock.StockInfoDetails == null || !stock.StockInfoDetails.Any())
                {
                    await _stockInfoRepository.DeleteDataAsync(stock);
                }
                else
                {
                    _stockInfoRepository.UpdateData(stock);
                }
                // æ·»åŠ åŽ†å²è®°å½•
                if (stockInfo_Hty != null)
                {
                    await AddStockInfoHtyAsync(stockInfo_Hty);
                }
                await _locationStatusChangeRecordRepository.AddDataAsync(result1.Item1);
                await _locationStatusChangeRecordRepository.AddDataAsync(result2.Item1);
                await _locationRepository.UpdateDataAsync(result1.Item2);
@@ -127,6 +180,7 @@
                await AddTaskHtyAsync(taskHty);
            });
            content.OK("出库完成");
        }
        catch (Exception ex)
        {
@@ -135,7 +189,54 @@
        return content;
    }
    private DtStockInfo_Hty CreateStockInfoHty(DtStockInfo stock, List<DtStockInfoDetail> details, bool isFullExit)
    {
        var stockInfoHty = new DtStockInfo_Hty()
        {
            PalletCode = stock.PalletCode,
            LocationCode = stock.LocationCode,
            IsFullExit = isFullExit,
            StockStatus = stock.StockStatus,
            OrderNo = stock.OrderNo,
            OrderType = stock.OrderType,
            Remark = stock.Remark,
            StockInfoDetails = new List<DtStockInfoDetail_Hty>()
        };
        if (details != null)
        {
            foreach (var detail in details)
            {
                stockInfoHty.StockInfoDetails.Add(CreateStockInfoDetailHty(detail));
            }
        }
        return stockInfoHty;
    }
    /// <summary>
    /// åˆ›å»ºåº“存明细历史记录
    /// </summary>
    private DtStockInfoDetail_Hty CreateStockInfoDetailHty(DtStockInfoDetail detail)
    {
        return new DtStockInfoDetail_Hty
        {
            MaterielCode = detail.MaterielCode,
            MaterielName = detail.MaterielName,
            DemandClassification = detail.DemandClassification,
            Warehouse = detail.Warehouse,
            OrderNo = detail.OrderNo,
            Unit = detail.Unit,
            Specs = detail.Specs,
            Weight = detail.Weight,
            Quantity = detail.Quantity,
            OutboundQuantity = detail.OutboundQuantity,
            Status = detail.Status,
            DrawingNumber = detail.DrawingNumber,
            Date = detail.Date,
            Remark = detail.Remark
        };
    }
    #endregion å‡ºåº“任务完成
@@ -195,34 +296,35 @@
        WebResponseContent content = new WebResponseContent();
        try
        {
            var stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == task.PalletCode && x.StockStatus == (int)StockStateEmun.组盘暂存);
            var boxinfo = await _boxingInfoRepository.QueryFirstNavAsync(x => x.PalletCode == task.PalletCode);
            var locationStart = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.SourceAddress);
            var locationEnd = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.TargetAddress);
            if (stock == null)
            if (boxinfo == null)
            {
                return content.Error("未找到组盘数据");
            }
            stock.LocationCode = task.TargetAddress;
            stock.StockStatus = (int)StockStateEmun.已入库;
            var stock = CreateStock(boxinfo, task);
            task.TaskState = (int)TaskInStatusEnum.InFinish;
            var taskHty = task.Adapt<Dt_Task_Hty>();
            taskHty.FinishTime = DateTime.Now;
            taskHty.OperateType = App.User.UserName != null ? (int)OperateTypeEnum.人工完成 : (int)OperateTypeEnum.自动完成;
            taskHty.Creater = App.User.UserName != null ? App.User.UserName : "System";
            var result1 = UpdateLocationStatus(locationStart, LocationEnum.Free, task.TaskNum.Value, (int)StatusChangeTypeEnum.AutomaticInbound);
            var result2 = UpdateLocationStatus(locationEnd, LocationEnum.InStock, task.TaskNum.Value, (int)StatusChangeTypeEnum.AutomaticInbound);
            var result1 = UpdateLocationStatus(task.SourceAddress, LocationEnum.InStockDisable, task.TaskNum.Value, (int)StatusChangeTypeEnum.AutomaticInbound);
            var result2 = UpdateLocationStatus(task.TargetAddress, LocationEnum.Lock, task.TaskNum.Value, (int)StatusChangeTypeEnum.AutomaticInbound);
            await _unitOfWorkManage.UseTranAsync(async () =>
            {
                await _stockInfoRepository.UpdateDataAsync(stock);
                await _stockInfoRepository.AddDataNavAsync(stock);
                await DeleteTaskAsync(task.TaskId);
                await AddTaskHtyAsync(taskHty);
                await _locationStatusChangeRecordRepository.AddDataAsync(result1.Item1);
                await _locationStatusChangeRecordRepository.AddDataAsync(result2.Item1);
                await _locationRepository.UpdateDataAsync(result1.Item2);
                await _locationStatusChangeRecordRepository.AddDataAsync(result1.Item1);
                await _locationRepository.UpdateDataAsync(result2.Item2);
                await _locationRepository.UpdateDataAsync(result1.Item2);
            });
            content.OK("入库完成");
        }
@@ -233,7 +335,21 @@
        return content;
    }
    public DtStockInfo CreateStock(DtBoxingInfo boxingInfo,Dt_Task task)
    {
        var boxDetail = boxingInfo.BoxingInfoDetails.Adapt<List<DtStockInfoDetail>>();
        boxDetail.ForEach(x => { x.Status = (int)StockStateEmun.已入库; });
        return new DtStockInfo()
        {
            PalletCode = task.PalletCode,
            LocationCode = task.TargetAddress,
            CreateDate = DateTime.Now,
            Creater = "system",
            IsFullExit = boxingInfo.IsFullExit,
            StockInfoDetails = boxDetail,
            StockStatus = (int)StockStateEmun.已入库
        };
    }
    #endregion å…¥åº“任务完成
    #region AGV搬运任务完成
@@ -382,8 +498,9 @@
        WebResponseContent content = new WebResponseContent();
        try
        {
            var stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == taskDto.PalletCode && x.StockStatus == (int)StockStateEmun.组盘暂存);
            if (stock == null)
            var boxingInfo = await _boxingInfoRepository.QueryFirstNavAsync(x => x.PalletCode == taskDto.PalletCode && x.StockStatus == (int)StockStateEmun.组盘暂存);
            if (boxingInfo == null)
            {
                return content.Error("托盘信息不存在,请确认托盘已组盘成功");
            }
@@ -471,7 +588,8 @@
                await _locationRepository.UpdateDataAsync(result2.Item2);
                BaseDal.AddData(taskNew);
            });
            return content = await SendWCSTask(taskDTO);
            //return content = await SendWCSTask(taskDTO);
            return content.OK("成功");
        }
        catch (Exception err)
        {
@@ -519,11 +637,11 @@
        Dt_Task taskNew = new Dt_Task();
        if (StartAddress.Floor != location.Floor)
        {
            taskNew = RequestAcrossFloorTask(StartAddress, location, (int)TaskInboundTypeEnum.Inbound, taskDto.PalletCode);
            taskNew = RequestAcrossFloorTask(StartAddress, location, (int)TaskInboundTypeEnum.Inbound, taskDto);
        }
        else
        {
            taskNew = RequestAGVCarryTask(StartAddress, location, (int)TaskInboundTypeEnum.Inbound, taskDto.PalletCode);
            taskNew = RequestAGVCarryTask(StartAddress, location, (int)TaskInboundTypeEnum.Inbound, taskDto);
        }
        return taskNew;
@@ -622,29 +740,80 @@
    #endregion
    #region è¯·æ±‚出库
    public async Task<WebResponseContent> OtherOutBoundTaskAsync(string palletCode)
    public async Task<WebResponseContent> OutBoundTaskAsync(string palletCode)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            DtStockInfo stcok = await _stockInfoRepository.QueryFirstAsync(x => x.PalletCode == palletCode);
            DtStockInfo stcok = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == palletCode);
            if (stcok == null)
            {
                return content.Error("托盘信息不存在,请确认托盘已入库成功");
            }
            if (stcok.LocationInfo.LocationStatus != (int)LocationEnum.InStock)
            {
                return content.Error("请确认库存货位状态是否为有货");
            }
            var task = await BaseDal.QueryFirstAsync(x => x.PalletCode == palletCode);
            if (task != null)
            {
                return content.Error("该托盘已存在任务");
            }
            var location = await _locationRepository.QueryFirstAsync(x => x.LocationCode == stcok.LocationCode);
            if (location.AreaId == 2)
            {
                return content.Error("该托盘库存已在出库缓存区");
            }
            Dt_Task taskNew= await RequestOutboundTaskAsync(new RequestTaskDto { PalletCode = palletCode, AreaId = 2, Position = stcok.LocationCode, TaskType = (int)TaskOutboundTypeEnum.OutOther });
            return content.OK(data: taskNew);
            Dt_Task taskNew = await RequestOutboundTaskAsync(new RequestTaskDto { PalletCode = palletCode, AreaId = 2, Position = stcok.LocationCode, TaskType = (int)TaskOutboundTypeEnum.Outbound });
            var taskDto = CreateListTaskDTO(taskNew);
            var result = GetlcoationState(taskNew, (int)StatusChangeTypeEnum.AutomaticOutbound);
            await _unitOfWorkManage.UseTranAsync(async () =>
            {
                BaseDal.AddData(taskNew);
                _stockInfoRepository.UpdateData(stcok);
                await _locationStatusChangeRecordRepository.AddDataAsync(result.Item1);
                await _locationRepository.UpdateDataAsync(result.Item2);
            });
            return content = await SendWCSTask(taskDto);
        }
        catch (Exception ex)
        {
            return content.Error(ex.Message);
        }
    }
    public (List<DtLocationStatusChangeRecord>,List<DtLocationInfo>) GetlcoationState(Dt_Task task,int StatusChangeTypeEnum)
    {
        List<DtLocationStatusChangeRecord> locationStatusChangeRecords = new List<DtLocationStatusChangeRecord>();
        List<DtLocationInfo> locations = new List<DtLocationInfo>();
        var result1 = UpdateLocationStatus(task.SourceAddress, LocationEnum.InStockDisable, task.TaskNum.Value, StatusChangeTypeEnum);
        var result2 = UpdateLocationStatus(task.TargetAddress, LocationEnum.Lock, task.TaskNum.Value, StatusChangeTypeEnum);
        locationStatusChangeRecords.AddRange(result1.Item1);
        locationStatusChangeRecords.AddRange(result2.Item1);
        locations.AddRange(result1.Item2);
        locations.AddRange(result2.Item2);
        return (locationStatusChangeRecords,locations);
    }
    public (List<DtLocationStatusChangeRecord>, List<DtLocationInfo>) GetlcoationState(List<Dt_Task> tasks, int StatusChangeTypeEnum)
    {
        List<DtLocationStatusChangeRecord> locationStatusChangeRecords = new List<DtLocationStatusChangeRecord>();
        List<DtLocationInfo> locations = new List<DtLocationInfo>();
        foreach (var item in tasks)
        {
            var result1 = UpdateLocationStatus(item.SourceAddress, LocationEnum.InStockDisable, item.TaskNum.Value, StatusChangeTypeEnum);
            var result2 = UpdateLocationStatus(item.TargetAddress, LocationEnum.Lock, item.TaskNum.Value, StatusChangeTypeEnum);
            locationStatusChangeRecords.AddRange(result1.Item1);
            locationStatusChangeRecords.AddRange(result2.Item1);
            locations.AddRange(result1.Item2);
            locations.AddRange(result2.Item2);
        }
        return (locationStatusChangeRecords, locations);
    }
@@ -731,9 +900,9 @@
            Roadway = "SC1",
            TargetAddress = location.LocationCode,
            Dispatchertime = DateTime.Now,
            MaterialNo = "",
            MaterialNo = taskDto.MaterielCode,
            NextAddress = station.stationChildCode,
            OrderNo = null,
            OrderNo = taskDto.OrderNo,
            PalletCode = taskDto.PalletCode,
            SourceAddress = taskDto.Position,
            CurrentAddress = taskDto.Position,
@@ -756,11 +925,11 @@
        Dt_Task taskNew = new Dt_Task();
        if (StartAddress.Floor != location.Floor)
        {
            taskNew = RequestAcrossFloorTask(StartAddress, location, taskDto.TaskType, taskDto.PalletCode);
            taskNew = RequestAcrossFloorTask(StartAddress, location, taskDto.TaskType, taskDto);
        }
        else
        {
            taskNew = RequestAGVCarryTask(StartAddress, location, taskDto.TaskType, taskDto.PalletCode);
            taskNew = RequestAGVCarryTask(StartAddress, location, taskDto.TaskType,  taskDto);
        }
        return taskNew;
@@ -834,7 +1003,7 @@
    #endregion
    #region è¯·æ±‚跨楼层任务
    public Dt_Task RequestAcrossFloorTask(DtLocationInfo StartAddress, DtLocationInfo EndAddress, int TaskType, string palletCode)
    public Dt_Task RequestAcrossFloorTask(DtLocationInfo StartAddress, DtLocationInfo EndAddress, int TaskType,  RequestTaskDto taskDto)
    {
        WebResponseContent content = new WebResponseContent();
@@ -845,10 +1014,10 @@
            Roadway = "AGV",
            TargetAddress = EndAddress.LocationCode,
            Dispatchertime = DateTime.Now,
            MaterialNo = "",
            MaterialNo = taskDto.MaterielCode,
            NextAddress = next.stationChildCode,
            OrderNo = null,
            PalletCode = palletCode,
            OrderNo = taskDto.OrderNo,
            PalletCode = taskDto.PalletCode,
            SourceAddress = StartAddress.LocationCode,
            CurrentAddress = StartAddress.LocationCode,
            TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew,
@@ -865,7 +1034,7 @@
    #endregion
    #region è¯·æ±‚AGV搬运任务
    public Dt_Task RequestAGVCarryTask(DtLocationInfo StartAddress, DtLocationInfo EndAddress, int TaskType, string palletCode)
    public Dt_Task RequestAGVCarryTask(DtLocationInfo StartAddress, DtLocationInfo EndAddress, int TaskType, RequestTaskDto taskDto)
    {
        WebResponseContent content = new WebResponseContent();
@@ -875,10 +1044,10 @@
            Roadway = "AGV",
            TargetAddress = EndAddress.LocationCode,
            Dispatchertime = DateTime.Now,
            MaterialNo = "",
            MaterialNo = taskDto.MaterielCode,
            NextAddress = EndAddress.LocationCode,
            OrderNo = null,
            PalletCode = palletCode,
            OrderNo = taskDto.OrderNo,
            PalletCode = taskDto.PalletCode,
            SourceAddress = StartAddress.LocationCode,
            CurrentAddress = StartAddress.LocationCode,
            TaskState = (int)TaskAGVCarryStatusEnum.CarryNew,
@@ -1159,7 +1328,57 @@
        return wcsBasez + address;
    }
    public async Task<WebResponseContent> SendERPTaskCompletion(string palletCode)
    /// <summary>
    /// ç”Ÿäº§é¢†æ–™
    /// </summary>
    /// <param name="palletCode"></param>
    /// <returns></returns>
    public async Task<WebResponseContent> ERPProduction(string palletCode)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            DtStockInfo stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == palletCode);
            Dt_Task task = await BaseDal.QueryFirstAsync(x => x.PalletCode == palletCode);
            MaterialRequisition allocate = new MaterialRequisition
            {
                context = new Context
                {
                    CultureName = "zh-CN",
                    EntCode = "001",
                    OrgCode = "102",
                    UserCode = "MH0551"
                },
                documentTypeCode = "TransIn002",
                businessDate = DateTime.Now.ToString("yyyy-MM-dd"),
                isApproved = true,
                issueList = new List<issueList>()
                {
                    new issueList
                    {
                        //备料ID
                        PickListID = task.OrderNo,
                        //存储地点
                        WhCode = "204",
                        //领料数量
                        IssueQty = task.OrderNo,
                    }
                }
            };
            return content.OK(data: allocate);
        }
        catch (Exception ex)
        {
            return content.Error(ex.Message);
        }
    }
    /// <summary>
    /// è°ƒæ‹¨
    /// </summary>
    /// <param name="palletCode"></param>
    /// <returns></returns>
    public async Task<WebResponseContent> ERPAllocate(string palletCode)
    {
        WebResponseContent content = new WebResponseContent();
        try
@@ -1178,12 +1397,16 @@
                businessDate = DateTime.Now.ToString("yyyy-MM-dd"),
                isApproved = true,
                transferInList = stock.StockInfoDetails.Select(item => new transferInList
                transferInList = stock.StockInfoDetails.Where(x => x.OutboundQuantity > 0).Select(item => new transferInList
                {
                    //物料编码
                    ItemCode = item.MaterielCode,
                    TransInWHCode = item.Warehouse,
                    TransInQty = item.Quantity,
                    TransOutWHCode = "001",
                    //调入仓库地址
                    TransInWHCode = item.Remark==""? item.Warehouse: item.Remark,
                    //调入数量
                    TransInQty = item.OutboundQuantity,
                    // è°ƒå‡ºä»“库编码
                    TransOutWHCode = "201",
                }).ToList()
            };
            return content.OK(data: allocate);
@@ -1193,7 +1416,126 @@
            return content.Error(ex.Message);
        }
    }
    /// <summary>
    /// æ‚发
    /// </summary>
    /// <param name="palletCode"></param>
    /// <returns></returns>
    public async Task<WebResponseContent> ERPMixedSend(string palletCode)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            DtStockInfo stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == palletCode);
            MixedSend send = new MixedSend
            {
                context = new Context
                {
                    CultureName = "zh-CN",
                    EntCode = "001",
                    OrgCode = "102",
                    UserCode = "MH0551"
                },
                documentTypeCode = "TransIn002",
                businessDate = DateTime.Now.ToString("yyyy-MM-dd"),
                isApproved = true,
                miscShipList = stock.StockInfoDetails.Where(x => x.OutboundQuantity > 0).Select(item => new miscShipList
                {
                    //物料编码
                    ItemCode = item.MaterielCode,
                    //存储地点编号
                    WhCode = item.Warehouse,
                    //杂发数量
                    Qty = item.OutboundQuantity,
                    BenefitDeptCode = "0505",
                }).ToList()
            };
            return content.OK(data: send);
        }
        catch (Exception ex)
        {
            return content.Error(ex.Message);
        }
    }
    /// <summary>
    /// æ‚æ”¶
    /// </summary>
    /// <param name="palletCode"></param>
    /// <returns></returns>
    public async Task<WebResponseContent> ERPMixedReceive(string palletCode)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            DtStockInfo stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == palletCode);
            MixedReceive allocate = new MixedReceive
            {
                context = new Context
                {
                    CultureName = "zh-CN",
                    EntCode = "001",
                    OrgCode = "102",
                    UserCode = "MH0551"
                },
                documentTypeCode = "TransIn002",
                businessDate = DateTime.Now.ToString("yyyy-MM-dd"),
                isApproved = true,
                miscRcvList = stock.StockInfoDetails.Where(x => x.OutboundQuantity > 0).Select(item => new miscRcvList
                {
                    ItemCode = item.MaterielCode,
                    WhCode = item.Warehouse,
                    Qty = item.OutboundQuantity,
                    CostPrice = 0,
                }).ToList()
            };
            return content.OK(data: allocate);
        }
        catch (Exception ex)
        {
            return content.Error(ex.Message);
        }
    }
    /// <summary>
    /// é€€æ–™
    /// </summary>
    /// <param name="palletCode"></param>
    /// <returns></returns>
    public async Task<WebResponseContent> ERPreturnMaterialList(string palletCode)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            DtStockInfo stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == palletCode);
            ReturnMaterials allocate = new ReturnMaterials
            {
                context = new Context
                {
                    CultureName = "zh-CN",
                    EntCode = "001",
                    OrgCode = "102",
                    UserCode = "MH0551"
                },
                documentTypeCode = "TransIn002",
                businessDate = DateTime.Now.ToString("yyyy-MM-dd"),
                isApproved = true,
                returnMaterialList = stock.StockInfoDetails.Select(item => new returnMaterialList
                {
                    PickListID = item.MaterielCode,
                    WhCode = item.Warehouse,
                    RecedeQty = item.OutboundQuantity,
                    RecedeReason = 1,
                }).ToList()
            };
            return content.OK(data: allocate);
        }
        catch (Exception ex)
        {
            return content.Error(ex.Message);
        }
    }
    #endregion