using System; using System.Collections.Generic; using System.Text; using WIDESEA_Common; using WIDESEA_Core.Utilities; using WIDESEA_Entity.DomainModels; namespace WIDESEA_Services { public class WMSApi { /// /// 发送入库请求至WMS,请求下发入库任务 /// /// 托盘号 /// public static WebResponseContent PostInboundRequstToWMS(string barcode) { WebResponseContent content = new WebResponseContent(); try { SaveModel saveModel = new SaveModel(); saveModel.MainData = new Dictionary(); saveModel.MainData.Add("barcode", barcode); content = HttpHelper.GetHttpRequestData( saveModel, APIAddress.WmsIPAddress + APIAddress.PostInboundRequstToWMS); if (!content.Status) throw new Exception($"入库申请调用失败:" + content.Message); } catch (Exception ex) { content.Error(ex.Message); } return content; } /// /// 向WMS上报任务状态 /// /// 托盘号 /// public static WebResponseContent PostTaskStateToWMS(string barcode,string taskState, string rgvId = null) { WebResponseContent content = new WebResponseContent(); try { SaveModel saveModel = new SaveModel(); saveModel.MainData = new Dictionary(); saveModel.MainData.Add("barcode", barcode); saveModel.MainData.Add("taskState", taskState); if(rgvId != null) saveModel.MainData.Add("rgvId", rgvId); else saveModel.MainData.Add("rgvId", 0); content = HttpHelper.GetHttpRequestData( saveModel, APIAddress.WmsIPAddress + APIAddress.PostTaskStateToWMS); if (!content.Status) { throw new Exception($"向WMS上报任务状态调用失败:" + content.Message); } content.OK(); } catch (Exception ex) { content.Error(ex.Message); } return content; } /// /// 向WMS上报任务完成 /// /// 托盘号 /// public static WebResponseContent TellWmsTaskFinished(string barcode,string rgvId = null) { WebResponseContent content = new WebResponseContent(); try { SaveModel saveModel = new SaveModel(); saveModel.MainData = new Dictionary(); saveModel.MainData.Add("barcode", barcode); if(rgvId != null) saveModel.MainData.Add("rgvId", rgvId); else saveModel.MainData.Add("rgvId", ""); content = HttpHelper.GetHttpRequestData( saveModel, APIAddress.WmsIPAddress + APIAddress.TellWmsTaskFinished); if (!content.Status) { throw new Exception($"向WMS上报任务状态调用失败:" + content.Message); } content.OK(); } catch (Exception ex) { content.Error(ex.Message); } return content; } /// /// 向WMS上报称重得到的结果以及对应的托盘号RFID /// /// 托盘号 /// 重量 /// public static WebResponseContent TellWmsWeightResult(string barcode,string weight) { WebResponseContent content = new WebResponseContent(); try { SaveModel saveModel = new SaveModel(); saveModel.MainData = new Dictionary(); saveModel.MainData.Add("barcode", barcode); saveModel.MainData.Add("weight", weight); content = HttpHelper.GetHttpRequestData( saveModel, APIAddress.WmsIPAddress + APIAddress.TellWmsWeightResult); if (!content.Status) { throw new Exception($"向WMS上报称重结果异常:" + content.Message); } content.OK(); } catch (Exception ex) { content.Error(ex.Message); } return content; } /// /// 当托盘码校验不一致时,上报WMS,由WMS处理 /// /// 系统记录到的托盘码 /// 线体站台读取到的托盘码 /// 任务号 /// 发生站台 /// public static WebResponseContent PostRFIDNoMatch(string systemRFID,string lineRFID,string taskNumber,string station) { WebResponseContent content = new WebResponseContent(); try { SaveModel saveModel = new SaveModel(); saveModel.MainData = new Dictionary(); saveModel.MainData.Add("systemRFID", systemRFID); saveModel.MainData.Add("lineRFID", lineRFID); saveModel.MainData.Add("taskNumber", taskNumber); saveModel.MainData.Add("station", station); content = HttpHelper.GetHttpRequestData( saveModel, APIAddress.WmsIPAddress + APIAddress.TellWmsRFIDNoMatch); if (!content.Status) { throw new Exception($"当托盘码校验不一致时调用失败:" + content.Message); } content.OK(); } catch (Exception ex) { content.Error(ex.Message); } return content; } /// /// 向WMS申请新的货位,当入库任务和测量出库任务冲突时 /// /// /// public static WebResponseContent RequstNewLocationIdWhenConflict(string barcode) { WebResponseContent content = new WebResponseContent(); try { SaveModel saveModel = new SaveModel(); saveModel.MainData = new Dictionary(); saveModel.MainData.Add("barcode", barcode); content = HttpHelper.GetHttpRequestData( saveModel, APIAddress.WmsIPAddress + APIAddress.RequstNewLocationIdWhenConflict); if (!content.Status) { throw new Exception($"当托盘码校验不一致时调用失败:" + content.Message); } content.OK(); } catch (Exception ex) { content.Error(ex.Message); } return content; } } }