|
@@ -8,6 +8,8 @@ using Microsoft.Data.SqlClient;
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
using Microsoft.Extensions.Caching.Memory;
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
+using NPOI.SS.UserModel;
|
|
|
+using NPOI.XSSF.UserModel;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
@@ -823,6 +825,170 @@ namespace wispro.sp.api.Controllers
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ [Authorize]
|
|
|
+ public FileProcessTask GetStaticsPointReport(int Year, int Month)
|
|
|
+ {
|
|
|
+ CalMonth calMonth = Context.CalMonths.FirstOrDefault(c => c.Year == Year && c.Month == Month);
|
|
|
+ if (calMonth != null)
|
|
|
+ {
|
|
|
+ var filename = $"{DateTime.Now.ToString("yyyyMMddhhmmss")}-{calMonth.Year}{calMonth.Month}代理人案件绩效点数清单.xlsx";
|
|
|
+ var attachfileSavePath = utility.ConfigHelper.GetSectionValue("AttachFileSavePath");
|
|
|
+ var filePath = Path.Combine(attachfileSavePath, filename);
|
|
|
+
|
|
|
+ var fileTask = new FileProcessTask()
|
|
|
+ {
|
|
|
+ Id = Guid.NewGuid().ToString(),
|
|
|
+ FileName = filename,
|
|
|
+ FilePath = filePath,
|
|
|
+ Processed = 0
|
|
|
+ };
|
|
|
+
|
|
|
+ fileTaskService.Add(fileTask);
|
|
|
+
|
|
|
+ ExportDataResult result = new ExportDataResult()
|
|
|
+ {
|
|
|
+ fileTask = fileTask,
|
|
|
+ calMonth = calMonth
|
|
|
+ };
|
|
|
+
|
|
|
+ System.Threading.Thread t = new System.Threading.Thread(new ParameterizedThreadStart(ExportStaticPointReport));
|
|
|
+ t.Start(result);
|
|
|
+
|
|
|
+ return fileTask;
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ private void ExportStaticPointReport(object exportDataResult)
|
|
|
+ {
|
|
|
+ ExportDataResult result = (ExportDataResult)exportDataResult;
|
|
|
+ FileProcessTask file = result.fileTask;
|
|
|
+ CalMonth calMonth = result.calMonth;
|
|
|
+
|
|
|
+ //var StatisticsResults = _CalMyStatistics(calMonth);
|
|
|
+ string strSQL = @" SELECT Staff.Name as 姓名,PerformanceItem.CaseNo as 案号,
|
|
|
+ StaffStatistics.jxType as 点数类型,
|
|
|
+ StaffStatistics.totalBasePoint as 基础点数,
|
|
|
+ StaffStatistics.totalActuallyPoint as 调整后点数
|
|
|
+ ,StaffStatistics.FinianlPoint as 最终点数,
|
|
|
+ StaffStatistics.nanduXS as 难度系数,
|
|
|
+ StaffStatistics.S as S案件数,
|
|
|
+ StaffStatistics.A as A案件数,
|
|
|
+ StaffStatistics.B as B案件数,
|
|
|
+ StaffStatistics.C as C案件数,
|
|
|
+ StaffStatistics.D as D案件数
|
|
|
+ FROM StaffStatistics,Staff,PerformanceItem
|
|
|
+ WHERE StaffStatistics.ItemId =PerformanceItem.Id
|
|
|
+ and StaffStatistics.StaffId = staff.Id
|
|
|
+ and PerformanceItem.CalMonthId =@CalMonthId
|
|
|
+ order by Staff.Name ";
|
|
|
+
|
|
|
+ DataTable dt = new DataTable();
|
|
|
+ spDbContext spDb = new spDbContext();
|
|
|
+ using (var conn = spDb.Database.GetDbConnection())
|
|
|
+ {
|
|
|
+ conn.Open();
|
|
|
+ var cmd = conn.CreateCommand();
|
|
|
+ cmd.CommandText = strSQL;
|
|
|
+ cmd.CommandType = CommandType.Text;
|
|
|
+
|
|
|
+ cmd.Parameters.Add(new SqlParameter("CalMonthId", calMonth.Id));
|
|
|
+ using (var reader = cmd.ExecuteReader())
|
|
|
+ {
|
|
|
+ dt.Load(reader);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ NPOIExcel.DataTableToExcel(dt, result.fileTask.FilePath);
|
|
|
+
|
|
|
+ #region 添加月度的难度系数和各等级案件数量
|
|
|
+ /*
|
|
|
+ // 检查文件是否是只读的
|
|
|
+ if ((System.IO.File.GetAttributes(result.fileTask.FilePath) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
|
|
|
+ {
|
|
|
+ // 取消只读属性
|
|
|
+ System.IO.File.SetAttributes(result.fileTask.FilePath, System.IO.File.GetAttributes(result.fileTask.FilePath) & ~FileAttributes.ReadOnly);
|
|
|
+ }
|
|
|
+
|
|
|
+ using (FileStream f = new FileStream(result.fileTask.FilePath, FileMode.Open, FileAccess.ReadWrite))
|
|
|
+ {
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook(f);
|
|
|
+
|
|
|
+ ISheet sheet = workbook.GetSheetAt(0);
|
|
|
+
|
|
|
+ ICellStyle style = workbook.CreateCellStyle();
|
|
|
+
|
|
|
+ // 设置边框
|
|
|
+ style.BorderTop = BorderStyle.Thin;
|
|
|
+ style.BorderBottom = BorderStyle.Thin;
|
|
|
+ style.BorderLeft = BorderStyle.Thin;
|
|
|
+ style.BorderRight = BorderStyle.Thin;
|
|
|
+
|
|
|
+ sheet.ShiftRows(0, sheet.LastRowNum, 1);
|
|
|
+ sheet.ShiftRows(0, sheet.LastRowNum, 1);
|
|
|
+
|
|
|
+ IRow newRow = sheet.CreateRow(0);
|
|
|
+ ICell cell = newRow.CreateCell(0);
|
|
|
+ cell.SetCellValue((calMonth.NanduXS != null) ? calMonth.NanduXS.Value : 0.0);
|
|
|
+ cell.CellStyle = style;
|
|
|
+
|
|
|
+ cell = newRow.CreateCell(1);
|
|
|
+ cell.SetCellValue((calMonth.S != null) ? calMonth.S.Value : 0.0);
|
|
|
+ cell.CellStyle = style;
|
|
|
+
|
|
|
+ cell = newRow.CreateCell(2);
|
|
|
+ cell.SetCellValue((calMonth.A != null) ? calMonth.A.Value : 0.0);
|
|
|
+ cell.CellStyle = style;
|
|
|
+
|
|
|
+ cell = newRow.CreateCell(3);
|
|
|
+ cell.SetCellValue((calMonth.B != null) ? calMonth.B.Value : 0.0);
|
|
|
+ cell.CellStyle = style;
|
|
|
+
|
|
|
+ cell = newRow.CreateCell(4);
|
|
|
+ cell.SetCellValue((calMonth.C != null) ? calMonth.C.Value : 0.0);
|
|
|
+ cell.CellStyle = style;
|
|
|
+
|
|
|
+ cell = newRow.CreateCell(5);
|
|
|
+ cell.SetCellValue((calMonth.D != null) ? calMonth.D.Value : 0.0);
|
|
|
+ cell.CellStyle = style;
|
|
|
+
|
|
|
+
|
|
|
+ sheet.ShiftRows(0, sheet.LastRowNum, 1);
|
|
|
+ newRow = sheet.CreateRow(0);
|
|
|
+ cell = newRow.CreateCell(0);
|
|
|
+ cell.SetCellValue("难度系数");
|
|
|
+ cell.CellStyle = style;
|
|
|
+
|
|
|
+ cell = newRow.CreateCell(1);
|
|
|
+ cell.SetCellValue("S");
|
|
|
+ cell.CellStyle = style;
|
|
|
+
|
|
|
+ cell = newRow.CreateCell(2);
|
|
|
+ cell.SetCellValue("A");
|
|
|
+ cell.CellStyle = style;
|
|
|
+
|
|
|
+ cell = newRow.CreateCell(3);
|
|
|
+ cell.SetCellValue("B");
|
|
|
+ cell.CellStyle = style;
|
|
|
+
|
|
|
+ cell = newRow.CreateCell(4);
|
|
|
+ cell.SetCellValue("C");
|
|
|
+ cell.CellStyle = style;
|
|
|
+
|
|
|
+ cell = newRow.CreateCell(5);
|
|
|
+ cell.SetCellValue("D");
|
|
|
+ cell.CellStyle = style;
|
|
|
+
|
|
|
+ workbook.Write(f);
|
|
|
+
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ result.fileTask.Finished = true;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void ExportStaticReport(object exportDataResult)
|
|
|
{
|