From 5441648d49d4d9433b8e93f1c6196e47aedcf127 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Fri, 14 Mar 2025 17:39:52 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=95=B0=E6=8D=AE=E5=BA=93=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2.修改货架IP接口 --- WCS.DAL/Db/DbHelp.cs | 2 +- WCS.WebApi/Controllers/StoreInfoController.cs | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/WCS.DAL/Db/DbHelp.cs b/WCS.DAL/Db/DbHelp.cs index c0850f9..180b104 100644 --- a/WCS.DAL/Db/DbHelp.cs +++ b/WCS.DAL/Db/DbHelp.cs @@ -15,7 +15,7 @@ namespace WCS.DAL.Db /// public static SqlSugarScope db = new SqlSugarScope(new ConnectionConfig() { - ConnectionString = $"Data Source={DbPath.DataDbPath};Version=3;journal_mode=WAL;", + ConnectionString = $"Data Source={DbPath.DataDbPath};", DbType = DbType.Sqlite,//[Sqlite]安装[System.Data.SQLite]; IsAutoCloseConnection = true }, db => diff --git a/WCS.WebApi/Controllers/StoreInfoController.cs b/WCS.WebApi/Controllers/StoreInfoController.cs index b3d3abb..b06869f 100644 --- a/WCS.WebApi/Controllers/StoreInfoController.cs +++ b/WCS.WebApi/Controllers/StoreInfoController.cs @@ -223,6 +223,53 @@ namespace WCS.WebApi.Controllers }; } } + + + [Route("updateClientIp")] + [HttpPost(Name = "updateClientIp")] + public async Task updateClientIp(RequestBase request) + { + try + { + if (request.UserName != "aaa") + { + return new ResponseBase() + { + Code = 300, + Message = "用户名不对头!修改货架的IP。" + }; + } + + //获取货架 此组后端管的货架 + var shelfInfos = DbHelp.db.Queryable() + .Where(t => t.ClientIp.Contains(".225.")) + .ToList(); + shelfInfos.ForEach(t => t.ClientIp = t.ClientIp.Replace(".225.", ".210.")); + + + var moduleInfos = DbHelp.db.Queryable() + .Where(t => t.CleintIp.Contains(".225.")) + .ToList(); + moduleInfos.ForEach(t => t.CleintIp = t.CleintIp.Replace(".225.", ".210.")); + + DbHelp.db.Updateable(moduleInfos).UpdateColumns(t => new { t.CleintIp }).ExecuteCommand(); + DbHelp.db.Updateable(shelfInfos).UpdateColumns(t => new { t.ClientIp }).ExecuteCommand(); + + return new ResponseBase() + { + Code = 200, + Message = "更新库位成功" + }; + } + catch (Exception ex) + { + return new ResponseBase() + { + Code = 300, + Message = ex.Message + }; + } + } #endregion } }