Esempio n. 1
0
        /// <summary>
        /// 取消提交工时表
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="resourceId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool CancleSubmitWorkEntry(DateTime startDate, long resourceId, long userId)
        {
            var weList = GetWorkEntryListByStartDate(startDate, resourceId);

            if (weList.Count == 0)
            {
                return(false);
            }

            sdk_work_entry_report_dal rptDal = new sdk_work_entry_report_dal();

            var find = rptDal.FindSignleBySql <sdk_work_entry_report>($"select * from sdk_work_entry_report where resource_id={resourceId} and start_date='{startDate}' and delete_time=0");

            if (find == null || find.status_id != (int)DicEnum.WORK_ENTRY_REPORT_STATUS.WAITING_FOR_APPROVAL)
            {
                return(false);
            }

            sdk_work_entry_report reportOld = rptDal.FindById(find.id);

            find.status_id      = (int)DicEnum.WORK_ENTRY_REPORT_STATUS.HAVE_IN_HAND;
            find.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
            find.update_user_id = userId;
            find.submit_time    = find.update_time;
            find.submit_user_id = userId;
            rptDal.Update(find);
            OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <sdk_work_entry_report>(reportOld, find), find.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SDK_WORK_RECORD, "工时表取消提交");

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// 工时表提交检查
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="resourceId"></param>
        /// <returns>0:OK;1:工时表为空:2:工时表不为可提交状态;3:有一个或多个休假请求没有审批</returns>
        public int SubmitWorkEntryCheck(DateTime startDate, long resourceId)
        {
            var weList = GetWorkEntryListByStartDate(startDate, resourceId);

            if (weList.Count == 0)
            {
                return(1);
            }

            sdk_work_entry_report_dal rptDal = new sdk_work_entry_report_dal();

            var requestCnt = rptDal.FindSignleBySql <int>($"select count(0) from tst_timeoff_request where resource_id={resourceId} and status_id={(int)DicEnum.TIMEOFF_REQUEST_STATUS.COMMIT} and request_date>='{startDate}' and request_date<'{startDate.AddDays(7)}' and delete_time=0");

            if (requestCnt > 0)
            {
                return(3);
            }

            var find = rptDal.FindSignleBySql <sdk_work_entry_report>($"select * from sdk_work_entry_report where resource_id={resourceId} and start_date='{startDate}' and delete_time=0");

            if (find != null && find.status_id != (int)DicEnum.WORK_ENTRY_REPORT_STATUS.HAVE_IN_HAND && find.status_id != (int)DicEnum.WORK_ENTRY_REPORT_STATUS.REJECTED)
            {
                return(2);
            }

            return(0);
        }
Esempio n. 3
0
        /// <summary>
        /// 工时表提交
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="resourceId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool SubmitWorkEntry(DateTime startDate, long resourceId, long userId)
        {
            var weList = GetWorkEntryListByStartDate(startDate, resourceId);
            //if (weList.Count == 0)
            //    return false;

            sdk_work_entry_report     report = new sdk_work_entry_report();
            sdk_work_entry_report_dal rptDal = new sdk_work_entry_report_dal();

            var find = rptDal.FindSignleBySql <sdk_work_entry_report>($"select * from sdk_work_entry_report where resource_id={resourceId} and start_date='{startDate}' and delete_time=0");

            if (find != null && find.status_id != (int)DicEnum.WORK_ENTRY_REPORT_STATUS.HAVE_IN_HAND && find.status_id != (int)DicEnum.WORK_ENTRY_REPORT_STATUS.REJECTED)
            {
                return(false);
            }

            if (find == null)
            {
                report.id             = rptDal.GetNextIdCom();
                report.create_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
                report.update_time    = report.create_time;
                report.create_user_id = userId;
                report.update_user_id = userId;
                report.resource_id    = resourceId;
                report.start_date     = startDate;
                report.end_date       = startDate.AddDays(6);
                report.status_id      = (int)DicEnum.WORK_ENTRY_REPORT_STATUS.WAITING_FOR_APPROVAL;
                report.submit_time    = report.create_time;
                report.submit_user_id = userId;
                rptDal.Insert(report);
                OperLogBLL.OperLogAdd <sdk_work_entry_report>(report, report.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SDK_WORK_RECORD, "工时表提交");

                foreach (var we in weList)
                {
                    var weOld = dal.FindById(we.id);
                    we.update_time          = Tools.Date.DateHelper.ToUniversalTimeStamp();
                    we.update_user_id       = userId;
                    we.work_entry_report_id = report.id;
                    dal.Update(we);
                    OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <sdk_work_entry>(weOld, we), we.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SDK_WORK_ENTRY, "工时表提交");
                }
            }
            else
            {
                sdk_work_entry_report reportOld = rptDal.FindById(find.id);
                find.status_id      = (int)DicEnum.WORK_ENTRY_REPORT_STATUS.WAITING_FOR_APPROVAL;
                find.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
                find.update_user_id = userId;
                find.submit_time    = find.update_time;
                find.submit_user_id = userId;
                rptDal.Update(find);
                OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <sdk_work_entry_report>(reportOld, find), find.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SDK_WORK_RECORD, "工时表提交");
            }

            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// 工时表审批
        /// </summary>
        /// <param name="ids">,号分割的多个工时表id</param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public int ApproveWorkEntryReport(string ids, long userId)
        {
            int appCnt  = 0;
            var rptDal  = new sdk_work_entry_report_dal();
            var logDal  = new tst_work_entry_report_log_dal();
            var reports = rptDal.FindListBySql($"select * from sdk_work_entry_report where id in({ids}) and status_id={(int)DicEnum.WORK_ENTRY_REPORT_STATUS.WAITING_FOR_APPROVAL} and delete_time=0");

            if (reports == null || reports.Count == 0)
            {
                return(appCnt);
            }

            var user = new UserResourceBLL().GetResourceById(userId);

            foreach (var report in reports)
            {
                // 判断用户是否在当前可以审批工时表
                int tier = GetWorkEntryReportCurrentApproveTier(report.id);
                if (tier == 3)
                {
                    continue;
                }
                var aprvResList = GetApproverList((long)report.resource_id);
                tier++;
                if (user.security_level_id == 1 || aprvResList.Exists(_ => _.tier == tier && _.approver_resource_id == userId)) // 用户是管理员或用户可以审批下一级
                {
                    tst_work_entry_report_log log = new tst_work_entry_report_log();
                    log.id = logDal.GetNextIdCom();
                    log.work_entry_report_id = report.id;
                    log.oper_user_id         = userId;
                    log.oper_type_id         = (int)DicEnum.WORK_ENTRY_REPORT_OPER_TYPE.APPROVAL;
                    log.oper_time            = Tools.Date.DateHelper.ToUniversalTimeStamp();
                    log.tier = tier;

                    logDal.Insert(log);
                    OperLogBLL.OperLogAdd <tst_work_entry_report_log>(log, log.id, userId, DicEnum.OPER_LOG_OBJ_CATE.WORK_ENTRY_REPORT_LOG, "工时表审批");

                    appCnt++;

                    if (aprvResList.Count == 0 || aprvResList.Max(_ => _.tier) == tier)    // 是最后一级审批人
                    {
                        var rptOld = rptDal.FindById(report.id);
                        report.status_id       = (int)DicEnum.WORK_ENTRY_REPORT_STATUS.PAYMENT_BEEN_APPROVED;
                        report.update_time     = Tools.Date.DateHelper.ToUniversalTimeStamp();
                        report.update_user_id  = userId;
                        report.approve_time    = report.update_time;
                        report.approve_user_id = userId;
                        rptDal.Update(report);
                        OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <sdk_work_entry_report>(rptOld, report), report.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SDK_WORK_RECORD, "工时表审批");
                    }
                }
            }

            return(appCnt);
        }
Esempio n. 5
0
        /// <summary>
        /// 删除工时表
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="resourceId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool DeleteWorkEntryReport(DateTime startDate, long resourceId, long userId)
        {
            sdk_work_entry_report_dal rptDal = new sdk_work_entry_report_dal();
            var find = rptDal.FindSignleBySql <sdk_work_entry_report>($"select * from sdk_work_entry_report where resource_id={resourceId} and start_date='{startDate}' and delete_time=0");

            if (find != null && find.status_id != (int)DicEnum.WORK_ENTRY_REPORT_STATUS.HAVE_IN_HAND)
            {
                return(false);
            }

            var weList = GetWorkEntryListByStartDate(startDate, resourceId);

            if (weList.Count == 0)
            {
                return(false);
            }

            var bll = new TimeOffPolicyBLL();
            tst_timeoff_balance_dal balDal = new tst_timeoff_balance_dal();

            //var weList = GetWorkEntryByBatchId(batchId);
            //if (weList.Count == 0)
            //    return true;
            //if (weList[0].approve_and_post_user_id != null) // 已审批提交不能删除
            //    return false;

            foreach (var we in weList)
            {
                we.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
                we.delete_user_id = userId;
                dal.Update(we);
                OperLogBLL.OperLogDelete <sdk_work_entry>(we, we.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SDK_WORK_ENTRY, "删除工时");

                if (we.task_id == (long)CostCode.Sick)  // 病假需要在假期余额表删除记录
                {
                    bll.UpdateTimeoffBalance(we.resource_id.Value, Tools.Date.DateHelper.TimeStampToUniversalDateTime(we.start_time.Value), (CostCode)we.task_id);
                    //var balance = bll.UpdateTimeoffBalance((long)we.resource_id, Tools.Date.DateHelper.TimeStampToDateTime((long)we.start_time), (decimal)we.hours_billed);
                    //balDal.ExecuteSQL($"delete from tst_timeoff_balance where object_id={we.id}");
                }
            }

            if (find != null)
            {
                find.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
                find.delete_user_id = userId;
                rptDal.Update(find);
                OperLogBLL.OperLogDelete <sdk_work_entry_report>(find, find.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SDK_WORK_RECORD, "删除工时表");
            }
            return(true);
        }
Esempio n. 6
0
        /// <summary>
        /// 查询工时表是否可以提交、取消提交
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="resourceId"></param>
        /// <returns>1:可以提交;2:可以取消提交;0:其他</returns>
        public int GetTimesheetSubmitStatus(DateTime startDate, long resourceId)
        {
            sdk_work_entry_report_dal rptDal = new sdk_work_entry_report_dal();
            var find = rptDal.FindSignleBySql <sdk_work_entry_report>($"select * from sdk_work_entry_report where resource_id={resourceId} and start_date='{startDate}' and delete_time=0");

            if (find == null)
            {
                return(1);
            }
            if (find.status_id == (int)DicEnum.WORK_ENTRY_REPORT_STATUS.WAITING_FOR_APPROVAL)
            {
                return(2);
            }
            if (find.status_id == (int)DicEnum.WORK_ENTRY_REPORT_STATUS.HAVE_IN_HAND ||
                find.status_id == (int)DicEnum.WORK_ENTRY_REPORT_STATUS.REJECTED)
            {
                return(1);
            }
            return(0);
        }