fix 二维码校验设备权限
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
// using Dlhis.Entity.Basic.Entity;
|
||||
// using Dlhis.Entity.Device.Entities;
|
||||
// using Dlhis.Entity.Device.Enums;
|
||||
// using Dlhis.Entity.Sys.Entities;
|
||||
// using Dlhis.Entity.Sys.Enums;
|
||||
// using Dlhis.Entity.Visitor.Entity;
|
||||
// using Dlhis.Entity.Visitor.Enums;
|
||||
// using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
// using SqlSugar;
|
||||
//
|
||||
// namespace Dlhis.Basic.Organization.Services.Implements;
|
||||
//
|
||||
// public class SapBusinessTripService : ISapBusinessTripService
|
||||
// {
|
||||
// private readonly IJinkoJipService _jinkoJipService;
|
||||
// private readonly IDbContext _dbContext;
|
||||
// private readonly ILogger<SapBusinessTripService> _logger;
|
||||
//
|
||||
// public SapBusinessTripService(IJinkoJipService jinkoJipService, IDbContext dbContext , ILogger<SapBusinessTripService> logger)
|
||||
// {
|
||||
// _jinkoJipService = jinkoJipService;
|
||||
// _dbContext = dbContext;
|
||||
// _logger = logger;
|
||||
// }
|
||||
//
|
||||
// /// <inheritdoc />
|
||||
// public async Task HandlerBusinessTripsByFactoryAsync(string factory)
|
||||
// {
|
||||
// var today = DateTime.Today;
|
||||
// var yesterday = today.AddDays(-1);
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// var tripResponse = await _jinkoJipService.GetTravelInfosByFactoryAsync(today, today, factory);
|
||||
// if (!tripResponse.Items.Any())
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// foreach (var tripInfoItem in tripResponse.Items.Where(x => x.Destination.IsPresent()))
|
||||
// {
|
||||
// if (await _dbContext.Queryable<BusinessTripEntity>().Where(x => x.Code == tripInfoItem.Code
|
||||
// && x.BeginDate == tripInfoItem.BeginDate
|
||||
// && x.EndDate == tripInfoItem.EndDate
|
||||
// && x.Destination == factory).AnyAsync())
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// var entity = tripInfoItem.Adapt<BusinessTripEntity>();
|
||||
// entity.Status = BusinessTripStatusEnumType.Wait;
|
||||
// await _dbContext.InsertAsync(entity);
|
||||
// }
|
||||
//
|
||||
// //获取今天和昨天的出差数据
|
||||
// var tripInfos = await _dbContext.Queryable<BusinessTripEntity>()
|
||||
// .Where(x => (SqlFunc.DateIsSame(x.BeginDate, today) && SqlFunc.DateIsSame(x.BeginDate, today))
|
||||
// || (SqlFunc.DateIsSame(x.BeginDate, yesterday) && SqlFunc.DateIsSame(x.BeginDate, yesterday)))
|
||||
// .Where(x => !SqlFunc.IsNullOrEmpty(x.Destination))
|
||||
// .Where(x => x.Destination == factory)
|
||||
// .ToListAsync();
|
||||
//
|
||||
// //获取分组信息
|
||||
// var tripGroup = await _dbContext.Queryable<DeviceGroupEntity>()
|
||||
// .Where(x => x.Type == DeviceTypeEnumType.Door)
|
||||
// .Where(x => x.TenantId == factory)
|
||||
// .Where(x => x.IsBusinessTrip)
|
||||
// .SingleAsync();
|
||||
//
|
||||
// var userCodes = tripInfos.Select(x => x.Code).Distinct().ToList();
|
||||
// var gainfos = await _dbContext.Queryable<GainfoEntity>().Where(x => userCodes.Contains(x.Code)).ToListAsync();
|
||||
//
|
||||
// foreach (var gainfo in gainfos)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var myTripInfos = tripInfos.Where(x => x.Code == gainfo.Code).ToList();
|
||||
//
|
||||
// var yesterdayTripInfo = myTripInfos.FirstOrDefault(x => x.BeginDate == yesterday && x.EndDate == yesterday); //昨天出差数据
|
||||
// var todayTripInfo = myTripInfos.FirstOrDefault(x => x.BeginDate == today && x.EndDate == today); //今天出差数据
|
||||
//
|
||||
// //都为空不处理
|
||||
// if (yesterdayTripInfo == null && todayTripInfo == null) continue;
|
||||
//
|
||||
// //都不为空则更新数据状态
|
||||
// if (yesterdayTripInfo != null && todayTripInfo != null)
|
||||
// {
|
||||
// todayTripInfo.Status = BusinessTripStatusEnumType.Generated;
|
||||
// await _dbContext.UpdateAsync(todayTripInfo);
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// var beforeResult = await _devicePermissionApi.GetPermissionUsersInfoAsync(new List<string> { gainfo.Code });
|
||||
//
|
||||
// if (yesterdayTripInfo != null)
|
||||
// {
|
||||
// yesterdayTripInfo.Status = BusinessTripStatusEnumType.Deleted;
|
||||
// await _dbContext.Updateable<DevicePermissionEntity>()
|
||||
// .SetColumns(x => x.IsDeleted == true)
|
||||
// .Where(x => x.AssignType == AssignTypeEnumType.User)
|
||||
// .Where(x => x.AssignValue == gainfo.No)
|
||||
// .Where(x => x.UniqueType == DeviceAssignmentTypeEnumType.Group)
|
||||
// .Where(x => x.UniqueValue == tripGroup.Code)
|
||||
// .Where(x => x.Type == tripGroup.Type)
|
||||
// .Where(x => x.TenantId == factory)
|
||||
// .ExecuteCommandAsync();
|
||||
// await _dbContext.UpdateAsync(yesterdayTripInfo);
|
||||
// }
|
||||
//
|
||||
// if (yesterdayTripInfo == null)
|
||||
// {
|
||||
// todayTripInfo.Status = BusinessTripStatusEnumType.Generated;
|
||||
// await _dbContext.InsertAsync(new DevicePermissionEntity
|
||||
// {
|
||||
// AssignType = AssignTypeEnumType.User,
|
||||
// AssignValue = gainfo.No,
|
||||
// UniqueType = DeviceAssignmentTypeEnumType.Group,
|
||||
// UniqueValue = tripGroup.Code,
|
||||
// TenantId = factory,
|
||||
// Type = tripGroup.Type,
|
||||
// IsDeleted = false
|
||||
// });
|
||||
// await _dbContext.UpdateAsync(todayTripInfo);
|
||||
// }
|
||||
//
|
||||
// await _devicePermissionApi.RePermissionUsersInfoAsync(beforeResult.Data);
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// _logger.LogError(e, "出差自动下发任务失败:{message}", e.Message);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// _logger.LogError(e, "处理{factory}出差数据失败:{message}", factory, e.Message);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user