using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace OASystem.Domain.Entities.Resource
{
///
/// 商邀公务AI
///
[SugarTable("Res_InvitationAI", "商邀公务AI")]
public class Res_InvitationAI: EntityBase
{
///
/// 名称
///
[SugarColumn(ColumnName = "InvName", ColumnDescription = "名称", IsNullable = true, ColumnDataType = "varchar(150)")]
public string InvName { get; set; }
///
/// 团组ID
/// 注:自定义命名时,GroupID = 0;使用团组名称时,GroupID = Grp_DelegationInfo.Id
///
[SugarColumn(ColumnName = "GroupId", ColumnDescription = "团组ID", IsNullable = true, ColumnDataType = "int")]
public int GroupId { get; set; }
///
/// ai 抓取信息存储(含本地数据信息)
///
[SugarColumn(ColumnName = "AiCrawledDetails", ColumnDescription = "ai 抓取信息存储(含本地数据信息)", IsJson = true, IsNullable = true, ColumnDataType = "varchar(max)")]
public List AiCrawledDetails { get; set; } = new List();
///
/// 词条信息
///
[SugarColumn(ColumnName = "Entries", ColumnDescription = "词条信息", IsJson = true, IsNullable = true, ColumnDataType = "varchar(max)")]
public EntryInfo EntryInfo { get; set; } = new EntryInfo();
}
///
/// 单位信息
///
public class InvitationAIInfo
{
///
/// Guid
///
public string Guid { get; set; }
///
/// 复选框是否选中
///
public bool IsChecked { get; set; } = false;
///
/// 数据来源
/// 0-本地数据;1-第三方AI接口数据;2-用户手动输入数据
///
public int Source { get; set; } = 0;
///
/// 归属区域
///
public string Region { get; set; }
///
/// 标准行业:信息技术、金融与财会、工业制造、医疗保健、政府与公共服务、消费与贸易
///
public string Industry { get; set; }
///
/// 名称(中文)
///
public string NameCn { get; set; }
///
/// 名称(英文)
///
public string NameEn { get; set; }
///
/// 地址
///
public string Address { get; set; }
///
/// 经营范围
///
public string Scope { get; set; }
///
/// 联系人
///
public string Contact { get; set; }
///
/// 联系电话
///
public string Phone { get; set; }
///
/// 联系邮箱
///
public string Email { get; set; }
///
/// 官网地址
///
public string SiteUrl { get; set; }
///
/// 文章地址
///
public List PostUrl { get; set; } = new List();
///
/// 推荐等级
///
public string RecLevel { get; set; }
///
/// 对接建议
///
public string IntgAdvice { get; set; }
///
/// 邮件信息
///
public EmailInfo EmailInfo { get; set; } = new EmailInfo();
///
/// 备注
///
public string Remark { get; set; }
///
/// 操作时间
///
public DateTime OperatedAt { get; set; }
///
/// 操作人
///
public string Operator { get; set; }
}
///
/// 新闻链接信息
///
public class PostNewsItem
{
public string Date { get; set; }
public string Description { get; set; }
public string Url { get; set; }
}
public class EntryInfo
{
///
/// 出访单位
///
public string OriginUnit { get; set; }
///
/// 拜访国家
///
public List TargetCountry { get; set; } = new List();
///
/// 行业信息
/// 信息技术、金融与财会、工业制造、医疗保健、政府与公共服务、消费与贸易
///
public List Industries { get; set; } = new List();
///
/// 规模类型
///
public List ScaleTypes { get; set; } = new List();
///
/// 是否需要华人单位背景
///
public bool IsBackground { get; set; } = false;
///
/// 出访目的
///
public string Objective { get; set; }
///
/// 数据条数
/// 每个国家获取数据总条数,默认10条
///
public int NeedCount { get; set; } = 5;
///
/// 其他规则
///
public string OtherConstraints { get; set; }
///
/// 操作时间
///
public DateTime OperatedAt { get; set; } = new DateTime();
///
/// 操作人
///
public string Operator { get; set; }
}
public class EmailInfo
{
///
/// 邮件标题
///
public string EmailTitle { get; set; }
///
/// 邮箱内容
///
public string EmailContent { get; set; }
///
/// 发送状态
/// 1.未开始
/// 2.AI生成成功
/// 3.手动编辑
/// 4.发送完成
/// 5.发送失败
///
public int Status { get; set; } = 1;
///
/// 操作时间
///
public DateTime OperatedAt { get; set; }
///
/// 操作人
///
public string Operator { get; set; }
}
public class AICreateEmailInfo
{
public string Guid { get; set; }
public string NameCn { get; set; }
public string Scope { get; set; }
public string Subject { get; set; }
public string Content { get; set; }
}
public class CountryAIPormptInfo {
public string Country { get; set; }
public int Count { get; set; }
}
#region 行业信息
///
/// 行业信息
///
public class IndustryNode
{
public string Code { get; init; }
public string NameCn { get; init; }
public string NameEn { get; init; }
public string ParentCode { get; init; }
public List Children { get; init; } = new();
public string Keywords { get; init; }
public IndustryNode() { }
///
/// 静态缓存:扁平化字典,用于 O(1) 效率查找
///
private static readonly Dictionary _flatCache;
public static List Roots { get; }
static IndustryNode()
{
Roots = BuildInitialData();
// 预先扁平化所有节点,方便后续根据 Code 查找
_flatCache = Roots.SelectMany(GetSelfAndChildren).ToDictionary(x => x.Code);
}
///
/// 递归获取所有节点(平铺)
///
private static IEnumerable GetSelfAndChildren(IndustryNode node)
{
yield return node;
if (node.Children == null) yield break;
foreach (var child in node.Children.SelectMany(GetSelfAndChildren))
yield return child;
}
///
/// 快速查找节点 (O(1))
///
public static IndustryNode FindByCode(string code) =>
!string.IsNullOrEmpty(code) && _flatCache.TryGetValue(code, out var node) ? node : null;
///
/// 初始化全球行业分类静态数据
///
public static List BuildInitialData() => new()
{
new() { Code = "TECH", NameCn = "信息技术", NameEn = "Technology", Keywords = "IT,互联网,软件,AI", Children = new() {
new() { Code = "TECH01", ParentCode = "TECH", NameCn = "软件开发与服务", NameEn = "Software & Services" },
new() { Code = "TECH02", ParentCode = "TECH", NameCn = "硬件与半导体", NameEn = "Hardware & Semiconductors" },
new() { Code = "TECH03", ParentCode = "TECH", NameCn = "人工智能与大数据", NameEn = "AI & Big Data" }
}},
new() { Code = "FIN", NameCn = "金融与财会", NameEn = "Financials", Keywords = "银行,保险,证券", Children = new() {
new() { Code = "FIN01", ParentCode = "FIN", NameCn = "银行业", NameEn = "Banking" },
new() { Code = "FIN02", ParentCode = "FIN", NameCn = "保险与风险管理", NameEn = "Insurance" },
new() { Code = "FIN03", ParentCode = "FIN", NameCn = "资本市场与证券", NameEn = "Capital Markets" }
}},
new() { Code = "MANU", NameCn = "工业制造", NameEn = "Manufacturing", Keywords = "工厂,机械,自动化", Children = new() {
new() { Code = "MANU01", ParentCode = "MANU", NameCn = "汽车与运输设备", NameEn = "Automotive" },
new() { Code = "MANU02", ParentCode = "MANU", NameCn = "机械与电气设备", NameEn = "Machinery & Electrical" },
new() { Code = "MANU03", ParentCode = "MANU", NameCn = "消费电子制造", NameEn = "Consumer Electronics" }
}},
new() { Code = "HLT", NameCn = "医疗保健", NameEn = "Healthcare", Keywords = "制药,医院,器械", Children = new() {
new() { Code = "HLT01", ParentCode = "HLT", NameCn = "制药与生物技术", NameEn = "Pharmaceuticals & Biotech" },
new() { Code = "HLT02", ParentCode = "HLT", NameCn = "医疗器械与供应", NameEn = "Medical Devices" },
new() { Code = "HLT03", ParentCode = "HLT", NameCn = "医疗机构与诊所", NameEn = "Health Institutions" }
}},
new() { Code = "GOV", NameCn = "政府与公共服务", NameEn = "Government", Keywords = "行政,机关,组织,NGO", Children = new() {
new() { Code = "GOV01", ParentCode = "GOV", NameCn = "政府行政机关", NameEn = "Administrative Bodies" },
new() { Code = "GOV02", ParentCode = "GOV", NameCn = "国际组织与NGO", NameEn = "International Orgs & NGOs" },
new() { Code = "GOV03", ParentCode = "GOV", NameCn = "公共教育与科研单位", NameEn = "Education & Research" }
}},
new() { Code = "CONS", NameCn = "消费与贸易", NameEn = "Consumer & Trade", Keywords = "零售,电商,物流", Children = new() {
new() { Code = "CONS01", ParentCode = "CONS", NameCn = "电子商务与零售", NameEn = "E-commerce & Retail" },
new() { Code = "CONS02", ParentCode = "CONS", NameCn = "物流与供应链", NameEn = "Logistics & Supply Chain" },
new() { Code = "CONS03", ParentCode = "CONS", NameCn = "酒店与旅游餐饮", NameEn = "Hospitality & Tourism" }
}}
};
}
#endregion
#region 单位规模信息
///
/// 单位规模
///
public class OrgScale
{
public string Label { get; init; }
public int MinStaff { get; init; }
public int MaxStaff { get; init; }
public static List GetScales() => new()
{
new() { Label = "微型 (1-10人)", MinStaff = 1, MaxStaff = 10 },
new() { Label = "小型 (11-50人)", MinStaff = 11, MaxStaff = 50 },
new() { Label = "中型 (51-200人)", MinStaff = 51, MaxStaff = 200 },
new() { Label = "大型 (201-1000人)", MinStaff = 201, MaxStaff = 1000 },
new() { Label = "超大型 (1000人以上)", MinStaff = 1001, MaxStaff = int.MaxValue }
};
///
/// 根据人数自动匹配规模标签
///
public static string GetLabel(int count) =>
GetScales().FirstOrDefault(s => count >= s.MinStaff && count <= s.MaxStaff)?.Label ?? "未知规模";
}
#endregion
#region AI 行业匹配结果实体
///
/// AI 行业匹配结果实体
///
public class IndustryMatchResult
{
///
/// 原始出访单位名称
///
public string SourceUnitName { get; set; } = string.Empty;
///
/// 匹配到的目标单位名称(必须与输入 NameCn 一致)
///
public string TargetUnitName { get; set; } = string.Empty;
///
/// 目标单位所属国家
///
public string TargetCountry { get; set; } = string.Empty;
///
/// 识别出的行业分类(来自动态传入的行业标准)
///
public string MatchedIndustry { get; set; } = string.Empty;
///
/// 匹配置信度 (0.0 - 1.0)
///
public double ConfidenceScore { get; set; }
///
/// AI 给出的匹配理由说明
///
public string MatchReason { get; set; } = string.Empty;
// --- 辅助属性 (非 AI 返回内容) ---
///
/// 判断是否为高价值匹配(业务逻辑判定)
///
[JsonIgnore]
public bool IsHighValue => ConfidenceScore >= 0.8;
}
#endregion
}