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

313 lines
12 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 = "";
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);
LogHelper.WriteSysLogBase("WMS接口:条码:" + barcode + ",MES返回结果:" + res, MethodBase.GetCurrentMethod().Name);
Context.Response.Write(res);
}
/// <summary>
/// 调用WMS接口03
/// 喷涂报废接口
/// </summary>
/// <param name="barcode">条码号:A2048856739-P.190605.0008(二维码)</param>
/// <param name="isOK">0-不合格;1-合格; </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);
errorReason = "";
//return true;
#region 参数判断
if (string.IsNullOrWhiteSpace(barcode))
{
//model.ErrReason = "条码号不能为空";
//Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
errorReason = "条码号不能为空";
return false;
}
string stcokNo = "";
string batchNo = "";
string partNo = "";
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));
errorReason = "条码号无效,请检查条码是否破损缺失";
return false;
}
#endregion
string res = Function.WMSSpraying(barcode, isOK, stcokNo, partNo, batchNo);
JsonModel<NoModel> model = JSONTools.ScriptDeserialize<JsonModel<NoModel>>(res);
LogHelper.WriteSysLogBase("【WMS报废调入MES接口】条码:" + barcode + ",出参:" + res, MethodBase.GetCurrentMethod().Name);
if (model.Result == "1")
{
errorReason = "";
return true;
}
else
{
errorReason = model.ErrReason;
LogHelper.WriteSysLogBase("【WMS报废调入MES接口】条码:" + barcode + ",报错:" + errorReason, MethodBase.GetCurrentMethod().Name);
return false;
}
//Context.Response.Write(res);
}
/// <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;
}
}
}