肖洋
2024-12-26 223a7b9cdb5db711ac644bcfdbbbc7c4d2b7f344
优化代码结构和增强功能

更新了 `.gitignore` 文件以排除特定文件,添加了控制台输出的颜色化方法,提升了任务处理的超时时间和用户 token 信息的获取效率。修改了多个服务接口以支持库存数据回填,增强了日志记录方式和错误处理逻辑,简化了任务创建逻辑,并引入了信号量控制并发访问。此外,调整了数据库连接配置并优化了 Vue.js 路由。最后,清理了 `appsettings.json` 文件以提高可读性。
已删除1个文件
已修改17个文件
836 ■■■■ 文件已修改
.gitignore 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Helper/ConsoleHelper.cs 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs 51 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSClient/src/api/http.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSClient/src/components/basic/ViewGrid/ViewGrid.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSClient/src/router/tables.js 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/IRepository.cs 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/SqlSugarHelper.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/HostedService/SeedDataHostedService.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/ProcessApply/IProcessApplyService.cs 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs 175 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs 438 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Integration/ProcessApplyController.cs 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -1591,3 +1591,5 @@
/Code Management/.vs/Code Management/v17/workspaceFileList.bin
/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json
/Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/copilot-chat/bef6627e/sessions/0fd52b0d-b36f-4668-871f-5e1c1d23e2e3
/Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/copilot-chat/bef6627e/sessions/82695646-a5cf-44a5-803d-fe8b5ff11fef
/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Helper/ConsoleHelper.cs
@@ -27,6 +27,22 @@
        }
        /// <summary>
        /// åœ¨æŽ§åˆ¶å°è¾“出
        /// </summary>
        /// <param name="str">文本</param>
        /// <param name="color">前颜色</param>
        public static void WriteColorLine(object str, ConsoleColor color)
        {
            lock (_objLock)
            {
                ConsoleColor currentForeColor = Console.ForegroundColor;
                Console.ForegroundColor = color;
                Console.WriteLine(str);
                Console.ForegroundColor = currentForeColor;
            }
        }
        /// <summary>
        /// æ‰“印错误信息
        /// </summary>
        /// <param name="str">待打印的字符串</param>
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs
@@ -396,22 +396,22 @@
                            switch (typeCode)
                            {
                                case TypeCode.Boolean:
                                    operateResult = Communicator.Wait(devicePro.DeviceProAddress, 500, 10 * 6000, Convert.ToBoolean(deviceProtocolDetail.ProtocalDetailValue));
                                    operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToBoolean(deviceProtocolDetail.ProtocalDetailValue));
                                    break;
                                case TypeCode.Byte:
                                    operateResult = Communicator.Wait(devicePro.DeviceProAddress, 500, 10 * 6000, Convert.ToByte(deviceProtocolDetail.ProtocalDetailValue));
                                    operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToByte(deviceProtocolDetail.ProtocalDetailValue));
                                    break;
                                case TypeCode.Int16:
                                    operateResult = Communicator.Wait(devicePro.DeviceProAddress, 500, 10 * 6000, Convert.ToInt16(deviceProtocolDetail.ProtocalDetailValue));
                                    operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToInt16(deviceProtocolDetail.ProtocalDetailValue));
                                    break;
                                case TypeCode.Int32:
                                    operateResult = Communicator.Wait(devicePro.DeviceProAddress, 500, 10 * 6000, Convert.ToInt32(deviceProtocolDetail.ProtocalDetailValue));
                                    operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToInt32(deviceProtocolDetail.ProtocalDetailValue));
                                    break;
                                case TypeCode.UInt16:
                                    operateResult = Communicator.Wait(devicePro.DeviceProAddress, 500, 10 * 6000, Convert.ToUInt16(deviceProtocolDetail.ProtocalDetailValue));
                                    operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToUInt16(deviceProtocolDetail.ProtocalDetailValue));
                                    break;
                                case TypeCode.UInt32:
                                    operateResult = Communicator.Wait(devicePro.DeviceProAddress, 500, 10 * 6000, Convert.ToUInt32(deviceProtocolDetail.ProtocalDetailValue));
                                    operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToUInt32(deviceProtocolDetail.ProtocalDetailValue));
                                    break;
                                default:
                                    break;
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -101,7 +101,7 @@
                                    // è¾“出警告信息
                                    ConsoleHelper.WriteWarningLine($"【{conveyorLine.DeviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{station.stationChildCode}】空托盘请求扫码入库");
                                    // å¤„理入库请求
                                    NGRequestTaskInbound(conveyorLine, command, station.stationChildCode, 0, station.stationLocation);
                                    NGRequestTaskInbound(conveyorLine, command, station, 0);
                                }
                                else
                                {
@@ -162,26 +162,12 @@
                    #region è°ƒç”¨äº‹ä»¶æ€»çº¿é€šçŸ¥å‰ç«¯
                    // èŽ·å–ç¼“å­˜ä¸­çš„ç”¨æˆ·ä¿¡æ¯
                    if (userTokenIds == null && userIds == null)
                    var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken");
                    if (tokenInfos != null && tokenInfos.Any())
                    {
                        var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken");
                        if (tokenInfos != null && tokenInfos.Any())
                        {
                            userTokenIds = tokenInfos.Select(x => x.Token_ID).ToList();
                            userIds = tokenInfos.Select(x => x.UserId).ToList();
                        userTokenIds = tokenInfos.Select(x => x.Token_ID).ToList();
                        userIds = tokenInfos.Select(x => x.UserId).ToList();
                            // æž„造通知数据
                            object obj = new
                            {
                                command,
                                commandWrite
                            };
                            // å‘送通知
                            _noticeService.LineData(userIds.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, childDeviceCode, data = obj });
                        }
                    }
                    else
                    {
                        // æž„造通知数据
                        object obj = new
                        {
@@ -726,7 +712,7 @@
        #region è®¾å¤‡NG口入库
        public void NGRequestTaskInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue, string TargetAddress)
        public void NGRequestTaskInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, Dt_StationManager stationManager, int ProtocalDetailValue)
        {
            var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
            var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.MOMIP_BASE)?.ConfigValue;
@@ -735,7 +721,6 @@
            {
                throw new InvalidOperationException("MOM IP æœªé…ç½®");
            }
            Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode);
            TrayCellsStatusDto trayCells = new TrayCellsStatusDto()
            {
                Software = "WMS",
@@ -750,9 +735,9 @@
            var MOMIpAddress = wmsBase + ipAddress;
            var result = HttpHelper.PostAsync(MOMIpAddress, trayCells.ToJsonString()).Result;
            WriteInfo("入站校验", $"【{childDeviceCode}】入站校验请求参数【{trayCells.ToJsonString()}】");
            WriteInfo("入站校验", $"【{stationManager.stationChildCode}】入站校验请求参数【{trayCells.ToJsonString()}】");
            WriteInfo("入站校验", "");
            WriteInfo("入站校验", $"【{childDeviceCode}】入站校验返回参数【{result}】");
            WriteInfo("入站校验", $"【{stationManager.stationChildCode}】入站校验返回参数【{result}】");
            ResultTrayCellsStatus result1 = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(result);
            if (result1.Success)
@@ -765,28 +750,16 @@
                if (result1.SerialNos.Count <= 0)
                {
                    // ç©ºæ‰˜ç›˜å…¥åº“逻辑
                    Dt_Task dt_Task = new Dt_Task()
                    {
                        TargetAddress = TargetAddress,
                        PalletCode = command.Barcode,
                        NextAddress = TargetAddress,
                        TaskNum = 0
                    };
                    var next = dt_Task.NextAddress;
                    var taskCommand = MapTaskCommand(dt_Task, command);
                    dt_Task.NextAddress = next;
                    conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, stationManager.stationLocation, stationManager.stationChildCode);
                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
                    ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                    ConveyorLineSendFinish(conveyorLine, stationManager.stationChildCode, ProtocalDetailValue, true);
                }
                else
                {
                    conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, 1000, childDeviceCode);
                    conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, 1000, stationManager.stationChildCode);
                    ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                    ConveyorLineSendFinish(conveyorLine, stationManager.stationChildCode, ProtocalDetailValue, true);
                }
            }
            else
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -1,6 +1,8 @@
using Mapster;
using Newtonsoft.Json;
using Quartz;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using WIDESEAWCS_BasicInfoRepository;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core.Caches;
@@ -78,11 +80,31 @@
                                StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
                                if (stackerCraneTaskCommand != null)
                                {
                                    bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
                                    if (sendFlag)
                                    var taskNum = commonStackerCrane.GetValue<StackerCraneDBName, int>(StackerCraneDBName.TaskNum);
                                    var taskBarCode = commonStackerCrane.GetValue<StackerCraneDBName, string>(StackerCraneDBName.Barcode);
                                    ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】堆垛机任务号:【{taskNum}】,堆垛机托盘号:【{taskBarCode}】,任务任务号:【{task.TaskNum}】任务托盘号:【{task.PalletCode}】", ConsoleColor.DarkBlue);
                                    if (taskNum == 0 && taskBarCode != task.PalletCode)
                                    {
                                        commonStackerCrane.LastTaskType = task.TaskType;
                                        _taskService.UpdateTaskStatusToNext(task.TaskNum);
                                        ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】任务号为【{0}】,托盘号不一致可以下发任务", ConsoleColor.DarkBlue);
                                        bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
                                        if (sendFlag)
                                        {
                                            StringBuilder builder = new StringBuilder();
                                            builder.AppendLine();
                                            builder.AppendLine($"【{commonStackerCrane.DeviceName}】堆垛机状态:【{commonStackerCrane.StackerCraneStatusDes}】,时间:【{DateTime.Now}】");
                                            builder.AppendLine($"【{commonStackerCrane.DeviceName}】手自动状态:【{commonStackerCrane.StackerCraneAutoStatusDes}】,时间:【{DateTime.Now}】");
                                            builder.AppendLine($"【{commonStackerCrane.DeviceName}】作业状态:【{commonStackerCrane.StackerCraneWorkStatusDes}】,时间:【{DateTime.Now}】");
                                            builder.AppendLine($"【{commonStackerCrane.DeviceName}】下发任务成功,【{JsonConvert.SerializeObject(stackerCraneTaskCommand, Formatting.Indented)}】");
                                            builder.AppendLine($"时间:【{DateTime.Now}】");
                                            builder.AppendLine();
                                            ConsoleHelper.WriteColorLine(builder, ConsoleColor.Blue);
                                            commonStackerCrane.LastTaskType = task.TaskType;
                                            _taskService.UpdateTaskStatusToNext(task.TaskNum);
                                        }
                                    }
                                    else
                                    {
                                        ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】任务号不为【{0}】,或者托盘号一致不可以下发任务", ConsoleColor.DarkBlue);
                                    }
                                }
                            }
@@ -133,8 +155,7 @@
            CommonStackerCrane? commonStackerCrane = sender as CommonStackerCrane;
            if (commonStackerCrane != null)
            {
                //var x = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType);
                //if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5)
                if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5)
                {
                    //Console.Out.WriteLine("TaskCompleted" + e.TaskNum);
                    ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】任务完成,任务号:【{e.TaskNum}】", ConsoleColor.Blue);
Code Management/WMS/WIDESEA_WMSClient/src/api/http.js
@@ -11,8 +11,8 @@
let loadingInstance
let loadingStatus = false
if (process.env.NODE_ENV == 'development') {
  axios.defaults.baseURL = 'http://localhost:5000/';
  // axios.defaults.baseURL = 'http://192.168.5.251:5000/';
  // axios.defaults.baseURL = 'http://localhost:5000/';
  axios.defaults.baseURL = 'http://192.168.5.251:5000/';
}
else if (process.env.NODE_ENV == 'debug') {
  axios.defaults.baseURL = 'http://127.0.0.1:9991/';
Code Management/WMS/WIDESEA_WMSClient/src/components/basic/ViewGrid/ViewGrid.vue
@@ -329,7 +329,7 @@
      //需要从远程绑定数据源的字典编号,如果字典数据源的查询结果较多,请在onInit中将字典编号添加进来
      //只对自定sql有效
      remoteKeys: [],
      columnIndex: false, //2020.11.01是否显示行号
      columnIndex: true, //2020.11.01是否显示行号
      ck: true, //2020.11.01是否显示checkbox
      continueAdd: false, //2021.04.11新建时是否可以连续新建操作
      continueAddName: '保存后继续添加', //2021.04.11按钮名称
Code Management/WMS/WIDESEA_WMSClient/src/router/tables.js
@@ -4,7 +4,7 @@
    name: 'Dt_AreaInfo',
    component: () => import('@/views/widesea_wms/basicinfo/Dt_AreaInfo.vue'),
    meta: {
      keepAlive: false
      keepAlive: true
    }
  },
  {
@@ -44,7 +44,7 @@
    name: 'Dt_LocationInfo',
    component: () => import('@/views/widesea_wms/basicinfo/Dt_LocationInfo.vue'),
    meta: {
      keepAlive: false
      keepAlive: true
    }
  },
  {
@@ -140,14 +140,14 @@
    name: 'Dt_Task',
    component: () => import('@/views/widesea_wms/taskinfo/Dt_Task.vue'),
    meta: {
      keepAlive: false
      keepAlive: true
    }
  },{
    path: '/Dt_Task_Hty',
    name: 'Dt_Task_Hty',
    component: () => import('@/views/widesea_wms/taskinfo/Dt_Task_Hty.vue'),
    meta: {
      keepAlive: false
      keepAlive: true
    }
  },
  // {
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs
@@ -78,12 +78,23 @@
    private static void LogRequestParameters(Dictionary<string, object> parameters,string url = "")
    {
        LogFactory.GetLog("API接口").Info(true, "url:" + url + "请求参数: " + JsonConvert.SerializeObject(parameters));
        StringBuilder builder = new StringBuilder();
        builder.Append(Environment.NewLine);
        builder.Append("---------------------------------------------");
        builder.Append(Environment.NewLine);
        builder.Append("url:" + url + "请求参数: " + JsonConvert.SerializeObject(parameters));
        LogFactory.GetLog("API接口").Info(true, builder);
    }
    private static void LogResponseParameters(string responseBody, string url = "")
    {
        LogFactory.GetLog("API接口").Info(true, "url:" + url + "响应参数: " + responseBody);
        StringBuilder builder = new StringBuilder();
        builder.Append(Environment.NewLine);
        builder.Append("url:" + url + "响应参数: " + responseBody);
        builder.Append(Environment.NewLine);
        builder.Append("---------------------------------------------");
        builder.Append(Environment.NewLine);
        LogFactory.GetLog("API接口").Info(true, builder);
    }
    private static IEnumerable<KeyValuePair<string, string>> ConvertToKeyValuePairs(Dictionary<string, object> parameters)
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/IRepository.cs
@@ -124,6 +124,20 @@
        Task<bool> UpdateDataAsync(List<TEntity> listEntity);
        /// <summary>
        /// å¯¼èˆªæ›´æ–°æ•°æ®(只支持2级)
        /// </summary>
        /// <param name="Entity"></param>
        /// <returns></returns>
        Task<bool> UpdateDataNavAsync(TEntity Entity);
        /// <summary>
        /// å¯¼èˆªæ›´æ–°æ•°æ®(只支持2级)
        /// </summary>
        /// <param name="Entity"></param>
        /// <returns></returns>
        bool UpdateDataNav(TEntity Entity);
        /// <summary>
        /// æŒ‡å®šåˆ—更新数据
        /// </summary>
        /// <param name="entity"></param>
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs
@@ -880,6 +880,16 @@
            return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).ToList();
        }
        public Task<bool> UpdateDataNavAsync(TEntity Entity)
        {
            return _db.UpdateNav(Entity).IncludesAllFirstLayer().ExecuteCommandAsync();
        }
        public bool UpdateDataNav(TEntity Entity)
        {
            return _db.UpdateNav(Entity).IncludesAllFirstLayer().ExecuteCommand();
        }
        //List<TResult> QueryMuch<T, T2, T3, TResult>(
        //    Expression<Func<T, T2, T3, object[]>> joinExpression,
        //    Expression<Func<T, T2, T3, TResult>> selectExpression,
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/SqlSugarHelper.cs
@@ -4,6 +4,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core.Seed;
namespace WIDESEA_Core.Helper
{
@@ -15,7 +16,7 @@
        //用单例模式
        public static SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig()
        {
            ConnectionString = "Data Source=.;Initial Catalog=WIDESEAWCS_TEST;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",//连接符字串
            ConnectionString = DBContext.GetMainConnectionDb().Connection,
            DbType = DbType.SqlServer,//数据库类型
            IsAutoCloseConnection = true //不设成true要手动close
        },
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/HostedService/SeedDataHostedService.cs
@@ -49,7 +49,7 @@
                {
                    // ä½¿ç”¨ myScopedService æ‰§è¡Œä»»åŠ¡
                    //await DBSeed.SeedAsync(_dbContext, _webRootPath);
                    await DBSeed.SeedAsync(_dbContext, _webRootPath);
                    //多租户 åŒæ­¥
                    //await DBSeed.TenantSeedAsync(_dbContext);
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/ProcessApply/IProcessApplyService.cs
@@ -11,4 +11,12 @@
public interface IProcessApplyService : IDependency
{
    Task<WebResponseContent> GetProcessApplyAsync(ProcessApplyDto input);
    /// <summary>
    /// è¡¥å½•入库数据
    /// </summary>
    /// <param name="palletCode">托盘号</param>
    /// <param name="areaID">区域主键</param>
    /// <returns></returns>
    Task<WebResponseContent> StockInDataBackfillInterfaceAsync(string palletCode, int areaID);
}
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs
@@ -4,10 +4,15 @@
using WIDESEA_Common;
using WIDESEA_Core;
using WIDESEA_Core.Const;
using WIDESEA_Core.Helper;
using WIDESEA_DTO;
using WIDESEA_DTO.MOM;
using WIDESEA_IBusinessesRepository;
using WIDESEA_IServices;
using WIDESEA_IStorageBasicRepository;
using WIDESEA_IStorageTaskRepository;
using WIDESEA_IStoragIntegrationServices;
using WIDESEA_Model.Models;
namespace WIDESEA_StoragIntegrationServices;
@@ -15,10 +20,18 @@
{
    private readonly LogFactory LogFactory = new LogFactory();
    private readonly ISys_ConfigService _configService;
    private readonly IDt_AreaInfoRepository _areaInfoRepository;
    private readonly ICellStateService _cellStateService;
    private readonly IStockInfoRepository _stockInfoRepository;
    private readonly IAgingInOrOutInputService _gingInOrOutInputService;
    public ProcessApplyService(ISys_ConfigService configRepository)
    public ProcessApplyService(ISys_ConfigService configRepository, IDt_AreaInfoRepository areaInfoRepository, ICellStateService cellStateService, IDt_TaskRepository taskRepository, IStockInfoRepository stockInfoRepository, IAgingInOrOutInputService gingInOrOutInputService)
    {
        _configService = configRepository;
        _areaInfoRepository = areaInfoRepository;
        _cellStateService = cellStateService;
        _stockInfoRepository = stockInfoRepository;
        _gingInOrOutInputService = gingInOrOutInputService;
    }
    /// <summary>
@@ -62,4 +75,164 @@
        }
        return content;
    }
    /// <summary>
    /// è¡¥å½•出库数据
    /// </summary>
    /// <param name="palletCode"></param>
    /// <returns></returns>
    public async Task<WebResponseContent> StockOutDataBackfillInterfaceAsync(string palletCode, int areaID)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            var area = _areaInfoRepository.QueryFirst(x => x.AreaID == areaID);
            var trayCells = new TrayCellsStatusDto()
            {
                Software = area.Spare3,
                TrayBarcode = palletCode,
                EquipmentCode = area.Spare2,
                SceneType = area.Spare4
            };
            content = await _cellStateService.GetTrayCellStatusAsync(trayCells);
            if (!content.Status) return content;
            var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
            if (result.SerialNos.Count > 0)
            {
                var stockHty = await SqlSugarHelper.Db.Queryable<DtStockInfo>().IncludesAllFirstLayer().FirstAsync();
                if (stockHty != null)
                {
                    var parameterInfo = JsonConvert.DeserializeObject<List<ParameterInfo>>(stockHty.ParameterInfos).FirstOrDefault(y => y.Description.Contains("时间"));
                    if (parameterInfo == null) throw new Exception("");
                    var outHours = (DateTime.Now - (stockHty.LinedProcessFeedbackTime == null ? stockHty.ModifyDate.Value : stockHty.LinedProcessFeedbackTime.ToDateTime())).TotalHours;
                    var isNG = outHours > parameterInfo.LowerSpecificationsLimit.ToDouble() && outHours < parameterInfo.UpperSpecificationsLimit.ToDouble();
                    var defectCode = string.Empty;
                    if (!isNG) defectCode = "TQCK";
                    var outputDto = new AgingOutputDto
                    {
                        OpFlag = 1,
                        Software = area.Spare3,
                        EquipmentCode = area.Spare2,
                        TrayBarcode = palletCode,
                        SerialNos = result.SerialNos.Select(x => new SerialNoOutDto
                        {
                            SlotNo = x.PositionNo,
                            SerialNo = x.SerialNo,
                            SerialNoResult = true, //isNG,
                            ParameterInfo = new List<ParameterInfoOutput> {
                                new ParameterInfoOutput() {
                                    Value = outHours.ToString(),
                                    ParameterCode =parameterInfo.ParameterCode,
                                    ParameterDesc = parameterInfo.Description,
                                    ParameterResult  = "OK", //isNG.ToString(),
                                    TargetValue = parameterInfo.TargetValue,
                                    LowerLomit = parameterInfo.LowerSpecificationsLimit,
                                    UpperLimit = parameterInfo.UpperSpecificationsLimit,
                                    DefectCode = defectCode,
                                    UOMCode = parameterInfo.UOMCode,
                                }
                            }
                        }).ToList()
                    };
                    content = await _gingInOrOutInputService.GetOCVOutputAsync(outputDto);
                }
            }
            else
            {
                content.Error("电芯数据为空");
            }
        }
        catch (Exception ex)
        {
        }
        return content;
    }
    /// <summary>
    /// è¡¥å½•入库数据
    /// </summary>
    /// <param name="palletCode"></param>
    /// <param name="areaID"></param>
    /// <returns></returns>
    public async Task<WebResponseContent> StockInDataBackfillInterfaceAsync(string palletCode, int areaID)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            var area = _areaInfoRepository.QueryFirst(x => x.AreaID == areaID);
            var trayCells = new TrayCellsStatusDto()
            {
                Software = area.Spare3,
                TrayBarcode = palletCode,
                EquipmentCode = area.Spare2,
                SceneType = area.Spare4
            };
            content = await _cellStateService.GetTrayCellStatusAsync(trayCells);
            if (!content.Status) return content;
            var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
            if (result.SerialNos.Count > 0 && result.Success)
            {
                var stockInfo = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == palletCode);
                if (stockInfo != null)
                {
                    stockInfo.IsFull = true;
                    stockInfo.StockInfoDetails = result.SerialNos.Select(serialNoObj => new DtStockInfoDetail
                    {
                        SerialNumber = serialNoObj.SerialNo,
                        OrderNo = serialNoObj.PositionNo.ToString(),
                        Status = serialNoObj.SerialNoStatus,
                        MaterielCode = result.BindCode,
                        Remark = result.TrayBarcodePropertys.ToJsonString(),
                    }).ToList();
                    stockInfo.Remark = stockInfo.StockInfoDetails.Count().ToString();
                    // å¤„理请求参数
                    AgingInputDto agingInputDto = new AgingInputDto()
                    {
                        SerialNos = stockInfo.StockInfoDetails
                            .Select(item => new SerialNoInDto { SerialNo = item.SerialNumber, PositionNo = item.OrderNo })
                            .ToList(),
                        TrayBarcode = palletCode,
                        OpFlag = 1,
                        EquipmentCode = area.Spare2,
                        Software = area.Spare3
                    };
                    content = _gingInOrOutInputService.GetOCVInputAsync(agingInputDto).Result;
                    var respone = JsonConvert.DeserializeObject<ResponeAgingInputDto>(content.Data.ToString());
                    stockInfo.LinedProcessFeedbackTime = respone.LinedProcessFeedbackTime;
                    stockInfo.SpecialParameterDuration = respone.SpecialParameterDuration;
                    //2024å¹´11月16日:新增字段计算应出库时间
                    stockInfo.OutboundTime = Convert.ToDateTime(respone.LinedProcessFeedbackTime == null ? DateTime.Now : respone.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(respone.SpecialParameterDuration));
                    stockInfo.ProductionLine = respone.ProductionLine;
                    stockInfo.ParameterInfos = respone.ParameterInfos.ToJsonString();
                    stockInfo.StockStatus = 1;
                    var isResult = await _stockInfoRepository.UpdateDataNavAsync(stockInfo);
                    if (isResult)
                        content.OK("更新数据成功");
                    else
                        content.Error("更新数据失败");
                }
                else
                {
                    content.Error("未找到库存");
                }
            }
            else
            {
                return content;
            }
        }
        catch (Exception ex)
        {
            content.Error(ex.Message);
        }
        return content;
    }
}
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -1,6 +1,8 @@
using Mapster;
using AngleSharp.Dom;
using Mapster;
using Masuit.Tools;
using SixLabors.Fonts.Tables.AdvancedTypographic;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using WIDESEA_Core.Const;
@@ -8,6 +10,7 @@
using WIDESEA_DTO.WMS;
using WIDESEA_IServices;
using WIDESEA_IStoragIntegrationServices;
using WIDESEA_StoragIntegrationServices;
using WIDESEAWCS_BasicInfoRepository;
namespace WIDESEA_StorageTaskServices;
@@ -77,18 +80,100 @@
        {
            if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
            {
                #region è€ç‰ˆæœ¬
                //var process = await SqlSugarHelper.Db.Queryable<Dt_EquipmentProcess>()
                //    .FirstAsync(x => x.EquipmentName == task.Roadway);
                //var info = JsonConvert.DeserializeObject<ResponseEqptRunDto>(process.ProcessValue);
                if (!task.Roadway.Contains("FR") && stock.ProcessCode != "OCVB")  //非分容库区与当前工序是OCVB均上报MOM出入站
                //if (!task.Roadway.Contains("FR") && stock.ProcessCode != "OCVB")  //非分容库区与当前工序是OCVB均上报MOM出入站
                //{
                //    var agingOutputDto = MapToAgingOutputDto(stock);
                //    content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto);
                //    //ValidateResponse(content);
                //    var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString());
                //    if (!result.Success || !agingOutputDto.SerialNos[0].SerialNoResult)
                //    {
                //        if (result.MessageCode == "E10001")
                //        {
                //            var area = _areaInfoRepository.QueryFirst(x => x.AreaCode == stock.AreaCode);
                //            if (area == null)
                //            {
                //                throw new Exception("未找到对应的库区信息");
                //            }
                //            var trayCells = new TrayCellsStatusDto()
                //            {
                //                Software = area.Spare3,
                //                TrayBarcode = task.PalletCode,
                //                EquipmentCode = area.Spare2,
                //                SceneType = area.Spare4
                //            };
                //            content = await _cellStateService.GetTrayCellStatusAsync(trayCells);
                //            if (!content.Status) return content;
                //            var ResultTray = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
                //            if (ResultTray.SerialNos.Count > 0)
                //            {
                //                var parameterInfo = JsonConvert.DeserializeObject<List<ParameterInfo>>(stock.ParameterInfos).FirstOrDefault(y => y.Description.Contains("时间"));
                //                if (parameterInfo == null) throw new Exception("");
                //                var outHours = (DateTime.Now - (stock.LinedProcessFeedbackTime == null ? stock.CreateDate : stock.LinedProcessFeedbackTime.ToDateTime())).TotalHours;
                //                var isNG = outHours > parameterInfo.LowerSpecificationsLimit.ToDouble() && outHours < parameterInfo.UpperSpecificationsLimit.ToDouble();
                //                var defectCode = string.Empty;
                //                if (!isNG) defectCode = "TQCK";
                //                var outputDto = new AgingOutputDto
                //                {
                //                    OpFlag = 1,
                //                    Software = area.Spare3,
                //                    EquipmentCode = area.Spare2,
                //                    TrayBarcode = stock.PalletCode,
                //                    SerialNos = ResultTray.SerialNos.Select(x => new SerialNoOutDto
                //                    {
                //                        SlotNo = x.PositionNo,
                //                        SerialNo = x.SerialNo,
                //                        SerialNoResult = true, //isNG,
                //                        ParameterInfo = new List<ParameterInfoOutput> {
                //                            new ParameterInfoOutput() {
                //                                Value = outHours.ToString(),
                //                                ParameterCode =parameterInfo.ParameterCode,
                //                                ParameterDesc = parameterInfo.Description,
                //                                ParameterResult  = "OK", //isNG.ToString(),
                //                                TargetValue = parameterInfo.TargetValue,
                //                                LowerLomit = parameterInfo.LowerSpecificationsLimit,
                //                                UpperLimit = parameterInfo.UpperSpecificationsLimit,
                //                                DefectCode = defectCode,
                //                                UOMCode = parameterInfo.UOMCode,
                //                            }
                //                        }
                //                    }).ToList()
                //                };
                //                content = await _agingInOrOutInputService.GetOCVOutputAsync(outputDto);
                //                result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString());
                //                if (!result.Success)
                //                    task.Remark = "NG";
                //            }
                //        }
                //        else
                //            task.Remark = "NG";
                //    }
                //}
                #endregion è€ç‰ˆæœ¬
                if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
                {
                    var agingOutputDto = MapToAgingOutputDto(stock);
                    content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto);
                    //ValidateResponse(content);
                    var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString());
                    if (!result.Success || !agingOutputDto.SerialNos[0].SerialNoResult)
                    if (!task.Roadway.Contains("FR") && stock.ProcessCode != "OCVB")
                    {
                        task.Remark = "NG";
                        var agingOutputDto = MapToAgingOutputDto(stock);
                        content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto);
                        var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString());
                        task.Remark = result.Success ? null : "NG";
                        if (!result.Success && result.MessageCode == "E10001")
                        {
                            await HandleOutBoundError(stock, task);
                        }
                    }
                }
            }
@@ -96,6 +181,8 @@
            // æ›´æ–°åº“存状态和任务状态
            (var loc, var tas) = UpdateStockAndTaskStatus(stock, task);
            var taskHty = task.Adapt<Dt_Task_Hty>();
            DtStockInfo_Hty stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>();
            stockInfo_Hty.ModifyDate = DateTime.Now;
            // äº‹åŠ¡å¤„ç†
            await _unitOfWorkManage.UseTranAsync(async () =>
@@ -104,9 +191,9 @@
                {
                    await DeleteStockInfoAsync(stock.Id);
                    await DeleteStockInfoDetailsAsync(stock.StockInfoDetails);
                    await AddStockInfoHtyAsync(stockInfo_Hty);
                }
                await UpdateLocationAsync(loc);
                //if (task.Roadway.Contains("FR") || task.Roadway.Contains("GW") || task.TaskType == (int)TaskOutboundTypeEnum.OutTray)   //如果是分容或高温出库 å°†ä»»åŠ¡åˆ é™¤
                await DeleteTaskAsync(task.TaskId);
                await AddTaskHtyAsync(taskHty);
            });
@@ -175,10 +262,6 @@
        };
    }
    private void ValidateResponse(WebResponseContent content)
    {
    }
    private (DtLocationInfo, Dt_Task) UpdateStockAndTaskStatus(DtStockInfo stock, Dt_Task task)
    {
        var location = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress && x.RoadwayNo == task.Roadway);
@@ -199,6 +282,15 @@
        if (!isStockUpdated)
        {
            throw new Exception("库存信息更新失败");
        }
    }
    private async Task AddStockInfoHtyAsync(DtStockInfo_Hty dtStock)
    {
        var isStockAdd = await SqlSugarHelper.Db.InsertNav(dtStock).IncludesAllFirstLayer().ExecuteCommandAsync();
        if (!isStockAdd)
        {
            throw new Exception("库存历史信息添加失败");
        }
    }
@@ -917,7 +1009,7 @@
        }
        catch (Exception err)
        {
            throw;
            return content.Error(err.Message);
        }
    }
@@ -1331,6 +1423,129 @@
    public async Task<WebResponseContent> CreateAndSendInboundTask(string palletCode, string position)
    {
        #region
        //WebResponseContent content = new WebResponseContent();
        //try
        //{
        //    // æŸ¥è¯¢åº“存信息
        //    var stockInfo = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == palletCode);
        //    if (stockInfo == null)
        //    {
        //        var taskOld = BaseDal.QueryFirst(x => x.PalletCode == palletCode);
        //        if (!taskOld.IsNullOrEmpty())
        //        {// åˆ›å»ºWMS任务
        //            WMSTaskDTO taskDTO = new WMSTaskDTO()
        //            {
        //                TaskNum = taskOld.TaskNum.Value,
        //                Grade = 1,
        //                PalletCode = taskOld.PalletCode,
        //                RoadWay = taskOld.Roadway,
        //                SourceAddress = taskOld.CurrentAddress,
        //                TargetAddress = taskOld.TargetAddress,
        //                TaskState = taskOld.TaskState.Value,
        //                Id = 0,
        //                TaskType = taskOld.TaskType,
        //            };
        //            return content.OK(data: taskDTO);
        //        }
        //        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;
        //        ConsoleHelper.WriteErrorLine(content.ToJsonString());
        //        var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
        //        if (!result.Success) return content.Error(result.MOMMessage);
        //        if (result.SerialNos.Count > 0)
        //        {
        //            var boxing = CreateBoxingInfo(result, palletCode);
        //            if (boxing == null) return content.Error("组盘失败");
        //            // èŽ·å–å·¥è‰ºè·¯çº¿
        //            ProcessApplyDto process = await GetProcessApplyAsync(result);
        //            // èµ‹å€¼ä¸Šä½è½¯ä»¶åç§°å’Œè®¾å¤‡ç¼–码
        //            process.Software = area.Spare3;
        //            process.EquipmentCode = area.Spare2;
        //            content = await _processApplyService.GetProcessApplyAsync(process);
        //            if (!content.Status) return content.Error("工艺申请失败");
        //            var resultProcessApply = JsonConvert.DeserializeObject<ResultProcessApply>(content.Data.ToString());
        //            if (!resultProcessApply.Success) return content.Error("工艺申请失败");
        //            var number = resultProcessApply.ProcessInfo.Where(x => x.ProcessCode.Contains(boxing.ProcessCode)).FirstOrDefault().Number.ToInt32();
        //            foreach (var item in resultProcessApply.ProcessInfo)
        //            {
        //                if (item.Number.ToInt32() == number + 1)
        //                {
        //                    boxing.NextProcessCode = item.ProcessCode;
        //                }
        //            }
        //            var location = await GetLocationDistributeAsync(station.Roadway);
        //            ConsoleHelper.WriteErrorLine(location.ToJsonString());
        //            // åˆ›å»ºæ–°ä»»åŠ¡å®žä¾‹
        //            var task = new Dt_Task
        //            {
        //                CurrentAddress = station.stationLocation,
        //                Grade = 1,
        //                Roadway = station.Roadway,
        //                TargetAddress = location.LocationCode,
        //                Dispatchertime = DateTime.Now,
        //                MaterialNo = "",
        //                NextAddress = location.LocationCode,
        //                OrderNo = null,
        //                PalletCode = palletCode,
        //                SourceAddress = position,
        //                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.TargetAddress,
        //                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);
        //                await _boxingInfoRepository.AddDataNavAsync(boxing);
        //            });
        //            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
        WebResponseContent content = new WebResponseContent();
        try
        {
@@ -1339,20 +1554,10 @@
            if (stockInfo == null)
            {
                var taskOld = BaseDal.QueryFirst(x => x.PalletCode == palletCode);
                if (!taskOld.IsNullOrEmpty())
                {// åˆ›å»ºWMS任务
                    WMSTaskDTO taskDTO = new WMSTaskDTO()
                    {
                        TaskNum = taskOld.TaskNum.Value,
                        Grade = 1,
                        PalletCode = taskOld.PalletCode,
                        RoadWay = taskOld.Roadway,
                        SourceAddress = taskOld.CurrentAddress,
                        TargetAddress = taskOld.TargetAddress,
                        TaskState = taskOld.TaskState.Value,
                        Id = 0,
                        TaskType = taskOld.TaskType,
                    };
                if (taskOld != null)
                {
                    // åˆ›å»ºWMS任务
                    WMSTaskDTO taskDTO = CreateWMSTaskDTO(taskOld);
                    return content.OK(data: taskDTO);
                }
                var area = _areaInfoRepository.QueryFirst(x => x.AreaID == 2);
@@ -1363,11 +1568,37 @@
                ConsoleHelper.WriteErrorLine(content.ToJsonString());
                var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
                if (result == null || !result.Success) return content.Error(result?.MOMMessage ?? "Deserialization error");
                if (result.SerialNos.Count > 0)
                {
                    var boxing = CreateBoxingInfo(result, palletCode);
                    if (boxing == null) return content.Error("组盘失败");
                    // èŽ·å–å·¥è‰ºè·¯çº¿
                    ProcessApplyDto process = await GetProcessApplyAsync(result);
                    // èµ‹å€¼ä¸Šä½è½¯ä»¶åç§°å’Œè®¾å¤‡ç¼–码
                    process.Software = area.Spare3;
                    process.EquipmentCode = area.Spare2;
                    content = await _processApplyService.GetProcessApplyAsync(process);
                    if (!content.Status) return content.Error("工艺申请失败");
                    var resultProcessApply = JsonConvert.DeserializeObject<ResultProcessApply>(content.Data.ToString()) as ResultProcessApply;
                    if (resultProcessApply == null || !resultProcessApply.Success) return content.Error("工艺申请失败");
                    var number = resultProcessApply.ProcessInfo.Where(x => x.ProcessCode.Contains(boxing.ProcessCode)).FirstOrDefault()?.Number.ToInt32() ?? 0;
                    foreach (var item in resultProcessApply.ProcessInfo)
                    {
                        if (item.Number.ToInt32() == number + 1)
                        {
                            boxing.NextProcessCode = item.ProcessCode;
                        }
                    }
                    var location = await GetLocationDistributeAsync(station.Roadway);
                    ConsoleHelper.WriteErrorLine(location.ToJsonString());
                    // åˆ›å»ºæ–°ä»»åŠ¡å®žä¾‹
                    var task = new Dt_Task
                    {
@@ -1388,26 +1619,16 @@
                    };
                    // åˆ›å»ºWMS任务
                    WMSTaskDTO taskDTO = new WMSTaskDTO()
                    {
                        TaskNum = task.TaskNum.Value,
                        Grade = 1,
                        PalletCode = task.PalletCode,
                        RoadWay = task.Roadway,
                        SourceAddress = task.SourceAddress,
                        TargetAddress = task.TargetAddress,
                        TaskState = task.TaskState.Value,
                        Id = 0,
                        TaskType = task.TaskType,
                    };
                    WMSTaskDTO taskDTO = CreateWMSTaskDTO(task);
                    await _unitOfWorkManage.UseTranAsync(async () =>
                    {
                        // æ·»åŠ ä»»åŠ¡åˆ°æ•°æ®åº“
                        await BaseDal.AddDataAsync(task);
                        // æ›´æ–°åº“存位置状态为不可用
                        location.LocationStatus = (int)LocationEnum.InStockDisable;
                        location.LocationStatus = (int)LocationEnum.Lock;
                        await _locationRepository.UpdateDataAsync(location);
                        await _boxingInfoRepository.AddDataNavAsync(boxing);
                    });
                    content.OK(data: taskDTO);
@@ -1423,9 +1644,50 @@
        }
        catch (Exception ex)
        {
            // æ›´è¯¦ç»†çš„æ—¥å¿—记录,可使用日志框架替换 Console.WriteLine
            Console.WriteLine($"Error in CreateAndSendInboundTask: {ex.Message}");
            content.Error(ex.Message);
        }
        return content;
    }
    private WMSTaskDTO CreateWMSTaskDTO(object source)
    {
        if (source is Dt_Task taskOld)
        {
            return new WMSTaskDTO()
            {
                TaskNum = taskOld.TaskNum.Value,
                Grade = 1,
                PalletCode = taskOld.PalletCode,
                RoadWay = taskOld.Roadway,
                SourceAddress = taskOld.CurrentAddress,
                TargetAddress = taskOld.TargetAddress,
                TaskState = taskOld.TaskState.Value,
                Id = 0,
                TaskType = taskOld.TaskType,
            };
        }
        else if (source is Dt_Task task)
        {
            return new WMSTaskDTO()
            {
                TaskNum = task.TaskNum.Value,
                Grade = 1,
                PalletCode = task.PalletCode,
                RoadWay = task.Roadway,
                SourceAddress = task.SourceAddress,
                TargetAddress = task.TargetAddress,
                TaskState = task.TaskState.Value,
                Id = 0,
                TaskType = task.TaskType,
            };
        }
        else
        {
            throw new ArgumentException("Invalid source object type for WMSTaskDTO creation.");
        }
    }
    #endregion é™ç½®å¼‚常口入库
@@ -1473,6 +1735,7 @@
    {
        return await BaseDal.Delete(ids);
    }
    public override WebResponseContent DeleteData(object[] key)
    {
        WebResponseContent content = new WebResponseContent();
@@ -1500,8 +1763,8 @@
        {
            return content.Error("删除任务异常:" + ex.Message);
        }
    }
    /// <summary>
    /// é€šè¿‡ID获取任务
    /// </summary>
@@ -1740,7 +2003,6 @@
            // èŽ·å–ç›®æ ‡åœ°å€å’Œæ›´æ–°ä»»åŠ¡çŠ¶æ€
            input.Position = Regex.Replace(input.Position, @"-(\d+)", "");
            if (Convert.ToInt32(input.Position) > 1999)
            {
@@ -1911,6 +2173,8 @@
        return content;
    }
    private static readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
    /// <summary>
    /// æŸ¥æ‰¾è´§ä½
    /// </summary>
@@ -1921,6 +2185,7 @@
    {
        #region èŽ·å–è´§ä½
        await _semaphore.WaitAsync();
        try
        {
            List<DtLocationInfo> locations;
@@ -1944,6 +2209,10 @@
        {
            Console.WriteLine(err.Message.ToString());
            return null;
        }
        finally
        {
            _semaphore.Release();
        }
        #endregion èŽ·å–è´§ä½
@@ -1995,6 +2264,89 @@
        return minRoadwayNo;
    }
    // æ–°çš„出库错误处理逻辑
    private async Task HandleOutBoundError(DtStockInfo stock, Dt_Task task)
    {
        WebResponseContent content = new WebResponseContent();
        var area = _areaInfoRepository.QueryFirst(x => x.AreaCode == stock.AreaCode);
        if (area == null)
        {
            throw new Exception("未找到对应的库区信息");
        }
        var trayCells = new TrayCellsStatusDto
        {
            Software = area.Spare3,
            TrayBarcode = task.PalletCode,
            EquipmentCode = area.Spare2,
            SceneType = area.Spare4
        };
        content = await _cellStateService.GetTrayCellStatusAsync(trayCells);
        if (!content.Status) return;
        var ResultTray = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
        if (ResultTray.SerialNos.Count > 0)
        {
            var parameterInfo = GetParameterInfo(stock);
            var outHours = CalculateOutHours(stock);
            var isNG = outHours > parameterInfo.LowerSpecificationsLimit.ToDouble()
                        && outHours < parameterInfo.UpperSpecificationsLimit.ToDouble();
            var defectCode = !isNG ? "TQCK" : string.Empty;
            var outputDto = CreateAgingOutputDto(area, stock, ResultTray, parameterInfo, outHours, defectCode);
            content = await _agingInOrOutInputService.GetOCVOutputAsync(outputDto);
            var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString());
            if (!result.Success)
                task.Remark = "NG";
        }
    }
    // è®¡ç®—出库小时的方法
    private double CalculateOutHours(DtStockInfo stock) =>
        (DateTime.Now - Convert.ToDateTime(stock.LinedProcessFeedbackTime ?? stock.CreateDate.ToString())).TotalHours;
    // ç”Ÿæˆ AgingOutputDto çš„封装方法
    private AgingOutputDto CreateAgingOutputDto(Dt_AreaInfo area, DtStockInfo stock, ResultTrayCellsStatus resultTray,
        ParameterInfo parameterInfo, double outHours, string defectCode)
    {
        return new AgingOutputDto
        {
            OpFlag = 1,
            Software = area.Spare3,
            EquipmentCode = area.Spare2,
            TrayBarcode = stock.PalletCode,
            SerialNos = resultTray.SerialNos.Select(x => new SerialNoOutDto
            {
                SlotNo = x.PositionNo,
                SerialNo = x.SerialNo,
                SerialNoResult = true,
                ParameterInfo = new List<ParameterInfoOutput>
                {
                    new ParameterInfoOutput
                    {
                        Value = outHours.ToString(),
                        ParameterCode = parameterInfo.ParameterCode,
                        ParameterDesc = parameterInfo.Description,
                        ParameterResult  = "OK",
                        TargetValue = parameterInfo.TargetValue,
                        LowerLomit = parameterInfo.LowerSpecificationsLimit,
                        UpperLimit = parameterInfo.UpperSpecificationsLimit,
                        DefectCode = defectCode,
                    }
                }
            }).ToList()
        };
    }
    // èŽ·å–å‚æ•°ä¿¡æ¯çš„è¾…åŠ©æ–¹æ³•
    private ParameterInfo GetParameterInfo(DtStockInfo stock) =>
        JsonConvert.DeserializeObject<List<ParameterInfo>>(stock.ParameterInfos)
            .FirstOrDefault(y => y.Description.Contains("时间"));
    #endregion ä»»åŠ¡è¯·æ±‚æ–¹æ³•
    #endregion private å†…部方法
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Integration/ProcessApplyController.cs
@@ -25,4 +25,16 @@
    {
        return await _processApplyService.GetProcessApplyAsync(input);
    }
    /// <summary>
    /// è¡¥å½•入库数据
    /// </summary>
    /// <param name="palletCode">托盘号</param>
    /// <param name="areaID">区域主键</param>
    /// <returns></returns>
    [HttpPost("StockInDataBack")]
    public async Task<WebResponseContent> StockInDataBackfillInterfaceAsync(string palletCode, int areaID)
    {
        return await _processApplyService.StockInDataBackfillInterfaceAsync(palletCode, areaID);
    }
}
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json
ÎļþÒÑɾ³ý