作者 tangxvhui

暂存

package adapter
type TaskAnomalyItem struct {
Id int `json:"id"`
Id int `json:"id,string"`
TaskId int `json:"taskId,string"` // 任务id
TaskRecordId int `json:"taskRecordId,string"` // 任务反馈记录id
Category int `json:"category"` // 异常分类
Leader string `json:"leader"` // 任务负责人
CurrentStage TaskStage `json:"currentStage"` // 计划进度的里程碑
LastStage TaskStage `json:"lastStage"` // 实际进度完成的里程碑
TaskStageCheck TaskStage `json:"taskStageCheck"`
AssessFlag int `json:"anomaly"` // 异常反馈的次数
TaskStageCheck TaskStage `json:"taskStageCheck"` // 实际进度完成的里程碑
AssessFlag int `json:"assessFlag"` // 异常反馈的次数
WarnFlag int `json:"warnFlag"` // 里程碑异常次数
AssistFlag int `json:"assistFlag"` // 辅导异常次数
TaskLevel string `json:"taskLevel"` // 任务类型
... ... @@ -23,51 +24,3 @@ type TaskAnomalyItem struct {
MarkD string `json:"markD"` // 去辅导
AnomalyDesc string `json:"anomalyDesc"` // 异常状况描述
}
// func (t *TaskAnomalyItem) GenAnomalyDesc() {
// nowTime := time.Now()
// var str string
// switch t.Category {
// case 1:
// //里程碑异常
// {
// if t.TaskStageCheck.RealCompletedAt == 0 {
// //逾期未完成
// planCompletedAt := time.Unix(t.TaskStageCheck.PlanCompletedAt, 0)
// subDay := xtime.SubDayAbs(nowTime, planCompletedAt)
// str = fmt.Sprintf("里程碑%s已逾期%d天", t.TaskStageCheck.Name, subDay)
// } else {
// //逾期完成
// planCompletedAt := time.Unix(t.TaskStageCheck.PlanCompletedAt, 0)
// realCompletedAt := time.Unix(t.TaskStageCheck.RealCompletedAt, 0)
// subDay := xtime.SubDayAbs(realCompletedAt, planCompletedAt)
// str = fmt.Sprintf("里程碑%s逾期%d天完成", t.TaskStageCheck.Name, subDay)
// }
// }
// case 2:
// //反馈异常
// {
// recordBegin := time.Unix(t.RecordBegin, 0)
// subDay := xtime.SubDayAbs(nowTime, recordBegin)
// str = fmt.Sprintf(
// "本任务自%s未正常反馈项目进度,已异常%d天",
// recordBegin.Local().Format("2006-01-02"),
// subDay,
// )
// }
// case 3:
// // 辅导异常
// {
// recordBegin := time.Unix(t.RecordBegin, 0)
// subDay := xtime.SubDayAbs(nowTime, recordBegin)
// str = fmt.Sprintf(
// "本任务计划于%s完成辅导,已逾期%d天",
// recordBegin.Local().Format("2006-01-02"),
// subDay,
// )
// }
// }
// }
... ...
... ... @@ -8,5 +8,5 @@ type ListTaskAnomalyCommand struct {
TaskName string `json:"taskName"`
DayTime string `json:"dayTime"` //发生异常的日期
Category int `json:"category"` //异常分类
TaskLeaderId string `json:"taskLeaderId"` //任务负责人id
leaderId string `json:"leaderId"` //任务负责人id
}
... ...
... ... @@ -16,7 +16,7 @@ import (
// 异常中心查看
// 我负责的任务,异常列表
func (srv TaskService) ListTaskAnomaly1(param command.ListTaskAnomalyCommand) (map[string]interface{}, error) {
func (srv TaskService) ListTaskAnomaly1(param *command.ListTaskAnomalyCommand) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -47,6 +47,7 @@ func (srv TaskService) ListTaskAnomaly1(param command.ListTaskAnomalyCommand) (m
item := adapter.TaskAnomalyItem{
Id: val.Id,
TaskId: val.TaskId,
TaskRecordId: val.TaskRecordId,
Category: val.Category,
Leader: val.LeaderName,
CurrentStage: adapter.TaskStage{
... ... @@ -85,9 +86,6 @@ func (srv TaskService) ListTaskAnomaly1(param command.ListTaskAnomalyCommand) (m
item.MarkC = val.Marks["c"]
item.MarkD = val.Marks["d"]
}
if val.TaskStageCheck.RealCompletedAt > 0 {
item.TaskStageCheck.RealCompletedAt = time.Unix(val.TaskStageCheck.RealCompletedAt, 0).Local().Format("2006-01-02")
}
if val.CurrentStage.RealCompletedAt > 0 {
item.CurrentStage.RealCompletedAt = time.Unix(val.CurrentStage.RealCompletedAt, 0).Local().Format("2006-01-02")
}
... ... @@ -98,12 +96,12 @@ func (srv TaskService) ListTaskAnomaly1(param command.ListTaskAnomalyCommand) (m
case 1:
{
//里程碑异常
if val.TaskStageCheck.RealCompletedAt == 0 {
if val.TaskStageCheck.RealCompletedAt == 0 && val.TaskStageCheck.Id > 0 {
//逾期未完成
planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
subDay := xtime.SubDayAbs(nowTime, planCompletedAt)
item.AnomalyDesc = fmt.Sprintf("里程碑%s已逾期%d天", val.TaskStageCheck.Name, subDay)
} else {
} else if val.TaskStageCheck.RealCompletedAt > 0 && val.TaskStageCheck.Id > 0 {
//逾期完成
planCompletedAt := time.Unix(val.TaskStageCheck.PlanCompletedAt, 0)
realCompletedAt := time.Unix(val.TaskStageCheck.RealCompletedAt, 0)
... ... @@ -143,10 +141,16 @@ func (srv TaskService) ListTaskAnomaly1(param command.ListTaskAnomalyCommand) (m
}
// 我的下级负责任务,异常列表
func (srv TaskService) ListTaskAnomaly2() {}
func (srv TaskService) ListTaskAnomaly2() error {
return nil
}
// 与我有关的任务,异常列表
func (srv TaskService) ListTaskAnomaly3() {}
func (srv TaskService) ListTaskAnomaly3() error {
return nil
}
// 对异常记录的操作标记
func (srv TaskService) MarkTaskAnomaly() {}
func (srv TaskService) MarkTaskAnomaly() error {
return nil
}
... ...
... ... @@ -30,7 +30,10 @@ type TaskStageRepository interface {
}
// 描述里程碑完成情况
func (t TaskStage) StatusDescription() string {
func (t *TaskStage) StatusDescription() string {
if t.Id == 0 {
return ""
}
nowDay := time.Now().Format("2006-01-02")
nowTime, _ := time.ParseInLocation("2006-01-02", nowDay, time.Local)
... ...
... ... @@ -9,7 +9,7 @@ import (
func TestGenerateToken(t *testing.T) {
ut := UserAuth{
CompanyId: 8,
UserId: 3422185340122624,
UserId: 3422174102828544,
Phone: "13066667710",
PlatformId: 29,
AdminType: 1,
... ...
... ... @@ -26,6 +26,7 @@ func NewTaskAnomalyDao(options map[string]interface{}) *TaskAnomalyDao {
type ListTaskAnomaly struct {
Id int `pg:"id"`
TaskId int `pg:"task_id"`
TaskRecordId int `pg:"task_record_id"`
Category int `pg:"category"`
CurrentStage domain.TaskStage `pg:"current_stage"` // 计划执行的里程碑
LastStage domain.TaskStage `pg:"last_stage"` // 上一个完成的里程碑
... ... @@ -58,6 +59,7 @@ func (d *TaskAnomalyDao) List1(userId int, companyId int, taskName string, categ
)select
task_anomaly.id,
task_anomaly.task_id,
task_anomaly.task_record_id,
task_anomaly.category,
task_anomaly.current_stage,
task_anomaly.last_stage,
... ... @@ -148,6 +150,7 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ
)select
task_anomaly.id,
task_anomaly.task_id,
task_anomaly.task_record_id,
task_anomaly.category,
task_anomaly.current_stage,
task_anomaly.last_stage,
... ...
... ... @@ -250,3 +250,19 @@ func (c *TaskController) CancelIgnore() {
c.Response(nil, err)
}
func (c *TaskController) TaskAnomalyList1() {
srv := service.NewTaskService()
paramReq := &command.ListTaskAnomalyCommand{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.UserId = int(userReq.UserId)
resp, err := srv.ListTaskAnomaly1(paramReq)
c.Response(resp, err)
}
... ...
... ... @@ -34,4 +34,9 @@ func init() {
web.NSCtrlPost("/ignore/cancel", (*controllers.TaskController).CancelIgnore),
)
web.AddNamespace(taskFontNS)
taskAnomalyNS := web.NewNamespace("/v1/font",
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
web.NSCtrlPost("/task_anomaly/my_task", (*controllers.TaskController).TaskAnomalyList1),
)
web.AddNamespace(taskAnomalyNS)
}
... ...