新框架PC后端代码(祈禧6月初版本)
南骏 池
3 天以前 72449a1b8699b65712e57fba8abce5a8240e9465
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using System.Data;
using System.Data.SqlClient;
using System.Dynamic;
using System.Text;
using Gs.Toolbox;
using Gs.Toolbox.ApiCore.Abstract.Mvc;
using Gs.Toolbox.ApiCore.Common.Mvc;
using Gs.Toolbox.ApiCore.Group;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static Gs.Toolbox.UtilityHelper;
 
namespace Gs.Wom.WorkService
{
 
    [ApiGroup(ApiGroupNames.WOM)]
    public class WorkCollectController : IRomteService
    {
        private readonly IHttpContextAccessor _http;
        private readonly string _userCode, _userGuid, _orgFids;
        public WorkCollectController(IHttpContextAccessor httpContextAccessor)
        {
            _http = httpContextAccessor;
            (_userCode, _userGuid, _orgFids) =
                GetUserGuidAndOrgGuid(_http);
        }
        #region
 
 
        /// <summary>
        ///     读取,采集,采集的时候返回列表
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        [RequestMethod(RequestMethods.POST)]
        public ReturnDto<ExpandoObject> GetModel([FromBody] dynamic model)
        {
            string barCode = model.barCode.ToString();//追溯码
            string processNo = model.processNo;//工序
            string banCi = model.banCi;//班次
            string gongWei = model.gongWei;//工位
            string checkResult = model.checkResult; //结果
            string badDescription = model.badDescription;//不良描述
            //水检值
            string t001 = model.t001;
            string t002 = model.t002;
            string t003 = model.t003;
            string t004 = model.t004;
            string t005 = model.t005;
            string t006 = model.t006;
            string t007 = model.t007;
            string t008 = model.t008;
            string t009 = model.t009;
            string t010 = model.t010;
            string t011 = model.t011;
            dynamic m = new ExpandoObject();
            m.list = new List<dynamic>();
            m.list2 = new List<dynamic>();
            m.list3 = new List<dynamic>();
            m.outMsg = "";
            m.outSum = -1;
            string _strMsg = "";
            int _sum = 0;
            SqlParameter[] parameters =
            {
                new("@inP3",checkResult),
                new("@inP4", barCode),
                new("@inEdtUserGuid", _userGuid),
                new("@processNo",processNo),
                new("@banCi",banCi),
                new("@gongWei",gongWei),
                new("@badDescription",badDescription),
                  new("@t001",t001),
                    new("@t002",t002),
                      new("@t003",t003),
                        new("@t004",t004),
                          new("@t005",t005),
                            new("@t006",t006),
                              new("@t007",t007),
                                new("@t008",t008),
                                  new("@t009",t009),
                                    new("@t010",t010),
                                       new("@t011",t011),
            };
            var dset = new DataSet();
            try
            {
                dset = DbHelperSQL.RunProcedure("[work_collect_mx]",
                    parameters, "0");
                if (dset != null && dset.Tables.Count > 0 &&
                    dset.Tables[0].Rows.Count > 0)
                {
                    //0返回消息和返回值
                    _strMsg = dset.Tables[0].Rows[0]["outMsg"].ToString();
                    _sum = int.Parse(dset.Tables[0].Rows[0]["outSum"].ToString());
                    //1统计和头表
                    if (dset.Tables.Count > 1 && dset.Tables[1].Rows.Count > 0)
                    {
                        var dr = dset.Tables[1].Rows[0];
                        m = dr.RowToDynamic();
                    }
                    m.outMsg = _strMsg;
                    m.outSum = _sum;
                    //2良品列表
                    if (dset.Tables.Count > 2)
                    {
                        var _tb = dset.Tables[2].TableToDynamicList();
                        m.list = _tb;
                    }
                    //3不良品列表
                    if (dset.Tables.Count > 3)
                    {
                        var _tb2 = dset.Tables[3].TableToDynamicList();
                        m.list2 = _tb2;
                    }
                }
                else
                {
                    m.outMsg = "没有找到该条码!";
                    m.outSum = -1;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Debug(this.ToString(), ex.Message);
                m.outMsg = ex.Message;
                m.outSum = -1;
            }
            if (m.outSum > 0)
                return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, m.outMsg);
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Exception, m.outMsg);
        }
        #endregion
    }
}