diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 719698d..f8f54fe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -72,6 +72,7 @@ + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 719698d..f8f54fe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -72,6 +72,7 @@ + diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt index ad81434..dfdea73 100644 --- a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt @@ -173,7 +173,7 @@ "合同发票" -> requireContext().navigatePageTo() // "业务统计" -> requireContext().navigatePageTo() "客户列表" -> requireContext().navigatePageTo() -// "外场检测" -> requireContext().navigatePageTo() + "外场检测" -> requireContext().navigatePageTo() } } }) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 719698d..f8f54fe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -72,6 +72,7 @@ + diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt index ad81434..dfdea73 100644 --- a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt @@ -173,7 +173,7 @@ "合同发票" -> requireContext().navigatePageTo() // "业务统计" -> requireContext().navigatePageTo() "客户列表" -> requireContext().navigatePageTo() -// "外场检测" -> requireContext().navigatePageTo() + "外场检测" -> requireContext().navigatePageTo() } } }) diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt new file mode 100644 index 0000000..85a8cb1 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt @@ -0,0 +1,174 @@ +package com.casic.xz.meterage.fragment.outfield + +import android.os.Handler +import android.view.View +import androidx.lifecycle.ViewModelProvider +import androidx.recyclerview.widget.DividerItemDecoration +import com.casic.xz.meterage.R +import com.casic.xz.meterage.extensions.diffCurrentTime +import com.casic.xz.meterage.extensions.formatToYearMonthDay +import com.casic.xz.meterage.extensions.showEmptyPage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.vm.OutfieldDetectionViewModel +import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter +import com.pengxh.kt.lite.adapter.ViewHolder +import com.pengxh.kt.lite.base.KotlinBaseFragment +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.fragment_outfield_detection.* +import kotlinx.android.synthetic.main.include_empty_view.* + +/** + * 外场检测 + * + * formId:ywglxcjc + * */ +class OutfieldDetectionFragment(private val status: String) : KotlinBaseFragment() { + + private lateinit var weakReferenceHandler: WeakReferenceHandler + private lateinit var outfieldDetectionViewModel: OutfieldDetectionViewModel + private lateinit var outfieldDetectionAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var pageIndex = 1 + private var isRefresh = false + private var isLoadMore = false + + override fun initData() { + weakReferenceHandler = WeakReferenceHandler(callback) + outfieldDetectionViewModel = ViewModelProvider(this)[OutfieldDetectionViewModel::class.java] + outfieldDetectionViewModel.outfieldDetectionList.observe(this) { + if (it.code == 200) { + val dataRows = it.data?.rows!! + when { + isRefresh -> { + dataBeans.clear() + dataBeans = dataRows + outfieldLayout.finishRefresh() + isRefresh = false + } + isLoadMore -> { + if (dataRows.size == 0) { + "到底了,别拉了".show(requireContext()) + } + dataBeans.addAll(dataRows) + outfieldLayout.finishLoadMore() + isLoadMore = false + } + else -> { + dataBeans = dataRows + } + } + weakReferenceHandler.sendEmptyMessage(2023041101) + } + } + } + + override fun initEvent() { + outfieldLayout.setOnRefreshListener { + isRefresh = true + //刷新之后页码重置 + pageIndex = 1 + getOutfieldDetectionList() + } + + outfieldLayout.setOnLoadMoreListener { + isLoadMore = true + pageIndex++ + getOutfieldDetectionList() + } + } + + override fun onResume() { + super.onResume() + pageIndex = 1 + getOutfieldDetectionList() + } + + private fun getOutfieldDetectionList() { + outfieldDetectionViewModel.getOutfieldDetectionList( + status, "", "", "", pageIndex + ) + } + + override fun initLayoutView(): Int = R.layout.fragment_outfield_detection + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + private val callback = Handler.Callback { + when (it.what) { + 2023041101 -> { + if (isRefresh || isLoadMore) { + outfieldDetectionAdapter.notifyDataSetChanged() + } else { + if (dataBeans.size == 0) { + emptyView!!.showEmptyPage("无外场检测申请") { + pageIndex = 1 + getOutfieldDetectionList() + } + } else { + emptyView!!.hide() + outfieldDetectionAdapter = object : + NormalRecyclerAdapter( + R.layout.item_outfield_detection_rv_l, dataBeans + ) { + override fun convertView( + viewHolder: ViewHolder, + position: Int, + item: OutfieldDetectionListModel.DataModel.RowsModel + ) { + val deltaT = item.applyTime.diffCurrentTime() + if (deltaT <= 24) { + viewHolder.setVisibility(R.id.overTimeView, View.GONE) + } else { + viewHolder.setVisibility(R.id.overTimeView, View.VISIBLE) + } + + val remark = if (item.remark.isNullOrBlank()) { + "客户没添加任何备注信息" + } else { + "【备注】:${item.remark}" + } + + viewHolder.setText(R.id.executiveItemView, item.executiveItem) + .setText( + R.id.hazardSourceView, item.hazardSourceAndPreventionMethod + ) + .setText(R.id.remarkView, remark) + .setText(R.id.fullAddressView, "详细地址:${item.fullAddress}") + .setText( + R.id.executiveEnvironmentView, + "现场环境:${item.executiveEnvironment}" + ) + .setText( + R.id.applyTimeView, + "申请时间:${item.applyTime.formatToYearMonthDay()}" + ) + .setText(R.id.directorView, item.director) + .setText(R.id.phoneView, item.phone) + } + } + outfieldRecyclerView.addItemDecoration( + DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL) + ) + outfieldRecyclerView.adapter = outfieldDetectionAdapter + outfieldDetectionAdapter.setOnItemClickedListener(object : + NormalRecyclerAdapter.OnItemClickedListener { + override fun onItemClicked( + position: Int, t: OutfieldDetectionListModel.DataModel.RowsModel + ) { + + } + }) + } + } + } + } + true + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 719698d..f8f54fe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -72,6 +72,7 @@ + diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt index ad81434..dfdea73 100644 --- a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt @@ -173,7 +173,7 @@ "合同发票" -> requireContext().navigatePageTo() // "业务统计" -> requireContext().navigatePageTo() "客户列表" -> requireContext().navigatePageTo() -// "外场检测" -> requireContext().navigatePageTo() + "外场检测" -> requireContext().navigatePageTo() } } }) diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt new file mode 100644 index 0000000..85a8cb1 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt @@ -0,0 +1,174 @@ +package com.casic.xz.meterage.fragment.outfield + +import android.os.Handler +import android.view.View +import androidx.lifecycle.ViewModelProvider +import androidx.recyclerview.widget.DividerItemDecoration +import com.casic.xz.meterage.R +import com.casic.xz.meterage.extensions.diffCurrentTime +import com.casic.xz.meterage.extensions.formatToYearMonthDay +import com.casic.xz.meterage.extensions.showEmptyPage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.vm.OutfieldDetectionViewModel +import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter +import com.pengxh.kt.lite.adapter.ViewHolder +import com.pengxh.kt.lite.base.KotlinBaseFragment +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.fragment_outfield_detection.* +import kotlinx.android.synthetic.main.include_empty_view.* + +/** + * 外场检测 + * + * formId:ywglxcjc + * */ +class OutfieldDetectionFragment(private val status: String) : KotlinBaseFragment() { + + private lateinit var weakReferenceHandler: WeakReferenceHandler + private lateinit var outfieldDetectionViewModel: OutfieldDetectionViewModel + private lateinit var outfieldDetectionAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var pageIndex = 1 + private var isRefresh = false + private var isLoadMore = false + + override fun initData() { + weakReferenceHandler = WeakReferenceHandler(callback) + outfieldDetectionViewModel = ViewModelProvider(this)[OutfieldDetectionViewModel::class.java] + outfieldDetectionViewModel.outfieldDetectionList.observe(this) { + if (it.code == 200) { + val dataRows = it.data?.rows!! + when { + isRefresh -> { + dataBeans.clear() + dataBeans = dataRows + outfieldLayout.finishRefresh() + isRefresh = false + } + isLoadMore -> { + if (dataRows.size == 0) { + "到底了,别拉了".show(requireContext()) + } + dataBeans.addAll(dataRows) + outfieldLayout.finishLoadMore() + isLoadMore = false + } + else -> { + dataBeans = dataRows + } + } + weakReferenceHandler.sendEmptyMessage(2023041101) + } + } + } + + override fun initEvent() { + outfieldLayout.setOnRefreshListener { + isRefresh = true + //刷新之后页码重置 + pageIndex = 1 + getOutfieldDetectionList() + } + + outfieldLayout.setOnLoadMoreListener { + isLoadMore = true + pageIndex++ + getOutfieldDetectionList() + } + } + + override fun onResume() { + super.onResume() + pageIndex = 1 + getOutfieldDetectionList() + } + + private fun getOutfieldDetectionList() { + outfieldDetectionViewModel.getOutfieldDetectionList( + status, "", "", "", pageIndex + ) + } + + override fun initLayoutView(): Int = R.layout.fragment_outfield_detection + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + private val callback = Handler.Callback { + when (it.what) { + 2023041101 -> { + if (isRefresh || isLoadMore) { + outfieldDetectionAdapter.notifyDataSetChanged() + } else { + if (dataBeans.size == 0) { + emptyView!!.showEmptyPage("无外场检测申请") { + pageIndex = 1 + getOutfieldDetectionList() + } + } else { + emptyView!!.hide() + outfieldDetectionAdapter = object : + NormalRecyclerAdapter( + R.layout.item_outfield_detection_rv_l, dataBeans + ) { + override fun convertView( + viewHolder: ViewHolder, + position: Int, + item: OutfieldDetectionListModel.DataModel.RowsModel + ) { + val deltaT = item.applyTime.diffCurrentTime() + if (deltaT <= 24) { + viewHolder.setVisibility(R.id.overTimeView, View.GONE) + } else { + viewHolder.setVisibility(R.id.overTimeView, View.VISIBLE) + } + + val remark = if (item.remark.isNullOrBlank()) { + "客户没添加任何备注信息" + } else { + "【备注】:${item.remark}" + } + + viewHolder.setText(R.id.executiveItemView, item.executiveItem) + .setText( + R.id.hazardSourceView, item.hazardSourceAndPreventionMethod + ) + .setText(R.id.remarkView, remark) + .setText(R.id.fullAddressView, "详细地址:${item.fullAddress}") + .setText( + R.id.executiveEnvironmentView, + "现场环境:${item.executiveEnvironment}" + ) + .setText( + R.id.applyTimeView, + "申请时间:${item.applyTime.formatToYearMonthDay()}" + ) + .setText(R.id.directorView, item.director) + .setText(R.id.phoneView, item.phone) + } + } + outfieldRecyclerView.addItemDecoration( + DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL) + ) + outfieldRecyclerView.adapter = outfieldDetectionAdapter + outfieldDetectionAdapter.setOnItemClickedListener(object : + NormalRecyclerAdapter.OnItemClickedListener { + override fun onItemClicked( + position: Int, t: OutfieldDetectionListModel.DataModel.RowsModel + ) { + + } + }) + } + } + } + } + true + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java new file mode 100644 index 0000000..1397228 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java @@ -0,0 +1,364 @@ +package com.casic.xz.meterage.model; + +import java.util.List; + +public class OutfieldDetectionListModel { + + private int code; + private DataModel data; + private String message; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String addressAreaName; + private String addressCityName; + private String addressCountryName; + private String addressProvinceName; + private String applyTime; + private String approvalStatus; + private String approvalStatusName; + private String createTime; + private String customerId; + private String customerName; + private String decisionItem; + private String director; + private String directorId; + private String directorName; + private String executiveAddress; + private String executiveEnvironment; + private String executiveItem; + private String fullAddress; + private String hazardSourceAndPreventionMethod; + private String id; + private String isDel; + private String orderId; + private String phone; + private String preCost; + private String preEndTime; + private String preStartTime; + private String processId; + private String remark; + private String siteExecutiveName; + private String siteExecutiveNo; + private String taskId; + private String taskSource; + private String taskSourceName; + private String updateTime; + + public String getAddressAreaName() { + return addressAreaName; + } + + public void setAddressAreaName(String addressAreaName) { + this.addressAreaName = addressAreaName; + } + + public String getAddressCityName() { + return addressCityName; + } + + public void setAddressCityName(String addressCityName) { + this.addressCityName = addressCityName; + } + + public String getAddressCountryName() { + return addressCountryName; + } + + public void setAddressCountryName(String addressCountryName) { + this.addressCountryName = addressCountryName; + } + + public String getAddressProvinceName() { + return addressProvinceName; + } + + public void setAddressProvinceName(String addressProvinceName) { + this.addressProvinceName = addressProvinceName; + } + + public String getApplyTime() { + return applyTime; + } + + public void setApplyTime(String applyTime) { + this.applyTime = applyTime; + } + + public String getApprovalStatus() { + return approvalStatus; + } + + public void setApprovalStatus(String approvalStatus) { + this.approvalStatus = approvalStatus; + } + + public String getApprovalStatusName() { + return approvalStatusName; + } + + public void setApprovalStatusName(String approvalStatusName) { + this.approvalStatusName = approvalStatusName; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getDecisionItem() { + return decisionItem; + } + + public void setDecisionItem(String decisionItem) { + this.decisionItem = decisionItem; + } + + public String getDirector() { + return director; + } + + public void setDirector(String director) { + this.director = director; + } + + public String getDirectorId() { + return directorId; + } + + public void setDirectorId(String directorId) { + this.directorId = directorId; + } + + public String getDirectorName() { + return directorName; + } + + public void setDirectorName(String directorName) { + this.directorName = directorName; + } + + public String getExecutiveAddress() { + return executiveAddress; + } + + public void setExecutiveAddress(String executiveAddress) { + this.executiveAddress = executiveAddress; + } + + public String getExecutiveEnvironment() { + return executiveEnvironment; + } + + public void setExecutiveEnvironment(String executiveEnvironment) { + this.executiveEnvironment = executiveEnvironment; + } + + public String getExecutiveItem() { + return executiveItem; + } + + public void setExecutiveItem(String executiveItem) { + this.executiveItem = executiveItem; + } + + public String getFullAddress() { + return fullAddress; + } + + public void setFullAddress(String fullAddress) { + this.fullAddress = fullAddress; + } + + public String getHazardSourceAndPreventionMethod() { + return hazardSourceAndPreventionMethod; + } + + public void setHazardSourceAndPreventionMethod(String hazardSourceAndPreventionMethod) { + this.hazardSourceAndPreventionMethod = hazardSourceAndPreventionMethod; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsDel() { + return isDel; + } + + public void setIsDel(String isDel) { + this.isDel = isDel; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPreCost() { + return preCost; + } + + public void setPreCost(String preCost) { + this.preCost = preCost; + } + + public String getPreEndTime() { + return preEndTime; + } + + public void setPreEndTime(String preEndTime) { + this.preEndTime = preEndTime; + } + + public String getPreStartTime() { + return preStartTime; + } + + public void setPreStartTime(String preStartTime) { + this.preStartTime = preStartTime; + } + + public String getProcessId() { + return processId; + } + + public void setProcessId(String processId) { + this.processId = processId; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getSiteExecutiveName() { + return siteExecutiveName; + } + + public void setSiteExecutiveName(String siteExecutiveName) { + this.siteExecutiveName = siteExecutiveName; + } + + public String getSiteExecutiveNo() { + return siteExecutiveNo; + } + + public void setSiteExecutiveNo(String siteExecutiveNo) { + this.siteExecutiveNo = siteExecutiveNo; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskSource() { + return taskSource; + } + + public void setTaskSource(String taskSource) { + this.taskSource = taskSource; + } + + public String getTaskSourceName() { + return taskSourceName; + } + + public void setTaskSourceName(String taskSourceName) { + this.taskSourceName = taskSourceName; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + } + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 719698d..f8f54fe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -72,6 +72,7 @@ + diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt index ad81434..dfdea73 100644 --- a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt @@ -173,7 +173,7 @@ "合同发票" -> requireContext().navigatePageTo() // "业务统计" -> requireContext().navigatePageTo() "客户列表" -> requireContext().navigatePageTo() -// "外场检测" -> requireContext().navigatePageTo() + "外场检测" -> requireContext().navigatePageTo() } } }) diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt new file mode 100644 index 0000000..85a8cb1 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt @@ -0,0 +1,174 @@ +package com.casic.xz.meterage.fragment.outfield + +import android.os.Handler +import android.view.View +import androidx.lifecycle.ViewModelProvider +import androidx.recyclerview.widget.DividerItemDecoration +import com.casic.xz.meterage.R +import com.casic.xz.meterage.extensions.diffCurrentTime +import com.casic.xz.meterage.extensions.formatToYearMonthDay +import com.casic.xz.meterage.extensions.showEmptyPage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.vm.OutfieldDetectionViewModel +import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter +import com.pengxh.kt.lite.adapter.ViewHolder +import com.pengxh.kt.lite.base.KotlinBaseFragment +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.fragment_outfield_detection.* +import kotlinx.android.synthetic.main.include_empty_view.* + +/** + * 外场检测 + * + * formId:ywglxcjc + * */ +class OutfieldDetectionFragment(private val status: String) : KotlinBaseFragment() { + + private lateinit var weakReferenceHandler: WeakReferenceHandler + private lateinit var outfieldDetectionViewModel: OutfieldDetectionViewModel + private lateinit var outfieldDetectionAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var pageIndex = 1 + private var isRefresh = false + private var isLoadMore = false + + override fun initData() { + weakReferenceHandler = WeakReferenceHandler(callback) + outfieldDetectionViewModel = ViewModelProvider(this)[OutfieldDetectionViewModel::class.java] + outfieldDetectionViewModel.outfieldDetectionList.observe(this) { + if (it.code == 200) { + val dataRows = it.data?.rows!! + when { + isRefresh -> { + dataBeans.clear() + dataBeans = dataRows + outfieldLayout.finishRefresh() + isRefresh = false + } + isLoadMore -> { + if (dataRows.size == 0) { + "到底了,别拉了".show(requireContext()) + } + dataBeans.addAll(dataRows) + outfieldLayout.finishLoadMore() + isLoadMore = false + } + else -> { + dataBeans = dataRows + } + } + weakReferenceHandler.sendEmptyMessage(2023041101) + } + } + } + + override fun initEvent() { + outfieldLayout.setOnRefreshListener { + isRefresh = true + //刷新之后页码重置 + pageIndex = 1 + getOutfieldDetectionList() + } + + outfieldLayout.setOnLoadMoreListener { + isLoadMore = true + pageIndex++ + getOutfieldDetectionList() + } + } + + override fun onResume() { + super.onResume() + pageIndex = 1 + getOutfieldDetectionList() + } + + private fun getOutfieldDetectionList() { + outfieldDetectionViewModel.getOutfieldDetectionList( + status, "", "", "", pageIndex + ) + } + + override fun initLayoutView(): Int = R.layout.fragment_outfield_detection + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + private val callback = Handler.Callback { + when (it.what) { + 2023041101 -> { + if (isRefresh || isLoadMore) { + outfieldDetectionAdapter.notifyDataSetChanged() + } else { + if (dataBeans.size == 0) { + emptyView!!.showEmptyPage("无外场检测申请") { + pageIndex = 1 + getOutfieldDetectionList() + } + } else { + emptyView!!.hide() + outfieldDetectionAdapter = object : + NormalRecyclerAdapter( + R.layout.item_outfield_detection_rv_l, dataBeans + ) { + override fun convertView( + viewHolder: ViewHolder, + position: Int, + item: OutfieldDetectionListModel.DataModel.RowsModel + ) { + val deltaT = item.applyTime.diffCurrentTime() + if (deltaT <= 24) { + viewHolder.setVisibility(R.id.overTimeView, View.GONE) + } else { + viewHolder.setVisibility(R.id.overTimeView, View.VISIBLE) + } + + val remark = if (item.remark.isNullOrBlank()) { + "客户没添加任何备注信息" + } else { + "【备注】:${item.remark}" + } + + viewHolder.setText(R.id.executiveItemView, item.executiveItem) + .setText( + R.id.hazardSourceView, item.hazardSourceAndPreventionMethod + ) + .setText(R.id.remarkView, remark) + .setText(R.id.fullAddressView, "详细地址:${item.fullAddress}") + .setText( + R.id.executiveEnvironmentView, + "现场环境:${item.executiveEnvironment}" + ) + .setText( + R.id.applyTimeView, + "申请时间:${item.applyTime.formatToYearMonthDay()}" + ) + .setText(R.id.directorView, item.director) + .setText(R.id.phoneView, item.phone) + } + } + outfieldRecyclerView.addItemDecoration( + DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL) + ) + outfieldRecyclerView.adapter = outfieldDetectionAdapter + outfieldDetectionAdapter.setOnItemClickedListener(object : + NormalRecyclerAdapter.OnItemClickedListener { + override fun onItemClicked( + position: Int, t: OutfieldDetectionListModel.DataModel.RowsModel + ) { + + } + }) + } + } + } + } + true + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java new file mode 100644 index 0000000..1397228 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java @@ -0,0 +1,364 @@ +package com.casic.xz.meterage.model; + +import java.util.List; + +public class OutfieldDetectionListModel { + + private int code; + private DataModel data; + private String message; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String addressAreaName; + private String addressCityName; + private String addressCountryName; + private String addressProvinceName; + private String applyTime; + private String approvalStatus; + private String approvalStatusName; + private String createTime; + private String customerId; + private String customerName; + private String decisionItem; + private String director; + private String directorId; + private String directorName; + private String executiveAddress; + private String executiveEnvironment; + private String executiveItem; + private String fullAddress; + private String hazardSourceAndPreventionMethod; + private String id; + private String isDel; + private String orderId; + private String phone; + private String preCost; + private String preEndTime; + private String preStartTime; + private String processId; + private String remark; + private String siteExecutiveName; + private String siteExecutiveNo; + private String taskId; + private String taskSource; + private String taskSourceName; + private String updateTime; + + public String getAddressAreaName() { + return addressAreaName; + } + + public void setAddressAreaName(String addressAreaName) { + this.addressAreaName = addressAreaName; + } + + public String getAddressCityName() { + return addressCityName; + } + + public void setAddressCityName(String addressCityName) { + this.addressCityName = addressCityName; + } + + public String getAddressCountryName() { + return addressCountryName; + } + + public void setAddressCountryName(String addressCountryName) { + this.addressCountryName = addressCountryName; + } + + public String getAddressProvinceName() { + return addressProvinceName; + } + + public void setAddressProvinceName(String addressProvinceName) { + this.addressProvinceName = addressProvinceName; + } + + public String getApplyTime() { + return applyTime; + } + + public void setApplyTime(String applyTime) { + this.applyTime = applyTime; + } + + public String getApprovalStatus() { + return approvalStatus; + } + + public void setApprovalStatus(String approvalStatus) { + this.approvalStatus = approvalStatus; + } + + public String getApprovalStatusName() { + return approvalStatusName; + } + + public void setApprovalStatusName(String approvalStatusName) { + this.approvalStatusName = approvalStatusName; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getDecisionItem() { + return decisionItem; + } + + public void setDecisionItem(String decisionItem) { + this.decisionItem = decisionItem; + } + + public String getDirector() { + return director; + } + + public void setDirector(String director) { + this.director = director; + } + + public String getDirectorId() { + return directorId; + } + + public void setDirectorId(String directorId) { + this.directorId = directorId; + } + + public String getDirectorName() { + return directorName; + } + + public void setDirectorName(String directorName) { + this.directorName = directorName; + } + + public String getExecutiveAddress() { + return executiveAddress; + } + + public void setExecutiveAddress(String executiveAddress) { + this.executiveAddress = executiveAddress; + } + + public String getExecutiveEnvironment() { + return executiveEnvironment; + } + + public void setExecutiveEnvironment(String executiveEnvironment) { + this.executiveEnvironment = executiveEnvironment; + } + + public String getExecutiveItem() { + return executiveItem; + } + + public void setExecutiveItem(String executiveItem) { + this.executiveItem = executiveItem; + } + + public String getFullAddress() { + return fullAddress; + } + + public void setFullAddress(String fullAddress) { + this.fullAddress = fullAddress; + } + + public String getHazardSourceAndPreventionMethod() { + return hazardSourceAndPreventionMethod; + } + + public void setHazardSourceAndPreventionMethod(String hazardSourceAndPreventionMethod) { + this.hazardSourceAndPreventionMethod = hazardSourceAndPreventionMethod; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsDel() { + return isDel; + } + + public void setIsDel(String isDel) { + this.isDel = isDel; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPreCost() { + return preCost; + } + + public void setPreCost(String preCost) { + this.preCost = preCost; + } + + public String getPreEndTime() { + return preEndTime; + } + + public void setPreEndTime(String preEndTime) { + this.preEndTime = preEndTime; + } + + public String getPreStartTime() { + return preStartTime; + } + + public void setPreStartTime(String preStartTime) { + this.preStartTime = preStartTime; + } + + public String getProcessId() { + return processId; + } + + public void setProcessId(String processId) { + this.processId = processId; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getSiteExecutiveName() { + return siteExecutiveName; + } + + public void setSiteExecutiveName(String siteExecutiveName) { + this.siteExecutiveName = siteExecutiveName; + } + + public String getSiteExecutiveNo() { + return siteExecutiveNo; + } + + public void setSiteExecutiveNo(String siteExecutiveNo) { + this.siteExecutiveNo = siteExecutiveNo; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskSource() { + return taskSource; + } + + public void setTaskSource(String taskSource) { + this.taskSource = taskSource; + } + + public String getTaskSourceName() { + return taskSourceName; + } + + public void setTaskSourceName(String taskSourceName) { + this.taskSourceName = taskSourceName; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + } + } +} diff --git a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt index 36059c5..1feffe7 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt @@ -69,4 +69,5 @@ const val STANDARD_FILE_FORM_ID = "jlglwjsp" const val CERTIFICATE_REPORT_FORM_ID = "ywglzsbg" const val CONTRACT_FORM_ID = "cwczht" + const val OUTFIELD_DETECTION_FORM_ID = "ywglxcjc" } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 719698d..f8f54fe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -72,6 +72,7 @@ + diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt index ad81434..dfdea73 100644 --- a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt @@ -173,7 +173,7 @@ "合同发票" -> requireContext().navigatePageTo() // "业务统计" -> requireContext().navigatePageTo() "客户列表" -> requireContext().navigatePageTo() -// "外场检测" -> requireContext().navigatePageTo() + "外场检测" -> requireContext().navigatePageTo() } } }) diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt new file mode 100644 index 0000000..85a8cb1 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt @@ -0,0 +1,174 @@ +package com.casic.xz.meterage.fragment.outfield + +import android.os.Handler +import android.view.View +import androidx.lifecycle.ViewModelProvider +import androidx.recyclerview.widget.DividerItemDecoration +import com.casic.xz.meterage.R +import com.casic.xz.meterage.extensions.diffCurrentTime +import com.casic.xz.meterage.extensions.formatToYearMonthDay +import com.casic.xz.meterage.extensions.showEmptyPage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.vm.OutfieldDetectionViewModel +import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter +import com.pengxh.kt.lite.adapter.ViewHolder +import com.pengxh.kt.lite.base.KotlinBaseFragment +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.fragment_outfield_detection.* +import kotlinx.android.synthetic.main.include_empty_view.* + +/** + * 外场检测 + * + * formId:ywglxcjc + * */ +class OutfieldDetectionFragment(private val status: String) : KotlinBaseFragment() { + + private lateinit var weakReferenceHandler: WeakReferenceHandler + private lateinit var outfieldDetectionViewModel: OutfieldDetectionViewModel + private lateinit var outfieldDetectionAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var pageIndex = 1 + private var isRefresh = false + private var isLoadMore = false + + override fun initData() { + weakReferenceHandler = WeakReferenceHandler(callback) + outfieldDetectionViewModel = ViewModelProvider(this)[OutfieldDetectionViewModel::class.java] + outfieldDetectionViewModel.outfieldDetectionList.observe(this) { + if (it.code == 200) { + val dataRows = it.data?.rows!! + when { + isRefresh -> { + dataBeans.clear() + dataBeans = dataRows + outfieldLayout.finishRefresh() + isRefresh = false + } + isLoadMore -> { + if (dataRows.size == 0) { + "到底了,别拉了".show(requireContext()) + } + dataBeans.addAll(dataRows) + outfieldLayout.finishLoadMore() + isLoadMore = false + } + else -> { + dataBeans = dataRows + } + } + weakReferenceHandler.sendEmptyMessage(2023041101) + } + } + } + + override fun initEvent() { + outfieldLayout.setOnRefreshListener { + isRefresh = true + //刷新之后页码重置 + pageIndex = 1 + getOutfieldDetectionList() + } + + outfieldLayout.setOnLoadMoreListener { + isLoadMore = true + pageIndex++ + getOutfieldDetectionList() + } + } + + override fun onResume() { + super.onResume() + pageIndex = 1 + getOutfieldDetectionList() + } + + private fun getOutfieldDetectionList() { + outfieldDetectionViewModel.getOutfieldDetectionList( + status, "", "", "", pageIndex + ) + } + + override fun initLayoutView(): Int = R.layout.fragment_outfield_detection + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + private val callback = Handler.Callback { + when (it.what) { + 2023041101 -> { + if (isRefresh || isLoadMore) { + outfieldDetectionAdapter.notifyDataSetChanged() + } else { + if (dataBeans.size == 0) { + emptyView!!.showEmptyPage("无外场检测申请") { + pageIndex = 1 + getOutfieldDetectionList() + } + } else { + emptyView!!.hide() + outfieldDetectionAdapter = object : + NormalRecyclerAdapter( + R.layout.item_outfield_detection_rv_l, dataBeans + ) { + override fun convertView( + viewHolder: ViewHolder, + position: Int, + item: OutfieldDetectionListModel.DataModel.RowsModel + ) { + val deltaT = item.applyTime.diffCurrentTime() + if (deltaT <= 24) { + viewHolder.setVisibility(R.id.overTimeView, View.GONE) + } else { + viewHolder.setVisibility(R.id.overTimeView, View.VISIBLE) + } + + val remark = if (item.remark.isNullOrBlank()) { + "客户没添加任何备注信息" + } else { + "【备注】:${item.remark}" + } + + viewHolder.setText(R.id.executiveItemView, item.executiveItem) + .setText( + R.id.hazardSourceView, item.hazardSourceAndPreventionMethod + ) + .setText(R.id.remarkView, remark) + .setText(R.id.fullAddressView, "详细地址:${item.fullAddress}") + .setText( + R.id.executiveEnvironmentView, + "现场环境:${item.executiveEnvironment}" + ) + .setText( + R.id.applyTimeView, + "申请时间:${item.applyTime.formatToYearMonthDay()}" + ) + .setText(R.id.directorView, item.director) + .setText(R.id.phoneView, item.phone) + } + } + outfieldRecyclerView.addItemDecoration( + DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL) + ) + outfieldRecyclerView.adapter = outfieldDetectionAdapter + outfieldDetectionAdapter.setOnItemClickedListener(object : + NormalRecyclerAdapter.OnItemClickedListener { + override fun onItemClicked( + position: Int, t: OutfieldDetectionListModel.DataModel.RowsModel + ) { + + } + }) + } + } + } + } + true + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java new file mode 100644 index 0000000..1397228 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java @@ -0,0 +1,364 @@ +package com.casic.xz.meterage.model; + +import java.util.List; + +public class OutfieldDetectionListModel { + + private int code; + private DataModel data; + private String message; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String addressAreaName; + private String addressCityName; + private String addressCountryName; + private String addressProvinceName; + private String applyTime; + private String approvalStatus; + private String approvalStatusName; + private String createTime; + private String customerId; + private String customerName; + private String decisionItem; + private String director; + private String directorId; + private String directorName; + private String executiveAddress; + private String executiveEnvironment; + private String executiveItem; + private String fullAddress; + private String hazardSourceAndPreventionMethod; + private String id; + private String isDel; + private String orderId; + private String phone; + private String preCost; + private String preEndTime; + private String preStartTime; + private String processId; + private String remark; + private String siteExecutiveName; + private String siteExecutiveNo; + private String taskId; + private String taskSource; + private String taskSourceName; + private String updateTime; + + public String getAddressAreaName() { + return addressAreaName; + } + + public void setAddressAreaName(String addressAreaName) { + this.addressAreaName = addressAreaName; + } + + public String getAddressCityName() { + return addressCityName; + } + + public void setAddressCityName(String addressCityName) { + this.addressCityName = addressCityName; + } + + public String getAddressCountryName() { + return addressCountryName; + } + + public void setAddressCountryName(String addressCountryName) { + this.addressCountryName = addressCountryName; + } + + public String getAddressProvinceName() { + return addressProvinceName; + } + + public void setAddressProvinceName(String addressProvinceName) { + this.addressProvinceName = addressProvinceName; + } + + public String getApplyTime() { + return applyTime; + } + + public void setApplyTime(String applyTime) { + this.applyTime = applyTime; + } + + public String getApprovalStatus() { + return approvalStatus; + } + + public void setApprovalStatus(String approvalStatus) { + this.approvalStatus = approvalStatus; + } + + public String getApprovalStatusName() { + return approvalStatusName; + } + + public void setApprovalStatusName(String approvalStatusName) { + this.approvalStatusName = approvalStatusName; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getDecisionItem() { + return decisionItem; + } + + public void setDecisionItem(String decisionItem) { + this.decisionItem = decisionItem; + } + + public String getDirector() { + return director; + } + + public void setDirector(String director) { + this.director = director; + } + + public String getDirectorId() { + return directorId; + } + + public void setDirectorId(String directorId) { + this.directorId = directorId; + } + + public String getDirectorName() { + return directorName; + } + + public void setDirectorName(String directorName) { + this.directorName = directorName; + } + + public String getExecutiveAddress() { + return executiveAddress; + } + + public void setExecutiveAddress(String executiveAddress) { + this.executiveAddress = executiveAddress; + } + + public String getExecutiveEnvironment() { + return executiveEnvironment; + } + + public void setExecutiveEnvironment(String executiveEnvironment) { + this.executiveEnvironment = executiveEnvironment; + } + + public String getExecutiveItem() { + return executiveItem; + } + + public void setExecutiveItem(String executiveItem) { + this.executiveItem = executiveItem; + } + + public String getFullAddress() { + return fullAddress; + } + + public void setFullAddress(String fullAddress) { + this.fullAddress = fullAddress; + } + + public String getHazardSourceAndPreventionMethod() { + return hazardSourceAndPreventionMethod; + } + + public void setHazardSourceAndPreventionMethod(String hazardSourceAndPreventionMethod) { + this.hazardSourceAndPreventionMethod = hazardSourceAndPreventionMethod; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsDel() { + return isDel; + } + + public void setIsDel(String isDel) { + this.isDel = isDel; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPreCost() { + return preCost; + } + + public void setPreCost(String preCost) { + this.preCost = preCost; + } + + public String getPreEndTime() { + return preEndTime; + } + + public void setPreEndTime(String preEndTime) { + this.preEndTime = preEndTime; + } + + public String getPreStartTime() { + return preStartTime; + } + + public void setPreStartTime(String preStartTime) { + this.preStartTime = preStartTime; + } + + public String getProcessId() { + return processId; + } + + public void setProcessId(String processId) { + this.processId = processId; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getSiteExecutiveName() { + return siteExecutiveName; + } + + public void setSiteExecutiveName(String siteExecutiveName) { + this.siteExecutiveName = siteExecutiveName; + } + + public String getSiteExecutiveNo() { + return siteExecutiveNo; + } + + public void setSiteExecutiveNo(String siteExecutiveNo) { + this.siteExecutiveNo = siteExecutiveNo; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskSource() { + return taskSource; + } + + public void setTaskSource(String taskSource) { + this.taskSource = taskSource; + } + + public String getTaskSourceName() { + return taskSourceName; + } + + public void setTaskSourceName(String taskSourceName) { + this.taskSourceName = taskSourceName; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + } + } +} diff --git a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt index 36059c5..1feffe7 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt @@ -69,4 +69,5 @@ const val STANDARD_FILE_FORM_ID = "jlglwjsp" const val CERTIFICATE_REPORT_FORM_ID = "ywglzsbg" const val CONTRACT_FORM_ID = "cwczht" + const val OUTFIELD_DETECTION_FORM_ID = "ywglxcjc" } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt index d104cea..5bb091f 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt @@ -466,4 +466,15 @@ @Header("token") token: String, @Body requestBody: RequestBody ): String + + /** + * 获取外场检测申请列表 + */ + @POST("/business/siteExecutive/approval/listPage") + suspend fun getOutfieldDetectionList( + @Header("token") token: String, + @Body requestBody: RequestBody, + @QueryMap limit: Map, + @QueryMap offset: Map + ): String } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 719698d..f8f54fe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -72,6 +72,7 @@ + diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt index ad81434..dfdea73 100644 --- a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt @@ -173,7 +173,7 @@ "合同发票" -> requireContext().navigatePageTo() // "业务统计" -> requireContext().navigatePageTo() "客户列表" -> requireContext().navigatePageTo() -// "外场检测" -> requireContext().navigatePageTo() + "外场检测" -> requireContext().navigatePageTo() } } }) diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt new file mode 100644 index 0000000..85a8cb1 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt @@ -0,0 +1,174 @@ +package com.casic.xz.meterage.fragment.outfield + +import android.os.Handler +import android.view.View +import androidx.lifecycle.ViewModelProvider +import androidx.recyclerview.widget.DividerItemDecoration +import com.casic.xz.meterage.R +import com.casic.xz.meterage.extensions.diffCurrentTime +import com.casic.xz.meterage.extensions.formatToYearMonthDay +import com.casic.xz.meterage.extensions.showEmptyPage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.vm.OutfieldDetectionViewModel +import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter +import com.pengxh.kt.lite.adapter.ViewHolder +import com.pengxh.kt.lite.base.KotlinBaseFragment +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.fragment_outfield_detection.* +import kotlinx.android.synthetic.main.include_empty_view.* + +/** + * 外场检测 + * + * formId:ywglxcjc + * */ +class OutfieldDetectionFragment(private val status: String) : KotlinBaseFragment() { + + private lateinit var weakReferenceHandler: WeakReferenceHandler + private lateinit var outfieldDetectionViewModel: OutfieldDetectionViewModel + private lateinit var outfieldDetectionAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var pageIndex = 1 + private var isRefresh = false + private var isLoadMore = false + + override fun initData() { + weakReferenceHandler = WeakReferenceHandler(callback) + outfieldDetectionViewModel = ViewModelProvider(this)[OutfieldDetectionViewModel::class.java] + outfieldDetectionViewModel.outfieldDetectionList.observe(this) { + if (it.code == 200) { + val dataRows = it.data?.rows!! + when { + isRefresh -> { + dataBeans.clear() + dataBeans = dataRows + outfieldLayout.finishRefresh() + isRefresh = false + } + isLoadMore -> { + if (dataRows.size == 0) { + "到底了,别拉了".show(requireContext()) + } + dataBeans.addAll(dataRows) + outfieldLayout.finishLoadMore() + isLoadMore = false + } + else -> { + dataBeans = dataRows + } + } + weakReferenceHandler.sendEmptyMessage(2023041101) + } + } + } + + override fun initEvent() { + outfieldLayout.setOnRefreshListener { + isRefresh = true + //刷新之后页码重置 + pageIndex = 1 + getOutfieldDetectionList() + } + + outfieldLayout.setOnLoadMoreListener { + isLoadMore = true + pageIndex++ + getOutfieldDetectionList() + } + } + + override fun onResume() { + super.onResume() + pageIndex = 1 + getOutfieldDetectionList() + } + + private fun getOutfieldDetectionList() { + outfieldDetectionViewModel.getOutfieldDetectionList( + status, "", "", "", pageIndex + ) + } + + override fun initLayoutView(): Int = R.layout.fragment_outfield_detection + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + private val callback = Handler.Callback { + when (it.what) { + 2023041101 -> { + if (isRefresh || isLoadMore) { + outfieldDetectionAdapter.notifyDataSetChanged() + } else { + if (dataBeans.size == 0) { + emptyView!!.showEmptyPage("无外场检测申请") { + pageIndex = 1 + getOutfieldDetectionList() + } + } else { + emptyView!!.hide() + outfieldDetectionAdapter = object : + NormalRecyclerAdapter( + R.layout.item_outfield_detection_rv_l, dataBeans + ) { + override fun convertView( + viewHolder: ViewHolder, + position: Int, + item: OutfieldDetectionListModel.DataModel.RowsModel + ) { + val deltaT = item.applyTime.diffCurrentTime() + if (deltaT <= 24) { + viewHolder.setVisibility(R.id.overTimeView, View.GONE) + } else { + viewHolder.setVisibility(R.id.overTimeView, View.VISIBLE) + } + + val remark = if (item.remark.isNullOrBlank()) { + "客户没添加任何备注信息" + } else { + "【备注】:${item.remark}" + } + + viewHolder.setText(R.id.executiveItemView, item.executiveItem) + .setText( + R.id.hazardSourceView, item.hazardSourceAndPreventionMethod + ) + .setText(R.id.remarkView, remark) + .setText(R.id.fullAddressView, "详细地址:${item.fullAddress}") + .setText( + R.id.executiveEnvironmentView, + "现场环境:${item.executiveEnvironment}" + ) + .setText( + R.id.applyTimeView, + "申请时间:${item.applyTime.formatToYearMonthDay()}" + ) + .setText(R.id.directorView, item.director) + .setText(R.id.phoneView, item.phone) + } + } + outfieldRecyclerView.addItemDecoration( + DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL) + ) + outfieldRecyclerView.adapter = outfieldDetectionAdapter + outfieldDetectionAdapter.setOnItemClickedListener(object : + NormalRecyclerAdapter.OnItemClickedListener { + override fun onItemClicked( + position: Int, t: OutfieldDetectionListModel.DataModel.RowsModel + ) { + + } + }) + } + } + } + } + true + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java new file mode 100644 index 0000000..1397228 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java @@ -0,0 +1,364 @@ +package com.casic.xz.meterage.model; + +import java.util.List; + +public class OutfieldDetectionListModel { + + private int code; + private DataModel data; + private String message; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String addressAreaName; + private String addressCityName; + private String addressCountryName; + private String addressProvinceName; + private String applyTime; + private String approvalStatus; + private String approvalStatusName; + private String createTime; + private String customerId; + private String customerName; + private String decisionItem; + private String director; + private String directorId; + private String directorName; + private String executiveAddress; + private String executiveEnvironment; + private String executiveItem; + private String fullAddress; + private String hazardSourceAndPreventionMethod; + private String id; + private String isDel; + private String orderId; + private String phone; + private String preCost; + private String preEndTime; + private String preStartTime; + private String processId; + private String remark; + private String siteExecutiveName; + private String siteExecutiveNo; + private String taskId; + private String taskSource; + private String taskSourceName; + private String updateTime; + + public String getAddressAreaName() { + return addressAreaName; + } + + public void setAddressAreaName(String addressAreaName) { + this.addressAreaName = addressAreaName; + } + + public String getAddressCityName() { + return addressCityName; + } + + public void setAddressCityName(String addressCityName) { + this.addressCityName = addressCityName; + } + + public String getAddressCountryName() { + return addressCountryName; + } + + public void setAddressCountryName(String addressCountryName) { + this.addressCountryName = addressCountryName; + } + + public String getAddressProvinceName() { + return addressProvinceName; + } + + public void setAddressProvinceName(String addressProvinceName) { + this.addressProvinceName = addressProvinceName; + } + + public String getApplyTime() { + return applyTime; + } + + public void setApplyTime(String applyTime) { + this.applyTime = applyTime; + } + + public String getApprovalStatus() { + return approvalStatus; + } + + public void setApprovalStatus(String approvalStatus) { + this.approvalStatus = approvalStatus; + } + + public String getApprovalStatusName() { + return approvalStatusName; + } + + public void setApprovalStatusName(String approvalStatusName) { + this.approvalStatusName = approvalStatusName; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getDecisionItem() { + return decisionItem; + } + + public void setDecisionItem(String decisionItem) { + this.decisionItem = decisionItem; + } + + public String getDirector() { + return director; + } + + public void setDirector(String director) { + this.director = director; + } + + public String getDirectorId() { + return directorId; + } + + public void setDirectorId(String directorId) { + this.directorId = directorId; + } + + public String getDirectorName() { + return directorName; + } + + public void setDirectorName(String directorName) { + this.directorName = directorName; + } + + public String getExecutiveAddress() { + return executiveAddress; + } + + public void setExecutiveAddress(String executiveAddress) { + this.executiveAddress = executiveAddress; + } + + public String getExecutiveEnvironment() { + return executiveEnvironment; + } + + public void setExecutiveEnvironment(String executiveEnvironment) { + this.executiveEnvironment = executiveEnvironment; + } + + public String getExecutiveItem() { + return executiveItem; + } + + public void setExecutiveItem(String executiveItem) { + this.executiveItem = executiveItem; + } + + public String getFullAddress() { + return fullAddress; + } + + public void setFullAddress(String fullAddress) { + this.fullAddress = fullAddress; + } + + public String getHazardSourceAndPreventionMethod() { + return hazardSourceAndPreventionMethod; + } + + public void setHazardSourceAndPreventionMethod(String hazardSourceAndPreventionMethod) { + this.hazardSourceAndPreventionMethod = hazardSourceAndPreventionMethod; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsDel() { + return isDel; + } + + public void setIsDel(String isDel) { + this.isDel = isDel; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPreCost() { + return preCost; + } + + public void setPreCost(String preCost) { + this.preCost = preCost; + } + + public String getPreEndTime() { + return preEndTime; + } + + public void setPreEndTime(String preEndTime) { + this.preEndTime = preEndTime; + } + + public String getPreStartTime() { + return preStartTime; + } + + public void setPreStartTime(String preStartTime) { + this.preStartTime = preStartTime; + } + + public String getProcessId() { + return processId; + } + + public void setProcessId(String processId) { + this.processId = processId; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getSiteExecutiveName() { + return siteExecutiveName; + } + + public void setSiteExecutiveName(String siteExecutiveName) { + this.siteExecutiveName = siteExecutiveName; + } + + public String getSiteExecutiveNo() { + return siteExecutiveNo; + } + + public void setSiteExecutiveNo(String siteExecutiveNo) { + this.siteExecutiveNo = siteExecutiveNo; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskSource() { + return taskSource; + } + + public void setTaskSource(String taskSource) { + this.taskSource = taskSource; + } + + public String getTaskSourceName() { + return taskSourceName; + } + + public void setTaskSourceName(String taskSourceName) { + this.taskSourceName = taskSourceName; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + } + } +} diff --git a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt index 36059c5..1feffe7 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt @@ -69,4 +69,5 @@ const val STANDARD_FILE_FORM_ID = "jlglwjsp" const val CERTIFICATE_REPORT_FORM_ID = "ywglzsbg" const val CONTRACT_FORM_ID = "cwczht" + const val OUTFIELD_DETECTION_FORM_ID = "ywglxcjc" } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt index d104cea..5bb091f 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt @@ -466,4 +466,15 @@ @Header("token") token: String, @Body requestBody: RequestBody ): String + + /** + * 获取外场检测申请列表 + */ + @POST("/business/siteExecutive/approval/listPage") + suspend fun getOutfieldDetectionList( + @Header("token") token: String, + @Body requestBody: RequestBody, + @QueryMap limit: Map, + @QueryMap offset: Map + ): String } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt index 759a2a5..add9920 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt @@ -1063,4 +1063,35 @@ ) return api.getContractDetail(AuthenticationHelper.token!!, requestBody) } + + /** + * 获取外场检测申请列表 + */ + suspend fun getOutfieldDetectionList( + approvalStatus: String, + customerName: String, + directorName: String, + siteExecutiveNo: String, + offset: Int + ): String { + val param = JsonObject() + param.addProperty("approvalStatus", approvalStatus) + param.addProperty("customerName", customerName) + param.addProperty("directorName", directorName) + param.addProperty("siteExecutiveNo", siteExecutiveNo) + param.addProperty("formId", LocaleConstant.OUTFIELD_DETECTION_FORM_ID) + + val requestBody = param.toString().toRequestBody( + "application/json;charset=UTF-8".toMediaType() + ) + + val limitMap = HashMap() + limitMap["limit"] = LocaleConstant.PAGE_LIMIT + + val offsetMap = HashMap() + offsetMap["offset"] = offset + return api.getOutfieldDetectionList( + AuthenticationHelper.token!!, requestBody, limitMap, offsetMap + ) + } } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 719698d..f8f54fe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -72,6 +72,7 @@ + diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt index ad81434..dfdea73 100644 --- a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt @@ -173,7 +173,7 @@ "合同发票" -> requireContext().navigatePageTo() // "业务统计" -> requireContext().navigatePageTo() "客户列表" -> requireContext().navigatePageTo() -// "外场检测" -> requireContext().navigatePageTo() + "外场检测" -> requireContext().navigatePageTo() } } }) diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt new file mode 100644 index 0000000..85a8cb1 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt @@ -0,0 +1,174 @@ +package com.casic.xz.meterage.fragment.outfield + +import android.os.Handler +import android.view.View +import androidx.lifecycle.ViewModelProvider +import androidx.recyclerview.widget.DividerItemDecoration +import com.casic.xz.meterage.R +import com.casic.xz.meterage.extensions.diffCurrentTime +import com.casic.xz.meterage.extensions.formatToYearMonthDay +import com.casic.xz.meterage.extensions.showEmptyPage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.vm.OutfieldDetectionViewModel +import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter +import com.pengxh.kt.lite.adapter.ViewHolder +import com.pengxh.kt.lite.base.KotlinBaseFragment +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.fragment_outfield_detection.* +import kotlinx.android.synthetic.main.include_empty_view.* + +/** + * 外场检测 + * + * formId:ywglxcjc + * */ +class OutfieldDetectionFragment(private val status: String) : KotlinBaseFragment() { + + private lateinit var weakReferenceHandler: WeakReferenceHandler + private lateinit var outfieldDetectionViewModel: OutfieldDetectionViewModel + private lateinit var outfieldDetectionAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var pageIndex = 1 + private var isRefresh = false + private var isLoadMore = false + + override fun initData() { + weakReferenceHandler = WeakReferenceHandler(callback) + outfieldDetectionViewModel = ViewModelProvider(this)[OutfieldDetectionViewModel::class.java] + outfieldDetectionViewModel.outfieldDetectionList.observe(this) { + if (it.code == 200) { + val dataRows = it.data?.rows!! + when { + isRefresh -> { + dataBeans.clear() + dataBeans = dataRows + outfieldLayout.finishRefresh() + isRefresh = false + } + isLoadMore -> { + if (dataRows.size == 0) { + "到底了,别拉了".show(requireContext()) + } + dataBeans.addAll(dataRows) + outfieldLayout.finishLoadMore() + isLoadMore = false + } + else -> { + dataBeans = dataRows + } + } + weakReferenceHandler.sendEmptyMessage(2023041101) + } + } + } + + override fun initEvent() { + outfieldLayout.setOnRefreshListener { + isRefresh = true + //刷新之后页码重置 + pageIndex = 1 + getOutfieldDetectionList() + } + + outfieldLayout.setOnLoadMoreListener { + isLoadMore = true + pageIndex++ + getOutfieldDetectionList() + } + } + + override fun onResume() { + super.onResume() + pageIndex = 1 + getOutfieldDetectionList() + } + + private fun getOutfieldDetectionList() { + outfieldDetectionViewModel.getOutfieldDetectionList( + status, "", "", "", pageIndex + ) + } + + override fun initLayoutView(): Int = R.layout.fragment_outfield_detection + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + private val callback = Handler.Callback { + when (it.what) { + 2023041101 -> { + if (isRefresh || isLoadMore) { + outfieldDetectionAdapter.notifyDataSetChanged() + } else { + if (dataBeans.size == 0) { + emptyView!!.showEmptyPage("无外场检测申请") { + pageIndex = 1 + getOutfieldDetectionList() + } + } else { + emptyView!!.hide() + outfieldDetectionAdapter = object : + NormalRecyclerAdapter( + R.layout.item_outfield_detection_rv_l, dataBeans + ) { + override fun convertView( + viewHolder: ViewHolder, + position: Int, + item: OutfieldDetectionListModel.DataModel.RowsModel + ) { + val deltaT = item.applyTime.diffCurrentTime() + if (deltaT <= 24) { + viewHolder.setVisibility(R.id.overTimeView, View.GONE) + } else { + viewHolder.setVisibility(R.id.overTimeView, View.VISIBLE) + } + + val remark = if (item.remark.isNullOrBlank()) { + "客户没添加任何备注信息" + } else { + "【备注】:${item.remark}" + } + + viewHolder.setText(R.id.executiveItemView, item.executiveItem) + .setText( + R.id.hazardSourceView, item.hazardSourceAndPreventionMethod + ) + .setText(R.id.remarkView, remark) + .setText(R.id.fullAddressView, "详细地址:${item.fullAddress}") + .setText( + R.id.executiveEnvironmentView, + "现场环境:${item.executiveEnvironment}" + ) + .setText( + R.id.applyTimeView, + "申请时间:${item.applyTime.formatToYearMonthDay()}" + ) + .setText(R.id.directorView, item.director) + .setText(R.id.phoneView, item.phone) + } + } + outfieldRecyclerView.addItemDecoration( + DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL) + ) + outfieldRecyclerView.adapter = outfieldDetectionAdapter + outfieldDetectionAdapter.setOnItemClickedListener(object : + NormalRecyclerAdapter.OnItemClickedListener { + override fun onItemClicked( + position: Int, t: OutfieldDetectionListModel.DataModel.RowsModel + ) { + + } + }) + } + } + } + } + true + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java new file mode 100644 index 0000000..1397228 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java @@ -0,0 +1,364 @@ +package com.casic.xz.meterage.model; + +import java.util.List; + +public class OutfieldDetectionListModel { + + private int code; + private DataModel data; + private String message; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String addressAreaName; + private String addressCityName; + private String addressCountryName; + private String addressProvinceName; + private String applyTime; + private String approvalStatus; + private String approvalStatusName; + private String createTime; + private String customerId; + private String customerName; + private String decisionItem; + private String director; + private String directorId; + private String directorName; + private String executiveAddress; + private String executiveEnvironment; + private String executiveItem; + private String fullAddress; + private String hazardSourceAndPreventionMethod; + private String id; + private String isDel; + private String orderId; + private String phone; + private String preCost; + private String preEndTime; + private String preStartTime; + private String processId; + private String remark; + private String siteExecutiveName; + private String siteExecutiveNo; + private String taskId; + private String taskSource; + private String taskSourceName; + private String updateTime; + + public String getAddressAreaName() { + return addressAreaName; + } + + public void setAddressAreaName(String addressAreaName) { + this.addressAreaName = addressAreaName; + } + + public String getAddressCityName() { + return addressCityName; + } + + public void setAddressCityName(String addressCityName) { + this.addressCityName = addressCityName; + } + + public String getAddressCountryName() { + return addressCountryName; + } + + public void setAddressCountryName(String addressCountryName) { + this.addressCountryName = addressCountryName; + } + + public String getAddressProvinceName() { + return addressProvinceName; + } + + public void setAddressProvinceName(String addressProvinceName) { + this.addressProvinceName = addressProvinceName; + } + + public String getApplyTime() { + return applyTime; + } + + public void setApplyTime(String applyTime) { + this.applyTime = applyTime; + } + + public String getApprovalStatus() { + return approvalStatus; + } + + public void setApprovalStatus(String approvalStatus) { + this.approvalStatus = approvalStatus; + } + + public String getApprovalStatusName() { + return approvalStatusName; + } + + public void setApprovalStatusName(String approvalStatusName) { + this.approvalStatusName = approvalStatusName; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getDecisionItem() { + return decisionItem; + } + + public void setDecisionItem(String decisionItem) { + this.decisionItem = decisionItem; + } + + public String getDirector() { + return director; + } + + public void setDirector(String director) { + this.director = director; + } + + public String getDirectorId() { + return directorId; + } + + public void setDirectorId(String directorId) { + this.directorId = directorId; + } + + public String getDirectorName() { + return directorName; + } + + public void setDirectorName(String directorName) { + this.directorName = directorName; + } + + public String getExecutiveAddress() { + return executiveAddress; + } + + public void setExecutiveAddress(String executiveAddress) { + this.executiveAddress = executiveAddress; + } + + public String getExecutiveEnvironment() { + return executiveEnvironment; + } + + public void setExecutiveEnvironment(String executiveEnvironment) { + this.executiveEnvironment = executiveEnvironment; + } + + public String getExecutiveItem() { + return executiveItem; + } + + public void setExecutiveItem(String executiveItem) { + this.executiveItem = executiveItem; + } + + public String getFullAddress() { + return fullAddress; + } + + public void setFullAddress(String fullAddress) { + this.fullAddress = fullAddress; + } + + public String getHazardSourceAndPreventionMethod() { + return hazardSourceAndPreventionMethod; + } + + public void setHazardSourceAndPreventionMethod(String hazardSourceAndPreventionMethod) { + this.hazardSourceAndPreventionMethod = hazardSourceAndPreventionMethod; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsDel() { + return isDel; + } + + public void setIsDel(String isDel) { + this.isDel = isDel; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPreCost() { + return preCost; + } + + public void setPreCost(String preCost) { + this.preCost = preCost; + } + + public String getPreEndTime() { + return preEndTime; + } + + public void setPreEndTime(String preEndTime) { + this.preEndTime = preEndTime; + } + + public String getPreStartTime() { + return preStartTime; + } + + public void setPreStartTime(String preStartTime) { + this.preStartTime = preStartTime; + } + + public String getProcessId() { + return processId; + } + + public void setProcessId(String processId) { + this.processId = processId; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getSiteExecutiveName() { + return siteExecutiveName; + } + + public void setSiteExecutiveName(String siteExecutiveName) { + this.siteExecutiveName = siteExecutiveName; + } + + public String getSiteExecutiveNo() { + return siteExecutiveNo; + } + + public void setSiteExecutiveNo(String siteExecutiveNo) { + this.siteExecutiveNo = siteExecutiveNo; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskSource() { + return taskSource; + } + + public void setTaskSource(String taskSource) { + this.taskSource = taskSource; + } + + public String getTaskSourceName() { + return taskSourceName; + } + + public void setTaskSourceName(String taskSourceName) { + this.taskSourceName = taskSourceName; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + } + } +} diff --git a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt index 36059c5..1feffe7 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt @@ -69,4 +69,5 @@ const val STANDARD_FILE_FORM_ID = "jlglwjsp" const val CERTIFICATE_REPORT_FORM_ID = "ywglzsbg" const val CONTRACT_FORM_ID = "cwczht" + const val OUTFIELD_DETECTION_FORM_ID = "ywglxcjc" } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt index d104cea..5bb091f 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt @@ -466,4 +466,15 @@ @Header("token") token: String, @Body requestBody: RequestBody ): String + + /** + * 获取外场检测申请列表 + */ + @POST("/business/siteExecutive/approval/listPage") + suspend fun getOutfieldDetectionList( + @Header("token") token: String, + @Body requestBody: RequestBody, + @QueryMap limit: Map, + @QueryMap offset: Map + ): String } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt index 759a2a5..add9920 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt @@ -1063,4 +1063,35 @@ ) return api.getContractDetail(AuthenticationHelper.token!!, requestBody) } + + /** + * 获取外场检测申请列表 + */ + suspend fun getOutfieldDetectionList( + approvalStatus: String, + customerName: String, + directorName: String, + siteExecutiveNo: String, + offset: Int + ): String { + val param = JsonObject() + param.addProperty("approvalStatus", approvalStatus) + param.addProperty("customerName", customerName) + param.addProperty("directorName", directorName) + param.addProperty("siteExecutiveNo", siteExecutiveNo) + param.addProperty("formId", LocaleConstant.OUTFIELD_DETECTION_FORM_ID) + + val requestBody = param.toString().toRequestBody( + "application/json;charset=UTF-8".toMediaType() + ) + + val limitMap = HashMap() + limitMap["limit"] = LocaleConstant.PAGE_LIMIT + + val offsetMap = HashMap() + offsetMap["offset"] = offset + return api.getOutfieldDetectionList( + AuthenticationHelper.token!!, requestBody, limitMap, offsetMap + ) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt b/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt new file mode 100644 index 0000000..8b3a375 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt @@ -0,0 +1,60 @@ +package com.casic.xz.meterage.view.home + +import androidx.fragment.app.Fragment +import com.casic.xz.meterage.R +import com.casic.xz.meterage.adapter.SubViewPagerAdapter +import com.casic.xz.meterage.base.ApplicationBaseActivity +import com.casic.xz.meterage.extensions.initLayoutImmersionBar +import com.casic.xz.meterage.fragment.outfield.OutfieldDetectionFragment +import com.gyf.immersionbar.ImmersionBar +import kotlinx.android.synthetic.main.activity_outfield_detection.* +import kotlinx.android.synthetic.main.include_base_title.* + +class OutfieldDetectionActivity : ApplicationBaseActivity() { + + private val pageTitles = arrayOf( + "草稿箱", + "审批中", + "已通过", + "未通过", + "已取消" + ) + private var fragmentPages: ArrayList = ArrayList() + + init { + pageTitles.forEach { + //和证书报告状态一致 + when (it) { + "草稿箱" -> fragmentPages.add(OutfieldDetectionFragment("1")) + "审批中" -> fragmentPages.add(OutfieldDetectionFragment("3")) + "已通过" -> fragmentPages.add(OutfieldDetectionFragment("4")) + "未通过" -> fragmentPages.add(OutfieldDetectionFragment("5")) + "已取消" -> fragmentPages.add(OutfieldDetectionFragment("6")) + } + } + } + + override fun initLayoutView(): Int = R.layout.activity_outfield_detection + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(true).init() + initLayoutImmersionBar(rootView) + titleView.text = "外场检测" + } + + override fun initData() { + viewPager.adapter = SubViewPagerAdapter( + supportFragmentManager, fragmentPages, pageTitles + ) + //绑定 + topTabLayout.setupWithViewPager(viewPager) + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + leftBackView.setOnClickListener { finish() } + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 719698d..f8f54fe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -72,6 +72,7 @@ + diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt index ad81434..dfdea73 100644 --- a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt @@ -173,7 +173,7 @@ "合同发票" -> requireContext().navigatePageTo() // "业务统计" -> requireContext().navigatePageTo() "客户列表" -> requireContext().navigatePageTo() -// "外场检测" -> requireContext().navigatePageTo() + "外场检测" -> requireContext().navigatePageTo() } } }) diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt new file mode 100644 index 0000000..85a8cb1 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt @@ -0,0 +1,174 @@ +package com.casic.xz.meterage.fragment.outfield + +import android.os.Handler +import android.view.View +import androidx.lifecycle.ViewModelProvider +import androidx.recyclerview.widget.DividerItemDecoration +import com.casic.xz.meterage.R +import com.casic.xz.meterage.extensions.diffCurrentTime +import com.casic.xz.meterage.extensions.formatToYearMonthDay +import com.casic.xz.meterage.extensions.showEmptyPage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.vm.OutfieldDetectionViewModel +import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter +import com.pengxh.kt.lite.adapter.ViewHolder +import com.pengxh.kt.lite.base.KotlinBaseFragment +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.fragment_outfield_detection.* +import kotlinx.android.synthetic.main.include_empty_view.* + +/** + * 外场检测 + * + * formId:ywglxcjc + * */ +class OutfieldDetectionFragment(private val status: String) : KotlinBaseFragment() { + + private lateinit var weakReferenceHandler: WeakReferenceHandler + private lateinit var outfieldDetectionViewModel: OutfieldDetectionViewModel + private lateinit var outfieldDetectionAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var pageIndex = 1 + private var isRefresh = false + private var isLoadMore = false + + override fun initData() { + weakReferenceHandler = WeakReferenceHandler(callback) + outfieldDetectionViewModel = ViewModelProvider(this)[OutfieldDetectionViewModel::class.java] + outfieldDetectionViewModel.outfieldDetectionList.observe(this) { + if (it.code == 200) { + val dataRows = it.data?.rows!! + when { + isRefresh -> { + dataBeans.clear() + dataBeans = dataRows + outfieldLayout.finishRefresh() + isRefresh = false + } + isLoadMore -> { + if (dataRows.size == 0) { + "到底了,别拉了".show(requireContext()) + } + dataBeans.addAll(dataRows) + outfieldLayout.finishLoadMore() + isLoadMore = false + } + else -> { + dataBeans = dataRows + } + } + weakReferenceHandler.sendEmptyMessage(2023041101) + } + } + } + + override fun initEvent() { + outfieldLayout.setOnRefreshListener { + isRefresh = true + //刷新之后页码重置 + pageIndex = 1 + getOutfieldDetectionList() + } + + outfieldLayout.setOnLoadMoreListener { + isLoadMore = true + pageIndex++ + getOutfieldDetectionList() + } + } + + override fun onResume() { + super.onResume() + pageIndex = 1 + getOutfieldDetectionList() + } + + private fun getOutfieldDetectionList() { + outfieldDetectionViewModel.getOutfieldDetectionList( + status, "", "", "", pageIndex + ) + } + + override fun initLayoutView(): Int = R.layout.fragment_outfield_detection + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + private val callback = Handler.Callback { + when (it.what) { + 2023041101 -> { + if (isRefresh || isLoadMore) { + outfieldDetectionAdapter.notifyDataSetChanged() + } else { + if (dataBeans.size == 0) { + emptyView!!.showEmptyPage("无外场检测申请") { + pageIndex = 1 + getOutfieldDetectionList() + } + } else { + emptyView!!.hide() + outfieldDetectionAdapter = object : + NormalRecyclerAdapter( + R.layout.item_outfield_detection_rv_l, dataBeans + ) { + override fun convertView( + viewHolder: ViewHolder, + position: Int, + item: OutfieldDetectionListModel.DataModel.RowsModel + ) { + val deltaT = item.applyTime.diffCurrentTime() + if (deltaT <= 24) { + viewHolder.setVisibility(R.id.overTimeView, View.GONE) + } else { + viewHolder.setVisibility(R.id.overTimeView, View.VISIBLE) + } + + val remark = if (item.remark.isNullOrBlank()) { + "客户没添加任何备注信息" + } else { + "【备注】:${item.remark}" + } + + viewHolder.setText(R.id.executiveItemView, item.executiveItem) + .setText( + R.id.hazardSourceView, item.hazardSourceAndPreventionMethod + ) + .setText(R.id.remarkView, remark) + .setText(R.id.fullAddressView, "详细地址:${item.fullAddress}") + .setText( + R.id.executiveEnvironmentView, + "现场环境:${item.executiveEnvironment}" + ) + .setText( + R.id.applyTimeView, + "申请时间:${item.applyTime.formatToYearMonthDay()}" + ) + .setText(R.id.directorView, item.director) + .setText(R.id.phoneView, item.phone) + } + } + outfieldRecyclerView.addItemDecoration( + DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL) + ) + outfieldRecyclerView.adapter = outfieldDetectionAdapter + outfieldDetectionAdapter.setOnItemClickedListener(object : + NormalRecyclerAdapter.OnItemClickedListener { + override fun onItemClicked( + position: Int, t: OutfieldDetectionListModel.DataModel.RowsModel + ) { + + } + }) + } + } + } + } + true + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java new file mode 100644 index 0000000..1397228 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java @@ -0,0 +1,364 @@ +package com.casic.xz.meterage.model; + +import java.util.List; + +public class OutfieldDetectionListModel { + + private int code; + private DataModel data; + private String message; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String addressAreaName; + private String addressCityName; + private String addressCountryName; + private String addressProvinceName; + private String applyTime; + private String approvalStatus; + private String approvalStatusName; + private String createTime; + private String customerId; + private String customerName; + private String decisionItem; + private String director; + private String directorId; + private String directorName; + private String executiveAddress; + private String executiveEnvironment; + private String executiveItem; + private String fullAddress; + private String hazardSourceAndPreventionMethod; + private String id; + private String isDel; + private String orderId; + private String phone; + private String preCost; + private String preEndTime; + private String preStartTime; + private String processId; + private String remark; + private String siteExecutiveName; + private String siteExecutiveNo; + private String taskId; + private String taskSource; + private String taskSourceName; + private String updateTime; + + public String getAddressAreaName() { + return addressAreaName; + } + + public void setAddressAreaName(String addressAreaName) { + this.addressAreaName = addressAreaName; + } + + public String getAddressCityName() { + return addressCityName; + } + + public void setAddressCityName(String addressCityName) { + this.addressCityName = addressCityName; + } + + public String getAddressCountryName() { + return addressCountryName; + } + + public void setAddressCountryName(String addressCountryName) { + this.addressCountryName = addressCountryName; + } + + public String getAddressProvinceName() { + return addressProvinceName; + } + + public void setAddressProvinceName(String addressProvinceName) { + this.addressProvinceName = addressProvinceName; + } + + public String getApplyTime() { + return applyTime; + } + + public void setApplyTime(String applyTime) { + this.applyTime = applyTime; + } + + public String getApprovalStatus() { + return approvalStatus; + } + + public void setApprovalStatus(String approvalStatus) { + this.approvalStatus = approvalStatus; + } + + public String getApprovalStatusName() { + return approvalStatusName; + } + + public void setApprovalStatusName(String approvalStatusName) { + this.approvalStatusName = approvalStatusName; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getDecisionItem() { + return decisionItem; + } + + public void setDecisionItem(String decisionItem) { + this.decisionItem = decisionItem; + } + + public String getDirector() { + return director; + } + + public void setDirector(String director) { + this.director = director; + } + + public String getDirectorId() { + return directorId; + } + + public void setDirectorId(String directorId) { + this.directorId = directorId; + } + + public String getDirectorName() { + return directorName; + } + + public void setDirectorName(String directorName) { + this.directorName = directorName; + } + + public String getExecutiveAddress() { + return executiveAddress; + } + + public void setExecutiveAddress(String executiveAddress) { + this.executiveAddress = executiveAddress; + } + + public String getExecutiveEnvironment() { + return executiveEnvironment; + } + + public void setExecutiveEnvironment(String executiveEnvironment) { + this.executiveEnvironment = executiveEnvironment; + } + + public String getExecutiveItem() { + return executiveItem; + } + + public void setExecutiveItem(String executiveItem) { + this.executiveItem = executiveItem; + } + + public String getFullAddress() { + return fullAddress; + } + + public void setFullAddress(String fullAddress) { + this.fullAddress = fullAddress; + } + + public String getHazardSourceAndPreventionMethod() { + return hazardSourceAndPreventionMethod; + } + + public void setHazardSourceAndPreventionMethod(String hazardSourceAndPreventionMethod) { + this.hazardSourceAndPreventionMethod = hazardSourceAndPreventionMethod; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsDel() { + return isDel; + } + + public void setIsDel(String isDel) { + this.isDel = isDel; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPreCost() { + return preCost; + } + + public void setPreCost(String preCost) { + this.preCost = preCost; + } + + public String getPreEndTime() { + return preEndTime; + } + + public void setPreEndTime(String preEndTime) { + this.preEndTime = preEndTime; + } + + public String getPreStartTime() { + return preStartTime; + } + + public void setPreStartTime(String preStartTime) { + this.preStartTime = preStartTime; + } + + public String getProcessId() { + return processId; + } + + public void setProcessId(String processId) { + this.processId = processId; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getSiteExecutiveName() { + return siteExecutiveName; + } + + public void setSiteExecutiveName(String siteExecutiveName) { + this.siteExecutiveName = siteExecutiveName; + } + + public String getSiteExecutiveNo() { + return siteExecutiveNo; + } + + public void setSiteExecutiveNo(String siteExecutiveNo) { + this.siteExecutiveNo = siteExecutiveNo; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskSource() { + return taskSource; + } + + public void setTaskSource(String taskSource) { + this.taskSource = taskSource; + } + + public String getTaskSourceName() { + return taskSourceName; + } + + public void setTaskSourceName(String taskSourceName) { + this.taskSourceName = taskSourceName; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + } + } +} diff --git a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt index 36059c5..1feffe7 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt @@ -69,4 +69,5 @@ const val STANDARD_FILE_FORM_ID = "jlglwjsp" const val CERTIFICATE_REPORT_FORM_ID = "ywglzsbg" const val CONTRACT_FORM_ID = "cwczht" + const val OUTFIELD_DETECTION_FORM_ID = "ywglxcjc" } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt index d104cea..5bb091f 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt @@ -466,4 +466,15 @@ @Header("token") token: String, @Body requestBody: RequestBody ): String + + /** + * 获取外场检测申请列表 + */ + @POST("/business/siteExecutive/approval/listPage") + suspend fun getOutfieldDetectionList( + @Header("token") token: String, + @Body requestBody: RequestBody, + @QueryMap limit: Map, + @QueryMap offset: Map + ): String } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt index 759a2a5..add9920 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt @@ -1063,4 +1063,35 @@ ) return api.getContractDetail(AuthenticationHelper.token!!, requestBody) } + + /** + * 获取外场检测申请列表 + */ + suspend fun getOutfieldDetectionList( + approvalStatus: String, + customerName: String, + directorName: String, + siteExecutiveNo: String, + offset: Int + ): String { + val param = JsonObject() + param.addProperty("approvalStatus", approvalStatus) + param.addProperty("customerName", customerName) + param.addProperty("directorName", directorName) + param.addProperty("siteExecutiveNo", siteExecutiveNo) + param.addProperty("formId", LocaleConstant.OUTFIELD_DETECTION_FORM_ID) + + val requestBody = param.toString().toRequestBody( + "application/json;charset=UTF-8".toMediaType() + ) + + val limitMap = HashMap() + limitMap["limit"] = LocaleConstant.PAGE_LIMIT + + val offsetMap = HashMap() + offsetMap["offset"] = offset + return api.getOutfieldDetectionList( + AuthenticationHelper.token!!, requestBody, limitMap, offsetMap + ) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt b/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt new file mode 100644 index 0000000..8b3a375 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt @@ -0,0 +1,60 @@ +package com.casic.xz.meterage.view.home + +import androidx.fragment.app.Fragment +import com.casic.xz.meterage.R +import com.casic.xz.meterage.adapter.SubViewPagerAdapter +import com.casic.xz.meterage.base.ApplicationBaseActivity +import com.casic.xz.meterage.extensions.initLayoutImmersionBar +import com.casic.xz.meterage.fragment.outfield.OutfieldDetectionFragment +import com.gyf.immersionbar.ImmersionBar +import kotlinx.android.synthetic.main.activity_outfield_detection.* +import kotlinx.android.synthetic.main.include_base_title.* + +class OutfieldDetectionActivity : ApplicationBaseActivity() { + + private val pageTitles = arrayOf( + "草稿箱", + "审批中", + "已通过", + "未通过", + "已取消" + ) + private var fragmentPages: ArrayList = ArrayList() + + init { + pageTitles.forEach { + //和证书报告状态一致 + when (it) { + "草稿箱" -> fragmentPages.add(OutfieldDetectionFragment("1")) + "审批中" -> fragmentPages.add(OutfieldDetectionFragment("3")) + "已通过" -> fragmentPages.add(OutfieldDetectionFragment("4")) + "未通过" -> fragmentPages.add(OutfieldDetectionFragment("5")) + "已取消" -> fragmentPages.add(OutfieldDetectionFragment("6")) + } + } + } + + override fun initLayoutView(): Int = R.layout.activity_outfield_detection + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(true).init() + initLayoutImmersionBar(rootView) + titleView.text = "外场检测" + } + + override fun initData() { + viewPager.adapter = SubViewPagerAdapter( + supportFragmentManager, fragmentPages, pageTitles + ) + //绑定 + topTabLayout.setupWithViewPager(viewPager) + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + leftBackView.setOnClickListener { finish() } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt b/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt new file mode 100644 index 0000000..fbded6a --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt @@ -0,0 +1,50 @@ +package com.casic.xz.meterage.vm + +import androidx.lifecycle.MutableLiveData +import com.casic.xz.meterage.base.BaseApplication +import com.casic.xz.meterage.extensions.separateResponseCode +import com.casic.xz.meterage.extensions.toErrorMessage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.utils.retrofit.RetrofitServiceManager +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken +import com.pengxh.kt.lite.extensions.launch +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.vm.BaseViewModel +import com.pengxh.kt.lite.vm.LoadState + +/** + * 外场检测 VM + * */ +class OutfieldDetectionViewModel : BaseViewModel() { + + private val gson by lazy { Gson() } + val outfieldDetectionList = MutableLiveData() + + fun getOutfieldDetectionList( + approvalStatus: String, + customerName: String, + directorName: String, + siteExecutiveNo: String, + offset: Int + ) = launch({ + loadState.value = LoadState.Loading + val response = RetrofitServiceManager.getOutfieldDetectionList( + approvalStatus, customerName, directorName, siteExecutiveNo, offset + ) + val responseCode = response.separateResponseCode() + if (responseCode == 200) { + loadState.value = LoadState.Success + outfieldDetectionList.value = gson.fromJson( + response, object : TypeToken() {}.type + ) + } else { + loadState.value = LoadState.Fail + response.toErrorMessage().show(BaseApplication.get()) + } + }, { + loadState.value = LoadState.Fail + it.cause.toString().show(BaseApplication.get()) + it.printStackTrace() + }) +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 719698d..f8f54fe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -72,6 +72,7 @@ + diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt index ad81434..dfdea73 100644 --- a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt @@ -173,7 +173,7 @@ "合同发票" -> requireContext().navigatePageTo() // "业务统计" -> requireContext().navigatePageTo() "客户列表" -> requireContext().navigatePageTo() -// "外场检测" -> requireContext().navigatePageTo() + "外场检测" -> requireContext().navigatePageTo() } } }) diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt new file mode 100644 index 0000000..85a8cb1 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt @@ -0,0 +1,174 @@ +package com.casic.xz.meterage.fragment.outfield + +import android.os.Handler +import android.view.View +import androidx.lifecycle.ViewModelProvider +import androidx.recyclerview.widget.DividerItemDecoration +import com.casic.xz.meterage.R +import com.casic.xz.meterage.extensions.diffCurrentTime +import com.casic.xz.meterage.extensions.formatToYearMonthDay +import com.casic.xz.meterage.extensions.showEmptyPage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.vm.OutfieldDetectionViewModel +import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter +import com.pengxh.kt.lite.adapter.ViewHolder +import com.pengxh.kt.lite.base.KotlinBaseFragment +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.fragment_outfield_detection.* +import kotlinx.android.synthetic.main.include_empty_view.* + +/** + * 外场检测 + * + * formId:ywglxcjc + * */ +class OutfieldDetectionFragment(private val status: String) : KotlinBaseFragment() { + + private lateinit var weakReferenceHandler: WeakReferenceHandler + private lateinit var outfieldDetectionViewModel: OutfieldDetectionViewModel + private lateinit var outfieldDetectionAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var pageIndex = 1 + private var isRefresh = false + private var isLoadMore = false + + override fun initData() { + weakReferenceHandler = WeakReferenceHandler(callback) + outfieldDetectionViewModel = ViewModelProvider(this)[OutfieldDetectionViewModel::class.java] + outfieldDetectionViewModel.outfieldDetectionList.observe(this) { + if (it.code == 200) { + val dataRows = it.data?.rows!! + when { + isRefresh -> { + dataBeans.clear() + dataBeans = dataRows + outfieldLayout.finishRefresh() + isRefresh = false + } + isLoadMore -> { + if (dataRows.size == 0) { + "到底了,别拉了".show(requireContext()) + } + dataBeans.addAll(dataRows) + outfieldLayout.finishLoadMore() + isLoadMore = false + } + else -> { + dataBeans = dataRows + } + } + weakReferenceHandler.sendEmptyMessage(2023041101) + } + } + } + + override fun initEvent() { + outfieldLayout.setOnRefreshListener { + isRefresh = true + //刷新之后页码重置 + pageIndex = 1 + getOutfieldDetectionList() + } + + outfieldLayout.setOnLoadMoreListener { + isLoadMore = true + pageIndex++ + getOutfieldDetectionList() + } + } + + override fun onResume() { + super.onResume() + pageIndex = 1 + getOutfieldDetectionList() + } + + private fun getOutfieldDetectionList() { + outfieldDetectionViewModel.getOutfieldDetectionList( + status, "", "", "", pageIndex + ) + } + + override fun initLayoutView(): Int = R.layout.fragment_outfield_detection + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + private val callback = Handler.Callback { + when (it.what) { + 2023041101 -> { + if (isRefresh || isLoadMore) { + outfieldDetectionAdapter.notifyDataSetChanged() + } else { + if (dataBeans.size == 0) { + emptyView!!.showEmptyPage("无外场检测申请") { + pageIndex = 1 + getOutfieldDetectionList() + } + } else { + emptyView!!.hide() + outfieldDetectionAdapter = object : + NormalRecyclerAdapter( + R.layout.item_outfield_detection_rv_l, dataBeans + ) { + override fun convertView( + viewHolder: ViewHolder, + position: Int, + item: OutfieldDetectionListModel.DataModel.RowsModel + ) { + val deltaT = item.applyTime.diffCurrentTime() + if (deltaT <= 24) { + viewHolder.setVisibility(R.id.overTimeView, View.GONE) + } else { + viewHolder.setVisibility(R.id.overTimeView, View.VISIBLE) + } + + val remark = if (item.remark.isNullOrBlank()) { + "客户没添加任何备注信息" + } else { + "【备注】:${item.remark}" + } + + viewHolder.setText(R.id.executiveItemView, item.executiveItem) + .setText( + R.id.hazardSourceView, item.hazardSourceAndPreventionMethod + ) + .setText(R.id.remarkView, remark) + .setText(R.id.fullAddressView, "详细地址:${item.fullAddress}") + .setText( + R.id.executiveEnvironmentView, + "现场环境:${item.executiveEnvironment}" + ) + .setText( + R.id.applyTimeView, + "申请时间:${item.applyTime.formatToYearMonthDay()}" + ) + .setText(R.id.directorView, item.director) + .setText(R.id.phoneView, item.phone) + } + } + outfieldRecyclerView.addItemDecoration( + DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL) + ) + outfieldRecyclerView.adapter = outfieldDetectionAdapter + outfieldDetectionAdapter.setOnItemClickedListener(object : + NormalRecyclerAdapter.OnItemClickedListener { + override fun onItemClicked( + position: Int, t: OutfieldDetectionListModel.DataModel.RowsModel + ) { + + } + }) + } + } + } + } + true + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java new file mode 100644 index 0000000..1397228 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java @@ -0,0 +1,364 @@ +package com.casic.xz.meterage.model; + +import java.util.List; + +public class OutfieldDetectionListModel { + + private int code; + private DataModel data; + private String message; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String addressAreaName; + private String addressCityName; + private String addressCountryName; + private String addressProvinceName; + private String applyTime; + private String approvalStatus; + private String approvalStatusName; + private String createTime; + private String customerId; + private String customerName; + private String decisionItem; + private String director; + private String directorId; + private String directorName; + private String executiveAddress; + private String executiveEnvironment; + private String executiveItem; + private String fullAddress; + private String hazardSourceAndPreventionMethod; + private String id; + private String isDel; + private String orderId; + private String phone; + private String preCost; + private String preEndTime; + private String preStartTime; + private String processId; + private String remark; + private String siteExecutiveName; + private String siteExecutiveNo; + private String taskId; + private String taskSource; + private String taskSourceName; + private String updateTime; + + public String getAddressAreaName() { + return addressAreaName; + } + + public void setAddressAreaName(String addressAreaName) { + this.addressAreaName = addressAreaName; + } + + public String getAddressCityName() { + return addressCityName; + } + + public void setAddressCityName(String addressCityName) { + this.addressCityName = addressCityName; + } + + public String getAddressCountryName() { + return addressCountryName; + } + + public void setAddressCountryName(String addressCountryName) { + this.addressCountryName = addressCountryName; + } + + public String getAddressProvinceName() { + return addressProvinceName; + } + + public void setAddressProvinceName(String addressProvinceName) { + this.addressProvinceName = addressProvinceName; + } + + public String getApplyTime() { + return applyTime; + } + + public void setApplyTime(String applyTime) { + this.applyTime = applyTime; + } + + public String getApprovalStatus() { + return approvalStatus; + } + + public void setApprovalStatus(String approvalStatus) { + this.approvalStatus = approvalStatus; + } + + public String getApprovalStatusName() { + return approvalStatusName; + } + + public void setApprovalStatusName(String approvalStatusName) { + this.approvalStatusName = approvalStatusName; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getDecisionItem() { + return decisionItem; + } + + public void setDecisionItem(String decisionItem) { + this.decisionItem = decisionItem; + } + + public String getDirector() { + return director; + } + + public void setDirector(String director) { + this.director = director; + } + + public String getDirectorId() { + return directorId; + } + + public void setDirectorId(String directorId) { + this.directorId = directorId; + } + + public String getDirectorName() { + return directorName; + } + + public void setDirectorName(String directorName) { + this.directorName = directorName; + } + + public String getExecutiveAddress() { + return executiveAddress; + } + + public void setExecutiveAddress(String executiveAddress) { + this.executiveAddress = executiveAddress; + } + + public String getExecutiveEnvironment() { + return executiveEnvironment; + } + + public void setExecutiveEnvironment(String executiveEnvironment) { + this.executiveEnvironment = executiveEnvironment; + } + + public String getExecutiveItem() { + return executiveItem; + } + + public void setExecutiveItem(String executiveItem) { + this.executiveItem = executiveItem; + } + + public String getFullAddress() { + return fullAddress; + } + + public void setFullAddress(String fullAddress) { + this.fullAddress = fullAddress; + } + + public String getHazardSourceAndPreventionMethod() { + return hazardSourceAndPreventionMethod; + } + + public void setHazardSourceAndPreventionMethod(String hazardSourceAndPreventionMethod) { + this.hazardSourceAndPreventionMethod = hazardSourceAndPreventionMethod; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsDel() { + return isDel; + } + + public void setIsDel(String isDel) { + this.isDel = isDel; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPreCost() { + return preCost; + } + + public void setPreCost(String preCost) { + this.preCost = preCost; + } + + public String getPreEndTime() { + return preEndTime; + } + + public void setPreEndTime(String preEndTime) { + this.preEndTime = preEndTime; + } + + public String getPreStartTime() { + return preStartTime; + } + + public void setPreStartTime(String preStartTime) { + this.preStartTime = preStartTime; + } + + public String getProcessId() { + return processId; + } + + public void setProcessId(String processId) { + this.processId = processId; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getSiteExecutiveName() { + return siteExecutiveName; + } + + public void setSiteExecutiveName(String siteExecutiveName) { + this.siteExecutiveName = siteExecutiveName; + } + + public String getSiteExecutiveNo() { + return siteExecutiveNo; + } + + public void setSiteExecutiveNo(String siteExecutiveNo) { + this.siteExecutiveNo = siteExecutiveNo; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskSource() { + return taskSource; + } + + public void setTaskSource(String taskSource) { + this.taskSource = taskSource; + } + + public String getTaskSourceName() { + return taskSourceName; + } + + public void setTaskSourceName(String taskSourceName) { + this.taskSourceName = taskSourceName; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + } + } +} diff --git a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt index 36059c5..1feffe7 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt @@ -69,4 +69,5 @@ const val STANDARD_FILE_FORM_ID = "jlglwjsp" const val CERTIFICATE_REPORT_FORM_ID = "ywglzsbg" const val CONTRACT_FORM_ID = "cwczht" + const val OUTFIELD_DETECTION_FORM_ID = "ywglxcjc" } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt index d104cea..5bb091f 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt @@ -466,4 +466,15 @@ @Header("token") token: String, @Body requestBody: RequestBody ): String + + /** + * 获取外场检测申请列表 + */ + @POST("/business/siteExecutive/approval/listPage") + suspend fun getOutfieldDetectionList( + @Header("token") token: String, + @Body requestBody: RequestBody, + @QueryMap limit: Map, + @QueryMap offset: Map + ): String } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt index 759a2a5..add9920 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt @@ -1063,4 +1063,35 @@ ) return api.getContractDetail(AuthenticationHelper.token!!, requestBody) } + + /** + * 获取外场检测申请列表 + */ + suspend fun getOutfieldDetectionList( + approvalStatus: String, + customerName: String, + directorName: String, + siteExecutiveNo: String, + offset: Int + ): String { + val param = JsonObject() + param.addProperty("approvalStatus", approvalStatus) + param.addProperty("customerName", customerName) + param.addProperty("directorName", directorName) + param.addProperty("siteExecutiveNo", siteExecutiveNo) + param.addProperty("formId", LocaleConstant.OUTFIELD_DETECTION_FORM_ID) + + val requestBody = param.toString().toRequestBody( + "application/json;charset=UTF-8".toMediaType() + ) + + val limitMap = HashMap() + limitMap["limit"] = LocaleConstant.PAGE_LIMIT + + val offsetMap = HashMap() + offsetMap["offset"] = offset + return api.getOutfieldDetectionList( + AuthenticationHelper.token!!, requestBody, limitMap, offsetMap + ) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt b/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt new file mode 100644 index 0000000..8b3a375 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt @@ -0,0 +1,60 @@ +package com.casic.xz.meterage.view.home + +import androidx.fragment.app.Fragment +import com.casic.xz.meterage.R +import com.casic.xz.meterage.adapter.SubViewPagerAdapter +import com.casic.xz.meterage.base.ApplicationBaseActivity +import com.casic.xz.meterage.extensions.initLayoutImmersionBar +import com.casic.xz.meterage.fragment.outfield.OutfieldDetectionFragment +import com.gyf.immersionbar.ImmersionBar +import kotlinx.android.synthetic.main.activity_outfield_detection.* +import kotlinx.android.synthetic.main.include_base_title.* + +class OutfieldDetectionActivity : ApplicationBaseActivity() { + + private val pageTitles = arrayOf( + "草稿箱", + "审批中", + "已通过", + "未通过", + "已取消" + ) + private var fragmentPages: ArrayList = ArrayList() + + init { + pageTitles.forEach { + //和证书报告状态一致 + when (it) { + "草稿箱" -> fragmentPages.add(OutfieldDetectionFragment("1")) + "审批中" -> fragmentPages.add(OutfieldDetectionFragment("3")) + "已通过" -> fragmentPages.add(OutfieldDetectionFragment("4")) + "未通过" -> fragmentPages.add(OutfieldDetectionFragment("5")) + "已取消" -> fragmentPages.add(OutfieldDetectionFragment("6")) + } + } + } + + override fun initLayoutView(): Int = R.layout.activity_outfield_detection + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(true).init() + initLayoutImmersionBar(rootView) + titleView.text = "外场检测" + } + + override fun initData() { + viewPager.adapter = SubViewPagerAdapter( + supportFragmentManager, fragmentPages, pageTitles + ) + //绑定 + topTabLayout.setupWithViewPager(viewPager) + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + leftBackView.setOnClickListener { finish() } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt b/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt new file mode 100644 index 0000000..fbded6a --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt @@ -0,0 +1,50 @@ +package com.casic.xz.meterage.vm + +import androidx.lifecycle.MutableLiveData +import com.casic.xz.meterage.base.BaseApplication +import com.casic.xz.meterage.extensions.separateResponseCode +import com.casic.xz.meterage.extensions.toErrorMessage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.utils.retrofit.RetrofitServiceManager +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken +import com.pengxh.kt.lite.extensions.launch +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.vm.BaseViewModel +import com.pengxh.kt.lite.vm.LoadState + +/** + * 外场检测 VM + * */ +class OutfieldDetectionViewModel : BaseViewModel() { + + private val gson by lazy { Gson() } + val outfieldDetectionList = MutableLiveData() + + fun getOutfieldDetectionList( + approvalStatus: String, + customerName: String, + directorName: String, + siteExecutiveNo: String, + offset: Int + ) = launch({ + loadState.value = LoadState.Loading + val response = RetrofitServiceManager.getOutfieldDetectionList( + approvalStatus, customerName, directorName, siteExecutiveNo, offset + ) + val responseCode = response.separateResponseCode() + if (responseCode == 200) { + loadState.value = LoadState.Success + outfieldDetectionList.value = gson.fromJson( + response, object : TypeToken() {}.type + ) + } else { + loadState.value = LoadState.Fail + response.toErrorMessage().show(BaseApplication.get()) + } + }, { + loadState.value = LoadState.Fail + it.cause.toString().show(BaseApplication.get()) + it.printStackTrace() + }) +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_outfield_detection.xml b/app/src/main/res/layout/activity_outfield_detection.xml new file mode 100644 index 0000000..87fa531 --- /dev/null +++ b/app/src/main/res/layout/activity_outfield_detection.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 719698d..f8f54fe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -72,6 +72,7 @@ + diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt index ad81434..dfdea73 100644 --- a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt @@ -173,7 +173,7 @@ "合同发票" -> requireContext().navigatePageTo() // "业务统计" -> requireContext().navigatePageTo() "客户列表" -> requireContext().navigatePageTo() -// "外场检测" -> requireContext().navigatePageTo() + "外场检测" -> requireContext().navigatePageTo() } } }) diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt new file mode 100644 index 0000000..85a8cb1 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt @@ -0,0 +1,174 @@ +package com.casic.xz.meterage.fragment.outfield + +import android.os.Handler +import android.view.View +import androidx.lifecycle.ViewModelProvider +import androidx.recyclerview.widget.DividerItemDecoration +import com.casic.xz.meterage.R +import com.casic.xz.meterage.extensions.diffCurrentTime +import com.casic.xz.meterage.extensions.formatToYearMonthDay +import com.casic.xz.meterage.extensions.showEmptyPage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.vm.OutfieldDetectionViewModel +import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter +import com.pengxh.kt.lite.adapter.ViewHolder +import com.pengxh.kt.lite.base.KotlinBaseFragment +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.fragment_outfield_detection.* +import kotlinx.android.synthetic.main.include_empty_view.* + +/** + * 外场检测 + * + * formId:ywglxcjc + * */ +class OutfieldDetectionFragment(private val status: String) : KotlinBaseFragment() { + + private lateinit var weakReferenceHandler: WeakReferenceHandler + private lateinit var outfieldDetectionViewModel: OutfieldDetectionViewModel + private lateinit var outfieldDetectionAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var pageIndex = 1 + private var isRefresh = false + private var isLoadMore = false + + override fun initData() { + weakReferenceHandler = WeakReferenceHandler(callback) + outfieldDetectionViewModel = ViewModelProvider(this)[OutfieldDetectionViewModel::class.java] + outfieldDetectionViewModel.outfieldDetectionList.observe(this) { + if (it.code == 200) { + val dataRows = it.data?.rows!! + when { + isRefresh -> { + dataBeans.clear() + dataBeans = dataRows + outfieldLayout.finishRefresh() + isRefresh = false + } + isLoadMore -> { + if (dataRows.size == 0) { + "到底了,别拉了".show(requireContext()) + } + dataBeans.addAll(dataRows) + outfieldLayout.finishLoadMore() + isLoadMore = false + } + else -> { + dataBeans = dataRows + } + } + weakReferenceHandler.sendEmptyMessage(2023041101) + } + } + } + + override fun initEvent() { + outfieldLayout.setOnRefreshListener { + isRefresh = true + //刷新之后页码重置 + pageIndex = 1 + getOutfieldDetectionList() + } + + outfieldLayout.setOnLoadMoreListener { + isLoadMore = true + pageIndex++ + getOutfieldDetectionList() + } + } + + override fun onResume() { + super.onResume() + pageIndex = 1 + getOutfieldDetectionList() + } + + private fun getOutfieldDetectionList() { + outfieldDetectionViewModel.getOutfieldDetectionList( + status, "", "", "", pageIndex + ) + } + + override fun initLayoutView(): Int = R.layout.fragment_outfield_detection + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + private val callback = Handler.Callback { + when (it.what) { + 2023041101 -> { + if (isRefresh || isLoadMore) { + outfieldDetectionAdapter.notifyDataSetChanged() + } else { + if (dataBeans.size == 0) { + emptyView!!.showEmptyPage("无外场检测申请") { + pageIndex = 1 + getOutfieldDetectionList() + } + } else { + emptyView!!.hide() + outfieldDetectionAdapter = object : + NormalRecyclerAdapter( + R.layout.item_outfield_detection_rv_l, dataBeans + ) { + override fun convertView( + viewHolder: ViewHolder, + position: Int, + item: OutfieldDetectionListModel.DataModel.RowsModel + ) { + val deltaT = item.applyTime.diffCurrentTime() + if (deltaT <= 24) { + viewHolder.setVisibility(R.id.overTimeView, View.GONE) + } else { + viewHolder.setVisibility(R.id.overTimeView, View.VISIBLE) + } + + val remark = if (item.remark.isNullOrBlank()) { + "客户没添加任何备注信息" + } else { + "【备注】:${item.remark}" + } + + viewHolder.setText(R.id.executiveItemView, item.executiveItem) + .setText( + R.id.hazardSourceView, item.hazardSourceAndPreventionMethod + ) + .setText(R.id.remarkView, remark) + .setText(R.id.fullAddressView, "详细地址:${item.fullAddress}") + .setText( + R.id.executiveEnvironmentView, + "现场环境:${item.executiveEnvironment}" + ) + .setText( + R.id.applyTimeView, + "申请时间:${item.applyTime.formatToYearMonthDay()}" + ) + .setText(R.id.directorView, item.director) + .setText(R.id.phoneView, item.phone) + } + } + outfieldRecyclerView.addItemDecoration( + DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL) + ) + outfieldRecyclerView.adapter = outfieldDetectionAdapter + outfieldDetectionAdapter.setOnItemClickedListener(object : + NormalRecyclerAdapter.OnItemClickedListener { + override fun onItemClicked( + position: Int, t: OutfieldDetectionListModel.DataModel.RowsModel + ) { + + } + }) + } + } + } + } + true + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java new file mode 100644 index 0000000..1397228 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java @@ -0,0 +1,364 @@ +package com.casic.xz.meterage.model; + +import java.util.List; + +public class OutfieldDetectionListModel { + + private int code; + private DataModel data; + private String message; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String addressAreaName; + private String addressCityName; + private String addressCountryName; + private String addressProvinceName; + private String applyTime; + private String approvalStatus; + private String approvalStatusName; + private String createTime; + private String customerId; + private String customerName; + private String decisionItem; + private String director; + private String directorId; + private String directorName; + private String executiveAddress; + private String executiveEnvironment; + private String executiveItem; + private String fullAddress; + private String hazardSourceAndPreventionMethod; + private String id; + private String isDel; + private String orderId; + private String phone; + private String preCost; + private String preEndTime; + private String preStartTime; + private String processId; + private String remark; + private String siteExecutiveName; + private String siteExecutiveNo; + private String taskId; + private String taskSource; + private String taskSourceName; + private String updateTime; + + public String getAddressAreaName() { + return addressAreaName; + } + + public void setAddressAreaName(String addressAreaName) { + this.addressAreaName = addressAreaName; + } + + public String getAddressCityName() { + return addressCityName; + } + + public void setAddressCityName(String addressCityName) { + this.addressCityName = addressCityName; + } + + public String getAddressCountryName() { + return addressCountryName; + } + + public void setAddressCountryName(String addressCountryName) { + this.addressCountryName = addressCountryName; + } + + public String getAddressProvinceName() { + return addressProvinceName; + } + + public void setAddressProvinceName(String addressProvinceName) { + this.addressProvinceName = addressProvinceName; + } + + public String getApplyTime() { + return applyTime; + } + + public void setApplyTime(String applyTime) { + this.applyTime = applyTime; + } + + public String getApprovalStatus() { + return approvalStatus; + } + + public void setApprovalStatus(String approvalStatus) { + this.approvalStatus = approvalStatus; + } + + public String getApprovalStatusName() { + return approvalStatusName; + } + + public void setApprovalStatusName(String approvalStatusName) { + this.approvalStatusName = approvalStatusName; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getDecisionItem() { + return decisionItem; + } + + public void setDecisionItem(String decisionItem) { + this.decisionItem = decisionItem; + } + + public String getDirector() { + return director; + } + + public void setDirector(String director) { + this.director = director; + } + + public String getDirectorId() { + return directorId; + } + + public void setDirectorId(String directorId) { + this.directorId = directorId; + } + + public String getDirectorName() { + return directorName; + } + + public void setDirectorName(String directorName) { + this.directorName = directorName; + } + + public String getExecutiveAddress() { + return executiveAddress; + } + + public void setExecutiveAddress(String executiveAddress) { + this.executiveAddress = executiveAddress; + } + + public String getExecutiveEnvironment() { + return executiveEnvironment; + } + + public void setExecutiveEnvironment(String executiveEnvironment) { + this.executiveEnvironment = executiveEnvironment; + } + + public String getExecutiveItem() { + return executiveItem; + } + + public void setExecutiveItem(String executiveItem) { + this.executiveItem = executiveItem; + } + + public String getFullAddress() { + return fullAddress; + } + + public void setFullAddress(String fullAddress) { + this.fullAddress = fullAddress; + } + + public String getHazardSourceAndPreventionMethod() { + return hazardSourceAndPreventionMethod; + } + + public void setHazardSourceAndPreventionMethod(String hazardSourceAndPreventionMethod) { + this.hazardSourceAndPreventionMethod = hazardSourceAndPreventionMethod; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsDel() { + return isDel; + } + + public void setIsDel(String isDel) { + this.isDel = isDel; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPreCost() { + return preCost; + } + + public void setPreCost(String preCost) { + this.preCost = preCost; + } + + public String getPreEndTime() { + return preEndTime; + } + + public void setPreEndTime(String preEndTime) { + this.preEndTime = preEndTime; + } + + public String getPreStartTime() { + return preStartTime; + } + + public void setPreStartTime(String preStartTime) { + this.preStartTime = preStartTime; + } + + public String getProcessId() { + return processId; + } + + public void setProcessId(String processId) { + this.processId = processId; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getSiteExecutiveName() { + return siteExecutiveName; + } + + public void setSiteExecutiveName(String siteExecutiveName) { + this.siteExecutiveName = siteExecutiveName; + } + + public String getSiteExecutiveNo() { + return siteExecutiveNo; + } + + public void setSiteExecutiveNo(String siteExecutiveNo) { + this.siteExecutiveNo = siteExecutiveNo; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskSource() { + return taskSource; + } + + public void setTaskSource(String taskSource) { + this.taskSource = taskSource; + } + + public String getTaskSourceName() { + return taskSourceName; + } + + public void setTaskSourceName(String taskSourceName) { + this.taskSourceName = taskSourceName; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + } + } +} diff --git a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt index 36059c5..1feffe7 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt @@ -69,4 +69,5 @@ const val STANDARD_FILE_FORM_ID = "jlglwjsp" const val CERTIFICATE_REPORT_FORM_ID = "ywglzsbg" const val CONTRACT_FORM_ID = "cwczht" + const val OUTFIELD_DETECTION_FORM_ID = "ywglxcjc" } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt index d104cea..5bb091f 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt @@ -466,4 +466,15 @@ @Header("token") token: String, @Body requestBody: RequestBody ): String + + /** + * 获取外场检测申请列表 + */ + @POST("/business/siteExecutive/approval/listPage") + suspend fun getOutfieldDetectionList( + @Header("token") token: String, + @Body requestBody: RequestBody, + @QueryMap limit: Map, + @QueryMap offset: Map + ): String } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt index 759a2a5..add9920 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt @@ -1063,4 +1063,35 @@ ) return api.getContractDetail(AuthenticationHelper.token!!, requestBody) } + + /** + * 获取外场检测申请列表 + */ + suspend fun getOutfieldDetectionList( + approvalStatus: String, + customerName: String, + directorName: String, + siteExecutiveNo: String, + offset: Int + ): String { + val param = JsonObject() + param.addProperty("approvalStatus", approvalStatus) + param.addProperty("customerName", customerName) + param.addProperty("directorName", directorName) + param.addProperty("siteExecutiveNo", siteExecutiveNo) + param.addProperty("formId", LocaleConstant.OUTFIELD_DETECTION_FORM_ID) + + val requestBody = param.toString().toRequestBody( + "application/json;charset=UTF-8".toMediaType() + ) + + val limitMap = HashMap() + limitMap["limit"] = LocaleConstant.PAGE_LIMIT + + val offsetMap = HashMap() + offsetMap["offset"] = offset + return api.getOutfieldDetectionList( + AuthenticationHelper.token!!, requestBody, limitMap, offsetMap + ) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt b/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt new file mode 100644 index 0000000..8b3a375 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt @@ -0,0 +1,60 @@ +package com.casic.xz.meterage.view.home + +import androidx.fragment.app.Fragment +import com.casic.xz.meterage.R +import com.casic.xz.meterage.adapter.SubViewPagerAdapter +import com.casic.xz.meterage.base.ApplicationBaseActivity +import com.casic.xz.meterage.extensions.initLayoutImmersionBar +import com.casic.xz.meterage.fragment.outfield.OutfieldDetectionFragment +import com.gyf.immersionbar.ImmersionBar +import kotlinx.android.synthetic.main.activity_outfield_detection.* +import kotlinx.android.synthetic.main.include_base_title.* + +class OutfieldDetectionActivity : ApplicationBaseActivity() { + + private val pageTitles = arrayOf( + "草稿箱", + "审批中", + "已通过", + "未通过", + "已取消" + ) + private var fragmentPages: ArrayList = ArrayList() + + init { + pageTitles.forEach { + //和证书报告状态一致 + when (it) { + "草稿箱" -> fragmentPages.add(OutfieldDetectionFragment("1")) + "审批中" -> fragmentPages.add(OutfieldDetectionFragment("3")) + "已通过" -> fragmentPages.add(OutfieldDetectionFragment("4")) + "未通过" -> fragmentPages.add(OutfieldDetectionFragment("5")) + "已取消" -> fragmentPages.add(OutfieldDetectionFragment("6")) + } + } + } + + override fun initLayoutView(): Int = R.layout.activity_outfield_detection + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(true).init() + initLayoutImmersionBar(rootView) + titleView.text = "外场检测" + } + + override fun initData() { + viewPager.adapter = SubViewPagerAdapter( + supportFragmentManager, fragmentPages, pageTitles + ) + //绑定 + topTabLayout.setupWithViewPager(viewPager) + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + leftBackView.setOnClickListener { finish() } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt b/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt new file mode 100644 index 0000000..fbded6a --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt @@ -0,0 +1,50 @@ +package com.casic.xz.meterage.vm + +import androidx.lifecycle.MutableLiveData +import com.casic.xz.meterage.base.BaseApplication +import com.casic.xz.meterage.extensions.separateResponseCode +import com.casic.xz.meterage.extensions.toErrorMessage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.utils.retrofit.RetrofitServiceManager +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken +import com.pengxh.kt.lite.extensions.launch +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.vm.BaseViewModel +import com.pengxh.kt.lite.vm.LoadState + +/** + * 外场检测 VM + * */ +class OutfieldDetectionViewModel : BaseViewModel() { + + private val gson by lazy { Gson() } + val outfieldDetectionList = MutableLiveData() + + fun getOutfieldDetectionList( + approvalStatus: String, + customerName: String, + directorName: String, + siteExecutiveNo: String, + offset: Int + ) = launch({ + loadState.value = LoadState.Loading + val response = RetrofitServiceManager.getOutfieldDetectionList( + approvalStatus, customerName, directorName, siteExecutiveNo, offset + ) + val responseCode = response.separateResponseCode() + if (responseCode == 200) { + loadState.value = LoadState.Success + outfieldDetectionList.value = gson.fromJson( + response, object : TypeToken() {}.type + ) + } else { + loadState.value = LoadState.Fail + response.toErrorMessage().show(BaseApplication.get()) + } + }, { + loadState.value = LoadState.Fail + it.cause.toString().show(BaseApplication.get()) + it.printStackTrace() + }) +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_outfield_detection.xml b/app/src/main/res/layout/activity_outfield_detection.xml new file mode 100644 index 0000000..87fa531 --- /dev/null +++ b/app/src/main/res/layout/activity_outfield_detection.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_outfield_detection.xml b/app/src/main/res/layout/fragment_outfield_detection.xml new file mode 100644 index 0000000..18ee1bd --- /dev/null +++ b/app/src/main/res/layout/fragment_outfield_detection.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 719698d..f8f54fe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -72,6 +72,7 @@ + diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt index ad81434..dfdea73 100644 --- a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt @@ -173,7 +173,7 @@ "合同发票" -> requireContext().navigatePageTo() // "业务统计" -> requireContext().navigatePageTo() "客户列表" -> requireContext().navigatePageTo() -// "外场检测" -> requireContext().navigatePageTo() + "外场检测" -> requireContext().navigatePageTo() } } }) diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt new file mode 100644 index 0000000..85a8cb1 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt @@ -0,0 +1,174 @@ +package com.casic.xz.meterage.fragment.outfield + +import android.os.Handler +import android.view.View +import androidx.lifecycle.ViewModelProvider +import androidx.recyclerview.widget.DividerItemDecoration +import com.casic.xz.meterage.R +import com.casic.xz.meterage.extensions.diffCurrentTime +import com.casic.xz.meterage.extensions.formatToYearMonthDay +import com.casic.xz.meterage.extensions.showEmptyPage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.vm.OutfieldDetectionViewModel +import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter +import com.pengxh.kt.lite.adapter.ViewHolder +import com.pengxh.kt.lite.base.KotlinBaseFragment +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.fragment_outfield_detection.* +import kotlinx.android.synthetic.main.include_empty_view.* + +/** + * 外场检测 + * + * formId:ywglxcjc + * */ +class OutfieldDetectionFragment(private val status: String) : KotlinBaseFragment() { + + private lateinit var weakReferenceHandler: WeakReferenceHandler + private lateinit var outfieldDetectionViewModel: OutfieldDetectionViewModel + private lateinit var outfieldDetectionAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var pageIndex = 1 + private var isRefresh = false + private var isLoadMore = false + + override fun initData() { + weakReferenceHandler = WeakReferenceHandler(callback) + outfieldDetectionViewModel = ViewModelProvider(this)[OutfieldDetectionViewModel::class.java] + outfieldDetectionViewModel.outfieldDetectionList.observe(this) { + if (it.code == 200) { + val dataRows = it.data?.rows!! + when { + isRefresh -> { + dataBeans.clear() + dataBeans = dataRows + outfieldLayout.finishRefresh() + isRefresh = false + } + isLoadMore -> { + if (dataRows.size == 0) { + "到底了,别拉了".show(requireContext()) + } + dataBeans.addAll(dataRows) + outfieldLayout.finishLoadMore() + isLoadMore = false + } + else -> { + dataBeans = dataRows + } + } + weakReferenceHandler.sendEmptyMessage(2023041101) + } + } + } + + override fun initEvent() { + outfieldLayout.setOnRefreshListener { + isRefresh = true + //刷新之后页码重置 + pageIndex = 1 + getOutfieldDetectionList() + } + + outfieldLayout.setOnLoadMoreListener { + isLoadMore = true + pageIndex++ + getOutfieldDetectionList() + } + } + + override fun onResume() { + super.onResume() + pageIndex = 1 + getOutfieldDetectionList() + } + + private fun getOutfieldDetectionList() { + outfieldDetectionViewModel.getOutfieldDetectionList( + status, "", "", "", pageIndex + ) + } + + override fun initLayoutView(): Int = R.layout.fragment_outfield_detection + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + private val callback = Handler.Callback { + when (it.what) { + 2023041101 -> { + if (isRefresh || isLoadMore) { + outfieldDetectionAdapter.notifyDataSetChanged() + } else { + if (dataBeans.size == 0) { + emptyView!!.showEmptyPage("无外场检测申请") { + pageIndex = 1 + getOutfieldDetectionList() + } + } else { + emptyView!!.hide() + outfieldDetectionAdapter = object : + NormalRecyclerAdapter( + R.layout.item_outfield_detection_rv_l, dataBeans + ) { + override fun convertView( + viewHolder: ViewHolder, + position: Int, + item: OutfieldDetectionListModel.DataModel.RowsModel + ) { + val deltaT = item.applyTime.diffCurrentTime() + if (deltaT <= 24) { + viewHolder.setVisibility(R.id.overTimeView, View.GONE) + } else { + viewHolder.setVisibility(R.id.overTimeView, View.VISIBLE) + } + + val remark = if (item.remark.isNullOrBlank()) { + "客户没添加任何备注信息" + } else { + "【备注】:${item.remark}" + } + + viewHolder.setText(R.id.executiveItemView, item.executiveItem) + .setText( + R.id.hazardSourceView, item.hazardSourceAndPreventionMethod + ) + .setText(R.id.remarkView, remark) + .setText(R.id.fullAddressView, "详细地址:${item.fullAddress}") + .setText( + R.id.executiveEnvironmentView, + "现场环境:${item.executiveEnvironment}" + ) + .setText( + R.id.applyTimeView, + "申请时间:${item.applyTime.formatToYearMonthDay()}" + ) + .setText(R.id.directorView, item.director) + .setText(R.id.phoneView, item.phone) + } + } + outfieldRecyclerView.addItemDecoration( + DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL) + ) + outfieldRecyclerView.adapter = outfieldDetectionAdapter + outfieldDetectionAdapter.setOnItemClickedListener(object : + NormalRecyclerAdapter.OnItemClickedListener { + override fun onItemClicked( + position: Int, t: OutfieldDetectionListModel.DataModel.RowsModel + ) { + + } + }) + } + } + } + } + true + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java new file mode 100644 index 0000000..1397228 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java @@ -0,0 +1,364 @@ +package com.casic.xz.meterage.model; + +import java.util.List; + +public class OutfieldDetectionListModel { + + private int code; + private DataModel data; + private String message; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String addressAreaName; + private String addressCityName; + private String addressCountryName; + private String addressProvinceName; + private String applyTime; + private String approvalStatus; + private String approvalStatusName; + private String createTime; + private String customerId; + private String customerName; + private String decisionItem; + private String director; + private String directorId; + private String directorName; + private String executiveAddress; + private String executiveEnvironment; + private String executiveItem; + private String fullAddress; + private String hazardSourceAndPreventionMethod; + private String id; + private String isDel; + private String orderId; + private String phone; + private String preCost; + private String preEndTime; + private String preStartTime; + private String processId; + private String remark; + private String siteExecutiveName; + private String siteExecutiveNo; + private String taskId; + private String taskSource; + private String taskSourceName; + private String updateTime; + + public String getAddressAreaName() { + return addressAreaName; + } + + public void setAddressAreaName(String addressAreaName) { + this.addressAreaName = addressAreaName; + } + + public String getAddressCityName() { + return addressCityName; + } + + public void setAddressCityName(String addressCityName) { + this.addressCityName = addressCityName; + } + + public String getAddressCountryName() { + return addressCountryName; + } + + public void setAddressCountryName(String addressCountryName) { + this.addressCountryName = addressCountryName; + } + + public String getAddressProvinceName() { + return addressProvinceName; + } + + public void setAddressProvinceName(String addressProvinceName) { + this.addressProvinceName = addressProvinceName; + } + + public String getApplyTime() { + return applyTime; + } + + public void setApplyTime(String applyTime) { + this.applyTime = applyTime; + } + + public String getApprovalStatus() { + return approvalStatus; + } + + public void setApprovalStatus(String approvalStatus) { + this.approvalStatus = approvalStatus; + } + + public String getApprovalStatusName() { + return approvalStatusName; + } + + public void setApprovalStatusName(String approvalStatusName) { + this.approvalStatusName = approvalStatusName; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getDecisionItem() { + return decisionItem; + } + + public void setDecisionItem(String decisionItem) { + this.decisionItem = decisionItem; + } + + public String getDirector() { + return director; + } + + public void setDirector(String director) { + this.director = director; + } + + public String getDirectorId() { + return directorId; + } + + public void setDirectorId(String directorId) { + this.directorId = directorId; + } + + public String getDirectorName() { + return directorName; + } + + public void setDirectorName(String directorName) { + this.directorName = directorName; + } + + public String getExecutiveAddress() { + return executiveAddress; + } + + public void setExecutiveAddress(String executiveAddress) { + this.executiveAddress = executiveAddress; + } + + public String getExecutiveEnvironment() { + return executiveEnvironment; + } + + public void setExecutiveEnvironment(String executiveEnvironment) { + this.executiveEnvironment = executiveEnvironment; + } + + public String getExecutiveItem() { + return executiveItem; + } + + public void setExecutiveItem(String executiveItem) { + this.executiveItem = executiveItem; + } + + public String getFullAddress() { + return fullAddress; + } + + public void setFullAddress(String fullAddress) { + this.fullAddress = fullAddress; + } + + public String getHazardSourceAndPreventionMethod() { + return hazardSourceAndPreventionMethod; + } + + public void setHazardSourceAndPreventionMethod(String hazardSourceAndPreventionMethod) { + this.hazardSourceAndPreventionMethod = hazardSourceAndPreventionMethod; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsDel() { + return isDel; + } + + public void setIsDel(String isDel) { + this.isDel = isDel; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPreCost() { + return preCost; + } + + public void setPreCost(String preCost) { + this.preCost = preCost; + } + + public String getPreEndTime() { + return preEndTime; + } + + public void setPreEndTime(String preEndTime) { + this.preEndTime = preEndTime; + } + + public String getPreStartTime() { + return preStartTime; + } + + public void setPreStartTime(String preStartTime) { + this.preStartTime = preStartTime; + } + + public String getProcessId() { + return processId; + } + + public void setProcessId(String processId) { + this.processId = processId; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getSiteExecutiveName() { + return siteExecutiveName; + } + + public void setSiteExecutiveName(String siteExecutiveName) { + this.siteExecutiveName = siteExecutiveName; + } + + public String getSiteExecutiveNo() { + return siteExecutiveNo; + } + + public void setSiteExecutiveNo(String siteExecutiveNo) { + this.siteExecutiveNo = siteExecutiveNo; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskSource() { + return taskSource; + } + + public void setTaskSource(String taskSource) { + this.taskSource = taskSource; + } + + public String getTaskSourceName() { + return taskSourceName; + } + + public void setTaskSourceName(String taskSourceName) { + this.taskSourceName = taskSourceName; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + } + } +} diff --git a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt index 36059c5..1feffe7 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt @@ -69,4 +69,5 @@ const val STANDARD_FILE_FORM_ID = "jlglwjsp" const val CERTIFICATE_REPORT_FORM_ID = "ywglzsbg" const val CONTRACT_FORM_ID = "cwczht" + const val OUTFIELD_DETECTION_FORM_ID = "ywglxcjc" } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt index d104cea..5bb091f 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt @@ -466,4 +466,15 @@ @Header("token") token: String, @Body requestBody: RequestBody ): String + + /** + * 获取外场检测申请列表 + */ + @POST("/business/siteExecutive/approval/listPage") + suspend fun getOutfieldDetectionList( + @Header("token") token: String, + @Body requestBody: RequestBody, + @QueryMap limit: Map, + @QueryMap offset: Map + ): String } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt index 759a2a5..add9920 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt @@ -1063,4 +1063,35 @@ ) return api.getContractDetail(AuthenticationHelper.token!!, requestBody) } + + /** + * 获取外场检测申请列表 + */ + suspend fun getOutfieldDetectionList( + approvalStatus: String, + customerName: String, + directorName: String, + siteExecutiveNo: String, + offset: Int + ): String { + val param = JsonObject() + param.addProperty("approvalStatus", approvalStatus) + param.addProperty("customerName", customerName) + param.addProperty("directorName", directorName) + param.addProperty("siteExecutiveNo", siteExecutiveNo) + param.addProperty("formId", LocaleConstant.OUTFIELD_DETECTION_FORM_ID) + + val requestBody = param.toString().toRequestBody( + "application/json;charset=UTF-8".toMediaType() + ) + + val limitMap = HashMap() + limitMap["limit"] = LocaleConstant.PAGE_LIMIT + + val offsetMap = HashMap() + offsetMap["offset"] = offset + return api.getOutfieldDetectionList( + AuthenticationHelper.token!!, requestBody, limitMap, offsetMap + ) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt b/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt new file mode 100644 index 0000000..8b3a375 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt @@ -0,0 +1,60 @@ +package com.casic.xz.meterage.view.home + +import androidx.fragment.app.Fragment +import com.casic.xz.meterage.R +import com.casic.xz.meterage.adapter.SubViewPagerAdapter +import com.casic.xz.meterage.base.ApplicationBaseActivity +import com.casic.xz.meterage.extensions.initLayoutImmersionBar +import com.casic.xz.meterage.fragment.outfield.OutfieldDetectionFragment +import com.gyf.immersionbar.ImmersionBar +import kotlinx.android.synthetic.main.activity_outfield_detection.* +import kotlinx.android.synthetic.main.include_base_title.* + +class OutfieldDetectionActivity : ApplicationBaseActivity() { + + private val pageTitles = arrayOf( + "草稿箱", + "审批中", + "已通过", + "未通过", + "已取消" + ) + private var fragmentPages: ArrayList = ArrayList() + + init { + pageTitles.forEach { + //和证书报告状态一致 + when (it) { + "草稿箱" -> fragmentPages.add(OutfieldDetectionFragment("1")) + "审批中" -> fragmentPages.add(OutfieldDetectionFragment("3")) + "已通过" -> fragmentPages.add(OutfieldDetectionFragment("4")) + "未通过" -> fragmentPages.add(OutfieldDetectionFragment("5")) + "已取消" -> fragmentPages.add(OutfieldDetectionFragment("6")) + } + } + } + + override fun initLayoutView(): Int = R.layout.activity_outfield_detection + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(true).init() + initLayoutImmersionBar(rootView) + titleView.text = "外场检测" + } + + override fun initData() { + viewPager.adapter = SubViewPagerAdapter( + supportFragmentManager, fragmentPages, pageTitles + ) + //绑定 + topTabLayout.setupWithViewPager(viewPager) + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + leftBackView.setOnClickListener { finish() } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt b/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt new file mode 100644 index 0000000..fbded6a --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt @@ -0,0 +1,50 @@ +package com.casic.xz.meterage.vm + +import androidx.lifecycle.MutableLiveData +import com.casic.xz.meterage.base.BaseApplication +import com.casic.xz.meterage.extensions.separateResponseCode +import com.casic.xz.meterage.extensions.toErrorMessage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.utils.retrofit.RetrofitServiceManager +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken +import com.pengxh.kt.lite.extensions.launch +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.vm.BaseViewModel +import com.pengxh.kt.lite.vm.LoadState + +/** + * 外场检测 VM + * */ +class OutfieldDetectionViewModel : BaseViewModel() { + + private val gson by lazy { Gson() } + val outfieldDetectionList = MutableLiveData() + + fun getOutfieldDetectionList( + approvalStatus: String, + customerName: String, + directorName: String, + siteExecutiveNo: String, + offset: Int + ) = launch({ + loadState.value = LoadState.Loading + val response = RetrofitServiceManager.getOutfieldDetectionList( + approvalStatus, customerName, directorName, siteExecutiveNo, offset + ) + val responseCode = response.separateResponseCode() + if (responseCode == 200) { + loadState.value = LoadState.Success + outfieldDetectionList.value = gson.fromJson( + response, object : TypeToken() {}.type + ) + } else { + loadState.value = LoadState.Fail + response.toErrorMessage().show(BaseApplication.get()) + } + }, { + loadState.value = LoadState.Fail + it.cause.toString().show(BaseApplication.get()) + it.printStackTrace() + }) +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_outfield_detection.xml b/app/src/main/res/layout/activity_outfield_detection.xml new file mode 100644 index 0000000..87fa531 --- /dev/null +++ b/app/src/main/res/layout/activity_outfield_detection.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_outfield_detection.xml b/app/src/main/res/layout/fragment_outfield_detection.xml new file mode 100644 index 0000000..18ee1bd --- /dev/null +++ b/app/src/main/res/layout/fragment_outfield_detection.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_contract_collection_rv_l.xml b/app/src/main/res/layout/item_contract_collection_rv_l.xml index 3ece950..6cf075d 100644 --- a/app/src/main/res/layout/item_contract_collection_rv_l.xml +++ b/app/src/main/res/layout/item_contract_collection_rv_l.xml @@ -44,7 +44,7 @@ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 719698d..f8f54fe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -72,6 +72,7 @@ + diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt index ad81434..dfdea73 100644 --- a/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/xz/meterage/fragment/HomePageFragment.kt @@ -173,7 +173,7 @@ "合同发票" -> requireContext().navigatePageTo() // "业务统计" -> requireContext().navigatePageTo() "客户列表" -> requireContext().navigatePageTo() -// "外场检测" -> requireContext().navigatePageTo() + "外场检测" -> requireContext().navigatePageTo() } } }) diff --git a/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt new file mode 100644 index 0000000..85a8cb1 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/fragment/outfield/OutfieldDetectionFragment.kt @@ -0,0 +1,174 @@ +package com.casic.xz.meterage.fragment.outfield + +import android.os.Handler +import android.view.View +import androidx.lifecycle.ViewModelProvider +import androidx.recyclerview.widget.DividerItemDecoration +import com.casic.xz.meterage.R +import com.casic.xz.meterage.extensions.diffCurrentTime +import com.casic.xz.meterage.extensions.formatToYearMonthDay +import com.casic.xz.meterage.extensions.showEmptyPage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.vm.OutfieldDetectionViewModel +import com.pengxh.kt.lite.adapter.NormalRecyclerAdapter +import com.pengxh.kt.lite.adapter.ViewHolder +import com.pengxh.kt.lite.base.KotlinBaseFragment +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.fragment_outfield_detection.* +import kotlinx.android.synthetic.main.include_empty_view.* + +/** + * 外场检测 + * + * formId:ywglxcjc + * */ +class OutfieldDetectionFragment(private val status: String) : KotlinBaseFragment() { + + private lateinit var weakReferenceHandler: WeakReferenceHandler + private lateinit var outfieldDetectionViewModel: OutfieldDetectionViewModel + private lateinit var outfieldDetectionAdapter: NormalRecyclerAdapter + private var dataBeans: MutableList = ArrayList() + private var pageIndex = 1 + private var isRefresh = false + private var isLoadMore = false + + override fun initData() { + weakReferenceHandler = WeakReferenceHandler(callback) + outfieldDetectionViewModel = ViewModelProvider(this)[OutfieldDetectionViewModel::class.java] + outfieldDetectionViewModel.outfieldDetectionList.observe(this) { + if (it.code == 200) { + val dataRows = it.data?.rows!! + when { + isRefresh -> { + dataBeans.clear() + dataBeans = dataRows + outfieldLayout.finishRefresh() + isRefresh = false + } + isLoadMore -> { + if (dataRows.size == 0) { + "到底了,别拉了".show(requireContext()) + } + dataBeans.addAll(dataRows) + outfieldLayout.finishLoadMore() + isLoadMore = false + } + else -> { + dataBeans = dataRows + } + } + weakReferenceHandler.sendEmptyMessage(2023041101) + } + } + } + + override fun initEvent() { + outfieldLayout.setOnRefreshListener { + isRefresh = true + //刷新之后页码重置 + pageIndex = 1 + getOutfieldDetectionList() + } + + outfieldLayout.setOnLoadMoreListener { + isLoadMore = true + pageIndex++ + getOutfieldDetectionList() + } + } + + override fun onResume() { + super.onResume() + pageIndex = 1 + getOutfieldDetectionList() + } + + private fun getOutfieldDetectionList() { + outfieldDetectionViewModel.getOutfieldDetectionList( + status, "", "", "", pageIndex + ) + } + + override fun initLayoutView(): Int = R.layout.fragment_outfield_detection + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + private val callback = Handler.Callback { + when (it.what) { + 2023041101 -> { + if (isRefresh || isLoadMore) { + outfieldDetectionAdapter.notifyDataSetChanged() + } else { + if (dataBeans.size == 0) { + emptyView!!.showEmptyPage("无外场检测申请") { + pageIndex = 1 + getOutfieldDetectionList() + } + } else { + emptyView!!.hide() + outfieldDetectionAdapter = object : + NormalRecyclerAdapter( + R.layout.item_outfield_detection_rv_l, dataBeans + ) { + override fun convertView( + viewHolder: ViewHolder, + position: Int, + item: OutfieldDetectionListModel.DataModel.RowsModel + ) { + val deltaT = item.applyTime.diffCurrentTime() + if (deltaT <= 24) { + viewHolder.setVisibility(R.id.overTimeView, View.GONE) + } else { + viewHolder.setVisibility(R.id.overTimeView, View.VISIBLE) + } + + val remark = if (item.remark.isNullOrBlank()) { + "客户没添加任何备注信息" + } else { + "【备注】:${item.remark}" + } + + viewHolder.setText(R.id.executiveItemView, item.executiveItem) + .setText( + R.id.hazardSourceView, item.hazardSourceAndPreventionMethod + ) + .setText(R.id.remarkView, remark) + .setText(R.id.fullAddressView, "详细地址:${item.fullAddress}") + .setText( + R.id.executiveEnvironmentView, + "现场环境:${item.executiveEnvironment}" + ) + .setText( + R.id.applyTimeView, + "申请时间:${item.applyTime.formatToYearMonthDay()}" + ) + .setText(R.id.directorView, item.director) + .setText(R.id.phoneView, item.phone) + } + } + outfieldRecyclerView.addItemDecoration( + DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL) + ) + outfieldRecyclerView.adapter = outfieldDetectionAdapter + outfieldDetectionAdapter.setOnItemClickedListener(object : + NormalRecyclerAdapter.OnItemClickedListener { + override fun onItemClicked( + position: Int, t: OutfieldDetectionListModel.DataModel.RowsModel + ) { + + } + }) + } + } + } + } + true + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java new file mode 100644 index 0000000..1397228 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/model/OutfieldDetectionListModel.java @@ -0,0 +1,364 @@ +package com.casic.xz.meterage.model; + +import java.util.List; + +public class OutfieldDetectionListModel { + + private int code; + private DataModel data; + private String message; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public DataModel getData() { + return data; + } + + public void setData(DataModel data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private List rows; + private int total; + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public static class RowsModel { + private String addressAreaName; + private String addressCityName; + private String addressCountryName; + private String addressProvinceName; + private String applyTime; + private String approvalStatus; + private String approvalStatusName; + private String createTime; + private String customerId; + private String customerName; + private String decisionItem; + private String director; + private String directorId; + private String directorName; + private String executiveAddress; + private String executiveEnvironment; + private String executiveItem; + private String fullAddress; + private String hazardSourceAndPreventionMethod; + private String id; + private String isDel; + private String orderId; + private String phone; + private String preCost; + private String preEndTime; + private String preStartTime; + private String processId; + private String remark; + private String siteExecutiveName; + private String siteExecutiveNo; + private String taskId; + private String taskSource; + private String taskSourceName; + private String updateTime; + + public String getAddressAreaName() { + return addressAreaName; + } + + public void setAddressAreaName(String addressAreaName) { + this.addressAreaName = addressAreaName; + } + + public String getAddressCityName() { + return addressCityName; + } + + public void setAddressCityName(String addressCityName) { + this.addressCityName = addressCityName; + } + + public String getAddressCountryName() { + return addressCountryName; + } + + public void setAddressCountryName(String addressCountryName) { + this.addressCountryName = addressCountryName; + } + + public String getAddressProvinceName() { + return addressProvinceName; + } + + public void setAddressProvinceName(String addressProvinceName) { + this.addressProvinceName = addressProvinceName; + } + + public String getApplyTime() { + return applyTime; + } + + public void setApplyTime(String applyTime) { + this.applyTime = applyTime; + } + + public String getApprovalStatus() { + return approvalStatus; + } + + public void setApprovalStatus(String approvalStatus) { + this.approvalStatus = approvalStatus; + } + + public String getApprovalStatusName() { + return approvalStatusName; + } + + public void setApprovalStatusName(String approvalStatusName) { + this.approvalStatusName = approvalStatusName; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getDecisionItem() { + return decisionItem; + } + + public void setDecisionItem(String decisionItem) { + this.decisionItem = decisionItem; + } + + public String getDirector() { + return director; + } + + public void setDirector(String director) { + this.director = director; + } + + public String getDirectorId() { + return directorId; + } + + public void setDirectorId(String directorId) { + this.directorId = directorId; + } + + public String getDirectorName() { + return directorName; + } + + public void setDirectorName(String directorName) { + this.directorName = directorName; + } + + public String getExecutiveAddress() { + return executiveAddress; + } + + public void setExecutiveAddress(String executiveAddress) { + this.executiveAddress = executiveAddress; + } + + public String getExecutiveEnvironment() { + return executiveEnvironment; + } + + public void setExecutiveEnvironment(String executiveEnvironment) { + this.executiveEnvironment = executiveEnvironment; + } + + public String getExecutiveItem() { + return executiveItem; + } + + public void setExecutiveItem(String executiveItem) { + this.executiveItem = executiveItem; + } + + public String getFullAddress() { + return fullAddress; + } + + public void setFullAddress(String fullAddress) { + this.fullAddress = fullAddress; + } + + public String getHazardSourceAndPreventionMethod() { + return hazardSourceAndPreventionMethod; + } + + public void setHazardSourceAndPreventionMethod(String hazardSourceAndPreventionMethod) { + this.hazardSourceAndPreventionMethod = hazardSourceAndPreventionMethod; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsDel() { + return isDel; + } + + public void setIsDel(String isDel) { + this.isDel = isDel; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPreCost() { + return preCost; + } + + public void setPreCost(String preCost) { + this.preCost = preCost; + } + + public String getPreEndTime() { + return preEndTime; + } + + public void setPreEndTime(String preEndTime) { + this.preEndTime = preEndTime; + } + + public String getPreStartTime() { + return preStartTime; + } + + public void setPreStartTime(String preStartTime) { + this.preStartTime = preStartTime; + } + + public String getProcessId() { + return processId; + } + + public void setProcessId(String processId) { + this.processId = processId; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getSiteExecutiveName() { + return siteExecutiveName; + } + + public void setSiteExecutiveName(String siteExecutiveName) { + this.siteExecutiveName = siteExecutiveName; + } + + public String getSiteExecutiveNo() { + return siteExecutiveNo; + } + + public void setSiteExecutiveNo(String siteExecutiveNo) { + this.siteExecutiveNo = siteExecutiveNo; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTaskSource() { + return taskSource; + } + + public void setTaskSource(String taskSource) { + this.taskSource = taskSource; + } + + public String getTaskSourceName() { + return taskSourceName; + } + + public void setTaskSourceName(String taskSourceName) { + this.taskSourceName = taskSourceName; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + } + } +} diff --git a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt index 36059c5..1feffe7 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/LocaleConstant.kt @@ -69,4 +69,5 @@ const val STANDARD_FILE_FORM_ID = "jlglwjsp" const val CERTIFICATE_REPORT_FORM_ID = "ywglzsbg" const val CONTRACT_FORM_ID = "cwczht" + const val OUTFIELD_DETECTION_FORM_ID = "ywglxcjc" } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt index d104cea..5bb091f 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitService.kt @@ -466,4 +466,15 @@ @Header("token") token: String, @Body requestBody: RequestBody ): String + + /** + * 获取外场检测申请列表 + */ + @POST("/business/siteExecutive/approval/listPage") + suspend fun getOutfieldDetectionList( + @Header("token") token: String, + @Body requestBody: RequestBody, + @QueryMap limit: Map, + @QueryMap offset: Map + ): String } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt index 759a2a5..add9920 100644 --- a/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/xz/meterage/utils/retrofit/RetrofitServiceManager.kt @@ -1063,4 +1063,35 @@ ) return api.getContractDetail(AuthenticationHelper.token!!, requestBody) } + + /** + * 获取外场检测申请列表 + */ + suspend fun getOutfieldDetectionList( + approvalStatus: String, + customerName: String, + directorName: String, + siteExecutiveNo: String, + offset: Int + ): String { + val param = JsonObject() + param.addProperty("approvalStatus", approvalStatus) + param.addProperty("customerName", customerName) + param.addProperty("directorName", directorName) + param.addProperty("siteExecutiveNo", siteExecutiveNo) + param.addProperty("formId", LocaleConstant.OUTFIELD_DETECTION_FORM_ID) + + val requestBody = param.toString().toRequestBody( + "application/json;charset=UTF-8".toMediaType() + ) + + val limitMap = HashMap() + limitMap["limit"] = LocaleConstant.PAGE_LIMIT + + val offsetMap = HashMap() + offsetMap["offset"] = offset + return api.getOutfieldDetectionList( + AuthenticationHelper.token!!, requestBody, limitMap, offsetMap + ) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt b/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt new file mode 100644 index 0000000..8b3a375 --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/view/home/OutfieldDetectionActivity.kt @@ -0,0 +1,60 @@ +package com.casic.xz.meterage.view.home + +import androidx.fragment.app.Fragment +import com.casic.xz.meterage.R +import com.casic.xz.meterage.adapter.SubViewPagerAdapter +import com.casic.xz.meterage.base.ApplicationBaseActivity +import com.casic.xz.meterage.extensions.initLayoutImmersionBar +import com.casic.xz.meterage.fragment.outfield.OutfieldDetectionFragment +import com.gyf.immersionbar.ImmersionBar +import kotlinx.android.synthetic.main.activity_outfield_detection.* +import kotlinx.android.synthetic.main.include_base_title.* + +class OutfieldDetectionActivity : ApplicationBaseActivity() { + + private val pageTitles = arrayOf( + "草稿箱", + "审批中", + "已通过", + "未通过", + "已取消" + ) + private var fragmentPages: ArrayList = ArrayList() + + init { + pageTitles.forEach { + //和证书报告状态一致 + when (it) { + "草稿箱" -> fragmentPages.add(OutfieldDetectionFragment("1")) + "审批中" -> fragmentPages.add(OutfieldDetectionFragment("3")) + "已通过" -> fragmentPages.add(OutfieldDetectionFragment("4")) + "未通过" -> fragmentPages.add(OutfieldDetectionFragment("5")) + "已取消" -> fragmentPages.add(OutfieldDetectionFragment("6")) + } + } + } + + override fun initLayoutView(): Int = R.layout.activity_outfield_detection + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(true).init() + initLayoutImmersionBar(rootView) + titleView.text = "外场检测" + } + + override fun initData() { + viewPager.adapter = SubViewPagerAdapter( + supportFragmentManager, fragmentPages, pageTitles + ) + //绑定 + topTabLayout.setupWithViewPager(viewPager) + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + leftBackView.setOnClickListener { finish() } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt b/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt new file mode 100644 index 0000000..fbded6a --- /dev/null +++ b/app/src/main/java/com/casic/xz/meterage/vm/OutfieldDetectionViewModel.kt @@ -0,0 +1,50 @@ +package com.casic.xz.meterage.vm + +import androidx.lifecycle.MutableLiveData +import com.casic.xz.meterage.base.BaseApplication +import com.casic.xz.meterage.extensions.separateResponseCode +import com.casic.xz.meterage.extensions.toErrorMessage +import com.casic.xz.meterage.model.OutfieldDetectionListModel +import com.casic.xz.meterage.utils.retrofit.RetrofitServiceManager +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken +import com.pengxh.kt.lite.extensions.launch +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.vm.BaseViewModel +import com.pengxh.kt.lite.vm.LoadState + +/** + * 外场检测 VM + * */ +class OutfieldDetectionViewModel : BaseViewModel() { + + private val gson by lazy { Gson() } + val outfieldDetectionList = MutableLiveData() + + fun getOutfieldDetectionList( + approvalStatus: String, + customerName: String, + directorName: String, + siteExecutiveNo: String, + offset: Int + ) = launch({ + loadState.value = LoadState.Loading + val response = RetrofitServiceManager.getOutfieldDetectionList( + approvalStatus, customerName, directorName, siteExecutiveNo, offset + ) + val responseCode = response.separateResponseCode() + if (responseCode == 200) { + loadState.value = LoadState.Success + outfieldDetectionList.value = gson.fromJson( + response, object : TypeToken() {}.type + ) + } else { + loadState.value = LoadState.Fail + response.toErrorMessage().show(BaseApplication.get()) + } + }, { + loadState.value = LoadState.Fail + it.cause.toString().show(BaseApplication.get()) + it.printStackTrace() + }) +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_outfield_detection.xml b/app/src/main/res/layout/activity_outfield_detection.xml new file mode 100644 index 0000000..87fa531 --- /dev/null +++ b/app/src/main/res/layout/activity_outfield_detection.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_outfield_detection.xml b/app/src/main/res/layout/fragment_outfield_detection.xml new file mode 100644 index 0000000..18ee1bd --- /dev/null +++ b/app/src/main/res/layout/fragment_outfield_detection.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_contract_collection_rv_l.xml b/app/src/main/res/layout/item_contract_collection_rv_l.xml index 3ece950..6cf075d 100644 --- a/app/src/main/res/layout/item_contract_collection_rv_l.xml +++ b/app/src/main/res/layout/item_contract_collection_rv_l.xml @@ -44,7 +44,7 @@ diff --git a/app/src/main/res/layout/item_outfield_detection_rv_l.xml b/app/src/main/res/layout/item_outfield_detection_rv_l.xml new file mode 100644 index 0000000..174f10d --- /dev/null +++ b/app/src/main/res/layout/item_outfield_detection_rv_l.xml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file