作者 郑周

Merge branch 'dev-zhengzhou' into dev-tangxvhui

@@ -35,6 +35,11 @@ type CheckRecipientCommand struct { @@ -35,6 +35,11 @@ type CheckRecipientCommand struct {
35 Recipients []string `cname:"被评估人ID" json:"recipients"` 35 Recipients []string `cname:"被评估人ID" json:"recipients"`
36 } 36 }
37 37
  38 +// CheckTaskTemplateCommand 检测选中的模板是否含有任务指标
  39 +type CheckTaskTemplateCommand struct {
  40 + TemplateId int64 `cname:"模板ID" json:"templateId,string"`
  41 +}
  42 +
38 func (in *UpdateProjectCommand) Valid(validation *validation.Validation) { 43 func (in *UpdateProjectCommand) Valid(validation *validation.Validation) {
39 if utf8.RuneCountInString(in.Name) > 40 { 44 if utf8.RuneCountInString(in.Name) > 40 {
40 validation.SetError("name", "项目名称最大长度40个字符") 45 validation.SetError("name", "项目名称最大长度40个字符")
@@ -910,3 +910,41 @@ func (rs *EvaluationProjectService) generateEvaluationItemUsed(transactionContex @@ -910,3 +910,41 @@ func (rs *EvaluationProjectService) generateEvaluationItemUsed(transactionContex
910 } 910 }
911 return nil 911 return nil
912 } 912 }
  913 +
  914 +func (rs *EvaluationProjectService) CheckTaskTemplate(in *command.CheckTaskTemplateCommand) (interface{}, error) {
  915 + transactionContext, err := factory.ValidateStartTransaction(in)
  916 + if err != nil {
  917 + return nil, err
  918 + }
  919 + defer func() {
  920 + transactionContext.RollbackTransaction()
  921 + }()
  922 +
  923 + cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
  924 + cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId, "includeDeleted": true})
  925 + if err != nil {
  926 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  927 + }
  928 + if cycleTemplate == nil || cycleTemplate.Template == nil {
  929 + return nil, application.ThrowError(application.BUSINESS_ERROR, "未找到模板")
  930 + }
  931 +
  932 + // 指标任务的项目(存在一项类型为任务指标),必须添加项目负责人
  933 + var indicatorTypeTask = 0
  934 +outerLoop:
  935 + for i := range cycleTemplate.Template.LinkNodes {
  936 + var node = cycleTemplate.Template.LinkNodes[i]
  937 + for j := range node.NodeContents {
  938 + if node.NodeContents[j].IndicatorType == domain.IndicatorTypeTask {
  939 + indicatorTypeTask = 1
  940 + break outerLoop
  941 + }
  942 + }
  943 + }
  944 +
  945 + if err := transactionContext.CommitTransaction(); err != nil {
  946 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  947 + }
  948 +
  949 + return map[string]interface{}{"indicatorTypeTask": indicatorTypeTask}, nil
  950 +}
@@ -139,3 +139,13 @@ func (controller *ProjectController) CheckRecipients() { @@ -139,3 +139,13 @@ func (controller *ProjectController) CheckRecipients() {
139 controller.Response(ruService.CheckRecipients(in)) 139 controller.Response(ruService.CheckRecipients(in))
140 } 140 }
141 } 141 }
  142 +
  143 +func (controller *ProjectController) CheckTaskTemplate() {
  144 + ruService := service.NewEvaluationProjectService()
  145 + in := &command.CheckTaskTemplateCommand{}
  146 + if err := controller.Unmarshal(in); err != nil {
  147 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  148 + } else {
  149 + controller.Response(ruService.CheckTaskTemplate(in))
  150 + }
  151 +}
@@ -17,6 +17,7 @@ func init() { @@ -17,6 +17,7 @@ func init() {
17 web.NSRouter("/list", &controllers.ProjectController{}, "Post:ListProject"), 17 web.NSRouter("/list", &controllers.ProjectController{}, "Post:ListProject"),
18 web.NSRouter("/detail", &controllers.ProjectController{}, "Put:UpdateProjectForTemplate"), 18 web.NSRouter("/detail", &controllers.ProjectController{}, "Put:UpdateProjectForTemplate"),
19 web.NSRouter("/check-recipients", &controllers.ProjectController{}, "Post:CheckRecipients"), 19 web.NSRouter("/check-recipients", &controllers.ProjectController{}, "Post:CheckRecipients"),
  20 + web.NSRouter("/check-template", &controllers.ProjectController{}, "Post:CheckTaskTemplate"),
20 web.NSRouter("/copy", &controllers.ProjectController{}, "Post:CopyProject"), 21 web.NSRouter("/copy", &controllers.ProjectController{}, "Post:CopyProject"),
21 web.NSRouter("/activate", &controllers.ProjectController{}, "Post:ActivateProject"), 22 web.NSRouter("/activate", &controllers.ProjectController{}, "Post:ActivateProject"),
22 web.NSRouter("/pause", &controllers.ProjectController{}, "Post:PauseProject"), 23 web.NSRouter("/pause", &controllers.ProjectController{}, "Post:PauseProject"),