Browse Source

2024-05-22 修改

修改

1. 车公司资料详情 逻辑更改,新增根据ID查询车公司资料
zhaiy 10 months ago
parent
commit
1e5a4d7cb2

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

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

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

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

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

@@ -101,6 +101,8 @@ import com.pan_american.android.data.model.resource_management.airplane_three_co
 import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeRequest
 import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeResponse
 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.CarResourceDetailRequest
+import com.pan_american.android.data.model.resource_management.car_resource.network.CarResourceDetailResponse
 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
@@ -164,6 +166,12 @@ interface APIService {
     @POST("/api/Resource/QueryCarData")
     fun getCarData(@Body resourceRequest: ResourceRequest): Call<CarResourceResponse>
 
+    /**
+     * 车辆供应商资源,根据id查询车公司信息
+     */
+    @POST("/api/Resource/QuerCarDataDetailById")
+    fun getCarResourceDetailById(@Body carResourceDetailRequest: CarResourceDetailRequest): Call<CarResourceDetailResponse>
+
     /**
      * 车辆供应商资源,车公司信息添加
      */

+ 96 - 65
app/src/main/java/com/pan_american/android/ui/resource_management/car_resource/AddCarResourceActivity.kt

@@ -10,6 +10,8 @@ import com.pan_american.android.base.BaseActivity
 import com.pan_american.android.base.BaseResponse
 import com.pan_american.android.base.ListAdapter
 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.CarResourceDetailRequest
+import com.pan_american.android.data.model.resource_management.car_resource.network.CarResourceDetailResponse
 import com.pan_american.android.data.network.APIService
 import com.pan_american.android.data.network.ServiceCreator
 import com.pan_american.android.databinding.ActivityAddCarResourceBinding
@@ -28,13 +30,21 @@ class AddCarResourceActivity : BaseActivity<ActivityAddCarResourceBinding>() {
 
     private var fromList = false
 
+    private var apiService = ServiceCreator.create<APIService>()
+
+    private var resourceId = 0
+
     override fun getViewBinding() = ActivityAddCarResourceBinding.inflate(layoutInflater)
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         screenAdaptation(binding)
 
-        fromList = intent.getBooleanExtra("fromList", false)
+        intent.apply {
+            fromList = this.getBooleanExtra("fromList", false)
+            resourceId = this.getIntExtra("resource_id", 0)
+        }
+
 
         initTitle()
         initViews()
@@ -61,8 +71,6 @@ class AddCarResourceActivity : BaseActivity<ActivityAddCarResourceBinding>() {
 
         if (fromList) {
 
-            carResource = intent.getSerializableExtra("carResource") as CarResource
-
             initCarResourceInfo()
 
             binding.commit.setText(resources.getString(R.string.update))
@@ -209,77 +217,100 @@ class AddCarResourceActivity : BaseActivity<ActivityAddCarResourceBinding>() {
     }
 
     private fun initCarResourceInfo() {
-        binding.apply {
-            carCompany.setText(carResource.unitName)
-            for (item in OASystem.score) {
-                if (item == carResource.score.toString()) {
-                    companyScore.text = carResource.score.toString()
-                    isChose = true
-                }
-            }
-            departmentArea.setText(carResource.unitArea)
-            departmentLocation.setText(carResource.address)
-            contactsName.setText(carResource.contact)
-            contactsPhone.setText(carResource.contactTel)
-            contactsEmail.setText(carResource.contactEmail)
-            contactsFax.setText(carResource.contactFax)
-            carDescription.setText(carResource.carDes)
-            otherInfo.setText(carResource.otherInfo)
-        }
 
-        when (carResource.qualificationScore) {
-            "A" -> binding.carQualificationA.isChecked = true
-            "B" -> binding.carQualificationB.isChecked = true
-            "C" -> binding.carQualificationC.isChecked = true
-        }
+        apiService.getCarResourceDetailById(CarResourceDetailRequest(resourceId)).enqueue(object : Callback<CarResourceDetailResponse> {
+            override fun onResponse(
+                call: Call<CarResourceDetailResponse>,
+                response: Response<CarResourceDetailResponse>
+            ) {
+                val resourceResponse = response.body()
+
+                if (resourceResponse != null) {
+                    if (resourceResponse.code == 200) {
+                        carResource = resourceResponse.data
+
+                        binding.apply {
+                            carCompany.setText(carResource.unitName)
+                            for (item in OASystem.score) {
+                                if (item == carResource.score.toString()) {
+                                    companyScore.text = carResource.score.toString()
+                                    isChose = true
+                                }
+                            }
+                            departmentArea.setText(carResource.unitArea)
+                            departmentLocation.setText(carResource.address)
+                            contactsName.setText(carResource.contact)
+                            contactsPhone.setText(carResource.contactTel)
+                            contactsEmail.setText(carResource.contactEmail)
+                            contactsFax.setText(carResource.contactFax)
+                            carDescription.setText(carResource.carDes)
+                            otherInfo.setText(carResource.otherInfo)
+                        }
 
-        when (carResource.carAgeScore) {
-            "A" -> binding.carAgeA.isChecked = true
-            "B" -> binding.carAgeB.isChecked = true
-            "C" -> binding.carAgeC.isChecked = true
-        }
+                        when (carResource.qualificationScore) {
+                            "A" -> binding.carQualificationA.isChecked = true
+                            "B" -> binding.carQualificationB.isChecked = true
+                            "C" -> binding.carQualificationC.isChecked = true
+                        }
 
-        when (carResource.cleanImgScore) {
-            "A" -> binding.carSurfaceA.isChecked = true
-            "B" -> binding.carSurfaceB.isChecked = true
-            "C" -> binding.carSurfaceC.isChecked = true
-        }
+                        when (carResource.carAgeScore) {
+                            "A" -> binding.carAgeA.isChecked = true
+                            "B" -> binding.carAgeB.isChecked = true
+                            "C" -> binding.carAgeC.isChecked = true
+                        }
 
-        when (carResource.smellScore) {
-            "A" -> binding.carInnerA.isChecked = true
-            "B" -> binding.carInnerB.isChecked = true
-            "C" -> binding.carInnerC.isChecked = true
-        }
+                        when (carResource.cleanImgScore) {
+                            "A" -> binding.carSurfaceA.isChecked = true
+                            "B" -> binding.carSurfaceB.isChecked = true
+                            "C" -> binding.carSurfaceC.isChecked = true
+                        }
 
-        when (carResource.waterPaperScore) {
-            "A" -> binding.carPrepareA.isChecked = true
-            "B" -> binding.carPrepareB.isChecked = true
-            "C" -> binding.carPrepareC.isChecked = true
-        }
+                        when (carResource.smellScore) {
+                            "A" -> binding.carInnerA.isChecked = true
+                            "B" -> binding.carInnerB.isChecked = true
+                            "C" -> binding.carInnerC.isChecked = true
+                        }
 
-        when (carResource.hardwareScore) {
-            "A" -> binding.carDisposeA.isChecked = true
-            "B" -> binding.carDisposeB.isChecked = true
-            "C" -> binding.carDisposeC.isChecked = true
-        }
+                        when (carResource.waterPaperScore) {
+                            "A" -> binding.carPrepareA.isChecked = true
+                            "B" -> binding.carPrepareB.isChecked = true
+                            "C" -> binding.carPrepareC.isChecked = true
+                        }
 
-        when (carResource.timeScore) {
-            "A" -> binding.timeConceptA.isChecked = true
-            "B" -> binding.timeConceptB.isChecked = true
-            "C" -> binding.timeConceptC.isChecked = true
-        }
+                        when (carResource.hardwareScore) {
+                            "A" -> binding.carDisposeA.isChecked = true
+                            "B" -> binding.carDisposeB.isChecked = true
+                            "C" -> binding.carDisposeC.isChecked = true
+                        }
 
-        when (carResource.safetyScore) {
-            "A" -> binding.safetyConceptA.isChecked = true
-            "B" -> binding.safetyConceptB.isChecked = true
-            "C" -> binding.safetyConceptC.isChecked = true
-        }
+                        when (carResource.timeScore) {
+                            "A" -> binding.timeConceptA.isChecked = true
+                            "B" -> binding.timeConceptB.isChecked = true
+                            "C" -> binding.timeConceptC.isChecked = true
+                        }
 
-        when (carResource.drivingAgeScore) {
-            "A" -> binding.driverA.isChecked = true
-            "B" -> binding.driverB.isChecked = true
-            "C" -> binding.driverC.isChecked = true
-        }
+                        when (carResource.safetyScore) {
+                            "A" -> binding.safetyConceptA.isChecked = true
+                            "B" -> binding.safetyConceptB.isChecked = true
+                            "C" -> binding.safetyConceptC.isChecked = true
+                        }
+
+                        when (carResource.drivingAgeScore) {
+                            "A" -> binding.driverA.isChecked = true
+                            "B" -> binding.driverB.isChecked = true
+                            "C" -> binding.driverC.isChecked = true
+                        }
+
+                    } else {
+                        showMessage(resourceResponse.msg)
+                    }
+                }
+            }
+
+            override fun onFailure(call: Call<CarResourceDetailResponse>, t: Throwable) {
+                showErrorInfo(R.string.car_resource_detail_get_failed)
+            }
+        })
     }
 
     /**

+ 1 - 1
app/src/main/java/com/pan_american/android/ui/resource_management/car_resource/CarResourceListFragment.kt

@@ -174,7 +174,7 @@ class CarResourceListFragment : BaseFragment<FragmentCarResourceListBinding>() {
                 override fun onItemClick(position: Int) {
                     val intent =
                         Intent(OASystem.context, AddCarResourceActivity::class.java).apply {
-                            putExtra("carResource", carList[position])
+                            putExtra("resource_id", carList[position].id)
                             putExtra("fromList", true)
                         }
 

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

@@ -44,8 +44,8 @@ class AddGuideResourceActivity : BaseActivity<ActivityAddGuideResourceBinding>()
         screenAdaptation(binding)
 
         intent.apply {
-            fromList = intent.getBooleanExtra("fromList", false)
-            resourceId = intent.getIntExtra("resource_id", 0)
+            fromList = this.getBooleanExtra("fromList", false)
+            resourceId = this.getIntExtra("resource_id", 0)
         }
 
 

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

@@ -169,6 +169,7 @@ class GuideResourceListFragment : BaseFragment<FragmentGuideResourceListBinding>
                 }
             }
         }.create()
+
         binding.guideResourceList.adapter = adapter
 
         adapter.onRecyclerViewItemClick =

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

@@ -407,6 +407,7 @@
 
     <!-- 车公司资料,错误信息 -->
     <string name="car_resource_list_get_failed">车公司资料列表获取失败</string>
+    <string name="car_resource_detail_get_failed">车公司资料详情获取失败</string>
 
     <!-- 酒店资料数据 -->
     <string name="add_hotel_resource">新增酒店资料数据</string>