From da431c25dfe5122e4ed70372da36ede3e4eaec4a Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期五, 31 五月 2024 17:43:41 +0800 Subject: [PATCH] 1. 新增自动报告生成功能 --- src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricDailyInfo.kt | 171 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 149 insertions(+), 22 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricDailyInfo.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricDailyInfo.kt index bd11107..9bef607 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricDailyInfo.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricDailyInfo.kt @@ -1,8 +1,12 @@ package com.flightfeather.uav.lightshare.bean +import com.flightfeather.uav.common.utils.DateUtil import com.flightfeather.uav.domain.entity.CompanyDevice +import com.flightfeather.uav.domain.entity.ElectricMinuteValue +import com.flightfeather.uav.lightshare.eunm.ElectricityStatus import com.flightfeather.uav.lightshare.eunm.ElectricityType import java.util.* +import kotlin.math.round /** * 鐢ㄧ數閲忔棩鍒嗘瀽缁撴灉 @@ -10,27 +14,37 @@ * Created by feiyu */ class ElectricDailyInfo { - var day: String = "" + var day = "" + var dayIndex = 0 /***********浜х嚎璁惧ProductionLine, pl************/ - private var plDCode: String? = null // 璁惧缂栧彿 + var plDCode: String? = null // 璁惧缂栧彿 private var plSTime: Date? = null // 寮�鍚椂闂� private var plRTime: Date? = null // 姝e紡杩愯鏃堕棿 private var plETime: Date? = null // 鍏抽棴鏃堕棿 - // FIXME: 2021/12/1 锛堢姸鎬佷负杩愯銆侀珮璐熻嵎鐨勬椂闀匡級 - private var plRunTime: Int = 0 // 杩愯鏃堕暱锛堝垎閽燂級 + var plRunTime: Int = 0 // 杩愯鏃堕暱锛堝垎閽燂級锛堢姸鎬佷负杩愯銆侀珮璐熻嵎鐨勬椂闀匡級 private var plRunPeriod = mutableListOf<Int>()// 杩愯鏃舵锛堝皬鏃讹級 + var plPower = .0 // 鐢ㄧ數閲忥紙鍗冪摝鏃讹級 /***********鍑�鍖栬澶嘝urify, pf********************/ - private var pfDCode: String? = null + var pfDCode: String? = null private var pfSTime: Date? = null private var pfRTime: Date? = null private var pfETime: Date? = null - private var pfRunTime: Int = 0 + var pfRunTime: Int = 0 private var pfRunPeriod = mutableListOf<Int>() + var pfPower = .0 - // TODO: 2021/12/1 姝e紡杩愯鏃堕棿宸� - // TODO: 2021/12/1 鍏抽棴鏃堕棿宸� - private var dailyResult: String = ""// 褰撴棩鍒嗘瀽缁撴灉鎻忚堪 + var plRTimeStr: String? = null + var plETimeStr: String? = null + var pfRTimeStr: String? = null + var pfETimeStr: String? = null + var rTimeDiff:Int? = 0 //姝e紡杩愯鏃堕棿宸� + 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 @@ -57,10 +71,85 @@ } } - fun setEndTime(date: Date) { + private var lastPlStatus = -2 // 涓婁釜鏃堕棿鐐圭殑浜х嚎璁惧鐘舵�� + private var plTag = false // true锛氬綋鏃ユ渶鍚庝竴鍒嗛挓鐨勬暟鎹緷鏃ф槸杩愯鐘舵�侊紝鏈叧闂骇绾胯澶� + private var lastPfStatus = -2 // 涓婁釜鏃堕棿鐐圭殑鍑�鍖栬澶囩姸鎬� + private var pfTag = false + fun setEndTime(s: Triple<String, String, Double>, e:ElectricMinuteValue?) { + val hourMinute = DateUtil.instance.dateToString(e?.mvDataTime, DateUtil.DateStyle.HH_MM) when (deviceType) { - ElectricityType.ProductionLine -> plETime = date - ElectricityType.Purify -> pfETime = date + ElectricityType.ProductionLine -> { + if (lastPlStatus == -1) { + return + } else if (lastPlStatus <= ElectricityStatus.A.value) { + lastPlStatus = s.first.toInt() + } else if (lastPlStatus >= ElectricityStatus.B.value) { + if (s.first.toInt() <= ElectricityStatus.A.value) { + plETime = e?.mvDataTime + lastPlStatus = -1 + } else { + if (hourMinute == "23:59") plTag = true + lastPlStatus = s.first.toInt() + } + } + } + ElectricityType.Purify -> { + if (lastPfStatus == -1) { + return + } else if (lastPfStatus <= ElectricityStatus.A.value) { + lastPfStatus = s.first.toInt() + } else if (lastPfStatus >= ElectricityStatus.B.value) { + if (s.first.toInt() <= ElectricityStatus.A.value) { + pfETime = e?.mvDataTime + lastPfStatus = -1 + } else { + if (hourMinute == "23:59") pfTag = true + lastPfStatus = s.first.toInt() + } + } + } + else -> Unit + } + } + + /** + * 濡傛灉璁惧鍏抽棴鏃舵槸鐩存帴浠庤繍琛岀姸鎬佹柇鐢碉紝鍒欏湪姝ゅ灏嗘渶鍚庝竴涓暟鎹殑鏃堕棿璁颁负鍏抽棴鏃堕棿 + */ + fun setEndTime2(date: Date) { + when (deviceType) { + ElectricityType.ProductionLine -> { + if (plETime == null && !plTag) { + plETime = date + } + } + ElectricityType.Purify -> { + if (pfETime == null && !pfTag) { + pfETime = date + } + } + else -> Unit + } + } + + /** + * 璁剧疆姝e紡杩愯鏃堕棿 + */ + fun setRunningTime(s: Triple<String, String, Double>, e:ElectricMinuteValue?) { + when (deviceType) { + ElectricityType.ProductionLine -> { + if (plRTime == null) { + if (s.first.toInt() >= ElectricityStatus.C.value) { + plRTime = e?.mvDataTime + } + } + } + ElectricityType.Purify -> { + if (pfRTime == null) { + if (s.first.toInt() >= ElectricityStatus.C.value) { + pfRTime = e?.mvDataTime + } + } + } else -> Unit } } @@ -68,11 +157,13 @@ /** * 澧炲姞杩愯鏃堕暱 */ - fun addRunTime(min: Int) { - when (deviceType) { - ElectricityType.ProductionLine -> plRunTime += min - ElectricityType.Purify -> pfRunTime += min - else -> Unit + fun addRunTime(s: Triple<String, String, Double>) { + if (s.first.toInt() >= ElectricityStatus.C.value) { + when (deviceType) { + ElectricityType.ProductionLine -> plRunTime++ + ElectricityType.Purify -> pfRunTime++ + else -> Unit + } } } @@ -88,15 +179,51 @@ } /** + * 绱鐢ㄧ數閲� + */ + fun addPower(e: ElectricMinuteValue?) { + e?.let { + val avgElectric = (it.mvElectricityA + it.mvElectricityB + it.mvElectricityC) / 3 + val power = avgElectric * 1 / 60 + when (deviceType) { + ElectricityType.ProductionLine -> plPower += power + ElectricityType.Purify -> pfPower += power + else -> Unit + } + } + } + + /** * 缁熻寰楀嚭褰撴棩鍒嗘瀽缁撴灉 */ fun getResult() { - // 1. 璁惧寮�鍚叧闂槸鍚﹀悎瑙� + // 鐢ㄧ數閲� + plPower = round(plPower * 100) / 100 - // TODO: 2021/12/1 1. 璁惧姝e紡杩愯鏃堕棿宸� =銆嬪紑鍚槸鍚﹀悎瑙� - // TODO: 2021/12/1 2锛岃澶囧叧闂椂闂村樊 =銆嬪叧闂槸鍚﹀悎瑙� - // TODO: 2021/12/1 3. 杩愯鏃堕暱宸� =銆嬭繍琛岃繃绋嬫槸鍚﹀悎瑙� - // TODO: 2021/12/1 4. 缁煎悎鍒ゆ柇缁撴灉 + pfPower = round(pfPower * 100) / 100 + // 寮�鍏虫椂闂存牸寮忓寲 + plRTimeStr = DateUtil.instance.dateToString(plRTime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS) + plETimeStr = DateUtil.instance.dateToString(plETime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS) + pfRTimeStr = DateUtil.instance.dateToString(pfRTime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS) + pfETimeStr = DateUtil.instance.dateToString(pfETime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS) + + // 1. 璁惧姝e紡杩愯鏃堕棿宸� =銆嬪紑鍚槸鍚﹀悎瑙� + if (pfRTime != null && plRTime != null) { + rTimeDiff = ((pfRTime!!.time - plRTime!!.time) / 1000 / 60).toInt() + sResult = rTimeDiff == null || rTimeDiff!! < 0 + } + // 2锛岃澶囧叧闂椂闂村樊 =銆嬪叧闂槸鍚﹀悎瑙� + if (pfETime != null && plETime != null) { + eTimeDiff = ((pfETime!!.time - plETime!!.time) / 1000 / 60).toInt() + eResult = eTimeDiff == null || eTimeDiff!! > 0 + } else { + // 褰撳叧闂椂闂村瓨鍦╪ull鏃讹紝璇存槑褰撴棩骞舵病鏈夊叧闂澶囷紝鍏抽棴鍚堣 + eTimeDiff = null + eResult = true + } + // 3. 杩愯鏃堕暱宸� =銆嬭繍琛岃繃绋嬫槸鍚﹀悎瑙� + runningTimeDiff = pfRunTime - plRunTime + rResult = runningTimeDiff > 0 // TODO: 2021/12/1 5. 澶氭棩鎽樿缁熻锛岃繍琛屽ぉ鏁般�佸悎瑙勫ぉ鏁扮瓑 } -- Gitblit v1.9.3