huangxiaoqiang
2 天以前 c3ed42924f19d383dd643814b754d60b392496d3
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -1,5 +1,6 @@
using Mapster;
using Masuit.Tools;
using SixLabors.Fonts.Tables.AdvancedTypographic;
using SqlSugar;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@@ -616,13 +617,13 @@
        }
        LogFactory.GetLog("任务完成").InfoFormat(true, "验证任务是否存在", JsonConvert.SerializeObject(task));
        if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut)
        {
            return await CompleteInToOutTaskAsync(task);
        }
        // 验证库存是否存在
        var stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == task.PalletCode);
        if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut)
        {
            return await CompleteInToOutTaskAsync(task,stock);
        }
        // 根据任务类型调用相应的完成任务方法
        switch (task.TaskType)
        {
@@ -636,7 +637,6 @@
            case (int)TaskOutboundTypeEnum.OutTray:
            case (int)TaskOutboundTypeEnum.Outbound:
            case (int)TaskOutboundTypeEnum.OutNG:
            case (int)TaskOutboundTypeEnum.OutQuality:
            
                LogFactory.GetLog("任务完成").InfoFormat(true, "出库任务", "");
                return await CompleteStackTaskAsync(task, stock);
@@ -648,7 +648,6 @@
            case (int)TaskRelocationTypeEnum.Relocation:
                return await CompleteTransferTaskAsync(task, stock);
            default:
                return content.Error("任务类型不存在");
        }
@@ -675,6 +674,11 @@
            var stock = await QueryStockInfo(input.PalletCode);
            if (stock != null)
            {
                List<string> strings = new List<string>() { "GW","CW","FR"};
                if (stock.AreaCode.Contains(strings))
                {
                    return content.Error($"托盘【{stock.PalletCode}】存在库存不允许入库");
                }
                Dt_Task taskNew = new Dt_Task
                {
                    Grade = 1,
@@ -777,6 +781,7 @@
            // 更详细的异常处理,可以根据异常类型记录不同的错误日志等
            content.Error(err.Message);
            Console.WriteLine(err.Message);
            LogFactory.GetLog($"请求入库异常").Info(true, $"异常信息【{err.Message}】异常行【{err.StackTrace}】");
        }
        return content;
@@ -905,8 +910,8 @@
    // 获取组盘信息
    private DtBoxingInfo CreateBoxingInfo(ResultTrayCellsStatus result, string palletCode)
    {
        var boxing=_boxingInfoRepository.QueryFirst(x=>x.PalletCode== palletCode);
    {
         var boxing=_boxingInfoRepository.QueryFirst(x=>x.PalletCode == palletCode);
        if (boxing == null)
        {
            return new DtBoxingInfo
@@ -925,8 +930,7 @@
                }).ToList()
            };
        }
        else
        {
        else {
            _boxingInfoRepository.DeleteData(boxing);
            return new DtBoxingInfo
            {
@@ -934,16 +938,17 @@
                IsFull = true,
                ProcessCode = result.ProcessCode,
                ProductionLine = result.ProductionLine,
                BoxingInfoDetails = result.SerialNos.Select(serialNoObj => new DtBoxingInfoDetail
                BoxingInfoDetails = result.SerialNos.Select(seriaINoObj => new DtBoxingInfoDetail
                {
                    SerialNumber = serialNoObj.SerialNo,
                    OrderNo = serialNoObj.PositionNo.ToString(),
                    Status = serialNoObj.SerialNoStatus,
                    SerialNumber = seriaINoObj.SerialNo,
                    OrderNo = seriaINoObj.PositionNo.ToString(),
                    Status = seriaINoObj.SerialNoStatus,
                    MaterielCode = result.BindCode,
                    Remark = result.TrayBarcodePropertys.ToJsonString(),
                }).ToList()
            };
        }
    }
    // 获取工艺申请
@@ -977,11 +982,12 @@
        WebResponseContent content = new WebResponseContent();
        try
        {
            // 记录异常信息并抛出
            LogFactory.GetLog($"{position}请求{productionLine}任务").Info(true, $"{position}-{tag}-{areaCode}-{JsonConvert.SerializeObject(areaCodes)}-{productionLine}");
            // 根据托盘类型查询库存信息
            DtStockInfo stockInfo = tag == (int)TaskOutboundTypeEnum.Outbound
                ? areaCode != "CWSC1" ? await QueryStockInfoForRealTrayAsync(areaCode, areaCodes, productionLine) : await QueryStockInfoForRealTrayCWAsync(areaCodes, productionLine)
                : await QueryStockInfoForEmptyTrayAsync(areaCode, position);
            if (stockInfo == null)
            {
                return content.Error("库存信息不存在");
@@ -1314,7 +1320,7 @@
                }
                else
                {
                    task = CreateTask(stockInfo, "1049-1", taskType);
                    task = CreateTask(stockInfo, "1049-8", taskType);
                }
                
            }
@@ -1740,7 +1746,7 @@
        // 创建历史任务实例模型
        try
        {
            foreach (object item in key)
            foreach (var item in key)
            {
                Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(key));
                if (task == null)
@@ -1748,9 +1754,6 @@
                    return content.Error("未找到任务信息!");
                }
                var taskHtyNG = CreateHistoricalTask(task, true);
                // 执行数据库事务
                // 添加历史任务
                var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0;
@@ -1890,7 +1893,6 @@
        {
            taskHty.Creater = App.User.UserName != null ? App.User.UserName : "System";
        }
        taskHty.TaskState = task.TaskType > 199 ? (int)TaskInStatusEnum.InFinish : (int)TaskOutStatusEnum.OutFinish;
        return taskHty;
    }
@@ -2147,7 +2149,10 @@
            ToAddress = await GetRoadWayAsync(process);
        else
            ToAddress = process[0];
        if(string.IsNullOrEmpty(ToAddress))
        {
            return content.Error("无法获取目标地址");
        }
        // 创建新任务实例
        var task = new Dt_Task
        {