From ac85d00b1c88e0088c9f6f23c09a4ed87415ad38 Mon Sep 17 00:00:00 2001 From: yyk <2336760928@qq.com> Date: 星期四, 18 七月 2024 15:54:39 +0800 Subject: [PATCH] 修改库存信息接口及页面。 --- Wms/Wms/Controllers/UpApiController.cs | 114 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 95 insertions(+), 19 deletions(-) diff --git a/Wms/Wms/Controllers/UpApiController.cs b/Wms/Wms/Controllers/UpApiController.cs index ab24289..b966b0b 100644 --- a/Wms/Wms/Controllers/UpApiController.cs +++ b/Wms/Wms/Controllers/UpApiController.cs @@ -14,6 +14,14 @@ using Model.ModelVm.BllCheckVm; using WMS.DAL; using Microsoft.AspNetCore.Authorization; +using Utility; +using System.Collections.Generic; +using System.Reflection.Emit; +using System.Linq; +using System.Text; +using Newtonsoft.Json.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; namespace Wms.Controllers { @@ -30,7 +38,7 @@ private readonly IArrivalNoticeServer _arrivalNoticeSvc; private readonly IStockCheckServer _stockCheckSvc;//鐩樼偣鍗昐vc private readonly IProcurePlanServer _procurePlanSvc;//閲囪喘鍗昐vs - public UpApiController(IOptions<ApiUrlConfig> setting,IExportNoticeServer exNoticeSvc,IArrivalNoticeServer arrivalNoticeServer,IStockCheckServer stockCheckSvc, IProcurePlanServer procurePlanSvc) + public UpApiController(IOptions<ApiUrlConfig> setting, IExportNoticeServer exNoticeSvc, IArrivalNoticeServer arrivalNoticeServer, IStockCheckServer stockCheckSvc, IProcurePlanServer procurePlanSvc) { _config = setting.Value; _exNoticeSvc = exNoticeSvc; @@ -77,7 +85,7 @@ /// <param name="model">鍏ュ簱鍗曞彿</param> /// <returns></returns> [HttpPost] - public IActionResult FinishAsn(IdVm model) + public IActionResult FinishAsn(IdVm model) { try { @@ -124,7 +132,7 @@ return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); } - _arrivalNoticeSvc.ByPdaFinish(model.Code, model.Code.Substring(0,2) == "AS" ? _config.ErpHost + _config.AsnFinishUrl : _config.ErpHost + _config.SoFinishUrl, int.Parse(userId)); + _arrivalNoticeSvc.ByPdaFinish(model.Code, model.Code.Substring(0, 2) == "AS" ? _config.ErpHost + _config.AsnFinishUrl : _config.ErpHost + _config.SoFinishUrl, int.Parse(userId)); return Ok(new { code = 0, count = 0, msg = "鍗曟嵁澶嶆牳骞朵笂浼犳垚鍔�" }); } @@ -200,7 +208,7 @@ /// <param name="model"></param> /// <returns></returns> [HttpPost] - public IActionResult FinishCr(AdjustStockCheckVm model) + public async Task<IActionResult> FinishCr(AdjustStockCheckVm model) { try { @@ -215,27 +223,24 @@ { return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); } - bool bolls = false; + //bool bolls = false; if (model.Origin == "0") { - bolls = _stockCheckSvc.StockAdjust(model.Id, int.Parse(userId)); + await _stockCheckSvc.StockAdjust(model.Id); } else { - bolls = _stockCheckSvc.StockAdjustAuto(model.Id, int.Parse(userId)); + await _stockCheckSvc.StockAdjustAuto(model.Id); } - if (bolls) - { - //绯荤粺瀵规帴鍚庢斁寮� - //var bl =_stockCheckSvc.FinishCr(model.Id,_config.ErpHost + _config.DataChangeUrl, int.Parse(userId)); - //if (bl) - //{ - return Ok(new { code = 0, count = 0, msg = "鐩樼偣鍗曡皟鏁翠笂浼犳垚鍔�" }); - //} - //return Ok(new { code = 1, count = 0, msg = "鍑哄簱鍗曞叧鍗曟垚鍔熶絾涓婁紶澶辫触" }); - } + //绯荤粺瀵规帴鍚庢斁寮� + //var bl =_stockCheckSvc.FinishCr(model.Id,_config.ErpHost + _config.DataChangeUrl, 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 = "鐩樼偣鍗曡皟鏁村け璐�" }); + //return Ok(new { code = 1, msg = "鐩樼偣鍗曡皟鏁村け璐�" }); } catch (Exception e) @@ -330,7 +335,7 @@ { SoResInfo result = _exNoticeSvc.ErpAddExportNotice(model); return Ok(result); - + } catch (Exception e) { @@ -413,6 +418,10 @@ #region 娴嬭瘯灏忔暟浣嶆暟鍊� + ///// <summary> + ///// 娴嬭瘯灏忔暟浣嶆暟鍊� + ///// </summary> + ///// <returns></returns> //[HttpGet] //public IActionResult Demo() //{ @@ -433,6 +442,73 @@ // } //} + /// <summary> + /// 娴嬭瘯楠岀鍔犲瘑 + /// </summary> + /// <returns></returns> + [ServiceFilter(typeof(ApiResponseActionFilter))] + [Verification] + [HttpPost] + public IActionResult Demo2(IdVm model) + { + var result = new ErpModel { Success = -1, Message = "" }; + try + { + //var com = new Common(); + //decimal s = 13.3450M; + //var sdf = com.GetViewVal(4, s); + result = new ErpModel { Success = -1, Message = "sdf.ToString()" }; + + return Ok(result); + } + catch (Exception e) + { + result.Message = e.Message; + return Ok(result); + } + } + + [HttpPost] + [ServiceFilter(typeof(ApiResponseActionFilter))] + [UnitOfWork] + public string Demo3(IdVm model) + { + string jsonParams = JsonConvert.SerializeObject(model); + + // 鐢熸垚鏃堕棿鎴筹紙Unix 鏃堕棿鎴筹級 + var timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(); + + // 鐢熸垚绛惧悕 + var signature = GenerateSignature(jsonParams); + + // 杈撳嚭绛惧悕 + Console.WriteLine("Generated Signature: " + signature); + return signature; + } + + private static string GenerateSignature(string jsonParams) + { + var appKey = "90170307d4184844ac2a26b431f79981"; + // 灏� JSON 瀛楃涓茶浆鎹负 JObject + JObject jObject = JObject.Parse(jsonParams); + + // 杩囨护鎺夋暟缁勭被鍨嬬殑灞炴�� + var filteredProperties = jObject.Properties() + .Where(p => p.Value.Type != JTokenType.Array) + .ToDictionary(p => p.Name, p => p.Value.ToString()); + + // 娣诲姞鏃堕棿鎴筹紙Unix 鏃堕棿鎴筹級 + var timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(); + filteredProperties.Add("timestamp", timestamp); + filteredProperties.Add("appKey", appKey); + + // 鏋勫缓寰呯鍚嶅瓧绗︿覆 + var signatureBaseString = string.Join("&", filteredProperties.OrderBy(p => p.Key).Select(p => p.Key + "=" + p.Value)); + + // 璁$畻 MD5 鍊� + var computedSignature = Md5Tools.CalcMd5(signatureBaseString); + return computedSignature; + } #endregion } } -- Gitblit v1.8.0