一厂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.
 
 
 
 
 

611 lines
25 KiB

using System.Collections.Generic;
using System.Data;
using System.Reflection;
using System.Web.Script.Services;
using System.Web.Services;
using Tools;
using Webservice;
using WebService.Model;
namespace WebService
{
/// <summary>
/// PaintWebservice 的摘要说明
/// </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 PaintWebservice : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
/// <summary>
/// 根据油漆条码查询油漆信息
/// </summary>
/// <param name="app_id"></param>
/// <param name="PaintCode"></param>
/// <param name="sign"></param>
[WebMethodAttribute]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void GetInfoByPaintCode(string app_id, string PaintCode, string sign)
{
string errorReason = "";
JsonModel<PaintInfoModel> model = new JsonModel<PaintInfoModel>();
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<PaintInfoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(PaintCode))
{
model.ErrReason = "缺少必要传入参数 PaintCode";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PaintInfoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(sign))
{
model.ErrReason = "缺少必要传入参数 sign";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PaintInfoModel>>(model));
return;
}
bool access = Function.AppIDIsRight(app_id.Trim());
if (!access)
{
model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PaintInfoModel>>(model));
return;
}
string[] param = { Function.app_secret.Trim(), PaintCode.Trim() };
bool paramIsRight = Function.signIsRight(param, sign);
if (!paramIsRight)
{
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PaintInfoModel>>(model));
return;
}
#endregion
DataTable dtIsUsing = Function.GetPaintInfoIsUsing(PaintCode, out errorReason);
if (dtIsUsing.Rows.Count < 1)
{
model.ErrReason = "油漆条码已停用或有误";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PaintInfoModel>>(model));
return;
}
DataTable dt = Function.GetPaintInfo(PaintCode, out errorReason);
List<PaintInfoModel> listInfo = new List<PaintInfoModel>();
if (dt != null && dt.Rows.Count > 0)
{
model.Result = "1";
PaintInfoModel info = new PaintInfoModel();
info.PaintName = dt.Rows[0]["PaintName"].ToString();
info.PaintModel = dt.Rows[0]["PaintModel"].ToString();
info.UnitCode = dt.Rows[0]["UnitCode"].ToString();
info.CarModelCode = dt.Rows[0]["CarModelCode"].ToString();
listInfo.Add(info);
}
else
{
model.Result = "0";
}
model.ErrReason = errorReason;
model.ResultRowsCount = dt.Rows.Count.ToString();
model.DataList = listInfo;
LogHelper.WriteSysLogBase("【加漆防错-根据油漆条码返回油漆信息】入参:PaintCode:" + PaintCode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<PaintInfoModel>>(model), MethodBase.GetCurrentMethod().Name);
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PaintInfoModel>>(model));
}
/// <summary>
/// 油漆和油漆桶匹配
/// </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 CheckPaint(string app_id, string PaintCode, 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(PaintCode))
{
model.ErrReason = "缺少必要传入参数 PaintCode";
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(), PaintCode.Trim(), DrumCode.Trim() };
bool paramIsRight = Function.signIsRight(param, sign);
if (!paramIsRight)
{
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
#endregion
DataTable dt = Function.IsMatch(PaintCode, DrumCode, out errorReason);
if (dt != null && dt.Rows.Count > 0)
{
model.Result = "1";
}
else
{
model.Result = "0";
}
model.ErrReason = errorReason;
model.ResultRowsCount = dt.Rows.Count.ToString();
model.DataList = null;
LogHelper.WriteSysLogBase("【加漆防错-油漆和油漆桶匹配】入参:PaintCode:" + PaintCode + ",DrumCode:" + DrumCode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<NoModel>>(model), MethodBase.GetCurrentMethod().Name);
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(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 ScanDrumCode(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
DataTable dt1 = Function.IsExitBucketCode(DrumCode, out errorReason);
if (dt1 != null && dt1.Rows.Count > 0)
{
}
else
{
model.ErrReason = "油漆桶" + DrumCode + "系统中不存在";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
DataTable dt2 = Function.IsEmpty(DrumCode, out errorReason);
if (dt2 != null && dt2.Rows.Count > 0)
{
if (!string.IsNullOrWhiteSpace(dt2.Rows[0]["PaintCode"].ToString()))
{
model.ErrReason = "油漆桶" + DrumCode + "已加注油漆或清洗剂,请清空后再加注";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
}
LogHelper.WriteSysLogBase("【加漆-扫描油漆桶】入参:PaintDrumCode:" + DrumCode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<NoModel>>(model), MethodBase.GetCurrentMethod().Name);
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
}
/// <summary>
/// 油漆加注
/// </summary>
/// <param name="app_id"></param>
/// <param name="PaintCode"></param>
/// <param name="DrumCode"></param>
/// <param name="sign"></param>
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void ScanPaint(string app_id, string PaintCode, 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(PaintCode))
{
model.ErrReason = "缺少必要传入参数 PaintCode";
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(), PaintCode.Trim(), DrumCode.Trim() };
bool paramIsRight = Function.signIsRight(param, sign);
if (!paramIsRight)
{
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
#endregion
DataTable dt1 = Function.IsExitBucketCode(DrumCode, out errorReason);
if (dt1 != null && dt1.Rows.Count > 0)
{
}
else
{
model.ErrReason = "油漆系统条码" + DrumCode + "在系统中不存在";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
DataTable dt2 = Function.IsEmpty(DrumCode, out errorReason);
if (dt2 != null && dt2.Rows.Count > 0)
{
if (!string.IsNullOrWhiteSpace(dt2.Rows[0]["PaintCode"].ToString()))
{
model.ErrReason = "油系统条码" + DrumCode + "已加注油漆或清洗剂,请清空后再加注";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
}
DataTable dtIsUsing = Function.GetPaintInfoIsUsing(PaintCode, out errorReason);
if (dtIsUsing.Rows.Count < 1)
{
model.ErrReason = "油漆条码已停用或有误";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
if (Function.IsExitPaintCode(PaintCode))
{
model.ErrReason = "该油漆已经加注在油漆系统中";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
int state = Function.IsPaint(PaintCode) == 1 ? 1 : 2;
int res = Function.AddPaint(PaintCode, DrumCode, state,out errorReason);
model.Result = res < 1 ? "0" : "1";
model.ErrReason = errorReason;
model.ResultRowsCount = res.ToString();
model.DataList = null;
LogHelper.WriteSysLogBase("【加漆-加注油漆】入参:PaintCode:" + PaintCode + ",DrumCode:" + DrumCode + ",State:" + state + ",出参:" + JSONTools.ScriptSerialize<JsonModel<NoModel>>(model), MethodBase.GetCurrentMethod().Name);
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(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 ClearBucket(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.ClearBucket(DrumCode, out errorReason);
model.Result = res < 1 ? "0" : "1";
model.ErrReason = errorReason;
model.ResultRowsCount = res.ToString();
model.DataList = null;
LogHelper.WriteSysLogBase("【加漆-清空油漆桶】入参:DrumCode:" + DrumCode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<NoModel>>(model), MethodBase.GetCurrentMethod().Name);
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
}
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void GetPaintInfo(string app_id, string drumCode, string sign)
{
string errorReason = "";
JsonModel<PaintInfoModel> model = new JsonModel<PaintInfoModel>();
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<PaintInfoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(drumCode))
{
model.ErrReason = "缺少必要传入参数 drumCode";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PaintInfoModel>>(model));
return;
}
if (string.IsNullOrWhiteSpace(sign))
{
model.ErrReason = "缺少必要传入参数 sign";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PaintInfoModel>>(model));
return;
}
bool access = Function.AppIDIsRight(app_id.Trim());
if (!access)
{
model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PaintInfoModel>>(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<PaintInfoModel>>(model));
return;
}
#endregion
DataTable dt = Function.IsEmpty(drumCode, out errorReason);
if (dt != null && dt.Rows.Count > 0)
{
DataTable dt1 = Function.GetPaintInfo(dt.Rows[0]["PaintCode"].ToString(), out errorReason);
List<PaintInfoModel> listInfo=new List<PaintInfoModel>();
if (dt.Rows.Count < 1)
{
model.Result = "0";
}
else
{
model.Result = "1";
PaintInfoModel info = new PaintInfoModel();
if (dt1 != null && dt1.Rows.Count > 0)
{
info.PaintName = dt1.Rows[0]["PaintName"].ToString();
}
info.PaintCode = dt.Rows[0]["PaintCode"].ToString();
listInfo.Add(info);
}
model.ErrReason = errorReason;
model.ResultRowsCount = dt.Rows.Count.ToString();
model.DataList = listInfo;
LogHelper.WriteSysLogBase("APP根据油漆系统条码查询油漆信息,入参drumCode=" + drumCode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<PaintInfoModel>>(model), MethodBase.GetCurrentMethod().Name);
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PaintInfoModel>>(model));
}
else
{
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = "油漆系统为空,无需清空!";
model.DataList = null;
LogHelper.WriteSysLogBase("APP根据油漆系统条码查询加料信息,入参drumCode=" + drumCode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<PaintInfoModel>>(model), MethodBase.GetCurrentMethod().Name);
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PaintInfoModel>>(model));
}
}
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void GetPaintRecord()
{
string errorReason = "";
JsonModel<PaintRecordModel> model = new JsonModel<PaintRecordModel>();
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = errorReason;
model.DataList = null;
DataTable dt = Function.GetPaintRecord(out errorReason);
if (dt != null && dt.Rows.Count > 0)
{
List<PaintRecordModel> listInfo = new List<PaintRecordModel>();
model.Result = "1";
for (int i = 0; i < dt.Rows.Count; i++)
{
PaintRecordModel info = new PaintRecordModel();
info.BucketCode = dt.Rows[i]["BucketCode"].ToString();
info.PaintCode= dt.Rows[i]["PaintCode"].ToString();
info.CreateTime= dt.Rows[i]["CreateTime"].ToString();
info.BucketState= dt.Rows[i]["BucketState"].ToString();
listInfo.Add(info);
}
model.ErrReason = errorReason;
model.ResultRowsCount = dt.Rows.Count.ToString();
model.DataList = listInfo;
}
else
{
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = "无记录!";
model.DataList = null;
}
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<PaintRecordModel>>(model));
}
}
}