From 93000441daeeabce0696bb32c5335e10740916d6 Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Mon, 12 Jul 2021 09:23:17 +0800
Subject: [PATCH] 1.

---
 src/main/java/org/springblade/modules/performance/controller/PerformanceController.java |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/src/main/java/org/springblade/modules/performance/controller/PerformanceController.java b/src/main/java/org/springblade/modules/performance/controller/PerformanceController.java
index 1d5991c..4ccccdd 100644
--- a/src/main/java/org/springblade/modules/performance/controller/PerformanceController.java
+++ b/src/main/java/org/springblade/modules/performance/controller/PerformanceController.java
@@ -21,8 +21,13 @@
 import io.swagger.annotations.ApiParam;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import lombok.AllArgsConstructor;
+
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 
+import net.sourceforge.pinyin4j.PinyinHelper;
+import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
+import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
@@ -33,6 +38,8 @@
 import org.springblade.modules.performance.vo.PerformanceVO;
 import org.springblade.modules.performance.service.IPerformanceService;
 import org.springblade.core.boot.ctrl.BladeController;
+
+import java.util.*;
 
 /**
  *  保安员表现管理
@@ -122,4 +129,51 @@
 	}
 
 
+	/**
+	 * 查询本年所有月份的表现差的数量
+	 * @return
+	 */
+	@GetMapping("/queryYearPer")
+	public R queryYearAlarm() {
+		Calendar cal = Calendar.getInstance();
+		String year = String.valueOf(cal.get(Calendar.YEAR));
+		Map<String, String> map = performanceService.queryYearPer(year);
+		map = (HashMap<String, String>) sortMapBykeyAsc(map) ;//key升序
+		return R.data(map);
+	}
+
+	//升序
+	public  static Map<String, String> sortMapBykeyAsc(Map<String, String> oriMap) {
+		Map<String, String> sortedMap = new LinkedHashMap<String, String>();
+		try {
+			if (oriMap != null && !oriMap.isEmpty()) {
+				List<Map.Entry<String, String>> entryList = new ArrayList<Map.Entry<String, String>>(oriMap.entrySet());
+				Collections.sort(entryList,
+					new Comparator<Map.Entry<String, String>>() {
+						public int compare(Map.Entry<String, String> entry2,
+										   Map.Entry<String, String> entry1) {
+							int value2 = 0, value1 = 0;
+							try {
+								value2 = Integer.parseInt(entry1.getKey());
+								value1 = Integer.parseInt(entry2.getKey());
+							} catch (NumberFormatException e) {
+								value2 = 0;
+								value1 = 0;
+							}
+							return value1 - value2;
+						}
+					});
+				Iterator<Map.Entry<String, String>> iter = entryList.iterator();
+				Map.Entry<String, String> tmpEntry = null;
+				while (iter.hasNext()) {
+					tmpEntry = iter.next();
+					sortedMap.put(tmpEntry.getKey(), tmpEntry.getValue());
+				}
+			}
+		} catch (Exception e) {
+		}
+		return sortedMap;
+	}
+
+
 }

--
Gitblit v1.9.3