1
huangxiaoqiang
5 天以前 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;
@@ -776,6 +777,7 @@
            // 更详细的异常处理,可以根据异常类型记录不同的错误日志等
            content.Error(err.Message);
            Console.WriteLine(err.Message);
            LogFactory.GetLog($"请求入库异常").Info(true, $"异常信息【{err.Message}】异常行【{err.StackTrace}】");
        }
        return content;
@@ -976,6 +978,8 @@
        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)
@@ -1738,21 +1742,20 @@
        // 创建历史任务实例模型
        try
        {
            Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(key[0]));
            if (task == null)
            foreach (var item in key)
            {
                return content.Error("未找到任务信息!");
                Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(key));
                if (task == null)
                {
                    return content.Error("未找到任务信息!");
                }
                var taskHtyNG = CreateHistoricalTask(task, true);
                // 添加历史任务
                var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0;
                // 删除任务数据
                var isTaskDelete = BaseDal.Delete(task.TaskId);
            }
            var taskHtyNG = CreateHistoricalTask(task, true);
            // 执行数据库事务
            // 添加历史任务
            var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0;
            // 删除任务数据
            var isTaskDelete = BaseDal.Delete(task.TaskId);
            return content.OK("删除成功!");
        }
        catch (Exception ex)
@@ -1886,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;
    }