| | |
| | | Vacation //休假 |
| | | Abnormal //异常 |
| | | ) |
| | | |
| | | type FileTemplateCategory int |
| | | |
| | | const ( |
| | | FileTemplateCategory_Selfmade FileTemplateCategory = iota + 1 //入库-自制 |
| | | FileTemplateCategory_Output //出库 |
| | | FileTemplateCategory_JialianInput = 14 //嘉联入库 |
| | | FileTemplateCategory_JialianOutput = 15 //嘉联出库 |
| | | FileTemplateCategory_JialianAttendance = 16 //嘉联-员工考勤 |
| | | ) |
| | |
| | | type AttendanceController struct { |
| | | } |
| | | |
| | | // GetTemplate |
| | | // @Tags 考勤管理 |
| | | // @Summary 获取模版列表 |
| | | // @Produce application/json |
| | | // @Param object body request.TemplateCategoryRequest true "参数" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-jl/v1/attendance/getTemplate [post] |
| | | func (slf AttendanceController) GetTemplate(c *gin.Context) { |
| | | var params request.TemplateCategoryRequest |
| | | if err := c.ShouldBind(¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | |
| | | list, err := models.NewFileTemplateAttachmentSearch().SetCategory(params.Category).Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查找失败") |
| | | return |
| | | } |
| | | |
| | | util.ResponseFormat(c, code.Success, list) |
| | | } |
| | | |
| | | // AttendanceInput |
| | | // |
| | | // @Tags 考勤管理 |
| | |
| | | as.ActualAttendanceDays = as.ActualAttendanceDays + 1 |
| | | time2, _ := timex.StringToTime2(manage.Date) |
| | | day := time2.Day() |
| | | as.Details[day-1].Status = manage.Status |
| | | detail := as.Details[day-1] |
| | | detail.Status = manage.Status |
| | | detail.StartWorkTime = manage.StartWorkTime |
| | | detail.EndWorkTime = manage.EndWorkTime |
| | | detail.ClassesStartTime = manage.ClassesStartTime |
| | | detail.ClassesEndTime = manage.ClassesEndTime |
| | | detail.Classes = manage.Classes |
| | | as.Details[day-1] = detail |
| | | |
| | | m[manage.WorkerId] = as |
| | | } |
| | |
| | | "silkserver/constvar" |
| | | ) |
| | | |
| | | type TemplateCategoryRequest struct { |
| | | Category constvar.FileTemplateCategory `json:"category"` |
| | | } |
| | | |
| | | type GetAttendanceList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | |
| | | type AttendanceDetail struct { |
| | | Date int `json:"date"` //日期 |
| | | Status constvar.AttendanceStatus `json:"status"` //状态 |
| | | StartWorkTime string `json:"startWorkTime"` //上班打卡时间 |
| | | EndWorkTime string `json:"endWorkTime"` //下班打卡时间 |
| | | Classes string `json:"classes"` //班次 |
| | | ClassesStartTime string `json:"classesStartTime"` //班次开始时间 |
| | | ClassesEndTime string `json:"classesEndTime"` //班次下班时间 |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/attendance/getTemplate": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "考勤管理" |
| | | ], |
| | | "summary": "获取模版列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.TemplateCategoryRequest" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/attendance/saveAttendanceRule": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "DictTypeSpec" |
| | | ] |
| | | }, |
| | | "constvar.FileTemplateCategory": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2 |
| | | ], |
| | | "x-enum-comments": { |
| | | "FileTemplateCategory_Output": "出库", |
| | | "FileTemplateCategory_Selfmade": "入库-自制" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "FileTemplateCategory_Selfmade", |
| | | "FileTemplateCategory_Output" |
| | | ] |
| | | }, |
| | | "constvar.MiniDictType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.TemplateCategoryRequest": { |
| | | "type": "object", |
| | | "properties": { |
| | | "category": { |
| | | "$ref": "#/definitions/constvar.FileTemplateCategory" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateAttendance": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "response.AttendanceDetail": { |
| | | "type": "object", |
| | | "properties": { |
| | | "classes": { |
| | | "description": "班次", |
| | | "type": "string" |
| | | }, |
| | | "classesEndTime": { |
| | | "description": "班次下班时间", |
| | | "type": "string" |
| | | }, |
| | | "classesStartTime": { |
| | | "description": "班次开始时间", |
| | | "type": "string" |
| | | }, |
| | | "date": { |
| | | "description": "日期", |
| | | "type": "integer" |
| | | }, |
| | | "endWorkTime": { |
| | | "description": "下班打卡时间", |
| | | "type": "string" |
| | | }, |
| | | "startWorkTime": { |
| | | "description": "上班打卡时间", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "description": "状态", |
| | | "allOf": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/attendance/getTemplate": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "考勤管理" |
| | | ], |
| | | "summary": "获取模版列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.TemplateCategoryRequest" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/attendance/saveAttendanceRule": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "DictTypeSpec" |
| | | ] |
| | | }, |
| | | "constvar.FileTemplateCategory": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2 |
| | | ], |
| | | "x-enum-comments": { |
| | | "FileTemplateCategory_Output": "出库", |
| | | "FileTemplateCategory_Selfmade": "入库-自制" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "FileTemplateCategory_Selfmade", |
| | | "FileTemplateCategory_Output" |
| | | ] |
| | | }, |
| | | "constvar.MiniDictType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.TemplateCategoryRequest": { |
| | | "type": "object", |
| | | "properties": { |
| | | "category": { |
| | | "$ref": "#/definitions/constvar.FileTemplateCategory" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateAttendance": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "response.AttendanceDetail": { |
| | | "type": "object", |
| | | "properties": { |
| | | "classes": { |
| | | "description": "班次", |
| | | "type": "string" |
| | | }, |
| | | "classesEndTime": { |
| | | "description": "班次下班时间", |
| | | "type": "string" |
| | | }, |
| | | "classesStartTime": { |
| | | "description": "班次开始时间", |
| | | "type": "string" |
| | | }, |
| | | "date": { |
| | | "description": "日期", |
| | | "type": "integer" |
| | | }, |
| | | "endWorkTime": { |
| | | "description": "下班打卡时间", |
| | | "type": "string" |
| | | }, |
| | | "startWorkTime": { |
| | | "description": "上班打卡时间", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "description": "状态", |
| | | "allOf": [ |
| | |
| | | - DictTypeWorkshop |
| | | - DictTypeColor |
| | | - DictTypeSpec |
| | | constvar.FileTemplateCategory: |
| | | enum: |
| | | - 1 |
| | | - 2 |
| | | type: integer |
| | | x-enum-comments: |
| | | FileTemplateCategory_Output: 出库 |
| | | FileTemplateCategory_Selfmade: 入库-自制 |
| | | x-enum-varnames: |
| | | - FileTemplateCategory_Selfmade |
| | | - FileTemplateCategory_Output |
| | | constvar.MiniDictType: |
| | | enum: |
| | | - 1 |
| | |
| | | $ref: '#/definitions/request.RankStandard' |
| | | type: array |
| | | type: object |
| | | request.TemplateCategoryRequest: |
| | | properties: |
| | | category: |
| | | $ref: '#/definitions/constvar.FileTemplateCategory' |
| | | type: object |
| | | request.UpdateAttendance: |
| | | properties: |
| | | date: |
| | |
| | | type: object |
| | | response.AttendanceDetail: |
| | | properties: |
| | | classes: |
| | | description: 班次 |
| | | type: string |
| | | classesEndTime: |
| | | description: 班次下班时间 |
| | | type: string |
| | | classesStartTime: |
| | | description: 班次开始时间 |
| | | type: string |
| | | date: |
| | | description: 日期 |
| | | type: integer |
| | | endWorkTime: |
| | | description: 下班打卡时间 |
| | | type: string |
| | | startWorkTime: |
| | | description: 上班打卡时间 |
| | | type: string |
| | | status: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.AttendanceStatus' |
| | |
| | | summary: 获取考勤统计 |
| | | tags: |
| | | - 考勤管理 |
| | | /api-jl/v1/attendance/getTemplate: |
| | | post: |
| | | parameters: |
| | | - description: 参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.TemplateCategoryRequest' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 获取模版列表 |
| | | tags: |
| | | - 考勤管理 |
| | | /api-jl/v1/attendance/saveAttendanceRule: |
| | | post: |
| | | parameters: |
New file |
| | |
| | | package models |
| | | |
| | | import ( |
| | | "fmt" |
| | | "gorm.io/gorm" |
| | | "silkserver/constvar" |
| | | "silkserver/pkg/mysqlx" |
| | | ) |
| | | |
| | | type ( |
| | | //FileTemplateAttachment 上传文件模版管理 |
| | | FileTemplateAttachment struct { |
| | | gorm.Model |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Category constvar.FileTemplateCategory `json:"category" gorm:"type:int(11);comment:模版种类"` |
| | | Name string `json:"name" gorm:"type:varchar(63);comment:模版名称"` |
| | | TableInfo string `json:"tableInfo" gorm:"type:varchar(31);comment:表名"` |
| | | FileUrl string `json:"fileUrl" gorm:"type:varchar(255);comment:文件地址"` |
| | | } |
| | | FileTemplateAttachmentSearch struct { |
| | | FileTemplateAttachment |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Keyword string |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | } |
| | | ) |
| | | |
| | | func (slf *FileTemplateAttachment) TableName() string { |
| | | return "wms_file_template_attachment" |
| | | } |
| | | |
| | | func NewFileTemplateAttachmentSearch() *FileTemplateAttachmentSearch { |
| | | return &FileTemplateAttachmentSearch{Orm: mysqlx.GetDB()} |
| | | } |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) SetOrm(tx *gorm.DB) *FileTemplateAttachmentSearch { |
| | | slf.Orm = tx |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) SetPage(page, size int) *FileTemplateAttachmentSearch { |
| | | slf.PageNum, slf.PageSize = page, size |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) SetOrder(order string) *FileTemplateAttachmentSearch { |
| | | slf.Order = order |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) SetID(id int) *FileTemplateAttachmentSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) SetKeyword(keyword string) *FileTemplateAttachmentSearch { |
| | | slf.Keyword = keyword |
| | | return slf |
| | | } |
| | | |
| | | //func (slf *FileTemplateAttachmentSearch) SetPreload(preload bool) *FileTemplateAttachmentSearch { |
| | | // slf.Preload = preload |
| | | // return slf |
| | | //} |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) SetCategory(category constvar.FileTemplateCategory) *FileTemplateAttachmentSearch { |
| | | slf.Category = category |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&FileTemplateAttachment{}) |
| | | |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | if slf.Order != "" { |
| | | db = db.Order(slf.Order) |
| | | } |
| | | |
| | | //if slf.Preload { |
| | | // db = db.Model(&FileTemplateAttachment{}).Preload("Attachment") |
| | | //} |
| | | |
| | | if int(slf.Category) != 0 { |
| | | db = db.Where("category=?", slf.Category) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | // Create 单条插入 |
| | | func (slf *FileTemplateAttachmentSearch) Create(record *FileTemplateAttachment) error { |
| | | var db = slf.build() |
| | | |
| | | if err := db.Create(record).Error; err != nil { |
| | | return err |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | | // CreateBatch 批量插入 |
| | | func (slf *FileTemplateAttachmentSearch) CreateBatch(records []*FileTemplateAttachment) error { |
| | | var db = slf.build() |
| | | |
| | | if err := db.Create(&records).Error; err != nil { |
| | | return fmt.Errorf("create batch err: %v, records: %+v", err, records) |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) Update(record *FileTemplateAttachment) error { |
| | | var db = slf.build() |
| | | |
| | | if err := db.Omit("CreatedAt").Updates(record).Error; err != nil { |
| | | return fmt.Errorf("save err: %v, record: %+v", err, record) |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Unscoped().Delete(&FileTemplateAttachment{}).Error |
| | | } |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) First() (*FileTemplateAttachment, error) { |
| | | var ( |
| | | record = new(FileTemplateAttachment) |
| | | db = slf.build() |
| | | ) |
| | | |
| | | if err := db.First(record).Error; err != nil { |
| | | return record, err |
| | | } |
| | | |
| | | return record, nil |
| | | } |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) FindByPage() ([]*FileTemplateAttachment, int64, error) { |
| | | var ( |
| | | records = make([]*FileTemplateAttachment, 0) |
| | | total int64 |
| | | db = slf.build() |
| | | ) |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | return records, total, fmt.Errorf("find count err: %v", err) |
| | | } |
| | | if slf.PageNum*slf.PageSize > 0 { |
| | | db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) |
| | | } |
| | | if err := db.Find(&records).Error; err != nil { |
| | | return records, total, fmt.Errorf("find records err: %v", err) |
| | | } |
| | | |
| | | return records, total, nil |
| | | } |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) Find() ([]*FileTemplateAttachment, error) { |
| | | var ( |
| | | records = make([]*FileTemplateAttachment, 0) |
| | | db = slf.build() |
| | | ) |
| | | |
| | | if err := db.Find(&records).Error; err != nil { |
| | | return records, fmt.Errorf("find records err: %v", err) |
| | | } |
| | | |
| | | return records, nil |
| | | } |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) FirstRes() (*FileTemplateAttachment, *gorm.DB) { |
| | | var ( |
| | | record = new(FileTemplateAttachment) |
| | | db = slf.build() |
| | | ) |
| | | |
| | | return record, db.First(&record) |
| | | } |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) Count() (int64, error) { |
| | | var ( |
| | | total int64 |
| | | db = slf.build() |
| | | ) |
| | | err := db.Count(&total).Error |
| | | return total, err |
| | | } |
| | | |
| | | func (slf *FileTemplateAttachmentSearch) UpdateByMap(upMap map[string]interface{}) error { |
| | | var ( |
| | | db = slf.build() |
| | | ) |
| | | |
| | | if err := db.Updates(upMap).Error; err != nil { |
| | | return fmt.Errorf("update by map err: %v, upMap: %+v", err, upMap) |
| | | } |
| | | |
| | | return nil |
| | | } |
| | |
| | | attendanceApi := r.Group(urlPrefix + "/attendance") |
| | | attendanceController := new(controllers.AttendanceController) |
| | | { |
| | | attendanceApi.POST("getTemplate", attendanceController.GetTemplate) //获取模版列表 |
| | | attendanceApi.POST("attendanceInput", attendanceController.AttendanceInput) //考勤导入 |
| | | attendanceApi.POST("getAttendanceList", attendanceController.GetAttendanceList) //获取考勤列表 |
| | | attendanceApi.POST("updateAttendance", attendanceController.UpdateAttendance) //更新考勤 |