From a700aeb0a07d11da1e6b2ae999983ba17a415c70 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期三, 30 七月 2025 16:02:04 +0800 Subject: [PATCH] 2025.7.30 1. 新增基础数据产品相关接口(待完成) --- src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt | 145 +++++++++++++++++++++++++++++++++++++----------- 1 files changed, 111 insertions(+), 34 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt index 80d462f..e8f9e4e 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt @@ -1,11 +1,15 @@ package cn.flightfeather.supervision.business.autooutput.datasource +import cn.flightfeather.supervision.common.exception.BizException import cn.flightfeather.supervision.common.utils.Constant import cn.flightfeather.supervision.domain.ds1.entity.* import cn.flightfeather.supervision.domain.ds2.entity.LedgerRecord import cn.flightfeather.supervision.domain.ds2.entity.LedgerSubType import cn.flightfeather.supervision.domain.ds2.entity.UserMap import cn.flightfeather.supervision.domain.ds2.entity.UserinfoTZ +import cn.flightfeather.supervision.lightshare.vo.AreaVo +import cn.flightfeather.supervision.lightshare.vo.EvaluationSubRuleVo +import org.springframework.beans.BeanUtils import tk.mybatis.mapper.entity.Example import java.time.LocalDateTime import java.time.ZoneId @@ -36,6 +40,12 @@ } } +// fun setResource(areaVo: AreaVo) { +// val task = taskRep.findOneTask(areaVo) +// val taskId = task?.tguid +// val sceneType = areaVo.scensetypeid?.toInt() ?: throw BizException("鍦烘櫙绫诲瀷鏈缃紝鏃犳硶璇勪及") +// } + fun setResource(config: AopDataConfig) { config.sceneType ?: return evaluationScene.config = config @@ -47,10 +57,49 @@ } } + fun setResource(subtask: Subtask) { + val scene = aopDbMapper.scenseMapper.selectByPrimaryKey(subtask.scenseid) + val sceneType = scene.typeid?.toInt() + val config = AopDataConfig(topTaskGuid = subtask.tguid, sceneType = sceneType, + districtName = subtask.districtname, townCode = subtask.towncode) + evaluationScene.config = config +// val check = aopSceneTypeCheck.checkSceneType(sceneType) + this.mode = 0 + sceneSourceList.clear() + sceneSourceList.add(scene) + } + /** * 杞鏁版嵁婧� */ fun loop(callback: (index:Int, evaluationScene: EvaluationScene) -> Unit) { + when (mode) { + 0 -> { + sceneSourceList.forEachIndexed { i, scene -> + evaluationScene.clear() + evaluationScene.index = i + evaluationScene.setDefaultScene(scene) + do { + callback(i, evaluationScene) + } while (evaluationScene.gotoNextSubTask()) + } + } + 1 -> { + userSourceList.forEachIndexed { i, user -> + evaluationScene.clear() + evaluationScene.index = i + evaluationScene.setDefaultUserTZ(user) + callback(i, evaluationScene) + } + } + } + } + + /** + * 鏍规嵁瀛愪换鍔″彧杞涓�娆� + * 褰撴暟鎹簮鏄�氳繃[setResource]浼犲叆[Subtask]鏃跺喅瀹氭椂 + */ + fun runBySubTask(callback: (index: Int, evaluationScene: EvaluationScene) -> Unit) { when (mode) { 0 -> { sceneSourceList.forEachIndexed { i, scene -> @@ -73,23 +122,16 @@ // 浠庣洃绠$郴缁熻幏鍙栧満鏅� private fun initSceneSource(config: AopDataConfig) { - config.topTaskGuid ?: throw IllegalStateException("椤跺眰浠诲姟id涓嶈兘涓簄ull") + config.topTaskGuid ?: throw BizException("椤跺眰浠诲姟id涓嶈兘涓簄ull") this.config = config this.mode = 0 sceneSourceList.clear() val taskSceneIdList = - aopDbMapper.monitorobjectversionMapper.getSceneByType(config.topTaskGuid, config.sceneType, config.townCode) - - aopDbMapper.scenseMapper.selectByExample(Example(Scense::class.java).apply { - createCriteria() - .andIn("guid", taskSceneIdList) -// .andEqualTo("provincecode", config.provinceCode) -// .andEqualTo("citycode", config.cityCode) -// .andEqualTo("districtcode", config.districtCode) -// .andEqualTo("towncode", config.townCode) -// .andEqualTo("typeid", config.sceneType) -// .andNotEqualTo("extension1", '0') - })?.let { sceneSourceList.addAll(it) } + aopDbMapper.scenseMapper.getSceneByType(config.topTaskGuid, config.sceneType, config.townCode) + taskSceneIdList.forEach { + println(it.name) + } + sceneSourceList.addAll(taskSceneIdList) } // 浠庡彴璐︾郴缁熻幏鍙栧満鏅� @@ -147,12 +189,21 @@ }) } //宸℃煡浠诲姟淇℃伅 + var subTaskIndex = 0 val subTask = InfoProxy<Subtask> {_,_ -> + return@InfoProxy if (subTaskList.value?.isNotEmpty() == true) { + subTaskList.value?.get(subTaskIndex) + } else { + null + } + } + + val subTaskList = InfoProxy<List<Subtask>> {_,_ -> return@InfoProxy aopDbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply { createCriteria().andEqualTo("scenseid", scene.value?.guid) // .andBetween("planstarttime", config?.startTime, config?.endTime) .andEqualTo("tguid", config?.topTaskGuid) - })?.takeIf { it.isNotEmpty() }?.get(0) + }) } //鐜板満宸℃煡淇℃伅 @@ -166,23 +217,23 @@ val baseScene = InfoProxy<BaseScene> {_,_ -> return@InfoProxy when (config?.sceneType.toString()) { // 鐩戠绯荤粺 - Constant.ScenseType.TYPE1.value -> { + Constant.SceneType.TYPE1.value -> { aopDbMapper.sceneConstructionSiteMapper.selectByPrimaryKey(scene.value?.guid) } - Constant.ScenseType.TYPE2.value -> { + Constant.SceneType.TYPE2.value -> { aopDbMapper.sceneWharfMapper.selectByPrimaryKey(scene.value?.guid) } - Constant.ScenseType.TYPE3.value -> { + Constant.SceneType.TYPE3.value -> { aopDbMapper.sceneMixingPlantMapper.selectByPrimaryKey(scene.value?.guid) } - Constant.ScenseType.TYPE14.value -> { + Constant.SceneType.TYPE14.value -> { aopDbMapper.sceneStorageYardMapper.selectByPrimaryKey(scene.value?.guid) } // 鍙拌处绯荤粺 - Constant.ScenseType.TYPE5.value -> { + Constant.SceneType.TYPE5.value -> { aopDbMapper.restaurantBaseInfoMapper.selectByPrimaryKey(userInfoTZ.value?.guid) } - Constant.ScenseType.TYPE6.value -> { + Constant.SceneType.TYPE6.value -> { aopDbMapper.vehicleBaseInfoMapper.selectByPrimaryKey(userInfoTZ.value?.guid) } else -> null @@ -231,9 +282,9 @@ val totalScore = InfoProxy<Int>() //鑷姩璇勫垎瑙勫垯涓�绾у垎绫� - val topItems = InfoProxy<MutableList<Evaluationsubrule2>>(config?.sceneType.toString()) { _, cacheMap -> - val _topItems = mutableListOf<Evaluationsubrule2>() - val _rules = mutableListOf<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>>() + val topRules = InfoProxy<MutableList<EvaluationSubRuleVo>>(config?.sceneType.toString()) { _, cacheMap -> + val _topItems = mutableListOf<EvaluationSubRuleVo>() + val _rules = mutableListOf<Pair<EvaluationSubRuleVo, MutableList<EvaluationSubRuleVo>>>() val rule = aopDbMapper.evaluationruleMapper.selectByExample(Example(Evaluationrule::class.java).apply { createCriteria() .andEqualTo("tasktypeid", 99) @@ -247,7 +298,11 @@ val rules = aopDbMapper.evaluationsubruleMapper.selectByExample(Example(Evaluationsubrule2::class.java).apply { createCriteria().andEqualTo("erguid", ruleId) - }) + }).map { + val vo = EvaluationSubRuleVo() + BeanUtils.copyProperties(it, vo) + vo + } rules.forEach { if (it.ertype == 2) { _topItems.add(it) @@ -258,7 +313,7 @@ var t = 0 _topItems.forEach { t += it.maxscore ?: 0 - val tempRules = mutableListOf<Evaluationsubrule2>() + val tempRules = mutableListOf<EvaluationSubRuleVo>() for (i in rules) { if (i.fatherid == it.guid && i.ertype == 3) { tempRules.add(i) @@ -270,7 +325,7 @@ } tempRules.sortBy { t -> t.displayid } tempRules.forEach { temp -> - val tempSubRules = mutableListOf<Evaluationsubrule2>() + val tempSubRules = mutableListOf<EvaluationSubRuleVo>() for (i in rules) { if (i.fatherid == temp.guid && i.ertype == 4) { tempSubRules.add(i) @@ -291,11 +346,11 @@ // FIXME: 2023/8/9 瀛愯鍒欑殑鑾峰彇蹇呴』鍦╗topItems]璋冪敤涔嬪悗锛屽惁鍒欎负绌� //鑷姩璇勫垎瑙勫垯浜岀骇鍜屼笁绾у垎绫� - val rules = InfoProxy<MutableList<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>>>() + val rules = InfoProxy<MutableList<Pair<EvaluationSubRuleVo, MutableList<EvaluationSubRuleVo>>>>() //蹇呭~鍙拌处鏁伴噺 val ledgerCount = InfoProxy<Int>(config?.sceneType.toString()) {_, cacheMap -> - val tzSceneType = Constant.ScenseType.typeMap(scene.value?.typeid) + val tzSceneType = Constant.SceneType.typeMap(scene.value?.typeid) val list = aopDbMapper.ledgerSubTypeMapper.selectCountByExample(Example(LedgerSubType::class.java).apply { createCriteria().andEqualTo("lScenetype", tzSceneType).andEqualTo("lNeedupdate", true) }) @@ -338,21 +393,43 @@ */ fun clear() { scene.clear() + subTaskIndex = 0 + subTaskList.clear() userInfo.clear() userInfoTZ.clear() + baseScene.clear() + problemTypes.clear() + ledgerCount.clear() + ledgerRecords.clear() + + clearSubtask() + } + + fun clearSubtask() { subTask.clear() inspection.clear() - baseScene.clear() problems.clear() evaluation.clear() itemevaluationList.clear() - problemTypes.clear() - baseRule.clear() totalScore.clear() - topItems.clear() + topRules.clear() + baseRule.clear() rules.clear() - ledgerCount.clear() - ledgerRecords.clear() + } + + /** + * 鍒囨崲鑷充笅涓�涓贰鏌ヤ换鍔� + * 涓�涓満鏅彲鑳藉悓鏃跺瓨鍦ㄥ涓贰鏌ヤ换鍔subTaskList]锛岄渶瑕佸姣忎釜宸℃煡浠诲姟鍒嗗埆杩涜璇勫垎 + * @return 鏄惁鏈変笅涓�涓贰鏌ヤ换鍔� + */ + fun gotoNextSubTask(): Boolean { + return if (subTaskIndex + 1 < (subTaskList.value?.size ?: 0)) { + clearSubtask() + subTaskIndex++ + true + } else { + false + } } /** -- Gitblit v1.9.3