From aed297a5fbc8df9dab01b28da21f872ee546b43c Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期一, 13 十月 2025 16:15:11 +0800
Subject: [PATCH] 2025.10.13 1. 统一调整controller层的返回类型,通过添加全局响应增强器GlobalResponseAdvice来管理返回结果; 2. 新增mybatis-generator自定义插件,实现给数据库实体entity自动添加swagger注解@ApiModel和@ApiModelProperty
---
src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt | 85 +++++++++++++++++++++++++++++-------------
1 files changed, 58 insertions(+), 27 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt
index 23bcf93..c7db9cf 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt
@@ -7,6 +7,7 @@
import cn.flightfeather.supervision.domain.ds2.entity.LedgerSubType
import cn.flightfeather.supervision.domain.ds2.entity.UserMap
import cn.flightfeather.supervision.domain.ds2.entity.UserinfoTZ
+import cn.flightfeather.supervision.lightshare.vo.AreaVo
import cn.flightfeather.supervision.lightshare.vo.EvaluationSubRuleVo
import org.springframework.beans.BeanUtils
import tk.mybatis.mapper.entity.Example
@@ -28,8 +29,10 @@
* 璁剧疆鏁版嵁婧�
*/
fun setResource(topTaskGuid: String?, sceneType: Int, districtName: String?, townCode: String?) {
- val config = AopDataConfig(topTaskGuid = topTaskGuid, sceneType = sceneType, districtName = districtName,
- townCode = townCode)
+ val config = AopDataConfig(
+ topTaskGuid = topTaskGuid, sceneType = sceneType, districtName = districtName,
+ townCode = townCode
+ )
evaluationScene.config = config
val check = aopSceneTypeCheck.checkSceneType(sceneType)
if (check.first) {
@@ -38,6 +41,12 @@
initUserSource(config)
}
}
+
+// fun setResource(areaVo: AreaVo) {
+// val task = taskRep.findOneTask(areaVo)
+// val taskId = task?.tguid
+// val sceneType = areaVo.scensetypeid?.toInt() ?: throw BizException("鍦烘櫙绫诲瀷鏈缃紝鏃犳硶璇勪及")
+// }
fun setResource(config: AopDataConfig) {
config.sceneType ?: return
@@ -53,8 +62,10 @@
fun setResource(subtask: Subtask) {
val scene = aopDbMapper.scenseMapper.selectByPrimaryKey(subtask.scenseid)
val sceneType = scene.typeid?.toInt()
- val config = AopDataConfig(topTaskGuid = subtask.tguid, sceneType = sceneType,
- districtName = subtask.districtname, townCode = subtask.towncode)
+ val config = AopDataConfig(
+ topTaskGuid = subtask.tguid, sceneType = sceneType,
+ districtName = subtask.districtname, townCode = subtask.towncode
+ )
evaluationScene.config = config
// val check = aopSceneTypeCheck.checkSceneType(sceneType)
this.mode = 0
@@ -65,7 +76,7 @@
/**
* 杞鏁版嵁婧�
*/
- fun loop(callback: (index:Int, evaluationScene: EvaluationScene) -> Unit) {
+ fun loop(callback: (index: Int, evaluationScene: EvaluationScene) -> Unit) {
when (mode) {
0 -> {
sceneSourceList.forEachIndexed { i, scene ->
@@ -77,6 +88,7 @@
} while (evaluationScene.gotoNextSubTask())
}
}
+
1 -> {
userSourceList.forEachIndexed { i, user ->
evaluationScene.clear()
@@ -102,6 +114,7 @@
callback(i, evaluationScene)
}
}
+
1 -> {
userSourceList.forEachIndexed { i, user ->
evaluationScene.clear()
@@ -142,7 +155,7 @@
}
// 鍗曚釜璇勪及瀵硅薄
- inner class EvaluationScene(){
+ inner class EvaluationScene() {
var index = 0
var config: AopDataConfig? = null
@@ -153,7 +166,7 @@
fun setDefaultScene(s: Scense?) {
scene.value = s
- userInfoTZ.fetch = {_,_ ->
+ userInfoTZ.fetch = { _, _ ->
val svUserId = aopDbMapper.userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
createCriteria().andEqualTo("dGuid", scene.value?.guid)
})?.takeIf { m -> m.isNotEmpty() }?.get(0)?.guid
@@ -166,7 +179,7 @@
fun setDefaultUserTZ(u: UserinfoTZ?) {
userInfoTZ.value = u
- scene.fetch = {_,_ ->
+ scene.fetch = { _, _ ->
val svUserId = aopDbMapper.userMapMapper.selectByExample(Example(UserMap::class.java).apply {
createCriteria().andEqualTo("tzUserId", userInfoTZ.value?.guid)
})?.takeIf { m -> m.isNotEmpty() }?.get(0)?.svUserId
@@ -175,15 +188,16 @@
}
}
- val userInfo = InfoProxy<Userinfo>{_,_ ->
+ val userInfo = InfoProxy<Userinfo> { _, _ ->
scene.value?.guid ?: return@InfoProxy null
return@InfoProxy aopDbMapper.userinfoMapper.selectOne(Userinfo().apply {
dGuid = scene.value?.guid
})
}
+
//宸℃煡浠诲姟淇℃伅
var subTaskIndex = 0
- val subTask = InfoProxy<Subtask> {_,_ ->
+ val subTask = InfoProxy<Subtask> { _, _ ->
return@InfoProxy if (subTaskList.value?.isNotEmpty() == true) {
subTaskList.value?.get(subTaskIndex)
} else {
@@ -191,7 +205,7 @@
}
}
- val subTaskList = InfoProxy<List<Subtask>> {_,_ ->
+ val subTaskList = InfoProxy<List<Subtask>> { _, _ ->
return@InfoProxy aopDbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
createCriteria().andEqualTo("scenseid", scene.value?.guid)
// .andBetween("planstarttime", config?.startTime, config?.endTime)
@@ -200,25 +214,28 @@
}
//鐜板満宸℃煡淇℃伅
- val inspection = InfoProxy<Inspection>{_,_ ->
+ val inspection = InfoProxy<Inspection> { _, _ ->
val inspection = Inspection()
inspection.stguid = subTask.value?.stguid
return@InfoProxy aopDbMapper.inspectionMapper.selectOne(inspection)
}
//鍚勫満鏅壒鏈夌殑鍩烘湰淇℃伅
- val baseScene = InfoProxy<BaseScene> {_,_ ->
+ val baseScene = InfoProxy<BaseScene> { _, _ ->
return@InfoProxy when (config?.sceneType.toString()) {
// 鐩戠绯荤粺
Constant.SceneType.TYPE1.value -> {
aopDbMapper.sceneConstructionSiteMapper.selectByPrimaryKey(scene.value?.guid)
}
+
Constant.SceneType.TYPE2.value -> {
aopDbMapper.sceneWharfMapper.selectByPrimaryKey(scene.value?.guid)
}
+
Constant.SceneType.TYPE3.value -> {
aopDbMapper.sceneMixingPlantMapper.selectByPrimaryKey(scene.value?.guid)
}
+
Constant.SceneType.TYPE14.value -> {
aopDbMapper.sceneStorageYardMapper.selectByPrimaryKey(scene.value?.guid)
}
@@ -226,15 +243,17 @@
Constant.SceneType.TYPE5.value -> {
aopDbMapper.restaurantBaseInfoMapper.selectByPrimaryKey(userInfoTZ.value?.guid)
}
+
Constant.SceneType.TYPE6.value -> {
aopDbMapper.vehicleBaseInfoMapper.selectByPrimaryKey(userInfoTZ.value?.guid)
}
+
else -> null
}
}
//鍏蜂綋鐨勯棶棰�
- val problems = InfoProxy<MutableList<Problemlist>> {_,_ ->
+ val problems = InfoProxy<MutableList<Problemlist>> { _, _ ->
if (noRecord()) return@InfoProxy mutableListOf()
return@InfoProxy aopDbMapper.problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
createCriteria().andEqualTo("stguid", subTask.value?.stguid)
@@ -242,7 +261,7 @@
}
//璇勪及鎬诲垎
- val evaluation = InfoProxy<Evaluation> {_,_ ->
+ val evaluation = InfoProxy<Evaluation> { _, _ ->
if (noRecord()) return@InfoProxy null
return@InfoProxy aopDbMapper.evaluationMapper.selectByExample(Example(Evaluation::class.java).apply {
@@ -251,7 +270,7 @@
}
//璇勪及缁嗗垯寰楀垎
- val itemevaluationList = InfoProxy<MutableList<Itemevaluation>> {_,_ ->
+ val itemevaluationList = InfoProxy<MutableList<Itemevaluation>> { _, _ ->
return@InfoProxy aopDbMapper.itemevaluationMapper.selectByExample(Example(Itemevaluation::class.java).apply {
createCriteria().andEqualTo("stguid", subTask.value?.stguid)
})
@@ -282,6 +301,14 @@
createCriteria()
.andEqualTo("tasktypeid", 99)
.andEqualTo("scensetypeid", scene.value?.typeid)
+ and(createCriteria().orEqualTo("provincecode", scene.value?.provincecode).orIsNull("provincecode"))
+ and(createCriteria().orEqualTo("citycode", scene.value?.citycode).orIsNull("citycode"))
+ and(createCriteria().orEqualTo("districtcode", scene.value?.districtcode).orIsNull("districtcode"))
+ and(createCriteria().orEqualTo("towncode", scene.value?.towncode).orIsNull("towncode"))
+ orderBy("towncode").desc()
+ .orderBy("districtcode").desc()
+ .orderBy("citycode").desc()
+ .orderBy("provincecode").desc()
})
if (rule.isNotEmpty()) {
this@EvaluationScene.baseRule.value = rule[0]
@@ -342,7 +369,7 @@
val rules = InfoProxy<MutableList<Pair<EvaluationSubRuleVo, MutableList<EvaluationSubRuleVo>>>>()
//蹇呭~鍙拌处鏁伴噺
- val ledgerCount = InfoProxy<Int>(config?.sceneType.toString()) {_, cacheMap ->
+ val ledgerCount = InfoProxy<Int>(config?.sceneType.toString()) { _, cacheMap ->
val tzSceneType = Constant.SceneType.typeMap(scene.value?.typeid)
val list = aopDbMapper.ledgerSubTypeMapper.selectCountByExample(Example(LedgerSubType::class.java).apply {
createCriteria().andEqualTo("lScenetype", tzSceneType).andEqualTo("lNeedupdate", true)
@@ -352,7 +379,7 @@
}
//鐢ㄦ埛瀹為檯鎻愪氦鍙拌处鏁伴噺
- val ledgerRecords = InfoProxy<List<LedgerRecord>> {_,_ ->
+ val ledgerRecords = InfoProxy<List<LedgerRecord>> { _, _ ->
return@InfoProxy aopDbMapper.ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply {
createCriteria().andEqualTo("lrYear", config?.year)
.andEqualTo("lrMonth", config?.month)
@@ -371,9 +398,12 @@
orderBy("planstarttime").desc()
})
if (r.isNotEmpty()) {
- val thisMonth = LocalDateTime.ofInstant(subTask.value?.planstarttime?.toInstant(), ZoneId.systemDefault())
- .withDayOfMonth(1).toLocalDate()
- val lastMonth = LocalDateTime.ofInstant(r[0]?.planstarttime?.toInstant(), ZoneId.systemDefault()).withDayOfMonth(1).toLocalDate()
+ val thisMonth =
+ LocalDateTime.ofInstant(subTask.value?.planstarttime?.toInstant(), ZoneId.systemDefault())
+ .withDayOfMonth(1).toLocalDate()
+ val lastMonth =
+ LocalDateTime.ofInstant(r[0]?.planstarttime?.toInstant(), ZoneId.systemDefault()).withDayOfMonth(1)
+ .toLocalDate()
if (lastMonth.plusMonths(1).isEqual(thisMonth)) {
last.subTask.value = r[0]
}
@@ -451,12 +481,13 @@
if (defaultValue != null) {
return defaultValue
} else if (!fetched && _value == null) {
- _value = if (cacheMap.containsKey(key) && LocalDateTime.now().minusDays(1).isBefore(cacheTimeStamp)) {
- cacheMap[key]
- } else {
- cacheTimeStamp = LocalDateTime.now()
- fetch(defaultValue, cacheMap)
- }
+ _value =
+ if (cacheMap.containsKey(key) && LocalDateTime.now().minusDays(1).isBefore(cacheTimeStamp)) {
+ cacheMap[key]
+ } else {
+ cacheTimeStamp = LocalDateTime.now()
+ fetch(defaultValue, cacheMap)
+ }
fetched = true
}
return _value
--
Gitblit v1.9.3