|
@@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -386,13 +387,12 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
|
|
|
if (list == null) {
|
|
|
return newArrayList();
|
|
|
}
|
|
|
- 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);
|
|
|
+ TreeUtil.postorderTraversalCustomerRate(list);
|
|
|
+ TreeUtil.postorderTraversalCustomerRateCalculate(list);
|
|
|
if (customerId != null) {
|
|
|
- return TreeUtil.getCustomerRateTreeNode(newList,customerId);
|
|
|
+ return TreeUtil.getCustomerRateTreeNode(list,customerId);
|
|
|
}
|
|
|
+ List<CustomerRateDto> newList = list.stream().filter(p -> p.getDeviceCount() > 0).sorted(Comparator.comparingInt(CustomerRateDto::getDeviceCount).reversed()).collect(Collectors.toList());
|
|
|
return newList;
|
|
|
}
|
|
|
|
|
@@ -433,37 +433,23 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
|
|
|
|
|
|
@Override
|
|
|
public void getRateExcelByCustomer(Integer period, Integer channelId, Integer customerId, HttpServletResponse httpServletResponse) {
|
|
|
- LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
- //1、查询数据权限的建筑ids
|
|
|
- List<Integer> buildingIds = buildingService.getIdsByDataPermission();
|
|
|
-
|
|
|
- //2、根据数据项查询客户
|
|
|
- List<Customer> customerList = customerService.getCustomerListByItem(loginUser.getSiteId(), buildingIds, null);
|
|
|
-
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
- Integer startDate = Integer.valueOf(LocalDate.now().plusDays(-1).format(formatter));
|
|
|
-
|
|
|
- List<WaterReadRateListDto> list = newArrayList();
|
|
|
- if (period == 2) { // 昨天,查询天表
|
|
|
- list = statMeterReadRateByBuildingMapper.getRateListByCustomer(loginUser.getSiteId(), startDate, buildingIds, customerList, null, null);
|
|
|
- } else if (period == 7) { // 近7天,查询7天表
|
|
|
- list = statMeterReadRateByBuildingMapper.getRateList7DayByCustomer(loginUser.getSiteId(), startDate, buildingIds, customerList, null, null);
|
|
|
- } else if (period == 15) {// 近15天,查询15天表
|
|
|
- list = statMeterReadRateByBuildingMapper.getRateList15DayByCustomer(loginUser.getSiteId(), startDate, buildingIds, customerList, null, null);
|
|
|
- }
|
|
|
-
|
|
|
+ List<CustomerRateDto> list = this.getListByCustomer(period,channelId,customerId,null,null);
|
|
|
+ List<WaterReadRateListDto> newList = newArrayList();
|
|
|
+ TreeUtil.traversalCustomerRate(list,newList,"");
|
|
|
String title = "按客户统计抄表率";
|
|
|
- String[] rowsName = new String[]{"序号", "客户名称", "应抄水表总个数", "多次抄收成功水表数", "多次抄收成功率(%)"};
|
|
|
+ //客户、水表类型、应抄水表总数、抄收成功总数、抄收成功率(%)
|
|
|
+ String[] rowsName = new String[]{"序号", "客户", "水表类型", "应抄水表总数", "抄收成功总数", "抄收成功率(%)"};
|
|
|
List<Object[]> dataList = newArrayList();
|
|
|
Object[] objs = null;
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- WaterReadRateListDto waterReadRateListDto = list.get(i);
|
|
|
+ for (int i = 0; i < newList.size(); i++) {
|
|
|
+ WaterReadRateListDto waterReadRateListDto = newList.get(i);
|
|
|
objs = new Object[rowsName.length];
|
|
|
objs[0] = i;
|
|
|
objs[1] = waterReadRateListDto.getCustomerName();
|
|
|
- objs[2] = waterReadRateListDto.getDeviceCount();
|
|
|
- objs[3] = waterReadRateListDto.getRealReadTimes();
|
|
|
- objs[4] = waterReadRateListDto.getReadRate();
|
|
|
+ objs[2] = waterReadRateListDto.getChannelName();
|
|
|
+ objs[3] = waterReadRateListDto.getDeviceCount();
|
|
|
+ objs[4] = waterReadRateListDto.getRealReadTimes();
|
|
|
+ objs[5] = waterReadRateListDto.getReadRate();
|
|
|
dataList.add(objs);
|
|
|
}
|
|
|
ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
|