|
@@ -895,6 +895,77 @@ namespace wispro.sp.api.Controllers
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ [Authorize]
|
|
|
+ public FileProcessTask OtherNewCaseAllocationReport(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(_OtherNewCaseAllocationReport));
|
|
|
+ t.Start(result);
|
|
|
+
|
|
|
+ return fileTask;
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void _OtherNewCaseAllocationReport(object exportDataResult)
|
|
|
+ {
|
|
|
+ ExportDataResult result = (ExportDataResult)exportDataResult;
|
|
|
+ FileProcessTask file = result.fileTask;
|
|
|
+ CalMonth calMonth = result.calMonth;
|
|
|
+
|
|
|
+ //var StatisticsResults = _CalMyStatistics(calMonth);
|
|
|
+ string strSQL = @" SELECT Staff.Name as 姓名,sum([ActualAmount]) as 绩效金额
|
|
|
+ FROM [spDB].[dbo].[AllocationRatio],
|
|
|
+ performanceItem,staff
|
|
|
+ where Staff.Id = AllocationRatio.PersonId and PerformanceItem.Id= AllocationRatio.ItemId
|
|
|
+ and ItemId in (select id from PerformanceItem where CalMonthId in (select id from CalMonth where year =@year and month=@month))
|
|
|
+ group by Staff.Name
|
|
|
+ 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("year", calMonth.Year));
|
|
|
+ cmd.Parameters.Add(new SqlParameter("month", calMonth.Month));
|
|
|
+ using (var reader = cmd.ExecuteReader())
|
|
|
+ {
|
|
|
+ dt.Load(reader);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ NPOIExcel.DataTableToExcel(dt, result.fileTask.FilePath);
|
|
|
+ result.fileTask.Finished = true;
|
|
|
+ }
|
|
|
+
|
|
|
private void _GetOtherNewCaseAllocationReport(object exportDataResult)
|
|
|
{
|
|
|
ExportDataResult result = (ExportDataResult)exportDataResult;
|