还是同步员工

This commit is contained in:
2024-11-01 17:31:28 +08:00
parent 8c1d98456c
commit 4f630ffaf0

View File

@@ -1501,17 +1501,17 @@ namespace Tnb.ProductionMgr
try try
{ {
var erpdb = _db.AsTenant().GetConnection("erpdb"); var erpdb = _db.AsTenant().GetConnection("erpdb");
// List<ErpUserDto> persons = await erpdb.Queryable<ErpBdPsndoc>() List<ErpUserDto> persons = await erpdb.Queryable<ErpBdPsndoc>()
// .Where(x=>x.ENABLESTATE!=1) .Where(x=>x.ENABLESTATE!=1)
// .Select(x=>new ErpUserDto .Select(x=>new ErpUserDto
// { {
// PERSON_ID = x.ID, PERSON_ID = x.ID,
// CODE = x.CODE, CODE = x.CODE,
// NAME = x.NAME, NAME = x.NAME,
// TYPE = "1", TYPE = "1",
// ENABLESTATE = x.ENABLESTATE ENABLESTATE = x.ENABLESTATE
// }) })
// .ToListAsync(); .ToListAsync();
List<ErpUserDto> users = await erpdb.Queryable<ErpSmUser>() List<ErpUserDto> users = await erpdb.Queryable<ErpSmUser>()
.Where(x=>x.ENABLESTATE!=1) .Where(x=>x.ENABLESTATE!=1)
.Select(x=>new ErpUserDto .Select(x=>new ErpUserDto
@@ -1625,89 +1625,89 @@ namespace Tnb.ProductionMgr
await _db.Insertable(insertErpExtendFields).ExecuteCommandAsync(); await _db.Insertable(insertErpExtendFields).ExecuteCommandAsync();
} }
// foreach (var person in persons) foreach (var person in persons)
// { {
// List<ErpExtendField> userErpExtendFields = erpExtendFields.Where(x => x.person_id == person.PERSON_ID).ToList(); List<ErpExtendField> userErpExtendFields = erpExtendFields.Where(x => x.person_id == person.PERSON_ID).ToList();
// if (userErpExtendFields == null || userErpExtendFields.IsEmpty() || userErpExtendFields.Count == 1) if (userErpExtendFields == null || userErpExtendFields.IsEmpty() || userErpExtendFields.Count == 1)
// { {
//
// UserEntity userEntity = new UserEntity(); UserEntity userEntity = new UserEntity();
// if (userErpExtendFields.Count == 1) if (userErpExtendFields.Count == 1)
// { {
// userEntity = existsUsers.Find(x => x.Id == erpExtendFields[0].table_id); userEntity = existsUsers.Find(x => x.Id == erpExtendFields[0].table_id);
// int state = person.ENABLESTATE == 2 ? 1 : 0; int state = person.ENABLESTATE == 2 ? 1 : 0;
// if (userEntity != null) if (userEntity != null)
// { {
// if (userEntity.EnabledMark != state) if (userEntity.EnabledMark != state)
// { {
// await _db.Updateable<UserEntity>() await _db.Updateable<UserEntity>()
// .SetColumns(x => x.EnabledMark == state) .SetColumns(x => x.EnabledMark == state)
// .Where(x => x.Id == userEntity.Id) .Where(x => x.Id == userEntity.Id)
// .ExecuteCommandAsync(); .ExecuteCommandAsync();
// } }
// continue; continue;
// } }
// } }
//
//
// userEntity.Id = SnowflakeIdHelper.NextId(); userEntity.Id = SnowflakeIdHelper.NextId();
// userEntity.Account = person.CODE; userEntity.Account = person.CODE;
// userEntity.RealName = person.NAME; userEntity.RealName = person.NAME;
// userEntity.Gender = 1; userEntity.Gender = 1;
// userEntity.OrganizeId = WmsWareHouseConst.AdministratorOrgId; userEntity.OrganizeId = WmsWareHouseConst.AdministratorOrgId;
// userEntity.RoleId = "30327535942933"; userEntity.RoleId = "30327535942933";
// userEntity.Secretkey = Guid.NewGuid().ToString(); userEntity.Secretkey = Guid.NewGuid().ToString();
// userEntity.Password = MD5Encryption.Encrypt(MD5Encryption.Encrypt(CommonConst.DEFAULTPASSWORD) + userEntity.Password = MD5Encryption.Encrypt(MD5Encryption.Encrypt(CommonConst.DEFAULTPASSWORD) +
// userEntity.Secretkey); userEntity.Secretkey);
// userEntity.EntryDate = DateTime.Now; userEntity.EntryDate = DateTime.Now;
// userEntity.EnabledMark = person.ENABLESTATE == 2 ? 1 : 0; userEntity.EnabledMark = person.ENABLESTATE == 2 ? 1 : 0;
// userEntity.CreatorTime = DateTime.Now; userEntity.CreatorTime = DateTime.Now;
// insertUsers2.Add(userEntity); insertUsers2.Add(userEntity);
//
// UserRelationEntity userRelationEntity = new UserRelationEntity(); UserRelationEntity userRelationEntity = new UserRelationEntity();
// userRelationEntity.Id = SnowflakeIdHelper.NextId(); userRelationEntity.Id = SnowflakeIdHelper.NextId();
// userRelationEntity.UserId = userEntity.Id; userRelationEntity.UserId = userEntity.Id;
// userRelationEntity.ObjectType = "Role"; userRelationEntity.ObjectType = "Role";
// userRelationEntity.ObjectId = "30327535942933"; userRelationEntity.ObjectId = "30327535942933";
// userRelationEntity.CreatorTime = DateTime.Now; userRelationEntity.CreatorTime = DateTime.Now;
// insertUserRelations2.Add(userRelationEntity); insertUserRelations2.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;
// insertUserRelations2.Add(userRelationEntity2); insertUserRelations2.Add(userRelationEntity2);
//
// ErpExtendField erpExtendField = new ErpExtendField(); ErpExtendField erpExtendField = new ErpExtendField();
// erpExtendField.org_id = WmsWareHouseConst.AdministratorOrgId; erpExtendField.org_id = WmsWareHouseConst.AdministratorOrgId;
// erpExtendField.table_name = "base_user"; erpExtendField.table_name = "base_user";
// erpExtendField.table_id = userEntity.Id; erpExtendField.table_id = userEntity.Id;
// erpExtendField.person_id = person.PERSON_ID; erpExtendField.person_id = person.PERSON_ID;
// erpExtendField.user_id = person.USER_ID; erpExtendField.user_id = person.USER_ID;
// insertErpExtendFields2.Add(erpExtendField); insertErpExtendFields2.Add(erpExtendField);
// } }
// else else
// { {
//
// } }
// } }
//
// if (!insertUsers2.IsEmpty()) if (!insertUsers2.IsEmpty())
// { {
// await _db.Insertable(insertUsers2).ExecuteCommandAsync(); await _db.Insertable(insertUsers2).ExecuteCommandAsync();
//
// } }
// if (!insertUserRelations2.IsEmpty()) if (!insertUserRelations2.IsEmpty())
// { {
// await _db.Insertable(insertUserRelations2).ExecuteCommandAsync(); await _db.Insertable(insertUserRelations2).ExecuteCommandAsync();
// } }
//
// if (!insertErpExtendFields2.IsEmpty()) if (!insertErpExtendFields2.IsEmpty())
// { {
// await _db.Insertable(insertErpExtendFields2).ExecuteCommandAsync(); await _db.Insertable(insertErpExtendFields2).ExecuteCommandAsync();
// } }
await _db.Ado.CommitTranAsync(); await _db.Ado.CommitTranAsync();