服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-09-12 ff0ef3ea134660a9542a50f675f4c5aafa8af223
Tiger.Business.MES/BIZ/BIZ_MES_WO.cs
@@ -13,6 +13,7 @@
using Microsoft.AspNetCore.Http;
using Tiger.Model.Entitys.MES.BizMesWoBatch;
using Tiger.Model.Entitys.MES.BizMesWo;
using Tiger.Model.Entitys.MES.Position;
namespace Tiger.Business.MES
{
@@ -103,7 +104,6 @@
            var result = new ApiAction();
            try
            {
                WoContext.RemoveBatch(input.WoBatch.BATCH_NO);
                //保存前的判断,并生成批次号
                var _wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == input.Wo.ORDER_NO).FirstAsync();
                //if (_wo.STATUS > (int)BIZ_MES_WO.STATUSs.Init)
@@ -125,6 +125,14 @@
                    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()))
                {
                    result.IsSuccessed = false;
                    result.LocaleMsg = new($"工单批次在线体[{input.WoBatch.ACT_LINE}]中状态为[{input.WoBatch.STATUS.GetEnumDesc<BIZ_MES_WO.STATUSs>()}],不能下发!");
                    return result;
                }
                WoContext.RemoveBatch(input.WoBatch.BATCH_NO);
                var _batchWos = await Biz.Db.Queryable<V_MES_WO_BATCH>().Where(x => x.ORDER_NO == input.WoBatch.ORDER_NO).ToListAsync();
                if (_batchWos.Count > 0)
                {
@@ -187,7 +195,7 @@
                var db = Biz.Db;
                var dbTran = db.UseTran(() =>
                {
                    db.Updateable(_wo, input.UserId).ExecuteCommand();
                    db.Updateable(_wo, input.UserId).UpdateColumns(x => new { x.STATUS }).ExecuteCommand();
                });
                if (!dbTran.IsSuccess)
                {
@@ -201,5 +209,50 @@
            }
            return result;
        }
        /// <summary>
        /// 更新工单批次状态
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<ApiAction> UpdateWoBatchStatus(BizMesWoInput input)
        {
            var result = new ApiAction();
            try
            {
                //保存前的判断
                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()) {
                        WoContext.RemoveBatch(input.WoBatch);
                    }
                }
                else
                {
                    result.IsSuccessed = false;
                    result.LocaleMsg = new($"工单批次[{input.WoBatch}]不存在");
                    return result;
                }
                var db = Biz.Db;
                var dbTran = db.UseTran(() =>
                {
                    db.Updateable(_woBatch, input.UserId).UpdateColumns(x=> new { x.STATUS}).ExecuteCommand();
                });
                if (!dbTran.IsSuccess)
                {
                    result.IsSuccessed = false;
                    result.LocaleMsg = new($"更新工单批次状态异常");
                }
            }
            catch (Exception ex)
            {
                result.CatchExceptionWithLog(ex, "更新工单批次状态异常");
            }
            return result;
        }
    }
}