From 0c78c7aaeaa5a427bc8a5c5faf3cd6bbb589c2da Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期二, 08 十月 2019 12:08:38 +0800
Subject: [PATCH] map 改造

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/utils/AdminUtils.java |   61 +++++++++++-------------------
 1 files changed, 23 insertions(+), 38 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/utils/AdminUtils.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/utils/AdminUtils.java
index da98543..1c11f48 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/utils/AdminUtils.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/utils/AdminUtils.java
@@ -5,13 +5,14 @@
 import java.util.List;
 import java.util.Map;
 
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-
 import org.yeshi.utils.DateUtil;
 
 import com.google.gson.Gson;
+import com.yeshi.fanli.dto.ChartTDO;
 import com.yeshi.fanli.util.StringUtil;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
 
 
 public class AdminUtils {
@@ -65,21 +66,18 @@
 	}
 	
 	
-	public static Map<String, Object> yearsDataFactory(List<Map<String, Object>> list) {
+	public static Map<String, Object> yearsDataFactory(List<ChartTDO> list) {
 
 		List<Object> resultList = new ArrayList<Object>();
 		List<Object> listDate = new ArrayList<Object>();
 		
 		if (list != null && list.size() > 0) {
-			for (int i = 0; i < list.size(); i++) {
-				Map<String, Object> map = list.get(i);
-				Object showValue = map.get("showValue");
-				Object showDate = map.get("showDate");
-	
+			for (ChartTDO chart: list) {
+				String showDate = chart.getShowDate();
+				String showValue = chart.getShowValue();
 				if (showValue == null) {
-					showValue = 0;
+					showValue = "0";
 				}
-				
 				resultList.add(showValue);
 				listDate.add(showDate);
 			}
@@ -95,43 +93,30 @@
 	
 	
 	public static List<Object> dayOrMonthDataFactory(Integer dateType, List<String> listDate , 
-			List<Map<String, Object>> list) throws Exception {
-
+			List<ChartTDO> list) throws Exception {
 		List<Object> resultList = new ArrayList<Object>();
-		
 		if (list != null && list.size() > 0) {
 			for (int i = 0; i < listDate.size(); i++) {
-				
-				Object showValue = null;
-				if (list != null && list.size() > 0) {
-					// 鏃ユ湡鍖归厤璧嬪��
-					for (int j = 0; j < list.size(); j++) {
-						Map<String, Object> map = list.get(j);
-						
-						String showDate = listDate.get(i);
-						if (dateType == 2 && Integer.parseInt(showDate) < 10 ) {
-							showDate = "0" + showDate;
-						}
-						
-						Object reslutDate = map.get("showDate");
-						String reslutTime = reslutDate.toString();
-						
-						if (showDate.equalsIgnoreCase(reslutTime)) {
-							showValue = map.get("showValue");
-							break;
-						}
-						
+				String showValue = null;
+				// 鏃ユ湡鍖归厤璧嬪��
+				for (ChartTDO chart: list) {
+					String showDate = listDate.get(i);
+					if (dateType == 2 && Integer.parseInt(showDate) < 10 ) {
+						showDate = "0" + showDate;
+					}
+					String reslutTime = chart.getShowDate();
+					if (showDate.equalsIgnoreCase(reslutTime)) {
+						showValue = chart.getShowValue();
+						break;
 					}
 				}
 				
-				
 				if (showValue == null) {
-					showValue = 0;
+					showValue = "0";
 				}
 				resultList.add(showValue);
 			}
 		}
-		
 		return resultList;
 	}
 	
@@ -146,7 +131,7 @@
 	 * @throws Exception
 	 */
 	public static JSONObject chartDataFactory(Integer dateType, String year, String startTime, String endTime, 
-			List<Map<String, Object>> list) throws Exception{
+			List<ChartTDO> list) throws Exception{
 
 		Object objectDate = null;
 		List<String> dateList = getDateList(dateType, startTime, endTime, year);

--
Gitblit v1.8.0