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.
349 lines
12 KiB
349 lines
12 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Threading;
|
|
using System.Web;
|
|
using System.Web.Script.Services;
|
|
using System.Web.Services;
|
|
using MESClassLibrary;
|
|
using MESClassLibrary.BLL.TruckBox;
|
|
using OPCAutomation;
|
|
using Webservice;
|
|
using WebService.Model;
|
|
using JSONTools = Tools.JSONTools;
|
|
|
|
namespace WebService
|
|
{
|
|
/// <summary>
|
|
/// TruckBoxWebService 的摘要说明
|
|
/// </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 TruckBoxWebService : System.Web.Services.WebService
|
|
{
|
|
|
|
[WebMethod]
|
|
public string HelloWorld()
|
|
{
|
|
return "Hello World";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 零件加注
|
|
/// </summary>
|
|
/// <param name="app_id"></param>
|
|
/// <param name="partName"></param>
|
|
/// <param name="batchNo"></param>
|
|
/// <param name="sign"></param>
|
|
[WebMethodAttribute]
|
|
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
|
|
public void AddPartInfo(string app_id, string partName, string bucketNo, string batchNo, 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(partName))
|
|
{
|
|
model.ErrReason = "缺少必要传入参数 partName";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
if (string.IsNullOrWhiteSpace(bucketNo) && partName=="底涂剂")
|
|
{
|
|
model.ErrReason = "缺少必要传入参数 bucketNo";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
if (string.IsNullOrWhiteSpace(batchNo))
|
|
{
|
|
model.ErrReason = "缺少必要传入参数 batchNo";
|
|
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(), partName.Trim(), bucketNo.Trim(), batchNo.Trim() };
|
|
bool paramIsRight = Function.signIsRight(param, sign);
|
|
if (!paramIsRight)
|
|
{
|
|
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
if (!Function.CheckPart(partName))
|
|
{
|
|
model.ErrReason = "零件名称有误";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
|
|
#region 给PLC写入
|
|
|
|
if (partName == "底涂剂")
|
|
{
|
|
//条码格式:零件号/失效日期/生产日期
|
|
string[] barCode = batchNo.Split('/');
|
|
if (barCode.Length != 3)
|
|
{
|
|
model.ErrReason = "底涂剂条码有误";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
|
|
#region 校验是否需要加底涂剂
|
|
|
|
if (bucketNo.Contains("1"))
|
|
{
|
|
#region 写入失效日期、保质期、加注完成
|
|
|
|
if (Function.UpdateDone(59, barCode[1], barCode[2]) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
model.ErrReason = "1#罐加注失败";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
if (bucketNo.Contains("2"))
|
|
{
|
|
#region 写入失效日期、保质期、加注完成
|
|
|
|
if (Function.UpdateDone(60, barCode[1], barCode[2]) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
model.ErrReason = "2#罐加注失败";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
|
|
if (Function.SavePart(partName,bucketNo, batchNo, out errorReason) >= 1)
|
|
{
|
|
model.Result = "1";
|
|
model.ResultType = "Result";
|
|
model.ResultRowsCount = "0";
|
|
model.ErrReason = "";
|
|
model.DataList = null;
|
|
|
|
LogHelper.WriteSysLogBase("保存零件批次信息,入参partName:" + partName + ",batchNo:" + batchNo + "已保存", MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
else
|
|
{
|
|
model.Result = "0";
|
|
model.ResultType = "Result";
|
|
model.ResultRowsCount = "0";
|
|
model.ErrReason = errorReason;
|
|
model.DataList = null;
|
|
}
|
|
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
}
|
|
|
|
[WebMethodAttribute]
|
|
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
|
|
public void GetPart(string app_id, string sign)
|
|
{
|
|
string errorReason = "";
|
|
|
|
JsonModel<AddPartModel> model = new JsonModel<AddPartModel>();
|
|
model.Result = "0";
|
|
model.ResultType = "List";
|
|
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<AddPartModel>>(model));
|
|
return;
|
|
}
|
|
|
|
bool access = Function.AppIDIsRight(app_id.Trim());
|
|
if (!access)
|
|
{
|
|
model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<AddPartModel>>(model));
|
|
return;
|
|
}
|
|
|
|
string[] param = { Function.app_secret.Trim()};
|
|
bool paramIsRight = Function.signIsRight(param, sign);
|
|
if (!paramIsRight)
|
|
{
|
|
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<AddPartModel>>(model));
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
List<AddPartModel> list = new List<AddPartModel>();
|
|
|
|
DataTable dt = Function.GetPartInfo();
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
AddPartModel mod = new AddPartModel();
|
|
mod.PartName = dt.Rows[i][0].ToString();
|
|
|
|
list.Add(mod);
|
|
}
|
|
}
|
|
|
|
model.Result = "1";
|
|
model.ResultType = "List";
|
|
model.ResultRowsCount = dt.Rows.Count.ToString();
|
|
model.ErrReason = errorReason;
|
|
model.DataList = list;
|
|
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<AddPartModel>>(model));
|
|
}
|
|
|
|
[WebMethodAttribute]
|
|
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
|
|
public void ScanBucket(string app_id, string barCode, 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(barCode))
|
|
{
|
|
model.ErrReason = "缺少必要传入参数 barCode";
|
|
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(), barCode.Trim() };
|
|
bool paramIsRight = Function.signIsRight(param, sign);
|
|
if (!paramIsRight)
|
|
{
|
|
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
|
|
if (barCode != "1" && barCode != "2")
|
|
{
|
|
model.ErrReason = "barCode参数传输错误";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
if (barCode.Contains("1"))
|
|
{
|
|
if (!Function.IsAdd("BBMPT1.ZP.Add1"))
|
|
{
|
|
model.ErrReason = "1#罐不需要加注";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
model.Result = "1";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
}
|
|
}
|
|
|
|
if (barCode.Contains("2"))
|
|
{
|
|
if (!Function.IsAdd("BBMPT1.ZP.Add2"))
|
|
{
|
|
model.ErrReason = "2#罐不需要加注";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
model.Result = "1";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|