12345678910111213141516171819202122232425262728293031323334353637383940 |
- // Copyright 2019 github.com. All rights reserved.
- // Use of this source code is governed by github.com.
- package staff
- import (
- "context"
- "github.com/jaryhe/gopkgs/database"
- "github.com/jaryhe/gopkgs/logger"
- "go.uber.org/zap"
- "smart-site-management/errors"
- "smart-site-management/model"
- "smart-site-management/pb/v1"
- )
- func LaborCompanyStatistics(ctx context.Context, req *v1.LaborCompanyStatisticsRequest) (reply *v1.LaborCompanyStatisticsReply, err error) {
- reply = &v1.LaborCompanyStatisticsReply{}
- if req.ProjectId == 0 {
- return nil,errors.ParamsError
- }
- list, err := model.StaffCompanyStaticList(database.DB(), req.ProjectId)
- if err != nil {
- logger.Error("StaffCompanyStaticList",
- zap.String("err", err.Error()))
- return nil, errors.DataBaseError
- }
- reply.List = make([]*v1.LaborCompanyStatistics, len(list))
- for i, v := range list{
- item := &v1.LaborCompanyStatistics{
- LaborCompany:v.CompanyName,
- Total:int64(v.StaffCount),
- Attendance:int64(v.StaffAttendanceCount),
- LaborAttendance: int64(v.StaffAttendanceLabor),
- ManagerAttendance:int64(v.StaffAttendanceCount - v.StaffAttendanceLabor),
- }
- reply.List[i] = item
- }
- return reply, nil
- }
|