一厂MES,含注塑,喷涂,冲孔
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.
 
 
 
 
 

579 lines
22 KiB

using AppWebservice.Model;
using System.Collections.Generic;
using System.Data;
using System.Web.Script.Services;
using System.Web.Services;
using Tools;
namespace AppWebservice
{
/// <summary>
/// AppWebservice 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
// [System.Web.Script.Services.ScriptService]
public class AppWebservice : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void MD5Encrypt(string str)
{
string errorReason = "";
JsonModel<NoModel> model = new JsonModel<NoModel>();
model.Result = "0";
model.ResultType = "List";
model.ResultRowsCount = "0";
model.ErrReason = errorReason;
model.DataList = null;
List<NoModel> res = new List<NoModel>();
if (!string.IsNullOrWhiteSpace(str))
{
DataTable dt = new DataTable();
dt.Columns.Add("result");
DataRow dr = dt.NewRow();
dr[0] = Function.MD5Encryption(str);
dt.Rows.Add(dr);
res = Tools.DataTableToList.ConvertTo<NoModel>(dt);
model.Result = "0";
model.ResultRowsCount = "1";
model.DataList = res;
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
}
else
{
model.ErrReason = "缺少必要的传入参数 服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
}
/// <summary>
/// 根据塑料粒子条码查询加料信息
/// lx 20190527
/// </summary>
/// <param name="app_id"></param>
/// <param name="particleCode"></param>
/// <param name="sign"></param>
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void GetInfoByParticles(string app_id, string particleCode, string sign)
{
string errorReason = "";
JsonModel<InfoModel> model = new JsonModel<InfoModel>();
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = errorReason;
model.DataList = null;
#region 参数判断
if (string.IsNullOrWhiteSpace(app_id))
{
model.ErrReason = "缺少必要传入参数 app_id";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<InfoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(particleCode))
{
model.ErrReason = "缺少必要传入参数 particleCode";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<InfoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(sign))
{
model.ErrReason = "缺少必要传入参数 sign";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<InfoModel>>(model));
return;
}
bool access = Function.AppIDIsRight(app_id.Trim());
if (!access)
{
model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<InfoModel>>(model));
return;
}
string[] param = { Function.app_secret.Trim(), particleCode.Trim() };
bool paramIsRight = Function.signIsRight(param, sign);
if (!paramIsRight)
{
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<InfoModel>>(model));
return;
}
#endregion
#region 解析塑料粒子条码
//解析塑料粒子条码,长度为20的为一维码,否则为二维码
//二维码样例Z-340.180411.000001;5000;S35001;20180411;P1710401.[#Line#];180411;
//第一个分号之前的数据,即Z-340.180411.000001; Z-340为零件号,180411为批次号,000001为流水号
//一维码前十位为零件号,tb_Product PartNo,11~16位为批次
string stockNo = ""; //存货代码
string batchNo = ""; //批次
Function.GetCode(particleCode, out stockNo, out batchNo);
#endregion
if (!string.IsNullOrWhiteSpace(stockNo))
{
DataTable dt = Function.GetInfoByParticles(stockNo, out errorReason);
List<InfoModel> listInfo = new List<InfoModel>();
if (dt.Rows.Count < 1)
{
model.Result = "0";
}
else
{
model.Result = "1";
InfoModel info = new InfoModel();
info.Code = stockNo;
info.Name = dt.Rows[0]["PartName"].ToString();
info.Type = dt.Rows[0]["PartNo"].ToString();
info.CarType = "塑料粒子";
info.Color = dt.Rows[0]["ColorName"].ToString();
info.Batch = batchNo;
info.Stock = "";
listInfo.Add(info);
}
model.ErrReason = errorReason;
model.ResultRowsCount = dt.Rows.Count.ToString();
model.DataList = listInfo;
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<InfoModel>>(model));
}
else
{
model.Result = "0";
model.ErrReason = "塑料粒子条码错误,无法解析";
model.ResultRowsCount = "0";
model.DataList = null;
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<InfoModel>>(model));
}
}
/// <summary>
/// 料筒与塑料粒子关系绑定
/// lx 20190527
/// </summary>
/// <param name="app_id"></param>
/// <param name="particleCode">塑料粒子</param>
/// /// <param name="drumCode">料筒</param>
/// <param name="sign"></param>
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void BindparticleCodeAndDrum(string app_id, string particleCode, string drumCode, string sign)
{
string errorReason = "";
JsonModel<NoModel> model = new JsonModel<NoModel>();
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = errorReason;
model.DataList = null;
#region 参数判断
if (string.IsNullOrWhiteSpace(app_id))
{
model.ErrReason = "缺少必要传入参数 app_id";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(particleCode))
{
model.ErrReason = "缺少必要传入参数 particleCode";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(drumCode))
{
model.ErrReason = "缺少必要传入参数 drumCode";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(sign))
{
model.ErrReason = "缺少必要传入参数 sign";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
bool access = Function.AppIDIsRight(app_id.Trim());
if (!access)
{
model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
string[] param = { Function.app_secret.Trim(), particleCode.Trim(), drumCode.Trim() };
bool paramIsRight = Function.signIsRight(param, sign);
if (!paramIsRight)
{
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
#endregion
int res = Function.BindparticleCodeAndDrum(particleCode, drumCode, out errorReason);
if (res < 1)
{
model.Result = "0";
}
else
{
model.Result = "1";
}
model.ErrReason = errorReason;
model.ResultRowsCount = res.ToString();
model.DataList = null;
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
}
/// <summary>
/// 根据注塑机条码查询计划信息
/// lx 20190527
/// </summary>
/// <param name="app_id"></param>
/// <param name="machineCode"></param>
/// <param name="sign"></param>
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void GetPlan(string app_id, string machineCode, string sign)
{
string errorReason = "";
JsonModel<PlanModel> model = new JsonModel<PlanModel>();
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = errorReason;
model.DataList = null;
#region 参数判断
if (string.IsNullOrWhiteSpace(app_id))
{
model.ErrReason = "缺少必要传入参数 app_id";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PlanModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(machineCode))
{
model.ErrReason = "缺少必要传入参数 machineCode";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PlanModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(sign))
{
model.ErrReason = "缺少必要传入参数 sign";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PlanModel>>(model));
return;
}
bool access = Function.AppIDIsRight(app_id.Trim());
if (!access)
{
model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PlanModel>>(model));
return;
}
string[] param = { Function.app_secret.Trim(), machineCode.Trim() };
bool paramIsRight = Function.signIsRight(param, sign);
if (!paramIsRight)
{
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PlanModel>>(model));
return;
}
#endregion
DataTable dt = Function.GetPlan(machineCode, out errorReason);
List<PlanModel> listInfo = new List<PlanModel>();
if (dt.Rows.Count < 1)
{
model.Result = "0";
}
else
{
model.Result = "1";
listInfo = Tools.DataTableToList.ConvertTo<PlanModel>(dt);
}
model.ErrReason = errorReason;
model.ResultRowsCount = dt.Rows.Count.ToString();
model.DataList = listInfo;
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PlanModel>>(model));
}
/// <summary>
/// 根据料筒条码查询加料信息
/// </summary>
/// <param name="app_id"></param>
/// <param name="drumCode"></param>
/// <param name="sign"></param>
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void GetMaterialInfo(string app_id, string drumCode, string sign)
{
string errorReason = "";
JsonModel<MaterialInfoModel> model = new JsonModel<MaterialInfoModel>();
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = errorReason;
model.DataList = null;
#region 参数判断
if (string.IsNullOrWhiteSpace(app_id))
{
model.ErrReason = "缺少必要传入参数 app_id";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<MaterialInfoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(drumCode))
{
model.ErrReason = "缺少必要传入参数 drumCode";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<MaterialInfoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(sign))
{
model.ErrReason = "缺少必要传入参数 sign";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<MaterialInfoModel>>(model));
return;
}
bool access = Function.AppIDIsRight(app_id.Trim());
if (!access)
{
model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<MaterialInfoModel>>(model));
return;
}
string[] param = { Function.app_secret.Trim(), drumCode.Trim() };
bool paramIsRight = Function.signIsRight(param, sign);
if (!paramIsRight)
{
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<MaterialInfoModel>>(model));
return;
}
#endregion
DataTable dt = Function.GetMaterialInfo(drumCode, out errorReason);
string cylinderBarCode = dt.Rows[0][0].ToString();
string stockNo = ""; //存货代码
string batchNo = ""; //批次
Function.GetCode(cylinderBarCode, out stockNo, out batchNo);
if (!string.IsNullOrWhiteSpace(stockNo))
{
DataTable dt_info = Function.GetInfoByParticles(stockNo, out errorReason);
List<MaterialInfoModel> listInfo = new List<MaterialInfoModel>();
if (dt.Rows.Count < 1)
{
model.Result = "0";
}
else
{
model.Result = "1";
MaterialInfoModel info = new MaterialInfoModel();
info.Code = cylinderBarCode;
info.Name = dt_info.Rows[0]["PartName"].ToString();
info.Batch = batchNo;
listInfo.Add(info);
}
model.ErrReason = errorReason;
model.ResultRowsCount = dt.Rows.Count.ToString();
model.DataList = listInfo;
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<MaterialInfoModel>>(model));
}
else
{
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = "未获取到加料信息";
model.DataList = null;
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<MaterialInfoModel>>(model));
}
}
/// <summary>
/// 注塑机与料筒关系绑定
/// lx 20190527
/// </summary>
/// <param name="app_id"></param>
/// <param name="machineCode"></param>
/// <param name="drumCode"></param>
/// <param name="sign"></param>
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void BindMachineAndDrum(string app_id, string machineCode, string drumCode, string sign)
{
string errorReason = "";
JsonModel<NoModel> model = new JsonModel<NoModel>();
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = errorReason;
model.DataList = null;
#region 参数判断
if (string.IsNullOrWhiteSpace(app_id))
{
model.ErrReason = "缺少必要传入参数 app_id";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(machineCode))
{
model.ErrReason = "缺少必要传入参数 machineCode";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(drumCode))
{
model.ErrReason = "缺少必要传入参数 drumCode";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(sign))
{
model.ErrReason = "缺少必要传入参数 sign";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
bool access = Function.AppIDIsRight(app_id.Trim());
if (!access)
{
model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
string[] param = { Function.app_secret.Trim(), machineCode.Trim(), drumCode.Trim() };
bool paramIsRight = Function.signIsRight(param, sign);
if (!paramIsRight)
{
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
#endregion
int res = Function.BindMachineAndDrum(machineCode, drumCode, out errorReason);
if (res < 1)
{
model.Result = "0";
}
else
{
model.Result = "1";
}
model.ErrReason = errorReason;
model.ResultRowsCount = res.ToString();
model.DataList = null;
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
}
/// <summary>
/// 料筒清空关系解绑
/// lx 20190527
/// </summary>
/// <param name="app_id"></param>
/// <param name="drumCode"></param>
/// <param name="sign"></param>
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void ClearDrum(string app_id, string drumCode, string sign)
{
string errorReason = "";
JsonModel<NoModel> model = new JsonModel<NoModel>();
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = errorReason;
model.DataList = null;
#region 参数判断
if (string.IsNullOrWhiteSpace(app_id))
{
model.ErrReason = "缺少必要传入参数 app_id";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(drumCode))
{
model.ErrReason = "缺少必要传入参数 drumCode";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(sign))
{
model.ErrReason = "缺少必要传入参数 sign";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
bool access = Function.AppIDIsRight(app_id.Trim());
if (!access)
{
model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
string[] param = { Function.app_secret.Trim(), drumCode.Trim() };
bool paramIsRight = Function.signIsRight(param, sign);
if (!paramIsRight)
{
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
#endregion
int res = Function.ClearDrum(drumCode, out errorReason);
if (res < 1)
{
model.Result = "0";
}
else
{
model.Result = "1";
}
model.ErrReason = errorReason;
model.ResultRowsCount = res.ToString();
model.DataList = null;
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
}
}
}