using MES.Service.DB; using MES.Service.Dto.service; using MES.Service.Modes; using MES.Service.service.QC; using MES.Service.util; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; using SqlSugar; using System.Data; using System.Dynamic; namespace MESApplication.Controllers.QC; /// /// 产线提交接口控制器 /// [Route("api/[controller]")] [ApiController] public class ProductionLineController : ControllerBase { /// /// 获取产线提交页面数据 /// [HttpPost("GetProductionLinePage")] public ResponseResult GetProductionLinePage([FromBody] ProductionLineQueryDto queryObj) { try { dynamic resultInfos = new ExpandoObject(); var (item, totalCount) = new ProductionLineService().GetProductionLinePage(queryObj); resultInfos.tbBillList = item; return new ResponseResult { status = 0, message = "OK", data = resultInfos, TotalCount = totalCount }; } catch (Exception ex) { return ResponseResult.ResponseError(ex); } } /// /// 提交检验(生成首检单) /// [HttpPost("SubmitInspection")] public ResponseResult SubmitInspection([FromBody] JObject data) { try { var gid = data["gid"]?.ToString(); var userNo = data["userNo"]?.ToString(); if (string.IsNullOrEmpty(gid) || string.IsNullOrEmpty(userNo)) { return new ResponseResult { status = 1, message = "参数错误:gid和userNo不能为空", data = null }; } var workOrderId = Convert.ToDecimal(gid); var (success, message) = new ProductionLineService().SubmitInspection(workOrderId, userNo); dynamic resultInfos = new ExpandoObject(); resultInfos.tbBillList = success; return new ResponseResult { status = success ? 0 : 1, message = message, data = resultInfos }; } catch (Exception ex) { return ResponseResult.ResponseError(ex); } } }