public static List <SoLieuThongKe> ThongKeDonViTheoNhom(int DepartmentGroupID, DateTime?tuNgay = null, DateTime?denNgay = null, string connectionName = "DatabaseConnection") { var result = new List <SoLieuThongKe>(); foreach (var department in DepartmentServices.GetList(DepartmentGroupID: DepartmentGroupID).OrderBy(department => department.DisplayOrder).ThenBy(department => department.DepartmentName)) { var items = PerformServices.GetList(departmentId: department.DepartmentID, fromDate: tuNgay, toDate: denNgay); result.Add(new SoLieuThongKe { ObjectID = department.DepartmentID, ObjectName = department.DepartmentName, NotPerform = items.Count(item => item.Status == 0), NotPerformInTerm = items.Count(item => item.Status == 0 && item.RequiredDate >= DateTime.Now.Date), NotPerformOutTerm = items.Count(item => item.Status == 0 && item.RequiredDate < DateTime.Now.Date), Performing = items.Count(item => item.Status == 1), PerformingInTerm = items.Count(item => item.Status == 1 && item.RequiredDate >= DateTime.Now.Date), PerformingOutTerm = items.Count(item => item.Status == 1 && item.RequiredDate < DateTime.Now.Date), WaitToConfirm = items.Count(item => item.Status == 3), Done = items.Count(item => item.Status == 2), DoneInTerm = items.Count(item => item.Status == 2 && item.RequiredDate >= item.FinishedOnDate.Date), DoneOutTerm = items.Count(item => item.Status == 2 && item.RequiredDate < item.FinishedOnDate.Date), Total = items.Count }); } return(result); }
/// <summary> /// Lưu thông tin ý kiến chỉ đạo mới /// </summary> /// <param name="request"></param> /// <param name="trackerIds"></param> /// <param name="departmentIds"></param> /// <param name="userIds"></param> public static void Create(Request request, List <int> trackerIds, List <int> departmentIds = null, List <int> userIds = null, bool isFinishedConfirm = false) { Create(request); if (trackerIds != null) { foreach (var trackerId in trackerIds) { Tracking tracking = new Tracking(request.RequestID, trackerId); TrackingServices.Create(tracking); } } if (departmentIds != null) { foreach (var departmentId in departmentIds) { Perform perform = new Perform(requestId: request.RequestID, departmentId: departmentId, requiredDate: request.RequiredDate); perform.IsFinishedConfirm = isFinishedConfirm; PerformServices.CreatePerform(perform); } } if (userIds != null) { foreach (var userId in userIds.Where(u => !departmentIds.Contains(UserServices.GetById(u).DepartmentID))) { Perform perform = new Perform(requestId: request.RequestID, userId: userId, requiredDate: request.RequiredDate); PerformServices.CreatePerform(perform); } } }
public static List <SoLieuThongKe> ThongKeTheoTatCaNhomDonVi_TrangChu(string connectionName = "DatabaseConnection") { var result = new List <SoLieuThongKe>(); foreach (var departmentGroup in DepartmentGroupServices.GetList(isShowStatistic: true)) { var items = PerformServices.GetList(departmentGroupId: departmentGroup.DepartmentGroupID); var doneItems = PerformServices.GetList(departmentGroupId: departmentGroup.DepartmentGroupID, fromDate: new DateTime(DateTime.Now.Year, 1, 1)); result.Add(new SoLieuThongKe { ObjectID = departmentGroup.DepartmentGroupID, ObjectName = departmentGroup.DepartmentGroupName, NotPerform = items.Count(item => item.Status == 0), NotPerformInTerm = items.Count(item => item.Status == 0 && item.RequiredDate >= DateTime.Now.Date), NotPerformOutTerm = items.Count(item => item.Status == 0 && item.RequiredDate < DateTime.Now.Date), Performing = items.Count(item => item.Status == 1), PerformingInTerm = items.Count(item => item.Status == 1 && item.RequiredDate >= DateTime.Now.Date), PerformingOutTerm = items.Count(item => item.Status == 1 && item.RequiredDate < DateTime.Now.Date), WaitToConfirm = items.Count(item => item.Status == 3), Done = doneItems.Count(item => item.Status == 2), DoneInTerm = doneItems.Count(item => item.Status == 2 && item.RequiredDate >= item.FinishedOnDate.Date), DoneOutTerm = doneItems.Count(item => item.Status == 2 && item.RequiredDate < item.FinishedOnDate.Date), Total = items.Count }); } return(result); }
public static List <SoLieuThongKe> ThongKeTheoTatCaChuyenVienTheoDoi(DateTime?tuNgay = null, DateTime?denNgay = null) { var result = new List <SoLieuThongKe>(); foreach (var user in UserServices.GetList(roles: new[] { UserRole.ChuyenVienVP, UserRole.Administrator })) { var items = GetList(MaNguoiTheoDoi: user.UserID, tuNgay: tuNgay, denNgay: denNgay); result.Add(new SoLieuThongKe { ObjectID = user.UserID, ObjectName = user.FullName, GroupID = user.DepartmentID, GroupName = user.Department.DepartmentName, NotPerform = items.Count(item => item.Status == 0), NotPerformInTerm = items.Count(item => item.Status == 0 && item.RequiredDate.Date >= DateTime.Now.Date), NotPerformOutTerm = items.Count(item => item.Status == 0 && item.RequiredDate.Date < DateTime.Now.Date), Performing = items.Count(item => item.Status == 1), PerformingInTerm = items.Count(item => item.Status == 1 && item.RequiredDate.Date >= DateTime.Now.Date), PerformingOutTerm = items.Count(item => item.Status == 1 && item.RequiredDate.Date < DateTime.Now.Date), WaitToConfirm = PerformServices.GetList(maNguoiTheoDoi: user.UserID, fromDate: tuNgay).Where(item => item.Status == 3).Select(item => item.RequestID).Distinct().Count(), Done = items.Count(item => item.Status == 2), DoneInTerm = items.Count(item => item.Status == 2 && item.RequiredDate.Date >= item.FinishedOnDate.Date), DoneOutTerm = items.Count(item => item.Status == 2 && item.RequiredDate.Date < item.FinishedOnDate.Date), Total = items.Count }); } return(result); }
/// <summary> /// Kiểm tra quyền báo cáo tình hình thực hiện ý kiến chỉ đạo /// </summary> /// <param name="requestID"></param> /// <returns></returns> public static bool CheckReportPermission(long requestID) { //Nếu là tài khoản admin thì được báo cáo tình hình thực hiện tất cả những YKCD của đơn vị if (CommonSessions.Role == UserRole.Administrator) { return(true); } var request = RequestServices.GetById(requestID); if (request == null) { return(false); } //Nếu đây là ý kiến chỉ đạo của UBND tỉnh if (request.IsAgencyRequest) { //Lãnh đạo đơn vị, lãnh đạo VP, chuyên viên VP, quản trị hệ thống có quyền báo cáo trực tiếp if (CommonSessions.Role == UserRole.LanhDaoDonVi || CommonSessions.Role == UserRole.LanhDaoVP || CommonSessions.Role == UserRole.ChuyenVienVP || CommonSessions.Role == UserRole.Administrator) { return(true); } } //Nếu tài khoản đang đăng nhập là tài khoản cá nhân if (CommonSessions.UserID > 0) { //Người nhập YKCD, người theo dõi, người yêu cầu, người thực hiện có quyền báo cáo if (request.CreatedBy == CommonSessions.UserID || request.Trackings.Any(t => t.UserID == CommonSessions.UserID) || request.Performs.Any(p => p.UserID == CommonSessions.UserID) || request.RequesterID == CommonSessions.UserID) { return(true); } } //Nếu tài khoản đang đăng nhập là tài khoản đơn vị if (CommonSessions.DepartmentID > 0) { //Những đưn vị được phân công thực hiện có quyền báo cáo if (PerformServices.GetList(requestID).Any(item => item.DepartmentID == CommonSessions.DepartmentID)) { return(true); } } return(false); }
/// <summary> /// Giao việc một ý kiến chỉ đạo cho cá nhân, đơn vị thực hiện /// </summary> /// <param name="request">Thông tin ý kiến chỉ đạo</param> /// <param name="requesterId">Mã người giao việc</param> /// <param name="trackerIds">Mã người theo dõi</param> /// <param name="departmentIds">Mã đơn vị thực hiện</param> /// <param name="isFinishedConfirm">Có cần xác nhận</param> public static void Assign(Request request, int requesterId, List <int> trackerIds, List <int> departmentIds, bool isFinishedConfirm) { foreach (var trackerId in trackerIds) { Tracking tracking = new Tracking(request.RequestID, trackerId); TrackingServices.Create(tracking); } foreach (var departmentId in departmentIds) { Perform perform = new Perform(requestId: request.RequestID, departmentId: departmentId, requiredDate: request.RequiredDate); perform.IsFinishedConfirm = isFinishedConfirm; PerformServices.CreatePerform(perform); } var orgRequest = GetById(request.RequestID); orgRequest.Status = 1; orgRequest.IsAssignPerform = true; orgRequest.RequesterID = requesterId; Update(orgRequest); if (request.IsAgencyRequest) { orgRequest.CreatedBy = CommonSessions.UserID; Update(orgRequest); Report report = new Report() { ReportContent = $"Đã giao cho {request.Departments?.Select(i => i.DepartmentName)?.ToList()?.DisplayInline()} thực hiện", PerformOnDate = DateTime.Now, RequestID = request.RequestID, Status = 1 }; AgencyServiceHelper.ReceiveReport(ConfigurationManager.AppSettings["Agency_Service"], report); } }
public static void Update(long performId, int status, DateTime performOnDate, bool isNeedConfirm) { var perform = PerformServices.GetById(performId); if (perform != null) { perform.Status = status; if (status == 2 && perform.IsFinishedConfirm == true && isNeedConfirm) { perform.Status = 3; perform.FinishedOnDate = performOnDate; } else if (status == 2 && (!isNeedConfirm || !perform.IsFinishedConfirm)) { perform.Status = 2; perform.FinishedOnDate = performOnDate; } PerformServices.Update(perform); } RequestServices.CapNhatTrangThaiYKCD(perform.RequestID); }
public static void Create(Report report, List <int> performIds, object fileContent, string fileName, string uploadFolder, bool isStaffReport = false, bool isSendToAgency = false, bool isSendFromAgency = false) { if (!string.IsNullOrEmpty(report.ReportContent)) { Create(report); ReportFileServices.CreateReportFile(report, fileContent, fileName, uploadFolder); } Request request = RequestServices.GetById(report.RequestID); if (request.IsAgencyRequest) { if (request.Performs.Count > 0) { if (isSendFromAgency) { if (request.Status == 2) { foreach (var perform in request.Performs) { PerformServices.Update(performId: perform.PerformID, status: report.Status, performOnDate: report.PerformOnDate, isNeedConfirm: false); } } } else if (isStaffReport) { if (performIds != null) { foreach (var performId in performIds) { PerformServices.Update(performId: performId, status: report.Status, performOnDate: report.PerformOnDate, isNeedConfirm: false); } report.Status = RequestServices.CapNhatTrangThaiYKCD(request.RequestID); } } else { PerformServices.Update(performId: performIds.FirstOrDefault(), status: report.Status, performOnDate: report.PerformOnDate, isNeedConfirm: true); report.Status = RequestServices.CapNhatTrangThaiYKCD(request.RequestID); } if (isSendToAgency) { if (report.Status == 3) { report.Status = 2; } AgencyServiceHelper.ReceiveReport(ConfigurationManager.AppSettings["Agency_Service"], report); } } else { if (!isSendFromAgency) { request.Status = report.Status; if (request.Status == 2) { request.FinishedOnDate = report.PerformOnDate; } RequestServices.Update(request); if (isSendToAgency) { if (report.Status == 3) { report.Status = 2; } AgencyServiceHelper.ReceiveReport(ConfigurationManager.AppSettings["Agency_Service"], report); } } } } else if (isStaffReport) { foreach (var performId in performIds) { PerformServices.Update(performId: performId, status: report.Status, performOnDate: report.PerformOnDate, isNeedConfirm: false); } } else { PerformServices.Update(performId: performIds.FirstOrDefault(), status: report.Status, performOnDate: report.PerformOnDate, isNeedConfirm: true); } }
/// <summary> /// Cập nhật thông tin ý kiến chỉ đạo /// </summary> /// <param name="request"></param> /// <param name="trackerIds"></param> /// <param name="departmentIds"></param> /// <param name="userIds"></param> public static void Update(Request request, List <int> trackerIds, List <int> departmentIds = null, List <int> userIds = null, bool isFinishedConfirm = false) { Update(request); #region Lưu thông tin chuyên viên theo dõi var oldTrackers = TrackingServices.GetList(request.RequestID); foreach (var oldTracker in oldTrackers) { if (!trackerIds.Contains(oldTracker.UserID)) { TrackingServices.Delete(oldTracker.TrackingID); } } foreach (var trackerId in trackerIds) { if (!oldTrackers.Select(t => t.UserID).Contains(trackerId)) { TrackingServices.Create(new Tracking(request.RequestID, trackerId)); } } #endregion #region Lưu thông tin đơn vị thực hiện if (departmentIds != null) { var oldDepartmentPerforms = request.Performs.Where(p => p.DepartmentID > 0); foreach (var oldPerform in oldDepartmentPerforms) { if (!departmentIds.Contains(oldPerform.DepartmentID)) { PerformServices.Delete(oldPerform.PerformID); } } foreach (var departmentId in departmentIds) { if (!oldDepartmentPerforms.Select(t => t.DepartmentID).Contains(departmentId)) { Perform perform = new Perform(requestId: request.RequestID, departmentId: departmentId, requiredDate: request.RequiredDate); perform.IsFinishedConfirm = isFinishedConfirm; PerformServices.CreatePerform(perform); } else { var perform = PerformServices.GetList(request.RequestID, departmentId: departmentId).FirstOrDefault(); if (perform != null) { perform.RequiredDate = request.RequiredDate; perform.IsFinishedConfirm = isFinishedConfirm; PerformServices.Update(perform); } } } } #endregion #region Lưu thông tin người thực hiện if (userIds != null) { var oldUserPerforms = request.Performs.Where(p => p.UserID > 0); foreach (var oldPerform in oldUserPerforms) { if (!userIds.Contains(oldPerform.UserID)) { PerformServices.Delete(oldPerform.PerformID); } } foreach (var userId in userIds) { if (!oldUserPerforms.Select(t => t.UserID).Contains(userId)) { Perform perform = new Perform(requestId: request.RequestID, userId: userId, requiredDate: request.RequiredDate); PerformServices.CreatePerform(perform); } else { var perform = PerformServices.GetList(request.RequestID, userId: userId).FirstOrDefault(); if (perform != null) { perform.RequiredDate = request.RequiredDate; PerformServices.Update(perform); } } } } #endregion }
/// <summary> /// Cập nhật lại trạng thái request sau khi cập nhật trạng thái perform bất kì /// </summary> /// <param name="MaYKCD"></param> /// <param name="connectionName"></param> public static int CapNhatTrangThaiYKCD(long MaYKCD, string connectionName = "DatabaseConnection") { var request = GetById(MaYKCD); if (request == null) { return(-1); } //Nếu đây là ý kiến chỉ đạo của UBND tỉnh if (request.IsAgencyRequest) { //Nếu ykcd của UB tỉnh đã hoàn thành, cập nhật các nội dung giao việc trong đơn vị thành đã hoàn thành if (request.Status == 2) { foreach (var perform in request.Performs) { perform.Status = 2; perform.FinishedOnDate = request.FinishedOnDate; PerformServices.Update(perform); } } //Nếu ykcd đã giao cho phòng ban thực hiện, cập nhật trạng thái ykcd thành đang thực hiện else if (request.Status == 0 && request.IsAssignPerform) { request.Status = 1; } //Nếu các nội dung giao việc đã hoàn thành, cập nhật trạng thái ykcd thành chờ xác nhận else if (request.Performs != null && request.Performs?.Count > 0 && request.Performs.TrueForAll(item => item.Status == 2) && request.Status != 2) { request.Status = 3; } else if (request.Performs != null && request.Performs?.Count > 0 && request.Performs.TrueForAll(item => item.Status == 2)) { request.Status = 2; } else { request.Status = 1; } } //Nếu đây là ykcd nội bộ đơn vị else { if (request.Performs.TrueForAll(item => item.Status == 0)) { request.Status = 0; } else if (request.Performs.TrueForAll(item => item.Status == 2)) { request.Status = 2; } else { request.Status = 1; } } Update(request); return(request.Status); }
public static SoLieuThongKe LaySoLieuThongKe_TrangChu(int MaNguoiTheoDoi = 0, int MaLanhDao = 0, int MaDonVi = 0, bool YkcdCuaUbndTinh = false) { if (MaNguoiTheoDoi > 0) { var items = GetList(MaNguoiTheoDoi: MaNguoiTheoDoi); var doneItems = GetList(MaNguoiTheoDoi: MaNguoiTheoDoi, tuNgay: new DateTime(DateTime.Now.Year, 1, 1)); if (items != null) { return new SoLieuThongKe { NotPerform = items.Count(item => item.Status == 0), NotPerformInTerm = items.Count(item => item.Status == 0 && item.RequiredDate >= DateTime.Now.Date), NotPerformOutTerm = items.Count(item => item.Status == 0 && item.RequiredDate < DateTime.Now.Date), Performing = items.Count(item => item.Status == 1), PerformingInTerm = items.Count(item => item.Status == 1 && item.RequiredDate >= DateTime.Now.Date), PerformingOutTerm = items.Count(item => item.Status == 1 && item.RequiredDate < DateTime.Now.Date), WaitToConfirm = PerformServices.GetList(maNguoiTheoDoi: MaNguoiTheoDoi).Where(item => item.Status == 3).Select(item => item.RequestID).Distinct().Count(), Done = doneItems.Count(item => item.Status == 2), DoneInTerm = doneItems.Count(item => item.Status == 2 && item.RequiredDate >= item.FinishedOnDate.Date), DoneOutTerm = doneItems.Count(item => item.Status == 2 && item.RequiredDate < item.FinishedOnDate.Date), Total = items.Count } } ; } else if (MaLanhDao > 0) { var items = GetList(MaNguoiGiaoViec: MaLanhDao); var doneItems = GetList(MaNguoiGiaoViec: MaLanhDao, tuNgay: new DateTime(DateTime.Now.Year, 1, 1)); if (items != null) { return new SoLieuThongKe { NotPerform = items.Count(item => item.Status == 0), NotPerformInTerm = items.Count(item => item.Status == 0 && item.RequiredDate >= DateTime.Now.Date), NotPerformOutTerm = items.Count(item => item.Status == 0 && item.RequiredDate < DateTime.Now.Date), Performing = items.Count(item => item.Status == 1), PerformingInTerm = items.Count(item => item.Status == 1 && item.RequiredDate >= DateTime.Now.Date), PerformingOutTerm = items.Count(item => item.Status == 1 && item.RequiredDate < DateTime.Now.Date), WaitToConfirm = PerformServices.GetList(maNguoiGiaoViec: MaLanhDao).Where(item => item.Status == 3).Select(item => item.RequestID).Distinct().Count(), Done = doneItems.Count(item => item.Status == 2), DoneInTerm = doneItems.Count(item => item.Status == 2 && item.RequiredDate >= item.FinishedOnDate.Date), DoneOutTerm = doneItems.Count(item => item.Status == 2 && item.RequiredDate < item.FinishedOnDate.Date), Total = items.Count } } ; } else if (MaDonVi > 0) { var items = GetList(MaDonViThucHien: MaDonVi); var doneItems = GetList(MaDonViThucHien: MaDonVi, tuNgay: new DateTime(DateTime.Now.Year, 1, 1)); if (items != null) { return new SoLieuThongKe { NotPerform = items.Count(item => item.Status == 0), NotPerformInTerm = items.Count(item => item.Status == 0 && item.RequiredDate >= DateTime.Now.Date), NotPerformOutTerm = items.Count(item => item.Status == 0 && item.RequiredDate < DateTime.Now.Date), Performing = items.Count(item => item.Status == 1), PerformingInTerm = items.Count(item => item.Status == 1 && item.RequiredDate >= DateTime.Now.Date), PerformingOutTerm = items.Count(item => item.Status == 1 && item.RequiredDate < DateTime.Now.Date), WaitToConfirm = items.Count(item => item.Status == 3), Done = doneItems.Count(item => item.Status == 2), DoneInTerm = doneItems.Count(item => item.Status == 2 && item.RequiredDate >= item.FinishedOnDate.Date), DoneOutTerm = doneItems.Count(item => item.Status == 2 && item.RequiredDate < item.FinishedOnDate.Date), Total = items.Count } } ; } else if (YkcdCuaUbndTinh) { var items = GetList(YkcdCuaUbndTinh: true); var doneItems = GetList(YkcdCuaUbndTinh: true, tuNgay: new DateTime(DateTime.Now.Year, 1, 1)); if (items != null) { return new SoLieuThongKe { NotPerform = items.Count(item => item.Status == 0), NotPerformInTerm = items.Count(item => item.Status == 0 && item.RequiredDate >= DateTime.Now.Date), NotPerformOutTerm = items.Count(item => item.Status == 0 && item.RequiredDate < DateTime.Now.Date), Performing = items.Count(item => item.Status == 1), PerformingInTerm = items.Count(item => item.Status == 1 && item.RequiredDate >= DateTime.Now.Date), PerformingOutTerm = items.Count(item => item.Status == 1 && item.RequiredDate < DateTime.Now.Date), WaitToConfirm = items.Count(item => item.Status == 3), Done = doneItems.Count(item => item.Status == 2), DoneInTerm = doneItems.Count(item => item.Status == 2 && item.RequiredDate >= item.FinishedOnDate.Date), DoneOutTerm = doneItems.Count(item => item.Status == 2 && item.RequiredDate < item.FinishedOnDate.Date), Total = items.Count } } ; } return(new SoLieuThongKe()); }