123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- using Newtonsoft.Json;
- using System.Collections.Generic;
- using System.Net;
- using System.Text;
- namespace Aitex.Core.MES.JC
- {
- public class JCFabAuto: FabAutoComm
- {
- public List<string> m_lotList=new List<string>();
- private List<LotInformation> m_lotInformationList=new List<LotInformation>();
- public string m_userId;
- private string m_recipe;
- private string m_batchID;
- //public JCFabAuto(List<string> lotList, string userId)
- //{
- // m_lotList=lotList;
- // m_userId = userId;
- //}
- public JCFabAuto()
- {
- }
- /// <summary>
- /// 根据扫码信息获取Recipe
- /// </summary>
- /// <returns></returns>
- public override string GetRecipeByLot(List<string> list)
- {
- try
- {
- list.ForEach(x =>
- {
- string url = "http://api.mes.com/WIP/GetLotByLot";
- IDictionary<string, string> para = new Dictionary<string, string>();
- para.Add("lot", x);
- string urlStr = HttpClient.HttpPost(url, para);
- if (urlStr != "")
- {
- m_lotInformationList.Add(JsonConvert.DeserializeObject<LotInformation>(urlStr));
- }
- });
- m_recipe = m_lotInformationList[0].Data.Lot.RuncardRecipe;
- return m_recipe;
- }
- catch (System.Exception)
- {
- return string.Empty;
- }
-
- }
- /// <summary>
- /// 进站
- /// </summary>
- /// <returns></returns>
- public override bool CheckIn()
- {
- try
- {
- string url = "http://api-eqpauto.mes.com/API/WIP/CheckIn";
- IDictionary<string, string> para = new Dictionary<string, string>();
- 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<CheckInInformation>(urlStr);
- m_batchID = checkInInformation.data.BATCHID;
- return true;
- }
- else
- {
- return false;
- }
- }
- catch
- {
- return false;
- }
- }
- /// <summary>
- /// 出站
- /// </summary>
- /// <returns></returns>
- public override bool CheckOut()
- {
- try
- {
- string url = "http://api-eqpauto.mes.com/API/WIP/CheckOut";
- IDictionary<string, string> para = new Dictionary<string, string>();
- 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;
- }
- }
- }
- }
|