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

408 lines
15 KiB

3 months ago
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;
3 months ago
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");
1 month ago
string res = Function.WMSSpraying(barcode, 1, stcokNo, partNo, batchNo, ref colorName, ref productName, ref carType);
3 months ago
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;
}
3 months ago
/// <summary>
/// 调用WMS接口03
/// 喷涂报废接口
/// </summary>
/// <param name="barcode">条码号:A2048856739-P.190605.0008(二维码)</param>
/// <param name="isOK">0-不合格;1-合格;9-返喷 8-其他 </param>
3 months ago
[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);
1 month ago
//string errorReason = "";
3 months ago
//return true;
if (string.IsNullOrWhiteSpace(barcode))
{
//model.ErrReason = "条码号不能为空";
//Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
errorReason = "条码号不能为空";
return false;
}
bool sendRst = true;
3 months ago
string stcokNo = "";
string batchNo = "";
string partNo = "";
string colorName = string.Empty;
string productName = string.Empty;
string carType = string.Empty;
try
3 months ago
{
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);
3 months ago
return false;
}
}
3 months ago
/// <summary>
/// 喷涂下线
/// </summary>
/// <param name="barCode"></param>
/// <returns></returns>
1 month ago
[WebMethod(EnableSession = true)]
public string PaintLineDown(string barCode)
{
bool sendRst = true;
string colorName = string.Empty;
string productName = string.Empty;
string carType = string.Empty;
1 month ago
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);
1 month ago
if (sendRst == true)
{
Function.SaveLineDownInfo(barCode, carType, colorName, productName);
1 month ago
if (Context.Session["LastBarCode"] != null)
{
1 month ago
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());
}
}
1 month ago
Context.Session["LastBarCode"] = barCode;
Context.Session["LastCarType"] = carType;
Context.Session["LastColorName"] = colorName;
Context.Session["LastProductName"] = productName;
return "操作成功!";
}
else
{
return errorReason;
}
1 month ago
}
catch (Exception ex)
{
return "下线服务异常,异常原因:"+ ex.Message;
}
3 months ago
}
1 month ago
/// <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;
3 months ago
#region 参数判断
if (string.IsNullOrWhiteSpace(barCode))
1 month ago
{
errorReason = "条码号不能为空";
return false;
3 months ago
}
Function.GetCode(barCode, out stcokNo, out batchNo, out partNo);
if (string.IsNullOrWhiteSpace(stcokNo) && string.IsNullOrWhiteSpace(partNo))
3 months ago
{
errorReason = "条码号无效,请检查条码是否破损缺失";
return false;
}
3 months ago
#endregion
1 month ago
1 month ago
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;
1 month ago
throw new Exception(model.ErrReason);
3 months ago
}
return true;
3 months ago
}
/// <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 = "合格";
3 months ago
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)]
1 month ago
public bool WMSInterfaceStockIn(string barcode, string partNo, string batchNo, int isOK, int LineId)
3 months ago
{
bool res = false;
1 month ago
res = Function.WMSInterfaceStockIn(barcode, partNo, batchNo, isOK, LineId);
3 months ago
return res;
}
}
1 month ago
3 months ago
}