快乐的昕的电脑
2025-11-21 ab5a72d56086103154c85570c5bca27b7be6d2b4
Services/MesCutterLedgerManager.cs
@@ -58,24 +58,32 @@
    /// <param name="type">操作类型(上刀、下刀)</param>
    /// <param name="useLimit">使用上限</param>
    /// <returns>存储过程执行结果</returns>
    public object SubmitToolAction(string workOrderNo, string machineNo, string toolNo, string type, int? useLimit, decimal? sdjs = null, decimal? xdjs = null)
    public object SubmitToolAction(
        string workOrderNo,
        string machineNo,
        string toolNo,
        string type,
        int? useLimit,
        decimal? sdjs = null,
        decimal? xdjs = null,
        decimal? modlLifeWorning = null) // 新增:寿命比预警值(0~1的小数)
    {
        var parameters = new[]
        {
            new SugarParameter("V_WORK_ORDER_NO", workOrderNo),
            new SugarParameter("V_MACHINE_NO", machineNo),
            new SugarParameter("V_TOOL_NO", toolNo),
            new SugarParameter("V_TYPE", type),
            new SugarParameter("V_USE_LIMIT", useLimit ?? (object)DBNull.Value),
            new SugarParameter("V_SDJS", sdjs ?? (object)DBNull.Value),
            new SugarParameter("V_XDJS", xdjs ?? (object)DBNull.Value),
            new SugarParameter("PO_OUTMSG", null) { Direction = ParameterDirection.Output, DbType = System.Data.DbType.String, Size = 200 },
            new SugarParameter("PO_OUTSUM", null) { Direction = ParameterDirection.Output, DbType = System.Data.DbType.Int32 }
        };
        new SugarParameter("V_WORK_ORDER_NO", workOrderNo),
        new SugarParameter("V_MACHINE_NO", machineNo),
        new SugarParameter("V_TOOL_NO", toolNo),
        new SugarParameter("V_TYPE", type),
        new SugarParameter("V_USE_LIMIT", useLimit ?? (object)DBNull.Value),
        new SugarParameter("V_SDJS", sdjs ?? (object)DBNull.Value),
        new SugarParameter("V_XDJS", xdjs ?? (object)DBNull.Value),
        new SugarParameter("PO_OUTMSG", null) { Direction = ParameterDirection.Output, DbType = System.Data.DbType.String, Size = 200 },
        new SugarParameter("PO_OUTSUM", null) { Direction = ParameterDirection.Output, DbType = System.Data.DbType.Int32 },
        new SugarParameter("V_MODL_LIFE_WORNING", modlLifeWorning ?? (object)DBNull.Value) // 新增
    };
        try
        {
            Db.Ado.UseStoredProcedure().SqlQuery<object>(
                "PROC_TOOL_ACTION", parameters);
            Db.Ado.UseStoredProcedure().SqlQuery<object>("PROC_TOOL_ACTION", parameters);
            var outMsg = parameters[7].Value?.ToString();
            var outSum = parameters[8].Value;
            // 这里 outMsg 已经包含了存储过程每步DML的详细错误信息