| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.dataInterchange.api.feignClient.UPWarnMsgAdptInfoClient; |
| | | import com.ruoyi.dataInterchange.api.model.enums.WarnType; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | |
| | | List<Car> carList = carService.list(); |
| | | List<Warn> warns = new ArrayList<>(); |
| | | for (UPWarnMsgAdptInfoVo vo : list) { |
| | | String warnTypeName = WarnType.getWarnTypeName(vo.getWarnType()); |
| | | warn = new Warn(); |
| | | Optional<Car> carOptional = carList.stream().filter(s -> s.getVehicleNumber().equals(vo.getVehicleNo())).findFirst(); |
| | | if (carOptional.isPresent()) { |
| | | warn.setCarId(carOptional.get().getId()); |
| | | Car car = carOptional.get(); |
| | | if(car.getOperateType().equals("出租车") && StringUtils.isNotEmpty(warnTypeName) && "疲劳驾驶报警".equals(warnTypeName)){ |
| | | continue; |
| | | } |
| | | warn.setCarId(car.getId()); |
| | | } |
| | | Optional<Driver> optional = driverList.stream().filter(s -> s.getVehicleNumber().equals(vo.getVehicleNo())).findFirst(); |
| | | if (optional.isPresent()) { |
| | |
| | | warn.setEnterpriseId(enterprise.getId()); |
| | | warn.setStartTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(vo.getCreateTime() * 1000), ZoneOffset.ofHours(8)).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | warn.setEndTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(vo.getCreateTime() * 1000), ZoneOffset.ofHours(8)).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | warn.setWarnType(WarnType.getWarnTypeName(vo.getWarnType())); |
| | | warn.setWarnType(warnTypeName); |
| | | warn.setWarnNumber(1); |
| | | warn.setSpeed(null == vo.getSpeed() ? BigDecimal.ZERO : new BigDecimal(vo.getSpeed())); |
| | | if(null != vo.getLongitude()){ |
| | | if(null != vo.getLongitude() && 0 != vo.getLongitude()){ |
| | | warn.setLongitude(new BigDecimal(vo.getLongitude()).divide(new BigDecimal(1000000)).toString()); |
| | | } |
| | | if(null != vo.getLatitude()){ |
| | | if(null != vo.getLatitude() && 0 != vo.getLatitude()){ |
| | | warn.setLatitude(new BigDecimal(vo.getLatitude()).divide(new BigDecimal(1000000)).toString()); |
| | | } |
| | | Map<String, String> geocode = null; |
| | | try { |
| | | geocode = GDMapGeocodingUtil.geocode(warn.getLongitude(), warn.getLatitude()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | e.printStackTrace(); |
| | | } |
| | | warn.setAddress(geocode.get("address")); |
| | | } |
| | | switch (vo.getResult()) { |
| | | case 0x00: |
| | | warn.setTreatmentState("处理中"); |
| | |
| | | } |
| | | Optional<Car> optional1 = carList.stream().filter(s -> s.getVehicleNumber().equals(warn.getVehicleNumber())).findFirst(); |
| | | if (optional1.isPresent()) { |
| | | Car car = optional1.get(); |
| | | if(car.getOperateType().equals("出租车") && "疲劳驾驶报警".equals(warn.getWarnType())){ |
| | | this.removeById(warn.getId()); |
| | | continue; |
| | | } |
| | | warn.setCarId(optional1.get().getId()); |
| | | this.updateById(warn); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * 获取所有报警数据 |
| | | * @param carWarnListReq |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Warn> getAllCarWarnList(CarWarnListReq carWarnListReq) { |
| | | return this.baseMapper.getAllCarWarnList(carWarnListReq); |
| | | } |
| | | |
| | | /** |
| | | * 获取预警汇总统计最高的10类报警数据 |
| | | * |
| | | * @return |
| | |
| | | } |
| | | if (!collect.isEmpty()) { |
| | | List<Map<String, Object>> warnGroupCount = this.baseMapper.getWarnGroupCount(collect); |
| | | Integer num = Integer.valueOf(warnGroupCount.get(0).get("num").toString()); |
| | | if(num > 0){ |
| | | list.addAll(warnGroupCount); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | |
| | | public List<Map<String, Object>> getWarnGroupCountTop10() { |
| | | return this.baseMapper.getWarnGroupCountTop10(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取根据车辆类型的报警汇总数据 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> getAllWarnGroupVehicleType() { |
| | | List<Map<String, Object>> allWarnGroupVehicleType = this.baseMapper.getAllWarnGroupVehicleType(); |
| | | for (Map<String, Object> map : allWarnGroupVehicleType) { |
| | | Integer total = Integer.valueOf(map.get("total").toString()); |
| | | Integer processed = Integer.valueOf(map.get("processed").toString()); |
| | | if(total == 0){ |
| | | map.put("rate", BigDecimal.ZERO); |
| | | }else{ |
| | | map.put("rate", BigDecimal.valueOf(processed / total * 100).setScale(2, RoundingMode.HALF_EVEN)); |
| | | } |
| | | } |
| | | return allWarnGroupVehicleType; |
| | | } |
| | | } |