作者 tangxvhui

修正sql错误

package adapter
type AssessCycleDescResp struct {
CycleId int `json:"cycleId"`
CycleName string `json:"cycleName"` //周期名称
BeginDay string `json:"beginDay"` //开始的日期
StepList []AssessTaskStep `json:"stepList"` //考评流程
}
type AssessCycleStep struct {
SortBy int `json:"sortBy"` //排序
LinkNodeId int `json:"linkNodeId"` //流程id
LinkNodeName string `json:"linkNodeName"` //流程名称
BeginTime string `json:"beginTime"` //开始时间时间
EndTime string `json:"endTime"` //结束时间
LinkNodeType int `json:"linkNodeType"` //流程类型
Desc string `json:"desc"` //情况描述
Status string `json:"status"` //流程是否完成 "":未参加,"uncompleted":未完成,"completed":完成
}
... ...
... ... @@ -2,6 +2,7 @@ package query
type AssessCycleDescQuery struct {
CycleId int `json:"cycleId"` //评估任务的id
BeginDay string `json:"beginDay"` //开始时间 2022-01-02
UserId int `json:"userId"` //当前登录人的id
CompanyId int `json:"companyId"` //当前登录的公司
}
... ...
... ... @@ -60,7 +60,7 @@ func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQu
}
//获取我的项目周期进度描述
func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQuery) (*adapter.AssessTaskDescResp, error) {
func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQuery) (*adapter.AssessCycleDescResp, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -79,24 +79,32 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessTaskData, err := staffAssessTaskRepo.FindOne(map[string]interface{}{
// "id": param.AssessTaskId,
assessTaskDataAny, err := staffAssessTaskRepo.FindOne(map[string]interface{}{
"cycleId": param.CycleId,
"beginDay": param.BeginDay,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error())
}
_, myAssessTask, err := staffAssessTaskRepo.Find(map[string]interface{}{
"cycleId": param.CycleId,
"beginDay": param.BeginDay,
"executorId": param.UserId,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "我的评估任务不存在,"+err.Error())
}
//返回的数据结果
result := adapter.AssessTaskDescResp{
AssessTaskId: assessTaskData.Id,
EvaluationProjectId: assessTaskData.EvaluationProjectId,
EvaluationProjectName: assessTaskData.EvaluationProjectName,
CycleName: assessTaskData.CycleName,
BeginTime: assessTaskData.BeginTime.Local().Format("2006-01-02 15:04-05"),
EndTime: assessTaskData.EndTime.Local().Format("2006-01-02 15:04-05"),
result := adapter.AssessCycleDescResp{
CycleId: int(assessTaskDataAny.CycleId),
CycleName: assessTaskDataAny.CycleName,
BeginDay: assessTaskDataAny.BeginDay,
StepList: []adapter.AssessTaskStep{},
}
for _, v := range assessTaskData.StepList {
for _, v := range assessTaskDataAny.StepList {
stepItem := adapter.AssessTaskStep{
SortBy: v.SortBy,
LinkNodeName: v.LinkNodeName,
... ... @@ -109,9 +117,10 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
}
switch v.LinkNodeType {
case domain.LinkNodeSelfAssessment:
if len(myAssessTask) > 0 {
//个人自评完成情况
_, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": assessTaskData.Id,
"staffAssessTaskId": myAssessTask[0].Id,
"executorId": param.UserId,
"typesList": []string{string(domain.AssessSelf)},
})
... ... @@ -122,10 +131,14 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
stepItem.Status = string(assessSelfData[0].Status)
}
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
}
case domain.LinkNodeAllInvite:
if len(myAssessTask) > 0 {
}
//邀请别人评估自己
_, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": assessTaskData.Id,
// "staffAssessTaskId": assessTaskData.Id,
"targetUserId": param.UserId,
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
"limit": 5,
... ... @@ -147,7 +160,7 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
case domain.LinkNodeAllAssessment:
//我评估别人,被邀请评估
_, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": assessTaskData.Id,
// "staffAssessTaskId": assessTaskData.Id,
"executorId": param.UserId,
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
})
... ... @@ -168,7 +181,7 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
case domain.LinkNodeSuperiorAssessment:
//我评估别人,上级评估
_, assessSupperList, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": assessTaskData.Id,
// "staffAssessTaskId": assessTaskData.Id,
"executorId": param.UserId,
"typesList": []string{string(domain.AssessSuper)},
})
... ...
... ... @@ -140,7 +140,7 @@ type AssessCycleDay struct {
func (d *StaffAssessDao) AllAssessCycleDayList(companyId int, cycleId int) ([]AssessCycleDay, error) {
sqlStr := `select distinct staff_assess_task.begin_day ,
staff_assess_task.cycle_id ,
staff_assess_task.cycle_name
staff_assess_task.cycle_name,
staff_assess_task.company_id
from staff_assess_task
where staff_assess_task.cycle_id = ?
... ...
... ... @@ -156,6 +156,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
if v, ok := queryOptions["endTime"]; ok {
query.Where("end_time<=?", v)
}
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...
... ... @@ -120,6 +120,9 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{})
if v, ok := queryOptions["beginDay"]; ok {
query.Where("begin_day=?", v)
}
if v, ok := queryOptions["cycleId"]; ok {
query.Where("cycle_id=?", v)
}
if v, ok := queryOptions["executorId"].(int); ok && v > 0 {
query.Where(`executor_id @>'[?]'`, v)
}
... ...