|
@@ -1,13 +1,17 @@
|
|
|
-using Microsoft.AspNetCore.Authorization;
|
|
|
+using DynamicExpresso;
|
|
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
+using System.Linq.Expressions;
|
|
|
using System.Threading.Tasks;
|
|
|
+using wispro.sp.api.Utility;
|
|
|
using wispro.sp.entity;
|
|
|
using wispro.sp.share;
|
|
|
+using wispro.sp.utility;
|
|
|
|
|
|
namespace wispro.sp.api.Controllers
|
|
|
{
|
|
@@ -264,7 +268,7 @@ namespace wispro.sp.api.Controllers
|
|
|
/// <param name="userid">用户id</param>
|
|
|
/// <param name="type">获取类型;0:处理中;1:所有;4:已归档</param>
|
|
|
/// <returns></returns>
|
|
|
- public ListApiResponse<PerformanceItem> GetMyList(int userid, int type,int pageIndex=1,int pageSize = 5)
|
|
|
+ public ListApiResponse<PerformanceItem> GetMyList(int userid, int type,int pageIndex=1,int pageSize = 10)
|
|
|
{
|
|
|
ListApiResponse<PerformanceItem> ret = new ListApiResponse<PerformanceItem>();
|
|
|
var results = Context.PerformanceItems
|
|
@@ -498,23 +502,62 @@ namespace wispro.sp.api.Controllers
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
public ListApiResponse<PerformanceItem> QueryFilter(QueryFilter queryFilter)
|
|
|
{
|
|
|
|
|
|
ListApiResponse<PerformanceItem> ret = new ListApiResponse<PerformanceItem>();
|
|
|
- ret.TotalCount = Context.PerformanceItems.Count<PerformanceItem>();
|
|
|
|
|
|
- List<PerformanceItem> retList = Context.PerformanceItems
|
|
|
- .Where<PerformanceItem>(s => (s.ItemStaffs
|
|
|
- .Where<ItemStaff>(iStaff => iStaff.DoPerson.Name == queryFilter.PersonName) .Count() > 0 || s.Reviewer.Name == queryFilter.PersonName) && s.CalMonth.Month == queryFilter.Month && s.CalMonth.Year == queryFilter.Year)
|
|
|
+ string strExpress = "";
|
|
|
+ if (queryFilter.userId > 0)
|
|
|
+ {
|
|
|
+ strExpress = $"(s.ItemStaffs.Where<ItemStaff>(iStaff => iStaff.DoPerson.Id == {queryFilter.userId}).Count() > 0))";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(strExpress))
|
|
|
+ {
|
|
|
+ strExpress = $"{strExpress} && s.CalMonth.Status == {Convert.ToInt32(queryFilter.jxType)}";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ var interpreter = new Interpreter();
|
|
|
+ Expression<Func<PerformanceItem, bool>> dynamicWhere = interpreter.ParseAsExpression<Func<PerformanceItem, bool>>(strExpress, "s");
|
|
|
+
|
|
|
+ var response = Context.PerformanceItems.Where<PerformanceItem>(dynamicWhere);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response = response.OrderConditions<PerformanceItem>(queryFilter.Sorts);
|
|
|
+ ret.TotalCount = response.Count();
|
|
|
+
|
|
|
+ var retList = response
|
|
|
.Include(pi => pi.ItemStaffs).ThenInclude(iStaff => iStaff.DoPerson)
|
|
|
.Include(pi => pi.Reviewer)
|
|
|
.Include(pi => pi.Customer)
|
|
|
-
|
|
|
- .OrderByDescending(o => o.Id)
|
|
|
- .Skip<PerformanceItem>((queryFilter.pageIndex - 1) * queryFilter.pageSize).Take(queryFilter.pageSize).ToList<PerformanceItem>();
|
|
|
+ .Skip<PerformanceItem>((queryFilter.PageIndex - 1) * queryFilter.PageSize).Take(queryFilter.PageSize).ToList<PerformanceItem>();
|
|
|
+
|
|
|
+
|
|
|
+ #region 将某些属性设为null,避免循环取值造成返回json过大
|
|
|
+ foreach (PerformanceItem item in retList)
|
|
|
+ {
|
|
|
+ foreach (ItemStaff itemStaff in item.ItemStaffs)
|
|
|
+ {
|
|
|
+ itemStaff.DoPerson.ItemStaffs = null;
|
|
|
+ itemStaff.DoPerson.ReviewerItems = null;
|
|
|
+ itemStaff.Item = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ item.Reviewer.ReviewerItems = null;
|
|
|
+ item.Reviewer.Customers = null;
|
|
|
+ item.Reviewer.ItemStaffs = null;
|
|
|
+
|
|
|
+ item.Customer.PerformanceItems = null;
|
|
|
+ item.CalMonth.PerformanceItems = null;
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
|
|
|
- //Context.PerformanceItems.Where<PerformanceItem>(p=>p.ItemStaffs.Where<ItemStaff>)
|
|
|
ret.Results = retList;
|
|
|
|
|
|
return ret;
|