刘磊
2024-12-24 e2bb2738c6ddb1d013837924dc639b0f6f63662b
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -1,5 +1,4 @@
using AngleSharp.Io;
using Mapster;
using Mapster;
using Masuit.Tools;
using System.Text.RegularExpressions;
using WIDESEA_Core.Const;
@@ -429,9 +428,10 @@
            if (boxing.ProcessCode == "OCV1")
                area = _areaInfoRepository.QueryFirst(x => x.AreaID == 6);
            else if (boxing.ProcessCode == "OCVB")
                area = _areaInfoRepository.QueryFirst(x => x.AreaID == 7);
            else
                area = _areaInfoRepository.QueryFirst(x => x.AreaID == loation.AreaId);
            if (area == null)
                throw new Exception("未找到对应区域信息");
@@ -454,7 +454,7 @@
            Remark = boxing.BoxingInfoDetails.Count().ToString(),
        };
        if (boxing.ProcessCode != "OCVB")
        if (boxing.ProcessCode != "OCVB" && !task.Roadway.Contains("FR"))
        {
            // 处理请求参数
            AgingInputDto agingInputDto = new AgingInputDto()
@@ -1323,9 +1323,91 @@
    #endregion 指定任务出库
    #region  静置异常口入库
    #region 静置异常口入库
    #endregion
    public async Task<WebResponseContent> CreateAndSendInboundTask(string locationCode, string palletCode, string position)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            // 查询库存信息
            var stockInfo = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == palletCode);
            if (stockInfo == null)
            {
                var area = _areaInfoRepository.QueryFirst(x => x.AreaID == 2);
                var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == position);
                TrayCellsStatusDto trayCells = CreateTrayCellsStatusDto(area, palletCode);
                content = await GetTrayCellStatusAsync(trayCells);
                if (!content.Status) return content;
                var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
                if (!result.Success)
                {
                    if (result.SerialNos.Count <= 0)
                    {
                        var location = await GetLocationDistributeAsync(station.Roadway);
                        // 创建新任务实例
                        var task = new Dt_Task
                        {
                            CurrentAddress = locationCode,
                            Grade = 1,
                            Roadway = station.Roadway,
                            TargetAddress = location.LocationCode,
                            Dispatchertime = DateTime.Now,
                            MaterialNo = "",
                            NextAddress = location.LocationCode,
                            OrderNo = null,
                            PalletCode = palletCode,
                            SourceAddress = locationCode,
                            TaskState = (int)TaskInStatusEnum.Line_InFinish,
                            TaskType = (int)TaskInboundTypeEnum.Inbound,
                            TaskNum = await BaseDal.GetTaskNo(),
                            Creater = "Systeam"
                        };
                        // 创建WMS任务
                        WMSTaskDTO taskDTO = new WMSTaskDTO()
                        {
                            TaskNum = task.TaskNum.Value,
                            Grade = 1,
                            PalletCode = task.PalletCode,
                            RoadWay = task.Roadway,
                            SourceAddress = task.SourceAddress,
                            TargetAddress = task.Roadway,
                            TaskState = task.TaskState.Value,
                            Id = 0,
                            TaskType = task.TaskType,
                        };
                        await _unitOfWorkManage.UseTranAsync(async () =>
                        {
                            // 添加任务到数据库
                            await BaseDal.AddDataAsync(task);
                            // 更新库存位置状态为不可用
                            location.LocationStatus = (int)LocationEnum.InStockDisable;
                            await _locationRepository.UpdateDataAsync(location);
                        });
                        content.OK(data: taskDTO);
                    }
                    else
                        content.Error(result.MOMMessage);
                }
            }
            else
            {
                // TODO质检回库
                var area = _areaInfoRepository.QueryFirst(x => x.AreaID == 2);
            }
        }
        catch (Exception ex)
        {
            content.Error(ex.Message);
        }
        return content;
    }
    #endregion 静置异常口入库
    #endregion 外部接口方法