Commit c629cc5a authored by xiaoguang.xu's avatar xiaoguang.xu

修复userDetail 小写身份证数据244303个

parent 21e49667
Pipeline #943 failed with stages
......@@ -2,6 +2,8 @@ package cn.quantgroup.xyqb.controller.external;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.entity.UserHashMapping;
import cn.quantgroup.xyqb.model.Gender;
import cn.quantgroup.xyqb.model.IdType;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.repository.IUserDetailRepository;
import cn.quantgroup.xyqb.util.encrypt.MD5Util;
......@@ -53,16 +55,37 @@ public class SyncHashController {
while (isContinue) {
Stopwatch started = Stopwatch.createStarted();
Long endPosition = startPosition + step;
List<UserDetail> userDetails = userDetailRepository.findByIdBetween(startPosition, endPosition);
String sql = "select * from `user_detail` u where u.`id_no` like binary '%x' and u.id >= " + startPosition + " and u.id < " + endPosition;
List<UserDetail> userDetails = jdbcTemplate.query(sql, (rs, rowNum) -> {
UserDetail userDetail = new UserDetail();
userDetail.setId(rs.getLong("id"));
userDetail.setUserId(rs.getLong("user_id"));
userDetail.setPhoneNo(rs.getString("phone_no"));
userDetail.setName(rs.getString("name"));
userDetail.setIdNo(rs.getString("id_no"));
userDetail.setIdType(IdType.values()[rs.getInt("id_type")]);
userDetail.setIsAuthenticated(rs.getInt("is_authenticated") == 1);
userDetail.setGender(Gender.values()[rs.getInt("gender")]);
userDetail.setEmail(rs.getString("email"));
userDetail.setQq(rs.getString("qq"));
userDetail.setCreatedAt(rs.getTimestamp("created_at"));
userDetail.setUpdatedAt(rs.getTimestamp("updated_at"));
return userDetail;
});
if (userDetails.isEmpty()) {
log.info("没有数据了. 结束了");
return;
startPosition = endPosition;
if (endPosition > 49434765L) {
log.info("没有数据了. 结束了");
return;
}
continue;
}
log.info("查询用户需要的时间 : {}ms", started.elapsed(TimeUnit.MILLISECONDS));
List<UserHashMapping> userHashMappings = new ArrayList<>();
userDetails.forEach(userDetail -> {
String idNo = userDetail.getIdNo();
if (idNo != null) {
userDetail.setIdNo(idNo.toUpperCase());
UserHashMapping userHashMapping = new UserHashMapping();
userHashMapping.setUserId(userDetail.getUserId());
userHashMapping.setIdNoMd5(MD5Util.build(userDetail.getIdNo()));
......@@ -84,7 +107,7 @@ public class SyncHashController {
jdbcTemplate.execute(sbSql.toString());
// StringUtils.trimWhitespace()
userDetailRepository.save(userDetails);
log.info("batchUpdate需要的时间 : {}ms", started.elapsed(TimeUnit.MILLISECONDS));
......
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