jianghaiqing 4 months ago
commit 2284ba47d4

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.Module.Core.Constants
{
/// <summary>
/// SqlSugar缓存常量
/// </summary>
public class SqlSugarCacheConst
{
/// <summary>
/// SqlSugar二级缓存
/// </summary>
public const string SqlSugar = "sys_sqlSugar:";
/// <summary>
/// SqlSugar二级缓存港口信息
/// </summary>
public const string Port = "sys_sqlSugar:Port";
/// <summary>
/// SqlSugar二级缓存 往来单位信息
/// </summary>
public const string InfoClient = "sys_sqlSugar:InfoClient";
}
}

@ -1,4 +1,5 @@
using System.ComponentModel;
using SqlSugar;
namespace DS.Module.Core.Data;
@ -19,4 +20,16 @@ public abstract class BaseOrgModel<TKey> : BaseModel<TKey>, IOrgId
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "机构Id")]
public long OrgId { get; set; } = 0;
}
/// <summary>
/// 机构实体基类
/// </summary>
public abstract class BaseOrgModelV2<TKey> : BaseModelV2<TKey>, IOrgId
{
/// <summary>
/// 机构Id
/// </summary>
[SugarColumn(ColumnDescription = "机构Id")]
public long OrgId { get; set; }
}

@ -20,7 +20,7 @@
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.14" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
<PackageReference Include="LanguageExt.Core" Version="4.4.7" />
<PackageReference Include="MailKit" Version="4.6.0" />
<PackageReference Include="MailKit" Version="4.7.1.1" />
<PackageReference Include="Mapster" Version="7.4.0" />
<PackageReference Include="Masuit.Tools.Core" Version="2024.4.5" />
<PackageReference Include="MediatR" Version="12.2.0" />
@ -32,7 +32,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.16" />
<PackageReference Include="MimeKit" Version="4.6.0" />
<PackageReference Include="MimeKit" Version="4.7.1" />
<PackageReference Include="MiniExcel" Version="1.34.0" />
<PackageReference Include="NETCore.MailKit" Version="2.1.0" />

@ -47,7 +47,7 @@ namespace DS.Module.SqlSugar
public IEnumerable<string> GetAllKey<V>()
{
//性能注意: 只查sqlsugar用到的key
return RedisHelper.Keys("cache:SqlSugarDataCache.*");
return RedisHelper.Keys("*SqlSugarDataCache.*");
//个人封装问题key前面会带上cache:缓存前缀,请根据实际情况自行修改 ,如果没有去掉前缀或者使用最下面.如果不确定,可以用最下面前面都加通配符的做法
// return RedisHelper.Keys("SqlSugarDataCache.*");
// return RedisHelper.Keys("*SqlSugarDataCache.*");

@ -8,13 +8,13 @@ namespace DS.WMS.Core.Application.Entity
/// <summary>
/// 申请相关业务基类
/// </summary>
public abstract class ApplicationBase : BaseModelV2<long>
public abstract class ApplicationBase : BaseOrgModelV2<long>
{
/// <summary>
/// 申请单编号
/// </summary>
[SugarColumn(ColumnDescription = "申请单编号", Length = 50, IsNullable = false)]
public string ApplicationNO { get; set; }
public string ApplicationNO { get; set; } = string.Empty;
/// <summary>
/// 申请单状态

@ -512,7 +512,7 @@ namespace DS.WMS.Core.Check.Method
catch (Exception ex)
{
await tenantDb.Ado.RollbackTranAsync();
//await ex.LogAsync(tenantDb);
await ex.LogAsync(tenantDb);
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
@ -559,7 +559,7 @@ namespace DS.WMS.Core.Check.Method
catch (Exception ex)
{
await tenantDb.Ado.RollbackTranAsync();
//await ex.LogAsync(tenantDb);
await ex.LogAsync(tenantDb);
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}

@ -26,4 +26,8 @@ public class CodePortSelectRes
/// </summary>
public string EdiCode { get; set; }
/// <summary>
/// 助记码
/// </summary>
public string PinYinCode { get; set; }
}

@ -0,0 +1,109 @@
using System.ComponentModel;
using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.Code.Entity
{
/// <summary>
/// 发票商品编码表
/// </summary>
[SugarTable("code_invoice", "发票商品编码表")]
public class CodeInvoice : BaseOrgModelV2<long>
{
/// <summary>
/// 编码
/// </summary>
[SugarColumn(ColumnDescription = "编码", Length = 50, IsNullable = false)]
public string Code { get; set; } = string.Empty;
/// <summary>
/// 名称
/// </summary>
[SugarColumn(ColumnDescription = "名称", Length = 100, IsNullable = false)]
public string Name { get; set; } = string.Empty;
/// <summary>
/// 税目
/// </summary>
[SugarColumn(ColumnDescription = "税目", Length = 50, IsNullable = true)]
public string? TaxCategory { get; set; }
/// <summary>
/// 税率
/// </summary>
[SugarColumn(ColumnDescription = "税率")]
public decimal TaxRate { get; set; }
/// <summary>
/// 零税率标识
/// </summary>
[SugarColumn(ColumnDescription = "零税率标识")]
public ZeroTaxRateIdentification Identification { get; set; }
/// <summary>
/// 是否含税
/// </summary>
[SugarColumn(ColumnDescription = "是否含税")]
public bool IsIncludingTax { get; set; }
/// <summary>
/// 是否默认商品名
/// </summary>
[SugarColumn(ColumnDescription = "是否默认商品名")]
public bool IsDefault { get; set; }
/// <summary>
/// 默认币别
/// </summary>
[SugarColumn(ColumnDescription = "默认币别", Length = 3, IsNullable = true)]
public string? DefaultCurrency { get; set; }
/// <summary>
/// 规格型号
/// </summary>
[SugarColumn(ColumnDescription = "规格型号", Length = 100, IsNullable = true)]
public string? Specification { get; set; }
/// <summary>
/// 单位
/// </summary>
[SugarColumn(ColumnDescription = "单位", IsNullable = true, Length = 50)]
public string? Unit { get; set; }
}
/// <summary>
/// 零税率标识
/// </summary>
public enum ZeroTaxRateIdentification
{
/// <summary>
/// 非零税率
/// </summary>
[Description("非零税率")]
NonZero,
/// <summary>
/// 免征
/// </summary>
[Description("免征")]
Exemption,
/// <summary>
/// 不征收
/// </summary>
[Description("不征收")]
NotLevied,
/// <summary>
/// 普通零税率
/// </summary>
[Description("普通零税率")]
Ordinary,
/// <summary>
/// 出口退税
/// </summary>
[Description("出口退税")]
ExportTaxRebate
}
}

@ -1,4 +1,5 @@
using DS.Module.Core;
using DS.Module.Core.Constants;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.SqlSugar;
@ -108,7 +109,7 @@ public class CodePortService:ICodePortService
var data = req.Adapt<CodePort>();
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
var entity = tenantDb.Insertable(data).RemoveDataCache(SqlSugarCacheConst.Port).ExecuteReturnEntity();
_sysCacheService.RemoveCache(Sys.Method.SysCacheCategoryEnum.CommonCodePort, "DS8").GetAwaiter().GetResult();
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
}
@ -118,7 +119,7 @@ public class CodePortService:ICodePortService
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
tenantDb.Updateable(info).RemoveDataCache(SqlSugarCacheConst.Port).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
_sysCacheService.RemoveCache(Sys.Method.SysCacheCategoryEnum.CommonCodePort, "DS8").GetAwaiter().GetResult();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
@ -162,7 +163,7 @@ public class CodePortService:ICodePortService
return DataResult.Failed("存在已导入的港口信息!",MultiLanguageConst.CodePortImportAlready);
}
tenantDb.Insertable(list).ExecuteCommand();
tenantDb.Insertable(list).RemoveDataCache(SqlSugarCacheConst.Port).ExecuteCommand();
_sysCacheService.RemoveCache(Sys.Method.SysCacheCategoryEnum.CommonCodePort, "DS8").GetAwaiter().GetResult();
return DataResult.Successed("引入成功!",MultiLanguageConst.DataImportSuccess);
}
@ -185,7 +186,7 @@ public class CodePortService:ICodePortService
var list = tenantDb.Queryable<CodePort>().Where(x => req.Ids.Contains(x.Id)).ToList();
if (list.Count > 0)
{
tenantDb.Deleteable(list).ExecuteCommand();
tenantDb.Deleteable(list).RemoveDataCache(SqlSugarCacheConst.Port).ExecuteCommand();
}
_sysCacheService.RemoveCache(Sys.Method.SysCacheCategoryEnum.CommonCodePort, "DS8").GetAwaiter().GetResult();
return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess);

@ -38,6 +38,11 @@ public class ClientSelectRes
/// </summary>
public List<ClientParamRes> ClientParams { get; set; }
/// <summary>
/// 助记码
/// </summary>
public string PinYinCode { get; set; }
}
/// <summary>

@ -1,4 +1,5 @@
using DS.Module.Core;
using DS.Module.Core.Constants;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Check.Entity;
@ -74,7 +75,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService
var entity = TenantDb.InsertNav(data).Include(x => x.InvoiceHeaders).ExecuteReturnEntity();
tag.ClientId = entity.Id;
TenantDb.Insertable(tag).ExecuteCommand();
TenantDb.Insertable(tag).RemoveDataCache(SqlSugarCacheConst.InfoClient).ExecuteCommand();
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
}
else
@ -85,7 +86,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService
info = req.Adapt(info);
tag = req.ClientTag.Adapt(tag);
TenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
TenantDb.Updateable(info).RemoveDataCache(SqlSugarCacheConst.InfoClient).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
TenantDb.Updateable(tag).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
//创建或更新发票抬头
@ -185,7 +186,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService
//收发货人
await TenantDb.Deleteable<InfoClientShipper>().Where(x => req.Ids.Contains(x.ClientId)).ExecuteCommandAsync();
//删除客户信息
await TenantDb.Deleteable<InfoClient>().Where(x => req.Ids.Contains(x.Id)).ExecuteCommandAsync();
await TenantDb.Deleteable<InfoClient>().RemoveDataCache(SqlSugarCacheConst.InfoClient).Where(x => req.Ids.Contains(x.Id)).ExecuteCommandAsync();
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;

@ -99,6 +99,12 @@ namespace DS.WMS.Core.Op.Entity.TaskInteraction
/// 状态变更
/// </summary>
[Description("状态变更")]
StatusChanged = 2
StatusChanged = 2,
/// <summary>
/// 审核
/// </summary>
[Description("审核")]
Audit = 101
}
}

@ -0,0 +1,67 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.Op.Entity.TaskInteraction
{
/// <summary>
/// 任务邮件发送配置
/// </summary>
[SugarTable("business_task_mail", "任务邮件发送配置")]
public class BusinessTaskMail : BaseModelV2<long>
{
/// <summary>
/// 任务类型
/// </summary>
[SugarColumn(ColumnDescription = "任务类型", IsNullable = false)]
public TaskBaseTypeEnum TaskType { get; set; }
/// <summary>
/// 任务状态
/// </summary>
[SugarColumn(ColumnDescription = "任务状态", IsNullable = false)]
public TaskStatusEnum TaskStatus { get; set; }
/// <summary>
/// 主题
/// </summary>
[SugarColumn(ColumnDescription = "主题", Length = 200, IsNullable = false)]
public string Title { get; set; } = string.Empty;
/// <summary>
/// 内容
/// </summary>
[SugarColumn(ColumnDescription = "内容", ColumnDataType = "text", IsNullable = false)]
public string Content { get; set; } = string.Empty;
/// <summary>
/// 客户名称
/// </summary>
[SugarColumn(ColumnDescription = "客户名称", Length = 200, IsNullable = true)]
public string? CustomerName { get; set; }
/// <summary>
/// 机构ID
/// </summary>
[SugarColumn(ColumnDescription = "机构ID", IsNullable = false)]
public long OrgId { get; set; }
/// <summary>
/// 接收人设置
/// </summary>
[Navigate(NavigateType.OneToOne, nameof(Id))]
public BusinessTaskMailReceiver? Receiver { get; set; }
/// <summary>
/// 发送人设置
/// </summary>
[Navigate(NavigateType.OneToOne, nameof(Id))]
public BusinessTaskMailSender? Sender { get; set; }
/// <summary>
/// 附件设置
/// </summary>
[Navigate(NavigateType.OneToMany, nameof(BusinessTaskMailAttachment.TaskMailId))]
public List<BusinessTaskMailAttachment>? Attachments { get; set; }
}
}

@ -0,0 +1,23 @@
using SqlSugar;
namespace DS.WMS.Core.Op.Entity.TaskInteraction
{
/// <summary>
/// 任务邮件附件配置
/// </summary>
[SugarTable("business_task_mail_attachment", "任务邮件附件配置")]
public class BusinessTaskMailAttachment
{
/// <summary>
/// 任务邮件配置ID
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public long TaskMailId { get; set; }
/// <summary>
/// 打印模板ID
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public long TemplateId { get; set; }
}
}

@ -0,0 +1,143 @@
using SqlSugar;
namespace DS.WMS.Core.Op.Entity.TaskInteraction
{
/// <summary>
/// 任务邮件接收人配置
/// </summary>
[SugarTable("business_task_mail_receiver", "任务邮件接收人配置")]
public class BusinessTaskMailReceiver
{
/// <summary>
/// 任务邮件配置ID
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public long TaskMailId { get; set; }
/// <summary>
/// Desc:是否船公司
/// </summary>
[SugarColumn(ColumnDescription = "是否船公司", DefaultValue = "0")]
public bool IsCarrier { get; set; }
/// <summary>
/// Desc:是否订舱公司
/// </summary>
[SugarColumn(ColumnDescription = "是否订舱公司", DefaultValue = "0")]
public bool IsBooking { get; set; }
/// <summary>
/// Desc:是否场站
/// </summary>
[SugarColumn(ColumnDescription = "是否场站", DefaultValue = "0")]
public bool IsYard { get; set; }
/// <summary>
/// Desc:是否车队
/// </summary>
[SugarColumn(ColumnDescription = "是否车队", DefaultValue = "0")]
public bool IsTruck { get; set; }
/// <summary>
/// Desc:是否委托单位
/// </summary>
[SugarColumn(ColumnDescription = "是否委托单位", DefaultValue = "0")]
public bool IsController { get; set; }
/// <summary>
/// Desc:是否报关行
/// </summary>
[SugarColumn(ColumnDescription = "是否报关行", DefaultValue = "0")]
public bool IsCustom { get; set; }
/// <summary>
/// Desc:是否代理(国外)
/// </summary>
[SugarColumn(ColumnDescription = "是否代理(国外)", DefaultValue = "0")]
public bool IsAgent { get; set; }
/// <summary>
/// Desc:是否代理(国内)
/// </summary>
[SugarColumn(ColumnDescription = "是否代理(国内)", DefaultValue = "0")]
public bool IsAgentCn { get; set; }
/// <summary>
/// Desc:是否快递公司
/// </summary>
[SugarColumn(ColumnDescription = "是否快递公司", DefaultValue = "0")]
public bool IsExpress { get; set; }
/// <summary>
/// Desc:是否航空公司
/// </summary>
[SugarColumn(ColumnDescription = "是否航空公司", DefaultValue = "0")]
public bool IsAirLines { get; set; }
/// <summary>
/// Desc:是否发货人
/// </summary>
[SugarColumn(ColumnDescription = "是否发货人", DefaultValue = "0")]
public bool IsShipper { get; set; }
/// <summary>
/// Desc:是否收货人
/// </summary>
[SugarColumn(ColumnDescription = "是否收货人", DefaultValue = "0")]
public bool IsConsignee { get; set; }
/// <summary>
/// Desc:是否通知人
/// </summary>
[SugarColumn(ColumnDescription = "是否通知人", DefaultValue = "0")]
public bool IsNotifyParty { get; set; }
/// <summary>
/// Desc:是否仓库
/// </summary>
[SugarColumn(ColumnDescription = "是否仓库", DefaultValue = "0")]
public bool IsWareHouse { get; set; }
/// <summary>
/// Desc:是否码头
/// </summary>
[SugarColumn(ColumnDescription = "是否码头", DefaultValue = "0")]
public bool IsWharf { get; set; }
/// <summary>
/// Desc:是否保险公司
/// </summary>
[SugarColumn(ColumnDescription = "是否保险公司", DefaultValue = "0")]
public bool IsInsurer { get; set; }
/// <summary>
/// Desc:是否租箱公司
/// </summary>
[SugarColumn(ColumnDescription = "是否租箱公司", DefaultValue = "0")]
public bool IsLeasing { get; set; }
/// <summary>
/// Desc:是否贸易代理
/// </summary>
[SugarColumn(ColumnDescription = "是否贸易代理", DefaultValue = "0")]
public bool IsTradingAgency { get; set; }
/// <summary>
/// Desc:是否船代
/// </summary>
[SugarColumn(ColumnDescription = "是否船代", DefaultValue = "0")]
public bool IsShipAgency { get; set; }
/// <summary>
/// Desc:是否经营单位
/// </summary>
[SugarColumn(ColumnDescription = "是否经营单位", DefaultValue = "0")]
public bool IsEnterprise { get; set; }
/// <summary>
/// Desc:是否国内发货人
/// </summary>
[SugarColumn(ColumnDescription = "是否国内发货人", DefaultValue = "0")]
public bool IsShipperCn { get; set; }
}
}

@ -0,0 +1,43 @@
using System.ComponentModel;
using SqlSugar;
namespace DS.WMS.Core.Op.Entity.TaskInteraction
{
/// <summary>
/// 任务邮件发送人配置
/// </summary>
[SugarTable("business_task_mail_sender", "任务邮件发送人配置")]
public class BusinessTaskMailSender
{
/// <summary>
/// 任务邮件配置ID
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public long TaskMailId { get; set; }
/// <summary>
/// 是否操作
/// </summary>
[Description("是否操作")]
public bool IsOperator { get; set; }
/// <summary>
/// 是否单证
/// </summary>
[Description("是否单证")]
public bool IsVouchingClerk { get; set; }
/// <summary>
/// 是否销售
/// </summary>
[Description("是否销售")]
public bool IsSale { get; set; }
/// <summary>
/// 是否客服
/// </summary>
[Description("是否客服")]
public bool IsCustomerService { get; set; }
}
}

@ -0,0 +1,9 @@
namespace DS.WMS.Core.Op.Interface.TaskInteraction
{
/// <summary>
/// 邮件配置服务定义
/// </summary>
public interface ITaskMailService
{
}
}

@ -523,7 +523,8 @@ public partial class SeaExportService : ISeaExportService
catch (Exception ex)
{
await dbScope.Ado.RollbackTranAsync();
return await Task.FromResult(DataResult.Failed("添加失败!" + ",请联系管理员!" + ex.ToString()));
await ex.LogAsync(tenantDb);
return await Task.FromResult(DataResult.Failed("添加失败!" + ",请联系管理员!"));
}
}
else
@ -635,7 +636,8 @@ public partial class SeaExportService : ISeaExportService
catch (Exception ex)
{
await dbScope.Ado.RollbackTranAsync();
return await Task.FromResult(DataResult.Failed("更新失败!" + ",请联系管理员!" + ex.ToString()));
await ex.LogAsync(tenantDb);
return await Task.FromResult(DataResult.Failed("更新失败!" + ",请联系管理员!"));
}
}
}

@ -0,0 +1,65 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Op.Entity.TaskInteraction;
using DS.WMS.Core.Op.Interface.TaskInteraction;
namespace DS.WMS.Core.Op.Method.TaskInteraction
{
/// <summary>
/// 邮件配置服务
/// </summary>
public class TaskMailService : ServiceBase, ITaskMailService
{
/// <summary>
/// 初始化
/// </summary>
/// <param name="provider"></param>
public TaskMailService(IServiceProvider provider) : base(provider)
{
}
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<DataResult<List<BusinessTaskMail>>> GetListAsync(PageRequest request)
{
var whereList = request.GetConditionalModels(Db);
return await TenantDb.Queryable<BusinessTaskMail>().Includes(x => x.Receiver).Includes(x => x.Sender)
.Where(whereList).ToQueryPageAsync(request.PageCondition);
}
///// <summary>
///// 编辑
///// </summary>
///// <param name="taskMail"></param>
///// <returns></returns>
//public async Task<DataResult> EditAsync(BusinessTaskMail taskMail)
//{
// try
// {
// }
// catch (Exception ex)
// {
// await TenantDb.Ado.RollbackTranAsync();
// await ex.LogAsync(Db);
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
// }
// if (taskMail.Id == 0)
// {
// taskMail.Receiver ??= new();
// taskMail.Sender ??= new();
// await TenantDb.InsertNav(taskMail).Include(x => x.Receiver).Include(x => x.Sender).ExecuteCommandAsync();
// }
// else
// {
// }
//}
}
}

@ -510,6 +510,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
//记录日志
await LogService.WriteLogAsync(new BusinessTaskLog
{
ActionType = ActionType.Audit,
AuditStatus = callback.Status,
BusinessId = callback.BusinessId,
BusinessType = callback.BusinessType.Value,
@ -566,6 +567,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
//记录日志
await LogService.WriteLogAsync(new BusinessTaskLog
{
ActionType = ActionType.Audit,
AuditStatus = callback.FlowStatus,
BusinessId = callback.BusinessId,
BusinessType = callback.BusinessType.Value,

@ -90,11 +90,5 @@ namespace DS.WMS.Core.Settlement.Entity
/// </summary>
[SugarColumn(ColumnDescription = "解锁时间", IsNullable = true)]
public DateTime? UnlockTime { get; set; }
/// <summary>
/// 所属机构(公司)
/// </summary>
[SugarColumn(ColumnDescription = "所属机构(公司)", IsNullable = true)]
public long? OrgId { get; set; }
}
}

@ -0,0 +1,28 @@
namespace DS.WMS.Core.Sys.Dtos
{
/// <summary>
/// 发票商品编码下拉
/// </summary>
public class CodeInvoiceSelect
{
/// <summary>
/// ID
/// </summary>
public long Id { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// 税率
/// </summary>
public decimal TaxRate { get; set; }
/// <summary>
/// 下拉显示名称
/// </summary>
public string DisplayName => Name + " " + TaxRate.ToString("F4");
}
}

@ -0,0 +1,15 @@
using DS.Module.Core;
using DS.WMS.Core.Sys.Dtos;
namespace DS.WMS.Core.Sys.Interface
{
public interface ICodeInvoiceService
{
/// <summary>
/// 获取下拉数据
/// </summary>
/// <param name="text">模糊搜索字符</param>
/// <returns></returns>
Task<DataResult<List<CodeInvoiceSelect>>> GetSelectListAsync(string text);
}
}

@ -1,4 +1,5 @@
using DS.Module.Core;
using DS.Module.Core.Constants;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.Core.Log;
@ -1071,7 +1072,6 @@ public class ClientCommonService : IClientCommonService
.WhereIF(code == "shipagency", (a, b) => b.IsShipAgency == true)
.WhereIF(code == "enterprise", (a, b) => b.IsEnterprise == true)
.WhereIF(!string.IsNullOrEmpty(queryKey), (a, b) => a.CodeName.Contains(queryKey) || a.ShortName.Contains(queryKey))
.WithCache()
.Select((a, b) => new ClientSelectRes
{
Id = a.Id,
@ -1079,8 +1079,9 @@ public class ClientCommonService : IClientCommonService
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent,
PinYinCode = a.ShortName + "(" + a.CodeName + ")"
}
).Take(20).ToListAsync();
).Take(20).WithCache(SqlSugarCacheConst.InfoClient).ToListAsync();
return await Task.FromResult(DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess));
}
/// <summary>

@ -0,0 +1,30 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Sys.Interface;
namespace DS.WMS.Core.Sys.Method
{
public class CodeInvoiceService : ServiceBase, ICodeInvoiceService
{
public CodeInvoiceService(IServiceProvider provider) : base(provider)
{
}
/// <summary>
/// 获取下拉数据
/// </summary>
/// <param name="text">模糊搜索字符</param>
/// <returns></returns>
public async Task<DataResult<List<CodeInvoiceSelect>>> GetSelectListAsync(string text)
{
var list = await TenantDb.Queryable<CodeInvoice>()
.WhereIF(!text.IsNullOrEmpty(), x => x.Code.Contains(text) || x.Name.Contains(text))
.OrderByDescending(x => x.IsDefault).Select<CodeInvoiceSelect>().ToListAsync();
var result = DataResult<List<CodeInvoiceSelect>>.Success(list);
result.Count = list.Count;
return result;
}
}
}

@ -23,6 +23,7 @@ using DS.WMS.Core.Info.Dtos;
using NPOI.SS.Formula.Functions;
using DS.WMS.Core.Flow.Dtos;
using Microsoft.Extensions.Logging;
using DS.Module.Core.Constants;
namespace DS.WMS.Core.Sys.Method;
@ -1079,9 +1080,12 @@ public class CommonService : ICommonService
var list = await tenantDb.Queryable<CodePort>()
.Where(x => x.Status == StatusEnum.Enable)
.WhereIF(!string.IsNullOrEmpty(queryKey), x => x.PortName.Contains(queryKey) || x.CnName.Contains(queryKey))
.WithCache()
.Select<CodePortSelectRes>()
.Select(x => new CodePortSelectRes()
{
PinYinCode = x.CnName + "(" + x.PortName + ")",
},true)
.Take(20)
.WithCache(SqlSugarCacheConst.Port)
.ToListAsync();
return await Task.FromResult(DataResult<List<CodePortSelectRes>>.Success("获取数据成功!", list));
}
@ -1231,7 +1235,8 @@ public class CommonService : ICommonService
catch (Exception ex)
{
db.Ado.RollbackTran();
return DataResult.Failed("企业注册失败!" + ex);
ex.LogAsync(db).GetAwaiter().GetResult();
return DataResult.Failed("企业注册失败!");
}
}

@ -5,6 +5,7 @@ using DS.Module.Core.Helpers;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface;
@ -302,7 +303,8 @@ public class TenantApplyService : ITenantApplyService
catch (Exception ex)
{
await dbScope.Ado.RollbackTranAsync();
return await Task.FromResult(DataResult.Failed("审批失败!" + ",请联系管理员!"+ex.ToString()));
await ex.LogAsync(db);
return await Task.FromResult(DataResult.Failed("审批失败!" + ",请联系管理员!"));
}
}
else
@ -441,7 +443,8 @@ public class TenantApplyService : ITenantApplyService
catch (Exception ex)
{
db.Ado.RollbackTran();
return DataResult.Failed("更新失败!" + ex);
ex.LogAsync(db).GetAwaiter().GetResult();
return DataResult.Failed("更新失败!");
}
}

@ -4,6 +4,7 @@ using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
using DS.Module.SqlSugar;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface;
@ -186,6 +187,7 @@ public class TenantService : ITenantService
catch (Exception ex)
{
db.Ado.RollbackTran();
ex.LogAsync(db).GetAwaiter().GetResult();
return DataResult.Failed("租户权限模块授权失败!" + ex, MultiLanguageConst.DataUpdateFailed);
}
}

@ -4,6 +4,7 @@ using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface;
@ -183,7 +184,8 @@ public class VersionService : IVersionService
catch (Exception ex)
{
await dbScope.Ado.RollbackTranAsync();
return await Task.FromResult(DataResult.Failed("审批失败!" + ",请联系管理员!" + ex.ToString()));
await ex.LogAsync(db);
return await Task.FromResult(DataResult.Failed("审批失败!" + ",请联系管理员!"));
}
}

@ -29,6 +29,19 @@ public class ClientCommonController : ApiController
_invokeService = invokeService;
}
/// <summary>
/// 获取发票商品编码下拉数据
/// </summary>
/// <param name="service"></param>
/// <param name="text">模糊搜索文本</param>
/// <returns></returns>
[HttpGet, Route("GetInvoiceCodeList")]
public async Task<DataResult<List<CodeInvoiceSelect>>> GetInvoiceCodeListAsync(
[FromServices] ICodeInvoiceService service, [FromQuery] string text)
{
return await service.GetSelectListAsync(text);
}
/// <summary>
/// 获取商品下拉列表-客户端
/// </summary>
@ -426,7 +439,7 @@ public class ClientCommonController : ApiController
/// <returns></returns>
[HttpGet]
[Route("GetDeptList")]
public DataResult<List<DeptSelectRes>> GetDeptList([FromQuery]string orgId = "")
public DataResult<List<DeptSelectRes>> GetDeptList([FromQuery] string orgId = "")
{
var res = _invokeService.GetDeptList(orgId);
return res;
@ -497,7 +510,7 @@ public class ClientCommonController : ApiController
var res = _invokeService.GetCustomerServiceList();
return res;
}
/// <summary>
/// 获取司机列表
/// </summary>
@ -509,7 +522,7 @@ public class ClientCommonController : ApiController
var res = _invokeService.GetDiverList();
return res;
}
/// <summary>
/// 获取派车调度人员列表
/// </summary>
@ -554,7 +567,7 @@ public class ClientCommonController : ApiController
var res = _invokeService.GetPackageSelectList();
return res;
}
/// <summary>
/// 获取船名下拉列表
/// </summary>
@ -566,7 +579,7 @@ public class ClientCommonController : ApiController
var res = _invokeService.GetVesselSelectList();
return res;
}
/// <summary>
/// 获取航次下拉列表
/// </summary>
@ -578,7 +591,7 @@ public class ClientCommonController : ApiController
var res = _invokeService.GetVoynoSelectList();
return res;
}
/// <summary>
/// 获取运输条款下拉列表
/// </summary>

@ -49,5 +49,19 @@ namespace DS.WMS.PrintApi.Controllers
var res = await _invokeService.GetOpenJsonPrintInfoByTemplateCode(req);
return res;
}
/// <summary>
/// sql数据源打印
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
[Route("GetOpenSqlPrintInfo")]
public async Task<PrintDataResult> GetOpenSqlPrintInfo([FromBody] OpenSqlPrintReq req)
{
var res = await _invokeService.GetOpenSqlPrintInfo(req);
return res;
}
}
}

@ -19,13 +19,9 @@
/// </summary>
public string TemplateCode { get; set; }
/// <summary>
/// 主键id
/// 入口参数JSON字符串
/// </summary>
public long Id { get; set; }
/// <summary>
/// 主键ids
/// </summary>
public long[] Ids { get; set; }
public string ParamJsonStr { get; set; }
/// <summary>
/// 打印类型 1. PDF 2.EXCEL 2.WORD

@ -19,5 +19,13 @@ namespace DS.WMS.PrintApi.Service
/// <returns></returns>
public Task<PrintDataResult> GetOpenJsonPrintInfoByTemplateCode(OpenJsonPrintByCodeReq req);
/// <summary>
/// sql 打印
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public Task<PrintDataResult> GetOpenSqlPrintInfo(OpenSqlPrintReq req);
}
}

@ -7,6 +7,11 @@ using System.IO;
using System.Text;
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Rendering;
using SqlSugar;
using static System.Net.Mime.MediaTypeNames;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace DS.WMS.PrintApi.Service
{
@ -205,7 +210,11 @@ namespace DS.WMS.PrintApi.Service
return await Task.FromResult(PrintDataResult.Failed(ex.Message));
}
}
/// <summary>
/// sql 打印
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public async Task<PrintDataResult> GetOpenSqlPrintInfo(OpenSqlPrintReq req)
{
@ -213,10 +222,14 @@ namespace DS.WMS.PrintApi.Service
{
using (var db = SqlSugarUtil.GetInstance())
{
var template = db.Queryable<SysPrintTemplate>().Filter(null, true).Where(x => x.TenantId == req.TenantId)
.WhereIF(req.TemplateId!= 0,x=>x.Id ==req.TemplateId)
if (req.TenantId == 0 || req.TenantId == null)
{
return await Task.FromResult(PrintDataResult.Failed("缺失关键参数租户id!"));
}
var template = await db.Queryable<SysPrintTemplate>().Filter(null, true).Where(x => x.TenantId == req.TenantId)
.WhereIF(req.TemplateId!= 0,x=>x.Id == req.TemplateId)
.WhereIF(!string.IsNullOrEmpty(req.TemplateCode), x => x.Id == req.TemplateId)
.First();
.FirstAsync();
if (template == null)
{
return await Task.FromResult(PrintDataResult.Failed("打印模板不存在!"));
@ -225,10 +238,21 @@ namespace DS.WMS.PrintApi.Service
{
return await Task.FromResult(PrintDataResult.Failed("非Sql打印接口!"));
}
if (template == null) {
if (string.IsNullOrEmpty(template.SourceSql))
{
return await Task.FromResult(PrintDataResult.Failed("打印数据源不能为空!"));
}
if (!template.SourceSql.Contains(';'))
{
return await Task.FromResult(PrintDataResult.Failed("数据源必须包含分号!"));
}
if (template.SourceSql.Substring(template.SourceSql.Length - 1, 1) != ";")
{
return await Task.FromResult(PrintDataResult.Failed("数据源最后必须包含分号!"));
}
if (SqlUtil.IsSqlInjection(template.SourceSql))
{
return await Task.FromResult(PrintDataResult.Failed("sql数据源包含非法字符,请检查!"));
}
if (String.IsNullOrEmpty(template.PrintJsonContent))
{
@ -236,6 +260,39 @@ namespace DS.WMS.PrintApi.Service
}
try
{
var tenantDb = db.GetConnection(req.TenantId);
var data = new Dictionary<string, List<dynamic>>();
var sugarParams = new List<SugarParameter>();
if (!string.IsNullOrEmpty(req.ParamJsonStr))
{
var param = JsonHelper.Instance.Deserialize<Dictionary<string, string>>(req.ParamJsonStr);
foreach (var p in param)
{
sugarParams.Add(new SugarParameter($"@{p.Key}", p.Value));
}
}
if (template.SourceSql.Contains(';'))
{
var sqlArr = template.SourceSql.Split(';');
if (sqlArr.Length > 0)
{
for (int i = 0; i < sqlArr.Length; i++)
{
if (!string.IsNullOrEmpty(sqlArr[i]))
{
var temp = tenantDb.Ado.SqlQuery<dynamic>(sqlArr[i], sugarParams);
data.Add("sql" + i, temp);
}
}
}
else
{
}
}
var basePath = String.Empty;
var savePath = "wwwroot/PrintTempFile";
@ -256,7 +313,7 @@ namespace DS.WMS.PrintApi.Service
var dataSource = report.Dictionary.Connections[0] as JsonDataSourceConnection;
var str = new FastReport.Data.JsonConnection.JsonDataSourceConnectionStringBuilder();
//str.Json = req.JsonDataStr;
str.Json = JsonConvert.SerializeObject(data);
dataSource.ConnectionString = str.ConnectionString;
report.Prepare();
@ -268,22 +325,7 @@ namespace DS.WMS.PrintApi.Service
printName = $"{fileName}.pdf";
saveFile = Path.Combine(savePath, printName);
PDFExport pdfExport = new PDFExport();
pdfExport.Export(report, saveFile);
#region 处理托书挂载附件
if (template.TemplateCode == "bill_of_lading")
{
System.IO.FileStream file = new System.IO.FileStream(saveFile, FileMode.Open, FileAccess.Read);
var movePath = Path.Combine(AppSetting.Configuration["FileSettings:MovePath"], printName);
using (var fileStream = File.Create(movePath))
{
await file.CopyToAsync(fileStream);
}
file.Close();
}
#endregion
pdfExport.Export(report, saveFile);
}
else if (req.PrintType == "2")
{

@ -58,6 +58,6 @@ namespace DS.WMS.PrintApi.Utils
{
return 0;
}
}
}
}
}

@ -0,0 +1,41 @@
using Newtonsoft.Json.Converters;
using Newtonsoft.Json;
namespace DS.WMS.PrintApi.Utils
{
public class JsonHelper
{
private static JsonHelper _jsonHelper = new JsonHelper();
public static JsonHelper Instance { get { return _jsonHelper; } }
public string Serialize(object obj)
{
return JsonConvert.SerializeObject(obj, new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" });
}
public string SerializeByConverter(object obj, params JsonConverter[] converters)
{
return JsonConvert.SerializeObject(obj, converters);
}
public T Deserialize<T>(string input)
{
return JsonConvert.DeserializeObject<T>(input);
}
public T DeserializeByConverter<T>(string input, params JsonConverter[] converter)
{
return JsonConvert.DeserializeObject<T>(input, converter);
}
public T DeserializeBySetting<T>(string input, JsonSerializerSettings settings)
{
return JsonConvert.DeserializeObject<T>(input, settings);
}
private object NullToEmpty(object obj)
{
return null;
}
}
}

@ -0,0 +1,26 @@
using System;
namespace DS.WMS.PrintApi.Utils
{
public static class SqlUtil
{
/// <summary>
/// sql
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsSqlInjection(string input)
{
string[] sqlCheckList = { "TRUNCATE", "INSERT", "UPDATE", "DELETE", "DROP", "--", "'" };
foreach (string item in sqlCheckList)
{
if (input.IndexOf(item, StringComparison.OrdinalIgnoreCase) >= 0)
{
return true;
}
}
return false;
}
}
}
Loading…
Cancel
Save