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/TaskService.kt | 2 src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/AopCreditCode.kt | 14 + src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/ProblemInfo.kt | 21 +++ src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/ProblemRep.kt | 4 src/test/kotlin/cn/flightfeather/supervision/business/crosstimechange/CrossTimeChangeManagerTest.kt | 43 ++++++ src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/TaskRep.kt | 7 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/TaskController.kt | 2 src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/CrossTimeChangeManager.kt | 190 +++++++++++++++++++++++++++ src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/package.info | 7 + src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/EvaluationRep.kt | 4 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt | 79 ++++++----- src/test/kotlin/cn/flightfeather/supervision/business/autooutput/AopEvaluationTest.kt | 6 src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/ScenePbGroup.kt | 17 ++ src/main/kotlin/cn/flightfeather/supervision/domain/ds2/repository/OverallEvaluationRep.kt | 12 + src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt | 1 15 files changed, 364 insertions(+), 45 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/AopCreditCode.kt b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/AopCreditCode.kt index 7d9819a..ae7a4d5 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/AopCreditCode.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/AopCreditCode.kt @@ -10,6 +10,8 @@ import cn.flightfeather.supervision.domain.ds2.repository.UserMapRep import org.springframework.stereotype.Component import java.time.LocalDate +import java.time.ZoneId +import java.util.* /** * 鏍规嵁鑷姩璇勪及[AopEvaluation]缁撴灉鐢熸垚鐜俊鐮� @@ -33,9 +35,19 @@ userMapRep.findFromSupervision(it)?.let { s -> // 浠庨缇界洃绠$郴缁熶腑鏌ユ壘璇勫垎 val e = evaluationRep.findByScene(s.guid, date) - e?.resultscorebef?.toInt()?.let {score -> + if (e.isNotEmpty()) { // 鏍规嵁璇勫垎鐢熸垚瀵瑰簲鐨勭幆淇$爜 + var score = 0 + e.forEach {eva -> + val s = eva?.resultscorebef?.toInt() ?: 0 + if (s > score) score = s + } overallEvaluationRep.insertOrUpdateOne(it?.guid, score, sceneType, date, endDate) + } else { + // TODO: 2024/12/6 褰撴病鏈夋壘鍒拌嚜鍔ㄨ瘎鍒嗚褰曟椂锛岄噰鐢ㄥ巻鍙叉渶鏂扮殑鐜俊鐮佽褰曚綔涓烘湰鏈熻褰� + overallEvaluationRep.selectLatest(it?.guid)?.let {o -> + overallEvaluationRep.insertOrUpdateOne(o.biGuid, o.oeScore, sceneType, date, endDate) + } } } } diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/CrossTimeChangeManager.kt b/src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/CrossTimeChangeManager.kt new file mode 100644 index 0000000..759a6b8 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/CrossTimeChangeManager.kt @@ -0,0 +1,190 @@ +package cn.flightfeather.supervision.business.crosstimechange + +import cn.flightfeather.supervision.common.utils.DateUtil +import cn.flightfeather.supervision.common.utils.ExcelUtil +import cn.flightfeather.supervision.domain.ds1.entity.Problemlist +import cn.flightfeather.supervision.domain.ds1.repository.ProblemRep +import cn.flightfeather.supervision.domain.ds1.repository.SubTaskRep +import cn.flightfeather.supervision.lightshare.vo.AreaVo +import org.springframework.stereotype.Component +import java.io.File +import java.io.FileOutputStream +import java.time.format.DateTimeFormatter + +/** + * 璺ㄦ椂闂磋法鏈堝害鏁存敼 + * @date 2024/12/20 + * @author feiyu02 + */ +@Component +class CrossTimeChangeManager(private val subTaskRep: SubTaskRep, private val problemRep: ProblemRep) { + + /** + * 鎵ц璺ㄦ湀搴﹁法鏃堕棿鏁存敼鍒嗘瀽 + * @param areaVo 绛涢�夋潯浠讹紝鍖呮嫭鍖哄煙銆佸満鏅被鍨嬨�佹椂闂磋寖鍥� + */ + fun execute(areaVo: AreaVo, fileName: String) { + val pbGroupList = searchProblem(areaVo) + pbGroupList.forEach { changeAnalysis(it) } + formatToExcel(areaVo, pbGroupList, fileName) + } + + /** + * 鏌ヨ鑼冨洿鍐呯殑鍦烘櫙鍙婂悇鏈堝害闂 + */ + fun searchProblem(areaVo: AreaVo): List<ScenePbGroup> { + // 鑾峰彇鑼冨洿鍐呮墍鏈夌殑宸℃煡璁板綍鍙婂叿浣撻棶棰� + val summary = subTaskRep.findSummary(areaVo) + // 鎸夌収鍦烘櫙杩涜褰掔被 + val sceneMap = mutableMapOf<String?, ScenePbGroup>() + summary.forEach { + if (!sceneMap.containsKey(it.sceneId)) { + sceneMap[it.sceneId] = ScenePbGroup().apply { + scene = it.scene + } + } + sceneMap[it.sceneId]?.apply { + pbGroup.add(ProblemInfo().apply { + subtask = it.subtask + val pList = problemRep.find(Problemlist().apply { + stguid = it.stGuid + }) + pbList.addAll(pList) + }) + } + } + // 灏嗗綊绫诲ソ鐨勫悇鍦烘櫙闂鎸夌収宸℃煡鏃堕棿鍗囧簭鎺掑垪骞惰浆鎹负鏁扮粍缁撴瀯 + val res = mutableListOf<ScenePbGroup>() + sceneMap.forEach { (t, u) -> + u.pbGroup.sortBy { it?.subtask?.planstarttime } + res.add(u) + } + // 灏嗗満鏅寜鐓у敮涓�缂栧彿鍗囧簭鎺掑垪锛堥潪蹇呰锛� + res.sortBy { it.scene?.index } + + return res + } + + /** + * 鍒嗘瀽鍗曚釜鍦烘櫙鍚勬湀闂鏄惁鍙互鏁存敼 + */ + fun changeAnalysis(scenePbGroup: ScenePbGroup) { + scenePbGroup.pbGroup.forEachIndexed {i,it -> + it?.pbList?.forEach { p -> + // 宸叉暣鏀圭殑闂鐣ヨ繃 + if (p?.ischanged == true) return@forEach + + // 鎵惧埌缁撴灉锛堟寚鏈変竴涓湀鏈嚭鐜版闂锛屾垨鑰呭嚭鐜颁簡姝ら棶棰樹絾宸叉暣鏀癸級锛屽垯鍏佽灏嗘鍘嗗彶闂浣滀负宸叉暣鏀� + var found = false + + // 鍚戝悗缁湀搴︽煡鎵炬槸鍚︽湁鐩稿悓鐨勯棶棰樺嚭鐜� + var index = i + 1 + while (!found && index < scenePbGroup.pbGroup.size) { + val nextGroup = scenePbGroup.pbGroup[index] + val result = nextGroup?.pbList?.find { nP -> + nP?.ptguid == p?.ptguid + } + // 璇ユ湀鏈嚭鐜版闂锛屾垨鑰呭嚭鐜颁簡姝ら棶棰樹絾宸叉暣鏀� + if (result == null || result.ischanged == true) { + found = true + } + index++ + } + + // 鑻ヨ闂绗﹀悎鏁存敼鏉′欢锛屽垯娣诲姞鑷冲彲鏁存敼鍒楄〃 + if (found) { + it.pbChangeList.add(p) + } + } + } + } + + /** + * 鏍煎紡鍖栬緭鍑鸿嚦excel鏂囦欢 + */ + fun formatToExcel(areaVo: AreaVo, pbGroupList: List<ScenePbGroup>, fileName: String) { + if (pbGroupList.isEmpty()) return + + val h = mutableListOf<MutableList<Any>>() + val c = mutableListOf<MutableList<Any>>() + + // 鐢熸垚琛ㄥご + val h1 = mutableListOf<Any>("鍞竴缂栧彿", "鍦烘櫙") + val monHead = mutableListOf<String>() + var time = areaVo.starttime?.toLocalDate() + val end = areaVo.endtime?.toLocalDate() + // 姝ゅ寮�濮嬫椂闂村簲涓烘湀鍒濓紝缁撴潫鏃堕棿搴斾负鏈堟湯锛屽垯鍙互鐩存帴鐢╥sBefore姣旇緝 + while (time?.isBefore(end) == true) { + monHead.add(time.format(DateTimeFormatter.ofPattern("YYYY-MM"))) + time = time.plusMonths(1) + } + monHead.forEach { + val str = it.split("-")[1] + "鏈�" + h1.addAll(listOf(str + "闂", str + "鏈暣鏀�", str + "鏈暣鏀规暟")) + } + monHead.forEach { + val str = it.split("-")[1] + "鏈�" + h1.addAll(listOf(str + "鍙暣鏀�", str + "鍘熸暣鏀规暟", str + "鏂板鍙暣鏀规暟")) + } + h.add(h1) + + // 鐢熸垚鍐呭 + pbGroupList.forEach {pbg -> + val index = pbg.scene?.index ?: "" + val name = pbg.scene?.name ?: "" + + val problemContent = mutableListOf<Any>() + monHead.forEach {mH -> + val stp = pbg.pbGroup.find { pbi -> + DateUtil.DateToString(pbi?.subtask?.planstarttime, DateUtil.DateStyle.YYYY_MM) == mH + } + + if (stp == null) { + problemContent.addAll(listOf("/", "/", "/")) + } else { + // 闂 + problemContent.add(stp.pbList.mapIndexed { i, pb -> "${i+1}銆�${pb?.problemname}" }.joinToString + ("\n")) + val unchanged = stp.pbList.filter { pb-> pb?.ischanged != true } + // 鏈暣鏀� + problemContent.add(unchanged.mapIndexed { i, pb -> "${i+1}銆�${pb?.problemname}" }.joinToString("\n")) + // 鏈暣鏀规暟 + problemContent.add(unchanged.size) + } + } + + val willChangeContent = mutableListOf<Any>() + monHead.forEach {mH -> + val stp = pbg.pbGroup.find { pbi -> + DateUtil.DateToString(pbi?.subtask?.planstarttime, DateUtil.DateStyle.YYYY_MM) == mH + } + + if (stp == null) { + willChangeContent.addAll(listOf("/", "/", "/")) + } else { + // 鍙暣鏀� + willChangeContent.add(stp.pbChangeList.mapIndexed { i, pb -> "${i+1}銆�${pb?.problemname}" } + .joinToString("\n")) + val changed = stp.pbList.filter { pb-> pb?.ischanged == true } + // 鍘熸暣鏀规暟 + willChangeContent.add(changed.size) + // 鏂板鍙暣鏀规暟 + willChangeContent.add(stp.pbChangeList.size) + } + } + + val row = mutableListOf<Any>() + row.add(index) + row.add(name) + row.addAll(problemContent) + row.addAll(willChangeContent) + + c.add(row) + } + + // 鐢熸垚鏂囦欢 + val file = File("target/${fileName}") + val out = FileOutputStream(file) + ExcelUtil.write2(out, h.map { it.toTypedArray() }, c.map { it.toTypedArray() }.toMutableList()) + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/ProblemInfo.kt b/src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/ProblemInfo.kt new file mode 100644 index 0000000..021f50b --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/ProblemInfo.kt @@ -0,0 +1,21 @@ +package cn.flightfeather.supervision.business.crosstimechange + +import cn.flightfeather.supervision.domain.ds1.entity.Problemlist +import cn.flightfeather.supervision.domain.ds1.entity.Subtask + +/** + * 闂鏁存敼鎯呭喌 + * @date 2024/12/20 + * @author feiyu02 + */ +class ProblemInfo { + + // 宸℃煡浠诲姟 + var subtask: Subtask? = null + + // 鍘嗗彶闂 + val pbList = mutableListOf<Problemlist?>() + + // 鍙璺ㄦ椂闂磋法鏈堝害鏁存敼鐨勯棶棰� + val pbChangeList = mutableListOf<Problemlist?>() +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/ScenePbGroup.kt b/src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/ScenePbGroup.kt new file mode 100644 index 0000000..c291da1 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/ScenePbGroup.kt @@ -0,0 +1,17 @@ +package cn.flightfeather.supervision.business.crosstimechange + +import cn.flightfeather.supervision.domain.ds1.entity.Scense + +/** + * 鍦烘櫙璺ㄦ湀搴﹂棶棰樼粍 + * @date 2024/12/20 + * @author feiyu02 + */ +class ScenePbGroup { + + // 鍦烘櫙 + var scene: Scense? = null + + // 鍘嗘潵鍚勬湀浠界殑闂鎯呭喌 + val pbGroup = mutableListOf<ProblemInfo?>() +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/package.info b/src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/package.info new file mode 100644 index 0000000..effd4de --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/package.info @@ -0,0 +1,7 @@ +璺ㄦ椂闂磋法鏈堝害鏁存敼 + +瀵逛簬鍚屼竴瀹跺満鏅紝浠涓湀涓哄懆鏈燂紝闇�瑕佸垽鏂瘡涓湀鏈暣鏀圭殑闂鍦ㄥ悗缁湀浠界洃绠′腑鏄惁鏈嚭鐜帮紝鑻ユ湭鍑虹幇锛屽垯璁や负璇ラ棶棰樺凡鏁存敼 + +鍏蜂綋閫昏緫 +1. 绛涢�夎繖N涓湀鐨勯棶棰橈紱 +2. 寰幆鍒ゆ柇姣忎釜鏈堢殑姣忎釜鏈暣鏀归棶棰橈紝鍦ㄥ悗缁湀浠戒腑锛岃嫢鑷冲皯鏈変竴涓湀鏈嚭鐜拌繃璇ラ棶棰橈紝鍒欒涓鸿闂宸叉暣鏀� \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/EvaluationRep.kt b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/EvaluationRep.kt index c3ccd05..daa3233 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/EvaluationRep.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/EvaluationRep.kt @@ -24,14 +24,14 @@ * @param date 鏃ユ湡锛屽彧浣跨敤骞村拰鏈� * @return */ - fun findByScene(sceneId: String?, date: LocalDate): Evaluation? { + fun findByScene(sceneId: String?, date: LocalDate): List<Evaluation?> { val sT = date.withDayOfMonth(1).atStartOfDay() val eT = sT.plusMonths(1).minusSeconds(1) val res = evaluationMapper.selectByExample(Example(Evaluation::class.java).apply { createCriteria().andEqualTo("sguid", sceneId) .andBetween("evaluatetime", sT, eT) }) - return if (res.isNotEmpty()) res[0] else null + return res } fun findBySubtask(subTaskId: String?): Evaluation? { diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/ProblemRep.kt b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/ProblemRep.kt index dea0666..da59135 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/ProblemRep.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/ProblemRep.kt @@ -18,6 +18,10 @@ return problemlistMapper.updateByPrimaryKey(problemlist) } + fun find(problemlist: Problemlist): List<Problemlist?> { + return problemlistMapper.select(problemlist) + } + /** * 鑾峰彇鍚勫満鏅殑闂鍜屾暣鏀规暟閲忕粺璁� */ diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/TaskRep.kt b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/TaskRep.kt index 22d0ebb..85bffce 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/TaskRep.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/TaskRep.kt @@ -79,10 +79,13 @@ /** * 鑾峰彇鏃ヤ换鍔� * @param taskId 椤跺眰浠诲姟id + * @param userId 鎵ц鐢ㄦ埛id */ - fun findDayTasks(taskId: String?): List<Task?> { + fun findDayTasks(taskId: String?, userId: String? = null): List<Task?> { return taskMapper.selectByExample(Example(Task::class.java).apply { - createCriteria().andEqualTo("tsguid", taskId) + createCriteria().andEqualTo("tsguid", taskId).apply { + userId?.let { andLike("executorguids", "%$it%") } + } orderBy("starttime").desc() }) } diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/ds2/repository/OverallEvaluationRep.kt b/src/main/kotlin/cn/flightfeather/supervision/domain/ds2/repository/OverallEvaluationRep.kt index b99a538..06a70a5 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/domain/ds2/repository/OverallEvaluationRep.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/domain/ds2/repository/OverallEvaluationRep.kt @@ -5,6 +5,7 @@ import cn.flightfeather.supervision.domain.ds2.entity.OverallEvaluation import cn.flightfeather.supervision.domain.ds2.mapper.OverallEvaluationMapper import org.springframework.stereotype.Repository +import tk.mybatis.mapper.entity.Example import java.time.LocalDate import java.time.ZoneId import java.util.* @@ -13,6 +14,17 @@ class OverallEvaluationRep(private val overallEvaluationMapper: OverallEvaluationMapper){ /** + * 鑾峰彇鏈�鏂拌褰� + */ + fun selectLatest(userId: String?): OverallEvaluation? { + val res = overallEvaluationMapper.selectByExample(Example(OverallEvaluation::class.java).apply { + createCriteria().andEqualTo("biGuid", userId) + orderBy("oeUpdateTime").desc() + }) + return if (res.isNotEmpty()) res[0] else null + } + + /** * 鎻掑叆涓�鏉$幆淇$爜璁板綍 * @param userId * @param score diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/TaskService.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/TaskService.kt index b656fe3..6046e69 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/TaskService.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/TaskService.kt @@ -30,7 +30,7 @@ fun getDayTaskList(taskVoList: List<TaskVo>, date: String, guid: String, userType: String): List<TaskVo> - fun getDayTask(taskId: String, userId: String, userType: String): List<DayTaskProgressVo> + fun getDayTask(taskId: String, userId: String?, userType: String): List<DayTaskProgressVo> fun findByName(name: String): TaskVo diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt index fb9b6bb..d33ffe5 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt @@ -526,6 +526,7 @@ return "success" } + override fun changeProblem(problemId: String, files: Array<MultipartFile>): BaseResponse<String> { // 闂鍜岄棶棰樺浘鐗囧悎娉曟�ф鏌� val p = problemlistMapper.selectByPrimaryKey(problemId) ?: return BaseResponse(false, "闂涓嶅瓨鍦�") 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 )) } diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/TaskController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/TaskController.kt index dafb2b7..a3251c1 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/TaskController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/TaskController.kt @@ -52,7 +52,7 @@ @GetMapping("/dayTask/{taskId}") fun getDayTask( @PathVariable("taskId") taskId: String, - @RequestParam("userId") userId: String, + @RequestParam("userId", required = false) userId: String?, @RequestParam("userType") userType: String ) = taskService.getDayTask(taskId, userId, userType) diff --git a/src/test/kotlin/cn/flightfeather/supervision/business/autooutput/AopEvaluationTest.kt b/src/test/kotlin/cn/flightfeather/supervision/business/autooutput/AopEvaluationTest.kt index 6b2f2b0..852f32f 100644 --- a/src/test/kotlin/cn/flightfeather/supervision/business/autooutput/AopEvaluationTest.kt +++ b/src/test/kotlin/cn/flightfeather/supervision/business/autooutput/AopEvaluationTest.kt @@ -79,11 +79,11 @@ */ @Test fun test() { - val taskId = "88wgq9l5gm9cUMg1" - val districtCode = "310104" +// val taskId = "88wgq9l5gm9cUMg1" +// val districtCode = "310104" val districtName = "寰愭眹鍖�" val year = 2024 - val month = 5 + val month = 11 val sceneType = Constant.SceneType.TYPE5.value.toInt() // xhFuDataAnalysis.setResource(taskId, sceneType, year, month) // xhFuDataAnalysis.execute() diff --git a/src/test/kotlin/cn/flightfeather/supervision/business/crosstimechange/CrossTimeChangeManagerTest.kt b/src/test/kotlin/cn/flightfeather/supervision/business/crosstimechange/CrossTimeChangeManagerTest.kt new file mode 100644 index 0000000..c5faa2c --- /dev/null +++ b/src/test/kotlin/cn/flightfeather/supervision/business/crosstimechange/CrossTimeChangeManagerTest.kt @@ -0,0 +1,43 @@ +package cn.flightfeather.supervision.business.crosstimechange + +import cn.flightfeather.supervision.common.utils.Constant +import cn.flightfeather.supervision.lightshare.vo.AreaVo +import org.junit.Test +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.runner.RunWith +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.context.junit.jupiter.SpringExtension +import org.springframework.test.context.junit4.SpringRunner +import java.time.LocalDateTime + +@RunWith(SpringRunner::class) +@ExtendWith(SpringExtension::class) +@SpringBootTest +class CrossTimeChangeManagerTest { + + @Autowired + lateinit var crossTimeChangeManager: CrossTimeChangeManager + + @Test + fun execute() { +// crossTimeChangeManager.execute(AreaVo().apply { +// provincecode = "31" +// citycode = "3100" +// districtcode = "310104" +// starttime = LocalDateTime.of(2024, 3, 1, 0, 0, 0, 0) +// endtime = LocalDateTime.of(2024, 6, 30, 23, 59, 59, 999) +// scensetypeid = Constant.SceneType.TYPE5.value +// }, "寰愭眹椁愰ギ鍘嗗彶闂鍙暣鏀圭粺璁�-3鑷�6鏈�.xlsx") + + crossTimeChangeManager.execute(AreaVo().apply { + provincecode = "31" + citycode = "3100" + districtcode = "310104" + starttime = LocalDateTime.of(2024, 7, 1, 0, 0, 0, 0) + endtime = LocalDateTime.of(2024, 10, 31, 23, 59, 59, 999) + scensetypeid = Constant.SceneType.TYPE5.value + }, "寰愭眹椁愰ギ鍘嗗彶闂鍙暣鏀圭粺璁�-7鑷�10鏈�.xlsx") + } +} \ No newline at end of file -- Gitblit v1.9.3