fix 批量入职外包人员
This commit is contained in:
@@ -430,12 +430,12 @@ public class DevicePermissionService : IDevicePermissionService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var deivces = await _dbContext.Queryable<DeviceEntity>()
|
var devices = await _dbContext.Queryable<DeviceEntity>()
|
||||||
.Where(x => x.Enable)
|
.Where(x => x.Enable)
|
||||||
.Where(x => deviceCodes.Contains(x.Code))
|
.Where(x => deviceCodes.Contains(x.Code))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
var tasks = deivces.Select(x => new DeviceTaskEntity
|
var tasks = devices.Select(x => new DeviceTaskEntity
|
||||||
{
|
{
|
||||||
DeviceUniqueNo = x.UniqueNo,
|
DeviceUniqueNo = x.UniqueNo,
|
||||||
Status = DeviceTaskStatusEnumType.Wait,
|
Status = DeviceTaskStatusEnumType.Wait,
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
using Dlhis.Basic.Organization.Response;
|
|
||||||
using Dlhis.Basic.Organization.Services;
|
|
||||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace Dlhis.Basic.MealUser.Controllers;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 就餐人员
|
|
||||||
/// </summary>
|
|
||||||
[Authorize]
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
[ApiController]
|
|
||||||
public class MealUsersController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly IMealUserService _mealUserService;
|
|
||||||
|
|
||||||
public MealUsersController(IMealUserService mealUserService)
|
|
||||||
{
|
|
||||||
_mealUserService = mealUserService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 就餐人员分页
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("page")]
|
|
||||||
public async Task<Pagination<MealUserResponse>> GetPageAsync([FromQuery] PageDto request)
|
|
||||||
{
|
|
||||||
return await _mealUserService.GetPageAsync(request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,6 +3,7 @@ using Dlhis.Basic.Organization.Request;
|
|||||||
using Dlhis.Basic.Organization.Response;
|
using Dlhis.Basic.Organization.Response;
|
||||||
using Dlhis.Basic.Organization.Services;
|
using Dlhis.Basic.Organization.Services;
|
||||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||||
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@@ -34,6 +35,21 @@ public class GainfoOutsourceController : ControllerBase
|
|||||||
await _gainfoOutSourceService.SaveAsync(request);
|
await _gainfoOutSourceService.SaveAsync(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批量入职
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requests"></param>
|
||||||
|
[HttpPost("batchEntry")]
|
||||||
|
[Transactional]
|
||||||
|
public async Task EntryAsync(List<GainfoOutsourceRequest> requests)
|
||||||
|
{
|
||||||
|
(requests.DistinctBy(x => x.Factory).Count() > 1).ThrowIfTrue("仅支持单个基地外包人员导入");
|
||||||
|
foreach (var request in requests)
|
||||||
|
{
|
||||||
|
await _gainfoOutSourceService.SaveAsync(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑
|
/// 编辑
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using Dlhis.Basic.Organization.Request;
|
using Dlhis.Basic.Device.Services;
|
||||||
|
using Dlhis.Basic.Organization.Request;
|
||||||
using Dlhis.Basic.Organization.Response;
|
using Dlhis.Basic.Organization.Response;
|
||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.Entity.Basic.Entity;
|
||||||
|
using Dlhis.Entity.Device.Enums;
|
||||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||||
using Kurisu.AspNetCore.Utils;
|
using Kurisu.AspNetCore.Utils;
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
@@ -13,16 +15,20 @@ public class GainfoOutsourceService : IGainfoOutsourceService
|
|||||||
{
|
{
|
||||||
private readonly IDbContext _dbContext;
|
private readonly IDbContext _dbContext;
|
||||||
private readonly RedisCache _redisCache;
|
private readonly RedisCache _redisCache;
|
||||||
|
private readonly IDevicePermissionService _devicePermissionService;
|
||||||
|
|
||||||
public GainfoOutsourceService(IDbContext dbContext, RedisCache redisCache)
|
public GainfoOutsourceService(IDbContext dbContext, RedisCache redisCache, IDevicePermissionService devicePermissionService)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_redisCache = redisCache;
|
_redisCache = redisCache;
|
||||||
|
_devicePermissionService = devicePermissionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SaveAsync(GainfoOutsourceRequest request)
|
public async Task SaveAsync(GainfoOutsourceRequest request)
|
||||||
{
|
{
|
||||||
await CheckIdNoDuplicate(request.IdNo);
|
await CheckDuplicate(request.IdNo, request.Code);
|
||||||
|
var sapCodeExists = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Factory == request.Factory).Where(x => x.Code == request.ExternalInfo.SapCode).AnyAsync();
|
||||||
|
sapCodeExists.ThrowIfFalse("对接人不属于当前基地");
|
||||||
|
|
||||||
if (!request.Id.HasValue)
|
if (!request.Id.HasValue)
|
||||||
{
|
{
|
||||||
@@ -40,6 +46,8 @@ public class GainfoOutsourceService : IGainfoOutsourceService
|
|||||||
SapCode = request.ExternalInfo.SapCode,
|
SapCode = request.ExternalInfo.SapCode,
|
||||||
SapPhone = request.ExternalInfo.SapPhone
|
SapPhone = request.ExternalInfo.SapPhone
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await _devicePermissionService.GenerateDeviceTasksAsync(entity.No, DeviceTaskEnumType.Add);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -103,9 +111,16 @@ public class GainfoOutsourceService : IGainfoOutsourceService
|
|||||||
/// 检查证件号重复
|
/// 检查证件号重复
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idNo"></param>
|
/// <param name="idNo"></param>
|
||||||
private async Task CheckIdNoDuplicate(string idNo)
|
/// <param name="code"></param>
|
||||||
|
private async Task CheckDuplicate(string idNo, string code)
|
||||||
{
|
{
|
||||||
var exists = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == idNo).AnyAsync();
|
var exists = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == idNo).AnyAsync();
|
||||||
exists.ThrowIfTrue($"证件号{idNo}重复");
|
exists.ThrowIfTrue($"证件号{idNo}重复");
|
||||||
|
|
||||||
|
if (code.IsPresent())
|
||||||
|
{
|
||||||
|
exists = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == code).AnyAsync();
|
||||||
|
exists.ThrowIfTrue($"工号{code}重复");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ public class GainfoService : IGainfoService
|
|||||||
|
|
||||||
public async Task<object> CheckIdNoAndNameMatchAsync(GainfoCheckIdNoAndNameRequest request)
|
public async Task<object> CheckIdNoAndNameMatchAsync(GainfoCheckIdNoAndNameRequest request)
|
||||||
{
|
{
|
||||||
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.External).FirstAsync(x => x.IdNo == request.IdNo && x.Name == request.Name)
|
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.External).FirstAsync(x => x.IdNo == request.IdNo && x.Name == request.Name)
|
||||||
?? await _gainfoStore.Queryable(GainfoStatusEnumType.Working).FirstAsync(x => x.IdNo == request.IdNo && x.Name == request.Name);
|
?? await _gainfoStore.Queryable(GainfoStatusEnumType.Working).FirstAsync(x => x.IdNo == request.IdNo && x.Name == request.Name);
|
||||||
|
|
||||||
gainfo.ThrowIfNull("验证失败!");
|
gainfo.ThrowIfNull("验证失败!");
|
||||||
|
|||||||
Reference in New Issue
Block a user