作者 郑周

1. 增加暂停和恢复

@@ -3,6 +3,7 @@ package service @@ -3,6 +3,7 @@ package service
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "strconv" 5 "strconv"
  6 + "strings"
6 "time" 7 "time"
7 8
8 "github.com/linmadan/egglib-go/core/application" 9 "github.com/linmadan/egglib-go/core/application"
@@ -170,7 +171,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp @@ -170,7 +171,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
170 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 171 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
171 } 172 }
172 // 项目调整截止时间,同步更新任务时间 173 // 项目调整截止时间,同步更新任务时间
173 - if err := rs.updateTaskTime(transactionContext, in.Id, end); err != nil { 174 + if err := rs.updateTaskTime(transactionContext, in.Id, &end); err != nil {
174 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 175 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
175 } 176 }
176 177
@@ -179,31 +180,35 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp @@ -179,31 +180,35 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
179 } 180 }
180 return project, nil 181 return project, nil
181 } else { 182 } else {
182 - _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "template")  
183 - if err != nil {  
184 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
185 - }  
186 - // 周期内的所有项目,员工不能重复被评估  
187 - rids := map[string]bool{}  
188 - for i := range projects {  
189 - // 排除当前项目  
190 - if in.Id != projects[i].Id {  
191 - ids := projects[i].Recipients  
192 - for j := range ids {  
193 - rids[ids[j]] = true  
194 - }  
195 - }  
196 - }  
197 - repeatNum := 0  
198 - for i := range in.Recipients {  
199 - id := in.Recipients[i]  
200 - if _, ok := rids[id]; ok {  
201 - repeatNum++  
202 - }  
203 - }  
204 - if repeatNum > 0 {  
205 - return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("有%d人已经在本周期其他项目内,需要将他们移除", repeatNum))  
206 - } 183 + //_, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "template")
  184 + //if err != nil {
  185 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  186 + //}
  187 + //// 周期内的所有项目,员工不能重复被评估
  188 + //rids := map[string]bool{}
  189 + //for i := range projects {
  190 + // it := projects[i]
  191 + // // 排除当前项目
  192 + // if in.Id == it.Id {
  193 + // continue
  194 + // }
  195 + // // 启用状态
  196 + // if it.State == domain.ProjectStateEnable {
  197 + // for j := range it.Recipients {
  198 + // rids[it.Recipients[j]] = true
  199 + // }
  200 + // }
  201 + //}
  202 + //repeatNum := 0
  203 + //for i := range in.Recipients {
  204 + // id := in.Recipients[i]
  205 + // if _, ok := rids[id]; ok {
  206 + // repeatNum++
  207 + // }
  208 + //}
  209 + //if repeatNum > 0 {
  210 + // return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("有%d人已经在本周期其他项目内,需要将他们移除", repeatNum))
  211 + //}
207 212
208 cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId, "includeDeleted": true}) 213 cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId, "includeDeleted": true})
209 if err != nil { 214 if err != nil {
@@ -237,6 +242,32 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp @@ -237,6 +242,32 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
237 return nil, application.ThrowError(application.BUSINESS_ERROR, "评估截至时间不能超出周期截至时间") 242 return nil, application.ThrowError(application.BUSINESS_ERROR, "评估截至时间不能超出周期截至时间")
238 } 243 }
239 244
  245 + // 判断起始时间,是否有被评估人的任务
  246 + assessTaskRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
  247 + _, assessTasks, err := assessTaskRepository.Find(map[string]interface{}{
  248 + "companyId": in.CompanyId,
  249 + "cycleId": in.CycleId,
  250 + "beginDay": start.Format("2006-01-02"),
  251 + })
  252 +
  253 + rids := map[int]int{}
  254 + for i1 := range assessTasks {
  255 + it := assessTasks[i1]
  256 + for i2 := range it.ExecutorId {
  257 + rids[it.ExecutorId[i2]] = 0
  258 + }
  259 + }
  260 + for i := range in.Recipients {
  261 + id := in.Recipients[i]
  262 + id2, _ := strconv.Atoi(id)
  263 + if _, ok := rids[id2]; ok {
  264 + year, month, day := start.Date()
  265 + start0 := time.Date(year, month, day, 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻
  266 + today := start0.Add(24 * time.Hour).Format("2006-01-02 15:04:05")
  267 + return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("当前时间已有正在进行的项目,请将项目开始时间设置至 %s 之后", today))
  268 + }
  269 + }
  270 +
240 if project.State == domain.ProjectStateWaitConfig { 271 if project.State == domain.ProjectStateWaitConfig {
241 project.State = domain.ProjectStateWaitActive 272 project.State = domain.ProjectStateWaitActive
242 } 273 }
@@ -264,7 +295,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp @@ -264,7 +295,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
264 } 295 }
265 296
266 // 更新项目截止时间,同步任务截止时间 297 // 更新项目截止时间,同步任务截止时间
267 -func (rs *EvaluationProjectService) updateTaskTime(context application.TransactionContext, projectId int64, end time.Time) error { 298 +func (rs *EvaluationProjectService) updateTaskTime(context application.TransactionContext, projectId int64, end *time.Time) error {
268 // 查看任务过程,重新日计算任务截至期 299 // 查看任务过程,重新日计算任务截至期
269 taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": context}) 300 taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": context})
270 tasks, err := taskRepository.Find(map[string]interface{}{"projectId": projectId}) 301 tasks, err := taskRepository.Find(map[string]interface{}{"projectId": projectId})
@@ -278,7 +309,10 @@ func (rs *EvaluationProjectService) updateTaskTime(context application.Transacti @@ -278,7 +309,10 @@ func (rs *EvaluationProjectService) updateTaskTime(context application.Transacti
278 309
279 for i := range tasks { 310 for i := range tasks {
280 task := tasks[i] 311 task := tasks[i]
281 - task.TimeEnd = &end // 先赋值 312 +
  313 + if end != nil {
  314 + task.TimeEnd = end // 先赋值
  315 + }
282 316
283 if task.NextSentAt == nil { // 重新计算 317 if task.NextSentAt == nil { // 重新计算
284 // 环节起始和截止本地时间 318 // 环节起始和截止本地时间
@@ -424,10 +458,14 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter @@ -424,10 +458,14 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter
424 pmpUserIds = append(pmpUserIds, userId) 458 pmpUserIds = append(pmpUserIds, userId)
425 } 459 }
426 460
427 - // 如果是已启用状态时,当前时间超过截至时间显示【已结束】  
428 - if project.State == domain.ProjectStateEnable { 461 + // 如果是已启用或暂停状态时,当前时间超过截至时间显示【已结束】
  462 + if project.State == domain.ProjectStateEnable || project.State == domain.ProjectStatePause {
429 if now > project.EndTime.Unix() { 463 if now > project.EndTime.Unix() {
430 project.State = domain.ProjectStateDisable 464 project.State = domain.ProjectStateDisable
  465 + _, err = projectRepository.Insert(project)
  466 + if err != nil {
  467 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  468 + }
431 } 469 }
432 } 470 }
433 471
@@ -469,11 +507,58 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) @@ -469,11 +507,58 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
469 if len(project.Recipients) == 0 { 507 if len(project.Recipients) == 0 {
470 return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人") 508 return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人")
471 } 509 }
472 - if project.State == domain.TemplateStateEnable { 510 + if project.State == domain.ProjectStateEnable {
473 return nil, application.ThrowError(application.BUSINESS_ERROR, "项目已启动") 511 return nil, application.ThrowError(application.BUSINESS_ERROR, "项目已启动")
474 } 512 }
475 513
476 - project.State = domain.TemplateStateEnable 514 + // 周期内的所有项目,已启用的员工不能重复被评估
  515 + _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": project.CompanyId, "cycleId": project.CycleId}, "template")
  516 + if err != nil {
  517 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  518 + }
  519 + userMap := map[string]*domain.User{}
  520 + for i := range projects {
  521 + it := projects[i]
  522 + // 排除当前项目
  523 + if in.Id == it.Id {
  524 + continue
  525 + }
  526 + // 启用状态的被评估人
  527 + if it.State == domain.ProjectStateEnable {
  528 + for j := range it.Recipients {
  529 + userMap[it.Recipients[j]] = nil
  530 + }
  531 + }
  532 + }
  533 + ids := make([]string, 0)
  534 + for k := range userMap {
  535 + ids = append(ids, k)
  536 + }
  537 + if len(ids) > 0 {
  538 + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
  539 + _, users, err := userRepository.Find(map[string]interface{}{"ids": ids})
  540 + if err != nil {
  541 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  542 + }
  543 + for i := range users {
  544 + s64 := strconv.FormatInt(users[i].Id, 10)
  545 + userMap[s64] = users[i]
  546 + }
  547 + var build strings.Builder
  548 + for i := range project.Recipients {
  549 + id := project.Recipients[i]
  550 + if user, ok := userMap[id]; ok {
  551 + build.WriteString("[")
  552 + build.WriteString(user.Name)
  553 + build.WriteString("]")
  554 + }
  555 + }
  556 + if build.Len() > 0 {
  557 + return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("请先停止%s正在进行的项目", build.String()))
  558 + }
  559 + }
  560 +
  561 + project.State = domain.ProjectStateEnable
477 project, err = projectRepository.Insert(project) 562 project, err = projectRepository.Insert(project)
478 if err != nil { 563 if err != nil {
479 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 564 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -535,6 +620,139 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) @@ -535,6 +620,139 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
535 return project, nil 620 return project, nil
536 } 621 }
537 622
  623 +func (rs *EvaluationProjectService) Pause(in *command.ActivateProjectCommand) (interface{}, error) {
  624 + transactionContext, err := factory.ValidateStartTransaction(in)
  625 + if err != nil {
  626 + return nil, err
  627 + }
  628 + defer func() {
  629 + transactionContext.RollbackTransaction()
  630 + }()
  631 +
  632 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  633 + taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
  634 +
  635 + project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
  636 + if err != nil {
  637 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  638 + }
  639 + if project.State != domain.ProjectStateEnable {
  640 + return nil, application.ThrowError(application.BUSINESS_ERROR, "项目未启动")
  641 + }
  642 +
  643 + project.State = domain.ProjectStatePause
  644 + project, err = projectRepository.Insert(project)
  645 + if err != nil {
  646 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  647 + }
  648 +
  649 + tasks, err := taskRepository.Find(map[string]interface{}{"projectId": project.Id})
  650 + if err != nil {
  651 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  652 + }
  653 +
  654 + for i := range tasks {
  655 + it := tasks[i]
  656 + it.NextSentAt = nil
  657 + _, err = taskRepository.Insert(it)
  658 + if err != nil {
  659 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  660 + }
  661 + }
  662 +
  663 + if err := transactionContext.CommitTransaction(); err != nil {
  664 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  665 + }
  666 + return project, nil
  667 +}
  668 +
  669 +func (rs *EvaluationProjectService) Resume(in *command.ActivateProjectCommand) (interface{}, error) {
  670 + transactionContext, err := factory.ValidateStartTransaction(in)
  671 + if err != nil {
  672 + return nil, err
  673 + }
  674 + defer func() {
  675 + transactionContext.RollbackTransaction()
  676 + }()
  677 +
  678 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  679 + project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
  680 + if err != nil {
  681 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  682 + }
  683 + if project.Template == nil {
  684 + return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加评估模板")
  685 + }
  686 + if len(project.Recipients) == 0 {
  687 + return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人")
  688 + }
  689 + if project.State == domain.ProjectStateEnable {
  690 + return nil, application.ThrowError(application.BUSINESS_ERROR, "项目已启动")
  691 + }
  692 +
  693 + // 周期内的所有项目,已启用的员工不能重复被评估
  694 + _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": project.CompanyId, "cycleId": project.CycleId}, "template")
  695 + if err != nil {
  696 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  697 + }
  698 + userMap := map[string]*domain.User{}
  699 + for i := range projects {
  700 + it := projects[i]
  701 + // 排除当前项目
  702 + if in.Id == it.Id {
  703 + continue
  704 + }
  705 + // 启用状态的被评估人
  706 + if it.State == domain.ProjectStateEnable {
  707 + for j := range it.Recipients {
  708 + userMap[it.Recipients[j]] = nil
  709 + }
  710 + }
  711 + }
  712 + ids := make([]string, 0)
  713 + for k := range userMap {
  714 + ids = append(ids, k)
  715 + }
  716 + if len(ids) > 0 {
  717 + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
  718 + _, users, err := userRepository.Find(map[string]interface{}{"ids": ids})
  719 + if err != nil {
  720 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  721 + }
  722 + for i := range users {
  723 + s64 := strconv.FormatInt(users[i].Id, 10)
  724 + userMap[s64] = users[i]
  725 + }
  726 + var build strings.Builder
  727 + for i := range project.Recipients {
  728 + id := project.Recipients[i]
  729 + if user, ok := userMap[id]; ok {
  730 + build.WriteString("[")
  731 + build.WriteString(user.Name)
  732 + build.WriteString("]")
  733 + }
  734 + }
  735 + if build.Len() > 0 {
  736 + return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("请先停止%s正在进行的项目", build.String()))
  737 + }
  738 + }
  739 +
  740 + project.State = domain.ProjectStateEnable
  741 + project, err = projectRepository.Insert(project)
  742 + if err != nil {
  743 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  744 + }
  745 + // 项目恢复,同步更新任务时间
  746 + if err = rs.updateTaskTime(transactionContext, in.Id, nil); err != nil {
  747 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  748 + }
  749 +
  750 + if err := transactionContext.CommitTransaction(); err != nil {
  751 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  752 + }
  753 + return project, nil
  754 +}
  755 +
538 func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interface{}, error) { 756 func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interface{}, error) {
539 transactionContext, err := factory.ValidateStartTransaction(in) 757 transactionContext, err := factory.ValidateStartTransaction(in)
540 if err != nil { 758 if err != nil {
@@ -555,7 +773,7 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf @@ -555,7 +773,7 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf
555 project.Recipients = make([]string, 0) // 重置被评估人 773 project.Recipients = make([]string, 0) // 重置被评估人
556 774
557 // 如果拷贝已经启用的模板,默认先设置为待启用 775 // 如果拷贝已经启用的模板,默认先设置为待启用
558 - if project.State == domain.ProjectStateEnable { 776 + if project.State == domain.ProjectStateEnable || project.State == domain.ProjectStatePause {
559 project.State = domain.ProjectStateWaitActive 777 project.State = domain.ProjectStateWaitActive
560 } 778 }
561 project, err = projectRepository.Insert(project) 779 project, err = projectRepository.Insert(project)
@@ -587,11 +805,14 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo @@ -587,11 +805,14 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo
587 // 周期内的所有项目,员工不能重复被评估 805 // 周期内的所有项目,员工不能重复被评估
588 rids := map[string]bool{} 806 rids := map[string]bool{}
589 for i := range projects { 807 for i := range projects {
  808 + it := projects[i]
590 // 排除当前项目 809 // 排除当前项目
591 - if in.Id != projects[i].Id {  
592 - ids := projects[i].Recipients  
593 - for j := range ids {  
594 - rids[ids[j]] = true 810 + if in.Id == it.Id {
  811 + continue
  812 + }
  813 + if it.State == domain.ProjectStateEnable {
  814 + for j := range it.Recipients {
  815 + rids[it.Recipients[j]] = true
595 } 816 }
596 } 817 }
597 } 818 }
@@ -234,8 +234,10 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP @@ -234,8 +234,10 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP
234 var projectItemUsed = map[int][]*domain.EvaluationItemUsed{} // 项目ID-> 评估内容项 234 var projectItemUsed = map[int][]*domain.EvaluationItemUsed{} // 项目ID-> 评估内容项
235 var userProjectMap = map[int][]*dao.IndicatorUserProject{} // 用户ID-> 用户评估的项目(用户在周期内可能有多个项目模板,激活状态只能是1个) 235 var userProjectMap = map[int][]*dao.IndicatorUserProject{} // 用户ID-> 用户评估的项目(用户在周期内可能有多个项目模板,激活状态只能是1个)
236 var projectIds = make([]int, 0) 236 var projectIds = make([]int, 0)
237 - 237 + var userIds = make([]string, 0)
238 if len(in.UserIds) > 0 { 238 if len(in.UserIds) > 0 {
  239 + userIds = in.UserIds // 赋值
  240 +
239 staffAssessRepository := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext}) 241 staffAssessRepository := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext})
240 _, assessList, err := staffAssessRepository.Find(map[string]interface{}{ 242 _, assessList, err := staffAssessRepository.Find(map[string]interface{}{
241 "cycleId": in.CycleId, 243 "cycleId": in.CycleId,
@@ -295,7 +297,9 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP @@ -295,7 +297,9 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP
295 } 297 }
296 userProjectMap[it.TargetUserId] = append(array, &it) 298 userProjectMap[it.TargetUserId] = append(array, &it)
297 } 299 }
298 - 300 + for k := range userProjectMap {
  301 + userIds = append(userIds, strconv.Itoa(k))
  302 + }
299 for k, _ := range projectIdsMap { 303 for k, _ := range projectIdsMap {
300 projectIds = append(projectIds, k) 304 projectIds = append(projectIds, k)
301 } 305 }
@@ -323,8 +327,8 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP @@ -323,8 +327,8 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP
323 327
324 adapterList := make([]*adapter.PerformanceIndicatorAdapter, 0) 328 adapterList := make([]*adapter.PerformanceIndicatorAdapter, 0)
325 categoryMap := map[string]int{} // 内容分类 329 categoryMap := map[string]int{} // 内容分类
326 - for i := range in.UserIds {  
327 - userId := in.UserIds[i] 330 + for i := range userIds {
  331 + userId := userIds[i]
328 userIdInt, err := strconv.Atoi(userId) 332 userIdInt, err := strconv.Atoi(userId)
329 if err != nil { 333 if err != nil {
330 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 334 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -7,11 +7,12 @@ import ( @@ -7,11 +7,12 @@ import (
7 const ( 7 const (
8 ProjectStateWaitConfig int = 0 // 项目状态-待完成配置 8 ProjectStateWaitConfig int = 0 // 项目状态-待完成配置
9 ProjectStateWaitActive int = 1 // 项目状态-待启用 9 ProjectStateWaitActive int = 1 // 项目状态-待启用
10 - ProjectStateEnable int = 2 // 项目状态-启用  
11 - ProjectStateDisable int = 3 // 项目状态-停用(假状态) 10 + ProjectStateEnable int = 2 // 项目状态-启动
  11 + ProjectStateDisable int = 3 // 项目状态-结束
  12 + ProjectStatePause int = 4 // 项目状态-暂停(可恢复启动)
12 ) 13 )
13 14
14 -// 项目的评估内容配置 15 +// EvaluationProject 项目的评估内容配置
15 type EvaluationProject struct { 16 type EvaluationProject struct {
16 Id int64 `json:"id,string" comment:"ID"` 17 Id int64 `json:"id,string" comment:"ID"`
17 Name string `json:"name" comment:"名称"` 18 Name string `json:"name" comment:"名称"`
@@ -96,6 +96,26 @@ func (controller *ProjectController) ActivateProject() { @@ -96,6 +96,26 @@ func (controller *ProjectController) ActivateProject() {
96 } 96 }
97 } 97 }
98 98
  99 +func (controller *ProjectController) PauseProject() {
  100 + ruService := service.NewEvaluationProjectService()
  101 + in := &command.ActivateProjectCommand{}
  102 + if err := controller.Unmarshal(in); err != nil {
  103 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  104 + } else {
  105 + controller.Response(ruService.Pause(in))
  106 + }
  107 +}
  108 +
  109 +func (controller *ProjectController) ResumeProject() {
  110 + ruService := service.NewEvaluationProjectService()
  111 + in := &command.ActivateProjectCommand{}
  112 + if err := controller.Unmarshal(in); err != nil {
  113 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  114 + } else {
  115 + controller.Response(ruService.Resume(in))
  116 + }
  117 +}
  118 +
99 func (controller *ProjectController) CopyProject() { 119 func (controller *ProjectController) CopyProject() {
100 ruService := service.NewEvaluationProjectService() 120 ruService := service.NewEvaluationProjectService()
101 in := &command.CopyProjectCommand{} 121 in := &command.CopyProjectCommand{}
@@ -19,6 +19,8 @@ func init() { @@ -19,6 +19,8 @@ func init() {
19 web.NSRouter("/check-recipients", &controllers.ProjectController{}, "Post:CheckRecipients"), 19 web.NSRouter("/check-recipients", &controllers.ProjectController{}, "Post:CheckRecipients"),
20 web.NSRouter("/copy", &controllers.ProjectController{}, "Post:CopyProject"), 20 web.NSRouter("/copy", &controllers.ProjectController{}, "Post:CopyProject"),
21 web.NSRouter("/activate", &controllers.ProjectController{}, "Post:ActivateProject"), 21 web.NSRouter("/activate", &controllers.ProjectController{}, "Post:ActivateProject"),
  22 + web.NSRouter("/pause", &controllers.ProjectController{}, "Post:PauseProject"),
  23 + web.NSRouter("/resume", &controllers.ProjectController{}, "Post:ResumeProject"),
22 ) 24 )
23 web.AddNamespace(ns) 25 web.AddNamespace(ns)
24 } 26 }
@@ -58,7 +58,6 @@ func NextTime(now0 time.Time, start time.Time, kpiCycle int) time.Time { @@ -58,7 +58,6 @@ func NextTime(now0 time.Time, start time.Time, kpiCycle int) time.Time {
58 switch kpiCycle { 58 switch kpiCycle {
59 case domain.KpiCycleDay: 59 case domain.KpiCycleDay:
60 nextTime = now0 // 当前时间的0点开始发送 60 nextTime = now0 // 当前时间的0点开始发送
61 - //nextTime = timeconv.AddDate(now0, 0, 0, 0) // 当前时间的0点开始发送  
62 break 61 break
63 case domain.KpiCycleWeek: 62 case domain.KpiCycleWeek:
64 offsetSeconds := int64(now0.Sub(start0).Seconds()) 63 offsetSeconds := int64(now0.Sub(start0).Seconds())