From db6156a92cc59467bde608a00c76952ebc75e488 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期二, 05 三月 2024 09:51:05 +0800 Subject: [PATCH] 优化代码 --- 代码管理/WMS/WMS_Server/WIDESEA_WMS/Services/Taskinfo/Partial/dt_agvtaskService.cs | 67 +++++++++++++++++++++++++++++++++ 1 files changed, 66 insertions(+), 1 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/Taskinfo/Partial/dt_agvtaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/Taskinfo/Partial/dt_agvtaskService.cs" index 304ecfa..d4bb396 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/Taskinfo/Partial/dt_agvtaskService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/Taskinfo/Partial/dt_agvtaskService.cs" @@ -17,6 +17,14 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Http; using WIDESEA_WMS.IRepositories; +using WIDESEA_WMS.Repositories; +using WIDESEA_Core.EFDbContext; +using static System.Collections.Specialized.BitVector32; +using WIDESEA_Comm.TaskNo; +using WIDESEA_Common; +using WIDESEA_Core.ManageUser; +using WIDESEA_Comm.LogInfo; +using StackExchange.Redis; namespace WIDESEA_WMS.Services { @@ -37,5 +45,62 @@ //澶氱鎴蜂細鐢ㄥ埌杩檌nit浠g爜锛屽叾浠栨儏鍐靛彲浠ヤ笉鐢� //base.Init(dbRepository); } - } + /// <summary> + /// 娣诲姞浠诲姟 + /// </summary> + /// <param name="saveDataModel"></param> + /// <returns></returns> + public override WebResponseContent Add(SaveModel saveDataModel) + { + WebResponseContent content = new WebResponseContent(); + try + { + VOLContext context = new VOLContext(); + Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context); + var fromaddress = saveDataModel.MainData["agv_fromaddress"].ToString(); + var toaddress = saveDataModel.MainData["agv_toaddress"].ToString(); + var tasktype = saveDataModel.MainData["agv_tasktype"].ToString(); + var grade = saveDataModel.MainData["agv_grade"].ToInt(); + var worktype = saveDataModel.MainData["agv_worktype"].ToInt(); + var station1 = stationinfoRepository.FindFirst(x => x.stationCode == fromaddress); + var station2 = stationinfoRepository.FindFirst(x => x.stationCode == toaddress); + if (station1 == null || station2 == null) + throw new Exception($"璧风偣鍦板潃{fromaddress}鎴栫粓鐐瑰湴鍧�{toaddress}涓嶅瓨鍦紒"); + if (string.IsNullOrEmpty(station1.stationType)) + throw new Exception($"璧风偣{fromaddress}鏈粦瀹氱墿鏂欑被鍨嬶紒"); + var task = _repository.Find(t => t.agv_fromaddress == fromaddress + || t.agv_fromaddress == toaddress + || t.agv_toaddress == fromaddress + || t.agv_toaddress == toaddress + ).Any(); + if (task) + throw new Exception("璧峰鎴栫洰鐨勫湴鍧�锛屽凡瀛樺湪浠诲姟涓紒"); + dt_agvtask agvtask = new dt_agvtask(); + agvtask.agv_id = Guid.NewGuid(); + agvtask.agv_fromaddress = fromaddress; + agvtask.agv_toaddress = toaddress; + agvtask.agv_tasknum = IdenxManager.GetTaskNo("KH-"); + agvtask.agv_code = "AGV"; + agvtask.agv_taskstate = AGVTaskStateEnum.Create.ToString(); + agvtask.agv_tasktype = tasktype; + agvtask.agv_worktype = worktype;//宸ヤ綔绫诲瀷 + agvtask.bindSN = station1.bindSN; + agvtask.agv_materielid = station1.stationType;//鐗╂枡绫诲瀷 + agvtask.agv_qty = station1.quantity; + agvtask.agv_createtime = DateTime.Now; + agvtask.agv_grade = grade;//浠诲姟浼樺厛绾� + agvtask.agv_userid = UserContext.Current.UserName; + _repository.Add(agvtask, true); + content.OK(); + WriteDBLog.Success($"鎵嬪姩娣诲姞浠诲姟", new { 鏁版嵁 = saveDataModel }, "WMS", UserContext.Current.UserName); + } + catch (Exception ex) + { + WriteDBLog.Error($"鎵嬪姩娣诲姞浠诲姟", new { 鏁版嵁 = saveDataModel, 寮傚父淇℃伅 = ex.Message }, "WMS", UserContext.Current.UserName); + content.Error(ex.Message); + } + + return content; + } + } } -- Gitblit v1.9.3