切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
郑周
2 years ago
提交
5c7ad832b6d7685004384dcbddfc2462e0033c55
1 个父辈
38c202ce
1. 增加 里程碑日志模型
显示空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
381 行增加
和
28 行删除
pkg/application/factory/reposetory.go
pkg/application/staff_assess/command/save_assess_info.go
pkg/application/staff_assess/service/service.go
pkg/application/staff_assess/service/service_v2.go
pkg/domain/staff_assess_cache.go
pkg/domain/task_record.go
pkg/infrastructure/pg/models/task_record.go
pkg/infrastructure/repository/pg_task_record_repository.go
pkg/application/factory/reposetory.go
查看文件 @
5c7ad83
...
...
@@ -239,3 +239,11 @@ func CreateTaskIgnoreRepository(options map[string]interface{}) domain.TaskIgnor
}
return
repository
.
NewTaskIgnoreRepository
(
transactionContext
)
}
func
CreateTaskRecordRepository
(
options
map
[
string
]
interface
{})
domain
.
TaskRecordRepository
{
var
transactionContext
*
pg
.
TransactionContext
if
value
,
ok
:=
options
[
"transactionContext"
];
ok
{
transactionContext
=
value
.
(
*
pg
.
TransactionContext
)
}
return
repository
.
NewTaskRecordRepository
(
transactionContext
)
}
...
...
pkg/application/staff_assess/command/save_assess_info.go
查看文件 @
5c7ad83
...
...
@@ -4,20 +4,17 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
//保存员工填写评估内容
type
SaveAssessInfoCommand
struct
{
AssessId
int
`json:"assessId"`
//
ExecutorId
int
`json:"executorId"`
//填写人的id
CompanyId
int
`json:"companyId"`
//公司id
AssessContent
[]
domain
.
AssessContent
`json:"assessContent"`
AssessId
int
`json:"assessId" comment:"ID"`
ExecutorId
int
`json:"executorId" comment:"填写人ID"`
CompanyId
int
`json:"companyId" comment:"公司ID"`
AssessContent
[]
domain
.
AssessContent
`json:"assessContent" comment:"填写内容"`
}
//type AssessContent struct {
// Category string `json:"category"`
// Name string `json:"name"`
// Value string `json:"value"`
// Remark []RemarkText `json:"remark"`
//}
//
//type RemarkText struct {
// Title string `json:"title"`
// RemarkText string `json:"remarkText"`
//}
// SaveSelfAssessCommand 保存自评填写内容
type
SaveSelfAssessCommand
struct
{
AssessId
int
`json:"assessId" comment:"ID"`
ExecutorId
int
`json:"executorId" comment:"填写人ID"`
CompanyId
int
`json:"companyId" comment:"公司ID"`
AssessContent
[]
domain
.
AssessContent
`json:"assessContent" comment:"填写内容"`
AssessTaskStages
[]
domain
.
AssessTaskStage
`json:"assessTaskStages" comment:"里程碑内容"`
}
...
...
pkg/application/staff_assess/service/service.go
查看文件 @
5c7ad83
...
...
@@ -1119,6 +1119,135 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
},
nil
}
// SaveSelfAssess 提交自评评估内容
func
(
srv
StaffAssessServeice
)
SaveSelfAssess
(
in
*
command
.
SaveSelfAssessCommand
)
(
map
[
string
]
interface
{},
error
)
{
transactionContext
,
err
:=
factory
.
ValidateStartTransaction
(
in
)
if
err
!=
nil
{
return
nil
,
err
}
defer
func
()
{
transactionContext
.
RollbackTransaction
()
}()
assessReps
:=
factory
.
CreateStaffAssessRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
// 获取员工的评估
assessData
,
err
:=
assessReps
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
in
.
AssessId
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取员工的评估"
+
err
.
Error
())
}
// 检查截止时间
endTimeInt
:=
assessData
.
EndTime
.
Unix
()
if
endTimeInt
<
time
.
Now
()
.
Unix
()
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"当前环节已过截止时间,提交后无法修改内容"
)
}
// 检查执行人
if
assessData
.
CompanyId
!=
in
.
CompanyId
||
assessData
.
Executor
.
UserId
!=
in
.
ExecutorId
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"当前用户不是评估的执行人"
)
}
assessContentRepo
:=
factory
.
CreateStaffAssessContentRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
//待更新的评估填写信息
var
assessContentList
[]
*
domain
.
StaffAssessContent
// 已完成
_
,
assessContentList
,
err
=
assessContentRepo
.
Find
(
map
[
string
]
interface
{}{
"staffAssessId"
:
assessData
.
Id
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取项目填写内容"
+
err
.
Error
())
}
if
len
(
assessContentList
)
==
0
{
// 未完成获取评估内容
assessContentList
,
err
=
srv
.
getAssessInfoUncompletedV2
(
transactionContext
,
assessData
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取项目填写内容"
+
err
.
Error
())
}
}
// 处理提交上来的数据
paramContentMap
:=
map
[
string
]
domain
.
AssessContent
{}
for
i
,
v
:=
range
in
.
AssessContent
{
key
:=
fmt
.
Sprintf
(
"%s-%s"
,
v
.
Category
,
v
.
Name
)
paramContentMap
[
key
]
=
in
.
AssessContent
[
i
]
}
//更新的评估填写信息
for
_
,
v
:=
range
assessContentList
{
key
:=
fmt
.
Sprintf
(
"%s-%s"
,
v
.
Category
,
v
.
Name
)
item
,
ok
:=
paramContentMap
[
key
]
if
!
ok
{
continue
}
if
assessData
.
Types
==
domain
.
AssessSelf
{
// 每日自评需要检查必填项
if
v
.
Required
==
domain
.
NodeRequiredYes
&&
len
(
item
.
Value
)
==
0
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
v
.
Category
+
"-"
+
v
.
Name
+
":必填项"
)
}
}
v
.
Value
=
item
.
Value
if
len
(
item
.
Value
)
>
0
{
// 转换填入的评估值
err
=
v
.
TransformValue
()
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
v
.
Category
+
"-"
+
v
.
Name
+
":"
+
err
.
Error
())
}
}
for
ii
:=
range
v
.
Remark
{
for
_
,
vvv
:=
range
item
.
Remark
{
if
v
.
Remark
[
ii
]
.
Title
==
vvv
.
Title
{
v
.
Remark
[
ii
]
.
RemarkText
=
vvv
.
RemarkText
break
}
}
}
}
//保存信息
for
i
:=
range
assessContentList
{
_
,
err
=
assessContentRepo
.
Save
(
assessContentList
[
i
])
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"保存评估填写内容"
+
err
.
Error
())
}
}
assessData
.
Status
=
domain
.
StaffAssessCompleted
assessData
.
UpdatedAt
=
time
.
Now
()
_
,
err
=
assessReps
.
Save
(
assessData
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"保存评估任务"
+
err
.
Error
())
}
// 删除缓存
cacheRepository
:=
factory
.
CreateStaffAssessCacheRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
if
_
,
caches
,
err
:=
cacheRepository
.
Find
(
map
[
string
]
interface
{}{
"assessId"
:
assessData
.
Id
,
"limit"
:
1
});
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
else
{
for
i
:=
range
caches
{
if
err
=
cacheRepository
.
Remove
(
caches
[
i
]
.
Id
);
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
}
}
if
len
(
in
.
AssessTaskStages
)
>
0
{
tsIds
:=
make
([]
int
,
0
)
for
i
:=
range
in
.
AssessTaskStages
{
tsId
:=
in
.
AssessTaskStages
[
i
]
.
TaskStageId
if
tsId
>
0
{
tsIds
=
append
(
tsIds
,
tsId
)
}
}
}
// 里程碑记录
//taskRecordRepository := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
//taskRecordRepository.Find()
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
return
map
[
string
]
interface
{}{
"assessId"
:
assessData
.
Id
,
},
nil
}
// 获取员工的上级是谁
func
(
srv
StaffAssessServeice
)
getStaffSuper
(
transactionContext
application
.
TransactionContext
,
targetUser
domain
.
User
)
([]
*
domain
.
User
,
error
)
{
if
targetUser
.
ParentId
==
0
{
...
...
pkg/application/staff_assess/service/service_v2.go
查看文件 @
5c7ad83
...
...
@@ -957,8 +957,7 @@ func (srv StaffAssessServeice) SelectAssessInviteUserV2(param *query.SelectAsses
}
// 获取未完成的员工评估内容
func
(
srv
StaffAssessServeice
)
getAssessInfoUncompletedV2
(
transactionContext
application
.
TransactionContext
,
assess
*
domain
.
StaffAssess
)
([]
*
domain
.
StaffAssessContent
,
error
)
{
func
(
srv
StaffAssessServeice
)
getAssessInfoUncompletedV2
(
transactionContext
application
.
TransactionContext
,
assess
*
domain
.
StaffAssess
)
([]
*
domain
.
StaffAssessContent
,
error
)
{
evaluationItemRepo
:=
factory
.
CreateEvaluationItemUsedRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
...
...
pkg/domain/staff_assess_cache.go
查看文件 @
5c7ad83
...
...
@@ -7,6 +7,7 @@ type StaffAssessCache struct {
Id
int64
`json:"id,string" comment:"ID"`
AssessId
int64
`json:"assessId,string" comment:"评估项ID"`
AssessContent
[]
AssessContent
`json:"assessContent" comment:"评估项提交数据"`
AssessTaskStages
[]
AssessTaskStage
`json:"assessTaskStages" comment:"里程碑内容"`
CreatedAt
time
.
Time
`json:"createdAt" comment:"创建时间"`
UpdatedAt
time
.
Time
`json:"updatedAt" comment:"更新时间"`
DeletedAt
*
time
.
Time
`json:"deletedAt" comment:"删除时间"`
...
...
@@ -24,6 +25,15 @@ type RemarkText struct {
RemarkText
string
`json:"remarkText"`
}
type
AssessTaskStage
struct
{
Category
string
`json:"category"`
Name
string
`json:"name"`
TaskStageId
int
`json:"taskStageId" comment:"里程碑ID"`
Status
TaskStageState
`json:"status" comment:"里程碑完成情况"`
AssistLevel
int
`json:"assistLevel" comment:"上级辅导情况"`
AssistContent
string
`json:"assistContent" comment:"上级辅导内容"`
}
type
StaffAssessCacheRepository
interface
{
Save
(
param
*
StaffAssessCache
)
(
*
StaffAssessCache
,
error
)
Remove
(
id
int64
)
error
...
...
pkg/domain/task_record.go
查看文件 @
5c7ad83
...
...
@@ -2,16 +2,34 @@ package domain
import
"time"
// 任务反馈情况记录
const
(
AssistLevel1
int
=
1
// 未辅导
AssistLevel2
int
=
2
// 已辅导-辅导对里程碑无作用
AssistLevel3
int
=
3
// 已辅导-辅导对里程碑作用一般
AssistLevel4
int
=
4
// 已辅导-辅导对里程碑作用很好
)
// TaskRecord 任务反馈情况记录
type
TaskRecord
struct
{
Id
int
// id
CreatedAt
time
.
Time
//
UpdatedAt
time
.
Time
//
StaffAssessId
int
// 每日评估的id
TaskId
int
// 里程碑任务的id
Name
string
// 任务名称
Alias
string
// 任务别名
TaskLeader
TaskLeader
// 里程碑完成情况填写人
Rating
int
// 上级辅导情况
RatingContent
string
// 上级辅导内容
Id
int
`json:"id,string" comment:"ID"`
CompanyId
int
`json:"companyId,string" comment:"公司ID"`
StaffAssessId
int
`json:"staffAssessId,string" comment:"每日评估的ID"`
TaskId
int
`json:"taskId,string" comment:"里程碑任务的ID"`
TaskName
string
`json:"taskName" comment:"任务名称"`
TaskAlias
string
`json:"taskAlias" comment:"任务别名"`
TaskLeader
TaskLeader
`json:"taskLeader" comment:"任务负责人"`
AssistLevel
int
`json:"assistLevel" comment:"上级辅导情况"`
AssistContent
string
`json:"assistContent" comment:"上级辅导内容"`
TaskStages
[]
TaskStage
`json:"taskStages" comment:"里程碑列表"`
TaskStageCheck
TaskStage
`json:"taskStageCheck" comment:"提交的里程碑"`
CreatedAt
time
.
Time
`json:"createdAt" comment:"创建时间"`
UpdatedAt
time
.
Time
`json:"updatedAt" comment:"更新时间"`
DeletedAt
*
time
.
Time
`json:"deletedAt" comment:"删除时间"`
}
type
TaskRecordRepository
interface
{
Insert
(
t
*
TaskRecord
)
(
*
TaskRecord
,
error
)
Remove
(
t
*
TaskRecord
)
(
*
TaskRecord
,
error
)
FindOne
(
queryOptions
map
[
string
]
interface
{})
(
*
TaskRecord
,
error
)
Find
(
queryOptions
map
[
string
]
interface
{})
(
int
,
[]
*
TaskRecord
,
error
)
}
...
...
pkg/infrastructure/pg/models/task_record.go
0 → 100644
查看文件 @
5c7ad83
package
models
import
(
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"time"
)
// 任务阶段
type
TaskRecord
struct
{
tableName
struct
{}
`comment:"评估项目" pg:"task_record"`
Id
int
`comment:"ID" pg:"pk:id"`
CompanyId
int
`comment:"公司ID"`
StaffAssessId
int
`comment:"每日评估的ID"`
TaskId
int
`comment:"里程碑任务的ID"`
TaskName
string
`comment:"任务名称"`
TaskAlias
string
`comment:"任务别名"`
TaskLeader
domain
.
TaskLeader
`comment:"任务负责人"`
AssistLevel
int
`comment:"上级辅导情况"`
AssistContent
string
`comment:"上级辅导内容"`
TaskStages
[]
domain
.
TaskStage
`comment:"里程碑列表"`
TaskStageCheck
domain
.
TaskStage
`comment:"提交的里程碑"`
CreatedAt
time
.
Time
`comment:"创建时间"`
UpdatedAt
time
.
Time
`comment:"更新时间"`
DeletedAt
*
time
.
Time
`comment:"删除时间"`
}
...
...
pkg/infrastructure/repository/pg_task_record_repository.go
0 → 100644
查看文件 @
5c7ad83
package
repository
import
(
"errors"
"fmt"
"github.com/go-pg/pg/v10"
pgTransaction
"github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
"time"
)
type
TaskRecordRepository
struct
{
transactionContext
*
pgTransaction
.
TransactionContext
}
func
NewTaskRecordRepository
(
transactionContext
*
pgTransaction
.
TransactionContext
)
*
TaskRecordRepository
{
return
&
TaskRecordRepository
{
transactionContext
:
transactionContext
}
}
func
(
repo
*
TaskRecordRepository
)
TransformToDomain
(
m
*
models
.
TaskRecord
)
domain
.
TaskRecord
{
return
domain
.
TaskRecord
{
Id
:
m
.
Id
,
CompanyId
:
m
.
CompanyId
,
StaffAssessId
:
m
.
StaffAssessId
,
TaskId
:
m
.
TaskId
,
TaskName
:
m
.
TaskName
,
TaskAlias
:
m
.
TaskAlias
,
TaskLeader
:
m
.
TaskLeader
,
AssistLevel
:
m
.
AssistLevel
,
AssistContent
:
m
.
AssistContent
,
TaskStages
:
m
.
TaskStages
,
TaskStageCheck
:
m
.
TaskStageCheck
,
CreatedAt
:
m
.
CreatedAt
.
Local
(),
UpdatedAt
:
m
.
UpdatedAt
.
Local
(),
DeletedAt
:
m
.
DeletedAt
,
}
}
func
(
repo
*
TaskRecordRepository
)
TransformToModel
(
d
*
domain
.
TaskRecord
)
models
.
TaskRecord
{
return
models
.
TaskRecord
{
Id
:
d
.
Id
,
CompanyId
:
d
.
CompanyId
,
StaffAssessId
:
d
.
StaffAssessId
,
TaskId
:
d
.
TaskId
,
TaskName
:
d
.
TaskName
,
TaskAlias
:
d
.
TaskAlias
,
TaskLeader
:
d
.
TaskLeader
,
AssistLevel
:
d
.
AssistLevel
,
AssistContent
:
d
.
AssistContent
,
TaskStages
:
d
.
TaskStages
,
TaskStageCheck
:
d
.
TaskStageCheck
,
CreatedAt
:
d
.
CreatedAt
,
UpdatedAt
:
d
.
UpdatedAt
,
DeletedAt
:
d
.
DeletedAt
,
}
}
func
(
repo
*
TaskRecordRepository
)
nextIdentify
()
(
int64
,
error
)
{
return
utils
.
NewSnowflakeId
()
}
func
(
repo
*
TaskRecordRepository
)
Insert
(
d
*
domain
.
TaskRecord
)
(
*
domain
.
TaskRecord
,
error
)
{
var
isCreate
=
d
.
Id
==
0
if
isCreate
{
id
,
err
:=
repo
.
nextIdentify
()
if
err
!=
nil
{
return
d
,
err
}
d
.
Id
=
int
(
id
)
d
.
CreatedAt
=
time
.
Now
()
d
.
UpdatedAt
=
d
.
CreatedAt
}
else
{
d
.
UpdatedAt
=
time
.
Now
()
}
m
:=
repo
.
TransformToModel
(
d
)
tx
:=
repo
.
transactionContext
.
PgTx
var
err
error
if
isCreate
{
_
,
err
=
tx
.
Model
(
&
m
)
.
Returning
(
"id"
)
.
Insert
()
}
else
{
_
,
err
=
tx
.
Model
(
&
m
)
.
Returning
(
"id"
)
.
WherePK
()
.
Update
()
// 更新和删除必须增加条件
}
if
err
!=
nil
{
return
nil
,
err
}
d
.
Id
=
m
.
Id
return
d
,
nil
}
func
(
repo
*
TaskRecordRepository
)
Remove
(
d
*
domain
.
TaskRecord
)
(
*
domain
.
TaskRecord
,
error
)
{
tx
:=
repo
.
transactionContext
.
PgTx
nowTime
:=
time
.
Now
()
m
:=
repo
.
TransformToModel
(
d
)
m
.
DeletedAt
=
&
nowTime
if
_
,
err
:=
tx
.
Model
(
&
m
)
.
WherePK
()
.
Update
();
err
!=
nil
{
return
d
,
err
}
return
d
,
nil
}
func
(
repo
*
TaskRecordRepository
)
FindOne
(
queryOptions
map
[
string
]
interface
{})
(
*
domain
.
TaskRecord
,
error
)
{
tx
:=
repo
.
transactionContext
.
PgTx
m
:=
new
(
models
.
TaskRecord
)
query
:=
tx
.
Model
(
m
)
query
.
Where
(
"deleted_at isnull"
)
if
id
,
ok
:=
queryOptions
[
"id"
];
ok
{
query
.
Where
(
"id=?"
,
id
)
}
if
err
:=
query
.
First
();
err
!=
nil
{
if
errors
.
Is
(
err
,
pg
.
ErrNoRows
)
{
return
nil
,
fmt
.
Errorf
(
"没有此资源"
)
}
else
{
return
nil
,
err
}
}
u
:=
repo
.
TransformToDomain
(
m
)
return
&
u
,
nil
}
func
(
repo
*
TaskRecordRepository
)
Find
(
queryOptions
map
[
string
]
interface
{})
(
int
,
[]
*
domain
.
TaskRecord
,
error
)
{
tx
:=
repo
.
transactionContext
.
PgTx
var
m
[]
*
models
.
TaskRecord
query
:=
tx
.
Model
(
&
m
)
.
Where
(
"deleted_at isnull"
)
if
v
,
ok
:=
queryOptions
[
"ids"
];
ok
{
query
.
Where
(
"id in(?)"
,
pg
.
In
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"notId"
];
ok
{
query
.
Where
(
"id != ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name LIKE ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"companyId"
];
ok
{
query
.
Where
(
"company_id = ?"
,
v
)
}
//if v, ok := queryOptions["state"]; ok && v.(int) >= 0 {
// query.Where("state = ?", v)
//}
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int64
);
ok
{
query
.
Limit
(
int
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int64
);
ok
{
query
.
Offset
(
int
(
v
))
}
//// 按创建时间降序
//query.Order("created_at DESC")
count
,
err
:=
query
.
SelectAndCount
()
if
err
!=
nil
{
return
0
,
nil
,
err
}
var
arrays
[]
*
domain
.
TaskRecord
for
_
,
v
:=
range
m
{
d
:=
repo
.
TransformToDomain
(
v
)
arrays
=
append
(
arrays
,
&
d
)
}
return
count
,
arrays
,
nil
}
...
...
请
注册
或
登录
后发表评论