| | |
| | | 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) |
| | | { |
| | | 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) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"工单[{input.Wo.ORDER_NO}]已经存在工单批次[{_batch.BATCH_NO}]在线体[{input.WoBatch.ACT_LINE}]中状态为[{_batch.STATUS.GetEnumDesc<BIZ_MES_WO.STATUSs>()}],不能下发!"); |
| | | return result; |
| | | 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; |
| | | } |
| | | 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}]已经有批次存在线体[{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(); |
| | | }); |
| | |
| | | _woBatch.ACT_LINE = input.ActLine; |
| | | _woBatch.CHANGE_USER = input.UserId; |
| | | _woBatch.CHANGE_TIME = DateTime.Now; |
| | | _wo.STATUS = BIZ_MES_WO.STATUSs.Release.GetValue(); |
| | | } |
| | | if (!Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Where(x => x.ORDER_NO == input.WorkOrder && x.STATUS> BIZ_MES_WO_BATCH.STATUSs.Init.GetValue()).Any()) { |
| | | _wo.STATUS = BIZ_MES_WO.STATUSs.Init.GetValue(); |
| | | else |
| | | { |
| | | if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Init.GetValue() && !Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Where(x => x.ORDER_NO == input.WorkOrder && x.BATCH_NO != input.WoBatch && x.STATUS > BIZ_MES_WO_BATCH.STATUSs.Init.GetValue()).Any()) |
| | | { |
| | | _wo.STATUS = BIZ_MES_WO.STATUSs.Init.GetValue(); |
| | | } |
| | | } |
| | | } |
| | | else |
| | |
| | | { |
| | | db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.UPDATE_USER, x.UPDATE_TIME, x.CHANGE_USER, x.CHANGE_TIME }).ExecuteCommand(); |
| | | } |
| | | if (!_wo.IsNullOrEmpty() && _wo.STATUS == BIZ_MES_WO.STATUSs.Init.GetValue()) |
| | | if (!_wo.IsNullOrEmpty()) |
| | | { |
| | | db.Updateable(_wo, input.UserId).UpdateColumns(x => new { x.STATUS, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand(); |
| | | } |
| | |
| | | result.Data = ship.BusinessDate.Date == DateTime.Now.Date ? new() |
| | | { |
| | | ShipDoc = ship.ShipDoc, |
| | | ShippingQty = ship.ShipQty, |
| | | ShippingQty = ship.ShipQty.ToDouble(), |
| | | Tag = "Customer" |
| | | } : new() |
| | | { |
| | | ShipDoc = ship.ShipDoc, |
| | | ShippingQty = ship.ShipQty, |
| | | ShippingQty = ship.ShipQty.ToDouble(), |
| | | Tag = "InStoreLabel" |
| | | }; |
| | | result.LocaleMsg = new($"出货信息存在!"); |