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