bklLiudl
2024-07-23 277bbae216debe7e6c04e8cc6ee6e1ba9763e14b
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
using BLL.DAL;
using BLL.IDAL;
using Common;
using Json;
using Lib;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;
 
namespace wms.Areas.BasicInfo.Controllers
{
    public class BarCodeAjaxController : AjaxPage
    {
        // GET: BasicInfo/BarCodeAjax
        public ActionResult GetPalletNoList()
        {
            var dd = Request["ajaxdata"];
 
            var pnc = new JavaScriptSerializer().Deserialize<PalletNoCount>(dd);
            if (pnc.count > 0)
            {
                IDALBarCode bc = new DALBarCode();
 
                int startNo = bc.GetStartNo();
                IList<BarCode> lst = new List<BarCode>();
                IList<string> lst2 = new List<string>();
                DateTime t = DateTime.Now;
                string strT = t.ToString("yyyyMM");
                string strPalletType = "";
 
                strPalletType = pnc.type;
                if (pnc.type == "B")
                {
                    strPalletType += "0";
                }
                else
                {
                    if (pnc.SpecificationType == "01")
                    {
                        strPalletType += "3";
                    }
                    if (pnc.SpecificationType == "02")
                    {
                        strPalletType += "2";
                    }
                    if (pnc.SpecificationType == "03")
                    {
                        strPalletType += "1";
                    }
                }
 
                for (int i = 0; i < pnc.count; i++)
                {
                    string palletNo = "";
                    BarCode barCode = new BarCode();
                    if (startNo < 10)
                    {
                        palletNo += strPalletType;
                        palletNo += strT;
                        palletNo += "00";
                        palletNo += startNo.ToString();
                        startNo++;
                        if (startNo > 999)
                        {
                            startNo = 1;
                        }
                        barCode.code = palletNo;
                        lst.Add(barCode);
                        lst2.Add(barCode.code);
                        continue;
                    }
                    if ((startNo >= 10) && (startNo < 100))
                    {
                        palletNo += strPalletType;
                        palletNo += strT;
                        palletNo += "0";
                        palletNo += startNo.ToString();
                        startNo++;
                        if (startNo > 999)
                        {
                            startNo = 1;
                        }
                        barCode.code = palletNo;
                        lst.Add(barCode);
                        lst2.Add(barCode.code);
                        continue;
                    }
                    if ((startNo >= 100))
                    {
                        palletNo += strPalletType;
                        palletNo += strT;
                        palletNo += startNo.ToString();
                        startNo++;
                        if (startNo > 999)
                        {
                            startNo = 1;
                        }
                        barCode.code = palletNo;
                        lst.Add(barCode);
                        lst2.Add(barCode.code);
                        continue;
                    }
                }
                int n = bc.UpdateStartNo(startNo);
                string json = JsonHelper.IListToJson<BarCode>(lst, "List");
                //ReturnJson.AddProperty("Result", lst2);
                ReturnJson.AddProperty("Result", new JsonObject(json));
                ReturnJson.AddProperty("Code", 1);
                ReturnJson.AddProperty("Message", "响应成功");
                ReturnJson.AddProperty("SubCode", 0);
                ReturnJson.AddProperty("SubMessage", "");
                return Content(this.ReturnJson.ToString());
            }           
 
            return Content(null);
        }
 
        public ActionResult GetPosList()
        {
 
            if (true)
            {
                IDALBarCode bc = new DALBarCode();
 
                IList<DepotsLocation> lst = new List<DepotsLocation>();
                lst = (IList<DepotsLocation>)bc.GetPosList();
 
                string json = JsonHelper.IListToJson<DepotsLocation>(lst, "List");
                ReturnJson.AddProperty("Result", new JsonObject(json));
                ReturnJson.AddProperty("Code", 1);
                ReturnJson.AddProperty("Message", "响应成功");
                ReturnJson.AddProperty("SubCode", 0);
                ReturnJson.AddProperty("SubMessage", "");
                return Content(this.ReturnJson.ToString());
            }
 
 
            //return Content(null);
        }
    }
}