|
|
|
|
using Furion.DependencyInjection;
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 订舱自动化相关
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings("Application", Name = "BookingOrderAuto", Order = 1)]
|
|
|
|
|
public class BookingOrderAutoService : IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<BookingOrderAutoService> _logger;
|
|
|
|
|
|
|
|
|
|
private readonly SqlSugarRepository<SysTenant> _repoTenant;
|
|
|
|
|
private readonly SqlSugarRepository<SysUser> _repoUser;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrder> _repoBookingOrder;
|
|
|
|
|
private readonly BookingOrderService _servBookingOrder;
|
|
|
|
|
|
|
|
|
|
public BookingOrderAutoService(ILogger<BookingOrderAutoService> logger,
|
|
|
|
|
SqlSugarRepository<SysTenant> repoTenant,
|
|
|
|
|
SqlSugarRepository<SysUser> repoUser,
|
|
|
|
|
SqlSugarRepository<BookingOrder> repoBookingOrder,
|
|
|
|
|
BookingOrderService servBookingOrder)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_repoTenant = repoTenant;
|
|
|
|
|
_repoUser = repoUser;
|
|
|
|
|
_repoBookingOrder = repoBookingOrder;
|
|
|
|
|
_servBookingOrder = servBookingOrder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据查询编号和公司ID获取操作信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrderAuto/GetOpInfoForBooking")]
|
|
|
|
|
[AllowAnonymous, ApiUser(ApiCode = "BookingAuto")]
|
|
|
|
|
public async Task<BookingAutoQueryOpOutput> GetOpInfoForBooking([FromQuery] BookingAutoQueryInput dto)
|
|
|
|
|
{
|
|
|
|
|
var tenant = await _repoTenant.AsQueryable().Filter(null, true)
|
|
|
|
|
.WhereIF(dto.TenantId > 0, x => x.Id == dto.TenantId)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.CompId), x => x.CompId == dto.CompId)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (tenant == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("未找到租户公司信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var strOpId = await _repoBookingOrder.AsQueryable().Filter(null, true)
|
|
|
|
|
.Where(x => x.IsDeleted == false && x.TenantId == tenant.Id)
|
|
|
|
|
.WhereIF(dto.QueryType == BookingAutoQueryType.BookingNO, x => x.CUSTNO == dto.QueryCode)
|
|
|
|
|
.WhereIF(dto.QueryType == BookingAutoQueryType.MBLNO, x => x.MBLNO == dto.QueryCode)
|
|
|
|
|
.Select(x => x.OPID)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(strOpId))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("未找到业务或操作数据");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var opid = Convert.ToInt64(strOpId);
|
|
|
|
|
|
|
|
|
|
var opInfo = await _repoUser.AsQueryable().Filter(null, true)
|
|
|
|
|
.FirstAsync(x => x.Id == opid);
|
|
|
|
|
return opInfo.Adapt<BookingAutoQueryOpOutput>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发送下货纸
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingOrderAuto/LetterYard")]
|
|
|
|
|
[AllowAnonymous, ApiUser(ApiCode = "BookingAuto")]
|
|
|
|
|
public async Task LetterYard(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
await _servBookingOrder.SendLetterYard(bookingId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 放舱
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingOrderAuto/FangCang")]
|
|
|
|
|
[AllowAnonymous, ApiUser(ApiCode = "BookingAuto")]
|
|
|
|
|
public async Task FangCang()
|
|
|
|
|
{
|
|
|
|
|
//自动放舱涉及选择模板的问题,得确认方案后实现
|
|
|
|
|
throw Oops.Bah("暂未实现");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新订舱数据
|
|
|
|
|
/// 当前支持如下:
|
|
|
|
|
/// 1.提单号-MBLNO 2.开船日期-ETD
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingOrderAuto/UpdateBookingData")]
|
|
|
|
|
[AllowAnonymous, ApiUser(ApiCode = "BookingAuto")]
|
|
|
|
|
public async Task UpdateBookingData(BookingAutoUpdateDataInput dto)
|
|
|
|
|
{
|
|
|
|
|
var tenant = await _repoTenant.AsQueryable().Filter(null, true)
|
|
|
|
|
.WhereIF(dto.TenantId > 0, x => x.Id == dto.TenantId)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.CompId), x => x.CompId == dto.CompId)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (tenant == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("未找到租户公司信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var order = await _repoBookingOrder.AsQueryable().Filter(null, true)
|
|
|
|
|
.Where(x => x.IsDeleted == false && x.TenantId == tenant.Id)
|
|
|
|
|
.WhereIF(dto.QueryType == BookingAutoQueryType.BookingNO, x => x.CUSTNO == dto.QueryCode)
|
|
|
|
|
.WhereIF(dto.QueryType == BookingAutoQueryType.MBLNO, x => x.MBLNO == dto.QueryCode)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (order == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("未找到业务数据");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var jobjData = dto.DataJson as JObject;
|
|
|
|
|
var updColList = new List<string>();
|
|
|
|
|
foreach (var item in jobjData)
|
|
|
|
|
{
|
|
|
|
|
if (item.Key.ToUpper() == "MBLNO")
|
|
|
|
|
{
|
|
|
|
|
order.MBLNO = item.Value.ToString();
|
|
|
|
|
updColList.Add("MBLNO");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Key.ToUpper() == "ETD")
|
|
|
|
|
{
|
|
|
|
|
order.ETD = Convert.ToDateTime(item.Value.ToString());
|
|
|
|
|
updColList.Add("ETD");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _repoBookingOrder.AsUpdateable(order).UpdateColumns(updColList.ToArray()).ExecuteCommandAsync();
|
|
|
|
|
_logger.LogInformation($"更新订舱数据 {order.Id},更新字段:{string.Join(",", updColList)},原始数据:{dto.ToJsonString()}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取船司账号信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingOrderAuto/GetCarrierAccount")]
|
|
|
|
|
[AllowAnonymous, ApiUser(ApiCode = "BookingAuto")]
|
|
|
|
|
public async Task GetCarrierAccount()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|