From 1650f3fe1467d21074b597042861c46f3a8c4447 Mon Sep 17 00:00:00 2001 From: zhaowc <526854230@qq.com> Date: 星期二, 01 四月 2025 10:11:24 +0800 Subject: [PATCH] 问题修改 --- Wms/Wms/Controllers/UpApiController.cs | 354 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 301 insertions(+), 53 deletions(-) diff --git a/Wms/Wms/Controllers/UpApiController.cs b/Wms/Wms/Controllers/UpApiController.cs index 1e6feb4..c5dab11 100644 --- a/Wms/Wms/Controllers/UpApiController.cs +++ b/Wms/Wms/Controllers/UpApiController.cs @@ -12,6 +12,12 @@ using WMS.IBLL.IBllAsnServer; 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; +using Model.ModelDto.LogDto; namespace Wms.Controllers { @@ -27,24 +33,27 @@ 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 #region 璋冪敤涓婃父绯荤粺鎺ュ彛 - /// <summary> - /// 鍏ュ簱鍗曞畬鎴愬洖浼� + /// 鍏ュ簱鍗曞叧闂� /// </summary> /// <param name="model">鍏ュ簱鍗曞彿</param> /// <returns></returns> [HttpPost] - public IActionResult FinishAsn(IdVm model) + public IActionResult CloseAsn(IdVm model) { try { @@ -59,34 +68,22 @@ { return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); } - var bolls = _arrivalNoticeSvc.CloseArrivalNotice(model.Id, int.Parse(userId)); - - if (bolls == "") - { - //绯荤粺瀵规帴鍚庢斁寮� - //var bl =_ArrivalNoticeSvc.FinishAsn(model.Id,_config.ErpHost+_config.AsnFinishUrl,int.Parse(userId)); - //if (bl) - //{ - return Ok(new { code = 0, count = 0, msg = "鍏ュ簱鍗曞叧鍗曚笂浼犳垚鍔�" }); - //} - //return Ok(new { code = 1, count = 0, msg = "鍑哄簱鍗曞叧鍗曟垚鍔熶絾涓婁紶澶辫触" }); - } - return Ok(new { code = 1, msg = "鍏ュ簱鍗曞叧鍗曞け璐�" }); + _arrivalNoticeSvc.CloseArrivalNotice(model.Id, int.Parse(userId)); + return Ok(new { code = 0, count = 0, msg = "鍏ュ簱鍗曞叧鍗曟垚鍔�" }); } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } - /// <summary> - /// 瀹屾垚鍑哄簱鍗曟嵁 //鍑哄簱鍗曞叧闂弽棣� + /// 鍏ュ簱鍗曞鏍稿苟鍥炰紶 /// </summary> - /// <param name="model"></param> + /// <param name="model">鍏ュ簱鍗曞彿</param> /// <returns></returns> [HttpPost] - public IActionResult FinishExportNotice(IdVm model) + public IActionResult FinishAsn(FinshVm model) { try { @@ -101,20 +98,69 @@ { return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); } - var bolls = _exNoticeSvc.CloseExportNotice(model.Id, int.Parse(userId)); - if (bolls) + _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 = "鍏ュ簱鍗曞鏍稿苟涓婁紶鎴愬姛" }); + } + catch (Exception e) + { + return Ok(new { code = 1, msg = e.Message }); + } + } + + /// <summary> + /// 瀹屾垚/鍏抽棴鍑哄簱鍗曟嵁 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [HttpPost] + public IActionResult CloseExportNotice(IdVm model) + { + try + { + //鑾峰彇褰撳墠鐧诲綍鐨勭敤鎴稩D + var claimsIdentity = this.User.Identity as ClaimsIdentity; + if (claimsIdentity == null) { - //绯荤粺瀵规帴鍚庢斁寮� - //var bl =_exNoticeSvc.FinishSo(model.Id,_config.ErpHost + _config.SoFinishUrl, int.Parse(userId)); - //if (bl) - //{ - return Ok(new { code = 0, count = 0, msg = "鍑哄簱鍗曞叧鍗曚笂浼犳垚鍔�" }); - //} - //return Ok(new { code = 1, count = 0, msg = "鍑哄簱鍗曞叧鍗曟垚鍔熶絾涓婁紶澶辫触" }); + return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); } + var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; + if (string.IsNullOrWhiteSpace(userId)) + { + return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + } + _exNoticeSvc.CloseExportNotice(model.Id, int.Parse(userId)); - return Ok(new { code = 1, msg = "鍑哄簱鍗曞叧鍗曞け璐�" }); - + return Ok(new { code = 0, count = 0, msg = "鍑哄簱鍗曞叧鍗曟垚鍔�" }); + } + catch (Exception e) + { + return Ok(new { code = 1, msg = e.Message }); + } + } + /// <summary> + /// //鍑哄簱鍗曞鏍稿苟涓婁紶 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [HttpPost] + public IActionResult FinishExportNotice(FinshVm model) + { + try + { + //鑾峰彇褰撳墠鐧诲綍鐨勭敤鎴稩D + var claimsIdentity = this.User.Identity as ClaimsIdentity; + if (claimsIdentity == null) + { + return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + } + var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; + if (string.IsNullOrWhiteSpace(userId)) + { + return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + } + _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) { @@ -172,8 +218,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 @@ -187,27 +284,43 @@ [HttpPost] public IActionResult CreateAsn(AsnInfo model) { - var result = new ErpModel { Success = -1, Message = "" }; + // liudl Test + var result = new HttpReturnModel { Success = "-1", Message = "" }; + var logStr = ""; + if (model.Origin == "MES") + { + logStr = $@".\log\MES\鍏ュ簱鍗曚笅鍙�" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + } + else if (model.Origin == "ERP") + { + logStr = $@".\log\ERP\鍏ュ簱鍗曚笅鍙�" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + } + try { - var claimsIdentity = this.User.Identity as ClaimsIdentity; - if (claimsIdentity == null) + //log鏃ュ織璁板綍 + if (logStr != "") { - throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅"); - } - string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; - if (string.IsNullOrWhiteSpace(UserId)) - { - throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅"); + var jsonData = JsonConvert.SerializeObject(model); + LogFile.SaveLogToFile($"鍏ュ簱鍗曚笅鍙戯細( {jsonData} ),", logStr); } - result = _arrivalNoticeSvc.CreateAsn(model); - + result = _arrivalNoticeSvc.HttpCreateAsn(model, _config.WcsHost + _config.AddOrderTaskUrl); + if (logStr != "") + { + var jsonData = JsonConvert.SerializeObject(result); + LogFile.SaveLogToFile($"鍏ュ簱鍗曚笅鍙戣繑鍥炲弬鏁帮細( {jsonData} ),", logStr); + } return Ok(result); } catch (Exception e) { result.Message = e.Message; + if (logStr != "") + { + var jsonData = JsonConvert.SerializeObject(result); + LogFile.SaveLogToFile($"鍏ュ簱鍗曚笅鍙戣繑鍥炲弬鏁帮細( {jsonData} ),", logStr); + } return Ok(result); } } @@ -220,26 +333,96 @@ [HttpPost] public IActionResult CreateSo(SoInfo model) { + var logStr = ""; + if (model.Origin == "MES") + { + logStr = $@".\log\MES\鍑哄簱鍗曚笅鍙�" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + } + else if (model.Origin == "ERP") + { + logStr = $@".\log\ERP\鍑哄簱鍗曚笅鍙�" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + } + try - { - var bl = _exNoticeSvc.ErpAddExportNotice(model); - if (bl) + { + //log鏃ュ織璁板綍 + if (logStr != "") { - return Ok(new ErpModel { Success = 0, Message = "鎴愬姛"}); + var jsonData = JsonConvert.SerializeObject(model); + LogFile.SaveLogToFile($"鍑哄簱鍗曚笅鍙戯細( {jsonData} ),", logStr); } - else + + _exNoticeSvc.HttpAddExportNotice(model); + + var data = new HttpReturnModel { Success = "0", Message = "鎴愬姛" }; + + if (logStr != "") { - return Ok(new ErpModel { Success = -1, Message = "澶辫触" }); + var jsonData = JsonConvert.SerializeObject(data); + LogFile.SaveLogToFile($"鍑哄簱鍗曚笅鍙戣繑鍥炲弬鏁帮細( {jsonData} ),", logStr); } - + + return Ok(data); + + } catch (Exception e) { - return Ok(new ErpModel { Success = -1, Message = e.Message }); + var data = new HttpReturnModel { Success = "-1", Message = "澶辫触" + e.Message }; + if (logStr != "") + { + var jsonData = JsonConvert.SerializeObject(data); + LogFile.SaveLogToFile($"鍑哄簱鍗曚笅鍙戣繑鍥炲弬鏁帮細( {jsonData} ),", logStr); + } + return Ok(data); } } - //绠辩爜淇℃伅 鎵嬫寔缁勬墭鐢� (璧嬬爜鎴栬拷婧笅鍙戝埌wms) + /// <summary> + /// 閲婃斁澶囨枡鍖哄偍浣嶇姸鎬丣C24 + /// </summary> + /// <param name="model">鐘舵�佷俊鎭�</param> + /// <returns></returns> + [HttpPost] + public IActionResult UpLocate(UpLocateModel model) + { + //璁板綍log + var logStr = ""; + if (model.Origin == "MES") + { + logStr = $@".\log\MES\閲婃斁澶囨枡鍖哄偍浣嶇姸鎬�" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + } + try + { + if (logStr != "") + { + var jsonData = JsonConvert.SerializeObject(model); + LogFile.SaveLogToFile($"閲婃斁澶囨枡鍖哄偍浣嶇姸鎬侊細( {jsonData} ),", logStr); + } + _arrivalNoticeSvc.UpLocate(model.WareHouseNo, model.LocatNo); + + var data = new HttpReturnModel { Success = "0", Message = "鎴愬姛" }; + + if (logStr != "") + { + var jsonData = JsonConvert.SerializeObject(data); + LogFile.SaveLogToFile($"閲婃斁澶囨枡鍖哄偍浣嶇姸鎬佽繑鍥炲弬鏁帮細( {jsonData} ),", logStr); + } + return Ok(data); + + } + catch (Exception e) + { + var data = new HttpReturnModel { Success = "0", Message = "澶辫触锛�" + e.Message }; + if (logStr != "") + { + var jsonData = JsonConvert.SerializeObject(data); + LogFile.SaveLogToFile($"閲婃斁澶囨枡鍖哄偍浣嶇姸鎬佽繑鍥炲弬鏁帮細( {jsonData} ),", logStr); + } + return Ok(data); + } + } + //璐ㄦ缁撴灉涓嬪彂鎺ュ彛 @@ -252,6 +435,71 @@ //鍖呰淇℃伅鎺ュ彛 + /// <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); + } + + /// <summary> + /// 鏁板瓧瀛敓绯荤粺搴撳瓨璐ㄩ噺鐘舵�佸弽棣� + /// </summary> + /// <param name="model">鏉ユ簮淇℃伅</param> + /// <returns></returns> + [HttpPost] + public IActionResult ReLogData(DigitalTwinModel model) + { + + //璁板綍log + var logStr = ""; + logStr = $@".\log\鏁板瓧瀛敓\鎿嶄綔鏃ュ織淇℃伅鍙嶉" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + var jsonData = JsonConvert.SerializeObject(model); + LogFile.SaveLogToFile($"鎿嶄綔鏃ュ織淇℃伅鍙嶉锛�( {jsonData} ),", logStr); + try + { + //鑾峰彇搴撳瓨淇℃伅 + List<OperationDto> stocks = _stock.ReLogData(); + + if (stocks.Count == 0) + { + var data = new HttpReturnModel { Success = "0", Message = "褰撳墠鏃犳搷浣滀俊鎭�" }; + return Ok(data); + } + return Ok(stocks); + + } + catch (Exception e) + { + var data = new HttpReturnModel { Success = "0", Message = "澶辫触锛�" + e.Message }; + if (logStr != "") + { + jsonData = JsonConvert.SerializeObject(data); + LogFile.SaveLogToFile($"鎿嶄綔鏃ュ織淇℃伅鍙嶉锛岃繑鍥炲弬鏁帮細( {jsonData} ),", logStr); + } + return Ok(data); + } + + } + #endregion } -- Gitblit v1.8.0