This commit is contained in:
2024-10-09 09:24:28 +08:00
parent 92d5a5400f
commit dc5cce35ee

View File

@@ -1505,6 +1505,7 @@ namespace Tnb.ProductionMgr
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x=>x.table_name=="base_user").ToListAsync();
List<UserEntity> insertUsers = new List<UserEntity>();
List<UserEntity> existsUsers = await _db.Queryable<UserEntity>().ToListAsync();
List<UserRelationEntity> insertUserRelations = new List<UserRelationEntity>();
List<ErpExtendField> insertErpExtendFields = new List<ErpExtendField>();
@@ -1522,34 +1523,41 @@ namespace Tnb.ProductionMgr
else
{
UserEntity userEntity = new UserEntity();
userEntity.Id = SnowflakeIdHelper.NextId();
userEntity.Account = person.CODE;
userEntity.RealName = person.NAME;
userEntity.Gender = 1;
userEntity.OrganizeId = WmsWareHouseConst.AdministratorOrgId;
userEntity.RoleId = "30327535942933";
userEntity.Secretkey = Guid.NewGuid().ToString();
userEntity.Password = MD5Encryption.Encrypt(MD5Encryption.Encrypt(CommonConst.DEFAULTPASSWORD) + userEntity.Secretkey);
userEntity.EntryDate = DateTime.Now;
userEntity.EnabledMark = 1;
userEntity.CreatorTime = DateTime.Now;
insertUsers.Add(userEntity);
UserRelationEntity userRelationEntity = new UserRelationEntity();
userRelationEntity.Id = SnowflakeIdHelper.NextId();
userRelationEntity.UserId = userEntity.Id;
userRelationEntity.ObjectType = "Role";
userRelationEntity.ObjectId = "30327535942933";
userRelationEntity.CreatorTime = DateTime.Now;
insertUserRelations.Add(userRelationEntity);
if (existsUsers.Exists(x => x.Account == person.CODE))
{
userEntity = existsUsers.Find(x => x.Account == person.CODE);
}
else
{
userEntity.Id = SnowflakeIdHelper.NextId();
userEntity.Account = person.CODE;
userEntity.RealName = person.NAME;
userEntity.Gender = 1;
userEntity.OrganizeId = WmsWareHouseConst.AdministratorOrgId;
userEntity.RoleId = "30327535942933";
userEntity.Secretkey = Guid.NewGuid().ToString();
userEntity.Password = MD5Encryption.Encrypt(MD5Encryption.Encrypt(CommonConst.DEFAULTPASSWORD) + userEntity.Secretkey);
userEntity.EntryDate = DateTime.Now;
userEntity.EnabledMark = 1;
userEntity.CreatorTime = DateTime.Now;
insertUsers.Add(userEntity);
UserRelationEntity userRelationEntity = new UserRelationEntity();
userRelationEntity.Id = SnowflakeIdHelper.NextId();
userRelationEntity.UserId = userEntity.Id;
userRelationEntity.ObjectType = "Role";
userRelationEntity.ObjectId = "30327535942933";
userRelationEntity.CreatorTime = DateTime.Now;
insertUserRelations.Add(userRelationEntity);
UserRelationEntity userRelationEntity2 = new UserRelationEntity();
userRelationEntity2.Id = SnowflakeIdHelper.NextId();
userRelationEntity2.UserId = userEntity.Id;
userRelationEntity2.ObjectType = "Organize";
userRelationEntity2.ObjectId = WmsWareHouseConst.AdministratorOrgId;
userRelationEntity2.CreatorTime = DateTime.Now;
insertUserRelations.Add(userRelationEntity2);
UserRelationEntity userRelationEntity2 = new UserRelationEntity();
userRelationEntity2.Id = SnowflakeIdHelper.NextId();
userRelationEntity2.UserId = userEntity.Id;
userRelationEntity2.ObjectType = "Organize";
userRelationEntity2.ObjectId = WmsWareHouseConst.AdministratorOrgId;
userRelationEntity2.CreatorTime = DateTime.Now;
insertUserRelations.Add(userRelationEntity2);
}
ErpExtendField extendField = new ErpExtendField();
extendField.org_id = WmsWareHouseConst.AdministratorOrgId;