| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | |
| | | import com.moral.api.entity.HistorySecondCruiser; |
| | | import com.moral.api.entity.Organization; |
| | | import com.moral.api.entity.SpecialDevice; |
| | | import com.moral.api.entity.SpecialDeviceHistory; |
| | | import com.moral.api.entity.TbDaily; |
| | | import com.moral.api.entity.*; |
| | | import com.moral.api.mapper.DailyMapper; |
| | | import com.moral.api.mapper.HistorySecondCruiserMapper; |
| | | import com.moral.api.mapper.SpecialDeviceMapper; |
| | | import com.moral.api.mapper.SysDictTypeMapper; |
| | | import com.moral.api.pojo.bo.ExcelBO; |
| | | import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserListDTO; |
| | | import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultCountDTO; |
| | | import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultDTO; |
| | | import com.moral.api.pojo.enums.SysDictTypeEnum; |
| | | import com.moral.api.pojo.vo.excel.DailyVo; |
| | | import com.moral.api.service.OrganizationService; |
| | | import com.moral.api.service.SpecialDeviceHistoryService; |
| | | import com.moral.api.service.SpecialDeviceService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.service.SysDictTypeService; |
| | | import com.moral.constant.Constants; |
| | | |
| | | import com.moral.util.AmendUtils; |
| | |
| | | |
| | | @Autowired |
| | | private HistorySecondCruiserMapper HistorySecondCruiserMapper; |
| | | |
| | | @Autowired |
| | | private SysDictTypeService sysDictTypeService; |
| | | |
| | | @Autowired |
| | | private SpecialDeviceHistoryService specialDeviceHistoryService; |
| | |
| | | @Override |
| | | public List<HistorySecondCruiserResultDTO> carTrajectoryNewAvg(Map<String, Object> params) { |
| | | double range = Double.valueOf(params.get("range").toString()); |
| | | String type = params.get("type").toString(); |
| | | params.put("dateFormat", "%Y-%m-%d %H:%i:%s"); |
| | | Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo(); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization"); |
| | | Integer orgId = (Integer) orgInfo.get("id"); |
| | | params.put("orgId", orgId); |
| | | params.put("type","$."+params.get("type")); |
| | | params.put("type","$."+type); |
| | | //从秒数据表获取走航车数据 |
| | | List<HistorySecondCruiserListDTO> data = HistorySecondCruiserMapper.getCruiserDataNewAvg(params); |
| | | data.removeIf(o->{ |
| | |
| | | if(CollectionUtils.isEmpty(data)){ |
| | | return null; |
| | | } |
| | | return filterDataNew(data,range); |
| | | List<HistorySecondCruiserResultDTO> result = filterDataNew(data,range); |
| | | if(CollectionUtils.isNotEmpty(result)){ |
| | | SysDictData list = sysDictTypeService.listOne(SysDictTypeEnum.SYS_SECOND_CRUISER.getValue(),type); |
| | | if(list.getDataValue().contains(",")){ |
| | | List<String> resultStr = Arrays.asList(list.getDataValue().split(",")); |
| | | if(resultStr.size() % 2 ==0){ |
| | | result.forEach(it->{ |
| | | it.setAvgNum(numAvg(resultStr,it.getAvgNum())); |
| | | }); |
| | | } |
| | | }else { |
| | | BigDecimal dataValue = Objects.nonNull(list.getDataValue())?BigDecimal.valueOf(Integer.parseInt(list.getDataValue())):BigDecimal.ZERO; |
| | | result.forEach(it->{ |
| | | it.setAvgNum(it.getAvgNum().add(dataValue)); |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | 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(Integer.parseInt(list.get(i))))>= 0 ){ |
| | | return num.add(BigDecimal.valueOf(Integer.parseInt(list.get(nums)))); |
| | | } |
| | | nums+=2; |
| | | } |
| | | return num; |
| | | } |
| | | |
| | | @Override |
| | | public SpecialDevice getSpecialDeviceMapByMac(String mac) { |
| | | QueryWrapper<SpecialDevice> queryWrapper = new QueryWrapper(); |