调整优化代码逻辑

develop
old易 2024-07-03 14:05:21 +08:00
parent 3341f9f729
commit 41841a3bc9
5 changed files with 39 additions and 28 deletions

View File

@ -257,6 +257,7 @@ namespace New_College.Api.Controllers.Front
var firstmodels = planmajordesc.Where(e => e.UniversityName == s.UniversityName).FirstOrDefault(); var firstmodels = planmajordesc.Where(e => e.UniversityName == s.UniversityName).FirstOrDefault();
planmajordesc.Where(ww => planids.Contains(ww.ID)).ToList().ForEach(a => planmajordesc.Where(ww => planids.Contains(ww.ID)).ToList().ForEach(a =>
{ {
string remark = string.IsNullOrWhiteSpace(a.Remark) ? "" : "("+a.Remark + ")";
tableDetailItemsViews.Add(new VolunteerItemsViewMinExcelAttr() tableDetailItemsViews.Add(new VolunteerItemsViewMinExcelAttr()
{ {
UniversityName = s.UniversityName, UniversityName = s.UniversityName,
@ -264,7 +265,7 @@ namespace New_College.Api.Controllers.Front
AreaName = planstatus ? firstmodels.Province != null ? firstmodels.Province + "|" + (planstatus ? firstmodels.City : "") : "" : "", AreaName = planstatus ? firstmodels.Province != null ? firstmodels.Province + "|" + (planstatus ? firstmodels.City : "") : "" : "",
Nature = planstatus ? firstmodels.Nature != null ? firstmodels.Nature : "" : "", Nature = planstatus ? firstmodels.Nature != null ? firstmodels.Nature : "" : "",
fee = string.IsNullOrEmpty(a.Fee) ? "--" : a.Fee, fee = string.IsNullOrEmpty(a.Fee) ? "--" : a.Fee,
Major = a.MajorName, Major = a.MajorName + remark,
MajorCode = a.MajorCode, MajorCode = a.MajorCode,
// MajorGroup = a.MajorGroup, // MajorGroup = a.MajorGroup,
//// MajorRemark = a.Remark, //// MajorRemark = a.Remark,

View File

@ -111,6 +111,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Update="wwwroot\fonts\AlimamaDongFangDaKai-Regular.otf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\fonts\NotoSansCJKsc-Regular.otf"> <Content Update="wwwroot\fonts\NotoSansCJKsc-Regular.otf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>

View File

@ -33,6 +33,8 @@ namespace New_College.Tasks
} }
private void DoWork(object state) private void DoWork(object state)
{
try
{ {
HtmlAgHelper agHelper = new HtmlAgHelper(); HtmlAgHelper agHelper = new HtmlAgHelper();
var list = agHelper.HtmlCreatePageData(); var list = agHelper.HtmlCreatePageData();
@ -63,6 +65,11 @@ namespace New_College.Tasks
}); });
ConsoleHelper.WriteWarningLine($"Job spider success {DateTime.Now}-{list.Count}"); ConsoleHelper.WriteWarningLine($"Job spider success {DateTime.Now}-{list.Count}");
} }
catch (Exception ex)
{
ConsoleHelper.WriteWarningLine($"Job spider 抓取异常");
}
}
public Task StopAsync(CancellationToken cancellationToken) public Task StopAsync(CancellationToken cancellationToken)
{ {

View File

@ -38,7 +38,7 @@ namespace PDFGenerateApi
pdf.SetDefaultPageSize(pageSize); pdf.SetDefaultPageSize(pageSize);
Document document = new Document(pdf); Document document = new Document(pdf);
// 加载中文字体 // 加载中文字体
string fontsPath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "fonts", "NotoSansCJKsc-Regular.otf"); string fontsPath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "fonts", "AlimamaDongFangDaKai-Regular.otf");
//if (!File.Exists(fontsPath)) //if (!File.Exists(fontsPath))
//{ //{
// bool aa = true; // bool aa = true;
@ -135,11 +135,11 @@ namespace PDFGenerateApi
h++; h++;
if (h == 4) if (h == 4)
{ {
table.AddHeaderCell(new Cell().Add(new Paragraph(header).SetWidth(85).SetFont(font).SetBold().SetTextAlignment(TextAlignment.CENTER))); table.AddHeaderCell(new Cell().Add(new Paragraph(header).SetWidth(120).SetFont(font).SetBold().SetTextAlignment(TextAlignment.CENTER)));
} }
else else
{ {
table.AddHeaderCell(new Cell().Add(new Paragraph(header).SetFont(font).SetBold().SetTextAlignment(TextAlignment.CENTER))); table.AddHeaderCell(new Cell().Add(new Paragraph(header).SetWidth(50).SetFont(font).SetBold().SetTextAlignment(TextAlignment.CENTER)));
} }
} }
dataList.ForEach(a => dataList.ForEach(a =>