package com.za.bean.db.order

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathHitTester
import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity(tableName = "photo_template_bean")
data class PhotoTemplateInfo(
	@PrimaryKey(autoGenerate = true) val primaryId : Int? = null,
	val id : Int? = null,
	val taskNode : Int? = null,
	val imageDescription : String? = null, // 图片描述
	val imageTitle : String? = null, // 图片标题
	val tag : String? = null, // 标签
	val doHaveFilm : Int? = null, //是否必拍 0 非必拍  1 必拍
	val photoUrl : String? = null, //封面地址
	val photoName : String? = null, // 图片名称
	val photoType : Int? = null, // 1 照片  2 电子工单
	val sort : Int? = null, //照片在后台的位置
	val createTime : String? = null, //创建时间
	val numbering : String? = null, // 图片编号
	val recognizeType : Int? = null, //orc 识别类型 0 无  1 车牌号 2 车架号
	//以下属性非后台返回属性
	val userOrderId : Int? = null,
	val taskCode : String? = null,
	val taskId : Int? = null,
	val photoLocalPath : String? = null, //照片未添加水印之前的位置
	val photoUploadPath : String? = null, //照片上传服务器之后的路径
	val photoLocalWaterMarkerPath : String? = null, //照片水印位置
	val photoUploadStatus : Int? = null, // 0 未上传 1 准备上传 2 已上传 3 上传失败 4 上传中 5 照片不符合条件 6 照片缺失地址信息  7 ocr车架号识别出错
	val photoUploadStatusStr : String? = null,
	var advanceTime : Long? = null,
	val needWaterMarker : Boolean? = null,
	val needShowPhoneBrand : Boolean? = null,
	val myCustomPhotoType : Int? = null, // 1 默认是服务中照片订单图片  2 历史中照片  3.更换电瓶照片  4.普通的照片
	//    photo info字段
	val realTakePhotoTime : String? = null, //真实拍照时间
	val photoSource : Int? = null, //1相机  2 相册  3真实位置
	val time : String? = null, // 拍照时间
	val lat : Float? = null,
	val lng : Float? = null,
	val address : String? = null,
	val showPingAnGiveUpPhoto : Int? = null, //值==1的时候并且符合到达现场取消就展示，其他不展示
) {
	fun convertPhotoStatusStr(status : Int) : String {
		return when (status) {
			1 -> "准备上传"
			2 -> "已上传"
			3 -> "上传失败"
			4 -> "上传中"
			5 -> "照片不符合条件"
			6 -> "照片缺失地址信息"
			7 -> "车架号识别出错"
			else -> ""
		}
	}

	fun getPhotoStatusColor() : Color {
		return when (this.photoUploadStatus) {
			1 -> Color(0xFF2DBBF9)
			2 -> Color(0xFF32CD32)
			3 -> Color.Red
			4 -> Color(0xFF2DBBF9)
			5 -> Color.Red
			6 -> Color.Red
			else -> Color(0xFF2DBBF9)
		}
	}

	fun getFormatPhotoUrl() : String? {
		if (this.photoUrl?.startsWith("http://") == true) {
			return this.photoUrl.replace("http://", "https://")
		}
		return this.photoUrl
	}
}