public async Task <Result> Clock([FromBody] ClockDto address) { var context = HttpContext; string account = await _jwtUtil.GetMessageByToken(context); int companyId = _commonAppService.GetUserCompId(account); return(_attendanceAppService.Clock(address, account, companyId)); }
private bool CheckLocation(Company company, ClockDto clockDto) { double lng = Math.Abs(company.Lng - clockDto.Lng); double lat = Math.Abs(company.Lat - clockDto.Lat); if (lng <= 1 && lat <= 1) { return(true); } else { return(false); } }
//根据当前登录用户的地理位置打卡 public Result Clock(ClockDto address, string account, int compId) { //找到公司员工 //根据地址判断员工是否在公司 //获取签到的日期 //获取签到的时间 // Worker worker = _ctx.Worker.SingleOrDefault(w => w.Account.Equals(account)); Company company = _ctx.Company.SingleOrDefault(c => c.Id == compId); Result result = new Result(); if (CheckLocation(company, address)) { DateTime dt = DateTime.Now; string clockDay = dt.ToString("yyyy-MM-dd"); result = ClockIn(worker.Id, dt, clockDay); } else { result.IsSuccess = false; result.Message = "您当前定位不在公司附近!"; } return(result); }
public Result Clock(ClockDto address, string account, int compId) { return(_attendanceManager.Clock(address, account, compId)); }