wet 2 years ago
parent 4714036a7b
commit c41990df52

@ -17,11 +17,11 @@ namespace Common.Entity
/// <summary> /// <summary>
/// 钉钉机器人推送地址 预警发送地址 /// 钉钉机器人推送地址 预警发送地址
/// </summary> /// </summary>
public string ServerWarnApiUrl { get; set; } public string ServerWarnApiUrl { get; set; }
/// <summary> /// <summary>
/// 重点错预警URl /// 重点错预警URl
/// </summary> /// </summary>
public string ServerWarnApiUrlErr { get; set; } public string ServerWarnApiUrlErr { get; set; }
/// <summary> /// <summary>
/// 关键字 /// 关键字
/// </summary> /// </summary>
@ -39,6 +39,12 @@ namespace Common.Entity
/// </summary> /// </summary>
public bool IsDev { get; set; } = false; public bool IsDev { get; set; } = false;
/// <summary>
/// 是否report
/// </summary>
public bool IsReport { get; set; } = false;
/// <summary> /// <summary>
/// 站点名称 /// 站点名称
/// </summary> /// </summary>

@ -15,6 +15,7 @@ using Common.Extensions;
using Common.Entity; using Common.Entity;
using Common.Tools; using Common.Tools;
using Common; using Common;
using djy.Service.Report;
namespace djy.Service.DjyService namespace djy.Service.DjyService
{ {
@ -221,6 +222,10 @@ namespace djy.Service.DjyService
{ {
Hangfire.RecurringJob.AddOrUpdate(() => _LogsClear(), "0 0 0 * * ? ", TimeZoneInfo.Local); 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 #endregion

@ -17,7 +17,6 @@ namespace djy.Service.Report
public class ReportService : ServBase, IReportService public class ReportService : ServBase, IReportService
{ {
#region 获取模板 #region 获取模板
public List<DS_ReportTemplate> GetTemplate() public List<DS_ReportTemplate> GetTemplate()
{ {
try try
@ -137,7 +136,6 @@ namespace djy.Service.Report
if (isbook) { if (isbook) {
if (Gid.IsNull()) if (Gid.IsNull())
{ {
DS_Report report = new DS_Report(); DS_Report report = new DS_Report();
report.GID = Guid.NewGuid().ToString("N"); report.GID = Guid.NewGuid().ToString("N");
report.UserID = user.GID; report.UserID = user.GID;
@ -200,7 +198,76 @@ namespace djy.Service.Report
return "取消成功!"; return "取消成功!";
} }
} }
#endregion #endregion
#region 定时任务
public void TemplateTask() {
try
{ ///获取所有订阅过的用户
var datetime = DateTime.Now.AddDays(-1);
var list = DbBus.Get(DbList.DSDB).Select<DS_Report>().Where(x => x.IsBook == true && x.EndTime < datetime).ToList();
var templist = DbBus.Get(DbList.DSDB).Select<DS_ReportTemplate>().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<date) {
DbBus.Get(DbList.DSDB).Update<DS_Report>().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<DS_Report>().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
} }
} }

@ -10,37 +10,11 @@ using System.Text;
namespace djy_Report.Controllers.Report namespace djy_Report.Controllers.Report
{ {
[AllowAnonymous]
public class ReportController : ApiBase public class ReportController : ApiBase
{ {
IReportService ser = IOC.AddServer<IReportService>(); IReportService ser = IOC.AddServer<IReportService>();
#region 获取模板
[HttpGet("GetTemplate")]
public Response<List<DS_ReportTemplate>> GetTemplate()
{
var result = new Response<List<DS_ReportTemplate>>();
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 获取列表 #region 获取列表
[HttpGet("Load")] [HttpGet("Load")]
public object Load() public object Load()
@ -125,8 +99,6 @@ namespace djy_Report.Controllers.Report
result.data = ser.IsBook(Gid, TemplateId,isBook, DJson,user); result.data = ser.IsBook(Gid, TemplateId,isBook, DJson,user);
return result; return result;
} }
#endregion #endregion

@ -111,7 +111,6 @@ namespace djy_Report
var xmlPath = Path.Combine(basePath, "AppServer.xml"); var xmlPath = Path.Combine(basePath, "AppServer.xml");
}); });
//初始化IOC //初始化IOC
IOC.container = services; 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. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {
//swagger //swagger
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
@ -163,7 +161,7 @@ namespace djy_Report
endpoints.MapControllers(); endpoints.MapControllers();
}); });
//启动运行启动 //启动运行启动
//_Job(env); _Job(env);
} }
/// <summary> /// <summary>
/// 启动任务请求 /// 启动任务请求

@ -11,6 +11,7 @@
"IdentServerUrl": "http://123.234.225.158:35101", "IdentServerUrl": "http://123.234.225.158:35101",
"WebId": 234, "WebId": 234,
"IsDev": true, "IsDev": true,
"IsReport": true,
"Area": "山东省|青岛市|市南区", "Area": "山东省|青岛市|市南区",
"DesKey": "2Fv6I7oV6AlCFEbN", "DesKey": "2Fv6I7oV6AlCFEbN",
"jwt_Audience": "admin", "jwt_Audience": "admin",

@ -10,6 +10,7 @@
"WebConfig": { "WebConfig": {
"IdentServerUrl": "http://djy-identity.myshipping.net", "IdentServerUrl": "http://djy-identity.myshipping.net",
"WebId": 234, "WebId": 234,
"IsReport": true,
"Area": "山东省|青岛市|市南区", "Area": "山东省|青岛市|市南区",
"DesKey": "2Fv6I7oV6AlCFEbN", "DesKey": "2Fv6I7oV6AlCFEbN",
"jwt_Audience": "admin", "jwt_Audience": "admin",

Loading…
Cancel
Save