| | |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | | String patten = RedisConst.buildKey(companyId, RedisConst.KEY_DEPOT) + "*"; |
| | | |
| | | Collection<String> keys = redisCache.keys(patten); |
| | | if (null == keys) { |
| | | return null; |
| | | } |
| | | |
| | | List<Depot> list = new ArrayList<>(); |
| | | |
| | | String patten = RedisConst.buildKey(companyId, RedisConst.KEY_DEPOT) + "*"; |
| | | Collection<String> keys = redisCache.keys(patten); |
| | | if (null != keys) { |
| | | for (String key : keys) { |
| | | list.add((Depot) redisCache.getCacheObject(key)); |
| | | } |
| | | } |
| | | |
| | | //缓存获取为空,则查询数据库 |
| | | if (list.size() < 1) { |
| | | if (list.isEmpty()) { |
| | | list = this.getData(companyId,null, false); |
| | | setCacheDepotList(list, companyId); |
| | | } |
| | | |
| | | if(!list.isEmpty()){ |
| | | //重新排序 |
| | | Collections.sort(list, (p1, p2) -> p1.getOrderNum() - p2.getOrderNum()); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | |
| | | result.add(depot); |
| | | } |
| | | } |
| | | if(!result.isEmpty()){ |
| | | //重新排序 |
| | | Collections.sort(result, (p1, p2) -> p1.getOrderNum() - p2.getOrderNum()); |
| | | Collections.sort(list, (p1, p2) -> p1.getOrderNum() - p2.getOrderNum()); |
| | | } |
| | | return result; |
| | | } |
| | | |