fix 不再支持老系统档案号
This commit is contained in:
@@ -132,7 +132,9 @@ public class AppointmentAreaService : IAppointmentAreaService
|
|||||||
public async Task<List<Guid>> GetAssignmentsAsync(string customCode)
|
public async Task<List<Guid>> GetAssignmentsAsync(string customCode)
|
||||||
{
|
{
|
||||||
return await _dbContext.Queryable<AppointmentAreaAssignmentEntity>()
|
return await _dbContext.Queryable<AppointmentAreaAssignmentEntity>()
|
||||||
.Where(x => x.CustomCode == customCode).Select(x => x.DeviceGroupCode)
|
.LeftJoin<DeviceGroupEntity>((x, dg) => x.DeviceGroupCode == dg.Code)
|
||||||
|
.Where((x, dg) => x.CustomCode == customCode && dg.AsAppointment)
|
||||||
|
.Select(x => x.DeviceGroupCode)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
using Dlhis.Basic.Organization.Request;
|
|
||||||
using Dlhis.Basic.Organization.Services;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace Dlhis.Basic.Organization.Controllers;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 老系统档案表
|
|
||||||
/// </summary>
|
|
||||||
[Authorize]
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
[ApiController]
|
|
||||||
public class OldDeviceGainfosController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly IOldDeviceGainfoService _oldGainfoService;
|
|
||||||
|
|
||||||
public OldDeviceGainfosController(IOldDeviceGainfoService oldGainfoService)
|
|
||||||
{
|
|
||||||
_oldGainfoService = oldGainfoService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 上传
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="requests"></param>
|
|
||||||
[HttpPost("upload")]
|
|
||||||
public async Task BatchUploadAsync(List<OldDeviceGainfoUploadRequest> requests)
|
|
||||||
{
|
|
||||||
await _oldGainfoService.BatchUploadAsync(requests);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
using Dlhis.Basic.Organization.Request;
|
|
||||||
using Dlhis.Entity.Basic.Entity;
|
|
||||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
|
||||||
using Mapster;
|
|
||||||
|
|
||||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
|
||||||
|
|
||||||
public class OldGainfoService : IOldDeviceGainfoService
|
|
||||||
{
|
|
||||||
private readonly IDbContext _dbContext;
|
|
||||||
|
|
||||||
public OldGainfoService(IDbContext dbContext)
|
|
||||||
{
|
|
||||||
_dbContext = dbContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public async Task BatchUploadAsync(List<OldDeviceGainfoUploadRequest> requests)
|
|
||||||
{
|
|
||||||
var entities = requests.Adapt<List<OldDeviceGainfoEntity>>();
|
|
||||||
|
|
||||||
foreach (var entity in entities)
|
|
||||||
{
|
|
||||||
if (!await _dbContext.Queryable<OldDeviceGainfoEntity>().AnyAsync(x => x.No == entity.No && x.Code == entity.Code && x.DeviceUniqueNo == entity.DeviceUniqueNo))
|
|
||||||
{
|
|
||||||
await _dbContext.InsertAsync(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
using Dlhis.Entity.Device.Enums;
|
|
||||||
using Kurisu.AspNetCore.DataAccess.SqlSugar;
|
|
||||||
using SqlSugar;
|
|
||||||
using SqlSugar.DbConvert;
|
|
||||||
|
|
||||||
namespace Dlhis.Entity.Basic.Entity;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 老系统设备档案
|
|
||||||
/// </summary>
|
|
||||||
[SugarTable(TableName = "OldDeviceGainfos", TableDescription = "老系统设备档案")]
|
|
||||||
public class OldDeviceGainfoEntity : SugarBaseEntity
|
|
||||||
{
|
|
||||||
[SugarColumn(IsNullable = false, ColumnDescription = "厂区")]
|
|
||||||
public string Factory { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 档案号
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(IsNullable = false, ColumnDescription = "档案号", IndexGroupNameList = new[] { "unique_OldGainfos_no_code_unique" })]
|
|
||||||
public string No { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 工号
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(IsNullable = false, ColumnDescription = "工号", IndexGroupNameList = new[] { "unique_OldGainfos_no_code_unique" })]
|
|
||||||
public string Code { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设备唯一号
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(IsNullable = false, ColumnDescription = "设备唯一号", IndexGroupNameList = new[] { "unique_OldGainfos_no_code_unique" })]
|
|
||||||
public string DeviceUniqueNo { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 处理状态
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "处理状态", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
|
||||||
public OldDeviceGainfoEnumType Status { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 备注说明
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(IsNullable = true, ColumnDataType = "varchar(2000)", ColumnDescription = "备注说明")]
|
|
||||||
public string Remark { get; set; }
|
|
||||||
}
|
|
||||||
@@ -116,19 +116,6 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.CardNo.IsPresent() && request.UserUniqueNo != request.CardNo)
|
|
||||||
{
|
|
||||||
//UserUniqueNo为老系统档案号(自动生成),CardNo为工号
|
|
||||||
if (await _dbContext.Queryable<OldDeviceGainfoEntity>()
|
|
||||||
.Where(x => x.DeviceUniqueNo == request.DeviceUniqueNo)
|
|
||||||
.Where(x => x.No == request.UserUniqueNo && x.Code == request.CardNo)
|
|
||||||
.Select(x => x.Code)
|
|
||||||
.AnyAsync())
|
|
||||||
{
|
|
||||||
request.UserUniqueNo = request.CardNo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var currentGainfo = gainfos.FirstOrDefault(x => x.Code == request.UserUniqueNo);
|
var currentGainfo = gainfos.FirstOrDefault(x => x.Code == request.UserUniqueNo);
|
||||||
var userType = currentGainfo?.Type;
|
var userType = currentGainfo?.Type;
|
||||||
var needUpload = ((userType is GainfoUserTypeEnumType.Normal or GainfoUserTypeEnumType.SecurityWhite)
|
var needUpload = ((userType is GainfoUserTypeEnumType.Normal or GainfoUserTypeEnumType.SecurityWhite)
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ public class AssignmentService : IAssignmentService
|
|||||||
var data = await GetDataAsync(request);
|
var data = await GetDataAsync(request);
|
||||||
if (data.IsEmpty()) return new List<DeviceTaskToDeviceByDeviceResponse>();
|
if (data.IsEmpty()) return new List<DeviceTaskToDeviceByDeviceResponse>();
|
||||||
|
|
||||||
await HandlerOldDeviceGainfoAsync(data);
|
|
||||||
await HandlerTimePeriodAsync(data);
|
await HandlerTimePeriodAsync(data);
|
||||||
var deviceUploadInfos = await GetDeviceUploadRecordInfosAsync(data);
|
var deviceUploadInfos = await GetDeviceUploadRecordInfosAsync(data);
|
||||||
|
|
||||||
@@ -196,46 +195,6 @@ public class AssignmentService : IAssignmentService
|
|||||||
task.ModifiedTime = now;
|
task.ModifiedTime = now;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (await _dbContext.Queryable<OldDeviceGainfoEntity>().Where(x => x.Status != OldDeviceGainfoEnumType.Deleted).AnyAsync())
|
|
||||||
{
|
|
||||||
var dCodes = await _dbContext.Queryable<DeviceTaskEntity>()
|
|
||||||
.LeftJoin<GainfoEntity>((x, ga) => x.UserNo == ga.No)
|
|
||||||
.Where(x => taskIds.Contains(x.Id))
|
|
||||||
.Where(x => x.Status == DeviceTaskStatusEnumType.Process)
|
|
||||||
.Select((x, ga) => new
|
|
||||||
{
|
|
||||||
x.DeviceUniqueNo,
|
|
||||||
ga.Code,
|
|
||||||
ga.No
|
|
||||||
})
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
var oldDeviceGainfoWhere = LinqExpressionExtensions.False<OldDeviceGainfoEntity>();
|
|
||||||
dCodes.ForEach(item => { oldDeviceGainfoWhere = oldDeviceGainfoWhere.Or(x => x.Code == item.Code && x.DeviceUniqueNo == item.DeviceUniqueNo); });
|
|
||||||
var oldData = await _dbContext.Queryable<OldDeviceGainfoEntity>().Where(x => x.Status == OldDeviceGainfoEnumType.Wait)
|
|
||||||
.Where(oldDeviceGainfoWhere)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
oldData.ForEach(d =>
|
|
||||||
{
|
|
||||||
var current = dCodes.FirstOrDefault(x => x.Code == d.Code);
|
|
||||||
if (current != null)
|
|
||||||
{
|
|
||||||
var task = deviceTasks.FirstOrDefault(x => x.UserNo == current.No && x.DeviceUniqueNo == current.DeviceUniqueNo);
|
|
||||||
if (task != null)
|
|
||||||
{
|
|
||||||
d.Status = task.Status == DeviceTaskStatusEnumType.Success
|
|
||||||
? OldDeviceGainfoEnumType.Deleted
|
|
||||||
: OldDeviceGainfoEnumType.Error;
|
|
||||||
|
|
||||||
d.Remark = task.ResultMessage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
await _dbContext.UpdateAsync(oldData);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
await _dbContext.UpdateAsync(deviceTasks);
|
await _dbContext.UpdateAsync(deviceTasks);
|
||||||
}
|
}
|
||||||
@@ -406,31 +365,6 @@ public class AssignmentService : IAssignmentService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 处理老档案数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="data"></param>
|
|
||||||
private async Task HandlerOldDeviceGainfoAsync(List<TaskDto> data)
|
|
||||||
{
|
|
||||||
if (await _dbContext.Queryable<OldDeviceGainfoEntity>().Where(x => x.Status != OldDeviceGainfoEnumType.Deleted).AnyAsync())
|
|
||||||
{
|
|
||||||
var oldDeviceGainfoWhere = LinqExpressionExtensions.False<OldDeviceGainfoEntity>();
|
|
||||||
data.ForEach(item => { oldDeviceGainfoWhere = oldDeviceGainfoWhere.Or(x => x.Code == item.UserCode && x.DeviceUniqueNo == item.DeviceUniqueNo); });
|
|
||||||
var oldData = await _dbContext.Queryable<OldDeviceGainfoEntity>()
|
|
||||||
.Where(x => x.Status == OldDeviceGainfoEnumType.Wait || x.Status == OldDeviceGainfoEnumType.Error)
|
|
||||||
.Where(oldDeviceGainfoWhere)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
data.ForEach(item =>
|
|
||||||
{
|
|
||||||
var o = oldData.FirstOrDefault(x => x.Code == item.UserCode && x.DeviceUniqueNo == item.DeviceUniqueNo);
|
|
||||||
if (o != null)
|
|
||||||
item.OldUserNo = o.No;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task HandlerTimePeriodAsync(List<TaskDto> data)
|
private async Task HandlerTimePeriodAsync(List<TaskDto> data)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user