|
|
@ -1,4 +1,6 @@
|
|
|
|
using Common;
|
|
|
|
using AutoMapper;
|
|
|
|
|
|
|
|
using Common;
|
|
|
|
|
|
|
|
using Common.Const;
|
|
|
|
using Common.DJYModel;
|
|
|
|
using Common.DJYModel;
|
|
|
|
using Common.Extensions;
|
|
|
|
using Common.Extensions;
|
|
|
|
using Common.Tools;
|
|
|
|
using Common.Tools;
|
|
|
@ -17,14 +19,17 @@ using NETCore.Encrypt.Internal;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
|
|
|
using Org.BouncyCastle.Ocsp;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Data.Common;
|
|
|
|
using System.Data.Common;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
using System.Security.Policy;
|
|
|
|
using System.Security.Policy;
|
|
|
|
using System.Security.Principal;
|
|
|
|
using System.Security.Principal;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
using static NPOI.HSSF.Util.HSSFColor;
|
|
|
|
|
|
|
|
|
|
|
|
namespace djy.Service.AFR
|
|
|
|
namespace djy.Service.AFR
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -262,7 +267,7 @@ namespace djy.Service.AFR
|
|
|
|
.ToListAsync();
|
|
|
|
.ToListAsync();
|
|
|
|
histories.ForEach(item =>
|
|
|
|
histories.ForEach(item =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var master = result.FirstOrDefault(m => m.GID == item.PID);
|
|
|
|
var master = result.FirstOrDefault(m => m.GID == item.MID);
|
|
|
|
if (master == null) return;
|
|
|
|
if (master == null) return;
|
|
|
|
master.History = item;
|
|
|
|
master.History = item;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -334,8 +339,7 @@ namespace djy.Service.AFR
|
|
|
|
await DbAMS.Insert(input.HouseList).WithTransaction(tran).ExecuteAffrowsAsync();
|
|
|
|
await DbAMS.Insert(input.HouseList).WithTransaction(tran).ExecuteAffrowsAsync();
|
|
|
|
await DbAMS.Insert(input.HouseList.SelectMany(h => h.CntrList)).WithTransaction(tran).ExecuteAffrowsAsync();
|
|
|
|
await DbAMS.Insert(input.HouseList.SelectMany(h => h.CntrList)).WithTransaction(tran).ExecuteAffrowsAsync();
|
|
|
|
|
|
|
|
|
|
|
|
AFRMasterHistory history = BuildAFRMasterHistory(input.GID, "新增", 0, "创建了单据");
|
|
|
|
await BuildAFRMasterHistoryAsync(input.GID, input.HouseList.Select(h => h.GID), "新增", 0, "创建了单据", tran);
|
|
|
|
await DbAMS.Insert(history).WithTransaction(tran).ExecuteAffrowsAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
|
tran.Commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -448,6 +452,8 @@ namespace djy.Service.AFR
|
|
|
|
if (waitInsertHouseGids.Any())
|
|
|
|
if (waitInsertHouseGids.Any())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await DbAMS.Insert(waitInsertHouseList).WithTransaction(tran).ExecuteAffrowsAsync();
|
|
|
|
await DbAMS.Insert(waitInsertHouseList).WithTransaction(tran).ExecuteAffrowsAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await BuildAFRMasterHistoryAsync(input.GID, waitInsertHouseGids, "新增", 0, "新增了单据", tran);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (waitDeleteHouseGids.Any())
|
|
|
|
if (waitDeleteHouseGids.Any())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -457,14 +463,18 @@ namespace djy.Service.AFR
|
|
|
|
.WithTransaction(tran)
|
|
|
|
.WithTransaction(tran)
|
|
|
|
.Where(h => waitDeleteHouseGids.Contains(h.GID))
|
|
|
|
.Where(h => waitDeleteHouseGids.Contains(h.GID))
|
|
|
|
.ExecuteAffrowsAsync();
|
|
|
|
.ExecuteAffrowsAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await BuildAFRMasterHistoryAsync(input.GID, waitDeleteHouseGids, "删除", 0, "删除了单据", tran);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (waitUpdateHouseGids.Any())
|
|
|
|
if (waitUpdateHouseGids.Any())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await DbAMS.Update<AFRHouse>()
|
|
|
|
await DbAMS.Update<AFRHouse>()
|
|
|
|
.SetSource(waitUpdateHouseList)
|
|
|
|
.SetSource(waitUpdateHouseList)
|
|
|
|
.IgnoreColumns(h => new { h.StateIsMatched, h.StateIsAccept })
|
|
|
|
.IgnoreColumns(h => new { h.StateIsMatched, h.StateIsAccept, h.StateIsSend, h.NewNotice })
|
|
|
|
.WithTransaction(tran)
|
|
|
|
.WithTransaction(tran)
|
|
|
|
.ExecuteAffrowsAsync();
|
|
|
|
.ExecuteAffrowsAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await BuildAFRMasterHistoryAsync(input.GID, waitUpdateHouseGids, "修改", 0, "修改了单据", tran);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 箱子执行
|
|
|
|
// 箱子执行
|
|
|
@ -488,28 +498,38 @@ namespace djy.Service.AFR
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
AFRMasterHistory history = BuildAFRMasterHistory(input.GID, "修改", 0, "修改了单据");
|
|
|
|
|
|
|
|
await DbAMS.Insert(history).WithTransaction(tran).ExecuteAffrowsAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
|
tran.Commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return await Get(input.GID);
|
|
|
|
return await Get(input.GID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private AFRMasterHistory BuildAFRMasterHistory(string pid, string state, int type, string remark)
|
|
|
|
private async Task BuildAFRMasterHistoryAsync(string mid, IEnumerable<string> hids, string state, int type, string remark, DbTransaction tran = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var history = new AFRMasterHistory()
|
|
|
|
List<AFRMasterHistory> list = new(hids.Count());
|
|
|
|
{
|
|
|
|
foreach (string hid in hids)
|
|
|
|
GID = Guid.NewGuid().ToString(),
|
|
|
|
{
|
|
|
|
CreateTime = DateTime.Now,
|
|
|
|
var history = new AFRMasterHistory()
|
|
|
|
Operator = User.ShowName,
|
|
|
|
{
|
|
|
|
PID = pid,
|
|
|
|
GID = Guid.NewGuid().ToString(),
|
|
|
|
State = state,
|
|
|
|
CreateTime = DateTime.Now,
|
|
|
|
Type = Convert.ToByte(type)
|
|
|
|
Operator = User.ShowName,
|
|
|
|
};
|
|
|
|
MID = mid,
|
|
|
|
history.Remark = $"{history.Operator}于{(DateTime)history.CreateTime:yyyy-MM-dd HH:mm:ss}{remark}";
|
|
|
|
HID = hid,
|
|
|
|
return history;
|
|
|
|
State = state,
|
|
|
|
|
|
|
|
Type = Convert.ToByte(type)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
history.Remark = $"{history.Operator}于{(DateTime)history.CreateTime:yyyy-MM-dd HH:mm:ss}{remark}";
|
|
|
|
|
|
|
|
list.Add(history);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tran == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await DbAMS.Insert(list).ExecuteAffrowsAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await DbAMS.Insert(list).WithTransaction(tran).ExecuteAffrowsAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task Delete(string ids)
|
|
|
|
public async Task Delete(string ids)
|
|
|
@ -545,7 +565,7 @@ namespace djy.Service.AFR
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<string> Send(string ids, string hids, int sendType)
|
|
|
|
public async Task<string> Send(string ids, string hids, int sendType)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
//return "发送成功";
|
|
|
|
#region 查询电子口岸的请求参数
|
|
|
|
#region 查询电子口岸的请求参数
|
|
|
|
var paramSets = await DbBus.Get(DbList.djydb).Select<ParamSet>().Where(x => x.PARAMNAME == "AFRURL" || x.PARAMNAME == "AFRAccount" || x.PARAMNAME == "AFRKey").ToListAsync(p => new
|
|
|
|
var paramSets = await DbBus.Get(DbList.djydb).Select<ParamSet>().Where(x => x.PARAMNAME == "AFRURL" || x.PARAMNAME == "AFRAccount" || x.PARAMNAME == "AFRKey").ToListAsync(p => new
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -582,7 +602,7 @@ namespace djy.Service.AFR
|
|
|
|
var houseGids = houseAll.Select(h => h.GID);
|
|
|
|
var houseGids = houseAll.Select(h => h.GID);
|
|
|
|
cntrAll = await DbAMS.Select<AFRCntrno>().Where(c => houseGids.Contains(c.PID)).ToListAsync();
|
|
|
|
cntrAll = await DbAMS.Select<AFRCntrno>().Where(c => houseGids.Contains(c.PID)).ToListAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sendType is 2 or 3)
|
|
|
|
else if (sendType is 2 or 3 or 4)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(hids))
|
|
|
|
if (string.IsNullOrEmpty(hids))
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -602,20 +622,20 @@ namespace djy.Service.AFR
|
|
|
|
var housePids = houseAll.Select(h => h.PID);
|
|
|
|
var housePids = houseAll.Select(h => h.PID);
|
|
|
|
masterAll = await DbAMS.Select<AFRMaster>().Where(m => m.IsDel == false && housePids.Contains(m.GID)).ToListAsync();
|
|
|
|
masterAll = await DbAMS.Select<AFRMaster>().Where(m => m.IsDel == false && housePids.Contains(m.GID)).ToListAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sendType is 4)
|
|
|
|
//else if (sendType is 4)
|
|
|
|
{
|
|
|
|
//{
|
|
|
|
if (string.IsNullOrEmpty(hids))
|
|
|
|
// if (string.IsNullOrEmpty(hids))
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
throw new ArgumentNullException(nameof(hids));
|
|
|
|
// throw new ArgumentNullException(nameof(hids));
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
var hidArr = hids.Split(',');
|
|
|
|
// var hidArr = hids.Split(',');
|
|
|
|
|
|
|
|
|
|
|
|
houseAll = await DbAMS.Select<AFRHouse>().Where(h => h.IsDel == false && hidArr.Contains(h.GID)).ToListAsync();
|
|
|
|
// houseAll = await DbAMS.Select<AFRHouse>().Where(h => h.IsDel == false && hidArr.Contains(h.GID)).ToListAsync();
|
|
|
|
if (houseAll.Count != hidArr.Length)
|
|
|
|
// if (houseAll.Count != hidArr.Length)
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
throw new Exception("所选记录有些已被删除,请刷新页面后重试");
|
|
|
|
// throw new Exception("所选记录有些已被删除,请刷新页面后重试");
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder messageBuilder = new();
|
|
|
|
StringBuilder messageBuilder = new();
|
|
|
@ -630,13 +650,39 @@ namespace djy.Service.AFR
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#region 发送前的参数验证
|
|
|
|
#region 发送前的各项校验
|
|
|
|
|
|
|
|
// 判断是否有分单数据
|
|
|
|
houseList = houseAll.Where(h => h.PID == masterItem.GID).ToList() ?? throw new Exception("分单为空");
|
|
|
|
houseList = houseAll.Where(h => h.PID == masterItem.GID).ToList() ?? throw new Exception("分单为空");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 验证接口要求
|
|
|
|
if (masterItem.FilingType == "Tranship" && (string.IsNullOrWhiteSpace(masterItem.LastForeignHarbourCode) || string.IsNullOrWhiteSpace(masterItem.LastForeignHarbour)))
|
|
|
|
if (masterItem.FilingType == "Tranship" && (string.IsNullOrWhiteSpace(masterItem.LastForeignHarbourCode) || string.IsNullOrWhiteSpace(masterItem.LastForeignHarbour)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new Exception("当【申报运输类型】为【Tranship】时,【交货地全称】与【交货地五字码】为必填项");
|
|
|
|
throw new Exception("当【申报运输类型】为【Tranship】时,【交货地全称】与【交货地五字码】为必填项");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 验证账户余额是否充足
|
|
|
|
|
|
|
|
var fin = new FinanceService();
|
|
|
|
|
|
|
|
var getfinrs = fin.CheckBalance(new CustFee
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CARRIER = masterItem.ShipCompanyCode,
|
|
|
|
|
|
|
|
//ETD = null,
|
|
|
|
|
|
|
|
//VOYNO = masterItem.Voyno,
|
|
|
|
|
|
|
|
//VESSEL = masterItem.Vessel,
|
|
|
|
|
|
|
|
//HBLNO = item.HBLNo,
|
|
|
|
|
|
|
|
//SENDUSERID = user.GID,
|
|
|
|
|
|
|
|
LURURENID = User.GID,
|
|
|
|
|
|
|
|
//CtnrCount = ,
|
|
|
|
|
|
|
|
//CtnrInfo = string.Empty,
|
|
|
|
|
|
|
|
BSTYPE = BusinessType.AFR_REPORT,
|
|
|
|
|
|
|
|
SENDTYPE = sendType switch { 1 or 2 => 0, 3 => 1, _ => throw new NotImplementedException() },
|
|
|
|
|
|
|
|
//BSNO = oid.ToString(),
|
|
|
|
|
|
|
|
//MBLNO = master.MBLNO.ToString(),
|
|
|
|
|
|
|
|
}, houseList.Count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!getfinrs.Status)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new Exception(getfinrs.Message);
|
|
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
AFRRequestDto requestDto = new AFRRequestDto()
|
|
|
|
AFRRequestDto requestDto = new AFRRequestDto()
|
|
|
@ -765,6 +811,47 @@ namespace djy.Service.AFR
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string tip = $"发送成功!船东提单号:【{masterItem.MBLNO}】货代提单号:【{string.Join("、", houseList.Select(h => h.HouseBillNo))}】{Environment.NewLine}";
|
|
|
|
string tip = $"发送成功!船东提单号:【{masterItem.MBLNO}】货代提单号:【{string.Join("、", houseList.Select(h => h.HouseBillNo))}】{Environment.NewLine}";
|
|
|
|
messageBuilder.Append(tip);
|
|
|
|
messageBuilder.Append(tip);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 扣费、保存状态
|
|
|
|
|
|
|
|
foreach (AFRHouse dealHouseItem in houseList)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var expendResult = fin.Expend(new CustFee
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CARRIER = masterItem.ShipCompanyCode,
|
|
|
|
|
|
|
|
ETD = null,
|
|
|
|
|
|
|
|
VOYNO = masterItem.Voyno,
|
|
|
|
|
|
|
|
VESSEL = masterItem.Vessel,
|
|
|
|
|
|
|
|
HBLNO = dealHouseItem.HouseBillNo,
|
|
|
|
|
|
|
|
SENDUSERID = User.GID,
|
|
|
|
|
|
|
|
LURURENID = User.GID,
|
|
|
|
|
|
|
|
CtnrCount = dealHouseItem.CntrList?.Count ?? 0,
|
|
|
|
|
|
|
|
CtnrInfo = string.Empty,
|
|
|
|
|
|
|
|
BSTYPE = BusinessType.AFR_REPORT,
|
|
|
|
|
|
|
|
SENDTYPE = sendType switch { 1 or 2 => 0, 3 => 1, _ => -1 },
|
|
|
|
|
|
|
|
BSNO = masterItem.GID,
|
|
|
|
|
|
|
|
MBLNO = masterItem.MBLNO,
|
|
|
|
|
|
|
|
}, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!expendResult.Status)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
logger.LogError($"执行扣费失败,{logGuid},异常信息:{expendResult.Message}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
logger.LogError($"执行扣费时发生未知异常,{logGuid},异常信息:{ex.Message}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 保存状态
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 记录历史
|
|
|
|
|
|
|
|
var state = sendType switch { 1 => "新增发送成功", 2 => "重发成功", 3 => "修改发送成功", _ => "" };
|
|
|
|
|
|
|
|
await BuildAFRMasterHistoryAsync(masterItem.GID, houseList.Select(h => h.GID), state, 0, "发送了单据");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -778,6 +865,13 @@ namespace djy.Service.AFR
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// 记录历史
|
|
|
|
|
|
|
|
var state = sendType switch { 1 => "新增发送失败", 2 => "重发失败", 3 => "修改发送失败", _ => "" };
|
|
|
|
|
|
|
|
await BuildAFRMasterHistoryAsync(masterItem.GID, houseList.Select(h => h.GID), state, 0, $"发送单据失败,失败原因:{ex.Message}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 保存状态
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 构建响应
|
|
|
|
string tip;
|
|
|
|
string tip;
|
|
|
|
if (houseList == null)
|
|
|
|
if (houseList == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -788,6 +882,8 @@ namespace djy.Service.AFR
|
|
|
|
tip = $"发送失败!船东提单号:【{masterItem.MBLNO}】货代提单号:【{string.Join("、", houseList.Select(h => h.HouseBillNo))}】,原因:{ex.Message}{Environment.NewLine}";
|
|
|
|
tip = $"发送失败!船东提单号:【{masterItem.MBLNO}】货代提单号:【{string.Join("、", houseList.Select(h => h.HouseBillNo))}】,原因:{ex.Message}{Environment.NewLine}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
messageBuilder.Append(tip);
|
|
|
|
messageBuilder.Append(tip);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 继续处理下一单
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -797,6 +893,22 @@ namespace djy.Service.AFR
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
#region 发送前的各项校验
|
|
|
|
|
|
|
|
// 验证账户余额是否充足
|
|
|
|
|
|
|
|
var fin = new FinanceService();
|
|
|
|
|
|
|
|
var getfinrs = fin.CheckBalance(new CustFee
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LURURENID = User.GID,
|
|
|
|
|
|
|
|
BSTYPE = BusinessType.AFR_REPORT,
|
|
|
|
|
|
|
|
SENDTYPE = 5,
|
|
|
|
|
|
|
|
}, houseAll.Count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!getfinrs.Status)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new Exception(getfinrs.Message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
string hbnos = string.Join(',', houseAll.Select(h => h.HouseBillNo));
|
|
|
|
string hbnos = string.Join(',', houseAll.Select(h => h.HouseBillNo));
|
|
|
|
var businessParam = new Dictionary<string, string>()
|
|
|
|
var businessParam = new Dictionary<string, string>()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -813,45 +925,88 @@ namespace djy.Service.AFR
|
|
|
|
|
|
|
|
|
|
|
|
logger.LogInformation($"请求宁波电子口岸API,{logGuid},响应:{response}");
|
|
|
|
logger.LogInformation($"请求宁波电子口岸API,{logGuid},响应:{response}");
|
|
|
|
|
|
|
|
|
|
|
|
//JObject rlt = JObject.Parse(response);
|
|
|
|
JObject rlt = JObject.Parse(response);
|
|
|
|
//var code = rlt.GetValue("code")?.ToString();
|
|
|
|
var code = rlt.GetValue("code")?.ToString();
|
|
|
|
//var msg = rlt.GetValue("msg")?.ToString();
|
|
|
|
var msg = rlt.GetValue("msg")?.ToString();
|
|
|
|
//if (code == "T")
|
|
|
|
if (code == "T")
|
|
|
|
//{
|
|
|
|
{
|
|
|
|
// var data = rlt["data"] as JObject;
|
|
|
|
var data = rlt["data"] as JObject;
|
|
|
|
|
|
|
|
|
|
|
|
// var code2 = data.GetValue("code")?.ToString();
|
|
|
|
var code2 = data.GetValue("code")?.ToString();
|
|
|
|
// var msg2 = data.GetValue("msg")?.ToString();
|
|
|
|
var msg2 = data.GetValue("msg")?.ToString();
|
|
|
|
// var data2 = data.GetValue("data")?.ToString();
|
|
|
|
var data2 = data.GetValue("data")?.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
// if (code2 == "1")
|
|
|
|
if (code2 == "1")
|
|
|
|
// {
|
|
|
|
{
|
|
|
|
// string tip = $"发送成功!船东提单号:【{masterItem.MBLNO}】货代提单号:【{string.Join("、", houseList.Select(h => h.HouseBillNo))}】{Environment.NewLine}";
|
|
|
|
string tip = $"发送成功!货代提单号:【{string.Join("、", houseAll.Select(h => h.HouseBillNo))}】{Environment.NewLine}";
|
|
|
|
// messageBuilder.Append(tip);
|
|
|
|
messageBuilder.Append(tip);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else
|
|
|
|
#region 扣费、记录历史、保存状态
|
|
|
|
// {
|
|
|
|
foreach (AFRHouse expendHouseItem in houseAll)
|
|
|
|
// throw new Exception($"电子口岸接口返回失败结果(code:{code2},msg:{msg})");
|
|
|
|
{
|
|
|
|
// }
|
|
|
|
AFRMaster expendMasterItem = masterAll.First(m => m.GID == expendHouseItem.PID);
|
|
|
|
//}
|
|
|
|
// 扣费
|
|
|
|
//else
|
|
|
|
try
|
|
|
|
//{
|
|
|
|
{
|
|
|
|
// throw new Exception($"电子口岸接口调用失败(msg:{msg})");
|
|
|
|
var expendResult = fin.Expend(new CustFee
|
|
|
|
//}
|
|
|
|
{
|
|
|
|
|
|
|
|
CARRIER = expendMasterItem.ShipCompanyCode,
|
|
|
|
|
|
|
|
ETD = null,
|
|
|
|
|
|
|
|
VOYNO = expendMasterItem.Voyno,
|
|
|
|
|
|
|
|
VESSEL = expendMasterItem.Vessel,
|
|
|
|
|
|
|
|
HBLNO = expendHouseItem.HouseBillNo,
|
|
|
|
|
|
|
|
SENDUSERID = User.GID,
|
|
|
|
|
|
|
|
LURURENID = User.GID,
|
|
|
|
|
|
|
|
CtnrCount = cntrAll.Count(c => c.PID == expendHouseItem.GID),
|
|
|
|
|
|
|
|
CtnrInfo = string.Empty,
|
|
|
|
|
|
|
|
BSTYPE = BusinessType.AFR_REPORT,
|
|
|
|
|
|
|
|
SENDTYPE = 5,
|
|
|
|
|
|
|
|
BSNO = expendMasterItem.GID,
|
|
|
|
|
|
|
|
MBLNO = expendMasterItem.MBLNO,
|
|
|
|
|
|
|
|
}, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!expendResult.Status)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
logger.LogError($"执行扣费失败,{logGuid},异常信息:{expendResult.Message}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
logger.LogError($"执行扣费时发生未知异常,{logGuid},异常信息:{ex.Message}");
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 记录历史
|
|
|
|
|
|
|
|
await BuildAFRMasterHistoryAsync(expendMasterItem.GID, new string[] { expendHouseItem.GID }, "删除发送成功", 0, "删除发送了单据");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 保存状态
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new Exception($"电子口岸接口返回失败结果(code:{code2},msg:{msg})");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new Exception($"电子口岸接口调用失败(msg:{msg})");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//string tip;
|
|
|
|
// 构建响应
|
|
|
|
//if (houseList == null)
|
|
|
|
string tip = $"发送失败!货代提单号:【{string.Join("、", houseAll.Select(h => h.HouseBillNo))}】,原因:{ex.Message}";
|
|
|
|
//{
|
|
|
|
messageBuilder.Append(tip);
|
|
|
|
// tip = $"发送失败!船东提单号:【{masterItem.MBLNO}】,原因:{ex.Message}{Environment.NewLine}";
|
|
|
|
|
|
|
|
//}
|
|
|
|
// 记录历史
|
|
|
|
//else
|
|
|
|
houseAll.ForEach(async h =>
|
|
|
|
//{
|
|
|
|
{
|
|
|
|
// tip = $"发送失败!船东提单号:【{masterItem.MBLNO}】货代提单号:【{string.Join("、", houseList.Select(h => h.HouseBillNo))}】,原因:{ex.Message}{Environment.NewLine}";
|
|
|
|
await BuildAFRMasterHistoryAsync(h.PID, new string[] { h.GID }, "删除发送失败", 0, $"删除发送单据失败,原因:{ex.Message}");
|
|
|
|
//}
|
|
|
|
});
|
|
|
|
//messageBuilder.Append(tip);
|
|
|
|
|
|
|
|
//continue;
|
|
|
|
// 保存状态
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
@ -928,10 +1083,11 @@ namespace djy.Service.AFR
|
|
|
|
throw new NotImplementedException();
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<List<AFRMasterHistory>> GetHistory(string id)
|
|
|
|
public async Task<List<AFRMasterHistory>> GetHistory(string mid, string hid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var data = await DbAMS.Select<AFRMasterHistory>()
|
|
|
|
var data = await DbAMS.Select<AFRMasterHistory>()
|
|
|
|
.Where(h => h.PID == id)
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(mid), h => h.MID == mid)
|
|
|
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(hid), h => h.HID == hid)
|
|
|
|
.ToListAsync();
|
|
|
|
.ToListAsync();
|
|
|
|
return data;
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|