fix 数据添加有误处理,展示排序

This commit is contained in:
2024-05-24 14:37:03 +08:00
parent c3b69fbf24
commit 9cc880253c
4 changed files with 18 additions and 12 deletions

View File

@@ -22,6 +22,8 @@ public class BusinessPlaceShiftTinyResponse
/// </summary> /// </summary>
public TimeOnly End { get; set; } public TimeOnly End { get; set; }
public int Sequence { get; set; }
/// <summary> /// <summary>
/// 时间段描述 /// 时间段描述
/// </summary> /// </summary>

View File

@@ -163,7 +163,8 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
CustomCode = shiftinfo.Id.ToString(), CustomCode = shiftinfo.Id.ToString(),
Name = shiftinfo.ShiftType.GetDescription(), Name = shiftinfo.ShiftType.GetDescription(),
Start = shiftinfo.Start, Start = shiftinfo.Start,
End = shiftinfo.End End = shiftinfo.End,
Sequence = shiftinfo.Sequence
}; };
list.Add(shift); list.Add(shift);
@@ -175,7 +176,7 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
Name = place.Name, Name = place.Name,
TenantCode = tenantInfo.Code, TenantCode = tenantInfo.Code,
TenantName = tenantInfo.Name, TenantName = tenantInfo.Name,
Shifts = list Shifts = list.OrderBy(x => x.Sequence).ToList()
}; };
} }

View File

@@ -71,7 +71,7 @@ public class DeviceConnectService : IDeviceConnectService
if (request.BusinessPlaceCode.HasValue) if (request.BusinessPlaceCode.HasValue)
{ {
var businessPlace = await _dbContext.Queryable<BusinessPlaceEntity>().Where(x => x.Code == request.BusinessPlaceCode).FirstAsync(); var businessPlace = await _dbContext.Queryable<BusinessPlaceEntity>().Where(x => x.Code == request.BusinessPlaceCode).FirstAsync();
businessPlace.ThrowIfNull("营业点不存在,无法设置到设备注册信息中"); businessPlace.ThrowIfNull("营业点不存在,无法设置到设备注册信息中");
} }
//更新营业点信息 //更新营业点信息
@@ -123,8 +123,8 @@ public class DeviceConnectService : IDeviceConnectService
private async Task<DeviceEntity> GetEnableDeviceAsync(string uniqueNo, bool checkExists = true, string deployPlace = "", string tenantId = "") private async Task<DeviceEntity> GetEnableDeviceAsync(string uniqueNo, bool checkExists = true, string deployPlace = "", string tenantId = "")
{ {
var device = await _dbContext.Queryable<DeviceEntity>() var device = await _dbContext.Queryable<DeviceEntity>()
.Where(x => x.UniqueNo == uniqueNo) .Where(x => x.UniqueNo == uniqueNo)
.FirstAsync(); .FirstAsync();
if (checkExists) if (checkExists)
{ {
@@ -135,7 +135,7 @@ public class DeviceConnectService : IDeviceConnectService
{ {
if (device == null) if (device == null)
{ {
device = new DeviceEntity() device = new DeviceEntity
{ {
Code = Guid.NewGuid(), Code = Guid.NewGuid(),
ConnectionInfo = string.Empty, ConnectionInfo = string.Empty,
@@ -144,10 +144,12 @@ public class DeviceConnectService : IDeviceConnectService
TenantId = tenantId, TenantId = tenantId,
Supplier = string.Empty, Supplier = string.Empty,
Funcs = new List<DeviceFuncEnumType>(), Funcs = new List<DeviceFuncEnumType>(),
Type = DeviceTypeEnumType.Meal,
DeployPlace = deployPlace, DeployPlace = deployPlace,
HeartbeatInterval = 0, HeartbeatInterval = 30,
DeployDirection = string.Empty, DeployDirection = string.Empty,
Enable = true, Enable = true,
AsAttendance = false,
DeployPosition = string.Empty, DeployPosition = string.Empty,
CreatedBy = 1, CreatedBy = 1,
CreateTime = DateTime.Now, CreateTime = DateTime.Now,
@@ -161,4 +163,4 @@ public class DeviceConnectService : IDeviceConnectService
return device; return device;
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Diagnostics; 
using Dlhis.Basic.Device.Request; using Dlhis.Basic.Device.Request;
using Dlhis.Basic.Device.Response; using Dlhis.Basic.Device.Response;
using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Basic.Entity;
@@ -42,7 +42,7 @@ public class DeviceService : IDeviceService
.LeftJoin<BusinessPlaceEntity>((d, dt, dr, bp) => dr.BusinessPlaceCode == bp.Code) .LeftJoin<BusinessPlaceEntity>((d, dt, dr, bp) => dr.BusinessPlaceCode == bp.Code)
.WhereIF(request.Type.HasValue, (d, dt) => d.Type == request.Type) .WhereIF(request.Type.HasValue, (d, dt) => d.Type == request.Type)
.WhereIF(request.Enable.HasValue, (d, dt) => d.Enable == request.Enable) .WhereIF(request.Enable.HasValue, (d, dt) => d.Enable == request.Enable)
.WhereIF(request.Search.IsPresent(), (d) => d.UniqueNo == request.Search || d.DeployPlace.Contains(request.Search)) .WhereIF(request.Search.IsPresent(), d => d.UniqueNo == request.Search || d.DeployPlace.Contains(request.Search))
.Select((d, dt, dr, bp) => new DevicePageResponse .Select((d, dt, dr, bp) => new DevicePageResponse
{ {
FuncsStr = d.Funcs.ToString(), FuncsStr = d.Funcs.ToString(),
@@ -57,6 +57,7 @@ public class DeviceService : IDeviceService
var deviceUniqueNos = page.Data.Select(x => x.UniqueNo).ToList(); var deviceUniqueNos = page.Data.Select(x => x.UniqueNo).ToList();
var balanceInfos = await _dbContext.Queryable<BalanceRecordEntity>().Where(x => x.Type == BalanceRecordTypeEnumType.Out) var balanceInfos = await _dbContext.Queryable<BalanceRecordEntity>().Where(x => x.Type == BalanceRecordTypeEnumType.Out)
.Where(x=>x.Status == BalanceRecordStatusEnumType.Valid)
.Where(x => deviceUniqueNos.Contains(x.DeviceUniqueNo)) .Where(x => deviceUniqueNos.Contains(x.DeviceUniqueNo))
.Select(x => new .Select(x => new
{ {
@@ -87,7 +88,7 @@ public class DeviceService : IDeviceService
var template = await CheckTemplateExistsAsync(request.TemplateCode); var template = await CheckTemplateExistsAsync(request.TemplateCode);
await CheckTemplateFieldAsync(request.TemplateCode, request.ConnectionInfo); await CheckTemplateFieldAsync(request.TemplateCode, request.ConnectionInfo);
DeviceEntity entity = null; DeviceEntity entity;
if (!request.Id.HasValue) if (!request.Id.HasValue)
{ {
entity = request.Adapt<DeviceEntity>(); entity = request.Adapt<DeviceEntity>();
@@ -525,7 +526,7 @@ public class DeviceService : IDeviceService
var list = new List<RecentNumberResponse>(); var list = new List<RecentNumberResponse>();
times.ForEach(time => times.ForEach(time =>
{ {
var count = devices.Where(x => x.CreateTime.ToString("yyyy-MM-dd") == time).Count(); var count = devices.Count(x => x.CreateTime.ToString("yyyy-MM-dd") == time);
var res = new RecentNumberResponse var res = new RecentNumberResponse
{ {
Date = time, Date = time,