...
|
...
|
@@ -42,7 +42,6 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
|
|
}
|
|
|
|
|
|
listData := []adapter.TaskAnomalyItem{}
|
|
|
nowTime := time.Now()
|
|
|
for _, val := range anomalyList {
|
|
|
item := adapter.TaskAnomalyItem{
|
|
|
Id: val.Id,
|
...
|
...
|
@@ -99,7 +98,7 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
|
|
if val.TaskStageCheck.RealCompletedAt == 0 && val.TaskStageCheck.Id > 0 {
|
|
|
//逾期未完成
|
|
|
planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
subDay := xtime.SubDayAbs(nowTime, planCompletedAt)
|
|
|
subDay := xtime.SubDayAbs(val.CreatedAt, planCompletedAt)
|
|
|
item.AnomalyDesc = fmt.Sprintf("里程碑%s已逾期%d天", val.TaskStageCheck.Name, subDay)
|
|
|
} else if val.TaskStageCheck.RealCompletedAt > 0 && val.TaskStageCheck.Id > 0 {
|
|
|
//逾期完成
|
...
|
...
|
@@ -113,7 +112,7 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
|
|
//反馈异常
|
|
|
{
|
|
|
recordBegin := time.Unix(val.RecordBegin, 0)
|
|
|
subDay := xtime.SubDayAbs(nowTime, recordBegin)
|
|
|
subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
|
|
item.AnomalyDesc = fmt.Sprintf(
|
|
|
"本任务自%s未正常反馈项目进度,已异常%d天",
|
|
|
recordBegin.Local().Format("2006-01-02"),
|
...
|
...
|
@@ -124,7 +123,7 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
|
|
//辅导异常
|
|
|
{
|
|
|
recordBegin := time.Unix(val.RecordBegin, 0)
|
|
|
subDay := xtime.SubDayAbs(nowTime, recordBegin)
|
|
|
subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
|
|
item.AnomalyDesc = fmt.Sprintf(
|
|
|
"本任务计划于%s完成辅导,已逾期%d天",
|
|
|
recordBegin.Local().Format("2006-01-02"),
|
...
|
...
|
@@ -141,13 +140,253 @@ func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) ( |
|
|
}
|
|
|
|
|
|
// 我的下级负责任务,异常列表
|
|
|
func (srv TaskService) ListTaskAnomaly2() error {
|
|
|
return nil
|
|
|
func (srv TaskService) ListTaskAnomaly2(param *command.ListTaskAnomalyCommand) (map[string]interface{}, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
taskAnomalyDao := dao.NewTaskAnomalyDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
limit := 500
|
|
|
offset := 0
|
|
|
cnt, anomalyList, err := taskAnomalyDao.List2(param.UserId, param.CompanyId, param.TaskName, param.Category, param.DayTime, param.LeaderId, limit, offset)
|
|
|
if err != nil {
|
|
|
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
listData := []adapter.TaskAnomalyItem{}
|
|
|
|
|
|
for _, val := range anomalyList {
|
|
|
item := adapter.TaskAnomalyItem{
|
|
|
Id: val.Id,
|
|
|
TaskId: val.TaskId,
|
|
|
TaskRecordId: val.TaskRecordId,
|
|
|
Category: val.Category,
|
|
|
Leader: val.LeaderName,
|
|
|
CurrentStage: adapter.TaskStage{
|
|
|
Id: val.CurrentStage.Id,
|
|
|
Name: val.CurrentStage.Name,
|
|
|
StatusDescription: val.CurrentStage.StatusDescription(),
|
|
|
SortBy: val.CurrentStage.SortBy,
|
|
|
PlanCompletedAt: time.Unix(val.CurrentStage.PlanCompletedAt, 0).Local().Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
},
|
|
|
LastStage: adapter.TaskStage{
|
|
|
Id: val.LastStage.Id,
|
|
|
Name: val.LastStage.Name,
|
|
|
StatusDescription: val.LastStage.StatusDescription(),
|
|
|
SortBy: val.LastStage.SortBy,
|
|
|
PlanCompletedAt: time.Unix(val.LastStage.PlanCompletedAt, 0).Local().Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
},
|
|
|
AssessFlag: val.AssessFlag,
|
|
|
WarnFlag: val.WarnFlag,
|
|
|
AssistFlag: val.AssistFlag,
|
|
|
TaskLevel: val.LevelName,
|
|
|
TaskName: val.TaskName,
|
|
|
TaskAlias: val.TaskAlias,
|
|
|
TaskEndTime: int64(val.TaskEndTime),
|
|
|
TaskSortBy: val.TaskSortBy,
|
|
|
RecordBegin: val.RecordBegin,
|
|
|
MarkA: "",
|
|
|
MarkB: "",
|
|
|
MarkC: "",
|
|
|
MarkD: "",
|
|
|
}
|
|
|
if len(val.Marks) > 0 {
|
|
|
item.MarkA = val.Marks["a"]
|
|
|
item.MarkB = val.Marks["b"]
|
|
|
item.MarkC = val.Marks["c"]
|
|
|
item.MarkD = val.Marks["d"]
|
|
|
}
|
|
|
if val.CurrentStage.RealCompletedAt > 0 {
|
|
|
item.CurrentStage.RealCompletedAt = time.Unix(val.CurrentStage.RealCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
if val.LastStage.RealCompletedAt > 0 {
|
|
|
item.LastStage.RealCompletedAt = time.Unix(val.LastStage.RealCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
switch val.Category {
|
|
|
case 1:
|
|
|
{
|
|
|
//里程碑异常
|
|
|
if val.TaskStageCheck.RealCompletedAt == 0 && val.TaskStageCheck.Id > 0 {
|
|
|
//逾期未完成
|
|
|
planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
subDay := xtime.SubDayAbs(val.CreatedAt, planCompletedAt)
|
|
|
item.AnomalyDesc = fmt.Sprintf("里程碑%s已逾期%d天", val.TaskStageCheck.Name, subDay)
|
|
|
} else if val.TaskStageCheck.RealCompletedAt > 0 && val.TaskStageCheck.Id > 0 {
|
|
|
//逾期完成
|
|
|
planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
realCompletedAt := time.Unix(val.TaskStageCheck.RealCompletedAt, 0)
|
|
|
subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt)
|
|
|
item.AnomalyDesc = fmt.Sprintf("里程碑%s逾期%d天完成", val.TaskStageCheck.Name, subDay)
|
|
|
}
|
|
|
}
|
|
|
case 2:
|
|
|
//反馈异常
|
|
|
{
|
|
|
recordBegin := time.Unix(val.RecordBegin, 0)
|
|
|
subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
|
|
item.AnomalyDesc = fmt.Sprintf(
|
|
|
"本任务自%s未正常反馈项目进度,已异常%d天",
|
|
|
recordBegin.Local().Format("2006-01-02"),
|
|
|
subDay,
|
|
|
)
|
|
|
}
|
|
|
case 3:
|
|
|
//辅导异常
|
|
|
{
|
|
|
recordBegin := time.Unix(val.RecordBegin, 0)
|
|
|
subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
|
|
item.AnomalyDesc = fmt.Sprintf(
|
|
|
"本任务计划于%s完成辅导,已逾期%d天",
|
|
|
recordBegin.Local().Format("2006-01-02"),
|
|
|
subDay,
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
listData = append(listData, item)
|
|
|
}
|
|
|
|
|
|
result := tool_funs.SimpleWrapGridMap(int64(cnt), listData)
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// 与我有关的任务,异常列表
|
|
|
func (srv TaskService) ListTaskAnomaly3() error {
|
|
|
return nil
|
|
|
func (srv TaskService) ListTaskAnomaly3(param *command.ListTaskAnomalyCommand) (map[string]interface{}, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
taskAnomalyDao := dao.NewTaskAnomalyDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
limit := 500
|
|
|
offset := 0
|
|
|
cnt, anomalyList, err := taskAnomalyDao.List3(param.UserId, param.CompanyId, param.TaskName, param.Category, param.DayTime, param.LeaderId, limit, offset)
|
|
|
if err != nil {
|
|
|
return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
listData := []adapter.TaskAnomalyItem{}
|
|
|
|
|
|
for _, val := range anomalyList {
|
|
|
item := adapter.TaskAnomalyItem{
|
|
|
Id: val.Id,
|
|
|
TaskId: val.TaskId,
|
|
|
TaskRecordId: val.TaskRecordId,
|
|
|
Category: val.Category,
|
|
|
Leader: val.LeaderName,
|
|
|
CurrentStage: adapter.TaskStage{
|
|
|
Id: val.CurrentStage.Id,
|
|
|
Name: val.CurrentStage.Name,
|
|
|
StatusDescription: val.CurrentStage.StatusDescription(),
|
|
|
SortBy: val.CurrentStage.SortBy,
|
|
|
PlanCompletedAt: time.Unix(val.CurrentStage.PlanCompletedAt, 0).Local().Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
},
|
|
|
LastStage: adapter.TaskStage{
|
|
|
Id: val.LastStage.Id,
|
|
|
Name: val.LastStage.Name,
|
|
|
StatusDescription: val.LastStage.StatusDescription(),
|
|
|
SortBy: val.LastStage.SortBy,
|
|
|
PlanCompletedAt: time.Unix(val.LastStage.PlanCompletedAt, 0).Local().Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
},
|
|
|
AssessFlag: val.AssessFlag,
|
|
|
WarnFlag: val.WarnFlag,
|
|
|
AssistFlag: val.AssistFlag,
|
|
|
TaskLevel: val.LevelName,
|
|
|
TaskName: val.TaskName,
|
|
|
TaskAlias: val.TaskAlias,
|
|
|
TaskEndTime: int64(val.TaskEndTime),
|
|
|
TaskSortBy: val.TaskSortBy,
|
|
|
RecordBegin: val.RecordBegin,
|
|
|
MarkA: "",
|
|
|
MarkB: "",
|
|
|
MarkC: "",
|
|
|
MarkD: "",
|
|
|
}
|
|
|
if len(val.Marks) > 0 {
|
|
|
item.MarkA = val.Marks["a"]
|
|
|
item.MarkB = val.Marks["b"]
|
|
|
item.MarkC = val.Marks["c"]
|
|
|
item.MarkD = val.Marks["d"]
|
|
|
}
|
|
|
if val.CurrentStage.RealCompletedAt > 0 {
|
|
|
item.CurrentStage.RealCompletedAt = time.Unix(val.CurrentStage.RealCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
if val.LastStage.RealCompletedAt > 0 {
|
|
|
item.LastStage.RealCompletedAt = time.Unix(val.LastStage.RealCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
switch val.Category {
|
|
|
case 1:
|
|
|
{
|
|
|
//里程碑异常
|
|
|
if val.TaskStageCheck.RealCompletedAt == 0 && val.TaskStageCheck.Id > 0 {
|
|
|
//逾期未完成
|
|
|
planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
subDay := xtime.SubDayAbs(val.CreatedAt, planCompletedAt)
|
|
|
item.AnomalyDesc = fmt.Sprintf("里程碑%s已逾期%d天", val.TaskStageCheck.Name, subDay)
|
|
|
} else if val.TaskStageCheck.RealCompletedAt > 0 && val.TaskStageCheck.Id > 0 {
|
|
|
//逾期完成
|
|
|
planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
|
|
|
realCompletedAt := time.Unix(val.TaskStageCheck.RealCompletedAt, 0)
|
|
|
subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt)
|
|
|
item.AnomalyDesc = fmt.Sprintf("里程碑%s逾期%d天完成", val.TaskStageCheck.Name, subDay)
|
|
|
}
|
|
|
}
|
|
|
case 2:
|
|
|
//反馈异常
|
|
|
{
|
|
|
recordBegin := time.Unix(val.RecordBegin, 0)
|
|
|
subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
|
|
item.AnomalyDesc = fmt.Sprintf(
|
|
|
"本任务自%s未正常反馈项目进度,已异常%d天",
|
|
|
recordBegin.Local().Format("2006-01-02"),
|
|
|
subDay,
|
|
|
)
|
|
|
}
|
|
|
case 3:
|
|
|
//辅导异常
|
|
|
{
|
|
|
recordBegin := time.Unix(val.RecordBegin, 0)
|
|
|
subDay := xtime.SubDayAbs(val.CreatedAt, recordBegin)
|
|
|
item.AnomalyDesc = fmt.Sprintf(
|
|
|
"本任务计划于%s完成辅导,已逾期%d天",
|
|
|
recordBegin.Local().Format("2006-01-02"),
|
|
|
subDay,
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
listData = append(listData, item)
|
|
|
}
|
|
|
|
|
|
result := tool_funs.SimpleWrapGridMap(int64(cnt), listData)
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// 对异常记录的操作标记
|
...
|
...
|
|