北鸣对接T+畅捷通,看板API
yl
2023-11-20 f84de3e390ddb9f637342f16e758da4cbef5216e
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
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
 
namespace VueWebApi.Tools
{
    public class LabCodeStatusMessage
    {
        public static ToMessage mes = new ToMessage(); //定义全局返回信息对象
 
 
        #region[生产开报工:自制工序任务开报工判断:工单+工序条码]
        /// <summary>
        /// 扫码信息为工单+工序条码
        /// </summary>
        /// <param name="rightcode">功能编码</param>
        /// <param name="hbilltype">单据类型</param>
        /// <param name="hbarcode">条形码</param>
        /// <returns></returns>
        public static ToMessage LabCodeStatus(string rightcode, string hbilltype,string hbarcode)
        {
            var sql = "";
            DataTable dt;
            var dynamicParams = new DynamicParameters();
            mes.code = "200";
            try
            {
                //0.判断条码是否为当前功能扫描条码
                sql = @"select rightcode,hbilltype  from T_BarCodeBill where hbarcode=@hbarcode";
                dynamicParams.Add("@hbarcode", hbarcode);
                dt = DapperHelper.selectdata(sql, dynamicParams);
                if (dt.Rows.Count>0)
                {
                    if (dt.Rows[0]["rightcode"].ToString() != rightcode && dt.Rows[0]["hbilltype"].ToString() != hbilltype) 
                    {
                        mes.code = "300";
                        mes.count = 0;
                        mes.Message = "当前条码状态不满足此功能!";
                        mes.data = null;
                        return mes;
                    }
                }
                //1.判断当前功能条码是否为系统生成有效条码
                sql = @"select *   from T_BarCodeBill where hbarcode=@hbarcode";
                dynamicParams.Add("@hbarcode", hbarcode);
                dt = DapperHelper.selectdata(sql, dynamicParams);
                if (dt.Rows.Count<=0)
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.Message = "当前条码在系统中不存在!";
                    mes.data = null;
                    return mes;
                }
                //2.判断当前功能条码是否为有效条码
                sql = @"select *   from T_BarCodeBill where hbarcode=@hbarcode and hbarcodestatus='Y'";
                dynamicParams.Add("@hbarcode", hbarcode);
                dt = DapperHelper.selectdata(sql, dynamicParams);
                if (dt.Rows.Count <= 0)
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.Message = "当前条码已停用!";
                    mes.data = null;
                    return mes;
                }
                //2.判断当前功能条码质量状态是否为不合格
                sql = @"select *   from T_BarCodeBill where hbarcode=@hbarcode and hbarcodestatus='Y'and qualitystatus='NG' ";
                dynamicParams.Add("@hbarcode", hbarcode);
                dt = DapperHelper.selectdata(sql, dynamicParams);
                if (dt.Rows.Count > 0)
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.Message = "当前条码质量状态不通过!";
                    mes.data = null;
                    return mes;
                }
 
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.Message = e.Message;
                mes.data = null;
                return mes;
            }
            return mes;
        }
        #endregion
    }
}