Browse Source

指标计算rediskey

dev_shibei_match
jianjun 5 years ago
parent
commit
d4306676d4
  1. 8
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java
  3. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexCodeFieldReDao.java
  4. 54
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/redis/IndexCodeFieldReRedis.java
  5. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/CpcIndexCalculateService.java
  6. 17
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/IndexCodeFieldReService.java
  7. 11
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java
  8. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java
  9. 28
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/IndexCodeFieldReServiceImpl.java
  10. 4
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexCodeFieIdReDao.xml

8
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -297,4 +297,12 @@ public class RedisKeys {
public static String getExternalAppSecretKey(String appId) { public static String getExternalAppSecretKey(String appId) {
return String.format(rootPrefix+"externalapp:secret:%s",appId); return String.format(rootPrefix+"externalapp:secret:%s",appId);
} }
/**
* 计算指标时获取指标code和fields关系缓存Key
* @return
*/
public static String getIndexCodeFieldReKey() {
return rootPrefix.concat("data:index:indexcode:field");
}
} }

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java

@ -4,7 +4,7 @@ import com.epmet.commons.extappauth.bean.ExternalAppRequestParam;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.screen.form.IndexCalculateForm; import com.epmet.dto.screen.form.IndexCalculateForm;
import com.epmet.service.screen.CpcIndexCalculateService; import com.epmet.service.indexcal.CpcIndexCalculateService;
import com.epmet.service.screen.IndexCalculateService; import com.epmet.service.screen.IndexCalculateService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexCodeFieldReDao.java

@ -4,6 +4,10 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.screen.IndexCodeFieldReEntity; import com.epmet.entity.screen.IndexCodeFieldReEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.Map;
@Mapper @Mapper
public interface IndexCodeFieldReDao extends BaseDao<IndexCodeFieldReEntity> { public interface IndexCodeFieldReDao extends BaseDao<IndexCodeFieldReEntity> {
Map<String, String> getAllData();
} }

54
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/redis/IndexCodeFieldReRedis.java

@ -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);
}
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/CpcIndexCalculateService.java → epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/CpcIndexCalculateService.java

@ -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;

17
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/IndexCodeFieldReService.java

@ -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();
}

11
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/CpcIndexCalculateServiceImpl.java → epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java

@ -1,13 +1,13 @@
package com.epmet.service.screen.impl; package com.epmet.service.indexcal.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao; import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao;
import com.epmet.dao.screen.IndexCodeFieldReDao; import com.epmet.dao.screen.IndexCodeFieldReDao;
import com.epmet.dao.screen.IndexGroupDetailDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.entity.screen.IndexGroupDetailEntity; import com.epmet.entity.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum; import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.screen.CpcIndexCalculateService; import com.epmet.service.indexcal.CpcIndexCalculateService;
import com.epmet.service.screen.IndexGroupDetailService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -25,7 +25,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
@Autowired @Autowired
private IndexCodeFieldReDao indexCodeFieldReDao; private IndexCodeFieldReDao indexCodeFieldReDao;
@Autowired @Autowired
private IndexGroupDetailDao indexGroupDetailDao; private IndexGroupDetailService getDetailListByParentCode;
@Override @Override
public Boolean cpcIndexCalculate(CalculateCommonFormDTO formDTO) { public Boolean cpcIndexCalculate(CalculateCommonFormDTO formDTO) {
//计算最大最小值 //计算最大最小值
@ -35,12 +35,13 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
return false; return false;
} }
//获取指标权重信息 //获取指标权重信息
List<IndexGroupDetailEntity> indexDetails = indexGroupDetailDao.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); List<IndexGroupDetailEntity> indexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(),IndexCodeEnum.CAN_YU_YI_SHI.getCode());
if (CollectionUtils.isEmpty(indexDetails)){ if (CollectionUtils.isEmpty(indexDetails)){
log.warn("customerId:{} have not any indexGroupDetail",formDTO.getCustomerId()); log.warn("customerId:{} have not any indexGroupDetail",formDTO.getCustomerId());
return false; return false;
} }
log.info(JSON.toJSONString(minAndMaxList)); log.info(JSON.toJSONString(minAndMaxList));
Map<String, BigDecimal> list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId()); Map<String, BigDecimal> list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId());
return null; return null;

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java

@ -9,9 +9,6 @@ import com.epmet.dto.ScreenCustomerGridDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.CustomerGridInfoDTO; import com.epmet.dto.indexcal.CustomerGridInfoDTO;
import com.epmet.dto.indexcal.PageQueryGridFormDTO; import com.epmet.dto.indexcal.PageQueryGridFormDTO;
import com.epmet.dto.indexcollect.FactIndexGovrnAblityGridMonthlyDTO;
import com.epmet.dto.indexcollect.FactIndexPartyAblityGridMonthlyDTO;
import com.epmet.dto.indexcollect.FactIndexServiceAblityGridMonthlyDTO;
import com.epmet.entity.screen.IndexGroupDetailEntity; import com.epmet.entity.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum; import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.indexcal.GridCorreLationService; import com.epmet.service.indexcal.GridCorreLationService;
@ -22,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -160,6 +156,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
* @description 分页查询网格列表 * @description 分页查询网格列表
* @Date 2020/8/27 14:42 * @Date 2020/8/27 14:42
**/ **/
@Override
public List<ScreenCustomerGridDTO> pageGridList(PageQueryGridFormDTO formDTO){ public List<ScreenCustomerGridDTO> pageGridList(PageQueryGridFormDTO formDTO){
int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize();
formDTO.setPageIndex(pageIndex); formDTO.setPageIndex(pageIndex);

28
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/IndexCodeFieldReServiceImpl.java

@ -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;
}
}

4
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexCodeFieIdReDao.xml

@ -3,4 +3,8 @@
<mapper namespace="com.epmet.dao.screen.IndexCodeFieldReDao"> <mapper namespace="com.epmet.dao.screen.IndexCodeFieldReDao">
<select id="getAllData" resultType="java.util.Map">
SELECT INDEX_CODE,FIELD_ID FROM index_code_field_re WHERE DEL_FLAG = '0';
</select>
</mapper> </mapper>
Loading…
Cancel
Save