| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.BLL.Important; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | |
| | | // plcService.Close(); |
| | | // plcService.OpenService(); |
| | | //} |
| | | |
| | | string lastHandlerWorkPileIDForOP0501 = "";//最后一次处理的工件号 |
| | | |
| | | while (true) |
| | | { |
| | |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), |
| | | $"{_dataCaptureConfig.WorkingProcedure}工序读取工控机中二维码信息,工件最新时间:{(cache == null ? "无缓存" : cache.ToString())}"); |
| | | for (int i = dt.Rows.Count - 1; i >= 0; i--) |
| | | { |
| | | {//降序,即优先读取最后一条数据 |
| | | string timeValue = " "; |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | var oldTime = DateTime.Now.AddMinutes(-10); |
| | | if (currrentTime <= oldTime) |
| | | { |
| | | // if (currrentTime <= oldTime) |
| | | if (lastHandlerWorkPileIDForOP0501 == Convert.ToString(dt.Rows[i]["打标内容"])) |
| | | {//如果excel里的时间要比 当前前10分钟时间要早,那么我就忽略不处理。 |
| | | break; |
| | | } |
| | | filteredRows[j] = dt.Rows[i]; |
| | |
| | | else |
| | | { |
| | | var cacheTime = Convert.ToDateTime(cache); |
| | | if (currrentTime <= cacheTime) |
| | | { |
| | | //if (currrentTime <= cacheTime) |
| | | if (lastHandlerWorkPileIDForOP0501 == Convert.ToString(dt.Rows[i]["打标内容"])) |
| | | {//如果excel里的时间要比 我缓存中的时间要早,那么我就忽略不处理。 |
| | | break; |
| | | } |
| | | filteredRows[j] = dt.Rows[i]; |
| | |
| | | wplog.OnlineTime = DateTimeHelper.GetDateTime();//给上线时间用 |
| | | |
| | | //wplog.QualityState = 1; |
| | | wplog.QualityState = (int)QualityState.OK;//默认合格,OP05默认合格 |
| | | wplog.QualityState = (int)QualityStateEnum.OK;//默认合格,OP05默认合格 |
| | | |
| | | wplog.ProcessingDuration = 1; |
| | | wplog.MachineToolState = 1; |
| | |
| | | wplog.KnifeToolEarlyWarningLife = 3; |
| | | wplog.KnifeToolSurplusLife = 10; |
| | | |
| | | //快速处理 |
| | | List<WorkPieceLog> wplogs = new List<WorkPieceLog>(); |
| | | |
| | | foreach (var item in filteredRows) |
| | | { |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), |
| | | $"{_dataCaptureConfig.WorkingProcedure}工序读取工控机中二维码信息,读取工件二维码:{item["打标内容"].ToString()}"); |
| | | |
| | | if (item == null) break; |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.WorkPieceID = item["打标内容"].ToString(); |
| | | wplog.OfflineTime = Convert.ToDateTime(dataTime); |
| | | wplog.Remarks = item["时间"].ToString() + "|" + item["打标内容"].ToString() + "|" + item["打标内容"].ToString() + "|" + item["扫码等级"].ToString() + "|" + item["扫码结果"].ToString(); |
| | | WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), null, _dataCaptureConfig.IsFeedback); |
| | | //转换 |
| | | WorkPieceLog newLog = EntityPropHelper.Mapper<WorkPieceLog, WorkPieceLog>(wplog); |
| | | wplogs.Add(newLog); |
| | | } |
| | | //查询数据,过滤 |
| | | var queryList = wplogs.Select(x => x.WorkPieceID).ToList(); |
| | | List<WorkPieceProcess> new_exist_WorkPieceProcess = new List<WorkPieceProcess>(); |
| | | using (DbModel db = new DbModel()) |
| | | { |
| | | //找到数据库中已有这个工序的数据 |
| | | new_exist_WorkPieceProcess = db.WorkPieceProcess.Where(o => queryList.Contains(o.WorkPieceID) |
| | | && o.WorkingProcedureCurrent == _dataCaptureConfig.WorkingProcedure).ToList(); |
| | | } |
| | | var querynew__exist_WorkPieceProcessList = new_exist_WorkPieceProcess.Select(x => x.WorkPieceID).ToList(); |
| | | //找到需要新增的数据 |
| | | wplogs = wplogs.Where(x => !querynew__exist_WorkPieceProcessList.Contains(x.WorkPieceID)).ToList(); |
| | | foreach (var item in wplogs) |
| | | { |
| | | Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), |
| | | $"{_dataCaptureConfig.WorkingProcedure}工序读取工控机中二维码信息,读取工件二维码:{item.WorkPieceID.ToString()}"); |
| | | |
| | | ReadQRcodeManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), null, _dataCaptureConfig.IsFeedback); |
| | | |
| | | threadStatusMonitor.Threadstatue = 1; |
| | | } |
| | | |
| | | |
| | | //记录下最后一个码 |
| | | lastHandlerWorkPileIDForOP0501 = Convert.ToString(dt.Rows[dt.Rows.Count - 1]["打标内容"]); |
| | | } |
| | | } |
| | | |