Browse Source

Merge remote-tracking branch 'origin/dev_screen_data' into dev_temp

dev_shibei_match
zxc 5 years ago
parent
commit
51ed0f6bb6
  1. 14
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/TreeResultDTO.java
  2. 13
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/screen/ScreenCustomerGridDao.java
  3. 50
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/AgencyServiceImpl.java
  4. 8
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml
  5. 15
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml
  6. 1
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CalculateCommonFormDTO.java
  7. 28
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CustomerGridInfoDTO.java
  8. 1
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/ExtremeValueCommonDTO.java
  9. 60
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailDTO.java
  10. 116
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenCustomerGridDTO.java
  11. 28
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/IndexGroupDetailResult.java
  12. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDao.java
  13. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailDao.java
  14. 19
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/ScreenCustomerGridDao.java
  15. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailEntity.java
  16. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailTemplateEntity.java
  17. 23
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java
  18. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/GridCorreLationService.java
  19. 39
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java
  20. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupDetailService.java
  21. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java
  22. 16
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java
  23. 18
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java
  24. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java
  25. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexOutputVO.java
  26. 19
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/SampleScore.java
  27. 17
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/SampleValue.java
  28. 5
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml
  29. 2
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml
  30. 23
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml
  31. 16
      epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java

14
epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/TreeResultDTO.java

@ -29,6 +29,20 @@ public class TreeResultDTO implements Serializable {
@JsonIgnore
private String pids;
/**
* 中心点位
*/
private List<Double> centerMark;
/**
* 机关级别
*/
@JsonIgnore
private String level;
@JsonIgnore
private String centerMarkA;
/**
* 子目录
*/

13
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/screen/ScreenCustomerGridDao.java

@ -17,10 +17,7 @@
package com.epmet.datareport.dao.screen;
import com.epmet.screen.dto.result.AgencyDistributionResultDTO;
import com.epmet.screen.dto.result.BranchResultDTO;
import com.epmet.screen.dto.result.ParymemberDistributionResultDTO;
import com.epmet.screen.dto.result.UserDistributionResultDTO;
import com.epmet.screen.dto.result.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -66,5 +63,13 @@ public interface ScreenCustomerGridDao {
* @date 2020/8/19 10:30 上午
*/
List<ParymemberDistributionResultDTO> selectParymemberDistribution(@Param("parentId")String parentId);
/**
* @Description 查询机关下的网格
* @param agencyId
* @author zxc
* @date 2020/8/26 5:29 下午
*/
List<TreeResultDTO> selectGridInfo(@Param("agencyId")String agencyId);
}

50
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/AgencyServiceImpl.java

@ -15,6 +15,7 @@ import com.epmet.datareport.service.screen.AgencyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
@ -52,11 +53,37 @@ public class AgencyServiceImpl implements AgencyService {
if (null == rootAgency){
return new TreeResultDTO();
}
List<TreeResultDTO> departmentList = this.getDepartmentList(("".equals(rootAgency.getPids()) || rootAgency.getPids().equals(NumConstant.ZERO_STR)) ? rootAgency.getValue():rootAgency.getPids().concat(",").concat(rootAgency.getValue()));
rootAgency.setChildren(departmentList);
List<Double> centerMark = this.getCenterMark(rootAgency.getCenterMarkA());
rootAgency.setCenterMark(centerMark.size() == NumConstant.ZERO ? new ArrayList<>() : centerMark);
if (rootAgency.getLevel().equals(ScreenConstant.COMMUNITY)){
List<TreeResultDTO> treeResultDTOS = screenCustomerGridDao.selectGridInfo(rootAgency.getValue());
rootAgency.setChildren(treeResultDTOS);
}else {
List<TreeResultDTO> departmentList = this.getDepartmentList(("".equals(rootAgency.getPids()) || rootAgency.getPids().equals(NumConstant.ZERO_STR)) ? rootAgency.getValue() : rootAgency.getPids().concat(",").concat(rootAgency.getValue()));
rootAgency.setChildren(departmentList);
}
return rootAgency;
}
/**
* @Description 处理centerMark
* @param centerMark
* @author zxc
* @date 2020/8/26 5:18 下午
*/
public List<Double> getCenterMark(String centerMark){
if (centerMark.length() == NumConstant.ZERO) {
return new ArrayList<>();
}
List<Double> result = new ArrayList<>();
String substring = centerMark.substring(2, centerMark.length() - 2);
String[] split = substring.split(",");
for (String s : split) {
result.add(Double.valueOf(s));
}
return result;
}
/**
* @Description 递归查询填充下级
* @param subAgencyPids
@ -66,10 +93,21 @@ public class AgencyServiceImpl implements AgencyService {
private List<TreeResultDTO> getDepartmentList(String subAgencyPids) {
List<TreeResultDTO> subAgencyList = screenCustomerAgencyDao.selectSubAgencyList(subAgencyPids);
if (subAgencyList.size() > NumConstant.ZERO) {
for (TreeResultDTO sub : subAgencyList) {
List<TreeResultDTO> subAgency = getDepartmentList(sub.getPids() + "," + sub.getValue());
sub.setChildren(subAgency);
}
subAgencyList.forEach(sub -> {
List<Double> centerMark = this.getCenterMark(sub.getCenterMarkA());
sub.setCenterMark(centerMark.size() == NumConstant.ZERO ? new ArrayList<>() : centerMark);
if (sub.getLevel().equals(ScreenConstant.COMMUNITY)){
List<TreeResultDTO> treeResultDTOS = screenCustomerGridDao.selectGridInfo(sub.getValue());
treeResultDTOS.forEach(tree -> {
List<Double> centerMarkTree = this.getCenterMark(tree.getCenterMarkA());
tree.setCenterMark(centerMarkTree.size() == NumConstant.ZERO ? new ArrayList<>() : centerMarkTree);
});
sub.setChildren(treeResultDTOS);
}else {
List<TreeResultDTO> subAgency = getDepartmentList(sub.getPids() + "," + sub.getValue());
sub.setChildren(subAgency);
}
});
}
return subAgencyList;
}

8
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml

@ -8,7 +8,9 @@
SELECT
agency_name AS label,
agency_id AS value,
pids AS pids
pids AS pids,
IFNULL(center_mark,'') AS centerMarkA,
level AS level
FROM
screen_customer_agency
WHERE
@ -22,7 +24,9 @@
SELECT
agency_id AS value,
agency_name AS label,
pids AS pids
pids AS pids,
IFNULL(center_mark,'') AS centerMarkA,
level AS level
FROM
screen_customer_agency
WHERE

15
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml

@ -67,4 +67,19 @@
AND scg.del_flag = 0
AND sutd.parent_id = #{parentId}
</select>
<!-- 查询机关下的网格 -->
<select id="selectGridInfo" resultType="com.epmet.screen.dto.result.TreeResultDTO">
SELECT
grid_id AS value,
grid_name AS label,
IFNULL(center_mark,'') AS centerMarkA
FROM
screen_customer_grid
WHERE
del_flag = '0'
AND parent_agency_id = #{agencyId}
ORDER BY
created_time DESC
</select>
</mapper>

1
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CalculateCommonFormDTO.java

@ -12,6 +12,7 @@ import java.io.Serializable;
*/
@Data
public class CalculateCommonFormDTO implements Serializable {
private static final long serialVersionUID = -5689788391963427717L;
/**
* 月份id: yyyyMM
*/

28
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CustomerGridInfoDTO.java

@ -0,0 +1,28 @@
package com.epmet.dto.indexcal;
import com.epmet.dto.ScreenCustomerGridDTO;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 客户下所有网格
*
* @author yinzuomei@elink-cn.com
* @date 2020/8/26 13:45
*/
@Data
public class CustomerGridInfoDTO implements Serializable {
private static final long serialVersionUID = -3211409107659568304L;
/**
* 网格总数
*/
private Integer total;
/**
* 网格列表
*/
private List<ScreenCustomerGridDTO> gridList;
}

1
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/ExtremeValueCommonDTO.java

@ -14,6 +14,7 @@ import java.math.BigDecimal;
@Data
public class ExtremeValueCommonDTO implements Serializable {
private static final long serialVersionUID = -6295067080250068024L;
/**
* 最小值
*/

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

116
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenCustomerGridDTO.java

@ -0,0 +1,116 @@
/**
* 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;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 网格(党支部)信息
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-26
*/
@Data
public class ScreenCustomerGridDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID 主键ID
*/
private String id;
/**
* 客户id
*/
private String customerId;
/**
* 网格id
*/
private String gridId;
/**
* 组织名称
*/
private String gridName;
/**
* 网格所属组织id
*/
private String parentAgencyId;
/**
* 坐标区域
*/
private String areaMarks;
/**
* 中心点位
*/
private String centerMark;
/**
* 党支部=网格的位置
*/
private String partyMark;
/**
* 删除标识 0.未删除 1.已删除
*/
private Integer delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增)
*/
private String dataEndTime;
/**
* 所有上级ID用英文逗号分开
*/
private String allParentIds;
}

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

19
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/ScreenCustomerGridDao.java

@ -18,6 +18,7 @@
package com.epmet.dao.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.ScreenCustomerGridDTO;
import com.epmet.dto.screencoll.form.CustomerGridFormDTO;
import com.epmet.entity.screen.ScreenCustomerGridEntity;
import org.apache.ibatis.annotations.Mapper;
@ -55,4 +56,22 @@ public interface ScreenCustomerGridDao extends BaseDao<ScreenCustomerGridEntity>
* @Date 10:52 2020-08-18
**/
void batchInsertCustomerGrid(@Param("list") List<CustomerGridFormDTO> list, @Param("customerId")String customerId);
/**
* @return java.lang.Integer
* @param customerId
* @author yinzuomei
* @description 查询客户下网格总数
* @Date 2020/8/26 15:33
**/
Integer selectCountByCustomerId(@Param("customerId") String customerId);
/**
* @return java.util.List<com.epmet.dto.ScreenCustomerGridDTO>
* @param customerId
* @author yinzuomei
* @description 查询客户下网格信息
* @Date 2020/8/26 15:33
**/
List<ScreenCustomerGridDTO> selectListByCustomerId(@Param("customerId")String customerId);
}

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) {

1
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/GridCorreLationService.java

@ -1,5 +1,6 @@
package com.epmet.service.indexcal;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
/**

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

@ -1,7 +1,18 @@
package com.epmet.service.indexcal.impl;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.indexcoll.FactIndexGovrnAblityGridMonthlyDao;
import com.epmet.dao.indexcoll.FactIndexPartyAblityGridMonthlyDao;
import com.epmet.dao.indexcoll.FactIndexServiceAblityGridMonthlyDao;
import com.epmet.dao.screen.ScreenCustomerGridDao;
import com.epmet.dto.ScreenCustomerGridDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.CustomerGridInfoDTO;
import com.epmet.service.indexcal.GridCorreLationService;
import io.swagger.annotations.Authorization;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
@ -12,6 +23,16 @@ import org.springframework.stereotype.Service;
*/
@Service
public class GridCorreLationServiceImpl implements GridCorreLationService {
private Logger logger = LogManager.getLogger(GridCorreLationServiceImpl.class);
@Autowired
private FactIndexGovrnAblityGridMonthlyDao factIndexGovrnAblityGridMonthlyDao;
@Autowired
private FactIndexPartyAblityGridMonthlyDao factIndexPartyAblityGridMonthlyDao;
@Autowired
private FactIndexServiceAblityGridMonthlyDao factIndexServiceAblityGridMonthlyDao;
@Autowired
private ScreenCustomerGridDao screenCustomerGridDao;
/**
* @param formDTO
@ -22,6 +43,22 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
**/
@Override
public Boolean calculateGridCorreLation(CalculateCommonFormDTO formDTO) {
return null;
return true;
}
/**
* @return com.epmet.dto.indexcal.CustomerGridInfoDTO
* @param customerId
* @author yinzuomei
* @description 查询客户下网格信息
* @Date 2020/8/26 15:37
**/
public CustomerGridInfoDTO queryCustomerGridInfo(String customerId){
CustomerGridInfoDTO customerGridInfoDTO=new CustomerGridInfoDTO();
customerGridInfoDTO.setTotal(screenCustomerGridDao.selectCountByCustomerId(customerId));
customerGridInfoDTO.setGridList(screenCustomerGridDao.selectListByCustomerId(customerId));
return customerGridInfoDTO;
}
}

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

18
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java

@ -8,25 +8,23 @@ import java.util.stream.Collectors;
public class BatchScoreCalculator {
/**
* 每个指标都是一条数据每一条数据中包含该指标的一组样本
*/
private List<IndexInputVO> indexVOS;
/**
* 执行计算
* @return 每一条都是一个指标的所有样本对应的得分值
*/
public List<IndexOutputVO> exec(List<IndexInputVO> indexVOS) {
this.indexVOS = indexVOS;
public List<IndexOutputVO> exec(List<IndexInputVO> indexInputVOS) {
return indexVOS.stream().map(i -> {
return indexInputVOS.stream().map(i -> {
String indexId = i.getIndexId();
List indexValues = i.getIndexValues();
List<SampleValue> indexValueVOs = i.getIndexValueVOs();
BigDecimal weight = i.getWeight();
ScoreCalculator scoreCalculator = i.getScoreCalculator();
List scores4OneIndex = scoreCalculator.normalize(indexValues, weight);
// 循环同一个指标内的多个样本值的SampleValue列表
List<SampleScore> scores4OneIndex = indexValueVOs.stream().map(vo -> {
BigDecimal score = scoreCalculator.normalize(vo.getSampleValue(), weight);
return new SampleScore(vo.getSampleId(), score);
}).collect(Collectors.toList());
return new IndexOutputVO(indexId, scores4OneIndex);
}).collect(Collectors.toList());

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java

@ -22,7 +22,7 @@ public class IndexInputVO<T> {
/**
* 指标的样本值
*/
private List<T> indexValues;
private List<SampleValue<T>> indexValueVOs;
/**
* 权重
@ -31,8 +31,8 @@ public class IndexInputVO<T> {
private ScoreCalculator<T> scoreCalculator;
public IndexInputVO(List<T> indexValues, BigDecimal weight, ScoreCalculator<T> scoreCalculator) {
this.indexValues = indexValues;
public IndexInputVO(List<SampleValue<T>> indexValueVOs, BigDecimal weight, ScoreCalculator<T> scoreCalculator) {
this.indexValueVOs = indexValueVOs;
this.weight = weight;
this.scoreCalculator = scoreCalculator;
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexOutputVO.java

@ -8,7 +8,7 @@ import java.util.List;
@Data
@AllArgsConstructor
public class IndexOutputVO<T> {
public class IndexOutputVO {
/**
* 指标标记由使用者传入用以标记该条指标的独有特性一般用id或者code
@ -19,5 +19,5 @@ public class IndexOutputVO<T> {
/**
* 指标的样本值
*/
private List<BigDecimal> indexScores;
private List<SampleScore> indexScoreVOs;
}

19
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/SampleScore.java

@ -0,0 +1,19 @@
package com.epmet.support.normalizing.batch;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.math.BigDecimal;
/**
* 样本得分对象
*/
@Data
@AllArgsConstructor
public class SampleScore {
private String sampleId;
private BigDecimal sampleScore;
}

17
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/SampleValue.java

@ -0,0 +1,17 @@
package com.epmet.support.normalizing.batch;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* 样本值对象
*/
@Data
@AllArgsConstructor
public class SampleValue<T> {
private String sampleId;
private T sampleValue;
}

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>

23
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml

@ -54,4 +54,27 @@
</foreach>
</insert>
<!-- 查询客户下网格总数 -->
<select id="selectCountByCustomerId" parameterType="map" resultType="java.lang.Integer">
SELECT
count( GRID_ID ) AS total
FROM
screen_customer_grid m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
</select>
<!-- 查询客户下网格信息 -->
<select id="selectListByCustomerId" parameterType="map" resultType="com.epmet.dto.ScreenCustomerGridDTO">
SELECT
m.GRID_ID,
m.CUSTOMER_ID,
m.GRID_NAME
FROM
screen_customer_grid m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID = #{customerId}
</select>
</mapper>

16
epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java

@ -4,6 +4,7 @@ import com.epmet.support.normalizing.*;
import com.epmet.support.normalizing.batch.BatchScoreCalculator;
import com.epmet.support.normalizing.batch.IndexInputVO;
import com.epmet.support.normalizing.batch.IndexOutputVO;
import com.epmet.support.normalizing.batch.SampleValue;
import org.junit.Test;
import java.math.BigDecimal;
@ -24,10 +25,8 @@ public class DemoScoreCal {
@Test
public void demoInteger() {
Integer[] iArray = {4, 8, 1, 3, 2};
BigDecimal minScore = new BigDecimal(5);
BigDecimal maxScore = new BigDecimal(10);
ScoreCalculator sc = new IntegerScoreCalculator(iArray, minScore, maxScore, Correlation.NEGATIVE);
ScoreCalculator sc = new IntegerScoreCalculator(iArray, ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.NEGATIVE);
BigDecimal[] scores = sc.normalize(iArray);
Arrays.stream(scores).forEach(s -> System.out.println(s));
}
@ -38,10 +37,8 @@ public class DemoScoreCal {
@Test
public void demoIntegerPartical() {
Integer[] iArray = {4, 1, 8};
BigDecimal minScore = new BigDecimal(5);
BigDecimal maxScore = new BigDecimal(10);
ScoreCalculator sc = new IntegerScoreCalculator(1, 8, minScore, maxScore, Correlation.NEGATIVE);
ScoreCalculator sc = new IntegerScoreCalculator(1, 8, ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.NEGATIVE);
BigDecimal[] scores = sc.normalize(iArray);// 此处也可以直接使用list参数的重载方法,计算阶段没有任何区别,区别在于new IntegerScoreCalculator()阶段
Arrays.stream(scores).forEach(s -> System.out.println(s));
}
@ -76,9 +73,12 @@ public class DemoScoreCal {
ScoreCalculator<Integer> sc1 = new IntegerScoreCalculator(1, 8, ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.NEGATIVE);
ScoreCalculator<Integer> sc2 = new IntegerScoreCalculator(1, 8, ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.NEGATIVE);
List<SampleValue<Integer>> index1SampleValues = Arrays.asList(new SampleValue<>("id1", 4), new SampleValue<>("id2", 1), new SampleValue<>("id3", 8));
List<SampleValue<Integer>> index2SampleValues = Arrays.asList(new SampleValue<>("id1", 1), new SampleValue<>("id2", 8), new SampleValue<>("id3", 3));
// 每个指标的信息,包括样本列表,权重,指标标记
IndexInputVO<Integer> index1VO = new IndexInputVO<>("aaa", Arrays.asList(4, 1, 8), new BigDecimal(1), sc1);
IndexInputVO<Integer> index2VO = new IndexInputVO<>("bbb", Arrays.asList(1, 8, 3), new BigDecimal(1), sc2);
IndexInputVO<Integer> index1VO = new IndexInputVO<>("aaa", index1SampleValues, new BigDecimal(1), sc1);
IndexInputVO<Integer> index2VO = new IndexInputVO<>("bbb", index2SampleValues, new BigDecimal(1), sc2);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO);

Loading…
Cancel
Save