|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Furion.DependencyInjection;
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Furion;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Furion.DataEncryption;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Security.Claims;
|
|
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
|
|
|
using Microsoft.AspNetCore.Authentication;
|
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Furion.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using Myshipping.Application.Service.BookingOrder.Dto;
|
|
|
|
|
using Myshipping.Application.ConfigOption;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Yitter.IdGenerator;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
using Furion.RemoteRequest.Extensions;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using Myshipping.Application.EDI;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using Myshipping.Core.Helper;
|
|
|
|
|
using Myshipping.Application.Enum;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 订舱服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings("Application", Name = "BookingOrder", Order = 1)]
|
|
|
|
|
public class BookingOrderService : IBookingOrderService, IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrder> _rep;
|
|
|
|
|
private readonly SqlSugarRepository<BookingCtn> _repCtn;
|
|
|
|
|
private readonly SqlSugarRepository<BookingCtnDetail> _ctndetailrep;
|
|
|
|
|
private readonly SqlSugarRepository<BookingLog> _bookinglog;
|
|
|
|
|
private readonly SqlSugarRepository<BookingLogDetail> _bookinglogdetail;
|
|
|
|
|
private readonly SqlSugarRepository<BookingRemark> _bookingremark;
|
|
|
|
|
private readonly SqlSugarRepository<BookingFile> _bookingfile;
|
|
|
|
|
private readonly SqlSugarRepository<DjyWebsiteAccountConfig> _repWebAcc;
|
|
|
|
|
private readonly SqlSugarRepository<SysDictData> _dicdata;
|
|
|
|
|
private readonly SqlSugarRepository<BookingPrintTemplate> _repPrint;
|
|
|
|
|
private readonly ILogger<BookingOrderService> _logger;
|
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
|
private readonly SqlSugarRepository<BookingStatusLog> _statuslog;
|
|
|
|
|
private readonly SqlSugarRepository<BookingStatusLogDetail> _statuslogdetail;
|
|
|
|
|
private readonly SqlSugarRepository<BookingPrintTemplate> _repPrintTemplate;
|
|
|
|
|
private readonly SqlSugarRepository<BookingLetteryard> _repLetterYard;
|
|
|
|
|
private readonly SqlSugarRepository<SysUser> _repUser;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrderUrl> _repOrderUrl;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrderContact> _repOrderContact;
|
|
|
|
|
|
|
|
|
|
public BookingOrderService(SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn, SqlSugarRepository<BookingCtnDetail> ctndetailrep,
|
|
|
|
|
SqlSugarRepository<BookingLog> bookinglog, SqlSugarRepository<BookingLogDetail> bookinglogdetail, SqlSugarRepository<BookingRemark> bookingremark,
|
|
|
|
|
SqlSugarRepository<BookingFile> bookingfile, SqlSugarRepository<DjyWebsiteAccountConfig> webconfig, SqlSugarRepository<BookingPrintTemplate> repPrint,
|
|
|
|
|
SqlSugarRepository<SysDictData> dicdata, SqlSugarRepository<BookingStatusLog> statuslog, SqlSugarRepository<BookingStatusLogDetail> statuslogdetail,
|
|
|
|
|
ILogger<BookingOrderService> logger, ISysCacheService cache,
|
|
|
|
|
SqlSugarRepository<BookingPrintTemplate> repPrintTemplate, SqlSugarRepository<BookingLetteryard> repLetterYard, SqlSugarRepository<SysUser> repUser,
|
|
|
|
|
SqlSugarRepository<BookingOrderUrl> repOrderUrl, SqlSugarRepository<BookingOrderContact> repOrderContact)
|
|
|
|
|
{
|
|
|
|
|
this._logger = logger;
|
|
|
|
|
this._rep = rep;
|
|
|
|
|
this._repCtn = repCtn;
|
|
|
|
|
this._ctndetailrep = ctndetailrep;
|
|
|
|
|
this._bookinglog = bookinglog;
|
|
|
|
|
this._bookinglogdetail = bookinglogdetail;
|
|
|
|
|
this._bookingremark = bookingremark;
|
|
|
|
|
this._bookingfile = bookingfile;
|
|
|
|
|
this._repWebAcc = webconfig;
|
|
|
|
|
this._repPrint = repPrint;
|
|
|
|
|
this._dicdata = dicdata;
|
|
|
|
|
this._cache = cache;
|
|
|
|
|
this._statuslog = statuslog;
|
|
|
|
|
this._statuslogdetail = statuslogdetail;
|
|
|
|
|
this._repPrintTemplate = repPrintTemplate;
|
|
|
|
|
this._repLetterYard = repLetterYard;
|
|
|
|
|
this._repUser = repUser;
|
|
|
|
|
this._repOrderUrl = repOrderUrl;
|
|
|
|
|
this._repOrderContact = repOrderContact;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 主表和箱信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页查询订舱主表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/page")]
|
|
|
|
|
public async Task<dynamic> Page([FromQuery] BookingOrderInput input)
|
|
|
|
|
{
|
|
|
|
|
List<long> userlist = await DataFilterExtensions.GetDataScopeIdList();
|
|
|
|
|
var entities = await _rep.AsQueryable()
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.BSSTATUS), u => u.BSSTATUS == input.BSSTATUS)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.MBLNO), u => input.MBLNO.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Contains(u.MBLNO))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.HBLNO), u => input.HBLNO.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Contains(u.HBLNO))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.BOOKINGNO), u => u.BOOKINGNO.IndexOf(input.BOOKINGNO) > -1)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CONTRACTNO), u => u.CONTRACTNO.IndexOf(input.CONTRACTNO) > -1)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SERVICECONTRACTNO), u => u.SERVICECONTRACTNO.IndexOf(input.SERVICECONTRACTNO) > -1)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPER), u => u.SHIPPER.Contains(input.SHIPPER))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEE), u => u.CONSIGNEE.Contains(input.CONSIGNEE))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTY), u => u.NOTIFYPARTY.Contains(input.NOTIFYPARTY))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTY2), u => u.NOTIFYPARTY2.Contains(input.NOTIFYPARTY2))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.YARDID), u => u.YARDID == input.YARDID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.YARD), u => u.YARD == input.YARD)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.VESSELID), u => u.VESSELID.IndexOf(input.VESSELID) > -1)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.VESSEL), u => u.VESSEL.ToLower().IndexOf(u.VESSEL.ToLower()) > -1)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.VOYNO), u => u.VOYNO.IndexOf(input.VOYNO) > -1)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.VOYNOINNER), u => u.VOYNOINNER.IndexOf(input.VOYNOINNER) > -1)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PLACERECEIPT), u => u.PLACERECEIPT.Contains(input.PLACERECEIPT))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PLACERECEIPTID), u => u.PLACERECEIPTID == input.PLACERECEIPTID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PORTLOAD), u => u.PORTLOAD.IndexOf(input.PORTLOAD) > -1)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PORTDISCHARGE), u => u.PORTDISCHARGE.IndexOf(input.PORTDISCHARGE) > -1)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PLACEDELIVERY), u => u.PLACEDELIVERY.Contains(input.PLACEDELIVERY))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PLACEDELIVERYID), u => u.PLACEDELIVERYID == input.PLACEDELIVERYID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.DESTINATION), u => u.DESTINATION.Contains(input.DESTINATION))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.DESTINATIONID), u => u.DESTINATIONID == input.DESTINATIONID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.NOBILL), u => u.NOBILL == input.NOBILL)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.COPYNOBILLL), u => u.COPYNOBILLL == input.COPYNOBILLL)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.ISSUETYPE), u => u.ISSUETYPE == input.ISSUETYPE)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.ISSUEPLACE), u => u.ISSUEPLACE.Contains(input.ISSUEPLACE))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.ISSUEPLACEID), u => u.ISSUEPLACEID == input.ISSUEPLACEID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.BLFRT), u => u.BLFRT == input.BLFRT)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PREPARDATID), u => u.PREPARDATID == input.PREPARDATID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PREPARDAT), u => u.PREPARDAT == input.PREPARDAT)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PAYABLEAT), u => u.PAYABLEAT.Contains(input.PAYABLEAT))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PAYABLEATID), u => u.PAYABLEATID == input.PAYABLEATID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SERVICE), u => u.SERVICE.Contains(input.SERVICE))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.MARKS), u => u.MARKS.Contains(input.MARKS))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.HSCODE), u => u.HSCODE.IndexOf(input.HSCODE) > -1)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.DESCRIPTION), u => u.DESCRIPTION.Contains(input.DESCRIPTION))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.KINDPKGS), u => u.KINDPKGS == input.KINDPKGS)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CNTRTOTAL), u => u.CNTRTOTAL == input.CNTRTOTAL)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CARRIERID), u => u.CARRIERID == input.CARRIERID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CARRIER), u => u.CARRIER.Contains(input.CARRIER))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CARGOID), u => u.CARGOID == input.CARGOID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.DCLASS), u => u.DCLASS == input.DCLASS)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.DUNNO), u => u.DUNNO == input.DUNNO)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.DPAGE), u => u.DPAGE == input.DPAGE)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.DLABEL), u => u.DLABEL == input.DLABEL)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.LINKMAN), u => u.LINKMAN == input.LINKMAN)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.TEMPID), u => u.TEMPID == input.TEMPID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.TEMPSET), u => u.TEMPSET == input.TEMPSET)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.REEFERF), u => u.REEFERF == input.REEFERF)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.HUMIDITY), u => u.HUMIDITY == input.HUMIDITY)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.TEMPMIN), u => u.TEMPMIN == input.TEMPMIN)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.TEMPMAX), u => u.TEMPMAX == input.TEMPMAX)
|
|
|
|
|
.WhereIF(input.ISCONTAINERSOC != null, u => u.ISCONTAINERSOC == input.ISCONTAINERSOC)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SOREMARK), u => u.SOREMARK.Contains(input.SOREMARK))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SIREMARK), u => u.SIREMARK.Contains(input.SIREMARK))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.YARDREMARK), u => u.YARDREMARK.Contains(input.YARDREMARK))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.COMPID), u => u.COMPID == input.COMPID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.COMPNAME), u => u.COMPNAME.IndexOf(input.COMPNAME) > -1)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERNAME), u => u.SHIPPERNAME.Contains(input.SHIPPERNAME))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERCITY), u => u.SHIPPERCITY.Contains(input.SHIPPERCITY))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERPROVINCE), u => u.SHIPPERPROVINCE == input.SHIPPERPROVINCE)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERPOSTCODE), u => u.SHIPPERPOSTCODE == input.SHIPPERPOSTCODE)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERCOUNTRY), u => u.SHIPPERCOUNTRY == input.SHIPPERCOUNTRY)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERATTN), u => u.SHIPPERATTN.Contains(input.SHIPPERATTN))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERTEL), u => u.SHIPPERTEL == input.SHIPPERTEL)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEENAME), u => u.CONSIGNEENAME.Contains(input.CONSIGNEENAME))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEECITY), u => u.CONSIGNEECITY.Contains(input.CONSIGNEECITY))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEEPROVINCE), u => u.CONSIGNEEPROVINCE == input.CONSIGNEEPROVINCE)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEEPOSTCODE), u => u.CONSIGNEEPOSTCODE == input.CONSIGNEEPOSTCODE)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEERCOUNTRY), u => u.CONSIGNEERCOUNTRY == input.CONSIGNEERCOUNTRY)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEEATTN), u => u.CONSIGNEEATTN.Contains(input.CONSIGNEEATTN))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEETEL), u => u.CONSIGNEETEL == input.CONSIGNEETEL)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYNAME), u => u.NOTIFYPARTYNAME.Contains(input.NOTIFYPARTYNAME))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYCITY), u => u.NOTIFYPARTYCITY.Contains(input.NOTIFYPARTYCITY))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYPROVINCE), u => u.NOTIFYPARTYPROVINCE == input.NOTIFYPARTYPROVINCE)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYPOSTCODE), u => u.NOTIFYPARTYPOSTCODE == input.NOTIFYPARTYPOSTCODE)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYCOUNTRY), u => u.NOTIFYPARTYCOUNTRY == input.NOTIFYPARTYCOUNTRY)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYATTN), u => u.NOTIFYPARTYATTN.Contains(input.NOTIFYPARTYATTN))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYTEL), u => u.NOTIFYPARTYTEL == input.NOTIFYPARTYTEL)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PONO), u => u.PONO == input.PONO)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.OPID), u => u.OPID == input.OPID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.DOCID), u => u.DOCID == input.DOCID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.OP), u => u.OP == input.OP)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.DOC), u => u.DOC == input.DOC)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SALEID), u => u.SALEID == input.SALEID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SALE), u => u.SALE.Contains(input.SALE))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CUSTSERVICEID), u => u.CUSTSERVICEID == input.CUSTSERVICEID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CUSTSERVICE), u => u.CUSTSERVICE.Contains(input.CUSTSERVICE))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CUSTOMERNAME), u => u.CUSTOMERNAME.Contains(input.CUSTOMERNAME))
|
|
|
|
|
.WhereIF(input.CUSTOMERID != null, u => u.CUSTOMERID == input.CUSTOMERID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.FORWARDER), u => u.FORWARDER.Contains(input.FORWARDER))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CUSTSERVICE), u => u.CUSTSERVICE == input.CUSTSERVICE)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CUSTOMERNAME), u => u.CUSTOMERNAME == input.CUSTOMERNAME)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.FORWARDER), u => u.FORWARDER == input.FORWARDER)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SHIPAGENCY), u => u.SHIPAGENCY == input.SHIPAGENCY)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CUSTOMSER), u => u.CUSTOMSER == input.CUSTOMSER)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.TRUCKER), u => u.TRUCKER == input.TRUCKER)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.AGENTID), u => u.AGENTID == input.AGENTID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.FORWARDERID), u => u.FORWARDERID == input.FORWARDERID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SHIPAGENCY), u => u.SHIPAGENCY.Contains(input.SHIPAGENCY))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SHIPAGENCYID), u => u.SHIPAGENCYID == input.SHIPAGENCYID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CUSTOMSER), u => u.CUSTOMSER.Contains(input.CUSTOMSER))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CUSTOMSERID), u => u.CUSTOMSERID == input.CUSTOMSERID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.TRUCKER), u => u.TRUCKER.Contains(input.TRUCKER))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.TRUCKERID), u => u.TRUCKERID == input.TRUCKERID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.AGENTNAME), u => u.AGENTNAME.Contains(input.AGENTNAME))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.AGENTID), u => u.AGENTID == input.AGENTID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.WEITUO), u => u.WEITUO.Contains(input.WEITUO))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SCACCODE), u => u.SCACCODE == input.SCACCODE)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.ITNCODE), u => u.ITNCODE == input.ITNCODE)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CUSTNO), u => u.CUSTNO.Contains(input.CUSTNO))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.TRANSPORTID), u => u.TRANSPORTID == input.TRANSPORTID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.TRANSPORT), u => u.TRANSPORT.Contains(input.TRANSPORT))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.YARDCONTRACTTEL), u => u.YARDCONTRACTTEL == input.YARDCONTRACTTEL)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.YARDCONTRACTEMAIL), u => u.YARDCONTRACTEMAIL == input.YARDCONTRACTEMAIL)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.LANECODE), u => u.LANECODE == input.LANECODE)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.LANENAME), u => u.LANENAME.Contains(input.LANENAME))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.FREIGHTPAYER), u => u.FREIGHTPAYER.Contains(input.FREIGHTPAYER))
|
|
|
|
|
.Where(u => userlist.Contains((long)u.CreatedUserId))
|
|
|
|
|
.ToPagedListAsync(input.PageNo, input.PageSize);
|
|
|
|
|
return entities.XnPagedResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加订舱
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
[HttpPost("/BookingOrder/add")]
|
|
|
|
|
public async Task Add(AddBookingOrderInput input)
|
|
|
|
|
{
|
|
|
|
|
JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YardContract", "YardContractTel", "YardContractEmail");
|
|
|
|
|
JsonUtil.TrimFields(input);
|
|
|
|
|
if (input.ctnInputs != null)
|
|
|
|
|
{
|
|
|
|
|
var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}");
|
|
|
|
|
input.CNTRTOTAL = string.Join(" / ", groupList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var entity = input.Adapt<BookingOrder>();
|
|
|
|
|
|
|
|
|
|
await _rep.InsertAsync(entity);
|
|
|
|
|
if (input.ctnInputs != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in input.ctnInputs)
|
|
|
|
|
{
|
|
|
|
|
var ctnentity = item.Adapt<BookingCtn>();
|
|
|
|
|
ctnentity.BILLID = entity.Id;
|
|
|
|
|
await _repCtn.InsertAsync(ctnentity);
|
|
|
|
|
foreach (var it in item.ctnDetailInputs)
|
|
|
|
|
{
|
|
|
|
|
var ctndetail = it.Adapt<BookingCtnDetail>();
|
|
|
|
|
ctndetail.CTNID = ctnentity.Id;
|
|
|
|
|
await _ctndetailrep.InsertAsync(ctndetail);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////添加booking日志
|
|
|
|
|
await _bookinglog.InsertAsync(new BookingLog
|
|
|
|
|
{
|
|
|
|
|
Type = "Add",
|
|
|
|
|
BookingId = entity.Id,
|
|
|
|
|
TenantId = Convert.ToInt64(UserManager.TENANT_ID),
|
|
|
|
|
CreatedTime = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO))
|
|
|
|
|
{
|
|
|
|
|
await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除订舱
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
[HttpPost("/BookingOrder/delete")]
|
|
|
|
|
public async Task Delete(long Id)
|
|
|
|
|
{
|
|
|
|
|
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).Select(x => x.Id).ToListAsync();
|
|
|
|
|
await _repCtn.UpdateAsync(x => x.BILLID == Id, x => new BookingCtn { IsDeleted = true });
|
|
|
|
|
await _ctndetailrep.UpdateAsync(x => ctnlist.Contains((long)x.CTNID), x => new BookingCtnDetail { IsDeleted = true });
|
|
|
|
|
_logger.LogInformation(Id + "删除成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新订舱
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
[HttpPost("/BookingOrder/update")]
|
|
|
|
|
public async Task Update(UpdateBookingOrderInput input)
|
|
|
|
|
{
|
|
|
|
|
JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YardContract", "YardContractTel", "YardContractEmail");
|
|
|
|
|
JsonUtil.TrimFields(input);
|
|
|
|
|
if (input.ctnInputs != null)
|
|
|
|
|
{
|
|
|
|
|
var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}");
|
|
|
|
|
input.CNTRTOTAL = string.Join(" / ", groupList);
|
|
|
|
|
}
|
|
|
|
|
var main = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
|
|
|
|
|
var entity = input.Adapt<BookingOrder>();
|
|
|
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == input.Id).Select(x => x.Id).ToListAsync();
|
|
|
|
|
await _repCtn.DeleteAsync(x => x.BILLID == input.Id);
|
|
|
|
|
await _ctndetailrep.DeleteAsync(x => ctnlist.Contains((long)x.CTNID));
|
|
|
|
|
if (input.ctnInputs != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in input.ctnInputs)
|
|
|
|
|
{
|
|
|
|
|
var ctnentity = item.Adapt<BookingCtn>();
|
|
|
|
|
ctnentity.BILLID = entity.Id;
|
|
|
|
|
await _repCtn.InsertAsync(ctnentity);
|
|
|
|
|
foreach (var it in item.ctnDetailInputs)
|
|
|
|
|
{
|
|
|
|
|
var ctndetail = it.Adapt<BookingCtnDetail>();
|
|
|
|
|
ctndetail.CTNID = ctnentity.Id;
|
|
|
|
|
await _ctndetailrep.InsertAsync(ctndetail);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool flag = true;
|
|
|
|
|
long bid = 0;
|
|
|
|
|
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(entity))
|
|
|
|
|
{
|
|
|
|
|
string name = descriptor.Name;
|
|
|
|
|
if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId" || name == "CreatedUserName")
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
object value = descriptor.GetValue(entity);
|
|
|
|
|
var oldvalue = main.GetType().GetProperty(name).GetValue(main, null);
|
|
|
|
|
|
|
|
|
|
if (name == "KGS" || name == "CBM")
|
|
|
|
|
{
|
|
|
|
|
if (Convert.ToDecimal(value) == Convert.ToDecimal(oldvalue))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
string _oldvalue = oldvalue != null ? oldvalue.ToString() : "";
|
|
|
|
|
string _value = value != null ? value.ToString() : "";
|
|
|
|
|
if (_oldvalue != _value)
|
|
|
|
|
{
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
////添加booking日志
|
|
|
|
|
bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog
|
|
|
|
|
{
|
|
|
|
|
Type = "Edit",
|
|
|
|
|
BookingId = entity.Id,
|
|
|
|
|
TenantId = Convert.ToInt64(UserManager.TENANT_ID),
|
|
|
|
|
CreatedTime = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name
|
|
|
|
|
});
|
|
|
|
|
flag = false;
|
|
|
|
|
}
|
|
|
|
|
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
|
|
|
|
|
{
|
|
|
|
|
PId = bid,
|
|
|
|
|
Field = descriptor.Description,
|
|
|
|
|
OldValue = _oldvalue,
|
|
|
|
|
NewValue = _value,
|
|
|
|
|
});
|
|
|
|
|
if (descriptor.Name == "YARDID" || descriptor.Name == "YARD" || descriptor.Name == "MBLNO")
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO))
|
|
|
|
|
{
|
|
|
|
|
await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取订舱明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/get")]
|
|
|
|
|
public async Task<BookingOrderOutput> Get(long Id)
|
|
|
|
|
{
|
|
|
|
|
BookingOrderOutput ordOut = new BookingOrderOutput();
|
|
|
|
|
var main = await _rep.FirstOrDefaultAsync(u => u.Id == Id);
|
|
|
|
|
if (main != null)
|
|
|
|
|
{
|
|
|
|
|
ordOut = main.Adapt<BookingOrderOutput>();
|
|
|
|
|
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).ToListAsync();
|
|
|
|
|
var ctninput = ctnlist.Adapt<List<BookingCtnDto>>();
|
|
|
|
|
foreach (var item in ctninput)
|
|
|
|
|
{
|
|
|
|
|
var ctndetaillist = await _ctndetailrep.AsQueryable().Where(x => x.CTNID == item.Id).ToListAsync();
|
|
|
|
|
item.ctnDetailInputs = ctndetaillist.Adapt<List<BookingCtnDetailDto>>();
|
|
|
|
|
}
|
|
|
|
|
ordOut.ctnInputs = ctninput;
|
|
|
|
|
|
|
|
|
|
var ordUrl = _repOrderUrl.FirstOrDefault(x => x.BookingId == Id);
|
|
|
|
|
if (ordUrl != null)
|
|
|
|
|
{
|
|
|
|
|
ordOut.Link = new BookingOrderUrlOutput()
|
|
|
|
|
{
|
|
|
|
|
LinkUrlTxxp = ordUrl.UrlTxxp,
|
|
|
|
|
LinkUrlVgm = ordUrl.UrlVgm,
|
|
|
|
|
LinkUrlVmgSi = ordUrl.UrlVgmSi,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ordOut;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 日志、备注、附件、货运动态等
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取日志明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/getLog")]
|
|
|
|
|
public async Task<BookingLogDto> GetLog(long Id)
|
|
|
|
|
{
|
|
|
|
|
BookingLogDto list = new BookingLogDto();
|
|
|
|
|
var main = await _bookinglog.FirstOrDefaultAsync(u => u.BookingId == Id);
|
|
|
|
|
if (main != null)
|
|
|
|
|
{
|
|
|
|
|
list = main.Adapt<BookingLogDto>();
|
|
|
|
|
var details = await _bookinglogdetail.AsQueryable().Where(x => x.PId == main.Id).ToListAsync();
|
|
|
|
|
|
|
|
|
|
list.details = details;
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取备注
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/getRemark")]
|
|
|
|
|
public async Task<BookingRemark> GetRemark(long Id)
|
|
|
|
|
{
|
|
|
|
|
var list = await _bookingremark.FirstOrDefaultAsync(u => u.PId == Id);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加备注
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dto"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
[HttpPost("/BookingOrder/addRemark")]
|
|
|
|
|
public async Task AddRemark(BookingRemarkDto dto)
|
|
|
|
|
{
|
|
|
|
|
var entity = dto.Adapt<BookingRemark>();
|
|
|
|
|
await _bookingremark.InsertAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加订舱附件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="file"></param>
|
|
|
|
|
/// <param name="dto"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingOrder/addFile")]
|
|
|
|
|
public async Task AddFile(IFormFile file, [FromForm] BookingFileDto dto)
|
|
|
|
|
{
|
|
|
|
|
//未上传打印模板文件
|
|
|
|
|
if (file == null || file.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK200);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var opt = App.GetOptions<BookingAttachOptions>();
|
|
|
|
|
var originalFilename = file.FileName; // 文件原始名称
|
|
|
|
|
var fileSuffix = Path.GetExtension(file.FileName).ToLower(); // 文件后缀
|
|
|
|
|
if (!opt.fileType.Contains(fileSuffix))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK114);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var dirAbs = string.Empty;
|
|
|
|
|
if (string.IsNullOrEmpty(opt.basePath))
|
|
|
|
|
{
|
|
|
|
|
dirAbs = Path.Combine(App.WebHostEnvironment.WebRootPath, opt.relativePath);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dirAbs = Path.Combine(opt.basePath, opt.relativePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(dirAbs))
|
|
|
|
|
Directory.CreateDirectory(dirAbs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 先存库获取Id
|
|
|
|
|
var id = YitIdHelper.NextId();
|
|
|
|
|
var fileSaveName = $"{id}{fileSuffix}".ToLower();
|
|
|
|
|
var fileRelaPath = Path.Combine(opt.relativePath, fileSaveName).ToLower();
|
|
|
|
|
var fileAbsPath = Path.Combine(dirAbs, fileSaveName).ToLower();
|
|
|
|
|
var newFile = new BookingFile
|
|
|
|
|
{
|
|
|
|
|
Id = id,
|
|
|
|
|
FileName = originalFilename,
|
|
|
|
|
FilePath = fileRelaPath,
|
|
|
|
|
TypeCode = dto.TypeCode,
|
|
|
|
|
TypeName = dto.TypeName,
|
|
|
|
|
TenantId = Convert.ToInt16(UserManager.TENANT_ID),
|
|
|
|
|
TenantName = UserManager.TENANT_NAME,
|
|
|
|
|
};
|
|
|
|
|
await _bookingfile.InsertAsync(newFile);
|
|
|
|
|
using (var stream = File.Create(fileAbsPath))
|
|
|
|
|
{
|
|
|
|
|
await file.CopyToAsync(stream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取附件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/getFile")]
|
|
|
|
|
public async Task<BookingFile> GetFile(long Id)
|
|
|
|
|
{
|
|
|
|
|
var list = await _bookingfile.FirstOrDefaultAsync(u => u.BookingId == Id);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取货运动态
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async Task<List<BookingStatusLogDto>> GetBookingStatusLog(long Id)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var statuslog = await _statuslog.AsQueryable().Where(x => x.BookingId == Id).ToListAsync();
|
|
|
|
|
var dto = statuslog.Adapt<List<BookingStatusLogDto>>();
|
|
|
|
|
foreach (var item in dto)
|
|
|
|
|
{
|
|
|
|
|
var detail = await _statuslogdetail.AsQueryable().Where(x => x.PId == item.Id).ToListAsync();
|
|
|
|
|
item.detail = detail.Adapt<List<BookingStatusLogDetailDto>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 运踪
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 调用运踪接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async Task SendTrace(string BusinessId, string YARDID, string YARD, string MBLNO)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("提单号:" + MBLNO + " 调用运踪接口");
|
|
|
|
|
var key = _repWebAcc.FirstOrDefault(x => x.TenantId == Convert.ToInt64(UserManager.TENANT_ID) && x.TypeCode == "seae_billtraceurl");
|
|
|
|
|
var url = _cache.GetAllDictData().Result;
|
|
|
|
|
BillTraceDto billdto = new BillTraceDto();
|
|
|
|
|
List<BillTraceList> billTraceList = new List<BillTraceList>();
|
|
|
|
|
billTraceList.Add(new BillTraceList
|
|
|
|
|
{
|
|
|
|
|
BusinessId = BusinessId,
|
|
|
|
|
MBLNO = MBLNO,
|
|
|
|
|
YARD = YARD,
|
|
|
|
|
YardCode = YARDID,
|
|
|
|
|
CARRIER = null,
|
|
|
|
|
CARRIERID = null,
|
|
|
|
|
isBook = false
|
|
|
|
|
});
|
|
|
|
|
billdto.Children = billTraceList;
|
|
|
|
|
billdto.Key = key.Account;
|
|
|
|
|
billdto.PWD = key.Password;
|
|
|
|
|
billdto.url = url.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "response_seae_billtraceurl").Value;
|
|
|
|
|
billdto.Gid = UserManager.DjyUserId;
|
|
|
|
|
var json = billdto.ToJsonString();
|
|
|
|
|
var html = await url.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "request_seae_billtraceurl").Value.SetHttpMethod(HttpMethod.Post).SetQueries(new { msg = json }).SetRetryPolicy(3, 5000).SendAsAsync<RespCommon>();
|
|
|
|
|
_logger.LogInformation("提单号:" + MBLNO + " 调用运踪接口返回" + html.ToJsonString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 插入货运动态
|
|
|
|
|
/// </summary>
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
public async Task AddBookingStatusLog(List<BookingStatusLogDto> all)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
foreach (var item in all)
|
|
|
|
|
{
|
|
|
|
|
//清空原有数据
|
|
|
|
|
var old = await _statuslog.AsQueryable().Where(x => x.BookingId == item.BookingId && x.Gategory == "ship").ToListAsync();
|
|
|
|
|
await _statuslog.DeleteAsync(x => x.BookingId == item.BookingId && x.Gategory == "ship");
|
|
|
|
|
foreach (var ot in old)
|
|
|
|
|
{
|
|
|
|
|
await _statuslogdetail.DeleteAsync(x => x.PId == ot.Id);
|
|
|
|
|
}
|
|
|
|
|
//新增数据
|
|
|
|
|
var bookingStatusLog = new BookingStatusLog();
|
|
|
|
|
bookingStatusLog.BookingId = item.BookingId;
|
|
|
|
|
bookingStatusLog.Gategory = "ship";
|
|
|
|
|
bookingStatusLog.CreatedTime = DateTime.Now;
|
|
|
|
|
bookingStatusLog.Status = item.Status;
|
|
|
|
|
bookingStatusLog.OpTime = item.OpTime;
|
|
|
|
|
bookingStatusLog.MBLNO = item.MBLNO;
|
|
|
|
|
var id = await _statuslog.InsertReturnSnowflakeIdAsync(bookingStatusLog);
|
|
|
|
|
if (item.detail != null && item.detail.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var dt in item.detail)
|
|
|
|
|
{
|
|
|
|
|
var BookingStatusLogDetail = new BookingStatusLogDetail();
|
|
|
|
|
BookingStatusLogDetail.PId = id;
|
|
|
|
|
BookingStatusLogDetail.Status = dt.Status;
|
|
|
|
|
BookingStatusLogDetail.CNTRNO = dt.CNTRNO;
|
|
|
|
|
BookingStatusLogDetail.OPTime = dt.OPTime;
|
|
|
|
|
await _statuslogdetail.InsertAsync(BookingStatusLogDetail);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 放舱(下货纸)
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取放舱信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/letteryard")]
|
|
|
|
|
public async Task<UpdateBookingLetteryardOutput> LetterYard(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
var order = _rep.FirstOrDefault(x => x.Id == bookingId);
|
|
|
|
|
var letterYard = await _repLetterYard.FirstOrDefaultAsync(x => x.BookingId == bookingId);
|
|
|
|
|
if (letterYard == null)
|
|
|
|
|
{
|
|
|
|
|
var user = _repUser.FirstOrDefault(x => x.Id == UserManager.UserId);
|
|
|
|
|
letterYard = new BookingLetteryard()
|
|
|
|
|
{
|
|
|
|
|
BookingId = bookingId,
|
|
|
|
|
Description = order.DESCRIPTION,
|
|
|
|
|
FromName = user.Name,
|
|
|
|
|
FromTel = user.Tel,
|
|
|
|
|
FromMail = user.Email,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var output = letterYard.Adapt<UpdateBookingLetteryardOutput>();
|
|
|
|
|
|
|
|
|
|
//链接信息
|
|
|
|
|
var urlModel = _repOrderUrl.FirstOrDefault(x => x.BookingId == bookingId);
|
|
|
|
|
if (urlModel != null)
|
|
|
|
|
{
|
|
|
|
|
output.OrderUrl = urlModel.Adapt<BookingOrderUrlLetterYardOutput>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存(新增或修改)下货纸
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingLetteryard/save")]
|
|
|
|
|
public async Task Save(UpdateBookingLetteryardInput input)
|
|
|
|
|
{
|
|
|
|
|
if (input.Id == 0)
|
|
|
|
|
{
|
|
|
|
|
var entity = input.Adapt<BookingLetteryard>();
|
|
|
|
|
await _repLetterYard.InsertAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var entity = _repLetterYard.FirstOrDefault(x => x.BookingId == input.Id);
|
|
|
|
|
entity = input.Adapt(entity);
|
|
|
|
|
await _repLetterYard.UpdateAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var order = _rep.FirstOrDefault(x => x.Id == input.BookingId);
|
|
|
|
|
|
|
|
|
|
//生成提箱小票
|
|
|
|
|
var allowCarrier = _cache.GetAllDictData().Result.Where(x => x.TypeCode == "txxp_carrier_list").Select(x => x.Code).ToList();
|
|
|
|
|
if (allowCarrier.Contains(order.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
var txxpLink = await TxxpLink(input.BookingId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//todo:vgm、vgm&si链接
|
|
|
|
|
//...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取放舱pdf
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/letteryardpdf")]
|
|
|
|
|
public async Task<IActionResult> LetterYardPdf(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
return await LetterYardFile(bookingId, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取放舱excel
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/letteryardxlsx")]
|
|
|
|
|
public async Task<IActionResult> LetterYardXlsx(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
return await LetterYardFile(bookingId, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成放舱文件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
|
/// <param name="type">类型,1:pdf、2:xlsx</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[NonAction]
|
|
|
|
|
private async Task<IActionResult> LetterYardFile(long bookingId, int type = 1)
|
|
|
|
|
{
|
|
|
|
|
//打印报表服务地址
|
|
|
|
|
var reportUrl = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "url_report_generate").Value;
|
|
|
|
|
if (!reportUrl.EndsWith("/"))
|
|
|
|
|
{
|
|
|
|
|
reportUrl += "/";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//订舱数据
|
|
|
|
|
var order = _rep.FirstOrDefault(x => x.Id == bookingId);
|
|
|
|
|
if (order == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK001);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var letterYard = await _repLetterYard.FirstOrDefaultAsync(x => x.BookingId == bookingId);
|
|
|
|
|
if (letterYard == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK116);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var printTemplate = _repPrintTemplate.FirstOrDefault(x => x.TenantId == letterYard.TenantId && x.TypeCode == "fangcang");
|
|
|
|
|
if (printTemplate == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK115);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var opt = App.GetOptions<PrintTemplateOptions>();
|
|
|
|
|
var dirAbs = opt.basePath;
|
|
|
|
|
if (string.IsNullOrEmpty(dirAbs))
|
|
|
|
|
{
|
|
|
|
|
dirAbs = App.WebHostEnvironment.WebRootPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var fileAbsPath = Path.Combine(dirAbs, printTemplate.FilePath);
|
|
|
|
|
if (!File.Exists(fileAbsPath))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK115);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"准备调用报表生成放舱:id:{bookingId},文件:{printTemplate.FileName}");
|
|
|
|
|
var genUrl = $"{reportUrl}Report/BookingReport?bookingId={bookingId}&type={type}";
|
|
|
|
|
var rtn = await genUrl
|
|
|
|
|
.SetContentType("multipart/form-data")
|
|
|
|
|
.SetBodyBytes(("file", File.ReadAllBytes(fileAbsPath), HttpUtility.UrlEncode(printTemplate.FileName, Encoding.GetEncoding("UTF-8"))))
|
|
|
|
|
.PostAsStringAsync();
|
|
|
|
|
var jobjRtn = JObject.Parse(rtn);
|
|
|
|
|
_logger.LogInformation($"调用报表生成放舱返回:{rtn}");
|
|
|
|
|
if (jobjRtn.GetBooleanValue("Success"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//调用读取文件
|
|
|
|
|
var fn = jobjRtn.GetStringValue("Data");
|
|
|
|
|
_logger.LogInformation($"准备调用读取放舱文件:id:{bookingId},文件名:{fn}");
|
|
|
|
|
var readFileUrl = $"{reportUrl}Report/GetFile?fileName={fn}";
|
|
|
|
|
var bs = await readFileUrl.GetAsByteArrayAsync();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"调用读取放舱文件返回:{bs.Length}");
|
|
|
|
|
|
|
|
|
|
var fileName = HttpUtility.UrlEncode($"{bookingId}_{type}_{DateTime.Now.Ticks}.{(type == 1 ? "pdf" : "xlsx")}", Encoding.GetEncoding("UTF-8"));
|
|
|
|
|
var result = new FileContentResult(bs, "application/octet-stream") { FileDownloadName = fileName };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"生成报表文件失败:{jobjRtn.GetStringValue("Message")}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 样单
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 小票链接
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取提箱小票链接
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/txxplink")]
|
|
|
|
|
public async Task<string> TxxpLink(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
var order = _rep.FirstOrDefault(x => x.Id == bookingId);
|
|
|
|
|
if (order == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK001);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ordUrl = _repOrderUrl.FirstOrDefault(x => x.BookingId == bookingId);
|
|
|
|
|
if (ordUrl == null)
|
|
|
|
|
{
|
|
|
|
|
ordUrl = new BookingOrderUrl();
|
|
|
|
|
ordUrl.BookingId = bookingId;
|
|
|
|
|
await _repOrderUrl.InsertAsync(ordUrl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(ordUrl.UrlTxxp))
|
|
|
|
|
{
|
|
|
|
|
return ordUrl.UrlTxxp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//校验船公司
|
|
|
|
|
if (string.IsNullOrEmpty(order.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK118);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//判断船公司是否支持
|
|
|
|
|
var allowCarrier = _cache.GetAllDictData().Result.Where(x => x.TypeCode == "txxp_carrier_list").Select(x => x.Code).ToList();
|
|
|
|
|
if (!allowCarrier.Contains(order.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK117);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//亿通账号
|
|
|
|
|
var ytAcc = _repWebAcc.FirstOrDefault(x => x.CreatedUserId == UserManager.UserId && x.TypeCode == "YitongWeb");
|
|
|
|
|
if (ytAcc == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK119);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//场站转换
|
|
|
|
|
var yardset = _cache.GetAllMappingYard().Result.FirstOrDefault(y => y.Code == order.YARDID && y.Module == "BookingTxxp");
|
|
|
|
|
if (yardset == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK120, order.YARDID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ctns = await _repCtn.Where(x => x.BILLID == bookingId).ToListAsync();
|
|
|
|
|
//校验箱子数据录入
|
|
|
|
|
if (ctns.Where(c => string.IsNullOrEmpty(c.CTNALL) || !c.CTNNUM.HasValue).Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK121);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//箱型映射
|
|
|
|
|
var ctnMapping = await _cache.GetAllMappingCtn();
|
|
|
|
|
ctnMapping = ctnMapping.Where(x => x.Module == "BookingTxxp").ToList();
|
|
|
|
|
if (ctnMapping.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK122);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var expCode = ctns.Select(x => x.CTNCODE).Distinct().Except(ctnMapping.Select(y => y.Code)).ToList();
|
|
|
|
|
if (expCode.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK123, string.Join(',', expCode));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var user = await _repUser.FirstOrDefaultAsync(x => x.Id == UserManager.UserId);
|
|
|
|
|
|
|
|
|
|
//调用小票服务
|
|
|
|
|
var dicUrlTxxp = _cache.GetAllDictData().Result.First(x => x.TypeCode == "url_set" && x.Code == "txxp_service");
|
|
|
|
|
var postObj = new
|
|
|
|
|
{
|
|
|
|
|
SystemCode = "djy_hechuan",
|
|
|
|
|
CarrierCode = order.CARRIERID,
|
|
|
|
|
billOrderId = order.Id.ToString(),
|
|
|
|
|
sendOrderCode = order.MBLNO,
|
|
|
|
|
userId = UserManager.DjyUserId,
|
|
|
|
|
customerId = order.CUSTOMERID.ToString(),
|
|
|
|
|
// userName = currUser.CODENAME,
|
|
|
|
|
//userPassword = currUser.PASSWORD,
|
|
|
|
|
operatorName = UserManager.Name,
|
|
|
|
|
depotCode = yardset.MapCode,
|
|
|
|
|
depotName = yardset.MapName,
|
|
|
|
|
AgentName = UserManager.TENANT_NAME,
|
|
|
|
|
linkName = UserManager.Name,
|
|
|
|
|
linkMobile = user.Tel,
|
|
|
|
|
CustomerName = $"{UserManager.TENANT_NAME}+{UserManager.Name}", //公司名称+用户姓名
|
|
|
|
|
memo = string.Empty,
|
|
|
|
|
boxInfo = ctns.Select(c =>
|
|
|
|
|
{
|
|
|
|
|
return new
|
|
|
|
|
{
|
|
|
|
|
boxType = ctnMapping.First(x => x.Code == c.CTNCODE).MapCode,
|
|
|
|
|
boxCount = c.CTNNUM.Value
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
|
sysLoginName = ytAcc.Account,
|
|
|
|
|
sysPsssword = ytAcc.Password
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string strPostObj = postObj.ToJsonString();
|
|
|
|
|
_logger.LogInformation($"调用提箱小票接口传递数据:{strPostObj}");
|
|
|
|
|
var strResp = await dicUrlTxxp.Value.SetBody(postObj).PostAsStringAsync();
|
|
|
|
|
_logger.LogInformation($"调用提箱小票接口返回:{strResp}");
|
|
|
|
|
|
|
|
|
|
var jobjResp = JObject.Parse(strResp);
|
|
|
|
|
int respCode = jobjResp.GetIntValue("code");
|
|
|
|
|
if (respCode != 200)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK124, jobjResp.GetStringValue("message"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//保存url
|
|
|
|
|
var txxpUrl = jobjResp.GetStringValue("data");
|
|
|
|
|
ordUrl.UrlTxxp = txxpUrl;
|
|
|
|
|
await _repOrderUrl.UpdateAsync(ordUrl);
|
|
|
|
|
return txxpUrl;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region VGM及VMG链接
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取VGM、VGM&SI链接
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/vgmlink")]
|
|
|
|
|
public async Task<string[]> VgmLink(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
var order = _rep.FirstOrDefault(x => x.Id == bookingId);
|
|
|
|
|
if (order == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK001);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ordUrl = _repOrderUrl.FirstOrDefault(x => x.BookingId == bookingId);
|
|
|
|
|
if (ordUrl == null)
|
|
|
|
|
{
|
|
|
|
|
ordUrl = new BookingOrderUrl();
|
|
|
|
|
ordUrl.BookingId = bookingId;
|
|
|
|
|
await _repOrderUrl.InsertAsync(ordUrl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(ordUrl.UrlVgm))
|
|
|
|
|
{
|
|
|
|
|
return new string[] { ordUrl.UrlVgm, ordUrl.UrlVgmSi };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//校验船公司
|
|
|
|
|
if (string.IsNullOrEmpty(order.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK118);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//判断船公司是否支持
|
|
|
|
|
var allowCarrier = _cache.GetAllDictData().Result.Where(x => x.TypeCode == "vgm_carrier_list").Select(x => x.Code).ToList();
|
|
|
|
|
if (!allowCarrier.Contains(order.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK117);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//船公司网站账号
|
|
|
|
|
var carrWebAccMap = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "carrier_web_account_mapping" && x.Code == order.CARRIERID);
|
|
|
|
|
var webacc = _repWebAcc.FirstOrDefault(x => x.TypeCode == carrWebAccMap.Value && x.CreatedUserId == UserManager.UserId);
|
|
|
|
|
if (webacc == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK125);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//场站转换
|
|
|
|
|
var yardset = _cache.GetAllMappingYard().Result.FirstOrDefault(y => y.Code == order.YARDID && y.Module == "BookingVgm");
|
|
|
|
|
if (yardset == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK120, order.YARDID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ctns = await _repCtn.Where(x => x.BILLID == bookingId).ToListAsync();
|
|
|
|
|
//校验箱子数据录入
|
|
|
|
|
if (ctns.Where(c => string.IsNullOrEmpty(c.CTNALL) || !c.CTNNUM.HasValue).Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK121);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//箱型映射
|
|
|
|
|
var ctnMapping = await _cache.GetAllMappingCtn();
|
|
|
|
|
ctnMapping = ctnMapping.Where(x => x.Module == "BookingVgm").ToList();
|
|
|
|
|
if (ctnMapping.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK122);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var expCode = ctns.Select(x => x.CTNCODE).Distinct().Except(ctnMapping.Select(y => y.Code)).ToList();
|
|
|
|
|
if (expCode.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK123, string.Join(',', expCode));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var user = await _repUser.FirstOrDefaultAsync(x => x.Id == UserManager.UserId);
|
|
|
|
|
|
|
|
|
|
//调用小票服务
|
|
|
|
|
var dicUrlTxxp = _cache.GetAllDictData().Result.First(x => x.TypeCode == "url_set" && x.Code == "vgm_link_service");
|
|
|
|
|
var postObj = new
|
|
|
|
|
{
|
|
|
|
|
SystemCode = "djy_hechuan",
|
|
|
|
|
billOrderId = order.Id.ToString(),
|
|
|
|
|
sendOrderCode = order.MBLNO,
|
|
|
|
|
customerName = $"{UserManager.TENANT_NAME}+{UserManager.Name}", //公司名称+用户姓名
|
|
|
|
|
customerId = order.CUSTOMERID.ToString(),
|
|
|
|
|
agentName = string.IsNullOrEmpty(order.FORWARDER) ? UserManager.TENANT_NAME : order.FORWARDER,
|
|
|
|
|
carrierCode = order.CARRIERID,
|
|
|
|
|
userName = webacc.Account,
|
|
|
|
|
userPassword = webacc.Password,
|
|
|
|
|
depotCode = yardset.MapCode,
|
|
|
|
|
depotName = order.YARD,
|
|
|
|
|
linkName = UserManager.Name,
|
|
|
|
|
linkMobile = user.Tel,
|
|
|
|
|
linkEmail = user.Email,
|
|
|
|
|
userId = UserManager.DjyUserId,
|
|
|
|
|
returnUrl = "",
|
|
|
|
|
shipName = order.VESSEL,
|
|
|
|
|
voyNo = order.VOYNO,
|
|
|
|
|
etdstr = order.ETD.HasValue ? order.ETD.Value.ToString("yyyy-MM-dd") : string.Empty,
|
|
|
|
|
potrSend = order.PORTLOAD,
|
|
|
|
|
potrGoal = order.PORTDISCHARGE,
|
|
|
|
|
boxinfoStr = order.CNTRTOTAL,
|
|
|
|
|
vgmEndTimeStr = order.CLOSEVGMDATE.HasValue ? order.CLOSEVGMDATE.Value.ToString("yyyy-MM-dd") : string.Empty,
|
|
|
|
|
returnOkUrl = "",
|
|
|
|
|
SiReturnUrl = "",
|
|
|
|
|
DataInfoJson = new
|
|
|
|
|
{
|
|
|
|
|
order.SHIPPER,
|
|
|
|
|
order.CONSIGNEE,
|
|
|
|
|
order.NOTIFYPARTY,
|
|
|
|
|
order.MARKS,
|
|
|
|
|
order.DESCRIPTION,
|
|
|
|
|
order.BLFRT,
|
|
|
|
|
order.SERVICE,
|
|
|
|
|
order.ISSUETYPE,
|
|
|
|
|
order.TRANSPORT,
|
|
|
|
|
order.TRANSPORTID,
|
|
|
|
|
order.DESTINATION,
|
|
|
|
|
order.DESTINATIONID,
|
|
|
|
|
order.KINDPKGS,
|
|
|
|
|
order.THIRDPAYADDR,
|
|
|
|
|
order.PORTLOAD,
|
|
|
|
|
order.PORTLOADID,
|
|
|
|
|
order.PORTDISCHARGE,
|
|
|
|
|
order.PORTDISCHARGEID
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
string strPostObj = postObj.ToJsonString();
|
|
|
|
|
_logger.LogInformation($"调用VGM链接接口传递数据:{strPostObj}");
|
|
|
|
|
var strResp = await dicUrlTxxp.Value.SetBody(postObj).PostAsStringAsync();
|
|
|
|
|
_logger.LogInformation($"调用VGM链接接口返回:{strResp}");
|
|
|
|
|
|
|
|
|
|
var jobjResp = JObject.Parse(strResp);
|
|
|
|
|
int respCode = jobjResp.GetIntValue("code");
|
|
|
|
|
if (respCode != 200)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK126, jobjResp.GetStringValue("message"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//保存url
|
|
|
|
|
var memoData = jobjResp.GetJObjectValue("memoData");
|
|
|
|
|
ordUrl.UrlVgm = memoData.GetStringValue("vgmUrl");
|
|
|
|
|
ordUrl.UrlVgmSi = memoData.GetStringValue("vgmAndSiUrl");
|
|
|
|
|
await _repOrderUrl.UpdateAsync(ordUrl);
|
|
|
|
|
return new string[] { ordUrl.UrlVgm, ordUrl.UrlVgmSi };
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 订舱、截单EDI
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 其他
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取用户报表的json
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
[HttpGet("/BookingOrder/reportJson")]
|
|
|
|
|
public async Task<IActionResult> GenReportJson(long id)
|
|
|
|
|
{
|
|
|
|
|
var jsonUrl = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "url_report_generate").Value;
|
|
|
|
|
if (!jsonUrl.EndsWith("/"))
|
|
|
|
|
{
|
|
|
|
|
jsonUrl += "/";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jsonUrl += "Report/BookingReportJson?bookingId=" + id;
|
|
|
|
|
|
|
|
|
|
var rtn = await jsonUrl.SetHttpMethod(HttpMethod.Get).GetAsStringAsync();
|
|
|
|
|
var fileName = HttpUtility.UrlEncode($"{id}.json", Encoding.GetEncoding("UTF-8"));
|
|
|
|
|
var result = new FileContentResult(Encoding.UTF8.GetBytes(rtn), "application/octet-stream") { FileDownloadName = fileName };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成报表文件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <param name="type">类型,对应字典中的【订舱打印模板类型】</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/reportFile")]
|
|
|
|
|
public async Task<IActionResult> GenReportJson(long id, string type)
|
|
|
|
|
{
|
|
|
|
|
//打印报表服务地址
|
|
|
|
|
var reportUrl = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "url_report_generate").Value;
|
|
|
|
|
if (!reportUrl.EndsWith("/"))
|
|
|
|
|
{
|
|
|
|
|
reportUrl += "/";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//订舱数据
|
|
|
|
|
var order = _rep.FirstOrDefault(x => x.Id == id);
|
|
|
|
|
if (order == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK001);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//打印模板
|
|
|
|
|
var printTemplate = _repPrint.FirstOrDefault(x => x.TenantId == order.TenantId && x.TypeCode == type);
|
|
|
|
|
if (printTemplate == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK112);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//读取配置路劲
|
|
|
|
|
var opt = App.GetOptions<PrintTemplateOptions>();
|
|
|
|
|
var dirAbs = opt.basePath;
|
|
|
|
|
if (string.IsNullOrEmpty(dirAbs))
|
|
|
|
|
{
|
|
|
|
|
dirAbs = App.WebHostEnvironment.WebRootPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//读取模板并调用接口
|
|
|
|
|
var fileAbsPath = Path.Combine(dirAbs, printTemplate.FilePath).ToLower();
|
|
|
|
|
if (!File.Exists(fileAbsPath))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK112);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"准备调用报表生成:id:{id},文件:{printTemplate.FileName}");
|
|
|
|
|
var genUrl = reportUrl + "Report/BookingReport?bookingId=" + id;
|
|
|
|
|
var rtn = await genUrl
|
|
|
|
|
.SetContentType("multipart/form-data")
|
|
|
|
|
.SetBodyBytes(("file", File.ReadAllBytes(fileAbsPath), HttpUtility.UrlEncode(printTemplate.FileName, Encoding.GetEncoding("UTF-8"))))
|
|
|
|
|
.PostAsStringAsync();
|
|
|
|
|
var jobjRtn = JObject.Parse(rtn);
|
|
|
|
|
_logger.LogInformation($"调用报表生成返回:{rtn}");
|
|
|
|
|
if (jobjRtn.GetBooleanValue("Success"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//调用读取文件
|
|
|
|
|
var fn = jobjRtn.GetStringValue("Data");
|
|
|
|
|
_logger.LogInformation($"准备调用读取文件:id:{id},文件名:{fn}");
|
|
|
|
|
var readFileUrl = reportUrl + "Report/GetFile?fileName=" + fn;
|
|
|
|
|
var bs = await readFileUrl.GetAsByteArrayAsync();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"调用读取文件返回:{bs.Length}");
|
|
|
|
|
|
|
|
|
|
var fileName = HttpUtility.UrlEncode($"{id}_{type}_{DateTime.Now.Ticks}.pdf", Encoding.GetEncoding("UTF-8"));
|
|
|
|
|
var result = new FileContentResult(bs, "application/octet-stream") { FileDownloadName = fileName };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"生成报表文件失败:{jobjRtn.GetStringValue("Message")}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|