DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_FormTest/App.config
@@ -1,12 +1,52 @@ <?xml version="1.0" encoding="utf-8"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/> </startup> <configSections> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </configSections> <appSettings> <add key="OP80QualityData_Test" value="X:\CA4GC20TD_Test\"/> <add key="OP60QualityData_Test" value="Q:\Measuring_Data_df_Test\"/> <add key="OP60QualityData_Zhengshi" value="Q:\Measuring_Data_dfq\"/> <add key="OP60QualityData_Test_Localhost" value="D:\数瀛信息科技\公司项目\DF22001-一汽连杆项目\映射盘文件\OP60(尼伯丁)\"/> <!--net use x: \\192.168.216.133\Destination /savecred /persistent:yes net use z: \\192.168.216.130\kistler /savecred /persistent:yes net use y: \\192.168.216.6\data /savecred /persistent:yes net use u: \\192.168.216.130\NutrunnerData /savecred /persistent:yes--> <!-- 判断工序是否跳序的基准配置 --> <add key="WorkingProcedureAllStr" value="OP05OP10OP20OP30OP35OP40OP50OP60OP70OP80" /> <add key="WorkPeiceIDPath" value="Y:\qualified" /> <!-- op30工序的工位质量信息 --> <add key="OP30QualityDataFor36Station" value="Z:\" /> <add key="OP30QualityDataFor45Station" value="U:\" /> <add key="OP60QualityData" value="V:\" /> <add key="OP20QualityData" value="W:\" /> <add key="OP80QualityData" value="X:\CA4GC20TD\" /> <!--<add key="WorkPeiceIDPath" value="C:\Users\13650\Desktop\yiqi" />--> <add key="HeartBeatAlertInterval" value="2000" /> </appSettings> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> </startup> <entityFramework> <providers> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> </providers> </entityFramework> <connectionStrings> <!--<add name="SCADA_DF22001_CORE" connectionString="Server=.;Database=iWare.SCADA;User=sa;Password=123abc.com;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />--> <!--<add name="SCADA_DF22001_CORE" connectionString="Server=10.10.40.166;Database=iWare.SCADA;User=sa;Password=123abc.com;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />--> <add name="SCADA_DF22001_CORE" connectionString="Server=.;Database=iWare.SCADA;User=sa;Password=123abc.com;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" /> <add name="SCModel" connectionString="data source=.;initial catalog=SCTest_new;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" /> </connectionStrings> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration> DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_FormTest/Form1.Designer.cs
@@ -31,6 +31,13 @@ this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); this.tb_TongJi = new System.Windows.Forms.TextBox(); this.checkBox_NowDay = new System.Windows.Forms.CheckBox(); this.dateTimePicker_End = new System.Windows.Forms.DateTimePicker(); this.label16 = new System.Windows.Forms.Label(); this.dateTimePicker_Start = new System.Windows.Forms.DateTimePicker(); this.btn_TongJi = new System.Windows.Forms.Button(); this.SuspendLayout(); // // button1 @@ -63,17 +70,92 @@ this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // // button4 // this.button4.Location = new System.Drawing.Point(76, 335); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(244, 54); this.button4.TabIndex = 3; this.button4.Text = "统计分析"; this.button4.UseVisualStyleBackColor = true; this.button4.Click += new System.EventHandler(this.button4_Click); // // tb_TongJi // this.tb_TongJi.Location = new System.Drawing.Point(444, 107); this.tb_TongJi.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.tb_TongJi.Multiline = true; this.tb_TongJi.Name = "tb_TongJi"; this.tb_TongJi.Size = new System.Drawing.Size(748, 459); this.tb_TongJi.TabIndex = 19; // // checkBox_NowDay // this.checkBox_NowDay.AutoSize = true; this.checkBox_NowDay.Location = new System.Drawing.Point(940, 51); this.checkBox_NowDay.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.checkBox_NowDay.Name = "checkBox_NowDay"; this.checkBox_NowDay.Size = new System.Drawing.Size(59, 19); this.checkBox_NowDay.TabIndex = 18; this.checkBox_NowDay.Text = "今天"; this.checkBox_NowDay.UseVisualStyleBackColor = true; // // dateTimePicker_End // this.dateTimePicker_End.Location = new System.Drawing.Point(702, 49); this.dateTimePicker_End.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.dateTimePicker_End.Name = "dateTimePicker_End"; this.dateTimePicker_End.Size = new System.Drawing.Size(200, 25); this.dateTimePicker_End.TabIndex = 17; // // label16 // this.label16.AutoSize = true; this.label16.Location = new System.Drawing.Point(660, 57); this.label16.Name = "label16"; this.label16.Size = new System.Drawing.Size(22, 15); this.label16.TabIndex = 16; this.label16.Text = "至"; // // dateTimePicker_Start // this.dateTimePicker_Start.Location = new System.Drawing.Point(444, 49); this.dateTimePicker_Start.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.dateTimePicker_Start.Name = "dateTimePicker_Start"; this.dateTimePicker_Start.Size = new System.Drawing.Size(200, 25); this.dateTimePicker_Start.TabIndex = 15; // // btn_TongJi // this.btn_TongJi.BackColor = System.Drawing.Color.Aqua; this.btn_TongJi.Location = new System.Drawing.Point(1038, 37); this.btn_TongJi.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btn_TongJi.Name = "btn_TongJi"; this.btn_TongJi.Size = new System.Drawing.Size(155, 48); this.btn_TongJi.TabIndex = 14; this.btn_TongJi.Text = "统计信息"; this.btn_TongJi.UseVisualStyleBackColor = false; this.btn_TongJi.Click += new System.EventHandler(this.btn_TongJi_Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(1307, 688); this.Controls.Add(this.tb_TongJi); this.Controls.Add(this.checkBox_NowDay); this.Controls.Add(this.dateTimePicker_End); this.Controls.Add(this.label16); this.Controls.Add(this.dateTimePicker_Start); this.Controls.Add(this.btn_TongJi); this.Controls.Add(this.button4); this.Controls.Add(this.button3); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); this.PerformLayout(); } @@ -82,6 +164,13 @@ private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; private System.Windows.Forms.TextBox tb_TongJi; private System.Windows.Forms.CheckBox checkBox_NowDay; private System.Windows.Forms.DateTimePicker dateTimePicker_End; private System.Windows.Forms.Label label16; private System.Windows.Forms.DateTimePicker dateTimePicker_Start; private System.Windows.Forms.Button btn_TongJi; } } DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_FormTest/Form1.cs
@@ -1,4 +1,5 @@ using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using System; using System.Collections.Generic; using System.ComponentModel; @@ -98,5 +99,104 @@ MessageBox.Show("异常:" + ex.Message); } } private void button4_Click(object sender, EventArgs e) { } private void btn_TongJi_Click(object sender, EventArgs e) { //统计 int store_FDJ = 0;//现有发动机数 int store_EmptySalver = 0;//空托盘数量 int store_EmptySalver_TS = 0;//空托盘托数 int count_In_FDJ = 0;//查询某天入库了多少发动机 int count_In_EmptySalver = 0;//查询某天入库了多少 空托盘 int count_In_EmptySalver_TS = 0;//查询某天入库了多少 空托盘托数 int count_Out_FDJ = 0;//查询某天出库了多少发动机 int count_Out_EmptySalver = 0;//查询某天出库了多少 空托盘 int count_Out_EmptySalver_TS = 0;//查询某天出库了多少 空托盘托数 int count_ZY_EmptySalver = 0;//查询某天转运了多少 空托盘 int count_ZY_EmptySalver_TS = 0;//查询某天转运了多少 空托盘托数 //某段时间的统计 var str_start = this.dateTimePicker_Start.Value.ToString("yyyy-MM-dd" + " " + "00:00:00"); var str_end = this.dateTimePicker_End.Value.ToString("yyyy-MM-dd" + " " + "23:59:59"); var start = Convert.ToDateTime(str_start); var end = Convert.ToDateTime(str_end); int allPlacesCount = 0; List<string> strList = new List<string>() { "OP05","OP10","OP20","OP30","OP35","OP40","OP50","OP60","OP70","OP80" }; var q_strList = string.Join(",", strList); var str = ""; str += "时间范围: " + str_start + "至" + str_end + " \r\n"; using (DbModel edm = new DbModel()) { var allPlaces = edm.WorkPieceLog.Where(x => (x.CreatedTime >= start && x.CreatedTime <= end)).ToList(); var groups = allPlaces.GroupBy(x => x.WorkingProcedure).OrderBy(x => x.Key); foreach (var gg in groups) { var _key = gg.Key; var _list = gg.ToList(); var emtype = " "; var _list_youzhi = _list.Where(x => x.WorkPieceID.Length > 20 && x.WorkPieceID != emtype).ToList(); var _list_empty = _list.Where(x => string.IsNullOrEmpty(x.WorkPieceID) || x.WorkPieceID == emtype).ToList(); var _list_other = _list.Where(x => !((x.WorkPieceID.Length > 20 && x.WorkPieceID != emtype) || (string.IsNullOrEmpty(x.WorkPieceID) || x.WorkPieceID == emtype))).ToList(); var _list_other_str_list = _list_other.Select(x => x.WorkPieceID).Distinct().ToList(); var _list_other_str = string.Join("|", _list_other_str_list); str += $"==================【{_key}】========================= \r\n"; str += $"总量: {_list.Count()},正确二维码数:{_list_youzhi.Count()},空值:{_list_empty.Count},其他:{_list_other.Count},分别是{_list_other_str} \r\n"; //再进行分组,统计 二维码不对的数据 var _list_qc_error = _list.Where(x => string.IsNullOrEmpty(x.WorkPieceID) || x.WorkPieceID.Length <= 20).ToList(); var group_qc_error = _list_qc_error.GroupBy(x => new { x.WorkPieceID, x.CreatedUserName }); str += $"二维码不对的数据,总量: {_list_qc_error.Count()} \r\n"; foreach (var item in group_qc_error) { str += $"二维码不对的数据,WorkPieceID: {item.Key.WorkPieceID},CreatedUserName: {item.Key.CreatedUserName},数量:{item.ToList().Count()} \r\n"; } //再进行分组,统计 二维码对的数据 var group_qc_ok = _list_youzhi.GroupBy(x => new { x.CreatedUserName }); str += $"二维码正确的数据,总量: {_list_youzhi.Count()} \r\n"; foreach (var item in group_qc_ok) { str += $"二维码正确的数据,CreatedUserName: {item.Key.CreatedUserName},数量:{item.ToList().Count()} \r\n"; } //再进行分组,统计 二维码对的数据-去重 var _list_youzhi_quchong = _list_youzhi.Select(x => new { x.CreatedUserName }).Distinct().ToList(); var group_qc_ok_quchong = _list_youzhi_quchong.GroupBy(x => new { x.CreatedUserName }); str += $"(去重后)二维码正确的数据,总量: {_list_youzhi_quchong.Count()} \r\n"; foreach (var item in group_qc_ok_quchong) { str += $"(去重后)二维码正确的数据,CreatedUserName: {item.Key.CreatedUserName},数量:{item.ToList().Count()} \r\n"; } str += "\r\n"; } } str += "\r\n"; this.tb_TongJi.Text = str; } } } DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_FormTest/iWare_SCADA_FormTest2.csproj
@@ -34,6 +34,12 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Reference Include="EntityFramework"> <HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath> </Reference> <Reference Include="EntityFramework.SqlServer"> <HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> @@ -45,6 +51,9 @@ <Reference Include="System.Net.Http" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> <Reference Include="Yitter.IdGenerator.Net45"> <HintPath>..\packages\Yitter.IdGenerator.Net45.1.0.0\lib\net452\Yitter.IdGenerator.Net45.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> <Compile Include="Form1.cs"> @@ -86,6 +95,10 @@ <Project>{32708f19-fe1a-48f5-b373-8e1c776f216c}</Project> <Name>iWare_SCADA_BusinessLogical</Name> </ProjectReference> <ProjectReference Include="..\iWare_SCADA_Model\iWare_SCADA_Model.csproj"> <Project>{91C185DE-15AB-44AE-B585-53799FC51BE0}</Project> <Name>iWare_SCADA_Model</Name> </ProjectReference> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>