|
|
@ -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 -> { |
|
|
|
DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date); |
|
|
|
List<DimGridEntity> gridsInfo = dimGridService.getGridListByCustomerId(customerId); |
|
|
|
List<GroupGridDailyResultDTO> resultDTOS = groupDataService.groupGridDaily(customerId,dimIdBean,gridsInfo); |
|
|
|
factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS,customerId); |
|
|
|
try { |
|
|
|
DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date); |
|
|
|
|
|
|
|
// 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 -> { |
|
|
|
List<DimAgencyDTO> customerAgencyInfos = dimAgencyService.getAgencyInfoByCustomerId(customerId); |
|
|
|
List<AgencyGroupDailyResultDTO> agencyGroupDaily = this.getAgencyGroupDaily(customerAgencyInfos, dimIdBean, customerId); |
|
|
|
factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily,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); |
|
|
|
} |
|
|
|
}); |
|
|
|