From b3f75becd8305056d8ec3b3b732143c387b397e7 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期三, 11 九月 2024 19:28:47 +0800 Subject: [PATCH] 规则维护更新 --- /dev/null | 70 -------------- Tiger.Model.Net/Entitys/MES/ParameterEntity/BizBasPkgRuleParameter.cs | 5 + Tiger.Api/Controllers/MES/MESController.BizBaseRule.cs | 57 +++++++++++ Tiger.IBusiness/MES/BIZ/IBasRule.cs | 3 Tiger.Business.MES/BIZ/BizBasRule.cs | 109 +++++++++++++++++++++ 5 files changed, 173 insertions(+), 71 deletions(-) diff --git a/Tiger.Api/Controllers/MES/MESController.BAS_PKG_RULE.cs b/Tiger.Api/Controllers/MES/MESController.BAS_PKG_RULE.cs deleted file mode 100644 index 136ff6a..0000000 --- a/Tiger.Api/Controllers/MES/MESController.BAS_PKG_RULE.cs +++ /dev/null @@ -1,36 +0,0 @@ -锘縰sing Microsoft.AspNetCore.Mvc; -using Rhea.Common; -using System.Threading.Tasks; -using Tiger.IBusiness; -using Tiger.Model; -using Tiger.Model.Entitys.MES.BizBasPkgRule; -using Tiger.Model.Entitys.MES.BizMesWo; -using Tiger.Model.Entitys.MES.BizMesWoBatch; - -namespace Tiger.Api.Controllers.MES -{ - public partial class MESController : ControllerBase - { - - /// <summary> - /// 淇濆瓨鍖呰瑙勫垯 - /// </summary> - /// <param name="action"></param> - /// <returns></returns> - [HttpPost] - [Route("api/[controller]/[action]")] - public async Task<IActionResult> SaveBasPkgRule([FromBody] ApiAction<BizBasPkgRuleInput> action) - { - ApiAction response = new(); - try - { - response = response.GetResponse(await DI.Resolve<IBasPkgRule>().SaveBasPkgRule(action.Data)); - } - catch (System.Exception ex) - { - response = response.GetResponse().CatchExceptionWithLog(ex); - } - return Ok(response); - } - } -} diff --git a/Tiger.Api/Controllers/MES/MESController.BizBaseRule.cs b/Tiger.Api/Controllers/MES/MESController.BizBaseRule.cs new file mode 100644 index 0000000..f12b0ea --- /dev/null +++ b/Tiger.Api/Controllers/MES/MESController.BizBaseRule.cs @@ -0,0 +1,57 @@ +锘縰sing Microsoft.AspNetCore.Mvc; +using Rhea.Common; +using System.Threading.Tasks; +using Tiger.IBusiness; +using Tiger.Model; +using Tiger.Model.Entitys.MES.BizBasPkgRule; +using Tiger.Model.Entitys.MES.BizMesWo; +using Tiger.Model.Entitys.MES.BizMesWoBatch; + +namespace Tiger.Api.Controllers.MES +{ + public partial class MESController : ControllerBase + { + + /// <summary> + /// 淇濆瓨鍖呰瑙勫垯 + /// </summary> + /// <param name="action"></param> + /// <returns></returns> + [HttpPost] + [Route("api/[controller]/[action]")] + public async Task<IActionResult> SaveBasPkgRule([FromBody] ApiAction<BizBasPkgRuleInput> action) + { + ApiAction response = new(); + try + { + response = response.GetResponse(await DI.Resolve<IBasRule>().SaveBasPkgRule(action.Data)); + } + catch (System.Exception ex) + { + response = response.GetResponse().CatchExceptionWithLog(ex); + } + return Ok(response); + } + + /// <summary> + /// 淇濆瓨鐗╂枡鏉$爜瑙勫垯 + /// </summary> + /// <param name="action"></param> + /// <returns></returns> + [HttpPost] + [Route("api/[controller]/[action]")] + public async Task<IActionResult> SaveBasItemRule([FromBody] ApiAction<BizBasItemRuleInput> action) + { + ApiAction response = new(); + try + { + response = response.GetResponse(await DI.Resolve<IBasRule>().SaveBasItemRule(action.Data)); + } + catch (System.Exception ex) + { + response = response.GetResponse().CatchExceptionWithLog(ex); + } + return Ok(response); + } + } +} diff --git a/Tiger.Business.MES/BIZ/BAS_PKG_RULE.cs b/Tiger.Business.MES/BIZ/BAS_PKG_RULE.cs deleted file mode 100644 index 6cb1275..0000000 --- a/Tiger.Business.MES/BIZ/BAS_PKG_RULE.cs +++ /dev/null @@ -1,70 +0,0 @@ -锘縰sing Tiger.Model; -using SqlSugar; -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Text; -using System.Threading.Tasks; -using Rhea.Common; -using System.Net; -using System.Linq; -using Newtonsoft.Json; -using Tiger.IBusiness; -using Microsoft.AspNetCore.Http; -using Tiger.Model.Entitys.MES.BizMesWoBatch; -using Tiger.Model.Entitys.MES.BizMesWo; -using Tiger.Model.Entitys.MES.BizBasPkgRule; - -namespace Tiger.Business.MES -{ - public partial class BizBasPkgRule : IBasPkgRule - { - /// <summary> - /// 淇濆瓨鍖呰瑙勫垯锛屽寘鎷槑缁嗗拰閲嶉噺鑼冨洿 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - public async Task<ApiAction> SaveBasPkgRule(BizBasPkgRuleInput input) - { - var result = new ApiAction(); - try - { - var db = Biz.Db; - var dbTran = db.UseTran(() => - { - //if (input.PkgRule!=null) - //{ - // var y = db.Storageable(input.PkgRule) - // .WhereColumns(t => new { t.ID, t.GHOST_ROW }) - // .ToStorage(); - // y.AsInsertable.ExecuteCommand(); - // y.AsUpdateable.ExecuteCommand(); - //} - - var z = db.Storageable(input.PkgDtl) - .WhereColumns(t => new { t.ID, t.GHOST_ROW }) - .ToStorage(); - z.AsInsertable.ExecuteCommand(); - z.AsUpdateable.ExecuteCommand(); - - - var o = db.Storageable(input.PkgProd) - .WhereColumns(t => new { t.ID, t.GHOST_ROW }) - .ToStorage(); - o.AsInsertable.ExecuteCommand(); - o.AsUpdateable.ExecuteCommand(); - }); - if (!dbTran.IsSuccess) - { - result.IsSuccessed = false; - result.Message = $"淇濆瓨鍖呰瑙勫垯寮傚父"; - } - } - catch (Exception ex) - { - result.CatchExceptionWithLog(ex, "淇濆瓨鍖呰瑙勫垯寮傚父"); - } - return await Task.FromResult(result); - } - } -} diff --git a/Tiger.Business.MES/BIZ/BizBasRule.cs b/Tiger.Business.MES/BIZ/BizBasRule.cs new file mode 100644 index 0000000..6be57a4 --- /dev/null +++ b/Tiger.Business.MES/BIZ/BizBasRule.cs @@ -0,0 +1,109 @@ +锘縰sing Tiger.Model; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using Rhea.Common; +using System.Net; +using System.Linq; +using Newtonsoft.Json; +using Tiger.IBusiness; +using Microsoft.AspNetCore.Http; +using Tiger.Model.Entitys.MES.BizMesWoBatch; +using Tiger.Model.Entitys.MES.BizMesWo; +using Tiger.Model.Entitys.MES.BizBasPkgRule; + +namespace Tiger.Business.MES +{ + public partial class BizBasRule : IBasRule + { + /// <summary> + /// 淇濆瓨鐗╂枡鏉$爜瑙勫垯 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + public async Task<ApiAction> SaveBasItemRule(BizBasItemRuleInput input) + { + var result = new ApiAction(); + try + { + var ItemCusts = input.ItemCusts.Select(q => q.ID).ToList(); + List<BAS_ITEM_CUST> list = await Biz.Db.Queryable<BAS_ITEM_CUST>().Where(q => !SqlFunc.ContainsArray(ItemCusts, q.ID)).ToListAsync(); + var db = Biz.Db; + var dbTran = db.UseTran(() => + { + var z = db.Storageable(input.ItemCusts) + .WhereColumns(t => new { t.ID, t.GHOST_ROW }) + .ToStorage(); + z.AsInsertable.ExecuteCommand(); + z.AsUpdateable.ExecuteCommand(); + + db.Deleteable(list).ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.Message = $"淇濆瓨鐗╂枡鏉$爜瑙勫垯寮傚父"; + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "淇濆瓨鐗╂枡鏉$爜瑙勫垯寮傚父"); + } + return result; + } + + /// <summary> + /// 淇濆瓨鍖呰瑙勫垯锛屽寘鎷槑缁嗗拰閲嶉噺鑼冨洿 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + public async Task<ApiAction> SaveBasPkgRule(BizBasPkgRuleInput input) + { + var result = new ApiAction(); + try + { + var pkgProds = input.PkgProd.Select(q => q.ID).ToList(); + List<BAS_PKG_PROD> listPrd = await Biz.Db.Queryable<BAS_PKG_PROD>().Where(q => !SqlFunc.ContainsArray(pkgProds, q.ID)).ToListAsync(); + var db = Biz.Db; + var dbTran = db.UseTran(() => + { + //if (input.PkgRule!=null) + //{ + // var y = db.Storageable(input.PkgRule) + // .WhereColumns(t => new { t.ID, t.GHOST_ROW }) + // .ToStorage(); + // y.AsInsertable.ExecuteCommand(); + // y.AsUpdateable.ExecuteCommand(); + //} + + var z = db.Storageable(input.PkgDtl) + .WhereColumns(t => new { t.ID, t.GHOST_ROW }) + .ToStorage(); + z.AsInsertable.ExecuteCommand(); + z.AsUpdateable.ExecuteCommand(); + + var o = db.Storageable(input.PkgProd) + .WhereColumns(t => new { t.ID, t.GHOST_ROW }) + .ToStorage(); + o.AsInsertable.ExecuteCommand(); + o.AsUpdateable.ExecuteCommand(); + + db.Deleteable(listPrd).ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.Message = $"淇濆瓨鍖呰瑙勫垯寮傚父"; + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "淇濆瓨鍖呰瑙勫垯寮傚父"); + } + return result; + } + } +} diff --git a/Tiger.IBusiness/MES/BIZ/IBasPkgRule.cs b/Tiger.IBusiness/MES/BIZ/IBasRule.cs similarity index 76% rename from Tiger.IBusiness/MES/BIZ/IBasPkgRule.cs rename to Tiger.IBusiness/MES/BIZ/IBasRule.cs index a410cc9..bb316ff 100644 --- a/Tiger.IBusiness/MES/BIZ/IBasPkgRule.cs +++ b/Tiger.IBusiness/MES/BIZ/IBasRule.cs @@ -10,8 +10,9 @@ namespace Tiger.IBusiness { - public interface IBasPkgRule + public interface IBasRule { public Task<ApiAction> SaveBasPkgRule(BizBasPkgRuleInput input); + public Task<ApiAction> SaveBasItemRule(BizBasItemRuleInput input); } } diff --git a/Tiger.Model.Net/Entitys/MES/ParameterEntity/BizBasPkgRuleParameter.cs b/Tiger.Model.Net/Entitys/MES/ParameterEntity/BizBasPkgRuleParameter.cs index 401af7c..4ba6b86 100644 --- a/Tiger.Model.Net/Entitys/MES/ParameterEntity/BizBasPkgRuleParameter.cs +++ b/Tiger.Model.Net/Entitys/MES/ParameterEntity/BizBasPkgRuleParameter.cs @@ -12,4 +12,9 @@ public List<BAS_PKG_DTL> PkgDtl { get; set; } public List<BAS_PKG_PROD> PkgProd { get; set; } } + + public class BizBasItemRuleInput + { + public List<BAS_ITEM_CUST> ItemCusts { get; set; } + } } -- Gitblit v1.9.3