liujiandao
2024-04-24 db38b24898e99794369ae6a78ab43089b4c5cfef
考勤修改
6个文件已修改
145 ■■■■■ 已修改文件
controllers/attendance_controller.go 49 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/request/attendance_request.go 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/response/attendance_response.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/attendance_controller.go
@@ -12,6 +12,7 @@
    "silkserver/middleware"
    "silkserver/models"
    "silkserver/pkg/logx"
    "silkserver/pkg/structx"
    "silkserver/pkg/timex"
    "time"
)
@@ -229,14 +230,37 @@
        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, "更新成功")
}
@@ -268,13 +292,6 @@
    }
    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 {
@@ -292,6 +309,14 @@
            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)
controllers/request/attendance_request.go
@@ -27,4 +27,11 @@
    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
}
controllers/response/attendance_response.go
@@ -12,6 +12,7 @@
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"`        //工作日加班时长
docs/docs.go
@@ -3782,13 +3782,33 @@
        "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": "状态",
@@ -3798,8 +3818,16 @@
                        }
                    ]
                },
                "workTypeId": {
                    "description": "工种id",
                    "type": "integer"
                },
                "workerId": {
                    "description": "人员id",
                    "type": "string"
                },
                "workerName": {
                    "description": "人员姓名",
                    "type": "string"
                }
            }
@@ -4181,6 +4209,10 @@
                    "description": "工种",
                    "type": "string"
                },
                "workTypeId": {
                    "description": "工种id",
                    "type": "integer"
                },
                "workerId": {
                    "description": "人员id",
                    "type": "string"
docs/swagger.json
@@ -3770,13 +3770,33 @@
        "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": "状态",
@@ -3786,8 +3806,16 @@
                        }
                    ]
                },
                "workTypeId": {
                    "description": "工种id",
                    "type": "integer"
                },
                "workerId": {
                    "description": "人员id",
                    "type": "string"
                },
                "workerName": {
                    "description": "人员姓名",
                    "type": "string"
                }
            }
@@ -4169,6 +4197,10 @@
                    "description": "工种",
                    "type": "string"
                },
                "workTypeId": {
                    "description": "工种id",
                    "type": "integer"
                },
                "workerId": {
                    "description": "人员id",
                    "type": "string"
docs/swagger.yaml
@@ -1056,18 +1056,39 @@
    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:
@@ -1341,6 +1362,9 @@
      workType:
        description: 工种
        type: string
      workTypeId:
        description: 工种id
        type: integer
      workerId:
        description: 人员id
        type: string