|
@@ -2,9 +2,9 @@ package com.ruoyi.benyun.utils;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.ruoyi.benyun.constant.RedisContant;
|
|
|
-import com.ruoyi.benyun.mapper.WdInfoDao;
|
|
|
-import com.ruoyi.benyun.service.WriteService;
|
|
|
import com.ruoyi.benyun.entity.WdInfo;
|
|
|
+import com.ruoyi.benyun.mapper.WdInfoDao;
|
|
|
+//import com.ruoyi.benyun.service.WriteService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.data.geo.Distance;
|
|
@@ -15,9 +15,10 @@ import org.springframework.data.redis.connection.RedisGeoCommands;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Hashtable;
|
|
|
+import java.util.List;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
-import java.util.concurrent.ExecutionException;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -36,8 +37,8 @@ public class WdRedisStoreage {
|
|
|
|
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
- WriteService writeService;
|
|
|
+ //@Autowired
|
|
|
+ //WriteService writeService;
|
|
|
|
|
|
|
|
|
/***
|
|
@@ -112,90 +113,91 @@ public class WdRedisStoreage {
|
|
|
//给网点打标签并存入redis中
|
|
|
//writeWdGeoRedis2();
|
|
|
}
|
|
|
-
|
|
|
- public void clearSql2(){
|
|
|
- List<String> wdId = new ArrayList<>();
|
|
|
- List<String> storeId = new ArrayList<>();
|
|
|
- List<String> houseId = new ArrayList<>();
|
|
|
- List<String> buildId = new ArrayList<>();
|
|
|
- List<String> trafficId = new ArrayList<>();
|
|
|
- List<String> enterpriseId = new ArrayList<>();
|
|
|
- long start = System.currentTimeMillis();
|
|
|
-
|
|
|
- try{
|
|
|
- System.out.println("开始清理");
|
|
|
-
|
|
|
- QueryWrapper<WdInfo> wdInfoOriginQueryWrapper = new QueryWrapper<>();
|
|
|
- wdInfoOriginQueryWrapper.select("hash", "count(hash) as audit").groupBy("hash").having("count(hash) >= 2");
|
|
|
- List<WdInfo> wdInfoOrigins = wdInfoDao.selectList(wdInfoOriginQueryWrapper);
|
|
|
-
|
|
|
- HashMap<String, Integer> hashMap = new HashMap<>();
|
|
|
- for (WdInfo wdInfo : wdInfoOrigins) {
|
|
|
- hashMap.put(wdInfo.getHash(), wdInfo.getAudit());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- HashMap<String,Integer> hashMap1 = new HashMap<>();
|
|
|
- hashMap1.put("total",1);
|
|
|
- CompletableFuture<Void> future = null;
|
|
|
- for (String s : hashMap.keySet()) {
|
|
|
- future = CompletableFuture.runAsync(()->{
|
|
|
- synchronized (this){
|
|
|
- if(hashMap1.get("total")%1000 == 0){
|
|
|
- writeService.clearSql2(wdId,storeId,houseId,buildId,trafficId,enterpriseId);
|
|
|
- wdId.clear();
|
|
|
- storeId.clear();
|
|
|
- houseId.clear();
|
|
|
- buildId.clear();
|
|
|
- trafficId.clear();
|
|
|
- enterpriseId.clear();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("hash",s);
|
|
|
- queryWrapper.orderByDesc("collect_time");
|
|
|
- queryWrapper.last("limit " + (hashMap.get(s) - 1));
|
|
|
- List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
|
|
|
- for (WdInfo wdInfo : wdInfos) {
|
|
|
- wdId.add(wdInfo.getWdId());
|
|
|
-
|
|
|
- switch (wdInfo.getWdTypeCode()){
|
|
|
- case "1":
|
|
|
- storeId.add(wdInfo.getWdId());
|
|
|
- break;
|
|
|
- case "2":
|
|
|
- houseId.add(wdInfo.getWdId());
|
|
|
- break;
|
|
|
- case "3":
|
|
|
- buildId.add(wdInfo.getWdId());
|
|
|
- break;
|
|
|
- case "4":
|
|
|
- trafficId.add(wdInfo.getWdId());
|
|
|
- break;
|
|
|
- case "5":
|
|
|
- enterpriseId.add(wdInfo.getWdId());
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- System.out.println("进度:"+wdInfoOrigins.size()+"/"+hashMap1.get("total"));
|
|
|
- hashMap1.put("total",hashMap1.get("total")+1);
|
|
|
- },executorService);
|
|
|
- }
|
|
|
- future.get();
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }finally {
|
|
|
- //删除
|
|
|
- writeService.clearSql2(wdId,storeId,houseId,buildId,trafficId,enterpriseId);
|
|
|
- long end = System.currentTimeMillis();
|
|
|
- System.out.println("完成清理 "+(end-start)/(1000*60));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
+//
|
|
|
+// public void clearSql2(){
|
|
|
+// List<String> wdId = new ArrayList<>();
|
|
|
+// List<String> storeId = new ArrayList<>();
|
|
|
+// List<String> houseId = new ArrayList<>();
|
|
|
+// List<String> buildId = new ArrayList<>();
|
|
|
+// List<String> trafficId = new ArrayList<>();
|
|
|
+// List<String> enterpriseId = new ArrayList<>();
|
|
|
+// long start = System.currentTimeMillis();
|
|
|
+//
|
|
|
+// try{
|
|
|
+// System.out.println("开始清理");
|
|
|
+//
|
|
|
+// QueryWrapper<WdInfo> wdInfoOriginQueryWrapper = new QueryWrapper<>();
|
|
|
+// wdInfoOriginQueryWrapper.select("hash", "count(hash) as audit").groupBy("hash").having("count(hash) >= 2");
|
|
|
+// List<WdInfo> wdInfoOrigins = wdInfoDao.selectList(wdInfoOriginQueryWrapper);
|
|
|
+//
|
|
|
+// HashMap<String, Integer> hashMap = new HashMap<>();
|
|
|
+// for (WdInfo wdInfo : wdInfoOrigins) {
|
|
|
+// hashMap.put(wdInfo.getHash(), wdInfo.getAudit());
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// HashMap<String,Integer> hashMap1 = new HashMap<>();
|
|
|
+// hashMap1.put("total",1);
|
|
|
+// CompletableFuture<Void> future = null;
|
|
|
+// for (String s : hashMap.keySet()) {
|
|
|
+// FutureTask
|
|
|
+// future = CompletableFuture.runAsync(()->{
|
|
|
+// synchronized (this){
|
|
|
+// if(hashMap1.get("total")%1000 == 0){
|
|
|
+// writeService.clearSql2(wdId,storeId,houseId,buildId,trafficId,enterpriseId);
|
|
|
+// wdId.clear();
|
|
|
+// storeId.clear();
|
|
|
+// houseId.clear();
|
|
|
+// buildId.clear();
|
|
|
+// trafficId.clear();
|
|
|
+// enterpriseId.clear();
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+// queryWrapper.eq("hash",s);
|
|
|
+// queryWrapper.orderByDesc("collect_time");
|
|
|
+// queryWrapper.last("limit " + (hashMap.get(s) - 1));
|
|
|
+// List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
|
|
|
+// for (WdInfo wdInfo : wdInfos) {
|
|
|
+// wdId.add(wdInfo.getWdId());
|
|
|
+//
|
|
|
+// switch (wdInfo.getWdTypeCode()){
|
|
|
+// case "1":
|
|
|
+// storeId.add(wdInfo.getWdId());
|
|
|
+// break;
|
|
|
+// case "2":
|
|
|
+// houseId.add(wdInfo.getWdId());
|
|
|
+// break;
|
|
|
+// case "3":
|
|
|
+// buildId.add(wdInfo.getWdId());
|
|
|
+// break;
|
|
|
+// case "4":
|
|
|
+// trafficId.add(wdInfo.getWdId());
|
|
|
+// break;
|
|
|
+// case "5":
|
|
|
+// enterpriseId.add(wdInfo.getWdId());
|
|
|
+// break;
|
|
|
+// default:
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// System.out.println("进度:"+wdInfoOrigins.size()+"/"+hashMap1.get("total"));
|
|
|
+// hashMap1.put("total",hashMap1.get("total")+1);
|
|
|
+// },executorService);
|
|
|
+// }
|
|
|
+// future.get();
|
|
|
+// }catch (Exception e){
|
|
|
+// e.printStackTrace();
|
|
|
+// }finally {
|
|
|
+// //删除
|
|
|
+// writeService.clearSql2(wdId,storeId,houseId,buildId,trafficId,enterpriseId);
|
|
|
+// long end = System.currentTimeMillis();
|
|
|
+// System.out.println("完成清理 "+(end-start)/(1000*60));
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
public void writeWdGeoRedis1(String time){
|
|
|
//1.将网点坐标存入redis中
|