You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
825 lines
31 KiB
825 lines
31 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Reflection;
|
|
using System.Data;
|
|
using System.IO;
|
|
using SiaSun.LMS.Model;
|
|
using System.Xml;
|
|
using System.Net;
|
|
using System.Web.UI.WebControls;
|
|
using System.Threading;
|
|
using System.Net.Http;
|
|
using System.Net.Http.Headers;
|
|
|
|
namespace SiaSun.LMS.Implement
|
|
{
|
|
class S_ERPService : SiaSun.LMS.Implement.S_BaseService, SiaSun.LMS.Interface.I_ERPService
|
|
{
|
|
#region 基础信息
|
|
|
|
/// <summary>服务地址
|
|
/// 服务地址
|
|
/// </summary>
|
|
public string _sUrl = string.Empty;
|
|
|
|
/// <summary>用户
|
|
/// 用户
|
|
/// </summary>
|
|
private string _sUserName = string.Empty;
|
|
|
|
/// <summary>密码
|
|
/// 密码
|
|
/// </summary>
|
|
private string _sUserPsd = string.Empty;
|
|
|
|
/// <summary>路径
|
|
/// 路径
|
|
/// </summary>
|
|
public string _sPath;
|
|
|
|
/// <summary>方法
|
|
/// 方法
|
|
/// </summary>
|
|
public string _sMethod;
|
|
|
|
/// <summary>xml文档
|
|
/// xml文档
|
|
/// </summary>
|
|
public string _sXml;
|
|
|
|
#endregion
|
|
|
|
public S_ERPService()
|
|
{
|
|
this._sUrl = SiaSun.LMS.Common.StringUtil.GetConfig("ERP");
|
|
}
|
|
|
|
//解析传入XML转成DataTable
|
|
|
|
private System.Data.DataTable XmlToDataTable(string str)
|
|
{
|
|
XmlTextReader reader = null;
|
|
try
|
|
{
|
|
str = str.Replace("换行符", "\r\n").Replace("~", "/");
|
|
DataSet xmlds = new DataSet();
|
|
StringReader stream = new StringReader(str);
|
|
reader = new XmlTextReader(stream);
|
|
xmlds.ReadXml(reader);
|
|
|
|
if (reader != null)
|
|
{
|
|
reader.Close();
|
|
}
|
|
|
|
return xmlds.Tables[0];
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (reader != null)
|
|
{
|
|
reader.Close();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
//StringBuilder sbResult = new StringBuilder();
|
|
|
|
//DataTable dt = new DataTable();
|
|
//str = str.Replace("\n", string.Empty);
|
|
|
|
////string[] aStr = str.Replace(">", ">").Replace("<", "<").Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?><root><invokeServiceReturn xsi:type=\"xsd:string\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">", "").Replace("</invokeServiceReturn></root>", "").Split(new string[] { "</C>" }, StringSplitOptions.None);
|
|
//string[] aStr = str.Replace(">", ">").Replace("<", "<").Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "").Replace("</invokeServiceReturn></root>", "").Split(new string[] { "</C>" }, StringSplitOptions.None);
|
|
|
|
//string sField = string.Empty;
|
|
|
|
//string sTmp = string.Empty;
|
|
|
|
//int iBegin = 0;
|
|
|
|
//int iEnd = 0;
|
|
|
|
//int i = 0;
|
|
|
|
//foreach (string s in aStr)
|
|
//{
|
|
// //if (s.IndexOf("<DBSET RESULT=\"0\"></DBSET>") > 0)
|
|
// //{
|
|
// // return dt;
|
|
// //}
|
|
|
|
// //if (s.IndexOf("<C N=\"SUCCEED_FLAG\">1") > 0)
|
|
// //{
|
|
// // return dt;
|
|
// //}
|
|
|
|
// iBegin = s.IndexOf("<C N=\"");
|
|
|
|
// if (iBegin < 0)
|
|
// {
|
|
// sbResult.Append(s);
|
|
|
|
// continue;
|
|
// }
|
|
|
|
// iEnd = s.LastIndexOf("\">");
|
|
|
|
// sField = s.Substring(iBegin, iEnd - iBegin);
|
|
|
|
// sField = sField.Replace("<C N=\"", "");
|
|
|
|
// sTmp = s.Replace("<C N=\"", "<");
|
|
|
|
// sTmp = sTmp.Replace("\">", ">");
|
|
|
|
// if (sTmp.Contains("RESULT="))
|
|
// {
|
|
// sTmp = sTmp.Replace(sTmp.Substring(sTmp.IndexOf("RESULT="), sTmp.IndexOf("><R><") - sTmp.IndexOf("RESULT=")), "");
|
|
// }
|
|
|
|
|
|
// sbResult.Append(sTmp);
|
|
|
|
// sbResult.Append("</");
|
|
|
|
// sbResult.Append(sField);
|
|
|
|
// sbResult.Append(">");
|
|
|
|
// i++;
|
|
//}
|
|
|
|
//dt = new SiaSun.LMS.Common.Xml().GetDataTable_0(sbResult.ToString());
|
|
|
|
//return dt;
|
|
}
|
|
|
|
public DataTable CreateData(SiaSun.LMS.Model.PLAN_LIST mPLAN_LIST)
|
|
{
|
|
DataTable dataTable = new DataTable(typeof(SiaSun.LMS.Model.PLAN_LIST).Name);
|
|
|
|
foreach (PropertyInfo propertyInfo in typeof(SiaSun.LMS.Model.PLAN_LIST).GetProperties())
|
|
{
|
|
dataTable.Columns.Add(new DataColumn(propertyInfo.Name, propertyInfo.PropertyType));
|
|
}
|
|
|
|
return dataTable;
|
|
}
|
|
|
|
public string getInfo(string IN_XMAL)
|
|
{
|
|
bool bResult = false;
|
|
string sResult = string.Empty;
|
|
string outpara = string.Empty;
|
|
|
|
try
|
|
{
|
|
DataTable dt = this.XmlToDataTable(IN_XMAL);
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
SiaSun.LMS.Model.GOODS_MAIN mGOODS_MAIN = new SiaSun.LMS.Model.GOODS_MAIN();
|
|
mGOODS_MAIN = this._P_GOODS_MAIN.GetModel(dr["equipCode"].ToString());
|
|
|
|
#region 校验
|
|
|
|
if (mGOODS_MAIN == null)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult=string.Format("失败,未找到物料编码{0}!",dr["equipCode"]);
|
|
|
|
return sResult;
|
|
}
|
|
if (!(mGOODS_MAIN.GOODS_NAME == dr["equipName"].ToString()))
|
|
{
|
|
bResult = false;
|
|
|
|
sResult=string.Format("失败,物料名称{0}与基础信息不符!",dr["equipName"]);
|
|
|
|
return sResult;
|
|
}
|
|
if (!(dr["equipState"].ToString() == "0"))
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("失败,物料编码{0}状态故障,任务不执行!", dr["equipCode"].ToString());
|
|
|
|
return sResult;
|
|
}
|
|
|
|
#endregion
|
|
|
|
if (dr["event"].ToString() == "0")///入库
|
|
{
|
|
string num=dr["equipNum"].ToString();
|
|
|
|
if (!(Convert.ToInt32(dr["equipNum"].ToString()) > 0))
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("失败,物料{0}计划入库数量小于0,任务不执行!", dr["equipCode"].ToString());
|
|
|
|
return sResult;
|
|
}
|
|
|
|
int _PLAN_ID = 0;
|
|
|
|
Model.PLAN_MAIN mPLAN_MAIN = new Model.PLAN_MAIN();
|
|
mPLAN_MAIN.PLAN_CREATE_TIME = dr["time"].ToString();
|
|
mPLAN_MAIN.PLAN_CREATER = "MES";
|
|
mPLAN_MAIN.PLAN_ID = 0;
|
|
mPLAN_MAIN.PLAN_STATUS = SiaSun.LMS.Enum.PLAN_STATUS.Waiting.ToString();
|
|
mPLAN_MAIN.PLAN_FLAG = "0";
|
|
mPLAN_MAIN.PLAN_TYPE_CODE = "PlanIn";
|
|
mPLAN_MAIN.PLAN_RELATIVE_ID = 0;
|
|
|
|
Model.PLAN_LIST mPLAN_LIST = new Model.PLAN_LIST();
|
|
|
|
mPLAN_LIST.PLAN_ID = 0;
|
|
mPLAN_LIST.PLAN_LIST_QUANTITY = Convert.ToInt32(dr["equipNum"].ToString());
|
|
mPLAN_LIST.PLAN_LIST_ORDERED_QUANTITY = 0;
|
|
mPLAN_LIST.PLAN_LIST_FINISHED_QUANTITY = 0;
|
|
mPLAN_LIST.GOODS_ID = mGOODS_MAIN.GOODS_ID;
|
|
|
|
DataTable dtPLAN_LIST = CreateData(mPLAN_LIST);
|
|
DataRow dataRow = dtPLAN_LIST.NewRow();
|
|
foreach (PropertyInfo propertyInfo in typeof(SiaSun.LMS.Model.PLAN_LIST).GetProperties())
|
|
{
|
|
dataRow[propertyInfo.Name] = propertyInfo.GetValue(mPLAN_LIST, null);
|
|
}
|
|
dtPLAN_LIST.Rows.Add(dataRow);
|
|
|
|
object[] outParams = new object[] { };
|
|
|
|
bResult = this.Invoke("PlanBase", "PlanCreate", new object[] { mPLAN_MAIN, dtPLAN_LIST, _PLAN_ID, sResult }, out outParams);
|
|
|
|
sResult = outParams[3].ToString();
|
|
}
|
|
else if (dr["event"].ToString() == "1")///出库
|
|
{
|
|
string num = dr["equipNum"].ToString();
|
|
|
|
if (!(Convert.ToInt32(dr["equipNum"].ToString()) > 0))
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("失败,物料{0}计划入库数量小于0,任务不执行!", dr["equipCode"].ToString());
|
|
|
|
return sResult;
|
|
}
|
|
|
|
int _PLAN_ID = 0;
|
|
|
|
Model.PLAN_MAIN mPLAN_MAIN = new Model.PLAN_MAIN();
|
|
mPLAN_MAIN.PLAN_CREATE_TIME = dr["time"].ToString();
|
|
mPLAN_MAIN.PLAN_CREATER = "MES";
|
|
mPLAN_MAIN.PLAN_ID = 0;
|
|
mPLAN_MAIN.PLAN_STATUS = SiaSun.LMS.Enum.PLAN_STATUS.Waiting.ToString();
|
|
mPLAN_MAIN.PLAN_FLAG = "0";
|
|
mPLAN_MAIN.PLAN_TYPE_CODE = "PlanOut";
|
|
mPLAN_MAIN.PLAN_RELATIVE_ID = 0;
|
|
|
|
Model.PLAN_LIST mPLAN_LIST = new Model.PLAN_LIST();
|
|
|
|
mPLAN_LIST.PLAN_ID = 0;
|
|
mPLAN_LIST.PLAN_LIST_QUANTITY = Convert.ToInt32(dr["equipNum"].ToString());
|
|
mPLAN_LIST.PLAN_LIST_ORDERED_QUANTITY = 0;
|
|
mPLAN_LIST.PLAN_LIST_FINISHED_QUANTITY = 0;
|
|
mPLAN_LIST.GOODS_ID = mGOODS_MAIN.GOODS_ID;
|
|
|
|
List<PLAN_LIST> lmPLAN_LIST = new List<PLAN_LIST>();
|
|
|
|
lmPLAN_LIST.Add(mPLAN_LIST);
|
|
|
|
DataTable dtPLAN_LIST = CreateData(mPLAN_LIST);
|
|
|
|
DataRow dataRow = dtPLAN_LIST.NewRow();
|
|
foreach (PropertyInfo propertyInfo in typeof(SiaSun.LMS.Model.PLAN_LIST).GetProperties())
|
|
{
|
|
dataRow[propertyInfo.Name] = propertyInfo.GetValue(mPLAN_LIST, null);
|
|
}
|
|
dtPLAN_LIST.Rows.Add(dataRow);
|
|
|
|
object[] outParams = new object[] { };
|
|
|
|
bResult = this.Invoke("PlanBase", "PlanCreate", new object[] { mPLAN_MAIN, dtPLAN_LIST, _PLAN_ID, sResult }, out outParams);
|
|
|
|
sResult = outParams[3].ToString();
|
|
}
|
|
else
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("失败,任务状态{0}输入有误,任务不执行!", dr["enent"].ToString());
|
|
|
|
return sResult;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = "失败,未得到数据!";
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = "处理MES传入的参数错误" + ex.Message;
|
|
}
|
|
|
|
if (bResult == true)
|
|
{
|
|
sResult = "计划录入成功!";
|
|
}
|
|
|
|
return sResult;
|
|
}
|
|
|
|
|
|
public bool HttpPost( string JsonParas, out string sResult)
|
|
{
|
|
string _SapUrl ="http://192.168.181.39/api/yunhai/wms/stock/score";
|
|
|
|
// string strURL = "";
|
|
|
|
sResult = string.Empty;
|
|
|
|
bool bResult = true;
|
|
//创建一个HTTP请求
|
|
HttpWebRequest request;
|
|
|
|
HttpWebResponse resp;
|
|
#region
|
|
//Authorization auth;
|
|
|
|
// Dictionary<string, string> s = new Dictionary<string, string>();
|
|
|
|
// //s.Add("TOKEN", "hQeB+Y442Uk=");
|
|
|
|
//// s.Add("actionmethod", MethodName);
|
|
|
|
// s.Add("parms", JsonParas);
|
|
|
|
//jsonParas = "TOKEN=42A+o0BDiq8=&actionmethod=/WSO2/RequestDemo&JSONSTR=" + jsonParas;
|
|
#endregion
|
|
try
|
|
{
|
|
request = (HttpWebRequest)WebRequest.Create(_SapUrl);
|
|
|
|
request.Proxy = null;
|
|
|
|
// request.Headers.Add("ContentType", "application/json");
|
|
|
|
//Post请求方式
|
|
request.Method = "POST";
|
|
|
|
request.Timeout = 8000;
|
|
|
|
//内容类型
|
|
// request.ContentType = "application/x-www-form-urlencoded";
|
|
request.ContentType = "application/json";
|
|
|
|
|
|
//using (HttpClient httpClient = new HttpClient())
|
|
//{
|
|
// httpClient.Timeout = Timeout;
|
|
// using (HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("Post"), uri))
|
|
// {
|
|
// request.Headers.TryAddWithoutValidation("User-Agent", "Warehouse Management System");
|
|
// request.Headers.TryAddWithoutValidation("Content-Type", "application/json");
|
|
// request.Content = new StringContent(body, Encoding.UTF8);
|
|
// request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
|
|
// content = httpClient.SendAsync(request).Result.Content.ReadAsStringAsync().Result;
|
|
// }
|
|
//}
|
|
|
|
#region
|
|
//int i = 0;
|
|
|
|
//StringBuilder builder = new StringBuilder();
|
|
|
|
//foreach (var item in s)
|
|
//{
|
|
// if (i > 0)
|
|
// builder.Append("&");
|
|
// builder.AppendFormat("{0}={1}", item.Key, item.Value);
|
|
// i++;
|
|
//}
|
|
|
|
//string strDecrypt = builder.ToString();
|
|
|
|
//strDecrypt = strDecrypt.Replace("+","%2B");
|
|
|
|
#endregion
|
|
|
|
//string paraUrlCoded = System.Web.HttpUtility.UrlEncode("parms");
|
|
//paraUrlCoded += "=" + System.Web.HttpUtility.UrlEncode(JsonParas);
|
|
|
|
//byte[] payload = Encoding.UTF8.GetBytes(JsonParas);
|
|
byte[] payload = Encoding.UTF8.GetBytes(JsonParas);
|
|
|
|
request.ContentLength = payload.Length;
|
|
|
|
using (Stream reqStream = request.GetRequestStream())
|
|
{
|
|
reqStream.Write(payload, 0, payload.Length);
|
|
|
|
reqStream.Close();
|
|
}
|
|
//HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
//if (response.StatusCode == HttpStatusCode.OK)
|
|
//{
|
|
// Stream responseStream = response.GetResponseStream();
|
|
// StreamReader myStreamReader = new StreamReader(responseStream);
|
|
// sResult = myStreamReader.ReadToEnd();
|
|
//}
|
|
//response.Close();
|
|
resp = (HttpWebResponse)request.GetResponse();
|
|
|
|
Stream stream = resp.GetResponseStream();
|
|
|
|
//获取响应内容
|
|
using (StreamReader reader = new StreamReader(stream))
|
|
{
|
|
sResult = reader.ReadToEnd();
|
|
|
|
reader.Close();
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sResult = ex.Message.ToString();
|
|
bResult = false;
|
|
}
|
|
|
|
return bResult;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 查询极卷信息zupan
|
|
/// </summary>
|
|
/// <param name="labelNumber">标签号</param>
|
|
public bool MesRetry(string strRequest, out string sResult)
|
|
{
|
|
bool bResult = false;
|
|
sResult = string.Empty;
|
|
SiaSun.LMS.Common.Log log = new Common.Log();
|
|
//_sUsername = SiaSun.LMS.Common.StringUtil.GetConfig("wsUserName");
|
|
//_sPassword = SiaSun.LMS.Common.StringUtil.GetConfig("wsPassword");
|
|
|
|
try
|
|
{
|
|
bResult=this.HttpPost(strRequest, out sResult);
|
|
if (!bResult)
|
|
{
|
|
sResult = "调用接口报错信息:" + sResult + ":联系维护人员查看问题后再进行重发";
|
|
bResult = false;
|
|
}
|
|
else
|
|
{
|
|
#region 日志
|
|
Model.MES_INTERFACE_LOG mMES_INTERFACE_LOG = new Model.MES_INTERFACE_LOG();
|
|
mMES_INTERFACE_LOG.INTERFACE = "MesRetry";
|
|
mMES_INTERFACE_LOG.IN_MESSAGE = strRequest;
|
|
mMES_INTERFACE_LOG.OUT_MESSAGE = sResult;
|
|
mMES_INTERFACE_LOG.SENDER = "WMS";
|
|
mMES_INTERFACE_LOG.RECEIVER = "MES";
|
|
mMES_INTERFACE_LOG.TIME_STAMP = Common.StringUtil.GetDateTime();
|
|
this._P_MES_INTERFACE_LOG.Add(mMES_INTERFACE_LOG);
|
|
#endregion
|
|
}
|
|
//HeaderDetailOut response = new HeaderDetailOut();
|
|
//response= Newtonsoft.Json.JsonConvert.DeserializeObject<HeaderDetailOut>(sResult);
|
|
|
|
//if (response.IsSuccess.Equals("0"))
|
|
//{
|
|
// sResult = "接口重发失败";
|
|
// return bResult;
|
|
//}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//HostLog.Error("QueryPolarcoilInfo-" + ex);
|
|
log.SaveLog(ex.Message);
|
|
|
|
}
|
|
//#region 日志
|
|
//Model.MES_INTERFACE_LOG mMES_INTERFACE_LOG = new Model.MES_INTERFACE_LOG();
|
|
//mMES_INTERFACE_LOG.INTERFACE = "MesRetry";
|
|
//mMES_INTERFACE_LOG.IN_MESSAGE = strRequest;
|
|
//mMES_INTERFACE_LOG.OUT_MESSAGE = sResult;
|
|
//mMES_INTERFACE_LOG.SENDER = "WMS";
|
|
//mMES_INTERFACE_LOG.RECEIVER = "MES";
|
|
//mMES_INTERFACE_LOG.TIME_STAMP = Common.StringUtil.GetDateTime();
|
|
//this._P_MES_INTERFACE_LOG.Add(mMES_INTERFACE_LOG);
|
|
//#endregion
|
|
return bResult;
|
|
}
|
|
|
|
///// <summary>
|
|
///// 客户端查传递物料主数据
|
|
///// </summary>
|
|
///// <param name="labelNumber">标签号</param>
|
|
//public bool GoodsDataToBaili(string producttype, out string sResult)
|
|
//{
|
|
// bool bResult = false;
|
|
// sResult = string.Empty;
|
|
// SiaSun.LMS.Common.Log log = new Common.Log();
|
|
// //_sUsername = SiaSun.LMS.Common.StringUtil.GetConfig("wsUserName");
|
|
// //_sPassword = SiaSun.LMS.Common.StringUtil.GetConfig("wsPassword");
|
|
|
|
// //MaterialInfo hic = new MaterialInfo();
|
|
// //hic.productItems = new productItems[1];
|
|
// //hic.productItems[0] = new productItems();
|
|
|
|
// RESPONST_TO_BAILIMES baili = new RESPONST_TO_BAILIMES();
|
|
// baili.content = new Content[1];
|
|
// baili.content[0] = new Content();
|
|
// try
|
|
// {
|
|
// IList<GOODS_MAIN> lstgoods = this._P_GOODS_MAIN.GetList();
|
|
// foreach (GOODS_MAIN gds in lstgoods)
|
|
// {
|
|
// //百利 原材料
|
|
// baili.content[0].ProductType = "01";
|
|
// baili.content[0].MaterialCodification = gds.GOODS_CODE;
|
|
// baili.content[0].Name = gds.GOODS_NAME;
|
|
// baili.content[0].Specification = gds.GOODS_CONST_PROPERTY1;
|
|
// baili.content[0].UnitID = gds.GOODS_UNITS;
|
|
// baili.content[0].PartNo = gds.GOODS_CONST_PROPERTY3;
|
|
// baili.content[0].Status = "有效";
|
|
|
|
// //原材料 琥崧
|
|
// //hic.productItems[0].productType = "物料";
|
|
// //hic.productItems[0].materialCodification = gds.GOODS_CODE;
|
|
// //hic.productItems[0].name = gds.GOODS_NAME;
|
|
// //hic.productItems[0].specification = gds.GOODS_CONST_PROPERTY1;
|
|
// //hic.productItems[0].code = gds.GOODS_CONST_PROPERTY2;
|
|
// //hic.productItems[0].partNo = gds.GOODS_CONST_PROPERTY3;
|
|
// //hic.productItems[0].supplierPartNo = gds.GOODS_CONST_PROPERTY4;
|
|
|
|
// //if (S_ERPService.Post($"{HusongUrl}syncProductItems", Common.JsonHelper.Serializer(hic), out string cont))
|
|
// //{
|
|
// // HusongResponseData data = Common.JsonHelper.Deserialize<HusongResponseData>(cont);
|
|
// // if (data != null && (data.success==true))
|
|
// // {
|
|
// // sResult += $"推送琥崧成品入库成功\n";
|
|
// // }
|
|
// // else
|
|
// // {
|
|
// // bResult = false;
|
|
// // sResult += $"推送琥崧成品入库失败 {(data != null && !string.IsNullOrWhiteSpace(data.msg) ? data.msg : cont)}\n";
|
|
// // }
|
|
// //}
|
|
// //else
|
|
// //{
|
|
// // bResult = false;
|
|
// // sResult += $"推送佰利成品入库异常\n";
|
|
// //}
|
|
// if (S_ERPService.Post($"{BailiUrl}saveMaterialInfo", Common.JsonHelper.Serializer(baili), out string cont))
|
|
// {
|
|
// BailiResponseData data = Common.JsonHelper.Deserialize<BailiResponseData>(cont);
|
|
// if (data != null && (data.code.Equals("200")))
|
|
// {
|
|
// sResult += $"推送百利物料数据成功\n";
|
|
// }
|
|
// else
|
|
// {
|
|
// bResult = false;
|
|
// sResult += $"推送百利物料数据失败 {(data != null && !string.IsNullOrWhiteSpace(data.message) ? data.message : cont)}\n";
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// bResult = false;
|
|
// sResult += $"推送百利物料数据异常\n";
|
|
// }
|
|
|
|
|
|
// }
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// //HostLog.Error("QueryPolarcoilInfo-" + ex);
|
|
// log.SaveLog(ex.Message);
|
|
|
|
// }
|
|
|
|
// return bResult;
|
|
//}
|
|
|
|
public static bool Post(string uri, string body, out string content)
|
|
{
|
|
try
|
|
{
|
|
using (HttpClient httpClient = new HttpClient())
|
|
{
|
|
//TimeSpan timeout = DateTime.Now;
|
|
//httpClient.Timeout = Timeout;
|
|
using (HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("Post"), uri))
|
|
{
|
|
request.Headers.TryAddWithoutValidation("User-Agent", "Warehouse Management System");
|
|
request.Headers.TryAddWithoutValidation("Content-Type", "application/json");
|
|
request.Content = new StringContent(body, Encoding.UTF8);
|
|
request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
|
|
content = httpClient.SendAsync(request).Result.Content.ReadAsStringAsync().Result;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
content = $"异常 {ex.Message}";
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据MES组盘,暂存区
|
|
/// </summary>
|
|
/// <param name="json"></param>
|
|
/// <param name="body"></param>
|
|
/// <param name="content"></param>
|
|
/// <returns></returns>
|
|
public bool MesInfo(string json, out string sResult)
|
|
{
|
|
bool bResult = false;
|
|
sResult = string.Empty;
|
|
ManageIn manageIn = new ManageIn();
|
|
|
|
SiaSun.LMS.Model.MANAGE_MAIN mMANAGE_MAIN = null;
|
|
|
|
SiaSun.LMS.Model.MANAGE_LIST mMANAGE_LIST = null;
|
|
|
|
List<SiaSun.LMS.Model.MANAGE_LIST> lsMANAGE_LIST = new List<SiaSun.LMS.Model.MANAGE_LIST>();
|
|
#region 生成MANAGE_MAIN
|
|
//生成暂存区库存
|
|
mMANAGE_MAIN = new Model.MANAGE_MAIN();
|
|
|
|
mMANAGE_MAIN.PLAN_ID = 0;
|
|
|
|
mMANAGE_MAIN.PLAN_TYPE_CODE = string.Empty;
|
|
|
|
mMANAGE_MAIN.MANAGE_TYPE_CODE = SiaSun.LMS.Enum.MANAGE_TYPE.ManageMove.ToString();
|
|
|
|
mMANAGE_MAIN.MANAGE_STATUS = SiaSun.LMS.Enum.MANAGE_STATUS.Waiting.ToString();
|
|
|
|
mMANAGE_MAIN.STOCK_BARCODE = "ABC1070402001093";
|
|
|
|
// mMANAGE_MAIN.FULL_FLAG = mSTORAGE_MAIN.FULL_FLAG;
|
|
|
|
mMANAGE_MAIN.CELL_MODEL = "0";
|
|
|
|
mMANAGE_MAIN.START_CELL_ID =0;
|
|
|
|
mMANAGE_MAIN.END_CELL_ID = 0;
|
|
|
|
mMANAGE_MAIN.MANAGE_OPERATOR = "MES";
|
|
|
|
mMANAGE_MAIN.MANAGE_BEGIN_TIME = SiaSun.LMS.Common.StringUtil.GetCurDateTimeString();
|
|
|
|
#endregion
|
|
|
|
#region 生成MANAGE_LIST
|
|
|
|
mMANAGE_LIST = new Model.MANAGE_LIST();
|
|
|
|
mMANAGE_LIST.GOODS_ID = 910;
|
|
|
|
mMANAGE_LIST.PLAN_LIST_ID = 0;
|
|
|
|
mMANAGE_LIST.STORAGE_LIST_ID = 0;
|
|
|
|
mMANAGE_LIST.MANAGE_LIST_QUANTITY =1;
|
|
|
|
mMANAGE_LIST.MANAGE_LIST_REMARK ="";
|
|
mMANAGE_LIST.GOODS_PROPERTY6 = "未翻转";
|
|
|
|
lsMANAGE_LIST.Add(mMANAGE_LIST);
|
|
|
|
bResult= manageIn.ManageCreate(mMANAGE_MAIN, lsMANAGE_LIST,true,true,false, out sResult);
|
|
|
|
#endregion
|
|
//条码作为托盘码,物料码从中截取
|
|
|
|
bResult = this.ApplyIn(mMANAGE_MAIN.STOCK_BARCODE, out sResult, out string lany_way);
|
|
return bResult;
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="json"></param>
|
|
/// <param name="body"></param>
|
|
/// <param name="content"></param>
|
|
/// <returns></returns>
|
|
public bool ApplyIn(string stock_barcode, out string sResult, out string lane_way)
|
|
{
|
|
bool bResult = false;
|
|
sResult=string.Empty;
|
|
int end_cell_id = 0;
|
|
Common.Log log = new Common.Log();
|
|
|
|
lane_way = "2";
|
|
//物料码转托盘码
|
|
string good_code = stock_barcode.Substring(3,12);
|
|
//查翻转机构库存,CELL_LOGICAL_NAME是FZ就是翻转货位
|
|
string sqlfz = string.Format("select * from wh_cell where cell_status='Nohave' and run_status='Enable' and CELL_LOGICAL_NAME = 'FZ'", stock_barcode);
|
|
DataTable dtfz = this.GetList(sqlfz);
|
|
#region 查管理和调度任务
|
|
//查管理任务
|
|
string sql4 = string.Format("select * from manage_main where stock_barcode='{0}'", stock_barcode);
|
|
DataTable dt4 = this.GetList(sql4);
|
|
//查调度任务
|
|
string sql5 = string.Format("select * from io_control where stock_barcode='{0}'", stock_barcode);
|
|
DataTable dt5 = this.GetList(sql5);
|
|
#endregion
|
|
#region 查CELL_ID
|
|
///查暂存区CELL_ID
|
|
string sql6 = string.Format("SELECT CELL_ID FROM WH_CELL WHERE CELL_CODE = 'zcq'");
|
|
DataTable dt6 = this.GetList(sql6);
|
|
///查CELL_ID
|
|
string sql7 = string.Format("SELECT CELL_ID FROM WH_CELL WHERE CELL_CODE = '{0}'", "12001");
|
|
DataTable dt7 = this.GetList(sql7);
|
|
#endregion
|
|
string strSQL = string.Format(@"SELECT * FROM WH_CELL WHERE 1=1 AND CELL_STATUS = 'Nohave'and cell_type='cell' and area_id=1
|
|
AND RUN_STATUS = 'Enable' ORDER BY CELL_X,CELL_Y,CELL_Z");
|
|
|
|
DataTable dtCELL = base.GetList(strSQL);
|
|
|
|
if (dtCELL.Rows.Count <=0)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("可用货位不足");
|
|
|
|
return bResult;
|
|
}
|
|
lane_way = dtCELL.Rows[0]["LANE_WAY"].ToString();
|
|
ManageIn manageIn = new ManageIn();
|
|
///上报高度
|
|
/// CELL_MODEL = "0";
|
|
//有管理和控制任务不能入库
|
|
if (dt4.Rows.Count > 0 || dt5.Rows.Count > 0)
|
|
{
|
|
bResult = false;
|
|
|
|
sResult = string.Format("托盘条码[{0}]存在未完成的任务!", stock_barcode);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
//判断翻转是否有可用货位
|
|
if (dtfz.Rows.Count <= 0)
|
|
{
|
|
//入到正常货位里面,logic_area=0传入,实际是用CELL_LOGIC_NAME来找的翻转货位,CELL表里面用CELL_LOGIC_NAME为FZ标记翻转货位,
|
|
bResult = new ManageUp().ManageCreate(stock_barcode.TrimEnd(), Convert.ToInt32(dt7.Rows[0]["CELL_ID"].ToString()), end_cell_id, "0", "0", true, true, "SYS", out sResult);
|
|
log.SaveLog("MES调用入库:"+sResult);
|
|
return bResult;
|
|
|
|
}
|
|
else
|
|
{
|
|
//入到反转货位里面 logic_area='FZ',传入,实际是用CELL_LOGIC_NAME来找的翻转货位,CELL表里面用CELL_LOGIC_NAME为FZ标记翻转货位
|
|
bResult = new ManageUp().ManageCreate(stock_barcode.TrimEnd(), Convert.ToInt32(dt7.Rows[0]["CELL_ID"].ToString()), end_cell_id, "0", "FZ", true, true, "SYS", out sResult);
|
|
log.SaveLog("MES调用入库:" + sResult);
|
|
return bResult;
|
|
#region \\控制任务 暂时用不上
|
|
//SiaSun.LMS.Model.IO_CONTROL mIO_CONTROL = new SiaSun.LMS.Model.IO_CONTROL();
|
|
//mIO_CONTROL.RELATIVE_CONTROL_ID = -1;
|
|
//mIO_CONTROL.MANAGE_ID = 0;
|
|
//mIO_CONTROL.STOCK_BARCODE = mIO_CONTROL_APPLY.STOCK_BARCODE;
|
|
//mIO_CONTROL.CONTROL_TASK_LEVEL = "0";
|
|
//mIO_CONTROL.PRE_CONTROL_STATUS = string.Empty;
|
|
//mIO_CONTROL.CONTROL_TASK_TYPE = 4;
|
|
//mIO_CONTROL.START_DEVICE_CODE = mIO_CONTROL_APPLY.DEVICE_CODE;
|
|
//mIO_CONTROL.END_DEVICE_CODE = "12101";
|
|
//mIO_CONTROL.CONTROL_BEGIN_TIME = SiaSun.LMS.Common.StringUtil.GetDateTime();
|
|
|
|
//mIO_CONTROL.CONTROL_STATUS = 0;
|
|
//mIO_CONTROL.START_WAREHOUSE_CODE = "1";
|
|
//mIO_CONTROL.END_WAREHOUSE_CODE = "1";
|
|
|
|
//mIO_CONTROL.ERROR_TEXT = "";
|
|
|
|
//this._P_IO_CONTROL.Add(mIO_CONTROL);
|
|
#endregion
|
|
}
|
|
|
|
// return bResult;
|
|
}
|
|
|
|
|
|
}
|
|
}
|