From 0651efda1f08d417c82994887c68dfea2c9b4235 Mon Sep 17 00:00:00 2001 From: wxw <Administrator@DESKTOP-5BIMHQ3> Date: 星期三, 11 十二月 2024 11:28:37 +0800 Subject: [PATCH] 修改问题 --- Wms/Wms/Controllers/UpApiController.cs | 232 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 223 insertions(+), 9 deletions(-) diff --git a/Wms/Wms/Controllers/UpApiController.cs b/Wms/Wms/Controllers/UpApiController.cs index 371825e..632d00f 100644 --- a/Wms/Wms/Controllers/UpApiController.cs +++ b/Wms/Wms/Controllers/UpApiController.cs @@ -33,8 +33,9 @@ private readonly IStockCheckServer _stockCheckSvc;//鐩樼偣鍗昐vc private readonly IProcurePlanServer _procurePlanSvc;//閲囪喘鍗昐vs private readonly IRcsServer _rcsserver;//RCS鐩稿叧浠诲姟 + private readonly INoticeServer _noticeSvc;//浜屾ゼ鍗曟嵁鐩稿叧 - public UpApiController(IOptions<ApiUrlConfig> setting,IExportNoticeServer exNoticeSvc,IArrivalNoticeServer arrivalNoticeServer,IStockCheckServer stockCheckSvc, IProcurePlanServer procurePlanSvc,IRcsServer rcsserver) + public UpApiController(IOptions<ApiUrlConfig> setting,IExportNoticeServer exNoticeSvc,IArrivalNoticeServer arrivalNoticeServer,IStockCheckServer stockCheckSvc, IProcurePlanServer procurePlanSvc,IRcsServer rcsserver, INoticeServer noticeSvc) { _config = setting.Value; _exNoticeSvc = exNoticeSvc; @@ -42,7 +43,7 @@ _stockCheckSvc = stockCheckSvc; _procurePlanSvc = procurePlanSvc; _rcsserver = rcsserver; - + _noticeSvc = noticeSvc; } #endregion @@ -403,11 +404,82 @@ } } - //RCS鍙《 + #region 浜屾ゼ涓氬姟 + /// <summary> + /// RCS鍙《 + /// </summary> + /// <param name="pallmsg"></param> + /// <returns></returns> [HttpPost] public IActionResult GetPalletNo(Pallnetmsg pallmsg) { - var result = new ErpModel { Success = -1, Message = "",}; + var logStr = $@".\log\AGV\AGV鐢宠鍙《" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + var result = new ErpModel { Success = -1, Message = "", }; + try + { + var jsonData = JsonConvert.SerializeObject(pallmsg); + LogFile.SaveLogToFile($"AGV鐢宠鍙《锛�( {jsonData} ),", logStr); + + if (string.IsNullOrWhiteSpace(pallmsg.Location)) + { + result.Message = "鍙枡浣嶇疆涓虹┖锛�"; + return Ok(result); + } + if (string.IsNullOrWhiteSpace(pallmsg.Type)) + { + result.Message = "浠诲姟绫诲瀷涓虹┖锛�"; + return Ok(result); + } + _rcsserver.GetPalletNo(pallmsg ,_config.AgvHost + _config.GenAgvSchedulingTask); + result.Success = 0; + result.Message = "鍙《鎴愬姛锛�"; + return Ok(result); + } + catch (Exception e) + { + LogFile.SaveLogToFile($"AGV鐢宠鍙《寮傚父锛�( {e.Message} ),", logStr); + + result.Message = e.Message; + return Ok(result); + } + } + /// <summary> + /// 灏嗗噣妗舵敼涓鸿剰妗跺苟鎷夊埌鑴忔《鍖� + /// </summary> + /// <param name="pallmsg"></param> + /// <returns></returns> + [HttpPost] + public IActionResult ChangePalletStatus(Pallnetmsg pallmsg) + { + var result = new ErpModel { Success = -1, Message = "", }; + try + { + if (string.IsNullOrWhiteSpace(pallmsg.PalletNo)) + { + result.Message = "妗剁紪鍙蜂笉鑳戒负绌猴紒"; + return Ok(result); + } + _rcsserver.ChangePalletStatus(pallmsg.PalletNo, _config.AgvHost + _config.GenAgvSchedulingTask); + result.Success = 0; + result.Message = "鎿嶄綔鎴愬姛锛�"; + return Ok(result); + } + catch (Exception e) + { + result.Message = e.Message; + return Ok(result); + } + } + + /// <summary> + /// MES涓嬪彂娓呮礂閿佸畾鑴忔《 + /// </summary> + /// <param name="pallmsg"></param> + /// <returns></returns> + [HttpPost] + public IActionResult CleanPallet(Pallnetmsg pallmsg) + { + var result = new ErpModel { Success = -1, Message = "", }; try { if (string.IsNullOrWhiteSpace(pallmsg.Location)) @@ -415,9 +487,12 @@ result.Message = "鍙枡浣嶇疆涓虹┖锛�"; return Ok(result); } - _rcsserver.GetPalletNo(pallmsg); - - + if (string.IsNullOrWhiteSpace(pallmsg.PalletNo)) + { + result.Message = "妗跺彿涓虹┖锛�"; + return Ok(result); + } + _rcsserver.CleanPallet(pallmsg, _config.AgvHost + _config.GenAgvSchedulingTask); result.Success = 0; result.Message = "鍙《鎴愬姛锛�"; return Ok(result); @@ -429,26 +504,165 @@ } } - //RCS鐢宠鍌ㄤ綅 + /// <summary> + /// RCS鐢宠鍌ㄤ綅 + /// </summary> + /// <param name="pallmsg"></param> + /// <returns></returns> [HttpPost] public IActionResult ApplyLocatNo(Pallnetmsg pallmsg) { + var logStr = $@".\log\AGV\AGV鐢宠鍌ㄤ綅" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + var result = new ErpModel { Success = -1, Message = "" }; try { - _rcsserver.ApplyLocatNo(pallmsg); + var jsonData = JsonConvert.SerializeObject(pallmsg); + LogFile.SaveLogToFile($"AGV鐢宠鍌ㄤ綅锛�( {jsonData} ),", logStr); + + if (string.IsNullOrWhiteSpace(pallmsg.Location)) + { + result.Message = "鐢宠浣嶇疆涓虹┖锛�"; + return Ok(result); + } + if (string.IsNullOrWhiteSpace(pallmsg.Type)) + { + result.Message = "浠诲姟绫诲瀷涓虹┖锛�"; + return Ok(result); + } + if (string.IsNullOrWhiteSpace(pallmsg.PalletNo)) + { + result.Message = "鐢宠鎵樼洏鍙蜂负绌猴紒"; + return Ok(result); + } + _rcsserver.ApplyLocatNo(pallmsg, _config.AgvHost + _config.GenAgvSchedulingTask); result.Success = 0; result.Message = "鐢宠鍌ㄤ綅鎴愬姛锛�"; return Ok(result); } catch (Exception e) { + LogFile.SaveLogToFile($"AGV鐢宠鍌ㄤ綅寮傚父锛�( {e.Message} ),", logStr); result.Message = e.Message; return Ok(result); } } + /// <summary> + /// 鍏ュ簱鍗曟嵁涓嬪彂 + /// </summary> + /// <param name="model">鍏ュ簱鍗曚俊鎭�</param> + /// <returns></returns> + //[Authorize] + [HttpPost] + public IActionResult CreateAsnWork(AsnInfo model) + { + var result = new ErpModel { Success = -1, Message = "" }; + try + { + /*var claimsIdentity = this.User.Identity as ClaimsIdentity; + if (claimsIdentity == null) + { + throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅"); + } + string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; + if (string.IsNullOrWhiteSpace(UserId)) + { + throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅"); + }*/ + + result = _noticeSvc.CreateAsnWork(model); + + return Ok(result); + } + catch (Exception e) + { + result.Message = e.Message; + return Ok(result); + } + } + + /// <summary> + /// Agv浠诲姟瀹屾垚鍙嶉 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [HttpPost] + public IActionResult agvCallBack(AgvTaskDto model) + { + var result = new ErpModel { Success = -1, Message = "" }; + try + { + //璁板綍log + var logStr = $@".\log\AGV\浠诲姟鎵ц閫氱煡" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + var jsonData = JsonConvert.SerializeObject(model); + LogFile.SaveLogToFile($"浠诲姟鎵ц閫氱煡锛�( {jsonData} ),", logStr); + + if (string.IsNullOrEmpty(model.reqCode)) + { + return Ok(new AgvResultModel { code = "-1", message = "璇锋眰澶辫触锛宺eqCode鍙傛暟寮傚父", reqCode = model.reqCode }); + } + switch (model.method) + { + case "start"://浠诲姟寮�濮� + return Ok(new AgvResultModel { code = "0", message = "鎴愬姛", reqCode = model.reqCode }); + + case "outbin"://璧板嚭鍌ㄤ綅 + return Ok(new AgvResultModel { code = "0", message = "鎴愬姛", reqCode = model.reqCode }); + + case "end"://浠诲姟缁撴潫 + result = _noticeSvc.RCSFinishTask(model.reqCode, "1"); + return Ok(result); + case "cancel"://浠诲姟鍗曞彇娑� + return Ok(new AgvResultModel { code = "0", message = "鎴愬姛", reqCode = model.reqCode }); + + case "apply"://CTU鏂欑鍙栨斁鐢宠 + return Ok(new AgvResultModel { code = "0", message = "鎴愬姛", reqCode = model.reqCode }); + + default: + return Ok(new AgvResultModel { code = "-1", message = "璇锋眰澶辫触锛宮ethod浠诲姟绫诲瀷閿欒", reqCode = model.reqCode }); + } + } + catch (Exception ex) + { + return Ok(new AgvResultModel { code = "-1", message = ex.Message, reqCode = model.reqCode }); + } + } + + /// <summary> + /// 鍑哄簱鍗曟嵁涓嬪彂 + /// </summary> + /// <param name="model">鍑哄簱鍗曚俊鎭�</param> + /// <returns></returns> + //[Authorize] + [HttpPost] + public IActionResult CreateSoWork(SoInfo model) + { + try + { + /*var claimsIdentity = this.User.Identity as ClaimsIdentity; + if (claimsIdentity == null) + { + throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅"); + } + string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; + if (string.IsNullOrWhiteSpace(UserId)) + { + throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅"); + }*/ + + SoResInfo result = _noticeSvc.CreateSoWork(model); + return Ok(result); + + } + catch (Exception e) + { + return Ok(new ErpModel { Success = -1, Message = e.Message }); + } + } + #endregion + //绠辩爜淇℃伅 鎵嬫寔缁勬墭鐢� (璧嬬爜鎴栬拷婧笅鍙戝埌wms) //璐ㄦ缁撴灉涓嬪彂鎺ュ彛 -- Gitblit v1.8.0