diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/TreeResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/TreeResultDTO.java index b12a8f46f5..0f28cda5b2 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/TreeResultDTO.java +++ b/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 centerMark; + + /** + * 机关级别 + */ + @JsonIgnore + private String level; + + @JsonIgnore + private String centerMarkA; + /** * 子目录 */ diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/screen/ScreenCustomerGridDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/screen/ScreenCustomerGridDao.java index 4e57c2f71d..ec6a2e7ee1 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/screen/ScreenCustomerGridDao.java +++ b/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 selectParymemberDistribution(@Param("parentId")String parentId); + + /** + * @Description 查询机关下的网格 + * @param agencyId + * @author zxc + * @date 2020/8/26 5:29 下午 + */ + List selectGridInfo(@Param("agencyId")String agencyId); } \ No newline at end of file diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/AgencyServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/AgencyServiceImpl.java index 0e1d557215..8ee16c42f6 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/AgencyServiceImpl.java +++ b/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 departmentList = this.getDepartmentList(("".equals(rootAgency.getPids()) || rootAgency.getPids().equals(NumConstant.ZERO_STR)) ? rootAgency.getValue():rootAgency.getPids().concat(",").concat(rootAgency.getValue())); - rootAgency.setChildren(departmentList); + List centerMark = this.getCenterMark(rootAgency.getCenterMarkA()); + rootAgency.setCenterMark(centerMark.size() == NumConstant.ZERO ? new ArrayList<>() : centerMark); + if (rootAgency.getLevel().equals(ScreenConstant.COMMUNITY)){ + List treeResultDTOS = screenCustomerGridDao.selectGridInfo(rootAgency.getValue()); + rootAgency.setChildren(treeResultDTOS); + }else { + List 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 getCenterMark(String centerMark){ + if (centerMark.length() == NumConstant.ZERO) { + return new ArrayList<>(); + } + List 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 getDepartmentList(String subAgencyPids) { List subAgencyList = screenCustomerAgencyDao.selectSubAgencyList(subAgencyPids); if (subAgencyList.size() > NumConstant.ZERO) { - for (TreeResultDTO sub : subAgencyList) { - List subAgency = getDepartmentList(sub.getPids() + "," + sub.getValue()); - sub.setChildren(subAgency); - } + subAgencyList.forEach(sub -> { + List centerMark = this.getCenterMark(sub.getCenterMarkA()); + sub.setCenterMark(centerMark.size() == NumConstant.ZERO ? new ArrayList<>() : centerMark); + if (sub.getLevel().equals(ScreenConstant.COMMUNITY)){ + List treeResultDTOS = screenCustomerGridDao.selectGridInfo(sub.getValue()); + treeResultDTOS.forEach(tree -> { + List centerMarkTree = this.getCenterMark(tree.getCenterMarkA()); + tree.setCenterMark(centerMarkTree.size() == NumConstant.ZERO ? new ArrayList<>() : centerMarkTree); + }); + sub.setChildren(treeResultDTOS); + }else { + List subAgency = getDepartmentList(sub.getPids() + "," + sub.getValue()); + sub.setChildren(subAgency); + } + }); } return subAgencyList; } diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml index cfdb8da6de..f66aef3609 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml +++ b/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 diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml index 1e45902a79..123fbbbc75 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml +++ b/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} + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CalculateCommonFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CalculateCommonFormDTO.java index 1d56dd17b1..4c43a57890 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CalculateCommonFormDTO.java +++ b/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 */ diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CustomerGridInfoDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CustomerGridInfoDTO.java new file mode 100644 index 0000000000..16ede875bb --- /dev/null +++ b/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 gridList; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/ExtremeValueCommonDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/ExtremeValueCommonDTO.java index 63dbb58262..fd383a61dd 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/ExtremeValueCommonDTO.java +++ b/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; /** * 最小值 */ diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/IndexGroupDetailDTO.java new file mode 100644 index 0000000000..efe372f027 --- /dev/null +++ b/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 + *

+ * 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.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; + +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenCustomerGridDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenCustomerGridDTO.java new file mode 100644 index 0000000000..ee7863d40b --- /dev/null +++ b/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 + *

+ * 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.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; + +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/IndexGroupDetailResult.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/IndexGroupDetailResult.java new file mode 100644 index 0000000000..0d6cea89c8 --- /dev/null +++ b/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 indexGroupDetailList; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDao.java index 5458720940..c873ffdb0b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDao.java +++ b/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 { int inertGroupFromTable(String customerId); + + List getDetailByCode(String indexCode, Integer offset); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailDao.java index 1a7dd4a0a8..8c7a4e82fb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailDao.java +++ b/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 { - + + List getDetailListByParentCode(@Param("customerId") String customerId, @Param("indexCode") String indexCode); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/ScreenCustomerGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/ScreenCustomerGridDao.java index c9fa856582..60f5a64ef4 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/ScreenCustomerGridDao.java +++ b/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 * @Date 10:52 2020-08-18 **/ void batchInsertCustomerGrid(@Param("list") List 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 + * @param customerId + * @author yinzuomei + * @description 查询客户下网格信息 + * @Date 2020/8/26 15:33 + **/ + List selectListByCustomerId(@Param("customerId")String customerId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailEntity.java index c0088d5383..1336dd050f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailEntity.java +++ b/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; + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailTemplateEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailTemplateEntity.java index 569cda48d9..20162b1198 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/IndexGroupDetailTemplateEntity.java +++ b/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; + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java index 931b9afd55..d19fb1d628 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java +++ b/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 { 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 { //构建 分组明细 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 { 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 { //构建 分组明细 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 { 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) { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/GridCorreLationService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/GridCorreLationService.java index 89001f5d4f..7b7905a535 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/GridCorreLationService.java +++ b/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; /** 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 70a6a9222b..a192fafc6a 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 @@ -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; } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupDetailService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupDetailService.java index ea03e298a1..aa69cba8e7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupDetailService.java +++ b/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 { - + /** + * desc:根据all_parent_index_code 获取指标明细 + * @param customerId + * @param indexCode + */ + List getDetailListByParentCode(String customerId,String... indexCode); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java index 54a368044b..d51cf3ea88 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java +++ b/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) { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java index db9fe1f411..6c22b360d6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java +++ b/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 implements IndexGroupDetailService { + @Override + public List 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()); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java index 85b8cf501d..9ce5ec4913 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java +++ b/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 indexVOS; - /** * 执行计算 * @return 每一条都是一个指标的,所有样本对应的,得分值 */ - public List exec(List indexVOS) { - this.indexVOS = indexVOS; + public List exec(List indexInputVOS) { - return indexVOS.stream().map(i -> { + return indexInputVOS.stream().map(i -> { String indexId = i.getIndexId(); - List indexValues = i.getIndexValues(); + List indexValueVOs = i.getIndexValueVOs(); BigDecimal weight = i.getWeight(); ScoreCalculator scoreCalculator = i.getScoreCalculator(); - List scores4OneIndex = scoreCalculator.normalize(indexValues, weight); + // 循环同一个指标内的多个样本值的SampleValue列表 + List 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()); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java index 984388d07d..94ea1ef0ad 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java @@ -22,7 +22,7 @@ public class IndexInputVO { /** * 指标的样本值 */ - private List indexValues; + private List> indexValueVOs; /** * 权重 @@ -31,8 +31,8 @@ public class IndexInputVO { private ScoreCalculator scoreCalculator; - public IndexInputVO(List indexValues, BigDecimal weight, ScoreCalculator scoreCalculator) { - this.indexValues = indexValues; + public IndexInputVO(List> indexValueVOs, BigDecimal weight, ScoreCalculator scoreCalculator) { + this.indexValueVOs = indexValueVOs; this.weight = weight; this.scoreCalculator = scoreCalculator; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexOutputVO.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexOutputVO.java index ab85a8cabf..fdf0a3dea9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexOutputVO.java +++ b/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 { +public class IndexOutputVO { /** * 指标标记,由使用者传入,用以标记该条指标的独有特性,一般用id或者code @@ -19,5 +19,5 @@ public class IndexOutputVO { /** * 指标的样本值 */ - private List indexScores; + private List indexScoreVOs; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/SampleScore.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/SampleScore.java new file mode 100644 index 0000000000..bd677fc861 --- /dev/null +++ b/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; + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/SampleValue.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/SampleValue.java new file mode 100644 index 0000000000..0818cc8d97 --- /dev/null +++ b/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 { + + private String sampleId; + + private T sampleValue; + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml index b7854f3338..ac4ad73bd5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml @@ -3,4 +3,9 @@ + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml index c044654dd8..8ec562b386 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml @@ -7,7 +7,7 @@ delete from index_group_detail_template diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml index 9a37bd23c0..1cf2922cd9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml @@ -54,4 +54,27 @@ + + + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java b/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java index 178468b0a0..1bb7514d5a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java +++ b/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 sc1 = new IntegerScoreCalculator(1, 8, ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.NEGATIVE); ScoreCalculator sc2 = new IntegerScoreCalculator(1, 8, ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.NEGATIVE); + List> index1SampleValues = Arrays.asList(new SampleValue<>("id1", 4), new SampleValue<>("id2", 1), new SampleValue<>("id3", 8)); + List> index2SampleValues = Arrays.asList(new SampleValue<>("id1", 1), new SampleValue<>("id2", 8), new SampleValue<>("id3", 3)); + // 每个指标的信息,包括样本列表,权重,指标标记 - IndexInputVO index1VO = new IndexInputVO<>("aaa", Arrays.asList(4, 1, 8), new BigDecimal(1), sc1); - IndexInputVO index2VO = new IndexInputVO<>("bbb", Arrays.asList(1, 8, 3), new BigDecimal(1), sc2); + IndexInputVO index1VO = new IndexInputVO<>("aaa", index1SampleValues, new BigDecimal(1), sc1); + IndexInputVO index2VO = new IndexInputVO<>("bbb", index2SampleValues, new BigDecimal(1), sc2); List indexInputVOS = Arrays.asList(index1VO, index2VO);