|
@@ -2,12 +2,18 @@
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
+using Microsoft.AspNetCore.StaticFiles;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
+using Microsoft.Extensions.Hosting;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
+using System.Data;
|
|
|
|
+using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Linq.Expressions;
|
|
|
|
+using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
|
+using wispro.sp.api.Services;
|
|
using wispro.sp.api.Utility;
|
|
using wispro.sp.api.Utility;
|
|
using wispro.sp.entity;
|
|
using wispro.sp.entity;
|
|
using wispro.sp.share;
|
|
using wispro.sp.share;
|
|
@@ -21,11 +27,14 @@ namespace wispro.sp.api.Controllers
|
|
public class PerformanceItemController : ControllerBase
|
|
public class PerformanceItemController : ControllerBase
|
|
{
|
|
{
|
|
spDbContext Context;
|
|
spDbContext Context;
|
|
-
|
|
|
|
- public PerformanceItemController(spDbContext context)
|
|
|
|
|
|
+ IFileTaskService fileTaskService;
|
|
|
|
+ public PerformanceItemController(spDbContext context, IFileTaskService _fileTaskService)
|
|
{
|
|
{
|
|
Context = context;
|
|
Context = context;
|
|
|
|
+ fileTaskService = _fileTaskService;
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+
|
|
public ApiSaveResponse New(PerformanceItem item)
|
|
public ApiSaveResponse New(PerformanceItem item)
|
|
{
|
|
{
|
|
ApiSaveResponse ret = new ApiSaveResponse();
|
|
ApiSaveResponse ret = new ApiSaveResponse();
|
|
@@ -413,8 +422,8 @@ namespace wispro.sp.api.Controllers
|
|
}
|
|
}
|
|
private List<StaffStatistics> _CalMyStatistics(CalMonth calMonth, int? userid = null)
|
|
private List<StaffStatistics> _CalMyStatistics(CalMonth calMonth, int? userid = null)
|
|
{
|
|
{
|
|
-
|
|
|
|
- double gspjXS = DegreeOfDifficulty(calMonth.Year , calMonth.Month);
|
|
|
|
|
|
+
|
|
|
|
+ double gspjXS = DegreeOfDifficulty(calMonth.Year, calMonth.Month);
|
|
|
|
|
|
//未归档,从绩效记录中统计数据
|
|
//未归档,从绩效记录中统计数据
|
|
var results = Context.PerformanceItems.Where<PerformanceItem>(s => s.CalMonth.Id == calMonth.Id);
|
|
var results = Context.PerformanceItems.Where<PerformanceItem>(s => s.CalMonth.Id == calMonth.Id);
|
|
@@ -439,172 +448,23 @@ namespace wispro.sp.api.Controllers
|
|
|
|
|
|
foreach (PerformanceItem item in ItemList)
|
|
foreach (PerformanceItem item in ItemList)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (item.BasePoint == null)
|
|
//if (item.BasePoint == null)
|
|
//{
|
|
//{
|
|
-
|
|
|
|
- Utility.Utility.CalBasePoint(item,Rules);
|
|
|
|
|
|
|
|
- Context.SaveChanges();
|
|
|
|
|
|
+ //Utility.Utility.CalBasePoint(item,Rules);
|
|
|
|
+
|
|
|
|
+ //Context.SaveChanges();
|
|
//}
|
|
//}
|
|
|
|
|
|
if (item.BasePoint != null && item.BasePoint.Value > 0)
|
|
if (item.BasePoint != null && item.BasePoint.Value > 0)
|
|
{
|
|
{
|
|
double doPersonBasePoint = item.BasePoint.Value;
|
|
double doPersonBasePoint = item.BasePoint.Value;
|
|
|
|
|
|
- System.Collections.Hashtable doPersonsBL = new System.Collections.Hashtable();
|
|
|
|
-
|
|
|
|
- bool isPJFP = true;
|
|
|
|
- double total = item.ItemStaffs.Count();
|
|
|
|
- if (item.ItemStaffs.Where<ItemStaff>(p => p.PerformancePoint != null || p.PerformancePoint == 0).Count() > 0)
|
|
|
|
- {
|
|
|
|
- total = item.ItemStaffs.Select(i => i.PerformancePoint.Value).Sum();
|
|
|
|
- isPJFP = false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<StaffStatistics> itemStatistics = new List<StaffStatistics>();
|
|
|
|
-
|
|
|
|
- if (item.Reviewer != null)
|
|
|
|
- {
|
|
|
|
- Context.Entry(item.Reviewer).Reference(b => b.StaffGrade).Load();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- foreach (ItemStaff itemStaff in item.ItemStaffs)
|
|
|
|
- {
|
|
|
|
- Context.Entry(itemStaff).Reference(b => b.DoPerson).Load();
|
|
|
|
- Context.Entry(itemStaff.DoPerson).Reference(b => b.StaffGrade).Load();
|
|
|
|
-
|
|
|
|
- #region 计算审核人绩效点数,核稿人绩效点数按照核稿人与个处理人的核稿系数计算后加总,没有找到核稿系数(比如同级别),核稿系数为0
|
|
|
|
- if (item.ReviewerId != null && item.Type !="专案")
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- #region 取审核人等级审核等级系数
|
|
|
|
- VerifyCoefficient vcoefficient
|
|
|
|
- = verifyCoefficients.Where<VerifyCoefficient>(v =>
|
|
|
|
- v.CheckerId == item.Reviewer.StaffGrade.Id
|
|
|
|
- && v.DoPersonId == itemStaff.DoPerson.StaffGradeId)
|
|
|
|
- .FirstOrDefault<VerifyCoefficient>();
|
|
|
|
- #endregion
|
|
|
|
-
|
|
|
|
- if (vcoefficient != null)
|
|
|
|
- {
|
|
|
|
- double reviewerBasePoint = item.BasePoint.Value * vcoefficient.Coefficient;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- string temJxType = $"{item.Type}审核";
|
|
|
|
-
|
|
|
|
- var temReviewerStatic = itemStatistics.Where<StaffStatistics>(s => s.StaffId == item.ReviewerId && s.jxType == temJxType && s.CalMonth.Id == calMonth.Id).FirstOrDefault();
|
|
|
|
- if (temReviewerStatic != null)
|
|
|
|
- {
|
|
|
|
- temReviewerStatic.totalBasePoint += reviewerBasePoint;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if (item.Reviewer.IsOnJob && itemStaff.DoPerson.Status != "试用期") //判断是否在职
|
|
|
|
- {
|
|
|
|
- temReviewerStatic = new StaffStatistics()
|
|
|
|
- {
|
|
|
|
- CalMonth = calMonth,
|
|
|
|
- CalMonthId = calMonth.Id,
|
|
|
|
- StaffId = item.ReviewerId.Value,
|
|
|
|
- totalBasePoint = reviewerBasePoint,
|
|
|
|
- jxType = temJxType
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- itemStatistics.Add(temReviewerStatic);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- #endregion
|
|
|
|
-
|
|
|
|
- #region 计算各处理人的绩效点数
|
|
|
|
- double handlerBasePoint;
|
|
|
|
- if (item.Type != "专案")
|
|
|
|
- {
|
|
|
|
- if (isPJFP)
|
|
|
|
- {
|
|
|
|
- handlerBasePoint = item.BasePoint.Value * 1.0 / total;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- handlerBasePoint = item.BasePoint.Value * itemStaff.PerformancePoint.Value / total;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- handlerBasePoint = itemStaff.PerformancePoint.Value;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- string handlerJxType = $"{item.Type}处理";
|
|
|
|
- var temStatic = itemStatistics.Where<StaffStatistics>(s => s.StaffId == itemStaff.DoPersonId && s.jxType == handlerJxType && s.CalMonth.Id == calMonth.Id).FirstOrDefault();
|
|
|
|
- if (temStatic != null)
|
|
|
|
- {
|
|
|
|
- if (item.Type != "专案")
|
|
|
|
- {
|
|
|
|
- temStatic.totalBasePoint += handlerBasePoint * itemStaff.DoPerson.StaffGrade.Coefficient;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- temStatic.totalBasePoint += handlerBasePoint;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if (itemStaff.DoPerson.StaffGrade != null && itemStaff.DoPerson.IsOnJob)
|
|
|
|
- {
|
|
|
|
- if (item.Type != "专案")
|
|
|
|
- {
|
|
|
|
- if (itemStaff.DoPerson.Status == "试用期" && item.Reviewer != null)
|
|
|
|
- {
|
|
|
|
- temStatic = new StaffStatistics()
|
|
|
|
- {
|
|
|
|
- CalMonth = calMonth,
|
|
|
|
- CalMonthId = calMonth.Id,
|
|
|
|
- StaffId = item.Reviewer.Id,
|
|
|
|
- totalBasePoint = handlerBasePoint * item.Reviewer.StaffGrade.Coefficient,
|
|
|
|
- jxType = handlerJxType
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- itemStatistics.Add(temStatic);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- temStatic = new StaffStatistics()
|
|
|
|
- {
|
|
|
|
- CalMonth = calMonth,
|
|
|
|
- CalMonthId = calMonth.Id,
|
|
|
|
- StaffId = itemStaff.DoPersonId,
|
|
|
|
- totalBasePoint = handlerBasePoint * itemStaff.DoPerson.StaffGrade.Coefficient,
|
|
|
|
- jxType = handlerJxType
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- itemStatistics.Add(temStatic);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- temStatic = new StaffStatistics()
|
|
|
|
- {
|
|
|
|
- CalMonth = calMonth,
|
|
|
|
- CalMonthId = calMonth.Id,
|
|
|
|
- StaffId = itemStaff.DoPersonId,
|
|
|
|
- totalBasePoint = handlerBasePoint ,
|
|
|
|
- jxType = handlerJxType
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- itemStatistics.Add(temStatic);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- #endregion
|
|
|
|
- }
|
|
|
|
|
|
+ List<StaffStatistics> itemStatistics = _calItemJX(calMonth, verifyCoefficients, item,Context);
|
|
|
|
|
|
List<StaffStatistics> temItemStatics;
|
|
List<StaffStatistics> temItemStatics;
|
|
|
|
|
|
@@ -633,7 +493,7 @@ namespace wispro.sp.api.Controllers
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if(userid != null)
|
|
|
|
|
|
+ if (userid != null)
|
|
{
|
|
{
|
|
retList = retList.Where<StaffStatistics>(s => s.StaffId == userid.Value).ToList();
|
|
retList = retList.Where<StaffStatistics>(s => s.StaffId == userid.Value).ToList();
|
|
}
|
|
}
|
|
@@ -645,7 +505,7 @@ namespace wispro.sp.api.Controllers
|
|
{
|
|
{
|
|
if (!staffXiShu.ContainsKey(ss.StaffId))
|
|
if (!staffXiShu.ContainsKey(ss.StaffId))
|
|
{
|
|
{
|
|
- staffXiShu.Add(ss.StaffId, DegreeOfDifficulty(calMonth.Year ,calMonth.Month, ss.StaffId));
|
|
|
|
|
|
+ staffXiShu.Add(ss.StaffId, DegreeOfDifficulty(calMonth.Year, calMonth.Month, ss.StaffId));
|
|
}
|
|
}
|
|
|
|
|
|
ss.totalActuallyPoint = ss.totalBasePoint * staffXiShu[ss.StaffId] / gspjXS;
|
|
ss.totalActuallyPoint = ss.totalBasePoint * staffXiShu[ss.StaffId] / gspjXS;
|
|
@@ -660,8 +520,171 @@ namespace wispro.sp.api.Controllers
|
|
|
|
|
|
|
|
|
|
return retList;
|
|
return retList;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<StaffStatistics> _calItemJX(CalMonth calMonth, List<VerifyCoefficient> verifyCoefficients, PerformanceItem item,spDbContext spDb)
|
|
|
|
+ {
|
|
|
|
+ System.Collections.Hashtable doPersonsBL = new System.Collections.Hashtable();
|
|
|
|
+
|
|
|
|
+ bool isPJFP = true;
|
|
|
|
+ double total = item.ItemStaffs.Count();
|
|
|
|
+ if (item.ItemStaffs.Where<ItemStaff>(p => p.PerformancePoint != null || p.PerformancePoint == 0).Count() > 0)
|
|
|
|
+ {
|
|
|
|
+ total = item.ItemStaffs.Select(i => i.PerformancePoint.Value).Sum();
|
|
|
|
+ isPJFP = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<StaffStatistics> itemStatistics = new List<StaffStatistics>();
|
|
|
|
+
|
|
|
|
+ if (item.ReviewerId != null)
|
|
|
|
+ {
|
|
|
|
+ item.Reviewer = spDb.Staffs.Include(s => s.StaffGrade).FirstOrDefault(p => p.Id == item.ReviewerId);
|
|
|
|
+ //spDb.Entry(item.Reviewer).Reference(b => b.StaffGrade).Load();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ foreach (ItemStaff itemStaff in item.ItemStaffs)
|
|
|
|
+ {
|
|
|
|
+ if(itemStaff.DoPerson == null)
|
|
|
|
+ {
|
|
|
|
+ itemStaff.DoPerson = spDb.Staffs.Include(s=>s.StaffGrade).FirstOrDefault(p=>p.Id==itemStaff.DoPersonId);
|
|
|
|
+ }
|
|
|
|
+ //spDb.Entry(itemStaff).Reference(b => b.DoPerson).Load();
|
|
|
|
+ //spDb.Entry(itemStaff.DoPerson).Reference(b => b.StaffGrade).Load();
|
|
|
|
+
|
|
|
|
+ #region 计算审核人绩效点数,核稿人绩效点数按照核稿人与个处理人的核稿系数计算后加总,没有找到核稿系数(比如同级别),核稿系数为0
|
|
|
|
+ if (item.ReviewerId != null && item.Type != "专案")
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ #region 取审核人等级审核等级系数
|
|
|
|
+ VerifyCoefficient vcoefficient
|
|
|
|
+ = verifyCoefficients.Where<VerifyCoefficient>(v =>
|
|
|
|
+ v.CheckerId == item.Reviewer.StaffGrade.Id
|
|
|
|
+ && v.DoPersonId == itemStaff.DoPerson.StaffGradeId)
|
|
|
|
+ .FirstOrDefault<VerifyCoefficient>();
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ if (vcoefficient != null)
|
|
|
|
+ {
|
|
|
|
+ double reviewerBasePoint = item.BasePoint.Value * vcoefficient.Coefficient;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ string temJxType = $"{item.Type}审核";
|
|
|
|
+
|
|
|
|
+ var temReviewerStatic = itemStatistics.Where<StaffStatistics>(s => s.StaffId == item.ReviewerId && s.jxType == temJxType && s.CalMonth.Id == calMonth.Id).FirstOrDefault();
|
|
|
|
+ if (temReviewerStatic != null)
|
|
|
|
+ {
|
|
|
|
+ temReviewerStatic.totalBasePoint += reviewerBasePoint;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (item.Reviewer.IsOnJob && itemStaff.DoPerson.Status != "试用期") //判断是否在职
|
|
|
|
+ {
|
|
|
|
+ temReviewerStatic = new StaffStatistics()
|
|
|
|
+ {
|
|
|
|
+ CalMonth = calMonth,
|
|
|
|
+ CalMonthId = calMonth.Id,
|
|
|
|
+ StaffId = item.ReviewerId.Value,
|
|
|
|
+ totalBasePoint = reviewerBasePoint,
|
|
|
|
+ jxType = temJxType
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ itemStatistics.Add(temReviewerStatic);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 计算各处理人的绩效点数
|
|
|
|
+ double handlerBasePoint;
|
|
|
|
+ if (item.Type != "专案")
|
|
|
|
+ {
|
|
|
|
+ if (isPJFP)
|
|
|
|
+ {
|
|
|
|
+ handlerBasePoint = item.BasePoint.Value * 1.0 / total;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ handlerBasePoint = item.BasePoint.Value * itemStaff.PerformancePoint.Value / total;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ handlerBasePoint = itemStaff.PerformancePoint.Value;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ string handlerJxType = $"{item.Type}处理";
|
|
|
|
+ var temStatic = itemStatistics.Where<StaffStatistics>(s => s.StaffId == itemStaff.DoPersonId && s.jxType == handlerJxType && s.CalMonth.Id == calMonth.Id).FirstOrDefault();
|
|
|
|
+ if (temStatic != null)
|
|
|
|
+ {
|
|
|
|
+ if (item.Type != "专案")
|
|
|
|
+ {
|
|
|
|
+ temStatic.totalBasePoint += handlerBasePoint * itemStaff.DoPerson.StaffGrade.Coefficient;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ temStatic.totalBasePoint += handlerBasePoint;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (itemStaff.DoPerson.StaffGrade != null && itemStaff.DoPerson.IsOnJob)
|
|
|
|
+ {
|
|
|
|
+ if (item.Type != "专案")
|
|
|
|
+ {
|
|
|
|
+ if (itemStaff.DoPerson.Status == "试用期" && item.Reviewer != null)
|
|
|
|
+ {
|
|
|
|
+ temStatic = new StaffStatistics()
|
|
|
|
+ {
|
|
|
|
+ CalMonth = calMonth,
|
|
|
|
+ CalMonthId = calMonth.Id,
|
|
|
|
+ StaffId = item.Reviewer.Id,
|
|
|
|
+ totalBasePoint = handlerBasePoint * item.Reviewer.StaffGrade.Coefficient,
|
|
|
|
+ jxType = handlerJxType
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ itemStatistics.Add(temStatic);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ temStatic = new StaffStatistics()
|
|
|
|
+ {
|
|
|
|
+ CalMonth = calMonth,
|
|
|
|
+ CalMonthId = calMonth.Id,
|
|
|
|
+ StaffId = itemStaff.DoPersonId,
|
|
|
|
+ totalBasePoint = handlerBasePoint * itemStaff.DoPerson.StaffGrade.Coefficient,
|
|
|
|
+ jxType = handlerJxType
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ itemStatistics.Add(temStatic);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ temStatic = new StaffStatistics()
|
|
|
|
+ {
|
|
|
|
+ CalMonth = calMonth,
|
|
|
|
+ CalMonthId = calMonth.Id,
|
|
|
|
+ StaffId = itemStaff.DoPersonId,
|
|
|
|
+ totalBasePoint = handlerBasePoint,
|
|
|
|
+ jxType = handlerJxType
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ itemStatistics.Add(temStatic);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return itemStatistics;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 计算指定用户,指定年月的绩效统计信息
|
|
/// 计算指定用户,指定年月的绩效统计信息
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -723,55 +746,198 @@ namespace wispro.sp.api.Controllers
|
|
|
|
|
|
return str;
|
|
return str;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ [HttpGet,HttpPost]
|
|
|
|
+ public FileProcessTask ExportData(QueryFilter queryFilter)
|
|
|
|
+ {
|
|
|
|
+ var filename = $"{DateTime.Now.ToString("yyyyMMddhhmmss")}-绩效数据下载.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);
|
|
|
|
+ ThreadObject threadObject = new ThreadObject()
|
|
|
|
+ {
|
|
|
|
+ queryFilter = queryFilter,
|
|
|
|
+ fileTask = fileTask
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ System.Threading.Thread t = new System.Threading.Thread(new ParameterizedThreadStart(ExportDataThread));
|
|
|
|
+ t.Start(threadObject);
|
|
|
|
+
|
|
|
|
+ return fileTask;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ internal class ThreadObject
|
|
|
|
+ {
|
|
|
|
+ public QueryFilter queryFilter { get; set; }
|
|
|
|
+ public FileProcessTask fileTask { get; set; }
|
|
|
|
+ }
|
|
|
|
|
|
- [HttpPost]
|
|
|
|
- public ListApiResponse<PerformanceItem> QueryFilter(QueryFilter queryFilter)
|
|
|
|
|
|
+ private void ExportDataThread(object tObj)
|
|
{
|
|
{
|
|
|
|
+ QueryFilter queryFilter = ((ThreadObject)tObj).queryFilter;
|
|
|
|
+ FileProcessTask fileTask = ((ThreadObject)tObj).fileTask;
|
|
|
|
|
|
- ListApiResponse<PerformanceItem> ret = new ListApiResponse<PerformanceItem>();
|
|
|
|
|
|
+ IQueryable<PerformanceItem> response = NewMethod(queryFilter);
|
|
|
|
+
|
|
|
|
+ var retList = response
|
|
|
|
+ .Include(p=>p.Customer)
|
|
|
|
+ .Include(p=>p.ItemStaffs).ThenInclude(p=>p.DoPerson).ThenInclude(p=>p.StaffGrade)
|
|
|
|
+ .Include(p=>p.Reviewer).ThenInclude(p=>p.StaffGrade)
|
|
|
|
+ .Include(p=>p.PreOastaff)
|
|
|
|
+ .Include(p=>p.CalMonth)
|
|
|
|
+ .ToList<PerformanceItem>();
|
|
|
|
|
|
- string strExpress = "";
|
|
|
|
|
|
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(strExpress))
|
|
|
|
- {
|
|
|
|
- strExpress = $"{strExpress} && s.CalMonth.Status == {Convert.ToInt32(queryFilter.jxType)}";
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- strExpress = $"s.CalMonth.Status == {Convert.ToInt32(queryFilter.jxType)}";
|
|
|
|
- }
|
|
|
|
|
|
+ DataTable dt = new DataTable();
|
|
|
|
+ #region 添加栏位
|
|
|
|
+ dt.Columns.Add("我方文号",typeof(string));
|
|
|
|
+ dt.Columns.Add("申请类型", typeof(string));
|
|
|
|
+ dt.Columns.Add("业务类型", typeof(string));
|
|
|
|
+ dt.Columns.Add("备注(填表注意事项)", typeof(string));
|
|
|
|
+ dt.Columns.Add("处理事项", typeof(string));
|
|
|
|
+ dt.Columns.Add("案件阶段", typeof(string));
|
|
|
|
+ dt.Columns.Add("案件系数", typeof(string));
|
|
|
|
+ dt.Columns.Add("处理事项系数", typeof(string));
|
|
|
|
+ dt.Columns.Add("前一次OA处理事项系数", typeof(string));
|
|
|
|
+ dt.Columns.Add("前一次OA处理人", typeof(string));
|
|
|
|
+ dt.Columns.Add("处理人等级", typeof(string));
|
|
|
|
+ dt.Columns.Add("基本点数", typeof(string));
|
|
|
|
+ dt.Columns.Add("核稿系数", typeof(string));
|
|
|
|
+ dt.Columns.Add("核稿绩效", typeof(string));
|
|
|
|
+ dt.Columns.Add("处理人", typeof(string));
|
|
|
|
+ dt.Columns.Add("核稿人", typeof(string));
|
|
|
|
+ dt.Columns.Add("客户名称", typeof(string));
|
|
|
|
+ dt.Columns.Add("申请人", typeof(string));
|
|
|
|
+ dt.Columns.Add("处理事项完成日", typeof(string));
|
|
|
|
+ dt.Columns.Add("定稿日", typeof(string));
|
|
|
|
+ dt.Columns.Add("返稿日", typeof(string));
|
|
|
|
+ dt.Columns.Add("案件类型", typeof(string));
|
|
|
|
+ dt.Columns.Add("案件状态", typeof(string));
|
|
|
|
+ dt.Columns.Add("处理事项备注", typeof(string));
|
|
|
|
+ dt.Columns.Add("处理状态", typeof(string));
|
|
|
|
+ dt.Columns.Add("案件名称", typeof(string));
|
|
|
|
+ dt.Columns.Add("委案日期", typeof(string));
|
|
|
|
+ dt.Columns.Add("客户期限", typeof(string));
|
|
|
|
+ dt.Columns.Add("内部期限", typeof(string));
|
|
|
|
+ dt.Columns.Add("初稿日", typeof(string));
|
|
|
|
+ dt.Columns.Add("备注(发文严重超期是否属客观原因,若为否,请填写原因)", typeof(string));
|
|
|
|
+ dt.Columns.Add("备注", typeof(string));
|
|
|
|
+ #endregion
|
|
|
|
|
|
- if (queryFilter.ConditionTree != null)
|
|
|
|
|
|
+ List<VerifyCoefficient> verifyCoefficients = new spDbContext().VerifyCoefficients.ToList();
|
|
|
|
+ fileTask.Size = retList.Count;
|
|
|
|
+
|
|
|
|
+ foreach (var item in retList)
|
|
{
|
|
{
|
|
- string strTem = GetExpress(queryFilter.ConditionTree);
|
|
|
|
|
|
+ fileTask.Processed += 1;
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(strTem))
|
|
|
|
|
|
+ if (item.CaseNo.StartsWith("J"))
|
|
{
|
|
{
|
|
- strExpress = $"{strExpress} && ({strTem})";
|
|
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
|
|
- var interpreter = new Interpreter();
|
|
|
|
- Expression<Func<PerformanceItem, bool>> dynamicWhere = interpreter.ParseAsExpression<Func<PerformanceItem, bool>>(strExpress, "s");
|
|
|
|
|
|
+ if (item.CaseNo == "")
|
|
|
|
+ {
|
|
|
|
+ System.Diagnostics.Debug.WriteLine(item.CaseNo);
|
|
|
|
+ }
|
|
|
|
+ var row = dt.NewRow();
|
|
|
|
+ row["我方文号"] = item.CaseNo;
|
|
|
|
+ row["申请类型"] = item.ApplicationType;
|
|
|
|
+ row["业务类型"] = item.BusinessType;
|
|
|
|
+ row["备注(填表注意事项)"] = item.AgentFeedbackMemo;
|
|
|
|
+ row["处理事项"] = item.DoItem;
|
|
|
|
+ row["案件阶段"] = item.CaseStage;
|
|
|
|
+ row["案件系数"] = item.CaseCoefficient;
|
|
|
|
+ row["处理事项系数"] = item.DoItemCoefficient;
|
|
|
|
+ row["前一次OA处理事项系数"] = "";
|
|
|
|
+
|
|
|
|
+ if (item.PreOastaffId.HasValue)
|
|
|
|
+ {
|
|
|
|
+ row["前一次OA处理人"] = item.PreOastaff?.Name;
|
|
|
|
+ }
|
|
|
|
|
|
- IQueryable<PerformanceItem> response;
|
|
|
|
- if (queryFilter.userId > 0)
|
|
|
|
- {
|
|
|
|
- response = Context.PerformanceItems.Where<PerformanceItem>(dynamicWhere).Where(s => (s.ItemStaffs.Where<ItemStaff>(iStaff => iStaff.DoPerson.Id == queryFilter.userId).Count() > 0));// || s.ReviewerId == queryFilter.userId));
|
|
|
|
|
|
+ string strISLevels = "";
|
|
|
|
+ string strISNames = "";
|
|
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- response = Context.PerformanceItems.Where<PerformanceItem>(dynamicWhere);
|
|
|
|
|
|
+ foreach (var istaff in item.ItemStaffs)
|
|
|
|
+ {
|
|
|
|
+ strISLevels = string.IsNullOrEmpty(strISLevels) ? istaff.DoPerson.StaffGrade.Grade : $"{strISLevels},{istaff.DoPerson.StaffGrade.Grade}";
|
|
|
|
+ strISNames = string.IsNullOrEmpty(strISNames) ? istaff.DoPerson.Name : $"{strISNames},{istaff.DoPerson.Name}";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ row["处理人等级"] = strISLevels;
|
|
|
|
+ row["基本点数"] = item.BasePoint;
|
|
|
|
+ row["处理人"] = strISNames;
|
|
|
|
+ row["核稿人"] = item.Reviewer?.Name;
|
|
|
|
+
|
|
|
|
+ if (item.ReviewerId != null && item.BasePoint.HasValue)
|
|
|
|
+ {
|
|
|
|
+ var jxList = _calItemJX(item.CalMonth, verifyCoefficients, item, new spDbContext());
|
|
|
|
+
|
|
|
|
+ row["核稿系数"] = "";
|
|
|
|
+ var temJx = jxList.FirstOrDefault<StaffStatistics>(s => s.jxType.Contains("审核") && s.StaffId == item.ReviewerId);
|
|
|
|
+ if (temJx != null)
|
|
|
|
+ {
|
|
|
|
+ row["核稿绩效"] = temJx.totalBasePoint;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ row["客户名称"] = item.Customer?.Name;
|
|
|
|
+ row["申请人"] = item.ApplicationName;
|
|
|
|
+ row["处理事项完成日"] = item.FinishedDate?.ToString("yyyy-MM-dd");
|
|
|
|
+ row["定稿日"] = item.FinalizationDate?.ToString("yyyy-MM-dd");
|
|
|
|
+ row["返稿日"] = item.ReturnDate?.ToString("yyyy-MM-dd");
|
|
|
|
+ row["案件类型"] = item.CaseType;
|
|
|
|
+ row["案件状态"] = item.CaseState;
|
|
|
|
+ row["处理事项备注"] = item.DoItemState;
|
|
|
|
+ row["处理状态"] = item.DoItemState;
|
|
|
|
+ row["案件名称"] = item.CaseName;
|
|
|
|
+ row["委案日期"] = item.EntrustingDate?.ToString("yyyy-MM-dd");
|
|
|
|
+ row["客户期限"] = item.CustomerLimitDate?.ToString("yyyy-MM-dd");
|
|
|
|
+ row["内部期限"] = item.InternalDate?.ToString("yyyy-MM-dd"); ;
|
|
|
|
+ row["初稿日"] = item.FirstDraftDate?.ToString("yyyy-MM-dd");
|
|
|
|
+ row["备注(发文严重超期是否属客观原因,若为否,请填写原因)"] = item.OverDueMemo;
|
|
|
|
+ row["备注"] = item.DoItemMemo;
|
|
|
|
+
|
|
|
|
+ dt.Rows.Add(row);
|
|
|
|
+ }
|
|
|
|
+ catch(Exception ex)
|
|
|
|
+ {
|
|
|
|
+ throw ex;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ utility.NPOIExcel.DataTableToExcel(dt,fileTask.FilePath);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ fileTask.Finished = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [HttpPost]
|
|
|
|
+ public ListApiResponse<PerformanceItem> QueryFilter(QueryFilter queryFilter)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ ListApiResponse<PerformanceItem> ret = new ListApiResponse<PerformanceItem>();
|
|
|
|
+
|
|
|
|
+ IQueryable<PerformanceItem> response = NewMethod(queryFilter);
|
|
|
|
|
|
int totals = response.ToList<PerformanceItem>().Count;
|
|
int totals = response.ToList<PerformanceItem>().Count;
|
|
|
|
|
|
- if (totals > 0 && totals < (queryFilter.PageIndex - 1) * queryFilter.PageSize) {
|
|
|
|
|
|
+ if (totals > 0 && totals < (queryFilter.PageIndex - 1) * queryFilter.PageSize)
|
|
|
|
+ {
|
|
response = response
|
|
response = response
|
|
.Include(pi => pi.ItemStaffs).ThenInclude(iStaff => iStaff.DoPerson)
|
|
.Include(pi => pi.ItemStaffs).ThenInclude(iStaff => iStaff.DoPerson)
|
|
.Include(pi => pi.Reviewer)
|
|
.Include(pi => pi.Reviewer)
|
|
@@ -792,7 +958,7 @@ namespace wispro.sp.api.Controllers
|
|
}
|
|
}
|
|
ret.TotalCount = totals;
|
|
ret.TotalCount = totals;
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
var retList = response.ToList<PerformanceItem>();
|
|
var retList = response.ToList<PerformanceItem>();
|
|
|
|
|
|
@@ -831,7 +997,49 @@ namespace wispro.sp.api.Controllers
|
|
|
|
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ private IQueryable<PerformanceItem> NewMethod(QueryFilter queryFilter)
|
|
|
|
+ {
|
|
|
|
+ string strExpress = "";
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (!string.IsNullOrEmpty(strExpress))
|
|
|
|
+ {
|
|
|
|
+ strExpress = $"{strExpress} && s.CalMonth.Status == {Convert.ToInt32(queryFilter.jxType)}";
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strExpress = $"s.CalMonth.Status == {Convert.ToInt32(queryFilter.jxType)}";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (queryFilter.ConditionTree != null)
|
|
|
|
+ {
|
|
|
|
+ string strTem = GetExpress(queryFilter.ConditionTree);
|
|
|
|
+
|
|
|
|
+ if (!string.IsNullOrEmpty(strTem))
|
|
|
|
+ {
|
|
|
|
+ strExpress = $"{strExpress} && ({strTem})";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var interpreter = new Interpreter();
|
|
|
|
+ Expression<Func<PerformanceItem, bool>> dynamicWhere = interpreter.ParseAsExpression<Func<PerformanceItem, bool>>(strExpress, "s");
|
|
|
|
+
|
|
|
|
+ IQueryable<PerformanceItem> response;
|
|
|
|
+ if (queryFilter.userId > 0)
|
|
|
|
+ {
|
|
|
|
+ response = new spDbContext().PerformanceItems.Where<PerformanceItem>(dynamicWhere).Where(s => (s.ItemStaffs.Where<ItemStaff>(iStaff => iStaff.DoPerson.Id == queryFilter.userId).Count() > 0));// || s.ReviewerId == queryFilter.userId));
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ response = new spDbContext().PerformanceItems.Where<PerformanceItem>(dynamicWhere);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+
|
|
public ApiSaveResponse AddProjectPerformance(ProjectPointRecord pointRecord)
|
|
public ApiSaveResponse AddProjectPerformance(ProjectPointRecord pointRecord)
|
|
{
|
|
{
|
|
ApiSaveResponse retResponse = new ApiSaveResponse();
|
|
ApiSaveResponse retResponse = new ApiSaveResponse();
|