作者 tangxvhui

修正sql错误

  1 +package adapter
  2 +
  3 +type AssessCycleDescResp struct {
  4 + CycleId int `json:"cycleId"`
  5 + CycleName string `json:"cycleName"` //周期名称
  6 + BeginDay string `json:"beginDay"` //开始的日期
  7 + StepList []AssessTaskStep `json:"stepList"` //考评流程
  8 +}
  9 +
  10 +type AssessCycleStep struct {
  11 + SortBy int `json:"sortBy"` //排序
  12 + LinkNodeId int `json:"linkNodeId"` //流程id
  13 + LinkNodeName string `json:"linkNodeName"` //流程名称
  14 + BeginTime string `json:"beginTime"` //开始时间时间
  15 + EndTime string `json:"endTime"` //结束时间
  16 + LinkNodeType int `json:"linkNodeType"` //流程类型
  17 + Desc string `json:"desc"` //情况描述
  18 + Status string `json:"status"` //流程是否完成 "":未参加,"uncompleted":未完成,"completed":完成
  19 +}
@@ -2,6 +2,7 @@ package query @@ -2,6 +2,7 @@ package query
2 2
3 type AssessCycleDescQuery struct { 3 type AssessCycleDescQuery struct {
4 CycleId int `json:"cycleId"` //评估任务的id 4 CycleId int `json:"cycleId"` //评估任务的id
  5 + BeginDay string `json:"beginDay"` //开始时间 2022-01-02
5 UserId int `json:"userId"` //当前登录人的id 6 UserId int `json:"userId"` //当前登录人的id
6 CompanyId int `json:"companyId"` //当前登录的公司 7 CompanyId int `json:"companyId"` //当前登录的公司
7 } 8 }
@@ -60,7 +60,7 @@ func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQu @@ -60,7 +60,7 @@ func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQu
60 } 60 }
61 61
62 //获取我的项目周期进度描述 62 //获取我的项目周期进度描述
63 -func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQuery) (*adapter.AssessTaskDescResp, error) { 63 +func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQuery) (*adapter.AssessCycleDescResp, error) {
64 transactionContext, err := factory.CreateTransactionContext(nil) 64 transactionContext, err := factory.CreateTransactionContext(nil)
65 if err != nil { 65 if err != nil {
66 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 66 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -79,24 +79,32 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -79,24 +79,32 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
79 staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ 79 staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
80 "transactionContext": transactionContext, 80 "transactionContext": transactionContext,
81 }) 81 })
82 - assessTaskData, err := staffAssessTaskRepo.FindOne(map[string]interface{}{  
83 - // "id": param.AssessTaskId, 82 + assessTaskDataAny, err := staffAssessTaskRepo.FindOne(map[string]interface{}{
  83 + "cycleId": param.CycleId,
  84 + "beginDay": param.BeginDay,
  85 + "limit": 1,
84 }) 86 })
85 if err != nil { 87 if err != nil {
86 return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error()) 88 return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error())
87 } 89 }
  90 + _, myAssessTask, err := staffAssessTaskRepo.Find(map[string]interface{}{
  91 + "cycleId": param.CycleId,
  92 + "beginDay": param.BeginDay,
  93 + "executorId": param.UserId,
  94 + "limit": 1,
  95 + })
  96 + if err != nil {
  97 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "我的评估任务不存在,"+err.Error())
  98 + }
88 //返回的数据结果 99 //返回的数据结果
89 - result := adapter.AssessTaskDescResp{  
90 - AssessTaskId: assessTaskData.Id,  
91 - EvaluationProjectId: assessTaskData.EvaluationProjectId,  
92 - EvaluationProjectName: assessTaskData.EvaluationProjectName,  
93 - CycleName: assessTaskData.CycleName,  
94 - BeginTime: assessTaskData.BeginTime.Local().Format("2006-01-02 15:04-05"),  
95 - EndTime: assessTaskData.EndTime.Local().Format("2006-01-02 15:04-05"), 100 + result := adapter.AssessCycleDescResp{
  101 + CycleId: int(assessTaskDataAny.CycleId),
  102 + CycleName: assessTaskDataAny.CycleName,
  103 + BeginDay: assessTaskDataAny.BeginDay,
96 StepList: []adapter.AssessTaskStep{}, 104 StepList: []adapter.AssessTaskStep{},
97 } 105 }
98 106
99 - for _, v := range assessTaskData.StepList { 107 + for _, v := range assessTaskDataAny.StepList {
100 stepItem := adapter.AssessTaskStep{ 108 stepItem := adapter.AssessTaskStep{
101 SortBy: v.SortBy, 109 SortBy: v.SortBy,
102 LinkNodeName: v.LinkNodeName, 110 LinkNodeName: v.LinkNodeName,
@@ -109,9 +117,10 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -109,9 +117,10 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
109 } 117 }
110 switch v.LinkNodeType { 118 switch v.LinkNodeType {
111 case domain.LinkNodeSelfAssessment: 119 case domain.LinkNodeSelfAssessment:
  120 + if len(myAssessTask) > 0 {
112 //个人自评完成情况 121 //个人自评完成情况
113 _, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{ 122 _, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{
114 - "staffAssessTaskId": assessTaskData.Id, 123 + "staffAssessTaskId": myAssessTask[0].Id,
115 "executorId": param.UserId, 124 "executorId": param.UserId,
116 "typesList": []string{string(domain.AssessSelf)}, 125 "typesList": []string{string(domain.AssessSelf)},
117 }) 126 })
@@ -122,10 +131,14 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -122,10 +131,14 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
122 stepItem.Status = string(assessSelfData[0].Status) 131 stepItem.Status = string(assessSelfData[0].Status)
123 } 132 }
124 stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) 133 stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
  134 + }
125 case domain.LinkNodeAllInvite: 135 case domain.LinkNodeAllInvite:
  136 + if len(myAssessTask) > 0 {
  137 +
  138 + }
126 //邀请别人评估自己 139 //邀请别人评估自己
127 _, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{ 140 _, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{
128 - "staffAssessTaskId": assessTaskData.Id, 141 + // "staffAssessTaskId": assessTaskData.Id,
129 "targetUserId": param.UserId, 142 "targetUserId": param.UserId,
130 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, 143 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
131 "limit": 5, 144 "limit": 5,
@@ -147,7 +160,7 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -147,7 +160,7 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
147 case domain.LinkNodeAllAssessment: 160 case domain.LinkNodeAllAssessment:
148 //我评估别人,被邀请评估 161 //我评估别人,被邀请评估
149 _, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{ 162 _, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{
150 - "staffAssessTaskId": assessTaskData.Id, 163 + // "staffAssessTaskId": assessTaskData.Id,
151 "executorId": param.UserId, 164 "executorId": param.UserId,
152 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, 165 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
153 }) 166 })
@@ -168,7 +181,7 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -168,7 +181,7 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
168 case domain.LinkNodeSuperiorAssessment: 181 case domain.LinkNodeSuperiorAssessment:
169 //我评估别人,上级评估 182 //我评估别人,上级评估
170 _, assessSupperList, err := staffAssessRepo.Find(map[string]interface{}{ 183 _, assessSupperList, err := staffAssessRepo.Find(map[string]interface{}{
171 - "staffAssessTaskId": assessTaskData.Id, 184 + // "staffAssessTaskId": assessTaskData.Id,
172 "executorId": param.UserId, 185 "executorId": param.UserId,
173 "typesList": []string{string(domain.AssessSuper)}, 186 "typesList": []string{string(domain.AssessSuper)},
174 }) 187 })
@@ -140,7 +140,7 @@ type AssessCycleDay struct { @@ -140,7 +140,7 @@ type AssessCycleDay struct {
140 func (d *StaffAssessDao) AllAssessCycleDayList(companyId int, cycleId int) ([]AssessCycleDay, error) { 140 func (d *StaffAssessDao) AllAssessCycleDayList(companyId int, cycleId int) ([]AssessCycleDay, error) {
141 sqlStr := `select distinct staff_assess_task.begin_day , 141 sqlStr := `select distinct staff_assess_task.begin_day ,
142 staff_assess_task.cycle_id , 142 staff_assess_task.cycle_id ,
143 - staff_assess_task.cycle_name 143 + staff_assess_task.cycle_name,
144 staff_assess_task.company_id 144 staff_assess_task.company_id
145 from staff_assess_task 145 from staff_assess_task
146 where staff_assess_task.cycle_id = ? 146 where staff_assess_task.cycle_id = ?
@@ -156,6 +156,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in @@ -156,6 +156,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
156 if v, ok := queryOptions["endTime"]; ok { 156 if v, ok := queryOptions["endTime"]; ok {
157 query.Where("end_time<=?", v) 157 query.Where("end_time<=?", v)
158 } 158 }
  159 +
159 count, err := query.SelectAndCount() 160 count, err := query.SelectAndCount()
160 if err != nil { 161 if err != nil {
161 return 0, nil, err 162 return 0, nil, err
@@ -120,6 +120,9 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{}) @@ -120,6 +120,9 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{})
120 if v, ok := queryOptions["beginDay"]; ok { 120 if v, ok := queryOptions["beginDay"]; ok {
121 query.Where("begin_day=?", v) 121 query.Where("begin_day=?", v)
122 } 122 }
  123 + if v, ok := queryOptions["cycleId"]; ok {
  124 + query.Where("cycle_id=?", v)
  125 + }
123 if v, ok := queryOptions["executorId"].(int); ok && v > 0 { 126 if v, ok := queryOptions["executorId"].(int); ok && v > 0 {
124 query.Where(`executor_id @>'[?]'`, v) 127 query.Where(`executor_id @>'[?]'`, v)
125 } 128 }