From 7b2d0945add46c2500a84a655a205dafba732bc0 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Fri, 1 Nov 2024 14:08:30 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/ErpEntity/ErpBdPsndoc.cs | 5 +++++ .../Tnb.ProductionMgr.Entities/Entity/ErpEntity/ErpSmUser.cs | 5 +++++ .../Entity/ErpEntity/ErpUserDto.cs | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpEntity/ErpBdPsndoc.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpEntity/ErpBdPsndoc.cs index 766bff23..ca0ce2b3 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpEntity/ErpBdPsndoc.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpEntity/ErpBdPsndoc.cs @@ -11,5 +11,10 @@ namespace Tnb.ProductionMgr.Entities.Entity.ErpEntity public string ID { get; set; } public string CODE { get; set; } public string NAME { get; set; } + + /// + /// 1 未启用,2已启用,3已停用 + /// + public int ENABLESTATE { get; set; } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpEntity/ErpSmUser.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpEntity/ErpSmUser.cs index 06d65f52..d21261f3 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpEntity/ErpSmUser.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpEntity/ErpSmUser.cs @@ -12,5 +12,10 @@ namespace Tnb.ProductionMgr.Entities.Entity.ErpEntity public string PK_PSNDOC { get; set; } public string CODE { get; set; } public string NAME { get; set; } + + /// + /// 1 未启用,2已启用,3已停用 + /// + public int ENABLESTATE { get; set; } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpEntity/ErpUserDto.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpEntity/ErpUserDto.cs index ffd8091e..7ae86e79 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpEntity/ErpUserDto.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpEntity/ErpUserDto.cs @@ -13,5 +13,10 @@ namespace Tnb.ProductionMgr.Entities.Entity.ErpEntity /// 1 erp人员 2 erp用户 /// public string TYPE { get; set; } + + /// + /// 1 未启用,2已启用,3已停用 + /// + public int ENABLESTATE { get; set; } } } \ No newline at end of file From f83990b9ad21068d7449b3af6cee5c6cd55b57d1 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Fri, 1 Nov 2024 14:15:48 +0800 Subject: [PATCH 2/6] 1 --- .../Tnb.ProductionMgr/TimeWorkService.cs | 54 ++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index b86cdf65..34ed002e 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -732,7 +732,9 @@ namespace Tnb.ProductionMgr return "true"; } - + + #region 同步基础数据 + /// /// 同步基础数据 /// @@ -1500,15 +1502,18 @@ namespace Tnb.ProductionMgr { var erpdb = _db.AsTenant().GetConnection("erpdb"); List persons = await erpdb.Queryable() + .Where(x=>x.ENABLESTATE!=1) .Select(x=>new ErpUserDto { PERSON_ID = x.ID, CODE = x.CODE, NAME = x.NAME, TYPE = "1", + ENABLESTATE = x.ENABLESTATE }) .ToListAsync(); List users = await erpdb.Queryable() + .Where(x=>x.ENABLESTATE!=1) .Select(x=>new ErpUserDto { PERSON_ID = x.PK_PSNDOC, @@ -1516,6 +1521,7 @@ namespace Tnb.ProductionMgr CODE = x.CODE, NAME = x.NAME, TYPE = "2", + ENABLESTATE = x.ENABLESTATE }) .ToListAsync(); @@ -1537,6 +1543,16 @@ namespace Tnb.ProductionMgr { ErpExtendField eef = insertErpExtendFields.Find(x => x.person_id == person.PERSON_ID); eef.user_id = person.USER_ID; + + UserEntity existUser = insertUsers.Find(x => x.Id == eef.table_id); + if (existUser != null) + { + int state = person.ENABLESTATE == 2 ? 1 : 0; + if (existUser.EnabledMark != state) + { + existUser.EnabledMark = state; + } + } } else { @@ -1544,6 +1560,18 @@ namespace Tnb.ProductionMgr if (existsUsers.Exists(x => x.Account == person.CODE)) { userEntity = existsUsers.Find(x => x.Account == person.CODE); + + if (userEntity != null) + { + int state = person.ENABLESTATE == 2 ? 1 : 0; + if (userEntity.EnabledMark != state) + { + await _db.Updateable() + .SetColumns(x => x.EnabledMark == state) + .Where(x => x.Id == userEntity.Id) + .ExecuteCommandAsync(); + } + } } else { @@ -1556,7 +1584,7 @@ namespace Tnb.ProductionMgr userEntity.Secretkey = Guid.NewGuid().ToString(); userEntity.Password = MD5Encryption.Encrypt(MD5Encryption.Encrypt(CommonConst.DEFAULTPASSWORD) + userEntity.Secretkey); userEntity.EntryDate = DateTime.Now; - userEntity.EnabledMark = 1; + userEntity.EnabledMark = person.ENABLESTATE == 2 ? 1 : 0; userEntity.CreatorTime = DateTime.Now; insertUsers.Add(userEntity); @@ -1587,6 +1615,26 @@ namespace Tnb.ProductionMgr } } + else + { + ErpExtendField user = erpExtendFields.Find(x => x.person_id == person.PERSON_ID || x.user_id == person.USER_ID); + + if (user != null) + { + UserEntity ue = await _db.Queryable().Where(x=>x.Id==user.table_id).FirstAsync(); + if (ue != null) + { + int state = person.ENABLESTATE == 2 ? 1 : 0; + if (ue.EnabledMark != state) + { + await _db.Updateable() + .SetColumns(x => x.EnabledMark == state) + .Where(x => x.Id == ue.Id) + .ExecuteCommandAsync(); + } + } + } + } } await _db.Insertable(insertUsers).ExecuteCommandAsync(); @@ -1607,6 +1655,8 @@ namespace Tnb.ProductionMgr return msg; } + + #endregion /// /// 监测工艺 From 8c1d98456c684af0b5bbd2b7d379e8ec46c864a1 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Fri, 1 Nov 2024 16:48:37 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=B8=8D=E5=86=8D=E5=90=8C=E6=AD=A5erp?= =?UTF-8?q?=E7=9A=84=E5=91=98=E5=B7=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.ProductionMgr/TimeWorkService.cs | 280 +++++++++++------- 1 file changed, 174 insertions(+), 106 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index 34ed002e..26ad9061 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -1501,17 +1501,17 @@ namespace Tnb.ProductionMgr try { var erpdb = _db.AsTenant().GetConnection("erpdb"); - List persons = await erpdb.Queryable() - .Where(x=>x.ENABLESTATE!=1) - .Select(x=>new ErpUserDto - { - PERSON_ID = x.ID, - CODE = x.CODE, - NAME = x.NAME, - TYPE = "1", - ENABLESTATE = x.ENABLESTATE - }) - .ToListAsync(); + // List persons = await erpdb.Queryable() + // .Where(x=>x.ENABLESTATE!=1) + // .Select(x=>new ErpUserDto + // { + // PERSON_ID = x.ID, + // CODE = x.CODE, + // NAME = x.NAME, + // TYPE = "1", + // ENABLESTATE = x.ENABLESTATE + // }) + // .ToListAsync(); List users = await erpdb.Queryable() .Where(x=>x.ENABLESTATE!=1) .Select(x=>new ErpUserDto @@ -1525,125 +1525,193 @@ namespace Tnb.ProductionMgr }) .ToListAsync(); - persons.AddRange(users); + // persons.AddRange(users); List erpExtendFields = await _db.Queryable().Where(x=>x.table_name=="base_user").ToListAsync(); - List insertUsers = new List(); List existsUsers = await _db.Queryable().ToListAsync(); + List insertUsers = new List(); List insertUserRelations = new List(); List insertErpExtendFields = new List(); - await _db.Ado.BeginTranAsync(); + List insertUsers2 = new List(); + List insertUserRelations2 = new List(); + List insertErpExtendFields2 = new List(); - foreach (var person in persons) + await _db.Ado.BeginTranAsync(); + + foreach (var user in users) { - if ((person.TYPE=="1" && erpExtendFields.All(x => x.person_id != person.PERSON_ID)) || (person.TYPE=="2" && erpExtendFields.All(x => x.user_id != person.USER_ID))) + List userErpExtendFields = erpExtendFields.Where(x => x.user_id == user.USER_ID).ToList(); + if (userErpExtendFields == null || userErpExtendFields.IsEmpty() || userErpExtendFields.Count == 1) { - if (person.TYPE == "2" && insertErpExtendFields.FindIndex(x=>x.person_id==person.PERSON_ID)!=-1 && person.PERSON_ID!="~") + + UserEntity userEntity = new UserEntity(); + if (userErpExtendFields.Count == 1) { - ErpExtendField eef = insertErpExtendFields.Find(x => x.person_id == person.PERSON_ID); - eef.user_id = person.USER_ID; - - UserEntity existUser = insertUsers.Find(x => x.Id == eef.table_id); - if (existUser != null) + userEntity = existsUsers.Find(x => x.Id == erpExtendFields[0].table_id); + int state = user.ENABLESTATE == 2 ? 1 : 0; + if (userEntity != null) { - int state = person.ENABLESTATE == 2 ? 1 : 0; - if (existUser.EnabledMark != state) - { - existUser.EnabledMark = state; - } - } - } - else - { - UserEntity userEntity = new UserEntity(); - if (existsUsers.Exists(x => x.Account == person.CODE)) - { - userEntity = existsUsers.Find(x => x.Account == person.CODE); - - if (userEntity != null) - { - int state = person.ENABLESTATE == 2 ? 1 : 0; - if (userEntity.EnabledMark != state) - { - await _db.Updateable() - .SetColumns(x => x.EnabledMark == state) - .Where(x => x.Id == userEntity.Id) - .ExecuteCommandAsync(); - } - } - } - 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 = person.ENABLESTATE == 2 ? 1 : 0; - 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); - } - - ErpExtendField extendField = new ErpExtendField(); - extendField.org_id = WmsWareHouseConst.AdministratorOrgId; - extendField.table_name = "base_user"; - extendField.table_id = userEntity.Id; - extendField.person_id = person.PERSON_ID; - extendField.user_id = person.USER_ID; - insertErpExtendFields.Add(extendField); - } - - } - else - { - ErpExtendField user = erpExtendFields.Find(x => x.person_id == person.PERSON_ID || x.user_id == person.USER_ID); - - if (user != null) - { - UserEntity ue = await _db.Queryable().Where(x=>x.Id==user.table_id).FirstAsync(); - if (ue != null) - { - int state = person.ENABLESTATE == 2 ? 1 : 0; - if (ue.EnabledMark != state) + if (userEntity.EnabledMark != state) { await _db.Updateable() .SetColumns(x => x.EnabledMark == state) - .Where(x => x.Id == ue.Id) + .Where(x => x.Id == userEntity.Id) .ExecuteCommandAsync(); } + continue; } } + + + userEntity.Id = SnowflakeIdHelper.NextId(); + userEntity.Account = user.CODE; + userEntity.RealName = user.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 = user.ENABLESTATE == 2 ? 1 : 0; + 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); + + ErpExtendField erpExtendField = new ErpExtendField(); + erpExtendField.org_id = WmsWareHouseConst.AdministratorOrgId; + erpExtendField.table_name = "base_user"; + erpExtendField.table_id = userEntity.Id; + erpExtendField.person_id = user.PERSON_ID; + erpExtendField.user_id = user.USER_ID; + insertErpExtendFields.Add(erpExtendField); + } + else + { + } } - await _db.Insertable(insertUsers).ExecuteCommandAsync(); - await _db.Insertable(insertUserRelations).ExecuteCommandAsync(); - await _db.Insertable(insertErpExtendFields).ExecuteCommandAsync(); + if (!insertUsers.IsEmpty()) + { + existsUsers.AddRange(insertUsers); + await _db.Insertable(insertUsers).ExecuteCommandAsync(); + + } + if (!insertUserRelations.IsEmpty()) + { + await _db.Insertable(insertUserRelations).ExecuteCommandAsync(); + } + + if (!insertErpExtendFields.IsEmpty()) + { + erpExtendFields.AddRange(insertErpExtendFields); + await _db.Insertable(insertErpExtendFields).ExecuteCommandAsync(); + } + + // foreach (var person in persons) + // { + // List userErpExtendFields = erpExtendFields.Where(x => x.person_id == person.PERSON_ID).ToList(); + // if (userErpExtendFields == null || userErpExtendFields.IsEmpty() || userErpExtendFields.Count == 1) + // { + // + // UserEntity userEntity = new UserEntity(); + // if (userErpExtendFields.Count == 1) + // { + // userEntity = existsUsers.Find(x => x.Id == erpExtendFields[0].table_id); + // int state = person.ENABLESTATE == 2 ? 1 : 0; + // if (userEntity != null) + // { + // if (userEntity.EnabledMark != state) + // { + // await _db.Updateable() + // .SetColumns(x => x.EnabledMark == state) + // .Where(x => x.Id == userEntity.Id) + // .ExecuteCommandAsync(); + // } + // continue; + // } + // } + // + // + // 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 = person.ENABLESTATE == 2 ? 1 : 0; + // userEntity.CreatorTime = DateTime.Now; + // insertUsers2.Add(userEntity); + // + // UserRelationEntity userRelationEntity = new UserRelationEntity(); + // userRelationEntity.Id = SnowflakeIdHelper.NextId(); + // userRelationEntity.UserId = userEntity.Id; + // userRelationEntity.ObjectType = "Role"; + // userRelationEntity.ObjectId = "30327535942933"; + // userRelationEntity.CreatorTime = DateTime.Now; + // insertUserRelations2.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; + // insertUserRelations2.Add(userRelationEntity2); + // + // ErpExtendField erpExtendField = new ErpExtendField(); + // erpExtendField.org_id = WmsWareHouseConst.AdministratorOrgId; + // erpExtendField.table_name = "base_user"; + // erpExtendField.table_id = userEntity.Id; + // erpExtendField.person_id = person.PERSON_ID; + // erpExtendField.user_id = person.USER_ID; + // insertErpExtendFields2.Add(erpExtendField); + // } + // else + // { + // + // } + // } + // + // if (!insertUsers2.IsEmpty()) + // { + // await _db.Insertable(insertUsers2).ExecuteCommandAsync(); + // + // } + // if (!insertUserRelations2.IsEmpty()) + // { + // await _db.Insertable(insertUserRelations2).ExecuteCommandAsync(); + // } + // + // if (!insertErpExtendFields2.IsEmpty()) + // { + // await _db.Insertable(insertErpExtendFields2).ExecuteCommandAsync(); + // } await _db.Ado.CommitTranAsync(); - msg = $"新增用户{insertUsers.Count}条"; + msg = $"新增用户{insertUsers.Count+insertUsers2.Count}条"; } catch (Exception e) { From 4f630ffaf06da0452dd130ba37e676491098fc4f Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Fri, 1 Nov 2024 17:31:28 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=BF=98=E6=98=AF=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=91=98=E5=B7=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.ProductionMgr/TimeWorkService.cs | 188 +++++++++--------- 1 file changed, 94 insertions(+), 94 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index 26ad9061..9f23ef85 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -1501,17 +1501,17 @@ namespace Tnb.ProductionMgr try { var erpdb = _db.AsTenant().GetConnection("erpdb"); - // List persons = await erpdb.Queryable() - // .Where(x=>x.ENABLESTATE!=1) - // .Select(x=>new ErpUserDto - // { - // PERSON_ID = x.ID, - // CODE = x.CODE, - // NAME = x.NAME, - // TYPE = "1", - // ENABLESTATE = x.ENABLESTATE - // }) - // .ToListAsync(); + List persons = await erpdb.Queryable() + .Where(x=>x.ENABLESTATE!=1) + .Select(x=>new ErpUserDto + { + PERSON_ID = x.ID, + CODE = x.CODE, + NAME = x.NAME, + TYPE = "1", + ENABLESTATE = x.ENABLESTATE + }) + .ToListAsync(); List users = await erpdb.Queryable() .Where(x=>x.ENABLESTATE!=1) .Select(x=>new ErpUserDto @@ -1625,89 +1625,89 @@ namespace Tnb.ProductionMgr await _db.Insertable(insertErpExtendFields).ExecuteCommandAsync(); } - // foreach (var person in persons) - // { - // List userErpExtendFields = erpExtendFields.Where(x => x.person_id == person.PERSON_ID).ToList(); - // if (userErpExtendFields == null || userErpExtendFields.IsEmpty() || userErpExtendFields.Count == 1) - // { - // - // UserEntity userEntity = new UserEntity(); - // if (userErpExtendFields.Count == 1) - // { - // userEntity = existsUsers.Find(x => x.Id == erpExtendFields[0].table_id); - // int state = person.ENABLESTATE == 2 ? 1 : 0; - // if (userEntity != null) - // { - // if (userEntity.EnabledMark != state) - // { - // await _db.Updateable() - // .SetColumns(x => x.EnabledMark == state) - // .Where(x => x.Id == userEntity.Id) - // .ExecuteCommandAsync(); - // } - // continue; - // } - // } - // - // - // 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 = person.ENABLESTATE == 2 ? 1 : 0; - // userEntity.CreatorTime = DateTime.Now; - // insertUsers2.Add(userEntity); - // - // UserRelationEntity userRelationEntity = new UserRelationEntity(); - // userRelationEntity.Id = SnowflakeIdHelper.NextId(); - // userRelationEntity.UserId = userEntity.Id; - // userRelationEntity.ObjectType = "Role"; - // userRelationEntity.ObjectId = "30327535942933"; - // userRelationEntity.CreatorTime = DateTime.Now; - // insertUserRelations2.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; - // insertUserRelations2.Add(userRelationEntity2); - // - // ErpExtendField erpExtendField = new ErpExtendField(); - // erpExtendField.org_id = WmsWareHouseConst.AdministratorOrgId; - // erpExtendField.table_name = "base_user"; - // erpExtendField.table_id = userEntity.Id; - // erpExtendField.person_id = person.PERSON_ID; - // erpExtendField.user_id = person.USER_ID; - // insertErpExtendFields2.Add(erpExtendField); - // } - // else - // { - // - // } - // } - // - // if (!insertUsers2.IsEmpty()) - // { - // await _db.Insertable(insertUsers2).ExecuteCommandAsync(); - // - // } - // if (!insertUserRelations2.IsEmpty()) - // { - // await _db.Insertable(insertUserRelations2).ExecuteCommandAsync(); - // } - // - // if (!insertErpExtendFields2.IsEmpty()) - // { - // await _db.Insertable(insertErpExtendFields2).ExecuteCommandAsync(); - // } + foreach (var person in persons) + { + List userErpExtendFields = erpExtendFields.Where(x => x.person_id == person.PERSON_ID).ToList(); + if (userErpExtendFields == null || userErpExtendFields.IsEmpty() || userErpExtendFields.Count == 1) + { + + UserEntity userEntity = new UserEntity(); + if (userErpExtendFields.Count == 1) + { + userEntity = existsUsers.Find(x => x.Id == erpExtendFields[0].table_id); + int state = person.ENABLESTATE == 2 ? 1 : 0; + if (userEntity != null) + { + if (userEntity.EnabledMark != state) + { + await _db.Updateable() + .SetColumns(x => x.EnabledMark == state) + .Where(x => x.Id == userEntity.Id) + .ExecuteCommandAsync(); + } + continue; + } + } + + + 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 = person.ENABLESTATE == 2 ? 1 : 0; + userEntity.CreatorTime = DateTime.Now; + insertUsers2.Add(userEntity); + + UserRelationEntity userRelationEntity = new UserRelationEntity(); + userRelationEntity.Id = SnowflakeIdHelper.NextId(); + userRelationEntity.UserId = userEntity.Id; + userRelationEntity.ObjectType = "Role"; + userRelationEntity.ObjectId = "30327535942933"; + userRelationEntity.CreatorTime = DateTime.Now; + insertUserRelations2.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; + insertUserRelations2.Add(userRelationEntity2); + + ErpExtendField erpExtendField = new ErpExtendField(); + erpExtendField.org_id = WmsWareHouseConst.AdministratorOrgId; + erpExtendField.table_name = "base_user"; + erpExtendField.table_id = userEntity.Id; + erpExtendField.person_id = person.PERSON_ID; + erpExtendField.user_id = person.USER_ID; + insertErpExtendFields2.Add(erpExtendField); + } + else + { + + } + } + + if (!insertUsers2.IsEmpty()) + { + await _db.Insertable(insertUsers2).ExecuteCommandAsync(); + + } + if (!insertUserRelations2.IsEmpty()) + { + await _db.Insertable(insertUserRelations2).ExecuteCommandAsync(); + } + + if (!insertErpExtendFields2.IsEmpty()) + { + await _db.Insertable(insertErpExtendFields2).ExecuteCommandAsync(); + } await _db.Ado.CommitTranAsync(); From 1f99c534905935a5ae61340eb32966f07aeefe17 Mon Sep 17 00:00:00 2001 From: majian <780924089@qq.com> Date: Fri, 1 Nov 2024 19:28:24 +0800 Subject: [PATCH 5/6] 1 --- WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs index f2eead51..4157687b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs @@ -539,7 +539,7 @@ namespace Tnb.WarehouseMgr } InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, Size = items_pretask.Count, Region_id = WmsWareHouseConst.REGION_CPOutstock_ID }; - List endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); + List endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput, _db); int instockLocIndex = 0; foreach (Tuple item in items_pretask) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs index aaff4c2c..2d499131 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs @@ -489,7 +489,7 @@ namespace Tnb.WarehouseMgr code_batch = r.Key.code_batch, material_specification = item.material_specification, container_no = item.container_no, - warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, + warehouse_id = WmsWareHouseConst.WAREHOUSE_YCL_ID, print_qty = qty, scan_qty = qty, print_id = "", From 50f520d24e41a7f303774620cb57b42a905372a3 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Mon, 4 Nov 2024 13:54:07 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E7=A9=BA=E8=BD=BD=E5=85=B7=E5=AE=9A?= =?UTF-8?q?=E7=82=B9=E9=85=8D=E9=80=81=E5=A2=9E=E5=8A=A0hxjB=20hxjD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index 9f23ef85..f12a6733 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -493,21 +493,31 @@ namespace Tnb.ProductionMgr return "YTCS没开机"; } string stateHxja = await _redisData.TryGetValueByKeyField("hxjA", "State"); + string stateHxjb = await _redisData.TryGetValueByKeyField("hxjB", "State"); string stateHxjc = await _redisData.TryGetValueByKeyField("hxjC", "State"); + string stateHxjd = await _redisData.TryGetValueByKeyField("hxjD", "State"); List hxjList = new List(); if ("OK" == stateHxja) { hxjList.Add("hxjA"); } + if ("OK" == stateHxjb) + { + hxjList.Add("hxjB"); + } if ("OK" == stateHxjc) { hxjList.Add("hxjC"); } + if ("OK" == stateHxjd) + { + hxjList.Add("hxjD"); + } if (hxjList.IsEmpty()) { - Log.Error($"hxjA,hxjC不正常"); - return "hxjA,hxjC不正常"; + Log.Error($"hxjA,hxjB,hxjC,hxjD不正常"); + return "hxjA,hxjB,hxjC,hxjD不正常"; } string msg = ""; List equipments = await _db.Queryable()