服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-10-23 666a8c8ed399c6e74b2f307bf6649b32a0fdb3e1
Tiger.Business/MES/Biz.Route.cs
@@ -14,6 +14,7 @@
using Tiger.Model.Entitys.WMS.DTOS;
using static Tiger.Model.BIZ_MES_WO;
using Tiger.Model.Entitys.MES.Position;
using System.Security.Cryptography;
namespace Tiger.Business
{
@@ -521,9 +522,9 @@
                            expableOper.And(x => x.ROT_ID == item.ID);
                        }
                    }
                    expable.And(x => x.PROD_CODE == input.prodCode && x.CUST_CODE == input.custCode);
                    expableOper.And(x => x.PROD_CODE == input.prodCode && x.CUST_CODE == input.custCode);
                    string _custCode = input.custCode ?? "";
                    expable.And(x => x.PROD_CODE == input.prodCode && (x.CUST_CODE == _custCode));
                    expableOper.And(x => x.PROD_CODE == input.prodCode && x.CUST_CODE == _custCode);
                    var exp = expable.ToExpression();
                    var expOper = expableOper.ToExpression();
@@ -990,6 +991,53 @@
                }
                return result;
            }
            /// <summary>
            /// 添加工单工艺路线
            /// </summary>
            /// <param name="input"></param>
            /// <returns></returns>
            public async Task<ApiAction> ProdRouteToWo(WoRotInput input)
            {
                var result = new ApiAction();
                try
                {
                    //保存前判断
                    if (Db.Queryable<BIZ_MES_WO>().Any(x => x.ORDER_NO == input.wo && x.STATUS > STATUSs.Init.GetValue() && x.STATUS < STATUSs.Closed.GetValue())) {
                        result.IsSuccessed = false;
                        result.LocaleMsg = new($"工单[{input.wo}]状态不是初始化或者完成,不可以修改工艺路线!");
                        return result;
                    }
                    var wo = await Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == input.wo).FirstAsync();
                    wo.ROUTE_STATUS = ROUTE_STATUSs.Finish.GetValue();
                    SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { ROT_ID = input.rotId, WO = input.wo, ERR_CODE = 0, ERR_MSG = "" });
                    pars[2].Direction = System.Data.ParameterDirection.Output;
                    pars[3].Direction = System.Data.ParameterDirection.Output;
                    Biz.Db.Ado.UseStoredProcedure().ExecuteCommand("SP_MES_PROD2WO", pars);
                    result.Data = pars[2].Value;
                    result.IsSuccessed = pars[2].Value.ToInt32() == 0 ? true : false;
                    result.LocaleMsg = new(pars[3].Value.ToString());
                    var db = Db;
                    var dbTran = db.UseTran(() =>
                    {
                        db.Updateable(wo, input.userId).UpdateColumns(x => new { x.ROUTE_STATUS, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand();
                    });
                    if (!dbTran.IsSuccess)
                    {
                        result.IsSuccessed = false;
                        result.LocaleMsg = new($"添加工单工艺路线异常");
                    }
                }
                catch (Exception ex)
                {
                    result.CatchExceptionWithLog(ex, "添加工单工艺路线异常");
                }
                return result;
            }
        } //endClass Route
    } //endClass Biz
}