From 52a0c16de9b0955a5f092560b73f16e41684f97b Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 31 十二月 2024 10:13:35 +0800 Subject: [PATCH] 1. 环信码生成时,如果在线场景当期没有评估(未巡查)结果,则延用历史最新一次的结果; 2. 新增跨时间跨月度的历史整改记录查询逻辑 3. 优化获取顶层任务和日任务的获取逻辑 --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt | 79 ++++++++++++++++++++++----------------- 1 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt index 87908bb..70db70c 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt @@ -318,55 +318,64 @@ return taskVoList } - override fun getDayTask(taskId: String, userId: String, userType: String): List<DayTaskProgressVo> { - val example = Example(Task::class.java) - val criteria = example.createCriteria() - //鏋勯�犳煡璇㈡潯浠� - criteria.andEqualTo("tsguid", taskId) - if (userType == "1") { - criteria.andLike("executorguids", "%$userId%") - } - + override fun getDayTask(taskId: String, userId: String?, userType: String): List<DayTaskProgressVo> { val resultList = ArrayList<DayTaskProgressVo>() + // 鑾峰彇鎬讳换鍔′笅鎵�鏈夋棩浠诲姟 + val dayTasks = if (userType == "1") { + taskRep.findDayTasks(taskId, userId) + } else { + taskRep.findDayTasks(taskId) + } + + // 鑾峰彇鎬讳换鍔′笅鎵�鏈夌殑瀛愪换鍔� + val subTasks = subTaskRep.findAll(Subtask().apply { tguid = taskId }) + //鏍规嵁sql鏉′欢鏌ヨ - taskMapper.selectByExample(example).forEach { - val exampleTotal = Example(Subtask::class.java).apply { - createCriteria().andEqualTo("tsguid", it.tguid) + dayTasks.forEach {t-> + // 绛涢�夊綋鍓嶆棩浠诲姟涓嬬殑瀛愪换鍔� + val filterSubTasks = subTasks.filter {s-> + s?.tsguid == t?.tguid + } + // 瀛愪换鍔℃�绘暟 + val total = filterSubTasks.size + + // 瀛愪换鍔″畬鎴愭暟 + val complete = filterSubTasks.count {fs-> + fs?.status == Constant.TaskProgress.RUNINGSTATUS3.text } - val total = subtaskMapper.selectCountByExample(exampleTotal) - - val exampleComplete = exampleTotal.apply { - and().andEqualTo("status", Constant.TaskProgress.RUNINGSTATUS3.text) + // 鑾峰彇褰撴棩鎵�鏈夌殑闂 + val subTaskIds = filterSubTasks.map { fs-> fs?.stguid } + val problemList = if (subTaskIds.isNotEmpty()) { + problemListMapper.selectByExample(Example(Problemlist::class.java).apply { + createCriteria().andIn("stguid", subTaskIds) + }) + } else{ + emptyList() } - val complete = subtaskMapper.selectCountByExample(exampleComplete) + var changed = 0 - problemListMapper.findUnchangedCount(it.tguid ?: "").forEach { i -> - //缁撴灉琛ㄧず璇ュ瓙浠诲姟鏈暣鏀归棶棰樻暟 - if (i == 0) { - changed++ - } - } - //瀹℃牳鏄惁瀹屾垚 - var check = false - with(subtaskMapper.selectByExample(exampleTotal)) breaking@{ - forEach { - problemListMapper.selectByExample(Example(Problemlist::class.java).apply { - createCriteria().andEqualTo("stguid", it.stguid) - }).forEach { problem -> - if (problem.extension3 == Constant.PROBLEM_UNCHECKED) { - check = true - return@breaking - } + var check = true + filterSubTasks.forEach {fs -> + // 绛涢�夋瘡涓瓙浠诲姟涓嬬殑闂鏈暣鏀规暟 + problemList.filter { p-> p?.stguid == fs?.stguid }.onEach { pro -> + // 褰撳瓨鍦ㄨ嚦灏戜竴涓棶棰樻病鏈夊鏍告椂锛屽綋鏃ュ鏍哥姸鎬佷负鏈鏍� + if (pro.extension3 == Constant.PROBLEM_UNCHECKED || pro.extension3 == Constant.CHANGE_UNCHECKED) { + check = false + } + }.count { i -> i?.ischanged != true }.let { c -> + // 娌℃湁鏈暣鏀归棶棰樻椂锛屽垯琛ㄧず璇ュ瓙浠诲姟宸茬粡鏁存敼瀹屾垚 + if (c == 0) { + changed++ } } } resultList.add(DayTaskProgressVo( - it.tguid, it.starttime, taskId, complete, changed, total, check + t?.tguid, t?.starttime, taskId, complete, changed, total, check )) } -- Gitblit v1.9.3