根据单位获取数量箱型信息

usertest
ZR20090193-陈敬勇 5 months ago
parent b622628758
commit 502363e759

@ -0,0 +1,74 @@
using DS.WMS.Core.Info.Dtos;
using DS.WMS.Core.Op.Entity;
using FluentValidation;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Sys.Dtos
{
/// <summary>
/// 根据单位代码获取数量及其他信息请求实体
/// </summary>
public class UnitSelectInfoReq
{
/// <summary>
/// 业务类型 1 海运出口 2 海运进口
/// </summary>
public BusinessType BusinessType { get; set; }
/// <summary>
/// 业务Id
/// </summary>
public long BusinessId { get; set; }
/// <summary>
/// Desc:单位代码
/// </summary>
public string Code { get; set; }
}
/// <summary>
/// 验证
/// </summary>
public class UnitSelectInfoReqReqValidator : AbstractValidator<UnitSelectInfoReq>
{
/// <summary>
/// 构造函数
/// </summary>
public UnitSelectInfoReqReqValidator()
{
this.RuleFor(o => o.Code)
.NotEmpty().WithName("单位代码");
this.RuleFor(o => o.BusinessId)
.NotEmpty().WithName("业务Id");
this.RuleFor(o => o.BusinessType)
.NotEmpty().WithName("业务类型");
}
}
/// <summary>
/// 根据单位代码获取数量及其他信息返回实体
/// </summary>
public class UnitSelectInfoRes
{
/// <summary>
/// Desc:单位代码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 数量
/// </summary>
public decimal? Quantity { get; set; }
/// <summary>
/// TEU
/// </summary>
public int TEU { get; set; }
/// <summary>
/// 自然箱 所有箱型的合计数
/// </summary>
public int? CtnTotalNum { get; set; }
}
}

@ -13,7 +13,12 @@ namespace DS.WMS.Core.Sys.Interface;
///
/// </summary>
public interface IClientCommonService
{
{
/// <summary>
/// 根据单位获取数量箱型信息
/// </summary>
/// <returns></returns>
public DataResult<UnitSelectInfoRes> GetUnitSelectInfo(UnitSelectInfoReq req);
/// <summary>
/// 根据类型获取往来单位下拉及业务信息列表
/// </summary>

@ -18,6 +18,7 @@ using DS.WMS.Core.Sys.Interface;
using Mapster;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.Extensions.DependencyInjection;
using NPOI.POIFS.Crypt.Dsig;
using SqlSugar;
using System.Collections.Generic;
using static System.Runtime.InteropServices.JavaScript.JSType;
@ -42,7 +43,95 @@ public class ClientCommonService : IClientCommonService
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
#region 根据单位获取数量箱型信息
/// <summary>
/// 根据单位获取数量箱型信息
/// </summary>
/// <returns></returns>
public DataResult<UnitSelectInfoRes> GetUnitSelectInfo(UnitSelectInfoReq req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//var data = new ClientSelectInfoRes();
if (req.BusinessType == BusinessType.OceanShippingExport)
{
var info = tenantDb.Queryable<SeaExport>().First(x => x.Id == req.BusinessId);
if (info.IsNull())
{
return DataResult<UnitSelectInfoRes>.Failed("业务信息不存在!");
}
var ctns = tenantDb.Queryable<OpCtn>().Where(x => x.BSNO == req.BusinessId.ToString()).ToList();
var dictvalue = db.Queryable<SysDictData>().InnerJoin<SysDictType>((a, b) => a.TypeId == b.Id)
.Where((a, b) => b.Code == "fee_unit").Select((a, b) => a.Value).ToList();
if (dictvalue.Where(x=>x ==req.Code).Any())
{
var data = GetSeaExportUnit(info, req.Code);
return DataResult<UnitSelectInfoRes>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
else
{
var codeCtns = tenantDb.Queryable<CodeCtn>().Where(x => x.Status == StatusEnum.Enable).ToList();
if (codeCtns.Where(x => x.CtnName == req.Code).Any())
{
//var data = GetSeaExportCtnsUnit(ctns, codeCtns, req.Code);
var codeCtn = codeCtns.First(x => x.CtnName == req.Code);
var ctns1 = ctns.Where(x => x.Ctn == req.Code).ToList();
var data = new UnitSelectInfoRes();
data.Code = req.Code;
data.Quantity = ctns1.Sum(x => x.CtnNum);
data.TEU = (int)data.Quantity * (int)codeCtn.TEU;
data.CtnTotalNum = ctns.Sum(x => x.CtnNum);
return DataResult<UnitSelectInfoRes>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
else
{
return DataResult<UnitSelectInfoRes>.Failed("没有维护该箱型的集装箱信息!");
}
}
}
else
{
return DataResult<UnitSelectInfoRes>.Failed("非法业务类型");
}
}
private UnitSelectInfoRes GetSeaExportUnit(SeaExport seaExport, string code)
{
var data = new UnitSelectInfoRes();
data.Code = code;
switch (code)
{
case "P"://单票
data.Quantity = 1;
break;
case "Z"://重量
data.Quantity = seaExport.KGS;
break;
case "C"://尺码
data.Quantity = seaExport.CBM;
break;
case "J"://件数
data.Quantity = seaExport.PKGS;
break;
case "JF"://计费吨
data.Quantity = seaExport.KGS/1000> seaExport.CBM? seaExport.KGS/1000: seaExport.CBM;
break;
//默认
default:
data.Quantity = 0;
break;
}
return data;
}
#endregion
#region 根据类型获取往来单位下拉及业务信息列表
/// <summary>
/// 根据类型获取往来单位下拉及业务信息列表

@ -27,7 +27,18 @@ public class ClientCommonController : ApiController
public ClientCommonController(IClientCommonService invokeService)
{
_invokeService = invokeService;
}
}
/// <summary>
/// 根据单位获取数量箱型信息
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("GetUnitSelectInfo")]
public DataResult<UnitSelectInfoRes> GetUnitSelectInfo([FromBody] UnitSelectInfoReq req)
{
var res = _invokeService.GetUnitSelectInfo(req);
return res;
}
/// <summary>
/// 根据类型获取往来单位下拉及业务信息列表
/// </summary>

Loading…
Cancel
Save