大简云公司用户信息同步到客户端

master
wanghaomei 1 year ago
parent f417de39cc
commit 4b4c6ac1af

File diff suppressed because one or more lines are too long

@ -0,0 +1,444 @@
using Furion;
using Furion.DataEncryption;
using Furion.EventBus;
using Furion.RemoteRequest.Extensions;
using Microsoft.Extensions.Logging;
using Myshipping.Core.Entity;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yitter.IdGenerator;
namespace Myshipping.Core
{
/// <summary>
/// 公司、用户同步订阅器
/// </summary>
public class CompanyUserSyncSubscriber : IEventSubscriber
{
private readonly ILogger<CompanyUserSyncSubscriber> _logger;
public CompanyUserSyncSubscriber(IServiceProvider services, ILogger<CompanyUserSyncSubscriber> logger)
{
Services = services;
_logger = logger;
}
public IServiceProvider Services { get; }
//公司及用户信息的同步
[EventSubscribe("CompanyUserSync:CompanyUser")]
public async Task CompanyUserSyncCompanyUser(EventHandlerExecutingContext context)
{
_logger.LogInformation($"收到公司及用户信息的同步订阅消息:{context.Source.Payload}");
var dto = JsonConvert.DeserializeObject<MyshippingCompanyUserSyncDto>(context.Source.Payload.ToString());
var repoMenu = App.GetService<SqlSugarRepository<SysMenu>>();
var repoTenant = App.GetService<SqlSugarRepository<SysTenant>>();
var repoOrg = App.GetService<SqlSugarRepository<SysOrg>>();
var repoPos = App.GetService<SqlSugarRepository<SysPos>>();
var repoRole = App.GetService<SqlSugarRepository<SysRole>>();
var repoRoleMenu = App.GetService<SqlSugarRepository<SysRoleMenu>>();
var repoUser = App.GetService<SqlSugarRepository<SysUser>>();
var repoEmp = App.GetService<SqlSugarRepository<SysEmp>>();
var repoEmpPos = App.GetService<SqlSugarRepository<SysEmpPos>>();
var repoUserRole = App.GetService<SqlSugarRepository<SysUserRole>>();
//租户信息
var tenant = await repoTenant.AsQueryable().Filter(null, true).FirstAsync(x => x.CompId == dto.Company.CompId && x.IsDeleted == false);
if (tenant == null)
{
tenant = new SysTenant();
tenant.Id = YitIdHelper.NextId();
tenant.Name = dto.Company.CompName;
tenant.AdminName = dto.Company.AdminShowName;
tenant.Email = dto.Company.AdminUserEmail;
tenant.Phone = dto.Company.AdminUserMobile;
tenant.CompId = dto.Company.CompId;
tenant.CreatedUserId = 142307070910551L;
tenant.CreatedUserName = "超级管理员";
await repoTenant.InsertAsync(tenant);
}
else
{
tenant.Name = dto.Company.CompName;
tenant.AdminName = dto.Company.AdminShowName;
tenant.Email = dto.Company.AdminUserEmail;
tenant.Phone = dto.Company.AdminUserMobile;
tenant.UpdatedUserId = 142307070910551L;
tenant.UpdatedUserName = "超级管理员";
await repoTenant.UpdateAsync(tenant);
}
//组织机构
var org = await repoOrg.AsQueryable().Filter(null, true).FirstAsync(x => x.Pid == 0 && x.TenantId == tenant.Id && x.IsDeleted == false);
if (org == null)
{
org = new SysOrg();
org.Id = YitIdHelper.NextId();
org.Name = tenant.Name;
org.Pid = 0;
org.Pids = string.Empty;
org.Code = string.Empty;
org.Contacts = dto.Company.AdminShowName;
org.Tel = dto.Company.AdminUserMobile;
org.Sort = 0;
org.TenantId = tenant.Id;
org.CreatedUserId = 142307070910551L;
org.CreatedUserName = "超级管理员";
await repoOrg.InsertAsync(org);
}
//职位
var pos = await repoPos.AsQueryable().Filter(null, true).FirstAsync(x => x.Code == "SystemPos" && x.TenantId == tenant.Id && x.IsDeleted == false);
if (pos == null)
{
pos = new SysPos();
pos.Id = YitIdHelper.NextId();
pos.Code = "SystemPos";
pos.Name = "系统职位";
pos.Sort = 0;
pos.TenantId = tenant.Id;
pos.CreatedUserId = 142307070910551L;
pos.CreatedUserName = "超级管理员";
await repoPos.InsertAsync(pos);
}
//系统角色
var roleSystem = await repoRole.AsQueryable().Filter(null, true).FirstAsync(x => x.Code == "SystemRole" && x.TenantId == tenant.Id && x.IsDeleted == false);
if (roleSystem == null)
{
roleSystem = new SysRole();
roleSystem.Id = YitIdHelper.NextId();
roleSystem.Code = "SystemRole";
roleSystem.Name = "系统角色";
roleSystem.RoleType = RoleType.NormalRole;
roleSystem.DataScopeType = DataScopeType.SELF;
roleSystem.Sort = 1;
roleSystem.TenantId = tenant.Id;
roleSystem.CreatedUserId = 142307070910551L;
roleSystem.CreatedUserName = "超级管理员";
await repoRole.InsertAsync(roleSystem);
//角色菜单
var initMenu = new long[] {
347225881825349,
351064299098181,
351175233155141,
353548710699077,
410157538861125,
430004145692741
};
foreach (var menuId in initMenu)
{
var roleMenu = new SysRoleMenu();
roleMenu.SysRoleId = roleSystem.Id;
roleMenu.SysMenuId = menuId;
await repoRoleMenu.InsertAsync(roleMenu);
}
}
//管理员角色
var roleAdmin = await repoRole.AsQueryable().Filter(null, true).FirstAsync(x => x.Code == "AdminRole" && x.TenantId == tenant.Id && x.IsDeleted == false);
if (roleAdmin == null)
{
roleAdmin = new SysRole();
roleAdmin.Id = YitIdHelper.NextId();
roleAdmin.Code = "AdminRole";
roleAdmin.Name = "管理员角色";
roleAdmin.RoleType = RoleType.AdminRole;
roleAdmin.DataScopeType = DataScopeType.ALL;
roleAdmin.Sort = 0;
roleAdmin.TenantId = tenant.Id;
roleAdmin.CreatedUserId = 142307070910551L;
roleAdmin.CreatedUserName = "超级管理员";
await repoRole.InsertAsync(roleAdmin);
//角色菜单
var initMenu = new long[] {
347225881825349,
351064299098181,
351175233155141,
353548710699077,
410157538861125,
430004145692741,
142307070910564,
142307070910581,
142307070910589,
142307070914651,
360699813744709,
374126362341445,
142307070910563,
142307000914633,
};
foreach (var menuId in initMenu)
{
var roleMenu = new SysRoleMenu();
roleMenu.SysRoleId = roleAdmin.Id;
roleMenu.SysMenuId = menuId;
await repoRoleMenu.InsertAsync(roleMenu);
}
//管理员的部分菜单有子项,需要加入权限
var parentMenuList = new long[] {
142307070910563,
142307070910564,
142307000914633,
142307070910581,
142307070910589,
142307070914651
};
var subMenuList = repoMenu.AsQueryable().Filter(null, true).Where(x => parentMenuList.Contains(x.Pid)).Select(x => x.Id).ToList();
foreach (var menuId in subMenuList)
{
if (repoRoleMenu.AsQueryable().Filter(null, true).Count(x => x.SysRoleId == roleAdmin.Id && x.SysMenuId == menuId) == 0)
{
var roleMenu = new SysRoleMenu();
roleMenu.SysRoleId = roleAdmin.Id;
roleMenu.SysMenuId = menuId;
await repoRoleMenu.InsertAsync(roleMenu);
}
}
}
//用户信息
var dbUsers = await repoUser.AsQueryable().Filter(null, true).Where(x => x.TenantId == tenant.Id && x.IsDeleted == false).ToListAsync();
var keyDES = App.GetOptions<EncryptKeyOptions>().DES;
foreach (var usr in dto.Users)
{
var user = dbUsers.FirstOrDefault(u => u.DjyUserId == usr.GID);
if (user == null)
{
user = new SysUser();
user.Id = YitIdHelper.NextId();
user.Name = usr.SHOWNAME;
user.NickName = usr.SHOWNAME;
user.Account = usr.CODENAME;
user.Password = DESCEncryption.Encrypt(usr.PASSWORD, keyDES);
user.Email = usr.EMAIL1;
user.Phone = usr.MOBILE;
user.AdminType = AdminType.None;
user.DjyUserId = usr.GID;
user.TenantId = tenant.Id;
await repoUser.InsertAsync(user);
//SysEmp
var emp = new SysEmp();
emp.Id = user.Id;
emp.OrgId = org.Id;
emp.OrgName = org.Name;
await repoEmp.InsertAsync(emp);
//SysEmpPos
var empPos = new SysEmpPos();
empPos.SysEmpId = emp.Id;
empPos.SysPosId = pos.Id;
await repoEmpPos.InsertAsync(empPos);
//SysUserRole
var userRole = new SysUserRole();
userRole.SysUserId = user.Id;
userRole.SysRoleId = roleSystem.Id;
await repoUserRole.InsertAsync(userRole);
}
//管理员账号
if (usr.GID == dto.Company.AdminUser && dbUsers.Count(u => u.AdminType == AdminType.Admin) == 0)
{
var adminUser = new SysUser();
adminUser.Id = YitIdHelper.NextId();
adminUser.Name = "系统管理员";
adminUser.NickName = adminUser.Name;
adminUser.Account = usr.EMAIL1;
adminUser.Password = DESCEncryption.Encrypt(usr.PASSWORD, keyDES);
adminUser.Email = string.Empty;
adminUser.Phone = string.Empty;
adminUser.AdminType = AdminType.Admin;
adminUser.TenantId = tenant.Id;
await repoUser.InsertAsync(adminUser);
//SysEmp
var emp = new SysEmp();
emp.Id = adminUser.Id;
emp.OrgId = org.Id;
emp.OrgName = org.Name;
await repoEmp.InsertAsync(emp);
//SysEmpPos
var empPos = new SysEmpPos();
empPos.SysEmpId = emp.Id;
empPos.SysPosId = pos.Id;
await repoEmpPos.InsertAsync(empPos);
//SysUserRole
var userRole = new SysUserRole();
userRole.SysUserId = adminUser.Id;
userRole.SysRoleId = roleAdmin.Id;
await repoUserRole.InsertAsync(userRole);
}
}
}
//用户离职信息的同步
[EventSubscribe("CompanyUserSync:UserLeave")]
public async Task CompanyUserSyncUserLeave(EventHandlerExecutingContext context)
{
_logger.LogInformation($"收到用户离职信息的同步订阅消息:{context.Source.Payload}");
var dto = JsonConvert.DeserializeObject<MyshippingUserLeaveSyncDto>(context.Source.Payload.ToString());
var repoTenant = App.GetService<SqlSugarRepository<SysTenant>>();
var repoUser = App.GetService<SqlSugarRepository<SysUser>>();
//租户信息
var tenant = await repoTenant.AsQueryable().Filter(null, true).FirstAsync(x => x.CompId == dto.CompId && x.IsDeleted == false);
if (tenant != null)
{
var user = await repoUser.AsQueryable().Filter(null, true).FirstAsync(u => u.DjyUserId == dto.UserId && u.TenantId == tenant.Id);
if (user != null)
{
_logger.LogInformation($"处理 {tenant.Name} 的 {user.Name} 离职");
var keyDES = App.GetOptions<EncryptKeyOptions>().DES;
user.Account = YitIdHelper.NextId().ToString();
user.Phone = string.Empty;
user.Email = string.Empty;
user.Name += "(离职)";
user.Password = DESCEncryption.Encrypt("123456", keyDES);
await repoUser.UpdateAsync(user);
}
}
}
}
/// <summary>
/// 公司及用户信息的同步dto
/// </summary>
public class MyshippingCompanyUserSyncDto
{
/// <summary>
/// 类型
/// </summary>
public string Type { get; set; }
/// <summary>
/// 公司
/// </summary>
public MyshippingCompanySyncDto Company { get; set; }
/// <summary>
/// 员工信息
/// </summary>
public List<MyshippingUserSyncDto> Users { get; set; }
}
/// <summary>
/// 用户离职信息的同步dto
/// </summary>
public class MyshippingUserLeaveSyncDto
{
/// <summary>
/// 类型
/// </summary>
public string Type { get; set; }
/// <summary>
/// 公司ID
/// </summary>
public string CompId { get; set; }
/// <summary>
/// 用户ID
/// </summary>
public string UserId { get; set; }
}
/// <summary>
/// 公司信息的同步dto
/// </summary>
public class MyshippingCompanySyncDto
{
/// <summary>
/// 公司ID
/// </summary>
public string CompId { get; set; }
/// <summary>
/// 公司名称
/// </summary>
public string CompName { get; set; }
/// <summary>
/// 地址
/// </summary>
public string Address { get; set; }
/// <summary>
/// 税号
/// </summary>
public string TaxCode { get; set; }
/// <summary>
/// 海关登记号
/// </summary>
public string CustomsCode { get; set; }
/// <summary>
/// 开户行
/// </summary>
public string BankName { get; set; }
/// <summary>
/// 开户行账号
/// </summary>
public string BankAccount { get; set; }
/// <summary>
/// 管理员ID
/// </summary>
public string AdminUser { get; set; }
/// <summary>
/// 管理员姓名
/// </summary>
public string AdminShowName { get; set; }
/// <summary>
/// 管理员邮箱
/// </summary>
public string AdminUserEmail { get; set; }
/// <summary>
/// 管理员手机
/// </summary>
public string AdminUserMobile { get; set; }
}
/// <summary>
/// 员工信息的同步dto
/// </summary>
public class MyshippingUserSyncDto
{
/// <summary>
/// 员工ID
/// </summary>
public string GID { get; set; }
/// <summary>
/// 登录名
/// </summary>
public string CODENAME { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string SHOWNAME { get; set; }
/// <summary>
/// 密码
/// </summary>
public string PASSWORD { get; set; }
/// <summary>
/// 手机
/// </summary>
public string MOBILE { get; set; }
/// <summary>
/// 邮箱
/// </summary>
public string EMAIL1 { get; set; }
}
}

@ -1,5 +1,6 @@
using Furion;
using Furion.DataEncryption;
using Furion.EventBus;
using Furion.RemoteRequest.Extensions;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
@ -29,39 +30,18 @@ namespace Myshipping.Core.MQ
{
private readonly IServiceScopeFactory _scopeFactory;
private readonly IServiceScope _serviceScope;
private readonly ISysUserService _serviceUser;
private readonly ILogger<RecCompanyUserChangeService> _logger;
private readonly ISysTenantService _tenantService;
private readonly ISysUserService _userService;
private readonly SqlSugarRepository<SysUser> _sysUserRep;
private readonly SqlSugarRepository<SysTenant> _sysTenantRep;
private readonly SqlSugarRepository<SysOrg> _sysOrgRep;
private readonly SqlSugarRepository<SysPos> _sysPosRep;
private readonly SqlSugarRepository<SysRole> _sysRoleRep;
private readonly SqlSugarRepository<SysMenu> _sysMenuRep;
private readonly ISysRoleMenuService _sysRoleMenuService;
private readonly IAuthService _IAuthService;
private readonly IEventPublisher _publisher;
private IConnection mqConn;
private IModel model;
public RecCompanyUserChangeService(IServiceScopeFactory scopeFactory, ISysUserService serviceUser, ISysRoleMenuService sysRoleMenuService,IAuthService IAuthService)
public RecCompanyUserChangeService(IServiceScopeFactory scopeFactory)
{
_scopeFactory = scopeFactory;
//通过这个注入DBContext
_serviceScope = _scopeFactory.CreateScope();
_serviceUser = serviceUser;
_IAuthService = IAuthService;
_sysRoleMenuService = sysRoleMenuService;
_logger = _serviceScope.ServiceProvider.GetService<ILogger<RecCompanyUserChangeService>>();
_tenantService = _serviceScope.ServiceProvider.GetService<ISysTenantService>();
_userService = _serviceScope.ServiceProvider.GetService<ISysUserService>();
_sysUserRep = _serviceScope.ServiceProvider.GetService<SqlSugarRepository<SysUser>>();
_sysTenantRep = _serviceScope.ServiceProvider.GetService<SqlSugarRepository<SysTenant>>();
_sysOrgRep = _serviceScope.ServiceProvider.GetService<SqlSugarRepository<SysOrg>>();
_sysPosRep = _serviceScope.ServiceProvider.GetService<SqlSugarRepository<SysPos>>();
_sysRoleRep = _serviceScope.ServiceProvider.GetService<SqlSugarRepository<SysRole>>();
_sysMenuRep = _serviceScope.ServiceProvider.GetService<SqlSugarRepository<SysMenu>>();
_publisher = _serviceScope.ServiceProvider.GetService<IEventPublisher>();
}
public override void Dispose()
@ -85,11 +65,13 @@ namespace Myshipping.Core.MQ
string ExchangeName = "djy.comp&user.change";
string QueueName = $"djy.comp&user.change.{DateTime.Now.Ticks}";
ConnectionFactory factory = new ConnectionFactory();
var repoSysCfg = _serviceScope.ServiceProvider.GetService<SqlSugarRepository<SysConfig>>();
var mqUrl = repoSysCfg.FirstOrDefault(x => x.Code == "CompanyUserChangeMqUrl").Value;
_logger.LogInformation($"准备连接公司用户同步消息队列:{mqUrl}");
factory.Uri = new Uri(mqUrl);
mqConn = factory.CreateConnection("客户订舱平台");
mqConn = factory.CreateConnection("客户订舱平台客户端");
model = mqConn.CreateModel();
model.ExchangeDeclare(ExchangeName, ExchangeType.Fanout);
@ -107,207 +89,18 @@ namespace Myshipping.Core.MQ
private async void Consumer_Received(object ch, BasicDeliverEventArgs ea)
{
//获取授权---------- (用超级管理员的权限)
LoginInput login = new LoginInput();
login.Account = "superAdmin";
login.Password = "123456";
var rtn = "http://localhost:5000/login".SetHttpMethod(HttpMethod.Post).SetContentType("application/json").SetBody(login.ToJsonString()).SetRetryPolicy(3, 5000).PostAsStringAsync();
var token = JObject.Parse(rtn.Result).GetStringValue("data");
var headers = new Dictionary<string, object>();
headers.Add("Authorization", $"Bearer {token}");
//-----
var body = ea.Body;
var strBody = Encoding.UTF8.GetString(body.ToArray());
var jobj = JObject.Parse(strBody);
var type = jobj.GetStringValue("type");
if (type == "CompanyAudit") //新公司审核通过
{
var comp = jobj.GetJObjectValue("company");
var compid = comp.GetStringValue("CompId");
var compname = comp.GetStringValue("CompName");
var adminShowName = comp.GetStringValue("AdminShowName");
var findTenant = _sysTenantRep.FirstOrDefault(x => x.CompId == compid); //先根据关联ID查找
if (findTenant == null)
{
findTenant = _sysTenantRep.FirstOrDefault(x => x.Name == compname); //再根据公司全称查找
}
if (findTenant == null) //找不到,新建
{
var tenant = new SysTenant();
tenant.Id = YitIdHelper.NextId();
tenant.Name = compname;
tenant.AdminName = adminShowName;
tenant.Email = $"{tenant.Id}";
tenant.TenantType = TenantTypeEnum.COMMON;
tenant.CompId = compid;
findTenant = _sysTenantRep.InsertReturnEntity(tenant);
await _tenantService.InitNewTenant(findTenant);
//新增的系统租户新增权限
GrantRoleMenuInput tenantmenuInput = new GrantRoleMenuInput();
tenantmenuInput.Id = findTenant.Id;
List<long> tenantGrantMenuIdList = new List<long>();
tenantGrantMenuIdList = _sysMenuRep.AsQueryable().Where(x => x.Pids.Contains("142307070910563")).Select(x => x.Id).ToList();//暂时写死默认新增权限管理
tenantmenuInput.GrantMenuIdList = tenantGrantMenuIdList;
await _sysRoleMenuService.GrantMenu(tenantmenuInput);
}
}
else if (type == "UserJoin") //用户加入公司
{
var compid = jobj.GetStringValue("compId");
var findTenant = _sysTenantRep.FirstOrDefault(x => x.CompId == compid); //先根据关联ID查找
//同步用户
var user = jobj.GetJArrayValue("users");
//租户id
var tenantid = findTenant.Id;
var keyDES = App.GetOptions<EncryptKeyOptions>().DES;
foreach (JObject item in user)
{
var GID = item.GetStringValue("GID");
var Accont = item.GetStringValue("CODENAME");
var Name = item.GetStringValue("SHOWNAME");
var Pass = DESCEncryption.Encrypt(item.GetStringValue("PASSWORD"), keyDES);
var Email = item.GetStringValue("EMAIL1");
var Phone = item.GetStringValue("MOBILE");
var PassWord = item.GetStringValue("PASSWORD");
var Org = await _sysOrgRep.AsQueryable().Filter(null, true).Where(x => x.TenantId == tenantid && x.IsDeleted == false && x.Pid == 0).FirstAsync();
//------ 拼接对象调用新增用户接口
AddUserInput adduser = new AddUserInput();
adduser.Account = Accont;
adduser.Password = PassWord;
adduser.Confirm = PassWord;
adduser.Sex = 1;
adduser.Phone = Phone;
adduser.TenantId = tenantid;
EmpOutput2 empOutput2 = new EmpOutput2();
empOutput2.OrgId = Org.Id.ToString();
empOutput2.OrgName = Org.Name;
List<long> PosIdList = new List<long>();
var pos = _sysPosRep.AsQueryable().Filter(null, true).Where(x => x.TenantId == tenantid && x.IsDeleted == false).FirstAsync();
PosIdList.Add(pos.Id);
empOutput2.PosIdList = PosIdList;
adduser.SysEmpParam = empOutput2;
await "http://localhost:5000/sysUser/add".SetHeaders(headers).SetHttpMethod(HttpMethod.Post).SetBody(adduser).SetRetryPolicy(3, 5000).PostAsStringAsync();
// await _serviceUser.AddUser(adduser, true);
}
//-----授权角色id普通用户
var role = _sysRoleRep.AsQueryable().Filter(null, true).Where(x => x.TenantId == tenantid && x.Name == "普通用户").FirstAsync();
GrantRoleMenuInput menuInput = new GrantRoleMenuInput();
menuInput.Id = Convert.ToInt64(role.Id);
List<long> GrantMenuIdList = new List<long>();
GrantMenuIdList.Add(351064299098181);//暂时写死 ,后续从字典获取 新增订舱台账
menuInput.GrantMenuIdList = GrantMenuIdList;
await _sysRoleMenuService.GrantMenu(menuInput);
}
else if (type == "UserLeave") //用户离职
if (type == "UserLeave") //用户离职
{
var userId = jobj.GetJObjectValue("userId");
var compId = jobj.GetStringValue("compId");
//删除用户
_sysUserRep.Delete(x => x.DjyUserId == userId.ToString());
await _publisher.PublishAsync(new ChannelEventSource($"CompanyUserSync:UserLeave", strBody));
}
else if (type == "CompanyUserSync") //公司及员工数据同步
{
//----------同步租户
var comp = jobj.GetJObjectValue("company");
var compid = comp.GetStringValue("CompId");
var compname = comp.GetStringValue("CompName");
var adminShowName = comp.GetStringValue("AdminShowName");
var findTenant = _sysTenantRep.FirstOrDefault(x => x.CompId == compid); //先根据关联ID查找
if (findTenant == null)
{
findTenant = _sysTenantRep.FirstOrDefault(x => x.Name == compname); //再根据公司全称查找
}
if (findTenant == null) //找不到,新建
{
var tenant = new SysTenant();
tenant.Id = YitIdHelper.NextId();
tenant.Name = compname;
tenant.AdminName = adminShowName;
tenant.Email = $"{tenant.Id}";
tenant.TenantType = TenantTypeEnum.COMMON;
tenant.CompId = compid;
findTenant = _sysTenantRep.InsertReturnEntity(tenant);
await _tenantService.InitNewTenant(findTenant);
//新增的系统租户新增权限
GrantRoleMenuInput tenantmenuInput = new GrantRoleMenuInput();
tenantmenuInput.Id = findTenant.Id;
List<long> tenantGrantMenuIdList = new List<long>();
tenantGrantMenuIdList = _sysMenuRep.AsQueryable().Where(x => x.Pids.Contains("142307070910563")).Select(x => x.Id).ToList();//暂时写死默认新增权限管理
tenantmenuInput.GrantMenuIdList = tenantGrantMenuIdList;
await _sysRoleMenuService.GrantMenu(tenantmenuInput);
}
//----------
//同步用户
var user = jobj.GetJArrayValue("users");
//租户id
var tenantid = findTenant.Id;
var keyDES = App.GetOptions<EncryptKeyOptions>().DES;
foreach (JObject item in user)
{
var GID = item.GetStringValue("GID");
var Accont = item.GetStringValue("CODENAME");
var Name = item.GetStringValue("SHOWNAME");
var Pass = DESCEncryption.Encrypt(item.GetStringValue("PASSWORD"), keyDES);
var Email = item.GetStringValue("EMAIL1");
var Phone = item.GetStringValue("MOBILE");
var PassWord = item.GetStringValue("PASSWORD");
var Org = await _sysOrgRep.AsQueryable().Filter(null, true).Where(x => x.TenantId == tenantid && x.IsDeleted == false && x.Pid == 0).FirstAsync();
//------ 拼接对象调用新增用户接口
AddUserInput adduser = new AddUserInput();
adduser.Account = Accont;
adduser.Password = PassWord;
adduser.Confirm = PassWord;
adduser.Sex = 1;
adduser.Phone = Phone;
adduser.TenantId = tenantid;
EmpOutput2 empOutput2 = new EmpOutput2();
empOutput2.OrgId = Org.Id.ToString();
empOutput2.OrgName = Org.Name;
List<long> PosIdList = new List<long>();
var pos = _sysPosRep.AsQueryable().Filter(null, true).Where(x => x.TenantId == tenantid && x.IsDeleted == false).FirstAsync();
PosIdList.Add(pos.Id);
empOutput2.PosIdList = PosIdList;
adduser.SysEmpParam = empOutput2;
//await _serviceUser.AddUser(adduser, true);
await "http://localhost:5000/sysUser/add".SetHeaders(headers).SetHttpMethod(HttpMethod.Post).SetBody(adduser).SetRetryPolicy(3, 5000).PostAsStringAsync();
}
//-----授权角色id普通用户
var role = _sysRoleRep.AsQueryable().Filter(null, true).Where(x => x.TenantId == tenantid && x.Name == "普通用户").FirstAsync();
GrantRoleMenuInput menuInput = new GrantRoleMenuInput();
menuInput.Id = Convert.ToInt64(role.Id);
List<long> GrantMenuIdList = new List<long>();
GrantMenuIdList.Add(351064299098181);//暂时写死 ,后续从字典获取 新增订舱台账
menuInput.GrantMenuIdList = GrantMenuIdList;
await _sysRoleMenuService.GrantMenu(menuInput);
await _publisher.PublishAsync(new ChannelEventSource($"CompanyUserSync:CompanyUser", strBody));
}
_logger.LogInformation($"收到消息:{strBody}");

@ -5447,6 +5447,146 @@
</summary>
</member>
<member name="T:Myshipping.Core.CompanyUserSyncSubscriber">
<summary>
公司、用户同步订阅器
</summary>
</member>
<member name="T:Myshipping.Core.MyshippingCompanyUserSyncDto">
<summary>
公司及用户信息的同步dto
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingCompanyUserSyncDto.Type">
<summary>
类型
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingCompanyUserSyncDto.Company">
<summary>
公司
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingCompanyUserSyncDto.Users">
<summary>
员工信息
</summary>
</member>
<member name="T:Myshipping.Core.MyshippingUserLeaveSyncDto">
<summary>
用户离职信息的同步dto
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingUserLeaveSyncDto.Type">
<summary>
类型
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingUserLeaveSyncDto.CompId">
<summary>
公司ID
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingUserLeaveSyncDto.UserId">
<summary>
用户ID
</summary>
</member>
<member name="T:Myshipping.Core.MyshippingCompanySyncDto">
<summary>
公司信息的同步dto
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingCompanySyncDto.CompId">
<summary>
公司ID
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingCompanySyncDto.CompName">
<summary>
公司名称
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingCompanySyncDto.Address">
<summary>
地址
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingCompanySyncDto.TaxCode">
<summary>
税号
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingCompanySyncDto.CustomsCode">
<summary>
海关登记号
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingCompanySyncDto.BankName">
<summary>
开户行
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingCompanySyncDto.BankAccount">
<summary>
开户行账号
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingCompanySyncDto.AdminUser">
<summary>
管理员ID
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingCompanySyncDto.AdminShowName">
<summary>
管理员姓名
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingCompanySyncDto.AdminUserEmail">
<summary>
管理员邮箱
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingCompanySyncDto.AdminUserMobile">
<summary>
管理员手机
</summary>
</member>
<member name="T:Myshipping.Core.MyshippingUserSyncDto">
<summary>
员工信息的同步dto
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingUserSyncDto.GID">
<summary>
员工ID
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingUserSyncDto.CODENAME">
<summary>
登录名
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingUserSyncDto.SHOWNAME">
<summary>
姓名
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingUserSyncDto.PASSWORD">
<summary>
密码
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingUserSyncDto.MOBILE">
<summary>
手机
</summary>
</member>
<member name="P:Myshipping.Core.MyshippingUserSyncDto.EMAIL1">
<summary>
邮箱
</summary>
</member>
<member name="T:Myshipping.Core.BStyleServiceExtension">
<summary>
B格

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>False</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\app.publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
</PropertyGroup>
</Project>

@ -23,6 +23,7 @@ using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
using Myshipping.Application.ConfigOption;
using Myshipping.Application.Event;
using Myshipping.Core.MQ;
namespace Myshipping.Web.Core;
@ -119,8 +120,13 @@ public class Startup : AppStartup
builder.AddSubscriber<LogZipClearSubscriber>();
//消息推送
builder.AddSubscriber<MessagePushSubscriber>();
//公司及用户信息的同步
builder.AddSubscriber<CompanyUserSyncSubscriber>();
});
//公司员工变动消息队列服务
services.AddHostedService<RecCompanyUserChangeService>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

@ -4,8 +4,8 @@
"DefaultDbType": "MySql",
//"DefaultDbString": "Data Source=60.209.125.238;Database=booking_customer_test;User ID=root;Password=Djy@Mysql.test;pooling=true;port=32006;sslmode=none;CharSet=utf8mb4;Convert Zero Datetime=True;Allow Zero Datetime=True;",
//"DefaultDbString": "Data Source=60.209.125.238;Database=booking_djy_test;User ID=root;Password=Djy@Mysql.test;pooling=true;port=32006;sslmode=none;CharSet=utf8mb4;Convert Zero Datetime=True;Allow Zero Datetime=True;",
//"DefaultDbString": "Data Source=47.104.222.4;Database=booking_customer;User ID=root;Password=d0pC?Vhxq!Aj5g29H-TZ=M74rX38~]Jw;pooling=true;port=3306;sslmode=none;CharSet=utf8mb4;Convert Zero Datetime=True;Allow Zero Datetime=True;",
"DefaultDbString": "Data Source=47.104.222.4;Database=booking_djy;User ID=root;Password=d0pC?Vhxq!Aj5g29H-TZ=M74rX38~]Jw;pooling=true;port=3306;sslmode=none;CharSet=utf8mb4;Convert Zero Datetime=True;Allow Zero Datetime=True;",
"DefaultDbString": "Data Source=47.104.222.4;Database=booking_customer;User ID=root;Password=d0pC?Vhxq!Aj5g29H-TZ=M74rX38~]Jw;pooling=true;port=3306;sslmode=none;CharSet=utf8mb4;Convert Zero Datetime=True;Allow Zero Datetime=True;",
//"DefaultDbString": "Data Source=47.104.222.4;Database=booking_djy;User ID=root;Password=d0pC?Vhxq!Aj5g29H-TZ=M74rX38~]Jw;pooling=true;port=3306;sslmode=none;CharSet=utf8mb4;Convert Zero Datetime=True;Allow Zero Datetime=True;",
"DbConfigs": [
{

Loading…
Cancel
Save