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); } }
public static string CommitFailNewSFCInfo(string json) { string iRtn = "0"; //0-成功,非0-失败 try { string[] arrstrjsonitem = json.Split(';'); if (arrstrjsonitem.Length < 3) { iRtn = "1:传入参数不全"; //传入参数不全 return(iRtn); } string stroldsfc = arrstrjsonitem[0]; string strnewsfc = arrstrjsonitem[1]; string strfailqty = arrstrjsonitem[2]; decimal dfailqty = decimal.Parse(strfailqty); //提交结果 var context = LEDAO.APIGateWay.GetEntityContext(); using (context) { #region 除数据 var delstate = from u in context.P_SFC_State where u.SFC == strnewsfc select u; foreach (var del in delstate) { context.P_SFC_State.DeleteObject(del); } var delilog = from u in context.P_SFC_Process_IOLog where u.SFC == strnewsfc select u; foreach (var del in delilog) { context.P_SFC_Process_IOLog.DeleteObject(del); } var delData = from u in context.P_SFC_ProcessData where u.SFC == strnewsfc select u; foreach (var del in delData) { context.P_SFC_ProcessData.DeleteObject(del); } var delWip = from u in context.P_Material_WIP where u.lot_no == strnewsfc select u; foreach (var del in delWip) { context.P_Material_WIP.DeleteObject(del); } #endregion //context.SaveChanges(); //先提交 #region 增加数据 //--P_SFC_State var varstate = from u in context.P_SFC_State where u.SFC == stroldsfc select u; foreach (var cnew in varstate) { cnew.qty = cnew.qty - dfailqty; //产生批次记录 P_SFC_State pnewsfcstate = new P_SFC_State(); //pnewsfcstate = cnew; //pnewsfcstate.id = 0; pnewsfcstate.grade_id = cnew.grade_id; pnewsfcstate.grade_type = cnew.grade_type; pnewsfcstate.input_station = cnew.input_station; pnewsfcstate.is_tray = cnew.is_tray; pnewsfcstate.main_order = cnew.main_order; pnewsfcstate.mat_code = cnew.mat_code; pnewsfcstate.now_process = cnew.now_process; pnewsfcstate.order_no = cnew.order_no; pnewsfcstate.parent_order = cnew.parent_order; pnewsfcstate.process_time = cnew.process_time; pnewsfcstate.SFC = strnewsfc; pnewsfcstate.qty = dfailqty; pnewsfcstate.initqty = dfailqty; pnewsfcstate.state = cnew.state; pnewsfcstate.workshop = cnew.workshop; pnewsfcstate.fail_times = cnew.fail_times; pnewsfcstate.from_process = cnew.from_process; pnewsfcstate.begin_time = cnew.begin_time; pnewsfcstate.end_time = cnew.end_time; pnewsfcstate.begin_Date = cnew.begin_Date; pnewsfcstate.begin_classcode = cnew.begin_classcode; pnewsfcstate.end_Date = cnew.end_Date; pnewsfcstate.end_classcode = cnew.end_classcode; context.P_SFC_State.AddObject(pnewsfcstate); } //--P_SFC_Process_IOLog var varIoLog = from u in context.P_SFC_Process_IOLog where u.SFC == stroldsfc select u; foreach (var cnewiolog in varIoLog) { cnewiolog.qty = cnewiolog.qty - dfailqty; //产生批次记录 P_SFC_Process_IOLog pnewsfcIolog = new P_SFC_Process_IOLog(); //pnewsfcIolog = cnewiolog; //pnewsfcIolog.id = 0; pnewsfcIolog.class_code = cnewiolog.class_code; pnewsfcIolog.emp_code = cnewiolog.emp_code; pnewsfcIolog.fail_times = cnewiolog.fail_times; pnewsfcIolog.group_code = cnewiolog.group_code; pnewsfcIolog.input_time = cnewiolog.input_time; pnewsfcIolog.order_no = cnewiolog.order_no; pnewsfcIolog.output_time = cnewiolog.output_time; pnewsfcIolog.p_date = cnewiolog.p_date; pnewsfcIolog.pass = cnewiolog.pass; pnewsfcIolog.process_code = cnewiolog.process_code; pnewsfcIolog.start_time = cnewiolog.start_time; pnewsfcIolog.station_code = cnewiolog.station_code; pnewsfcIolog.workshop = cnewiolog.workshop; pnewsfcIolog.SFC = strnewsfc; pnewsfcIolog.qty = dfailqty; context.P_SFC_Process_IOLog.AddObject(pnewsfcIolog); } //--P_SFC_ProcessData var varData = from u in context.P_SFC_ProcessData where u.SFC == stroldsfc select u; foreach (var cnewData in varData) { //cnewData.qty = cnewData.qty - dfailqty; //当前P_SFC_ProcessData qty为0,不需要修改数据 //产生批次记录 P_SFC_ProcessData pnewsfcData = new P_SFC_ProcessData(); //pnewsfcData = cnewData; //pnewsfcData.id = 0; pnewsfcData.class_code = cnewData.class_code; pnewsfcData.emp_code = cnewData.emp_code; pnewsfcData.fail_times = cnewData.fail_times; pnewsfcData.idx = cnewData.idx; pnewsfcData.input_time = cnewData.input_time; pnewsfcData.mat_code = cnewData.mat_code; pnewsfcData.order_no = cnewData.order_no; pnewsfcData.P_Date = cnewData.P_Date; pnewsfcData.pass = cnewData.pass; pnewsfcData.pid = cnewData.pid; pnewsfcData.qty = 0; pnewsfcData.SFC = strnewsfc; pnewsfcData.station_code = cnewData.station_code; pnewsfcData.step_id = cnewData.step_id; pnewsfcData.step_type = cnewData.step_type; pnewsfcData.unit = cnewData.unit; pnewsfcData.val = cnewData.val; pnewsfcData.workshop = cnewData.workshop; context.P_SFC_ProcessData.AddObject(pnewsfcData); } //--P_Material_WIP var varWip = from u in context.P_Material_WIP where u.lot_no == stroldsfc select u; foreach (var cnewWip in varWip) { if (cnewWip.lot_qty - dfailqty < 0) { continue; } cnewWip.lot_qty = cnewWip.lot_qty - dfailqty; #region //产生批次记录 //P_Material_WIP pnewsfcWip = new P_Material_WIP(); //pnewsfcWip.bill_no = cnewWip.bill_no; //pnewsfcWip.feed_time = cnewWip.feed_time; //pnewsfcWip.input_time = cnewWip.input_time; //pnewsfcWip.lot_qty = dfailqty; //pnewsfcWip.lot_no = strnewsfc; //pnewsfcWip.mat_code = cnewWip.mat_code; //pnewsfcWip.order_no = cnewWip.order_no; //pnewsfcWip.Parent_order = cnewWip.Parent_order; //pnewsfcWip.parent_station = cnewWip.parent_station; //pnewsfcWip.point_id = cnewWip.point_id; //pnewsfcWip.state = cnewWip.state; //pnewsfcWip.station_code = cnewWip.station_code; //pnewsfcWip.workshop = cnewWip.workshop; //context.P_Material_WIP.AddObject(pnewsfcWip); #endregion } #endregion #region 修改被拆分批次 var varsfcstate = from u in context.P_SFC_State where u.SFC == stroldsfc select u; foreach (var mod in varsfcstate) { mod.initqty -= dfailqty; //mod.qty -= dfailqty; } #endregion context.SaveChanges(); } return(iRtn); } catch (Exception exp) { iRtn = "9:" + exp.Message; return(iRtn); } }
//提交fail 登记 private void btn_addfaillog_Click(object sender, EventArgs e) { ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(); try { string strfailsfc = txtBox_registeredsfc.Text; if (string.IsNullOrWhiteSpace(txtBox_registeredsfc.Text)) { SendMsgShow("SFC 信息为空,请检查", 2); return; } if (string.IsNullOrWhiteSpace(ktxtBox_orderno.Text)) { SendMsgShow("工单 信息为空,请检查", 2); return; } if (string.IsNullOrWhiteSpace(kComboBox_Process1.Text)) { SendMsgShow("测试工序 信息为空,请检查", 2); return; } //if (string.IsNullOrWhiteSpace(kComboBox_TestStation.Text)) //{ // SendMsgShow("测试工位 信息为空,请检查", 2); // return; //} //if (string.IsNullOrWhiteSpace(txtBox_empname.Text)) //{ // SendMsgShow("测试人 信息为空,请检查", 2); // return; //} //检查员工号是否正常???? double dfailqty = 0; //是否需要拆分批次 if (kryptonCheckBox1.Checked == true) { if (string.IsNullOrWhiteSpace(txtBox_newregisteredsfc.Text)) { SendMsgShow("新的批次号为空,请检查", 2); return; } if (string.IsNullOrWhiteSpace(KtxtBox_newregisteredsfcNum.Text)) { SendMsgShow("新的批次号的数量为空,请检查", 2); return; } if (double.Parse(KtxtBox_newregisteredsfcNum.Text.Trim()) - double.Parse(kTxtBox_SFCQty.Text.Trim()) >= 0.000001) { dfailqty = 0; MessageBox.Show("拆分批次数量大于或等于总数量 ", "错误"); return; } strfailsfc = txtBox_newregisteredsfc.Text; } ////////////////////////////////////////////////////// string wipdata = client.RunServerAPI("BLL.WIP", "GetWipQty1ByLot", txtBox_registeredsfc.Text); if (!string.IsNullOrEmpty(wipdata)) { decimal SumNum = 0; for (int i = 0; i < dataGridView_faildesc.RowCount; i++) { decimal num = Convert.ToDecimal(this.dataGridView_faildesc.Rows[i].Cells["strfailNum"].Value.ToString()); if (num != 0) { SumNum += num; } } decimal wipqty = Convert.ToDecimal(wipdata); if (SumNum > wipqty) { MessageBox.Show("该批次已使用,线边仓剩余数量小于登记不良数量 ", "提示"); return; } } ///////////////////////////////////////////////////// try { if (KtxtBox_newregisteredsfcNum.Enabled == false) { dfailqty = double.Parse(kTxtBox_SFCQty.Text.Trim()); } else { dfailqty = double.Parse(KtxtBox_newregisteredsfcNum.Text.Trim()); } } catch (Exception exp) { MessageBox.Show("请输入正确数量 " + exp.Message, "提示"); return; } int iisProcess = 0; // 提交维修登记时,如果现象中都是不需要处理的,则维修状态为-1=不需要处理,否则维修状态为0=需要处理; List <NGCode_Data> lstcurrngcode = new List <NGCode_Data>(); for (int i = 0; i < dataGridView_faildesc.Rows.Count; i++) { //如果DataGridView是可编辑的,将数据提交,否则处于编辑状态的行无法取到 dataGridView_faildesc.EndEdit(); DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dataGridView_faildesc.Rows[i].Cells["bselect"]; Boolean flag = Convert.ToBoolean(checkCell.Value); if (flag == true) //查找被选择的数据行 { //从 DATAGRIDVIEW 中获取数据项 NGCode_Data clngcode = new NGCode_Data(); clngcode.failPhenomenoncode = dataGridView_faildesc.Rows[i].Cells[0].Value.ToString().Trim(); clngcode.failPhenomenondesc = dataGridView_faildesc.Rows[i].Cells[1].Value.ToString().Trim(); clngcode.failtypecode = dataGridView_faildesc.Rows[i].Cells[2].Value.ToString().Trim(); clngcode.strfailNum = dataGridView_faildesc.Rows[i].Cells[3].Value.ToString().Trim(); clngcode.isProcess = dataGridView_faildesc.Rows[i].Cells[4].Value.ToString().Trim(); if (clngcode.isProcess == "是") { iisProcess = 1; } double dfailNum = double.Parse(clngcode.strfailNum); if (dfailNum <= 0.0000001) { SendMsgShow("不良现象[" + clngcode.failPhenomenoncode + "]对应数量为0 请检查", 2); lstcurrngcode.Clear(); return; } if ((dfailNum - dfailqty) > 0.0000001) { SendMsgShow("不良现象[" + clngcode.failPhenomenoncode + "]对应数量大于总数量, 请检查", 2); lstcurrngcode.Clear(); return; } lstcurrngcode.Add(clngcode); } } if (lstcurrngcode.Count <= 0) { SendMsgShow("未选择不良现象, 请检查", 2); return; } if (kryptonCheckBox1.Checked) { if (txtBox_newregisteredsfc.Text == txtBox_registeredsfc.Text) { SendMsgShow("拆分新批次不能与批次号相同", 2); return; } string jsdata = client.RunServerAPI("BLL.SFC", "GetSfcState", txtBox_newregisteredsfc.Text); if (!string.IsNullOrEmpty(jsdata)) { SendMsgShow("拆分批次号已存在,请更改", 2); return; } //如果有新的批次号,需要将主批次号的过站记录复制到新的批次号中 int iRet = CreateNewSFCInfo(txtBox_registeredsfc.Text, txtBox_newregisteredsfc.Text, double.Parse(KtxtBox_newregisteredsfcNum.Text.Trim())); if (iRet == 0) { //strfailsfc = txtBox_newregisteredsfc.Text; //kTxtBox_SFCQty.Text = KtxtBox_newregisteredsfcNum.Text; } else { MessageBox.Show("拆分批次失败 ", "错误"); return; } } //在P_FailLog表中增加不良记录 //获取P_Date string str = ""; str = client.RunServerAPI("BLL.Faillog", "GetPDate", strGroupCode); DateTime dPdate = new DateTime(); dPdate = DateTime.Parse(str); P_FailLog dtpfaillog = new P_FailLog(); dtpfaillog.fguid = Guid.NewGuid().ToString(); dtpfaillog.order_no = ktxtBox_orderno.Text; dtpfaillog.sfc = strfailsfc; //dtpfaillog.from_process= dtpfaillog.from_process = dicTestProcessInfo[kComboBox_Process1.Text]; //来源工序id //dtpfaillog.from_station = dicTestStationInfo[kComboBox_TestStation.Text]; //来源工站id dtpfaillog.process_code = dicTestProcessInfo[kComboBox_Process1.Text]; //当前工序id,责任工序,先预设维修工序id,再在维修中来修改 dtpfaillog.from_emp = g_stremp; dtpfaillog.fail_times = 1; dtpfaillog.p_date = dPdate; dtpfaillog.class_code = client.RunServerAPI("BLL.Faillog", "GetClassCode", strGroupCode); dtpfaillog.Disposal_Process = g_stremp; dtpfaillog.ws_code = g_strWorkShopCode; if (iRepairProcc == 3) { dtpfaillog.state = 9; //报废 iisProcess = 1; } else { if (iisProcess == 1) { dtpfaillog.state = 0; //后续会根据不良现象来判断是否需要给“-1”, } else { dtpfaillog.state = -1; } } dtpfaillog.qty = (decimal)dfailqty; dtpfaillog.ng_remark = richTextBox_ng_remark.Text.Trim(); string strJson = JsonConvert.SerializeObject(dtpfaillog); str = ""; str = client.RunServerAPI("BLL.Faillog", "AddFailLog", strJson); if (string.IsNullOrWhiteSpace(str) || str == "0") { SendMsgShow("增加不良记录失败", 2); return; } //在P_Fail_Detail表中增加不良记录 for (int i = 0; i < lstcurrngcode.Count; i++) { P_Fail_Detail clpfiledetail = new P_Fail_Detail(); clpfiledetail.fguid = dtpfaillog.fguid; clpfiledetail.order_no = ktxtBox_orderno.Text; clpfiledetail.sfc = strfailsfc; clpfiledetail.ng_code = lstcurrngcode[i].failPhenomenoncode; clpfiledetail.qty = decimal.Parse(lstcurrngcode[i].strfailNum); clpfiledetail.ws_code = g_strWorkShopCode; strJson = JsonConvert.SerializeObject(clpfiledetail); str = ""; str = client.RunServerAPI("BLL.Fail_Detail", "AddFail_Detail", strJson); if (string.IsNullOrWhiteSpace(str) || str == "0") { SendMsgShow("增加不良明细失败", 2); return; } } //更新P_SFC_State 当前工序和过站时间 +P_SFC_Process_IOLog 当前工序和工站 if (iisProcess == 1) //如果需要处理,才更新state表信息??? { str = ""; //order,sfc,nowprocess,state,failtimes,pass,grade_id,grade_type,iofailtimes strJson = ktxtBox_orderno.Text + "," + strfailsfc + "," + dicTestProcessInfo[kComboBox_Process1.Text] + "," + "0" + "," + "1" + "," + "0" + "," + "grade_id" + "," + "grade_type" + "," + "1" + "," + dicTestProcessInfo[kComboBox_Process1.Text]; str = client.RunServerAPI("BLL.SFC", "UpDataSFCInfoAndSFCIOLogData", strJson); if (!str.Contains("OK")) { SendMsgShow("更新P_SFC_State 失败 Or P_SFC_Process_IOLog 失败," + str, 2); return; } } SendMsgShow("提交不良信息已完成", 0); //判断是否需要快速报废 if (iRepairProcc == 3) { P_SFC_State clpsfcstateTmp = new P_SFC_State(); clpsfcstateTmp.order_no = ktxtBox_orderno.Text; clpsfcstateTmp.SFC = strfailsfc; clpsfcstateTmp.fail_times = 0; clpsfcstateTmp.state = -1; //设置状态为 -1 ,已报废 clpsfcstateTmp.now_process = "END"; //order,sfc,nowprocess,state,failtimes,pass,grade_id,grade_type,iofailtimes strJson = clpsfcstateTmp.order_no + "," + strfailsfc + "," + "END" + "," + "-1" + "," + "0" + "," + "0" + "," + "grade_id" + "," + "grade_type" + "," + "0" + "," + dicTestProcessInfo[kComboBox_Process1.Text]; str = client.RunServerAPI("BLL.SFC", "UpDataSFCInfoAndSFCIOLogData", strJson); if (!str.Contains("OK")) { MessageBox.Show("更新P_SFC_State 失败 Or P_SFC_Process_IOLog 失败," + str, "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } ClearFormPar(); txtBox_registeredsfc.Text = ""; } catch (Exception exp) { SendMsgShow(exp.Message, 2); } return; }
private void ktb_input1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)13) { Component.Tool.DisplayResult(textBox1, true, ""); string SFC = ktb_input1.Text.Trim(); try { string str = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Pack", "GetSfcState", SFC); if (str.Length == 0) { //Component.Tool.DisplayResult(textBox3, true, "托盘号不存在,是否创建托盘?"); DialogResult result = KryptonMessageBox.Show("确定创建此托盘号吗?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.No) { ktb_input1.Text = ""; ktb_input1.Focus(); //Component.Tool.DisplayResult(textBox3, true, "请输入托盘号"); List <P_SFC_State> dp = new List <P_SFC_State>(); kryptonDataGridView1.DataSource = dp; return; } P_SFC_State sfcList = new P_SFC_State() { is_tray = 1, SFC = ktb_input1.Text, }; string strJson = JsonToolsNet.ObjectToJson(sfcList); string opq = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Pack", "AddSFCState", strJson); ktb_input1.Text = ""; ktb_input2.Focus(); ktb_input2.Enabled = true; //Component.Tool.DisplayResult(textBox4, true, "请输入SFC"); //Component.Tool.DisplayResult(textBox3, true, ""); List <P_SFC_State> kn = new List <P_SFC_State>(); kryptonDataGridView1.DataSource = kn; return; } else { List <P_SFC_State> dt = JsonConvert.DeserializeObject <List <P_SFC_State> >(str); if (dt[0].is_tray == 0) { //Component.Tool.DisplayResult(textBox3, false, "不是托盘号,请重新输入!"); ktb_input1.Text = ""; ktb_input1.Focus(); List <P_SFC_State> kn = new List <P_SFC_State>(); kryptonDataGridView1.DataSource = kn; return; } else { string tray_sfc = dt[0].SFC; string msn = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Pack", "GetTrayDetail", tray_sfc); if (msn.Length == 0) { ktb_input2.Enabled = true; //Component.Tool.DisplayResult(textBox3, true, "托盘目前为空"); List <P_SFC_State> kn = new List <P_SFC_State>(); kryptonDataGridView1.DataSource = kn; ktb_input2.Focus(); return; } else { ktb_input2.Enabled = true; //Component.Tool.DisplayResult(textBox3, true, "加载成功"); LoadGridView(); ktb_input2.Focus(); } } } } catch (Exception exc) { KryptonMessageBox.Show(exc.Message); } } }
//提交操作 private void btn_reback_Click(object sender, EventArgs e) { ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(); try { if (string.IsNullOrWhiteSpace(richTextBox_faildesc.Text.Trim())) { MessageBox.Show("请给出维修说明,在记录中填写", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrWhiteSpace(kComboBox_Process.Text.Trim())) { MessageBox.Show("请选择责任工序", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //修改数据库信息,1.P_SFC_State(如果P_SFC_State表中存在记录才修改), //更新P_SFC_State 当前工序和过站时间 +P_SFC_Process_IOLog 当前工序 int ishebeifail = 0; string str = ""; List <P_Fail_Detail> lstpFailDetail = new List <P_Fail_Detail>(); for (int i = 0; i < dataGridView_faildetail.Rows.Count; i++) { P_Fail_Detail onepfaildetail = new P_Fail_Detail(); onepfaildetail.id = int.Parse(dataGridView_faildetail.Rows[i].Cells["detail_id"].Value.ToString()); if ((this.dataGridView_faildetail.Rows[i].Cells["failReasoncode"] as DataGridViewComboBoxCell).Value == null) { MessageBox.Show("原因代码为空,请选择", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } onepfaildetail.reason_code = dicReason[(string)(this.dataGridView_faildetail.Rows[i].Cells["failReasoncode"] as DataGridViewComboBoxCell).Value]; if (onepfaildetail.reason_code.Contains("EEE")) //判断是否为设备不良原因代码 { ishebeifail = 1; } if ((this.dataGridView_faildetail.Rows[i].Cells["failtype"] as DataGridViewComboBoxCell).Value == null) { MessageBox.Show("原因类型代码为空,请选择", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } onepfaildetail.reasontype_code = dicTypeReason[(string)(this.dataGridView_faildetail.Rows[i].Cells["failtype"] as DataGridViewComboBoxCell).Value]; lstpFailDetail.Add(onepfaildetail); } //order,sfc,nowprocess,state,failtimes,pass,grade_id,grade_type,iofailtimes if (checkBox1.Checked == true) { if (checkedListBox1.CheckedItems.Count > 0) { for (int items = 0; items < checkedListBox1.CheckedItems.Count; items++) { string judecode = ((ComboboxItem)checkedListBox1.CheckedItems[items]).Value; string judename = ((ComboboxItem)checkedListBox1.CheckedItems[items]).Text; string SFC = textBox_sfc.Text.ToString(); string JudeCodeJson = client.RunServerAPI("BLL.SFC", "GetJudeSFC", judecode + "," + SFC); if (string.IsNullOrEmpty(JudeCodeJson)) { P_SFC_Jude sfc_jude = new P_SFC_Jude() { jude_code = judecode, jude_name = judename, sfc = SFC, state = 0 }; string judejson = JsonToolsNet.ObjectToJson(sfc_jude); client.RunServerAPI("BLL.SFC", "InsertSFCJude", judejson); } else { MessageBox.Show("该批次已存在[ " + judename + " ]的待判,不可重复", "提示"); return; } } } else { MessageBox.Show("请勾选待判名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } string strJson = ""; P_SFC_State clpsfcstateTmp = new P_SFC_State(); clpsfcstateTmp.order_no = strorderno; clpsfcstateTmp.SFC = strsfc; clpsfcstateTmp.fail_times = 0; if (iRepairProcc == 1) //降级 { if (string.IsNullOrWhiteSpace(kComboBox_ProductGrade.Text.Trim())) { MessageBox.Show("请先设置级别", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (string.IsNullOrWhiteSpace(kComboBox_rebackprocess.Text.Trim())) { MessageBox.Show("请先设置返回工序", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } clpsfcstateTmp.from_process = strfromprocess_code; clpsfcstateTmp.now_process = diczrprocess[this.kComboBox_rebackprocess.Text.ToString().Trim()]; if (clpsfcstateTmp.now_process == "END") { clpsfcstateTmp.state = 2;//该批次已完成,可以流向下一工序 } else { clpsfcstateTmp.state = 1; //设置状态为 1 ,未完成,,正常加工 } B_Product_Grade clBProductGrade = new B_Product_Grade(); clBProductGrade = dicProductGrade[kComboBox_ProductGrade.Text.Trim()]; clpsfcstateTmp.grade_id = clBProductGrade.grade_id.ToString(); clpsfcstateTmp.grade_type = clBProductGrade.grade_type; //order,sfc,nowprocess,state,failtimes,pass,grade_id,grade_type,iofailtimes strJson = strorderno + "," + strsfc + "," + diczrprocess[this.kComboBox_rebackprocess.Text.ToString().Trim()] + "," + "1" + "," + "0" + "," + "0" + "," + clBProductGrade.grade_id + "," + clBProductGrade.grade_type + "," + "0" + "," + strfromprocess_code; } else if (iRepairProcc == 2) //待判 { //待完善??? } else if (iRepairProcc == 3) //报废 { clpsfcstateTmp.state = -1; //设置状态为 -1 ,已报废 clpsfcstateTmp.now_process = "END"; //order,sfc,nowprocess,state,failtimes,pass,grade_id,grade_type,iofailtimes strJson = strorderno + "," + strsfc + "," + "END" + "," + "-1" + "," + "0" + "," + "0" + "," + "grade_id" + "," + "grade_type" + "," + "0" + "," + strfromprocess_code; } else //不做操作,直接返回指定工序 { if (string.IsNullOrWhiteSpace(kComboBox_rebackprocess.Text.Trim())) { MessageBox.Show("请先设置返回工序", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } clpsfcstateTmp.state = 1; //设置状态为 1 ,未完成,,正常加工 clpsfcstateTmp.now_process = diczrprocess[this.kComboBox_rebackprocess.Text.ToString().Trim()]; //order,sfc,nowprocess,state,failtimes,pass,grade_id,grade_type,iofailtimes strJson = strorderno + "," + strsfc + "," + diczrprocess[this.kComboBox_rebackprocess.Text.ToString().Trim()] + "," + "1" + "," + "0" + "," + "0" + "," + "grade_id" + "," + "grade_type" + "," + "0" + "," + strfromprocess_code; } str = client.RunServerAPI("BLL.SFC", "UpDataSFCInfoAndSFCIOLogData", strJson); if (!str.Contains("OK")) { MessageBox.Show("更新P_SFC_State 失败 Or P_SFC_Process_IOLog 失败," + str, "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //更新维修结果 P_FailLog P_Fail_Detail P_FailLog clpfaillog = new P_FailLog(); clpfaillog.fid = int.Parse(strfid); if (!string.IsNullOrWhiteSpace(kComboBox_Process.Text.Trim())) { clpfaillog.process_code = strfromprocess_code; clpfaillog.Disposal_Process = strfromprocess_code; #region //if (diczrprocess.Keys.Contains(kComboBox_Process.Text.Trim())) //{ // clpfaillog.process_code = diczrprocess[kComboBox_Process.Text.Trim()]; //} //else //{ // MessageBox.Show("请选择责任工序!"); // return; //} //clpfaillog.Disposal_Process = diczrprocess[kComboBox_Process.Text.Trim()]; #endregion //根据责任工序,找到责任人和工位 strJson = ""; strJson = strsfc + "," + clpfaillog.process_code; str = client.RunServerAPI("BLL.SFC", "GetSFCIOLogInfo", strJson); if (string.IsNullOrWhiteSpace(str)) { // } else { List <P_SFC_Process_IOLog> lstsfciolog = JsonConvert.DeserializeObject <List <P_SFC_Process_IOLog> >(str); if (lstsfciolog.Count > 0) { clpfaillog.emp_code = lstsfciolog[0].emp_code; } if (ishebeifail == 1) //存在设备不良,需要根据工位代码找到设备代码 { //根据工位,找到设备 str = client.RunServerAPI("BLL.Station", "GetStationEquipmentByStation", lstsfciolog[0].station_code); if (string.IsNullOrWhiteSpace(str)) { // } else { List <B_StationMachine> lststationequipment = JsonConvert.DeserializeObject <List <B_StationMachine> >(str); if (lstsfciolog.Count > 0) { clpfaillog.equipment_code = lststationequipment[0].machine_code; } } } } } if (iRepairProcc == 1) //降级 { clpfaillog.state = 1; } else if (iRepairProcc == 2) //待判 { //待完善??? } else if (iRepairProcc == 3) //报废 { clpfaillog.state = 9; //报废状态 } else { clpfaillog.state = 1; } if (!string.IsNullOrWhiteSpace(richTextBox_faildesc.Text.Trim())) { clpfaillog.repair_remark = richTextBox_faildesc.Text.Trim(); } str = ""; str = client.RunServerAPI("BLL.Faillog", "UpdateFailLog", JsonConvert.SerializeObject(clpfaillog)); if (!str.Contains("1")) { MessageBox.Show("更新P_FailLog 失败" + str, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } str = ""; str = client.RunServerAPI("BLL.Fail_Detail", "UpdateFail_Detail", JsonConvert.SerializeObject(lstpFailDetail)); if (!str.Contains("1")) { MessageBox.Show("更新P_Fail_Detail 失败" + str, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch (Exception exp) { MessageBox.Show("提交失败:" + exp.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //提交完成 MessageBox.Show("维修完成", "OK", MessageBoxButtons.OK, MessageBoxIcon.None); this.Close(); }