|
@@ -42,9 +42,9 @@ public class LiftDataService {
|
|
|
//默认状态为新增
|
|
|
entry.setLiftStatus(1);
|
|
|
//电梯停保
|
|
|
- if (CommonEnum.LiftStatus.STOP_INSURANCE.equals(entry.getLiftCompanyStatus())) {
|
|
|
+ if (CommonEnum.LiftStatus.STOP_INSURANCE.getCode().equals(entry.getLiftCompanyStatus())) {
|
|
|
entry.setLiftStatus(3);
|
|
|
- } else if (CommonEnum.ProjectStatus.STOP_SERVICE.equals(entry.getProjectStatus())) {
|
|
|
+ } else if (CommonEnum.ProjectStatus.STOP_SERVICE.getCode().equals(entry.getProjectStatus())) {
|
|
|
entry.setLiftStatus(3);
|
|
|
entry.setLostTime(entry.getProjectEndTime());
|
|
|
}
|
|
@@ -60,15 +60,13 @@ public class LiftDataService {
|
|
|
* @date 2020/2/5 12:28 下午
|
|
|
*/
|
|
|
public RestResponse liftOverView(LiftDataRequest liftDataRequest) {
|
|
|
- //获取时间段内按月份统计的丢失电梯数量
|
|
|
Map<Integer, List<Long>> liftStatusToNums = initLiftStatusToNums(liftDataRequest);
|
|
|
-
|
|
|
//从redis中获取当前公司总的电梯信息
|
|
|
List<LiftDataModel> companyTotalLiftDataList = getLiftDataModels(liftDataRequest);
|
|
|
//设置时间段
|
|
|
DataStatisticsUtil.setBeginYearToNow(liftDataRequest);
|
|
|
//从redis中获取当前公司时间段之内的电梯信息
|
|
|
- List<LiftDataModel> liftDataModelList = getLiftDataModels(liftDataRequest);
|
|
|
+ List<LiftDataModel> liftDataModelList = getNewLiftData(companyTotalLiftDataList, liftDataRequest);
|
|
|
if ((companyTotalLiftDataList != null && companyTotalLiftDataList.size() > 0)) {
|
|
|
//获取传递起始时间之前的电梯信息
|
|
|
List<LiftDataModel> beforeLiftDataList = companyTotalLiftDataList.stream()
|
|
@@ -106,18 +104,21 @@ public class LiftDataService {
|
|
|
DataStatisticsUtil.getMonth(liftDataModel.getConnectTime()), Collectors.counting()));
|
|
|
|
|
|
//获取时间段内按月份统计的丢失电梯数量
|
|
|
- Map<Integer, Long> monthToLostLiftNums = liftDataModelList.stream()
|
|
|
- //获取电梯状态是丢失的电梯数据
|
|
|
- .filter(a -> {
|
|
|
- if (a.getLiftStatus() != null) {
|
|
|
- return a.getLiftStatus() == 3;
|
|
|
- }
|
|
|
- return false;
|
|
|
- })
|
|
|
- //通过丢失时间顺序排列
|
|
|
- .sorted(Comparator.comparing(LiftDataModel::getLostTime))
|
|
|
- .collect(Collectors.groupingBy(liftDataModel ->
|
|
|
- DataStatisticsUtil.getMonth(liftDataModel.getLostTime()), Collectors.counting()));
|
|
|
+ liftDataModelList = liftDataModelList.stream().filter(liftDataModel -> {
|
|
|
+ //获取电梯状态是丢失的电梯数据
|
|
|
+ if (liftDataModel.getLiftStatus() != null) {
|
|
|
+ return liftDataModel.getLiftStatus() == 3;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ //通过丢失时间顺序排列
|
|
|
+ }).sorted(Comparator.comparing(liftDataModel -> {
|
|
|
+ if (liftDataModel.getLostTime() != null) {
|
|
|
+ return liftDataModel.getLostTime();
|
|
|
+ }
|
|
|
+ return LocalDateTime.of(1970, 1, 1, 0, 0, 0);
|
|
|
+ })).collect(Collectors.toList());
|
|
|
+ Map<Integer, Long> monthToLostLiftNums = liftDataModelList.stream().collect(Collectors.groupingBy(liftDataModel ->
|
|
|
+ DataStatisticsUtil.getMonth(liftDataModel.getLostTime()), Collectors.counting()));
|
|
|
//设置电梯总览情况
|
|
|
setLiftOverViewNum(liftDataRequest, liftStatusToNums, beforeLiftTotalNum, monthToNewLiftNums, monthToLostLiftNums);
|
|
|
}
|
|
@@ -230,12 +231,12 @@ public class LiftDataService {
|
|
|
List<Long> onMaintenanceLiftNums = new ArrayList<>();
|
|
|
List<Long> lostLiftNums = new ArrayList<>();
|
|
|
for (int i = 1; i <= nowMonthValue; i++) {
|
|
|
- long newLiftNum = monthToNewLiftNums.get(i) != null ? monthToNewLiftNums.get(i) : 0L;
|
|
|
- long lostLiftNum = monthToLostLiftNums.get(i) != null ? monthToLostLiftNums.get(i) : 0L;
|
|
|
+ long newLiftNum = DataStatisticsUtil.getLongValue(monthToNewLiftNums.get(i));
|
|
|
+ long lostLiftNum = DataStatisticsUtil.getLongValue(monthToLostLiftNums.get(i));
|
|
|
//计算在保电梯台量:原有电梯台量 + 新增电梯台量 - 丢失电梯台量
|
|
|
- long onMaintenanceLiftNum = beforeLiftTotalNum + newLiftNum - lostLiftNum;
|
|
|
+ beforeLiftTotalNum = beforeLiftTotalNum + newLiftNum - lostLiftNum;
|
|
|
newLiftNums.add(newLiftNum);
|
|
|
- onMaintenanceLiftNums.add(onMaintenanceLiftNum);
|
|
|
+ onMaintenanceLiftNums.add(beforeLiftTotalNum);
|
|
|
lostLiftNums.add(lostLiftNum);
|
|
|
}
|
|
|
liftStatusToNums.put(1, newLiftNums);
|
|
@@ -271,4 +272,24 @@ public class LiftDataService {
|
|
|
liftStatusToNums.put(3, lostLiftNums);
|
|
|
return liftStatusToNums;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param liftDataRequest 新增电梯
|
|
|
+ * @return
|
|
|
+ * @description
|
|
|
+ * @date 2020/5/23 4:44 下午
|
|
|
+ */
|
|
|
+ private List<LiftDataModel> getNewLiftData(List<LiftDataModel> liftDataModelList, LiftDataRequest liftDataRequest) {
|
|
|
+ if (liftDataModelList != null && liftDataModelList.size() > 0) {
|
|
|
+ return liftDataModelList.stream().filter(liftDataModel -> {
|
|
|
+ if (liftDataModel.getLostTime() != null) {
|
|
|
+ return liftDataModel.getLostTime().isAfter(liftDataRequest.getStartTimeDate()) ||
|
|
|
+ liftDataModel.getLostTime().isBefore(liftDataRequest.getEndTimeDate());
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
}
|