Ver código fonte

考勤明细统计导出

黑艺新账号
dao 7 meses atrás
pai
commit
b37d559465
7 arquivos alterados com 526 adições e 41 exclusões
  1. +71
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/ADR_RecordController.cs
  2. +2
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/ADR_Record/StatisticDetailIndex.cshtml
  3. +16
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/ADR_Record/StatisticDetailIndex.js
  4. +19
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordBLL.cs
  5. +67
    -2
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordEntity.cs
  6. +2
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordIBLL.cs
  7. +349
    -38
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordService.cs

+ 71
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/ADR_RecordController.cs Ver arquivo

@@ -7,6 +7,8 @@ using Learun.Application.Base.SystemModule;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Newtonsoft.Json;

namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers
{
@@ -154,6 +156,75 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers
return Success(data);
}

[HttpPost, ValidateInput(false)]
public ActionResult ExportStatisticList(string queryJson)
{
var queryParam = queryJson.ToJObject();
var data = aDR_RecordIBLL.GetStatisticDetailList(queryJson).ToList();
var result = new List<Dictionary<string, string>>();
if(data.Any())
{
foreach (var item in data)
{
var aaa = new Dictionary<string, string>();
aaa.Add("UserName", item.UserName);
aaa.Add("UserNo", item.UserNo);
aaa.Add("DepartmentName", item.DepartmentName);
aaa.Add("CompilationCategoryName", item.CompilationCategoryName);
aaa.Add("ClockDate", item.ClockDate);
aaa.Add("BanCi", item.BanCi);
aaa.Add("TimePeriod", item.TimePeriod);
aaa.Add("ADStatusWorkName", item.ADStatusWorkName);
aaa.Add("ADStatusCloseName", item.ADStatusCloseName);
aaa.Add("ClockTimeWork", item.ClockTimeWork);
aaa.Add("ClockTimeClose", item.ClockTimeClose);
aaa.Add("IsFitName", item.IsFitName);
aaa.Add("ChidaoMinutes", item.ChidaoMinutes.ToString());
aaa.Add("ZaoTuiMinutes", item.ZaoTuiMinutes.ToString());
aaa.Add("ChuQinMinutes", item.ChuQinMinutes.ToString());
aaa.Add("WorkMinutes", item.WorkMinutes.ToString());
aaa.Add("RestMinutes", item.RestMinutes.ToString());

result.Add(aaa);
}
}
var resultStr = JsonConvert.SerializeObject(result);

//数据源
var exportTable = resultStr.ToTable();
//设置导出格式
ExcelConfig excelconfig = new ExcelConfig();
excelconfig.Title = "考勤明细统计";
excelconfig.TitleFont = "微软雅黑";
excelconfig.TitlePoint = 20;
excelconfig.FileName = "考勤明细统计.xls";
excelconfig.IsAllSizeColumn = true;
//每一列的设置,没有设置的列信息,系统将按datatable中的列名导出
excelconfig.ColumnEntity = new List<ColumnModel>();
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "UserName", ExcelColumn = "姓名" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "UserNo", ExcelColumn = "职工编号" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "DepartmentName", ExcelColumn = "部门" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "CompilationCategoryName", ExcelColumn = "坐班授课" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "ClockDate", ExcelColumn = "日期" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "BanCi", ExcelColumn = "班次" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "TimePeriod", ExcelColumn = "时间段" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "ADStatusWorkName", ExcelColumn = "上班状态" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "ADStatusCloseName", ExcelColumn = "下班状态" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "ClockTimeWork", ExcelColumn = "签到时间" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "ClockTimeClose", ExcelColumn = "签退时间" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "IsFitName", ExcelColumn = "人脸检测" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "ChidaoMinutes", ExcelColumn = "迟到(分钟)" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "ZaoTuiMinutes", ExcelColumn = "早退(分钟)" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "ChuQinMinutes", ExcelColumn = "出勤(分钟)" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "WorkMinutes", ExcelColumn = "工作(分钟)" });
excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "RestMinutes", ExcelColumn = "休息(分钟)" });

//调用导出方法
ExcelHelper.ExcelDownload(exportTable, excelconfig);

return Success("导出成功!");
}

/// <summary>
/// 考勤明细统计
/// <summary>


+ 2
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/ADR_Record/StatisticDetailIndex.cshtml Ver arquivo

@@ -44,7 +44,8 @@
<div class="lr-layout-tool-right">
<div class=" btn-group btn-group-sm">
<a id="lr_refresh" class="btn btn-default"><i class="fa fa-refresh"></i></a>
</div>
<a id="lr_export" class="btn btn-default"><i class="fa fa-sign-out"></i>导出</a>
</div>
</div>
</div>
<div class="lr-layout-body" id="gridtable"></div>


+ 16
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/ADR_Record/StatisticDetailIndex.js Ver arquivo

@@ -63,6 +63,22 @@ var bootstrap = function ($, learun) {
});
//考勤状态
$('#ClockStatus').lrDataItemSelect({ code: 'ADStatus' });
$('#lr_export').on('click', function () {
var p = {};
p.startTime = startTime;
p.endTime = endTime;
p.UserNo = $('#UserNo').val();
p.UserName = $('#UserName').val();
p.F_DepartmentId = $('#F_DepartmentId').lrselectGet();
p.ClockStatus = $('#ClockStatus').lrselectGet();
learun.download({
method: "POST",
url: top.$.rootUrl + '/LogisticsManagement/ADR_Record/ExportStatisticList',
param: {
queryJson: JSON.stringify(p)
}
});
});
},
// 初始化列表
initGird: function () {


+ 19
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordBLL.cs Ver arquivo

@@ -213,6 +213,25 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
}
}

public IEnumerable<ADR_RecordEntity> GetStatisticDetailList(string queryJson)
{
try
{
return aDR_RecordService.GetStatisticDetailList(queryJson);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}

#endregion

}


+ 67
- 2
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordEntity.cs Ver arquivo

@@ -11,7 +11,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
/// 日 期:2020-08-28 18:09
/// 描 述:考勤记录
/// </summary>
public class ADR_RecordEntity
public class ADR_RecordEntity
{
#region 实体成员
/// <summary>
@@ -122,7 +122,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
/// 新增调用
/// </summary>
public void Create()
{
{
this.ID = Guid.NewGuid().ToString();
}
/// <summary>
@@ -181,11 +181,63 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
[NotMapped]
public string ADStatusWork { get; set; }
/// <summary>
/// 上班状态 1正常,2迟到,3早退,4上班补签,5下班补签,6缺勤
/// </summary>
[NotMapped]
public string ADStatusWorkName
{
get
{
switch (ADStatusWork)
{
case "1":
return "正常";
case "2":
return "迟到";
case "3":
return "早退";
case "4":
case "5":
return "补签";
case "6":
return "缺勤";
default:
return "";
}
}
}
/// <summary>
/// 下班状态
/// </summary>
[NotMapped]
public string ADStatusClose { get; set; }
/// <summary>
/// 下班状态
/// </summary>
[NotMapped]
public string ADStatusCloseName
{
get
{
switch (ADStatusWork)
{
case "1":
return "正常";
case "2":
return "迟到";
case "3":
return "早退";
case "4":
case "5":
return "补签";
case "6":
return "缺勤";
default:
return "";
}
}
}
/// <summary>
/// 签到时间
/// </summary>
[NotMapped]
@@ -230,11 +282,24 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
/// </summary>
[NotMapped]
public string IsFitstr { get; set; }

/// <summary>
/// 人脸识别
/// </summary>
[NotMapped]
public string IsFitName { get { return (IsFitstr == "True,True") ? "通过" : "异常"; } }
/// <summary>
/// 坐班授课
/// </summary>
[NotMapped]
public string CompilationCategory { get; set; }
/// <summary>
/// 坐班授课
/// </summary>
[NotMapped]
public string CompilationCategoryName { get { return CompilationCategory == "1" ? "坐班" : CompilationCategory == "2" ? "授课" : ""; } }
[NotMapped]
public string DepartmentName { get; set; }
#endregion
}
}


+ 2
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordIBLL.cs Ver arquivo

@@ -50,6 +50,8 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
/// <param name="queryJson">查询参数</param>
/// <returns></returns>
IEnumerable<ADR_RecordEntity> GetStatisticDetailList(Pagination pagination, string queryJson);

IEnumerable<ADR_RecordEntity> GetStatisticDetailList(string queryJson);
/// <summary>
/// 获取考勤人脸通过图片
/// <summary>


+ 349
- 38
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordService.cs Ver arquivo

@@ -1,4 +1,6 @@
using Dapper;
using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Learun.Application.TwoDevelopment.PersonnelManagement;
using Learun.DataBase.Repository;
using Learun.Util;
@@ -250,6 +252,8 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
var queryParam = queryJson.ToJObject();
var datest = DateTime.Now.ToDateString();
var dateet = datest;

if (!queryParam["startTime"].IsEmpty())
{
datest = queryParam["startTime"].ToDate().ToDateString();
@@ -266,6 +270,32 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
{
return totalResult;
}

#region 查询参数
var userNo = string.Empty;
if (!queryParam["UserNo"].IsEmpty())
{
userNo = queryParam["UserNo"].ToString();
}
var userName = string.Empty;
if (!queryParam["UserName"].IsEmpty())
{
userName = queryParam["UserName"].ToString();
}
var deptId = string.Empty;
if (!queryParam["F_DepartmentId"].IsEmpty())
{
deptId = queryParam["F_DepartmentId"].ToString();
}
var clockStatus = string.Empty;
if (!queryParam["ClockStatus"].IsEmpty())
{
clockStatus = queryParam["ClockStatus"].ToString();
}
#endregion


//考勤时间段查询语句
var totalSql = new StringBuilder();
totalSql.Append("select top 100 percent * from ( ");
@@ -276,44 +306,45 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
var date = datest.ToDate().AddDays(i).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.ADphoto,t.ADType,emp.Photo,emp.CompilationCategory,t.img,t.IsFit,t.ADTime,t.ClockTime,t.ClockStatus,'{date}' as ClockDate ");
strSql.Append(" from " + basedbname + ".dbo.LR_Base_User u ");
strSql.Append(" inner join EmpInfo emp on u.F_EnCode=emp.EmpNo ");
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 UserNoPrev = Config.GetValue("ADR_RecordUserNoPrev");
if (!string.IsNullOrEmpty(UserNoPrev))
{
strSql.Append(" and u.F_encode like '" + UserNoPrev + "%' ");
}
strSql.Append($"select u.EmpNo as UserNo,u.EmpName as UserName,u.F_DepartmentId as Department,t.ID,t.ADphoto,t.ADType,u.Photo,u.CompilationCategory,t.img,t.IsFit,t.ADTime,t.ClockTime,t.ClockStatus,'{date}' as ClockDate ");
//strSql.Append(" from " + basedbname + ".dbo.LR_Base_User u ");
strSql.Append(" from EmpInfo u ");
//strSql.Append(" inner join EmpInfo emp on u.F_EnCode=emp.EmpNo ");
strSql.Append(" left join ADR_Record t on u.EmpNo=t.UserNo and t.ADYear='" + date.Substring(0, 4) + "' and t.ADMonth='" + date.Substring(5, 2) + "' and t.ADDay='" + date.Substring(8, 2) + "' where 1=1 ");
//strSql.Append(" where u.F_Description='教师' AND u.F_DeleteMark = 0 AND u.F_EnabledMark = 1 and u.F_Encode is not null ");

//var UserNoPrev = Config.GetValue("ADR_RecordUserNoPrev");
//if (!string.IsNullOrEmpty(UserNoPrev))
//{
// strSql.Append(" and u.F_encode like '" + UserNoPrev + "%' ");
//}
// 虚拟参数
if (!queryParam["UserNo"].IsEmpty())
if (!userNo.IsEmpty())
{
strSql.Append($" AND u.F_EnCode = '{queryParam["UserNo"].ToString()}' ");
strSql.Append($" AND u.EmpNo = '{userNo}' ");
}
if (!queryParam["UserName"].IsEmpty())
if (!userName.IsEmpty())
{
strSql.Append($" AND u.F_RealName Like '%{queryParam["UserName"].ToString()}%' ");
strSql.Append($" AND u.EmpName Like '%{userName}%' ");
}
if (!queryParam["F_DepartmentId"].IsEmpty())
if (!deptId.IsEmpty())
{
strSql.Append($" AND emp.F_DepartmentId = '{queryParam["F_DepartmentId"].ToString()}' ");
strSql.Append($" AND u.F_DepartmentId = '{deptId}' ");
}
if (!queryParam["ClockStatus"].IsEmpty())
if (!clockStatus.IsEmpty())
{
//if (queryParam["ClockStatus"].ToString() == "6" || queryParam["ClockStatus"].ToString() == "0")//缺勤、旷工
if (queryParam["ClockStatus"].ToString() == "0")
if (clockStatus == "0")
{
strSql.Append(" AND t.ClockStatus is null ");
}
else if(queryParam["ClockStatus"].ToString() == "6")
else if (clockStatus == "6")
{

}
else
{
strSql.Append($" AND t.ClockStatus = '{queryParam["ClockStatus"].ToString()}' ");
strSql.Append($" AND t.ClockStatus = '{clockStatus}' ");
}
}
totalSql.Append(strSql);
@@ -325,13 +356,13 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
totalSql.Append(" ) as bb where 1=1 order by bb.ClockDate");
//当天记录列表
var data = this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>(totalSql.ToString())
.GroupBy(x => new { x.UserNo, x.UserName, x.Department, x.ClockDate,x.CompilationCategory }).Select(x => new
.GroupBy(x => new { x.UserNo, x.UserName, x.Department, x.ClockDate, x.CompilationCategory }).Select(x => new
{
UserNo = x.Key.UserNo,
UserName = x.Key.UserName,
Department = x.Key.Department,
ClockDate = x.Key.ClockDate,
CompilationCategory=x.Key.CompilationCategory,
CompilationCategory = x.Key.CompilationCategory,
Group = x.Select(y => new ADR_RecordEntity()
{
ADType = y.ADType,
@@ -340,7 +371,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
ClockStatus = y.ClockStatus,
Photo = y.Photo,
IsFit = y.IsFit,
Img=y.Img
Img = y.Img
})
}).ToList();

@@ -364,7 +395,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
UserNo = item.UserNo,
UserName = item.UserName,
Department = item.Department,
CompilationCategory=item.CompilationCategory,
CompilationCategory = item.CompilationCategory,
ClockDate = item.ClockDate,
BanCi = "上下班",
TimePeriodNo = 0,
@@ -419,7 +450,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
ClockDate = item.ClockDate,
BanCi = "上下班",
TimePeriodNo = 1,
ADPhoto = adtype2 != null ? adtype2.ADPhoto:"",
ADPhoto = adtype2 != null ? adtype2.ADPhoto : "",
TimePeriod = string.Format("上午上下班({0}-{1})", restrictionEntity.WorkTime, restrictionEntity.NoonCloseTime),
ADStatusWork = adtype1 != null ? adtype1.ClockStatus : "6",
ADStatusClose = adtype8 != null ? adtype8.ClockStatus : "6",
@@ -460,23 +491,23 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
#endregion
}

if (!queryParam["ClockStatus"].IsEmpty())
if (!clockStatus.IsEmpty())
{
var ClockStatus = queryParam["ClockStatus"].ToString();
if(ClockStatus=="6")
//var ClockStatus = queryParam["ClockStatus"].ToString();
if (clockStatus == "6")
{
totalResult = totalResult.Where(x => x.ADStatusWork == ClockStatus || x.ADStatusClose == ClockStatus).ToList();
totalResult = totalResult.Where(x => x.ADStatusWork == clockStatus || x.ADStatusClose == clockStatus).ToList();
}
if(ClockStatus=="1")
if (clockStatus == "1")
{
totalResult = totalResult.Where(x => x.ADStatusWork == ClockStatus && x.ADStatusClose == ClockStatus).ToList();
totalResult = totalResult.Where(x => x.ADStatusWork == clockStatus && x.ADStatusClose == clockStatus).ToList();
}
//totalResult.Where(x => x.ClockStatus == ClockStatus);
}
var result= totalResult;
if (pagination.sidx== "UserName")
var result = totalResult;
if (pagination.sidx == "UserName")
{
if (pagination.sord=="ASC")
if (pagination.sord == "ASC")
{
result = totalResult.OrderBy(x => x.UserName).ToList();
}
@@ -522,12 +553,292 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
}
}

public IEnumerable<ADR_RecordEntity> GetStatisticDetailList(string queryJson)
{
try
{
var basedbname = BaseRepository().getDbConnection().Database;
var queryParam = queryJson.ToJObject();
var datest = DateTime.Now.ToDateString();
var dateet = datest;


if (!queryParam["startTime"].IsEmpty())
{
datest = queryParam["startTime"].ToDate().ToDateString();
}
if (!queryParam["endTime"].IsEmpty())
{
dateet = queryParam["endTime"].ToDate().ToDateString();
}
//考勤时间段查询结果
var totalResult = new List<ADR_RecordEntity>();
//启用的考勤规则
var restrictionEntity = this.BaseRepository("CollegeMIS").FindEntity<ADR_RestrictionEntity>(m => m.REnable == true);
if (restrictionEntity == null)
{
return totalResult;
}

#region 查询参数
var userNo = string.Empty;
if (!queryParam["UserNo"].IsEmpty())
{
userNo = queryParam["UserNo"].ToString();
}
var userName = string.Empty;
if (!queryParam["UserName"].IsEmpty())
{
userName = queryParam["UserName"].ToString();
}
var deptId = string.Empty;
if (!queryParam["F_DepartmentId"].IsEmpty())
{
deptId = queryParam["F_DepartmentId"].ToString();
}
var clockStatus = string.Empty;
if (!queryParam["ClockStatus"].IsEmpty())
{
clockStatus = queryParam["ClockStatus"].ToString();
}
#endregion



//考勤时间段查询语句
var totalSql = new StringBuilder();
totalSql.Append("select top 100 percent * from ( ");
//考勤时间段查询
for (int i = 0; i < (dateet.ToDate() - datest.ToDate()).Days + 1; i++)
{
//当天日期
var date = datest.ToDate().AddDays(i).ToDateString();
//当天查询语句
var strSql = new StringBuilder();
strSql.Append($"select u.EmpNo as UserNo,u.EmpName as UserName,u.F_DepartmentId as Department,d.F_FullName as DepartmentName,t.ID,t.ADphoto,t.ADType,u.Photo,u.CompilationCategory,t.img,t.IsFit,t.ADTime,t.ClockTime,t.ClockStatus,'{date}' as ClockDate ");
//strSql.Append(" from " + basedbname + ".dbo.LR_Base_User u ");
strSql.Append(" from EmpInfo u ");
strSql.Append(" left join " + basedbname + ".dbo.LR_Base_Department d on u.F_DepartmentId=d.F_DepartmentId ");
//strSql.Append(" inner join EmpInfo emp on u.F_EnCode=emp.EmpNo ");
strSql.Append(" left join ADR_Record t on u.EmpNo=t.UserNo and t.ADYear='" + date.Substring(0, 4) + "' and t.ADMonth='" + date.Substring(5, 2) + "' and t.ADDay='" + date.Substring(8, 2) + "' where 1=1 ");
//strSql.Append(" where u.F_Description='教师' AND u.F_DeleteMark = 0 AND u.F_EnabledMark = 1 and u.F_Encode is not null ");

//var UserNoPrev = Config.GetValue("ADR_RecordUserNoPrev");
//if (!string.IsNullOrEmpty(UserNoPrev))
//{
// strSql.Append(" and u.F_encode like '" + UserNoPrev + "%' ");
//}
// 虚拟参数
if (!userNo.IsEmpty())
{
strSql.Append($" AND u.EmpNo = '{userNo}' ");
}
if (!userName.IsEmpty())
{
strSql.Append($" AND u.EmpName Like '%{userName}%' ");
}
if (!deptId.IsEmpty())
{
strSql.Append($" AND u.F_DepartmentId = '{deptId}' ");
}
if (!clockStatus.IsEmpty())
{
//if (queryParam["ClockStatus"].ToString() == "6" || queryParam["ClockStatus"].ToString() == "0")//缺勤、旷工
if (clockStatus == "0")
{
strSql.Append(" AND t.ClockStatus is null ");
}
else if (clockStatus == "6")
{

}
else
{
strSql.Append($" AND t.ClockStatus = '{clockStatus}' ");
}
}
totalSql.Append(strSql);
if (i < (dateet.ToDate() - datest.ToDate()).Days)
{
totalSql.Append(" union ");
}
}
totalSql.Append(" ) as bb where 1=1 order by bb.ClockDate");
//当天记录列表
var data = this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>(totalSql.ToString())
.GroupBy(x => new { x.UserNo, x.UserName, x.Department, x.DepartmentName, x.ClockDate, x.CompilationCategory }).Select(x => new
{
UserNo = x.Key.UserNo,
UserName = x.Key.UserName,
Department = x.Key.Department,
x.Key.DepartmentName,
ClockDate = x.Key.ClockDate,
CompilationCategory = x.Key.CompilationCategory,
Group = x.Select(y => new ADR_RecordEntity()
{
ADType = y.ADType,
ADPhoto = y.ADPhoto,
ClockTime = y.ClockTime,
ClockStatus = y.ClockStatus,
Photo = y.Photo,
IsFit = y.IsFit,
Img = y.Img
})
}).ToList();

if (restrictionEntity.ClockTime == "二次打卡")
{
#region 二次打卡

foreach (var item in data)
{
//上班时间
var WorkTimeTemp = string.Format("{0} {1}", item.ClockDate, restrictionEntity.WorkTime).ToDate();
//下班时间
var CloseTimeTemp = string.Format("{0} {1}", item.ClockDate, restrictionEntity.CloseTime).ToDate();
var WholeMinutes = (CloseTimeTemp - WorkTimeTemp).TotalMinutes.ToInt();//全天应工作分钟数
string photo = item.Group.FirstOrDefault().Photo;
var adtype1 = item.Group.FirstOrDefault(x => x.ADType == "1");//上班
var adtype2 = item.Group.FirstOrDefault(x => x.ADType == "2");//下班
//全天
var whole = new ADR_RecordEntity()
{
UserNo = item.UserNo,
UserName = item.UserName,
Department = item.Department,
DepartmentName = item.DepartmentName,
CompilationCategory = item.CompilationCategory,
ClockDate = item.ClockDate,
BanCi = "上下班",
TimePeriodNo = 0,
ADPhoto = adtype2 != null ? adtype2.ADPhoto : "",
TimePeriod = string.Format("上下班({0}-{1})", restrictionEntity.WorkTime, restrictionEntity.CloseTime),
ADStatusWork = adtype1 != null ? adtype1.ClockStatus : "6",
ADStatusClose = adtype2 != null ? adtype2.ClockStatus : "6",
ClockTimeWork = adtype1 != null ? adtype1.ClockTime.ToTimeString() : "-",
ClockTimeClose = adtype2 != null ? adtype2.ClockTime.ToTimeString() : "-",
ChidaoMinutes = adtype1 != null ? adtype1.ClockStatus == "2" ? (adtype1.ClockTime.Value - WorkTimeTemp).TotalMinutes.ToInt() : 0 : 0,
ZaoTuiMinutes = adtype2 != null ? adtype2.ClockStatus == "3" ? (CloseTimeTemp - adtype2.ClockTime.Value).TotalMinutes.ToInt() : 0 : 0,
ChuQinMinutes = adtype1 != null && adtype2 != null ? (adtype2.ClockTime.Value - adtype1.ClockTime.Value).TotalMinutes.ToInt() : 0,
QueQinMinutes = adtype1 != null && adtype2 != null ? 0 : WholeMinutes,
RestMinutes = 0,
Photo = photo,// adtype1 != null && adtype2 != null ? adtype1.Photo: "",
IsFitstr = (adtype1 != null ? adtype1.IsFit.ToString() : "") + "," + (adtype2 != null ? adtype2.IsFit.ToString() : ""),
Img = (adtype1 != null ? adtype1.Img : "") + "," + (adtype2 != null ? adtype2.Img : ""),
};
whole.WorkMinutes = WholeMinutes == whole.QueQinMinutes ? 0 : WholeMinutes - whole.ChidaoMinutes - whole.ZaoTuiMinutes - whole.QueQinMinutes;
totalResult.Add(whole);
}
#endregion
}
else
{
#region 四次打卡

foreach (var item in data)
{
//上班时间
var WorkTimeTemp = string.Format("{0} {1}", item.ClockDate, restrictionEntity.WorkTime).ToDate();
//下班时间
var CloseTimeTemp = string.Format("{0} {1}", item.ClockDate, restrictionEntity.CloseTime).ToDate();
//中午下班时间
var NoonCloseTimeTemp = string.Format("{0} {1}", item.ClockDate, restrictionEntity?.NoonCloseTime).ToDate();
//中午上班时间
var NoonWorkTimeTemp = string.Format("{0} {1}", item.ClockDate, restrictionEntity?.NoonWorkTime).ToDate();
var MorningMinutes = (NoonCloseTimeTemp - WorkTimeTemp).TotalMinutes.ToInt();//上午应工作分钟数
var AfternoonMinutes = (CloseTimeTemp - NoonWorkTimeTemp).TotalMinutes.ToInt();//下午应工作分钟数

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,
CompilationCategory = item.CompilationCategory,
ClockDate = item.ClockDate,
BanCi = "上下班",
TimePeriodNo = 1,
ADPhoto = adtype2 != null ? adtype2.ADPhoto : "",
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;
totalResult.Add(morning);
//下午
var afternoon = new ADR_RecordEntity()
{
UserNo = item.UserNo,
UserName = item.UserName,
Department = item.Department,
CompilationCategory = item.CompilationCategory,
ClockDate = item.ClockDate,
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;
totalResult.Add(afternoon);
}
#endregion
}

if (!clockStatus.IsEmpty())
{
//var ClockStatus = queryParam["ClockStatus"].ToString();
if (clockStatus == "6")
{
totalResult = totalResult.Where(x => x.ADStatusWork == clockStatus || x.ADStatusClose == clockStatus).ToList();
}
if (clockStatus == "1")
{
totalResult = totalResult.Where(x => x.ADStatusWork == clockStatus && x.ADStatusClose == clockStatus).ToList();
}
//totalResult.Where(x => x.ClockStatus == ClockStatus);
}
var result = totalResult;
return result;// totalResult.OrderBy(x => x.ClockDate).ThenBy(x => x.UserNo).ThenBy(x => x.TimePeriodNo);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}

public string GetStatisticDetailimg(string teachno)
{
var strSql = new StringBuilder();
strSql.Append("SELECT t.img ");
strSql.Append(" FROM ADR_Record t ");
strSql.Append(" WHERE 1=1 and userno='"+ teachno + "' and isfit=1 and img is not null");
strSql.Append(" WHERE 1=1 and userno='" + teachno + "' and isfit=1 and img is not null");

return this.BaseRepository("CollegeMIS").FindObject(strSql.ToString())?.ToString();
}
@@ -575,7 +886,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
}
if (string.IsNullOrWhiteSpace(entity.ADYear)) entity.ADYear = entity.ADTime.Value.Year.ToString();
if (string.IsNullOrWhiteSpace(entity.ADMonth)) entity.ADMonth = entity.ADTime.Value.Month.ToString().PadLeft(2, '0');
if (string.IsNullOrWhiteSpace(entity.ADDay)) entity.ADDay = entity.ADTime.Value.Day.ToString().PadLeft(2,'0');
if (string.IsNullOrWhiteSpace(entity.ADDay)) entity.ADDay = entity.ADTime.Value.Day.ToString().PadLeft(2, '0');
if (!string.IsNullOrEmpty(keyValue))
{
entity.Modify(keyValue);
@@ -590,7 +901,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
entity.Create();
this.BaseRepository("CollegeMIS").Insert(entity);
}
//同步修改授课考勤打卡
aDR_RestrictionService.ClockInModifyTeachAttendance(entity);
}


Carregando…
Cancelar
Salvar