ouyangqing
2021-01-15 71cb5772e28908d6ad100b111dbecf8b353c0b25
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
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using WebAPI.Models;
using WebAPI.WebS;
 
namespace WebAPI.Service
{
    public class YqnQbService
    {
        /// <summary>
        /// 获取单据号
        /// </summary>
        /// <returns></returns>
        public static ApiResult<DocumentsView> GetInterBillNo()
        { 
            var hInterId= DBUtility.ClsPub.CreateBillID(ApiConfig.HBillType, ref DBUtility.ClsPub.sExeReturnInfo);
            var hBillNo= DBUtility.ClsPub.CreateBillCode(ApiConfig.HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
            if (hInterId == 0 || string.IsNullOrEmpty(hBillNo))
                return new ApiResult<DocumentsView> { code = -1, msg = "获取失败" };
            DocumentsView documentsView = new DocumentsView()
            {
                HBillNo = hBillNo,
                HInterID = hInterId
            };
            return new ApiResult<DocumentsView> { code = 1, msg = "获取成功", data = documentsView };
        }
        /// <summary>
        /// 扫码方法 
        /// </summary>
        public static ApiResult<DataSet> GetHbarCodeDetail(string sBillBarCode)
        {
            if (string.IsNullOrEmpty(sBillBarCode))
                return new ApiResult<DataSet> { code = -1, msg = "条码不能为空" };
            sBillBarCode = sBillBarCode.CompareTo("#") > 0 ? sBillBarCode.Split(Convert.ToChar("#"))[0] : sBillBarCode;
            var dataSet = GetBarCodeDb(sBillBarCode);
            if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
                return new ApiResult<DataSet> { code = -1, msg = "不存在流转卡号" };
            return new ApiResult<DataSet> { code = 1, msg = "查询成功",data=dataSet };
        }
        /// <summary>
        /// 流转卡回车方法 
        /// </summary>
        public static ApiResult<DataSet> GetProcDetail(string sBillNo, string sProcNo)
        {
            if (string.IsNullOrEmpty(sBillNo)||string.IsNullOrEmpty(sProcNo))
                return new ApiResult<DataSet> { code = -1, msg = "条码和流转卡不能为空" };
            var dataSet = GetProcDb(sBillNo, sProcNo);
            if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
                return new ApiResult<DataSet> { code = -1, msg = "流水号或流转卡号为空" };
            return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet };
        }
        /// <summary>
        /// 获取生产资源列表 
        /// </summary>
        public static ApiResult<DataSet> GetSourceList(string sWhere)
        {
            var dataSet = GetSourceDb(sWhere);
            if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
                return new ApiResult<DataSet> { code = -1, msg = "未查询到生产资源" };
            return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet };
        }
        /// <summary>
        /// 获取生产班组列表 
        /// </summary>
        public static ApiResult<DataSet> GetGroupList(string sWhere)
        {
            var dataSet = GetGroupDb(sWhere);
            if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
                return new ApiResult<DataSet> { code = -1, msg = "未查询到生产班组" };
            return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet };
        }
        /// <summary>
        /// 获取工作中心列表 
        /// </summary>
        public static ApiResult<DataSet> GetWorkCenterList(string sWhere)
        {
            var dataSet = GetGroupDb(sWhere);
            if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
                return new ApiResult<DataSet> { code = -1, msg = "未查询到工作中心" };
            return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet };
        }
        /// <summary>
        /// 进站接收单
        /// </summary>
        public static ApiResult SetStationInBill(ClsSc_StationInBillMain oMain)
        {
            WebS.WebService1 oWebs = new WebS.WebService1();
            string sErrMsg = string.Empty;
            var result = oWebs.set_SaveStationInBill(oMain, ref  sErrMsg);
            if (!result)
            {
                return new ApiResult { code = -1, msg = sErrMsg };
            }
            return new ApiResult { code = 1, msg = "操作成功" };
        }
        #region sql语句
        public static DataSet GetBarCodeDb(string billBarCode)
        {
            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
            var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList  where 单据号= '" + billBarCode + "'", "h_v_Sc_ProcessExchangeBillList");
            return dataSet;
        }
        public static DataSet GetSourceDb(string sWhere)
        {
            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
            var dataSet = oCN.RunProcReturn("Select HItemID,HNumber 生产资源代码,HName 生产资源 from Gy_Source where HStopflag=0 " + sWhere + " Order by HItemID ", "Gy_Source");
            return dataSet;
        }
        public static DataSet GetGroupDb(string sWhere)
        {
            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
            var dataSet = oCN.RunProcReturn("Select HItemID,HNumber 生产班组代码,HName 生产班组 from Gy_Group where HStopflag=0 " + sWhere + " Order by HItemID ", "Gy_Source");
            return dataSet;
        }
 
        public static DataSet GetProcDb(string sBillNo, string sProcNo)
        {
            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
            var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList  where 单据号= '" + sBillNo + "' and 工序号='" + sProcNo + "'", "h_v_Sc_ProcessExchangeBillList");
            return dataSet;
        }
        /// <summary>
        /// 工作中心
        /// </summary>
        /// <param name="sWhere"></param>
        /// <returns></returns>
        public static DataSet GetWorkCenterDb(string sWhere)
        {
            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
            var dataSet = oCN.RunProcReturn("Select HItemID,HNumber 工作中心代码,HName 工作中心 from Gy_Group where HStopflag=0 " + sWhere + " Order by HItemID ", "Gy_Source");
            return dataSet;
        }
        #endregion
 
    }
}