From 0f925aa31ef78144d24878433302917c33d04c8d Mon Sep 17 00:00:00 2001
From: chengsc <Demo@DESKTOP-CPA90BF>
Date: 星期三, 23 十月 2024 08:27:39 +0800
Subject: [PATCH] 修改问题
---
Wms/Wms/Controllers/UpApiController.cs | 131 ++++++++++++++++++++++++++++++++++++-------
1 files changed, 108 insertions(+), 23 deletions(-)
diff --git a/Wms/Wms/Controllers/UpApiController.cs b/Wms/Wms/Controllers/UpApiController.cs
index 857538a..e215e71 100644
--- a/Wms/Wms/Controllers/UpApiController.cs
+++ b/Wms/Wms/Controllers/UpApiController.cs
@@ -12,6 +12,7 @@
using WMS.IBLL.IBllAsnServer;
using WMS.IBLL.IBllCheckServer;
using Model.ModelVm.BllCheckVm;
+using Microsoft.Extensions.Logging;
namespace Wms.Controllers
{
@@ -73,7 +74,7 @@
/// <param name="model">鍏ュ簱鍗曞彿</param>
/// <returns></returns>
[HttpPost]
- public IActionResult FinishAsn(IdVm model)
+ public IActionResult FinishAsn(FinshVm model)
{
try
{
@@ -88,7 +89,7 @@
{
return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
}
- _arrivalNoticeSvc.FinishAsn(model.Id, _config.ErpHost + _config.AsnFinishUrl, 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 = "鍏ュ簱鍗曞鏍稿苟涓婁紶鎴愬姛" });
}
@@ -134,7 +135,7 @@
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
- public IActionResult FinishExportNotice(IdVm model)
+ public IActionResult FinishExportNotice(FinshVm model)
{
try
{
@@ -149,7 +150,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)
@@ -223,27 +224,42 @@
[HttpPost]
public IActionResult CreateAsn(AsnInfo model)
{
- var result = new ErpModel { Success = -1, Message = "" };
+ 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);
+ 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);
}
}
@@ -256,26 +272,95 @@
[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>
+ /// <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);
+ }
+ }
+
//璐ㄦ缁撴灉涓嬪彂鎺ュ彛
--
Gitblit v1.8.0