diff --git a/web/Djy.Common/Entity/WebConfig.cs b/web/Djy.Common/Entity/WebConfig.cs index 8c21f8b..486d6fe 100644 --- a/web/Djy.Common/Entity/WebConfig.cs +++ b/web/Djy.Common/Entity/WebConfig.cs @@ -17,11 +17,11 @@ namespace Common.Entity /// /// 钉钉机器人推送地址 预警发送地址 /// - public string ServerWarnApiUrl { get; set; } + public string ServerWarnApiUrl { get; set; } /// /// 重点错预警URl /// - public string ServerWarnApiUrlErr { get; set; } + public string ServerWarnApiUrlErr { get; set; } /// /// 关键字 /// @@ -39,6 +39,12 @@ namespace Common.Entity /// public bool IsDev { get; set; } = false; + + /// + /// 是否report + /// + public bool IsReport { get; set; } = false; + /// /// 站点名称 /// diff --git a/web/djy.Service/DjyService/ToolsService.cs b/web/djy.Service/DjyService/ToolsService.cs index 4dd52a8..07593a7 100644 --- a/web/djy.Service/DjyService/ToolsService.cs +++ b/web/djy.Service/DjyService/ToolsService.cs @@ -15,6 +15,7 @@ using Common.Extensions; using Common.Entity; using Common.Tools; using Common; +using djy.Service.Report; namespace djy.Service.DjyService { @@ -221,6 +222,10 @@ namespace djy.Service.DjyService { Hangfire.RecurringJob.AddOrUpdate(() => _LogsClear(), "0 0 0 * * ? ", TimeZoneInfo.Local); } + if (sysOptionConfig.Webconfig.IsReport) + { + Hangfire.RecurringJob.AddOrUpdate(() => new ReportService().TemplateTask(), "0 0 0 * * ? ", TimeZoneInfo.Local); + } } #endregion diff --git a/web/djy.Service/Report/ReportService.cs b/web/djy.Service/Report/ReportService.cs index 3b658a6..366e7b9 100644 --- a/web/djy.Service/Report/ReportService.cs +++ b/web/djy.Service/Report/ReportService.cs @@ -17,7 +17,6 @@ namespace djy.Service.Report public class ReportService : ServBase, IReportService { #region 获取模板 - public List GetTemplate() { try @@ -137,7 +136,6 @@ namespace djy.Service.Report if (isbook) { if (Gid.IsNull()) { - DS_Report report = new DS_Report(); report.GID = Guid.NewGuid().ToString("N"); report.UserID = user.GID; @@ -200,7 +198,76 @@ namespace djy.Service.Report return "取消成功!"; } } - #endregion + #endregion + + + + #region 定时任务 + public void TemplateTask() { + try + { ///获取所有订阅过的用户 + var datetime = DateTime.Now.AddDays(-1); + var list = DbBus.Get(DbList.DSDB).Select().Where(x => x.IsBook == true && x.EndTime < datetime).ToList(); + var templist = DbBus.Get(DbList.DSDB).Select().ToList(); + var fin = new FinanceService(); + foreach (var item in list) + { + var getfinrs = fin.Expend(new CustFee + { + SENDUSERID = item.UserID, + LURURENID = item.UserID, + CtnrCount = 1, + CtnrInfo = string.Empty, + BSTYPE = 17, + SENDTYPE = templist.Where(x => x.GID == item.TemplateID).Select(x => x.SendType).FirstOrDefault(), ////templist.SendType, + BSNO = item.GID, + }, 0); + if (!getfinrs.Status) + { + ///扣费失败 ,更改状态 + var date = DateTime.Now; + if (item.EndTime().Set(w => new DS_Report + { + IsBook = false, + }).Where(w => w.GID == item.GID).ExecuteAffrows(); + } + } + else + { + ////余额充足 ,执行扣费, + fin.Expend(new CustFee + { + SENDUSERID = item.UserID, + LURURENID = item.UserID, + CtnrCount = 1, + CtnrInfo = string.Empty, + BSTYPE = 17, + SENDTYPE = templist.Where(x => x.GID == item.TemplateID).Select(x => x.SendType).FirstOrDefault(), ////templist.SendType, + BSNO = item.GID, + }, 1); + DbBus.Get(DbList.DSDB).Update().Set(w => new DS_Report + { + EndTime = Convert.ToDateTime(w.EndTime).AddMonths(1),///修改截止日期 + LastUpdate = DateTime.Now, + LastUserId = item.GID + }).Where(w => w.GID == item.GID).ExecuteAffrows(); + } + } + } + catch (Exception ex) { + + Exception excep = ex; + while (excep != null) + { + _LogsAdd("TemplateTask", "post", $"报表定时任务:{excep.Message}{excep.StackTrace}"); + excep = excep.InnerException; + } + + } + + } + #endregion } } diff --git a/web/djy_Report/Controllers/Report/ReportController.cs b/web/djy_Report/Controllers/Report/ReportController.cs index 059f3da..242c5ed 100644 --- a/web/djy_Report/Controllers/Report/ReportController.cs +++ b/web/djy_Report/Controllers/Report/ReportController.cs @@ -10,37 +10,11 @@ using System.Text; namespace djy_Report.Controllers.Report { - [AllowAnonymous] + public class ReportController : ApiBase { - IReportService ser = IOC.AddServer(); - #region 获取模板 - [HttpGet("GetTemplate")] - public Response> GetTemplate() - { - var result = new Response>(); - try - { - var user = GetUserInfo(); - if (user == null) - { - result.Code = 401; - result.Message = "登录过期,请重新登录!"; - return result; - } - result.Result = ser.GetTemplate(); - } - catch (Exception ex) - { - result.Code = 500; - result.Message = ex.InnerException?.Message ?? ex.Message; - } - return result; - } - #endregion - #region 获取列表 [HttpGet("Load")] public object Load() @@ -125,8 +99,6 @@ namespace djy_Report.Controllers.Report result.data = ser.IsBook(Gid, TemplateId,isBook, DJson,user); return result; } - - #endregion diff --git a/web/djy_Report/Startup.cs b/web/djy_Report/Startup.cs index 3c43478..4d0a01a 100644 --- a/web/djy_Report/Startup.cs +++ b/web/djy_Report/Startup.cs @@ -111,7 +111,6 @@ namespace djy_Report var xmlPath = Path.Combine(basePath, "AppServer.xml"); }); - //ʼIOC IOC.container = services; @@ -122,7 +121,6 @@ namespace djy_Report // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { - //swagger if (env.IsDevelopment()) { @@ -163,7 +161,7 @@ namespace djy_Report endpoints.MapControllers(); }); // - //_Job(env); + _Job(env); } /// /// diff --git a/web/djy_Report/appsettings.Development.json b/web/djy_Report/appsettings.Development.json index afe8173..af1c564 100644 --- a/web/djy_Report/appsettings.Development.json +++ b/web/djy_Report/appsettings.Development.json @@ -11,6 +11,7 @@ "IdentServerUrl": "http://123.234.225.158:35101", "WebId": 234, "IsDev": true, + "IsReport": true, "Area": "ɽʡ|ൺ|", "DesKey": "2Fv6I7oV6AlCFEbN", "jwt_Audience": "admin", diff --git a/web/djy_Report/appsettings.json b/web/djy_Report/appsettings.json index 6b2c22f..7b17a07 100644 --- a/web/djy_Report/appsettings.json +++ b/web/djy_Report/appsettings.json @@ -10,6 +10,7 @@ "WebConfig": { "IdentServerUrl": "http://djy-identity.myshipping.net", "WebId": 234, + "IsReport": true, "Area": "ɽʡ|ൺ|", "DesKey": "2Fv6I7oV6AlCFEbN", "jwt_Audience": "admin",