|
|
@@ -48,6 +48,7 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
private var mTicketDetailData: TicketDetailRespVO? = null
|
|
|
private lateinit var observer: Observer<MsgEvent>
|
|
|
private var mCanHandle: Boolean? = null // 是否可以操作,创建人、上锁人至少符合一个才可操作
|
|
|
+ private var mapRatio: Float = 1f
|
|
|
|
|
|
override val viewBinding: FragmentStepBinding
|
|
|
get() = FragmentStepBinding.inflate(layoutInflater)
|
|
|
@@ -72,10 +73,8 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
.setCardBackgroundColor(requireContext().getColor(R.color.item_rv_step_bg_done))
|
|
|
} else {
|
|
|
holder.getView<MaterialCardView>(R.id.cv_step).setCardBackgroundColor(
|
|
|
- if (mStep + 1 == step.index)
|
|
|
- requireContext().getColor(R.color.item_rv_step_bg_doing)
|
|
|
- else
|
|
|
- requireContext().getColor(R.color.common_bg_white_10)
|
|
|
+ if (mStep + 1 == step.index) requireContext().getColor(R.color.item_rv_step_bg_doing)
|
|
|
+ else requireContext().getColor(R.color.common_bg_white_10)
|
|
|
)
|
|
|
}
|
|
|
|
|
|
@@ -89,8 +88,7 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
holder.getView<ImageView>(R.id.iv_status)
|
|
|
.setImageResource(if (step.stepDetail?.stepStatus == "1") R.mipmap.step_executed else R.mipmap.step_not_executed)
|
|
|
holder.setText(
|
|
|
- R.id.tv_status,
|
|
|
- if (step.stepDetail?.stepStatus == "1") {
|
|
|
+ R.id.tv_status, if (step.stepDetail?.stepStatus == "1") {
|
|
|
if (step.index == 3) getString(R.string.allocated) else getString(R.string.executed)
|
|
|
} else {
|
|
|
if (step.index == 3) getString(R.string.not_allocated) else getString(R.string.not_executed)
|
|
|
@@ -145,8 +143,11 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
if (mStep >= 4) {
|
|
|
changePage(
|
|
|
PageChangeBO(
|
|
|
- 2, mChangePage?.workstationId, mChangePage?.ticketId,
|
|
|
- mChangePage?.machineryId, mChangePage?.machineryName
|
|
|
+ 2,
|
|
|
+ mChangePage?.workstationId,
|
|
|
+ mChangePage?.ticketId,
|
|
|
+ mChangePage?.machineryId,
|
|
|
+ mChangePage?.machineryName
|
|
|
)
|
|
|
)
|
|
|
}
|
|
|
@@ -183,6 +184,7 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
}
|
|
|
})
|
|
|
mBinding?.mapview?.addLayer(stationLayer)
|
|
|
+ stationLayer?.setRatio(mapRatio)
|
|
|
mBinding?.mapview?.refresh()
|
|
|
}
|
|
|
|
|
|
@@ -237,8 +239,7 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
}
|
|
|
|
|
|
presenter?.getMachineryDetail(
|
|
|
- pageChangeBO.machineryId!!,
|
|
|
- {
|
|
|
+ pageChangeBO.machineryId!!, {
|
|
|
mMachineryDetail = it
|
|
|
Glide.with(this).load(it?.machineryImg).into(mBinding?.ivMachinery!!)
|
|
|
}) { itList ->
|
|
|
@@ -250,43 +251,73 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
if (mLotoList.isNotEmpty()) {
|
|
|
mLotoList[0].mapId?.let { itId ->
|
|
|
presenter?.getMapInfo(itId) { itMapInfo ->
|
|
|
- itMapInfo?.imageUrl ?: return@getMapInfo
|
|
|
- BitmapUtil.loadBitmapFromUrl(requireContext(), itMapInfo.imageUrl) {
|
|
|
- if (it == null) {
|
|
|
+ // 如果没有图 URL,直接返回
|
|
|
+ val imageUrl = itMapInfo?.imageUrl ?: return@getMapInfo
|
|
|
+
|
|
|
+ BitmapUtil.loadBitmapFromUrl(requireContext(), imageUrl) { mapBmp ->
|
|
|
+ if (mapBmp == null) {
|
|
|
LogUtil.e("Map pic is null")
|
|
|
return@loadBitmapFromUrl
|
|
|
}
|
|
|
- mMapPicWidth = it.width
|
|
|
+
|
|
|
+ // 清空旧点
|
|
|
mStationList.clear()
|
|
|
- val location = IntArray(2)
|
|
|
- mBinding?.mapview?.getLocationOnScreen(location)
|
|
|
- itMapInfo.pointList?.forEach { itPoint ->
|
|
|
- val locationX =
|
|
|
- (itPoint.x!!.toFloat() - (itMapInfo.x!!.toFloat() / 50)) * 50 / itMapInfo.width!!.toFloat() * it.width
|
|
|
- val locationY =
|
|
|
- (itPoint.y!!.toFloat() + 1 - itMapInfo.y!!.toFloat() / 50) * 50 / itMapInfo.height!!.toFloat() * it.height
|
|
|
+
|
|
|
+ // 1 格 对应的像素
|
|
|
+ val cellPx = 50f
|
|
|
+ // 后端给的“逻辑”子图原始尺寸(像素)
|
|
|
+ val backendW = itMapInfo.width!!.toFloat()
|
|
|
+ val backendH = itMapInfo.height!!.toFloat()
|
|
|
+ // 实际下载回来的 Bitmap 尺寸(像素)
|
|
|
+ val actualW = mapBmp.width.toFloat()
|
|
|
+ val actualH = mapBmp.height.toFloat()
|
|
|
+ // 计算缩放比例
|
|
|
+ val ratioX = actualW / backendW
|
|
|
+ val ratioY = actualH / backendH
|
|
|
+ mapRatio = ratioX
|
|
|
+ // 子图在全局坐标系里的左上角偏移(像素)
|
|
|
+ val offsetX = itMapInfo.x!!.toFloat()
|
|
|
+ val offsetY = itMapInfo.y!!.toFloat()
|
|
|
+ // 图标请求尺寸:逻辑 45px * 缩放比
|
|
|
+ val iconReqPx = (45f * ratioX).toInt().coerceAtLeast(1)
|
|
|
+
|
|
|
+ itMapInfo.pointList?.forEach { pt ->
|
|
|
+ // 1) 格数 → 全局像素
|
|
|
+ val globalX = pt.x!!.toFloat() * cellPx
|
|
|
+ val globalY = pt.y!!.toFloat() * cellPx
|
|
|
+ // 2) 全局像素 - 子图偏移 = 子图内像素
|
|
|
+ val localX = globalX - offsetX
|
|
|
+ val localY = globalY - offsetY
|
|
|
+ // 3) 再乘缩放比,得到真实 Bitmap 上的像素坐标
|
|
|
+ val finalX = localX * ratioX
|
|
|
+ val finalY = localY * ratioY
|
|
|
+ // 异步加载点位图标,固定请求尺寸
|
|
|
BitmapUtil.loadBitmapFromUrl(
|
|
|
requireContext(),
|
|
|
- itPoint.pointIcon!!,
|
|
|
- reqWidth = 18,
|
|
|
- reqHeight = 18
|
|
|
- ) { itBitmap ->
|
|
|
+ pt.pointIcon!!,
|
|
|
+ reqWidth = iconReqPx,
|
|
|
+ reqHeight = iconReqPx
|
|
|
+ ) { bmpIcon ->
|
|
|
+ val icon = bmpIcon ?: BitmapUtil.getResizedBitmapFromMipmap(
|
|
|
+ requireContext(),
|
|
|
+ R.mipmap.ticket_type_placeholder,
|
|
|
+ iconReqPx,
|
|
|
+ iconReqPx
|
|
|
+ )
|
|
|
+
|
|
|
mStationList.add(
|
|
|
CustomStationLayer.IsolationPoint(
|
|
|
- PointF(locationX, locationY),
|
|
|
- itPoint.entityName!!,
|
|
|
- itBitmap ?: BitmapUtil.getResizedBitmapFromMipmap(
|
|
|
- requireContext(),
|
|
|
- R.mipmap.ticket_type_placeholder,
|
|
|
- 18,
|
|
|
- 18
|
|
|
- ),
|
|
|
- itPoint.entityId!!,
|
|
|
- mMachineryDetail?.pointIdList?.contains(itPoint.entityId) == true
|
|
|
+ PointF(finalX, finalY),
|
|
|
+ pt.entityName!!,
|
|
|
+ icon,
|
|
|
+ pt.entityId!!.toLong(),
|
|
|
+ mMachineryDetail?.pointIdList?.contains(pt.entityId) == true
|
|
|
)
|
|
|
)
|
|
|
+
|
|
|
+ // 全部点都加载完后,设置给 layer 并绘制
|
|
|
if (mStationList.size == itMapInfo.pointList.size) {
|
|
|
- mBinding?.mapview?.loadMap(it)
|
|
|
+ mBinding?.mapview?.loadMap(mapBmp)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -347,8 +378,7 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
else -> ""
|
|
|
}
|
|
|
if (step == 8 && presenter?.checkCrossJobUnlockData(
|
|
|
- requireContext(),
|
|
|
- mTicketDetailData
|
|
|
+ requireContext(), mTicketDetailData
|
|
|
) == true
|
|
|
) {
|
|
|
mTipDialog.setTip(getString(R.string.all_point_have_other_job_not_finish))
|
|
|
@@ -358,8 +388,7 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
presenter?.updateCoincideToUnLock(it) {
|
|
|
if (it) {
|
|
|
presenter?.updateStep(
|
|
|
- mStepList.find { it.index == step }?.stepDetail?.stepId!!,
|
|
|
- "1"
|
|
|
+ mStepList.find { it.index == step }?.stepDetail?.stepId!!, "1"
|
|
|
) {
|
|
|
mChangePage?.let {
|
|
|
refreshPage(it)
|
|
|
@@ -382,8 +411,7 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
BusinessManager.sendLoadingEventMsg(null, false)
|
|
|
refreshPage(mChangePage!!)
|
|
|
if (presenter?.jumpJobProgressPageCheck(
|
|
|
- requireContext(),
|
|
|
- step
|
|
|
+ requireContext(), step
|
|
|
) == true
|
|
|
) {
|
|
|
// 自动跳转
|
|
|
@@ -403,20 +431,21 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
|
|
|
else -> {
|
|
|
presenter?.updateStep(
|
|
|
- mStepList.find { it.index == step }?.stepDetail?.stepId!!,
|
|
|
- "1"
|
|
|
+ mStepList.find { it.index == step }?.stepDetail?.stepId!!, "1"
|
|
|
) {
|
|
|
refreshPage(mChangePage!!)
|
|
|
if (presenter?.jumpJobProgressPageCheck(
|
|
|
- requireContext(),
|
|
|
- step
|
|
|
+ requireContext(), step
|
|
|
) == true
|
|
|
) {
|
|
|
// 自动跳转
|
|
|
changePage(
|
|
|
PageChangeBO(
|
|
|
- 2, mChangePage?.workstationId, mChangePage?.ticketId,
|
|
|
- mChangePage?.machineryId, mChangePage?.machineryName
|
|
|
+ 2,
|
|
|
+ mChangePage?.workstationId,
|
|
|
+ mChangePage?.ticketId,
|
|
|
+ mChangePage?.machineryId,
|
|
|
+ mChangePage?.machineryName
|
|
|
)
|
|
|
)
|
|
|
}
|
|
|
@@ -432,8 +461,11 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
presenter?.tipToJobProgressPageCheck(requireContext(), mStep) {
|
|
|
changePage(
|
|
|
PageChangeBO(
|
|
|
- 2, mChangePage?.workstationId, mChangePage?.ticketId,
|
|
|
- mChangePage?.machineryId, mChangePage?.machineryName
|
|
|
+ 2,
|
|
|
+ mChangePage?.workstationId,
|
|
|
+ mChangePage?.ticketId,
|
|
|
+ mChangePage?.machineryId,
|
|
|
+ mChangePage?.machineryName
|
|
|
)
|
|
|
)
|
|
|
}
|