forked from rongchao/epmet-cloud-rizhao
10 changed files with 124 additions and 11 deletions
@ -0,0 +1,54 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.redis; |
||||
|
|
||||
|
import com.epmet.commons.tools.redis.RedisKeys; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.data.redis.core.HashOperations; |
||||
|
import org.springframework.data.redis.core.RedisTemplate; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
import java.util.concurrent.TimeUnit; |
||||
|
|
||||
|
@Slf4j |
||||
|
@Component |
||||
|
public class IndexCodeFieldReRedis { |
||||
|
@Autowired |
||||
|
private RedisTemplate redisTemplate; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* @Description 获取指标code和字段Id的关系 |
||||
|
*/ |
||||
|
public Map<String, String> getIndexCodeFiledReMap() { |
||||
|
HashOperations hashOperations = redisTemplate.opsForHash(); |
||||
|
Map<String, String> values = hashOperations.entries(RedisKeys.getIndexCodeFieldReKey()); |
||||
|
return values; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @Description 存入指标code和字段Id的关系 |
||||
|
*/ |
||||
|
public void setIndexCodeFiledReMap(Map<String, String> records) { |
||||
|
HashOperations hashOperations = redisTemplate.opsForHash(); |
||||
|
hashOperations.putAll(RedisKeys.getIndexCodeFieldReKey(), records); |
||||
|
redisTemplate.expire(RedisKeys.getIndexCodeFieldReKey(), 1, TimeUnit.DAYS); |
||||
|
} |
||||
|
} |
@ -1,4 +1,4 @@ |
|||||
package com.epmet.service.screen; |
package com.epmet.service.indexcal; |
||||
|
|
||||
import com.epmet.dto.indexcal.CalculateCommonFormDTO; |
import com.epmet.dto.indexcal.CalculateCommonFormDTO; |
||||
|
|
@ -0,0 +1,17 @@ |
|||||
|
package com.epmet.service.indexcal; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 党员指标计算service |
||||
|
* |
||||
|
* @author liujianjun@elink-cn.com |
||||
|
* @date 2020/8/18 10:25 |
||||
|
*/ |
||||
|
public interface IndexCodeFieldReService { |
||||
|
/** |
||||
|
* desc:获取指标code对应的字段值 |
||||
|
* @return |
||||
|
*/ |
||||
|
Map<String,String> getIndexCodeFieldReList(); |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package com.epmet.service.indexcal.impl; |
||||
|
|
||||
|
import com.epmet.dao.screen.IndexCodeFieldReDao; |
||||
|
import com.epmet.redis.IndexCodeFieldReRedis; |
||||
|
import com.epmet.service.indexcal.IndexCodeFieldReService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.util.CollectionUtils; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Service |
||||
|
public class IndexCodeFieldReServiceImpl implements IndexCodeFieldReService { |
||||
|
@Autowired |
||||
|
private IndexCodeFieldReDao indexCodeFieldReDao; |
||||
|
|
||||
|
@Autowired |
||||
|
private IndexCodeFieldReRedis indexCodeFieldReRedis; |
||||
|
@Override |
||||
|
public Map<String, String> getIndexCodeFieldReList() { |
||||
|
Map<String, String> indexCodeFiledReMap = indexCodeFieldReRedis.getIndexCodeFiledReMap(); |
||||
|
if (CollectionUtils.isEmpty(indexCodeFiledReMap)){ |
||||
|
indexCodeFiledReMap = indexCodeFieldReDao.getAllData(); |
||||
|
indexCodeFieldReRedis.setIndexCodeFiledReMap(indexCodeFiledReMap); |
||||
|
} |
||||
|
return indexCodeFiledReMap; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue