|
@@ -6,8 +6,10 @@ import com.bz.smart_city.commom.model.CommonQueryCondition;
|
|
|
import com.bz.smart_city.commom.model.Pagination;
|
|
|
import com.bz.smart_city.commom.util.DateTimeUtil;
|
|
|
import com.bz.smart_city.commom.util.ExcelUtil;
|
|
|
+import com.bz.smart_city.commom.util.TreeUtil;
|
|
|
import com.bz.smart_city.commom.util.UserUtil;
|
|
|
import com.bz.smart_city.dto.*;
|
|
|
+import com.bz.smart_city.dto.assistant.InstallPlanDataDTO;
|
|
|
import com.bz.smart_city.entity.Customer;
|
|
|
import com.bz.smart_city.service.BuildingService;
|
|
|
import com.bz.smart_city.service.CustomerService;
|
|
@@ -22,6 +24,8 @@ import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import com.bz.smart_city.entity.StatMeterReadRateByBuilding;
|
|
|
import com.bz.smart_city.dao.MeterReadRecordMapper;
|
|
@@ -322,7 +326,7 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Pagination<CustomerRateDto> getListByCustomer(Integer period, Integer channelId, Integer customerId, String sortColumn, String sortOrder, int pageNum, int pageSize) {
|
|
|
+ public List<CustomerRateDto> getListByCustomer(Integer period, Integer channelId, Integer customerId, String sortColumn, String sortOrder, int pageNum, int pageSize) {
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
///查询数据权限的建筑ids
|
|
|
List<Integer> buildingIds = buildingService.getIdsByDataPermission();
|
|
@@ -340,27 +344,50 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
|
|
|
List<WaterReadRateListDto> waterReadRateListDtoList = newArrayList();
|
|
|
|
|
|
if (period == 2) { // 昨天,查询天表
|
|
|
- PageHelper.startPage(pageNum, pageSize);
|
|
|
+ //PageHelper.startPage(pageNum, pageSize);
|
|
|
customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building",loginUser.getSiteId(), startDate, buildingIds,channelId,customerIds);
|
|
|
} else if (period == 7) { // 近7天,查询7天表
|
|
|
- PageHelper.startPage(pageNum, pageSize);
|
|
|
+ //PageHelper.startPage(pageNum, pageSize);
|
|
|
customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building_7day",loginUser.getSiteId(), startDate, buildingIds,channelId,customerIds);
|
|
|
} else if (period == 15) {// 近15天,查询15天表
|
|
|
- PageHelper.startPage(pageNum, pageSize);
|
|
|
+ //PageHelper.startPage(pageNum, pageSize);
|
|
|
customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building_15day",loginUser.getSiteId(), startDate, buildingIds,channelId,customerIds);
|
|
|
}else if (period == 99) {// 上个月,查询15天表
|
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
|
|
|
startDate = Integer.parseInt(LocalDateTime.now().plusMonths(-1).format(df));
|
|
|
- PageHelper.startPage(pageNum, pageSize);
|
|
|
+ //PageHelper.startPage(pageNum, pageSize);
|
|
|
customerRateDtoList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2("sc_stat_meter_read_rate_by_building_month",loginUser.getSiteId(), startDate, buildingIds,channelId,customerIds);
|
|
|
}
|
|
|
- if (customerRateDtoList != null && customerRateDtoList.size()>0) {
|
|
|
+ /*if (customerRateDtoList != null && customerRateDtoList.size()>0) {
|
|
|
for (CustomerRateDto customerRateDto : customerRateDtoList) {
|
|
|
customerRateDto.setList(statMeterReadRateByBuildingMapper.getRateListByCustomerV2AndDeviceType("sc_stat_meter_read_rate_by_building_month",loginUser.getSiteId(), startDate, buildingIds,channelId,customerRateDto.getCustomerId()));
|
|
|
}
|
|
|
+ }*/
|
|
|
+ List<WaterReadRateListDto> dataList = statMeterReadRateByBuildingMapper.getRateListByCustomerV2AndDeviceType("sc_stat_meter_read_rate_by_building_month",loginUser.getSiteId(), startDate, buildingIds,channelId,null);
|
|
|
+ if (dataList != null && dataList.size() > 0) {
|
|
|
+ for (WaterReadRateListDto waterReadRateListDto : dataList) {
|
|
|
+ if (customerRateDtoList != null && customerRateDtoList.size() > 0) {
|
|
|
+ for (CustomerRateDto customerRateDto : customerRateDtoList) {
|
|
|
+ if(customerRateDto.getCustomerId().equals(waterReadRateListDto.getCustomerId())){
|
|
|
+ if (customerRateDto.getList() != null) {
|
|
|
+ customerRateDto.getList().add(waterReadRateListDto);
|
|
|
+ }else {
|
|
|
+ customerRateDto.setList(newArrayList(waterReadRateListDto));
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- return new Pagination<>(customerRateDtoList);
|
|
|
+ //4、组装树形数据
|
|
|
+ List<CustomerRateDto> list = TreeUtil.getCustomerRateTree(customerRateDtoList, 0, 1);
|
|
|
+ List<CustomerRateDto> newList = list.stream().filter(p -> (p.getList() != null && p.getList().size() > 0) || (p.getChildren() != null && p.getChildren().size() > 0)).collect(Collectors.toList());
|
|
|
+ //List<CustomerRateDto> newList = list.stream().filter(p -> p.getCustomerId()==121).collect(Collectors.toList());
|
|
|
+ TreeUtil.postorderTraversalCustomerRate(newList);
|
|
|
+ TreeUtil.postorderTraversalCustomerRateCalculate(newList);
|
|
|
+ return newList;
|
|
|
}
|
|
|
|
|
|
@Override
|