| | |
| | | @Service |
| | | @Slf4j |
| | | public class HistorySecondCruiserServiceImpl extends ServiceImpl<HistorySecondCruiserMapper, HistorySecondCruiser> implements HistorySecondCruiserService { |
| | | @Autowired |
| | | private SysDictTypeService sysDictTypeService; |
| | | |
| | | @Autowired |
| | | private HistorySecondCruiserMapper historySecondCruiserMapper; |
| | |
| | | //获取当前时间 |
| | | endTime = DateUtils.getCurDate(DateUtils.yyyy_MM_dd_HH_mm_ss_EN); |
| | | } |
| | | SysDictData list = sysDictTypeService.listOne("ZHC", "dustld"); |
| | | List<HistorySecondCruiser> result = historySecondCruiserMapper.getResult(startTime, endTime); |
| | | |
| | | // |
| | |
| | | // String flyLon1 = dust.get("flyLon").toString(); |
| | | if (latDouble1==latDouble && lonDouble1==lonDouble){ |
| | | Double dustld = Objects.nonNull(dust.get("dustld"))?Double.parseDouble(dust.get("dustld").toString()):0d; |
| | | if(list.getDataValue().contains(",")){ |
| | | List<String> resultStr = Arrays.asList(list.getDataValue().split(",")); |
| | | if(resultStr.size() % 2 ==0){ |
| | | dustld = numAvg(resultStr,BigDecimal.valueOf(dustld)).doubleValue(); |
| | | } |
| | | }else { |
| | | BigDecimal dataValue = Objects.nonNull(list.getDataValue())?BigDecimal.valueOf(Double.parseDouble(list.getDataValue())):BigDecimal.ZERO; |
| | | dustld = BigDecimal.valueOf(dustld).add(dataValue).doubleValue(); |
| | | } |
| | | doubleArrayList.add(dustld); |
| | | break; |
| | | } |
| | |
| | | continue; |
| | | } |
| | | Double ListAva = doubleArrayList.stream() .collect(Collectors.averagingDouble(Double::doubleValue)); |
| | | double rsAvg = new BigDecimal(ListAva/1000).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | double rsAvg = new BigDecimal(ListAva).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | secondCruiserSort.setRoad(string); |
| | | secondCruiserSort.setValue(rsAvg); |
| | | secondCruiserSort.setMac(mac); |
| | |
| | | } |
| | | } |
| | | if (!ObjectUtils.isEmpty(list1)){ |
| | | // log.info(list1.size()+""); |
| | | secondCruiserSortMapper.insertAll(list1); |
| | | } |
| | | |
| | | } |
| | | |
| | | private BigDecimal numAvg(List<String> list , BigDecimal num){ |
| | | int nums = 1; |
| | | for (int i=0;i<list.size();i=i+2){ |
| | | if(num.compareTo(BigDecimal.valueOf(Double.parseDouble(list.get(i))))>= 0 ){ |
| | | return num.add(BigDecimal.valueOf(Double.parseDouble(list.get(i+1)))); |
| | | } |
| | | nums+=2; |
| | | } |
| | | return num; |
| | | } |
| | | } |