| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- 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
- {
- /// <summary>
- /// 商邀公务AI
- /// </summary>
- [SugarTable("Res_InvitationAI", "商邀公务AI")]
- public class Res_InvitationAI: EntityBase
- {
- /// <summary>
- /// 名称
- /// </summary>
- [SugarColumn(ColumnName = "InvName", ColumnDescription = "名称", IsNullable = true, ColumnDataType = "varchar(150)")]
- public string InvName { get; set; }
- /// <summary>
- /// 团组ID
- /// 注:自定义命名时,GroupID = 0;使用团组名称时,GroupID = Grp_DelegationInfo.Id
- /// </summary>
- [SugarColumn(ColumnName = "GroupId", ColumnDescription = "团组ID", IsNullable = true, ColumnDataType = "int")]
- public int GroupId { get; set; }
- /// <summary>
- /// ai 抓取信息存储(含本地数据信息)
- /// </summary>
- [SugarColumn(ColumnName = "AiCrawledDetails", ColumnDescription = "ai 抓取信息存储(含本地数据信息)", IsJson = true, IsNullable = true, ColumnDataType = "varchar(max)")]
- public List<InvitationAIInfo> AiCrawledDetails { get; set; } = new List<InvitationAIInfo>();
- /// <summary>
- /// 词条信息
- /// </summary>
- [SugarColumn(ColumnName = "Entries", ColumnDescription = "词条信息", IsJson = true, IsNullable = true, ColumnDataType = "varchar(max)")]
- public EntryInfo EntryInfo { get; set; } = new EntryInfo();
- }
- /// <summary>
- /// 单位信息
- /// </summary>
- public class InvitationAIInfo
- {
- /// <summary>
- /// Guid
- /// </summary>
- public string Guid { get; set; }
- /// <summary>
- /// 复选框是否选中
- /// </summary>
- public bool IsChecked { get; set; } = false;
- /// <summary>
- /// 数据来源
- /// 0-本地数据;1-第三方AI接口数据;2-用户手动输入数据
- /// </summary>
- public int Source { get; set; } = 0;
- /// <summary>
- /// 归属区域
- /// </summary>
- public string Region { get; set; }
- /// <summary>
- /// 标准行业:信息技术、金融与财会、工业制造、医疗保健、政府与公共服务、消费与贸易
- /// </summary>
- public string Industry { get; set; }
- /// <summary>
- /// 名称(中文)
- /// </summary>
- public string NameCn { get; set; }
- /// <summary>
- /// 名称(英文)
- /// </summary>
- public string NameEn { get; set; }
- /// <summary>
- /// 地址
- /// </summary>
- public string Address { get; set; }
- /// <summary>
- /// 经营范围
- /// </summary>
- public string Scope { get; set; }
- /// <summary>
- /// 联系人
- /// </summary>
- public string Contact { get; set; }
- /// <summary>
- /// 联系电话
- /// </summary>
- public string Phone { get; set; }
- /// <summary>
- /// 联系邮箱
- /// </summary>
- public string Email { get; set; }
- /// <summary>
- /// 官网地址
- /// </summary>
- public string SiteUrl { get; set; }
- /// <summary>
- /// 文章地址
- /// </summary>
- public List<PostNewsItem> PostUrl { get; set; } = new List<PostNewsItem>();
- /// <summary>
- /// 推荐等级
- /// </summary>
- public string RecLevel { get; set; }
- /// <summary>
- /// 对接建议
- /// </summary>
- public string IntgAdvice { get; set; }
- /// <summary>
- /// 邮件信息
- /// </summary>
- public EmailInfo EmailInfo { get; set; } = new EmailInfo();
- /// <summary>
- /// 备注
- /// </summary>
- public string Remark { get; set; }
- /// <summary>
- /// 操作时间
- /// </summary>
- public DateTime OperatedAt { get; set; }
- /// <summary>
- /// 操作人
- /// </summary>
- public string Operator { get; set; }
- }
- /// <summary>
- /// 新闻链接信息
- /// </summary>
- public class PostNewsItem
- {
- public string Date { get; set; }
- public string Description { get; set; }
- public string Url { get; set; }
- }
- public class EntryInfo
- {
- /// <summary>
- /// 出访单位
- /// </summary>
- public string OriginUnit { get; set; }
- /// <summary>
- /// 拜访国家
- /// </summary>
- public List<string> TargetCountry { get; set; } = new List<string>();
- /// <summary>
- /// 行业信息
- /// 信息技术、金融与财会、工业制造、医疗保健、政府与公共服务、消费与贸易
- /// </summary>
- public List<string> Industries { get; set; } = new List<string>();
- /// <summary>
- /// 规模类型
- /// </summary>
- public List<string> ScaleTypes { get; set; } = new List<string>();
- /// <summary>
- /// 是否需要华人单位背景
- /// </summary>
- public bool IsBackground { get; set; } = false;
- /// <summary>
- /// 出访目的
- /// </summary>
- public string Objective { get; set; }
- /// <summary>
- /// 数据条数
- /// 每个国家获取数据总条数,默认10条
- /// </summary>
- public int NeedCount { get; set; } = 5;
- /// <summary>
- /// 其他规则
- /// </summary>
- public string OtherConstraints { get; set; }
- /// <summary>
- /// 操作时间
- /// </summary>
- public DateTime OperatedAt { get; set; } = new DateTime();
- /// <summary>
- /// 操作人
- /// </summary>
- public string Operator { get; set; }
- }
- public class EmailInfo
- {
- /// <summary>
- /// 邮件标题
- /// </summary>
- public string EmailTitle { get; set; }
- /// <summary>
- /// 邮箱内容
- /// </summary>
- public string EmailContent { get; set; }
- /// <summary>
- /// 发送状态
- /// 1.未开始
- /// 2.AI生成成功
- /// 3.手动编辑
- /// 4.发送完成
- /// 5.发送失败
- /// </summary>
- public int Status { get; set; } = 1;
- /// <summary>
- /// 操作时间
- /// </summary>
- public DateTime OperatedAt { get; set; }
- /// <summary>
- /// 操作人
- /// </summary>
- 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 行业信息
- /// <summary>
- /// 行业信息
- /// </summary>
- 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<IndustryNode> Children { get; init; } = new();
- public string Keywords { get; init; }
- public IndustryNode() { }
- /// <summary>
- /// 静态缓存:扁平化字典,用于 O(1) 效率查找
- /// </summary>
- private static readonly Dictionary<string, IndustryNode> _flatCache;
- public static List<IndustryNode> Roots { get; }
- static IndustryNode()
- {
- Roots = BuildInitialData();
- // 预先扁平化所有节点,方便后续根据 Code 查找
- _flatCache = Roots.SelectMany(GetSelfAndChildren).ToDictionary(x => x.Code);
- }
- /// <summary>
- /// 递归获取所有节点(平铺)
- /// </summary>
- private static IEnumerable<IndustryNode> GetSelfAndChildren(IndustryNode node)
- {
- yield return node;
- if (node.Children == null) yield break;
- foreach (var child in node.Children.SelectMany(GetSelfAndChildren))
- yield return child;
- }
- /// <summary>
- /// 快速查找节点 (O(1))
- /// </summary>
- public static IndustryNode FindByCode(string code) =>
- !string.IsNullOrEmpty(code) && _flatCache.TryGetValue(code, out var node) ? node : null;
- /// <summary>
- /// 初始化全球行业分类静态数据
- /// </summary>
- public static List<IndustryNode> 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 单位规模信息
- /// <summary>
- /// 单位规模
- /// </summary>
- public class OrgScale
- {
- public string Label { get; init; }
- public int MinStaff { get; init; }
- public int MaxStaff { get; init; }
- public static List<OrgScale> 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 }
- };
- /// <summary>
- /// 根据人数自动匹配规模标签
- /// </summary>
- public static string GetLabel(int count) =>
- GetScales().FirstOrDefault(s => count >= s.MinStaff && count <= s.MaxStaff)?.Label ?? "未知规模";
- }
- #endregion
- #region AI 行业匹配结果实体
- /// <summary>
- /// AI 行业匹配结果实体
- /// </summary>
- public class IndustryMatchResult
- {
- /// <summary>
- /// 原始出访单位名称
- /// </summary>
- public string SourceUnitName { get; set; } = string.Empty;
- /// <summary>
- /// 匹配到的目标单位名称(必须与输入 NameCn 一致)
- /// </summary>
- public string TargetUnitName { get; set; } = string.Empty;
- /// <summary>
- /// 目标单位所属国家
- /// </summary>
- public string TargetCountry { get; set; } = string.Empty;
- /// <summary>
- /// 识别出的行业分类(来自动态传入的行业标准)
- /// </summary>
- public string MatchedIndustry { get; set; } = string.Empty;
- /// <summary>
- /// 匹配置信度 (0.0 - 1.0)
- /// </summary>
- public double ConfidenceScore { get; set; }
- /// <summary>
- /// AI 给出的匹配理由说明
- /// </summary>
- public string MatchReason { get; set; } = string.Empty;
- // --- 辅助属性 (非 AI 返回内容) ---
- /// <summary>
- /// 判断是否为高价值匹配(业务逻辑判定)
- /// </summary>
- [JsonIgnore]
- public bool IsHighValue => ConfidenceScore >= 0.8;
- }
- #endregion
- }
|