...
|
...
|
@@ -384,46 +384,6 @@ func (statisticsService *StatisticsService) EmployeesContributionsStatistics(emp |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 员工排行榜统计 (弃用)
|
|
|
//func (statisticsService *StatisticsService) EmployeesRankingListStatistics(employeesRankingListStatisticsCommand *command.EmployeesRankingListStatisticsCommand) (interface{}, error) {
|
|
|
// if err := employeesRankingListStatisticsCommand.ValidateCommand(); err != nil {
|
|
|
// return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
// }
|
|
|
// transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// if err := transactionContext.StartTransaction(); err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// defer func() {
|
|
|
// transactionContext.RollbackTransaction()
|
|
|
// }()
|
|
|
//
|
|
|
// var employeeDao *dao.EmployeeDao
|
|
|
// if value, err := factory.CreateEmployeeDao(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// }); err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// } else {
|
|
|
// employeeDao = value
|
|
|
// }
|
|
|
//
|
|
|
// if employeesRankingListStatisticsCommand.StartTime.IsZero() && employeesRankingListStatisticsCommand.EndTime.IsZero() {
|
|
|
// employeesRankingListStatisticsCommand.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())
|
|
|
// employeesRankingListStatisticsCommand.EndTime = time.Now().Local()
|
|
|
// }
|
|
|
//
|
|
|
// if employeesRankingListStatistics, err := employeeDao.CalculateEmployeesRankingList(employeesRankingListStatisticsCommand.CompanyId, employeesRankingListStatisticsCommand.StartTime, employeesRankingListStatisticsCommand.EndTime, employeesRankingListStatisticsCommand.Offset, employeesRankingListStatisticsCommand.Limit); err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// } else {
|
|
|
// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// return employeesRankingListStatistics, nil
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
// 贡献值、财富值榜单
|
|
|
func (statisticsService *StatisticsService) ContributionsWealthRanking(contributionsWealthRankingQuery *query.ContributionsWealthRankingQuery) (interface{}, error) {
|
|
|
if err := contributionsWealthRankingQuery.ValidateQuery(); err != nil {
|
...
|
...
|
@@ -449,8 +409,10 @@ func (statisticsService *StatisticsService) ContributionsWealthRanking(contribut |
|
|
employeeDao = value
|
|
|
}
|
|
|
|
|
|
// 返回年榜开始时间、结束时间
|
|
|
if contributionsWealthRankingQuery.RankingType == 2 {
|
|
|
if contributionsWealthRankingQuery.RankingType == 1 { // 返回总榜
|
|
|
contributionsWealthRankingQuery.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())
|
|
|
contributionsWealthRankingQuery.EndTime = time.Now()
|
|
|
} else if contributionsWealthRankingQuery.RankingType == 2 { // 返回年榜
|
|
|
// 获取公司最新年榜
|
|
|
var listIntervalRepository domain.ListIntervalRepository
|
|
|
if value, err := factory.CreateListIntervalRepository(map[string]interface{}{
|
...
|
...
|
@@ -470,22 +432,36 @@ func (statisticsService *StatisticsService) ContributionsWealthRanking(contribut |
|
|
if _, listIntervals, err := listIntervalRepository.Find(listListIntervalQuery); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if len(listIntervals) == 0 {
|
|
|
contributionsWealthRankingQuery.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())
|
|
|
contributionsWealthRankingQuery.EndTime = time.Now()
|
|
|
} else {
|
|
|
contributionsWealthRankingQuery.StartTime = listIntervals[0].IntervalStartTime
|
|
|
contributionsWealthRankingQuery.EndTime = listIntervals[0].IntervalEndTime
|
|
|
if len(listIntervals) == 0 { // 未配置年榜
|
|
|
contributionsWealthRankingQuery.StartTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
|
|
|
contributionsWealthRankingQuery.EndTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
|
|
|
} else if len(listIntervals) == 1 { // 只配置了一个年榜
|
|
|
currentTime := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
|
|
|
if currentTime.Before(listIntervals[0].IntervalStartTime) && currentTime.After(listIntervals[0].IntervalEndTime) || currentTime.Equal(listIntervals[0].IntervalStartTime) || currentTime.Equal(listIntervals[0].IntervalEndTime) { // 当前时间在榜单内
|
|
|
contributionsWealthRankingQuery.StartTime = listIntervals[0].IntervalStartTime
|
|
|
contributionsWealthRankingQuery.EndTime = listIntervals[0].IntervalEndTime
|
|
|
} else { // 当前时间处于空档期
|
|
|
contributionsWealthRankingQuery.StartTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
|
|
|
contributionsWealthRankingQuery.EndTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
|
|
|
}
|
|
|
} else { // 配置了多个年榜
|
|
|
// 判断当前时间是否在榜单里
|
|
|
currentTime := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
|
|
|
for _, listInterval := range listIntervals {
|
|
|
if currentTime.Before(listInterval.IntervalStartTime) && currentTime.After(listInterval.IntervalEndTime) || currentTime.Equal(listInterval.IntervalStartTime) || currentTime.Equal(listInterval.IntervalEndTime) { // 当前时间在榜单内
|
|
|
contributionsWealthRankingQuery.StartTime = listInterval.IntervalStartTime
|
|
|
contributionsWealthRankingQuery.EndTime = listInterval.IntervalEndTime
|
|
|
break
|
|
|
} else { // 当前时间处于空档期
|
|
|
contributionsWealthRankingQuery.StartTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
|
|
|
contributionsWealthRankingQuery.EndTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 返回总榜
|
|
|
if contributionsWealthRankingQuery.RankingType == 1 {
|
|
|
contributionsWealthRankingQuery.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())
|
|
|
contributionsWealthRankingQuery.EndTime = time.Now()
|
|
|
}
|
|
|
|
|
|
// 默认返回总榜
|
|
|
if contributionsWealthRankingStatistics, err := employeeDao.ContributionsWealthRanking(tool_funs.SimpleStructToMap(contributionsWealthRankingQuery)); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
|