Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -9,10 +9,13 @@ namespace Tnb.BasicData.Entities
|
||||
[SugarTable("bas_mbom_output")]
|
||||
public class BasMbomOutput : BaseEntity<string>
|
||||
{
|
||||
public BasMbomOutput()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 工单Id
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string mo_id { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:生产bomid
|
||||
/// Default:
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace Tnb.ProductionMgr.Entities.Dto
|
||||
/// </summary>
|
||||
public string mold_type_code { get; set; }
|
||||
/// <summary>
|
||||
/// 型腔数
|
||||
/// 可用台数
|
||||
/// </summary>
|
||||
public int? cavity_qty { get; set; }
|
||||
public int available_stations { get; set; }
|
||||
public string mold_id { get; set;}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
/// <summary>
|
||||
/// 组装、包装排产输入参数
|
||||
/// </summary>
|
||||
public class PackSchedlingCrInput
|
||||
{
|
||||
/// <summary>
|
||||
/// bom任务集合
|
||||
/// </summary>
|
||||
public List<PackSchedlingItem> items{ get; set; }
|
||||
}
|
||||
|
||||
public class PackSchedlingItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 工单Id
|
||||
/// </summary>
|
||||
public string mo_id { get; set; }
|
||||
/// <summary>
|
||||
/// 生产bomId
|
||||
/// </summary>
|
||||
public string bom_id { get; set; }
|
||||
/// <summary>
|
||||
/// 工序id
|
||||
/// </summary>
|
||||
public string process_id { get; set; }
|
||||
/// <summary>
|
||||
/// 产线Id
|
||||
/// </summary>
|
||||
public string workline_id { get; set; }
|
||||
/// <summary>
|
||||
/// 物料Id
|
||||
/// </summary>
|
||||
public string material_id { get; set; }
|
||||
/// <summary>
|
||||
/// 生产任务单号
|
||||
/// </summary>
|
||||
public string mo_task_code { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string material_code { get; set; }
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string material_name { get; set; }
|
||||
/// <summary>
|
||||
/// bom产出料数量
|
||||
/// </summary>
|
||||
public string qty { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,14 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// </summary>
|
||||
public class PackingSchedulingListOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 工单Id
|
||||
/// </summary>
|
||||
public string mo_id { get; set; }
|
||||
/// <summary>
|
||||
/// 工序Id
|
||||
/// </summary>
|
||||
public string process_id { get; set; }
|
||||
/// <summary>
|
||||
/// 产线Id
|
||||
/// </summary>
|
||||
@@ -24,6 +32,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// </summary>
|
||||
public string mo_task_code { get; set; }
|
||||
/// <summary>
|
||||
/// 物料Id
|
||||
/// </summary>
|
||||
public string material_id { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string material_code { get; set; }
|
||||
@@ -32,6 +44,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// </summary>
|
||||
public string material_name { get; set; }
|
||||
/// <summary>
|
||||
/// 工序名称
|
||||
/// </summary>
|
||||
public string process_name { get; set; }
|
||||
/// <summary>
|
||||
/// 产出数量
|
||||
/// </summary>
|
||||
public string qty { get; set; }
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
/// <summary>
|
||||
/// 拆解组装包装排产输入参数
|
||||
/// </summary>
|
||||
public class UnPackSchedlingInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 工单Id
|
||||
/// </summary>
|
||||
public string mo_id { get; set; }
|
||||
/// <summary>
|
||||
/// 生产任务Id
|
||||
/// </summary>
|
||||
public string mo_task_id { get; set; }
|
||||
/// <summary>
|
||||
/// 生产bom Id
|
||||
/// </summary>
|
||||
public string bom_id { get; set; }
|
||||
/// <summary>
|
||||
/// 产线Id
|
||||
/// </summary>
|
||||
public string workline_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:预计开始时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? estimated_start_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:预计结束时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? estimated_end_date { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -177,6 +177,10 @@ namespace Tnb.ProductionMgr.Entities
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string modify_id { get; set; }
|
||||
/// <summary>
|
||||
/// 模具型号
|
||||
/// </summary>
|
||||
public string mold_type_code { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ using Aop.Api.Domain;
|
||||
using Senparc.Weixin.MP.AdvancedAPIs.Card;
|
||||
using Aspose.Cells.Drawing.Texts;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using WebSocketSharp.Frame;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
@@ -50,6 +51,7 @@ namespace Tnb.ProductionMgr
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private static Dictionary<string, object> _dicDefect = new Dictionary<string, object>();
|
||||
private static Dictionary<string, object> _dicWorkLine = new Dictionary<string, object>();
|
||||
private static Dictionary<string, object> _dicProcess = new Dictionary<string, object>();
|
||||
private readonly ISqlSugarClient _db;
|
||||
|
||||
|
||||
@@ -108,8 +110,10 @@ namespace Tnb.ProductionMgr
|
||||
mold_id = a.id,
|
||||
mold_code = a.mold_code,
|
||||
mold_name = a.mold_name,
|
||||
mold_type_code = a.mold_type_code,
|
||||
material_name = b.name,
|
||||
cavity_qty = a.cavity_qty,
|
||||
material_code = b.code,
|
||||
available_stations = SqlFunc.Subqueryable<EqpEquipment>().Where(it => it.mold_id == a.id).Count(),
|
||||
})
|
||||
.ToListAsync();
|
||||
return list;
|
||||
@@ -429,11 +433,10 @@ namespace Tnb.ProductionMgr
|
||||
var pos = taskCode.IndexOf("-", StringComparison.Ordinal);
|
||||
if (pos > -1)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var num = taskCode.AsSpan().Slice(pos + 1).ToString().ParseToInt();
|
||||
var code = taskCode.AsSpan().Slice(0, pos).ToString();
|
||||
var n = (num + 1).ToString().PadLeft(2, '0');
|
||||
moTask.mo_task_code = sb.Append(code).Append("-").Append(n).ToString();
|
||||
moTask.mo_task_code = $"{code}-{n}";
|
||||
}
|
||||
}
|
||||
try
|
||||
@@ -509,15 +512,28 @@ namespace Tnb.ProductionMgr
|
||||
/// <summary>
|
||||
/// 获取组装包装排产任务列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="input">拆解bom,生成组装包装任务列表,输入参数</param>
|
||||
/// <remarks>
|
||||
/// output:
|
||||
///<br/>{
|
||||
///<br/> workline_id:产线Id
|
||||
///<br/> workline_name:产线名称
|
||||
///<br/> material_code:物料编码
|
||||
///<br/> material_name:物料名称
|
||||
///<br/> qty:输出料数量
|
||||
///<br/>}
|
||||
/// </remarks>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetPackSchedulingTaskList(ProductionSchedulingCrInput input)
|
||||
public async Task<dynamic> GetPackSchedulingTaskList(UnPackSchedlingInput input)
|
||||
{
|
||||
if (_dicWorkLine.Count < 1)
|
||||
{
|
||||
_dicWorkLine = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workline").ToDictionaryAsync(x => x.Id, x => x.FullName);
|
||||
}
|
||||
if (_dicProcess.Count < 1)
|
||||
{
|
||||
_dicProcess = await _db.Queryable<BasProcess>().Select(it => new { id = it.id, process_name = it.process_name }).Distinct().ToDictionaryAsync(x => x.id, x => x.process_name);
|
||||
}
|
||||
var outputList = new List<PackingSchedulingListOutput>();
|
||||
var bom = await _db.Queryable<BasMbom>().FirstAsync(it => it.id == input.bom_id);
|
||||
if (bom != null && bom.route_id.IsNotEmptyOrNull())
|
||||
@@ -535,8 +551,12 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
var material = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == item.material_id);
|
||||
var output = new PackingSchedulingListOutput();
|
||||
output.mo_id = input.mo_id;
|
||||
output.process_id = item.process_id;
|
||||
output.workline_id = input.workline_id;
|
||||
output.workline_name = _dicWorkLine.ContainsKey(input.workline_id) ? _dicWorkLine[input.workline_id].ToString() : "";
|
||||
output.process_name = _dicProcess[item.process_id]?.ToString();
|
||||
output.material_id = item.material_id;
|
||||
output.material_code = material?.code;
|
||||
output.material_name = material?.name;
|
||||
output.qty = item.num;
|
||||
@@ -546,8 +566,97 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
}
|
||||
}
|
||||
//生成任务单号
|
||||
if (outputList.Count > 0)
|
||||
{
|
||||
var mo = await _db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id);
|
||||
if (mo != null && mo.mo_code.IsNotEmptyOrNull())
|
||||
{
|
||||
var taskCodes = outputList.Where(it => it.mo_task_code.IsNotEmptyOrNull()).ToList();
|
||||
if (taskCodes == null || taskCodes.Count < 1)
|
||||
{
|
||||
for (int i = 1, len = outputList.Count; i <= len; i++)
|
||||
{
|
||||
outputList[i - 1].mo_task_code = $"{mo.mo_code}-{i.ToString().PadLeft(2, '0')}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return outputList;
|
||||
}
|
||||
/// <summary>
|
||||
/// 组装包装排产
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PackSchedling(PackSchedlingCrInput input)
|
||||
{
|
||||
if (input.items == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input.items));
|
||||
}
|
||||
DbResult<bool> dbResult = null;
|
||||
if (input.items.Count > 0)
|
||||
{
|
||||
var moTasks = input.items.Select(x => new PrdMoTask
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
mo_task_code = x.mo_task_code,
|
||||
material_id = x.material_id,
|
||||
mo_id = x.mo_id,
|
||||
bom_id = x.bom_id,
|
||||
create_id = _userManager.UserId,
|
||||
scheduled_qty = x.qty.ParseToInt(),
|
||||
create_time = DateTime.Now
|
||||
}).ToList();
|
||||
dbResult = await _db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _db.Insertable(moTasks).ExecuteCommandAsync();
|
||||
List<PrdTaskLog> taskLogList = new();
|
||||
List<PrdMoTaskDefectRecord> taskDefectRecordList = new();
|
||||
|
||||
foreach (var moTask in moTasks)
|
||||
{
|
||||
var material = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == moTask.material_id);
|
||||
var mo = await _db.Queryable<PrdMo>().FirstAsync(it => it.id == moTask.mo_id);
|
||||
var taskLog = new PrdTaskLog();
|
||||
taskLog.id = SnowflakeIdHelper.NextId();
|
||||
taskLog.mo_code = mo?.mo_code;
|
||||
taskLog.eqp_code = (await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == moTask.eqp_id))?.code;
|
||||
taskLog.mold_code = (await _db.Queryable<Molds>().FirstAsync(it => it.id == moTask.mold_id))?.mold_code;
|
||||
taskLog.item_code = material?.code;
|
||||
taskLog.item_standard = material?.material_standard;
|
||||
taskLog.status = DictConst.ToBeScheduledEncode;
|
||||
taskLog.operator_name = _userManager.RealName;
|
||||
taskLog.create_id = _userManager.UserId;
|
||||
taskLog.create_time = DateTime.Now;
|
||||
taskLog.mo_task_id = moTask.id;
|
||||
taskLog.mo_task_code = moTask.mo_task_code;
|
||||
taskLogList.Add(taskLog);
|
||||
//将生产任务插入到自检报废记录表
|
||||
var sacipRecord = new PrdMoTaskDefectRecord();
|
||||
sacipRecord.id = SnowflakeIdHelper.NextId();
|
||||
sacipRecord.material_code = material?.code;
|
||||
sacipRecord.material_name = material?.name;
|
||||
sacipRecord.estimated_start_date = mo?.plan_start_date;
|
||||
sacipRecord.estimated_end_date = mo?.plan_end_date;
|
||||
sacipRecord.plan_qty = moTask.plan_qty;
|
||||
sacipRecord.scrap_qty = moTask.scrap_qty;
|
||||
sacipRecord.status = moTask.mo_task_status;
|
||||
sacipRecord.create_id = _userManager.UserId;
|
||||
sacipRecord.create_time = DateTime.Now;
|
||||
sacipRecord.mo_task_id = moTask.id;
|
||||
sacipRecord.mo_task_code = moTask.mo_task_code;
|
||||
taskDefectRecordList.Add(sacipRecord);
|
||||
}
|
||||
await _db.Insertable(taskLogList).ExecuteCommandAsync();
|
||||
await _db.Insertable(taskDefectRecordList).ExecuteCommandAsync();
|
||||
});
|
||||
}
|
||||
return dbResult!.IsSuccess;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产任务下发,开始 、结束、完成
|
||||
|
||||
@@ -1,29 +1,11 @@
|
||||
using System.Dynamic;
|
||||
using System.Reflection.Emit;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Extensitions.EventBus;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Senparc.Weixin.Work.AdvancedAPIs.MailList;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.BasicData.Entitys.Entity;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
using Tnb.ProductionMgr.Entities.Enums;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
|
||||
namespace Tnb.ProductionMgr;
|
||||
|
||||
350
common/Tnb.Common/DataValidation/Check.cs
Normal file
350
common/Tnb.Common/DataValidation/Check.cs
Normal file
@@ -0,0 +1,350 @@
|
||||
using JetBrains.Annotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Tnb.Common;
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static class Check
|
||||
{
|
||||
public static T NotNull<T>(T value, string parameterName)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(parameterName);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static T NotNull<T>(
|
||||
T value,
|
||||
string parameterName,
|
||||
string message)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(parameterName, message);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static string NotNull(
|
||||
string value,
|
||||
string parameterName,
|
||||
int maxLength = int.MaxValue,
|
||||
int minLength = 0)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} can not be null!", parameterName);
|
||||
}
|
||||
|
||||
if (value.Length > maxLength)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} length must be equal to or lower than {maxLength}!", parameterName);
|
||||
}
|
||||
|
||||
if (minLength > 0 && value.Length < minLength)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} length must be equal to or bigger than {minLength}!", parameterName);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static string NotNullOrWhiteSpace(
|
||||
string value,
|
||||
string parameterName,
|
||||
int maxLength = int.MaxValue,
|
||||
int minLength = 0)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} can not be null, empty or white space!", parameterName);
|
||||
}
|
||||
|
||||
if (value.Length > maxLength)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} length must be equal to or lower than {maxLength}!", parameterName);
|
||||
}
|
||||
|
||||
if (minLength > 0 && value.Length < minLength)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} length must be equal to or bigger than {minLength}!", parameterName);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static string NotNullOrEmpty(
|
||||
string value,
|
||||
string parameterName,
|
||||
int maxLength = int.MaxValue,
|
||||
int minLength = 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} can not be null or empty!", parameterName);
|
||||
}
|
||||
|
||||
if (value.Length > maxLength)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} length must be equal to or lower than {maxLength}!", parameterName);
|
||||
}
|
||||
|
||||
if (minLength > 0 && value.Length < minLength)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} length must be equal to or bigger than {minLength}!", parameterName);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ICollection<T> NotNullOrEmpty<T>(ICollection<T> value, string parameterName)
|
||||
{
|
||||
if (value == null || value.Count <= 0)
|
||||
{
|
||||
throw new ArgumentException(parameterName + " can not be null or empty!", parameterName);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Type AssignableTo<TBaseType>(
|
||||
Type type,
|
||||
string parameterName)
|
||||
{
|
||||
NotNull(type, parameterName);
|
||||
|
||||
if (!type.IsAssignableTo(typeof(TBaseType)))
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} (type of {type.AssemblyQualifiedName}) should be assignable to the {typeof(TBaseType).FullName}!");
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public static string Length(
|
||||
[AllowNull] string value,
|
||||
string parameterName,
|
||||
int maxLength,
|
||||
int minLength = 0)
|
||||
{
|
||||
if (minLength > 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
throw new ArgumentException(parameterName + " can not be null or empty!", parameterName);
|
||||
}
|
||||
|
||||
if (value.Length < minLength)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} length must be equal to or bigger than {minLength}!", parameterName);
|
||||
}
|
||||
}
|
||||
|
||||
if (value != null && value.Length > maxLength)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} length must be equal to or lower than {maxLength}!", parameterName);
|
||||
}
|
||||
|
||||
return value!;
|
||||
}
|
||||
|
||||
public static short Positive(
|
||||
short value,
|
||||
string parameterName)
|
||||
{
|
||||
if(value == 0)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is equal to zero");
|
||||
}
|
||||
else if(value < 0)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is less than zero");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Int32 Positive(
|
||||
Int32 value,
|
||||
string parameterName)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is equal to zero");
|
||||
}
|
||||
else if (value < 0)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is less than zero");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Int64 Positive(
|
||||
Int64 value,
|
||||
string parameterName)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is equal to zero");
|
||||
}
|
||||
else if (value < 0)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is less than zero");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static float Positive(
|
||||
float value,
|
||||
string parameterName)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is equal to zero");
|
||||
}
|
||||
else if (value < 0)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is less than zero");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static double Positive(
|
||||
double value,
|
||||
string parameterName)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is equal to zero");
|
||||
}
|
||||
else if (value < 0)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is less than zero");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static decimal Positive(
|
||||
decimal value,
|
||||
string parameterName)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is equal to zero");
|
||||
}
|
||||
else if (value < 0)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is less than zero");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Int16 Range(
|
||||
Int16 value,
|
||||
string parameterName,
|
||||
Int16 minimumValue,
|
||||
Int16 maximumValue = Int16.MaxValue)
|
||||
{
|
||||
if(value < minimumValue || value > maximumValue)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
public static Int32 Range(
|
||||
Int32 value,
|
||||
string parameterName,
|
||||
Int32 minimumValue,
|
||||
Int32 maximumValue = Int32.MaxValue)
|
||||
{
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Int64 Range(
|
||||
Int64 value,
|
||||
string parameterName,
|
||||
Int64 minimumValue,
|
||||
Int64 maximumValue = Int64.MaxValue)
|
||||
{
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public static float Range(
|
||||
float value,
|
||||
string parameterName,
|
||||
float minimumValue,
|
||||
float maximumValue = float.MaxValue)
|
||||
{
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public static double Range(
|
||||
double value,
|
||||
string parameterName,
|
||||
double minimumValue,
|
||||
double maximumValue = double.MaxValue)
|
||||
{
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public static decimal Range(
|
||||
decimal value,
|
||||
string parameterName,
|
||||
decimal minimumValue,
|
||||
decimal maximumValue = decimal.MaxValue)
|
||||
{
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static T NotDefaultOrNull<T>(
|
||||
T? value,
|
||||
string parameterName)
|
||||
where T : struct
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} is null!", parameterName);
|
||||
}
|
||||
|
||||
if (value.Value.Equals(default(T)))
|
||||
{
|
||||
throw new ArgumentException($"{parameterName} has a default value!", parameterName);
|
||||
}
|
||||
|
||||
return value.Value;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public static class BooleanExtensions
|
||||
/// </summary>
|
||||
private static bool? GetBool(this object data)
|
||||
{
|
||||
switch (data.ToString().Trim().ToLower())
|
||||
switch (data.ToString()?.Trim().ToLower())
|
||||
{
|
||||
case "0":
|
||||
return false;
|
||||
|
||||
@@ -16,7 +16,7 @@ public static class DictionaryExtensions
|
||||
/// <param name="dictionary">要操作的字典.</param>
|
||||
/// <param name="key">指定键名.</param>
|
||||
/// <returns>获取到的值.</returns>
|
||||
public static TValue GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
|
||||
public static TValue? GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
|
||||
{
|
||||
return dictionary.TryGetValue(key, out TValue value) ? value : default(TValue);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public static class EnumExtensions
|
||||
/// <returns></returns>
|
||||
public static string GetDescription(this System.Enum value)
|
||||
{
|
||||
return value.GetType().GetMember(value.ToString()).FirstOrDefault()?.GetCustomAttribute<DescriptionAttribute>()?.Description;
|
||||
return value.GetType().GetMember(value.ToString()).FirstOrDefault()?.GetCustomAttribute<DescriptionAttribute>()?.Description ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -162,7 +162,7 @@ public static class EnumExtensions
|
||||
/// <returns></returns>
|
||||
public static string GetDescription(this object value)
|
||||
{
|
||||
return value.GetType().GetMember(value.ToString() ?? string.Empty).FirstOrDefault()?.GetCustomAttribute<DescriptionAttribute>()?.Description;
|
||||
return value.GetType().GetMember(value.ToString() ?? string.Empty).FirstOrDefault()?.GetCustomAttribute<DescriptionAttribute>()?.Description ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -219,7 +219,7 @@ public static partial class Extensions
|
||||
/// </summary>
|
||||
private static bool? GetBool(this object data)
|
||||
{
|
||||
switch (data.ToString().Trim().ToLower())
|
||||
switch (data.ToString()?.Trim().ToLower())
|
||||
{
|
||||
case "0":
|
||||
return false;
|
||||
@@ -466,7 +466,7 @@ public static partial class Extensions
|
||||
{
|
||||
try
|
||||
{
|
||||
return obj == null ? string.Empty : obj.ToString();
|
||||
return obj == null ? string.Empty : obj.ToString()!;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -489,7 +489,7 @@ public static partial class Extensions
|
||||
return string.Join(",", list);
|
||||
}
|
||||
|
||||
return obj.ToString();
|
||||
return obj.ToString()!;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -678,7 +678,7 @@ public static partial class Extensions
|
||||
/// <returns></returns>
|
||||
public static string ObjToString(this object thisValue)
|
||||
{
|
||||
if (thisValue != null) return thisValue.ToString().Trim();
|
||||
if (thisValue != null) return thisValue.ToString()!.Trim();
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public static class RandomExtensions
|
||||
|
||||
Array array = System.Enum.GetValues(type);
|
||||
int index = random.Next(array.GetLowerBound(0), array.GetUpperBound(0) + 1);
|
||||
return (T)array.GetValue(index);
|
||||
return (T)array.GetValue(index)!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -67,7 +67,7 @@ public static class RandomExtensions
|
||||
public static T NextItem<T>(this Random random, T[] items)
|
||||
{
|
||||
if (items == null || items.Length == 0)
|
||||
return default(T);
|
||||
return default(T)!;
|
||||
|
||||
return items[random.Next(items.Length)];
|
||||
}
|
||||
|
||||
@@ -111,10 +111,10 @@ public class UserAgent : IUserAgent
|
||||
private DeviceInfo _device;
|
||||
private OSInfo _os;
|
||||
|
||||
private bool? _isBot;
|
||||
//private bool? _isBot;
|
||||
private bool? _isMobileDevice;
|
||||
private bool? _isTablet;
|
||||
private bool? _isPdfConverter;
|
||||
//private bool? _isPdfConverter;
|
||||
|
||||
static UserAgent()
|
||||
{
|
||||
@@ -142,7 +142,7 @@ public class UserAgent : IUserAgent
|
||||
}
|
||||
}
|
||||
|
||||
return _rawValue;
|
||||
return _rawValue ?? "";
|
||||
}
|
||||
|
||||
set
|
||||
@@ -151,10 +151,10 @@ public class UserAgent : IUserAgent
|
||||
_userAgent = null;
|
||||
_device = null;
|
||||
_os = null;
|
||||
_isBot = null;
|
||||
//_isBot = null;
|
||||
_isMobileDevice = null;
|
||||
_isTablet = null;
|
||||
_isPdfConverter = null;
|
||||
//_isPdfConverter = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ public static class CodeGenHelper
|
||||
field = entityInfo.Columns.Find(it => it.PropertyName.Equals(sort.ToUpperCase()))?.DbColumnName;
|
||||
break;
|
||||
}
|
||||
return string.IsNullOrEmpty(field) ? null : field;
|
||||
return string.IsNullOrEmpty(field) ? "" : field;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -63,7 +63,7 @@ public static class ComparisonHelper<T>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <returns></returns>
|
||||
public int Compare(T x, T y)
|
||||
public int Compare(T? x, T? y)
|
||||
{
|
||||
return _comparer.Compare(_keySelector(x), _keySelector(y));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using JNPF.DependencyInjection;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using JNPF.DependencyInjection;
|
||||
|
||||
namespace JNPF.Common.Security;
|
||||
|
||||
@@ -49,14 +50,14 @@ public static class EqualityHelper<T>
|
||||
: this(keySelector, EqualityComparer<TV>.Default)
|
||||
{ }
|
||||
|
||||
public bool Equals(T x, T y)
|
||||
public bool Equals(T? x, T? y)
|
||||
{
|
||||
return _comparer.Equals(_keySelector(x), _keySelector(y));
|
||||
}
|
||||
|
||||
public int GetHashCode(T obj)
|
||||
public int GetHashCode([DisallowNull] T obj)
|
||||
{
|
||||
return _comparer.GetHashCode(_keySelector(obj));
|
||||
return _comparer.GetHashCode(_keySelector(obj)!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ using NPOI.XSSF.UserModel;
|
||||
|
||||
namespace JNPF.Common.Security;
|
||||
|
||||
#pragma warning disable CS8602, CS0618, CA2200
|
||||
/// <summary>
|
||||
/// Excel导出操作类
|
||||
/// 版 本:V3.2.0
|
||||
@@ -740,7 +741,7 @@ public class ExcelExportHelper<T>
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1039,7 +1040,7 @@ public class ExcelExportHelper<T>
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1168,4 +1169,5 @@ public class ExcelExportHelper<T>
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS8602, CS0618, CA2200
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace JNPF.Common.Helper
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
dataRow[j] = cell.ToString().Trim();
|
||||
dataRow[j] = cell.ToString()?.Trim();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,6 +505,7 @@ public class FileHelper
|
||||
|
||||
#endregion
|
||||
|
||||
#pragma warning disable CA1416 // 验证平台兼容性
|
||||
#region 生成高清晰缩略图
|
||||
|
||||
/// <summary>
|
||||
@@ -669,6 +670,7 @@ public class FileHelper
|
||||
}
|
||||
|
||||
#endregion
|
||||
#pragma warning restore CA1416 // 验证平台兼容性
|
||||
|
||||
#region 将文件路径转为内存流
|
||||
|
||||
@@ -712,7 +714,8 @@ public class FileHelper
|
||||
|
||||
if (selectFiles.Count > 0)
|
||||
{
|
||||
return selectFiles.FirstOrDefault().FullName;
|
||||
//modified by PhilPan
|
||||
return selectFiles.First().FullName;
|
||||
}
|
||||
|
||||
return Path.Combine(folderPath, $@"{prefix}_{DateTime.Now.ParseToUnixTime()}.log");
|
||||
@@ -737,7 +740,7 @@ public class FileHelper
|
||||
Microsoft.AspNetCore.Http.HttpContext? httpContext = App.HttpContext;
|
||||
httpContext.Response.ContentType = "application/octet-stream";
|
||||
httpContext.Response.Headers.Add("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName, Encoding.UTF8));
|
||||
httpContext.Response.Headers.Add("Content-Length", buff.Length.ToString());
|
||||
httpContext.Response.Headers.Add("Content-Length", buff?.Length.ToString());
|
||||
httpContext.Response.Body.WriteAsync(buff);
|
||||
httpContext.Response.Body.Flush();
|
||||
httpContext.Response.Body.Close();
|
||||
|
||||
@@ -46,7 +46,7 @@ public static class JsonHelper
|
||||
/// <returns></returns>
|
||||
public static T ToObject<T>(this string json)
|
||||
{
|
||||
return _ = _jsonSerializer.Deserialize<T>(json) ?? default(T);
|
||||
return _jsonSerializer.Deserialize<T>(json);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -58,7 +58,7 @@ public static class JsonHelper
|
||||
/// <returns></returns>
|
||||
public static T ToObject<T>(this string json, object jsonSerializerOptions = default)
|
||||
{
|
||||
return _ = _jsonSerializer.Deserialize<T>(json, jsonSerializerOptions) ?? default(T);
|
||||
return _jsonSerializer.Deserialize<T>(json, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -69,7 +69,7 @@ public static class JsonHelper
|
||||
/// <returns></returns>
|
||||
public static T ToObject<T>(this object json)
|
||||
{
|
||||
return _ = ToJsonString(json).ToObject<T>() ?? default(T);
|
||||
return ToJsonString(json).ToObject<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -81,7 +81,7 @@ public static class JsonHelper
|
||||
/// <returns></returns>
|
||||
public static T ToObject<T>(this object json, object jsonSerializerOptions = default)
|
||||
{
|
||||
return _ = ToJsonString(json, jsonSerializerOptions).ToObject<T>(jsonSerializerOptions) ?? default(T);
|
||||
return ToJsonString(json, jsonSerializerOptions).ToObject<T>(jsonSerializerOptions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -92,7 +92,7 @@ public static class JsonHelper
|
||||
/// <returns></returns>
|
||||
public static List<T> ToList<T>(this string json)
|
||||
{
|
||||
return _ = _jsonSerializer.Deserialize<List<T>>(json) ?? null;
|
||||
return _jsonSerializer.Deserialize<List<T>>(json);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -104,7 +104,7 @@ public static class JsonHelper
|
||||
/// <returns></returns>
|
||||
public static List<T> ToList<T>(this string json, object jsonSerializerOptions = default)
|
||||
{
|
||||
return _ = _jsonSerializer.Deserialize<List<T>>(json, jsonSerializerOptions) ?? null;
|
||||
return _jsonSerializer.Deserialize<List<T>>(json, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -217,6 +217,7 @@ public static class MachineHelper
|
||||
}
|
||||
#endregion
|
||||
|
||||
#pragma warning disable CA1416 // 验证平台兼容性
|
||||
#region Windows
|
||||
|
||||
/// <summary>
|
||||
@@ -364,4 +365,6 @@ public static class MachineHelper
|
||||
}
|
||||
|
||||
#endregion
|
||||
#pragma warning restore CA1416 // 验证平台兼容性
|
||||
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class SuperQueryHelper
|
||||
{
|
||||
case JnpfKeyConst.COMINPUT:
|
||||
case JnpfKeyConst.TEXTAREA:
|
||||
item.fieldValue = item.fieldValue?.ToString().Replace("\r\n", string.Empty);
|
||||
item.fieldValue = item.fieldValue?.ToString()?.Replace("\r\n", string.Empty);
|
||||
switch (item.symbol)
|
||||
{
|
||||
case "==": // 等于
|
||||
@@ -549,8 +549,9 @@ public class SuperQueryHelper
|
||||
queryOr.mainWhere = true;
|
||||
queryList.Add(queryOr);
|
||||
}
|
||||
//modified by PhilPan
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
switch (item.symbol)
|
||||
{
|
||||
case ">=": // 大于等于
|
||||
|
||||
Reference in New Issue
Block a user