feiyu02
2025-11-14 c03e1d823eb86c856ecbe40d8d2180ffce7c7b0f
2025.11.14
新增值域的增删改接口
已修改11个文件
201 ■■■■ 文件已修改
src/main/kotlin/cn/flightfeather/supervision/config/RestExceptionHandler.kt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/DomaincatalogService.kt 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/DomainitemService.kt 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdBaseServiceImpl.kt 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdSingleSceneServiceImpl.kt 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DomaincatalogServiceImpl.kt 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DomainitemServiceImpl.kt 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/dataprod/DPChangeInfo.kt 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/dataprod/DPProblemRecurrence.kt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DomaincatalogController.kt 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DomainitemController.kt 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/config/RestExceptionHandler.kt
@@ -23,6 +23,7 @@
    @ExceptionHandler(Exception::class)
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    fun exception(e: Exception): BaseResponse<String> {
        e.printStackTrace()
        return BaseResponse.fail("500", e)
    }
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/DomaincatalogService.kt
@@ -13,9 +13,9 @@
    fun findAll(): MutableList<DomaincatalogVo>
    fun save(domaincatalog: Domaincatalog): Int
    fun save(domaincatalog: Domaincatalog): Domaincatalog
    fun update(domaincatalog: Domaincatalog): Int
    fun update(domaincatalog: Domaincatalog): Domaincatalog
    fun delete(id: String): Int
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/DomainitemService.kt
@@ -9,9 +9,9 @@
    fun findAll(): MutableList<DomainitemVo>
    fun save(domainitem: Domainitem): Int
    fun save(domainitem: Domainitem): Domainitem
    fun update(domainitem: Domainitem): Int
    fun update(domainitem: Domainitem): Domainitem
    fun delete(id: String): Int
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdBaseServiceImpl.kt
@@ -164,6 +164,20 @@
                val res = mutableListOf<DPInspectionInfo>()
                val subtaskList = aopDbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
                    createCriteria().andEqualTo("tguid", queryOpt.topTaskId)
                        .andEqualTo("provincecode", queryOpt.provinceCode)
                        .andEqualTo("citycode", queryOpt.cityCode)
                        .andEqualTo("districtcode", queryOpt.districtCode)
                        .apply {
//                            queryOpt.topTaskId?.let { topTaskId ->
//                                andEqualTo("tguid", topTaskId)
//                            }
                            queryOpt.startTime?.let { startTime ->
                                andGreaterThanOrEqualTo("planstarttime", startTime)
                            }
                            queryOpt.endTime?.let { endTime ->
                                andLessThanOrEqualTo("planstarttime", endTime)
                            }
                        }
                })
                if (subtaskList.isEmpty()) return@queryCache emptyList<DPInspectionInfo>()
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DataProdSingleSceneServiceImpl.kt
@@ -10,7 +10,6 @@
import cn.flightfeather.supervision.lightshare.vo.dataprod.DPChangeInfo
import cn.flightfeather.supervision.lightshare.vo.dataprod.DPProblemRecurrence
import cn.flightfeather.supervision.lightshare.vo.dataprod.QueryOptSingle
import cn.flightfeather.supervision.lightshare.vo.dataprod.base.DPInspectionInfo
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Service
import tk.mybatis.mapper.entity.Example
@@ -24,7 +23,7 @@
class DataProdSingleSceneServiceImpl(private val aopDbMapper: AopDbMapper) : DataProdSingleSceneService {
    // 整改要求最大耗时(天)
    private val maxChangeTime = 3
    private val MAX_CHANGE_TIME = 3
    override fun getChangeInfo(option: QueryOptSingle): DPChangeInfo {
        return QueryByCache.queryCache(
@@ -41,21 +40,44 @@
                })
                return@queryCache DPChangeInfo().apply {
                    subTasks = subtaskList
                    problems = problemList.map {problem ->
                    problems = problemList.map { problem ->
                        val problemListVo = ProblemListVo()
                        BeanUtils.copyProperties(problem, problemListVo)
                        problemListVo
                    }
                    proCount = problemList.size
                    changeCount = problemList.count { it.ischanged == true }
                    changePer = if (proCount == 0) 0.0 else changeCount.toDouble() / proCount
                    changeTime = problemList
                        .filter { it.ischanged == true }
                        .maxOf { (it.changedtime?.time?:0L) - (it?.time?.time?:0L) }.toInt()
                        .div(1000 * 60 * 60 * 24)
                    val eff = if (changeTime == 0) 1.0 else maxChangeTime.toDouble() / changeTime
                    changeEfficiency = if (eff > 1.0) 1.0 else eff
                    val changeTimeList = mutableListOf<Long>()
                    problemList.forEach { p ->
                        if (p.ischanged != true) return@forEach
                        // 整改耗时(天)
                        val day = ((p.changedtime?.time ?: 0L) - (p?.time?.time ?: 0L)).div(1000 * 60 * 60 * 24)
                        changeTimeList.add(day)
                        // 及时现场整改
                        if (day <= 1) {
                            immeChangeCount++
                        }
                        // 常态/规范整改(48小时内整改)
                        else if (day < MAX_CHANGE_TIME) {
                            normalChangeCount++
                        }
                        // 最终整改
                        changeCount++
                    }
                    immeChangePer = if (proCount == 0) 0.0 else immeChangeCount.toDouble() / proCount
                    normalChangePer = if (proCount == 0) 0.0 else normalChangeCount.toDouble() / proCount
                    changePer = if (proCount == 0) 0.0 else changeCount.toDouble() / proCount
                    if (changeTimeList.isNotEmpty()) {
                        changeTime = changeTimeList.maxOrNull()?.toInt() ?: 0
                        val eff = if (changeTime == 0) 1.0 else MAX_CHANGE_TIME.toDouble() / changeTime
                        changeEfficiency = if (eff > 1.0) 1.0 else eff
                        avgChangeTime = changeTimeList.average().toInt()
                        val effAvg = if (avgChangeTime == 0) 1.0 else MAX_CHANGE_TIME.toDouble() / avgChangeTime
                        avgChangeEfficiency = if (effAvg > 1.0) 1.0 else effAvg
                    }
                }
            }
        )
@@ -70,35 +92,38 @@
            cache = { return@queryCache null },
            calculate = {
                val problemList = aopDbMapper.problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
                    createCriteria().andEqualTo("scenseid", option.sceneId)
                        .andBetween("planstarttime", option.startTime, option.endTime)
                    orderBy("planstarttime").desc()
                    createCriteria().andEqualTo("sguid", option.sceneId)
                        .andBetween("time", option.startTime, option.endTime)
                    orderBy("time").desc()
                })
                if (problemList.isEmpty()) return@queryCache emptyList()
                val problemTypeList = aopDbMapper.problemtypeMapper.selectByExample(Example(Problemtype::class.java)
                    .apply { createCriteria().andIn("guid", problemList.map { it.ptguid }) })
                val problemTypeList = aopDbMapper.problemtypeMapper.selectByExample(
                    Example(Problemtype::class.java)
                        .apply { createCriteria().andIn("guid", problemList.map { it.ptguid }) })
                val problemMap = problemList
                    .filter {
                        val type = problemTypeList.find { type-> type.guid == it.ptguid }
                        val type = problemTypeList.find { type -> type.guid == it.ptguid }
                        type?.typename != "道路扬尘" || type.description == "工地内多条道路明显泥痕/泥泞/积尘/遗撒"
                    }.groupBy { problem ->
                    val type = problemTypeList.find { type-> type.guid == problem.ptguid } ?: return@groupBy null
                    /**
                     * 2025.10.30 目前根据业务要求,在工地类型中,“道路扬尘”问题出现概率非常高,
                     * 因此该问题在做重复性统计时, 只统计用其子类型"工地内多条道路明显泥痕/泥泞/积尘/遗撒"为分类类型
                     */
                    if (type.typename == "道路扬尘") {
                        val type = problemTypeList.find { type -> type.guid == problem.ptguid } ?: return@groupBy null
//                    /**
//                     * 2025.10.30 目前根据业务要求,在工地类型中,“道路扬尘”问题出现概率非常高,
//                     * 因此该问题在做重复性统计时, 只统计用其子类型"工地内多条道路明显泥痕/泥泞/积尘/遗撒"为分类类型
//                     */
//                    if (type.typename == "道路扬尘") {
//                        type.description
//                    } else {
//                        type.typename
//                    }
                        type.description
                    } else {
                        type.typename
                    }
                }
                return@queryCache problemMap.map { (key, value) ->
                    val type = problemTypeList.find { type-> type.guid == value.first().ptguid }
                    val type = problemTypeList.find { type -> type.guid == value.first().ptguid }
                    DPProblemRecurrence().apply {
                        problemTag = key
                        problemType = type
                        this.problemList = value
                        count = value.size
                        changeCount = value.count { it.ischanged == true }
                        changePer = if (count == 0) 0.0 else changeCount.toDouble() / count
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DomaincatalogServiceImpl.kt
@@ -1,5 +1,6 @@
package cn.flightfeather.supervision.lightshare.service.impl
import cn.flightfeather.supervision.common.exception.BizException
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.common.utils.UUIDGenerator
import cn.flightfeather.supervision.domain.ds1.entity.*
@@ -33,7 +34,9 @@
    //获取全部
    override fun findAll(): MutableList<DomaincatalogVo> {
        val domaincatalogVoList = mutableListOf<DomaincatalogVo>()
        val domaincatalogList = domaincatalogMapper.selectAll()
        val domaincatalogList = domaincatalogMapper.selectByExample(Example(Domaincatalog::class.java).apply {
            orderBy("name")
        })
        domaincatalogList.forEach {
            val domaincatalogVo = DomaincatalogVo()
            BeanUtils.copyProperties(it,domaincatalogVo)
@@ -42,9 +45,30 @@
        return domaincatalogVoList
    }
    override fun save(domaincatalog: Domaincatalog): Int = domaincatalogMapper.insert(domaincatalog)
    override fun save(domaincatalog: Domaincatalog): Domaincatalog{
        if (domaincatalog.guid == null) {
            domaincatalog.guid = UUIDGenerator.generate16ShortUUID()
        }
        if (domaincatalogMapper.insert(domaincatalog) == 1) {
            return domaincatalog
        } else {
            throw BizException("值域项新增失败")
        }
    }
    override fun update(domaincatalog: Domaincatalog): Int = domaincatalogMapper.updateByPrimaryKey(domaincatalog)
    override fun update(domaincatalog: Domaincatalog): Domaincatalog{
        // 2025.11.11 新增版本号对比逻辑,若更新的配置信息版本号等于数据历史版本号,才能更新
        val oldOne = domaincatalogMapper.selectByPrimaryKey(domaincatalog.guid)
        if ((domaincatalog.version == oldOne.version)) {
            // 更新时,版本号递增
            domaincatalog.version = (domaincatalog.version ?: 0) + 1
            domaincatalogMapper.updateByPrimaryKey(domaincatalog)
            return domaincatalog
        } else {
            throw BizException("版本号不一致,更新失败")
        }
    }
    override fun delete(id: String): Int = domaincatalogMapper.deleteByPrimaryKey(id)
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/DomainitemServiceImpl.kt
@@ -1,6 +1,8 @@
package cn.flightfeather.supervision.lightshare.service.impl
import cn.flightfeather.supervision.common.exception.BizException
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.common.utils.UUIDGenerator
import cn.flightfeather.supervision.domain.ds1.entity.Domainitem
import cn.flightfeather.supervision.domain.ds1.mapper.DomainitemMapper
import cn.flightfeather.supervision.lightshare.service.DomainitemService
@@ -45,7 +47,7 @@
        val domainitemVoList = mutableListOf<DomainitemVo>()
        val domainitem = Domainitem()
        domainitem.dcguid = guid
        val domainitemList = domainitemMapper.select(domainitem)
        val domainitemList = domainitemMapper.select(domainitem).also { it.sortBy { it1 -> it1.index } }
        domainitemList.forEach {
            val domainitemVo = DomainitemVo()
            BeanUtils.copyProperties(it, domainitemVo)
@@ -74,9 +76,29 @@
        return domainitemVoList
    }
    override fun save(domainitem: Domainitem): Int = domainitemMapper.insert(domainitem)
    override fun save(domainitem: Domainitem): Domainitem{
        if (domainitem.guid == null) {
            domainitem.guid = UUIDGenerator.generate16ShortUUID()
        }
        return if (domainitemMapper.insert(domainitem) == 1) {
            domainitem
        } else {
            throw BizException("值域项新增失败")
        }
    }
    override fun update(domainitem: Domainitem): Int = domainitemMapper.updateByPrimaryKey(domainitem)
    override fun update(domainitem: Domainitem): Domainitem {
        // 2025.11.11 新增版本号对比逻辑,若更新的配置信息版本号等于数据历史版本号,才能更新
        val oldOne = domainitemMapper.selectByPrimaryKey(domainitem.guid)
        if ((domainitem.remark == oldOne.remark)) {
            // 更新时,版本号递增
            domainitem.remark = domainitem.remark?.toInt()?.plus(1)?.toString() ?: "1"
            domainitemMapper.updateByPrimaryKey(domainitem)
        } else {
            throw BizException("值域项更新失败,版本号不一致")
        }
        return domainitem
    }
    override fun delete(id: String): Int = domainitemMapper.deleteByPrimaryKey(id)
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/dataprod/DPChangeInfo.kt
@@ -35,13 +35,25 @@
    @ApiModelProperty(value = "问题列表")
    var problems: List<ProblemListVo>? = null
    @ApiModelProperty(value = "问题数")
    @ApiModelProperty(value = "最终问题数")
    var proCount = 0
    @ApiModelProperty(value = "整改数")
    @ApiModelProperty(value = "及时现场整改数")
    var immeChangeCount = 0
    @ApiModelProperty(value = "及时现场整改率")
    var immeChangePer: Double = 0.0
    @ApiModelProperty(value = "常态/规范整改数(48小时内整改)")
    var normalChangeCount = 0
    @ApiModelProperty(value = "常态/规范整改率")
    var normalChangePer: Double = 0.0
    @ApiModelProperty(value = "最终整改数")
    var changeCount = 0
    @ApiModelProperty(value = "整改率")
    @ApiModelProperty(value = "最终整改率")
    var changePer: Double = 0.0
    @ApiModelProperty(value = "整改耗时(天)(取耗时最长的问题作为最终整改耗时)")
@@ -50,4 +62,10 @@
    // 整改效率 = 整改要求最大耗时 / 整改实际耗时
    @ApiModelProperty(value = "整改效率")
    var changeEfficiency: Double = 0.0
    @ApiModelProperty(value = "平均整改耗时(天)")
    var avgChangeTime: Int = 0
    @ApiModelProperty(value = "平均整改效率")
    var avgChangeEfficiency: Double = 0.0
}
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/dataprod/DPProblemRecurrence.kt
@@ -1,6 +1,8 @@
package cn.flightfeather.supervision.lightshare.vo.dataprod
import cn.flightfeather.supervision.domain.ds1.entity.Problemlist
import cn.flightfeather.supervision.domain.ds1.entity.Problemtype
import cn.flightfeather.supervision.lightshare.vo.ProblemListVo
import io.swagger.annotations.ApiModelProperty
/**
@@ -16,6 +18,9 @@
    @ApiModelProperty(value = "问题类型")
    var problemType: Problemtype? = null
    @ApiModelProperty(value = "问题")
    var problemList: List<Problemlist>? = null
    @ApiModelProperty(value = "出现次数")
    var count = 0
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DomaincatalogController.kt
@@ -16,9 +16,7 @@
    fun getAll() = domaincatalogService.findAll()
    @PutMapping
    fun add(@RequestBody domaincatalog: Domaincatalog):Int {
       return domaincatalogService.save(domaincatalog)
    }
    fun add(@RequestBody domaincatalog: Domaincatalog) = domaincatalogService.save(domaincatalog)
    @PostMapping
    fun update(@RequestBody domaincatalog: Domaincatalog) = domaincatalogService.update(domaincatalog)
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DomainitemController.kt
@@ -66,5 +66,11 @@
    @GetMapping("/name")
    fun getItemByName(
        @ApiParam("值域名称") @RequestParam("name") name:String
    ) = domainitemService.findOneByName(name)
    ) = domainitemService.findByLogName(name)
    @ApiOperation("根据值域类别guid,获取具体的选项")
    @GetMapping("/catalogId")
    fun getItemByCatalogId(
        @ApiParam("值域类别guid") @RequestParam("catalogId") catalogId:String
    ) = domainitemService.findByLogID(catalogId)
}