schangxiang@126.com
2025-09-17 e8e8a06fc68a6a645ce32be2cc9c3aaa67a97d68
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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Xml;
 
namespace iWareWebservice.AppDao
{
    public class StockIvnDAO
    {
        private static object Lock = new object();
 
        private static StockIvnDAO Instance = null;
 
        /// <summary>
        /// 获取单例的方法
        /// </summary>
        /// <returns>单例实体</returns>
        public static StockIvnDAO GetInstance()
        {
            if (Instance == null)
            {
                lock (Lock)
                {
                    if (Instance == null)
                    {
                        Instance = new StockIvnDAO();
                    }
                }
            }
            return Instance;
        }
 
        public string GetStockMaterial(string XMLParas)
        {
            AppUtil.LogHelper.GetInstance().WriteLog(this.GetType().Name+".GetStockMaterial.请求参数->", XMLParas);
 
            string sql = "";
            string rspbodyStr = "";
            string rspStartStr = "";
            string rspEndStr = "</StockItems></Data></root>";
 
            string conStr = ConfigurationManager.ConnectionStrings["SysDb"].ConnectionString;
            try
            {
                sql = @"select c.code as plcaecode,c.[row],c.col,c.layer,b.code as materialcode,b.wide,b.Thick,b.[length],b.[weight] from BASEPlaceMaterial a 
                            left join BASEMaterial b on a.materialid=b.id 
                            left join BASEPlace c on a.placeid=c.id
                                where c.typeid='4';";
 
                DataTable ivnDt = MsSqlDao.CreateInstance(conStr).GetDataTable(sql);
                if (ivnDt.Rows.Count>0)
                {
                    rspStartStr = new ResponseXmlString().GetResponseHeardStr(new Random().Next(1, 9999).ToString(),true,"") + "<StockItems>";
                    for (int i = 0; i < ivnDt.Rows.Count; i++)
                    {
                        string materialcode = ivnDt.Rows[i]["materialcode"].ToString().Trim();
                        string materialqty = "1";//ivnDt.Rows[i]["Qty"].ToString().Trim();
                        string materiallength = ivnDt.Rows[i]["length"].ToString().Trim();
                        string materialthick = ivnDt.Rows[i]["Thick"].ToString().Trim();
                        string materialwide = ivnDt.Rows[i]["wide"].ToString().Trim();
                        string materialweight = ivnDt.Rows[i]["weight"].ToString().Trim();
 
 
                        string articlenumber = materialwide + " * " + materialthick + " * " + materiallength;
 
                        rspbodyStr += "<StockItem MaterialNo=\"" + materialcode + "\" Nesting_No=\"" + materialcode + "\" Quantity=\"" + materialqty + "\" ArticleNumber=\"" + articlenumber + "\" ArticleType=\"Profile\" Grade=\"A\" Classification=\"AB\">"
                                   + "<Profile ProfileType=\"BP\" Length=\"" + materiallength + "\" Density = \"7.850\" WebHeight=\"" + materialwide + "\" WebThickness = \"" + materialthick + "\" FlangeWidth = \"20.50\" FlangeThickness = \"14.80\" SectionDim = \"" + materialwide + "x" + materialthick + "\" UnitWeight=\"" + materialweight + "\" />"
                                   + "</StockItem>";
                    }
                }
                else
                    rspStartStr = new ResponseXmlString().GetResponseHeardStr(new Random().Next(1, 9999).ToString(),false,"未存在库存");
 
            }
            catch (Exception){}
            return rspStartStr + rspbodyStr + rspEndStr;
        }
    }
}