Browse Source

网格小组

dev_shibei_match
zxc 5 years ago
parent
commit
0eee56cbf7
  1. 4
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/GroupConstant.java
  2. 25
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/GridIdListByCustomerResultDTO.java
  3. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java
  4. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/GroupDataService.java
  5. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java
  6. 21
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java
  7. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java
  8. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java
  9. 5
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml

4
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/GroupConstant.java

@ -29,4 +29,8 @@ public interface GroupConstant {
String CITY = "city"; String CITY = "city";
String PROVINCE = "province"; String PROVINCE = "province";
String ERRORGRIDDAILY = "groupGridDaily ==>【网格小组统计出错了... 维度:网格-日】customerId为:";
String ERRORAGENCYDAILY = "groupAgencyDaily ==>【网格小组统计出错了... 维度:机关-日】customerId为:";
} }

25
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/GridIdListByCustomerResultDTO.java

@ -0,0 +1,25 @@
package com.epmet.dto.group.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @CreateTime 2020/6/23 13:54
*/
@Data
public class GridIdListByCustomerResultDTO implements Serializable {
private static final long serialVersionUID = -4170349451726088582L;
/**
* 网格ID
*/
private String GridId;
/**
* 机关ID
*/
private String agencyId;
}

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java

@ -20,6 +20,7 @@ package com.epmet.dao.org;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.group.AgencyDTO; import com.epmet.dto.group.AgencyDTO;
import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO; import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO;
import com.epmet.dto.group.result.GridIdListByCustomerResultDTO;
import com.epmet.entity.org.CustomerGridEntity; import com.epmet.entity.org.CustomerGridEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -57,5 +58,5 @@ public interface CustomerGridDao extends BaseDao<CustomerGridEntity> {
* @param dateId * @param dateId
* @author zxc * @author zxc
*/ */
List<String> getCustomerGridIdList(@Param("customerId") String customerId, @Param("dateId") String dateId); List<GridIdListByCustomerResultDTO> getCustomerGridIdList(@Param("customerId") String customerId, @Param("dateId") String dateId);
} }

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/GroupDataService.java

@ -1,7 +1,6 @@
package com.epmet.service.group; package com.epmet.service.group;
import com.epmet.dto.group.result.*; import com.epmet.dto.group.result.*;
import com.epmet.entity.stats.DimGridEntity;
import com.epmet.util.DimIdGenerator; import com.epmet.util.DimIdGenerator;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -18,7 +17,7 @@ public interface GroupDataService {
* @param customerId * @param customerId
* @author zxc * @author zxc
*/ */
List<GroupGridDailyResultDTO> groupGridDaily(String customerId, DimIdGenerator.DimIdBean dimIdBean, List<DimGridEntity> gridsInfo); List<GroupGridDailyResultDTO> groupGridDaily(String customerId, DimIdGenerator.DimIdBean dimIdBean, List<GridIdListByCustomerResultDTO> gridsInfo);
/** /**
* @Description 获取同级机关下网格下的小组数量 * @Description 获取同级机关下网格下的小组数量

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java

@ -36,7 +36,7 @@ public class GroupDataServiceImpl implements GroupDataService {
* @author zxc * @author zxc
*/ */
@Override @Override
public List<GroupGridDailyResultDTO> groupGridDaily(String customerId, DimIdGenerator.DimIdBean dimTime, List<DimGridEntity> gridsInfo) { public List<GroupGridDailyResultDTO> groupGridDaily(String customerId, DimIdGenerator.DimIdBean dimTime, List<GridIdListByCustomerResultDTO> gridsInfo) {
List<GroupGridDailyResultDTO> result = new ArrayList<>(); List<GroupGridDailyResultDTO> result = new ArrayList<>();
if (gridsInfo.size() == NumConstant.ZERO){ if (gridsInfo.size() == NumConstant.ZERO){
return new ArrayList<>(); return new ArrayList<>();
@ -46,7 +46,7 @@ public class GroupDataServiceImpl implements GroupDataService {
GroupGridDailyResultDTO dailyResult = new GroupGridDailyResultDTO(); GroupGridDailyResultDTO dailyResult = new GroupGridDailyResultDTO();
BeanUtils.copyProperties(dimTime,dailyResult); BeanUtils.copyProperties(dimTime,dailyResult);
dailyResult.setAgencyId(grid.getAgencyId()); dailyResult.setAgencyId(grid.getAgencyId());
dailyResult.setGridId(grid.getId()); dailyResult.setGridId(grid.getGridId());
dailyResult.setCustomerId(customerId); dailyResult.setCustomerId(customerId);
result.add(dailyResult); result.add(dailyResult);
}); });

21
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java

@ -1,18 +1,19 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.constant.GroupConstant;
import com.epmet.dto.AgencySubTreeDto; import com.epmet.dto.AgencySubTreeDto;
import com.epmet.dto.group.form.AgencyMonthlyFormDTO; import com.epmet.dto.group.form.AgencyMonthlyFormDTO;
import com.epmet.dto.group.result.*; import com.epmet.dto.group.result.*;
import com.epmet.dto.stats.DimAgencyDTO; import com.epmet.dto.stats.DimAgencyDTO;
import com.epmet.entity.stats.DimAgencyEntity; import com.epmet.entity.stats.DimAgencyEntity;
import com.epmet.entity.stats.DimGridEntity;
import com.epmet.service.StatsGroupService; import com.epmet.service.StatsGroupService;
import com.epmet.service.group.GroupDataService; import com.epmet.service.group.GroupDataService;
import com.epmet.service.org.CustomerGridService; import com.epmet.service.org.CustomerGridService;
import com.epmet.service.stats.*; import com.epmet.service.stats.*;
import com.epmet.util.DimIdGenerator; import com.epmet.util.DimIdGenerator;
import com.epmet.util.ModuleConstant; import com.epmet.util.ModuleConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -30,6 +31,7 @@ import java.util.stream.Collectors;
* @CreateTime 2020/6/16 14:14 * @CreateTime 2020/6/16 14:14
*/ */
@Service @Service
@Slf4j
public class StatsGroupServiceImpl implements StatsGroupService { public class StatsGroupServiceImpl implements StatsGroupService {
@Autowired @Autowired
@ -63,10 +65,17 @@ public class StatsGroupServiceImpl implements StatsGroupService {
customerIds = dimCustomerService.selectCustomerIdPage(pageNo,pageSize); customerIds = dimCustomerService.selectCustomerIdPage(pageNo,pageSize);
if (customerIds.size() != NumConstant.ZERO){ if (customerIds.size() != NumConstant.ZERO){
customerIds.forEach(customerId -> { customerIds.forEach(customerId -> {
try {
DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date); DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date);
List<DimGridEntity> gridsInfo = dimGridService.getGridListByCustomerId(customerId);
// List<DimGridEntity> gridsInfo = dimGridService.getGridListByCustomerId(customerId);
List<GridIdListByCustomerResultDTO> gridsInfo = customerGridService.getCustomerGridIdList(customerId, dimIdBean.getDateId());
List<GroupGridDailyResultDTO> resultDTOS = groupDataService.groupGridDaily(customerId,dimIdBean,gridsInfo); List<GroupGridDailyResultDTO> resultDTOS = groupDataService.groupGridDaily(customerId,dimIdBean,gridsInfo);
factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS,customerId); factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS,customerId);
} catch (Exception e) {
log.error(GroupConstant.ERRORGRIDDAILY+customerId,e);
}
}); });
} }
@ -87,9 +96,13 @@ public class StatsGroupServiceImpl implements StatsGroupService {
if (customerIds.size() != NumConstant.ZERO){ if (customerIds.size() != NumConstant.ZERO){
DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date); DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date);
customerIds.forEach(customerId -> { customerIds.forEach(customerId -> {
try {
List<DimAgencyDTO> customerAgencyInfos = dimAgencyService.getAgencyInfoByCustomerId(customerId); List<DimAgencyDTO> customerAgencyInfos = dimAgencyService.getAgencyInfoByCustomerId(customerId);
List<AgencyGroupDailyResultDTO> agencyGroupDaily = this.getAgencyGroupDaily(customerAgencyInfos, dimIdBean, customerId); List<AgencyGroupDailyResultDTO> agencyGroupDaily = this.getAgencyGroupDaily(customerAgencyInfos, dimIdBean, customerId);
factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily,customerId); factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily,customerId);
} catch (Exception e) {
log.error(GroupConstant.ERRORAGENCYDAILY+customerId,e);
}
}); });
} }
}while (customerIds.size() != NumConstant.ZERO && customerIds.size() == pageSize); }while (customerIds.size() != NumConstant.ZERO && customerIds.size() == pageSize);
@ -139,12 +152,12 @@ public class StatsGroupServiceImpl implements StatsGroupService {
String pidByAgencyId = dimAgencyService.getPidByAgencyId(agencyId); String pidByAgencyId = dimAgencyService.getPidByAgencyId(agencyId);
agencyResult.setPid(StringUtils.isBlank(pidByAgencyId)?"0":pidByAgencyId); agencyResult.setPid(StringUtils.isBlank(pidByAgencyId)?"0":pidByAgencyId);
// TODO 1. 机关下有多少网格 // TODO 1. 机关下有多少网格
List<String> customerGridIdList = customerGridService.getCustomerGridIdList(customerId, dateId); List<GridIdListByCustomerResultDTO> customerGridIdList = customerGridService.getCustomerGridIdList(customerId, dateId);
AtomicReference<Integer> gridSize = new AtomicReference<>(0); AtomicReference<Integer> gridSize = new AtomicReference<>(0);
if (customerGridIdList.size() != NumConstant.ZERO){ if (customerGridIdList.size() != NumConstant.ZERO){
customerGridIdList.forEach(gridId -> { customerGridIdList.forEach(gridId -> {
allGrid.forEach(allAgencyGrid -> { allGrid.forEach(allAgencyGrid -> {
if (gridId.equals(allAgencyGrid)){ if (gridId.getGridId().equals(allAgencyGrid)){
gridSize.updateAndGet(v -> v + NumConstant.ONE); gridSize.updateAndGet(v -> v + NumConstant.ONE);
} }
}); });

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java

@ -2,6 +2,7 @@ package com.epmet.service.org;
import com.epmet.dto.group.AgencyDTO; import com.epmet.dto.group.AgencyDTO;
import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO; import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO;
import com.epmet.dto.group.result.GridIdListByCustomerResultDTO;
import com.epmet.entity.org.CustomerGridEntity; import com.epmet.entity.org.CustomerGridEntity;
import java.util.Date; import java.util.Date;
@ -30,5 +31,5 @@ public interface CustomerGridService {
* @param dateId * @param dateId
* @author zxc * @author zxc
*/ */
List<String> getCustomerGridIdList(String customerId,String dateId); List<GridIdListByCustomerResultDTO> getCustomerGridIdList(String customerId, String dateId);
} }

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java

@ -5,6 +5,7 @@ import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.org.CustomerGridDao; import com.epmet.dao.org.CustomerGridDao;
import com.epmet.dto.group.AgencyDTO; import com.epmet.dto.group.AgencyDTO;
import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO; import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO;
import com.epmet.dto.group.result.GridIdListByCustomerResultDTO;
import com.epmet.entity.org.CustomerGridEntity; import com.epmet.entity.org.CustomerGridEntity;
import com.epmet.service.org.CustomerGridService; import com.epmet.service.org.CustomerGridService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -42,7 +43,7 @@ public class CustomerGridServiceImpl implements CustomerGridService {
* @author zxc * @author zxc
*/ */
@Override @Override
public List<String> getCustomerGridIdList(String customerId, String dateId) { public List<GridIdListByCustomerResultDTO> getCustomerGridIdList(String customerId, String dateId) {
return customerGridDao.getCustomerGridIdList(customerId, dateId); return customerGridDao.getCustomerGridIdList(customerId, dateId);
} }
} }

5
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml

@ -36,9 +36,10 @@
</select> </select>
<!-- 获取客户下某个时间点以前的网格ID --> <!-- 获取客户下某个时间点以前的网格ID -->
<select id="getCustomerGridIdList" resultType="java.lang.String"> <select id="getCustomerGridIdList" resultType="com.epmet.dto.group.result.GridIdListByCustomerResultDTO">
SELECT SELECT
id AS gridId id AS gridId,
pid AS agencyId
FROM FROM
customer_grid customer_grid
WHERE WHERE

Loading…
Cancel
Save