| | |
| | | import cn.flightfeather.supervision.common.utils.Constant |
| | | import cn.flightfeather.supervision.common.utils.QueryByCache |
| | | import cn.flightfeather.supervision.domain.ds1.entity.SceneConstructionSite |
| | | import cn.flightfeather.supervision.domain.ds1.repository.TaskRep |
| | | import cn.flightfeather.supervision.lightshare.service.DataProdBaseService |
| | | import cn.flightfeather.supervision.lightshare.service.DataProdMiddleService |
| | | import cn.flightfeather.supervision.lightshare.vo.dataprod.QueryOpt |
| | |
| | | import cn.flightfeather.supervision.lightshare.vo.dataprod.middle.DPInspectionSummary |
| | | import cn.flightfeather.supervision.lightshare.vo.dataprod.middle.DPProblemCountByArea |
| | | import cn.flightfeather.supervision.lightshare.vo.dataprod.middle.DPProblemTypeCount |
| | | import org.springframework.beans.BeanUtils |
| | | import org.springframework.stereotype.Service |
| | | |
| | | /** |
| | |
| | | * @author feiyu02 |
| | | */ |
| | | @Service |
| | | class DataProdMiddleServiceImpl(private val dataProdBaseService: DataProdBaseService) : DataProdMiddleService { |
| | | class DataProdMiddleServiceImpl( |
| | | private val dataProdBaseService: DataProdBaseService, private val taskRep: TaskRep, |
| | | ) : DataProdMiddleService { |
| | | |
| | | |
| | | override fun getInspectionSummary(queryOpt: QueryOpt): DPInspectionSummary { |
| | | return QueryByCache.queryCache( |
| | |
| | | when (it.scene?.typeid.toString()) { |
| | | // 对于建筑工地类型,根据其csStatus判断是否停工或完工 |
| | | Constant.SceneType.TYPE1.value -> { |
| | | when ((it.subScene as SceneConstructionSite).csStatus) { |
| | | when ((it.subScene as SceneConstructionSite?)?.csStatus) { |
| | | "停工" -> { |
| | | res.stopSceneCount++ |
| | | } |
| | |
| | | } |
| | | return@queryCache res |
| | | }, |
| | | save = {} |
| | | ) |
| | | } |
| | | |
| | |
| | | return QueryByCache.queryCache( |
| | | cache = { return@queryCache null }, |
| | | calculate = { |
| | | // 查询上一个周期的总任务统计情况 |
| | | val lastTopTask = taskRep.findLastTopTask(queryOpt.topTaskId) |
| | | val lastQueryOpt = QueryOpt() |
| | | BeanUtils.copyProperties(queryOpt, lastQueryOpt) |
| | | lastQueryOpt.topTaskId = lastTopTask?.tguid |
| | | val lastInspectionInfo = dataProdBaseService.getInspectionInfo(lastQueryOpt) |
| | | val lastAllProblemList = lastInspectionInfo.flatMap { it.problems ?: emptyList() } |
| | | val lastAllProblemMap = lastAllProblemList.groupBy { it.typeid } |
| | | |
| | | // 查询当前周期的总任务统计情况 |
| | | val res = mutableListOf<DPProblemTypeCount>() |
| | | val inspectionInfo = dataProdBaseService.getInspectionInfo(queryOpt) |
| | | val allProblemList = inspectionInfo.flatMap { it.problems ?: emptyList() } |
| | |
| | | this.typeName = problemList.firstOrNull()?.typename |
| | | this.count = problemList.size |
| | | this.ratio = problemList.size.toDouble() / allProblemList.size |
| | | this.ratioDiff = |
| | | if (lastAllProblemMap[typeid] == null) { |
| | | this.ratio |
| | | } else { |
| | | this.ratio - lastAllProblemMap[typeid]!!.size.toDouble() / lastAllProblemList.size |
| | | } |
| | | }) |
| | | } |
| | | return@queryCache res |
| | | }, |
| | | save = {} |
| | | ) |
| | | } |
| | | |
| | |
| | | |
| | | return@queryCache res |
| | | }, |
| | | save = {} |
| | | ) |
| | | } |
| | | |
| | |
| | | |
| | | return@queryCache res |
| | | }, |
| | | save = {} |
| | | ) |
| | | } |
| | | } |