wet 2 years ago
parent 7893a0dd12
commit 4714036a7b

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using djy.Model;
using Common;
using djy.Model.AmsDto;
using Common.Utilities;
using djy.Model.Ams;
using djy.IService.Djy;
using Common.DJYModel;
using djy.Model.Report;
namespace djy.IService.Report
{
public interface IReportService : IsBase
{
List<DS_ReportTemplate> GetTemplate();
TableData Load(User user);
string SaveInfo(DS_Report dto, User user);
string IsBook(string Gid, string TemplateId, bool isBook, string DJson, User user);
}
}

@ -15,8 +15,4 @@
<ProjectReference Include="..\djy.Model\djy.Model.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Report\" />
</ItemGroup>
</Project>

@ -0,0 +1,57 @@
using FreeSql.DataAnnotations;
using Newtonsoft.Json;
using System;
using System.ComponentModel.DataAnnotations;
namespace djy.Model.Report
{
[JsonObject(MemberSerialization.OptIn), Table(Name = "DS_Report", DisableSyncStructure = true)]
public class DS_Report
{
[JsonProperty, Column(IsPrimary = true, IsNullable = false)]
[MaxLength(50)]
public string GID { get; set; }
[MaxLength(50)]
public string UserID { get; set; }
[MaxLength(50)]
public string UserName { get; set; }
[MaxLength(50)]
public string CompID { get; set; }
[MaxLength(100)]
public string CompName { get; set; }
[MaxLength(50)]
public string TemplateID { get; set; }
public bool? IsBook { get; set; }
public bool? IsWechat { get; set; }
public bool? IsEmail { get; set; }
[MaxLength(5000)]
public string DJson { get; set; }
public DateTime? EndTime { get; set; }
public DateTime CreateTime { get; set; }
public DateTime? LastUpdate { get; set; }
public bool? IsDel { get; set; }
[MaxLength(50)]
public string LastUserId { get; set; }
}
}

@ -0,0 +1,27 @@
using FreeSql.DataAnnotations;
using Newtonsoft.Json;
using System;
using System.ComponentModel.DataAnnotations;
namespace djy.Model.Report
{
[JsonObject(MemberSerialization.OptIn), Table(Name = "DS_ReportTemplate", DisableSyncStructure = true)]
public class DS_ReportTemplate
{
[JsonProperty, Column(IsPrimary = true, IsNullable = false)]
[MaxLength(50)]
public string GID { get; set; }
[MaxLength(50)]
public string TemplateName { get; set; }
[MaxLength(5000)]
public string TemplateDescribe { get; set; }
public DateTime CreateTime { get; set; }
public int SendType { get; set; }
}
}

@ -0,0 +1,52 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace djy.Model.ReportDto
{
public class ReportDto
{
public string GID { get; set; }
public string UserID { get; set; }
public string UserName { get; set; }
public string CompID { get; set; }
public string CompName { get; set; }
public string TemplateID { get; set; }
public string TemplateName { get; set; }
public string TemplateDescribe { get; set; }
public bool? IsBook { get; set; }
public bool? IsWechat { get; set; }
public bool? IsEmail { get; set; }
public string DJson { get; set; }
public DateTime? EndTime { get; set; }
public DateTime CreateTime { get; set; }
}
}

@ -28,8 +28,4 @@
<ProjectReference Include="..\Djy.Common\Common.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Report\" />
</ItemGroup>
</Project>

@ -39,6 +39,11 @@ namespace djy.Service.DjyService
/// Common库
/// </summary>
public const string Common = "Common";
/// <summary>
/// 东胜库
/// </summary>
public const string DSDB = "DSDB";
}
/// <summary>

@ -0,0 +1,206 @@
using Common.DJYModel;
using Common.Extensions;
using Common.Utilities;
using djy.IService.Report;
using djy.Model.Report;
using djy.Model.ReportDto;
using djy.Service.DjyService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace djy.Service.Report
{
public class ReportService : ServBase, IReportService
{
#region 获取模板
public List<DS_ReportTemplate> GetTemplate()
{
try
{
var List = DbBus.Get(DbList.DSDB).Select<DS_ReportTemplate>().ToList();
return List;
}
catch (Exception e)
{
throw;
}
}
#endregion
#region 列表
public TableData Load(User user)
{
var result = new TableData();
var templist = DbBus.Get(DbList.DSDB).Select<DS_ReportTemplate>().ToList();
List<ReportDto> query = DbBus.Get(DbList.DSDB).Select<DS_ReportTemplate, DS_Report>().LeftJoin((temp, main) => main.TemplateID == temp.GID).
WhereIf(user.CompId != null, x => x.t2.CompID == user.CompId).ToList((temp, main) => new ReportDto
{
GID = main.GID,
UserID = main.UserID,
UserName = main.UserName,
CompID = main.CompID,
CompName = main.CompName,
TemplateID = main.TemplateID,
TemplateName = temp.TemplateName,
TemplateDescribe = temp.TemplateDescribe,
IsBook = main.IsBook,
IsWechat = main.IsWechat,
IsEmail = main.IsEmail,
DJson = main.DJson,
EndTime = main.EndTime,
CreateTime = main.CreateTime
}).ToList();
foreach (var item in templist)
{
var it = query.Where(x => x.TemplateID == item.GID).FirstOrDefault();
if (it==null) {
query.Add(new ReportDto
{
GID = null,
UserID = user.GID,
UserName = user.SHOWNAME,
CompID = user.CompId,
CompName = user.COMNAME,
TemplateID = item.GID,
TemplateName = item.TemplateName,
TemplateDescribe = item.TemplateDescribe,
IsBook = null,
IsWechat = null,
IsEmail = null,
DJson = null,
EndTime = null,
CreateTime = DateTime.Now
});
}
}
result.data = query;
result.count = (int)query.Count();
return result;
}
#endregion
#region 新增编辑
public string SaveInfo(DS_Report dto, User user)
{
string guid = dto.GID;
var list = DbBus.Get(DbList.DSDB).Select<DS_Report>().WhereIf(dto.GID != null, x => x.GID != dto.GID).
Where(x => x.IsDel != true && x.TemplateID == dto.TemplateID && x.CompID == user.Comid).ToOne();
if (list != null)
{
return "-1";
}
if (dto.GID.IsNull())
{
DS_Report report = dto.MapTo<DS_Report>();
report.GID = Guid.NewGuid().ToString("N");
report.UserID = user.GID;
report.UserName = user.SHOWNAME;
report.CompID = user.CompId;
report.CompName = user.COMNAME;
report.IsBook = false;
report.IsEmail = false;
report.IsDel = false;
report.CreateTime = DateTime.Now;
report.LastUpdate = DateTime.Now;
DbBus.Get(DbList.DSDB).Insert(report).ExecuteAffrows();
guid = report.GID;
}
else
{
DbBus.Get(DbList.DSDB).Update<DS_Report>().Set(w => new DS_Report
{
TemplateID = dto.TemplateID,
IsBook = dto.IsBook,
IsEmail=dto.IsEmail,
DJson=dto.DJson,
LastUpdate = DateTime.Now,
LastUserId=user.GID
}).Where(w => w.GID == dto.GID).ExecuteAffrows();
}
return guid;
}
#endregion
#region 取消订阅/订阅
public string IsBook(string Gid,string TemplateId, bool isbook,string DJson, User user) {
if (isbook) {
if (Gid.IsNull())
{
DS_Report report = new DS_Report();
report.GID = Guid.NewGuid().ToString("N");
report.UserID = user.GID;
report.UserName = user.SHOWNAME;
report.CompID = user.CompId;
report.CompName = user.COMNAME;
report.IsDel = false;
report.TemplateID = TemplateId;
report.CreateTime = DateTime.Now;
report.LastUpdate = DateTime.Now;
DbBus.Get(DbList.DSDB).Insert(report).ExecuteAffrows();
Gid = report.GID;
}
////订阅
var fin = new FinanceService();
var templist = DbBus.Get(DbList.DSDB).Select<DS_ReportTemplate>().
Where(x => x.GID==TemplateId).ToOne();
var getfinrs = fin.Expend(new CustFee
{
SENDUSERID = user.GID,
LURURENID = user.GID,
CtnrCount = 1,
CtnrInfo = string.Empty,
BSTYPE = 17,
SENDTYPE = templist.SendType,
BSNO = Gid,
}, 0);
if (!getfinrs.Status)
{
return getfinrs.Message;
}
DbBus.Get(DbList.DSDB).Update<DS_Report>().Set(w => new DS_Report
{
IsBook = true,
IsEmail=true,
DJson=DJson,
EndTime=DateTime.Now.AddMonths(1),
LastUpdate = DateTime.Now,
LastUserId = user.GID
}).Where(w => w.GID ==Gid).ExecuteAffrows();
fin.Expend(new CustFee
{
SENDUSERID = user.GID,
LURURENID = user.GID,
CtnrCount = 1,
CtnrInfo = string.Empty,
BSTYPE = 17,
SENDTYPE = templist.SendType,
BSNO = Gid,
}, 1);
return "订阅成功!";
}
else {
DbBus.Get(DbList.DSDB).Update<DS_Report>().Set(w => new DS_Report
{
IsBook = false,
LastUpdate = DateTime.Now,
LastUserId = user.GID
}).Where(w => w.GID == Gid).ExecuteAffrows();
return "取消成功!";
}
}
#endregion
}
}

@ -23,8 +23,4 @@
<ProjectReference Include="..\djy.Model\djy.Model.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Report\" />
</ItemGroup>
</Project>

@ -1,15 +1,134 @@
using Microsoft.AspNetCore.Authorization;
using Common.DJYModel;
using Common.Utilities;
using djy.IService.Report;
using djy.Model.Report;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Text;
namespace djy_Report.Controllers.Report
{
[AllowAnonymous]
public class ReportController : ApiBase
{
[HttpGet]
public string GetName() {
return "1";
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 获取列表
[HttpGet("Load")]
public object Load()
{
//UserAuthorityDto aut = GetUserAuthorityToFormDto("modAmsList");
//if (!aut.IsPower)
//{
// var result = new Response();
// result.Code = 201;
// result.Message = "没有权限!";
// return result;
//}
var user = GetUserInfo();
if (user == null)
{
var result = new Response();
result.Code = 401;
result.Message = "登录过期,请重新登录!";
return result;
}
return ser.Load(user);
}
#endregion
#region 新增编辑
[HttpPost("AddOrUpdate")]
public Response AddOrUpdate([FromBody] DS_Report Dto)
{
var result = new Response();
var user = GetUserInfo();
if (user == null)
{
result.Code = 401;
result.Message = "登录过期,请重新登录!";
return result;
}
if (Dto == null)
{
result.Code = 500;
result.Message = "无效数据!";
}
result.data = ser.SaveInfo(Dto, user);
if (result.data == "-1")
{
result.Code = 201;
result.Message = "数据重复!";
}
return result;
}
#endregion
#region 订阅 取消订阅
[HttpPost("IsBook")]
public Response IsBook(string Gid,string TemplateId, bool isBook, string DJson)
{
var result = new Response();
var user = GetUserInfo();
if (user == null)
{
result.Code = 401;
result.Message = "登录过期,请重新登录!";
return result;
}
if (string.IsNullOrEmpty(Gid)) {
result.Code = 201;
result.Message = "没有相关业务ID";
return result;
}
if (string.IsNullOrEmpty(Gid)&&!isBook)
{
result.Code = 201;
result.Message = "未订阅数据不能取消订阅";
return result;
}
result.data = ser.IsBook(Gid, TemplateId,isBook, DJson,user);
return result;
}
#endregion
}
}

@ -106,7 +106,7 @@ namespace djy_Report
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "djy_AmsApi", Version = "v1" });
c.SwaggerDoc("v1", new OpenApiInfo { Title = "djy_Report", Version = "v1" });
var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
var xmlPath = Path.Combine(basePath, "AppServer.xml");
@ -130,7 +130,7 @@ namespace djy_Report
app.UseSwagger();
app.UseSwaggerUI(c => {
c.SwaggerEndpoint("/swagger/v1/swagger.json", "djy_AmsApi v1");
c.SwaggerEndpoint("/swagger/v1/swagger.json", "djy_Report v1");
// c.RoutePrefix = "apidoc";
});
}

@ -28,15 +28,14 @@
"Rbmq_UserName": "djy_paas",
"Rbmq_Password": "123qwe",
"Rbmq_Sqlhost": "Data Source =192.168.1.205,1433; Initial Catalog=TestDjyLogs; Persist Security Info=True; User ID =test; Password=test123;pooling=true",
"DapperDbString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;",
"DataConnList": [
{
"SysKey": "AMS",
"TitleName": "AMS",
"SysKey": "DSDB",
"TitleName": "DSDB",
"Index": 100,
"DataType": 1,
"Status": 0,
"ConnString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;"
"ConnString": "Data Source =123.234.225.158,28000; Initial Catalog=DevDongSheng; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;"
},
{
"SysKey": "Common",

@ -27,17 +27,16 @@
"Rbmq_UserName": "admin",
"Rbmq_Password": "admin",
"Rbmq_Sqlhost": "Data Source =172.31.85.154; Initial Catalog=djy_logs; Persist Security Info=True; User ID =sa; Password=QDdjy#2020*;pooling=true",
"DapperDbString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;",
"requesterDea": "nbforwarder",
"DataConnList": [
{
"SysKey": "AMS",
"TitleName": "AMS",
"SysKey": "DSDB",
"TitleName": "DSDB",
"Index": 100,
"DataType": 1,
"Status": 0,
"ConnString": "Data Source =123.234.225.158,28000; Initial Catalog=DevAMS; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;"
"ConnString": "Data Source =123.234.225.158,28000; Initial Catalog=DevDongSheng; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true;"
},
{
"SysKey": "Common",

Loading…
Cancel
Save