Browse Source

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

yuanrf 1 year ago
parent
commit
28f5247beb

+ 31 - 8
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -30,6 +30,7 @@ using System.Globalization;
 using NPOI.POIFS.Properties;
 using NPOI.POIFS.Properties;
 using SixLabors.ImageSharp.ColorSpaces;
 using SixLabors.ImageSharp.ColorSpaces;
 using OASystem.Domain.ViewModels.QiYeWeChat;
 using OASystem.Domain.ViewModels.QiYeWeChat;
+using System.Diagnostics;
 
 
 namespace OASystem.API.Controllers
 namespace OASystem.API.Controllers
 {
 {
@@ -50,13 +51,14 @@ namespace OASystem.API.Controllers
         private readonly ForeignReceivablesRepository _ForForeignReceivablesRep;  //对外收款账单仓库
         private readonly ForeignReceivablesRepository _ForForeignReceivablesRep;  //对外收款账单仓库
         private readonly ProceedsReceivedRepository _proceedsReceivedRep;  //已收款项仓库
         private readonly ProceedsReceivedRepository _proceedsReceivedRep;  //已收款项仓库
         private readonly PaymentRefundAndOtherMoneyRepository _paymentRefundAndOtherMoneyRep; //收款退还与其他款项 仓库
         private readonly PaymentRefundAndOtherMoneyRepository _paymentRefundAndOtherMoneyRep; //收款退还与其他款项 仓库
+        private readonly DelegationInfoRepository _delegationInfoRep; //团组信息 仓库
 
 
         /// <summary>
         /// <summary>
         /// 初始化
         /// 初始化
         /// </summary>
         /// </summary>
         public FinancialController(IMapper mapper, IConfiguration configuration, DailyFeePaymentRepository daiRep, SqlSugarClient sqlSugar, SetDataTypeRepository setDataTypeRep,
         public FinancialController(IMapper mapper, IConfiguration configuration, DailyFeePaymentRepository daiRep, SqlSugarClient sqlSugar, SetDataTypeRepository setDataTypeRep,
             TeamRateRepository teamRateRep, ForeignReceivablesRepository ForForeignReceivablesRep, ProceedsReceivedRepository proceedsReceivedRep,
             TeamRateRepository teamRateRep, ForeignReceivablesRepository ForForeignReceivablesRep, ProceedsReceivedRepository proceedsReceivedRep,
-            PaymentRefundAndOtherMoneyRepository paymentRefundAndOtherMoneyRep, HttpClient httpClient)
+            PaymentRefundAndOtherMoneyRepository paymentRefundAndOtherMoneyRep, HttpClient httpClient, DelegationInfoRepository delegationInfoRep)
         {
         {
             _mapper = mapper;
             _mapper = mapper;
             _config = configuration;
             _config = configuration;
@@ -68,6 +70,7 @@ namespace OASystem.API.Controllers
             _proceedsReceivedRep = proceedsReceivedRep;
             _proceedsReceivedRep = proceedsReceivedRep;
             _paymentRefundAndOtherMoneyRep = paymentRefundAndOtherMoneyRep;
             _paymentRefundAndOtherMoneyRep = paymentRefundAndOtherMoneyRep;
             _httpClient = httpClient;
             _httpClient = httpClient;
+            _delegationInfoRep = delegationInfoRep;
         }
         }
 
 
         #region 日付申请
         #region 日付申请
@@ -335,21 +338,41 @@ namespace OASystem.API.Controllers
                 //迁移数据更新团组汇率
                 //迁移数据更新团组汇率
                 //Result teamRateData1 = await _teamRateRep.GetGroupRateChangeData();
                 //Result teamRateData1 = await _teamRateRep.GetGroupRateChangeData();
 
 
-                //PostGroupTeamRateHot
-
                 //var data = await _teamRateRep.PostGroupTeamRateHot();
                 //var data = await _teamRateRep.PostGroupTeamRateHot();
 
 
-                Result teamRateData = await _teamRateRep.GetGroupRateDataSource(dto);
-                if (teamRateData.Code != 0)
+
+                Stopwatch stopwatch = Stopwatch.StartNew();
+
+                GroupNameDto groupNameDto = new GroupNameDto() { PortType = dto.PortType };
+                var groups = await _delegationInfoRep.GetGroupNameList(groupNameDto);
+
+                List<CurrencyHot> _currData = new List<CurrencyHot>();
+
+                string currData = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("GroupTeamCurrencyData");//string 取
+
+                if (!string.IsNullOrEmpty(currData))
                 {
                 {
-                    return Ok(JsonView(false, teamRateData.Msg));
+                    _currData = JsonConvert.DeserializeObject<List<CurrencyHot>>(currData);
                 }
                 }
-                return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
+                else
+                {
+                    _currData = await _teamRateRep.PostGroupTeamRateHot();
+
+                    //过期时间 25 Hours
+                    TimeSpan ts = DateTime.Now.AddHours(25).TimeOfDay;
+                    await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync("GroupTeamCurrencyData", JsonConvert.SerializeObject(_currData), ts);
+                }
+
+                var _data = new { GroupData = groups.Data, TeamRateData = _currData };
+
+                stopwatch.Stop();
+
+                return Ok(JsonView(true, $"查询成功!耗时:{stopwatch.ElapsedMilliseconds / 1000}s", _data));
+
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
                 return Ok(JsonView(false, ex.Message));
                 return Ok(JsonView(false, ex.Message));
-                throw;
             }
             }
         }
         }
 
 

+ 101 - 6
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -6,7 +6,9 @@ using OASystem.Infrastructure.Repositories.Groups;
 using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities;
 using Quartz.Util;
 using Quartz.Util;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Net.Http.Headers;
 using System.Net.Http.Headers;
+using static QRCoder.PayloadGenerator.SwissQrCode;
 
 
 namespace OASystem.API.Controllers
 namespace OASystem.API.Controllers
 {
 {
@@ -1366,6 +1368,53 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
         #endregion
         #endregion
 
 
         #region 商邀资料
         #region 商邀资料
+
+
+        /// <summary>
+        /// 商邀资料 基础数据源
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> QueryIOAInitData(QueryIOAInitDataDto dto)
+        {
+            try
+            {
+                #region 参数验证
+
+                if (dto.PortType < 1) return Ok(JsonView(false, "请传入有效的PortType参数!"));
+
+                #endregion
+
+                List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.JietuanTime).ToList();
+                List<Res_InvitationOfficialActivityData> _ioaDatas = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().Where(it => it.IsDel == 0).ToList();
+                List<Sys_Users> _Users = _sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0).ToList();
+
+                var _countryData = _ioaDatas.Select(it => it.Country).Distinct().ToList(); _countryData.Remove("");
+                var _inviterData = _ioaDatas.Select(it => it.UnitName).Distinct().ToList(); _inviterData.Remove("");
+                var _contactData = _ioaDatas.Select(it => it.Contact).Distinct().ToList(); _contactData.Remove("");
+                var _domainData = _ioaDatas.Select(it => it.Field).Distinct().ToList(); _domainData.Remove("");
+                var _groupNameData = _DelegationInfos.Select(it => new { it.Id, it.TeamName }).ToList();
+                var _userNameData = _Users.Select(it => new { it.Id, it.CnName }).ToList();
+
+                var _data = new {
+                    CountryData = _countryData,
+                    InviterData = _inviterData,
+                    DomainData = _domainData,
+                    ContactData = _contactData,
+                    GroupNameData = _groupNameData,
+                    UserNameData = _userNameData,
+                };
+
+                return Ok(JsonView(true, $"查询成功!", _data));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, ex.Message));
+            }
+        }
+
         /// <summary>
         /// <summary>
         /// 商邀资料查询
         /// 商邀资料查询
         /// </summary>
         /// </summary>
@@ -1377,17 +1426,63 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
         {
         {
             try
             try
             {
             {
-                Result groupData = await _InvitationOfficialActivityDataRep.QueryInvitationOfficialActivityData(dto);
-                if (groupData.Code != 0)
+                #region 参数验证
+
+                if (dto.PageIndex < 1) return Ok(JsonView(false, "请传入有效的PageIndex参数!"));
+
+                if (dto.PageSize < 1) return Ok(JsonView(false, "请传入有效的PageSize参数!"));
+
+                #endregion
+
+                string sqlWhere = string.Empty;
+                if (!string.IsNullOrWhiteSpace(dto.Country)) { sqlWhere += string.Format(@" And i.Country like '%{0}%'", dto.Country); }
+                if (!string.IsNullOrWhiteSpace(dto.UnitName)) { sqlWhere += string.Format(@" And i.UnitName like '%{0}%'", dto.UnitName); }
+                if (!string.IsNullOrWhiteSpace(dto.Contact)) { sqlWhere += string.Format(@" And i.Contact like '%{0}%'", dto.Contact); }
+                if (!string.IsNullOrWhiteSpace(dto.Delegation)) { sqlWhere += string.Format(@" And i.Delegation like '%{0}%'", dto.Delegation); }
+                if (!string.IsNullOrWhiteSpace(dto.Field)) { sqlWhere += string.Format(@" And i.Field like '%{0}%'", dto.Field); }
+
+                if (dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString())) { sqlWhere += string.Format(@" And i.CreateUserId={0}", dto.CreateUserId); }
+                if (!string.IsNullOrWhiteSpace(dto.StartCreateTime) && !string.IsNullOrWhiteSpace(dto.EndCreateTime))
                 {
                 {
-                    return Ok(JsonView(false, groupData.Msg));
+                    sqlWhere += string.Format(@" And i.CreateTime between '{0}' and '{1}'", dto.StartCreateTime, dto.EndCreateTime);
                 }
                 }
-                return Ok(JsonView(true, groupData.Msg, groupData.Data));
+                sqlWhere += string.Format(@"And i.Isdel={0}", 0);
+
+                if (!string.IsNullOrEmpty(sqlWhere.Trim()))
+                {
+                    Regex r = new Regex("And");
+                    sqlWhere = r.Replace(sqlWhere, "Where", 1);
+                }
+                string sql = string.Format(@"Select ROW_NUMBER() Over(Order By i.CreateTime Desc) As Row_Number,
+                                             i.*,u.CnName As CreateUserName 
+                                             From Res_InvitationOfficialActivityData i 
+                                             Left Join Sys_Users u On i.CreateUserId = u.Id {0}", sqlWhere);
+
+                int totalCount = 0;
+
+                List<InvitationOfficialActivityDataView> _ivitiesViews = _sqlSugar.SqlQueryable<InvitationOfficialActivityDataView>(sql).ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
+
+                List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().ToList();
+
+                foreach (var item in _ivitiesViews)
+                {
+                    string delegationNameList = "";
+                    string[] DelegationName = item.Delegation.Split(',');
+                    for (int i = 0; i < DelegationName.Length; i++)
+                    {
+                        delegationNameList += _DelegationInfos.Find(it => it.Id == int.Parse(DelegationName[i]))?.TeamName ?? "Unknown" + ",";
+                    }
+                    if (!string.IsNullOrWhiteSpace(delegationNameList))
+                    {
+                        item.DelegationStr = delegationNameList.Substring(0, delegationNameList.Length - 1);
+                    }
+                }
+
+                return Ok(JsonView(true, $"查询成功!", _ivitiesViews, totalCount));
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
-                return Ok(JsonView(false, "程序错误!"));
-                throw;
+                return Ok(JsonView(false, ex.Message));
             }
             }
         }
         }
         /// <summary>
         /// <summary>

+ 1 - 0
OASystem/OASystem.Api/OAMethodLib/Quartz/Business/DeleReminderMessage.cs

@@ -83,5 +83,6 @@ namespace OASystem.API.OAMethodLib.Quartz.Business
             }
             }
         }
         }
 
 
+
     }
     }
 }
 }

+ 30 - 0
OASystem/OASystem.Api/OAMethodLib/Quartz/Business/TeamCurrency.cs

@@ -0,0 +1,30 @@
+using OASystem.Infrastructure.Repositories.Groups;
+
+namespace OASystem.API.OAMethodLib.Quartz.Business
+{
+    public class TeamCurrency
+    {
+
+        private readonly static TeamRateRepository _grpCurrencyRep = AutofacIocManager.Instance.GetService<TeamRateRepository>();
+
+        /// <summary>
+        /// 团组币种信息
+        /// 每天 凌晨零点更新
+        /// </summary>
+        public static async void PostTeamCurrencyUpdate()
+        {
+            string grpCurrencyName = "GroupTeamCurrencyData";
+
+            var _currData = await _grpCurrencyRep.PostGroupTeamRateHot();
+            if (_currData != null)
+            {
+              var s = await RedisRepository.RedisFactory.CreateRedisRepository().KeyDeleteAsync(grpCurrencyName);
+                if (s)
+                {
+                    TimeSpan ts = DateTime.Now.AddHours(25).TimeOfDay;
+                    await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync(grpCurrencyName,JsonConvert.SerializeObject(_currData), ts);
+                }
+            }
+        }
+    }
+}

+ 33 - 0
OASystem/OASystem.Api/OAMethodLib/Quartz/Jobs/GroupTeamCurrencyJob.cs

@@ -0,0 +1,33 @@
+using OASystem.API.OAMethodLib.Quartz.Business;
+using Quartz;
+using QuzrtzJob.Factory;
+
+namespace OASystem.API.OAMethodLib.Quartz.Jobs
+{
+    /// <summary>
+    /// 团组币种 定时任务
+    /// </summary>
+    public class GroupTeamCurrencyJob : IJob
+    {
+        private readonly ILogger<GroupTeamCurrencyJob> _logger;
+
+        /// <summary>
+        /// 团组币种
+        /// 定时任务
+        /// </summary>
+        /// <param name="logger"></param>
+        public GroupTeamCurrencyJob(ILogger<GroupTeamCurrencyJob> logger)
+        {
+            _logger = logger;
+        }
+
+        public Task Execute(IJobExecutionContext context)
+        {
+            _logger.LogInformation("调用团组币种接口 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
+            //在此处编写任务业务代码
+            TeamCurrency.PostTeamCurrencyUpdate();
+
+            return Task.CompletedTask;
+        }
+    }
+}

+ 6 - 0
OASystem/OASystem.Api/OAMethodLib/Quartz/QuartzFactory.cs

@@ -40,16 +40,22 @@ namespace QuzrtzJob.Factory
                             //.WithSimpleSchedule(x => x.WithIntervalInSeconds(60).RepeatForever())//每六十秒执行一次
                             //.WithSimpleSchedule(x => x.WithIntervalInSeconds(60).RepeatForever())//每六十秒执行一次
                             .WithCronSchedule("0 0 9,18 * * ?") //每天早上九点和下午六点触发
                             .WithCronSchedule("0 0 9,18 * * ?") //每天早上九点和下午六点触发
                             .Build();
                             .Build();
+            var teamCurrencyTrigger = TriggerBuilder.Create()
+                            //.WithSimpleSchedule(x => x.WithIntervalInSeconds(60).RepeatForever())//每六十秒执行一次
+                            .WithCronSchedule("0 0 0 * * ? ") //每天零点零分点触发
+                            .Build();
 
 
             //5、创建任务
             //5、创建任务
             var jobDetail = JobBuilder.Create<ALiYunPostMessageJob>().WithIdentity("job1", "group") .Build();
             var jobDetail = JobBuilder.Create<ALiYunPostMessageJob>().WithIdentity("job1", "group") .Build();
             var taskJobDetail = JobBuilder.Create<TaskJob>().WithIdentity("job2", "group").Build();
             var taskJobDetail = JobBuilder.Create<TaskJob>().WithIdentity("job2", "group").Build();
             var taskMsgJobDetail = JobBuilder.Create<TaskNewsFeedJob>().WithIdentity("job3", "group").Build();
             var taskMsgJobDetail = JobBuilder.Create<TaskNewsFeedJob>().WithIdentity("job3", "group").Build();
+            var teamCurrencyJobDetail = JobBuilder.Create<GroupTeamCurrencyJob>().WithIdentity("job4", "group").Build();
 
 
             //6、将触发器和任务器绑定到调度器中
             //6、将触发器和任务器绑定到调度器中
             await _scheduler.ScheduleJob(jobDetail, trigger);
             await _scheduler.ScheduleJob(jobDetail, trigger);
             await _scheduler.ScheduleJob(taskJobDetail, taskTrigger);
             await _scheduler.ScheduleJob(taskJobDetail, taskTrigger);
             await _scheduler.ScheduleJob(taskMsgJobDetail, taskMsgTrigger);
             await _scheduler.ScheduleJob(taskMsgJobDetail, taskMsgTrigger);
+            await _scheduler.ScheduleJob(teamCurrencyJobDetail, teamCurrencyTrigger);
 
 
 
 
             return await Task.FromResult("将触发器和任务器绑定到调度器中完成");
             return await Task.FromResult("将触发器和任务器绑定到调度器中完成");

+ 4 - 0
OASystem/OASystem.Domain/Dtos/Resource/InvitationOfficialActivityDataDto.cs

@@ -6,6 +6,10 @@ using System.Threading.Tasks;
 
 
 namespace OASystem.Domain.Dtos.Resource
 namespace OASystem.Domain.Dtos.Resource
 {
 {
+
+    public class QueryIOAInitDataDto : PortDtoBase { }
+
+
     public class QueryInvitationOfficialActivityDataDto:DtoBase
     public class QueryInvitationOfficialActivityDataDto:DtoBase
     {
     {
         /// <summary>
         /// <summary>

+ 1 - 0
OASystem/OASystem.Domain/ViewModels/Resource/InvitationOfficialActivityDataView.cs

@@ -10,6 +10,7 @@ namespace OASystem.Domain.ViewModels.Resource
 {
 {
     public class InvitationOfficialActivityDataView: Res_InvitationOfficialActivityData
     public class InvitationOfficialActivityDataView: Res_InvitationOfficialActivityData
     {
     {
+        public int Row_Number { get; set; }
         public string CreateUserName { get; set; }
         public string CreateUserName { get; set; }
         public string DelegationStr { get;set; }
         public string DelegationStr { get;set; }
     }
     }

+ 1 - 14
OASystem/OASystem.Infrastructure/Repositories/Groups/TeamRateRepository.cs

@@ -682,23 +682,10 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
 
             var teamRateInfo = _sqlSugar.SqlQueryable<TeamRateInfoView>(teamRateInfoSql).ToList();
             var teamRateInfo = _sqlSugar.SqlQueryable<TeamRateInfoView>(teamRateInfoSql).ToList();
 
 
-            List<SetDataInfoView> currencyDatas = new List<SetDataInfoView>();
             #region 获取所有币种
             #region 获取所有币种
 
 
             string sql = string.Format(@"Select * From Sys_SetData Where STid = {0} And IsDel = 0", 66);
             string sql = string.Format(@"Select * From Sys_SetData Where STid = {0} And IsDel = 0", 66);
-            var DBdata = _setDataRep.GetListBySqlWithNolock(sql);
-
-            if (DBdata == null || DBdata.Count == 0)
-            {
-                return _view;
-            }
-
-            currencyDatas = DBdata.Select(x => new SetDataInfoView
-            {
-                Name = x.Name,
-                Id = x.Id,
-                Remark = x.Remark,
-            }).ToList();
+            var currencyDatas = _sqlSugar.SqlQueryable<SetDataInfoView>(sql).ToList();
 
 
             _view = currencyDatas.Select(it => new CurrencyHot() { CurrencyId = it.Id,  CurrencyCode = it.Name, CurrencyName = it.Remark}).ToList();
             _view = currencyDatas.Select(it => new CurrencyHot() { CurrencyId = it.Id,  CurrencyCode = it.Name, CurrencyName = it.Remark}).ToList();
             #endregion
             #endregion

+ 8 - 4
OASystem/OASystem.Infrastructure/Repositories/Resource/InvitationOfficialActivityDataRepository.cs

@@ -55,17 +55,21 @@ namespace OASystem.Infrastructure.Repositories.Resource
                 }
                 }
                 string sql = string.Format(@"select i.*,(select CnName from Sys_Users where Id=i.CreateUserId ) as CreateUserName from 
                 string sql = string.Format(@"select i.*,(select CnName from Sys_Users where Id=i.CreateUserId ) as CreateUserName from 
                                             Res_InvitationOfficialActivityData i {0} order by CreateTime desc", sqlWhere);
                                             Res_InvitationOfficialActivityData i {0} order by CreateTime desc", sqlWhere);
-                List<InvitationOfficialActivityDataView> _ivitiesViews = await _sqlSugar.SqlQueryable<InvitationOfficialActivityDataView>(sql).ToListAsync();
+                List<InvitationOfficialActivityDataView> _ivitiesViews =  _sqlSugar.SqlQueryable<InvitationOfficialActivityDataView>(sql).ToList();
                 if (_ivitiesViews.Count != 0)
                 if (_ivitiesViews.Count != 0)
                 {
                 {
+                    List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().ToList();
+
                     foreach (var item in _ivitiesViews)
                     foreach (var item in _ivitiesViews)
                     {
                     {
                         string delegationNameList = "";
                         string delegationNameList = "";
                         string[] DelegationName = item.Delegation.Split(',');
                         string[] DelegationName = item.Delegation.Split(',');
                         for (int i = 0; i < DelegationName.Length; i++)
                         for (int i = 0; i < DelegationName.Length; i++)
                         {
                         {
-                            Grp_DelegationInfo _DelegationInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(a => a.Id ==int.Parse(DelegationName[i]));
-                            if (_DelegationInfo != null) { delegationNameList += _DelegationInfo.TeamName + ","; }
+                            //Grp_DelegationInfo _DelegationInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(a => a.Id ==int.Parse(DelegationName[i]));
+                            //if (_DelegationInfo != null) { delegationNameList += _DelegationInfo.TeamName + ","; }
+
+                            delegationNameList += _DelegationInfos.Find(it => it.Id == int.Parse(DelegationName[i]))?.TeamName ?? "Unknown" + ",";
                         }
                         }
                         if (!string.IsNullOrWhiteSpace(delegationNameList))
                         if (!string.IsNullOrWhiteSpace(delegationNameList))
                         {
                         {
@@ -113,7 +117,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
-                result = new Result() { Code = -2, Msg = "未知错误" };
+                result = new Result() { Code = -2, Msg = ex.Message };
             }
             }
             return result;
             return result;
         }
         }