From 0e97de73f6719ccd57469cea07a9f567864cc57a Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周三, 04 9月 2024 10:13:54 +0800
Subject: [PATCH] 日志增加  WorkingProcedureCurrent

---
 iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterfaceLog/AccessInterfaceLogService.cs      |    8 ++
 iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterface/AccessInterfaceService.cs            |   77 +++++++++++++------------
 iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterfaceLog/Dto/AddAccessInterfaceLogInput.cs |   18 +++++
 iWara.SCADA.Code/iWare.Wms.Core/Entity/Access/AccessInterfaceLog.cs                                 |   15 +++++
 iWara.SCADA.Code/iWare.Wms.Application/iWare.Wms.Application.xml                                    |   10 +++
 5 files changed, 88 insertions(+), 40 deletions(-)

diff --git a/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterface/AccessInterfaceService.cs b/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterface/AccessInterfaceService.cs
index 7607dfc..96655eb 100644
--- a/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterface/AccessInterfaceService.cs
+++ b/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterface/AccessInterfaceService.cs
@@ -70,9 +70,9 @@
             IAccessInterfaceLogService accessInterfaceLog,
             IRepository<ThreadStatusMonitor, MasterDbContextLocator> threadStatusMonitorRep,
             IRepository<DataCaptureConfig, MasterDbContextLocator> dataCaptureConfigRep,
-            IRepository<WorkPieceProcess, MasterDbContextLocator> workPieceProcessRep, WorkPieceInfoService WorkPieceInfoService, 
-            IRepository<WorkPieceInfoLog, MasterDbContextLocator> workPieceInfoLog, 
-            IRepository<EquipmentCurrentMonitor, MasterDbContextLocator> equipmentCurrentMonitorRep, 
+            IRepository<WorkPieceProcess, MasterDbContextLocator> workPieceProcessRep, WorkPieceInfoService WorkPieceInfoService,
+            IRepository<WorkPieceInfoLog, MasterDbContextLocator> workPieceInfoLog,
+            IRepository<EquipmentCurrentMonitor, MasterDbContextLocator> equipmentCurrentMonitorRep,
             IRepository<EquipmentBaseInfo, MasterDbContextLocator> equipmentBaseInfoRep, ISysDictTypeService dict
             , IRepository<ProductionPlanInfo, MasterDbContextLocator> productionPlanInfoRep
             , IRepository<ShiftInfo, MasterDbContextLocator> shiftInfoRep)
@@ -127,9 +127,10 @@
             {
                 addLog.IpAddress = ipAddress.MapToIPv4().ToString();
             }
+            AddQualityDataInfoInputV2 input = null;
             try
             {
-                var input = JsonConvert.DeserializeObject<AddQualityDataInfoInputV2>(json);
+                input = JsonConvert.DeserializeObject<AddQualityDataInfoInputV2>(json);
                 addLog.Key = input.WorkPieceID;
 
                 if (input == null || string.IsNullOrEmpty(input.WorkPieceID) || input.QualityState == 0)
@@ -277,7 +278,7 @@
                         }
                         updateinfo.WorkPieceState = (int)WorkPieceState.WIP;//鎺ㄥ嚭鍚庡拰SPC鎶芥鍚� 璐ㄩ噺褰曞叆鏃剁姸鎬佷慨鏀瑰洖鍦ㄥ埗鍝�
                         updateinfo.QualityState = (int)EnumQualityState.Suspected;
-                        updateinfo.QualityErrorInfo = $"宸ヤ欢{update.WorkPieceID}鍦ㄥ伐搴弡input.WorkingProcedure}鎶芥涓嶅悎鏍硷紝鐩稿叧宸ヤ欢璐ㄩ噺鐘舵�佸彉鏇翠负鐤戜技";;
+                        updateinfo.QualityErrorInfo = $"宸ヤ欢{update.WorkPieceID}鍦ㄥ伐搴弡input.WorkingProcedure}鎶芥涓嶅悎鏍硷紝鐩稿叧宸ヤ欢璐ㄩ噺鐘舵�佸彉鏇翠负鐤戜技"; ;
                         updateinfo.QualityStateUpdateUser = input.QualityStateUpdateUser;
                         updateinfo.QualityStateUpdateTime = now;
                         updateinfo.QualityStateUpdateMode = EnumQualityStateUpdateMode.SPC.ToString();
@@ -299,6 +300,8 @@
             {
                 try
                 {
+                    addLog.WorkPieceID = input.WorkPieceID;
+                    addLog.WorkingProcedureCurrent = input.WorkingProcedure;
 
                     await _accessInterfaceLog.AddInterfaceLogAsync(addLog);
                 }
@@ -392,7 +395,7 @@
                 .ProjectToType<EquipmentCurrentMonitorOutputV2>()
                 .OrderBy(o => o.EquipmentID)
                 .ToListAsync();
-            
+
             return equipmentCurrentMonitors;
         }
 
@@ -406,10 +409,10 @@
             List<ProduceCompletionStatus> list = new List<ProduceCompletionStatus>();
 
             //鑾峰彇褰撳墠骞寸殑绗竴澶�
-            var yearOneDay= DateTime.Now.AddDays(-((int)DateTime.Now.DayOfYear - 1)).Date;     
+            var yearOneDay = DateTime.Now.AddDays(-((int)DateTime.Now.DayOfYear - 1)).Date;
             //鑾峰彇鏈堜唤璁″垝
             var productionPlanInfos = _productionPlanInfoRep.DetachedEntities
-                                     .Where(o=>o.IsDeleted==false&& o.PlanType.Equals("2")).ToList();
+                                     .Where(o => o.IsDeleted == false && o.PlanType.Equals("2")).ToList();
             try
             {
                 //鑾峰彇鏈�杩戜竴骞翠笅绾垮伐浠剁殑鎴愬搧
@@ -444,7 +447,7 @@
                 }
 
             }
-            catch(Exception ex)
+            catch (Exception ex)
             {
 
             }
@@ -465,17 +468,17 @@
             var day = DateTime.Now.ToString("yyyy-MM-dd");
             //鑾峰彇褰撳墠鏈堜唤璁″垝
             var productionPlanInfos = _productionPlanInfoRep.DetachedEntities.ProjectToType<ProductionPlanInfoOutput>().ToList()
-                                     .Where(o => o.PlanType.Equals("2")&& o.PlanTimeHand.Equals(month)).FirstOrDefault();
+                                     .Where(o => o.PlanType.Equals("2") && o.PlanTimeHand.Equals(month)).FirstOrDefault();
             //鑾峰彇鏈�杩戞湀涓嬬嚎宸ヤ欢鐨勬垚鍝�
             try
             {
 
-            var MonthCompletionnNum = _workPieceInfoRep.DetachedEntities.ProjectToType<WorkPieceInfoOutput>().ToList()
-                                     .Where(o => o.WorkPieceLastOfflineTimeHand.Equals(month)
-                                     && o.WorkPieceState == (int)WorkPieceState.FinishedProducts).Count();
+                var MonthCompletionnNum = _workPieceInfoRep.DetachedEntities.ProjectToType<WorkPieceInfoOutput>().ToList()
+                                         .Where(o => o.WorkPieceLastOfflineTimeHand.Equals(month)
+                                         && o.WorkPieceState == (int)WorkPieceState.FinishedProducts).Count();
                 currentProduceInfo.CurrentMonthProduceNum = MonthCompletionnNum;
             }
-            catch(Exception ex)
+            catch (Exception ex)
             {
 
             }
@@ -485,13 +488,13 @@
                                      && o.WorkPieceState == (int)WorkPieceState.FinishedProducts).Count();
 
             //鑾峰彇鐝鐝粍淇℃伅
-            var shiftlist = _shiftInfoRep.DetachedEntities.ProjectToType<ShiftInfoOutput>().ToList().Where(o=>o.StartTime<DateTime.Now&&o.EndTime> DateTime.Now).FirstOrDefault();
+            var shiftlist = _shiftInfoRep.DetachedEntities.ProjectToType<ShiftInfoOutput>().ToList().Where(o => o.StartTime < DateTime.Now && o.EndTime > DateTime.Now).FirstOrDefault();
 
             currentProduceInfo.CurrentShiftProduceNum = DayCompletionnNum;
             currentProduceInfo.CurrentShiftPlanNum = 0;
-            currentProduceInfo.CurrentMonthPlanNum = (productionPlanInfos==null?0: productionPlanInfos.PlanProductionNum);
+            currentProduceInfo.CurrentMonthPlanNum = (productionPlanInfos == null ? 0 : productionPlanInfos.PlanProductionNum);
 
-            if(shiftlist==null)
+            if (shiftlist == null)
             {
                 currentProduceInfo.CurrentTime = DateTime.Now;
                 currentProduceInfo.CurrentTeamLeader = "琚佺彮闀�";
@@ -501,11 +504,11 @@
             {
                 //鑾峰彇鐝璁″垝
                 var shiftplan = _productionPlanInfoRep.DetachedEntities.ProjectToType<ProductionPlanInfoOutput>().ToList()
-                                         .Where(o => o.PlanType.Equals("1")&&o.TeamType.Equals(shiftlist.ShiftName)&& o.PlanTimeDayHand.Equals(day)).FirstOrDefault();
+                                         .Where(o => o.PlanType.Equals("1") && o.TeamType.Equals(shiftlist.ShiftName) && o.PlanTimeDayHand.Equals(day)).FirstOrDefault();
                 currentProduceInfo.CurrentTime = DateTime.Now;
                 currentProduceInfo.CurrentTeamLeader = shiftlist.ShiftRemark;
                 currentProduceInfo.CurrentTeamName = shiftlist.ShiftName;
-                if(shiftplan!=null)
+                if (shiftplan != null)
                 {
                     currentProduceInfo.CurrentShiftPlanNum = shiftplan.PlanProductionNum;
                 }
@@ -532,7 +535,7 @@
                 }
 
             }
-            catch(Exception ex)
+            catch (Exception ex)
             {
                 currentProduceInfo.CurrentSafeProductionDay = "寮傚父";
             }
@@ -564,16 +567,16 @@
                 case "OP10杩炴潌鍘氬害":
                     qualityDataDisplay.QualityType = str;
                     var datas = _qualityDataInfoRep.DetachedEntities.ProjectToType<QualityDataInfoOutput>()
-                        .Where(o=>!string.IsNullOrEmpty(o.QualityOP10To1)&& !string.IsNullOrEmpty(o.WorkPieceID))
+                        .Where(o => !string.IsNullOrEmpty(o.QualityOP10To1) && !string.IsNullOrEmpty(o.WorkPieceID))
                         .OrderByDescending(o => o.OP10QualityReceiveTime)
-                        .Select(o=>new QualityData() { WorkPieceID = o.WorkPieceID, QualityDataVaule = double.Parse( o.QualityOP10To1) })
+                        .Select(o => new QualityData() { WorkPieceID = o.WorkPieceID, QualityDataVaule = double.Parse(o.QualityOP10To1) })
                         .Take(10).Reverse().ToList();
                     qualityDataDisplay.list = datas;
                     break;
                 case "OP30娑ㄦ柇鍔涚煩":
                     qualityDataDisplay.QualityType = str;
                     var dataop30ch1 = _qualityDataInfoRep.DetachedEntities.ProjectToType<QualityDataInfoOutput>()
-                        .Where(o => !string.IsNullOrEmpty(o.QualityOP30To1)&&!string.IsNullOrEmpty(o.WorkPieceID))
+                        .Where(o => !string.IsNullOrEmpty(o.QualityOP30To1) && !string.IsNullOrEmpty(o.WorkPieceID))
                         .OrderByDescending(o => o.OP30QualityReceiveTimeCH3)
                         .Select(o => new QualityData() { WorkPieceID = o.WorkPieceID, QualityDataVaule = double.Parse(o.QualityOP30To1.Replace("kN", "")) })
                         .Take(10).Reverse().ToList();
@@ -582,7 +585,7 @@
                 case "OP35鍘嬭鍔涚煩":
                     qualityDataDisplay.QualityType = str;
                     var dataop35 = _qualityDataInfoRep.DetachedEntities.ProjectToType<QualityDataInfoOutput>()
-                        .Where(o => !string.IsNullOrEmpty(o.QualityOP35To1)&&!string.IsNullOrEmpty(o.WorkPieceID))
+                        .Where(o => !string.IsNullOrEmpty(o.QualityOP35To1) && !string.IsNullOrEmpty(o.WorkPieceID))
                         .OrderByDescending(o => o.OP35QualityReceiveTime)
                         .Select(o => new QualityData() { WorkPieceID = o.WorkPieceID, QualityDataVaule = double.Parse(o.QualityOP35To1) })
                         .Take(10).Reverse().ToList();
@@ -604,7 +607,7 @@
         {
             try
             {
-                
+
                 var dicts = await _dict.GetDictTreeOutput();
                 var dict = dicts.Where(o => o.Code.Equals("screen_refresh_frequency"));
                 if (dict.Any())
@@ -624,7 +627,7 @@
                     return 5000;
                 }
             }
-            catch(Exception ex)
+            catch (Exception ex)
             {
 
                 return 6000;
@@ -640,20 +643,20 @@
         /// <returns></returns>
         [HttpGet("GetProductionForTime")]
         [AllowAnonymous]
-        public async Task<List<ProductionInfo>> GetProductionForTime(DateTime start,DateTime end)
+        public async Task<List<ProductionInfo>> GetProductionForTime(DateTime start, DateTime end)
         {
             //鑾峰彇鏈�杩戞湀涓嬬嚎宸ヤ欢鐨勬垚鍝�
             var Production = from info in _workPieceInfoRep.DetachedEntities.ProjectToType<WorkPieceInfoOutput>().ToList()
-                                    where info.WorkPieceLastOfflineTime>=start
-                                    where info.WorkPieceLastOfflineTime<=end
-                                    where info.WorkPieceState==(int)WorkPieceState.FinishedProducts
-                                    group info by info.WorkPieceLastOfflineTimeDayHand into grouplist
-                                    select new ProductionInfo()
-                                    {
-                                        Day=grouplist.Key,
-                                        ProductionNum=grouplist.Count(),
-                                    };
-            return Production.OrderBy(o=>o.Day).ToList();
+                             where info.WorkPieceLastOfflineTime >= start
+                             where info.WorkPieceLastOfflineTime <= end
+                             where info.WorkPieceState == (int)WorkPieceState.FinishedProducts
+                             group info by info.WorkPieceLastOfflineTimeDayHand into grouplist
+                             select new ProductionInfo()
+                             {
+                                 Day = grouplist.Key,
+                                 ProductionNum = grouplist.Count(),
+                             };
+            return Production.OrderBy(o => o.Day).ToList();
 
         }
         #endregion
diff --git a/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterfaceLog/AccessInterfaceLogService.cs b/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterfaceLog/AccessInterfaceLogService.cs
index 200934f..51b59ee 100644
--- a/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterfaceLog/AccessInterfaceLogService.cs
+++ b/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterfaceLog/AccessInterfaceLogService.cs
@@ -44,7 +44,11 @@
         public async Task AddInterfaceLogAsync(AddAccessInterfaceLogInput input)
         {
             AccessInterfaceLog log = new();
-            log.Id=input.Id;
+
+            log.WorkPieceID = input.WorkPieceID;
+            log.WorkingProcedureCurrent = input.WorkingProcedureCurrent;
+
+            log.Id = input.Id;
             log.ParaJSON = input.JsonString;
             log.Action = input.Action;
             log.IPAddress = input.IpAddress;
@@ -112,7 +116,7 @@
                 //    }
                 //}
                 //log.Keys = string.Join(", ", keys);
-                if(input.Result.GetType().Name.Equals("String"))
+                if (input.Result.GetType().Name.Equals("String"))
                 {
                     log.ResultJson = input.Result.ToString();
 
diff --git a/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterfaceLog/Dto/AddAccessInterfaceLogInput.cs b/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterfaceLog/Dto/AddAccessInterfaceLogInput.cs
index 4c5f0a9..597cbd1 100644
--- a/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterfaceLog/Dto/AddAccessInterfaceLogInput.cs
+++ b/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterfaceLog/Dto/AddAccessInterfaceLogInput.cs
@@ -1,4 +1,5 @@
-锘縰sing System;
+锘縰sing Microsoft.EntityFrameworkCore;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -11,6 +12,21 @@
     /// </summary>
     public class AddAccessInterfaceLogInput
     {
+
+        /// <summary>
+        /// 宸ヤ欢鍙�
+        /// </summary>
+        [Comment("宸ヤ欢鍙�")]
+
+        public string WorkPieceID { get; set; }
+
+
+        /// <summary>
+        /// 褰撳墠宸ュ簭;杩涘叆涓嬩竴宸ュ簭鍓嶏紝姝ゅ伐搴忎笉鍙樺寲
+        /// </summary>
+        [Comment("褰撳墠宸ュ簭")]
+
+        public string WorkingProcedureCurrent { get; set; }
         public long Id { get; set; }
         /// <summary>
         /// 璇锋眰鍙傛暟Json瀛楃涓�
diff --git a/iWara.SCADA.Code/iWare.Wms.Application/iWare.Wms.Application.xml b/iWara.SCADA.Code/iWare.Wms.Application/iWare.Wms.Application.xml
index d8c26c8..971ac42 100644
--- a/iWara.SCADA.Code/iWare.Wms.Application/iWare.Wms.Application.xml
+++ b/iWara.SCADA.Code/iWare.Wms.Application/iWare.Wms.Application.xml
@@ -27,6 +27,16 @@
             娣诲姞澶栭儴璁块棶鏃ュ織鍙傛暟
             </summary>
         </member>
+        <member name="P:iWare.Wms.Application.AddAccessInterfaceLogInput.WorkPieceID">
+            <summary>
+            宸ヤ欢鍙�
+            </summary>
+        </member>
+        <member name="P:iWare.Wms.Application.AddAccessInterfaceLogInput.WorkingProcedureCurrent">
+            <summary>
+            褰撳墠宸ュ簭;杩涘叆涓嬩竴宸ュ簭鍓嶏紝姝ゅ伐搴忎笉鍙樺寲
+            </summary>
+        </member>
         <member name="P:iWare.Wms.Application.AddAccessInterfaceLogInput.JsonString">
             <summary>
             璇锋眰鍙傛暟Json瀛楃涓�
diff --git a/iWara.SCADA.Code/iWare.Wms.Core/Entity/Access/AccessInterfaceLog.cs b/iWara.SCADA.Code/iWare.Wms.Core/Entity/Access/AccessInterfaceLog.cs
index 2a9cc78..d234bba 100644
--- a/iWara.SCADA.Code/iWare.Wms.Core/Entity/Access/AccessInterfaceLog.cs
+++ b/iWara.SCADA.Code/iWare.Wms.Core/Entity/Access/AccessInterfaceLog.cs
@@ -10,6 +10,21 @@
 {
     public class AccessInterfaceLog : DEntityBase
     {
+
+        /// <summary>
+        /// 宸ヤ欢鍙�
+        /// </summary>
+        [Comment("宸ヤ欢鍙�")]
+
+        public string WorkPieceID { get; set; }
+
+
+        /// <summary>
+        /// 褰撳墠宸ュ簭;杩涘叆涓嬩竴宸ュ簭鍓嶏紝姝ゅ伐搴忎笉鍙樺寲
+        /// </summary>
+        [Comment("褰撳墠宸ュ簭")]
+
+        public string WorkingProcedureCurrent { get; set; }
         /// <summary>
         /// 璋冪敤琛屼负
         /// </summary>

--
Gitblit v1.9.3