From abbaf2374fff7d02ecc3eecd6bf62504fbf27c4b Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Tue, 06 Apr 2021 22:33:25 +0800
Subject: [PATCH] 预警数量统计接口修改,预警数量分布接口修改,预警分类占比接口新增

---
 blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/parcel/service/impl/ParcelServiceImpl.java |   94 +++++++++++++++++++++++++++++-----------------
 1 files changed, 59 insertions(+), 35 deletions(-)

diff --git a/blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/parcel/service/impl/ParcelServiceImpl.java b/blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/parcel/service/impl/ParcelServiceImpl.java
index f1b2906..bca65ef 100644
--- a/blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/parcel/service/impl/ParcelServiceImpl.java
+++ b/blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/parcel/service/impl/ParcelServiceImpl.java
@@ -4,6 +4,7 @@
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import io.swagger.models.auth.In;
+import org.springblade.jfpt.animalheat.util.ImageUtil;
 import org.springblade.jfpt.parcel.service.ParcelService;
 import org.springblade.jfpt.parcel.util.DateUtils;
 import org.springblade.jfpt.parcel.util.HttpClientUtils;
@@ -155,7 +156,7 @@
 				//12.封装数据
 				list.add(listTime);
 				list.add(parcelList);
-				list.add(getKindServenDataList());
+				list.add(getKindServenDataList(conditionVo));
 				//13.返回
 				return list;
 			}
@@ -178,28 +179,38 @@
 		String startDate = null;
 		String endDate = null;
 		//2.2查询本天的数据
-		if (conditionVo.getStatus() == 0) {
-			//3.获取本天开始时间和结束时间
-			startDate = DateUtils.getToday();
-			endDate = DateUtils.getToday();
+		if (null!=conditionVo.getStatus()) {
+			if (conditionVo.getStatus() == 0) {
+				//3.获取本天开始时间和结束时间
+				startDate = DateUtils.getToday();
+				endDate = DateUtils.getToday();
+			}
+			//2.2查询过去6天及当天的的数据
+			if (conditionVo.getStatus() == 1) {
+				//3.获取过去6天及当天开始时间和结束时间
+				startDate = DateUtils.getPastDate(6, now());
+				endDate = DateUtils.getToday();
+			}
+			//2.4查询本周的数据
+			if (conditionVo.getStatus() == 3) {
+				//3.获取过去6天及当天开始时间和结束时间
+				startDate = DateUtils.getWeekStart();
+				endDate = DateUtils.getWeekEnd();
+			}
+			//2.2查询本月的数据
+			if (conditionVo.getStatus() == 2) {
+				//3.获取本月开始时间和结束时间
+				startDate = DateUtils.getMonthStart();
+				endDate = DateUtils.getMonthEnd();
+			}
 		}
-		//2.2查询过去6天及当天的的数据
-		if (conditionVo.getStatus() == 1) {
-			//3.获取过去6天及当天开始时间和结束时间
-			startDate = DateUtils.getPastDate(6,now());
-			endDate = DateUtils.getToday();
-		}
-		//2.4查询本周的数据
-		if (conditionVo.getStatus() == 3) {
-			//3.获取过去6天及当天开始时间和结束时间
-			startDate = DateUtils.getWeekStart();
-			endDate = DateUtils.getWeekEnd();
-		}
-		//2.2查询本月的数据
-		if (conditionVo.getStatus() == 2) {
-			//3.获取本月开始时间和结束时间
-			startDate = DateUtils.getMonthStart();
-			endDate = DateUtils.getMonthEnd();
+		//2.5 按时间条件查询
+		if (null!=conditionVo.getStartTime() && conditionVo.getStartTime()!=""
+			&& null != conditionVo.getEndTime() && conditionVo.getEndTime()!=""){
+			startDate = conditionVo.getStartTime().substring(0,10);
+			System.out.println("startDate = " + startDate);
+			endDate = conditionVo.getEndTime().substring(0,10);
+			System.out.println("endDate = " + endDate);
 		}
 		map.put("startDate", startDate);
 		map.put("endDate", endDate);
@@ -217,21 +228,20 @@
 
 	/**
 	 * 查询包裹,违禁品总数
-	 * @param status 状态码 0:本天    1:本周   2:本月
+	 * @param conditionVo status 状态码 0:本天    1:本周   2:本月
 	 * @return
 	 */
 	@Override
-	public List<Integer> selectParcelCount(Integer status) {
+	public List<Integer> selectParcelCount(ConditionVo conditionVo) {
 		List<Integer> list = new ArrayList<>();
-		ConditionVo conditionVo = new ConditionVo();
-		conditionVo.setStatus(status);
 		//获取包裹数据
 		List<Object> parcelData = getParcelData(conditionVo, PARCEL_URL, PARCEL_KEY, PARCEL_SECRET);
 		if (null!=parcelData) {
 			//查询当天的包裹总数
 			Integer dangerCount = null;
 			Integer contrabandCount = null;
-			if (status == 0) {
+			conditionVo.setStatus(0);
+			if (conditionVo.getStatus() == 0) {
 				for (Object object : parcelData) {
 					//取出list里面的值转为map
 					Map<String, Object> objectMap = (Map<String, Object>) object;
@@ -253,9 +263,9 @@
 	 * @return
 	 */
 	@Override
-	public Map<String, Object> selectParcelData() {
+	public Map<String, Object> selectParcelData(ConditionVo conditionVo) {
 		HashMap<String, Object> map = new HashMap<>();
-		map.put("parcelData",getKindServenDataList());
+		map.put("parcelData",getKindServenDataList(conditionVo));
 		return map;
 	}
 
@@ -263,9 +273,10 @@
 	 * 获取危险违禁品7天内每天的数量集合
 	 * @return
 	 */
-	public List<Integer> getKindServenDataList(){
-		ConditionVo conditionVo = new ConditionVo();
-		conditionVo.setStatus(1);//近7天status 为 1
+	public List<Integer> getKindServenDataList(ConditionVo conditionVo){
+		if (null==conditionVo){
+			conditionVo.setStatus(1);//近7天status 为 1
+		}
 		//获取数据
 		List<Object> objectList = getParcelData(conditionVo,PARCEL_CONTRABAND_URL,PARCEL_KEY,PARCEL_SECRET);
 		if (null!=objectList) {
@@ -308,7 +319,7 @@
 	 * @return
 	 */
 	@Override
-	public Map<String, String> getParcelPic(String imgUrl) {
+	public Map<String, Object> getParcelPic(String imgUrl) {
 		//截取图片imgKey信息
 		String[] imgKeys = imgUrl.split("=", imgUrl.length());
 		String imgKey = imgKeys[1];
@@ -317,8 +328,12 @@
 		map.put("imgKey",imgKey);
 		//执行http远程调用
 		String s = HttpClientUtils.doGetHeaderPictureBase64(PARCEL_PICTURE_URL, PARCEL_KEY, PARCEL_SECRET, map);
-		map.put("imgBase64",s);
-		return map;
+		//获取图片的长宽
+		Map<String, Object> imageMap = ImageUtil.getBase64ImageWidthAndHeight(s);
+		//封装数据
+		imageMap.put("imgBase64",s);
+		//返回
+		return imageMap;
 	}
 
 	/**
@@ -410,4 +425,13 @@
 		return null;
 	}
 
+	/**
+	 * 查询当前时间段违禁品总个数
+	 * @param conditionVo
+	 * @return
+	 */
+	@Override
+	public Integer selParcelTimeCount(ConditionVo conditionVo) {
+		return selectParcelCount(conditionVo).get(1);
+	}
 }

--
Gitblit v1.9.3