username@email.com
2023-03-14 bf14008acffe7a9a7ac6e2eeb38ce3552b71b33a
zhengcaioa/zhengcaioa/Controllers/AdmManagement/SigninController.cs
@@ -25,10 +25,12 @@
        private readonly IWfRunProcessService _wfRunProcessService;
        private readonly IWfHistoryService _wfHistoryService;
        private readonly IWfNeeddeelService _wfNeeddeelService;
        private readonly IPltPageService _pltPageService;
        [CheckLogin]
        public SigninController(ILogger<SigninController> logger, IAdmSigninService signinService, ISysAttachmentService sysAttachmentService
            , IAdmAttendanceRuleService attendanceRuleService, ILiaotianService liaotianService, IWfRunProcessService wfRunProcessService
            , IWfHistoryService wfHistoryService, IWfNeeddeelService wfNeeddeelService)
            , IWfHistoryService wfHistoryService, IWfNeeddeelService wfNeeddeelService
             , IPltPageService pltPageService)
        {
            _logger = logger;
            _signinService = signinService;
@@ -38,6 +40,7 @@
            _wfRunProcessService = wfRunProcessService;
            _wfHistoryService = wfHistoryService;
            _wfNeeddeelService = wfNeeddeelService;
            _pltPageService = pltPageService;
        }
        #region 考勤签到打卡
@@ -201,9 +204,64 @@
            search.userId = curentuser.Id;
            return JsonConvert.SerializeObject(_signinService.SearchByPaging(search));
        }
        /// <summary>
        /// 我的考勤记录
        /// </summary>
        /// <returns></returns>
        [CheckLogin]
        public IActionResult SigninAll(string id)
        {
            JArray jar = new JArray();
            for (var i = 1; i <= 12; i++)
            {
                var jo = string.Format("\"code\":{0},  \"label\":\"{1}月\" ", i, i);
                jar.Add(JObject.Parse("{" + jo + "}"));
            }
            ViewBag.month = jar;
            JArray Year = new JArray();
            for (var i = -1; i < 2; i++)
            {
                var jo = string.Format("\"code\":{0},  \"label\":\"{0}年\" ", DateTime.Now.Year + i);
                Year.Add(JObject.Parse("{" + jo + "}"));
            }
            ViewBag.year = Year;
            ViewBag.userid = id;
            List<ActionEntity> actionlist = new List<ActionEntity>();
            ActionEntity actionEntity = new ActionEntity();
            actionEntity.OpenType = 0;
            actionEntity.ActionUrl = "";
            actionEntity.ActionFun = "Search";
            actionEntity.PageIco = "fa fa-search";
            actionEntity.ActionName = "查询";
            actionlist.Add(actionEntity);
            ViewData["ActionInfo"] = actionlist;
            return View();
        }
        /// <summary>
        /// 取得考勤记录
        /// </summary>
        /// <returns></returns>
        [CheckLogin]
        public string GetSigninListAll(AdmSignInDTOSearch search)
        {
            //var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            //search.userId = curentuser.Id;
            return JsonConvert.SerializeObject(_signinService.SearchByPaging(search));
        }
        #endregion
        #region 请假与销假
         public IActionResult AskLeave(string id="", string StratTimeName = "", string EndTimeName = "")
        public IActionResult AskLeave(string id="", string StratTimeName = "", string EndTimeName = "")
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
@@ -296,8 +354,8 @@
                else
                {
                    dangqianbuzhou = wfRunProcessDTO.Step;
                    //查询历史意见
                     lishiyijian = _wfHistoryService.GetListshenpi(wfRunProcessDTO.Id);
                    //查询审批进度
                    lishiyijian = _wfHistoryService.GetListshenpi(wfRunProcessDTO.Id);
                    if(wfRunProcessDTO.Step != "提交")
                    {
                        shifoubiaoji = "D";
@@ -338,8 +396,37 @@
            admAsk.RecStatus = "A";
            ResultEntity resultEntity = new ResultEntity();
            resultEntity.Result = false;
                if (String.IsNullOrEmpty(admAsk.Id))
            if(admAsk.Step == "提交")
            {
                //请假时间不能重叠
              //var qingjia  =   _signinService.GetAskLeaveChongdie(curentuser.Id, admAsk.StratTime.Value, admAsk.EndTime.Value);
              //  if (qingjia.Count > 0)
              //  {
              //      resultEntity.Result = false;
              //      resultEntity.Message = "该时间段已经有请假!";
              //      return JsonConvert.SerializeObject(resultEntity);
              //  }
            ////请假超过三天,必须提前三天以上请假!
            //    if (admAsk.LaveDay.Value >= 3 && admAsk.StratTime.Value.Date < DateTime.Now.Date.AddDays(3))
            //    {
            //        resultEntity.Result = false;
            //        resultEntity.Message = "请假超过三天,必须提前三天以上请假!";
            //        return JsonConvert.SerializeObject(resultEntity);
            //    }
                //请假超过七天,必须提前七天以上请假!
                if (admAsk.LaveDay.Value >= 7 && admAsk.StratTime.Value.Date < DateTime.Now.Date.AddDays(7))
                {
                    resultEntity.Result = false;
                    resultEntity.Message = "请假超过七天,必须提前七天以上请假!";
                    return JsonConvert.SerializeObject(resultEntity);
                }
            }
            if (String.IsNullOrEmpty(admAsk.Id))
                {
                    admAsk.Creater = curentuser.Id;
                    admAsk.Createtime = DateTime.Now;
@@ -872,7 +959,7 @@
                else
                {
                    dangqianbuzhou = wfRunProcessDTO.Step;
                    //查询历史意见
                    //查询审批进度
                    lishiyijian = _wfHistoryService.GetListshenpi(wfRunProcessDTO.Id);
                    if (wfRunProcessDTO.Step != "提交")
                    {
@@ -910,8 +997,8 @@
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            leaveOff.RecStatus = "A";
            //未挂审批流,提交直接通过
            leaveOff.ShenpiStatus = "A";
            ////未挂审批流,提交直接通过
            //leaveOff.ShenpiStatus = "A";
            if (String.IsNullOrEmpty(leaveOff.Id))
            {
                leaveOff.Creater = curentuser.Id;
@@ -921,6 +1008,27 @@
            leaveOff.Modifytime = DateTime.Now;
            ResultEntity resultEntity = new ResultEntity();
            resultEntity.Result = false;
            if (leaveOff.Step == "提交")
            {
                //请假时间不能重叠
                var qingjia = _signinService.GetAskLeaveOffChongdie(curentuser.Id, leaveOff.StratTime.Value, leaveOff.EndTime.Value);
                if (qingjia.Count > 0)
                {
                    resultEntity.Result = false;
                    resultEntity.Message = "该时间段已经有销假!";
                    return JsonConvert.SerializeObject(resultEntity);
                }
                //销假必须三天以内
                if (leaveOff.StratTime.Value.Date < DateTime.Now.Date.AddDays(-4))
                {
                    resultEntity.Result = false;
                    resultEntity.Message = "请在72小时内进行销假处理,超过72小时无法提交";
                    return JsonConvert.SerializeObject(resultEntity);
                }
            }
            using (TransactionScope scope = new TransactionScope())
            {
                if (leaveOff.Step == "提交")
@@ -980,6 +1088,12 @@
        #region 考勤规则
        public IActionResult AttendanceRule()
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            var pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/Signin/AttendanceRule/");
            var pageEntities2 = pageEntities.Where(x => x.PageMethod == "02").ToList();
            ViewData["ActionInfo2"] = pageEntities2;
            AdmAttendanceRuleDTO admAttendanceRuleDTO =  _attendanceRuleService.Get("");
            admAttendanceRuleDTO.admAttendanceRulesDtlDTOs = _attendanceRuleService.GetDtlList("");