From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/utils/AdminUtils.java | 348 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 174 insertions(+), 174 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 09e46ee..56d8a85 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 @@ -1,174 +1,174 @@ -package com.yeshi.fanli.controller.admin.utils; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -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 { - - /** - * 楠岃瘉鏁版嵁 - * @param dateType - * @param startTime - * @param endTime - * @return - */ - public static String validateParams(Integer dateType, String startTime, String endTime) { - - String validateMsg = null; - - if (dateType == null) { - validateMsg = "璇烽�夋嫨瑙嗗浘绫诲瀷"; - } - - if (dateType == 1 && (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime))) { - validateMsg = "璇烽�夋嫨鏃堕棿鍖洪棿"; - } - - return validateMsg; - } - - /** - * 鑾峰彇鏃堕棿鍒楄〃 - * @param dateType - * @param startTime - * @param endTime - * @param year - * @return - */ - public static List<String> getDateList(Integer dateType, String startTime, String endTime, String year) { - List<String> dateList = new ArrayList<String>(); - if (dateType == 1) { - try { - dateList = DateUtil.dayFactory(startTime, endTime); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (dateType == 2) { - for (int i = 1; i <= 12; i++) { - dateList.add(i + ""); // 12涓湀 - } - } else if (dateType == 3) { - for (int i = 2018; i <= 2030; i++) { - dateList.add(i + ""); // 10骞� - } - } - - return dateList; - } - - - 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 (ChartTDO chart: list) { - String showDate = chart.getShowDate(); - String showValue = chart.getShowValue(); - if (showValue == null) { - showValue = "0"; - } - resultList.add(showValue); - listDate.add(showDate); - } - } - - Map<String, Object> map = new HashMap<String, Object>(); - map.put("date", listDate); - map.put("value", resultList); - - return map; - } - - - - public static List<Object> dayOrMonthDataFactory(Integer dateType, List<String> listDate , - 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++) { - 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"; - } - resultList.add(showValue); - } - } - return resultList; - } - - - /** - * 鍥捐〃鏁版嵁缁勭粐 - * @param dateType - * @param year - * @param startTime - * @param endTime - * @param list - * @throws Exception - */ - public static JSONObject chartDataFactory(Integer dateType, String year, String startTime, String endTime, - List<ChartTDO> list) throws Exception{ - - Object objectDate = null; - List<String> dateList = getDateList(dateType, startTime, endTime, year); - - Gson gson = new Gson(); - JSONArray line_list = new JSONArray(); - - JSONObject innerList = new JSONObject(); - innerList.put("name", "鎬昏"); - - if (dateType != 3) { - innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list))); - } else { - // 骞磋鍥� - Map<String, Object> map = yearsDataFactory(list); - - if (objectDate == null) { - objectDate = map.get("date"); - } - innerList.put("data", gson.toJson(map.get("value"))); - } - - line_list.add(innerList); - - JSONObject data = new JSONObject(); - if (objectDate != null) { - data.put("xAxis_list", gson.toJson(objectDate)); - } else { - data.put("xAxis_list", gson.toJson(dateList)); - } - - data.put("line_list", line_list); - return data; - } - -} +package com.yeshi.fanli.controller.admin.utils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +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 { + + /** + * 楠岃瘉鏁版嵁 + * @param dateType + * @param startTime + * @param endTime + * @return + */ + public static String validateParams(Integer dateType, String startTime, String endTime) { + + String validateMsg = null; + + if (dateType == null) { + validateMsg = "璇烽�夋嫨瑙嗗浘绫诲瀷"; + } + + if (dateType == 1 && (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime))) { + validateMsg = "璇烽�夋嫨鏃堕棿鍖洪棿"; + } + + return validateMsg; + } + + /** + * 鑾峰彇鏃堕棿鍒楄〃 + * @param dateType + * @param startTime + * @param endTime + * @param year + * @return + */ + public static List<String> getDateList(Integer dateType, String startTime, String endTime, String year) { + List<String> dateList = new ArrayList<String>(); + if (dateType == 1) { + try { + dateList = DateUtil.dayFactory(startTime, endTime); + } catch (Exception e) { + e.printStackTrace(); + } + + } else if (dateType == 2) { + for (int i = 1; i <= 12; i++) { + dateList.add(i + ""); // 12涓湀 + } + } else if (dateType == 3) { + for (int i = 2018; i <= 2030; i++) { + dateList.add(i + ""); // 10骞� + } + } + + return dateList; + } + + + 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 (ChartTDO chart: list) { + String showDate = chart.getShowDate(); + String showValue = chart.getShowValue(); + if (showValue == null) { + showValue = "0"; + } + resultList.add(showValue); + listDate.add(showDate); + } + } + + Map<String, Object> map = new HashMap<String, Object>(); + map.put("date", listDate); + map.put("value", resultList); + + return map; + } + + + + public static List<Object> dayOrMonthDataFactory(Integer dateType, List<String> listDate , + 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++) { + 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"; + } + resultList.add(showValue); + } + } + return resultList; + } + + + /** + * 鍥捐〃鏁版嵁缁勭粐 + * @param dateType + * @param year + * @param startTime + * @param endTime + * @param list + * @throws Exception + */ + public static JSONObject chartDataFactory(Integer dateType, String year, String startTime, String endTime, + List<ChartTDO> list) throws Exception{ + + Object objectDate = null; + List<String> dateList = getDateList(dateType, startTime, endTime, year); + + Gson gson = new Gson(); + JSONArray line_list = new JSONArray(); + + JSONObject innerList = new JSONObject(); + innerList.put("name", "鎬昏"); + + if (dateType != 3) { + innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list))); + } else { + // 骞磋鍥� + Map<String, Object> map = yearsDataFactory(list); + + if (objectDate == null) { + objectDate = map.get("date"); + } + innerList.put("data", gson.toJson(map.get("value"))); + } + + line_list.add(innerList); + + JSONObject data = new JSONObject(); + if (objectDate != null) { + data.put("xAxis_list", gson.toJson(objectDate)); + } else { + data.put("xAxis_list", gson.toJson(dateList)); + } + + data.put("line_list", line_list); + return data; + } + +} -- Gitblit v1.8.0