kingno
2025-06-09 305e2990bb2161177e87ab7711f9dfb205762bcd
src/Bro.M141.Process/M141Process_Mysql.cs
@@ -145,7 +145,6 @@
        {
            try
            {
                Thread.Sleep(200);
                if (pro.Details != null)
                {
                    foreach (var item in pro.Details)
@@ -153,7 +152,9 @@
                        if (item != null)
                        {
                            var defects = item.ResultList.GetDefectDescList();
                            item.DefectList.AddRange(defects);
                            var ngSpecCodes = item.SpecList.Where(u => u.MeasureResult != true).Select(u => u.Code);
                            defects.AddRange(ngSpecCodes);
                            item.DefectList.AddRange(defects.Distinct());
                        }
                    }
                }
@@ -168,7 +169,7 @@
                //CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"{jsondata}");
                string mysqlstr = $"update forlocal set data='{jsondata}' where plcnum='{pro.SEQUENCE}'";
                string mysqlstr = $"update forlocal set data='{jsondata}',pid='{pro.PID}' where plcnum='{pro.SEQUENCE}'";
                if (Operatoremysql(mysqlstr, connStrLocal))
                {
@@ -195,8 +196,42 @@
                    //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 (pro.Details != null)
                    {
                        foreach (var item in pro.Details)
                        {
                            if (item != null)
                            {
                                var defects = item.ResultList.GetDefectDescList();
                                var ngSpecCodes = item.SpecList.Where(u => u.MeasureResult != true).Select(u => u.Code);
                                defects.AddRange(ngSpecCodes);
                                item.DefectList.AddRange(defects.Distinct());
                                item.DefectList = item.DefectList.Distinct().ToList();
                            }
                        }
                    }
                    string strtem = "select * from forall  where plcnum='" + pro.SEQUENCE + "' and device='" + devicestr + "' ";
                    var temdb = selectdt(strtem, connStrAll);
                    if (temdb != null && temdb.Rows.Count > 0)
                    {
                        string mysqlstr = $"update forall set data='" + JsonConvert.SerializeObject(pro, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }) + "' where plcnum='" + pro.SEQUENCE + "' and device='" + devicestr + "' ";
                        if (Operatoremysql(mysqlstr, connStrAll))
                        {
                            CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"数据库forall更新数据成功");
                        }
                        else
                        {
                            CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"数据库forall更新数据异常  {mysqlstr}");
                        }
                    }
                    else
                    {
                    string str1 = "select id from forall  order by id desc limit 1";
                    string index = selectmysql(str1, connStrAll);
                    if (!string.IsNullOrEmpty(index))
                    {
                        string str2 = $"delete from forall where id < ({index}-1000)";
@@ -213,6 +248,7 @@
                    {
                        CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"数据库forall插入数据异失败  {mysqlstr}");
                    }
                    }
                }
                catch (Exception e)