feiyu02
2025-12-20 5a003a42d2b34e8362910ac1d3e5a8866768e5fe
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt
@@ -13,6 +13,7 @@
import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
import cn.flightfeather.supervision.lightshare.service.MediafileService
import cn.flightfeather.supervision.lightshare.service.ProblemlistService
import cn.flightfeather.supervision.lightshare.service.SubtaskService
import cn.flightfeather.supervision.lightshare.service.TaskService
import cn.flightfeather.supervision.lightshare.vo.*
import com.fasterxml.jackson.core.type.TypeReference
@@ -103,6 +104,36 @@
            }
        }
        return problemListVolistTemp1
    }
    override fun getBySceneMonth(sceneId: String, year: Int?, month: Int?): List<ProblemListVo> {
        var _year = year
        var _month = month
        if (year == null) {
            PageHelper.startPage<Problemlist>(1, 1)
            val lastProblem = problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
                createCriteria().andEqualTo("sguid", sceneId)
                orderBy("time").desc()
            }).takeIf { it.isNotEmpty() }?.get(0)
            if (lastProblem == null) {
                return emptyList()
            } else {
                val lt = LocalDateTime.ofInstant(lastProblem.time?.toInstant(), ZoneId.systemDefault())
                _year = lt.year
                _month = lt.monthValue
            }
        }
        val sT = LocalDateTime.of(_year!!, _month!!, 1, 0, 0, 0, 0)
        val eT = sT.plusMonths(1).minusSeconds(1)
        return problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
            createCriteria().andBetween("time", sT,eT)
                .andEqualTo("sguid", sceneId)
            orderBy("time").desc()
        }).map {
            val problemVo = ProblemListVo();
            BeanUtils.copyProperties(it, problemVo)
            problemVo
        }
    }
    //获取某顶层任务下,某个场景下的问题整改情况
@@ -314,12 +345,12 @@
    override fun delete(id: String): Int = problemlistMapper.deleteByPrimaryKey(id)
    override fun setDeleteStatus(id: String): BaseResponse<Int> {
    override fun setDeleteStatus(id: String): Int {
        val p = problemlistMapper.selectByPrimaryKey(id)
        return when {
            p.ischanged == true -> BaseResponse(false, "问题已整改,无法删除", data = 0)
            p.extension3 != Constant.PROBLEM_UNCHECKED -> BaseResponse(false, "问题已审核,无法删除", data = 0)
            p.ischanged == true -> throw BizException("问题已整改,无法删除")
            p.extension3 != Constant.PROBLEM_UNCHECKED -> throw BizException("问题已审核,无法删除")
            else -> {
                // 2021/4/25 将原来的添加删除状态改为直接删除
//                p.remark = Constant.PROBLEM_DELETED
@@ -333,7 +364,7 @@
                    inspection.problemcount = inspection.problemcount!! - 1
                    inspectionMapper.updateByPrimaryKey(inspection)
                }
                BaseResponse(true, "问题删除成功", data = i)
                i
            }
        }
    }
@@ -372,11 +403,11 @@
        remark: String,
        userId: String,
        userName: String,
    ): BaseResponse<String> {
    ): String {
        if (action !in 0..5) {
            return BaseResponse(false, "非法的操作指令")
            throw BizException("非法的操作指令")
        }
        val p = problemlistMapper.selectByPrimaryKey(pId) ?: return BaseResponse(false, "问题不存在")
        val p = problemlistMapper.selectByPrimaryKey(pId) ?: throw BizException("问题不存在")
        val subtask = p.stguid?.let { subTaskRep.findOne(it) }
        val response = BaseResponse<String>(true)
        var event = ""
@@ -485,15 +516,15 @@
                bizLog.info(WorkStreamLogInfo(userId, userName, event))
            }
        }
        return response
        return if (response.success) "问题审核成功" else throw BizException(response.message)
    }
    override fun newProblem(problem: String, files: Array<MultipartFile>): BaseResponse<String> {
    override fun newProblem(problem: String, files: Array<MultipartFile>): String {
        //json转object
        val problemVo = ObjectMapper().readValue(problem, object : TypeReference<ProblemVo>() {})
        val inspection = inspectionMapper.selectByPrimaryKey(problemVo.insGuid) ?: return BaseResponse(false, "巡查记录不存在")
        val scene = scenseMapper.selectByPrimaryKey(inspection.sguid) ?: return BaseResponse(false, "巡查记录对应场景不存在")
        val inspection = inspectionMapper.selectByPrimaryKey(problemVo.insGuid) ?: throw BizException("巡查记录不存在")
        val scene = scenseMapper.selectByPrimaryKey(inspection.sguid) ?: throw BizException("巡查记录对应场景不存在")
        // 保存问题
        val problemlist = ProblemListVo.newPro(inspection, problemVo, scene)
        problemlistMapper.insert(problemlist)
@@ -513,7 +544,7 @@
            bizLog.info(WorkStreamLogInfo(subtask?.executorguids, subtask?.executorrealtimes, event))
        }
        return BaseResponse(true)
        return "success"
    }
    override fun updateProblem(problem: ProblemListVo, deleteImg: List<String>, files: Array<MultipartFile>): String {
@@ -527,15 +558,15 @@
    }
    override fun changeProblem(problemId: String, files: Array<MultipartFile>): BaseResponse<String> {
    override fun changeProblem(problemId: String, files: Array<MultipartFile>): String {
        // 问题和问题图片合法性检查
        val p = problemlistMapper.selectByPrimaryKey(problemId) ?: return BaseResponse(false, "问题不存在")
        val p = problemlistMapper.selectByPrimaryKey(problemId) ?: throw BizException("问题不存在")
        val mediaFiles = mediafileMapper.selectByExample(Example(Mediafile::class.java).apply {
            createCriteria().andEqualTo("businessguid", p.guid)
                .andEqualTo("businesstypeid", 1)
                .andEqualTo("ischanged", false)
        })
        if (mediaFiles.isEmpty()) return BaseResponse(false, "问题不存在或已整改,无法重复整改")
        if (mediaFiles.isEmpty()) throw BizException("问题不存在或已整改,无法重复整改")
        // 更新问题
        p.apply {
@@ -568,7 +599,7 @@
            }
        }
        return BaseResponse(true)
        return "success"
    }
    override fun updateChange(problemId: String, deleteImg: List<String>, files: Array<MultipartFile>): String {