注塑喷涂
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.

763 lines
32 KiB

4 months ago
using System;
using System.Collections.Generic;
6 months ago
using System.Data;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Web.Script.Services;
using System.Web.Services;
using Tools;
using WebService.Model;
namespace Webservice
{
/// <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 = "1";
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;
LogHelper.WriteSysLogBase("根据塑料粒子查询加料信息,入参particleCode=" + particleCode, MethodBase.GetCurrentMethod().Name);
#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 = ""; //批次
string partNo = ""; //零件号
Function.GetCode(particleCode, out stockNo, out batchNo, out partNo);
#endregion
if (!string.IsNullOrWhiteSpace(stockNo) || !string.IsNullOrWhiteSpace(partNo))
{
DataTable dt = Function.GetInfoByParticles(stockNo, partNo, out errorReason);
List<InfoModel> listInfo = new List<InfoModel>();
if (dt.Rows.Count < 1)
{
model.Result = "0";
errorReason = "根据零件号:" + partNo + "查询不到塑料粒子信息";
}
else
{
model.Result = "1";
InfoModel info = new InfoModel();
info.Code = dt.Rows[0]["StockNo"].ToString(); ;
info.Name = dt.Rows[0]["ProductName"].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;
LogHelper.WriteSysLogBase("APP根据塑料粒子查询加料信息,入参particleCode=" + particleCode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<InfoModel>>(model), MethodBase.GetCurrentMethod().Name);
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 = "";
int flag = 0;
JsonModel<NoModel> model = new JsonModel<NoModel>();
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = errorReason;
model.DataList = null;
LogHelper.WriteSysLogBase("料筒与塑料粒子关系绑定,入参particleCode=" + particleCode + "drumCode=" + drumCode, MethodBase.GetCurrentMethod().Name);
#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
#region 查询当前料筒是否已经绑定塑料粒子和注塑机,如果有绑定则提示解绑;第二次添加的原料和已有原料不一样则解绑之前的塑料粒子,否则可以继续加
bool isBind = Function.QueryIsBind(particleCode, drumCode, out errorReason, out flag);
if (isBind)
{
model.ErrReason = errorReason;
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
return;
}
#endregion
int res = Function.BindparticleCodeAndDrum(particleCode, drumCode,flag, out errorReason);
if (res < 1)
{
model.Result = "0";
}
else
{
model.Result = "1";
}
model.ErrReason = errorReason;
model.ResultRowsCount = res.ToString();
model.DataList = null;
LogHelper.WriteSysLogBase("APP料筒与塑料粒子关系绑定,入参particleCode=" + particleCode + "drumCode=" + drumCode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<NoModel>>(model), MethodBase.GetCurrentMethod().Name);
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;
LogHelper.WriteSysLogBase("根据注塑机条码查询计划信息,入参machineCode=" + machineCode, MethodBase.GetCurrentMethod().Name);
#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;
LogHelper.WriteSysLogBase("APP根据注塑机条码查询计划信息,入参machineCode=" + machineCode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<PlanModel>>(model), MethodBase.GetCurrentMethod().Name);
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;
LogHelper.WriteSysLogBase("根据料筒条码查询加料信息,入参drumCode=" + drumCode, MethodBase.GetCurrentMethod().Name);
#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);
if (dt != null && dt.Rows.Count > 0)
{
string cylinderBarCode = dt.Rows[0][0].ToString();
string stockNo = ""; //存货代码
string batchNo = ""; //批次
string partNo = ""; //零件号
Function.GetCode(cylinderBarCode, out stockNo, out batchNo, out partNo);
if (!string.IsNullOrWhiteSpace(stockNo) || !string.IsNullOrWhiteSpace(partNo))
{
DataTable dt_info = Function.GetInfoByParticles(stockNo, partNo, out errorReason);
List<MaterialInfoModel> listInfo = new List<MaterialInfoModel>();
if (dt.Rows.Count < 1)
{
model.Result = "0";
}
else
{
model.Result = "1";
MaterialInfoModel info = new MaterialInfoModel();
if (dt_info != null && dt_info.Rows.Count > 0)
{
info.Code = dt_info.Rows[0]["PartNo"].ToString();
info.Name = dt_info.Rows[0]["ProductName"].ToString();
}
info.Batch = batchNo;
listInfo.Add(info);
}
model.ErrReason = errorReason;
model.ResultRowsCount = dt.Rows.Count.ToString();
model.DataList = listInfo;
LogHelper.WriteSysLogBase("APP根据料筒条码查询加料信息,入参drumCode=" + drumCode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<MaterialInfoModel>>(model), MethodBase.GetCurrentMethod().Name);
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<MaterialInfoModel>>(model));
}
else
{
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = "未获取到加料信息";
model.DataList = null;
LogHelper.WriteSysLogBase("APP根据料筒条码查询加料信息,入参drumCode=" + drumCode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<MaterialInfoModel>>(model), MethodBase.GetCurrentMethod().Name);
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<MaterialInfoModel>>(model));
}
}
else
{
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = "未获取到条码信息";
model.DataList = null;
LogHelper.WriteSysLogBase("APP根据料筒条码查询加料信息,入参drumCode=" + drumCode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<MaterialInfoModel>>(model), MethodBase.GetCurrentMethod().Name);
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;
LogHelper.WriteSysLogBase("注塑机与料筒关系绑定,入参machineCode=" + machineCode + "drumCode=" + drumCode, MethodBase.GetCurrentMethod().Name);
#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;
LogHelper.WriteSysLogBase("APP注塑机与料筒关系绑定,入参machineCode=" + machineCode + "drumCode=" + drumCode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<NoModel>>(model), MethodBase.GetCurrentMethod().Name);
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;
LogHelper.WriteSysLogBase("注塑机与料筒关系绑定,入参drumCode=" + drumCode, MethodBase.GetCurrentMethod().Name);
#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;
LogHelper.WriteSysLogBase("APP注塑机与料筒关系绑定,入参drumCode=" + drumCode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<NoModel>>(model), MethodBase.GetCurrentMethod().Name);
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
}
4 months ago
/// <summary>
/// 喷涂下线二次质检。 扫码就认为不合格 没有一次质检记录,未给wms传过报工(stockin),否则抛出提醒
/// </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 string PaintSecondCheck(string app_id, string sjBarCode, string sign)
{
string errorReason = "";
//LogHelper.WriteSysLogBase("注塑机与料筒关系绑定,入参machineCode=" + machineCode + "drumCode=" + drumCode, MethodBase.GetCurrentMethod().Name);
#region 参数判断
if (string.IsNullOrWhiteSpace(app_id))
{
errorReason = "缺少必要传入参数 app_id";
return errorReason;
}
if (string.IsNullOrWhiteSpace(sjBarCode))
{
//Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
errorReason = "缺少必要传入参数 sjBarCode";
return errorReason;
}
if (sjBarCode.Length !=20)
{
//Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
errorReason = "传入参数 sjBarCode格式不正确,请扫描20位注塑条码。";
return errorReason;
}
bool access = Function.AppIDIsRight(app_id.Trim());
if (!access)
{
errorReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
return errorReason;
}
string[] param = { Function.app_secret.Trim(), sjBarCode.Trim() };
bool paramIsRight = Function.signIsRight(param, sign);
if (!paramIsRight)
{
errorReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
return errorReason;
}
#endregion
bool res = Function.IsStockIn(sjBarCode);
if (res ==true)
{
errorReason = $"扫描条码[{sjBarCode}]已报工,无法重新判定为不合格操作。";
return errorReason;
}
//res = Function.barcodeStatus(sjBarCode);
//if (res == false)
//{
// errorReason = $"扫描条码[{sjBarCode}]未经过一次质检或者质检不合格,无法重新判定为不合格操作。";
// return errorReason;
//}
DataTable dt = Function.GetInspectResult(sjBarCode);
if(dt.Rows.Count == 0)
{
errorReason = $"扫描条码[{sjBarCode}]未经过第一次质检,无法操作。";
return errorReason;
}
if (dt.Rows[0]["inspectResult"].ToString().Trim() == "[合格]")
{
InspectModel model = new InspectModel();
model.inspectResult = "[抛光]";
model.ID = Guid.NewGuid().ToString();
model.barcode = dt.Rows[0]["barcode"].ToString().Trim();
model.side = dt.Rows[0]["side"].ToString().Trim();
model.position = dt.Rows[0]["position"].ToString().Trim();
model.stationNo = dt.Rows[0]["stationNo"].ToString().Trim();
model.workClass = dt.Rows[0]["workClass"].ToString().Trim();
model.productInfo = dt.Rows[0]["productInfo"].ToString().Trim();
model.InspectTimes = GetInspectTimes( dt.Rows[0]["InspectTimes"].ToString().Trim()).ToString();
model.productOption = dt.Rows[0]["productOption"].ToString().Trim();
model.damnPosition = dt.Rows[0]["damnPosition"].ToString().Trim();
model.defectID = dt.Rows[0]["defectID"].ToString().Trim();
model.reason = dt.Rows[0]["reason"].ToString().Trim();
model.remark1 = dt.Rows[0]["remark1"].ToString().Trim();
model.remark2 = dt.Rows[0]["remark2"].ToString().Trim();
model.remark3 = "PDA判定";
Function.InsertInspect(model);
return "true";
}
else
{
//Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
errorReason = $"扫描条码[{sjBarCode}]最新质检结果不是合格状态,无需重新操作。";
return errorReason;
}
}
int GetInspectTimes(string oldtimes)
{
int i = 0;
int.TryParse(oldtimes, out i);
return i+1;
}
6 months ago
}
}