From 4714036a7bce5dd26a332b6090d170fd8659f153 Mon Sep 17 00:00:00 2001 From: wet <1034391973@qq.com> Date: Fri, 22 Jul 2022 16:33:19 +0800 Subject: [PATCH] 1 --- web/djy.IService/Report/IReportService.cs | 34 +++ web/djy.IService/djy.IService.csproj | 4 - web/djy.Model/Report/DS_Report.cs | 57 +++++ web/djy.Model/Report/DS_ReportTemplate.cs | 27 +++ web/djy.Model/ReportDto/ReportDto.cs | 52 +++++ web/djy.Model/djy.Model.csproj | 4 - web/djy.Service/DjyService/DbContext.cs | 5 + web/djy.Service/Report/ReportService.cs | 206 ++++++++++++++++++ web/djy.Service/djy.Service.csproj | 4 - .../Controllers/Report/ReportController.cs | 127 ++++++++++- web/djy_Report/Startup.cs | 4 +- web/djy_Report/appsettings.Development.json | 7 +- web/djy_Report/appsettings.json | 7 +- 13 files changed, 512 insertions(+), 26 deletions(-) create mode 100644 web/djy.IService/Report/IReportService.cs create mode 100644 web/djy.Model/Report/DS_Report.cs create mode 100644 web/djy.Model/Report/DS_ReportTemplate.cs create mode 100644 web/djy.Model/ReportDto/ReportDto.cs create mode 100644 web/djy.Service/Report/ReportService.cs diff --git a/web/djy.IService/Report/IReportService.cs b/web/djy.IService/Report/IReportService.cs new file mode 100644 index 0000000..41e12b3 --- /dev/null +++ b/web/djy.IService/Report/IReportService.cs @@ -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 GetTemplate(); + + + TableData Load(User user); + + + string SaveInfo(DS_Report dto, User user); + + + string IsBook(string Gid, string TemplateId, bool isBook, string DJson, User user); + } +} diff --git a/web/djy.IService/djy.IService.csproj b/web/djy.IService/djy.IService.csproj index 4097205..08cdfed 100644 --- a/web/djy.IService/djy.IService.csproj +++ b/web/djy.IService/djy.IService.csproj @@ -15,8 +15,4 @@ - - - - diff --git a/web/djy.Model/Report/DS_Report.cs b/web/djy.Model/Report/DS_Report.cs new file mode 100644 index 0000000..39e5dc4 --- /dev/null +++ b/web/djy.Model/Report/DS_Report.cs @@ -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; } + } +} diff --git a/web/djy.Model/Report/DS_ReportTemplate.cs b/web/djy.Model/Report/DS_ReportTemplate.cs new file mode 100644 index 0000000..3046758 --- /dev/null +++ b/web/djy.Model/Report/DS_ReportTemplate.cs @@ -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; } + } +} diff --git a/web/djy.Model/ReportDto/ReportDto.cs b/web/djy.Model/ReportDto/ReportDto.cs new file mode 100644 index 0000000..a3dc598 --- /dev/null +++ b/web/djy.Model/ReportDto/ReportDto.cs @@ -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; } + + + } +} diff --git a/web/djy.Model/djy.Model.csproj b/web/djy.Model/djy.Model.csproj index 31566ca..8e3cf9a 100644 --- a/web/djy.Model/djy.Model.csproj +++ b/web/djy.Model/djy.Model.csproj @@ -28,8 +28,4 @@ - - - - diff --git a/web/djy.Service/DjyService/DbContext.cs b/web/djy.Service/DjyService/DbContext.cs index 9b75517..d2d8bc4 100644 --- a/web/djy.Service/DjyService/DbContext.cs +++ b/web/djy.Service/DjyService/DbContext.cs @@ -39,6 +39,11 @@ namespace djy.Service.DjyService /// Common库 /// public const string Common = "Common"; + + /// + /// 东胜库 + /// + public const string DSDB = "DSDB"; } /// diff --git a/web/djy.Service/Report/ReportService.cs b/web/djy.Service/Report/ReportService.cs new file mode 100644 index 0000000..3b658a6 --- /dev/null +++ b/web/djy.Service/Report/ReportService.cs @@ -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 GetTemplate() + { + try + { + var List = DbBus.Get(DbList.DSDB).Select().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().ToList(); + + List query = DbBus.Get(DbList.DSDB).Select().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().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(); + 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().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(). + 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().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().Set(w => new DS_Report + { + IsBook = false, + LastUpdate = DateTime.Now, + LastUserId = user.GID + }).Where(w => w.GID == Gid).ExecuteAffrows(); + return "取消成功!"; + } + } + #endregion + + } +} diff --git a/web/djy.Service/djy.Service.csproj b/web/djy.Service/djy.Service.csproj index 524960e..88b6423 100644 --- a/web/djy.Service/djy.Service.csproj +++ b/web/djy.Service/djy.Service.csproj @@ -23,8 +23,4 @@ - - - - diff --git a/web/djy_Report/Controllers/Report/ReportController.cs b/web/djy_Report/Controllers/Report/ReportController.cs index 03ac1bd..059f3da 100644 --- a/web/djy_Report/Controllers/Report/ReportController.cs +++ b/web/djy_Report/Controllers/Report/ReportController.cs @@ -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(); + + #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() + { + //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 + + } } diff --git a/web/djy_Report/Startup.cs b/web/djy_Report/Startup.cs index 0511b39..3c43478 100644 --- a/web/djy_Report/Startup.cs +++ b/web/djy_Report/Startup.cs @@ -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"; }); } diff --git a/web/djy_Report/appsettings.Development.json b/web/djy_Report/appsettings.Development.json index 915c58a..afe8173 100644 --- a/web/djy_Report/appsettings.Development.json +++ b/web/djy_Report/appsettings.Development.json @@ -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", diff --git a/web/djy_Report/appsettings.json b/web/djy_Report/appsettings.json index e87a389..6b2c22f 100644 --- a/web/djy_Report/appsettings.json +++ b/web/djy_Report/appsettings.json @@ -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",