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;
|
}
|
}
|
}
|