feat 卡类型编辑

This commit is contained in:
2025-01-03 11:56:06 +08:00
parent d7ab8f27e6
commit fddf77858e
10 changed files with 129 additions and 43 deletions

View File

@@ -1,6 +1,9 @@
using Dlhis.Basic.Organization.Request;
using Dlhis.Basic.Device.Services;
using Dlhis.Basic.Organization.Request;
using Dlhis.Basic.Organization.Response;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Device.Enums;
using Kurisu.AspNetCore.CustomClass;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
using Kurisu.AspNetCore.Utils.Extensions;
using Mapster;
@@ -11,11 +14,18 @@ public class GainfoCardService : IGainfoCardService
{
private readonly IDbContext _dbContext;
private readonly IGainfoStore _gainfoStore;
private readonly IDevicePermissionService _devicePermissionService;
private readonly IGainfoPermissionService _gainfoPermissionService;
public GainfoCardService(IDbContext dbContext, IGainfoStore gainfoStore)
public GainfoCardService(IDbContext dbContext,
IGainfoStore gainfoStore,
IDevicePermissionService devicePermissionService,
IGainfoPermissionService gainfoPermissionService)
{
_dbContext = dbContext;
_gainfoStore = gainfoStore;
_devicePermissionService = devicePermissionService;
_gainfoPermissionService = gainfoPermissionService;
}
public async Task ChangeCardAsync(GainfoChangeCardRequest request)
@@ -46,4 +56,37 @@ public class GainfoCardService : IGainfoCardService
})
.ToListAsync();
}
public async Task<List<KeyValueDto<string, string>>> GetCardTypesAsync()
{
var r = new List<KeyValueDto<string, string>>
{
new()
{
Key = "行政卡", Value = "2"
},
new()
{
Key = "车间卡", Value = "3"
}
};
return await Task.FromResult(r);
}
public async Task EditCardTypeAsync(string code, int typeId)
{
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == code).SingleAsync();
gainfo.ThrowIfNull("人员不存在");
gainfo.CardType = typeId;
var myDeviceCodes = await _devicePermissionService.GetUserDeviceCodesByNoAsync(gainfo.No);
var deviceCodes = await _dbContext.Queryable<DeviceEntity>()
.Where(x => myDeviceCodes.Contains(x.Code))
.Where(x => x.EnableTimePeriod)
.Select(x => x.Code)
.ToListAsync();
await _gainfoPermissionService.ResetPermissionsAsync(gainfo.No, DeviceTaskEnumType.Update, deviceCodes, "卡类型编辑下发");
}
}

View File

@@ -362,7 +362,7 @@ public class GainfoService : IGainfoService
IdNo = ga.IdNo,
Gender = ga.Gender,
Address = ga.Address,
Birthday = ga.Birthday,
OriginalBirthday = ga.Birthday,
Phone = ga.Phone,
Grade = ga.Grade,
Title = ga.Title,

View File

@@ -221,7 +221,6 @@ public class GainfoUpdateService : IGainfoUpdateService
CostId = item.KOSTL,
EntryDate = item.createdate,
ResignationDate = item.ZLZRQ,
CardType = SafeParseCardType(item.ZZ_KLX),
Workplace = _tenants.LastOrDefault(x => x.Name == item.ZZ_GZDJDNM)?.Code ?? item.ZZ_GZDJDNM,
Factory = _tenants.FirstOrDefault(x => x.Name == item.ZZ_GZDCQNM)?.Code ?? item.ZZ_GZDCQNM,
};
@@ -251,7 +250,6 @@ public class GainfoUpdateService : IGainfoUpdateService
ZSTATUS = item.ZSTATUS,
ZLZRQ = item.ZLZRQ,
STELL_NM = item.STELL_NM,
ZZ_KLX = item.ZZ_KLX,
createdate = item.createdate,
ZZ_GZDJDNM = item.ZZ_GZDJDNM,
ZZ_GZDCQNM = item.ZZ_GZDCQNM,
@@ -284,7 +282,6 @@ public class GainfoUpdateService : IGainfoUpdateService
ResignationDate = item.ZLZRQ,
Workplace = workplace,
Factory = factory,
CardType = SafeParseCardType(item.ZZ_KLX)
}).Where(x => x.Code == item.ename).ExecuteCommandAsync();
await _identityUserSyncService.SyncAccountAsync(gainfo.Code, gainfo.Name, gainfo.IdNo, factory);
@@ -355,7 +352,6 @@ public class GainfoUpdateService : IGainfoUpdateService
ResignationDate = item.ZLZRQ,
Workplace = workplace,
Factory = factory,
CardType = SafeParseCardType(item.ZZ_KLX)
}).Where(x => x.Code == item.ename).ExecuteCommandAsync();
}
}
@@ -385,7 +381,6 @@ public class GainfoUpdateService : IGainfoUpdateService
ZWORKCODE = x.ename,
ZZ_SFZH = x.idno,
GBDAT = x.birthday,
ZZ_KLX = x.ZZ_KLX,
ZXUELI = x.email,
ORGEH = x.appellation,
ZMOBILE = x.phone,
@@ -432,7 +427,6 @@ public class GainfoUpdateService : IGainfoUpdateService
ename = person.ZWORKCODE,
idno = person.ZZ_SFZH,
birthday = person.GBDAT,
ZZ_KLX = person.ZZ_KLX,
email = person.ZXUELI,
appellation = person.ORGEH,
phone = person.ZMOBILE,
@@ -477,14 +471,4 @@ public class GainfoUpdateService : IGainfoUpdateService
idNo = idNo.TrimStart();
return idNo[..6];
}
private static int? SafeParseCardType(string ZZ_KLX)
{
if (int.TryParse(ZZ_KLX, out var cardType))
{
return cardType;
}
return null;
}
}