|
|
@@ -5,16 +5,13 @@ using System.Windows.Forms;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using System.Text;
|
|
|
using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
using System.Diagnostics;
|
|
|
using LabelManager2;
|
|
|
using UAS_LabelMachine.PublicMethod;
|
|
|
using UAS_LabelMachine.Entity;
|
|
|
-using UAS_特殊解析规则;
|
|
|
using UAS_LabelMachine.PublicForm;
|
|
|
using System.Threading;
|
|
|
using System.IO;
|
|
|
-using System.Globalization;
|
|
|
using System.IO.Ports;
|
|
|
using UAS_LabelMachine.CustomControl;
|
|
|
|
|
|
@@ -72,6 +69,8 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
bool logout = false;
|
|
|
|
|
|
+ string SplitChar = ",@#| &";
|
|
|
+
|
|
|
DataTable SingleLabelParam;
|
|
|
DataTable MidLabelParam;
|
|
|
DataTable OutLabelParam;
|
|
|
@@ -228,7 +227,10 @@ namespace UAS_LabelMachine
|
|
|
case "FrontendCheck":
|
|
|
//比对当前箱数量和容量
|
|
|
FrontCollect.Text = msg;
|
|
|
- FrontCheckFunction(msg);
|
|
|
+ if (!FrontCheckFunction(msg))
|
|
|
+ {
|
|
|
+ MessageLog.AppendText(">>未能匹配到合适的采集策略\n", Color.Red);
|
|
|
+ }
|
|
|
break;
|
|
|
case "BackendCheck":
|
|
|
BackCheck.Text = msg;
|
|
|
@@ -247,17 +249,35 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private bool FrontCheckFunction(string msg)
|
|
|
{
|
|
|
+ int GroupCount = 0;
|
|
|
for (int i = 0; i < ScanGroup.Rows.Count; i++)
|
|
|
{
|
|
|
+
|
|
|
string sg_name = ScanGroup.Rows[i]["sg_name"].ToString();
|
|
|
string sg_brand = ScanGroup.Rows[i]["sg_brand"].ToString();
|
|
|
- reg = new Regex(ScanGroup.Rows[i]["sg_script"].ToString());
|
|
|
+ string sg_script = ScanGroup.Rows[i]["sg_script"].ToString();
|
|
|
+ string sg_id = ScanGroup.Rows[i]["sg_id"].ToString();
|
|
|
+ reg = new Regex(sg_script);
|
|
|
Match matchs1 = reg.Match(msg);
|
|
|
int index = 0;
|
|
|
- string[] arr = matchs1.Value.Split(',');
|
|
|
- DataTable dt = BaseUtil.filterDataTable(ScanItem, "sg_name='" + sg_name + "' and sg_brand='" + sg_brand + "' and items_num=" + arr.Length);
|
|
|
-
|
|
|
- if (dt.Rows.Count > 0)
|
|
|
+ //自动获取分隔符号,分割解析到的数据
|
|
|
+ char Splitor = BaseUtil.GetSplitChar(matchs1.Value.ToString());
|
|
|
+ string[] sgarr = sg_script.Split(Splitor);
|
|
|
+ string[] arr = matchs1.Value.Split(Splitor);
|
|
|
+ DataTable dt = BaseUtil.filterDataTable(ScanItem, "sg_id=" + sg_id);
|
|
|
+ List<int> ItemIndex = new List<int>();
|
|
|
+ for (int j = 0; j < sgarr.Length; j++)
|
|
|
+ {
|
|
|
+ for (int k = 0; k < dt.Rows.Count; k++)
|
|
|
+ {
|
|
|
+ if (sgarr[j].Contains(dt.Rows[k]["si_name"].ToString()))
|
|
|
+ {
|
|
|
+ ItemIndex.Add(j);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //成功获取到了分隔符号并且匹配的项次相等, 如果不包含分隔符只需要一项
|
|
|
+ if ((SplitChar.Contains(Splitor.ToString()) && ItemIndex.Count == dt.Rows.Count) || (!SplitChar.Contains(Splitor.ToString()) && ItemIndex.Count == 1))
|
|
|
{
|
|
|
for (int j = 0; j < dt.Rows.Count; j++)
|
|
|
{
|
|
|
@@ -269,61 +289,71 @@ namespace UAS_LabelMachine
|
|
|
if (si_expression != "")
|
|
|
{
|
|
|
si_exp = new Regex(si_expression);
|
|
|
- DateCode = si_exp.Match(arr[index]).Value;
|
|
|
+ DateCode = si_exp.Match(arr[ItemIndex[j]]).Value;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DateCode = arr[index];
|
|
|
+ DateCode = arr[ItemIndex[j]];
|
|
|
}
|
|
|
LabelInfDataTable.Rows[CurrentRowIndex]["pib_datecode"] = DateCode;
|
|
|
break;
|
|
|
case "LotNo":
|
|
|
- LotNo = arr[index];
|
|
|
+ LotNo = arr[ItemIndex[j]];
|
|
|
LabelInfDataTable.Rows[CurrentRowIndex]["pib_lotno"] = LotNo;
|
|
|
break;
|
|
|
case "PN":
|
|
|
- PN = arr[index];
|
|
|
- if (LabelInfDataTable.Rows[CurrentRowIndex]["pib_lotno"].ToString() != QTY.ToString())
|
|
|
+ PN = arr[ItemIndex[j]];
|
|
|
+ if (LabelInfDataTable.Rows[CurrentRowIndex]["pd_custprodspec"].ToString() != PN)
|
|
|
{
|
|
|
- return false;
|
|
|
+ MessageLog.AppendText(">>客户物料型号不匹配\n", Color.Red);
|
|
|
}
|
|
|
break;
|
|
|
case "Order":
|
|
|
- Order = arr[index];
|
|
|
- if (LabelInfDataTable.Rows[CurrentRowIndex]["pib_ordercode"].ToString() != QTY.ToString())
|
|
|
+ Order = arr[ItemIndex[j]];
|
|
|
+ if (LabelInfDataTable.Rows[CurrentRowIndex]["pd_pocode"].ToString() != Order)
|
|
|
{
|
|
|
- return false;
|
|
|
+ MessageLog.AppendText(">>订单号不匹配\n", Color.Red);
|
|
|
}
|
|
|
break;
|
|
|
case "QTY":
|
|
|
if (si_expression != "")
|
|
|
{
|
|
|
si_exp = new Regex(si_expression);
|
|
|
- QTY = si_exp.Match(arr[index]).Value;
|
|
|
+ QTY = si_exp.Match(arr[ItemIndex[j]]).Value;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- QTY = arr[index];
|
|
|
+ QTY = arr[ItemIndex[j]];
|
|
|
}
|
|
|
- if (LabelInfDataTable.Rows[CurrentRowIndex]["pib_lotno"].ToString() != QTY.ToString())
|
|
|
+ if (LabelInfDataTable.Rows[CurrentRowIndex]["pib_qty"].ToString() != QTY.ToString())
|
|
|
{
|
|
|
- return false;
|
|
|
+ MessageLog.AppendText(">>数量不匹配\n", Color.Red);
|
|
|
}
|
|
|
break;
|
|
|
case "OutBox":
|
|
|
- OutBox = arr[index];
|
|
|
+ OutBox = arr[ItemIndex[j]];
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
index = index + 1;
|
|
|
}
|
|
|
- LabelInf.Refresh();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ GroupCount = GroupCount + 1;
|
|
|
}
|
|
|
}
|
|
|
- LabelInfDataTable.Rows[CurrentRowIndex]["pib_ifpick"] = true;
|
|
|
- LabelInf.Refresh();
|
|
|
- return true;
|
|
|
+ if (GroupCount == ScanGroup.Rows.Count)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LabelInfDataTable.Rows[CurrentRowIndex]["pib_ifpick"] = true;
|
|
|
+ LabelInf.Refresh();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void BackendCheckFunction(string msg, string pib_id)
|
|
|
@@ -745,17 +775,13 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
//查询所有的采集策略
|
|
|
sql.Clear();
|
|
|
- sql.Append("select * from (select sg_brand,si_item,sg_name,si_expression,instr(sg_name,si_name) itemindex from (select sg_brand,si_item ");
|
|
|
- sql.Append(",max(si_expression)si_expression,sg_name,si_name from prodiodetail left join product on pd_prodcode=pr_code left join scangroup on nvl(pd_brand,pr_brand) ");
|
|
|
- sql.Append("=sg_brand left join scanitem on sg_id=si_sgid where pd_inoutno='" + pi_inoutno.Text + "' and si_enable=-1 group by ");
|
|
|
- sql.Append("sg_brand,si_item,sg_name,si_name))A left join (select count(1) items_num,sg_name,sg_brand from (select sg_name,sg_brand from prodiodetail ");
|
|
|
- sql.Append("left join product on pd_prodcode=pr_code left join scangroup on nvl(pd_brand,pr_brand)=sg_brand left join scanitem ");
|
|
|
- sql.Append("on sg_id=si_sgid where pd_inoutno='" + pi_inoutno.Text + "' and si_enable=-1 group by sg_brand,si_item,sg_name ");
|
|
|
- sql.Append(") group by sg_name,sg_brand)B on A.sg_name=b.sg_name and A.sg_brand=B.sg_brand order by A.sg_name,itemindex");
|
|
|
+ sql.Append("select sg_id,sg_brand,si_item ,sg_script,max(si_expression)si_expression,instr(sg_name,si_name)itemindex,sg_name,si_name,sg_step from prodiodetail left join ");
|
|
|
+ sql.Append("product on pd_prodcode=pr_code left join scangroup on nvl(pd_brand,pr_brand) =sg_brand left join scanitem on sg_id=si_sgid ");
|
|
|
+ sql.Append("where pd_inoutno='" + pi_inoutno.Text + "' and si_enable=-1 group by sg_id,sg_script,sg_brand,si_item,sg_name,si_name,sg_step order by sg_step,itemindex ");
|
|
|
ScanItem = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
sql.Clear();
|
|
|
- sql.Append("select distinct sg_brand from prodiodetail left join product on pd_prodcode=pr_code left join scangroup on nvl(pd_brand,");
|
|
|
- sql.Append("pr_brand)=sg_brand left join scanitem on sg_id=si_sgid where pd_inoutno='" + pi_inoutno.Text + "' and si_enable=-1 ");
|
|
|
+ sql.Append("select distinct sg_brand from prodiodetail left join product on pd_prodcode=pr_code left ");
|
|
|
+ sql.Append("join scangroup on nvl(pd_brand,pr_brand)=sg_brand where pd_inoutno='" + pi_inoutno.Text + "'");
|
|
|
DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
FrontCombo.DataSource = dt1;
|
|
|
FrontCombo.DisplayMember = "sg_brand";
|
|
|
@@ -1320,7 +1346,7 @@ namespace UAS_LabelMachine
|
|
|
back_sg_separator.Text = dt.Rows[0]["splitfront"].ToString();
|
|
|
}
|
|
|
//获取所有的匹配脚本
|
|
|
- ScanGroup = (DataTable)dh.ExecuteSql("select distinct sg_brand,sg_script,sg_name from prodiobarcode left join scangroup on pib_brand=sg_brand where pib_inoutno='" + pi_inoutno.Text + "' and sg_id is not null", "select");
|
|
|
+ ScanGroup = (DataTable)dh.ExecuteSql("select distinct sg_brand,sg_id,sg_name,sg_script from prodiobarcode left join scangroup on pib_brand=sg_brand where pib_inoutno='" + pi_inoutno.Text + "' and sg_id is not null", "select");
|
|
|
//绑定数据之后往下找到未采集的数据显示在当前采集的栏目
|
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
{
|