| | |
| | | "silkserver/middleware" |
| | | "silkserver/models" |
| | | "silkserver/pkg/logx" |
| | | "silkserver/pkg/structx" |
| | | "silkserver/pkg/timex" |
| | | "time" |
| | | ) |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, "人员id和考勤日期不能为空") |
| | | return |
| | | } |
| | | m := make(map[string]interface{}) |
| | | m["status"] = params.Status |
| | | m["overTimeDuration"] = params.OverTimeDuration |
| | | err = models.NewAttendanceManageSearch().SetDate(params.Date).SetWorkerId(params.WorkerId).UpdateByMap(m) |
| | | count, err := models.NewAttendanceManageSearch().SetDate(params.Date).SetWorkerId(params.WorkerId).Count() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "更新失败") |
| | | util.ResponseFormat(c, code.RequestParamError, err) |
| | | return |
| | | } |
| | | if count > 0 { |
| | | m := make(map[string]interface{}) |
| | | m["status"] = params.Status |
| | | m["over_time_duration"] = params.OverTimeDuration |
| | | err = models.NewAttendanceManageSearch().SetDate(params.Date).SetWorkerId(params.WorkerId).UpdateByMap(m) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "更新失败") |
| | | return |
| | | } |
| | | } else { |
| | | var manage models.AttendanceManage |
| | | err = structx.AssignTo(params, &manage) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "数据转换失败") |
| | | return |
| | | } |
| | | info := middleware.GetUserInfo(c) |
| | | manage.AddPeople = info.NickName |
| | | manage.CreateTime = timex.TimeToString2(time.Now()) |
| | | err = models.NewAttendanceManageSearch().Create(&manage) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "更新失败") |
| | | return |
| | | } |
| | | } |
| | | |
| | | util.ResponseFormat(c, code.Success, "更新成功") |
| | | } |
| | | |
| | |
| | | } |
| | | year, month, _ := location.Date() |
| | | date := timex.GetDate(year, month) |
| | | var details []response.AttendanceDetail |
| | | for i := 1; i <= date; i++ { |
| | | var ad response.AttendanceDetail |
| | | ad.Date = i |
| | | ad.Status = constvar.Vacation |
| | | details = append(details, ad) |
| | | } |
| | | |
| | | manages, err := models.NewAttendanceManageSearch().SetMonth(params.Month).SetPreload(true).FindNotTotal() |
| | | if err != nil { |
| | |
| | | as.WorkerName = manage.WorkerName |
| | | as.WorkType = manage.WorkType.WorkName |
| | | as.Month = params.Month |
| | | as.WorkTypeId = manage.WorkTypeId |
| | | var details []response.AttendanceDetail |
| | | for i := 1; i <= date; i++ { |
| | | var ad response.AttendanceDetail |
| | | ad.Date = i |
| | | ad.Status = constvar.Vacation |
| | | details = append(details, ad) |
| | | } |
| | | as.Details = details |
| | | } |
| | | as.WeekdayOverTime = as.WeekdayOverTime.Add(manage.OverTimeDuration) |
| | |
| | | WorkerId string `json:"workerId"` //人员id |
| | | Status constvar.AttendanceStatus `json:"status"` //状态 |
| | | OverTimeDuration decimal.Decimal `json:"overTimeDuration"` //加班时长 |
| | | WorkerName string `json:"workerName"` //人员姓名 |
| | | StartWorkTime string `json:"startWorkTime"` //上班打卡时间 |
| | | EndWorkTime string `json:"endWorkTime"` //下班打卡时间 |
| | | Classes string `json:"classes"` //班次 |
| | | ClassesStartTime string `json:"classesStartTime"` //班次开始时间 |
| | | ClassesEndTime string `json:"classesEndTime"` //班次下班时间 |
| | | WorkTypeId uint `json:"workTypeId"` //工种id |
| | | } |
| | |
| | | type AttendanceStatistic struct { |
| | | WorkerId string `json:"workerId"` //人员id |
| | | WorkerName string `json:"workerName"` //人员姓名 |
| | | WorkTypeId uint `json:"workTypeId"` //工种id |
| | | WorkType string `json:"workType"` //工种 |
| | | Month string `json:"month"` //月份 |
| | | WeekdayOverTime decimal.Decimal `json:"weekdayOverTime"` //工作日加班时长 |
| | |
| | | "request.UpdateAttendance": { |
| | | "type": "object", |
| | | "properties": { |
| | | "classes": { |
| | | "description": "班次", |
| | | "type": "string" |
| | | }, |
| | | "classesEndTime": { |
| | | "description": "班次下班时间", |
| | | "type": "string" |
| | | }, |
| | | "classesStartTime": { |
| | | "description": "班次开始时间", |
| | | "type": "string" |
| | | }, |
| | | "date": { |
| | | "description": "日期", |
| | | "type": "string" |
| | | }, |
| | | "endWorkTime": { |
| | | "description": "下班打卡时间", |
| | | "type": "string" |
| | | }, |
| | | "overTimeDuration": { |
| | | "description": "加班时长", |
| | | "type": "number" |
| | | }, |
| | | "startWorkTime": { |
| | | "description": "上班打卡时间", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "description": "状态", |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "workTypeId": { |
| | | "description": "工种id", |
| | | "type": "integer" |
| | | }, |
| | | "workerId": { |
| | | "description": "人员id", |
| | | "type": "string" |
| | | }, |
| | | "workerName": { |
| | | "description": "人员姓名", |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | "description": "工种", |
| | | "type": "string" |
| | | }, |
| | | "workTypeId": { |
| | | "description": "工种id", |
| | | "type": "integer" |
| | | }, |
| | | "workerId": { |
| | | "description": "人员id", |
| | | "type": "string" |
| | |
| | | "request.UpdateAttendance": { |
| | | "type": "object", |
| | | "properties": { |
| | | "classes": { |
| | | "description": "班次", |
| | | "type": "string" |
| | | }, |
| | | "classesEndTime": { |
| | | "description": "班次下班时间", |
| | | "type": "string" |
| | | }, |
| | | "classesStartTime": { |
| | | "description": "班次开始时间", |
| | | "type": "string" |
| | | }, |
| | | "date": { |
| | | "description": "日期", |
| | | "type": "string" |
| | | }, |
| | | "endWorkTime": { |
| | | "description": "下班打卡时间", |
| | | "type": "string" |
| | | }, |
| | | "overTimeDuration": { |
| | | "description": "加班时长", |
| | | "type": "number" |
| | | }, |
| | | "startWorkTime": { |
| | | "description": "上班打卡时间", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "description": "状态", |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "workTypeId": { |
| | | "description": "工种id", |
| | | "type": "integer" |
| | | }, |
| | | "workerId": { |
| | | "description": "人员id", |
| | | "type": "string" |
| | | }, |
| | | "workerName": { |
| | | "description": "人员姓名", |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | "description": "工种", |
| | | "type": "string" |
| | | }, |
| | | "workTypeId": { |
| | | "description": "工种id", |
| | | "type": "integer" |
| | | }, |
| | | "workerId": { |
| | | "description": "人员id", |
| | | "type": "string" |
| | |
| | | type: object |
| | | request.UpdateAttendance: |
| | | properties: |
| | | classes: |
| | | description: 班次 |
| | | type: string |
| | | classesEndTime: |
| | | description: 班次下班时间 |
| | | type: string |
| | | classesStartTime: |
| | | description: 班次开始时间 |
| | | type: string |
| | | date: |
| | | description: 日期 |
| | | type: string |
| | | endWorkTime: |
| | | description: 下班打卡时间 |
| | | type: string |
| | | overTimeDuration: |
| | | description: 加班时长 |
| | | type: number |
| | | startWorkTime: |
| | | description: 上班打卡时间 |
| | | type: string |
| | | status: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.AttendanceStatus' |
| | | description: 状态 |
| | | workTypeId: |
| | | description: 工种id |
| | | type: integer |
| | | workerId: |
| | | description: 人员id |
| | | type: string |
| | | workerName: |
| | | description: 人员姓名 |
| | | type: string |
| | | type: object |
| | | request.UpdateDict: |
| | |
| | | workType: |
| | | description: 工种 |
| | | type: string |
| | | workTypeId: |
| | | description: 工种id |
| | | type: integer |
| | | workerId: |
| | | description: 人员id |
| | | type: string |