1. 调整返回接口的异常捕获类为自定义异常类;
2. 修改AreaVo类中时间参数的类型;
3. 新增文档生成任务类型,并新增文档后台生成任务逻辑;
已修改23个文件
已添加3个文件
已重命名1个文件
326 ■■■■ 文件已修改
src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/AopCreditCode.kt 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/bgtask/AopTaskCtrl.kt 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/bgtask/ReportTaskCtrl.kt 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplateMulti.kt 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/common/exception/ResponseErrorException.kt 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/common/executor/BackgroundTaskCtrl.kt 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/common/executor/BgTaskStatus.kt 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/common/executor/BgTaskType.kt 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/EvaluationRuleRep.kt 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/TaskRep.kt 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/domain/ds2/repository/ComplaintAndPunishmentRep.kt 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/EvaluationService.kt 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/BgTaskServiceImpl.kt 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ComplaintServiceImpl.kt 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt 104 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserMapServiceImpl.kt 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AreaVo.kt 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/BaseResPack.kt 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationController.kt 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-dev.yml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-pro.yml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-test.yml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/cn/flightfeather/supervision/CommonTest.kt 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt
@@ -1,5 +1,6 @@
package cn.flightfeather.supervision.business.autooutput.datasource
import cn.flightfeather.supervision.common.exception.ResponseErrorException
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.domain.ds1.entity.*
import cn.flightfeather.supervision.domain.ds2.entity.LedgerRecord
@@ -85,7 +86,7 @@
    // ä»Žç›‘管系统获取场景
    private fun initSceneSource(config: AopDataConfig) {
        config.topTaskGuid ?: throw IllegalStateException("顶层任务id不能为null")
        config.topTaskGuid ?: throw ResponseErrorException("顶层任务id不能为null")
        this.config = config
        this.mode = 0
        sceneSourceList.clear()
src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/AopCreditCode.kt
@@ -1,6 +1,7 @@
package cn.flightfeather.supervision.business.autooutput.score
import cn.flightfeather.supervision.business.autooutput.datasource.AopDataConfig
import cn.flightfeather.supervision.common.exception.ResponseErrorException
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.domain.ds1.repository.EvaluationRep
import cn.flightfeather.supervision.domain.ds2.entity.UserinfoTZ
@@ -22,7 +23,7 @@
) {
    fun execute(config: AopDataConfig) {
        if (config.year == null || config.month == null) throw IllegalStateException("环信码评估时必须传递时间条件!")
        if (config.year == null || config.month == null) throw ResponseErrorException("环信码评估时必须传递时间条件!")
        // æ‰¾åˆ°é£žç¾½çŽ¯å¢ƒä¸­éœ€è¦ç”ŸæˆçŽ¯ä¿¡ç çš„æ‰€æœ‰ç«™ç‚¹
        val sceneType = Constant.SceneType.getByValue(config.sceneType.toString())
        val userList = findUsers(config.districtName, sceneType)
src/main/kotlin/cn/flightfeather/supervision/business/bgtask/AopTaskCtrl.kt
ÎļþÃû´Ó src/main/kotlin/cn/flightfeather/supervision/business/autooutput/AopTaskCtrl.kt ÐÞ¸Ä
@@ -1,9 +1,10 @@
package cn.flightfeather.supervision.business.autooutput
package cn.flightfeather.supervision.business.bgtask
import cn.flightfeather.supervision.business.autooutput.dataanalysis.*
import cn.flightfeather.supervision.business.autooutput.datasource.AopDataConfig
import cn.flightfeather.supervision.business.autooutput.score.AopCreditCode
import cn.flightfeather.supervision.business.autooutput.score.AopEvaluation
import cn.flightfeather.supervision.common.exception.ResponseErrorException
import cn.flightfeather.supervision.common.executor.BackgroundTaskCtrl
import cn.flightfeather.supervision.common.executor.BgTaskStatus
import cn.flightfeather.supervision.common.executor.BgTaskType
@@ -11,7 +12,6 @@
import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import org.springframework.stereotype.Component
import java.time.LocalDate
/**
 * è‡ªåŠ¨è¯„ä¼°ä»»åŠ¡ç®¡ç†
@@ -45,10 +45,11 @@
        if (taskId != null) {
            val districtCode = areaVo.districtcode
            val districtName = areaVo.districtname
            val d = LocalDate.parse(areaVo.starttime)
//            val d = LocalDateTime.parse(areaVo.starttime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
            val d = areaVo.starttime ?: throw ResponseErrorException("自动评估任务必须设定时间")
            val year = d.year
            val month = d.monthValue
            val sceneType = areaVo.scensetypeid?.toInt() ?: throw IllegalStateException("场景类型未设置,无法评估")
            val sceneType = areaVo.scensetypeid?.toInt() ?: throw ResponseErrorException("场景类型未设置,无法评估")
            val id = "${BgTaskType.AUTO_SCORE.name}-${districtCode}-${sceneType}"
            val name = "${districtName}${Constant.SceneType.getDes(sceneType)}自动评分"
@@ -68,7 +69,7 @@
            }
            return bgTask.taskStatus
        } else {
            throw IllegalStateException("巡查总任务不存在,无法评估")
            throw ResponseErrorException("巡查总任务不存在,无法评估")
        }
    }
src/main/kotlin/cn/flightfeather/supervision/business/bgtask/ReportTaskCtrl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,41 @@
package cn.flightfeather.supervision.business.bgtask
import cn.flightfeather.supervision.business.report.BaseExcel
import cn.flightfeather.supervision.business.report.DataSource
import cn.flightfeather.supervision.business.report.DbMapper
import cn.flightfeather.supervision.business.report.file.ReportOne
import cn.flightfeather.supervision.business.report.file.ReportThree
import cn.flightfeather.supervision.business.report.file.ReportTwo
import cn.flightfeather.supervision.common.executor.BackgroundTaskCtrl
import cn.flightfeather.supervision.common.executor.BgTaskStatus
import cn.flightfeather.supervision.common.executor.BgTaskType
import cn.flightfeather.supervision.lightshare.vo.ExcelConfigVo
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Component
import java.io.File
import java.net.URLEncoder
/**
 * è‡ªåŠ¨ç”ŸæˆæŠ¥å‘Šä»»åŠ¡ç®¡ç†
 */
@Component
class ReportTaskCtrl(
    private val backgroundTaskCtrl: BackgroundTaskCtrl,
    private val dbMapper: DbMapper,
    @Value("\${filePath}") private val filePath: String,
) {
    fun startTask(baseExcel: BaseExcel, downloadUrl: String): BgTaskStatus {
        val id =
            "${BgTaskType.DOCUMENT.name}-${baseExcel.dataSource.config.districtCode}-${baseExcel.dataSource.config.sceneType}"
        val taskName = baseExcel.getReportName()
        val bgTask = backgroundTaskCtrl.startNewTask(BgTaskType.DOCUMENT, id, taskName) {
            val p = "$filePath/autoscore/"
            baseExcel.toFile(p)
            true
        }
        bgTask.taskStatus.extra = downloadUrl
        return bgTask.taskStatus
    }
}
src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplateMulti.kt
@@ -1,5 +1,6 @@
package cn.flightfeather.supervision.business.report
import cn.flightfeather.supervision.common.exception.ResponseErrorException
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.common.utils.DateUtil
import cn.flightfeather.supervision.common.utils.ExcelUtil
@@ -31,7 +32,7 @@
    open fun execute() {
        if (dataSourceList.isEmpty()) throw IllegalStateException("${templateName}: æ•°æ®æºä¸ºç©º")
        if (dataSourceList.isEmpty()) throw ResponseErrorException("${templateName}: æ•°æ®æºä¸ºç©º")
        //合成表头
        cols.forEach {
            it.combineHead(head, dataSourceList[0])
src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt
@@ -11,6 +11,7 @@
import cn.flightfeather.supervision.domain.ds2.mapper.LedgerSubTypeMapper
import cn.flightfeather.supervision.domain.ds2.mapper.UserMapMapper
import cn.flightfeather.supervision.lightshare.vo.ExcelConfigVo
import org.springframework.stereotype.Component
import tk.mybatis.mapper.entity.Example
import java.time.LocalDateTime
import java.time.ZoneId
@@ -390,6 +391,7 @@
    }
}
@Component
data class DbMapper(
    val scenseMapper: ScenseMapper,
    val problemlistMapper: ProblemlistMapper,
src/main/kotlin/cn/flightfeather/supervision/common/exception/ResponseErrorException.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,13 @@
package cn.flightfeather.supervision.common.exception
/**
 * å…è®¸æŽ¥å£è¿”回的业务层面的错误
 */
class ResponseErrorException : Exception {
    constructor():super()
    constructor(message: String) : super(message)
    constructor(message: String, cause: Throwable) : super(message, cause)
    constructor(cause: Throwable) : super(cause)
    constructor(message: String, cause: Throwable, enableSuppression: Boolean, writableStackTrace: Boolean)
            : super(message, cause, enableSuppression, writableStackTrace)
}
src/main/kotlin/cn/flightfeather/supervision/common/executor/BackgroundTaskCtrl.kt
@@ -1,5 +1,6 @@
package cn.flightfeather.supervision.common.executor
import cn.flightfeather.supervision.common.exception.ResponseErrorException
import org.springframework.stereotype.Component
import java.time.LocalDateTime
import java.util.concurrent.ConcurrentHashMap
@@ -20,13 +21,13 @@
    /**
     * æ–°å¢žä»»åŠ¡
     */
    @Throws(IllegalStateException::class)
    @Throws(ResponseErrorException::class)
    fun newTask(type: BgTaskType, id: String, name: String, task: () -> Boolean): BgTask {
        if (!taskCollection.containsKey(type)) {
            taskCollection[type] = ConcurrentHashMap<String, BgTask>()
        }
        val taskSet = taskCollection[type]!!
        if (taskSet.containsKey(id)) throw IllegalStateException("无法创建任务, ä»»åŠ¡[${name}]的id重复")
        if (taskSet.containsKey(id)) throw ResponseErrorException("无法创建任务, ä»»åŠ¡[${name}]的id重复")
        val t = BgTask(type, id, name, task)
        taskSet[id] = t
        return t
@@ -35,20 +36,20 @@
    /**
     * å¼€å§‹ä»»åŠ¡
     */
    @Throws(IllegalStateException::class)
    @Throws(ResponseErrorException::class)
    fun startTask(type: BgTaskType, id: String): BgTask {
        val taskSet = taskCollection[type] ?: throw throw IllegalStateException("无法开启任务,该任务类型[${type.des}]不存在")
        val t = taskSet[id] ?: throw IllegalStateException("无法开启任务,该任务[${id}]不存在")
        val taskSet = taskCollection[type] ?: throw throw ResponseErrorException("无法开启任务,该任务类型[${type.des}]不存在")
        val t = taskSet[id] ?: throw ResponseErrorException("无法开启任务,该任务[${id}]不存在")
        return startTask(t)
    }
    @Throws(IllegalStateException::class)
    @Throws(ResponseErrorException::class)
    fun startTask(task: BgTask): BgTask {
        if (task.taskStatus.status != TaskStatus.WAITING) {
            if (task.taskStatus.status == TaskStatus.RUNNING) {
                throw IllegalStateException("无法开启任务,任务[${task.name}]正在执行")
                throw ResponseErrorException("无法开启任务,任务[${task.name}]正在执行")
            } else {
                throw IllegalStateException("无法开启任务,任务[${task.name}]已结束")
                throw ResponseErrorException("无法开启任务,任务[${task.name}]已结束")
            }
        } else {
            task.ready()
@@ -60,7 +61,7 @@
    /**
     * æ–°å¢žå¹¶å¼€å§‹ä»»åŠ¡
     */
    @Throws(IllegalStateException::class)
    @Throws(ResponseErrorException::class)
    fun startNewTask(type: BgTaskType, id: String, name: String, task: () -> Boolean): BgTask {
        val t = newTask(type, id, name, task)
        return startTask(t)
@@ -95,11 +96,11 @@
    /**
     * å¼ºåˆ¶å…³é—­ä»»åŠ¡
     */
    @Throws(IllegalStateException::class)
    @Throws(ResponseErrorException::class)
    fun shutDownTask(type: BgTaskType, id: String?): List<BgTaskStatus?> {
        val taskMap = taskCollection[type] ?: throw IllegalStateException("无法关闭任务,任务类型[${type.des}]未创建")
        val taskMap = taskCollection[type] ?: throw ResponseErrorException("无法关闭任务,任务类型[${type.des}]未创建")
        return if (id != null) {
            val task = taskMap[id] ?: throw IllegalStateException("无法关闭任务,任务[${id}]不存在")
            val task = taskMap[id] ?: throw ResponseErrorException("无法关闭任务,任务[${id}]不存在")
            task.shutdown()
            listOf(task.taskStatus)
        } else {
@@ -112,11 +113,11 @@
        }
    }
    @Throws(IllegalStateException::class)
    @Throws(ResponseErrorException::class)
    fun removeTask(type: BgTaskType, id: String): Boolean {
        val statusList = shutDownTask(type, id)
        if (statusList.isNotEmpty()) {
            val s = statusList.first() ?: throw IllegalStateException("无法移除任务,任务不存在")
            val s = statusList.first() ?: throw ResponseErrorException("无法移除任务,任务不存在")
            taskCollection[s.type]?.remove(s.id)
            return true
        }
src/main/kotlin/cn/flightfeather/supervision/common/executor/BgTaskStatus.kt
@@ -45,6 +45,9 @@
            }
        }
    // é¢å¤–自定义附带信息
    var extra: Any? = null
}
enum class TaskStatus {
src/main/kotlin/cn/flightfeather/supervision/common/executor/BgTaskType.kt
@@ -4,7 +4,9 @@
    //测试任务
    TEST(0, "测试任务"),
    //自动评分
    AUTO_SCORE(1, "自动评估任务");
    AUTO_SCORE(1, "自动评估任务"),
    //文档生成
    DOCUMENT(2, "生成文档任务");
    companion object {
@@ -13,6 +15,7 @@
            return when (index) {
                TEST.index -> TEST
                AUTO_SCORE.index -> AUTO_SCORE
                DOCUMENT.index -> DOCUMENT
                else -> null
            }
        }
src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/EvaluationRuleRep.kt
@@ -20,11 +20,11 @@
        return evaluationruleMapper.selectByExample(Example(Evaluationrule::class.java).apply {
            createCriteria().andEqualTo("tasktypeid", areaEvaVo.taskTypeId)
                .andEqualTo("scensetypeid", areaEvaVo.scensetypeid)
                .andEqualTo("provincecode", areaEvaVo.provincecode)
                .andEqualTo("citycode", areaEvaVo.citycode)
                .andEqualTo("districtcode", areaEvaVo.districtcode)
                .andEqualTo("towncode", areaEvaVo.towncode)
                .andEqualTo("isuse", true)
            and(createCriteria().orEqualTo("provincecode", areaEvaVo.provincecode).orIsNull("provincecode"))
            and(createCriteria().orEqualTo("citycode", areaEvaVo.citycode).orIsNull("citycode"))
            and(createCriteria().orEqualTo("districtcode", areaEvaVo.districtcode).orIsNull("districtcode"))
            and(createCriteria().orEqualTo("towncode", areaEvaVo.towncode).orIsNull("towncode"))
        })
    }
}
src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/TaskRep.kt
@@ -5,7 +5,9 @@
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import org.springframework.stereotype.Repository
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.util.*
@Repository
@@ -13,7 +15,7 @@
    private fun exampleTask(areaVo: AreaVo): Task?{
        areaVo.starttime ?: return null
        val mStart = LocalDate.parse(areaVo.starttime).withDayOfMonth(1).atStartOfDay()
        val mStart = areaVo.starttime!!.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0)
        val mEnd = mStart.plusMonths(1).minusSeconds(1)
        return Task().apply {
            provincecode = areaVo.provincecode
src/main/kotlin/cn/flightfeather/supervision/domain/ds2/repository/ComplaintAndPunishmentRep.kt
@@ -6,6 +6,8 @@
import cn.flightfeather.supervision.lightshare.vo.ComplaintVo
import cn.flightfeather.supervision.lightshare.vo.PunishmentVo
import org.springframework.stereotype.Repository
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.util.*
/**
@@ -30,6 +32,12 @@
        return findComplaint(tzUserIdList, s, e)
    }
    fun findComplaint(tzUserIdList: List<String?>, sTime: LocalDateTime?, eTime: LocalDateTime?): List<ComplaintVo?> {
        val s = sTime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
        val e = eTime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
        return findComplaint(tzUserIdList, s, e)
    }
    fun findComplaint(tzUserIdList: List<String?>, sTime: String?, eTime: String?): List<ComplaintVo?> {
        return complaintMapper.findComplaint(tzUserIdList, sTime, eTime)
    }
@@ -44,6 +52,12 @@
        return findPunishment(tzUserIdList, s, e)
    }
    fun findPunishment(tzUserIdList: List<String?>, sTime: LocalDateTime?, eTime: LocalDateTime?): List<PunishmentVo?> {
        val s = sTime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
        val e = eTime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
        return findPunishment(tzUserIdList, s, e)
    }
    fun findPunishment(tzUserIdList: List<String?>, sTime: String?, eTime: String?): List<PunishmentVo?> {
        return punishmentMapper.findPunishment(tzUserIdList, sTime, eTime)
    }
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/EvaluationService.kt
@@ -7,6 +7,8 @@
import cn.flightfeather.supervision.lightshare.vo.AutoScoreResultVo
import cn.flightfeather.supervision.lightshare.vo.BaseResponse
import cn.flightfeather.supervision.lightshare.vo.EvaluateResVo
import springfox.documentation.annotations.ApiIgnore
import javax.servlet.http.HttpServletResponse
interface EvaluationService {
@@ -39,4 +41,6 @@
    fun autoEvaluate(areaVo: AreaVo): BgTaskStatus?
    fun findAutoEvaluation(areaVo: AreaVo): List<AutoScoreResultVo?>?
    fun downloadAutoEvaluation(areaVo: AreaVo, response: HttpServletResponse): Boolean
}
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/BgTaskServiceImpl.kt
@@ -1,5 +1,6 @@
package cn.flightfeather.supervision.lightshare.service.impl
import cn.flightfeather.supervision.common.exception.ResponseErrorException
import cn.flightfeather.supervision.common.executor.BackgroundTaskCtrl
import cn.flightfeather.supervision.common.executor.BgTaskConditionVo
import cn.flightfeather.supervision.common.executor.BgTaskStatus
@@ -15,21 +16,21 @@
    }
    override fun startTask(condition: BgTaskConditionVo): BgTaskStatus? {
        condition.type ?: throw IllegalStateException("任务类型不能为空")
        condition.id ?: throw IllegalStateException("任务id不能为空")
        condition.type ?: throw ResponseErrorException("任务类型不能为空")
        condition.id ?: throw ResponseErrorException("任务id不能为空")
        val task = backgroundTaskCtrl.startTask(condition.type!!, condition.id!!)
        return task.taskStatus
    }
    override fun shutDownTask(condition: BgTaskConditionVo): List<BgTaskStatus?> {
        condition.type ?: throw IllegalStateException("任务类型不能为空")
        condition.type ?: throw ResponseErrorException("任务类型不能为空")
        return backgroundTaskCtrl.shutDownTask(condition.type!!, condition.id)
    }
    override fun removeTask(condition: BgTaskConditionVo): Boolean {
        condition.type ?: throw IllegalStateException("任务类型不能为空")
        condition.id ?: throw IllegalStateException("任务id不能为空")
        condition.type ?: throw ResponseErrorException("任务类型不能为空")
        condition.id ?: throw ResponseErrorException("任务id不能为空")
        return backgroundTaskCtrl.removeTask(condition.type!!, condition.id!!)
    }
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ComplaintServiceImpl.kt
@@ -1,5 +1,6 @@
package cn.flightfeather.supervision.lightshare.service.impl
import cn.flightfeather.supervision.common.exception.ResponseErrorException
import cn.flightfeather.supervision.domain.ds1.repository.SceneRep
import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
import cn.flightfeather.supervision.domain.ds1.repository.UserInfoSVRep
@@ -36,7 +37,7 @@
            }
            //以飞羽监管系统中的用户为主体
            2 -> {
                val task = taskRep.findOneTask(areaVo) ?: throw IllegalStateException("当前查询条件下未找到对应顶层任务")
                val task = taskRep.findOneTask(areaVo) ?: throw ResponseErrorException("当前查询条件下未找到对应顶层任务")
                val scenes = sceneRep.findScene(task.tguid!!, areaVo.scensetypeid?.toInt(), areaVo.towncode)
                    .map { it?.guid }
                val idList = userInfoSVRep.findUser(scenes).map { it?.guid }
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/EvaluationServiceImpl.kt
@@ -1,11 +1,16 @@
package cn.flightfeather.supervision.lightshare.service.impl
import cn.flightfeather.supervision.business.AutoScore2
import cn.flightfeather.supervision.business.autooutput.AopTaskCtrl
import cn.flightfeather.supervision.business.bgtask.AopTaskCtrl
import cn.flightfeather.supervision.business.autooutput.score.AopEvaluation
import cn.flightfeather.supervision.common.executor.BackgroundTaskCtrl
import cn.flightfeather.supervision.business.bgtask.ReportTaskCtrl
import cn.flightfeather.supervision.business.report.DataSource
import cn.flightfeather.supervision.business.report.DbMapper
import cn.flightfeather.supervision.business.report.file.ReportOne
import cn.flightfeather.supervision.business.report.file.ReportThree
import cn.flightfeather.supervision.business.report.file.ReportTwo
import cn.flightfeather.supervision.common.exception.ResponseErrorException
import cn.flightfeather.supervision.common.executor.BgTaskStatus
import cn.flightfeather.supervision.common.executor.BgTaskType
import cn.flightfeather.supervision.domain.ds1.entity.Domainitem
import cn.flightfeather.supervision.domain.ds1.entity.Evaluation
import cn.flightfeather.supervision.domain.ds1.entity.Subtask
@@ -18,15 +23,17 @@
import cn.flightfeather.supervision.domain.ds1.repository.EvaluationRep
import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
import cn.flightfeather.supervision.lightshare.service.EvaluationService
import cn.flightfeather.supervision.lightshare.service.SearchService
import cn.flightfeather.supervision.lightshare.service.SubtaskService
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import cn.flightfeather.supervision.lightshare.vo.AutoScoreResultVo
import cn.flightfeather.supervision.lightshare.vo.BaseResponse
import cn.flightfeather.supervision.lightshare.vo.EvaluateResVo
import cn.flightfeather.supervision.lightshare.vo.*
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Service
import tk.mybatis.mapper.entity.Example
import java.io.File
import java.net.URLEncoder
import java.util.*
import javax.servlet.http.HttpServletResponse
import kotlin.Comparator
@Service
@@ -35,14 +42,21 @@
    private val evaluationRep: EvaluationRep,
    private val taskRep: TaskRep,
    private val aopTaskCtrl: AopTaskCtrl,
    private val searchService: SearchService,
    private val dbMapper: DbMapper,
    @Value("\${filePath}") private val filePath: String,
    private val reportTaskCtrl: ReportTaskCtrl,
) : EvaluationService {
    @Autowired
    lateinit var subtaskService: SubtaskService
    @Autowired
    lateinit var domainitemMapper: DomainitemMapper
    @Autowired
    lateinit var subtaskMapper: SubtaskMapper
    @Autowired
    lateinit var aopEvaluation: AopEvaluation
    private var isAutoScoreRunning = false
@@ -53,12 +67,13 @@
        var areaVolist = mutableListOf<EvaluateResVo>()
        //考核类型是规范考核
        if (evaluationlist.isNotEmpty() &&
                Objects.equals(evaluationlist.get(0).ertype, Constant.RuleType.STANDARD.value)) {
            Objects.equals(evaluationlist.get(0).ertype, Constant.RuleType.STANDARD.value)
        ) {
            //获取规范考核的考核界限(问题数量)
            val example = Example(Domainitem::class.java)
            val criteria = example.createCriteria()
            criteria.andEqualTo("dcguid", Domain.STANDARDLEVEL.value)
            val standardlevel:String? = domainitemMapper.selectByExample(example).get(0).value
            val standardlevel: String? = domainitemMapper.selectByExample(example).get(0).value
            //按街镇计算严重不规范场景数量并按百分比排序
            while (evaluationlist.isNotEmpty()) {
                val tmplist = mutableListOf<Evaluation>()
@@ -68,9 +83,9 @@
                val evaluation = evaluationlist.get(0)//获取一种街镇
                var areaVo = EvaluateResVo()
                areaVo = transform(areaVo, evaluation)
                while (iterator.hasNext()){
                while (iterator.hasNext()) {
                    val tmp = iterator.next()
                    if (Objects.equals(tmp.towncode, evaluation.towncode)){
                    if (Objects.equals(tmp.towncode, evaluation.towncode)) {
                        if (tmp.resultscorebef!!.toInt() >= standardlevel!!.toInt())
                            areaVo.notstandardnum++
                        areaVo.allsensenum++
@@ -84,7 +99,8 @@
        }
        //考核类型是评分考核
        else if (evaluationlist.isNotEmpty() &&
                Objects.equals(evaluationlist.get(0).ertype, Constant.RuleType.SCORE.value)){
            Objects.equals(evaluationlist.get(0).ertype, Constant.RuleType.SCORE.value)
        ) {
            //获取评分考核的评分界限
            val example = Example(Domainitem::class.java)
            val criteria = example.createCriteria()
@@ -100,7 +116,7 @@
                val evaluation = evaluationlist.get(0)//获取一种街镇
                var areaVo = EvaluateResVo()
                areaVo = transform(areaVo, evaluation)
                while (iterator.hasNext()){
                while (iterator.hasNext()) {
                    val tmp = iterator.next()
                    if (Objects.equals(tmp.towncode, evaluation.towncode)) {
                        if (tmp.resultscorebef!!.toInt() < scorelevellist.get(scorelevellist.size - 1).text!!.toInt())
@@ -136,7 +152,7 @@
    override fun delete(id: String): Int = evaluationMapper.deleteByPrimaryKey(id)
    //获取指定区域(顶层任务)指定场景的评分信息
    fun getRankInfo(tguid: String, scensetypeid: String?, ruletypeid: ByteArray?):MutableList<Evaluation>{
    fun getRankInfo(tguid: String, scensetypeid: String?, ruletypeid: ByteArray?): MutableList<Evaluation> {
        val evaluationlist = mutableListOf<Evaluation>()
        val subtaskVolist = subtaskService.findByTaskID(tguid)
        subtaskVolist.forEach {
@@ -148,11 +164,11 @@
                criteria.andEqualTo("scensetypeid", scensetypeid)
            if (ruletypeid != null)//评分类型
                criteria.andEqualTo("ertype", ruletypeid)
            else{
            else {
                criteria.andEqualTo("ertype", Constant.RuleType.STANDARD.value)
                val result = evaluationMapper.selectByExample(example)//查询是否有规范性评分表
                //没有规范表就查询评分表
                if (result.isEmpty()){
                if (result.isEmpty()) {
                    val example1 = Example(Evaluation::class.java)
                    val criteria1 = example1.createCriteria()
                    criteria1.andEqualTo("stguid", it.stguid)//子任务id
@@ -162,8 +178,7 @@
                    val result1 = evaluationMapper.selectByExample(example1)
                    if (result1.size == 1)
                        evaluationlist.add(result1.get(0))
                }
                else
                } else
                    if (result.size == 1)
                        evaluationlist.add(result.get(0))
            }
@@ -172,7 +187,7 @@
    }
    //Evaluation传递数据给AreaVo
    fun transform(areaVo: EvaluateResVo, evaluation: Evaluation):EvaluateResVo{
    fun transform(areaVo: EvaluateResVo, evaluation: Evaluation): EvaluateResVo {
        areaVo.provincecode = evaluation.provincecode
        areaVo.provincename = evaluation.provincename
        areaVo.citycode = evaluation.citycode
@@ -185,15 +200,15 @@
    }
    //按街道严重不规范场景百分比排序
    fun sort(areaVolist: MutableList<EvaluateResVo>):MutableList<EvaluateResVo>{
        Collections.sort(areaVolist, object : Comparator<EvaluateResVo>{
    fun sort(areaVolist: MutableList<EvaluateResVo>): MutableList<EvaluateResVo> {
        Collections.sort(areaVolist, object : Comparator<EvaluateResVo> {
            override fun compare(o1: EvaluateResVo?, o2: EvaluateResVo?): Int {
                var num1 = 0.0
                if (o1!!.allsensenum != 0)
                    num1 = (o1.notstandardnum/o1.allsensenum).toDouble()
                    num1 = (o1.notstandardnum / o1.allsensenum).toDouble()
                var num2 = 0.0
                if (o2!!.allsensenum != 0)
                    num2 = (o2.notstandardnum/o2.allsensenum).toDouble()
                    num2 = (o2.notstandardnum / o2.allsensenum).toDouble()
                return compareValues(num1, num2)
            }
        })
@@ -270,8 +285,47 @@
    override fun findAutoEvaluation(areaVo: AreaVo): List<AutoScoreResultVo?>? {
        //1. æŸ¥æ‰¾åŽ†å²è®°å½•ï¼ŒæŸ¥çœ‹è¯„ä¼°æ˜¯å¦å·²å­˜åœ¨
        areaVo.scensetypeid ?: throw IllegalStateException("查询时必须选择一个场景类型")
        val task = taskRep.findOneTask(areaVo) ?: throw IllegalStateException("查询时必须选择一个场景类型")
//        areaVo.scensetypeid ?: throw ResponseErrorException("查询时必须选择一个场景类型")
//        val task = taskRep.findOneTask(areaVo) ?: throw ResponseErrorException("查询时必须选择一个场景类型")
        return evaluationRep.findAutoScore(areaVo)
    }
    override fun downloadAutoEvaluation(areaVo: AreaVo, response: HttpServletResponse): Boolean {
        areaVo.scensetypeid ?: throw ResponseErrorException("必须选择一个场景类型")
        val topTask = taskRep.findOneTask(areaVo) ?: throw ResponseErrorException("未找到符合条件的顶层任务")
        val config = ExcelConfigVo(
            topTask.tguid ?: "",
            topTask.starttime,
            topTask.endtime,
            topTask.provincecode,
            topTask.citycode,
            topTask.districtcode,
            topTask.towncode,
            areaVo.scensetypeid?.toInt()
        )
        val dataSource = DataSource(config, dbMapper)
        val t = ReportTwo(dataSource)
        val fileName = t.getReportName()
        val p = "$filePath/autoscore/"
        val file = File(p + fileName)
        if (config.forceUpdate || !file.exists()) {
            val downloadUrl = "/autoscore/${fileName}"
            reportTaskCtrl.startTask(t, downloadUrl)
            return false
        } else {
            val fName = Base64.getEncoder().encodeToString(fileName.toByteArray())
            response.apply {
                setHeader("Content-Disposition", "attachment;filename=$fName")
                setHeader("fileName", fName)
                addHeader("Access-Control-Expose-Headers", "fileName")
                contentType = "application/vnd.ms-excel;charset=UTF-8"
                setHeader("Pragma", "no-cache")
                setHeader("Cache-Control", "no-cache")
                setDateHeader("Expires", 0)
            }
            response.outputStream.write(file.readBytes())
            return true
        }
    }
}
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt
@@ -116,8 +116,8 @@
    override fun getStatisticalResult(areaVo: AreaVo): List<StatisticsVo> {
        val districtcode = areaVo.districtcode
        val sceneType = areaVo.scensetypeid
        val startTime = areaVo.starttime
        val endTime = areaVo.endtime
        val startTime = areaVo.starttime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
        val endTime = areaVo.endtime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
        val maps = problemlistMapper.getStatisticalResult(districtcode,startTime, endTime, sceneType)
        val statisticsVos = mutableListOf<StatisticsVo>()
        maps.forEach {
@@ -146,7 +146,12 @@
//                .andGreaterThanOrEqualTo("endtime", areaVo.endtime)
//                .andEqualTo("districtcode", areaVo.districtcode)
        val chargeInfoVo = ChargeInfoVo()
        val sql = "select T_GUID, T_Name from tm_t_task where TS_GUID IS NULL and T_StartTime <= '" + areaVo.starttime + "' and T_EndTime >= '" + areaVo.endtime + "' and T_DistrictCode = '" + areaVo.districtcode +"'"
        val sTime = areaVo.starttime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
        val eTime = areaVo.endtime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
        val sql =
            "select T_GUID, T_Name from tm_t_task where TS_GUID IS NULL and T_StartTime <= '" + sTime + "' and T_EndTime" +
                    " >= '" + eTime + "' and T_DistrictCode = '" + areaVo.districtcode + "'"
        val maps1 = taskMapper.selectSE(sql)
        var topTaskId = String()
        var topTaskName = String()
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt
@@ -17,6 +17,7 @@
import cn.flightfeather.supervision.lightshare.vo.*
import com.github.pagehelper.PageHelper
import org.springframework.beans.BeanUtils
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Service
import tk.mybatis.mapper.entity.Example
import java.io.File
@@ -55,7 +56,9 @@
        val ledgerSubTypeMapper: LedgerSubTypeMapper,
        val ledgerRecordMapper: LedgerRecordMapper,
        val userMapMapper: UserMapMapper,
        val taskService: TaskService
        val taskService: TaskService,
        @Value("\${filePath}") var filePath: String,
        @Value("\${imgPath}") var imgPath: String
) : SearchService {
    private val dateUtil = DateUtil()
@@ -122,7 +125,7 @@
            setDateHeader("Expires", 0)
        }
        val p = Constant.DEFAULT_FILE_PATH + "/files/autoscore/"
        val p = "$filePath/autoscore/"
        val file = File(p + fileName)
        if (config.forceUpdate || !file.exists()) {
            t.toFile(p)
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserMapServiceImpl.kt
@@ -1,6 +1,7 @@
package cn.flightfeather.supervision.lightshare.service.impl
import cn.flightfeather.supervision.business.autooutput.dataanalysis.AopDataDeviceMap
import cn.flightfeather.supervision.common.exception.ResponseErrorException
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.common.utils.UUIDGenerator
import cn.flightfeather.supervision.domain.ds1.entity.Userinfo
@@ -97,7 +98,7 @@
            }
            //以飞羽监管系统中的用户为主体
            2 -> {
                val task = taskRep.findOneTask(areaVo) ?: throw IllegalStateException("当前查询条件下未找到对应顶层任务")
                val task = taskRep.findOneTask(areaVo) ?: throw ResponseErrorException("当前查询条件下未找到对应顶层任务")
                val scenes = sceneRep.findScene(task.tguid!!, areaVo.scensetypeid?.toInt(), areaVo.towncode)
                    .map { it?.guid }
                userInfoSVRep.findUser(scenes).map { it?.guid }
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/AreaVo.kt
@@ -1,6 +1,8 @@
package cn.flightfeather.supervision.lightshare.vo
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonInclude
import java.time.LocalDateTime
/**
 * åŒºåŸŸæ¡ä»¶
@@ -17,9 +19,11 @@
    var towncode: String? = null
    var townname: String? = null
    // æ—¶é—´èŒƒå›´
    var starttime: String? = null
    var endtime: String? = null
    // æ—¶é—´èŒƒå›´,格式yyyy-MM-dd HH:mm:ss
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    var starttime: LocalDateTime? = null
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    var endtime: LocalDateTime? = null
    // åœºæ™¯åç§°
    var sceneName: String? = null
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/BaseResPack.kt
@@ -1,5 +1,6 @@
package cn.flightfeather.supervision.lightshare.web
import cn.flightfeather.supervision.common.exception.ResponseErrorException
import cn.flightfeather.supervision.lightshare.vo.BaseResponse
import cn.flightfeather.supervision.lightshare.vo.DataHead
@@ -19,7 +20,7 @@
        } else {
            BaseResponse(true, data = res)
        }
    } catch (e: IllegalStateException) {
    } catch (e: ResponseErrorException) {
        BaseResponse(false, message = e.message ?: "")
    }
}
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationController.kt
@@ -6,6 +6,8 @@
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.web.bind.annotation.*
import springfox.documentation.annotations.ApiIgnore
import javax.servlet.http.HttpServletResponse
@Api(tags = ["EvaluationController"], description = "评估总分API接口")
@RestController
@@ -65,4 +67,9 @@
    @ApiOperation(value = "根据区域范围获取自动评估历史记录")
    @PostMapping("/auto/record")
    fun findAutoEvaluation(@RequestBody areaVo: AreaVo) = resPack { evaluationService.findAutoEvaluation(areaVo) }
    @ApiOperation(value = "下载自动评估结果")
    @PostMapping("/auto/record/download")
    fun downloadAutoEvaluation(@RequestBody areaVo: AreaVo, @ApiIgnore response: HttpServletResponse) =
        resPack { evaluationService.downloadAutoEvaluation(areaVo, response) }
}
src/main/resources/application-dev.yml
@@ -17,4 +17,5 @@
      v2:
        enabled: true
imgPath: target
filePath: target
src/main/resources/application-pro.yml
@@ -11,4 +11,5 @@
      username: ledger
      password: ledger_fxxchackxr
imgPath: D:/02product/04supervision/images/
filePath: D:/02product/04supervision/files/
src/main/resources/application-test.yml
@@ -26,3 +26,6 @@
    swagger:
      v2:
        enabled: true
imgPath: C:\02product\supervision\images
filePath: C:\02product\supervision\files
src/test/kotlin/cn/flightfeather/supervision/CommonTest.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,15 @@
package cn.flightfeather.supervision
import org.junit.Test
import java.util.*
class CommonTest {
    @Test
    fun foo1() {
        val fName = Base64.getEncoder().encodeToString("2024å¹´01月静安区工地-规范性评估与分析清单.xls".toByteArray())
        val dName = String(Base64.getDecoder().decode(fName))
        println(fName)
        println(dName)
    }
}