| | |
| | | import com.alibaba.fastjson.JSON; |
| | | 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.config.Interceptor.UserHelper; |
| | | 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.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.device.AppDeviceVo; |
| | | import com.moral.api.pojo.vo.excel.DailyVo; |
| | | import com.moral.api.pojo.vo.user.QxUser; |
| | | 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.SysAreaService; |
| | | import com.moral.api.service.SysDictTypeService; |
| | | import com.moral.constant.Constants; |
| | | |
| | | import com.moral.util.AmendUtils; |
| | |
| | | import com.moral.util.FileUtils; |
| | | import com.moral.util.GeodesyUtils; |
| | | import com.moral.util.TokenUtils; |
| | | |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | |
| | | private HistorySecondCruiserMapper HistorySecondCruiserMapper; |
| | | |
| | | @Autowired |
| | | private SysDictTypeService sysDictTypeService; |
| | | |
| | | @Autowired |
| | | private SpecialDeviceHistoryService specialDeviceHistoryService; |
| | | |
| | | @Autowired |
| | |
| | | @Autowired |
| | | RedisTemplate redisTemplate; |
| | | |
| | | @Autowired |
| | | private SysAreaService sysAreaService; |
| | | |
| | | private final static Double dis = 50d; |
| | | |
| | | |
| | |
| | | //获取当前用户信息 |
| | | Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo(); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization"); |
| | | Integer userId = (Integer) userInfo.get("userId"); |
| | | List<Integer> integerList = new ArrayList<>(); |
| | | SysDictData listSys = sysDictTypeService.listOne(SysDictTypeEnum.SYS_SECOND_CRUISER_RANGE.getValue(),userId.toString()); |
| | | if(listSys.getDataValue().contains(",")){ |
| | | List<Integer> resultStr = Arrays.asList(listSys.getDataValue().split(",")).stream().map(Integer::parseInt).collect(Collectors.toList()); |
| | | integerList.addAll(resultStr); |
| | | }else { |
| | | Integer dataValue = Objects.nonNull(listSys.getDataValue())?Integer.parseInt(listSys.getDataValue()):0; |
| | | integerList.add(dataValue); |
| | | } |
| | | Integer orgId = (Integer) orgInfo.get("id"); |
| | | //获取所有子组织 |
| | | List<Organization> organizations = organizationService.getChildrenOrganizationsById(orgId); |
| | | List<Integer> orgIds = organizations.stream().map(Organization::getId).collect(Collectors.toList()); |
| | | orgIds.add(orgId); |
| | | integerList.addAll(orgIds); |
| | | QueryWrapper<SpecialDeviceHistory> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("mac", "name") |
| | | queryWrapper.select("DISTINCT mac, name").lambda(); |
| | | |
| | | //.eq("special_type", Constants.SPECIAL_DEVICE_CRUISER) |
| | | .eq("is_delete", Constants.NOT_DELETE) |
| | | .in("organization_id", orgIds); |
| | | queryWrapper.eq("is_delete", Constants.NOT_DELETE) |
| | | .in("organization_id", integerList); |
| | | return specialDeviceHistoryService.listMaps(queryWrapper); |
| | | } |
| | | |
| | |
| | | if (lon < 70 || lon > 150 || lat < 20 || lat > 60) { |
| | | return true; |
| | | } |
| | | if(type){ |
| | | o.putAll(value); |
| | | }else { |
| | | |
| | | } |
| | | |
| | | o.putAll(value); |
| | | return false; |
| | | }); |
| | | /*for (Map<String, Object> map:data) { |
| | |
| | | @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(); |
| | | Integer userId = (Integer) userInfo.get("userId"); |
| | | 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")); |
| | | List<Integer> integerList = new ArrayList<>(); |
| | | SysDictData listSys = sysDictTypeService.listOne(SysDictTypeEnum.SYS_SECOND_CRUISER_RANGE.getValue(),userId.toString()); |
| | | if(listSys.getDataValue().contains(",")){ |
| | | List<Integer> resultStr = Arrays.asList(listSys.getDataValue().split(",")).stream().map(Integer::parseInt).collect(Collectors.toList()); |
| | | integerList.addAll(resultStr); |
| | | }else { |
| | | Integer dataValue = Objects.nonNull(listSys.getDataValue())?Integer.parseInt(listSys.getDataValue()):0; |
| | | integerList.add(dataValue); |
| | | } |
| | | integerList.add(orgId); |
| | | params.put("orgIds", integerList); |
| | | 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(Double.parseDouble(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(Double.parseDouble(list.get(i))))>= 0 ){ |
| | | return num.add(BigDecimal.valueOf(Double.parseDouble(list.get(i+1)))); |
| | | } |
| | | nums+=2; |
| | | } |
| | | return num; |
| | | } |
| | | |
| | | @Override |
| | | public SpecialDevice getSpecialDeviceMapByMac(String mac) { |
| | | QueryWrapper<SpecialDevice> queryWrapper = new QueryWrapper(); |
| | |
| | | String time2 = params.get("time2").toString(); |
| | | String rsTime = getTime(time1, time2); |
| | | list.add(rsTime); |
| | | List<Map<String, Object>> maps = specialDeviceService.carTrajectory(params,false); |
| | | // List<Map<String, Object>> maps = specialDeviceService.carTrajectory(params,false); |
| | | // List<Map<String, Object>> maps = HistorySecondCruiserMapper.getCruiserData(params); |
| | | List<Map<String, Object>> maps = HistorySecondCruiserMapper.getAllCruiserData(params); |
| | | |
| | | if (ObjectUtils.isEmpty(maps)){ |
| | | return null; |
| | | } |
| | |
| | | map.put("time1",time3); |
| | | map.put("time2",time4); |
| | | map.put("mac",mac); |
| | | List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false); |
| | | // List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false); |
| | | List<Map<String, Object>> maps1 = HistorySecondCruiserMapper.getAllCruiserData(params); |
| | | if (ObjectUtils.isEmpty(maps1)){ |
| | | return null; |
| | | } |
| | |
| | | map.put("time1",time5); |
| | | map.put("time2",time6); |
| | | map.put("mac",mac); |
| | | List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false); |
| | | // List<Map<String, Object>> maps1 = specialDeviceService.carTrajectory(map,false); |
| | | List<Map<String, Object>> maps1 = HistorySecondCruiserMapper.getAllCruiserData(params); |
| | | if (ObjectUtils.isEmpty(maps1)){ |
| | | return null; |
| | | } |
| | |
| | | String type = params.get("type").toString(); |
| | | String code = params.get("code").toString(); |
| | | String area = params.get("area").toString(); |
| | | String mac = params.get("mac").toString(); |
| | | rsMap.put("area",area); |
| | | rsMap.put("mac",mac.substring(9)); |
| | | String value = JSON.toJSONString(rsMap); |
| | | |
| | | String mac = params.get("mac").toString(); |
| | | QueryWrapper<TbDaily> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("mac",mac); |
| | | queryWrapper.likeRight("time",time1.substring(0,10)); |
| | |
| | | |
| | | /** |
| | | * 下载走航车日报 |
| | | * @param id |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public DailyVo loadDaily(Integer id) { |
| | | ArrayList<String> rsList = new ArrayList<>(); |
| | | DailyVo dailyVo = new DailyVo(); |
| | | TbDaily tbDaily = dailyMapper.selectById(id); |
| | | if (tbDaily==null){ |
| | | return null; |
| | | public List<DailyVo> loadDaily(List<Integer> ids) { |
| | | ArrayList<DailyVo> dailyVos = new ArrayList<>(); |
| | | for (Integer id : ids) { |
| | | ArrayList<String> rsList = new ArrayList<>(); |
| | | DailyVo dailyVo = new DailyVo(); |
| | | TbDaily tbDaily = dailyMapper.selectById(id); |
| | | |
| | | SysArea areaByCode = sysAreaService.getAreaByCode(Integer.parseInt(tbDaily.getCode())); |
| | | if (tbDaily==null){ |
| | | continue; |
| | | } |
| | | String images = tbDaily.getImages(); |
| | | if (!ObjectUtils.isEmpty(images)){ |
| | | String[] split = images.split(","); |
| | | List<String> list1 = Arrays.asList(split); |
| | | dailyVo.setImages(list1); |
| | | }else { |
| | | dailyVo.setImages(rsList); |
| | | } |
| | | String value = tbDaily.getValue(); |
| | | Map map = JSON.parseObject(value, Map.class); |
| | | List<String> list = (List<String>) map.get("time"); |
| | | String join = String.join("-", list); |
| | | map.put("time",join); |
| | | dailyVo.setCode(map); |
| | | dailyVo.setName(areaByCode.getAreaName()); |
| | | dailyVo.setType(tbDaily.getType().equals("car")?"走航车":"无人机"); |
| | | dailyVos.add(dailyVo); |
| | | } |
| | | String images = tbDaily.getImages(); |
| | | if (!ObjectUtils.isEmpty(images)){ |
| | | String[] split = images.split(","); |
| | | List<String> list1 = Arrays.asList(split); |
| | | dailyVo.setImages(list1); |
| | | }else { |
| | | dailyVo.setImages(rsList); |
| | | } |
| | | String value = tbDaily.getValue(); |
| | | Map map = JSON.parseObject(value, Map.class); |
| | | dailyVo.setCode(map); |
| | | return dailyVo; |
| | | return dailyVos; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | Object mac = params.get("mac"); |
| | | if (!ObjectUtils.isEmpty(mac)){ |
| | | String MAC = mac.toString(); |
| | | String[] split = mac.toString().split(","); |
| | | List<String> list = Arrays.asList(split); |
| | | List<String> macList = new ArrayList<>(new TreeSet<>(list)); |
| | | QueryWrapper<TbDaily> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("type",type).eq("code",code).eq("mac",MAC); |
| | | queryWrapper.eq("type",type).eq("code",code).in("mac",macList); |
| | | queryWrapper.between("time",startTime,endTime); |
| | | List<TbDaily> dailies = dailyMapper.selectList(queryWrapper); |
| | | for (TbDaily daily : dailies) { |
| | |
| | | return excelBOS; |
| | | } |
| | | |
| | | @Override |
| | | public List<AppDeviceVo> selectSpecialDevice() { |
| | | QxUser user = UserHelper.getCurrentUser(); |
| | | Integer organizationId = user.getOrganizationId(); |
| | | // Integer organizationId=71; |
| | | List<AppDeviceVo> appDeviceVos; |
| | | if (organizationId!=24){ |
| | | appDeviceVos = specialDeviceMapper.selectSpecialDevice(organizationId); |
| | | }else { |
| | | appDeviceVos = specialDeviceMapper.selectSpecialDevice(null); |
| | | } |
| | | return appDeviceVos; |
| | | } |
| | | |
| | | //计算平均值和最大值 |
| | | private HashMap<String, Object> getStringObjectHashMap(List<Map<String, Object>> maps) { |
| | | HashMap<String, Object> rsMap = new HashMap<>(); |
| | |
| | | |
| | | |
| | | for (Map<String, Object> map : maps) { |
| | | // String flylon = map.get("flylon").toString(); |
| | | // String flylat = map.get("flylat").toString(); |
| | | // String s = flylon + "-" + flylat; |
| | | // if (Double.parseDouble(map.get("a34004").toString())>200){ |
| | | // |
| | | // } |
| | | pm25List.add(Double.parseDouble(map.get("a34004").toString())); |
| | | pm10List.add(Double.parseDouble(map.get("a34002").toString())); |
| | | COList.add(Double.parseDouble(map.get("a21005").toString())); |
| | | SO2List.add(Double.parseDouble(map.get("a21026").toString())); |
| | | NO2List.add(Double.parseDouble(map.get("a21004").toString())); |
| | | O3List.add(Double.parseDouble(map.get("a05024").toString())); |
| | | VOCList.add(Double.parseDouble(map.get("a99054").toString())); |
| | | |
| | | Map value = JSON.parseObject(map.get("value").toString(), Map.class); |
| | | if (!ObjectUtils.isEmpty(value.get("a34004"))){ |
| | | pm25List.add(Double.parseDouble(value.get("a34004").toString())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(value.get("a34002"))){ |
| | | pm10List.add(Double.parseDouble(value.get("a34002").toString())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(value.get("a21005"))){ |
| | | COList.add(Double.parseDouble(value.get("a21005").toString())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(value.get("a21026"))){ |
| | | SO2List.add(Double.parseDouble(value.get("a21026").toString())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(value.get("a21004"))){ |
| | | NO2List.add(Double.parseDouble(value.get("a21004").toString())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(value.get("a05024"))){ |
| | | O3List.add(Double.parseDouble(value.get("a05024").toString())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(value.get("a99054"))){ |
| | | VOCList.add(Double.parseDouble(value.get("a99054").toString())); |
| | | } |
| | | } |
| | | |
| | | //获取平均值 |
| | |
| | | if(!list.contains(d)){ |
| | | list.add(d); |
| | | integer++; |
| | | HistorySecondCruiserResultCountDTO countResultDTO = Objects.isNull(map.get(integer))?new HistorySecondCruiserResultCountDTO():map.get(integer); |
| | | countResultDTO.setSumNum(d.getNum()); |
| | | countResultDTO.setContNum(1); |
| | | map.put(integer,countResultDTO); |
| | | mapTest.put(d.getFlyLon()+"_"+d.getFlyLat(),d.getNum()); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private double getDivisor(String code,double num){ |
| | | double rs = 0.0; |
| | | if (code.contains("-")){ |
| | | String data = code.substring(1); |
| | | rs = num - Double.parseDouble(data); |
| | | } else if (code.contains("*")){ |
| | | String data = code.substring(1); |
| | | rs = num * Double.parseDouble(data); |
| | | } else if (code.contains("/")){ |
| | | String data = code.substring(1); |
| | | rs = num / Double.parseDouble(data); |
| | | } else if (code.contains(",")){ |
| | | String[] split = code.split(","); |
| | | for (String s : split) { |
| | | String[] split1 = s.split("<"); |
| | | double sp1 = Double.parseDouble(split1[0]); |
| | | double sp2 = Double.parseDouble(split1[1]); |
| | | double sp3 = Double.parseDouble(split1[2]); |
| | | if (num>=sp1 && num<=sp2){ |
| | | rs = num + sp3; |
| | | } |
| | | } |
| | | }else { |
| | | rs = num + Double.parseDouble(code); |
| | | } |
| | | return rs; |
| | | } |
| | | } |