Asoka.Wang 21f044712c 1
2025-08-27 18:39:19 +08:00

292 lines
9.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using NPP.SmartSchedue.Api.Contracts.Services.Integration.Output;
using NPP.SmartSchedue.Api.Contracts.Domain.Work;
namespace NPP.SmartSchedue.Api.Contracts.Services.Integration.Input
{
/// <summary>
/// 智能整合输入
/// </summary>
public class SmartIntegrationInput
{
/// <summary>
/// 选中的任务ID列表
/// </summary>
public List<long> SelectedTaskIds { get; set; } = new();
/// <summary>
/// 选中的项目号列表
/// </summary>
public List<string> SelectedProjectNumbers { get; set; } = new();
/// <summary>
/// 整合策略配置
/// </summary>
public IntegrationStrategy Strategy { get; set; } = new();
/// <summary>
/// 操作员信息
/// </summary>
public long OperatorUserId { get; set; }
public string OperatorName { get; set; }
/// <summary>
/// 整合批次名称(可选)
/// </summary>
public string BatchName { get; set; }
/// <summary>
/// 整合备注
/// </summary>
public string Remarks { get; set; }
}
/// <summary>
/// 整合策略
/// </summary>
public class IntegrationStrategy
{
/// <summary>
/// 人员分配策略
/// </summary>
public PersonnelAllocationStrategy PersonnelStrategy { get; set; } = PersonnelAllocationStrategy.FairDistribution;
/// <summary>
/// 设备分配策略
/// </summary>
public EquipmentAllocationStrategy EquipmentStrategy { get; set; } = EquipmentAllocationStrategy.MaxUtilization;
/// <summary>
/// 是否强制满足班次规则
/// </summary>
public bool EnforceShiftRules { get; set; } = true;
/// <summary>
/// 是否优先分配高优先级任务
/// </summary>
public bool PrioritizeHighPriorityTasks { get; set; } = true;
/// <summary>
/// 是否考虑人员资质匹配
/// </summary>
public bool ConsiderQualificationMatch { get; set; } = true;
/// <summary>
/// 是否启用负载均衡
/// </summary>
public bool EnableLoadBalancing { get; set; } = true;
/// <summary>
/// 最大连续工作天数限制
/// </summary>
public int? MaxContinuousWorkDays { get; set; }
/// <summary>
/// 设备利用率目标(百分比)
/// </summary>
public decimal TargetEquipmentUtilization { get; set; } = 80.0m;
}
/// <summary>
/// 人员分配策略枚举
/// </summary>
public enum PersonnelAllocationStrategy
{
/// <summary>
/// 公平分配(均衡工作量)
/// </summary>
FairDistribution = 1,
/// <summary>
/// 技能优先(优先匹配最佳技能)
/// </summary>
SkillPriority = 2,
/// <summary>
/// 效率优先(优先分配给高效人员)
/// </summary>
EfficiencyPriority = 3,
/// <summary>
/// 负载均衡(平衡所有人员工作负荷)
/// </summary>
LoadBalance = 4
}
/// <summary>
/// 设备分配策略枚举
/// </summary>
public enum EquipmentAllocationStrategy
{
/// <summary>
/// 最大利用率(优先使用利用率高的设备)
/// </summary>
MaxUtilization = 1,
/// <summary>
/// 负载均衡(平衡所有设备使用率)
/// </summary>
LoadBalance = 2,
/// <summary>
/// 性能优先(优先使用性能最佳的设备)
/// </summary>
PerformancePriority = 3,
/// <summary>
/// 就近分配(优先分配距离最近的设备)
/// </summary>
ProximityPriority = 4
}
/// <summary>
/// 人员分配输入
/// 深度架构思考:支持两种输入模式,避免重复数据库查询,提升性能和数据一致性
/// </summary>
public class PersonnelAllocationInput
{
/// <summary>
/// 待分配的任务ID列表当Tasks为空时使用
/// </summary>
public List<long> TaskIds { get; set; } = new();
/// <summary>
/// 待分配的任务对象列表(性能优化:避免重复数据库查询)
/// 深度业务考量当上级调用方已经加载了完整的task对象时直接传入可以
/// 1. 避免重复数据库查询,提升性能
/// 2. 确保数据一致性,防止查询间隙的数据变更
/// 3. 减少Include操作的开销
/// 使用优先级Tasks > TaskIds
/// </summary>
public List<WorkOrderEntity> Tasks { get; set; } = new();
/// <summary>
/// 人员分配策略
/// </summary>
public PersonnelAllocationStrategy Strategy { get; set; }
/// <summary>
/// 是否强制满足班次规则
/// </summary>
public bool EnforceShiftRules { get; set; } = true;
/// <summary>
/// 排除的人员ID列表不参与分配
/// </summary>
public List<long> ExcludedPersonnelIds { get; set; } = new();
/// <summary>
/// 优先考虑的人员ID列表
/// </summary>
public List<long> PreferredPersonnelIds { get; set; } = new();
}
/// <summary>
/// 设备分配输入
/// 深度架构优化:支持两种输入模式,避免重复数据库查询,提升性能和数据一致性
/// </summary>
public class EquipmentAllocationInput
{
/// <summary>
/// 待分配的任务ID列表当Tasks为空时使用
/// </summary>
public List<long> TaskIds { get; set; } = new();
/// <summary>
/// 待分配的任务对象列表(性能优化:避免重复数据库查询)
/// 深度业务考量当上级调用方SmartScheduleOrchestratorService已经加载了完整的task对象时直接传入可以
/// 1. 避免重复数据库查询提升性能50%以上
/// 2. 确保数据一致性,防止查询间隙的数据变更
/// 3. 减少Include操作的开销降低内存占用
/// 4. 保持与PersonnelAllocationInput相同的优化模式
/// 使用优先级Tasks > TaskIds
/// </summary>
public List<WorkOrderEntity> Tasks { get; set; } = new();
/// <summary>
/// 设备分配策略
/// </summary>
public EquipmentAllocationStrategy Strategy { get; set; }
/// <summary>
/// 目标利用率(百分比)
/// </summary>
public decimal TargetUtilization { get; set; } = 80.0m;
/// <summary>
/// 排除的设备ID列表不参与分配
/// </summary>
public List<long> ExcludedEquipmentIds { get; set; } = new();
/// <summary>
/// 优先考虑的设备ID列表
/// </summary>
public List<long> PreferredEquipmentIds { get; set; } = new();
}
/// <summary>
/// 整合记录输入
/// </summary>
public class IntegrationRecordInput
{
/// <summary>
/// 整合的任务ID列表
/// </summary>
public List<long> TaskIds { get; set; } = new();
/// <summary>
/// 人员分配结果
/// </summary>
public PersonnelAllocationResult PersonnelAllocation { get; set; }
/// <summary>
/// 设备分配结果
/// </summary>
public EquipmentAllocationResult EquipmentAllocation { get; set; }
/// <summary>
/// 整合策略
/// </summary>
public IntegrationStrategy Strategy { get; set; }
/// <summary>
/// 操作员信息
/// </summary>
public long OperatorUserId { get; set; }
public string OperatorName { get; set; }
/// <summary>
/// 整合备注
/// </summary>
public string Remarks { get; set; }
}
/// <summary>
/// 整合历史查询输入
/// </summary>
public class IntegrationHistoryQueryInput
{
/// <summary>
/// 操作员ID
/// </summary>
public long? OperatorUserId { get; set; }
/// <summary>
/// 项目号
/// </summary>
public string ProjectNumber { get; set; }
/// <summary>
/// 整合时间范围
/// </summary>
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
/// <summary>
/// 分页参数
/// </summary>
public int PageIndex { get; set; } = 1;
public int PageSize { get; set; } = 20;
}
}