Browse Source

年表-月表,访问数据库次数优化

master
zhangyongzhangyong 5 years ago
parent
commit
6ad06926ef
  1. 21
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  2. 19
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerDeptDao.java
  3. 19
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java
  4. 54
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java
  5. 22
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  6. 23
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerDeptDao.xml
  7. 24
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml

21
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java

@ -56,17 +56,6 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
**/
void batchInsertCustomerAgency(@Param("list") List<CustomerAgencyFormDTO> list, @Param("customerId")String customerId);
/**
* 根据客户id组织id查询区/街道 组织名称
*
* @param customerId 客户id
* @param agencyId 组织id
* @return java.util.String
* @Author zhangyong
* @Date 16:57 2020-09-03
**/
String selectParentAgencyInfo(@Param("customerId")String customerId, @Param("agencyId")String agencyId);
/**
* 返回当前客户下未匹配到的组织信息
* @param customerId 客户id
@ -76,4 +65,14 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
* @Date 14:38 2020-09-04
**/
List<ScreenCustomerAgencyEntity> selectListMismatcAgencyInfo(@Param("customerId")String customerId, @Param("agencyIds") String[] agencyIds);
/**
* 根据客户id查询区/街道 组织名称id
*
* @param customerId 客户id
* @return java.util.List<com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity>
* @Author zhangyong
* @Date 16:57 2020-09-03
**/
List<ScreenCustomerAgencyEntity> selectListAgencyInfo(@Param("customerId")String customerId);
}

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

@ -57,16 +57,6 @@ public interface ScreenCustomerDeptDao extends BaseDao<ScreenCustomerDeptEntity>
**/
void batchInsertCustomerDept(@Param("list") List<CustomerDeptFormDTO> list, @Param("customerId")String customerId);
/**
* 根据客户id部门id查询部门父级 信息
* @param customerId 客户id
* @param deptId 部门id
* @return com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity
* @Author zhangyong
* @Date 16:57 2020-09-03
**/
ScreenCustomerDeptEntity selectParentDeptInfo(@Param("customerId")String customerId, @Param("deptId")String deptId);
/**
* @param customerId
* @param deptId
@ -88,4 +78,13 @@ public interface ScreenCustomerDeptDao extends BaseDao<ScreenCustomerDeptEntity>
**/
List<ScreenCustomerDeptEntity> selectListMismatchDeptInfo(@Param("customerId") String customerId,
@Param("deptIds") String[] deptIds);
/**
* 根据客户id 查询部门 信息
* @param customerId 客户id
* @return java.util.List<com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity>
* @Author zhangyong
* @Date 16:57 2020-09-03
**/
List<ScreenCustomerDeptEntity> selectListDeptInfo(@Param("customerId")String customerId);
}

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

@ -95,16 +95,6 @@ public interface ScreenCustomerGridDao extends BaseDao<ScreenCustomerGridEntity>
**/
ScreenCustomerGridDTO selectParentAgencyId(@Param("customerId") String customerId, @Param("gridId") String gridId);
/**
* 根据客户id网格id查询网格(党支部)父级信息
* @param customerId
* @param gridId
* @return com.epmet.dto.screen.FactIndexGridScoreDTO
* @Author zhangyong
* @Date 16:57 2020-09-03
**/
ScreenCustomerGridDTO selectParentGridInfo(@Param("customerId")String customerId, @Param("gridId")String gridId);
/**
* 返回当前客户下未匹配到的网格信息
*
@ -116,4 +106,13 @@ public interface ScreenCustomerGridDao extends BaseDao<ScreenCustomerGridEntity>
**/
List<ScreenCustomerGridDTO> selectListMismatchGridInfo(@Param("customerId") String customerId,
@Param("gridIds") String[] gridIds);
/**
* 根据客户id 查询网格(党支部)详细信息
* @param customerId
* @return java.util.List<com.epmet.dto.ScreenCustomerGridDTO>
* @Author zhangyong
* @Date 16:57 2020-09-03
**/
List<ScreenCustomerGridDTO> selectListGridInfo(@Param("customerId")String customerId);
}

54
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java

@ -281,6 +281,8 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
// 根据网格id进行分组,最后组装一条数据 一个网格 对应 4条数据
Map<String, List<FactIndexGridScoreDTO>> collect = gridScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexGridScoreDTO::getGridId));
// 查询网格的 上级组织id 和 组织名称
List<ScreenCustomerGridDTO> parentGridList = screenCustomerGridDao.selectListGridInfo(customerId);
String[] orgIds = new String[collect.size()];
int j = 0;
for(Map.Entry<String,List<FactIndexGridScoreDTO>> gridScore : collect.entrySet()){
@ -304,14 +306,21 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
monthlyFormDTO);
}
}
// 查询网格的 上级组织id 和 组织名称
ScreenCustomerGridDTO parentGridInfo = screenCustomerGridDao.selectParentGridInfo(customerId, gridScore.getKey());
if (null == parentGridInfo){
// 匹配网格的 上级组织id 和 组织名称
String parentAgencyId = "";
String gridName = "";
for (ScreenCustomerGridDTO gridDTO : parentGridList){
if (gridScore.getKey().equals(gridDTO.getGridId())){
parentAgencyId = gridDTO.getParentAgencyId();
gridName = gridDTO.getGridName();
}
}
if ("".equals(parentAgencyId)){
throw new RuntimeException("在screen_customer_grid表中未查询到该客户下的网格信息:customerId =" + customerId + ", gridId = " + gridScore.getKey());
}
// 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScore.getKey(),
parentGridInfo.getParentAgencyId(), parentGridInfo.getGridName(), monthlyFormDTO);
parentAgencyId, gridName, monthlyFormDTO);
monthlyFormDTOList.add(monthlyFormDTO);
}
if (monthlyFormDTOList.size() > NumConstant.ZERO){
@ -371,6 +380,8 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
// 根据组织id 进行分组,最后组装一条数据 一个组织id 对应 4条数据
Map<String, List<FactIndexCommunityScoreDTO>> collect = communityScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId));
// 根据客户id,查询区/街道 组织名称、id
List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId);
String[] orgIds = new String[collect.size()];
int j = 0;
for(Map.Entry<String,List<FactIndexCommunityScoreDTO>> communityScore : collect.entrySet()){
@ -397,9 +408,14 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 当前组织 的上级组织id
String parentAgencyId = communityScore.getValue().get(NumConstant.ZERO).getParentAgencyId();
// 查询 组织名称
String agencyName = screenCustomerAgencyDao.selectParentAgencyInfo(customerId, communityScore.getKey());
if (null == agencyName){
// 获取 组织名称
String agencyName = "";
for (ScreenCustomerAgencyEntity agencyScoreDTO : parentAgencyList) {
if (communityScore.getKey().equals(agencyScoreDTO.getAgencyId())) {
agencyName = agencyScoreDTO.getAgencyName();
}
}
if ("".equals(agencyName)){
throw new RuntimeException("在screen_customer_agency表中未查询到该客户下的组织名称:customerId =" + customerId + ", agencyId = " + communityScore.getKey());
}
// 补充表中其他字段
@ -461,6 +477,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
// 根据部门id 进行分组,最后组装一条数据 一个部门id 对应 4条数据
Map<String, List<DeptScoreDTO>> collect = deptScoreDTOS.stream().collect(Collectors.groupingBy(DeptScoreDTO::getDeptId));
List<ScreenCustomerDeptEntity> parentDeptList = screenCustomerDeptDao.selectListDeptInfo(customerId);
String[] orgIds = new String[collect.size()];
int j = 0;
for(Map.Entry<String,List<DeptScoreDTO>> deptScore : collect.entrySet()){
@ -479,13 +496,20 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
monthlyFormDTO);
}
// 查询网格的 上级组织id 和 组织名称
ScreenCustomerDeptEntity parentDeptInfo = screenCustomerDeptDao.selectParentDeptInfo(customerId, deptScore.getKey());
if (null == parentDeptInfo){
String parentAgencyId = "";
String deptName = "";
for (ScreenCustomerDeptEntity deptEntity : parentDeptList) {
if (deptScore.getKey().equals(deptEntity.getDeptId())) {
parentAgencyId = deptEntity.getParentAgencyId();
deptName = deptEntity.getDeptName();
}
}
if ("".equals(parentAgencyId)){
throw new RuntimeException("在screen_customer_dept表中未查询到该客户下的父级信息:customerId =" + customerId + ", deptId = " + deptScore.getKey());
}
// 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, deptScore.getKey(),
parentDeptInfo.getParentAgencyId(), parentDeptInfo.getDeptName(), monthlyFormDTO);
parentAgencyId, deptName, monthlyFormDTO);
monthlyFormDTOList.add(monthlyFormDTO);
}
if (monthlyFormDTOList.size() > NumConstant.ZERO){
@ -539,6 +563,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
// 根据组织id(eg:社区或者街道id) 进行分组,最后组装一条数据 一个组织id 对应 4条数据
Map<String, List<AgencyScoreDTO>> collect = agencyScoreDTOS.stream().collect(Collectors.groupingBy(AgencyScoreDTO::getAgencyId));
List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId);
String[] orgIds = new String[collect.size()];
int j = 0;
for(Map.Entry<String,List<AgencyScoreDTO>> agencyScore : collect.entrySet()){
@ -562,8 +587,13 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 当前组织 的上级组织id
String parentAgencyId = agencyScore.getValue().get(NumConstant.ZERO).getParentAgencyId();
// 查询 组织名称
String agencyName = screenCustomerAgencyDao.selectParentAgencyInfo(customerId, agencyScore.getKey());
if (null == agencyName){
String agencyName = "";
for (ScreenCustomerAgencyEntity agencyScoreDTO : parentAgencyList) {
if (agencyScore.getKey().equals(agencyScoreDTO.getAgencyId())) {
agencyName = agencyScoreDTO.getAgencyName();
}
}
if ("".equals(agencyName)){
throw new RuntimeException("在screen_customer_agency表中未查询到该客户下的组织名称:customerId =" + customerId + ", agencyId = " + agencyScore.getKey());
}
// 补充表中其他字段

22
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml

@ -60,17 +60,6 @@
</foreach>
</insert>
<select id="selectParentAgencyInfo" parameterType="map" resultType="String">
SELECT
AGENCY_NAME agencyName
FROM
screen_customer_agency
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID =#{customerId}
AND AGENCY_ID = #{agencyId}
</select>
<select id="selectListMismatcAgencyInfo" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity">
SELECT
AGENCY_ID agencyId,
@ -90,4 +79,15 @@
</foreach>
</if>
</select>
<select id="selectListAgencyInfo" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity">
SELECT
AGENCY_ID agencyId,
AGENCY_NAME agencyName
FROM
screen_customer_agency
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID =#{customerId}
</select>
</mapper>

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

@ -64,17 +64,6 @@
AND m.CUSTOMER_ID =#{customerId}
AND m.DEPT_ID =#{deptId}
</select>
<select id="selectParentDeptInfo" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity">
SELECT
PARENT_AGENCY_ID parentAgencyId,
DEPT_NAME deptName
FROM
screen_customer_dept
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID =#{customerId}
AND DEPT_ID = #{deptId}
</select>
<select id="selectListMismatchDeptInfo" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity">
SELECT
@ -93,4 +82,16 @@
</foreach>
</if>
</select>
<select id="selectListDeptInfo" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity">
SELECT
DEPT_ID deptId,
PARENT_AGENCY_ID parentAgencyId,
DEPT_NAME deptName
FROM
screen_customer_dept
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID =#{customerId}
</select>
</mapper>

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

@ -106,18 +106,6 @@
AND m.GRID_ID = #{gridId}
</select>
<select id="selectParentGridInfo" parameterType="map" resultType="com.epmet.dto.ScreenCustomerGridDTO">
SELECT
GRID_NAME gridName,
PARENT_AGENCY_ID parentAgencyId
FROM
screen_customer_grid
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID =#{customerId}
AND GRID_ID = #{gridId}
</select>
<select id="selectListMismatchGridInfo" parameterType="map" resultType="com.epmet.dto.ScreenCustomerGridDTO">
SELECT
GRID_ID gridId,
@ -136,4 +124,16 @@
</foreach>
</if>
</select>
<select id="selectListGridInfo" parameterType="map" resultType="com.epmet.dto.ScreenCustomerGridDTO">
SELECT
GRID_ID gridId,
GRID_NAME gridName,
PARENT_AGENCY_ID parentAgencyId
FROM
screen_customer_grid
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID =#{customerId}
</select>
</mapper>

Loading…
Cancel
Save