wet 2 years ago
commit 6eae4efc9f

@ -0,0 +1,87 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
[Tenant("taskmanage")]
[SugarTable("task_original_download_his")]
[Description("任务正本下载运行表")]
public class TaskOriginalDownloadHisInfo
{
/// <summary>
/// 惟一主键
/// </summary>
[SugarColumn(ColumnDescription = "惟一主键", IsPrimaryKey = true)]
public string PK_ID { get; set; }
/// <summary>
/// 任务主键
/// </summary>
public string TASK_ID { get; set; }
/// <summary>
/// 状态 succ-成功 failure-失败 timeout-超时
/// </summary>
public string STATUS { get; set; }
/// <summary>
/// 起始时间
/// </summary>
public Nullable<DateTime> START_DATE { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public Nullable<DateTime> END_DATE { get; set; }
/// <summary>
/// 请求文件URL
/// </summary>
public string REQUEST_URL { get; set; }
/// <summary>
/// 下载完文件URL
/// </summary>
public string RESULT_URL { get; set; }
/// <summary>
/// 处理结果
/// </summary>
public string RESULT_NOTE { get; set; }
/// <summary>
/// 是否超时 1-超时 0-未超时
/// </summary>
public int IS_TIMEOUT { get; set; }
/// <summary>
/// 创建人ID
/// </summary>
public long CreatedUserId { get; set; }
/// <summary>
/// 创建人名称
/// </summary>
public string CreatedUserName { get; set; }
/// <summary>
/// 租户id
/// </summary>
public long? TenantId { get; set; }
/// <summary>
/// 租户名称
/// </summary>
public string TenantName { get; set; }
/// <summary>
/// 软删除
/// </summary>
public bool IsDeleted { get; set; } = false;
}
}

@ -4421,6 +4421,76 @@
品名分类名称
</summary>
</member>
<member name="P:Myshipping.Application.TaskOriginalDownloadHisInfo.PK_ID">
<summary>
惟一主键
</summary>
</member>
<member name="P:Myshipping.Application.TaskOriginalDownloadHisInfo.TASK_ID">
<summary>
任务主键
</summary>
</member>
<member name="P:Myshipping.Application.TaskOriginalDownloadHisInfo.STATUS">
<summary>
状态 succ-成功 failure-失败 timeout-超时
</summary>
</member>
<member name="P:Myshipping.Application.TaskOriginalDownloadHisInfo.START_DATE">
<summary>
起始时间
</summary>
</member>
<member name="P:Myshipping.Application.TaskOriginalDownloadHisInfo.END_DATE">
<summary>
结束时间
</summary>
</member>
<member name="P:Myshipping.Application.TaskOriginalDownloadHisInfo.REQUEST_URL">
<summary>
请求文件URL
</summary>
</member>
<member name="P:Myshipping.Application.TaskOriginalDownloadHisInfo.RESULT_URL">
<summary>
下载完文件URL
</summary>
</member>
<member name="P:Myshipping.Application.TaskOriginalDownloadHisInfo.RESULT_NOTE">
<summary>
处理结果
</summary>
</member>
<member name="P:Myshipping.Application.TaskOriginalDownloadHisInfo.IS_TIMEOUT">
<summary>
是否超时 1-超时 0-未超时
</summary>
</member>
<member name="P:Myshipping.Application.TaskOriginalDownloadHisInfo.CreatedUserId">
<summary>
创建人ID
</summary>
</member>
<member name="P:Myshipping.Application.TaskOriginalDownloadHisInfo.CreatedUserName">
<summary>
创建人名称
</summary>
</member>
<member name="P:Myshipping.Application.TaskOriginalDownloadHisInfo.TenantId">
<summary>
租户id
</summary>
</member>
<member name="P:Myshipping.Application.TaskOriginalDownloadHisInfo.TenantName">
<summary>
租户名称
</summary>
</member>
<member name="P:Myshipping.Application.TaskOriginalDownloadHisInfo.IsDeleted">
<summary>
软删除
</summary>
</member>
<member name="T:Myshipping.Application.BookingTemplateType">
<summary>
收发通模板类型
@ -6027,16 +6097,25 @@
</member>
<member name="M:Myshipping.Application.BookingOrderService.GetReportFile(System.Int64,System.String,System.Int32)">
<summary>
生成报表文件
生成报表文件(准备作废)
</summary>
<param name="bookingId"></param>
<param name="type">类型1pdf、2xlsx、3docx</param>
<param name="typeCode">报表类型代码例如fangcang、samplebill等</param>
<returns></returns>
</member>
<member name="M:Myshipping.Application.BookingOrderService.GenPrintFile(System.Int64,Myshipping.Application.Entity.BookingPrintTemplate,System.Int32)">
<summary>
生成打印报表文件
</summary>
<param name="bookingId">订舱ID</param>
<param name="template">打印模板</param>
<param name="type">类型1pdf、2xlsx、3docx</param>
<returns></returns>
</member>
<member name="M:Myshipping.Application.BookingOrderService.Print(System.Int64,System.String,System.Int32)">
<summary>
打印
打印准备作废使用PrintOrder代替
</summary>
<param name="bookingId">订舱Id</param>
<param name="typeCode">打印类型代码对应字典booking_template_type</param>
@ -6050,12 +6129,13 @@
<param name="fileName">文件名</param>
<returns></returns>
</member>
<member name="M:Myshipping.Application.BookingOrderService.PrintWithView(System.Int64,System.String)">
<member name="M:Myshipping.Application.BookingOrderService.PrintOrder(System.Int64,System.Int64,System.Int32)">
<summary>
打印(可浏览器预览
打印(返回文件名
</summary>
<param name="bookingId">订舱Id</param>
<param name="typeCode">打印类型代码对应字典booking_template_type</param>
<param name="templateId">打印模板ID</param>
<param name="type">类型1pdf、2xlsx、3docx</param>
<returns></returns>
</member>
<member name="M:Myshipping.Application.BookingOrderService.ViewPrintPdf(System.String)">
@ -9785,21 +9865,25 @@
<summary>
主键
</summary>
<example>358942162968645</example>
</member>
<member name="P:Myshipping.Application.ParaContractNoDto.ContractNo">
<summary>
合约号编号
</summary>
<example>TAO21A00759</example>
</member>
<member name="P:Myshipping.Application.ParaContractNoDto.ContractName">
<summary>
合约号名称
</summary>
<example>测试1</example>
</member>
<member name="P:Myshipping.Application.ParaContractNoDto.ContractNote">
<summary>
合约号备注
</summary>
<example>测试1</example>
</member>
<member name="P:Myshipping.Application.ParaContractNoDto.CreateTime">
<summary>
@ -9948,6 +10032,163 @@
修改者名称
</summary>
</member>
<member name="T:Myshipping.Application.QueryParaContractNoDto">
<summary>
约号台账查询
</summary>
</member>
<member name="P:Myshipping.Application.QueryParaContractNoDto.ContractNo">
<summary>
合约号编号
</summary>
</member>
<member name="P:Myshipping.Application.QueryParaContractNoDto.ContractName">
<summary>
合约号名称
</summary>
</member>
<member name="P:Myshipping.Application.QueryParaContractNoDto.ContractNote">
<summary>
合约号备注
</summary>
</member>
<member name="P:Myshipping.Application.QueryParaContractNoDto.CreateUserName">
<summary>
创建者名称
</summary>
<example></example>
</member>
<member name="P:Myshipping.Application.QueryParaContractNoDto.UpdateUserName">
<summary>
修改者名称
</summary>
<example></example>
</member>
<member name="P:Myshipping.Application.QueryParaContractNoDto.CreateTimeBegin">
<summary>
创建时间开始
</summary>
<example>2022-01-01</example>
</member>
<member name="P:Myshipping.Application.QueryParaContractNoDto.CreateTimeEnd">
<summary>
创建时间结束
</summary>
<example>2023-07-01</example>
</member>
<member name="P:Myshipping.Application.QueryParaContractNoDto.UpdateTimeBegin">
<summary>
更新时间开始
</summary>
<example></example>
</member>
<member name="P:Myshipping.Application.QueryParaContractNoDto.UpdateTimeEnd">
<summary>
更新时间结束
</summary>
<example></example>
</member>
<member name="P:Myshipping.Application.QueryParaContractNoDto.PageNo">
<summary>
当前页码
</summary>
<example>1</example>
</member>
<member name="P:Myshipping.Application.QueryParaContractNoDto.PageSize">
<summary>
页码容量
</summary>
<example>20</example>
</member>
<member name="P:Myshipping.Application.QueryParaContractNoDto.SortField">
<summary>
排序字段
</summary>
<example>ContractNo</example>
</member>
<member name="P:Myshipping.Application.QueryParaContractNoDto.descSort">
<summary>
排序方法,默认降序
</summary>
<example>true</example>
</member>
<member name="T:Myshipping.Application.QueryParaGoodsCategoryDto">
<summary>
品名分类参数台账查询
</summary>
</member>
<member name="P:Myshipping.Application.QueryParaGoodsCategoryDto.GoodsCategory">
<summary>
品名分类
</summary>
<example>02</example>
</member>
<member name="P:Myshipping.Application.QueryParaGoodsCategoryDto.GoodsCategoryName">
<summary>
品名分类名称
</summary>
<example></example>
</member>
<member name="P:Myshipping.Application.QueryParaGoodsCategoryDto.CreateUserName">
<summary>
创建者名称
</summary>
<example></example>
</member>
<member name="P:Myshipping.Application.QueryParaGoodsCategoryDto.UpdateUserName">
<summary>
修改者名称
</summary>
<example></example>
</member>
<member name="P:Myshipping.Application.QueryParaGoodsCategoryDto.CreateTimeBegin">
<summary>
创建时间开始
</summary>
<example>2022-01-01</example>
</member>
<member name="P:Myshipping.Application.QueryParaGoodsCategoryDto.CreateTimeEnd">
<summary>
创建时间结束
</summary>
<example>2023-07-01</example>
</member>
<member name="P:Myshipping.Application.QueryParaGoodsCategoryDto.UpdateTimeBegin">
<summary>
更新时间开始
</summary>
<example></example>
</member>
<member name="P:Myshipping.Application.QueryParaGoodsCategoryDto.UpdateTimeEnd">
<summary>
更新时间结束
</summary>
<example></example>
</member>
<member name="P:Myshipping.Application.QueryParaGoodsCategoryDto.PageNo">
<summary>
当前页码
</summary>
<example>1</example>
</member>
<member name="P:Myshipping.Application.QueryParaGoodsCategoryDto.PageSize">
<summary>
页码容量
</summary>
<example>20</example>
</member>
<member name="P:Myshipping.Application.QueryParaGoodsCategoryDto.SortField">
<summary>
排序字段
</summary>
<example>GoodsCategory</example>
</member>
<member name="P:Myshipping.Application.QueryParaGoodsCategoryDto.descSort">
<summary>
排序方法,默认降序
</summary>
<example>true</example>
</member>
<member name="T:Myshipping.Application.QueryParaGoodsDto">
<summary>
品名参数台账查询
@ -10069,6 +10310,7 @@
检索品名参数
</summary>
<param name="queryItem">检索值</param>
<param name="top">默认最大行数</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.IParaService.GetParaGoodsPageAsync(Myshipping.Application.QueryParaGoodsDto)">
@ -10078,6 +10320,78 @@
<param name="QuerySearch">品名参数台账查询请求</param>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.IParaService.SaveParaGoodsCategoryInfo(Myshipping.Application.ParaGoodsCategoryDto)">
<summary>
保存品名分类参数
</summary>
<param name="model">品名分类参数</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.IParaService.GetParaGoodsCategoryInfo(System.Int64)">
<summary>
主键获取品名分类参数
</summary>
<param name="Id">品名分类主键</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.IParaService.QueryParaGoodsCategoryInfo(System.String,System.Int32)">
<summary>
检索品名分类参数
</summary>
<param name="queryItem">检索值</param>
<param name="top">默认最大行数</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.IParaService.DeleteParaGoodsCategoryInfo(System.Int64[])">
<summary>
作废品名分类参数
</summary>
<param name="Ids">品名分类参数主键数组</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.IParaService.GetParaGoodsCategoryPageAsync(Myshipping.Application.QueryParaGoodsCategoryDto)">
<summary>
品名分类参数台账查询
</summary>
<param name="QuerySearch">品名分类参数台账查询请求</param>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.IParaService.SaveParaContractNoInfo(Myshipping.Application.ParaContractNoDto)">
<summary>
保存约号参数
</summary>
<param name="model">约号参数</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.IParaService.GetParaContractNoInfo(System.Int64)">
<summary>
主键获取约号参数
</summary>
<param name="Id">约号主键</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.IParaService.QuerytParaContractNoInfo(System.String,System.Int32)">
<summary>
检索约号参数
</summary>
<param name="queryItem">检索值</param>
<param name="top">默认最大行数</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.IParaService.DeleteParaContractNoInfo(System.Int64[])">
<summary>
作废约号参数
</summary>
<param name="Ids">约号参数主键数组</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.IParaService.GetParaContractNoPageAsync(Myshipping.Application.QueryParaContractNoDto)">
<summary>
约号参数台账查询
</summary>
<param name="QuerySearch">约号参数台账查询请求</param>
<returns>返回结果</returns>
</member>
<member name="T:Myshipping.Application.ParaService">
<summary>
订舱业务参数
@ -10119,6 +10433,78 @@
<param name="QuerySearch">品名参数台账查询请求</param>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.ParaService.SaveParaGoodsCategoryInfo(Myshipping.Application.ParaGoodsCategoryDto)">
<summary>
保存品名分类参数
</summary>
<param name="model">品名分类参数</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.ParaService.GetParaGoodsCategoryInfo(System.Int64)">
<summary>
主键获取品名分类参数
</summary>
<param name="Id">品名分类主键</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.ParaService.QueryParaGoodsCategoryInfo(System.String,System.Int32)">
<summary>
检索品名分类参数
</summary>
<param name="queryItem">检索值</param>
<param name="top">默认最大行数</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.ParaService.DeleteParaGoodsCategoryInfo(System.Int64[])">
<summary>
作废品名分类参数
</summary>
<param name="Ids">品名分类参数主键数组</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.ParaService.GetParaGoodsCategoryPageAsync(Myshipping.Application.QueryParaGoodsCategoryDto)">
<summary>
品名分类参数台账查询
</summary>
<param name="QuerySearch">品名分类参数台账查询请求</param>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.ParaService.SaveParaContractNoInfo(Myshipping.Application.ParaContractNoDto)">
<summary>
保存约号参数
</summary>
<param name="model">约号参数</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.ParaService.GetParaContractNoInfo(System.Int64)">
<summary>
主键获取约号参数
</summary>
<param name="Id">约号主键</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.ParaService.QuerytParaContractNoInfo(System.String,System.Int32)">
<summary>
检索约号参数
</summary>
<param name="queryItem">检索值</param>
<param name="top">默认最大行数</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.ParaService.DeleteParaContractNoInfo(System.Int64[])">
<summary>
作废约号参数
</summary>
<param name="Ids">约号参数主键数组</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.ParaService.GetParaContractNoPageAsync(Myshipping.Application.QueryParaContractNoDto)">
<summary>
约号参数台账查询
</summary>
<param name="QuerySearch">约号参数台账查询请求</param>
<returns>返回结果</returns>
</member>
<member name="P:Myshipping.Application.RulesEngineOrderBookingContaCargoInfo.PKGs">
<summary>
件数
@ -12222,6 +12608,13 @@
<param name="QuerySearch">任务台账查询请求</param>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.ITaskManageService.DownloadOriginalTask(System.String[])">
<summary>
下载正本提单
</summary>
<param name="PKIds">任务主键数组</param>
<returns>返回结果</returns>
</member>
<member name="T:Myshipping.Application.TaskManageService">
<summary>
任务管理
@ -12263,5 +12656,12 @@
<param name="QuerySearch">任务台账查询请求</param>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.TaskManageService.DownloadOriginalTask(System.String[])">
<summary>
下载正本提单(可批量)
</summary>
<param name="PKIds">任务主键数组</param>
<returns>返回结果</returns>
</member>
</members>
</doc>

@ -368,7 +368,7 @@ namespace Myshipping.Application
var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}");
input.CNTRTOTAL = string.Join(" / ", groupList);
}
var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID&&x.ParentId==0).FirstAsync();
var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.ParentId == 0).FirstAsync();
if (et != null)
{
@ -483,7 +483,7 @@ namespace Myshipping.Application
}
var main = await _rep.AsQueryable().Where(x => x.Id == input.Id).FirstAsync();
var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.Id != input.Id&& x.ParentId == 0).FirstAsync();
var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.Id != input.Id && x.ParentId == 0).FirstAsync();
if (et != null)
{
@ -933,7 +933,8 @@ namespace Myshipping.Application
}
_logger.LogInformation("调用运踪接口提单号:" + item.MBLNO + " 调用运踪接口");
if (item.isBook&&(string.IsNullOrWhiteSpace(item.CARRIERID)|| string.IsNullOrWhiteSpace(item.CARRIER) || string.IsNullOrWhiteSpace(item.MBLNO))) {
if (item.isBook && (string.IsNullOrWhiteSpace(item.CARRIERID) || string.IsNullOrWhiteSpace(item.CARRIER) || string.IsNullOrWhiteSpace(item.MBLNO)))
{
throw Oops.Bah("订阅目的港船公司或提单号不能为空!");
}
billTraceList.Add(new BillTraceList
@ -1372,7 +1373,7 @@ namespace Myshipping.Application
}
/// <summary>
/// 获取放舱pdf
/// 获取放舱pdf(准备作废,后期使用打印相关接口)
/// </summary>
/// <param name="bookingId"></param>
/// <param name="type">类型1pdf、2xlsx、3docx</param>
@ -1412,7 +1413,7 @@ namespace Myshipping.Application
}
/// <summary>
/// 获取放舱excel
/// 获取放舱excel(准备作废,后期使用打印相关接口)
/// </summary>
/// <param name="bookingId"></param>
/// <returns></returns>
@ -1431,7 +1432,7 @@ namespace Myshipping.Application
}
/// <summary>
/// 生成报表文件
/// 生成报表文件(准备作废)
/// </summary>
/// <param name="bookingId"></param>
/// <param name="type">类型1pdf、2xlsx、3docx</param>
@ -1501,11 +1502,75 @@ namespace Myshipping.Application
}
}
/// <summary>
/// 生成打印报表文件
/// </summary>
/// <param name="bookingId">订舱ID</param>
/// <param name="printTemplate">打印模板</param>
/// <param name="type">类型1pdf、2xlsx、3docx</param>
/// <returns></returns>
[NonAction]
private async Task<byte[]> GenPrintFile(long bookingId, BookingPrintTemplate printTemplate, int type = 1)
{
//打印报表服务地址
var reportUrl = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "url_report_generate").Value;
if (!reportUrl.EndsWith("/"))
{
reportUrl += "/";
}
//订舱数据
var order = _rep.FirstOrDefault(x => x.Id == bookingId);
if (order == null)
{
throw Oops.Bah(BookingErrorCode.BOOK001);
}
var opt = App.GetOptions<PrintTemplateOptions>();
var dirAbs = opt.basePath;
if (string.IsNullOrEmpty(dirAbs))
{
dirAbs = App.WebHostEnvironment.WebRootPath;
}
var fileAbsPath = Path.Combine(dirAbs, printTemplate.FilePath);
_logger.LogInformation($"查找模板文件:{fileAbsPath}");
if (!File.Exists(fileAbsPath))
{
throw Oops.Bah(BookingErrorCode.BOOK115);
}
_logger.LogInformation($"准备调用报表生成id{bookingId},文件:{printTemplate.FileName}");
var genUrl = $"{reportUrl}Report/BookingReport?bookingId={bookingId}&type={type}";
var rtn = await genUrl
.SetContentType("multipart/form-data")
.SetBodyBytes(("file", File.ReadAllBytes(fileAbsPath), HttpUtility.UrlEncode(printTemplate.FileName, Encoding.GetEncoding("UTF-8"))))
.PostAsStringAsync();
var jobjRtn = JObject.Parse(rtn);
_logger.LogInformation($"调用报表生成返回:{rtn}");
if (jobjRtn.GetBooleanValue("Success"))
{
//调用读取文件
var fn = jobjRtn.GetStringValue("Data");
_logger.LogInformation($"准备调用读取报表文件id{bookingId},文件名:{fn}");
var readFileUrl = $"{reportUrl}Report/GetFile?fileName={fn}";
var bs = await readFileUrl.GetAsByteArrayAsync();
_logger.LogInformation($"调用读取报表文件返回:{bs.Length}");
return bs;
}
else
{
throw Oops.Bah($"生成报表文件失败:{jobjRtn.GetStringValue("Message")}");
}
}
#endregion
#region 打印
/// <summary>
/// 打印
/// 打印准备作废使用PrintOrder代替
/// </summary>
/// <param name="bookingId">订舱Id</param>
/// <param name="typeCode">打印类型代码对应字典booking_template_type</param>
@ -1589,16 +1654,40 @@ namespace Myshipping.Application
}
/// <summary>
/// 打印(可浏览器预览
/// 打印(返回文件名
/// </summary>
/// <param name="bookingId">订舱Id</param>
/// <param name="typeCode">打印类型代码对应字典booking_template_type</param>
/// <param name="templateId">打印模板ID</param>
/// <param name="type">类型1pdf、2xlsx、3docx</param>
/// <returns></returns>
[HttpGet("/BookingOrder/PrintWithView")]
public async Task<string> PrintWithView(long bookingId, string typeCode)
[HttpGet("/BookingOrder/PrintOrder")]
public async Task<string> PrintOrder(long bookingId, long templateId, int type = 1)
{
var bs = await GetReportFile(bookingId, typeCode);
var fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}.pdf", Encoding.GetEncoding("UTF-8"));//名称
var printTemplate = await _repPrintTemplate.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == templateId);
if (printTemplate == null)
{
throw Oops.Bah(BookingErrorCode.BOOK115);
}
var bs = await GenPrintFile(bookingId, printTemplate, type);
var fileType = "";
if (type == 1)
{
fileType = ".pdf";
}
else if (type == 2)
{
fileType = ".xlsx";
}
else if (type == 3)
{
fileType = ".docx";
}
else
{
throw Oops.Bah("类型参数不正确");
}
var fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}{fileType}", Encoding.GetEncoding("UTF-8"));//名称
var opt = App.GetOptions<TempFileOptions>().Path;
var serverpath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt);//服务器路径
if (!Directory.Exists(serverpath))
@ -1607,33 +1696,73 @@ namespace Myshipping.Application
}
var fullPath = Path.Combine(serverpath, fileName);
await File.WriteAllBytesAsync(fullPath, bs);
var vid = Guid.NewGuid().ToString().Replace("-", "");
await _cache.SetTimeoutAsync(vid, fullPath, TimeSpan.FromSeconds(300));
return vid;
//记录打印次数和时间,用于前端动态展示常用的打印类型
var printRecentListKey = $"{PrintRecentListTypeKey}_{printTemplate.CateCode}";
var usrCfg = _repUserConfig.AsQueryable().First(x => x.CreatedUserId == UserManager.UserId && x.Type == printRecentListKey);
if (usrCfg == null)
{
usrCfg = new DjyUserConfig();
usrCfg.Type = printRecentListKey;
usrCfg.ConfigJson = (new long[] { templateId }).ToJson();
await _repUserConfig.InsertAsync(usrCfg);
}
else
{
var arr = JArray.Parse(usrCfg.ConfigJson).Select(x => Convert.ToInt64(x)).Where(x => x != templateId).ToList();
arr.Insert(0, templateId);
usrCfg.ConfigJson = arr.ToArray().ToJson();
await _repUserConfig.UpdateAsync(usrCfg);
}
return fileName;
}
///// <summary>
///// 下载打印文件(PDF直接预览)
///// </summary>
///// <param name="vid">查看ID</param>
///// <returns></returns>
//[HttpGet("/BookingOrder/ViewPrintPdf/{vid}"), AllowAnonymous]
//public void ViewPrintPdf(string vid)
//{
// if (_cache.Exists(vid))
// {
// var fileFullName = _cache.Get(vid);
// var readMem = new ReadOnlyMemory<byte>(File.ReadAllBytes(fileFullName));
// _httpContextAccessor.HttpContext.Response.BodyWriter.WriteAsync(readMem);
// }
// else
// {
// throw Oops.Bah("下载链接失效,请重新打印");
// }
//}
/// <summary>
/// 下载打印文件(PDF直接预览)
/// 预览模板生成的pdf文件
/// </summary>
/// <param name="vid">查看ID</param>
/// <param name="fn">文件名称</param>
/// <returns></returns>
[HttpGet("/BookingOrder/ViewPrintPdf/{vid}"), AllowAnonymous]
public void ViewPrintPdf(string vid)
[HttpGet("/BookingOrder/ViewPrintPdf/{fn}"), AllowAnonymous]
public void ViewPrintPdf(string fn)
{
if (_cache.Exists(vid))
var opt = App.GetOptions<TempFileOptions>().Path;
var fileFullPath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt);
var fileFullName = Path.Combine(fileFullPath, fn);
if (File.Exists(fileFullName))
{
var fileFullName = _cache.Get(vid);
var readMem = new ReadOnlyMemory<byte>(File.ReadAllBytes(fileFullName));
_httpContextAccessor.HttpContext.Response.BodyWriter.WriteAsync(readMem);
}
else
{
throw Oops.Bah("下载链接失效,请重新打印");
_httpContextAccessor.HttpContext.Response.StatusCode = 404;
}
}
/// <summary>
/// 获取订舱打印模板列表(带有当前用户打印历史排序)
/// 获取订舱打印模板列表(带有当前用户打印历史排序)准备作废使用PrintTemplateWithHistoryList代替
/// </summary>
/// <returns></returns>
[HttpGet("/BookingOrder/PrintTemplateList")]
@ -1682,6 +1811,59 @@ namespace Myshipping.Application
}
}
/// <summary>
/// 获取订舱打印模板列表(带有当前用户打印历史排序)
/// </summary>
/// <param name="cateCode">分类代码使用字典【booking_template_category】中的代码</param>
/// <returns></returns>
[HttpGet("/BookingOrder/PrintTemplateWithHistoryList")]
public async Task<dynamic> PrintTemplateWithHistoryList(string cateCode)
{
//当前公司所有已配置的模板
var allList = await _repPrintTemplate.AsQueryable()
.Filter(null, true).InnerJoin<BookingPrinttemplateRight>((d, t) => d.Id == t.PrintTemplateId && t.SysUserId == UserManager.UserId)
.Where(d => d.TenantId == UserManager.TENANT_ID && d.CateCode == cateCode)
.Select(d => new
{
d.Id,
d.CateCode,
d.CateName,
d.DisplayName
})
.ToListAsync();
var listReult = new List<dynamic>();
//当前用户打印历史数据
var printRecentListKey = $"{PrintRecentListTypeKey}_{cateCode}";
var usrCfg = await _repUserConfig.AsQueryable().FirstAsync(x => x.CreatedUserId == UserManager.UserId && x.Type == printRecentListKey);
if (usrCfg != null)
{
var arr = JArray.Parse(usrCfg.ConfigJson).Select(x => Convert.ToInt64(x)).ToList();
//按顺序加入到结果
arr.ForEach(x =>
{
var find = allList.FirstOrDefault(y => y.Id == x);
if (find != null)
{
listReult.Add(find);
}
});
var listOut = allList.Where(x => !arr.Contains(x.Id)).ToList();
listReult.AddRange(listOut);
return listReult;
}
else
{
return allList;
}
}
#endregion
#region 下货纸

@ -11,21 +11,25 @@ namespace Myshipping.Application
/// <summary>
/// 主键
/// </summary>
/// <example>358942162968645</example>
public string Id{ get; set; }
/// <summary>
/// 合约号编号
/// </summary>
public string ContractNo { get; set; }
/// <example>TAO21A00759</example>
public string ContractNo { get; set; }
/// <summary>
/// 合约号名称
/// </summary>
/// <example>测试1</example>
public string ContractName { get; set; }
/// <summary>
/// 合约号备注
/// </summary>
/// <example>测试1</example>
public string ContractNote { get; set; }
/// <summary>

@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 约号台账查询
/// </summary>
public class QueryParaContractNoDto
{
/// <summary>
/// 合约号编号
/// </summary>
public string ContractNo { get; set; }
/// <summary>
/// 合约号名称
/// </summary>
public string ContractName { get; set; }
/// <summary>
/// 合约号备注
/// </summary>
public string ContractNote { get; set; }
/// <summary>
/// 创建者名称
/// </summary>
/// <example></example>
public string CreateUserName { get; set; }
/// <summary>
/// 修改者名称
/// </summary>
/// <example></example>
public string UpdateUserName { get; set; }
/// <summary>
/// 创建时间开始
/// </summary>
/// <example>2022-01-01</example>
public string CreateTimeBegin { get; set; }
/// <summary>
/// 创建时间结束
/// </summary>
/// <example>2023-07-01</example>
public string CreateTimeEnd { get; set; }
/// <summary>
/// 更新时间开始
/// </summary>
/// <example></example>
public string UpdateTimeBegin { get; set; }
/// <summary>
/// 更新时间结束
/// </summary>
/// <example></example>
public string UpdateTimeEnd { get; set; }
/// <summary>
/// 当前页码
/// </summary>
/// <example>1</example>
public int PageNo { get; set; } = 1;
/// <summary>
/// 页码容量
/// </summary>
/// <example>20</example>
public int PageSize { get; set; } = 20;
/// <summary>
/// 排序字段
/// </summary>
/// <example>ContractNo</example>
public string SortField { get; set; }
/// <summary>
/// 排序方法,默认降序
/// </summary>
/// <example>true</example>
public bool descSort { get; set; } = true;
}
}

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 品名分类参数台账查询
/// </summary>
public class QueryParaGoodsCategoryDto
{
/// <summary>
/// 品名分类
/// </summary>
/// <example>02</example>
public string GoodsCategory { get; set; }
/// <summary>
/// 品名分类名称
/// </summary>
/// <example></example>
public string GoodsCategoryName { get; set; }
/// <summary>
/// 创建者名称
/// </summary>
/// <example></example>
public string CreateUserName { get; set; }
/// <summary>
/// 修改者名称
/// </summary>
/// <example></example>
public string UpdateUserName { get; set; }
/// <summary>
/// 创建时间开始
/// </summary>
/// <example>2022-01-01</example>
public string CreateTimeBegin { get; set; }
/// <summary>
/// 创建时间结束
/// </summary>
/// <example>2023-07-01</example>
public string CreateTimeEnd { get; set; }
/// <summary>
/// 更新时间开始
/// </summary>
/// <example></example>
public string UpdateTimeBegin { get; set; }
/// <summary>
/// 更新时间结束
/// </summary>
/// <example></example>
public string UpdateTimeEnd { get; set; }
/// <summary>
/// 当前页码
/// </summary>
/// <example>1</example>
public int PageNo { get; set; } = 1;
/// <summary>
/// 页码容量
/// </summary>
/// <example>20</example>
public int PageSize { get; set; } = 20;
/// <summary>
/// 排序字段
/// </summary>
/// <example>GoodsCategory</example>
public string SortField { get; set; }
/// <summary>
/// 排序方法,默认降序
/// </summary>
/// <example>true</example>
public bool descSort { get; set; } = true;
}
}

@ -33,6 +33,7 @@ namespace Myshipping.Application
/// 检索品名参数
/// </summary>
/// <param name="queryItem">检索值</param>
/// <param name="top">默认最大行数</param>
/// <returns>返回回执</returns>
Task<List<ParaGoodsDto>> QueryParaGoodsInfo(string queryItem, int top = 10);
@ -43,47 +44,77 @@ namespace Myshipping.Application
/// <returns>返回结果</returns>
Task<dynamic> GetParaGoodsPageAsync(QueryParaGoodsDto QuerySearch);
///// <summary>
///// 保存品名分类参数
///// </summary>
///// <param name="model">品名分类参数</param>
///// <returns>返回回执</returns>
//Task<CommonWebApiResult> SaveParaGoodsCategoryInfo(ParaGoodsCategoryDto model);
///// <summary>
///// 主键获取品名分类参数
///// </summary>
///// <param name="Id">品名分类主键</param>
///// <returns>返回回执</returns>
//Task<CommonWebApiResult> GetParaGoodsCategoryInfo(long Id);
///// <summary>
///// 检索品名分类参数
///// </summary>
///// <param name="queryItem">检索值</param>
///// <returns>返回回执</returns>
//Task<CommonWebApiResult> QueryParaGoodsCategoryInfo(string queryItem);
///// <summary>
///// 保存约号参数
///// </summary>
///// <param name="model">约号参数</param>
///// <returns>返回回执</returns>
//Task<CommonWebApiResult> SaveParaContractNoInfo(ParaGoodsCategoryDto model);
///// <summary>
///// 主键获取约号参数
///// </summary>
///// <param name="Id">约号主键</param>
///// <returns>返回回执</returns>
//Task<CommonWebApiResult> GetParaContractNoInfo(long Id);
///// <summary>
///// 检索约号参数
///// </summary>
///// <param name="queryItem">检索值</param>
///// <returns>返回回执</returns>
//Task<CommonWebApiResult> QuerytParaContractNoInfo(string queryItem);
/// <summary>
/// 保存品名分类参数
/// </summary>
/// <param name="model">品名分类参数</param>
/// <returns>返回回执</returns>
Task<long> SaveParaGoodsCategoryInfo(ParaGoodsCategoryDto model);
/// <summary>
/// 主键获取品名分类参数
/// </summary>
/// <param name="Id">品名分类主键</param>
/// <returns>返回回执</returns>
Task<ParaGoodsCategoryDto> GetParaGoodsCategoryInfo(long Id);
/// <summary>
/// 检索品名分类参数
/// </summary>
/// <param name="queryItem">检索值</param>
/// <param name="top">默认最大行数</param>
/// <returns>返回回执</returns>
Task<List<ParaGoodsCategoryDto>> QueryParaGoodsCategoryInfo(string queryItem, int top = 10);
/// <summary>
/// 作废品名分类参数
/// </summary>
/// <param name="Ids">品名分类参数主键数组</param>
/// <returns>返回回执</returns>
Task<string> DeleteParaGoodsCategoryInfo(long[] Ids);
/// <summary>
/// 品名分类参数台账查询
/// </summary>
/// <param name="QuerySearch">品名分类参数台账查询请求</param>
/// <returns>返回结果</returns>
Task<dynamic> GetParaGoodsCategoryPageAsync(QueryParaGoodsCategoryDto QuerySearch);
/// <summary>
/// 保存约号参数
/// </summary>
/// <param name="model">约号参数</param>
/// <returns>返回回执</returns>
Task<long> SaveParaContractNoInfo(ParaContractNoDto model);
/// <summary>
/// 主键获取约号参数
/// </summary>
/// <param name="Id">约号主键</param>
/// <returns>返回回执</returns>
Task<ParaContractNoDto> GetParaContractNoInfo(long Id);
/// <summary>
/// 检索约号参数
/// </summary>
/// <param name="queryItem">检索值</param>
/// <param name="top">默认最大行数</param>
/// <returns>返回回执</returns>
Task<List<ParaContractNoDto>> QuerytParaContractNoInfo(string queryItem, int top = 10);
/// <summary>
/// 作废约号参数
/// </summary>
/// <param name="Ids">约号参数主键数组</param>
/// <returns>返回回执</returns>
Task<string> DeleteParaContractNoInfo(long[] Ids);
/// <summary>
/// 约号参数台账查询
/// </summary>
/// <param name="QuerySearch">约号参数台账查询请求</param>
/// <returns>返回结果</returns>
Task<dynamic> GetParaContractNoPageAsync(QueryParaContractNoDto QuerySearch);
}
}

@ -7,8 +7,11 @@ using Microsoft.Extensions.Logging;
using Myshipping.Application.Entity;
using Myshipping.Application.Helper;
using Myshipping.Core;
using Myshipping.Core.Entity;
using NPOI.OpenXmlFormats.Wordprocessing;
using NPOI.SS.Formula.Functions;
using NPOI.XWPF.UserModel;
using Org.BouncyCastle.Crypto;
using System;
using System.Collections.Generic;
using System.Linq;
@ -60,6 +63,17 @@ namespace Myshipping.Application
if(sameList.Count > 0 && !string.IsNullOrWhiteSpace(model.Id) && sameList.Any(t=>t.Id != long.Parse(model.Id)))
throw Oops.Oh($"商品编码【{model.GoodsCode}】已存在不能重复保存");
//如果填写了品名分配需要确认根据库中数据一致
if (!string.IsNullOrWhiteSpace(model.GoodsCategory))
{
var categoryInfo = _paraGoodsCategoryInfoRepository.AsQueryable().First(t => t.GOODS_CATEGORY.Equals(model.GoodsCategory.Trim()));
if (categoryInfo == null)
throw Oops.Oh($"品名分类代码【{model.GoodsCategory}】不存在,请确认品名分类");
if (!string.IsNullOrWhiteSpace(model.GoodsCategoryName) && !categoryInfo.GOODS_CATEGORY_NAME.Equals(model.GoodsCategoryName.Trim()))
throw Oops.Oh($"品名分类名称【{model.GoodsCategoryName}】错误code={model.GoodsCategory}请确认品名分类");
}
if (!string.IsNullOrWhiteSpace(model.Id))
{
@ -135,7 +149,6 @@ namespace Myshipping.Application
await _paraGoodsInfoRepository.AsUpdateable(entity).IgnoreColumns(it => new
{
it.Id,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
@ -281,8 +294,8 @@ namespace Myshipping.Application
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.GoodsDesp), t => t.GOODS_DESP.Contains(QuerySearch.GoodsDesp.Trim(), StringComparison.OrdinalIgnoreCase))
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.GoodsNameEN), t => t.GOODS_NAME_EN.Contains(QuerySearch.GoodsNameEN.Trim(), StringComparison.OrdinalIgnoreCase))
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.GoodsCategory), t => t.GOODS_CATEGORY.Equals(QuerySearch.GoodsCategory.Trim(), StringComparison.OrdinalIgnoreCase))
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.CreateUserName), t => t.GOODS_NAME_EN.Contains(QuerySearch.CreateUserName.Trim(), StringComparison.OrdinalIgnoreCase))
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.UpdateUserName), t => t.GOODS_NAME_EN.Contains(QuerySearch.UpdateUserName.Trim(), StringComparison.OrdinalIgnoreCase))
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.CreateUserName), t => t.CreatedUserName.Contains(QuerySearch.CreateUserName.Trim(), StringComparison.OrdinalIgnoreCase))
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.UpdateUserName), t => t.UpdatedUserName.Contains(QuerySearch.UpdateUserName.Trim(), StringComparison.OrdinalIgnoreCase))
.OrderBy(entityOrderCol + (QuerySearch.descSort ? " asc " : " desc "))
.ToPagedListAsync(QuerySearch.PageNo, QuerySearch.PageSize);
return new
@ -295,77 +308,525 @@ namespace Myshipping.Application
};
}
///// <summary>
///// 保存品名分类参数
///// </summary>
///// <param name="model">品名分类参数</param>
///// <returns>返回回执</returns>
//public async Task<CommonWebApiResult> SaveParaGoodsCategoryInfo(ParaGoodsCategoryDto model)
//{
// CommonWebApiResult result = new CommonWebApiResult();
// return result;
//}
///// <summary>
///// 主键获取品名分类参数
///// </summary>
///// <param name="Id">品名分类主键</param>
///// <returns>返回回执</returns>
//public async Task<CommonWebApiResult> GetParaGoodsCategoryInfo(long Id)
//{
// CommonWebApiResult result = new CommonWebApiResult();
// return result;
//}
///// <summary>
///// 检索品名分类参数
///// </summary>
///// <param name="queryItem">检索值</param>
///// <returns>返回回执</returns>
//public async Task<CommonWebApiResult> QueryParaGoodsCategoryInfo(string queryItem)
//{
// CommonWebApiResult result = new CommonWebApiResult();
// return result;
//}
///// <summary>
///// 保存约号参数
///// </summary>
///// <param name="model">约号参数</param>
///// <returns>返回回执</returns>
//public async Task<CommonWebApiResult> SaveParaContractNoInfo(ParaGoodsCategoryDto model)
//{
// CommonWebApiResult result = new CommonWebApiResult();
// return result;
//}
///// <summary>
///// 主键获取约号参数
///// </summary>
///// <param name="Id">约号主键</param>
///// <returns>返回回执</returns>
//public async Task<CommonWebApiResult> GetParaContractNoInfo(long Id)
//{
// CommonWebApiResult result = new CommonWebApiResult();
// return result;
//}
///// <summary>
///// 检索约号参数
///// </summary>
///// <param name="queryItem">检索值</param>
///// <returns>返回回执</returns>
//public async Task<CommonWebApiResult> QuerytParaContractNoInfo(string queryItem)
//{
// CommonWebApiResult result = new CommonWebApiResult();
// return result;
//}
/// <summary>
/// 保存品名分类参数
/// </summary>
/// <param name="model">品名分类参数</param>
/// <returns>返回回执</returns>
[HttpPost("/Para/SaveParaGoodsCategoryInfo")]
public async Task<long> SaveParaGoodsCategoryInfo(ParaGoodsCategoryDto model)
{
ParaGoodsCategoryInfo info = null;
try
{
////判断代码不能重复
//var sameList = _paraGoodsCategoryInfoRepository.AsQueryable()
// .Where(t => t.GOODS_CATEGORY.Equals(model.GoodsCategory, StringComparison.OrdinalIgnoreCase)).ToList();
//if (sameList.Count > 0 && !string.IsNullOrWhiteSpace(model.Id) && sameList.Any(t => t.Id != long.Parse(model.Id)))
// throw Oops.Oh($"商品分类代码【{model.GoodsCategory}】已存在不能重复保存");
if (!string.IsNullOrWhiteSpace(model.Id))
{
info = await _paraGoodsCategoryInfoRepository.AsQueryable().FirstAsync(t => t.Id == long.Parse(model.Id));
//如果填写了品名分配需要确认根据库中数据一致
if (!info.GOODS_CATEGORY.Equals(model.GoodsCategory, StringComparison.OrdinalIgnoreCase))
{
var existsList = _paraGoodsCategoryInfoRepository.AsQueryable()
.LeftJoin(_paraGoodsInfoRepository.AsQueryable(), (cate, goods) => cate.GOODS_CATEGORY == goods.GOODS_CATEGORY)
.Where(cate => cate.Id == info.Id)
.Select((cate, goods) => new { Cate = cate, Goods = goods }).ToList();
if (existsList.Any(t => t.Goods != null))
throw Oops.Oh($"原分类代码{info.GOODS_CATEGORY}已有对应品名参数,不能修改");
}
info.GOODS_CATEGORY = model.GoodsCategory;
info.GOODS_CATEGORY_NAME = model.GoodsCategoryName;
await _paraGoodsCategoryInfoRepository.AsUpdateable(info).IgnoreColumns(it => new
{
it.Id,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName
}).ExecuteCommandAsync();
}
else
{
info = model.Adapt<ParaGoodsCategoryInfo>();
await _paraGoodsCategoryInfoRepository.InsertAsync(info);
}
}
catch (Exception ex)
{
throw Oops.Bah($"保存品名分类参数异常,{ex.Message}");
}
return info.Id;
}
/// <summary>
/// 主键获取品名分类参数
/// </summary>
/// <param name="Id">品名分类主键</param>
/// <returns>返回回执</returns>
[HttpGet("/Para/GetParaGoodsCategoryInfo")]
public async Task<ParaGoodsCategoryDto> GetParaGoodsCategoryInfo(long Id)
{
ParaGoodsCategoryDto model = null;
try
{
ParaGoodsCategoryInfo info = _paraGoodsCategoryInfoRepository.AsQueryable().First(t => t.Id == Id);
if (info == null)
throw Oops.Oh($"获取品名分类参数失败");
model = info.Adapt<ParaGoodsCategoryDto>();
}
catch (Exception ex)
{
throw Oops.Bah($"获取品名分类参数异常,{ex.Message}");
}
return model;
}
/// <summary>
/// 检索品名分类参数
/// </summary>
/// <param name="queryItem">检索值</param>
/// <param name="top">默认最大行数</param>
/// <returns>返回回执</returns>
[HttpGet("/Para/QueryParaGoodsCategoryInfo")]
public async Task<List<ParaGoodsCategoryDto>> QueryParaGoodsCategoryInfo([FromQuery] string queryItem, [FromQuery] int top = 10)
{
List<ParaGoodsCategoryDto> list = new List<ParaGoodsCategoryDto>();
try
{
var query = _paraGoodsCategoryInfoRepository.AsQueryable();
if (!string.IsNullOrWhiteSpace(queryItem))
{
query = query.Where(t =>
t.GOODS_CATEGORY.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
t.GOODS_CATEGORY_NAME.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase)
);
}
query = query.OrderBy("GOODS_CATEGORY asc");
var currList = await query.Take(top).ToListAsync();
if (currList.Count > 0)
list = currList.Select(t => t.Adapt<ParaGoodsCategoryDto>()).ToList();
}
catch (Exception ex)
{
throw Oops.Bah($"保存品名参数异常,{ex.Message}");
}
return list;
}
/// <summary>
/// 作废品名分类参数
/// </summary>
/// <param name="Ids">品名分类参数主键数组</param>
/// <returns>返回回执</returns>
[HttpPost("/Para/DeleteParaGoodsCategoryInfo")]
public async Task<string> DeleteParaGoodsCategoryInfo(long[] Ids)
{
try
{
//如果没有给主键直接抛异常
if (Ids.Length == 0)
throw Oops.Oh("没有提供需要作废的主键信息");
var list = _paraGoodsCategoryInfoRepository.AsQueryable().Where(t => Ids.Contains(t.Id)).ToList();
if (list.Count != Ids.Length)
{
var noRecord = string.Join(",", Ids.GroupJoin(list, l => l, r => r.Id, (l, r) => {
var currList = r.ToList();
if (r.Count() > 0)
return string.Empty;
return l.ToString();
}).Where(t => !string.IsNullOrWhiteSpace(t)).ToArray());
throw Oops.Oh($"以下主键信息 {noRecord} 检索失败或者已作废过");
}
//这里需要判断当前的品名分类是否已经对应到品名上,如果已有对应则不能直接作废
var existsList = _paraGoodsCategoryInfoRepository.AsQueryable()
.LeftJoin(_paraGoodsInfoRepository.AsQueryable(),(cate, goods) => cate.GOODS_CATEGORY == goods.GOODS_CATEGORY)
.Where(cate => Ids.Contains(cate.Id))
.Select((cate, goods) => new { Cate = cate, Goods = goods }).ToList();
if(existsList.Any(t=>t.Goods != null))
throw Oops.Oh($"以下分类代码已指定品名参数不能直接删除,{string.Join(",",existsList.Select(t=>t.Cate.GOODS_CATEGORY).Distinct().ToArray())}");
list.ForEach(async entity =>
{
entity.IsDeleted = true;
entity.UpdatedTime = DateTime.Now;
entity.UpdatedUserId = UserManager.UserId;
entity.UpdatedUserName = UserManager.Name;
await _paraGoodsCategoryInfoRepository.AsUpdateable(entity).IgnoreColumns(it => new
{
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName
}).ExecuteCommandAsync();
});
}
catch (Exception ex)
{
throw Oops.Bah($"作废品名参数异常,{ex.Message}");
}
return "作废成功";
}
#region 品名分类参数台账查询
/// <summary>
/// 品名分类参数台账查询
/// </summary>
/// <param name="QuerySearch">品名分类参数台账查询请求</param>
/// <returns>返回结果</returns>
[HttpPost("/Para/GetParaGoodsCategoryPage")]
public async Task<dynamic> GetParaGoodsCategoryPageAsync(QueryParaGoodsCategoryDto QuerySearch)
{
DateTime createBegin = DateTime.MinValue;
DateTime createEnd = DateTime.MinValue;
DateTime updateBegin = DateTime.MinValue;
DateTime updateEnd = DateTime.MinValue;
if (!string.IsNullOrWhiteSpace(QuerySearch.CreateTimeBegin))
{
if (!DateTime.TryParse(QuerySearch.CreateTimeBegin, out createBegin))
throw Oops.Oh($"创建开始日期格式错误,{QuerySearch.CreateTimeBegin}");
}
if (!string.IsNullOrWhiteSpace(QuerySearch.CreateTimeEnd))
{
if (!DateTime.TryParse(QuerySearch.CreateTimeEnd, out createEnd))
throw Oops.Oh($"创建结束日期格式错误,{QuerySearch.CreateTimeEnd}");
createEnd = createEnd.AddDays(1);
}
if (!string.IsNullOrWhiteSpace(QuerySearch.UpdateTimeBegin))
{
if (!DateTime.TryParse(QuerySearch.UpdateTimeBegin, out updateBegin))
throw Oops.Oh($"更新起始日期格式错误,{QuerySearch.UpdateTimeBegin}");
}
if (!string.IsNullOrWhiteSpace(QuerySearch.UpdateTimeEnd))
{
if (!DateTime.TryParse(QuerySearch.UpdateTimeEnd, out updateEnd))
throw Oops.Oh($"更新结束日期格式错误,{QuerySearch.UpdateTimeEnd}");
updateEnd = updateEnd.AddDays(1);
}
string entityOrderCol = "CreatedTime";
//这里因为返回给前端的台账数据是DTO所以这里排序时候需要转换成Entity对应的字段
if (!string.IsNullOrWhiteSpace(QuerySearch.SortField))
entityOrderCol = MapsterExtHelper.GetAdaptProperty<ParaGoodsCategoryDto, ParaGoodsCategoryInfo>(QuerySearch.SortField);
var entities = await _paraGoodsCategoryInfoRepository.AsQueryable().Filter(null, true)
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.GoodsCategory), t => t.GOODS_CATEGORY.Contains(QuerySearch.GoodsCategory.Trim(), StringComparison.OrdinalIgnoreCase))
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.GoodsCategoryName), t => t.GOODS_CATEGORY_NAME.Contains(QuerySearch.GoodsCategoryName.Trim(), StringComparison.OrdinalIgnoreCase))
.WhereIF(createBegin != DateTime.MinValue, t => t.CreatedTime.HasValue && t.CreatedTime.Value >= createBegin)
.WhereIF(createEnd != DateTime.MinValue, t => t.CreatedTime.HasValue && t.CreatedTime.Value < createEnd)
.WhereIF(updateBegin != DateTime.MinValue, t => t.UpdatedTime.HasValue && t.UpdatedTime.Value >= updateBegin)
.WhereIF(updateEnd != DateTime.MinValue, t => t.UpdatedTime.HasValue && t.UpdatedTime.Value < updateEnd)
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.CreateUserName), t => t.CreatedUserName.Contains(QuerySearch.CreateUserName.Trim(), StringComparison.OrdinalIgnoreCase))
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.UpdateUserName), t => t.UpdatedUserName.Contains(QuerySearch.UpdateUserName.Trim(), StringComparison.OrdinalIgnoreCase))
.OrderBy(entityOrderCol + (QuerySearch.descSort ? " asc " : " desc "))
.ToPagedListAsync(QuerySearch.PageNo, QuerySearch.PageSize);
return new
{
PageNo = entities.PageIndex,
PageSize = entities.PageSize,
TotalPage = entities.TotalPages,
TotalRows = entities.TotalCount,
Rows = entities.Items.Select(t => t.Adapt<ParaGoodsCategoryDto>()).ToList()
};
}
#endregion
#region 保存约号参数
/// <summary>
/// 保存约号参数
/// </summary>
/// <param name="model">约号参数</param>
/// <returns>返回回执</returns>
[HttpPost("/Para/SaveParaContractNoInfo")]
public async Task<long> SaveParaContractNoInfo(ParaContractNoDto model)
{
ParaContractNoInfo info = null;
try
{
//判断代码不能重复
var sameList = _paraContractNoInfoRepository.AsQueryable()
.Where(t => t.CONTRACT_NO.Equals(model.ContractNo, StringComparison.OrdinalIgnoreCase)).ToList();
if (sameList.Count > 0 && !string.IsNullOrWhiteSpace(model.Id) && sameList.Any(t => t.Id != long.Parse(model.Id)))
throw Oops.Oh($"合约号编号【{model.ContractNo}】已存在不能重复保存");
if (!string.IsNullOrWhiteSpace(model.Id))
{
info = await _paraContractNoInfoRepository.AsQueryable().FirstAsync(t => t.Id == long.Parse(model.Id));
info.CONTRACT_NO = model.ContractNo;
info.CONTRACT_NAME = model.ContractName;
info.CONTRACT_NAME = model.ContractName;
await _paraContractNoInfoRepository.AsUpdateable(info).IgnoreColumns(it => new
{
it.Id,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName
}).ExecuteCommandAsync();
}
else
{
info = model.Adapt<ParaContractNoInfo>();
await _paraContractNoInfoRepository.InsertAsync(info);
}
}
catch (Exception ex)
{
throw Oops.Bah($"保存约号参数异常,{ex.Message}");
}
return info.Id;
}
#endregion
#region 主键获取约号参数
/// <summary>
/// 主键获取约号参数
/// </summary>
/// <param name="Id">约号主键</param>
/// <returns>返回回执</returns>
[HttpGet("/Para/GetParaContractNoInfo")]
public async Task<ParaContractNoDto> GetParaContractNoInfo(long Id)
{
ParaContractNoDto model = null;
try
{
ParaContractNoInfo info = _paraContractNoInfoRepository.AsQueryable().First(t => t.Id == Id);
if (info == null)
throw Oops.Oh($"获取约号参数失败");
model = info.Adapt<ParaContractNoDto>();
}
catch (Exception ex)
{
throw Oops.Bah($"获取约号参数异常,{ex.Message}");
}
return model;
}
#endregion
#region 检索约号参数
/// <summary>
/// 检索约号参数
/// </summary>
/// <param name="queryItem">检索值</param>
/// <param name="top">默认最大行数</param>
/// <returns>返回回执</returns>
[HttpGet("/Para/QuerytParaContractNoInfo")]
public async Task<List<ParaContractNoDto>> QuerytParaContractNoInfo([FromQuery] string queryItem, [FromQuery] int top = 10)
{
List<ParaContractNoDto> list = new List<ParaContractNoDto>();
try
{
var query = _paraContractNoInfoRepository.AsQueryable();
if (!string.IsNullOrWhiteSpace(queryItem))
{
query = query.Where(t =>
t.CONTRACT_NO.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
t.CONTRACT_NAME.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
t.CONTRACT_NOTE.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase)
);
}
query = query.OrderBy("CONTRACT_NO asc");
var currList = await query.Take(top).ToListAsync();
if (currList.Count > 0)
list = currList.Select(t => t.Adapt<ParaContractNoDto>()).ToList();
}
catch (Exception ex)
{
throw Oops.Bah($"检索约号参数异常,{ex.Message}");
}
return list;
}
#endregion
#region 作废约号参数
/// <summary>
/// 作废约号参数
/// </summary>
/// <param name="Ids">约号参数主键数组</param>
/// <returns>返回回执</returns>
[HttpPost("/Para/DeleteParaContractNoInfo")]
public async Task<string> DeleteParaContractNoInfo(long[] Ids)
{
try
{
//如果没有给主键直接抛异常
if (Ids.Length == 0)
throw Oops.Oh("没有提供需要作废的主键信息");
var list = _paraContractNoInfoRepository.AsQueryable().Where(t => Ids.Contains(t.Id)).ToList();
if (list.Count != Ids.Length)
{
var noRecord = string.Join(",", Ids.GroupJoin(list, l => l, r => r.Id, (l, r) => {
var currList = r.ToList();
if (r.Count() > 0)
return string.Empty;
return l.ToString();
}).Where(t => !string.IsNullOrWhiteSpace(t)).ToArray());
throw Oops.Oh($"以下主键信息 {noRecord} 检索失败或者已作废过");
}
list.ForEach(async entity =>
{
entity.IsDeleted = true;
entity.UpdatedTime = DateTime.Now;
entity.UpdatedUserId = UserManager.UserId;
entity.UpdatedUserName = UserManager.Name;
await _paraContractNoInfoRepository.AsUpdateable(entity).IgnoreColumns(it => new
{
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName
}).ExecuteCommandAsync();
});
}
catch (Exception ex)
{
throw Oops.Bah($"作废约号参数异常,{ex.Message}");
}
return "作废成功";
}
#endregion
#region 约号参数台账查询
/// <summary>
/// 约号参数台账查询
/// </summary>
/// <param name="QuerySearch">约号参数台账查询请求</param>
/// <returns>返回结果</returns>
[HttpPost("/Para/GetParaContractNoPage")]
public async Task<dynamic> GetParaContractNoPageAsync(QueryParaContractNoDto QuerySearch)
{
DateTime createBegin = DateTime.MinValue;
DateTime createEnd = DateTime.MinValue;
DateTime updateBegin = DateTime.MinValue;
DateTime updateEnd = DateTime.MinValue;
if (!string.IsNullOrWhiteSpace(QuerySearch.CreateTimeBegin))
{
if (!DateTime.TryParse(QuerySearch.CreateTimeBegin, out createBegin))
throw Oops.Oh($"创建开始日期格式错误,{QuerySearch.CreateTimeBegin}");
}
if (!string.IsNullOrWhiteSpace(QuerySearch.CreateTimeEnd))
{
if (!DateTime.TryParse(QuerySearch.CreateTimeEnd, out createEnd))
throw Oops.Oh($"创建结束日期格式错误,{QuerySearch.CreateTimeEnd}");
createEnd = createEnd.AddDays(1);
}
if (!string.IsNullOrWhiteSpace(QuerySearch.UpdateTimeBegin))
{
if (!DateTime.TryParse(QuerySearch.UpdateTimeBegin, out updateBegin))
throw Oops.Oh($"更新起始日期格式错误,{QuerySearch.UpdateTimeBegin}");
}
if (!string.IsNullOrWhiteSpace(QuerySearch.UpdateTimeEnd))
{
if (!DateTime.TryParse(QuerySearch.UpdateTimeEnd, out updateEnd))
throw Oops.Oh($"更新结束日期格式错误,{QuerySearch.UpdateTimeEnd}");
updateEnd = updateEnd.AddDays(1);
}
string entityOrderCol = "CreatedTime";
//这里因为返回给前端的台账数据是DTO所以这里排序时候需要转换成Entity对应的字段
if (!string.IsNullOrWhiteSpace(QuerySearch.SortField))
entityOrderCol = MapsterExtHelper.GetAdaptProperty<ParaContractNoDto, ParaContractNoInfo>(QuerySearch.SortField);
var entities = await _paraContractNoInfoRepository.AsQueryable().Filter(null, true)
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.ContractNo), t => t.CONTRACT_NO.Contains(QuerySearch.ContractNo.Trim(), StringComparison.OrdinalIgnoreCase))
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.ContractName), t => t.CONTRACT_NAME.Contains(QuerySearch.ContractName.Trim(), StringComparison.OrdinalIgnoreCase))
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.ContractNote), t => t.CONTRACT_NOTE.Contains(QuerySearch.ContractNote.Trim(), StringComparison.OrdinalIgnoreCase))
.WhereIF(createBegin != DateTime.MinValue, t => t.CreatedTime.HasValue && t.CreatedTime.Value >= createBegin)
.WhereIF(createEnd != DateTime.MinValue, t => t.CreatedTime.HasValue && t.CreatedTime.Value < createEnd)
.WhereIF(updateBegin != DateTime.MinValue, t => t.UpdatedTime.HasValue && t.UpdatedTime.Value >= updateBegin)
.WhereIF(updateEnd != DateTime.MinValue, t => t.UpdatedTime.HasValue && t.UpdatedTime.Value < updateEnd)
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.CreateUserName), t => t.CreatedUserName.Contains(QuerySearch.CreateUserName.Trim(), StringComparison.OrdinalIgnoreCase))
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.UpdateUserName), t => t.UpdatedUserName.Contains(QuerySearch.UpdateUserName.Trim(), StringComparison.OrdinalIgnoreCase))
.OrderBy(entityOrderCol + (QuerySearch.descSort ? " asc " : " desc "))
.ToPagedListAsync(QuerySearch.PageNo, QuerySearch.PageSize);
return new
{
PageNo = entities.PageIndex,
PageSize = entities.PageSize,
TotalPage = entities.TotalPages,
TotalRows = entities.TotalCount,
Rows = entities.Items.Select(t => t.Adapt<ParaContractNoDto>()).ToList()
};
}
#endregion
}
}

@ -40,5 +40,13 @@ namespace Myshipping.Application
/// <param name="QuerySearch">任务台账查询请求</param>
/// <returns>返回结果</returns>
Task<dynamic> GetPageAsync(QueryTaskManageDto QuerySearch);
/// <summary>
/// 下载正本提单
/// </summary>
/// <param name="PKIds">任务主键数组</param>
/// <returns>返回结果</returns>
Task<TaskManageOrderResultDto> DownloadOriginalTask(string[] PKIds);
}
}

@ -2,6 +2,7 @@
using Furion.DistributedIDGenerator;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Furion.JsonSerialization;
using Furion.RemoteRequest;
using Mapster;
using Microsoft.AspNetCore.Authorization;
@ -13,6 +14,7 @@ using Myshipping.Application.Entity;
using Myshipping.Application.Helper;
using Myshipping.Core;
using Myshipping.Core.Entity;
using Myshipping.Core.Service;
using MySqlX.XDevAPI.Common;
using NPOI.SS.Formula.Functions;
using SqlSugar;
@ -43,10 +45,13 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<TaskVGMFeedBackInfo> _taskVGMFeedBackInfoRepository;
private readonly SqlSugarRepository<SysUser> _sysUserRepository;
private readonly SqlSugarRepository<TaskStatManageInfo> _taskStatManageInfoRepository;
private readonly SqlSugarRepository<TaskOriginalDownloadHisInfo> _taskOriginalDownloadHisInfoRepository;
private readonly IDjyWebsiteAccountConfigService _webAccountConfig;
private readonly ILogger<BookingOrderService> _logger;
const string CONST_WEB_ACCOUNT_TYPE = "CmaWeb";
public TaskManageService(SqlSugarRepository<TaskBaseInfo> taskBaseInfoRepository,
SqlSugarRepository<TaskSIFeedBackInfo> taskSIFeedBackInfoRepository,
SqlSugarRepository<TaskSIFeedBackContaInfo> taskSIFeedBackContaInfoRepository,
@ -56,6 +61,8 @@ namespace Myshipping.Application
SqlSugarRepository<TaskVGMFeedBackInfo> taskVGMFeedBackInfoRepository,
SqlSugarRepository<SysUser> sysUserRepository,
SqlSugarRepository<TaskStatManageInfo> taskStatManageInfoRepository,
SqlSugarRepository<TaskOriginalDownloadHisInfo> taskOriginalDownloadHisInfoRepository,
IDjyWebsiteAccountConfigService webAccountConfig,
ILogger<BookingOrderService> logger)
{
_taskBaseInfoRepository = taskBaseInfoRepository;
@ -67,6 +74,8 @@ namespace Myshipping.Application
_taskVGMFeedBackInfoRepository = taskVGMFeedBackInfoRepository;
_sysUserRepository = sysUserRepository;
_taskStatManageInfoRepository = taskStatManageInfoRepository;
_taskOriginalDownloadHisInfoRepository = taskOriginalDownloadHisInfoRepository;
_webAccountConfig = webAccountConfig;
_logger = logger;
}
@ -611,5 +620,107 @@ namespace Myshipping.Application
Rows = entities.Items.Select(t => t.Adapt<TaskBaseInfoDto>()).ToList()
};
}
#region 下载正本提单(可批量)
/// <summary>
/// 下载正本提单(可批量)
/// </summary>
/// <param name="PKIds">任务主键数组</param>
/// <returns>返回结果</returns>
[HttpPost("/TaskManage/DownloadOriginalTask")]
public async Task<TaskManageOrderResultDto> DownloadOriginalTask(string[] PKIds)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
try
{
var taskList = _taskBaseInfoRepository.AsQueryable().Where(t => PKIds.Contains(t.PK_ID)).ToList();
//获取个人对应的账户,这里GetAccountConfig逻辑优先取个人个人没有配置取公司对应配置
var userWebAccountConfig = _webAccountConfig.GetAccountConfig(CONST_WEB_ACCOUNT_TYPE, UserManager.UserId).GetAwaiter().GetResult();
if (userWebAccountConfig == null)
throw Oops.Bah($"个人/公司网站【{CONST_WEB_ACCOUNT_TYPE}】获取失败,请维护个人/公司网站账户信息");
taskList.ForEach(async tsk => {
await InnerDownloadOriginalTask(tsk, userWebAccountConfig);
});
}
catch (Exception ex)
{
throw Oops.Bah($"下载正本提单异常,{0}", ex.Message);
}
return result;
}
#endregion
private async Task<TaskManageOrderResultDto> InnerDownloadOriginalTask(TaskBaseInfo taskBaseInfo, DjyWebsiteAccountConfig webAccountConfig)
{
var result = new TaskManageOrderResultDto();
/*
1TaskOriginalDownloadHisInfosucc/tempfailure/timeout
2RESULT_NOTEJSON {"pageUrl":"http://www.cnc-ebusiness.com/ebusiness/bl/detail/AASM104300"}
3
4
*/
//正本下载URL
string originalUrl = string.Empty;
try
{
var hisList = _taskOriginalDownloadHisInfoRepository
.Where(t => t.TASK_ID == taskBaseInfo.PK_ID).ToList();
if (hisList.Any(t => new string[] { "succ", "temp" }.Contains(t.STATUS)))
throw Oops.Bah("下载URL不存在请用最新任务数据");
if (string.IsNullOrWhiteSpace(taskBaseInfo.RESULT_NOTE))
throw Oops.Bah("下载URL不存在请用最新任务数据");
var resultObj = JSON.Deserialize<dynamic>(taskBaseInfo.RESULT_NOTE);
originalUrl = resultObj.pageUrl.ToString();
if (string.IsNullOrWhiteSpace(originalUrl))
throw Oops.Bah("解析下载URL不存在请用最新任务数据");
DateTime startDate = DateTime.Now;
TaskOriginalDownloadHisInfo taskOriginalDownloadHisInfo = new TaskOriginalDownloadHisInfo
{
PK_ID = IDGen.NextID().ToString(),
TASK_ID = taskBaseInfo.PK_ID,
REQUEST_URL = originalUrl,
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name,
STATUS = "temp",
IS_TIMEOUT = 0,
START_DATE = startDate,
TenantId = UserManager.TENANT_ID,
TenantName = UserManager.TENANT_NAME
};
//写入记录
_taskOriginalDownloadHisInfoRepository.Insert(taskOriginalDownloadHisInfo);
}
catch (Exception ex)
{
result.succ = false;
result.msg = ex.Message;
}
return result;
}
//private async Task<TaskManageOrderResultDto> Inner
}
}

Loading…
Cancel
Save