From 24180a4a19e29ad39ccf61f4b31f03d0f594c99c Mon Sep 17 00:00:00 2001 From: kazelee <1847801760@qq.com> Date: 星期五, 09 五月 2025 17:30:45 +0800 Subject: [PATCH] 抽检功能部分接口与后台功能开发,待完善测试 --- Models/TN_Order_Task.cs | 11 +++ ServiceCore/CheckCore.cs | 70 +++++++++++++++++++++++ /dev/null | 0 .vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/bed55563-1884-46d9-8f7f-fb19ae6beec5.vsidx | 0 Consts/TaskName.cs | 1 config/config.json | 3 + Models/TN_Check_Order.cs | 25 ++++++++ Controllers/MoboxController.cs | 10 +++ .vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/6f64c2b7-09d5-4b3c-9a79-72745b90527c.vsidx | 0 Services/MoboxService.cs | 24 ++++++++ Dtos/Request/MoboxRequest.cs | 8 ++ HH.WCS.Mobox3.DSZSH.csproj | 4 + 12 files changed, 155 insertions(+), 1 deletions(-) diff --git a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/6f64c2b7-09d5-4b3c-9a79-72745b90527c.vsidx b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/6f64c2b7-09d5-4b3c-9a79-72745b90527c.vsidx new file mode 100644 index 0000000..a81c146 --- /dev/null +++ b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/6f64c2b7-09d5-4b3c-9a79-72745b90527c.vsidx Binary files differ diff --git a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/9cdebdd3-1654-41dc-894c-c2dd9e6fc6e0.vsidx b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/9cdebdd3-1654-41dc-894c-c2dd9e6fc6e0.vsidx deleted file mode 100644 index 80ce873..0000000 --- a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/9cdebdd3-1654-41dc-894c-c2dd9e6fc6e0.vsidx +++ /dev/null Binary files differ diff --git a/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/bed55563-1884-46d9-8f7f-fb19ae6beec5.vsidx b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/bed55563-1884-46d9-8f7f-fb19ae6beec5.vsidx new file mode 100644 index 0000000..c8c5a9c --- /dev/null +++ b/.vs/HH.WCS.Mobox3.DSZSH/FileContentIndex/bed55563-1884-46d9-8f7f-fb19ae6beec5.vsidx Binary files differ diff --git a/Consts/TaskName.cs b/Consts/TaskName.cs index aac3d8b..90cda13 100644 --- a/Consts/TaskName.cs +++ b/Consts/TaskName.cs @@ -6,6 +6,7 @@ namespace HH.WCS.Mobox3.DSZSH.Consts { public class TaskName { + public const string 鎶芥 = "鎶芥"; public const string 濂借繍绠盻婊$涓嬬嚎鍏ュ簱 = "濂借繍绠�婊$涓嬬嚎鍏ュ簱"; public const string 濂借繍绠盻绌虹涓婄嚎 = "濂借繍绠�绌虹涓婄嚎"; public const string 濂借繍绠盻绌虹鍏ュ簱 = "濂借繍绠�绌虹鍏ュ簱"; diff --git a/Controllers/MoboxController.cs b/Controllers/MoboxController.cs index 9d9bfe2..1af0231 100644 --- a/Controllers/MoboxController.cs +++ b/Controllers/MoboxController.cs @@ -118,6 +118,16 @@ return BuildSimpleResult(-1, $"涓嶅悎娉曠殑瀹瑰櫒绫诲瀷锛�{locCntrRel.S_CNTR_CODE}'"); } } + + /// <summary> + /// 鍒涘缓鎶芥鍗曪紙鍙兘鐢盤DA/WMS鑷瀹屾垚锛�+ /// </summary> + /// <param name="model"></param> + /// <returns></returns> + public SimpleResult CreateCheckOrder(CreateCheckOrderInfo model) { + return MoboxService.CreateCheckOrder(model); + } + #endregion #region Mobox 鎺ュ彛 diff --git a/Dtos/Request/MoboxRequest.cs b/Dtos/Request/MoboxRequest.cs index 0e87376..8d35242 100644 --- a/Dtos/Request/MoboxRequest.cs +++ b/Dtos/Request/MoboxRequest.cs @@ -93,6 +93,14 @@ } public class EmptyOnlineGoodpackInfo : StartCntEndInfo { } + + public class CreateCheckOrderInfo { + public string CgId { get; set; } + public string ItemName { get; set; } + public string BatchNo { get; set; } + public string Qty { get; set; } + public string EndArea { get; set; } + } #endregion #region WMS 鏁版嵁 diff --git a/HH.WCS.Mobox3.DSZSH.csproj b/HH.WCS.Mobox3.DSZSH.csproj index 5fefc35..f1bfe8c 100644 --- a/HH.WCS.Mobox3.DSZSH.csproj +++ b/HH.WCS.Mobox3.DSZSH.csproj @@ -237,10 +237,13 @@ <Compile Include="Helpers\ResultHelper.cs" /> <Compile Include="Helpers\DbHelper.cs" /> <Compile Include="Models\DebugModel.cs" /> + <Compile Include="Models\TN_Check_Order.cs" /> <Compile Include="Models\TN_Inbound_Order.cs" /> + <Compile Include="Models\TN_Order_Task.cs" /> <Compile Include="Models\TN_Outbound_Order.cs" /> <Compile Include="Models\TN_Outbound_Detail.cs" /> <Compile Include="Models\TN_Outbound_Task.cs" /> + <Compile Include="ServiceCore\CheckCore.cs" /> <Compile Include="ServiceCore\OutboundCore.cs" /> <Compile Include="Services\DebugService.cs" /> <Compile Include="Devices\BaseModbusDevice.cs" /> @@ -290,7 +293,6 @@ <ItemGroup> <None Include=".editorconfig" /> <None Include="App.config" /> - <None Include="config\config.comment.json" /> <None Include="config\config.json"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </None> diff --git a/Models/TN_Check_Order.cs b/Models/TN_Check_Order.cs new file mode 100644 index 0000000..00db05c --- /dev/null +++ b/Models/TN_Check_Order.cs @@ -0,0 +1,25 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using SqlSugar; + +namespace HH.WCS.Mobox3.DSZSH.Models { + /// <summary> + /// 鎶芥鍗�+ /// </summary> + [SugarTable("TN_Check_Order")] + public class TN_Check_Order : BaseModel { + public string S_CG_ID { get; set; } + public string S_ITEM_NAME { get; set; } + public string S_BATCH_NO { get; set; } + public int N_QTY { get; set; } + public string S_END_AREA { get; set; } + /// <summary> + /// 鎶芥鍗曠姸鎬侊細0鏈墽琛�1鎵ц涓�2瀹屾垚 + /// </summary> + public int N_B_STATE { get; set; } = 0; + } +} diff --git a/Models/TN_Order_Task.cs b/Models/TN_Order_Task.cs new file mode 100644 index 0000000..9bbb09b --- /dev/null +++ b/Models/TN_Order_Task.cs @@ -0,0 +1,11 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DSZSH.Models { + public class TN_Order_Task { + + } +} diff --git a/ServiceCore/CheckCore.cs b/ServiceCore/CheckCore.cs new file mode 100644 index 0000000..9eee55a --- /dev/null +++ b/ServiceCore/CheckCore.cs @@ -0,0 +1,70 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using HH.WCS.Mobox3.DSZSH.Consts; +using HH.WCS.Mobox3.DSZSH.Helpers; +using HH.WCS.Mobox3.DSZSH.Helpers.Model; +using HH.WCS.Mobox3.DSZSH.Models; + +namespace HH.WCS.Mobox3.DSZSH.ServiceCore { + /// <summary> + /// 瀹氭椂杞浠诲姟锛氭娊妫�笟鍔℃牳蹇�+ /// </summary> + public class CheckCore { + /// <summary> + /// 杞鏌ョ湅鎶芥鍗曟槸鍚︽湁鎵ц涓殑椤圭洰 + /// </summary> + public void CheckOrderState() { + var db = DbHelper.GetDbClient(); + try { + var orderList = db.Queryable<TN_Check_Order>() + .Where(c => c.N_B_STATE == 0) + .OrderBy(c => c.T_CREATE).ToList(); + + using (var tran = db.Ado.UseTran()) { + foreach (var order in orderList) { + var startLocList = db.Queryable<TN_Location, TN_Loc_Container, TN_CG_Detail> + ((l, c, d) => l.S_CODE == c.S_LOC_CODE && c.S_CNTR_CODE == d.S_CNTR_CODE) + .Where((l, c, d) => d.S_CG_ID == order.S_CG_ID && d.S_BATCH_NO == order.S_BATCH_NO) + .Select((l, c) => new { Location = l, Container = c }) + .Take(order.N_QTY).ToList(); // 鑾峰彇鎸囧畾鏁伴噺鐨勮揣浣嶆暟锛岄殢鏈烘娊鍙栨晠鏃犻渶鎺掑簭 + + if (startLocList.Count < order.N_QTY) { + LogHelper.Info($"杞 | 褰撳墠鍙娊妫�殑鐗╂枡鏁伴噺 {startLocList.Count} 鏃犳硶婊¤冻鎶芥鍗曟暟閲�{order.N_QTY} 瑕佹眰"); + return; + } + + var endLocList = db.Queryable<TN_Location>() + .Where(l => l.S_AREA_CODE == order.S_END_AREA) + .Where(ExprHelper.LocIsFree) + .Where(ExprHelper.LocIsEmpty) + .Take(order.N_QTY).ToList(); // 鑾峰彇鎸囧畾鏁伴噺鐨勮揣浣嶆暟 + + if (endLocList.Count < order.N_QTY) { + LogHelper.Info($"杞 | 缁堢偣鍖哄煙鍙敤璐т綅 {startLocList.Count} 鏃犳硶婊¤冻鎶芥鍗曟暟閲�{order.N_QTY} 瑕佹眰"); + return; + } + + // TODO 鍙傝�鍑哄簱锛屽鏋滆姹備换鍔¢『搴忎篃瑕佹柊鍒涘缓琛ㄥ瓨鍌紝鏈夐渶姹傚啀鏇存柊 + for (var i = 0; i < order.N_QTY; i++) { + if (!TaskHelper.LogCreateTask(startLocList[i].Location.S_CODE, startLocList[i].Container.S_CNTR_CODE, + endLocList[i].S_CODE, TaskName.鎶芥)) { + tran.RollbackTran(); + } + } + + order.N_B_STATE = 1; + db.Updateable<TN_Check_Order>(endLocList).UpdateColumns(c => c.N_B_STATE); + tran.CommitTran(); + } + } + } + catch (Exception ex) { + LogHelper.InfoEx(ex); + } + } + } +} diff --git a/Services/MoboxService.cs b/Services/MoboxService.cs index 0fe26c0..d2f68a6 100644 --- a/Services/MoboxService.cs +++ b/Services/MoboxService.cs @@ -382,6 +382,30 @@ return BuildSimpleEx(ex); } } + + public static SimpleResult CreateCheckOrder(CreateCheckOrderInfo model) { + var db = DbHelper.GetDbClient(); + try { + + var order = new TN_Check_Order { + S_CG_ID = model.CgId, + S_ITEM_NAME = model.ItemName, + S_BATCH_NO = model.BatchNo, + N_QTY = model.Qty, + S_END_AREA = model.EndArea, + }; + + if (db.Insertable<TN_Check_Order>(order).ExecuteCommand() > 0) { + return BuildSimpleResult(0, "鎻掑叆鎶芥鍗曟垚鍔燂細" + JsonConvert.SerializeObject(order)); + } + else { + return BuildSimpleResult(2, "鎻掑叆鎶芥鍗曞け璐ワ細" + JsonConvert.SerializeObject(order)); + } + } + catch (Exception ex) { + return BuildSimpleEx(ex); + } + } #endregion #region Mobox 鍔熻兘 diff --git a/config/config.json b/config/config.json index 43f0079..63727c7 100644 --- a/config/config.json +++ b/config/config.json @@ -98,6 +98,9 @@ "EndAreas": [ "HJQ1" ] }, { + "Name": "鎶芥" + } + { "Name": "鎴愬搧鑳跺嚭搴� }, { -- Gitblit v1.9.1