From 9fa8e33b3085eb3a52b1d7d575fda67ad495810f Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Wed, 23 Aug 2023 15:21:50 +0800
Subject: [PATCH] chore:测试提交
---
screen-manage/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java | 100 ++++++++++++++++++++++++++++++---
screen-manage/src/main/java/com/moral/api/service/impl/HistorySecondCruiserServiceImpl.java | 68 +++++++++++++---------
screen-manage/src/main/java/com/moral/api/controller/ManageCoordinateDetailController.java | 7 +-
screen-common/src/main/java/com/moral/constant/RedisConstants.java | 3 +
4 files changed, 137 insertions(+), 41 deletions(-)
diff --git a/screen-common/src/main/java/com/moral/constant/RedisConstants.java b/screen-common/src/main/java/com/moral/constant/RedisConstants.java
index c07f1cf..7a08d47 100644
--- a/screen-common/src/main/java/com/moral/constant/RedisConstants.java
+++ b/screen-common/src/main/java/com/moral/constant/RedisConstants.java
@@ -105,4 +105,7 @@
public static final String DATE_CHANG_SHU = "date_changshu";
+
+
+ public static final String DATE_COORDINATE="data_coordinate";
}
diff --git a/screen-manage/src/main/java/com/moral/api/controller/ManageCoordinateDetailController.java b/screen-manage/src/main/java/com/moral/api/controller/ManageCoordinateDetailController.java
index 407774b..4d33cd0 100644
--- a/screen-manage/src/main/java/com/moral/api/controller/ManageCoordinateDetailController.java
+++ b/screen-manage/src/main/java/com/moral/api/controller/ManageCoordinateDetailController.java
@@ -65,7 +65,6 @@
return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
}
-
return null;
}
@@ -99,7 +98,7 @@
* ���������������
* @return
*/
- @GetMapping("select")
+ @PostMapping("select")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
@ApiImplicitParam(name = "coordinateId", value = "������id", required = true, paramType = "query", dataType = "String"),
@@ -110,7 +109,7 @@
if (!params.containsKey("coordinateId") || !params.containsKey("time1")|| !params.containsKey("time2")) {
return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
}
- Map<String, Object> map = manageCoordinateDetailService.selectCoordinate(params);
- return null;
+ Map<String,Object> rsMap = manageCoordinateDetailService.selectCoordinate(params);
+ return ResultMessage.ok(rsMap);
}
}
diff --git a/screen-manage/src/main/java/com/moral/api/service/impl/HistorySecondCruiserServiceImpl.java b/screen-manage/src/main/java/com/moral/api/service/impl/HistorySecondCruiserServiceImpl.java
index 4e5e34d..36574a2 100644
--- a/screen-manage/src/main/java/com/moral/api/service/impl/HistorySecondCruiserServiceImpl.java
+++ b/screen-manage/src/main/java/com/moral/api/service/impl/HistorySecondCruiserServiceImpl.java
@@ -30,6 +30,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -116,38 +117,51 @@
@Override
public Map<String,Object> getCruiserInFo(Map<String, Object> params) {
HashMap<String, Object> map = new HashMap<>();
+ String mac = params.get("mac").toString();
+ String time1 = params.get("time1").toString();
params.put("dateFormat", "%Y-%m-%d %H:%i:%s");
- List<CruiserDTO> data = historySecondCruiserMapper.getCruiserInfo(params);
- List<CruiserDTO> rsCruiser = data.stream().distinct().collect(Collectors.toList());
- rsCruiser.removeIf(o->{
- if (ObjectUtils.isEmpty(o.getFlyLon()) || ObjectUtils.isEmpty(o.getFlyLat())) {
- return true;
- }
- double lon = o.getFlyLon();
- double lat = o.getFlyLat();
- double[] doubles = RoadUtils.transformWGS84ToBD09(lon, lat);
- Matcher matcher = Pattern.compile("\\d*\\.\\d{8}").matcher(""+doubles[0]);
- matcher.find();
- String s = matcher.group();
- Matcher matcher1 = Pattern.compile("\\d*\\.\\d{8}").matcher(""+doubles[1]);
- matcher1.find();
- String s1 = matcher1.group();
- o.setFlyLon(Double.parseDouble(s));
- o.setFlyLat(Double.parseDouble(s1));
- o.setData(lon+"_"+lat);
+ ArrayList<Object> list = new ArrayList<>();
+ List<CruiserDTO> data = (List<CruiserDTO>) redisTemplate.opsForHash().get(RedisConstants.DATE_COORDINATE, mac + time1);
+// List<CruiserDTO> data = (List<CruiserDTO>) redisTemplate.opsForValue().get(mac + time1);
+ if (ObjectUtils.isEmpty(data)){
+ data = historySecondCruiserMapper.getCruiserInfo(params);
+ data = data.stream().distinct().collect(Collectors.toList());
+ data.removeIf(o->{
+ if (ObjectUtils.isEmpty(o.getFlyLon()) || ObjectUtils.isEmpty(o.getFlyLat())) {
+ return true;
+ }
+ double lon = o.getFlyLon();
+ double lat = o.getFlyLat();
+ double[] doubles = RoadUtils.transformWGS84ToBD09(lon, lat);
+ Matcher matcher = Pattern.compile("\\d*\\.\\d{8}").matcher(""+doubles[0]);
+ matcher.find();
+ String s = matcher.group();
+ Matcher matcher1 = Pattern.compile("\\d*\\.\\d{8}").matcher(""+doubles[1]);
+ matcher1.find();
+ String s1 = matcher1.group();
+ o.setFlyLon(Double.parseDouble(s));
+ o.setFlyLat(Double.parseDouble(s1));
+ o.setData(lon+"_"+lat);
// o.setFlyLon(doubles[0]);
// o.setFlyLat(doubles[1]);
- if (lon < 70 || lon > 150 || lat < 20 || lat > 60) {
- return true;
- }
- return false;
- });
- if(CollectionUtils.isEmpty(data)){
- return null;
+ if (lon < 70 || lon > 150 || lat < 20 || lat > 60) {
+ return true;
+ }
+ return false;
+ });
+
+ redisTemplate.opsForHash().put(RedisConstants.DATE_COORDINATE,mac+time1,data);
+ //������������������
+ redisTemplate.opsForHash().getOperations().expire(RedisConstants.DATE_COORDINATE,600, TimeUnit.SECONDS);
+
}
- map.put("rsData",rsCruiser);
+
+// redisTemplate.opsForValue().set(mac+time1,rsCruiser,600, TimeUnit.SECONDS);
+
+ map.put("rsData",data);
+ map.put("data",list);
log.info(data.size()+"");
- log.info(rsCruiser.size()+"");
+ log.info(data.size()+"");
return map;
}
diff --git a/screen-manage/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java b/screen-manage/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java
index 308b3c0..121db66 100644
--- a/screen-manage/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java
+++ b/screen-manage/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java
@@ -2,19 +2,30 @@
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;
@@ -25,6 +36,8 @@
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.TokenUtils;
import com.sun.org.apache.regexp.internal.RE;
@@ -39,6 +52,9 @@
@Autowired
private HistorySecondCruiserMapper historySecondCruiserMapper;
+
+ @Autowired
+ private RedisTemplate redisTemplate;
/**
* ���������������
* @param params
@@ -55,10 +71,13 @@
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();
+ 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("1")){
String[] rs = code.split("_");
manageCoordinateDetail.setCoordinateId(coordinateId);
manageCoordinateDetail.setLongitude(Double.parseDouble(rs[0]));
@@ -74,10 +93,11 @@
if (integer>=1){
return null;
}
- manageCoordinateDetailMapper.insert(manageCoordinateDetail);
-
+ manageCoordinateDetailMapper.insert(manageCoordinateDetail);
}else {
- manageCoordinateDetailMapper.deleteById(manageCoordinateDetail.getId());
+ manageCoordinateDetailMapper.deleteById(manageCoordinateDetail.getId());
+// manageCoordinateDetailMapper.delete(wrapper);
+
}
}
return 200;
@@ -99,17 +119,77 @@
* @return
*/
@Override
- public Map<String, Object> selectCoordinate(Map<String, Object> params) {
+ public Map<String,Object> selectCoordinate(Map<String, Object> params) {
+ HashMap<String,Object> rsMap = new HashMap<>();
+ String mac = params.get("mac").toString();
+ String time1 = params.get("time1").toString();
+ ArrayList<ManageCoordinateDetail> rsList1 = new ArrayList<>();
params.put("dateFormat", "%Y-%m-%d %H:%i:%s");
String coordinateId = params.get("coordinateId").toString();
QueryWrapper<ManageCoordinateDetail> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("coordinate_id",coordinateId);
List<ManageCoordinateDetail> manageCoordinateDetails = manageCoordinateDetailMapper.selectList(queryWrapper);
+ List<CruiserDTO> cruiserInfo = (List<CruiserDTO>) redisTemplate.opsForHash().get(RedisConstants.DATE_COORDINATE, mac + time1);
+ if (ObjectUtils.isEmpty(cruiserInfo)){
+ cruiserInfo = historySecondCruiserMapper.getCruiserInfo(params);
+ cruiserInfo = cruiserInfo.stream().distinct().collect(Collectors.toList());
+ cruiserInfo.removeIf(o->{
+ if (ObjectUtils.isEmpty(o.getFlyLon()) || ObjectUtils.isEmpty(o.getFlyLat())) {
+ return true;
+ }
+ double lon = o.getFlyLon();
+ double lat = o.getFlyLat();
+ double[] doubles = RoadUtils.transformWGS84ToBD09(lon, lat);
+ Matcher matcher = Pattern.compile("\\d*\\.\\d{8}").matcher(""+doubles[0]);
+ matcher.find();
+ String s = matcher.group();
+ Matcher matcher1 = Pattern.compile("\\d*\\.\\d{8}").matcher(""+doubles[1]);
+ matcher1.find();
+ String s1 = matcher1.group();
+ o.setFlyLon(Double.parseDouble(s));
+ o.setFlyLat(Double.parseDouble(s1));
+ o.setData(lon+"_"+lat);
+// o.setFlyLon(doubles[0]);
+// o.setFlyLat(doubles[1]);
+ if (lon < 70 || lon > 150 || lat < 20 || lat > 60) {
+ return true;
+ }
+ return false;
+ });
+ redisTemplate.opsForHash().put(RedisConstants.DATE_COORDINATE,mac+time1,cruiserInfo);
+ //������������������
+ redisTemplate.opsForHash().getOperations().expire(RedisConstants.DATE_COORDINATE,6000, TimeUnit.SECONDS);
+ }
+// List<CruiserDTO> cruiserInfo = historySecondCruiserMapper.getCruiserInfo(params);
+ if (ObjectUtils.isEmpty(manageCoordinateDetails)){
+ rsMap.put("rsData",cruiserInfo);
+ rsMap.put("data",rsList1);
+ return rsMap;
+ }
+ for (int i=cruiserInfo.size()-1;i>0;i--) {
+ CruiserDTO cruiserDTO = cruiserInfo.get(i);
+ String data = cruiserDTO.getData();
+ String[] rs = data.split("_");
+ String flyLon = rs[0];
+ String flyLat = rs[1];
+ for (ManageCoordinateDetail manageCoordinateDetail : manageCoordinateDetails) {
+ String latitude = manageCoordinateDetail.getLatitude().toString();
+ String longitude = manageCoordinateDetail.getLongitude().toString();
+ if (latitude.equals(flyLat) && longitude.equals(flyLon)){
+ manageCoordinateDetail.setLongitude(Double.parseDouble(flyLon));
+ manageCoordinateDetail.setLatitude(Double.parseDouble(flyLat));
+ rsList1.add(manageCoordinateDetail);
+ cruiserInfo.remove(i);
+ break;
+ }
+ }
-
- return null;
+ }
+ rsMap.put("rsData",cruiserInfo);
+ rsMap.put("data",rsList1);
+ return rsMap;
}
--
Gitblit v1.8.0