新增BC舱位比对结果表

optimize
jianghaiqing 10 months ago
parent 4eea3be5ec
commit 5efcd92d56

@ -0,0 +1,53 @@
using Myshipping.Core.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 舱位变更比对记录表
/// </summary>
[SugarTable("booking_slot_compare", TableDescription = "舱位变更比对记录表")]
public class BookingSlotCompare : DBEntityTenant
{
/// <summary>
/// 舱位主键
/// </summary>
[SugarColumn(ColumnName = "SLOT_ID")]
[Description("舱位主键")]
public long SLOT_ID { get; set; }
/// <summary>
/// 打印时间
/// </summary>
[SugarColumn(ColumnName = "PRINT_DATE")]
[Description("打印时间")]
public Nullable<DateTime> PRINT_DATE { get; set; }
/// <summary>
/// 比对类型 BC_MODIFY-BC变更比对
/// </summary>
[SugarColumn(ColumnName = "COMPARE_TYPE")]
[Description("比对类型")]
public string COMPARE_TYPE { get; set; }
/// <summary>
/// 比对结果JSON
/// </summary>
[SugarColumn(ColumnName = "COMPARE_RLT")]
[Description("比对结果JSON")]
public string COMPARE_RLT { get; set; }
/// <summary>
/// 比对差异项数
/// </summary>
[SugarColumn(ColumnName = "COMPARE_DIFF_NUM")]
[Description("比对差异项数")]
public Nullable<int> COMPARE_DIFF_NUM { get; set; }
}
}

@ -154,5 +154,11 @@ namespace Myshipping.Application
/// </summary>
[Description("派车")]
TRUCK_DISPATCH,
/// <summary>
/// Booking Amendment
/// </summary>
[Description("BC变更")]
BC_MODIFY
}
}

@ -47,7 +47,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Entity\BookingSlot\" />
<Folder Include="Entity\Fee\" />
</ItemGroup>

@ -1,10 +1,12 @@
using Furion.DependencyInjection;
using Furion;
using Furion.DependencyInjection;
using Furion.DistributedIDGenerator;
using Furion.DynamicApiController;
using Furion.EventBus;
using Furion.Extensions;
using Furion.FriendlyException;
using Furion.JsonSerialization;
using Furion.RemoteRequest.Extensions;
using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
@ -16,17 +18,24 @@ using Myshipping.Application.Service.BookingOrder.Dto;
using Myshipping.Application.Service.BookingSlot.Dto;
using Myshipping.Core;
using Myshipping.Core.Service;
using MySqlX.XDevAPI.Common;
using Org.BouncyCastle.Asn1.Tsp;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using Yitter.IdGenerator;
using static Aliyun.OSS.Model.CreateSelectObjectMetaInputFormatModel;
namespace Myshipping.Application
{
@ -361,6 +370,41 @@ namespace Myshipping.Application
throw Oops.Bah($"未找到订舱编号为 {dto.DataObj.SLOT_BOOKING_NO} 的数据");
}
id = model.Id;
//生成待比对详情
TaskBCInfoDto bcSrcDto = model.Adapt<TaskBCInfoDto>();
TaskBCInfoDto bcTargetDto = dto.DataObj.Adapt<TaskBCInfoDto>();
//提取箱信息
var ctnList = _repCtn.AsQueryable()
.Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID
&& x.SLOT_ID == model.Id).ToList();
if(ctnList != null)
{
bcSrcDto.CtnList = ctnList.GroupBy(x => x.CTNALL)
.Select(x =>
{
return new TaskBCCTNInfoDto { CtnALL = x.Key, CTNNUM = x.ToList()
.Sum(a => a.CTNNUM) };
}).ToList();
}
if (dto.DataObj.CtnList != null && dto.DataObj.CtnList.Count > 0)
{
bcTargetDto.CtnList = dto.DataObj.CtnList.GroupBy(x => x.CTNALL)
.Select(x =>
{
return new TaskBCCTNInfoDto
{
CtnALL = x.Key,
CTNNUM = x.ToList()
.Sum(a => a.CTNNUM)
};
}).ToList();
}
var oldObj = model.Adapt<BookingSlotBaseApiSaveDto>();
dto.DataObj.Adapt(model);
@ -409,6 +453,9 @@ namespace Myshipping.Application
CONST_BC_MODIFY_NOTICE_FILE_CODE, CONST_BC_MODIFY_NOTICE_FILE_NAME).GetAwaiter();
}
}
//一般更新数据指的是Booking Amendment,需要与舱位进行数据比对
await PushCompareBCInfo(bcSrcDto, bcTargetDto,id);
}
else if (dto.OpType == "del")
{
@ -918,6 +965,93 @@ namespace Myshipping.Application
await _bookingFileRepository.InsertAsync(bookFile);
}
#endregion
private async Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto,long slotId)
{
string batchNo = IDGen.NextID().ToString();
DateTime bDate = DateTime.Now;
var compareResult = await ExcuteCompare(bcSrcDto, bcTargetDto);
DateTime eDate = DateTime.Now;
TimeSpan ts = eDate.Subtract(bDate);
var timeDiff = ts.TotalMilliseconds;
_logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg}", batchNo, timeDiff, compareResult.succ ? "成功" : "失败");
if (compareResult == null)
throw Oops.Oh($"舱位主键{slotId}请求BC比对失败返回为空");
}
#region 请求BC比对
/// <summary>
/// 请求BC比对
/// </summary>
/// <param name="bcSrcDto">BC详情</param>
/// <param name="bcTargetDto">BC变更后详情</param>
/// <returns>返回回执</returns>
[NonAction]
private async Task<TaskManageExcuteResultDto> ExcuteCompare(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto)
{
TaskManageExcuteResultDto model = null;
/*
1URL
2JSON
3POST
4
*/
var url = App.Configuration["BCCompareUrl"];
using (var httpClient = new HttpClient())
{
try
{
using (var reduceAttach = new MultipartFormDataContent())
{
var dataContent = new ByteArrayContent(Encoding.UTF8.GetBytes(JSON.Serialize(bcSrcDto)));
dataContent.Headers.ContentDisposition = new ContentDispositionHeaderValue($"form-data")
{
Name = "srcJson"
};
reduceAttach.Add(dataContent);
var dataContent2 = new ByteArrayContent(Encoding.UTF8.GetBytes(JSON.Serialize(bcTargetDto)));
dataContent2.Headers.ContentDisposition = new ContentDispositionHeaderValue($"form-data")
{
Name = "destJson"
};
reduceAttach.Add(dataContent2);
//请求
var response = httpClient.PostAsync(url, reduceAttach).Result;
var result = response.Content.ReadAsStringAsync().Result;
model = JSON.Deserialize<TaskManageExcuteResultDto>(result);
}
}
catch (Exception ex)
{
_logger.LogInformation("推送BC比对异常原因{error}", ex.Message);
throw Oops.Oh($"推送BC比对异常原因{ex.Message}");
}
}
return model;
}
#endregion
}
public class DynameFileInfo

@ -0,0 +1,77 @@
using Mapster;
using Myshipping.Application.Entity;
using Myshipping.Application.Service.BookingSlot.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
public class BookingSlotMapper : IRegister
{
public void Register(TypeAdapterConfig config)
{
config.ForType<BookingSlotBase, TaskBCInfoDto>()
.Map(dest => dest.CarrierId, src => src.CARRIERID)
.Map(dest => dest.Carrier, src => src.CARRIER)
.Map(dest => dest.MBLNo, src => src.SLOT_BOOKING_NO)
.Map(dest => dest.BookingSlotType, src => src.BOOKING_SLOT_TYPE)
.Map(dest => dest.BookingSlotTypeName, src => src.BOOKING_SLOT_TYPE_NAME)
.Map(dest => dest.Vessel, src => src.VESSEL)
.Map(dest => dest.VoyNo, src => src.VOYNO)
.Map(dest => dest.VGMSubmissionCutDate, src => src.VGM_SUBMISSION_CUT_DATE)
.Map(dest => dest.WeekAt, src => src.WEEK_AT)
.Map(dest => dest.CarriageType, src => src.CARRIAGE_TYPE)
.Map(dest => dest.CarriageTypeName, src => src.CARRIAGE_TYPE_NAME)
.Map(dest => dest.ContractNo, src => src.CONTRACT_NO)
.Map(dest => dest.CtnStat, src => src.CTN_STAT)
.Map(dest => dest.CYCutoffTime, src => src.CY_CUT_DATE)
.Map(dest => dest.DetensionFreeDays, src => src.DETENSION_FREE_DAYS)
.Map(dest => dest.ETD, src => src.ETD)
.Map(dest => dest.ETA, src => src.ETA)
.Map(dest => dest.LaneCode, src => src.LANECODE)
.Map(dest => dest.LaneName, src => src.LANENAME)
.Map(dest => dest.ManifestCutDate, src => src.MANIFEST_CUT_DATE)
.Map(dest => dest.MDGFCutDate, src => src.MDGF_CUT_DATE)
.Map(dest => dest.PlaceDelivery, src => src.PLACEDELIVERY)
.Map(dest => dest.PlaceReceipt, src => src.PLACERECEIPT)
.Map(dest => dest.PortDischarge, src => src.PORTDISCHARGE)
.Map(dest => dest.Portload, src => src.PORTLOAD)
.Map(dest => dest.TransferPort1, src => src.TRANSFER_PORT_1)
.Map(dest => dest.TransferPort2, src => src.TRANSFER_PORT_2);
config.ForType<BookingSlotBaseApiSaveDto, TaskBCInfoDto>()
.Map(dest => dest.CarrierId, src => src.CARRIERID)
.Map(dest => dest.Carrier, src => src.CARRIER)
.Map(dest => dest.MBLNo, src => src.SLOT_BOOKING_NO)
.Map(dest => dest.BookingSlotType, src => src.BOOKING_SLOT_TYPE)
.Map(dest => dest.BookingSlotTypeName, src => src.BOOKING_SLOT_TYPE_NAME)
.Map(dest => dest.Vessel, src => src.VESSEL)
.Map(dest => dest.VoyNo, src => src.VOYNO)
.Map(dest => dest.VGMSubmissionCutDate, src => src.VGM_SUBMISSION_CUT_DATE)
.Map(dest => dest.WeekAt, src => src.WEEK_AT)
.Map(dest => dest.CarriageType, src => src.CARRIAGE_TYPE)
.Map(dest => dest.CarriageTypeName, src => src.CARRIAGE_TYPE_NAME)
.Map(dest => dest.ContractNo, src => src.CONTRACT_NO)
.Map(dest => dest.CtnStat, src => src.CTN_STAT)
.Map(dest => dest.CYCutoffTime, src => src.CY_CUT_DATE)
.Map(dest => dest.DetensionFreeDays, src => src.DETENSION_FREE_DAYS)
.Map(dest => dest.ETD, src => src.ETD)
.Map(dest => dest.ETA, src => src.ETA)
.Map(dest => dest.LaneCode, src => src.LANECODE)
.Map(dest => dest.LaneName, src => src.LANENAME)
.Map(dest => dest.ManifestCutDate, src => src.MANIFEST_CUT_DATE)
.Map(dest => dest.MDGFCutDate, src => src.MDGF_CUT_DATE)
.Map(dest => dest.PlaceDelivery, src => src.PLACEDELIVERY)
.Map(dest => dest.PlaceReceipt, src => src.PLACERECEIPT)
.Map(dest => dest.PortDischarge, src => src.PORTDISCHARGE)
.Map(dest => dest.Portload, src => src.PORTLOAD)
.Map(dest => dest.TransferPort1, src => src.TRANSFER_PORT_1)
.Map(dest => dest.TransferPort2, src => src.TRANSFER_PORT_2);
}
}
}
Loading…
Cancel
Save