package oa_logic import ( "context" "dubbo.apache.org/dubbo-go/v3/common/logger" "errors" "fmt" "github.com/fonchain_enterprise/fonchain-main/api/oa" "github.com/fonchain_enterprise/fonchain-main/pkg/e" "github.com/fonchain_enterprise/fonchain-main/pkg/model/oa_model" "github.com/fonchain_enterprise/fonchain-main/pkg/service" "github.com/fonchain_enterprise/fonchain-main/pkg/service/oa_new/common" "github.com/fonchain_enterprise/fonchain-main/pkg/utils/holiday" ) // QueryOaApplyMonth 按月获取oa审批记录 func QueryOaApplyMonth(staffUID uint64, month string, applyStatus []int32, applyType []string) (oaApplys []*oa.OAApply, err error) { fmt.Println("================ StaffCollectionDetail QueryOaApplyMonth enter =======================") oaApplyReq := new(oa.ApplyRecordReq) if month == "" { month = holiday.CurrentMonth() } month = common.Add25ForMonth(month) dates := holiday.SplitMonthV1(month, common.YYMMDD) // 查询 全部审批类型 oaApplyReq.StaffUID = staffUID oaApplyReq.BeginTime = dates[0] oaApplyReq.EndTime = dates[len(dates)-1] oaApplyReq.Page = 1 oaApplyReq.PageSize = 999999 oaApplyReq.ApplyStatus = applyStatus if applyType != nil || len(applyType) > 0 { oaApplyReq.ApplyType = applyType } //fmt.Println("================ StaffCollectionDetail QueryOaApplyMonth oaApplyReq enter =======================") //fmt.Printf("staffUID %v dates %v applyStatus %v applyType %v\n", staffUID, dates, applyStatus, applyType) //fmt.Printf("oaApplyReq: %v\n", oaApplyReq) //fmt.Println("================ StaffCollectionDetail QueryOaApplyMonth oaApplyReq out =======================") // 获取申请记录 oaApplyRes, oaApplyErr := service.GrpcOAImpl.QueryOaApply(context.Background(), oaApplyReq) if oaApplyErr != nil { logger.Errorf("查询申请记录失败:%s", oaApplyErr.Error()) return nil, errors.New(e.ErrQueryOaApply) } if oaApplyRes.Total == 0 { logger.Errorf("未查询申请记录:%s", "oaApplyRes.Data is nil") return nil, nil } else { fmt.Println("================ StaffCollectionDetail QueryOaApplyMonth QueryOaApply enter =======================") fmt.Printf("QueryOaApply res is : %v\n", oaApplyRes.Data) fmt.Println("================ StaffCollectionDetail QueryOaApplyMonth QueryOaApply out =======================") } fmt.Println("================ StaffCollectionDetail QueryOaApplyMonth out =======================") return oaApplyRes.Data, nil } // QueryOaApplyDates 按日期获取oa审批记录 func QueryOaApplyDates(staffUID uint64, dates []string, applyStatus []int32, applyType []string) (oaApplys []*oa.OAApply, err error) { fmt.Println("================ StaffCollectionDetail QueryOaApplyDates WorkDayMonth enter =======================") fmt.Printf("staffUID %v dates %v applyStatus %v applyType %v\n", staffUID, dates, applyStatus, applyType) oaApplyReq := new(oa.ApplyRecordReq) // 查询 全部审批类型 oaApplyReq.StaffUID = staffUID oaApplyReq.BeginTime = dates[0] oaApplyReq.EndTime = dates[len(dates)-1] oaApplyReq.Page = 1 oaApplyReq.PageSize = 999999 oaApplyReq.ApplyStatus = applyStatus if applyType != nil { oaApplyReq.ApplyType = applyType } fmt.Printf("================ enter 1 %+v======================= \n", applyType) // 获取申请记录 oaApplyRes, oaApplyErr := service.GrpcOAImpl.QueryOaApply(context.Background(), oaApplyReq) fmt.Printf("================ enter 2 %+v======================= \n", applyType) //fmt.Println("================ StaffCollectionDetail QueryOaApplyDates WorkDayMonth out =======================") //fmt.Printf("oaApplyRes.Data: %v\n", oaApplyRes.Data) //fmt.Printf("oaApplyErr: %v\n", oaApplyErr.Error()) if oaApplyErr != nil { logger.Errorf("查询申请记录失败:%s", oaApplyErr.Error()) return nil, errors.New(e.ErrQueryOaApply) } if oaApplyRes.Data == nil || len(oaApplyRes.Data) == 0 { logger.Errorf("未查询申请记录:%s", "oaApplyRes.Data is nil") fmt.Printf("未查询申请记录:%s\n", "oaApplyRes.Data is nil") return nil, nil } fmt.Printf("================ enter 3 %+v======================= \n", applyType) //fmt.Println("================ StaffCollectionDetail QueryOaApplyDates WorkDayMonth out =======================") //fmt.Printf("oaApplyRes.Data: %v\n", oaApplyRes.Data) return oaApplyRes.Data, nil } // QueryOaApplyDatesSpecial 按日期获取oa审批记录 注 外勤申请 查询的 条件为 审批提交即可查询 func QueryOaApplyDatesSpecial(staffUID uint64, dates []string, applyStatus []int32, applyType []string) (oaApplys []*oa.OAApply, err error) { oaApplys = make([]*oa.OAApply, 0) fmt.Println("================ StaffCollectionDetail QueryOaApplyDates WorkDayMonth enter =======================") fmt.Printf("staffUID %v dates %v applyStatus %v applyType %v\n", staffUID, dates, applyStatus, applyType) oaApplyReq := new(oa.ApplyRecordReq) // 查询 全部审批类型 oaApplyReq.StaffUID = staffUID oaApplyReq.BeginTime = dates[0] oaApplyReq.EndTime = dates[len(dates)-1] oaApplyReq.Page = 1 oaApplyReq.PageSize = 999999 oaApplyReq.ApplyStatus = applyStatus if applyType != nil { oaApplyReq.ApplyType = applyType } else { oaApplyReq.ApplyType = append(oaApplyReq.ApplyType, []string{ oa_model.TypeLeave, oa_model.TypeSick, oa_model.TypeDayOff, oa_model.TypeAnnualLeave, oa_model.TypeMaritalLeave, oa_model.TypeMatingCheckLeave, oa_model.TypeMaternityLeave, oa_model.TypePaternityLeave, oa_model.TypeParentalLeave, oa_model.TypeNursingLeave, oa_model.TypeFuneralLeave, oa_model.TypeAbortLeave, oa_model.TypeMakeUp, oa_model.TypeOverTime, oa_model.TypeOutWork, oa_model.TypeGoOut, oa_model.TypeBusinessTrip, oa_model.TypeBreastFeedingLeave, }...) } fmt.Printf("================ enter 1 %+v======================= \n", oaApplyReq) // 获取申请记录 oaApplyRes, oaApplyErr := service.GrpcOAImpl.QueryOaApply(context.Background(), oaApplyReq) fmt.Printf("================ enter 2 %+v======================= \n", oaApplyReq) fmt.Println("================ StaffCollectionDetail QueryOaApplyDates WorkDayMonth out =======================") //fmt.Printf("oaApplyRes.Data: %v\n", oaApplyRes.Data) //fmt.Printf("oaApplyErr: %v\n", oaApplyErr.Error()) if oaApplyErr != nil { logger.Errorf("查询申请记录失败:%s", oaApplyErr.Error()) return nil, errors.New(e.ErrQueryOaApply) } if oaApplyRes.Data != nil { oaApplys = append(oaApplys, oaApplyRes.Data...) fmt.Printf("================ enter 3 %+v======================= \n", oaApplyReq) fmt.Println("================ StaffCollectionDetail QueryOaApplyDates WorkDayMonth out =======================") //fmt.Printf("oaApplyRes.Data: %v\n", oaApplyRes.Data) } // 查询 外勤审批 状态为 审批中的 oaApplyReq.ApplyStatus = append(oaApplyReq.ApplyStatus, e.ApprovalWorkStatusDoing) oaApplyReq.ApplyType = []string{oa_model.TypeOutWork} // 获取 外勤 申请记录 状态为 审批中的 outWorkApplyRes, outWorkApplyErr := service.GrpcOAImpl.QueryOaApply(context.Background(), oaApplyReq) if outWorkApplyErr != nil { logger.Errorf("查询申请记录失败:%s", outWorkApplyErr.Error()) return nil, errors.New(e.ErrQueryOaApply) } if outWorkApplyRes.Data != nil { oaApplys = append(oaApplys, outWorkApplyRes.Data...) fmt.Printf("================ enter 4 %+v======================= \n", oaApplyReq) fmt.Println("================ StaffCollectionDetail QueryOaApplyDates WorkDayMonth out =======================") //fmt.Printf("oaApplyRes.Data: %v\n", outWorkApplyRes.Data) } return oaApplys, nil }