|
@@ -20,10 +20,14 @@ import com.ruoyi.demo.service.ChannelAnalyseService;
|
|
|
import com.ruoyi.demo.utils.InitMapUtil;
|
|
|
import com.ruoyi.demo.utils.WdRedisStoreage;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.concurrent.ExecutionException;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -48,6 +52,10 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
@Autowired
|
|
|
private StoreWdDao storeWdDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("executor")
|
|
|
+ ExecutorService executor;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public HashMap cityTier(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
@@ -103,29 +111,44 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
List<WdInfo> queryWd = wdInfoDao.selectList(queryWrapper);
|
|
|
|
|
|
//2.获取网点周边标签,并进行统计
|
|
|
- int total = 0;
|
|
|
- HashMap<String,Integer> hashMap = new HashMap<>();
|
|
|
+ Hashtable<String, Integer> hashtable = new Hashtable<>();
|
|
|
+ hashtable.put("total",0);
|
|
|
+ CompletableFuture<Void> future = null;
|
|
|
for (WdInfo wdInfo : queryWd) {
|
|
|
- List<String> wdTag = wdRedisStoreage.getWdTag(wdInfo);
|
|
|
- if (wdTag == null)
|
|
|
- continue;
|
|
|
- total++;
|
|
|
- for (String s : wdTag) {
|
|
|
- Integer integer = hashMap.get(s);
|
|
|
- if (integer == null)
|
|
|
- hashMap.put(s,1);
|
|
|
- else
|
|
|
- hashMap.put(s,integer+1);
|
|
|
- }
|
|
|
+ future = CompletableFuture.runAsync(()->{
|
|
|
+ List<String> wdTag = wdRedisStoreage.getWdTag(wdInfo);
|
|
|
+ if (wdTag != null){
|
|
|
+ for (String s : wdTag) {
|
|
|
+ s += "边";
|
|
|
+ Integer integer = hashtable.get(s);
|
|
|
+ if (integer == null)
|
|
|
+ hashtable.put(s,1);
|
|
|
+ else
|
|
|
+ hashtable.put(s,integer+1);
|
|
|
+ hashtable.put("total",hashtable.get("total")+1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },executor);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ future.get();
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } catch (ExecutionException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
}
|
|
|
|
|
|
//3.封装统计值
|
|
|
HashMap<String, Object> result = new HashMap<>();
|
|
|
List<TagAnalyse> list = new ArrayList<>();
|
|
|
- for (String s : hashMap.keySet()) {
|
|
|
+ Integer total = hashtable.get("total");
|
|
|
+ for (String s : hashtable.keySet()) {
|
|
|
+ if (s.equals("total"))
|
|
|
+ continue;
|
|
|
+
|
|
|
TagAnalyse tagAnalyse = new TagAnalyse();
|
|
|
tagAnalyse.setName(s);
|
|
|
- tagAnalyse.setCount(hashMap.get(s));
|
|
|
+ tagAnalyse.setCount(hashtable.get(s));
|
|
|
BigDecimal bigDecimal = new BigDecimal((double) tagAnalyse.getCount() / total);
|
|
|
double v = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
tagAnalyse.setRadio(v);
|