jianghaiqing 4 months ago
commit 1b45a00771

@ -1489,6 +1489,8 @@ public static class MultiLanguageConst
public const string TaskStatusNotSupported = "Task_Status_Not_Supported";
[Description("当前任务状态不正确,无法提交审核")]
public const string TaskAuditStatusError = "Task_Audit_Status_Error";
[Description("无法从配置中获取任务接收人,请联系管理员检查系统配置")]
public const string TaskReceiverNotFound = "Task_Receiver_Not_Found";
#endregion
#region 任务台相关

@ -6,6 +6,24 @@ namespace DS.Module.Core.Extensions;
public static class StringExtensions
{
/// <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;
}
/// <summary>
/// 以指定字符串作为分隔符将指定字符串分隔成数组
/// </summary>

@ -64,6 +64,16 @@ public class ClientAccountDateReq
/// </summary>
public byte? AccountDays { get; set; }
/// <summary>
/// 上半月
/// </summary>
public byte? AccountFirstHalf { get; set; }
/// <summary>
/// 下半月
/// </summary>
public byte? AccountSecondHalf { get; set; }
/// <summary>
/// Desc:信用额度
/// </summary>
@ -88,7 +98,7 @@ public class ClientAccountDateReq
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
public string? Note { get; set; }
/// <summary>
/// 特批放单客户

@ -73,6 +73,16 @@ public class ClientAccountDateRes
/// </summary>
public byte? AccountDays { get; set; }
/// <summary>
/// 上半月
/// </summary>
public byte? AccountFirstHalf { get; set; }
/// <summary>
/// 下半月
/// </summary>
public byte? AccountSecondHalf { get; set; }
/// <summary>
/// Desc:信用额度
/// </summary>

@ -70,6 +70,18 @@ public class InfoClientAccountDate : BaseModelV2<long>
[SugarColumn(ColumnDescription = "账期日期", IsNullable = true)]
public byte? AccountDays { get; set; }
/// <summary>
/// 上半月
/// </summary>
[SugarColumn(ColumnDescription = "上半月", IsNullable = true)]
public byte? AccountFirstHalf { get; set; }
/// <summary>
/// 下半月
/// </summary>
[SugarColumn(ColumnDescription = "下半月", IsNullable = true)]
public byte? AccountSecondHalf { get; set; }
/// <summary>
/// Desc:信用额度
/// </summary>

@ -16,6 +16,11 @@ namespace DS.WMS.Core.Op.Dtos
/// 业务主键
/// </summary>
public long Id { get; set; }
/// <summary>
/// 箱信息
/// </summary>
public List<OpCtnReq> CtnInfo { get; set; }
/// <summary>
/// 场站Id t_crm_client CUSTNAME
/// </summary>

@ -16,7 +16,7 @@
public string? TaskDescription { get; set; }
/// <summary>
/// 任务接收用户ID此值为空时则默认为任务发起者
/// 任务接收用户ID此值为空时则从配置中获取
/// </summary>
public long[]? RecvUserIdList { get; set; }
}

@ -2,6 +2,7 @@
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.EDI;
using DS.WMS.Core.Op.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
@ -110,5 +111,13 @@ namespace DS.WMS.Core.Op.Interface
/// <param name="req"></param>
/// <returns></returns>
public Task<DataResult> SeaExportOpenEdit(SeaExportOpenEditReq req);
/// <summary>
/// 保存集装箱明细信息需自动更新业务主表
/// </summary>
/// <param name="entity"></param>
/// <param name="ctnList"></param>
/// <returns></returns>
public SeaExport UpdateSeaExportCtnInfo(SeaExport entity, List<OpCtnReq> ctnList);
}
}

@ -1998,10 +1998,135 @@ namespace DS.WMS.Core.Op.Method
var dic = req.GetPropertiesArray();
var info = req.Adapt(order);
info.Note = "对外开放更新接口";
#region 处理箱型箱量
if (req.CtnInfo.Count > 0)
{
//处理箱型箱量
info = UpdateSeaExportCtnInfo(info, req.CtnInfo);
}
#endregion
await tenantDb.Updateable(info).UpdateColumns(dic).EnableDiffLogEvent().ExecuteCommandAsync();
return await Task.FromResult(DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess));
}
#endregion
#region 保存集装箱明细信息需自动更新业务主表 箱量相关字段CNTR1--CNTR10每种箱型的数量列头显示箱型 、TEU合计TEU、CNTRTOTAL集装箱 例如20GP*1 40GP*2
/// <summary>
/// 保存集装箱明细信息需自动更新业务主表
/// </summary>
/// <param name="entity"></param>
/// <param name="ctnList"></param>
/// <returns></returns>
public SeaExport UpdateSeaExportCtnInfo(SeaExport entity, List<OpCtnReq> ctnList)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var dictList = db.Queryable<SysDictData>().InnerJoin<SysDictType>((a, b) => a.TypeId == b.Id)
.Where((a, b) => b.Code == "seaexport_ctn_map").OrderBy((a, b) => a.OrderNo)
.Select((a, b) => a.Value).ToList();
#region 重置相关字段属性
entity.Cntr1 = 0;
entity.Cntr2 = 0;
entity.Cntr3 = 0;
entity.Cntr4 = 0;
entity.Cntr5 = 0;
entity.Cntr6 = 0;
entity.Cntr7 = 0;
entity.Cntr8 = 0;
entity.Cntr9 = 0;
entity.Cntr10 = 0;
entity.OtherCntr = 0;
entity.TEU = 0;
entity.CntrTotal = "";
#endregion
#region 处理箱型箱量
for (int i = 0; i < dictList.Count; i++)
{
var ctnCode = dictList[i];
//var ctn = ctnList.Where(x => (x.CtnCode == ctnCode || x.Ctn == ctnCode)).First();
//var ctn = ctnList.Where(x => x.Ctn == ctnCode).First();
if (ctnList.Where(x => x.CtnCode == ctnCode).Any())
{
var ctns = ctnList.Where(x => x.CtnCode == ctnCode).ToList();
foreach (var ctn in ctns)
{
switch (ctnCode.ToUpper())
{
case "40HQ":
entity.Cntr1 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "20GP":
entity.Cntr2 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "40GP":
entity.Cntr3 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "40HC":
entity.Cntr4 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "20OT":
entity.Cntr5 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "40OT":
entity.Cntr6 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "20FR":
entity.Cntr7 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "40FR":
entity.Cntr8 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "20RF":
entity.Cntr9 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "40RF":
entity.Cntr10 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
default:
break;
}
}
}
}
//处理其他箱型
var otherCtns = ctnList.Where(x => !dictList.Contains(x.CtnCode)).ToList();
if (otherCtns.Count > 0)
{
foreach (var item in otherCtns)
{
entity.OtherCntr += item.CtnNum;
entity.TEU += item.TEU;
entity.CntrTotal += item.CtnCode + "*" + item.TEU + "";
}
}
#endregion
return entity;
}
#endregion
}
}

@ -454,7 +454,7 @@ public partial class SeaExportService : ISeaExportService
if (req.CtnInfo.Count > 0)
{
//处理箱型箱量
data = UpdateSeaExportCtnInfo(data, req.CtnInfo);
data = seaComService.UpdateSeaExportCtnInfo(data, req.CtnInfo);
}
#endregion
@ -534,7 +534,7 @@ public partial class SeaExportService : ISeaExportService
if (req.CtnInfo.Count > 0)
{
//处理箱型箱量
info = UpdateSeaExportCtnInfo(info, req.CtnInfo);
info = seaComService.UpdateSeaExportCtnInfo(info, req.CtnInfo);
}
#endregion
#region 更新结算方式及结算日期
@ -950,121 +950,7 @@ public partial class SeaExportService : ISeaExportService
#endregion
#region 保存集装箱明细信息需自动更新业务主表 箱量相关字段CNTR1--CNTR10每种箱型的数量列头显示箱型 、TEU合计TEU、CNTRTOTAL集装箱 例如20GP*1 40GP*2
/// <summary>
/// 保存集装箱明细信息需自动更新业务主表
/// </summary>
/// <param name="entity"></param>
/// <param name="ctnList"></param>
/// <returns></returns>
private SeaExport UpdateSeaExportCtnInfo(SeaExport entity, List<OpCtnReq> ctnList)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var dictList = db.Queryable<SysDictData>().InnerJoin<SysDictType>((a, b) => a.TypeId == b.Id)
.Where((a, b) => b.Code == "seaexport_ctn_map").OrderBy((a, b) => a.OrderNo)
.Select((a, b) => a.Value).ToList();
#region 重置相关字段属性
entity.Cntr1 = 0;
entity.Cntr2 = 0;
entity.Cntr3 = 0;
entity.Cntr4 = 0;
entity.Cntr5 = 0;
entity.Cntr6 = 0;
entity.Cntr7 = 0;
entity.Cntr8 = 0;
entity.Cntr9 = 0;
entity.Cntr10 = 0;
entity.OtherCntr = 0;
entity.TEU = 0;
entity.CntrTotal = "";
#endregion
#region 处理箱型箱量
for (int i = 0; i < dictList.Count; i++)
{
var ctnCode = dictList[i];
//var ctn = ctnList.Where(x => (x.CtnCode == ctnCode || x.Ctn == ctnCode)).First();
//var ctn = ctnList.Where(x => x.Ctn == ctnCode).First();
if (ctnList.Where(x => x.CtnCode == ctnCode).Any())
{
var ctns = ctnList.Where(x => x.CtnCode == ctnCode).ToList();
foreach (var ctn in ctns)
{
switch (ctnCode.ToUpper())
{
case "40HQ":
entity.Cntr1 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "20GP":
entity.Cntr2 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "40GP":
entity.Cntr3 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "40HC":
entity.Cntr4 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "20OT":
entity.Cntr5 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "40OT":
entity.Cntr6 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "20FR":
entity.Cntr7 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "40FR":
entity.Cntr8 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "20RF":
entity.Cntr9 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
case "40RF":
entity.Cntr10 += ctn.CtnNum;
entity.TEU += ctn.TEU;
entity.CntrTotal += ctnCode + "*" + ctn.TEU + "";
break;
default:
break;
}
}
}
}
//处理其他箱型
var otherCtns = ctnList.Where(x => !dictList.Contains(x.CtnCode)).ToList();
if (otherCtns.Count > 0)
{
foreach (var item in otherCtns)
{
entity.OtherCntr += item.CtnNum;
entity.TEU += item.TEU;
entity.CntrTotal += item.CtnCode + "*" + item.TEU + "";
}
}
#endregion
return entity;
}
#endregion
/// <summary>
/// 订单及货运动态

@ -46,6 +46,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
var taskList = new List<BusinessTask>();
var first = request.First();
var defaultUsers = await GetRecvUsers(first.RecvUserIdList);
var biz = await TenantDb.Queryable<SeaExport>().Select(x => new
{
x.Id,
@ -55,9 +56,10 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
x.Voyno,
x.ETD,
}).FirstAsync(x => x.Id == first.BusinessId);
var userList = await GetRecvUsers(first.RecvUserIdList);
foreach (var item in request)
{
var recvUsers = await GetRecvUsers(item.BusinessId, item.BusinessType, item.TaskType);
var info = new TaskManageOrderMessageInfo
{
Head = new TaskManageOrderMessageHeadInfo
@ -79,7 +81,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
TaskSource = TaskSourceEnum.WORK_FLOW,
TaskUserId = User.UserId,
TaskUserName = User.UserName,
RecvUserInfoList = userList,
RecvUserInfoList = recvUsers ?? defaultUsers,
TaskTenatId = tenatId,
TaskTenatName = tenatName,
IsCheckExistsByTaskType = true

@ -11,10 +11,12 @@ using DS.WMS.Core.Op.Entity.TaskInteraction;
using DS.WMS.Core.Op.Interface.TaskInteraction;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.TaskPlat.Dtos;
using DS.WMS.Core.TaskPlat.Entity;
using DS.WMS.Core.TaskPlat.Interface;
using Masuit.Tools;
using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection;
using Org.BouncyCastle.Crypto;
using SqlSugar;
namespace DS.WMS.Core.Op.Method.TaskInteraction
@ -239,10 +241,19 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
if (request.RecvUserIdList == null || request.RecvUserIdList.Length == 0)
{
//默认接收人=当前订单的操作员
var opr = await TenantDb.Queryable<SeaExport>().Where(x => x.Id == request.BusinessId)
.Select(x => new { x.OperatorId, x.OperatorName }).FirstAsync();
info.Main.RecvUserInfoList = [new RecvUserInfo { RecvUserId = opr.OperatorId, RecvUserName = opr.OperatorName }];
//根据配置获取默认接收人
info.Main.RecvUserInfoList = await GetRecvUsers(request.BusinessId, request.BusinessType, request.TaskType);
if (info.Main.RecvUserInfoList == null || info.Main.RecvUserInfoList.Count == 0)
{
if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
{
info.Main.RecvUserInfoList = await GetRecvUsers(long.Parse(User.UserId));
}
else
{
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskReceiverNotFound));
}
}
}
else
{
@ -346,7 +357,12 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
string[] ids = FlowInstanceService.GetMarkers(instance);
//变更任务接收人为所有审批执行人
var users = await GetRecvUsers(ids.Select(long.Parse).ToArray());
await ManagerService.TransferTask(task.BusinessId, task.TaskType, users);
result = await ManagerService.TransferTask(task.BusinessId, task.TaskType, users);
if (result.Succeeded)
{
task.RecvUsers = string.Join(",", ids);
await TenantDb.Updateable(task).UpdateColumns(x => x.RecvUsers).ExecuteCommandAsync();
}
}
}
@ -514,6 +530,65 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
x.BusinessId == id && x.BusinessType == businessType && x.TaskType == taskType);
}
/// <summary>
/// 获取任务接收用户列表
/// </summary>
/// <param name="id">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="taskType">任务类型</param>
/// <returns></returns>
protected internal async Task<List<RecvUserInfo>?> GetRecvUsers(long id, BusinessType businessType, TaskBaseTypeEnum taskType)
{
string typeCode = taskType.ToString();
var allocations = await TenantDb.Queryable<TaskAllocationtSet>().Where(x => x.TaskTypeCode == typeCode)
.Select(x => new
{
x.CarrierId,
x.IsAllotCustomerService, //客服
x.IsAllotOperator, //操作
x.IsAllotSale, //销售
x.IsAllotVouchingClerk //单证
}).ToListAsync();
long? carrierId = null;
switch (businessType)
{
case BusinessType.OceanShippingExport:
carrierId = await TenantDb.Queryable<SeaExport>().Where(x => x.Id == id).Select(x => x.CarrierId).FirstAsync();
break;
}
var allocation = allocations.Find(x => x.CarrierId == carrierId);
//未找到匹配值
if (allocation == null)
return null;
var expr = Expressionable.Create<SysUser>();
if (allocation.IsAllotCustomerService)
{
expr = expr.Or(x => x.IsCustomerService);
}
else if (allocation.IsAllotOperator)
{
expr = expr.Or(x => x.IsOperator);
}
else if (allocation.IsAllotSale)
{
expr = expr.Or(x => x.IsSale);
}
else if (allocation.IsAllotVouchingClerk)
{
expr = expr.Or(x => x.IsVouchingClerk);
}
var condition = expr.ToExpression();
if (condition.IsNullOrEmpty())
return null;
return await Db.Queryable<SysUser>().Where(condition).Select(
x => new RecvUserInfo { RecvUserId = x.Id, RecvUserName = x.UserName }).ToListAsync();
}
/// <summary>
/// 获取任务接收用户列表
/// </summary>

@ -281,7 +281,7 @@ namespace DS.WMS.Core.TaskPlat.Method
{
// 附件分类代码错误,请提供正确的分类代码
throw new Exception(
string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskFileCategoryError)), taskId)
string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskFileEmpty)), taskId)
);
}
var basePath = AppSetting.app(new string[] { "FileSettings", "BasePath" });

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NameOfLastUsedPublishProfile>D:\Code\ds8-solution-pro\ds-wms-service\DS.WMS.MainApi\Properties\PublishProfiles\FolderProfile1.pubxml</NameOfLastUsedPublishProfile>
<NameOfLastUsedPublishProfile>D:\Source\Repos\DS8\ds-wms-service\DS.WMS.MainApi\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
</PropertyGroup>
</Project>

@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project>
<PropertyGroup>
<_PublishTargetUrl>D:\Publish\DS8\Main</_PublishTargetUrl>
<History>True|2024-08-05T01:44:23.2252289Z;True|2024-08-05T09:28:10.5509876+08:00;True|2024-08-05T09:17:28.1699596+08:00;True|2024-08-05T08:47:56.4462670+08:00;True|2024-06-07T15:21:06.7600490+08:00;True|2024-06-07T15:17:45.6855676+08:00;True|2024-05-31T13:57:26.8256021+08:00;True|2024-05-30T16:18:14.8047074+08:00;True|2024-05-30T09:30:24.9756841+08:00;True|2024-05-29T17:46:22.9869679+08:00;True|2024-05-29T17:20:28.9621862+08:00;True|2024-05-29T17:18:16.4688274+08:00;True|2024-05-29T16:33:42.5152962+08:00;False|2024-05-29T16:33:09.8393409+08:00;False|2024-05-29T16:31:07.7569208+08:00;True|2024-05-28T18:00:39.2399003+08:00;True|2024-05-28T08:47:53.8630073+08:00;True|2024-05-23T17:51:45.6784172+08:00;True|2024-05-21T17:32:52.9294009+08:00;</History>
<History>True|2024-08-05T01:54:03.6786719Z;True|2024-08-05T09:44:23.2252289+08:00;True|2024-08-05T09:28:10.5509876+08:00;True|2024-08-05T09:17:28.1699596+08:00;True|2024-08-05T08:47:56.4462670+08:00;True|2024-06-07T15:21:06.7600490+08:00;True|2024-06-07T15:17:45.6855676+08:00;True|2024-05-31T13:57:26.8256021+08:00;True|2024-05-30T16:18:14.8047074+08:00;True|2024-05-30T09:30:24.9756841+08:00;True|2024-05-29T17:46:22.9869679+08:00;True|2024-05-29T17:20:28.9621862+08:00;True|2024-05-29T17:18:16.4688274+08:00;True|2024-05-29T16:33:42.5152962+08:00;False|2024-05-29T16:33:09.8393409+08:00;False|2024-05-29T16:31:07.7569208+08:00;True|2024-05-28T18:00:39.2399003+08:00;True|2024-05-28T08:47:53.8630073+08:00;True|2024-05-23T17:51:45.6784172+08:00;True|2024-05-21T17:32:52.9294009+08:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

@ -0,0 +1,31 @@
namespace DS.WMS.PrintApi.Model
{
/// <summary>
/// Sql打印请求数据
/// </summary>
public class OpenSqlPrintReq
{
/// <summary>
/// 租户Id
/// </summary>
public long TenantId { get; set; }
/// <summary>
/// 模板Id
/// </summary>
public long TemplateId { get; set; }
/// <summary>
/// 打印模板code
/// </summary>
public string TemplateCode { get; set; }
/// <summary>
/// 主键ids
/// </summary>
public long[] Ids { get; set; }
/// <summary>
/// 打印类型 1. PDF 2.EXCEL 2.WORD
/// </summary>
public string PrintType { get; set; }
}
}

@ -205,5 +205,118 @@ namespace DS.WMS.PrintApi.Service
return await Task.FromResult(PrintDataResult.Failed(ex.Message));
}
}
public async Task<PrintDataResult> GetOpenSqlPrintInfo(OpenSqlPrintReq req)
{
try
{
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)
.WhereIF(!string.IsNullOrEmpty(req.TemplateCode), x => x.Id == req.TemplateId)
.First();
if (template == null)
{
return await Task.FromResult(PrintDataResult.Failed("打印模板不存在!"));
}
if (!template.IsUseDataSource)
{
return await Task.FromResult(PrintDataResult.Failed("非Sql打印接口!"));
}
if (template == null) {
}
if (String.IsNullOrEmpty(template.PrintJsonContent))
{
return await Task.FromResult(PrintDataResult.Failed("打印模板内容不能为空!"));
}
try
{
var basePath = String.Empty;
var savePath = "wwwroot/PrintTempFile";
var fileName = DateTime.Now.Ticks + "-" + NumUtil.GetRandomString(3);
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);
#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
}
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