Vgm相关

master
ZR20090193-陈敬勇 6 months ago
parent 22a53fdc54
commit 30172daff4

@ -70,6 +70,12 @@ public static class MultiLanguageConst
[Description("箱型映射信息不存在")]
public const string MappingCtnNotExist = "MappingCtn_Not_Exist";
[Description("船司映射信息已存在")]
public const string MappingCarrierExist = "MappingCarrier_Exist";
[Description("船司映射信息不存在")]
public const string MappingCarrierNotExist = "MappingCarrier_Not_Exist";
#endregion
#region 用户管理

@ -537,4 +537,40 @@ public static partial class Extensions
int.TryParse(strVal, out rtnVal);
return rtnVal;
}
/// <summary>
/// 获取int值
/// </summary>
/// <param name="jobj"></param>
/// <param name="prop"></param>
/// <returns></returns>
public static bool GetBooleanValue(this JObject jobj, string prop)
{
var jt = jobj[prop];
if (jt == null)
{
return false;
}
var strVal = jt.ToString();
bool.TryParse(strVal, out bool rtnVal);
return rtnVal;
}
/// <summary>
/// 获取JObject
/// </summary>
/// <param name="jobj"></param>
/// <param name="prop"></param>
/// <returns></returns>
public static JObject GetJObjectValue(this JObject jobj, string prop)
{
var jt = jobj[prop];
if (jt == null)
{
return null;
}
return jt as JObject;
}
}

@ -14,105 +14,75 @@ public class ClientBankReq
public long Id { get; set; }
/// <summary>
/// 客户id
/// 客户Id
/// </summary>
public long ClientId { get; set; }
/// <summary>
/// Desc:联系人代码
/// </summary>
public string CodeName { get; set; }
/// <summary>
/// Desc:联系人简称
/// </summary>
public string ShortName { get; set; }
/// <summary>
/// Desc:职务
/// </summary>
public string Job { get; set; }
/// <summary>
/// Desc:通讯地址
/// Desc:代码
/// </summary>
public string Address { get; set; }
/// <summary>
/// Desc:邮箱
/// </summary>
public string Email { get; set; }
/// <summary>
/// Desc:手机
/// </summary>
public string Mobile { get; set; }
public string CodeName { get; set; }
/// <summary>
/// Desc:电话
/// Desc:币别
/// </summary>
public string Tel { get; set; }
public string Currency { get; set; }
/// <summary>
/// Desc:传真
/// Desc:银行名称
/// </summary>
public string Fax { get; set; }
public string BankName { get; set; }
/// <summary>
/// Desc:QQ
/// Desc:银行账户
/// </summary>
public string QQ { get; set; }
public string Account { get; set; }
/// <summary>
/// Desc:是否为操作
/// Desc:银行地址
/// </summary>
public bool? IsOperator { get; set; } = false;
public string BankAddress { get; set; }
/// <summary>
/// Desc:是否为财务
/// Desc:财务软件代码
/// </summary>
public bool? IsFinancialStaff { get; set; } = false;
public string FinanceSoftCode { get; set; }
/// <summary>
/// Desc:是否为销售
/// Desc:科目代码
/// </summary>
public bool? IsSaleMan { get; set; } = false;
public string SubjectCode { get; set; }
/// <summary>
/// Desc:是否为其他
/// Desc:户头名称
/// </summary>
public bool? IsOther { get; set; } = false;
public string AccountName { get; set; }
/// <summary>
/// Desc:是否保险联系人
/// Desc:代理银行名称
/// </summary>
public bool? IsInsurance { get; set; } = false;
public string BankAgentName { get; set; }
/// <summary>
/// Desc:是否对账联系人
/// Desc:银行账号
/// </summary>
public bool? IsCheckAccount { get; set; } = false;
public string BankAccountNo { get; set; }
/// <summary>
/// 提醒日期1
/// Desc: 银行SWIFT
/// </summary>
public DateTime Anniversary1 { get; set; }
public string SWIFT { get; set; }
/// <summary>
/// 提醒日期2
/// </summary>
public DateTime Anniversary2 { get; set; }
/// <summary>
/// 提醒备注1
/// Desc: 国家Id
/// </summary>
public string AnniversaryNote1 { get; set; }
public long? CountryId { get; set; }
/// <summary>
/// 提醒备注2
/// Desc:是否开票默认账户
/// </summary>
public string AnniversaryNote2 { get; set; }
public bool? IsInvoiceDefault { get; set; } = false;
/// <summary>
/// 状态 0 启用 1 禁用
@ -138,8 +108,8 @@ public class ClientBankReqValidator : AbstractValidator<ClientBankReq>
public ClientBankReqValidator()
{
this.RuleFor(o => o.CodeName)
.NotEmpty().WithName("联系人代码");
this.RuleFor(o => o.ShortName)
.NotEmpty().WithName("联系人简称");
.NotEmpty().WithName("银行代码");
this.RuleFor(o => o.BankName)
.NotEmpty().WithName("银行名称");
}
}

@ -0,0 +1,76 @@
using DS.Module.Core;
using DS.WMS.Core.Code.Dtos;
using FluentValidation;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Map.Dtos
{
/// <summary>
/// 船司映射信息请求
/// </summary>
public class MappingCarrierReq
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 关联业务id
/// </summary>
public long LinkId { get; set; }
/// <summary>
/// 代码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 模块
/// </summary>
public string Module { get; set; }
/// <summary>
/// 映射代码
/// </summary>
public string MapCode { get; set; }
/// <summary>
/// 映射名称
/// </summary>
public string MapName { get; set; }
/// <summary>
/// 状态 0 启用 1 禁用
/// </summary>
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
}
/// <summary>
/// 验证
/// </summary>
public class MappingCarrierReqValidator : AbstractValidator<MappingCarrierReq>
{
/// <summary>
/// 构造函数
/// </summary>
public MappingCarrierReqValidator()
{
this.RuleFor(o => o.LinkId)
.NotEmpty().WithName("船司Id");
this.RuleFor(o => o.Module)
.NotEmpty().WithName("模块");
this.RuleFor(o => o.MapCode)
.NotEmpty().WithName("映射代码");
this.RuleFor(o => o.MapName)
.NotEmpty().WithName("映射名称");
}
}
}

@ -0,0 +1,63 @@
using DS.Module.Core;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Map.Dtos
{
/// <summary>
/// 船司映射信息返回
/// </summary>
public class MappingCarrierRes
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 关联业务id
/// </summary>
public long LinkId { get; set; }
/// <summary>
/// 代码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 模块
/// </summary>
public string Module { get; set; }
/// <summary>
/// 映射代码
/// </summary>
public string MapCode { get; set; }
/// <summary>
/// 映射名称
/// </summary>
public string MapName { get; set; }
/// <summary>
/// 船公司名称
/// </summary>
public string CarrierName { get; set; }
/// <summary>
/// 状态 0 启用 1 禁用
/// </summary>
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
}
}

@ -0,0 +1,52 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Map.Entity
{
/// <summary>
/// 船司映射信息
/// </summary>
[SqlSugar.SugarTable("op_map_carrier", "船司映射信息")]
public class MappingCarrier : BaseModel<long>
{
/// <summary>
/// 关联业务id
/// </summary>
public long LinkId { get; set; }
/// <summary>
/// 代码
/// </summary>
[SugarColumn(ColumnDescription = "代码", Length = 100, IsNullable = false)]
public string Code { get; set; }
/// <summary>
/// 模块
/// </summary>
[SugarColumn(ColumnDescription = "模块", Length = 100, IsNullable = false)]
public string Module { get; set; }
/// <summary>
/// 映射代码
/// </summary>
[SugarColumn(ColumnDescription = "映射代码", Length = 100, IsNullable = false)]
public string MapCode { get; set; }
/// <summary>
/// 映射名称
/// </summary>
[SugarColumn(ColumnDescription = "映射名称", Length = 100, IsNullable = true)]
public string MapName { get; set; }
/// <summary>
/// 状态 0启用 1禁用
/// </summary>
[SugarColumn(ColumnDescription = "状态", DefaultValue = "0")]
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
}
}

@ -0,0 +1,49 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Map.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Map.Interface
{
public interface IMappingCarrierService
{
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<MappingCarrierRes>> GetListByPage(PageRequest request);
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
DataResult EditMappingCarrier(MappingCarrierReq req);
/// <summary>
/// 获取详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<MappingCarrierRes> GetMappingCarrierInfo(string id);
/// <summary>
/// 删除
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public DataResult DelMappingCarrier(IdModel req);
/// <summary>
/// 批量删除
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public DataResult BatchDelMappingCarrier(IdModel req);
}
}

@ -0,0 +1,127 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Info.Dtos;
using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Map.Dtos;
using DS.WMS.Core.Map.Entity;
using DS.WMS.Core.Map.Interface;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using DS.Module.Core.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Org.BouncyCastle.Ocsp;
using Mapster;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Code.Entity;
namespace DS.WMS.Core.Map.Method
{
public class MappingCarrierService : IMappingCarrierService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public MappingCarrierService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
public DataResult BatchDelMappingCarrier(IdModel req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = tenantDb.Queryable<MappingCarrier>().Where(x => req.Ids.Contains(x.Id)).ToList();
;
if (list.Count > 0)
{
tenantDb.Deleteable(list).ExecuteCommand();
}
return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess);
}
public DataResult DelMappingCarrier(IdModel req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var info = tenantDb.Queryable<MappingCarrier>().Where(x => x.Id == long.Parse(req.Id)).First();
if (info == null)
{
return DataResult.Failed("船司映射信息不存在!", MultiLanguageConst.MappingCarrierNotExist);
}
tenantDb.Deleteable(info).ExecuteCommand();
return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess);
}
public DataResult EditMappingCarrier(MappingCarrierReq req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
if (tenantDb.Queryable<MappingCarrier>().Where(x => x.LinkId == req.LinkId && x.Module == req.Module).Any())
{
return DataResult.Failed("船司映射信息已存在!", MultiLanguageConst.MappingCarrierExist);
}
var data = req.Adapt<MappingCarrier>();
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = tenantDb.Queryable<MappingCarrier>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
}
}
public DataResult<List<MappingCarrierRes>> GetListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<MappingCarrier>()
.Where(whereList)
.Select<MappingCarrierRes>()
.Mapper(it =>
{
it.CarrierName = tenantDb.Queryable<InfoClient>().Where(x => x.Id == it.LinkId).Select(n => n.ShortName).First();
}
).ToQueryPage(request.PageCondition);
return data;
}
public DataResult<MappingCarrierRes> GetMappingCarrierInfo(string id)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<MappingCarrier>()
.Where(a => a.Id == long.Parse(id))
.Select<MappingCarrierRes>()
.Mapper(it =>
{
it.CarrierName = tenantDb.Queryable<InfoClient>().Where(x => x.Id == it.LinkId).Select(n => n.ShortName).First();
}
)
.First();
return DataResult<MappingCarrierRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
}
}
}

@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.Dtos
{
/// <summary>
///
/// </summary>
public class BatchVGM
{
/// <summary>
/// id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 提单号
/// </summary>
public string MBLNO { get; set; }
public List<BatchVGMList> ctnlist { get; set; }
}
public class BatchVGMList {
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 箱型代码
/// </summary>
public string CtnCode { get; set; }
/// <summary>
/// 表现形式
/// </summary>
public string CtnAll { get; set; }
/// <summary>
/// 箱号
/// </summary>
public string CntrNo { get; set; }
/// <summary>
/// 毛重
/// </summary>
public decimal? KGS { get; set; }
/// <summary>
/// 皮重
/// </summary>
public decimal? TareWeight { get; set; }
/// <summary>
/// 称重方式
/// </summary>
public string WeightType { get; set; }
/// <summary>
/// 称重重量
/// </summary>
public decimal? WeightKGS { get; set; }
}
}

@ -1032,6 +1032,27 @@ public class SeaExportReq
/// </summary>
public string Note { get; set; } = "";
/// <summary>
/// 中转港代码
/// </summary>
public string TransportCode { get; set; }
/// <summary>
/// 第三付款地
/// </summary>
[SugarColumn(ColumnDescription = "第三付款地", IsNullable = true, Length = 50)]
public string ThirdPayAt { get; set; }
/// <summary>
/// 发货人 t_info_client CUSTNAME
/// </summary>
public string Shipper { get; set; }
/// <summary>
/// 收货人 t_info_client CUSTNAME
/// </summary>
public string Consignee { get; set; }
/// <summary>
/// 通知人 t_info_client CUSTNAME
/// </summary>
public string NotifyParty { get; set; }
}
/// <summary>

@ -1061,4 +1061,30 @@ public class SeaExportRes
/// </summary>
public string IsBookingYZ { get; set; }
/// <summary>
/// VGM截止日期
/// </summary>
public DateTime? CloseVgmDate { get; set; }
/// <summary>
/// 中转港代码
/// </summary>
public string TransportCode { get; set; }
/// <summary>
/// 第三付款地
/// </summary>
[SugarColumn(ColumnDescription = "第三付款地", IsNullable = true, Length = 50)]
public string ThirdPayAt { get; set; }
/// <summary>
/// 发货人 t_info_client CUSTNAME
/// </summary>
public string Shipper { get; set; }
/// <summary>
/// 收货人 t_info_client CUSTNAME
/// </summary>
public string Consignee { get; set; }
/// <summary>
/// 通知人 t_info_client CUSTNAME
/// </summary>
public string NotifyParty { get; set; }
}

@ -0,0 +1,37 @@
using DS.Module.Core.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.Entity
{
/// <summary>
/// 订舱链接
/// </summary>
[SqlSugar.SugarTable("op_booking_order_url", "订舱链接")]
public class BookingOrderUrl : BaseModel<long>
{
/// <summary>
/// 业务ID
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "业务id", IsNullable = false)]
public long? BusinessId { get; set; }
/// <summary>
/// 提箱小票链接
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "提箱小票链接", IsNullable = true, Length = 500)]
public string UrlTxxp { get; set; }
/// <summary>
/// VGM链接
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "VGM链接", IsNullable = true, Length = 500)]
public string UrlVgm { get; set; }
/// <summary>
/// VGM SI链接
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "VGM SI链接", IsNullable = true, Length = 500)]
public string UrlVgmSi { get; set; }
}
}

@ -42,7 +42,7 @@ namespace DS.WMS.Core.Op.Entity
/// 箱量
/// </summary>
[SugarColumn(ColumnDescription = "箱量", IsNullable = true, DefaultValue = "0")]
public int CtnNum { get; set; }
public int? CtnNum { get; set; }
/// <summary>
/// TEU

@ -1,6 +1,7 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using SqlSugar;
using System.ComponentModel;
namespace DS.WMS.Core.Op.Entity;
@ -116,19 +117,32 @@ public class SeaExport : BaseOrgModel<long>
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "发货人", IsNullable = true)]
public long? ShipperId { get; set; }
/// <summary>
/// 发货人 t_info_client CUSTNAME
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "发货人", IsNullable = true)]
public string Shipper { get; set; }
/// <summary>
/// 收货人 t_info_client CUSTNAME
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "收货人", IsNullable = true)]
public long? ConsigneeId { get; set; }
/// <summary>
/// 收货人 t_info_client CUSTNAME
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "收货人", IsNullable = true)]
public string Consignee { get; set; }
/// <summary>
/// 通知人 t_info_client CUSTNAME
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "通知人", IsNullable = true)]
public long? NotifyPartyId { get; set; }
/// <summary>
/// 通知人 t_info_client CUSTNAME
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "通知人", IsNullable = true)]
public string NotifyParty { get; set; }
/// <summary>
/// 国外代理人Id t_info_client CUSTNAME
/// </summary>
@ -340,7 +354,11 @@ public class SeaExport : BaseOrgModel<long>
/// </summary>
[SugarColumn(ColumnDescription = "预付地点", IsNullable = true, Length = 50)]
public string PayableAt { get; set; }
/// <summary>
/// 第三付款地
/// </summary>
[SugarColumn(ColumnDescription = "第三付款地", IsNullable = true, Length = 50)]
public string ThirdPayAt { get; set; }
/// <summary>
/// 运输条款 CY-CY t_code_service
/// </summary>
@ -831,7 +849,11 @@ public class SeaExport : BaseOrgModel<long>
/// </summary>
[SugarColumn(ColumnDescription = "仓库", IsNullable = true, Length = 20)]
public string WareHouse { get; set; }
/// <summary>
/// VGM截止日期
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "截单日期", IsNullable = false)]
public DateTime? CloseVgmDate { get; set; }
/// <summary>
/// 截单日期
/// </summary>
@ -1204,7 +1226,11 @@ public class SeaExport : BaseOrgModel<long>
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "销售公司Id", IsNullable = true, DefaultValue = "0")]
public long SaleOrgId { get; set; }
/// <summary>
/// 中转港代码
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "中转港代码", IsNullable = true, Length = 60)]
public string TransportCode { get; set; }
/// <summary>
/// 中转港
/// </summary>

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.Interface
{
public interface ISeaExportCommonService
{
/// <summary>
/// 设置货物状态完成
/// </summary>
/// <param name="code"></param>
/// <param name="bookingId"></param>
/// <returns></returns>
public Task SetGoodsStatus(string code, long bookingId);
}
}

@ -97,4 +97,32 @@ public interface ISeaExportService
/// <param name="req"></param>
/// <returns></returns>
public Task<DataResult<string>> UnsubscribeBillTrace(List<BillTraceUnsubscribeList> req);
/// <summary>
/// 获取VGM、VGM SI链接
/// </summary>
/// <param name="id">业务Id</param>
/// <returns></returns>
public Task<DataResult<string[]>> VgmLink(string id);
/// <summary>
/// 发送VGM
/// </summary>
/// <param name="id">业务Id</param>
/// <returns></returns>
public Task<DataResult<string>> VgmSend(string id);
/// <summary>
/// 批量获取vgm
/// </summary>
/// <param name="ids">业务id 逗号拼接</param>
/// <returns></returns>
public Task<DataResult<List<BatchVGM>>> GetVmgDataList(string ids);
/// <summary>
/// 批量保存vgm
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public Task<DataResult<string>> SaveBatchVgm(List<BatchVGMList> req);
}

@ -23,6 +23,7 @@ namespace DS.WMS.Core.Op.Method
private readonly IUser user;
private readonly ISaasDbService saasService;
private readonly ICommonService commonService;
private readonly ISeaExportCommonService seaComService;
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
/// <summary>
///
@ -35,7 +36,7 @@ namespace DS.WMS.Core.Op.Method
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
commonService = _serviceProvider.GetRequiredService<ICommonService>();
seaComService = _serviceProvider.GetRequiredService<ISeaExportCommonService>();
}
/// <summary>
/// 插入货运动态
@ -164,7 +165,7 @@ namespace DS.WMS.Core.Op.Method
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
//2023-12-28 JHQ 增加舱单放行推送状态
await SetGoodsStatus("CDFX", item.BookingId);
await seaComService.SetGoodsStatus("CDFX", item.BookingId);
}
}
if (item.Status == "海关放行")
@ -180,7 +181,7 @@ namespace DS.WMS.Core.Op.Method
StatusGroup = "booking_status_group_billtrace"
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
await SetGoodsStatus("BG", item.BookingId);
await seaComService.SetGoodsStatus("BG", item.BookingId);
}
}
@ -197,7 +198,7 @@ namespace DS.WMS.Core.Op.Method
StatusGroup = "booking_status_group_billtrace"
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
await SetGoodsStatus("ZZFX", item.BookingId);
await seaComService.SetGoodsStatus("ZZFX", item.BookingId);
}
}
@ -214,7 +215,7 @@ namespace DS.WMS.Core.Op.Method
StatusGroup = "booking_status_group_billtrace"
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
await SetGoodsStatus("MTFX", item.BookingId);
await seaComService.SetGoodsStatus("MTFX", item.BookingId);
}
}
@ -311,7 +312,7 @@ namespace DS.WMS.Core.Op.Method
StatusGroup = "booking_status_group_billtrace"
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
await SetGoodsStatus("YRG", item.BookingId);
await seaComService.SetGoodsStatus("YRG", item.BookingId);
}
}
#endregion
@ -333,88 +334,6 @@ namespace DS.WMS.Core.Op.Method
/// <summary>
/// 设置货物状态完成
/// </summary>
/// <param name="code"></param>
/// <param name="bookingId"></param>
/// <returns></returns>
public async Task SetGoodsStatus(string code, long bookingId)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var CreatedUserId = tenantDb.Queryable<SeaExport>().Filter(null, true).Where(x => x.Id == bookingId).Select(x => x.CreateBy).First();
if (CreatedUserId != null)
{
var gsCfg = tenantDb.Queryable<BookingGoodsStatusConfig>().First(x => x.SystemCode == code && x.CreateBy == (long)CreatedUserId);
if (gsCfg != null)
{
_logger.Info($"检查{code}货物状态:{bookingId}");
var gs = tenantDb.Queryable<BookingGoodsStatus>().First(x => x.ConfigId == gsCfg.Id && x.BusinessId == bookingId);
if (gs == null)
{
gs = new BookingGoodsStatus()
{
BusinessId = bookingId,
ConfigId = gsCfg.Id,
FinishTime = DateTime.Now,
FinishUserName = user.UserId.IsNull() ? "超级管理员" : user.UserId,
FinishBy = user.UserId.IsNull() ? 0 : long.Parse(user.UserId),
StatusCode = gsCfg.SystemCode,
StatusName = gsCfg.StatusName,
};
await tenantDb.Insertable(gs).ExecuteCommandAsync();
_logger.Info($"发送{code}后自动完成货物状态,Id{bookingId}");
//更新货物状态
await SetBookingOrderGoodsStatus(bookingId);
}
}
}
}
/// <summary>
/// 更新主单货物状态
/// </summary>
/// <param name="bookingId"></param>
/// <returns></returns>
public async Task SetBookingOrderGoodsStatus(long bookingId)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var order = tenantDb.Queryable<SeaExport>().Filter(null, true).First(x => x.Id == bookingId);
var createUserid = order.CreateBy;
//获取当前用户已经录入的货物状态
var list = await tenantDb.Queryable<BookingGoodsStatus>().LeftJoin(tenantDb.Queryable<BookingGoodsStatusConfig>(),
(goods, config) => config.Id == goods.ConfigId).Where((goods, config) => config.CreateBy == createUserid && goods.BusinessId == bookingId).
OrderBy((goods, config) => config.OrderNo).
Select((goods, config) => new
{
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
FinishTime = goods.FinishTime,
FinishUser = goods.FinishUserName,
FinishUserId = goods.FinishBy,
IsPublic = goods.IsPublic,
ExtData = goods.ExtData,
Remark = goods.Note,
OrderNo = config.OrderNo
}).ToListAsync();
if (list != null)
{
//回写主单状态
var StatusName = list.Where(x => x.FinishTime.HasValue).OrderByDescending(x => x.OrderNo).Select(x => x.StatusName).FirstOrDefault();
if (StatusName == null)
{
StatusName = "";
}
order.BusinessStatusName = StatusName;
await tenantDb.Updateable(order).EnableDiffLogEvent().ExecuteCommandAsync();
// 记录日志
//var newOrder = order.Adapt<SeaExport>();
//newOrder.BSSTATUSNAME = StatusName;
//await SaveLog(newOrder, order, "自动更新货物状态");
}
}
}
}

@ -0,0 +1,126 @@
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Interface;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using NLog;
using NLog.Web;
using DS.Module.Core.Extensions;
using Logger = NLog.Logger;
using Mapster;
namespace DS.WMS.Core.Op.Method
{
public class SeaExportCommonService: ISeaExportCommonService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
private readonly ICommonService commonService;
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public SeaExportCommonService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
commonService = _serviceProvider.GetRequiredService<ICommonService>();
}
#region 设置货物状态
/// <summary>
/// 设置货物状态完成
/// </summary>
/// <param name="code"></param>
/// <param name="bookingId"></param>
/// <returns></returns>
public async Task SetGoodsStatus(string code, long bookingId)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var CreatedUserId = tenantDb.Queryable<SeaExport>().Filter(null, true).Where(x => x.Id == bookingId).Select(x => x.CreateBy).First();
if (CreatedUserId != null)
{
var gsCfg = tenantDb.Queryable<BookingGoodsStatusConfig>().First(x => x.SystemCode == code && x.CreateBy == (long)CreatedUserId);
if (gsCfg != null)
{
_logger.Info($"检查{code}货物状态:{bookingId}");
var gs = tenantDb.Queryable<BookingGoodsStatus>().First(x => x.ConfigId == gsCfg.Id && x.BusinessId == bookingId);
if (gs == null)
{
gs = new BookingGoodsStatus()
{
BusinessId = bookingId,
ConfigId = gsCfg.Id,
FinishTime = DateTime.Now,
FinishUserName = user.UserId.IsNull() ? "超级管理员" : user.UserId,
FinishBy = user.UserId.IsNull() ? 0 : long.Parse(user.UserId),
StatusCode = gsCfg.SystemCode,
StatusName = gsCfg.StatusName,
};
await tenantDb.Insertable(gs).ExecuteCommandAsync();
_logger.Info($"发送{code}后自动完成货物状态,Id{bookingId}");
//更新货物状态
await SetBookingOrderGoodsStatus(bookingId);
}
}
}
}
/// <summary>
/// 更新主单货物状态
/// </summary>
/// <param name="bookingId"></param>
/// <returns></returns>
public async Task SetBookingOrderGoodsStatus(long bookingId)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var order = tenantDb.Queryable<SeaExport>().Filter(null, true).First(x => x.Id == bookingId);
var createUserid = order.CreateBy;
//获取当前用户已经录入的货物状态
var list = await tenantDb.Queryable<BookingGoodsStatus>().LeftJoin(tenantDb.Queryable<BookingGoodsStatusConfig>(),
(goods, config) => config.Id == goods.ConfigId).Where((goods, config) => config.CreateBy == createUserid && goods.BusinessId == bookingId).
OrderBy((goods, config) => config.OrderNo).
Select((goods, config) => new
{
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
FinishTime = goods.FinishTime,
FinishUser = goods.FinishUserName,
FinishUserId = goods.FinishBy,
IsPublic = goods.IsPublic,
ExtData = goods.ExtData,
Remark = goods.Note,
OrderNo = config.OrderNo
}).ToListAsync();
if (list != null)
{
//回写主单状态
var StatusName = list.Where(x => x.FinishTime.HasValue).OrderByDescending(x => x.OrderNo).Select(x => x.StatusName).FirstOrDefault();
if (StatusName == null)
{
StatusName = "";
}
order.BusinessStatusName = StatusName;
await tenantDb.Updateable(order).EnableDiffLogEvent().ExecuteCommandAsync();
// 记录日志
//var newOrder = order.Adapt<SeaExport>();
//newOrder.BSSTATUSNAME = StatusName;
//await SaveLog(newOrder, order, "自动更新货物状态");
}
}
#endregion
}
}

@ -90,13 +90,14 @@ namespace DS.WMS.Core.Op.Method
public DataResult DelSeaExportRemark(string id)
{
var info = db.Queryable<SeaExportRemark>().Where(x => x.Id == long.Parse(id)).First();
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var info = tenantDb.Queryable<SeaExportRemark>().Where(x => x.Id == long.Parse(id)).First();
if (info == null)
{
return DataResult.Failed("海运出口备注不存在!", MultiLanguageConst.SeaExportRemarkNotExist);
}
}
db.Deleteable(info).ExecuteCommand();
tenantDb.Deleteable(info).ExecuteCommand();
return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess);
}
}

@ -20,7 +20,18 @@ using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SqlSugar;
using SqlSugar.Extensions;
using System.Security.Policy;
using NLog;
using NLog.Web;
using DS.Module.Core.Extensions;
using Logger = NLog.Logger;
using LanguageExt.ClassInstances.Pred;
using LanguageExt;
using DS.WMS.Core.Info.Entity;
using Org.BouncyCastle.Ocsp;
using Microsoft.AspNetCore.Mvc;
using LanguageExt.TypeClasses;
namespace DS.WMS.Core.Op.Method;
@ -29,9 +40,10 @@ public class SeaExportService : ISeaExportService
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
//private readonly ICrawlerDataService crawlerService;
private readonly ISaasDbService saasService;
private readonly ICommonService commonService;
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
private readonly ISeaExportCommonService seaComService;
/// <summary>
///
/// </summary>
@ -43,8 +55,7 @@ public class SeaExportService : ISeaExportService
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
commonService = _serviceProvider.GetRequiredService<ICommonService>();
//crawlerService = _serviceProvider.GetRequiredService<ICrawlerDataService>();
seaComService = _serviceProvider.GetRequiredService<ISeaExportCommonService>();
}
/// <summary>
@ -557,9 +568,9 @@ public class SeaExportService : ISeaExportService
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var account = tenantDb.Queryable<CodeThirdParty>().Where(x => x.CustomerId == req.YardId && x.AccountType == "BillTrace").First();
var userKey = db.Queryable<SysConfig>().Where(x => x.Code == "spiderUserKeyBilltrace").First().Value;
var userSecret = db.Queryable<SysConfig>().Where(x => x.Code == "spiderUserSecretBilltrace").First().Value;
var spiderServerUrl = db.Queryable<SysConfig>().Where(x => x.Code == "spiderServerUrlBillTraceNew").First().Value;
var userKey = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "spiderUserKeyBilltrace" && x.TenantId == 1288018625843826688).First().Value;
var userSecret = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "spiderUserSecretBilltrace" && x.TenantId == 1288018625843826688).First().Value;
var spiderServerUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "spiderServerUrlBillTraceNew" && x.TenantId == 1288018625843826688).First().Value;
var tenantName = db.Queryable<SysTenant>().Filter(null, true).Where(x => x.Id == long.Parse(user.TenantId)).First().Name;
if (account.IsNull())
{
@ -640,11 +651,11 @@ public class SeaExportService : ISeaExportService
return await Task.FromResult(DataResult<string>.Failed("未传入正确参数!"));
}
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var userKey = db.Queryable<SysConfig>().Where(x => x.Code == "seae_billtraceurl_userKey").First().Value;
var userPwd = db.Queryable<SysConfig>().Where(x => x.Code == "seae_billtraceurl_userPwd").First().Value;
var userId = db.Queryable<SysConfig>().Where(x => x.Code == "seae_billtraceurl_userId").First().Value;
var reqUrl = db.Queryable<SysConfig>().Where(x => x.Code == "request_seae_billtraceurl").First().Value;
var resUrl = db.Queryable<SysConfig>().Where(x => x.Code == "response_seae_billtraceurl").First().Value;
var userKey = db.Queryable<SysConfig>().Filter(null,true).Where(x => x.Code == "seae_billtraceurl_userKey" && x.TenantId == 1288018625843826688).First().Value;
var userPwd = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "seae_billtraceurl_userPwd" && x.TenantId == 1288018625843826688).First().Value;
var userId = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "seae_billtraceurl_userId" && x.TenantId == 1288018625843826688).First().Value;
var reqUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "request_seae_billtraceurl" && x.TenantId == 1288018625843826688).First().Value;
var resUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "response_seae_billtraceurl" && x.TenantId == 1288018625843826688).First().Value;
BillTraceMain billdto = new BillTraceMain();
List<BillTraceReq> billTraceList = new List<BillTraceReq>();
@ -760,11 +771,11 @@ public class SeaExportService : ISeaExportService
return await Task.FromResult(DataResult<string>.Failed("未传入正确参数!"));
}
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var userKey = db.Queryable<SysConfig>().Where(x => x.Code == "seae_billtraceurl_userKey").First().Value;
var userPwd = db.Queryable<SysConfig>().Where(x => x.Code == "seae_billtraceurl_userPwd").First().Value;
var userId = db.Queryable<SysConfig>().Where(x => x.Code == "seae_billtraceurl_userId").First().Value;
var reqUrl = db.Queryable<SysConfig>().Where(x => x.Code == "request_seae_billtraceurl").First().Value;
var resUrl = db.Queryable<SysConfig>().Where(x => x.Code == "response_seae_billtraceurl").First().Value;
var userKey = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "seae_billtraceurl_userKey" && x.TenantId == 1288018625843826688).First().Value;
var userPwd = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "seae_billtraceurl_userPwd" && x.TenantId == 1288018625843826688).First().Value;
var userId = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "seae_billtraceurl_userId" && x.TenantId == 1288018625843826688).First().Value;
var reqUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "request_seae_billtraceurl" && x.TenantId == 1288018625843826688).First().Value;
var resUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "response_seae_billtraceurl" && x.TenantId == 1288018625843826688).First().Value;
BillTraceUnsubscribeDto reqDto = new BillTraceUnsubscribeDto()
{
@ -810,4 +821,497 @@ public class SeaExportService : ISeaExportService
}
}
#endregion
#region VGM及VMG链接
/// <summary>
/// 获取VGM、VGM SI链接
/// </summary>
/// <param name="id">业务Id</param>
/// <returns></returns>
public async Task<DataResult<string[]>> VgmLink(string id)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var bookingId = long.Parse(id);
var order = tenantDb.Queryable<SeaExport>().First(x => x.Id == bookingId);
if (order == null)
{
return await Task.FromResult(DataResult<string[]>.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist));
}
var orderUrl = tenantDb.Queryable<BookingOrderUrl>().First(x => x.BusinessId == bookingId);
if (orderUrl == null)
{
orderUrl = new BookingOrderUrl()
{
BusinessId = bookingId
};
await tenantDb.Insertable(orderUrl).ExecuteCommandAsync();
}
if (!string.IsNullOrEmpty(orderUrl.UrlVgm))
{
return await Task.FromResult(DataResult<string[]>.Success(new string[] { orderUrl.UrlVgm, orderUrl.UrlVgmSi }));
}
//校验船公司
if (string.IsNullOrEmpty(order.Carrier))
{
return await Task.FromResult(DataResult<string[]>.Failed("船公司未正确填写!"));
}
var ctns = tenantDb.Queryable<OpCtn>().Where(x => x.BSNO == id).ToList();
//判断船公司是否支持
var allowCarrier = db.Queryable<SysDictData>().Where(x => x.TypeId == 1790194688729419776).Select(x => x.Value).ToList();
if (!allowCarrier.Contains(order.Carrier))
return await Task.FromResult(DataResult<string[]>.Failed("不支持的船公司"));
//船公司网站账号
var webacc = tenantDb.Queryable<CodeThirdParty>().Where(x => x.CustomerId == order.CarrierId && x.AccountType == "VgmSet").First(); ;
if (webacc == null)
return await Task.FromResult(DataResult<string[]>.Failed("船公司网站账号未配置"));
//场站转换
var yardset = tenantDb.Queryable<MappingYard>().Where(x => x.Status == StatusEnum.Enable && x.Module == "BookingVgm" && x.LinkId == order.YardId).First();
if (yardset == null)
{
return await Task.FromResult(DataResult<string[]>.Failed(String.Format("场站EDI配置未找到{0}", $"{order.Yard}(VGM)")));
}
//校验箱子数据录入
if (ctns.Where(c => string.IsNullOrEmpty(c.CtnAll) || !c.CtnNum.HasValue).Count() > 0)
{
return await Task.FromResult(DataResult<string[]>.Failed("所有箱型箱量必须录入完整!"));
}
//箱型映射
var ctnMapping = tenantDb.Queryable<MappingCtn>().Where(x => x.Module == "BookingVgm").ToList();
//if (ctnMapping.Count == 0)
//{
// throw Oops.Bah(BookingErrorCode.BOOK122);
//}
var expCode = ctns.Select(x => x.CtnCode).Distinct().Except(ctnMapping.Select(y => y.Code)).ToList();
if (expCode.Count > 0)
{
return await Task.FromResult(DataResult<string[]>.Failed(String.Format("箱型EDI配置未找到{0}", $"{string.Join(',', expCode)}(VGM)")));
}
//接收反馈地址
var dicUrlVgmResp = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "vgm_si_post_reponse" && x.TenantId == 1288018625843826688).First();
var dicUrlSiResp = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "si_post_response" && x.TenantId == 1288018625843826688).First();
var userInfo = await db.Queryable<SysUser>().Filter(null, true).FirstAsync(x => x.Id == long.Parse(user.UserId));
var tenant = db.Queryable<SysTenant>().Filter(null, true).First(x => x.Id == long.Parse(user.TenantId));
//调用vgm链接服务
var postUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "vgm_link_service" && x.TenantId == 1288018625843826688).First().Value;
var postObj = new
{
SystemCode = "djy_hechuan",
billOrderId = order.Id.ToString(),
sendOrderCode = order.MBLNO,
customerName = $"{tenant.Name}+{userInfo.UserName}", //公司名称+用户姓名
customerId = order.CustomerId.ToString(),
agentName = string.IsNullOrEmpty(order.Forwarder) ? tenant.Name : order.Forwarder,
carrierCode = order.Carrier,
userName = webacc.AppKey,
userPassword = webacc.AppSecret,
depotCode = yardset.MapCode,
depotName = yardset.MapName,
linkName = userInfo.UserName,
linkMobile = userInfo.Phone,
linkEmail = userInfo.Email,
userId = userInfo.DjyUserId,
signatory = userInfo.NickName,
returnUrl = dicUrlVgmResp?.Value,
shipName = order.Vessel,
voyNo = order.Voyno,
etdstr = order.ETD.HasValue ? order.ETD.Value.ToString("yyyy-MM-dd") : string.Empty,
potrSend = order.LoadPort,
potrGoal = order.DischargePort,
boxinfoStr = order.CntrTotal.Replace("'", ""),
vgmEndTimeStr = order.CloseVgmDate.HasValue ? order.CloseVgmDate.Value.ToString("yyyy-MM-dd") : string.Empty,
returnOkUrl = "",
SiReturnUrl = dicUrlSiResp?.Value,
DataInfoJson = new
{
order.Shipper,
order.Consignee,
order.NotifyParty,
order.Marks,
order.Description,
order.MBLFrt,
order.Service,
order.IssueType,
order.Transport,
order.TransportCode,
order.Destination,
order.DestinationId,
order.KindPkgs,
order.ThirdPayAt,
order.LoadPort,
order.LoadPortId,
order.DischargePort,
order.DischargePortId
}
};
string strPostObj = postObj.ToJsonString();
_logger.Info($"调用VGM链接接口 {postUrl} 传递数据:{strPostObj}");
var result = RequestHelper.Post(strPostObj, postUrl);
_logger.Info($"调用VGM链接接口返回{result}");
var jobjResp = JObject.Parse(result);
int respCode = jobjResp.GetIntValue("code");
if (respCode != 200)
{
return await Task.FromResult(DataResult<string[]>.Failed(jobjResp.GetStringValue("message")));
}
//保存url
var memoData = jobjResp.GetJObjectValue("memoData");
orderUrl.UrlVgm = memoData.GetStringValue("vgmUrl");
orderUrl.UrlVgmSi = memoData.GetStringValue("vgmAndSiUrl");
await tenantDb.Updateable(orderUrl).ExecuteCommandAsync();
//货运动态
var bookingStatus = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"生成VGM链接",
Group = "ship",
OpTime = DateTime.Now,
MBLNO = order.MBLNO
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
return await Task.FromResult(DataResult<string[]>.Success(new string[]{ orderUrl.UrlVgm, orderUrl.UrlVgmSi }));
}
/// <summary>
/// 发送VGM
/// </summary>
/// <param name="id">业务Id</param>
/// <returns></returns>
public async Task<DataResult<string>> VgmSend(string id) {
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var bookingId = long.Parse(id);
var order = tenantDb.Queryable<SeaExport>().First(x => x.Id == bookingId);
var ctns = tenantDb.Queryable<OpCtn>().Where(x => x. BSNO == id).ToList();
//船公司
if (order.CarrierId == 0 || order.CarrierId.ToString().IsNull())
return await Task.FromResult(DataResult<string>.Failed("船公司未正确填写!"));
//提单号不能为空
if (string.IsNullOrEmpty(order.MBLNO))
return await Task.FromResult(DataResult<string>.Failed("主提单号不能为空!"));
var config = db.Queryable<SysConfig>().Where(x => x.Code == "VgmDirectSendCarrierCode").First();
if (config == null)
return await Task.FromResult(DataResult<string>.Failed("请配置租户的VGM直发船司参数!"));
var arrCarr = config.Value.Split(",", StringSplitOptions.RemoveEmptyEntries);
if (!arrCarr.Contains(order.Carrier)) //使用大简云发送vgm
{
//ETD不能为空
if (!order.ETD.HasValue)
return await Task.FromResult(DataResult<string>.Failed("ETD不能为空!"));
//重量不能为空
if (!order.KGS.HasValue)
return await Task.FromResult(DataResult<string>.Failed("重量不能为空!"));
var urlConfig = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "DjyVgmApiMyshppingUrl" && x.TenantId == 1288018625843826688).First().Value;
var userKey = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "DjyVgmApiMyshppingUserKey" && x.TenantId == 1288018625843826688).First().Value;
var userPwd = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "DjyVgmApiMyshppingUserPwd" && x.TenantId == 1288018625843826688).First().Value;
if (userKey.IsNull() || userPwd.IsNull())
return await Task.FromResult(DataResult<string>.Failed("请在网站账号中维护VGM接口的用户id和秘钥!"));
var objMdata = new
{
MBLNO = order.MBLNO,
CARRIER = order.Carrier,
ChuanMing = order.Vessel,
HangCi = order.VoucherNo,
ETD = order.ETD.Value.ToString("yyyy-MM-dd HH:mm:ss"),
ZongZhongLiang = order.KGS.ToString(),
BeiZhu = "",
ORDERNO = order.CustomerNo,
VGMCLOSETIME = order.CloseVgmDate.HasValue ? order.CloseVgmDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
};
var listCtn = new List<dynamic>();
foreach (var ctn in ctns)
{
if (string.IsNullOrEmpty(ctn.CtnAll)
|| string.IsNullOrEmpty(ctn.CntrNo)
|| string.IsNullOrEmpty(ctn.SealNo)
|| !ctn.WeightKGS.HasValue
|| string.IsNullOrEmpty(ctn.WeightDate))
{
return await Task.FromResult(DataResult<string>.Failed("所有箱子的箱型、箱号、封号、称重重量和称重时间都不能为空!"));
}
listCtn.Add(new
{
ChengZhongZhongLiang = ctn.WeightKGS.Value.ToString(),
ChengZhongShiJian = ctn.WeightDate,
CTNALL = ctn.CtnAll.Replace("'", ""),
CNTRNO = ctn.CntrNo,
SEALNO = ctn.SealNo
});
}
var dictParam = new Dictionary<string, string> {
{ "ac", "vgm" },
{ "uid", userKey },
{ "skey", userPwd },
{ "optype", "9"},
{ "mdata", JsonConvert.SerializeObject(objMdata)},
{ "ctndata", JsonConvert.SerializeObject(listCtn)}
};
_logger.Info($"调用vgm发送接口{ urlConfig },参数:{JsonConvert.SerializeObject(dictParam)}");
var result = RequestHelper.Post(JsonConvert.SerializeObject(dictParam), urlConfig);
_logger.Info($"调用vgm发送接口{ urlConfig },返回:{result}");
var jobjRtn = JObject.Parse(result);
if (jobjRtn.GetBooleanValue("Success"))
{
//货运动态
var bookingStatus = new BookingStatusLog() {
BusinessId = bookingId,
Status = $"发送VGM",
Group = "ship",
MBLNO = order.MBLNO
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
}
else
{
return await Task.FromResult(DataResult<string>.Failed(jobjRtn.GetStringValue("Message")));
}
}
else //直接调用vgm接口直发
{
//判断船公司是否支持
var allowCarrier = db.Queryable<SysDictData>().Where(x => x.TypeId == 1790194688729419776).Select(x => x.Value).ToList();
if (!allowCarrier.Contains(order.Carrier))
return await Task.FromResult(DataResult<string>.Failed("不支持的船公司"));
////船公司网站账号
//var carrWebAccMap = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "carrier_web_account_mapping" && x.Code == order.Carrier);
//if (carrWebAccMap == null)
// return await Task.FromResult(DataResult<string>.Failed("不支持的船公司或账号映射未配置"));
var webacc = tenantDb.Queryable<CodeThirdParty>().Where(x => x.CustomerId == order.CarrierId && x.AccountType == "VgmSet").First(); ;
if (webacc == null)
return await Task.FromResult(DataResult<string>.Failed("船公司网站账号未配置"));
#region 箱信息校验2022-7-1修改【累加】的必须有重量、皮重和称重重量【总重】的只需要称重重量不为空
if (ctns.Where(c => c.WeightType== "累加" &&
(
string.IsNullOrEmpty(c.CntrNo)
|| !c.WeightKGS.HasValue
|| c.WeightKGS == 0
|| !c.TareWeight.HasValue
|| c.TareWeight == 0
|| !c.KGS.HasValue
|| c.KGS == 0)
).Count() > 0)
{
return await Task.FromResult(DataResult<string>.Failed("称重方式为累加时,箱号、重量、箱皮重以及称重重量都不能为空"));
}
if (ctns.Where(c => c.WeightType == "总重" &&
(
string.IsNullOrEmpty(c.CntrNo)
|| !c.WeightKGS.HasValue
|| c.WeightKGS == 0)
).Count() > 0)
{
return await Task.FromResult(DataResult<string>.Failed("称重方式为总重时,箱号和称重重量都不能为空"));
}
#endregion
if (string.IsNullOrEmpty(order.Yard) || string.IsNullOrEmpty(order.YardId.ToString()))
return await Task.FromResult(DataResult<string>.Failed("场站未正确选择!"));
// 场站映射
string mappingYard, mappingYardId;
var yardMapList = tenantDb.Queryable<MappingYard>().Where(x => x.Status == StatusEnum.Enable && x.Module == "BookingVgm" && x.LinkId == order.YardId && (x.CarrierId == 0 || x.CarrierId == order.CarrierId))?.ToList();
if (yardMapList?.Any() == true)
{
var yardset = yardMapList.FirstOrDefault(x => x.CarrierId == order.CarrierId)
?? yardMapList.FirstOrDefault(x => x.CarrierId == 0 || x.CarrierId.ToString() == "");
mappingYard = yardset.MapName;
mappingYardId = yardset.MapCode;
}
else
{
var yard = tenantDb.Queryable<InfoClient>().First(x => x.Id == order.YardId);
mappingYard = yard.ShortName;
mappingYardId = yard.CodeName;
}
// 船司映射
var carrMap = tenantDb.Queryable<MappingCarrier>().Where(x => x.Status == StatusEnum.Enable && x.Module == "BookingVgm" && x.LinkId == order.CarrierId).First();
string mappingCarrierCode = carrMap != null ? carrMap.MapCode : order.Carrier;
var userInfo = await db.Queryable<SysUser>().Filter(null,true).FirstAsync(x => x.Id == long.Parse(user.UserId));
var tenant = db.Queryable<SysTenant>().Filter(null,true).First(x=>x.Id == long.Parse(user.TenantId));
int idx = 1;
//调用接口
var postUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "vgm_service_single" && x.TenantId == 1288018625843826688).First().Value;
//var dicUrl = _cache.GetAllDictData().Result.First(x => x.TypeCode == "url_set" && x.Code == "vgm_service_single");
var sendObj = new
{
SystemCode = "djy_hechuan",
billOrderId = order.Id.ToString(),
sendOrderCode = order.MBLNO,
customerName = $"{tenant.Name}+{ userInfo.UserName }", //公司名称+用户姓名
customerId = order.CustomerId.ToString(),
agentName = string.IsNullOrEmpty(order.Forwarder) ? tenant.Name : order.Forwarder,
carrierCode = mappingCarrierCode,
userName = webacc.AppKey,
userPassword = webacc.AppSecret,
depotCode = mappingYardId,
depotName = mappingYard,
linkName = userInfo.UserName,
linkMobile = userInfo.Phone,
linkEmail = userInfo.Email,
userId = userInfo.DjyUserId,
signatory = userInfo.NickName, //2023年8月28日董怡含把用户昵称当做vgm上传人
returnUrl = "",
shipName = order.Vessel,
voyNo = order.Voyno,
etdstr = order.ETD.HasValue ? order.ETD.Value.ToString("yyyy-MM-dd") : string.Empty,
potrSend = order.LoadPort,
potrGoal = order.DischargePort,
boxinfoStr = order.CntrTotal.Replace("'", ""),
vgmEndTimeStr = order.CloseVgmDate.HasValue ? order.CloseVgmDate.Value.ToString("yyyy-MM-dd") : string.Empty,
BoxInfo = ctns.Select(c => new
{
index = idx++,
boxType = c.CtnAll.Replace("'", ""),
boxcount = c.CtnNum.HasValue ? c.CtnNum.Value : 0,
code = c.CntrNo,
sealCode = c.SealNo,
weigth = c.KGS,
weigthTare = c.TareWeight,
weigthTotal = c.WeightKGS,
weigthType = c.WeightType == "累加" ? "SM2" : "SM1"
}).ToList(),
returnOkUrl = ""
};
string strPostObj = sendObj.ToJsonString();
_logger.Info($"调用VGM直发接口 {postUrl} 传递数据:{strPostObj}");
var result = RequestHelper.Post(strPostObj, postUrl);
_logger.Info($"调用VGM直发接口返回{result}");
var jobjResp = JObject.Parse(result);
int respCode = jobjResp.GetIntValue("code");
if (respCode != 200)
{
return await Task.FromResult(DataResult<string>.Failed(jobjResp.GetStringValue("message")));
}
//货运动态
var bookingStatus = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"直发VGM",
Group = "ship",
OpTime = DateTime.Now,
MBLNO = order.MBLNO
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
}
////设置货物状态已发VGM并回传东胜
await seaComService.SetGoodsStatus("YFVGM", bookingId);
//await SendBookingOrder(new long[] { bookingId });
return await Task.FromResult(DataResult<string>.Success("Vgm发送成功!"));
}
/// <summary>
/// 批量获取vgm
/// </summary>
/// <param name="ids">业务id 逗号拼接</param>
/// <returns></returns>
public async Task<DataResult<List<BatchVGM>>> GetVmgDataList(string ids)
{
var arr = ids.Split(',');
if (arr.Length == 0)
{
return await Task.FromResult(DataResult<List<BatchVGM>>.Failed("请传入正确数据!"));
}
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var main = await tenantDb.Queryable<SeaExport>().Where(x => x.ParentId == 0).ToListAsync();
List<BatchVGM> batchVGMs = new List<BatchVGM>();
foreach (var item in arr)
{
BatchVGM batchVGM = new BatchVGM();
batchVGM.Id = Convert.ToInt64(item);
batchVGM.MBLNO = main.Where(x => x.Id == batchVGM.Id).Select(x => x.MBLNO).FirstOrDefault();
batchVGM.ctnlist = await tenantDb.Queryable<OpCtn>().Where(x => x.BSNO == item).Select(x => new BatchVGMList
{
Id = x.Id,
CtnCode = x.CtnCode,
CtnAll = x.CtnAll,
CntrNo = x.CntrNo,
KGS = x.KGS,
TareWeight = x.TareWeight,
WeightType = x.WeightType,
WeightKGS = x.WeightKGS
}).ToListAsync();
batchVGMs.Add(batchVGM);
}
return await Task.FromResult(DataResult<List<BatchVGM>>.Success(batchVGMs));
}
/// <summary>
/// 批量保存vgm
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<DataResult<string>> SaveBatchVgm(List<BatchVGMList> dto)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (dto == null)
{
return await Task.FromResult(DataResult<string>.Failed("未提交数据!"));
}
foreach (var item in dto)
{
var dic = item.GetPropertiesArray();
var info = tenantDb.Queryable<OpCtn>().Where(x=>x.Id == item.Id).First();
info = item.Adapt(info);
tenantDb.Updateable(info).UpdateColumns(dic).ExecuteCommand();
}
return await Task.FromResult(DataResult<string>.Success("更新成功!", MultiLanguageConst.DataUpdateSuccess));
}
#endregion
}

@ -87,6 +87,13 @@ public class SysUser : UserTenantModel<long>
[Description("职位")]
public string Duty { get; set; }
/// <summary>
/// 大简云用户id
/// </summary>
[Description("大简云用户id")]
public string DjyUserId { get; set; }
/// <summary>
/// 用户类型 0-超管 1-管理员 2-普通用户 3- 租户申请
/// </summary>

@ -563,8 +563,8 @@ public class ClientCommonService : IClientCommonService
public DataResult<List<IssueTypeSelectRes>> GetIssueTypeSelectList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<InfoClient>()
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt())
var data = tenantDb.Queryable<CodeIssueType>()
.Where(a => a.Status == StatusEnum.Enable)
.Select<IssueTypeSelectRes>().ToList();
return DataResult<List<IssueTypeSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}

@ -0,0 +1,92 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Interface;
using DS.WMS.Core.Map.Dtos;
using DS.WMS.Core.Map.Interface;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.MainApi.Controllers
{
/// <summary>
/// 箱型映射信息 模块
/// </summary>
public class MappingCarrierController : ApiController
{
private readonly IMappingCarrierService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public MappingCarrierController(IMappingCarrierService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetMappingCarrierList")]
public DataResult<List<MappingCarrierRes>> GetMappingCarrierList([FromBody] PageRequest request)
{
var res = _invokeService.GetListByPage(request);
return res;
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("EditMappingCarrier")]
public DataResult EditMappingCarrier([FromBody] MappingCarrierReq req)
{
var res = _invokeService.EditMappingCarrier(req);
return res;
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id">Id</param>
/// <returns></returns>
[HttpGet]
[Route("GetMappingCarrierInfo")]
public DataResult<MappingCarrierRes> GetMappingCarrierInfo([FromQuery] string id)
{
var res = _invokeService.GetMappingCarrierInfo(id);
return res;
}
/// <summary>
/// 删除
/// </summary>
/// <param name="req">Id</param>
/// <returns></returns>
[HttpPost]
[Route("DelMappingCarrier")]
public DataResult DelMappingCarrier([FromBody] IdModel req)
{
var res = _invokeService.DelMappingCarrier(req);
return res;
}
/// <summary>
///批量删除
/// </summary>
/// <param name="req">Id</param>
/// <returns></returns>
[HttpPost]
[Route("BatchDelMappingCarrier")]
public DataResult BatchDelMappingCarrier([FromBody] IdModel req)
{
var res = _invokeService.BatchDelMappingCarrier(req);
return res;
}
}
}

@ -1300,3 +1300,10 @@
2024-05-09 16:03:34.6576 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-05-09 16:03:34.6817 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-05-09 16:03:34.7177 Info Configuration initialized.
2024-05-14 10:58:40.4048 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-05-14 10:58:40.4531 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-05-14 10:58:40.4630 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-05-14 10:58:40.4950 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-05-14 10:58:40.5159 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-05-14 10:58:40.5233 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-05-14 10:58:40.5233 Info Configuration initialized.

@ -142,4 +142,50 @@ public class SeaExportController : ApiController
}
/// <summary>
/// 获取VGM、VGM SI链接
/// </summary>
/// <param name="id">业务Id</param>
/// <returns></returns>
[HttpGet]
[Route("VgmLink")]
public async Task<DataResult<string[]>> VgmLink([FromQuery] string id)
{
return await _invokeService.VgmLink(id);
}
/// <summary>
/// 发送VGM
/// </summary>
/// <param name="id">业务Id</param>
/// <returns></returns>
[HttpGet]
[Route("VgmSend")]
public async Task<DataResult<string>> VgmSend([FromQuery] string id)
{
return await _invokeService.VgmSend(id);
}
/// <summary>
/// 批量获取vgm
/// </summary>
/// <param name="ids">业务id 逗号拼接</param>
/// <returns></returns>
[HttpGet]
[Route("GetVmgDataList")]
public async Task<DataResult<List<BatchVGM>>> GetVmgDataList([FromQuery] string ids)
{
return await _invokeService.GetVmgDataList(ids);
}
/// <summary>
/// 批量保存vgm
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("SaveBatchVgm")]
public async Task<DataResult<string>> SaveBatchVgm([FromBody] List<BatchVGMList> req)
{
return await _invokeService.SaveBatchVgm(req);
}
}
Loading…
Cancel
Save