YL
2021-09-06 28f99afc92f67b372df91f1205a3dd8c2ff7be6e
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
using Newtonsoft.Json.Linq;
using Pub_Class;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web.Http;
using WebAPI.Models;
 
namespace WebAPI.Controllers
{
    //生产上料单Controller
    public class Sc_MaterToSourceBillController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
 
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        //获取系统参数
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
 
 
        /// <summary>
        /// 返回生产上料单列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Sc_MaterToSourceBill/list")]
        [HttpGet]
        public object list(string sWhere)
        {
            try
            {
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Sc_MaterToSourceBillList " + sWhere, "h_v_Sc_MaterToSourceBillList");
                }
                else
                {
                    string sql1 = "select * from h_v_Sc_MaterToSourceBillList where 1 = 1 ";
                    string sql = sql1 + sWhere;
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MaterToSourceBillList");
                }
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "Sucess!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
 
        //
 
        #region  报工平台上料防错单弹窗查找数据
        [Route("Sc_MaterToSourceBill/GetMESMaterToSourceFrom")]
        [HttpGet]
        public object GetMESMaterToSourceFrom(string HSourceInterID, string HSourceEntryID, string HSourceBillNo, string HSourceBillType)
        {
            try
            {
                //根据选择资源ID获取当前生产工单、责任人
                ds = oCN.RunProcReturn("exec h_p_JIT_GetInfoByICMOStatusInterID @HSourceInterID=" + HSourceInterID + ",@HSourceEntryID=" + HSourceEntryID + ",@HSourceBillNo='" + HSourceBillNo + "',@HSourceBillType='" + HSourceBillType + "'", "h_p_JIT_GetInfoByICMOStatusInterID");
                if (ds.Tables[0].Rows.Count > 0)
                {
 
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取资源绑定数据成功!";
                    objJsonResult.data = ds;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "暂无资源绑定!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
 
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.Message.ToString();
                objJsonResult.data = null;
 
            }
            return objJsonResult;
        }
        #endregion
 
        #region 报工平台上料防错一键扫码方法
        [Route("Sc_MaterToSourceBill/get_CheckTypeByBarCode_Json")]
        [HttpGet]
        public object get_CheckTypeByBarCode_Json(string HBarCode,string HSourceID)
        {
            
            //根据递入的条码前三位,判断条码类型(生产资源、物料条码)
            ds = oCN.RunProcReturn(" select HSourceName,BarCodeType from Xt_BarCodeType where HSourceNumber= '" + HBarCode.Substring(0, 3) + "'", "Xt_BarCodeType");
 
            //无返回数据则为物料条码
            if (ds == null || ds.Tables[0].Rows.Count == 0)
            {
                 //1.查询条形码在条码档案表中是否存在
                 //2.匹配用料清单的物料编码是否一致
 
            }
            else
            {
                string sBarBillName = Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HSourceName"]);
                string sBarBillType = Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0]["BarCodeType"]);
 
                //判断条码类型为 基础资料条码 或 源单条码
                if (sBarBillType == "基础资料条码")
                {
        
                    //部门条码
                    if (sBarBillName == "生产资源")
                    {
                        DAL.ClsGy_Source_View dal = new DAL.ClsGy_Source_View();
                        //将递入的条码去掉前三位后转化成整形
                        int ID;
                        if (int.TryParse(HBarCode.Remove(0, 3), out ID))
                        {
                            if (int.Parse(HSourceID)!= ID)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "生产资源条码与生产订单绑定资源不匹配!";
                                return objJsonResult;
                            }
                            else
                            {
                                if (dal.GetInfoByID(ID))
                                {
                                    objJsonResult.code = "1";
                                    objJsonResult.count = 1;
                                    objJsonResult.Message = "获取资源绑定数据成功!";
                                    objJsonResult.Verify = "资源条码";
                                    objJsonResult.data = dal;
                                    return objJsonResult;
                                }
                                else
                                {
                                    objJsonResult.code = "0";
                                    objJsonResult.count = 0;
                                    objJsonResult.Message = "无效资源条码!";
                                    return objJsonResult;
                                }
                            }
                        }
                        else
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "错误的部门条码!";
                            return objJsonResult;
                        }
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无效基础资料条码!";
                        return objJsonResult;
                    }
                }
                //源单条码
                else if (sBarBillType == "源单条码")
                {
                    
                    
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无效条码类型!";
                    return objJsonResult;
                }
            }
            return objJsonResult;
        }
        #endregion
    }
}