| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | 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.entity.ManageCoordinateDetail; |
| | | import com.moral.api.mapper.HistorySecondCruiserMapper; |
| | | import com.moral.api.mapper.ManageCoordinateDetailMapper; |
| | | import com.moral.api.pojo.dto.cruiser.CruiserDTO; |
| | | import com.moral.api.pojo.redisBean.AccountInfoDTO; |
| | | import com.moral.api.service.ManageCoordinateDetailService; |
| | | import com.moral.api.util.RoadUtils; |
| | | import com.moral.util.TokenUtils; |
| | | import com.sun.org.apache.regexp.internal.RE; |
| | | |
| | | |
| | | @Service |
| | |
| | | private HistorySecondCruiserMapper historySecondCruiserMapper; |
| | | /** |
| | | * 新增经纬度 |
| | | * @param manageCoordinateDetails |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public Integer insertCoordinate(List<ManageCoordinateDetail> manageCoordinateDetails) { |
| | | public Integer insertCoordinate(Map<String,Object> params) { |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | String token = request.getHeader("token"); |
| | | AccountInfoDTO accountInfoDTO = (AccountInfoDTO) TokenUtils.getUserInfoByToken(token); |
| | | ManageAccount manageAccount = accountInfoDTO.getAccount(); |
| | | Integer id = manageAccount.getId(); |
| | | String userName = manageAccount.getUserName(); |
| | | |
| | | int coordinateId = Integer.parseInt(params.get("coordinateId").toString()); |
| | | List<ManageCoordinateDetail> manageCoordinateDetails = (List<ManageCoordinateDetail>) params.get("data"); |
| | | for (ManageCoordinateDetail manageCoordinateDetail : manageCoordinateDetails) { |
| | | if (manageCoordinateDetail.getState().equals("1")){ |
| | | String code = manageCoordinateDetail.getCode(); |
| | | String[] rs = code.split("_"); |
| | | manageCoordinateDetail.setCoordinateId(coordinateId); |
| | | manageCoordinateDetail.setLongitude(Double.parseDouble(rs[0])); |
| | | manageCoordinateDetail.setLatitude(Double.parseDouble(rs[1])); |
| | | manageCoordinateDetail.setState("2"); |
| | | int insert = manageCoordinateDetailMapper.insert(manageCoordinateDetail); |
| | | if (insert!=1){ |
| | | manageCoordinateDetail.setUpdateUserId(id); |
| | | manageCoordinateDetail.setUpdayeUserName(userName); |
| | | QueryWrapper<ManageCoordinateDetail> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("coordinate_id",coordinateId); |
| | | wrapper.eq("longitude",manageCoordinateDetail.getLongitude()); |
| | | wrapper.eq("latitude",manageCoordinateDetail.getLatitude()); |
| | | Integer integer = manageCoordinateDetailMapper.selectCount(wrapper); |
| | | if (integer>=1){ |
| | | return null; |
| | | } |
| | | manageCoordinateDetailMapper.insert(manageCoordinateDetail); |
| | | |
| | | }else { |
| | | int i = manageCoordinateDetailMapper.deleteById(manageCoordinateDetail.getId()); |
| | | if (i!=1){ |
| | | return null; |
| | | } |
| | | manageCoordinateDetailMapper.deleteById(manageCoordinateDetail.getId()); |
| | | } |
| | | } |
| | | return 200; |
| | |
| | | queryWrapper.eq("coordinate_id",coordinateId); |
| | | List<ManageCoordinateDetail> manageCoordinateDetails = manageCoordinateDetailMapper.selectList(queryWrapper); |
| | | |
| | | // ArrayList<String> list1 = new ArrayList<>(); |
| | | // ArrayList<String> list2 = new ArrayList<>(); |
| | | // for (ManageCoordinateDetail manageCoordinateDetail : manageCoordinateDetails) { |
| | | // Double latitude = manageCoordinateDetail.getLatitude(); |
| | | // Double longitude = manageCoordinateDetail.getLongitude(); |
| | | // String s = longitude + "_" + latitude; |
| | | // list1.add(s); |
| | | // } |
| | | // List<CruiserDTO> cruiserInfo = historySecondCruiserMapper.getCruiserInfo(params); |
| | | // for (CruiserDTO cruiserDTO : cruiserInfo) { |
| | | // String s = cruiserDTO.getFlyLat().toString(); |
| | | // String s1 = cruiserDTO.getFlyLon().toString(); |
| | | // String rs = s1 + "_" + s; |
| | | // list2.add(rs); |
| | | // } |
| | | // //取交集 |
| | | // list1.retainAll(list2); |
| | | // //取差集 |
| | | // list2.removeAll(list1); |
| | | // //存入数据库的数据 |
| | | // CruiserDTO rsDTO = new CruiserDTO(); |
| | | // for (ManageCoordinateDetail manageCoordinateDetail : manageCoordinateDetails) { |
| | | // String latitude = manageCoordinateDetail.getLatitude().toString(); |
| | | // String longitude = manageCoordinateDetail.getLongitude().toString(); |
| | | // for (CruiserDTO cruiserDTO : cruiserInfo) { |
| | | // Double flyLat = cruiserDTO.getFlyLat(); |
| | | // Double flyLon = cruiserDTO.getFlyLon(); |
| | | // if (latitude.equals(flyLat+"") && longitude.equals(flyLon+"")){ |
| | | // rsDTO.setFlyLat(flyLat); |
| | | // rsDTO.setFlyLon(flyLon); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | |
| | | |
| | | return null; |