| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | import com.doumee.core.haikang.model.cars.BaseCarsPageResponse; |
| | | import com.doumee.core.haikang.model.cars.BaseCarsResponse; |
| | | import com.doumee.core.haikang.model.cars.request.CarsAlarmListRequest; |
| | | import com.doumee.core.haikang.model.cars.request.CarsDeviceRequest; |
| | | import com.doumee.core.haikang.model.cars.request.CarsGpsRequest; |
| | | import com.doumee.core.haikang.model.cars.response.CarsDeviceDetaisResponse; |
| | | import com.doumee.core.haikang.model.cars.response.CarsDeviceResponse; |
| | | import com.doumee.core.haikang.model.cars.response.CarsGpsResponse; |
| | | import com.doumee.core.haikang.model.cars.response.*; |
| | | import com.doumee.core.haikang.model.param.BaseListPageResponse; |
| | | import com.doumee.core.haikang.model.param.BaseResponse; |
| | | import com.doumee.core.haikang.model.param.respose.FindHomeAlarmInfoPageResponse; |
| | |
| | | } |
| | | return list; |
| | | } |
| | | public static List<CarsAlarmResultListResponse> getAlarmEvemtList(List<CarsDeviceDetaisResponse> detaisResponses , Date date) { |
| | | List<CarsAlarmResultListResponse> list = new ArrayList<>(); |
| | | if(detaisResponses ==null || detaisResponses.size()==0){ |
| | | return list ; |
| | | } |
| | | CarsAlarmListRequest param = new CarsAlarmListRequest(); |
| | | param.setStartTime(DateUtil.getPlusTime2(DateUtil.getStartOfDay(date))); |
| | | param.setEndTime(DateUtil.getPlusTime2(DateUtil.getEndOfDay(date))); |
| | | param.setPageNo(1); |
| | | param.setPageSize(100); |
| | | for( CarsDeviceDetaisResponse de :detaisResponses ){ |
| | | param.setDeviceCode(de.getTerminalID()); |
| | | BaseCarsPageResponse<CarsAlarmListResponse> data = getAlarmList(param); |
| | | if(data!=null &&data.getResults()!=null){ |
| | | for(CarsAlarmListResponse model :data.getResults()){ |
| | | CarsAlarmResultListResponse tm = new CarsAlarmResultListResponse(); |
| | | tm.setTime(model.getTime()); |
| | | tm.setCarCode(de.getPlateNum()); |
| | | tm.setType(model.getType()); |
| | | tm.setSubType(model.getSubType()); |
| | | Date tmDate = DateUtil.fromStringToDate("yyyy-MM-dd HH:mm:ss", tm.getTime() ); |
| | | if(tmDate!=null){ |
| | | tm.setTimeStamp(tmDate.getTime()); |
| | | } |
| | | tm.setTitle(HKConstants.CarsEventType.getName(tm.getType(),tm.getSubType())); |
| | | list.add(tm); |
| | | } |
| | | } |
| | | } |
| | | Collections.sort(list, (o1, o2) -> { |
| | | return (int) (o1.getTimeStamp() - o2.getTimeStamp()); //按数量从大到小排序 |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | private static CarsDeviceDetaisResponse getFromListById(String key, List<CarsDeviceDetaisResponse> list) { |
| | | for(CarsDeviceDetaisResponse dd :list){ |
| | |
| | | String url = BASE_URL + "device/list/"; |
| | | TreeMap<String, String> BASE_PARAMS = getBaseParams(); |
| | | if(StringUtils.isNotBlank(param.getProductKey())){ |
| | | BASE_PARAMS.put("productKey", "");//设备型号秘钥 |
| | | BASE_PARAMS.put("productKey", param.getProductKey());//设备型号秘钥 |
| | | } |
| | | BASE_PARAMS.put("pageSize",Constants.equalsInteger(param.getPageSize(),0)? "100":param.getPageSize().toString());//页面大小 |
| | | BASE_PARAMS.put("pageNo", Constants.equalsInteger(param.getPageNo(),0)? "1":param.getPageNo().toString());//当前页 |
| | |
| | | } |
| | | return null; |
| | | } |
| | | public static BaseCarsPageResponse<CarsAlarmListResponse> getAlarmList(CarsAlarmListRequest param) { |
| | | String url = BASE_URL + "alarm/list/"; |
| | | TreeMap<String, String> BASE_PARAMS = getBaseParams(); |
| | | if(StringUtils.isNotBlank(param.getStartTime())){ |
| | | BASE_PARAMS.put("startTime", param.getStartTime()); |
| | | } |
| | | if(StringUtils.isNotBlank(param.getEndTime())){ |
| | | BASE_PARAMS.put("endTime", param.getEndTime()); |
| | | } |
| | | BASE_PARAMS.put("deviceCode", param.getDeviceCode()); |
| | | BASE_PARAMS.put("pageSize",Constants.equalsInteger(param.getPageSize(),0)? "100":param.getPageSize().toString());//页面大小 |
| | | BASE_PARAMS.put("pageNo", Constants.equalsInteger(param.getPageNo(),0)? "1":param.getPageNo().toString());//当前页 |
| | | String str = sendRequest(url,BASE_PARAMS); |
| | | TypeReference typeReference = |
| | | new TypeReference<BaseCarsResponse<BaseCarsPageResponse<CarsAlarmListResponse>>>(){}; |
| | | BaseCarsResponse<BaseCarsPageResponse<CarsAlarmListResponse>> result = JSONObject.parseObject(str, typeReference.getType()); |
| | | if(result!=null && Constants.equalsInteger(result.getStatus(),0)){ |
| | | return result.getData(); |
| | | } |
| | | return null; |
| | | } |
| | | } |