Merge branch 'feat-cjy-taskBench' into dev
This commit is contained in:
commit
1838187a64
@ -467,21 +467,37 @@ func UpdateTaskProgress(req *CompleteTaskRequest) error {
|
||||
return commonErr.ReturnError(err, "查询指派记录失败", "查询指派记录失败: ")
|
||||
}
|
||||
} else {
|
||||
// 如果没有提供UUID,根据员工信息查询最早的未完成任务
|
||||
// 如果没有提供UUID,根据员工信息与任务类型筛选最早的未手动完成任务
|
||||
if req.EmployeeName == "" || req.EmployeeNum == "" {
|
||||
tx.Rollback()
|
||||
return commonErr.ReturnError(nil, "参数错误", "员工姓名和手机号不能为空")
|
||||
}
|
||||
|
||||
err = tx.Where("task_assignee = ? AND task_assignee_num = ? AND actual_status = 1",
|
||||
req.EmployeeName, req.EmployeeNum).
|
||||
// 仅选择“未手动完成”的记录
|
||||
query := tx.Where("task_assignee = ? AND task_assignee_num = ? AND status = 1",
|
||||
req.EmployeeName, req.EmployeeNum)
|
||||
|
||||
// 根据任务类型,要求该类型仍有可完成的余量
|
||||
switch req.TaskType {
|
||||
case "video":
|
||||
query = query.Where("pending_video_count > 0 AND complete_video_count < assign_video_count")
|
||||
case "post":
|
||||
query = query.Where("pending_post_count > 0 AND complete_post_count < assign_post_count")
|
||||
case "data":
|
||||
query = query.Where("pending_data_count > 0 AND complete_data_count < assign_data_count")
|
||||
default:
|
||||
tx.Rollback()
|
||||
return commonErr.ReturnError(nil, "无效的任务类型", "任务类型必须是video、post或data")
|
||||
}
|
||||
|
||||
err = query.
|
||||
Order("operator_time ASC").
|
||||
First(&assignRecord).Error
|
||||
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
tx.Rollback()
|
||||
return commonErr.ReturnError(nil, "未找到任务记录", "该员工没有未完成的任务记录")
|
||||
return commonErr.ReturnError(nil, "未找到任务记录", "该员工没有符合条件的未手动完成任务记录")
|
||||
}
|
||||
tx.Rollback()
|
||||
return commonErr.ReturnError(err, "查询指派记录失败", "查询指派记录失败: ")
|
||||
@ -497,51 +513,129 @@ func UpdateTaskProgress(req *CompleteTaskRequest) error {
|
||||
case "video":
|
||||
newCompleteCount := assignRecord.CompleteVideoCount + req.CompleteCount
|
||||
if newCompleteCount > assignRecord.AssignVideoCount {
|
||||
// 记录超限日志,但不返回错误
|
||||
app.ModuleClients.Lg.Info("视频完成数量超出限制",
|
||||
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
||||
zap.String("employeeName", req.EmployeeName),
|
||||
zap.String("employeeNum", req.EmployeeNum),
|
||||
zap.Int("currentCompleteCount", assignRecord.CompleteVideoCount),
|
||||
zap.Int("requestCompleteCount", req.CompleteCount),
|
||||
zap.Int("newCompleteCount", newCompleteCount),
|
||||
zap.Int("assignVideoCount", assignRecord.AssignVideoCount),
|
||||
)
|
||||
// 暂时都只记录错误,不报错;并且不更新
|
||||
if req.AssignRecordsUUID != "false" {
|
||||
app.ModuleClients.Lg.Info("视频完成数量超出限制,跳过更新",
|
||||
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
||||
zap.String("employeeName", req.EmployeeName),
|
||||
zap.String("employeeNum", req.EmployeeNum),
|
||||
zap.Int("currentCompleteCount", assignRecord.CompleteVideoCount),
|
||||
zap.Int("requestCompleteCount", req.CompleteCount),
|
||||
zap.Int("newCompleteCount", newCompleteCount),
|
||||
zap.Int("assignVideoCount", assignRecord.AssignVideoCount),
|
||||
)
|
||||
tx.Rollback()
|
||||
return nil
|
||||
} else {
|
||||
tx.Rollback()
|
||||
return commonErr.ReturnError(nil, "完成数量超出指派数量", "视频完成数量不能超过已指派数量")
|
||||
}
|
||||
}
|
||||
newPending := assignRecord.PendingVideoCount - req.CompleteCount
|
||||
if newPending < 0 {
|
||||
// 暂时都只记录错误,不报错;并且不更新
|
||||
if req.AssignRecordsUUID != "false" {
|
||||
app.ModuleClients.Lg.Info("待发视频数不足,跳过更新",
|
||||
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
||||
zap.String("employeeName", req.EmployeeName),
|
||||
zap.String("employeeNum", req.EmployeeNum),
|
||||
zap.Int("currentPendingCount", assignRecord.PendingVideoCount),
|
||||
zap.Int("requestCompleteCount", req.CompleteCount),
|
||||
zap.Int("newPendingCount", newPending),
|
||||
)
|
||||
tx.Rollback()
|
||||
return nil
|
||||
} else {
|
||||
tx.Rollback()
|
||||
return commonErr.ReturnError(nil, "待发视频数不足", "待发视频数不能小于0")
|
||||
}
|
||||
}
|
||||
updateData["complete_video_count"] = newCompleteCount
|
||||
updateData["pending_video_count"] = assignRecord.PendingVideoCount - req.CompleteCount
|
||||
updateData["pending_video_count"] = newPending
|
||||
case "post":
|
||||
newCompleteCount := assignRecord.CompletePostCount + req.CompleteCount
|
||||
if newCompleteCount > assignRecord.AssignPostCount {
|
||||
// 记录超限日志,但不返回错误
|
||||
app.ModuleClients.Lg.Info("图文完成数量超出限制",
|
||||
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
||||
zap.String("employeeName", req.EmployeeName),
|
||||
zap.String("employeeNum", req.EmployeeNum),
|
||||
zap.Int("currentCompleteCount", assignRecord.CompletePostCount),
|
||||
zap.Int("requestCompleteCount", req.CompleteCount),
|
||||
zap.Int("newCompleteCount", newCompleteCount),
|
||||
zap.Int("assignPostCount", assignRecord.AssignPostCount),
|
||||
)
|
||||
// 暂时先只记录,不报错;并且不更新
|
||||
if req.AssignRecordsUUID != "false" {
|
||||
app.ModuleClients.Lg.Info("图文完成数量超出限制,跳过更新",
|
||||
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
||||
zap.String("employeeName", req.EmployeeName),
|
||||
zap.String("employeeNum", req.EmployeeNum),
|
||||
zap.Int("currentCompleteCount", assignRecord.CompletePostCount),
|
||||
zap.Int("requestCompleteCount", req.CompleteCount),
|
||||
zap.Int("newCompleteCount", newCompleteCount),
|
||||
zap.Int("assignPostCount", assignRecord.AssignPostCount),
|
||||
)
|
||||
tx.Rollback()
|
||||
return nil
|
||||
} else {
|
||||
tx.Rollback()
|
||||
return commonErr.ReturnError(nil, "完成数量超出指派数量", "图文完成数量不能超过已指派数量")
|
||||
}
|
||||
}
|
||||
newPending := assignRecord.PendingPostCount - req.CompleteCount
|
||||
if newPending < 0 {
|
||||
// 暂时都只记录错误,不报错;并且不更新
|
||||
if req.AssignRecordsUUID != "false" {
|
||||
app.ModuleClients.Lg.Info("待发图文数不足,跳过更新",
|
||||
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
||||
zap.String("employeeName", req.EmployeeName),
|
||||
zap.String("employeeNum", req.EmployeeNum),
|
||||
zap.Int("currentPendingCount", assignRecord.PendingPostCount),
|
||||
zap.Int("requestCompleteCount", req.CompleteCount),
|
||||
zap.Int("newPendingCount", newPending),
|
||||
)
|
||||
tx.Rollback()
|
||||
return nil
|
||||
} else {
|
||||
tx.Rollback()
|
||||
return commonErr.ReturnError(nil, "待发图文数不足", "待发图文数不能小于0")
|
||||
}
|
||||
}
|
||||
updateData["complete_post_count"] = newCompleteCount
|
||||
updateData["pending_post_count"] = assignRecord.PendingPostCount - req.CompleteCount
|
||||
updateData["pending_post_count"] = newPending
|
||||
case "data":
|
||||
newCompleteCount := assignRecord.CompleteDataCount + req.CompleteCount
|
||||
if newCompleteCount > assignRecord.AssignDataCount {
|
||||
// 记录超限日志,但不返回错误
|
||||
app.ModuleClients.Lg.Info("数据完成数量超出限制",
|
||||
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
||||
zap.String("employeeName", req.EmployeeName),
|
||||
zap.String("employeeNum", req.EmployeeNum),
|
||||
zap.Int("currentCompleteCount", assignRecord.CompleteDataCount),
|
||||
zap.Int("requestCompleteCount", req.CompleteCount),
|
||||
zap.Int("newCompleteCount", newCompleteCount),
|
||||
zap.Int("assignDataCount", assignRecord.AssignDataCount),
|
||||
)
|
||||
// 暂时都只记录错误,不报错;并且不更新
|
||||
if req.AssignRecordsUUID != "false" {
|
||||
app.ModuleClients.Lg.Info("数据完成数量超出限制,跳过更新",
|
||||
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
||||
zap.String("employeeName", req.EmployeeName),
|
||||
zap.String("employeeNum", req.EmployeeNum),
|
||||
zap.Int("currentCompleteCount", assignRecord.CompleteDataCount),
|
||||
zap.Int("requestCompleteCount", req.CompleteCount),
|
||||
zap.Int("newCompleteCount", newCompleteCount),
|
||||
zap.Int("assignDataCount", assignRecord.AssignDataCount),
|
||||
)
|
||||
tx.Rollback()
|
||||
return nil
|
||||
} else {
|
||||
tx.Rollback()
|
||||
return commonErr.ReturnError(nil, "完成数量超出指派数量", "数据完成数量不能超过已指派数量")
|
||||
}
|
||||
}
|
||||
newPending := assignRecord.PendingDataCount - req.CompleteCount
|
||||
if newPending < 0 {
|
||||
// 暂时都只记录错误,不报错;并且不更新
|
||||
if req.AssignRecordsUUID != "false" {
|
||||
app.ModuleClients.Lg.Info("待发数据数不足,跳过更新",
|
||||
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
||||
zap.String("employeeName", req.EmployeeName),
|
||||
zap.String("employeeNum", req.EmployeeNum),
|
||||
zap.Int("currentPendingCount", assignRecord.PendingDataCount),
|
||||
zap.Int("requestCompleteCount", req.CompleteCount),
|
||||
zap.Int("newPendingCount", newPending),
|
||||
)
|
||||
tx.Rollback()
|
||||
return nil
|
||||
} else {
|
||||
tx.Rollback()
|
||||
return commonErr.ReturnError(nil, "待发数据数不足", "待发数据数不能小于0")
|
||||
}
|
||||
}
|
||||
updateData["complete_data_count"] = newCompleteCount
|
||||
updateData["pending_data_count"] = assignRecord.PendingDataCount - req.CompleteCount
|
||||
updateData["pending_data_count"] = newPending
|
||||
default:
|
||||
tx.Rollback()
|
||||
return commonErr.ReturnError(nil, "无效的任务类型", "任务类型必须是video、post或data")
|
||||
|
Loading…
Reference in New Issue
Block a user