From d5b43ef0da42eaf50a08ce17e5fd3351eeb26a5e Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Sat, 20 Mar 2021 14:10:19 +0800
Subject: [PATCH] 违禁品筛选条件去除,警情统计接口修改

---
 blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/parcel/service/impl/ParcelServiceImpl.java |  144 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 125 insertions(+), 19 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 8e68cb7..83084f6 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
@@ -1,19 +1,18 @@
 package org.springblade.jfpt.parcel.service.impl;
 
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.alibaba.nacos.common.utils.JacksonUtils;
 import org.springblade.jfpt.parcel.service.ParcelService;
 import org.springblade.jfpt.parcel.util.DateUtils;
 import org.springblade.jfpt.parcel.util.HttpClientUtils;
-import org.springblade.jfpt.parcel.util.JacksonUtil;
 import org.springblade.jfpt.parcel.vo.ConditionVo;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import springfox.documentation.spring.web.json.Json;
 
+import java.text.SimpleDateFormat;
 import java.util.*;
+
+import static org.springblade.core.tool.utils.DateUtil.now;
 
 /**
  * 包裹服务实现层
@@ -35,8 +34,8 @@
 
 
 	/**
-	 * 获取查询条件
-	 * @param conditionVo 查询条件对象
+	 * 获取违禁包裹统计数据,远程调用接口
+	 * @param conditionVo 查询条件对象  status 状态码 0:本天    1:近7天   2:本月  3:本周
 	 * @return
 	 */
 	@Override
@@ -45,16 +44,33 @@
 		if (null!=conditionVo.getStatus()) {
 			//获取数据
 			List<Object> objectList = getParcelData(conditionVo,PARCEL_CONTRABAND_URL,PARCEL_KEY,PARCEL_SECRET);
-			//5.遍历,分别取出数据
+			Map<String,String> mapCode = new HashMap<>();
+			//遍历集合,存储所有的违禁包裹编码
 			for (Object object : objectList) {
-				Map<String, Object> objectMap = (Map<String, Object>) object;//取出list里面的值转为map
-				System.out.println("liMap.get(\"objCode\") = " + objectMap.get("objCode"));
-				System.out.println("liMap.get(\"objCode\") = " + objectMap.get("objCount"));
-				System.out.println("liMap.get(\"objCode\") = " + objectMap.get("dateStr"));
-				System.out.println("liMap.get(\"objCode\") = " + objectMap.get("objName"));
+				//取出list里面的值转为map
+				Map<String, Object> objectMap = (Map<String, Object>) object;
+				//将所有的违禁包裹编码存起来
+				mapCode.put(objectMap.get("objCode").toString(),objectMap.get("objCode").toString());
 			}
+			System.out.println("mapCode = " + mapCode);
+			//遍历违禁编码map数据
+			List<Map<String,Object>> list = new ArrayList<>();
+			for (String value:mapCode.values()) {
+				Integer count = 0;
+				HashMap<String, Object> map = new HashMap<>();
+				for (Object object : objectList) {
+					Map<String, Object> objectMap = (Map<String, Object>) object;//取出list里面的值转为map
+					//将所有的违禁包裹编码存起来
+					if (value.equals(objectMap.get("objCode").toString())){
+						count+=Integer.parseInt(objectMap.get("objCount").toString());
+						map.put("name",objectMap.get("objName").toString());
+						map.put("value",count);
+					}
+				}
+				list.add(map);
+			}
+			return list;
 		}
-
 		return null;
 	}
 
@@ -75,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
@@ -123,6 +139,7 @@
 			//12.封装数据
 			list.add(listTime);
 			list.add(parcelList);
+			list.add(getKindServenDataList());
 			//13.返回
 			return list;
 		}
@@ -149,17 +166,23 @@
 			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();
 		}
 		//2.2查询本月的数据
 		if (conditionVo.getStatus() == 2) {
 			//3.获取本月开始时间和结束时间
-			startDate = DateUtils.getWeekStart();
-			endDate = DateUtils.getWeekEnd();
+			startDate = DateUtils.getMonthStart();
+			endDate = DateUtils.getMonthEnd();
 		}
 		map.put("startDate", startDate);
 		map.put("endDate", endDate);
@@ -167,6 +190,89 @@
 		String params = HttpClientUtils.httpPost(url, key, secret, map);
 		//5.数据转换
 		Map<String, Object> data = (Map<String, Object>) JSONObject.parse(params);
+		//System.out.println("data = " + data);
 		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;
+	}
+
+	/**
+	 * 查询7天内违禁品每天的数量(需筛选危险品)
+	 * @return
+	 */
+	@Override
+	public Map<String, Object> selectParcelData() {
+		HashMap<String, Object> map = new HashMap<>();
+		map.put("parcelData",getKindServenDataList());
+		return map;
+	}
+
+	/**
+	 * 获取危险违禁品7天内每天的数量集合
+	 * @return
+	 */
+	public List<Integer> getKindServenDataList(){
+		ConditionVo conditionVo = new ConditionVo();
+		conditionVo.setStatus(1);//近7天status 为 1
+		//获取数据
+		List<Object> objectList = getParcelData(conditionVo,PARCEL_CONTRABAND_URL,PARCEL_KEY,PARCEL_SECRET);
+		//遍历违禁编码map数据
+		List<String> times = DateUtils.pastDay(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
+		List<Integer> list = new ArrayList<>();
+		for (String time:times) {
+			Integer count = 0;
+			//遍历集合数据获取每一天的count
+			for (Object object : objectList) {
+				Map<String, Object> objectMap = (Map<String, Object>) object;//取出list里面的值转为map
+				//对比时间和objCode,危险品,刀具,枪支等
+				if (time.equals(objectMap.get("dateStr").toString()) ){
+//					//枪支
+//					if (objectMap.get("objCode").toString().equals("gan")) {
+//						count += Integer.parseInt(objectMap.get("objCount").toString());
+//					}
+//					//刀具
+//					if (objectMap.get("objCode").toString().equals("knife")) {
+//						count += Integer.parseInt(objectMap.get("objCount").toString());
+//					}
+//					//爆炸物
+//					if (objectMap.get("objCode").toString().equals("boomExplosive")) {
+//						count += Integer.parseInt(objectMap.get("objCount").toString());
+//					}
+					//3-20 修改不筛选危险品,由第三方筛选好
+					count += Integer.parseInt(objectMap.get("objCount").toString());
+				}
+			}
+			list.add(count);
+		}
+		return list;
+	}
 }

--
Gitblit v1.9.3