代码格式化 及 更新箱型箱量多行记录问题

usertest
ZR20090193-陈敬勇 6 months ago
parent d36337fb7a
commit 1ba9a9bf46

@ -44,7 +44,7 @@ public class SeaExportService : ISeaExportService
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
private readonly ISaasDbService saasService;
private readonly ICommonService commonService;
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
private readonly ISeaExportCommonService seaComService;
@ -201,7 +201,7 @@ public class SeaExportService : ISeaExportService
.Map(dto => dto.WEIGHTYPE, poco => poco.WeightType)
.Map(dto => dto.WEIGHSIGN, poco => poco.WeightSign)
;
TypeAdapterConfig<OpCtnDetail, SeaExportCtnDetailEDIBaseModel>
.NewConfig()
.Map(dto => dto.HSCODE, poco => poco.HSCode)
@ -289,20 +289,20 @@ public class SeaExportService : ISeaExportService
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
if (req.CtnInfo.Count > 0)
{
{
foreach (var item in req.CtnInfo)
{
var ctn = item.Adapt<OpCtn>();
ctn.BSNO = entity.Id.ToString();
tenantDb.Insertable(ctn).ExecuteCommand();
}
tenantDb.Insertable(ctn).ExecuteCommand();
}
}
if (req.EdiInfo.IsNotNull())
{
var edi = req.EdiInfo.Adapt<SeaExportEdi>();
edi.BusinessId = entity.Id;
tenantDb.Insertable(edi).ExecuteCommand();
{
var edi = req.EdiInfo.Adapt<SeaExportEdi>();
edi.BusinessId = entity.Id;
tenantDb.Insertable(edi).ExecuteCommand();
}
#region 初始化费用状态表
var feeStatus = BusinessFeeStatus.Init(entity.Id);
@ -312,8 +312,8 @@ public class SeaExportService : ISeaExportService
}
else
{
var info = tenantDb.Queryable<SeaExport>().Where(x => x.Id == req.Id).First();
var feeStatus = tenantDb.Queryable<BusinessFeeStatus>().Where(x => x.BusinessId == req.Id).First();
var info = tenantDb.Queryable<SeaExport>().Where(x => x.Id == req.Id).First();
var feeStatus = tenantDb.Queryable<BusinessFeeStatus>().Where(x => x.BusinessId == req.Id).First();
if (feeStatus.IsNotNull() && (bool)feeStatus.IsBusinessLocking)
{
@ -362,7 +362,7 @@ public class SeaExportService : ISeaExportService
if (req.EdiInfo.IsNotNull())
{
var edi = tenantDb.Queryable<SeaExportEdi>().Where(x => x.BusinessId == req.Id).ToList();
var ediInfo = req.EdiInfo.Adapt(edi);
var ediInfo = req.EdiInfo.Adapt(edi);
tenantDb.Updateable(ediInfo).ExecuteCommand();
}
@ -371,7 +371,7 @@ public class SeaExportService : ISeaExportService
{
feeStatus = BusinessFeeStatus.Init(req.Id);
tenantDb.Insertable(feeStatus).ExecuteCommand();
}
}
#endregion
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
}
@ -384,11 +384,12 @@ public class SeaExportService : ISeaExportService
/// <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;
@ -402,74 +403,80 @@ public class SeaExportService : ISeaExportService
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.Ctn == ctnCode).Any())
{
var ctn = ctnList.Where(x => x.Ctn == ctnCode).First();
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;
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.Ctn)).ToList();
var otherCtns = ctnList.Where(x => !dictList.Contains(x.CtnCode)).ToList();
if (otherCtns.Count > 0)
{
@ -577,7 +584,7 @@ public class SeaExportService : ISeaExportService
data.CustomerNo = sequence.Data;
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
#region 初始化费用状态表
var feeStatus = BusinessFeeStatus.Init(entity.Id);
tenantDb.Insertable(feeStatus).ExecuteCommand();
@ -712,7 +719,7 @@ public class SeaExportService : ISeaExportService
#endregion
/// <summary>
/// 获取场站数据
@ -883,7 +890,7 @@ public class SeaExportService : ISeaExportService
return await Task.FromResult(DataResult<string>.Failed("未传入正确参数!"));
}
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var userKey = db.Queryable<SysConfig>().Filter(null,true).Where(x => x.Code == "seae_billtraceurl_userKey" && x.TenantId == 1288018625843826688).First().Value;
var userKey = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "seae_billtraceurl_userKey" && x.TenantId == 1288018625843826688).First().Value;
var userPwd = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "seae_billtraceurl_userPwd" && x.TenantId == 1288018625843826688).First().Value;
var userId = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "seae_billtraceurl_userId" && x.TenantId == 1288018625843826688).First().Value;
var reqUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "request_seae_billtraceurl" && x.TenantId == 1288018625843826688).First().Value;
@ -1061,11 +1068,11 @@ public class SeaExportService : ISeaExportService
/// </summary>
/// <param name="id">业务Id</param>
/// <returns></returns>
public async Task<DataResult<string[]>> VgmLink(string id)
public async Task<DataResult<string[]>> VgmLink(string id)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var bookingId = long.Parse(id);
var bookingId = long.Parse(id);
var order = tenantDb.Queryable<SeaExport>().First(x => x.Id == bookingId);
if (order == null)
{
@ -1077,8 +1084,8 @@ public class SeaExportService : ISeaExportService
{
orderUrl = new BookingOrderUrl()
{
BusinessId = bookingId
};
BusinessId = bookingId
};
await tenantDb.Insertable(orderUrl).ExecuteCommandAsync();
}
@ -1134,7 +1141,7 @@ public class SeaExportService : ISeaExportService
var dicUrlVgmResp = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "vgm_si_post_reponse" && x.TenantId == 1288018625843826688).First();
var dicUrlSiResp = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "si_post_response" && x.TenantId == 1288018625843826688).First();
var userInfo = await db.Queryable<SysUser>().Filter(null, true).FirstAsync(x => x.Id == long.Parse(user.UserId));
var userInfo = await db.Queryable<SysUser>().Filter(null, true).FirstAsync(x => x.Id == long.Parse(user.UserId));
var tenant = db.Queryable<SysTenant>().Filter(null, true).First(x => x.Id == long.Parse(user.TenantId));
//调用vgm链接服务
var postUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "vgm_link_service" && x.TenantId == 1288018625843826688).First().Value;
@ -1155,7 +1162,7 @@ public class SeaExportService : ISeaExportService
linkMobile = userInfo.Phone,
linkEmail = userInfo.Email,
userId = userInfo.DjyUserId,
signatory = userInfo.NickName,
signatory = userInfo.NickName,
returnUrl = dicUrlVgmResp?.Value,
shipName = order.Vessel,
voyNo = order.Voyno,
@ -1208,7 +1215,7 @@ public class SeaExportService : ISeaExportService
orderUrl.UrlVgmSi = memoData.GetStringValue("vgmAndSiUrl");
await tenantDb.Updateable(orderUrl).ExecuteCommandAsync();
//货运动态
var bookingStatus = new BookingStatusLog()
{
@ -1220,14 +1227,15 @@ public class SeaExportService : ISeaExportService
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
return await Task.FromResult(DataResult<string[]>.Success(new string[]{ orderUrl.UrlVgm, orderUrl.UrlVgmSi }));
return await Task.FromResult(DataResult<string[]>.Success(new string[] { orderUrl.UrlVgm, orderUrl.UrlVgmSi }));
}
/// <summary>
/// 发送VGM
/// </summary>
/// <param name="id">业务Id</param>
/// <returns></returns>
public async Task<DataResult<string>> VgmSend(string id) {
public async Task<DataResult<string>> VgmSend(string id)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
@ -1235,7 +1243,7 @@ public class SeaExportService : ISeaExportService
var order = tenantDb.Queryable<SeaExport>().First(x => x.Id == bookingId);
var ctns = tenantDb.Queryable<OpCtn>().Where(x => x. BSNO == id).ToList();
var ctns = tenantDb.Queryable<OpCtn>().Where(x => x.BSNO == id).ToList();
//船公司
if (order.CarrierId == 0 || order.CarrierId.ToString().IsNull())
@ -1263,7 +1271,7 @@ public class SeaExportService : ISeaExportService
var urlConfig = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "DjyVgmApiMyshppingUrl" && x.TenantId == 1288018625843826688).First().Value;
var userKey = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "DjyVgmApiMyshppingUserKey" && x.TenantId == 1288018625843826688).First().Value;
var userPwd = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "DjyVgmApiMyshppingUserPwd" && x.TenantId == 1288018625843826688).First().Value;
if (userKey.IsNull() || userPwd.IsNull())
return await Task.FromResult(DataResult<string>.Failed("请在网站账号中维护VGM接口的用户id和秘钥!"));
@ -1311,19 +1319,20 @@ public class SeaExportService : ISeaExportService
{ "ctndata", JsonConvert.SerializeObject(listCtn)}
};
_logger.Info($"调用vgm发送接口{ urlConfig },参数:{JsonConvert.SerializeObject(dictParam)}");
_logger.Info($"调用vgm发送接口{urlConfig},参数:{JsonConvert.SerializeObject(dictParam)}");
var result = RequestHelper.Post(JsonConvert.SerializeObject(dictParam), urlConfig);
_logger.Info($"调用vgm发送接口{ urlConfig },返回:{result}");
_logger.Info($"调用vgm发送接口{urlConfig},返回:{result}");
var jobjRtn = JObject.Parse(result);
if (jobjRtn.GetBooleanValue("Success"))
{
//货运动态
var bookingStatus = new BookingStatusLog() {
var bookingStatus = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"发送VGM",
Group = "ship",
@ -1347,13 +1356,13 @@ public class SeaExportService : ISeaExportService
//var carrWebAccMap = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "carrier_web_account_mapping" && x.Code == order.Carrier);
//if (carrWebAccMap == null)
// return await Task.FromResult(DataResult<string>.Failed("不支持的船公司或账号映射未配置"));
var webacc = tenantDb.Queryable<CodeThirdParty>().Where(x => x.CustomerId == order.CarrierId && x.AccountType == "VgmSet").First(); ;
var webacc = tenantDb.Queryable<CodeThirdParty>().Where(x => x.CustomerId == order.CarrierId && x.AccountType == "VgmSet").First(); ;
if (webacc == null)
return await Task.FromResult(DataResult<string>.Failed("船公司网站账号未配置"));
#region 箱信息校验2022-7-1修改【累加】的必须有重量、皮重和称重重量【总重】的只需要称重重量不为空
if (ctns.Where(c => c.WeightType== "累加" &&
if (ctns.Where(c => c.WeightType == "累加" &&
(
string.IsNullOrEmpty(c.CntrNo)
|| !c.WeightKGS.HasValue
@ -1403,9 +1412,9 @@ public class SeaExportService : ISeaExportService
var carrMap = tenantDb.Queryable<MappingCarrier>().Where(x => x.Status == StatusEnum.Enable && x.Module == "BookingVgm" && x.LinkId == order.CarrierId).First();
string mappingCarrierCode = carrMap != null ? carrMap.MapCode : order.Carrier;
var userInfo = await db.Queryable<SysUser>().Filter(null,true).FirstAsync(x => x.Id == long.Parse(user.UserId));
var userInfo = await db.Queryable<SysUser>().Filter(null, true).FirstAsync(x => x.Id == long.Parse(user.UserId));
var tenant = db.Queryable<SysTenant>().Filter(null,true).First(x=>x.Id == long.Parse(user.TenantId));
var tenant = db.Queryable<SysTenant>().Filter(null, true).First(x => x.Id == long.Parse(user.TenantId));
int idx = 1;
//调用接口
var postUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "vgm_service_single" && x.TenantId == 1288018625843826688).First().Value;
@ -1415,7 +1424,7 @@ public class SeaExportService : ISeaExportService
SystemCode = "djy_hechuan",
billOrderId = order.Id.ToString(),
sendOrderCode = order.MBLNO,
customerName = $"{tenant.Name}+{ userInfo.UserName }", //公司名称+用户姓名
customerName = $"{tenant.Name}+{userInfo.UserName}", //公司名称+用户姓名
customerId = order.CustomerId.ToString(),
agentName = string.IsNullOrEmpty(order.Forwarder) ? tenant.Name : order.Forwarder,
carrierCode = mappingCarrierCode,
@ -1462,7 +1471,7 @@ public class SeaExportService : ISeaExportService
if (respCode != 200)
{
return await Task.FromResult(DataResult<string>.Failed(jobjResp.GetStringValue("message")));
}
}
//货运动态
var bookingStatus = new BookingStatusLog()
{
@ -1495,7 +1504,7 @@ public class SeaExportService : ISeaExportService
return await Task.FromResult(DataResult<List<BatchVGM>>.Failed("请传入正确数据!"));
}
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var main = await tenantDb.Queryable<SeaExport>().Where(x => x.ParentId == 0).ToListAsync();
List<BatchVGM> batchVGMs = new List<BatchVGM>();
foreach (var item in arr)
@ -1529,7 +1538,7 @@ public class SeaExportService : ISeaExportService
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (dto == null)
{
{
return await Task.FromResult(DataResult<string>.Failed("未提交数据!"));
}
@ -1537,11 +1546,11 @@ public class SeaExportService : ISeaExportService
foreach (var item in dto)
{
var dic = item.GetPropertiesArray();
var info = tenantDb.Queryable<OpCtn>().Where(x=>x.Id == item.Id).First();
var info = tenantDb.Queryable<OpCtn>().Where(x => x.Id == item.Id).First();
info = item.Adapt(info);
tenantDb.Updateable(info).UpdateColumns(dic).ExecuteCommand();
}
}
return await Task.FromResult(DataResult<string>.Success("更新成功!", MultiLanguageConst.DataUpdateSuccess));
}
@ -1574,8 +1583,8 @@ public class SeaExportService : ISeaExportService
BusinessId = bookingId
};
await tenantDb.Insertable(orderUrl).ExecuteCommandAsync();
}
}
//校验船公司
if (string.IsNullOrEmpty(order.Carrier))
{
@ -1584,7 +1593,7 @@ public class SeaExportService : ISeaExportService
//判断船公司是否支持 1790295446942519296
var allowCarrier = db.Queryable<SysDictData>()
.InnerJoin<SysDictType>((a,b)=>a.TypeId == b.Id).Where((a,b) => b.Code == "txxp_carrier_list").Select((a,b) => a.Value).ToList();
.InnerJoin<SysDictType>((a, b) => a.TypeId == b.Id).Where((a, b) => b.Code == "txxp_carrier_list").Select((a, b) => a.Value).ToList();
if (!allowCarrier.Contains(order.Carrier))
return await Task.FromResult(DataResult<string>.Failed("不支持的船公司"));
@ -1598,8 +1607,8 @@ public class SeaExportService : ISeaExportService
//根据订舱代理获取账号类型
var ytMapList = db.Queryable<SysDictData>()
.InnerJoin<SysDictType>((a, b) => a.TypeId == b.Id).Where((a, b) => b.Code == "txxp_yitong_forwarder_map")
.Select((a,b)=>new { Value = a.Value, Name = a.Name }).ToList();
.Select((a, b) => new { Value = a.Value, Name = a.Name }).ToList();
var ytmap = ytMapList.FirstOrDefault(x => x.Value == order.Forwarder);
if (ytmap == null)
{
@ -1617,7 +1626,7 @@ public class SeaExportService : ISeaExportService
{
return await Task.FromResult(DataResult<string>.Failed(String.Format("场站EDI配置未找到{0}", $"{order.Yard} {order.Carrier}(提箱小票)")));
}
var yardset = yardsetList.FirstOrDefault(x => x.Code == order.Carrier);
if (yardset == null)
@ -1634,7 +1643,7 @@ public class SeaExportService : ISeaExportService
//箱型映射
var ctnMapping = tenantDb.Queryable<MappingCtn>().Where(x => x.Module == "BookingTxxp").ToList();
var expCode = ctns.Select(x => x.CtnCode).Distinct().Except(ctnMapping.Select(y => y.Code)).ToList();
if (expCode.Count > 0)
{
@ -1692,8 +1701,8 @@ public class SeaExportService : ISeaExportService
}
var addUrlFlag = string.IsNullOrEmpty(orderUrl.UrlTxxp) ? true : false; //新生成还是更新链接
//保存url
//保存url
//保存url
var txxpUrl = jobjResp.GetStringValue("data");
orderUrl.UrlTxxp = txxpUrl;
@ -1735,7 +1744,7 @@ public class SeaExportService : ISeaExportService
_logger.Info("批次={no}获取请求VOLTA截单详情 {msg}", batchNo, JsonConvert.SerializeObject(req));
if (!req.SendType.Equals("E", StringComparison.OrdinalIgnoreCase))
return DataResult<VOLTAEDIBaseModel>.Failed($"只接受发送类型截单E");
return DataResult<VOLTAEDIBaseModel>.Failed($"只接受发送类型截单E");
if (req.Id == 0)
return DataResult<VOLTAEDIBaseModel>.Failed($"订单Id不能为空");
@ -1745,13 +1754,13 @@ public class SeaExportService : ISeaExportService
if (order == null)
return DataResult<VOLTAEDIBaseModel>.Failed($"获取订单信息失败");
if (order.ParentId== 0)
if (order.ParentId == 0)
return DataResult<VOLTAEDIBaseModel>.Failed($"获取当前订单为分单不能生成EDI信息");
_logger.Info("批次={no}提取订单信息完成", batchNo);
if (!order.Carrier.Equals("VOL", StringComparison.OrdinalIgnoreCase) && !order.Carrier.Equals("FCS", StringComparison.OrdinalIgnoreCase))
{
{
return DataResult<VOLTAEDIBaseModel>.Failed($"当前订单的船公司不是VOL(沃尔塔航运)不能发送VOLTA截单EDI");
}
@ -1767,16 +1776,17 @@ public class SeaExportService : ISeaExportService
var ctns = tenantDb.Queryable<OpCtn>().Where(x => x.BSNO == order.Id.ToString()).ToList();
//VOLTAEDIBaseModel voltaModel = order.Adapt<VOLTAEDIBaseModel>();
var voltaModel = new VOLTAEDIBaseModel() {
var voltaModel = new VOLTAEDIBaseModel()
{
BookingId = order.MBLNO,
id = order.Id,
ShpperName = order.ShipperContent,
ConsigneeName = order.ConsigneeContent,
ShpperName = order.ShipperContent,
ConsigneeName = order.ConsigneeContent,
NotifyName = order.NotifyPartyContent,
LoadPort = order.LoadPort,
DischargePort = order.DischargePort,
FinalDestination = order.Destination,
PlaceOfDelivery =order.DeliveryPlace,
PlaceOfDelivery = order.DeliveryPlace,
CargoDescription = order.Description,
Marks = order.Marks,
Vessel = order.Vessel,
@ -1808,22 +1818,24 @@ public class SeaExportService : ISeaExportService
if (voltaModel.CargoDescription.EndsWith("\n"))
voltaModel.CargoDescription = voltaModel.CargoDescription.Substring(0, voltaModel.CargoDescription.Length - 1);
if (voltaModel != null) {
if (voltaModel != null)
{
var list = new List<VOLTAEDIContaModel>();
foreach (var item in ctns)
{
list.Add(new VOLTAEDIContaModel() {
ContaNo = item.CntrNo,
SealNo =item.SealNo,
list.Add(new VOLTAEDIContaModel()
{
ContaNo = item.CntrNo,
SealNo = item.SealNo,
GWt = item.KGS,
NWt = item.TareWeight,
Qty = item.PKGS,
CBM = item.CBM,
Pkgs =item.KindPkgs
Pkgs = item.KindPkgs
});
}
}
//voltaModel.ContaList = ctns.Adapt<List<VOLTAEDIContaModel>>();
//voltaModel.ContaList = ctns.Adapt<List<VOLTAEDIContaModel>>();
StringBuilder pkgsBuilder = new StringBuilder();
//还需要翻译箱明细的包装
@ -1834,8 +1846,8 @@ public class SeaExportService : ISeaExportService
//包装基础数据
var basePkgsList = tenantDb.Queryable<CodePackage>().ToList();
var ediPkgsList = tenantDb.Queryable<MappingPackage>().Where(t => t.Module == "BOOK_CLOSING_VOLTA"
&& t.CarrierId.HasValue && t.CarrierId ==order.CarrierId)
var ediPkgsList = tenantDb.Queryable<MappingPackage>().Where(t => t.Module == "BOOK_CLOSING_VOLTA"
&& t.CarrierId.HasValue && t.CarrierId == order.CarrierId)
.ToList();
int startNo = 1;
@ -1870,7 +1882,7 @@ public class SeaExportService : ISeaExportService
if (pkgsBuilder.Length > 0)
{
_logger.Info("批次={no}获取请求VOLTA截单详情有错误 {msg}", batchNo, JsonConvert.SerializeObject(req));
return DataResult<VOLTAEDIBaseModel>.Failed("获取请求VOLTA截单详情有错误:"+ JsonConvert.SerializeObject(req));
return DataResult<VOLTAEDIBaseModel>.Failed("获取请求VOLTA截单详情有错误:" + JsonConvert.SerializeObject(req));
}
return DataResult<VOLTAEDIBaseModel>.Success(voltaModel);
@ -1924,13 +1936,13 @@ public class SeaExportService : ISeaExportService
public async Task<DataResult<string>> SendBookingOrClosingEDI(BookingOrClosingEDIOrderReq req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var dictValue= db.Queryable<SysDictData>()
var dictValue = db.Queryable<SysDictData>()
.InnerJoin<SysDictType>((a, b) => a.TypeId == b.Id).Where((a, b) => b.Code == "XiangManCang")
.Select((a, b) => new { Value = a.Value, Name = a.Name }).First();
var order = tenantDb.Queryable<SeaExport>().First(x => x.Id == req.Id);
var Forwarder = order.Forwarder;
if (!string.IsNullOrEmpty(Forwarder) && dictValue.Value == Forwarder)
{
{
return await XMCEXCEL(req.Id);
}
else
@ -1952,7 +1964,7 @@ public class SeaExportService : ISeaExportService
var order = tenantDb.Queryable<SeaExport>().First(x => x.Id == Id);
var edi = tenantDb.Queryable<SeaExportEdi>().First(x => x.BusinessId == Id);
var ctn = tenantDb.Queryable<OpCtn>().Where(x => x.BSNO == order.Id.ToString()).ToList();
var ctn = tenantDb.Queryable<OpCtn>().Where(x => x.BSNO == order.Id.ToString()).ToList();
#region 箱满仓生成excel文件
string fileName = String.Empty;
@ -2136,7 +2148,7 @@ public class SeaExportService : ISeaExportService
ICell cell5 = row.GetCell(5);
var serviceMap = tenantDb.Queryable<MappingService>()
.Where(x => x.Status == StatusEnum.Enable && x.Module == "XiangManCangEDI" && x.Code == service).Select(x => x.MapCode).First();
if (cell5 != null)
{
row.Cells[5].SetCellValue(serviceMap);
@ -2144,7 +2156,7 @@ public class SeaExportService : ISeaExportService
else
{
row.CreateCell(5).SetCellValue(serviceMap);
}
}
}
if (i == 19)
{
@ -2337,7 +2349,7 @@ public class SeaExportService : ISeaExportService
{
bl = tenantDb.Queryable<MappingService>()
.Where(x => x.Status == StatusEnum.Enable && x.Module == "XiangManCangEDI" && x.Code == BLFRTCode).Select(x => x.MapCode).First();
}
ICell cell = row.GetCell(0);
if (cell != null)
@ -2371,7 +2383,7 @@ public class SeaExportService : ISeaExportService
{
bl = tenantDb.Queryable<MappingService>()
.Where(x => x.Status == StatusEnum.Enable && x.Module == "XiangManCangEDI" && x.Code == BLFRTCode).Select(x => x.MapCode).First();
}
if (bl == "预付")
{
@ -2537,7 +2549,7 @@ public class SeaExportService : ISeaExportService
}
var key = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "billTraceNewUserKey" && x.TenantId == 1288018625843826688).Select(x => x.Value).First();
if (string.IsNullOrEmpty(key))
{
return await Task.FromResult(DataResult<string>.Failed("未获取到相关KEY请联系管理员"));
@ -2631,7 +2643,7 @@ public class SeaExportService : ISeaExportService
public async Task<DataResult<string>> InnerBookingOrClosingEDI(BookingOrClosingEDIOrderReq req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
string batchNo = GuidHelper.NewGuidFormatN();
_logger.Info("批次={no}获取请求订舱、截单EDI {msg}", batchNo, JsonConvert.SerializeObject(req));
@ -2660,20 +2672,20 @@ public class SeaExportService : ISeaExportService
var ediExtModel = tenantDb.Queryable<SeaExportEdi>().First(x => x.BusinessId == req.Id);
if (ediExtModel == null)
return DataResult<string>.Failed($"获取EDI信息失败");
return DataResult<string>.Failed($"获取EDI信息失败");
_logger.Info("批次={no}提取订单EDI信息完成", batchNo);
//箱信息
var contaList = tenantDb.Queryable<OpCtn>().Where(x => x.BSNO == order.Id.ToString()).ToList();
var check= CheckBookingOrClosingEDI(order, contaList);
var check = CheckBookingOrClosingEDI(order, contaList);
if (!check.Succeeded)
{
return DataResult<string>.Failed(check.Message);
}
var carrMap= tenantDb.Queryable<MappingCarrier>().Where(t => t.Module.Equals("BOOK_OR_CLOSING_RT", StringComparison.OrdinalIgnoreCase)
var carrMap = tenantDb.Queryable<MappingCarrier>().Where(t => t.Module.Equals("BOOK_OR_CLOSING_RT", StringComparison.OrdinalIgnoreCase)
&& t.LinkId == order.CarrierId)
.First();
@ -2714,7 +2726,7 @@ public class SeaExportService : ISeaExportService
&& t.CarrierId == order.CarrierId).ToList();
//包装基础数据
var basePkgsList = tenantDb.Queryable<CodePackage>().Where(x=>x.Status == StatusEnum.Enable).ToList();
var basePkgsList = tenantDb.Queryable<CodePackage>().Where(x => x.Status == StatusEnum.Enable).ToList();
//EDI SO\SI代码
var ediSOSICfg = tenantDb.Queryable<MappingCarrier>().First(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
@ -2740,7 +2752,7 @@ public class SeaExportService : ISeaExportService
userWebAccountConfig = await tenantDb.Queryable<CodeThirdParty>().FirstAsync(x => x.AccountType == CONST_TSL_TYPE_CODE);
_logger.Info("批次={no} 获取获取网站的账户完成result={Num}", batchNo,JsonConvert.SerializeObject(userWebAccountConfig));
_logger.Info("批次={no} 获取获取网站的账户完成result={Num}", batchNo, JsonConvert.SerializeObject(userWebAccountConfig));
if (userWebAccountConfig == null)
return DataResult<string>.Failed($"未配置个人或公司网站账户,网站{CONST_TSL_TYPE_CODE}");
@ -2830,7 +2842,7 @@ public class SeaExportService : ISeaExportService
primaryModel.ESLLINECODE = order.Lane;
//起始港映射
var ediLoadPortList = tenantDb.Queryable<MappingPort>()
var ediLoadPortList = tenantDb.Queryable<MappingPort>()
.Where(a => a.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase) && a.CarrierId == order.CarrierId).ToList();
//收货地
@ -2882,7 +2894,7 @@ public class SeaExportService : ISeaExportService
}
//目的港基础
var portList = tenantDb.Queryable<CodePort>().Where(x=>x.Status == StatusEnum.Enable).ToList();
var portList = tenantDb.Queryable<CodePort>().Where(x => x.Status == StatusEnum.Enable).ToList();
//目的港映射
var ediPortList = tenantDb.Queryable<MappingPort>()
@ -3041,7 +3053,7 @@ public class SeaExportService : ISeaExportService
|| ediRouteEnum == EDIRouteEnum.YML || ediRouteEnum == EDIRouteEnum.YT || ediRouteEnum == EDIRouteEnum.INTTRA)
{
//付费方式基础数据
var baseFrtList = tenantDb.Queryable<CodeFrt>().Where(x=>x.Status == StatusEnum.Enable).ToList();
var baseFrtList = tenantDb.Queryable<CodeFrt>().Where(x => x.Status == StatusEnum.Enable).ToList();
var baseFrtInfo = baseFrtList.FirstOrDefault(t =>
t.EdiCode.Equals(order.MBLFrt, StringComparison.OrdinalIgnoreCase));
@ -3059,7 +3071,7 @@ public class SeaExportService : ISeaExportService
if (currFrtInfo == null)
return DataResult<string>.Failed($"付费方式{order.MBLFrt}的EDI代码未找到");
primaryModel.BLFRTEDICODE = currFrtInfo.MapCode?.Trim();
}
}
@ -3091,7 +3103,7 @@ public class SeaExportService : ISeaExportService
if (!string.IsNullOrWhiteSpace(order.IssueType))
{
//签单方式EDI
var baseIssueTypeList = tenantDb.Queryable<CodeIssueType>().Where(x => x.Status == StatusEnum.Enable).ToList();
var baseIssueTypeList = tenantDb.Queryable<CodeIssueType>().Where(x => x.Status == StatusEnum.Enable).ToList();
var baseIssueTypeInfo = baseIssueTypeList.FirstOrDefault(t =>
t.EnName.Equals(order.IssueType, StringComparison.OrdinalIgnoreCase));
@ -3479,7 +3491,7 @@ public class SeaExportService : ISeaExportService
*/
//EDI文件
var bookFile = new OpFile
{
{
FileName = fileName,
FilePath = FilePath,
TypeCode = fileTypeCode,
@ -3488,7 +3500,7 @@ public class SeaExportService : ISeaExportService
};
await tenantDb.Insertable(bookFile).ExecuteCommandAsync();
}
}
#region 检查订舱、截单EDI订单信息
/// <summary>
@ -3567,7 +3579,7 @@ public class SeaExportService : ISeaExportService
result.Succeeded = false;
result.Message = "系统参数配置email_api_url 请联系管理员";
return await Task.FromResult(result);
}
}
List<EmailApiDto> emailList = new List<EmailApiDto>();
@ -3688,7 +3700,7 @@ public class SeaExportService : ISeaExportService
par.Add("username", ediCfg.UserName);
par.Add("pwd", ediCfg.Password);
par.Add("path", ediCfg.FolderName);
var ftpSpiderUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "booking_edi_ftp_server" && x.TenantId == 1288018625843826688).First().Value;
if (ftpSpiderUrl == null)
return await Task.FromResult(EdiDataResult.Failed("系统未配置booking_edi_ftp_server 请联系管理员!"));
@ -3754,7 +3766,7 @@ public class SeaExportService : ISeaExportService
/// <param name="accountConfig">配置账户</param>
/// <returns>返回回执</returns>
private async Task<EdiDataResult> InnerSendBookingOrClosingEDIToPOST(string filePath, string url, CodeThirdParty accountConfig)
{
{
CancellationTokenSource cts = new CancellationTokenSource();
var userKey = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "BCOrDraftUserKey" && x.TenantId == 1288018625843826688).First();
@ -3817,13 +3829,13 @@ public class SeaExportService : ISeaExportService
var jobjRetn = JObject.Parse(res);
if (jobjRetn.GetStringValue("code") != "200")
{
{
return await Task.FromResult(EdiDataResult.Failed(jobjRetn.GetStringValue("msg")));
}
else
{
return await Task.FromResult(EdiDataResult.Failed("请求成功!"));
}
}
}
#region 触发订舱
@ -3853,7 +3865,7 @@ public class SeaExportService : ISeaExportService
{
strCheck = Regex.Replace(strCheck, "\\<br\\s{1,}/\\>", "\n");
}
throw new Exception($"发送{EDIRouteEnum.PIL.ToString()}校验失败,{strCheck}");
throw new Exception($"发送{EDIRouteEnum.PIL.ToString()}校验失败,{strCheck}");
}
@ -3935,7 +3947,7 @@ public class SeaExportService : ISeaExportService
var currRlt = new EdiDataResult();
if (req.SendType == "B")
{
currRlt= YMLEdiHelper.CreateEdiYML(ediModel);
currRlt = YMLEdiHelper.CreateEdiYML(ediModel);
}
else if (req.SendType == "E")
{
@ -3988,7 +4000,7 @@ public class SeaExportService : ISeaExportService
#endregion
result.Succeeded = currRlt.Succeeded;
result.ExtraData1 = currRlt.Succeeded ? currRlt.ExtraData1.ToString() : "";
}
}
else if (ediRouteEnum == EDIRouteEnum.MELL)
{
#region MELL
@ -4057,7 +4069,7 @@ public class SeaExportService : ISeaExportService
result.Succeeded = false;
result.Message = ex.Message;
}
return result;
return result;
}
#endregion

Loading…
Cancel
Save