public static IResult BindPreStep(string process) { string strRes = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Step", "GetPreStepAll", process); ILE.IResult res = JsonConvert.DeserializeObject <LEResult>(strRes); return(res); }
public static IResult DISResult(string spc, string APIName, string json) { string strRes = Tools.ServiceReferenceManager.GetClient().RunServerAPI(spc, APIName, json); ILE.IResult res = JsonConvert.DeserializeObject <LEResult>(strRes); return(res); }
//工单 private void ktxtOrder_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)13 && !ktxtOrder.ReadOnly) { ILE.IResult res = BLL.WIP.Check_WIP_Work(kcb_process.SelectedValue.ToString(), ktxtOrder.Text); //当前IP找不到任何工位 Component.Tool.DisplayResult(txt_resgx, res.Result, res.ExtMessage); AutoMat(); ktxt_lot.Focus(); } }
//自动投料 void AutoMat() { ILE.IResult res = BLL.WIP.Get_WIP_AutoSend(ktxtOrder.Text, kcb_process.SelectedValue.ToString()); if (res.Result) { lotlist = JsonConvert.DeserializeObject <List <LEDAO.V_Material_WIP> >(res.obj.ToString()); kryptonButton1.Visible = true; } else { kryptonButton1.Visible = false; } }
/// <summary> /// 弹出待判 /// </summary> /// <param name="job"></param> //public void LoadJude(IJob job, int j, Main main) //{ // if (job.StepList[j].AutoRun != 1) // { // string JudeJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SFC", "GetJudeBySfc", job.SFC); // List<P_SFC_Jude> listJude = JsonConvert.DeserializeObject<List<P_SFC_Jude>>(JudeJson); // if (listJude != null) // { // UserForm.JudePrompt Jude = new UserForm.JudePrompt(job.SFC, listJude); // Jude.ShowDialog(); // if (Jude.State == 0) // { // return; // } // } // } //} /// <summary> /// 弹出子工步 /// </summary> /// <param name="step_code"></param> /// <param name="job"></param> /// <param name="j"></param> /// <param name="_main"></param> public void LoadSonStep(string step_code, IJob job, int j, Main _main) { bool isfedbatch = false; string sfc = ""; ILE.IResult res = BindSonStep(step_code, job.FlowCode); if (res.obj != null) { List <B_ProcessSonStep> SonStepList = JsonConvert.DeserializeObject <List <B_ProcessSonStep> >(res.obj.ToString()); if (res.Result) { ServiceReference.ServiceClient clien = new ServiceReference.ServiceClient(); string step_name = clien.RunServerAPI("BLL.Step", "GetStepNmae", step_code + "," + job.Product); ProcessSonStepForm gridform = new ProcessSonStepForm(SonStepList, job, isfedbatch, sfc, step_name, j, _main); gridform.ShowDialog(); } } }
//双击行事件 private void dataGridView1_DoubleClick(object sender, EventArgs e) { bool isFedBatch = true; string sfc = this.textSFC.Text.ToString().Trim().ToUpper(); string step_code = this.dataGridView1.SelectedRows[0].Cells["step_code"].Value.ToString(); string flow_code = this.dataGridView1.SelectedRows[0].Cells["flow_code"].Value.ToString(); ILE.IResult res = BindSonStep(step_code, flow_code); if (res.obj != null) { List <B_ProcessSonStep> SonStepList = JsonConvert.DeserializeObject <List <B_ProcessSonStep> >(res.obj.ToString()); if (res.Result) { ServiceReference.ServiceClient clien = new ServiceReference.ServiceClient(); string step_name = clien.RunServerAPI("BLL_Step", "GetStepNmae", step_code + "," + job.Product); ProcessSonStepForm gridform = new ProcessSonStepForm(SonStepList, job, isFedBatch, sfc, step_name, 0, main); gridform.ShowDialog(); } } }
public IResult DoWork(IJob job, string val) { IResult res = new LEResult(); decimal qyt = 0; try { ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(); string product_code = job.Product; string rule_code = client.RunServerAPI("BLL.Product", "GetRuleByProductCode", product_code); //var pattern = @"^([0-9]{4}-).+$"; if (!string.IsNullOrEmpty(rule_code)) { var pattern = @rule_code; bool result = System.Text.RegularExpressions.Regex.IsMatch(val, pattern); if (!result) { res.Result = false; res.ExtMessage = "条码不符合规则,请重新扫描"; return(res); } } string jsdata = client.RunServerAPI("BLL.SFC", "GetSfcState", val); #region --返回空 if (string.IsNullOrEmpty(jsdata)) { if (job.RouteType == "首工站") { //根据sfc在P_SFC_State表中查询是否存在未维修记录 string strclFailLog = client.RunServerAPI("BLL.Faillog", "GetFileLogBySFC", val); if (!string.IsNullOrWhiteSpace(strclFailLog)) { List <P_FailLog> dt = new List <P_FailLog>(); dt = JsonConvert.DeserializeObject <List <P_FailLog> >(strclFailLog); if (dt.Count > 0) { res.ExtMessage = "当前批次[" + val.ToString() + "]已进入维修工序,请检查"; res.Result = false; return(res); } } string ResProduct1 = client.RunServerAPI("BLL.Product", "GetProductFlow", job.OrderNO); res = JsonConvert.DeserializeObject <ILE.LEResult>(ResProduct1); V_ProductFlow produc1 = JsonConvert.DeserializeObject <V_ProductFlow>(res.obj.ToString()); string strRes1 = client.RunServerAPI("BLL.Process", "GetFlowDetailOK", produc1.flow_code + "," + job.ProcessCode); res = JsonConvert.DeserializeObject <ILE.LEResult>(strRes1); if (!res.Result) { return(res); } string strqty = client.RunServerAPI("BLL.SFC", "GetSFCQty_2", job.OrderNO + "," + job.ProcessCode); decimal.TryParse(strqty, out qyt); job.FatherOrderNO = produc1.parent_order; job.Pid = Convert.ToInt32(res.obj); job.Product = produc1.product_code; job.FlowCode = produc1.flow_code; job.MaxQTY = produc1.max_qty.Value; job.MaxQTYOrder = produc1.qty.Value; job.QTYOrder = qyt; if (job.QTYOrder >= job.MaxQTYOrder) { res.ExtMessage = "工单完成数已达上限"; res.Result = false; return(res); } //验证是否打印绑定 ILE.IResult res1 = DP003.CheckPrintBing.PrintBing(job, client, val, res); if (!res1.Result) { return(res1); } job.start_time = DateTime.Parse(client.RunServerAPI("BLL.Process", "GetServerTime", "")); job.SFC = val; job.StepList[job.StepIdx].StepValue = val; job.StepList[job.StepIdx].Completed = true; res.Result = true; return(res); } res.Result = false; res.ExtMessage = "没有成品批次号"; return(res); } #endregion P_SFC_State sfc = JsonConvert.DeserializeObject <P_SFC_State>(jsdata); if (job.Pid == 0) { string ResProduct1 = client.RunServerAPI("BLL.Product", "GetProductFlow", sfc.order_no); res = JsonConvert.DeserializeObject <ILE.LEResult>(ResProduct1); V_ProductFlow produc1 = JsonConvert.DeserializeObject <V_ProductFlow>(res.obj.ToString()); string strRes1 = client.RunServerAPI("BLL.Process", "GetFlowDetailOK", produc1.flow_code + "," + job.ProcessCode); res = JsonConvert.DeserializeObject <ILE.LEResult>(strRes1); if (!res.Result) { return(res); } string strqty = client.RunServerAPI("BLL.SFC", "GetSFCQty_2", sfc.order_no + "," + job.ProcessCode); decimal.TryParse(strqty, out qyt); job.MaxQTY = produc1.max_qty.Value; job.MaxQTYOrder = produc1.qty.Value; job.QTYOrder = qyt; if (job.RouteType == "首工站" && job.QTYOrder >= job.MaxQTYOrder) { res.ExtMessage = "工单完成数已达上限"; res.Result = false; return(res); } job.FatherOrderNO = produc1.parent_order; job.Pid = Convert.ToInt32(res.obj); job.Product = produc1.product_code; job.FlowCode = produc1.flow_code; } string Pid = job.Pid.ToString(); string Strict = client.RunServerAPI("BLL.Process", "GetStrict", Pid); if (Strict == "1") { switch (sfc.state) { case -1: res.Result = false; res.ExtMessage = "成品批次已报废"; return(res); case 0: res.Result = false; res.ExtMessage = "成品批次已停用"; return(res); case 1: break; case 2: res.Result = false; res.ExtMessage = "成品批次已完成"; return(res); } if (job.ProcessCode != sfc.now_process) { string processs_code = sfc.now_process; string processJson = client.RunServerAPI("BLL.Process", "GetProcess", processs_code); V_ProcessList_Workshop list = JsonConvert.DeserializeObject <V_ProcessList_Workshop>(processJson); string Process_name = list.process_name; res.Result = false; res.ExtMessage = "成品批次工序是[" + Process_name + "]"; return(res); } } job.OrderNO = sfc.order_no; ///////////////////////////////////// //判断是否严格控制该工序,严格控制则执行以下代码,不严格控制则随意工序,不做控制 ///////////////////////////////////// //验证是否打印绑定 ILE.IResult resResult = DP003.CheckPrintBing.PrintBing(job, client, val, res); if (!resResult.Result) { return(resResult); } ///// string ResProduct = client.RunServerAPI("BLL.Product", "GetProductFlow", job.OrderNO); res = JsonConvert.DeserializeObject <ILE.LEResult>(ResProduct); if (!res.Result && Strict == "1") { return(res); } V_ProductFlow produc = JsonConvert.DeserializeObject <V_ProductFlow>(res.obj.ToString()); string strRes = client.RunServerAPI("BLL.Process", "GetFlowDetailOK", produc.flow_code + "," + job.ProcessCode); res = JsonConvert.DeserializeObject <ILE.LEResult>(strRes); if (res.obj == null) { return(res); } if (!res.Result && Strict == "1") { return(res); } string strqty1 = client.RunServerAPI("BLL.SFC", "GetSFCQty_2", job.OrderNO + "," + job.ProcessCode); decimal.TryParse(strqty1, out qyt); job.FatherOrderNO = produc.parent_order; job.Pid = Convert.ToInt32(res.obj); job.Product = produc.product_code; job.FlowCode = produc.flow_code; job.MaxQTY = produc.max_qty.Value; job.MaxQTYOrder = produc.qty.Value; job.QTYOrder = qyt; job.SFC = val; // job.start_time = DateTime.Parse(client.RunServerAPI("BLL.Process", "GetServerTime", "")); //job.start_time = DateTime.Now; job.QTY = sfc.qty.Value; job.StepList[job.StepIdx].StepValue = val; job.StepList[job.StepIdx].Completed = true; res.Result = true; return(res); } catch (Exception exc) { res.Result = false; return(res); } }
/// <summary> /// 关键工序采集完成后,加载后续的工序,比如零件,录入,设备,从processStep表 /// </summary> /// <param name="job"></param> public static ILE.IResult FillJobStep(IJob job) { int i = 0; List <Step> liststep = new List <Step>(); if (!job.IsExiseStep && job.MaxQTY > 1 & job.RouteType == "首工站" & job.production_mode == 0) { Step sp4 = new Step(); sp4.StepName = "批次数量"; sp4.StepCode = "LOT QTY"; sp4.TypeID = 0; sp4.DriveCode = "DP004"; sp4.FileName = "DP004.dll"; sp4.IsRecord = 0; sp4.AllowReuse = 0; sp4.Format = "^[0-9]+$"; sp4.Completed = false; liststep.Add(sp4); i++; } //job.IndexBack = job.StepList.Count(); ILE.IResult res = BindStep(job.Pid.ToString()); if (!res.Result) { res.obj = null; return(res); } if (res.obj == null) //无工步的情况 { job.IndexBack = job.StepList.Count + i; job.StepList.AddRange(liststep); job.StepLoad = false; return(res); } List <dynamic> steplist = JsonConvert.DeserializeObject <List <dynamic> >(res.obj.ToString()); foreach (dynamic tstep in steplist) { Step step = new Step(); step.StepID = tstep.step_id; step.StepName = tstep.step_name; step.StepCode = tstep.step_code; step.StepType = tstep.step_type; step.TypeID = tstep.type_id; step.DriveCode = tstep.drive_code; step.FileName = tstep.file_name; step.Parameter = tstep.parameter; step.Matcode = tstep.mat_code; step.CtrlType = tstep.ctrl_type; step.TimeOut = tstep.time_out; step.Format = tstep.format; step.AllowReuse = tstep.allow_reuse; step.AutoRun = tstep.autorun; step.AutoRestart = (int)tstep.auto_restart; step.Idx = tstep.idx; step.IsRecord = tstep.is_record; step.Triger = tstep.triger; step.Parameter2 = tstep.parameter2; step.consume_type = (int)tstep.consume_type; step.consume_percent = (float)tstep.consume_percent; liststep.Add(step); } //代表前工步的数量 job.IndexBack = job.StepList.Count + i; job.StepList.AddRange(liststep); job.StepLoad = true; return(res); }
//批次 private void ktxt_lot_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13 && !ktxt_lot.ReadOnly) { if (string.IsNullOrWhiteSpace(ktxt_lot.Text)) { Component.Tool.DisplayResult(txt_resgx, false, "装料批次不能为空"); return; } string lot = ktxt_lot.Text.Trim().Replace("#", ""); try { string mat_code = string.Empty; if (lotWIP == null) { string order_no = ktxtOrder.Text; if (order_no == "") { MessageBox.Show("工单号不可为空,请选择工单", "提示"); return; } //根据批次号及工单获取物料编号 mat_code = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.WIP", "GetMat_codeBylot", lot + "," + order_no); if (mat_code == "") { MessageBox.Show("该工单和批次未能获取物料编号,请确认工单号及批次号", "提示"); return; } } else { mat_code = lotWIP.mat_code; } DateTime MaterialInputTime = Convert.ToDateTime(Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.WIP", "GetWipInputTimeByLot", lot + "," + mat_code)); string strwip_valid = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Product", "GetWip_validByProductCode", mat_code); if (strwip_valid != "") { decimal wip_valid = Convert.ToDecimal(strwip_valid); TimeSpan ts = DateTime.Now - MaterialInputTime; decimal h = ts.Hours; if (h > wip_valid) { DialogResult result = KryptonMessageBox.Show("该物料已超出时效时间,确定继续使用吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.No) { return; } } } ILE.IResult res = BLL.WIP.Check_WIP_Lot(ktxtOrder.Text, lot); if (res.Result) { res = BLL.WIP.Get_WIP_LotInfo(ktxtOrder.Text, lot); if (!res.Result) { Component.Tool.DisplayResult(txt_resgx, res.Result, res.ExtMessage); return; } List <LEDAO.V_Material_WIP> wip = JsonConvert.DeserializeObject <List <LEDAO.V_Material_WIP> >(res.obj.ToString()); if (lotWIP == null) { if (wip.Count == 1) { lotWIP = wip[0]; } //多个wip_id,弹窗选择 if (wip.Count > 1) { SelGridForm gridform = new SelGridForm(wip); gridform.ShowDialog(); if (gridform.WIP != null) { lotWIP = gridform.WIP; ktxt_lot.Text = lotWIP.lot_no; } else { return; } } } //判断是否是最小批次 if (!BLL.WIP.Check_Mbm(ktxtOrder.Text)) { //是否可分批投入 if (BLL.WIP.Check_Mat_Split(Convert.ToInt32(lotWIP.id), ktxtOrder.Text)) { UserForm.NumForm num = new UserForm.NumForm(); num.ShowDialog(); switch (num.State) { case 1: if (lotWIP.lot_qty < num.Num) { Component.Tool.DisplayResult(txt_resgx, false, "当前批次记录不能大于" + lotWIP.lot_qty); return; } lotWIP.lot_qty = num.Num; break; case 2: break; default: return; } } } int id = Convert.ToInt32(lotWIP.id); res = BLL.WIP.Get_WIP_Point(kcb_Station.SelectedValue.ToString(), ktxtOrder.Text, id); //判断是否有安装点 if (res.Result) { pointList = JsonConvert.DeserializeObject <List <string> >(res.obj.ToString()); if (pointList.Count > 0) { ktxt_piont.Visible = true; kryptonLabel2.Visible = true; ktxt_piont.Focus(); } } else { res = BLL.WIP.Sumit_FeedMatToStation(id, null, kcb_Station.SelectedValue.ToString(), ktxtOrder.Text, ktxt_emp.Text, lotWIP.lot_qty); deWork(); DataBind(); } } else { ktxt_lot.Text = ""; } Component.Tool.DisplayResult(txt_resgx, res.Result, res.ExtMessage); } catch (Exception exc) { KryptonMessageBox.Show(exc.Message); } finally { lotWIP = null; } } }