|
|
@ -1,5 +1,4 @@
|
|
|
|
using AutoMapper;
|
|
|
|
using Common;
|
|
|
|
using Common;
|
|
|
|
|
|
|
|
using Common.Const;
|
|
|
|
using Common.Const;
|
|
|
|
using Common.DJYModel;
|
|
|
|
using Common.DJYModel;
|
|
|
|
using Common.Extensions;
|
|
|
|
using Common.Extensions;
|
|
|
@ -14,24 +13,14 @@ using djy.Model.Ams;
|
|
|
|
using djy.Model.AmsDto;
|
|
|
|
using djy.Model.AmsDto;
|
|
|
|
using djy.Service.DjyService;
|
|
|
|
using djy.Service.DjyService;
|
|
|
|
using FreeSql;
|
|
|
|
using FreeSql;
|
|
|
|
using Google.Protobuf.WellKnownTypes;
|
|
|
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using NETCore.Encrypt.Internal;
|
|
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
|
|
|
using Org.BouncyCastle.Ocsp;
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
|
|
|
|
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.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
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -224,7 +213,7 @@ namespace djy.Service.AFR
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.UserId), (m) => m.UserID == input.UserId)
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.UserId), (m) => m.UserID == input.UserId)
|
|
|
|
// 下面是前端传来的条件
|
|
|
|
// 下面是前端传来的条件
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.MBLNO), (m) => m.MBLNO.Contains(input.MBLNO))
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.MBLNO), (m) => m.MBLNO.Contains(input.MBLNO))
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.UserName), (m) => m.UserName.Contains(input.UserName))
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.UserName), (m) => m.LastUpdateUserName.Contains(input.UserName))
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.DischargeHarbour), (m) => m.DischargeHarbour.Contains(input.DischargeHarbour))
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.DischargeHarbour), (m) => m.DischargeHarbour.Contains(input.DischargeHarbour))
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.ShipCompanyName), (m) => m.ShipCompanyName.Contains(input.ShipCompanyName))
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.ShipCompanyName), (m) => m.ShipCompanyName.Contains(input.ShipCompanyName))
|
|
|
|
.WhereIf(input.CreateTimeStart != null, (m) => m.CreateTime >= input.CreateTimeStart)
|
|
|
|
.WhereIf(input.CreateTimeStart != null, (m) => m.CreateTime >= input.CreateTimeStart)
|
|
|
@ -255,7 +244,7 @@ namespace djy.Service.AFR
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.UserId), (m, h) => m.UserID == input.UserId)
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.UserId), (m, h) => m.UserID == input.UserId)
|
|
|
|
// 下面是前端传来的条件
|
|
|
|
// 下面是前端传来的条件
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.MBLNO), (m, h) => m.MBLNO.Contains(input.MBLNO))
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.MBLNO), (m, h) => m.MBLNO.Contains(input.MBLNO))
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.UserName), (m, h) => m.UserName.Contains(input.UserName))
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.UserName), (m, h) => h.LastUpdateUserName.Contains(input.UserName))
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.DischargeHarbour), (m, h) => m.DischargeHarbour.Contains(input.DischargeHarbour))
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.DischargeHarbour), (m, h) => m.DischargeHarbour.Contains(input.DischargeHarbour))
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.ShipCompanyName), (m, h) => m.ShipCompanyName.Contains(input.ShipCompanyName))
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(input.ShipCompanyName), (m, h) => m.ShipCompanyName.Contains(input.ShipCompanyName))
|
|
|
|
.WhereIf(input.CreateTimeStart != null, (m, h) => m.CreateTime >= input.CreateTimeStart)
|
|
|
|
.WhereIf(input.CreateTimeStart != null, (m, h) => m.CreateTime >= input.CreateTimeStart)
|
|
|
@ -363,6 +352,19 @@ namespace djy.Service.AFR
|
|
|
|
input.CompID = User.CompId;
|
|
|
|
input.CompID = User.CompId;
|
|
|
|
input.CompName = User.CompName;
|
|
|
|
input.CompName = User.CompName;
|
|
|
|
input.CreateTime = nowTime;
|
|
|
|
input.CreateTime = nowTime;
|
|
|
|
|
|
|
|
input.StateIsSend = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (await DbAMS.Select<AFRMaster>().AnyAsync(m => m.MBLNO == input.MBLNO))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new Exception("已存在相同的船东提单号");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var hblNoList = input.HouseList.Select(h => h.HouseBillNo).ToList();
|
|
|
|
|
|
|
|
if (await DbAMS.Select<AFRHouse>().AnyAsync(h => hblNoList.Contains(h.HouseBillNo)))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new Exception("已存在相同的货代提单号");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
input.HouseList.ForEach(house =>
|
|
|
|
input.HouseList.ForEach(house =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
house.GID = Guid.NewGuid().ToString();
|
|
|
|
house.GID = Guid.NewGuid().ToString();
|
|
|
@ -372,6 +374,8 @@ namespace djy.Service.AFR
|
|
|
|
house.CreateTime = nowTime;
|
|
|
|
house.CreateTime = nowTime;
|
|
|
|
house.LastUpdate = nowTime;
|
|
|
|
house.LastUpdate = nowTime;
|
|
|
|
house.MBLNO = input.MBLNO;
|
|
|
|
house.MBLNO = input.MBLNO;
|
|
|
|
|
|
|
|
house.StateIsAccept = house.StateIsMatched = house.StateIsSend = house.StateIsDelete = false;
|
|
|
|
|
|
|
|
house.NewNotice = "";
|
|
|
|
|
|
|
|
|
|
|
|
// 将null换为空对象,避免后续处理null值麻烦
|
|
|
|
// 将null换为空对象,避免后续处理null值麻烦
|
|
|
|
house.CntrList ??= new List<AFRCntrno>();
|
|
|
|
house.CntrList ??= new List<AFRCntrno>();
|
|
|
@ -387,9 +391,16 @@ namespace djy.Service.AFR
|
|
|
|
|
|
|
|
|
|
|
|
await using DbTransaction tran = await GetDbAmsTransaction();
|
|
|
|
await using DbTransaction tran = await GetDbAmsTransaction();
|
|
|
|
|
|
|
|
|
|
|
|
await DbAMS.Insert(input).ExecuteAffrowsAsync();
|
|
|
|
await DbAMS.Insert(input)
|
|
|
|
await DbAMS.Insert(input.HouseList).WithTransaction(tran).ExecuteAffrowsAsync();
|
|
|
|
.ExecuteAffrowsAsync();
|
|
|
|
await DbAMS.Insert(input.HouseList.SelectMany(h => h.CntrList)).WithTransaction(tran).ExecuteAffrowsAsync();
|
|
|
|
|
|
|
|
|
|
|
|
await DbAMS.Insert(input.HouseList)
|
|
|
|
|
|
|
|
.WithTransaction(tran)
|
|
|
|
|
|
|
|
.ExecuteAffrowsAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await DbAMS.Insert(input.HouseList.SelectMany(h => h.CntrList))
|
|
|
|
|
|
|
|
.WithTransaction(tran)
|
|
|
|
|
|
|
|
.ExecuteAffrowsAsync();
|
|
|
|
|
|
|
|
|
|
|
|
await SaveHistoryAsync(input.GID, input.HouseList, "新增", 0, "创建了单据", tran);
|
|
|
|
await SaveHistoryAsync(input.GID, input.HouseList, "新增", 0, "创建了单据", tran);
|
|
|
|
|
|
|
|
|
|
|
@ -398,6 +409,11 @@ namespace djy.Service.AFR
|
|
|
|
// 修改
|
|
|
|
// 修改
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (await DbAMS.Select<AFRMaster>().AnyAsync(m => m.MBLNO == input.MBLNO && m.GID != input.GID))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new Exception("已存在相同的船东提单号");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 下面这段的3个作用:
|
|
|
|
// 下面这段的3个作用:
|
|
|
|
// 1. 将null换为空对象,避免后续处理null值麻烦
|
|
|
|
// 1. 将null换为空对象,避免后续处理null值麻烦
|
|
|
|
// 2. 如果主键为null,说明是新加的数据,这时候需要手动给GID、PID、CreateTime赋值
|
|
|
|
// 2. 如果主键为null,说明是新加的数据,这时候需要手动给GID、PID、CreateTime赋值
|
|
|
@ -408,7 +424,7 @@ namespace djy.Service.AFR
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
input.HouseList.ForEach(house =>
|
|
|
|
foreach (var house in input.HouseList)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
house.LastUpdate = nowTime;
|
|
|
|
house.LastUpdate = nowTime;
|
|
|
|
house.LastUpdateUserID = User.GID;
|
|
|
|
house.LastUpdateUserID = User.GID;
|
|
|
@ -419,6 +435,15 @@ namespace djy.Service.AFR
|
|
|
|
house.PID = input.GID;
|
|
|
|
house.PID = input.GID;
|
|
|
|
house.CreateTime = nowTime;
|
|
|
|
house.CreateTime = nowTime;
|
|
|
|
house.MBLNO = input.MBLNO;
|
|
|
|
house.MBLNO = input.MBLNO;
|
|
|
|
|
|
|
|
house.StateIsAccept = house.StateIsMatched = house.StateIsSend = house.StateIsDelete = false;
|
|
|
|
|
|
|
|
house.NewNotice = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (await DbAMS.Select<AFRHouse>().AnyAsync(h => h.HouseBillNo == house.HouseBillNo && h.GID != house.GID))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new Exception("已存在相同的货代提单号");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (house.CntrList == null)
|
|
|
|
if (house.CntrList == null)
|
|
|
@ -439,7 +464,7 @@ namespace djy.Service.AFR
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 对分单数据统计出要执行的操作,判断哪些数据是 新增/修改/删除
|
|
|
|
#region 对分单数据统计出要执行的操作,判断哪些数据是 新增/修改/删除
|
|
|
@ -683,7 +708,7 @@ namespace djy.Service.AFR
|
|
|
|
if (houseList.Any(h => h.StateIsDelete == false))
|
|
|
|
if (houseList.Any(h => h.StateIsDelete == false))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string tip = string.Join("、", houseList.Where(h => h.StateIsDelete == false).Select(h => h.HouseBillNo).ToList());
|
|
|
|
string tip = string.Join("、", houseList.Where(h => h.StateIsDelete == false).Select(h => h.HouseBillNo).ToList());
|
|
|
|
throw new Exception($"所选分单中存在未“删除发送”的记录,分单号:【{tip}】,请重新选择(只有“删除发送”成功的,才能进行“重发”操作)");
|
|
|
|
throw new Exception($"只有“删除发送”成功的,才能进行“重发”操作,所选分单中存在未“删除发送”的记录,分单号:【{tip}】");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 如果操作类型为“修改”,则待发送记录不能有“已删除”的
|
|
|
|
// 如果操作类型为“修改”,则待发送记录不能有“已删除”的
|
|
|
@ -692,7 +717,7 @@ namespace djy.Service.AFR
|
|
|
|
if (houseList.Any(h => h.StateIsDelete))
|
|
|
|
if (houseList.Any(h => h.StateIsDelete))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string tip = string.Join("、", houseList.Where(h => h.StateIsDelete).Select(h => h.HouseBillNo).ToList());
|
|
|
|
string tip = string.Join("、", houseList.Where(h => h.StateIsDelete).Select(h => h.HouseBillNo).ToList());
|
|
|
|
throw new Exception($"所选分单中存在已经“删除发送”的记录,分单号:【{tip}】,请重新选择(已“删除发送”的记录需要先进行“重发”,才能进行 “修改发送”或“删除发送” 操作)");
|
|
|
|
throw new Exception($"已“删除发送”的记录需要先进行“重发”,才能进行 “修改发送”或“删除发送” 操作,所选分单中存在已经“删除发送”的记录,分单号:【{tip}】");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 记录状态是回执成功的,才可以修改(暂不校验)
|
|
|
|
// 记录状态是回执成功的,才可以修改(暂不校验)
|
|
|
@ -836,7 +861,7 @@ namespace djy.Service.AFR
|
|
|
|
|
|
|
|
|
|
|
|
if (code2 == "1")
|
|
|
|
if (code2 == "1")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
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 扣费、保存状态
|
|
|
|
#region 扣费、保存状态
|
|
|
@ -921,11 +946,11 @@ namespace djy.Service.AFR
|
|
|
|
string tip;
|
|
|
|
string tip;
|
|
|
|
if (houseList == null)
|
|
|
|
if (houseList == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tip = $"发送失败!船东提单号:【{masterItem.MBLNO}】,原因:{ex.Message}{Environment.NewLine}";
|
|
|
|
tip = $"● 发送失败!船东提单号:【{masterItem.MBLNO}】,原因:{ex.Message}{Environment.NewLine}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
@ -993,7 +1018,7 @@ namespace djy.Service.AFR
|
|
|
|
|
|
|
|
|
|
|
|
if (code2 == "1")
|
|
|
|
if (code2 == "1")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string tip = $"发送成功!货代提单号:【{string.Join("、", houseAll.Select(h => h.HouseBillNo))}】{Environment.NewLine}";
|
|
|
|
string tip = $"● 发送成功!货代提单号:【{string.Join("、", houseAll.Select(h => h.HouseBillNo))}】{Environment.NewLine}";
|
|
|
|
messageBuilder.Append(tip);
|
|
|
|
messageBuilder.Append(tip);
|
|
|
|
|
|
|
|
|
|
|
|
#region 扣费、记录历史、保存状态
|
|
|
|
#region 扣费、记录历史、保存状态
|
|
|
@ -1058,7 +1083,7 @@ namespace djy.Service.AFR
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// 构建响应
|
|
|
|
// 构建响应
|
|
|
|
string tip = $"发送失败!货代提单号:【{string.Join("、", houseAll.Select(h => h.HouseBillNo))}】,原因:{ex.Message}";
|
|
|
|
string tip = $"● 发送失败!货代提单号:【{string.Join("、", houseAll.Select(h => h.HouseBillNo))}】,原因:{ex.Message}";
|
|
|
|
messageBuilder.Append(tip);
|
|
|
|
messageBuilder.Append(tip);
|
|
|
|
|
|
|
|
|
|
|
|
// 记录历史
|
|
|
|
// 记录历史
|
|
|
@ -1131,10 +1156,15 @@ namespace djy.Service.AFR
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<List<AFRMasterHistory>> GetHistory(string id, string hid)
|
|
|
|
public async Task<List<AFRMasterHistory>> GetHistory(string pid, string hid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(pid) && string.IsNullOrWhiteSpace(hid))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new ArgumentException(nameof(pid) + "或" + nameof(hid));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var data = await DbAMS.Select<AFRMasterHistory>()
|
|
|
|
var data = await DbAMS.Select<AFRMasterHistory>()
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(id), h => h.PID == id)
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(pid), h => h.PID == pid)
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(hid), h => h.HID == hid)
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(hid), h => h.HID == hid)
|
|
|
|
.OrderByDescending(h => h.CreateTime)
|
|
|
|
.OrderByDescending(h => h.CreateTime)
|
|
|
|
.ToListAsync();
|
|
|
|
.ToListAsync();
|
|
|
|