| | |
| | | "silkserver/models" |
| | | "silkserver/pkg/logx" |
| | | "silkserver/pkg/timex" |
| | | "strings" |
| | | "time" |
| | | ) |
| | | |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, "参数不能为空") |
| | | return |
| | | } |
| | | //获取月份天数 |
| | | location, err := time.ParseInLocation("2006-01", "2024-04", time.Local) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "月份格式错误") |
| | | return |
| | | } |
| | | 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 { |
| | | util.ResponseFormat(c, code.RequestParamError, err) |
| | | return |
| | | } |
| | | |
| | | m := make(map[string]response.AttendanceStatistic) |
| | | for _, manage := range manages { |
| | | var as response.AttendanceStatistic |
| | |
| | | as.WorkerName = manage.WorkerName |
| | | as.WorkType = manage.WorkType.WorkName |
| | | as.Month = params.Month |
| | | as.Details = details |
| | | } |
| | | as.WeekdayOverTime = as.WeekdayOverTime.Add(manage.OverTimeDuration) |
| | | as.ActualAttendanceDays = as.ActualAttendanceDays + 1 |
| | | var ad response.AttendanceDetail |
| | | ad.Date = strings.ReplaceAll(manage.Date, params.Month+"-", "") |
| | | ad.Status = manage.Status |
| | | as.Details = append(as.Details, ad) |
| | | time2, _ := timex.StringToTime2(manage.Date) |
| | | day := time2.Day() |
| | | as.Details[day-1].Status = manage.Status |
| | | |
| | | m[manage.WorkerId] = as |
| | | } |
| | |
| | | type GetWorkshopManage struct { |
| | | PageInfo |
| | | KeyWord string `json:"keyWord"` |
| | | WorkshopName string `json:"workshopName"` //车间名称 |
| | | GroupNumber int `json:"groupNumber"` //组别 |
| | | } |
| | | |
| | | type GetWorkshopManageCar struct { |
| | |
| | | } |
| | | |
| | | type AttendanceDetail struct { |
| | | Date string `json:"date"` //日期 |
| | | Date int `json:"date"` //日期 |
| | | Status constvar.AttendanceStatus `json:"status"` //状态 |
| | | } |
| | |
| | | // @Param Authorization header string true "token" |
| | | // @Param object query request.GetPriceStandard true "参数" |
| | | // @Success 200 {object} util.ResponseList{data=[]models.WorkshopManage} "成功" |
| | | // @Router /api-jl/v1/system/getWorkshopManageList [get] |
| | | // @Router /api-jl/v1/system/getWorkshopManageList [post] |
| | | func (slf WorkshopManageController) GetWorkshopManageList(c *gin.Context) { |
| | | var param request.GetWorkshopManage |
| | | err := c.ShouldBindQuery(¶m) |
| | | err := c.BindJSON(¶m) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | | } |
| | | list, total, err := models.NewWorkshopManageSearch().SetPage(param.Page, param.PageSize).Find() |
| | | list, total, err := models.NewWorkshopManageSearch().SetWorkshopName(param.WorkshopName).SetGroupNumber(param.GroupNumber).SetPage(param.Page, param.PageSize).Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.SelectError, "查询失败") |
| | | return |
| | |
| | | } |
| | | }, |
| | | "/api-jl/v1/system/getWorkshopManageList": { |
| | | "get": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | |
| | | "properties": { |
| | | "date": { |
| | | "description": "日期", |
| | | "type": "string" |
| | | "type": "integer" |
| | | }, |
| | | "status": { |
| | | "description": "状态", |
| | |
| | | } |
| | | }, |
| | | "/api-jl/v1/system/getWorkshopManageList": { |
| | | "get": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | |
| | | "properties": { |
| | | "date": { |
| | | "description": "日期", |
| | | "type": "string" |
| | | "type": "integer" |
| | | }, |
| | | "status": { |
| | | "description": "状态", |
| | |
| | | properties: |
| | | date: |
| | | description: 日期 |
| | | type: string |
| | | type: integer |
| | | status: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.AttendanceStatus' |
| | |
| | | tags: |
| | | - 系统设置/车间管理 |
| | | /api-jl/v1/system/getWorkshopManageList: |
| | | get: |
| | | post: |
| | | parameters: |
| | | - description: token |
| | | in: header |
| | |
| | | func GetCurrentTime() string { |
| | | return time.Now().Format(timeLayout) |
| | | } |
| | | |
| | | func GetDate(year int, month time.Month) int { |
| | | day := 0 |
| | | if month == time.February { |
| | | if (year%4 == 0 && year%100 != 0) || year%400 == 0 { |
| | | day = 29 |
| | | } else { |
| | | day = 28 |
| | | } |
| | | } else { |
| | | if month == time.January || month == time.March || month == time.May || month == time.July || |
| | | month == time.August || month == time.October || month == time.December { |
| | | day = 31 |
| | | } else { |
| | | day = 30 |
| | | } |
| | | } |
| | | return day |
| | | } |
| | |
| | | systemApi.GET("getRankStandardGrade", rawSilkController.GetRankStandardGrade) //获取生丝等级 |
| | | systemApi.POST("saveRankStandard", rawSilkController.SaveRankStandard) //保存生丝定级标准 |
| | | //车间管理 |
| | | systemApi.GET("getWorkshopManageList", workshopController.GetWorkshopManageList) //获取车间管理列表 |
| | | systemApi.POST("getWorkshopManageList", workshopController.GetWorkshopManageList) //获取车间管理列表 |
| | | systemApi.POST("saveWorkshopManage", workshopController.SaveWorkshopManage) //保存车间管理 |
| | | systemApi.DELETE("deleteWorkshopManage/:id", workshopController.DeleteWorkshopManage) //删除车间管理 |
| | | systemApi.GET("getWorkshopManageGroup/:number", workshopController.GetWorkshopManageGroup) //获取车间组别 |