liujiandao
2024-04-23 adb8a4d6c2806beae1ac97af7f71c8a3ce3ed0c9
修改考勤信息
7个文件已修改
307 ■■■■■ 已修改文件
controllers/attendance_controller.go 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/request/attendance_request.go 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/attendance_manage.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/attendance_controller.go
@@ -186,6 +186,37 @@
    util.ResponseFormatList(c, code.Success, manages, total)
}
// UpdateAttendance
//
//    @Tags        考勤管理
//    @Summary    更新考勤
//    @Produce    application/json
//    @Param        object    body        request.UpdateAttendance    true    "参数"
//    @Param         Authorization    header string true "token"
//    @Success    200        {object}    util.Response        "成功"
//    @Router        /api-jl/v1/attendance/updateAttendance [post]
func (slf AttendanceController) UpdateAttendance(c *gin.Context) {
    var params request.UpdateAttendance
    err := c.BindJSON(&params)
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误")
        return
    }
    if params.Date == "" || params.WorkerId == "" {
        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)
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "更新失败")
        return
    }
    util.ResponseFormat(c, code.Success, "更新成功")
}
// GetAttendanceStatistic
//
//    @Tags        考勤管理
controllers/request/attendance_request.go
@@ -1,5 +1,10 @@
package request
import (
    "github.com/shopspring/decimal"
    "silkserver/constvar"
)
type GetAttendanceList struct {
    PageInfo
    Keyword string `json:"keyword"`
@@ -12,3 +17,10 @@
type GetAttendanceStatistic struct {
    Month string `json:"month"` //月份
}
type UpdateAttendance struct {
    Date             string                    `json:"date"`             //日期
    WorkerId         string                    `json:"workerId"`         //人员id
    Status           constvar.AttendanceStatus `json:"status"`           //状态
    OverTimeDuration decimal.Decimal           `json:"overTimeDuration"` //加班时长
}
docs/docs.go
@@ -238,6 +238,43 @@
                }
            }
        },
        "/api-jl/v1/attendance/updateAttendance": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "考勤管理"
                ],
                "summary": "更新考勤",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateAttendance"
                        }
                    },
                    {
                        "type": "string",
                        "description": "token",
                        "name": "Authorization",
                        "in": "header",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-jl/v1/fineness/changeYieldRegister": {
            "post": {
                "produces": [
@@ -2954,10 +2991,6 @@
                "id": {
                    "type": "integer"
                },
                "name": {
                    "description": "车间",
                    "type": "string"
                },
                "startDate": {
                    "description": "开始日期",
                    "type": "string"
@@ -2981,9 +3014,17 @@
                    "description": "工人ID",
                    "type": "string"
                },
                "workshop": {
                    "description": "车间编号",
                    "type": "string"
                },
                "workshopGroup": {
                    "description": "车组",
                    "type": "integer"
                },
                "workshopName": {
                    "description": "车间名称",
                    "type": "string"
                }
            }
        },
@@ -3333,7 +3374,8 @@
                "startWorkerPosition",
                "workerId",
                "workshop",
                "workshopGroup"
                "workshopGroup",
                "workshopName"
            ],
            "properties": {
                "endDate": {
@@ -3357,12 +3399,16 @@
                    "type": "string"
                },
                "workshop": {
                    "description": "车间",
                    "description": "车间编号",
                    "type": "string"
                },
                "workshopGroup": {
                    "description": "车组",
                    "type": "integer"
                },
                "workshopName": {
                    "description": "车间名称",
                    "type": "string"
                }
            }
        },
@@ -3680,6 +3726,31 @@
                }
            }
        },
        "request.UpdateAttendance": {
            "type": "object",
            "properties": {
                "date": {
                    "description": "日期",
                    "type": "string"
                },
                "overTimeDuration": {
                    "description": "加班时长",
                    "type": "number"
                },
                "status": {
                    "description": "状态",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.AttendanceStatus"
                        }
                    ]
                },
                "workerId": {
                    "description": "人员id",
                    "type": "string"
                }
            }
        },
        "request.UpdateDict": {
            "type": "object",
            "properties": {
@@ -3737,7 +3808,8 @@
                "startWorkerPosition",
                "workerId",
                "workshop",
                "workshopGroup"
                "workshopGroup",
                "workshopName"
            ],
            "properties": {
                "endDate": {
@@ -3764,12 +3836,16 @@
                    "type": "string"
                },
                "workshop": {
                    "description": "车间",
                    "description": "车间编号",
                    "type": "string"
                },
                "workshopGroup": {
                    "description": "车组",
                    "type": "integer"
                },
                "workshopName": {
                    "description": "车间名称",
                    "type": "string"
                }
            }
        },
docs/swagger.json
@@ -226,6 +226,43 @@
                }
            }
        },
        "/api-jl/v1/attendance/updateAttendance": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "考勤管理"
                ],
                "summary": "更新考勤",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateAttendance"
                        }
                    },
                    {
                        "type": "string",
                        "description": "token",
                        "name": "Authorization",
                        "in": "header",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-jl/v1/fineness/changeYieldRegister": {
            "post": {
                "produces": [
@@ -2942,10 +2979,6 @@
                "id": {
                    "type": "integer"
                },
                "name": {
                    "description": "车间",
                    "type": "string"
                },
                "startDate": {
                    "description": "开始日期",
                    "type": "string"
@@ -2969,9 +3002,17 @@
                    "description": "工人ID",
                    "type": "string"
                },
                "workshop": {
                    "description": "车间编号",
                    "type": "string"
                },
                "workshopGroup": {
                    "description": "车组",
                    "type": "integer"
                },
                "workshopName": {
                    "description": "车间名称",
                    "type": "string"
                }
            }
        },
@@ -3321,7 +3362,8 @@
                "startWorkerPosition",
                "workerId",
                "workshop",
                "workshopGroup"
                "workshopGroup",
                "workshopName"
            ],
            "properties": {
                "endDate": {
@@ -3345,12 +3387,16 @@
                    "type": "string"
                },
                "workshop": {
                    "description": "车间",
                    "description": "车间编号",
                    "type": "string"
                },
                "workshopGroup": {
                    "description": "车组",
                    "type": "integer"
                },
                "workshopName": {
                    "description": "车间名称",
                    "type": "string"
                }
            }
        },
@@ -3668,6 +3714,31 @@
                }
            }
        },
        "request.UpdateAttendance": {
            "type": "object",
            "properties": {
                "date": {
                    "description": "日期",
                    "type": "string"
                },
                "overTimeDuration": {
                    "description": "加班时长",
                    "type": "number"
                },
                "status": {
                    "description": "状态",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.AttendanceStatus"
                        }
                    ]
                },
                "workerId": {
                    "description": "人员id",
                    "type": "string"
                }
            }
        },
        "request.UpdateDict": {
            "type": "object",
            "properties": {
@@ -3725,7 +3796,8 @@
                "startWorkerPosition",
                "workerId",
                "workshop",
                "workshopGroup"
                "workshopGroup",
                "workshopName"
            ],
            "properties": {
                "endDate": {
@@ -3752,12 +3824,16 @@
                    "type": "string"
                },
                "workshop": {
                    "description": "车间",
                    "description": "车间编号",
                    "type": "string"
                },
                "workshopGroup": {
                    "description": "车组",
                    "type": "integer"
                },
                "workshopName": {
                    "description": "车间名称",
                    "type": "string"
                }
            }
        },
docs/swagger.yaml
@@ -535,9 +535,6 @@
        type: integer
      id:
        type: integer
      name:
        description: 车间
        type: string
      startDate:
        description: 开始日期
        type: string
@@ -553,9 +550,15 @@
      workerId:
        description: 工人ID
        type: string
      workshop:
        description: 车间编号
        type: string
      workshopGroup:
        description: 车组
        type: integer
      workshopName:
        description: 车间名称
        type: string
    type: object
  models.WorkshopManage:
    properties:
@@ -803,11 +806,14 @@
        description: 工人ID
        type: string
      workshop:
        description: 车间
        description: 车间编号
        type: string
      workshopGroup:
        description: 车组
        type: integer
      workshopName:
        description: 车间名称
        type: string
    required:
    - endDate
    - endWorkerPosition
@@ -816,6 +822,7 @@
    - workerId
    - workshop
    - workshopGroup
    - workshopName
    type: object
  request.ChangeYieldRegister:
    properties:
@@ -1031,6 +1038,22 @@
          $ref: '#/definitions/request.RankStandard'
        type: array
    type: object
  request.UpdateAttendance:
    properties:
      date:
        description: 日期
        type: string
      overTimeDuration:
        description: 加班时长
        type: number
      status:
        allOf:
        - $ref: '#/definitions/constvar.AttendanceStatus'
        description: 状态
      workerId:
        description: 人员id
        type: string
    type: object
  request.UpdateDict:
    properties:
      dictType:
@@ -1083,11 +1106,14 @@
        description: 工人ID
        type: string
      workshop:
        description: 车间
        description: 车间编号
        type: string
      workshopGroup:
        description: 车组
        type: integer
      workshopName:
        description: 车间名称
        type: string
    required:
    - endDate
    - endWorkerPosition
@@ -1096,6 +1122,7 @@
    - workerId
    - workshop
    - workshopGroup
    - workshopName
    type: object
  request.YieldRegisterCircleInfo:
    properties:
@@ -1513,6 +1540,30 @@
      summary: 保存加班规则
      tags:
      - 考勤管理
  /api-jl/v1/attendance/updateAttendance:
    post:
      parameters:
      - description: 参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.UpdateAttendance'
      - description: token
        in: header
        name: Authorization
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 更新考勤
      tags:
      - 考勤管理
  /api-jl/v1/fineness/changeYieldRegister:
    post:
      parameters:
models/attendance_manage.go
@@ -71,6 +71,16 @@
    return slf
}
func (slf *AttendanceManageSearch) SetDate(date string) *AttendanceManageSearch {
    slf.Date = date
    return slf
}
func (slf *AttendanceManageSearch) SetWorkerId(workerId string) *AttendanceManageSearch {
    slf.WorkerId = workerId
    return slf
}
func (slf *AttendanceManageSearch) build() *gorm.DB {
    var db = slf.Orm.Table(slf.TableName())
@@ -86,6 +96,14 @@
        db = db.Where("date like ?", slf.Month+"%")
    }
    if slf.Date != "" {
        db = db.Where("date = ?", slf.Date)
    }
    if slf.WorkerId != "" {
        db = db.Where("worker_id = ?", slf.WorkerId)
    }
    return db
}
router/router.go
@@ -107,6 +107,7 @@
    {
        attendanceApi.POST("attendanceInput", attendanceController.AttendanceInput)               //考勤导入
        attendanceApi.POST("getAttendanceList", attendanceController.GetAttendanceList)           //获取考勤列表
        attendanceApi.POST("updateAttendance", attendanceController.UpdateAttendance)             //更新考勤
        attendanceApi.POST("getAttendanceStatistic", attendanceController.GetAttendanceStatistic) //获取考勤统计
        attendanceApi.DELETE("deleteAttendanceInfo", attendanceController.DeleteAttendanceInfo)   //删除考勤信息
        attendanceApi.GET("getAttendanceRule", attendanceController.GetAttendanceRule)            //获取加班规则