1
huangxiaoqiang
2025-10-24 927ce822017ff8459be84b742d519970ca614096
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -52,8 +52,8 @@
    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;
    private readonly IDt_OtherOutboundOrderRepository _OtheroutorderRepository;
    private readonly IDt_OtherOutboundOrderDetailRepository _OtheroutorderdetailRepository;
    public Dt_TaskService(IDt_TaskRepository BaseDal,
                                IUnitOfWorkManage unitOfWorkManage,
@@ -68,8 +68,8 @@
                                IStockInfoDetailRepository stockInfoDetailRepository,
                                IDt_StationManagerRepository stationManagerRepository,
                                ISys_ConfigService configService,
                                IDt_OutboundOrderRepository outorderRepository,
                                IDt_OutboundOrderDetailRepository outorderdetailRepository) : base(BaseDal)
                                IDt_OtherOutboundOrderRepository OtheroutorderRepository,
                                IDt_OtherOutboundOrderDetailRepository OtheroutorderdetailRepository) : base(BaseDal)
    {
        _unitOfWorkManage = unitOfWorkManage;
        _stockInfoRepository = stockInfoRepository;
@@ -83,8 +83,8 @@
        _stockInfoDetailRepository = stockInfoDetailRepository;
        _stationManagerRepository = stationManagerRepository;
        _configService = configService;
        _outorderRepository = outorderRepository;
        _outorderdetailRepository = outorderdetailRepository;
        _OtheroutorderRepository = OtheroutorderRepository;
        _OtheroutorderdetailRepository = OtheroutorderdetailRepository;
    }
    #region å¤–部接口方法
@@ -519,11 +519,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;
@@ -731,9 +731,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 +756,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 +834,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 +845,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 +865,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 +875,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 +1159,54 @@
        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
                    {
                        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
@@ -1193,7 +1240,123 @@
            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);
            Allocate allocate = new Allocate
            {
                context = new Context
                {
                    CultureName = "zh-CN",
                    EntCode = "001",
                    OrgCode = "102",
                    UserCode = "MH0551"
                },
                documentTypeCode = "TransIn002",
                businessDate = DateTime.Now.ToString("yyyy-MM-dd"),
                isApproved = true,
                transferInList = stock.StockInfoDetails.Select(item => new transferInList
                {
                    ItemCode = item.MaterielCode,
                    TransInWHCode = item.Warehouse,
                    TransInQty = item.Quantity,
                    TransOutWHCode = "001",
                }).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> ERPMixedReceive(string palletCode)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            DtStockInfo stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == palletCode);
            Allocate allocate = new Allocate
            {
                context = new Context
                {
                    CultureName = "zh-CN",
                    EntCode = "001",
                    OrgCode = "102",
                    UserCode = "MH0551"
                },
                documentTypeCode = "TransIn002",
                businessDate = DateTime.Now.ToString("yyyy-MM-dd"),
                isApproved = true,
                transferInList = stock.StockInfoDetails.Select(item => new transferInList
                {
                    ItemCode = item.MaterielCode,
                    TransInWHCode = item.Warehouse,
                    TransInQty = item.Quantity,
                    TransOutWHCode = "001",
                }).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);
            Allocate allocate = new Allocate
            {
                context = new Context
                {
                    CultureName = "zh-CN",
                    EntCode = "001",
                    OrgCode = "102",
                    UserCode = "MH0551"
                },
                documentTypeCode = "TransIn002",
                businessDate = DateTime.Now.ToString("yyyy-MM-dd"),
                isApproved = true,
                transferInList = stock.StockInfoDetails.Select(item => new transferInList
                {
                    ItemCode = item.MaterielCode,
                    TransInWHCode = item.Warehouse,
                    TransInQty = item.Quantity,
                    TransOutWHCode = "001",
                }).ToList()
            };
            return content.OK(data: allocate);
        }
        catch (Exception ex)
        {
            return content.Error(ex.Message);
        }
    }
    #endregion