diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index a5be29eb58..0d623e2010 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/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) { return String.format(rootPrefix+"externalapp:secret:%s",appId); } + + /** + * 计算指标时获取指标code和fields关系缓存Key + * @return + */ + public static String getIndexCodeFieldReKey() { + return rootPrefix.concat("data:index:indexcode:field"); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java index 4117f6dc75..c2211c0d80 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java +++ b/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.dto.indexcal.CalculateCommonFormDTO; 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexCodeFieldReDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexCodeFieldReDao.java index edd402249f..3088f29531 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexCodeFieldReDao.java +++ b/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 org.apache.ibatis.annotations.Mapper; +import java.util.Map; + @Mapper public interface IndexCodeFieldReDao extends BaseDao { + Map getAllData(); + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/redis/IndexCodeFieldReRedis.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/redis/IndexCodeFieldReRedis.java new file mode 100644 index 0000000000..2863952420 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 getIndexCodeFiledReMap() { + HashOperations hashOperations = redisTemplate.opsForHash(); + Map values = hashOperations.entries(RedisKeys.getIndexCodeFieldReKey()); + return values; + } + + /** + * @Description 存入指标code和字段Id的关系 + */ + public void setIndexCodeFiledReMap(Map records) { + HashOperations hashOperations = redisTemplate.opsForHash(); + hashOperations.putAll(RedisKeys.getIndexCodeFieldReKey(), records); + redisTemplate.expire(RedisKeys.getIndexCodeFieldReKey(), 1, TimeUnit.DAYS); + } +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/CpcIndexCalculateService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/CpcIndexCalculateService.java similarity index 90% rename from epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/CpcIndexCalculateService.java rename to epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/CpcIndexCalculateService.java index bb4bc6e397..d65f6d43db 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/CpcIndexCalculateService.java +++ b/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; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/IndexCodeFieldReService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/IndexCodeFieldReService.java new file mode 100644 index 0000000000..d8a40a8a52 --- /dev/null +++ b/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 getIndexCodeFieldReList(); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/CpcIndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java similarity index 79% rename from epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/CpcIndexCalculateServiceImpl.java rename to epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java index 476eacb60c..46a25bb129 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/CpcIndexCalculateServiceImpl.java +++ b/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.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao; import com.epmet.dao.screen.IndexCodeFieldReDao; -import com.epmet.dao.screen.IndexGroupDetailDao; import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.entity.screen.IndexGroupDetailEntity; 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -25,7 +25,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { @Autowired private IndexCodeFieldReDao indexCodeFieldReDao; @Autowired - private IndexGroupDetailDao indexGroupDetailDao; + private IndexGroupDetailService getDetailListByParentCode; @Override public Boolean cpcIndexCalculate(CalculateCommonFormDTO formDTO) { //计算最大最小值 @@ -35,12 +35,13 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { return false; } //获取指标权重信息 - List indexDetails = indexGroupDetailDao.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); + List indexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(),IndexCodeEnum.CAN_YU_YI_SHI.getCode()); if (CollectionUtils.isEmpty(indexDetails)){ log.warn("customerId:{} have not any indexGroupDetail",formDTO.getCustomerId()); return false; } + log.info(JSON.toJSONString(minAndMaxList)); Map list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId()); return null; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java index 96b82127c6..8a922020fa 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java +++ b/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.CustomerGridInfoDTO; 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.eum.IndexCodeEnum; 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.util.CollectionUtils; -import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -160,6 +156,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { * @description 分页查询网格列表 * @Date 2020/8/27 14:42 **/ + @Override public List pageGridList(PageQueryGridFormDTO formDTO){ int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); formDTO.setPageIndex(pageIndex); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/IndexCodeFieldReServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/IndexCodeFieldReServiceImpl.java new file mode 100644 index 0000000000..047973e066 --- /dev/null +++ b/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 getIndexCodeFieldReList() { + Map indexCodeFiledReMap = indexCodeFieldReRedis.getIndexCodeFiledReMap(); + if (CollectionUtils.isEmpty(indexCodeFiledReMap)){ + indexCodeFiledReMap = indexCodeFieldReDao.getAllData(); + indexCodeFieldReRedis.setIndexCodeFiledReMap(indexCodeFiledReMap); + } + return indexCodeFiledReMap; + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexCodeFieIdReDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexCodeFieIdReDao.xml index 4186e0e155..c903e17583 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexCodeFieIdReDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexCodeFieIdReDao.xml @@ -3,4 +3,8 @@ + + \ No newline at end of file