InvalidDataMessageJob.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using Microsoft.EntityFrameworkCore;
  2. using Quartz;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. using wispro.sp.entity;
  9. namespace wispro.sp.api.Job
  10. {
  11. public class InvalidDataMessageJob : IJob
  12. {
  13. public Task Execute(IJobExecutionContext context)
  14. {
  15. spDbContext spDb = new spDbContext();
  16. var lstItem = spDb.PerformanceItems.Where<PerformanceItem>(p =>
  17. (p.AgentFeedbackMemo != "已算绩效" && p.CalMonth.Status == 0 && !p.CaseNo.StartsWith("J")
  18. && (p.BasePoint ==null || (string.IsNullOrEmpty(p.CaseCoefficient) && p.Type =="新申请")
  19. || (p.Type =="OA" && string.IsNullOrEmpty(p.CaseCoefficient) && p.DoItemCoefficient =="实质")
  20. || (string.IsNullOrEmpty(p.DoItemCoefficient))
  21. )))
  22. .Include(p => p.Reviewer)
  23. .Include(p => p.CalMonth)
  24. .Include(p => p.Customer)
  25. .Include(p => p.WorkflowUser)
  26. .ToList<PerformanceItem>();
  27. if (lstItem.Count > 0)
  28. {
  29. DataTable dt = new DataTable();
  30. dt.Columns.Add("我方文号");
  31. dt.Columns.Add("业务人员");
  32. dt.Columns.Add("申请国家");
  33. dt.Columns.Add("客户名称");
  34. dt.Columns.Add("专利类型");
  35. dt.Columns.Add("处理事项");
  36. dt.Columns.Add("案件阶段");
  37. dt.Columns.Add("案件系数");
  38. dt.Columns.Add("处理事项系数");
  39. dt.Columns.Add("案件状态");
  40. dt.Columns.Add("翻译字数");
  41. dt.Columns.Add("基础点数");
  42. dt.Columns.Add("绩效类型");
  43. dt.Columns.Add("备注");
  44. foreach (var p in lstItem)
  45. {
  46. DataRow row = dt.NewRow();
  47. row["我方文号"] = p.CaseNo;
  48. row["专利类型"] = p.ApplicationType;
  49. row["处理事项"] = p.DoItem;
  50. row["案件阶段"] = p.CaseStage;
  51. row["案件系数"] = p.CaseCoefficient;
  52. row["处理事项系数"] = p.DoItemCoefficient;
  53. row["案件状态"] = p.CaseState;
  54. row["翻译字数"] = p.WordCount;
  55. row["基础点数"] = p.BasePoint;
  56. row["绩效类型"] = p.Type;
  57. row["备注"] = p.CaseMemo;
  58. row["客户名称"] = p.ApplicationName;
  59. row["申请国家"] = p.Country;
  60. if (p.WorkflowUser != null)
  61. {
  62. row["业务人员"] = p.WorkflowUser.Name;
  63. }
  64. dt.Rows.Add(row);
  65. }
  66. string strPath = $"c:\\temp\\{DateTime.Now.ToString("yyyyMMddhhmmss")}-JXList.xlsx";
  67. utility.NPOIExcel.DataTableToExcel(dt, strPath);
  68. string strBody = $"<div style=\"position:absolute;width:800;height:300;margin-top:50px;margin-left:200px;margin-right:200px;box-shadow:0px 0px 3px 3px #ccc \"><div style= \"margin-top: 20px; margin-left:20px;;font-size:14px; \">各位好!</div><div style= \"margin-top: 25px; margin-left:20px;font-size:14px; \"><div>附件为本期绩效记录中疑似有问题数据,请检查并补充缺失数据!</div><div style= \"margin-top: 100px;margin-right:15px; padding-bottom: 20px; font-size:14px;color:#888888;float:right; \">小美集团绩效管理系统</div></div>";
  69. string strKey = wispro.sp.utility.ConfigHelper.GetSectionValue("InvalidDataMessageMails");
  70. if (!string.IsNullOrEmpty(strKey))
  71. {
  72. string[] mails = strKey.Trim().Split(',');
  73. foreach (string mail in mails)
  74. {
  75. string[] strings = mail.Split("|");
  76. _ = QuartzUtil.AddMailJob("疑似有问题绩效数据清单", strBody, strings[0], strings[1], strPath);
  77. }
  78. }
  79. //_ = QuartzUtil.AddMailJob("疑似有问题绩效数据清单", strBody, "罗才洋", "luocaiyang@china-wispro.com", strPath);
  80. //_ = QuartzUtil.AddMailJob("疑似有问题绩效数据清单", strBody, "何青瓦", "heqingwa@china-wispro.com", strPath);
  81. //_ = QuartzUtil.AddMailJob("疑似有问题绩效数据清单", strBody, "钟子敏", "zhongzimin@china-wispro.com", strPath);
  82. ////_ = QuartzUtil.AddMailJob("疑似有问题绩效数据清单", strBody, "夏敏", "xiamin@china-wispro.com", strPath);
  83. //_ = QuartzUtil.AddMailJob("疑似有问题绩效数据清单", strBody, "吴芳", "wufang@china-wispro.com", strPath);
  84. //_ = QuartzUtil.AddMailJob("疑似有问题绩效数据清单", strBody, "邢丽霞", "xinglixia@china-wispro.com", strPath);
  85. ////_ = QuartzUtil.AddMailJob("疑似有问题绩效数据清单", strBody, "孙心洁", "sunxinjie@china-wispro.com", strPath);
  86. //_ = QuartzUtil.AddMailJob("疑似有问题绩效数据清单", strBody, "李诗华", "lishihua@china-wispro.com", strPath);
  87. //_ = QuartzUtil.AddMailJob("疑似有问题绩效数据清单", strBody, "田婵玉", "tianchanyu@china-wispro.com", strPath);
  88. }
  89. return Task.CompletedTask;
  90. }
  91. }
  92. }