From ba0f00cf00c2a5c693e9608a56d1f7d032f5e216 Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Tue, 23 Mar 2021 19:19:17 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/parcel/service/impl/ParcelServiceImpl.java |  315 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 233 insertions(+), 82 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 83084f6..a259baf 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,10 +1,14 @@
 package org.springblade.jfpt.parcel.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import io.swagger.models.auth.In;
 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.util.PageList;
 import org.springblade.jfpt.parcel.vo.ConditionVo;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -30,6 +34,12 @@
 
 	@Value("${PARCEL_URL}")
 	private String PARCEL_URL;
+
+	@Value("${PARCEL_PICTURE_URL}")
+	private String PARCEL_PICTURE_URL;
+
+	@Value("${PARCEL_DETAIL_RUL}")
+	private String PARCEL_DETAIL_RUL;
 
 
 
@@ -83,65 +93,66 @@
 	public Object getParcelStatis(ConditionVo conditionVo) {
 		List<Object> list = new ArrayList<>();//返回
 		//1.判空
-		if (null!=conditionVo.getStatus()){
+		if (null!=conditionVo.getStatus()) {
 			//2.获取数据
-			List<Object> objectList = getParcelData(conditionVo,PARCEL_URL,PARCEL_KEY,PARCEL_SECRET);
-			System.out.println("objectList = " + objectList);
-			//3.创建时间集合,包裹集合数据
-			List<String> listTime = new ArrayList<>();
-			List<Map<String,Object>> parcelList = new ArrayList<>();
-			if (conditionVo.getStatus() == 1) {
-				//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
-					Map<String, Object> objectMap = (Map<String, Object>) object;
-					//5.将远程时间数据存入集合
-					percelTimeList.add(objectMap.get("dateStr").toString());
-				}
-				for (String time:listTime) {
-					//6.创建map,用于存储包裹数据
-					HashMap<String, Object> hashMap = new HashMap<>();
-					//7.如果远程数据哪天数据没有,则为0
-					if (!percelTimeList.contains(time)){
-						hashMap.put("dateStr",time);
-						hashMap.put("checkCount",0);
-						hashMap.put("dangerCount",0);
-						parcelList.add(hashMap);
-					}else {
-						//8.遍历,分别取出数据
-						for (Object object : objectList) {
-							//9.取出list里面的值转为map
-							Map<String, Object> objectMap = (Map<String, Object>) object;
-							String dateStr = objectMap.get("dateStr").toString();  //安检时间
-							Integer checkCount = Integer.parseInt(objectMap.get("checkCount").toString()); //安检包裹数量
-							Integer dangerCount = Integer.parseInt(objectMap.get("dangerCount").toString()); //违禁包裹数量
-							//10.判断,存入数据
-							if (time.equals(dateStr)) {
-								Set<Map.Entry<String, Object>> entries = objectMap.entrySet();
-								for (Map.Entry<String, Object> m : entries) {
-									if (m.getKey().equals("checkCount")) {
-										hashMap.put("checkCount", checkCount);
-										hashMap.put("dateStr", dateStr);
-									}
-									if (m.getKey().equals("dangerCount")) {
-										hashMap.put("dangerCount", dangerCount);
+			List<Object> objectList = getParcelData(conditionVo, PARCEL_URL, PARCEL_KEY, PARCEL_SECRET);
+			if (null != objectList) {
+				//3.创建时间集合,包裹集合数据
+				List<String> listTime = new ArrayList<>();
+				List<Map<String, Object>> parcelList = new ArrayList<>();
+				if (conditionVo.getStatus() == 1) {
+					//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
+						Map<String, Object> objectMap = (Map<String, Object>) object;
+						//5.将远程时间数据存入集合
+						percelTimeList.add(objectMap.get("dateStr").toString());
+					}
+					for (String time : listTime) {
+						//6.创建map,用于存储包裹数据
+						HashMap<String, Object> hashMap = new HashMap<>();
+						//7.如果远程数据哪天数据没有,则为0
+						if (!percelTimeList.contains(time)) {
+							hashMap.put("dateStr", time);
+							hashMap.put("checkCount", 0);
+							hashMap.put("dangerCount", 0);
+							parcelList.add(hashMap);
+						} else {
+							//8.遍历,分别取出数据
+							for (Object object : objectList) {
+								//9.取出list里面的值转为map
+								Map<String, Object> objectMap = (Map<String, Object>) object;
+								String dateStr = objectMap.get("dateStr").toString();  //安检时间
+								Integer checkCount = Integer.parseInt(objectMap.get("checkCount").toString()); //安检包裹数量
+								Integer dangerCount = Integer.parseInt(objectMap.get("dangerCount").toString()); //违禁包裹数量
+								//10.判断,存入数据
+								if (time.equals(dateStr)) {
+									Set<Map.Entry<String, Object>> entries = objectMap.entrySet();
+									for (Map.Entry<String, Object> m : entries) {
+										if (m.getKey().equals("checkCount")) {
+											hashMap.put("checkCount", checkCount);
+											hashMap.put("dateStr", dateStr);
+										}
+										if (m.getKey().equals("dangerCount")) {
+											hashMap.put("dangerCount", dangerCount);
+										}
 									}
 								}
 							}
+							//11.加入到集合中
+							parcelList.add(hashMap);
 						}
-						//11.加入到集合中
-						parcelList.add(hashMap);
 					}
 				}
+				//12.封装数据
+				list.add(listTime);
+				list.add(parcelList);
+				list.add(getKindServenDataList());
+				//13.返回
+				return list;
 			}
-			//12.封装数据
-			list.add(listTime);
-			list.add(parcelList);
-			list.add(getKindServenDataList());
-			//13.返回
-			return list;
 		}
 		return null;
 	}
@@ -157,7 +168,7 @@
 	 */
 	private List<Object> getParcelData(ConditionVo conditionVo, String url, String key, String secret) {
 		//1.创建map对象,用于存储请求接口的秘钥
-		Map<String, String> map = new HashMap<>();
+		Map<String, Object> map = new HashMap<>();
 		String startDate = null;
 		String endDate = null;
 		//2.2查询本天的数据
@@ -190,8 +201,11 @@
 		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());
+		if (data.get("succ").toString().equals("ok")){
+			//6.返回数据
+			return JSON.parseArray(data.get("result").toString());
+		}
+		return null;
 	}
 
 
@@ -207,22 +221,25 @@
 		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()); //违禁物品数量
+		if (null!=parcelData) {
+			//查询当天的包裹总数
+			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;
 		}
-		//封装数据
-		list.add(dangerCount);
-		list.add(contrabandCount);
-		//返回数据
-		return list;
+		return null;
 	}
 
 	/**
@@ -245,16 +262,17 @@
 		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 (null!=objectList) {
+			//遍历违禁编码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());
@@ -267,12 +285,145 @@
 //					if (objectMap.get("objCode").toString().equals("boomExplosive")) {
 //						count += Integer.parseInt(objectMap.get("objCount").toString());
 //					}
-					//3-20 修改不筛选危险品,由第三方筛选好
-					count += Integer.parseInt(objectMap.get("objCount").toString());
+						//3-20 修改不筛选危险品,由第三方筛选好
+						count += Integer.parseInt(objectMap.get("objCount").toString());
+					}
+				}
+				list.add(count);
+			}
+			return list;
+		}
+		return null;
+	}
+
+	/**
+	 * 获取图片地址
+	 * @param imgUrl 图片Url
+	 * @return
+	 */
+	@Override
+	public Map<String, String> getParcelPic(String imgUrl) {
+		//截取图片imgKey信息
+		String[] imgKeys = imgUrl.split("=", imgUrl.length());
+		String imgKey = imgKeys[1];
+		//封装成map对象
+		HashMap<String, String> map = new HashMap<>();
+		map.put("imgKey",imgKey);
+		//执行http远程调用
+		String s = HttpClientUtils.doGetHeaderPictureBase64(PARCEL_PICTURE_URL, PARCEL_KEY, PARCEL_SECRET, map);
+		map.put("imgBase64",s);
+		return map;
+	}
+
+	/**
+	 * 获取包裹明细分页数据,远程调用api获取数据
+	 * @param conditionVo  请求参数对象
+	 * @return
+	 */
+	@Override
+	public Object getParcelDetailPage(ConditionVo conditionVo) {
+		String result = getParcelDataPageList(conditionVo, PARCEL_DETAIL_RUL, PARCEL_KEY, PARCEL_SECRET).get("result").toString();
+		if (null!=result) {
+			return JSONObject.parse(result);
+		}
+		return null;
+	}
+
+
+	/**
+	 * 获取包裹违禁品明细分页数据,远程调用api获取数据
+	 * @param conditionVo  请求参数对象
+	 * @return
+	 */
+	@Override
+	public Object getParcelkindDetailPage(ConditionVo conditionVo) {
+		conditionVo.setDecisioDiagramResult("contraband");
+		Map<Object, Object> map = new HashMap<>();
+		List<Object> list = new ArrayList<>();
+		//获取违禁包裹数据
+		Map<String,Object> result = (Map<String,Object>)getParcelDataPageList(conditionVo, PARCEL_DETAIL_RUL, PARCEL_KEY, PARCEL_SECRET).get("result");
+		if (null!=result) {
+			//获取总违禁包裹数量
+			Integer totalSize = Integer.parseInt(result.get("totalSize").toString());
+			int total = totalSize/conditionVo.getCurrentPage() +1 ;
+			for (int i = 0;i<total;i++){
+				conditionVo.setCurrentPage(i+1);
+				//获取违禁包裹数据
+				Map<String,Object> resultData = (Map<String,Object>)getParcelDataPageList(conditionVo, PARCEL_DETAIL_RUL, PARCEL_KEY, PARCEL_SECRET).get("result");
+				//提取违禁品数据
+				List<Object> dataList = JSON.parseArray(resultData.get("data").toString());
+				for (Object data : dataList) {
+					//取出list里面的值转为map
+					Map<String, Object> objectMap = (Map<String, Object>) data;
+					//获取违禁包裹名称,包裹Id,包裹图片,过机时间
+					String checkMachineName = objectMap.get("checkMachineName").toString();
+					String packageId = objectMap.get("packageId").toString();
+					String imgUrl = objectMap.get("imgUrl").toString();
+					String samplingTime = objectMap.get("samplingTime").toString();
+					//获取违禁品集合数据
+					List<Object> detailVoList = JSON.parseArray(objectMap.get("coordsDetailVoList").toString());
+					//遍历违禁品集合数据
+					for (Object detailVo : detailVoList) {
+						//封装违禁包裹信息
+						Map<String, Object> detailVoMap = (Map<String, Object>) detailVo;
+						detailVoMap.put("checkMachineName", checkMachineName);
+						detailVoMap.put("packageId", packageId);
+						detailVoMap.put("imgUrl", imgUrl);
+						detailVoMap.put("samplingTime", samplingTime);
+						list.add(detailVoMap);
+					}
 				}
 			}
-			list.add(count);
+			//对组装好的违禁品集合数据排序,按时间
+			//分页
+			List<Object> listPaging = PageList.getListPaging(list, conditionVo.getCurrentPage(), conditionVo.getPageSize());
+			//封装数据
+			map.put("totalSize", list.size());
+			map.put("data", listPaging);
+			map.put("currentPage", conditionVo.getCurrentPage());
+			map.put("pageSize", conditionVo.getPageSize());
+			//返回数据
+			return map;
 		}
-		return list;
+		return null;
 	}
+
+	/**
+	 * 远程调用api 获取违禁品详细数据
+	 * @param conditionVo 条件
+	 * @param url 违禁品详细数据Url
+	 * @param key key
+	 * @param secret 秘钥
+	 * @return
+	 */
+	public Map<String,Object> getParcelDataPageList(ConditionVo conditionVo, String url, String key, String secret){
+		//1.创建map对象存储数据
+		HashMap<String, Object> map = new HashMap<>();
+		//2.条件判断
+		if (null!=conditionVo.getStartTime()){
+			map.put("startTime", conditionVo.getStartTime());
+		}
+		if (null!=conditionVo.getEndTime()){
+			map.put("endTime", conditionVo.getEndTime());
+		}
+		if (null!=conditionVo.getDecisioDiagramResult()){
+			map.put("decisioDiagramResult", conditionVo.getDecisioDiagramResult());
+		}
+		if (null!=conditionVo.getCurrentPage()){
+			map.put("currentPage", conditionVo.getCurrentPage());
+		}
+		if (null!=conditionVo.getPageSize()){
+			map.put("pageSize", conditionVo.getPageSize());
+		}
+		//3.远程调用api 获取数据
+		String params = HttpClientUtils.httpPost(PARCEL_DETAIL_RUL, PARCEL_KEY, PARCEL_SECRET, map);
+		Map<String,Object> paramsMap = (Map<String, Object>) JSONObject.parse(params);
+		if (paramsMap.get("succ").toString().equals("ok")){
+			//4返回数据
+			return paramsMap;
+		}
+		//4返回数据
+		return null;
+	}
+
 }

--
Gitblit v1.9.3