riku
2021-11-17 3a7da032ec18b2d5d36afb3fd9622c7d763257b7
1. 将用电量接口返回的参数动态化
已修改9个文件
已删除2个文件
已添加1个文件
309 ■■■■■ 文件已修改
src/main/kotlin/com/flightfeather/uav/domain/entity/CompanyDevice.java 120 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricVo.kt 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/eunm/CarStatus.kt 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/eunm/CarType.kt 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/eunm/ElectricityType.kt 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/RealTimeDataService.kt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ElectricityServiceImpl.kt 65 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/impl/AirDataRepositoryImpl.kt 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/generator/generatorConfig.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/CompanyDeviceMapper.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/CompanyDevice.java
@@ -15,6 +15,36 @@
    private String cdDeviceCode;
    /**
     * è®¾å¤‡ç±»åž‹ï¼Œ0:产线;1:净化
     */
    @Column(name = "CD_Type")
    private Integer cdType;
    /**
     * è®¾å¤‡ç±»åž‹åç§°
     */
    @Column(name = "CD_Type_Name")
    private String cdTypeName;
    /**
     * è®¾å¤‡ç”µæµç•Œé™å€¼ï¼Œé‡‡ç”¨â€œ;”分隔不同界限
     */
    @Column(name = "CD_Limits")
    private String cdLimits;
    /**
     * è®¾å¤‡ç”µæµä¸åŒç•Œé™ä¸‹å¯¹åº”的状态编号
     */
    @Column(name = "CD_Status")
    private String cdStatus;
    /**
     * è®¾å¤‡ç”µæµä¸åŒç•Œé™ä¸‹å¯¹åº”的状态名称
     */
    @Column(name = "CD_Status_Name")
    private String cdStatusName;
    /**
     * @return CD_Id
     */
    public Integer getCdId() {
@@ -55,4 +85,94 @@
    public void setCdDeviceCode(String cdDeviceCode) {
        this.cdDeviceCode = cdDeviceCode == null ? null : cdDeviceCode.trim();
    }
    /**
     * èŽ·å–è®¾å¤‡ç±»åž‹ï¼Œ0:产线;1:净化
     *
     * @return CD_Type - è®¾å¤‡ç±»åž‹ï¼Œ0:产线;1:净化
     */
    public Integer getCdType() {
        return cdType;
    }
    /**
     * è®¾ç½®è®¾å¤‡ç±»åž‹ï¼Œ0:产线;1:净化
     *
     * @param cdType è®¾å¤‡ç±»åž‹ï¼Œ0:产线;1:净化
     */
    public void setCdType(Integer cdType) {
        this.cdType = cdType;
    }
    /**
     * èŽ·å–è®¾å¤‡ç±»åž‹åç§°
     *
     * @return CD_Type_Name - è®¾å¤‡ç±»åž‹åç§°
     */
    public String getCdTypeName() {
        return cdTypeName;
    }
    /**
     * è®¾ç½®è®¾å¤‡ç±»åž‹åç§°
     *
     * @param cdTypeName è®¾å¤‡ç±»åž‹åç§°
     */
    public void setCdTypeName(String cdTypeName) {
        this.cdTypeName = cdTypeName == null ? null : cdTypeName.trim();
    }
    /**
     * èŽ·å–è®¾å¤‡ç”µæµç•Œé™å€¼ï¼Œé‡‡ç”¨â€œ;”分隔不同界限
     *
     * @return CD_Limits - è®¾å¤‡ç”µæµç•Œé™å€¼ï¼Œé‡‡ç”¨â€œ;”分隔不同界限
     */
    public String getCdLimits() {
        return cdLimits;
    }
    /**
     * è®¾ç½®è®¾å¤‡ç”µæµç•Œé™å€¼ï¼Œé‡‡ç”¨â€œ;”分隔不同界限
     *
     * @param cdLimits è®¾å¤‡ç”µæµç•Œé™å€¼ï¼Œé‡‡ç”¨â€œ;”分隔不同界限
     */
    public void setCdLimits(String cdLimits) {
        this.cdLimits = cdLimits == null ? null : cdLimits.trim();
    }
    /**
     * èŽ·å–è®¾å¤‡ç”µæµä¸åŒç•Œé™ä¸‹å¯¹åº”çš„çŠ¶æ€ç¼–å·
     *
     * @return CD_Status - è®¾å¤‡ç”µæµä¸åŒç•Œé™ä¸‹å¯¹åº”的状态编号
     */
    public String getCdStatus() {
        return cdStatus;
    }
    /**
     * è®¾ç½®è®¾å¤‡ç”µæµä¸åŒç•Œé™ä¸‹å¯¹åº”的状态编号
     *
     * @param cdStatus è®¾å¤‡ç”µæµä¸åŒç•Œé™ä¸‹å¯¹åº”的状态编号
     */
    public void setCdStatus(String cdStatus) {
        this.cdStatus = cdStatus == null ? null : cdStatus.trim();
    }
    /**
     * èŽ·å–è®¾å¤‡ç”µæµä¸åŒç•Œé™ä¸‹å¯¹åº”çš„çŠ¶æ€åç§°
     *
     * @return CD_Status_Name - è®¾å¤‡ç”µæµä¸åŒç•Œé™ä¸‹å¯¹åº”的状态名称
     */
    public String getCdStatusName() {
        return cdStatusName;
    }
    /**
     * è®¾ç½®è®¾å¤‡ç”µæµä¸åŒç•Œé™ä¸‹å¯¹åº”的状态名称
     *
     * @param cdStatusName è®¾å¤‡ç”µæµä¸åŒç•Œé™ä¸‹å¯¹åº”的状态名称
     */
    public void setCdStatusName(String cdStatusName) {
        this.cdStatusName = cdStatusName == null ? null : cdStatusName.trim();
    }
}
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricVo.kt
@@ -7,9 +7,11 @@
    var d1eB: Double = .0,
    var d1eC: Double = .0,
    var d1Status: String? = "0",
    var d1StatusName: String? = null,
    //废气净化装置
    var d2eA: Double = .0,
    var d2eB: Double = .0,
    var d2eC: Double = .0,
    var d2Status: String? = "0"
    var d2Status: String? = "0",
    var d2StatusName: String? = null
)
src/main/kotlin/com/flightfeather/uav/lightshare/eunm/CarStatus.kt
ÎļþÒÑɾ³ý
src/main/kotlin/com/flightfeather/uav/lightshare/eunm/CarType.kt
ÎļþÒÑɾ³ý
src/main/kotlin/com/flightfeather/uav/lightshare/eunm/ElectricityType.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,12 @@
package com.flightfeather.uav.lightshare.eunm
/**
 * @author riku
 * Date: 2019/9/26
 */
enum class ElectricityType(val value: Int){
    //产线设备
    ProductionLine(0),
    //净化设备
    Purify(1)
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/RealTimeDataService.kt
@@ -30,4 +30,9 @@
     * å‡å€¼è®¡ç®—,将秒级值换算为分钟均值
     */
    fun averageData(): BaseResponse<String>
    /**
     * æ•°æ®ä¼˜åŒ–,在数据预处理基础上做进一步数据优化
     */
    fun dataCalibration(): BaseResponse<String>
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ElectricityServiceImpl.kt
@@ -10,6 +10,7 @@
import com.flightfeather.uav.lightshare.bean.DataHead
import com.flightfeather.uav.lightshare.bean.DataVo
import com.flightfeather.uav.lightshare.bean.ElectricVo
import com.flightfeather.uav.lightshare.eunm.ElectricityType
import com.flightfeather.uav.lightshare.service.ElectricityService
import com.flightfeather.uav.socket.bean.AirData
import com.github.pagehelper.PageHelper
@@ -102,22 +103,21 @@
            createCriteria().andEqualTo("cdCompanyId", cId)
        })
        //产线风机
        var d1: String? = null
        var d1: CompanyDevice? = null
        //废气净化装置
        var d2: String? = null
        var d2: CompanyDevice? = null
        deviceCodeList.forEach {
            // FIXME: 2021/11/5 æ­¤å¤„暂时写死,后续修改
            if (it?.cdDeviceCode == "31011020210602" || it?.cdDeviceCode == "31011020210603") {
                d1 = it.cdDeviceCode
            }else if (it?.cdDeviceCode == "31011020210601" || it?.cdDeviceCode == "31011020210604") {
                d2 = it.cdDeviceCode
            if (it?.cdType == ElectricityType.ProductionLine.value) {
                d1 = it
            }else if (it?.cdType == ElectricityType.Purify.value) {
                d2 = it
            }
        }
        var pageInfo = PageHelper.startPage<ElectricMinuteValue>(p, perP)
        val dataList1 = electricMinuteValueMapper.selectByExample(Example(ElectricMinuteValue::class.java).apply {
            createCriteria().andEqualTo("mvStatCode", d1)
            createCriteria().andEqualTo("mvStatCode", d1?.cdDeviceCode)
                .apply {
                    sTime?.let { andGreaterThanOrEqualTo("mvDataTime", it) }
                    eTime?.let { andLessThanOrEqualTo("mvDataTime", it) }
@@ -134,7 +134,7 @@
        }
        pageInfo = PageHelper.startPage<ElectricMinuteValue>(p, perP)
        val dataList2 = electricMinuteValueMapper.selectByExample(Example(ElectricMinuteValue::class.java).apply {
            createCriteria().andEqualTo("mvStatCode", d2)
            createCriteria().andEqualTo("mvStatCode", d2?.cdDeviceCode)
                .apply {
                    sTime?.let { andGreaterThanOrEqualTo("mvDataTime", it) }
                    eTime?.let { andLessThanOrEqualTo("mvDataTime", it) }
@@ -192,7 +192,9 @@
                            d1eA = d?.mvElectricityA ?: .0
                            d1eB = d?.mvElectricityB ?: .0
                            d1eC = d?.mvElectricityC ?: .0
                            d1Status = getStatus(d)
                            val s = getStatus(d, d1)
                            d1Status = s.first
                            d1StatusName = s.second
                        }
                        dataList1.removeAt(0)
                    }
@@ -205,7 +207,9 @@
                            d2eA = d?.mvElectricityA ?: .0
                            d2eB = d?.mvElectricityB ?: .0
                            d2eC = d?.mvElectricityC ?: .0
                            d2Status = getStatus(d)
                            val s = getStatus(d, d2)
                            d2Status = s.first
                            d2StatusName = s.second
                        }
                        dataList2.removeAt(0)
                    }
@@ -220,30 +224,21 @@
    }
    // FIXME: 2021/11/5 æ­¤å¤„暂时写死,后续修改
    private fun getStatus(e: ElectricMinuteValue?): String {
        var values = listOf(1, 100)
        var status = listOf("0", "2", "3")
    private fun getStatus(e: ElectricMinuteValue?, d: CompanyDevice?): Pair<String, String> {
        var values = mutableListOf<Int>().apply {
            d?.cdLimits?.split(";")?.forEach {
                it.toIntOrNull()?.let { i -> add(i) }
            }
        }
        var status = d?.cdStatus?.split(";") ?: emptyList()
        var statusNames = d?.cdStatusName?.split(";") ?: emptyList()
        if (values.isEmpty()) values = mutableListOf(1, 100)
        if (status.isEmpty()) status = listOf("0", "2", "3")
        if (statusNames.isEmpty()) statusNames = listOf("待机", "运行", "超负荷")
        if (e == null) {
            return status.first()
            return Pair(status.first(), statusNames.first())
        }
        when (e.mvStatCode) {
            "31011020210601" -> {
                values = listOf(1, 100)
                status = listOf("0", "2", "3")
            }
            "31011020210602" -> {
                values = listOf(13, 30)
                status = listOf("0", "2", "3")
            }
            "31011020210603" -> {
                values = listOf(1, 50, 80)
                status = listOf("0", "1", "2", "3")
            }
            "31011020210604" -> {
                values = listOf(15, 90, 125)
                status = listOf("0", "1", "2", "3")
            }
        }
        val electricityList = mutableListOf<Double>()
        electricityList.add(e.mvElectricityA)
        electricityList.add(e.mvElectricityB)
@@ -252,9 +247,9 @@
        val avg = electricityList.average()
        for (i in values.indices) {
            if (avg < values[i]) {
                return status[i]
                return Pair(status[i], statusNames[i])
            }
        }
        return status.last()
        return Pair(status.last(), statusNames.last())
    }
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt
@@ -317,4 +317,8 @@
        return BaseResponse(count > 0, data = "插入数据: ${count}条")
    }
    override fun dataCalibration(): BaseResponse<String> {
        return BaseResponse(true)
    }
}
src/main/kotlin/com/flightfeather/uav/repository/impl/AirDataRepositoryImpl.kt
@@ -172,29 +172,29 @@
                    dataTransform(vo, d)
                    /**************************************************************************/
                    // FIXME: 2021/11/8 é’ˆå¯¹åŽ†å²ç½‘æ ¼åŒ–åŽŸå§‹æ•°æ®ï¼Œè¿›è¡Œä¸´æ—¶æ ¡å‡†å¤„ç†
                    val dTime = LocalDateTime.ofInstant(d.dataTime?.toInstant(), ZoneId.systemDefault())
                    // CO: 2021.8.28 17:27èµ· *0.25
                    val coTime = LocalDateTime.of(2021, 8, 28, 17, 27, 0)
                    if (dTime.isAfter(coTime)) {
                        d.co = d.co?.times(0.25f)
                    }
                    // NO2
                    d.no2 = d.no2?.times(0.6f)
                    // O3
                    d.o3 = abs(d.o3?.minus(d.no2?.div(2) ?: 0f) ?: 0f) * 1.5f
                    // SO2: *0.2, 2021.8.29 6:00èµ· *0.08
                    val so2Time = LocalDateTime.of(2021, 8, 29, 6, 0, 0)
                    d.so2 = if (dTime.isAfter(so2Time)) {
                        d.so2?.times(0.08f)
                    } else {
                        d.so2?.times(0.2f)
                    }
                    // H2S
                    d.h2s = d.h2s?.let { sqrt(it) * 2 }
//                    val dTime = LocalDateTime.ofInstant(d.dataTime?.toInstant(), ZoneId.systemDefault())
//                    // CO: 2021.8.28 17:27èµ· *0.25
//                    val coTime = LocalDateTime.of(2021, 8, 28, 17, 27, 0)
//                    if (dTime.isAfter(coTime)) {
//                        d.co = d.co?.times(0.25f)
//                    }
//
//                    // NO2
//                    d.no2 = d.no2?.times(0.6f)
//
//                    // O3
//                    d.o3 = abs(d.o3?.minus(d.no2?.div(2) ?: 0f) ?: 0f) * 1.5f
//
//                    // SO2: *0.2, 2021.8.29 6:00èµ· *0.08
//                    val so2Time = LocalDateTime.of(2021, 8, 29, 6, 0, 0)
//                    d.so2 = if (dTime.isAfter(so2Time)) {
//                        d.so2?.times(0.08f)
//                    } else {
//                        d.so2?.times(0.2f)
//                    }
//
//                    // H2S
//                    d.h2s = d.h2s?.let { sqrt(it) * 2 }
                    /**************************************************************************/
                    realTimeDataGridMapper.insert(d)
                    count++
src/main/resources/application.yml
@@ -7,9 +7,9 @@
#    password: cn.FLIGHTFEATHER
#    çº¿ä¸ŠæœåС噍
    url: jdbc:mysql://localhost:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false
    username: dronemonitor
    password: dronemonitor_hackxrnomxm
#    url: jdbc:mysql://localhost:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false
#    username: dronemonitor
#    password: dronemonitor_hackxrnomxm
#    å¼€å‘本地服务器
#    url: jdbc:mysql://localhost:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false
@@ -17,9 +17,9 @@
#    password: 123456
#   å¼€å‘远程服务器
#    url: jdbc:mysql://47.100.191.150:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false
#    username: remoteU1
#    password: eSoF8DnzfGTlhAjE
    url: jdbc:mysql://47.100.191.150:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false
    username: remoteU1
    password: eSoF8DnzfGTlhAjE
    hikari:
      maximum-pool-size: 500
      minimum-idle: 20
src/main/resources/generator/generatorConfig.xml
@@ -48,7 +48,7 @@
<!--        <table tableName="air_real_time_data" domainObjectName="RealTimeData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="mission" domainObjectName="Mission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="el_minutevalue" domainObjectName="ElectricMinuteValue" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="el_company_device" domainObjectName="CompanyDevice" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
        <table tableName="el_company_device" domainObjectName="CompanyDevice" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
<!--        <table tableName="co_complaint" domainObjectName="Complaint" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="co_assessment" domainObjectName="Assessment" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="real_time_data_grid" domainObjectName="RealTimeDataGrid" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
@@ -56,6 +56,6 @@
<!--        <table tableName="real_time_data_vehicle" domainObjectName="RealTimeDataVehicle" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="device_info" domainObjectName="DeviceInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="factor_calibration" domainObjectName="FactorCalibration" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
        <table tableName="real_time_data_grid_min" domainObjectName="RealTimeDataGridMin" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
<!--        <table tableName="real_time_data_grid_min" domainObjectName="RealTimeDataGridMin" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
    </context>
</generatorConfiguration>
src/main/resources/mapper/CompanyDeviceMapper.xml
@@ -8,11 +8,17 @@
    <id column="CD_Id" jdbcType="INTEGER" property="cdId" />
    <result column="CD_Company_Id" jdbcType="VARCHAR" property="cdCompanyId" />
    <result column="CD_Device_Code" jdbcType="VARCHAR" property="cdDeviceCode" />
    <result column="CD_Type" jdbcType="INTEGER" property="cdType" />
    <result column="CD_Type_Name" jdbcType="VARCHAR" property="cdTypeName" />
    <result column="CD_Limits" jdbcType="VARCHAR" property="cdLimits" />
    <result column="CD_Status" jdbcType="VARCHAR" property="cdStatus" />
    <result column="CD_Status_Name" jdbcType="VARCHAR" property="cdStatusName" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
    -->
    CD_Id, CD_Company_Id, CD_Device_Code
    CD_Id, CD_Company_Id, CD_Device_Code, CD_Type, CD_Type_Name, CD_Limits, CD_Status,
    CD_Status_Name
  </sql>
</mapper>