作者 郑周

Merge branch 'dev-zhengzhou' into dev-tangxvhui

... ... @@ -13,16 +13,31 @@ type UserAdapter struct {
type EvaluationProjectAdapter struct {
*domain.EvaluationProject
RecipientList []*UserAdapter `json:"recipientList" comment:"被评估人"`
Principal *UserAdapter `json:"principal" comment:"任务负责人"`
PmpList []*UserAdapter `json:"pmpList" comment:"项目管理员"`
}
func (adapter *EvaluationProjectAdapter) TransformRecipientAdapter(recipients []*domain.User) {
func (adapter *EvaluationProjectAdapter) TransformRecipientAdapter(recipients []*domain.User, principalId string) {
// 任务负责人ID
var principalIdInt = int64(0)
if len(principalId) > 0 {
i, err := strconv.ParseInt(principalId, 10, 64)
if err == nil {
principalIdInt = i
}
}
adapter.RecipientList = make([]*UserAdapter, 0)
for i := range recipients {
adapter.RecipientList = append(adapter.RecipientList, &UserAdapter{
ua := &UserAdapter{
Id: recipients[i].Id,
Name: recipients[i].Name,
})
}
adapter.RecipientList = append(adapter.RecipientList, ua)
if ua.Id == principalIdInt {
adapter.Principal = ua
}
}
}
... ...
... ... @@ -17,14 +17,15 @@ type UpdateProjectCommand struct {
}
type UpdateProjectTemplateCommand struct {
CompanyId int64 `cname:"公司ID" json:"companyId"`
CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"`
Id int64 `cname:"项目ID" json:"id,string" valid:"Required"`
TemplateId int64 `cname:"模板ID" json:"templateId,string"`
Recipients []string `cname:"被评估人ID" json:"recipients"`
TimeStart string `cname:"自评起始时间" json:"timeStart" valid:"Required"`
TimeEnd string `cname:"自评截止时间" json:"timeEnd" valid:"Required"`
KpiCycle int `cname:"评估周期" json:"kpiCycle" valid:"Required"`
CompanyId int64 `cname:"公司ID" json:"companyId"`
CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"`
Id int64 `cname:"项目ID" json:"id,string" valid:"Required"`
TemplateId int64 `cname:"模板ID" json:"templateId,string"`
Recipients []string `cname:"被评估人ID" json:"recipients"`
PrincipalId string `cname:"任务负责人" json:"principalId"`
TimeStart string `cname:"自评起始时间" json:"timeStart" valid:"Required"`
TimeEnd string `cname:"自评截止时间" json:"timeEnd" valid:"Required"`
KpiCycle int `cname:"评估周期" json:"kpiCycle" valid:"Required"`
}
type CheckRecipientCommand struct {
... ...
... ... @@ -218,6 +218,22 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加模板")
}
// 指标任务的项目(存在一项类型为任务指标),必须添加项目负责人
var isIndicatorTypeTask = false
outerLoop:
for i := range cycleTemplate.Template.LinkNodes {
var node = cycleTemplate.Template.LinkNodes[i]
for j := range node.NodeContents {
if node.NodeContents[j].IndicatorType == domain.IndicatorTypeTask {
isIndicatorTypeTask = true
break outerLoop
}
}
}
if isIndicatorTypeTask && len(in.PrincipalId) == 0 {
return nil, application.ThrowError(application.BUSINESS_ERROR, "请选择任务负责人")
}
start, err := time.ParseInLocation("2006-01-02 15:04:05", in.TimeStart, time.Local)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -272,6 +288,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
project.State = domain.ProjectStateWaitActive
}
project.Recipients = in.Recipients
project.PrincipalId = in.PrincipalId
project.Template = cycleTemplate.Template
// 项目起始截止时间(环节中的时间暂未分开计算)
... ... @@ -378,7 +395,7 @@ func (rs *EvaluationProjectService) Get(in *command.GetProjectCommand) (interfac
if len(project.Recipients) > 0 {
_, users, _ := userRepository.Find(map[string]interface{}{"ids": project.Recipients, "limit": len(project.Recipients)})
projectAdapter.TransformRecipientAdapter(users)
projectAdapter.TransformRecipientAdapter(users, project.PrincipalId)
}
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -767,6 +784,7 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf
project.Name = project.Name + " 副本"
project.CreatorId = in.CreatorId
project.Recipients = make([]string, 0) // 重置被评估人
project.PrincipalId = "" // 重置任务负责人
// 如果拷贝已经启用的模板,默认先设置为待启用
if project.State == domain.ProjectStateEnable || project.State == domain.ProjectStatePause {
... ...
... ... @@ -26,6 +26,7 @@ type EvaluationProject struct {
Pmp int `json:"pmp" comment:"PM角色权限"`
PmpIds []string `json:"pmpIds" comment:"项目管理员ID"`
Recipients []string `json:"recipients" comment:"被评估人ID"`
PrincipalId string `json:"principalId" comment:"任务负责人ID"`
Template *EvaluationTemplate `json:"template" comment:"评估模板"`
BeginTime time.Time `json:"beginTime" comment:"项目起始时间"`
EndTime time.Time `json:"endTime" comment:"项目截至时间"`
... ...
... ... @@ -20,6 +20,7 @@ type EvaluationProject struct {
Pmp int `comment:"PM角色权限" pg:",use_zero"`
PmpIds []string `comment:"项目管理员ID"`
Recipients []string `comment:"被评估人ID"`
PrincipalId string `comment:"任务负责人ID"`
Template *domain.EvaluationTemplate `comment:"评估模板"`
BeginTime time.Time `comment:"项目起始时间"`
EndTime time.Time `comment:"项目截至时间 "`
... ...
... ... @@ -47,6 +47,7 @@ func (repo *EvaluationProjectRepository) TransformToDomain(m *models.EvaluationP
Pmp: m.Pmp,
PmpIds: m.PmpIds,
Recipients: m.Recipients,
PrincipalId: m.PrincipalId,
Template: m.Template,
BeginTime: m.BeginTime,
EndTime: m.EndTime,
... ... @@ -70,6 +71,7 @@ func (repo *EvaluationProjectRepository) TransformToModel(d *domain.EvaluationPr
Pmp: d.Pmp,
PmpIds: d.PmpIds,
Recipients: d.Recipients,
PrincipalId: d.PrincipalId,
Template: d.Template,
BeginTime: d.BeginTime,
EndTime: d.EndTime,
... ...
-- 增加指标分类字段, 默认0
ALTER TABLE public.evaluation_item_used ADD indicator_type int4 NOT NULL DEFAULT 0;
COMMENT ON COLUMN public.evaluation_item_used.indicator_type IS '指标类型';
-- 增加项目表-任务负责人ID
ALTER TABLE public.evaluation_project ADD principal_id text NULL;
COMMENT ON COLUMN public.evaluation_project.principal_id IS '任务负责人ID';
\ No newline at end of file
... ...