diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/ADR_RecordController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/ADR_RecordController.cs index 517c1c215..0a4e65137 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/ADR_RecordController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/ADR_RecordController.cs @@ -62,6 +62,16 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers { return View(); } + + /// + /// 明细统计主页面 + /// + /// + [HttpGet] + public ActionResult StatisticDetailIndex() + { + return View(); + } #endregion #region 获取数据 @@ -123,7 +133,6 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers [AjaxOnly] public ActionResult GetStatisticList(string pagination, string queryJson) { - Pagination paginationobj = pagination.ToObject(); var data = aDR_RecordIBLL.GetStatisticList(null, queryJson).GroupBy(x => new { x.UserNo, x.UserName }) .Select(x => new ADR_RecordEntity() { @@ -134,10 +143,30 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers ZaoTuiNum = x.Where(y => y.ClockStatus == "3").Count().ToString() }).OrderBy(x => x.UserNo); - return Success(data); } + /// + /// 考勤明细统计 + /// + /// 查询参数 + /// + [HttpGet] + [AjaxOnly] + public ActionResult GetStatisticDetailList(string pagination, string queryJson) + { + Pagination paginationobj = pagination.ToObject(); + var data = aDR_RecordIBLL.GetStatisticDetailList(paginationobj, queryJson); + var jsonData = new + { + rows = data, + total = paginationobj.total, + page = paginationobj.page, + records = paginationobj.records + }; + return Success(jsonData); + } + #endregion #region 提交数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/ADR_Record/StatisticDetailIndex.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/ADR_Record/StatisticDetailIndex.cshtml new file mode 100644 index 000000000..be307d061 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/ADR_Record/StatisticDetailIndex.cshtml @@ -0,0 +1,45 @@ +@{ + ViewBag.Title = "考勤记录统计"; + Layout = "~/Views/Shared/_Index.cshtml"; +} +
+
+
+
+
+ @*
+ +
+
+  查询 +
*@ +
+
+
+
+
考勤时间
+ +
+
+
职工编号
+ +
+
+
职工姓名
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+@Html.AppendJsFile("/Areas/LogisticsManagement/Views/ADR_Record/StatisticDetailIndex.js") diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/ADR_Record/StatisticDetailIndex.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/ADR_Record/StatisticDetailIndex.js new file mode 100644 index 000000000..38eb89978 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/ADR_Record/StatisticDetailIndex.js @@ -0,0 +1,126 @@ +/* * 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架(http://www.learun.cn) + * Copyright (c) 2013-2020 力软信息技术(苏州)有限公司 + * 创建人:超级管理员 + * 日 期:2020-08-28 18:09 + * 描 述:考勤记录统计 + */ +var refreshGirdData; +var bootstrap = function ($, learun) { + "use strict"; + //var date = ""; + var page = { + init: function () { + page.initGird(); + page.bind(); + }, + bind: function () { + $('#multiple_condition_query').lrMultipleQuery(function (queryJson) { + page.search(queryJson); + }, 220, 400); + //当前年 + var now = learun.formatDate(new Date(), 'yyyy-MM-dd'); + $('#Date').val(now); + // 刷新 + $('#lr_refresh').on('click', function () { + location.reload(); + }); + //查询 + //$('#btn_Search').on('click', function () { + // date = $('#date').val(); + // if (date == null || date == undefined || date == "") { + // learun.alert.warning("请选择查询时间!"); + // return; + // } + // page.search(); + //}); + }, + // 初始化列表 + initGird: function () { + $('#gridtable').lrAuthorizeJfGrid({ + url: top.$.rootUrl + '/LogisticsManagement/ADR_Record/GetStatisticDetailList', + headData: [ + { label: "姓名", name: "UserName", width: 100, align: "left" }, + { label: "职工编号", name: "UserNo", width: 100, align: "left" }, + { + label: "部门", name: "Department", width: 100, align: "left", + formatterAsync: function (callback, value, row, op, $cell) { + learun.clientdata.getAsync('custmerData', { + url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'classdata', + key: value, + keyId: 'id', + callback: function (_data) { + callback(_data['name']); + } + }); + } + }, + { label: "日期", name: "ClockDate", width: 100, align: "left" }, + { label: "班次", name: "BanCi", width: 60, align: "left" }, + { label: "时间段", name: "TimePeriod", width: 150, align: "left" }, + { + label: "上班状态", name: "ADStatusWork", width: 60, align: "left", formatterAsync: function (callback, value, row, op, $cell) { + learun.clientdata.getAsync('dataItem', { + key: value, + code: 'ADStatus', + callback: function (_data) { + //callback(_data.text); + if (_data.text) { + if (_data.text == "正常") { + callback('' + _data.text + ''); + } else if (_data.text == "缺勤") { + callback('' + _data.text + ''); + } else { + callback('' + _data.text + ''); + } + } + + } + }); + } + }, + { + label: "下班状态", name: "ADStatusClose", width: 60, align: "left", formatterAsync: function (callback, value, row, op, $cell) { + learun.clientdata.getAsync('dataItem', { + key: value, + code: 'ADStatus', + callback: function (_data) { + if (_data.text) { + if (_data.text == "正常") { + callback('' + _data.text + ''); + } else if (_data.text == "缺勤") { + callback('' + _data.text + ''); + } else { + callback('' + _data.text + ''); + } + } + + } + }); + } + }, + { label: "签到时间", name: "ClockTimeWork", width: 80, align: "left" }, + { label: "签退时间", name: "ClockTimeClose", width: 80, align: "left" }, + { label: "迟到(分钟)", name: "ChidaoMinutes", width: 80, align: "left" }, + { label: "早退(分钟)", name: "ZaoTuiMinutes", width: 80, align: "left" }, + { label: "出勤(分钟)", name: "ChuQinMinutes", width: 80, align: "left" }, + { label: "缺勤(分钟)", name: "QueQinMinutes", width: 80, align: "left" }, + { label: "工作(分钟)", name: "WorkMinutes", width: 80, align: "left" }, + { label: "休息(分钟)", name: "RestMinutes", width: 80, align: "left" }, + ], + mainId: '', + isPage: true, + sidx: 'UserNo,UserName,ClockTime' + }); + page.search(); + }, + search: function (param) { + param = param || {}; + //param.Date = date; + $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); + } + }; + refreshGirdData = function () { + $('#gridtable').jfGridSet('reload'); + }; + page.init(); +} diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/ADR_Record/StatisticIndex.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/ADR_Record/StatisticIndex.js index 3eb624dd4..3009e0c92 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/ADR_Record/StatisticIndex.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/ADR_Record/StatisticIndex.js @@ -64,7 +64,7 @@ var bootstrap = function ($, learun) { ], mainId: '', isPage: false, - sidx: "ClockDate desc,UserNo", + sidx: "UserNo" }); }, search: function (param) { diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj index ba1620df9..3af8213ac 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj @@ -1117,6 +1117,7 @@ + @@ -6792,6 +6793,7 @@ + diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordBLL.cs index d3c9c7c11..1adb9b0fa 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordBLL.cs @@ -133,6 +133,30 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement } } } + + /// + /// 考勤明细统计 + /// + /// 查询参数 + /// + public IEnumerable GetStatisticDetailList(Pagination pagination, string queryJson) + { + try + { + return aDR_RecordService.GetStatisticDetailList(pagination, queryJson); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } #endregion #region 提交数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordEntity.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordEntity.cs index 6bbbf4318..dc6529489 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordEntity.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordEntity.cs @@ -50,7 +50,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement [Column("CLOCKTIME")] public DateTime? ClockTime { get; set; } /// - /// 打卡结果 1正常,2迟到,3早退,4上班补签,5下班补签 + /// 打卡结果 1正常,2迟到,3早退,4上班补签,5下班补签,6缺勤 /// [Column("CLOCKSTATUS")] public string ClockStatus { get; set; } @@ -119,7 +119,71 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement /// [NotMapped] public string ZaoTuiNum { get; set; } - + /// + /// 班次 如:上下班 + /// + [NotMapped] + public string BanCi { get; set; } + /// + /// 时间段 如:上午上下班(08:05:00-11:24:00) + /// + [NotMapped] + public string TimePeriod { get; set; } + /// + /// 时间段标识 1上午,2下午 + /// + [NotMapped] + public int TimePeriodNo { get; set; } + /// + /// 上班状态 + /// + [NotMapped] + public string ADStatusWork { get; set; } + /// + /// 下班状态 + /// + [NotMapped] + public string ADStatusClose { get; set; } + /// + /// 签到时间 + /// + [NotMapped] + public string ClockTimeWork { get; set; } + /// + /// 签退时间 + /// + [NotMapped] + public string ClockTimeClose { get; set; } + /// + /// 迟到 + /// + [NotMapped] + public int ChidaoMinutes { get; set; } + /// + /// 早退 + /// + [NotMapped] + public int ZaoTuiMinutes { get; set; } + /// + /// 出勤 + /// + [NotMapped] + public int ChuQinMinutes { get; set; } + /// + /// 缺勤 + /// + [NotMapped] + public int QueQinMinutes { get; set; } + /// + /// 工作 + /// + [NotMapped] + public int WorkMinutes { get; set; } + /// + /// 休息 + /// + [NotMapped] + public int RestMinutes { get; set; } #endregion } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordIBLL.cs index b35775734..5de4924f4 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordIBLL.cs @@ -43,6 +43,13 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement /// 查询参数 /// IEnumerable GetStatisticList(Pagination pagination, string queryJson); + + /// + /// 考勤明细统计 + /// + /// 查询参数 + /// + IEnumerable GetStatisticDetailList(Pagination pagination, string queryJson); #endregion #region 提交数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordService.cs index 03e312998..8361bf0a6 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordService.cs @@ -1,9 +1,11 @@ using Dapper; +using Learun.Application.TwoDevelopment.PersonnelManagement; using Learun.DataBase.Repository; using Learun.Util; using System; using System.Collections.Generic; using System.Data; +using System.Linq; using System.Text; namespace Learun.Application.TwoDevelopment.LogisticsManagement @@ -192,9 +194,9 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement var basedbname = BaseRepository().getDbConnection().Database; var strSql = new StringBuilder(); - strSql.Append("select t.*,u.F_RealName as UserName "); + strSql.Append("select t.ID,t.UserNo,t.ClockStatus,u.F_RealName as UserName "); strSql.Append(" from ADR_Record t "); - strSql.Append(" left join " + basedbname + ".dbo.LR_Base_User u on u. F_EnCode=T.UserNo "); + strSql.Append(" left join " + basedbname + ".dbo.LR_Base_User u on u.F_EnCode=t.UserNo "); strSql.Append(" where 1=1 "); var queryParam = queryJson.ToJObject(); // 虚拟参数 @@ -231,6 +233,132 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement } } + /// + /// 考勤明细统计 + /// + /// 查询参数 + /// + public IEnumerable GetStatisticDetailList(Pagination pagination, string queryJson) + { + try + { + var basedbname = BaseRepository().getDbConnection().Database; + var queryParam = queryJson.ToJObject(); + var date = DateTime.Now.ToDateString(); + if (!queryParam["Date"].IsEmpty()) + { + date = queryParam["Date"].ToDate().ToDateString(); + } + + var strSql = new StringBuilder(); + strSql.Append("select u.F_Encode as UserNo,u.F_RealName as UserName,u.F_DepartmentId as Department,t.ID,t.ADType,t.ADTime,t.ClockTime,t.ClockStatus "); + strSql.Append(" from " + basedbname + ".dbo.LR_Base_User u "); + strSql.Append(" left join ADR_Record t on u.F_EnCode=t.UserNo and t.ADYear='" + date.Substring(0, 4) + "' and t.ADMonth='" + date.Substring(5, 2) + "' and t.ADDay='" + date.Substring(8, 2) + "' "); + strSql.Append(" where u.F_Description='教师' AND u.F_DeleteMark = 0 AND u.F_EnabledMark = 1 and u.F_Encode is not null "); + // 虚拟参数 + var dp = new DynamicParameters(new { }); + if (!queryParam["UserNo"].IsEmpty()) + { + dp.Add("UserNo", queryParam["UserNo"].ToString(), DbType.String); + strSql.Append(" AND u.F_EnCode = @UserNo "); + } + if (!queryParam["UserName"].IsEmpty()) + { + dp.Add("UserName", "%" + queryParam["UserName"].ToString() + "%", DbType.String); + strSql.Append(" AND u.F_RealName Like @UserName "); + } + //某天记录列表 + var data = this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp, pagination) + .GroupBy(x => new { x.UserNo, x.UserName, x.Department }).Select(x => new + { + UserNo = x.Key.UserNo, + UserName = x.Key.UserName, + Department = x.Key.Department, + Group = x.Select(y => new ADR_RecordEntity() + { + ADType = y.ADType, + ClockTime = y.ClockTime, + ClockStatus = y.ClockStatus + }) + }); + //启用的考勤规则 + var restrictionEntity = this.BaseRepository("CollegeMIS").FindEntity(m => m.REnable == true); + var WorkTimeTemp = string.Format("{0} {1}", date, restrictionEntity?.WorkTime).ToDate(); + var NoonCloseTimeTemp = string.Format("{0} {1}", date, restrictionEntity?.NoonCloseTime).ToDate(); + var NoonWorkTimeTemp = string.Format("{0} {1}", date, restrictionEntity?.NoonWorkTime).ToDate(); + var CloseTimeTemp = string.Format("{0} {1}", date, restrictionEntity?.CloseTime).ToDate(); + var MorningMinutes = (NoonCloseTimeTemp - WorkTimeTemp).TotalMinutes.ToInt();//上午应工作分钟数 + var AfternoonMinutes = (CloseTimeTemp - NoonWorkTimeTemp).TotalMinutes.ToInt();//下午应工作分钟数 + + //结果列表 + var result = new List(); + foreach (var item in data) + { + var adtype1 = item.Group.FirstOrDefault(x => x.ADType == "1"); + var adtype8 = item.Group.FirstOrDefault(x => x.ADType == "8"); + var adtype7 = item.Group.FirstOrDefault(x => x.ADType == "7"); + var adtype2 = item.Group.FirstOrDefault(x => x.ADType == "2"); + //上午 + var morning = new ADR_RecordEntity() + { + UserNo = item.UserNo, + UserName = item.UserName, + Department = item.Department, + ClockDate = date, + BanCi = "上下班", + TimePeriodNo = 1, + TimePeriod = string.Format("上午上下班({0}-{1})", restrictionEntity?.WorkTime, restrictionEntity?.NoonCloseTime), + ADStatusWork = adtype1 != null ? adtype1.ClockStatus : "6", + ADStatusClose = adtype8 != null ? adtype8.ClockStatus : "6", + ClockTimeWork = adtype1 != null ? adtype1.ClockTime.ToTimeString() : "-", + ClockTimeClose = adtype8 != null ? adtype8.ClockTime.ToTimeString() : "-", + ChidaoMinutes = adtype1 != null ? adtype1.ClockStatus == "2" ? (adtype1.ClockTime.Value - WorkTimeTemp).TotalMinutes.ToInt() : 0 : 0, + ZaoTuiMinutes = adtype8 != null ? adtype8.ClockStatus == "3" ? (NoonCloseTimeTemp - adtype8.ClockTime.Value).TotalMinutes.ToInt() : 0 : 0, + ChuQinMinutes = adtype1 != null && adtype8 != null ? (adtype8.ClockTime.Value - adtype1.ClockTime.Value).TotalMinutes.ToInt() : 0, + QueQinMinutes = adtype1 != null && adtype8 != null ? 0 : MorningMinutes, + RestMinutes = 0 + }; + morning.WorkMinutes = MorningMinutes == morning.QueQinMinutes ? 0 : MorningMinutes - morning.ChidaoMinutes - morning.ZaoTuiMinutes - morning.QueQinMinutes; + result.Add(morning); + //下午 + var afternoon = new ADR_RecordEntity() + { + UserNo = item.UserNo, + UserName = item.UserName, + Department = item.Department, + ClockDate = date, + BanCi = "上下班", + TimePeriodNo = 2, + TimePeriod = string.Format("下午上下班({0}-{1})", restrictionEntity?.NoonWorkTime, restrictionEntity?.CloseTime), + ADStatusWork = adtype7 != null ? adtype7.ClockStatus : "6", + ADStatusClose = adtype2 != null ? adtype2.ClockStatus : "6", + ClockTimeWork = adtype7 != null ? adtype7.ClockTime.ToTimeString() : "-", + ClockTimeClose = adtype2 != null ? adtype2.ClockTime.ToTimeString() : "-", + ChidaoMinutes = adtype7 != null ? adtype7.ClockStatus == "2" ? (adtype7.ClockTime.Value - NoonWorkTimeTemp).TotalMinutes.ToInt() : 0 : 0, + ZaoTuiMinutes = adtype2 != null ? adtype2.ClockStatus == "3" ? (CloseTimeTemp - adtype2.ClockTime.Value).TotalMinutes.ToInt() : 0 : 0, + ChuQinMinutes = adtype7 != null && adtype2 != null ? (adtype2.ClockTime.Value - adtype7.ClockTime.Value).TotalMinutes.ToInt() : 0, + QueQinMinutes = adtype7 != null && adtype2 != null ? 0 : AfternoonMinutes, + RestMinutes = 0 + }; + afternoon.WorkMinutes = AfternoonMinutes == afternoon.QueQinMinutes ? 0 : AfternoonMinutes - afternoon.ChidaoMinutes - afternoon.ZaoTuiMinutes - afternoon.QueQinMinutes; + result.Add(afternoon); + } + + return result.OrderBy(x => x.UserNo).ThenBy(x => x.UserName).ThenBy(x => x.TimePeriodNo); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } + #endregion #region 提交数据