From 157abc191c34e57c1b958ae74fc3de6518ca8a30 Mon Sep 17 00:00:00 2001 From: zhaowc <526854230@qq.com> Date: 星期五, 28 二月 2025 11:06:36 +0800 Subject: [PATCH] 修改客户需求 --- Wms/Wms/Controllers/DownApiController.cs | 245 +++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 227 insertions(+), 18 deletions(-) diff --git a/Wms/Wms/Controllers/DownApiController.cs b/Wms/Wms/Controllers/DownApiController.cs index 8729e68..e558169 100644 --- a/Wms/Wms/Controllers/DownApiController.cs +++ b/Wms/Wms/Controllers/DownApiController.cs @@ -17,6 +17,7 @@ using Model.ModelVm.PdaVm; using WMS.IBLL.IPdaServer; using Model.ModelVm; +using WMS.IBLL.IDataServer; namespace Wms.Controllers { @@ -34,8 +35,10 @@ private readonly ITaskServer _taskSvc;//浠诲姟Svc private readonly IPdaSoServer _pdaSoSvc;//绌烘墭鍑哄簱Svc private readonly IPdaAsnServer _paAsnSvc;//绌烘墭璺虹粦瀹� + private readonly IStockServer _stockSvc;//AGV浠诲姟瀹屾垚绠� + private readonly IPdaCrServer _pdaCrServer; // PDA浠诲姟璋冨害 - public DownApiController(IOptions<ApiUrlConfig> setting, IExportNoticeServer exNoticeSvc, IPalletBindServer asnPalletBindSvc, IStockCheckServer crCheckSvc, ITaskServer taskSvc, IPdaSoServer pdaSoSvc,IPdaAsnServer paAsnSvc) + public DownApiController(IOptions<ApiUrlConfig> setting, IExportNoticeServer exNoticeSvc, IPalletBindServer asnPalletBindSvc, IStockCheckServer crCheckSvc, ITaskServer taskSvc, IPdaSoServer pdaSoSvc,IPdaAsnServer paAsnSvc,IStockServer stockSvc,IPdaCrServer pdaCrServer) { _config = setting.Value; _exNoticeSvc = exNoticeSvc; @@ -44,6 +47,8 @@ _taskSvc = taskSvc; _pdaSoSvc = pdaSoSvc; _paAsnSvc = paAsnSvc; + _stockSvc = stockSvc; + _pdaCrServer = pdaCrServer; } #region WMS鎺ュ彛 璋冪敤涓嬫父绯荤粺鎺ュ彛 @@ -361,20 +366,20 @@ } //鎺ユ敹鏃堕棿 var time1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - var orderType = _taskSvc.GetTaskOrderType(model.TaskNo);// 鍒ゆ柇鍗曟嵁绫诲瀷鍏ュ嚭绉� + var orderType = _taskSvc.GetTaskOrderType(model.TaskNo,model.TaskType);// 鍒ゆ柇鍗曟嵁绫诲瀷鍏ュ嚭绉� switch (orderType) { case "0"://鍏ュ簱瀹屾垚浠诲姟 if (model.TaskType == "0")//0锛氬叆搴� 1锛氬嚭搴� 2锛氱Щ搴� { _asnPalletBindSvc.ArrivalSuccess(model.TaskNo, 0); - return Ok(new WcsModel { StatusCode = 0, Msg = "鍏ュ簱瀹屾垚" }); + return Ok(new WcsModel { StatusCode = 0, Msg = "鍏ュ簱瀹屾垚" }); } break; case "1"://鍑哄簱瀹屾垚浠诲姟 if (model.TaskType == "1")//0锛氬叆搴� 1锛氬嚭搴� 2锛氱Щ搴� { - _exNoticeSvc.ExportSuccess(model.TaskNo, 0); + _exNoticeSvc.ExportSuccess(model.TaskNo, 0, _config.AgvHost + _config.GenAgvSchedulingTask); return Ok(new WcsModel { StatusCode = 0, Msg = "鍑哄簱瀹屾垚" }); } else if (model.TaskType == "2") @@ -429,7 +434,7 @@ var bl = _exNoticeSvc.EmptyException(model); LogFile.SaveLogToFile($"绌哄彇寮傚父锛�(鎵ц缁撴灉鎴愬姛),", logStr); - return Ok(new { Success = 0, Message = "" }); + return Ok(new { Success = 0,StatusCode = 0, Message = "" }); } catch (Exception e) { @@ -454,7 +459,7 @@ var list = _asnPalletBindSvc.FullException(model); LogFile.SaveLogToFile($"婊″叆寮傚父锛�( {JsonConvert.SerializeObject(list)} ),", logStr); - return Ok(new { Success = 0, Message = "", TaskList = list }); + return Ok(new { Success = 0, StatusCode = 0, Message = "", TaskList = list }); } catch (Exception e) { @@ -549,12 +554,12 @@ [HttpPost] public IActionResult BindPlnInHouseWcs(PalletsBind model) { - var logStr = $@".\log\WCS\WCS鐢宠绌烘墭璺虹粦瀹�" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + var logStr = $@".\log\WCS\WCS鍙堝彔鎵樻満鐢宠绌烘墭鍏ュ簱" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; try { var strMsg = _paAsnSvc.BindNullPallets(model); - return Ok(new { Success = 0, Message = "绌烘墭璺虹粦瀹氭垚鍔�", TaskList = strMsg }); + return Ok(new { Success = 0, Message = "绌烘墭璺虹粦瀹氭垚鍔�"}); } catch (Exception e) { @@ -588,6 +593,102 @@ } } + /// <summary> + /// WMS鎷h揣鐢宠绌烘墭鍑哄簱 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [AllowAnonymous] + [HttpPost] + public IActionResult IssuePlnCheckHouseWcs(CheckModePalletVm model) + { + var logStr = $@".\log\WCS\WMS鎷h揣鐢宠绌烘墭鍑哄簱" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + try + { + string list = _pdaSoSvc.IssuePlnCehckHouseWcs(model, 0,_config.AgvHost+_config.GenAgvSchedulingTask); + + return Ok(new { Success = 0, Message = "鎷h揣鍙┖鎵樼洏鎴愬姛"}); + } + catch (Exception e) + { + LogFile.SaveLogToFile($"WMS鎷h揣鐢宠绌烘墭鍑哄簱寮傚父杩斿洖锛�( {e.Message} ),", logStr); + + return Ok(new ErpModel { Success = -1, Message = e.Message }); + } + } + + /// <summary> + /// WCS鐢宠鏄惁缂犺啘 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [AllowAnonymous] + [HttpPost] + public IActionResult RequestPackWcs(RequesIsBale model) + { + var logStr = $@".\log\WCS\WCS鐢宠缂犺啘鎷嗚啘" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + try + { + int t = _asnPalletBindSvc.RequestPackWcs(model.PalletNo); + LogFile.SaveLogToFile($"WCS鐢宠缂犺啘鍏ュ簱璇锋眰锛岃姹傛墭鐩樺憟锛�( {model.PalletNo} ),", logStr); + + return Ok(new { Success = t, Message = "缂犺啘鎸囦护鍙戦�佹垚鍔�" }); + } + catch (Exception e) + { + LogFile.SaveLogToFile($"WCS鐢宠缂犺啘鍏ュ簱寮傚父杩斿洖锛�( {e.Message} ),", logStr); + + return Ok(new ErpModel { Success = -1, Message = e.Message }); + } + } + + /// <summary> + /// WCS鐢宠鏄惁鎷嗚啘 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [AllowAnonymous] + [HttpPost] + public IActionResult RequestUnPackWcs(RequesIsBale model) + { + var logStr = $@".\log\WCS\WCS鐢宠缂犺啘鎷嗚啘" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + try + { + int t = _asnPalletBindSvc.RequestUnPackWcs(model.PalletNo); + + return Ok(new { Success = t, Message = "鎷嗚啘鎸囦护鍙戦�佹垚鍔�" }); + } + catch (Exception e) + { + LogFile.SaveLogToFile($"WCS鐢宠鎷嗚啘鍑哄簱寮傚父杩斿洖锛�( {e.Message} ),", logStr); + + return Ok(new ErpModel { Success = -1, Message = e.Message }); + } + } + + /// <summary> + /// WCS鍙嶉缂犺啘瀹屾垚 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [AllowAnonymous] + [HttpPost] + public IActionResult RequestPackedWcs(RequesIsBale model) + { + var logStr = $@".\log\WCS\WCS鐢宠缂犺啘鎷嗚啘" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + try + { + int t = _asnPalletBindSvc.RequestPackedWcs(model.PalletNo); + + return Ok(new { Success = t, Message = "缂犺啘瀹屾垚鎸囦护鍙戦�佹垚鍔�" }); + } + catch (Exception e) + { + LogFile.SaveLogToFile($"WCS鐢宠缂犺啘瀹屾垚寮傚父杩斿洖锛�( {e.Message} ),", logStr); + + return Ok(new ErpModel { Success = -1, Message = e.Message }); + } + } ///// <summary> ///// 鎴愬搧绠辩爜鎷嗗灈鎷h揣 @@ -624,6 +725,60 @@ //杞﹂棿鍙枡 + //WCS鐢宠鎷嗗灈淇℃伅 + /// <summary> + /// 鎴愬搧绠辩爜鎷嗗灈鎷h揣 + /// </summary> + /// <param name="model">鍏ュ簱鍗曚俊鎭�</param> + /// <returns></returns> + [AllowAnonymous] + [HttpPost] + public IActionResult ResultBoxInfoCheckWcs(BoxInfoCheck model) + { + var logStr = $@".\log\WCS\WCS鐢宠鎷嗗灈鎵樼洏淇℃伅" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + try + { + RequestBoxInfoCheck list = _exNoticeSvc.BoxInfoCheckWcs(model); + return Ok(new { Success = 1,Message = "鎷嗗灈淇℃伅鑾峰彇鎴愬姛",data = list}); + } + catch (Exception e) + { + LogFile.SaveLogToFile($"WCS鐢宠鎵樼洏鎷嗗灈寮傚父杩斿洖锛�( {e.Message} ),", logStr); + + return Ok(new ErpModel { Success = -1, Message = e.Message}); + } + + } + + + /// <summary> + /// 鎴愬搧绠辩爜鎷嗗灈鎷h揣 + /// </summary> + /// <param name="model">鍏ュ簱鍗曚俊鎭�</param> + /// <returns></returns> + [AllowAnonymous] + [HttpPost] + public IActionResult ResultBoxInfoExportWcs(BoxInfoCheck model) + { + var logStr = $@".\log\WCS\WCS鐢宠鎴愬搧绠辩爜鎷嗗灈鎷h揣淇℃伅" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + try + { + //杩斿洖鍑哄簱鍒嗘嫞瑁呰溅鍙� + var list = _exNoticeSvc.BoxInfoExportWcs(model.BoxNo); + return Ok(new { Success = "1", Message = "鎴愬搧绠辩爜鎷嗗灈鎷h揣鎴愬姛", loadubgAddre = list }); + } + catch (Exception e) + { + LogFile.SaveLogToFile($"WCS鐢宠鎴愬搧绠辩爜鎷嗗灈鎷h揣寮傚父杩斿洖锛�( {e.Message} ),", logStr); + + return Ok(new { Success = "-1", Message = e.Message, loadubgAddre ="" }); + } + + } + + + + #endregion #region AGV @@ -632,10 +787,10 @@ /// AGV 鎵ц鍥炶皟鐨勬柟娉曪紝鍖呭惈浠诲姟寮�濮嬶紝璧板嚭鍌ㄤ綅锛屼换鍔″畬鎴愬強浠诲姟鍙栨秷銆� /// 鍙栨秷閫氱煡涓轰换鍔″崟锛屽叾浠栭�氱煡涓哄崟涓换鍔$粍鎴栧瓙浠诲姟銆傛敞鎰忥細鏄惁閫氱煡闇�瑕佸湪浠诲姟妯℃澘閰嶇疆 /// </summary> + /// <param name="model">鍏ュ簱鍗曚俊鎭�</param> /// <returns></returns> - /// <exception cref="Exception"></exception> [HttpPost] - public IActionResult AgvCallback(AgvContinueTask model) + public IActionResult AgvCallback(AgvTaskDto model) { try { @@ -646,38 +801,92 @@ //鎺ユ敹鏃堕棿 var time1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - var orderType = _taskSvc.GetTaskOrderType(model.TaskCode);// 鍒ゆ柇鍗曟嵁绫诲瀷鍏ュ嚭绉� + + //娴嬭瘯鎺ュ彛鐢� + var orderType = _taskSvc.GetTaskOrderType(model.TaskCode, "0");// 鍒ゆ柇鍗曟嵁绫诲瀷鍏ュ嚭绉� var taskType = _taskSvc.GetTaskType(model.TaskCode);//鏍规嵁浠诲姟鍙疯幏鍙栦换鍔$被鍨� switch (orderType) { case "0"://鍏ュ簱浠诲姟鎵ц + if (model.Method == "mid") //AGV鍒拌揪鍏ュ簱鍙o紝璇锋眰鏀捐揣 + { + //涓嬪彂WCS鏀捐揣璇锋眰 + var ret = _taskSvc.GetWcsPuttype(model.TaskCode,_config.WcsHost + _config.HttpInRequest); + if (ret.Contains("-1")) + { + logStr = $@".\log\WCS\浠诲姟鍙嶉" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + LogFile.SaveLogToFile($"鏀捐揣璇锋眰WCS澶辫触锛屽弽棣堟墽琛岄�氱煡锛�( {model.CurrentCallCode} ),", logStr); + return Ok(new OutCommanAgvDto { Code = "1", Message = "澶辫触", ReqCode = model.ReqCode }); + } + } + else if (model.Method == "end")//AGV鏀捐揣鍒板叆搴撳彛瀹屾垚 + { + _stockSvc.ArriveFinish(model.TaskCode,_config.WcsHost + _config.HttpInFinish); + } + + break; + case "1"://鍑哄簱浠诲姟鎵ц + _stockSvc.SoFinish(model.TaskCode,_config.MesHost + _config.MesBeiLiaoUrl); + break; + case "2"://鐩樺簱浠诲姟鎵ц + case "3"://绉诲簱浠诲姟鎵ц - return Ok(new OutCommanAgvDto { Code = "0", Message = "鎴愬姛", ReqCode = model.ReqCode }); + _stockSvc.MoveFinish(model.TaskCode, _config.MesHost + _config.MesBeiLiaoUrl); + break; + // return Ok(new OutCommanAgvDto { Code = "0", Message = "鎴愬姛", ReqCode = model.ReqCode }); default: return Ok(new OutCommanAgvDto { Code = "1", Message = "澶辫触", ReqCode = model.ReqCode }); } + return Ok(new OutCommanAgvDto { Code = "0", Message = "鎴愬姛", ReqCode = model.ReqCode }); } catch (Exception ex) { - return Ok(new WcsModel + return Ok(new OutCommanAgvDto { - StatusCode = -1, - Msg = ex.Message + Code = "1", + Message = ex.Message }); } } + /// <summary> + /// 浠诲姟缁х画鎵ц鎺ュ彛 + /// 璋冪敤AGV浠诲姟妯℃澘continueTask锛學CS璋冪敤鎺ュ彛杩斿洖璇ュ伐浣嶅彲鏀句俊鍙� + /// </summary> + /// <param name="model">鍏ュ簱鍙d俊鎭�</param> + /// <returns></returns> + [HttpPost] + public IActionResult AgcontinueTask(PutModel model) + { + try + { + //璁板綍log + var logStr = $@".\log\WCS\浠诲姟鍙嶉" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + var jsonData = JsonConvert.SerializeObject(model); + LogFile.SaveLogToFile($"WCS浠诲姟鍙嶉鎵ц閫氱煡锛�( {jsonData} ),", logStr); + + //涓嬪彂AGV缁х画鎵ц + _pdaCrServer.AgvContinue(model.TaskNo,_config.AgvHost+_config.ContinueTask); + + + return Ok(new HttpReturnModel { Success = "0", Message = "鎴愬姛"}); + + } + catch (Exception ex) + { + return Ok(new HttpReturnModel { Success = "1", Message = ex.ToString() }); + throw ex; + } + } + #endregion - - #endregion - #region PDA -- Gitblit v1.8.0