From 86f899fa91e811415614dff1a699141144bfc802 Mon Sep 17 00:00:00 2001
From: quanzhou <quan.zhou@broconcentric.com>
Date: 星期五, 12 十二月 2025 13:25:37 +0800
Subject: [PATCH] S5上传mes逻辑修改及打印机逻辑修改和数据库存储数据增加
---
src/Bro.M141.Process/M141Process_Mysql.cs | 60 ++++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 42 insertions(+), 18 deletions(-)
diff --git a/src/Bro.M141.Process/M141Process_Mysql.cs b/src/Bro.M141.Process/M141Process_Mysql.cs
index 59cd94f..592ceda 100644
--- a/src/Bro.M141.Process/M141Process_Mysql.cs
+++ b/src/Bro.M141.Process/M141Process_Mysql.cs
@@ -23,10 +23,8 @@
{
public class M141Process_Mysql
{
-
string connStrAll = "server=localhost;port=3306;user id=root;password=123456;database=BroDB;charset=utf8";
string connStrLocal = "server=localhost;port=3306;user id=root;password=123456;database=BroDB;charset=utf8";
-
#region 鍩虹鎿嶄綔
public void IniDBIP(string IP)
@@ -109,7 +107,6 @@
#endregion
-
public void NewProduct(ProductModel pro)
{
try
@@ -123,7 +120,7 @@
if (!string.IsNullOrEmpty(index))
{
- string str2 = $"delete from forlocal where id < ({index}-1000)";
+ string str2 = $"delete from forlocal where id < ({index}-2000)";
Operatoremysql(str2, connStrLocal);
}
@@ -199,7 +196,7 @@
//string destr = "delete from forall where id not in (select id from (select id from forall order BY id desc limit 1000) as subquery)";
//Operatoremysql(destr, connStrAll);
- if (string.IsNullOrEmpty(netname) /*|| devicestr != "S3" */)
+ if (string.IsNullOrEmpty(netname) || devicestr != "S3")
{
if (pro.Details != null)
{
@@ -213,7 +210,6 @@
item.DefectList.AddRange(defects.Distinct());
item.DefectList = item.DefectList.Distinct().ToList();
}
-
}
}
}
@@ -245,7 +241,7 @@
//HOperatorSet.AffineTransPoint2d(new HTuple(pro.Centermatrix.ToArray()), x1, y1, out HTuple qx, out HTuple qy);
CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"sql {pro.SN}鍘熷潗鏍噞num} {x1},{y1}");
- HOperatorSet.ProjectiveTransPixel(new HTuple(pro.Centermatrix.ToArray()), x1, y1, out HTuple qx, out HTuple qy);
+ HOperatorSet.ProjectiveTransPixel(new HTuple(pro.Centermatrix.ToArray()), y1, x1, out HTuple qx, out HTuple qy);
CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"sql {pro.SN}鏂板潗鏍噞num} {qx},{qy}");
Netdefectdetail temc = new Netdefectdetail()
@@ -287,11 +283,11 @@
if (!string.IsNullOrEmpty(index))
{
- string str2 = $"delete from forall where id < ({index}-1000)";
+ string str2 = $"delete from forall where id < ({index}-2000)";
Operatoremysql(str2, connStrAll);
}
- string mysqlstr = $"insert into forall (basketcode,device,plcnum,sn,data,time) values('{pro.BasketCode}','{devicestr}','{pro.SEQUENCE}','{pro.SN}','{JsonConvert.SerializeObject(pro, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All })}','{DateTime.Now.ToString("yyyyMMddHHmmss")}')";
+ string mysqlstr = $"insert into forall (basketcode,zword,device,plcnum,sn,data,time) values('{pro.BasketCode}','{pro.Zword}','{devicestr}','{pro.SEQUENCE}','{pro.SN}','{JsonConvert.SerializeObject(pro, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All })}','{DateTime.Now.ToString("yyyyMMddHHmmss")}')";
if (Operatoremysql(mysqlstr, connStrAll))
{
@@ -335,7 +331,6 @@
return null;
}
-
public List<Netdefectdetail> GetNetdefectdetails(string plcnum)
{
try
@@ -374,8 +369,8 @@
{
ProductModel p = null;
p = JsonConvert.DeserializeObject<ProductModel>(str, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All });
-
- return p.Result=="OK";
+
+ return p.Result == "OK";
}
}
catch (Exception e)
@@ -385,13 +380,13 @@
return false;
}
-
- public string Getbasketcode(string plcnum, out string sn)
+ public string Getbasketcode(string plcnum, out string sn, out string zword)
{
sn = "Noread";
+ zword = "Noread";
try
{
- string mysqlstr = $"select basketcode,sn from forall where plcnum='{plcnum}' && device='S2' order by id desc limit 1";
+ string mysqlstr = $"select basketcode,sn,zword from forall where plcnum='{plcnum}' && device='S2' order by id desc limit 1";
var dt = selectdt(mysqlstr, connStrAll);
if (dt == null || dt.Rows.Count == 0)
{
@@ -400,6 +395,7 @@
else
{
sn = dt.Rows[0][1].ToString();
+ zword = dt.Rows[0][2].ToString();
return dt.Rows[0][0].ToString();
}
}
@@ -410,6 +406,37 @@
return "NoRead";
}
+ public List<ProductModel> SNGetProductList(string sn,string device)
+ {
+ try
+ {
+ string mysqlstr = $"select data from forall where sn='{sn}' and device='{device}'";
+ var dt = selectdt(mysqlstr, connStrAll);
+ if (dt == null)
+ {
+ return null;
+ }
+ else
+ {
+ List<ProductModel> plist = new List<ProductModel>();
+ for (int i = 0; i < dt.Rows.Count; i++)
+ {
+ string strjson = dt.Rows[i][0].ToString();
+ strjson = strjson.Replace(@"\", @"\\");
+ ProductModel p = JsonConvert.DeserializeObject<ProductModel>(strjson, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All });
+
+ //JsonConvert.DeserializeObject<IProcessConfig>(_configBackupStr, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All });
+ plist.Add(p);
+ }
+ return plist;
+ }
+ }
+ catch (Exception e)
+ {
+ CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鏁版嵁搴揻orall鏁版嵁寮傚父 {e.ToString()}");
+ }
+ return null;
+ }
public List<ProductModel> GetProductList(string plcnum)
{
@@ -443,8 +470,6 @@
return null;
}
-
-
public DataTable getBasketCode()
{
try
@@ -469,7 +494,6 @@
}
-
public void NewBasketcode(string code)
{
--
Gitblit v1.8.0