|
|
@@ -7,6 +7,8 @@ using UAS_MES.DataOperate;
|
|
|
using UAS_MES.PublicMethod;
|
|
|
using UAS_MES.Entity;
|
|
|
using LabelManager2;
|
|
|
+using System.Threading;
|
|
|
+using UAS_MES.PublicForm;
|
|
|
|
|
|
namespace UAS_MES.Make
|
|
|
{
|
|
|
@@ -27,8 +29,12 @@ namespace UAS_MES.Make
|
|
|
|
|
|
string ErrorMessage = "";
|
|
|
|
|
|
+ System.DateTime[] indate;
|
|
|
+
|
|
|
ApplicationClass lbl;
|
|
|
|
|
|
+ Thread InitPrint;
|
|
|
+
|
|
|
public Make_ColorBoxLoadPrint()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
@@ -40,6 +46,14 @@ namespace UAS_MES.Make
|
|
|
dh = new DataHelper();
|
|
|
code.Focus();
|
|
|
asc.controllInitializeSize(this);
|
|
|
+ InitPrint = new Thread(InPrint);
|
|
|
+ SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
|
|
|
+ BaseUtil.SetFormCenter(stw);
|
|
|
+ stw.ShowDialog();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void InPrint()
|
|
|
+ {
|
|
|
lbl = new ApplicationClass();
|
|
|
}
|
|
|
|
|
|
@@ -52,129 +66,123 @@ namespace UAS_MES.Make
|
|
|
OperateResult.AppendText(">>输入内容不能为空\n", Color.Red);
|
|
|
return;
|
|
|
}
|
|
|
- //string Omakecode;
|
|
|
- //string Omsid;
|
|
|
- //string Oerrormessage;
|
|
|
- //LogicHandler.CheckStepSNAndMacode(ms_makecode.Text, User.UserSourceCode, code.Text, User.UserCode, out Omakecode, out Omsid, out Oerrormessage)
|
|
|
- //通过输入指定字符来设置当前执行的步骤
|
|
|
- if (load.Checked = true)
|
|
|
- OperateResult.AppendText(">>开始执行上料工序\n", Color.Green);
|
|
|
- else if (unload.Checked = true)
|
|
|
- OperateResult.AppendText(">>开始执行下料工序\n", Color.Green);
|
|
|
- if (ms_makecode.Text == "")
|
|
|
+ if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
|
|
|
{
|
|
|
- if (!LogicHandler.GetMakeInfo(code.Text, out ma_code, out ErrorMessage))
|
|
|
+ string Msid;
|
|
|
+ if (ms_makecode.Text == "")
|
|
|
{
|
|
|
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
|
|
|
- }
|
|
|
- }
|
|
|
- if (ms_makecode.Text != ma_code || ma_code == "")
|
|
|
- {
|
|
|
- //ma_code不为空的时候表示不是第一次加载,提示用户切换工单
|
|
|
- if (ma_code != "" && ms_makecode.Text != "")
|
|
|
- {
|
|
|
- OperateResult.AppendText(">>切换工单至工单号" + ma_code + "\n", Color.Red);
|
|
|
- }
|
|
|
- sql.Clear();
|
|
|
- sql.Append("select ma_code as ms_makecode,mcd_okqty,ma_qty,ma_qty-mcd_inqty as mcd_remainqty,pr_detail,pr_code ");
|
|
|
- sql.Append("from makeserial left join make on ms_makecode=ma_code left join product on ");
|
|
|
- sql.Append("ms_prodcode=pr_code left join makecraftdetail on ms_makecode=mcd_macode where ms_sncode=:sncode");
|
|
|
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select", code.Text);
|
|
|
- if (dt.Rows.Count > 0)
|
|
|
- {
|
|
|
- BaseUtil.SetFormValue(this.Controls, dt);
|
|
|
- sncode.Text = code.Text;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- OperateResult.AppendText(">>序列号" + code.Text + "不存在\n", Color.Red);
|
|
|
- return;
|
|
|
+ if (!LogicHandler.GetMakeInfo(code.Text, out ma_code, out ErrorMessage))
|
|
|
+ {
|
|
|
+ OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
|
|
|
+ }
|
|
|
}
|
|
|
- //判断当前的执行状态 ,Loading表示执行上料操作,UnLoading表示执行下料操作
|
|
|
- if (load.Checked = true)
|
|
|
+ if (ms_makecode.Text != ma_code || ListA.Rows.Count == 0)
|
|
|
{
|
|
|
- string Omakecode;
|
|
|
- string Omsid;
|
|
|
- //string Oerrormessage;
|
|
|
- //检测当前序列号和岗位资源是否对应
|
|
|
- if (LogicHandler.CheckStepSNAndMacode(ms_makecode.Text, User.UserSourceCode, code.Text, User.UserCode, out Omakecode, out Omsid, out ErrorMessage))
|
|
|
+ if (LogicHandler.CheckStepSNAndMacode(ms_makecode.Text, User.UserSourceCode, code.Text, User.UserCode, out ma_code, out Msid, out ErrorMessage) || ListA.Rows.Count > 0)
|
|
|
{
|
|
|
- //判断当前工序是否是上料工序cd_ifinput或者是否是测试工序cd_iftest
|
|
|
sql.Clear();
|
|
|
- sql.Append("select cr_code,cd_stepcode,cd_ifinput,cd_iftest from makeserial left join craft on ms_craftcode=cr_code left join craftdetail on cd_crid=cr_id and ");
|
|
|
- sql.Append("cd_stepcode=ms_nextstepcode where ms_sncode='" + code.Text + "' and ms_makecode='" + ms_makecode.Text + "'");
|
|
|
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
+ sql.Append("select ms_makecode,ms_sncode,ma_qty,pr_detail,pr_code from makeserial left join make on ");
|
|
|
+ sql.Append("ms_makecode=ma_code left join product on ms_prodcode=pr_code where ms_sncode=:sncode");
|
|
|
+ dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select", code.Text);
|
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
- //如果是上料工序
|
|
|
- if (dt.Rows[0]["cd_ifinput"].ToString() != "0")
|
|
|
+ BaseUtil.SetFormValue(this.Controls, dt);
|
|
|
+ LoadCollectNum();
|
|
|
+ if (PrintLabel.SelectedValue == null)
|
|
|
{
|
|
|
- // 查询没有结果,提示该上料工序没有需要上料的数据,请先维护对应的数据
|
|
|
- sql.Clear();
|
|
|
- sql.Append("select sp_id,sp_description,sp_soncode,pr_detail,pr_spec,sp_repcode,pr_id,sp_type,");
|
|
|
- sql.Append("'未采集' sp_ifpick ,sp_prefix,sp_length,sp_regex,sp_regex,sp_ifforsn from stepproduct ");
|
|
|
- sql.Append("left join product on pr_code=sp_soncode where sp_craftcode='" + dt.Rows[0]["cr_code"].ToString() + "' and sp_stepcode='" + dt.Rows[0]["cd_stepcode"].ToString() + "' ");
|
|
|
- sql.Append("And sp_mothercode='" + pr_code.Text + "' and ((sp_type='物料' and pr_tracekind<>2)or sp_type<>'物料') ");
|
|
|
- sql.Append("order by SP_DETNO asc");
|
|
|
- ListA = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
- //获取对应 产品的机身标的打印模板
|
|
|
- if (ListA.Rows.Count > 0)
|
|
|
- {
|
|
|
- OperateResult.AppendText(">>请采集" + ListA.Rows[RemainIndex]["sp_soncode"].ToString() + "的条码\n", Color.Green);
|
|
|
- }
|
|
|
+ OperateResult.AppendText(">>产品编号:" + pr_code.Text + "未维护机身标签\n", Color.Red);
|
|
|
+ return;
|
|
|
}
|
|
|
- if (dt.Rows[0]["cd_iftest"].ToString() != "0")
|
|
|
+ ms_sncode.Text = code.Text;
|
|
|
+ }
|
|
|
+ //判断当前的执行状态 ,Loading表示执行上料操作,UnLoading表示执行下料操作
|
|
|
+ if (load.Checked == true)
|
|
|
+ {
|
|
|
+ OperateResult.AppendText(">>开始执行上料工序\n");
|
|
|
+ //判断当前工序是否是上料工序cd_ifinput或者是否是测试工序cd_iftest
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("select cr_code,cd_stepcode,cd_ifinput,cd_iftest from makeserial left join craft on ms_craftcode=cr_code left join craftdetail on cd_crid=cr_id and ");
|
|
|
+ sql.Append("cd_stepcode=ms_nextstepcode where ms_sncode='" + code.Text + "' and ms_makecode='" + ms_makecode.Text + "'");
|
|
|
+ dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
- DoTestProcedure();
|
|
|
+ //如果是上料工序
|
|
|
+ if (dt.Rows[0]["cd_ifinput"].ToString() != "0")
|
|
|
+ {
|
|
|
+ // 查询没有结果,提示该上料工序没有需要上料的数据,请先维护对应的数据
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("select sp_id,sp_description,sp_soncode,pr_detail,pr_spec,sp_repcode,pr_id,sp_type,");
|
|
|
+ sql.Append("'未采集' sp_ifpick ,sp_prefix,sp_length,sp_regex,sp_regex,sp_ifforsn from stepproduct ");
|
|
|
+ sql.Append("left join product on pr_code=sp_soncode where sp_craftcode='" + dt.Rows[0]["cr_code"].ToString() + "' and sp_stepcode='" + dt.Rows[0]["cd_stepcode"].ToString() + "' ");
|
|
|
+ sql.Append("And sp_mothercode='" + pr_code.Text + "' and ((sp_type='物料' and pr_tracekind<>2)or sp_type<>'物料') ");
|
|
|
+ sql.Append("order by SP_DETNO asc");
|
|
|
+ ListA = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
+ //获取对应 产品的机身标的打印模板
|
|
|
+ if (ListA.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ OperateResult.AppendText(">>请采集" + ListA.Rows[RemainIndex]["sp_soncode"].ToString() + "的条码\n");
|
|
|
+ code.Clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dt.Rows[0]["cd_iftest"].ToString() != "0")
|
|
|
+ DoTestProcedure();
|
|
|
}
|
|
|
}
|
|
|
+ //如果执行的是下料操作
|
|
|
+ else if (unload.Checked == true)
|
|
|
+ {
|
|
|
+ OperateResult.AppendText(">>开始执行下料工序\n");
|
|
|
+ if (LogicHandler.SetMaterialDown(ms_sncode.Text, code.Text, User.UserSourceCode, User.CurrentStepCode, User.UserName, out ErrorMessage))
|
|
|
+ OperateResult.AppendText(">>条码" + code.Text + "下料成功\n", Color.Green);
|
|
|
+ else
|
|
|
+ OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, code.Text);
|
|
|
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
|
|
|
- }
|
|
|
- }
|
|
|
- //如果执行的是下料操作
|
|
|
- else if (unload.Checked = true)
|
|
|
- {
|
|
|
- string ErrorMessage1 = "";
|
|
|
- if (LogicHandler.SetMaterialDown(sncode.Text, code.Text, User.UserSourceCode, User.CurrentStepCode, User.UserName, out ErrorMessage1))
|
|
|
- OperateResult.AppendText(">>条码" + code.Text + "下料成功\n", Color.Green);
|
|
|
- else
|
|
|
- OperateResult.AppendText(">>" + ErrorMessage1 + "\n", Color.Red);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //如果ListA中没有数据执行的是测试工序
|
|
|
- if (ListA.Rows.Count == 0)
|
|
|
- {
|
|
|
- DoTestProcedure();
|
|
|
}
|
|
|
- //存在数据执行的是上料采集
|
|
|
- else
|
|
|
- {
|
|
|
- //如果当前的索引和长度相等则表示采集完成
|
|
|
- if (RemainIndex == ListA.Rows.Count - 1)
|
|
|
+ else {
|
|
|
+ //如果ListA中没有数据执行的是测试工序
|
|
|
+ if (ListA.Rows.Count == 0)
|
|
|
{
|
|
|
- OperateResult.AppendText(">>序列号"+ms_sncode.Text+"对应的工单已经采集完成\n", Color.Green);
|
|
|
- code.Text = "";
|
|
|
- return;
|
|
|
+ DoTestProcedure();
|
|
|
}
|
|
|
- string ErrorMessage;
|
|
|
- //获取上料需要传递的参数,sp_soncode,sp_id
|
|
|
- string soncode = ListA.Rows[RemainIndex]["sp_soncode"].ToString();
|
|
|
- string sonID = ListA.Rows[RemainIndex]["sp_id"].ToString();
|
|
|
- //执行上料
|
|
|
- if (LogicHandler.SetMaterialUp(sncode.Text, ms_makecode.Text, code.Text, soncode, User.UserSourceCode, User.UserName, sonID, out ErrorMessage))
|
|
|
+ //存在数据执行的是上料采集
|
|
|
+ else
|
|
|
{
|
|
|
- RemainIndex = RemainIndex + 1;
|
|
|
- OperateResult.AppendText(">>请采集物料编号为" + ListA.Rows[RemainIndex]["sp_soncode"].ToString() + "的条码\n", Color.Green);
|
|
|
+ //获取上料需要传递的参数,sp_soncode,sp_id
|
|
|
+ string soncode = ListA.Rows[RemainIndex]["sp_soncode"].ToString();
|
|
|
+ string sonID = ListA.Rows[RemainIndex]["sp_id"].ToString();
|
|
|
+ if (!dh.CheckExist("barcode", "bar_code='" + code.Text + "' and bar_prodcode='" + soncode + "'"))
|
|
|
+ {
|
|
|
+ OperateResult.AppendText(">>必须采集物料编号为" + ListA.Rows[RemainIndex]["sp_soncode"].ToString() + "对应的条码\n", Color.Red);
|
|
|
+ code.Clear();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //执行上料
|
|
|
+ if (LogicHandler.SetMaterialUp(ms_sncode.Text, ms_makecode.Text, code.Text, soncode, User.UserSourceCode, User.UserName, sonID, out ErrorMessage))
|
|
|
+ {
|
|
|
+ RemainIndex = RemainIndex + 1;
|
|
|
+ code.Clear();
|
|
|
+ if (RemainIndex <= ListA.Rows.Count - 1)
|
|
|
+ OperateResult.AppendText(">>请采集物料编号为" + ListA.Rows[RemainIndex]["sp_soncode"].ToString() + "的条码\n");
|
|
|
+ if (RemainIndex == ListA.Rows.Count)
|
|
|
+ {
|
|
|
+ OperateResult.AppendText(">>序列号" + ms_sncode.Text + "对应的工单已经采集完成\n", Color.Green);
|
|
|
+ Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, code.Text, int.Parse(PrintNum.Text), indate[PrintLabel.SelectedIndex]);
|
|
|
+ RemainIndex = 0;
|
|
|
+ code.Clear();
|
|
|
+ LoadCollectNum();
|
|
|
+ BaseUtil.CleanDataTableData(ListA);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
|
|
|
+ code.Clear();
|
|
|
+ }
|
|
|
}
|
|
|
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
|
|
|
}
|
|
|
}
|
|
|
+ else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -191,7 +199,6 @@ namespace UAS_MES.Make
|
|
|
//由于打印驱动暂时不可用,暂时注释打印方法
|
|
|
if (LogicHandler.SetCollectionFinish(code.Text, ms_makecode.Text, User.UserName, User.UserSourceCode, out ErrorMessage1))
|
|
|
{
|
|
|
- sncode.Text = "";
|
|
|
//如果值为空默认设置为0
|
|
|
if (int.Parse(mcd_remainqty.Text) > 0)
|
|
|
{
|
|
|
@@ -213,23 +220,30 @@ namespace UAS_MES.Make
|
|
|
OperateResult.AppendText(">>该序列号所属工单" + ms_makecode.Text + "已全部采集完成\n", Color.Green);
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- MessageBox.Show(ErrorMessage1);
|
|
|
+ else OperateResult.AppendText(">>" + ErrorMessage1 + "\n", Color.Red);
|
|
|
}
|
|
|
|
|
|
private void pr_code_TextChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
- dt = (DataTable)dh.ExecuteSql("select pl_labelname,pl_labelcode from productlabel where pl_prodcode='" + pr_code.Text + "' order by pl_isdefault desc", "select");
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select pl_labelname,pl_labelcode,pl_indate,pl_labelurl from productlabel where pl_prodcode='" + pr_code.Text + "' order by pl_isdefault desc", "select");
|
|
|
PrintLabel.DataSource = dt;
|
|
|
PrintLabel.DisplayMember = "pl_labelname";
|
|
|
PrintLabel.ValueMember = "pl_labelcode";
|
|
|
ftpOperater ftp = new ftpOperater();
|
|
|
+ indate = new System.DateTime[dt.Rows.Count];
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
- ftp.Download(dt.Rows[i]["pl_labelname"].ToString());
|
|
|
+ BaseUtil.GetPrintLabel(dt.Rows[i]["pl_labelname"].ToString(), dt.Rows[i]["pl_labelurl"].ToString(), dt.Rows[i]["pl_indate"].ToString());
|
|
|
+ indate[i] = Convert.ToDateTime(dt.Rows[i]["pl_indate"].ToString());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void LoadCollectNum()
|
|
|
+ {
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select ma_qty-mcd_inqty mcd_remainqty from make left join makecraftdetail on mcd_macode=ma_code where ma_code='" + ms_makecode.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'", "select");
|
|
|
+ BaseUtil.SetFormValue(Controls, dt);
|
|
|
+ }
|
|
|
+
|
|
|
private void 标签打印_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
{
|
|
|
lbl.Quit();
|