From 05f2a20bb792169bf7b8a101af8718b96449f55a Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周五, 06 9月 2024 16:11:33 +0800 Subject: [PATCH] 整理代码 --- DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_04.cs | 13 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_06.cs | 3 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2004.cs | 7 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2006.cs | 3 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1004.cs | 7 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1002.cs | 3 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP7009.cs | 3 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_02.cs | 3 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/WorkingProcedureCompleteManager.cs | 272 ++++++ DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2003.cs | 3 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_03.cs | 11 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/ReadQRcodeManager.cs | 276 ++++++ DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2001.cs | 3 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_05.cs | 3 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2005.cs | 3 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP0506.cs | 3 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1003.cs | 3 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_OP0501.cs | 5 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/QualityInfoCompleteManager.cs | 444 ++++++++++ DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Test/UnitTest1.cs | 3 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/WorkPieceInfoManager.cs | 1216 --------------------------- DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/WorkPieceSPCPushOffManager.cs | 132 +++ DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_01.cs | 3 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/WorkPiecePushOffManager.cs | 159 +++ DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj | 5 25 files changed, 1,343 insertions(+), 1,243 deletions(-) diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/QualityInfoCompleteManager.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/QualityInfoCompleteManager.cs new file mode 100644 index 0000000..7ee69c9 --- /dev/null +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/QualityInfoCompleteManager.cs @@ -0,0 +1,444 @@ +锘縰sing iWare_SCADA_BusinessLogical.Utils; +using iWare_SCADA_Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace iWare_SCADA_BusinessLogical.BLL.Important +{ + public class QualityInfoCompleteManager + { + /// <summary> + /// 璐ㄩ噺妫�娴嬪畬鎴� + /// </summary> + /// <param name="logMiddle"></param> + /// <param name="type"></param> + public static void QualityInfoComplete(WorkPieceLogMiddle logMiddle, LogType type) + { + //鏍规嵁璐ㄩ噺鏁版嵁鍒ゆ柇鏄惁鍚堟牸/涓嶅悎鏍� 銆怑ditby shaocx,2024-06-25銆� + WorkPieceInfoManager.SetLogMiddleForQuality(ref logMiddle); + + //姝ゅ鍚屾椂鎻掑叆浜哤orkPieceLog锛學orkPieceInfoLog琛紝骞舵柊澧炴垨淇敼WorkPieceInfo琛� + //鎻掑叆璐ㄩ噺鐩稿叧琛≦ualityDataInfo + + using (DbModel db = new DbModel()) + { + + bool isAddWorkPieceInfo = false; + WorkPieceLog loginfo2 = new WorkPieceLog(); + loginfo2 = EntityPropHelper.Mapper<WorkPieceLog, WorkPieceLogMiddle>(logMiddle); + try + { + + if (logMiddle.WorkPieceID.Length == 22) + {//鑾峰彇鍒扮殑宸ヤ欢鍙峰紓甯� + WorkPieceInfo pieceInfo = new WorkPieceInfo(); + pieceInfo = db.WorkPieceInfo.Where(o => o.WorkPieceID == logMiddle.WorkPieceID).FirstOrDefault(); + if (pieceInfo == null || pieceInfo.WorkPieceID.Length < 1) + {//娌℃湁宸ヤ欢淇℃伅锛屼笉鍋氭洿鏂� + if (logMiddle.MonitoringPoint.Equals("OP1002") || logMiddle.MonitoringPoint.Equals("OP1003") || logMiddle.MonitoringPoint.Contains("OP2002")) + {//OP10 娌℃湁涓婄嚎鎵爜鏋紝绾﹀畾鐢ㄦ祴閲忓畬鎴愪俊鍙峰綋涓婄嚎鏍囪 + pieceInfo = EntityPropHelper.Mapper<WorkPieceInfo, WorkPieceLogMiddle>(logMiddle); + //EntityPropHelper<WorkPieceLog, WorkPieceInfo>.CopyProp(loginfo, info, loginfo.GetWorkPieceInfoDict()); + if (!logMiddle.WorkingProcedure.Equals("OP05")) + {//褰撳伐浠朵簩缁寸爜绗竴娆″嚭鐜扮殑宸ュ簭涓嶆槸OP05锛屽垯璁剧疆涓哄彲鐤戠姸鎬� + pieceInfo.QualityState = (int)QualityStateEnum.Suspected; + pieceInfo.QualityErrorInfo = $"宸ヤ欢浜岀淮鐮佺涓�娆″嚭鐜扮殑宸ュ簭{logMiddle.MonitoringPoint}涓嶆槸OP05,鏁版嵁缂哄け,璇风‘璁ゆ儏鍐靛苟鍋氱浉搴斿鐞嗭紒"; + pieceInfo.Remarks = $"宸ヤ欢浜岀淮鐮佺涓�娆″嚭鐜扮殑宸ュ簭{logMiddle.WorkingProcedure}涓嶆槸OP05,鏁版嵁缂哄け,璇风‘璁ゆ儏鍐靛苟鍋氱浉搴斿鐞嗭紒"; + } + else + { + pieceInfo.QualityState = (int)QualityStateEnum.OK;//姝ゅ闇�瑕佹敞鎰忥紝鍒ゆ柇鎵�鏈夊伐搴忚川閲忥紝鐒跺悗鍐嶈祴鍊� //榛樿鍚堟牸锛孫P05榛樿鏄悎鏍� + pieceInfo.Remarks = "OP05鏂板宸ヤ欢淇℃伅"; + } + pieceInfo.WorkPieceinitOnlineTime = DateTimeHelper.GetDateTime(); + pieceInfo.WorkingProcedurePlan = ConfigHelper.GetConfigString("WorkingProcedureAllStr") ?? "OP05OP10OP20OP30OP35OP40OP50OP60OP70OP80"; + pieceInfo.CreatedUserName = WorkPieceInfoManager.ResetUpdatedUserName(logMiddle); + SystemBussinessHelper.SetWorkPieceInfoMiddleForCreatedUserName(ref pieceInfo, logMiddle.DataCapturePointCname); + pieceInfo.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + pieceInfo.WorkingProcedureStartTime = DateTimeHelper.GetDateTime();// + pieceInfo.WorkingProcedureEndTime = null; + pieceInfo = WorkPieceInfoManager.ParseQRCode(pieceInfo); + isAddWorkPieceInfo = true; + + + } + else + { + loginfo2.Remarks = $"|宸ヤ欢{logMiddle.WorkPieceID} 璐ㄩ噺妫�娴嬪畬鎴愬伐搴弡logMiddle.MonitoringPoint} 娌℃湁鑾峰彇鍒板伐浠朵俊鎭笉鍋氭洿鏂�"; + Log4NetHelper.WriteErrorLog(type, $"宸ヤ欢{logMiddle.WorkPieceID} 璐ㄩ噺妫�娴嬪畬鎴愬伐搴弡logMiddle.MonitoringPoint} 娌℃湁鑾峰彇鍒板伐浠朵俊鎭笉鍋氭洿鏂�"); + return; + } + } + if (logMiddle.MonitoringPoint.Equals("OP1002") || logMiddle.MonitoringPoint.Equals("OP1003") || logMiddle.MonitoringPoint.Contains("OP2002")) + {// OP10 娌℃湁涓婄嚎鎵爜鏋紝绾﹀畾鐢ㄦ祴閲忓畬鎴愪俊鍙峰綋涓婄嚎鏍囪锛屾墍浠ヤ笂绾块渶瑕佷慨鏀圭殑瀛楁鏀捐繖閲� + + if (logMiddle.WorkingProcedure.Equals("OP10")) + { + var WorkingProcedure = (logMiddle.MonitoringPoint.Equals("OP1002") ? "OP10" : "OP40"); + loginfo2.WorkingProcedure = WorkingProcedure;//瑙e喅OP10锛孫P40鍚屼竴涓殑闂 + logMiddle.WorkingProcedure = WorkingProcedure;//瑙e喅OP10锛孫P40鍚屼竴涓殑闂 + } + pieceInfo.WorkPieceCurrentPosition = logMiddle.WorkingProcedure; + pieceInfo.WorkPieceCurrentPositionOrder = pieceInfo.WorkingProcedurePlan.IndexOf(logMiddle.WorkingProcedure) / 2; + pieceInfo.WorkingProcedureCurrent = logMiddle.WorkingProcedure; + pieceInfo.WorkingProcedureStartTime = DateTimeHelper.GetDateTime(); + + #region 鏇存柊璁惧瀹炴椂琛� + + bool isAddEquipmentCurrentMonitor = false; + EquipmentCurrentMonitor equinfo = new EquipmentCurrentMonitor(); + equinfo = db.EquipmentCurrentMonitor.Where(o => o.EquipmentID == logMiddle.EquipmentID).FirstOrDefault(); + if (equinfo == null || equinfo.Id < 1) + {//娌℃湁宸ヤ欢淇℃伅锛屼笉鍋氭洿鏂� + Log4NetHelper.WriteErrorLog(type, $"璁惧{logMiddle.EquipmentID} 鍛婅鐩戞帶{logMiddle.WorkingProcedure} 娌℃湁鑾峰彇鍒拌澶囩洃鎺т俊鎭紝鐜版柊澧�"); + equinfo = EntityPropHelper.Mapper<EquipmentCurrentMonitor, WorkPieceLog>(logMiddle); + equinfo.OnlineTime = DateTime.Now; + isAddEquipmentCurrentMonitor = true; + } + else + {//鏇存柊宸ヤ欢 + equinfo.WorkPieceID = logMiddle.WorkPieceID; + equinfo.UpdatedUserName = WorkPieceInfoManager.ResetUpdatedUserName(logMiddle); + equinfo.UpdatedTime = DateTime.Now; + equinfo.OnlineTime = DateTime.Now; + } + if (isAddEquipmentCurrentMonitor) + { + equinfo.Id = Yitter.IdGenerator.YitIdHelper.NextId(); + db.EquipmentCurrentMonitor.Add(equinfo); + } + #endregion + //UpdateKnifeToolLift(db, loginfo);//鏇存柊鍒�鍏峰鍛戒俊鎭� + } + + pieceInfo.WorkingProcedureCurrent = logMiddle.WorkingProcedure;//鏇存柊褰撳墠宸ュ簭 銆怑ditby shaocx,2024-09-03銆� + pieceInfo.WorkPieceState = (int)WorkPieceState.WIP;//鎺ㄥ嚭鍚庡拰SPC鎶芥鍚� 璐ㄩ噺褰曞叆鏃剁姸鎬佷慨鏀瑰洖鍦ㄥ埗鍝� + pieceInfo.EquipmentID = logMiddle.EquipmentID; + pieceInfo.QualityStateUpdateUser = logMiddle.UpdatedUserName; + pieceInfo.QualityStateUpdateTime = logMiddle.UpdatedTime.Value.LocalDateTime; + pieceInfo.QualityStateUpdateMode = QualityStateUpdateMode.Auto.ToString(); + pieceInfo.Remarks = $"{logMiddle.WorkingProcedure}璐ㄩ噺妫�娴嬪畬鎴愪慨鏀�"; + pieceInfo.UpdatedUserName = WorkPieceInfoManager.ResetUpdatedUserName(logMiddle); + SystemBussinessHelper.SetWorkPieceInfoMiddleForUpdateDataCapturePointCname(ref pieceInfo, logMiddle.DataCapturePointCname); + pieceInfo.UpdatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + if (!(pieceInfo.WorkingProcedureStartTime.HasValue && pieceInfo.WorkingProcedureStartTime > DateTime.Parse("1900/01/01"))) + {//宸ュ簭寮�濮嬫椂闂存病鏈夊垯璧嬪�� + pieceInfo.WorkingProcedureStartTime = DateTimeHelper.GetDateTime(); + } + pieceInfo.QualityState = (int)((logMiddle.QualityStateStr.Equals("OK") || logMiddle.QualityStateStr.Equals("0K")) ? QualityStateEnum.OK : QualityStateEnum.NG); + //璧嬪�间笉鍚堟牸鍘熷洜 + WorkPieceInfoManager.SetQualityNoOk_WorkPieceInfo(logMiddle, ref pieceInfo); + + + if (!pieceInfo.QualityState.Equals(((int)QualityStateEnum.OK).ToString())) + { + pieceInfo.QualityErrorInfo = $"{logMiddle.WorkingProcedure}宸ュ簭璐ㄩ噺閲囬泦鏁版嵁涓嶅悎鏍納pieceInfo.QualityState}"; + } + else + { + pieceInfo.QualityErrorInfo = ""; + } + logMiddle.QualityState = pieceInfo.QualityState; + if (isAddWorkPieceInfo) + { + db.WorkPieceInfo.Add(pieceInfo); + } + + #region 鏍规嵁鏍囧噯鍊兼洿鏂版渶鏂拌川閲忔暟鎹紙OP10/OP40/OP20/OP60锛� + var qcofig = db.EquipmentQualityConfig.Where(o => o.WorkingProcedure.Equals(logMiddle.WorkingProcedure) && o.ParamType != 1 && o.IsDeleted == false).ToList(); + if (qcofig.Count > 0) + { + WorkPieceInfoManager.QualityDataHand(logMiddle, qcofig); + } + #endregion + + + var qualityData = db.QualityDataInfo.Where(o => o.WorkPieceID == logMiddle.WorkPieceID).FirstOrDefault(); + if (qualityData == null || qualityData.WorkPieceID.Length < 1 || qualityData.WorkingProcedure.Length < 1) + {//鎻掑叆QualityDataInfo琛� + qualityData = EntityPropHelper.Mapper<QualityDataInfo, WorkPieceLog>(logMiddle); + db.QualityDataInfo.Add(WorkPieceInfoManager.GetAddQualityDataInfo(qualityData)); + } + //淇敼QualityDataInfo琛� //閲嶅鏀跺埌璐ㄩ噺淇℃伅锛屼細瑕嗙洊涔嬪墠鐨� + EntityPropHelper<WorkPieceLogMiddle, QualityDataInfo>.CopyProp(logMiddle, qualityData, WorkPieceInfoManager.GetQualityDataInfoUpdate(logMiddle, logMiddle.WorkingProcedure, logMiddle.MonitoringPoint));//鎸囧畾淇敼瀛楁 + + qualityData.QualityStateUpdateUser = pieceInfo.UpdatedUserName; + qualityData.QualityReceiveTime = pieceInfo.UpdatedTime.Value.LocalDateTime; + qualityData.QualityStateUpdateMode = pieceInfo.QualityStateUpdateMode; + if (logMiddle.WorkingProcedure.Equals("OP10")) + { + qualityData.OP10QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; + qualityData.OP10QualityReceiveTime = DateTimeHelper.GetDateTime(); + } + else if (logMiddle.WorkingProcedure.Equals("OP20")) + { + //Log4NetHelper.WriteErrorLog(type, $" {loginfo.WorkingProcedure}璐ㄩ噺淇℃伅銆恵loginfo.QualityStateStr ?? "绌�"}銆�" + + // $"銆恵(loginfo.QualityState.HasValue? loginfo.QualityState.Value:999)}銆戙�恵(info.QualityState.HasValue ? info.QualityState.Value : 888)}銆� 璇诲彇宸ヤ欢鐮佹暟鎹甗{loginfo.WorkPieceID ?? "绌�"}]"); + qualityData.OP20QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; + qualityData.OP20QualityReceiveTime = DateTimeHelper.GetDateTime(); + qualityData.OP20QualityFilePath = logMiddle.OP20QualityFilePath; + } + else if (logMiddle.WorkingProcedure.Equals("OP30")) + { + switch (logMiddle.MonitoringPoint) + { + case "OP3002CH3": + qualityData.OP30QualityFilePathCH3 = logMiddle.OP30QualityFilePathCH3; + qualityData.OP30QualityStateCH3 = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; + qualityData.OP30QualityReceiveTimeCH3 = DateTimeHelper.GetDateTime(); + + if (qualityData.OP30QualityStateCH3 == ((int)QualityStateEnum.NG).ToString()) + { + logMiddle.QualityNoOk = (int)QualityNoOkEnum.OP30娑ㄦ柇宸ヤ綅鍔涚煩瓒呭樊; + logMiddle.QualityNoOkReason = QualityNoOkEnum.OP30娑ㄦ柇宸ヤ綅鍔涚煩瓒呭樊.ToString(); + //璧嬪�间笉鍚堟牸鍘熷洜 + WorkPieceInfoManager.SetQualityNoOk_WorkPieceInfo(logMiddle, ref pieceInfo); + } + + break; + case "OP3002CH4": + qualityData.OP30QualityFilePathCH4 = logMiddle.OP30QualityFilePathCH4; + qualityData.OP30QualityStateCH4 = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; + qualityData.OP30QualityReceiveTimeCH4 = DateTimeHelper.GetDateTime(); + + if (qualityData.OP30QualityStateCH4 == ((int)QualityStateEnum.NG).ToString()) + { + logMiddle.QualityNoOk = (int)QualityNoOkEnum.OP30棰勬嫥绱у伐浣嶅姏鐭╄秴宸�; + logMiddle.QualityNoOkReason = QualityNoOkEnum.OP30棰勬嫥绱у伐浣嶅姏鐭╄秴宸�.ToString(); + //璧嬪�间笉鍚堟牸鍘熷洜 + WorkPieceInfoManager.SetQualityNoOk_WorkPieceInfo(logMiddle, ref pieceInfo); + } + + break; + case "OP3002CH5": + qualityData.OP30QualityFilePathCH5 = logMiddle.OP30QualityFilePathCH5; + qualityData.OP30QualityStateCH5 = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; + qualityData.OP30QualityReceiveTimeCH5 = DateTimeHelper.GetDateTime(); + + if (qualityData.OP30QualityStateCH5 == ((int)QualityStateEnum.NG).ToString()) + { + logMiddle.QualityNoOk = (int)QualityNoOkEnum.OP30缁堟嫥绱у伐浣嶅姏鐭╄秴宸�; + logMiddle.QualityNoOkReason = QualityNoOkEnum.OP30缁堟嫥绱у伐浣嶅姏鐭╄秴宸�.ToString(); + //璧嬪�间笉鍚堟牸鍘熷洜 + WorkPieceInfoManager.SetQualityNoOk_WorkPieceInfo(logMiddle, ref pieceInfo); + } + + break; + case "OP3002CH6": + qualityData.OP30QualityFilePathCH6 = logMiddle.OP30QualityFilePathCH6; + qualityData.OP30QualityStateCH6 = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; + qualityData.OP30QualityReceiveTimeCH6 = DateTimeHelper.GetDateTime(); + + if (qualityData.OP30QualityStateCH6 == ((int)QualityStateEnum.NG).ToString()) + { + logMiddle.QualityNoOk = (int)QualityNoOkEnum.OP30鍘嬭‖濂楀伐浣嶅姏鐭╄秴宸�; + logMiddle.QualityNoOkReason = QualityNoOkEnum.OP30鍘嬭‖濂楀伐浣嶅姏鐭╄秴宸�.ToString(); + //璧嬪�间笉鍚堟牸鍘熷洜 + WorkPieceInfoManager.SetQualityNoOk_WorkPieceInfo(logMiddle, ref pieceInfo); + } + + break; + default: + break; + } + //qualityData.OP30QualityState = loginfo.QualityState.HasValue ? loginfo.QualityState.Value.ToString() : "3"; + //qualityData.OP30QualityReceiveTime = DateTimeHelper.GetDateTime(); + } + else if (logMiddle.WorkingProcedure.Equals("OP35")) + { + qualityData.OP35QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; + qualityData.OP35QualityReceiveTime = DateTimeHelper.GetDateTime(); + } + else if (logMiddle.WorkingProcedure.Equals("OP40")) + { + qualityData.OP40QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; + qualityData.OP40QualityReceiveTime = DateTimeHelper.GetDateTime(); + } + else if (logMiddle.WorkingProcedure.Equals("OP60")) + { + qualityData.OP60QualityFilePath = logMiddle.OP60QualityFilePath; + qualityData.OP60QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; + qualityData.OP60QualityReceiveTime = DateTimeHelper.GetDateTime(); + } + else if (logMiddle.WorkingProcedure.Equals("OP80")) + { + qualityData.OP80QualityFilePath = logMiddle.OP80QualityFilePath; + qualityData.OP80QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; + qualityData.OP80QualityReceiveTime = DateTimeHelper.GetDateTime(); + } + + var pro = db.WorkPieceProcess.Where(o => o.WorkPieceID == logMiddle.WorkPieceID + //淇锛氭煡璇㈢殑宸ュ簭鏄綋鍓嶇嚎绋嬬殑宸ュ簭锛岃�屼笉鏄綋鍓嶆暟鎹殑宸ュ簭 銆怑ditby shaocx,2024-09-03銆� + //&& o.WorkingProcedureCurrent == pieceInfo.WorkingProcedureCurrent + && o.WorkingProcedureCurrent == logMiddle.WorkingProcedure + && o.OperationType == OperationType.鐢熶骇.ToString()).OrderByDescending(o => o.StartTime).FirstOrDefault(); + if (pro == null || pro.WorkPieceID.Length < 1 || logMiddle.MonitoringPoint.Equals("OP1002") || logMiddle.MonitoringPoint.Equals("OP1003") || logMiddle.MonitoringPoint.Contains("OP2002")) + {// OP10 娌℃湁涓婄嚎鎵爜鏋紝绾﹀畾鐢ㄦ祴閲忓畬鎴愪俊鍙峰綋涓婄嚎鏍囪锛屾墍浠ヤ笂绾块渶瑕佷慨鏀圭殑瀛楁鏀捐繖閲� + //涓婄嚎鏄瘡娆¢兘鎻掑叆 + + WorkPieceProcess process_05 = WorkPieceProcessHelper.CreateWorkPieceProcessForOP05(logMiddle, db, pieceInfo); + if (process_05 != null) + {//鍒涘缓OP05宸ュ簭锛屽綋娌℃湁05宸ュ簭鏃�,鎵嶅垱寤� 銆怑ditby shaocx,2024-08-29銆� + db.WorkPieceProcess.Add(process_05); + } + + WorkPieceProcess process = new WorkPieceProcess(); + process = EntityPropHelper.Mapper<WorkPieceProcess, WorkPieceInfo>(pieceInfo); + QualityStateHelper.ResetQualityNoOkForNewProcess(ref process); + process.StartTime = DateTimeHelper.GetDateTime(); + + //涓嶅啀榛樿璧嬪�间负鍚堟牸 銆怑ditby shaocx,2024-08-16銆� + //process.QualityState = pieceInfo.QualityState.HasValue ? pieceInfo.QualityState.Value : (int)QualityState.OK;//榛樿鍚堟牸锛屽凡澶勭悊 + process.QualityState = WorkPieceInfoManager.GetQualityStateValue(pieceInfo.QualityState); + + + //璁板綍璐ㄩ噺涓嶅悎鏍煎師鍥� 銆怑ditby shaocx,2024-06-26銆� + //璧嬪�间笉鍚堟牸鍘熷洜 + WorkPieceInfoManager.SetQualityNoOk_WorkPieceProcess(logMiddle, ref process); + + process.Id = Yitter.IdGenerator.YitIdHelper.NextId(); + process.CreatedUserName = WorkPieceInfoManager.ResetUpdatedUserName(logMiddle); + process.DataCapturePointCname = logMiddle.DataCapturePointCname; + process.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + process.UpdatedUserName = WorkPieceInfoManager.ResetUpdatedUserName(logMiddle); + process.UpdateDataCapturePointCname = logMiddle.DataCapturePointCname; + process.UpdatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + process.OperationType = OperationType.鐢熶骇.ToString(); + process.QualityDataInfoID = qualityData.Id; + process.Remarks = ""; + process.MyRemarks = "璐ㄩ噺妫�娴嬪畬鎴愭椂锛屽鏋滄壘涓嶅埌灏辨柊寤�"; + db.WorkPieceProcess.Add(process); + } + else + {//鍏朵粬鐨勯兘鍙槸淇敼 + pro.QualityDataInfoID = qualityData.Id; + pro.UpdatedUserName = WorkPieceInfoManager.ResetUpdatedUserName(logMiddle); + pro.UpdateDataCapturePointCname = logMiddle.DataCapturePointCname; + pro.UpdatedTime = DateTimeHelper.GetDateTime(); + + //涓嶅啀榛樿璧嬪�间负鍚堟牸 銆怑ditby shaocx,2024-08-16銆� + //pro.QualityState = pieceInfo.QualityState.HasValue ? pieceInfo.QualityState.Value : 9; + pro.QualityState = WorkPieceInfoManager.GetQualityStateValue(pieceInfo.QualityState); + + //璧嬪�间笉鍚堟牸鍘熷洜 + WorkPieceInfoManager.SetQualityNoOk_WorkPieceProcess(logMiddle, ref pro); + + //TODO:鍒ゆ柇濡傛灉鏄�60宸ュ簭锛岄偅涔堝氨瑕佹洿鏂皃ro琛ㄧ殑鍒涘缓浜轰负loginfo.MonitoringPoint 銆怑ditby shaocx,2024-06-05銆� + if (logMiddle.WorkingProcedure == "OP60") + { + pro.CreatedUserName = WorkPieceInfoManager.ResetUpdatedUserName(logMiddle); + pro.DataCapturePointCname = logMiddle.DataCapturePointCname; + } + } + + if (logMiddle.QualityType != null && logMiddle.QualityType.Equals(QualityType.SPC.ToString())) + {//SPC鍙嶉锛� + if (logMiddle.QualityState != (int)QualityStateEnum.OK) + { + //褰撴煇鍒板伐搴忔娴嬪埌涓嶅悎鏍煎伐浠舵椂锛屼粠璇ュ伐浠跺姞宸ュ畬鎴愭椂鍒诲墠鎸囧畾鏃堕棿璧疯嚦鎶ユ涓嶅悎鏍兼椂闂存锛岀郴缁熷皢璇ュ伐浠剁殑鏈�鍚庡姞宸ュ伐搴忓湪璇ユ椂闂存鍐呭姞宸ョ殑鎵�鏈夊伐浠躲�佹鍦ㄥ姞宸ョ殑宸ヤ欢銆佽宸ュ簭鍏ュ彛澶勭殑绗竴涓伐浠跺叏閮ㄦ爣璁颁负鐤戜技鐘舵�侊紝鐢变汉宸ュ妫�宸ヤ欢骞朵慨鏀圭姸鎬侊紝骞舵敮鎸佹壒閲忓彉鏇淬�� + //绛斿锛氬湪绾挎祴閲忎笉闇�瑕佽蛋杩欎釜娴佺▼锛屽彧鏈塖PC鎶芥鎵嶉渶瑕侊紝闇�瑕佹妸杩欐椂闂存鐨勫伐浠跺叏閮ㄧ疆涓虹枒浼硷紝鍝�曟槸宸插畬鎴愬伐浠� + //鏃堕棿娈佃捣濮嬫椂闂达細鎶芥宸ヤ欢鐢熶骇鏃堕棿鍓嶄竴SPC鎶芥鏃堕棿 + //鏃堕棿娈电粨鏉熸椂闂达細鎶芥宸ヤ欢璐ㄩ噺缁撴灉鍑虹幇鍚庣殑鏃堕棿 + //鎶芥宸ヤ欢宸ュ簭鎵弿鏋鍏ュ彛澶勭殑绗竴涓伐浠� 涔熸妸璐ㄩ噺鐘舵�佺疆涓虹枒浼� + //锛堟瘡涓�宸ュ簭SPC鎶芥鏄缃殑鍥哄畾鐨勶紝姣斿200鎶�4锛岀姸鎬佺疆涓虹枒浼兼椂鑻ュ伐浠惰繕鍦ㄨ澶囧唴锛屼細缁х画鐢熶骇瀹屾瘯鍚庢帓鍑猴級 + //鐩墠杩欏潡閫昏緫鏀惧埌浜� WebAPI涓簡 + + } + + } + db.WorkPieceInfoLog.Add(WorkPieceInfoManager.GetAddWorkPieceInfoLog(pieceInfo)); + db.QualityDataInfoLog.Add(WorkPieceInfoManager.GetAddQualityDataInfoLog(qualityData));//鎻掑叆鏃ュ織 + } + else + { + loginfo2.Remarks = $"璐ㄩ噺妫�娴嬪畬鎴愯鍙栦簩缁寸爜{logMiddle.WorkPieceID ?? "绌�"}寮傚父"; + Log4NetHelper.WriteErrorLog(type, $" {logMiddle.WorkingProcedure}宸ュ簭鐩戞帶璇荤爜鏍囪 璇诲彇宸ヤ欢鐮佹暟鎹甗{logMiddle.WorkPieceID ?? "绌�"}]鏃跺紓甯革細"); + + } + } + catch (Exception ex) + { + loginfo2.Remarks = $"璐ㄩ噺妫�娴嬪畬鎴�,鏇存柊鏁版嵁寮傚父{ex.Message}"; + Log4NetHelper.WriteErrorLog(type, $" {logMiddle.WorkingProcedure}璐ㄩ噺妫�娴嬪畬鎴� 宸ヤ欢鐮佹暟鎹甗{logMiddle.WorkPieceID ?? "绌�"}]鏃跺紓甯革細" + ex.Message, ex); + } + finally + { + loginfo2.Remarks = $"璐ㄩ噺锛歿logMiddle.QualityStateStr ?? "绌�"}"; + db.WorkPieceLog.Add(WorkPieceInfoManager.GetAddWorkPieceLog(loginfo2));//鎻掑叆宸ヤ欢閲囬泦鏃ュ織琛� + db.SaveChanges(); + } + } + } + + /// <summary> + /// 璐ㄩ噺妫�娴嬪畬鎴�-OP70涓撶敤 + /// </summary> + /// <param name="logMiddle"></param> + /// <param name="type"></param> + public static void QualityInfoCompleteForOP70(WorkPieceLogMiddle logMiddle, LogType type) + { + if (string.IsNullOrEmpty(logMiddle.QualityOP70To1) && string.IsNullOrEmpty(logMiddle.QualityOP70To2) && string.IsNullOrEmpty(logMiddle.QualityOP70To3)) + { + Log4NetHelper.WriteErrorLog(type, $" {logMiddle.WorkingProcedure}宸ュ簭鐩戞帶娓呮礂鏈烘暟鎹� 璇诲彇宸ヤ欢鐮佹暟鎹甗{logMiddle.WorkPieceID ?? "绌�"}]鑾峰彇鐨勪笁涓�奸兘鏄┖鐨勶紝涓嶅鐞嗚繑鍥�"); + return; + } + using (DbModel db = new DbModel()) + { + try + { + bool isAdd = false; + if (logMiddle.WorkPieceID.Length == 22) + { + var qualityData = db.QualityDataInfo.Where(o => o.WorkPieceID == logMiddle.WorkPieceID).FirstOrDefault(); + if (qualityData == null || qualityData.WorkPieceID.Length < 1 || qualityData.WorkingProcedure.Length < 1) + {//鎻掑叆QualityDataInfo琛� + isAdd = true; + qualityData = EntityPropHelper.Mapper<QualityDataInfo, WorkPieceLog>(logMiddle); + } + + qualityData.QualityStateUpdateUser = "OP7009"; + qualityData.QualityReceiveTime = DateTime.Now; + + //鐗规畩澶勭悊OP70鐨勮川閲忔暟鎹� + if (string.IsNullOrEmpty(qualityData.QualityOP70To1) && !string.IsNullOrEmpty(SystemHelper.GetStrForQualityOP70(logMiddle.QualityOP70To1))) + { + qualityData.QualityOP70To1 = logMiddle.QualityOP70To1; + } + if (string.IsNullOrEmpty(qualityData.QualityOP70To2) && !string.IsNullOrEmpty(SystemHelper.GetStrForQualityOP70(logMiddle.QualityOP70To2))) + { + qualityData.QualityOP70To2 = logMiddle.QualityOP70To2; + } + if (string.IsNullOrEmpty(qualityData.QualityOP70To3) && !string.IsNullOrEmpty(SystemHelper.GetStrForQualityOP70(logMiddle.QualityOP70To3))) + { + qualityData.QualityOP70To3 = logMiddle.QualityOP70To3; + } + + + db.QualityDataInfoLog.Add(WorkPieceInfoManager.GetAddQualityDataInfoLog(qualityData));//鎻掑叆鏃ュ織 + + if (isAdd) + { + db.QualityDataInfo.Add(WorkPieceInfoManager.GetAddQualityDataInfo(qualityData)); + } + db.SaveChanges();//淇濆瓨鏁版嵁 + } + else + { + Log4NetHelper.WriteErrorLog(type, $" {logMiddle.WorkingProcedure}宸ュ簭鐩戞帶娓呮礂鏈烘暟鎹� 璇诲彇宸ヤ欢鐮佹暟鎹甗{logMiddle.WorkPieceID ?? "绌�"}]鏃跺紓甯革細"); + + } + } + catch (Exception ex) + { + Log4NetHelper.WriteErrorLog(type, $" {logMiddle.WorkingProcedure}宸ュ簭鐩戞帶娓呮礂鏈烘暟鎹� 璇诲彇宸ヤ欢鐮佹暟鎹甗{logMiddle.WorkPieceID ?? "绌�"}]鏃跺紓甯革細", ex); + } + finally + { + } + } + } + } +} diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/ReadQRcodeManager.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/ReadQRcodeManager.cs new file mode 100644 index 0000000..684fc26 --- /dev/null +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/ReadQRcodeManager.cs @@ -0,0 +1,276 @@ +锘縰sing iWare_SCADA_BusinessLogical.Utils; +using iWare_SCADA_Model; +using System; +using System.Collections.Generic; +using System.Data.Entity.Validation; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace iWare_SCADA_BusinessLogical.BLL.Important +{ + public class ReadQRcodeManager + { + /// <summary> + /// 璇诲彇浜岀淮鐮佹椂閫昏緫 + /// 鏍¢獙宸ヤ欢鏄惁璺冲簭锛岃川閲忔槸鍚﹀悎鏍� + /// </summary> + public static void ReadQRcode(WorkPieceLog loginfo, LogType type, PLCService plcService, int? IsFeedback) + {//姝ゅ鍚屾椂鎻掑叆浜哤orkPieceLog锛學orkPieceInfoLog琛紝骞舵柊澧炴垨淇敼WorkPieceInfo琛� + using (DbModel db = new DbModel()) + { + try + { + bool isAddWorkPieceInfo = false; + if (loginfo.WorkPieceID.Length == 22) + { + WorkPieceInfo info = new WorkPieceInfo(); + info = db.WorkPieceInfo.Where(o => o.WorkPieceID == loginfo.WorkPieceID).FirstOrDefault(); + if (info == null || info.WorkPieceID.Length < 1) + {//鎻掑叆WorkPieceInfo琛� + loginfo = CommonManager.Instance.GetWorkPieceID(loginfo, type); + info = EntityPropHelper.Mapper<WorkPieceInfo, WorkPieceLog>(loginfo); + //EntityPropHelper<WorkPieceLog, WorkPieceInfo>.CopyProp(loginfo, info, loginfo.GetWorkPieceInfoDict()); + if (!loginfo.WorkingProcedure.Equals("OP05")) + {//褰撳伐浠朵簩缁寸爜绗竴娆″嚭鐜扮殑宸ュ簭涓嶆槸OP05锛屽垯璁剧疆涓哄彲鐤戠姸鎬� + info.QualityState = (int)QualityStateEnum.Suspected; + info.QualityErrorInfo = $"宸ヤ欢浜岀淮鐮佺涓�娆″嚭鐜扮殑宸ュ簭{loginfo.MonitoringPoint}涓嶆槸OP05,鏁版嵁缂哄け,璇风‘璁ゆ儏鍐靛苟鍋氱浉搴斿鐞嗭紒"; + info.Remarks = $"宸ヤ欢浜岀淮鐮佺涓�娆″嚭鐜扮殑宸ュ簭{loginfo.WorkingProcedure}涓嶆槸OP05,鏁版嵁缂哄け,璇风‘璁ゆ儏鍐靛苟鍋氱浉搴斿鐞嗭紒"; + } + else + {//OP05宸ュ簭 + info.QualityState = (int)QualityStateEnum.OK;//姝ゅ闇�瑕佹敞鎰忥紝鍒ゆ柇鎵�鏈夊伐搴忚川閲忥紝鐒跺悗鍐嶈祴鍊� //榛樿鍚堟牸锛孫P05榛樿鏄悎鏍� + info.Remarks = "OP05鏂板宸ヤ欢淇℃伅"; + } + info.WorkPieceinitOnlineTime = DateTimeHelper.GetDateTime(); + info.WorkingProcedurePlan = ConfigHelper.GetConfigString("WorkingProcedureAllStr") ?? "OP05OP10OP20OP30OP35OP40OP50OP60OP70OP80"; + info.CreatedUserName = loginfo.MonitoringPoint; + info.WorkingProcedureCurrent = loginfo.WorkingProcedure;//宸ュ簭璧嬪�� + SystemBussinessHelper.SetWorkPieceInfoMiddleForCreatedUserName(ref info, loginfo.DataCapturePointCname); + info.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + info = WorkPieceInfoManager.ParseQRCode(info); + isAddWorkPieceInfo = true; + } + else + { + //瀛樺湪 琛� WorkPieceInfo鏈夛紝浣嗘槸 WorkPieceProcess杩欎釜宸ュ簭涓嶅瓨鍦ㄧ殑鎯呭喌 銆怑ditby shaocx,2024-09-06銆� + //if (info.WorkingProcedureCurrent.Equals("OP05")) + //{ + // loginfo.Remarks = $"璇诲彇浜岀淮鐮亄loginfo.WorkPieceID ?? "绌�"} OP05宸ュ簭閲嶅璇诲彇浜�"; + // return; + //} + } + if ((loginfo.WorkingProcedure.Equals("OP05") && isAddWorkPieceInfo == false)) + {//瀛樺湪 琛� WorkPieceInfo鏈夛紝浣嗘槸 WorkPieceProcess杩欎釜宸ュ簭涓嶅瓨鍦ㄧ殑鎯呭喌 + //濡傛灉鏄疧P05鐨勶紝骞朵笖鏄� 涓嶉渶瑕佹柊澧� 琛╓orkPieceInfo锛岄偅涔堝氨涓嶉渶瑕佹洿鏂拌〃 WorkPieceInfo + } + else + { + info.WorkingProcedureStartTime = DateTimeHelper.GetDateTime();// + info.WorkingProcedureEndTime = null; + info.WorkPieceState = (int)WorkPieceState.WIP; + info.EquipmentID = loginfo.EquipmentID; + info.QualityStateUpdateUser = loginfo.UpdatedUserName; + info.QualityStateUpdateTime = loginfo.UpdatedTime.Value.LocalDateTime; + info.QualityStateUpdateMode = QualityStateUpdateMode.Auto.ToString(); + info.UpdatedUserName = loginfo.MonitoringPoint; + SystemBussinessHelper.SetWorkPieceInfoMiddleForUpdateDataCapturePointCname(ref info, loginfo.DataCapturePointCname); + info.UpdatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + + info.WorkPieceCurrentPosition = loginfo.WorkingProcedure; + info.WorkPieceCurrentPositionOrder = info.WorkingProcedurePlan.IndexOf(loginfo.WorkingProcedure) / 2; + info.WorkingProcedureCurrent = loginfo.WorkingProcedure;//宸ュ簭璧嬪�� + info.Remarks = $"{info.WorkingProcedureCurrent}宸ヤ欢涓婄嚎"; + } + + + //淇涓� op35 鍚屼竴涓欢 涓嬬嚎鏃堕棿璺熶笅涓�涓笂绾挎椂闂翠竴妯′竴鏍风殑闂 銆怑ditby shaocx,2024-08-27銆� + var isNeedAddNewProcess = true; + + //鐗规畩澶勭悊OP05涓婄嚎锛屽洜涓轰粬鏄牴鎹枃鏈垪琛ㄥ唴瀹逛笂绾跨殑 銆怑ditby shaocx,2024-09-03銆� + if (loginfo.WorkingProcedure.Equals("OP05")) + { + var op05Proccss = db.WorkPieceProcess.Where(o => o.WorkPieceID == loginfo.WorkPieceID && o.WorkingProcedureCurrent == loginfo.WorkingProcedure).FirstOrDefault(); + if (op05Proccss != null) + { + isNeedAddNewProcess = false;//涓嶉渶瑕佹柊澧炰簡 + } + } + else + { + var pro = db.WorkPieceProcess.Where(o => o.WorkPieceID == loginfo.WorkPieceID && !o.OperationType.Equals("SPC") && (o.EndTime == null || o.EndTime <= DateTime.MinValue)).OrderByDescending(o => o.StartTime).FirstOrDefault(); + if (pro != null && pro.WorkPieceID.Length > 1) + { + if (pro.WorkingProcedureCurrent == loginfo.WorkingProcedure) + {//琛ㄧず宸ュ簭鐩稿悓 + isNeedAddNewProcess = false; + pro.Remarks = "鍙堜竴娆′笂绾匡紝鏇存柊缁撴潫鏃堕棿"; + } + else + { + pro.EndTime = DateTimeHelper.GetDateTime(); + pro.UpdatedUserName = loginfo.MonitoringPoint; + pro.UpdateDataCapturePointCname = loginfo.DataCapturePointCname; + pro.UpdatedTime = DateTimeHelper.GetDateTime(); + pro.Remarks = "鍙堜竴娆′笂绾匡紝鏇存柊缁撴潫鏃堕棿"; + } + } + } + if (isNeedAddNewProcess) + { + //姣忔鎵弿涓婄嚎閮芥彃鍏ヨ拷婧〃 + WorkPieceProcess new_process = new WorkPieceProcess(); + new_process = EntityPropHelper.Mapper<WorkPieceProcess, WorkPieceInfo>(info); + QualityStateHelper.ResetQualityNoOkForNewProcess(ref new_process); + new_process.StartTime = DateTimeHelper.GetDateTime(); + + //涓嶅啀榛樿璧嬪�间负鍚堟牸 銆怑ditby shaocx,2024-08-16銆� + //process.QualityState = info.QualityState.HasValue ? info.QualityState.Value : (int)QualityState.OK;//榛樿鍚堟牸锛屽凡澶勭悊 + new_process.QualityState = WorkPieceInfoManager.GetQualityStateValue(info.QualityState); + + if (new_process.WorkingProcedureCurrent == WorkingProcedureForHMI.OP70.ToString()) + { //鐗规畩澶勭悊OP70锛屽洜涓篛P70娌℃湁娴嬮噺锛岄粯璁ゅ悎鏍� [Editby shaocx,2024-07-03] + new_process.QualityState = (int)QualityStateEnum.OK;//榛樿鍚堟牸锛孫P70榛樿鏄悎鏍� + } + + new_process.Id = Yitter.IdGenerator.YitIdHelper.NextId(); + new_process.CreatedUserName = loginfo.MonitoringPoint; + new_process.DataCapturePointCname = loginfo.DataCapturePointCname; + new_process.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + new_process.UpdatedUserName = loginfo.MonitoringPoint; + new_process.UpdateDataCapturePointCname = loginfo.DataCapturePointCname; + new_process.UpdatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + new_process.OperationType = OperationType.鐢熶骇.ToString(); + new_process.Remarks = ""; + new_process.MyRemarks = "璇荤爜涓婄嚎鏃讹紝姣忔鎵弿涓婄嚎閮芥彃鍏ヨ拷婧〃"; + if (loginfo.WorkingProcedure.Equals("OP05")) + {//鐗规畩澶勭悊OP05宸ュ簭 + new_process.EndTime = new_process.StartTime; + + //濡傛灉宸茬粡瀛樺湪鍏朵粬宸ュ簭锛岄偅涔堝氨蹇呴』瑕佹寜鐓у叾浠栧伐搴忕殑鏃堕棿寰�鍓嶆帹鏁版嵁 銆怑ditby shaocx,2024-09-05銆� + var op05OtherProccss = db.WorkPieceProcess.Where(o => o.WorkPieceID == loginfo.WorkPieceID).OrderBy(x => x.StartTime).FirstOrDefault(); + if (op05OtherProccss != null) + {//璇存槑鏈夛紝閭d箞鏃堕棿灏辨寜鐓ц繖涓椂闂村線鍓嶆帹 + var _time = op05OtherProccss.StartTime.AddHours(-1); + new_process.StartTime = _time; + new_process.EndTime = _time; + new_process.CreatedTime = _time; + new_process.UpdatedTime = _time; + } + } + db.WorkPieceProcess.Add(new_process); + } + //db.Database.AutoTransactionsEnabled = false;// 鍚屼竴涓猄aveChanges榛樿浜嬪姟锛� 鍏抽棴榛樿浜嬪姟锛�... 濂藉儚涓嶈兘鐢ㄥ晩锛屽悗闈㈠啀鐮旂┒鍚� + if (isAddWorkPieceInfo) + { + db.WorkPieceInfo.Add(info); + } + else + {//涓嶇‘瀹歩nfo鏄洿鎺ヤ細淇敼杩樻槸闇�瑕佸啀娆℃煡璇紝寰呮祴璇� + //info.Remarks = "淇敼锛屽叿浣撲慨鏀归�昏緫寰呭畾"; + } + + #region 鍒ゆ柇鏄惁璺冲簭,鎴栬川閲忎笉绗﹀悎 鐒跺悗鍙嶉PLC + /* + if (IsFeedback.HasValue && IsFeedback.Value == (int)FeedbackMode.FeedbackPLC) + { + bool checkQualityInfoCompleteFlag = false; + bool plcFlag = true;//鍙嶉缁橮LC鐨勬爣璁� + string message = ""; + checkQualityInfoCompleteFlag = WorkPieceInfoManager.CheckQualityInfoComplete(info, loginfo, type); + + if (!checkQualityInfoCompleteFlag || info.QualityState != (int)QualityStateEnum.OK) + { + plcFlag = false; + message = !checkQualityInfoCompleteFlag ? "璺冲簭锛�" : ""; + message += info.QualityState != (int)QualityStateEnum.OK ? "璐ㄩ噺涓嶇鍚�" : ""; + } + + } + else + {//璇荤爜瀹屾垚鑻ュ伐浠惰川閲忎笉绗﹀悎鎴栧彂鐢熻烦搴忥紝涓嶇敤绠¤澶囨槸鍚︽妸宸ヤ欢鏀捐繃鍘伙紝鏁伴噰绯荤粺閮戒笉鍙樻洿褰撳墠宸ュ簭锛屽弽棣堣澶嘝LC宸ヤ欢涓嶇鍚堬紝 + //鑻ュ伐搴忓悗缁敹闆嗙偣鏀跺埌鐩稿叧宸ヤ欢淇℃伅鍐嶅彉鏇村綋鍓嶅伐搴忥紝 浣嗚川閲忎俊鎭笉鍙� + + info.WorkingProcedureCurrent = loginfo.WorkingProcedure; + } + //*/ + #endregion + + #region 鏇存柊璁惧瀹炴椂琛� + + bool isAddEquipmentCurrentMonitor = false; + EquipmentCurrentMonitor equinfo = new EquipmentCurrentMonitor(); + equinfo = db.EquipmentCurrentMonitor.Where(o => o.EquipmentID == loginfo.EquipmentID).FirstOrDefault(); + if (equinfo == null || equinfo.Id < 1) + {//娌℃湁宸ヤ欢淇℃伅锛屼笉鍋氭洿鏂� + Log4NetHelper.WriteErrorLog(type, $"璁惧{loginfo.EquipmentID} 鍛婅鐩戞帶{loginfo.WorkingProcedure} 娌℃湁鑾峰彇鍒拌澶囩洃鎺т俊鎭紝鐜版柊澧�"); + equinfo = EntityPropHelper.Mapper<EquipmentCurrentMonitor, WorkPieceLog>(loginfo); + equinfo.OnlineTime = DateTime.Now; + isAddEquipmentCurrentMonitor = true; + } + else + {//鏇存柊宸ヤ欢 + equinfo.WorkPieceID = loginfo.WorkPieceID; + equinfo.UpdatedUserName = loginfo.MonitoringPoint; + equinfo.UpdatedTime = DateTime.Now; + equinfo.OnlineTime = DateTime.Now; + } + if (isAddEquipmentCurrentMonitor) + { + equinfo.Id = Yitter.IdGenerator.YitIdHelper.NextId(); + db.EquipmentCurrentMonitor.Add(equinfo); + } + #endregion + //db.WorkPieceLog.Add(GetAddWorkPieceLog(loginfo)); + db.WorkPieceInfoLog.Add(WorkPieceInfoManager.GetAddWorkPieceInfoLog(info)); + //UpdateKnifeToolLift(db, loginfo);//鏇存柊鍒�鍏峰鍛戒俊鎭� + } + else + { + loginfo.Remarks = $"涓婄嚎瀹屾垚璇诲彇浜岀淮鐮亄loginfo.WorkPieceID ?? "绌�"}寮傚父"; + Log4NetHelper.WriteErrorLog(type, $" {loginfo.WorkingProcedure}涓婄嚎鐩戞帶璇荤爜鏍囪 璇诲彇宸ヤ欢鐮佹暟鎹甗{loginfo.WorkPieceID ?? "绌�"}]鏃跺紓甯革細"); + + } + } + catch (Exception e) + { + loginfo.Remarks = $"璇诲彇浜岀淮鐮亄loginfo.WorkPieceID ?? "绌�"}鏇存柊鏁版嵁寮傚父{e.Message}"; + Log4NetHelper.WriteErrorLog(type, $" {loginfo.WorkingProcedure}涓婄嚎鐩戞帶璇荤爜鏍囪 璇诲彇宸ヤ欢鐮佹暟鎹甗{loginfo.WorkPieceID ?? "绌�"}]鏃跺紓甯革細", e); + } + finally + { + loginfo.Id = Yitter.IdGenerator.YitIdHelper.NextId(); + db.WorkPieceLog.Add(loginfo); + + //淇濆瓨鏁版嵁搴撶殑寮傚父鎹曟崏 [Editby shaocx,2024-08-29] + try + { + db.SaveChanges(); + } + catch (DbEntityValidationException exception) + { + var errorMessages = + exception.EntityValidationErrors + .SelectMany(validationResult => validationResult.ValidationErrors) + .Select(m => m.ErrorMessage); + var fullErrorMessage = string.Join(", ", errorMessages); + var exceptionMessage = string.Concat(exception.Message, " 楠岃瘉寮傚父娑堟伅鏄細", fullErrorMessage); + + Log4NetHelper.WriteErrorLog(type, $" {loginfo.WorkingProcedure}涓婄嚎鐩戞帶璇荤爜鏍囪 璇诲彇宸ヤ欢鐮佹暟鎹甗{loginfo.WorkPieceID ?? "绌�"}],淇濆瓨鏁版嵁搴撴椂寮傚父锛�" + exceptionMessage, exception); + + throw new DbEntityValidationException(exceptionMessage, exception.EntityValidationErrors); + } + catch (Exception) + { + + throw; + } + + + + } + + } + } + } +} diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/WorkPiecePushOffManager.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/WorkPiecePushOffManager.cs new file mode 100644 index 0000000..598c7fe --- /dev/null +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/WorkPiecePushOffManager.cs @@ -0,0 +1,159 @@ +锘縰sing iWare_SCADA_BusinessLogical.Utils; +using iWare_SCADA_Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace iWare_SCADA_BusinessLogical.BLL.Important +{ + public class WorkPiecePushOffManager + { + /// <summary> + /// 宸ヤ欢鎺ㄥ嚭NOOK + /// </summary> + /// <param name="loginfo"></param> + /// <param name="type"></param> + public static void WorkPiecePushOff(WorkPieceLogMiddle loginfo, LogType type) + { + using (DbModel db = new DbModel()) + { + WorkPieceLog loginfo2 = new WorkPieceLog(); + loginfo2 = EntityPropHelper.Mapper<WorkPieceLog, WorkPieceLogMiddle>(loginfo); + try + { + if (loginfo.WorkPieceID != null && loginfo.WorkPieceID.Trim('\0').Length == 22) + { + WorkPieceInfo cur_db_info = new WorkPieceInfo(); + cur_db_info = db.WorkPieceInfo.Where(o => o.WorkPieceID == loginfo.WorkPieceID).FirstOrDefault(); + if (cur_db_info == null || cur_db_info.WorkPieceID.Length < 1) + {//娌℃湁宸ヤ欢淇℃伅锛屼笉鍋氭洿鏂� + Log4NetHelper.WriteErrorLog(type, $"宸ヤ欢{loginfo.WorkPieceID} 宸ヤ欢鎺ㄥ嚭NOOK宸ュ簭{loginfo.WorkingProcedure} 娌℃湁鑾峰彇鍒板伐浠朵俊鎭笉鍋氭洿鏂�"); + return; + } + else + {//鏇存柊琛╓orkPieceInfo + if (loginfo.WorkingProcedure.Equals("OP10")) + { + /* + info.WorkPieceCurrentPosition = info.WorkingProcedureCurrent + "NOOK"; + loginfo2.WorkingProcedure = info.WorkingProcedureCurrent;//瑙e喅OP10锛孫P40鍚屼竴涓殑闂 + loginfo.WorkingProcedure = info.WorkingProcedureCurrent; //瑙e喅OP10锛孫P40鍚屼竴涓殑闂 + //*/ + //淇 閿欒璁板綍鎴怬P05鐨勯棶棰� 銆怑ditby shaocx,2024-08-26銆� + var set_WorkingProcedureCurrent = ""; + if (cur_db_info.WorkingProcedureCurrent != "OP10" && cur_db_info.WorkingProcedureCurrent != "OP40") + { + WorkPieceInfoManager.SetWorkingProcedureCurrentForOP10(cur_db_info, ref set_WorkingProcedureCurrent); + } + else + { + set_WorkingProcedureCurrent = cur_db_info.WorkingProcedureCurrent; + } + cur_db_info.WorkingProcedureCurrent = set_WorkingProcedureCurrent; + cur_db_info.WorkPieceCurrentPosition = set_WorkingProcedureCurrent + "NOOK"; + loginfo2.WorkingProcedure = set_WorkingProcedureCurrent;//瑙e喅OP10锛孫P40鍚屼竴涓殑闂 + loginfo.WorkingProcedure = set_WorkingProcedureCurrent; //瑙e喅OP10锛孫P40鍚屼竴涓殑闂 + } + else + { + cur_db_info.WorkingProcedureCurrent = loginfo.WorkingProcedure; + cur_db_info.WorkPieceCurrentPosition = loginfo.WorkingProcedure + "NOOK"; + } + cur_db_info.WorkPieceState = (int)WorkPieceState.NOOKPush; + cur_db_info.UpdatedUserName = loginfo.MonitoringPoint; + SystemBussinessHelper.SetWorkPieceInfoMiddleForUpdateDataCapturePointCname(ref cur_db_info, loginfo.DataCapturePointCname); + cur_db_info.UpdatedTime = DateTime.Now; + cur_db_info.Remarks = "宸ヤ欢NOOK鎺ㄥ嚭"; + loginfo2.Remarks = cur_db_info.Remarks; + if (!(cur_db_info.WorkingProcedureStartTime.HasValue && cur_db_info.WorkingProcedureStartTime > DateTime.Parse("1900/01/01"))) + { + cur_db_info.WorkingProcedureStartTime = DateTimeHelper.GetDateTime(); + } + cur_db_info.WorkingProcedureEndTime = DateTimeHelper.GetDateTime(); + cur_db_info.WorkingProcedureCompleted = cur_db_info.WorkingProcedureCompleted + loginfo.WorkingProcedure;//宸插畬鎴愬伐搴� + cur_db_info.WorkPieceCurrentPositionOrder = cur_db_info.WorkingProcedurePlan.IndexOf(loginfo.WorkingProcedure) / 2; + } + QualityDataInfo qualityData = null; + qualityData = db.QualityDataInfo.Where(o => o.WorkPieceID == loginfo.WorkPieceID).FirstOrDefault(); + if (loginfo.WorkingProcedure.Equals("OP35")) + {//涓轰簡瑙e喅OP35鐨勯噰闆嗗埌鐨勮川閲忎俊鎭槸OK杩楴OOK鐨勬儏鍐碉紝OP35 NOOK鏃舵洿鏂拌川閲忎俊鎭� + loginfo2.Remarks = $"OP35NOOK鍘熻川閲忎俊鎭瘂(cur_db_info.QualityState.HasValue ? cur_db_info.QualityState.Value.ToString() : "绌�")}"; + cur_db_info.QualityState = (int)QualityStateEnum.NG; + if (!cur_db_info.QualityState.Equals(((int)QualityStateEnum.OK).ToString())) + { + cur_db_info.QualityErrorInfo = $"{loginfo.WorkingProcedure}宸ュ簭璐ㄩ噺NOOK閲囬泦鏁版嵁涓嶅悎鏍納cur_db_info.QualityState}"; + } + else + { + cur_db_info.QualityErrorInfo = ""; + } + loginfo.QualityState = cur_db_info.QualityState; + + + if (qualityData != null) + { + qualityData.OP35QualityState = loginfo.QualityState.HasValue ? loginfo.QualityState.Value.ToString() : "3"; + qualityData.OP35QualityReceiveTime = DateTimeHelper.GetDateTime(); + db.QualityDataInfoLog.Add(WorkPieceInfoManager.GetAddQualityDataInfoLog(qualityData)); + } + } + //鏇存柊涓婁竴宸ュ簭鐨勭粨鏉熸椂闂� + var pro = db.WorkPieceProcess.Where(o => o.WorkPieceID == loginfo.WorkPieceID + && o.WorkingProcedureCurrent == loginfo.WorkingProcedure && o.OperationType == OperationType.鐢熶骇.ToString()).OrderByDescending(o => o.StartTime).FirstOrDefault(); + if (pro != null && pro.WorkPieceID.Length > 0) + { + pro.EndTime = DateTimeHelper.GetDateTime(); + pro.Remarks = "NOOK缁撴潫"; + pro.UpdatedUserName = loginfo.MonitoringPoint; + pro.UpdateDataCapturePointCname = loginfo.DataCapturePointCname; + pro.UpdatedTime = DateTimeHelper.GetDateTime(); + } + else + {//濡傛灉鎵句笉鍒板氨鏂板缓 銆怑ditby shaocx,2024-09-03銆� + WorkPieceProcess add_process = new WorkPieceProcess(); + add_process = EntityPropHelper.Mapper<WorkPieceProcess, WorkPieceInfo>(cur_db_info); + QualityStateHelper.ResetQualityNoOkForNewProcess(ref add_process); + add_process.Id = Yitter.IdGenerator.YitIdHelper.NextId(); + add_process.StartTime = DateTimeHelper.GetDateTime().AddSeconds(-SystemBussinessHelper.MoNiTimeForWorkingProcedure(loginfo.WorkingProcedure)); + add_process.EndTime = DateTimeHelper.GetDateTime(); + //涓嶅啀榛樿璧嬪�间负鍚堟牸 銆怑ditby shaocx,2024-08-16銆� + add_process.QualityState = WorkPieceInfoManager.GetQualityStateValue(loginfo.QualityState); + + add_process.CreatedUserName = loginfo.MonitoringPoint; + add_process.DataCapturePointCname = loginfo.DataCapturePointCname; + add_process.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + add_process.UpdatedUserName = loginfo.MonitoringPoint; + add_process.UpdateDataCapturePointCname = loginfo.DataCapturePointCname; + add_process.UpdatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + add_process.OperationType = OperationType.鐢熶骇.ToString(); + add_process.Remarks = "NOOK缁撴潫"; + add_process.MyRemarks = "NOOK缁撴潫鏃讹紝濡傛灉鎵句笉鍒板氨鏂板缓"; + db.WorkPieceProcess.Add(add_process); + } + + QualityStateHelper.SetQualityStateForNoOk(ref cur_db_info, ref pro, ref qualityData); + + db.WorkPieceInfoLog.Add(WorkPieceInfoManager.GetAddWorkPieceInfoLog(cur_db_info)); + + } + else + { + loginfo2.Remarks = $"宸ヤ欢NOOK鎺ㄥ嚭璇诲彇浜岀淮鐮亄loginfo.WorkPieceID ?? "绌�"}寮傚父"; + Log4NetHelper.WriteErrorLog(type, $" {loginfo.WorkingProcedure}宸ヤ欢NOOK鎺ㄥ嚭璇荤爜鏍囪 璇诲彇宸ヤ欢鐮佹暟鎹甗{loginfo.WorkPieceID ?? "绌�"}]鏃跺紓甯革細"); + } + } + catch (Exception e) + { + loginfo2.Remarks = $"璇诲彇浜岀淮鐮亄loginfo.WorkPieceID ?? "绌�"}鏇存柊鏁版嵁寮傚父{e.Message}"; + } + + + db.WorkPieceLog.Add(WorkPieceInfoManager.GetAddWorkPieceLog(loginfo2));//鎻掑叆宸ヤ欢閲囬泦鏃ュ織琛� + db.SaveChanges(); + } + + } + } +} diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/WorkPieceSPCPushOffManager.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/WorkPieceSPCPushOffManager.cs new file mode 100644 index 0000000..c46119d --- /dev/null +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/WorkPieceSPCPushOffManager.cs @@ -0,0 +1,132 @@ +锘縰sing iWare_SCADA_BusinessLogical.Utils; +using iWare_SCADA_Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace iWare_SCADA_BusinessLogical.BLL.Important +{ + public class WorkPieceSPCPushOffManager + { + /// <summary> + /// 宸ヤ欢SPC鎶芥鎺ㄥ嚭 + /// </summary> + /// <param name="loginfo"></param> + /// <param name="type"></param> + public static void WorkPieceSPCPushOff(WorkPieceLogMiddle loginfo, LogType type) + { + + using (DbModel db = new DbModel()) + { + WorkPieceLog loginfo2 = new WorkPieceLog(); + loginfo2 = EntityPropHelper.Mapper<WorkPieceLog, WorkPieceLogMiddle>(loginfo); + try + { + if ((loginfo.WorkPieceID != null && loginfo.WorkPieceID.Trim('\0').Length == 22) + //|| !((loginfo.WorkingProcedure.Equals("OP10") || loginfo.WorkingProcedure.Equals("OP40")) && loginfo.Remarks.Length > 0) + ) + { + WorkPieceInfo cur_db_info = new WorkPieceInfo(); + cur_db_info = db.WorkPieceInfo.Where(o => o.WorkPieceID == loginfo.WorkPieceID).FirstOrDefault(); + if (cur_db_info == null || cur_db_info.WorkPieceID.Length < 1) + {//娌℃湁宸ヤ欢淇℃伅锛屼笉鍋氭洿鏂� + loginfo2.Remarks = $"宸ヤ欢{loginfo.WorkPieceID} 宸ヤ欢SPC鎺ㄥ嚭宸ュ簭{loginfo.WorkingProcedure} 娌℃湁鑾峰彇鍒板伐浠朵俊鎭笉鍋氭洿鏂�"; + Log4NetHelper.WriteErrorLog(type, $"宸ヤ欢{loginfo.WorkPieceID} 宸ヤ欢SPC鎺ㄥ嚭宸ュ簭{loginfo.WorkingProcedure} 娌℃湁鑾峰彇鍒板伐浠朵俊鎭笉鍋氭洿鏂�"); + return; + } + else + {//鏇存柊琛╓orkPieceInfo + if (loginfo.WorkingProcedure.Equals("OP10")) + { + //淇 閿欒璁板綍鎴怬P05鐨勯棶棰� 銆怑ditby shaocx,2024-08-26銆� + var set_WorkingProcedureCurrent = ""; + if (cur_db_info.WorkingProcedureCurrent != "OP10" && cur_db_info.WorkingProcedureCurrent != "OP40") + { + WorkPieceInfoManager.SetWorkingProcedureCurrentForOP10(cur_db_info, ref set_WorkingProcedureCurrent); + } + else + { + set_WorkingProcedureCurrent = cur_db_info.WorkingProcedureCurrent; + } + cur_db_info.WorkingProcedureCurrent = set_WorkingProcedureCurrent; + cur_db_info.WorkPieceCurrentPosition = set_WorkingProcedureCurrent + "SPC"; + loginfo2.WorkingProcedure = set_WorkingProcedureCurrent;//瑙e喅OP10锛孫P40鍚屼竴涓殑闂 + loginfo.WorkingProcedure = set_WorkingProcedureCurrent; //瑙e喅OP10锛孫P40鍚屼竴涓殑闂 + } + else + { + cur_db_info.WorkingProcedureCurrent = loginfo.WorkingProcedure; + cur_db_info.WorkPieceCurrentPosition = loginfo.WorkingProcedure + "SPC"; + } + cur_db_info.WorkPieceState = (int)WorkPieceState.SPCPush; + cur_db_info.UpdatedUserName = loginfo.MonitoringPoint; + SystemBussinessHelper.SetWorkPieceInfoMiddleForUpdateDataCapturePointCname(ref cur_db_info, loginfo.DataCapturePointCname); + cur_db_info.UpdatedTime = DateTime.Now; + cur_db_info.WorkingProcedureEndTime = DateTimeHelper.GetDateTime(); + if (!(cur_db_info.WorkingProcedureStartTime.HasValue && cur_db_info.WorkingProcedureStartTime > DateTime.Parse("1900/01/01"))) + { + cur_db_info.WorkingProcedureStartTime = DateTimeHelper.GetDateTime(); + } + + + cur_db_info.WorkingProcedureCompleted = cur_db_info.WorkingProcedureCompleted + loginfo.WorkingProcedure;//宸插畬鎴愬伐搴� + cur_db_info.WorkPieceCurrentPositionOrder = cur_db_info.WorkingProcedurePlan.IndexOf(loginfo.WorkingProcedure) / 2; + } + cur_db_info.Remarks = "宸ヤ欢SPC鎶芥鎺ㄥ嚭"; + loginfo2.Remarks = cur_db_info.Remarks; + + //鏇存柊涓婁竴宸ュ簭鐨勭粨鏉熸椂闂� + var pro = db.WorkPieceProcess.Where(o => o.WorkPieceID == loginfo.WorkPieceID && o.WorkingProcedureCurrent == loginfo.WorkingProcedure + && o.OperationType == OperationType.鐢熶骇.ToString()).OrderByDescending(o => o.StartTime).FirstOrDefault(); + if (pro != null && pro.WorkPieceID.Length > 0) + { + pro.EndTime = DateTimeHelper.GetDateTime(); + pro.Remarks = (pro.Remarks ?? "") + "SPC鎶芥缁撴潫"; + pro.UpdatedUserName = loginfo.MonitoringPoint; + pro.UpdateDataCapturePointCname = loginfo.DataCapturePointCname; + pro.UpdatedTime = DateTimeHelper.GetDateTime(); + } + //姣忔SPC 閮芥彃鍏ヨ拷婧〃 + WorkPieceProcess process = new WorkPieceProcess(); + process = EntityPropHelper.Mapper<WorkPieceProcess, WorkPieceInfo>(cur_db_info); + QualityStateHelper.ResetQualityNoOkForNewProcess(ref process); + process.StartTime = DateTimeHelper.GetDateTime(); + process.OperationType = OperationType.SPC.ToString(); + process.QualityState = (int)QualityStateEnum.Suspected; + process.Id = Yitter.IdGenerator.YitIdHelper.NextId(); + process.CreatedUserName = loginfo.MonitoringPoint; + process.DataCapturePointCname = loginfo.DataCapturePointCname; + process.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + process.UpdatedUserName = loginfo.MonitoringPoint; + process.UpdateDataCapturePointCname = loginfo.DataCapturePointCname; + process.UpdatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + process.Remarks = "宸ヤ欢SPC鎶芥鎺ㄥ嚭"; + process.MyRemarks = "SPC鏃讹紝鎻掑叆杩芥函琛�"; + db.WorkPieceProcess.Add(process); + + + db.WorkPieceInfoLog.Add(WorkPieceInfoManager.GetAddWorkPieceInfoLog(cur_db_info)); + } + else + { + loginfo2.Remarks = $"宸ヤ欢SPC鎶芥鎺ㄥ嚭璇诲彇浜岀淮鐮亄loginfo.WorkPieceID ?? "绌�"}寮傚父"; + Log4NetHelper.WriteErrorLog(type, $" {loginfo.WorkingProcedure}宸ヤ欢SPC鎶芥鎺ㄥ嚭璇荤爜鏍囪 璇诲彇宸ヤ欢鐮佹暟鎹甗{loginfo.WorkPieceID ?? "绌�"}]鏃跺紓甯革細"); + } + } + catch (Exception e) + { + loginfo2.Remarks = $"璇诲彇浜岀淮鐮亄loginfo.WorkPieceID ?? "绌�"}鏇存柊鏁版嵁寮傚父{e.Message}"; + } + finally + { + db.WorkPieceLog.Add(WorkPieceInfoManager.GetAddWorkPieceLog(loginfo2));//鎻掑叆宸ヤ欢閲囬泦鏃ュ織琛� + db.SaveChanges(); + } + + } + } + + } +} diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/WorkingProcedureCompleteManager.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/WorkingProcedureCompleteManager.cs new file mode 100644 index 0000000..99f4ba7 --- /dev/null +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/Important/WorkingProcedureCompleteManager.cs @@ -0,0 +1,272 @@ +锘縰sing iWare_SCADA_BusinessLogical.Utils; +using iWare_SCADA_Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace iWare_SCADA_BusinessLogical.BLL.Important +{ + public class WorkingProcedureCompleteManager + { + /// <summary> + /// 宸ュ簭瀹屾垚 + /// </summary> + /// <param name="logMiddle"></param> + /// <param name="type"></param> + public static void WorkingProcedureComplete(WorkPieceLogMiddle logMiddle, LogType type) + { + + using (DbModel db = new DbModel()) + { + if (logMiddle.WorkingProcedure.Equals("OP70")) + { + logMiddle.QualityState = (int)QualityStateEnum.OK; //濡傛灉鏄疧P70锛屽垯榛樿鏄悎鏍� 銆怑ditby shaocx,2024-06-25銆� + } + + WorkPieceLog loginfo2 = new WorkPieceLog(); + loginfo2 = EntityPropHelper.Mapper<WorkPieceLog, WorkPieceLogMiddle>(logMiddle); + + try + { + if (logMiddle.WorkPieceID != null && logMiddle.WorkPieceID.Trim('\0').Length == 22) + { + + bool isAddWorkPieceInfo = false; + WorkPieceInfo db_info = new WorkPieceInfo(); + db_info = db.WorkPieceInfo.Where(o => o.WorkPieceID == logMiddle.WorkPieceID).FirstOrDefault(); + if (db_info == null || db_info.WorkPieceID.Length < 1) + {//娌℃湁宸ヤ欢淇℃伅锛屼笉鍋氭洿鏂� 锛堜负浜嗘祴璇曞厛鍏堟柊澧烇級 + Log4NetHelper.WriteErrorLog(type, $"宸ヤ欢{logMiddle.WorkPieceID} 宸ヤ欢鎺ㄥ嚭宸ュ簭{logMiddle.WorkingProcedure} 娌℃湁鑾峰彇鍒板伐浠朵俊鎭笉鍋氭洿鏂�"); + //db.WorkPieceLog.Add(GetAddWorkPieceLog(loginfo));//鎻掑叆宸ヤ欢閲囬泦鏃ュ織琛� + //db.SaveChanges(); + + loginfo2 = CommonManager.Instance.GetWorkPieceID(logMiddle, type); + db_info = EntityPropHelper.Mapper<WorkPieceInfo, WorkPieceLog>(logMiddle); + //EntityPropHelper<WorkPieceLog, WorkPieceInfo>.CopyProp(loginfo, info, loginfo.GetWorkPieceInfoDict()); + if (!logMiddle.WorkingProcedure.Equals("OP05")) + {//褰撳伐浠朵簩缁寸爜绗竴娆″嚭鐜扮殑宸ュ簭涓嶆槸OP05锛屽垯璁剧疆涓哄彲鐤戠姸鎬� + db_info.QualityState = (int)QualityStateEnum.Suspected; + db_info.QualityErrorInfo = $"宸ヤ欢浜岀淮鐮佺涓�娆″嚭鐜扮殑宸ュ簭{logMiddle.MonitoringPoint}涓嶆槸OP05,鏁版嵁缂哄け,璇风‘璁ゆ儏鍐靛苟鍋氱浉搴斿鐞嗭紒"; + db_info.Remarks = $"宸ヤ欢浜岀淮鐮佺涓�娆″嚭鐜扮殑宸ュ簭{logMiddle.MonitoringPoint}涓嶆槸OP05,鏁版嵁缂哄け,璇风‘璁ゆ儏鍐靛苟鍋氱浉搴斿鐞嗭紒"; + } + else + { + db_info.QualityState = (int)QualityStateEnum.OK;//姝ゅ闇�瑕佹敞鎰忥紝鍒ゆ柇鎵�鏈夊伐搴忚川閲忥紝鐒跺悗鍐嶈祴鍊� //榛樿鍚堟牸锛孫P05榛樿鏄悎鏍� + db_info.Remarks = "OP05鏂板宸ヤ欢淇℃伅"; + } + db_info.WorkPieceinitOnlineTime = DateTimeHelper.GetDateTime();//WorkPieceInitOnlineTime + db_info.WorkingProcedurePlan = ConfigHelper.GetConfigString("WorkingProcedureAllStr") ?? "OP05OP10OP20OP30OP35OP40OP50OP60OP70OP80"; + db_info.CreatedUserName = logMiddle.MonitoringPoint; + SystemBussinessHelper.SetWorkPieceInfoMiddleForCreatedUserName(ref db_info, logMiddle.DataCapturePointCname); + db_info.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + db_info.WorkingProcedureCurrent = logMiddle.WorkingProcedure; + db_info.WorkingProcedureEndTime = null; + db_info = WorkPieceInfoManager.ParseQRCode(db_info); + isAddWorkPieceInfo = true; + } + if (logMiddle.WorkingProcedure.Equals("OP10")) + { + //var WorkingProcedure = (loginfo.MonitoringPoint.Equals("OP1002") ? "OP10" : "OP40"); + loginfo2.WorkingProcedure = db_info.WorkingProcedureCurrent;//瑙e喅OP10锛孫P40鍚屼竴涓殑闂 + logMiddle.WorkingProcedure = db_info.WorkingProcedureCurrent; //瑙e喅OP10锛孫P40鍚屼竴涓殑闂 + } + + db_info.WorkingProcedureCurrent = logMiddle.WorkingProcedure;//璧嬪�兼渶鏂板伐搴� 銆怑ditby shaocx,2024-09-03銆� + db_info.UpdatedUserName = logMiddle.MonitoringPoint; + SystemBussinessHelper.SetWorkPieceInfoMiddleForUpdateDataCapturePointCname(ref db_info, logMiddle.DataCapturePointCname); + db_info.UpdatedTime = DateTimeHelper.GetDateTime(); + db_info.WorkingProcedureCompleted = db_info.WorkingProcedureCompleted + logMiddle.WorkingProcedure;//宸插畬鎴愬伐搴� + if (!(db_info.WorkingProcedureStartTime.HasValue && db_info.WorkingProcedureStartTime > DateTime.Parse("1900/01/01"))) + {//鑻ヤ竴鐩存病鏈夊伐搴忓紑濮嬫椂闂达紝鍒欒祴鍊煎綋鍓嶆椂闂� + db_info.WorkingProcedureStartTime = DateTimeHelper.GetDateTime(); + } + db_info.WorkingProcedureEndTime = DateTimeHelper.GetDateTime(); + db_info.WorkPieceCurrentPositionOrder = db_info.WorkingProcedurePlan.IndexOf(logMiddle.WorkingProcedure) / 2; + db_info.Remarks = $"{logMiddle.WorkingProcedure}宸ュ簭瀹屾垚"; + long op80id = 0; + if (logMiddle.WorkingProcedure.Equals("OP80")) + { + db_info.WorkPieceState = (int)WorkPieceState.FinishedProducts; + db_info.WorkPieceLastOfflineTime = DateTimeHelper.GetDateTime(); + db_info.WorkPieceCurrentPosition = "OP80"; + db_info.CompleteTime = DateTimeHelper.GetDateTime(); + db_info.OP80NewCode = logMiddle.OP80NewCode; + + //璐ㄦ鏁版嵁鏀逛负 鑾峰彇鏂囦欢鍚庝慨鏀� 銆怑ditby shaocx,2024-06-15銆� + /* + info.QualityState = (int)((loginfo.QualityStateStr.Equals("OK") || loginfo.QualityStateStr.Equals("0K")) ? QualityState.OK : QualityState.NG); + loginfo.QualityState = info.QualityState; + info.QualityStateUpdateUser = loginfo.UpdatedUserName; + info.QualityStateUpdateTime = loginfo.UpdatedTime.Value.LocalDateTime; + info.QualityStateUpdateMode = QualityStateUpdateMode.Auto.ToString(); + //*/ + + + var qualityData = db.QualityDataInfo.Where(o => o.WorkPieceID == logMiddle.WorkPieceID).FirstOrDefault(); + if (qualityData == null || qualityData.WorkPieceID.Length < 1 || qualityData.WorkingProcedure.Length < 1) + {//鎻掑叆QualityDataInfo琛� + qualityData = EntityPropHelper.Mapper<QualityDataInfo, WorkPieceLog>(logMiddle); + db.QualityDataInfo.Add(WorkPieceInfoManager.GetAddQualityDataInfo(qualityData)); + } + //淇敼QualityDataInfo琛� //閲嶅鏀跺埌璐ㄩ噺淇℃伅锛屼細瑕嗙洊涔嬪墠鐨� + EntityPropHelper<WorkPieceLogMiddle, QualityDataInfo>.CopyProp(logMiddle, qualityData, WorkPieceInfoManager.GetQualityDataInfoUpdate(logMiddle, logMiddle.WorkingProcedure, logMiddle.MonitoringPoint));//鎸囧畾淇敼瀛楁 + + //璐ㄦ鏁版嵁鏀逛负 鑾峰彇鏂囦欢鍚庝慨鏀� 銆怑ditby shaocx,2024-06-15銆� + /* + qualityData.QualityStateUpdateUser = info.UpdatedUserName; + qualityData.QualityReceiveTime = info.UpdatedTime.Value.LocalDateTime; + qualityData.QualityStateUpdateMode = info.QualityStateUpdateMode; + qualityData.OP80QualityState = loginfo.QualityState.HasValue ? loginfo.QualityState.Value.ToString() : "3"; + qualityData.OP80QualityReceiveTime = DateTimeHelper.GetDateTime(); + qualityData.OP80QualityFilePath = loginfo.OP80QualityFilePath; + op80id = qualityData.Id; + loginfo2.Remarks = (loginfo2.Remarks ?? "") + $"璐ㄩ噺锛歿loginfo.QualityStateStr ?? "绌�"}"; + if (!info.QualityState.Equals(((int)QualityState.OK).ToString())) + { + info.QualityErrorInfo = $"{loginfo.WorkingProcedure}宸ュ簭璐ㄩ噺閲囬泦鏁版嵁涓嶅悎鏍�"; + } + else + { + info.QualityErrorInfo = ""; + } + //*/ + + loginfo2.Remarks = $"娴嬮噺鍚堟牸鐘舵��:{logMiddle.St3_Means_OK},绉伴噸鐘舵��:{logMiddle.St4_Weight_OK}"; + } + else if (logMiddle.WorkingProcedure.Equals("OP30")) + { + + db_info.QualityState = (int)((logMiddle.QualityStateStr.Equals("OK") || logMiddle.QualityStateStr.Equals("0K")) ? QualityStateEnum.OK : QualityStateEnum.NG); + logMiddle.QualityState = db_info.QualityState; + db_info.QualityStateUpdateUser = logMiddle.UpdatedUserName; + db_info.QualityStateUpdateTime = logMiddle.UpdatedTime.Value.LocalDateTime; + db_info.QualityStateUpdateMode = QualityStateUpdateMode.Auto.ToString(); + + var qualityData = db.QualityDataInfo.Where(o => o.WorkPieceID == logMiddle.WorkPieceID).FirstOrDefault(); + if (qualityData == null || qualityData.WorkPieceID.Length < 1 || qualityData.WorkingProcedure.Length < 1) + {//鎻掑叆QualityDataInfo琛� + qualityData = EntityPropHelper.Mapper<QualityDataInfo, WorkPieceLog>(logMiddle); + db.QualityDataInfo.Add(WorkPieceInfoManager.GetAddQualityDataInfo(qualityData)); + } + qualityData.QualityStateUpdateUser = db_info.UpdatedUserName; + qualityData.QualityReceiveTime = db_info.UpdatedTime.Value.LocalDateTime; + qualityData.QualityStateUpdateMode = db_info.QualityStateUpdateMode; + qualityData.OP30QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; + qualityData.OP30QualityReceiveTime = DateTimeHelper.GetDateTime(); + loginfo2.Remarks = (loginfo2.Remarks ?? "") + $"璐ㄩ噺锛歿logMiddle.QualityStateStr ?? "绌�"}"; + if (!db_info.QualityState.Equals(((int)QualityStateEnum.OK).ToString())) + { + db_info.QualityErrorInfo = $"{logMiddle.WorkingProcedure}宸ュ簭璐ㄩ噺閲囬泦鏁版嵁涓嶅悎鏍�"; + } + else + { + db_info.QualityErrorInfo = ""; + } + } + else + { + //杩欓噷淇OP10銆丱P40 鍥犱负PLC鍏堟帹 SPC鎺ㄥ嚭銆佸啀鎺� 浜у搧涓嬬嚎闂锛屽鑷� 浜у搧涓嬬嚎鏇存柊鏁版嵁鏃讹紝鎶奡PC鏁版嵁瑕嗙洊鐨勯棶棰� 銆怑ditby shaocx,2024-08-27銆� + var isAlow = SystemBussinessHelper.IsAllowUpdateWorkPieceStateToWip(db_info, db, logMiddle); + if (isAlow) + { + db_info.WorkPieceState = (int)WorkPieceState.WIP; + } + + + if (db_info.WorkingProcedurePlan.IndexOf(logMiddle.WorkingProcedure) + 4 <= db_info.WorkingProcedurePlan.Length) + { + db_info.WorkPieceCurrentPosition = db_info.WorkingProcedurePlan.Substring(db_info.WorkingProcedurePlan.IndexOf(logMiddle.WorkingProcedure), 8); + } + } + + var pro = db.WorkPieceProcess.Where(o => o.WorkPieceID == logMiddle.WorkPieceID + && o.WorkingProcedureCurrent == db_info.WorkingProcedureCurrent + && o.OperationType == OperationType.鐢熶骇.ToString()).OrderByDescending(o => o.StartTime).FirstOrDefault(); + if (pro == null || pro.WorkPieceID.Length < 1) + { + WorkPieceProcess add_process = new WorkPieceProcess(); + add_process = EntityPropHelper.Mapper<WorkPieceProcess, WorkPieceInfo>(db_info); + QualityStateHelper.ResetQualityNoOkForNewProcess(ref add_process); + add_process.Id = Yitter.IdGenerator.YitIdHelper.NextId(); + add_process.StartTime = DateTimeHelper.GetDateTime().AddSeconds(-SystemBussinessHelper.MoNiTimeForWorkingProcedure(logMiddle.WorkingProcedure)); + add_process.EndTime = DateTimeHelper.GetDateTime(); + if (logMiddle.WorkingProcedure.Equals("OP80")) + {//OP80鐨勮川閲忔暟鎹槸鍚庢潵鑾峰彇鏂囦欢鎼炵殑 + //璐ㄦ鏁版嵁锛屽啀鑰冭檻 鍙﹀涓ょ鐘舵�� 銆怑ditby shaocx,2024-08-27銆� + QualityStateHelper.SetQualityStateForOP80(logMiddle, ref db_info, ref add_process); + } + else + { + //涓嶅啀榛樿璧嬪�间负鍚堟牸 銆怑ditby shaocx,2024-08-16銆� + //process.QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value : (int)QualityState.OK;//榛樿鍚堟牸锛屽凡澶勭悊 + add_process.QualityState = WorkPieceInfoManager.GetQualityStateValue(logMiddle.QualityState); + } + add_process.CreatedUserName = logMiddle.MonitoringPoint; + add_process.DataCapturePointCname = logMiddle.DataCapturePointCname; + add_process.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + add_process.UpdatedUserName = logMiddle.MonitoringPoint; + add_process.UpdateDataCapturePointCname = logMiddle.DataCapturePointCname; + add_process.UpdatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); + add_process.OperationType = OperationType.鐢熶骇.ToString(); + add_process.Remarks = ""; + add_process.MyRemarks = "宸ュ簭瀹屾垚鏃讹紝濡傛灉鎵句笉鍒板氨鏂板缓"; + if (logMiddle.WorkingProcedure.Equals("OP80")) + { + add_process.GetQcDataFlag = logMiddle.GetQcDataFlag;//璧嬪�兼爣璁� [Editby shaocx,2024-06-15] + } + if (op80id > 0) + { + add_process.QualityDataInfoID = op80id; + } + db.WorkPieceProcess.Add(add_process); + } + else + { + if (logMiddle.WorkingProcedure.Equals("OP80")) + {//OP80鐨勮川閲忔暟鎹槸鍚庢潵鑾峰彇鏂囦欢鎼炵殑 + //璐ㄦ鏁版嵁锛屽啀鑰冭檻 鍙﹀涓ょ鐘舵�� 銆怑ditby shaocx,2024-08-27銆� + QualityStateHelper.SetQualityStateForOP80(logMiddle, ref db_info, ref pro); + } + if (op80id > 0) + { + pro.QualityDataInfoID = op80id; + } + pro.EndTime = DateTimeHelper.GetDateTime(); + pro.UpdatedUserName = logMiddle.MonitoringPoint; + pro.UpdateDataCapturePointCname = logMiddle.DataCapturePointCname; + pro.UpdatedTime = DateTimeHelper.GetDateTime(); + if (logMiddle.WorkingProcedure.Equals("OP80")) + { + if (pro.GetQcDataFlag != 0) + { + pro.GetQcDataFlag = logMiddle.GetQcDataFlag;//璧嬪�兼爣璁� [Editby shaocx,2024-06-15] + } + } + } + + + if (isAddWorkPieceInfo) + { + db.WorkPieceInfo.Add(db_info); + } + db.WorkPieceInfoLog.Add(WorkPieceInfoManager.GetAddWorkPieceInfoLog(db_info)); + } + else + { + loginfo2.Remarks = $"涓嬬嚎瀹屾垚璇诲彇浜岀淮鐮亄logMiddle.WorkPieceID ?? "绌�"}寮傚父"; + Log4NetHelper.WriteErrorLog(type, $" {logMiddle.WorkingProcedure}宸ュ簭涓嬬嚎 璇诲彇宸ヤ欢鐮佹暟鎹甗{logMiddle.WorkPieceID ?? "绌�"}]鏃跺紓甯革細"); + + } + } + catch (Exception e) + { + loginfo2.Remarks = $"璇诲彇浜岀淮鐮亄logMiddle.WorkPieceID ?? "绌�"}鏇存柊鏁版嵁寮傚父{e.Message}"; + } + db.WorkPieceLog.Add(WorkPieceInfoManager.GetAddWorkPieceLog(loginfo2));//鎻掑叆宸ヤ欢閲囬泦鏃ュ織琛� + db.SaveChanges(); + } + } + } +} diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/WorkPieceInfoManager.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/WorkPieceInfoManager.cs index b0bf5f0..e01949f 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/WorkPieceInfoManager.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/WorkPieceInfoManager.cs @@ -156,267 +156,7 @@ } } - /// <summary> - /// 璇诲彇浜岀淮鐮佹椂閫昏緫 - /// 鏍¢獙宸ヤ欢鏄惁璺冲簭锛岃川閲忔槸鍚﹀悎鏍� - /// </summary> - public static void ReadQRcode(WorkPieceLog loginfo, LogType type, PLCService plcService, int? IsFeedback) - {//姝ゅ鍚屾椂鎻掑叆浜哤orkPieceLog锛學orkPieceInfoLog琛紝骞舵柊澧炴垨淇敼WorkPieceInfo琛� - using (DbModel db = new DbModel()) - { - try - { - bool isAddWorkPieceInfo = false; - if (loginfo.WorkPieceID.Length == 22) - { - WorkPieceInfo info = new WorkPieceInfo(); - info = db.WorkPieceInfo.Where(o => o.WorkPieceID == loginfo.WorkPieceID).FirstOrDefault(); - if (info == null || info.WorkPieceID.Length < 1) - {//鎻掑叆WorkPieceInfo琛� - loginfo = CommonManager.Instance.GetWorkPieceID(loginfo, type); - info = EntityPropHelper.Mapper<WorkPieceInfo, WorkPieceLog>(loginfo); - //EntityPropHelper<WorkPieceLog, WorkPieceInfo>.CopyProp(loginfo, info, loginfo.GetWorkPieceInfoDict()); - if (!loginfo.WorkingProcedure.Equals("OP05")) - {//褰撳伐浠朵簩缁寸爜绗竴娆″嚭鐜扮殑宸ュ簭涓嶆槸OP05锛屽垯璁剧疆涓哄彲鐤戠姸鎬� - info.QualityState = (int)QualityStateEnum.Suspected; - info.QualityErrorInfo = $"宸ヤ欢浜岀淮鐮佺涓�娆″嚭鐜扮殑宸ュ簭{loginfo.MonitoringPoint}涓嶆槸OP05,鏁版嵁缂哄け,璇风‘璁ゆ儏鍐靛苟鍋氱浉搴斿鐞嗭紒"; - info.Remarks = $"宸ヤ欢浜岀淮鐮佺涓�娆″嚭鐜扮殑宸ュ簭{loginfo.WorkingProcedure}涓嶆槸OP05,鏁版嵁缂哄け,璇风‘璁ゆ儏鍐靛苟鍋氱浉搴斿鐞嗭紒"; - } - else - {//OP05宸ュ簭 - info.QualityState = (int)QualityStateEnum.OK;//姝ゅ闇�瑕佹敞鎰忥紝鍒ゆ柇鎵�鏈夊伐搴忚川閲忥紝鐒跺悗鍐嶈祴鍊� //榛樿鍚堟牸锛孫P05榛樿鏄悎鏍� - info.Remarks = "OP05鏂板宸ヤ欢淇℃伅"; - } - info.WorkPieceinitOnlineTime = DateTimeHelper.GetDateTime(); - info.WorkingProcedurePlan = ConfigHelper.GetConfigString("WorkingProcedureAllStr") ?? "OP05OP10OP20OP30OP35OP40OP50OP60OP70OP80"; - info.CreatedUserName = loginfo.MonitoringPoint; - info.WorkingProcedureCurrent = loginfo.WorkingProcedure;//宸ュ簭璧嬪�� - SystemBussinessHelper.SetWorkPieceInfoMiddleForCreatedUserName(ref info, loginfo.DataCapturePointCname); - info.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - info = ParseQRCode(info); - isAddWorkPieceInfo = true; - } - else - { - //瀛樺湪 琛� WorkPieceInfo鏈夛紝浣嗘槸 WorkPieceProcess杩欎釜宸ュ簭涓嶅瓨鍦ㄧ殑鎯呭喌 銆怑ditby shaocx,2024-09-06銆� - //if (info.WorkingProcedureCurrent.Equals("OP05")) - //{ - // loginfo.Remarks = $"璇诲彇浜岀淮鐮亄loginfo.WorkPieceID ?? "绌�"} OP05宸ュ簭閲嶅璇诲彇浜�"; - // return; - //} - } - if ((loginfo.WorkingProcedure.Equals("OP05") && isAddWorkPieceInfo == false)) - {//瀛樺湪 琛� WorkPieceInfo鏈夛紝浣嗘槸 WorkPieceProcess杩欎釜宸ュ簭涓嶅瓨鍦ㄧ殑鎯呭喌 - //濡傛灉鏄疧P05鐨勶紝骞朵笖鏄� 涓嶉渶瑕佹柊澧� 琛╓orkPieceInfo锛岄偅涔堝氨涓嶉渶瑕佹洿鏂拌〃 WorkPieceInfo - } - else - { - info.WorkingProcedureStartTime = DateTimeHelper.GetDateTime();// - info.WorkingProcedureEndTime = null; - info.WorkPieceState = (int)WorkPieceState.WIP; - info.EquipmentID = loginfo.EquipmentID; - info.QualityStateUpdateUser = loginfo.UpdatedUserName; - info.QualityStateUpdateTime = loginfo.UpdatedTime.Value.LocalDateTime; - info.QualityStateUpdateMode = QualityStateUpdateMode.Auto.ToString(); - info.UpdatedUserName = loginfo.MonitoringPoint; - SystemBussinessHelper.SetWorkPieceInfoMiddleForUpdateDataCapturePointCname(ref info, loginfo.DataCapturePointCname); - info.UpdatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - - info.WorkPieceCurrentPosition = loginfo.WorkingProcedure; - info.WorkPieceCurrentPositionOrder = info.WorkingProcedurePlan.IndexOf(loginfo.WorkingProcedure) / 2; - info.WorkingProcedureCurrent = loginfo.WorkingProcedure;//宸ュ簭璧嬪�� - info.Remarks = $"{info.WorkingProcedureCurrent}宸ヤ欢涓婄嚎"; - } - - - //淇涓� op35 鍚屼竴涓欢 涓嬬嚎鏃堕棿璺熶笅涓�涓笂绾挎椂闂翠竴妯′竴鏍风殑闂 銆怑ditby shaocx,2024-08-27銆� - var isNeedAddNewProcess = true; - - //鐗规畩澶勭悊OP05涓婄嚎锛屽洜涓轰粬鏄牴鎹枃鏈垪琛ㄥ唴瀹逛笂绾跨殑 銆怑ditby shaocx,2024-09-03銆� - if (loginfo.WorkingProcedure.Equals("OP05")) - { - var op05Proccss = db.WorkPieceProcess.Where(o => o.WorkPieceID == loginfo.WorkPieceID && o.WorkingProcedureCurrent == loginfo.WorkingProcedure).FirstOrDefault(); - if (op05Proccss != null) - { - isNeedAddNewProcess = false;//涓嶉渶瑕佹柊澧炰簡 - } - } - else - { - var pro = db.WorkPieceProcess.Where(o => o.WorkPieceID == loginfo.WorkPieceID && !o.OperationType.Equals("SPC") && (o.EndTime == null || o.EndTime <= DateTime.MinValue)).OrderByDescending(o => o.StartTime).FirstOrDefault(); - if (pro != null && pro.WorkPieceID.Length > 1) - { - if (pro.WorkingProcedureCurrent == loginfo.WorkingProcedure) - {//琛ㄧず宸ュ簭鐩稿悓 - isNeedAddNewProcess = false; - pro.Remarks = "鍙堜竴娆′笂绾匡紝鏇存柊缁撴潫鏃堕棿"; - } - else - { - pro.EndTime = DateTimeHelper.GetDateTime(); - pro.UpdatedUserName = loginfo.MonitoringPoint; - pro.UpdateDataCapturePointCname = loginfo.DataCapturePointCname; - pro.UpdatedTime = DateTimeHelper.GetDateTime(); - pro.Remarks = "鍙堜竴娆′笂绾匡紝鏇存柊缁撴潫鏃堕棿"; - } - } - } - if (isNeedAddNewProcess) - { - //姣忔鎵弿涓婄嚎閮芥彃鍏ヨ拷婧〃 - WorkPieceProcess new_process = new WorkPieceProcess(); - new_process = EntityPropHelper.Mapper<WorkPieceProcess, WorkPieceInfo>(info); - QualityStateHelper.ResetQualityNoOkForNewProcess(ref new_process); - new_process.StartTime = DateTimeHelper.GetDateTime(); - - //涓嶅啀榛樿璧嬪�间负鍚堟牸 銆怑ditby shaocx,2024-08-16銆� - //process.QualityState = info.QualityState.HasValue ? info.QualityState.Value : (int)QualityState.OK;//榛樿鍚堟牸锛屽凡澶勭悊 - new_process.QualityState = GetQualityStateValue(info.QualityState); - - if (new_process.WorkingProcedureCurrent == WorkingProcedureForHMI.OP70.ToString()) - { //鐗规畩澶勭悊OP70锛屽洜涓篛P70娌℃湁娴嬮噺锛岄粯璁ゅ悎鏍� [Editby shaocx,2024-07-03] - new_process.QualityState = (int)QualityStateEnum.OK;//榛樿鍚堟牸锛孫P70榛樿鏄悎鏍� - } - - new_process.Id = Yitter.IdGenerator.YitIdHelper.NextId(); - new_process.CreatedUserName = loginfo.MonitoringPoint; - new_process.DataCapturePointCname = loginfo.DataCapturePointCname; - new_process.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - new_process.UpdatedUserName = loginfo.MonitoringPoint; - new_process.UpdateDataCapturePointCname = loginfo.DataCapturePointCname; - new_process.UpdatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - new_process.OperationType = OperationType.鐢熶骇.ToString(); - new_process.Remarks = ""; - new_process.MyRemarks = "璇荤爜涓婄嚎鏃讹紝姣忔鎵弿涓婄嚎閮芥彃鍏ヨ拷婧〃"; - if (loginfo.WorkingProcedure.Equals("OP05")) - {//鐗规畩澶勭悊OP05宸ュ簭 - new_process.EndTime = new_process.StartTime; - - //濡傛灉宸茬粡瀛樺湪鍏朵粬宸ュ簭锛岄偅涔堝氨蹇呴』瑕佹寜鐓у叾浠栧伐搴忕殑鏃堕棿寰�鍓嶆帹鏁版嵁 銆怑ditby shaocx,2024-09-05銆� - var op05OtherProccss = db.WorkPieceProcess.Where(o => o.WorkPieceID == loginfo.WorkPieceID).OrderBy(x => x.StartTime).FirstOrDefault(); - if (op05OtherProccss != null) - {//璇存槑鏈夛紝閭d箞鏃堕棿灏辨寜鐓ц繖涓椂闂村線鍓嶆帹 - var _time = op05OtherProccss.StartTime.AddHours(-1); - new_process.StartTime = _time; - new_process.EndTime = _time; - new_process.CreatedTime = _time; - new_process.UpdatedTime = _time; - } - } - db.WorkPieceProcess.Add(new_process); - } - //db.Database.AutoTransactionsEnabled = false;// 鍚屼竴涓猄aveChanges榛樿浜嬪姟锛� 鍏抽棴榛樿浜嬪姟锛�... 濂藉儚涓嶈兘鐢ㄥ晩锛屽悗闈㈠啀鐮旂┒鍚� - if (isAddWorkPieceInfo) - { - db.WorkPieceInfo.Add(info); - } - else - {//涓嶇‘瀹歩nfo鏄洿鎺ヤ細淇敼杩樻槸闇�瑕佸啀娆℃煡璇紝寰呮祴璇� - //info.Remarks = "淇敼锛屽叿浣撲慨鏀归�昏緫寰呭畾"; - } - - #region 鍒ゆ柇鏄惁璺冲簭,鎴栬川閲忎笉绗﹀悎 鐒跺悗鍙嶉PLC - /* - if (IsFeedback.HasValue && IsFeedback.Value == (int)FeedbackMode.FeedbackPLC) - { - bool checkQualityInfoCompleteFlag = false; - bool plcFlag = true;//鍙嶉缁橮LC鐨勬爣璁� - string message = ""; - checkQualityInfoCompleteFlag = WorkPieceInfoManager.CheckQualityInfoComplete(info, loginfo, type); - - if (!checkQualityInfoCompleteFlag || info.QualityState != (int)QualityStateEnum.OK) - { - plcFlag = false; - message = !checkQualityInfoCompleteFlag ? "璺冲簭锛�" : ""; - message += info.QualityState != (int)QualityStateEnum.OK ? "璐ㄩ噺涓嶇鍚�" : ""; - } - - } - else - {//璇荤爜瀹屾垚鑻ュ伐浠惰川閲忎笉绗﹀悎鎴栧彂鐢熻烦搴忥紝涓嶇敤绠¤澶囨槸鍚︽妸宸ヤ欢鏀捐繃鍘伙紝鏁伴噰绯荤粺閮戒笉鍙樻洿褰撳墠宸ュ簭锛屽弽棣堣澶嘝LC宸ヤ欢涓嶇鍚堬紝 - //鑻ュ伐搴忓悗缁敹闆嗙偣鏀跺埌鐩稿叧宸ヤ欢淇℃伅鍐嶅彉鏇村綋鍓嶅伐搴忥紝 浣嗚川閲忎俊鎭笉鍙� - - info.WorkingProcedureCurrent = loginfo.WorkingProcedure; - } - //*/ - #endregion - - #region 鏇存柊璁惧瀹炴椂琛� - - bool isAddEquipmentCurrentMonitor = false; - EquipmentCurrentMonitor equinfo = new EquipmentCurrentMonitor(); - equinfo = db.EquipmentCurrentMonitor.Where(o => o.EquipmentID == loginfo.EquipmentID).FirstOrDefault(); - if (equinfo == null || equinfo.Id < 1) - {//娌℃湁宸ヤ欢淇℃伅锛屼笉鍋氭洿鏂� - Log4NetHelper.WriteErrorLog(type, $"璁惧{loginfo.EquipmentID} 鍛婅鐩戞帶{loginfo.WorkingProcedure} 娌℃湁鑾峰彇鍒拌澶囩洃鎺т俊鎭紝鐜版柊澧�"); - equinfo = EntityPropHelper.Mapper<EquipmentCurrentMonitor, WorkPieceLog>(loginfo); - equinfo.OnlineTime = DateTime.Now; - isAddEquipmentCurrentMonitor = true; - } - else - {//鏇存柊宸ヤ欢 - equinfo.WorkPieceID = loginfo.WorkPieceID; - equinfo.UpdatedUserName = loginfo.MonitoringPoint; - equinfo.UpdatedTime = DateTime.Now; - equinfo.OnlineTime = DateTime.Now; - } - if (isAddEquipmentCurrentMonitor) - { - equinfo.Id = Yitter.IdGenerator.YitIdHelper.NextId(); - db.EquipmentCurrentMonitor.Add(equinfo); - } - #endregion - //db.WorkPieceLog.Add(GetAddWorkPieceLog(loginfo)); - db.WorkPieceInfoLog.Add(GetAddWorkPieceInfoLog(info)); - //UpdateKnifeToolLift(db, loginfo);//鏇存柊鍒�鍏峰鍛戒俊鎭� - } - else - { - loginfo.Remarks = $"涓婄嚎瀹屾垚璇诲彇浜岀淮鐮亄loginfo.WorkPieceID ?? "绌�"}寮傚父"; - Log4NetHelper.WriteErrorLog(type, $" {loginfo.WorkingProcedure}涓婄嚎鐩戞帶璇荤爜鏍囪 璇诲彇宸ヤ欢鐮佹暟鎹甗{loginfo.WorkPieceID ?? "绌�"}]鏃跺紓甯革細"); - - } - } - catch (Exception e) - { - loginfo.Remarks = $"璇诲彇浜岀淮鐮亄loginfo.WorkPieceID ?? "绌�"}鏇存柊鏁版嵁寮傚父{e.Message}"; - Log4NetHelper.WriteErrorLog(type, $" {loginfo.WorkingProcedure}涓婄嚎鐩戞帶璇荤爜鏍囪 璇诲彇宸ヤ欢鐮佹暟鎹甗{loginfo.WorkPieceID ?? "绌�"}]鏃跺紓甯革細", e); - } - finally - { - loginfo.Id = Yitter.IdGenerator.YitIdHelper.NextId(); - db.WorkPieceLog.Add(loginfo); - - //淇濆瓨鏁版嵁搴撶殑寮傚父鎹曟崏 [Editby shaocx,2024-08-29] - try - { - db.SaveChanges(); - } - catch (DbEntityValidationException exception) - { - var errorMessages = - exception.EntityValidationErrors - .SelectMany(validationResult => validationResult.ValidationErrors) - .Select(m => m.ErrorMessage); - var fullErrorMessage = string.Join(", ", errorMessages); - var exceptionMessage = string.Concat(exception.Message, " 楠岃瘉寮傚父娑堟伅鏄細", fullErrorMessage); - - Log4NetHelper.WriteErrorLog(type, $" {loginfo.WorkingProcedure}涓婄嚎鐩戞帶璇荤爜鏍囪 璇诲彇宸ヤ欢鐮佹暟鎹甗{loginfo.WorkPieceID ?? "绌�"}],淇濆瓨鏁版嵁搴撴椂寮傚父锛�" + exceptionMessage, exception); - - throw new DbEntityValidationException(exceptionMessage, exception.EntityValidationErrors); - } - catch (Exception) - { - - throw; - } - - - - } - - } - } + public static WorkPieceLogMiddle QualityDataHand(WorkPieceLogMiddle loginfo, List<EquipmentQualityConfig> qcofig) { try @@ -510,436 +250,7 @@ return loginfo; } - /// <summary> - /// 璐ㄩ噺妫�娴嬪畬鎴� - /// </summary> - /// <param name="logMiddle"></param> - /// <param name="type"></param> - public static void QualityInfoComplete(WorkPieceLogMiddle logMiddle, LogType type) - { - //鏍规嵁璐ㄩ噺鏁版嵁鍒ゆ柇鏄惁鍚堟牸/涓嶅悎鏍� 銆怑ditby shaocx,2024-06-25銆� - WorkPieceInfoManager.SetLogMiddleForQuality(ref logMiddle); - - //姝ゅ鍚屾椂鎻掑叆浜哤orkPieceLog锛學orkPieceInfoLog琛紝骞舵柊澧炴垨淇敼WorkPieceInfo琛� - //鎻掑叆璐ㄩ噺鐩稿叧琛≦ualityDataInfo - - using (DbModel db = new DbModel()) - { - - bool isAddWorkPieceInfo = false; - WorkPieceLog loginfo2 = new WorkPieceLog(); - loginfo2 = EntityPropHelper.Mapper<WorkPieceLog, WorkPieceLogMiddle>(logMiddle); - try - { - - if (logMiddle.WorkPieceID.Length == 22) - {//鑾峰彇鍒扮殑宸ヤ欢鍙峰紓甯� - WorkPieceInfo pieceInfo = new WorkPieceInfo(); - pieceInfo = db.WorkPieceInfo.Where(o => o.WorkPieceID == logMiddle.WorkPieceID).FirstOrDefault(); - if (pieceInfo == null || pieceInfo.WorkPieceID.Length < 1) - {//娌℃湁宸ヤ欢淇℃伅锛屼笉鍋氭洿鏂� - if (logMiddle.MonitoringPoint.Equals("OP1002") || logMiddle.MonitoringPoint.Equals("OP1003") || logMiddle.MonitoringPoint.Contains("OP2002")) - {//OP10 娌℃湁涓婄嚎鎵爜鏋紝绾﹀畾鐢ㄦ祴閲忓畬鎴愪俊鍙峰綋涓婄嚎鏍囪 - pieceInfo = EntityPropHelper.Mapper<WorkPieceInfo, WorkPieceLogMiddle>(logMiddle); - //EntityPropHelper<WorkPieceLog, WorkPieceInfo>.CopyProp(loginfo, info, loginfo.GetWorkPieceInfoDict()); - if (!logMiddle.WorkingProcedure.Equals("OP05")) - {//褰撳伐浠朵簩缁寸爜绗竴娆″嚭鐜扮殑宸ュ簭涓嶆槸OP05锛屽垯璁剧疆涓哄彲鐤戠姸鎬� - pieceInfo.QualityState = (int)QualityStateEnum.Suspected; - pieceInfo.QualityErrorInfo = $"宸ヤ欢浜岀淮鐮佺涓�娆″嚭鐜扮殑宸ュ簭{logMiddle.MonitoringPoint}涓嶆槸OP05,鏁版嵁缂哄け,璇风‘璁ゆ儏鍐靛苟鍋氱浉搴斿鐞嗭紒"; - pieceInfo.Remarks = $"宸ヤ欢浜岀淮鐮佺涓�娆″嚭鐜扮殑宸ュ簭{logMiddle.WorkingProcedure}涓嶆槸OP05,鏁版嵁缂哄け,璇风‘璁ゆ儏鍐靛苟鍋氱浉搴斿鐞嗭紒"; - } - else - { - pieceInfo.QualityState = (int)QualityStateEnum.OK;//姝ゅ闇�瑕佹敞鎰忥紝鍒ゆ柇鎵�鏈夊伐搴忚川閲忥紝鐒跺悗鍐嶈祴鍊� //榛樿鍚堟牸锛孫P05榛樿鏄悎鏍� - pieceInfo.Remarks = "OP05鏂板宸ヤ欢淇℃伅"; - } - pieceInfo.WorkPieceinitOnlineTime = DateTimeHelper.GetDateTime(); - pieceInfo.WorkingProcedurePlan = ConfigHelper.GetConfigString("WorkingProcedureAllStr") ?? "OP05OP10OP20OP30OP35OP40OP50OP60OP70OP80"; - pieceInfo.CreatedUserName = ResetUpdatedUserName(logMiddle); - SystemBussinessHelper.SetWorkPieceInfoMiddleForCreatedUserName(ref pieceInfo, logMiddle.DataCapturePointCname); - pieceInfo.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - pieceInfo.WorkingProcedureStartTime = DateTimeHelper.GetDateTime();// - pieceInfo.WorkingProcedureEndTime = null; - pieceInfo = ParseQRCode(pieceInfo); - isAddWorkPieceInfo = true; - - - } - else - { - loginfo2.Remarks = $"|宸ヤ欢{logMiddle.WorkPieceID} 璐ㄩ噺妫�娴嬪畬鎴愬伐搴弡logMiddle.MonitoringPoint} 娌℃湁鑾峰彇鍒板伐浠朵俊鎭笉鍋氭洿鏂�"; - Log4NetHelper.WriteErrorLog(type, $"宸ヤ欢{logMiddle.WorkPieceID} 璐ㄩ噺妫�娴嬪畬鎴愬伐搴弡logMiddle.MonitoringPoint} 娌℃湁鑾峰彇鍒板伐浠朵俊鎭笉鍋氭洿鏂�"); - return; - } - } - if (logMiddle.MonitoringPoint.Equals("OP1002") || logMiddle.MonitoringPoint.Equals("OP1003") || logMiddle.MonitoringPoint.Contains("OP2002")) - {// OP10 娌℃湁涓婄嚎鎵爜鏋紝绾﹀畾鐢ㄦ祴閲忓畬鎴愪俊鍙峰綋涓婄嚎鏍囪锛屾墍浠ヤ笂绾块渶瑕佷慨鏀圭殑瀛楁鏀捐繖閲� - - if (logMiddle.WorkingProcedure.Equals("OP10")) - { - var WorkingProcedure = (logMiddle.MonitoringPoint.Equals("OP1002") ? "OP10" : "OP40"); - loginfo2.WorkingProcedure = WorkingProcedure;//瑙e喅OP10锛孫P40鍚屼竴涓殑闂 - logMiddle.WorkingProcedure = WorkingProcedure;//瑙e喅OP10锛孫P40鍚屼竴涓殑闂 - } - pieceInfo.WorkPieceCurrentPosition = logMiddle.WorkingProcedure; - pieceInfo.WorkPieceCurrentPositionOrder = pieceInfo.WorkingProcedurePlan.IndexOf(logMiddle.WorkingProcedure) / 2; - pieceInfo.WorkingProcedureCurrent = logMiddle.WorkingProcedure; - pieceInfo.WorkingProcedureStartTime = DateTimeHelper.GetDateTime(); - - #region 鏇存柊璁惧瀹炴椂琛� - - bool isAddEquipmentCurrentMonitor = false; - EquipmentCurrentMonitor equinfo = new EquipmentCurrentMonitor(); - equinfo = db.EquipmentCurrentMonitor.Where(o => o.EquipmentID == logMiddle.EquipmentID).FirstOrDefault(); - if (equinfo == null || equinfo.Id < 1) - {//娌℃湁宸ヤ欢淇℃伅锛屼笉鍋氭洿鏂� - Log4NetHelper.WriteErrorLog(type, $"璁惧{logMiddle.EquipmentID} 鍛婅鐩戞帶{logMiddle.WorkingProcedure} 娌℃湁鑾峰彇鍒拌澶囩洃鎺т俊鎭紝鐜版柊澧�"); - equinfo = EntityPropHelper.Mapper<EquipmentCurrentMonitor, WorkPieceLog>(logMiddle); - equinfo.OnlineTime = DateTime.Now; - isAddEquipmentCurrentMonitor = true; - } - else - {//鏇存柊宸ヤ欢 - equinfo.WorkPieceID = logMiddle.WorkPieceID; - equinfo.UpdatedUserName = ResetUpdatedUserName(logMiddle); - equinfo.UpdatedTime = DateTime.Now; - equinfo.OnlineTime = DateTime.Now; - } - if (isAddEquipmentCurrentMonitor) - { - equinfo.Id = Yitter.IdGenerator.YitIdHelper.NextId(); - db.EquipmentCurrentMonitor.Add(equinfo); - } - #endregion - //UpdateKnifeToolLift(db, loginfo);//鏇存柊鍒�鍏峰鍛戒俊鎭� - } - - pieceInfo.WorkingProcedureCurrent = logMiddle.WorkingProcedure;//鏇存柊褰撳墠宸ュ簭 銆怑ditby shaocx,2024-09-03銆� - pieceInfo.WorkPieceState = (int)WorkPieceState.WIP;//鎺ㄥ嚭鍚庡拰SPC鎶芥鍚� 璐ㄩ噺褰曞叆鏃剁姸鎬佷慨鏀瑰洖鍦ㄥ埗鍝� - pieceInfo.EquipmentID = logMiddle.EquipmentID; - pieceInfo.QualityStateUpdateUser = logMiddle.UpdatedUserName; - pieceInfo.QualityStateUpdateTime = logMiddle.UpdatedTime.Value.LocalDateTime; - pieceInfo.QualityStateUpdateMode = QualityStateUpdateMode.Auto.ToString(); - pieceInfo.Remarks = $"{logMiddle.WorkingProcedure}璐ㄩ噺妫�娴嬪畬鎴愪慨鏀�"; - pieceInfo.UpdatedUserName = ResetUpdatedUserName(logMiddle); - SystemBussinessHelper.SetWorkPieceInfoMiddleForUpdateDataCapturePointCname(ref pieceInfo, logMiddle.DataCapturePointCname); - pieceInfo.UpdatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - if (!(pieceInfo.WorkingProcedureStartTime.HasValue && pieceInfo.WorkingProcedureStartTime > DateTime.Parse("1900/01/01"))) - {//宸ュ簭寮�濮嬫椂闂存病鏈夊垯璧嬪�� - pieceInfo.WorkingProcedureStartTime = DateTimeHelper.GetDateTime(); - } - pieceInfo.QualityState = (int)((logMiddle.QualityStateStr.Equals("OK") || logMiddle.QualityStateStr.Equals("0K")) ? QualityStateEnum.OK : QualityStateEnum.NG); - //璧嬪�间笉鍚堟牸鍘熷洜 - SetQualityNoOk_WorkPieceInfo(logMiddle, ref pieceInfo); - - - if (!pieceInfo.QualityState.Equals(((int)QualityStateEnum.OK).ToString())) - { - pieceInfo.QualityErrorInfo = $"{logMiddle.WorkingProcedure}宸ュ簭璐ㄩ噺閲囬泦鏁版嵁涓嶅悎鏍納pieceInfo.QualityState}"; - } - else - { - pieceInfo.QualityErrorInfo = ""; - } - logMiddle.QualityState = pieceInfo.QualityState; - if (isAddWorkPieceInfo) - { - db.WorkPieceInfo.Add(pieceInfo); - } - - #region 鏍规嵁鏍囧噯鍊兼洿鏂版渶鏂拌川閲忔暟鎹紙OP10/OP40/OP20/OP60锛� - var qcofig = db.EquipmentQualityConfig.Where(o => o.WorkingProcedure.Equals(logMiddle.WorkingProcedure) && o.ParamType != 1 && o.IsDeleted == false).ToList(); - if (qcofig.Count > 0) - { - QualityDataHand(logMiddle, qcofig); - } - #endregion - - - var qualityData = db.QualityDataInfo.Where(o => o.WorkPieceID == logMiddle.WorkPieceID).FirstOrDefault(); - if (qualityData == null || qualityData.WorkPieceID.Length < 1 || qualityData.WorkingProcedure.Length < 1) - {//鎻掑叆QualityDataInfo琛� - qualityData = EntityPropHelper.Mapper<QualityDataInfo, WorkPieceLog>(logMiddle); - db.QualityDataInfo.Add(GetAddQualityDataInfo(qualityData)); - } - //淇敼QualityDataInfo琛� //閲嶅鏀跺埌璐ㄩ噺淇℃伅锛屼細瑕嗙洊涔嬪墠鐨� - EntityPropHelper<WorkPieceLogMiddle, QualityDataInfo>.CopyProp(logMiddle, qualityData, GetQualityDataInfoUpdate(logMiddle, logMiddle.WorkingProcedure, logMiddle.MonitoringPoint));//鎸囧畾淇敼瀛楁 - - qualityData.QualityStateUpdateUser = pieceInfo.UpdatedUserName; - qualityData.QualityReceiveTime = pieceInfo.UpdatedTime.Value.LocalDateTime; - qualityData.QualityStateUpdateMode = pieceInfo.QualityStateUpdateMode; - if (logMiddle.WorkingProcedure.Equals("OP10")) - { - qualityData.OP10QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; - qualityData.OP10QualityReceiveTime = DateTimeHelper.GetDateTime(); - } - else if (logMiddle.WorkingProcedure.Equals("OP20")) - { - //Log4NetHelper.WriteErrorLog(type, $" {loginfo.WorkingProcedure}璐ㄩ噺淇℃伅銆恵loginfo.QualityStateStr ?? "绌�"}銆�" + - // $"銆恵(loginfo.QualityState.HasValue? loginfo.QualityState.Value:999)}銆戙�恵(info.QualityState.HasValue ? info.QualityState.Value : 888)}銆� 璇诲彇宸ヤ欢鐮佹暟鎹甗{loginfo.WorkPieceID ?? "绌�"}]"); - qualityData.OP20QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; - qualityData.OP20QualityReceiveTime = DateTimeHelper.GetDateTime(); - qualityData.OP20QualityFilePath = logMiddle.OP20QualityFilePath; - } - else if (logMiddle.WorkingProcedure.Equals("OP30")) - { - switch (logMiddle.MonitoringPoint) - { - case "OP3002CH3": - qualityData.OP30QualityFilePathCH3 = logMiddle.OP30QualityFilePathCH3; - qualityData.OP30QualityStateCH3 = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; - qualityData.OP30QualityReceiveTimeCH3 = DateTimeHelper.GetDateTime(); - - if (qualityData.OP30QualityStateCH3 == ((int)QualityStateEnum.NG).ToString()) - { - logMiddle.QualityNoOk = (int)QualityNoOkEnum.OP30娑ㄦ柇宸ヤ綅鍔涚煩瓒呭樊; - logMiddle.QualityNoOkReason = QualityNoOkEnum.OP30娑ㄦ柇宸ヤ綅鍔涚煩瓒呭樊.ToString(); - //璧嬪�间笉鍚堟牸鍘熷洜 - SetQualityNoOk_WorkPieceInfo(logMiddle, ref pieceInfo); - } - - break; - case "OP3002CH4": - qualityData.OP30QualityFilePathCH4 = logMiddle.OP30QualityFilePathCH4; - qualityData.OP30QualityStateCH4 = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; - qualityData.OP30QualityReceiveTimeCH4 = DateTimeHelper.GetDateTime(); - - if (qualityData.OP30QualityStateCH4 == ((int)QualityStateEnum.NG).ToString()) - { - logMiddle.QualityNoOk = (int)QualityNoOkEnum.OP30棰勬嫥绱у伐浣嶅姏鐭╄秴宸�; - logMiddle.QualityNoOkReason = QualityNoOkEnum.OP30棰勬嫥绱у伐浣嶅姏鐭╄秴宸�.ToString(); - //璧嬪�间笉鍚堟牸鍘熷洜 - SetQualityNoOk_WorkPieceInfo(logMiddle, ref pieceInfo); - } - - break; - case "OP3002CH5": - qualityData.OP30QualityFilePathCH5 = logMiddle.OP30QualityFilePathCH5; - qualityData.OP30QualityStateCH5 = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; - qualityData.OP30QualityReceiveTimeCH5 = DateTimeHelper.GetDateTime(); - - if (qualityData.OP30QualityStateCH5 == ((int)QualityStateEnum.NG).ToString()) - { - logMiddle.QualityNoOk = (int)QualityNoOkEnum.OP30缁堟嫥绱у伐浣嶅姏鐭╄秴宸�; - logMiddle.QualityNoOkReason = QualityNoOkEnum.OP30缁堟嫥绱у伐浣嶅姏鐭╄秴宸�.ToString(); - //璧嬪�间笉鍚堟牸鍘熷洜 - SetQualityNoOk_WorkPieceInfo(logMiddle, ref pieceInfo); - } - - break; - case "OP3002CH6": - qualityData.OP30QualityFilePathCH6 = logMiddle.OP30QualityFilePathCH6; - qualityData.OP30QualityStateCH6 = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; - qualityData.OP30QualityReceiveTimeCH6 = DateTimeHelper.GetDateTime(); - - if (qualityData.OP30QualityStateCH6 == ((int)QualityStateEnum.NG).ToString()) - { - logMiddle.QualityNoOk = (int)QualityNoOkEnum.OP30鍘嬭‖濂楀伐浣嶅姏鐭╄秴宸�; - logMiddle.QualityNoOkReason = QualityNoOkEnum.OP30鍘嬭‖濂楀伐浣嶅姏鐭╄秴宸�.ToString(); - //璧嬪�间笉鍚堟牸鍘熷洜 - SetQualityNoOk_WorkPieceInfo(logMiddle, ref pieceInfo); - } - - break; - default: - break; - } - //qualityData.OP30QualityState = loginfo.QualityState.HasValue ? loginfo.QualityState.Value.ToString() : "3"; - //qualityData.OP30QualityReceiveTime = DateTimeHelper.GetDateTime(); - } - else if (logMiddle.WorkingProcedure.Equals("OP35")) - { - qualityData.OP35QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; - qualityData.OP35QualityReceiveTime = DateTimeHelper.GetDateTime(); - } - else if (logMiddle.WorkingProcedure.Equals("OP40")) - { - qualityData.OP40QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; - qualityData.OP40QualityReceiveTime = DateTimeHelper.GetDateTime(); - } - else if (logMiddle.WorkingProcedure.Equals("OP60")) - { - qualityData.OP60QualityFilePath = logMiddle.OP60QualityFilePath; - qualityData.OP60QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; - qualityData.OP60QualityReceiveTime = DateTimeHelper.GetDateTime(); - } - else if (logMiddle.WorkingProcedure.Equals("OP80")) - { - qualityData.OP80QualityFilePath = logMiddle.OP80QualityFilePath; - qualityData.OP80QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; - qualityData.OP80QualityReceiveTime = DateTimeHelper.GetDateTime(); - } - - var pro = db.WorkPieceProcess.Where(o => o.WorkPieceID == logMiddle.WorkPieceID - //淇锛氭煡璇㈢殑宸ュ簭鏄綋鍓嶇嚎绋嬬殑宸ュ簭锛岃�屼笉鏄綋鍓嶆暟鎹殑宸ュ簭 銆怑ditby shaocx,2024-09-03銆� - //&& o.WorkingProcedureCurrent == pieceInfo.WorkingProcedureCurrent - && o.WorkingProcedureCurrent == logMiddle.WorkingProcedure - && o.OperationType == OperationType.鐢熶骇.ToString()).OrderByDescending(o => o.StartTime).FirstOrDefault(); - if (pro == null || pro.WorkPieceID.Length < 1 || logMiddle.MonitoringPoint.Equals("OP1002") || logMiddle.MonitoringPoint.Equals("OP1003") || logMiddle.MonitoringPoint.Contains("OP2002")) - {// OP10 娌℃湁涓婄嚎鎵爜鏋紝绾﹀畾鐢ㄦ祴閲忓畬鎴愪俊鍙峰綋涓婄嚎鏍囪锛屾墍浠ヤ笂绾块渶瑕佷慨鏀圭殑瀛楁鏀捐繖閲� - //涓婄嚎鏄瘡娆¢兘鎻掑叆 - - WorkPieceProcess process_05 = WorkPieceProcessHelper.CreateWorkPieceProcessForOP05(logMiddle, db, pieceInfo); - if (process_05 != null) - {//鍒涘缓OP05宸ュ簭锛屽綋娌℃湁05宸ュ簭鏃�,鎵嶅垱寤� 銆怑ditby shaocx,2024-08-29銆� - db.WorkPieceProcess.Add(process_05); - } - - WorkPieceProcess process = new WorkPieceProcess(); - process = EntityPropHelper.Mapper<WorkPieceProcess, WorkPieceInfo>(pieceInfo); - QualityStateHelper.ResetQualityNoOkForNewProcess(ref process); - process.StartTime = DateTimeHelper.GetDateTime(); - - //涓嶅啀榛樿璧嬪�间负鍚堟牸 銆怑ditby shaocx,2024-08-16銆� - //process.QualityState = pieceInfo.QualityState.HasValue ? pieceInfo.QualityState.Value : (int)QualityState.OK;//榛樿鍚堟牸锛屽凡澶勭悊 - process.QualityState = WorkPieceInfoManager.GetQualityStateValue(pieceInfo.QualityState); - - - //璁板綍璐ㄩ噺涓嶅悎鏍煎師鍥� 銆怑ditby shaocx,2024-06-26銆� - //璧嬪�间笉鍚堟牸鍘熷洜 - SetQualityNoOk_WorkPieceProcess(logMiddle, ref process); - - process.Id = Yitter.IdGenerator.YitIdHelper.NextId(); - process.CreatedUserName = ResetUpdatedUserName(logMiddle); - process.DataCapturePointCname = logMiddle.DataCapturePointCname; - process.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - process.UpdatedUserName = ResetUpdatedUserName(logMiddle); - process.UpdateDataCapturePointCname = logMiddle.DataCapturePointCname; - process.UpdatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - process.OperationType = OperationType.鐢熶骇.ToString(); - process.QualityDataInfoID = qualityData.Id; - process.Remarks = ""; - process.MyRemarks = "璐ㄩ噺妫�娴嬪畬鎴愭椂锛屽鏋滄壘涓嶅埌灏辨柊寤�"; - db.WorkPieceProcess.Add(process); - } - else - {//鍏朵粬鐨勯兘鍙槸淇敼 - pro.QualityDataInfoID = qualityData.Id; - pro.UpdatedUserName = ResetUpdatedUserName(logMiddle); - pro.UpdateDataCapturePointCname = logMiddle.DataCapturePointCname; - pro.UpdatedTime = DateTimeHelper.GetDateTime(); - - //涓嶅啀榛樿璧嬪�间负鍚堟牸 銆怑ditby shaocx,2024-08-16銆� - //pro.QualityState = pieceInfo.QualityState.HasValue ? pieceInfo.QualityState.Value : 9; - pro.QualityState = WorkPieceInfoManager.GetQualityStateValue(pieceInfo.QualityState); - - //璧嬪�间笉鍚堟牸鍘熷洜 - SetQualityNoOk_WorkPieceProcess(logMiddle, ref pro); - - //TODO:鍒ゆ柇濡傛灉鏄�60宸ュ簭锛岄偅涔堝氨瑕佹洿鏂皃ro琛ㄧ殑鍒涘缓浜轰负loginfo.MonitoringPoint 銆怑ditby shaocx,2024-06-05銆� - if (logMiddle.WorkingProcedure == "OP60") - { - pro.CreatedUserName = ResetUpdatedUserName(logMiddle); - pro.DataCapturePointCname = logMiddle.DataCapturePointCname; - } - } - - if (logMiddle.QualityType != null && logMiddle.QualityType.Equals(QualityType.SPC.ToString())) - {//SPC鍙嶉锛� - if (logMiddle.QualityState != (int)QualityStateEnum.OK) - { - //褰撴煇鍒板伐搴忔娴嬪埌涓嶅悎鏍煎伐浠舵椂锛屼粠璇ュ伐浠跺姞宸ュ畬鎴愭椂鍒诲墠鎸囧畾鏃堕棿璧疯嚦鎶ユ涓嶅悎鏍兼椂闂存锛岀郴缁熷皢璇ュ伐浠剁殑鏈�鍚庡姞宸ュ伐搴忓湪璇ユ椂闂存鍐呭姞宸ョ殑鎵�鏈夊伐浠躲�佹鍦ㄥ姞宸ョ殑宸ヤ欢銆佽宸ュ簭鍏ュ彛澶勭殑绗竴涓伐浠跺叏閮ㄦ爣璁颁负鐤戜技鐘舵�侊紝鐢变汉宸ュ妫�宸ヤ欢骞朵慨鏀圭姸鎬侊紝骞舵敮鎸佹壒閲忓彉鏇淬�� - //绛斿锛氬湪绾挎祴閲忎笉闇�瑕佽蛋杩欎釜娴佺▼锛屽彧鏈塖PC鎶芥鎵嶉渶瑕侊紝闇�瑕佹妸杩欐椂闂存鐨勫伐浠跺叏閮ㄧ疆涓虹枒浼硷紝鍝�曟槸宸插畬鎴愬伐浠� - //鏃堕棿娈佃捣濮嬫椂闂达細鎶芥宸ヤ欢鐢熶骇鏃堕棿鍓嶄竴SPC鎶芥鏃堕棿 - //鏃堕棿娈电粨鏉熸椂闂达細鎶芥宸ヤ欢璐ㄩ噺缁撴灉鍑虹幇鍚庣殑鏃堕棿 - //鎶芥宸ヤ欢宸ュ簭鎵弿鏋鍏ュ彛澶勭殑绗竴涓伐浠� 涔熸妸璐ㄩ噺鐘舵�佺疆涓虹枒浼� - //锛堟瘡涓�宸ュ簭SPC鎶芥鏄缃殑鍥哄畾鐨勶紝姣斿200鎶�4锛岀姸鎬佺疆涓虹枒浼兼椂鑻ュ伐浠惰繕鍦ㄨ澶囧唴锛屼細缁х画鐢熶骇瀹屾瘯鍚庢帓鍑猴級 - //鐩墠杩欏潡閫昏緫鏀惧埌浜� WebAPI涓簡 - - } - - } - db.WorkPieceInfoLog.Add(GetAddWorkPieceInfoLog(pieceInfo)); - db.QualityDataInfoLog.Add(GetAddQualityDataInfoLog(qualityData));//鎻掑叆鏃ュ織 - } - else - { - loginfo2.Remarks = $"璐ㄩ噺妫�娴嬪畬鎴愯鍙栦簩缁寸爜{logMiddle.WorkPieceID ?? "绌�"}寮傚父"; - Log4NetHelper.WriteErrorLog(type, $" {logMiddle.WorkingProcedure}宸ュ簭鐩戞帶璇荤爜鏍囪 璇诲彇宸ヤ欢鐮佹暟鎹甗{logMiddle.WorkPieceID ?? "绌�"}]鏃跺紓甯革細"); - - } - } - catch (Exception ex) - { - loginfo2.Remarks = $"璐ㄩ噺妫�娴嬪畬鎴�,鏇存柊鏁版嵁寮傚父{ex.Message}"; - Log4NetHelper.WriteErrorLog(type, $" {logMiddle.WorkingProcedure}璐ㄩ噺妫�娴嬪畬鎴� 宸ヤ欢鐮佹暟鎹甗{logMiddle.WorkPieceID ?? "绌�"}]鏃跺紓甯革細" + ex.Message, ex); - } - finally - { - loginfo2.Remarks = $"璐ㄩ噺锛歿logMiddle.QualityStateStr ?? "绌�"}"; - db.WorkPieceLog.Add(GetAddWorkPieceLog(loginfo2));//鎻掑叆宸ヤ欢閲囬泦鏃ュ織琛� - db.SaveChanges(); - } - } - } - - /// <summary> - /// 璐ㄩ噺妫�娴嬪畬鎴�-OP70涓撶敤 - /// </summary> - /// <param name="logMiddle"></param> - /// <param name="type"></param> - public static void QualityInfoCompleteForOP70(WorkPieceLogMiddle logMiddle, LogType type) - { - if (string.IsNullOrEmpty(logMiddle.QualityOP70To1) && string.IsNullOrEmpty(logMiddle.QualityOP70To2) && string.IsNullOrEmpty(logMiddle.QualityOP70To3)) - { - Log4NetHelper.WriteErrorLog(type, $" {logMiddle.WorkingProcedure}宸ュ簭鐩戞帶娓呮礂鏈烘暟鎹� 璇诲彇宸ヤ欢鐮佹暟鎹甗{logMiddle.WorkPieceID ?? "绌�"}]鑾峰彇鐨勪笁涓�奸兘鏄┖鐨勶紝涓嶅鐞嗚繑鍥�"); - return; - } - using (DbModel db = new DbModel()) - { - try - { - bool isAdd = false; - if (logMiddle.WorkPieceID.Length == 22) - { - var qualityData = db.QualityDataInfo.Where(o => o.WorkPieceID == logMiddle.WorkPieceID).FirstOrDefault(); - if (qualityData == null || qualityData.WorkPieceID.Length < 1 || qualityData.WorkingProcedure.Length < 1) - {//鎻掑叆QualityDataInfo琛� - isAdd = true; - qualityData = EntityPropHelper.Mapper<QualityDataInfo, WorkPieceLog>(logMiddle); - } - - qualityData.QualityStateUpdateUser = "OP7009"; - qualityData.QualityReceiveTime = DateTime.Now; - - //鐗规畩澶勭悊OP70鐨勮川閲忔暟鎹� - if (string.IsNullOrEmpty(qualityData.QualityOP70To1) && !string.IsNullOrEmpty(SystemHelper.GetStrForQualityOP70(logMiddle.QualityOP70To1))) - { - qualityData.QualityOP70To1 = logMiddle.QualityOP70To1; - } - if (string.IsNullOrEmpty(qualityData.QualityOP70To2) && !string.IsNullOrEmpty(SystemHelper.GetStrForQualityOP70(logMiddle.QualityOP70To2))) - { - qualityData.QualityOP70To2 = logMiddle.QualityOP70To2; - } - if (string.IsNullOrEmpty(qualityData.QualityOP70To3) && !string.IsNullOrEmpty(SystemHelper.GetStrForQualityOP70(logMiddle.QualityOP70To3))) - { - qualityData.QualityOP70To3 = logMiddle.QualityOP70To3; - } - - - db.QualityDataInfoLog.Add(GetAddQualityDataInfoLog(qualityData));//鎻掑叆鏃ュ織 - - if (isAdd) - { - db.QualityDataInfo.Add(GetAddQualityDataInfo(qualityData)); - } - db.SaveChanges();//淇濆瓨鏁版嵁 - } - else - { - Log4NetHelper.WriteErrorLog(type, $" {logMiddle.WorkingProcedure}宸ュ簭鐩戞帶娓呮礂鏈烘暟鎹� 璇诲彇宸ヤ欢鐮佹暟鎹甗{logMiddle.WorkPieceID ?? "绌�"}]鏃跺紓甯革細"); - - } - } - catch (Exception ex) - { - Log4NetHelper.WriteErrorLog(type, $" {logMiddle.WorkingProcedure}宸ュ簭鐩戞帶娓呮礂鏈烘暟鎹� 璇诲彇宸ヤ欢鐮佹暟鎹甗{logMiddle.WorkPieceID ?? "绌�"}]鏃跺紓甯革細", ex); - } - finally - { - } - } - } + /// <summary> /// 璧嬪�� 淇敼浜� 銆怑ditby shaocx,2024-07-05銆� @@ -955,268 +266,8 @@ return logMiddle.MonitoringPoint; } - /// <summary> - /// 宸ヤ欢鎺ㄥ嚭NOOK - /// </summary> - /// <param name="loginfo"></param> - /// <param name="type"></param> - public static void WorkPiecePushOff(WorkPieceLogMiddle loginfo, LogType type) - { - using (DbModel db = new DbModel()) - { - WorkPieceLog loginfo2 = new WorkPieceLog(); - loginfo2 = EntityPropHelper.Mapper<WorkPieceLog, WorkPieceLogMiddle>(loginfo); - try - { - if (loginfo.WorkPieceID != null && loginfo.WorkPieceID.Trim('\0').Length == 22) - { - WorkPieceInfo cur_db_info = new WorkPieceInfo(); - cur_db_info = db.WorkPieceInfo.Where(o => o.WorkPieceID == loginfo.WorkPieceID).FirstOrDefault(); - if (cur_db_info == null || cur_db_info.WorkPieceID.Length < 1) - {//娌℃湁宸ヤ欢淇℃伅锛屼笉鍋氭洿鏂� - Log4NetHelper.WriteErrorLog(type, $"宸ヤ欢{loginfo.WorkPieceID} 宸ヤ欢鎺ㄥ嚭NOOK宸ュ簭{loginfo.WorkingProcedure} 娌℃湁鑾峰彇鍒板伐浠朵俊鎭笉鍋氭洿鏂�"); - return; - } - else - {//鏇存柊琛╓orkPieceInfo - if (loginfo.WorkingProcedure.Equals("OP10")) - { - /* - info.WorkPieceCurrentPosition = info.WorkingProcedureCurrent + "NOOK"; - loginfo2.WorkingProcedure = info.WorkingProcedureCurrent;//瑙e喅OP10锛孫P40鍚屼竴涓殑闂 - loginfo.WorkingProcedure = info.WorkingProcedureCurrent; //瑙e喅OP10锛孫P40鍚屼竴涓殑闂 - //*/ - //淇 閿欒璁板綍鎴怬P05鐨勯棶棰� 銆怑ditby shaocx,2024-08-26銆� - var set_WorkingProcedureCurrent = ""; - if (cur_db_info.WorkingProcedureCurrent != "OP10" && cur_db_info.WorkingProcedureCurrent != "OP40") - { - SetWorkingProcedureCurrentForOP10(cur_db_info, ref set_WorkingProcedureCurrent); - } - else - { - set_WorkingProcedureCurrent = cur_db_info.WorkingProcedureCurrent; - } - cur_db_info.WorkingProcedureCurrent = set_WorkingProcedureCurrent; - cur_db_info.WorkPieceCurrentPosition = set_WorkingProcedureCurrent + "NOOK"; - loginfo2.WorkingProcedure = set_WorkingProcedureCurrent;//瑙e喅OP10锛孫P40鍚屼竴涓殑闂 - loginfo.WorkingProcedure = set_WorkingProcedureCurrent; //瑙e喅OP10锛孫P40鍚屼竴涓殑闂 - } - else - { - cur_db_info.WorkingProcedureCurrent = loginfo.WorkingProcedure; - cur_db_info.WorkPieceCurrentPosition = loginfo.WorkingProcedure + "NOOK"; - } - cur_db_info.WorkPieceState = (int)WorkPieceState.NOOKPush; - cur_db_info.UpdatedUserName = loginfo.MonitoringPoint; - SystemBussinessHelper.SetWorkPieceInfoMiddleForUpdateDataCapturePointCname(ref cur_db_info, loginfo.DataCapturePointCname); - cur_db_info.UpdatedTime = DateTime.Now; - cur_db_info.Remarks = "宸ヤ欢NOOK鎺ㄥ嚭"; - loginfo2.Remarks = cur_db_info.Remarks; - if (!(cur_db_info.WorkingProcedureStartTime.HasValue && cur_db_info.WorkingProcedureStartTime > DateTime.Parse("1900/01/01"))) - { - cur_db_info.WorkingProcedureStartTime = DateTimeHelper.GetDateTime(); - } - cur_db_info.WorkingProcedureEndTime = DateTimeHelper.GetDateTime(); - cur_db_info.WorkingProcedureCompleted = cur_db_info.WorkingProcedureCompleted + loginfo.WorkingProcedure;//宸插畬鎴愬伐搴� - cur_db_info.WorkPieceCurrentPositionOrder = cur_db_info.WorkingProcedurePlan.IndexOf(loginfo.WorkingProcedure) / 2; - } - QualityDataInfo qualityData = null; - qualityData = db.QualityDataInfo.Where(o => o.WorkPieceID == loginfo.WorkPieceID).FirstOrDefault(); - if (loginfo.WorkingProcedure.Equals("OP35")) - {//涓轰簡瑙e喅OP35鐨勯噰闆嗗埌鐨勮川閲忎俊鎭槸OK杩楴OOK鐨勬儏鍐碉紝OP35 NOOK鏃舵洿鏂拌川閲忎俊鎭� - loginfo2.Remarks = $"OP35NOOK鍘熻川閲忎俊鎭瘂(cur_db_info.QualityState.HasValue ? cur_db_info.QualityState.Value.ToString() : "绌�")}"; - cur_db_info.QualityState = (int)QualityStateEnum.NG; - if (!cur_db_info.QualityState.Equals(((int)QualityStateEnum.OK).ToString())) - { - cur_db_info.QualityErrorInfo = $"{loginfo.WorkingProcedure}宸ュ簭璐ㄩ噺NOOK閲囬泦鏁版嵁涓嶅悎鏍納cur_db_info.QualityState}"; - } - else - { - cur_db_info.QualityErrorInfo = ""; - } - loginfo.QualityState = cur_db_info.QualityState; - - - if (qualityData != null) - { - qualityData.OP35QualityState = loginfo.QualityState.HasValue ? loginfo.QualityState.Value.ToString() : "3"; - qualityData.OP35QualityReceiveTime = DateTimeHelper.GetDateTime(); - db.QualityDataInfoLog.Add(GetAddQualityDataInfoLog(qualityData)); - } - } - //鏇存柊涓婁竴宸ュ簭鐨勭粨鏉熸椂闂� - var pro = db.WorkPieceProcess.Where(o => o.WorkPieceID == loginfo.WorkPieceID - && o.WorkingProcedureCurrent == loginfo.WorkingProcedure && o.OperationType == OperationType.鐢熶骇.ToString()).OrderByDescending(o => o.StartTime).FirstOrDefault(); - if (pro != null && pro.WorkPieceID.Length > 0) - { - pro.EndTime = DateTimeHelper.GetDateTime(); - pro.Remarks = "NOOK缁撴潫"; - pro.UpdatedUserName = loginfo.MonitoringPoint; - pro.UpdateDataCapturePointCname = loginfo.DataCapturePointCname; - pro.UpdatedTime = DateTimeHelper.GetDateTime(); - } - else - {//濡傛灉鎵句笉鍒板氨鏂板缓 銆怑ditby shaocx,2024-09-03銆� - WorkPieceProcess add_process = new WorkPieceProcess(); - add_process = EntityPropHelper.Mapper<WorkPieceProcess, WorkPieceInfo>(cur_db_info); - QualityStateHelper.ResetQualityNoOkForNewProcess(ref add_process); - add_process.Id = Yitter.IdGenerator.YitIdHelper.NextId(); - add_process.StartTime = DateTimeHelper.GetDateTime().AddSeconds(-SystemBussinessHelper.MoNiTimeForWorkingProcedure(loginfo.WorkingProcedure)); - add_process.EndTime = DateTimeHelper.GetDateTime(); - //涓嶅啀榛樿璧嬪�间负鍚堟牸 銆怑ditby shaocx,2024-08-16銆� - add_process.QualityState = WorkPieceInfoManager.GetQualityStateValue(loginfo.QualityState); - - add_process.CreatedUserName = loginfo.MonitoringPoint; - add_process.DataCapturePointCname = loginfo.DataCapturePointCname; - add_process.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - add_process.UpdatedUserName = loginfo.MonitoringPoint; - add_process.UpdateDataCapturePointCname = loginfo.DataCapturePointCname; - add_process.UpdatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - add_process.OperationType = OperationType.鐢熶骇.ToString(); - add_process.Remarks = "NOOK缁撴潫"; - add_process.MyRemarks = "NOOK缁撴潫鏃讹紝濡傛灉鎵句笉鍒板氨鏂板缓"; - db.WorkPieceProcess.Add(add_process); - } - - QualityStateHelper.SetQualityStateForNoOk(ref cur_db_info, ref pro, ref qualityData); - - db.WorkPieceInfoLog.Add(GetAddWorkPieceInfoLog(cur_db_info)); - - } - else - { - loginfo2.Remarks = $"宸ヤ欢NOOK鎺ㄥ嚭璇诲彇浜岀淮鐮亄loginfo.WorkPieceID ?? "绌�"}寮傚父"; - Log4NetHelper.WriteErrorLog(type, $" {loginfo.WorkingProcedure}宸ヤ欢NOOK鎺ㄥ嚭璇荤爜鏍囪 璇诲彇宸ヤ欢鐮佹暟鎹甗{loginfo.WorkPieceID ?? "绌�"}]鏃跺紓甯革細"); - } - } - catch (Exception e) - { - loginfo2.Remarks = $"璇诲彇浜岀淮鐮亄loginfo.WorkPieceID ?? "绌�"}鏇存柊鏁版嵁寮傚父{e.Message}"; - } - - - db.WorkPieceLog.Add(GetAddWorkPieceLog(loginfo2));//鎻掑叆宸ヤ欢閲囬泦鏃ュ織琛� - db.SaveChanges(); - } - - } - /// <summary> - /// 宸ヤ欢SPC鎶芥鎺ㄥ嚭 - /// </summary> - /// <param name="loginfo"></param> - /// <param name="type"></param> - public static void WorkPieceSPCPushOff(WorkPieceLogMiddle loginfo, LogType type) - { - - using (DbModel db = new DbModel()) - { - WorkPieceLog loginfo2 = new WorkPieceLog(); - loginfo2 = EntityPropHelper.Mapper<WorkPieceLog, WorkPieceLogMiddle>(loginfo); - try - { - if ((loginfo.WorkPieceID != null && loginfo.WorkPieceID.Trim('\0').Length == 22) - //|| !((loginfo.WorkingProcedure.Equals("OP10") || loginfo.WorkingProcedure.Equals("OP40")) && loginfo.Remarks.Length > 0) - ) - { - WorkPieceInfo cur_db_info = new WorkPieceInfo(); - cur_db_info = db.WorkPieceInfo.Where(o => o.WorkPieceID == loginfo.WorkPieceID).FirstOrDefault(); - if (cur_db_info == null || cur_db_info.WorkPieceID.Length < 1) - {//娌℃湁宸ヤ欢淇℃伅锛屼笉鍋氭洿鏂� - loginfo2.Remarks = $"宸ヤ欢{loginfo.WorkPieceID} 宸ヤ欢SPC鎺ㄥ嚭宸ュ簭{loginfo.WorkingProcedure} 娌℃湁鑾峰彇鍒板伐浠朵俊鎭笉鍋氭洿鏂�"; - Log4NetHelper.WriteErrorLog(type, $"宸ヤ欢{loginfo.WorkPieceID} 宸ヤ欢SPC鎺ㄥ嚭宸ュ簭{loginfo.WorkingProcedure} 娌℃湁鑾峰彇鍒板伐浠朵俊鎭笉鍋氭洿鏂�"); - return; - } - else - {//鏇存柊琛╓orkPieceInfo - if (loginfo.WorkingProcedure.Equals("OP10")) - { - //淇 閿欒璁板綍鎴怬P05鐨勯棶棰� 銆怑ditby shaocx,2024-08-26銆� - var set_WorkingProcedureCurrent = ""; - if (cur_db_info.WorkingProcedureCurrent != "OP10" && cur_db_info.WorkingProcedureCurrent != "OP40") - { - SetWorkingProcedureCurrentForOP10(cur_db_info, ref set_WorkingProcedureCurrent); - } - else - { - set_WorkingProcedureCurrent = cur_db_info.WorkingProcedureCurrent; - } - cur_db_info.WorkingProcedureCurrent = set_WorkingProcedureCurrent; - cur_db_info.WorkPieceCurrentPosition = set_WorkingProcedureCurrent + "SPC"; - loginfo2.WorkingProcedure = set_WorkingProcedureCurrent;//瑙e喅OP10锛孫P40鍚屼竴涓殑闂 - loginfo.WorkingProcedure = set_WorkingProcedureCurrent; //瑙e喅OP10锛孫P40鍚屼竴涓殑闂 - } - else - { - cur_db_info.WorkingProcedureCurrent = loginfo.WorkingProcedure; - cur_db_info.WorkPieceCurrentPosition = loginfo.WorkingProcedure + "SPC"; - } - cur_db_info.WorkPieceState = (int)WorkPieceState.SPCPush; - cur_db_info.UpdatedUserName = loginfo.MonitoringPoint; - SystemBussinessHelper.SetWorkPieceInfoMiddleForUpdateDataCapturePointCname(ref cur_db_info, loginfo.DataCapturePointCname); - cur_db_info.UpdatedTime = DateTime.Now; - cur_db_info.WorkingProcedureEndTime = DateTimeHelper.GetDateTime(); - if (!(cur_db_info.WorkingProcedureStartTime.HasValue && cur_db_info.WorkingProcedureStartTime > DateTime.Parse("1900/01/01"))) - { - cur_db_info.WorkingProcedureStartTime = DateTimeHelper.GetDateTime(); - } - - - cur_db_info.WorkingProcedureCompleted = cur_db_info.WorkingProcedureCompleted + loginfo.WorkingProcedure;//宸插畬鎴愬伐搴� - cur_db_info.WorkPieceCurrentPositionOrder = cur_db_info.WorkingProcedurePlan.IndexOf(loginfo.WorkingProcedure) / 2; - } - cur_db_info.Remarks = "宸ヤ欢SPC鎶芥鎺ㄥ嚭"; - loginfo2.Remarks = cur_db_info.Remarks; - - //鏇存柊涓婁竴宸ュ簭鐨勭粨鏉熸椂闂� - var pro = db.WorkPieceProcess.Where(o => o.WorkPieceID == loginfo.WorkPieceID && o.WorkingProcedureCurrent == loginfo.WorkingProcedure - && o.OperationType == OperationType.鐢熶骇.ToString()).OrderByDescending(o => o.StartTime).FirstOrDefault(); - if (pro != null && pro.WorkPieceID.Length > 0) - { - pro.EndTime = DateTimeHelper.GetDateTime(); - pro.Remarks = (pro.Remarks ?? "") + "SPC鎶芥缁撴潫"; - pro.UpdatedUserName = loginfo.MonitoringPoint; - pro.UpdateDataCapturePointCname = loginfo.DataCapturePointCname; - pro.UpdatedTime = DateTimeHelper.GetDateTime(); - } - //姣忔SPC 閮芥彃鍏ヨ拷婧〃 - WorkPieceProcess process = new WorkPieceProcess(); - process = EntityPropHelper.Mapper<WorkPieceProcess, WorkPieceInfo>(cur_db_info); - QualityStateHelper.ResetQualityNoOkForNewProcess(ref process); - process.StartTime = DateTimeHelper.GetDateTime(); - process.OperationType = OperationType.SPC.ToString(); - process.QualityState = (int)QualityStateEnum.Suspected; - process.Id = Yitter.IdGenerator.YitIdHelper.NextId(); - process.CreatedUserName = loginfo.MonitoringPoint; - process.DataCapturePointCname = loginfo.DataCapturePointCname; - process.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - process.UpdatedUserName = loginfo.MonitoringPoint; - process.UpdateDataCapturePointCname = loginfo.DataCapturePointCname; - process.UpdatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - process.Remarks = "宸ヤ欢SPC鎶芥鎺ㄥ嚭"; - process.MyRemarks = "SPC鏃讹紝鎻掑叆杩芥函琛�"; - db.WorkPieceProcess.Add(process); - - - db.WorkPieceInfoLog.Add(GetAddWorkPieceInfoLog(cur_db_info)); - } - else - { - loginfo2.Remarks = $"宸ヤ欢SPC鎶芥鎺ㄥ嚭璇诲彇浜岀淮鐮亄loginfo.WorkPieceID ?? "绌�"}寮傚父"; - Log4NetHelper.WriteErrorLog(type, $" {loginfo.WorkingProcedure}宸ヤ欢SPC鎶芥鎺ㄥ嚭璇荤爜鏍囪 璇诲彇宸ヤ欢鐮佹暟鎹甗{loginfo.WorkPieceID ?? "绌�"}]鏃跺紓甯革細"); - } - } - catch (Exception e) - { - loginfo2.Remarks = $"璇诲彇浜岀淮鐮亄loginfo.WorkPieceID ?? "绌�"}鏇存柊鏁版嵁寮傚父{e.Message}"; - } - finally - { - db.WorkPieceLog.Add(GetAddWorkPieceLog(loginfo2));//鎻掑叆宸ヤ欢閲囬泦鏃ュ織琛� - db.SaveChanges(); - } - - } - } + + public static void SetWorkingProcedureCurrentForOP10(WorkPieceInfo cur_db_info, ref string set_WorkingProcedureCurrent) @@ -1248,264 +299,7 @@ } } - /// <summary> - /// 宸ュ簭瀹屾垚 - /// </summary> - /// <param name="logMiddle"></param> - /// <param name="type"></param> - public static void WorkingProcedureComplete(WorkPieceLogMiddle logMiddle, LogType type) - { - - using (DbModel db = new DbModel()) - { - if (logMiddle.WorkingProcedure.Equals("OP70")) - { - logMiddle.QualityState = (int)QualityStateEnum.OK; //濡傛灉鏄疧P70锛屽垯榛樿鏄悎鏍� 銆怑ditby shaocx,2024-06-25銆� - } - - WorkPieceLog loginfo2 = new WorkPieceLog(); - loginfo2 = EntityPropHelper.Mapper<WorkPieceLog, WorkPieceLogMiddle>(logMiddle); - - try - { - if (logMiddle.WorkPieceID != null && logMiddle.WorkPieceID.Trim('\0').Length == 22) - { - - bool isAddWorkPieceInfo = false; - WorkPieceInfo db_info = new WorkPieceInfo(); - db_info = db.WorkPieceInfo.Where(o => o.WorkPieceID == logMiddle.WorkPieceID).FirstOrDefault(); - if (db_info == null || db_info.WorkPieceID.Length < 1) - {//娌℃湁宸ヤ欢淇℃伅锛屼笉鍋氭洿鏂� 锛堜负浜嗘祴璇曞厛鍏堟柊澧烇級 - Log4NetHelper.WriteErrorLog(type, $"宸ヤ欢{logMiddle.WorkPieceID} 宸ヤ欢鎺ㄥ嚭宸ュ簭{logMiddle.WorkingProcedure} 娌℃湁鑾峰彇鍒板伐浠朵俊鎭笉鍋氭洿鏂�"); - //db.WorkPieceLog.Add(GetAddWorkPieceLog(loginfo));//鎻掑叆宸ヤ欢閲囬泦鏃ュ織琛� - //db.SaveChanges(); - - loginfo2 = CommonManager.Instance.GetWorkPieceID(logMiddle, type); - db_info = EntityPropHelper.Mapper<WorkPieceInfo, WorkPieceLog>(logMiddle); - //EntityPropHelper<WorkPieceLog, WorkPieceInfo>.CopyProp(loginfo, info, loginfo.GetWorkPieceInfoDict()); - if (!logMiddle.WorkingProcedure.Equals("OP05")) - {//褰撳伐浠朵簩缁寸爜绗竴娆″嚭鐜扮殑宸ュ簭涓嶆槸OP05锛屽垯璁剧疆涓哄彲鐤戠姸鎬� - db_info.QualityState = (int)QualityStateEnum.Suspected; - db_info.QualityErrorInfo = $"宸ヤ欢浜岀淮鐮佺涓�娆″嚭鐜扮殑宸ュ簭{logMiddle.MonitoringPoint}涓嶆槸OP05,鏁版嵁缂哄け,璇风‘璁ゆ儏鍐靛苟鍋氱浉搴斿鐞嗭紒"; - db_info.Remarks = $"宸ヤ欢浜岀淮鐮佺涓�娆″嚭鐜扮殑宸ュ簭{logMiddle.MonitoringPoint}涓嶆槸OP05,鏁版嵁缂哄け,璇风‘璁ゆ儏鍐靛苟鍋氱浉搴斿鐞嗭紒"; - } - else - { - db_info.QualityState = (int)QualityStateEnum.OK;//姝ゅ闇�瑕佹敞鎰忥紝鍒ゆ柇鎵�鏈夊伐搴忚川閲忥紝鐒跺悗鍐嶈祴鍊� //榛樿鍚堟牸锛孫P05榛樿鏄悎鏍� - db_info.Remarks = "OP05鏂板宸ヤ欢淇℃伅"; - } - db_info.WorkPieceinitOnlineTime = DateTimeHelper.GetDateTime();//WorkPieceInitOnlineTime - db_info.WorkingProcedurePlan = ConfigHelper.GetConfigString("WorkingProcedureAllStr") ?? "OP05OP10OP20OP30OP35OP40OP50OP60OP70OP80"; - db_info.CreatedUserName = logMiddle.MonitoringPoint; - SystemBussinessHelper.SetWorkPieceInfoMiddleForCreatedUserName(ref db_info, logMiddle.DataCapturePointCname); - db_info.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - db_info.WorkingProcedureCurrent = logMiddle.WorkingProcedure; - db_info.WorkingProcedureEndTime = null; - db_info = ParseQRCode(db_info); - isAddWorkPieceInfo = true; - } - if (logMiddle.WorkingProcedure.Equals("OP10")) - { - //var WorkingProcedure = (loginfo.MonitoringPoint.Equals("OP1002") ? "OP10" : "OP40"); - loginfo2.WorkingProcedure = db_info.WorkingProcedureCurrent;//瑙e喅OP10锛孫P40鍚屼竴涓殑闂 - logMiddle.WorkingProcedure = db_info.WorkingProcedureCurrent; //瑙e喅OP10锛孫P40鍚屼竴涓殑闂 - } - - db_info.WorkingProcedureCurrent = logMiddle.WorkingProcedure;//璧嬪�兼渶鏂板伐搴� 銆怑ditby shaocx,2024-09-03銆� - db_info.UpdatedUserName = logMiddle.MonitoringPoint; - SystemBussinessHelper.SetWorkPieceInfoMiddleForUpdateDataCapturePointCname(ref db_info, logMiddle.DataCapturePointCname); - db_info.UpdatedTime = DateTimeHelper.GetDateTime(); - db_info.WorkingProcedureCompleted = db_info.WorkingProcedureCompleted + logMiddle.WorkingProcedure;//宸插畬鎴愬伐搴� - if (!(db_info.WorkingProcedureStartTime.HasValue && db_info.WorkingProcedureStartTime > DateTime.Parse("1900/01/01"))) - {//鑻ヤ竴鐩存病鏈夊伐搴忓紑濮嬫椂闂达紝鍒欒祴鍊煎綋鍓嶆椂闂� - db_info.WorkingProcedureStartTime = DateTimeHelper.GetDateTime(); - } - db_info.WorkingProcedureEndTime = DateTimeHelper.GetDateTime(); - db_info.WorkPieceCurrentPositionOrder = db_info.WorkingProcedurePlan.IndexOf(logMiddle.WorkingProcedure) / 2; - db_info.Remarks = $"{logMiddle.WorkingProcedure}宸ュ簭瀹屾垚"; - long op80id = 0; - if (logMiddle.WorkingProcedure.Equals("OP80")) - { - db_info.WorkPieceState = (int)WorkPieceState.FinishedProducts; - db_info.WorkPieceLastOfflineTime = DateTimeHelper.GetDateTime(); - db_info.WorkPieceCurrentPosition = "OP80"; - db_info.CompleteTime = DateTimeHelper.GetDateTime(); - db_info.OP80NewCode = logMiddle.OP80NewCode; - - //璐ㄦ鏁版嵁鏀逛负 鑾峰彇鏂囦欢鍚庝慨鏀� 銆怑ditby shaocx,2024-06-15銆� - /* - info.QualityState = (int)((loginfo.QualityStateStr.Equals("OK") || loginfo.QualityStateStr.Equals("0K")) ? QualityState.OK : QualityState.NG); - loginfo.QualityState = info.QualityState; - info.QualityStateUpdateUser = loginfo.UpdatedUserName; - info.QualityStateUpdateTime = loginfo.UpdatedTime.Value.LocalDateTime; - info.QualityStateUpdateMode = QualityStateUpdateMode.Auto.ToString(); - //*/ - - - var qualityData = db.QualityDataInfo.Where(o => o.WorkPieceID == logMiddle.WorkPieceID).FirstOrDefault(); - if (qualityData == null || qualityData.WorkPieceID.Length < 1 || qualityData.WorkingProcedure.Length < 1) - {//鎻掑叆QualityDataInfo琛� - qualityData = EntityPropHelper.Mapper<QualityDataInfo, WorkPieceLog>(logMiddle); - db.QualityDataInfo.Add(GetAddQualityDataInfo(qualityData)); - } - //淇敼QualityDataInfo琛� //閲嶅鏀跺埌璐ㄩ噺淇℃伅锛屼細瑕嗙洊涔嬪墠鐨� - EntityPropHelper<WorkPieceLogMiddle, QualityDataInfo>.CopyProp(logMiddle, qualityData, GetQualityDataInfoUpdate(logMiddle, logMiddle.WorkingProcedure, logMiddle.MonitoringPoint));//鎸囧畾淇敼瀛楁 - - //璐ㄦ鏁版嵁鏀逛负 鑾峰彇鏂囦欢鍚庝慨鏀� 銆怑ditby shaocx,2024-06-15銆� - /* - qualityData.QualityStateUpdateUser = info.UpdatedUserName; - qualityData.QualityReceiveTime = info.UpdatedTime.Value.LocalDateTime; - qualityData.QualityStateUpdateMode = info.QualityStateUpdateMode; - qualityData.OP80QualityState = loginfo.QualityState.HasValue ? loginfo.QualityState.Value.ToString() : "3"; - qualityData.OP80QualityReceiveTime = DateTimeHelper.GetDateTime(); - qualityData.OP80QualityFilePath = loginfo.OP80QualityFilePath; - op80id = qualityData.Id; - loginfo2.Remarks = (loginfo2.Remarks ?? "") + $"璐ㄩ噺锛歿loginfo.QualityStateStr ?? "绌�"}"; - if (!info.QualityState.Equals(((int)QualityState.OK).ToString())) - { - info.QualityErrorInfo = $"{loginfo.WorkingProcedure}宸ュ簭璐ㄩ噺閲囬泦鏁版嵁涓嶅悎鏍�"; - } - else - { - info.QualityErrorInfo = ""; - } - //*/ - - loginfo2.Remarks = $"娴嬮噺鍚堟牸鐘舵��:{logMiddle.St3_Means_OK},绉伴噸鐘舵��:{logMiddle.St4_Weight_OK}"; - } - else if (logMiddle.WorkingProcedure.Equals("OP30")) - { - - db_info.QualityState = (int)((logMiddle.QualityStateStr.Equals("OK") || logMiddle.QualityStateStr.Equals("0K")) ? QualityStateEnum.OK : QualityStateEnum.NG); - logMiddle.QualityState = db_info.QualityState; - db_info.QualityStateUpdateUser = logMiddle.UpdatedUserName; - db_info.QualityStateUpdateTime = logMiddle.UpdatedTime.Value.LocalDateTime; - db_info.QualityStateUpdateMode = QualityStateUpdateMode.Auto.ToString(); - - var qualityData = db.QualityDataInfo.Where(o => o.WorkPieceID == logMiddle.WorkPieceID).FirstOrDefault(); - if (qualityData == null || qualityData.WorkPieceID.Length < 1 || qualityData.WorkingProcedure.Length < 1) - {//鎻掑叆QualityDataInfo琛� - qualityData = EntityPropHelper.Mapper<QualityDataInfo, WorkPieceLog>(logMiddle); - db.QualityDataInfo.Add(GetAddQualityDataInfo(qualityData)); - } - qualityData.QualityStateUpdateUser = db_info.UpdatedUserName; - qualityData.QualityReceiveTime = db_info.UpdatedTime.Value.LocalDateTime; - qualityData.QualityStateUpdateMode = db_info.QualityStateUpdateMode; - qualityData.OP30QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value.ToString() : "3"; - qualityData.OP30QualityReceiveTime = DateTimeHelper.GetDateTime(); - loginfo2.Remarks = (loginfo2.Remarks ?? "") + $"璐ㄩ噺锛歿logMiddle.QualityStateStr ?? "绌�"}"; - if (!db_info.QualityState.Equals(((int)QualityStateEnum.OK).ToString())) - { - db_info.QualityErrorInfo = $"{logMiddle.WorkingProcedure}宸ュ簭璐ㄩ噺閲囬泦鏁版嵁涓嶅悎鏍�"; - } - else - { - db_info.QualityErrorInfo = ""; - } - } - else - { - //杩欓噷淇OP10銆丱P40 鍥犱负PLC鍏堟帹 SPC鎺ㄥ嚭銆佸啀鎺� 浜у搧涓嬬嚎闂锛屽鑷� 浜у搧涓嬬嚎鏇存柊鏁版嵁鏃讹紝鎶奡PC鏁版嵁瑕嗙洊鐨勯棶棰� 銆怑ditby shaocx,2024-08-27銆� - var isAlow = SystemBussinessHelper.IsAllowUpdateWorkPieceStateToWip(db_info, db, logMiddle); - if (isAlow) - { - db_info.WorkPieceState = (int)WorkPieceState.WIP; - } - - - if (db_info.WorkingProcedurePlan.IndexOf(logMiddle.WorkingProcedure) + 4 <= db_info.WorkingProcedurePlan.Length) - { - db_info.WorkPieceCurrentPosition = db_info.WorkingProcedurePlan.Substring(db_info.WorkingProcedurePlan.IndexOf(logMiddle.WorkingProcedure), 8); - } - } - - var pro = db.WorkPieceProcess.Where(o => o.WorkPieceID == logMiddle.WorkPieceID - && o.WorkingProcedureCurrent == db_info.WorkingProcedureCurrent - && o.OperationType == OperationType.鐢熶骇.ToString()).OrderByDescending(o => o.StartTime).FirstOrDefault(); - if (pro == null || pro.WorkPieceID.Length < 1) - { - WorkPieceProcess add_process = new WorkPieceProcess(); - add_process = EntityPropHelper.Mapper<WorkPieceProcess, WorkPieceInfo>(db_info); - QualityStateHelper.ResetQualityNoOkForNewProcess(ref add_process); - add_process.Id = Yitter.IdGenerator.YitIdHelper.NextId(); - add_process.StartTime = DateTimeHelper.GetDateTime().AddSeconds(-SystemBussinessHelper.MoNiTimeForWorkingProcedure(logMiddle.WorkingProcedure)); - add_process.EndTime = DateTimeHelper.GetDateTime(); - if (logMiddle.WorkingProcedure.Equals("OP80")) - {//OP80鐨勮川閲忔暟鎹槸鍚庢潵鑾峰彇鏂囦欢鎼炵殑 - //璐ㄦ鏁版嵁锛屽啀鑰冭檻 鍙﹀涓ょ鐘舵�� 銆怑ditby shaocx,2024-08-27銆� - QualityStateHelper.SetQualityStateForOP80(logMiddle, ref db_info, ref add_process); - } - else - { - //涓嶅啀榛樿璧嬪�间负鍚堟牸 銆怑ditby shaocx,2024-08-16銆� - //process.QualityState = logMiddle.QualityState.HasValue ? logMiddle.QualityState.Value : (int)QualityState.OK;//榛樿鍚堟牸锛屽凡澶勭悊 - add_process.QualityState = WorkPieceInfoManager.GetQualityStateValue(logMiddle.QualityState); - } - add_process.CreatedUserName = logMiddle.MonitoringPoint; - add_process.DataCapturePointCname = logMiddle.DataCapturePointCname; - add_process.CreatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - add_process.UpdatedUserName = logMiddle.MonitoringPoint; - add_process.UpdateDataCapturePointCname = logMiddle.DataCapturePointCname; - add_process.UpdatedTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local); - add_process.OperationType = OperationType.鐢熶骇.ToString(); - add_process.Remarks = ""; - add_process.MyRemarks = "宸ュ簭瀹屾垚鏃讹紝濡傛灉鎵句笉鍒板氨鏂板缓"; - if (logMiddle.WorkingProcedure.Equals("OP80")) - { - add_process.GetQcDataFlag = logMiddle.GetQcDataFlag;//璧嬪�兼爣璁� [Editby shaocx,2024-06-15] - } - if (op80id > 0) - { - add_process.QualityDataInfoID = op80id; - } - db.WorkPieceProcess.Add(add_process); - } - else - { - if (logMiddle.WorkingProcedure.Equals("OP80")) - {//OP80鐨勮川閲忔暟鎹槸鍚庢潵鑾峰彇鏂囦欢鎼炵殑 - //璐ㄦ鏁版嵁锛屽啀鑰冭檻 鍙﹀涓ょ鐘舵�� 銆怑ditby shaocx,2024-08-27銆� - QualityStateHelper.SetQualityStateForOP80(logMiddle, ref db_info, ref pro); - } - if (op80id > 0) - { - pro.QualityDataInfoID = op80id; - } - pro.EndTime = DateTimeHelper.GetDateTime(); - pro.UpdatedUserName = logMiddle.MonitoringPoint; - pro.UpdateDataCapturePointCname = logMiddle.DataCapturePointCname; - pro.UpdatedTime = DateTimeHelper.GetDateTime(); - if (logMiddle.WorkingProcedure.Equals("OP80")) - { - if (pro.GetQcDataFlag != 0) - { - pro.GetQcDataFlag = logMiddle.GetQcDataFlag;//璧嬪�兼爣璁� [Editby shaocx,2024-06-15] - } - } - } - - - if (isAddWorkPieceInfo) - { - db.WorkPieceInfo.Add(db_info); - } - db.WorkPieceInfoLog.Add(GetAddWorkPieceInfoLog(db_info)); - } - else - { - loginfo2.Remarks = $"涓嬬嚎瀹屾垚璇诲彇浜岀淮鐮亄logMiddle.WorkPieceID ?? "绌�"}寮傚父"; - Log4NetHelper.WriteErrorLog(type, $" {logMiddle.WorkingProcedure}宸ュ簭涓嬬嚎 璇诲彇宸ヤ欢鐮佹暟鎹甗{logMiddle.WorkPieceID ?? "绌�"}]鏃跺紓甯革細"); - - } - } - catch (Exception e) - { - loginfo2.Remarks = $"璇诲彇浜岀淮鐮亄logMiddle.WorkPieceID ?? "绌�"}鏇存柊鏁版嵁寮傚父{e.Message}"; - } - db.WorkPieceLog.Add(GetAddWorkPieceLog(loginfo2));//鎻掑叆宸ヤ欢閲囬泦鏃ュ織琛� - db.SaveChanges(); - } - } + public static void AlertMonitor(WorkPieceLog loginfo, LogType type) { diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP0506.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP0506.cs index c511139..2b5c0e8 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP0506.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP0506.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using System; @@ -63,7 +64,7 @@ wplog.UpdatedTime = DateTimeHelper.GetDateTime(); wplog.UpdatedUserName = DataCapturePointCode; //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + WorkPiecePushOffManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); return; } diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2001.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2001.cs index c3bbac7..5be9675 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2001.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2001.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using System; @@ -110,7 +111,7 @@ } } //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.ReadQRcode(wplog, LogType.PLCOP20, plcService, _dataCaptureConfig.IsFeedback); + ReadQRcodeManager.ReadQRcode(wplog, LogType.PLCOP20, plcService, _dataCaptureConfig.IsFeedback); //鍒ゆ柇鏄惁璺冲簭锛屼笂涓�宸ュ簭璐ㄩ噺鏄惁鍚堟牸 diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2003.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2003.cs index 1fb8637..295846f 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2003.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2003.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using System; @@ -110,7 +111,7 @@ } } //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.ReadQRcode(wplog, LogType.PLCOP20, plcService, _dataCaptureConfig.IsFeedback); + ReadQRcodeManager.ReadQRcode(wplog, LogType.PLCOP20, plcService, _dataCaptureConfig.IsFeedback); //鍒ゆ柇鏄惁璺冲簭锛屼笂涓�宸ュ簭璐ㄩ噺鏄惁鍚堟牸 diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2004.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2004.cs index ab96ebf..bf0b7d8 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2004.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2004.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using System; @@ -13,7 +14,7 @@ /// <summary> /// OP20SPC鎺ㄥ嚭鏍囪 /// </summary> - public class DataCaptureHandler_OP2004: DataCaptureHandler + public class DataCaptureHandler_OP2004 : DataCaptureHandler { public static readonly DataCaptureHandler_OP2004 Instance = new DataCaptureHandler_OP2004(); @@ -101,7 +102,7 @@ wplog.MonitoringPoint = "OP2004"; foreach (var col in colConfig) { - switch(col.DbNumber+ col.Offset) + switch (col.DbNumber + col.Offset) { case "": var valuecol = plcService.ReadValuePoint(col.DbNumber, col.Offset, PLCManger.GetTypeForString(col.DataCaptureColumnType)); @@ -110,7 +111,7 @@ } } //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.ReadQRcode(wplog, LogType.PLCOP20, plcService, _dataCaptureConfig.IsFeedback); + ReadQRcodeManager.ReadQRcode(wplog, LogType.PLCOP20, plcService, _dataCaptureConfig.IsFeedback); //鍒ゆ柇鏄惁璺冲簭锛屼笂涓�宸ュ簭璐ㄩ噺鏄惁鍚堟牸 diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2005.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2005.cs index 5b1f0ca..1f725f6 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2005.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2005.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using System; @@ -110,7 +111,7 @@ } } //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.ReadQRcode(wplog, LogType.PLCOP20, plcService, _dataCaptureConfig.IsFeedback); + ReadQRcodeManager.ReadQRcode(wplog, LogType.PLCOP20, plcService, _dataCaptureConfig.IsFeedback); //鍒ゆ柇鏄惁璺冲簭锛屼笂涓�宸ュ簭璐ㄩ噺鏄惁鍚堟牸 diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2006.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2006.cs index 3acdd71..e3c980e 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2006.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/DataCaptureHandler_OP2006.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using System; @@ -109,7 +110,7 @@ } } //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.ReadQRcode(wplog, LogType.PLCOP20, plcService, _dataCaptureConfig.IsFeedback); + ReadQRcodeManager.ReadQRcode(wplog, LogType.PLCOP20, plcService, _dataCaptureConfig.IsFeedback); //鍒ゆ柇鏄惁璺冲簭锛屼笂涓�宸ュ簭璐ㄩ噺鏄惁鍚堟牸 diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_01.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_01.cs index 8a2a57a..b333b43 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_01.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_01.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using iWare_SCADA_Model.MiddleModel; @@ -197,7 +198,7 @@ SystemBussinessHelper.SetWorkPieceLogMiddleForCreatedUserName(ref wplog, wplog.MonitoringPoint, DataCapturePointCname); //璇诲彇浜岀淮鐮佸悗鏇存柊鏁版嵁搴� - WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), plcService, _dataCaptureConfig.IsFeedback); + ReadQRcodeManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), plcService, _dataCaptureConfig.IsFeedback); threadStatusMonitor.Threadstatue = 1; diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_02.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_02.cs index aae2e7b..e15ec32 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_02.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_02.cs @@ -21,6 +21,7 @@ using Spire.Additions.Xps.Schema; using log4net; using static Org.BouncyCastle.Math.EC.ECCurve; +using iWare_SCADA_BusinessLogical.BLL.Important; namespace iWare_SCADA_BusinessLogical { @@ -630,7 +631,7 @@ //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.QualityInfoComplete(logMiddle, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + QualityInfoCompleteManager.QualityInfoComplete(logMiddle, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); threadStatusMonitor.Threadstatue = 1; diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_03.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_03.cs index ce93629..2e89129 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_03.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_03.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using iWare_SCADA_Model.MiddleModel; @@ -64,7 +65,7 @@ wplog.UpdatedTime = DateTimeHelper.GetDateTime(); wplog.UpdatedUserName = DataCapturePointCode; //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + WorkPiecePushOffManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); return; } @@ -153,13 +154,13 @@ {//op20浼氬悓鏃舵帹鍑哄浠讹紝鎵�浠ョ壒娈婂鐞� wplog.WorkPieceID = wplog.WorkPieceIDA; wplog.Remarks = "NOOK鎺ㄥ嚭宸ヤ欢A"; - WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + WorkPiecePushOffManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); wplog.WorkPieceID = wplog.WorkPieceIDB; wplog.Remarks = "NOOK鎺ㄥ嚭宸ヤ欢B"; - WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + WorkPiecePushOffManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); wplog.WorkPieceID = wplog.WorkPieceIDC; wplog.Remarks = "NOOK鎺ㄥ嚭宸ヤ欢C"; - WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + WorkPiecePushOffManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); //wplog.WorkPieceID = wplog.WorkPieceIDD; //wplog.Remarks = "NOOK鎺ㄥ嚭宸ヤ欢D"; //WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); @@ -167,7 +168,7 @@ else { //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + WorkPiecePushOffManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); } threadStatusMonitor.Threadstatue = 1; diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_04.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_04.cs index 5e0f18d..e983b9e 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_04.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_04.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using iWare_SCADA_Model.MiddleModel; @@ -63,7 +64,7 @@ wplog.UpdatedTime = DateTimeHelper.GetDateTime(); wplog.UpdatedUserName = DataCapturePointCode; //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + WorkPieceSPCPushOffManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); return; } @@ -153,24 +154,24 @@ {//op20,op50,op60 浼氬悓鏃舵帹鍑哄浠讹紝鎵�浠ョ壒娈婂鐞� wplog.WorkPieceID = wplog.WorkPieceIDA; wplog.Remarks = "SPC鎺ㄥ嚭宸ヤ欢A"; - WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + WorkPieceSPCPushOffManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); wplog.WorkPieceID = wplog.WorkPieceIDB; wplog.Remarks = "SPC鎺ㄥ嚭宸ヤ欢B"; - WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + WorkPieceSPCPushOffManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); wplog.WorkPieceID = wplog.WorkPieceIDC; wplog.Remarks = "SPC鎺ㄥ嚭宸ヤ欢C"; - WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + WorkPieceSPCPushOffManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); if (_dataCaptureConfig.WorkingProcedure.Equals("OP60")) { wplog.WorkPieceID = wplog.WorkPieceIDD; wplog.Remarks = "SPC鎺ㄥ嚭宸ヤ欢D"; - WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + WorkPieceSPCPushOffManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); } } else { //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + WorkPieceSPCPushOffManager.WorkPieceSPCPushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); } threadStatusMonitor.Threadstatue = 1; diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_05.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_05.cs index c9b4d37..c65d255 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_05.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_05.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using iWare_SCADA_Model.MiddleModel; @@ -344,7 +345,7 @@ //*/ //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + WorkingProcedureCompleteManager.WorkingProcedureComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); threadStatusMonitor.Threadstatue = 1; } diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_06.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_06.cs index 9fe30f2..0d92c6f 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_06.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_06.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using iWare_SCADA_Model.MiddleModel; @@ -65,7 +66,7 @@ wplog.UpdatedTime = DateTimeHelper.GetDateTime(); wplog.UpdatedUserName = DataCapturePointCode; //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + WorkPiecePushOffManager.WorkPiecePushOff(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); return; } diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_OP0501.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_OP0501.cs index 042948c..e1f8283 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_OP0501.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_OP0501.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using System; @@ -326,8 +327,8 @@ { Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"{_dataCaptureConfig.WorkingProcedure}宸ュ簭璇诲彇宸ユ帶鏈轰腑浜岀淮鐮佷俊鎭�,璇诲彇宸ヤ欢浜岀淮鐮�:{item.WorkPieceID.ToString()}"); - - WorkPieceInfoManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), null, _dataCaptureConfig.IsFeedback); + + ReadQRcodeManager.ReadQRcode(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), null, _dataCaptureConfig.IsFeedback); threadStatusMonitor.Threadstatue = 1; } diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1002.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1002.cs index fe09314..1cbd426 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1002.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1002.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using log4net; @@ -172,7 +173,7 @@ //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.QualityInfoComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + QualityInfoCompleteManager.QualityInfoComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); threadStatusMonitor.Threadstatue = 1; diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1003.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1003.cs index 9b5d01b..3919573 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1003.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1003.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using System; @@ -170,7 +171,7 @@ //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.QualityInfoComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + QualityInfoCompleteManager.QualityInfoComplete(wplog, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); threadStatusMonitor.Threadstatue = 1; } SystemValue.value_OP1003 = value.ToString(); diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1004.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1004.cs index 19d8bc9..c5bb9b6 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1004.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP1004.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using System; @@ -129,16 +130,16 @@ { Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {DataCapturePointCode}宸ュ簭1鐩戞帶璇荤爜鏍囪 璇诲彇宸ヤ欢鐮佹暟鎹畕wplog.WorkPieceID}鎺ㄥ嚭鍘熷洜[{wplog.OP10Flag}]"); - WorkPieceInfoManager.WorkPiecePushOff(wplog, LogType.PLCOP10); + WorkPiecePushOffManager.WorkPiecePushOff(wplog, LogType.PLCOP10); threadStatusMonitor.Threadstatue = 1; - wplog.Remarks =$"鎺ㄥ嚭鍘熷洜[{wplog.OP10Flag}] NOOK"; + wplog.Remarks = $"鎺ㄥ嚭鍘熷洜[{wplog.OP10Flag}] NOOK"; } //else if (wplog.OP10Flag == 2 || wplog.OP10Flag == 3) else { Log4NetHelper.WriteInfoLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $" {DataCapturePointCode}宸ュ簭23鐩戞帶璇荤爜鏍囪 璇诲彇宸ヤ欢鐮佹暟鎹畕wplog.WorkPieceID}鎺ㄥ嚭鍘熷洜[{wplog.OP10Flag}]"); - WorkPieceInfoManager.WorkPieceSPCPushOff(wplog, LogType.PLCOP10); + WorkPieceSPCPushOffManager.WorkPieceSPCPushOff(wplog, LogType.PLCOP10); wplog.Remarks = $"鎺ㄥ嚭鍘熷洜[{wplog.OP10Flag}] SPC"; threadStatusMonitor.Threadstatue = 1; } diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP7009.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP7009.cs index e0d6bd9..c882e76 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP7009.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/Special/DataCaptureHandler_OP7009.cs @@ -1,4 +1,5 @@ 锘縰sing iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using log4net; @@ -159,7 +160,7 @@ foreach (var item in noFinishWorkPieceProcessList) { wplog.WorkPieceID = item.WorkPieceID; - WorkPieceInfoManager.QualityInfoCompleteForOP70(wplog, LogType.OP7009); + QualityInfoCompleteManager.QualityInfoCompleteForOP70(wplog, LogType.OP7009); // threadStatusMonitor.Threadstatue = 1; } } diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj index 9e8adbe..17c9745 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj @@ -80,6 +80,11 @@ <Compile Include="BLL\CommonManager.cs" /> <Compile Include="BLL\DataCaptureColumnDictManager.cs" /> <Compile Include="BLL\DataCaptureConfigManager.cs" /> + <Compile Include="BLL\Important\QualityInfoCompleteManager.cs" /> + <Compile Include="BLL\Important\ReadQRcodeManager.cs" /> + <Compile Include="BLL\Important\WorkingProcedureCompleteManager.cs" /> + <Compile Include="BLL\Important\WorkPiecePushOffManager.cs" /> + <Compile Include="BLL\Important\WorkPieceSPCPushOffManager.cs" /> <Compile Include="BLL\SystemValue.cs" /> <Compile Include="BLL\WorkPieceInfoManager.cs" /> <Compile Include="BLL\WorkPieceLogManager.cs" /> diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Test/UnitTest1.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Test/UnitTest1.cs index 1faa746..7b96e1e 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Test/UnitTest1.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Test/UnitTest1.cs @@ -1,5 +1,6 @@ 锘縰sing iWare_SCADA_BusinessLogical; using iWare_SCADA_BusinessLogical.BLL; +using iWare_SCADA_BusinessLogical.BLL.Important; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -147,7 +148,7 @@ WorkPieceInfoManager.SetLogMiddleForQuality(ref logMiddle); //鏇存柊WorkPieceInfo琛ㄤ互鍙婃彃鍏orkPieceLog琛ㄥ拰WorkPieceInfoLog琛� - WorkPieceInfoManager.QualityInfoComplete(logMiddle, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); + QualityInfoCompleteManager.QualityInfoComplete(logMiddle, PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure)); string cc = ""; -- Gitblit v1.9.3