From 77a0331cc648f765cb39555d6f4afa50ef6fc1d9 Mon Sep 17 00:00:00 2001 From: tongchenfei Date: Tue, 12 Jan 2021 18:54:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B9=E4=BE=BF=E6=B5=8B=E8=AF=95=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8A=E6=8A=A5=E9=99=90=E5=88=B6=E6=AC=A1?= =?UTF-8?q?=E6=95=B0=E4=B8=BA1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../share/strategyreceiver/BlockStrategy.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt index e557599dcc..a5185554ef 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt @@ -34,6 +34,10 @@ private const val MORNING_PEAK_STOP_MINUTE = 9 * 60 + 30 private const val NIGHT_PEAK_START_MINUTE = 17 * 60 + 30 private const val NIGHT_PEAK_STOP_MINUTE = 19 * 60 + 30 +private const val NORMAL_UPLOAD_COUNT = 1 // 5 +private const val MORNING_PEAK_UPLOAD_COUNT = 1 // 2 +private const val NIGHT_PEAK_UPLOAD_COUNT = 1 // 3 + private const val DISTANCE_MORNING_PEAK_COUNT = "DISTANCE_MORNING_PEAK_COUNT" private const val DISTANCE_NIGHT_PEAK_COUNT = "DISTANCE_NIGHT_PEAK_COUNT" private const val DISTANCE_NORMAL_COUNT = "DISTANCE_NORMAL_COUNT" @@ -167,7 +171,7 @@ class BlockStrategy(private val context: Context, private val apis: IMogoService if (isMorningPeak()) { val distanceMorningCount = SharedPrefsMgr.getInstance(context).getInt(DISTANCE_MORNING_PEAK_COUNT, 0) val speedMorningCount = SharedPrefsMgr.getInstance(context).getInt(SPEED_MORNING_PEAK_COUNT, 0) - if (blockFromDistance && distanceMorningCount < 2) { + if (blockFromDistance && distanceMorningCount < MORNING_PEAK_UPLOAD_COUNT) { Logger.d(TAG, "按距离策略上报早高峰") SharedPrefsMgr.getInstance(context).putInt(DISTANCE_MORNING_PEAK_COUNT, distanceMorningCount + 1) p.location = latLonFromDistance @@ -175,7 +179,7 @@ class BlockStrategy(private val context: Context, private val apis: IMogoService apis.tanluApi.uploadRoadCondition(p) return } - if (blockFromSpeed && speedMorningCount < 2) { + if (blockFromSpeed && speedMorningCount < MORNING_PEAK_UPLOAD_COUNT) { Logger.d(TAG, "按速度策略上报早高峰") SharedPrefsMgr.getInstance(context).putInt(SPEED_MORNING_PEAK_COUNT, speedMorningCount + 1) p.location = latLonFromSpeed @@ -185,7 +189,7 @@ class BlockStrategy(private val context: Context, private val apis: IMogoService } else if (isNightPeak()) { val distanceNightCount = SharedPrefsMgr.getInstance(context).getInt(DISTANCE_NIGHT_PEAK_COUNT, 0) val speedNightCount = SharedPrefsMgr.getInstance(context).getInt(SPEED_NIGHT_PEAK_COUNT, 0) - if (blockFromDistance && distanceNightCount < 3) { + if (blockFromDistance && distanceNightCount < NIGHT_PEAK_UPLOAD_COUNT) { Logger.d(TAG, "按距离策略上报晚高峰") SharedPrefsMgr.getInstance(context).putInt(DISTANCE_NIGHT_PEAK_COUNT, distanceNightCount + 1) p.location = latLonFromDistance @@ -193,7 +197,7 @@ class BlockStrategy(private val context: Context, private val apis: IMogoService apis.tanluApi.uploadRoadCondition(p) return } - if (blockFromSpeed && speedNightCount < 3) { + if (blockFromSpeed && speedNightCount < NIGHT_PEAK_UPLOAD_COUNT) { Logger.d(TAG, "按速度策略上报晚高峰") SharedPrefsMgr.getInstance(context).putInt(SPEED_NIGHT_PEAK_COUNT, speedNightCount + 1) p.location = latLonFromSpeed @@ -203,7 +207,7 @@ class BlockStrategy(private val context: Context, private val apis: IMogoService } else { val distanceNormalCount = SharedPrefsMgr.getInstance(context).getInt(DISTANCE_NORMAL_COUNT, 0) val speedNormalCount = SharedPrefsMgr.getInstance(context).getInt(SPEED_NORMAL_COUNT, 0) - if (blockFromDistance && distanceNormalCount < 5) { + if (blockFromDistance && distanceNormalCount < NORMAL_UPLOAD_COUNT) { Logger.d(TAG, "按距离策略上报一般时段") SharedPrefsMgr.getInstance(context).putInt(DISTANCE_NORMAL_COUNT, distanceNormalCount + 1) p.location = latLonFromDistance @@ -211,7 +215,7 @@ class BlockStrategy(private val context: Context, private val apis: IMogoService apis.tanluApi.uploadRoadCondition(p) return } - if (blockFromSpeed && speedNormalCount < 5) { + if (blockFromSpeed && speedNormalCount < NORMAL_UPLOAD_COUNT) { Logger.d(TAG, "按速度策略上报一般时段") SharedPrefsMgr.getInstance(context).putInt(SPEED_NORMAL_COUNT, speedNormalCount + 1) p.location = latLonFromSpeed