| | |
| | | |
| | | /** |
| | | * 获取违禁包裹统计数据,远程调用接口 |
| | | * @param conditionVo 查询条件对象 status 状态码 0:本天 1:本周 2:本月 |
| | | * @param conditionVo 查询条件对象 status 状态码 0:本天 1:近7天 2:本月 3:本周 |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | 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) { |
| | |
| | | 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); |
| | |
| | | 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.获取本月开始时间和结束时间 |
| | |
| | | //获取包裹数据 |
| | | List<Object> parcelData = getParcelData(conditionVo, PARCEL_URL, PARCEL_KEY, PARCEL_SECRET); |
| | | //查询当天的包裹总数 |
| | | Integer checkCount = null; |
| | | Integer dangerCount = null; |
| | | Integer contrabandCount = null; |
| | | if (status == 0) { |
| | | for (Object object : parcelData) { |
| | | //取出list里面的值转为map |
| | | Map<String, Object> objectMap = (Map<String, Object>) object; |
| | | checkCount = Integer.parseInt(objectMap.get("checkCount").toString()); //安检包裹数量 |
| | | dangerCount = Integer.parseInt(objectMap.get("dangerCount").toString()); //违禁包裹数量 |
| | | contrabandCount = Integer.parseInt(objectMap.get("contrabandCount").toString()); //违禁物品数量 |
| | | } |
| | | } |
| | | //封装数据 |
| | | list.add(checkCount); |
| | | list.add(dangerCount); |
| | | list.add(contrabandCount); |
| | | //返回数据 |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 查询7天内违禁品每天的数量(需筛选危险品) |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Map<String, Object> selectParcelData() { |
| | | ConditionVo conditionVo = new ConditionVo(); |
| | | conditionVo.setStatus(1);//近7天status 为 1 |
| | | //获取数据 |
| | | List<Object> objectList = getParcelData(conditionVo,PARCEL_CONTRABAND_URL,PARCEL_KEY,PARCEL_SECRET); |
| | | //遍历违禁编码map数据 |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | 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()); |
| | | } |
| | | } |
| | | } |
| | | list.add(count); |
| | | } |
| | | map.put("parcelData",list); |
| | | return map; |
| | | } |
| | | } |