From c1becf4cbd2e99601ce011c14b8742427249cfb4 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 09 一月 2024 17:25:05 +0800 Subject: [PATCH] 1. 多项调整 --- src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/restaurant/ReScoreItem5.kt | 118 ++++++++++++++++++++++++++++++++++------------------------- 1 files changed, 68 insertions(+), 50 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/restaurant/ReScoreItem5.kt b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/restaurant/ReScoreItem5.kt index 688df3e..9200e28 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/restaurant/ReScoreItem5.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/restaurant/ReScoreItem5.kt @@ -1,18 +1,23 @@ package cn.flightfeather.supervision.business.autooutput.score.restaurant +import cn.flightfeather.supervision.business.autooutput.dataanalysis.XHFuDataAnalysis import cn.flightfeather.supervision.business.autooutput.score.ScoreItem import cn.flightfeather.supervision.domain.ds1.entity.DustDataResult import cn.flightfeather.supervision.domain.ds1.entity.Evaluationsubrule2 import cn.flightfeather.supervision.domain.ds1.mapper.DustDataResultMapper +import cn.flightfeather.supervision.domain.ds3.entity.FumeDailyAnalysis +import cn.flightfeather.supervision.domain.ds3.entity.FumeExceptionData +import cn.flightfeather.supervision.domain.ds3.mapper.FumeDailyAnalysisMapper import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component import tk.mybatis.mapper.entity.Example import java.time.LocalDateTime import java.time.ZoneId +import java.util.* import javax.annotation.PostConstruct @Component -class ReScoreItem5: ScoreItem() { +class ReScoreItem5(private val xhFuDataAnalysis: XHFuDataAnalysis) : ScoreItem() { companion object { private lateinit var instance: ReScoreItem5 } @@ -24,7 +29,7 @@ override var id: String = "PSQUi9f0f7JK6w9d" - override var name: String="娌圭儫鍦ㄧ嚎鐩戞祴鏁版嵁閲忕骇" + override var name: String = "娌圭儫鍦ㄧ嚎鐩戞祴鏁版嵁閲忕骇" @Autowired lateinit var dustDataResultMapper: DustDataResultMapper @@ -32,67 +37,80 @@ /** * 寰愭眹鍖洪楗洃绠″钩鍙拌仈缃戣褰曘�佸湪绾跨巼鍒嗘瀽鏁版嵁鍜岄珮宄扮粡钀ユ椂娈靛皬鏃惰秴鏍囨儏鍐� * 閫夐」濡備笅锛� - * 1.鏁版嵁鏃犲紓甯镐笖鏃犺秴鏍囨垨鏄剧ず鍑�鍖栬缃竻娲� - * 2.楂樺嘲缁忚惀鏃舵鏁版嵁鍦ㄧ嚎鐜囦綆浜�90%鎴栨樉绀哄噣鍖栬缃晠闅� - * 3.褰撴湀楂樺嘲缁忚惀鏃舵鍑虹幇涓夋鍙婁互涓�10鍒嗛挓鍧囧�艰秴鏍囨垨鏄剧ず鍑�鍖栬缃緝鑴� - * 4.褰撴湀楂樺嘲缁忚惀鏃舵鏁版嵁鎸佺画寮傚父鎴栧嚭鐜颁笁娆″強浠ヤ笂灏忔椂鏁版嵁瓒呮爣鎴栨棤娌圭儫鍑�鍖栬缃垨鍑�鍖栬缃湭姝e父寮�鍚� + * 1.鏁版嵁鏃犲紓甯镐笖鏃犺秴鏍囨垨鏄剧ず鍑�鍖栬缃竻娲侊紙涓嶆墸鍒嗭級 + * 2.褰撴湀瀛樺湪鏃ラ珮宄扮粡钀ユ椂娈垫暟鎹湪绾跨巼浣庝簬90%涓斿嚭鐜�3鏃ュ強浠ヤ笂锛堟墸5鍒嗭級 + * 3.褰撴湀瀛樺湪鏃ラ珮宄扮粡钀ユ椂娈佃繛缁笁娆″強浠ヤ笂10鍒嗛挓鍧囧�艰秴鏍囦笖鍑虹幇2鏃ュ強浠ュ唴鐨勬垨鏄剧ず鍑�鍖栬缃緝鑴忥紙鎵�5鍒嗭級 + * 4.褰撴湀瀛樺湪鏃ラ珮宄扮粡钀ユ椂娈佃繛缁笁娆″強浠ヤ笂10鍒嗛挓鍧囧�艰秴鏍囦笖鍑虹幇3鏃ュ強浠ヤ笂鐨勬垨鏃犳补鐑熷噣鍖栬缃垨鍑�鍖栬缃湭姝e父寮�鍚垨鏄剧ず鍑�鍖栬缃晠闅滐紙鎵�10鍒嗭級 */ - override fun otherProblem(size: Int): Int? { - var i = 1 - when { - condition1() -> { - if (i > size - 1) i = size - 1 - return i - } - condition2() -> { - i = 2 - if (i > size - 1) i = size - 1 - return i - } - condition3() -> { - i = 3 - if (i > size - 1) i = size - 1 - return i - } - else -> return null - } - } + override fun otherProblem(size: Int): List<Int>? { + val result = mutableListOf<Int>() - /** - * @return true 楂樺嘲缁忚惀鏃舵鏁版嵁鍦ㄧ嚎鐜囦綆浜�90%鎴栨樉绀哄噣鍖栬缃晠闅� - */ - private fun condition1(): Boolean { - return false - } - - /** - * @return true 褰撴湀楂樺嘲缁忚惀鏃舵鍑虹幇涓夋鍙婁互涓�10鍒嗛挓鍧囧�艰秴鏍囨垨鏄剧ず鍑�鍖栬缃緝鑴� - */ - private fun condition2(): Boolean { val time = evaluationScene.subTask.value?.planstarttime val lt = LocalDateTime.ofInstant(time?.toInstant(), ZoneId.systemDefault()) val st = lt.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0) val et = st.plusMonths(1) - val r = dustDataResultMapper.selectByExample(Example(DustDataResult::class.java).apply { - createCriteria().andGreaterThanOrEqualTo("drTime", st) - .andLessThan("drTime", et) - .andEqualTo("drSceneId", evaluationScene.scene.value?.guid) - }) + evaluationScene.config?.startTime = Date.from(st.atZone(ZoneId.systemDefault()).toInstant()) + evaluationScene.config?.endTime = Date.from(et.atZone(ZoneId.systemDefault()).toInstant()) + val dailyAnalysisDataList = xhFuDataAnalysis.fetchDataResources(evaluationScene) + val exceptionDataList = xhFuDataAnalysis.fetchExceptionData(evaluationScene) - var result = false - r.forEach { - if (it == null) return@forEach - if (it.drExceedTimes >= 3) { - result = true + var count = 0 + dailyAnalysisDataList.forEach { it.forEach dList@ {f -> + val keyOnlineRate = f?.keyOnlineRate?.split("%")?.get(0)?.toDouble() ?: return@dList + if (keyOnlineRate < 0.9) { + count++ + } + } } + + if (count >= 3) { + result.add(1) + } + + val dayList = mutableListOf<Int>() + exceptionDataList.forEach { + // 涓嶅湪楂樺嘲鏃舵鐨勫紓甯告暟鎹笉浣滀负鍒ゆ柇渚濇嵁 + if (!peakPeriod(it)) return@forEach + // 寮傚父鏃堕暱澶т簬绛変簬20鍒嗛挓锛岃〃绀轰笁涓椂闂寸偣鐨勬暟鎹紓甯� + if ((it?.endTime?.time?.minus(it.beginTime.time) ?: 0) >= (20 * 60 * 1000)) { + val cal = Calendar.getInstance() + cal.time = it!!.beginTime + val date = cal.get(Calendar.DAY_OF_MONTH) + if (!dayList.contains(date)) { + dayList.add(date) + } } } + //鏃ラ珮宄扮粡钀ユ椂娈佃繛缁笁娆″強浠ヤ笂10鍒嗛挓鍧囧�艰秴鏍囦笖鍑虹幇3鏃ュ強浠ヤ笂 + if (dayList.size >= 3) { + result.add(3) + } + //鏃ラ珮宄扮粡钀ユ椂娈佃繛缁笁娆″強浠ヤ笂10鍒嗛挓鍧囧�艰秴鏍囦笖鍑虹幇2鏃ュ強浠ュ唴 + else if (dayList.size > 0) { + result.add(2) + } + return result } /** - * @return true 褰撴湀楂樺嘲缁忚惀鏃舵鏁版嵁鎸佺画寮傚父鎴栧嚭鐜颁笁娆″強浠ヤ笂灏忔椂鏁版嵁瓒呮爣鎴栨棤娌圭儫鍑�鍖栬缃垨鍑�鍖栬缃湭姝e父寮�鍚� + * 鍒ゆ柇寮傚父鏄惁澶勪簬楂樺嘲鏃舵 */ - private fun condition3(): Boolean { - return false + private fun peakPeriod(data: FumeExceptionData?): Boolean { + if (data == null) return false + val today = LocalDateTime.ofInstant(data.beginTime.toInstant(), ZoneId.systemDefault()) + val noonP1 = today.withHour(9).withMinute(59).withSecond(59) + val noonP2 = today.withHour(14).withMinute(0).withSecond(0) + val nightP1 = today.withHour(16).withMinute(59).withSecond(59) + val nightP2 = today.withHour(21).withMinute(0).withSecond(0) + val beginTime = LocalDateTime.ofInstant(data.beginTime.toInstant(), ZoneId.systemDefault()) + val endTime = LocalDateTime.ofInstant(data.endTime.toInstant(), ZoneId.systemDefault()) + val b1 = + (beginTime.isAfter(noonP1) && beginTime.isBefore(noonP2)) || (beginTime.isAfter(nightP1) && beginTime.isBefore( + nightP2)) + val b2 = (endTime.isAfter(noonP1) && endTime.isBefore(noonP2)) || (endTime.isAfter(nightP1) && endTime.isBefore( + nightP2)) + + return b1 || b2 } + } \ No newline at end of file -- Gitblit v1.9.3