Explorar o código

添加导出月最终绩效报表
修改季度等级调整数据页面
修正导出到excel档模块单元格格式

luocaiyang %!s(int64=3) %!d(string=hai) anos
pai
achega
a21262f979

+ 2 - 11
wispro.sp.api/AppealHandler/MissingCaseReviewHandler.cs

@@ -70,28 +70,19 @@ namespace wispro.sp.api.AppealHandler
                 }
 
                 var itemControler = new PerformanceItemController((spDbContext)spContext,new Services.FileTaskCacheService());
-
-                
                 PerformanceItem Item = itemControler.GetItemInfoByCaseStage(strCaseNo,strDoItem, strCaseStage);
-
-                
-                var Rules = ((spDbContext)spContext).BasePointRules.ToList();
-                
-                Utility.Utility.CalBasePoint(Item, Rules);
-
                 CalMonth calMonth = ((spDbContext)spContext).CalMonths.FirstOrDefault(c=>c.Status == 0);
 
-
                 if (calMonth != null )
                 {
                     if (Item.Id == 0 || Item.CalMonthId != calMonth.Id)
                     {
                         Item.Id = 0;
                         SaveToDb(Item, (spDbContext)spContext, calMonth);
+
+                        itemControler.RefreshPoint(Item);
                     }
                 }
-                //((spDbContext)spContext).PerformanceItems.Add(Item);
-                //((spDbContext)spContext).SaveChanges();
             }
         }
 

+ 163 - 40
wispro.sp.api/Controllers/PerformanceItemController.cs

@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.StaticFiles;
+using Microsoft.Data.SqlClient;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Caching.Memory;
 using Microsoft.Extensions.Hosting;
@@ -787,6 +788,84 @@ namespace wispro.sp.api.Controllers
             return new List<string>();
         }
 
+        public FileProcessTask GetStaticsReport(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(ExportStaticReport));
+                t.Start(result);
+
+                return fileTask;
+            }
+
+            return null;
+        }
+
+
+        private void ExportStaticReport(object exportDataResult)
+        {
+            ExportDataResult result = (ExportDataResult)exportDataResult;
+            FileProcessTask file = result.fileTask;
+            CalMonth calMonth = result.calMonth;
+
+            //var StatisticsResults = _CalMyStatistics(calMonth);
+            string strSQL = @"SELECT  Staff.Name as 代理人,StaffGrade.Grade as 代理人等级,
+                  (select sum([FinianlPoint]) from[StaffStatistics] B where B.StaffId = A.[StaffId] and b.jxType = '新申请处理' and CalMonthId = @CalMonthId ) as '新申请处理',
+                  (select sum([FinianlPoint]) from[StaffStatistics] B where B.StaffId = A.[StaffId] and b.jxType = '新申请审核' and CalMonthId = @CalMonthId) as '新申请审核',
+	              (select sum([FinianlPoint]) from[StaffStatistics] B where B.StaffId = A.[StaffId] and b.jxType = '专案处理' and CalMonthId = @CalMonthId) as '专案处理',
+                  (select sum([FinianlPoint]) from[StaffStatistics] B where B.StaffId = A.[StaffId] and b.jxType = '专案审核' and CalMonthId = @CalMonthId) as '专案审核',
+	              (select sum([FinianlPoint]) from[StaffStatistics] B where B.StaffId = A.[StaffId] and b.jxType = 'OA处理' and CalMonthId = @CalMonthId) as OA处理,
+                  (select sum([FinianlPoint]) from[StaffStatistics] B where B.StaffId = A.[StaffId] and b.jxType = 'OA审核' and CalMonthId = @CalMonthId) as OA审核,	  
+	              (select sum([FinianlPoint]) from[StaffStatistics] B where B.StaffId = A.[StaffId] and b.jxType = '其它处理' and CalMonthId = @CalMonthId) as 其它处理,
+                  (select sum([FinianlPoint]) from[StaffStatistics] B where B.StaffId = A.[StaffId] and b.jxType = '其它审核' and CalMonthId = @CalMonthId) as 其它审核,
+                  (select sum([FinianlPoint]) from[StaffStatistics] B where B.StaffId = A.[StaffId]  and CalMonthId = @CalMonthId) as 总计
+              FROM[spDB].[dbo].[StaffStatistics] as A
+              inner join Staff on Staff.Id = A.StaffId
+              Left join StaffGrade on Staff.StaffGradeId = StaffGrade.Id
+              where CalMonthId = @CalMonthId
+              group by A.StaffId, Staff.Name,StaffGrade.Grade";
+
+            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);
+            result.fileTask.Finished = true;
+        }
+
         private List<StaffStatistics> _CalMyStatistics(CalMonth calMonth, int? userid = null)
         {
             var retList = Context.StaffStatistics.Where(s => s.CalMonthId == calMonth.Id);
@@ -1057,9 +1136,11 @@ namespace wispro.sp.api.Controllers
             };
         }
 
-        public FileProcessTask CurrentData2Excel()
+
+
+        public FileProcessTask CurrentData2Excel(int Year,int Month)
         {
-            CalMonth calMonth = Context.CalMonths.FirstOrDefault(c => c.Status == 0);
+            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";
@@ -1076,8 +1157,13 @@ namespace wispro.sp.api.Controllers
 
                 fileTaskService.Add(fileTask);
 
+                ExportDataResult result = new ExportDataResult() {
+                    fileTask = fileTask,
+                    calMonth = calMonth
+                };
+
                 System.Threading.Thread t = new System.Threading.Thread(new ParameterizedThreadStart(Export2ExcelThread));
-                t.Start(fileTask);
+                t.Start(result);
 
                 return fileTask;
             }
@@ -1086,9 +1172,16 @@ namespace wispro.sp.api.Controllers
 
         }
 
+        internal class ExportDataResult
+        {
+            public FileProcessTask fileTask { get; set; }
+            public CalMonth calMonth { get; set; }
+        }
+
         private void Export2ExcelThread(object attfile)
         {
-            FileProcessTask file = (FileProcessTask)attfile;
+            ExportDataResult result = (ExportDataResult)attfile;
+            FileProcessTask file = result.fileTask;
 
             spDbContext spDb = new spDbContext();
             List<PerformanceItem> items = spDb.PerformanceItems
@@ -1097,7 +1190,7 @@ namespace wispro.sp.api.Controllers
                 .Include(p => p.Customer)
                 .Include(p => p.CalMonth)
                 .Include(p => p.ItemStaffs).ThenInclude(s => s.DoPerson).ThenInclude(s => s.StaffGrade)
-                .Where(p => p.CalMonth.Status == 0 && !p.CaseNo.StartsWith("J")).OrderBy(p => p.CaseNo).ThenBy(p => p.DoItem).ToList();
+                .Where(p => p.CalMonth.Id == result.calMonth.Id && !p.CaseNo.StartsWith("J")).OrderBy(p => p.CaseNo).ThenBy(p => p.DoItem).ToList();
 
             DataTable dt = new DataTable();
             #region 栏位名称
@@ -1792,7 +1885,7 @@ namespace wispro.sp.api.Controllers
             {
                 if (jx.totalBasePoint == 0)
                 {
-                    return;
+                    continue;
                 }
 
                 jx.ItemId = Item.Id;
@@ -2179,6 +2272,40 @@ namespace wispro.sp.api.Controllers
                 }
             }
         }
+
+        public ProcessTask FinishedCalMonth(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(_FinishedCalMonth));
+                t.Start(result);
+
+                return fileTask;
+            }
+
+            return null;
+        }
         /// <summary>
         /// 新申请/专案: 
         ///     调整点数 = 分配比例点数/分配比例点数之和*总点数
@@ -2196,56 +2323,49 @@ namespace wispro.sp.api.Controllers
         /// <param name="year"></param>
         /// <param name="month"></param>
         /// <returns></returns>
-        public ApiSaveResponse FinishedCalMonth(int year,int month)
+        private void _FinishedCalMonth(object proecssTask)
         {
-            CalMonth calMonth = Context.CalMonths.Where<CalMonth>(c => c.Month == month && c.Year == year).FirstOrDefault();
-
+            ExportDataResult result = (ExportDataResult)proecssTask;
+            CalMonth calMonth = result.calMonth;
+            
             if (calMonth != null || calMonth.Status !=4)
             {
-                
-                using (var t = Context.Database.BeginTransaction())
+                spDbContext spDb = new spDbContext();
+                calMonth = spDb.CalMonths.FirstOrDefault(c=>c.Id == calMonth.Id);
+                using (var t = spDb.Database.BeginTransaction())
                 {
                     try
                     {
-                        _RefreshBasePoint(calMonth,Context);
+                        _RefreshBasePoint(calMonth, spDb);
                         //_CalJXPoint(calMonth, Context);
 
                         calMonth.Status = 4;
-                        Context.SaveChanges();
+                        spDb.SaveChanges();
 
-                        StatisticsCount(calMonth.Id); //等级核算案件统计
+                        StatisticsCount(calMonth.Id,spDb); //等级核算案件统计
 
                         #region 将待审核的申诉全部修改为已审核
-                        var aList = Context.AppealRecords.Where(a => a.State == 0).ToList();
+                        var aList = spDb.AppealRecords.Where(a => a.State == 0).ToList();
                         aList.ForEach(a =>a.State = 1);
-                        Context.SaveChanges();
+                        spDb.SaveChanges();
                         #endregion
 
                         t.Commit();
-                        return new ApiSaveResponse()
-                        {
-                            Success = true
-                        };
+                        result.fileTask.Finished = true;
 
                     }
                     catch (Exception ex)
                     {
                         t.Rollback();
-                        return new ApiSaveResponse()
-                        {
-                            Success = false,
-                            ErrorMessage = ex.Message
-                        };
+                        result.fileTask.ErrorMessage = ex.Message;
+                        result.fileTask.Finished = true;
                     }
                 }
             }
             else
             {
-                return new ApiSaveResponse()
-                {
-                    Success = false,
-                    ErrorMessage ="指定月份没有数据或者已归档!"
-                };
+                result.fileTask.ErrorMessage = "指定月份没有数据或者已归档!";
+                result.fileTask.Finished = true;
             }
 
         }
@@ -2788,7 +2908,7 @@ namespace wispro.sp.api.Controllers
             var retObj = Context.PerformanceItems.Include(p=>p.Customer).FirstOrDefault<PerformanceItem>(p => p.CaseNo == CaseNo.Trim() 
             && p.DoItem == DoItem.Trim() && p.CaseStage == caseStage);
 
-            if (retObj == null && UpdateFromIPEasy)
+            if (retObj == null || UpdateFromIPEasy)
             {
                 var temObj = new Job.UpdateJXDataFromIPEasyJob().GetItemFromIPEasyDB(
                     new PerformanceItem() {CaseNo =CaseNo,DoItem =DoItem,CaseStage = caseStage },
@@ -2999,19 +3119,19 @@ namespace wispro.sp.api.Controllers
         /// </summary>
         /// <param name="calMonthId"></param>
         /// <returns></returns>
-        private List<StaffStatisticsforLevel> StatisticsCount(int calMonthId)
+        private List<StaffStatisticsforLevel> StatisticsCount(int calMonthId,spDbContext spDb )
         {
             var retlist = new List<StaffStatisticsforLevel>();
 
             #region 新申请
-            var newList = Context.PerformanceItems.Include(p => p.ItemStaffs)
+            var newList = spDb.PerformanceItems.Include(p => p.ItemStaffs)
                 .Where(p=>p.CalMonthId == calMonthId && p.BasePoint >0
                     && (p.Type =="新申请" || p.Type =="专案" || (p.Type == "其它" && p.WordCount >0 && (p.DoItem =="新申请" || p.DoItem == "翻译")))
                 ).ToList();
 
             foreach(var p in newList)
             {
-                var pointList = Context.StaffStatistics.Include(i=>i.Staff).Where(i=>i.ItemId == p.Id).ToList();
+                var pointList = spDb.StaffStatistics.Include(i=>i.Staff).Where(i=>i.ItemId == p.Id).ToList();
 
                 #region 新申请处理
                 var doList = pointList.Where(i => i.jxType.Contains("处理"));
@@ -3138,13 +3258,13 @@ namespace wispro.sp.api.Controllers
             #endregion
 
             #region 国内OA
-            var cnOA = Context.PerformanceItems.Include(x=>x.ItemStaffs)
+            var cnOA = spDb.PerformanceItems.Include(x=>x.ItemStaffs)
                 .Where(x => x.CalMonthId == calMonthId && x.Type == "OA" && x.CaseNo.Contains("CN") && x.BasePoint > 0
                 && (x.CaseStage == "一通" || x.DoItemCoefficient.Contains("首次转入"))).ToList();
 
             foreach(var p in cnOA)
             {
-                var pointList = Context.StaffStatistics.Include(i => i.Staff).Where(i=> i.ItemId == p.Id).ToList();
+                var pointList = spDb.StaffStatistics.Include(i => i.Staff).Where(i=> i.ItemId == p.Id).ToList();
 
                 #region 国内OA处理
                 var doList = pointList.Where(i => i.jxType.Contains("处理"));
@@ -3233,13 +3353,13 @@ namespace wispro.sp.api.Controllers
             #endregion
 
             #region 涉外OA
-            var gwOA = Context.PerformanceItems.Include(x => x.ItemStaffs)
+            var gwOA = spDb.PerformanceItems.Include(x => x.ItemStaffs)
                 .Where(x => x.CalMonthId == calMonthId && x.Type == "OA" && !x.CaseNo.Contains("CN") && x.BasePoint>0
                 && (x.DoItemCoefficient.Contains("实质"))).ToList();
 
             foreach (var p in gwOA)
             {
-                var pointList = Context.StaffStatistics.Include(i => i.Staff).Where(i => i.ItemId == p.Id).ToList();
+                var pointList = spDb.StaffStatistics.Include(i => i.Staff).Where(i => i.ItemId == p.Id).ToList();
 
                 #region 涉外OA处理
                 var doList = pointList.Where(i => i.jxType.Contains("处理"));
@@ -3468,7 +3588,10 @@ namespace wispro.sp.api.Controllers
                 result.UpgradeBase = temResult.doAverage();
             }
 
-            var temAverage= result.pAverage(result.Statistics[0].StaffId);
+            if (result.Statistics.Count > 0)
+            {
+                var temAverage = result.pAverage(result.Statistics[0].StaffId);
+            }
             return result;
         }
 
@@ -3488,7 +3611,7 @@ namespace wispro.sp.api.Controllers
                     var temList = Context.StaffStatisticsforLevels.Where(l => l.CalMonthId == temObj.Id);
                     Context.StaffStatisticsforLevels.RemoveRange(temList);
 
-                    var NewList = StatisticsCount(temObj.Id);
+                    var NewList = StatisticsCount(temObj.Id,Context);
 
                     Context.StaffStatisticsforLevels.AddRange(NewList);
                     Context.SaveChanges();

+ 3 - 1
wispro.sp.api/Job/InvalidDataMessageJob.cs

@@ -19,7 +19,9 @@ namespace wispro.sp.api.Job
             var lstItem = spDb.PerformanceItems.Where<PerformanceItem>(p =>
                 (p.AgentFeedbackMemo != "已算绩效"  && p.CalMonth.Status == 0 && !p.CaseNo.StartsWith("J") 
                 && (p.BasePoint ==null || (string.IsNullOrEmpty(p.CaseCoefficient) && p.Type =="新申请")
-                || (p.Type =="OA" && string.IsNullOrEmpty(p.CaseCoefficient) && p.DoItemCoefficient =="实质"))))
+                || (p.Type =="OA" && string.IsNullOrEmpty(p.CaseCoefficient) && p.DoItemCoefficient =="实质")
+                || (string.IsNullOrEmpty(p.DoItemCoefficient))
+                )))
                 .Include(p => p.Reviewer)
                 .Include(p => p.CalMonth)
                 .Include(p => p.Customer)

+ 11 - 6
wispro.sp.share/FileProcessTask.cs

@@ -6,18 +6,23 @@ using System.Threading.Tasks;
 
 namespace wispro.sp.share
 {
-    public class FileProcessTask
+    public class ProcessTask
     {
         public string Id { get; set; }
-
-        public string FileName { get; set; }
-
-        public string FilePath { get; set; }
-
         public int Size { get; set; }
 
         public int Processed { get; set; }
 
         public bool Finished { get; set; }
+
+        public string ErrorMessage { get;set; }
+    }
+
+    public class FileProcessTask: ProcessTask
+    {
+        public string FileName { get; set; }
+
+        public string FilePath { get; set; }
+        
     }
 }

+ 108 - 3
wispro.sp.utility/NPOIExcle.cs

@@ -167,7 +167,7 @@ namespace wispro.sp.utility
         /// <param name="dt">datatable</param>
         /// <param name="strFile">strFile</param>
         /// <returns></returns>
-        public static bool DataTableToExcel(DataTable dt, string strFile)
+        public static bool DataTableToExcel(DataTable dt, string strFile,bool isAutoColumnWidth=true)
         {
             bool result = false;
             IWorkbook workbook = null;
@@ -190,16 +190,79 @@ namespace wispro.sp.utility
                     {
                         cell = row.CreateCell(c);
                         cell.SetCellValue(dt.Columns[c].ColumnName);
+
+                        ICellStyle cellStyleColumn = workbook.CreateCellStyle();
+                        cellStyleColumn.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
+                        cellStyleColumn.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
+                        cellStyleColumn.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
+                        cellStyleColumn.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
+                        cellStyleColumn.WrapText = true;// 指定单元格自动换行
+                        cellStyleColumn.VerticalAlignment = VerticalAlignment.Center;//垂直居中
+                        cellStyleColumn.Alignment = HorizontalAlignment.Center; //水平居中
+
+                        IFont font = workbook.CreateFont();
+                        font.IsBold = true;
+                        cellStyleColumn.SetFont(font);
+
+                        cell.CellStyle = cellStyleColumn;
                     }
 
+                    #region 设置边框
+                    ICellStyle cellStyle = workbook.CreateCellStyle();
+                    cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
+                    cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
+                    cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
+                    cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
+                    cellStyle.WrapText = true;// 指定单元格自动换行
+                    cellStyle.VerticalAlignment = VerticalAlignment.Center;//垂直居中
+                    cellStyle.Alignment = HorizontalAlignment.Center;
+
+                    #endregion
+
                     //设置每行每列的单元格,
                     for (int i = 0; i < rowCount; i++)
                     {
                         row = sheet.CreateRow(i + 1);
+                        row.Height = 30*20;
+
                         for (int j = 0; j < columnCount; j++)
                         {
+                            
                             cell = row.CreateCell(j);//excel第二行开始写入数据
-                            cell.SetCellValue(dt.Rows[i][j].ToString());
+
+                            if(dt.Rows[i][j] is System.DBNull)
+                            {
+                                cell.SetCellValue("");
+                                
+                            }
+                            else
+                            {
+                                switch (dt.Rows[i][j].GetType().ToString())
+                                {
+                                    case "System.String":
+                                        cell.SetCellValue(dt.Rows[i][j].ToString());
+                                        break;
+                                    case "System.Double":
+                                    case "System.Int32":
+                                    case "System.Int64":
+                                    case "System.Float":
+                                    case "System.Decimal":
+                                        cell.SetCellValue(double.Parse(dt.Rows[i][j].ToString()));
+                                        cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("###0.00");//(short)CellType.NUMERIC;
+                                        break;
+                                    case "System.DateTime":
+                                        cell.SetCellValue(DateTime.Parse(dt.Rows[i][j].ToString()));
+                                        break;
+                                    default:
+                                        cell.SetCellValue(dt.Rows[i][j].ToString());
+                                        break;
+                                }
+                                
+                            }
+                            cell.CellStyle = cellStyle;
+
+
+
                         }
                     }
                     using (fs = File.OpenWrite(strFile))
@@ -207,6 +270,46 @@ namespace wispro.sp.utility
                         workbook.Write(fs);//向打开的这个xls文件中写入数据
                         result = true;
                     }
+
+                    #region 设定列宽
+                    if (isAutoColumnWidth)
+                    {
+                        for (int i = 0; i < columnCount; i++)
+                        {
+                            sheet.AutoSizeColumn(i);
+                        }
+
+                        //获取当前列的宽度,然后对比本列的长度,取最大值
+                        for (int columnNum = 0; columnNum <= columnCount; columnNum++)
+                        {
+                            int columnWidth = sheet.GetColumnWidth(columnNum) / 256;
+                            for (int rowNum = 0; rowNum <1; rowNum++)
+                            {
+                                IRow currentRow;
+                                //当前行未被使用过
+                                if (sheet.GetRow(rowNum) == null)
+                                {
+                                    currentRow = sheet.CreateRow(rowNum);
+                                }
+                                else
+                                {
+                                    currentRow = sheet.GetRow(rowNum);
+                                }
+
+                                if (currentRow.GetCell(columnNum) != null)
+                                {
+                                    ICell currentCell = currentRow.GetCell(columnNum);
+                                    int length = Encoding.Default.GetBytes(currentCell.ToString()).Length;
+                                    if (columnWidth < length)
+                                    {
+                                        columnWidth = length;
+                                    }
+                                }
+                            }
+                            sheet.SetColumnWidth(columnNum, columnWidth * 256);
+                        }
+                    }
+                    #endregion
                 }
                 return result;
             }
@@ -282,7 +385,9 @@ namespace wispro.sp.utility
         {
             IWorkbook workbook;
             string fileExt = Path.GetExtension(file).ToLower();
-            if (fileExt == ".xlsx") { workbook = new XSSFWorkbook(); } else if (fileExt == ".xls") { workbook = new HSSFWorkbook(); } else { workbook = null; }
+            if (fileExt == ".xlsx") { workbook = new XSSFWorkbook(); } 
+            else if (fileExt == ".xls") { workbook = new HSSFWorkbook(); } 
+            else { workbook = null; }
             if (workbook == null) { return; }
             ISheet sheet = string.IsNullOrEmpty(dt.TableName) ? workbook.CreateSheet("Sheet1") : workbook.CreateSheet(dt.TableName);
 

+ 7 - 7
wispro.sp.web/Layouts/BasicLayout.razor

@@ -192,13 +192,13 @@
 
             }
         },
-        new MenuDataItem
-        {
-            Path ="/Workflow/Manage",
-            Name ="流程管理",
-            Key= "wfManage",
-            Icon = "apartment"
-        }
+        //new MenuDataItem
+        //{
+        //    Path ="/Workflow/Manage",
+        //    Name ="流程管理",
+        //    Key= "wfManage",
+        //    Icon = "apartment"
+        //}
 
     };
 

+ 32 - 13
wispro.sp.web/Pages/AppCase/CaseManager.razor

@@ -93,21 +93,36 @@ RenderFragment gdIcon =
                 <Extra>
                     @if (HandlingCalMonth.Status != 4)
                     {
-                        <a @onclick="()=>GuidangCalMonth(HandlingCalMonth)">
-                            <Icon Component="gdIcon" Style="font-size:28px;"></Icon>
-                            完成本期绩效计算,归档数据
-                        </a>
-
+                        if(isGuiDang)
+                        {
+                            <Button Icon="download" Type="@ButtonType.Text" Loading>数据归档中</Button>
+                        }
+                        else{
                         
+                            <a @onclick="()=>GuidangCalMonth(HandlingCalMonth)">
+                                <Icon Component="gdIcon" Style="font-size:28px;"></Icon>
+                                完成本期绩效计算,归档数据
+                            </a>
+                        }
                     }
 
-                    if(isDownloading){
-                            <Button Icon="download" Type="@ButtonType.Text" Loading>导出线下绩效计算报表</Button>
-                        }
-                        else
-                        {
-                            <Button Icon="download" Type="@ButtonType.Text" OnClick="() => ExportCurrentMonthJXList()">导出线下绩效计算报表</Button>
-                        }
+                    @*@if(isDownloading)
+                    {
+                        <Button Icon="download" Type="@ButtonType.Text" Loading>导出线下绩效计算报表</Button>
+                    }
+                    else
+                    {
+                        <Button Icon="download" Type="@ButtonType.Text" OnClick="() => ExportCurrentMonthJXList()">导出线下绩效计算报表</Button>
+                    }*@
+
+                    @if (isDownloading)
+                    {
+                        <Button Icon="download" Type="@ButtonType.Text" Loading>导出最终绩效报表</Button>
+                    }
+                    else
+                    {
+                        <Button Icon="download" Type="@ButtonType.Text" OnClick="() => ExportJXDataAsync(HandlingCalMonth)">导出最终绩效报表</Button>
+                    }
 
                     @if (isDownloading)
                     {
@@ -119,6 +134,8 @@ RenderFragment gdIcon =
                     }
                     </Extra>
 
+                    
+
                 <Body>
                     <AntDesign.Table DataSource="_Datas" TItem="PerformanceItem" @ref="@table"
                                      @bind-PageIndex="_pageIndex"
@@ -136,6 +153,9 @@ RenderFragment gdIcon =
                             </AntDesign.Column>
 
                             <AntDesign.Column Title="基础点数" TData="string" Width="100" Sortable>@(context.BasePoint == null ? "" : context.BasePoint)</AntDesign.Column>
+                            <AntDesign.Column Title="绩效备注" Width="100" @bind-Field="@context.AgentFeedbackMemo" Sortable>
+                                <span>@(context.AgentFeedbackMemo == null ? "" : context.AgentFeedbackMemo)</span>
+                            </AntDesign.Column>
                             <AntDesign.Column Title="我方文号" @bind-Field="@context.CaseNo" Width="150" Sortable Filterable />
                             <AntDesign.Column Title="案件类型" @bind-Field="@context.CaseType" Width="120" Sortable Filterable />
                             <AntDesign.Column Title="案件系数"
@@ -146,7 +166,6 @@ RenderFragment gdIcon =
                                               Sortable />
                             <AntDesign.Column Title="处理事项" @bind-Field="@context.DoItem" Width="150" Sortable Filterable />
                             <AntDesign.Column Title="处理事项系数" @bind-Field="@context.DoItemCoefficient" Width="150" Sortable Filterable />
-                            <AntDesign.Column Title="绩效特殊字段" @bind-Field="@context.AgentFeedbackMemo" Width="250" />
                             <AntDesign.Column Title="案件阶段" @bind-Field="@context.CaseStage" Width="100"></AntDesign.Column>
                             <AntDesign.Column Title="处理人" TData="string" DataIndex="@nameof(context.ItemStaffs)" Width="150">
                                 @if (context.ItemStaffs != null)

+ 40 - 3
wispro.sp.web/Pages/AppCase/CaseManager.razor.cs

@@ -91,12 +91,27 @@ namespace wispro.sp.web.Pages.AppCase
             StateHasChanged();
         }
 
+        bool isGuiDang = false;
         private async Task GuidangCalMonth(CalMonth calMonth)
         {
+            isGuiDang = true;
             //还未实现,此处需要添加归档代码
-            await _ItemService.FinishedCalMonth(calMonth);
+            var fileData = await _ItemService.FinishedCalMonth(calMonth);
 
-            await Task.Delay(1);
+            while (!fileData.Finished)
+            {
+                fileData = await _ItemService.getExportDataProcessing(fileData.Id);
+                await Task.Delay(1000);
+            }
+
+            if (!string.IsNullOrEmpty(fileData.ErrorMessage))
+            {
+                //calMonths = await _CalMonthService.GetAll();
+                calMonth.Status = 4;
+                //calMonthClick(calMonth);
+            }
+
+            isGuiDang = false;
             StateHasChanged();
         }
 
@@ -131,12 +146,33 @@ namespace wispro.sp.web.Pages.AppCase
 
             isDownloading = false;
 
+           
+
+        }
+
+        private async Task ExportJXDataAsync(CalMonth calMonth)
+        {
+            isDownloading = true;
+            var fileData = await _ItemService.ExportJXReport(calMonth.Year,calMonth.Month);
+
+            while (!fileData.Finished)
+            {
+                fileData = await _ItemService.getExportDataProcessing(fileData.Id);
+                await Task.Delay(20);
+            }
+
+            NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
+
+            isDownloading = false;
+
+            
+
         }
 
         private async Task ExportCurrentMonthJXList()
         {
             isDownloading = true;
-            var fileData = await _ItemService.CurrentData2Excel();
+            var fileData = await _ItemService.CurrentData2Excel(HandlingCalMonth);
 
             while (!fileData.Finished)
             {
@@ -152,6 +188,7 @@ namespace wispro.sp.web.Pages.AppCase
         async Task OnRefresh(PerformanceItem item)
         {
             item = await _ItemService.RefreshItem(item.Id);
+            table.ReloadData();
             StateHasChanged();
         }
 

+ 32 - 9
wispro.sp.web/Pages/AppCase/LevelStatistics.razor.cs

@@ -17,6 +17,9 @@ namespace wispro.sp.web.Pages.AppCase
         DatePicker<DateTime?> refDate;
         DateTime? SelectedTime;
 
+        [Inject]
+        public MessageService MessageService { get; set; }
+
         DatePickerLocale CN = new DatePickerLocale
         {
             FirstDayOfWeek = DayOfWeek.Sunday,
@@ -65,9 +68,27 @@ namespace wispro.sp.web.Pages.AppCase
                     }
                 }
 
-                await pService.StatisticsLevelCount(year, 1);
-                await pService.StatisticsLevelCount(year, 2);
-                await pService.StatisticsLevelCount(year, 3);
+                //await pService.StatisticsLevelCount(year, 1);
+                //await pService.StatisticsLevelCount(year, 2);
+                //await pService.StatisticsLevelCount(year, 3);
+                try
+                {
+                    AResult = await pService.CalAgentLevel(SelectedTime.Value.Year, quartar, "A");
+                    BResult = await pService.CalAgentLevel(SelectedTime.Value.Year, quartar, "B");
+                    CResult = await pService.CalAgentLevel(SelectedTime.Value.Year, quartar, "C");
+                    DResult = await pService.CalAgentLevel(SelectedTime.Value.Year, quartar, "D");
+                }
+                catch (Exception ex)
+                {
+                    AResult = new LevelStatisticsResult();
+                    BResult = new LevelStatisticsResult();
+                    CResult = new LevelStatisticsResult();
+                    DResult = new LevelStatisticsResult();
+                    await MessageService.Error($"【{SelectedTime.Value.Year}】年【{quartar}】季度等级数据还没有汇总!");
+                }
+
+
+                StateHasChanged();
             }
         }
 
@@ -81,18 +102,20 @@ namespace wispro.sp.web.Pages.AppCase
         protected override async Task OnInitializedAsync()
         {
             await _authService.CanVisitResource();
-            if(SelectedTime == null)
+            if (SelectedTime == null)
             {
                 SelectedTime = DateTime.Now.AddMonths(-3);
             }
 
 
-            AResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "A");
-            BResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "B");
-            CResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "C");
-            DResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "D");
-            
+            //AResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "A");
+            //BResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "B");
+            //CResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "C");
+            //DResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "D");
+
             await base.OnInitializedAsync();
+
+            await ShowSelectedDate();
         }
 
         

+ 3 - 0
wispro.sp.web/Pages/AppCase/MyCaselist.razor

@@ -133,6 +133,9 @@
                             <AntDesign.Column Title="基础点数" Width="100" @bind-Field="@context.BasePoint" Sortable>
                                 <span>@(context.BasePoint == null ? "" : context.BasePoint)</span>
                             </AntDesign.Column>
+                            <AntDesign.Column Title="绩效备注" Width="100" @bind-Field="@context.AgentFeedbackMemo" Sortable>
+                                <span>@(context.AgentFeedbackMemo == null ? "" : context.AgentFeedbackMemo)</span>
+                            </AntDesign.Column>
                             <AntDesign.Column Title="我方文号" @bind-Field="@context.CaseNo" Width="150" Sortable Filterable />
                             <AntDesign.Column Title="案件类型" @bind-Field="@context.CaseType" Width="120" Sortable Filterable />
                             <AntDesign.Column Title="申请类型" @bind-Field="@context.ApplicationType" Width="120" Sortable Filterable />

+ 72 - 65
wispro.sp.web/Pages/Report/StaffStaticsReport.razor

@@ -1,81 +1,88 @@
 @page  "/Report/StaticsTrend"
 
-<PageContainer>
-    <Breadcrumb>
-        <Breadcrumb>
-            <BreadcrumbItem>
-                <a href="/Home"><Icon Type="home"></Icon></a>
-            </BreadcrumbItem>
-            <BreadcrumbItem>
-                <span>申诉单项统计</span>
-            </BreadcrumbItem>
-        </Breadcrumb>
-    </Breadcrumb>
-    <Content>
-        <Space>
-            <SpaceItem>统计类型:</SpaceItem>
-            <SpaceItem>
-                <Select DataSource="@Types"
-                        @bind-Value="@iType"
-                        LabelName="@nameof(TJType.Name)"
-                        ValueName="@nameof(TJType.value)"
-                        Placeholder="请选择统计类型">
-                </Select>
-            </SpaceItem>
-            <SpaceItem><Button Icon="search" Loading="_noIconLoading" OnClick="OnButtonClick">开始统计</Button></SpaceItem>
-        </Space>
-    </Content>
-    <ChildContent>
-        <div>
-            @if (Datas == null)
-            {
-
-            }
-            else
-            {
+<AuthorizeView>
+    <Authorized>
+        <PageContainer>
+            <Breadcrumb>
+                <Breadcrumb>
+                    <BreadcrumbItem>
+                        <a href="/Home"><Icon Type="home"></Icon></a>
+                    </BreadcrumbItem>
+                    <BreadcrumbItem>
+                        <span>申诉单项统计</span>
+                    </BreadcrumbItem>
+                </Breadcrumb>
+            </Breadcrumb>
+            <Content>
+                <Space>
+                    <SpaceItem>统计类型:</SpaceItem>
+                    <SpaceItem>
+                        <Select DataSource="@Types"
+                                @bind-Value="@iType"
+                                LabelName="@nameof(TJType.Name)"
+                                ValueName="@nameof(TJType.value)"
+                                Placeholder="请选择统计类型">
+                        </Select>
+                    </SpaceItem>
+                    <SpaceItem><Button Icon="search" Loading="_noIconLoading" OnClick="OnButtonClick">开始统计</Button></SpaceItem>
+                </Space>
+            </Content>
+            <ChildContent>
                 <div>
-                    <center>
-                        <Blazor.ECharts.Components.ELine Option="option" Class="chart-normal" EventTypes="EventTypes" OnEventCallback="OnEchartsEvent" @ref="chart"/>
-                        @{
-                            System.Data.DataTable tableData = Datas.GetTableData();
+                    @if (Datas == null)
+                    {
 
-                            <table width="80%" border="1">
-                                <thead>
-                                <th>序号</th>
+                    }
+                    else
+                    {
+                        <div>
+                            <center>
+                                <Blazor.ECharts.Components.ELine Option="option" Class="chart-normal" EventTypes="EventTypes" OnEventCallback="OnEchartsEvent" @ref="chart"/>
+                                @{
+                                    System.Data.DataTable tableData = Datas.GetTableData();
 
-                                @foreach (System.Data.DataColumn column in tableData.Columns)
-                                {
-                                    <th>@column.ColumnName</th>
-                                }
+                                    <table width="80%" border="1">
+                                        <thead>
+                                        <th>序号</th>
 
-                                </thead>
-                                <tbody>
-                                    @{
-                                        int iIndex = 1;
-                                        foreach (System.Data.DataRow row in tableData.Rows)
+                                        @foreach (System.Data.DataColumn column in tableData.Columns)
                                         {
-                                            <tr>
-                                                <td style="text-align: center;">@iIndex</td>
+                                            <th>@column.ColumnName</th>
+                                        }
 
-                                                @foreach (System.Data.DataColumn column in tableData.Columns)
+                                        </thead>
+                                        <tbody>
+                                            @{
+                                                int iIndex = 1;
+                                                foreach (System.Data.DataRow row in tableData.Rows)
                                                 {
-                                                    <td>@row[column.ColumnName].ToString()</td>
+                                                    <tr>
+                                                        <td style="text-align: center;">@iIndex</td>
+
+                                                        @foreach (System.Data.DataColumn column in tableData.Columns)
+                                                        {
+                                                            <td>@row[column.ColumnName].ToString()</td>
+                                                        }
+                                                    </tr>
+                                                    iIndex++;
                                                 }
-                                            </tr>
-                                            iIndex++;
-                                        }
-                                    }
-                                </tbody>
-                            </table>
-                        }
+                                            }
+                                        </tbody>
+                                    </table>
+                                }
 
 
 
-                    </center>
+                            </center>
+                        </div>
+                    }
                 </div>
-            }
-        </div>
-    </ChildContent>
-</PageContainer>
+            </ChildContent>
+        </PageContainer>
+    </Authorized>
+    <NotAuthorized>
+        <div><h1>您没有授权使用此功能</h1></div>
+    </NotAuthorized>
+</AuthorizeView>
 
 

+ 11 - 4
wispro.sp.web/Services/PerformanceItemServices.cs

@@ -64,11 +64,18 @@ namespace wispro.sp.web.Services
             var fileData = await _httpClient.Post<FileProcessTask>($"PerformanceItem/ExportData", query);
 
             return fileData;
+            
+        }
+
+        public async Task<FileProcessTask> ExportJXReport(int Year,int month)
+        {
+            var fileData = await _httpClient.Get<FileProcessTask>($"PerformanceItem/GetStaticsReport?Year={Year}&Month={month}");
+            return fileData;
         }
 
-        public async Task<FileProcessTask> CurrentData2Excel()
+        public async Task<FileProcessTask> CurrentData2Excel(CalMonth calMonth)
         {
-            var fileData = await _httpClient.Get<FileProcessTask>($"PerformanceItem/CurrentData2Excel");
+            var fileData = await _httpClient.Get<FileProcessTask>($"PerformanceItem/CurrentData2Excel?Year={calMonth.Year}&Month={calMonth.Month}");
 
             return fileData;
         }
@@ -121,9 +128,9 @@ namespace wispro.sp.web.Services
 
         }
 
-        public async  Task<ApiSaveResponse> FinishedCalMonth(CalMonth calMonth)
+        public async  Task<FileProcessTask> FinishedCalMonth(CalMonth calMonth)
         {
-            var ret = await _httpClient.Get<ApiSaveResponse>($"PerformanceItem/FinishedCalMonth?year={calMonth.Year}&month={calMonth.Month}");
+            var ret = await _httpClient.Get<FileProcessTask>($"PerformanceItem/FinishedCalMonth?year={calMonth.Year}&month={calMonth.Month}");
             return ret;
         }