From 2ae8bf126599f68ba1ca721ff2acc1dd4461e9a5 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 12 九月 2023 11:05:47 +0800 Subject: [PATCH] 1. 整合了飞羽环境、徐汇油烟及金山扬尘两个数据库; 2. 优化重构自动评估模块逻辑; 3. 新增监测数据自动化统; 4. 将自动统计应用于自动评估中; --- src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt | 77 ++++++++++++++++++++++++++++++-------- 1 files changed, 60 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt index da0703a..350740f 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt @@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component import tk.mybatis.mapper.entity.Example +import java.time.Duration import java.time.LocalDateTime import java.time.ZoneId import javax.annotation.PostConstruct @@ -38,21 +39,22 @@ val rowData = RowData() init { - if (config.districtCode == null) { - throw IllegalStateException("鍙傛暟缂哄皯鍖哄幙缂栫爜:[districtCode]") - } - if (config.sceneType == null) { - throw IllegalStateException("鍙傛暟缂哄皯鍦烘櫙绫诲瀷:[sceneType]") - } +// if (config.districtCode == null) { +// throw IllegalStateException("鍙傛暟缂哄皯鍖哄幙缂栫爜:[districtCode]") +// } +// if (config.sceneType == null) { +// throw IllegalStateException("鍙傛暟缂哄皯鍦烘櫙绫诲瀷:[sceneType]") +// } getSource(config) } fun loop(callback: (index:Int, rowData: RowData) -> Unit) { - reset() +// reset() for (i in sourceList.indices) { +// rowData.recordLastScene() rowData.index = i - rowData.clear() rowData.subTask = sourceList[i] + rowData.clear() callback(i, rowData) } } @@ -75,10 +77,10 @@ } /** - * 鑾峰彇鎶ュ憡鏁版嵁婧� + * 鑾峰彇鎶ュ憡鏁版嵁婧愶紙宸℃煡浠诲姟锛� */ private fun getSource(config: ExcelConfigVo) { - if (config.sceneType == null) return +// if (config.sceneType == null) return val result = mutableListOf<Subtask>() @@ -107,6 +109,8 @@ } config.startTime?.let { andGreaterThanOrEqualTo("planstarttime", it) } config.endTime?.let { andLessThanOrEqualTo("planendtime", it) } + config.districtCode?.let { andEqualTo("districtcode", it) } +// andEqualTo("tguid", config.topTaskGuid) } }) } else { @@ -123,11 +127,12 @@ for (s in subTaskList) { if (s.scenseid == it) { subtask = s - break + result.add(s) } } - if (subtask == null) subtask = Subtask().apply { scenseid = it } - result.add(subtask) + if (subtask == null) { + result.add(Subtask().apply { scenseid = it }) + } } } else { result.addAll(subTaskList) @@ -141,6 +146,8 @@ var index = 0 var subTask: Subtask? = null + + private var lastScene: Scense? = null //鍦烘櫙鍩烘湰淇℃伅 val scene: Scense? @@ -191,6 +198,7 @@ } private var _problems = mutableListOf<Problemlist>() + //璇勪及鎬诲垎 val evaluation: Evaluation? get() { if (_evaluation == null) { @@ -204,6 +212,7 @@ } private var _evaluation: Evaluation? = null + //璇勪及缁嗗垯寰楀垎 val itemevaluationList: MutableList<Itemevaluation> get() { if (_itemevaluationList.isEmpty()) { @@ -222,8 +231,8 @@ get() { if (_problemTypes.isEmpty()) { val r = dbMapper.problemtypeMapper.selectByExample(Example(Problemtype::class.java).apply { - createCriteria().andEqualTo("scensetypeid", config.sceneType) - .andEqualTo("districtcode", config.districtCode) + createCriteria().andEqualTo("scensetypeid", scene?.typeid) + .andEqualTo("districtcode", scene?.districtcode) orderBy("extension1") }) _problemTypes.addAll(r) @@ -239,7 +248,7 @@ val rule = dbMapper.evaluationruleMapper.selectByExample(Example(Evaluationrule::class.java).apply { createCriteria() .andEqualTo("tasktypeid", 99) - .andEqualTo("scensetypeid", config.sceneType) + .andEqualTo("scensetypeid", scene?.typeid) }) if (rule.isNotEmpty()) { val ruleId = rule[0].guid @@ -298,7 +307,7 @@ val ledgerCount: Int get() { if (_ledgerCount == -1) { - val tzSceneType = Constant.ScenseType.typeMap(config.sceneType?.toByte()) + val tzSceneType = Constant.ScenseType.typeMap(scene?.typeid) _ledgerCount = dbMapper.ledgerSubTypeMapper.selectCountByExample(Example(LedgerSubType::class.java).apply { createCriteria().andEqualTo("lScenetype", tzSceneType).andEqualTo("lNeedupdate", true) }) @@ -332,6 +341,33 @@ private var _ledgerRecordNum: List<LedgerRecord>? = null /** + * 鑾峰彇褰撳墠宸℃煡浠诲姟鐨勪笂鏈熷贰鏌ヨ褰� + */ + fun lastOne(): RowData { + val last = RowData() + val r = dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply { + createCriteria().andEqualTo("scenseid", subTask?.scenseid) + .andLessThan("planstarttime", subTask?.planstarttime) + orderBy("planstarttime").desc() + }) + if (r.isNotEmpty()) { + val thisMonth = LocalDateTime.ofInstant(subTask?.planstarttime?.toInstant(), ZoneId.systemDefault()).withDayOfMonth(1).toLocalDate() + val lastMonth = LocalDateTime.ofInstant(r[0]?.planstarttime?.toInstant(), ZoneId.systemDefault()).withDayOfMonth(1).toLocalDate() + if (lastMonth.plusMonths(1).isEqual(thisMonth)) { + last.subTask = r[0] + } + } + return last + } + + /** + * 璁板綍涓婁竴涓満鏅� + */ + fun recordLastScene() { + lastScene = scene + } + + /** * 娓呯┖褰撳墠澶勭悊鐨勫璞$殑鐩稿叧鏁版嵁婧� */ fun clear() { @@ -341,6 +377,13 @@ _evaluation = null _itemevaluationList.clear() _ledgerRecordNum = null + if (lastScene != null && lastScene?.typeid != scene?.typeid) { + _problemTypes.clear() + _topItems.clear() + _rules.clear() + _ledgerCount = -1 + } + recordLastScene() } /** -- Gitblit v1.9.3