feiyu02
2021-12-16 49832a5bba94c816e83e7e74095106643f0a433e
1. 用电量日分析
2. 网格权重污染分析
已修改12个文件
已添加9个文件
406 ■■■■ 文件已修改
src/main/kotlin/com/flightfeather/uav/common/Contanst.kt 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/common/utils/MapUtil.kt 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/CompanySOP.kt 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricDailyInfo.kt 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/GridVo.kt 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/EPWModelService.kt 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/EPWModelServiceImpl.kt 141 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ElectricityServiceImpl.kt 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/DeviceInfoController.kt 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/EPWModelController.kt 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/BaseModel.kt 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/BaseSOP.kt 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/NoTag.kt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/epw/EPWGridModel.kt 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/epw/EPWModel.kt 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/epw/NoSection.kt 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/epw/TimeSection.kt 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/epw/WindDirWeight.kt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/epw/WindDisWeight.kt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/EPWModelServiceImplTest.kt 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/common/Contanst.kt
@@ -38,3 +38,7 @@
    put(22, listOf(1.357157189f, 1.155444400f, 1.184586476f, 1.085940877f, 0.841801847f, 1.0f, 1.0f, 1.018320115f))
    put(23, listOf(1.312873355f, 1.191067031f, 1.189618093f, 1.106982786f, 0.848180982f, 1.0f, 1.0f, 1.019044077f))
}
//网格化监测设备经纬度(gps)
const val GridLng = 121.235813
const val GridLat = 30.835898
src/main/kotlin/com/flightfeather/uav/common/utils/MapUtil.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,27 @@
package com.flightfeather.uav.common.utils
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
object MapUtil {
    private const val Ea = 6378137 //赤道半径
    private const val Eb = 6356725 //极半径
    /**
     * æ ¹æ®åæ ‡ç‚¹ã€è·ç¦»å’Œè§’度,获取另一个坐标
     * @param pos åæ ‡ç‚¹(GPSç³»)
     * @param len è·ç¦»ï¼ˆç±³ï¼‰
     * @param radian å¼§åº¦
     */
    fun getPointByLen(pos: Pair<Double, Double>, len: Double, radian: Double): Pair<Double, Double> {
        val dx = len * sin(radian)
        val dy = len * cos(radian)
        val ec = Eb + (Ea - Eb) * (90.0 - pos.second) / 90.0
        val ed = ec * cos(pos.second * PI / 180)
        val lng = (dx / ed + pos.first * PI / 180.0) * 180.0 / PI
        val lat = (dy / ec + pos.second * PI / 180.0) * 180.0 / PI
        return Pair(lng, lat)
    }
}
src/main/kotlin/com/flightfeather/uav/lightshare/bean/CompanySOP.kt
@@ -82,18 +82,6 @@
    var ciAddress: String? = null
    /**
     * ä¸­å¿ƒç»åº¦
     */
    var ciLongitude: BigDecimal? = null
    /**
     * ä¸­å¿ƒçº¬åº¦
     */
    var ciLatitude: BigDecimal? = null
    /**
     * ç»„织机构代码
     */
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricDailyInfo.kt
@@ -30,13 +30,13 @@
    private var pfRunTime: Int = 0
    private var pfRunPeriod = mutableListOf<Int>()
    private var rTimeDiff:Int = 0 //正式运行时间差
    private var sResult:Boolean = false //设备开启是否合规
    private var eTimeDiff: Int = 0 //关闭时间差
    private var eResult: Boolean = false //设备关闭是否合规
    private var runningTimeDiff = 0 //运行时长差
    private var rResult:Boolean = false //运行过程是否合规
    private var dailyResult: String = ""// å½“日分析结果描述
    var rTimeDiff:Int = 0 //正式运行时间差
    var sResult:Boolean = false //设备开启是否合规
    var eTimeDiff: Int = 0 //关闭时间差
    var eResult: Boolean = false //设备关闭是否合规
    var runningTimeDiff = 0 //运行时长差
    var rResult:Boolean = false //运行过程是否合规
    var dailyResult: String = ""// å½“日分析结果描述
    // å½“前设备类型,用于插入数据时决定赋值字段
    private var deviceType: ElectricityType = ElectricityType.ProductionLine
src/main/kotlin/com/flightfeather/uav/lightshare/bean/GridVo.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
package com.flightfeather.uav.lightshare.bean
import com.flightfeather.uav.model.BaseModel
import com.flightfeather.uav.model.BaseSOP
/**
 * é£Žé™©åˆ†æžç½‘格对象
 * Date: 2021/12/8
 */
class GridVo(sourceName: String) : BaseSOP("", sourceName, "") {
    // å·¦ä¸‹åæ ‡
    var lb: Pair<Double, Double>? = null
    // å³ä¸Šåæ ‡
    var rt: Pair<Double, Double>? = null
    // æƒé‡ç»“æžœ<监测因子, æƒé‡ç»“æžœ>
    var result = mutableMapOf<String, Double>()
    // ç›¸å¯¹å½±å“ç­‰çº§ï¼Œ0:影响最大(前33%);1:影响适中(中间33%);2:影响轻微(最后33%)
    var level = mutableMapOf<String, Int>()
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/EPWModelService.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
package com.flightfeather.uav.lightshare.service
import com.flightfeather.uav.lightshare.bean.BaseResponse
import com.flightfeather.uav.lightshare.bean.GridVo
import com.flightfeather.uav.socket.eunm.UWDeviceType
interface EPWModelService {
    /**
     * ç½‘格分析分析
     * @param type æ•°æ®æºç±»åž‹ @see [UWDeviceType], 0a,0b,0c,0d
     * @param len ç½‘格长度
     */
    fun getEpwModelResult(deviceCode: String, startTime: String, endTime: String, len: Double): BaseResponse<List<GridVo>>
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/EPWModelServiceImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,141 @@
package com.flightfeather.uav.lightshare.service.impl
import com.flightfeather.uav.common.GridLat
import com.flightfeather.uav.common.GridLng
import com.flightfeather.uav.common.utils.MapUtil
import com.flightfeather.uav.lightshare.bean.BaseResponse
import com.flightfeather.uav.lightshare.bean.GridVo
import com.flightfeather.uav.lightshare.service.EPWModelService
import com.flightfeather.uav.lightshare.service.RealTimeDataService
import com.flightfeather.uav.model.epw.EPWGridModel
import com.flightfeather.uav.model.epw.EPWModel
import com.flightfeather.uav.socket.eunm.UWDeviceType
import org.springframework.stereotype.Service
import kotlin.math.PI
@Service
class EPWModelServiceImpl(
    private val realTimeDataService: RealTimeDataService,
) : EPWModelService {
    val epwModel = EPWGridModel()
    override fun getEpwModelResult(deviceCode: String, startTime: String, endTime: String, len: Double): BaseResponse<List<GridVo>> {
        if (deviceCode.length < 2) return BaseResponse(false, "设备编号格式错误")
        val type = deviceCode.substring(0, 2)
        // ç¡®å®šæ•°æ®æºç±»åž‹ï¼ŒåŒºåˆ†ä¸ºâ€˜å®šç‚¹ç›‘测数据’和‘移动监测数据两种’
        val gridType = when (type) {
            UWDeviceType.UAV.value -> '0'
            UWDeviceType.VEHICLE.value -> '0'
            UWDeviceType.GRID.value -> '1'
            UWDeviceType.BOAT.value -> 'f'
            else -> 'f'
        }
        if (gridType == 'f') return BaseResponse(false)
        val points = mutableListOf<GridVo>()
        // æ ¹æ®ä¸åŒç±»åž‹ï¼Œç¡®å®šä¸åŒçš„网格生成方式,得出网格中心点集合(网格默认采用正方形)
        // èµ°èˆªç›‘测
        if (gridType == '0') {
            // TODO: 2021/12/6 èµ°èˆªç›‘测网格点生成
        }
        // å®šç‚¹ç›‘测
        else if (gridType == '1') {
            // FIXME: 2021/12/6 æ­¤å¤„为了测试暂时将站点经纬度写死,后续通过数据库配置获取
            val center = Pair(121.235813, 30.835898)
            // a.确定网格长度对应的坐标差值
            val p1 = MapUtil.getPointByLen(center, len, PI / 2)//正东方向(90°)的坐标点
            val p2 = MapUtil.getPointByLen(center, len, PI)//正南方向(180°)的坐标点
            val dx = p1.first - center.first
            val dy = center.second - p2.second
            // b.确定单边有多少个网格(规定监测点在中心网格的中点上,因此单边网格数一定为奇数)
            val totalLen = 2000 // ç½‘格范围,边长为20千米的正方形
            val gridNum = ((totalLen / 2 / len).toInt() - 1) * 2 + 1
            // c.确定左上角网格左下和右上的两个对角点坐标
            //中心点坐标
            val g1CenterLng = center.first - (gridNum - 1) / 2 * dx//经度减小
            val g1CenterLat = center.second + (gridNum - 1) / 2 * dy//纬度增加
            //左下坐标
            val g1LB = Pair(g1CenterLng - dx / 2, g1CenterLat - dy / 2)
            //右上坐标
            val g1RT = Pair(g1CenterLng + dx / 2, g1CenterLat + dy / 2)
            // d.得出所有网格的两个对角点坐标
            for (x in 0 until gridNum) {
                for (y in 0 until gridNum) {
                    points.add(GridVo("$x-$y").apply {
                        this.lb = Pair(g1LB.first + dx * x, g1LB.second - dy * y)
                        this.rt = Pair(g1RT.first + dx * x, g1RT.second - dy * y)
                        this.ciLongitude = (lb!!.first + dx / 2).toBigDecimal()
                        this.ciLatitude = (lb!!.second + dy / 2).toBigDecimal()
                    })
                }
            }
        }
        // è®¡ç®—各中心点污染风险权重结果并赋予对应影响等级
        var page = 1
        var totalPage = -1
        while (totalPage == -1 || page <= totalPage) {
            realTimeDataService.getSecondData(deviceCode, startTime, endTime, 0, page, 5000).apply {
                if (totalPage == -1) {
                    totalPage = head?.totalPage ?: 0
                }
                val dataList = data ?: emptyList()
                // FIXME: 2021/7/13 æ­¤å¤„为了测试暂时将站点经纬度写死,后续通过数据库配置获取
                dataList.forEach {
                    if (it.lng == 0.0 && it.lat == 0.0) {
                        it.lng = GridLng
                        it.lat = GridLat
                    }
                }
                epwModel.execute(dataList, points, true)
                page++
            }
        }
        val r = epwModel.outputResult()
        val max = mutableMapOf<String, Double>()//记录每种监测因子的最大值
//        val min = mutableMapOf<String, Double>()//记录每种监测因子的最小值
        //为每个网格赋值权重结果并且筛选各监测因子的最大最小值
        points.forEach {
            val key = "${it.sourceName};${it.index}"
            val d = r[key]
            d?.forEach { (t, u) ->
                it.result[t] = u["综合(${t})"]?.average ?: .0
                //筛选最大值
                if (!max.containsKey(t)) {
                    max[t] = it.result[t]!!
                } else {
                    if (max[t]!! < it.result[t]!!) {
                        max[t] = it.result[t]!!
                    }
                }
//                //筛选最小值
//                if (!min.containsKey(t)) {
//                    min[t] = it.result[t]!!
//                } else {
//                    if (min[t]!! > it.result[t]!!) {
//                        min[t] = it.result[t]!!
//                    }
//                }
            }
        }
        // æ ¹æ®æœ€å¤§æœ€å°å€¼ï¼Œè®¡ç®—每个网格的各监测因子的影响等级(0->2)(影响大->小)
        points.forEach {
            it.result.forEach{ (k, v) ->
                max[k]?.let {m ->
                    val level = when (v / m) {
                        in 0.6666..1.0 -> 0
                        in 0.3333..0.6665 -> 1
                        in .0..0.3332 -> 2
                        else -> 2
                    }
                    it.level[k] = level
                }
            }
        }
        return BaseResponse(true, data = points)
    }
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ElectricityServiceImpl.kt
@@ -132,11 +132,13 @@
        if (startTime == null && endTime == null) {
            dataList1.reverse()
        }
        pageInfo = PageHelper.startPage<ElectricMinuteValue>(p, perP)
        if (dataList1.isEmpty()) return BaseResponse(true, data = result)
//        pageInfo = PageHelper.startPage<ElectricMinuteValue>(p, perP)
        val dataList2 = electricMinuteValueMapper.selectByExample(Example(ElectricMinuteValue::class.java).apply {
            createCriteria().andEqualTo("mvStatCode", d2?.cdDeviceCode)
                .apply {
                    sTime?.let { andGreaterThanOrEqualTo("mvDataTime", it) }
                    andGreaterThanOrEqualTo("mvDataTime", sTime ?: dataList1[0].mvDataTime)
                    eTime?.let { andLessThanOrEqualTo("mvDataTime", it) }
                }
            orderBy("mvDataTime").apply {
src/main/kotlin/com/flightfeather/uav/lightshare/web/DeviceInfoController.kt
@@ -2,6 +2,7 @@
import com.flightfeather.uav.lightshare.service.DeviceService
import io.swagger.annotations.Api
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
@@ -10,5 +11,6 @@
@RequestMapping("air/device")
class DeviceInfoController(private val deviceService: DeviceService) {
    @GetMapping("/all")
    fun getDeviceInfo() = deviceService.getDeviceInfo()
}
src/main/kotlin/com/flightfeather/uav/lightshare/web/EPWModelController.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
package com.flightfeather.uav.lightshare.web
import com.flightfeather.uav.lightshare.service.EPWModelService
import io.swagger.annotations.Api
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
@Api(tags = ["污染权重分析API接口"])
@RestController
@RequestMapping("air/analysis")
class EPWModelController (private val epwModelService: EPWModelService){
    @GetMapping("/epw")
    fun epwModel(
        @RequestParam(value = "deviceCode", required = true) deviceCode: String,
        @RequestParam(value = "startTime", required = true) startTime: String,
        @RequestParam(value = "endTime", required = true) endTime: String,
        @RequestParam(value = "len", required = true) len: Double,
    ) = epwModelService.getEpwModelResult(deviceCode, startTime, endTime, len)
}
src/main/kotlin/com/flightfeather/uav/model/BaseModel.kt
@@ -14,7 +14,7 @@
 * æ±¡æŸ“源影响程度权重分析模型
 * åŸºç±»
 */
abstract class BaseModel<M : BaseMData, S : BaseSOP> {
abstract class BaseModel<M : BaseMData> {
    data class ResultCell(
        var total: Double = 0.0,
@@ -27,26 +27,26 @@
        }
    }
    abstract var dataPrep: BaseDataPrep<M, S>
    abstract var dataPrep: BaseDataPrep<M, BaseSOP>
    // æƒé‡å› å­ï¼Œåœ¨è¿›è¡Œè®¡ç®—分析时使用的监测因子
    abstract var factorTypes: List<FactorType>
    // æƒé‡å€¼ï¼Œå¤šç§æƒé‡è¿›è¡Œä¹˜ç§¯è®¡ç®—
    abstract var weights: List<BaseWeight<M, S>>
    abstract var weights: List<BaseWeight<M, BaseSOP>>
    // è®¡ç®—结果
    private val rMap = mutableMapOf<String, MutableMap<String, MutableMap<String, ResultCell>>>()
    // ç»“果筛选方式
    abstract var sections: List<BaseSection<M, S>>
    abstract var sections: List<BaseSection<M, BaseSOP>>
    /**
     * æ±¡æŸ“源影响程度计算
     * @param mDataList ç›‘测数据集合
     * @param sopList æ±¡æŸ“源集合
     */
    fun execute(mDataList: List<M>, sopList: List<S>, hasNext: Boolean = false) {
    fun execute(mDataList: List<M>, sopList: List<BaseSOP>, hasNext: Boolean = false) {
        if (!hasNext) rMap.clear()
        //1. æ•°æ®é¢„处理
@@ -68,7 +68,7 @@
     * @param mData ç›‘测数据
     * @param sop æ±¡æŸ“源
     */
    private fun weightCompute(mData: M, sop: S) {
    private fun weightCompute(mData: M, sop: BaseSOP) {
        val effect = BaseEffect(sop.sourceId, sop.sourceName, sop.index)
        // å°†åŽŸç›‘æµ‹æ•°æ®æŒ‰ç…§æƒé‡è®¡ç®—å‡ºç»“æžœå€¼
@@ -234,5 +234,5 @@
    /**
     * æ±¡æŸ“源数据合法性检查
     */
    abstract fun sopCheck(s: S): Boolean
    abstract fun sopCheck(s: BaseSOP): Boolean
}
src/main/kotlin/com/flightfeather/uav/model/BaseSOP.kt
@@ -1,5 +1,7 @@
package com.flightfeather.uav.model
import java.math.BigDecimal
/**
 * Source of pollution
 * æ±¡æŸ“源 åŸºç±»
@@ -9,4 +11,16 @@
    var sourceId: String,
    var sourceName: String,
    var index: String
)
) {
    /**
     * ä¸­å¿ƒç»åº¦
     */
    var ciLongitude: BigDecimal? = null
    /**
     * ä¸­å¿ƒçº¬åº¦
     */
    var ciLatitude: BigDecimal? = null
}
src/main/kotlin/com/flightfeather/uav/model/NoTag.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,5 @@
package com.flightfeather.uav.model
class NoTag : BaseTag() {
    override var name: String = "无分类"
}
src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt
@@ -5,6 +5,7 @@
import com.flightfeather.uav.lightshare.bean.CompanySOP
import com.flightfeather.uav.lightshare.bean.DataVo
import com.flightfeather.uav.model.BaseDataPrep
import com.flightfeather.uav.model.BaseSOP
import com.flightfeather.uav.socket.bean.AirData
import com.flightfeather.uav.socket.bean.AirDataPackage
import com.flightfeather.uav.socket.eunm.FactorType
@@ -13,7 +14,7 @@
import kotlin.math.round
import kotlin.math.sqrt
class EPWDataPrep : BaseDataPrep<DataVo, CompanySOP>() {
class EPWDataPrep : BaseDataPrep<DataVo, BaseSOP>() {
    // å‘前检索的数据记录数
    private val ncal = 15
@@ -99,7 +100,7 @@
        return mDataList
    }
    override fun sopPrep(sopList: List<CompanySOP>): List<CompanySOP> {
    override fun sopPrep(sopList: List<BaseSOP>): List<BaseSOP> {
        return sopList
    }
src/main/kotlin/com/flightfeather/uav/model/epw/EPWGridModel.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,28 @@
package com.flightfeather.uav.model.epw
import com.flightfeather.uav.lightshare.bean.DataVo
import com.flightfeather.uav.model.*
import com.flightfeather.uav.socket.eunm.FactorType
import java.math.BigDecimal
/**
 * ç½‘格化权重分析模型
 * æ ¹æ®èµ°èˆªç›‘测数据、定点监测数据,结合风速、风向、监测点与网格中心的相对位置等因素,计算网格区域对监测区域的影响程度
 * @author riku
 */
class EPWGridModel : BaseModel<DataVo>() {
    // é»˜è®¤ç›‘测点经纬度
    var defaultLocation: Pair<Double, Double>? = null
        set(value) {
            weights = listOf(WindDirWeight(value), WindDisWeight(value))
        }
    override var dataPrep: BaseDataPrep<DataVo, BaseSOP> = EPWDataPrep()
    override var factorTypes: List<FactorType> = WeightType.weightType
    override var weights: List<BaseWeight<DataVo, BaseSOP>> = listOf(WindDirWeight(defaultLocation), WindDisWeight(defaultLocation))
    override var sections: List<BaseSection<DataVo, BaseSOP>> = listOf(NoSection())
    override fun mDataCheck(m: DataVo): Boolean = !(m.lng == null || m.lng == 0.0 || m.lat == null || m.lat == 0.0)
    override fun sopCheck(s: BaseSOP): Boolean =
        !(s.ciLongitude == null || s.ciLongitude == BigDecimal(0) || s.ciLatitude == null || s.ciLatitude == BigDecimal(0))
}
src/main/kotlin/com/flightfeather/uav/model/epw/EPWModel.kt
@@ -11,7 +11,7 @@
 * æ ¹æ®èµ°èˆªç›‘测数据,结合风速、风向、监测点与企业的相对位置等因素,计算企业对监测区域的影响程度
 * @author riku
 */
class EPWModel : BaseModel<DataVo, CompanySOP>() {
class EPWModel : BaseModel<DataVo>() {
    // é»˜è®¤ç›‘测点经纬度
    var defaultLocation: Pair<Double, Double>? = null
@@ -19,17 +19,17 @@
            weights = listOf(WindDirWeight(value), WindDisWeight(value))
        }
    override var dataPrep: BaseDataPrep<DataVo, CompanySOP> = EPWDataPrep()
    override var dataPrep: BaseDataPrep<DataVo, BaseSOP> = EPWDataPrep()
    override var factorTypes: List<FactorType> = WeightType.weightType
    override var weights: List<BaseWeight<DataVo, CompanySOP>> = listOf(WindDirWeight(defaultLocation), WindDisWeight(defaultLocation))
    override var weights: List<BaseWeight<DataVo, BaseSOP>> = listOf(WindDirWeight(defaultLocation), WindDisWeight(defaultLocation))
    override var sections: List<BaseSection<DataVo, CompanySOP>> = listOf(TimeSection())
    override var sections: List<BaseSection<DataVo, BaseSOP>> = listOf(TimeSection())
    override fun mDataCheck(m: DataVo): Boolean = !(m.lng == null || m.lng == 0.0 || m.lat == null || m.lat == 0.0)
    override fun sopCheck(s: CompanySOP): Boolean =
    override fun sopCheck(s: BaseSOP): Boolean =
        !(s.ciLongitude == null || s.ciLongitude == BigDecimal(0) || s.ciLatitude == null || s.ciLatitude == BigDecimal(0))
}
src/main/kotlin/com/flightfeather/uav/model/epw/NoSection.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
package com.flightfeather.uav.model.epw
import com.flightfeather.uav.lightshare.bean.DataVo
import com.flightfeather.uav.model.*
/**
 * ä¸åšåˆ†ç±»ç»Ÿè®¡
 */
class NoSection : BaseSection<DataVo, BaseSOP>() {
    override val sectionValues: List<Double> = listOf(1.0)
    override val sectionType: List<String> = listOf("综合")
    override val tagClz: Class<out BaseTag> = NoTag::class.java
    override fun onSectionValue(mData: DataVo, sop: BaseSOP, effect: BaseEffect): Double {
        return .0
    }
}
src/main/kotlin/com/flightfeather/uav/model/epw/TimeSection.kt
@@ -2,16 +2,13 @@
import com.flightfeather.uav.lightshare.bean.CompanySOP
import com.flightfeather.uav.lightshare.bean.DataVo
import com.flightfeather.uav.model.BaseEffect
import com.flightfeather.uav.model.BaseSection
import com.flightfeather.uav.model.BaseTag
import com.flightfeather.uav.model.TimeTag
import com.flightfeather.uav.model.*
/**
 * æ—¶æ®µåˆ†ç±»ç»Ÿè®¡
 * [6,9,12,14,17,20]; [6,9)为早上,之后依次为上午,中午,下午,傍晚和晚上
 */
class TimeSection : BaseSection<DataVo, CompanySOP>() {
class TimeSection : BaseSection<DataVo, BaseSOP>() {
    override val sectionValues: List<Double> = listOf(6.0, 9.0, 12.0, 14.0, 17.0, 20.0)
@@ -21,7 +18,7 @@
    override val constType: List<String> = listOf("综合")
    override fun onSectionValue(mData: DataVo, sop: CompanySOP, effect: BaseEffect): Double {
    override fun onSectionValue(mData: DataVo, sop: BaseSOP, effect: BaseEffect): Double {
        return getHour(mData.time!!)
    }
src/main/kotlin/com/flightfeather/uav/model/epw/WindDirWeight.kt
@@ -2,6 +2,7 @@
import com.flightfeather.uav.lightshare.bean.CompanySOP
import com.flightfeather.uav.lightshare.bean.DataVo
import com.flightfeather.uav.model.BaseSOP
import com.flightfeather.uav.model.BaseWeight
import com.flightfeather.uav.socket.eunm.FactorType
import kotlin.math.PI
@@ -11,7 +12,7 @@
/**
 * é£Žå‘权重
 */
class WindDirWeight(var defaultLocation: Pair<Double, Double>?) : BaseWeight<DataVo, CompanySOP>() {
class WindDirWeight(var defaultLocation: Pair<Double, Double>?) : BaseWeight<DataVo, BaseSOP>() {
    override val tag: String = "风向权重"
@@ -19,7 +20,7 @@
    override val weights: List<Double> = listOf(1.0, 0.8, 0.5, 0.2, 0.1)
    override fun onWeightFactor(mData: DataVo, sop: CompanySOP): Double {
    override fun onWeightFactor(mData: DataVo, sop: BaseSOP): Double {
        val p1 = if (mData.lng == null || mData.lat == null || mData.lng == .0 || mData.lat == .0) defaultLocation else Pair(mData.lng!!, mData.lat!!)
        p1 ?: return .0
        val p2 = Pair(sop.ciLongitude!!.toDouble(), sop.ciLatitude!!.toDouble())
src/main/kotlin/com/flightfeather/uav/model/epw/WindDisWeight.kt
@@ -2,6 +2,7 @@
import com.flightfeather.uav.lightshare.bean.CompanySOP
import com.flightfeather.uav.lightshare.bean.DataVo
import com.flightfeather.uav.model.BaseSOP
import com.flightfeather.uav.model.BaseWeight
import com.flightfeather.uav.socket.eunm.FactorType
import kotlin.math.abs
@@ -12,7 +13,7 @@
 * é£Žé€Ÿè·ç¦»æƒé‡
 * ç›‘测点与污染源之间的物理距离与当前风速得出的权重
 */
class WindDisWeight(var defaultLocation: Pair<Double, Double>?) : BaseWeight<DataVo, CompanySOP>() {
class WindDisWeight(var defaultLocation: Pair<Double, Double>?) : BaseWeight<DataVo, BaseSOP>() {
    override val tag: String = "风速距离权重"
@@ -20,7 +21,7 @@
    override val weights: List<Double> = listOf(1.0, 0.8, 0.6, 0.5, 0.3, 0.0)
    override fun onWeightFactor(mData: DataVo, sop: CompanySOP): Double? {
    override fun onWeightFactor(mData: DataVo, sop: BaseSOP): Double? {
        val p1 = if (mData.lng == null || mData.lat == null || mData.lng == .0 || mData.lat == .0) defaultLocation else Pair(mData.lng!!, mData.lat!!)
        p1 ?: return .0
        val p2 = Pair(sop.ciLongitude!!.toDouble(), sop.ciLatitude!!.toDouble())
src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/EPWModelServiceImplTest.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,24 @@
package com.flightfeather.uav.lightshare.service.impl
import com.flightfeather.uav.lightshare.service.EPWModelService
import com.flightfeather.uav.lightshare.service.ElectricityService
import junit.framework.TestCase
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
@SpringBootTest
class EPWModelServiceImplTest : TestCase() {
    @Autowired
    lateinit var epwModelService: EPWModelService
    @Test
    fun testGetEpwModelResult() {
        val r= epwModelService.getEpwModelResult("0d0000000001", "2021-07-01 00:00:00", "2021-07-01 23:59:59", 1000.0)
        println(r)
    }
}