Skip to content

Commit

Permalink
修改
Browse files Browse the repository at this point in the history
  • Loading branch information
maikebing committed Feb 17, 2024
1 parent 34ec12f commit bbc8abe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion IoTSharp/Dockerfile
Expand Up @@ -28,7 +28,7 @@ RUN apt-get update && apt-get install -y ca-certificates curl gnupg && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
NODE_MAJOR=20 && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && apt-get install nodejs -y && \
apt-get update && apt-get install nodejs -y && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
npm config set registry https://registry.npmmirror.com && \
export NODE_OPTIONS=--openssl-legacy-provider && \
Expand Down
11 changes: 5 additions & 6 deletions IoTSharp/Extensions/CachingExtension.cs
Expand Up @@ -9,20 +9,19 @@ namespace IoTSharp.Extensions
{
public static class CachingExtension
{

public static HomeKanbanDto GetKanBanCache(this IEasyCachingProvider _caching, Guid tid, ApplicationDbContext _context)
public static HomeKanbanDto GetKanBanCache(this IEasyCachingProvider _caching, Guid tid, ApplicationDbContext _context)
{
var kbc= _caching.Get($"{nameof(HomeKanbanDto)}{tid}", () =>
var kbc = _caching.Get($"{nameof(HomeKanbanDto)}{tid}", () =>
{
HomeKanbanDto m = new();
m.DeviceCount = _context.Device.Count(c => c.Tenant.Id == tid && !c.Deleted);
m.EventCount = _context.BaseEvents.Count(c => c.Tenant.Id == tid && c.CreaterDateTime.CompareTo(DateTime.Today) >= 0 && c.EventStaus > -1);
m.EventCount = _context.BaseEvents.Count(c => c.Tenant.Id == tid && c.CreaterDateTime > DateTime.Today.ToUniversalTime() && c.EventStaus > -1);
var query = from c in _context.Device where c.Tenant.Id == tid && !c.Deleted select c;
var al = from a in _context.AttributeLatest where a.KeyName == Constants._Active && a.Value_Boolean == true select a.DeviceId;
var devquery = from x in query where al.Contains(x.Id) select x;
m.OnlineDeviceCount = devquery.Count();
m.AttributesDataCount = _context.AttributeLatest.Count(c => c.DateTime.CompareTo(DateTime.Today) >= 0);
m.AlarmsCount = _context.Alarms.Count(c => c.Tenant.Id == tid && c.StartDateTime.CompareTo(DateTime.Today) >= 0);
m.AttributesDataCount = _context.AttributeLatest.Count(c => c.DateTime > DateTime.Today.ToUniversalTime());
m.AlarmsCount = _context.Alarms.Count(c => c.Tenant.Id == tid && c.StartDateTime > DateTime.Today.ToUniversalTime());
var tuc = from t in _context.UserClaims where t.ClaimType == IoTSharpClaimTypes.Tenant select t;
var uq = from u in _context.Users where tuc.Any(c => c.UserId == u.Id) select u;
m.UserCount = uq.Count();
Expand Down

0 comments on commit bbc8abe

Please sign in to comment.