using Learun.Application.WorkFlow; using Learun.Util; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using Learun.Application.Organization; using Learun.Application.Base.AuthorizeModule; using Learun.Application.TwoDevelopment.LR_LGManager; namespace Learun.Application.Web.Areas.LR_NewWorkFlow.Controllers { /// /// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架 /// Copyright (c) 2013-2018 上海力软信息技术有限公司 /// 创建人:力软-框架开发组 /// 日 期:2018.12.09 /// 描 述:流程进程 /// public class NWFProcessController : MvcControllerBase { private NWFProcessIBLL nWFProcessIBLL = new NWFProcessBLL(); LC_hetongIBLL lcHetongIbll=new LC_hetongBLL(); private NWFSchemeIBLL nWFSchemeIBLL = new NWFSchemeBLL(); private NWFTaskIBLL nWFTaskIBLL = new NWFTaskBLL(); private UserIBLL userIbll = new UserBLL(); private UserRelationIBLL userRelationIBLL = new UserRelationBLL(); private StudentLeaveIBLL studentLeaveIBLL = new StudentLeaveBLL(); private StudentLeave_zcIBLL studentLeave_ZcIBLL = new StudentLeave_zcBLL(); #region 视图功能 /// /// 视图功能 /// /// [HttpGet] public ActionResult Index() { return View(); } /// /// 发起流程 /// /// [HttpGet] public ActionResult ReleaseForm() { return View(); } /// /// 流程容器 /// /// [HttpGet] public ActionResult NWFContainerForm() { return View(); } /// /// 查看节点审核信息 /// /// [HttpGet] public ActionResult LookNodeForm() { return View(); } /// /// 创建流程 /// /// [HttpGet] public ActionResult CreateForm() { return View(); } /// /// 审核流程 /// /// [HttpGet] public ActionResult AuditFlowForm() { return View(); } /// /// 加签审核流程 /// /// [HttpGet] public ActionResult SignAuditFlowForm() { return View(); } /// /// 加签审核 /// /// [HttpGet] public ActionResult SignFlowForm() { return View(); } /// /// 合同打印 /// /// [HttpGet] public ActionResult htPrint(string keyValue) { //获取校长的签名盖章 var listTaskLog = nWFTaskIBLL.GetLogList(keyValue); var nwfTaskLogEntity = listTaskLog.FirstOrDefault(a => a.F_TaskUserName == "关亮"); if (nwfTaskLogEntity != null) { ViewBag.StampImg = nwfTaskLogEntity.F_StampImg; ViewBag.SignImg = nwfTaskLogEntity.F_SignImg; } var data = nWFProcessIBLL.GetHTInfo(keyValue); var userInfo = new UserEntity(); if (data != null) { userInfo = userIbll.GetEntityByUserId(data.LC_sqwtr); } var beginTime = data?.LC_htkssj.ToDate(); var endTime = data?.LC_htjssj.ToDate(); var operationTime = nwfTaskLogEntity?.F_CreateDate; ViewBag.UserName = userInfo?.F_RealName; ViewBag.IDCard = userInfo?.F_IdentityCardNo; ViewBag.Htmc = data?.LC_htmc; ViewBag.BeginYear = beginTime?.Year; ViewBag.BeginMonth = beginTime?.Month; ViewBag.BeginDay = beginTime?.Day; ViewBag.EndYear = endTime?.Year; ViewBag.EndMonth = endTime?.Month; ViewBag.EndDay = endTime?.Day; ViewBag.OperationYear = operationTime?.Year; ViewBag.OperationMonth = operationTime?.Month; ViewBag.OperationDay = operationTime?.Day; return View(); } /// /// 流程进度查看(父子流程) /// /// [HttpGet] public ActionResult LookFlowForm() { return View(); } /// /// 监控页面 /// /// [HttpGet] public ActionResult MonitorIndex() { return View(); } /// /// 合同归档 /// /// [HttpGet] public ActionResult ContractFiling() { return View(); } [HttpGet] public ActionResult ContractFilingMonitor() { return View(); } /// /// 人事归档 /// /// [HttpGet] public ActionResult PersonalFiling() { return View(); } /// /// 监控详情页面 /// /// [HttpGet] public ActionResult MonitorDetailsIndex() { return View(); } /// /// 查看各个节点表单 /// /// [HttpGet] public ActionResult MonitorForm() { return View(); } /// /// 指定审核人 /// /// [HttpGet] public ActionResult AppointForm() { return View(); } /// /// 添加审核节点 /// /// [HttpGet] public ActionResult AddTaskForm() { return View(); } /// /// 批量审核页面 /// /// [HttpGet] public ActionResult BatchAuditIndex() { return View(); } /// /// 选择下一节点审核人员 /// /// [HttpGet] public ActionResult SelectUserForm() { return View(); } /// /// 签名弹层 /// /// public ActionResult SignForm() { ViewBag.IsHaveStampRight = false; var loginUserInfo = LoginUserInfo.Get(); if (loginUserInfo.Description.Contains("管理员") || loginUserInfo.roleIds.Split(',').Contains(Config.GetValue("StampRightRoleId"))) { ViewBag.IsHaveStampRight = true; } return View(); } /// /// 流程时间统计 /// /// [HttpGet] public ActionResult StatisticTimeIndex() { return View(); } /// /// 流程时间统计-饼图 /// /// [HttpGet] public ActionResult StatisticTimeForm() { return View(); } /// /// 流程次数统计 /// /// [HttpGet] public ActionResult StatisticCountIndex() { return View(); } /// /// 普通教师请假归档 /// /// [HttpGet] public ActionResult LeaveFiling() { return View(); } /// /// 普通教师请假流程监控 /// /// [HttpGet] public ActionResult LeaveFilingMonitor() { return View(); } /// /// 中层领导请假归档 /// /// [HttpGet] public ActionResult LeaderLeaveFiling() { return View(); } /// /// 中层领导请假流程监控 /// /// [HttpGet] public ActionResult LeaderLeaveFilingMonitor() { return View(); } #endregion #region 统计页面 [HttpGet] public ActionResult MonitorIndexRenShi() { return View(); } [HttpGet] public ActionResult MonitorIndexZiChan() { return View(); } [HttpGet] public ActionResult MonitorIndexGongWen() { return View(); } [HttpGet] public ActionResult MonitorIndexXingZhen() { return View(); } [HttpGet] public ActionResult StatsIndex() { return View(); } [HttpGet] public ActionResult TeachLeaveIndex() { return View(); } #endregion #region 获取数据 /// /// 获取我的流程信息列表 /// /// 分页参数 /// 查询条件 /// [HttpGet] [AjaxOnly] public ActionResult GetPorcessList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var list = nWFProcessIBLL.GetPageList(paginationobj, queryJson); var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } [HttpGet] [AjaxOnly] public ActionResult GetContractList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var list = lcHetongIbll.GetPageList(paginationobj, queryJson); var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } /// /// 获取我的流程信息列表 /// /// 分页参数 /// 查询条件 /// [HttpGet] [AjaxOnly] public ActionResult GetTaskPageList(string pagination, string queryJson, string categoryId) { Pagination paginationobj = pagination.ToObject(); IEnumerable list = new List(); UserInfo userInfo = LoginUserInfo.Get(); switch (categoryId) { case "1": list = nWFProcessIBLL.GetMyPageList(userInfo.userId, paginationobj, queryJson); break; case "2": list = nWFProcessIBLL.GetMyTaskPageList(userInfo, paginationobj, queryJson); break; case "3": list = nWFProcessIBLL.GetMyFinishTaskPageList(userInfo, paginationobj, queryJson); break; } var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } /// /// 获取批量审核任务清单 /// /// 分页参数 /// 查询条件 /// [HttpGet] [AjaxOnly] public ActionResult GetBatchTaskPageList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); UserInfo userInfo = LoginUserInfo.Get(); var data = nWFProcessIBLL.GetMyTaskPageList(userInfo, paginationobj, queryJson, true); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } /// /// 获取我的流程信息列表 /// /// 分页参数 /// 查询条件 /// [HttpGet] [AjaxOnly] public ActionResult GetTask(string taskId) { var data = nWFTaskIBLL.GetEntity(taskId); return Success(data); } /// /// 获取普通教师请假归档列表 /// /// /// /// [HttpGet] [AjaxOnly] public ActionResult GetLeaveList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var list = studentLeaveIBLL.GetPageList(paginationobj, queryJson); var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } /// /// 获取中层领导请假归档列表 /// /// /// /// [HttpGet] [AjaxOnly] public ActionResult GetLeaderLeaveList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var list = studentLeave_ZcIBLL.GetPageList(paginationobj, queryJson); var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } [HttpGet] [AjaxOnly] public ActionResult OfficialTravelStats(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var list = nWFProcessIBLL.OfficialTravelStats(paginationobj, queryJson); var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } [HttpGet] [AjaxOnly] public ActionResult TeachLeaveStats(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var list = studentLeaveIBLL.TeachLeaveStats(paginationobj, queryJson); var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } #endregion #region 保存更新删除 /// /// 删除流程进程实体 /// /// 流程进程主键 [HttpPost] [AjaxOnly] public ActionResult DeleteEntity(string processId) { nWFProcessIBLL.DeleteEntity(processId); return Success("删除成功"); } /// /// 流程合同监控--作废 /// /// 流程进程主键 [HttpPost] [AjaxOnly] public ActionResult UpdateEnabledMark(string processId,string EnabledMark) { nWFProcessIBLL.UpdateEnabledMark(processId, EnabledMark); return Success("操作成功"); } /// /// 普通教师请假归档 /// /// 请假主键 [HttpPost] [AjaxOnly] public ActionResult DoFileStudentLeave(string keyValue) { studentLeaveIBLL.DoFile(keyValue); return Success("归档成功"); } /// /// 中层领导请假归档 /// /// 请假主键 [HttpPost] [AjaxOnly] public ActionResult DoFileStudentLeaveZC(string keyValue) { studentLeave_ZcIBLL.DoFile(keyValue); return Success("归档成功"); } #endregion #region 流程API /// /// 获取流程模板 /// /// 流程编码 /// [HttpGet] [AjaxOnly] public ActionResult GetSchemeByCode(string code) { var schemeInfo = nWFSchemeIBLL.GetInfoEntityByCode(code); if (schemeInfo != null) { var data = nWFSchemeIBLL.GetSchemeEntity(schemeInfo.F_SchemeId); return Success(data); } return Fail("找不到该流程模板"); } /// /// 根据流程进程主键获取流程模板 /// /// 流程进程主键 /// [HttpGet] [AjaxOnly] public ActionResult GetSchemeByProcessId(string processId) { var processEntity = nWFProcessIBLL.GetEntity(processId); if (processEntity != null) { if (string.IsNullOrEmpty(processEntity.F_SchemeId)) { var schemeInfo = nWFSchemeIBLL.GetInfoEntityByCode(processEntity.F_SchemeCode); if (schemeInfo != null) { var data = nWFSchemeIBLL.GetSchemeEntity(schemeInfo.F_SchemeId); return Success(data); } } else { var data = nWFSchemeIBLL.GetSchemeEntity(processEntity.F_SchemeId); return Success(data); } } return Fail("找不到该流程模板"); } /// /// 获取流程下一节点审核 /// /// 流程编码 /// 流程进程主键 /// 任务主键 /// 节点ID /// 操作编码 /// [HttpGet] [AjaxOnly] public ActionResult GetNextAuditors(string code, string processId, string taskId, string nodeId, string operationCode) { UserInfo userInfo = LoginUserInfo.Get(); var data = nWFProcessIBLL.GetNextAuditors(code, processId, taskId, nodeId, operationCode, userInfo); return Success(data); } /// /// 获取流程进程信息 /// /// 进程主键 /// 任务主键 /// [HttpGet] [AjaxOnly] public ActionResult GetProcessDetails(string processId, string taskId) { UserInfo userInfo = LoginUserInfo.Get(); var data = nWFProcessIBLL.GetProcessDetails(processId, taskId, userInfo); if (!string.IsNullOrEmpty(data.childProcessId)) { processId = data.childProcessId; } var taskNode = nWFProcessIBLL.GetTaskUserList(processId); var jsonData = new { info = data, task = taskNode }; return Success(jsonData); } /// /// 获取子流程详细信息 /// /// 父流程进程主键 /// 父流程子流程发起主键 /// 子流程流程模板编码 /// 父流程发起子流程节点Id /// [HttpGet] [AjaxOnly] public ActionResult GetChildProcessDetails(string processId, string taskId, string schemeCode, string nodeId) { UserInfo userInfo = LoginUserInfo.Get(); var data = nWFProcessIBLL.GetChildProcessDetails(processId, taskId, schemeCode, nodeId, userInfo); var taskNode = nWFProcessIBLL.GetTaskUserList(data.childProcessId); var jsonData = new { info = data, task = taskNode }; return Success(jsonData); } /// /// 保存草稿 /// /// 流程进程主键 /// 流程模板编码 /// [HttpPost] [AjaxOnly] public ActionResult SaveDraft(string processId, string schemeCode, string createUserId) { UserInfo userInfo = LoginUserInfo.Get(); if (!string.IsNullOrEmpty(createUserId) && userInfo.userId != createUserId) { var userEntity = userIbll.GetEntityByUserId(createUserId); userInfo.userId = userEntity.F_UserId; userInfo.enCode = userEntity.F_EnCode; userInfo.realName = userEntity.F_RealName; userInfo.nickName = userEntity.F_NickName; userInfo.headIcon = userEntity.F_HeadIcon; userInfo.gender = userEntity.F_Gender; userInfo.mobile = userEntity.F_Mobile; userInfo.telephone = userEntity.F_Telephone; userInfo.email = userEntity.F_Email; userInfo.oICQ = userEntity.F_OICQ; userInfo.weChat = userEntity.F_WeChat; userInfo.companyId = userEntity.F_CompanyId; userInfo.departmentId = userEntity.F_DepartmentId; userInfo.openId = userEntity.F_OpenId; userInfo.isSystem = userEntity.F_SecurityLevel == 1 ? true : false; } nWFProcessIBLL.SaveDraft(processId, schemeCode, userInfo); return Success("流程草稿保存成功"); } /// /// 删除草稿 /// /// 流程进程主键 /// [HttpPost] [AjaxOnly] public ActionResult DeleteDraft(string processId) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.DeleteDraft(processId, userInfo); return Success("流程草稿删除成功"); } /// /// 创建流程 /// /// 流程模板编码 /// 流程进程主键 /// 流程进程自定义标题 /// 流程进程等级 /// 下一节点审核人 /// 流程创建人 /// [HttpPost] [AjaxOnly] public ActionResult CreateFlow(string schemeCode, string processId, string title, int level, string auditors, string createUserId) { UserInfo userInfo = LoginUserInfo.Get(); if (!string.IsNullOrEmpty(createUserId) && userInfo.userId != createUserId) { if (title == null) { title = ""; } title += "【" + userInfo.realName + "代发】"; var userEntity = userIbll.GetEntityByUserId(createUserId); userInfo.userId = userEntity.F_UserId; userInfo.enCode = userEntity.F_EnCode; userInfo.realName = userEntity.F_RealName; userInfo.nickName = userEntity.F_NickName; userInfo.headIcon = userEntity.F_HeadIcon; userInfo.gender = userEntity.F_Gender; userInfo.mobile = userEntity.F_Mobile; userInfo.telephone = userEntity.F_Telephone; userInfo.email = userEntity.F_Email; userInfo.oICQ = userEntity.F_OICQ; userInfo.weChat = userEntity.F_WeChat; userInfo.companyId = userEntity.F_CompanyId; userInfo.departmentId = userEntity.F_DepartmentId; userInfo.openId = userEntity.F_OpenId; userInfo.isSystem = userEntity.F_SecurityLevel == 1 ? true : false; userInfo.roleIds = userRelationIBLL.GetObjectIds(userEntity.F_UserId, 1); userInfo.postIds = userRelationIBLL.GetObjectIds(userEntity.F_UserId, 2); } try { nWFProcessIBLL.CreateFlow(schemeCode, processId, title, level, auditors, userInfo); return Success("流程创建成功"); } catch (System.Exception ex) { nWFProcessIBLL.SaveDraft(processId, schemeCode, userInfo); return Fail(ex.Message); } } /// /// 创建流程(子流程) /// /// 流程模板编码 /// 流程进程主键 /// 父流程进程主键 /// 父流程任务主键 /// [HttpPost] [AjaxOnly] public ActionResult CreateChildFlow(string schemeCode, string processId, string parentProcessId, string parentTaskId) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.CreateChildFlow(schemeCode, processId, parentProcessId, parentTaskId, userInfo); return Success("流程创建成功"); } /// /// 重新创建流程 /// /// 流程进程主键 /// [HttpPost] [AjaxOnly] public ActionResult AgainCreateFlow(string processId) { try { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.AgainCreateFlow(processId, userInfo); return Success("流程重新创建成功"); } catch (System.Exception ex) { return Fail(ex.Message); } } /// /// 审批流程 /// /// 流程审批操作码agree 同意 disagree 不同意 lrtimeout 超时 back 退回至上一个审核节点 /// 流程审批操名称 /// 流程进程主键 /// 流程任务主键 /// 审批意见 /// 下一节点指定审核人 /// [HttpPost] [AjaxOnly] public ActionResult AuditFlow(string operationCode, string operationName, string processId, string taskId, string des, string auditors, string stamp, string signUrl) { UserInfo userInfo = LoginUserInfo.Get(); try { //if (operationCode == "back")//退回至上一个审核节点【暂定】 //{ // nWFProcessIBLL.AuditFlow2(operationCode, operationName, processId, taskId, des, auditors, stamp, signUrl, userInfo); //} //else //{ // nWFProcessIBLL.AuditFlow(operationCode, operationName, processId, taskId, des, auditors, stamp, signUrl, userInfo); //} nWFProcessIBLL.AuditFlow(operationCode, operationName, processId, taskId, des, auditors, stamp, signUrl, userInfo); return Success("流程审批成功"); } catch (System.Exception ex) { return Fail(ex.Message); } } /// /// 审批流程 /// /// 流程审批操作码agree 同意 disagree 不同意 /// 任务串 /// [HttpPost] [AjaxOnly] public ActionResult AuditFlows(string operationCode, string taskIds) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.AuditFlows(operationCode, taskIds, userInfo); return Success("流程批量审批成功"); } /// /// 流程加签 /// /// 流程进程主键 /// 流程任务主键 /// 加签人员 /// 加签说明 /// [HttpPost] [AjaxOnly] public ActionResult SignFlow(string processId, string taskId, string userId, string des) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.SignFlow(processId, taskId, userId, des, userInfo); return Success("流程加签成功"); } /// /// 流程加签审核 /// /// 审核操作码 /// 流程进程主键 /// 流程任务主键 /// 加签说明 /// [HttpPost] [AjaxOnly] public ActionResult SignAuditFlow(string operationCode, string processId, string taskId, string des) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.SignAuditFlow(operationCode, processId, taskId, des, userInfo); return Success("加签审批成功"); } /// /// 确认阅读 /// /// 流程进程主键 /// 流程任务主键 /// [HttpPost] [AjaxOnly] public ActionResult ReferFlow(string processId, string taskId) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.ReferFlow(processId, taskId, userInfo); return Success("保存成功"); } /// /// 催办流程 /// /// 流程进程主键 /// 当前操作人信息 /// [HttpPost] [AjaxOnly] public ActionResult UrgeFlow(string processId) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.UrgeFlow(processId, userInfo); return Success("催办成功"); } /// /// 撤销流程(只有在该流程未被处理的情况下) /// /// 流程进程主键 /// [HttpPost] [AjaxOnly] public ActionResult RevokeFlow(string processId) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.RevokeFlow(processId, userInfo); return Success("撤销成功"); } /// /// 获取流程当前任务需要处理的人 /// /// 流程进程主键 /// [HttpGet] [AjaxOnly] public ActionResult GetTaskUserList(string processId) { var data = nWFProcessIBLL.GetTaskUserList(processId); return Success(data); } /// /// 指派流程审核人 /// /// 任务列表 [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult AppointUser(string strList) { IEnumerable list = strList.ToObject>(); UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.AppointUser(list, userInfo); return Success("指派成功"); } /// /// 作废流程 /// /// 流程进程主键 /// [HttpPost] [AjaxOnly] public ActionResult DeleteFlow(string processId) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.DeleteFlow(processId, userInfo); return Success("作废成功"); } /// /// 撤销审核 /// /// 流程进程主键 /// 任务主键 /// [HttpPost] [AjaxOnly] public ActionResult RevokeAudit(string processId, string taskId) { UserInfo userInfo = LoginUserInfo.Get(); var res = nWFProcessIBLL.RevokeAudit(processId, taskId, userInfo); if (res) { return Success("撤销成功"); } else { return Fail("撤销失败,当前不允许撤销!"); } } /// /// 添加任务 /// /// /// /// /// [HttpPost] [AjaxOnly] public ActionResult AddTask(string processId, string bNodeId, string eNodeId) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.AddTask(processId, bNodeId, eNodeId, userInfo); return Success("添加成功"); } #endregion #region 流程效率分析 /// /// 获取审批时间统计数据 /// /// /// public ActionResult GetStatisticTimeData(string processId) { var taskdata = nWFTaskIBLL.GetALLTaskList(processId).OrderByDescending(x => x.F_CreateDate); var legendData = new List(); var seriesData = new List(); foreach (var item in taskdata) { legendData.Add(item.F_ModifyUserName); seriesData.Add(new WfSchemeReportModelOfPie2() { name = item.F_ModifyUserName, value = (item.F_ModifyDate - item.F_CreateDate).HasValue ? (item.F_ModifyDate - item.F_CreateDate).Value.TotalMinutes.ToDecimal(2).ToString() : "0" }); } var jsonData = new { legendData = legendData, seriesData = seriesData }; return Success(jsonData); } /// /// 获取审批次数统计数据 /// /// /// public ActionResult GetStatisticCountData(string queryJson) { var taskdata = nWFTaskIBLL.GetFinishTaskList(); if (!string.IsNullOrEmpty(queryJson)) { var queryParam = queryJson.ToJObject(); if (!queryParam["year"].IsEmpty()) { var year = queryParam["year"].ToInt(); taskdata = taskdata.Where(x => x.F_ModifyDate.HasValue && x.F_ModifyDate.Value.Year == year); } } var taskgroup = taskdata.GroupBy(x => new { x.F_ModifyUserId, x.F_ModifyUserName }).Select(x => new { userId = x.Key.F_ModifyUserId, userName = x.Key.F_ModifyUserName, count = x.Select(y => y.F_Id).Count() }); var legendData = new List(); var seriesData = new List(); foreach (var item in taskgroup) { legendData.Add(item.userName); seriesData.Add(new WfSchemeReportModelOfPie() { value = item.count, name = item.userName }); } var jsonData = new { legendData = legendData, seriesData = seriesData }; return Success(jsonData); } #endregion } }