发表于: 2020-03-29 15:32:51
0 1348
今天完成的事情:
1、工作中遇到的框架:
数据库: mySql
基础:mybatis + ssm + redis + redission锁
定时任务:quartz
会话:websocket + netty
队列:rocketMq
分布式: dubbo + nacos
日志:elk技术
发布:jekins
web服务:nginx
脚本:shell
序列化:photobuff
单点登录: JWT
2、业务常用
状态类计算:
转换为二进制,根据位索引位置上的num的值获取值判断所有状态/开关
比如000110001000
取第五位:1
取第十位:0
判断开关和状态
工具类业务操作:
bean拷贝:
BeanUtils.copyProperties(user, productUser);
Bean转map:
EntityUtils.entityToStringMap(company)
时间操作:
User.getLastLoginTime().after(impLog.getCreateTime()))
时间差
LocalDate localDate = LocalDate.now();
LocalDate comStopDate = company.getStopDate();
long dif = localDate.until(comStopDate, ChronoUnit.DAYS);
转换:
LocalDateTime localDateTime = LocalDateTime.now();
LocalDateTime lastLoginTime = LocalDateTime.parse(vb.getString("lastLoginTime"), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
jdk8流:
交集:
uins = tokenUins.stream().filter(uins::contains).collect(Collectors.toSet());
去重:
List<Long> onlineUin = online.stream().distinct().map(s -> getUin(s)).collect(Collectors.toList());
过滤:
List<Map<String, Object>> onlineMap = maps.stream().filter(m -> onlineUin.contains(m.get("uin"))).collect(Collectors.toList());
转list:
List<Dept> allChildren = new ArrayList<>();
List<Integer> collect = allChildren.stream().map(Dept::getDeptId).collect(Collectors.toList());
分组:
Map<String, List<WechatUser>> collect = wechats.stream().filter(w -> !StringUtils.isEmpty(w.getUserName())).collect(Collectors.groupingBy(w -> w.getUserName()));
原子操作:
Atomic相关类:
AtomicInteger、AtomicLong和LongAdder
private static LongAdder onlineCount = new LongAdder();
高并发锁场景使用
异步操作:
AtomicReference<Result<Boolean>> result = new AtomicReference<>(new Result<>());
String batchId = UUIDUtil.getUuid();
Result<ArrayList<LoginParam>> paramResult = wechatDeviceLoginService.loginCheck(companyCode, tokenUser.getUserName(), gId, batchId, im62txt);
if (paramResult.getData() == null){
return paramResult;
}
//执行登录
CompletableFuture.supplyAsync(() -> wechatDeviceLoginService.deviceLogin(companyCode, tokenUser.getUserName(), gId, batchId, im62txt.getOriginalFilename(), paramResult.getData()))
.whenComplete((resultMap, ex) -> result.set(resultMap));
redis锁注解
/**
* @author Zhang Qiang
* @date 2019/10/28 11:49
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface ReLock {
/**
* key
*/
String key() default "";
/**
* 是否循环获取锁
*/
boolean isHold() default true;
/**
* 尝试加锁等待超时时间
*/
long waitTime() default 3 * 1000L;
/**
* 最长持锁时间,到期自动解锁
*/
long leaseTime() default 3 * 1000L;
/**
* 时间格式,默认ms
*/
TimeUnit timeUnit() default TimeUnit.MICROSECONDS;
}
明天计划的事情:
不想上班
遇到的问题:
周末写日报..真是醉了
业务中遇到的逻辑问题..
如异步发送队列给生产端,生产端返回后获取结果:消费端收到执行结果通过WebsocketCacheManager获取session然后返回
评论