| | |
| | | { |
| | | try |
| | | { |
| | | Thread.Sleep(200); |
| | | if (pro.Details != null) |
| | | { |
| | | foreach (var item in pro.Details) |
| | |
| | | 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()); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | //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)) |
| | | { |
| | |
| | | //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 str1 = "select id from forall order by id desc limit 1"; |
| | | string index = selectmysql(str1, connStrAll); |
| | | if (!string.IsNullOrEmpty(index)) |
| | | if (pro.Details != null) |
| | | { |
| | | string str2 = $"delete from forall where id < ({index}-1000)"; |
| | | Operatoremysql(str2, connStrAll); |
| | | 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 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 strtem = "select * from forall where plcnum='" + pro.SEQUENCE + "' and device='" + devicestr + "' "; |
| | | |
| | | if (Operatoremysql(mysqlstr, connStrAll)) |
| | | var temdb = selectdt(strtem, connStrAll); |
| | | if (temdb != null && temdb.Rows.Count > 0) |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"数据库forall插入数据成功"); |
| | | 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 |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"数据库forall插入数据异失败 {mysqlstr}"); |
| | | 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)"; |
| | | 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")}')"; |
| | | |
| | | if (Operatoremysql(mysqlstr, connStrAll)) |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"数据库forall插入数据成功"); |
| | | } |
| | | else |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"数据库forall插入数据异失败 {mysqlstr}"); |
| | | } |
| | | } |
| | | |
| | | } |