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

Commit a1792093 authored by 张国柄's avatar 张国柄

fix;

parent bea198a7
...@@ -196,6 +196,15 @@ public class AdamRdmService { ...@@ -196,6 +196,15 @@ public class AdamRdmService {
return thirdPartInfoVos; return thirdPartInfoVos;
} }
public boolean addThirdPartVoListByUid(String uid, List<AdamThirdPartInfoVo> vos, AdamThirdPartInfoVo vo) {
if (CollectionUtils.isEmpty(vos)) {
vos = Collections.singletonList(vo);
} else {
vos.add(vo);
}
return redisUtil.set(AdamRedisConst.INFO_THIRD_PARTY + uid, vos);
}
public AdamThirdPartInfoVo getThirdPartVoByUidPlatform(String uid, String platform) { public AdamThirdPartInfoVo getThirdPartVoByUidPlatform(String uid, String platform) {
List<AdamThirdPartInfoVo> vos = this.getThirdPartVoListByUid(uid); List<AdamThirdPartInfoVo> vos = this.getThirdPartVoListByUid(uid);
if (!CollectionUtils.isEmpty(vos)) { if (!CollectionUtils.isEmpty(vos)) {
......
...@@ -6,33 +6,22 @@ import com.liquidnet.service.adam.constant.AdamRedisConst; ...@@ -6,33 +6,22 @@ import com.liquidnet.service.adam.constant.AdamRedisConst;
import com.liquidnet.service.adam.dto.vo.*; import com.liquidnet.service.adam.dto.vo.*;
import com.liquidnet.service.kylin.constant.KylinRedisConst; import com.liquidnet.service.kylin.constant.KylinRedisConst;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinPerformanceVo; import com.liquidnet.service.kylin.dto.vo.mongo.KylinPerformanceVo;
import com.liquidnet.service.platform.utils.NknameUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service("adamRdmService") @Service("adamRdmService")
public class DMRdmService { public class DMRdmService {
@Autowired // @Autowired
MongoTemplate mongoTemplate; // MongoTemplate mongoTemplate;
@Autowired @Autowired
RedisUtil redisUtil; RedisUtil redisUtil;
...@@ -52,42 +41,24 @@ public class DMRdmService { ...@@ -52,42 +41,24 @@ public class DMRdmService {
public List<String> getNknameList() { public List<String> getNknameList() {
ArrayList<String> list = (ArrayList<String>) redisUtil.get(AdamRedisConst.INFO_LIBRARY_NKNAME); ArrayList<String> list = (ArrayList<String>) redisUtil.get(AdamRedisConst.INFO_LIBRARY_NKNAME);
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
InputStream inputStream = null; list = NknameUtil.readForStringList();
InputStreamReader inputStreamReader = null;
BufferedReader bufferedReader = null;
try {
inputStream = this.getClass().getClassLoader().getResourceAsStream("META-FIL/library_nickname.csv");
inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
bufferedReader = new BufferedReader(inputStreamReader);
String line;
while ((line = bufferedReader.readLine()) != null) {
int l = org.apache.commons.lang3.StringUtils.length(line);
if (l == 0) {
break;
}
if (l > 11) {
line = line.substring(0, 11);
}
list.add(line);
}
} catch (IOException e) {
log.error("Read CSV[library_nickname.csv] failure.", e);
} finally {
try {
if (null != bufferedReader) bufferedReader.close();
if (null != inputStreamReader) inputStreamReader.close();
if (null != inputStream) inputStream.close();
} catch (IOException e) {
log.error("Close stream failure.", e);
}
}
if (!CollectionUtils.isEmpty(list)) redisUtil.set(AdamRedisConst.INFO_LIBRARY_NKNAME, list); if (!CollectionUtils.isEmpty(list)) redisUtil.set(AdamRedisConst.INFO_LIBRARY_NKNAME, list);
} }
return list; return list;
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <Mobile, SMS CODE> */
public boolean setSmsCodeByMobile(String mobile, String smsCode) {
// TODO: 2021/7/29 改为1分钟
return redisUtil.set(AdamRedisConst.VALID_SMS_CODE_MOBILE + mobile, smsCode, 60);
}
public String getSmsCodeByMobile(String mobile) {
return (String) redisUtil.get(AdamRedisConst.VALID_SMS_CODE_MOBILE + mobile);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <Mobile|OPENID, UID> */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <Mobile|OPENID, UID> */
public boolean setUidByMobile(String mobile, String uid) { public boolean setUidByMobile(String mobile, String uid) {
...@@ -98,17 +69,17 @@ public class DMRdmService { ...@@ -98,17 +69,17 @@ public class DMRdmService {
String key = AdamRedisConst.IDENTITY_MOBILE.concat(mobile); String key = AdamRedisConst.IDENTITY_MOBILE.concat(mobile);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
String val = (String) redisUtil.get(key); String val = (String) redisUtil.get(key);
if (StringUtils.isEmpty(val)) { // if (StringUtils.isEmpty(val)) {
Query query = Query.query(Criteria.where("mobile").is(mobile).and("state").is(1)); // Query query = Query.query(Criteria.where("mobile").is(mobile).and("state").is(1));
query.fields().include("uid"); // query.fields().include("uid");
s = System.currentTimeMillis(); // s = System.currentTimeMillis();
AdamUserInfoVo vo = mongoTemplate.findOne(query, AdamUserInfoVo.class, AdamUserInfoVo.class.getSimpleName()); // AdamUserInfoVo vo = mongoTemplate.findOne(query, AdamUserInfoVo.class, AdamUserInfoVo.class.getSimpleName());
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
if (null != vo) { // if (null != vo) {
val = vo.getUid(); // val = vo.getUid();
redisUtil.set(key, vo.getUid()); // redisUtil.set(key, vo.getUid());
} // }
} // }
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s); log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s);
return val; return val;
} }
...@@ -125,17 +96,17 @@ public class DMRdmService { ...@@ -125,17 +96,17 @@ public class DMRdmService {
String key = AdamRedisConst.IDENTITY_THIRD_PARTY + platform + ":" + openId; String key = AdamRedisConst.IDENTITY_THIRD_PARTY + platform + ":" + openId;
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
String val = (String) redisUtil.get(key); String val = (String) redisUtil.get(key);
if (StringUtils.isEmpty(val)) { // if (StringUtils.isEmpty(val)) {
Query query = Query.query(Criteria.where("openId").is(openId).and("platform").is(platform).and("state").is(1)); // Query query = Query.query(Criteria.where("openId").is(openId).and("platform").is(platform).and("state").is(1));
query.fields().include("uid"); // query.fields().include("uid");
s = System.currentTimeMillis(); // s = System.currentTimeMillis();
AdamThirdPartInfoVo vo = mongoTemplate.findOne(query, AdamThirdPartInfoVo.class, AdamThirdPartInfoVo.class.getSimpleName()); // AdamThirdPartInfoVo vo = mongoTemplate.findOne(query, AdamThirdPartInfoVo.class, AdamThirdPartInfoVo.class.getSimpleName());
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
if (null != vo) { // if (null != vo) {
val = vo.getUid(); // val = vo.getUid();
redisUtil.set(key, vo.getUid()); // redisUtil.set(key, vo.getUid());
} // }
} // }
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s); log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s);
return val; return val;
} }
...@@ -154,14 +125,14 @@ public class DMRdmService { ...@@ -154,14 +125,14 @@ public class DMRdmService {
String rk = AdamRedisConst.INFO_USER.concat(uid); String rk = AdamRedisConst.INFO_USER.concat(uid);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
AdamUserInfoVo vo = (AdamUserInfoVo) redisUtil.get(rk); AdamUserInfoVo vo = (AdamUserInfoVo) redisUtil.get(rk);
if (null == vo) { // if (null == vo) {
s = System.currentTimeMillis(); // s = System.currentTimeMillis();
vo = mongoTemplate.findOne(Query.query(Criteria.where("uid").is(uid).and("state").is(1)), // vo = mongoTemplate.findOne(Query.query(Criteria.where("uid").is(uid).and("state").is(1)),
AdamUserInfoVo.class, AdamUserInfoVo.class.getSimpleName()); // AdamUserInfoVo.class, AdamUserInfoVo.class.getSimpleName());
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
//
if (null != vo) redisUtil.set(rk, vo); // if (null != vo) redisUtil.set(rk, vo);
} // }
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s); log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s);
return vo; return vo;
} }
...@@ -180,14 +151,14 @@ public class DMRdmService { ...@@ -180,14 +151,14 @@ public class DMRdmService {
String rk = AdamRedisConst.INFO_REAL_NAME.concat(uid); String rk = AdamRedisConst.INFO_REAL_NAME.concat(uid);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
AdamRealInfoVo vo = (AdamRealInfoVo) redisUtil.get(rk); AdamRealInfoVo vo = (AdamRealInfoVo) redisUtil.get(rk);
if (null == vo) { // if (null == vo) {
s = System.currentTimeMillis(); // s = System.currentTimeMillis();
vo = mongoTemplate.findOne(Query.query(Criteria.where("uid").is(uid).and("state").is(1)), // vo = mongoTemplate.findOne(Query.query(Criteria.where("uid").is(uid).and("state").is(1)),
AdamRealInfoVo.class, AdamRealInfoVo.class.getSimpleName()); // AdamRealInfoVo.class, AdamRealInfoVo.class.getSimpleName());
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
//
if (null != vo) redisUtil.set(rk, vo); // if (null != vo) redisUtil.set(rk, vo);
} // }
if (null != vo) { if (null != vo) {
vo.setName(SensitizeUtil.chineseName(vo.getName())); vo.setName(SensitizeUtil.chineseName(vo.getName()));
vo.setIdCard(SensitizeUtil.custom(vo.getIdCard(), 3, 2)); vo.setIdCard(SensitizeUtil.custom(vo.getIdCard(), 3, 2));
...@@ -217,18 +188,27 @@ public class DMRdmService { ...@@ -217,18 +188,27 @@ public class DMRdmService {
String rk = AdamRedisConst.INFO_THIRD_PARTY.concat(uid); String rk = AdamRedisConst.INFO_THIRD_PARTY.concat(uid);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
List<AdamThirdPartInfoVo> thirdPartInfoVos = (List<AdamThirdPartInfoVo>) redisUtil.get(rk); List<AdamThirdPartInfoVo> thirdPartInfoVos = (List<AdamThirdPartInfoVo>) redisUtil.get(rk);
if (CollectionUtils.isEmpty(thirdPartInfoVos)) { // if (CollectionUtils.isEmpty(thirdPartInfoVos)) {
s = System.currentTimeMillis(); // s = System.currentTimeMillis();
thirdPartInfoVos = mongoTemplate.find(Query.query(Criteria.where("uid").is(uid).and("state").is(1)), // thirdPartInfoVos = mongoTemplate.find(Query.query(Criteria.where("uid").is(uid).and("state").is(1)),
AdamThirdPartInfoVo.class, AdamThirdPartInfoVo.class.getSimpleName()); // AdamThirdPartInfoVo.class, AdamThirdPartInfoVo.class.getSimpleName());
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
//
if (!CollectionUtils.isEmpty(thirdPartInfoVos)) redisUtil.set(rk, thirdPartInfoVos); // if (!CollectionUtils.isEmpty(thirdPartInfoVos)) redisUtil.set(rk, thirdPartInfoVos);
} // }
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s); log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s);
return thirdPartInfoVos; return thirdPartInfoVos;
} }
public boolean addThirdPartVoListByUid(String uid, List<AdamThirdPartInfoVo> vos, AdamThirdPartInfoVo vo) {
if (CollectionUtils.isEmpty(vos)) {
vos = Collections.singletonList(vo);
} else {
vos.add(vo);
}
return redisUtil.set(AdamRedisConst.INFO_THIRD_PARTY + uid, vos);
}
public AdamThirdPartInfoVo getThirdPartVoByUidPlatform(String uid, String platform) { public AdamThirdPartInfoVo getThirdPartVoByUidPlatform(String uid, String platform) {
List<AdamThirdPartInfoVo> vos = this.getThirdPartVoListByUid(uid); List<AdamThirdPartInfoVo> vos = this.getThirdPartVoListByUid(uid);
if (!CollectionUtils.isEmpty(vos)) { if (!CollectionUtils.isEmpty(vos)) {
...@@ -256,18 +236,39 @@ public class DMRdmService { ...@@ -256,18 +236,39 @@ public class DMRdmService {
String rk = AdamRedisConst.INFO_ENTERS.concat(uid); String rk = AdamRedisConst.INFO_ENTERS.concat(uid);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
List<AdamEntersVo> vos = (List<AdamEntersVo>) redisUtil.get(rk); List<AdamEntersVo> vos = (List<AdamEntersVo>) redisUtil.get(rk);
// if (CollectionUtils.isEmpty(vos)) {
// s = System.currentTimeMillis();
// vos = mongoTemplate.find(
// Query.query(Criteria.where("uid").is(uid).and("state").is(1)).with(Sort.by(Sort.Direction.DESC, "createdAt")),
// AdamEntersVo.class, AdamEntersVo.class.getSimpleName()
// );
// log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
//
// if (!CollectionUtils.isEmpty(vos)) redisUtil.set(rk, vos);
// }
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s);
return vos;
}
public boolean addEntersVoByUid(String uid, List<AdamEntersVo> vos, AdamEntersVo vo) {
if (CollectionUtils.isEmpty(vos)) { if (CollectionUtils.isEmpty(vos)) {
s = System.currentTimeMillis(); vos = Collections.singletonList(vo);
vos = mongoTemplate.find( } else {
Query.query(Criteria.where("uid").is(uid).and("state").is(1)).with(Sort.by(Sort.Direction.DESC, "createdAt")), vos.add(vo);
AdamEntersVo.class, AdamEntersVo.class.getSimpleName() }
); return redisUtil.set(AdamRedisConst.INFO_ENTERS + uid, vos);
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); }
if (!CollectionUtils.isEmpty(vos)) redisUtil.set(rk, vos); public boolean rmvEntersVoByUid(String uid, List<AdamEntersVo> vos, String entersId) {
if (CollectionUtils.isEmpty(vos)) {
return true;
} }
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s); vos.removeIf(r -> r.getEntersId().equals(entersId));
return vos; return redisUtil.set(AdamRedisConst.INFO_ENTERS + uid, vos);
}
public AdamEntersVo getEntersVoByUidEntersId(List<AdamEntersVo> vos, String entersId) {
return vos.stream().filter(r -> r.getEntersId().equals(entersId)).findAny().orElse(null);
} }
public AdamEntersVo getEntersVoByUidEntersId(String uid, String entersId) { public AdamEntersVo getEntersVoByUidEntersId(String uid, String entersId) {
...@@ -293,18 +294,39 @@ public class DMRdmService { ...@@ -293,18 +294,39 @@ public class DMRdmService {
String rk = AdamRedisConst.INFO_ADDRESSES.concat(uid); String rk = AdamRedisConst.INFO_ADDRESSES.concat(uid);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
List<AdamAddressesVo> vos = (List<AdamAddressesVo>) redisUtil.get(rk); List<AdamAddressesVo> vos = (List<AdamAddressesVo>) redisUtil.get(rk);
// if (CollectionUtils.isEmpty(vos)) {
// s = System.currentTimeMillis();
// vos = mongoTemplate.find(
// Query.query(Criteria.where("uid").is(uid).and("state").is(1)).with(Sort.by(Sort.Direction.DESC, "createdAt")),
// AdamAddressesVo.class, AdamAddressesVo.class.getSimpleName()
// );
// log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
//
// if (!CollectionUtils.isEmpty(vos)) redisUtil.set(rk, vos);
// }
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s);
return vos;
}
public boolean addAddressesVoByUid(String uid, List<AdamAddressesVo> vos, AdamAddressesVo vo) {
if (CollectionUtils.isEmpty(vos)) { if (CollectionUtils.isEmpty(vos)) {
s = System.currentTimeMillis(); vos = Collections.singletonList(vo);
vos = mongoTemplate.find( } else {
Query.query(Criteria.where("uid").is(uid).and("state").is(1)).with(Sort.by(Sort.Direction.DESC, "createdAt")), vos.add(vo);
AdamAddressesVo.class, AdamAddressesVo.class.getSimpleName() }
); return redisUtil.set(AdamRedisConst.INFO_ADDRESSES + uid, vos);
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); }
if (!CollectionUtils.isEmpty(vos)) redisUtil.set(rk, vos); public boolean rmvAddressesVoByUid(String uid, List<AdamAddressesVo> vos, String addressesId) {
if (CollectionUtils.isEmpty(vos)) {
return true;
} }
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s); vos.removeIf(r -> r.getAddressesId().equals(addressesId));
return vos; return redisUtil.set(AdamRedisConst.INFO_ADDRESSES + uid, vos);
}
public AdamAddressesVo getAddressesVoByUidAddressesId(List<AdamAddressesVo> vos, String addressesId) {
return vos.stream().filter(r -> r.getAddressesId().equals(addressesId)).findAny().orElse(null);
} }
public AdamAddressesVo getAddressesVoByUidAddressesId(String uid, String addressesId) { public AdamAddressesVo getAddressesVoByUidAddressesId(String uid, String addressesId) {
...@@ -335,13 +357,13 @@ public class DMRdmService { ...@@ -335,13 +357,13 @@ public class DMRdmService {
String rk = AdamRedisConst.INFO_USER_MEMBER.concat(uid); String rk = AdamRedisConst.INFO_USER_MEMBER.concat(uid);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
AdamUserMemberVo vo = (AdamUserMemberVo) redisUtil.get(rk); AdamUserMemberVo vo = (AdamUserMemberVo) redisUtil.get(rk);
if (null == vo) { // if (null == vo) {
s = System.currentTimeMillis(); // s = System.currentTimeMillis();
vo = mongoTemplate.findOne(Query.query(Criteria.where("uid").is(uid)), AdamUserMemberVo.class, AdamUserMemberVo.class.getSimpleName()); // vo = mongoTemplate.findOne(Query.query(Criteria.where("uid").is(uid)), AdamUserMemberVo.class, AdamUserMemberVo.class.getSimpleName());
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
//
if (null != vo) redisUtil.set(rk, vo); // if (null != vo) redisUtil.set(rk, vo);
} // }
if (null != vo) { if (null != vo) {
vo.setState(vo.getState() == 1 ? (vo.getExpiryAt().isAfter(LocalDateTime.now()) ? 1 : 2) : vo.getState()); vo.setState(vo.getState() == 1 ? (vo.getExpiryAt().isAfter(LocalDateTime.now()) ? 1 : 2) : vo.getState());
} }
...@@ -356,19 +378,21 @@ public class DMRdmService { ...@@ -356,19 +378,21 @@ public class DMRdmService {
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <MEMBER_SIMPLE_INFO> */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <MEMBER_SIMPLE_INFO> */
public AdamMemberSimpleVo getMemberSimpleVo() { public AdamMemberSimpleVo getMemberSimpleVo() {
long s = System.currentTimeMillis();
AdamMemberSimpleVo vo = (AdamMemberSimpleVo) redisUtil.get(AdamRedisConst.INFO_MEMBER_SIMPLE); AdamMemberSimpleVo vo = (AdamMemberSimpleVo) redisUtil.get(AdamRedisConst.INFO_MEMBER_SIMPLE);
if (null == vo) { // if (null == vo) {
long s = System.currentTimeMillis(); // long s = System.currentTimeMillis();
List<AdamMemberSimpleVo> vos = mongoTemplate.find( // List<AdamMemberSimpleVo> vos = mongoTemplate.find(
Query.query(Criteria.where("state").is(1)).with(Sort.by(Sort.Direction.ASC, "memberId")), // Query.query(Criteria.where("state").is(1)).with(Sort.by(Sort.Direction.ASC, "memberId")),
AdamMemberSimpleVo.class, AdamMemberVo.class.getSimpleName() // AdamMemberSimpleVo.class, AdamMemberVo.class.getSimpleName()
); // );
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
//
vo = CollectionUtils.isEmpty(vos) ? null : vos.get(0); // vo = CollectionUtils.isEmpty(vos) ? null : vos.get(0);
//
if (null != vo) redisUtil.set(AdamRedisConst.INFO_MEMBER_SIMPLE, vo); // if (null != vo) redisUtil.set(AdamRedisConst.INFO_MEMBER_SIMPLE, vo);
} // }
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s);
return vo; return vo;
} }
...@@ -382,15 +406,15 @@ public class DMRdmService { ...@@ -382,15 +406,15 @@ public class DMRdmService {
String key = AdamRedisConst.INFO_MEMBER_CATEGORY.concat(memberId); String key = AdamRedisConst.INFO_MEMBER_CATEGORY.concat(memberId);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
AdamMemberVo vo = (AdamMemberVo) redisUtil.get(key); AdamMemberVo vo = (AdamMemberVo) redisUtil.get(key);
if (null == vo) { // if (null == vo) {
s = System.currentTimeMillis(); // s = System.currentTimeMillis();
vo = mongoTemplate.findOne( // vo = mongoTemplate.findOne(
Query.query(Criteria.where("memberId").is(memberId).and("state").is(1)), // Query.query(Criteria.where("memberId").is(memberId).and("state").is(1)),
AdamMemberVo.class, AdamMemberVo.class.getSimpleName() // AdamMemberVo.class, AdamMemberVo.class.getSimpleName()
); // );
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
if (null != vo) redisUtil.set(key, vo); // if (null != vo) redisUtil.set(key, vo);
} // }
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s); log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s);
return vo; return vo;
} }
...@@ -409,22 +433,21 @@ public class DMRdmService { ...@@ -409,22 +433,21 @@ public class DMRdmService {
String key = AdamRedisConst.INFO_MEMBER_PRICE.concat(memberId); String key = AdamRedisConst.INFO_MEMBER_PRICE.concat(memberId);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
List<AdamMemberPriceVo> vos = (List<AdamMemberPriceVo>) redisUtil.get(key); List<AdamMemberPriceVo> vos = (List<AdamMemberPriceVo>) redisUtil.get(key);
if (CollectionUtils.isEmpty(vos)) { // if (CollectionUtils.isEmpty(vos)) {
s = System.currentTimeMillis(); // s = System.currentTimeMillis();
vos = mongoTemplate.find( // vos = mongoTemplate.find(
Query.query(Criteria.where("memberId").is(memberId).and("state").is(1)), // Query.query(Criteria.where("memberId").is(memberId).and("state").is(1)),
AdamMemberPriceVo.class, AdamMemberPriceVo.class.getSimpleName() // AdamMemberPriceVo.class, AdamMemberPriceVo.class.getSimpleName()
); // );
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
//
if (!CollectionUtils.isEmpty(vos)) redisUtil.set(key, vos); // if (!CollectionUtils.isEmpty(vos)) redisUtil.set(key, vos);
} // }
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s); log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s);
return vos; return vos;
} }
public AdamMemberPriceVo getMemberPriceVoByPriceId(String memberId, String memberPriceId) { public AdamMemberPriceVo getMemberPriceVoByPriceId(String memberId, String memberPriceId) {
long s = System.currentTimeMillis();
List<AdamMemberPriceVo> vos = this.getMemberPriceVoByMemberId(memberId); List<AdamMemberPriceVo> vos = this.getMemberPriceVoByMemberId(memberId);
if (!CollectionUtils.isEmpty(vos)) { if (!CollectionUtils.isEmpty(vos)) {
// for (AdamMemberPriceVo r : vos) { // for (AdamMemberPriceVo r : vos) {
...@@ -476,6 +499,40 @@ public class DMRdmService { ...@@ -476,6 +499,40 @@ public class DMRdmService {
return val; return val;
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <UID, MEMBER_ORDER_LIST(SUCC)> */
public boolean setMemberOrderVosByUid(String uid, List<AdamMemberOrderVo> vos) {
return redisUtil.set(AdamRedisConst.INFO_MEMBER_ORDER + uid, vos);
}
public ArrayList<AdamMemberOrderVo> getMemberOrderVosByUid(String uid) {
long s = System.currentTimeMillis();
ArrayList<AdamMemberOrderVo> vos = (ArrayList<AdamMemberOrderVo>) redisUtil.get(AdamRedisConst.INFO_MEMBER_ORDER + uid);
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s);
return vos;
}
public boolean addMemberOrderVoByUid(String uid, List<AdamMemberOrderVo> vos, AdamMemberOrderVo vo) {
if (CollectionUtils.isEmpty(vos)) {
vos = Collections.singletonList(vo);
} else {
vos.add(vo);
}
return redisUtil.set(AdamRedisConst.INFO_MEMBER_ORDER + uid, vos);
}
public boolean rmvMemberOrderVoByUid(String uid, List<AdamMemberOrderVo> vos, String orderNo) {
if (CollectionUtils.isEmpty(vos)) {
return true;
}
vos.removeIf(r -> r.getOrderNo().equals(orderNo));
return redisUtil.set(AdamRedisConst.INFO_MEMBER_ORDER + uid, vos);
}
public void delMemberOrderVoByUid(String uid) {
redisUtil.del(AdamRedisConst.INFO_MEMBER_ORDER + uid);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <ORDER_NO, MEMBER_ORDER_INFO> */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <ORDER_NO, MEMBER_ORDER_INFO> */
public boolean setShotMemberOrderVoByOrderNo(String orderNo, AdamMemberOrderVo vo) { public boolean setShotMemberOrderVoByOrderNo(String orderNo, AdamMemberOrderVo vo) {
...@@ -486,16 +543,16 @@ public class DMRdmService { ...@@ -486,16 +543,16 @@ public class DMRdmService {
String key = AdamRedisConst.SHOT_MEMBER_ORDER + orderNo; String key = AdamRedisConst.SHOT_MEMBER_ORDER + orderNo;
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
AdamMemberOrderVo vo = (AdamMemberOrderVo) redisUtil.get(key); AdamMemberOrderVo vo = (AdamMemberOrderVo) redisUtil.get(key);
if (null == vo) { // if (null == vo) {
s = System.currentTimeMillis(); // s = System.currentTimeMillis();
vo = mongoTemplate.findOne( // vo = mongoTemplate.findOne(
Query.query(Criteria.where("orderNo").is(orderNo)), // Query.query(Criteria.where("orderNo").is(orderNo)),
AdamMemberOrderVo.class, AdamMemberOrderVo.class.getSimpleName() // AdamMemberOrderVo.class, AdamMemberOrderVo.class.getSimpleName()
); // );
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
//
if (null != vo) redisUtil.set(key, vo); // if (null != vo) redisUtil.set(key, vo);
} // }
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s); log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s);
return vo; return vo;
} }
...@@ -529,15 +586,15 @@ public class DMRdmService { ...@@ -529,15 +586,15 @@ public class DMRdmService {
String key = AdamRedisConst.INFO_MEMBER_CODE.concat(memberCode); String key = AdamRedisConst.INFO_MEMBER_CODE.concat(memberCode);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
AdamMemberCodeVo vo = (AdamMemberCodeVo) redisUtil.get(key); AdamMemberCodeVo vo = (AdamMemberCodeVo) redisUtil.get(key);
if (null == vo) { // if (null == vo) {
s = System.currentTimeMillis(); // s = System.currentTimeMillis();
vo = mongoTemplate.findOne( // vo = mongoTemplate.findOne(
Query.query(Criteria.where("code").is(memberCode)), // Query.query(Criteria.where("code").is(memberCode)),
AdamMemberCodeVo.class, AdamMemberCodeVo.class.getSimpleName() // AdamMemberCodeVo.class, AdamMemberCodeVo.class.getSimpleName()
); // );
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
if (null != vo && vo.getState() == 0) redisUtil.set(AdamRedisConst.INFO_MEMBER_CODE.concat(memberCode), vo); // if (null != vo && vo.getState() == 0) redisUtil.set(AdamRedisConst.INFO_MEMBER_CODE.concat(memberCode), vo);
} // }
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s); log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s);
return vo; return vo;
} }
...@@ -546,19 +603,37 @@ public class DMRdmService { ...@@ -546,19 +603,37 @@ public class DMRdmService {
redisUtil.del(AdamRedisConst.INFO_MEMBER_CODE.concat(memberCode)); redisUtil.del(AdamRedisConst.INFO_MEMBER_CODE.concat(memberCode));
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <AdamMemberCodeVo::buyOrderNo, MEMBER_CODE> */
public boolean setMemberCodeByBuyOrderNo(String buyOrderNo, String memberCode) {
return redisUtil.set(AdamRedisConst.INFO_BUY_MEMBER_ORDER_CODE + buyOrderNo, memberCode);
}
public String getMemberCodeByBuyOrderNo(String buyOrderNo) {
return (String) redisUtil.get(AdamRedisConst.INFO_BUY_MEMBER_ORDER_CODE + buyOrderNo);
}
public void delMemberCodeByBuyOrderNo(String buyOrderNo) {
redisUtil.del(AdamRedisConst.INFO_BUY_MEMBER_ORDER_CODE + buyOrderNo);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | */
/** /**
* Temporarily connect Mongo * Temporarily connect Mongo
*/ */
public AdamMemberCodeVo getMemberCodeVoByBuyOrderNo(String buyOrderNo) { public AdamMemberCodeVo getMemberCodeVoByBuyOrderNo(String buyOrderNo) {
Query query = Query.query(Criteria.where("buyOrderNo").is(buyOrderNo)); // Query query = Query.query(Criteria.where("buyOrderNo").is(buyOrderNo));
query.fields().include("code").include("memberNo").include("state").include("type"); // query.fields().include("code").include("memberNo").include("state").include("type");
long s = System.currentTimeMillis(); // long s = System.currentTimeMillis();
AdamMemberCodeVo vo = mongoTemplate.findOne( // AdamMemberCodeVo vo = mongoTemplate.findOne(
query, AdamMemberCodeVo.class, AdamMemberCodeVo.class.getSimpleName() // query, AdamMemberCodeVo.class, AdamMemberCodeVo.class.getSimpleName()
); // );
log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
// return vo;
// TODO: 2021/7/30 存在购买会员兑换码功能时,按需调整
AdamMemberCodeVo vo = AdamMemberCodeVo.getNew();
vo.setCode(this.getMemberCodeByBuyOrderNo(buyOrderNo));
return vo; return vo;
} }
......
...@@ -2,7 +2,6 @@ package com.liquidnet.service.platform.service.impl.adam.dm; ...@@ -2,7 +2,6 @@ package com.liquidnet.service.platform.service.impl.adam.dm;
import com.liquidnet.service.adam.mapper.AdamUserMapper; import com.liquidnet.service.adam.mapper.AdamUserMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
...@@ -30,8 +29,8 @@ public abstract class DataMigrationProcessorService { ...@@ -30,8 +29,8 @@ public abstract class DataMigrationProcessorService {
// public static final String DB_PWD = "zhengzai!mYT"; // public static final String DB_PWD = "zhengzai!mYT";
// public static final String DB_NAME_PASSPORT = "devpassport"; // public static final String DB_NAME_PASSPORT = "devpassport";
@Autowired // @Autowired
public MongoTemplate mongoTemplate; // public MongoTemplate mongoTemplate;
@Autowired @Autowired
public DMRdmService dmRdmService; public DMRdmService dmRdmService;
@Autowired @Autowired
......
...@@ -31,10 +31,10 @@ public class DMAddressesProcessor extends DataMigrationProcessorService { ...@@ -31,10 +31,10 @@ public class DMAddressesProcessor extends DataMigrationProcessorService {
public void dataProcessing(Integer dg, Integer dG, String incrDt, String flg, String flu) { public void dataProcessing(Integer dg, Integer dG, String incrDt, String flg, String flu) {
if (StringUtils.isNotEmpty(flu)) { if (StringUtils.isNotEmpty(flu)) {
log.info("DM.flush.addresses:{}", userMapper.executeForDM("adam_addresses")); log.info("DM.flush.addresses:{}", userMapper.executeForDM("adam_addresses"));
log.info("DM.flush.AdamAddressesVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamAddressesVo.class.getSimpleName()).getDeletedCount()); // log.info("DM.flush.AdamAddressesVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamAddressesVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from addresses where created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()"; String sqlCount = "select count(1) from addresses where created_at" + (StringUtils.isBlank(incrDt) ? "<curdate()" : (">=curdate()-" + incrDt));
if (null != dg) { if (null != dg) {
sqlCount = sqlCount + " and id%" + dG + "=" + dg; sqlCount = sqlCount + " and id%" + dG + "=" + dg;
} }
...@@ -92,10 +92,13 @@ public class DMAddressesProcessor extends DataMigrationProcessorService { ...@@ -92,10 +92,13 @@ public class DMAddressesProcessor extends DataMigrationProcessorService {
addressesList.add(addresses); addressesList.add(addresses);
vos.add(vo); vos.add(vo);
dmRdmService.addAddressesVoByUid(uid, dmRdmService.getAddressesVoByUid(uid), vo);
} }
if (addressesList.size() == 500 || (addressesList.size() > 0 && smFlg)) { if (addressesList.size() == 500 || (addressesList.size() > 0 && smFlg)) {
tl += addressesList.size(); tl += addressesList.size();
mongoTemplate.insert(vos, AdamAddressesVo.class.getSimpleName()); // mongoTemplate.insert(vos, AdamAddressesVo.class.getSimpleName());
log.info("DM.execute.limit.result:{}", dmAddressesService.saveBatch(addressesList)); log.info("DM.execute.limit.result:{}", dmAddressesService.saveBatch(addressesList));
vos.clear(); vos.clear();
addressesList.clear(); addressesList.clear();
......
...@@ -32,10 +32,10 @@ public class DMCollectionProcessor extends DataMigrationProcessorService { ...@@ -32,10 +32,10 @@ public class DMCollectionProcessor extends DataMigrationProcessorService {
if (StringUtils.isNotEmpty(flu)) { if (StringUtils.isNotEmpty(flu)) {
log.info("DM.flush.collection:{}", userMapper.executeForDM("adam_collection")); log.info("DM.flush.collection:{}", userMapper.executeForDM("adam_collection"));
log.info("DM.flush.AdamCollectVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamCollectBaseVo.class.getSimpleName()).getDeletedCount()); // log.info("DM.flush.AdamCollectVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamCollectBaseVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from user_collections where type='TICKET' and status=1 and content_id>=5722 and created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()"; String sqlCount = "select count(1) from user_collections where type='TICKET' and status=1 and content_id>=5722 and created_at" + (StringUtils.isBlank(incrDt) ? "<curdate()" : (">=curdate()-" + incrDt));
if (null != dg) { if (null != dg) {
sqlCount = sqlCount + " and id%" + dG + "=" + dg; sqlCount = sqlCount + " and id%" + dG + "=" + dg;
} }
...@@ -89,7 +89,7 @@ public class DMCollectionProcessor extends DataMigrationProcessorService { ...@@ -89,7 +89,7 @@ public class DMCollectionProcessor extends DataMigrationProcessorService {
} }
if (collectionList.size() == 500 || (collectionList.size() > 0 && smFlg)) { if (collectionList.size() == 500 || (collectionList.size() > 0 && smFlg)) {
tl += collectionList.size(); tl += collectionList.size();
mongoTemplate.insert(vos, AdamCollectBaseVo.class.getSimpleName()); // mongoTemplate.insert(vos, AdamCollectBaseVo.class.getSimpleName());
log.info("DM.execute.limit.result:{}", dmCollectionService.saveBatch(collectionList)); log.info("DM.execute.limit.result:{}", dmCollectionService.saveBatch(collectionList));
vos.clear(); vos.clear();
collectionList.clear(); collectionList.clear();
......
...@@ -32,11 +32,11 @@ public class DMEntersProcessor extends DataMigrationProcessorService { ...@@ -32,11 +32,11 @@ public class DMEntersProcessor extends DataMigrationProcessorService {
if (StringUtils.isNotEmpty(flu)) { if (StringUtils.isNotEmpty(flu)) {
log.info("DM.flush.enters:{}", userMapper.executeForDM("adam_enters")); log.info("DM.flush.enters:{}", userMapper.executeForDM("adam_enters"));
log.info("DM.flush.AdamEntersVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamEntersVo.class.getSimpleName()).getDeletedCount()); // log.info("DM.flush.AdamEntersVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamEntersVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from (\n" + String sqlCount = "select count(1) from (\n" +
" select row_number() over (partition by user_id,type,idcode,name order by updated_at desc) rn,e.* from enters e where e.is_certification = 'yes' and e.deleted_at is null and created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()\n" + " select row_number() over (partition by user_id,type,idcode,name order by updated_at desc) rn,e.* from enters e where e.is_certification = 'yes' and e.deleted_at is null and created_at" + (StringUtils.isBlank(incrDt) ? "<curdate()" : (">=curdate()-" + incrDt)) + "\n" +
" ) tk where tk.rn=1 "; " ) tk where tk.rn=1 ";
if (null != dg) { if (null != dg) {
sqlCount = sqlCount + " and id%" + dG + "=" + dg; sqlCount = sqlCount + " and id%" + dG + "=" + dg;
...@@ -98,10 +98,11 @@ public class DMEntersProcessor extends DataMigrationProcessorService { ...@@ -98,10 +98,11 @@ public class DMEntersProcessor extends DataMigrationProcessorService {
if (enters.getType() == 1) { if (enters.getType() == 1) {
dmRdmService.setCertification(1, enters.getIdCard(), enters.getName()); dmRdmService.setCertification(1, enters.getIdCard(), enters.getName());
} }
dmRdmService.addEntersVoByUid(uid, dmRdmService.getEntersVoByUid(uid), vo);
} }
if (entersList.size() == 500 || (entersList.size() > 0 && smFlg)) { if (entersList.size() == 500 || (entersList.size() > 0 && smFlg)) {
tl += entersList.size(); tl += entersList.size();
mongoTemplate.insert(vos, AdamEntersVo.class.getSimpleName()); // mongoTemplate.insert(vos, AdamEntersVo.class.getSimpleName());
log.info("DM.execute.limit.result:{}", dmEntersService.saveBatch(entersList)); log.info("DM.execute.limit.result:{}", dmEntersService.saveBatch(entersList));
vos.clear(); vos.clear();
entersList.clear(); entersList.clear();
......
...@@ -186,7 +186,7 @@ public class DMMemberCodeProcessor extends DataMigrationProcessorService { ...@@ -186,7 +186,7 @@ public class DMMemberCodeProcessor extends DataMigrationProcessorService {
if (StringUtils.isNotEmpty(flu)) { if (StringUtils.isNotEmpty(flu)) {
log.info("DM.flush.member_code:{}", userMapper.executeForDM("adam_member_code")); log.info("DM.flush.member_code:{}", userMapper.executeForDM("adam_member_code"));
log.info("DM.flush.AdamMemberCodeVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamMemberCodeVo.class.getSimpleName()).getDeletedCount()); // log.info("DM.flush.AdamMemberCodeVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamMemberCodeVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from vip_card_codes where buy_order_id <> use_order_id or status=0"; String sqlCount = "select count(1) from vip_card_codes where buy_order_id <> use_order_id or status=0";
...@@ -253,7 +253,7 @@ public class DMMemberCodeProcessor extends DataMigrationProcessorService { ...@@ -253,7 +253,7 @@ public class DMMemberCodeProcessor extends DataMigrationProcessorService {
// } // }
if (memberCodeList.size() == 500) { if (memberCodeList.size() == 500) {
tl += memberCodeList.size(); tl += memberCodeList.size();
mongoTemplate.insert(vos, AdamMemberCodeVo.class.getSimpleName()); // mongoTemplate.insert(vos, AdamMemberCodeVo.class.getSimpleName());
log.info("DM.execute.limit.result:{}", dmMemberCodeService.saveBatch(memberCodeList)); log.info("DM.execute.limit.result:{}", dmMemberCodeService.saveBatch(memberCodeList));
vos.clear(); vos.clear();
memberCodeList.clear(); memberCodeList.clear();
......
...@@ -56,10 +56,10 @@ public class DMMemberOrderProcessor extends DataMigrationProcessorService { ...@@ -56,10 +56,10 @@ public class DMMemberOrderProcessor extends DataMigrationProcessorService {
if (StringUtils.isNotEmpty(flu)) { if (StringUtils.isNotEmpty(flu)) {
log.info("DM.flush.member_order:{}", userMapper.executeForDM("adam_member_order")); log.info("DM.flush.member_order:{}", userMapper.executeForDM("adam_member_order"));
log.info("DM.flush.AdamMemberOrderVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamMemberOrderVo.class.getSimpleName()).getDeletedCount()); // log.info("DM.flush.AdamMemberOrderVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamMemberOrderVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from user_vip_card_orders where status in (1,5) and created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()"; String sqlCount = "select count(1) from user_vip_card_orders where status in (1,5) and created_at" + (StringUtils.isBlank(incrDt) ? "<curdate()" : (">=curdate()-" + incrDt));
if (null != dg) { if (null != dg) {
sqlCount = sqlCount + " and id%" + dG + "=" + dg; sqlCount = sqlCount + " and id%" + dG + "=" + dg;
} }
...@@ -129,10 +129,12 @@ public class DMMemberOrderProcessor extends DataMigrationProcessorService { ...@@ -129,10 +129,12 @@ public class DMMemberOrderProcessor extends DataMigrationProcessorService {
memberOrderList.add(memberOrder); memberOrderList.add(memberOrder);
vos.add(vo); vos.add(vo);
dmRdmService.addMemberOrderVoByUid(uid, dmRdmService.getMemberOrderVosByUid(uid), vo);
} }
if (memberOrderList.size() == 500 || (memberOrderList.size() > 0 && smFlg)) { if (memberOrderList.size() == 500 || (memberOrderList.size() > 0 && smFlg)) {
tl += memberOrderList.size(); tl += memberOrderList.size();
mongoTemplate.insert(vos, AdamMemberOrderVo.class.getSimpleName()); // mongoTemplate.insert(vos, AdamMemberOrderVo.class.getSimpleName());
log.info("DM.execute.limit.result:{}", dmMemberOrderService.saveBatch(memberOrderList)); log.info("DM.execute.limit.result:{}", dmMemberOrderService.saveBatch(memberOrderList));
vos.clear(); vos.clear();
memberOrderList.clear(); memberOrderList.clear();
......
...@@ -32,10 +32,10 @@ public class DMRealNameProcessor extends DataMigrationProcessorService { ...@@ -32,10 +32,10 @@ public class DMRealNameProcessor extends DataMigrationProcessorService {
if (StringUtils.isNotEmpty(flu)) { if (StringUtils.isNotEmpty(flu)) {
log.info("DM.flush.real_name:{}", userMapper.executeForDM("adam_real_name")); log.info("DM.flush.real_name:{}", userMapper.executeForDM("adam_real_name"));
log.info("DM.flush.AdamRealInfoVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamRealInfoVo.class.getSimpleName()).getDeletedCount()); // log.info("DM.flush.AdamRealInfoVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamRealInfoVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from user_real_name where id not in (9145,7456,7448,7197,7194,4137,4138,4139,269,261,262,263,264,265,266,267,251) and created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()"; String sqlCount = "select count(1) from user_real_name where id not in (9145,7456,7448,7197,7194,4137,4138,4139,269,261,262,263,264,265,266,267,251) and created_at" + (StringUtils.isBlank(incrDt) ? "<curdate()" : (">=curdate()-" + incrDt));
if (null != dg) { if (null != dg) {
sqlCount = sqlCount + " and id%" + dG + "=" + dg; sqlCount = sqlCount + " and id%" + dG + "=" + dg;
} }
...@@ -96,11 +96,12 @@ public class DMRealNameProcessor extends DataMigrationProcessorService { ...@@ -96,11 +96,12 @@ public class DMRealNameProcessor extends DataMigrationProcessorService {
realNameList.add(realName); realNameList.add(realName);
vos.add(vo); vos.add(vo);
dmRdmService.setRealInfoVoByUid(uid, vo);
dmRdmService.setCertification(1, realName.getIdCard(), realName.getName()); dmRdmService.setCertification(1, realName.getIdCard(), realName.getName());
} }
if (realNameList.size() == 500 || (realNameList.size() > 0 && smFlg)) { if (realNameList.size() == 500 || (realNameList.size() > 0 && smFlg)) {
tl += realNameList.size(); tl += realNameList.size();
mongoTemplate.insert(vos, AdamRealInfoVo.class.getSimpleName()); // mongoTemplate.insert(vos, AdamRealInfoVo.class.getSimpleName());
log.info("DM.execute.limit.result:{}", dmRealNameService.saveBatch(realNameList)); log.info("DM.execute.limit.result:{}", dmRealNameService.saveBatch(realNameList));
vos.clear(); vos.clear();
realNameList.clear(); realNameList.clear();
......
...@@ -34,11 +34,11 @@ public class DMThirdPartsProcessor extends DataMigrationProcessorService { ...@@ -34,11 +34,11 @@ public class DMThirdPartsProcessor extends DataMigrationProcessorService {
if (StringUtils.isNotEmpty(flu)) { if (StringUtils.isNotEmpty(flu)) {
log.info("DM.flush.third_party:{}", userMapper.executeForDM("adam_third_party")); log.info("DM.flush.third_party:{}", userMapper.executeForDM("adam_third_party"));
log.info("DM.flush.AdamThirdPartInfoVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamThirdPartInfoVo.class.getSimpleName()).getDeletedCount()); // log.info("DM.flush.AdamThirdPartInfoVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamThirdPartInfoVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from (\n" + String sqlCount = "select count(1) from (\n" +
" select row_number() over (partition by uid,type order by created_at desc) rn,id,uid,open_id,avatar,nickname,type,created_at,updated_at from user_third_parts where `status`=1 and delete_tag in (0,1) and open_id<>'' and uid>0 and created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()\n" + " select row_number() over (partition by uid,type order by created_at desc) rn,id,uid,open_id,avatar,nickname,type,created_at,updated_at from user_third_parts where `status`=1 and delete_tag in (0,1) and open_id<>'' and uid>0 and created_at" + (StringUtils.isBlank(incrDt) ? "<curdate()" : (">=curdate()-" + incrDt)) + "\n" +
" ) t where t.rn=1"; " ) t where t.rn=1";
if (null != dg) { if (null != dg) {
sqlCount = sqlCount + " and id%" + dG + "=" + dg; sqlCount = sqlCount + " and id%" + dG + "=" + dg;
...@@ -106,10 +106,11 @@ public class DMThirdPartsProcessor extends DataMigrationProcessorService { ...@@ -106,10 +106,11 @@ public class DMThirdPartsProcessor extends DataMigrationProcessorService {
vos.add(vo); vos.add(vo);
dmRdmService.setUidByPlatformOpenId(thirdParty.getPlatform(), thirdParty.getOpenId(), uid); dmRdmService.setUidByPlatformOpenId(thirdParty.getPlatform(), thirdParty.getOpenId(), uid);
dmRdmService.addThirdPartVoListByUid(uid, dmRdmService.getThirdPartVoListByUid(uid), vo);
} }
if (thirdPartyList.size() == 500 || (thirdPartyList.size() > 0 && smFlg)) { if (thirdPartyList.size() == 500 || (thirdPartyList.size() > 0 && smFlg)) {
tl += thirdPartyList.size(); tl += thirdPartyList.size();
mongoTemplate.insert(vos, AdamThirdPartInfoVo.class.getSimpleName()); // mongoTemplate.insert(vos, AdamThirdPartInfoVo.class.getSimpleName());
log.info("DM.execute.limit.result:{}", dmThirdPartyService.saveBatch(thirdPartyList)); log.info("DM.execute.limit.result:{}", dmThirdPartyService.saveBatch(thirdPartyList));
vos.clear(); vos.clear();
thirdPartyList.clear(); thirdPartyList.clear();
......
...@@ -39,8 +39,8 @@ public class DMTracesInfoProcessor extends DataMigrationProcessorService { ...@@ -39,8 +39,8 @@ public class DMTracesInfoProcessor extends DataMigrationProcessorService {
log.info("DM.flush.member:{}", userMapper.executeForDM("adam_member")); log.info("DM.flush.member:{}", userMapper.executeForDM("adam_member"));
log.info("DM.flush.member_price:{}", userMapper.executeForDM("adam_member_price")); log.info("DM.flush.member_price:{}", userMapper.executeForDM("adam_member_price"));
log.info("DM.flush.AdamMemberVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamMemberVo.class.getSimpleName()).getDeletedCount()); // log.info("DM.flush.AdamMemberVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamMemberVo.class.getSimpleName()).getDeletedCount());
log.info("DM.flush.AdamMemberPriceVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamMemberPriceVo.class.getSimpleName()).getDeletedCount()); // log.info("DM.flush.AdamMemberPriceVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamMemberPriceVo.class.getSimpleName()).getDeletedCount());
} }
this.memberCardInfoHandler(); this.memberCardInfoHandler();
this.memberCardPriceHandler(); this.memberCardPriceHandler();
...@@ -90,7 +90,7 @@ public class DMTracesInfoProcessor extends DataMigrationProcessorService { ...@@ -90,7 +90,7 @@ public class DMTracesInfoProcessor extends DataMigrationProcessorService {
dmRdmService.setMemberVoByMemberId(vo.getMemberId(), vo); dmRdmService.setMemberVoByMemberId(vo.getMemberId(), vo);
memberMapper.insert(o); memberMapper.insert(o);
mongoTemplate.insert(vo, AdamMemberVo.class.getSimpleName()); // mongoTemplate.insert(vo, AdamMemberVo.class.getSimpleName());
log.info("DM.execute ----------------------------> end"); log.info("DM.execute ----------------------------> end");
...@@ -147,7 +147,7 @@ public class DMTracesInfoProcessor extends DataMigrationProcessorService { ...@@ -147,7 +147,7 @@ public class DMTracesInfoProcessor extends DataMigrationProcessorService {
dmRdmService.setMemberPriceVoByMemberId(vo.getMemberId(), Collections.singletonList(vo)); dmRdmService.setMemberPriceVoByMemberId(vo.getMemberId(), Collections.singletonList(vo));
memberPriceMapper.insert(o); memberPriceMapper.insert(o);
mongoTemplate.insert(vo, AdamMemberPriceVo.class.getSimpleName()); // mongoTemplate.insert(vo, AdamMemberPriceVo.class.getSimpleName());
log.info("DM.execute ----------------------------> end"); log.info("DM.execute ----------------------------> end");
...@@ -214,8 +214,8 @@ public class DMTracesInfoProcessor extends DataMigrationProcessorService { ...@@ -214,8 +214,8 @@ public class DMTracesInfoProcessor extends DataMigrationProcessorService {
} }
private void setRdsCache() { private void setRdsCache() {
dmRdmService.setSwitch(AdamRedisConst.SWITCH_GRAY_LOGIN_SMS, 612543); // dmRdmService.setSwitch(AdamRedisConst.SWITCH_GRAY_LOGIN_SMS, 612543);
log.info("switch {}:{}", AdamRedisConst.SWITCH_GRAY_LOGIN_SMS, dmRdmService.getSwitch(AdamRedisConst.SWITCH_GRAY_LOGIN_SMS)); // log.info("switch {}:{}", AdamRedisConst.SWITCH_GRAY_LOGIN_SMS, dmRdmService.getSwitch(AdamRedisConst.SWITCH_GRAY_LOGIN_SMS));
List<String> nknameList = dmRdmService.getNknameList(); List<String> nknameList = dmRdmService.getNknameList();
log.info("init loader nknameList.size:{}", nknameList.size()); log.info("init loader nknameList.size:{}", nknameList.size());
} }
......
...@@ -52,11 +52,11 @@ public class DMUserInformationProcessor extends DataMigrationProcessorService { ...@@ -52,11 +52,11 @@ public class DMUserInformationProcessor extends DataMigrationProcessorService {
log.info("DM.flush.user:{}", userMapper.executeForDM("adam_user")); log.info("DM.flush.user:{}", userMapper.executeForDM("adam_user"));
log.info("DM.flush.user_info:{}", userMapper.executeForDM("adam_user_info")); log.info("DM.flush.user_info:{}", userMapper.executeForDM("adam_user_info"));
log.info("DM.flush.AdamUserInfoVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamUserInfoVo.class.getSimpleName()).getDeletedCount()); // log.info("DM.flush.AdamUserInfoVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamUserInfoVo.class.getSimpleName()).getDeletedCount());
} }
// String sqlCount = "select count(1) from users where delete_tag in (0,1) and length(mobile)=11 and created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()"; // String sqlCount = "select count(1) from users where delete_tag in (0,1) and length(mobile)=11 and created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()";
String sqlCount = "select count(1) from users where delete_tag in (0,1) and created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()"; String sqlCount = "select count(1) from users where delete_tag in (0,1) and created_at" + (StringUtils.isBlank(incrDt) ? "<curdate()" : (">=curdate()-" + incrDt));
if (null != dg) { if (null != dg) {
sqlCount = sqlCount + " and uid%" + dG + "=" + dg; sqlCount = sqlCount + " and uid%" + dG + "=" + dg;
} }
...@@ -144,11 +144,12 @@ public class DMUserInformationProcessor extends DataMigrationProcessorService { ...@@ -144,11 +144,12 @@ public class DMUserInformationProcessor extends DataMigrationProcessorService {
if (StringUtils.length(mobile) == 11) { if (StringUtils.length(mobile) == 11) {
dmRdmService.setUidByMobile(mobile, uid); dmRdmService.setUidByMobile(mobile, uid);
dmRdmService.setUserInfoVoByUid(uid, vo);
} }
} }
if (userList.size() == 500 || (userList.size() > 0 && smFlg)) { if (userList.size() == 500 || (userList.size() > 0 && smFlg)) {
tl += userList.size(); tl += userList.size();
mongoTemplate.insert(vos, AdamUserInfoVo.class.getSimpleName()); // mongoTemplate.insert(vos, AdamUserInfoVo.class.getSimpleName());
log.info("DM.execute.result:{} - {}", dmUserService.saveBatch(userList), dmUserInfoService.saveBatch(userInfoList)); log.info("DM.execute.result:{} - {}", dmUserService.saveBatch(userList), dmUserInfoService.saveBatch(userInfoList));
vos.clear(); vos.clear();
userList.clear(); userList.clear();
......
package com.liquidnet.service.platform.service.impl.adam.dm.processor; package com.liquidnet.service.platform.service.impl.adam.dm.processor;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.adam.dto.vo.AdamUserMemberVo; import com.liquidnet.service.adam.dto.vo.AdamUserMemberVo;
import com.liquidnet.service.adam.entity.AdamUserMember; import com.liquidnet.service.adam.entity.AdamUserMember;
import com.liquidnet.service.platform.service.impl.adam.dm.DMUserMemberService; import com.liquidnet.service.platform.service.impl.adam.dm.DMUserMemberService;
...@@ -9,8 +11,6 @@ import lombok.SneakyThrows; ...@@ -9,8 +11,6 @@ import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.sql.Connection; import java.sql.Connection;
...@@ -32,10 +32,10 @@ public class DMUserMemberProcessor extends DataMigrationProcessorService { ...@@ -32,10 +32,10 @@ public class DMUserMemberProcessor extends DataMigrationProcessorService {
if (StringUtils.isNotEmpty(flu)) { if (StringUtils.isNotEmpty(flu)) {
log.info("DM.flush.user_member:{}", userMapper.executeForDM("adam_user_member")); log.info("DM.flush.user_member:{}", userMapper.executeForDM("adam_user_member"));
log.info("DM.flush.AdamUserMemberVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamUserMemberVo.class.getSimpleName()).getDeletedCount()); // log.info("DM.flush.AdamUserMemberVo:{}", mongoTemplate.remove(Query.query(Criteria.where("_id").exists(true)), AdamUserMemberVo.class.getSimpleName()).getDeletedCount());
} }
String sqlCount = "select count(1) from user_cards where created_at" + (StringUtils.isBlank(incrDt) ? "<" : ">=") + "curdate()"; String sqlCount = "select count(1) from user_cards where created_at" + (StringUtils.isBlank(incrDt) ? "<curdate()" : (">=curdate()-" + incrDt));
if (null != dg) { if (null != dg) {
sqlCount = sqlCount + " and id%" + dG + "=" + dg; sqlCount = sqlCount + " and id%" + dG + "=" + dg;
} }
...@@ -101,7 +101,7 @@ public class DMUserMemberProcessor extends DataMigrationProcessorService { ...@@ -101,7 +101,7 @@ public class DMUserMemberProcessor extends DataMigrationProcessorService {
} }
if (userMemberList.size() == 500 || (userMemberList.size() > 0 && smFlg)) { if (userMemberList.size() == 500 || (userMemberList.size() > 0 && smFlg)) {
tl += userMemberList.size(); tl += userMemberList.size();
mongoTemplate.insert(vos, AdamUserMemberVo.class.getSimpleName()); // mongoTemplate.insert(vos, AdamUserMemberVo.class.getSimpleName());
log.info("DM.execute.limit.result:{}", dmUserMemberService.saveBatch(userMemberList)); log.info("DM.execute.limit.result:{}", dmUserMemberService.saveBatch(userMemberList));
vos.clear(); vos.clear();
userMemberList.clear(); userMemberList.clear();
...@@ -116,6 +116,12 @@ public class DMUserMemberProcessor extends DataMigrationProcessorService { ...@@ -116,6 +116,12 @@ public class DMUserMemberProcessor extends DataMigrationProcessorService {
log.info("DM.execute.limit {},{} - handle.counts:{}", ls, pSize, tl); log.info("DM.execute.limit {},{} - handle.counts:{}", ls, pSize, tl);
} }
log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> end", pl, num, pSize, tl); log.info("DM.execute.counts:{}/{},{} ~ {} ----------------------------> end", pl, num, pSize, tl);
AdamUserMember max = dmUserMemberService.getOne(Wrappers.lambdaQuery(AdamUserMember.class).orderByDesc(AdamUserMember::getMemberNo));
log.info("DM.execute.setMaxMemberNo:{} ----------------------------> end", JsonUtils.toJson(max));
if (null != max) {
dmRdmService.setMaxMemberNo(Integer.parseInt(max.getMemberNo()));
}
} catch (Exception e) { } catch (Exception e) {
log.error("ex:getConnection,dG/dg:{}/{},msg:{}", dG, dg, e.getMessage()); log.error("ex:getConnection,dG/dg:{}/{},msg:{}", dG, dg, e.getMessage());
} }
......
package com.liquidnet.service.platform.utils;
import com.liquidnet.commons.lang.util.CollectionUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
public class NknameUtil {
private static final Logger log = LoggerFactory.getLogger(NknameUtil.class);
public static ArrayList<String> readForStringList() {
ArrayList<String> nknameList = CollectionUtil.arrayListString();
InputStream inputStream = null;
InputStreamReader inputStreamReader = null;
BufferedReader bufferedReader = null;
try {
inputStream = NknameUtil.class.getClassLoader().getResourceAsStream("META-FIL/library_nickname.csv");
inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
bufferedReader = new BufferedReader(inputStreamReader);
String line;
while ((line = bufferedReader.readLine()) != null) {
int l = StringUtils.length(line);
if (l == 0) {
break;
}
if (l > 11) {
line = line.substring(0, 11);
}
nknameList.add(line);
}
} catch (IOException e) {
log.error("Read CSV[library_nickname.csv] failure.", e);
} finally {
try {
if (null != bufferedReader) bufferedReader.close();
if (null != inputStreamReader) inputStreamReader.close();
if (null != inputStream) inputStream.close();
} catch (IOException e) {
log.error("Close stream failure.", e);
}
}
return nknameList;
}
}
\ No newline at end of file
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