作者 tangxvhui

Merge branch 'test'

package notify
import "testing"
func TestXxx(t *testing.T) {
err := appMessageSend()
if err != nil {
t.Error(err)
}
}
... ...
package notify
import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 执行定时任务检查是否发送短信通知
var taskSmsNotify *notifySms
... ... @@ -11,6 +14,7 @@ func RunTaskSmsNotify() {
taskSmsNotify.init()
taskSmsNotify.regist(notifyStaffAssess{})
taskSmsNotify.regist(notifySummaryEvaluation{})
taskSmsNotify.regist(notifyConfirmEvaluationScore{})
taskSmsNotify.runTask()
}
... ... @@ -27,3 +31,33 @@ func AddNotifySummaryEvaluation(param *domain.SummaryEvaluation) {
newSms := newNotify.makeNotify(param)
taskSmsNotify.addTask(newSms)
}
// 确认周期评估短信提醒 ,预创建待发送的短信消息
func AddNotifyConfirmEvaluationScore(param *domain.SummaryEvaluation) error {
newNotify := notifyConfirmEvaluationScore{}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return err
}
if err := transactionContext.StartTransaction(); err != nil {
return err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
logSmsRepo := factory.CreateLogSmsRepository(map[string]interface{}{"transactionContext": transactionContext})
cnt, _, err := logSmsRepo.Find(map[string]interface{}{"from": newNotify.from(), "index": param.Id, "limit": 1})
if err != nil {
return err
}
if cnt > 0 {
return nil
}
if err := transactionContext.CommitTransaction(); err != nil {
return err
}
newSms := newNotify.makeNotify(param)
return taskSmsNotify.addTask(newSms)
}
... ...
... ... @@ -36,17 +36,22 @@ func (notices *notifySms) regist(ifsend notifySendOrNot) {
notices.sendOrNot[ifsend.from()] = ifsend
}
func (notices *notifySms) addTask(task *domain.LogSms) {
func (notices *notifySms) addTask(task *domain.LogSms) error {
// notices.newSms <- task
err := notices.addNewSms(task)
if err != nil {
e := fmt.Sprintf("添加短信通知任务:%+v %s", task, err)
log.Logger.Error(e)
return fmt.Errorf("添加短信通知任务:%s", err)
}
return nil
}
// RunTask 执行短信通知任务
func (notices *notifySms) runTask() {
if constant.Env != "prd" {
return
}
timer := time.NewTimer(notices.interval)
for {
select {
... ... @@ -108,8 +113,9 @@ func (notices *notifySms) checkSendSms() error {
nowDay := dayZeroTime(nowTime)
_, logSmsList, err := logSmsRepo.Find(map[string]interface{}{
"status": string(domain.SmsWait),
"executeAtBegin": nowDay,
"executeAtEnd": nowTime,
"executeAtBegin": nowDay,
"limit": 1000,
})
if err != nil {
return err
... ... @@ -130,9 +136,7 @@ func (notices *notifySms) checkSendSms() error {
// sendSms 发送短信消息
func (notices *notifySms) sendSms(param *domain.LogSms) error {
if constant.Env != "prd" {
return nil
}
//单开处理 数据保存操作,发一条短信更新一条数据
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -151,6 +155,7 @@ func (notices *notifySms) sendSms(param *domain.LogSms) error {
if ok {
ok, err := sendOrNot.ifSend(param.Index)
if err != nil {
log.Logger.Error("检查短信是否发送" + err.Error())
param.Result = err.Error()
}
sendOk = ok
... ... @@ -163,6 +168,7 @@ func (notices *notifySms) sendSms(param *domain.LogSms) error {
sms := serviceGateway.SmsService{}
err = sms.SendNoticeSms(param.Phone, param.TemplateId, param.Value)
if err != nil {
log.Logger.Error("短信发送出错" + err.Error())
param.Result = err.Error()
param.Status = domain.SmsSuccess
} else {
... ...
package notify
import (
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 短信提醒确认周期评估成绩
// 条件:上级提交评估后 到10号晚23:59前,对未确认的被评估人每隔6个小时进行提醒(23:00-7:00期间不提醒),直到确认
type notifyConfirmEvaluationScore struct {
}
var _ notifySendOrNot = (*notifyConfirmEvaluationScore)(nil)
func (notices notifyConfirmEvaluationScore) from() string {
return "ConfirmEvaluationScore"
}
func (notices notifyConfirmEvaluationScore) makeNotify(param *domain.SummaryEvaluation) *domain.LogSms {
newSms := domain.LogSms{
Id: 0,
Phone: param.Executor.Account,
TemplateId: 5634326,
Template: "您好,#name#,#periodName#成绩已出,请前往绩效系统PC端进行确认哦,超时未确认可能会影响当月绩效工资哦~ ",
Value: map[string]string{
"name": param.Executor.UserName,
"periodName": param.CycleName,
},
Result: "",
Status: domain.SmsWait,
From: notices.from(),
Index: param.Id,
ExecuteAt: notices.getTimeExecuteAt(time.Now()),
CreatedAt: time.Now(),
}
return &newSms
}
// 适配规则:上级提交评估后 到10号晚23:59前,可以发送
// 适配规则 对未确认的被评估人每隔6个小时进行提醒(23:00-7:00期间不提醒),直到确认
func (notices notifyConfirmEvaluationScore) ifSend(index int) (bool, error) {
//检查时间
nowTime := time.Now()
if nowTime.Day() > 10 {
return false, nil
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return false, err
}
if err := transactionContext.StartTransaction(); err != nil {
return false, err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
summaryEvaluationData, err := summaryEvaluationRepo.FindOne(map[string]interface{}{"id": index})
if err != nil {
return false, err
}
if summaryEvaluationData.Types == domain.EvaluationFinish {
return false, nil
}
//已确认 成绩,不在发送成绩
if summaryEvaluationData.CheckResult == domain.EvaluationCheckCompleted {
return false, nil
}
//检查数据 SummaryEvaluation ,types=5,并添加短信数据
//计算下一条短信
smsMessage := notices.makeNotify(summaryEvaluationData)
nextTime := nowTime.Add(6 * time.Hour)
smsMessage.ExecuteAt = notices.getTimeExecuteAt(nextTime)
logSmsRepo := factory.CreateLogSmsRepository(map[string]interface{}{"transactionContext": transactionContext})
err = logSmsRepo.Save(smsMessage)
if err != nil {
return true, err
}
if err := transactionContext.CommitTransaction(); err != nil {
return false, err
}
return true, nil
}
// 输入的时间为基础微调短信的执行时间
// 适配规则 :每隔6个小时进行提醒(23:00-7:00期间不提醒)
func (notices notifyConfirmEvaluationScore) getTimeExecuteAt(nowTime time.Time) time.Time {
nowHour := nowTime.Local().Hour()
if nowHour < 23 && nowHour >= 7 {
return nowTime
}
t1 := nowTime.Add(6 * time.Hour)
hour1 := t1.Local().Hour()
if hour1 < 23 && hour1 >= 7 {
return t1
}
return t1.Add(6 * time.Hour)
}
... ...
... ... @@ -11,6 +11,8 @@ import (
type notifyStaffAssess struct {
}
var _ notifySendOrNot = (*notifyStaffAssess)(nil)
func (notices notifyStaffAssess) from() string {
return "StaffAssess"
}
... ...
... ... @@ -12,6 +12,8 @@ import (
type notifySummaryEvaluation struct {
}
var _ notifySendOrNot = (*notifySummaryEvaluation)(nil)
func (notices notifySummaryEvaluation) from() string {
return "SummaryEvaluation"
}
... ...
... ... @@ -205,7 +205,10 @@ func (e *exportData3) FormatListValue(param []dao.DataStaffAssessContent2) {
e.data[key] = &strings.Builder{}
e.data[key].WriteString(val.Value + "\n") //填写的等级
for _, vv := range val.Remark {
vv.Title = strings.TrimSpace(vv.Title)
if vv.Title != "填写自评反馈" {
e.data[key].WriteString(vv.Title + "\n")
}
e.data[key].WriteString(vv.RemarkText + "\n")
}
dayKey := val.TargetUserId + val.EvaluationProjectId + val.BeginDay
... ...
... ... @@ -174,7 +174,10 @@ func (e *exportData2) setData(param []dao.ExportData1) {
e.data[key] = &strings.Builder{}
e.data[key].WriteString(v.Value + "\n")
for _, v2 := range v.Remark {
v2.Title = strings.TrimSpace(v2.Title)
if v2.Title != "填写自评反馈" {
e.data[key].WriteString(v2.Title + "\n")
}
e.data[key].WriteString(v2.RemarkText + "\n")
}
}
... ...
... ... @@ -7,6 +7,7 @@ type EvaluationSuperListAdapter struct {
EvaluationStatus string `json:"evaluationStatus"` //上级评估完成状态
EndTime string `json:"endTime"` //截止时间
TotalScoreSelf string `json:"totalScoreSelf"` //综合自评总分
TotalScoreSuper string `json:"totalScoreSuper"` //综合自评总分
Department string `json:"department"` //部门
Position string `json:"position"` //职位
EntryTime string `json:"entryTime"` //入职时间
... ...
... ... @@ -50,18 +50,18 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu
positionRepo := factory.CreatePositionRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
limit := param.PageSize
offset := (param.PageNumber - 1) * param.PageSize
// limit := param.PageSize
// offset := (param.PageNumber - 1) * param.PageSize
//获取评估列表信息
condition1 := map[string]interface{}{
"cycleId": param.CycleId,
"types": int(domain.EvaluationFinish),
"limit": limit,
}
if offset > 0 {
condition1["offset"] = offset
"limit": 5000,
}
// if offset > 0 {
// condition1["offset"] = offset
// }
if len(param.TargetUserName) > 0 {
condition1["targetUserName"] = "%" + param.TargetUserName + "%"
}
... ... @@ -147,6 +147,8 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu
firstSheetName := xlsxFile.GetSheetName(sheetIndex)
tableHead := []string{"姓名", "部门", "职位", "最终绩效得分"}
tableHead = append(tableHead, ratingHeader...)
// 最后一列
tableHead = append(tableHead, "备注")
if len(evaluationList) > 0 {
xlsxFile.SetSheetRow(firstSheetName, "A1", &[]string{evaluationList[0].CycleName + "最终成绩"})
if len(tableHead) > 1 {
... ... @@ -171,7 +173,7 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu
}
}
}
dataRaw := []string{
dataRow := []string{
v.TargetUser.UserName,
departmentName,
positinName,
... ... @@ -179,12 +181,18 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu
}
for _, v2 := range ratingHeader {
if num, ok := evaluationRatingMap[v.Id][v2]; ok {
dataRaw = append(dataRaw, fmt.Sprintf("%d", num))
dataRow = append(dataRow, fmt.Sprintf("%d", num))
} else {
dataRaw = append(dataRaw, "0")
dataRow = append(dataRow, "0")
}
}
if v.CheckResult == domain.EvaluationCheckCompleted {
dataRow = append(dataRow, "已确认")
} else {
dataRow = append(dataRow, "未确认")
}
xlsxFile.SetSheetRow(firstSheetName, fmt.Sprintf("A%d", i+firstDataRow), &dataRaw)
//最后一列
xlsxFile.SetSheetRow(firstSheetName, fmt.Sprintf("A%d", i+firstDataRow), &dataRow)
}
return xlsxFile, nil
}
... ...
... ... @@ -10,6 +10,7 @@ import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify"
roleService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
... ... @@ -647,7 +648,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain.
if len(evaluationList) == 0 {
//没有上级评估、360评估、hrbp 评估
//直接进入考核结果阶段
_, evaluationList, err = evaluationRepo.Find(map[string]interface{}{
_, evaluationFinishList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": param.TargetUser.UserId,
"typesList": []int{int(domain.EvaluationFinish)},
"cycleId": param.CycleId,
... ... @@ -656,12 +657,14 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain.
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluationList) > 0 {
if len(evaluationFinishList) > 0 {
//进入考核结果
//自评的结束时间
evaluationList[0].BeginTime = param.EndTime
evaluationList[0].Status = domain.EvaluationCompleted
err = evaluationRepo.Save(evaluationList[0])
if evaluationFinishList[0].BeginTime.After(nowTime) {
evaluationFinishList[0].BeginTime = nowTime
}
evaluationFinishList[0].Status = domain.EvaluationCompleted
err = evaluationRepo.Save(evaluationFinishList[0])
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
}
... ... @@ -746,7 +749,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma
if len(evaluationList) == 0 {
//没有上级评估
//直接进入考核结果阶段
_, evaluationList, err = evaluationRepo.Find(map[string]interface{}{
_, evaluationFinishList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": param.TargetUser.UserId,
"typesList": []int{int(domain.EvaluationFinish)},
"cycleId": param.CycleId,
... ... @@ -755,11 +758,12 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluationList) > 0 {
//360评估的结束时间
evaluationList[0].BeginTime = param.EndTime
evaluationList[0].Status = domain.EvaluationCompleted
err = evaluationRepo.Save(evaluationList[0])
if len(evaluationFinishList) > 0 {
if evaluationFinishList[0].BeginTime.After(nowTime) {
evaluationFinishList[0].BeginTime = nowTime
}
evaluationFinishList[0].Status = domain.EvaluationCompleted
err = evaluationRepo.Save(evaluationFinishList[0])
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
}
... ... @@ -810,16 +814,26 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain
if len(evaluationList) > 0 {
//上级评估的结束时间
evaluationList[0].BeginTime = param.EndTime
// evaluationList[0].BeginTime = param.EndTime
nowTime := time.Now()
if evaluationList[0].BeginTime.After(nowTime) {
evaluationList[0].BeginTime = nowTime
}
evaluationList[0].Status = domain.EvaluationCompleted
err = evaluationRepo.Save(evaluationList[0])
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//添加确认绩效成绩提醒短信提醒
err = notify.AddNotifyConfirmEvaluationScore(param)
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, "创建短信提醒失败"+err.Error())
}
return nil
}
... ... @@ -907,7 +921,7 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluationList) == 0 {
return nil, nil
return &adapter.EvaluationInfoCountCodeAdapter{}, nil
}
evaluationData := evaluationList[0]
levelCodeCountList, err := assessDao.CountAssessContentLevelCode(evaluationData.EvaluationProjectId, param.TargetUserId, domain.AssessSelf, param.CycleId)
... ... @@ -1007,22 +1021,21 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
// permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
// 获取权限配置
// _, 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, err
}
evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
"id": param.SummaryEvaluationId,
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"id": []int{param.SummaryEvaluationId},
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluationList) == 0 {
return &adapter.EvaluationInfoSuperAdapter{}, nil
}
evaluationData := evaluationList[0]
if evaluationData.Types != domain.EvaluationSuper {
return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
}
... ... @@ -1113,10 +1126,22 @@ func (srv *SummaryEvaluationService) GetEvaluationSuperForAdmin(param *command.Q
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
// evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"id": []int{param.SummaryEvaluationId},
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluationList) == 0 {
return &adapter.EvaluationInfoSuperAdapter{}, nil
}
evaluationData := evaluationList[0]
if evaluationData.CompanyId != param.CompanyId {
return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
}
... ... @@ -1568,6 +1593,7 @@ func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command.
Department: "",
Position: "",
EntryTime: "",
TotalScoreSuper: v.TotalScore,
}
for _, dep := range v.TargetDepartment {
item.Department += dep.DepartmentName + " "
... ... @@ -1705,10 +1731,12 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi
for i := range itemList {
result.ResetTotalRating(itemList[i])
}
//存在 超级管理员直接修改填写 总分的情况,此时不重新计算总分
if result.TotalScore == "0" || result.TotalScore == "" {
if err := result.EvaluationTotalScore(itemValues); err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
result.CheckResult = domain.EvaluationCheckCompleted
if err := evaluationRepo.Save(result); err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -1791,9 +1819,6 @@ func (srv *SummaryEvaluationService) GetTargetEvaluationResult(param *command.Qu
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()
}()
... ... @@ -1823,10 +1848,12 @@ func (srv *SummaryEvaluationService) GetTargetEvaluationResult(param *command.Qu
continue
}
}
// if result == nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有找到符合条件的数据")
// }
if result == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有找到符合条件的数据")
return &adapter.EvaluationInfoSuperAdapter{}, nil
}
// 评估内容和值
var itemList []*domain.EvaluationItemUsed
var itemValues []*domain.SummaryEvaluationValue
... ... @@ -1879,10 +1906,13 @@ func (srv *SummaryEvaluationService) GetTargetEvaluationResult(param *command.Qu
for i := range itemList {
result.ResetTotalRating(itemList[i])
}
//存在 超级管理员直接修改填写 总分的情况,此时不重新计算总分
if result.TotalScore == "0" || result.TotalScore == "" {
if err = result.EvaluationTotalScore(itemValues); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
}
// 基础数据
evaluationBase := srv.getSummaryEvaluation(transactionContext, result)
... ...
... ... @@ -371,6 +371,20 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
}
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": summaryEvaluation.TargetUser.UserId,
"typesList": []int{int(domain.EvaluationFinish)},
"cycleId": summaryEvaluation.CycleId,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 如果目标员工已经确认考核结果,就不能在进行评估编辑
if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能在编辑!")
}
// 自评评估内容(自评模板、筛选项目评估人)
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{
"evaluationProjectId": summaryEvaluation.EvaluationProjectId,
... ... @@ -757,6 +771,20 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
}
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": summaryEvaluation.TargetUser.UserId,
"typesList": []int{int(domain.EvaluationFinish)},
"cycleId": summaryEvaluation.CycleId,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 如果目标员工已经确认考核结果,就不能在进行评估编辑
if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能在编辑!")
}
// 自评评估内容(自评模板、筛选项目评估人)
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{
"evaluationProjectId": summaryEvaluation.EvaluationProjectId,
... ... @@ -871,3 +899,31 @@ func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFini
}
return nil
}
// GetUnconfirmedCycleList 获取未确认绩效成绩的周期列表
func (srv *SummaryEvaluationService) GetUnconfirmedCycleList(companyId int, userId int) (map[string]interface{}, error) {
transactionContext, err := factory.StartTransaction()
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{"transactionContext": transactionContext})
cycles, err := evaluationDao.TargetUnconfirmedCycleList(companyId, userId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取周期列表"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var cycleList []adapter.CycleListAdapter
for _, v := range cycles {
cycleList = append(cycleList, adapter.CycleListAdapter{
CycleId: v.CycleId,
CycleName: v.CycleName,
})
}
return tool_funs.SimpleWrapGridMap(int64(len(cycleList)), cycleList), nil
}
... ...
... ... @@ -50,6 +50,7 @@ const (
type EvaluationStatus string
const (
// EvaluationEditTotalScore EvaluationStatus = "completed_by_edit_score" //通过超级管理员直接修改分数完成的
EvaluationUncompleted EvaluationStatus = "uncompleted" //未提交填写的内容
EvaluationCompleted EvaluationStatus = "completed" //已提交填写的内容
)
... ...
... ... @@ -110,7 +110,7 @@ and staff_assess.evaluation_project_id in (
sqlStr += ` and staff_assess.target_user->>'userId' in(?) `
condition = append(condition, pg.In(exportUserIds))
}
sqlStr = withSql + sqlStr
sqlStr = withSql + sqlStr + " order by evaluation_item_used.sort_by "
result := []DataEvaluationItemUsed2{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr, condition...)
... ...
package dao
import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"time"
"github.com/go-pg/pg/v10"
... ... @@ -138,6 +139,28 @@ func (d *SummaryEvaluationDao) CountTargetUserCycleList(executorId int, evaluati
return cnt, err
}
// TargetUnconfirmedCycleList 用户【未确认绩效成绩】的周期列表
func (d *SummaryEvaluationDao) TargetUnconfirmedCycleList(companyId int, executorId int) ([]TargetUserCycle, error) {
sqlStr := `select
summary_evaluation.cycle_id,
summary_evaluation.begin_time,
summary_evaluation.cycle_name
from summary_evaluation
where summary_evaluation.deleted_at isnull
and summary_evaluation.company_id='?'
and summary_evaluation.target_user ->>'userId'='?'
and summary_evaluation.types='?'
and summary_evaluation.status=?
and summary_evaluation.check_result=?
`
tx := d.transactionContext.PgTx
condition := []interface{}{companyId, executorId, domain.EvaluationFinish, domain.EvaluationCompleted, domain.EvaluationCheckUncompleted}
sqlStr += ` order by summary_evaluation.begin_time desc;`
result := make([]TargetUserCycle, 0)
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
func (d *SummaryEvaluationDao) UpdateBeginTime(ids []int, beginTime time.Time) error {
if len(ids) == 0 {
return nil
... ...
... ... @@ -291,8 +291,8 @@ func (d *TaskDao) CountTaskAnomalyNotHrbp(param ListTaskCondition) (int, error)
from task
join t_task_1 on task.id =t_task_1.id
where 1=1
and task.anomaly>0 and task.deleted_at isnull `
condition := []interface{}{}
and task.anomaly>0 and company_id=? and task.deleted_at isnull `
condition := []interface{}{param.CompanyId}
whereSql := ``
if param.OnlyMy {
condition = append(condition, param.UserId)
... ... @@ -317,7 +317,7 @@ func (d *TaskDao) CountTaskAnomalyByHrbp(param ListTaskCondition) (int, error) {
)select count(*)
from task
left join t_task_ignore on t_task_ignore.task_id=task.id
where 1=1 and task.anomaly>0 and task.company_id=? and task.deleted_at isnull`
where 1=1 and task.anomaly>0 and task.company_id=? and t_task_ignore.id isnull and task.deleted_at isnull`
condition := []interface{}{param.UserId, param.CompanyId}
whereSql := ``
if param.OnlyMy {
... ...
... ... @@ -68,7 +68,12 @@ func (repo *LogSmsRepository) Find(queryOptions map[string]interface{}) (int, []
if v, ok := queryOptions["executeAtEnd"]; ok {
query.Where("execute_at<=?", v)
}
if v, ok := queryOptions["from"]; ok {
query.Where(`"from"=?`, v)
}
if v, ok := queryOptions["index"]; ok {
query.Where("index=?", v)
}
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...
... ... @@ -5,9 +5,18 @@ import "testing"
func TestPushInfo(t *testing.T) {
//测试消息推送
c := NewHttplibMmmOpenApiServiceGateway()
resp, err := c.PushInfo(0, "mmm.ability.performance", []int64{3422174102828544}, "ceshi推送一个消息233", "消息内容xxxx332")
//3436890424617728
//3422173870118400
resp, err := c.PushInfo(0, "mmm.ability.performance", []int64{3422173870118400}, "ceshi推送一个消息233", "消息内容xxxx332")
if err != nil {
t.Error(err)
}
t.Logf("%v", resp)
}
func TestSms(t *testing.T) {
c := SmsService{}
err := c.SendNoticeSms("18060823798", 5475050, map[string]string{
"name": "名字1"})
t.Log(err)
}
... ...
... ... @@ -28,6 +28,13 @@ func (c *SummaryEvaluationController) GetExecutorCycleList() {
c.Response(data, err)
}
func (c *SummaryEvaluationController) GetUnconfirmedScoreCycleList() {
srv := service.NewSummaryEvaluationService()
userReq := middlewares.GetUser(c.Ctx)
data, err := srv.GetUnconfirmedCycleList(int(userReq.CompanyId), int(userReq.UserId))
c.Response(data, err)
}
func (c *SummaryEvaluationController) GetMenu() {
srv := service.NewSummaryEvaluationService()
paramReq := &command.QueryMenu{}
... ... @@ -332,7 +339,6 @@ func (c *SummaryEvaluationController) GetTargetEvaluationResult() {
c.Response(data, err)
}
// 按周期获取上级评估列表
func (c *SummaryEvaluationController) ListAllEvaluationFinish() {
srv := service.NewSummaryEvaluationService()
param := &command.QueryEvaluationList{}
... ...
... ... @@ -33,7 +33,7 @@ func init() {
web.NSCtrlPut("/info-cache", (*controllers.StaffAssessController).SaveAssessCache), //通用保存员工评估的详情(缓存)
web.NSCtrlPost("/summary", (*controllers.StaffAssessController).QuerySummary), //员工绩效-项目管理-总览
web.NSCtrlPost("/summary/users", (*controllers.StaffAssessController).QueryMemberSummary), //员工绩效-综合管理-成员列表
web.NSCtrlPost("/summary/users-indicator", (*controllers.StaffAssessController).QueryMemberPerformanceIndicator), //员工绩效-综合管理-绩效导出指标
web.NSCtrlPost("/summary/users-indicator", (*controllers.StaffAssessController).QueryMemberPerformanceIndicator), //员工绩效-综合管理-绩效指标
web.NSCtrlPost("/summary/export-indicator", (*controllers.StaffAssessController).ExportPerformanceIndicator), //员工绩效-综合管理-绩效导出指标
web.NSCtrlPost("/target_user/self/cycle", (*controllers.StaffAssessController).ListTargetUserSelfCycle), //获取员工自评的周期下拉列表
web.NSCtrlPost("/target_user/self/summary", (*controllers.StaffAssessController).GetStaffAsessSelfCountLevel), //获取员工每日自评小结
... ...
... ... @@ -11,6 +11,7 @@ func init() {
summaryNS := web.NewNamespace("/v1/summary-evaluation",
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
web.NSCtrlPost("/executor/cycle/list", (*controllers.SummaryEvaluationController).GetExecutorCycleList),
web.NSCtrlPost("/executor/cycle/unconfirmed-score", (*controllers.SummaryEvaluationController).GetUnconfirmedScoreCycleList),
web.NSCtrlPost("/target_user/cycle/list", (*controllers.SummaryEvaluationController).GetTargetUserCycleList),
web.NSCtrlPost("/cycle/menu", (*controllers.SummaryEvaluationController).GetMenu),
web.NSCtrlPost("/evaluation-self", (*controllers.SummaryEvaluationController).GetEvaluationSelf),
... ...