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/UpApiController.cs | 122 ++++++++++++++++++++++++++++++++++------ 1 files changed, 104 insertions(+), 18 deletions(-) diff --git a/Wms/Wms/Controllers/UpApiController.cs b/Wms/Wms/Controllers/UpApiController.cs index ad22858..5b90b7c 100644 --- a/Wms/Wms/Controllers/UpApiController.cs +++ b/Wms/Wms/Controllers/UpApiController.cs @@ -13,11 +13,15 @@ using WMS.IBLL.IBllCheckServer; using Model.ModelVm.BllCheckVm; using Microsoft.Extensions.Logging; +using WMS.IBLL.IPdaServer; +using WMS.IBLL.IDataServer; +using Model.ModelDto.DataDto; +using System.Collections.Generic; namespace Wms.Controllers { /// <summary> - /// 涓婃父绯荤粺浜や簰ceshi + /// 涓婃父绯荤粺浜や簰 /// </summary> [Route("api/[controller]/[action]")] [ApiController] @@ -28,12 +32,16 @@ private readonly IExportNoticeServer _exNoticeSvc;//鍑哄簱鍗昐vc private readonly IArrivalNoticeServer _arrivalNoticeSvc; private readonly IStockCheckServer _stockCheckSvc;//鐩樼偣鍗昐vc - public UpApiController(IOptions<ApiUrlConfig> setting,IExportNoticeServer exNoticeSvc,IArrivalNoticeServer arrivalNoticeServer,IStockCheckServer stockCheckSvc) + private readonly IPdaCrServer _daCrSvc;//PDA + private readonly IStockServer _stock; //搴撳瓨 + public UpApiController(IOptions<ApiUrlConfig> setting, IExportNoticeServer exNoticeSvc, IArrivalNoticeServer arrivalNoticeServer, IStockCheckServer stockCheckSvc, IPdaCrServer daCrSvc, IStockServer stock) { _config = setting.Value; _exNoticeSvc = exNoticeSvc; _arrivalNoticeSvc = arrivalNoticeServer; _stockCheckSvc = stockCheckSvc; + _daCrSvc = daCrSvc; + _stock = stock; } #endregion @@ -74,7 +82,7 @@ /// <param name="model">鍏ュ簱鍗曞彿</param> /// <returns></returns> [HttpPost] - public IActionResult FinishAsn(IdVm model) + public IActionResult FinishAsn(FinshVm model) { try { @@ -89,7 +97,7 @@ { return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); } - _arrivalNoticeSvc.FinishAsn(model.Id, _config.ErpHost + _config.AsnFinishUrl, _config.MesHost + _config.MesAsnFinishUrl, _config.MesHost + _config.MesGetTokenUrl, int.Parse(userId)); + _arrivalNoticeSvc.FinishAsn(model.Id, _config.ErpHost + _config.AsnFinishUrl, _config.MesHost + _config.MesAsnFinishUrl, _config.MesHost + _config.MesGetTokenUrl, model.UserNo, model.Password, int.Parse(userId)); return Ok(new { code = 0, count = 0, msg = "鍏ュ簱鍗曞鏍稿苟涓婁紶鎴愬姛" }); } @@ -135,7 +143,7 @@ /// <param name="model"></param> /// <returns></returns> [HttpPost] - public IActionResult FinishExportNotice(IdVm model) + public IActionResult FinishExportNotice(FinshVm model) { try { @@ -150,7 +158,7 @@ { return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); } - _exNoticeSvc.FinishSo(model.Id, _config.ErpHost + _config.SoFinishUrl, int.Parse(userId)); + _exNoticeSvc.FinishSo(model.Id, _config.ErpHost + _config.SoFinishUrl, model.UserNo, model.Password, int.Parse(userId)); return Ok(new { code = 0, count = 0, msg = "鍑哄簱鍗曞鏍稿苟涓婁紶鎴愬姛" }); } catch (Exception e) @@ -209,8 +217,59 @@ } } - //绠辩爜淇℃伅 鎵嬫寔缁勬墭鐢� (鎵鐮佸悜杩芥函瑕佷俊鎭�) + //绠辩爜淇℃伅 鎵嬫寔缁勬墭鐢� (鎵鐮佸悜杩芥函瑕佷俊鎭�) + // + + /// <summary> + /// 涓嬪彂AGV璋冨害浠诲姟 + /// </summary> + /// <param name="type"></param> + /// <param name="taskno"></param> + /// <param name="positionStart"></param> + /// <param name="positionEnd"></param> + /// <returns></returns> + [HttpPost] + public IActionResult AGVTask(string type, string taskno, string positionStart, string positionEnd) + { + try + { + + OutCommanAgvDto agvRequest = _daCrSvc.AGVTask(type, taskno, positionStart, positionEnd, _config.AgvHost + _config.GenAgvSchedulingTask); + if (agvRequest.Code != "0") + { + return Ok(new { code = 1, msg = "灏忚溅浠诲姟鎵ц澶辫触" }); + } + + return Ok(new { code = 1, msg = "AGV浠诲姟涓嬪彂鎴愬姛" }); + + } + catch (Exception e) + { + return Ok(new { code = 1, msg = e.Message }); + } + } + + /// <summary> + /// 涓嬪彂AGV鍙栨秷浠诲姟 + /// </summary> + /// <param name="taskno"></param> + /// <returns></returns> + [HttpPost] + public IActionResult cancelTask(string taskno) + { + try + { + + _daCrSvc.cancelTask(taskno, _config.AgvHost + _config.CancelTask); + return Ok(new { code = 1, msg = "AGV浠诲姟鍙栨秷鎴愬姛" }); + + } + catch (Exception e) + { + return Ok(new { code = 1, msg = e.Message }); + } + } #endregion @@ -224,6 +283,7 @@ [HttpPost] public IActionResult CreateAsn(AsnInfo model) { + // liudl Test var result = new HttpReturnModel { Success = "-1", Message = "" }; var logStr = ""; if (model.Origin == "MES") @@ -234,7 +294,7 @@ { logStr = $@".\log\ERP\鍏ュ簱鍗曚笅鍙�" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; } - + try { //log鏃ュ織璁板綍 @@ -244,7 +304,7 @@ LogFile.SaveLogToFile($"鍏ュ簱鍗曚笅鍙戯細( {jsonData} ),", logStr); } - result = _arrivalNoticeSvc.HttpCreateAsn(model); + result = _arrivalNoticeSvc.HttpCreateAsn(model, _config.WcsHost + _config.AddOrderTaskUrl); if (logStr != "") { var jsonData = JsonConvert.SerializeObject(result); @@ -277,20 +337,20 @@ { logStr = $@".\log\MES\鍑哄簱鍗曚笅鍙�" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; } - else if(model.Origin == "ERP") + else if (model.Origin == "ERP") { logStr = $@".\log\ERP\鍑哄簱鍗曚笅鍙�" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; } - + try { //log鏃ュ織璁板綍 - if (logStr!="") + if (logStr != "") { var jsonData = JsonConvert.SerializeObject(model); LogFile.SaveLogToFile($"鍑哄簱鍗曚笅鍙戯細( {jsonData} ),", logStr); } - + _exNoticeSvc.HttpAddExportNotice(model); var data = new HttpReturnModel { Success = "0", Message = "鎴愬姛" }; @@ -302,12 +362,12 @@ } return Ok(data); - - + + } catch (Exception e) { - var data = new HttpReturnModel { Success = "-1", Message = "澶辫触"+e.Message }; + var data = new HttpReturnModel { Success = "-1", Message = "澶辫触" + e.Message }; if (logStr != "") { var jsonData = JsonConvert.SerializeObject(data); @@ -320,6 +380,7 @@ /// <summary> /// 閲婃斁澶囨枡鍖哄偍浣嶇姸鎬丣C24 /// </summary> + /// <param name="model">鐘舵�佷俊鎭�</param> /// <returns></returns> [HttpPost] public IActionResult UpLocate(UpLocateModel model) @@ -337,7 +398,7 @@ var jsonData = JsonConvert.SerializeObject(model); LogFile.SaveLogToFile($"閲婃斁澶囨枡鍖哄偍浣嶇姸鎬侊細( {jsonData} ),", logStr); } - _arrivalNoticeSvc.UpLocate(model.WareHouseNo,model.LocatNo); + _arrivalNoticeSvc.UpLocate(model.WareHouseNo, model.LocatNo); var data = new HttpReturnModel { Success = "0", Message = "鎴愬姛" }; @@ -347,7 +408,7 @@ LogFile.SaveLogToFile($"閲婃斁澶囨枡鍖哄偍浣嶇姸鎬佽繑鍥炲弬鏁帮細( {jsonData} ),", logStr); } return Ok(data); - + } catch (Exception e) { @@ -373,6 +434,31 @@ //鍖呰淇℃伅鎺ュ彛 + /// <summary> + /// 鏁板瓧瀛敓绯荤粺搴撳瓨璐ㄩ噺鐘舵�佸弽棣� + /// </summary> + /// <param name="model">鏉ユ簮淇℃伅</param> + /// <returns></returns> + [HttpPost] + public IActionResult ReLocateData(DigitalTwinModel model) + { + //璁板綍log + var logStr = ""; + logStr = $@".\log\鏁板瓧瀛敓\搴撲綅淇℃伅鍙婅川閲忕姸鎬佸弽棣�" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + var jsonData = JsonConvert.SerializeObject(model); + LogFile.SaveLogToFile($"搴撲綅淇℃伅鍙婅川閲忕姸鎬佸弽棣堬細( {jsonData} ),", logStr); + + //鑾峰彇搴撳瓨淇℃伅 + List<ReLocateDataModel> stocks = _stock.GetLocateList(); + + if (stocks.Count == 0) + { + var data = new HttpReturnModel { Success = "0", Message = "褰撳墠鏃犲簱瀛�" }; + return Ok(data); + } + return Ok(stocks); + } + #endregion } -- Gitblit v1.8.0