yusijie
6 天以前 e0038f90ad5a1592b88b8912808fec4391e3fe72
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
using Newtonsoft.Json;
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.CJGL
{
    public class Cj_CheckBarcodeController : ApiController
    {
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        DataSet ds;
 
 
        #region 三码合一,判断扫描物料条码绑定信息是否一致
        [Route("CheckBarcodeController/Get_BarCode_BarcodeCheck")]
        [HttpGet]
        public object CheckBarcode(string HBarCode_Pallet, string HBarCode_Destination, string HBarCode_MiddleBox, string HBarCode_SN, int HBarCodeType, int HInterID, string HBillNo, string HMaker, string HBillType)
        {
            try
            {
                ds = oCn.RunProcReturn("exec h_p_Cj_CheckBarcodeBing '" + HBarCode_Pallet + "','" + HBarCode_Destination + "','" + HBarCode_MiddleBox + "','" + HBarCode_SN + "','" + HBarCodeType + "'," + HInterID + ",'" + HBillNo + "','" + HMaker + "','" + HBillType + "'", "h_p_Cj_CheckBarcodeBing");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "扫描条码判断错误!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) == 1)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "扫描条码失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
 
        #endregion
 
        #region 三码合一核对扫描记录  上传生单
 
        [Route("CheckBarcodeController/Save_BarCode_BarcodeCheck")]
        [HttpGet]
        public object Save_BarCode_BarcodeCheck(Int64 HInterID, string HBillNo, string HBillType)
        {
            try
            {
                oCn.BeginTran();
                DataSet ds = oCn.RunProcReturn("exec h_p_WMS_BarCodeBingCheckBill_Insert " + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "'", "h_p_WMS_BarCodeBingCheckBill_Insert");
 
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    oCn.RollBack();
 
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //失败!
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0][0]) == 1)
                    {
                        oCn.RollBack();
 
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = ds.Tables[0].Rows[0]["HBackRemark"].ToString();  //失败!
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        oCn.Commit();
 
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "单据号:" + HBillNo + " 保存成功!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
            }
            catch (Exception e)
            {
                oCn.RollBack();
 
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "生成单据失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
 
        #endregion
 
        #region 拆箱小卫
        [Route("CheckBarcodeController/UnpackMiddleBox")]
        [HttpGet]
        public object UnpackMiddleBox(string HBarCode_Middle, int signal, string HMaker, string HDate)
        {
            try
            {
                if (signal == 1)//扫码
                {
                    DataSet ds = oCn.RunProcReturn("select a.HCaseCode 中箱码,a.HBarCode 对应的SN码,b.HNumber 物料代码,b.HName 物料名称 from Gy_CaseCodeRelation a left join Gy_Material b on a.HMaterID=b.HItemID where HCaseCode='" + HBarCode_Middle + "'", "Gy_CaseCodeRelation");
                    if (ds.Tables[0].Rows[0]["中箱码"].ToString() == "" || ds == null)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "条码不存在!请检查是否装箱";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
 
                }
 
                else
                {
                    oCn.BeginTran();
                    oCn.RunProc("delete from Gy_CaseCodeRelation where HCaseCode='" + HBarCode_Middle + "'");
                    DataSet dss = oCn.RunProcReturn("select * from Gy_BarCodeBill where HBarCode=' " + HBarCode_Middle + "'", "Gy_BarCodeBill");
                    if (dss != null && dss.Tables.Count > 0)
                    {
                        oCn.RunProc("delete from Gy_BarCodeBill where HBarCode='" + HBarCode_Middle + "'");
                    }
                    oCn.RunProc("insert into System_log VALUES('" + HDate + "','" + HMaker + "',''," + "'小卫拆箱条码" + HBarCode_Middle + "'," + "'APP-中箱码拆箱'" + ",''," + "'删除条码')");
                    oCn.Commit();
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
 
 
            }
            catch (Exception)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "错误请联系管理员";
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
 
        #region sn装箱小卫
        [Route("CheckBarcodeController/PackedBoxSn")]
        [HttpGet]
        public object PackedBoxSn(string HBarCode, string HMaker, string HDate)
        {
            try
            {
                DataSet ds = oCn.RunProcReturn("select a.HBarCode sn码,a.HItemID,b.Hname 物料名称,b.hnumber 物料代码 from Gy_BarCodeBill a LEFT JOIN Gy_Material b on a.hmaterid=b.hitemid where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill");
                if(ds.Tables[0].Rows.Count==0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "该sn码不存在,请检查!!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DataSet dss = oCn.RunProcReturn("select * from Gy_CaseCodeRelation where HBarCode='" + HBarCode + "'", "Gy_CaseCodeRelation");
                int counts=dss.Tables[0].Rows.Count;
                if (counts > 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "该sn码已经装箱,请检查!!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "成功";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
 
 
        #region sn装箱小卫提交
        [Route("CheckBarcodeController/submitPackedBoxSn")]
        [HttpGet]
        public object submitPackedBoxSn(string HItemIDs, string HMaker, string HDate)
        {
            try
            {
                DataSet ds = oCn.RunProcReturn("exec h_p_Gy_CaseCodeBySN  '"+ HItemIDs+ "'", "h_p_Gy_CaseCodeBySN");                
                if (ds.Tables[0].Rows[0]["HBack"] == "2")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "中箱码已存在请重新生成";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "成功";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}