quanzhou
2 天以前 86f899fa91e811415614dff1a699141144bfc802
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);
                }
@@ -244,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()
@@ -286,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))
                        {
@@ -334,7 +331,6 @@
            return null;
        }
        public List<Netdefectdetail> GetNetdefectdetails(string plcnum)
        {
            try
@@ -373,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)
@@ -384,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)
                {
@@ -399,6 +395,7 @@
                else
                {
                    sn = dt.Rows[0][1].ToString();
                    zword = dt.Rows[0][2].ToString();
                    return dt.Rows[0][0].ToString();
                }
            }
@@ -409,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, $"数据库forall数据异常 {e.ToString()}");
            }
            return null;
        }
        public List<ProductModel> GetProductList(string plcnum)
        {
@@ -442,8 +470,6 @@
            return null;
        }
        public DataTable getBasketCode()
        {
            try
@@ -468,7 +494,6 @@
        }
        public void NewBasketcode(string code)
        {