zzr99
2021-12-09 711d7d357f595956e38bba3a5488651fc7682ee6
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
using DBUtility;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Script.Serialization;
using WebAPI.Models;
 
namespace WebAPI.Controllers.博日自动扫码线
{
    public class ScanlineAPIController : ApiController
    {
        private jsonScanline objJsonResult = new jsonScanline();
        public DataSet ds = new DataSet();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
 
        #region 生成箱码接口
        [Route("packagebarcode/create")]
        [HttpGet]
        public object create(int num)
        {
            try
            {
                objJsonResult.data = new List<barcode>();
                for (int i = 0; i < num; i++)
                {
                    barcode jsn = new barcode();
                    //string prefix = "ZM"; 
                    //string date = DateTime.Now.ToString("yyMMddhh"); 
                    //string custom = "12"; 
                    //int nm = i; 
                    //string result = prefix + date + custom + nm.ToString().PadLeft(4, '0');
 
                    //条码前缀 = 箱码前缀 + 年 + 月 + 日
                    string sDate = DateTime.Now.ToString("yyyy-MM-dd");
                    string sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2);
                    string sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString();
                    sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
                    string sDay = "0" + ClsPub.isDate(sDate).Day.ToString();
                    sDay = sDay.Substring(sDay.Length - 2, 2);
                    string  sTMNumber ="ZX"+ sYear + sPeriod + sDay;
                    ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                    int LSH = ClsPub.isInt(ds.Tables[0].Rows[0][0])+1;  //流水号加1
                    string TM = sTMNumber + LSH;
                    jsn.packagebarcode = TM;
                    oCN.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                    objJsonResult.data.Add(jsn);
                }
                objJsonResult.status = 0;
                objJsonResult.msg = "查询数据成功!";
                objJsonResult.data =objJsonResult.data;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.status =-1;
                objJsonResult.msg = "生成箱条码失败!";
                objJsonResult.data =null;
                return objJsonResult;
            }
        }
        #endregion
 
 
        #region 报工平台开工单保存/编辑
        /// <summary>
        /// 开工单
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        [Route("packagebarcode/pack")]
        [HttpPost]
        public object pack([FromBody] JObject msg)
        {
            try
            {
                JavaScriptSerializer js = new JavaScriptSerializer();   //实例化一个能够序列化数据的类
                ScanLineCode list = js.Deserialize<ScanLineCode>(msg.ToString());    //将json数据转化为对象类型并赋值给list
 
                objJsonResult.status = 0;
                objJsonResult.msg = "success";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.status =-1;
                objJsonResult.msg = "success";
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}