更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -12,19 +12,6 @@ import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
// 考勤汇总:按月 / 季 / 年统计,覆盖全部在职员工(含无打卡记录的人)。
|
||||
//
|
||||
// 口径:
|
||||
// - 应出勤 = 区间内排班明细条数(一人一天一条);
|
||||
// - 已打卡 = 区间内有签到记录的考勤条数;
|
||||
// - 缺卡 = 应出勤 - 匹配排班且已签到的条数(负值归零);
|
||||
// - 出勤率 = 匹配排班且已签到 / 应出勤。
|
||||
//
|
||||
// 周期卡片的取数:
|
||||
// - 以锚点日期所在年份为准,一次性查出「按月的排班人数、按月的打卡情况」,
|
||||
// 再在内存里累加成季度卡与年度卡,避免 17 次独立查询。
|
||||
|
||||
// oaAttendCard 一个周期的考勤卡(月 / 季 / 年)。
|
||||
type oaAttendCard struct {
|
||||
Key string `json:"key"`
|
||||
Label string `json:"label"`
|
||||
@@ -44,7 +31,6 @@ type oaAttendCard struct {
|
||||
AttendanceRate int `json:"attendance_rate"`
|
||||
}
|
||||
|
||||
// oaAttendSummaryRow 汇总表的一行:一名员工在一个周期内的考勤卡。
|
||||
type oaAttendSummaryRow struct {
|
||||
Key string `json:"key"`
|
||||
Uid uint64 `json:"uid"`
|
||||
@@ -65,13 +51,11 @@ type oaAttendSummaryRow struct {
|
||||
AttendanceRate int `json:"attendance_rate"`
|
||||
}
|
||||
|
||||
// oaAttendCountByMonth 按月排班条数。
|
||||
type oaAttendCountByMonth struct {
|
||||
Month int64 `orm:"column(m)"`
|
||||
Cnt int64 `orm:"column(cnt)"`
|
||||
}
|
||||
|
||||
// oaAttendRecordByMonth 按月打卡统计。
|
||||
type oaAttendRecordByMonth struct {
|
||||
Month int64 `orm:"column(m)"`
|
||||
Clocked int64 `orm:"column(clocked)"`
|
||||
@@ -81,13 +65,11 @@ type oaAttendRecordByMonth struct {
|
||||
NoShift int64 `orm:"column(noschedule)"`
|
||||
}
|
||||
|
||||
// oaAttendEmpCount 按员工统计的排班条数。
|
||||
type oaAttendEmpCount struct {
|
||||
EmployeeID uint `orm:"column(employee_id)"`
|
||||
Cnt int64 `orm:"column(cnt)"`
|
||||
}
|
||||
|
||||
// oaAttendRowAgg 按员工聚合的打卡统计。
|
||||
type oaAttendRowAgg struct {
|
||||
EmployeeID uint `orm:"column(employee_id)"`
|
||||
Uid uint64 `orm:"column(uid)"`
|
||||
@@ -103,7 +85,6 @@ type oaAttendRowAgg struct {
|
||||
OffTime int64 `orm:"column(offtime)"`
|
||||
}
|
||||
|
||||
// oaAttendAgg 汇总用的累加器。
|
||||
type oaAttendAgg struct {
|
||||
scheduled int64
|
||||
clocked int64
|
||||
@@ -114,8 +95,6 @@ type oaAttendAgg struct {
|
||||
offTime int64
|
||||
}
|
||||
|
||||
// oaAttendPeriodRange 把锚点日期换算成统计区间;
|
||||
// period = month / quarter / year,返回的 end 未做「不超过今天」裁剪。
|
||||
func oaAttendPeriodRange(period, anchor string) (string, string, string, bool) {
|
||||
parsed, ok := scParseDate(anchor)
|
||||
if !ok {
|
||||
@@ -143,7 +122,6 @@ func oaAttendPeriodRange(period, anchor string) (string, string, string, bool) {
|
||||
return start.Format("2006-01-02"), end.Format("2006-01-02"), label, true
|
||||
}
|
||||
|
||||
// oaAttendCapEnd 统计区间不跨过今天,避免未来排班被算成缺卡。
|
||||
func oaAttendCapEnd(end string) string {
|
||||
today := time.Now().Format("2006-01-02")
|
||||
if end > today {
|
||||
@@ -152,7 +130,6 @@ func oaAttendCapEnd(end string) string {
|
||||
return end
|
||||
}
|
||||
|
||||
// oaAttendClampRange 把区间末尾裁到今天;整段都在未来时保留原区间(展示用,查询自然为空)。
|
||||
func oaAttendClampRange(start, end string) string {
|
||||
capped := oaAttendCapEnd(end)
|
||||
if capped < start {
|
||||
@@ -161,7 +138,6 @@ func oaAttendClampRange(start, end string) string {
|
||||
return capped
|
||||
}
|
||||
|
||||
// oaAttendFillCard 依据累计值补齐缺卡与出勤率。
|
||||
func oaAttendFillCard(card *oaAttendCard) {
|
||||
card.Missing = card.Scheduled - card.Matched
|
||||
if card.Missing < 0 {
|
||||
@@ -174,7 +150,6 @@ func oaAttendFillCard(card *oaAttendCard) {
|
||||
}
|
||||
}
|
||||
|
||||
// oaAttendOrgSQL 生成组织过滤的 SQL 片段与参数。
|
||||
func oaAttendOrgSQL(orgIDs []uint64) (string, []interface{}) {
|
||||
if len(orgIDs) == 0 {
|
||||
return "", nil
|
||||
@@ -188,7 +163,6 @@ func oaAttendOrgSQL(orgIDs []uint64) (string, []interface{}) {
|
||||
return " AND org_id IN (" + strings.Join(placeholders, ",") + ")", args
|
||||
}
|
||||
|
||||
// oaAttendMonthCards 生成锚点年份 1-12 月的考勤卡。
|
||||
func oaAttendMonthCards(tid uint64, year int, orgIDs []uint64) []oaAttendCard {
|
||||
yearStart := fmt.Sprintf("%d-01-01", year)
|
||||
yearEnd := oaAttendCapEnd(fmt.Sprintf("%d-12-31", year))
|
||||
@@ -199,7 +173,6 @@ func oaAttendMonthCards(tid uint64, year int, orgIDs []uint64) []oaAttendCard {
|
||||
entryCount := map[int64]int64{}
|
||||
recordAgg := map[int64]oaAttendRecordByMonth{}
|
||||
|
||||
// 整年都在未来:不查库,全部为 0
|
||||
if yearEnd >= yearStart {
|
||||
var entryRows []oaAttendCountByMonth
|
||||
entrySQL := "SELECT MONTH(schedule_date) AS m, COUNT(*) AS cnt FROM yz_backend_oa_schedule_entry" +
|
||||
@@ -261,7 +234,6 @@ func oaAttendMonthCards(tid uint64, year int, orgIDs []uint64) []oaAttendCard {
|
||||
return cards
|
||||
}
|
||||
|
||||
// oaAttendAggregateCards 用月度卡累加出 4 个季度卡与年度卡。
|
||||
func oaAttendAggregateCards(months []oaAttendCard, year int) ([]oaAttendCard, oaAttendCard) {
|
||||
quarters := make([]oaAttendCard, 0, 4)
|
||||
yearCard := oaAttendCard{
|
||||
@@ -315,7 +287,6 @@ func oaAttendAggregateCards(months []oaAttendCard, year int) ([]oaAttendCard, oa
|
||||
return quarters, yearCard
|
||||
}
|
||||
|
||||
// oaAttendDayStat 单日全员考勤数据,前端用日历格子展示。
|
||||
type oaAttendDayStat struct {
|
||||
Date string `json:"date"`
|
||||
Weekday int `json:"weekday"`
|
||||
@@ -330,13 +301,11 @@ type oaAttendDayStat struct {
|
||||
Future bool `json:"future"`
|
||||
}
|
||||
|
||||
// oaAttendDayCount 按日排班条数。
|
||||
type oaAttendDayCount struct {
|
||||
Day string `orm:"column(d)"`
|
||||
Cnt int64 `orm:"column(cnt)"`
|
||||
}
|
||||
|
||||
// oaAttendDayRecord 按日打卡统计。
|
||||
type oaAttendDayRecord struct {
|
||||
Day string `orm:"column(d)"`
|
||||
Clocked int64 `orm:"column(clocked)"`
|
||||
@@ -346,7 +315,6 @@ type oaAttendDayRecord struct {
|
||||
NoShift int64 `orm:"column(noschedule)"`
|
||||
}
|
||||
|
||||
// oaAttendDailyStats 区间内逐日的全员考勤数据(月/季/年日历共用)。
|
||||
func oaAttendDailyStats(tid uint64, startDate, endDate string, orgIDs []uint64) []oaAttendDayStat {
|
||||
result := make([]oaAttendDayStat, 0, 32)
|
||||
|
||||
@@ -409,7 +377,6 @@ func oaAttendDailyStats(tid uint64, startDate, endDate string, orgIDs []uint64)
|
||||
return result
|
||||
}
|
||||
|
||||
// oaAttendOrgNames 租户组织 ID → 名称。
|
||||
func oaAttendOrgNames(tid uint64) map[uint64]string {
|
||||
var rows []models.BackendOrganization
|
||||
_, err := models.Orm.QueryTable(new(models.BackendOrganization)).
|
||||
@@ -426,7 +393,6 @@ func oaAttendOrgNames(tid uint64) map[uint64]string {
|
||||
return names
|
||||
}
|
||||
|
||||
// oaAttendRoster 统计范围内的在职员工(按组织过滤,关键字在内存里过滤)。
|
||||
func oaAttendRoster(tid uint64, orgIDs []uint64) ([]models.BackendEmployee, bool, error) {
|
||||
qs := employeeBaseQuery(tid)
|
||||
if len(orgIDs) > 0 {
|
||||
@@ -444,7 +410,6 @@ func oaAttendRoster(tid uint64, orgIDs []uint64) ([]models.BackendEmployee, bool
|
||||
return rows, len(rows) >= 2000, nil
|
||||
}
|
||||
|
||||
// oaAttendEmpAggs 区间内的员工聚合:scheduled 来自排班表,其余来自考勤表。
|
||||
func oaAttendEmpAggs(tid uint64, startDate, endDate string, orgIDs []uint64) (map[uint]*oaAttendAgg, map[uint64]*oaAttendAgg, []oaAttendRowAgg) {
|
||||
aggByEmp := map[uint]*oaAttendAgg{}
|
||||
aggByUid := map[uint64]*oaAttendAgg{}
|
||||
@@ -516,8 +481,6 @@ func oaAttendEmpAggs(tid uint64, startDate, endDate string, orgIDs []uint64) (ma
|
||||
return aggByEmp, aggByUid, recordRows
|
||||
}
|
||||
|
||||
// Summary 全员考勤汇总(月 / 季 / 年)。
|
||||
// GET /backend/oa/attendance/summary?period=month&date=2026-11-14&org_id=&include_child=1&keyword=&page=&pageSize=
|
||||
func (c *BackendOaAttendanceController) Summary() {
|
||||
tid, _, ok := c.atOperator()
|
||||
if !ok {
|
||||
@@ -567,7 +530,6 @@ func (c *BackendOaAttendanceController) Summary() {
|
||||
monthCards := oaAttendMonthCards(tid, year, orgIDs)
|
||||
quarterCards, yearCard := oaAttendAggregateCards(monthCards, year)
|
||||
|
||||
// 当前选中周期对应的考勤卡
|
||||
activeKey := fmt.Sprintf("%d-%02d", year, int(mustParseMonth(anchor)))
|
||||
activeCard := yearCard
|
||||
switch period {
|
||||
@@ -635,7 +597,6 @@ func (c *BackendOaAttendanceController) Summary() {
|
||||
rows = append(rows, row)
|
||||
}
|
||||
|
||||
// 未绑定员工档案但打过卡的人:按登录身份 uid 单列,保证数据不丢
|
||||
for _, record := range recordRows {
|
||||
if record.EmployeeID != 0 {
|
||||
continue
|
||||
@@ -710,7 +671,6 @@ func (c *BackendOaAttendanceController) Summary() {
|
||||
})
|
||||
}
|
||||
|
||||
// mustParseMonth 取日期字符串的月份,解析失败返回当前月。
|
||||
func mustParseMonth(date string) time.Month {
|
||||
if parsed, ok := scParseDate(date); ok {
|
||||
return parsed.Month()
|
||||
|
||||
Reference in new issue
Block a user