WorkAttendanceController.cs
2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using Hh.Mes.Common.Request;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.Response;
using Hh.Mes.Service;
using Hh.Mes.Service.SystemAuth;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
namespace WebMvc.Controllers
{
public class WorkAttendanceController : BaseController
{
private readonly AttendanceService service;
private IHttpContextAccessor _accessor;
public WorkAttendanceController(IAuth authUtil, AttendanceService attendanceService, IHttpContextAccessor accessort) : base(authUtil)
{
service = attendanceService;
service.sysWebUser = authUtil.GetCurrentUser().User;
this._accessor = accessort;
service.ObjValue = _accessor.HttpContext.Connection.RemoteIpAddress.ToString();
}
public ActionResult Index()
{
return View();
}
#region 获取数据
/// <summary>
/// 加载及分页查询
/// </summary>
/// <param name="pageRequest">表单请求信息</param>
/// <param name="entity">请求条件实例</param>
/// <returns></returns>
[HttpPost]
public async Task<string> Load(PageReq pageRequest, sys_punch_clock entity)
{
var dataResult = await service.Load(pageRequest, entity);
var dataTable = dataResult.Tables[0];
var retrunResult = new Response
{
Result = dataTable,
Count = entity.Exel ? dataTable.Rows.Count : (int)dataResult.Tables[1].Rows[0]["rowTotal"]
};
return Serialize(retrunResult);
}
#endregion
[HttpPost]
public string Clock(string webcam, string idcard)
{
var resp = new Response();
//工卡登录
if (!string.IsNullOrEmpty(idcard))
{
resp = service.IdCardClockService(idcard);
}
else if (!string.IsNullOrEmpty(webcam))
{
resp = service.FaceClockService(webcam);
}
else
{
resp.Code = 500;
resp.Message = "请选择考勤方式";
}
return Serialize(resp);
}
}
}