1.AFR发送时验证字段补充 2.程序启动时清空字典缓存

master
zhangxiaofeng 10 months ago
parent e076e58132
commit 651b2ff9c5

@ -221,7 +221,7 @@ namespace djy.Service.AFR
// 下面是前端传来的条件 // 下面是前端传来的条件
.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.LastUpdateUserName.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.DischargeHarbourCode.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)
.WhereIf(input.CreateTimeEnd != null, (m) => m.CreateTime <= input.CreateTimeEnd); .WhereIf(input.CreateTimeEnd != null, (m) => m.CreateTime <= input.CreateTimeEnd);
@ -335,6 +335,13 @@ namespace djy.Service.AFR
AFRMaster oldMaster = null; AFRMaster oldMaster = null;
var nowTime = DateTime.Now; var nowTime = DateTime.Now;
#region 数据校验
if (string.IsNullOrWhiteSpace(input.MBLNO))
{
throw new Exception($"船东提单号不能为空");
}
#endregion
if (string.IsNullOrEmpty(input.GID)) if (string.IsNullOrEmpty(input.GID))
{ {
type = 0; type = 0;
@ -367,6 +374,10 @@ namespace djy.Service.AFR
} }
var hblNoList = input.HouseList.Select(h => h.HouseBillNo).ToList(); var hblNoList = input.HouseList.Select(h => h.HouseBillNo).ToList();
if (hblNoList.Any(h => string.IsNullOrWhiteSpace(h)))
{
throw new Exception("货代提单号不能为空");
}
if (hblNoList.Any() && await DbAMS.Select<AFRHouse>().AnyAsync(h => hblNoList.Contains(h.HouseBillNo))) if (hblNoList.Any() && await DbAMS.Select<AFRHouse>().AnyAsync(h => hblNoList.Contains(h.HouseBillNo)))
{ {
throw new Exception("已存在相同的货代提单号"); throw new Exception("已存在相同的货代提单号");
@ -697,6 +708,92 @@ namespace djy.Service.AFR
// 原始发送 重发 修改 // 原始发送 重发 修改
if (sendType is 1 or 2 or 3) if (sendType is 1 or 2 or 3)
{ {
// 批量检查主单字段是否为空
foreach (var masterItem in masterAll)
{
var checkEmptyFields = new List<(string, string)>
{
(masterItem.MBLNO, "船东提单号"),
(masterItem.Vessel, "船名"),
(masterItem.Voyno, "航次"),
(masterItem.LoadHarbour, "装货港"),
(masterItem.LoadHarbourCode, "装货港五字码"),
(masterItem.DischargeHarbour, "卸货港"),
(masterItem.DischargeHarbourCode, "卸货港五字码"),
(masterItem.EstimatedArrivalTime?.ToString(), "预计到达时间"),
(masterItem.ShipCompanyCode, "船公司"),
(masterItem.Clause, "运输条款"),
(masterItem.ConsignmentType, "整箱/拼箱"),
(masterItem.FilingType, "申报运输类型"),
(masterItem.LastForeignHarbour, "交货地全称"),
(masterItem.LastForeignHarbourCode, "交货地五字码"),
};
foreach (var (value, name) in checkEmptyFields)
{
if (string.IsNullOrWhiteSpace(value))
{
throw new Exception($"提单号【{masterItem.MBLNO}】的{name}不能为空");
}
}
}
// 批量检查分单字段是否为空
foreach (var house in houseAll)
{
var checkEmptyFields2 = new List<(string, string)>
{
(house.HouseBillNo, "货代提单号"),
(house.SendName, "发货人名称"),
(house.SendCountryCode, "发货人国家代码"),
(house.SendCountry, "发货人国家"),
(house.SendCity, "发货人城市"),
(house.SendAddress, "发货人地址"),
(house.SendTel, "发货人电话"),
(house.ReceiveName, "收货人名称"),
(house.ReceiveCountryCode, "收货人国家代码"),
(house.ReceiveCountry, "收货人国家"),
(house.ReceiveCity, "收货人城市"),
(house.ReceiveAddress, "收货人地址"),
(house.ReceiveTel, "收货人电话"),
(house.NotifyName, "通知人名称"),
(house.NotifyCountryCode, "通知人国家代码"),
(house.NotifyCountry, "通知人国家"),
(house.NotifyCity, "通知人城市"),
(house.NotifyAddress, "通知人地址"),
(house.NotifyTel, "通知人电话"),
};
foreach (var (value, name) in checkEmptyFields2)
{
if (string.IsNullOrWhiteSpace(value))
{
throw new Exception($"分单【{house.HouseBillNo}】的{name}不能为空");
}
}
}
// 批量检查箱子字段是否为空
foreach (var cntr in cntrAll)
{
var checkEmptyFields3 = new List<(string, string)>
{
(cntr.EnProductName, "品名"),
(cntr.ShippingMark, "唛头"),
(cntr.ContainerNo, "箱号"),
(cntr.ContainerTypeCode, "箱型"),
(cntr.SealNo, "封号"),
(cntr.Digit?.ToString(), "件数"),
(cntr.GrossWeight?.ToString(), "毛重"),
(cntr.Volume?.ToString(), "体积"),
(cntr.Hscode, "HSCode")
};
foreach (var (value, name) in checkEmptyFields3)
{
if (string.IsNullOrWhiteSpace(value))
{
throw new Exception($"箱号【{cntr.ContainerNo}】的{name}不能为空");
}
}
}
foreach (AFRMaster masterItem in masterAll) foreach (AFRMaster masterItem in masterAll)
{ {
// 待处理的分单 // 待处理的分单

@ -1,5 +1,9 @@
using djy_AfrApi.Milldlewares; using Common.Tools;
using djy_AfrApi.Controllers.Common;
using djy_AfrApi.Milldlewares;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using System.Collections.Generic;
using System.Linq;
namespace djy_AfrApi.Middlewares namespace djy_AfrApi.Middlewares
{ {
@ -42,7 +46,15 @@ namespace djy_AfrApi.Middlewares
/// </summary> /// </summary>
public static IApplicationBuilder UseCommonCacheMiddleware(this IApplicationBuilder app) public static IApplicationBuilder UseCommonCacheMiddleware(this IApplicationBuilder app)
{ {
return app.UseMiddleware<CommonDataCacheMiddleware>(); // 获取CommonController下所有含有RedisCaching特性的方法并将其缓存从Redis中清空
List<System.Reflection.MethodInfo> actions = typeof(CommonController).GetMethods().Where(m => m.GetCustomAttributes(typeof(Attributes.RedisCachingAttribute), false).Length > 0).ToList();
actions.ForEach(m =>
{
string redisKey = m.Name + "Cache";
YsRedisHelp.Del(redisKey);
});
return app.UseMiddleware<CommonDataCacheMiddleware>();
} }
} }
} }

@ -6,7 +6,7 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<_PublishTargetUrl>D:\DJY\Code\djyweb_ams\web\djy_AfrApi\bin\Release\net5.0\publish-windows\</_PublishTargetUrl> <_PublishTargetUrl>D:\DJY\Code\djyweb_ams\web\djy_AfrApi\bin\Release\net5.0\publish-windows\</_PublishTargetUrl>
<History>True|2024-01-25T02:01:36.0649321Z;True|2024-01-23T11:01:55.0706970+08:00;True|2024-01-19T13:34:45.2044545+08:00;True|2024-01-19T11:20:41.9920968+08:00;True|2024-01-08T15:50:46.8011898+08:00;True|2024-01-05T17:51:52.2695558+08:00;True|2024-01-05T17:04:21.5306695+08:00;True|2024-01-05T16:48:05.1050469+08:00;True|2024-01-05T15:13:30.4657789+08:00;True|2024-01-05T15:00:49.5985418+08:00;True|2024-01-05T13:48:06.1634940+08:00;True|2024-01-05T11:59:09.7697688+08:00;True|2024-01-05T11:33:19.2093394+08:00;True|2024-01-05T11:27:31.2454199+08:00;True|2024-01-05T11:20:20.5464568+08:00;True|2024-01-04T18:36:38.8259124+08:00;True|2024-01-04T15:54:57.9348895+08:00;True|2024-01-04T15:44:34.6535493+08:00;False|2024-01-04T15:44:20.9673752+08:00;True|2024-01-04T11:14:33.4379160+08:00;True|2024-01-03T21:54:40.3579096+08:00;True|2024-01-03T21:52:09.6604718+08:00;True|2024-01-03T16:04:13.6208067+08:00;True|2024-01-03T15:07:08.9376581+08:00;True|2024-01-02T10:57:59.7067270+08:00;True|2024-01-02T10:28:44.8223638+08:00;True|2023-12-29T17:26:12.9612280+08:00;</History> <History>True|2024-02-04T06:12:20.2942963Z;True|2024-02-04T14:09:16.2854775+08:00;True|2024-01-25T10:01:36.0649321+08:00;True|2024-01-23T11:01:55.0706970+08:00;True|2024-01-19T13:34:45.2044545+08:00;True|2024-01-19T11:20:41.9920968+08:00;True|2024-01-08T15:50:46.8011898+08:00;True|2024-01-05T17:51:52.2695558+08:00;True|2024-01-05T17:04:21.5306695+08:00;True|2024-01-05T16:48:05.1050469+08:00;True|2024-01-05T15:13:30.4657789+08:00;True|2024-01-05T15:00:49.5985418+08:00;True|2024-01-05T13:48:06.1634940+08:00;True|2024-01-05T11:59:09.7697688+08:00;True|2024-01-05T11:33:19.2093394+08:00;True|2024-01-05T11:27:31.2454199+08:00;True|2024-01-05T11:20:20.5464568+08:00;True|2024-01-04T18:36:38.8259124+08:00;True|2024-01-04T15:54:57.9348895+08:00;True|2024-01-04T15:44:34.6535493+08:00;False|2024-01-04T15:44:20.9673752+08:00;True|2024-01-04T11:14:33.4379160+08:00;True|2024-01-03T21:54:40.3579096+08:00;True|2024-01-03T21:52:09.6604718+08:00;True|2024-01-03T16:04:13.6208067+08:00;True|2024-01-03T15:07:08.9376581+08:00;True|2024-01-02T10:57:59.7067270+08:00;True|2024-01-02T10:28:44.8223638+08:00;True|2023-12-29T17:26:12.9612280+08:00;</History>
<LastFailureDetails /> <LastFailureDetails />
</PropertyGroup> </PropertyGroup>
</Project> </Project>

@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<_PublishTargetUrl>D:\DJY\Code\djyweb_ams\web\djy_AfrApi\bin\Release\net5.0\publish-linux\</_PublishTargetUrl> <_PublishTargetUrl>D:\DJY\Code\djyweb_ams\web\djy_AfrApi\bin\Release\net5.0\publish-linux\</_PublishTargetUrl>
<History>True|2024-01-29T06:55:22.3697340Z;True|2024-01-26T15:18:26.3618341+08:00;True|2024-01-26T14:55:05.3552141+08:00;True|2024-01-25T17:09:15.3482577+08:00;False|2024-01-25T17:08:55.2779489+08:00;True|2024-01-25T16:46:48.0925564+08:00;</History> <History>True|2024-02-04T06:34:07.9001297Z;True|2024-01-29T17:48:24.1888961+08:00;True|2024-01-29T14:55:22.3697340+08:00;True|2024-01-26T15:18:26.3618341+08:00;True|2024-01-26T14:55:05.3552141+08:00;True|2024-01-25T17:09:15.3482577+08:00;False|2024-01-25T17:08:55.2779489+08:00;True|2024-01-25T16:46:48.0925564+08:00;</History>
<LastFailureDetails /> <LastFailureDetails />
</PropertyGroup> </PropertyGroup>
</Project> </Project>

@ -46,7 +46,7 @@
"Index": 100, "Index": 100,
"DataType": 1, "DataType": 1,
"Status": 0, "Status": 0,
"ConnString": "Data Source =60.209.125.238,32009; Initial Catalog=DevCommonDB; Persist Security Info=True; User ID =sa; Password=Djy@Sql2022.test;pooling=true;" "ConnString": "Data Source =60.209.125.238,32009; Initial Catalog=TestCommonDB; Persist Security Info=True; User ID =sa; Password=Djy@Sql2022.test;pooling=true;"
}, },
{ {
"SysKey": "djydb", "SysKey": "djydb",

Loading…
Cancel
Save