From 6d1c537ee27d768017d9515374a7633c5556c097 Mon Sep 17 00:00:00 2001 From: wet <1034391973@qq.com> Date: Tue, 6 Jun 2023 11:22:35 +0800 Subject: [PATCH 1/2] 1 --- .../BookingOrder/BookingOrderService.cs | 2593 ++++++++++------- .../BookingOrder/Dto/BookingEDIExtDto.cs | 3 - .../BookingOrder/IBookingOrderService.cs | 4 +- 3 files changed, 1601 insertions(+), 999 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index efb85837..0e8d35f7 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -821,7 +821,14 @@ namespace Myshipping.Application } item.GoodsStatusList = itgoods.Union(itconfig).OrderBy(x => x.Sort).ToList(); - + var statuslog = await _repStatuslog.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id && (x.Status == "提箱" || x.Status == "返场")).OrderByDescending(x => x.CreatedTime).ToListAsync(); + var dto = statuslog.Adapt>(); + foreach (var it in dto) + { + var detail = await _statuslogdetail.AsQueryable().Where(x => x.PId == it.Id).ToListAsync(); + it.detail = detail.Adapt>(); + } + item.statuslogs = dto; } return list; @@ -4234,7 +4241,7 @@ namespace Myshipping.Application /// 订舱、截单EDI请求 /// 返回回执 [HttpPost("/BookingOrder/SendBookingOrClosingEDI")] - public async Task SendBookingOrClosingEDI(BookingOrClosingEDIOrderDto model) + public async Task SendBookingOrClosingEDI(BookingOrClosingEDIOrderDto model) { var dictvalue = _cache.GetAllDictData().Result.Where(x => x.Code == "XiangManCang").Select(x => x.Value).FirstOrDefault(); @@ -4242,598 +4249,1195 @@ namespace Myshipping.Application var FORWARDER = order.FORWARDER; if (!string.IsNullOrEmpty(FORWARDER) && dictvalue == FORWARDER) { - var edi = _bookingEDIExt.FirstOrDefault(x => x.BookingId == model.Id); - var ctn = _repCtn.AsQueryable().Where(x => x.BILLID == model.Id).ToList(); - #region 箱满仓生成excel文件 - string fileName = String.Empty; - var opt = App.GetOptions(); - var dirAbs = opt.basePath; - if (string.IsNullOrEmpty(dirAbs)) - { - dirAbs = App.WebHostEnvironment.WebRootPath; + #region + //var edi = _bookingEDIExt.FirstOrDefault(x => x.BookingId == model.Id); + //var ctn = _repCtn.AsQueryable().Where(x => x.BILLID == model.Id).ToList(); + //#region 箱满仓生成excel文件 + //string fileName = String.Empty; + //var opt = App.GetOptions(); + //var dirAbs = opt.basePath; + //if (string.IsNullOrEmpty(dirAbs)) + //{ + // dirAbs = App.WebHostEnvironment.WebRootPath; + //} + //var fPath = "upload/printtemplate/箱满舱上传Excel模板.xls"; + //var fileAbsPath = Path.Combine(dirAbs, fPath); + //_logger.LogInformation($"准备调用EXCEL"); + //var file = new FileStream(fileAbsPath, FileMode.Open); + //var excelwork = new HSSFWorkbook(file); + //var sheet = excelwork.GetSheetAt(0); + //for (int i = 0; i < sheet.LastRowNum; i++) + //{ + // ////获取行 + // var row = sheet.GetRow(i); + // if (i == 0) + // { + // //委托编号 + // ICell cell = row.GetCell(5); + // if (cell != null) + // { + // row.Cells[5].SetCellValue(order.CUSTNO); + // } + // else + // { + // row.CreateCell(5).SetCellValue(order.CUSTNO); + // } + // } + // if (i == 1) + // { + // //场站 + // var yardid = order.YARDID; + // if (!string.IsNullOrEmpty(yardid)) + // { + // ICell cell = row.GetCell(5); + // var yard = _cache.GetAllMappingYard().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == yardid).Select(x => x.MapCode).First(); + // if (cell != null) + // { + // row.Cells[5].SetCellValue(yard); + // } + // else + // { + // row.CreateCell(5).SetCellValue(yard); + // } + + // } + + // } + // if (i == 2) + // { + // //指定业务员 + // ICell cell = row.GetCell(5); + // if (cell != null) + // { + // row.Cells[5].SetCellValue(edi.XMCYWY); + // } + // else + // { + // row.CreateCell(5).SetCellValue(edi.XMCYWY); + // } + // } + // if (i == 3) + // { + // //提单号 + // ICell cell = row.GetCell(5); + // if (cell != null) + // { + // row.Cells[5].SetCellValue(order.MBLNO); + // } + // else + // { + // row.CreateCell(5).SetCellValue(order.MBLNO); + // } + // } + // if (i == 8) + // { + // //发货人 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.SHIPPER); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.SHIPPER); + // } + // } + // if (i == 10) + // { + // //发货人代码 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.SHIPPERID); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.SHIPPERID); + // } + // } + // if (i == 11) + // { + // //收货人 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.CONSIGNEE); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.CONSIGNEE); + // } + // } + // if (i == 14) + // { + // //通知人 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.NOTIFYPARTY); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.NOTIFYPARTY); + // } + // } + // if (i == 17) + // { + // //第二通知人 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.NOTIFYPARTY2); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.NOTIFYPARTY2); + // } + // } + // if (i == 18) + // { + // //起运港国际五字代码 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.PORTLOADID); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.PORTLOADID); + // } + + // var service = order.SERVICE; + // //运输方式 + // ICell cell5 = row.GetCell(5); + // if (cell5 != null) + // { + // row.Cells[5].SetCellValue(_cache.GetAllMappingService().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == service).Select(x => x.MapCode).First()); + // } + // else + // { + // row.CreateCell(5).SetCellValue(_cache.GetAllMappingService().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == service).Select(x => x.MapCode).First()); + // } + + + + + + // } + // if (i == 19) + // { + // //卸货港国际五字代码 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.PORTDISCHARGEID); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.PORTDISCHARGEID); + // } + // } + // if (i == 20) + // { + // //交货地国际五字代码 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.PLACEDELIVERYID); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.PLACEDELIVERYID); + // } + // } + // if (i == 21) + // { + // //ETD + + // if (order.ETD != null) + // { + + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(Convert.ToDateTime(order.ETD).ToString("yyyy-MM-dd")); + // } + // else + // { + // row.CreateCell(1).SetCellValue(Convert.ToDateTime(order.ETD).ToString("yyyy-MM-dd")); + // } + // } + + + // //船名 + // ICell cell4 = row.GetCell(4); + // if (cell4 != null) + // { + // row.Cells[4].SetCellValue(order.VESSEL); + // } + // else + // { + // row.CreateCell(4).SetCellValue(order.VESSEL); + // } + + // } + // if (i == 22) + // { + // //客户协约号 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.CONTRACTNO); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.CONTRACTNO); + // } + // } + // if (i == 23) + // { + // //航次 + // ICell cell = row.GetCell(4); + // if (cell != null) + // { + // row.Cells[4].SetCellValue(order.VOYNO); + // } + // else + // { + // row.CreateCell(4).SetCellValue(order.VOYNO); + // } + // } + // if (i == 26) + // { + // //唛头 + // ICell cell = row.GetCell(0); + // if (cell != null) + // { + // row.Cells[0].SetCellValue(order.MARKS); + // } + // else + // { + // row.CreateCell(0).SetCellValue(order.MARKS); + // } + + // if (order.PKGS != null) + // { + // //件数 + // ICell cell1 = row.GetCell(1); + // if (cell1 != null) + // { + // row.Cells[1].SetCellValue(order.PKGS.ToString()); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.PKGS.ToString()); + // } + + // } + // //包装 + // ICell cell2 = row.GetCell(2); + // if (cell2 != null) + // { + // row.Cells[2].SetCellValue(order.KINDPKGS); + // } + // else + // { + // row.CreateCell(2).SetCellValue(order.KINDPKGS); + // } + // //品名 + // ICell cell3 = row.GetCell(3); + // if (cell3 != null) + // { + // row.Cells[3].SetCellValue(order.DESCRIPTION); + // } + // else + // { + // row.CreateCell(3).SetCellValue(order.DESCRIPTION); + // } + // if (order.KGS != null) + // { + // //重量 + // ICell cell4 = row.GetCell(4); + // if (cell3 != null) + // { + // row.Cells[4].SetCellValue(order.KGS.ToString()); + // } + // else + // { + // row.CreateCell(4).SetCellValue(order.KGS.ToString()); + // } + // } + // if (order.CBM != null) + // { + // //尺码 + // ICell cell5 = row.GetCell(5); + // if (cell5 != null) + // { + // row.Cells[5].SetCellValue(order.CBM.ToString()); + // } + // else + // { + // row.CreateCell(5).SetCellValue(order.CBM.ToString()); + // } + // } + // } + // if (i == 39) + // { + // var c = ctn.DistinctBy(x => x.CTNALL).ToList(); + // var ctnAll = string.Empty; + // foreach (var item in c) + // { + // ctnAll += $"{ctn.Where(x => x.CTNALL == item.CTNALL).Count()}*{_cache.GetAllMappingCtn().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == item.CTNCODE).Select(x => x.MapCode).First()}+"; + // } + // ctnAll = ctnAll.Substring(0, ctnAll.Length - 1); + // //箱型箱量 + // ICell cell = row.GetCell(0); + // if (cell != null) + // { + // row.Cells[0].SetCellValue(ctnAll); + // } + // else + // { + // row.CreateCell(0).SetCellValue(ctnAll); + // } + // } + // if (i == 42) + // { + // //运费支付方式 + + // var BLFRTCode = _cache.GetAllCodeFrt().Result.Where(x => x.EnName == order.BLFRT).Select(x => x.Code).First(); + // var bl = string.Empty; + // if (!string.IsNullOrEmpty(BLFRTCode)) + // { + // bl = _cache.GetAllMappingFrt().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == BLFRTCode).Select(x => x.MapCode).First(); + // } + // ICell cell = row.GetCell(0); + // if (cell != null) + // { + // row.Cells[0].SetCellValue(bl); + // } + // else + // { + // row.CreateCell(0).SetCellValue(bl); + // } + // } + // if (i == 43) + // { + // //hscode + // ICell cell = row.GetCell(3); + // if (cell != null) + // { + // row.Cells[3].SetCellValue(order.HSCODE); + // } + // else + // { + // row.CreateCell(3).SetCellValue(order.HSCODE); + // } + // } + // if (i == 44) + // { + // var BLFRTCode = _cache.GetAllCodeFrt().Result.Where(x => x.EnName == order.BLFRT).Select(x => x.Code).First(); + // var bl = string.Empty; + // if (!string.IsNullOrEmpty(BLFRTCode)) + // { + // bl = _cache.GetAllMappingFrt().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == BLFRTCode).Select(x => x.MapCode).First(); + // } + // if (bl == "预付") + // { + // //预付地点 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.PREPARDATID); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.PREPARDATID); + // } + + // } + // else if((bl == "到付")) + // { + + // //预付地点 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.PAYABLEATID); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.PAYABLEATID); + // } + + + // } + + // } + // if (i == 45) + // { + // //Name accout + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(edi.EmcNameAccount); + // } + // else + // { + // row.CreateCell(1).SetCellValue(edi.EmcNameAccount); + // } + // } + // if (i == 47) + // { + // //Name accout + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.TEMPSET); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.TEMPSET); + // } + + + + // //温度 + // ICell cell2 = row.GetCell(2); + // if (cell2 != null) + // { + // row.Cells[2].SetCellValue(order.TEMPSET); + // } + // else + // { + // row.CreateCell(2).SetCellValue(order.TEMPSET); + // } + + + // //湿度 + // ICell cell3 = row.GetCell(3); + // if (cell2 != null) + // { + // row.Cells[3].SetCellValue(order.HUMIDITY); + // } + // else + // { + // row.CreateCell(3).SetCellValue(order.HUMIDITY); + // } + // } + // if (i == 49) + // { + // //危险品编号 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.DUNNO); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.DUNNO); + // } + // } + // if (i == 50) + // { + // //订舱备注 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.SOREMARK); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.SOREMARK); + // } + // } + //} + + //var fileFullPath = Path.Combine(App.WebHostEnvironment.WebRootPath, App.GetOptions().Path);//服务器路径 + //if (!Directory.Exists(fileFullPath)) + //{ + // Directory.CreateDirectory(fileFullPath); + //} + + ////2023-4-3,根据合川操作要求,文件名只带提单号 + //if (!string.IsNullOrEmpty(order.MBLNO)) + //{ + // fileName = $"{DateTime.Now.Ticks}_{order.MBLNO}.xls";//名称 + //} + //else + //{ + // fileName = $"{DateTime.Now.Ticks}_{order.MBLNO}.xls";//名称 + //} + //_logger.LogInformation("导出excel:" + Path.Combine(fileFullPath, fileName)); + //var filestream = new FileStream(Path.Combine(fileFullPath, fileName), FileMode.OpenOrCreate, FileAccess.ReadWrite); + //excelwork.Write(filestream); + //#endregion + + //#region 调用爬虫接口 + + //var url = _cache.GetAllDictData().Result.Where(x => x.Code == "xiangManCangPostUrl").Select(x => x.Value).FirstOrDefault(); + + //var account = _webAccountConfig.GetAccountConfig("XiangManCang", UserManager.UserId).Result; + + + //var key = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserKey").Select(x => x.Value).FirstOrDefault(); + //if (string.IsNullOrEmpty(key)) + //{ + // throw Oops.Bah("未获取到相关KEY,请联系管理员!"); + //} + + //var secret = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserSecret").Select(x => x.Value).FirstOrDefault(); + //if (string.IsNullOrEmpty(secret)) + //{ + // throw Oops.Bah("未获取到相关SECRET,请联系管理员!"); + //} + //////使用HttpClient方式上传文件 + //var carrier_code = _cache.GetAllMappingCarrier().Result.Where(x => x.Module == "HeChuan" && x.MapCode == order.CARRIERID).Select(x => x.Code).First(); + //string fn = string.Empty; + //using (var httpClient = new HttpClient()) + //{ + // using (var request = new HttpRequestMessage(new HttpMethod("Post"), url)) + // { + // request.Headers.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded"); + // var multipartContent = new MultipartFormDataContent(); + // multipartContent.Add(new StringContent("user_key"), key); + // multipartContent.Add(new StringContent("user_secret"), secret); + // multipartContent.Add(new StringContent("web_user"), account.Account); + // multipartContent.Add(new StringContent("web_psw"), account.Password); + // multipartContent.Add(new StringContent("carrier_code"), carrier_code); + // multipartContent.Add(new StreamContent(filestream, (int)filestream.Length), "file", fileName); + // request.Content = multipartContent; + // var response = await httpClient.SendAsync(request); + // if (response.IsSuccessStatusCode) + // { + // var strRtn = response.Content.ReadAsStringAsync().Result; + // var jobj = strRtn.ToJObject(); + // if (jobj.GetIntValue("code") == 200) + // { + // fn = jobj.GetStringValue("msg"); + + // } + // else + // { + // throw Oops.Bah(jobj.GetStringValue("msg")); + // } + // } + // } + //} + + //return fn; + //#endregion + #endregion + return await XMCEXCEL(model.Id); + } + else { + return await InnerBookingOrClosingEDI(model); + } + + } + + [NonAction] + public async Task XMCEXCEL(long Id,bool flag=false) { + + var order = _rep.FirstOrDefault(x => x.Id == Id); + var edi = _bookingEDIExt.FirstOrDefault(x => x.BookingId == Id); + var ctn = _repCtn.AsQueryable().Where(x => x.BILLID == Id).ToList(); + #region 箱满仓生成excel文件 + string fileName = String.Empty; + var opt = App.GetOptions(); + var dirAbs = opt.basePath; + if (string.IsNullOrEmpty(dirAbs)) + { + dirAbs = App.WebHostEnvironment.WebRootPath; + } + var fPath = "upload/printtemplate/箱满舱上传Excel模板.xls"; + var fileAbsPath = Path.Combine(dirAbs, fPath); + _logger.LogInformation($"准备调用EXCEL"); + var file = new FileStream(fileAbsPath, FileMode.Open); + var excelwork = new HSSFWorkbook(file); + var sheet = excelwork.GetSheetAt(0); + for (int i = 0; i < sheet.LastRowNum; i++) + { + ////获取行 + var row = sheet.GetRow(i); + if (i == 0) + { + //委托编号 + ICell cell = row.GetCell(5); + if (cell != null) + { + row.Cells[5].SetCellValue(order.CUSTNO); + } + else + { + row.CreateCell(5).SetCellValue(order.CUSTNO); + } } - var fPath = "upload/printtemplate/箱满舱上传Excel模板.xls"; - var fileAbsPath = Path.Combine(dirAbs, fPath); - _logger.LogInformation($"准备调用EXCEL"); - var file = new FileStream(fileAbsPath, FileMode.Open); - var excelwork = new HSSFWorkbook(file); - var sheet = excelwork.GetSheetAt(0); - for (int i = 0; i < sheet.LastRowNum; i++) + if (i == 1) { - ////获取行 - var row = sheet.GetRow(i); - if (i == 0) + //场站 + var yardid = order.YARDID; + if (!string.IsNullOrEmpty(yardid)) { - //委托编号 ICell cell = row.GetCell(5); + var yard = _cache.GetAllMappingYard().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == yardid).Select(x => x.MapCode).First(); if (cell != null) { - row.Cells[5].SetCellValue(order.CUSTNO); + row.Cells[5].SetCellValue(yard); } else { - row.CreateCell(5).SetCellValue(order.CUSTNO); + row.CreateCell(5).SetCellValue(yard); } - } - if (i == 1) - { - //场站 - var yardid = order.YARDID; - if (!string.IsNullOrEmpty(yardid)) - { - ICell cell = row.GetCell(5); - var yard = _cache.GetAllMappingYard().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == yardid).Select(x => x.MapCode).First(); - if (cell != null) - { - row.Cells[5].SetCellValue(yard); - } - else - { - row.CreateCell(5).SetCellValue(yard); - } - } + } + } + if (i == 2) + { + //指定业务员 + ICell cell = row.GetCell(5); + if (cell != null) + { + row.Cells[5].SetCellValue(edi.XMCYWY); } - if (i == 2) + else { - //指定业务员 - ICell cell = row.GetCell(5); - if (cell != null) - { - row.Cells[5].SetCellValue(edi.XMCYWY); - } - else - { - row.CreateCell(5).SetCellValue(edi.XMCYWY); - } + row.CreateCell(5).SetCellValue(edi.XMCYWY); } - if (i == 3) + } + if (i == 3) + { + //提单号 + ICell cell = row.GetCell(5); + if (cell != null) { - //提单号 - ICell cell = row.GetCell(5); - if (cell != null) - { - row.Cells[5].SetCellValue(order.MBLNO); - } - else - { - row.CreateCell(5).SetCellValue(order.MBLNO); - } + row.Cells[5].SetCellValue(order.MBLNO); } - if (i == 8) + else { - //发货人 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.SHIPPER); - } - else - { - row.CreateCell(1).SetCellValue(order.SHIPPER); - } + row.CreateCell(5).SetCellValue(order.MBLNO); } - if (i == 10) + } + if (i == 8) + { + //发货人 + ICell cell = row.GetCell(1); + if (cell != null) { - //发货人代码 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.SHIPPERID); - } - else - { - row.CreateCell(1).SetCellValue(order.SHIPPERID); - } + row.Cells[1].SetCellValue(order.SHIPPER); } - if (i == 11) + else { - //收货人 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.CONSIGNEE); - } - else - { - row.CreateCell(1).SetCellValue(order.CONSIGNEE); - } + row.CreateCell(1).SetCellValue(order.SHIPPER); } - if (i == 14) + } + if (i == 10) + { + //发货人代码 + ICell cell = row.GetCell(1); + if (cell != null) { - //通知人 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.NOTIFYPARTY); - } - else - { - row.CreateCell(1).SetCellValue(order.NOTIFYPARTY); - } + row.Cells[1].SetCellValue(order.SHIPPERID); } - if (i == 17) + else { - //第二通知人 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.NOTIFYPARTY2); - } - else - { - row.CreateCell(1).SetCellValue(order.NOTIFYPARTY2); - } + row.CreateCell(1).SetCellValue(order.SHIPPERID); + } + } + if (i == 11) + { + //收货人 + ICell cell = row.GetCell(1); + if (cell != null) + { + row.Cells[1].SetCellValue(order.CONSIGNEE); } - if (i == 18) + else { - //起运港国际五字代码 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.PORTLOADID); - } - else - { - row.CreateCell(1).SetCellValue(order.PORTLOADID); - } + row.CreateCell(1).SetCellValue(order.CONSIGNEE); + } + } + if (i == 14) + { + //通知人 + ICell cell = row.GetCell(1); + if (cell != null) + { + row.Cells[1].SetCellValue(order.NOTIFYPARTY); + } + else + { + row.CreateCell(1).SetCellValue(order.NOTIFYPARTY); + } + } + if (i == 17) + { + //第二通知人 + ICell cell = row.GetCell(1); + if (cell != null) + { + row.Cells[1].SetCellValue(order.NOTIFYPARTY2); + } + else + { + row.CreateCell(1).SetCellValue(order.NOTIFYPARTY2); + } + } + if (i == 18) + { + //起运港国际五字代码 + ICell cell = row.GetCell(1); + if (cell != null) + { + row.Cells[1].SetCellValue(order.PORTLOADID); + } + else + { + row.CreateCell(1).SetCellValue(order.PORTLOADID); + } - var service = order.SERVICE; - //运输方式 - ICell cell5 = row.GetCell(5); - if (cell5 != null) - { - row.Cells[5].SetCellValue(_cache.GetAllMappingService().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == service).Select(x => x.MapCode).First()); - } - else - { - row.CreateCell(5).SetCellValue(_cache.GetAllMappingService().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == service).Select(x => x.MapCode).First()); - } + var service = order.SERVICE; + //运输方式 + ICell cell5 = row.GetCell(5); + if (cell5 != null) + { + row.Cells[5].SetCellValue(_cache.GetAllMappingService().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == service).Select(x => x.MapCode).First()); + } + else + { + row.CreateCell(5).SetCellValue(_cache.GetAllMappingService().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == service).Select(x => x.MapCode).First()); + } + } + if (i == 19) + { + //卸货港国际五字代码 + ICell cell = row.GetCell(1); + if (cell != null) + { + row.Cells[1].SetCellValue(order.PORTDISCHARGEID); } - if (i == 19) + else + { + row.CreateCell(1).SetCellValue(order.PORTDISCHARGEID); + } + } + if (i == 20) + { + //交货地国际五字代码 + ICell cell = row.GetCell(1); + if (cell != null) + { + row.Cells[1].SetCellValue(order.PLACEDELIVERYID); + } + else { - //卸货港国际五字代码 + row.CreateCell(1).SetCellValue(order.PLACEDELIVERYID); + } + } + if (i == 21) + { + //ETD + + if (order.ETD != null) + { + ICell cell = row.GetCell(1); if (cell != null) { - row.Cells[1].SetCellValue(order.PORTDISCHARGEID); + row.Cells[1].SetCellValue(Convert.ToDateTime(order.ETD).ToString("yyyy-MM-dd")); } else { - row.CreateCell(1).SetCellValue(order.PORTDISCHARGEID); + row.CreateCell(1).SetCellValue(Convert.ToDateTime(order.ETD).ToString("yyyy-MM-dd")); } } - if (i == 20) + + + //船名 + ICell cell4 = row.GetCell(4); + if (cell4 != null) { - //交货地国际五字代码 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.PLACEDELIVERYID); - } - else - { - row.CreateCell(1).SetCellValue(order.PLACEDELIVERYID); - } + row.Cells[4].SetCellValue(order.VESSEL); } - if (i == 21) + else { - //ETD - - if (order.ETD != null) - { - - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(Convert.ToDateTime(order.ETD).ToString("yyyy-MM-dd")); - } - else - { - row.CreateCell(1).SetCellValue(Convert.ToDateTime(order.ETD).ToString("yyyy-MM-dd")); - } - } + row.CreateCell(4).SetCellValue(order.VESSEL); + } + } + if (i == 22) + { + //客户协约号 + ICell cell = row.GetCell(1); + if (cell != null) + { + row.Cells[1].SetCellValue(order.CONTRACTNO); + } + else + { + row.CreateCell(1).SetCellValue(order.CONTRACTNO); + } + } + if (i == 23) + { + //航次 + ICell cell = row.GetCell(4); + if (cell != null) + { + row.Cells[4].SetCellValue(order.VOYNO); + } + else + { + row.CreateCell(4).SetCellValue(order.VOYNO); + } + } + if (i == 26) + { + //唛头 + ICell cell = row.GetCell(0); + if (cell != null) + { + row.Cells[0].SetCellValue(order.MARKS); + } + else + { + row.CreateCell(0).SetCellValue(order.MARKS); + } - //船名 - ICell cell4 = row.GetCell(4); - if (cell4 != null) + if (order.PKGS != null) + { + //件数 + ICell cell1 = row.GetCell(1); + if (cell1 != null) { - row.Cells[4].SetCellValue(order.VESSEL); + row.Cells[1].SetCellValue(order.PKGS.ToString()); } else { - row.CreateCell(4).SetCellValue(order.VESSEL); + row.CreateCell(1).SetCellValue(order.PKGS.ToString()); } } - if (i == 22) + //包装 + ICell cell2 = row.GetCell(2); + if (cell2 != null) { - //客户协约号 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.CONTRACTNO); - } - else - { - row.CreateCell(1).SetCellValue(order.CONTRACTNO); - } + row.Cells[2].SetCellValue(order.KINDPKGS); } - if (i == 23) + else { - //航次 - ICell cell = row.GetCell(4); - if (cell != null) - { - row.Cells[4].SetCellValue(order.VOYNO); - } - else - { - row.CreateCell(4).SetCellValue(order.VOYNO); - } + row.CreateCell(2).SetCellValue(order.KINDPKGS); } - if (i == 26) + //品名 + ICell cell3 = row.GetCell(3); + if (cell3 != null) { - //唛头 - ICell cell = row.GetCell(0); - if (cell != null) - { - row.Cells[0].SetCellValue(order.MARKS); - } - else - { - row.CreateCell(0).SetCellValue(order.MARKS); - } - - if (order.PKGS != null) - { - //件数 - ICell cell1 = row.GetCell(1); - if (cell1 != null) - { - row.Cells[1].SetCellValue(order.PKGS.ToString()); - } - else - { - row.CreateCell(1).SetCellValue(order.PKGS.ToString()); - } - - } - //包装 - ICell cell2 = row.GetCell(2); - if (cell2 != null) - { - row.Cells[2].SetCellValue(order.KINDPKGS); - } - else - { - row.CreateCell(2).SetCellValue(order.KINDPKGS); - } - //品名 - ICell cell3 = row.GetCell(3); + row.Cells[3].SetCellValue(order.DESCRIPTION); + } + else + { + row.CreateCell(3).SetCellValue(order.DESCRIPTION); + } + if (order.KGS != null) + { + //重量 + ICell cell4 = row.GetCell(4); if (cell3 != null) { - row.Cells[3].SetCellValue(order.DESCRIPTION); + row.Cells[4].SetCellValue(order.KGS.ToString()); } else { - row.CreateCell(3).SetCellValue(order.DESCRIPTION); - } - if (order.KGS != null) - { - //重量 - ICell cell4 = row.GetCell(4); - if (cell3 != null) - { - row.Cells[4].SetCellValue(order.KGS.ToString()); - } - else - { - row.CreateCell(4).SetCellValue(order.KGS.ToString()); - } - } - if (order.CBM != null) - { - //尺码 - ICell cell5 = row.GetCell(5); - if (cell5 != null) - { - row.Cells[5].SetCellValue(order.CBM.ToString()); - } - else - { - row.CreateCell(5).SetCellValue(order.CBM.ToString()); - } + row.CreateCell(4).SetCellValue(order.KGS.ToString()); } } - if (i == 39) + if (order.CBM != null) { - var c = ctn.DistinctBy(x => x.CTNALL).ToList(); - var ctnAll = string.Empty; - foreach (var item in c) - { - ctnAll += $"{ctn.Where(x => x.CTNALL == item.CTNALL).Count()}*{_cache.GetAllMappingCtn().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == item.CTNCODE).Select(x => x.MapCode).First()}+"; - } - ctnAll = ctnAll.Substring(0, ctnAll.Length - 1); - //箱型箱量 - ICell cell = row.GetCell(0); - if (cell != null) + //尺码 + ICell cell5 = row.GetCell(5); + if (cell5 != null) { - row.Cells[0].SetCellValue(ctnAll); + row.Cells[5].SetCellValue(order.CBM.ToString()); } else { - row.CreateCell(0).SetCellValue(ctnAll); + row.CreateCell(5).SetCellValue(order.CBM.ToString()); } } - if (i == 42) + } + if (i == 39) + { + var c = ctn.DistinctBy(x => x.CTNALL).ToList(); + var ctnAll = string.Empty; + foreach (var item in c) { - //运费支付方式 - - var BLFRTCode = _cache.GetAllCodeFrt().Result.Where(x => x.EnName == order.BLFRT).Select(x => x.Code).First(); - var bl = string.Empty; - if (!string.IsNullOrEmpty(BLFRTCode)) - { - bl = _cache.GetAllMappingFrt().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == BLFRTCode).Select(x => x.MapCode).First(); - } - ICell cell = row.GetCell(0); - if (cell != null) - { - row.Cells[0].SetCellValue(bl); - } - else - { - row.CreateCell(0).SetCellValue(bl); - } + ctnAll += $"{ctn.Where(x => x.CTNALL == item.CTNALL).Count()}*{_cache.GetAllMappingCtn().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == item.CTNCODE).Select(x => x.MapCode).First()}+"; } - if (i == 43) + ctnAll = ctnAll.Substring(0, ctnAll.Length - 1); + //箱型箱量 + ICell cell = row.GetCell(0); + if (cell != null) { - //hscode - ICell cell = row.GetCell(3); - if (cell != null) - { - row.Cells[3].SetCellValue(order.HSCODE); - } - else - { - row.CreateCell(3).SetCellValue(order.HSCODE); - } + row.Cells[0].SetCellValue(ctnAll); } - if (i == 44) + else { - var BLFRTCode = _cache.GetAllCodeFrt().Result.Where(x => x.EnName == order.BLFRT).Select(x => x.Code).First(); - var bl = string.Empty; - if (!string.IsNullOrEmpty(BLFRTCode)) - { - bl = _cache.GetAllMappingFrt().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == BLFRTCode).Select(x => x.MapCode).First(); - } - if (bl == "预付") - { - //预付地点 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.PREPARDATID); - } - else - { - row.CreateCell(1).SetCellValue(order.PREPARDATID); - } - - } - else if((bl == "到付")) - { - - //预付地点 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.PAYABLEATID); - } - else - { - row.CreateCell(1).SetCellValue(order.PAYABLEATID); - } - + row.CreateCell(0).SetCellValue(ctnAll); + } + } + if (i == 42) + { + //运费支付方式 - } - + var BLFRTCode = _cache.GetAllCodeFrt().Result.Where(x => x.EnName == order.BLFRT).Select(x => x.Code).First(); + var bl = string.Empty; + if (!string.IsNullOrEmpty(BLFRTCode)) + { + bl = _cache.GetAllMappingFrt().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == BLFRTCode).Select(x => x.MapCode).First(); } - if (i == 45) + ICell cell = row.GetCell(0); + if (cell != null) { - //Name accout - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(edi.EmcNameAccount); - } - else - { - row.CreateCell(1).SetCellValue(edi.EmcNameAccount); - } + row.Cells[0].SetCellValue(bl); } - if (i == 47) + else { - //Name accout - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.TEMPSET); - } - else - { - row.CreateCell(1).SetCellValue(order.TEMPSET); - } - - - - //温度 - ICell cell2 = row.GetCell(2); - if (cell2 != null) - { - row.Cells[2].SetCellValue(order.TEMPSET); - } - else - { - row.CreateCell(2).SetCellValue(order.TEMPSET); - } - - - //湿度 - ICell cell3 = row.GetCell(3); - if (cell2 != null) - { - row.Cells[3].SetCellValue(order.HUMIDITY); - } - else - { - row.CreateCell(3).SetCellValue(order.HUMIDITY); - } + row.CreateCell(0).SetCellValue(bl); + } + } + if (i == 43) + { + //hscode + ICell cell = row.GetCell(3); + if (cell != null) + { + row.Cells[3].SetCellValue(order.HSCODE); + } + else + { + row.CreateCell(3).SetCellValue(order.HSCODE); + } + } + if (i == 44) + { + var BLFRTCode = _cache.GetAllCodeFrt().Result.Where(x => x.EnName == order.BLFRT).Select(x => x.Code).First(); + var bl = string.Empty; + if (!string.IsNullOrEmpty(BLFRTCode)) + { + bl = _cache.GetAllMappingFrt().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == BLFRTCode).Select(x => x.MapCode).First(); } - if (i == 49) + if (bl == "预付") { - //危险品编号 + //预付地点 ICell cell = row.GetCell(1); if (cell != null) { - row.Cells[1].SetCellValue(order.DUNNO); + row.Cells[1].SetCellValue(order.PREPARDATID); } else { - row.CreateCell(1).SetCellValue(order.DUNNO); + row.CreateCell(1).SetCellValue(order.PREPARDATID); } + } - if (i == 50) + else if ((bl == "到付")) { - //订舱备注 + + //预付地点 ICell cell = row.GetCell(1); if (cell != null) { - row.Cells[1].SetCellValue(order.SOREMARK); + row.Cells[1].SetCellValue(order.PAYABLEATID); } else { - row.CreateCell(1).SetCellValue(order.SOREMARK); + row.CreateCell(1).SetCellValue(order.PAYABLEATID); } + + } - } - var fileFullPath = Path.Combine(App.WebHostEnvironment.WebRootPath, App.GetOptions().Path);//服务器路径 - if (!Directory.Exists(fileFullPath)) - { - Directory.CreateDirectory(fileFullPath); } - - //2023-4-3,根据合川操作要求,文件名只带提单号 - if (!string.IsNullOrEmpty(order.MBLNO)) + if (i == 45) { - fileName = $"{DateTime.Now.Ticks}_{order.MBLNO}.xls";//名称 + //Name accout + ICell cell = row.GetCell(1); + if (cell != null) + { + row.Cells[1].SetCellValue(edi.EmcNameAccount); + } + else + { + row.CreateCell(1).SetCellValue(edi.EmcNameAccount); + } } - else + if (i == 47) { - fileName = $"{DateTime.Now.Ticks}_{order.MBLNO}.xls";//名称 - } - _logger.LogInformation("导出excel:" + Path.Combine(fileFullPath, fileName)); - var filestream = new FileStream(Path.Combine(fileFullPath, fileName), FileMode.OpenOrCreate, FileAccess.ReadWrite); - excelwork.Write(filestream); - #endregion - #region 调用爬虫接口 + //Name accout + ICell cell = row.GetCell(1); + if (cell != null) + { + row.Cells[1].SetCellValue(order.TEMPSET); + } + else + { + row.CreateCell(1).SetCellValue(order.TEMPSET); + } + - var url = _cache.GetAllDictData().Result.Where(x => x.Code == "xiangManCangPostUrl").Select(x => x.Value).FirstOrDefault(); - var account = _webAccountConfig.GetAccountConfig("XiangManCang", UserManager.UserId).Result; + //温度 + ICell cell2 = row.GetCell(2); + if (cell2 != null) + { + row.Cells[2].SetCellValue(order.TEMPSET); + } + else + { + row.CreateCell(2).SetCellValue(order.TEMPSET); + } - var key = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserKey").Select(x => x.Value).FirstOrDefault(); - if (string.IsNullOrEmpty(key)) - { - throw Oops.Bah("未获取到相关KEY,请联系管理员!"); + //湿度 + ICell cell3 = row.GetCell(3); + if (cell2 != null) + { + row.Cells[3].SetCellValue(order.HUMIDITY); + } + else + { + row.CreateCell(3).SetCellValue(order.HUMIDITY); + } } - - var secret = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserSecret").Select(x => x.Value).FirstOrDefault(); - if (string.IsNullOrEmpty(secret)) + if (i == 49) { - throw Oops.Bah("未获取到相关SECRET,请联系管理员!"); + //危险品编号 + ICell cell = row.GetCell(1); + if (cell != null) + { + row.Cells[1].SetCellValue(order.DUNNO); + } + else + { + row.CreateCell(1).SetCellValue(order.DUNNO); + } } - ////使用HttpClient方式上传文件 - var carrier_code = _cache.GetAllMappingCarrier().Result.Where(x => x.Module == "HeChuan" && x.MapCode == order.CARRIERID).Select(x => x.Code).First(); - string fn = string.Empty; - using (var httpClient = new HttpClient()) + if (i == 50) { - using (var request = new HttpRequestMessage(new HttpMethod("Post"), url)) + //订舱备注 + ICell cell = row.GetCell(1); + if (cell != null) { - request.Headers.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded"); - var multipartContent = new MultipartFormDataContent(); - multipartContent.Add(new StringContent("user_key"), key); - multipartContent.Add(new StringContent("user_secret"), secret); - multipartContent.Add(new StringContent("web_user"), account.Account); - multipartContent.Add(new StringContent("web_psw"), account.Password); - multipartContent.Add(new StringContent("carrier_code"), carrier_code); - multipartContent.Add(new StreamContent(filestream, (int)filestream.Length), "file", fileName); - request.Content = multipartContent; - var response = await httpClient.SendAsync(request); - if (response.IsSuccessStatusCode) - { - var strRtn = response.Content.ReadAsStringAsync().Result; - var jobj = strRtn.ToJObject(); - if (jobj.GetIntValue("code") == 200) - { - fn = jobj.GetStringValue("msg"); - - } - else - { - throw Oops.Bah(jobj.GetStringValue("msg")); - } - } + row.Cells[1].SetCellValue(order.SOREMARK); + } + else + { + row.CreateCell(1).SetCellValue(order.SOREMARK); } } + } - return fn; - #endregion + var fileFullPath = Path.Combine(App.WebHostEnvironment.WebRootPath, App.GetOptions().Path);//服务器路径 + if (!Directory.Exists(fileFullPath)) + { + Directory.CreateDirectory(fileFullPath); } - else { - return await InnerBookingOrClosingEDI(model); + + //2023-4-3,根据合川操作要求,文件名只带提单号 + if (!string.IsNullOrEmpty(order.MBLNO)) + { + fileName = $"{DateTime.Now.Ticks}_{order.MBLNO}.xls";//名称 + } + else + { + fileName = $"{DateTime.Now.Ticks}_{order.MBLNO}.xls";//名称 + } + _logger.LogInformation("导出excel:" + Path.Combine(fileFullPath, fileName)); + var filestream = new FileStream(Path.Combine(fileFullPath, fileName), FileMode.OpenOrCreate, FileAccess.ReadWrite); + excelwork.Write(filestream); + + #endregion + if (flag) { + filestream.Close(); + filestream.Dispose(); + var fpath = Path.Combine(fileFullPath, fileName); + var fInfo = new FileInfo(fpath); + _logger.LogInformation("箱满仓文件地址:" + fpath + " " + fInfo); + return new FileStreamResult(new FileStream(fpath, FileMode.Open), "application/octet-stream") { FileDownloadName = fInfo.Name }; } - - } - [NonAction] - public async Task InnerBookingOrClosingEDI(BookingOrClosingEDIOrderDto model) - { - string batchNo = IDGen.NextID().ToString(); + #region 调用爬虫接口 - _logger.LogInformation("批次={no}获取请求订舱、截单EDI {msg}", batchNo, JSON.Serialize(model)); - /* - 发送订舱和截单EDI的流程 - 1、通过订单号获取订单信息。 + var url = _cache.GetAllDictData().Result.Where(x => x.Code == "xiangManCangPostUrl").Select(x => x.Value).FirstOrDefault(); + + var account = _webAccountConfig.GetAccountConfig("XiangManCang", UserManager.UserId).Result; + + + var key = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserKey").Select(x => x.Value).FirstOrDefault(); + if (string.IsNullOrEmpty(key)) + { + throw Oops.Bah("未获取到相关KEY,请联系管理员!"); + } + + var secret = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserSecret").Select(x => x.Value).FirstOrDefault(); + if (string.IsNullOrEmpty(secret)) + { + throw Oops.Bah("未获取到相关SECRET,请联系管理员!"); + } + ////使用HttpClient方式上传文件 + var carrier_code = _cache.GetAllMappingCarrier().Result.Where(x => x.Module == "HeChuan" && x.MapCode == order.CARRIERID).Select(x => x.Code).First(); + string fn = string.Empty; + using (var httpClient = new HttpClient()) + { + using (var request = new HttpRequestMessage(new HttpMethod("Post"), url)) + { + request.Headers.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded"); + var multipartContent = new MultipartFormDataContent(); + multipartContent.Add(new StringContent("user_key"), key); + multipartContent.Add(new StringContent("user_secret"), secret); + multipartContent.Add(new StringContent("web_user"), account.Account); + multipartContent.Add(new StringContent("web_psw"), account.Password); + multipartContent.Add(new StringContent("carrier_code"), carrier_code); + multipartContent.Add(new StreamContent(filestream, (int)filestream.Length), "file", fileName); + request.Content = multipartContent; + var response = await httpClient.SendAsync(request); + if (response.IsSuccessStatusCode) + { + var strRtn = response.Content.ReadAsStringAsync().Result; + var jobj = strRtn.ToJObject(); + if (jobj.GetIntValue("code") == 200) + { + fn = jobj.GetStringValue("msg"); + + } + else + { + throw Oops.Bah(jobj.GetStringValue("msg")); + } + } + } + } + + return fn; + #endregion + } + + + [NonAction] + public async Task InnerBookingOrClosingEDI(BookingOrClosingEDIOrderDto model) + { + string batchNo = IDGen.NextID().ToString(); + + _logger.LogInformation("批次={no}获取请求订舱、截单EDI {msg}", batchNo, JSON.Serialize(model)); + /* + 发送订舱和截单EDI的流程 + 1、通过订单号获取订单信息。 2、检查订单的必填信息。 3、根据船公司ID获取对应的路由枚举。 4、获取EDI转换参数。(集装箱型号、包装方式) @@ -5713,541 +6317,542 @@ namespace Myshipping.Application [FromQuery] string forwarderCode, [FromQuery] string forwarderName, [FromQuery] string fileRole, [FromQuery] string sendType) { var order = _rep.FirstOrDefault(x => x.Id == id); - var edi = _bookingEDIExt.FirstOrDefault(x => x.BookingId == id); - var ctn = _repCtn.AsQueryable().Where(x => x.BILLID == id).ToList(); var FORWARDER = order.FORWARDER; var dictvalue = _cache.GetAllDictData().Result.Where(x => x.Code == "XiangManCang").Select(x => x.Value).FirstOrDefault(); _logger.LogInformation("FORWARDER:" + FORWARDER + "dictvalue:" + dictvalue); if (!string.IsNullOrEmpty(FORWARDER) && dictvalue == FORWARDER) { - #region 箱满仓生成excel文件 - string fileName = String.Empty; - var opt = App.GetOptions(); - var dirAbs = opt.basePath; - if (string.IsNullOrEmpty(dirAbs)) - { - dirAbs = App.WebHostEnvironment.WebRootPath; - } - var fPath = "upload/printtemplate/箱满舱上传Excel模板.xls"; - var fileAbsPath = Path.Combine(dirAbs, fPath); - _logger.LogInformation($"准备调用EXCEL"); - var file = new FileStream(fileAbsPath, FileMode.Open); - var excelwork = new HSSFWorkbook(file); - var sheet = excelwork.GetSheetAt(0); - for (int i = 0; i < sheet.LastRowNum; i++) - { - ////获取行 - var row = sheet.GetRow(i); - if (i == 0) - { - //委托编号 - ICell cell = row.GetCell(5); - if (cell != null) - { - row.Cells[5].SetCellValue(order.CUSTNO); - } - else - { - row.CreateCell(5).SetCellValue(order.CUSTNO); - } - } - if (i == 1) - { - //场站 - var yardid = order.YARDID; - if (!string.IsNullOrEmpty(yardid)) - { - ICell cell = row.GetCell(5); - var yard = _cache.GetAllMappingYard().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == yardid).Select(x => x.MapCode).First(); - if (cell != null) - { - row.Cells[5].SetCellValue(yard); - } - else - { - row.CreateCell(5).SetCellValue(yard); - } - - } - - } - if (i == 2) - { - //指定业务员 - ICell cell = row.GetCell(5); - if (cell != null) - { - row.Cells[5].SetCellValue(edi.XMCYWY); - } - else - { - row.CreateCell(5).SetCellValue(edi.XMCYWY); - } - } - if (i == 3) - { - //提单号 - ICell cell = row.GetCell(5); - if (cell != null) - { - row.Cells[5].SetCellValue(order.MBLNO); - } - else - { - row.CreateCell(5).SetCellValue(order.MBLNO); - } - } - if (i == 8) - { - //发货人 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.SHIPPER); - } - else - { - row.CreateCell(1).SetCellValue(order.SHIPPER); - } - } - if (i == 10) - { - //发货人代码 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.SHIPPERID); - } - else - { - row.CreateCell(1).SetCellValue(order.SHIPPERID); - } - } - if (i == 11) - { - //收货人 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.CONSIGNEE); - } - else - { - row.CreateCell(1).SetCellValue(order.CONSIGNEE); - } - } - if (i == 14) - { - //通知人 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.NOTIFYPARTY); - } - else - { - row.CreateCell(1).SetCellValue(order.NOTIFYPARTY); - } - } - if (i == 17) - { - //第二通知人 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.NOTIFYPARTY2); - } - else - { - row.CreateCell(1).SetCellValue(order.NOTIFYPARTY2); - } - } - if (i == 18) - { - //起运港国际五字代码 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.PORTLOADID); - } - else - { - row.CreateCell(1).SetCellValue(order.PORTLOADID); - } - - var service = order.SERVICE; - //运输方式 - ICell cell5 = row.GetCell(5); - if (cell5 != null) - { - row.Cells[5].SetCellValue(_cache.GetAllMappingService().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == service).Select(x => x.MapCode).First()); - } - else - { - row.CreateCell(5).SetCellValue(_cache.GetAllMappingService().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == service).Select(x => x.MapCode).First()); - } - - - - - - } - if (i == 19) - { - //卸货港国际五字代码 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.PORTDISCHARGEID); - } - else - { - row.CreateCell(1).SetCellValue(order.PORTDISCHARGEID); - } - } - if (i == 20) - { - //交货地国际五字代码 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.PLACEDELIVERYID); - } - else - { - row.CreateCell(1).SetCellValue(order.PLACEDELIVERYID); - } - } - if (i == 21) - { - //ETD - - if (order.ETD != null) - { - - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(Convert.ToDateTime(order.ETD).ToString("yyyy-MM-dd")); - } - else - { - row.CreateCell(1).SetCellValue(Convert.ToDateTime(order.ETD).ToString("yyyy-MM-dd")); - } - } - - - //船名 - ICell cell4 = row.GetCell(4); - if (cell4 != null) - { - row.Cells[4].SetCellValue(order.VESSEL); - } - else - { - row.CreateCell(4).SetCellValue(order.VESSEL); - } - - } - if (i == 22) - { - //客户协约号 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.CONTRACTNO); - } - else - { - row.CreateCell(1).SetCellValue(order.CONTRACTNO); - } - } - if (i == 23) - { - //航次 - ICell cell = row.GetCell(4); - if (cell != null) - { - row.Cells[4].SetCellValue(order.VOYNO); - } - else - { - row.CreateCell(4).SetCellValue(order.VOYNO); - } - } - if (i == 26) - { - //唛头 - ICell cell = row.GetCell(0); - if (cell != null) - { - row.Cells[0].SetCellValue(order.MARKS); - } - else - { - row.CreateCell(0).SetCellValue(order.MARKS); - } - - if (order.PKGS != null) - { - //件数 - ICell cell1 = row.GetCell(1); - if (cell1 != null) - { - row.Cells[1].SetCellValue(order.PKGS.ToString()); - } - else - { - row.CreateCell(1).SetCellValue(order.PKGS.ToString()); - } + #region + //#region 箱满仓生成excel文件 + //string fileName = String.Empty; + //var opt = App.GetOptions(); + //var dirAbs = opt.basePath; + //if (string.IsNullOrEmpty(dirAbs)) + //{ + // dirAbs = App.WebHostEnvironment.WebRootPath; + //} + //var fPath = "upload/printtemplate/箱满舱上传Excel模板.xls"; + //var fileAbsPath = Path.Combine(dirAbs, fPath); + //_logger.LogInformation($"准备调用EXCEL"); + //var file = new FileStream(fileAbsPath, FileMode.Open); + //var excelwork = new HSSFWorkbook(file); + //var sheet = excelwork.GetSheetAt(0); + //for (int i = 0; i < sheet.LastRowNum; i++) + //{ + // ////获取行 + // var row = sheet.GetRow(i); + // if (i == 0) + // { + // //委托编号 + // ICell cell = row.GetCell(5); + // if (cell != null) + // { + // row.Cells[5].SetCellValue(order.CUSTNO); + // } + // else + // { + // row.CreateCell(5).SetCellValue(order.CUSTNO); + // } + // } + // if (i == 1) + // { + // //场站 + // var yardid = order.YARDID; + // if (!string.IsNullOrEmpty(yardid)) + // { + // ICell cell = row.GetCell(5); + // var yard = _cache.GetAllMappingYard().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == yardid).Select(x => x.MapCode).First(); + // if (cell != null) + // { + // row.Cells[5].SetCellValue(yard); + // } + // else + // { + // row.CreateCell(5).SetCellValue(yard); + // } + + // } - } - //包装 - ICell cell2 = row.GetCell(2); - if (cell2 != null) - { - row.Cells[2].SetCellValue(order.KINDPKGS); - } - else - { - row.CreateCell(2).SetCellValue(order.KINDPKGS); - } - //品名 - ICell cell3 = row.GetCell(3); - if (cell3 != null) - { - row.Cells[3].SetCellValue(order.DESCRIPTION); - } - else - { - row.CreateCell(3).SetCellValue(order.DESCRIPTION); - } - if (order.KGS != null) - { - //重量 - ICell cell4 = row.GetCell(4); - if (cell3 != null) - { - row.Cells[4].SetCellValue(order.KGS.ToString()); - } - else - { - row.CreateCell(4).SetCellValue(order.KGS.ToString()); - } - } - if (order.CBM != null) - { - //尺码 - ICell cell5 = row.GetCell(5); - if (cell5 != null) - { - row.Cells[5].SetCellValue(order.CBM.ToString()); - } - else - { - row.CreateCell(5).SetCellValue(order.CBM.ToString()); - } - } - } - if (i == 39) - { - var c = ctn.DistinctBy(x => x.CTNALL).ToList(); - var ctnAll = string.Empty; - foreach (var item in c) - { - ctnAll += $"{ctn.Where(x => x.CTNALL == item.CTNALL).Count()}*{_cache.GetAllMappingCtn().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == item.CTNCODE).Select(x => x.MapCode).First()}+"; - } - ctnAll = ctnAll.Substring(0, ctnAll.Length - 1); - //箱型箱量 - ICell cell = row.GetCell(0); - if (cell != null) - { - row.Cells[0].SetCellValue(ctnAll); - } - else - { - row.CreateCell(0).SetCellValue(ctnAll); - } - } - if (i == 42) - { - //运费支付方式 + // } + // if (i == 2) + // { + // //指定业务员 + // ICell cell = row.GetCell(5); + // if (cell != null) + // { + // row.Cells[5].SetCellValue(edi.XMCYWY); + // } + // else + // { + // row.CreateCell(5).SetCellValue(edi.XMCYWY); + // } + // } + // if (i == 3) + // { + // //提单号 + // ICell cell = row.GetCell(5); + // if (cell != null) + // { + // row.Cells[5].SetCellValue(order.MBLNO); + // } + // else + // { + // row.CreateCell(5).SetCellValue(order.MBLNO); + // } + // } + // if (i == 8) + // { + // //发货人 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.SHIPPER); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.SHIPPER); + // } + // } + // if (i == 10) + // { + // //发货人代码 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.SHIPPERID); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.SHIPPERID); + // } + // } + // if (i == 11) + // { + // //收货人 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.CONSIGNEE); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.CONSIGNEE); + // } + // } + // if (i == 14) + // { + // //通知人 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.NOTIFYPARTY); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.NOTIFYPARTY); + // } + // } + // if (i == 17) + // { + // //第二通知人 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.NOTIFYPARTY2); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.NOTIFYPARTY2); + // } + // } + // if (i == 18) + // { + // //起运港国际五字代码 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.PORTLOADID); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.PORTLOADID); + // } - var BLFRTCode = _cache.GetAllCodeFrt().Result.Where(x => x.EnName == order.BLFRT).Select(x => x.Code).First(); - var bl = string.Empty; - if (!string.IsNullOrEmpty(BLFRTCode)) - { - bl = _cache.GetAllMappingFrt().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == BLFRTCode).Select(x => x.MapCode).First(); - } - ICell cell = row.GetCell(0); - if (cell != null) - { - row.Cells[0].SetCellValue(bl); - } - else - { - row.CreateCell(0).SetCellValue(bl); - } - } - if (i == 43) - { - //hscode - ICell cell = row.GetCell(3); - if (cell != null) - { - row.Cells[3].SetCellValue(order.HSCODE); - } - else - { - row.CreateCell(3).SetCellValue(order.HSCODE); - } - } - if (i == 44) - { - var BLFRTCode = _cache.GetAllCodeFrt().Result.Where(x => x.EnName == order.BLFRT).Select(x => x.Code).First(); - var bl = string.Empty; - if (!string.IsNullOrEmpty(BLFRTCode)) - { - bl = _cache.GetAllMappingFrt().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == BLFRTCode).Select(x => x.MapCode).First(); - } - if (bl == "预付") - { - //预付地点 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.PREPARDATID); - } - else - { - row.CreateCell(1).SetCellValue(order.PREPARDATID); - } + // var service = order.SERVICE; + // //运输方式 + // ICell cell5 = row.GetCell(5); + // if (cell5 != null) + // { + // row.Cells[5].SetCellValue(_cache.GetAllMappingService().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == service).Select(x => x.MapCode).First()); + // } + // else + // { + // row.CreateCell(5).SetCellValue(_cache.GetAllMappingService().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == service).Select(x => x.MapCode).First()); + // } - } - else if ((bl == "到付")) - { - //预付地点 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.PAYABLEATID); - } - else - { - row.CreateCell(1).SetCellValue(order.PAYABLEATID); - } - } - - } - if (i == 45) - { - //Name accout - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(edi.EmcNameAccount); - } - else - { - row.CreateCell(1).SetCellValue(edi.EmcNameAccount); - } - } - if (i == 47) - { - //Name accout - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.TEMPSET); - } - else - { - row.CreateCell(1).SetCellValue(order.TEMPSET); - } - + // } + // if (i == 19) + // { + // //卸货港国际五字代码 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.PORTDISCHARGEID); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.PORTDISCHARGEID); + // } + // } + // if (i == 20) + // { + // //交货地国际五字代码 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.PLACEDELIVERYID); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.PLACEDELIVERYID); + // } + // } + // if (i == 21) + // { + // //ETD + + // if (order.ETD != null) + // { + + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(Convert.ToDateTime(order.ETD).ToString("yyyy-MM-dd")); + // } + // else + // { + // row.CreateCell(1).SetCellValue(Convert.ToDateTime(order.ETD).ToString("yyyy-MM-dd")); + // } + // } + + + // //船名 + // ICell cell4 = row.GetCell(4); + // if (cell4 != null) + // { + // row.Cells[4].SetCellValue(order.VESSEL); + // } + // else + // { + // row.CreateCell(4).SetCellValue(order.VESSEL); + // } - //温度 - ICell cell2 = row.GetCell(2); - if (cell2 != null) - { - row.Cells[2].SetCellValue(order.TEMPSET); - } - else - { - row.CreateCell(2).SetCellValue(order.TEMPSET); - } + // } + // if (i == 22) + // { + // //客户协约号 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.CONTRACTNO); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.CONTRACTNO); + // } + // } + // if (i == 23) + // { + // //航次 + // ICell cell = row.GetCell(4); + // if (cell != null) + // { + // row.Cells[4].SetCellValue(order.VOYNO); + // } + // else + // { + // row.CreateCell(4).SetCellValue(order.VOYNO); + // } + // } + // if (i == 26) + // { + // //唛头 + // ICell cell = row.GetCell(0); + // if (cell != null) + // { + // row.Cells[0].SetCellValue(order.MARKS); + // } + // else + // { + // row.CreateCell(0).SetCellValue(order.MARKS); + // } + + // if (order.PKGS != null) + // { + // //件数 + // ICell cell1 = row.GetCell(1); + // if (cell1 != null) + // { + // row.Cells[1].SetCellValue(order.PKGS.ToString()); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.PKGS.ToString()); + // } + + // } + // //包装 + // ICell cell2 = row.GetCell(2); + // if (cell2 != null) + // { + // row.Cells[2].SetCellValue(order.KINDPKGS); + // } + // else + // { + // row.CreateCell(2).SetCellValue(order.KINDPKGS); + // } + // //品名 + // ICell cell3 = row.GetCell(3); + // if (cell3 != null) + // { + // row.Cells[3].SetCellValue(order.DESCRIPTION); + // } + // else + // { + // row.CreateCell(3).SetCellValue(order.DESCRIPTION); + // } + // if (order.KGS != null) + // { + // //重量 + // ICell cell4 = row.GetCell(4); + // if (cell3 != null) + // { + // row.Cells[4].SetCellValue(order.KGS.ToString()); + // } + // else + // { + // row.CreateCell(4).SetCellValue(order.KGS.ToString()); + // } + // } + // if (order.CBM != null) + // { + // //尺码 + // ICell cell5 = row.GetCell(5); + // if (cell5 != null) + // { + // row.Cells[5].SetCellValue(order.CBM.ToString()); + // } + // else + // { + // row.CreateCell(5).SetCellValue(order.CBM.ToString()); + // } + // } + // } + // if (i == 39) + // { + // var c = ctn.DistinctBy(x => x.CTNALL).ToList(); + // var ctnAll = string.Empty; + // foreach (var item in c) + // { + // ctnAll += $"{ctn.Where(x => x.CTNALL == item.CTNALL).Count()}*{_cache.GetAllMappingCtn().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == item.CTNCODE).Select(x => x.MapCode).First()}+"; + // } + // ctnAll = ctnAll.Substring(0, ctnAll.Length - 1); + // //箱型箱量 + // ICell cell = row.GetCell(0); + // if (cell != null) + // { + // row.Cells[0].SetCellValue(ctnAll); + // } + // else + // { + // row.CreateCell(0).SetCellValue(ctnAll); + // } + // } + // if (i == 42) + // { + // //运费支付方式 + + // var BLFRTCode = _cache.GetAllCodeFrt().Result.Where(x => x.EnName == order.BLFRT).Select(x => x.Code).First(); + // var bl = string.Empty; + // if (!string.IsNullOrEmpty(BLFRTCode)) + // { + // bl = _cache.GetAllMappingFrt().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == BLFRTCode).Select(x => x.MapCode).First(); + // } + // ICell cell = row.GetCell(0); + // if (cell != null) + // { + // row.Cells[0].SetCellValue(bl); + // } + // else + // { + // row.CreateCell(0).SetCellValue(bl); + // } + // } + // if (i == 43) + // { + // //hscode + // ICell cell = row.GetCell(3); + // if (cell != null) + // { + // row.Cells[3].SetCellValue(order.HSCODE); + // } + // else + // { + // row.CreateCell(3).SetCellValue(order.HSCODE); + // } + // } + // if (i == 44) + // { + // var BLFRTCode = _cache.GetAllCodeFrt().Result.Where(x => x.EnName == order.BLFRT).Select(x => x.Code).First(); + // var bl = string.Empty; + // if (!string.IsNullOrEmpty(BLFRTCode)) + // { + // bl = _cache.GetAllMappingFrt().Result.Where(x => x.Module == "XiangManCangEDI" && x.Code == BLFRTCode).Select(x => x.MapCode).First(); + // } + // if (bl == "预付") + // { + // //预付地点 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.PREPARDATID); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.PREPARDATID); + // } + + // } + // else if ((bl == "到付")) + // { + + // //预付地点 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.PAYABLEATID); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.PAYABLEATID); + // } + + + // } + // } + // if (i == 45) + // { + // //Name accout + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(edi.EmcNameAccount); + // } + // else + // { + // row.CreateCell(1).SetCellValue(edi.EmcNameAccount); + // } + // } + // if (i == 47) + // { + // //Name accout + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.TEMPSET); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.TEMPSET); + // } + + + + // //温度 + // ICell cell2 = row.GetCell(2); + // if (cell2 != null) + // { + // row.Cells[2].SetCellValue(order.TEMPSET); + // } + // else + // { + // row.CreateCell(2).SetCellValue(order.TEMPSET); + // } + + + // //湿度 + // ICell cell3 = row.GetCell(3); + // if (cell2 != null) + // { + // row.Cells[3].SetCellValue(order.HUMIDITY); + // } + // else + // { + // row.CreateCell(3).SetCellValue(order.HUMIDITY); + // } + // } + // if (i == 49) + // { + // //危险品编号 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.DUNNO); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.DUNNO); + // } + // } + // if (i == 50) + // { + // //订舱备注 + // ICell cell = row.GetCell(1); + // if (cell != null) + // { + // row.Cells[1].SetCellValue(order.SOREMARK); + // } + // else + // { + // row.CreateCell(1).SetCellValue(order.SOREMARK); + // } + // } + //} - //湿度 - ICell cell3 = row.GetCell(3); - if (cell2 != null) - { - row.Cells[3].SetCellValue(order.HUMIDITY); - } - else - { - row.CreateCell(3).SetCellValue(order.HUMIDITY); - } - } - if (i == 49) - { - //危险品编号 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.DUNNO); - } - else - { - row.CreateCell(1).SetCellValue(order.DUNNO); - } - } - if (i == 50) - { - //订舱备注 - ICell cell = row.GetCell(1); - if (cell != null) - { - row.Cells[1].SetCellValue(order.SOREMARK); - } - else - { - row.CreateCell(1).SetCellValue(order.SOREMARK); - } - } - } + //var fileFullPath = Path.Combine(App.WebHostEnvironment.WebRootPath, App.GetOptions().Path);//服务器路径 + //if (!Directory.Exists(fileFullPath)) + //{ + // Directory.CreateDirectory(fileFullPath); + //} - var fileFullPath = Path.Combine(App.WebHostEnvironment.WebRootPath, App.GetOptions().Path);//服务器路径 - if (!Directory.Exists(fileFullPath)) - { - Directory.CreateDirectory(fileFullPath); - } - - if (!string.IsNullOrEmpty(order.MBLNO)) - { - fileName = $"{DateTime.Now.Ticks}_{order.MBLNO}.xls";//名称 - } - else - { - fileName = $"{DateTime.Now.Ticks}_{order.MBLNO}.xls";//名称 - } - _logger.LogInformation("导出excel:" + Path.Combine(fileFullPath, fileName)); - var filestream = new FileStream(Path.Combine(fileFullPath, fileName), FileMode.OpenOrCreate, FileAccess.ReadWrite); - excelwork.Write(filestream); - filestream.Close(); - filestream.Dispose(); + //if (!string.IsNullOrEmpty(order.MBLNO)) + //{ + // fileName = $"{DateTime.Now.Ticks}_{order.MBLNO}.xls";//名称 + //} + //else + //{ + // fileName = $"{DateTime.Now.Ticks}_{order.MBLNO}.xls";//名称 + //} + //_logger.LogInformation("导出excel:" + Path.Combine(fileFullPath, fileName)); + //var filestream = new FileStream(Path.Combine(fileFullPath, fileName), FileMode.OpenOrCreate, FileAccess.ReadWrite); + //excelwork.Write(filestream); + //filestream.Close(); + //filestream.Dispose(); + //#endregion + ////return new FileStreamResult( filestream, "application/octet-stream") { FileDownloadName = fileName }; + //var fpath = Path.Combine(fileFullPath, fileName); + //var fInfo = new FileInfo(fpath); + //_logger.LogInformation("箱满仓文件地址:" + fpath + " " + fInfo); + //return new FileStreamResult(new FileStream(fpath, FileMode.Open), "application/octet-stream") { FileDownloadName = fInfo.Name }; #endregion - //return new FileStreamResult( filestream, "application/octet-stream") { FileDownloadName = fileName }; - var fpath = Path.Combine(fileFullPath, fileName); - var fInfo = new FileInfo(fpath); - _logger.LogInformation("箱满仓文件地址:" + fpath + " " + fInfo); - return new FileStreamResult(new FileStream(fpath, FileMode.Open), "application/octet-stream") { FileDownloadName = fInfo.Name }; - + + return await XMCEXCEL(id, true); } @@ -7469,7 +8074,7 @@ namespace Myshipping.Application { throw Oops.Bah("请上传正确数据"); } - var order = await _rep.AsQueryable().Filter(null, true).Where(x => ids.Contains(x.Id) && x.TenantId == UserManager.TENANT_ID).ToListAsync(); + var order = await _rep.AsQueryable().Filter(null, true).Where(x => ids.Contains(x.Id) && x.TenantId == UserManager.TENANT_ID&&x.IsDeleted==false).ToListAsync(); var dto = order.Adapt>(); if (dto.Count() == 0) @@ -7501,15 +8106,15 @@ namespace Myshipping.Application // item.ISSUETYPE = ISSUETYPE; //} - var ctn = await _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == item.Id).ToListAsync(); + var ctn = await _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == item.Id && x.IsDeleted == false).ToListAsync(); item.ctnInputs = ctn.Adapt>(); foreach (var it in item.ctnInputs) { - var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id).ToListAsync(); + var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id && x.IsDeleted == false).ToListAsync(); it.ctnDetailInputs = ctnDetailInputs.Adapt>(); } - var BookingEDIExt = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id).FirstAsync(); + var BookingEDIExt = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id && x.IsDeleted == false).FirstAsync(); if (BookingEDIExt != null) { item.BookingEDIExt = BookingEDIExt.Adapt(); @@ -7522,21 +8127,21 @@ namespace Myshipping.Application ExtData = t.ExtData }).Distinct().ToListAsync(); - var childrens = await _rep.AsQueryable().Filter(null, true).Where(x => x.ParentId == item.Id && x.TenantId == UserManager.TENANT_ID).ToListAsync(); + var childrens = await _rep.AsQueryable().Filter(null, true).Where(x => x.ParentId == item.Id && x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync(); item.childrens = childrens.Adapt>(); foreach (var childitem in item.childrens) { - var ctnInputs = await _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == childitem.Id).ToListAsync(); + var ctnInputs = await _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == childitem.Id && x.IsDeleted == false).ToListAsync(); childitem.ctnInputs = ctnInputs.Adapt>(); foreach (var it in childitem.ctnInputs) { - var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id).ToListAsync(); + var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id && x.IsDeleted == false).ToListAsync(); it.ctnDetailInputs = ctnDetailInputs.Adapt>(); } - var childBookingEDIExt = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == childitem.Id).FirstAsync(); + var childBookingEDIExt = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == childitem.Id && x.IsDeleted == false).FirstAsync(); if (childBookingEDIExt != null) { childitem.BookingEDIExt = childBookingEDIExt.Adapt(); diff --git a/Myshipping.Application/Service/BookingOrder/Dto/BookingEDIExtDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/BookingEDIExtDto.cs index d8959dd3..96120cab 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/BookingEDIExtDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/BookingEDIExtDto.cs @@ -172,9 +172,6 @@ namespace Myshipping.Application /// public string CNPTNo { get; set; } - - - /// /// 箱满仓业务员 /// diff --git a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs index 2f8f017a..7f27fae0 100644 --- a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs @@ -40,11 +40,11 @@ namespace Myshipping.Application /// /// 订舱、截单EDI请求 /// 返回回执 - Task SendBookingOrClosingEDI (BookingOrClosingEDIOrderDto model); + Task SendBookingOrClosingEDI (BookingOrClosingEDIOrderDto model); Task BachUpdate(BatchUpdate dto); - Task InnerBookingOrClosingEDI(BookingOrClosingEDIOrderDto model); + Task InnerBookingOrClosingEDI(BookingOrClosingEDIOrderDto model); Task SendBookingOrder(long[] ids); From fc0dfaa6b5675c8393547a9cf64654eae7790955 Mon Sep 17 00:00:00 2001 From: wet <1034391973@qq.com> Date: Tue, 6 Jun 2023 14:52:35 +0800 Subject: [PATCH 2/2] 1 --- .../BookingOrder/BookingOrderService.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 0e8d35f7..f0214356 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -2203,6 +2203,24 @@ namespace Myshipping.Application } } + [HttpPost("/BookingOrder/RefreshBillTrace")] + public async Task RefreshBillTrace(string Ids) { + + var url = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "response_seae_billtraceRefreshurl").Value; + var html = await url.SetHttpMethod(HttpMethod.Post).SetQueries(new { Ids = Ids, flag=true }).SetRetryPolicy(3, 5000).SendAsAsync(); + _logger.LogInformation("调用运踪刷新接口返回" + html.ToJsonString()); + if (html.Success != true) + { + _logger.LogError("调用运踪刷新接口返回:" + html.ToJsonString()); + throw Oops.Bah(html.Message); + } + } + + + + + + /// /// 插入货运动态 ///