Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jyzb_local_platform
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
赵剑炜
jyzb_local_platform
Commits
841a13f9
Commit
841a13f9
authored
Sep 20, 2023
by
赵剑炜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加业务
parent
ea7f26b5
显示空白字符变更
内嵌
并排
正在显示
28 个修改的文件
包含
790 行增加
和
65 行删除
+790
-65
.editorconfig
WebApiNET6-master/.editorconfig
+4
-0
dotnet-tools.json
WebApiNET6-master/APIs/.config/dotnet-tools.json
+13
-0
APIs.csproj
WebApiNET6-master/APIs/APIs.csproj
+10
-0
BaseInfoController.cs
WebApiNET6-master/APIs/Controllers/BaseInfoController.cs
+226
-0
MapperController.cs
WebApiNET6-master/APIs/Controllers/MapperController.cs
+5
-5
MemoryController.cs
WebApiNET6-master/APIs/Controllers/MemoryController.cs
+1
-1
UserController.cs
WebApiNET6-master/APIs/Controllers/UserController.cs
+21
-21
EquipmentSizeDto.cs
WebApiNET6-master/APIs/Dto/EquipmentSizeDto.cs
+13
-0
EquipmentTypeDto.cs
WebApiNET6-master/APIs/Dto/EquipmentTypeDto.cs
+11
-0
UserDto.cs
WebApiNET6-master/APIs/Dto/UserDto.cs
+0
-7
SqlsugarSetup.cs
WebApiNET6-master/APIs/Extensions/SqlsugarSetup.cs
+1
-1
MapperProfile.cs
WebApiNET6-master/APIs/Profiles/MapperProfile.cs
+3
-1
Program.cs
WebApiNET6-master/APIs/Program.cs
+21
-3
FolderProfile.pubxml
WebApiNET6-master/APIs/Properties/PublishProfiles/FolderProfile.pubxml
+23
-0
launchSettings.json
WebApiNET6-master/APIs/Properties/launchSettings.json
+23
-5
CommonReq.cs
WebApiNET6-master/APIs/Req/CommonReq.cs
+7
-0
RecordsReq.cs
WebApiNET6-master/APIs/Req/RecordsReq.cs
+40
-0
Startup.cs
WebApiNET6-master/APIs/Startup.cs
+31
-1
appsettings.json
WebApiNET6-master/APIs/appsettings.json
+36
-7
Common.csproj
WebApiNET6-master/Common/Common.csproj
+2
-0
AdminGlobalContext.cs
WebApiNET6-master/Common/Global/AdminGlobalContext.cs
+20
-0
RabbitMQConfig.cs
WebApiNET6-master/Common/Global/RabbitMQConfig.cs
+44
-0
RecordsReq.cs
WebApiNET6-master/Common/Utility/Model/RecordsReq.cs
+40
-0
RabbitMQContext.cs
WebApiNET6-master/Common/Utility/RabbitMQ/RabbitMQContext.cs
+109
-0
RabbitMQCustomContext.cs
WebApiNET6-master/Common/Utility/RabbitMQ/RabbitMQCustomContext.cs
+68
-0
EquipmentSize.cs
WebApiNET6-master/Models/SqlModel/EquipmentSize.cs
+2
-3
ApiResult.cs
WebApiNET6-master/Models/ToolsModel/ApiResult.cs
+0
-5
WebApiNet6.sln
WebApiNET6-master/WebApiNet6.sln
+16
-5
没有找到文件。
WebApiNET6-master/.editorconfig
0 → 100644
View file @
841a13f9
[*.cs]
# CS8600: 将 null 字面量或可能为 null 的值转换为非 null 类型。
dotnet_diagnostic.CS8600.severity = none
WebApiNET6-master/APIs/.config/dotnet-tools.json
0 → 100644
View file @
841a13f9
{
"version"
:
1
,
"isRoot"
:
true
,
"tools"
:
{
"dotnet-ef"
:
{
"version"
:
"7.0.11"
,
"commands"
:
[
"dotnet-ef"
]
}
}
}
\ No newline at end of file
WebApiNET6-master/APIs/APIs.csproj
View file @
841a13f9
...
...
@@ -11,6 +11,10 @@
</ItemGroup>
<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="7.1.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
...
...
@@ -27,4 +31,10 @@
<ProjectReference Include="..\Services\Services.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Properties\launchSettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
WebApiNET6-master/APIs/Controllers/BaseInfoController.cs
0 → 100644
View file @
841a13f9
using
APIs.Common
;
using
APIs.Dto
;
using
APIs.Req
;
using
Autofac.Core
;
using
AutoMapper
;
using
Common.Utility.RabbitMQ
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc.ModelBinding
;
using
Models.SqlModel
;
using
Models.ToolsModel
;
using
Newtonsoft.Json
;
using
Services
;
using
Services.Interface
;
using
static
Microsoft
.
AspNetCore
.
Razor
.
Language
.
TagHelperMetadata
;
namespace
APIs.Controllers
{
[
Route
(
"api/[controller]/[action]"
)]
[
ApiController
]
public
class
BaseInfoController
:
ControllerBase
{
public
IMapper
Mapper
{
get
;
}
private
readonly
IPoliceService
_policeService
;
private
readonly
IEquipmentTypeService
_equipmentTypeService
;
private
readonly
IEquipmentSizeService
_equipmentSizeService
;
private
readonly
ICarService
_carService
;
public
BaseInfoController
(
IMapper
mapper
,
IPoliceService
policeService
,
IEquipmentTypeService
equipmentTypeService
,
IEquipmentSizeService
equipmentSizeService
,
ICarService
carService
)
{
_carService
=
carService
;
_equipmentSizeService
=
equipmentSizeService
;
_equipmentTypeService
=
equipmentTypeService
;
_policeService
=
policeService
;
Mapper
=
mapper
;
}
/// <summary>
/// 查询人员信息
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[
HttpPost
]
public
virtual
async
Task
<
ApiResult
>
GetAllPersonnel
([
FromBody
]
CommonReq
req
)
{
try
{
DateTime
reqTime
=
DateTime
.
MinValue
;
if
(!
string
.
IsNullOrEmpty
(
req
.
updateTime
))
{
reqTime
=
DateTime
.
Parse
(
req
.
updateTime
);
}
var
police
=
await
_policeService
.
Query
(
p
=>
p
.
updateTime
>=
reqTime
);
var
src
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_SUCCESS
.
Code
,
msg
=
ResultCode
.
OPERATE_SUCCESS
.
Msg
,
data
=
police
};
return
src
;
}
catch
(
Exception
ex
)
{
var
error
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
ex
.
Message
,
};
return
error
;
}
}
/// <summary>
/// 查询装备类型信息
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
async
Task
<
string
>
GetEquipmentType
([
FromBody
]
CommonReq
req
)
{
try
{
DateTime
reqTime
=
DateTime
.
MinValue
;
if
(!
string
.
IsNullOrEmpty
(
req
.
updateTime
))
{
reqTime
=
DateTime
.
Parse
(
req
.
updateTime
);
}
var
typeQuery
=
await
_equipmentSizeService
.
Query
(
p
=>
p
.
updateTime
>=
reqTime
);
List
<
EquipmentTypeDto
>
typeDto
=
new
List
<
EquipmentTypeDto
>()
;
Mapper
.
Map
(
typeQuery
,
typeDto
);
var
src
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_SUCCESS
.
Code
,
msg
=
ResultCode
.
OPERATE_SUCCESS
.
Msg
,
data
=
typeDto
};
return
JsonConvert
.
SerializeObject
(
src
);
}
catch
(
Exception
ex
)
{
var
error
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
ex
.
Message
,
};
return
JsonConvert
.
SerializeObject
(
error
);
}
}
/// <summary>
/// 查询装备号型信息
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
async
Task
<
string
>
GetEquipmentSize
([
FromBody
]
CommonReq
req
)
{
try
{
DateTime
reqTime
=
DateTime
.
MinValue
;
if
(!
string
.
IsNullOrEmpty
(
req
.
updateTime
))
{
reqTime
=
DateTime
.
Parse
(
req
.
updateTime
);
}
var
sizeQuery
=
await
_equipmentSizeService
.
Query
(
p
=>
p
.
updateTime
>=
reqTime
);
List
<
EquipmentSizeDto
>
sizeDto
=
new
List
<
EquipmentSizeDto
>();
Mapper
.
Map
(
sizeQuery
,
sizeDto
);
var
src
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_SUCCESS
.
Code
,
msg
=
ResultCode
.
OPERATE_SUCCESS
.
Msg
,
data
=
sizeDto
};
return
JsonConvert
.
SerializeObject
(
src
);
}
catch
(
Exception
ex
)
{
var
error
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
ex
.
Message
,
};
return
JsonConvert
.
SerializeObject
(
error
);
}
}
/// <summary>
/// 查询车辆信息
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
async
Task
<
string
>
GetCar
([
FromBody
]
CommonReq
req
)
{
try
{
DateTime
reqTime
=
DateTime
.
MinValue
;
if
(!
string
.
IsNullOrEmpty
(
req
.
updateTime
))
{
reqTime
=
DateTime
.
Parse
(
req
.
updateTime
);
}
var
carQuery
=
await
_carService
.
Query
(
p
=>
p
.
updateTime
>=
reqTime
);
var
src
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_SUCCESS
.
Code
,
msg
=
ResultCode
.
OPERATE_SUCCESS
.
Msg
,
data
=
carQuery
};
return
JsonConvert
.
SerializeObject
(
src
);
}
catch
(
Exception
ex
)
{
var
error
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_FAILED
.
Code
,
msg
=
ex
.
Message
,
};
return
JsonConvert
.
SerializeObject
(
error
);
}
}
/// <summary>
/// 查询当前时间信息
/// </summary>
/// <returns></returns>
[
HttpGet
]
public
async
Task
<
string
>
GetTime
()
{
DateTime
reqTime
=
DateTime
.
Now
;
return
JsonConvert
.
SerializeObject
(
reqTime
.
ToString
(
"yyyy-MM-dd"
));
}
/// <summary>
/// 发送消息队列测试
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
async
Task
<
string
>
SendMQ
([
FromBody
(
EmptyBodyBehavior
=
EmptyBodyBehavior
.
Allow
)]
RecordsReq
req
)
{
await
RabbitMQContext
.
SendMessageAsynce
(
JsonConvert
.
SerializeObject
(
req
));
var
src
=
new
ApiResult
{
code
=
ResultCode
.
OPERATE_SUCCESS
.
Code
,
msg
=
ResultCode
.
OPERATE_SUCCESS
.
Msg
};
return
JsonConvert
.
SerializeObject
(
src
);
}
}
}
WebApiNET6-master/APIs/Controllers/MapperController.cs
View file @
841a13f9
...
...
@@ -6,7 +6,7 @@ using Services.Interface;
namespace
APIs.Controllers
{
[
Route
(
"api/[controller]"
)]
[
Route
(
"api/[controller]
/[action]
"
)]
[
ApiController
]
public
class
MapperController
:
ControllerBase
{
...
...
@@ -21,17 +21,17 @@ namespace APIs.Controllers
}
[
HttpPost
]
public
User
Dto
Test
(
Users
user
)
public
EquipmentType
Dto
Test
(
Users
user
)
{
var
userDto
=
new
User
Dto
();
var
userDto
=
new
EquipmentType
Dto
();
Mapper
.
Map
(
user
,
userDto
);
return
userDto
;
}
[
HttpGet
]
public
User
Dto
GetTest
()
public
EquipmentType
Dto
GetTest
()
{
var
userDto
=
new
User
Dto
();
var
userDto
=
new
EquipmentType
Dto
();
List
<
Users
>
aa
=
_tService
.
GetData
();
Mapper
.
Map
(
aa
,
userDto
);
return
userDto
;
...
...
WebApiNET6-master/APIs/Controllers/MemoryController.cs
View file @
841a13f9
...
...
@@ -3,7 +3,7 @@ using Microsoft.Extensions.Caching.Memory;
namespace
APIs.Controllers
{
[
Route
(
"api/[controller]"
)]
[
Route
(
"api/[controller]
/[action]
"
)]
[
ApiController
]
public
class
MemoryController
:
ControllerBase
{
...
...
WebApiNET6-master/APIs/Controllers/UserController.cs
View file @
841a13f9
...
...
@@ -10,9 +10,9 @@ using Services.Interface;
namespace
APIs.Controllers
{
[
Route
(
"api/[controller]"
)]
[
Route
(
"api/[controller]
/[action]
"
)]
[
ApiController
]
public
class
UserController
:
Controller
public
class
UserController
:
Controller
Base
{
public
IMapper
Mapper
{
get
;
}
private
readonly
IPoliceService
_policeService
;
...
...
@@ -22,27 +22,27 @@ namespace APIs.Controllers
Mapper
=
mapper
;
}
[
HttpGet
]
public
virtual
async
Task
<
HttpResponseMessage
>
GetAllPersonnel
()
{
//
[HttpGet]
//
public virtual async Task<HttpResponseMessage> GetAllPersonnel()
//
{
try
{
//var userDto = new UserDto();
var
police
=
await
_policeService
.
Query
();
return
JsonManager
.
ReturnSuccessResponse
(
police
);
}
catch
(
Exception
ex
)
{
ResultInfo
info
=
new
ResultInfo
()
{
Msg
=
ex
.
Message
,
Code
=
"19999"
};
return
JsonManager
.
SimpleStatusResponse
(
info
);
}
//
try
//
{
//
//var userDto = new UserDto();
//
var police = await _policeService.Query();
//
return JsonManager.ReturnSuccessResponse(police);
//
}
//
catch (Exception ex)
//
{
//
ResultInfo info = new ResultInfo()
//
{
//
Msg = ex.Message,
//
Code = "19999"
//
};
//
return JsonManager.SimpleStatusResponse(info);
//
}
}
//
}
...
...
WebApiNET6-master/APIs/Dto/EquipmentSizeDto.cs
0 → 100644
View file @
841a13f9
namespace
APIs.Dto
{
public
class
EquipmentSizeDto
{
public
String
id
{
get
;
set
;
}
public
String
name
{
get
;
set
;
}
public
String
code
{
get
;
set
;
}
public
String
typeId
{
get
;
set
;
}
public
String
typeName
{
get
;
set
;
}
public
DateTime
updateTime
{
get
;
set
;
}
public
DateTime
createTime
{
get
;
set
;
}
}
}
WebApiNET6-master/APIs/Dto/EquipmentTypeDto.cs
0 → 100644
View file @
841a13f9
namespace
APIs.Dto
;
public
class
EquipmentTypeDto
{
public
String
id
{
get
;
set
;
}
public
String
name
{
get
;
set
;
}
public
String
code
{
get
;
set
;
}
public
DateTime
updateTime
{
get
;
set
;
}
public
DateTime
createTime
{
get
;
set
;
}
}
\ No newline at end of file
WebApiNET6-master/APIs/Dto/UserDto.cs
deleted
100644 → 0
View file @
ea7f26b5
namespace
APIs.Dto
;
public
class
UserDto
{
public
int
Id
{
get
;
set
;
}
}
\ No newline at end of file
WebApiNET6-master/APIs/Extensions/SqlsugarSetup.cs
View file @
841a13f9
...
...
@@ -7,7 +7,7 @@ public static class SqlsugarSetup
public
static
void
AddSqlsugarSetup
(
this
IServiceCollection
services
,
IConfiguration
configuration
,
string
dbName
=
"MySQL"
)
{
var
a
=
configuration
.
GetConnectionString
(
dbName
);
services
.
AddScoped
<
ISqlSugarClient
>(
o
=>
{
var
listConfig
=
new
List
<
ConnectionConfig
>();
...
...
WebApiNET6-master/APIs/Profiles/MapperProfile.cs
View file @
841a13f9
...
...
@@ -8,6 +8,7 @@ public class MapperProfile : Profile
{
public
MapperProfile
()
{
CreateMap
<
User
,
UserDto
>().
ForMember
(
dest
=>
dest
.
Id
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
Id
));
CreateMap
<
EquipmentType
,
EquipmentTypeDto
>().
ForMember
(
dest
=>
dest
.
id
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
id
));
CreateMap
<
EquipmentSize
,
EquipmentSizeDto
>().
ForMember
(
dest
=>
dest
.
id
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
id
));
}
}
\ No newline at end of file
WebApiNET6-master/APIs/Program.cs
View file @
841a13f9
...
...
@@ -6,6 +6,7 @@ using System.Xml.Linq;
using
APIs
;
using
APIs.Extensions
;
using
APIs.Profiles
;
using
Autofac.Core
;
using
Autofac.Extensions.DependencyInjection
;
using
Common
;
using
FluentValidation.AspNetCore
;
...
...
@@ -32,12 +33,15 @@ public class Program
var
logger
=
NLogBuilder
.
ConfigureNLog
(
"nlog.config"
).
GetCurrentClassLogger
();
try
{
logger
.
Debug
(
"--------------init main--------------"
);
Console
.
WriteLine
(
$"[
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm"
)}
]"
+
"--------------init main--------------"
);
Console
.
WriteLine
(
"ɹ"
);
CreateHostBuilder
(
args
).
Build
().
Run
();
}
catch
(
Exception
exception
)
{
logger
.
Error
(
exception
,
"--------------Stopped program because of exception--------------"
);
Console
.
WriteLine
(
""
+
exception
);
throw
;
}
finally
...
...
@@ -46,17 +50,30 @@ public class Program
}
}
public
static
IHostBuilder
CreateHostBuilder
(
string
[]
args
)
=>
Host
.
CreateDefaultBuilder
(
args
)
public
static
IHostBuilder
CreateHostBuilder
(
string
[]
args
)
{
var
configuration
=
new
ConfigurationBuilder
()
.
SetBasePath
(
Directory
.
GetCurrentDirectory
())
.
AddJsonFile
(
"appsettings.json"
,
optional
:
false
)
.
Build
();
return
Host
.
CreateDefaultBuilder
(
args
)
.
UseServiceProviderFactory
(
new
AutofacServiceProviderFactory
())
.
ConfigureWebHostDefaults
(
webBuilder
=>
{
webBuilder
.
UseStartup
<
Startup
>();
webBuilder
.
UseUrls
(
configuration
[
"Launch"
]);
})
.
ConfigureLogging
(
logging
=>
{
logging
.
ClearProviders
();
logging
.
SetMinimumLevel
(
LogLevel
.
Trace
);
})
.
UseNLog
();
}
}
\ No newline at end of file
WebApiNET6-master/APIs/Properties/PublishProfiles/FolderProfile.pubxml
0 → 100644
View file @
841a13f9
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>false</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<ProjectGuid>50472ac8-0769-43fd-9559-dfaf7c616b47</ProjectGuid>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>
\ No newline at end of file
WebApiNET6-master/APIs/Properties/launchSettings.json
View file @
841a13f9
{
"$schema"
:
"https://json.schemastore.org/launchsettings.json"
,
{
"iisSettings"
:
{
"windowsAuthentication"
:
true
,
"anonymousAuthentication"
:
true
,
"iisExpress"
:
{
"applicationUrl"
:
"http://localhost:5133"
,
"sslPort"
:
5133
}
},
"$schema"
:
"http://json.schemastore.org/launchsettings.json"
,
"profiles"
:
{
"IIS Express"
:
{
"commandName"
:
"IISExpress"
,
"launchBrowser"
:
true
,
"launchUrl"
:
"swagger"
,
"environmentVariables"
:
{
"ASPNETCORE_ENVIRONMENT"
:
"Development"
},
"applicationUrl"
:
"http://localhost:5133;http://localhost:5143;"
},
"APIs"
:
{
"commandName"
:
"Project"
,
"dotnetRunMessages"
:
true
,
"launchBrowser"
:
true
,
"launchUrl"
:
"swagger"
,
"applicationUrl"
:
"http://localhost:5133"
,
"environmentVariables"
:
{
"ASPNETCORE_ENVIRONMENT"
:
"Development"
}
},
"applicationUrl"
:
"http://localhost:5133;http://localhost:5143;"
}
}
}
WebApiNET6-master/APIs/Req/CommonReq.cs
0 → 100644
View file @
841a13f9
namespace
APIs.Req
{
public
class
CommonReq
{
public
String
updateTime
{
get
;
set
;
}
}
}
WebApiNET6-master/APIs/Req/RecordsReq.cs
0 → 100644
View file @
841a13f9
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc.ModelBinding
;
using
System.ComponentModel.DataAnnotations
;
using
System.Diagnostics.CodeAnalysis
;
namespace
APIs.Req
{
public
class
RecordsReq
{
public
String
id
{
get
;
set
;
}
public
DateTime
useTime
{
get
;
set
;
}
public
String
userName
{
get
;
set
;
}
public
String
type
{
get
;
set
;
}
public
String
equipments
{
get
;
set
;
}
[
FromBody
]
public
List
<
EquipmentList
>
equipmentList
{
get
;
set
;
}
[
FromBody
]
public
List
<
CarList
>
carList
{
get
;
set
;
}
//
}
public
class
EquipmentList
{
public
String
epc
{
get
;
set
;
}
public
String
equipmentName
{
get
;
set
;
}
public
String
equipmentSize
{
get
;
set
;
}
public
String
outInState
{
get
;
set
;
}
public
String
errorState
{
get
;
set
;
}
}
public
class
CarList
{
public
String
carId
{
get
;
set
;
}
public
String
outInState
{
get
;
set
;
}
public
String
errorState
{
get
;
set
;
}
}
}
WebApiNET6-master/APIs/Startup.cs
View file @
841a13f9
...
...
@@ -14,6 +14,9 @@ using APIs.Extensions;
using
FluentValidation.AspNetCore
;
using
Repositories.IRepository.IUnitOfWork
;
using
Repositories.Repository.UnitOfWork
;
using
Common.Utility.RabbitMQ
;
using
Common.Global
;
using
System.Xml.Linq
;
namespace
APIs
{
...
...
@@ -47,12 +50,21 @@ namespace APIs
services
.
AddScoped
<
IPoliceService
,
PoliceService
>();
services
.
AddScoped
<
ICarService
,
CarService
>();
services
.
AddScoped
<
IEquipmentSizeService
,
EquipmentSizeService
>();
//
services.AddScoped<IEquipmentTypeService, EquipmentTypeService>();
services
.
AddScoped
<
IEquipmentTypeService
,
EquipmentTypeService
>();
services
.
AddScoped
<
IPoliceRepository
,
PoliceRepository
>();
services
.
AddScoped
<
ICarRepository
,
CarRepository
>();
services
.
AddScoped
<
IEquipmentSizeRepository
,
EquipmentSizeRepository
>();
services
.
AddScoped
<
IEquipmentTypeRepository
,
EquipmentTypeRepository
>();
#
region
注册
RabbitMQ
消费者
services
.
AddHostedService
<
RabbitMQCustomContext
>();
#
endregion
#
region
初始化全局配置信息
InitConfiguration
(
Configuration
);
#
endregion
services
.
AddFluentValidation
(
options
=>
{
options
.
RegisterValidatorsFromAssembly
(
Assembly
.
GetExecutingAssembly
());
...
...
@@ -76,7 +88,25 @@ namespace APIs
}
#
region
初始化全局静态配置
/// <summary>
/// 初始化全局静态配置
/// </summary>
private
void
InitConfiguration
(
IConfiguration
configuration
)
{
RabbitMQConfig
rabbits
=
new
RabbitMQConfig
();
rabbits
.
Port
=
int
.
Parse
(
configuration
.
GetSection
(
"RabbitMQConfig:Port"
).
Value
);
rabbits
.
QueueName
=
configuration
.
GetSection
(
"RabbitMQConfig:QueueName"
).
Value
;
rabbits
.
HostName
=
configuration
.
GetSection
(
"RabbitMQConfig:HostName"
).
Value
;
rabbits
.
ExchangeName
=
configuration
.
GetSection
(
"RabbitMQConfig:ExchangeName"
).
Value
;
rabbits
.
UserName
=
configuration
.
GetSection
(
"RabbitMQConfig:UserName"
).
Value
;
rabbits
.
Password
=
configuration
.
GetSection
(
"RabbitMQConfig:Password"
).
Value
;
AdminGlobalContext
.
RabbitMQConfig
=
rabbits
;
}
#
endregion
public
void
Configure
(
IApplicationBuilder
app
,
IWebHostEnvironment
env
)
{
...
...
WebApiNET6-master/APIs/appsettings.json
View file @
841a13f9
{
"Logging"
:
{
"LogLevel"
:
{
"Default"
:
"Information"
,
"Microsoft.AspNetCore"
:
"Warning"
"Default"
:
"Debug"
,
"Microsoft"
:
"Information"
,
"Information"
:
"Information"
}
},
"Launch"
:
"http://*:5233;http://*:5243"
,
"AllowedHosts"
:
"*"
,
"ConnectionStrings"
:
{
"MySQL"
:
"server=192.168.3.128;port=3306;Database=xuzhou;Uid=junmp;Pwd=123456;"
//RabbitMQ配置
},
"RabbitMQConfig"
:
{
//用户名
"UserName"
:
"root"
,
//密码
"Password"
:
"123456"
,
//ip地址,多个时以英文“
,
”分割
"HostName"
:
"192.168.3.188"
,
//端口
"Port"
:
5672
,
//虚拟队列名称
"QueueName"
:
"cabinet"
,
//虚拟交换机名称
"ExchangeName"
:
"uploadRecords"
},
"RabbitMQConfigCreate"
:
{
//生产者消息队列,后期可以建设多个队列名称
//用户名
"UserName"
:
"root"
,
//密码
"Password"
:
"123456"
,
//ip地址,多个时以英文“
,
”分割
"HostName"
:
"192.168.3.188"
,
//端口
"Port"
:
5672
,
//虚拟队列名称
"QueueName"
:
"cabinet"
,
//虚拟交换机名称
"ExchangeName"
:
"uploadRecords"
}
//
"Jwt"
:
{
//
"Secret"
:
"f30386a4fc41d3c1a75cd7f3de54c48c"
,
//
"Issuer"
:
"Atlantis"
,
//
"Audience"
:
"Atlantis"
//
}
}
WebApiNET6-master/Common/Common.csproj
View file @
841a13f9
...
...
@@ -7,8 +7,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.8.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="RabbitMQ.Client" Version="6.5.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.8.0" />
</ItemGroup>
...
...
WebApiNET6-master/Common/Global/AdminGlobalContext.cs
0 → 100644
View file @
841a13f9
using
Microsoft.Extensions.Configuration
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Common.Global
{
/// <summary>
/// 全局配置
/// </summary>
public
class
AdminGlobalContext
{
/// <summary>
/// RabbitMQ配置
/// </summary>
public
static
RabbitMQConfig
RabbitMQConfig
{
get
;
set
;
}
}
}
WebApiNET6-master/Common/Global/RabbitMQConfig.cs
0 → 100644
View file @
841a13f9
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Common.Global
{
/// <summary>
/// RabbitMQ配置
/// </summary>
public
class
RabbitMQConfig
{
/// <summary>
/// 用户名
/// </summary>
public
String
?
UserName
{
get
;
set
;
}
/// <summary>
/// 密码
/// </summary>
public
String
?
Password
{
get
;
set
;
}
/// <summary>
/// ip地址,多个时以英文“,”分割
/// </summary>
public
String
?
HostName
{
get
;
set
;
}
/// <summary>
/// 端口
/// </summary>
public
int
Port
{
get
;
set
;
}
/// <summary>
/// 虚拟队列名称
/// </summary>
public
String
?
QueueName
{
get
;
set
;
}
/// <summary>
/// 虚拟交换机名称
/// </summary>
public
String
?
ExchangeName
{
get
;
set
;
}
}
}
WebApiNET6-master/Common/Utility/Model/RecordsReq.cs
0 → 100644
View file @
841a13f9
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Common.Utility.Model
{
public
class
RecordsReq
{
public
String
id
{
get
;
set
;
}
public
DateTime
useTime
{
get
;
set
;
}
public
String
userName
{
get
;
set
;
}
public
String
type
{
get
;
set
;
}
public
String
equipments
{
get
;
set
;
}
public
List
<
EquipmentList
>
equipmentList
{
get
;
set
;
}
public
List
<
CarList
>
carList
{
get
;
set
;
}
//
}
public
class
EquipmentList
{
public
String
epc
{
get
;
set
;
}
public
String
equipmentName
{
get
;
set
;
}
public
String
equipmentSize
{
get
;
set
;
}
public
String
outInState
{
get
;
set
;
}
public
String
errorState
{
get
;
set
;
}
}
public
class
CarList
{
public
String
carId
{
get
;
set
;
}
public
String
outInState
{
get
;
set
;
}
public
String
errorState
{
get
;
set
;
}
}
}
WebApiNET6-master/Common/Utility/RabbitMQ/RabbitMQContext.cs
0 → 100644
View file @
841a13f9
using
Common.Global
;
using
RabbitMQ.Client
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Common.Utility.RabbitMQ
{
/// <summary>
/// RabbitMQ工具类
/// </summary>
public
class
RabbitMQContext
{
/// <summary>
/// 私有化构造函数
/// 用于单例模式
/// </summary>
private
RabbitMQContext
()
{
}
/// <summary>
/// Lazy对象
/// </summary>
private
static
readonly
Lazy
<
IConnection
>
LazyConnection
=
new
Lazy
<
IConnection
>(()
=>
{
ConnectionFactory
factory
=
null
;
IConnection
connection
=
null
;
#
region
初始工厂类
if
(
AdminGlobalContext
.
RabbitMQConfig
.
HostName
.
Contains
(
","
))
{
//创建连接对象工厂
factory
=
new
ConnectionFactory
()
{
UserName
=
AdminGlobalContext
.
RabbitMQConfig
.
UserName
,
Password
=
AdminGlobalContext
.
RabbitMQConfig
.
Password
,
AutomaticRecoveryEnabled
=
true
,
//如果connection挂掉是否重新连接
TopologyRecoveryEnabled
=
true
//连接恢复后,连接的交换机,队列等是否一同恢复
};
//创建连接对象
connection
=
factory
.
CreateConnection
(
AdminGlobalContext
.
RabbitMQConfig
.
HostName
.
Split
(
','
));
}
else
{
//创建连接对象工厂
factory
=
new
ConnectionFactory
()
{
UserName
=
AdminGlobalContext
.
RabbitMQConfig
.
UserName
,
Password
=
AdminGlobalContext
.
RabbitMQConfig
.
Password
,
HostName
=
AdminGlobalContext
.
RabbitMQConfig
.
HostName
,
Port
=
AdminGlobalContext
.
RabbitMQConfig
.
Port
,
RequestedHeartbeat
=
TimeSpan
.
FromSeconds
(
30
),
//心跳包
AutomaticRecoveryEnabled
=
true
,
//自动重连
TopologyRecoveryEnabled
=
true
,
//拓普重连
NetworkRecoveryInterval
=
TimeSpan
.
FromSeconds
(
10
)
};
//创建连接对象
connection
=
factory
.
CreateConnection
();
}
#
endregion
return
connection
;
});
/// <summary>
/// 单例对象
/// </summary>
public
static
IConnection
ConnectionInstance
{
get
{
return
LazyConnection
.
Value
;
}
}
/// <summary>
/// 是否已创建
/// </summary>
public
static
bool
IsConnectionInstanceCreated
{
get
{
return
LazyConnection
.
IsValueCreated
;
}
}
/// <summary>
/// 发送消息
/// </summary>
/// <param name="message">消息体</param>
public
static
void
SendMessage
(
string
message
)
{
IConnection
connection
=
ConnectionInstance
;
//定义通道
var
channel
=
connection
.
CreateModel
();
//如果只有生产者,则使用以下注释内容,作为单例使用
//定义交换机
//channel.ExchangeDeclare(AdminGlobalContext.RabbitMQConfig.ExchangeName, ExchangeType.Fanout, true, false);
////定义队列
//channel.QueueDeclare(AdminGlobalContext.RabbitMQConfig.QueueName, false, false, false, null);
////将队列绑定到交换机
//channel.QueueBind(AdminGlobalContext.RabbitMQConfig.QueueName, AdminGlobalContext.RabbitMQConfig.ExchangeName, "", null);
//发布消息
channel
.
BasicPublish
(
AdminGlobalContext
.
RabbitMQConfig
.
ExchangeName
,
""
,
null
,
Encoding
.
Default
.
GetBytes
(
message
));
}
/// <summary>
/// 异步发送消息
/// </summary>
/// <param name="message">消息体</param>
/// <returns></returns>
public
static
async
Task
SendMessageAsynce
(
string
message
)
{
await
Task
.
Run
(()
=>
SendMessage
(
message
));
}
}
}
WebApiNET6-master/Common/Utility/RabbitMQ/RabbitMQCustomContext.cs
0 → 100644
View file @
841a13f9
using
RabbitMQ.Client.Events
;
using
RabbitMQ.Client
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Microsoft.Extensions.Hosting
;
using
Common.Global
;
using
Newtonsoft.Json
;
using
Common.Utility.Model
;
namespace
Common.Utility.RabbitMQ
{
public
class
RabbitMQCustomContext
:
BackgroundService
{
ConnectionFactory
factory
=
null
;
IConnection
connection
=
null
;
protected
override
async
Task
ExecuteAsync
(
CancellationToken
stoppingToken
)
{
try
{
//创建连接对象工厂
factory
=
new
ConnectionFactory
()
{
UserName
=
AdminGlobalContext
.
RabbitMQConfig
.
UserName
,
Password
=
AdminGlobalContext
.
RabbitMQConfig
.
Password
,
HostName
=
AdminGlobalContext
.
RabbitMQConfig
.
HostName
,
Port
=
AdminGlobalContext
.
RabbitMQConfig
.
Port
,
RequestedHeartbeat
=
TimeSpan
.
FromSeconds
(
30
),
//心跳包
AutomaticRecoveryEnabled
=
true
,
//自动重连
TopologyRecoveryEnabled
=
true
,
//拓普重连
NetworkRecoveryInterval
=
TimeSpan
.
FromSeconds
(
10
)
};
//创建连接对象
connection
=
factory
.
CreateConnection
();
IModel
channel
=
connection
.
CreateModel
();
channel
.
ExchangeDeclare
(
AdminGlobalContext
.
RabbitMQConfig
.
ExchangeName
,
ExchangeType
.
Fanout
);
channel
.
QueueDeclare
(
AdminGlobalContext
.
RabbitMQConfig
.
QueueName
,
false
,
false
,
false
,
null
);
channel
.
QueueBind
(
AdminGlobalContext
.
RabbitMQConfig
.
QueueName
,
AdminGlobalContext
.
RabbitMQConfig
.
ExchangeName
,
""
,
null
);
var
consumer
=
new
EventingBasicConsumer
(
channel
);
consumer
.
Received
+=
(
ch
,
ea
)
=>
{
var
body
=
ea
.
Body
.
ToArray
();
string
str
=
Encoding
.
UTF8
.
GetString
(
body
);
RecordsReq
req
=
JsonConvert
.
DeserializeObject
<
RecordsReq
>(
str
);
Console
.
WriteLine
(
"接受到的mq消息:"
+
str
);
channel
.
BasicAck
(
ea
.
DeliveryTag
,
false
);
//Thread.Sleep(1000);
};
string
consumerTag
=
channel
.
BasicConsume
(
AdminGlobalContext
.
RabbitMQConfig
.
QueueName
,
false
,
consumer
);
}
catch
(
Exception
)
{
throw
;
}
}
}
}
WebApiNET6-master/Models/SqlModel/EquipmentSize.cs
View file @
841a13f9
...
...
@@ -18,11 +18,10 @@ namespace Models.SqlModel
public
String
code
{
get
;
set
;
}
public
String
unit
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"type_id"
)]
public
String
?
typeId
{
get
;
set
;
}
public
String
?
n
ame
{
get
;
set
;
}
[
SugarColumn
(
ColumnName
=
"name"
)]
public
String
?
typeN
ame
{
get
;
set
;
}
public
String
?
note
{
get
;
set
;
}
...
...
WebApiNET6-master/Models/ToolsModel/ApiResult.cs
View file @
841a13f9
...
...
@@ -10,21 +10,16 @@ namespace Models.ToolsModel
{
public
ApiResult
()
{
IsSuccess
=
true
;
code
=
"200"
;
msg
=
""
;
data
=
""
;
}
public
bool
IsSuccess
{
get
;
set
;
}
public
string
code
{
get
;
set
;
}
//public int statusCode { get; set; }
public
object
data
{
get
;
set
;
}
public
string
msg
{
get
;
set
;
}
#
region
list
info
public
int
page
{
get
;
set
;
}
public
int
count
{
get
;
set
;
}
public
int
total
{
get
;
set
;
}
#
endregion
...
...
WebApiNET6-master/WebApiNet6.sln
View file @
841a13f9
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "APIs", "APIs\APIs.csproj", "{50472AC8-0769-43FD-9559-DFAF7C616B47}"
# Visual Studio Version 17
VisualStudioVersion = 17.5.33414.496
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "APIs", "APIs\APIs.csproj", "{50472AC8-0769-43FD-9559-DFAF7C616B47}"
EndProject
Project("{
FAE04EC0-301F-11D3-BF4B-00C04F79EFBC
}") = "Models", "Models\Models.csproj", "{7E5B59D3-5DFA-460F-8DC4-C2A10C7E555E}"
Project("{
9A19103F-16F7-4668-BE54-9A1E7A4F7556
}") = "Models", "Models\Models.csproj", "{7E5B59D3-5DFA-460F-8DC4-C2A10C7E555E}"
EndProject
Project("{
FAE04EC0-301F-11D3-BF4B-00C04F79EFBC
}") = "Repositories", "Repositories\Repositories.csproj", "{73D6C350-8596-424A-B52B-D5DEBEE196C4}"
Project("{
9A19103F-16F7-4668-BE54-9A1E7A4F7556
}") = "Repositories", "Repositories\Repositories.csproj", "{73D6C350-8596-424A-B52B-D5DEBEE196C4}"
EndProject
Project("{
FAE04EC0-301F-11D3-BF4B-00C04F79EFBC
}") = "Services", "Services\Services.csproj", "{076E47FF-99EB-4C5B-82D8-272AD9DBE6AC}"
Project("{
9A19103F-16F7-4668-BE54-9A1E7A4F7556
}") = "Services", "Services\Services.csproj", "{076E47FF-99EB-4C5B-82D8-272AD9DBE6AC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{094E8D69-7AFA-4C76-9419-83F1DFF4944D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common", "Common\Common.csproj", "{094E8D69-7AFA-4C76-9419-83F1DFF4944D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7442AAAF-4E95-4765-AF7A-51907D6E09BA}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
...
...
@@ -37,4 +45,7 @@ Global
{094E8D69-7AFA-4C76-9419-83F1DFF4944D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{094E8D69-7AFA-4C76-9419-83F1DFF4944D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论