using 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 { /// /// 拆解包装 /// /// /// public async Task>> Submit(DoUnPackInput input) { var result = new ApiAction>(); try { var wipPkg = await Biz.Db.Queryable().Where(q => q.SN == input.SN && q.AUTH_ORG == input.AUTH_ORG).FirstAsync(); if (wipPkg == null) { result.IsSuccessed = false; result.LocaleMsg = new($"条码不存在包装中"); return result; } var wipPkgParent = await Biz.Db.Queryable().Where(q => q.SN == wipPkg.PARENT_SN && q.AUTH_ORG == input.AUTH_ORG).FirstAsync(); var db = Biz.Db; var dbTran = db.UseTran(() => { db.Updateable().SetColumns(q => q.PARENT_SN == null).Where(q => q.ID == wipPkg.ID).ExecuteCommand(); db.Updateable().SetColumns(q => q.QTY == q.QTY - 1).Where(q => q.ID == wipPkgParent.ID).ExecuteCommand(); if (!Biz.Db.Queryable().Any(q => q.PARENT_SN == wipPkg.PARENT_SN && q.SN != wipPkg.SN)) { db.Deleteable(wipPkgParent); } }); if (!dbTran.IsSuccess) { result.IsSuccessed = false; result.LocaleMsg = new($"拆解包装异常"); } result.Data = Biz.Db.Queryable().Where(q => q.PARENT_SN == wipPkgParent.SN).ToList(); } catch (Exception ex) { result.CatchExceptionWithLog(ex, "拆解包装异常"); } return result; } } }