|
@@ -1,9 +1,7 @@
|
|
|
package cn.com.ty.lift.batch.applet.service;
|
|
|
|
|
|
-import cn.com.ty.lift.batch.applet.constants.DataStatisticsConstants;
|
|
|
import cn.com.ty.lift.batch.applet.dao.mapper.LiftDataMapper;
|
|
|
import cn.com.ty.lift.batch.applet.dao.model.LiftDataModel;
|
|
|
-import cn.com.ty.lift.batch.applet.dao.model.request.CommonRequest;
|
|
|
import cn.com.ty.lift.batch.applet.dao.model.request.LiftDataRequest;
|
|
|
import cn.com.ty.lift.batch.applet.dao.model.response.RegionLiftResponse;
|
|
|
import cn.com.ty.lift.batch.applet.dao.model.response.RegionLiftResponseTotal;
|
|
@@ -12,7 +10,6 @@ import cn.com.ty.lift.common.constants.ApiConstants;
|
|
|
import cn.com.ty.lift.common.constants.CommonEnum;
|
|
|
import cn.com.ty.lift.common.utils.ProjectUtils;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
-import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -31,9 +28,6 @@ public class LiftDataService {
|
|
|
@Resource
|
|
|
private LiftDataMapper liftDataMapper;
|
|
|
|
|
|
- @Resource
|
|
|
- private RedisTemplate redisTemplate;
|
|
|
-
|
|
|
/**
|
|
|
* @param
|
|
|
* @return
|
|
@@ -41,20 +35,7 @@ public class LiftDataService {
|
|
|
* @date 2020/2/7 12:01 下午
|
|
|
*/
|
|
|
private List<LiftDataModel> getLiftDataModels(LiftDataRequest liftDataRequest) {
|
|
|
- return liftDataMapper.getLiftDataList(liftDataRequest);
|
|
|
-// (List<LiftDataModel>)
|
|
|
-// DataStatisticsUtil.getStatisticsDataFromRedis(redisTemplate,
|
|
|
-// DataStatisticsConstants.LIFT_DATA_FIELD, liftDataRequest.getMtCompanyId());
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param commonRequest 起始时间 终止时间
|
|
|
- * @return
|
|
|
- * @description 将电梯数据放入redis中
|
|
|
- * @date 2020/2/4 10:24 上午
|
|
|
- */
|
|
|
- public void putLiftDataListToRedis(CommonRequest commonRequest) {
|
|
|
- List<LiftDataModel> liftDataModelList = liftDataMapper.getLiftDataList(commonRequest);
|
|
|
+ List<LiftDataModel> liftDataModelList = liftDataMapper.getLiftDataList(liftDataRequest);
|
|
|
//设置电梯状态:1:新增, 3:丢失
|
|
|
if (liftDataModelList != null && liftDataModelList.size() > 0) {
|
|
|
liftDataModelList.forEach(entry -> {
|
|
@@ -69,11 +50,10 @@ public class LiftDataService {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- //通过公司id将数据进行分组,并将数据放入redis中
|
|
|
- DataStatisticsUtil.putStatisticsDataToRedis(liftDataModelList, redisTemplate,
|
|
|
- DataStatisticsConstants.LIFT_DATA_FIELD);
|
|
|
+ return liftDataModelList;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* @param liftDataRequest 起始时间 终止时间
|
|
|
* @return
|
|
@@ -128,16 +108,13 @@ public class LiftDataService {
|
|
|
DataStatisticsUtil.setBeginYearToNow(liftDataRequest);
|
|
|
//从redis中获取当前公司时间段之内的电梯信息
|
|
|
List<LiftDataModel> liftDataModelList = getLiftDataListFromRedis(liftDataRequest);
|
|
|
-
|
|
|
-
|
|
|
- if ((companyTotalLiftDataList != null && companyTotalLiftDataList.size() > 0) &&
|
|
|
- liftDataModelList != null && liftDataModelList.size() > 0) {
|
|
|
+ if ((companyTotalLiftDataList != null && companyTotalLiftDataList.size() > 0)) {
|
|
|
//获取传递起始时间之前的电梯信息
|
|
|
List<LiftDataModel> beforeLiftDataList = companyTotalLiftDataList.stream()
|
|
|
//新建时间在起始时间之前的
|
|
|
- .filter(a -> {
|
|
|
- if (a.getConnectTime() != null) {
|
|
|
- return a.getConnectTime().isBefore(liftDataRequest.getStartTimeDate());
|
|
|
+ .filter(liftDataModel -> {
|
|
|
+ if (liftDataModel.getConnectTime() != null) {
|
|
|
+ return liftDataModel.getConnectTime().isBefore(liftDataRequest.getStartTimeDate());
|
|
|
}
|
|
|
return false;
|
|
|
})
|
|
@@ -146,9 +123,9 @@ public class LiftDataService {
|
|
|
long beforeLiftTotalNum = 0L;
|
|
|
if (beforeLiftDataList.size() > 0) {
|
|
|
beforeLiftTotalNum = beforeLiftDataList.stream()
|
|
|
- .filter(a -> {
|
|
|
- if (a.getLiftStatus() != null) {
|
|
|
- return a.getLiftStatus() != 3;
|
|
|
+ .filter(liftDataModel -> {
|
|
|
+ if (liftDataModel.getLiftStatus() != null) {
|
|
|
+ return liftDataModel.getLiftStatus() != 3;
|
|
|
}
|
|
|
return false;
|
|
|
}).count();
|
|
@@ -157,9 +134,9 @@ public class LiftDataService {
|
|
|
//获取时间段内按月份统计的新增电梯数量
|
|
|
Map<Integer, Long> monthToNewLiftNums = liftDataModelList.stream()
|
|
|
//获取电梯状态是新增的电梯数据
|
|
|
- .filter(a -> {
|
|
|
- if (a.getLiftStatus() != null) {
|
|
|
- return a.getLiftStatus() == 1;
|
|
|
+ .filter(liftDataModel -> {
|
|
|
+ if (liftDataModel.getLiftStatus() != null) {
|
|
|
+ return liftDataModel.getLiftStatus() == 1;
|
|
|
}
|
|
|
return false;
|
|
|
})
|