Sfoglia il codice sorgente

接团客户名单英文Word 使用Ai完善

yuanrf 1 anno fa
parent
commit
034818f8e2
1 ha cambiato i file con 159 aggiunte e 66 eliminazioni
  1. 159 66
      OASystem/OASystem.Api/Controllers/GroupsController.cs

+ 159 - 66
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -22054,115 +22054,208 @@ AirHotelPrice
                     else transStrRes1 += $"{str1}|";
 
                 }
-                //string transStrRes = "0 & Provincial Health & Health Commission Deputy Director | 1 & Provincial People's Hospital & Provincial People's Hospital Chief Accountant | 2 & Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College & North Sichuan Medical College | 3 & Provincial Health Commission Planning & Provincial Health Commission Planning and Information Division Director | 4 &-& Deputy Director | 5 & Provincial Health Commission population and Family Division & Provincial Health Commission population and Family Division Director";
-                string transStrRes = "";
 
-                if (transStrRes1.Length > 0)
-                {
-                    transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
-                }
-                //0、 Deputy Director of the Provincial Health and Health Commission | 1、 Chief Accountant of the provincial People's Hospital | 2、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 3、 Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director | 5、 Director of the population and Family Department of the Provincial Health and Health Commission | 3、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 4、 Deputy Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director of the population and Family Department of the Provincial Health and Health Commission | 5、 Director of the population and Family Department of the Provincial Health and Health Commission
-                //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
-                //List<string> transArray = new List<string> { };
-                List<TranslateInfo> transArray = new List<TranslateInfo>();
+                #region AI转英文
+                string jsonValue = JsonConvert.SerializeObject(DcList);
+                string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
 
-                if (transStrRes.Contains("|"))
+                List<SeedMessages> messages = new List<SeedMessages>()
                 {
-                    string[] transArray1 = transStrRes.Split('|');
-                    if (transArray1.Length > 0)
-                    {
-                        foreach (var item in transArray1)
-                        {
-                            if (item.Contains("&"))
-                            {
-                                string[] transArray2 = item.Split('&');
-                                int index = 0;
-                                string companyName = "", job = "";
+                   new SeedMessages
+                   {
+                        Role = KimiRole.user,
+                        Content = jsonValue + text
+                   }
+                };
 
-                                if (transArray2.Length > 0)
-                                {
-                                    bool success = int.TryParse(transArray2[0].Trim(), out index);
-                                    if (1 < transArray2.Length) companyName = transArray2[1];
-                                    if (2 < transArray2.Length) job = transArray2[2];
-                                }
+                KiMiApiClient client = new KiMiApiClient();
+                var kimiApiResult = await client.SeedMessage(messages);
+                var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
+                string clients = kimiApiResult_JObject["content"].ToString();
 
-                                transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
-                            }
-                        }
-                    }
+                string startStr = "```json", endStr = "```";
+                
+                // 判断并清除开头部分
+                if (clients.StartsWith(startStr))
+                {
+                    clients = clients.Remove(0, startStr.Length);
+                }
+
+                // 判断并清除结尾部分
+                if (clients.EndsWith(endStr))
+                {
+                    clients = clients.Remove(clients.Length - endStr.Length);
                 }
 
+                var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
+
                 //循环赋值
-                for (int i = 0; i < DcList.Count; i++)
+                for (int i = 0; i < en_Json.Count; i++)
                 {
-                    string PYName = "";
-                    if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
-                    {
-                        string PY_Last = DcList[i].Pinyin.Split('/')[0];
-                        string PY_First = DcList[i].Pinyin.Split('/')[1];
-                        PYName = PY_First + " " + PY_Last;
-                    }
-                    else
-                    {
-                        string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
-                        string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
-                        PYName = PY_First + " " + PY_Last;
-                    }
+                    var dc = en_Json[i];
+                    var dc1 = DcList.Find(x => x.Id == dc.Id);
+
+                    string PYName = dc.FirstName + " " + dc.LastName;
                     builder.MoveToCell(0, i + 1, 0, 0);
                     builder.Write(PYName);
 
-                    string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
+                    string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
                     builder.MoveToCell(0, i + 1, 1, 0);
                     builder.Write(sex);
 
                     DateTime birthDt;
-                    bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
+                    bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
                     string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
                     builder.MoveToCell(0, i + 1, 2, 0);
                     builder.Write(birthday);
 
                     string company = string.Empty, job = string.Empty;
-                    var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
-                    if (dcTransInfo != null)
-                    {
-                        company = dcTransInfo.CompanyName;
-                        job = dcTransInfo.Job;
-                    }
+                    company = dc.CompanyFullName;
+                    job = dc.Job;
 
-                    if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
+                    if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName)  )
                     {
                         //查询对照表
-                        Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
+                        Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
                         if (tempCec != null)
                         {
                             company = tempCec.enName;
                         }
-                        //翻译
-                        else
-                        {
-
-                        }
                     }
 
                     builder.MoveToCell(0, i + 1, 3, 0);
                     builder.Write(company);
 
-                    if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
+                    if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
                     {
                         //查询对照表
-                        Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
+                        Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
                         if (tempPec != null)
                         {
                             job = tempPec.enName;
                         }
-                        //翻译
-                        else
-                        {
-                        }
                     }
                     builder.MoveToCell(0, i + 1, 4, 0);
                     builder.Write(job);
                 }
+
+                #endregion
+
+
+                #region 旧翻译英文处理
+
+                ////string transStrRes = "0 & Provincial Health & Health Commission Deputy Director | 1 & Provincial People's Hospital & Provincial People's Hospital Chief Accountant | 2 & Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College & North Sichuan Medical College | 3 & Provincial Health Commission Planning & Provincial Health Commission Planning and Information Division Director | 4 &-& Deputy Director | 5 & Provincial Health Commission population and Family Division & Provincial Health Commission population and Family Division Director";
+                //string transStrRes = "";
+
+                //if (transStrRes1.Length > 0)
+                //{
+                //    transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
+                //}
+
+                ////0、 Deputy Director of the Provincial Health and Health Commission | 1、 Chief Accountant of the provincial People's Hospital | 2、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 3、 Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director | 5、 Director of the population and Family Department of the Provincial Health and Health Commission | 3、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 4、 Deputy Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director of the population and Family Department of the Provincial Health and Health Commission | 5、 Director of the population and Family Department of the Provincial Health and Health Commission
+                ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
+                ////List<string> transArray = new List<string> { };
+                //List<TranslateInfo> transArray = new List<TranslateInfo>();
+
+                //if (transStrRes.Contains("|"))
+                //{
+                //    string[] transArray1 = transStrRes.Split('|');
+                //    if (transArray1.Length > 0)
+                //    {
+                //        foreach (var item in transArray1)
+                //        {
+                //            if (item.Contains("&"))
+                //            {
+                //                string[] transArray2 = item.Split('&');
+                //                int index = 0;
+                //                string companyName = "", job = "";
+
+                //                if (transArray2.Length > 0)
+                //                {
+                //                    bool success = int.TryParse(transArray2[0].Trim(), out index);
+                //                    if (1 < transArray2.Length) companyName = transArray2[1];
+                //                    if (2 < transArray2.Length) job = transArray2[2];
+                //                }
+
+                //                transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
+                //            }
+                //        }
+                //    }
+                //}
+
+                ////循环赋值
+                //for (int i = 0; i < DcList.Count; i++)
+                //{
+                //    string PYName = "";
+                //    if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
+                //    {
+                //        string PY_Last = DcList[i].Pinyin.Split('/')[0];
+                //        string PY_First = DcList[i].Pinyin.Split('/')[1];
+                //        PYName = PY_First + " " + PY_Last;
+                //    }
+                //    else
+                //    {
+                //        string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
+                //        string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
+                //        PYName = PY_First + " " + PY_Last;
+                //    }
+                //    builder.MoveToCell(0, i + 1, 0, 0);
+                //    builder.Write(PYName);
+
+                //    string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
+                //    builder.MoveToCell(0, i + 1, 1, 0);
+                //    builder.Write(sex);
+
+                //    DateTime birthDt;
+                //    bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
+                //    string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
+                //    builder.MoveToCell(0, i + 1, 2, 0);
+                //    builder.Write(birthday);
+
+                //    string company = string.Empty, job = string.Empty;
+                //    var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
+                //    if (dcTransInfo != null)
+                //    {
+                //        company = dcTransInfo.CompanyName;
+                //        job = dcTransInfo.Job;
+                //    }
+
+                //    if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
+                //    {
+                //        //查询对照表
+                //        Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
+                //        if (tempCec != null)
+                //        {
+                //            company = tempCec.enName;
+                //        }
+                //        //翻译
+                //        else
+                //        {
+
+                //        }
+                //    }
+
+                //    builder.MoveToCell(0, i + 1, 3, 0);
+                //    builder.Write(company);
+
+                //    if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
+                //    {
+                //        //查询对照表
+                //        Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
+                //        if (tempPec != null)
+                //        {
+                //            job = tempPec.enName;
+                //        }
+                //        //翻译
+                //        else
+                //        {
+                //        }
+                //    }
+                //    builder.MoveToCell(0, i + 1, 4, 0);
+                //    builder.Write(job);
+                //}
+
+                #endregion
             }
 
             //删除多余行