|
|
@ -1,7 +1,9 @@ |
|
|
|
package com.zc.business.service.impl; |
|
|
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult; |
|
|
|
import com.ruoyi.common.utils.StakeMarkUtils; |
|
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
import com.zc.business.domain.DcDevice; |
|
|
|
import com.zc.business.domain.DcMeteorologicalDetectorData; |
|
|
|
import com.zc.business.mapper.DcWeatherMonitoringMapper; |
|
|
|
import com.zc.business.service.IDcWeatherMonitoringService; |
|
|
@ -9,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@ -25,6 +28,8 @@ public class DcWeatherMonitoringServiceImpl implements IDcWeatherMonitoringServi |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DcWeatherMonitoringMapper weatherMonitoringMapper; |
|
|
|
@Autowired |
|
|
|
private DcDeviceServiceImpl dcDeviceService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@ -39,8 +44,12 @@ public class DcWeatherMonitoringServiceImpl implements IDcWeatherMonitoringServi |
|
|
|
public AjaxResult getTrafficConditions(){ |
|
|
|
|
|
|
|
|
|
|
|
DcDevice dcDevice = new DcDevice(); |
|
|
|
dcDevice.setDeviceType(3); |
|
|
|
List<DcDevice> deviceList = dcDeviceService.listDevice(dcDevice); |
|
|
|
|
|
|
|
//正常路段里程
|
|
|
|
BigDecimal normalMileage = new BigDecimal("154.585"); |
|
|
|
BigDecimal normalMileage = BigDecimal.ZERO; |
|
|
|
//降水里程
|
|
|
|
BigDecimal rainfallMileage = BigDecimal.ZERO; |
|
|
|
//团雾路段(处)
|
|
|
@ -50,10 +59,23 @@ public class DcWeatherMonitoringServiceImpl implements IDcWeatherMonitoringServi |
|
|
|
//异常数量
|
|
|
|
int anomalies = 0; |
|
|
|
//设备数量
|
|
|
|
int deviceNum = 10; |
|
|
|
int deviceNum = deviceList.size(); |
|
|
|
|
|
|
|
Map<String,Object> deviceRange = new HashMap<>(); |
|
|
|
|
|
|
|
for (DcDevice device : deviceList) { |
|
|
|
if (StringUtils.isNotEmpty(device.getStakeMarkRange())){ |
|
|
|
String[] stakeMarkRange = device.getStakeMarkRange().split(","); |
|
|
|
BigDecimal detectionRange = StakeMarkUtils.getKilometre(stakeMarkRange[1],stakeMarkRange[0]); |
|
|
|
normalMileage = normalMileage.add(detectionRange).setScale(2, RoundingMode.HALF_UP); |
|
|
|
deviceRange.put(device.getIotDeviceId(),detectionRange); |
|
|
|
} else { |
|
|
|
deviceRange.put(device.getIotDeviceId(),BigDecimal.ZERO); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//每个设备的检测范围
|
|
|
|
BigDecimal detectionRange = new BigDecimal("15.4585"); |
|
|
|
// BigDecimal detectionRange = new BigDecimal("15.4585");
|
|
|
|
|
|
|
|
List<DcMeteorologicalDetectorData> dataList = weatherMonitoringMapper.selectMeteorologicalDetectorData(); |
|
|
|
for (DcMeteorologicalDetectorData meteorologicalDetectorData : dataList) { |
|
|
@ -61,6 +83,9 @@ public class DcWeatherMonitoringServiceImpl implements IDcWeatherMonitoringServi |
|
|
|
if (StringUtils.isNotEmpty(meteorologicalDetectorData.getRainfall()) || StringUtils.isNotEmpty(meteorologicalDetectorData.getVisibilityType())){ |
|
|
|
BigDecimal rainfall = new BigDecimal(meteorologicalDetectorData.getRainfall()); |
|
|
|
if (rainfall.compareTo(BigDecimal.ZERO) > 0 || !"4".equals(meteorologicalDetectorData.getVisibilityType())){ |
|
|
|
|
|
|
|
if (deviceRange.get(meteorologicalDetectorData.getIotDeviceId()) != null){ |
|
|
|
BigDecimal detectionRange = new BigDecimal(deviceRange.get(meteorologicalDetectorData.getIotDeviceId()).toString()); |
|
|
|
normalMileage = normalMileage.subtract(detectionRange); |
|
|
|
anomalies ++; |
|
|
|
if (rainfall.compareTo(BigDecimal.ZERO) > 0){ |
|
|
@ -71,6 +96,8 @@ public class DcWeatherMonitoringServiceImpl implements IDcWeatherMonitoringServi |
|
|
|
heavyFogMileage = heavyFogMileage.add(detectionRange); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|