0
点赞
收藏
分享

微信扫一扫

用新特性批量更新数据状态

小磊z 2022-01-06 阅读 44
java
  //停用
    final String status="2";
    LocalDateTime now = LocalDateTime.now();
    List<String> ids = tVehicleMapper.selectList(null)
            .stream()  #开启流
            .filter(v -> v.getTvEndDate().isBefore(now)) //过滤出该字段今日前的数据
            .map(id -> id.getDataId()) //类型转换
            .collect(Collectors.toList()); 
    if (!CollUtil.isEmpty(ids)){
        LambdaUpdateWrapper<TVehicle> wp=new UpdateWrapper<TVehicle>()
                .lambda() 
                .set(TVehicle::getTvStatus,status)
                .in(TVehicle::getDataId,ids);
        tVehicleMapper.update(null,wp);
    }
举报

相关推荐

0 条评论