作者 tangxvhui

调整任务输出列表

... ... @@ -24,6 +24,7 @@ type TaskItem struct {
Anomaly int `json:"anomaly"` // 异常反馈情况
WarnFlag int `json:"warnFlag"` // 里程碑完成时间异常标记 0:正常 1标记为异常
AnomalyDesc []string `json:"anomalyDesc"` // 异常状态
AnomalyDesc2 []map[string]string `json:"anomalyDesc2"`
Marks map[string]string `json:"marks"` // 标记
}
... ...
... ... @@ -4,5 +4,5 @@ type MarkTaskAnomalyCommand struct {
Id int `json:"id,string"` //异常记录id
CompanyId int `json:"-"`
UserId int `json:"-"`
MarkType string `json:"markType"` //a:去更新,b:去反馈,c:去求助,d:去辅导
MarkType string `json:"markType"` //a:去更新,b:去反馈,c:去找上级,d:去辅导
}
... ...
... ... @@ -2,11 +2,13 @@ package service
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/log_opt"
"strconv"
"strings"
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/log_opt"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils/xtime"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
... ... @@ -1212,6 +1214,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
IsRef: false,
},
AnomalyDesc: []string{},
AnomalyDesc2: []map[string]string{},
Marks: map[string]string{},
}
if val.LastStage.RealCompletedAt > 0 {
... ... @@ -1257,26 +1260,94 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
}
}
tk.GenStatusDescript()
for _, val := range taskAnomalyList {
if tk.Id != val.TaskId {
for _, val3 := range taskAnomalyList {
if tk.Id != val3.TaskId {
continue
}
if val.Marks == nil {
val.Marks = map[string]string{}
if val3.Marks == nil {
val3.Marks = map[string]string{}
}
noticeWho := []string{}
for _, val2 := range val3.NoticeWho {
noticeWho = append(noticeWho, val2["name"])
}
switch val3.Category {
case domain.AnomalyCategoryType1:
{
//里程碑异常
if val3.TaskStageCheck.RealCompletedAt == 0 && val3.TaskStageCheck.Id > 0 {
//逾期未完成
planCompletedAt := time.Unix(val3.TaskStageCheck.PlanCompletedAt, 0)
subDay := xtime.SubDayAbs(val3.CreatedAt, planCompletedAt)
tk.AnomalyDesc = append(tk.AnomalyDesc, fmt.Sprintf("里程碑%s已逾期%d天", val3.TaskStageCheck.Name, subDay))
tk.AnomalyDesc2 = append(tk.AnomalyDesc2, map[string]string{
"types": "10",
"stageName": val3.TaskStageCheck.Name,
"interval": strconv.Itoa(subDay),
"noticeWho": strings.Join(noticeWho, ","),
})
} else if val3.TaskStageCheck.RealCompletedAt > 0 && val3.TaskStageCheck.Id > 0 {
//逾期完成
planCompletedAt := time.Unix(val3.TaskStageCheck.PlanCompletedAt, 0)
realCompletedAt := time.Unix(val3.TaskStageCheck.RealCompletedAt, 0)
subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt)
tk.AnomalyDesc = append(tk.AnomalyDesc, fmt.Sprintf("里程碑%s逾期%d天完成", val3.TaskStageCheck.Name, subDay))
tk.AnomalyDesc2 = append(tk.AnomalyDesc2, map[string]string{
"types": "11",
"stageName": val3.TaskStageCheck.Name,
"interval": strconv.Itoa(subDay),
"noticeWho": strings.Join(noticeWho, ","),
})
}
}
r := val.Remark + ",该条异常已通知"
for _, val2 := range val.NoticeWho {
r += val2["name"] + " "
case domain.AnomalyCategoryType2:
//反馈异常
{
recordBegin := time.Unix(val3.RecordBegin, 0)
subDay := xtime.SubDayAbs(val3.CreatedAt, recordBegin)
tk.AnomalyDesc = append(tk.AnomalyDesc, fmt.Sprintf(
"本任务自%s未正常反馈项目进度,已异常%d天",
recordBegin.Local().Format("2006-01-02"),
subDay,
))
tk.AnomalyDesc2 = append(tk.AnomalyDesc2, map[string]string{
"types": "2",
"dayTime": recordBegin.Local().Format("2006-01-02"),
"interval": strconv.Itoa(subDay),
"noticeWho": strings.Join(noticeWho, ","),
})
}
tk.AnomalyDesc = append(tk.AnomalyDesc, r)
switch val.Category {
case domain.AnomalyCategoryType3:
//辅导异常
{
recordBegin := time.Unix(val3.RecordBegin, 0)
subDay := xtime.SubDayAbs(val3.CreatedAt, recordBegin)
tk.AnomalyDesc = append(tk.AnomalyDesc, fmt.Sprintf(
"本任务计划于%s完成辅导,已逾期%d天",
recordBegin.Local().Format("2006-01-02"),
subDay,
))
tk.AnomalyDesc2 = append(tk.AnomalyDesc2, map[string]string{
"types": "3",
"dayTime": recordBegin.Local().Format("2006-01-02"),
"interval": strconv.Itoa(subDay),
"noticeWho": strings.Join(noticeWho, ","),
})
}
}
userId := strconv.Itoa(param.UserId)
switch val3.Category {
case domain.AnomalyCategoryType1:
tk.Marks["a"] = val.Marks["a"]
tk.Marks["c"] = val.Marks["c"]
if userId == val.LeaderId {
tk.Marks["a"] = val3.Marks["a"]
tk.Marks["c"] = val3.Marks["c"]
} else {
tk.Marks["d"] = val3.Marks["d"]
}
case domain.AnomalyCategoryType2:
tk.Marks["b"] = val.Marks["b"]
tk.Marks["b"] = val3.Marks["b"]
case domain.AnomalyCategoryType3:
tk.Marks["d"] = val.Marks["d"]
tk.Marks["d"] = val3.Marks["d"]
}
}
taskResult = append(taskResult, &tk)
... ... @@ -1394,6 +1465,7 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s
PlanCompletedAt: time.Unix(int64(val.CurrentStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
RealCompletedAt: "",
},
Marks: map[string]string{},
}
if val.LastStage.RealCompletedAt > 0 {
tk.LastStage.RealCompletedAt = time.Unix(int64(val.LastStage.RealCompletedAt), 0).Local().Format("2006-01-02")
... ... @@ -1439,27 +1511,97 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s
}
}
tk.GenStatusDescript()
for _, val := range taskAnomalyList {
if tk.Id != val.TaskId {
for _, val3 := range taskAnomalyList {
if tk.Id != val3.TaskId {
continue
}
if len(val.Marks) == 0 {
val.Marks = map[string]string{}
if val3.Marks == nil {
val3.Marks = map[string]string{}
}
r := val.Remark + ",该条异常已通知"
for _, val2 := range val.NoticeWho {
r += val2["name"] + " "
noticeWho := []string{}
for _, val2 := range val3.NoticeWho {
noticeWho = append(noticeWho, val2["name"])
}
tk.AnomalyDesc = append(tk.AnomalyDesc, r)
tk.Marks = map[string]string{}
switch val.Category {
switch val3.Category {
case domain.AnomalyCategoryType1:
tk.Marks["a"] = val.Marks["a"]
tk.Marks["c"] = val.Marks["c"]
{
//里程碑异常
if val3.TaskStageCheck.RealCompletedAt == 0 && val3.TaskStageCheck.Id > 0 {
//逾期未完成
planCompletedAt := time.Unix(val3.TaskStageCheck.PlanCompletedAt, 0)
subDay := xtime.SubDayAbs(val3.CreatedAt, planCompletedAt)
tk.AnomalyDesc = append(tk.AnomalyDesc, fmt.Sprintf("里程碑%s已逾期%d天", val3.TaskStageCheck.Name, subDay))
tk.AnomalyDesc2 = append(tk.AnomalyDesc2, map[string]string{
"types": "10",
"stageName": val3.TaskStageCheck.Name,
"interval": strconv.Itoa(subDay),
"noticeWho": strings.Join(noticeWho, ","),
})
} else if val3.TaskStageCheck.RealCompletedAt > 0 && val3.TaskStageCheck.Id > 0 {
//逾期完成
planCompletedAt := time.Unix(val3.TaskStageCheck.PlanCompletedAt, 0)
realCompletedAt := time.Unix(val3.TaskStageCheck.RealCompletedAt, 0)
subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt)
tk.AnomalyDesc = append(tk.AnomalyDesc, fmt.Sprintf("里程碑%s逾期%d天完成", val3.TaskStageCheck.Name, subDay))
tk.AnomalyDesc2 = append(tk.AnomalyDesc2, map[string]string{
"types": "11",
"stageName": val3.TaskStageCheck.Name,
"interval": strconv.Itoa(subDay),
"noticeWho": strings.Join(noticeWho, ","),
})
}
}
case domain.AnomalyCategoryType2:
//反馈异常
{
recordBegin := time.Unix(val3.RecordBegin, 0)
subDay := xtime.SubDayAbs(val3.CreatedAt, recordBegin)
tk.AnomalyDesc = append(tk.AnomalyDesc, fmt.Sprintf(
"本任务自%s未正常反馈项目进度,已异常%d天",
recordBegin.Local().Format("2006-01-02"),
subDay,
))
tk.AnomalyDesc2 = append(tk.AnomalyDesc2, map[string]string{
"types": "2",
"dayTime": recordBegin.Local().Format("2006-01-02"),
"interval": strconv.Itoa(subDay),
"noticeWho": strings.Join(noticeWho, ","),
})
}
case domain.AnomalyCategoryType3:
//辅导异常
{
recordBegin := time.Unix(val3.RecordBegin, 0)
subDay := xtime.SubDayAbs(val3.CreatedAt, recordBegin)
tk.AnomalyDesc = append(tk.AnomalyDesc, fmt.Sprintf(
"本任务计划于%s完成辅导,已逾期%d天",
recordBegin.Local().Format("2006-01-02"),
subDay,
))
tk.AnomalyDesc2 = append(tk.AnomalyDesc2, map[string]string{
"types": "3",
"dayTime": recordBegin.Local().Format("2006-01-02"),
"interval": strconv.Itoa(subDay),
"noticeWho": strings.Join(noticeWho, ","),
})
}
}
if len(val3.Marks) == 0 {
val3.Marks = map[string]string{}
}
userId := strconv.Itoa(param.UserId)
switch val3.Category {
case domain.AnomalyCategoryType1:
if userId == val.LeaderId {
tk.Marks["a"] = val3.Marks["a"]
tk.Marks["c"] = val3.Marks["c"]
} else {
tk.Marks["d"] = val3.Marks["d"]
}
case domain.AnomalyCategoryType2:
tk.Marks["b"] = val.Marks["b"]
tk.Marks["b"] = val3.Marks["b"]
case domain.AnomalyCategoryType3:
tk.Marks["d"] = val.Marks["d"]
tk.Marks["d"] = val3.Marks["d"]
}
}
taskResult = append(taskResult, &tk)
... ...
... ... @@ -980,7 +980,23 @@ func (srv TaskService) MarkTaskAnomalyByTask(param *command.MarkTaskAnomalyComma
}, nil
}
taskData := taskList[0]
_, anomalyList, err := taskAnomalyRepo.Find(map[string]interface{}{"isLast": 1, "companyId": param.CompanyId, "taskId": taskData.Id})
var category int
switch param.MarkType {
case "a":
category = domain.AnomalyCategoryType1
case "b":
category = domain.AnomalyCategoryType2
case "c":
category = domain.AnomalyCategoryType3
case "d":
category = domain.AnomalyCategoryType3
default:
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "MarkType error")
}
_, anomalyList, err := taskAnomalyRepo.Find(map[string]interface{}{
"isLast": 1, "companyId": param.CompanyId,
"taskId": taskData.Id, "category": category,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
package domain
import (
"time"
)
// 对异常记录的操作标记
type TaskAnomalyMark struct {
Id int
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CompanyId int `json:"companyId,string"` // 公司id
UserId int `json:"userId,string"` // 操作人id
TaskId int `json:"taskId,string"` // 任务id
TaskAnomalyId int `json:"taskAnomalyId,string"` // 异常记录id
Marks string `json:"marks"` // 已经操作的标记
}
// 已点击“去更新”
func (t *TaskAnomalyMark) MarkA() {
t.Marks = "已更新"
}
// 已点击 "去反馈"
func (t *TaskAnomalyMark) MarkB() {
t.Marks = "已反馈"
}
// 已点击 "找上级"
func (t *TaskAnomalyMark) MarkC() {
t.Marks = "已求助"
}
// 已点击 "去辅导"
func (t *TaskAnomalyMark) MarkD() {
t.Marks = "已辅导"
}
type TaskAnomalyMarkRepository interface {
Save(param *TaskAnomalyMark) error
FindOne(queryOptions map[string]interface{}) (*TaskAnomalyMark, error)
Find(queryOptions map[string]interface{}) (int, []*TaskAnomalyMark, error)
}
... ... @@ -475,6 +475,7 @@ type ListTask struct {
TaskId int `pg:"task_id"`
Alias string `pg:"alias"`
LeaderName string `pg:"leader_name"`
LeaderId string `pg:"leader_id"`
Level int `pg:"level"`
LevelName string `pg:"level_name"`
Anomaly int `pg:"anomaly"`
... ... @@ -506,6 +507,7 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error)
task.id ,
task.alias ,
task.leader ->>'name' as leader_name,
task.leader ->>'id' as leader_id,
task."level",
task.level_name ,
task.anomaly ,
... ... @@ -538,6 +540,7 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error)
t_task.id as task_id,
t_task.alias ,
t_task.leader_name,
t_task.leader_id,
t_task."level",
t_task.level_name ,
t_task.anomaly ,
... ... @@ -591,6 +594,7 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error)
task.id ,
task.alias ,
task.leader ->>'name' as leader_name,
task.leader ->>'id' as leader_id,
task."level",
task.level_name ,
task.anomaly ,
... ... @@ -622,6 +626,7 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error)
t_task.id as task_id,
t_task.alias ,
t_task.leader_name,
t_task.leader_id,
t_task."level",
t_task.level_name ,
t_task.anomaly ,
... ... @@ -674,6 +679,7 @@ func (d *TaskDao) ListTaskIgnore(param ListTaskCondition) ([]ListTask, error) {
task.id as task_id ,
task.alias ,
task.leader ->>'name' as leader_name,
task.leader ->>'id' as leader_id,
task."level" ,
task.level_name ,
task.anomaly ,
... ...
-- 增加任务记录字段
ALTER TABLE public.task_record
ADD remark_content jsonb NULL;
COMMENT ON COLUMN public.task_record.remark_content IS '填写反馈进度';
-- 增加任务记录字段
ALTER TABLE public.task_record
ADD task_created_by int NOT NULL DEFAULT 0;
... ... @@ -18,3 +15,27 @@ ALTER TABLE public.task_record
ADD assist_state int NOT NULL DEFAULT 1;
COMMENT ON COLUMN public.task_record.assist_state IS '辅导异常状态';
-- task_record 处理旧数据
WITH t_taff_assess_content AS (
SELECT
staff_assess_content.staff_assess_id,
staff_assess_content.category,
staff_assess_content."name",
staff_assess_content.remark
FROM
task_record
JOIN staff_assess_content ON task_record.staff_assess_id = staff_assess_content.staff_assess_id
AND staff_assess_content."name" = task_record.task_name
WHERE
1 = 1)
UPDATE
task_record
SET
remark_content = t_taff_assess_content.remark
FROM
t_taff_assess_content
WHERE
task_record.staff_assess_id = t_taff_assess_content.staff_assess_id
AND t_taff_assess_content."name" = task_record.task_name;
... ...