# Conflicts:
#	Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
optimize
wet 2 years ago
commit f6d10a9a52

@ -18,7 +18,7 @@ namespace Myshipping.Application.Entity
/// <summary>
/// 类型
/// </summary>
public BookingTemplateType Type { get; set; }
public string Type { get; set; }
/// <summary>
/// 模板内容
/// </summary>

@ -4816,11 +4816,12 @@
<param name="bookingId"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Application.BookingOrderService.LetterYardPdf(System.Int64)">
<member name="M:Myshipping.Application.BookingOrderService.LetterYardPdf(System.Int64,System.Int32)">
<summary>
获取放舱pdf
</summary>
<param name="bookingId"></param>
<param name="type">类型1pdf、2xlsx、3docx</param>
<returns></returns>
</member>
<member name="M:Myshipping.Application.BookingOrderService.LetterYardXlsx(System.Int64)">

@ -721,17 +721,18 @@ namespace Myshipping.Application
[HttpPost("/BookingOrder/AddRemark")]
public async Task AddRemark(BookingRemarkDto dto)
{
if (dto.Id==0)
if (dto.Id == 0)
{
var entity = dto.Adapt<BookingRemark>();
await _bookingremark.InsertAsync(entity);
}
else {
var entity= _bookingremark.FirstOrDefault(x => x.Id == dto.Id);
entity.Remark = dto.Remark;
await _bookingremark.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
else
{
var entity = _bookingremark.FirstOrDefault(x => x.Id == dto.Id);
entity.Remark = dto.Remark;
await _bookingremark.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
}
/// <summary>
@ -875,7 +876,7 @@ namespace Myshipping.Application
/// 调用运踪接口
/// </summary>
[HttpGet("/BookingOrder/SendTrace")]
public async Task SendTrace(string BusinessId, string YARDID, string YARD, string MBLNO,string CARRIER="",string CARRIERID="",bool isbook=false)
public async Task SendTrace(string BusinessId, string YARDID, string YARD, string MBLNO, string CARRIER = "", string CARRIERID = "", bool isbook = false)
{
_logger.LogInformation("调用运踪接口提单号:" + MBLNO + " 调用运踪接口");
var key = _webAccountConfig.GetAccountConfig("seae_billtraceurl", UserManager.UserId).Result;
@ -945,7 +946,7 @@ namespace Myshipping.Application
Code = t.Code,
Value = t.Value
}).ToListAsync();
#region 订舱状态
if (item.Status == "舱单")
{
@ -1007,7 +1008,7 @@ namespace Myshipping.Application
bookingStatus.BookingId = item.BookingId;
bookingStatus.StaCode = "sta_zhuangchuan";
bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_zhuangchuan").Select(x => x.Value).FirstOrDefault();
bookingStatus.StaTime = item.detail.Max(x=>x.OPTime);
bookingStatus.StaTime = item.detail.Max(x => x.OPTime);
bookingStatus.StaCate = "book_sta_cate_billtrace";
await _repBookingStatus.InsertAsync(bookingStatus);
}
@ -1272,17 +1273,37 @@ namespace Myshipping.Application
/// 获取放舱pdf
/// </summary>
/// <param name="bookingId"></param>
/// <param name="type">类型1pdf、2xlsx、3docx</param>
/// <returns></returns>
[HttpGet("/BookingOrder/LetterYardPdf")]
public async Task<IActionResult> LetterYardPdf(long bookingId)
public async Task<IActionResult> LetterYardPdf(long bookingId, int type = 1)
{
var letterYard = await _repLetterYard.FirstOrDefaultAsync(x => x.BookingId == bookingId);
if (letterYard == null)
{
throw Oops.Bah("放舱信息未找到,请先保存数据");
}
var bs = await GetReportFile(bookingId, "fangcang", 1);
var fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}.pdf", Encoding.GetEncoding("UTF-8"));
var fileType = "";
if (type == 1)
{
fileType = ".pdf";
}
else if (type == 2)
{
fileType = ".xlsx";
}
else if (type == 3)
{
fileType = ".docx";
}
else
{
throw Oops.Bah("类型参数不正确");
}
var bs = await GetReportFile(bookingId, "fangcang", type);
var fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}{fileType}", Encoding.GetEncoding("UTF-8"));
var result = new FileContentResult(bs, "application/octet-stream") { FileDownloadName = fileName };
return result;
@ -1409,16 +1430,18 @@ namespace Myshipping.Application
{
throw Oops.Bah("类型参数不正确");
}
var mblno= await _rep.AsQueryable().Where(x=>x.Id==bookingId).Select(x=>x.MBLNO).FirstAsync();
var typeObj = (await _cache.GetAllDictData()).First(x => x.TypeCode == "booking_template_type" && x.Code == typeCode);
var mblno = await _rep.AsQueryable().Where(x => x.Id == bookingId).Select(x => x.MBLNO).FirstAsync();
string fileName = string.Empty;
if (string.IsNullOrWhiteSpace(mblno))
{
fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}.{fileType}", Encoding.GetEncoding("UTF-8"));////名称
fileName = $"{bookingId}_{typeObj.Value.ValidFileName()}_{DateTime.Now.Ticks}{fileType}";////名称
}
else {
fileName = HttpUtility.UrlEncode($"{mblno}_{DateTime.Now.Ticks}.{fileType}", Encoding.GetEncoding("UTF-8"));////名称
else
{
fileName = $"{mblno}_{typeObj.Value.ValidFileName()}_{DateTime.Now.Ticks}{fileType}";////名称
}
//var result = new FileContentResult(bs, "application/octet-stream") { FileDownloadName = fileName };
var opt = App.GetOptions<TempFileOptions>().Path;
@ -1701,7 +1724,7 @@ namespace Myshipping.Application
var yardset = _cache.GetAllMappingYard().Result.FirstOrDefault(y => y.Code == order.YARDID && y.Module == "BookingTxxp");
if (yardset == null)
{
throw Oops.Bah(BookingErrorCode.BOOK120, order.YARDID);
throw Oops.Bah(BookingErrorCode.BOOK120, $"{order.YARDID}(提箱小票)");
}
var ctns = await _repCtn.Where(x => x.BILLID == bookingId).ToListAsync();
@ -1722,7 +1745,7 @@ namespace Myshipping.Application
var expCode = ctns.Select(x => x.CTNCODE).Distinct().Except(ctnMapping.Select(y => y.Code)).ToList();
if (expCode.Count > 0)
{
throw Oops.Bah(BookingErrorCode.BOOK123, string.Join(',', expCode));
throw Oops.Bah(BookingErrorCode.BOOK123, $"{string.Join(',', expCode)}(提箱小票)");
}
var user = await _repUser.FirstOrDefaultAsync(x => x.Id == UserManager.UserId);
@ -1845,7 +1868,7 @@ namespace Myshipping.Application
var yardset = _cache.GetAllMappingYard().Result.FirstOrDefault(y => y.Code == order.YARDID && y.Module == "BookingVgm");
if (yardset == null)
{
throw Oops.Bah(BookingErrorCode.BOOK120, order.YARDID);
throw Oops.Bah(BookingErrorCode.BOOK120, $"{order.YARDID}(VGM)");
}
//校验箱子数据录入
@ -1857,15 +1880,15 @@ namespace Myshipping.Application
//箱型映射
var ctnMapping = await _cache.GetAllMappingCtn();
ctnMapping = ctnMapping.Where(x => x.Module == "BookingVgm").ToList();
if (ctnMapping.Count == 0)
{
throw Oops.Bah(BookingErrorCode.BOOK122);
}
//if (ctnMapping.Count == 0)
//{
// throw Oops.Bah(BookingErrorCode.BOOK122);
//}
var expCode = ctns.Select(x => x.CTNCODE).Distinct().Except(ctnMapping.Select(y => y.Code)).ToList();
if (expCode.Count > 0)
{
throw Oops.Bah(BookingErrorCode.BOOK123, string.Join(',', expCode));
throw Oops.Bah(BookingErrorCode.BOOK123, $"{string.Join(',', expCode)}(VGM)");
}
//接收反馈地址
@ -2497,7 +2520,9 @@ namespace Myshipping.Application
await _bookingfile.InsertAsync(bookFile);
}
#region 下载订舱、截单EDI
/// <summary>
/// 下载订舱、截单EDI

@ -39,7 +39,7 @@ namespace Myshipping.Application
var entities = await _rep.AsQueryable()
.Where(m => m.CreatedUserId == UserManager.UserId)
.WhereIF(!string.IsNullOrEmpty(input.Title), u => u.Title.Contains(input.Title))
.WhereIF(input.Type.HasValue, u => u.Type == input.Type)
.WhereIF(!string.IsNullOrEmpty(input.Type), u =>u.Type.Contains(input.Type))
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities.XnPagedResult();
}
@ -52,7 +52,7 @@ namespace Myshipping.Application
[HttpPost("/BookingTemplate/add")]
public async Task Add(AddBookingTemplateInput input)
{
var c = _rep.Count(x => x.Type == input.Type && x.Title == input.Title);
var c = _rep.Count(x => x.Type.Contains(input.Type) && x.Title == input.Title);
if (c > 0)
{
throw Oops.Oh(BookingErrorCode.BOOK101);

@ -17,7 +17,7 @@ namespace Myshipping.Application
/// <summary>
/// 类型
/// </summary>
public virtual BookingTemplateType Type { get; set; }
public virtual string Type { get; set; }
/// <summary>
/// 模板内容
@ -91,7 +91,7 @@ namespace Myshipping.Application
/// <summary>
/// 类型
/// </summary>
public virtual BookingTemplateType? Type { get; set; }
public virtual string Type { get; set; }
/// <summary>
/// 模板内容

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Core
{
public static class StringExtentions
{
/// <summary>
/// 处理文件名称
/// </summary>
/// <param name="fn">文件名</param>
/// <returns>返回合法的文件名</returns>
public static string ValidFileName(this string fn)
{
char[] strs = "+#?*\"<>/;,-:%~".ToCharArray();
foreach (char c in strs)
fn = fn.Replace(c.ToString(), "_");
strs = ":,。;?".ToCharArray();
foreach (char c in strs)
fn = fn.Replace(c.ToString(), "_");
//去掉空格.
while (fn.Contains(" ") == true)
fn = fn.Replace(" ", "");
//替换特殊字符.
fn = fn.Replace("\t\n", "");
//处理合法的文件名.
StringBuilder rBuilder = new StringBuilder(fn);
foreach (char rInvalidChar in Path.GetInvalidFileNameChars())
rBuilder.Replace(rInvalidChar.ToString(), string.Empty);
fn = rBuilder.ToString();
fn = fn.Replace("__", "_");
fn = fn.Replace("__", "_");
fn = fn.Replace("__", "_");
fn = fn.Replace("__", "_");
fn = fn.Replace("__", "_");
fn = fn.Replace("__", "_");
fn = fn.Replace("__", "_");
fn = fn.Replace("__", "_");
fn = fn.Replace(" ", "");
fn = fn.Replace(" ", "");
fn = fn.Replace(" ", "");
fn = fn.Replace(" ", "");
fn = fn.Replace(" ", "");
fn = fn.Replace(" ", "");
fn = fn.Replace(" ", "");
fn = fn.Replace(" ", "");
if (fn.Length > 240)
fn = fn.Substring(0, 240);
return fn;
}
}
}

@ -5216,6 +5216,13 @@
时间戳
</summary>
</member>
<member name="M:Myshipping.Core.StringExtentions.ValidFileName(System.String)">
<summary>
处理文件名称
</summary>
<param name="fn">文件名</param>
<returns>返回合法的文件名</returns>
</member>
<member name="T:Myshipping.Core.LogExceptionHandler">
<summary>
全局异常处理

Loading…
Cancel
Save