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 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.dto.group.AgencyDTO;
import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO;
import com.epmet.dto.group.result.GridIdListByCustomerResultDTO;
import com.epmet.entity.org.CustomerGridEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -57,5 +58,5 @@ public interface CustomerGridDao extends BaseDao<CustomerGridEntity> {
* @param dateId
* @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;
import com.epmet.dto.group.result.*;
import com.epmet.entity.stats.DimGridEntity;
import com.epmet.util.DimIdGenerator;
import org.apache.ibatis.annotations.Param;
@ -18,7 +17,7 @@ public interface GroupDataService {
* @param customerId
* @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 获取同级机关下网格下的小组数量

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
*/
@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<>();
if (gridsInfo.size() == NumConstant.ZERO){
return new ArrayList<>();
@ -46,7 +46,7 @@ public class GroupDataServiceImpl implements GroupDataService {
GroupGridDailyResultDTO dailyResult = new GroupGridDailyResultDTO();
BeanUtils.copyProperties(dimTime,dailyResult);
dailyResult.setAgencyId(grid.getAgencyId());
dailyResult.setGridId(grid.getId());
dailyResult.setGridId(grid.getGridId());
dailyResult.setCustomerId(customerId);
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;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.constant.GroupConstant;
import com.epmet.dto.AgencySubTreeDto;
import com.epmet.dto.group.form.AgencyMonthlyFormDTO;
import com.epmet.dto.group.result.*;
import com.epmet.dto.stats.DimAgencyDTO;
import com.epmet.entity.stats.DimAgencyEntity;
import com.epmet.entity.stats.DimGridEntity;
import com.epmet.service.StatsGroupService;
import com.epmet.service.group.GroupDataService;
import com.epmet.service.org.CustomerGridService;
import com.epmet.service.stats.*;
import com.epmet.util.DimIdGenerator;
import com.epmet.util.ModuleConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -30,6 +31,7 @@ import java.util.stream.Collectors;
* @CreateTime 2020/6/16 14:14
*/
@Service
@Slf4j
public class StatsGroupServiceImpl implements StatsGroupService {
@Autowired
@ -63,10 +65,17 @@ public class StatsGroupServiceImpl implements StatsGroupService {
customerIds = dimCustomerService.selectCustomerIdPage(pageNo,pageSize);
if (customerIds.size() != NumConstant.ZERO){
customerIds.forEach(customerId -> {
try {
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);
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){
DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date);
customerIds.forEach(customerId -> {
try {
List<DimAgencyDTO> customerAgencyInfos = dimAgencyService.getAgencyInfoByCustomerId(customerId);
List<AgencyGroupDailyResultDTO> agencyGroupDaily = this.getAgencyGroupDaily(customerAgencyInfos, dimIdBean, customerId);
factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily,customerId);
} catch (Exception e) {
log.error(GroupConstant.ERRORAGENCYDAILY+customerId,e);
}
});
}
}while (customerIds.size() != NumConstant.ZERO && customerIds.size() == pageSize);
@ -139,12 +152,12 @@ public class StatsGroupServiceImpl implements StatsGroupService {
String pidByAgencyId = dimAgencyService.getPidByAgencyId(agencyId);
agencyResult.setPid(StringUtils.isBlank(pidByAgencyId)?"0":pidByAgencyId);
// TODO 1. 机关下有多少网格
List<String> customerGridIdList = customerGridService.getCustomerGridIdList(customerId, dateId);
List<GridIdListByCustomerResultDTO> customerGridIdList = customerGridService.getCustomerGridIdList(customerId, dateId);
AtomicReference<Integer> gridSize = new AtomicReference<>(0);
if (customerGridIdList.size() != NumConstant.ZERO){
customerGridIdList.forEach(gridId -> {
allGrid.forEach(allAgencyGrid -> {
if (gridId.equals(allAgencyGrid)){
if (gridId.getGridId().equals(allAgencyGrid)){
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.result.AgencyGridTotalCountResultDTO;
import com.epmet.dto.group.result.GridIdListByCustomerResultDTO;
import com.epmet.entity.org.CustomerGridEntity;
import java.util.Date;
@ -30,5 +31,5 @@ public interface CustomerGridService {
* @param dateId
* @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.dto.group.AgencyDTO;
import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO;
import com.epmet.dto.group.result.GridIdListByCustomerResultDTO;
import com.epmet.entity.org.CustomerGridEntity;
import com.epmet.service.org.CustomerGridService;
import org.springframework.beans.factory.annotation.Autowired;
@ -42,7 +43,7 @@ public class CustomerGridServiceImpl implements CustomerGridService {
* @author zxc
*/
@Override
public List<String> getCustomerGridIdList(String customerId, String dateId) {
public List<GridIdListByCustomerResultDTO> getCustomerGridIdList(String customerId, String 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>
<!-- 获取客户下某个时间点以前的网格ID -->
<select id="getCustomerGridIdList" resultType="java.lang.String">
<select id="getCustomerGridIdList" resultType="com.epmet.dto.group.result.GridIdListByCustomerResultDTO">
SELECT
id AS gridId
id AS gridId,
pid AS agencyId
FROM
customer_grid
WHERE

Loading…
Cancel
Save