From 82baf5d28ce79aa4d3b64956207d247596726924 Mon Sep 17 00:00:00 2001
From: hcong <1050828145@qq.com>
Date: 星期二, 10 十二月 2024 11:21:33 +0800
Subject: [PATCH] 1. BgTaskStatus状态属性序列化
---
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt | 102 ++++++++++++++++++++++++++++----------------------
1 files changed, 57 insertions(+), 45 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 7853af7..87908bb 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,6 +9,8 @@
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.common.utils.UUIDGenerator
+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.*
@@ -22,6 +25,7 @@
class TaskServiceImpl(
val taskMapper: TaskMapper,
private val taskRep: TaskRep,
+ private val subTaskRep: SubTaskRep,
) : TaskService {
@Autowired
@@ -102,7 +106,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) {
@@ -162,7 +166,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) {
@@ -176,13 +180,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)
@@ -221,10 +225,10 @@
// .andEqualTo("districtcode", districtCode)
// .andLessThanOrEqualTo("endtime", date)
// example.or(
- example.createCriteria().andIsNull("tsguid")
- .andEqualTo("districtcode", districtCode)
- .andLessThanOrEqualTo("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)
@@ -287,8 +291,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
@@ -297,9 +299,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%")
}
@@ -341,7 +343,7 @@
val complete = subtaskMapper.selectCountByExample(exampleComplete)
var changed = 0
- problemListMapper.findUnchangedCount(it.tguid ?: "").forEach {i ->
+ problemListMapper.findUnchangedCount(it.tguid ?: "").forEach { i ->
//缁撴灉琛ㄧず璇ュ瓙浠诲姟鏈暣鏀归棶棰樻暟
if (i == 0) {
changed++
@@ -354,7 +356,7 @@
forEach {
problemListMapper.selectByExample(Example(Problemlist::class.java).apply {
createCriteria().andEqualTo("stguid", it.stguid)
- }).forEach {problem ->
+ }).forEach { problem ->
if (problem.extension3 == Constant.PROBLEM_UNCHECKED) {
check = true
return@breaking
@@ -363,8 +365,8 @@
}
}
- resultList.add(DayTaskProgressVo(
- it.tguid, it.starttime, taskId, complete, changed, total, check
+ resultList.add(DayTaskProgressVo(
+ it.tguid, it.starttime, taskId, complete, changed, total, check
))
}
@@ -379,9 +381,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)
@@ -402,10 +404,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()
@@ -454,22 +456,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)
// }
// }
//
@@ -498,10 +500,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()
@@ -522,25 +524,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)
@@ -587,7 +589,7 @@
}
return taskVoList
}
-
+
override fun save(task: Task): Int {
// FIXME: 2021/10/9 鎸夌収褰撳墠鐨勯�昏緫锛屾鍑芥暟涓昏鐢ㄤ簬鏂板缓椤跺眰浠诲姟浠ュ強鏃ヤ换鍔★紝浣嗘槸鏃ヤ换鍔″唴瀹圭殑鐢熸垚閫昏緫鐩墠鐢卞墠绔痑pp瀹屾垚锛屽洜姝や細鍑虹幇涓�涓猙ug锛�
// FIXME: 2021/10/9 褰撳墠绔涓敤鎴峰悓鏃跺湪鍚屼竴涓《灞備换鍔′笅鐨勬柊鐨勪竴澶╁垱寤轰换鍔℃椂锛屼細鍑虹幇鍚屼竴澶╂湁澶氫釜鏃ヤ换鍔★紝姝ゆ椂鍓嶇鍚庣画鏌ョ湅鍙兘鐪嬪埌鍏朵腑涓�涓棩浠诲姟涓嬬殑瀛愪换鍔�
@@ -595,6 +597,7 @@
// FIXME: 2021/10/9 鍙﹀瀵逛簬椤跺眰浠诲姟涔熸坊鍔犵被浼奸�昏緫锛岀敱浜庨《灞備换鍔$殑浠诲姟鍚嶇О榛樿绯荤粺鑷姩鐢熸垚锛屽洜姝ゆ殏鏃跺彧鍒ゆ柇鍚屽悕鐨勯《灞備换鍔★紝褰撳瓨鍦ㄥ悓鍚嶉《灞備换鍔℃椂锛屼笉鍋氫繚瀛樻搷浣�
var result = 0
+ if (task.tguid == null) task.tguid = UUIDGenerator.generate16ShortUUID()
// 1銆侀鍏堝垽鏂槸椤跺眰浠诲姟杩樻槸鏃ヤ换鍔�
if (task.levelnum == 2) {
//2.1銆� 鏄《灞備换鍔℃椂锛屽垽鏂槸鍚﹀凡鏈夊悓鍚嶄换鍔�
@@ -608,7 +611,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)
})
@@ -634,6 +637,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
@@ -646,7 +657,7 @@
BeanUtils.copyProperties(it, subtask)
subtask.planstarttime = task.starttime
subtask.planendtime = task.endtime
- subtaskService.update(subtask)
+ subtaskService.changeStatus(subtask)
}
}
return re
@@ -665,7 +676,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
@@ -692,7 +703,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
@@ -704,7 +715,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()
@@ -732,7 +743,7 @@
override fun findTaskProgress(areaVo: AreaVo): List<TaskProgressVo?> {
val res = mutableListOf<TaskProgressVo?>()
- taskRep.findTasks(areaVo).forEach {t->
+ taskRep.findTasks(areaVo).forEach { t ->
if (t?.tguid == null) return@forEach
val pro = TaskProgressVo().apply {
tguid = t.tguid
@@ -752,7 +763,8 @@
count += c
}
totaltask = count
- completetask = subtaskService.getSummary(t.tguid!!, areaVo.scensetypeid?.toIntOrNull()).size
+ subTaskSummary = subTaskRep.findSummary(areaVo)
+ completetask = this.subTaskSummary?.size
}
res.add(pro)
}
--
Gitblit v1.9.3