From 223a7b9cdb5db711ac644bcfdbbbc7c4d2b7f344 Mon Sep 17 00:00:00 2001 From: 肖洋 <cathay_xy@163.com> Date: 星期四, 26 十二月 2024 13:58:24 +0800 Subject: [PATCH] 优化代码结构和增强功能 --- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs | 15 .gitignore | 2 Code Management/WMS/WIDESEA_WMSClient/src/components/basic/ViewGrid/ViewGrid.vue | 2 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/SqlSugarHelper.cs | 3 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 438 ++++++++++++++++++++++++++++--- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 33 + Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/IRepository.cs | 14 + Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs | 10 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/HostedService/SeedDataHostedService.cs | 2 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs | 51 -- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Integration/ProcessApplyController.cs | 12 /dev/null | 31 -- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Helper/ConsoleHelper.cs | 16 + Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs | 12 Code Management/WMS/WIDESEA_WMSClient/src/api/http.js | 4 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/ProcessApply/IProcessApplyService.cs | 8 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs | 175 ++++++++++++ Code Management/WMS/WIDESEA_WMSClient/src/router/tables.js | 8 18 files changed, 699 insertions(+), 137 deletions(-) diff --git a/.gitignore b/.gitignore index acd2870..7b03c8c 100644 --- a/.gitignore +++ b/.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 diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Helper/ConsoleHelper.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Helper/ConsoleHelper.cs index 452102f..9c43a3d 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Helper/ConsoleHelper.cs +++ b/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> diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs index 745f284..022cb6b 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs +++ b/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; diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs index beee08f..433a120 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs +++ b/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鍙e叆搴� - 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 diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs index 4213039..21112a9 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs @@ -1,6 +1,8 @@ 锘縰sing 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); diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/api/http.js b/Code Management/WMS/WIDESEA_WMSClient/src/api/http.js index 8b43a2a..aa57a03 100644 --- a/Code Management/WMS/WIDESEA_WMSClient/src/api/http.js +++ b/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/'; diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/components/basic/ViewGrid/ViewGrid.vue b/Code Management/WMS/WIDESEA_WMSClient/src/components/basic/ViewGrid/ViewGrid.vue index c548c62..c66cf97 100644 --- a/Code Management/WMS/WIDESEA_WMSClient/src/components/basic/ViewGrid/ViewGrid.vue +++ b/Code Management/WMS/WIDESEA_WMSClient/src/components/basic/ViewGrid/ViewGrid.vue @@ -329,7 +329,7 @@ //闇�瑕佷粠杩滅▼缁戝畾鏁版嵁婧愮殑瀛楀吀缂栧彿,濡傛灉瀛楀吀鏁版嵁婧愮殑鏌ヨ缁撴灉杈冨锛岃鍦╫nInit涓皢瀛楀吀缂栧彿娣诲姞杩涙潵 //鍙鑷畾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鎸夐挳鍚嶇О diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/router/tables.js b/Code Management/WMS/WIDESEA_WMSClient/src/router/tables.js index 8b4f264..03e27d3 100644 --- a/Code Management/WMS/WIDESEA_WMSClient/src/router/tables.js +++ b/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 } }, // { diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs index 990408f..692d693 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs +++ b/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) diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/IRepository.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/IRepository.cs index a7f1db1..4a5e263 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/IRepository.cs +++ b/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> diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs index 607821b..ee96461 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs +++ b/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, diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/SqlSugarHelper.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/SqlSugarHelper.cs index 48abb76..7ab5c6c 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Helper/SqlSugarHelper.cs +++ b/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 //涓嶈鎴恡rue瑕佹墜鍔╟lose }, diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/HostedService/SeedDataHostedService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/HostedService/SeedDataHostedService.cs index 21bbef2..fe41350 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/HostedService/SeedDataHostedService.cs +++ b/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); diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/ProcessApply/IProcessApplyService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/ProcessApply/IProcessApplyService.cs index 5fdccb3..b9cdd63 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/ProcessApply/IProcessApplyService.cs +++ b/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); } \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs index 3de2826..142e609 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs +++ b/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; + } } \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs index b19f3b0..e6c0992 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs @@ -1,6 +1,8 @@ -锘縰sing Mapster; +锘縰sing 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") //闈炲垎瀹瑰簱鍖轰笌褰撳墠宸ュ簭鏄疧CVB鍧囦笂鎶OM鍑哄叆绔� + //if (!task.Roadway.Contains("FR") && stock.ProcessCode != "OCVB") //闈炲垎瀹瑰簱鍖轰笌褰撳墠宸ュ簭鏄疧CVB鍧囦笂鎶OM鍑哄叆绔� + //{ + // 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 闈欑疆寮傚父鍙e叆搴� @@ -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 鍐呴儴鏂规硶 diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Integration/ProcessApplyController.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Integration/ProcessApplyController.cs index 543b12f..4f42cf1 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Integration/ProcessApplyController.cs +++ b/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); + } } \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json deleted file mode 100644 index e36aa41..0000000 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "AllowedHosts": "*", - "urls": "http://*:5000", - "MainDB": "DB_WIDESEA", //褰撳墠椤圭洰鐨勪富搴擄紝鎵�瀵瑰簲鐨勮繛鎺ュ瓧绗︿覆鐨凟nabled蹇呴』涓簍rue - //杩炴帴瀛楃涓� - //"ConnectionString": "HTI6FB1H05Krd07mNm9yBCNhofW6edA5zLs9TY~MNthRYW3kn0qKbMIsGp~3yyPDF1YZUCPBQx8U0Jfk4PH~ajNFXVIwlH85M3F~v_qKYQ3CeAz3q1mLVDn8O5uWt1~3Ut2V3KRkEwYHvW2oMDN~QIDXPxDgXN0R2oTIhc9dNu7QNaLEknblqmHhjaNSSpERdDVZIgHnMKejU_SL49tralBkZmDNi0hmkbL~837j1NWe37u9fJKmv91QPb~16JsuI9uu0EvNZ06g6PuZfOSAeFH9GMMIZiketdcJG3tHelo=", - "ConnectionString": "Data Source=192.168.5.251;Initial Catalog=WIDESEA_WMSDB_BBMain;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", - //"ConnectionString": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WMS2F08;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", - //"ConnectionString": "Data Source=.\\LIULEI;Initial Catalog=WIDESEA_WMSDB_BBMain;User ID=sa;Password=123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", - //"ConnectionString": "Data Source=192.168.20.251;Initial Catalog=WIDESEA_WMSDB;User ID=sa;Password=123456@gy;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", - - //璺ㄥ煙 - "Cors": { - "PolicyName": "CorsIpAccess", //绛栫暐鍚嶇О - "EnableAllIPs": true, //褰撲负true鏃讹紝寮�鏀炬墍鏈塈P鍧囧彲璁块棶銆� - // 鏀寔澶氫釜鍩熷悕绔彛锛屾敞鎰忕鍙e彿鍚庝笉瑕佸甫/鏂滄潌锛氭瘮濡俵ocalhost:8000/锛屾槸閿欑殑 - // 娉ㄦ剰锛宧ttp://127.0.0.1:1818 鍜� http://localhost:1818 鏄笉涓�鏍风殑 - "IPs": "http://127.0.0.1:8080,http://localhost:8080,http://127.0.0.1:8081,http://localhost:8081" - }, - "ApiName": "WIDESEA", - "ExpMinutes": 120, - - // 闇�瑕佺Щ搴撶殑琛� - "TransfertRows": "1,4,5,8" -} -- Gitblit v1.9.3