fix 优化查询null值,注释
This commit is contained in:
@@ -32,6 +32,12 @@ public class DeviceSaveRequest
|
||||
[Required(ErrorMessage = "设备功能不能为空")]
|
||||
public List<DeviceFuncEnumType> Funcs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 心跳间隔
|
||||
/// </summary>
|
||||
[Range(0, int.MaxValue)]
|
||||
public int HeartbeatInterval { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部署点
|
||||
/// </summary>
|
||||
|
||||
@@ -27,9 +27,11 @@ public class DeviceService : IDeviceService
|
||||
public async Task<Pagination<DevicePageResponse>> GetPageAsync(DevicePageRequest request)
|
||||
{
|
||||
var page = await _dbContext.Queryable<DeviceEntity>()
|
||||
.Select(device => new DevicePageResponse
|
||||
.LeftJoin<DeviceTemplateEntity>((d, dt) => d.TemplateCode == dt.Code)
|
||||
.Select((d, dt) => new DevicePageResponse
|
||||
{
|
||||
FuncsStr = device.Funcs.ToString()
|
||||
FuncsStr = d.Funcs.ToString(),
|
||||
Brand = dt.Brand,
|
||||
|
||||
}, true)
|
||||
.ToPageListAsync(request);
|
||||
@@ -70,7 +72,8 @@ public class DeviceService : IDeviceService
|
||||
var entity = await _dbContext.Queryable<DeviceEntity>().Where(x => x.Id == request.Id).FirstAsync();
|
||||
entity.ThrowIfNull("设备不存在,无法更新");
|
||||
|
||||
request.Adapt(entity);
|
||||
var uniqueNo = entity.UniqueNo;
|
||||
request.Adapt(entity).UniqueNo = uniqueNo;
|
||||
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,16 @@ public class MealUserService : IMealUserService
|
||||
public async Task<Pagination<MealUserResponse>> GetPageAsync(MealUserPageRequest request)
|
||||
{
|
||||
var page = await _dbContext.Queryable<CanteenUserEntity>()
|
||||
.Select<MealUserResponse>()
|
||||
.LeftJoin<GainfoEntity>((x, ga) => x.UserNo == ga.No)
|
||||
.Select((x, ga) => new MealUserResponse
|
||||
{
|
||||
Balance = x.Balance,
|
||||
BalanceOfRecharge = x.BalanceOfRecharge,
|
||||
BalanceOfSubsidies = x.BalanceOfSubsidies,
|
||||
UserCode = ga.Code,
|
||||
UserNo = ga.No,
|
||||
UserType = x.UserType
|
||||
})
|
||||
.ToPageListAsync(request);
|
||||
|
||||
return page;
|
||||
@@ -33,7 +42,7 @@ public class MealUserService : IMealUserService
|
||||
public async Task AddAsync(MealUserAddRequest request)
|
||||
{
|
||||
//todo 获取档案信息
|
||||
|
||||
|
||||
var gainfoEntity = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
|
||||
.Where(x => x.No.ToString() == request.UserNo)
|
||||
.FirstAsync();
|
||||
|
||||
@@ -8,31 +8,31 @@ public class CanteenSettingSaveRequest
|
||||
public long? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 配置生效范围
|
||||
/// 配置生效范围类型 CanteenSettingUnqiueEnumType
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(CanteenSettingUnqiueEnumType))]
|
||||
public CanteenSettingUnqiueEnumType UniqueType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 唯一值 eg:UniqueType = 1时,传入非空字符串
|
||||
/// 配置生效范围
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "值不能为空")]
|
||||
[Required(ErrorMessage = "配置生效范围不能为空")]
|
||||
public string UniqueValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义分类分类
|
||||
/// 自定义分类
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "分类不能为空")]
|
||||
public string Catalog { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 参数 CanteenSettingItemEnumType
|
||||
/// 就餐配置 CanteenSettingItemEnumType
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(CanteenSettingItemEnumType))]
|
||||
public CanteenSettingItemEnumType Item { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// 参数值
|
||||
/// </summary>
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ public class GainfoEntity : SugarBaseEntity
|
||||
public string NameEn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工号
|
||||
/// 学工号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "工号")]
|
||||
[SugarColumn(ColumnDescription = "学工号")]
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,57 +2,57 @@
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
|
||||
namespace Dlhis.ScheduledTask.TaskAssignment.Job
|
||||
namespace Dlhis.ScheduledTask.TaskAssignment.Job;
|
||||
|
||||
public class CreateGetAttendanceJob
|
||||
{
|
||||
public class CreateGetAttendanceJob
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ILogger<CreateSyncServerDateTimeJob> _logger;
|
||||
|
||||
public CreateGetAttendanceJob(IDbContext dbContext, ILogger<CreateSyncServerDateTimeJob> logger)
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ILogger<CreateSyncServerDateTimeJob> _logger;
|
||||
_logger = logger;
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public CreateGetAttendanceJob(IDbContext dbContext, ILogger<CreateSyncServerDateTimeJob> logger)
|
||||
public async Task RunAsync()
|
||||
{
|
||||
_dbContext.Client.QueryFilter.ClearAndBackup<ITenantId>();
|
||||
try
|
||||
{
|
||||
_logger = logger;
|
||||
_dbContext = dbContext;
|
||||
var devices = await _dbContext.Queryable<DeviceEntity>().Where(x => x.Enable).ToListAsync();
|
||||
devices = devices.Where(x => x.Funcs.Contains(DeviceFuncEnumType.Attendance)).ToList();
|
||||
|
||||
var tasks = devices.Select(x => new DeviceTaskEntity
|
||||
{
|
||||
DeviceUniqueNo = x.UniqueNo,
|
||||
Status = DeviceTaskStatusEnumType.Wait,
|
||||
|
||||
TenantId = x.TenantId,
|
||||
Version = 0,
|
||||
UserNo = string.Empty,
|
||||
UserCode = string.Empty,
|
||||
Type = DeviceTaskEnumType.UploadRecord,
|
||||
|
||||
CreatedBy = 1,
|
||||
CreateTime = DateTime.Now,
|
||||
ModifiedBy = 1,
|
||||
ModifiedTime = DateTime.Now,
|
||||
|
||||
}).ToList();
|
||||
|
||||
await _dbContext.InsertAsync(tasks);
|
||||
}
|
||||
|
||||
public async Task RunAsync()
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.Client.QueryFilter.ClearAndBackup();
|
||||
try
|
||||
{
|
||||
var devices = await _dbContext.Queryable<DeviceEntity>().Where(x => x.Enable).ToListAsync();
|
||||
devices = devices.Where(x => x.Funcs.Contains(DeviceFuncEnumType.Attendance)).ToList();
|
||||
|
||||
var tasks = devices.Select(x => new DeviceTaskEntity
|
||||
{
|
||||
DeviceUniqueNo = x.UniqueNo,
|
||||
Status = DeviceTaskStatusEnumType.Wait,
|
||||
|
||||
TenantId = x.TenantId,
|
||||
Version = 0,
|
||||
UserNo = string.Empty,
|
||||
UserCode = string.Empty,
|
||||
Type = DeviceTaskEnumType.UploadRecord,
|
||||
|
||||
CreatedBy = 1,
|
||||
CreateTime = DateTime.Now,
|
||||
ModifiedBy = 1,
|
||||
ModifiedTime = DateTime.Now,
|
||||
|
||||
}).ToList();
|
||||
|
||||
await _dbContext.InsertAsync(tasks);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"生成{DeviceTaskEnumType.UploadRecord.GetDescription()}任务失败:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_dbContext.Client.QueryFilter.Restore();
|
||||
}
|
||||
_logger.LogError(ex, "生成{type}任务失败:{message}", DeviceTaskEnumType.UploadRecord.GetDescription(), ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_dbContext.Client.QueryFilter.Restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user