From 8c15c9cc0d6474ed77e313258f9b09f7f2d6366e Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期三, 17 九月 2025 17:29:47 +0800 Subject: [PATCH] 2025.9.17 1. 新增数据产品接口 --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt | 237 +++++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 156 insertions(+), 81 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 022941c..f103925 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 @@ -1,5 +1,6 @@ package cn.flightfeather.supervision.lightshare.service.impl +import cn.flightfeather.supervision.common.exception.BizException import cn.flightfeather.supervision.domain.ds1.entity.Problemlist import cn.flightfeather.supervision.domain.ds1.entity.Subtask import cn.flightfeather.supervision.domain.ds1.entity.Task @@ -8,10 +9,11 @@ import cn.flightfeather.supervision.domain.ds1.mapper.TaskMapper import cn.flightfeather.supervision.common.utils.Constant import cn.flightfeather.supervision.common.utils.DateUtil -import cn.flightfeather.supervision.lightshare.service.EvaluationService -import cn.flightfeather.supervision.lightshare.service.SubtaskService -import cn.flightfeather.supervision.lightshare.service.TaskService -import cn.flightfeather.supervision.lightshare.service.UserinfoService +import cn.flightfeather.supervision.common.utils.UUIDGenerator +import cn.flightfeather.supervision.domain.ds1.repository.SceneRep +import cn.flightfeather.supervision.domain.ds1.repository.SubTaskRep +import cn.flightfeather.supervision.domain.ds1.repository.TaskRep +import cn.flightfeather.supervision.lightshare.service.* import cn.flightfeather.supervision.lightshare.vo.* import org.springframework.beans.BeanUtils import org.springframework.beans.factory.annotation.Autowired @@ -21,7 +23,12 @@ import kotlin.collections.ArrayList @Service -class TaskServiceImpl(val taskMapper: TaskMapper) : TaskService { +class TaskServiceImpl( + val taskMapper: TaskMapper, + private val taskRep: TaskRep, + private val subTaskRep: SubTaskRep, + private val sceneRep: SceneRep, +) : TaskService { @Autowired lateinit var subtaskService: SubtaskService @@ -101,7 +108,7 @@ townRank.standardRate = it.get("standardRate").toString().toFloat() } catch (e: Exception) { } - val s =it.get("hasScoredNum").toString() + val s = it.get("hasScoredNum").toString() try { townRank.hasScoredNum = it.get("hasScoredNum").toString().toInt() } catch (e: Exception) { @@ -161,7 +168,7 @@ if (type == 0) return getAllTop() //鑾峰彇鏈畬鎴愰《灞備换鍔″強瀵瑰簲鏃ヤ换鍔″垪琛� - else if (type == 1){ + else if (type == 1) { val tmp = getAllTop() tmp.forEach { if (it.runingstatus != Constant.TaskProgress.RUNINGSTATUS3.text) { @@ -175,13 +182,13 @@ } //鏍规嵁鏃ユ湡鑾峰彇鏃ヤ换鍔� - override fun findByDate(date: String): TaskVo { + override fun findByDate(topTaskId: String, date: String): TaskVo { val taskVo = TaskVo() val example = Example(Task::class.java) val criteria = example.createCriteria() //gsguid涓嶄负绌轰负鏃ヤ换鍔�,鏃ヤ换鍔″紑濮嬫椂闂村拰缁撴潫鏃堕棿鍦ㄥ悓涓�澶�,杩囨护寮�濮嬫椂闂村氨ok - criteria.andEqualTo("starttime", dateUtil.StringToDate(date.substring(0, 10))) - criteria.andIsNotNull("tsguid") + criteria.andEqualTo("starttime", DateUtil.StringToDate(date.substring(0, 10))) + criteria.andEqualTo("tsguid", topTaskId) val tasklist = taskMapper.selectByExample(example) if (tasklist.isNotEmpty()) { BeanUtils.copyProperties(tasklist[0], taskVo) @@ -220,10 +227,10 @@ // .andEqualTo("districtcode", districtCode) // .andLessThanOrEqualTo("endtime", date) // example.or( - example.createCriteria().andIsNull("tsguid") - .andEqualTo("districtcode", districtCode) - .andLessThan("starttime", date) - .andGreaterThanOrEqualTo("endtime", date) + example.createCriteria().andIsNull("tsguid") + .andEqualTo("districtcode", districtCode) + .andLessThanOrEqualTo("starttime", date) + .andGreaterThanOrEqualTo("endtime", date) // ) example.orderBy("starttime").desc() val tasklist = taskMapper.selectByExample(example) @@ -286,8 +293,6 @@ return if (tasks.isEmpty()) Task() else tasks[0] } - val dateUtil = DateUtil() - //鏍规嵁椤跺眰鍒楄〃,鏃ユ湡,鍜屾墽琛屼汉鍛業D锛岀敤鎴风被鍨嬭幏鍙栨棩浠诲姟 override fun getDayTaskList(taskVoList: List<TaskVo>, date: String, guid: String, userType: String): List<TaskVo> { if (taskVoList.isEmpty()) return taskVoList @@ -296,9 +301,9 @@ val criteria = example.createCriteria() //鏋勯�犳煡璇㈡潯浠� criteria.andEqualTo("tsguid", it.tguid) - val dateTemo = dateUtil.StringToDate(date) + val dateTemo = DateUtil.StringToDate(date) //鏉′欢杩囨护 - criteria.andBetween("starttime", dateTemo, dateUtil.addSecond(dateUtil.addMonth(dateTemo!!, 1)!!, 1)) + criteria.andBetween("starttime", dateTemo, DateUtil.addSecond(DateUtil.addMonth(dateTemo!!, 1)!!, 1)) if (userType == "1") { criteria.andLike("executorguids", "%$guid%") } @@ -315,55 +320,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 + resultList.add(DayTaskProgressVo( + t?.tguid, t?.starttime, taskId, complete, changed, total, check )) } @@ -378,9 +392,9 @@ val criteria = example.createCriteria() //鏋勯�犳煡璇㈡潯浠� criteria.andEqualTo("tsguid", it.tguid) - val dateTemo = dateUtil.StringToDate(date) + val dateTemo = DateUtil.StringToDate(date) //鏉′欢杩囨护 - criteria.andBetween("starttime", dateTemo, dateUtil.addSecond(dateUtil.addMonth(dateTemo!!, 1)!!, 1)) + criteria.andBetween("starttime", dateTemo, DateUtil.addSecond(DateUtil.addMonth(dateTemo!!, 1)!!, 1)) criteria.andLike("executorguids", "%$guid%") //鏍规嵁sql鏉′欢鏌ヨ val taskList = taskMapper.selectByExample(example) @@ -401,10 +415,10 @@ if (date.length < 7) { return taskVoList } - val startDate = DateUtil().StringToDate(date.substring(0, 7)) ?: return taskVoList + val startDate = DateUtil.StringToDate(date.substring(0, 7)) ?: return taskVoList //鏌ヨ涓�涓湀浠诲姟 - var endDate = DateUtil().addMonth(startDate, 1) ?: return taskVoList - endDate = DateUtil().addSecond(endDate, -1)!! + var endDate = DateUtil.addMonth(startDate, 1) ?: return taskVoList + endDate = DateUtil.addSecond(endDate, -1)!! //鏋勯�犳煡璇㈡潯浠� val example = Example(Task::class.java) val criteria = example.createCriteria() @@ -453,22 +467,22 @@ // return taskVoList // } // //鏃堕棿杞崲 -// val d1 = DateUtil().StringToDate(date.substring(0, 7)) ?: return taskVoList +// val d1 = DateUtil.StringToDate(date.substring(0, 7)) ?: return taskVoList // var startDate: Date? = null // var endDate: Date? = null // //鏍规嵁type绫诲瀷,寰楀埌瑕佹煡璇㈢殑鑼冨洿 // when (type) { // "Middle" -> { -// startDate = DateUtil().addMonth(d1, -1);endDate = DateUtil().addMonth(d1, 2) +// startDate = DateUtil.addMonth(d1, -1);endDate = DateUtil.addMonth(d1, 2) // } // "Left" -> { -// startDate = DateUtil().addMonth(d1, -3);endDate = d1 +// startDate = DateUtil.addMonth(d1, -3);endDate = d1 // } // "Right" -> { -// startDate = DateUtil().addMonth(d1, 1);endDate = DateUtil().addMonth(d1, 4) +// startDate = DateUtil.addMonth(d1, 1);endDate = DateUtil.addMonth(d1, 4) // } // else -> { -// startDate = d1;endDate = DateUtil().addMonth(d1, 1) +// startDate = d1;endDate = DateUtil.addMonth(d1, 1) // } // } // @@ -497,16 +511,16 @@ if (date.length < 7) { return taskVoList } - val startDate = DateUtil().StringToDate(date.substring(0, 7)) ?: return taskVoList + val startDate = DateUtil.StringToDate(date.substring(0, 7)) ?: return taskVoList //鏌ヨ涓�涓湀浠诲姟 - var endDate = DateUtil().addMonth(startDate, 1) ?: return taskVoList - endDate = DateUtil().addSecond(endDate, -1)!! + var endDate = DateUtil.addMonth(startDate, 1) ?: return taskVoList + endDate = DateUtil.addSecond(endDate, -1)!! //鏋勯�犳煡璇㈡潯浠� val example = Example(Task::class.java) val criteria = example.createCriteria() //鑾峰彇鐢ㄦ埛淇℃伅 val userInfo = userinfoMapper.findOne(guid) - val districtCode = userInfo.dGuid + val districtCode = userInfo?.dGuid //娣诲姞鏃ユ湡杩囨护 @@ -521,25 +535,25 @@ val criteria2 = example.createCriteria() criteria2.orBetween( - "endtime", - startDate, - endDate + "endtime", + startDate, + endDate ).andIsNull("tsguid"); if (userType == "1") { criteria2.andLike("executorguids", "%$guid%") - } else if (userType == "2"){ + } else if (userType == "2") { criteria2.andEqualTo("districtcode", districtCode) } example.or(criteria2) val criteria3 = example.createCriteria() criteria3.orLessThan("starttime", startDate).andGreaterThan( - "endtime", - endDate + "endtime", + endDate ).andIsNull("tsguid"); if (userType == "1") { criteria3.andLike("executorguids", "%$guid%") - } else if (userType == "2"){ + } else if (userType == "2") { criteria3.andEqualTo("districtcode", districtCode) } example.or(criteria3) @@ -586,7 +600,7 @@ } return taskVoList } - + override fun save(task: Task): Int { // FIXME: 2021/10/9 鎸夌収褰撳墠鐨勯�昏緫锛屾鍑芥暟涓昏鐢ㄤ簬鏂板缓椤跺眰浠诲姟浠ュ強鏃ヤ换鍔★紝浣嗘槸鏃ヤ换鍔″唴瀹圭殑鐢熸垚閫昏緫鐩墠鐢卞墠绔痑pp瀹屾垚锛屽洜姝や細鍑虹幇涓�涓猙ug锛� // FIXME: 2021/10/9 褰撳墠绔涓敤鎴峰悓鏃跺湪鍚屼竴涓《灞備换鍔′笅鐨勬柊鐨勪竴澶╁垱寤轰换鍔℃椂锛屼細鍑虹幇鍚屼竴澶╂湁澶氫釜鏃ヤ换鍔★紝姝ゆ椂鍓嶇鍚庣画鏌ョ湅鍙兘鐪嬪埌鍏朵腑涓�涓棩浠诲姟涓嬬殑瀛愪换鍔� @@ -594,6 +608,7 @@ // FIXME: 2021/10/9 鍙﹀瀵逛簬椤跺眰浠诲姟涔熸坊鍔犵被浼奸�昏緫锛岀敱浜庨《灞備换鍔$殑浠诲姟鍚嶇О榛樿绯荤粺鑷姩鐢熸垚锛屽洜姝ゆ殏鏃跺彧鍒ゆ柇鍚屽悕鐨勯《灞備换鍔★紝褰撳瓨鍦ㄥ悓鍚嶉《灞備换鍔℃椂锛屼笉鍋氫繚瀛樻搷浣� var result = 0 + if (task.tguid == null) task.tguid = UUIDGenerator.generate16ShortUUID() // 1銆侀鍏堝垽鏂槸椤跺眰浠诲姟杩樻槸鏃ヤ换鍔� if (task.levelnum == 2) { //2.1銆� 鏄《灞備换鍔℃椂锛屽垽鏂槸鍚﹀凡鏈夊悓鍚嶄换鍔� @@ -607,7 +622,7 @@ } } else { //3.1銆� 褰撴槸鏃ヤ换鍔℃椂锛屽垽鏂湪鍚屼竴涓《灞備换鍔′笅锛屾槸鍚︽湁鍚屽悕鐨勬棩浠诲姟 - val r =taskMapper.selectByExample(Example(Task::class.java).apply { + val r = taskMapper.selectByExample(Example(Task::class.java).apply { createCriteria().andEqualTo("tsguid", task.tsguid) .andEqualTo("name", task.name) }) @@ -633,6 +648,14 @@ return result } + override fun create(task: Task): Task { + val res = save(task) + if (res < 1) + throw BizException("浠诲姟鍒涘缓澶辫触") + else + return task + } + //淇敼鏃ヤ换鍔′俊鎭�,鑻ユ湁瀛愪换鍔�,瀛愪换鍔′篃淇敼 override fun update(task: Task): Int { var re = 1 @@ -645,7 +668,7 @@ BeanUtils.copyProperties(it, subtask) subtask.planstarttime = task.starttime subtask.planendtime = task.endtime - subtaskService.update(subtask) + subtaskService.changeStatus(subtask) } } return re @@ -664,7 +687,7 @@ criteria.andIsNull("tsguid") example.orderBy("starttime").asc() val result = taskMapper.selectByExample(example) - if (result.isNotEmpty()){ + if (result.isNotEmpty()) { result.forEach { var mytotalcount = 0 var mycompletecount = 0 @@ -691,7 +714,7 @@ taskProgressVo.mycompletetask = mycompletecount val daytaskVolist = getDayTaskByTaskID(it.tguid!!) val daytasklist = mutableListOf<TaskVo>() - if (daytaskVolist.isNotEmpty()){ + if (daytaskVolist.isNotEmpty()) { daytaskVolist.forEach { var mytotalcount1 = 0 var mycompletecount1 = 0 @@ -703,7 +726,7 @@ if (Objects.equals(it.status!!, Constant.TaskProgress.RUNINGSTATUS3.text)) mycompletecount1++ } - if(Objects.equals(it.status, Constant.TaskProgress.RUNINGSTATUS3.text)) + if (Objects.equals(it.status, Constant.TaskProgress.RUNINGSTATUS3.text)) completecount1++ } val daytaskProgressVo = TaskVo() @@ -725,4 +748,56 @@ return taskProgressVolist } + override fun findTask(areaVo: AreaVo): List<Task?> { + return taskRep.findTasks(areaVo) + } + + override fun findTaskProgress(areaVo: AreaVo): List<TaskProgressVo?> { + val res = mutableListOf<TaskProgressVo?>() + taskRep.findTasks(areaVo).forEach { t -> + if (t?.tguid == null) return@forEach + val pro = TaskProgressVo().apply { + tguid = t.tguid + name = t.name + levelnum = t.levelnum + provinceCode = t.provincecode + provinceName = t.provincename + cityCode = t.citycode + cityName = t.cityname + districtCode = t.districtcode + districtName = t.districtname + townCode = t.towncode + townName = t.townname + + var count = 0 + val countByScene = mutableMapOf<String?, Int>() + val allScenes = sceneRep.findSceneList(t.tguid!!, areaVo.scensetypeid?.toInt(), areaVo.towncode) + taskRep.findMonitorList(t.tguid!!, areaVo.scensetypeid).forEach { + val c = it.monitornum ?: 1 + count += c + + allScenes.find { s-> s?.guid == it.sguid }?.let { s-> +// if (!countByScene.containsKey(s.type)) { +// countByScene[s.type] = 0 +// } + countByScene[s.type] = (countByScene[s.type] ?: 0) + c + } + } + totaltask = count + totaltaskByScene = countByScene + + subTaskSummary = subTaskRep.findSummary(AreaVo().apply { + topTaskId = t.tguid + }) + val completeByScene = mutableMapOf<String?, Int>() + subTaskSummary?.forEach { + completeByScene[it.sceneType] = (completeByScene[it.sceneType] ?: 0) + 1 + } + completetask = this.subTaskSummary?.size + completetaskByScene = completeByScene + } + res.add(pro) + } + return res + } } \ No newline at end of file -- Gitblit v1.9.3