| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import io.swagger.models.auth.In; |
| | | import org.springblade.jfpt.alarm.constant.AlarmTimeConstant; |
| | | import org.springblade.jfpt.animalheat.util.ImageUtil; |
| | | import org.springblade.jfpt.parcel.service.ParcelService; |
| | | import org.springblade.jfpt.parcel.util.DateUtils; |
| | |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.springblade.core.tool.utils.DateUtil.now; |
| | | |
| | |
| | | //将所有的违禁包裹编码存起来 |
| | | 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()) { |
| | |
| | | public Integer selParcelTimeCount(ConditionVo conditionVo) { |
| | | return selectParcelCount(conditionVo).get(1); |
| | | } |
| | | |
| | | /** |
| | | *查询当前时间段区间时间违禁品个数 |
| | | * @param conditionVo |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Integer> selParcelTimeDis(ConditionVo conditionVo) { |
| | | ArrayList<List<Object>> objectArrayList = new ArrayList<>(); |
| | | //设置页码数 |
| | | conditionVo.setCurrentPage(1); |
| | | conditionVo.setPageSize(100); |
| | | //获取数据 |
| | | Map<String,Object> result =(Map<String,Object>) getParcelDataPageList(conditionVo, PARCEL_KIND_URL, PARCEL_KEY, PARCEL_SECRET).get("result"); |
| | | if (null!=result) { |
| | | List<Object> dataList = JSONArray.parseArray(result.get("data").toString()); |
| | | objectArrayList.add(dataList); |
| | | //取第一次获取到的数据总数,每次取100条,多于100分批次取 |
| | | int totalSize = Integer.parseInt(result.get("totalSize").toString()); |
| | | int i = totalSize/100+1; |
| | | if (i>1){ |
| | | for (int j=1;j<i;j++) { |
| | | conditionVo.setCurrentPage(j+1); |
| | | //获取数据 |
| | | Map<String,Object> result0 =(Map<String,Object>) getParcelDataPageList(conditionVo, PARCEL_KIND_URL, PARCEL_KEY, PARCEL_SECRET).get("result"); |
| | | List<Object> dataLists = JSONArray.parseArray(result0.get("data").toString()); |
| | | objectArrayList.add(dataLists); |
| | | } |
| | | } |
| | | //合并集合 |
| | | List<Object> collect = objectArrayList.stream().flatMap(List::stream).collect(Collectors.toList()); |
| | | //筛选数据,返回数据 |
| | | return getParcelTimeDis(collect); |
| | | } |
| | | return Arrays.asList(0,0,0,0,0,0,0,0,0,0,0,0); |
| | | } |
| | | |
| | | /** |
| | | * 筛选数据,分类返回 |
| | | * @param collect 集合数据 |
| | | * @return |
| | | */ |
| | | private List<Integer> getParcelTimeDis(List<Object> collect) { |
| | | List<Integer> list = new ArrayList<>(); |
| | | int count02 = 0; |
| | | int count0204 = 0; |
| | | int count0406 = 0; |
| | | int count0608 = 0; |
| | | int count0810 = 0; |
| | | int count1012 = 0; |
| | | int count1214 = 0; |
| | | int count1416 = 0; |
| | | int count1618 = 0; |
| | | int count1820 = 0; |
| | | int count2022 = 0; |
| | | int count2224 = 0; |
| | | //遍历集合 |
| | | for (Object data:collect) { |
| | | Map<String,Object> parcelData =(Map<String,Object>)data; |
| | | try { |
| | | long hours = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(parcelData.get("createTime").toString()).getHours(); |
| | | if (hours>0 && hours< AlarmTimeConstant.TWO){ |
| | | count02+=1; |
| | | } |
| | | if (hours>=AlarmTimeConstant.TWO && hours<AlarmTimeConstant.FOUR){ |
| | | count0204+=1; |
| | | } |
| | | if (hours>=AlarmTimeConstant.FOUR && hours<AlarmTimeConstant.SIX){ |
| | | count0406+=1; |
| | | } |
| | | if (hours>=AlarmTimeConstant.SIX && hours<AlarmTimeConstant.EIGHT){ |
| | | count0608+=1; |
| | | } |
| | | if (hours>=AlarmTimeConstant.EIGHT && hours<AlarmTimeConstant.TEN){ |
| | | count0810+=1; |
| | | } |
| | | if (hours>=AlarmTimeConstant.TEN && hours<AlarmTimeConstant.TWEKVE){ |
| | | count1012+=1; |
| | | } |
| | | if (hours>=AlarmTimeConstant.TWEKVE && hours<AlarmTimeConstant.FOURTEEN){ |
| | | count1214+=1; |
| | | } |
| | | if (hours>=AlarmTimeConstant.FOURTEEN && hours<AlarmTimeConstant.SIXTEEN){ |
| | | count1416+=1; |
| | | } |
| | | if (hours>=AlarmTimeConstant.SIXTEEN && hours<AlarmTimeConstant.EIGHTEEN){ |
| | | count1618+=1; |
| | | } |
| | | if (hours>=AlarmTimeConstant.EIGHTEEN && hours<AlarmTimeConstant.TWENTY){ |
| | | count1820+=1; |
| | | } |
| | | if (hours>=AlarmTimeConstant.TWENTY && hours<AlarmTimeConstant.TWENTY_TWO){ |
| | | count2022+=1; |
| | | } |
| | | if (hours>=AlarmTimeConstant.TWENTY_TWO && hours<AlarmTimeConstant.TWENTY_FOUR){ |
| | | count2224+=1; |
| | | } |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | //封装数据 |
| | | list.add(count02); |
| | | list.add(count0204); |
| | | list.add(count0406); |
| | | list.add(count0608); |
| | | list.add(count0810); |
| | | list.add(count1012); |
| | | list.add(count1214); |
| | | list.add(count1416); |
| | | list.add(count1618); |
| | | list.add(count1820); |
| | | list.add(count2022); |
| | | list.add(count2224); |
| | | //返回数据 |
| | | return list; |
| | | } |
| | | } |