服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-09-29 c88f9369513c600533934b9e47dea014d644c80e
Tiger.Business.MES/BIZ/BIZ_MES_WO.cs
@@ -121,16 +121,17 @@
                    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)
                if ((batchs.Count > 0 && 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 (Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Any(x => x.ORDER_NO == input.Wo.ORDER_NO && x.ACT_LINE == input.WoBatch.ACT_LINE && x.STATUS> BIZ_MES_WO.STATUSs.Imported.GetValue() && x.STATUS< BIZ_MES_WO.STATUSs.Closed.GetValue()))
                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.WoBatch.ACT_LINE}]中状态为[{input.WoBatch.STATUS.GetEnumDesc<BIZ_MES_WO.STATUSs>()}],不能下发!");
                    result.LocaleMsg = new($"工单[{input.Wo.ORDER_NO}]已经存在工单批次[{_batch.BATCH_NO}]在线体[{input.WoBatch.ACT_LINE}]中状态为[{_batch.STATUS.GetEnumDesc<BIZ_MES_WO.STATUSs>()}],不能下发!");
                    return result;
                }
                WoContext.RemoveBatch(input.WoBatch.BATCH_NO);
@@ -197,7 +198,7 @@
                var db = Biz.Db;
                var dbTran = db.UseTran(() =>
                {
                    db.Updateable(_wo, input.UserId).UpdateColumns(x => new { x.STATUS }).ExecuteCommand();
                    db.Updateable(_wo, input.UserId).UpdateColumns(x => new { x.STATUS, x.ROUTE_STATUS }).ExecuteCommand();
                });
                if (!dbTran.IsSuccess)
                {
@@ -224,12 +225,20 @@
            try
            {
                //保存前的判断
                var _wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == input.WorkOrder).FirstAsync();
                var _woBatch = await Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Where(x => x.BATCH_NO == input.WoBatch).FirstAsync();
                if (_woBatch != null)
                {
                    _woBatch.STATUS = input.Status < 0 ? _woBatch.STATUS : input.Status;
                    if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Paused.GetValue()) {
                    if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Paused.GetValue())
                    {
                        WoContext.RemoveBatch(input.WoBatch);
                    }
                    if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Release.GetValue() && Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Any(x => x.ORDER_NO == input.WorkOrder && x.BATCH_NO != input.WoBatch && x.ACT_LINE == _woBatch.ACT_LINE && BIZ_MES_WO.STATUSs.Imported.GetValue() < x.STATUS && x.STATUS < BIZ_MES_WO.STATUSs.Closed.GetValue()))
                    {
                        result.IsSuccessed = false;
                        result.LocaleMsg = new($"工单存在未完成的工单批次,不能下发");
                        return result;
                    }
                }
                else
@@ -242,7 +251,7 @@
                var db = Biz.Db;
                var dbTran = db.UseTran(() =>
                {
                    db.Updateable(_woBatch, input.UserId).UpdateColumns(x=> new { x.STATUS}).ExecuteCommand();
                    db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS }).ExecuteCommand();
                });
                if (!dbTran.IsSuccess)
                {
@@ -274,7 +283,14 @@
                    result.LocaleMsg = new($"工单号不能为空!");
                    return result;
                }
                List<BAS_LABEL_VAR_WO> varWoList = new();
                if (File.Exists(input.LABEL_VIEW_PATH))
                {
                    string imageFileName = Path.GetFileNameWithoutExtension(input.LABEL_VIEW_PATH);
                    string? path = Path.GetDirectoryName(input.LABEL_VIEW_PATH);
                    input.LABEL_VIEW_PATH = $"{path}//Temp//{imageFileName}.png";
                    varWoList = await Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(x => x.LABEL_ID == input.LABEL_ID && x.WORK_ORDER == input.WORK_ORDER).ToListAsync();
                }
                var db = Biz.Db;
                var dbTran = db.UseTran(() =>
                {
@@ -283,6 +299,11 @@
                       .ToStorage();
                    y.AsInsertable.ExecuteCommand();
                    y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
                    if (varWoList.Count > 0)
                    {
                        db.Updateable(varWoList).UpdateColumns(q => q.LABEL_VIEW_PATH).ExecuteCommand();
                    }
                });
                if (!dbTran.IsSuccess)
                {
@@ -294,7 +315,7 @@
            {
                result.CatchExceptionWithLog(ex, "更新工单模板变量异常");
            }
            return await Task.FromResult(result);
            return result;
        }
        /// <summary>
@@ -315,7 +336,8 @@
                    return result;
                }
                var labeltemp = Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE.Equals(input.LabelId) || q.ID.Equals(input.LabelId)).First();
                if (labeltemp == null) {
                if (labeltemp == null)
                {
                    result.IsSuccessed = false;
                    result.LocaleMsg = new($"模板不存在!");
                    return result;