| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using Windows.Globalization.PhoneNumberFormatting; |
| | | using Windows.Media.Ocr; |
| | | using static Org.BouncyCastle.Math.EC.ECCurve; |
| | | using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView; |
| | | |
| | |
| | | |
| | | 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 基础操作 |
| | |
| | | { |
| | | try |
| | | { |
| | | if (pro.Details!=null) |
| | | Thread.Sleep(200); |
| | | if (pro.Details != null) |
| | | { |
| | | foreach (var item in pro.Details) |
| | | { |
| | | if (item.ResultList!=null) |
| | | if (item != null) |
| | | { |
| | | item.ResultList.ForEach(u => |
| | | { |
| | | if (u.NetResults != null) |
| | | { |
| | | u.NetResults.ForEach(x => |
| | | { |
| | | if (x.DetectDetails != null) |
| | | { |
| | | var distinctItems = x.DetectDetails.GroupBy(i => new { i.ClassName, i.FinalResult }) // 根据Id和Name去重 |
| | | .Select(g => g.First()) // 选择每个组的第一个元素 |
| | | .ToList(); |
| | | x.DetectDetails = distinctItems; |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | var defects = item.ResultList.GetDefectDescList(); |
| | | item.DefectList.AddRange(defects); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | JsonSerializerSettings settings = new JsonSerializerSettings |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | |
| | | //保留数据库最新的1000条数据 |
| | | //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); |
| | |
| | | string str2 = $"delete from forall where id < ({index}-1000)"; |
| | | 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")}')"; |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | public string Getbasketcode(string plcnum) |
| | | public string Getbasketcode(string plcnum, out string sn) |
| | | { |
| | | sn = "Noread"; |
| | | try |
| | | { |
| | | string mysqlstr = $"select basketcode from forall where plcnum='{plcnum}' && device='S2' order by id desc limit 1"; |
| | | string str = selectmysql(mysqlstr, connStrAll); |
| | | if (!string.IsNullOrEmpty(str)) |
| | | string mysqlstr = $"select basketcode,sn 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) |
| | | { |
| | | return str; |
| | | return "Noread"; |
| | | } |
| | | else |
| | | { |
| | | sn = dt.Rows[0][1].ToString(); |
| | | return dt.Rows[0][0].ToString(); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | //CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"数据库forlocal获取异常 {e.ToString()}"); |
| | | |
| | | } |
| | | return "NoRead"; |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | string mysqlstr = $"select data from forall where plcnum='{plcnum}'"; |
| | | string mysqlstr = $"select data from forall where plcnum='{plcnum}' order by device"; |
| | | var dt = selectdt(mysqlstr, connStrAll); |
| | | if (dt == null) |
| | | { |