diff --git a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs index ed02d193..3b480f85 100644 --- a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs +++ b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs @@ -33,6 +33,11 @@ public static class MultiLanguageConst [Description("查询成功")] public const string DataQuerySuccess = "Data_Query_Success"; /// + /// 查询无数据 + /// + [Description("查询无数据")] + public const string DataQueryNoData = "Data_Query_NoData"; + /// /// 新增成功 /// [Description("新增成功")] @@ -424,6 +429,9 @@ public static class MultiLanguageConst [Description("用户邮箱设置不存在")] public const string UserEmailNotExist = "UserEmail_Not_Exist"; + [Description("未配置个人邮箱账号")] + public const string UserEmailNotSet = "UserEmail_Not_Set"; + [Description("列表字段设置已存在")] public const string ColumnSetExist = "Column_Set_Exist"; [Description("表单复制字段设置已存在")] diff --git a/ds-wms-service/DS.Module.Core/Constants/TaskFlowDataNameConst.cs b/ds-wms-service/DS.Module.Core/Constants/TaskFlowDataNameConst.cs index e56befd3..3d692c6e 100644 --- a/ds-wms-service/DS.Module.Core/Constants/TaskFlowDataNameConst.cs +++ b/ds-wms-service/DS.Module.Core/Constants/TaskFlowDataNameConst.cs @@ -14,5 +14,15 @@ /// 租户Id /// public const string TenantId = "TenantId"; + + /// + /// BC文件 + /// + public const string BCFile = "BCFile"; + + /// + /// BC修改文件 + /// + public const string AmendmentFile = "AmendmentFile"; } } diff --git a/ds-wms-service/DS.Module.Core/Data/TaskFlowDataContext.cs b/ds-wms-service/DS.Module.Core/Data/TaskFlowDataContext.cs index 19092acf..61e18b6c 100644 --- a/ds-wms-service/DS.Module.Core/Data/TaskFlowDataContext.cs +++ b/ds-wms-service/DS.Module.Core/Data/TaskFlowDataContext.cs @@ -5,12 +5,12 @@ /// public class TaskFlowDataContext { - private readonly Dictionary dataContext = new(); + private readonly Dictionary dataContext = new(); /// /// /// - public TaskFlowDataContext(string key, object value) + public TaskFlowDataContext(string key, object? value) { dataContext.Add(key, value); } @@ -18,7 +18,7 @@ /// /// /// - public TaskFlowDataContext(params (string key, object value)[] keyValues) + public TaskFlowDataContext(params (string key, object? value)[] keyValues) { foreach (var item in keyValues) { @@ -29,7 +29,7 @@ /// /// /// - public void Set(string key, object value) + public void Set(string key, object? value) { if (ContainsKey(key)) { diff --git a/ds-wms-service/DS.Module.Core/Filters/ApiUserFilter.cs b/ds-wms-service/DS.Module.Core/Filters/ApiUserFilter.cs index f425b867..a664f443 100644 --- a/ds-wms-service/DS.Module.Core/Filters/ApiUserFilter.cs +++ b/ds-wms-service/DS.Module.Core/Filters/ApiUserFilter.cs @@ -46,10 +46,7 @@ namespace DS.Module.Core.Filters && x.ApiSecret == secret && x.ApiCode == apiUser.ApiCode && x.IsDisable == false).First(); - var sql = db.Queryable().Where(x => x.ApiKey == key - && x.ApiSecret == secret - && x.ApiCode == apiUser.ApiCode - && x.IsDisable == false).ToSqlString(); + if (auth != null && (!auth.ExpireDate.HasValue || auth.ExpireDate > DateTime.Now)) { //var tenant = db.Queryable().First(x => x.Id == auth.TenantId); diff --git a/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeUserEmailReq.cs b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeUserEmailReq.cs index e4a19c62..48967c77 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeUserEmailReq.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeUserEmailReq.cs @@ -58,6 +58,10 @@ namespace DS.WMS.Core.Code.Dtos /// 发件SSL /// public bool? SmtpSSL { get; set; } = false; + /// + /// 是否为公司账号 + /// + public bool IsCompany { get; set; } = false; /// /// 状态 0启用 1禁用 diff --git a/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeUserEmailRes.cs b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeUserEmailRes.cs index b5419c70..de11111f 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeUserEmailRes.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeUserEmailRes.cs @@ -60,5 +60,10 @@ namespace DS.WMS.Core.Code.Dtos /// 状态 0启用 1禁用 /// public StatusEnum? Status { get; set; } = StatusEnum.Enable; + + /// + /// 是否为公司账号 + /// + public bool IsCompany { get; set; } = false; } } diff --git a/ds-wms-service/DS.WMS.Core/Code/Entity/CodeUserEmail.cs b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeUserEmail.cs index f68ea7b4..96dd515f 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Entity/CodeUserEmail.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeUserEmail.cs @@ -71,5 +71,11 @@ namespace DS.WMS.Core.Code.Entity /// [SugarColumn(ColumnDescription = "状态", DefaultValue = "0")] public StatusEnum? Status { get; set; } = StatusEnum.Enable; + + /// + /// 是否为公司账号 + /// + [SugarColumn(ColumnDescription = "是否为公司账号", DefaultValue = "0")] + public bool IsCompany { get; set; } = false; } } diff --git a/ds-wms-service/DS.WMS.Core/Code/Interface/IUserEmaiService.cs b/ds-wms-service/DS.WMS.Core/Code/Interface/IUserEmaiService.cs index 045869f0..b8907fd1 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Interface/IUserEmaiService.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Interface/IUserEmaiService.cs @@ -46,4 +46,11 @@ public interface IUserEmailService /// /// public DataResult BatchDelUserEmail(IdModel req); + + + /// + /// 获取用户邮箱配置 + /// + /// + public Task> GetUserEmailSetInfo(); } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/CodeUserEmailService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeUserEmailService.cs index 8fe59309..dcc46110 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Method/CodeUserEmailService.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeUserEmailService.cs @@ -125,4 +125,32 @@ public class CodeUserEmailService : IUserEmailService } return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess); } + + + /// + /// 获取用户邮箱配置 + /// + /// + public async Task> GetUserEmailSetInfo() + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + var data = await tenantDb.Queryable() + .Where(a => a.IsCompany == false && a.CreateBy == long.Parse(user.UserId)) + .Select() + .FirstAsync(); + + if (data == null) + { + data = await tenantDb.Queryable() + .Where(a => a.IsCompany == true) + .Select() + .FirstAsync(); + } + + if (data == null) + return DataResult.Failed("未配置个人邮箱账号", MultiLanguageConst.UserEmailNotSet); + + return DataResult.Success(data, MultiLanguageConst.DataQuerySuccess); + } } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotService.cs b/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotService.cs index c62b246a..8b823b6d 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotService.cs @@ -1,4 +1,5 @@ using DS.Module.Core; +using DS.Module.Core.Data; using DS.Module.DjyServiceStatus; using DS.WMS.Core.Op.Dtos; using Microsoft.AspNetCore.Http; @@ -24,6 +25,12 @@ namespace DS.WMS.Core.Op.Interface /// Task> ApiReceive(string jsonData, IFormFile file = null, IFormFile modifyFile = null); + /// + /// 舱位接收保存、取消接口(任务台使用) + /// + Task> ApiReceiveTask(TaskFlowDataContext dataContext); + + /// /// 获取舱位详情 /// diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs index c4796052..02dd0364 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs @@ -48,6 +48,8 @@ using DS.WMS.Core.Code.Method; using DS.WMS.Core.Map.Method; using DS.Module.Core.Extensions; using DS.Module.Core.Constants; +using DS.Module.Core.Data; +using DS.WMS.Core.TaskPlat.Dtos; namespace DS.WMS.Core.Op.Method { @@ -74,7 +76,7 @@ namespace DS.WMS.Core.Op.Method private readonly ICodePortService _codePortService; private readonly IMappingPortService _mappingPortService; private readonly ICodeCountryService _codeCountryService; - + private readonly string bcCompareUrl; @@ -125,6 +127,7 @@ namespace DS.WMS.Core.Op.Method _codeCtnService = _serviceProvider.GetRequiredService(); _codePortService = _serviceProvider.GetRequiredService(); _mappingPortService = _serviceProvider.GetRequiredService(); + _mappingCarrierService = _serviceProvider.GetRequiredService(); _codeCountryService = _serviceProvider.GetRequiredService(); bcCompareUrl = AppSetting.app(new string[] { "BCCompare", "Url" }); @@ -189,9 +192,9 @@ namespace DS.WMS.Core.Op.Method var delCtnList = tenantDb.Queryable().Where(x => x.SlotId == model.Id).ToList(); - if(delCtnList.Count > 0) + if (delCtnList.Count > 0) await tenantDb.Deleteable(delCtnList).ExecuteCommandAsync(); - + if (input.CtnList != null) { foreach (var ctn in input.CtnList) @@ -554,7 +557,7 @@ namespace DS.WMS.Core.Op.Method { Logger.Log(NLog.LogLevel.Error, $"自动生成舱位标签失败,原因:{e.Message}"); - return DataResult.Failed(string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotSlotBookingNoExists)),e.Message)); + return DataResult.Failed(string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotSlotBookingNoExists)), e.Message)); } return DataResult.Success(string.Empty); @@ -800,6 +803,118 @@ namespace DS.WMS.Core.Op.Method return DataResult.Success(id); } + + /// + /// 舱位接收保存、取消接口(任务台使用) + /// + public async Task> ApiReceiveTask(TaskFlowDataContext dataContext) + { + var a = user.UserId; + var b = user.UserName; + var c = user.TenantId; + var messageInfo = dataContext.Get(TaskFlowDataNameConst.TaskManageOrderMessageInfo); + if (messageInfo == null) + { + throw new ArgumentNullException($"缺少参数:{TaskFlowDataNameConst.TaskManageOrderMessageInfo}"); + } + + DynameFileInfo bcFileInfo = null; + DynameFileInfo bcNoticeFileInfo = null; + + var bcfile = dataContext.Get(TaskFlowDataNameConst.BCFile); + if (bcfile != null) + { + bcFileInfo = new DynameFileInfo + { + FileBytes = bcfile.ToByteArray(), + FileName = bcfile.FileName + }; + } + + var bcNoticeFile = dataContext.Get(TaskFlowDataNameConst.AmendmentFile); + if (bcNoticeFile != null) + { + bcNoticeFileInfo = new DynameFileInfo + { + FileBytes = bcNoticeFile.ToByteArray(), + FileName = bcNoticeFile.FileName + }; + } + + var taskBCInfoDto = messageInfo.Main.BCInfo; + + var allMapCarrierList = await _mappingCarrierService.GetAllList(); + MappingCarrierRes? carrierInfo = null; + + if (allMapCarrierList.Succeeded) + { + //carrierInfo = allMapCarrierList.Data.FirstOrDefault(t => t.LinkId == taskBCInfoDto.CarrierId && t.Module == CONST_MAPPING_CARRIER_MODULE); + carrierInfo = allMapCarrierList.Data.Where(t => t.MapCode.Equals(taskBCInfoDto.CarrierId, StringComparison.OrdinalIgnoreCase) && t.Module == CONST_MAPPING_CARRIER_MODULE).FirstOrDefault(); + } + + BookingSlotBaseApiDto slotModel = new BookingSlotBaseApiDto + { + DataObj = new BookingSlotBaseApiSaveDto + { + CarrierId = carrierInfo?.LinkId, + CarrierCode = carrierInfo?.Code, + SlotBookingNo = taskBCInfoDto.MBLNo, + BookingParty = taskBCInfoDto.BookingParty, + BookingSlotType = taskBCInfoDto.BookingSlotType, + BookingSlotTypeName = taskBCInfoDto.BookingSlotTypeName, + Vessel = taskBCInfoDto.Vessel, + Voyno = taskBCInfoDto.VoyNo, + VGMSubmissionCutDate = taskBCInfoDto.VGMCutoffTime, + //WeekAt = taskBCInfoDto.WeekAt, + CarriageType = taskBCInfoDto.CarriageType, + CarriageTypeName = taskBCInfoDto.CarriageTypeName, + ContractNo = taskBCInfoDto.ContractNo, + CtnStat = taskBCInfoDto.CtnStat, + CYCutDate = taskBCInfoDto.CYCutoffTime, + DetensionFreeDays = taskBCInfoDto.DetensionFreeDays, + ETD = taskBCInfoDto.ETD, + ETA = taskBCInfoDto.ETA, + LaneCode = taskBCInfoDto.LaneCode, + LaneName = taskBCInfoDto.LaneName, + ManifestCutDate = taskBCInfoDto.ManifestCutDate, + MDGFCutDate = taskBCInfoDto.MDGFCutDate, + PlaceDelivery = taskBCInfoDto.PlaceDelivery, + PlaceReceipt = taskBCInfoDto.PlaceReceipt, + PortDischarge = taskBCInfoDto.PortDischarge, + PortLoad = taskBCInfoDto.Portload, + SICutDate = taskBCInfoDto.SICutDate, + //CustomSICutDate = taskBCInfoDto.CustomSICutDate, + TransferPort1 = taskBCInfoDto.TransferPort1, + TransferPort2 = taskBCInfoDto.TransferPort2, + PriceCalculationDate = taskBCInfoDto.PriceCalculationDate, + CtnList = new List() + }, + OpType = "add" + }; + + if (int.TryParse(taskBCInfoDto.WeekAt, out int week)) + { + slotModel.DataObj.WeekAt = week; + } + if (taskBCInfoDto.CtnList.Count > 0) + { + taskBCInfoDto.CtnList.ForEach(t => + { + BookingSlotCtnSaveInput ctn = new BookingSlotCtnSaveInput + { + CtnAll = t.CtnALL, + CtnNum = t.CTNNUM.HasValue ? t.CTNNUM.Value : 1 + }; + + slotModel.DataObj.CtnList.Add(ctn); + }); + } + + + var rlt = await InnerApiReceive(slotModel, bcFileInfo, bcNoticeFileInfo); + + return rlt; + } #endregion #region 舱位接收保存、取消接口(内部接口) @@ -816,6 +931,8 @@ namespace DS.WMS.Core.Op.Method var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + var slotBase = await tenantDb.Queryable().Where(x => x.Id == 1814212362220212224).ToListAsync(); + //接口方法直接调用save、delete等方法会报错,可能因为非token授权登录导致,故重写一遍保存、删除代码 if (dto.OpType == "add" || dto.OpType == "update" || dto.OpType == "del" || dto.OpType == "cancellation") { @@ -946,7 +1063,7 @@ namespace DS.WMS.Core.Op.Method portCodeList = allPortCodeList.Data; } } - + var portInfo = await PlaceDeliveryToPort(portEnName, portCodeList, () => _mappingPortService.GetAllList()); if (portInfo.Succeeded) @@ -957,7 +1074,7 @@ namespace DS.WMS.Core.Op.Method { var allCountryCodeList = await _codeCountryService.GetAllList(); - if(allCountryCodeList.Succeeded) + if (allCountryCodeList.Succeeded) { var countryInfo = allCountryCodeList.Data.FirstOrDefault(p => p.Id == portInfo.Data.CountryId); @@ -970,12 +1087,12 @@ namespace DS.WMS.Core.Op.Method dto.DataObj.PortDischargeId = portInfo.Data.EdiCode; - + } } else { - Logger.Log(NLog.LogLevel.Info, $"交货地分割后得到的城市名称为空,订舱编号:{ dto.DataObj.SlotBookingNo}"); + Logger.Log(NLog.LogLevel.Info, $"交货地分割后得到的城市名称为空,订舱编号:{dto.DataObj.SlotBookingNo}"); } } else @@ -1106,7 +1223,7 @@ namespace DS.WMS.Core.Op.Method //提取箱信息 var ctnList = tenantDb.Queryable() - .Where(x => x.SlotId == model.Id).ToList(); + .Where(x => x.SlotId == model.Id).ToList(); if (ctnList != null) { @@ -1178,8 +1295,8 @@ namespace DS.WMS.Core.Op.Method { await tenantDb.Deleteable(p).ExecuteCommandAsync(); }); - } - + } + foreach (var ctn in dto.DataObj.CtnList) { var newCtn = ctn.Adapt(); @@ -1314,7 +1431,7 @@ namespace DS.WMS.Core.Op.Method } - if(id == 0) + if (id == 0) return DataResult.FailedData(id); return DataResult.Success(id); @@ -1369,7 +1486,7 @@ namespace DS.WMS.Core.Op.Method if (string.IsNullOrEmpty(portEnName)) { - return DataResult.FailedData(portInfo); + return DataResult.FailedData(portInfo); } // 匹配方式1:精准匹配 @@ -1703,7 +1820,7 @@ namespace DS.WMS.Core.Op.Method .Select(a => string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotMergeCheckPartRecordNoConsistentFail)), string.Join(",", a.Select(b => b.SlotBookingNo).ToArray()), a.Key)).ToArray()); } - + // 查询可用舱位及箱子列表 return rlt; } @@ -1863,7 +1980,7 @@ namespace DS.WMS.Core.Op.Method /// 返回附件列表 public async Task>> GetFile(long id) { - return _opFileService.GetOpFileList(id.ToString()) ; + return _opFileService.GetOpFileList(id.ToString()); } #endregion @@ -1977,7 +2094,7 @@ namespace DS.WMS.Core.Op.Method if (model.CustomerContactList != null && model.CustomerContactList.Count > 0) { //取委托客户下面所有的联系人列表 - var djyCustomerInfo = _clientInfoService.GetClientInfoWithContact(new Info.Dtos.QueryClientInfo { ClientId = model.CustomerId.Value,IsController = true }).GetAwaiter().GetResult().Data; + var djyCustomerInfo = _clientInfoService.GetClientInfoWithContact(new Info.Dtos.QueryClientInfo { ClientId = model.CustomerId.Value, IsController = true }).GetAwaiter().GetResult().Data; if (djyCustomerInfo == null) { @@ -2056,7 +2173,7 @@ namespace DS.WMS.Core.Op.Method { carrierInfo = allMapCarrierList.Data.FirstOrDefault(t => t.LinkId == bookingSlotBase.CarrierId.Value && t.Module == CONST_MAPPING_CARRIER_MODULE); } - + var custNo = bookingSlotBase.SlotBookingNo.Trim(); SeaExportReq bkModel = new SeaExportReq @@ -2073,7 +2190,7 @@ namespace DS.WMS.Core.Op.Method InnerVoyno = bookingSlotBase.Voyno?.ToUpper()?.Trim(), ETD = bookingSlotBase.ETD, ETA = bookingSlotBase.ETA, - SaleId = generateModel.SaleId.HasValue? generateModel.SaleId.Value:0, + SaleId = generateModel.SaleId.HasValue ? generateModel.SaleId.Value : 0, Sale = generateModel.SaleName, OperatorId = generateModel.OpId.HasValue ? generateModel.OpId.Value : 0, //op = generateModel.OpName, @@ -2092,7 +2209,7 @@ namespace DS.WMS.Core.Op.Method //CUSTSERVICE = generateModel.CustServiceName, LoadPort = bookingSlotBase.PortLoad, - LoadPortId = bookingSlotBase.PortLoadId.HasValue? bookingSlotBase.PortLoadId.Value:0, + LoadPortId = bookingSlotBase.PortLoadId.HasValue ? bookingSlotBase.PortLoadId.Value : 0, DischargePortId = bookingSlotBase.PortDischargeId.HasValue ? bookingSlotBase.PortLoadId.Value : 0, DischargePort = bookingSlotBase.PortDischarge, @@ -2239,7 +2356,8 @@ namespace DS.WMS.Core.Op.Method if (id > 0) { ////对应订舱和舱位关系 - var allocRlt = await ImportSlots(new ImportSlotsDto { + var allocRlt = await ImportSlots(new ImportSlotsDto + { slots = importSlots, bookingOrderId = id, isCheck = false, @@ -2447,10 +2565,10 @@ namespace DS.WMS.Core.Op.Method .Ignore(dest => dest.UpdateTime) .Ignore(dest => dest.CreateBy) .Ignore(dest => dest.UpdateBy); - //.Ignore(dest => dest.CreatedUserName) - //.Ignore(dest => dest.UpdatedUserName) - //.Ignore(dest => dest.TenantId) - //.Ignore(dest => dest.TenantName); + //.Ignore(dest => dest.CreatedUserName) + //.Ignore(dest => dest.UpdatedUserName) + //.Ignore(dest => dest.TenantId) + //.Ignore(dest => dest.TenantName); var newSlotAllocation = latestSlot.Adapt(config); newSlotAllocation.Id = 0; @@ -2512,14 +2630,14 @@ namespace DS.WMS.Core.Op.Method await _bookingSlotStockService.BookingSlotStock(new BookingSlotStockUpdateModel { BookingSlotType = latestSlot.BookingSlotType, - CarrierId = latestSlot.CarrierId.HasValue? latestSlot.CarrierId.Value:0, + CarrierId = latestSlot.CarrierId.HasValue ? latestSlot.CarrierId.Value : 0, ContractNo = latestSlot.ContractNo, Vessel = latestSlot.Vessel, Voyno = latestSlot.Voyno, PortLoadId = latestSlot.PortLoadCode, PortDischargeId = latestSlot.PortLoadCode, }); - + } } finally @@ -2599,7 +2717,7 @@ namespace DS.WMS.Core.Op.Method var model = tenantDb.Queryable().First(x => x.SlotBookingNo == slotBookingNo && x.CarrierCode == CarrierId); //if (model == null) - //throw Oops.Bah("舱位信息不存在"); + //throw Oops.Bah("舱位信息不存在"); id = model.Id; } @@ -2627,7 +2745,7 @@ namespace DS.WMS.Core.Op.Method var result = tenantDb.Queryable() .Select() .Where(whereList); - + var list = result.ToList(); return await result.ToQueryPageAsync(querySearch.PageCondition); diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/SpaceBooking/SpaceBookingMSKAPIService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/SpaceBooking/SpaceBookingMSKAPIService.cs index 934e2c24..ea132856 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/SpaceBooking/SpaceBookingMSKAPIService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/SpaceBooking/SpaceBookingMSKAPIService.cs @@ -1531,9 +1531,9 @@ namespace DS.WMS.Core.Op.Method } if (selectedShipSchedule == null) - //throw Oops.Oh("船期数据校验失败,请重新查询船期信息"); + //throw Oops.Oh("船期数据校验失败,请重新查询船期信息"); - model.placeOfReceiptCountryName = selectedShipSchedule.originCountryName; + model.placeOfReceiptCountryName = selectedShipSchedule.originCountryName; model.placeOfReceiptRegionName = selectedShipSchedule.originRegionName; model.carrierCollectionOriginGeoID = selectedShipSchedule.originGeoId; @@ -2244,11 +2244,12 @@ namespace DS.WMS.Core.Op.Method throw new ArgumentNullException($"提单号为空"); } - var tenantId = dataContext.Get(TaskFlowDataNameConst.TenantId); - if (tenantId == 0) - { - throw new ArgumentNullException($"缺少参数:TenantId"); - } + var tenantId = long.Parse(user.TenantId); + //var tenantId = dataContext.Get(TaskFlowDataNameConst.TenantId); + //if (tenantId == 0) + //{ + // throw new ArgumentNullException($"缺少参数:TenantId"); + //} string type = messageInfo.Main.TaskType switch { diff --git a/ds-wms-service/DS.WMS.Core/Sys/Interface/IClientCommonService.cs b/ds-wms-service/DS.WMS.Core/Sys/Interface/IClientCommonService.cs index b738ff4b..fd1ac156 100644 --- a/ds-wms-service/DS.WMS.Core/Sys/Interface/IClientCommonService.cs +++ b/ds-wms-service/DS.WMS.Core/Sys/Interface/IClientCommonService.cs @@ -13,7 +13,8 @@ namespace DS.WMS.Core.Sys.Interface; /// /// public interface IClientCommonService -{ +{ + /// /// 根据类型获取用户下拉列表 /// diff --git a/ds-wms-service/DS.WMS.Core/Sys/Method/ClientCommonService.cs b/ds-wms-service/DS.WMS.Core/Sys/Method/ClientCommonService.cs index f3c951bb..a17e59f5 100644 --- a/ds-wms-service/DS.WMS.Core/Sys/Method/ClientCommonService.cs +++ b/ds-wms-service/DS.WMS.Core/Sys/Method/ClientCommonService.cs @@ -43,6 +43,7 @@ public class ClientCommonService : IClientCommonService user = _serviceProvider.GetRequiredService(); saasService = _serviceProvider.GetRequiredService(); } + /// /// 根据类型获取用户下拉列表 /// diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowModule.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowModule.cs index 5c1b73c1..6acb9de6 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowModule.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowModule.cs @@ -24,10 +24,10 @@ namespace DS.WMS.Core.TaskPlat.Entity public string? TaskType { get; set; } /// - /// 所在命名空间 + /// Assembly名称 /// - [SugarColumn(ColumnDescription = "所在命名空间", IsNullable = true, Length = 255)] - public string? NameSpace { get; set; } + [SugarColumn(ColumnDescription = "Assembly名称", IsNullable = true, Length = 255)] + public string? AssemblyName { get; set; } /// /// Interface名称 diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs index 38996393..55e7ac6a 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs @@ -24,27 +24,31 @@ namespace DS.WMS.Core.TaskPlat.Method private readonly ISaasDbService saasDbService; private readonly IServiceProvider serviceProvider; private readonly IWebHostEnvironment environment; + //private readonly ICodeCtnService _codeCtnService; public TaskManageService(ILogger logger, ISaasDbService saasDbService, IServiceProvider serviceProvider, IUser user, - IWebHostEnvironment environment) + IWebHostEnvironment environment + //ICodeCtnService codeCtnService + ) { _logger = logger; this.saasDbService = saasDbService; this.serviceProvider = serviceProvider; this.user = user; this.environment = environment; + //_codeCtnService = codeCtnService; } public async Task InitTaskJob(TaskManageOrderMessageInfo info, IFormFile file = null, IFormFile modifyFile = null) { string batchNo = Guid.NewGuid().ToString(); - var a = user.UserId; - var b = user.UserName; - var c = user.TenantId; - var d = user.OrgId; + //var a = user.UserId; + //var b = user.UserName; + //var c = user.TenantId; + //var d = user.OrgId; try { _logger.LogInformation("批次={no} 接收到创建任务报文 报文={msg}", batchNo, JsonConvert.SerializeObject(info)); @@ -438,6 +442,68 @@ namespace DS.WMS.Core.TaskPlat.Method } #endregion + #region SI反馈入库 + //SI反馈入库 + //if (info.Main.TaskType == TaskBaseTypeEnum.SI_FEEDBACK) + //{ + // if (info.Main.SIFeedBack == null) + // throw new Exception($"任务类型={info.Main.TaskType.ToString()} SIFeedBack信息必传"); + + // TaskSiSubmitted taskSISubmitted = info.Main.SIFeedBack.Adapt(); + + // taskSISubmitted.Id = SnowFlakeSingle.Instance.NextId(); + // taskSISubmitted.TASK_ID = taskInfo.Id; + + // taskSISubmitted.CreateTime = taskInfo.CreateTime; + // taskSISubmitted.CreateBy = taskInfo.CreateBy; + + // await tenantDb.Insertable(taskSISubmitted).ExecuteCommandAsync(); + + // //SI反馈箱信息入库 + // if (info.Main.SIFeedBack.ContaList != null && info.Main.SIFeedBack.ContaList.Count > 0) + // { + // var codeCtnCache = (await _codeCtnService.GetAllList())?.Data ?? new List(); + + // info.Main.SIFeedBack.ContaList.ForEach(ctn => + // { + // var contaInfo = ctn.Adapt(); + + // //contaInfo.PK_ID = IDGen.NextID().ToString(); + // //contaInfo.P_PKID = taskSISubmitted.PK_ID; + + // //contaInfo.CreatedTime = taskInfo.CreatedTime; + // //contaInfo.UpdatedTime = taskInfo.CreatedTime; + + // //contaInfo.CreatedUserId = taskInfo.CreatedUserId; + // //contaInfo.CreatedUserName = taskInfo.CreatedUserName; + // //contaInfo.TenantId = taskInfo.TenantId; + // //contaInfo.TenantName = taskInfo.TenantName; + + // //if (string.IsNullOrWhiteSpace(contaInfo.CTNCODE) && !string.IsNullOrWhiteSpace(contaInfo.CTNALL)) + // //{ + // // if (ediCtnList != null && ediCtnList.Count > 0) + // // { + // // var ctnCodeInfo = ediCtnList.FirstOrDefault(x => !string.IsNullOrWhiteSpace(x.Name) + // // && x.Name.Equals(contaInfo.CTNALL, StringComparison.OrdinalIgnoreCase)); + + // // if (ctnCodeInfo != null) + // // { + // // contaInfo.CTNCODE = ctnCodeInfo.Code; + // // } + // // } + // //} + + // //_taskSISubmittedCtnRepository.Insert(contaInfo); + // }); + // } + + // var siService = _namedtaskSISubmittedServiceProvider + // .GetService(nameof(TaskManageSISubmittedService)); + + // await siService.ProcessSISubmitted(taskSISubmitted.TASK_ID); + + //} + #endregion #region BC 任务 if (info.Main.TaskType == TaskBaseTypeEnum.BC @@ -482,27 +548,28 @@ namespace DS.WMS.Core.TaskPlat.Method 2、推送钉钉消息@操作人 通知收到变更 */ + //(TaskFlowDataNameConst.TenantId, long.Parse(user.TenantId)), + + // 执行自动化操作 TaskFlowDataContext dataContext = new( (TaskFlowDataNameConst.TaskManageOrderMessageInfo, info), - (TaskFlowDataNameConst.TenantId, long.Parse(user.TenantId)) + (TaskFlowDataNameConst.BCFile, file), + (TaskFlowDataNameConst.AmendmentFile, modifyFile) ); TaskFlowRuner taskFlow = new TaskFlowRuner(tenantDb, serviceProvider); await taskFlow.Run(info.Main.TaskType, taskInfo.Id, dataContext); - if (info.Main.TaskType == TaskBaseTypeEnum.BC) - { - - } - else if (info.Main.TaskType == TaskBaseTypeEnum.CANCELLATION) - { - - } - else if (info.Main.TaskType == TaskBaseTypeEnum.BC_MODIFY) - { - - } + //if (info.Main.TaskType == TaskBaseTypeEnum.BC) + //{ + //} + //else if (info.Main.TaskType == TaskBaseTypeEnum.CANCELLATION) + //{ + //} + //else if (info.Main.TaskType == TaskBaseTypeEnum.BC_MODIFY) + //{ + //} } #endregion @@ -566,7 +633,7 @@ namespace DS.WMS.Core.TaskPlat.Method string? dirAbs; if (string.IsNullOrEmpty(basePath)) { - dirAbs = Path.Combine(environment.WebRootPath, relativePath); + dirAbs = Path.Combine(environment.WebRootPath ?? "", relativePath); } else { diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs index fd8c8cfc..aa9377bb 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs @@ -207,20 +207,20 @@ namespace DS.WMS.Core.TaskPlat throw new Exception($"未找到指定流程配置,ExecuteModuleId:{configItem.ExecuteModuleId}"); } Assembly assembly; - if (module.NameSpace!.StartsWith("DS.WMS.Core")) + if (module.AssemblyName!.StartsWith("DS.WMS.Core")) { //assembly = Assembly.GetEntryAssembly()!; assembly = Assembly.GetExecutingAssembly(); } else { - assembly = Assembly.Load(module.NameSpace!); + assembly = Assembly.Load(module.AssemblyName!); } //var interfaceType2 = assembly.GetType(module.InterfaceName!); var interfaceType = assembly.DefinedTypes.FirstOrDefault(x => x.Name == module.InterfaceName!); if (interfaceType == null) { - throw new Exception($"在命名空间【{module.NameSpace}】下未找到Interface【{module.InterfaceName}】"); + throw new Exception($"在程序集【{module.AssemblyName}】下未找到Interface【{module.InterfaceName}】"); } object? imp = serviceProvider.GetService(interfaceType); if (imp == null) @@ -257,6 +257,13 @@ namespace DS.WMS.Core.TaskPlat flowLog.IsSuccess = false; } } + else if (resultTemp is Task result3) + { + if (result3.Exception != null && result3.IsFaulted) + { + throw result3.Exception; + } + } stopwatch.Stop(); flowLogDetail.ElapsedMillisecond = stopwatch.ElapsedMilliseconds; flowLogDetail.IsComplete = true; diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/UserMailController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/UserMailController.cs index 82f5cecc..4a6a6e54 100644 --- a/ds-wms-service/DS.WMS.MainApi/Controllers/UserMailController.cs +++ b/ds-wms-service/DS.WMS.MainApi/Controllers/UserMailController.cs @@ -75,4 +75,17 @@ public class UserEmailController : ApiController var res = _invokeService.BatchDelUserEmail(req); return res; } + + + /// + /// 获取用户邮箱配置 + /// + /// + [HttpGet] + [Route("GetUserEmailSetInfo")] + public async Task> GetUserEmailSetInfo() + { + var res = await _invokeService.GetUserEmailSetInfo(); + return res; + } } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.PrintApi/Controllers/OpenPrintController.cs b/ds-wms-service/DS.WMS.PrintApi/Controllers/OpenPrintController.cs index 90d0407b..e1a2ca8b 100644 --- a/ds-wms-service/DS.WMS.PrintApi/Controllers/OpenPrintController.cs +++ b/ds-wms-service/DS.WMS.PrintApi/Controllers/OpenPrintController.cs @@ -23,7 +23,7 @@ namespace DS.WMS.PrintApi.Controllers } /// - /// 获取Json打印信息 + /// 根据模板Id获取Json打印信息 /// /// /// @@ -35,5 +35,19 @@ namespace DS.WMS.PrintApi.Controllers var res = await _invokeService.GetOpenJsonPrintInfo(req); return res; } + + /// + /// 根据模板Code获取Json打印信息 + /// + /// + /// + [HttpPost] + [AllowAnonymous] + [Route("GetOpenJsonPrintInfoByTemplateCode")] + public async Task GetOpenJsonPrintInfoByTemplateCode([FromBody] OpenJsonPrintByCodeReq req) + { + var res = await _invokeService.GetOpenJsonPrintInfoByTemplateCode(req); + return res; + } } } diff --git a/ds-wms-service/DS.WMS.PrintApi/Model/OpenJsonPrintByCodeReq.cs b/ds-wms-service/DS.WMS.PrintApi/Model/OpenJsonPrintByCodeReq.cs new file mode 100644 index 00000000..88a2bc99 --- /dev/null +++ b/ds-wms-service/DS.WMS.PrintApi/Model/OpenJsonPrintByCodeReq.cs @@ -0,0 +1,28 @@ +namespace DS.WMS.PrintApi.Model +{ + /// + /// Json打印请求数据 + /// + public class OpenJsonPrintByCodeReq + { + /// + /// 租户Id + /// + public long TenantId { get; set; } + + /// + /// 模板Code + /// + public string Code { get; set; } + + /// + /// Json数据 + /// + public string JsonDataStr { get; set; } + + /// + /// 打印类型 1. PDF 2.EXCEL 2.WORD + /// + public string PrintType { get; set; } + } +} diff --git a/ds-wms-service/DS.WMS.PrintApi/Model/SysPrintTemplate.cs b/ds-wms-service/DS.WMS.PrintApi/Model/SysPrintTemplate.cs index 23382a57..5cb3e99b 100644 --- a/ds-wms-service/DS.WMS.PrintApi/Model/SysPrintTemplate.cs +++ b/ds-wms-service/DS.WMS.PrintApi/Model/SysPrintTemplate.cs @@ -20,6 +20,11 @@ namespace DS.WMS.PrintApi.Model /// public long ModuleId { get; set; } /// + ///打印模板唯一编码 + /// + [Description("打印模板唯一编码")] + public string TemplateCode { get; set; } + /// ///打印模板名称 /// [Description("打印模板名称")] diff --git a/ds-wms-service/DS.WMS.PrintApi/Service/IOpenPrintService.cs b/ds-wms-service/DS.WMS.PrintApi/Service/IOpenPrintService.cs index b38cf226..b8e37109 100644 --- a/ds-wms-service/DS.WMS.PrintApi/Service/IOpenPrintService.cs +++ b/ds-wms-service/DS.WMS.PrintApi/Service/IOpenPrintService.cs @@ -11,5 +11,13 @@ namespace DS.WMS.PrintApi.Service /// /// public Task GetOpenJsonPrintInfo(OpenJsonPrintReq req); + + /// + /// 根据打印模板代码获取Json打印信息 + /// + /// + /// + + public Task GetOpenJsonPrintInfoByTemplateCode(OpenJsonPrintByCodeReq req); } } diff --git a/ds-wms-service/DS.WMS.PrintApi/Service/OpenPrintService.cs b/ds-wms-service/DS.WMS.PrintApi/Service/OpenPrintService.cs index 22bf7d34..c5564920 100644 --- a/ds-wms-service/DS.WMS.PrintApi/Service/OpenPrintService.cs +++ b/ds-wms-service/DS.WMS.PrintApi/Service/OpenPrintService.cs @@ -97,5 +97,91 @@ namespace DS.WMS.PrintApi.Service return await Task.FromResult(PrintDataResult.Failed(ex.Message)); } } + + public async Task GetOpenJsonPrintInfoByTemplateCode(OpenJsonPrintByCodeReq req) + { + try + { + using (var db = SqlSugarUtil.GetInstance()) + { + var template = db.Queryable().Filter(null, true).Where(x => x.TemplateCode == req.Code && x.TenantId == req.TenantId).First(); + if (template == null) + { + return await Task.FromResult(PrintDataResult.Failed("打印模板编码:["+ req.Code+"]的打印格式不存在!")); + } + if (template.IsUseDataSource) + { + return await Task.FromResult(PrintDataResult.Failed("非Json打印接口!")); + } + + try + { + var basePath = String.Empty; + var savePath = "wwwroot/PrintTempFile"; + + var fileName = DateTime.Now.Ticks; + var printFileName = $"{fileName}.frx"; + var printFile = Path.Combine(savePath, printFileName); + + //写入CRX文件 + using (FileStream fs = new FileStream(printFile, FileMode.Create)) + { + Byte[] info = new UTF8Encoding(true).GetBytes(template.PrintJsonContent); + fs.Write(info, 0, info.Length); + } + + //生成报表 + FastReport.Report report = new FastReport.Report(); + report.Load(printFile); + + var dataSource = report.Dictionary.Connections[0] as JsonDataSourceConnection; + var str = new FastReport.Data.JsonConnection.JsonDataSourceConnectionStringBuilder(); + str.Json = req.JsonDataStr; + dataSource.ConnectionString = str.ConnectionString; + + report.Prepare(); + var printName = string.Empty; + var saveFile = string.Empty; + //var saveFile = Path.Combine(savePath, printName); + if (req.PrintType == "1") + { + printName = $"{fileName}.pdf"; + saveFile = Path.Combine(savePath, printName); + PDFExport pdfExport = new PDFExport(); + pdfExport.Export(report, saveFile); + } + else if (req.PrintType == "2") + { + printName = $"{fileName}.xlsx"; + saveFile = Path.Combine(savePath, printName); + Excel2007Export excelExport = new Excel2007Export(); + excelExport.Export(report, saveFile); + } + else if (req.PrintType == "3") + { + printName = $"{fileName}.doc"; + saveFile = Path.Combine(savePath, printName); + Word2007Export wordExport = new Word2007Export(); + wordExport.Export(report, saveFile); + } + else + { + return await Task.FromResult(PrintDataResult.Failed("非法打印格式!")); + } + + return await Task.FromResult(PrintDataResult.OK(printName)); + } + catch (Exception e) + { + return await Task.FromResult(PrintDataResult.Failed(e.Message)); + } + } + } + catch (Exception ex) + { + //Logger.Warn(ex, "方法: GetOpenJsonPrintInfo"); + return await Task.FromResult(PrintDataResult.Failed(ex.Message)); + } + } } } diff --git a/ds-wms-service/DS.WMS.TaskApi/DS.WMS.TaskApi.csproj b/ds-wms-service/DS.WMS.TaskApi/DS.WMS.TaskApi.csproj index 64bed9c8..83336c04 100644 --- a/ds-wms-service/DS.WMS.TaskApi/DS.WMS.TaskApi.csproj +++ b/ds-wms-service/DS.WMS.TaskApi/DS.WMS.TaskApi.csproj @@ -12,6 +12,7 @@ + diff --git a/ds-wms-service/DS.WMS.TaskApi/Program.cs b/ds-wms-service/DS.WMS.TaskApi/Program.cs index 6d89fba9..c7be932f 100644 --- a/ds-wms-service/DS.WMS.TaskApi/Program.cs +++ b/ds-wms-service/DS.WMS.TaskApi/Program.cs @@ -15,6 +15,7 @@ using NLog.Web; using Swashbuckle.AspNetCore.SwaggerUI; using DS.Module.PrintModule; using DS.Module.DjyRulesEngine; +using DS.Module.RedisModule; var builder = WebApplication.CreateBuilder(args); var environment = builder.Environment.EnvironmentName; @@ -42,7 +43,8 @@ builder.Services.AddJwtInstall(); builder.Services.AddSaasDbInstall();//ֿ builder.Services.AddMultiLanguageInstall();//Է builder.Services.AddDjyModuleInstall();//Djy -//builder.Services.AddRuleEngineModuleInstall();//DjyУ +builder.Services.AddRuleEngineModuleInstall();//DjyУ +builder.Services.AddRedisModuleInstall();//redis // builder.Services.AddEndpointsApiExplorer(); // builder.Services.AddSwaggerGen(); diff --git a/ds-wms-service/DS.WMS.Test/SaasTest.cs b/ds-wms-service/DS.WMS.Test/SaasTest.cs index a0e39f3c..3ae9f6db 100644 --- a/ds-wms-service/DS.WMS.Test/SaasTest.cs +++ b/ds-wms-service/DS.WMS.Test/SaasTest.cs @@ -241,12 +241,12 @@ public class SaasTest var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持 - //var ass = Assembly.Load("DS.WMS.Core"); - //var types = ass.GetTypes().Where(it => it.FullName?.Contains("DS.WMS.Core.TaskPlat.Entity") == true).ToArray(); - //tenantDb.CodeFirst.InitTables(types); + var ass = Assembly.Load("DS.WMS.Core"); + var types = ass.GetTypes().Where(it => it.FullName?.Contains("DS.WMS.Core.TaskPlat.Entity") == true).ToArray(); + tenantDb.CodeFirst.InitTables(types); - tenantDb.CodeFirst.InitTables(typeof(TaskFlowLog)); - tenantDb.CodeFirst.InitTables(typeof(TaskFlowLogDetail)); + //tenantDb.CodeFirst.InitTables(typeof(TaskFlowLog)); + //tenantDb.CodeFirst.InitTables(typeof(TaskFlowLogDetail)); Assert.True(true); } } \ No newline at end of file