ExcelService.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. using Core.Dtos;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NPOI.HSSF.Record.CF;
  5. using OfficeOpenXml;
  6. using OfficeOpenXml.ConditionalFormatting;
  7. using OfficeOpenXml.Drawing.Chart;
  8. using OfficeOpenXml.Style;
  9. using ProductionLineMonitor.Application.Services.FaultService;
  10. using ProductionLineMonitor.Application.Services.OEEService;
  11. using ProductionLineMonitor.Core.Dtos;
  12. using ProductionLineMonitor.Core.IRepositories;
  13. using System;
  14. using System.Drawing;
  15. using System.IO;
  16. using System.Linq;
  17. using System.Security.Claims;
  18. using System.Text;
  19. using static ProductionLineMonitor.Core.Utils.EmailHelper;
  20. namespace ProductionLineMonitor.Application.Services
  21. {
  22. public class ExcelService : IExcelService
  23. {
  24. private readonly IUnitOfWork _unitOfWork;
  25. private readonly IOEEService _oeeService;
  26. private readonly IFaultService _faultService;
  27. public ExcelService(
  28. IUnitOfWork unitOfWork,
  29. IOEEService oEEService,
  30. IFaultService faultService)
  31. {
  32. _unitOfWork = unitOfWork;
  33. _oeeService = oEEService;
  34. _faultService = faultService;
  35. }
  36. public bool EquipmentOperationReport(DateTime dateTime)
  37. {
  38. string date = dateTime.ToString("yyyy-MM-dd");
  39. if (dateTime.Hour == 8) {
  40. date = dateTime.AddDays(-1).ToString("yyyy-MM-dd");
  41. }
  42. string machineIdString = "";
  43. string receiverAppSettingName = "";
  44. bool isSend = false;
  45. using (StreamReader file = File.OpenText("D:\\ReportForms\\Email.json"))
  46. {
  47. using JsonTextReader reader = new JsonTextReader(file);
  48. JObject jsonObject = (JObject)JToken.ReadFrom(reader);
  49. machineIdString = jsonObject["UtilizationRateEmail"]["MachineIDs"].ToString();
  50. receiverAppSettingName = jsonObject["UtilizationRateEmail"]["ReceiverAppSettingName"].ToString();
  51. isSend = jsonObject["UtilizationRateEmail"]["IsSend"].ToObject<bool>();
  52. }
  53. if (string.IsNullOrEmpty(machineIdString))
  54. {
  55. return false;
  56. }
  57. DateTime startTime = DateTime.Parse($"{date} 08:00:00");
  58. DateTime endTime= startTime.AddDays(1);
  59. DateTime dataStartTime = endTime.AddDays(-7);
  60. // 文件夹存储路径
  61. string folderPath = "D:\\ReportForms";
  62. if (!Directory.Exists(folderPath))
  63. Directory.CreateDirectory(folderPath);
  64. string excelName = $"{DateTime.Now:yyyyMMddHHmmss}.xlsx";
  65. var path = Path.Combine(folderPath, excelName);
  66. string[] machineIds = machineIdString.Split(',');
  67. foreach (var machineId in machineIds)
  68. {
  69. var machine = _unitOfWork.MachineRepository.GetById(machineId);
  70. var line = _unitOfWork.ProductionLineRepository.FirstOrDefault(x => x.Id == machine.ProductionLineId);
  71. var machineOEE = _oeeService.GetOEE(machineId, dataStartTime.ToString("yyyy-MM-dd"), startTime.ToString("yyyy-MM-dd"));
  72. var machineHourDatas = _unitOfWork.MachineOutPutPerHourRepository.GetList(
  73. x =>
  74. x.MachineId == machine.Id &&
  75. x.DataTime >= startTime &&
  76. x.DataTime < endTime).OrderBy(o => o.DataTime).ToList();
  77. FileInfo file = new FileInfo(path);
  78. //ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
  79. using ExcelPackage package = new ExcelPackage(file);
  80. ExcelWorksheet worksheet = package.Workbook.Worksheets.Add($"{line.Name} {machine.Name}");
  81. worksheet.View.ZoomScale = 80;
  82. worksheet.Cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
  83. #region tab header
  84. worksheet.Cells[1, 1].Value = "NO";
  85. worksheet.Cells[1, 2].Value = "时间";
  86. worksheet.Cells[1, 3].Value = "稼动率(%)";
  87. worksheet.Cells[1, 4].Value = "待机率(%)";
  88. worksheet.Cells[1, 5].Value = "报警率(%)";
  89. worksheet.Cells[1, 6].Value = "换料率(%)";
  90. worksheet.Cells[1, 7].Value = "产能(pcs)";
  91. worksheet.Cells[1, 8].Value = "稼动(min)";
  92. worksheet.Cells[1, 9].Value = "待机(min)";
  93. worksheet.Cells[1, 10].Value = "报警(min)";
  94. worksheet.Cells[1, 11].Value = "换料(min)";
  95. worksheet.Cells[1, 12].Value = "合计(min)";
  96. worksheet.Cells[1, 15].Value = $"{startTime:yyyy-MM-dd} 早班";
  97. worksheet.Cells[1, 15, 1, 24].Merge = true;
  98. worksheet.Cells[2, 15].Value = "NO";
  99. worksheet.Cells[2, 16].Value = "时段";
  100. worksheet.Cells[2, 17].Value = "机种";
  101. worksheet.Cells[2, 18].Value = "运行时间";
  102. worksheet.Cells[2, 19].Value = "报警时间";
  103. worksheet.Cells[2, 20].Value = "待料时间";
  104. worksheet.Cells[2, 21].Value = "换料时间";
  105. worksheet.Cells[2, 22].Value = "产能";
  106. worksheet.Cells[2, 23].Value = "TT";
  107. worksheet.Cells[2, 24].Value = "报警次数";
  108. worksheet.Cells[16, 15].Value = "NO";
  109. worksheet.Cells[16, 16].Value = "故障码";
  110. worksheet.Cells[16, 17].Value = "故障详情";
  111. worksheet.Cells[16, 24].Value = "报警次数";
  112. worksheet.Cells[16, 17, 16, 23].Merge = true;
  113. worksheet.Cells[17, 17, 17, 23].Merge = true;
  114. worksheet.Cells[18, 17, 18, 23].Merge = true;
  115. worksheet.Cells[19, 17, 19, 23].Merge = true;
  116. worksheet.Cells[20, 17, 20, 23].Merge = true;
  117. worksheet.Cells[21, 17, 21, 23].Merge = true;
  118. worksheet.Cells[22, 17, 22, 23].Merge = true;
  119. worksheet.Cells[23, 17, 23, 23].Merge = true;
  120. worksheet.Cells[24, 17, 24, 23].Merge = true;
  121. worksheet.Cells[25, 17, 25, 23].Merge = true;
  122. worksheet.Cells[26, 17, 26, 23].Merge = true;
  123. worksheet.Cells[1, 26].Value = $"{startTime:yyyy-MM-dd} 夜班";
  124. worksheet.Cells[1, 26, 1, 35].Merge = true;
  125. worksheet.Cells[2, 26].Value = "NO";
  126. worksheet.Cells[2, 27].Value = "时段";
  127. worksheet.Cells[2, 28].Value = "机种";
  128. worksheet.Cells[2, 29].Value = "运行时间";
  129. worksheet.Cells[2, 30].Value = "报警时间";
  130. worksheet.Cells[2, 31].Value = "待料时间";
  131. worksheet.Cells[2, 32].Value = "换料时间";
  132. worksheet.Cells[2, 33].Value = "产能";
  133. worksheet.Cells[2, 34].Value = "TT";
  134. worksheet.Cells[2, 35].Value = "报警次数";
  135. worksheet.Cells[16, 26].Value = "NO";
  136. worksheet.Cells[16, 27].Value = "故障码";
  137. worksheet.Cells[16, 28].Value = "故障详情";
  138. worksheet.Cells[16, 35].Value = "报警次数";
  139. worksheet.Cells[16, 28, 16, 34].Merge = true;
  140. worksheet.Cells[17, 28, 17, 34].Merge = true;
  141. worksheet.Cells[18, 28, 18, 34].Merge = true;
  142. worksheet.Cells[19, 28, 19, 34].Merge = true;
  143. worksheet.Cells[20, 28, 20, 34].Merge = true;
  144. worksheet.Cells[21, 28, 21, 34].Merge = true;
  145. worksheet.Cells[22, 28, 22, 34].Merge = true;
  146. worksheet.Cells[23, 28, 23, 34].Merge = true;
  147. worksheet.Cells[24, 28, 24, 34].Merge = true;
  148. worksheet.Cells[25, 28, 25, 34].Merge = true;
  149. worksheet.Cells[26, 28, 26, 34].Merge = true;
  150. worksheet.Column(1).Width = 5;
  151. worksheet.Column(2).Width = 12;
  152. worksheet.Column(3).Width = 12;
  153. worksheet.Column(4).Width = 12;
  154. worksheet.Column(5).Width = 12;
  155. worksheet.Column(6).Width = 12;
  156. worksheet.Column(7).Width = 12;
  157. worksheet.Column(8).Width = 12;
  158. worksheet.Column(9).Width = 12;
  159. worksheet.Column(10).Width = 12;
  160. worksheet.Column(11).Width = 12;
  161. worksheet.Column(12).Width = 12;
  162. worksheet.Column(13).Width = 2;
  163. worksheet.Column(14).Width = 2;
  164. worksheet.Column(15).Width = 5;
  165. worksheet.Column(16).Width = 12;
  166. worksheet.Column(17).Width = 12;
  167. worksheet.Column(18).Width = 12;
  168. worksheet.Column(19).Width = 12;
  169. worksheet.Column(20).Width = 12;
  170. worksheet.Column(21).Width = 12;
  171. worksheet.Column(22).Width = 12;
  172. worksheet.Column(23).Width = 12;
  173. worksheet.Column(24).Width = 12;
  174. worksheet.Column(22).Width = 12;
  175. worksheet.Column(23).Width = 12;
  176. worksheet.Column(25).Width = 2;
  177. worksheet.Column(26).Width = 5;
  178. worksheet.Column(27).Width = 12;
  179. worksheet.Column(28).Width = 12;
  180. worksheet.Column(29).Width = 12;
  181. worksheet.Column(30).Width = 12;
  182. worksheet.Column(31).Width = 12;
  183. worksheet.Column(32).Width = 12;
  184. worksheet.Column(33).Width = 12;
  185. worksheet.Column(34).Width = 12;
  186. worksheet.Column(35).Width = 12;
  187. #endregion
  188. for (int i = 0; i < machineOEE.Count; i++)
  189. {
  190. worksheet.Cells[i + 2, 1].Value = i + 1;
  191. worksheet.Cells[i + 2, 2].Value = machineOEE[i].Date + " " + machineOEE[i].Shift;
  192. worksheet.Cells[i + 2, 3].Value = (int)machineOEE[i].RunTimeRate;
  193. worksheet.Cells[i + 2, 4].Value = (int)machineOEE[i].IdelTimeRate;
  194. worksheet.Cells[i + 2, 5].Value = (int)machineOEE[i].DownTimeRate;
  195. worksheet.Cells[i + 2, 6].Value = (int)machineOEE[i].LoadMATTimeRate;
  196. worksheet.Cells[i + 2, 7].Value = machineOEE[i].Outputs;
  197. worksheet.Cells[i + 2, 8].Value = machineOEE[i].RunTime / 60;
  198. worksheet.Cells[i + 2, 9].Value = machineOEE[i].IdelTime / 60;
  199. worksheet.Cells[i + 2, 10].Value = machineOEE[i].DownTime / 60;
  200. worksheet.Cells[i + 2, 11].Value = machineOEE[i].LoadMATTime / 60;
  201. worksheet.Cells[i + 2, 12].Value
  202. = (machineOEE[i].RunTime + machineOEE[i].IdelTime + machineOEE[i].DownTime + machineOEE[i].LoadMATTime) / 60;
  203. }
  204. if (machineHourDatas != null)
  205. {
  206. if (machineHourDatas.Count == 24)
  207. {
  208. {
  209. int autoSum = 0;
  210. int alarmTimeSum = 0;
  211. int idelSum = 0;
  212. int outputSum = 0;
  213. double ttSum = 0;
  214. int alarmSum = 0;
  215. int loadTimeSum = 0;
  216. for (int i = 0; i < 12; i++)
  217. {
  218. int auto = machineHourDatas[i].AutoRunTime.Value / 60;
  219. autoSum += auto;
  220. int alarmTime = machineHourDatas[i].AlarmTime.Value / 60;
  221. alarmTimeSum += alarmTime;
  222. int idel = machineHourDatas[i].IdleTime.Value / 60;
  223. idelSum += idel;
  224. int output = machineHourDatas[i].OutPut.Value;
  225. outputSum += output;
  226. double tt = machineHourDatas[i].TT;
  227. //ttSum += tt;
  228. int alarm = machineHourDatas[i].AlarmSum.Value;
  229. alarmSum += alarm;
  230. int loadTime = machineHourDatas[i].LoadMATTime.Value / 60;
  231. loadTimeSum += loadTime;
  232. worksheet.Cells[i + 3, 15].Value = i + 1;
  233. worksheet.Cells[i + 3, 16].Value = machineHourDatas[i].Period;
  234. worksheet.Cells[i + 3, 17].Value = machineHourDatas[i].ModuleType;
  235. worksheet.Cells[i + 3, 18].Value = auto;
  236. worksheet.Cells[i + 3, 19].Value = alarmTime;
  237. worksheet.Cells[i + 3, 20].Value = idel;
  238. worksheet.Cells[i + 3, 21].Value = loadTime;
  239. worksheet.Cells[i + 3, 22].Value = output;
  240. worksheet.Cells[i + 3, 23].Value = Math.Round(tt, 2);
  241. worksheet.Cells[i + 3, 24].Value = alarm;
  242. }
  243. worksheet.Cells[15, 15].Value = "合计";
  244. worksheet.Cells[15, 15, 15, 17].Merge = true;
  245. worksheet.Cells[15, 18].Value = autoSum;
  246. worksheet.Cells[15, 19].Value = alarmTimeSum;
  247. worksheet.Cells[15, 20].Value = idelSum;
  248. worksheet.Cells[15, 21].Value = loadTimeSum;
  249. worksheet.Cells[15, 22].Value = outputSum;
  250. if (outputSum != 0)
  251. ttSum = autoSum * 60.0 / outputSum;
  252. else
  253. ttSum = 0;
  254. worksheet.Cells[15, 23].Value = Math.Round(ttSum, 2);
  255. worksheet.Cells[15, 24].Value = alarmSum;
  256. var faults = _faultService.GetFaultFrequencyTop10(machineId, startTime, startTime.AddHours(12), "安全门,门禁,提示上料,提示卸料");
  257. for (int i = 0; i < faults.Count; i++)
  258. {
  259. worksheet.Cells[17 + i, 15].Value = i + 1;
  260. worksheet.Cells[17 + i, 16].Value = faults[i].FaultCode;
  261. worksheet.Cells[17 + i, 17].Value = faults[i].FaultInfo;
  262. worksheet.Cells[17 + i, 24].Value = faults[i].Count;
  263. }
  264. }
  265. {
  266. int autoSum = 0;
  267. int alarmTimeSum = 0;
  268. int idelSum = 0;
  269. int outputSum = 0;
  270. double ttSum = 0;
  271. int alarmSum = 0;
  272. int loadTimeSum = 0;
  273. for (int i = 12; i < 24; i++)
  274. {
  275. int auto = machineHourDatas[i].AutoRunTime.Value / 60;
  276. autoSum += auto;
  277. int alarmTime = machineHourDatas[i].AlarmTime.Value / 60;
  278. alarmTimeSum += alarmTime;
  279. int idel = machineHourDatas[i].IdleTime.Value / 60;
  280. idelSum += idel;
  281. int output = machineHourDatas[i].OutPut.Value;
  282. outputSum += output;
  283. double tt = machineHourDatas[i].TT;
  284. //ttSum += tt;
  285. int alarm = machineHourDatas[i].AlarmSum.Value;
  286. alarmSum += alarm;
  287. int loadTime = machineHourDatas[i].LoadMATTime.Value / 60;
  288. loadTimeSum += loadTime;
  289. worksheet.Cells[i - 12 + 3, 26].Value = i + 1;
  290. worksheet.Cells[i - 12 + 3, 27].Value = machineHourDatas[i].Period;
  291. worksheet.Cells[i - 12 + 3, 28].Value = machineHourDatas[i].ModuleType;
  292. worksheet.Cells[i - 12 + 3, 29].Value = auto;
  293. worksheet.Cells[i - 12 + 3, 30].Value = alarmTime;
  294. worksheet.Cells[i - 12 + 3, 31].Value = idel;
  295. worksheet.Cells[i - 12 + 3, 32].Value = loadTime;
  296. worksheet.Cells[i - 12 + 3, 33].Value = output;
  297. worksheet.Cells[i - 12 + 3, 34].Value = Math.Round(tt, 2);
  298. worksheet.Cells[i - 12 + 3, 35].Value = alarm;
  299. }
  300. worksheet.Cells[15, 26].Value = "合计";
  301. worksheet.Cells[15, 26, 15, 28].Merge = true;
  302. worksheet.Cells[15, 29].Value = autoSum;
  303. worksheet.Cells[15, 30].Value = alarmTimeSum;
  304. worksheet.Cells[15, 31].Value = idelSum;
  305. worksheet.Cells[15, 32].Value = loadTimeSum;
  306. worksheet.Cells[15, 33].Value = outputSum;
  307. if (outputSum != 0)
  308. ttSum = autoSum * 60.0 / outputSum;
  309. else
  310. ttSum = 0;
  311. worksheet.Cells[15, 34].Value = Math.Round(ttSum, 2);
  312. worksheet.Cells[15, 35].Value = alarmSum;
  313. var faults = _faultService.GetFaultFrequencyTop10(machineId, startTime.AddHours(12), startTime.AddHours(24), "安全门,门禁,提示上料,提示卸料");
  314. for (int i = 0; i < faults.Count; i++)
  315. {
  316. worksheet.Cells[17 + i, 26].Value = i + 1;
  317. worksheet.Cells[17 + i, 27].Value = faults[i].FaultCode;
  318. worksheet.Cells[17 + i, 28].Value = faults[i].FaultInfo;
  319. worksheet.Cells[17 + i, 35].Value = faults[i].Count;
  320. }
  321. }
  322. }
  323. }
  324. //var faultFrequencys = _faultService.GetFaultFrequencyTop10ByShift(
  325. // machine.Id, dataStartTime, endTime, "安全门,门禁,提示上料,提示卸料");
  326. //var tables = new FaultFrequencyByShiftTable(faultFrequencys);
  327. //ExcelWorksheet worksheet1 = package.Workbook.Worksheets.Add($"{line.Name} {machine.Name} 报警");
  328. //worksheet1.View.ZoomScale = 80;
  329. //worksheet1.Cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
  330. //worksheet1.Column(1).Width = 5;
  331. //worksheet1.Column(2).Width = 10;
  332. //worksheet1.Column(3).Width = 30;
  333. //worksheet1.Cells[1, 1].Value = "NO";
  334. //worksheet1.Cells[1, 2].Value = "Code";
  335. //worksheet1.Cells[1, 3].Value = "Name";
  336. //for (int i = 0; i < tables.Shifts.Count(); i++)
  337. //{
  338. // worksheet1.Column(i + 4).Width = 20;
  339. // worksheet1.Cells[1, i + 4].Value = tables.Shifts[i];
  340. //}
  341. //for (int i = 0; i < tables.Nos.Count; i++)
  342. //{
  343. // worksheet1.Cells[i + 2, 1].Value = tables.Nos[i];
  344. // worksheet1.Cells[i + 2, 2].Value = tables.FaultCodes[i];
  345. // worksheet1.Cells[i + 2, 3].Value = tables.FaultInfos[i];
  346. // for (int j = 0; j < tables.Shifts.Count(); j++)
  347. // {
  348. // worksheet1.Cells[i + 2, j + 4].Value = tables.Counts[j, i];
  349. // }
  350. //}
  351. //var databar = worksheet1.Cells["D2:Q33"].ConditionalFormatting.AddDatabar(Color.Red);
  352. //// 创建数据条条件格式对象
  353. //ExcelConditionalFormattingDataBar dataBarConditionalFormatting = (ExcelConditionalFormattingDataBar)worksheet.Cells["D2:Q33"].ConditionalFormatting;
  354. //// 设置渐变填充
  355. //dataBarConditionalFormatting.BarFill.Type = ExcelFillStyle.DarkGray;
  356. ExcelChartSerie chartSerie;
  357. ExcelChart chart = worksheet.Drawings.AddChart("chart", eChartType.ColumnStacked);
  358. chart.YAxis.MinValue = 0;
  359. chart.YAxis.MaxValue = 100;
  360. chart.YAxis.Format = "0 \"%\"";
  361. chart.Legend.Position = eLegendPosition.Bottom;
  362. chart.Legend.Add();
  363. chart.Title.Text = "设备稼动曲线"; //设置图表的名称
  364. chart.SetPosition(540, 20); //设置图表位置
  365. chart.SetSize(1000, 400); //设置图表大小
  366. chart.ShowHiddenData = true;
  367. chartSerie = chart.Series.Add(worksheet.Cells[2, 3, machineOEE.Count + 1, 3], worksheet.Cells[2, 2, machineOEE.Count + 1, 2]);
  368. chartSerie.HeaderAddress = worksheet.Cells[1, 3];
  369. chartSerie = chart.Series.Add(worksheet.Cells[2, 4, machineOEE.Count + 1, 4], worksheet.Cells[2, 2, machineOEE.Count + 1, 2]);
  370. chartSerie.HeaderAddress = worksheet.Cells[1, 4];
  371. chartSerie = chart.Series.Add(worksheet.Cells[2, 5, machineOEE.Count + 1, 5], worksheet.Cells[2, 2, machineOEE.Count + 1, 2]);
  372. chartSerie.HeaderAddress = worksheet.Cells[1, 5];
  373. chartSerie = chart.Series.Add(worksheet.Cells[2, 6, machineOEE.Count + 1, 6], worksheet.Cells[2, 2, machineOEE.Count + 1, 2]);
  374. chartSerie.HeaderAddress = worksheet.Cells[1, 6];
  375. //var chartType2 = chart.PlotArea.ChartTypes.Add(eChartType.Line);
  376. //chartType2.UseSecondaryAxis = true;
  377. //chartType2.YAxis.Format = "0 \"pcs\"";
  378. //chartSerie = chartType2.Series.Add(worksheet.Cells[2, 6, machineOEE.Count + 1, 6], worksheet.Cells[2, 2, machineOEE.Count + 1, 2]);
  379. //chartSerie.HeaderAddress = worksheet.Cells[1, 6];
  380. foreach (var item in chart.Series)
  381. {
  382. var pieSerie = (ExcelBarChartSerie)item;
  383. pieSerie.DataLabel.ShowValue = true;
  384. }
  385. ExcelChart chart1 = worksheet.Drawings.AddChart("chart1", eChartType.ColumnStacked);
  386. chart1.Legend.Position = eLegendPosition.Bottom;
  387. chart1.Legend.Add();
  388. chart1.Title.Text = "设备产能曲线"; //设置图表的名称
  389. chart1.SetPosition(540, 1030); //设置图表位置
  390. chart1.SetSize(1000, 400); //设置图表大小
  391. chart1.ShowHiddenData = true;
  392. chart1.YAxis.Format = "0 \"pcs\"";
  393. ExcelChartSerie chartSerie1;
  394. chartSerie1 = chart1.Series.Add(worksheet.Cells[2, 7, machineOEE.Count + 1, 7], worksheet.Cells[2, 2, machineOEE.Count + 1, 2]);
  395. chartSerie1.HeaderAddress = worksheet.Cells[1, 7];
  396. foreach (var item in chart1.Series)
  397. {
  398. var pieSerie = (ExcelBarChartSerie)item;
  399. pieSerie.DataLabel.ShowValue = true;
  400. }
  401. package.Save();
  402. }
  403. if (!isSend)
  404. {
  405. return false;
  406. }
  407. if (string.IsNullOrEmpty(receiverAppSettingName))
  408. {
  409. return false;
  410. }
  411. SendMail(
  412. MailType.Message,
  413. receiverAppSettingName,
  414. "",
  415. "",
  416. "EQP.EAPAUTO01@eink.com",
  417. "",
  418. $"稼动数据 -- {excelName}",
  419. "",
  420. new string[] { path },
  421. Encoding.UTF8);
  422. return true;
  423. }
  424. }
  425. }