YL
2022-02-21 97bbd786a9fbdd2a1219f9db8a1e4c9e91875b75
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
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
 
namespace WebAPI.Controllers.仓存管理.条码生成
{
    public class Sc_BarCodeController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
 
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public WebServer webserver = new WebServer();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        private WebS.WebService1 oWebs = new WebS.WebService1();
        //获取系统参数
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
 
       
 
        #region 条码生成
 
        #region 条码生成获取工厂代码数据
 
        [Route("Sc_BarCode/GetHWorksNumberBill")]
        [HttpGet]
        public object GetHWorksNumberBill()
        {
            try
            {
                string ERPMode = "";
                string CampanyName = "";
                string SourceQtyCtl = "";
                List<object> list = new List<object>();
                if (oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo) == false)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "获取系统参数失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    ERPMode = oSystemParameter.omodel.WMS_WMSStockCtl_ERPMode;
                    CampanyName = oSystemParameter.omodel.WMS_CampanyName;
                    SourceQtyCtl = oSystemParameter.omodel.BarCode_SourceQtyCtl;
                }
                if (CampanyName == "飞龙") //系统参数  客户定制化名称
                {
                    list.Add("ZL");
                    list.Add("ST");
                    list.Add("SQ");
                    list.Add("MQ");
                }
                else
                {
                    list.Add("");
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "返回记录成功!";
                objJsonResult.list = list;
                return objJsonResult;
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
 
        public static DataSet Sc_GetMESBeginStepWorkBill(string sWhere)
        {
            if (sWhere == null || sWhere.Equals(""))
            {
                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MESBeginWorkBillList_NEW order by hmainid desc ", "h_v_Sc_MESBeginWorkBillList_NEW");
            }
            else
            {
                string sql1 = "select * from h_v_Sc_MESBeginWorkBillList_NEW where 1 = 1 ";
                string sql = sql1 + sWhere + " order by hmainid desc ";
                return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MESBeginWorkBillList_NEW");
            }
 
        }
 
        #endregion
 
        #region 条码生成获取条码类型数据
 
        [Route("Sc_BarCode/GetHBarCodeTypeBill")]
        [HttpGet]
        public object GetHBarCodeTypeBill()
        {
            try
            {
                List<object> list = new List<object>();
                string sCapName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo);
                if (sCapName == "夏宝电器")
                {
                    list.Add("内销机条码");
                    list.Add("外销机条码");
                    list.Add("半成品条码");
                }
                else if (sCapName == "博日科技")
                {
                    list.Add("仪器外购件条码普通规则");
                    list.Add("仪器外购件条码容器规则");
                    list.Add("仪器成品条码规则");
                    list.Add("试剂成品条码规则");
                }
                else
                {
                    list.Add("唯一条码");
                    list.Add("品种条码");
                    list.Add("批次条码");
                    //list.Add("托盘条码");
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "返回记录成功!";
                objJsonResult.list = list;
                return objJsonResult;
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
 
        #region [通过源单类型查找不通单据信息]
        [Route("Sc_BarCode/ReportFromBillList")]
        [HttpGet]
        public object ReportFromBillList(int page, int limit, string sWhere,string HSouceBillType,string HOrgID)
        {
            List<object> columnNameList = new List<object>();
            try
            {
                int count = 0;
                int pageNum = page;
                int pageSize = limit;
                string sql = "";
                string tabname = "";
                if (sWhere == null || sWhere.Equals(""))
                {
                    sWhere = " where 1=1 and HOrgID='"+HOrgID+"' ";
                }
                else
                {
                    sWhere = " where 1=1 and HOrgID='" + HOrgID + "' " + sWhere;
                }
                switch (HSouceBillType)
                {
                    case "生产订单":
                        tabname = "h_v_IFCLD_ICMOBillList_Source"; 
                        count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IFCLD_ICMOBillList_Source "+sWhere+ " and 任务数量>isnull(入库数量,0)  and 状态<>'结案' order by 单据号", "h_v_IFCLD_ICMOBillList_Source").Tables[0].Rows.Count;
                        sql = string.Format(@"select top " + pageSize + " * from(select row_number() over (order by 单据号) as HRowNumber,* from h_v_IFCLD_ICMOBillList_Source " + sWhere + " and 任务数量>isnull(入库数量,0)  and 状态<>'结案')   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        break;
                    case "生产汇报单":
                        break;
                    case "采购订单":
                        break;
                    case "收料通知单":
                        break;
                    case "委外订单":
                        break;
                    case "退货通知单":
                        break;
                    case "其他入库单":
                        break;
                    case "直接调拨单":
                        break;
                    case "采购退料单":
                        break;
                    case "生产退料单":
                        break;
                    case "组装拆卸单":
                        break;
                    default:
                        break;
                }
                ds = new SQLHelper.ClsCN().RunProcReturn(sql, tabname);
                string aa = ds.Tables[0].Columns[0].ToString();
 
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
 
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
 
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = count;
                    objJsonResult.Message = "获取资源绑定数据成功!";
                    objJsonResult.data = JsonConvert.DeserializeObject<DataTable>(JsonConvert.SerializeObject(ds.Tables[0], new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }));  //序列化DataSet中的时间格式,然后再反序列化回来
                    objJsonResult.list = columnNameList;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "暂无资源绑定!";
                    objJsonResult.data = null;
                    objJsonResult.list = columnNameList;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
 
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.Message.ToString();
                objJsonResult.data = null;
                objJsonResult.list = columnNameList;
            }
            return objJsonResult;
        }
        #endregion
 
        #endregion
    }
}