|
@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.atomic.AtomicLong;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -154,22 +155,32 @@ public class LiftDataService {
|
|
}
|
|
}
|
|
return "暂无";
|
|
return "暂无";
|
|
}));
|
|
}));
|
|
|
|
+ LocalDateTime startTimeDate = liftDataRequest.getStartTimeDate();
|
|
//封装区域电梯信息
|
|
//封装区域电梯信息
|
|
regionNameToLiftData.forEach((key, value) -> {
|
|
regionNameToLiftData.forEach((key, value) -> {
|
|
RegionLiftResponse regionLiftResponse = new RegionLiftResponse();
|
|
RegionLiftResponse regionLiftResponse = new RegionLiftResponse();
|
|
regionLiftResponse.setRegionName(key);
|
|
regionLiftResponse.setRegionName(key);
|
|
//总电梯数
|
|
//总电梯数
|
|
long totalLiftNums = value.size();
|
|
long totalLiftNums = value.size();
|
|
- //计算新增电梯的数量
|
|
|
|
- long newLiftNums = value.stream()
|
|
|
|
- .filter(a -> a.getLiftStatus() == 1).count();
|
|
|
|
- regionLiftResponse.setNewLiftNums(newLiftNums);
|
|
|
|
|
|
+ //计算新增电梯和丢失电梯的数量
|
|
|
|
+ AtomicLong newLiftNums = new AtomicLong(0);
|
|
|
|
+ AtomicLong lostLiftNums = new AtomicLong(0);
|
|
|
|
+ value.forEach(a -> {
|
|
|
|
+ if (a.getConnectTime() != null && a.getConnectTime().isAfter(startTimeDate)) {
|
|
|
|
+ if (a.getLiftStatus() == 1) {
|
|
|
|
+ newLiftNums.getAndIncrement();
|
|
|
|
+ }
|
|
|
|
+ if (a.getLiftStatus() == 3) {
|
|
|
|
+ lostLiftNums.getAndIncrement();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ //新增台量
|
|
|
|
+ regionLiftResponse.setNewLiftNums(newLiftNums.get());
|
|
//丢失电梯台量
|
|
//丢失电梯台量
|
|
- long lostLiftNums = value.stream()
|
|
|
|
- .filter(a -> a.getLiftStatus() == 3).count();
|
|
|
|
- regionLiftResponse.setLostLiftNums(lostLiftNums);
|
|
|
|
|
|
+ regionLiftResponse.setLostLiftNums(lostLiftNums.get());
|
|
//实际总台量
|
|
//实际总台量
|
|
- regionLiftResponse.setTotalLiftNums(totalLiftNums - lostLiftNums);
|
|
|
|
|
|
+ regionLiftResponse.setTotalLiftNums(totalLiftNums - lostLiftNums.get());
|
|
finalRegionLiftResponseList.add(regionLiftResponse);
|
|
finalRegionLiftResponseList.add(regionLiftResponse);
|
|
});
|
|
});
|
|
//通过丢失台量排序并获取前五的数据
|
|
//通过丢失台量排序并获取前五的数据
|