feiyu02
2024-08-02 16b961c2210fe29fd494ac1f9d830dd93503961f
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/InspectionServiceImpl.kt
@@ -1,9 +1,11 @@
package cn.flightfeather.supervision.lightshare.service.impl
import cn.flightfeather.supervision.common.exception.BizException
import cn.flightfeather.supervision.domain.ds1.entity.Inspection
import cn.flightfeather.supervision.domain.ds1.mapper.InspectionMapper
import cn.flightfeather.supervision.common.utils.DateUtil
import cn.flightfeather.supervision.common.utils.UUIDGenerator
import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
import cn.flightfeather.supervision.lightshare.service.*
import cn.flightfeather.supervision.lightshare.vo.*
import org.springframework.beans.BeanUtils
@@ -12,7 +14,10 @@
import tk.mybatis.mapper.entity.Example
@Service
class InspectionServiceImpl(val inspectionMapper: InspectionMapper) : InspectionService {
class InspectionServiceImpl(
    val inspectionMapper: InspectionMapper,
    private val taskRep: TaskRep,
) : InspectionService {
    @Autowired
    lateinit var problemlistService: ProblemlistService
@@ -29,35 +34,10 @@
    @Autowired
    lateinit var subtaskService: SubtaskService
    private val dateUtil = DateUtil()
    //获取污染场景版本主页的监管情况展示内容
    override fun getInspectionInfoByScene(sceneId: String, topTaskId: String): InspectionInfoVo {
        val maps = inspectionMapper.getInspectionInfoByScene(sceneId, topTaskId)
        val inspectionInfoVo = InspectionInfoVo()
        if (maps.isNotEmpty()) {
            val map = maps[0]
            if (map.isNotEmpty()) {
                inspectionInfoVo.topTaskid = map["topTaskId"].toString()
                inspectionInfoVo.topTaskName = map["topTaskName"].toString()
                inspectionInfoVo.sceneId = map["sceneId"].toString()
                inspectionInfoVo.sceneName = map["sceneName"].toString()
                inspectionInfoVo.inspectionId = map["inspectionId"].toString()
                inspectionInfoVo.subtaskId = map["subtaskId"].toString()
                inspectionInfoVo.inspected = map["isInspected"].toString().equals("1")
                map["inspectionTime"]?.let {
                    val time = it.toString()
                    inspectionInfoVo.inspectionTime = dateUtil.StringToString(time, DateUtil.DateStyle.YYYY_MM_DD)
                }
                inspectionInfoVo.inspectionTimes = map["inspectionTimes"].toString().toInt()
                inspectionInfoVo.promised = map["isPromised"].toString().equals("1")
                inspectionInfoVo.changed = map["isChanged"].toString().equals("1")
                inspectionInfoVo.unChangedCount = map["unChangedCount"].toString().toInt()
                inspectionInfoVo.changedCount = map["changedCount"].toString().toInt()
                inspectionInfoVo.promisedTime = map["promisedTime"].toString()
            }
        }
        return inspectionInfoVo
    override fun getInspectionInfoByScene(sceneId: String, topTaskId: String): InspectionInfoVo? {
        val resList = inspectionMapper.getInspectionInfoByScene(sceneId, topTaskId)
        return if (resList.isNotEmpty()) resList[0] else InspectionInfoVo()
    }
    //根据巡查ID获取问题列表
@@ -96,7 +76,7 @@
        val example = Example(Inspection::class.java)
        val criteria = example.createCriteria()
        criteria.andEqualTo("sguid", id)
        criteria.andLessThan("executionstarttime", DateUtil().StringToDate(date))
        criteria.andLessThan("executionstarttime", DateUtil.StringToDate(date))
        //添加巡查按执行时间排序*****
        example.orderBy("executionstarttime").desc()
        //**************************
@@ -241,12 +221,14 @@
    override fun delete(id: String): Int = inspectionMapper.deleteByPrimaryKey(id)
    override fun getStatistic(topTaskId: String, sceneTypeId: String): BaseResponse<List<InspectionStatisticVo>> {
    override fun getStatistic(topTaskId: String, sceneTypeId: String): List<InspectionStatisticVo> {
        val result = inspectionMapper.getStatistic(topTaskId, sceneTypeId)
        return if (result.isNotEmpty()) {
            BaseResponse(true, data = result)
        } else {
            BaseResponse(false)
        }
        return result.ifEmpty { throw BizException("无巡查记录") }
    }
    override fun getStatistic(areaVo: AreaVo): List<InspectionStatisticVo> {
        areaVo.scensetypeid ?: throw BizException("请求参数requestBody中场景类型scensetypeid不能为空")
        val topTask = taskRep.findOneTask(areaVo) ?: throw BizException("未找到相关巡查总任务")
        return getStatistic(topTask.tguid!!, areaVo.scensetypeid!!)
    }
}