commit 6b01b182fb9a7358e75e9214b6ded7cd0d23c89f Author: wenjy Date: Thu Nov 2 10:10:45 2023 +0800 添加项目文件。 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9491a2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,363 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/Dll/AsyncSocket.dll b/Dll/AsyncSocket.dll new file mode 100644 index 0000000..988d944 Binary files /dev/null and b/Dll/AsyncSocket.dll differ diff --git a/SLH.SSDMS.Collect/AsyncSocket.cs b/SLH.SSDMS.Collect/AsyncSocket.cs new file mode 100644 index 0000000..bb735f3 --- /dev/null +++ b/SLH.SSDMS.Collect/AsyncSocket.cs @@ -0,0 +1,100 @@ +using AsyncSocket; +using SLH.SSDMS.Common; +using SLH.SSDMS.Services; +using SLH.SSDMS.Services.serviceImpl; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Collect +{ + public class AsyncSocket + { + private static AsyncSocketServer server = new AsyncSocketServer(); + + private static IBufferParse bufferParse = new BufferParse(); + + public static void init() + { + server.Completed += new Action((key, enAction) => + { + switch (enAction) + { + case EnSocketAction.Connect: + LogHelper.Info(String.Format("接收到来自{0}的连接", key)); + break; + case EnSocketAction.SendMsg: + LogHelper.Info(String.Format("向客户端{0}发送了一条消息", key)); + break; + case EnSocketAction.Close: + LogHelper.Info(String.Format("{0}关闭了连接", key)); + break; + default: + break; + } + }); + + server.Received += new Action((key, msg) => + { + string bufferStr = StringChange.bytesToHexStr(msg, msg.Length); + LogHelper.Info(String.Format("收到客户端:{0}的数据:{1}", key, StringChange.bytesToHexStr(msg, msg.Length))); + + if(bufferStr.Contains("A55A") && bufferStr.Contains("0D0A")) + { + byte[] bufferLength = msg.Skip(2).Take(2).ToArray(); + int dataLen = Convert.ToInt32(StringChange.bytesToHexStr(bufferLength, bufferLength.Length), 16) + 1; + + try + { + byte[] calByte = new byte[dataLen]; + Array.Copy(msg, 2, calByte, 0, dataLen); + + var info = checkUtil.BCC(calByte); + + var test = msg[msg.Length - 2]; + + //判断校验 + if (msg[msg.Length - 3] == info) + { + if (calByte[2] == 132) + { + sendMessage(bufferParse.ReadAnalysis(calByte).Result); + } + + if (calByte[2] == 98) + { + sendMessage(bufferParse.HeartAnalysis(calByte).Result); + } + + if (calByte[2] == 164) + { + //终端IO返回 + } + + } + } + catch (Exception ex) + { + LogHelper.Error("接收数据异常", ex); + throw; + } + } + else + { + + LogHelper.Info("异常指令:" + StringChange.bytesToHexStr(msg, msg.Length)); + } + + }); + + server.StartAsync(7788); + } + + private static void sendMessage(byte[] buffer) + { + server.SendAsync(buffer); + } + } +} diff --git a/SLH.SSDMS.Collect/Properties/AssemblyInfo.cs b/SLH.SSDMS.Collect/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4c65487 --- /dev/null +++ b/SLH.SSDMS.Collect/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SLH.SSDMS.Collect")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SLH.SSDMS.Collect")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("c3937ff9-b218-48e4-a602-c59106b67c7b")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SLH.SSDMS.Collect/SLH.SSDMS.Collect.csproj b/SLH.SSDMS.Collect/SLH.SSDMS.Collect.csproj new file mode 100644 index 0000000..4aac75c --- /dev/null +++ b/SLH.SSDMS.Collect/SLH.SSDMS.Collect.csproj @@ -0,0 +1,64 @@ + + + + + Debug + AnyCPU + {C3937FF9-B218-48E4-A602-C59106B67C7B} + Library + Properties + SLH.SSDMS.Collect + SLH.SSDMS.Collect + v4.5.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\Dll\AsyncSocket.dll + + + + + + + + + + + + + + + + + {9DB66868-C6F0-4522-A551-09452B927C52} + SLH.SSDMS.Common + + + {3EFE1A92-DF3D-4B98-8A6B-DDA264385E52} + SLH.SSDMS.Services + + + + + + + \ No newline at end of file diff --git a/SLH.SSDMS.Collect/app.config b/SLH.SSDMS.Collect/app.config new file mode 100644 index 0000000..a0cefc2 --- /dev/null +++ b/SLH.SSDMS.Collect/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/SLH.SSDMS.Common/ConfigHelper.cs b/SLH.SSDMS.Common/ConfigHelper.cs new file mode 100644 index 0000000..482ccfb --- /dev/null +++ b/SLH.SSDMS.Common/ConfigHelper.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Common +{ + public class ConfigHelper + { + /// + /// 获取配置 + /// + /// 节点配置 + /// + public static string GetConfig(string sections) + { + try + { + return ConfigurationManager.AppSettings[sections].ToString(); + } + catch (Exception) { } + + return ""; + } + + /// + /// 更新Config文件,若Key已存在,替换当前Val值;不存在则添加新的键值对 + /// + /// + /// + public static void UpdateAppConfig(string key, string value) + { + //增加的内容写在appSettings段下 + System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); + if (config.AppSettings.Settings[key] == null) + { + config.AppSettings.Settings.Add(key, value); + } + else + { + config.AppSettings.Settings[key].Value = value; + } + config.Save(ConfigurationSaveMode.Modified); + ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件 + + + } + } +} diff --git a/SLH.SSDMS.Common/ExpressionExtensions.cs b/SLH.SSDMS.Common/ExpressionExtensions.cs new file mode 100644 index 0000000..1155f8b --- /dev/null +++ b/SLH.SSDMS.Common/ExpressionExtensions.cs @@ -0,0 +1,152 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Common +{ + /// + /// 谓词表达式构建器 + /// + public static class ExpressionExtensions + { + /// + /// 创建一个值恒为 true 的表达式。 + /// + /// 表达式方法类型 + /// 一个值恒为 true 的表达式。 + public static Expression> True() { return p => true; } + + /// + /// 创建一个值恒为 false 的表达式。 + /// + /// 表达式方法类型 + /// 一个值恒为 false 的表达式。 + public static Expression> False() { return f => false; } + + /// + /// 使用 Expression.OrElse 的方式拼接两个 System.Linq.Expression。 + /// + /// 表达式方法类型 + /// 左边的 System.Linq.Expression 。 + /// 右边的 System.Linq.Expression。 + /// 拼接完成的 System.Linq.Expression。 + public static Expression Or(this Expression left, Expression right) + { + return MakeBinary(left, right, Expression.OrElse); + } + + /// + /// 使用 Expression.AndAlso 的方式拼接两个 System.Linq.Expression。 + /// + /// 表达式方法类型 + /// 左边的 System.Linq.Expression 。 + /// 右边的 System.Linq.Expression。 + /// 拼接完成的 System.Linq.Expression。 + public static Expression And(this Expression left, Expression right) + { + return MakeBinary(left, right, Expression.AndAlso); + } + + /// + /// 使用自定义的方式拼接两个 System.Linq.Expression。 + /// + /// 表达式方法类型 + /// 左边的 System.Linq.Expression 。 + /// 右边的 System.Linq.Expression。 + /// + /// 拼接完成的 System.Linq.Expression。 + private static Expression MakeBinary(this Expression left, Expression right, Func func) + { + return MakeBinary((LambdaExpression)left, right, func) as Expression; + } + + /// + /// 拼接两个 + /// System.Linq.Expression + /// ,两个 + /// System.Linq.Expression + /// 的参数必须完全相同。 + /// + /// 左边的 + /// System.Linq.Expression + /// + /// 右边的 + /// System.Linq.Expression + /// + /// 表达式拼接的具体逻辑 + /// 拼接完成的 + /// System.Linq.Expression + /// + private static LambdaExpression MakeBinary(this LambdaExpression left, LambdaExpression right, Func func) + { + var data = Combinate(right.Parameters, left.Parameters).ToArray(); + + right = ParameterReplace.Replace(right, data) as LambdaExpression; + + return Expression.Lambda(func(left.Body, right.Body), left.Parameters.ToArray()); + } + + /// + /// 合并参数 + /// + /// + /// + /// + /// + private static IEnumerable> Combinate(IEnumerable left, IEnumerable right) + { + var a = left.GetEnumerator(); + var b = right.GetEnumerator(); + while (a.MoveNext() && b.MoveNext()) + yield return new KeyValuePair(a.Current, b.Current); + } + } + + internal sealed class ParameterReplace : ExpressionVisitor + { + public static Expression Replace(Expression e, IEnumerable> paramList) + { + var item = new ParameterReplace(paramList); + return item.Visit(e); + } + + private readonly Dictionary _parameters; + + public ParameterReplace(IEnumerable> paramList) + { + _parameters = paramList.ToDictionary(p => p.Key, p => p.Value, new ParameterEquality()); + } + + protected override Expression VisitParameter(ParameterExpression p) + { + ParameterExpression result; + if (_parameters.TryGetValue(p, out result)) + return result; + return base.VisitParameter(p); + } + + #region class: ParameterEquality + private class ParameterEquality : IEqualityComparer + { + public bool Equals(ParameterExpression x, ParameterExpression y) + { + if (x == null || y == null) + return false; + + return x.Type == y.Type; + } + + public int GetHashCode(ParameterExpression obj) + { + if (obj == null) + return 0; + + return obj.Type.GetHashCode(); + } + } + #endregion + } +} diff --git a/SLH.SSDMS.Common/JsonChange.cs b/SLH.SSDMS.Common/JsonChange.cs new file mode 100644 index 0000000..9ac80d1 --- /dev/null +++ b/SLH.SSDMS.Common/JsonChange.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web.Script.Serialization; + +namespace SLH.SSDMS.Common +{ + /// + /// Json格式转换 + /// + public class JsonChange + { + /// + /// Model 实体转json + /// + /// 可以是单个实体,也可是实体集(即:ToList()) + /// + public static string ModeToJson(object Model) + { + JavaScriptSerializer serializer = new JavaScriptSerializer(); + string str = serializer.Serialize(Model); + //HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json") }; + //return result; + return str; + } + } +} diff --git a/SLH.SSDMS.Common/LogHelper.cs b/SLH.SSDMS.Common/LogHelper.cs new file mode 100644 index 0000000..dafacdb --- /dev/null +++ b/SLH.SSDMS.Common/LogHelper.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Common +{ + public class LogHelper + { + //GetLogger表示log4net配置文件中logger标签中name属性,此处要一致 不然无log输出 + public static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("loginfo"); + public static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror"); + + /// + /// 记录Info日志 + /// + /// + /// + public static void Info(string msg) + { + Console.WriteLine(msg); + if (loginfo.IsInfoEnabled) + { + loginfo.Info(msg); + } + } + /// + /// 记录Error日志 + /// + /// + /// + public static void Error(string info, Exception ex = null) + { + if (!string.IsNullOrEmpty(info) && ex == null) + { + logerror.ErrorFormat("【附加信息】 : {0}
", new object[] { info }); + } + else if (!string.IsNullOrEmpty(info) && ex != null) + { + string errorMsg = BeautyErrorMsg(ex); + logerror.ErrorFormat("【附加信息】 : {0}
{1}", new object[] { info, errorMsg }); + } + else if (string.IsNullOrEmpty(info) && ex != null) + { + string errorMsg = BeautyErrorMsg(ex); + logerror.Error(errorMsg); + } + } + + /// + /// 美化错误信息 + /// + /// 异常 + /// 错误信息 + private static string BeautyErrorMsg(Exception ex) + { + string errorMsg = string.Format("【异常类型】:{0}
【异常信息】:{1}
【堆栈调用】:{2}", new object[] { ex.GetType().Name, ex.Message, ex.StackTrace }); + errorMsg = errorMsg.Replace("\r\n", "
"); + errorMsg = errorMsg.Replace("位置", "位置"); + return errorMsg; + } + } +} diff --git a/SLH.SSDMS.Common/Properties/AssemblyInfo.cs b/SLH.SSDMS.Common/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3d329c4 --- /dev/null +++ b/SLH.SSDMS.Common/Properties/AssemblyInfo.cs @@ -0,0 +1,37 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SLH.SSDMS.Common")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SLH.SSDMS.Common")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", ConfigFileExtension = "config", Watch = true)] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("9db66868-c6f0-4522-a551-09452b927c52")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SLH.SSDMS.Common/SLH.SSDMS.Common.csproj b/SLH.SSDMS.Common/SLH.SSDMS.Common.csproj new file mode 100644 index 0000000..c7706d6 --- /dev/null +++ b/SLH.SSDMS.Common/SLH.SSDMS.Common.csproj @@ -0,0 +1,67 @@ + + + + + Debug + AnyCPU + {9DB66868-C6F0-4522-A551-09452B927C52} + Library + Properties + SLH.SSDMS.Common + SLH.SSDMS.Common + v4.5.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\log4net.2.0.12\lib\net45\log4net.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + + \ No newline at end of file diff --git a/SLH.SSDMS.Common/StringChange.cs b/SLH.SSDMS.Common/StringChange.cs new file mode 100644 index 0000000..8df0a1d --- /dev/null +++ b/SLH.SSDMS.Common/StringChange.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Common +{ + /// + /// 数据类型转换 + /// + public static class StringChange + { + #region 数据类型转换函数 + public static byte[] Swap16Bytes(byte[] OldU16) + { + byte[] ReturnBytes = new byte[2]; + ReturnBytes[1] = OldU16[0]; + ReturnBytes[0] = OldU16[1]; + return ReturnBytes; + } + + public static bool CompareBytes(byte[] byteA, byte[] byteB, int iLen) + { + for (int i = 0; i < iLen; i++) + { + if (byteA[i] != byteB[i]) + { + return false; + } + } + return true; + } + + public static string bytesToHexStr(byte[] bytes, int iLen)//e.g. { 0x01, 0x01} ---> " 01 01" + { + string returnStr = ""; + if (bytes != null) + { + for (int i = 0; i < iLen; i++) + { + returnStr += bytes[i].ToString("X2"); + } + } + return returnStr; + } + + public static byte[] HexStrTorbytes(string strHex)//e.g. " 01 01" ---> { 0x01, 0x01} + { + strHex = strHex.Replace(" ", ""); + if ((strHex.Length % 2) != 0) + strHex += " "; + byte[] returnBytes = new byte[strHex.Length / 2]; + for (int i = 0; i < returnBytes.Length; i++) + returnBytes[i] = Convert.ToByte(strHex.Substring(i * 2, 2), 16); + return returnBytes; + } + + public static string StringToHexString(string s, Encoding encode) + { + byte[] b = encode.GetBytes(s); //按照指定编码将string编程字节数组 + string result = string.Empty; + for (int i = 0; i < b.Length; i++) //逐字节变为16进制字符,以%隔开 + { + result += "%" + Convert.ToString(b[i], 16); + } + return result; + } + + public static string HexStringToString(string hs, Encoding encode) + { + //以%分割字符串,并去掉空字符 + string[] chars = hs.Split(new char[] { '%' }, StringSplitOptions.RemoveEmptyEntries); + byte[] b = new byte[chars.Length]; + //逐个字符变为16进制字节数据 + for (int i = 0; i < chars.Length; i++) + { + b[i] = Convert.ToByte(chars[i], 16); + } + //按照指定编码将字节数组变为字符串 + return encode.GetString(b); + } + + public static short SwapInt16(this short n) + { + return (short)(((n & 0xff) << 8) | ((n >> 8) & 0xff)); + } + + public static ushort SwapUInt16(this ushort n) + { + return (ushort)(((n & 0xff) << 8) | ((n >> 8) & 0xff)); + } + + public static int SwapInt32(this int n) + { + return (int)(((SwapInt16((short)n) & 0xffff) << 0x10) | + (SwapInt16((short)(n >> 0x10)) & 0xffff)); + } + + public static uint SwapUInt32(this uint n) + { + return (uint)(((SwapUInt16((ushort)n) & 0xffff) << 0x10) | + (SwapUInt16((ushort)(n >> 0x10)) & 0xffff)); + } + + public static long SwapInt64(this long n) + { + return (long)(((SwapInt32((int)n) & 0xffffffffL) << 0x20) | + (SwapInt32((int)(n >> 0x20)) & 0xffffffffL)); + } + + public static ulong SwapUInt64(this ulong n) + { + return (ulong)(((SwapUInt32((uint)n) & 0xffffffffL) << 0x20) | + (SwapUInt32((uint)(n >> 0x20)) & 0xffffffffL)); + } + #endregion + } +} diff --git a/SLH.SSDMS.Common/StringExtension.cs b/SLH.SSDMS.Common/StringExtension.cs new file mode 100644 index 0000000..a3c368f --- /dev/null +++ b/SLH.SSDMS.Common/StringExtension.cs @@ -0,0 +1,339 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Xml; +using System.Xml.Serialization; + +namespace SLH.SSDMS.Common +{ + /// + /// 字符串通用类 + /// + public static class StringExtension + { + /// + /// 用于判断是否为空字符 + /// + /// + /// + public static bool IsBlank(this string s) + { + return s == null || (s.Trim().Length == 0); + } + + /// + /// 用于判断是否不为空字符 + /// + /// + /// + public static bool IsNotBlank(this string s) + { + return !s.IsBlank(); + } + /// + /// 判断是否为有效的Email地址 + /// + /// + /// + public static bool IsValidEmail(this string s) + { + if (!s.IsBlank()) + { + const string pattern = @"^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$"; + return Regex.IsMatch(s, pattern); + } + return false; + } + + /// + /// 验证是否是合法的电话号码 + /// + /// + /// + public static bool IsValidPhone(this string s) + { + if (!s.IsBlank()) + { + return Regex.IsMatch(s, @"^\+?((\d{2,4}(-)?)|(\(\d{2,4}\)))*(\d{0,16})*$"); + } + return true; + } + + /// + /// 验证是否是合法的手机号码 + /// + /// + /// + public static bool IsValidMobile(this string s) + { + if (!s.IsBlank()) + { + return Regex.IsMatch(s, @"^\+?\d{0,4}?[1][3-8]\d{9}$"); + } + return false; + } + + /// + /// 验证是否是合法的邮编 + /// + /// + /// + public static bool IsValidZipCode(this string s) + { + if (!s.IsBlank()) + { + return Regex.IsMatch(s, @"[1-9]\d{5}(?!\d)"); + } + return true; + } + + /// + /// 验证是否是合法的传真 + /// + /// + /// + public static bool IsValidFax(this string s) + { + if (!s.IsBlank()) + { + return Regex.IsMatch(s, @"(^[0-9]{3,4}\-[0-9]{7,8}$)|(^[0-9]{7,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)"); + } + return true; + } + + /// + /// 检查字符串是否为有效的INT32数字 + /// + /// + /// + public static bool IsInt32(this string val) + { + if (IsBlank(val)) + return false; + Int32 k; + return Int32.TryParse(val, out k); + } + + /// + /// 检查字符串是否为有效的INT64数字 + /// + /// + /// + public static bool IsInt64(this string val) + { + if (IsBlank(val)) + return false; + Int64 k; + return Int64.TryParse(val, out k); + } + + /// + /// 检查字符串是否为有效的Decimal + /// + /// + /// + public static bool IsDecimal(this string val) + { + if (IsBlank(val)) + return false; + decimal d; + return Decimal.TryParse(val, out d); + } + + /// + /// 将字符串转换成MD5加密字符串 + /// + /// + /// + public static string ToMD5(this string orgStr) + { + MD5 md5Hasher = MD5.Create(); + + // Convert the input string to a byte array and compute the hash. + byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(orgStr)); + + // Create a new Stringbuilder to collect the bytes + // and create a string. + StringBuilder sBuilder = new StringBuilder(); + + // Loop through each byte of the hashed data + // and format each one as a hexadecimal string. + for (int i = 0; i < data.Length; i++) + { + sBuilder.Append(data[i].ToString("x2")); + } + + // Return the hexadecimal string. + return sBuilder.ToString(); + } + + /// + /// 将对象序列化成XML + /// + /// + /// + /// + public static string ToXML(this T obj) where T : class + { + return ToXML(obj, Encoding.Default.BodyName); + } + public static string ToXML(this T obj, string encodeName) where T : class + { + if (obj == null) throw new ArgumentNullException("obj", "obj is null."); + + if (obj is string) throw new ApplicationException("obj can't be string object."); + + Encoding en = Encoding.GetEncoding(encodeName); + XmlSerializer serial = new XmlSerializer(typeof(T)); + XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); + ns.Add("", ""); + MemoryStream ms = new MemoryStream(); + XmlTextWriter xt = new XmlTextWriter(ms, en); + serial.Serialize(xt, obj, ns); + xt.Close(); + ms.Close(); + return en.GetString(ms.ToArray()); + } + /// + /// 将XML字符串反序列化成对象实体 + /// + /// + /// + /// + public static T Deserial(this string s) where T : class + { + return Deserial(s, Encoding.Default.BodyName); + } + public static T Deserial(this string s, string encodeName) where T : class + { + if (s.IsBlank()) + { + throw new ApplicationException("xml string is null or empty."); + } + XmlSerializer serial = new XmlSerializer(typeof(T)); + XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); + ns.Add("", ""); + + return (T)serial.Deserialize(new StringReader(s)); + } + /// + /// 获取扩展名 + /// + /// + /// + public static string GetExt(this string s) + { + string ret = string.Empty; + if (s.Contains('.')) + { + string[] temp = s.Split('.'); + ret = temp[temp.Length - 1]; + } + + return ret; + } + /// + /// 验证QQ格式 + /// + /// + /// + public static bool IsValidQQ(this string s) + { + if (!s.IsBlank()) + { + return Regex.IsMatch(s, @"^[1-9]\d{4,15}$"); + } + return false; + } + + /// + /// 字符串转成Int + /// + /// + /// + public static int ToInt(this string s) + { + int res; + int.TryParse(s, out res); + return res; + } + + /// + /// 生成单号 + /// + /// + /// + public static string GenerateBillsNo(this string s) + { + return string.Concat(s, DateTime.Now.ToString("yyyyMMddHHmmss")); + } + + /// + /// 生成初次入库单单号,出库单单号,盘点单单号 + /// + /// + /// + public static string GenerateInBillsNo(this string s) + { + return string.Concat(s, DateTime.Now.ToString("yyMMdd") + "001"); + } + + /// + /// 生成初次出库单单号 + /// + /// + /// + public static string GenerateOutBillsNo(this string s) + { + return string.Concat(s, DateTime.Now.ToString("yyyyMMdd") + "0001"); + } + + /// + /// 生成打印单号 + /// + /// + /// + public static string GenerateNumber(this string s) + { + Random rd = new Random(GetRandomSeed()); + string rdNext = rd.Next(000, 999).ToString(); + var str = string.Format("{0:000}", int.Parse(s)); + return DateTime.Now.Date.ToString("MMdd") + rdNext + str; + } + + /// + /// 生成打印单号,出库单流水号 + /// + /// + /// + public static string GeneratePrintNo(this string s) + { + var str = string.Format("{0:000}", int.Parse(s)); + return str; + } + + /// + /// 生成出库单流水号 + /// + /// + /// + public static string GenerateOutBillsFlowNo(this string s) + { + var str = string.Format("{0:0000}", int.Parse(s)); + return str; + } + + static int GetRandomSeed() + { + byte[] bytes = new byte[4]; + RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); + rng.GetBytes(bytes); + return BitConverter.ToInt32(bytes, 0); + } + } +} diff --git a/SLH.SSDMS.Common/UtilConvert.cs b/SLH.SSDMS.Common/UtilConvert.cs new file mode 100644 index 0000000..bec37ae --- /dev/null +++ b/SLH.SSDMS.Common/UtilConvert.cs @@ -0,0 +1,218 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Common +{ + /// + /// + /// + public static class UtilConvert + { + /// + /// + /// + /// + /// + public static int ObjToInt2(this object thisValue) + { + int reval = 0; + if (thisValue == null) return 0; + if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return reval; + } + /// + /// + /// + /// + /// + /// + public static int ObjToInt2(this object thisValue, int errorValue) + { + int reval = 0; + if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return errorValue; + } + /// + /// + /// + /// + /// + public static double ObjToMoney2(this object thisValue) + { + double reval = 0; + if (thisValue != null && thisValue != DBNull.Value && double.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return 0; + } + /// + /// + /// + /// + /// + /// + public static double ObjToMoney2(this object thisValue, double errorValue) + { + double reval = 0; + if (thisValue != null && thisValue != DBNull.Value && double.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return errorValue; + } + /// + /// + /// + /// + /// + public static string ObjToString2(this object thisValue) + { + if (thisValue != null) return thisValue.ToString().Trim(); + return ""; + } + /// + /// + /// + /// + /// + /// + public static string ObjToString2(this object thisValue, string errorValue) + { + if (thisValue != null) return thisValue.ToString().Trim(); + return errorValue; + } + /// + /// + /// + /// + /// + public static Decimal ObjToDecimal2(this object thisValue) + { + Decimal reval = 0; + if (thisValue != null && thisValue != DBNull.Value && decimal.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return 0; + } + /// + /// + /// + /// + /// + /// + public static Decimal ObjToDecimal2(this object thisValue, decimal errorValue) + { + Decimal reval = 0; + if (thisValue != null && thisValue != DBNull.Value && decimal.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return errorValue; + } + /// + /// + /// + /// + /// + public static DateTime ObjToDate2(this object thisValue) + { + DateTime reval = DateTime.MinValue; + if (thisValue != null && thisValue != DBNull.Value && DateTime.TryParse(thisValue.ToString(), out reval)) + { + reval = Convert.ToDateTime(thisValue); + } + return reval; + } + /// + /// + /// + /// + /// + /// + public static DateTime ObjToDate2(this object thisValue, DateTime errorValue) + { + DateTime reval = DateTime.MinValue; + if (thisValue != null && thisValue != DBNull.Value && DateTime.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return errorValue; + } + /// + /// + /// + /// + /// + public static bool ObjToBool2(this object thisValue) + { + bool reval = false; + if (thisValue != null && thisValue != DBNull.Value && bool.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return reval; + } + + /// + /// List转DataSet + /// + /// + /// + /// + public static DataSet ConvertToDataSet(List list) + { + if (list == null || list.Count <= 0) + { + return null; + } + + DataSet ds = new DataSet(); + DataTable dt = new DataTable(typeof(T).Name); + DataColumn column; + DataRow row; + + System.Reflection.PropertyInfo[] myPropertyInfo = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); + + foreach (T t in list) + { + if (t == null) + { + continue; + } + + row = dt.NewRow(); + + for (int i = 0, j = myPropertyInfo.Length; i < j; i++) + { + System.Reflection.PropertyInfo pi = myPropertyInfo[i]; + + string name = pi.Name; + + if (dt.Columns[name] == null) + { + column = new DataColumn(name, pi.PropertyType); + dt.Columns.Add(column); + } + + row[name] = pi.GetValue(t, null); + } + + dt.Rows.Add(row); + } + ds.Tables.Add(dt); + return ds; + } + } +} diff --git a/SLH.SSDMS.Common/checkUtil.cs b/SLH.SSDMS.Common/checkUtil.cs new file mode 100644 index 0000000..f0a825c --- /dev/null +++ b/SLH.SSDMS.Common/checkUtil.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Common +{ + public class checkUtil + { + /// + /// 异或校验 + /// + /// + /// + public static int BCC(byte[] data) + { + int temp = 0; + for (int index = 0; index < data.Length; index++) + { + temp = temp ^ data[index]; + } + + return temp; + } + } +} diff --git a/SLH.SSDMS.Common/log4net.config b/SLH.SSDMS.Common/log4net.config new file mode 100644 index 0000000..b4e86d8 --- /dev/null +++ b/SLH.SSDMS.Common/log4net.config @@ -0,0 +1,59 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SLH.SSDMS.Common/packages.config b/SLH.SSDMS.Common/packages.config new file mode 100644 index 0000000..8b4b4cc --- /dev/null +++ b/SLH.SSDMS.Common/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/SLH.SSDMS.Model/DO/Base_BeltInfo.cs b/SLH.SSDMS.Model/DO/Base_BeltInfo.cs new file mode 100644 index 0000000..24fd05b --- /dev/null +++ b/SLH.SSDMS.Model/DO/Base_BeltInfo.cs @@ -0,0 +1,158 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.DO +{ + /// + /// + /// + [SugarTable("base_BeltInfo")] + public partial class Base_BeltInfo + { + public Base_BeltInfo() + { + + } + + public Base_BeltInfo(string lotNum, string proYear, string proMonth, string proMachine, DateTime boardTime) + { + this.lotNum = lotNum; + this.proYear = proYear; + this.proMonth = proMonth; + this.proMachine = proMachine; + this.boardTime = boardTime; + } + + /// + /// Desc:主键 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int objId { get; set; } + + /// + /// Desc:卷号 + /// Default: + /// Nullable:True + /// + public string lotNum { get; set; } + + /// + /// Desc:生产年 + /// Default: + /// Nullable:True + /// + public string proYear { get; set; } + + /// + /// Desc:生产月 + /// Default: + /// Nullable:True + /// + public string proMonth { get; set; } + + /// + /// Desc:生产机台 + /// Default: + /// Nullable:True + /// + public string proMachine { get; set; } + + /// + /// Desc:上机时间 + /// Default: + /// Nullable:True + /// + public DateTime boardTime { get; set; } + + /// + /// 安装长度 + /// + public int beltLength { get; set; } + + /// + /// 更换标识 + /// + public int updateFlag { get; set; } + + /// + /// 运行时长 + /// + public decimal runTime { get; set; } + + /// + /// Desc:带强 + /// Default: + /// Nullable:True + /// + public string beltStrength { get; set; } + + /// + /// Desc:带宽 + /// Default: + /// Nullable:True + /// + public string beltWidth { get; set; } + + /// + /// Desc:上胶厚度 + /// Default: + /// Nullable:True + /// + public string upGlueThick { get; set; } + + /// + /// Desc:连接符 + /// Default: + /// Nullable:True + /// + public string unionSymbol { get; set; } + + /// + /// Desc:下胶厚度 + /// Default: + /// Nullable:True + /// + public string downGlueThick { get; set; } + + /// + /// Desc:盖胶级别 + /// Default: + /// Nullable:True + /// + public string coverGlueLevel { get; set; } + + /// + /// 首次上机时间 + /// + public string firstTime { get; set; } + + public string uuid { get; set; } + + /// + /// 正转时长 + /// + public int clockwiseTime { get; set; } + + /// + /// 正转里程 + /// + public int clockwiseDistance { get; set; } + + /// + /// 反转时长 + /// + public int antiClockwiseTime { get; set; } + + /// + /// 反转里程 + /// + public int antiClockwiseDistance { get; set; } + + } +} diff --git a/SLH.SSDMS.Model/DO/Base_Calculate.cs b/SLH.SSDMS.Model/DO/Base_Calculate.cs new file mode 100644 index 0000000..0514813 --- /dev/null +++ b/SLH.SSDMS.Model/DO/Base_Calculate.cs @@ -0,0 +1,100 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.DO +{ + /// + /// + /// + [SugarTable("base_Calculate")] + public partial class Base_Calculate + { + public Base_Calculate() + { + + + } + /// + /// Desc: + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int objId { get; set; } + + /// + /// Desc:标签序号 + /// Default: + /// Nullable:True + /// + public string rfidOrder { get; set; } + + /// + /// Desc:rfid标签 + /// Default: + /// Nullable:True + /// + public string rfidNum { get; set; } + + /// + /// Desc:第一次记录时间 + /// Default: + /// Nullable:True + /// + public DateTime? firstRecordTime { get; set; } + + /// + /// Desc:最新读取时间 + /// Default: + /// Nullable:True + /// + public DateTime? readTime { get; set; } + + /// + /// Desc:前距 + /// Default: + /// Nullable:True + /// + public string preDistance { get; set; } + + /// + /// Desc:后距 + /// Default: + /// Nullable:True + /// + public string aftDistance { get; set; } + + /// + /// Desc:删除标志 + /// Default: + /// Nullable:True + /// + public string deleteFlag { get; set; } + + /// + /// Desc:预留 + /// Default: + /// Nullable:True + /// + public string reserved1 { get; set; } + + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string reserved2 { get; set; } + + /// + /// Desc: + /// Default: + /// Nullable:True + /// + public string reserved3 { get; set; } + + } +} diff --git a/SLH.SSDMS.Model/DO/Base_ChangeRecord.cs b/SLH.SSDMS.Model/DO/Base_ChangeRecord.cs new file mode 100644 index 0000000..9fc2974 --- /dev/null +++ b/SLH.SSDMS.Model/DO/Base_ChangeRecord.cs @@ -0,0 +1,143 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.DO +{ + /// + ///更换记录表 + /// + [SugarTable("base_ChangeRecord")] + public partial class Base_ChangeRecord + { + public Base_ChangeRecord() + { + + + } + + public Base_ChangeRecord(string lotNum, string proYear, string proMonth, string proMachine, + string beltStrength, string beltWidth, string upGlueThick, + string unionSymbol, string downGlueThick, string coverGlueLevel, string oldUUID) + { + this.lotNum = lotNum; + this.proYear = proYear; + this.proMonth = proMonth; + this.proMachine = proMachine; + this.beltStrength = beltStrength; + this.beltWidth = beltWidth; + this.upGlueThick = upGlueThick; + this.unionSymbol = unionSymbol; + this.downGlueThick = downGlueThick; + this.coverGlueLevel = coverGlueLevel; + this.oldUUID = oldUUID; + } + + + /// + /// Desc:主键 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int objId { get; set; } + + /// + /// 历史卷号 + /// + public string oldNum { get; set; } + + /// + /// Desc:卷号 + /// Default: + /// Nullable:True + /// + public string lotNum { get; set; } + + /// + /// Desc:生产年 + /// Default: + /// Nullable:True + /// + public string proYear { get; set; } + + /// + /// Desc:生产月 + /// Default: + /// Nullable:True + /// + public string proMonth { get; set; } + + /// + /// Desc:生产机台 + /// Default: + /// Nullable:True + /// + public string proMachine { get; set; } + + /// + /// Desc:带强 + /// Default: + /// Nullable:True + /// + public string beltStrength { get; set; } + + /// + /// Desc:带宽 + /// Default: + /// Nullable:True + /// + public string beltWidth { get; set; } + + /// + /// Desc:上胶厚度 + /// Default: + /// Nullable:True + /// + public string upGlueThick { get; set; } + + /// + /// Desc:连接符 + /// Default: + /// Nullable:True + /// + public string unionSymbol { get; set; } + + /// + /// Desc:下胶厚度 + /// Default: + /// Nullable:True + /// + public string downGlueThick { get; set; } + + /// + /// Desc:盖胶级别 + /// Default: + /// Nullable:True + /// + public string coverGlueLevel { get; set; } + + /// + /// 更换时间 + /// + public DateTime changeTime { get; set; } + /// + /// 运行里程 + /// + public int runDistance { get; set; } + + /// + /// 运行时长 + /// + public decimal runTime { get; set; } + + /// + /// 旧胶带UUID + /// + public string oldUUID { get; set; } + + } +} diff --git a/SLH.SSDMS.Model/DO/Base_LogRecord.cs b/SLH.SSDMS.Model/DO/Base_LogRecord.cs new file mode 100644 index 0000000..2dd4fcb --- /dev/null +++ b/SLH.SSDMS.Model/DO/Base_LogRecord.cs @@ -0,0 +1,63 @@ +using SLH.SSDMS.Model.Enums; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.DO +{ + /// + ///日志记录 + /// + [SugarTable("base_LogRecord")] + public partial class Base_LogRecord + { + public Base_LogRecord() { } + + public Base_LogRecord(LogType logType, string logInfo, string logError, DateTime recordTime) + { + this.logType = logType; + this.logInfo = logInfo; + this.logError = logError; + this.recordTime = recordTime; + } + /// + /// Desc:自增标识 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int objId { get; set; } + + /// + /// Desc:日志类型:1-查询、2-添加、3-修改、4-删除 + /// Default: + /// Nullable:True + /// + public LogType logType { get; set; } + + /// + /// Desc:日志信息 + /// Default: + /// Nullable:True + /// + public string logInfo { get; set; } + + /// + /// Desc:异常日志 + /// Default: + /// Nullable:True + /// + public string logError { get; set; } + + /// + /// Desc:记录时间 + /// Default: + /// Nullable:True + /// + public DateTime recordTime { get; set; } + + } +} diff --git a/SLH.SSDMS.Model/DO/Base_RFIDInfo.cs b/SLH.SSDMS.Model/DO/Base_RFIDInfo.cs new file mode 100644 index 0000000..c63c190 --- /dev/null +++ b/SLH.SSDMS.Model/DO/Base_RFIDInfo.cs @@ -0,0 +1,84 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.DO +{ + [SugarTable("base_RFIDInfo")] + public class Base_RFIDInfo + { + + public Base_RFIDInfo() + { + + } + + public Base_RFIDInfo(string rfidCode, string lotNum, int orderFlag, int updateFlag, string firstTime, string uuid, int preDistance) + { + + this.rfidCode = rfidCode; + this.lotNum = lotNum; + this.orderFlag = orderFlag; + this.updateFlag = updateFlag; + this.firstTime = firstTime; + this.uuid = uuid; + this.preDistance = preDistance; + } + + /// + /// Desc:主键 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int objId { get; set; } + + /// + /// Desc:RFID + /// Default: + /// Nullable:True + /// + public string rfidCode { get; set; } + + /// + /// Desc:卷号 + /// Default: + /// Nullable:True + /// + public string lotNum { get; set; } + + /// + /// Desc:正反转标识 0-正转、1-反转 + /// Default: + /// Nullable:True + /// + public int orderFlag { get; set; } + + /// /// + /// Desc:更换标识 0-否、1-是 + /// Default: + /// Nullable:True + /// + public int updateFlag { get; set; } + + /// + /// Desc:首次读取时间 + /// Default: + /// Nullable:True + /// + public string firstTime { get; set; } + + /// + /// UUID + /// + public string uuid { get; set; } + + /// + /// 前距 + /// + public int preDistance { get; set; } + } +} diff --git a/SLH.SSDMS.Model/DO/Base_ReadRecord.cs b/SLH.SSDMS.Model/DO/Base_ReadRecord.cs new file mode 100644 index 0000000..dd07db6 --- /dev/null +++ b/SLH.SSDMS.Model/DO/Base_ReadRecord.cs @@ -0,0 +1,155 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.DO +{ + /// + /// + /// + [SugarTable("base_ReadRecord")] + public partial class Base_ReadRecord + { + public Base_ReadRecord() + { + + + } + /// + /// Desc:标识 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int objId { get; set; } + + /// + /// Desc:rfid标签号 + /// Default: + /// Nullable:True + /// + public string rfidCode { get; set; } + + /// + /// Desc:生产年 + /// Default: + /// Nullable:True + /// + public string proYear { get; set; } + + /// + /// Desc:生产月 + /// Default: + /// Nullable:True + /// + public string proMonth { get; set; } + + /// + /// Desc:生产机台 + /// Default: + /// Nullable:True + /// + public string proMachine { get; set; } + + /// + /// Desc:带强 + /// Default: + /// Nullable:True + /// + public string beltStrength { get; set; } + + /// + /// Desc:带宽 + /// Default: + /// Nullable:True + /// + public string beltWidth { get; set; } + + /// + /// Desc:上胶厚度 + /// Default: + /// Nullable:True + /// + public string upGlueThick { get; set; } + + /// + /// Desc:连接符 + /// Default: + /// Nullable:True + /// + public string unionSymbol { get; set; } + + /// + /// Desc:下胶厚度 + /// Default: + /// Nullable:True + /// + public string downGlueThick { get; set; } + + /// + /// Desc:盖胶级别 + /// Default: + /// Nullable:True + /// + public string coverGlueLevel { get; set; } + + /// + /// Desc:卷号 + /// Default: + /// Nullable:True + /// + public string lotNum { get; set; } + + /// + /// Desc:RFID序号 + /// Default: + /// Nullable:True + /// + public string rfidOrder { get; set; } + + /// + /// Desc:RFID前间隔 + /// Default: + /// Nullable:True + /// + public int preDistance { get; set; } + + /// + /// Desc:RFID后间隔 + /// Default: + /// Nullable:True + /// + public int aftDistance { get; set; } + + /// + /// Desc:记录时间 + /// Default: + /// Nullable:True + /// + public DateTime readTime { get; set; } + + /// + /// + /// + public decimal timeNumber { get; set; } + + /// + /// 终端地址 + /// + public string terminal { get; set; } + + /// + /// UUID + /// + public string uuid { get; set; } + + /// + /// 正反转标识:0-正转、1-反转 + /// + public int orderFlag { get; set; } + + } +} diff --git a/SLH.SSDMS.Model/DO/Base_RunRecord.cs b/SLH.SSDMS.Model/DO/Base_RunRecord.cs new file mode 100644 index 0000000..a7654b9 --- /dev/null +++ b/SLH.SSDMS.Model/DO/Base_RunRecord.cs @@ -0,0 +1,83 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.DO +{ + /// + /// + /// + [SugarTable("base_RunRecord")] + public partial class Base_RunRecord + { + public Base_RunRecord() + { + + } + + public Base_RunRecord(string lotNum, int runTime, int runDistance, DateTime recordTime) + { + this.lotNum = lotNum; + this.runTime = runTime; + this.runDistance = runDistance; + this.recordTime = recordTime; + } + + /// + /// Desc:主键 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int objId { get; set; } + + /// + /// Desc:卷号 + /// Default: + /// Nullable:True + /// + public string lotNum { get; set; } + + /// + /// 开机时间 + /// + public DateTime startTime { get; set; } + + /// + /// 关机时间 + /// + public DateTime endTime { get; set; } + + /// + /// Desc:运行时长 + /// Default: + /// Nullable:True + /// + public int runTime { get; set; } + + /// + /// Desc:运行距离 + /// Default: + /// Nullable:True + /// + public int runDistance { get; set; } + + /// + /// Desc:日期 + /// Default: + /// Nullable:True + /// + public DateTime recordTime { get; set; } + + /// + /// Desc:是否启用 + /// Default: + /// Nullable:True + /// + public int delete_flag { get; set; } + + } +} diff --git a/SLH.SSDMS.Model/DO/Base_rfidOrder.cs b/SLH.SSDMS.Model/DO/Base_rfidOrder.cs new file mode 100644 index 0000000..5018c3c --- /dev/null +++ b/SLH.SSDMS.Model/DO/Base_rfidOrder.cs @@ -0,0 +1,52 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.DO +{ + /// + /// RFID顺序 + /// + [SugarTable("base_rfidOrder")] + public class Base_rfidOrder + { + /// + /// Desc:主键 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int objId { get; set; } + + /// + /// Desc:RFID + /// Default: + /// Nullable:False + /// + public string RFIDCode { get; set; } + + /// + /// Desc:卷号 + /// Default: + /// Nullable:False + /// + public string lotNum { get; set; } + + /// + /// Desc:RFID序号 + /// Default: + /// Nullable:False + /// + public int rfidOrder { get; set; } + + /// + /// Desc:修改时间 + /// Default: + /// Nullable:False + /// + public DateTime updateTime { get; set; } + } +} diff --git a/SLH.SSDMS.Model/DO/Day_RunInfo.cs b/SLH.SSDMS.Model/DO/Day_RunInfo.cs new file mode 100644 index 0000000..efb6007 --- /dev/null +++ b/SLH.SSDMS.Model/DO/Day_RunInfo.cs @@ -0,0 +1,99 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.DO +{ + [SugarTable("day_RunInfo")] + public class Day_RunInfo + { + + public Day_RunInfo() + { + + } + + public Day_RunInfo(string lotNum, string beginTime, string endTime, string recordTime) + { + this.lotNum = lotNum; + this.beginTime = beginTime; + this.endTime = endTime; + this.recordTime = recordTime; + } + + /// + /// Desc:主键 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int objId { get; set; } + + /// + /// Desc:卷号 + /// Default: + /// Nullable:False + /// + public string lotNum { get; set; } + + /// + /// Desc:开始时间 + /// Default: + /// Nullable:False + /// + public string beginTime { get; set; } + + /// + /// Desc:结束时间 + /// Default: + /// Nullable:False + /// + public string endTime { get; set; } + + /// + /// Desc:运行时长 + /// Default: + /// Nullable:False + /// + public decimal runTime { get; set; } + + /// + /// Desc:运行里程 + /// Default: + /// Nullable:False + /// + public decimal runDistance { get; set; } + + /// + /// Desc:记录时间 + /// Default: + /// Nullable:False + /// + public string recordTime { get; set; } + + /// + /// 正转时长 + /// + public int clockwiseTime { get; set; } + + /// + /// 正转里程 + /// + public int clockwiseDistance { get; set; } + + /// + /// 反转时长 + /// + public int antiClockwiseTime { get; set; } + + /// + /// 反转里程 + /// + public int antiClockwiseDistance { get; set; } + + public string uuid { get; set; } + } +} diff --git a/SLH.SSDMS.Model/DO/Sys_Config.cs b/SLH.SSDMS.Model/DO/Sys_Config.cs new file mode 100644 index 0000000..ad0ec79 --- /dev/null +++ b/SLH.SSDMS.Model/DO/Sys_Config.cs @@ -0,0 +1,25 @@ +using Microsoft.SqlServer.Server; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.DO +{ + [SugarTable("sys_config")] + public class Sys_Config + { + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int config_id { get; set; } + + public string config_name { get; set; } + + public string config_key { get; set; } + + public string config_value { get; set; } + + public string remark { get; set; } + } +} diff --git a/SLH.SSDMS.Model/DTO/BeltInfoDTO.cs b/SLH.SSDMS.Model/DTO/BeltInfoDTO.cs new file mode 100644 index 0000000..6004b14 --- /dev/null +++ b/SLH.SSDMS.Model/DTO/BeltInfoDTO.cs @@ -0,0 +1,118 @@ +using SLH.SSDMS.Model.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.DTO +{ + /// + /// 输送带里程DTO + /// + public class BeltInfoDTO + { /// + /// Desc:主键 + /// Default: + /// Nullable:False + /// + public int objId { get; set; } + + /// + /// Desc:卷号 + /// Default: + /// Nullable:True + /// + public string lotNum { get; set; } + + /// + /// Desc:生产年 + /// Default: + /// Nullable:True + /// + public string proYear { get; set; } + + /// + /// Desc:生产月 + /// Default: + /// Nullable:True + /// + public string proMonth { get; set; } + + /// + /// Desc:生产机台 + /// Default: + /// Nullable:True + /// + public string proMachine { get; set; } + + /// + /// Desc:上机时间 + /// Default: + /// Nullable:True + /// + public DateTime boardTime { get; set; } + + /// + /// 更换标识 + /// + public IfBeltChanged updateFlag { get; set; } + + /// + /// 运行时长 + /// + public decimal runTime { get; set; } + + /// + /// 运行里程 + /// + public decimal distance { get; set; } + + /// + /// Desc:带强 + /// Default: + /// Nullable:True + /// + public string beltStrength { get; set; } + + /// + /// Desc:带宽 + /// Default: + /// Nullable:True + /// + public string beltWidth { get; set; } + + /// + /// Desc:上胶厚度 + /// Default: + /// Nullable:True + /// + public string upGlueThick { get; set; } + + /// + /// Desc:连接符 + /// Default: + /// Nullable:True + /// + public string unionSymbol { get; set; } + + /// + /// Desc:下胶厚度 + /// Default: + /// Nullable:True + /// + public string downGlueThick { get; set; } + + /// + /// Desc:盖胶级别 + /// Default: + /// Nullable:True + /// + public string coverGlueLevel { get; set; } + + /// + /// + /// + public DateTime firstTime { get; set; } + } +} diff --git a/SLH.SSDMS.Model/DTO/PageModel.cs b/SLH.SSDMS.Model/DTO/PageModel.cs new file mode 100644 index 0000000..6ffc34e --- /dev/null +++ b/SLH.SSDMS.Model/DTO/PageModel.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.DTO +{ + /// + /// 通用分页信息类 + /// + public class PageModel + { + /// + /// 当前页标 + /// + public int page { get; set; } = 1; + /// + /// 总页数 + /// + public int pageCount { get; set; } = 6; + /// + /// 数据总数 + /// + public int dataCount { get; set; } = 0; + /// + /// 每页大小 + /// + public int PageSize { set; get; } + /// + /// 返回数据 + /// + public List data { get; set; } + } +} diff --git a/SLH.SSDMS.Model/DTO/UploadModelDTO.cs b/SLH.SSDMS.Model/DTO/UploadModelDTO.cs new file mode 100644 index 0000000..7a24b4a --- /dev/null +++ b/SLH.SSDMS.Model/DTO/UploadModelDTO.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.DTO +{ + /// + /// 无人巡检数据上传DTO + /// + public class UploadModelDTO + { + public int objId { get; set; } + + /// + /// 运行方向 + /// + public int orderFlag { get; set; } + + /// + /// 运行速度 + /// + public decimal speed { get; set; } + + /// + /// 运载流量 + /// + public decimal carryFlow { get; set; } + + /// + /// 总作业量 + /// + public decimal titalWorkLoad { get; set; } + + /// + /// 记录时间 + /// + public string readTime { get; set; } + } +} diff --git a/SLH.SSDMS.Model/DTO/ViewModelDTO.cs b/SLH.SSDMS.Model/DTO/ViewModelDTO.cs new file mode 100644 index 0000000..c89ff77 --- /dev/null +++ b/SLH.SSDMS.Model/DTO/ViewModelDTO.cs @@ -0,0 +1,181 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.DTO +{ + /// + /// 视图层数据封装 + /// + public class ViewModelDTO + { + /// + /// Desc:标识 + /// Default: + /// Nullable:False + /// + public int objId { get; set; } + + /// + /// Desc:rfid标签号 + /// Default: + /// Nullable:True + /// + public string rfidCode { get; set; } + + /// + /// Desc:生产年 + /// Default: + /// Nullable:True + /// + public string proYear { get; set; } + + /// + /// Desc:生产月 + /// Default: + /// Nullable:True + /// + public string proMonth { get; set; } + + /// + /// Desc:生产机台 + /// Default: + /// Nullable:True + /// + public string proMachine { get; set; } + + /// + /// Desc:带强 + /// Default: + /// Nullable:True + /// + public string beltStrength { get; set; } + + /// + /// Desc:带宽 + /// Default: + /// Nullable:True + /// + public string beltWidth { get; set; } + + /// + /// Desc:上胶厚度 + /// Default: + /// Nullable:True + /// + public string upGlueThick { get; set; } + + /// + /// Desc:连接符 + /// Default: + /// Nullable:True + /// + public string unionSymbol { get; set; } + + /// + /// Desc:下胶厚度 + /// Default: + /// Nullable:True + /// + public string downGlueThick { get; set; } + + /// + /// Desc:盖胶级别 + /// Default: + /// Nullable:True + /// + public string coverGlueLevel { get; set; } + + /// + /// Desc:卷号 + /// Default: + /// Nullable:True + /// + public string lotNum { get; set; } + + /// + /// Desc:RFID序号 + /// Default: + /// Nullable:True + /// + public string rfidOrder { get; set; } + + /// + /// Desc:RFID前间隔 + /// Default: + /// Nullable:True + /// + public int preDistance { get; set; } + + /// + /// Desc:RFID后间隔 + /// Default: + /// Nullable:True + /// + public int aftDistance { get; set; } + + /// + /// Desc:记录时间 + /// Default: + /// Nullable:True + /// + public DateTime readTime { get; set; } + + /// + /// 速度 + /// + public decimal speed { get; set; } + + /// + /// 距离 + /// + public decimal distance { get; set; } + + /// + /// 上机时间 + /// + public DateTime boardTime { get; set; } + + /// + /// 更换标识 + /// + public int updateFlag { get; set; } + + /// + /// 累计运行时长 + /// + public decimal runTime { get; set; } + + /// + /// 终端地址 + /// + public string terminal { get; set; } + + /// + /// 胶带数量 + /// + public int beltSum { get; set; } + + /// + /// 运转方向 0-正转;1-反转 + /// + public int orderFlag { get; set; } + + /// + /// 首次读取时间 + /// + public string firstTime { get; set; } + + /// + /// 运载流量 + /// + public decimal carryFlow { get; set; } + + /// + /// 总作业量 + /// + public decimal titalWorkLoad { get; set; } + } +} diff --git a/SLH.SSDMS.Model/Enums/IfBeltChanged.cs b/SLH.SSDMS.Model/Enums/IfBeltChanged.cs new file mode 100644 index 0000000..637b89d --- /dev/null +++ b/SLH.SSDMS.Model/Enums/IfBeltChanged.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.Enums +{ + public enum IfBeltChanged + { + /// + /// 是 + /// + YES, + /// + /// 否 + /// + NO, + } +} diff --git a/SLH.SSDMS.Model/Enums/LogType.cs b/SLH.SSDMS.Model/Enums/LogType.cs new file mode 100644 index 0000000..e1258d0 --- /dev/null +++ b/SLH.SSDMS.Model/Enums/LogType.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Model.Enums +{ + public enum LogType + { + /// + /// 查詢 + /// + 查询记录, + + /// + /// 添加 + /// + 添加记录, + + /// + /// 修改 + /// + 修改记录, + + /// + /// 刪除 + /// + 刪除记录, + + /// + /// 接收 + /// + 接收记录, + + /// + /// 解析 + /// + 解析记录, + + /// + /// 运行日志 + /// + 运行日志, + } +} diff --git a/SLH.SSDMS.Model/Properties/AssemblyInfo.cs b/SLH.SSDMS.Model/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3f866cf --- /dev/null +++ b/SLH.SSDMS.Model/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SLH.SSDMS.Model")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SLH.SSDMS.Model")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("1c8b2e03-fc2d-4385-b87a-51a8dd92fe01")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SLH.SSDMS.Model/SLH.SSDMS.Model.csproj b/SLH.SSDMS.Model/SLH.SSDMS.Model.csproj new file mode 100644 index 0000000..418b7d8 --- /dev/null +++ b/SLH.SSDMS.Model/SLH.SSDMS.Model.csproj @@ -0,0 +1,70 @@ + + + + + Debug + AnyCPU + {1C8B2E03-FC2D-4385-B87A-51A8DD92FE01} + Library + Properties + SLH.SSDMS.Model + SLH.SSDMS.Model + v4.5.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\SqlSugar.5.0.2.6\lib\SqlSugar.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SLH.SSDMS.Model/packages.config b/SLH.SSDMS.Model/packages.config new file mode 100644 index 0000000..2d3e8c5 --- /dev/null +++ b/SLH.SSDMS.Model/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/SLH.SSDMS.RestSharp/Properties/AssemblyInfo.cs b/SLH.SSDMS.RestSharp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..75a37a4 --- /dev/null +++ b/SLH.SSDMS.RestSharp/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SLH.SSDMS.RestSharp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SLH.SSDMS.RestSharp")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("bd42a6ec-6a27-4e28-938f-9e7906d049e0")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SLH.SSDMS.RestSharp/SLH.SSDMS.RestSharp.csproj b/SLH.SSDMS.RestSharp/SLH.SSDMS.RestSharp.csproj new file mode 100644 index 0000000..e2fd54e --- /dev/null +++ b/SLH.SSDMS.RestSharp/SLH.SSDMS.RestSharp.csproj @@ -0,0 +1,69 @@ + + + + + Debug + AnyCPU + {BD42A6EC-6A27-4E28-938F-9E7906D049E0} + Library + Properties + SLH.SSDMS.RestSharp + SLH.SSDMS.RestSharp + v4.5.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\packages\RestSharp.106.11.7\lib\net452\RestSharp.dll + + + + + + + + + + + + + + + + + + + + + + {9DB66868-C6F0-4522-A551-09452B927C52} + SLH.SSDMS.Common + + + {1C8B2E03-FC2D-4385-B87A-51A8DD92FE01} + SLH.SSDMS.Model + + + + \ No newline at end of file diff --git a/SLH.SSDMS.RestSharp/Upload.cs b/SLH.SSDMS.RestSharp/Upload.cs new file mode 100644 index 0000000..d2d9648 --- /dev/null +++ b/SLH.SSDMS.RestSharp/Upload.cs @@ -0,0 +1,45 @@ +using Newtonsoft.Json; +using RestSharp; +using SLH.SSDMS.Common; +using SLH.SSDMS.Model.DTO; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.RestSharp +{ + public class Upload + { + + public static void sendMessage(ViewModelDTO viewModelDTO) + { + try + { + var client = new RestClient(ConfigHelper.GetConfig("uploadUrl")); + var request = new RestRequest(Method.POST); + request.AddHeader("Content-Type", "application/json"); + UploadModelDTO uploadModelDTO = new UploadModelDTO + { + objId = 10, + orderFlag = viewModelDTO.orderFlag, + speed = viewModelDTO.speed, + carryFlow = viewModelDTO.carryFlow, + titalWorkLoad = viewModelDTO.titalWorkLoad, + readTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + }; + string info = JsonConvert.SerializeObject(uploadModelDTO); + LogHelper.Info("上传数据至无人巡检系统:" + info); + request.AddJsonBody(info); + + IRestResponse response = client.Execute(request); + string result = response.Content; + LogHelper.Info("无人巡检数据上传成功,返回:" + result); + }catch(Exception ex) + { + LogHelper.Error("数据上传至无人巡检系统出现异常", ex); + } + } + } +} diff --git a/SLH.SSDMS.RestSharp/app.config b/SLH.SSDMS.RestSharp/app.config new file mode 100644 index 0000000..a0cefc2 --- /dev/null +++ b/SLH.SSDMS.RestSharp/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/SLH.SSDMS.RestSharp/packages.config b/SLH.SSDMS.RestSharp/packages.config new file mode 100644 index 0000000..ee227ba --- /dev/null +++ b/SLH.SSDMS.RestSharp/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/SLH.SSDMS.Services/IBaseServices.cs b/SLH.SSDMS.Services/IBaseServices.cs new file mode 100644 index 0000000..9ee9b8c --- /dev/null +++ b/SLH.SSDMS.Services/IBaseServices.cs @@ -0,0 +1,206 @@ +using SLH.SSDMS.Model.DTO; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Services +{ + /// + /// IBaseRepository + /// + public interface IBaseServices where TEntity : class + { + Task QuerySingle(Expression> whereExpression); + + Task QueryById(object objId); + Task QueryById(object objId, bool blnUseCache = false); + Task> QueryByIDs(object[] lstIds); + + Task Add(TEntity model); + + Task AddLog(TEntity model); + + Task Add(List listEntity); + + Task DeleteById(object id); + + Task Delete(TEntity model); + + Task Delete(Expression> whereExpression); + + Task DeleteByIds(object[] ids); + + Task Update(TEntity model); + Task Update(TEntity entity, string strWhere); + + Task Update(object operateAnonymousObjects); + + Task Update(TEntity entity, List lstColumns = null, List lstIgnoreColumns = null, string strWhere = ""); + + Task> Query(); + Task> Query(string strWhere); + Task> Query(Expression> whereExpression); + Task> Query(Expression> whereExpression, string strOrderByFileds); + Task> Query(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true); + Task> Query(string strWhere, string strOrderByFileds); + + Task QueryFirst(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true); + + Task> Query(Expression> whereExpression, int intTop, string strOrderByFileds); + Task> Query(string strWhere, int intTop, string strOrderByFileds); + + Task> Query( + Expression> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds); + Task> Query(string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds); + + + Task> QueryPage(Expression> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null); + + Task> QueryMuch( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null) where T : class, new(); + + Task> QueryMuch( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null) where T : class, new(); + + + Task> QueryMuch( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null) where T : class, new(); + + Task> QueryMuch( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null) where T : class, new(); + + #region 多表分页 + + /// + ///查询-多表查询 + /// + /// 实体1 + /// 实体2 + /// 实体3 + /// 实体4 + /// 实体5 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + Task> QueryMuchPage( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, + string strOrderByFileds = null) where T : class, new(); + + /// + ///查询-多表查询 + /// + /// 实体1 + /// 实体2 + /// 实体3 + /// 实体4 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + Task> QueryMuchPage( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, + string strOrderByFileds = null) where T : class, new(); + + + /// + ///查询-多表查询 + /// + /// 实体1 + /// 实体2 + /// 实体3 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + Task> QueryMuchPage( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, + string strOrderByFileds = null) where T : class, new(); + + + /// + ///查询-多表查询 + /// + /// 实体1 + /// 实体2 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + Task> QueryMuchPage( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, + string strOrderByFileds = null) where T : class, new(); + + + + /// + ///查询-多表查询 (测试) + /// + /// 实体1 + /// 实体2 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + Task> QueryMuchPage( + Expression> joinExpression, + Expression> selectExpression, + Expression> sortExpression, + Expression> whereLambda = null, + int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new(); + + #endregion + + /// + /// 存储过程 + /// + /// + /// + /// + Task> QueryByProc(string proc, List parameters) where T : class, new(); + + Task, List>> QueryByProc(string proc, List parameters) + where T : class, new(); + + + /// + /// sql语句 + /// + Task> QueryBySql(string sql, List parameters) where T : class, new(); + + #region 自定义 + /// + /// 添加上机记录 + /// + /// + /// + /// + Task BoardAdd(TEntity boardEntity, Expression> whereExpression); + #endregion + } +} diff --git a/SLH.SSDMS.Services/IBufferParse.cs b/SLH.SSDMS.Services/IBufferParse.cs new file mode 100644 index 0000000..b7caf95 --- /dev/null +++ b/SLH.SSDMS.Services/IBufferParse.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Services +{ + public interface IBufferParse + { + /// + /// 心跳解析 + /// + /// + /// + Task HeartAnalysis(byte[] buffer); + + /// + /// 读取解析 + /// + /// + /// + Task ReadAnalysis(byte[] buffer); + } +} diff --git a/SLH.SSDMS.Services/IReturnBuffer.cs b/SLH.SSDMS.Services/IReturnBuffer.cs new file mode 100644 index 0000000..70afcac --- /dev/null +++ b/SLH.SSDMS.Services/IReturnBuffer.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Services +{ + public interface IReturnBuffer + { + /// + /// 心跳解析成功结果 + /// + /// + byte[] HeartAnalysisResult(int status, byte terminal); + + /// + /// 读取解析结果 + /// + /// + byte[] ReadAnalysisResult(int status, byte terminal); + + /// + /// 定点停机、打开终端IO指令 + /// + /// + byte[] HaltBuffer(); + } +} diff --git a/SLH.SSDMS.Services/IRfidJudge.cs b/SLH.SSDMS.Services/IRfidJudge.cs new file mode 100644 index 0000000..3f19e3a --- /dev/null +++ b/SLH.SSDMS.Services/IRfidJudge.cs @@ -0,0 +1,47 @@ +using SLH.SSDMS.Model.DO; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Services +{ + public interface IRfidJudge + { + /// + /// 判断当前运行方向 + /// + /// + /// + Task JudgeDirection(string rfidCode); + + /// + /// 判断当前运行速度 + /// + /// + /// + Task JudgeRunSpeed(Base_ReadRecord readRecord); + + /// + /// 判断当前运行里程 + /// + /// + /// + Task JudgeRunDistance(Base_ReadRecord readRecord); + + /// + /// 判断当前运行时长 + /// + /// + /// + Task JudgeRunTime(Base_ReadRecord readRecord); + + /// + /// 判断当前胶带上机时间 + /// + /// + /// + Task JudgeFirstTime(string lotCode); + } +} diff --git a/SLH.SSDMS.Services/Properties/AssemblyInfo.cs b/SLH.SSDMS.Services/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c7b5090 --- /dev/null +++ b/SLH.SSDMS.Services/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SLH.SSDMS.Services")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SLH.SSDMS.Services")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("3efe1a92-df3d-4b98-8a6b-dda264385e52")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SLH.SSDMS.Services/SLH.SSDMS.Services.csproj b/SLH.SSDMS.Services/SLH.SSDMS.Services.csproj new file mode 100644 index 0000000..1f5558e --- /dev/null +++ b/SLH.SSDMS.Services/SLH.SSDMS.Services.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {3EFE1A92-DF3D-4B98-8A6B-DDA264385E52} + Library + Properties + SLH.SSDMS.Services + SLH.SSDMS.Services + v4.5.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\AutoMapper.5.0.2\lib\net45\AutoMapper.dll + + + ..\packages\SqlSugar.5.0.2.6\lib\SqlSugar.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + {9DB66868-C6F0-4522-A551-09452B927C52} + SLH.SSDMS.Common + + + {1C8B2E03-FC2D-4385-B87A-51A8DD92FE01} + SLH.SSDMS.Model + + + {BD42A6EC-6A27-4E28-938F-9E7906D049E0} + SLH.SSDMS.RestSharp + + + {634C0CFF-E2D5-462C-9395-1540BA1282FD} + SLH.SSDMS.WebSocket + + + + \ No newline at end of file diff --git a/SLH.SSDMS.Services/app.config b/SLH.SSDMS.Services/app.config new file mode 100644 index 0000000..a0cefc2 --- /dev/null +++ b/SLH.SSDMS.Services/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/SLH.SSDMS.Services/packages.config b/SLH.SSDMS.Services/packages.config new file mode 100644 index 0000000..e095aef --- /dev/null +++ b/SLH.SSDMS.Services/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/SLH.SSDMS.Services/serviceImpl/BaseServices.cs b/SLH.SSDMS.Services/serviceImpl/BaseServices.cs new file mode 100644 index 0000000..3a67be4 --- /dev/null +++ b/SLH.SSDMS.Services/serviceImpl/BaseServices.cs @@ -0,0 +1,757 @@ +using SLH.SSDMS.Common; +using SLH.SSDMS.Model.DTO; +using SqlSugar; +using SqlSugar.Extensions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Services.serviceImpl +{ + public class BaseServices : IBaseServices where TEntity : class, new() + { + private SqlSugarClient _dbBase; + + private SqlSugarClient _db + { + get + { + try + { + _dbBase = new SqlSugarClient(new ConnectionConfig() + { + ConnectionString = "Server=" + ConfigHelper.GetConfig("DataBaseServer") + ";Database=" + + ConfigHelper.GetConfig("DataBaseName") + ";User ID=" + ConfigHelper.GetConfig("DataBaseUser") + + ";Password=" + ConfigHelper.GetConfig("DataBasePassword"), + DbType = DbType.SqlServer, + IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样我就不多解释了 + //InitKey默认SystemTable + }); + + //可注释 + _dbBase.Aop.OnLogExecuting = (sql, pars) => //SQL执行中事件 + { + Parallel.For(0, 1, e => + { + string SqlLog = ""; + foreach (string item in new string[] { GetParas(pars), "【SQL语句】:" + sql }) + { + SqlLog = SqlLog + item; + } + LogHelper.Info("SqlLog:" + SqlLog); + }); + }; + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + return null; + } + return _dbBase; + } + } + + private string GetParas(SugarParameter[] pars) + { + string key = "【SQL参数】:"; + foreach (var param in pars) + { + key += $"{param.ParameterName}:{param.Value}\n"; + } + + return key; + } + + internal SqlSugarClient Db + { + get { return _db; } + } + + public async Task QuerySingle(Expression> whereExpression) + { + try + { + return await _db.Queryable().WhereIF(whereExpression != null, whereExpression).SingleAsync(); + } + catch (Exception ex) + { + return null; + } + + } + + public async Task QueryById(object objId) + { + return await _db.Queryable().In(objId).SingleAsync(); + } + /// + /// 功能描述:根据ID查询一条数据 + /// + /// + /// id(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件 + /// 是否使用缓存 + /// 数据实体 + public async Task QueryById(object objId, bool blnUseCache = false) + { + return await _db.Queryable().WithCacheIF(blnUseCache).In(objId).SingleAsync(); + } + + /// + /// 功能描述:根据ID查询数据 + /// + /// + /// id列表(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件 + /// 数据实体列表 + public async Task> QueryByIDs(object[] lstIds) + { + return await _db.Queryable().In(lstIds).ToListAsync(); + } + + /// + /// 写入实体数据 + /// + /// 博文实体类 + /// + public async Task Add(TEntity entity) + { + try + { + var insert = _db.Insertable(entity); + var info = await insert.ExecuteReturnIdentityAsync(); + return info; + } + catch (Exception ex) + { + return 0; + } + } + + public async Task AddLog(TEntity entity) + { + try + { + var insert = _db.Insertable(entity); + return await insert.ExecuteReturnIdentityAsync(); + } + catch (Exception ex) + { + LogHelper.Error("插入出錯:" + ex.Message); + return 0; + } + } + + /// + /// 批量插入实体(速度快) + /// + /// 实体集合 + /// 影响行数 + public async Task Add(List listEntity) + { + return await _db.Insertable(listEntity.ToArray()).ExecuteCommandAsync(); + } + + /// + /// 更新实体数据 + /// + /// 博文实体类 + /// + public async Task Update(TEntity entity) + { + ////这种方式会以主键为条件 + //var i = await Task.Run(() => _db.Updateable(entity).ExecuteCommand()); + //return i > 0; + //这种方式会以主键为条件 + return await _db.Updateable(entity).ExecuteCommandHasChangeAsync(); + } + + public async Task Update(TEntity entity, string strWhere) + { + //return await Task.Run(() => _db.Updateable(entity).Where(strWhere).ExecuteCommand() > 0); + return await _db.Updateable(entity).Where(strWhere).ExecuteCommandHasChangeAsync(); + } + + public async Task Update(string strSql, SugarParameter[] parameters = null) + { + //return await Task.Run(() => _db.Ado.ExecuteCommand(strSql, parameters) > 0); + return await _db.Ado.ExecuteCommandAsync(strSql, parameters) > 0; + } + + public async Task Update(object operateAnonymousObjects) + { + return await _db.Updateable(operateAnonymousObjects).ExecuteCommandAsync() > 0; + } + + public async Task Update( + TEntity entity, + List lstColumns = null, + List lstIgnoreColumns = null, + string strWhere = "" + ) + { + IUpdateable up = _db.Updateable(entity); + if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) + { + up = up.IgnoreColumns(lstIgnoreColumns.ToArray()); + } + if (lstColumns != null && lstColumns.Count > 0) + { + up = up.UpdateColumns(lstColumns.ToArray()); + } + if (!string.IsNullOrEmpty(strWhere)) + { + up = up.Where(strWhere); + } + return await up.ExecuteCommandHasChangeAsync(); + } + + /// + /// 根据实体删除一条数据 + /// + /// 实体类 + /// + public async Task Delete(TEntity entity) + { + //var i = await Task.Run(() => _db.Deleteable(entity).ExecuteCommand()); + //return i > 0; + return await _db.Deleteable(entity).ExecuteCommandHasChangeAsync(); + } + + /// + /// 根据表达式删除 + /// + /// + /// + public async Task Delete(Expression> whereExpression) + { + return await _db.Deleteable().Where(whereExpression).ExecuteCommandHasChangeAsync(); + } + + /// + /// 删除指定ID的数据 + /// + /// 主键ID + /// + public async Task DeleteById(object id) + { + //var i = await Task.Run(() => _db.Deleteable(id).ExecuteCommand()); + //return i > 0; + return await _db.Deleteable(id).ExecuteCommandHasChangeAsync(); + } + + /// + /// 删除指定ID集合的数据(批量删除) + /// + /// 主键ID集合 + /// + public async Task DeleteByIds(object[] ids) + { + //var i = await Task.Run(() => _db.Deleteable().In(ids).ExecuteCommand()); + //return i > 0; + return await _db.Deleteable().In(ids).ExecuteCommandHasChangeAsync(); + } + + + + /// + /// 功能描述:查询所有数据 + /// + /// + /// 数据列表 + public async Task> Query() + { + return await _db.Queryable().ToListAsync(); + } + + /// + /// 功能描述:查询数据列表 + /// + /// + /// 条件 + /// 数据列表 + public async Task> Query(string strWhere) + { + //return await Task.Run(() => _db.Queryable().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList()); + return await _db.Queryable().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToListAsync(); + } + + /// + /// 功能描述:查询数据列表 + /// + /// + /// whereExpression + /// 数据列表 + public async Task> Query(Expression> whereExpression) + { + try + { + return await _db.Queryable().WhereIF(whereExpression != null, whereExpression).ToListAsync(); + } + catch (Exception ex) + { + return null; + } + } + + /// + /// 功能描述:查询一个列表 + /// + /// + /// 条件表达式 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query(Expression> whereExpression, string strOrderByFileds) + { + //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToList()); + return await _db.Queryable().WhereIF(whereExpression != null, whereExpression).OrderByIF(strOrderByFileds != null, strOrderByFileds).ToListAsync(); + } + /// + /// 功能描述:查询一个列表 + /// + /// + /// + /// + /// + public async Task> Query(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true) + { + //return await Task.Run(() => _db.Queryable().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToList()); + try + { + return await _db.Queryable().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToListAsync(); + } + catch (Exception ex) + { + LogHelper.Error(ex.Message); + return null; + } + } + + /// + /// 排序取第一条 + /// + /// + /// + /// + /// + public async Task QueryFirst(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true) + { + try + { + TEntity info = await _db.Queryable().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).FirstAsync(); + return info; + } + catch (Exception ex) + { + return null; + } + } + + /// + /// 功能描述:查询一个列表 + /// + /// + /// 条件 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query(string strWhere, string strOrderByFileds) + { + //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList()); + return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToListAsync(); + } + + + /// + /// 功能描述:查询前N条数据 + /// + /// + /// 条件表达式 + /// 前N条 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query( + Expression> whereExpression, + int intTop, + string strOrderByFileds) + { + //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToList()); + return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToListAsync(); + } + + /// + /// 功能描述:查询前N条数据 + /// + /// + /// 条件 + /// 前N条 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query( + string strWhere, + int intTop, + string strOrderByFileds) + { + //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToList()); + return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToListAsync(); + } + + + + /// + /// 功能描述:分页查询 + /// + /// + /// 条件表达式 + /// 页码(下标0) + /// 页大小 + /// 数据总量 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query( + Expression> whereExpression, + int intPageIndex, + int intPageSize, + string strOrderByFileds) + { + //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageList(intPageIndex, intPageSize)); + return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageListAsync(intPageIndex, intPageSize); + } + + /// + /// 功能描述:分页查询 + /// + /// + /// 条件 + /// 页码(下标0) + /// 页大小 + /// 数据总量 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query( + string strWhere, + int intPageIndex, + int intPageSize, + + string strOrderByFileds) + { + //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageList(intPageIndex, intPageSize)); + return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageListAsync(intPageIndex, intPageSize); + } + + + + /// + /// 分页查询[使用版本,其他分页未测试] + /// + /// 条件表达式 + /// 页码(下标0) + /// 页大小 + /// 排序字段,如name asc,age desc + /// + public async Task> QueryPage(Expression> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) + { + + RefAsync totalCount = 0; + var list = await _db.Queryable() + .OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds) + .WhereIF(whereExpression != null, whereExpression) + .ToPageListAsync(intPageIndex, intPageSize, totalCount); + + int pageCount = (Math.Ceiling(totalCount.ObjToDecimal2() / intPageSize.ObjToDecimal2())).ObjToInt(); + return new PageModel() { dataCount = totalCount, pageCount = pageCount, page = intPageIndex, PageSize = intPageSize, data = list }; + } + + + /// + ///查询-多表查询 + /// + /// 实体1 + /// 实体2 + /// 实体3 + /// 实体4 + /// 实体5 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + public async Task> QueryMuch( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null) where T : class, new() + { + if (whereLambda == null) + { + return await _db.Queryable(joinExpression).Select(selectExpression).ToListAsync(); + } + return await _db.Queryable(joinExpression).Select(selectExpression).MergeTable().Where(whereLambda).ToListAsync(); + } + + + /// + ///查询-多表查询 + /// + /// 实体1 + /// 实体2 + /// 实体3 + /// 实体4 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + public async Task> QueryMuch( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null) where T : class, new() + { + if (whereLambda == null) + { + return await _db.Queryable(joinExpression).Select(selectExpression).ToListAsync(); + } + return await _db.Queryable(joinExpression).Select(selectExpression).MergeTable().Where(whereLambda).ToListAsync(); + } + + + /// + ///查询-多表查询 + /// + /// 实体1 + /// 实体2 + /// 实体3 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + public async Task> QueryMuch( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null) where T : class, new() + { + if (whereLambda == null) + { + return await _db.Queryable(joinExpression).Select(selectExpression).ToListAsync(); + } + return await _db.Queryable(joinExpression).Select(selectExpression).MergeTable().Where(whereLambda).ToListAsync(); + } + + /// + ///查询-多表查询 + /// + /// 实体1 + /// 实体2 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + public async Task> QueryMuch( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null) where T : class, new() + { + if (whereLambda == null) + { + return await _db.Queryable(joinExpression).Select(selectExpression).ToListAsync(); + } + return await _db.Queryable(joinExpression).Select(selectExpression).MergeTable().Where(whereLambda).ToListAsync(); + } + + #region 多表分页 + /// + ///查询-多表查询 + /// + /// 实体1 + /// 实体2 + /// 实体3 + /// 实体4 + /// 实体5 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + public async Task> QueryMuchPage( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new() + { + RefAsync totalCount = 0; + var list = await _db.Queryable(joinExpression) + .Select(selectExpression) + .MergeTable() + .WhereIF(whereLambda != null, whereLambda) + .OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds) + .ToPageListAsync(intPageIndex, intPageSize, totalCount); + int pageCount = (Math.Ceiling(totalCount.ObjToDecimal2() / intPageSize.ObjToDecimal2())).ObjToInt(); + return new PageModel() { dataCount = totalCount, pageCount = pageCount, page = intPageIndex, PageSize = intPageSize, data = list }; + } + + + /// + ///查询-多表查询 + /// + /// 实体1 + /// 实体2 + /// 实体3 + /// 实体4 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + public async Task> QueryMuchPage( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new() + { + RefAsync totalCount = 0; + var list = await _db.Queryable(joinExpression) + .Select(selectExpression) + .MergeTable() + .WhereIF(whereLambda != null, whereLambda) + .OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds) + .ToPageListAsync(intPageIndex, intPageSize, totalCount); + int pageCount = (Math.Ceiling(totalCount.ObjToDecimal2() / intPageSize.ObjToDecimal2())).ObjToInt(); + return new PageModel() { dataCount = totalCount, pageCount = pageCount, page = intPageIndex, PageSize = intPageSize, data = list }; + } + + + /// + ///查询-多表查询 + /// + /// 实体1 + /// 实体2 + /// 实体3 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + public async Task> QueryMuchPage( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new() + { + RefAsync totalCount = 0; + var list = await _db.Queryable(joinExpression) + .Select(selectExpression) + .MergeTable() + .WhereIF(whereLambda != null, whereLambda) + .OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds) + .ToPageListAsync(intPageIndex, intPageSize, totalCount); + int pageCount = (Math.Ceiling(totalCount.ObjToDecimal2() / intPageSize.ObjToDecimal2())).ObjToInt(); + return new PageModel() { dataCount = totalCount, pageCount = pageCount, page = intPageIndex, PageSize = intPageSize, data = list }; + } + + /// + ///查询-多表查询 + /// + /// 实体1 + /// 实体2 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + public async Task> QueryMuchPage( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new() + { + RefAsync totalCount = 0; + var list = await _db.Queryable(joinExpression) + .Select(selectExpression) + .MergeTable() + .WhereIF(whereLambda != null, whereLambda) + .OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds) + .ToPageListAsync(intPageIndex, intPageSize, totalCount); + int pageCount = (Math.Ceiling(totalCount.ObjToDecimal2() / intPageSize.ObjToDecimal2())).ObjToInt(); + return new PageModel() { dataCount = totalCount, pageCount = pageCount, page = intPageIndex, PageSize = intPageSize, data = list }; + } + + /// + ///查询-多表查询(测试) + /// + /// 实体1 + /// 实体2 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + public async Task> QueryMuchPage( + Expression> joinExpression, + Expression> selectExpression, + Expression> sortExpression, + Expression> whereLambda = null, + int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new() + { + RefAsync totalCount = 0; + var list = await _db.Queryable(joinExpression) + .WhereIF(whereLambda != null, whereLambda) + .Select(selectExpression) + .OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds) + .ToPageListAsync(intPageIndex, intPageSize, totalCount); + int pageCount = (Math.Ceiling(totalCount.ObjToDecimal2() / intPageSize.ObjToDecimal2())).ObjToInt(); + return new PageModel() { dataCount = totalCount, pageCount = pageCount, page = intPageIndex, PageSize = intPageSize, data = list }; + } + + + #endregion + + /// + /// 存储过程 + /// + /// + /// + /// + public async Task> QueryByProc(string proc, List parameters) where T : class, new() + { + //var nameP = new SugarParameter("@name", "张三"); + //var ageP = new SugarParameter("@age", null, true);//isOutput=true + //var ddd = new List(); + return await _db.Ado.UseStoredProcedure().SqlQueryAsync(proc, parameters); + } + + public async Task, List>> QueryByProc(string proc, List parameters) where T : class, new() + { + return await _db.Ado.UseStoredProcedure().SqlQueryAsync(proc, parameters); + } + + /// + /// sql语句 + /// + public async Task> QueryBySql(string sql, List parameters) where T : class, new() + { + return await _db.Ado.SqlQueryAsync(sql, parameters); + } + + #region 自定义 + /// + /// 添加上机记录,先判断是否存在该卷信息 + /// + /// + /// + /// + public async Task BoardAdd(TEntity boardEntity, Expression> whereExpression) + { + try + { + TEntity entity = await _db.Queryable().WhereIF(whereExpression != null, whereExpression).SingleAsync(); + if (entity != null) + { + return new int(); + } + return await Add(boardEntity); + } + catch (Exception ex) + { + return new int(); + } + } + #endregion + } +} diff --git a/SLH.SSDMS.Services/serviceImpl/BufferParse.cs b/SLH.SSDMS.Services/serviceImpl/BufferParse.cs new file mode 100644 index 0000000..b1226ef --- /dev/null +++ b/SLH.SSDMS.Services/serviceImpl/BufferParse.cs @@ -0,0 +1,272 @@ +using AutoMapper; +using SLH.SSDMS.Common; +using SLH.SSDMS.Model.DO; +using SLH.SSDMS.Model.DTO; +using SLH.SSDMS.RestSharp; +using SLH.SSDMS.WebSocket; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Services.serviceImpl +{ + public class BufferParse : IBufferParse + { + private static IReturnBuffer returnBuffer = new ReturnBuffer(); + + private static IRfidJudge rfidJudge = new RfidJudge(); + + private static IBaseServices baseServices = new BaseServices(); + + private static IBaseServices configServices = new BaseServices(); + + /// + /// 心跳解析 + /// + /// + /// + public async Task HeartAnalysis(byte[] buffer) + { + try + { + WebSocketServer.sendMessage("01"); + return returnBuffer.HeartAnalysisResult(1, buffer[3]); + }catch(Exception ex) + { + LogHelper.Error("心跳解析异常", ex); + return returnBuffer.HeartAnalysisResult(0, buffer[3]); + } + } + + /// + /// 指令解析 + /// + /// + /// + public async Task ReadAnalysis(byte[] buffer) + { + try + { + Mapper.Initialize(cret => cret.CreateMap()); + Base_ReadRecord readRecord = new Base_ReadRecord(); + + //RFID标签号 + string RFIDCode = ""; + + //终端地址 + readRecord.terminal = Convert.ToString(buffer[3], 16); + //生产年 + readRecord.proYear = Convert.ToString(buffer[4], 16) + Convert.ToString(buffer[5], 16); + //生产月 + readRecord.proMonth = Convert.ToString(buffer[6]); + //生产机台 + readRecord.proMachine = Convert.ToString(buffer[7], 16) + Convert.ToString(buffer[8], 16); + //带强 + readRecord.beltStrength = Convert.ToString(buffer[9], 16) + Convert.ToString(buffer[10], 16); + switch (readRecord.beltStrength) + { + case "05": + readRecord.beltStrength = "ST1400"; + break; + case "06": + readRecord.beltStrength = "ST1600"; + break; + case "07": + readRecord.beltStrength = "ST1800"; + break; + case "08": + readRecord.beltStrength = "ST2000"; + break; + case "09": + readRecord.beltStrength = "ST2250"; + break; + default: + readRecord.beltStrength = "ST1800"; + break; + } + //带宽 + readRecord.beltWidth = Convert.ToString(buffer[11], 16); + switch (readRecord.beltWidth) + { + case "5": + readRecord.beltWidth = "1200mm"; + break; + case "6": + readRecord.beltWidth = "1400mm"; + break; + case "7": + readRecord.beltWidth = "1600mm"; + break; + case "8": + readRecord.beltWidth = "1800mm"; + break; + case "9": + readRecord.beltWidth = "2000mm"; + break; + default: + readRecord.beltWidth = "1600mm"; + break; + } + //上胶厚度 + readRecord.upGlueThick = Convert.ToString(buffer[12], 16) + Convert.ToString(buffer[13], 16); + switch (readRecord.upGlueThick) + { + case "10": + readRecord.upGlueThick = "6mm"; + break; + case "11": + readRecord.upGlueThick = "6.5mm"; + break; + case "12": + readRecord.upGlueThick = "7mm"; + break; + case "13": + readRecord.upGlueThick = "7.5mm"; + break; + case "14": + readRecord.upGlueThick = "8mm"; + break; + default: + readRecord.upGlueThick = "7mm"; + break; + } + //连接符 ==>转为ASCII + readRecord.unionSymbol = ((char)Convert.ToInt16(Convert.ToString(buffer[14], 16) + Convert.ToString(buffer[15], 16))).ToString(); + //下胶厚度 + readRecord.downGlueThick = Convert.ToString(buffer[16], 16) + Convert.ToString(buffer[17], 16); + switch (readRecord.downGlueThick) + { + case "08": + readRecord.downGlueThick = "5mm"; + break; + case "09": + readRecord.downGlueThick = "5.5mm"; + break; + case "10": + readRecord.downGlueThick = "6mm"; + break; + case "11": + readRecord.downGlueThick = "6.5mm"; + break; + case "12": + readRecord.downGlueThick = "7mm"; + break; + default: + readRecord.downGlueThick = "6mm"; + break; + } + //盖胶级别 + readRecord.coverGlueLevel = Convert.ToString(buffer[18], 16) + Convert.ToString(buffer[19], 16); + switch (readRecord.coverGlueLevel) + { + case "01": + readRecord.coverGlueLevel = "L"; + break; + case "02": + readRecord.coverGlueLevel = "D"; + break; + case "03": + readRecord.coverGlueLevel = "H"; + break; + case "04": + readRecord.coverGlueLevel = "T1"; + break; + case "05": + readRecord.coverGlueLevel = "T2"; + break; + default: + readRecord.coverGlueLevel = "T3"; + break; + } + //卷号 + readRecord.lotNum = Convert.ToString(buffer[20], 16) + Convert.ToString(buffer[21], 16); + + //RFID卡序号 + readRecord.rfidOrder = Convert.ToString(buffer[22], 16) + Convert.ToString(buffer[23], 16); + //当前RFID前间距 + readRecord.preDistance = (Convert.ToString(buffer[24], 16) + Convert.ToString(buffer[25], 16)).ToInt(); + //当前RFID后间距 + readRecord.aftDistance = (Convert.ToString(buffer[26], 16) + Convert.ToString(buffer[27], 16)).ToInt(); + //读取时间 + readRecord.readTime = DateTime.Now; + + //时间戳 + byte[] timeByte = new byte[8]; + Array.Copy(buffer, 28, timeByte, 0, 8); + foreach (var item in timeByte) + { + readRecord.timeNumber = readRecord.timeNumber + item; + } + + //RFID标签 + byte[] rfidByte = new byte[24]; + Array.Copy(buffer, 4, rfidByte, 0, 24); + foreach (var item in rfidByte) + { + RFIDCode = RFIDCode + item; + } + readRecord.rfidCode = RFIDCode; + + //判断运行顺序 + + readRecord.orderFlag = await rfidJudge.JudgeDirection(RFIDCode); + + LogHelper.Info("标签数据解析完成:" + JsonChange.ModeToJson(readRecord)); + + LogHelper.Info("运行方向:" + readRecord.orderFlag); + + if (readRecord.orderFlag < 2) + { + await baseServices.Add(readRecord); + + try + { + ViewModelDTO viewModelDTO = Mapper.Map(readRecord); + viewModelDTO.runTime = await rfidJudge.JudgeRunTime(readRecord); + viewModelDTO.speed = await rfidJudge.JudgeRunSpeed(readRecord); + viewModelDTO.distance = await rfidJudge.JudgeRunDistance(readRecord); + string firstTime = await rfidJudge.JudgeFirstTime(readRecord.lotNum); + viewModelDTO.firstTime = firstTime.Substring(0, 10); + viewModelDTO.beltSum = 11; + + //获取BC9F流量 + Sys_Config sys_Config = await GetBC9FWorkFlow(); + if(sys_Config != null) + { + viewModelDTO.carryFlow = Convert.ToDecimal(sys_Config.config_value); + viewModelDTO.titalWorkLoad = Convert.ToDecimal(sys_Config.remark); + } + + //websocket上传数据 + WebSocketServer.sendMessage("01"); + WebSocketServer.sendMessage(JsonChange.ModeToJson(viewModelDTO)); + //上传无人巡检系统 + Upload.sendMessage(viewModelDTO); + } + catch(Exception ex) + { + LogHelper.Info("数据上传异常:" + ex); + } + } + } + catch(Exception ex) + { + LogHelper.Error("指令解析异常", ex); + } + return returnBuffer.ReadAnalysisResult(1, buffer[3]); + } + + /// + /// 获取BC9F作业流量 + /// + private async Task GetBC9FWorkFlow() + { + Sys_Config sys_Config = await configServices.QueryById(4); + LogHelper.Info($"获取BC9F数据:{JsonChange.ModeToJson(sys_Config)}"); + + return sys_Config; + } + } +} diff --git a/SLH.SSDMS.Services/serviceImpl/ReturnBuffer.cs b/SLH.SSDMS.Services/serviceImpl/ReturnBuffer.cs new file mode 100644 index 0000000..f8ff927 --- /dev/null +++ b/SLH.SSDMS.Services/serviceImpl/ReturnBuffer.cs @@ -0,0 +1,85 @@ +using SLH.SSDMS.Common; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Services.serviceImpl +{ + public class ReturnBuffer : IReturnBuffer + { + + public byte[] HeartAnalysisResult(int status, byte terminal) + { + byte[] buffer = new byte[10]; + buffer[0] = 0xA5; + buffer[1] = 0x5A; + buffer[2] = 0x00; + buffer[3] = 0x04; + buffer[4] = 0x62; + buffer[5] = terminal; + buffer[6] = Convert.ToByte(status); //状态 + + //取数据长度 + byte[] dataLength = new byte[2]; + dataLength[0] = buffer[2]; + dataLength[1] = buffer[3]; + int dataLen = StringChange.bytesToHexStr(dataLength, dataLength.Length).ToInt() + 1; + + //取长度、类型、数据计算校验 + byte[] calByte = new byte[dataLen]; + Array.Copy(buffer, 2, calByte, 0, dataLen); + buffer[7] = Convert.ToByte(checkUtil.BCC(calByte));//校验 + buffer[8] = 0x0D; + buffer[9] = 0x0A; + return buffer; + } + + public byte[] ReadAnalysisResult(int status, byte terminal) + { + byte[] buffer = new byte[10]; + buffer[0] = 0xA5; + buffer[1] = 0x5A; + buffer[2] = 0x00; + buffer[3] = 0x04; + buffer[4] = 0x84; + buffer[5] = terminal; + buffer[6] = Convert.ToByte(status); //状态 + + //取数据长度 + byte[] dataLength = new byte[2]; + dataLength[0] = buffer[2]; + dataLength[1] = buffer[3]; + int dataLen = StringChange.bytesToHexStr(dataLength, dataLength.Length).ToInt() + 1; + + //取长度、类型、数据计算校验 + byte[] calByte = new byte[dataLen]; + Array.Copy(buffer, 2, calByte, 0, dataLen); + buffer[7] = Convert.ToByte(checkUtil.BCC(calByte));//校验 + buffer[8] = 0x0D; + buffer[9] = 0x0A; + return buffer; + } + + public byte[] HaltBuffer() + { + byte[] buffer = new byte[14]; + buffer[0] = 0xA5; + buffer[1] = 0x5A; + buffer[2] = 0x00; + buffer[3] = 0x08; + buffer[4] = 0xA4; + buffer[5] = 0xFF; + buffer[6] = 0x01; + buffer[7] = 0x01; + buffer[8] = 0x00; + buffer[9] = 0x00; + buffer[10] = 0x00; + buffer[11] = 0x53; + buffer[12] = 0x0D; + buffer[13] = 0x0A; + return buffer; + } + } +} diff --git a/SLH.SSDMS.Services/serviceImpl/RfidJudge.cs b/SLH.SSDMS.Services/serviceImpl/RfidJudge.cs new file mode 100644 index 0000000..655034f --- /dev/null +++ b/SLH.SSDMS.Services/serviceImpl/RfidJudge.cs @@ -0,0 +1,182 @@ +using SLH.SSDMS.Common; +using SLH.SSDMS.Model.DO; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.Services.serviceImpl +{ + public class RfidJudge : IRfidJudge + { + private static string lastRfidCode = ""; + + private static Base_ReadRecord lastReadRecord = new Base_ReadRecord(); + + private static IBaseServices baseServices = new BaseServices(); + + private static IBaseServices runInfoServices = new BaseServices(); + + private static IBaseServices readRecordServices = new BaseServices(); + + private static IBaseServices beltInfoServices = new BaseServices(); + + public async Task JudgeDirection(string rfidCode) + { + Expression> exp = s1 => true; + exp = exp.And(x => x.updateFlag == 0); + Expression> order = (x) => x.rfidCode; + List rfidInfos = await baseServices.Query(exp, order,true); + + List rfidList = new List(); + rfidInfos.ForEach(x => rfidList.Add(x.rfidCode)); + + if (StringExtension.IsNotBlank(lastRfidCode)) + { + int presentIndex = rfidList.IndexOf(rfidCode); + int lastIndex = rfidList.IndexOf(lastRfidCode); + + if (lastIndex == 0 && presentIndex > lastIndex && presentIndex == 1) + { + lastRfidCode = rfidCode; + return 1; + } + + if (lastIndex == 0 && presentIndex > lastIndex && presentIndex == rfidList.Count - 1) + { + lastRfidCode = rfidCode; + return 0; + } + + if (lastIndex > 0 && presentIndex > 0 && lastIndex < presentIndex) + { + lastRfidCode = rfidCode; + return 1; + } + + if (lastIndex > 0 && presentIndex > 0 && lastIndex > presentIndex) + { + lastRfidCode = rfidCode; + return 0; + } + + if (presentIndex == 0 && lastIndex > presentIndex && lastIndex == rfidList.Count - 1) + { + lastRfidCode = rfidCode; + return 1; + } + + if (presentIndex == 0 && lastIndex > presentIndex && lastIndex == 1) + { + lastRfidCode = rfidCode; + return 0; + } + } + lastRfidCode = rfidCode; + return 3; + } + + public async Task JudgeRunSpeed(Base_ReadRecord readRecord) + { + //计算时间差 + try + { + TimeSpan readTime = new TimeSpan(readRecord.readTime.Ticks); + if (lastReadRecord == null) + { + Console.WriteLine("lastReadRecord为空"); + return new decimal(); + } + TimeSpan lastTime = new TimeSpan(lastReadRecord.readTime.Ticks); + decimal interval = (decimal)readTime.Subtract(lastTime).Duration().TotalSeconds; + Console.WriteLine("时差:" + interval); + + //计算速度m/s + decimal result = readRecord.preDistance / interval; + var speed = Math.Round(result, 3); + lastReadRecord = readRecord; + return speed; + } + catch(Exception ex) + { + LogHelper.Error("速度计算异常", ex); + return 0; + } + } + + public async Task JudgeRunDistance(Base_ReadRecord readRecord) + { + try + { + //查询已经生成好的里程数据 + Expression> exp = s1 => true; + exp = exp.And(x => x.lotNum == readRecord.lotNum); + List runInfos = await runInfoServices.Query(exp); + + var distance = runInfos.Sum(x=>x.runDistance); + + //查询当天的里程数据 + Expression> readExp = s1 => true; + readExp = readExp.And(x => x.readTime.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")); + List readRecords = await readRecordServices.Query(readExp); + + var info = readRecords.Sum(x => x.preDistance); + + return Math.Round((info + distance) / 1000,3); + } + catch (Exception ex) + { + LogHelper.Error("里程计算异常", ex); + return 0; + } + } + + public async Task JudgeRunTime(Base_ReadRecord readRecord) + { + try + { + //查询已经生成好的里程数据 + Expression> exp = s1 => true; + exp = exp.And(x => x.lotNum == readRecord.lotNum); + List runInfos = await runInfoServices.Query(exp); + + var runTime = runInfos.Sum(x=>x.runTime); + + //查询当天的里程数据 + Expression> readExp = s1 => true; + readExp = readExp.And(x => x.readTime.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")); + List readRecords = await readRecordServices.Query(readExp); + + Base_ReadRecord todayReadRecord = readRecords.OrderBy(x => x.readTime).First(); + + TimeSpan readTime = new TimeSpan(DateTime.Now.Ticks); + TimeSpan lastTime = new TimeSpan(todayReadRecord.readTime.Ticks); + decimal interval = (decimal)readTime.Subtract(lastTime).Duration().TotalSeconds; + + return Math.Round((interval + runTime) / 60 / 60,2); + } + catch (Exception ex) + { + LogHelper.Error("时长计算异常", ex); + return 0; + } + } + + public async Task JudgeFirstTime(string lotCode) + { + try + { + Expression> exp = s1 => true; + exp = exp.And(x => x.lotNum == lotCode); + var info = await beltInfoServices.Query(exp); + return info.FirstOrDefault().firstTime; + }catch(Exception ex) + { + LogHelper.Error("首次上机时间查询异常"+ lotCode, ex); + return DateTime.Now.ToString("yyyy-MM-dd"); + } + } + } +} diff --git a/SLH.SSDMS.Test/App.config b/SLH.SSDMS.Test/App.config new file mode 100644 index 0000000..d0253d5 --- /dev/null +++ b/SLH.SSDMS.Test/App.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SLH.SSDMS.Test/Properties/AssemblyInfo.cs b/SLH.SSDMS.Test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2de2416 --- /dev/null +++ b/SLH.SSDMS.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("SLH.SSDMS.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SLH.SSDMS.Test")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("883fe05c-20ac-4edb-8720-6e33efa693c7")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SLH.SSDMS.Test/SLH.SSDMS.Test.csproj b/SLH.SSDMS.Test/SLH.SSDMS.Test.csproj new file mode 100644 index 0000000..e22c839 --- /dev/null +++ b/SLH.SSDMS.Test/SLH.SSDMS.Test.csproj @@ -0,0 +1,83 @@ + + + + + + Debug + AnyCPU + {883FE05C-20AC-4EDB-8720-6E33EFA693C7} + Library + Properties + SLH.SSDMS.Test + SLH.SSDMS.Test + v4.5.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + + {9DB66868-C6F0-4522-A551-09452B927C52} + SLH.SSDMS.Common + + + {1C8B2E03-FC2D-4385-B87A-51A8DD92FE01} + SLH.SSDMS.Model + + + {3EFE1A92-DF3D-4B98-8A6B-DDA264385E52} + SLH.SSDMS.Services + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + + \ No newline at end of file diff --git a/SLH.SSDMS.Test/UnitTest1.cs b/SLH.SSDMS.Test/UnitTest1.cs new file mode 100644 index 0000000..ee1cb7e --- /dev/null +++ b/SLH.SSDMS.Test/UnitTest1.cs @@ -0,0 +1,61 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SLH.SSDMS.Common; +using SLH.SSDMS.Model.DO; +using SLH.SSDMS.Services; +using SLH.SSDMS.Services.serviceImpl; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; + +namespace SLH.SSDMS.Test +{ + [TestClass] + public class UnitTest1 + { + private static IBaseServices baseServices = new BaseServices(); + private static string last; + [TestMethod] + public void TestMethod1() + { + var code = Console.ReadLine(); + test(code); + } + + public string test(string code) + { + List list = new List(); + list.Add("abc"); + list.Add("123"); + list.Add("456"); + list.Add("789"); + if (StringExtension.IsNotBlank(last)) + { + int presentIndex = list.IndexOf(code); + int lastIndex = list.IndexOf(last); + + if (lastIndex > 0 && presentIndex > 0 && lastIndex < presentIndex) + { + return "0"; + } + + if (lastIndex > 0 && presentIndex > 0 && lastIndex > presentIndex) + { + return "1"; + } + + if (presentIndex == 0 && lastIndex > presentIndex) + { + return "0"; + } + + if (presentIndex == 0 && presentIndex > lastIndex) + { + return "1"; + } + } + + return ""; + + } + } +} diff --git a/SLH.SSDMS.Test/packages.config b/SLH.SSDMS.Test/packages.config new file mode 100644 index 0000000..506206f --- /dev/null +++ b/SLH.SSDMS.Test/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/SLH.SSDMS.WebSocket/Properties/AssemblyInfo.cs b/SLH.SSDMS.WebSocket/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..87f40bc --- /dev/null +++ b/SLH.SSDMS.WebSocket/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SLH.SSDMS.WebSocket")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SLH.SSDMS.WebSocket")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("634c0cff-e2d5-462c-9395-1540ba1282fd")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SLH.SSDMS.WebSocket/SLH.SSDMS.WebSocket.csproj b/SLH.SSDMS.WebSocket/SLH.SSDMS.WebSocket.csproj new file mode 100644 index 0000000..2b80b02 --- /dev/null +++ b/SLH.SSDMS.WebSocket/SLH.SSDMS.WebSocket.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {634C0CFF-E2D5-462C-9395-1540BA1282FD} + Library + Properties + SLH.SSDMS.WebSocket + SLH.SSDMS.WebSocket + v4.5.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Fleck.1.2.0\lib\net45\Fleck.dll + + + + + + + + + + + + + + + + + + + + {9DB66868-C6F0-4522-A551-09452B927C52} + SLH.SSDMS.Common + + + + \ No newline at end of file diff --git a/SLH.SSDMS.WebSocket/WebSocketServer.cs b/SLH.SSDMS.WebSocket/WebSocketServer.cs new file mode 100644 index 0000000..18b3953 --- /dev/null +++ b/SLH.SSDMS.WebSocket/WebSocketServer.cs @@ -0,0 +1,57 @@ +using Fleck; +using SLH.SSDMS.Common; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS.WebSocket +{ + public class WebSocketServer + { + private static List allSockets = new List(); + + public static void Init() + { + FleckLog.Level = LogLevel.Debug; + var server = new Fleck.WebSocketServer("ws://0.0.0.0:7181"); + server.Start(socket => + { + socket.OnOpen = () => + { + var data = socket.ConnectionInfo; + Console.WriteLine("Open!"); + allSockets.Add(socket); + }; + + socket.OnClose = () => + { + Console.WriteLine("Close!"); + allSockets.Remove(socket); + }; + + socket.OnMessage = message => + { + Console.WriteLine(message); + socket.Send("Echo:" + message); + }; + }); + } + + public static void sendMessage(string message) + { + try + { + foreach (var socket in allSockets.ToList()) + { + socket.Send(message); + LogHelper.Info("WebSocket接口上传数据:" + message); + } + }catch(Exception ex) + { + LogHelper.Error("WebSocket上传数据异常", ex); + } + } + } +} diff --git a/SLH.SSDMS.WebSocket/packages.config b/SLH.SSDMS.WebSocket/packages.config new file mode 100644 index 0000000..e0f0bfd --- /dev/null +++ b/SLH.SSDMS.WebSocket/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/SLH.SSDMS.sln b/SLH.SSDMS.sln new file mode 100644 index 0000000..47f3e3a --- /dev/null +++ b/SLH.SSDMS.sln @@ -0,0 +1,67 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31205.134 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS", "SLH.SSDMS\SLH.SSDMS.csproj", "{9FB908E1-CD3F-4C24-AEC9-BCE0F1277932}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS.Collect", "SLH.SSDMS.Collect\SLH.SSDMS.Collect.csproj", "{C3937FF9-B218-48E4-A602-C59106B67C7B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS.Common", "SLH.SSDMS.Common\SLH.SSDMS.Common.csproj", "{9DB66868-C6F0-4522-A551-09452B927C52}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS.Model", "SLH.SSDMS.Model\SLH.SSDMS.Model.csproj", "{1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS.Services", "SLH.SSDMS.Services\SLH.SSDMS.Services.csproj", "{3EFE1A92-DF3D-4B98-8A6B-DDA264385E52}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS.Test", "SLH.SSDMS.Test\SLH.SSDMS.Test.csproj", "{883FE05C-20AC-4EDB-8720-6E33EFA693C7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS.WebSocket", "SLH.SSDMS.WebSocket\SLH.SSDMS.WebSocket.csproj", "{634C0CFF-E2D5-462C-9395-1540BA1282FD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS.RestSharp", "SLH.SSDMS.RestSharp\SLH.SSDMS.RestSharp.csproj", "{BD42A6EC-6A27-4E28-938F-9E7906D049E0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9FB908E1-CD3F-4C24-AEC9-BCE0F1277932}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9FB908E1-CD3F-4C24-AEC9-BCE0F1277932}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9FB908E1-CD3F-4C24-AEC9-BCE0F1277932}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9FB908E1-CD3F-4C24-AEC9-BCE0F1277932}.Release|Any CPU.Build.0 = Release|Any CPU + {C3937FF9-B218-48E4-A602-C59106B67C7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3937FF9-B218-48E4-A602-C59106B67C7B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C3937FF9-B218-48E4-A602-C59106B67C7B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C3937FF9-B218-48E4-A602-C59106B67C7B}.Release|Any CPU.Build.0 = Release|Any CPU + {9DB66868-C6F0-4522-A551-09452B927C52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9DB66868-C6F0-4522-A551-09452B927C52}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9DB66868-C6F0-4522-A551-09452B927C52}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9DB66868-C6F0-4522-A551-09452B927C52}.Release|Any CPU.Build.0 = Release|Any CPU + {1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}.Release|Any CPU.Build.0 = Release|Any CPU + {3EFE1A92-DF3D-4B98-8A6B-DDA264385E52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3EFE1A92-DF3D-4B98-8A6B-DDA264385E52}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3EFE1A92-DF3D-4B98-8A6B-DDA264385E52}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3EFE1A92-DF3D-4B98-8A6B-DDA264385E52}.Release|Any CPU.Build.0 = Release|Any CPU + {883FE05C-20AC-4EDB-8720-6E33EFA693C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {883FE05C-20AC-4EDB-8720-6E33EFA693C7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {883FE05C-20AC-4EDB-8720-6E33EFA693C7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {883FE05C-20AC-4EDB-8720-6E33EFA693C7}.Release|Any CPU.Build.0 = Release|Any CPU + {634C0CFF-E2D5-462C-9395-1540BA1282FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {634C0CFF-E2D5-462C-9395-1540BA1282FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {634C0CFF-E2D5-462C-9395-1540BA1282FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {634C0CFF-E2D5-462C-9395-1540BA1282FD}.Release|Any CPU.Build.0 = Release|Any CPU + {BD42A6EC-6A27-4E28-938F-9E7906D049E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD42A6EC-6A27-4E28-938F-9E7906D049E0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BD42A6EC-6A27-4E28-938F-9E7906D049E0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD42A6EC-6A27-4E28-938F-9E7906D049E0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D6670BC7-6C9E-4C2B-B151-53A74EE757E8} + EndGlobalSection +EndGlobal diff --git a/SLH.SSDMS/App.config b/SLH.SSDMS/App.config new file mode 100644 index 0000000..b57c6be --- /dev/null +++ b/SLH.SSDMS/App.config @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SLH.SSDMS/Program.cs b/SLH.SSDMS/Program.cs new file mode 100644 index 0000000..1d0d2f5 --- /dev/null +++ b/SLH.SSDMS/Program.cs @@ -0,0 +1,63 @@ +using SLH.SSDMS.Collect; +using SLH.SSDMS.Common; +using SLH.SSDMS.Model.DO; +using SLH.SSDMS.Model.DTO; +using SLH.SSDMS.RestSharp; +using SLH.SSDMS.Services; +using SLH.SSDMS.Services.serviceImpl; +using SLH.SSDMS.WebSocket; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.ServiceProcess; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS +{ + + static class Program + { + /// + /// 应用程序的主入口点。 + /// + static void Main() + { + try + { + ServiceBase[] ServicesToRun; + ServicesToRun = new ServiceBase[] + { + new Service1() + }; + ServiceBase.Run(ServicesToRun); + } + catch(Exception ex) + { + LogHelper.Error("异常捕获", ex); + } + } + + public static void test() + { + try + { + ViewModelDTO viewModelDTO = new ViewModelDTO(); + viewModelDTO.orderFlag = 0; + viewModelDTO.runTime = 123.3M; + viewModelDTO.speed = 4.2M; + viewModelDTO.distance = 123; + string firstTime = "2021-10-11"; + viewModelDTO.firstTime = firstTime.Substring(0, 10); + viewModelDTO.beltSum = 11; + //上传无人巡检系统 + Upload.sendMessage(viewModelDTO); + }catch(Exception ex) + { + Console.WriteLine("上传异常:" + ex.Message); + } + } + + } +} diff --git a/SLH.SSDMS/ProjectInstaller.Designer.cs b/SLH.SSDMS/ProjectInstaller.Designer.cs new file mode 100644 index 0000000..b625f4b --- /dev/null +++ b/SLH.SSDMS/ProjectInstaller.Designer.cs @@ -0,0 +1,59 @@ + +namespace SLH.SSDMS +{ + partial class ProjectInstaller + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller(); + this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller(); + // + // serviceProcessInstaller1 + // + this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService; + this.serviceProcessInstaller1.Password = null; + this.serviceProcessInstaller1.Username = null; + // + // serviceInstaller1 + // + this.serviceInstaller1.DisplayName = "RFID采集服务"; + this.serviceInstaller1.ServiceName = "Service1"; + // + // ProjectInstaller + // + this.Installers.AddRange(new System.Configuration.Install.Installer[] { + this.serviceProcessInstaller1, + this.serviceInstaller1}); + + } + + #endregion + + private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1; + private System.ServiceProcess.ServiceInstaller serviceInstaller1; + } +} \ No newline at end of file diff --git a/SLH.SSDMS/ProjectInstaller.cs b/SLH.SSDMS/ProjectInstaller.cs new file mode 100644 index 0000000..a8d1fd4 --- /dev/null +++ b/SLH.SSDMS/ProjectInstaller.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Configuration.Install; +using System.Linq; +using System.Threading.Tasks; + +namespace SLH.SSDMS +{ + [RunInstaller(true)] + public partial class ProjectInstaller : System.Configuration.Install.Installer + { + public ProjectInstaller() + { + InitializeComponent(); + } + } +} diff --git a/SLH.SSDMS/ProjectInstaller.resx b/SLH.SSDMS/ProjectInstaller.resx new file mode 100644 index 0000000..65b03a9 --- /dev/null +++ b/SLH.SSDMS/ProjectInstaller.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 351, 17 + + + False + + \ No newline at end of file diff --git a/SLH.SSDMS/Properties/AssemblyInfo.cs b/SLH.SSDMS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..332b742 --- /dev/null +++ b/SLH.SSDMS/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SLH.SSDMS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SLH.SSDMS")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("9fb908e1-cd3f-4c24-aec9-bce0f1277932")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SLH.SSDMS/SLH.SSDMS.csproj b/SLH.SSDMS/SLH.SSDMS.csproj new file mode 100644 index 0000000..8ddf8a7 --- /dev/null +++ b/SLH.SSDMS/SLH.SSDMS.csproj @@ -0,0 +1,102 @@ + + + + + Debug + AnyCPU + {9FB908E1-CD3F-4C24-AEC9-BCE0F1277932} + Exe + SLH.SSDMS + SLH.SSDMS + v4.5.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + Component + + + ProjectInstaller.cs + + + Component + + + Service1.cs + + + + + + + + + + {C3937FF9-B218-48E4-A602-C59106B67C7B} + SLH.SSDMS.Collect + + + {9DB66868-C6F0-4522-A551-09452B927C52} + SLH.SSDMS.Common + + + {1C8B2E03-FC2D-4385-B87A-51A8DD92FE01} + SLH.SSDMS.Model + + + {BD42A6EC-6A27-4E28-938F-9E7906D049E0} + SLH.SSDMS.RestSharp + + + {3EFE1A92-DF3D-4B98-8A6B-DDA264385E52} + SLH.SSDMS.Services + + + {634C0CFF-E2D5-462C-9395-1540BA1282FD} + SLH.SSDMS.WebSocket + + + + + ProjectInstaller.cs + + + + \ No newline at end of file diff --git a/SLH.SSDMS/Service1.Designer.cs b/SLH.SSDMS/Service1.Designer.cs new file mode 100644 index 0000000..a4213d4 --- /dev/null +++ b/SLH.SSDMS/Service1.Designer.cs @@ -0,0 +1,38 @@ + +namespace SLH.SSDMS +{ + partial class Service1 + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.ServiceName = "Service1"; + } + + #endregion + } +} diff --git a/SLH.SSDMS/Service1.cs b/SLH.SSDMS/Service1.cs new file mode 100644 index 0000000..c75ef2b --- /dev/null +++ b/SLH.SSDMS/Service1.cs @@ -0,0 +1,32 @@ +using SLH.SSDMS.Collect; +using SLH.SSDMS.WebSocket; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Linq; +using System.ServiceProcess; +using System.Text; +using System.Threading.Tasks; + +namespace SLH.SSDMS +{ + public partial class Service1 : ServiceBase + { + public Service1() + { + InitializeComponent(); + } + + protected override void OnStart(string[] args) + { + AsyncSocket.init(); + WebSocketServer.Init(); + } + + protected override void OnStop() + { + } + } +}