From e561870f9644a5e80925346485fe623da678177f Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期二, 14 十月 2025 10:20:57 +0800
Subject: [PATCH] 调整WMS出库逻辑,原辅料可选择成品库出库;
---
Wms/Wms/Controllers/UpApiController.cs | 323 +++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 270 insertions(+), 53 deletions(-)
diff --git a/Wms/Wms/Controllers/UpApiController.cs b/Wms/Wms/Controllers/UpApiController.cs
index eefb118..0543cb8 100644
--- a/Wms/Wms/Controllers/UpApiController.cs
+++ b/Wms/Wms/Controllers/UpApiController.cs
@@ -24,6 +24,13 @@
using System.Threading.Tasks;
using WMS.BLL.BllPdaServer;
using WMS.IBLL.IPdaServer;
+using WMS.BLL.BllQualityServer;
+using WMS.IBLL;
+using ZXing.QrCode.Internal;
+using System.Xml.Linq;
+using WMS.IBLL.ISysServer;
+using ZXing;
+using WMS.IBLL.IBllQualityServer;
namespace Wms.Controllers
{
@@ -41,7 +48,15 @@
private readonly IStockCheckServer _stockCheckSvc;//鐩樼偣鍗昐vc
private readonly IProcurePlanServer _procurePlanSvc;//閲囪喘鍗昐vs
private readonly IPdaAsnServer _pdaAsnServer;// PDA
- public UpApiController(IOptions<ApiUrlConfig> setting, IExportNoticeServer exNoticeSvc, IArrivalNoticeServer arrivalNoticeServer, IStockCheckServer stockCheckSvc, IProcurePlanServer procurePlanSvc, IPdaAsnServer pdaAsnServer)
+ private readonly IMaterialsServer _materialSvc;//鐗╂枡Svc
+ private readonly ICustomerServer _customerSvc;//瀹㈡埛Svc
+ private readonly IQualityInspectServer _inspectSvc;//璐ㄩ噺Svc
+ private readonly IHttpServer _http;
+
+
+ private string logStr = $@".\log\SAP璧嬬爜\Sap涓嬪彂鎶ユ枃" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
+
+ public UpApiController(IOptions<ApiUrlConfig> setting, IExportNoticeServer exNoticeSvc, IArrivalNoticeServer arrivalNoticeServer, IStockCheckServer stockCheckSvc, IProcurePlanServer procurePlanSvc, IPdaAsnServer pdaAsnServer, IMaterialsServer materialSvc, ICustomerServer customerSvc,IQualityInspectServer inspectSvc, IHttpServer http)
{
_config = setting.Value;
_exNoticeSvc = exNoticeSvc;
@@ -49,7 +64,175 @@
_stockCheckSvc = stockCheckSvc;
_procurePlanSvc = procurePlanSvc;
_pdaAsnServer = pdaAsnServer;
+ _materialSvc = materialSvc;
+ _customerSvc = customerSvc;
+ _inspectSvc = inspectSvc;
+ _http = http;
}
+ #endregion
+
+ #region JC34
+ /// <summary>
+ /// 鐗╂枡涓嬪彂
+ /// </summary>
+ /// <param name="model"></param>
+ /// <returns></returns>
+ [AllowAnonymous]
+ [HttpPost]
+ public async Task<IActionResult> CreateSku(SapSkuInfoVm model)
+ {
+ var logStr = $@".\log\SAP\鐗╂枡涓绘暟鎹笅鍙�" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
+ try
+ {
+ var jsonData = JsonConvert.SerializeObject(model);
+ LogFile.SaveLogToFile($"Sap鐗╂枡涓绘暟鎹細( {jsonData} ),", logStr);;
+
+ var str = await _materialSvc.AddSkuSap(model.data);
+
+ var list = new { Success = 0, Message = "涓嬪彂鎴愬姛" };
+ if (!str.Contains("0"))
+ {
+ list = new { Success = -1, Message = str };
+ }
+
+ LogFile.SaveLogToFile($"SAP鐗╂枡涓绘暟鎹笅鍙戯細( {JsonConvert.SerializeObject(list)} ),", logStr);
+ return Ok(new { result = true, code = "1" ,message = "success" });
+ }
+ catch (Exception e)
+ {
+ return Ok(new { result = false, code = "400", message = e.Message });
+ }
+ }
+
+
+ /// <summary>
+ /// 瀹㈡埛淇℃伅鎺ユ敹
+ /// </summary>
+ /// <param name="model"></param>
+ /// <returns></returns>
+ [AllowAnonymous]
+ [HttpPost]
+ public async Task<IActionResult> CreateCustomer(SapCustomerVm model)
+ {
+ var logStr = $@".\log\SAP\瀹㈡埛渚涘簲鍟嗕富鏁版嵁鍚屾" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
+ try
+ {
+ var jsonData = JsonConvert.SerializeObject(model);
+ LogFile.SaveLogToFile($"Sap瀹㈡埛淇℃伅涓绘暟鎹細( {jsonData} ),", logStr);
+
+ var str = await _customerSvc.AddCustomerSap(model.data);
+
+ var list = new { Success = 0, Message = "涓嬪彂鎴愬姛" };
+ if (!str.Contains("0"))
+ {
+ list = new { Success = -1, Message = str };
+
+ LogFile.SaveLogToFile($"瀹㈡埛渚涘簲鍟嗕富鏁版嵁鍚屾锛�( {JsonConvert.SerializeObject(list)} ),", logStr);
+ return Ok(new { result = false, code = "400", message = str });
+ }
+ else
+ {
+ LogFile.SaveLogToFile($"瀹㈡埛渚涘簲鍟嗕富鏁版嵁鍚屾锛�( {JsonConvert.SerializeObject(list)} ),", logStr);
+
+ return Ok(new { result = true, code = "1", message = "success" });
+ }
+ }
+ catch (Exception e)
+ {
+ return Ok(new { result = false, code = "400", message = e.Message });
+ }
+ }
+
+
+ /// <summary>
+ /// 鍏ュ簱鍗曟帴鏀�
+ /// </summary>
+ /// <param name="model"></param>
+ /// <returns></returns>
+ [AllowAnonymous]
+ [HttpPost]
+ public IActionResult CreateAsn(SapAsnVm model)
+ {
+ var logStr = $@".\log\SAP\鍏ュ簱鍗曚笅鍙�" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
+ try
+ {
+ var jsonData = JsonConvert.SerializeObject(model);
+ LogFile.SaveLogToFile($"Sap鍏ュ簱鍗曟暟鎹細( {jsonData} ),", logStr);
+
+ var _result = _arrivalNoticeSvc.CreateAsn(model.data, model.@operator);
+
+ var list = new { Success = 0, Message = "涓嬪彂鎴愬姛" };
+ if (_result.Success == 0)
+ {
+ LogFile.SaveLogToFile($"Sap鍏ュ簱鍗曚笅鍙戞垚鍔燂細( {JsonConvert.SerializeObject(list)} ),", logStr);
+ return Ok(new { result = true, code = "1", message = "success" });
+ }
+ else
+ {
+ list = new { Success = -1, Message = _result.Message };
+
+ LogFile.SaveLogToFile($"Sap鍏ュ簱鍗曚笅鍙戝け璐ワ細( {JsonConvert.SerializeObject(list)} ),", logStr);
+ return Ok(new { result = false, code = "400", message = _result.Message });
+ }
+ }
+ catch (Exception e)
+ {
+ LogFile.SaveLogToFile($"Sap鍏ュ簱鍗曚笅鍙戝紓甯革細{e.Message}", logStr);
+ return Ok(new { result = false, code = "400", message = e.Message });
+ }
+ }
+
+ /// <summary>
+ /// 鍑哄簱鍗曟帴鏀�
+ /// </summary>
+ /// <param name="model"></param>
+ /// <returns></returns>
+ [AllowAnonymous]
+ [HttpPost]
+ public IActionResult CreateSo(SapSoVm model)
+ {
+ var logStr = $@".\log\SAP\鍑哄簱鍗曚笅鍙�" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
+ try
+ {
+ var jsonData = JsonConvert.SerializeObject(model);
+ LogFile.SaveLogToFile($"Sap鍑哄簱鍗曚笅鍙戯細( {jsonData} ),", logStr);
+
+ _exNoticeSvc.ErpAddExportNotice(model.data);
+
+ return Ok(new { result = true, code = "1", message = "success" });
+ }
+ catch (Exception e)
+ {
+ return Ok(new { result = false, code = "400", message = e.Message });
+ }
+ }
+
+
+ /// <summary>
+ /// 搴撳瓨璐ㄩ噺鐘舵�佹帴鏀�
+ /// </summary>
+ /// <param name="model"></param>
+ /// <returns></returns>
+ [AllowAnonymous]
+ [HttpPost]
+ public IActionResult UpQuality(SapQualityVm model)
+ {
+ var logStr = $@".\log\SAP\搴撳瓨璐ㄩ噺鐘舵�佹帴鏀�" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
+ try
+ {
+ var jsonData = JsonConvert.SerializeObject(model);
+ LogFile.SaveLogToFile($"Sap搴撳瓨璐ㄩ噺鐘舵�佷笅鍙戯細( {jsonData} ),", logStr);
+
+ _inspectSvc.InsertQualitySap(model.data);
+ return Ok(new { result = true, code = "1", message = "success" });
+ }
+ catch (Exception e)
+ {
+ return Ok(new { result = false, code = "400", message = e.Message });
+ }
+ }
+
+
#endregion
#region 璋冪敤涓婃父绯荤粺鎺ュ彛
@@ -197,7 +380,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, _config.ErpHost + _config.SoFinishUrl2, int.Parse(userId));
return Ok(new { code = 0, count = 0, msg = "鍑哄簱鍗曞鏍稿苟涓婁紶鎴愬姛" });
}
catch (Exception e)
@@ -237,7 +420,7 @@
await _stockCheckSvc.StockAdjustAuto(model.Id);
}
//绯荤粺瀵规帴鍚庢斁寮�
- //var bl =_stockCheckSvc.FinishCr(model.Id,_config.ErpHost + _config.DataChangeUrl, int.Parse(userId));
+ var bl =_stockCheckSvc.FinishCr(model.Id,_config.ErpHost + _config.DataChangeUrl, int.Parse(userId));
//if (bl)
//{
return Ok(new { code = 0, count = 0, msg = "鐩樼偣鍗曡皟鏁翠笂浼犳垚鍔�" });
@@ -268,13 +451,47 @@
{
return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠璇锋眰绠辩爜淇℃伅" });
}
- var models = _pdaAsnServer.GetFMBindBoxInfos(BoxNo);
+ var models = _pdaAsnServer.GetFMBindBoxInfos(BoxNo, _config.BoxHost + _config.GetBoxUrl);
return Ok(new { code = 0, msg = "鏍囩绠辩爜淇℃伅", data = models });
}
catch (Exception e)
{
return Ok(new { code = 1, msg = e.Message });
+ }
+ }
+
+
+ /// <summary>
+ /// 鍙戦�佽楠屽崟鎹�
+ /// </summary>
+ /// <param name="model">涓婚敭ID</param>
+ /// <returns></returns>
+ [HttpPost]
+ public IActionResult SendInspectionRequest(IdVm model)
+ {
+ try
+ {
+ 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 = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
+ }
+ var userName = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier)?.Value;
+
+ string url = _config.LimesHost + _config.SendInspection;
+ var models = _http.SendInspectionRequest(model, int.Parse(userId), url, userName);
+
+ return Ok(new HttpReturnModel { Success = "0", Message = "鍚慙imes璇烽獙鎴愬姛!", Data = models });
+ }
+ catch (Exception e)
+ {
+ return Ok(new HttpReturnModel { Success = "1", Message = e.Message });
}
}
@@ -315,59 +532,59 @@
}
}
- /// <summary>
- /// 鍏ュ簱鍗曟嵁涓嬪彂
- /// </summary>
- /// <param name="model">鍏ュ簱鍗曚俊鎭�</param>
- /// <returns></returns>
- [Authorize]
- [HttpPost]
- public IActionResult CreateAsn(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("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
- }
+ ///// <summary>
+ ///// 鍏ュ簱鍗曟嵁涓嬪彂
+ ///// </summary>
+ ///// <param name="model">鍏ュ簱鍗曚俊鎭�</param>
+ ///// <returns></returns>
+ //[Authorize]
+ //[HttpPost]
+ //public IActionResult CreateAsn(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 = _arrivalNoticeSvc.CreateAsn(model);
+ // result = _arrivalNoticeSvc.CreateAsn(model);
- return Ok(result);
- }
- catch (Exception e)
- {
- result.Message = e.Message;
- return Ok(result);
- }
- }
+ // return Ok(result);
+ // }
+ // catch (Exception e)
+ // {
+ // result.Message = e.Message;
+ // return Ok(result);
+ // }
+ //}
- /// <summary>
- /// 鍑哄簱鍗曚笅鍙戞帴鍙�
- /// </summary>
- /// <param name="model">鍑哄簱鍗曚俊鎭�</param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult CreateSo(SoInfo model)
- {
- try
- {
- SoResInfo result = _exNoticeSvc.ErpAddExportNotice(model);
- return Ok(result);
+ ///// <summary>
+ ///// 鍑哄簱鍗曚笅鍙戞帴鍙�
+ ///// </summary>
+ ///// <param name="model">鍑哄簱鍗曚俊鎭�</param>
+ ///// <returns></returns>
+ //[HttpPost]
+ //public IActionResult CreateSo(SoInfo model)
+ //{
+ // try
+ // {
+ // SoResInfo result = _exNoticeSvc.ErpAddExportNotice(model);
+ // return Ok(result);
- }
- catch (Exception e)
- {
- return Ok(new ErpModel { Success = -1, Message = e.Message });
- }
- }
+ // }
+ // catch (Exception e)
+ // {
+ // return Ok(new ErpModel { Success = -1, Message = e.Message });
+ // }
+ //}
/// <summary>
/// 杞﹂棿鍙枡
--
Gitblit v1.8.0