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
///
/// 监测工艺