服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-10-13 53f33d1f1575f5ce60fb3e6230e569ba4cc0dba5
Tiger.Business.MES/BIZ/BIZ_MES_WO.cs
@@ -108,12 +108,18 @@
            {
                //保存前的判断,并生成批次号
                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)
                //{
                //    result.IsSuccessed = false;
                //    result.LocaleMsg = new($"工单不是初始化状态,不能下发!");
                //    return result;
                //}
                if (_wo.IsNullOrEmpty())
                {
                    result.IsSuccessed = false;
                    result.LocaleMsg = new($"工单不存在,不能下发!");
                    return result;
                }
                if (_wo.ROUTE_STATUS != BIZ_MES_WO.ROUTE_STATUSs.Finish.GetValue())
                {
                    result.IsSuccessed = false;
                    result.LocaleMsg = new($"工单工艺路线未配置,不能下发!");
                    return result;
                }
                if (_wo.STATUS > (int)BIZ_MES_WO.STATUSs.Working)
                {
                    result.IsSuccessed = false;
@@ -134,7 +140,7 @@
                    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);
                //WoContext.RemoveBatch(input.WoBatch.BATCH_NO);
                input.Wo.ACT_LINE = input.WoBatch.ACT_LINE;
                input.Wo.RELEASE_TIME = DateTime.Now;
                input.Wo.RELEASE_USER = input.WoBatch.UPDATE_USER;
@@ -164,6 +170,31 @@
                {
                    result.IsSuccessed = false;
                    result.LocaleMsg = new($"保存批次工单异常");
                }
                //如果成功,根据条件异步保存工艺路线到产品的客户
                if (result.IsSuccessed && input.IfToCust) {
                    Work.DoAsync(() => {
                        try
                        {
                            SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { WO = input.Wo.ORDER_NO, ERR_CODE = 0, ERR_MSG = "" });
                            pars[1].Direction = System.Data.ParameterDirection.Output;
                            pars[2].Direction = System.Data.ParameterDirection.Output;
                            Biz.Db.Ado.UseStoredProcedure().ExecuteCommand("SP_MES_WO2CUST", pars);
                            //response.LocaleMsg = new(pars[2].Value.ToString());
                            if (pars[1].Value.ToInt32() == 0)
                            {
                                Logger.Default.Info($"工单[{input.Wo.ORDER_NO}]下发完成后保存工艺路线数据到产品[{input.Wo.ITEM_CODE}]的客户[{input.Wo.Customer.CUST_NAME_CN}]的工艺路线中,{pars[2].Value.ToString()}");
                            }
                            else
                            {
                                Logger.Default.Error($"工单[{input.Wo.ORDER_NO}]下发完成后保存工艺路线数据到产品[{input.Wo.ITEM_CODE}]的客户[{input.Wo.Customer.CUST_NAME_CN}]的工艺路线出错,{pars[2].Value.ToString()}");
                            }
                        }
                        catch (Exception ex)
                        {
                            result.CatchExceptionWithLog(ex, "保存批次工单异常");
                        }
                    });
                }
            }
            catch (Exception ex)
@@ -201,7 +232,7 @@
                var db = Biz.Db;
                var dbTran = db.UseTran(() =>
                {
                    db.Updateable(_wo, input.UserId).UpdateColumns(x => new { x.STATUS, x.ROUTE_STATUS }).ExecuteCommand();
                    db.Updateable(_wo, input.UserId).UpdateColumns(x => new { x.STATUS, x.ROUTE_STATUS, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand();
                });
                if (!dbTran.IsSuccess)
                {
@@ -235,7 +266,7 @@
                    _woBatch.STATUS = input.Status < 0 ? _woBatch.STATUS : input.Status;
                    if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Paused.GetValue())
                    {
                        WoContext.RemoveBatch(input.WoBatch);
                        //WoContext.RemoveBatch(input.WoBatch);
                    }
                    //如果是下发
                    if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Release.GetValue())
@@ -264,11 +295,11 @@
                    //如果是下发
                    if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Release.GetValue())
                    {
                        db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.RELEASE_USER, x.RELEASE_TIME, x.ACT_LINE }).ExecuteCommand();
                        db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.RELEASE_USER, x.RELEASE_TIME, x.ACT_LINE, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand();
                    }
                    else
                    {
                        db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS }).ExecuteCommand();
                        db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand();
                    }
                });
                if (!dbTran.IsSuccess)