| | |
| | | { |
| | | private readonly MesCutterLedgerManager m = new(); |
| | | |
| | | // 加入 sdjs、xdjs 为可空 decimal,保持与前端 JSON 字段名一致 |
| | | public record ToolActionRequest( |
| | | string workOrderNo, |
| | | string machineNo, |
| | | string toolNo, |
| | | string type, |
| | | int? useLimit |
| | | int? useLimit, |
| | | decimal? sdjs, |
| | | decimal? xdjs |
| | | ); |
| | | |
| | | public record FormDataRequest( |
| | |
| | | |
| | | /// <summary> |
| | | /// 上下刀操作(上刀type=0,下刀type=1) |
| | | /// 接收 JSON 请求体(Content-Type: application/json),并将 sdjs/xdjs 一并传入服务层 |
| | | /// </summary> |
| | | [HttpPost("SubmitToolAction")] |
| | | public IActionResult SubmitToolAction( |
| | | [FromForm] string workOrderNo, |
| | | [FromForm] string machineNo, |
| | | [FromForm] string toolNo, |
| | | [FromForm] string type, // string 类型 |
| | | [FromForm] int? useLimit |
| | | ) |
| | | public IActionResult SubmitToolAction([FromBody] ToolActionRequest req) |
| | | { |
| | | try |
| | | { |
| | | var result = m.SubmitToolAction(workOrderNo, machineNo, toolNo, type, useLimit); |
| | | var result = m.SubmitToolAction( |
| | | req.workOrderNo, |
| | | req.machineNo, |
| | | req.toolNo, |
| | | req.type, |
| | | req.useLimit, |
| | | req.sdjs, |
| | | req.xdjs |
| | | ); |
| | | |
| | | return Ok(new ResponseResult |
| | | { |
| | | status = 0, |
| | |
| | | /// <param name="type">操作类型(上刀、下刀)</param> |
| | | /// <param name="useLimit">使用上限</param> |
| | | /// <returns>存储过程执行结果</returns> |
| | | public object SubmitToolAction(string workOrderNo, string machineNo, string toolNo, string type, int? useLimit) |
| | | public object SubmitToolAction(string workOrderNo, string machineNo, string toolNo, string type, int? useLimit, decimal? sdjs = null, decimal? xdjs = null) |
| | | { |
| | | 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("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 } |
| | | }; |
| | | try |
| | | { |
| | | Db.Ado.UseStoredProcedure().SqlQuery<object>( |
| | | "PROC_TOOL_ACTION", parameters); |
| | | var outMsg = parameters[5].Value?.ToString(); |
| | | var outSum = parameters[6].Value; |
| | | var outMsg = parameters[7].Value?.ToString(); |
| | | var outSum = parameters[8].Value; |
| | | // 这里 outMsg 已经包含了存储过程每步DML的详细错误信息 |
| | | return new { outMsg, outSum }; |
| | | } |