| | |
| | | int? useLimit, |
| | | decimal? sdjs = null, |
| | | decimal? xdjs = null, |
| | | decimal? modlLifeWorning = null) // 新增:寿命比预警值(0~1的小数) |
| | | decimal? modlLifeWorning = null) |
| | | { |
| | | var parameters = new[] |
| | | var parameters = new List<SugarParameter> |
| | | { |
| | | 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) // 新增 |
| | | }; |
| | | new SugarParameter("V_WORK_ORDER_NO", workOrderNo) { DbType = SystemDataDbType.String }, |
| | | new SugarParameter("V_MACHINE_NO", machineNo) { DbType = SystemDataDbType.String }, |
| | | new SugarParameter("V_TOOL_NO", toolNo) { DbType = SystemDataDbType.String }, |
| | | new SugarParameter("V_TYPE", type) { DbType = SystemDataDbType.String }, |
| | | new SugarParameter("V_USE_LIMIT", useLimit ?? (object)DBNull.Value) { DbType = SystemDataDbType.Int32 }, |
| | | new SugarParameter("V_SDJS", sdjs ?? (object)DBNull.Value) { DbType = SystemDataDbType.Decimal }, |
| | | new SugarParameter("V_XDJS", xdjs ?? (object)DBNull.Value) { DbType = SystemDataDbType.Decimal }, |
| | | new SugarParameter("V_MODL_LIFE_WORNING", modlLifeWorning ?? (object)DBNull.Value) { DbType = SystemDataDbType.Decimal }, |
| | | new SugarParameter("PO_OUTMSG", null, SystemDataDbType.String, ParameterDirection.Output, 200), |
| | | new SugarParameter("PO_OUTSUM", null, SystemDataDbType.Int32, ParameterDirection.Output) |
| | | }; |
| | | |
| | | try |
| | | { |
| | | Db.Ado.UseStoredProcedure().SqlQuery<object>("PROC_TOOL_ACTION", parameters); |
| | | var outMsg = parameters[7].Value?.ToString(); |
| | | var outSum = parameters[8].Value; |
| | | // 这里 outMsg 已经包含了存储过程每步DML的详细错误信息 |
| | | Db.Ado.UseStoredProcedure().GetDataTable("PROC_TOOL_ACTION", parameters.ToArray()); |
| | | |
| | | var outMsg = parameters[8].Value?.ToString(); |
| | | var outSum = parameters[9].Value == DBNull.Value ? (int?)null : Convert.ToInt32(parameters[9].Value); |
| | | |
| | | return new { outMsg, outSum }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // 只有存储过程本身执行异常才会进入这里 |
| | | throw new Exception($"{ex.Message}"); |
| | | throw new Exception($"存储过程执行失败:{ex.Message}"); |
| | | } |
| | | } |
| | | |