fix: TaskDetail 字段对齐服务端实际返回

- name(非taskName), sendTime(非beginTime), taskPositions(数组非字符串)
- point 改为 Double(服务端返回0.0)
- hasPosition 从 taskPositions 判断(服务端无此字段)
- 新增 displayName/positionText/pointText 辅助属性
- displayDetail 使用实际字段名

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
dongliang
2026-04-28 10:45:18 +09:30
parent 5e2d71c25d
commit 9598976566
2 changed files with 91 additions and 47 deletions

View File

@@ -4,30 +4,80 @@ import com.google.gson.annotations.SerializedName
/**
* 任务详情数据类
* 对应 watchTask/lookTaskDetail API 返回
* 对应 watchTask/lookTaskDetail API 实际返回字段
*/
data class TaskDetail(
@SerializedName("id") val id: Long = 0,
/** 任务编号 */
/** 派单号 */
@SerializedName("no") val no: String = "",
/** 任务名称 */
@SerializedName("taskName") val taskName: String = "",
/** 地点名称 */
@SerializedName("positionName") val positionName: String = "",
/** 积分 */
@SerializedName("point") val point: Int = 0,
/** 状态2=待抢单, 3=待打卡, 4=进行中, 1=已完成 */
@SerializedName("status") val status: Int = 0,
/** 任务类型 */
@SerializedName("name") val name: String = "",
/** 任务类型0=计划,1=监控,2=指派,3=用户上报,4=巡检上报,5=巡检任务 */
@SerializedName("taskType") val taskType: Int = 0,
/** 开始时间 */
@SerializedName("beginTime") val beginTime: String = "",
/** 结束时间 */
@SerializedName("endTime") val endTime: String = "",
/** 状态2=待抢单,3=待打卡,4=进行中,5/6=完成 */
@SerializedName("status") val status: Int = 0,
/** 积分(服务端返回 Double */
@SerializedName("point") val point: Double = 0.0,
/** 派单时间 "04.28 09:10" */
@SerializedName("sendTime") val sendTime: String = "",
/** 创建时间 */
@SerializedName("createTime") val createTime: String = "",
/** 预计完成时间(指派任务) */
@SerializedName("preFinishTime") val preFinishTime: String? = null,
/** 过期时间 */
@SerializedName("expireTime") val expireTime: String? = null,
/** 确认时间 */
@SerializedName("confirmTime") val confirmTime: String? = null,
/** 操作时间 */
@SerializedName("actionTime") val actionTime: String? = null,
/** 完成时间 */
@SerializedName("finishTime") val finishTime: String? = null,
/** 打卡地点列表(非空=有场景打卡) */
@SerializedName("taskPositions") val taskPositions: List<String>? = null,
/** 巡检场景列表taskType=5 */
@SerializedName("taskInspectScenes") val taskInspectScenes: List<Any>? = null,
/** 协作人状态1=有协作人 */
@SerializedName("userStatus") val userStatus: Int = 0,
/** 协作人列表 */
@SerializedName("workTogether") val workTogether: List<Any>? = null,
/** 巡检人员 */
@SerializedName("inspectUser") val inspectUser: List<String>? = null,
/** 巡检开始时间 */
@SerializedName("executeTimeStart") val executeTimeStart: String? = null,
/** 巡检结束时间 */
@SerializedName("executeTimeEnd") val executeTimeEnd: String? = null,
/** 创建人/上报人 */
@SerializedName("createName") val createName: String = "",
/** 任务描述 */
@SerializedName("description") val description: String = "",
/** 协作人 */
@SerializedName("executorName") val executorName: String = "",
/** 是否有打卡地点(决定打卡方式:有=NFC打卡无=直接确认 */
@SerializedName("hasPosition") val hasPosition: Boolean = false
)
@SerializedName("content") val content: String = "",
/** 任务标准 */
@SerializedName("standard") val standard: String = "",
/** 任务要求(黄色提示 */
@SerializedName("taskRequire") val taskRequire: String? = null,
/** 图片附件 */
@SerializedName("uploadPic") val uploadPic: List<Any>? = null,
/** 语音附件 */
@SerializedName("voice") val voice: List<Any>? = null,
/** 打卡标志 */
@SerializedName("clockFlag") val clockFlag: Int = 0
) {
/** 是否有打卡地点(决定打卡方式:有=NFC无=直接确认) */
val hasPosition: Boolean get() = !taskPositions.isNullOrEmpty()
/** 地点显示文字(多个用逗号分隔) */
val positionText: String get() = taskPositions?.joinToString(",") ?: ""
/** 积分显示(去掉小数点) */
val pointText: String get() = if (point > 0) "+${point.toInt()}" else "0"
/** 任务名带类型前缀 */
val displayName: String get() {
val prefix = when (taskType) {
2 -> "指派:"
3, 4 -> "上报:"
5 -> "巡检:"
else -> ""
}
return "$prefix$name"
}
}