From 651b2ff9c591efba68dd627741baf33affced4b7 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng Date: Sun, 4 Feb 2024 15:08:01 +0800 Subject: [PATCH] =?UTF-8?q?1.AFR=E5=8F=91=E9=80=81=E6=97=B6=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E5=AD=97=E6=AE=B5=E8=A1=A5=E5=85=85=202.=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E5=90=AF=E5=8A=A8=E6=97=B6=E6=B8=85=E7=A9=BA=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/djy.Service/Afr/AfrService.cs | 99 ++++++++++++++++++- .../Milldlewares/MiddlewareHelpers.cs | 16 ++- .../FolderProfile-Windows.pubxml.user | 2 +- .../FolderProfile-linux.pubxml.user | 2 +- web/djy_AfrApi/appsettings.Staging.json | 2 +- 5 files changed, 115 insertions(+), 6 deletions(-) diff --git a/web/djy.Service/Afr/AfrService.cs b/web/djy.Service/Afr/AfrService.cs index c8c92be..ae4f40e 100644 --- a/web/djy.Service/Afr/AfrService.cs +++ b/web/djy.Service/Afr/AfrService.cs @@ -221,7 +221,7 @@ namespace djy.Service.AFR // 下面是前端传来的条件 .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.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(input.CreateTimeStart != null, (m) => m.CreateTime >= input.CreateTimeStart) .WhereIf(input.CreateTimeEnd != null, (m) => m.CreateTime <= input.CreateTimeEnd); @@ -335,6 +335,13 @@ namespace djy.Service.AFR AFRMaster oldMaster = null; var nowTime = DateTime.Now; + #region 数据校验 + if (string.IsNullOrWhiteSpace(input.MBLNO)) + { + throw new Exception($"船东提单号不能为空"); + } + #endregion + if (string.IsNullOrEmpty(input.GID)) { type = 0; @@ -367,6 +374,10 @@ namespace djy.Service.AFR } 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().AnyAsync(h => hblNoList.Contains(h.HouseBillNo))) { throw new Exception("已存在相同的货代提单号"); @@ -697,6 +708,92 @@ namespace djy.Service.AFR // 原始发送 重发 修改 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) { // 待处理的分单 diff --git a/web/djy_AfrApi/Milldlewares/MiddlewareHelpers.cs b/web/djy_AfrApi/Milldlewares/MiddlewareHelpers.cs index 75be504..848af22 100644 --- a/web/djy_AfrApi/Milldlewares/MiddlewareHelpers.cs +++ b/web/djy_AfrApi/Milldlewares/MiddlewareHelpers.cs @@ -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 System.Collections.Generic; +using System.Linq; namespace djy_AfrApi.Middlewares { @@ -42,7 +46,15 @@ namespace djy_AfrApi.Middlewares /// public static IApplicationBuilder UseCommonCacheMiddleware(this IApplicationBuilder app) { - return app.UseMiddleware(); + // 获取CommonController下所有含有RedisCaching特性的方法,并将其缓存从Redis中清空 + List 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(); } } } diff --git a/web/djy_AfrApi/Properties/PublishProfiles/FolderProfile-Windows.pubxml.user b/web/djy_AfrApi/Properties/PublishProfiles/FolderProfile-Windows.pubxml.user index c5a211c..921f4a2 100644 --- a/web/djy_AfrApi/Properties/PublishProfiles/FolderProfile-Windows.pubxml.user +++ b/web/djy_AfrApi/Properties/PublishProfiles/FolderProfile-Windows.pubxml.user @@ -6,7 +6,7 @@ <_PublishTargetUrl>D:\DJY\Code\djyweb_ams\web\djy_AfrApi\bin\Release\net5.0\publish-windows\ - 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; + 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; \ No newline at end of file diff --git a/web/djy_AfrApi/Properties/PublishProfiles/FolderProfile-linux.pubxml.user b/web/djy_AfrApi/Properties/PublishProfiles/FolderProfile-linux.pubxml.user index f33a355..eee4f20 100644 --- a/web/djy_AfrApi/Properties/PublishProfiles/FolderProfile-linux.pubxml.user +++ b/web/djy_AfrApi/Properties/PublishProfiles/FolderProfile-linux.pubxml.user @@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. <_PublishTargetUrl>D:\DJY\Code\djyweb_ams\web\djy_AfrApi\bin\Release\net5.0\publish-linux\ - 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; + 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; \ No newline at end of file diff --git a/web/djy_AfrApi/appsettings.Staging.json b/web/djy_AfrApi/appsettings.Staging.json index a978378..41bfd7d 100644 --- a/web/djy_AfrApi/appsettings.Staging.json +++ b/web/djy_AfrApi/appsettings.Staging.json @@ -46,7 +46,7 @@ "Index": 100, "DataType": 1, "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",