From 5bdba4f712b203db5acdd981922a5bc1706b29ff Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期一, 11 九月 2023 19:15:43 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/crm/manager/controller/DashboardController.java | 56 ++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 36 insertions(+), 20 deletions(-)
diff --git a/src/main/java/com/zy/crm/manager/controller/DashboardController.java b/src/main/java/com/zy/crm/manager/controller/DashboardController.java
index ffecb50..1202412 100644
--- a/src/main/java/com/zy/crm/manager/controller/DashboardController.java
+++ b/src/main/java/com/zy/crm/manager/controller/DashboardController.java
@@ -7,12 +7,13 @@
import com.zy.crm.manager.entity.Order;
import com.zy.crm.manager.service.CompanyTargetService;
import com.zy.crm.manager.service.OrderService;
-import com.zy.crm.manager.utils.WordUtils;
import com.zy.crm.system.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -33,14 +34,15 @@
public R getCompanyData() {
HashMap<String, Object> map = new HashMap<>();
+ NumberFormat formatter = new DecimalFormat("#,###");
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy");
String year = format.format(date);
- CompanyTarget companyTarget = companyTargetService.selectByYear(year);//鑾峰彇鍏徃鍏ㄥ勾鐩爣鏁版嵁
+ CompanyTarget companyTarget = companyTargetService.selectCompanyByYear(year);//鑾峰彇鍏徃鍏ㄥ勾鐩爣鏁版嵁
if (companyTarget == null) {
return R.error();
}
- map.put("yearTarget", companyTarget.getTarget$());//鍏ㄥ勾浜ゆ槗鐩爣
+ map.put("yearTarget", formatter.format(Double.parseDouble(companyTarget.getTarget())));//鍏ㄥ勾浜ゆ槗鐩爣
//鑾峰彇鍏ㄥ勾浜ゆ槗鎴愬姛閲戦
Double successMoney = orderService.selectMoneyByYearAndStatus(year, 1);
@@ -48,10 +50,12 @@
Double progressMoney = orderService.selectMoneyByYearAndStatus(year, 0);
//鑾峰彇鍏ㄥ勾浜ゆ槗澶辫触閲戦
Double failedMoney = orderService.selectMoneyByYearAndStatus(year, 2);
- //鍏ㄥ勾浜ゆ槗鐜�
- double yearTransactionRate = successMoney == 0 ? successMoney : (successMoney / (successMoney + progressMoney + failedMoney)) * 100;
- map.put("successMoney", WordUtils.formatNumberForAccounting(successMoney));//鍏ㄥ勾浜ゆ槗鎴愬姛閲戦
- map.put("progressMoney", WordUtils.formatNumberForAccounting(progressMoney));//鍏ㄥ勾鏈氦鏄撴垚鍔熼噾棰�
+ //鍏ㄥ勾瀹屾垚鐜�
+// double yearTransactionRate = successMoney == 0 ? successMoney : (successMoney / (successMoney + progressMoney + failedMoney)) * 100;
+ double yearTransactionRate = successMoney == 0 ? successMoney : (successMoney / Double.parseDouble(companyTarget.getTarget())) * 100;
+
+ map.put("successMoney", formatter.format(successMoney));//鍏ㄥ勾浜ゆ槗鎴愬姛閲戦
+ map.put("progressMoney", formatter.format(progressMoney));//鍏ㄥ勾鏈氦鏄撴垚鍔熼噾棰�
map.put("yearTransactionRate", String.format("%.2f", yearTransactionRate));//鍏ㄥ勾浜ゆ槗鐜�
return R.ok().add(map);
}
@@ -62,28 +66,39 @@
public R getPersonData() {
HashMap<String, Object> map = new HashMap<>();
+ NumberFormat formatter = new DecimalFormat("#,###");
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy");
String year = format.format(date);
- User user = getUser();
- String yearTarget = "0.00";//鑾峰彇涓汉鍏ㄥ勾鐩爣鏁版嵁
- if (user.getTarget() != null) {
- yearTarget = WordUtils.formatNumberForAccounting(Double.parseDouble(user.getTarget()));;
+ Double yearTarget = 0D;//鑾峰彇涓汉鍏ㄥ勾鐩爣鏁版嵁
+ CompanyTarget person = companyTargetService.selectPersonByYear(year, getUserId());
+ if (person != null) {
+ yearTarget = Double.parseDouble(person.getTarget());
}
- map.put("yearTarget", yearTarget);//鍏ㄥ勾浜ゆ槗鐩爣
+ map.put("yearTarget", formatter.format(yearTarget));//鍏ㄥ勾浜ゆ槗鐩爣
//鑾峰彇鍏ㄥ勾浜ゆ槗鎴愬姛閲戦
- Double successMoney = orderService.selectMoneyByUserAndYearAndStatus(user.getId(), year, 1);
+ Double successMoney = orderService.selectMoneyByUserAndYearAndStatus(getUserId(), year, 1);
//鑾峰彇鍏ㄥ勾鏈氦鏄撴垚鍔熼噾棰�
- Double progressMoney = orderService.selectMoneyByUserAndYearAndStatus(user.getId(), year, 0);
+ Double progressMoney = orderService.selectMoneyByUserAndYearAndStatus(getUserId(), year, 0);
//鑾峰彇鍏ㄥ勾浜ゆ槗澶辫触閲戦
- Double failedMoney = orderService.selectMoneyByUserAndYearAndStatus(user.getId(), year, 2);
- //鍏ㄥ勾浜ゆ槗鐜�
- double yearTransactionRate = successMoney == 0 ? successMoney : (successMoney / (successMoney + progressMoney + failedMoney)) * 100;
- map.put("successMoney", WordUtils.formatNumberForAccounting(successMoney));//鍏ㄥ勾浜ゆ槗鎴愬姛閲戦
- map.put("progressMoney", WordUtils.formatNumberForAccounting(progressMoney));//鍏ㄥ勾鏈氦鏄撴垚鍔熼噾棰�
+ Double failedMoney = orderService.selectMoneyByUserAndYearAndStatus(getUserId(), year, 2);
+ //鍏ㄥ勾瀹屾垚鐜�
+// double yearTransactionRate = successMoney == 0 ? successMoney : (successMoney / (successMoney + progressMoney + failedMoney)) * 100;
+ double yearTransactionRate = yearTarget==0? 0 : successMoney == 0 ? successMoney : (successMoney / yearTarget) * 100;
+
+ map.put("successMoney", formatter.format(successMoney));//鍏ㄥ勾浜ゆ槗鎴愬姛閲戦
+ map.put("progressMoney", formatter.format(progressMoney));//鍏ㄥ勾鏈氦鏄撴垚鍔熼噾棰�
map.put("yearTransactionRate", String.format("%.2f", yearTransactionRate));//鍏ㄥ勾浜ゆ槗鐜�
+
+ //鑾峰彇鍏ㄥ勾璺熻釜鏁伴噺
+ Integer progressCount = orderService.selectCountByUserYearAndStatus(getUserId(), year, 0);
+ //鑾峰彇鍏ㄥ勾鎴愪氦鏁伴噺
+ Integer successCount = orderService.selectCountByUserYearAndStatus(getUserId(), year, 1);
+ map.put("progressCount", progressCount);
+ map.put("successCount", successCount);
+
return R.ok().add(map);
}
@@ -92,10 +107,11 @@
@ManagerAuth
public R getStaffRank() {
ArrayList<HashMap<String, Object>> list = new ArrayList<>();
+ NumberFormat formatter = new DecimalFormat("#,###");
for (Order order : orderService.selectTopMoney()) {
HashMap<String, Object> map = new HashMap<>();
map.put("username", order.getUserId$());
- map.put("money", WordUtils.formatNumberForAccounting(order.getMoney()));
+ map.put("money", formatter.format(order.getMoney()));
list.add(map);
}
return R.ok().add(list);
--
Gitblit v1.9.1