Browse Source

2024-10-30 新增

新增:
1. 市场部营业额 - 团组列表 - 新增团组列表Excel生成功能
zhaiy 2 months ago
parent
commit
b6b2d0915e

+ 14 - 0
app/src/main/java/com/pan_american/android/data/model/customer_resource/market_sales_revenue/network/GenerateMarketSalesDocumentRequest.kt

@@ -0,0 +1,14 @@
+package com.pan_american.android.data.model.customer_resource.market_sales_revenue.network
+
+import com.pan_american.android.OASystem
+import com.pan_american.android.base.BaseRequest
+
+data class GenerateMarketSalesDocumentRequest(
+    val userId: Int = OASystem.userInfo.userId,
+    val pageId: Int = OASystem.MARKET_SALES_REVENUE,
+    var companyId: Int = 0,
+    val groupPickupUserId: Int = OASystem.userInfo.userId,
+    var beginDt: String = "",
+    var endDt: String = "",
+    val searchCriteria: String = ""
+): BaseRequest()

+ 8 - 0
app/src/main/java/com/pan_american/android/data/model/customer_resource/market_sales_revenue/network/GenerateMarketSalesDocumentResponse.kt

@@ -0,0 +1,8 @@
+package com.pan_american.android.data.model.customer_resource.market_sales_revenue.network
+
+import com.pan_american.android.base.BaseResponse
+
+data class GenerateMarketSalesDocumentResponse(val data: Data): BaseResponse() {
+
+    inner class Data(val url: String)
+}

+ 9 - 1
app/src/main/java/com/pan_american/android/data/model/login/entity/UserInfo.kt

@@ -1,3 +1,11 @@
 package com.pan_american.android.data.model.login.entity
 
-data class UserInfo(val userId: Int, val cnName: String, val companyName: String, val depName: String, val jobName: String, val email: String, val sex: Int)
+data class UserInfo(
+    val userId: Int,
+    val cnName: String,
+    val companyName: String,
+    val depName: String,
+    val jobName: String,
+    val email: String,
+    val sex: Int
+)

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

@@ -37,6 +37,8 @@ import com.pan_american.android.data.model.customer_resource.company_customer.ne
 import com.pan_american.android.data.model.customer_resource.company_customer.network.MarketCustomerRequest
 import com.pan_american.android.data.model.customer_resource.company_customer.network.MarketCustomerResponse
 import com.pan_american.android.data.model.customer_resource.company_customer.network.MarketCustomerSiftListResponse
+import com.pan_american.android.data.model.customer_resource.market_sales_revenue.network.GenerateMarketSalesDocumentRequest
+import com.pan_american.android.data.model.customer_resource.market_sales_revenue.network.GenerateMarketSalesDocumentResponse
 import com.pan_american.android.data.model.customer_resource.market_sales_revenue.network.MarketSalesAddVisitHistoryRequest
 import com.pan_american.android.data.model.customer_resource.market_sales_revenue.network.MarketSalesGroupListResponse
 import com.pan_american.android.data.model.customer_resource.market_sales_revenue.network.MarketSalesOrderRankResponse
@@ -924,6 +926,12 @@ interface APIService {
     @POST("/api/Statistics/PostMarketingSalesGroupList")
     fun getMarketSalesGroupList(@Body marketSalesStatisticsRequest: MarketSalesStatisticsRequest): Call<MarketSalesGroupListResponse>
 
+    /**
+     * 市场营业额,团组excel生成
+     */
+    @POST("/api/Statistics/PostMarketingSalesGroupExcel")
+    fun generateMarketSalesGroupListDocument(@Body generateMarketSalesDocumentRequest: GenerateMarketSalesDocumentRequest): Call<GenerateMarketSalesDocumentResponse>
+
     /**
      * 市场营业额,团组列表-拜访记录
      */

+ 70 - 1
app/src/main/java/com/pan_american/android/ui/customer_resource/market_sales_revenue/SalesRevenueListFragment.kt

@@ -1,6 +1,7 @@
 package com.pan_american.android.ui.customer_resource.market_sales_revenue
 
 import android.content.Intent
+import android.net.Uri
 import android.os.Bundle
 import android.view.LayoutInflater
 import android.view.View
@@ -11,9 +12,12 @@ import androidx.recyclerview.widget.LinearLayoutManager
 import com.pan_american.android.OASystem
 import com.pan_american.android.R
 import com.pan_american.android.base.BaseFragment
+import com.pan_american.android.base.CustomAlertDialog
 import com.pan_american.android.base.ListAdapter
 import com.pan_american.android.data.model.customer_resource.market_sales_revenue.entity.GroupListItem
 import com.pan_american.android.data.model.customer_resource.market_sales_revenue.entity.YearQuarterlyData
+import com.pan_american.android.data.model.customer_resource.market_sales_revenue.network.GenerateMarketSalesDocumentRequest
+import com.pan_american.android.data.model.customer_resource.market_sales_revenue.network.GenerateMarketSalesDocumentResponse
 import com.pan_american.android.data.model.customer_resource.market_sales_revenue.network.MarketSalesGroupListResponse
 import com.pan_american.android.data.model.customer_resource.market_sales_revenue.network.MarketSalesStatisticsRequest
 import com.pan_american.android.data.network.APIService
@@ -44,6 +48,8 @@ class SalesRevenueListFragment : BaseFragment<FragmentSalesRevenueListBinding>()
 
     private val marketSalesStatisticsRequest = MarketSalesStatisticsRequest()
 
+    private val generateMarketSalesDocumentRequest = GenerateMarketSalesDocumentRequest()
+
     private val groupList = ArrayList<GroupListItem>()
 
     override fun getViewBinding(
@@ -128,6 +134,64 @@ class SalesRevenueListFragment : BaseFragment<FragmentSalesRevenueListBinding>()
                 }
             }
         }
+
+        binding.generateDocument.setOnClickListener {
+
+            generateMarketSalesDocumentRequest.apply {
+                for (item in OASystem.marketSalesRevenueCompanyList) {
+                    if (item.name == OASystem.userInfo.companyName) {
+                        companyId = item.id
+                    }
+                }
+
+                beginDt = "$year-01-01"
+                endDt = "$year-12-31"
+            }
+
+            apiService.generateMarketSalesGroupListDocument(generateMarketSalesDocumentRequest).enqueue(object : Callback<GenerateMarketSalesDocumentResponse> {
+                override fun onResponse(
+                    call: Call<GenerateMarketSalesDocumentResponse>,
+                    response: Response<GenerateMarketSalesDocumentResponse>
+                ) {
+                    val urlResponse = response.body()
+
+                    if (urlResponse != null) {
+                        if (urlResponse.code == 200) {
+
+                            CustomAlertDialog.Builder(OASystem.context).apply {
+                                setTitle(resources.getString(R.string.hint))
+                                setMessage(
+                                    String.format(
+                                        resources.getString(R.string.market_sales_revenue_group_excel_generated),
+                                        generateMarketSalesDocumentRequest.beginDt,
+                                        generateMarketSalesDocumentRequest.endDt
+                                    )
+                                )
+                                setNegativeButtonAndListener(resources.getString(R.string.cancel)) { dialog, _ ->
+                                    dialog.dismiss()
+                                }
+                                setPositiveButtonAndListener(resources.getString(R.string.confirm)) { dialog, _ ->
+                                    val uri = Uri.parse(urlResponse.data.url)
+                                    startActivity(Intent(Intent.ACTION_VIEW, uri))
+
+                                    dialog.dismiss()
+                                }
+                            }.show()
+
+                        } else {
+                            showMessage(urlResponse.msg)
+                        }
+                    }
+                }
+
+                override fun onFailure(
+                    p0: Call<GenerateMarketSalesDocumentResponse>,
+                    p1: Throwable
+                ) {
+                    showErrorInfo(R.string.interface_request_error)
+                }
+            })
+        }
     }
 
     private fun getGroupCustomerList(type: Int) {
@@ -154,6 +218,12 @@ class SalesRevenueListFragment : BaseFragment<FragmentSalesRevenueListBinding>()
                                 groupList.add(item)
                             }
 
+                            if (groupList.size == 0) {
+                                showMessage(resources.getString(R.string.no_data))
+                            } else {
+                                binding.generateDocument.visibility = View.VISIBLE
+                            }
+
                             when(type) {
                                 1 -> {
                                     totalPage = getTotalPage(listResponse.count)
@@ -206,7 +276,6 @@ class SalesRevenueListFragment : BaseFragment<FragmentSalesRevenueListBinding>()
     private fun initList() {
 
         if (groupList.size == 0) {
-            showMessage(resources.getString(R.string.no_data))
             return
         }
 

+ 26 - 7
app/src/main/res/layout/fragment_sales_revenue_list.xml

@@ -12,6 +12,7 @@
         android:layout_marginStart="@dimen/common_padding"
         android:layout_marginTop="@dimen/common_padding_large"
         android:layout_marginEnd="@dimen/common_padding"
+        android:layout_marginBottom="@dimen/common_padding_large"
         android:orientation="horizontal">
 
         <TextView
@@ -34,17 +35,12 @@
             android:textSize="@dimen/text_size_medium" />
     </LinearLayout>
 
-    <View
-        android:layout_width="match_parent"
-        android:layout_height="@dimen/line"
-        android:layout_margin="@dimen/common_padding"
-        android:background="@color/line_color" />
-
     <com.scwang.smart.refresh.layout.SmartRefreshLayout
         android:id="@+id/group_customer_container"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
+        android:layout_height="0dp"
         android:layout_margin="@dimen/common_padding"
+        android:layout_weight="1"
         app:srlEnablePreviewInEditMode="true">
 
         <com.scwang.smart.refresh.header.ClassicsHeader
@@ -62,4 +58,27 @@
             android:layout_height="wrap_content" />
     </com.scwang.smart.refresh.layout.SmartRefreshLayout>
 
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <TextView
+            android:id="@+id/generate_document"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="@dimen/common_padding"
+            android:layout_marginTop="@dimen/common_padding"
+            android:layout_marginEnd="@dimen/common_padding"
+            android:layout_marginBottom="@dimen/common_padding_large"
+            android:background="@drawable/shape_corner_solid_blue"
+            android:gravity="center"
+            android:padding="@dimen/common_padding"
+            android:text="@string/generate_market_sales_revenue_group_excel"
+            android:textColor="@color/white"
+            android:textSize="@dimen/text_size_medium"
+            android:textStyle="bold"
+            android:visibility="gone" />
+
+    </LinearLayout>
+
 </LinearLayout>

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

@@ -1017,6 +1017,10 @@
     <string name="market_turnover">营业额</string>
     <string name="payment_date">收款日期</string>
 
+    <string name="generate_market_sales_revenue_group_excel">生成团组列表Excel</string>
+
+    <string name="market_sales_revenue_group_excel_generated">团组列表文档已生成,点击确认前往下载 \n\n生成时段: %s - %s</string>
+    
     <string name="visit_history">拜访记录</string>
     <string name="add_visit_history">添加拜访记录</string>
     <string name="visit_history_detail">拜访记录详情</string>