From 5ab5e848589059becbcddc8295dd17251477c1fd Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期一, 09 九月 2024 22:53:35 +0800 Subject: [PATCH] 拆解包装 --- Tiger.Model.Net/Tiger.Model.Net.csproj | 1 Tiger.Api/Controllers/MES/MESController.DoUnPack.cs | 40 +++++++++++++ Tiger.Model.Net/Entitys/MES/ParameterEntity/DoUnPackParameter.cs | 14 ++++ Tiger.Business.MES/Common/DoUnPack.cs | 59 +++++++++++++++++++ Tiger.IBusiness/MES/Common/IDoUnPack.cs | 17 +++++ 5 files changed, 131 insertions(+), 0 deletions(-) diff --git a/Tiger.Api/Controllers/MES/MESController.DoUnPack.cs b/Tiger.Api/Controllers/MES/MESController.DoUnPack.cs new file mode 100644 index 0000000..90b9317 --- /dev/null +++ b/Tiger.Api/Controllers/MES/MESController.DoUnPack.cs @@ -0,0 +1,40 @@ +锘縰sing Microsoft.AspNetCore.Mvc; +using Rhea.Common; +using System.Threading.Tasks; +using Tiger.IBusiness; +using Tiger.Model; +using Tiger.Model.Entitys.MES.BizMesWo; +using Tiger.Model.Entitys.MES.BizMesWoBatch; +using Tiger.Model.Entitys.MES.CodeVerification; +using Tiger.Model.Entitys.MES.DoUnPack; + +namespace Tiger.Api.Controllers.MES +{ + /// <summary> + /// + /// </summary> + public partial class MESController : ControllerBase + { + + /// <summary> + /// 鎷嗚В鍖呰 + /// </summary> + /// <param name="action"></param> + /// <returns></returns> + [HttpPost] + [Route("api/[controller]/DoUnPack/Submit")] + public async Task<IActionResult> DoUnPack_Submit([FromBody] ApiAction<DoUnPackInput> action) + { + ApiAction response = new(); + try + { + response = response.GetResponse(await DI.Resolve<IDoUnPack>().Submit(action.Data)); + } + catch (System.Exception ex) + { + response = response.GetResponse().CatchExceptionWithLog(ex); + } + return Ok(response); + } + } +} diff --git a/Tiger.Business.MES/Common/DoUnPack.cs b/Tiger.Business.MES/Common/DoUnPack.cs new file mode 100644 index 0000000..2019812 --- /dev/null +++ b/Tiger.Business.MES/Common/DoUnPack.cs @@ -0,0 +1,59 @@ +锘縰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.DoUnPack; +using Tiger.Model.Entitys.MES.Position; + +namespace Tiger.Business.MES +{ + public partial class DoUnPack : IDoUnPack + { + /// <summary> + /// 鎷嗚В鍖呰 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + public async Task<ApiAction<List<MES_WIP_PKG>>> Submit(DoUnPackInput input) + { + var result = new ApiAction<List<MES_WIP_PKG>>(); + try + { + var wipPkg = await Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.SN == input.SN && q.AUTH_ORG == input.AUTH_ORG).FirstAsync(); + var wipPkgParent = await Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.SN == wipPkg.PARENT_SN && q.AUTH_ORG == input.AUTH_ORG).FirstAsync(); + var db = Biz.Db; + var dbTran = db.UseTran(() => + { + db.Updateable<WMS_ITEM_PKG>().SetColumns(q => q.PARENT_SN == null).Where(q => q.ID == wipPkg.ID).ExecuteCommand(); + db.Updateable<WMS_ITEM_PKG>().SetColumns(q => q.QTY == q.QTY - 1).Where(q => q.ID == wipPkgParent.ID).ExecuteCommand(); + if (!Biz.Db.Queryable<WMS_ITEM_PKG>().Any(q => q.PARENT_SN == wipPkg.PARENT_SN && q.SN != wipPkg.SN)) + { + db.Deleteable(wipPkgParent); + } + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.Message = $"鎷嗚В鍖呰寮傚父"; + } + result.Data = Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.PARENT_SN == wipPkgParent.SN).ToList(); + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "鎷嗚В鍖呰寮傚父"); + } + return result; + } + } +} diff --git a/Tiger.IBusiness/MES/Common/IDoUnPack.cs b/Tiger.IBusiness/MES/Common/IDoUnPack.cs new file mode 100644 index 0000000..9f63654 --- /dev/null +++ b/Tiger.IBusiness/MES/Common/IDoUnPack.cs @@ -0,0 +1,17 @@ +锘縰sing Rhea.Common; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tiger.Model; +using Tiger.Model.Entitys.MES.DoUnPack; + +namespace Tiger.IBusiness +{ + public interface IDoUnPack + { + public Task<ApiAction<List<MES_WIP_PKG>>> Submit(DoUnPackInput input); + } +} diff --git a/Tiger.Model.Net/Entitys/MES/ParameterEntity/DoUnPackParameter.cs b/Tiger.Model.Net/Entitys/MES/ParameterEntity/DoUnPackParameter.cs new file mode 100644 index 0000000..3fda920 --- /dev/null +++ b/Tiger.Model.Net/Entitys/MES/ParameterEntity/DoUnPackParameter.cs @@ -0,0 +1,14 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tiger.Model.Entitys.MES.DoUnPack +{ + public class DoUnPackInput + { + public string SN { get; set; } + public string AUTH_ORG { get; set; } + } +} diff --git a/Tiger.Model.Net/Tiger.Model.Net.csproj b/Tiger.Model.Net/Tiger.Model.Net.csproj index 2f65ec2..3cc8b8d 100644 --- a/Tiger.Model.Net/Tiger.Model.Net.csproj +++ b/Tiger.Model.Net/Tiger.Model.Net.csproj @@ -157,6 +157,7 @@ <Compile Include="Entitys\MES\MES_WO_OPER.cs" /> <Compile Include="Entitys\MES\node.cs" /> <Compile Include="Entitys\MES\ParameterEntity\BizMesWoBatchParameter.cs" /> + <Compile Include="Entitys\MES\ParameterEntity\DoUnPackParameter.cs" /> <Compile Include="Entitys\MES\ParameterEntity\CodeVerificationParameter.cs" /> <Compile Include="Entitys\MES\ParameterEntity\BizMesWoParameter.cs" /> <Compile Include="Entitys\MES\ParameterEntity\BasLabelTempParameter.cs" /> -- Gitblit v1.9.3