1
huangxiaoqiang
2025-10-22 d4b0b578752a1478f6c11b352fbb8d2bad1f9e1d
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -23,7 +23,9 @@
using WIDESEA_Core.Enums;
using WIDESEA_DTO.ERP;
using WIDESEA_DTO.Location;
using WIDESEA_DTO.Stock;
using WIDESEA_DTO.WMS;
using WIDESEA_IOrderRepository;
using WIDESEA_IServices;
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Basic;
@@ -49,6 +51,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;
    public Dt_TaskService(IDt_TaskRepository BaseDal,
                                IUnitOfWorkManage unitOfWorkManage,
@@ -62,7 +66,9 @@
                                IDt_AreaInfoRepository areaInfoRepository,
                                IStockInfoDetailRepository stockInfoDetailRepository,
                                IDt_StationManagerRepository stationManagerRepository,
                                ISys_ConfigService configService) : base(BaseDal)
                                ISys_ConfigService configService,
                                IDt_OutboundOrderRepository outorderRepository,
                                IDt_OutboundOrderDetailRepository outorderdetailRepository) : base(BaseDal)
    {
        _unitOfWorkManage = unitOfWorkManage;
        _stockInfoRepository = stockInfoRepository;
@@ -76,6 +82,8 @@
        _stockInfoDetailRepository = stockInfoDetailRepository;
        _stationManagerRepository = stationManagerRepository;
        _configService = configService;
        _outorderRepository = outorderRepository;
        _outorderdetailRepository = outorderdetailRepository;
    }
    #region å¤–部接口方法
@@ -181,18 +189,16 @@
        WebResponseContent content = new WebResponseContent();
        try
        {
            var boxing = await _boxingInfoRepository.QueryFirstNavAsync(x => x.PalletCode == task.PalletCode);
            var stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == task.PalletCode && x.StockStatus == (int)StockStateEmun.组盘暂存);
            var locationStart = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.SourceAddress);
            var locationEnd = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.TargetAddress);
            if (boxing == null)
            if (stock == null)
            {
                return content.Error("未找到组盘数据");
            }
            DtStockInfo stock = CreatePalletStock(task, boxing);
            DtBoxingInfo_Hty boxingInfo_Hty = boxing.Adapt<DtBoxingInfo_Hty>();
            boxingInfo_Hty.ModifyDate = DateTime.Now;
            stock.LocationCode = task.TargetAddress;
            stock.StockStatus = (int)StockStateEmun.已入库;
            task.TaskState = (int)TaskInStatusEnum.InFinish;
            var taskHty = task.Adapt<Dt_Task_Hty>();
@@ -202,15 +208,11 @@
            await _unitOfWorkManage.UseTranAsync(async () =>
            {
                await _stockInfoRepository.AddDataNavAsync(stock);
                await _stockInfoRepository.UpdateDataAsync(stock);
                await DeleteTaskAsync(task.TaskId);
                await AddTaskHtyAsync(taskHty);
                await _boxingInfoRepository.Db.DeleteNav<DtBoxingInfo>(x => x.Id == boxing.Id)
                                        .Include(x => x.BoxingInfoDetails)
                                        .ExecuteCommandAsync();
                UpdateLocationStatus(locationStart, LocationEnum.Free, task.TaskNum.Value, (int)StatusChangeTypeEnum.AutomaticInbound);
                UpdateLocationStatus(locationEnd, LocationEnum.InStock, task.TaskNum.Value, (int)StatusChangeTypeEnum.AutomaticInbound);
                await AddBoxingHtyAsync(boxingInfo_Hty);
            });
            content.OK("入库完成");
        }
@@ -370,8 +372,8 @@
        WebResponseContent content = new WebResponseContent();
        try
        {
            var boxingInfo = await _boxingInfoRepository.QueryFirstNavAsync(x => x.PalletCode == taskDto.PalletCode);
            if (boxingInfo == null)
            var stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == taskDto.PalletCode && x.StockStatus == (int)StockStateEmun.组盘暂存);
            if (stock == null)
            {
                return content.Error("托盘信息不存在,请确认托盘已组盘成功");
            }
@@ -399,7 +401,7 @@
                switch (taskDto.AreaId)
                {
                    case 1:
                        return await InboundStakerArea(taskDto, StartAddress, await GetEmptyLocation("SC1"));
                        return await InboundStakerArea(taskDto, StartAddress);
                    case 2:
                    case 3:
                    case 4:
@@ -418,7 +420,7 @@
                    switch (location.AreaId)
                    {
                        case 1:
                            return await InboundStakerArea(taskDto, StartAddress, location);
                            return await InboundStakerArea(taskDto, StartAddress);
                        case 2:
                        case 3:
                        case 4:
@@ -445,22 +447,18 @@
        }
    }
    public async Task<WebResponseContent> InboundStakerArea(RequestTaskDto taskDto,DtLocationInfo StartAddress, DtLocationInfo location)
    public async Task<WebResponseContent> InboundStakerArea(RequestTaskDto taskDto,DtLocationInfo StartAddress)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            var station = _stationManagerRepository.QueryFirst(x => x.stationType == 1 && x.Roadway == "SC1");
            if (location == null)
            {
                return content.Error("终点区域未找到空闲库位");
            }
            Dt_Task taskNew = new Dt_Task
            {
                Grade = 1,
                Roadway = "SC1",
                TargetAddress = location.LocationCode,
                TargetAddress = "SC1",
                Dispatchertime = DateTime.Now,
                MaterialNo = "",
                NextAddress = station.stationChildCode,
@@ -481,10 +479,8 @@
            BaseDal.AddData(taskNew);
            UpdateLocationStatus(StartAddress, LocationEnum.InStockDisable, taskNew.TaskNum.Value, (int)StatusChangeTypeEnum.AutomaticInbound);
            UpdateLocationStatus(location, LocationEnum.Lock, taskNew.TaskNum.Value, (int)StatusChangeTypeEnum.AutomaticInbound);
            //UpdateLocationStatus(location, LocationEnum.Lock, taskNew.TaskNum.Value, (int)StatusChangeTypeEnum.AutomaticInbound);
            
            //return content.OK();
            return content = await SendWCSTask(taskDTO);
        }
@@ -1850,29 +1846,6 @@
        }
    }
    private DtStockInfo CreatePalletStock(Dt_Task task, DtBoxingInfo boxing)
    {
        var loation = _locationRepository.QueryFirst(x => x.RoadwayNo == task.Roadway && x.LocationCode == task.TargetAddress);
        if (loation == null)
            throw new Exception("未找到对应位置信息");
        var boxDetail = boxing.BoxingInfoDetails.Adapt<List<DtStockInfoDetail>>();
        boxDetail.ForEach(x => { x.Status = (int)StockStateEmun.已入库; });
        var stock = new DtStockInfo()
        {
            PalletCode = task.PalletCode,
            LocationCode = task.TargetAddress,
            CreateDate = DateTime.Now,
            Creater = "system",
            IsFull = boxing.IsFull,
            StockInfoDetails = boxDetail,
        };
        stock.StockStatus = 1;
        return stock;
    }
    #endregion ä»»åŠ¡è¯·æ±‚æ–¹æ³•