作者 陈志颖

fix:个人任务统计增加公司限定

... ... @@ -9,6 +9,7 @@ import (
type PersonTaskStatisticsCommand struct {
// 统一用户UID
Uid int64 `json:"uid" valid:"Required"`
CompanyId int `json:"companyId" valid:"Required"`
}
func (personTaskStatisticsCommand *PersonTaskStatisticsCommand) ValidateCommand() error {
... ...
... ... @@ -148,7 +148,7 @@ func (statisticsService *StatisticsService) PersonTaskStatistics(personTaskStati
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业员工")
}
if personTaskStatistics, err := taskDao.CalculatePersonTask(personTaskStatisticsCommand.Uid); err != nil {
if personTaskStatistics, err := taskDao.CalculatePersonTask(personTaskStatisticsCommand.Uid, personTaskStatisticsCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ...
... ... @@ -177,7 +177,7 @@ func (dao *TaskDao) CalculateSystemTask(companyId int64) (map[string]interface{}
}, nil
}
func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, error) {
func (dao *TaskDao) CalculatePersonTask(uid int64, companyId int) (map[string]interface{}, error) {
var underwayAsAssignedPerson int64
var unAcceptanceAsAssignedPerson int64
var completedAsAssignedPerson int64
... ... @@ -199,6 +199,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where(`task.assigned_person @> '{"uid":?}'`, uid).
Where("task.task_status = ? ", domain.TASK_STATUS_UNDERWAY).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -207,6 +208,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where(`task.assigned_person @> '{"uid":?}'`, uid).
Where("task.task_status = ? ", domain.TASK_STATUS_UNACCEPTANCE).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -215,6 +217,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where(`task.assigned_person @> '{"uid":?}'`, uid).
Where("task.task_status = ? ", domain.TASK_STATUS_COMPLETED).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -223,6 +226,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where("task.receiver_uid = ?", uid).
Where("task.task_status = ? ", domain.TASK_STATUS_UNCONFIRMED).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -231,6 +235,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where("task.receiver_uid = ?", uid).
Where("task.task_status = ? ", domain.TASK_STATUS_UNDERWAY).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -239,6 +244,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where("task.receiver_uid = ?", uid).
Where("task.task_status = ? ", domain.TASK_STATUS_UNACCEPTANCE).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -247,6 +253,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where("task.receiver_uid = ?", uid).
Where("task.task_status = ? ", domain.TASK_STATUS_COMPLETED).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -255,6 +262,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where(`task.sponsor @> '{"uid":?}'`, uid).
Where("task.task_status = ? ", domain.TASK_STATUS_UNRELEASED).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -263,6 +271,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where(`task.sponsor @> '{"uid":?}'`, uid).
Where("task.task_status = ? ", domain.TASK_STATUS_UNCLAIMED).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -271,6 +280,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where(`task.sponsor @> '{"uid":?}'`, uid).
Where("task.task_status = ? ", domain.TASK_STATUS_UNCONFIRMED).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -279,6 +289,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where(`task.sponsor @> '{"uid":?}'`, uid).
Where("task.task_status = ? ", domain.TASK_STATUS_UNDERWAY).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -287,6 +298,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where(`task.sponsor @> '{"uid":?}'`, uid).
Where("task.task_status = ? ", domain.TASK_STATUS_UNACCEPTANCE).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -295,6 +307,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where(`task.sponsor @> '{"uid":?}'`, uid).
Where("task.task_status = ? ", domain.TASK_STATUS_COMPLETED).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -303,6 +316,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).Join("JOIN bidder_infos AS bidder_info ON bidder_info.task_id = task.id").
Where(`bidder_info.bidder @> '{"uid":?}'`, uid).
Where("task.task_status = ? ", domain.TASK_STATUS_UNCLAIMED).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -311,6 +325,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where(`task.participators @> '[{"uid":?}]'`, uid).
Where("task.task_status = ? ", domain.TASK_STATUS_COMPLETED).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ... @@ -333,6 +348,7 @@ func (dao *TaskDao) CalculatePersonTask(uid int64) (map[string]interface{}, erro
if count, err := tx.Model(taskModel).
Where(`task.sponsor @> '{"uid":?}'`, uid).
Where("task.task_status = ? ", domain.TASK_STATUS_EXPIRED).
Where("task.company_id = ?", companyId).
Count(); err != nil {
return nil, err
} else {
... ...