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, "查询指派记录失败", "查询指派记录失败: ")
|
return commonErr.ReturnError(err, "查询指派记录失败", "查询指派记录失败: ")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 如果没有提供UUID,根据员工信息查询最早的未完成任务
|
// 如果没有提供UUID,根据员工信息与任务类型筛选最早的未手动完成任务
|
||||||
if req.EmployeeName == "" || req.EmployeeNum == "" {
|
if req.EmployeeName == "" || req.EmployeeNum == "" {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return commonErr.ReturnError(nil, "参数错误", "员工姓名和手机号不能为空")
|
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").
|
Order("operator_time ASC").
|
||||||
First(&assignRecord).Error
|
First(&assignRecord).Error
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == gorm.ErrRecordNotFound {
|
if err == gorm.ErrRecordNotFound {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return commonErr.ReturnError(nil, "未找到任务记录", "该员工没有未完成的任务记录")
|
return commonErr.ReturnError(nil, "未找到任务记录", "该员工没有符合条件的未手动完成任务记录")
|
||||||
}
|
}
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return commonErr.ReturnError(err, "查询指派记录失败", "查询指派记录失败: ")
|
return commonErr.ReturnError(err, "查询指派记录失败", "查询指派记录失败: ")
|
||||||
@ -497,51 +513,129 @@ func UpdateTaskProgress(req *CompleteTaskRequest) error {
|
|||||||
case "video":
|
case "video":
|
||||||
newCompleteCount := assignRecord.CompleteVideoCount + req.CompleteCount
|
newCompleteCount := assignRecord.CompleteVideoCount + req.CompleteCount
|
||||||
if newCompleteCount > assignRecord.AssignVideoCount {
|
if newCompleteCount > assignRecord.AssignVideoCount {
|
||||||
// 记录超限日志,但不返回错误
|
// 暂时都只记录错误,不报错;并且不更新
|
||||||
app.ModuleClients.Lg.Info("视频完成数量超出限制",
|
if req.AssignRecordsUUID != "false" {
|
||||||
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
app.ModuleClients.Lg.Info("视频完成数量超出限制,跳过更新",
|
||||||
zap.String("employeeName", req.EmployeeName),
|
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
||||||
zap.String("employeeNum", req.EmployeeNum),
|
zap.String("employeeName", req.EmployeeName),
|
||||||
zap.Int("currentCompleteCount", assignRecord.CompleteVideoCount),
|
zap.String("employeeNum", req.EmployeeNum),
|
||||||
zap.Int("requestCompleteCount", req.CompleteCount),
|
zap.Int("currentCompleteCount", assignRecord.CompleteVideoCount),
|
||||||
zap.Int("newCompleteCount", newCompleteCount),
|
zap.Int("requestCompleteCount", req.CompleteCount),
|
||||||
zap.Int("assignVideoCount", assignRecord.AssignVideoCount),
|
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["complete_video_count"] = newCompleteCount
|
||||||
updateData["pending_video_count"] = assignRecord.PendingVideoCount - req.CompleteCount
|
updateData["pending_video_count"] = newPending
|
||||||
case "post":
|
case "post":
|
||||||
newCompleteCount := assignRecord.CompletePostCount + req.CompleteCount
|
newCompleteCount := assignRecord.CompletePostCount + req.CompleteCount
|
||||||
if newCompleteCount > assignRecord.AssignPostCount {
|
if newCompleteCount > assignRecord.AssignPostCount {
|
||||||
// 记录超限日志,但不返回错误
|
// 暂时先只记录,不报错;并且不更新
|
||||||
app.ModuleClients.Lg.Info("图文完成数量超出限制",
|
if req.AssignRecordsUUID != "false" {
|
||||||
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
app.ModuleClients.Lg.Info("图文完成数量超出限制,跳过更新",
|
||||||
zap.String("employeeName", req.EmployeeName),
|
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
||||||
zap.String("employeeNum", req.EmployeeNum),
|
zap.String("employeeName", req.EmployeeName),
|
||||||
zap.Int("currentCompleteCount", assignRecord.CompletePostCount),
|
zap.String("employeeNum", req.EmployeeNum),
|
||||||
zap.Int("requestCompleteCount", req.CompleteCount),
|
zap.Int("currentCompleteCount", assignRecord.CompletePostCount),
|
||||||
zap.Int("newCompleteCount", newCompleteCount),
|
zap.Int("requestCompleteCount", req.CompleteCount),
|
||||||
zap.Int("assignPostCount", assignRecord.AssignPostCount),
|
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["complete_post_count"] = newCompleteCount
|
||||||
updateData["pending_post_count"] = assignRecord.PendingPostCount - req.CompleteCount
|
updateData["pending_post_count"] = newPending
|
||||||
case "data":
|
case "data":
|
||||||
newCompleteCount := assignRecord.CompleteDataCount + req.CompleteCount
|
newCompleteCount := assignRecord.CompleteDataCount + req.CompleteCount
|
||||||
if newCompleteCount > assignRecord.AssignDataCount {
|
if newCompleteCount > assignRecord.AssignDataCount {
|
||||||
// 记录超限日志,但不返回错误
|
// 暂时都只记录错误,不报错;并且不更新
|
||||||
app.ModuleClients.Lg.Info("数据完成数量超出限制",
|
if req.AssignRecordsUUID != "false" {
|
||||||
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
app.ModuleClients.Lg.Info("数据完成数量超出限制,跳过更新",
|
||||||
zap.String("employeeName", req.EmployeeName),
|
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
|
||||||
zap.String("employeeNum", req.EmployeeNum),
|
zap.String("employeeName", req.EmployeeName),
|
||||||
zap.Int("currentCompleteCount", assignRecord.CompleteDataCount),
|
zap.String("employeeNum", req.EmployeeNum),
|
||||||
zap.Int("requestCompleteCount", req.CompleteCount),
|
zap.Int("currentCompleteCount", assignRecord.CompleteDataCount),
|
||||||
zap.Int("newCompleteCount", newCompleteCount),
|
zap.Int("requestCompleteCount", req.CompleteCount),
|
||||||
zap.Int("assignDataCount", assignRecord.AssignDataCount),
|
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["complete_data_count"] = newCompleteCount
|
||||||
updateData["pending_data_count"] = assignRecord.PendingDataCount - req.CompleteCount
|
updateData["pending_data_count"] = newPending
|
||||||
default:
|
default:
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return commonErr.ReturnError(nil, "无效的任务类型", "任务类型必须是video、post或data")
|
return commonErr.ReturnError(nil, "无效的任务类型", "任务类型必须是video、post或data")
|
||||||
|
Loading…
Reference in New Issue
Block a user