riku
2021-12-03 e99f1cd836475a059ed6fdcbd4235416ba108dd1
1. 新增用电量日分析功能
已修改7个文件
34 ■■■■■ 文件已修改
src/main/kotlin/com/flightfeather/uav/dataprocess/ElectricDailyAnalysis.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricDailyInfo.kt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/ElectricityService.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ElectricityServiceImpl.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/ElectricityController.kt 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/ElectricityServiceImplTest.kt 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/dataprocess/ElectricDailyAnalysis.kt
@@ -63,9 +63,9 @@
        dataMap.forEach { (dCode, dayMap) ->
            dayMap.forEach { (day, list) ->
                dailyInfoMap[day]?.apply {
                    changeType(deviceMap[dCode])
                    setEndTime(list.last().mvDataTime)
                    getResult()
                }
            }
        }
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricDailyInfo.kt
@@ -125,15 +125,16 @@
        // TODO: 2021/12/1 1. 设备正式运行时间差 =》开启是否合规
        if (pfRTime != null && plRTime != null) {
            rTimeDiff = ((pfRTime!!.time - plRTime!!.time) / 1000 / 60).toInt()
            sResult = rTimeDiff > 0
            sResult = rTimeDiff < 0
        }
        // TODO: 2021/12/1 2,设备关闭时间差 =》关闭是否合规
        if (pfETime != null && plETime != null) {
            eTimeDiff = ((pfETime!!.time - plETime!!.time) / 1000 / 60).toInt()
            eResult = eTimeDiff > 0
        }
        // TODO: 2021/12/1 3. 运行时长差 =》运行过程是否合规
        runningTimeDiff = pfRunTime - plRunTime
        // TODO: 2021/12/1 4. 综合判断结果
        rResult = runningTimeDiff > 0
        // TODO: 2021/12/1 5. 多日摘要统计,运行天数、合规天数等
    }
src/main/kotlin/com/flightfeather/uav/lightshare/service/ElectricityService.kt
@@ -22,5 +22,5 @@
    /**
     * 企业用电量日统计信息
     */
    fun dailyStatistics(cId: String, startTime: String?, endTime: String?): BaseResponse<List<ElectricDailyInfo>>
    fun dailyAnalysis(cId: String, startTime: String?, endTime: String?): BaseResponse<List<ElectricDailyInfo>>
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ElectricityServiceImpl.kt
@@ -276,7 +276,7 @@
        return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages), data = result)
    }
    override fun dailyStatistics(cId: String, startTime: String?, endTime: String?): BaseResponse<List<ElectricDailyInfo>> {
    override fun dailyAnalysis(cId: String, startTime: String?, endTime: String?): BaseResponse<List<ElectricDailyInfo>> {
        // 根据企业id获取对应设备
        val devices = companyDeviceMapper.selectByExample(Example(CompanyDevice::class.java).apply {
            createCriteria().andEqualTo("cdCompanyId", cId)
src/main/kotlin/com/flightfeather/uav/lightshare/web/ElectricityController.kt
@@ -49,4 +49,12 @@
        @RequestParam(value = "page", required = false) page: Int?,
        @RequestParam(value = "perPage", required = false) perPage: Int?
    ) = electricityService.getElectricityInfo(cId, startTime, endTime, page, perPage)
    @ApiOperation(value = "企业用电量日分析")
    @GetMapping("/analysis/daily")
    fun dailyStatistics(
        @ApiParam("企业id") @RequestParam(value = "cId") cId: String,
        @ApiParam(value = "开始时间", example = "yyyy-MM-dd HH:mm:ss") @RequestParam(value = "startTime", required = false) startTime: String?,
        @ApiParam(value = "结束时间", example = "yyyy-MM-dd HH:mm:ss") @RequestParam(value = "endTime", required = false) endTime: String?,
    ) = electricityService.dailyAnalysis(cId, startTime, endTime)
}
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/test/kotlin/com/flightfeather/uav/lightshare/service/impl/ElectricityServiceImplTest.kt
@@ -3,7 +3,6 @@
import com.flightfeather.uav.lightshare.service.ElectricityService
import org.junit.Test
import org.junit.Assert.*
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
@@ -22,7 +21,7 @@
    @Test
    fun dailyStatistics() {
        val r = electricityService.dailyStatistics("J3euwNl19WZvH7iE", "2021-07-16 00:00:00", "2021-07-16 00:00:00")
        val r = electricityService.dailyAnalysis("J3euwNl19WZvH7iE", "2021-07-16 00:00:00", "2021-07-16 00:00:00")
        println(r)
    }
}