作者 tangxvhui

调整异常中心了列表查询

@@ -26,7 +26,7 @@ type TaskAnomaly struct { @@ -26,7 +26,7 @@ type TaskAnomaly struct {
26 CurrentStage TaskStage `json:"currentStage"` // 计划进度的里程碑 26 CurrentStage TaskStage `json:"currentStage"` // 计划进度的里程碑
27 LastStage TaskStage `json:"lastStage"` // 实际进度完成的里程碑 27 LastStage TaskStage `json:"lastStage"` // 实际进度完成的里程碑
28 TaskStageCheck TaskStage `json:"taskStageCheck"` // 当天任务反馈操作里程碑记录 28 TaskStageCheck TaskStage `json:"taskStageCheck"` // 当天任务反馈操作里程碑记录
29 - AssessFlag int `json:"anomaly"` // 异常反馈的次数 29 + AssessFlag int `json:"assessFlag"` // 异常反馈的次数
30 WarnFlag int `json:"warnFlag"` // 里程碑异常次数 30 WarnFlag int `json:"warnFlag"` // 里程碑异常次数
31 AssistFlag int `json:"assistFlag"` // 辅导异常次数 31 AssistFlag int `json:"assistFlag"` // 辅导异常次数
32 IsLast int `json:"isLast"` // 是否是最新的一条记录 1 是最新的记录 2 不是最新的记录 32 IsLast int `json:"isLast"` // 是否是最新的一条记录 1 是最新的记录 2 不是最新的记录
@@ -108,6 +108,17 @@ func (d *TaskAnomalyDao) List1(userId int, companyId int, taskName string, categ @@ -108,6 +108,17 @@ func (d *TaskAnomalyDao) List1(userId int, companyId int, taskName string, categ
108 condition = append(condition, dayTime) 108 condition = append(condition, dayTime)
109 sqlStr2 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? ` 109 sqlStr2 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? `
110 sqlStr1 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? ` 110 sqlStr1 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? `
  111 + switch category {
  112 + case domain.AnomalyCategoryType1:
  113 + sqlStr2 += " and task_anomaly.warn_flag=1 "
  114 + sqlStr1 += " and task_anomaly.warn_flag=1 "
  115 + case domain.AnomalyCategoryType2:
  116 + sqlStr2 += " and task_anomaly.assess_flag=1 "
  117 + sqlStr1 += " and task_anomaly.assess_flag=1 "
  118 + // case domain.AnomalyCategoryType3:
  119 + // sqlStr2 += " and task_anomaly.assist_flag=1 "
  120 + // sqlStr1 += " and task_anomaly.assist_flag=1 "
  121 + }
111 } 122 }
112 if len(taskName) > 0 { 123 if len(taskName) > 0 {
113 condition = append(condition, "%"+taskName+"%") 124 condition = append(condition, "%"+taskName+"%")
@@ -253,11 +264,7 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ @@ -253,11 +264,7 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ
253 join task_anomaly on t_task.task_id= task_anomaly.task_id 264 join task_anomaly on t_task.task_id= task_anomaly.task_id
254 where 1=1 and task_anomaly.is_last=1` 265 where 1=1 and task_anomaly.is_last=1`
255 condition := []interface{}{userId, userId, companyId, subLevel} 266 condition := []interface{}{userId, userId, companyId, subLevel}
256 - if len(dayTime) > 0 {  
257 - condition = append(condition, dayTime)  
258 - sqlStr2 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? `  
259 - sqlStr1 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? `  
260 - } 267 +
261 if len(taskName) > 0 { 268 if len(taskName) > 0 {
262 condition = append(condition, "%"+taskName+"%") 269 condition = append(condition, "%"+taskName+"%")
263 sqlStr2 += ` and t_task.task_alias like ? ` 270 sqlStr2 += ` and t_task.task_alias like ? `
@@ -268,6 +275,22 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ @@ -268,6 +275,22 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ
268 sqlStr1 += ` and task_anomaly.category=? ` 275 sqlStr1 += ` and task_anomaly.category=? `
269 sqlStr2 += ` and task_anomaly.category=? ` 276 sqlStr2 += ` and task_anomaly.category=? `
270 } 277 }
  278 + if len(dayTime) > 0 {
  279 + condition = append(condition, dayTime)
  280 + sqlStr2 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? `
  281 + sqlStr1 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? `
  282 + switch category {
  283 + case domain.AnomalyCategoryType1:
  284 + sqlStr2 += " and task_anomaly.warn_flag=1 "
  285 + sqlStr1 += " and task_anomaly.warn_flag=1 "
  286 + case domain.AnomalyCategoryType2:
  287 + sqlStr2 += " and task_anomaly.assess_flag=1 "
  288 + sqlStr1 += " and task_anomaly.assess_flag=1 "
  289 + // case domain.AnomalyCategoryType3:
  290 + // sqlStr2 += " and task_anomaly.assist_flag=1 "
  291 + // sqlStr1 += " and task_anomaly.assist_flag=1 "
  292 + }
  293 + }
271 if len(leaderId) > 0 { 294 if len(leaderId) > 0 {
272 condition = append(condition, pg.In(leaderId)) 295 condition = append(condition, pg.In(leaderId))
273 sqlStr2 += ` and t_task.leader_id in (?) ` 296 sqlStr2 += ` and t_task.leader_id in (?) `
@@ -350,6 +373,17 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ @@ -350,6 +373,17 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ
350 condition = append(condition, dayTime) 373 condition = append(condition, dayTime)
351 sqlStr2 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? ` 374 sqlStr2 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? `
352 sqlStr1 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? ` 375 sqlStr1 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? `
  376 + switch category {
  377 + case domain.AnomalyCategoryType1:
  378 + sqlStr2 += " and task_anomaly.warn_flag=1 "
  379 + sqlStr1 += " and task_anomaly.warn_flag=1 "
  380 + case domain.AnomalyCategoryType2:
  381 + sqlStr2 += " and task_anomaly.assess_flag=1 "
  382 + sqlStr1 += " and task_anomaly.assess_flag=1 "
  383 + // case domain.AnomalyCategoryType3:
  384 + // sqlStr2 += " and task_anomaly.assist_flag=1 "
  385 + // sqlStr1 += " and task_anomaly.assist_flag=1 "
  386 + }
353 } 387 }
354 if len(taskName) > 0 { 388 if len(taskName) > 0 {
355 condition = append(condition, "%"+taskName+"%") 389 condition = append(condition, "%"+taskName+"%")
@@ -443,7 +477,7 @@ func (d TaskAnomalyDao) SearchForUser(userId int, companyId int, taskName string @@ -443,7 +477,7 @@ func (d TaskAnomalyDao) SearchForUser(userId int, companyId int, taskName string
443 task_anomaly.created_at 477 task_anomaly.created_at
444 from t_task 478 from t_task
445 join task_anomaly on t_task.task_id= task_anomaly.task_id 479 join task_anomaly on t_task.task_id= task_anomaly.task_id
446 - where t_task.task_alias like ?` 480 + where t_task.task_alias like ? and task_anomaly.is_last=1 `
447 condition := []interface{}{userId, userId, companyId, fmt.Sprintf("[%d]", userId)} 481 condition := []interface{}{userId, userId, companyId, fmt.Sprintf("[%d]", userId)}
448 condition = append(condition, "%"+taskName+"%") 482 condition = append(condition, "%"+taskName+"%")
449 result := []ListTaskAnomaly{} 483 result := []ListTaskAnomaly{}