Browse Source

获取要计算的指标明细权重

dev_shibei_match
jianjun 5 years ago
parent
commit
3538826d9d
  1. 60
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailDTO.java
  2. 28
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/IndexGroupDetailResult.java
  3. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDao.java
  4. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailDao.java
  5. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailEntity.java
  6. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailTemplateEntity.java
  7. 23
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java
  8. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupDetailService.java
  9. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java
  10. 16
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java
  11. 5
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml
  12. 2
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml

60
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailDTO.java

@ -0,0 +1,60 @@
/**
* 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.dto.screen;
import lombok.Data;
import java.math.BigDecimal;
/**
* 客户指标详情
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-19
*/
@Data
public class IndexGroupDetailDTO {
private static final long serialVersionUID = 1L;
/**
* index_group.id
*/
private String indexGroupId;
/**
* 指标id
*/
private String indexId;
/**
* 权重同一组权重总和=1
*/
private BigDecimal weight;
/**
* 是否启用启用enable 禁用disabled
*/
private String status;
/**
* 阈值 如果是百分比 则为除以100以后的值
*/
private BigDecimal threshold;
}

28
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/IndexGroupDetailResult.java

@ -0,0 +1,28 @@
package com.epmet.dto.screen.result;
import com.epmet.dto.screen.IndexGroupDetailDTO;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* desc计算指标时 获取要计算的组的指标
*
* @author liujianjun
*/
@Data
public class IndexGroupDetailResult implements Serializable {
private static final long serialVersionUID = 3937041236261115759L;
/**
* 是否有下一组
*/
private Boolean hasNextGroup;
/**
* desc:指标详情列表 如果hasNextGroup是true则返回的是明细否则返回的是上级的分组的指标明细
* 例如网格的三大能力上次已经返回完毕下一次调用时返回的是网格相关的三大能力的 指标明细
*/
private List<IndexGroupDetailDTO> indexGroupDetailList;
}

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

@ -21,6 +21,8 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.screen.IndexGroupEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 客户指标分组
*
@ -31,4 +33,6 @@ import org.apache.ibatis.annotations.Mapper;
public interface IndexGroupDao extends BaseDao<IndexGroupEntity> {
int inertGroupFromTable(String customerId);
List<IndexGroupEntity> getDetailByCode(String indexCode, Integer offset);
}

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailDao.java

@ -20,6 +20,9 @@ package com.epmet.dao.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.screen.IndexGroupDetailEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 客户指标详情
@ -29,5 +32,6 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface IndexGroupDetailDao extends BaseDao<IndexGroupDetailEntity> {
List<IndexGroupDetailEntity> getDetailListByParentCode(@Param("customerId") String customerId, @Param("indexCode") String indexCode);
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailEntity.java

@ -62,4 +62,14 @@ public class IndexGroupDetailEntity extends BaseEpmetEntity {
*/
private String status;
/**
* 阈值 如果是百分比 则为除以100以后的值
*/
private BigDecimal threshold;
/**
* 所有指标code拼接的字符串 冒号隔开
*/
private String allParentIndexCode;
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailTemplateEntity.java

@ -62,4 +62,9 @@ public class IndexGroupDetailTemplateEntity extends BaseEpmetEntity {
*/
private BigDecimal threshold;
/**
* 所有指标code拼接的字符串 冒号隔开
*/
private String allParentIndexCode;
}

23
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java

@ -3,6 +3,7 @@ package com.epmet.model;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.utils.UniqueIdGenerator;
import com.epmet.entity.screen.IndexDictEntity;
import com.epmet.entity.screen.IndexGroupDetailTemplateEntity;
@ -122,7 +123,7 @@ public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
group1.setIndexCode(Pinyin4jUtil.getFirstSpellPinYin(indexDictEntity.getIndexName(),true));
indexGroupMap.put(index.getLevel1Index(), group1);
}
StringBuilder allIndexCodeSb = new StringBuilder(group1.getIndexCode());
String level4Index = index.getLevel4Index();
indexDictEntity = indexDicMap.get(level4Index);
String level2GroupId = UniqueIdGenerator.generate();
@ -139,14 +140,16 @@ public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
//构建 分组明细
templateEntity = indexGroupDetailMap.get(level4Index);
if (templateEntity == null) {
buildIndexGroupDetail(indexDictEntity, index, group1.getId(), 2);
buildIndexGroupDetail(indexDictEntity, index, group1, allIndexCodeSb.toString(), 2);
}
}
indexDictEntity = indexDicMap.get(index.getLevel5Index());
allIndexCodeSb.append(StrConstant.COLON);
allIndexCodeSb.append(group2.getIndexCode());
templateEntity = indexGroupDetailMap.get(index.getLevel5Index());
if (templateEntity == null) {
buildIndexGroupDetail(indexDictEntity, index, group2.getId(), 5);
buildIndexGroupDetail(indexDictEntity, index, group2, allIndexCodeSb.toString(), 5);
}
} else {
//todo 测试完去掉
@ -162,7 +165,7 @@ public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
group1.setIndexCode(Pinyin4jUtil.getFirstSpellPinYin(indexDictEntity.getIndexName(),true));
indexGroupMap.put(index.getLevel1Index(), group1);
}
StringBuilder allIndexCodeSb = new StringBuilder(group1.getIndexCode());
String level2Index = index.getLevel2Index();
indexDictEntity = indexDicMap.get(level2Index);
String level2GroupId = UniqueIdGenerator.generate();
@ -179,14 +182,15 @@ public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
//构建 分组明细
templateEntity = indexGroupDetailMap.get(level2Index);
if (templateEntity == null) {
buildIndexGroupDetail(indexDictEntity, index, group1.getId(), 2);
buildIndexGroupDetail(indexDictEntity, index, group1, allIndexCodeSb.toString(), 2);
}
}
indexDictEntity = indexDicMap.get(index.getLevel5Index());
allIndexCodeSb.append(StrConstant.COLON);
allIndexCodeSb.append(group2.getIndexCode());
templateEntity = indexGroupDetailMap.get(index.getLevel5Index());
if (templateEntity == null) {
buildIndexGroupDetail(indexDictEntity, index, group2.getId(), 5);
buildIndexGroupDetail(indexDictEntity, index, group2, allIndexCodeSb.toString(), 5);
}
}
//}
@ -195,10 +199,11 @@ public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
LOGGER.info("所有指标分组明细数据解析完成:{}", JSON.toJSONString(indexGroupDetailMap.values()));
}
private void buildIndexGroupDetail(IndexDictEntity indexDictEntity, IndexModel index, String groupId, Integer level) {
private void buildIndexGroupDetail(IndexDictEntity indexDictEntity, IndexModel index, IndexGroupTemplateEntity parentGroup, String allIndexCode, Integer level) {
IndexGroupDetailTemplateEntity templateEntity;
templateEntity = new IndexGroupDetailTemplateEntity();
templateEntity.setIndexGroupId(groupId);
templateEntity.setIndexGroupId(parentGroup.getId());
templateEntity.setAllParentIndexCode(allIndexCode);
templateEntity.setIndexId(indexDictEntity.getId());
if (level == 5) {

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupDetailService.java

@ -20,6 +20,8 @@ package com.epmet.service.screen;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.screen.IndexGroupDetailEntity;
import java.util.List;
/**
* 客户指标详情
*
@ -27,5 +29,10 @@ import com.epmet.entity.screen.IndexGroupDetailEntity;
* @since v1.0.0 2020-08-19
*/
public interface IndexGroupDetailService extends BaseService<IndexGroupDetailEntity> {
/**
* desc根据all_parent_index_code 获取指标明细
* @param customerId
* @param indexCode
*/
List<IndexGroupDetailEntity> getDetailListByParentCode(String customerId,String... indexCode);
}

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java

@ -3,6 +3,8 @@ package com.epmet.service.screen.impl;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao;
import com.epmet.dao.screen.IndexGroupDao;
import com.epmet.dao.screen.IndexGroupDetailDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.screen.form.IndexCalculateForm;
import com.epmet.entity.indexcoll.FactIndexPartyAblityCpcMonthlyEntity;
@ -31,6 +33,10 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
private FactIndexPartyAblityCpcMonthlyDao factIndexPartyAblityCpcMonthlyDao;
@Autowired
private GridCorreLationService gridCorreLationService;
@Autowired
private IndexGroupDao indexGroupDao;
@Autowired
private IndexGroupDetailDao indexGroupDetailDao;
@Override
public Boolean indexCalculate(IndexCalculateForm formDTO) {

16
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java

@ -18,11 +18,15 @@
package com.epmet.service.screen.impl;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.dao.screen.IndexGroupDetailDao;
import com.epmet.entity.screen.IndexGroupDetailEntity;
import com.epmet.service.screen.IndexGroupDetailService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 客户指标详情
*
@ -33,4 +37,16 @@ import org.springframework.stereotype.Service;
public class IndexGroupDetailServiceImpl extends BaseServiceImpl<IndexGroupDetailDao, IndexGroupDetailEntity> implements IndexGroupDetailService {
@Override
public List<IndexGroupDetailEntity> getDetailListByParentCode(String customerId,String... indexCode) {
if (indexCode == null || indexCode.length == 0){
throw new RenException("参数错误");
}
StringBuilder sb = new StringBuilder();
for (String code:indexCode){
sb.append(code).append(StrConstant.COLON);
}
sb = sb.deleteCharAt(sb.length());
return baseDao.getDetailListByParentCode(customerId,sb.toString());
}
}

5
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml

@ -3,4 +3,9 @@
<mapper namespace="com.epmet.dao.screen.IndexGroupDetailDao">
<select id="getDetailListByParentCode" resultType="com.epmet.entity.screen.IndexGroupDetailEntity">
select ID, INDEX_GROUP_ID, INDEX_ID, WEIGHT, THRESHOLD FROM index_group_detail_template
where STATUS = 'enable' and DEL_FLAG = '0'
</select>
</mapper>

2
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml

@ -7,7 +7,7 @@
delete from index_group_detail_template
</delete>
<select id="selectAll" resultType="com.epmet.entity.screen.IndexGroupDetailTemplateEntity">
select ID, INDEX_GROUP_ID, INDEX_ID, WEIGHT, THRESHOLD
select ID, INDEX_GROUP_ID, INDEX_ID, WEIGHT, THRESHOLD, ALL_PARENT_INDEX_CODE
from index_group_detail_template
where STATUS = 'enable' and DEL_FLAG = '0'
</select>

Loading…
Cancel
Save