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) } } } } 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() // æ¤å¤å¼å§æ¶é´åºä¸ºæåï¼ç»ææ¶é´åºä¸ºææ«ï¼åå¯ä»¥ç´æ¥ç¨isBeforeæ¯è¾ 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()) } } 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?>() } 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?>() } src/main/kotlin/cn/flightfeather/supervision/business/crosstimechange/package.info
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,7 @@ è·¨æ¶é´è·¨æåº¦æ´æ¹ 对äºåä¸å®¶åºæ¯ï¼ä»¥N个æä¸ºå¨æï¼éè¦å¤ææ¯ä¸ªææªæ´æ¹çé®é¢å¨åç»æä»½çç®¡ä¸æ¯å¦æªåºç°ï¼è¥æªåºç°ï¼å认为该é®é¢å·²æ´æ¹ å ·ä½é»è¾ 1. çéè¿N个æçé®é¢ï¼ 2. 循ç¯å¤ææ¯ä¸ªæçæ¯ä¸ªæªæ´æ¹é®é¢ï¼å¨åç»æä»½ä¸ï¼è¥è³å°æä¸ä¸ªææªåºç°è¿è¯¥é®é¢ï¼å认为该é®é¢å·²æ´æ¹ 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? { 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) } /** * è·åååºæ¯çé®é¢åæ´æ¹æ°éç»è®¡ */ 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() }) } 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 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 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, "é®é¢ä¸åå¨") 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 )) } 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) 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() 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") } }