| | |
| | | using Tiger.Model.MES.Yada; |
| | | using static Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser; |
| | | using Tiger.Model.Minsun; |
| | | using Tiger.Model.Entitys.MES.U9C; |
| | | |
| | | namespace Tiger.Business.MES |
| | | { |
| | |
| | | return result; |
| | | } |
| | | var batchs = await Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Where(x => x.ORDER_NO == input.Wo.ORDER_NO).ToListAsync(); |
| | | if ((batchs.Count > 0 && batchs.Sum(x => x.PLAN_QTY) + input.WoBatch.PLAN_QTY > _wo.PLAN_QTY) || input.WoBatch.PLAN_QTY > _wo.PLAN_QTY) |
| | | if (batchs.Count > 0) |
| | | { |
| | | if ((batchs.Sum(x => x.PLAN_QTY) + input.WoBatch.PLAN_QTY > _wo.PLAN_QTY) || input.WoBatch.PLAN_QTY > _wo.PLAN_QTY) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"工单下发的数量超过工单计划数量,不能下发!"); |
| | | return result; |
| | | } |
| | | var _batch = Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Where(x => x.ORDER_NO == input.Wo.ORDER_NO && x.ACT_LINE == input.WoBatch.ACT_LINE && x.STATUS < BIZ_MES_WO.STATUSs.Closed.GetValue()).First(); |
| | | if (_batch != null) |
| | | if (batchs.Any(x => x.ORDER_NO == input.Wo.ORDER_NO && x.ACT_LINE == input.WoBatch.ACT_LINE && x.STATUS < BIZ_MES_WO.STATUSs.Closed.GetValue())) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"工单[{input.Wo.ORDER_NO}]已经存在工单批次[{_batch.BATCH_NO}]在线体[{input.WoBatch.ACT_LINE}]中状态为[{_batch.STATUS.GetEnumDesc<BIZ_MES_WO.STATUSs>()}],不能下发!"); |
| | | result.LocaleMsg = new($"工单[{input.Wo.ORDER_NO}]已经有批次存在线体[{input.WoBatch.ACT_LINE}]中,而且状态不为关闭,不能下发!"); |
| | | return result; |
| | | } |
| | | if (batchs.Any(x => x.ORDER_NO == input.Wo.ORDER_NO && x.STATUS == BIZ_MES_WO.STATUSs.Init.GetValue() && SqlFunc.DateIsSame(x.PLAN_DATE, DateTime.Now))) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"工单[{input.Wo.ORDER_NO}]已经有批次存在计划日期相同,而且状态为[初始化],请转到工单批次中下发!"); |
| | | return result; |
| | | } |
| | | } |
| | | //WoContext.RemoveBatch(input.WoBatch.BATCH_NO); |
| | | input.WoBatch.PLAN_DATE = DateTime.Now; |
| | | input.Wo.PLAN_DATE += input.Wo.PLAN_DATE.Contains(input.WoBatch.PLAN_DATE.ToString("yyyy-MM-dd")) ? "" : $",{input.WoBatch.PLAN_DATE.ToString("yyyy-MM-dd")}"; |
| | | input.Wo.ACT_LINE = input.WoBatch.ACT_LINE; |
| | | input.Wo.RELEASE_TIME = DateTime.Now; |
| | | input.Wo.RELEASE_USER = input.WoBatch.UPDATE_USER; |
| | |
| | | .WhereColumns(t => new { t.ORDER_NO, t.GHOST_ROW }) |
| | | .ToStorage(); |
| | | y.AsInsertable.ExecuteCommand(); |
| | | y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); |
| | | y.AsUpdateable.IgnoreColumns(x => x.ID).UpdateColumns(q=>new { q.PLAN_DATE,q.ACT_LINE,q.RELEASE_TIME,q.RELEASE_USER,q.UPDATE_TIME,q.UPDATE_USER}).ExecuteCommand(); |
| | | |
| | | db.Insertable(input.WoBatch).ExecuteCommand(); |
| | | }); |