| | |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare.Wms.Core; |
| | | using iWare_SCADA_BusinessLogical.BLL; |
| | | using iWare_SCADA_BusinessLogical.Utils; |
| | | using iWare_SCADA_Model; |
| | | using System; |
| | |
| | | Object QualityState = null; |
| | | Object CheckUpdate = null; |
| | | Object QualityErrorInfo = null; |
| | | Object WorkingProcedureInt=null; |
| | | Object WorkingProcedureInt = null; |
| | | string WorkingProcedureCurrent = ""; |
| | | int UpdateIsOK = 0; |
| | | |
| | |
| | | case "CheckUpdate": |
| | | CheckUpdate = plcService.ReadValuePoint(col.DbNumber, col.Offset, col.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | |
| | | if((bool)CheckUpdate) |
| | | if ((bool)CheckUpdate) |
| | | { |
| | | var check = plcService.WriteValuePointNew(col.DbNumber, col.Offset, false); |
| | | } |
| | | } |
| | | //plcService.WriteValuePoint(col.DbNumber, col.Offset, 0, PLCManger.GetTypeForString(col.DataCaptureColumnType)); |
| | | break; |
| | | case "QualityErrorInfo": |
| | |
| | | StringBuilder builder = new StringBuilder(); |
| | | if (WorkPieceID != null) |
| | | { |
| | | if (WorkPieceID.ToString().Trim().Length==0) |
| | | if (WorkPieceID.ToString().Trim().Length == 0) |
| | | { |
| | | builder.AppendLine("工件二维码值:【" + WorkPieceID.ToString().Trim() + "】长度异常,长度不等于22位!"); |
| | | } |
| | |
| | | { |
| | | builder.AppendLine("工件工序:【" + WorkingProcedureInt + "】长度异常,不在约定枚举范围内!"); |
| | | } |
| | | |
| | | |
| | | |
| | | if (QualityState == null) |
| | | { |
| | |
| | | } |
| | | else if ((int)QualityState == 2 || (int)QualityState == 3) |
| | | { |
| | | if (QualityErrorInfo == null|| string.IsNullOrEmpty(QualityErrorInfo.ToString())) |
| | | if (QualityErrorInfo == null || string.IsNullOrEmpty(QualityErrorInfo.ToString())) |
| | | { |
| | | builder.AppendLine("工件二维码值:【" + WorkPieceID + "】质量不合格原因不能为空"); |
| | | } |
| | |
| | | using (DbModel db = new DbModel()) |
| | | { |
| | | info = new WorkPieceInfo(); |
| | | info = db.WorkPieceInfo.Where(o => o.WorkPieceID == WorkPieceID.ToString()&&o.IsDeleted==false).FirstOrDefault(); |
| | | info = db.WorkPieceInfo.Where(o => o.WorkPieceID == WorkPieceID.ToString() && o.IsDeleted == false).FirstOrDefault(); |
| | | |
| | | if (info == null) |
| | | { |
| | |
| | | continue; |
| | | } |
| | | |
| | | QualityStateEnum qualityStateEnum = (QualityStateEnum)Enum.Parse(typeof(QualityStateEnum), QualityState.ToString()); |
| | | |
| | | info.QualityState = Convert.ToInt32(QualityState); |
| | | if (qualityStateEnum == QualityStateEnum.OK) |
| | | { |
| | | info.QualityNoOk = 0;//清理不合格原因 【Editby shaocx,2024-12-19】 |
| | | info.QualityNoOkReason = ""; |
| | | } |
| | | info.QualityStateUpdateUser = "HMI"; |
| | | info.QualityStateUpdateTime = DateTime.Now; |
| | | info.QualityStateUpdateMode = Environment.MachineName+"自动"; |
| | | info.QualityStateUpdateMode = Environment.MachineName + "自动"; |
| | | info.QualityErrorInfo = QualityErrorInfo.ToString(); |
| | | if(!info.WorkingProcedureCurrent.Equals(WorkingProcedureCurrent)) |
| | | if (!info.WorkingProcedureCurrent.Equals(WorkingProcedureCurrent)) |
| | | { |
| | | info.Remarks = (info.Remarks ?? "" + $"HMI修改工序{info.WorkingProcedureCurrent}到{WorkingProcedureCurrent}"); |
| | | info.Remarks = ($"HMI修改工序{info.WorkingProcedureCurrent}到{WorkingProcedureCurrent}"); |
| | | info.WorkingProcedureCurrent = WorkingProcedureCurrent; |
| | | info.WorkingProcedureCurrent = WorkingProcedureCurrent; |
| | | } |
| | |
| | | |
| | | wplog = EntityPropHelper.Mapper<WorkPieceLog, WorkPieceInfo>(info); |
| | | wplog.Id = Yitter.IdGenerator.YitIdHelper.NextId(); |
| | | wplog.Remarks = "HMI更新工件质量信息"; |
| | | wplog.OnlineTime =info.WorkPieceinitOnlineTime; |
| | | |
| | | |
| | | //1:合格 2:不合格 3:疑似" |
| | | |
| | | wplog.Remarks = $"HMI更新工件质量信息,修改为[{qualityStateEnum.ToString()}]"; |
| | | wplog.PieceLogType = (int)PieceLogTypeEnum.HMI修改质量状态; |
| | | wplog.PieceLogTypeName = PieceLogTypeEnum.HMI修改质量状态.ToString(); |
| | | wplog.OnlineTime = info.WorkPieceinitOnlineTime; |
| | | |
| | | if (qualityStateEnum == QualityStateEnum.OK) |
| | | { |
| | | wplog.QualityNoOk = 0;//清理不合格原因 【Editby shaocx,2024-12-19】 |
| | | wplog.QualityNoOkReason = ""; |
| | | } |
| | | |
| | | db.WorkPieceLog.Add(wplog); |
| | | db.WorkPieceInfoLog.Add (WorkPieceInfoManager.GetAddWorkPieceInfoLog(info)); |
| | | db.WorkPieceInfoLog.Add(WorkPieceInfoManager.GetAddWorkPieceInfoLog(info)); |
| | | db.SaveChanges(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | if (!_dataCaptureConfig.DataCaptureFrequency.HasValue || _dataCaptureConfig.DataCaptureFrequency < 10) |
| | | { |
| | | Thread.Sleep(5000); |