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.
407 lines
15 KiB
407 lines
15 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Web;
|
|
using System.Web.Script.Services;
|
|
using System.Web.Services;
|
|
using Tools;
|
|
using WebService.Model;
|
|
|
|
namespace Webservice
|
|
{
|
|
/// <summary>
|
|
/// WMSWebService 的摘要说明
|
|
/// </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 WMSWebService : System.Web.Services.WebService
|
|
{
|
|
[WebMethod]
|
|
public string ConnectTest()
|
|
{
|
|
return "Connection is Ready.";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 调用WMS接口03
|
|
/// 喷涂合格入库
|
|
/// </summary>
|
|
/// <param name="barcode">条码号:A2048856739-P.190605.0008(二维码)</param>
|
|
[WebMethod]
|
|
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
|
|
public void WMSSprayingForApp(string barcode)
|
|
{
|
|
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(barcode))
|
|
{
|
|
model.ErrReason = "条码号不能为空";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
|
|
string stcokNo = "";
|
|
string batchNo = "";
|
|
string partNo = "";
|
|
string colorName = string.Empty;
|
|
string productName = string.Empty;
|
|
string carType = string.Empty;
|
|
Function.GetCode(barcode, out stcokNo, out batchNo, out partNo);
|
|
if (string.IsNullOrWhiteSpace(stcokNo) && string.IsNullOrWhiteSpace(partNo))
|
|
{
|
|
model.ErrReason = "条码号无效,请检查条码是否破损缺失";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
//string res = Function.WMSSpraying("60000000562010090015", 1, "6000000056", "86511-BU020RBC", "210721");
|
|
|
|
string res = Function.WMSSpraying(barcode, 1, stcokNo, partNo, batchNo, ref colorName, ref productName, ref carType);
|
|
|
|
LogHelper.WriteSysLogBase("WMS接口:条码:" + barcode + ",MES返回结果:" + res, MethodBase.GetCurrentMethod().Name);
|
|
|
|
Context.Response.Write(res);
|
|
}
|
|
[WebMethod]
|
|
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
|
|
public string WMSSprayingForCSForTest(string barcode, int isOK)
|
|
{
|
|
string errorReason = string.Empty;
|
|
bool b = WMSSprayingForCS(barcode, isOK, out errorReason);
|
|
if (string.IsNullOrEmpty(errorReason))
|
|
return "true";
|
|
return errorReason;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 调用WMS接口03
|
|
/// 喷涂报废接口
|
|
/// </summary>
|
|
/// <param name="barcode">条码号:A2048856739-P.190605.0008(二维码)</param>
|
|
/// <param name="isOK">0-不合格;1-合格;9-返喷 8-其他 </param>
|
|
[WebMethod]
|
|
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
|
|
public bool WMSSprayingForCS(string barcode, int isOK, out string errorReason)
|
|
{
|
|
LogHelper.WriteSysLogBase("【WMS报废调入MES接口】条码:" + barcode, MethodBase.GetCurrentMethod().Name);
|
|
|
|
//string errorReason = "";
|
|
//return true;
|
|
|
|
if (string.IsNullOrWhiteSpace(barcode))
|
|
{
|
|
//model.ErrReason = "条码号不能为空";
|
|
//Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
errorReason = "条码号不能为空";
|
|
return false;
|
|
}
|
|
bool sendRst = true;
|
|
string stcokNo = "";
|
|
string batchNo = "";
|
|
string partNo = "";
|
|
string colorName = string.Empty;
|
|
string productName = string.Empty;
|
|
string carType = string.Empty;
|
|
try
|
|
{
|
|
errorReason = "";
|
|
sendRst = SendToWmsService(barcode, isOK, ref stcokNo, ref batchNo, ref partNo, ref colorName, ref productName, ref carType,ref errorReason);
|
|
if(sendRst == true)
|
|
{
|
|
return sendRst;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errorReason = ex.Message;
|
|
LogHelper.WriteSysLogBase("【WMS报废调入MES接口】条码:" + barcode + ",报错:" + errorReason, MethodBase.GetCurrentMethod().Name);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 喷涂下线
|
|
/// </summary>
|
|
/// <param name="barCode"></param>
|
|
/// <returns></returns>
|
|
[WebMethod(EnableSession = true)]
|
|
public string PaintLineDown(string barCode)
|
|
{
|
|
bool sendRst = true;
|
|
string colorName = string.Empty;
|
|
string productName = string.Empty;
|
|
string carType = string.Empty;
|
|
|
|
string stcokNo = string.Empty;
|
|
string batchNo = string.Empty;
|
|
string partNo = string.Empty;
|
|
try
|
|
{
|
|
string errorReason = "";
|
|
sendRst = SendToWmsService(barCode, 1, ref stcokNo, ref batchNo, ref partNo, ref colorName, ref productName, ref carType, ref errorReason);
|
|
|
|
if (sendRst == true)
|
|
{
|
|
Function.SaveLineDownInfo(barCode, carType, colorName, productName);
|
|
if (Context.Session["LastBarCode"] != null)
|
|
{
|
|
if (ExsitBarCode(Context.Session["LastBarCode"].ToString()) == false)
|
|
{
|
|
Function.SaveLineDownInfo(Context.Session["LastBarCode"].ToString(), Context.Session["LastCarType"].ToString(), Context.Session["LastColorName"].ToString(), Context.Session["LastProductName"].ToString());
|
|
}
|
|
}
|
|
Context.Session["LastBarCode"] = barCode;
|
|
Context.Session["LastCarType"] = carType;
|
|
Context.Session["LastColorName"] = colorName;
|
|
Context.Session["LastProductName"] = productName;
|
|
return "操作成功!";
|
|
}
|
|
else
|
|
{
|
|
return errorReason;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "下线服务异常,异常原因:"+ ex.Message;
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 下悬挂链记录,是否存在该条码
|
|
/// </summary>
|
|
/// <param name="v"></param>
|
|
/// <returns></returns>
|
|
private bool ExsitBarCode(string barCode)
|
|
{
|
|
return Function.ExsitBarCodeInDownRecord(barCode);
|
|
}
|
|
|
|
bool SendToWmsService(string barCode,int isPass, ref string stcokNo, ref string batchNo, ref string partNo, ref string colorName, ref string productName, ref string carType,ref string errorReason)
|
|
{
|
|
string errorMsg = string.Empty;
|
|
//return true;
|
|
|
|
#region 参数判断
|
|
if (string.IsNullOrWhiteSpace(barCode))
|
|
{
|
|
errorReason = "条码号不能为空";
|
|
return false;
|
|
}
|
|
Function.GetCode(barCode, out stcokNo, out batchNo, out partNo);
|
|
if (string.IsNullOrWhiteSpace(stcokNo) && string.IsNullOrWhiteSpace(partNo))
|
|
{
|
|
errorReason = "条码号无效,请检查条码是否破损缺失";
|
|
return false;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
string res = Function.WMSSpraying(barCode, isPass, stcokNo, partNo, batchNo, ref colorName, ref productName, ref carType);
|
|
JsonModel<NoModel> model = JSONTools.ScriptDeserialize<JsonModel<NoModel>>(res);
|
|
|
|
if (model.Result == "0")
|
|
{
|
|
errorReason = model.ErrReason;
|
|
throw new Exception(model.ErrReason);
|
|
}
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
/// 当WMS调拨入库时,即报废的产品再次入库,WMS传入条码,MES记录入库
|
|
/// </summary>
|
|
/// <param name="barcode"></param>
|
|
[WebMethod]
|
|
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
|
|
public void AddStockInBarcode(string barcode)
|
|
{
|
|
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(barcode))
|
|
{
|
|
model.ErrReason = "条码号不能为空";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region 保存入库记录
|
|
|
|
bool res = Function.AddStockInBarcode(barcode, out errorReason);
|
|
|
|
if (res == true)
|
|
{
|
|
model.Result = "1";
|
|
model.ResultType = "Result";
|
|
model.ResultRowsCount = "0";
|
|
model.ErrReason = "成功";
|
|
model.DataList = null;
|
|
}
|
|
else
|
|
{
|
|
model.Result = "0";
|
|
model.ResultType = "Result";
|
|
model.ResultRowsCount = "0";
|
|
model.ErrReason = "接收失败:" + errorReason;
|
|
model.DataList = null;
|
|
}
|
|
|
|
#endregion
|
|
|
|
LogHelper.WriteSysLogBase("【WMS报废再入库】入参:" + barcode + ",出参:" + JSONTools.ScriptSerialize<JsonModel<NoModel>>(model), MethodBase.GetCurrentMethod().Name);
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 手持设备做质量判定
|
|
/// </summary>
|
|
/// <param name="barcode"></param>
|
|
/// <param name="InspectTimes"></param>
|
|
[WebMethod]
|
|
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
|
|
public void InsertInspect(string barcode, string InspectTimes)
|
|
{
|
|
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(barcode))
|
|
{
|
|
model.ErrReason = "条码号不能为空";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
if (string.IsNullOrWhiteSpace(InspectTimes))
|
|
{
|
|
model.ErrReason = "一次合格或抛光合格参数不能为空";
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 判断老外库里是否有该条码,有则返回颜色,没有则补打条码,直接入库
|
|
|
|
if (barcode.Contains("."))
|
|
{
|
|
barcode = Function.TransToBarCodeOne(barcode);
|
|
}
|
|
|
|
LogHelper.WriteSysLogBase("【手持设备质检判定】入参:barcode:" + barcode + ",InspectTimes:" + InspectTimes, MethodBase.GetCurrentMethod().Name);
|
|
|
|
bool exsitInLine = Function.ExistInLine(barcode);
|
|
if (!exsitInLine)
|
|
{
|
|
model.Result = "0";
|
|
model.ResultType = "Result";
|
|
model.ResultRowsCount = "0";
|
|
model.ErrReason = "喷涂线上找不到该条码,请补打条码后扫码入库,或在工位上附加颜色并进行质量判定";
|
|
model.DataList = null;
|
|
|
|
LogHelper.WriteSysLogBase("【手持设备质检判定】入参:barcode:" + barcode + ",InspectTimes:" + InspectTimes + ",出参:" + JSONTools.ScriptSerialize<JsonModel<NoModel>>(model), MethodBase.GetCurrentMethod().Name);
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 整理参数,保存质检结果
|
|
|
|
InspectModel InModel = new InspectModel();
|
|
InModel.ID = Guid.NewGuid().ToString();
|
|
InModel.barcode = barcode;
|
|
InModel.side = Function.GetSide(barcode); ;
|
|
InModel.position = "手持设备";
|
|
InModel.stationNo = "S20";
|
|
InModel.workClass = Function.GetWorkClass();
|
|
InModel.inspectResult = "合格";
|
|
InModel.productInfo = Function.GetProductInfo(barcode);
|
|
InModel.InspectTimes = InspectTimes;
|
|
InModel.productOption = "";
|
|
InModel.damnPosition = "";
|
|
InModel.defectID = "";
|
|
InModel.reason = "";
|
|
InModel.remark1 = "";
|
|
InModel.remark2 = "";
|
|
InModel.remark3 = "";
|
|
|
|
int res = Function.InsertInspect(InModel);
|
|
if (res > 0)
|
|
{
|
|
model.Result = "1";
|
|
model.ResultType = "Result";
|
|
model.ResultRowsCount = "0";
|
|
model.ErrReason = "成功";
|
|
model.DataList = null;
|
|
}
|
|
else
|
|
{
|
|
model.Result = "0";
|
|
model.ResultType = "Result";
|
|
model.ResultRowsCount = "0";
|
|
model.ErrReason = "失败";
|
|
model.DataList = null;
|
|
}
|
|
|
|
LogHelper.WriteSysLogBase("【手持设备质检判定】入参:barcode:" + barcode + ",InspectTimes:" + InspectTimes + ",出参:" + JSONTools.ScriptSerialize<JsonModel<NoModel>>(model), MethodBase.GetCurrentMethod().Name);
|
|
|
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
|
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// WMS入库接口-一码到底
|
|
/// </summary>
|
|
/// <param name="partNo"></param>
|
|
/// <param name="batchNo"></param>
|
|
/// <param name="isOK"></param>
|
|
/// <returns></returns>
|
|
[WebMethod]
|
|
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
|
|
public bool WMSInterfaceStockIn(string barcode, string partNo, string batchNo, int isOK, int LineId)
|
|
{
|
|
bool res = false;
|
|
res = Function.WMSInterfaceStockIn(barcode, partNo, batchNo, isOK, LineId);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
}
|
|
|