初版入库

main
潘建东 11 months ago
commit ad68f6b75b

583
.gitignore vendored

@ -0,0 +1,583 @@
## 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
*.mp4
MySQL/Conf/mysql.cnf
MySQL/Data/#ib_16384_0.dblwr
MySQL/Data/#ib_16384_1.dblwr
MySQL/Data/auto.cnf
MySQL/Data/binlog.000013
MySQL/Data/binlog.000014
MySQL/Data/binlog.000015
MySQL/Data/binlog.000016
MySQL/Data/binlog.000017
MySQL/Data/binlog.000018
MySQL/Data/binlog.000019
MySQL/Data/binlog.000020
MySQL/Data/binlog.000021
MySQL/Data/binlog.000022
MySQL/Data/binlog.index
MySQL/Data/ca-key.pem
MySQL/Data/ca.pem
MySQL/Data/client-cert.pem
MySQL/Data/client-key.pem
MySQL/Data/ib_buffer_pool
MySQL/Data/ibdata1
MySQL/Data/ibtmp1
MySQL/Data/mysql-bin.000001
MySQL/Data/mysql-bin.000002
MySQL/Data/mysql-bin.000003
MySQL/Data/mysql-bin.000004
MySQL/Data/mysql-bin.000005
MySQL/Data/mysql-bin.index
MySQL/Data/mysql.ibd
MySQL/Data/mysql.sock
MySQL/Data/private_key.pem
MySQL/Data/public_key.pem
MySQL/Data/server-cert.pem
MySQL/Data/server-key.pem
MySQL/Data/undo_001
MySQL/Data/undo_002
MySQL/Data/#innodb_redo/#ib_redo794
MySQL/Data/#innodb_redo/#ib_redo795_tmp
MySQL/Data/#innodb_redo/#ib_redo796_tmp
MySQL/Data/#innodb_redo/#ib_redo797_tmp
MySQL/Data/#innodb_redo/#ib_redo798_tmp
MySQL/Data/#innodb_redo/#ib_redo799_tmp
MySQL/Data/#innodb_redo/#ib_redo800_tmp
MySQL/Data/#innodb_redo/#ib_redo801_tmp
MySQL/Data/#innodb_redo/#ib_redo802_tmp
MySQL/Data/#innodb_redo/#ib_redo803_tmp
MySQL/Data/#innodb_redo/#ib_redo804_tmp
MySQL/Data/#innodb_redo/#ib_redo805_tmp
MySQL/Data/#innodb_redo/#ib_redo806_tmp
MySQL/Data/#innodb_redo/#ib_redo807_tmp
MySQL/Data/#innodb_redo/#ib_redo808_tmp
MySQL/Data/#innodb_redo/#ib_redo809_tmp
MySQL/Data/#innodb_redo/#ib_redo810_tmp
MySQL/Data/#innodb_redo/#ib_redo811_tmp
MySQL/Data/#innodb_redo/#ib_redo812_tmp
MySQL/Data/#innodb_redo/#ib_redo813_tmp
MySQL/Data/#innodb_redo/#ib_redo814_tmp
MySQL/Data/#innodb_redo/#ib_redo815_tmp
MySQL/Data/#innodb_redo/#ib_redo816_tmp
MySQL/Data/#innodb_redo/#ib_redo817_tmp
MySQL/Data/#innodb_redo/#ib_redo818_tmp
MySQL/Data/#innodb_redo/#ib_redo819_tmp
MySQL/Data/#innodb_redo/#ib_redo820_tmp
MySQL/Data/#innodb_redo/#ib_redo821_tmp
MySQL/Data/#innodb_redo/#ib_redo822_tmp
MySQL/Data/#innodb_redo/#ib_redo823_tmp
MySQL/Data/#innodb_redo/#ib_redo824_tmp
MySQL/Data/#innodb_redo/#ib_redo825_tmp
MySQL/Data/#innodb_temp/temp_1.ibt
MySQL/Data/#innodb_temp/temp_2.ibt
MySQL/Data/#innodb_temp/temp_3.ibt
MySQL/Data/#innodb_temp/temp_4.ibt
MySQL/Data/#innodb_temp/temp_5.ibt
MySQL/Data/#innodb_temp/temp_6.ibt
MySQL/Data/#innodb_temp/temp_7.ibt
MySQL/Data/#innodb_temp/temp_8.ibt
MySQL/Data/#innodb_temp/temp_9.ibt
MySQL/Data/#innodb_temp/temp_10.ibt
MySQL/Data/lsdb/cap_man.ibd
MySQL/Data/lsdb/cap_people.ibd
MySQL/Data/lsdb/cap_woman.ibd
MySQL/Data/lsdb/cap@002epublished.ibd
MySQL/Data/lsdb/cap@002ereceived.ibd
MySQL/Data/lsdb/ls_devicedata.ibd
MySQL/Data/lsdb/ls_tcpdatalog_20230330.ibd
MySQL/Data/lsdb/ls_tcpdatalog_20230331.ibd
MySQL/Data/lsdb/ls_tcpdatalog_20230401.ibd
MySQL/Data/lsdb/ls_tcpdatalog_20230402.ibd
MySQL/Data/lsdb/ls_tcpdatalog_20230403.ibd
MySQL/Data/lsdb/tprz_device.ibd
MySQL/Data/lsdb/zl_install_20230101.ibd
MySQL/Data/lsdb/zl_installstep_20230101.ibd
MySQL/Data/lsdb/zl_maintenance_20230101.ibd
MySQL/Data/lsdb/zl_param.ibd
MySQL/Data/lsdb/zl_product.ibd
MySQL/Data/mysql/general_log_213.sdi
MySQL/Data/mysql/general_log.CSM
MySQL/Data/mysql/general_log.CSV
MySQL/Data/mysql/slow_log_214.sdi
MySQL/Data/mysql/slow_log.CSM
MySQL/Data/mysql/slow_log.CSV
MySQL/Data/performance_schema/accounts_145.sdi
MySQL/Data/performance_schema/binary_log_trans_189.sdi
MySQL/Data/performance_schema/cond_instances_82.sdi
MySQL/Data/performance_schema/data_lock_waits_161.sdi
MySQL/Data/performance_schema/data_locks_160.sdi
MySQL/Data/performance_schema/error_log_83.sdi
MySQL/Data/performance_schema/events_errors_su_139.sdi
MySQL/Data/performance_schema/events_errors_su_140.sdi
MySQL/Data/performance_schema/events_errors_su_141.sdi
MySQL/Data/performance_schema/events_errors_su_142.sdi
MySQL/Data/performance_schema/events_errors_su_143.sdi
MySQL/Data/performance_schema/events_stages_cu_111.sdi
MySQL/Data/performance_schema/events_stages_hi_112.sdi
MySQL/Data/performance_schema/events_stages_hi_113.sdi
MySQL/Data/performance_schema/events_stages_su_114.sdi
MySQL/Data/performance_schema/events_stages_su_115.sdi
MySQL/Data/performance_schema/events_stages_su_116.sdi
MySQL/Data/performance_schema/events_stages_su_117.sdi
MySQL/Data/performance_schema/events_stages_su_118.sdi
MySQL/Data/performance_schema/events_statement_119.sdi
MySQL/Data/performance_schema/events_statement_120.sdi
MySQL/Data/performance_schema/events_statement_121.sdi
MySQL/Data/performance_schema/events_statement_122.sdi
MySQL/Data/performance_schema/events_statement_123.sdi
MySQL/Data/performance_schema/events_statement_124.sdi
MySQL/Data/performance_schema/events_statement_125.sdi
MySQL/Data/performance_schema/events_statement_126.sdi
MySQL/Data/performance_schema/events_statement_127.sdi
MySQL/Data/performance_schema/events_statement_128.sdi
MySQL/Data/performance_schema/events_statement_129.sdi
MySQL/Data/performance_schema/events_statement_130.sdi
MySQL/Data/performance_schema/events_transacti_131.sdi
MySQL/Data/performance_schema/events_transacti_132.sdi
MySQL/Data/performance_schema/events_transacti_133.sdi
MySQL/Data/performance_schema/events_transacti_134.sdi
MySQL/Data/performance_schema/events_transacti_135.sdi
MySQL/Data/performance_schema/events_transacti_136.sdi
MySQL/Data/performance_schema/events_transacti_137.sdi
MySQL/Data/performance_schema/events_transacti_138.sdi
MySQL/Data/performance_schema/events_waits_cur_84.sdi
MySQL/Data/performance_schema/events_waits_his_85.sdi
MySQL/Data/performance_schema/events_waits_his_86.sdi
MySQL/Data/performance_schema/events_waits_sum_87.sdi
MySQL/Data/performance_schema/events_waits_sum_88.sdi
MySQL/Data/performance_schema/events_waits_sum_89.sdi
MySQL/Data/performance_schema/events_waits_sum_90.sdi
MySQL/Data/performance_schema/events_waits_sum_91.sdi
MySQL/Data/performance_schema/events_waits_sum_92.sdi
MySQL/Data/performance_schema/file_instances_93.sdi
MySQL/Data/performance_schema/file_summary_by__94.sdi
MySQL/Data/performance_schema/file_summary_by__95.sdi
MySQL/Data/performance_schema/global_status_181.sdi
MySQL/Data/performance_schema/global_variables_184.sdi
MySQL/Data/performance_schema/host_cache_96.sdi
MySQL/Data/performance_schema/hosts_146.sdi
MySQL/Data/performance_schema/keyring_componen_191.sdi
MySQL/Data/performance_schema/keyring_keys_152.sdi
MySQL/Data/performance_schema/log_status_174.sdi
MySQL/Data/performance_schema/memory_summary_b_154.sdi
MySQL/Data/performance_schema/memory_summary_b_155.sdi
MySQL/Data/performance_schema/memory_summary_b_156.sdi
MySQL/Data/performance_schema/memory_summary_b_157.sdi
MySQL/Data/performance_schema/memory_summary_g_153.sdi
MySQL/Data/performance_schema/metadata_locks_159.sdi
MySQL/Data/performance_schema/mutex_instances_97.sdi
MySQL/Data/performance_schema/objects_summary__98.sdi
MySQL/Data/performance_schema/performance_time_99.sdi
MySQL/Data/performance_schema/persisted_variab_187.sdi
MySQL/Data/performance_schema/prepared_stateme_175.sdi
MySQL/Data/performance_schema/processlist_100.sdi
MySQL/Data/performance_schema/replication_appl_165.sdi
MySQL/Data/performance_schema/replication_appl_166.sdi
MySQL/Data/performance_schema/replication_appl_167.sdi
MySQL/Data/performance_schema/replication_appl_168.sdi
MySQL/Data/performance_schema/replication_appl_170.sdi
MySQL/Data/performance_schema/replication_appl_171.sdi
MySQL/Data/performance_schema/replication_asyn_172.sdi
MySQL/Data/performance_schema/replication_asyn_173.sdi
MySQL/Data/performance_schema/replication_conn_162.sdi
MySQL/Data/performance_schema/replication_conn_164.sdi
MySQL/Data/performance_schema/replication_grou_163.sdi
MySQL/Data/performance_schema/replication_grou_169.sdi
MySQL/Data/performance_schema/rwlock_instances_101.sdi
MySQL/Data/performance_schema/session_account__151.sdi
MySQL/Data/performance_schema/session_connect__150.sdi
MySQL/Data/performance_schema/session_status_182.sdi
MySQL/Data/performance_schema/session_variable_185.sdi
MySQL/Data/performance_schema/setup_actors_102.sdi
MySQL/Data/performance_schema/setup_consumers_103.sdi
MySQL/Data/performance_schema/setup_instrument_104.sdi
MySQL/Data/performance_schema/setup_objects_105.sdi
MySQL/Data/performance_schema/setup_threads_106.sdi
MySQL/Data/performance_schema/socket_instances_147.sdi
MySQL/Data/performance_schema/socket_summary_b_148.sdi
MySQL/Data/performance_schema/socket_summary_b_149.sdi
MySQL/Data/performance_schema/status_by_accoun_177.sdi
MySQL/Data/performance_schema/status_by_host_178.sdi
MySQL/Data/performance_schema/status_by_thread_179.sdi
MySQL/Data/performance_schema/status_by_user_180.sdi
MySQL/Data/performance_schema/table_handles_158.sdi
MySQL/Data/performance_schema/table_io_waits_s_107.sdi
MySQL/Data/performance_schema/table_io_waits_s_108.sdi
MySQL/Data/performance_schema/table_lock_waits_109.sdi
MySQL/Data/performance_schema/threads_110.sdi
MySQL/Data/performance_schema/tls_channel_stat_190.sdi
MySQL/Data/performance_schema/user_defined_fun_188.sdi
MySQL/Data/performance_schema/user_variables_b_176.sdi
MySQL/Data/performance_schema/users_144.sdi
MySQL/Data/performance_schema/variables_by_thr_183.sdi
MySQL/Data/performance_schema/variables_info_186.sdi
MySQL/Data/sys/sys_config.ibd
MySQL/Data/ymdb/wh_bill_data.ibd
MySQL/Data/ymdb/wh_bill.ibd
MySQL/Data/ymdb/wh_material.ibd
MySQL/Data/ymdb/wh_warehouse_manager.ibd
MySQL/Data/ymdb/wh_warehouse.ibd
MySQL/Data/zklt/database_source.ibd
Redis/redis.conf

@ -0,0 +1 @@
start "gateway" cmd /k docker build -f GatewayAPI\Dockerfile -t gateway:latest .

@ -0,0 +1 @@
start "lansheng" cmd /k docker build -f Lansheng\LanShengAPI\Dockerfile -t lansheng:latest .

@ -0,0 +1 @@
start "zhonglian" cmd /k docker build -f ZhongLian\ZhongLianAPI\Dockerfile -t zhonglian:latest .

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CacheInterface
{
public interface ICacheService
{
Task Set<T>(string key, T value, int ttl = -1);
Task BatchSet<T>(Dictionary<string, T> values, int ttl = -1);
Task<T> Get<T>(string key);
Task<Dictionary<string, T>> BatchGet<T>(IEnumerable<string> keys);
Task Delete(string key);
Task BatchDelete(params string[] keys);
Task<Dictionary<string, T>> Query<T>(string query, int count = 9999);
}
}

@ -0,0 +1,38 @@
using CacheInterface;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapr.AspNetCore;
using Microsoft.Extensions.Caching.Memory;
using Google.Protobuf.WellKnownTypes;
using CommonExtend;
using Dapr.Client;
using Microsoft.Extensions.Logging;
using System.Text.Json;
namespace CacheService
{
public static class CacheServiceExtend
{
public static IServiceCollection InitRedisCacheService(this IServiceCollection services, string url)
{
services.AddSingleton<ICacheService, RedisCacheService>((_services) =>
{
return new RedisCacheService(_services, url);
});
return services;
}
public static IServiceCollection InitMemoryCacheService(this IServiceCollection services)
{
services.AddSingleton<ICacheService, MemoryCacheService>((_services) =>
{
return new MemoryCacheService(_services);
});
return services;
}
}
}

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapr.AspNetCore" Version="1.9.0" />
<PackageReference Include="Dapr.Client" Version="1.9.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="NewLife.Redis" Version="5.2.2023.301" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="StackExchange.Redis" Version="2.6.96" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CommonExtend\CommonExtend.csproj" />
<ProjectReference Include="..\CacheInterface\CacheInterface.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,116 @@
using CacheInterface;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NewLife.Caching;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace CacheService
{
public class MemoryCacheService : ICacheService
{
public MemoryCacheService(IServiceProvider services)
{
Services = services;
Logger = Services.GetRequiredService<ILogger<RedisCacheService>>();
Memory = new MemoryCache();
Logger.LogDebug("加载缓存服务");
}
private readonly IServiceProvider Services;
private readonly ILogger<RedisCacheService> Logger;
private readonly MemoryCache Memory;
public Task Set<T>(string key, T value, int ttl = -1)
{
Logger.LogDebug($"设置缓存{key}:{JsonSerializer.Serialize(value)}");
if (value == null)
{
Memory.Remove(key);
}
else
{
Memory.Set(key, value, ttl);
}
return Task.CompletedTask;
}
public Task BatchSet<T>(Dictionary<string, T> values, int ttl = -1)
{
Logger.LogDebug($"批量设置缓存:{JsonSerializer.Serialize(values)}");
Memory.SetAll(values, ttl);
return Task.CompletedTask;
}
public Task<T> Get<T>(string key)
{
Logger.LogDebug($"读取缓存{key}");
T Result = Memory.Get<T>(key);
Logger.LogDebug($"{JsonSerializer.Serialize(Result)}");
return Task.FromResult(Result);
}
public Task<Dictionary<string, T>> BatchGet<T>(IEnumerable<string> keys)
{
Logger.LogDebug("批量读取缓存");
Dictionary<string, T> Result = (Dictionary<string, T>)Memory.GetAll<T>(keys);
Logger.LogDebug($"{JsonSerializer.Serialize(Result)}");
return Task.FromResult(Result);
}
public Task Delete(string key)
{
Logger.LogDebug($"删除缓存{key}");
Memory.Remove(key);
return Task.CompletedTask;
}
public Task BatchDelete(params string[] keys)
{
Logger.LogDebug($"批量删除缓存{JsonSerializer.Serialize(keys)}");
Memory.Remove(keys);
return Task.CompletedTask;
}
public Task<Dictionary<string, T>> Query<T>(string query, int count = 9999)
{
Logger.LogDebug($"查询缓存{query}");
var Keys = Memory.Keys.Where(x => x.Contains(query));
var Result = new Dictionary<string, T>();
if (Keys.Count() > 0)
{
Result = (Dictionary<string, T>)Memory.GetAll<T>(Keys);
}
Logger.LogDebug($"查询缓存{query}:{JsonSerializer.Serialize(Result)}");
return Task.FromResult(Result);
}
}
}

@ -0,0 +1,123 @@
using CacheInterface;
using Google.Api;
using Google.Protobuf.WellKnownTypes;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NewLife.Caching;
using Newtonsoft.Json.Linq;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace CacheService
{
public class RedisCacheService : ICacheService
{
public RedisCacheService(IServiceProvider services, string url)
{
Services = services;
Logger = Services.GetRequiredService<ILogger<RedisCacheService>>();
Redis = new FullRedis();
Redis.Init(url);
Logger.LogDebug("加载Redis缓存服务");
}
private readonly IServiceProvider Services;
private readonly ILogger<RedisCacheService> Logger;
private readonly FullRedis Redis;
public Task Set<T>(string key, T value, int ttl = -1)
{
Logger.LogDebug($"设置缓存{key}:{JsonSerializer.Serialize(value)}");
if (value == null)
{
Redis.Remove(key);
}
else
{
Redis.Set(key, value, ttl);
}
return Task.CompletedTask;
}
public Task BatchSet<T>(Dictionary<string, T> values, int ttl = -1)
{
Logger.LogDebug($"批量设置缓存:{JsonSerializer.Serialize(values)}");
Redis.SetAll(values, ttl);
return Task.CompletedTask;
}
public Task<T> Get<T>(string key)
{
Logger.LogDebug($"读取缓存{key}");
T Result = Redis.Get<T>(key);
Logger.LogDebug($"{JsonSerializer.Serialize(Result)}");
return Task.FromResult(Result);
}
public Task<Dictionary<string, T>> BatchGet<T>(IEnumerable<string> keys)
{
Logger.LogDebug("批量读取缓存");
Dictionary<string, T> Result = (Dictionary<string, T>)Redis.GetAll<T>(keys);
Logger.LogDebug($"{JsonSerializer.Serialize(Result)}");
return Task.FromResult(Result);
}
public Task Delete(string key)
{
Logger.LogDebug($"删除缓存{key}");
Redis.Remove(key);
return Task.CompletedTask;
}
public Task BatchDelete(params string[] keys)
{
Logger.LogDebug($"批量删除缓存{JsonSerializer.Serialize(keys)}");
Redis.Remove(keys);
return Task.CompletedTask;
}
public Task<Dictionary<string, T>> Query<T>(string query, int count = 9999)
{
Logger.LogDebug($"查询缓存{query}");
var Keys = Redis.Search(query, count);
var Result = new Dictionary<string, T>();
if (Keys.Count() > 0)
{
Result = (Dictionary<string, T>)Redis.GetAll<T>(Keys);
}
Logger.LogDebug($"查询缓存{query}:{JsonSerializer.Serialize(Result)}");
return Task.FromResult(Result);
}
}
}

@ -0,0 +1,61 @@
using DotNetty.Buffers;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CommonExtend
{
public static class ByteBufferExtend
{
public static string ReadHex(this IByteBuffer buffer, int length)
{
IByteBuffer Temp = Unpooled.Buffer(length);
buffer.ReadBytes(Temp, length);
var Result = Temp.Array.Byte2HexString();
Temp.Clear();
return Result;
}
public static void WriteHex(this IByteBuffer buffer, string value,int length)
{
var Temp = value.HexString2Byte().BytePadLeft(length);
buffer.WriteBytes(Temp);
}
public static int ReadInt(this IByteBuffer buffer, int length)
{
IByteBuffer Temp = Unpooled.Buffer(length);
buffer.ReadBytes(Temp, length);
var Result = Temp.Array.Byte2Int();
Temp.Clear();
return Result;
}
public static void WriteInt(this IByteBuffer buffer, int value,int length) {
var Temp = value.Int2Byte().BytePadLeft(length);
buffer.WriteBytes(Temp);
}
public static int[] ReadBitArray(this IByteBuffer buffer)
{
IByteBuffer Temp = Unpooled.Buffer(1);
buffer.ReadBytes(Temp, 1);
var Temp1 = Temp.Array.Byte2BitArray();
var Result = new int[] {
Temp1[0]?1:0,
Temp1[1]?1:0,
Temp1[2]?1:0,
Temp1[3]?1:0,
Temp1[4]?1:0,
Temp1[5]?1:0,
Temp1[6]?1:0,
Temp1[7]?1:0
};
Temp.Clear();
return Result;
}
}
}

@ -0,0 +1,189 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace CommonExtend
{
/// <summary>
/// 字节扩展方法
/// </summary>
public static class ByteExtend
{
/// <summary>
/// 字节数组转16进制字符串空格分隔
/// </summary>
/// <param name="byteDatas"></param>
/// <returns></returns>
public static string Byte2HexString(this byte[] byteDatas)
{
StringBuilder builder = new StringBuilder();
for (int i = 0; i < byteDatas.Length; i++)
{
builder.Append(string.Format("{0:X2}", byteDatas[i]));
}
return builder.ToString().Trim();
}
/// <summary>
/// Hex字符串转Byte数组
/// </summary>
/// <param name="hex">字符串</param>
/// <returns></returns>
public static byte[] HexString2Byte(this string hex)
{
var inputByteArray = new byte[hex.Length / 2];
for (var x = 0; x < inputByteArray.Length; x++)
{
var i = Convert.ToInt32(hex.Substring(x * 2, 2), 16);
inputByteArray[x] = (byte)i;
}
return inputByteArray;
}
public static int Byte2HexSum(this byte[] byteDatas)
{
var Sum = 0;
foreach (var byteData in byteDatas)
{
Sum += new byte[] { byteData }.Byte2HexString().Hex2Int();
}
return Sum;
}
/// <summary>
/// 字节byte 转int
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public static int Byte2Int(this byte[] data)
{
if (data.Length <= 1)
{
data = data.BytePadLeft(2);
}
if (BitConverter.IsLittleEndian)
Array.Reverse(data);
return BitConverter.ToUInt16(data, 0);
}
/// <summary>
/// 字节byte 转int
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public static byte[] Int2Byte(this int data)
{
var Temp = BitConverter.GetBytes(data);
if (BitConverter.IsLittleEndian)
Array.Reverse(Temp);
return Temp;
}
/// <summary>
/// 字节byte 转string
/// </summary>
/// <param name="data">字节数组</param>
/// <returns></returns>
public static string Byte2String(this byte[] data)
{
return System.Text.Encoding.UTF8.GetString(data);
}
/// <summary>
/// 字符串转byte数组
/// </summary>
/// <param name="data">字符串</param>
/// <returns></returns>
public static byte[] String2Byte(this string data)
{
return System.Text.Encoding.UTF8.GetBytes(data);
}
/// <summary>
/// 字节byte 转bit数组
/// </summary>
/// <param name="data">字节数组</param>
/// <returns></returns>
public static BitArray Byte2BitArray(this byte[] data)
{
return new BitArray(data);
}
/// <summary>
/// 字节byte 转bit数组
/// </summary>
/// <param name="data">字节数组</param>
/// <returns></returns>
public static int Byte2Bit(this byte[] data, short index)
{
var _Bits = new BitArray(data);
return _Bits[index] ? 1 : 0;
}
public static byte[] BitArray2Byte(this BitArray bitArray)
{
bitArray.Length = 8;
byte[] Temp = new byte[1];
bitArray.CopyTo(Temp, 0);
return Temp;
}
public static byte[] BitArray2Byte(this int[] bitArray)
{
BitArray bitArray1 = new BitArray(new bool[] {
Convert.ToBoolean(bitArray[0]),
Convert.ToBoolean(bitArray[1]),
Convert.ToBoolean(bitArray[2]),
Convert.ToBoolean(bitArray[3]),
Convert.ToBoolean(bitArray[4]),
Convert.ToBoolean(bitArray[5]),
Convert.ToBoolean(bitArray[6]),
Convert.ToBoolean(bitArray[7])
});
return BitArray2Byte(bitArray1);
}
public static int[] Int2Bit(this int data, int length)
{
string Temp = Convert.ToString(data, 2).PadLeft(length, '0');
int[] Temp1 = new int[length];
for (var i = 0; i < length; i++)
{
Temp1[i] = Convert.ToInt32(Temp.Substring(i, 1));
}
return Temp1;
}
/// <summary>
/// 根据长度补全字节数组
/// </summary>
/// <param name="data">字节数组</param>
/// <param name="length">长度</param>
/// <returns></returns>
public static byte[] BytePadLeft(this IEnumerable<byte> data, int length)
{
var _List = data.ToList();
if (_List.Count < length)
{
for (var i = 0; i < length - data.Count(); i++)
{
_List.Insert(0, new byte());
}
}
else if (_List.Count > length)
{
for (var i = 0; i < data.Count() - length; i++)
{
_List.RemoveAt(0);
}
}
return _List.ToArray();
}
}
}

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapr.Client" Version="1.9.0" />
<PackageReference Include="DotNetty.Buffers" Version="0.7.5" />
</ItemGroup>
</Project>

@ -0,0 +1,28 @@
using Dapr.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CommonExtend
{
public static class DaprExtend
{
public static bool Completed = false;
public static Task WaitComplete(this DaprClient daprClient) {
while (!daprClient.CheckHealthAsync().Result) {
Thread.Sleep(1000);
}
daprClient.WaitForSidecarAsync().Wait();
if (Completed)
{
return Task.CompletedTask;
}
Thread.Sleep(3000);
Completed = true;
return Task.CompletedTask;
}
}
}

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CommonExtend
{
public static class StringExtend
{
public static int Hex2Int(this string data)
{
return Convert.ToInt32(data, 16);
}
}
}

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CommonModel
{
public class BadRequestException: Exception
{
public BadRequestException(string message) : base(message) {
}
}
}

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CommonModel
{
public class PageBase
{
/// <summary>
/// 分页下标
/// </summary>
public int Index = 1;
/// <summary>
/// 分页大小
/// </summary>
public int Size = 20;
}
}

@ -0,0 +1,23 @@
namespace CommonModel
{
public class PageData : PageBase
{
/// <summary>
/// 结果条目合计
/// </summary>
public int Total { get; set; }
/// <summary>
/// 分页数据
/// </summary>
public List<dynamic>? Data { get; set; }
}
public class PageData<T> : PageData
{
/// <summary>
/// 分页数据
/// </summary>
public new List<T>? Data { get; set; }
}
}

@ -0,0 +1,122 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CommonModel
{
public class PageSearch : PageBase
{
/// <summary>
/// 统一查询
/// </summary>
public string? Search { get; set; }
/// <summary>
/// 开始日期
/// </summary>
public DateTime? StartDate { get; set; }
/// <summary>
/// 结束日期
/// </summary>
public DateTime? EndDate { get; set; }
}
public class PageSearch<T> : PageSearch
{
/// <summary>
/// 查询条件
/// </summary>
public T? Mode { get; set; }
}
public class PageDaySearch : PageSearch {
public PageDaySearch()
{
var DateNow = DateTime.Now;
if (StartDate == null && EndDate == null)
{
StartDate = DateTime.Today;
EndDate = DateNow;
}
else if (StartDate == null)
{
StartDate = DateTime.Today;
}
else if (EndDate == null)
{
EndDate = DateNow;
}
}
}
public class PageDaySearch<T> : PageDaySearch {
/// <summary>
/// 查询条件
/// </summary>
public T? Mode { get; set; }
}
public class PageMonthSearch : PageSearch
{
public PageMonthSearch()
{
var DateNow = DateTime.Now;
if (StartDate == null && EndDate == null)
{
StartDate = DateNow.AddMonths(-1);
EndDate = DateNow;
}
else if (StartDate == null)
{
StartDate = DateNow.AddMonths(-1);
}
else if (EndDate == null)
{
EndDate = DateNow;
}
}
}
public class PageMonthSearch<T> : PageMonthSearch
{
/// <summary>
/// 查询条件
/// </summary>
public T? Mode { get; set; }
}
public class PageYearSearch : PageSearch
{
public PageYearSearch()
{
var DateNow = DateTime.Now;
if (StartDate == null && EndDate == null)
{
StartDate = DateNow.AddYears(-1);
EndDate = DateNow;
}
else if (StartDate == null)
{
StartDate = DateNow.AddYears(-1);
}
else if (EndDate == null)
{
EndDate = DateNow;
}
}
}
public class PageYearSearch<T> : PageYearSearch
{
/// <summary>
/// 查询条件
/// </summary>
public T? Mode { get; set; }
}
}

@ -0,0 +1,12 @@
{
"profiles": {
"CommonModel": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:64279;http://localhost:64282"
}
}
}

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CommonModel
{
public class SplitDateId
{
/// <summary>
/// 开始日期
/// </summary>
public DateTime StartDate { get; set; }
/// <summary>
/// 结束日期
/// </summary>
public DateTime EndDate { get; set; }
public SplitDateId(string id, int index) {
StartDate = new DateTime(int.Parse(id.Substring(index, 4)), int.Parse(id.Substring(index + 4, 2)), int.Parse(id.Substring(index + 6, 2)), 0, 0, 0);
EndDate = new DateTime(int.Parse(id.Substring(index, 4)), int.Parse(id.Substring(index + 4, 2)), int.Parse(id.Substring(index + 6, 2)), 23, 59, 59);
}
}
}

@ -0,0 +1,30 @@
# 本地测试请修改hosts文件
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: rabbitmq-pubsub
spec:
type: pubsub.rabbitmq
version: v1
metadata:
# rabbitmq地址
- name: host
value: "amqp://rabbitmq:5672"
# 消息持久化
- name: durable
value: "true"
# 是否自动删除
- name: deletedWhenUnused
value: "false"
# 持久模型
- name: deliveryMode
value: "2"
# 预提消息数
- name: prefetchCount
value: "10"
# 重试等待时间
- name: reconnectWait
value: "3"
# 并行处理
- name: concurrencyMode
value: parallel

@ -0,0 +1,13 @@
# 本地测试请修改hosts文件
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: redis-pubsub
spec:
type: pubsub.redis
version: v1
metadata:
- name: redisHost
value: redis:6379
- name: redisPassword
value: ""

@ -0,0 +1,20 @@
# 本地测试请修改hosts文件
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
spec:
type: state.redis
version: v1
metadata:
- name: redisHost
value: redis:6379
- name: redisPassword
value: ""
- name: actorStateStore
value: "true"
- name: keyPrefix
value: None
# - 这是默认策略。 带有appid前缀的状态仅允许具有指定appid的应用程序管理。 所有的状态键都会以appid为前缀并对应用进行限定。
# name - 此设置使用状态存储组件的名称作为前缀。 对于一个给定的状态存储,多个应用程序可以共享同一个状态。
# none - 此设置不使用前缀。 多个应用程序在不同的状态存储中共享状态。

@ -0,0 +1,10 @@
# 本地测试请修改hosts文件
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: daprConfig
spec:
tracing:
samplingRate: "1"
zipkin:
endpointAddress: http://zipkin:9411/api/v2/spans

@ -0,0 +1,379 @@
version: '3.4'
services:
# Dapr Actor 服务
placement:
container_name: placement
hostname: placement
image: "daprio/dapr:1.9.5"
restart: always
command: ["./placement", "-port", "6050"]
networks:
- fy
# Dapr zipkin 检测
zipkin:
container_name: zipkin
hostname: zipkin
image: "openzipkin/zipkin:2.23.19"
restart: always
ports:
- "9411:9411"
networks:
- fy
gateway:
# container_name: gateway
image: "gateway:latest"
restart: always
# 端口映射
ports:
- "5330:5330"
# 应用启动时的地址
environment:
- "ASPNETCORE_URLS=http://*:5330;"
depends_on:
- placement
- zipkin
networks:
- fy
- mq
- cache
- db
gateway-dapr:
image: "daprio/daprd:1.9.5"
# restart: always
command: [ "./daprd", "-app-id", "gateway",
# 应用端口号
"-app-port", "5330" ,
"-dapr-http-port","6330",
"-placement-host-address","placement:6050",
# dapr 配置文件
"-config","/Dapr/config.yaml",
# dapr 组件
"-components-path", "/Dapr/Components"]
depends_on:
- gateway
# 数据持久化 - [卷标名称]:/var/lib/mysql 或者 - [直接使用宿主机的本地路径]:/var/lib/mysql
volumes:
- "../Dapr:/Dapr"
# 工作模型:绑定边车匹配的应用服务名
network_mode: "service:gateway"
auth:
# container_name: zhonglian
image: "auth:latest"
restart: always
# 端口映射
# ports:
# - "5027:80"
# 应用启动时的地址
# environment:
# - "ASPNETCORE_URLS=http://*:8081;"
depends_on:
- placement
- zipkin
#volumes:
# - "/usr/share/zoneinfo/Asia/Shanghai:/etc/localtime"
networks:
- fy
- mq
- cache
- db
auth-dapr:
image: "daprio/daprd:1.9.5"
restart: always
command: [ "./daprd", "-app-id", "auth",
# 应用端口号
"-app-port", "80" ,
"-placement-host-address","placement:6050",
# dapr 配置文件
"-config","/Dapr/config.yaml",
# dapr 组件
"-components-path", "/Dapr/Components"]
# 数据持久化 - [卷标名称]:/var/lib/mysql 或者 - [直接使用宿主机的本地路径]:/var/lib/mysql
depends_on:
- auth
volumes:
- "../Dapr:/Dapr"
# 工作模型:绑定边车匹配的应用服务名
network_mode: "service:auth"
crm:
# container_name: zhonglian
image: "crm:latest"
restart: always
# 端口映射
# ports:
# - "5027:80"
# 应用启动时的地址
# environment:
# - "ASPNETCORE_URLS=http://*:8081;"
depends_on:
- placement
- zipkin
#volumes:
# - "/usr/share/zoneinfo/Asia/Shanghai:/etc/localtime"
networks:
- fy
- mq
- cache
- db
crm-dapr:
image: "daprio/daprd:1.9.5"
restart: always
command: [ "./daprd", "-app-id", "crm",
# 应用端口号
"-app-port", "80" ,
"-placement-host-address","placement:6050",
# dapr 配置文件
"-config","/Dapr/config.yaml",
# dapr 组件
"-components-path", "/Dapr/Components"]
# 数据持久化 - [卷标名称]:/var/lib/mysql 或者 - [直接使用宿主机的本地路径]:/var/lib/mysql
depends_on:
- crm
volumes:
- "../Dapr:/Dapr"
# 工作模型:绑定边车匹配的应用服务名
network_mode: "service:crm"
drive:
# container_name: zhonglian
image: "drive:latest"
restart: always
# 端口映射
# ports:
# - "5027:80"
# 应用启动时的地址
# environment:
# - "ASPNETCORE_URLS=http://*:8081;"
depends_on:
- placement
- zipkin
#volumes:
# - "/usr/share/zoneinfo/Asia/Shanghai:/etc/localtime"
networks:
- fy
- mq
- cache
- db
drive-dapr:
image: "daprio/daprd:1.9.5"
restart: always
command: [ "./daprd", "-app-id", "drive",
# 应用端口号
"-app-port", "80" ,
"-placement-host-address","placement:6050",
# dapr 配置文件
"-config","/Dapr/config.yaml",
# dapr 组件
"-components-path", "/Dapr/Components"]
# 数据持久化 - [卷标名称]:/var/lib/mysql 或者 - [直接使用宿主机的本地路径]:/var/lib/mysql
depends_on:
- drive
volumes:
- "../Dapr:/Dapr"
# 工作模型:绑定边车匹配的应用服务名
network_mode: "service:drive"
tprz:
# container_name: zhonglian
image: "tprz:latest"
restart: always
# 端口映射
# ports:
# - "5027:80"
# 应用启动时的地址
# environment:
# - "ASPNETCORE_URLS=http://*:8081;"
depends_on:
- placement
- zipkin
#volumes:
# - "/usr/share/zoneinfo/Asia/Shanghai:/etc/localtime"
networks:
- fy
- mq
- cache
- db
tprz-dapr:
image: "daprio/daprd:1.9.5"
restart: always
command: [ "./daprd", "-app-id", "tprz",
# 应用端口号
"-app-port", "80" ,
"-placement-host-address","placement:6050",
# dapr 配置文件
"-config","/Dapr/config.yaml",
# dapr 组件
"-components-path", "/Dapr/Components"]
# 数据持久化 - [卷标名称]:/var/lib/mysql 或者 - [直接使用宿主机的本地路径]:/var/lib/mysql
depends_on:
- tprz
volumes:
- "../Dapr:/Dapr"
# 工作模型:绑定边车匹配的应用服务名
network_mode: "service:tprz"
wms:
# container_name: zhonglian
image: "wms:latest"
restart: always
# 端口映射
# ports:
# - "5027:80"
# 应用启动时的地址
# environment:
# - "ASPNETCORE_URLS=http://*:8081;"
depends_on:
- placement
- zipkin
#volumes:
# - "/usr/share/zoneinfo/Asia/Shanghai:/etc/localtime"
networks:
- fy
- mq
- cache
- db
wms-dapr:
image: "daprio/daprd:1.9.5"
restart: always
command: [ "./daprd", "-app-id", "wms",
# 应用端口号
"-app-port", "80" ,
"-placement-host-address","placement:6050",
# dapr 配置文件
"-config","/Dapr/config.yaml",
# dapr 组件
"-components-path", "/Dapr/Components"]
# 数据持久化 - [卷标名称]:/var/lib/mysql 或者 - [直接使用宿主机的本地路径]:/var/lib/mysql
depends_on:
- wms
volumes:
- "../Dapr:/Dapr"
# 工作模型:绑定边车匹配的应用服务名
network_mode: "service:wms"
bw:
# container_name: zhonglian
image: "bw:latest"
restart: always
# 端口映射
# ports:
# - "5027:80"
# 应用启动时的地址
# environment:
# - "ASPNETCORE_URLS=http://*:8081;"
depends_on:
- placement
- zipkin
#volumes:
# - "/usr/share/zoneinfo/Asia/Shanghai:/etc/localtime"
networks:
- fy
- mq
- cache
- db
bw-dapr:
image: "daprio/daprd:1.9.5"
restart: always
command: [ "./daprd", "-app-id", "bw",
# 应用端口号
"-app-port", "80" ,
"-placement-host-address","placement:6050",
# dapr 配置文件
"-config","/Dapr/config.yaml",
# dapr 组件
"-components-path", "/Dapr/Components"]
# 数据持久化 - [卷标名称]:/var/lib/mysql 或者 - [直接使用宿主机的本地路径]:/var/lib/mysql
depends_on:
- bw
volumes:
- "../Dapr:/Dapr"
# 工作模型:绑定边车匹配的应用服务名
network_mode: "service:bw"
zhonglian:
# container_name: zhonglian
image: "zhonglian:latest"
restart: always
# 端口映射
# ports:
# - "5027:80"
# 应用启动时的地址
depends_on:
- placement
- zipkin
networks:
- fy
- mq
- cache
- db
zhonglian-dapr:
image: "daprio/daprd:1.9.5"
restart: always
command: [ "./daprd", "-app-id", "zhonglian",
# 应用端口号
"-app-port", "80" ,
"-placement-host-address","placement:6050",
# dapr 配置文件
"-config","/Dapr/config.yaml",
# dapr 组件
"-components-path", "/Dapr/Components"]
# 数据持久化 - [卷标名称]:/var/lib/mysql 或者 - [直接使用宿主机的本地路径]:/var/lib/mysql
depends_on:
- zhonglian
volumes:
- "../Dapr:/Dapr"
# 工作模型:绑定边车匹配的应用服务名
network_mode: "service:zhonglian"
lansheng:
image: "lansheng:latest"
restart: always
# 端口映射
ports:
- "9001:9001"
networks:
- fy
- mq
- cache
- db
lansheng-dapr:
image: "daprio/daprd:1.9.5"
restart: always
command: [ "./daprd", "-app-id", "lansheng",
# 应用端口号
"-app-port", "80" ,
"-placement-host-address","placement:6050",
# dapr 配置文件
"-config","/Dapr/config.yaml",
# dapr 组件
"-components-path", "/Dapr/Components"]
# 数据持久化 - [卷标名称]:/var/lib/mysql 或者 - [直接使用宿主机的本地路径]:/var/lib/mysql
depends_on:
- lansheng
volumes:
- "../Dapr:/Dapr"
# 工作模型:绑定边车匹配的应用服务名
network_mode: "service:lansheng"
networks:
fy:
db:
external: true
mq:
external: true
cache:
external: true

@ -0,0 +1,103 @@
version: '3.4'
services:
# Dapr Actor 服务
placement:
container_name: placement
hostname: placement
image: "daprio/dapr:1.9.5"
restart: always
command: ["./placement", "-port", "6050"]
networks:
- fy
# Dapr zipkin 检测
zipkin:
container_name: zipkin
hostname: zipkin
image: "openzipkin/zipkin:2.23.19"
restart: always
ports:
- "9411:9411"
networks:
- fy
gateway:
# container_name: gateway
image: "gateway:latest"
restart: always
# 端口映射
ports:
- "5330:5330"
# 应用启动时的地址
environment:
- "ASPNETCORE_URLS=http://*:5330;"
depends_on:
- placement
- zipkin
networks:
- fy
- mq
- cache
- db
gateway-dapr:
image: "daprio/daprd:1.9.5"
# restart: always
command: [ "./daprd", "-app-id", "gateway",
# 应用端口号
"-app-port", "5330" ,
"-dapr-http-port","6330",
"-placement-host-address","placement:6050",
# dapr 配置文件
"-config","/Dapr/config.yaml",
# dapr 组件
"-components-path", "/Dapr/Components"]
depends_on:
- gateway
# 数据持久化 - [卷标名称]:/var/lib/mysql 或者 - [直接使用宿主机的本地路径]:/var/lib/mysql
volumes:
- "../Dapr:/Dapr"
# 工作模型:绑定边车匹配的应用服务名
network_mode: "service:gateway"
lansheng:
image: "lansheng:latest"
restart: always
# 端口映射
ports:
- "9001:9001"
networks:
- fy
- mq
- cache
- db
lansheng-dapr:
image: "daprio/daprd:1.9.5"
restart: always
command: [ "./daprd", "-app-id", "lansheng",
# 应用端口号
"-app-port", "80" ,
"-placement-host-address","placement:6050",
# dapr 配置文件
"-config","/Dapr/config.yaml",
# dapr 组件
"-components-path", "/Dapr/Components"]
# 数据持久化 - [卷标名称]:/var/lib/mysql 或者 - [直接使用宿主机的本地路径]:/var/lib/mysql
depends_on:
- lansheng
volumes:
- "../Dapr:/Dapr"
# 工作模型:绑定边车匹配的应用服务名
network_mode: "service:lansheng"
networks:
fy:
db:
external: true
mq:
external: true
cache:
external: true

@ -0,0 +1,60 @@
version: '3.4'
services:
# Dapr Actor 服务
redis:
container_name: redis
hostname: redis
image: "redis:6"
restart: always
ports:
- 6379:6379
environment:
TZ: Asia/Shanghai
volumes:
- ../Redis/redis.conf:/etc/redis/redis.conf
- ../Redis/data:/data
- ../Redis/logs:/logs
command: ["redis-server","/etc/redis/redis.conf"]
networks:
- cache
rabbitmq:
container_name: rabbitmq
hostname: rabbitmq
image: "rabbitmq:3.9.26-management"
restart: always
ports:
- 5672:5672
- 15672:15672
environment:
TZ: Asia/Shanghai
networks:
- mq
mysql:
container_name: mysql
hostname: mysql
image: "mysql:8"
restart: always
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: lsdb
TZ: Asia/Shanghai
volumes:
- ../MySQL/Data:/var/lib/mysql
- ../Mysql/Conf:/etc/mysql/conf.d/
command:
--lower_case_table_names=1
networks:
- db
networks:
db:
external: true
mq:
external: true
cache:
external: true

@ -0,0 +1,140 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ZhongLian", "ZhongLian", "{1FC51DED-0F42-4590-8FBA-ABCDDA960DFF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZhongLianAPI", "ZhongLian\ZhongLianAPI\ZhongLianAPI.csproj", "{6CB326C0-7C4F-404B-9CCC-6DCAFF907934}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZhongLianService", "ZhongLian\ZhongLianService\ZhongLianService.csproj", "{9E0013B1-441E-436A-B162-CF563E420391}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZhongLianModel", "ZhongLian\ZhongLianModel\ZhongLianModel.csproj", "{726BDE65-C3DC-498A-AFFD-9A35870BF573}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommonModel", "CommonModel\CommonModel.csproj", "{19193040-09A6-4B46-9BDA-9A8482A2E6E6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DockerCompose", "DockerCompose", "{AE411252-D6A9-4242-B67A-73D3FCB54778}"
ProjectSection(SolutionItems) = preProject
DockerCompose\docker-compose-all.yml = DockerCompose\docker-compose-all.yml
DockerCompose\docker-compose-dev.yml = DockerCompose\docker-compose-dev.yml
DockerCompose\docker-compose-env.yml = DockerCompose\docker-compose-env.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dapr", "Dapr", "{C9A49A38-F460-428D-9580-E810EA00F4E8}"
ProjectSection(SolutionItems) = preProject
Dapr\config.yaml = Dapr\config.yaml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Components", "Components", "{F65F5C2A-33B2-48D9-B4B0-14C455FE4C64}"
ProjectSection(SolutionItems) = preProject
Dapr\Components\pubsub-rabbitmq.yaml = Dapr\Components\pubsub-rabbitmq.yaml
Dapr\Components\pubsub-redis.yaml = Dapr\Components\pubsub-redis.yaml
Dapr\Components\statestore.yaml = Dapr\Components\statestore.yaml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GatewayAPI", "GatewayAPI\GatewayAPI.csproj", "{56EB64A2-F37F-4AE0-B63B-60C1E37FA7BE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Redis", "Redis", "{8C4F2BD0-8150-4812-8586-58367CD78B58}"
ProjectSection(SolutionItems) = preProject
Redis\redis.conf = Redis\redis.conf
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommonExtend", "CommonExtend\CommonExtend.csproj", "{FA95FA55-08F7-45A3-BFAD-177D36444024}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZhongLianInterface", "ZhongLian\ZhongLianInterface\ZhongLianInterface.csproj", "{D14C3E63-AA5A-45AA-BB8F-A9F3629A4839}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LanSheng", "LanSheng", "{32BDB007-D878-44E8-8AE2-1F9883DC1F0C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cache", "Cache", "{B2F2732F-074B-45AA-AFA4-A15C24A44E6C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheService", "Cache\CacheService\CacheService.csproj", "{592A8FEE-B09E-4A58-B56A-DFF2106A5A40}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheInterface", "Cache\CacheInterface\CacheInterface.csproj", "{4CC3E08E-C392-4584-BAD8-D686B366EF6D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LanShengAPI", "LanSheng\LanShengAPI\LanShengAPI.csproj", "{75DF5305-9570-4B5A-8EA7-A9E221A5AFC5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LanShengService", "LanSheng\LanShengService\LanShengService.csproj", "{518B59A4-7FE1-49DB-90D4-795B7A5FB59D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LanShengInterface", "LanSheng\LanShengInterface\LanShengInterface.csproj", "{E201C20A-D557-4E11-AC62-1DFCDB3FD434}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LanShengModel", "LanSheng\LanShengModel\LanShengModel.csproj", "{F1FA7228-55A8-4D7A-A10C-1180AB5F3A70}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6CB326C0-7C4F-404B-9CCC-6DCAFF907934}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CB326C0-7C4F-404B-9CCC-6DCAFF907934}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CB326C0-7C4F-404B-9CCC-6DCAFF907934}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CB326C0-7C4F-404B-9CCC-6DCAFF907934}.Release|Any CPU.Build.0 = Release|Any CPU
{9E0013B1-441E-436A-B162-CF563E420391}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E0013B1-441E-436A-B162-CF563E420391}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E0013B1-441E-436A-B162-CF563E420391}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E0013B1-441E-436A-B162-CF563E420391}.Release|Any CPU.Build.0 = Release|Any CPU
{726BDE65-C3DC-498A-AFFD-9A35870BF573}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{726BDE65-C3DC-498A-AFFD-9A35870BF573}.Debug|Any CPU.Build.0 = Debug|Any CPU
{726BDE65-C3DC-498A-AFFD-9A35870BF573}.Release|Any CPU.ActiveCfg = Release|Any CPU
{726BDE65-C3DC-498A-AFFD-9A35870BF573}.Release|Any CPU.Build.0 = Release|Any CPU
{19193040-09A6-4B46-9BDA-9A8482A2E6E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19193040-09A6-4B46-9BDA-9A8482A2E6E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19193040-09A6-4B46-9BDA-9A8482A2E6E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19193040-09A6-4B46-9BDA-9A8482A2E6E6}.Release|Any CPU.Build.0 = Release|Any CPU
{56EB64A2-F37F-4AE0-B63B-60C1E37FA7BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56EB64A2-F37F-4AE0-B63B-60C1E37FA7BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56EB64A2-F37F-4AE0-B63B-60C1E37FA7BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56EB64A2-F37F-4AE0-B63B-60C1E37FA7BE}.Release|Any CPU.Build.0 = Release|Any CPU
{FA95FA55-08F7-45A3-BFAD-177D36444024}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA95FA55-08F7-45A3-BFAD-177D36444024}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA95FA55-08F7-45A3-BFAD-177D36444024}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA95FA55-08F7-45A3-BFAD-177D36444024}.Release|Any CPU.Build.0 = Release|Any CPU
{D14C3E63-AA5A-45AA-BB8F-A9F3629A4839}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D14C3E63-AA5A-45AA-BB8F-A9F3629A4839}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D14C3E63-AA5A-45AA-BB8F-A9F3629A4839}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D14C3E63-AA5A-45AA-BB8F-A9F3629A4839}.Release|Any CPU.Build.0 = Release|Any CPU
{592A8FEE-B09E-4A58-B56A-DFF2106A5A40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{592A8FEE-B09E-4A58-B56A-DFF2106A5A40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{592A8FEE-B09E-4A58-B56A-DFF2106A5A40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{592A8FEE-B09E-4A58-B56A-DFF2106A5A40}.Release|Any CPU.Build.0 = Release|Any CPU
{4CC3E08E-C392-4584-BAD8-D686B366EF6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4CC3E08E-C392-4584-BAD8-D686B366EF6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CC3E08E-C392-4584-BAD8-D686B366EF6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4CC3E08E-C392-4584-BAD8-D686B366EF6D}.Release|Any CPU.Build.0 = Release|Any CPU
{75DF5305-9570-4B5A-8EA7-A9E221A5AFC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75DF5305-9570-4B5A-8EA7-A9E221A5AFC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75DF5305-9570-4B5A-8EA7-A9E221A5AFC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75DF5305-9570-4B5A-8EA7-A9E221A5AFC5}.Release|Any CPU.Build.0 = Release|Any CPU
{518B59A4-7FE1-49DB-90D4-795B7A5FB59D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{518B59A4-7FE1-49DB-90D4-795B7A5FB59D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{518B59A4-7FE1-49DB-90D4-795B7A5FB59D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{518B59A4-7FE1-49DB-90D4-795B7A5FB59D}.Release|Any CPU.Build.0 = Release|Any CPU
{E201C20A-D557-4E11-AC62-1DFCDB3FD434}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E201C20A-D557-4E11-AC62-1DFCDB3FD434}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E201C20A-D557-4E11-AC62-1DFCDB3FD434}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E201C20A-D557-4E11-AC62-1DFCDB3FD434}.Release|Any CPU.Build.0 = Release|Any CPU
{F1FA7228-55A8-4D7A-A10C-1180AB5F3A70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F1FA7228-55A8-4D7A-A10C-1180AB5F3A70}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F1FA7228-55A8-4D7A-A10C-1180AB5F3A70}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F1FA7228-55A8-4D7A-A10C-1180AB5F3A70}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6CB326C0-7C4F-404B-9CCC-6DCAFF907934} = {1FC51DED-0F42-4590-8FBA-ABCDDA960DFF}
{9E0013B1-441E-436A-B162-CF563E420391} = {1FC51DED-0F42-4590-8FBA-ABCDDA960DFF}
{726BDE65-C3DC-498A-AFFD-9A35870BF573} = {1FC51DED-0F42-4590-8FBA-ABCDDA960DFF}
{F65F5C2A-33B2-48D9-B4B0-14C455FE4C64} = {C9A49A38-F460-428D-9580-E810EA00F4E8}
{D14C3E63-AA5A-45AA-BB8F-A9F3629A4839} = {1FC51DED-0F42-4590-8FBA-ABCDDA960DFF}
{592A8FEE-B09E-4A58-B56A-DFF2106A5A40} = {B2F2732F-074B-45AA-AFA4-A15C24A44E6C}
{4CC3E08E-C392-4584-BAD8-D686B366EF6D} = {B2F2732F-074B-45AA-AFA4-A15C24A44E6C}
{75DF5305-9570-4B5A-8EA7-A9E221A5AFC5} = {32BDB007-D878-44E8-8AE2-1F9883DC1F0C}
{518B59A4-7FE1-49DB-90D4-795B7A5FB59D} = {32BDB007-D878-44E8-8AE2-1F9883DC1F0C}
{E201C20A-D557-4E11-AC62-1DFCDB3FD434} = {32BDB007-D878-44E8-8AE2-1F9883DC1F0C}
{F1FA7228-55A8-4D7A-A10C-1180AB5F3A70} = {32BDB007-D878-44E8-8AE2-1F9883DC1F0C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9BB66DA6-6F98-49BB-BC0B-FB09B4CC7C05}
EndGlobalSection
EndGlobal

@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "7.0.3",
"commands": [
"dotnet-ef"
]
}
}
}

@ -0,0 +1,22 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" >/etc/timezone
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["GatewayAPI/GatewayAPI.csproj", "GatewayAPI/"]
RUN dotnet restore "GatewayAPI/GatewayAPI.csproj"
COPY . .
WORKDIR "/src/GatewayAPI"
RUN dotnet build "GatewayAPI.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "GatewayAPI.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "GatewayAPI.dll"]

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Ocelot" Version="18.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
</ItemGroup>
</Project>

@ -0,0 +1,121 @@
using Ocelot.Authentication.Middleware;
using Ocelot.Authorization.Middleware;
using Ocelot.Cache.Middleware;
using Ocelot.Claims.Middleware;
using Ocelot.DownstreamPathManipulation.Middleware;
using Ocelot.DownstreamRouteFinder.Middleware;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.DownstreamUrlCreator.Middleware;
using Ocelot.Errors.Middleware;
using Ocelot.Headers.Middleware;
using Ocelot.LoadBalancer.Middleware;
using Ocelot.Logging;
using Ocelot.Middleware;
using Ocelot.Multiplexer;
using Ocelot.QueryStrings.Middleware;
using Ocelot.RateLimit.Middleware;
using Ocelot.Request.Middleware;
using Ocelot.Requester.Middleware;
using Ocelot.RequestId.Middleware;
using Ocelot.Responder.Middleware;
using Ocelot.Security.Middleware;
using Ocelot.WebSockets.Middleware;
namespace GatewayAPI
{
public static class OcelotPipelineExtensions
{
public static RequestDelegate BuildOcelotPipeline(this IApplicationBuilder app, OcelotPipelineConfiguration pipelineConfiguration)
{
app.UseDownstreamContextMiddleware();
app.UseExceptionHandlerMiddleware();
app.MapWhen((HttpContext httpContext) => httpContext.WebSockets.IsWebSocketRequest, delegate (IApplicationBuilder wenSocketsApp)
{
wenSocketsApp.UseDownstreamRouteFinderMiddleware();
wenSocketsApp.UseMultiplexingMiddleware();
wenSocketsApp.UseDownstreamRequestInitialiser();
wenSocketsApp.UseLoadBalancingMiddleware();
wenSocketsApp.UseMiddleware<HostReplaceMiddleware>();
wenSocketsApp.UseDownstreamUrlCreatorMiddleware();
wenSocketsApp.UseWebSocketsProxyMiddleware();
});
app.UseIfNotNull(pipelineConfiguration.PreErrorResponderMiddleware);
app.UseResponderMiddleware();
app.UseDownstreamRouteFinderMiddleware();
app.UseMultiplexingMiddleware();
app.UseSecurityMiddleware();
if (pipelineConfiguration.MapWhenOcelotPipeline != null)
{
foreach (KeyValuePair<Func<HttpContext, bool>, Action<IApplicationBuilder>> item in pipelineConfiguration.MapWhenOcelotPipeline)
{
app.MapWhen(item.Key, item.Value);
}
}
app.UseHttpHeadersTransformationMiddleware();
app.UseDownstreamRequestInitialiser();
app.UseRateLimiting();
app.UseRequestIdMiddleware();
app.UseIfNotNull(pipelineConfiguration.PreAuthenticationMiddleware);
if (pipelineConfiguration.AuthenticationMiddleware == null)
{
app.UseAuthenticationMiddleware();
}
else
{
app.Use(pipelineConfiguration.AuthenticationMiddleware);
}
app.UseClaimsToClaimsMiddleware();
app.UseIfNotNull(pipelineConfiguration.PreAuthorizationMiddleware);
if (pipelineConfiguration.AuthorizationMiddleware == null)
{
app.UseAuthorizationMiddleware();
}
else
{
app.Use(pipelineConfiguration.AuthorizationMiddleware);
}
app.UseClaimsToHeadersMiddleware();
app.UseIfNotNull(pipelineConfiguration.PreQueryStringBuilderMiddleware);
app.UseClaimsToQueryStringMiddleware();
app.UseClaimsToDownstreamPathMiddleware();
app.UseLoadBalancingMiddleware();
app.UseMiddleware<HostReplaceMiddleware>();
app.UseDownstreamUrlCreatorMiddleware();
app.UseOutputCacheMiddleware();
app.UseHttpRequesterMiddleware();
return app.Build();
}
private static void UseIfNotNull(this IApplicationBuilder builder, Func<HttpContext, Func<Task>, Task> middleware)
{
if (middleware != null)
{
builder.Use(middleware);
}
}
}
public class HostReplaceMiddleware : OcelotMiddleware
{
private readonly RequestDelegate _next;
public HostReplaceMiddleware(RequestDelegate next, IOcelotLoggerFactory loggerFactory)
: base(loggerFactory.CreateLogger<HostReplaceMiddleware>())
{
_next = next;
}
public async Task Invoke(HttpContext httpContext)
{
DownstreamRequest downstreamRequest = httpContext.Items.DownstreamRequest();
List<PlaceholderNameAndValue> list = httpContext.Items.TemplatePlaceholderNameAndValues();
list.ForEach((v) => {
downstreamRequest.Host = downstreamRequest.Host.Replace(v.Name, v.Value);
});
await _next(httpContext);
}
}
}

@ -0,0 +1,48 @@
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
#region Cors跨域
builder.Services.AddCors(options =>
{
options.AddPolicy("all", builder =>
{
builder.SetIsOriginAllowed(origin => true) //允许任何来源的主机访问
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials();//指定处理cookie
});
});
#endregion
#region Body长度
builder.Services.Configure<KestrelServerOptions>(options =>
{
options.Limits.MaxRequestBodySize = null;//不做限制
});
builder.Services.Configure<IISServerOptions>(options =>
{
options.MaxRequestBodySize = null;//不做限制
});
builder.Services.Configure<FormOptions>(x =>
{
x.ValueLengthLimit = int.MaxValue;
x.MultipartBodyLengthLimit = int.MaxValue;
x.MultipartHeadersLengthLimit = int.MaxValue;
});
#endregion
builder.Services.AddOcelot(builder.Configuration);
var app = builder.Build();
#region Cors跨域
app.UseCors("all");
#endregion
app.UseWebSockets();
app.UseOcelot((build, cfg) =>
{
build.BuildOcelotPipeline(cfg);
}).Wait();
app.Run();

@ -0,0 +1,37 @@
{
"profiles": {
"GatewayAPI": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5080"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:16737",
"sslPort": 0
}
}
}

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

@ -0,0 +1,88 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Routes": [
{
"DownstreamPathTemplate": "/v1.0/invoke/{app}/method/api/{url}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": "6330"
}
],
"UpstreamPathTemplate": "/{app}/api/{url}",
"UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ],
"Priority": 0
},
{
"DownstreamPathTemplate": "/v1.0/invoke/lansheng/method/api/device/{url}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": "6330"
}
],
"UpstreamPathTemplate": "/ry/api/gpsdata/{url}",
"UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ],
"Priority": 1
},
{
"DownstreamPathTemplate": "/2WaoDPVQth.txt",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "tprz",
"Port": "80"
}
],
"UpstreamPathTemplate": "/2WaoDPVQth.txt",
"UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ],
"Priority": 0
},
{
"DownstreamPathTemplate": "/Scanner.mp4",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "tprz",
"Port": "80"
}
],
"UpstreamPathTemplate": "/Scanner.mp4",
"UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ],
"Priority": 0
},
{
"DownstreamPathTemplate": "/{target}/{device}/preview/{stream}",
"DownstreamScheme": "ws",
"DownstreamHostAndPorts": [
{
"Host": "bw",
"Port": "80"
}
],
"UpstreamPathTemplate": "/bw/{target}/{device}/preview/{stream}",
"UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ]
},
{
"DownstreamPathTemplate": "/{url}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": "5027"
}
],
"UpstreamPathTemplate": "/zhonglian/{url}",
"UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ],
"Priority": 10
}
]
}

@ -0,0 +1,88 @@
using CommonModel;
using LanShengInterface;
using LanShengModel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace LanShengAPI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class DeviceController : ControllerBase
{
public DeviceController(IDeviceService deviceService, ITcpService tcpService)
{
TcpService = tcpService;
DeviceService = deviceService;
}
private readonly ITcpService TcpService;
private readonly IDeviceService DeviceService;
[HttpPost("PushParams")]
public async Task<ActionResult> PushParams(DeviceData deviceData)
{
try
{
await TcpService.PushParams(deviceData);
return Ok();
}
catch (BadRequestException ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("GetDeviceData")]
public async Task<ActionResult> GetDeviceData([FromQuery] string id)
{
try
{
return Ok(await DeviceService.GetDeviceData(id));
}
catch (BadRequestException ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("ResetRunCount")]
public async Task<ActionResult> ResetRunCount([FromQuery] string id) {
try
{
await DeviceService.ResetRunCount(id);
return Ok();
}
catch (BadRequestException ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost("GetDeviceDatas")]
public async Task<ActionResult> GetDeviceData(string[] ids) {
try
{
return Ok(await DeviceService.GetDeviceData(ids));
}
catch (BadRequestException ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost("GetDeviceError")]
public async Task<ActionResult> GetDeviceError(PageYearSearch<DeviceError> page)
{
try
{
return Ok(await DeviceService.GetDeviceErrorPage(page));
}
catch (BadRequestException ex)
{
return BadRequest(ex.Message);
}
}
}
}

@ -0,0 +1,29 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" >/etc/timezone
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["LanSheng/LanShengAPI/LanShengAPI.csproj", "LanSheng/LanShengAPI/"]
COPY ["LanSheng/LanShengService/LanShengService.csproj", "LanSheng/LanShengService/"]
COPY ["Cache/CacheService/CacheService.csproj", "Cache/CacheService/"]
COPY ["CommonExtend/CommonExtend.csproj", "CommonExtend/"]
COPY ["Cache/CacheInterface/CacheInterface.csproj", "Cache/CacheInterface/"]
COPY ["CommonModel/CommonModel.csproj", "CommonModel/"]
COPY ["LanSheng/LanShengInterface/LanShengInterface.csproj", "LanSheng/LanShengInterface/"]
COPY ["LanSheng/LanShengModel/LanShengModel.csproj", "LanSheng/LanShengModel/"]
RUN dotnet restore "LanSheng/LanShengAPI/LanShengAPI.csproj"
COPY . .
WORKDIR "/src/LanSheng/LanShengAPI"
RUN dotnet build "LanShengAPI.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "LanShengAPI.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "LanShengAPI.dll"]

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapr.Actors.AspNetCore" Version="1.9.0" />
<PackageReference Include="Dapr.AspNetCore" Version="1.9.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.13" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LanShengService\LanShengService.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,29 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using LanShengService;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers().AddNewtonsoftJson(options =>
{
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
}).AddDapr();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.InitLanShengService(builder.Configuration);
var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseStaticFiles();
app.MapControllers();
app.CreateLanShengService();
app.Run();

@ -0,0 +1,37 @@
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5048"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:53288",
"sslPort": 0
}
}
}

@ -0,0 +1,13 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore": "Warning"
}
},
"DotNetty": {
"Use": "Y",
"ThreadPool": 8,
"Port": 5888
}
}

@ -0,0 +1,18 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"Default": "Data Source=mysql;database=lsdb;User Id=root;Pwd=root;charset=utf8;pooling=true;"
},
"DotNetty": {
"Use": "Y",
"ThreadPool": 8,
"Port": 9001
},
"Redis": "redis:6379"
}

@ -0,0 +1,14 @@
using Dapr.Actors;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LanShengInterface
{
public interface IDeviceDataActor : IActor
{
Task StartTimer();
}
}

@ -0,0 +1,35 @@
using CommonModel;
using LanShengModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LanShengInterface
{
public interface IDeviceService
{
Task InsertData(DeviceData deviceData);
Task InsertDataDo();
Task TimerInsertDataDo();
Task InsertDataLog(TcpDataLog<DeviceData> dataLog);
Task InsertDataLogDo();
Task TimerInsertDataLogDo();
Task Offline(string id = "");
Task<DeviceData> GetDeviceData(string id);
Task<List<DeviceData>> GetDeviceData(string[] ids);
Task ResetRunCount(string id = "");
Task<PageData<DeviceError>> GetDeviceErrorPage(PageYearSearch<DeviceError> search);
}
}

@ -0,0 +1,14 @@
using Dapr.Actors;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LanShengInterface
{
public interface ITcpDataLogActor : IActor
{
Task StartTimer();
}
}

@ -0,0 +1,20 @@
using DotNetty.Transport.Channels;
using DotNetty.Transport.Channels.Groups;
using LanShengModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LanShengInterface
{
public interface ITcpService
{
Task AddChannel(string id, IChannelHandlerContext context);
Task PushParams(DeviceData deviceData);
Task RemoveMessageItem(TcpDataLog<DeviceData> packet);
}
}

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapr.Actors" Version="1.9.0" />
<PackageReference Include="DotNetty.Transport" Version="0.7.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CommonModel\CommonModel.csproj" />
<ProjectReference Include="..\LanShengModel\LanShengModel.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,23 @@
using DotNetty.Transport.Channels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LanShengModel
{
public class ChannelQueue
{
public ChannelQueue(IChannelId channelId,string dtu_id) {
ChannelId = channelId;
DTU_Id = dtu_id;
}
public readonly IChannelId ChannelId;
public readonly string DTU_Id;
public int MsgId = 0;
}
}

@ -0,0 +1,507 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LanShengModel
{
[SugarTable("LS_DeviceData")]
public class DeviceData
{
/// <summary>
/// 编号
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 50)]
public string? Id { get; set; }
/// <summary>
/// 设备状态
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? Status { get; set; }
/// <summary>
/// 故障代码
/// </summary>
[SugarColumn(Length = 20, IsNullable = true)]
public string? ErrCode { get; set; }
/// <summary>
/// 故障信息
/// </summary>
[SugarColumn(Length = 200, IsNullable = true)]
public string? ErrMsg { get; set; }
/// <summary>
/// 当前DTU的软件版本号
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Version { get; set; }
/// <summary>
/// 启动指示 (0未启动, 1已启动)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data2_B7 { get; set; }
/// <summary>
/// 电锁/IC卡 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data2_B6 { get; set; }
/// <summary>
/// 笼内急停 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data2_B5 { get; set; }
/// <summary>
/// 笼顶急停 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data2_B4 { get; set; }
/// <summary>
/// 防坠器限位 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data2_B3 { get; set; }
/// <summary>
/// 防冲顶限位 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data2_B2 { get; set; }
/// <summary>
/// 备用限位 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data2_B1 { get; set; }
/// <summary>
/// GPS限位 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data2_B0 { get; set; }
/// <summary>
/// 进料门限位 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data3_B7 { get; set; }
/// <summary>
/// 出料门限位 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data3_B6 { get; set; }
/// <summary>
/// 天窗门限位 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data3_B5 { get; set; }
/// <summary>
/// 上限位 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data3_B4 { get; set; }
/// <summary>
/// 下限位 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data3_B3 { get; set; }
/// <summary>
/// 上减速限位 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data3_B2 { get; set; }
/// <summary>
/// 下减速限位 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data3_B1 { get; set; }
/// <summary>
/// 抱闸状态 0动作 1未动作
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data3_B0 { get; set; }
/// <summary>
/// 一体机驱动故障
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data4 { get; set; }
/// <summary>
/// 一体机逻辑故障
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data5 { get; set; }
/// <summary>
/// 一体机电梯载重
/// </summary>
[SugarColumn(IsNullable = true)]
public decimal? Data6 { get; set; }
// <summary>
/// 一体机运行频率
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data7 { get; set; }
/// <summary>
/// 一体机输入电压
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data8 { get; set; }
/// <summary>
/// 一体机输出电流
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data10 { get; set; }
/// <summary>
/// 一体机当前楼层
/// </summary>
[SugarColumn(Length = 5, IsNullable = true)]
public int? Data11 { get; set; }
/// <summary>
/// 一体机目标楼层
/// </summary>
[SugarColumn(Length = 5, IsNullable = true)]
public int? Data12 { get; set; }
/// <summary>
/// 信道号
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data13 { get; set; }
/// <summary>
/// 一体机操作模式1智能模式2笼顶操作3防坠测试
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data14_B6 { get; set; }
/// <summary>
/// 一体机上升输入0断开1闭合
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data14_B5 { get; set; }
/// <summary>
/// 一体机下降输入0断开1闭合
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data14_B4 { get; set; }
/// <summary>
/// 一体机高速输入0断开1闭合
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data14_B3 { get; set; }
/// <summary>
/// 一体机上升输出0断开1闭合
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data14_B2 { get; set; }
/// <summary>
/// 一体机下降输出0断开1闭合
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data14_B1 { get; set; }
/// <summary>
/// 一体机高速输出0断开1闭合
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data14_B0 { get; set; }
/// <summary>
/// 一体机运行状态1上升2下降3停机
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data15_B6 { get; set; }
/// <summary>
/// 门机运行状态1上升2下降3停机
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data15_B4 { get; set; }
/// <summary>
/// 进料门上限位 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data15_B3 { get; set; }
/// <summary>
/// 进料门下限位 (0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data15_B2 { get; set; }
/// <summary>
/// 出料门上限位0断开1闭合
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data15_B1 { get; set; }
/// <summary>
/// 出料门下限位0断开1闭合
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data15_B0 { get; set; }
/// <summary>
/// 一体机通讯0异常1正常
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data16_B7 { get; set; }
/// <summary>
/// 门机通讯0异常1正常
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data16_B6 { get; set; }
/// <summary>
/// 左右笼通讯0异常1正常
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data16_B5 { get; set; }
/// <summary>
/// 人数摄像头通讯0异常1正常
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data16_B4 { get; set; }
/// <summary>
/// 门机控制 0无1进料门2出料门
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data16_B2 { get; set; }
/// <summary>
/// 进料门光幕(0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data16_B1 { get; set; }
/// <summary>
/// 出料门光幕(0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data16_B0 { get; set; }
/// <summary>
/// 门机故障代码
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data17 { get; set; }
/// <summary>
/// 门机控制0自动 1手动
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data18 { get; set; }
/// <summary>
/// 手动模式0点动 1开关到位
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data19 { get; set; }
/// <summary>
/// 检修开关0正常 1检修
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data20 { get; set; }
/// <summary>
/// 吊笼内人数
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data21 { get; set; }
/// <summary>
/// 语音码
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data22 { get; set; }
/// <summary>
/// 自动平层开关0关闭 1开启
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data23 { get; set; }
/// <summary>
/// 已学楼层数
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data24 { get; set; }
/// <summary>
/// 密码第一位
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data25_B4 { get; set; }
/// <summary>
/// 密码第二位
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data25_B0 { get; set; }
/// <summary>
/// 密码第三位
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data26_B4 { get; set; }
/// <summary>
/// 密码第四位
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data26_B0 { get; set; }
/// <summary>
/// 限速 (0不限速1限速)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data27_B7 { get; set; }
/// <summary>
/// 锁机 (0不锁机1锁机)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data27_B6 { get; set; }
/// <summary>
/// 故障复位 (0不复位1复位)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data27_B5 { get; set; }
/// <summary>
/// 超载清零 (0不清零1清零)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data27_B4 { get; set; }
/// <summary>
/// 载波修改 (0不修改1修改载波)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data27_B3 { get; set; }
/// <summary>
/// 预留
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data27_B2 { get; set; }
/// <summary>
/// 预留
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data27_B1 { get; set; }
/// <summary>
/// 修改完成标志0未完成1完成
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data27_B0 { get; set; }
/// <summary>
/// 协议版本号1 施工梯 2通用机 3塔机4揽胜升降机
/// </summary>
[SugarColumn(IsNullable = true)]
public int? AgreementVersion { get; set; }
/// <summary>
/// 上传数据的间隔时间每隔n秒,0XFFFF表示关闭定时上传
/// </summary>
[SugarColumn(IsNullable = true)]
public int? DataTick { get; set; }
/// <summary>
/// 全部为ASCII码字符需要记录下来上下线后都能显示上线后如和上一次不一致需做个图标标识出来
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? ICCID { get; set; }
/// <summary>
/// 东经
/// </summary>
[SugarColumn(IsNullable = true)]
public string? Longitude { get; set; }
/// <summary>
/// 北纬
/// </summary>
[SugarColumn(IsNullable = true)]
public string? Latitude { get; set; }
/// <summary>
/// 连接字符串长度
/// </summary>
[SugarColumn(IsNullable = true)]
public int? ConnectStrLength { get; set; }
/// <summary>
/// 连接字符串
/// </summary>
[SugarColumn(Length = 200, IsNullable = true)]
public string? ConnectString { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? UpdateDate { get; set; }
[SugarColumn(IsNullable = true)]
public DateTime? OfflineDate { get; set; }
/// <summary>
/// 修改标志1外围控制板执行修改0外围控制板不执行修改
/// </summary>
[SugarColumn(IsNullable = true)]
public int? UpdateTag { get; set; }
/// <summary>
/// IP是否修改,0:不修改,1:修改
/// </summary>
[SugarColumn(IsNullable = true)]
public int? IPSFXG { get; set; }
/// <summary>
/// 运行次数
/// </summary>
[SugarColumn(IsNullable = true,IsOnlyIgnoreInsert = true,DefaultValue = "0")]
public int? RunCount { get; set; }
#region 业务字段
[SugarColumn(IsIgnore = true)]
public string? MsgType { get; set; }
#endregion
}
}

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LanShengModel
{
public class DeviceData1001
{
public string? Status { get; set; }
public DateTime? UpdateDate { get; set; }
public int? AgreementVersion { get; set; }
public int? DataTick { get; set; }
public string? ICCID { get; set; }
public string? Longitude { get; set; }
public string? Latitude { get; set; }
public int? ConnectStrLength { get; set; }
public string? ConnectString { get; set; }
public static string[] GetColumns()
{
var Result = new List<string>();
var Type = typeof(DeviceData1001);
foreach (var Propety in Type.GetProperties())
{
Result.Add(Propety.Name);
}
return Result.ToArray();
}
}
}

@ -0,0 +1,372 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LanShengModel
{
public class DeviceData1103
{
public string? Status { get; set; }
/// <summary>
/// 故障代码
/// </summary>
[SugarColumn(Length = 20, IsNullable = true)]
public string? ErrCode { get; set; }
/// <summary>
/// 故障信息
/// </summary>
[SugarColumn(Length = 200, IsNullable = true)]
public string? ErrMsg { get; set; }
/// <summary>
/// 当前DTU的软件版本号
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Version { get; set; }
public DateTime? UpdateDate { get; set; }
/// <summary>
/// 启动指示 (0未启动, 1已启动)
/// </summary>
public int? Data2_B7 { get; set; }
/// <summary>
/// 电锁/IC卡 (0断开1闭合)
/// </summary>
public int? Data2_B6 { get; set; }
/// <summary>
/// 笼内急停 (0断开1闭合)
/// </summary>
public int? Data2_B5 { get; set; }
/// <summary>
/// 笼顶急停 (0断开1闭合)
/// </summary>
public int? Data2_B4 { get; set; }
/// <summary>
/// 防坠器限位 (0断开1闭合)
/// </summary>
public int? Data2_B3 { get; set; }
/// <summary>
/// 防冲顶限位 (0断开1闭合)
/// </summary>
public int? Data2_B2 { get; set; }
/// <summary>
/// 备用限位 (0断开1闭合)
/// </summary>
public int? Data2_B1 { get; set; }
/// <summary>
/// GPS限位 (0断开1闭合)
/// </summary>
public int? Data2_B0 { get; set; }
/// <summary>
/// 进料门限位 (0断开1闭合)
/// </summary>
public int? Data3_B7 { get; set; }
/// <summary>
/// 出料门限位 (0断开1闭合)
/// </summary>
public int? Data3_B6 { get; set; }
/// <summary>
/// 天窗门限位 (0断开1闭合)
/// </summary>
public int? Data3_B5 { get; set; }
/// <summary>
/// 上限位 (0断开1闭合)
/// </summary>
public int? Data3_B4 { get; set; }
/// <summary>
/// 下限位 (0断开1闭合)
/// </summary>
public int? Data3_B3 { get; set; }
/// <summary>
/// 上减速限位 (0断开1闭合)
/// </summary>
public int? Data3_B2 { get; set; }
/// <summary>
/// 下减速限位 (0断开1闭合)
/// </summary>
public int? Data3_B1 { get; set; }
/// <summary>
/// 抱闸状态 0动作 1未动作
/// </summary>
public int? Data3_B0 { get; set; }
/// <summary>
/// 一体机驱动故障
/// </summary>
public int? Data4 { get; set; }
/// <summary>
/// 一体机逻辑故障
/// </summary>
public int? Data5 { get; set; }
/// <summary>
/// 一体机电梯载重
/// </summary>
public decimal? Data6 { get; set; }
// <summary>
/// 一体机运行频率
/// </summary>
public int? Data7 { get; set; }
/// <summary>
/// 一体机输入电压
/// </summary>
public int? Data8 { get; set; }
/// <summary>
/// 一体机输出电流
/// </summary>
public int? Data10 { get; set; }
/// <summary>
/// 一体机当前楼层
/// </summary>
public int? Data11 { get; set; }
/// <summary>
/// 一体机目标楼层
/// </summary>
public int? Data12 { get; set; }
/// <summary>
/// 信道号
/// </summary>
public int? Data13 { get; set; }
/// <summary>
/// 一体机操作模式1智能模式2笼顶操作3防坠测试
/// </summary>
public int? Data14_B6 { get; set; }
/// <summary>
/// 一体机上升输入0断开1闭合
/// </summary>
public int? Data14_B5 { get; set; }
/// <summary>
/// 一体机下降输入0断开1闭合
/// </summary>
public int? Data14_B4 { get; set; }
/// <summary>
/// 一体机高速输入0断开1闭合
/// </summary>
public int? Data14_B3 { get; set; }
/// <summary>
/// 一体机上升输出0断开1闭合
/// </summary>
public int? Data14_B2 { get; set; }
/// <summary>
/// 一体机下降输出0断开1闭合
/// </summary>
public int? Data14_B1 { get; set; }
/// <summary>
/// 一体机高速输出0断开1闭合
/// </summary>
public int? Data14_B0 { get; set; }
/// <summary>
/// 一体机运行状态1上升2下降3停机
/// </summary>
public int? Data15_B6 { get; set; }
/// <summary>
/// 门机运行状态1上升2下降3停机
/// </summary>
public int? Data15_B4 { get; set; }
/// <summary>
/// 进料门上限位 (0断开1闭合)
/// </summary>
public int? Data15_B3 { get; set; }
/// <summary>
/// 进料门下限位 (0断开1闭合)
/// </summary>
public int? Data15_B2 { get; set; }
/// <summary>
/// 出料门上限位0断开1闭合
/// </summary>
public int? Data15_B1 { get; set; }
/// <summary>
/// 出料门下限位0断开1闭合
/// </summary>
public int? Data15_B0 { get; set; }
/// <summary>
/// 一体机通讯0异常1正常
/// </summary>
public int? Data16_B7 { get; set; }
/// <summary>
/// 门机通讯0异常1正常
/// </summary>
public int? Data16_B6 { get; set; }
/// <summary>
/// 左右笼通讯0异常1正常
/// </summary>
public int? Data16_B5 { get; set; }
/// <summary>
/// 人数摄像头通讯0异常1正常
/// </summary>
public int? Data16_B4 { get; set; }
/// <summary>
/// 门机控制 0无1进料门2出料门
/// </summary>
public int? Data16_B2 { get; set; }
/// <summary>
/// 进料门光幕(0断开1闭合)
/// </summary>
public int? Data16_B1 { get; set; }
/// <summary>
/// 出料门光幕(0断开1闭合)
/// </summary>
public int? Data16_B0 { get; set; }
/// <summary>
/// 门机故障代码
/// </summary>
public int? Data17 { get; set; }
/// <summary>
/// 门机控制0自动 1手动
/// </summary>
public int? Data18 { get; set; }
/// <summary>
/// 手动模式0点动 1开关到位
/// </summary>
public int? Data19 { get; set; }
/// <summary>
/// 检修开关0正常 1检修
/// </summary>
public int? Data20 { get; set; }
/// <summary>
/// 吊笼内人数
/// </summary>
public int? Data21 { get; set; }
/// <summary>
/// 语音码
/// </summary>
public int? Data22 { get; set; }
/// <summary>
/// 自动平层开关0关闭 1开启
/// </summary>
public int? Data23 { get; set; }
/// <summary>
/// 已学楼层数
/// </summary>
public int? Data24 { get; set; }
/// <summary>
/// 密码第一位
/// </summary>
public int? Data25_B4 { get; set; }
/// <summary>
/// 密码第二位
/// </summary>
public int? Data25_B0 { get; set; }
/// <summary>
/// 密码第三位
/// </summary>
public int? Data26_B4 { get; set; }
/// <summary>
/// 密码第四位
/// </summary>
public int? Data26_B0 { get; set; }
/// <summary>
/// 限速 (0不限速1限速)
/// </summary>
public int? Data27_B7 { get; set; }
/// <summary>
/// 锁机 (0不锁机1锁机)
/// </summary>
public int? Data27_B6 { get; set; }
/// <summary>
/// 故障复位 (0不复位1复位)
/// </summary>
public int? Data27_B5 { get; set; }
/// <summary>
/// 超载清零 (0不清零1清零)
/// </summary>
public int? Data27_B4 { get; set; }
/// <summary>
/// 载波修改 (0不修改1修改载波)
/// </summary>
public int? Data27_B3 { get; set; }
/// <summary>
/// 预留
/// </summary>
public int? Data27_B2 { get; set; }
/// <summary>
/// 预留
/// </summary>
public int? Data27_B1 { get; set; }
/// <summary>
/// 修改完成标志0未完成1完成
/// </summary>
public int? Data27_B0 { get; set; }
public static string[] GetColumns()
{
var Result = new List<string>();
var Type = typeof(DeviceData1103);
foreach (var Propety in Type.GetProperties())
{
Result.Add(Propety.Name);
}
return Result.ToArray();
}
}
}

@ -0,0 +1,48 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LanShengModel
{
[SugarTable("LS_DeviceError_{year}{month}{day}")]
[SplitTable(SplitType.Year)]
public class DeviceError
{
/// <summary>
/// 编号
/// </summary>
[SugarColumn(IsPrimaryKey = true,Length = 50,ColumnDescription = "编号")]
public string? Id { get; set; }
/// <summary>
/// 设备编号
/// </summary>
[SugarColumn(IsPrimaryKey = true,Length = 50,ColumnDescription = "设备编号")]
public string? DeviceId { get; set; }
/// <summary>
/// 错误代码
/// </summary>
[SugarColumn(IsNullable = true,ColumnDescription = "错误代码",Length = 20)]
public string? ErrCode { get; set; }
/// <summary>
/// 错误信息
/// </summary>
[SugarColumn(IsNullable = true,ColumnDescription = "错误信息",Length = 200)]
public string? ErrMsg { get; set; }
/// <summary>
/// 结束日期
/// </summary>
[SugarColumn(IsNullable = true,ColumnDescription = "结束日期")]
public DateTime? EndDate { get; set; }
[SplitField]
[SugarColumn(IsNullable = true)]
public DateTime? CreateDate { get; set; }
}
}

@ -0,0 +1,45 @@
/// <summary>
/// 设备故障报表
/// </summary>
public class DeviceErrorReport
{
/// <summary>
/// 故障类型
/// </summary>
public IEnumerable<string>? ErrCodes { get; set; }
/// <summary>
/// 公司编号
/// </summary>
public IEnumerable<string>? CompanyIds { get; set; }
/// <summary>
/// 项目编号
/// </summary>
public IEnumerable<string>? ProjectIds { get; set; }
/// <summary>
/// 设备编号
/// </summary>
public IEnumerable<string>? DeviceIds { get; set; }
/// <summary>
/// 开始日期
/// </summary>
public DateTime? StartDate { get; set; }
/// <summary>
/// 结束日期
/// </summary>
public DateTime? EndDate { get; set; }
/// <summary>
/// 单元
/// </summary>
public string? Unit { get; set; }
/// <summary>
/// 数据集
/// </summary>
public Dictionary<string, int>? Items { get; set; }
}

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DotNetty.Transport" Version="0.7.5" />
<PackageReference Include="SqlSugarCore" Version="5.1.3.50" />
</ItemGroup>
</Project>

@ -0,0 +1,74 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LanShengModel
{
[SugarTable("LS_TcpDataLog_{year}{month}{day}")]
[SplitTable(SplitType.Day)]
public class TcpDataLog
{
[SugarColumn(IsNullable = true, Length = 10)]
public string? Frame_START { get; set; }
[SugarColumn(IsNullable = true, Length = 10)]
public int? Frame_Length { get; set; }
[SugarColumn(IsNullable = true, Length = 10)]
public int? Frame_number { get; set; }
[SugarColumn(IsNullable = true, Length = 200)]
public string? DTU_ID { get; set; }
[SugarColumn(IsNullable = true, Length = 10)]
public string? Msg_ID { get; set; }
[SugarColumn(IsNullable = true, Length = 10)]
public int? Checksum { get; set; }
[SugarColumn(IsNullable = true, Length = 10)]
public string? Frame_END { get; set; }
[SplitField]
[SugarColumn(IsNullable = true)]
public DateTime? CreateDate { get; set; }
}
[SugarTable("LS_TcpDataLog_{year}{month}{day}")]
[SplitTable(SplitType.Day)]
public class TcpDataLog<T>
{
[SugarColumn(IsNullable = true, Length = 10)]
public string? Frame_START { get; set; }
[SugarColumn(IsNullable = true, Length = 10)]
public int? Frame_Length { get; set; }
[SugarColumn(IsNullable = true, Length = 10)]
public int? Frame_number { get; set; }
[SugarColumn(IsNullable = true, Length = 200)]
public string? DTU_ID { get; set; }
[SugarColumn(IsNullable = true, Length = 10)]
public string? Msg_ID { get; set; }
[SugarColumn(IsNullable = true, IsJson = true, ColumnDataType = "Text")]
public T? Content { get; set; }
[SugarColumn(IsNullable = true, Length = 10)]
public int? Checksum { get; set; }
[SugarColumn(IsNullable = true, Length = 10)]
public string? Frame_END { get; set; }
[SplitField]
[SugarColumn(IsNullable = true)]
public DateTime? CreateDate { get; set; }
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,52 @@
using CacheService;
using CommonExtend;
using Dapr.Client;
using LanShengInterface;
using LanShengService.Tcp;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LanShengService
{
public static class LanShengServiceExtend
{
public static IServiceCollection InitLanShengService(this IServiceCollection services, IConfiguration configuration)
{
SqlSugarScope sqlSugar = new SqlSugarScope(new ConnectionConfig()
{
DbType = SqlSugar.DbType.MySql,
ConnectionString = configuration.GetConnectionString("Default"),
IsAutoCloseConnection = true,
});
services.AddSingleton<ISqlSugarClient>(sqlSugar);
services.AddSingleton<ITcpService, TcpService>();
services.AddSingleton<IDeviceService, DeviceService>();
services.InitMemoryCacheService();
return services;
}
public static IApplicationBuilder CreateLanShengService(this IApplicationBuilder app)
{
Task.Run(() =>
{
app.ApplicationServices.GetRequiredService<ITcpService>();
});
return app;
}
}
public class LanShengService
{
}
}

@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ServerGarbageCollection>false</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapr.Actors.AspNetCore" Version="1.9.0" />
<PackageReference Include="DotNetty.Buffers" Version="0.7.5" />
<PackageReference Include="DotNetty.Codecs" Version="0.7.5" />
<PackageReference Include="DotNetty.Common" Version="0.7.5" />
<PackageReference Include="DotNetty.Handlers" Version="0.7.5" />
<PackageReference Include="DotNetty.Transport" Version="0.7.5" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.3.50" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Cache\CacheService\CacheService.csproj" />
<ProjectReference Include="..\..\CommonExtend\CommonExtend.csproj" />
<ProjectReference Include="..\..\CommonModel\CommonModel.csproj" />
<ProjectReference Include="..\LanShengInterface\LanShengInterface.csproj" />
<ProjectReference Include="..\LanShengModel\LanShengModel.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,119 @@
using CommonModel;
using DotNetty.Transport.Channels;
using DotNetty.Transport.Channels.Groups;
using Google.Api;
using LanShengInterface;
using LanShengModel;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace LanShengService.Tcp
{
public class ChannelHandler : ChannelHandlerAdapter
{
public ChannelHandler(IServiceProvider services)
{
Services = services;
Logger = Services.GetRequiredService<ILogger<ChannelHandler>>();
DeviceService = Services.GetRequiredService<IDeviceService>();
TcpService = Services.GetRequiredService<ITcpService>();
}
private readonly IServiceProvider Services;
private readonly IDeviceService DeviceService;
private readonly ILogger Logger;
private readonly ITcpService TcpService;
private int TryCount = 0;
private string DTU_Id = "";
public override async void ChannelRead(IChannelHandlerContext context, object message)
{
var packet = message as TcpDataLog<DeviceData>;
DTU_Id = packet!.DTU_ID!;
Logger.LogDebug($"接收到数据:{JsonSerializer.Serialize<TcpDataLog<DeviceData>>(packet!)}");
await TcpService.AddChannel(packet!.DTU_ID!, context);
await DeviceService.InsertDataLog(packet!);
if (packet!.Content != null)
{
await DeviceService.InsertData(packet!.Content);
}
if (packet.Msg_ID == "1001" || packet.Msg_ID == "1103")
{
var Reply = new TcpDataLog<DeviceData>
{
Frame_START = packet.Frame_START,
Frame_number = packet.Frame_number,
DTU_ID = packet.DTU_ID,
Frame_END = packet.Frame_END
};
if (packet.Msg_ID == "1001")
{
Reply.Msg_ID = "9001";
}
if (packet.Msg_ID == "1103")
{
Reply.Msg_ID = "9103";
}
try
{
await context.WriteAndFlushAsync(Reply);
}
catch
{
await context.CloseAsync();
}
}
if (packet.Msg_ID == "9104")
{
await TcpService.RemoveMessageItem(packet);
}
TryCount = 0;
}
public override void ChannelReadComplete(IChannelHandlerContext context)
{
context.Flush();
}
public override void ExceptionCaught(IChannelHandlerContext context, Exception exception)
{
TryCount++;
Logger.LogError(exception.ToString());
if (TryCount >= 5)
{
context.CloseAsync();
}
}
public override async void ChannelActive(IChannelHandlerContext context)
{
await TcpService.AddChannel("all", context);
base.ChannelActive(context);
}
public override async void ChannelInactive(IChannelHandlerContext context)
{
if (!string.IsNullOrEmpty(DTU_Id))
{
await DeviceService.Offline(DTU_Id);
}
await context.CloseAsync();
base.ChannelInactive(context);
}
}
}

@ -0,0 +1,178 @@
using DotNetty.Buffers;
using DotNetty.Codecs;
using DotNetty.Transport.Channels;
using LanShengModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CommonExtend;
using CommonModel;
namespace LanShengService.Tcp
{
public class DecoderHandler : ByteToMessageDecoder
{
protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List<object> output)
{
var request = new TcpDataLog<DeviceData>();
if (!input.HasArray)
{
return;
}
while (input.ReadableBytes >= 2)
{
if (input.ReadHex(1) == "FA")
{
if (input.ReadHex(1) == "AA")
{
request.Frame_START = "FAAA";
break;
}
else
{
input.SetReaderIndex(input.ReaderIndex - 1);
}
}
}
if (request.Frame_START != "FAAA")
{
return;
}
int ReadableBytes = input.ReadableBytes + 2;
if (ReadableBytes < 4)
{
input.SetReaderIndex(input.ReaderIndex - 2);
return;
}
request.Frame_Length = input.ReadInt(2);
if (ReadableBytes < request.Frame_Length)
{
input.ResetReaderIndex();
return;
}
request.Frame_number = input.ReadInt(2);
request.DTU_ID = input.ReadString(17, Encoding.ASCII);
request.Msg_ID = input.ReadHex(2);
IByteBuffer Content = Unpooled.Buffer((int)request.Frame_Length - 25 - 4);
input.ReadBytes(Content, (int)request.Frame_Length - 25 - 4);
try
{
request.Content = new DeviceData();
request.Content.Id = request.DTU_ID;
request.Content.Status = "online";
request.Content.UpdateDate = DateTime.Now;
request.Content.MsgType = request.Msg_ID;
switch (request.Msg_ID)
{
case "1001":
case "9104":
request.Content.AgreementVersion = Content.ReadInt(1);
request.Content.DataTick = Content.ReadInt(2);
request.Content.ICCID = Content.ReadString(20, Encoding.ASCII);
Content.SkipBytes(4);
request.Content.Longitude = Content.ReadString(9, Encoding.ASCII);
request.Content.Latitude = Content.ReadString(8, Encoding.ASCII);
request.Content.ConnectStrLength = Content.ReadInt(1);
request.Content.ConnectString = Content.ReadString((int)request.Content.ConnectStrLength, Encoding.ASCII);
break;
case "1103":
request.Content.Version = Content.ReadInt(1);
var Data2 = Content.ReadBitArray();
request.Content.Data2_B7 = Data2[0];
request.Content.Data2_B6 = Data2[1];
request.Content.Data2_B5 = Data2[2];
request.Content.Data2_B4 = Data2[3];
request.Content.Data2_B3 = Data2[4];
request.Content.Data2_B2 = Data2[5];
request.Content.Data2_B1 = Data2[6];
request.Content.Data2_B0 = Data2[7];
var Data3 = Content.ReadBitArray();
request.Content.Data3_B7 = Data3[0];
request.Content.Data3_B6 = Data3[1];
request.Content.Data3_B5 = Data3[2];
request.Content.Data3_B4 = Data3[3];
request.Content.Data3_B3 = Data3[4];
request.Content.Data3_B2 = Data3[5];
request.Content.Data3_B1 = Data3[6];
request.Content.Data3_B0 = Data3[7];
request.Content.Data4 = Content.ReadInt(1);
request.Content.Data5 = Content.ReadInt(1);
request.Content.Data6 = Content.ReadInt(1);
request.Content.Data7 = Content.ReadInt(1);
request.Content.Data8 = Content.ReadInt(2);
request.Content.Data10 = Content.ReadInt(1);
request.Content.Data11 = Content.ReadInt(1);
request.Content.Data12 = Content.ReadInt(1);
request.Content.Data13 = Content.ReadInt(1);
var Data14 = Content.ReadBitArray();
request.Content.Data14_B6 = Convert.ToInt32($"{Data14[1]}{Data14[0]}", 2);
request.Content.Data14_B5 = Data14[2];
request.Content.Data14_B4 = Data14[3];
request.Content.Data14_B3 = Data14[4];
request.Content.Data14_B2 = Data14[5];
request.Content.Data14_B1 = Data14[6];
request.Content.Data14_B0 = Data14[7];
var Data15 = Content.ReadBitArray();
request.Content.Data15_B6 = Convert.ToInt32($"{Data15[1]}{Data15[0]}", 2);
request.Content.Data15_B4 = Convert.ToInt32($"{Data15[3]}{Data15[2]}", 2);
request.Content.Data15_B3 = Data15[4];
request.Content.Data15_B2 = Data15[5];
request.Content.Data15_B1 = Data15[6];
request.Content.Data15_B0 = Data15[7];
var Data16 = Content.ReadBitArray();
request.Content.Data16_B7 = Data16[0];
request.Content.Data16_B6 = Data16[1];
request.Content.Data16_B5 = Data16[2];
request.Content.Data16_B4 = Data16[3];
request.Content.Data16_B2 = Convert.ToInt32($"{Data16[5]}{Data16[4]}", 2);
request.Content.Data16_B1 = Data16[6];
request.Content.Data16_B0 = Data16[7];
request.Content.Data17 = Content.ReadInt(1);
request.Content.Data18 = Content.ReadInt(1);
request.Content.Data19 = Content.ReadInt(1);
request.Content.Data20 = Content.ReadInt(1);
request.Content.Data21 = Content.ReadInt(1);
request.Content.Data22 = Content.ReadInt(1);
request.Content.Data23 = Content.ReadInt(1);
request.Content.Data24 = Content.ReadInt(1);
var Data25 = Content.ReadBitArray();
request.Content.Data25_B4 = Convert.ToInt32($"{Data25[3]}{Data25[2]}{Data25[1]}{Data25[0]}", 2);
request.Content.Data25_B0 = Convert.ToInt32($"{Data25[7]}{Data25[6]}{Data25[5]}{Data25[4]}", 2);
var Data26 = Content.ReadBitArray();
request.Content.Data26_B4 = Convert.ToInt32($"{Data26[3]}{Data26[2]}{Data26[1]}{Data26[0]}", 2);
request.Content.Data26_B0 = Convert.ToInt32($"{Data26[7]}{Data26[6]}{Data26[5]}{Data26[4]}", 2);
var Data27 = Content.ReadBitArray();
request.Content.Data27_B7 = Data27[0];
request.Content.Data27_B6 = Data27[1];
request.Content.Data27_B5 = Data27[2];
request.Content.Data27_B4 = Data27[3];
request.Content.Data27_B3 = Data27[4];
request.Content.Data27_B0 = Data27[7];
break;
default:
break;
}
request.Content = request.Content;
}
catch
{
request.Content = null;
}
request.Checksum = input.ReadInt(2);
request.Frame_END = input.ReadHex(2);
request.CreateDate = DateTime.Now;
if (request.Frame_END == "BBFB")
{
output.Add(request);
Content.Clear();
input.Clear();
}
else
{
return;
}
}
}
}

@ -0,0 +1,72 @@
using CommonExtend;
using CommonModel;
using DotNetty.Buffers;
using DotNetty.Codecs;
using DotNetty.Transport.Channels;
using LanShengModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LanShengService.Tcp
{
public class EncoderHandler : MessageToByteEncoder<TcpDataLog<DeviceData>>
{
protected override void Encode(IChannelHandlerContext context, TcpDataLog<DeviceData> message, IByteBuffer output)
{
List<byte> Temp = new List<byte>();
Temp.AddRange(message.Frame_START!.HexString2Byte().BytePadLeft(2));
Temp.AddRange(((int)message.Frame_number!).Int2Byte().BytePadLeft(2));
Temp.AddRange(Encoding.ASCII.GetBytes(message.DTU_ID!).BytePadLeft(17));
Temp.AddRange(message.Msg_ID!.HexString2Byte().BytePadLeft(2));
switch (message.Msg_ID)
{
case "1104":
Temp.AddRange(((int)message.Content!.Version!).Int2Byte().BytePadLeft(1));
Temp.AddRange(((int)message.Content!.DataTick!).Int2Byte().BytePadLeft(2));
int[] Data1 = new int[] {
(int)message.Content!.Data27_B7!,
(int)message.Content!.Data27_B6!,
(int)message.Content!.Data27_B5!,
(int)message.Content!.Data27_B4!,
(int)message.Content!.Data27_B3!,
0,
0,
(int)message.Content!.Data27_B0!,
};
Temp.AddRange(Data1.BitArray2Byte());
int[] Data2 = new int[] {
(int)message.Content!.Data23!,
(int)message.Content!.Data20!,
(int)message.Content!.Data19!,
(int)message.Content!.Data18!,
((int)message.Content!.Data16_B2!).Int2Bit(2)[1],
((int)message.Content!.Data16_B2!).Int2Bit(2)[0],
0,
0
};
Temp.AddRange(Data2.BitArray2Byte());
Temp.AddRange(((int)message.Content.Data25_B4!).Int2Byte().BytePadLeft(1));
Temp.AddRange(((int)message.Content.Data25_B0!).Int2Byte().BytePadLeft(1));
Temp.AddRange(((int)message.Content.Data26_B4!).Int2Byte().BytePadLeft(1));
Temp.AddRange(((int)message.Content.Data26_B0!).Int2Byte().BytePadLeft(1));
Temp.AddRange(((int)message.Content.UpdateTag!).Int2Byte().BytePadLeft(1));
var ConnectByte = Encoding.ASCII.GetBytes(message.Content.ConnectString!);
message.Content.ConnectStrLength = message.Content.ConnectString!.Length;
Temp.AddRange(((int)message.Content.ConnectStrLength!).Int2Byte().BytePadLeft(1));
Temp.AddRange(ConnectByte);
break;
default:
break;
}
message.Frame_Length = Temp.Count + 6;
Temp.InsertRange(2, ((int)message.Frame_Length!).Int2Byte().BytePadLeft(2));
message.Checksum = Temp.ToArray().Byte2HexSum();
Temp.AddRange(((int)message.Checksum!).Int2Byte().BytePadLeft(2));
Temp.AddRange(message.Frame_END!.HexString2Byte().BytePadLeft(2));
output.WriteBytes(Temp.ToArray());
}
}
}

@ -0,0 +1,40 @@
using DotNetty.Handlers.Timeout;
using DotNetty.Transport.Channels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LanShengService.Tcp
{
public class HeartBeatHandler : ChannelHandlerAdapter
{
/// <summary>
/// Heart Beat Handler.
/// </summary>
/// <param name="context"></param>
/// <param name="evt"></param>
public override async void UserEventTriggered(IChannelHandlerContext context, object evt)
{
var eventState = evt as IdleStateEvent;
if (eventState != null)
{
if (eventState.State == IdleState.ReaderIdle)
{
await context.CloseAsync();
}
else if (eventState.State == IdleState.WriterIdle)
{
}
else if (eventState.State == IdleState.AllIdle)
{
}
}
else
{
base.UserEventTriggered(context, evt);
}
}
}
}

@ -0,0 +1,340 @@
using Dapr.Actors.Client;
using Dapr.Actors;
using DotNetty.Buffers;
using DotNetty.Handlers.Logging;
using DotNetty.Handlers.Tls;
using DotNetty.Transport.Bootstrapping;
using DotNetty.Transport.Channels;
using DotNetty.Transport.Channels.Sockets;
using LanShengInterface;
using LanShengModel;
using LanShengService.Tcp;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.Json;
using System.Data;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using Dapr.Client;
using DotNetty.Transport.Channels.Groups;
using CommonModel;
using DotNetty.Handlers.Timeout;
using System.Diagnostics;
namespace LanShengService
{
public class TcpService : ITcpService
{
public TcpService(IServiceProvider services)
{
Services = services;
Logger = services.GetRequiredService<ILogger<TcpService>>();
Logger.LogDebug("创建Tcp服务");
DeviceService = services.GetRequiredService<IDeviceService>();
Db = services.GetRequiredService<ISqlSugarClient>();
Db.CodeFirst.SplitTables().InitTables(typeof(TcpDataLog<DeviceData>));
Logger.LogDebug("加载Tcp服务数据结构");
IConfiguration configuration = services.GetRequiredService<IConfiguration>()!;
if (configuration.GetSection("DotNetty").Exists())
{
if (configuration.GetSection("DotNetty:Use").Exists())
{
Use = configuration.GetSection("DotNetty:Use").Value!;
}
if (configuration.GetSection("DotNetty:ThreadPool").Exists())
{
ThreadPool = Convert.ToInt32(configuration.GetSection("DotNetty:ThreadPool").Value!);
}
if (configuration.GetSection("DotNetty:Port").Exists())
{
Port = Convert.ToInt32(configuration.GetSection("DotNetty:Port").Value!);
}
Logger.LogDebug("加载Tcp服务参数");
}
OpenTcpPort();
}
private readonly IServiceProvider Services;
private readonly ILogger Logger;
private readonly string Use = "N";
private readonly int ThreadPool = 1;
private readonly int Port = 8888;
private readonly ISqlSugarClient Db;
private readonly IDeviceService DeviceService;
private ServerBootstrap? Bootstrap;
private IEventLoopGroup? BossGroup;
private IEventLoopGroup? WorkerGroup;
private Dictionary<string, IChannelGroup>? ChannelGroups;
private List<TcpDataLog<DeviceData>>? MessageQueue;
private async Task OpenTcpPort()
{
if (Use == "Y")
{
ChannelGroups = new Dictionary<string, IChannelGroup>();
MessageQueue = new List<TcpDataLog<DeviceData>>();
Bootstrap = new ServerBootstrap();
BossGroup = new MultithreadEventLoopGroup(ThreadPool);
WorkerGroup = new MultithreadEventLoopGroup();
Logger.LogDebug("加载Tcp端口参数");
Bootstrap!.Group(BossGroup, WorkerGroup);
Bootstrap.Channel<TcpServerSocketChannel>();
Bootstrap
.Option(ChannelOption.SoBacklog, 1024)
.Option(ChannelOption.Allocator, UnpooledByteBufferAllocator.Default)
.Option(ChannelOption.RcvbufAllocator,new AdaptiveRecvByteBufAllocator())
.ChildOption(ChannelOption.Allocator, UnpooledByteBufferAllocator.Default)
.ChildOption(ChannelOption.RcvbufAllocator, new AdaptiveRecvByteBufAllocator())
.ChildOption(ChannelOption.SoKeepalive, true)
.ChildOption(ChannelOption.TcpNodelay, true)
.ChildOption(ChannelOption.SoReuseport, true)
.ChildHandler(new ActionChannelInitializer<IChannel>(channel =>
{
IChannelPipeline Pipeline = channel.Pipeline;
Pipeline.AddLast(new IdleStateHandler(10, 0, 0));//心跳
Pipeline.AddLast("encoder", new EncoderHandler());
Pipeline.AddLast("decoder", new DecoderHandler());
Pipeline.AddLast(new HeartBeatHandler());
Pipeline.AddLast(new ChannelHandler(Services));
}));
await Bootstrap.BindAsync(Port);
Logger.LogInformation($"启动Tcp端口监听{Port}");
DeviceService.TimerInsertDataDo();
DeviceService.TimerInsertDataLogDo();
AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
}
}
private void CurrentDomain_ProcessExit(object? sender, EventArgs e)
{
Logger.LogDebug("程序关闭");
if (Use == "Y")
{
Task.WaitAll(
BossGroup!.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(0), TimeSpan.FromSeconds(0)),
WorkerGroup!.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(0), TimeSpan.FromSeconds(0)));
}
DeviceService.Offline().Wait();
}
public Task AddChannel(string id, IChannelHandlerContext context)
{
if (!ChannelGroups!.ContainsKey(id))
{
lock (this)
{
if (!ChannelGroups!.ContainsKey(id))
{
ChannelGroups.Add(id, new DefaultChannelGroup(context.Executor));
}
}
}
if (!ChannelGroups[id].Contains(context.Channel))
{
lock (this)
{
if (!ChannelGroups[id].Contains(context.Channel))
{
ChannelGroups[id].Add(context.Channel);
Logger.LogDebug($"添加通道{id}:{context.Channel.Id.AsLongText()}");
}
}
}
return Task.CompletedTask;
}
public async Task PushParams(DeviceData deviceData)
{
Logger.LogDebug($"下发指令{JsonSerializer.Serialize(deviceData)}");
if (ChannelGroups == null)
{
throw new BadRequestException("连接服务器失败");
}
else
{
if (!ChannelGroups.ContainsKey(deviceData.Id!))
{
throw new BadRequestException("设备不在线");
}
else
{
await ReloadPush(deviceData);
Random random = new Random();
var Frame_number = 0;
do
{
Frame_number = random.Next(0, 20);
}
while (MessageQueue!.Any(x => x.DTU_ID == deviceData.Id && x.Frame_number == Frame_number));
TcpDataLog<DeviceData> packet = new TcpDataLog<DeviceData>()
{
Frame_START = "FAAA",
Frame_number = Frame_number,
DTU_ID = deviceData.Id,
Msg_ID = "1104",
Frame_END = "BBFB",
Content = deviceData
};
try
{
MessageQueue!.Add(packet);
await ChannelGroups[packet.DTU_ID!].WriteAndFlushAsync(packet);
}
catch
{
MessageQueue!.Remove(packet);
throw new BadRequestException("发送指令失败");
}
await WaitPushReply(packet);
}
}
}
private Task ReloadPush(DeviceData deviceData)
{
var oldData = Db.Queryable<DeviceData>().Where(x => x.Id == deviceData.Id).First();
if (deviceData.Version == null)
{
deviceData.Version = oldData.Version;
}
if (deviceData.DataTick == null)
{
deviceData.DataTick = oldData.DataTick;
}
if (deviceData.Data27_B7 == null)
{
deviceData.Data27_B7 = oldData.Data27_B7;
}
if (deviceData.Data27_B6 == null)
{
deviceData.Data27_B6 = oldData.Data27_B6;
}
if (deviceData.Data27_B5 == null)
{
deviceData.Data27_B5 = oldData.Data27_B5;
}
if (deviceData.Data27_B4 == null)
{
deviceData.Data27_B4 = oldData.Data27_B4;
}
if (deviceData.Data27_B3 == null)
{
deviceData.Data27_B3 = oldData.Data27_B3;
}
if (deviceData.ConnectString != null && deviceData.ConnectString != oldData.ConnectString)
{
deviceData.Data27_B0 = 1;
}
else
{
deviceData.Data27_B0 = 0;
}
if (deviceData.Data23 == null)
{
deviceData.Data23 = oldData.Data23;
}
if (deviceData.Data20 == null)
{
deviceData.Data20 = oldData.Data20;
}
if (deviceData.Data19 == null)
{
deviceData.Data19 = oldData.Data19;
}
if (deviceData.Data18 == null)
{
deviceData.Data18 = oldData.Data18;
}
if (deviceData.Data16_B2 == null)
{
deviceData.Data16_B2 = oldData.Data16_B2;
}
if (deviceData.Data25_B4 == null)
{
deviceData.Data25_B4 = oldData.Data25_B4;
}
if (deviceData.Data25_B0 == null)
{
deviceData.Data25_B0 = oldData.Data25_B0;
}
if (deviceData.Data26_B4 == null)
{
deviceData.Data26_B4 = oldData.Data26_B4;
}
if (deviceData.Data26_B0 == null)
{
deviceData.Data26_B0 = oldData.Data26_B0;
}
if (deviceData.UpdateTag == null)
{
deviceData.UpdateTag = 0;
}
if (deviceData.ConnectString == null)
{
deviceData.ConnectString = oldData.ConnectString;
}
return Task.CompletedTask;
}
private Task WaitPushReply(TcpDataLog<DeviceData> packet)
{
var tryCount = 20;
while (MessageQueue!.Any((x => x.DTU_ID == packet.DTU_ID && x.Frame_number == packet.Frame_number)))
{
if (tryCount <= 0)
{
MessageQueue!.Remove(packet);
throw new BadRequestException("设备应答超时");
}
Thread.Sleep(500);
tryCount--;
}
return Task.CompletedTask;
}
public Task RemoveMessageItem(TcpDataLog<DeviceData> packet)
{
Logger.LogDebug($"删除消息{JsonSerializer.Serialize(packet)}");
MessageQueue!.RemoveAll((x) => x.DTU_ID == packet.DTU_ID && x.Frame_number == packet.Frame_number);
return Task.CompletedTask;
}
}
}

@ -0,0 +1 @@
# FYCore

@ -0,0 +1,71 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ZhongLianInterface;
using ZhongLianModel;
using ZhongLianService;
namespace ZhongLianAPI.Controllers
{
/// <summary>
/// 文件接口
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class DriveController : ControllerBase
{
public DriveController(IDriveService driveService)
{
DriveService = driveService;
}
private readonly IDriveService DriveService;
/// <summary>
/// 上传文件
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
[DisableRequestSizeLimit]
[HttpPost("upload")]
public async Task<ActionResult> Upload(IFormFile file)
{
if (file == null)
{
return BadRequest("上传失败");
}
var File = new FileDO();
File.FileName = file.FileName;
File.ContentType = file.ContentType;
File.Data = new byte[file.Length];
file.OpenReadStream().Read(File.Data, 0, (int)file.Length);
var Msg = DriveService.InsertCheck(File);
if (string.IsNullOrEmpty(Msg))
{
return Ok(await DriveService.Insert(File));
}
else
{
return BadRequest(Msg);
}
}
/// <summary>
/// 获取文件
/// </summary>
/// <param name="id">编号</param>
/// <returns></returns>
[HttpGet("get")]
public async Task<ActionResult> Get([FromQuery] string id)
{
var FileItem = await DriveService.Get(id);
if (FileItem != null)
{
return File(FileItem.Data!, FileItem.ContentType!);
}
else
{
return BadRequest("下载失败");
}
}
}
}

@ -0,0 +1,107 @@
using CommonModel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ZhongLianInterface;
using ZhongLianModel;
using ZhongLianService;
namespace ZhongLianAPI.Controllers
{
/// <summary>
/// 安装单接口
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class InstallController : ControllerBase
{
public InstallController(IInstallService installService)
{
InstallService = installService;
}
private readonly IInstallService InstallService;
/// <summary>
/// 创建安装单
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
[HttpPost("insert")]
public async Task<ActionResult> Insert(InstallDO install)
{
var _CheckMSG = InstallService.InsertCheck(install);
if (string.IsNullOrEmpty(_CheckMSG))
{
return Ok(await InstallService.Insert(install));
}
else
{
return BadRequest(_CheckMSG);
}
}
/// <summary>
/// 更新安装单
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
[HttpPost("update")]
public async Task<ActionResult> Update(InstallDO install)
{
var _CheckMSG = InstallService.UpdateCheck(install);
if (string.IsNullOrEmpty(_CheckMSG))
{
return Ok(await InstallService.Update(install));
}
else
{
return BadRequest(_CheckMSG);
}
}
/// <summary>
/// 删除安装单
/// </summary>
/// <param name="ids">编号数组</param>
/// <returns></returns>
[HttpPost("delete")]
public async Task<ActionResult> Delete(string[] ids)
{
await InstallService.Delete(ids);
return Ok();
}
/// <summary>
/// 获取安装单列表
/// </summary>
/// <param name="pageSearch">查询条件</param>
/// <returns></returns>
[HttpPost("list")]
public async Task<ActionResult> List(PageYearSearch<InstallDO> pageSearch)
{
return Ok(await InstallService.List(pageSearch));
}
/// <summary>
/// 获取安装单详情
/// </summary>
/// <param name="id">编号</param>
/// <returns></returns>
[HttpGet("get")]
public async Task<ActionResult> Get([FromQuery] string id)
{
return Ok(await InstallService.Get(id));
}
/// <summary>
/// 获取安装单步骤
/// </summary>
/// <param name="installId">编号</param>
/// <returns></returns>
[HttpGet("getsteps")]
public async Task<ActionResult> GetSteps([FromQuery] string installId)
{
return Ok(await InstallService.GetStepsDO(installId));
}
}
}

@ -0,0 +1,67 @@
using CommonModel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ZhongLianInterface;
using ZhongLianModel;
using ZhongLianService;
namespace ZhongLianAPI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class MaintenanceController : ControllerBase
{
public MaintenanceController(IMaintenanceService maintenanceService) {
MaintenanceService = maintenanceService;
}
private readonly IMaintenanceService MaintenanceService;
[HttpPost("insert")]
public async Task<ActionResult> Insert(MaintenanceDO maintenance)
{
var _CheckMSG = MaintenanceService.InsertCheck(maintenance);
if (string.IsNullOrEmpty(_CheckMSG))
{
return Ok(await MaintenanceService.InserDO(maintenance));
}
else
{
return BadRequest(_CheckMSG);
}
}
[HttpPost("update")]
public async Task<ActionResult> Update(MaintenanceDO maintenance)
{
var _CheckMSG = MaintenanceService.UpdateCheck(maintenance);
if (string.IsNullOrEmpty(_CheckMSG))
{
return Ok(await MaintenanceService.UpdateDO(maintenance));
}
else
{
return BadRequest(_CheckMSG);
}
}
[HttpPost("delete")]
public async Task<ActionResult> Delete(string[] ids)
{
await MaintenanceService.DeleteDO(ids);
return Ok();
}
[HttpPost("list")]
public async Task<ActionResult> List(PageYearSearch<MaintenanceDO> pageSearch)
{
return Ok(await MaintenanceService.ListDO(pageSearch));
}
[HttpGet("get")]
public async Task<ActionResult> Get([FromQuery] string id)
{
return Ok(await MaintenanceService.GetDO(id));
}
}
}

@ -0,0 +1,70 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ZhongLianInterface;
using ZhongLianModel;
using ZhongLianService;
namespace ZhongLianAPI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ParamController : ControllerBase
{
public ParamController(IParamService productService) {
ProductService = productService;
}
private readonly IParamService ProductService;
/// <summary>
/// 创建设备分类
/// </summary>
/// <param name="product">设备分类</param>
/// <returns></returns>
[HttpPost("insert")]
public async Task<ActionResult> Insert(ParamDO product)
{
var _CheckMSG = ProductService.InsertCheck(product);
if (string.IsNullOrEmpty(_CheckMSG))
{
return Ok(await ProductService.Insert(product));
}
else
{
return BadRequest(_CheckMSG);
}
}
/// <summary>
/// 更新设备分类
/// </summary>
/// <param name="product">设备分类</param>
/// <returns></returns>
[HttpPost("update")]
public async Task<ActionResult> Update(ParamDO product)
{
var _CheckMSG = ProductService.UpdateCheck(product);
if (string.IsNullOrEmpty(_CheckMSG))
{
return Ok(await ProductService.Update(product));
}
else
{
return BadRequest(_CheckMSG);
}
}
[HttpPost("delete")]
public async Task<ActionResult> Delete(string[] ids) {
await ProductService.Delete(ids);
return Ok();
}
[HttpPost("list")]
public async Task<ActionResult> List(ParamDO param) {
return Ok(await ProductService.List(param));
}
}
}

@ -0,0 +1,87 @@
using CommonModel;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ZhongLianInterface;
using ZhongLianModel;
namespace ZhongLianAPI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ProjectController : ControllerBase
{
public ProjectController(IProjectService projectService)
{
ProjectService = projectService;
}
private readonly IProjectService ProjectService;
/// <summary>
/// 插入新工程
/// </summary>
/// <param name="project">工程对象</param>
/// <returns>工程对象</returns>
[HttpPost("insert")]
public async Task<ActionResult> insert(ProjectDO project)
{
return Ok(await ProjectService.Insert(project));
}
/// <summary>
/// 更新工程
/// </summary>
/// <param name="project">工程对象</param>
/// <returns>工程对象</returns>
[HttpPost("update")]
[HttpPut("update")]
public async Task<ActionResult> update(ProjectDO project)
{
return Ok(await ProjectService.Update(project));
}
/// <summary>
/// 删除工程
/// </summary>
/// <param name="ids">工程编号数组</param>
/// <returns></returns>
[HttpDelete("delete")]
[HttpPost("delete")]
public async Task<ActionResult> delete(string[] ids)
{
await ProjectService.Delete(ids);
return Ok();
}
/// <summary>
/// 根据编号查询工程详情
/// </summary>
/// <param name="id">编号</param>
/// <returns>工程</returns>
[HttpGet("get/{id}")]
[HttpPost("get/{id}")]
[AllowAnonymous]
public async Task<ActionResult> get(string id)
{
return Ok(await ProjectService.Get(id));
}
/// <summary>
/// 分页查询工程
/// </summary>
/// <param name="page">分页对象</param>
/// <returns>分页数据</returns>
[HttpPost("list")]
[AllowAnonymous]
public async Task<ActionResult> list(PageSearch<ProjectDO> page)
{
return Ok(await ProjectService.List(page));
}
[HttpGet("geo")]
public async Task<ActionResult> geo() {
return Ok(await ProjectService.GeoCount());
}
}
}

@ -0,0 +1,25 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" >/etc/timezone
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["ZhongLian/ZhongLianAPI/ZhongLianAPI.csproj", "ZhongLian/ZhongLianAPI/"]
COPY ["ZhongLian/ZhongLianService/ZhongLianService.csproj", "ZhongLian/ZhongLianService/"]
COPY ["CommonModel/CommonModel.csproj", "CommonModel/"]
COPY ["ZhongLian/ZhongLianModel/ZhongLianModel.csproj", "ZhongLian/ZhongLianModel/"]
RUN dotnet restore "ZhongLian/ZhongLianAPI/ZhongLianAPI.csproj"
COPY . .
WORKDIR "/src/ZhongLian/ZhongLianAPI"
RUN dotnet build "ZhongLianAPI.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "ZhongLianAPI.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ZhongLianAPI.dll"]

@ -0,0 +1,52 @@
using ZhongLianService;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers().AddNewtonsoftJson(options =>
{
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
}).AddDapr();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.InitZhongLianService(builder.Configuration);
#region Cors<72><73><EFBFBD><EFBFBD>
#if DEBUG
builder.Services.AddCors(options =>
{
options.AddPolicy("all", builder =>
{
builder.SetIsOriginAllowed(origin => true) //<2F><><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><CEBA><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials();//ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cookie
});
});
#endif
#endregion
var app = builder.Build();
// Configure the HTTP request pipeline.
#region Cors<72><73><EFBFBD><EFBFBD>
#if DEBUG
app.UseCors("all");
#endif
#endregion
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseStaticFiles();
#if !DEBUG
app.MapActorsHandlers();
#endif
app.MapControllers();
app.Run();

@ -0,0 +1,37 @@
{
"profiles": {
"ZhongLianAPI": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5027"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:52302",
"sslPort": 0
}
}
}

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapr.Actors.AspNetCore" Version="1.9.0" />
<PackageReference Include="Dapr.AspNetCore" Version="1.9.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.13" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ZhongLianService\ZhongLianService.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore": "Warning"
}
}
}

@ -0,0 +1,12 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"Default": "Data Source=124.71.176.44;database=lsdb;User Id=root;Pwd=root;charset=utf8;pooling=true;"
}
}

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhongLianModel;
namespace ZhongLianInterface
{
public interface IDriveService
{
/// <summary>
/// 创建
/// </summary>
/// <param name="file">文件</param>
/// <returns></returns>
Task<FileDO> Insert(FileDO file);
/// <summary>
/// 创建插入
/// </summary>
/// <param name="file">文件</param>
/// <returns></returns>
Task<FileDO> InsertDO(FileDO file);
/// <summary>
/// 创建检查
/// </summary>
/// <param name="file">文件</param>
/// <returns></returns>
string InsertCheck(FileDO file);
/// <summary>
/// 查询
/// </summary>
/// <param name="id">编号</param>
/// <returns></returns>
Task<FileDO> Get(string id);
/// <summary>
/// 查询数据
/// </summary>
/// <param name="id">编号</param>
/// <returns></returns>
Task<FileDO> GetDO(string id);
}
}

@ -0,0 +1,35 @@
using CommonModel;
using Dapr.Actors;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhongLianModel;
namespace ZhongLianInterface
{
public interface IInstallActor : IActor
{
/// <summary>
/// 创建
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
Task<InstallDO> Insert(InstallDO install);
/// <summary>
/// 更新
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
Task<InstallDO> Update(InstallDO install);
/// <summary>
/// 删除
/// </summary>
/// <param name="ids">编号数组</param>
/// <returns></returns>
Task Delete(string[] ids);
}
}

@ -0,0 +1,111 @@
using CommonModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhongLianModel;
namespace ZhongLianInterface
{
public interface IInstallService
{
/// <summary>
/// 创建
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
Task<InstallDO> Insert(InstallDO install);
/// <summary>
/// 创建数据
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
Task<InstallDO> InserDO(InstallDO install);
/// <summary>
/// 创建校验
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
string InsertCheck(InstallDO install);
/// <summary>
/// 更新
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
Task<InstallDO> Update(InstallDO install);
/// <summary>
/// 更新数据
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
Task<InstallDO> UpdateDO(InstallDO install);
/// <summary>
/// 更新校验
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
string UpdateCheck(InstallDO install);
/// <summary>
/// 删除
/// </summary>
/// <param name="ids">编号数组</param>
/// <returns></returns>
Task Delete(string[] ids);
/// <summary>
/// 删除数据
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
Task DeleteDO(string[] ids);
/// <summary>
/// 查询列表
/// </summary>
/// <param name="pageSearch">查询条件</param>
/// <returns></returns>
Task<PageData<InstallDO>> List(PageYearSearch<InstallDO> pageSearch);
/// <summary>
/// 查询列表数据
/// </summary>
/// <param name="pageSearch">查询条件</param>
/// <returns></returns>
Task<PageData<InstallDO>> ListDO(PageYearSearch<InstallDO> pageSearch);
/// <summary>
/// 查询详情
/// </summary>
/// <param name="id">编号</param>
/// <returns></returns>
Task<InstallDO> Get(string id);
/// <summary>
/// 查询详情数据
/// </summary>
/// <param name="id">编号</param>
/// <returns></returns>
Task<InstallDO> GetDO(string id);
/// <summary>
/// 查询步骤
/// </summary>
/// <param name="installId">编号</param>
/// <returns></returns>
Task<InstallStepDO[]> GetSteps(string installId);
/// <summary>
/// 查询步骤数据
/// </summary>
/// <param name="installId">编号</param>
/// <returns></returns>
Task<InstallStepDO[]> GetStepsDO(string installId);
}
}

@ -0,0 +1,27 @@
using CommonModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhongLianModel;
namespace ZhongLianInterface
{
public interface IMaintenanceService
{
Task<MaintenanceDO> InserDO(MaintenanceDO maintenance);
string InsertCheck(MaintenanceDO maintenance);
Task<MaintenanceDO> UpdateDO(MaintenanceDO maintenance);
string UpdateCheck(MaintenanceDO maintenance);
Task DeleteDO(string[] ids);
Task<MaintenanceDO> GetDO(string id);
Task<PageData<MaintenanceDO>> ListDO(PageYearSearch<MaintenanceDO> pageSearch);
}
}

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhongLianModel;
namespace ZhongLianInterface
{
public interface IParamService
{
Task<ParamDO> Insert(ParamDO param);
string InsertCheck(ParamDO param);
Task<ParamDO> Update(ParamDO param);
Task Use(string id);
string UpdateCheck(ParamDO param);
Task Delete(string[] ids);
Task<List<ParamDO>> List(ParamDO param);
}
}

@ -0,0 +1,55 @@
using CommonModel;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhongLianModel;
namespace ZhongLianInterface
{
/// <summary>
/// 工程服务
/// </summary>
public interface IProjectService
{
/// <summary>
/// 插入
/// </summary>
/// <param name="project">工程实体</param>
/// <returns>工程实体</returns>
Task<ProjectDO> Insert(ProjectDO project);
/// <summary>
/// 更新
/// </summary>
/// <param name="project">工程实体</param>
/// <returns>工程实体</returns>
Task<ProjectDO> Update(ProjectDO project);
/// <summary>
/// 删除
/// </summary>
/// <param name="Ids">Id数组</param>
/// <returns></returns>
Task Delete(string[] ids);
/// <summary>
/// 根据编号查询
/// </summary>
/// <param name="id">编号</param>
/// <returns>工程</returns>
Task<ProjectDO> Get(string id);
/// <summary>
/// 分页查询
/// </summary>
/// <param name="page">分页对象</param>
/// <returns>分页对象</returns>
Task<PageData<ProjectDO>> List(PageSearch<ProjectDO> page);
Task<List<GeoProjectDTO>> GeoCount();
}
}

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapr.Actors" Version="1.9.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CommonModel\CommonModel.csproj" />
<ProjectReference Include="..\ZhongLianModel\ZhongLianModel.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,92 @@
using SqlSugar;
namespace ZhongLianModel
{
/// <summary>
/// 公司实体类
/// </summary>
[SugarTable("CRM_Company_zl")]
public class CompanyDO
{
/// <summary>
/// 唯一键
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 64)]
public string? Id { get; set; }
/// <summary>
/// 编号
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? Code { get; set; }
[SugarColumn(IsIgnore = true, IsNullable = true)]
public string? System { get; set; }
/// <summary>
/// 名称
/// </summary>
[SugarColumn(Length = 250, IsNullable = true)]
public string? Name { get; set; }
/// <summary>
/// 法人代表
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? LegalPerson { get; set; }
/// <summary>
/// 社会信用代码
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? SCCode { get; set; }
/// <summary>
/// 人员规模
/// </summary>
[SugarColumn(Length = 60, IsNullable = true)]
public string? Scale { get; set; }
/// <summary>
/// 公司性质
/// </summary>
[SugarColumn(Length = 200, IsNullable = true)]
public string? Character { get; set; }
/// <summary>
/// 地址
/// </summary>
[SugarColumn(Length = 500, IsNullable = true)]
public string? Address { get; set; }
/// <summary>
/// 定位
/// </summary>
[SugarColumn(Length = 20, IsNullable = true)]
public string? Location { get; set; }
/// <summary>
/// 联系电话
/// </summary>
[SugarColumn(Length = 60, IsNullable = true)]
public string? Tel { get; set; }
/// <summary>
/// 简介
/// </summary>
[SugarColumn(Length = 500,IsNullable = true)]
public string? BriefIntroduction { get; set; }
/// <summary>
/// 创建日期
/// </summary>
[SugarColumn(Length = 24, IsNullable = true)]
public string? CreateDate { get; set; }
/// <summary>
/// 删除标识
/// </summary>
[SugarColumn(Length = 1, IsNullable = true)]
public int? Deleted { get; set; }
}
}

@ -0,0 +1,34 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZhongLianModel
{
/// <summary>
/// 设备实体
/// </summary>
[SugarTable("TPRZ_Device")]
public class DeviceDO
{
/// <summary>
/// 设备编号
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 64)]
public string? Id { get; set; }
/// <summary>
/// 工程
/// </summary>
[SugarColumn(Length = 64, IsNullable = true)]
public string? ProjectId { get; set; }
/// <summary>
/// 删除标识
/// </summary>
[SugarColumn(Length = 1, IsNullable = true)]
public int? Deleted { get; set; }
}
}

@ -0,0 +1,48 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZhongLianModel
{
/// <summary>
/// 文件
/// </summary>
[SugarTable("ZL_File_{year}{month}{day}")]
[SplitTable(SplitType.Year)]
public class FileDO
{
/// <summary>
/// 编号
/// </summary>
[SugarColumn(IsPrimaryKey = true,Length = 100)]
public string? Id { get; set; }
/// <summary>
/// 文件名称
/// </summary>
[SugarColumn(IsNullable = true,Length = 200)]
public string? FileName { get; set; }
/// <summary>
/// 文件类型
/// </summary>
[SugarColumn(IsNullable = true,Length = 50)]
public string? ContentType { get; set; }
/// <summary>
/// 数据
/// </summary>
[SugarColumn(IsNullable = true,ColumnDataType = "LONGBLOB")]
public byte[]? Data { get; set; }
/// <summary>
/// 创建日期
/// </summary>
[SplitField]
[SugarColumn(IsNullable = true)]
public DateTime? CreateDate { get; set; }
}
}

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZhongLianModel
{
public class GeoProjectDTO
{
public string? Code { get; set; }
public int? Count { get; set; }
public string? ParentCode { get; set; }
}
}

@ -0,0 +1,66 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZhongLianModel
{
/// <summary>
/// 组实体类
/// </summary>
[SugarTable("AT_Group_zl")]
public class GroupDO
{
/// <summary>
/// 唯一键
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 64)]
public string? Id { get; set; }
/// <summary>
/// 父键
/// </summary>
[SugarColumn(Length = 64,IsNullable = true)]
public string? PId { get; set; }
/// <summary>
/// 编号
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? Code { get; set; }
/// <summary>
/// 系统
/// </summary>
[SugarColumn(IsIgnore = true, IsNullable = true)]
public string? System { get; set; }
/// <summary>
/// 名称
/// </summary>
[SugarColumn(Length = 250, IsNullable = true)]
public string? Name { get; set; }
/// <summary>
/// 类型{0组织结构}
/// </summary>
[SugarColumn(Length = 2, IsNullable = true)]
public int? Type { get; set; }
/// <summary>
/// 创建日期
/// </summary>
[SugarColumn(Length = 24, IsNullable = true)]
public string? CreateDate { get; set; }
/// <summary>
/// 删除标识
/// </summary>
[SugarColumn(Length = 1, IsNullable = true)]
public int? Deleted { get; set; }
}
}

@ -0,0 +1,171 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
namespace ZhongLianModel
{
[SugarTable("ZL_Install_{year}{month}{day}")]
[SplitTable(SplitType.Year)]
public class InstallDO
{
/// <summary>
/// 编号
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 100)]
public string? Id { get; set; }
/// <summary>
/// 安装地点
/// </summary>
[SugarColumn(IsNullable = true, Length = 200)]
public string? Address { get; set; }
/// <summary>
/// 设备编号
/// </summary>
[SugarColumn(IsNullable = true, Length = 100)]
public string? DeviceId { get; set; }
/// <summary>
/// 设备信息
/// </summary>
[SugarColumn(IsJson = true, IsNullable = true, ColumnDataType = "Text")]
public Dictionary<string, dynamic>? Device { get; set; }
/// <summary>
/// 工作内容:安装,加节,拆卸
/// </summary>
[SugarColumn(IsNullable = true, Length = 50)]
public string? Action { get; set; }
/// <summary>
/// 安装人员编号
/// </summary>
[SugarColumn(IsNullable = true, Length = 100)]
public string? InstallUid { get; set; }
/// <summary>
/// 安装人员信息
/// </summary>
[SugarColumn(IsJson = true, IsNullable = true, ColumnDataType = "Text")]
public Dictionary<string, dynamic>? InstallUser { get; set; }
/// <summary>
/// 安装时间
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? InstallDate { get; set; }
/// <summary>
/// 巡检人员编号
/// </summary>
[SugarColumn(IsNullable = true, Length = 100)]
public string? PatrolUid { get; set; }
/// <summary>
/// 巡检人员信息
/// </summary>
[SugarColumn(IsJson = true, IsNullable = true, ColumnDataType = "Text")]
public Dictionary<string, dynamic>? PatrolUser { get; set; }
/// <summary>
/// 巡检时间
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? PatrolDate { get; set; }
/// <summary>
/// 安装单状态,0未完成1安装人员已提交2巡检人员未通过3已完成
/// </summary>
[SugarColumn(IsNullable = true, Length = 2)]
public int? State { get; set; }
/// <summary>
/// 备注
/// </summary>
[SugarColumn(IsNullable = true, ColumnDataType = "Text")]
public string? Remark { get; set; }
/// <summary>
/// 创建日期
/// </summary>
[SplitField]
[SugarColumn(IsNullable = true)]
public DateTime? CreateDate { get; set; }
/// <summary>
/// 最后更新日期
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? LastDate { get; set; }
#region 业务字段
/// <summary>
/// 创建日期文字
/// </summary>
[SugarColumn(IsIgnore = true)]
public string? CreateDateText
{
get
{
if (CreateDate == null)
{
return null;
}
else
{
return ((DateTime)CreateDate).ToString("yyyyMMddHHmmss");
}
}
}
/// <summary>
/// 安装日期文字
/// </summary>
[SugarColumn(IsIgnore = true)]
public string? InstallDateDateText
{
get
{
if (InstallDate == null)
{
return null;
}
else
{
return ((DateTime)InstallDate).ToString("yyyyMMddHHmmss");
}
}
}
/// <summary>
/// 巡检日期文字
/// </summary>
[SugarColumn(IsIgnore = true)]
public string? PatrolDateText
{
get
{
if (PatrolDate == null)
{
return null;
}
else
{
return ((DateTime)PatrolDate).ToString("yyyyMMdd");
}
}
}
/// <summary>
/// 安装步骤
/// </summary>
[SugarColumn(IsIgnore = true)]
public InstallStepDO[]? Steps { get; set; }
#endregion
}
}

@ -0,0 +1,70 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
namespace ZhongLianModel
{
[SugarTable("ZL_InstallStep_{year}{month}{day}")]
[SplitTable(SplitType.Year)]
public class InstallStepDO
{
/// <summary>
/// 安装单编号
/// </summary>
[SugarColumn(Length = 100, IsPrimaryKey = true)]
public string? InstallId { get; set; }
/// <summary>
/// 键
/// </summary>
[SugarColumn(Length = 50, IsPrimaryKey = true)]
public string? Key { get; set; }
/// <summary>
/// 值
/// </summary>
[SugarColumn(IsJson = true,IsNullable = true, ColumnDataType = "Text")]
public dynamic[]? Value { get; set; }
/// <summary>
/// 序号
/// </summary>
[SugarColumn(IsNullable = true, Length = 2)]
public int? Index { get; set; }
/// <summary>
/// 自定义数据
/// </summary>
[SugarColumn(IsJson = true, IsNullable = true, ColumnDataType = "Text")]
public Dictionary<string, dynamic>? Data { get; set; }
/// <summary>
/// 巡检状态 0:未巡检,1:已通过,2:未通过
/// </summary>
[SugarColumn(IsNullable = true, Length = 2)]
public int? State { get; set; }
/// <summary>
/// 巡检评论
/// </summary>
[SugarColumn(IsNullable = true, Length = 500)]
public string? Comment { get; set; }
/// <summary>
/// 创建日期
/// </summary>
[SplitField]
[SugarColumn(IsNullable = true)]
public DateTime? CreateDate { get; set; }
/// <summary>
/// 最后更新日期
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? LastDate { get; set; }
}
}

@ -0,0 +1,161 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZhongLianModel
{
[SugarTable("ZL_Maintenance_{year}{month}{day}")]
[SplitTable(SplitType.Year)]
public class MaintenanceDO
{
public MaintenanceDO() {
BomCodes = new string[0];
Boms = new string[0];
ErrorRemarkPhoto = new string[0];
ProcessResultPhoto = new string[0];
}
/// <summary>
/// 编号
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 100)]
public string? Id { get; set; }
/// <summary>
/// 标题
/// </summary>
[SugarColumn(IsNullable = true, Length = 200)]
public string? Title { get; set; }
/// <summary>
/// 单据类型
/// </summary>
[SugarColumn(IsNullable = true, Length = 50)]
public string? Type { get; set; }
/// <summary>
/// 维修人员编号
/// </summary>
[SugarColumn(IsNullable = true, Length = 100)]
public string? MaintenanceUid { get; set; }
/// <summary>
/// 维修人员信息
/// </summary>
[SugarColumn(IsJson = true, IsNullable = true, ColumnDataType = "Text")]
public Dictionary<string, dynamic>? MaintenanceUser { get; set; }
/// <summary>
/// 设备分类编号
/// </summary>
[SugarColumn(IsNullable = true, Length = 100)]
public string? DeviceTypeCode { get; set; }
/// <summary>
/// 设备分类
/// </summary>
[SugarColumn(IsNullable = true, Length = 200)]
public string? DeviceType { get; set; }
/// <summary>
/// 维修日期
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? MaintenanceDate { get; set; }
/// <summary>
/// 安装单状态,0未完成1维修人员已提交2审核未通过3已完成
/// </summary>
[SugarColumn(IsNullable = true, Length = 2)]
public int? State { get; set; }
/// <summary>
/// 备注
/// </summary>
[SugarColumn(IsNullable = true, ColumnDataType = "Text")]
public string? Remark { get; set; }
/// <summary>
/// 故障归类编号
/// </summary>
[SugarColumn(IsNullable = true, Length = 100)]
public string? ErrorTypeCode { get; set; }
/// <summary>
/// 故障归类
/// </summary>
[SugarColumn(IsNullable = true, Length = 200)]
public string? ErrorType { get; set; }
/// <summary>
/// 配件清单编号
/// </summary>
[SugarColumn(IsJson = true, IsNullable = true, ColumnDataType = "Text")]
public string[]? BomCodes { get; set; }
/// <summary>
/// 配件清单
/// </summary>
[SugarColumn(IsJson = true, IsNullable = true, ColumnDataType = "Text")]
public string[]? Boms { get; set; }
/// <summary>
/// 处理方式编号
/// </summary>
[SugarColumn(IsNullable = true, Length = 100)]
public string? ErrorActionCode { get; set; }
/// <summary>
/// 处理方式
/// </summary>
[SugarColumn(IsNullable = true, Length = 200)]
public string? ErrorAction { get; set; }
/// <summary>
/// 故障代码编号
/// </summary>
[SugarColumn(IsNullable = true, Length = 100)]
public string? ErrorCodeCode { get; set; }
/// <summary>
/// 故障代码
/// </summary>
[SugarColumn(IsNullable = true, Length = 200)]
public string? ErrorCode { get; set; }
/// <summary>
/// 故障分析
/// </summary>
[SugarColumn(IsNullable = true, Length = 500)]
public string? ErrorRemark { get; set; }
/// <summary>
/// 故障分析图片
/// </summary>
[SugarColumn(IsJson = true, IsNullable = true, ColumnDataType = "Text")]
public string[]? ErrorRemarkPhoto { get; set; }
/// <summary>
/// 处理结果
/// </summary>
[SugarColumn(IsNullable = true, Length = 500)]
public string? ProcessResult { get; set; }
/// <summary>
/// 处理结果图片
/// </summary>
[SugarColumn(IsJson = true, IsNullable = true, ColumnDataType = "Text")]
public string[]? ProcessResultPhoto { get; set; }
/// <summary>
/// 创建日期
/// </summary>
[SplitField]
[SugarColumn(IsNullable = true)]
public DateTime? CreateDate { get; set; }
}
}

@ -0,0 +1,25 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZhongLianModel
{
[SugarTable("ZL_Param")]
public class ParamDO
{
[SugarColumn(IsPrimaryKey = true,Length = 100)]
public string? Id { get; set; }
[SugarColumn(IsNullable = true,Length = 200)]
public string? Name { get; set; }
[SugarColumn(IsNullable = true,Length = 100)]
public string? Category { get; set; }
[SugarColumn(IsNullable = true)]
public int? UseCount { get; set; }
}
}

@ -0,0 +1,201 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZhongLianModel
{
/// <summary>
/// 工程实体
/// </summary>
[SugarTable("TPRZ_Project")]
public class ProjectDO
{
/// <summary>
/// 编号
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 64)]
public string? Id { get; set; }
/// <summary>
/// 编码
/// </summary>
[SugarColumn(Length = 200, IsNullable = true)]
public string? Code { get; set; }
/// <summary>
/// 公司编号
/// </summary>
[SugarColumn(Length = 64, IsNullable = true)]
public string? CompanyId { get; set; }
/// <summary>
/// 工程名称
/// </summary>
[SugarColumn(Length = 200, IsNullable = true)]
public string? Name { get; set; }
/// <summary>
/// 区域
/// </summary>
[SugarColumn(Length = 60, IsNullable = true)]
public string? Area { get; set; }
/// <summary>
/// 工地名称
/// </summary>
[SugarColumn(Length = 200, IsNullable = true)]
public string? AddressName { get; set; }
/// <summary>
/// 地址
/// </summary>
[SugarColumn(Length = 500, IsNullable = true)]
public string? Address { get; set; }
/// <summary>
/// 定位
/// </summary>
[SugarColumn(Length = 20, IsNullable = true)]
public string? Location { get; set; }
/// <summary>
/// 施工单位
/// </summary>
[SugarColumn(Length = 200, IsNullable = true)]
public string? CU { get; set; }
/// <summary>
/// 施工许可证
/// </summary>
[SugarColumn(Length = 100, IsNullable = true)]
public string? CC { get; set; }
/// <summary>
/// 监理单位
/// </summary>
[SugarColumn(Length = 200, IsNullable = true)]
public string? SU { get; set; }
/// <summary>
/// 项目经理
/// </summary>
[SugarColumn(Length = 200, IsNullable = true)]
public string? PM { get; set; }
/// <summary>
/// 项目经理联系方式
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? PT { get; set; }
/// <summary>
/// 现场负责人
/// </summary>
[SugarColumn(Length = 200, IsNullable = true)]
public string? SM { get; set; }
/// <summary>
/// 现场负责人联系方式
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? ST { get; set; }
/// <summary>
/// 资料员
/// </summary>
[SugarColumn(Length = 200, IsNullable = true)]
public string? DR { get; set; }
/// <summary>
/// 资料员联系方式
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? DT { get; set; }
/// <summary>
/// 工地财务
/// </summary>
[SugarColumn(Length = 200, IsNullable = true)]
public string? FA { get; set; }
/// <summary>
/// 工地财务联系方式
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? FT { get; set; }
/// <summary>
/// 监理
/// </summary>
[SugarColumn(Length = 200, IsNullable = true)]
public string? SP { get; set; }
/// <summary>
/// 监理联系方式
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? SPT { get; set; }
/// <summary>
/// 备注
/// </summary>
[SugarColumn(Length = 500, IsNullable = true)]
public string? Remark { get; set; }
/// <summary>
/// 创建日期
/// </summary>
[SugarColumn(Length = 24, IsNullable = true)]
public string? CreateDate { get; set; }
/// <summary>
/// 删除标识
/// </summary>
[SugarColumn(Length = 1, IsNullable = true)]
public int? Deleted { get; set; }
/// <summary>
/// 省份码
/// </summary>
[SugarColumn(Length = 10,IsNullable = true)]
public string? ProvinceCode { get; set; }
/// <summary>
/// 省份名
/// </summary>
[SugarColumn(Length = 20, IsNullable = true)]
public string? ProvinceName { get; set; }
/// <summary>
/// 市级码
/// </summary>
[SugarColumn(Length = 10, IsNullable = true)]
public string? CityCode { get; set; }
/// <summary>
/// 市级名
/// </summary>
[SugarColumn(Length = 20, IsNullable = true)]
public string? CityName { get; set; }
/// <summary>
/// 区域码
/// </summary>
[SugarColumn(Length = 10, IsNullable = true)]
public string? AreaCode { get; set; }
/// <summary>
/// 区域名
/// </summary>
[SugarColumn(Length = 20, IsNullable = true)]
public string? AreaName { get; set; }
#region 业务字段
[SugarColumn(IsIgnore = true, IsNullable = true)]
public string? CompanyName { get; set; }
#endregion
}
}

@ -0,0 +1,12 @@
{
"profiles": {
"ZhongLianModel": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:64277;http://localhost:64280"
}
}
}

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SqlSugarCore" Version="5.1.3.50" />
</ItemGroup>
</Project>

@ -0,0 +1,103 @@
using CommonModel;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhongLianModel;
using ZhongLianInterface;
namespace ZhongLianService
{
/// <summary>
/// 文件服务
/// </summary>
public class DriveService : IDriveService
{
public DriveService(IServiceProvider services, ISqlSugarClient sqlSugarClient)
{
Services = services;
Db = sqlSugarClient;
Db.CodeFirst.SplitTables().InitTables(typeof(FileDO));
}
private readonly IServiceProvider Services;
private readonly ISqlSugarClient Db;
#region 创建
/// <summary>
/// 创建
/// </summary>
/// <param name="file">文件</param>
/// <returns></returns>
public async Task<FileDO> Insert(FileDO file)
{
return await InsertDO(file);
}
/// <summary>
/// 创建插入
/// </summary>
/// <param name="file">文件</param>
/// <returns></returns>
public async Task<FileDO> InsertDO(FileDO file)
{
await Db.Insertable<FileDO>(file).SplitTable().ExecuteCommandAsync();
file.Data = null;
return file;
}
/// <summary>
/// 创建检查
/// </summary>
/// <param name="file">文件</param>
/// <returns></returns>
public string InsertCheck(FileDO file)
{
var _MaxId = Db.Queryable<FileDO>().SplitTable(DateTime.Today, DateTime.Today.AddDays(1)).Max(x => x.Id);
if (string.IsNullOrEmpty(_MaxId))
{
file.Id = $"FL{DateTime.Now.ToString("yyyyMMdd")}000001";
}
else
{
file.Id = $"FL{DateTime.Now.ToString("yyyyMMdd")}{(Convert.ToInt32(_MaxId.Substring(10, 6)) + 1).ToString().PadLeft(6, '0')}";
}
file.CreateDate = DateTime.Now;
return "";
}
#endregion
#region 查询
/// <summary>
/// 查询
/// </summary>
/// <param name="id">编号</param>
/// <returns></returns>
public async Task<FileDO> Get(string id)
{
return await GetDO(id);
}
/// <summary>
/// 查询数据
/// </summary>
/// <param name="id">编号</param>
/// <returns></returns>
public async Task<FileDO> GetDO(string id)
{
SplitDateId SplitDateId = new SplitDateId(id, 2);
return await Db.Queryable<FileDO>().Where(x => x.Id == id).SplitTable(SplitDateId.StartDate, SplitDateId.EndDate).SingleAsync();
}
#endregion
}
}

@ -0,0 +1,55 @@
using CommonModel;
using Dapr.Actors.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhongLianInterface;
using ZhongLianModel;
namespace ZhongLianService
{
/// <summary>
/// 安装单Actor
/// </summary>
public class InstallActor : Actor, IInstallActor
{
public InstallActor(ActorHost host, IInstallService installService) : base(host)
{
InstallService = installService;
}
private readonly IInstallService InstallService;
/// <summary>
/// 创建
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
public async Task<InstallDO> Insert(InstallDO install)
{
return await InstallService.InserDO(install);
}
/// <summary>
/// 更新
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
public async Task<InstallDO> Update(InstallDO install)
{
return await InstallService.UpdateDO(install);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="ids">编号数组</param>
/// <returns></returns>
public async Task Delete(string[] ids)
{
await InstallService.DeleteDO(ids);
}
}
}

@ -0,0 +1,385 @@
using CommonModel;
using Dapr.Actors;
using Dapr.Actors.Client;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhongLianInterface;
using ZhongLianModel;
namespace ZhongLianService
{
public class InstallService : IInstallService
{
public InstallService(IServiceProvider services, ISqlSugarClient sqlSugarClient)
{
Services = services;
Db = sqlSugarClient;
Db.CodeFirst.SplitTables().InitTables(typeof(InstallDO));
Db.CodeFirst.SplitTables().InitTables(typeof(InstallStepDO));
}
private readonly IServiceProvider Services;
private readonly ISqlSugarClient Db;
#region 创建
/// <summary>
/// 创建
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
public async Task<InstallDO> Insert(InstallDO install)
{
#if DEBUG
return await InserDO(install);
#else
var _ActorProxy = Services.GetRequiredService<IActorProxyFactory>();
var _Proxy = _ActorProxy.CreateActorProxy<IInstallActor>(new ActorId(install.Id), "InstallActor");
return await _Proxy.Insert(install);
#endif
}
/// <summary>
/// 创建数据
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
public async Task<InstallDO> InserDO(InstallDO install)
{
try
{
Db.Ado.BeginTran();
await Db.Insertable<InstallDO>(install).SplitTable().ExecuteCommandAsync();
if (install.Steps != null && install.Steps.Length > 0)
{
await Db.Insertable<InstallStepDO>(install.Steps).SplitTable().ExecuteCommandAsync();
}
Db.Ado.CommitTran();
}
catch
{
Db.Ado.RollbackTran();
throw;
}
return install;
}
/// <summary>
/// 创建校验
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
public string InsertCheck(InstallDO install)
{
var _MaxId = Db.Queryable<InstallDO>().SplitTable(DateTime.Today, DateTime.Today.AddDays(1)).Max(x => x.Id);
if (string.IsNullOrEmpty(_MaxId))
{
install.Id = $"IS{DateTime.Now.ToString("yyyyMMdd")}000001";
}
else
{
install.Id = $"IS{DateTime.Now.ToString("yyyyMMdd")}{(Convert.ToInt32(_MaxId.Substring(10, 6)) + 1).ToString().PadLeft(6, '0')}";
}
install.State = 0;
install.CreateDate = DateTime.Now;
if (install.Steps != null && install.Steps.Length > 0)
{
foreach (var step in install.Steps)
{
step.InstallId = install.Id;
step.CreateDate = install.CreateDate;
step.State = 0;
}
}
return "";
}
#endregion
#region 更新
/// <summary>
/// 更新
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
public async Task<InstallDO> Update(InstallDO install)
{
#if DEBUG
return await UpdateDO(install);
#else
var _ActorProxy = Services.GetRequiredService<IActorProxyFactory>();
var _Proxy = _ActorProxy.CreateActorProxy<IInstallActor>(new ActorId(install.Id), "InstallActor");
return await _Proxy.Update(install);
#endif
}
/// <summary>
/// 更新数据
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
public async Task<InstallDO> UpdateDO(InstallDO install)
{
try
{
Db.Ado.BeginTran();
await Db.Updateable<InstallDO>(install).IgnoreColumns(ignoreAllNullColumns: true).Where(x => x.Id == install.Id).SplitTable().ExecuteCommandAsync();
if (install.Steps != null && install.Steps.Length > 0)
{
SplitDateId SplitDateId = new SplitDateId(install.Id!, 2);
foreach (var step in install.Steps)
{
if (Db.Queryable<InstallStepDO>().SplitTable(SplitDateId.StartDate, SplitDateId.EndDate).Any(x => x.InstallId == install.Id && x.Key == step.Key))
{
await Db.Updateable<InstallStepDO>(step).IgnoreColumns(ignoreAllNullColumns: true).Where(x => x.InstallId == install.Id && x.Key == step.Key).SplitTable().ExecuteCommandAsync();
}
else
{
await Db.Insertable<InstallStepDO>(step).SplitTable().ExecuteCommandAsync();
}
}
}
Db.Ado.CommitTran();
}
catch
{
Db.Ado.RollbackTran();
throw;
}
return install;
}
/// <summary>
/// 更新校验
/// </summary>
/// <param name="install">安装单</param>
/// <returns></returns>
public string UpdateCheck(InstallDO install)
{
if (string.IsNullOrEmpty(install.Id))
{
return "安装单编号不存在";
}
SplitDateId SplitDateId = new SplitDateId(install.Id!, 2);
if (!Db.Queryable<InstallDO>().SplitTable(SplitDateId.StartDate, SplitDateId.EndDate).Any(x => x.Id == install.Id)) {
return "安装单编号不存在";
}
var _Install = Db.Queryable<InstallDO>().SplitTable(SplitDateId.StartDate, SplitDateId.EndDate).Where(x => x.Id == install.Id).Single();
if (install.Steps != null && install.Steps.Length > 0)
{
foreach (var step in install.Steps)
{
step.InstallId = install.Id;
if (step.State == null)
{
step.State = 0;
}
if (step.State == 1)
{
step.Comment = "";
}
if (install.State == 3 && step.State == 2)
{
install.State = 2;
}
step.CreateDate = _Install.CreateDate;
step.LastDate = DateTime.Now;
}
}
if (install.State == 1)
{
install.InstallDate = DateTime.Now;
}
if (install.State == 2 || install.State == 3)
{
install.PatrolDate = DateTime.Now;
}
install.LastDate = DateTime.Now;
return "";
}
#endregion
#region 删除
/// <summary>
/// 删除
/// </summary>
/// <param name="ids">编号数组</param>
/// <returns></returns>
public async Task Delete(string[] ids)
{
#if DEBUG
await DeleteDO(ids);
#else
var _ActorProxy = Services.GetRequiredService<IActorProxyFactory>();
var _Proxy = _ActorProxy.CreateActorProxy<IInstallActor>(new ActorId(Guid.NewGuid().ToString()), "InstallActor");
await _Proxy.Delete(ids);
#endif
}
/// <summary>
/// 删除数据
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public async Task DeleteDO(string[] ids)
{
try
{
Db.Ado.BeginTran();
foreach(var id in ids)
{
InstallDO InstallDO = new InstallDO() {
Id = id,
State = -1
};
await Db.Updateable<InstallDO>(InstallDO).IgnoreColumns(ignoreAllNullColumns: true).Where(x => x.Id == InstallDO.Id).SplitTable().ExecuteCommandAsync();
}
Db.Ado.CommitTran();
}
catch
{
Db.Ado.RollbackTran();
throw;
}
}
#endregion
#region 列表
/// <summary>
/// 查询列表
/// </summary>
/// <param name="pageSearch">查询条件</param>
/// <returns></returns>
public async Task<PageData<InstallDO>> List(PageYearSearch<InstallDO> pageSearch)
{
return await ListDO(pageSearch);
}
/// <summary>
/// 查询列表数据
/// </summary>
/// <param name="pageSearch">查询条件</param>
/// <returns></returns>
public async Task<PageData<InstallDO>> ListDO(PageYearSearch<InstallDO> pageSearch)
{
RefAsync<int> _Total = 0;
var _Result = await Db.Queryable<InstallDO>()
.Where(x => x.State != -1)
.WhereIF(!string.IsNullOrEmpty(pageSearch.Search), x =>
x.Id!.Contains(pageSearch.Search!) ||
x.Address!.Contains(pageSearch.Search!) ||
SqlFunc.JsonLike(x.InstallUser, pageSearch.Search!) ||
SqlFunc.JsonLike(x.PatrolUser, pageSearch.Search!)
)
.WhereIF(pageSearch.Mode != null && pageSearch.Mode.State != null, x => x.State == pageSearch.Mode!.State)
.WhereIF(pageSearch.Mode != null && !string.IsNullOrEmpty(pageSearch.Mode.InstallUid), x =>
x.InstallUid == pageSearch.Mode!.InstallUid
)
.WhereIF(pageSearch.Mode != null && !string.IsNullOrEmpty(pageSearch.Mode.PatrolUid), x =>
x.PatrolUid == pageSearch.Mode!.PatrolUid
)
.OrderByDescending(x => x.Id)
.SplitTable((DateTime)pageSearch.StartDate!, (DateTime)pageSearch.EndDate!)
.ToPageListAsync(pageSearch.Index, pageSearch.Size, _Total);
return new PageData<InstallDO>()
{
Index = pageSearch.Index,
Size = pageSearch.Size,
Data = _Result,
Total = _Total.Value
};
}
#endregion
#region 查询
/// <summary>
/// 查询详情
/// </summary>
/// <param name="id">编号</param>
/// <returns></returns>
public async Task<InstallDO> Get(string id)
{
return await GetDO(id);
}
/// <summary>
/// 查询详情数据
/// </summary>
/// <param name="id">编号</param>
/// <returns></returns>
public async Task<InstallDO> GetDO(string id)
{
SplitDateId SplitDateId = new SplitDateId(id, 2);
return await Db.Queryable<InstallDO>().Where(x => x.Id == id).SplitTable(SplitDateId.StartDate, SplitDateId.EndDate)
.Mapper((x) =>
{
x.Steps = Db.Queryable<InstallStepDO>()
.Where(y => y.InstallId == id)
.OrderBy(y => y.Index)
.SplitTable(SplitDateId.StartDate, SplitDateId.EndDate)
.ToArray();
})
.SingleAsync();
}
#endregion
#region 查询步骤
/// <summary>
/// 查询步骤
/// </summary>
/// <param name="installId">编号</param>
/// <returns></returns>
public async Task<InstallStepDO[]> GetSteps(string installId)
{
return await GetStepsDO(installId);
}
/// <summary>
/// 查询步骤数据
/// </summary>
/// <param name="installId">编号</param>
/// <returns></returns>
public async Task<InstallStepDO[]> GetStepsDO(string installId)
{
SplitDateId SplitDateId = new SplitDateId(installId, 2);
return await Db.Queryable<InstallStepDO>().Where(x => x.InstallId == installId).OrderBy(x => x.Index).SplitTable(SplitDateId.StartDate, SplitDateId.EndDate)
.ToArrayAsync();
}
#endregion
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save