package cn.flightfeather.supervision.lightshare.service.impl
|
|
import cn.flightfeather.supervision.business.autooutput.datasource.AopDbMapper
|
import cn.flightfeather.supervision.common.utils.Constant
|
import cn.flightfeather.supervision.common.utils.QueryByCache
|
import cn.flightfeather.supervision.domain.ds1.entity.*
|
import cn.flightfeather.supervision.lightshare.service.DataProdBaseService
|
import cn.flightfeather.supervision.lightshare.vo.ProblemListVo
|
import cn.flightfeather.supervision.lightshare.vo.dataprod.*
|
import org.springframework.beans.BeanUtils
|
import org.springframework.stereotype.Service
|
import tk.mybatis.mapper.entity.Example
|
|
/**
|
*
|
* @date 2025/9/15
|
* @author feiyu02
|
*/
|
@Service
|
class DataProdBaseServiceImpl(private val aopDbMapper: AopDbMapper) : DataProdBaseService {
|
|
override fun getSceneInfo(queryOpt: QueryOpt): List<DPSceneInfo> {
|
return QueryByCache.queryCache(
|
cache = { return@queryCache null },
|
calculate = {
|
val res = mutableListOf<DPSceneInfo>()
|
val objList = aopDbMapper.monitorobjectversionMapper.selectByExample(Example(Monitorobjectversion::class.java).apply {
|
createCriteria().andEqualTo("tid", queryOpt.topTaskId)
|
})
|
if (objList.isEmpty()) return@queryCache emptyList<DPSceneInfo>()
|
|
val guidList = objList.map { it.sguid }
|
val baseScene = aopDbMapper.scenseMapper.selectByExample(Example(Scense::class.java).apply {
|
createCriteria().andIn("guid", guidList)
|
.andEqualTo("typeid", queryOpt.sceneTypeId)
|
orderBy("typeid").orderBy("index")
|
})
|
baseScene.groupBy { it.typeid }.forEach { (typeid, sceneList) ->
|
when (typeid.toString()) {
|
Constant.SceneType.TYPE1.value -> {
|
val subScene = aopDbMapper.sceneConstructionSiteMapper.selectByExample(Example(SceneConstructionSite::class.java).apply {
|
createCriteria().andIn("sGuid", sceneList.map { it.guid })
|
})
|
sceneList.forEach {
|
val sub = subScene.find { sub-> sub.getsGuid() == it.guid }
|
res.add(DPSceneInfo().apply {
|
this.scene = it
|
this.subScene = sub
|
this.status = sub?.csStatus
|
this.statusBool = sub?.csStatus == "建设中"
|
this.stage = sub?.siExtension1
|
})
|
}
|
}
|
Constant.SceneType.TYPE2.value -> {
|
val subScene = aopDbMapper.sceneWharfMapper.selectByExample(Example(SceneWharf::class.java).apply {
|
createCriteria().andIn("sGuid", sceneList.map { it.guid })
|
})
|
sceneList.forEach {
|
val sub = subScene.find { sub-> sub.getsGuid() == it.guid }
|
res.add(DPSceneInfo().apply {
|
this.scene = it
|
this.subScene = sub
|
this.status = sub?.getwStatus()
|
this.statusBool = sub?.getwStatus() == "营运中"
|
})
|
}
|
}
|
Constant.SceneType.TYPE3.value -> {
|
val subScene = aopDbMapper.sceneMixingPlantMapper.selectByExample(Example(SceneMixingPlant::class.java).apply {
|
createCriteria().andIn("sGuid", sceneList.map { it.guid })
|
})
|
sceneList.forEach {
|
val sub = subScene.find { sub-> sub.getsGuid() == it.guid }
|
res.add(DPSceneInfo().apply {
|
this.scene = it
|
this.subScene = sub
|
this.status = sub?.mpStatus
|
this.statusBool = sub?.mpStatus == "营运中"
|
})
|
}
|
}
|
Constant.SceneType.TYPE14.value -> {
|
val subScene = aopDbMapper.sceneStorageYardMapper.selectByExample(Example
|
(SceneStorageYard::class.java).apply {
|
createCriteria().andIn("sGuid", sceneList.map { it.guid })
|
})
|
sceneList.forEach {
|
val sub = subScene.find { sub-> sub.getsGuid() == it.guid }
|
res.add(DPSceneInfo().apply {
|
this.scene = it
|
this.subScene = sub
|
this.status = sub?.syStatus
|
this.statusBool = sub?.syStatus == "营运中"
|
})
|
}
|
}
|
else -> {
|
sceneList.forEach {
|
res.add(DPSceneInfo().apply {
|
this.scene = it
|
})
|
}
|
}
|
}
|
}
|
return@queryCache res
|
}
|
)
|
}
|
|
override fun getEvaluateInfo(queryOpt: QueryOpt): List<DPEvaluateInfo> {
|
return QueryByCache.queryCache(
|
cache = { return@queryCache null },
|
calculate = {
|
val res = mutableListOf<DPEvaluateInfo>()
|
val subtaskList = aopDbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
|
createCriteria().andEqualTo("tguid", queryOpt.topTaskId)
|
})
|
if (subtaskList.isEmpty()) return@queryCache emptyList<DPEvaluateInfo>()
|
|
val sceneList = aopDbMapper.scenseMapper.selectByExample(Example(Scense::class.java).apply {
|
createCriteria().andIn("guid", subtaskList.map { it.scenseid })
|
.andEqualTo("typeid", queryOpt.sceneTypeId)
|
})
|
|
val validSubtaskList = subtaskList.filter { sceneList.find { scene -> scene.guid == it.scenseid } != null }
|
|
aopDbMapper.evaluationMapper.selectByExample(Example(Evaluation::class.java).apply {
|
createCriteria().andIn("stguid", validSubtaskList.map { it.stguid })
|
}).forEach {
|
res.add(DPEvaluateInfo().apply {
|
val scene = sceneList.find { sce-> sce.guid == it.sguid }
|
index = scene?.index
|
subTask = validSubtaskList.find { sub-> sub.stguid == it.stguid }?.apply {
|
towncode = scene?.towncode
|
townname = scene?.townname
|
}
|
evaluate = it
|
val score = it.resultscorebef?.toIntOrNull() ?: -1
|
scoreLevel = when {
|
score in 0..39 -> Constant.EvaluationLevel.D.text
|
score in 40..89 -> Constant.EvaluationLevel.C.text
|
score in 90..99 -> Constant.EvaluationLevel.B.text
|
score >= 100 -> Constant.EvaluationLevel.A.text
|
else -> ""
|
}
|
})
|
}
|
res.sortBy { it.index }
|
return@queryCache res
|
},
|
)
|
}
|
|
override fun getInspectionInfo(queryOpt: QueryOpt): List<DPInspectionInfo> {
|
return QueryByCache.queryCache(
|
cache = { return@queryCache null },
|
calculate = {
|
val res = mutableListOf<DPInspectionInfo>()
|
val subtaskList = aopDbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
|
createCriteria().andEqualTo("tguid", queryOpt.topTaskId)
|
})
|
if (subtaskList.isEmpty()) return@queryCache emptyList<DPInspectionInfo>()
|
|
val sceneList = aopDbMapper.scenseMapper.selectByExample(Example(Scense::class.java).apply {
|
createCriteria().andIn("guid", subtaskList.map { it.scenseid })
|
.andEqualTo("typeid", queryOpt.sceneTypeId)
|
})
|
val validSubtaskList = subtaskList.filter { sceneList.find { scene -> scene.guid == it.scenseid } != null }
|
|
val problemList = aopDbMapper.problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
|
createCriteria().andIn("stguid", validSubtaskList.map { it.stguid })
|
})
|
|
val problemTypeList = aopDbMapper.problemtypeMapper.selectByExample(Example(Problemtype::class.java)
|
.apply { createCriteria().andIn("guid", problemList.map { it.ptguid }) })
|
|
validSubtaskList.forEach {
|
res.add(DPInspectionInfo().apply {
|
val scene = sceneList.find { sce-> sce.guid == it.scenseid }
|
index = scene?.index
|
subTask = it.apply {
|
towncode = scene?.towncode
|
townname = scene?.townname
|
}
|
problems = problemList.filter { problem-> problem.stguid == it.stguid }.map { problem->
|
val problemListVo = ProblemListVo()
|
BeanUtils.copyProperties(problem, problemListVo)
|
problemListVo.apply {
|
problemTypeList.find { type-> type.guid == problem.ptguid }?.let {
|
typeid = it.typeid
|
typename = it.typename
|
}
|
}
|
// TODO 媒体文件
|
}
|
})
|
}
|
res.sortBy { it.index }
|
return@queryCache res
|
},
|
)
|
}
|
|
override fun getMonitorDataInfo(queryOpt: QueryOpt): List<DPMonitorDataInfo> {
|
return QueryByCache.queryCache(
|
cache = { return@queryCache null },
|
calculate = {
|
val res = mutableListOf<DPMonitorDataInfo>()
|
val sceneIdList = aopDbMapper.monitorobjectversionMapper.selectByExample(Example(Monitorobjectversion::class.java).apply {
|
createCriteria().andEqualTo("tid", queryOpt.topTaskId)
|
}).map { it.sguid }
|
if (sceneIdList.isEmpty()) return@queryCache res
|
|
val sceneList = aopDbMapper.scenseMapper.selectByExample(Example(Scense::class.java).apply {
|
createCriteria().andIn("guid", sceneIdList)
|
.andEqualTo("typeid", queryOpt.sceneTypeId)
|
})
|
|
aopDbMapper.dustDataResultMapper.selectByExample(Example(DustDataResult::class.java).apply {
|
createCriteria().andBetween("drTime", queryOpt.startTime, queryOpt.endTime)
|
.andIn("drSceneId", sceneList.map { it.guid })
|
}).forEach {
|
res.add(DPMonitorDataInfo().apply {
|
scene = sceneList.find { scene -> scene.guid == it?.drSceneId }
|
data = it
|
})
|
}
|
|
return@queryCache res
|
},
|
)
|
}
|
}
|