Browse Source

2024-05-22 修改

修改

1. 导游地接资料详情 逻辑更改,新增根据ID查询导游地接资料
zhaiy 10 months ago
parent
commit
0d275ffa3c

+ 5 - 0
app/src/main/java/com/pan_american/android/data/model/resource_management/guide_resource/network/GuideResourceDetailRequest.kt

@@ -0,0 +1,5 @@
+package com.pan_american.android.data.model.resource_management.guide_resource.network
+
+import com.pan_american.android.base.BaseRequest
+
+class GuideResourceDetailRequest(val id: Int): BaseRequest()

+ 6 - 0
app/src/main/java/com/pan_american/android/data/model/resource_management/guide_resource/network/GuideResourceDetailResponse.kt

@@ -0,0 +1,6 @@
+package com.pan_american.android.data.model.resource_management.guide_resource.network
+
+import com.pan_american.android.base.BaseResponse
+import com.pan_american.android.data.model.resource_management.guide_resource.entity.GuideResource
+
+class GuideResourceDetailResponse(val data: GuideResource): BaseResponse()

+ 5 - 0
app/src/main/java/com/pan_american/android/data/network/APIService.kt

@@ -103,6 +103,8 @@ import com.pan_american.android.data.model.resource_management.airplane_three_co
 import com.pan_american.android.data.model.resource_management.car_resource.entity.CarResource
 import com.pan_american.android.data.model.resource_management.car_resource.network.CarResourceResponse
 import com.pan_american.android.data.model.resource_management.guide_resource.entity.GuideResource
+import com.pan_american.android.data.model.resource_management.guide_resource.network.GuideResourceDetailRequest
+import com.pan_american.android.data.model.resource_management.guide_resource.network.GuideResourceDetailResponse
 import com.pan_american.android.data.model.resource_management.guide_resource.network.GuideResourceResponse
 import com.pan_american.android.data.model.resource_management.hotel_resource.entity.UpdateHotelResource
 import com.pan_american.android.data.model.resource_management.hotel_resource.network.HotelResourceDetailRequest
@@ -192,6 +194,9 @@ interface APIService {
     @POST("/api/Resource/QueryLocalGuide")
     fun getGuideData(@Body resourceRequest: ResourceRequest): Call<GuideResourceResponse>
 
+    @POST("/api/Resource/QueryLocalGuideDetailById")
+    fun getLocalGuideDetailById(@Body guideResourceDetailRequest: GuideResourceDetailRequest): Call<GuideResourceDetailResponse>
+
     /**
      * 导游地接供应商资源,导游地接信息操作
      * status: 1.新增     2.修改

+ 93 - 61
app/src/main/java/com/pan_american/android/ui/resource_management/guide_resource/AddGuideResourceActivity.kt

@@ -11,6 +11,8 @@ import com.pan_american.android.base.BaseResponse
 import com.pan_american.android.base.ListAdapter
 import com.pan_american.android.data.model.common.entity.Selector
 import com.pan_american.android.data.model.resource_management.guide_resource.entity.GuideResource
+import com.pan_american.android.data.model.resource_management.guide_resource.network.GuideResourceDetailRequest
+import com.pan_american.android.data.model.resource_management.guide_resource.network.GuideResourceDetailResponse
 import com.pan_american.android.data.network.APIService
 import com.pan_american.android.data.network.ServiceCreator
 import com.pan_american.android.databinding.ActivityAddGuideResourceBinding
@@ -31,13 +33,21 @@ class AddGuideResourceActivity : BaseActivity<ActivityAddGuideResourceBinding>()
 
     private var guideTypeId = -1
 
+    private val apiService = ServiceCreator.create<APIService>()
+
+    private var resourceId = 0
+
     override fun getViewBinding() = ActivityAddGuideResourceBinding.inflate(layoutInflater)
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         screenAdaptation(binding)
 
-        fromList = intent.getBooleanExtra("fromList", false)
+        intent.apply {
+            fromList = intent.getBooleanExtra("fromList", false)
+            resourceId = intent.getIntExtra("resource_id", 0)
+        }
+
 
         initTitle()
         initViews()
@@ -64,8 +74,6 @@ class AddGuideResourceActivity : BaseActivity<ActivityAddGuideResourceBinding>()
 
         if (fromList) {
 
-            guideResource = intent.getSerializableExtra("guideResource") as GuideResource
-
             initGuideResourceDetail()
 
             binding.commit.setText(resources.getString(R.string.update))
@@ -240,73 +248,97 @@ class AddGuideResourceActivity : BaseActivity<ActivityAddGuideResourceBinding>()
     }
 
     private fun initGuideResourceDetail() {
-        binding.apply {
-            for (item in OASystem.guideType) {
-                if (item.id == guideResource.staffType) {
-                    guideType.text = item.name
-                    guideTypeId = item.id
-                }
-            }
 
-            //老数据没有选择评分,更新数据时需要选择评分
-            for (item in OASystem.score) {
-                if (guideResource.score.toString() == item) {
-                    serviceScore.text = item
-                    isChose = true
-                }
-            }
+        apiService.getLocalGuideDetailById(GuideResourceDetailRequest(resourceId)).enqueue(object : Callback<GuideResourceDetailResponse> {
+            override fun onResponse(
+                call: Call<GuideResourceDetailResponse>,
+                response: Response<GuideResourceDetailResponse>
+            ) {
+                val resourceDetailResponse = response.body()
 
-            unitArea.setText(guideResource.unitArea)
-            departmentName.setText(guideResource.unitName)
-            supplierLocation.setText(guideResource.address)
-            contactsName.setText(guideResource.contact)
-            contactsPhone.setText(guideResource.contactTel)
-            contactsEmail.setText(guideResource.contactEmail)
-            contactsFax.setText(guideResource.contactFax)
-            otherInfo.setText(guideResource.otherInfo)
-        }
+                if (resourceDetailResponse != null) {
+                    if (resourceDetailResponse.code == 200) {
 
-        when (guideResource.suitScore) {
-            "A" -> binding.dressA.isChecked = true
-            "B" -> binding.dressB.isChecked = true
-            "C" -> binding.dressC.isChecked = true
-        }
+                        guideResource = resourceDetailResponse.data
 
-        when (guideResource.serveScore) {
-            "A" -> binding.awarenessA.isChecked = true
-            "B" -> binding.awarenessB.isChecked = true
-            "C" -> binding.awarenessC.isChecked = true
-        }
+                        binding.apply {
+                            for (item in OASystem.guideType) {
+                                if (item.id == guideResource.staffType) {
+                                    guideType.text = item.name
+                                    guideTypeId = item.id
+                                }
+                            }
 
-        when (guideResource.talkProScore) {
-            "A" -> binding.expertiseA.isChecked = true
-            "B" -> binding.expertiseB.isChecked = true
-            "C" -> binding.expertiseC.isChecked = true
-        }
+                            //老数据没有选择评分,更新数据时需要选择评分
+                            for (item in OASystem.score) {
+                                if (guideResource.score.toString() == item) {
+                                    serviceScore.text = item
+                                    isChose = true
+                                }
+                            }
 
-        when (guideResource.timeScore) {
-            "A" -> binding.timeConceptA.isChecked = true
-            "B" -> binding.timeConceptB.isChecked = true
-            "C" -> binding.timeConceptC.isChecked = true
-        }
+                            unitArea.setText(guideResource.unitArea)
+                            departmentName.setText(guideResource.unitName)
+                            supplierLocation.setText(guideResource.address)
+                            contactsName.setText(guideResource.contact)
+                            contactsPhone.setText(guideResource.contactTel)
+                            contactsEmail.setText(guideResource.contactEmail)
+                            contactsFax.setText(guideResource.contactFax)
+                            otherInfo.setText(guideResource.otherInfo)
+                        }
 
-        when (guideResource.fitScore) {
-            "A" -> binding.cooperationA.isChecked = true
-            "B" -> binding.cooperationB.isChecked = true
-            "C" -> binding.cooperationC.isChecked = true
-        }
+                        when (guideResource.suitScore) {
+                            "A" -> binding.dressA.isChecked = true
+                            "B" -> binding.dressB.isChecked = true
+                            "C" -> binding.dressC.isChecked = true
+                        }
 
-        when (guideResource.strainScore) {
-            "A" -> binding.adaptabilityA.isChecked = true
-            "B" -> binding.adaptabilityB.isChecked = true
-            "C" -> binding.adaptabilityC.isChecked = true
-        }
+                        when (guideResource.serveScore) {
+                            "A" -> binding.awarenessA.isChecked = true
+                            "B" -> binding.awarenessB.isChecked = true
+                            "C" -> binding.awarenessC.isChecked = true
+                        }
 
-        when (guideResource.localAndChineseScore) {
-            "A" -> binding.expressionA.isChecked = true
-            "B" -> binding.expressionB.isChecked = true
-            "C" -> binding.expressionC.isChecked = true
-        }
+                        when (guideResource.talkProScore) {
+                            "A" -> binding.expertiseA.isChecked = true
+                            "B" -> binding.expertiseB.isChecked = true
+                            "C" -> binding.expertiseC.isChecked = true
+                        }
+
+                        when (guideResource.timeScore) {
+                            "A" -> binding.timeConceptA.isChecked = true
+                            "B" -> binding.timeConceptB.isChecked = true
+                            "C" -> binding.timeConceptC.isChecked = true
+                        }
+
+                        when (guideResource.fitScore) {
+                            "A" -> binding.cooperationA.isChecked = true
+                            "B" -> binding.cooperationB.isChecked = true
+                            "C" -> binding.cooperationC.isChecked = true
+                        }
+
+                        when (guideResource.strainScore) {
+                            "A" -> binding.adaptabilityA.isChecked = true
+                            "B" -> binding.adaptabilityB.isChecked = true
+                            "C" -> binding.adaptabilityC.isChecked = true
+                        }
+
+                        when (guideResource.localAndChineseScore) {
+                            "A" -> binding.expressionA.isChecked = true
+                            "B" -> binding.expressionB.isChecked = true
+                            "C" -> binding.expressionC.isChecked = true
+                        }
+
+                    } else {
+                        showMessage(resourceDetailResponse.msg)
+                    }
+                }
+            }
+
+            override fun onFailure(call: Call<GuideResourceDetailResponse>, t: Throwable) {
+                showErrorInfo(R.string.guide_resource_detail_get_failed)
+            }
+        })
     }
 
     /**

+ 1 - 1
app/src/main/java/com/pan_american/android/ui/resource_management/guide_resource/GuideResourceListFragment.kt

@@ -176,7 +176,7 @@ class GuideResourceListFragment : BaseFragment<FragmentGuideResourceListBinding>
                 override fun onItemClick(position: Int) {
                     val intent =
                         Intent(OASystem.context, AddGuideResourceActivity::class.java).apply {
-                            putExtra("guideResource", guideList[position])
+                            putExtra("resource_id", guideList[position].id)
                             putExtra("fromList", true)
                         }
 

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -379,6 +379,7 @@
 
     <!-- 导游地接资料,错误信息 -->
     <string name="guide_resource_list_get_failed">导游地接列表获取失败</string>
+    <string name="guide_resource_detail_get_failed">导游地接详情获取失败</string>
 
     <!-- 车辆供应商资源 -->
     <string name="add_car_resource">新增车辆公司资源</string>