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