1
huangxiaoqiang
6 天以前 ce8f204db035e6fb7147edb4440591502f5c8567
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;
@@ -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);
@@ -777,6 +777,7 @@
            // 更详细的异常处理,可以根据异常类型记录不同的错误日志等
            content.Error(err.Message);
            Console.WriteLine(err.Message);
            LogFactory.GetLog($"请求入库异常").Info(true, $"异常信息【{err.Message}】异常行【{err.StackTrace}】");
        }
        return content;
@@ -905,8 +906,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 +926,7 @@
                }).ToList()
            };
        }
        else
        {
        else {
            _boxingInfoRepository.DeleteData(boxing);
            return new DtBoxingInfo
            {
@@ -934,16 +934,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 +978,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 +1316,7 @@
                }
                else
                {
                    task = CreateTask(stockInfo, "1049-1", taskType);
                    task = CreateTask(stockInfo, "1049-8", taskType);
                }
                
            }
@@ -1740,7 +1742,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 +1750,6 @@
                    return content.Error("未找到任务信息!");
                }
                var taskHtyNG = CreateHistoricalTask(task, true);
                // 执行数据库事务
                // 添加历史任务
                var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0;
@@ -1890,7 +1889,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 +2145,10 @@
            ToAddress = await GetRoadWayAsync(process);
        else
            ToAddress = process[0];
        if(string.IsNullOrEmpty(ToAddress))
        {
            return content.Error("无法获取目标地址");
        }
        // 创建新任务实例
        var task = new Dt_Task
        {