From 582d7ab9eb6879f4b5f3e1b1b7d162f3d53a0e39 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期日, 27 十月 2024 14:12:32 +0800 Subject: [PATCH] Merge branch 'master' into master_ben --- Tiger.Business/MES/Biz.Route.cs | 102 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 93 insertions(+), 9 deletions(-) diff --git a/Tiger.Business/MES/Biz.Route.cs b/Tiger.Business/MES/Biz.Route.cs index 8243cd7..f1f4a08 100644 --- a/Tiger.Business/MES/Biz.Route.cs +++ b/Tiger.Business/MES/Biz.Route.cs @@ -14,6 +14,7 @@ using Tiger.Model.Entitys.WMS.DTOS; using static Tiger.Model.BIZ_MES_WO; using Tiger.Model.Entitys.MES.Position; +using System.Security.Cryptography; namespace Tiger.Business { @@ -521,11 +522,10 @@ expableOper.And(x => x.ROT_ID == item.ID); } } - if (!string.IsNullOrEmpty(input.prodCode)) - { - expable.And(x => x.PROD_CODE == input.prodCode); - expableOper.And(x => x.PROD_CODE == input.prodCode); - } + string _custCode = input.custCode ?? ""; + expable.And(x => x.PROD_CODE == input.prodCode && (x.CUST_CODE == _custCode)); + expableOper.And(x => x.PROD_CODE == input.prodCode && x.CUST_CODE == _custCode); + var exp = expable.ToExpression(); var expOper = expableOper.ToExpression(); var db = Db; @@ -645,18 +645,18 @@ var result = new ApiAction(); try { - var item = await Biz.Db.Queryable<BAS_ITEM>().ByAuth(input.options).Where(x=>x.ITEM_CODE == input.prodCode).FirstAsync(); + var item = await Biz.Db.Queryable<BAS_ITEM>().ByAuth(input.options).Where(x => x.ITEM_CODE == input.prodCode).FirstAsync(); if (item == null) { result.IsSuccessed = false; result.LocaleMsg = new($"浜у搧[{input.prodCode}]涓嶅瓨鍦紒"); return result; } - item.DEFAULT_ROUTE = input.isDefault? input.rotCode: ""; + item.DEFAULT_ROUTE = input.isDefault ? input.rotCode : ""; var db = Db; var dbTran = db.UseTran(() => { - db.Updateable(item).UpdateColumns(q=> new { q.DEFAULT_ROUTE}).ExecuteCommand(); + db.Updateable(item).UpdateColumns(q => new { q.DEFAULT_ROUTE }).ExecuteCommand(); }); if (!dbTran.IsSuccess) { @@ -901,7 +901,7 @@ { db.Insertable(routeData.acts).ExecuteCommand(); } - if (operList.Count>0) + if (operList.Count > 0) { db.Insertable(operList).ExecuteCommand(); } @@ -954,6 +954,90 @@ return await Task.FromResult(result); } #endregion + /// <summary> + /// 鑾峰彇宸ヨ壓璺嚎鏍戝舰缁撴瀯 + /// </summary> + /// <param name="prodCode"></param> + /// <param name="orgCode"></param> + /// <returns></returns> + public async Task<List<V_MES_ROUTE_PTREE>> GetRoutePTree(string prodCode, string orgCode) + { + var result = new List<V_MES_ROUTE_PTREE>(); + try + { + + SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { PROD_CODE = prodCode, ORG_CODE = orgCode }); + result = Biz.Db.Ado.UseStoredProcedure().SqlQuery<V_MES_ROUTE_PTREE>("SP_MES_GET_ROUTE_PTREE", pars);//杩斿洖List + var item = await Db.Queryable<BAS_ITEM>().Where(q => q.ITEM_CODE == prodCode).FirstAsync(); + if (item != null && !item.DEFAULT_ROUTE.IsNullOrEmpty()) + { + var pid = result.Where(q => q.code == $"DefaultRoute_{orgCode}_{prodCode}").Select(q => q.tid).FirstOrDefault(); + result.ForEach(d => + { + if (d.pid == pid && d.code == item.DEFAULT_ROUTE) + { + d.isDefault = true; + } + else + { + d.isDefault = false; + } + }); + } + } + catch (Exception ex) + { + Logger.Default.Error(ex, "淇濆瓨榛樿宸ヨ壓璺嚎鍒颁骇鍝佸紓甯�"); + } + return result; + } + + /// <summary> + /// 娣诲姞宸ュ崟宸ヨ壓璺嚎 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + public async Task<ApiAction> ProdRouteToWo(WoRotInput input) + { + var result = new ApiAction(); + try + { + //淇濆瓨鍓嶅垽鏂� + if (Db.Queryable<BIZ_MES_WO>().Any(x => x.ORDER_NO == input.wo && x.STATUS > STATUSs.Init.GetValue() && x.STATUS < STATUSs.Closed.GetValue())) { + + result.IsSuccessed = false; + result.LocaleMsg = new($"宸ュ崟[{input.wo}]鐘舵�佷笉鏄垵濮嬪寲鎴栬�呭畬鎴愶紝涓嶅彲浠ヤ慨鏀瑰伐鑹鸿矾绾匡紒"); + return result; + } + + var wo = await Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == input.wo).FirstAsync(); + wo.ROUTE_STATUS = ROUTE_STATUSs.Finish.GetValue(); + + SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { ROT_ID = input.rotId, WO = input.wo, ERR_CODE = 0, ERR_MSG = "" }); + pars[2].Direction = System.Data.ParameterDirection.Output; + pars[3].Direction = System.Data.ParameterDirection.Output; + Biz.Db.Ado.UseStoredProcedure().ExecuteCommand("SP_MES_PROD2WO", pars); + result.Data = pars[2].Value; + result.IsSuccessed = pars[2].Value.ToInt32() == 0 ? true : false; + result.LocaleMsg = new(pars[3].Value.ToString()); + + var db = Db; + var dbTran = db.UseTran(() => + { + db.Updateable(wo, input.userId).UpdateColumns(x => new { x.ROUTE_STATUS, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.LocaleMsg = new($"娣诲姞宸ュ崟宸ヨ壓璺嚎寮傚父"); + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "娣诲姞宸ュ崟宸ヨ壓璺嚎寮傚父"); + } + return result; + } } //endClass Route } //endClass Biz } -- Gitblit v1.9.3