邮箱配置及打印修改

usertest
cjy 4 months ago
parent 506eb8cc82
commit 4858eb59b5

@ -33,6 +33,11 @@ public static class MultiLanguageConst
[Description("查询成功")]
public const string DataQuerySuccess = "Data_Query_Success";
/// <summary>
/// 查询无数据
/// </summary>
[Description("查询无数据")]
public const string DataQueryNoData = "Data_Query_NoData";
/// <summary>
/// 新增成功
/// </summary>
[Description("新增成功")]
@ -424,6 +429,9 @@ public static class MultiLanguageConst
[Description("用户邮箱设置不存在")]
public const string UserEmailNotExist = "UserEmail_Not_Exist";
[Description("未配置个人邮箱账号")]
public const string UserEmailNotSet = "UserEmail_Not_Set";
[Description("列表字段设置已存在")]
public const string ColumnSetExist = "Column_Set_Exist";
[Description("表单复制字段设置已存在")]

@ -58,6 +58,10 @@ namespace DS.WMS.Core.Code.Dtos
/// 发件SSL
/// </summary>
public bool? SmtpSSL { get; set; } = false;
/// <summary>
/// 是否为公司账号
/// </summary>
public bool IsCompany { get; set; } = false;
/// <summary>
/// 状态 0启用 1禁用

@ -60,5 +60,10 @@ namespace DS.WMS.Core.Code.Dtos
/// 状态 0启用 1禁用
/// </summary>
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 是否为公司账号
/// </summary>
public bool IsCompany { get; set; } = false;
}
}

@ -71,5 +71,11 @@ namespace DS.WMS.Core.Code.Entity
/// </summary>
[SugarColumn(ColumnDescription = "状态", DefaultValue = "0")]
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 是否为公司账号
/// </summary>
[SugarColumn(ColumnDescription = "是否为公司账号", DefaultValue = "0")]
public bool IsCompany { get; set; } = false;
}
}

@ -46,4 +46,11 @@ public interface IUserEmailService
/// <param name="req"></param>
/// <returns></returns>
public DataResult BatchDelUserEmail(IdModel req);
/// <summary>
/// 获取用户邮箱配置
/// </summary>
/// <returns></returns>
public Task<DataResult<CodeUserEmailRes>> GetUserEmailSetInfo();
}

@ -125,4 +125,32 @@ public class CodeUserEmailService : IUserEmailService
}
return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess);
}
/// <summary>
/// 获取用户邮箱配置
/// </summary>
/// <returns></returns>
public async Task<DataResult<CodeUserEmailRes>> GetUserEmailSetInfo()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = await tenantDb.Queryable<CodeUserEmail>()
.Where(a => a.IsCompany == false && a.CreateBy == long.Parse(user.UserId))
.Select<CodeUserEmailRes>()
.FirstAsync();
if (data == null)
{
data = await tenantDb.Queryable<CodeThirdParty>()
.Where(a => a.IsCompany == true)
.Select<CodeUserEmailRes>()
.FirstAsync();
}
if (data == null)
return DataResult<CodeUserEmailRes>.Failed("未配置个人邮箱账号", MultiLanguageConst.UserEmailNotSet);
return DataResult<CodeUserEmailRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
}
}

@ -13,7 +13,8 @@ namespace DS.WMS.Core.Sys.Interface;
///
/// </summary>
public interface IClientCommonService
{
{
/// <summary>
/// 根据类型获取用户下拉列表
/// </summary>

@ -43,6 +43,7 @@ public class ClientCommonService : IClientCommonService
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
/// <summary>
/// 根据类型获取用户下拉列表
/// </summary>

@ -75,4 +75,17 @@ public class UserEmailController : ApiController
var res = _invokeService.BatchDelUserEmail(req);
return res;
}
/// <summary>
/// 获取用户邮箱配置
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("GetUserEmailSetInfo")]
public async Task<DataResult<CodeUserEmailRes>> GetUserEmailSetInfo()
{
var res = await _invokeService.GetUserEmailSetInfo();
return res;
}
}

@ -23,7 +23,7 @@ namespace DS.WMS.PrintApi.Controllers
}
/// <summary>
/// 获取Json打印信息
/// 根据模板Id获取Json打印信息
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
@ -35,5 +35,19 @@ namespace DS.WMS.PrintApi.Controllers
var res = await _invokeService.GetOpenJsonPrintInfo(req);
return res;
}
/// <summary>
/// 根据模板Code获取Json打印信息
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
[Route("GetOpenJsonPrintInfoByTemplateCode")]
public async Task<PrintDataResult> GetOpenJsonPrintInfoByTemplateCode([FromBody] OpenJsonPrintByCodeReq req)
{
var res = await _invokeService.GetOpenJsonPrintInfoByTemplateCode(req);
return res;
}
}
}

@ -0,0 +1,28 @@
namespace DS.WMS.PrintApi.Model
{
/// <summary>
/// Json打印请求数据
/// </summary>
public class OpenJsonPrintByCodeReq
{
/// <summary>
/// 租户Id
/// </summary>
public long TenantId { get; set; }
/// <summary>
/// 模板Code
/// </summary>
public string Code { get; set; }
/// <summary>
/// Json数据
/// </summary>
public string JsonDataStr { get; set; }
/// <summary>
/// 打印类型 1. PDF 2.EXCEL 2.WORD
/// </summary>
public string PrintType { get; set; }
}
}

@ -20,6 +20,11 @@ namespace DS.WMS.PrintApi.Model
/// </summary>
public long ModuleId { get; set; }
/// <summary>
///打印模板唯一编码
/// </summary>
[Description("打印模板唯一编码")]
public string TemplateCode { get; set; }
/// <summary>
///打印模板名称
/// </summary>
[Description("打印模板名称")]

@ -11,5 +11,13 @@ namespace DS.WMS.PrintApi.Service
/// <param name="req"></param>
/// <returns></returns>
public Task<PrintDataResult> GetOpenJsonPrintInfo(OpenJsonPrintReq req);
/// <summary>
/// 根据打印模板代码获取Json打印信息
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public Task<PrintDataResult> GetOpenJsonPrintInfoByTemplateCode(OpenJsonPrintByCodeReq req);
}
}

@ -97,5 +97,91 @@ namespace DS.WMS.PrintApi.Service
return await Task.FromResult(PrintDataResult.Failed(ex.Message));
}
}
public async Task<PrintDataResult> GetOpenJsonPrintInfoByTemplateCode(OpenJsonPrintByCodeReq req)
{
try
{
using (var db = SqlSugarUtil.GetInstance())
{
var template = db.Queryable<SysPrintTemplate>().Filter(null, true).Where(x => x.TemplateCode == req.Code && x.TenantId == req.TenantId).First();
if (template == null)
{
return await Task.FromResult(PrintDataResult.Failed("打印模板编码:["+ req.Code+"]的打印格式不存在!"));
}
if (template.IsUseDataSource)
{
return await Task.FromResult(PrintDataResult.Failed("非Json打印接口!"));
}
try
{
var basePath = String.Empty;
var savePath = "wwwroot/PrintTempFile";
var fileName = DateTime.Now.Ticks;
var printFileName = $"{fileName}.frx";
var printFile = Path.Combine(savePath, printFileName);
//写入CRX文件
using (FileStream fs = new FileStream(printFile, FileMode.Create))
{
Byte[] info = new UTF8Encoding(true).GetBytes(template.PrintJsonContent);
fs.Write(info, 0, info.Length);
}
//生成报表
FastReport.Report report = new FastReport.Report();
report.Load(printFile);
var dataSource = report.Dictionary.Connections[0] as JsonDataSourceConnection;
var str = new FastReport.Data.JsonConnection.JsonDataSourceConnectionStringBuilder();
str.Json = req.JsonDataStr;
dataSource.ConnectionString = str.ConnectionString;
report.Prepare();
var printName = string.Empty;
var saveFile = string.Empty;
//var saveFile = Path.Combine(savePath, printName);
if (req.PrintType == "1")
{
printName = $"{fileName}.pdf";
saveFile = Path.Combine(savePath, printName);
PDFExport pdfExport = new PDFExport();
pdfExport.Export(report, saveFile);
}
else if (req.PrintType == "2")
{
printName = $"{fileName}.xlsx";
saveFile = Path.Combine(savePath, printName);
Excel2007Export excelExport = new Excel2007Export();
excelExport.Export(report, saveFile);
}
else if (req.PrintType == "3")
{
printName = $"{fileName}.doc";
saveFile = Path.Combine(savePath, printName);
Word2007Export wordExport = new Word2007Export();
wordExport.Export(report, saveFile);
}
else
{
return await Task.FromResult(PrintDataResult.Failed("非法打印格式!"));
}
return await Task.FromResult(PrintDataResult.OK(printName));
}
catch (Exception e)
{
return await Task.FromResult(PrintDataResult.Failed(e.Message));
}
}
}
catch (Exception ex)
{
//Logger.Warn(ex, "方法: GetOpenJsonPrintInfo");
return await Task.FromResult(PrintDataResult.Failed(ex.Message));
}
}
}
}

Loading…
Cancel
Save