All checks were successful
Build and Deploy / deploy (push) Successful in 1m1s
新增 warehouseOpenApi(Token/入库/件重尺/红外图),并在 fk_user 支持 IsEnabled 禁用登录。 Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
using Fake.Application;
|
||
|
||
namespace Oms.Application.Shared;
|
||
|
||
/// <summary>
|
||
/// 开放接口件重尺单位换算为系统内部单位(kg / cm)。
|
||
/// </summary>
|
||
public static class OpenApiMeasureUnitConverter
|
||
{
|
||
public static decimal ToKilograms(decimal weight, string? weightUnit)
|
||
{
|
||
var unit = string.IsNullOrWhiteSpace(weightUnit) ? "KG" : weightUnit.Trim().ToUpperInvariant();
|
||
return unit switch
|
||
{
|
||
"KG" or "KGS" or "KILOGRAM" or "KILOGRAMS" => weight,
|
||
"G" or "GRAM" or "GRAMS" => weight / 1000m,
|
||
"LB" or "LBS" or "POUND" or "POUNDS" => weight * 0.45359237m,
|
||
_ => throw new BusinessException($"不支持的重量单位:{weightUnit}")
|
||
};
|
||
}
|
||
|
||
public static decimal ToCentimeters(decimal length, string? lengthUnit)
|
||
{
|
||
var unit = string.IsNullOrWhiteSpace(lengthUnit) ? "CM" : lengthUnit.Trim().ToUpperInvariant();
|
||
return unit switch
|
||
{
|
||
"CM" or "CMS" or "CENTIMETER" or "CENTIMETERS" => length,
|
||
"MM" or "MILLIMETER" or "MILLIMETERS" => length / 10m,
|
||
"M" or "METER" or "METERS" => length * 100m,
|
||
"IN" or "INCH" or "INCHES" => length * 2.54m,
|
||
_ => throw new BusinessException($"不支持的长度单位:{lengthUnit}")
|
||
};
|
||
}
|
||
}
|