作者 tangxvhui

Merge branch '1.3.2-bug' into test

package adapter
// 列包含表周期和项目信息
type CycleAndProjctListAdapter struct {
CycleId string `json:"cycleId"` //周期id
CycleName string `json:"cycleName"` //
ProjectId string `json:"projectId"` //项目id
ProjectName string `json:"projectName"`
TargetUserId string `json:"targetUserId"`
}
... ...
package command
// type QueryEvaluationInfo struct {
// CycleId int `json:"cycleId,string"` //周期id
// ExecutorId int `json:"executorId,string"` //执行人id
// CompanyId int `json:"-"` //公司id
// }
type QueryEvaluation struct {
CycleId int `json:"cycleId,string"` //周期id
TargetUserId int `json:"targetUserId,string"` //员工id
... ... @@ -46,3 +40,11 @@ type QueryEvaluationSuper struct {
UserId int `json:"-"`
Advanced int `json:"advanced"`
}
// QueryEvaluationSelf 获取周期自评小结详情
type QueryEvaluationSelf struct {
CycleId int `json:"cycleId,string"` //周期id
TargetUserId int `json:"targetUserId,string"` //员工id
ProjectId int `json:"projectId,string"` //项目id
CompanyId int `json:"-"` //公司id
}
... ...
package service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
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/application/summary_evaluation/adapter"
"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"
)
func getPermission(companyId int64) (*domain.Permission, error) {
... ... @@ -16,3 +24,165 @@ func getPermission(companyId int64) (*domain.Permission, error) {
}
return permissionData, nil
}
// ListCycleAndProject
// 自评小结列表,自评评估列表
func (srv *SummaryEvaluationService) ListCycleAndProject(param *command.QueryCycleList) (map[string]interface{}, 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()
}()
limit := 600
offset := 0
if param.PageSize > 0 {
limit = param.PageSize
}
if param.PageNumber > 0 {
offset = (param.PageNumber - 1) * param.PageSize
}
assessDao := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
projectList, err := assessDao.ListCycleAndProject(param.UserId, param.CompanyId, limit, offset)
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())
}
cycleList := []adapter.CycleAndProjctListAdapter{}
for _, v := range projectList {
m := adapter.CycleAndProjctListAdapter{
CycleId: v.CycleId,
CycleName: v.CycleName,
ProjectId: v.EvaluationProjectId,
ProjectName: v.EvaluationProjectName,
TargetUserId: v.TargetUserId,
}
cycleList = append(cycleList, m)
}
return tool_funs.SimpleWrapGridMap(int64(len(projectList)), cycleList), nil
}
// 周期综合自评小结详情
func (srv *SummaryEvaluationService) CountEvaluationSelfLevelV2(param *command.QueryEvaluationSelf) (*adapter.EvaluationInfoCountCodeAdapter, 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()
}()
//统计周期内,评估项等级的数量
assessDao := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"limit": 1,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"types": domain.EvaluationSelf,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluationList) == 0 {
return &adapter.EvaluationInfoCountCodeAdapter{}, nil
}
evaluationData := evaluationList[0]
levelCodeCountList, err := assessDao.CountAssessContentLevelCode(param.ProjectId, param.TargetUserId, domain.AssessSelf, param.CycleId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": param.ProjectId,
"nodeType": int(domain.LinkNodeSelfAssessment),
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{
"summaryEvaluationId": evaluationData.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 获取组装基本信息
evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationData)
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
evaluationItems := srv.buildSummaryItemValue(itemList, itemValues)
levelCodeMap := map[int][]adapter.LevalCodeCount{}
for _, v := range evaluationItems {
codes := v.Rule.GetLevelCodes()
levelCode := []adapter.LevalCodeCount{}
for _, v2 := range codes {
levelCode = append(levelCode, adapter.LevalCodeCount{
Code: v2,
Number: 0,
})
}
levelCodeMap[v.EvaluationItemId] = levelCode
}
levelCodeCountMap := map[string]int{}
for _, v := range levelCodeCountList {
key := fmt.Sprintf("%s-%s-%s", v.Category, v.Name, v.LevelValue)
levelCodeCountMap[key] = v.Cnt
}
evaluationItemCount := []adapter.EvaluationItemCountCodeAdapter{}
for i := range evaluationItems {
itemCount := adapter.EvaluationItemCountCodeAdapter{
EvaluationItemAdapter: evaluationItems[i],
LevelCount: []adapter.LevalCodeCount{},
}
evaluationItemCount = append(evaluationItemCount, itemCount)
itemId := evaluationItems[i].EvaluationItemId
levelCodes, ok := levelCodeMap[itemId]
if !ok {
continue
}
evaluationItemCount[i].LevelCount = levelCodes
for i2 := range levelCodes {
key := fmt.Sprintf("%s-%s-%s",
evaluationItems[i].Category,
evaluationItems[i].Name,
levelCodes[i2].Code,
)
if mVal, ok := levelCodeCountMap[key]; ok {
levelCodes[i2].Number = mVal
}
}
}
evaluationInfo := adapter.EvaluationInfoCountCodeAdapter{
EvaluationBaseAdapter: evaluationBase,
EvaluationItems: evaluationItemCount,
}
return &evaluationInfo, nil
}
... ...
... ... @@ -64,10 +64,12 @@ func checkTaskRecord(param *domain.TaskRecord) error {
taskData := taskDataList[0]
if param.AnomalyState != domain.AnomalyState1 {
taskData.Anomaly += 1
}
if param.CanTaskAnomaly() {
} else {
taskData.Anomaly = 0
}
// if param.CanTaskAnomaly() {
// taskData.Anomaly = 0
// }
err = taskRepo.Save(taskData)
if err != nil {
return fmt.Errorf("保存任务数据:%s", err)
... ...
package domain
import (
"strings"
"time"
)
... ... @@ -46,13 +45,13 @@ type TaskRecordRepository interface {
}
// 是否取消任务的里程碑反馈异常记录
func (record *TaskRecord) CanTaskAnomaly() bool {
trimSpace := strings.TrimLeft(record.AssistContent, "\n") // 去掉前换行符
trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符
// 上级填写内容有值,选项是已辅导,变为正常
if !(len(trimSpace) == 0 || trimSpace == "无") && record.AssistLevel != AssistLevel1 {
return true
}
return false
}
// func (record *TaskRecord) CanTaskAnomaly() bool {
// trimSpace := strings.TrimLeft(record.AssistContent, "\n") // 去掉前换行符
// trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
// trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符
// // 上级填写内容有值,选项是已辅导,变为正常
// if !(len(trimSpace) == 0 || trimSpace == "无") && record.AssistLevel != AssistLevel1 {
// return true
// }
// return false
// }
... ...
... ... @@ -2,6 +2,7 @@ package dao
import (
"fmt"
"strconv"
"github.com/go-pg/pg/v10"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
... ... @@ -429,3 +430,33 @@ func (d *StaffAssessDao) CountUserSelfStaffAssess(param SearchConditin3) (int, e
_, err := tx.Query(pg.Scan(&result), sqlStr2, condition...)
return result, err
}
type CycleAndProjectItem struct {
CycleId string `pg:"cycle_id"`
CycleName string `pg:"cycle_name"`
EvaluationProjectId string `pg:"evaluation_project_id"`
EvaluationProjectName string `pg:"evaluation_project_name"`
TargetUserId string `pg:"target_user_id"`
}
// 获取某个人的自评的周期和项目
func (d *StaffAssessDao) ListCycleAndProject(userId int, companyId int, offset int, limit int) (result []CycleAndProjectItem, err error) {
sqlStr := `select
distinct
staff_assess.cycle_id ,
staff_assess.cycle_name ,
staff_assess.evaluation_project_id ,
staff_assess.evaluation_project_name ,
target_user->>'userId' as target_user_id
from staff_assess
where 1=1
and company_id=?
and target_user->>'userId'=?
and "types"='self'
order by cycle_id desc
limit ? offset ? `
tx := d.transactionContext.PgTx
condition := []interface{}{companyId, strconv.Itoa(userId), limit, offset}
_, err = tx.Query(&result, sqlStr, condition...)
return result, err
}
... ...
... ... @@ -117,6 +117,22 @@ func (c *SummaryEvaluationController) CountEvaluationSelfLevel() {
c.Response(data, err)
}
// CountEvaluationSelfLevelV2 获取自评小结
func (c *SummaryEvaluationController) CountEvaluationSelfLevelV2() {
srv := service.NewSummaryEvaluationService()
paramReq := &command.QueryEvaluationSelf{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.CountEvaluationSelfLevelV2(paramReq)
c.Response(data, err)
}
func (c *SummaryEvaluationController) Evaluation360List() {
srv := service.NewSummaryEvaluationService()
in := &command.QueryEvaluation360List{}
... ... @@ -422,3 +438,20 @@ func (c *SummaryEvaluationController) ModifyFinishScore() {
err = srv.ModifyFinishScore(param)
c.Response(nil, err)
}
// 获取周期和项目列表
func (c *SummaryEvaluationController) ListCycleAndProject() {
srv := service.NewSummaryEvaluationService()
param := &command.QueryCycleList{}
err := c.BindJSON(param)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
param.UserId = int(userReq.UserId)
param.CompanyId = int(userReq.CompanyId)
data, err := srv.ListCycleAndProject(param)
c.Response(data, err)
}
... ...
... ... @@ -30,15 +30,17 @@ func init() {
web.NSCtrlPost("/evaluation-super/list", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSuper),
web.NSCtrlPost("/evaluation-super/confirm", (*controllers.SummaryEvaluationController).ConfirmScoreEvaluation),
web.NSCtrlPost("/evaluation-result", (*controllers.SummaryEvaluationController).GetTargetEvaluationResult),
//web.NSCtrlPost("/target_user/evaluation-super", (*controllers.SummaryEvaluationController).GetTargetEvaluationResult),
// web.NSCtrlPost("/evaluation-super/all", (*controllers.SummaryEvaluationController).ListAllEvaluationSuper),
web.NSCtrlPost("/evaluation-finish/all", (*controllers.SummaryEvaluationController).ListAllEvaluationFinish),
web.NSCtrlPost("/evaluation-finish/modify-score", (*controllers.SummaryEvaluationController).ModifyFinishScore),
// web.NSCtrlPost("/evaluation-super/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationSuper),
web.NSCtrlPost("/evaluation-finish/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationFinish),
web.NSCtrlGet("/evaluation-self/now", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSelf),
//
web.NSCtrlPost("/staff_assess/self/remark", (*controllers.SummaryEvaluationController).SearchAssessRemark),
)
web.AddNamespace(summaryNS)
summaryV2 := web.NewNamespace("/v2/summary-evaluation",
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevelV2),
web.NSCtrlPost("/cycle_project/list", (*controllers.SummaryEvaluationController).ListCycleAndProject),
)
web.AddNamespace(summaryV2)
}
... ...