using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Reflection; using System.Text.RegularExpressions; using System.Web; using System.Web.Script.Services; using System.Web.Services; using Tools; using WebService.Model; namespace Webservice { /// /// WMSWebService 的摘要说明 /// [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 Function.exsitInspectResult("22000001512307190697").ToString(); return "Connection is Ready."; } /// /// 调用WMS接口03 /// lx 20190610 /// /// 条码号:A2048856739-P.190605.0008(二维码) [WebMethod] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] public void WMSSprayingForApp(string barcode) { //JsonModel model = new JsonModel(); //model.Result = "1"; //model.ResultType = "Result"; //model.ResultRowsCount = "0"; //model.ErrReason = "成功"; ; //model.DataList = null; //Context.Response.Write(JSONTools.ScriptSerialize>(model)); string errorReason = ""; JsonModel model = new JsonModel(); 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>(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>(model)); return; } #endregion string res = Function.WMSSpraying(barcode, 1, stcokNo, partNo, batchNo); LogHelper.WriteSysLogBase("WMS接口:条码:" + barcode + ",MES返回结果:"+ res, MethodBase.GetCurrentMethod().Name); Context.Response.Write(res); } /// /// 调用WMS接口03 /// lx 20190610,wff2022-04-19修改,报废由0变为2 /// /// 条码号:A2048856739-P.190605.0008(二维码) /// 1-合格;2-报废 [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>(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>(model)); errorReason = "条码号无效,请检查条码是否破损缺失"; return false; } #endregion string res = Function.WMSSpraying(barcode, isOK, stcokNo, partNo, batchNo); JsonModel model = JSONTools.ScriptDeserialize>(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); } /// /// wff2022-04-19增加,点修补调用WMS接口,isOK=0 /// /// /// /// /// [WebMethod] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] public bool WMSSprayingForDXB(string barcode, int isOK, out string errorReason) { LogHelper.WriteSysLogBase("【MES点修补调用WMS接口】条码:" + barcode, MethodBase.GetCurrentMethod().Name); errorReason = ""; //return true; #region 参数判断 if (string.IsNullOrWhiteSpace(barcode)) { 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)) { errorReason = "条码号无效,请检查条码是否破损缺失"; return false; } #endregion string res = Function.WMSSpraying(barcode, isOK, stcokNo, partNo, batchNo); JsonModel model = JSONTools.ScriptDeserialize>(res); LogHelper.WriteSysLogBase("【MES点修补调用WMS接口】条码:" + barcode + ",出参:" + res, MethodBase.GetCurrentMethod().Name); if (model.Result == "1") { errorReason = ""; return true; } else { errorReason = model.ErrReason; LogHelper.WriteSysLogBase("【MES点修补调用WMS接口】条码:" + barcode + ",报错:" + errorReason, MethodBase.GetCurrentMethod().Name); return false; } } /// /// 当WMS调拨入库时,即报废的产品再次入库,WMS传入条码,MES记录入库 /// /// [WebMethod] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] public void AddStockInBarcode(string barcode) { string errorReason = ""; JsonModel model = new JsonModel(); 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>(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>(model), MethodBase.GetCurrentMethod().Name); Context.Response.Write(JSONTools.ScriptSerialize>(model)); } /// /// 手持设备做质量判定 /// /// /// [WebMethod] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] public void InsertInspect(string barcode, string InspectTimes) { string errorReason = ""; JsonModel model = new JsonModel(); 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>(model)); return; } if (string.IsNullOrWhiteSpace(InspectTimes)) { model.ErrReason = "一次合格或抛光合格参数不能为空"; Context.Response.Write(JSONTools.ScriptSerialize>(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>(model), MethodBase.GetCurrentMethod().Name); Context.Response.Write(JSONTools.ScriptSerialize>(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); if (Regex.Matches(InModel.productInfo.Trim(), ",").Count < 3) { model.Result = "0"; model.ResultType = "Result"; model.ResultRowsCount = "0"; model.ErrReason = "条码没有颜色信息,无法入库"; model.DataList = null; LogHelper.WriteSysLogBase("【手持设备质检判定】入参:barcode:" + barcode + ",InspectTimes:" + InspectTimes + ",出参:" + JSONTools.ScriptSerialize>(model), MethodBase.GetCurrentMethod().Name); Context.Response.Write(JSONTools.ScriptSerialize>(model)); return; } 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>(model), MethodBase.GetCurrentMethod().Name); Context.Response.Write(JSONTools.ScriptSerialize>(model)); #endregion } /// /// WMS入库接口-一码到底 /// /// /// /// /// [WebMethod] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] public bool WMSInterfaceStockIn(string barcode, string partNo, string batchNo, int isOK) { bool res = false; res = Function.WMSInterfaceStockIn(barcode, partNo, batchNo, isOK); return res; } [WebMethod] public void WMSSprayingForAppReturnNo(string barcode) { string errorReason = ""; JsonModel model = new JsonModel(); 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>(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>(model)); return; } #endregion LogHelper.WriteSysLogBase("WMS接口:条码:" + barcode + ",开始调入时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), MethodBase.GetCurrentMethod().Name); string res = Function.WMSSprayingReturnNo(barcode, 1, stcokNo, partNo, batchNo); LogHelper.WriteSysLogBase("WMS接口:条码:" + barcode + ",MES返回结果:" + res + ",结束调用时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), MethodBase.GetCurrentMethod().Name); Context.Response.Write(res); } } }