using Newtonsoft.Json; using System.Collections.Generic; using System.Net; using System.Text; namespace Aitex.Core.MES.JC { public class JCFabAuto: FabAutoComm { public List m_lotList=new List(); private List m_lotInformationList=new List(); public string m_userId; private string m_recipe; private string m_batchID; //public JCFabAuto(List lotList, string userId) //{ // m_lotList=lotList; // m_userId = userId; //} public JCFabAuto() { } /// /// 根据扫码信息获取Recipe /// /// public override string GetRecipeByLot(List list) { try { list.ForEach(x => { string url = "http://api.mes.com/WIP/GetLotByLot"; IDictionary para = new Dictionary(); para.Add("lot", x); string urlStr = HttpClient.HttpPost(url, para); if (urlStr != "") { m_lotInformationList.Add(JsonConvert.DeserializeObject(urlStr)); } }); m_recipe = m_lotInformationList[0].Data.Lot.RuncardRecipe; return m_recipe; } catch (System.Exception) { return string.Empty; } } /// /// 进站 /// /// public override bool CheckIn() { try { string url = "http://api-eqpauto.mes.com/API/WIP/CheckIn"; IDictionary para = new Dictionary(); string equipmentName = Dns.GetHostName(); StringBuilder sLots = new StringBuilder(); StringBuilder sComponents = new StringBuilder(); StringBuilder sLotTags = new StringBuilder(); m_lotInformationList.ForEach(lotInformation => { if (lotInformation == m_lotInformationList[m_lotInformationList.Count - 1]) { lotInformation.Data.Components.ForEach(x => { sComponents.Append(x.ComponentID); }); sLotTags.Append(lotInformation.Data.Lot.TAG); } else { lotInformation.Data.Components.ForEach(x => { sComponents.Append(x.ComponentID + ","); }); sLotTags.Append(lotInformation.Data.Lot.TAG + ","); } }); m_lotList.ForEach(lot => { if (lot == m_lotList[m_lotList.Count - 1]) { sLots.Append(lot); } else { sLots.Append(lot + ","); } }); para.Add("equipmentName", equipmentName); para.Add("sLots", sLots.ToString()); para.Add("sComponents", sComponents.ToString()); para.Add("sLotTags", sLotTags.ToString()); para.Add("userID", m_userId); para.Add("recipe", m_recipe); string urlStr = HttpClient.HttpPost(url, para); if (urlStr != "") { var checkInInformation = JsonConvert.DeserializeObject(urlStr); m_batchID = checkInInformation.data.BATCHID; return true; } else { return false; } } catch { return false; } } /// /// 出站 /// /// public override bool CheckOut() { try { string url = "http://api-eqpauto.mes.com/API/WIP/CheckOut"; IDictionary para = new Dictionary(); para.Add("batchID", m_batchID); para.Add("userId", m_userId); string urlStr = HttpClient.HttpPost(url, para); if (urlStr != "") { return true; } else { return false; } } catch { return false; } } } }