Java Code Examples for cn.hutool.core.collection.CollectionUtil#isEmpty()

The following examples show how to use cn.hutool.core.collection.CollectionUtil#isEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileServiceImpl.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
@Override
public Boolean removeList(Long userId, List<Long> ids) {
    if (CollectionUtil.isEmpty(ids)) {
        return Boolean.TRUE;
    }
    List<File> list = super.list(Wrappers.<File>lambdaQuery().in(File::getId, ids));
    if (list.isEmpty()) {
        return true;
    }
    super.removeByIds(ids);

    fileStrategy.delete(list.stream().map((fi) -> FileDeleteDO.builder()
            .relativePath(fi.getRelativePath())
            .fileName(fi.getFilename())
            .group(fi.getGroup())
            .path(fi.getPath())
            .file(false)
            .build())
            .collect(Collectors.toList()));
    return true;
}
 
Example 2
Source File: PmsPatientServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
@Override
public PmsPatientResult patientLogin(String identificationNo, String medicalRecordNo) {
   PmsPatientExample pmsPatientExample=new PmsPatientExample();
   pmsPatientExample.createCriteria().andIdentificationNoEqualTo(identificationNo).andMedicalRecordNoEqualTo(medicalRecordNo);
   List<PmsPatient> pmsPatientList = pmsPatientMapper.selectByExample(pmsPatientExample);
    if(CollectionUtil.isEmpty(pmsPatientList)||pmsPatientList.size()>1){
        return null;
    }

    //数据正常的情况下,只会返回一个病人
    PmsPatientResult pmsPatientResult=new PmsPatientResult();
    BeanUtils.copyProperties(pmsPatientList.get(0),pmsPatientResult);

    return pmsPatientResult;

}
 
Example 3
Source File: PmsPatientServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
@Override
public PmsPatientResult patientLogin(String identificationNo, String medicalRecordNo) {
   PmsPatientExample pmsPatientExample=new PmsPatientExample();
   pmsPatientExample.createCriteria().andIdentificationNoEqualTo(identificationNo).andMedicalRecordNoEqualTo(medicalRecordNo);
   List<PmsPatient> pmsPatientList = pmsPatientMapper.selectByExample(pmsPatientExample);
    if(CollectionUtil.isEmpty(pmsPatientList)||pmsPatientList.size()>1){
        return null;
    }

    //数据正常的情况下,只会返回一个病人
    PmsPatientResult pmsPatientResult=new PmsPatientResult();
    BeanUtils.copyProperties(pmsPatientList.get(0),pmsPatientResult);

    return pmsPatientResult;

}
 
Example 4
Source File: RequestProcessorContext.java    From bitchat with Apache License 2.0 6 votes vote down vote up
private void initRequestProcessor() {
    if (!init.compareAndSet(false, true)) {
        return;
    }
    BaseConfig baseConfig = ConfigFactory.getConfig(BaseConfig.class);
    Set<Class<?>> classSet = ClassScaner.scanPackageBySuper(baseConfig.basePackage(), RequestProcessor.class);
    if (CollectionUtil.isEmpty(classSet)) {
        log.warn("[RequestProcessorContext] No RequestProcessor found");
        return;
    }
    for (Class<?> clazz : classSet) {
        if (clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers()) || !RequestProcessor.class.isAssignableFrom(clazz)) {
            continue;
        }
        try {
            // check whether the class has @Processor annotation
            // use name specified by @Processor first
            Processor processor = clazz.getAnnotation(Processor.class);
            String serviceName = (processor != null && StrUtil.isNotBlank(processor.name())) ? GenericsUtil.unifiedProcessorName(processor.name()) : clazz.getName();
            cacheRequestProcessor(serviceName, clazz);
        } catch (Exception e) {
            log.warn("[RequestProcessorContext] cacheRequestProcessor failed", e);
        }
    }
}
 
Example 5
Source File: MsgsCenterInfoServiceImpl.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 修改状态
 * 公告的已读,新增记录
 * <p>
 * 其他的更新状态
 *
 * @param msgCenterIds 主表id
 * @param userId       用户id
 * @return
 */
@Override
@Transactional(rollbackFor = Exception.class)
public boolean mark(List<Long> msgCenterIds, Long userId) {
    if (CollectionUtil.isEmpty(msgCenterIds) || userId == null) {
        return true;
    }
    List<MsgsCenterInfo> list = super.listByIds(msgCenterIds);

    //其他类型的修改状态
    if (!list.isEmpty()) {
        List<Long> idList = list.stream().mapToLong(MsgsCenterInfo::getId).boxed().collect(Collectors.toList());
        return msgsCenterInfoReceiveService.update(Wraps.<MsgsCenterInfoReceive>lbU()
                .eq(MsgsCenterInfoReceive::getUserId, userId)
                .in(MsgsCenterInfoReceive::getMsgsCenterId, idList)
                .set(MsgsCenterInfoReceive::getIsRead, true)
                .set(MsgsCenterInfoReceive::getUpdateTime, LocalDateTime.now())
                .set(MsgsCenterInfoReceive::getUpdateUser, userId)
        );
    }
    return true;
}
 
Example 6
Source File: DmsDrugServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
/**
 * 描述:1.调用DmsDrugDao查询所有记录(不包括status=0)
 * <p>author: ma
 * <p>author: 赵煜 修改越界错误
 */
@Override
public List<DmsDrugResult> selectAllDrug(){
    DmsDrugExample example = new DmsDrugExample();
    example.createCriteria().andStatusNotEqualTo(0);
    //返回数据包装成Result
    List<DmsDrug> dmsDrugs = dmsDrugMapper.selectByExample(example);
    List<DmsDrugResult> dmsDrugResultList = new ArrayList<>();
    for (DmsDrug dmsDrug   : dmsDrugs) {
        DmsDrugResult dmsDrugResult = new DmsDrugResult();
        BeanUtils.copyProperties(dmsDrug, dmsDrugResult);

        DmsDosageExample dmsDosageExample = new DmsDosageExample();
        //封装剂型
        dmsDosageExample.createCriteria().andIdEqualTo(dmsDrug.getDosageId());
        List<DmsDosage> dmsDosageList = dmsDosageMapper.selectByExample(dmsDosageExample);
        if(!CollectionUtil.isEmpty(dmsDosageList)){
            dmsDrugResult.setDosage(dmsDosageList.get(0));
        }
        dmsDrugResultList.add(dmsDrugResult);
    }
    return dmsDrugResultList;
}
 
Example 7
Source File: DmsDiseServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
@Override
public List<DmsDiseResult> parseList( String idsStr) {
    //解析ids->list<Id>
    List<Long> idList = strToList(idsStr);
   //根据list<Id>查询并封装诊断简单对象
    DmsDiseExample dmsDiseExample=new DmsDiseExample();
    dmsDiseExample.createCriteria().andIdIn(idList);
    List<DmsDise> dmsDiseList=dmsDiseMapper.selectByExample(dmsDiseExample);
    List<DmsDiseResult> dmsDiseResultList = new ArrayList<>();

    if(CollectionUtil.isEmpty(dmsDiseList)){
       return null;
    }

    //封装dto
    for(DmsDise dmsDise: dmsDiseList){
        DmsDiseResult dmsDiseResult=new DmsDiseResult();
        BeanUtils.copyProperties(dmsDise,dmsDiseResult);
        dmsDiseResultList.add(dmsDiseResult);
    }
    return dmsDiseResultList;
}
 
Example 8
Source File: AbstractVoteMsgQueue.java    From md_blockchain with Apache License 2.0 6 votes vote down vote up
@Override
protected void push(VoteMsg voteMsg) {
    String hash = voteMsg.getHash();
    List<VoteMsg> voteMsgs = voteMsgConcurrentHashMap.get(hash);
    if (CollectionUtil.isEmpty(voteMsgs)) {
        voteMsgs = new ArrayList<>();
        voteMsgs.add(voteMsg);
        voteMsgConcurrentHashMap.put(hash, voteMsgs);
    }
    //判断本地集合是否已经存在完全相同的voteMsg了
    for (VoteMsg temp : voteMsgs) {
        if (temp.getNumber() == voteMsg.getNumber() && temp.getAppId().equals(voteMsg.getAppId())) {
            return;
        }
    }
    //添加进去
    voteMsgs.add(voteMsg);
    //如果我已经对该hash的commit投过票了,就不再继续
    if (voteStateConcurrentHashMap.get(hash) != null) {
        return;
    }

    deal(voteMsg, voteMsgs);
}
 
Example 9
Source File: DmsDiseServiceImpl.java    From HIS with Apache License 2.0 6 votes vote down vote up
@Override
public List<DmsDiseResult> parseList( String idsStr) {
    //解析ids->list<Id>
    List<Long> idList = strToList(idsStr);
   //根据list<Id>查询并封装诊断简单对象
    DmsDiseExample dmsDiseExample=new DmsDiseExample();
    dmsDiseExample.createCriteria().andIdIn(idList);
    List<DmsDise> dmsDiseList=dmsDiseMapper.selectByExample(dmsDiseExample);
    List<DmsDiseResult> dmsDiseResultList = new ArrayList<>();

    if(CollectionUtil.isEmpty(dmsDiseList)){
       return null;
    }

    //封装dto
    for(DmsDise dmsDise: dmsDiseList){
        DmsDiseResult dmsDiseResult=new DmsDiseResult();
        BeanUtils.copyProperties(dmsDise,dmsDiseResult);
        dmsDiseResultList.add(dmsDiseResult);
    }
    return dmsDiseResultList;
}
 
Example 10
Source File: BountyRankVO.java    From runscore with Apache License 2.0 5 votes vote down vote up
public static List<BountyRankVO> convertFor(List<TotalAccountReceiveOrderSituation> situations) {
	if (CollectionUtil.isEmpty(situations)) {
		return new ArrayList<>();
	}
	List<BountyRankVO> vos = new ArrayList<>();
	for (TotalAccountReceiveOrderSituation situation : situations) {
		vos.add(convertFor(situation));
	}
	return vos;
}
 
Example 11
Source File: AbstractSessionManager.java    From bitchat with Apache License 2.0 5 votes vote down vote up
@Override
public List<Session> getSessionsByUserIdAndChannelType(long userId, ChannelType channelType) {
    Collection<Session> sessions = allSession();
    if (CollectionUtil.isEmpty(sessions)) {
        return Collections.emptyList();
    }
    return sessions.stream()
            .filter(session -> session.userId() == userId)
            .filter(session -> channelType == null || session.channelType() == channelType)
            .collect(Collectors.toList());
}
 
Example 12
Source File: RoleServiceImpl.java    From eladmin with Apache License 2.0 5 votes vote down vote up
/**
 * 清理缓存
 * @param id /
 */
public void delCaches(Long id, List<User> users) {
    users = CollectionUtil.isEmpty(users) ? userRepository.findByRoleId(id) : users;
    if (CollectionUtil.isNotEmpty(users)) {
        users.forEach(item -> userCacheClean.cleanUserCache(item.getUsername()));
        Set<Long> userIds = users.stream().map(User::getId).collect(Collectors.toSet());
        redisUtils.delByKeys(CacheKey.DATE_USER, userIds);
        redisUtils.delByKeys(CacheKey.MENU_USER, userIds);
        redisUtils.delByKeys(CacheKey.ROLE_AUTH, userIds);
        redisUtils.del(CacheKey.ROLE_ID + id);
    }

}
 
Example 13
Source File: ZookeeperReentrantDistributedLock.java    From javatech with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
@Override
public void run() {
    try {
        List<String> list = client.getChildren().forPath(path);
        if (CollectionUtil.isEmpty(list)) {
            client.delete().forPath(path);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
 
Example 14
Source File: SmsDescriptionServiceImpl.java    From HIS with Apache License 2.0 5 votes vote down vote up
@Override
public AppDocSkdResult getDetailById(Long id){
    SmsDescriptionExample smsDescriptionExample=new SmsDescriptionExample();
    smsDescriptionExample.createCriteria().andTheIdEqualTo(id).andTypeEqualTo(2);

    List<SmsDescription> smsDescriptionList= smsDescriptionMapper.selectByExample(smsDescriptionExample);
    //数据正常的情况下 只会查找除一条记录
    if(CollectionUtil.isEmpty(smsDescriptionList)||smsDescriptionList.size()>1){
        return null;
    }

    AppDocSkdResult result = new AppDocSkdResult();
    result.setUrl(smsDescriptionList.get(0).getUrl());
    result.setStar(smsDescriptionList.get(0).getStar());
    result.setDescription(smsDescriptionList.get(0).getDescription());

    SmsStaff staff = smsStaffMapper.selectByPrimaryKey(id);
    if(staff == null){
        return null;
    }
    SmsDept dept = smsDeptMapper.selectByPrimaryKey(staff.getDeptId());
    if(dept == null){
        return null;
    }

    result.setDeptId(dept.getId());
    result.setDeptName(dept.getName());

    return result;
}
 
Example 15
Source File: PayTypeVO.java    From runscore with Apache License 2.0 5 votes vote down vote up
public static List<PayTypeVO> convertFor(List<PayType> payTypes) {
	if (CollectionUtil.isEmpty(payTypes)) {
		return new ArrayList<>();
	}
	List<PayTypeVO> vos = new ArrayList<>();
	for (PayType payType : payTypes) {
		vos.add(convertFor(payType));
	}
	return vos;
}
 
Example 16
Source File: HttpContext.java    From bitchat with Apache License 2.0 5 votes vote down vote up
public HttpContext addCookie(Cookie cookie) {
    if (cookie != null) {
        if (CollectionUtil.isEmpty(cookies)) {
            cookies = new HashSet<>();
        }
        cookies.add(cookie);
    }
    return this;
}
 
Example 17
Source File: WithdrawRecordVO.java    From runscore with Apache License 2.0 5 votes vote down vote up
public static List<WithdrawRecordVO> convertFor(List<WithdrawRecord> withdrawRecords) {
	if (CollectionUtil.isEmpty(withdrawRecords)) {
		return new ArrayList<>();
	}
	List<WithdrawRecordVO> vos = new ArrayList<>();
	for (WithdrawRecord withdrawRecord : withdrawRecords) {
		vos.add(convertFor(withdrawRecord));
	}
	return vos;
}
 
Example 18
Source File: BmsDailySettlementServiceImpl.java    From HIS with Apache License 2.0 5 votes vote down vote up
@Override
public Date queryRecentEndDatetime(Long staffId) {
    BmsOperatorSettleRecordExample bmsOperatorSettleRecordExample = new BmsOperatorSettleRecordExample();
    bmsOperatorSettleRecordExample.createCriteria().andCashierIdEqualTo(staffId);
    //按截止时间倒序,选取最上面的一条记录
    bmsOperatorSettleRecordExample.setOrderByClause("end_datetime desc");
    List<BmsOperatorSettleRecord> bmsOperatorSettleRecordList = bmsOperatorSettleRecordMapper.selectByExample(bmsOperatorSettleRecordExample);
    Date endDatetime = null;
    if (!bmsOperatorSettleRecordList.isEmpty()){
        BmsOperatorSettleRecord bmsOperatorSettleRecord = bmsOperatorSettleRecordList.get(0);//可能有问题
        endDatetime = bmsOperatorSettleRecord.getEndDatetime();
    }
    else {
        BmsInvoiceRecordExample bmsInvoiceRecordExample = new BmsInvoiceRecordExample();
        bmsInvoiceRecordExample.createCriteria().andOperatorIdEqualTo(staffId);

        bmsInvoiceRecordExample.setOrderByClause("create_time asc");
        List<BmsInvoiceRecord> bmsInvoiceRecordList = bmsInvoiceRecordMapper.selectByExample(bmsInvoiceRecordExample);
        if (!bmsInvoiceRecordList.isEmpty()){
            endDatetime = bmsInvoiceRecordList.get(0).getCreateTime();
        }
        else {//所操作发票最早的时间
            BmsInvoiceRecordExample bmsInvoiceRecordExampleTemp=new BmsInvoiceRecordExample();
            bmsInvoiceRecordExampleTemp.createCriteria().andOperatorIdEqualTo(staffId);
            bmsInvoiceRecordExampleTemp.setOrderByClause("create_time desc");
            List<BmsInvoiceRecord> bmsInvoiceRecordListTemp = bmsInvoiceRecordMapper.selectByExample(bmsInvoiceRecordExampleTemp);
            if(!CollectionUtil.isEmpty(bmsInvoiceRecordListTemp))
                endDatetime = bmsInvoiceRecordListTemp.get(0).getCreateTime();
        }
    }
    return endDatetime;

}
 
Example 19
Source File: SysMenuController.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
/**
 * 当前登录用户的菜单
 *
 * @return
 */
@GetMapping("/current")
@ApiOperation(value = "查询当前用户菜单")
public List<SysMenu> findMyMenu(@LoginUser SysUser user) {
    List<SysRole> roles = user.getRoles();
    if (CollectionUtil.isEmpty(roles)) {
        return Collections.emptyList();
    }
    List<SysMenu> menus = menuService.findByRoleCodes(roles.parallelStream().map(SysRole::getCode).collect(Collectors.toSet()), CommonConstant.MENU);
    return treeBuilder(menus);
}
 
Example 20
Source File: BasketServiceImpl.java    From mall4j with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public List<ShopCartItemDto> getShopCartItemsByOrderItems(List<Long> basketId, OrderItemParam orderItem,String userId) {
    if (orderItem == null && CollectionUtil.isEmpty(basketId)) {
        return Collections.emptyList();
    }

    // 当立即购买时,没有提交的订单是没有购物车信息的
    if (CollectionUtil.isEmpty(basketId) && orderItem != null) {

        Sku sku = skuService.getSkuBySkuId(orderItem.getSkuId());
        if (sku == null) {
            throw new RuntimeException("订单包含无法识别的商品");
        }
        Product prod = productService.getProductByProdId(orderItem.getProdId());
        if (prod == null) {
            throw new RuntimeException("订单包含无法识别的商品");
        }

        // 拿到购物车的所有item
        ShopCartItemDto shopCartItemDto = new ShopCartItemDto();
        shopCartItemDto.setBasketId(-1L);
        shopCartItemDto.setSkuId(orderItem.getSkuId());
        shopCartItemDto.setProdCount(orderItem.getProdCount());
        shopCartItemDto.setProdId(orderItem.getProdId());
        shopCartItemDto.setSkuName(sku.getSkuName());
        shopCartItemDto.setPic(StrUtil.isBlank(sku.getPic())? prod.getPic() : sku.getPic());
        shopCartItemDto.setProdName(sku.getProdName());
        shopCartItemDto.setProductTotalAmount(Arith.mul(sku.getPrice(),orderItem.getProdCount()));
        shopCartItemDto.setPrice(sku.getPrice());
        shopCartItemDto.setDistributionCardNo(orderItem.getDistributionCardNo());
        shopCartItemDto.setBasketDate(new Date());
        ShopDetail shopDetail = shopDetailService.getShopDetailByShopId(orderItem.getShopId());
        shopCartItemDto.setShopId(shopDetail.getShopId());
        shopCartItemDto.setShopName(shopDetail.getShopName());
        return Collections.singletonList(shopCartItemDto);
    }
    List<ShopCartItemDto> dbShopCartItems = getShopCartItems(userId);

    // 返回购物车选择的商品信息
    return dbShopCartItems
            .stream()
            .filter(shopCartItemDto -> basketId.contains(shopCartItemDto.getBasketId()))
            .collect(Collectors.toList());
}