记得上下班打卡 | git大法好,push需谨慎

Commit d87b7213 authored by anjiabin's avatar anjiabin

提交chime社交相关

parent 60bda996
use prod_ln_scene;
#创建集合
db.createCollection("KylinCheckUserVo");
db.createCollection("ChimeUserInfoVo");
db.createCollection("ChimeUserTagsMappingVo");
#创建索引
db.KylinCheckUserPerformanceVo.createIndex({checkUserId:"hashed"});
db.KylinCheckUserVo.createIndex({merchantId:"hashed"});
db.KylinCheckUserVo.createIndex({mobile:"hashed"});
db.KylinOrderRefundEntitiesVo.createIndex({orderRefundsId:"hashed"});
db.KylinOrderRefundEntitiesVo.createIndex({orderTicketEntitiesId:"hashed"});
db.KylinOrderRefundPicVo.createIndex({orderRefundsId:"hashed"});
db.KylinOrderRefundsVo.createIndex({orderRefundsId:"hashed"});
db.KylinOrderRefundsVo.createIndex({orderTicketsId:"hashed"});
db.KylinOrderTicketEntitiesVo.createIndex({orderTicketEntitiesId:"hashed"});
db.KylinOrderTicketEntitiesVo.createIndex({orderId:"hashed"});
db.KylinOrderTicketVo.createIndex({orderTicketsId:"hashed"});
db.KylinOrderTicketVo.createIndex({orderCode:"hashed"});
db.KylinOrderTicketVo.createIndex({userId:"hashed"});
db.KylinPerformanceVo.createIndex({performancesId:"hashed"});
db.KylinPerformanceMisVo.createIndex({performancesId:"hashed"});
db.KylinTicketPartnerVo.createIndex({ticketsId:"hashed"});
db.KylinTicketPartnerVo.createIndex({timesId:"hashed"});
db.KylinTicketTimesPartnerVo.createIndex({performancesId:"hashed"});
db.KylinTicketTimesPartnerVo.createIndex({ticketTimesId:"hashed"});
db.PerformanceMemberAuditParam.createIndex({performancesId:"hashed"});
db.AdminUpushVo.createIndex({upushId:"hashed"});
db.ChimeUserInfoVo.createIndex({userId:"hashed"});
db.ChimeUserInfoVo.createIndex({joinPerformanceId:"hashed"});
db.ChimeUserTagsMappingVo.createIndex({userId:"hashed"});
db.ChimeUserTagsMappingVo.createIndex({tagCode:"hashed"});
#创建分片
sh.enableSharding("prod_ln_scene");
sh.shardCollection("prod_ln_scene.KylinCheckUserPerformanceVo",{"checkUserId":"hashed"});
sh.shardCollection("prod_ln_scene.KylinCheckUserVo",{"checkUserId":"hashed"});
sh.shardCollection("prod_ln_scene.KylinOrderRefundEntitiesVo",{"orderRefundsEntitiesId":"hashed"});
sh.shardCollection("prod_ln_scene.KylinOrderRefundPicVo",{"refundPicId":"hashed"});
sh.shardCollection("prod_ln_scene.KylinOrderRefundsVo",{"orderRefundsId":"hashed"});
sh.shardCollection("prod_ln_scene.KylinOrderTicketEntitiesVo",{"orderTicketEntitiesId":"hashed"});
sh.shardCollection("prod_ln_scene.KylinOrderTicketVo",{"orderTicketsId":"hashed"});
sh.shardCollection("prod_ln_scene.KylinPerformanceVo",{"performancesId":"hashed"});
sh.shardCollection("prod_ln_scene.KylinRoadShowVo",{"roadShowsId":"hashed"});
sh.shardCollection("prod_ln_scene.KylinPerformanceMisVo",{"performancesId":"hashed"});
sh.shardCollection("prod_ln_scene.KylinTicketPartnerVo",{"ticketsId":"hashed"});
sh.shardCollection("prod_ln_scene.KylinTicketTimesPartnerVo",{"ticketTimesId":"hashed"});
sh.shardCollection("prod_ln_scene.PerformanceMemberAuditParam",{"performancesId":"hashed"});
sh.shardCollection("prod_ln_scene.AdminUpushVo",{"upushId":"hashed"});
sh.shardCollection("prod_ln_scene.ChimeUserInfoVo",{"userId":"hashed"});
sh.shardCollection("prod_ln_scene.ChimeUserTagsMappingVo",{"userId":"hashed"});
......@@ -2,7 +2,6 @@ package com.liquidnet.service.chime.service.impl;
import com.liquidnet.commons.lang.util.BeanUtil;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.chime.dto.ChimeUserInfoDto;
import com.liquidnet.service.chime.dto.ChimeUserListQueryReqDto;
import com.liquidnet.service.chime.dto.ChimeUserTagDto;
......@@ -25,6 +24,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
......@@ -80,36 +80,59 @@ public class ChimePerformanceServiceImpl implements IChimePerformanceService{
// }
project.andInclude("_id");
//获取总数
Aggregation newAggregation = Aggregation.newAggregation(lookupToLots,matchToLots,project);
long startTime = System.currentTimeMillis();
SkipOperation skipOp = Aggregation.skip(0);
LimitOperation limitOp = Aggregation.limit(1000);
Aggregation newAggregation = Aggregation.newAggregation(lookupToLots,matchToLots,project,skipOp,limitOp);
List<ChimeUserInfoVo> tempChimeUserInfoVoList = mongoTemplate.aggregate(newAggregation,ChimeUserInfoVo.class.getSimpleName(),ChimeUserInfoVo.class).getMappedResults();
long count = tempChimeUserInfoVoList.size();
// long count = 1000;
long endTime = System.currentTimeMillis();
log.info("获取总数 count:{}条",count);
log.info("获取总数 耗时:{}ms",endTime-startTime);
//查询分页数据
startTime = System.currentTimeMillis();
SkipOperation skipOperation = Aggregation.skip(pageNum*pageSize);
LimitOperation limitOperation = Aggregation.limit(pageSize);
Aggregation aggregation = Aggregation.newAggregation(lookupToLots,matchToLots,project,skipOperation,limitOperation);
List<ChimeUserInfoVo> chimeUserInfoVoList = mongoTemplate.aggregate(aggregation,ChimeUserInfoVo.class.getSimpleName(),ChimeUserInfoVo.class).getMappedResults();
endTime = System.currentTimeMillis();
log.info("查询分页数据 耗时:{}ms",endTime-startTime);
//获取标签
if(StringUtil.isNull(chimeUserInfoVoList)){
return pagedResult;
};
//处理Vo
List<ChimeUserInfoDto> dtoList = new ArrayList<>();
startTime = System.currentTimeMillis();
List<String> userIdList = chimeUserInfoVoList.parallelStream().map(ChimeUserInfoVo::getUserId).collect(Collectors.toList());
Query query= Query.query(Criteria.where("userId").in(userIdList));
List<ChimeUserTagDto> tagVoList = mongoTemplate.find(query, ChimeUserTagDto.class,ChimeUserTagsMappingVo.class.getSimpleName());
for (ChimeUserInfoVo item : chimeUserInfoVoList) {
ChimeUserInfoDto voData = ChimeUserInfoDto.getNew();
BeanUtil.copy(item,voData);
voData.setPassWord("123456");
//获取标签
Query query= Query.query(Criteria.where("userId").is(item.getUserId())).with(Sort.by(Sort.Order.asc("tagCode")));
List<ChimeUserTagDto> tagVoList = mongoTemplate.find(query, ChimeUserTagDto.class,ChimeUserTagsMappingVo.class.getSimpleName());
voData.setUserTags(tagVoList);
List<ChimeUserTagDto> tempUserTag = tagVoList.parallelStream().filter(userVo -> userVo.getUserId().equalsIgnoreCase(voData.getUserId())).collect(Collectors.toList());
voData.setUserTags(tempUserTag);
dtoList.add(voData);
}
endTime = System.currentTimeMillis();
log.info("查询标签数据 耗时:{}ms",endTime-startTime);
pagedResult.setList(dtoList).setTotal(count, pageSize);
} catch (Exception e) {
e.printStackTrace();
}
return pagedResult;
}
// @Override
// public PagedResult<ChimeUserInfoDto> getUserListByCon(ChimeUserListQueryReqDto reqDto) {
// PagedResult<ChimeUserInfoDto> pagedResult = ObjectUtil.getChimeUserInfoDtoPagedResult();
......
package com.liquidnet.service.chime.test;
import com.liquidnet.common.third.easemob.util.EasemobUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.chime.biz.ChimeUserBiz;
import com.liquidnet.service.chime.dto.ChimeUserInfoDto;
import com.liquidnet.service.chime.dto.ChimeUserListQueryReqDto;
import com.liquidnet.service.chime.dto.NewPageResult;
import com.liquidnet.service.chime.service.IChimePerformanceService;
import com.liquidnet.service.chime.utils.DataUtils;
import com.liquidnet.service.chime.vo.mongo.ChimeUserTagsMappingVo;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
......@@ -19,6 +33,18 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class TestDataUtils {
@Autowired
private DataUtils dataUtils;
@Autowired
private EasemobUtil easemobUtil;
@Autowired
private ChimeUserBiz chimeUserBiz;
@Autowired
private IChimePerformanceService chimePerformanceService;
@Test
public void getPerformanceCount(){
......@@ -26,6 +52,118 @@ public class TestDataUtils {
@Test
public void getUserImgList(){
ExecutorService executorService = Executors.newFixedThreadPool(100);
Future future = executorService.submit(new Callable(){
public Object call() throws Exception {
System.out.println("Asynchronous Callable");
return "Callable Result";
}
});
try {
System.out.println("future.get() = " + future.get());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
@Test
public void createUserInfoVo(){
ExecutorService executorService = Executors.newFixedThreadPool(200);
long start = System.currentTimeMillis();
for(int i=0;i<1000000;i++){
int num = i+1;
Future future = executorService.submit(new Callable(){
public Object call() throws Exception {
ChimeUserInfoDto chimeUserInfoDto = ChimeUserInfoDto.getNew();
chimeUserInfoDto.setUserId("TEST"+ IDGenerator.nextTimeId());
chimeUserInfoDto.setPassWord("123456");
chimeUserInfoDto.setSex("男");
chimeUserInfoDto.setUserName("TestName"+num);
chimeUserInfoDto.setUserMobile("1381111"+num);
chimeUserInfoDto.setAvatar("https://img.zhengzai.tv/user/2021/07/27/a4cc2a4e6dcd44d1812dc60e079086b4.png");
chimeUserInfoDto.setUserCover("https://img.zhengzai.tv/user/2021/07/27/a4cc2a4e6dcd44d1812dc60e079086b4.png");
chimeUserInfoDto.setBirthday("2021-09-01");
chimeUserInfoDto.setSignature("测试签名");
chimeUserInfoDto.setArea("山西省 太原市 迎泽区");
chimeUserInfoDto.setJoinPerformanceId("-1");
// easemobUtil.createUser(chimeUserInfoDto.getUserId(),chimeUserInfoDto.getPassWord());
dataUtils.createChimeUser(chimeUserInfoDto);
//插入userTagMapping
List<ChimeUserTagsMappingVo> userTagList = new ArrayList<>();
for(int j=0;j<5;j++){
ChimeUserTagsMappingVo chimeUserTagDto = ChimeUserTagsMappingVo.getNew();
chimeUserTagDto.setUserId(chimeUserInfoDto.getUserId());
chimeUserTagDto.setTagCode("tags"+(j+1));
chimeUserTagDto.setTagDesc("标签"+(j+1));
userTagList.add(chimeUserTagDto);
}
dataUtils.createUserTagMapping(userTagList);
return Boolean.parseBoolean("true");
}
});
// Future future = executorService.submit(new Runnable() {
// public void run() {
// ChimeUserInfoDto chimeUserInfoDto = ChimeUserInfoDto.getNew();
// chimeUserInfoDto.setUserId("TEST"+ IDGenerator.nextTimeId());
// chimeUserInfoDto.setPassWord("123456");
// chimeUserInfoDto.setSex("男");
// chimeUserInfoDto.setUserName("TestName"+num);
// chimeUserInfoDto.setUserMobile("1381111"+num);
// chimeUserInfoDto.setAvatar("https://img.zhengzai.tv/user/2021/07/27/a4cc2a4e6dcd44d1812dc60e079086b4.png");
// chimeUserInfoDto.setUserCover("https://img.zhengzai.tv/user/2021/07/27/a4cc2a4e6dcd44d1812dc60e079086b4.png");
// chimeUserInfoDto.setBirthday("2021-09-01");
// chimeUserInfoDto.setSignature("测试签名");
// chimeUserInfoDto.setArea("山西省 太原市 迎泽区");
// chimeUserInfoDto.setJoinPerformanceId("-1");
// List<ChimeUserTagDto> imgList = new ArrayList<>();
// for(int j=0;j<5;j++){
// ChimeUserTagDto chimeUserTagDto = ChimeUserTagDto.getNew();
// chimeUserTagDto.setUserId(chimeUserInfoDto.getUserId());
// chimeUserTagDto.setTagCode("tags"+(j+1));
// chimeUserTagDto.setTagDesc("标签"+(j+1));
// imgList.add(chimeUserTagDto);
// }
// chimeUserInfoDto.setUserTags(imgList);
//// easemobUtil.createUser(chimeUserInfoDto.getUserId(),chimeUserInfoDto.getPassWord());
// dataUtils.createChimeUser(chimeUserInfoDto);
// }
// });
try {
System.out.println("执行第几个===="+num+" future.get()=="+future.get());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
System.out.println("耗时:"+(System.currentTimeMillis() - start)/1000 + "秒");
executorService.shutdown();
// EasemobUtil.createUsers();
}
@Test
public void testUserList(){
for(int i=0;i<10;i++){
long startTime = System.currentTimeMillis();
ChimeUserListQueryReqDto reqDto = ChimeUserListQueryReqDto.getNew();
// reqDto.setPerformanceId("-1");
reqDto.setPerformanceId("-1");
reqDto.setPageNum(1);
reqDto.setPageSize(50);
reqDto.setOrderItem(null);
reqDto.setOrderSc(null);
reqDto.setSex("男");
// reqDto.setTags("");
// PageInfo<ChimeUserInfoDto> pageInfo = chimePerformanceService.getUserListByCon(reqDto);
NewPageResult<ChimeUserInfoDto> pageInfo = chimePerformanceService.getUserListByCon(reqDto);
long endTime = System.currentTimeMillis();
log.info("耗时:{}ms",endTime-startTime);
}
}
}
......@@ -28,7 +28,8 @@ public class TestShumei {
public void checkText(){
// System.out.println(shumeiUtil.checkText("user123","甜梅号的小茉莉"));
System.out.println(shumeiUtil.checkText("user123","158****8858"));
// System.out.println(shumeiUtil.checkText("user123","158****8858"));
System.out.println(shumeiUtil.checkText("user123","投毒"));
}
@Test
public void checkImage(){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment