作者 tangxvhui

调整 公司的权限配置项

... ... @@ -17,7 +17,7 @@ import (
func main() {
startNodeTask()
startSummaryEvaluation()
// startConfirmEvaluationScore()
startConfirmEvaluationScore()
go notify.RunTaskSmsNotify()
go consumer.Run()
web.Run()
... ...
... ... @@ -7,6 +7,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
)
... ... @@ -18,30 +19,38 @@ func TaskConfirmScore() error {
str := fmt.Sprintf("自动确认周期评估考核结果耗时%.2f s", time.Since(nowTime).Seconds())
log.Logger.Info(str)
}()
for {
evaluationList, err := catchEvaluation()
evaluationList, err := catchEvaluation()
if err != nil {
log.Logger.Error(fmt.Sprintf("获取周期考核结果%s", err.Error()))
}
if len(evaluationList) == 0 {
return nil
}
evluationSrv := NewSummaryEvaluationService()
for _, val := range evaluationList {
permissionData, err := getPermission(val.CompanyId)
if err != nil {
log.Logger.Error(fmt.Sprintf("获取周期考核结果%s", err.Error()))
log.Logger.Error(fmt.Sprintf("获取公司的权限配置失败%s", err.Error()))
}
if len(evaluationList) == 0 {
return nil
if permissionData.OptConfirmPerf != domain.PermissionOn {
continue
}
evluationSrv := NewSummaryEvaluationService()
for _, val := range evaluationList {
targetUserId, err := strconv.Atoi(val.TargetUserId)
if err != nil {
log.Logger.Error(fmt.Sprintf("获取员工id%s", err))
continue
}
err = evluationSrv.ConfirmScoreEvaluation(&command.ConfirmScore{
SummaryEvaluationId: val.SummaryEvaluationId,
UserId: targetUserId,
})
if err != nil {
log.Logger.Error(fmt.Sprintf("确认周期考核结果%s", err.Error()))
}
targetUserId, err := strconv.Atoi(val.TargetUserId)
if err != nil {
log.Logger.Error(fmt.Sprintf("获取员工id%s", err))
continue
}
err = evluationSrv.ConfirmScoreEvaluation(&command.ConfirmScore{
SummaryEvaluationId: val.SummaryEvaluationId,
UserId: targetUserId,
})
if err != nil {
log.Logger.Error(fmt.Sprintf("确认周期考核结果%s", err.Error()))
}
}
return nil
}
func catchEvaluation() ([]dao.SummaryEvaluationData1, error) {
... ...
... ... @@ -1015,11 +1015,15 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
// permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
// 获取权限配置
_, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": param.CompanyId})
// _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": param.CompanyId})
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
permissinData, err := getPermission(int64(param.CompanyId))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return nil, err
}
evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
"id": param.SummaryEvaluationId,
... ... @@ -1078,15 +1082,13 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval
//组合 评估填写的值和评估项
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
for i, v := range itemValuesAdapter {
if len(permissionList) > 0 {
if permissionList[0].OptEvalScore == domain.PermissionOff &&
v.EvaluatorId > 0 {
itemValuesAdapter[i].ForbidEdit = true
}
if permissionList[0].OptHrScore == domain.PermissionOff &&
v.EvaluatorId < 0 {
itemValuesAdapter[i].ForbidEdit = true
}
if permissinData.OptEvalScore == domain.PermissionOff &&
v.EvaluatorId > 0 {
itemValuesAdapter[i].ForbidEdit = true
}
if permissinData.OptHrScore == domain.PermissionOff &&
v.EvaluatorId < 0 {
itemValuesAdapter[i].ForbidEdit = true
}
}
result := adapter.EvaluationInfoSuperAdapter{
... ... @@ -1214,16 +1216,19 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC
"transactionContext": transactionContext,
})
permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
// 获取权限配置
_, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": evaluationData.CompanyId})
// permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
// // 获取权限配置
// _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": evaluationData.CompanyId})
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
// if len(permissionList) == 0 {
// return nil, nil
// }
permissionData, err := getPermission(int64(evaluationData.CompanyId))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(permissionList) == 0 {
return nil, nil
}
permissionData := permissionList[0]
if permissionData.OptEvalScore == domain.PermissionOn && permissionData.OptHrScore == domain.PermissionOn {
return nil, nil
}
... ...
package service
import (
permissionSrv "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission"
permissionCmd "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
func getPermission(companyId int64) (*domain.Permission, error) {
srv := &permissionSrv.PermissionService{}
permissionData, err := srv.Get(&permissionCmd.GetPermissionCommand{
CompanyId: companyId,
})
if err != nil {
return nil, err
}
return permissionData, nil
}
... ...
... ... @@ -155,6 +155,7 @@ func (d *SummaryEvaluationDao) UpdateBeginTime(ids []int, beginTime time.Time) e
type SummaryEvaluationData1 struct {
SummaryEvaluationId int `pg:"summary_evaluation_id"`
TargetUserId string `pg:"target_user_id"`
CompanyId int64 `pg:"company_id"`
}
// 查询周期考核结果
... ... @@ -162,14 +163,15 @@ type SummaryEvaluationData1 struct {
func (d *SummaryEvaluationDao) ListEvaluationFinishNoResult() ([]SummaryEvaluationData1, error) {
sqlStr := `select
summary_evaluation.id as summary_evaluation_id,
summary_evaluation.target_user ->>'userName' as target_user_name
summary_evaluation.target_user ->>'userName' as target_user_name,
summary_evaluation.company_id
from summary_evaluation
where 1=1
and summary_evaluation."types" = 5
and summary_evaluation.status ='completed'
and summary_evaluation.check_result ='uncompleted'
and summary_evaluation.end_time <=now()
limit 10`
`
result := []SummaryEvaluationData1{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr)
... ...