feiyu02
2024-04-25 0392c333ed3d987cb2ab3dac4e1a972cff405f21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
    }
 
}