From b3190b020a4d67d88cae9042fd6014fe0b4925d2 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Mon, 15 Mar 2021 09:43:35 +0800
Subject: [PATCH] 包裹统计数据本周数据修改(新增状态status=3本周)

---
 blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/parcel/service/impl/ParcelServiceImpl.java |   52 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 47 insertions(+), 5 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 14bd180..88bc7f7 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
@@ -8,7 +8,11 @@
 import org.springblade.jfpt.parcel.vo.ConditionVo;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
 import java.util.*;
+
+import static org.springblade.core.tool.utils.DateUtil.now;
 
 /**
  * 包裹服务实现层
@@ -40,6 +44,7 @@
 		if (null!=conditionVo.getStatus()) {
 			//获取数据
 			List<Object> objectList = getParcelData(conditionVo,PARCEL_CONTRABAND_URL,PARCEL_KEY,PARCEL_SECRET);
+			System.out.println("objectList = " + objectList);
 			Map<String,String> mapCode = new HashMap<>();
 			//遍历集合,存储所有的违禁包裹编码
 			for (Object object : objectList) {
@@ -59,7 +64,7 @@
 					if (value.equals(objectMap.get("objCode").toString())){
 						count+=Integer.parseInt(objectMap.get("objCount").toString());
 						map.put("name",objectMap.get("objName").toString());
-						map.put("value",objectMap.get("objCount").toString());
+						map.put("value",count);
 					}
 				}
 				list.add(map);
@@ -86,8 +91,8 @@
 			List<String> listTime = new ArrayList<>();
 			List<Map<String,Object>> parcelList = new ArrayList<>();
 			if (conditionVo.getStatus() == 1) {
-				//3.获取本周开始时间和结束时间的每一天数组
-				listTime = DateUtils.pastDay(DateUtils.getWeekEnd());
+				//3.获取今天之前的每一天数组   2021-3-12 arsn修改
+				listTime = DateUtils.pastDay(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
 				List<String> percelTimeList = new ArrayList<>();
 				for (Object object:objectList) {
 					//4.取出list里面的值转为map
@@ -160,9 +165,15 @@
 			startDate = DateUtils.getToday();
 			endDate = DateUtils.getToday();
 		}
-		//2.2查询本周内每天的数据
+		//2.2查询过去6天及当天的的数据
 		if (conditionVo.getStatus() == 1) {
-			//3.获取本周开始时间和结束时间
+			//3.获取过去6天及当天开始时间和结束时间
+			startDate = DateUtils.getPastDate(6,now());
+			endDate = DateUtils.getToday();
+		}
+		//2.4查询本周的数据
+		if (conditionVo.getStatus() == 3) {
+			//3.获取过去6天及当天开始时间和结束时间
 			startDate = DateUtils.getWeekStart();
 			endDate = DateUtils.getWeekEnd();
 		}
@@ -180,4 +191,35 @@
 		Map<String, Object> data = (Map<String, Object>) JSONObject.parse(params);
 		return JSON.parseArray(data.get("result").toString());
 	}
+
+
+	/**
+	 * 查询包裹,违禁品总数
+	 * @param status 状态码 0:本天    1:本周   2:本月
+	 * @return
+	 */
+	@Override
+	public List<Integer> selectParcelCount(Integer status) {
+		List<Integer> list = new ArrayList<>();
+		ConditionVo conditionVo = new ConditionVo();
+		conditionVo.setStatus(status);
+		//获取包裹数据
+		List<Object> parcelData = getParcelData(conditionVo, PARCEL_URL, PARCEL_KEY, PARCEL_SECRET);
+		//查询当天的包裹总数
+		Integer dangerCount = null;
+		Integer contrabandCount = null;
+		if (status == 0) {
+			for (Object object : parcelData) {
+				//取出list里面的值转为map
+				Map<String, Object> objectMap = (Map<String, Object>) object;
+				dangerCount = Integer.parseInt(objectMap.get("dangerCount").toString()); //违禁包裹数量
+				contrabandCount = Integer.parseInt(objectMap.get("contrabandCount").toString()); //违禁物品数量
+			}
+		}
+		//封装数据
+		list.add(dangerCount);
+		list.add(contrabandCount);
+		//返回数据
+		return list;
+	}
 }

--
Gitblit v1.9.3