zjh
2025-11-12 2914a3a86ce976e5b397ee41bd1553e45fe68831
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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;
 
/// <summary>
/// 产线提交接口控制器
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class ProductionLineController : ControllerBase
{
    /// <summary>
    /// 获取产线提交页面数据
    /// </summary>
    [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);
        }
    }
    /// <summary>
    /// 提交检验(生成首检单)
    /// </summary>
    [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);
        }
    }
}