You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
474 lines
16 KiB
474 lines
16 KiB
using Gm_WMS.DataAccess.DataService;
|
|
using Stone.Common;
|
|
using Stone.Entity;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Stone.WinModule.Assembling
|
|
{
|
|
public partial class frmAssembling : Form
|
|
{
|
|
#region 初始化
|
|
|
|
private HtmlDocument doc = null;
|
|
|
|
private int StationLineCode = Convert.ToInt32(MyAppconfig.ReadValue("装配工位代码"));
|
|
|
|
private LocalDBService db = new LocalDBService();
|
|
private Entity_t_JIS_Assemble t_JIS_Assemble = new Entity_t_JIS_Assemble();
|
|
private Entity_t_StationLine t_StationLine = new Entity_t_StationLine();
|
|
private Entity_t_AssyStation t_AssyStation = new Entity_t_AssyStation();
|
|
|
|
private DataSet dsStationLine = null;
|
|
|
|
public frmAssembling()
|
|
{
|
|
InitializeComponent();
|
|
|
|
try
|
|
{
|
|
InitData();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void frmAssembling_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.webBrowser1.Navigate(Application.StartupPath + "\\html\\生产工位看板\\Produce1.html");
|
|
|
|
|
|
}catch(Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 事件
|
|
|
|
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
doc = webBrowser1.Document;
|
|
|
|
doc.GetElementById("btnAllOpen").Click += btnAllOpen_Click;
|
|
|
|
|
|
DataTable dtAssyStation = t_AssyStation.GetData($"[Code] like '%{StationLineCode}'").Tables[0];
|
|
if(dtAssyStation.Rows.Count == 0) throw new Exception($"工位号{StationLineCode}不存在");
|
|
|
|
doc.GetElementById("lblStationLineName").InnerHtml = dtAssyStation.Rows[0]["Name"].ToString();
|
|
|
|
timer1.Enabled = true; //扫描光标定位
|
|
timer2.Enabled = true; //看板时间显示
|
|
timer3.Enabled = true; //自动数据更新
|
|
timer4.Enabled = true; //节拍计时器
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void btnAllOpen_Click(object sender, HtmlElementEventArgs e)
|
|
{
|
|
MessageBox.Show("播放视频,建议另外开个windows窗口来播放");
|
|
}
|
|
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
{
|
|
if (!this.txtBarCode.Focused)
|
|
{
|
|
this.txtBarCode.Focus();
|
|
this.txtBarCode.SelectAll();
|
|
}
|
|
}
|
|
|
|
private void timer2_Tick(object sender, EventArgs e)
|
|
{
|
|
//显示当前时间
|
|
this.doc.GetElementById("lblTimeNow").InnerHtml = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
}
|
|
|
|
private void timer3_Tick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
UpdateWeb();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.lblMsg.Text = ex.Message;
|
|
}
|
|
}
|
|
|
|
private void timer4_Tick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if(TimerCount > 0)
|
|
{
|
|
TimerCount--;
|
|
}
|
|
|
|
doc.GetElementById("lblTimer").InnerHtml = $"{TimerCount}秒";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.lblMsg.Text = ex.Message;
|
|
}
|
|
}
|
|
|
|
private void txtBarCode_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
ScanBarCode();
|
|
}
|
|
}
|
|
|
|
private void btnExit_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 自定义方法
|
|
|
|
private void ScanBarCode()
|
|
{
|
|
try
|
|
{
|
|
this.lblMsg.Text = "";
|
|
|
|
string BarCode = this.txtBarCode.Text.Trim().ToUpper();
|
|
if (BarCode == "") throw new Exception("条码不能为空");
|
|
|
|
if (StationLineCode == 1)//扫描生产号(校验是否正确)
|
|
{
|
|
ScanBarCode(BarCode);
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("只有第1工位需要扫描");
|
|
}
|
|
|
|
|
|
this.txtBarCode.Text = "";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.lblMsg.Text = ex.Message;
|
|
}
|
|
finally
|
|
{
|
|
this.txtBarCode.Focus();
|
|
this.txtBarCode.SelectAll();
|
|
}
|
|
|
|
}
|
|
|
|
private void ScanBarCode(string BarCode)
|
|
{
|
|
if (dsStationLine.Tables[0].Rows.Count > 0)
|
|
{
|
|
if (BarCode == dsStationLine.Tables[0].Rows[0]["productionNumber"].ToString())
|
|
{
|
|
t_StationLine.Edit("[IsCorrect]=1", "[ID]=" + dsStationLine.Tables[0].Rows[0]["ID"].ToString());
|
|
|
|
dsStationLine.Tables[0].Rows[0]["IsCorrect"] = 1;
|
|
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("扫描的生产号不正确");
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("当前工位上没有订单");
|
|
}
|
|
|
|
}
|
|
|
|
private int TimerCount = 0; //倒计时
|
|
private void UpdateWeb()
|
|
{
|
|
if (UpdateData())
|
|
{
|
|
TimerCount = Convert.ToInt32(MyAppconfig.ReadValue("装配工位节拍"));
|
|
|
|
GetBomKey();
|
|
|
|
UpdateHtml(); //更新HTML显示
|
|
}
|
|
}
|
|
|
|
private void GetBomKey()
|
|
{
|
|
string StationCode = "RB0" + StationLineCode;
|
|
string BomCode = dsStationLine.Tables[0].Rows.Count > 0 ? dsStationLine.Tables[0].Rows[0]["itemNumber"].ToString() : "";
|
|
string CarModelCode = dsStationLine.Tables[0].Rows.Count > 0 ? dsStationLine.Tables[0].Rows[0]["CarModelCode"].ToString() : "";
|
|
string LUS = dsStationLine.Tables[0].Rows.Count > 0 ? dsStationLine.Tables[0].Rows[0]["LUS"].ToString() : "";
|
|
LUS = LUS.Replace(",", "','");
|
|
|
|
|
|
DataRow[] drBoms = dsBom.Tables[0].Select($"[BomCode]='{BomCode}' and [工位]='{StationCode}' and [IsKey]=1 and [CarModelCode]='{CarModelCode}'");
|
|
dsBomKey = dsBom.Clone();
|
|
|
|
foreach (DataRow drBom in drBoms)
|
|
{
|
|
dsBomKey.Tables[0].Rows.Add(drBom.ItemArray);
|
|
}
|
|
|
|
DataRow[] drBomsAssy = dsBom.Tables[0].Select($"[BomCode] in ('{LUS}') and [工位]='{StationCode}' and [CarModelCode]='{CarModelCode}'");
|
|
dsBomAssy = dsBom.Clone();
|
|
|
|
foreach (DataRow drBom in drBomsAssy)
|
|
{
|
|
dsBomAssy.Tables[0].Rows.Add(drBom.ItemArray);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private bool UpdateData()
|
|
{
|
|
//一号工位要去下一个订单,其他工位只取当前订单
|
|
DataSet dsTemp = null;
|
|
if (StationLineCode == 1)
|
|
{
|
|
dsTemp = t_StationLine.GetData("top 2 *", "([StationCode]=1 or [StationCode]=0)", "[StationCode] desc, [ID] asc");
|
|
if (dsTemp.Tables[0].Rows.Count == 2)
|
|
{
|
|
if (Convert.ToInt32(dsTemp.Tables[0].Rows[0]["StationCode"]) == 1)
|
|
{
|
|
//显示下一个床单的信息
|
|
doc.GetElementById("lblNextOrder").InnerHtml = dsTemp.Tables[0].Rows[1]["productionNumber"].ToString();
|
|
doc.GetElementById("lblNextDescription").InnerHtml = dsTemp.Tables[0].Rows[1]["description"].ToString();
|
|
}
|
|
else
|
|
{
|
|
doc.GetElementById("lblNextOrder").InnerHtml = "";
|
|
doc.GetElementById("lblNextDescription").InnerHtml = "";
|
|
|
|
dsTemp = t_StationLine.GetData("[StationCode]=" + StationLineCode);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
doc.GetElementById("lblNextOrder").InnerHtml = "";
|
|
doc.GetElementById("lblNextDescription").InnerHtml = "";
|
|
|
|
if (dsTemp.Tables[0].Rows.Count == 1)
|
|
{
|
|
if (Convert.ToInt32(dsTemp.Tables[0].Rows[0]["StationCode"]) != 1)
|
|
{
|
|
dsTemp = t_StationLine.GetData("[StationCode]=" + StationLineCode);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
dsTemp = t_StationLine.GetData("[StationCode]=" + StationLineCode);
|
|
}
|
|
|
|
|
|
//当前订单信息显示
|
|
if (dsTemp.Tables[0].Rows.Count > 0)
|
|
{
|
|
doc.GetElementById("lblProductionNumber").InnerHtml = dsTemp.Tables[0].Rows[0]["ProductionNumber"].ToString();
|
|
doc.GetElementById("lblDescription").InnerHtml = dsTemp.Tables[0].Rows[0]["Description"].ToString();
|
|
doc.GetElementById("lblIsCorrect").InnerHtml = dsTemp.Tables[0].Rows[0]["IsCorrect"].ToString() == "1" ? "是" : "否";
|
|
|
|
doc.GetElementById("lblRivetLeft").InnerHtml = dsTemp.Tables[0].Rows[0]["RivetCount2"].ToString() + "/" + dsTemp.Tables[0].Rows[0]["RivetCount1"].ToString();
|
|
doc.GetElementById("lblRivetRight").InnerHtml = dsTemp.Tables[0].Rows[0]["RivetCount4"].ToString() + "/" + dsTemp.Tables[0].Rows[0]["RivetCount3"].ToString();
|
|
doc.GetElementById("lblScrewLeft").InnerHtml = dsTemp.Tables[0].Rows[0]["ScrewCount2"].ToString() + "/" + dsTemp.Tables[0].Rows[0]["ScrewCount1"].ToString();
|
|
doc.GetElementById("lblScrewRight").InnerHtml = dsTemp.Tables[0].Rows[0]["ScrewCount4"].ToString() + "/" + dsTemp.Tables[0].Rows[0]["ScrewCount3"].ToString();
|
|
|
|
if (Convert.ToInt32(dsTemp.Tables[0].Rows[0]["IsInsert"]) == 1)
|
|
{
|
|
doc.GetElementById("Layer1").InnerHtml = "插单";
|
|
}
|
|
else
|
|
{
|
|
doc.GetElementById("Layer1").InnerHtml = "";
|
|
}
|
|
|
|
if (Convert.ToInt32(dsTemp.Tables[0].Rows[0]["IsCancel"]) == 1)
|
|
{
|
|
doc.GetElementById("Layer2").InnerHtml = "取消";
|
|
}
|
|
else
|
|
{
|
|
doc.GetElementById("Layer2").InnerHtml = "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
doc.GetElementById("lblProductionNumber").InnerHtml = "";
|
|
doc.GetElementById("lblDescription").InnerHtml = "";
|
|
doc.GetElementById("lblIsCorrect").InnerHtml = "";
|
|
|
|
doc.GetElementById("lblRivetLeft").InnerHtml = "0/0";
|
|
doc.GetElementById("lblRivetRight").InnerHtml = "0/0";
|
|
doc.GetElementById("lblScrewLeft").InnerHtml = "0/0";
|
|
doc.GetElementById("lblScrewRight").InnerHtml = "0/0";
|
|
|
|
doc.GetElementById("Layer1").InnerHtml = "";
|
|
doc.GetElementById("Layer2").InnerHtml = "";
|
|
}
|
|
|
|
|
|
if (dsTemp.Tables[0].Rows.Count > 0)
|
|
{
|
|
if (dsStationLine == null)
|
|
{
|
|
dsStationLine = dsTemp.Copy();
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
if (dsStationLine.Tables[0].Rows.Count == 0)
|
|
{
|
|
dsStationLine = dsTemp.Copy();
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
//如果当前数据没有变化,就不需要刷新界面
|
|
if (dsStationLine.Tables[0].Rows[0]["ID"].ToString() != dsTemp.Tables[0].Rows[0]["ID"].ToString())
|
|
{
|
|
dsStationLine = dsTemp.Copy();
|
|
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dsStationLine = dsTemp.Copy();
|
|
return true;
|
|
}
|
|
|
|
}
|
|
|
|
private void UpdateHtml()
|
|
{
|
|
#region 关键LU显示
|
|
//关键LU最多显示10行
|
|
for (int i = 0; i < 10; i++)
|
|
{
|
|
if (doc.GetElementById($"lblLuRow_no_{i + 1}") == null) break;
|
|
|
|
doc.GetElementById($"lblLuRow_no_{i + 1}").InnerHtml = " ";
|
|
doc.GetElementById($"lblLuRow_code_{i + 1}").InnerHtml = " ";
|
|
doc.GetElementById($"lblLuRow_name_{i + 1}").InnerHtml = " ";
|
|
|
|
}
|
|
|
|
//显示关键LU
|
|
for (int i = 0; i < dsBomKey.Tables[0].Rows.Count; i++)
|
|
{
|
|
if (doc.GetElementById($"lblLuRow_no_{i + 1}") == null) break;
|
|
|
|
doc.GetElementById($"lblLuRow_no_{i + 1}").InnerHtml = (i + 1).ToString();
|
|
doc.GetElementById($"lblLuRow_code_{i + 1}").InnerHtml = dsBomKey.Tables[0].Rows[i]["零件号"].ToString();
|
|
doc.GetElementById($"lblLuRow_name_{i + 1}").InnerHtml = dsBomKey.Tables[0].Rows[i]["零件"].ToString();
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 装配零件显示
|
|
//装配零件最多显示20行
|
|
for (int i = 0; i < 20; i++)
|
|
{
|
|
|
|
if (doc.GetElementById($"lblPartRow_no_{i + 1}") == null) break;
|
|
|
|
doc.GetElementById($"lblPartRow_no_{i + 1}").InnerHtml = " ";
|
|
doc.GetElementById($"lblPartRow_code_{i + 1}").InnerHtml = " ";
|
|
doc.GetElementById($"lblPartRow_name_{i + 1}").InnerHtml = " ";
|
|
doc.GetElementById($"lblPartRow_qty_{i + 1}").InnerHtml = " ";
|
|
|
|
}
|
|
|
|
//显示所有装配零件
|
|
for (int i = 0; i < dsBomAssy.Tables[0].Rows.Count; i++)
|
|
{
|
|
if (doc.GetElementById($"lblPartRow_no_{i + 1}") == null) break;
|
|
|
|
doc.GetElementById($"lblPartRow_no_{i + 1}").InnerHtml = (i + 1).ToString();
|
|
doc.GetElementById($"lblPartRow_code_{i + 1}").InnerHtml = dsBomAssy.Tables[0].Rows[i]["零件号"].ToString();
|
|
doc.GetElementById($"lblPartRow_name_{i + 1}").InnerHtml = dsBomAssy.Tables[0].Rows[i]["零件"].ToString();
|
|
doc.GetElementById($"lblPartRow_qty_{i + 1}").InnerHtml = dsBomAssy.Tables[0].Rows[i]["数量"].ToString();
|
|
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 初始化BOM清单(每次程序启动的时候调用BOM清单,以提高速度,如果更新BOM需要重新启动程序生效)
|
|
|
|
private DataSet dsBom = null; //全部BOM
|
|
private DataSet dsBomKey = null; //关键LU
|
|
private DataSet dsBomAssy = null; //当前工位的所有零件
|
|
|
|
|
|
//初始化BOM数据
|
|
private void InitData()
|
|
{
|
|
string sql = @"
|
|
select
|
|
CarModelCode,
|
|
VerCode,
|
|
ParentCode as [BomCode],
|
|
IsKey,
|
|
AssyStationCode as [工位],
|
|
ChildCode as [零件号],
|
|
ChildName as [零件],
|
|
Qty as [数量],
|
|
Deploy as [配置],
|
|
Feature as [特征],
|
|
BarCode as [条码],
|
|
0 as [状态]
|
|
|
|
from v_Bom
|
|
order by Sort asc
|
|
";
|
|
dsBom = db.Exec_DataSet(sql);
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|
|
|