| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.entity.ManageAccount; |
| | |
| | | import com.moral.api.pojo.redisBean.AccountInfoDTO; |
| | | import com.moral.api.service.ManageCoordinateDetailService; |
| | | import com.moral.api.util.RoadUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.RedisConstants; |
| | | import com.moral.util.DateUtils; |
| | | import com.moral.util.TokenUtils; |
| | | import com.sun.org.apache.regexp.internal.RE; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @Service |
| | |
| | | List<Map<String, Object>> data = (List<Map<String, Object>>) params.get("data"); |
| | | |
| | | for (Map<String, Object> datum : data) { |
| | | ManageCoordinateDetail manageCoordinateDetail = new ManageCoordinateDetail(); |
| | | |
| | | String code = datum.get("code").toString(); |
| | | String state = datum.get("state").toString(); |
| | | |
| | | if (state.equals("2")){ |
| | | ManageCoordinateDetail manageCoordinateDetail = new ManageCoordinateDetail(); |
| | | String[] rs = code.split("_"); |
| | | manageCoordinateDetail.setCoordinateId(coordinateId); |
| | | manageCoordinateDetail.setLongitude(Double.parseDouble(rs[0])); |
| | |
| | | return 2; |
| | | } |
| | | manageCoordinateDetailMapper.deleteById(Integer.parseInt(id1.toString())); |
| | | // manageCoordinateDetailMapper.delete(wrapper); |
| | | |
| | | } |
| | | } |
| | | return 200; |
| | |
| | | String[] rs = data.split("_"); |
| | | String flyLon = rs[0]; |
| | | String flyLat = rs[1]; |
| | | // double lonDouble = Double.parseDouble(flyLon); |
| | | // double latDouble = Double.parseDouble(flyLat); |
| | | for (ManageCoordinateDetail manageCoordinateDetail : manageCoordinateDetails) { |
| | | String latitude = manageCoordinateDetail.getLatitude().toString(); |
| | | String longitude = manageCoordinateDetail.getLongitude().toString(); |
| | | if (latitude.equals(flyLat) && longitude.equals(flyLon)){ |
| | | // double lonDouble1 = Double.parseDouble(longitude); |
| | | // double latDouble1 = Double.parseDouble(latitude); |
| | | // if (latDouble1==latDouble && lonDouble==lonDouble1){ |
| | | if (flyLon.equals(longitude) && flyLat.equals(latitude)){ |
| | | manageCoordinateDetail.setCode(data); |
| | | manageCoordinateDetail.setLongitude(cruiserDTO.getFlyLon()); |
| | | manageCoordinateDetail.setLatitude(cruiserDTO.getFlyLat()); |
| | |
| | | queryWrapper.eq("coordinate_id",coordinateId); |
| | | String time1 = params.remove("time1").toString(); |
| | | String time2 = params.remove("time2").toString(); |
| | | long l = DateUtils.compareDateStr(time1, time2); |
| | | long l = DateUtils.compareDateStrDay(time1, time2); |
| | | if (l>0){ |
| | | params.put("time1",time1); |
| | | params.put("time2",time2); |
| | |
| | | int j =0; |
| | | List<ManageCoordinateDetail> manageCoordinateDetails = manageCoordinateDetailMapper.selectList(queryWrapper); |
| | | List<CruiserDTO> cruiserInfo = historySecondCruiserMapper.getCruiserInfo(params); |
| | | cruiserInfo = cruiserInfo.stream().distinct().collect(Collectors.toList()); |
| | | if (ObjectUtils.isEmpty(manageCoordinateDetails)){ |
| | | for (CruiserDTO cruiserDTO : cruiserInfo) { |
| | | Double flyLat = cruiserDTO.getFlyLat(); |
| | |
| | | log.info(j+""); |
| | | } |
| | | }else { |
| | | for (int i=cruiserInfo.size()-1;i>0;i--) { |
| | | CruiserDTO cruiserDTO = cruiserInfo.get(i); |
| | | Double flyLat = cruiserDTO.getFlyLat(); |
| | | Double flyLon = cruiserDTO.getFlyLon(); |
| | | for (ManageCoordinateDetail manageCoordinateDetail : manageCoordinateDetails) { |
| | | String latitude = manageCoordinateDetail.getLatitude().toString(); |
| | | String longitude = manageCoordinateDetail.getLongitude().toString(); |
| | | if (latitude.equals(flyLat+"") && longitude.equals(flyLon+"")){ |
| | | cruiserInfo.remove(i); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | Map<String,Integer> map = new HashMap<>(manageCoordinateDetails.size()+50); |
| | | manageCoordinateDetails.forEach(it->map.put(it.getLatitude()+"_"+it.getLongitude(),it.getId())); |
| | | List<ManageCoordinateDetail> result = new ArrayList<>(); |
| | | for (CruiserDTO cruiserDTO : cruiserInfo) { |
| | | Double flyLat = cruiserDTO.getFlyLat(); |
| | | Double flyLon = cruiserDTO.getFlyLon(); |
| | | ManageCoordinateDetail rsDTO = new ManageCoordinateDetail(); |
| | | rsDTO.setLatitude(flyLat); |
| | | rsDTO.setLongitude(flyLon); |
| | | rsDTO.setState("2"); |
| | | rsDTO.setCreateTime(new Date()); |
| | | rsDTO.setUpdateTime(new Date()); |
| | | rsDTO.setCoordinateId(coordinateId); |
| | | manageCoordinateDetailMapper.insert(rsDTO); |
| | | j++; |
| | | log.info(j+""); |
| | | String fly = cruiserDTO.getFlyLat()+"_"+cruiserDTO.getFlyLon(); |
| | | if(!map.containsKey(fly)){ |
| | | ManageCoordinateDetail rsDTO = new ManageCoordinateDetail(); |
| | | rsDTO.setLatitude(cruiserDTO.getFlyLat()); |
| | | rsDTO.setLongitude(cruiserDTO.getFlyLon()); |
| | | rsDTO.setState("2"); |
| | | rsDTO.setCreateTime(new Date()); |
| | | rsDTO.setUpdateTime(new Date()); |
| | | rsDTO.setCoordinateId(coordinateId); |
| | | result.add(rsDTO); |
| | | } |
| | | } |
| | | if(!CollectionUtils.isEmpty(result)){ |
| | | this.saveBatch(result); |
| | | } |
| | | } |
| | | return 200; |