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) } }