public static string GetDAContainer(string data, string opt, string trans, string org) { string res = string.Empty; try { //验证当前DA是否可以交接\退片 string sql = "SELECT * FROM [FGA_PLATFORM].[dbo].[ProcessHOAudit_T] where SerialNO = '" + data + "' and OperationNo = '" + opt + "' and ContainerStatus = 'In Progress'"; DataSet ds_seq = new DataSet(); ds_seq = FGA_DAL.Base.SQLServerHelper.Query(sql); if (ds_seq != null && ds_seq.Tables.Count > 0 && ds_seq.Tables[0].Rows.Count > 0) { res = "0"; } else { //获取交接的From库位 Hashtable ht = new Hashtable(); string sql_floc = "SELECT [FLOC] FROM [FGA_PLATFORM].[dbo].[FGA_PARTTRANSFER_T] where OPERATION = '" + opt + "' and TRANSACTIONTYPE = '" + trans + "' and ORGANIZATION = '" + org + "'"; DataSet ds_floc = new DataSet(); ds_floc = FGA_DAL.Base.SQLServerHelper.Query(sql_floc); if (ds_floc != null && ds_floc.Tables.Count > 0 && ds_floc.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds_floc.Tables[0].Rows.Count; i++) { ht.Add(ds_floc.Tables[0].Rows[i][0], i); } } //获取当前操作的From库存 List <PlexContainer> luw = new List <PlexContainer>(); PlexContainer PC = new PlexContainer(); if (data != "" && data != null) { //从plex中获取DA的信息 FGA_NUtility.POL.ExecuteDataSourceResult rst = PlexHelper.PlexGetResult_1("7836", "Containers_By_Part_Get", "@Serial_No", data); PC.SerialNO = data; PC.PartNO = rst.ResultSets[0].Rows[0].Columns[3].Value; PC.OperationNo = rst.ResultSets[0].Rows[0].Columns[7].Value; PC.Quantity = decimal.Parse(rst.ResultSets[0].Rows[0].Columns[15].Value); PC.Location = rst.ResultSets[0].Rows[0].Columns[17].Value; PC.ContainerStatus = rst.ResultSets[0].Rows[0].Columns[19].Value; if (PC.OperationNo.Equals(opt)) { if (ht.Contains(PC.Location)) { luw.Add(PC); JavaScriptSerializer jssl = new JavaScriptSerializer(); res = jssl.Serialize(luw); } else { res = "2"; } } else { return("1"); } } } } catch (Exception e) { } return(res); }
public static string GetDAContainer(string serialno, string loadid, string cpos) { string res = string.Empty; try { List <PlexContainer> luw = new List <PlexContainer>(); PlexContainer PC = new PlexContainer(); //从plex中获取DA的信息,判断DA号对应的编码是否与small lot相符合 //编码一致,如果数量大于等于small lot数量 //////(1)数量相等直接取该DA //////(2)数量大于small lot时进行自动split //编码一致,如果数量小于small lot数量则直接报错 FGA_NUtility.POL.ExecuteDataSourceResult da_rst = PlexHelper.PlexGetResult_1("7836", "Containers_By_Part_Get", "@Serial_No", serialno); string location = da_rst.ResultSets[0].Rows[0].Columns[17].Value; if (location.IndexOf("OT") < 0 && location.IndexOf("OL") < 0) { PC.SerialNO = da_rst.ResultSets[0].Rows[0].Columns[10].Value; PC.PartNO = da_rst.ResultSets[0].Rows[0].Columns[3].Value; PC.Quantity = decimal.Parse(da_rst.ResultSets[0].Rows[0].Columns[15].Value); //获取该loadid对应position产品的信息 //如果跟plex一致则继续,否则返回异常 string partno = ""; int qty = 0; string sql = "SELECT PART_NO,QUANTITY FROM FGA_LOADDETAIL_T WHERE LOADID = '" + loadid + "' AND POSITION = " + cpos + ""; DataSet ds_seq = new DataSet(); ds_seq = FGA_DAL.Base.SQLServerHelper.Query(sql); if (ds_seq != null && ds_seq.Tables.Count > 0 && ds_seq.Tables[0].Rows.Count > 0) { partno = ds_seq.Tables[0].Rows[0][0].ToString(); qty = Convert.ToInt32(ds_seq.Tables[0].Rows[0][1].ToString()); } if (partno.Equals(PC.PartNO)) { if (PC.Quantity >= qty) { if (PC.Quantity == qty) { luw.Add(PC); JavaScriptSerializer jssl = new JavaScriptSerializer(); res = jssl.Serialize(luw); } else { //自动split FGA_NUtility.POL.ExecuteDataSourceResult result = PlexHelper.PlexGetResult_3("9920", "Container_Split_RF", "@Serial_No", "@Quantity", "@ModUser", serialno, qty.ToString(), "2786442"); //从plex中获取split的DA信息 FGA_NUtility.POL.ExecuteDataSourceResult rst = PlexHelper.PlexGetResult_2("33468", "Containers_By_Last_Action_Today_Get", "@Last_Action", "@From_Container", "Split Container", serialno); //获取当前split后最大的DA int a = 0; int b = 0; int c = 0; for (int i = 0; i < rst.ResultSets[0].RowCount; i++) { a = Int32.Parse(rst.ResultSets[0].Rows[i].Columns[0].Value.Substring(1, 7)); if (a > b) { b = a; c = i; } } PC.SerialNO = rst.ResultSets[0].Rows[c].Columns[0].Value; PC.PartNO = rst.ResultSets[0].Rows[c].Columns[2].Value; PC.Quantity = decimal.Parse(rst.ResultSets[0].Rows[c].Columns[6].Value); luw.Add(PC); JavaScriptSerializer jssl = new JavaScriptSerializer(); res = jssl.Serialize(luw); } } else { res = "qty_error"; } } } else { res = "loc_error"; } } catch (Exception e) { } return(res); }
public static string onActionReceive(string transferNO, string location) { string res = ""; int count = 0; string msg = ""; string plexid = "2786442"; string puser = (HttpContext.Current.Session[SysConst.S_LOGIN_USER] as UsersModel).USERNAME; string sql = "select plexid from userinfo where username = '******'"; DataSet ds2 = new DataSet(); ds2 = FGA_DAL.Base.SQLServerHelper_FGA.Query(sql); if (ds2 != null && ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0) { plexid = ds2.Tables[0].Rows[0][0].ToString(); } try { string sqlinfos = "SELECT [SerialNO] FROM [WMS_BarCode_V10].[dbo].[IPTransfer_Detail_t] where [TransferNO] = '" + transferNO + "' and isnull(dr,'0') = 0 "; DataSet ds = new DataSet(); ds = FGA_DAL.Base.SQLServerHelper_WMS.Query(sqlinfos); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { List <InterPlantTransferModel> luw = new List <InterPlantTransferModel>(); foreach (DataRow row in ds.Tables[0].Rows) { InterPlantTransferModel ERM = new InterPlantTransferModel(row); FGA_NUtility.POL.ExecuteDataSourceResult da_rst = PlexHelper.PlexGetResult_4("27181", "Container_Update_Simple", "@Serial_No", "@Location", "@Last_Action", "@Update_By", ERM.SerialNO, location, "Inter-Plant Transfer by scanner", plexid); if (!da_rst.Error) { count++; } else { msg = msg + ERM.SerialNO + '\n'; } } } if (!String.IsNullOrEmpty(msg)) { res = "Finished: " + count + '\n' + "Follow SerialNO is unsuccessful: " + '\n' + msg; } else { res = "Finished: " + count; //更改CycleInventory_H状态 string synsql = "update [InterPlantTransfer_H] set [Transtatus] = 'Completed',[Receiver] ='" + puser + "',[ReceptionDate] = getdate() where [TransferNO] = '" + transferNO + "'"; FGA_DAL.Base.SQLServerHelper_WMS.ExecuteSql(synsql); } } catch (Exception e) { } return(res); }
/// <summary> /// 根据workcenter同步当班产量 /// 1st: /// 2nd:15:00:00--22:59:59 /// 3rd:23:00:00--06:59:59 /// </summary> /// <returns></returns> public static List <userctrlModel> getOutPut(List <userctrlModel> nm) { if (nm.Count != 0) { //获取当前时间 //当前时间在07:00:00--14:59:59获取当天第一班 //当前时间在15:00:00--22:59:59获取当天第二班 //当前时间在23:00:00--23:59:59获取当天第三班 //当前时间在00:00:00--06:59:59获取当天第三班 string shift = ""; List <string> sqllist = new List <string>(); DateTime dt = DateTime.Now; string dts = ""; if (dt.Hour >= 7 && dt.Hour < 15) { shift = "1st"; dts = dt.Date.ToString(); } if (dt.Hour >= 15 && dt.Hour < 23) { shift = "2nd"; dts = dt.Date.ToString(); } if (dt.Hour < 7 && dt.Hour == 23) { shift = "3rd"; dts = dt.AddDays(-1).Date.ToString(); } foreach (userctrlModel vo in nm) { string sql = " select WCKey FROM [PlexWorkCenter_t] where WorkCenter = '" + vo.WORKCENTER + "' "; string wkey = ""; DataSet ds = new DataSet(); ds = FGA_DAL.Base.SQLServerHelper_WMS.Query(sql); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { wkey = ds.Tables[0].Rows[0][0].ToString(); //获取指定日期的产量 FGA_NUtility.POL.ExecuteDataSourceResult rst = PlexHelper.PlexGetResult_3("9330", "Daily_Production_Get_New", "@Workcenter_Code", "@Start_Date", "@End_Date", wkey, dts, dts); if (rst.ResultSets != null) { int count = rst.ResultSets[0].Rows.Length; for (int i = 0; i < count; i++) { string _shift = rst.ResultSets[0].Rows[i].Columns[1].Value; string _partno = rst.ResultSets[0].Rows[i].Columns[2].Value; string _quantity = rst.ResultSets[0].Rows[i].Columns[4].Value; string _reportdate = rst.ResultSets[0].Rows[i].Columns[10].Value; string _scrapqty = rst.ResultSets[0].Rows[i].Columns[29].Value; string _operationcode = rst.ResultSets[0].Rows[i].Columns[32].Value; string insert_sql = "insert into [Plex_Daily_Production]([WorkCenter],[ShiftGroup],[PartNO],[Quantity],[Report_Date],[Scrap_Quantity],[OperationCode],[CreateDate])" + "values('" + vo.WORKCENTER + "','" + _shift + "','" + _partno + "'," + _quantity + ",'" + _reportdate + "'," + _scrapqty + ",'" + _operationcode + "',getdate())"; sqllist.Add(insert_sql); } } } } //产量插入数据库 FGA_DAL.Base.SQLServerHelper_WMS.ExecuteSqlTran(sqllist); //获取各workcenter对应的产量 string sql_o = "select WorkCenter,sum(Quantity) Quantity from [Plex_Daily_Production] where " + "report_date = '" + dts + "' and ShiftGroup ='" + shift + "' group by WorkCenter"; DataSet dso = new DataSet(); dso = FGA_DAL.Base.SQLServerHelper_WMS.Query(sql_o); if (dso != null && dso.Tables.Count > 0 && dso.Tables[0].Rows.Count > 0) { //定义hashtable Dictionary <string, int> dic = new Dictionary <string, int>(); foreach (DataRow row in dso.Tables[0].Rows) { dic.Add(row[0].ToString(), Convert.ToInt32(row[1])); } //赋值workcenter的产量 for (int i = 0; i < nm.Count; i++) { if (dic.ContainsKey(nm[i].WORKCENTER)) { nm[i].QUANTITY = dic[nm[i].WORKCENTER]; } else { nm[i].QUANTITY = 0; } } } } return(nm); }
public static string CompareQty(string serialno, string partno, string location, string oqty, string nqty, bool ck1, bool ck2, string ope) { string result = string.Empty; int oqty1 = Convert.ToInt32(oqty); int nqty1 = Convert.ToInt32(nqty); string plexid = (HttpContext.Current.Session[SysConst.S_LOGIN_USER] as UsersModel).PLEXID; string nserialno = string.Empty; string label1 = ""; string label2 = ""; string oper = ope; try { if (nqty1 <= oqty1) { //直接move 修改operation if (nqty == oqty) { //获取该DA号对应1300的part_operation_key string sql = "SELECT [Part_Operation_Key] FROM Part_v_Part_Operation ppo left join " + " Part_v_part pp on ppo.part_key = pp.part_key where Operation_Key= 46860 and pp.Part_No = '" + partno + "'"; DataSet ds = new DataSet(); ds = FGA_DAL.Base.SQLServerHelper_Plex.Query(sql); string opk = null; if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { opk = ds.Tables[0].Rows[0][0].ToString(); } FGA_NUtility.POL.ExecuteDataSourceResult esr = PlexHelper.PlexGetResult_6("27181", "Container_Update_Simple", "@Serial_No", "@Last_Action", "@Location", "@Note", "@Update_By", "@Part_Operation_Key", serialno, "Updated at Inventory Update Form", location, "By Rework", plexid, opk); } else { if (oper == "1500") { //先split,获取split后的da FGA_NUtility.POL.ExecuteDataSourceResult res = PlexHelper.PlexGetResult_3("9920", "Container_Split_RF", "@Serial_No", "@Quantity", "@ModUser", serialno, nqty, plexid); //获取新的DA FGA_NUtility.POL.ExecuteDataSourceResult rst = PlexHelper.PlexGetResult_2("33468", "Containers_By_Last_Action_Today_Get", "@Last_Action", "@From_Container", "Split Container", serialno); if (rst.ResultSets != null) { nserialno = rst.ResultSets[0].Rows[rst.ResultSets[0].RowCount - 1].Columns[0].Value; //对新的DA move //获取该DA号对应1300的part_operation_key string sql = "SELECT [Part_Operation_Key] FROM Part_v_Part_Operation ppo left join " + " Part_v_part pp on ppo.part_key = pp.part_key where Operation_Key= 46860 and pp.Part_No = '" + partno + "'"; DataSet ds = new DataSet(); ds = FGA_DAL.Base.SQLServerHelper_Plex.Query(sql); string opk = null; if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { opk = ds.Tables[0].Rows[0][0].ToString(); } FGA_NUtility.POL.ExecuteDataSourceResult esr = PlexHelper.PlexGetResult_6("27181", "Container_Update_Simple", "@Serial_No", "@Last_Action", "@Location", "@Note", "@Update_By", "@Part_Operation_Key", nserialno, "Updated at Inventory Update Form", location, "By rework", plexid, opk); } //按界面条件打印标签 if (ck1) { //获取旧DA标签代码 FGA_NUtility.POL.ExecuteDataSourceResult result11 = PlexHelper.PlexGetResult_3("1953", "Web Service Get Container Label", "@SerialNo", "@PLCName", "@IPAddress", serialno, "Rework in New", "172.17.190.44"); if (result11.OutputParameters != null) { label1 = result11.OutputParameters[2].Value; } } if (ck2) { //获取新DA标签代码 FGA_NUtility.POL.ExecuteDataSourceResult result22 = PlexHelper.PlexGetResult_3("1953", "Web Service Get Container Label", "@SerialNo", "@PLCName", "@IPAddress", nserialno, "Rework in New", "172.17.190.44"); if (result22.OutputParameters != null) { label2 = result22.OutputParameters[2].Value; } } result = "New SerialNo" + label2 + "Old SerialNo" + label1; } else { result = "ope_error"; } } } else { result = "qty_error"; } } catch { } return(result); }
public static string SynToPlex(string data, string toloc, string CycleNO)//同步结果到Plex { string res = string.Empty; string puser = (HttpContext.Current.Session[SysConst.S_LOGIN_USER] as UsersModel).USERNAME; string plexid = ""; string sql = "select plexid from userinfo where username = '******'"; DataSet ds2 = new DataSet(); ds2 = FGA_DAL.Base.SQLServerHelper_FGA.Query(sql); if (ds2 != null && ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0) { plexid = ds2.Tables[0].Rows[0][0].ToString(); } int count = 0; string msg = ""; CycleInventory_Detail model = new CycleInventory_Detail(); List <CycleInventory_Detail> listmodel = new List <CycleInventory_Detail>(); JavaScriptSerializer jssl = new JavaScriptSerializer(); listmodel = jssl.Deserialize <List <CycleInventory_Detail> >(data); string cMon = DateTime.Now.Month.ToString(); string cDay = DateTime.Now.Day.ToString(); string pdate = DateTime.Now.Year.ToString().Substring(2, 2) + (cMon.Length == 1 ? "0" + cMon : cMon) + (cDay.Length == 1 ? "0" + cDay : cDay); foreach (CycleInventory_Detail vo in listmodel) { FGA_NUtility.POL.ExecuteDataSourceResult da_rst = null; FGA_NUtility.POL.ExecuteDataSourceResult move = PlexHelper.PlexGetResult_4("6601", "Container_Move", "@Serial_No", "@Location", "@Last_Action", "@Update_By", vo.SerialNO, toloc.Trim(), "Cycle Inventory", plexid); if (vo.Quantity != vo.ActualQty) { da_rst = PlexHelper.PlexGetResult_6("27181", "Container_Update_Simple", "@Serial_No", "@Quantity", "@Last_Action", "@Update_By", "@Tracking_No", "@Adjustment_Reason_Key", vo.SerialNO, vo.ActualQty.ToString(), "Cycle Inventory", plexid, "INV" + pdate, "2874"); } else { da_rst = PlexHelper.PlexGetResult_5("27181", "Container_Update_Simple", "@Serial_No", "@Last_Action", "@Update_By", "@Tracking_No", "@Adjustment_Reason_Key", vo.SerialNO, "Cycle Inventory", plexid, "INV" + pdate, "2874"); } if (!da_rst.Error) { count++; } else { msg = msg + vo.SerialNO + '\n'; } } if (!String.IsNullOrEmpty(msg)) { res = "Finished: " + count + '\n' + "Follow SerialNO is unsuccessful: " + '\n' + msg; } else { res = "Finished: " + count; //更改CycleInventory_H状态 string synsql = "update [FGA_CycleInventory_H] set CycleStatus = 'Completed',[CompleteBy] ='" + puser + "',[CompleteDate] = getdate() where CycleNO = '" + CycleNO + "'"; FGA_DAL.Base.SQLServerHelper_WMS.ExecuteSql(synsql); } return(res); }