| | |
| | | package cn.flightfeather.supervision.lightshare.service.impl |
| | | |
| | | 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 |
| | |
| | | private val sceneRep: SceneRep, |
| | | @Value("\${filePath}") var filePath: String, |
| | | @Value("\${imgPath}") var imgPath: String, |
| | | private val dbMapper: DbMapper, |
| | | private val reportTaskCtrl: ReportTaskCtrl, |
| | | ) : SearchService { |
| | | |
| | | private val dateUtil = DateUtil() |
| | | |
| | | override fun writeToFile(config: ExcelConfigVo, mode: Int) { |
| | | val dbMapper = DbMapper( |
| | |
| | | } |
| | | |
| | | override fun getExcel(config: ExcelConfigVo, response: HttpServletResponse): Boolean { |
| | | val dbMapper = DbMapper( |
| | | scenseMapper, |
| | | problemlistMapper, |
| | | problemtypeMapper, |
| | | subtaskMapper, |
| | | monitorobjectversionMapper, |
| | | sceneConstructionSiteMapper, |
| | | sceneMixingPlantMapper, |
| | | sceneStorageYardMapper, |
| | | sceneWharfMapper, |
| | | taskMapper, |
| | | evaluationruleMapper, evaluationsubruleMapper, evaluationMapper, itemevaluationMapper, |
| | | ledgerSubTypeMapper, ledgerRecordMapper, userinfoMapper, userMapMapper, townMapper |
| | | ) |
| | | val dataSource = DataSource(config, dbMapper) |
| | | val t = when (config.mode) { |
| | | 1 -> ReportOne(dataSource) |
| | |
| | | else -> ReportOne(dataSource) |
| | | } |
| | | val fileName = t.getReportName() |
| | | val fName = URLEncoder.encode(fileName, "UTF-8") |
| | | 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) |
| | | } |
| | | |
| | | val p = "$filePath/autoscore/" |
| | | val file = File(p + fileName) |
| | | if (config.forceUpdate || !file.exists()) { |
| | | t.toFile(p) |
| | | 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 |
| | | } |
| | | response.outputStream.write(file.readBytes()) |
| | | |
| | | return true |
| | | } |
| | | |
| | | override fun getSubTaskDetail(config: ExcelConfigVo): SubTaskTableVo { |
| | |
| | | } |
| | | |
| | | //建立第一层目录,包含所有的任务 |
| | | val time = dateUtil.DateToString(Date(), "yyyy-MM-dd_HH-mm-ss") |
| | | val time = DateUtil.DateToString(Date(), "yyyy-MM-dd_HH-mm-ss") |
| | | var basePath = |
| | | Constant.DEFAULT_FILE_PATH + File.separator + "images" + File.separator + "temp" + File.separator + time |
| | | imgPath + File.separator + "temp" + File.separator + time |
| | | var file = File(basePath) |
| | | var i = 1 |
| | | while (file.exists() && i <= 100) { |
| | |
| | | createCriteria().andEqualTo("businessguid", p.guid) |
| | | }).forEach { m -> |
| | | val picPath = |
| | | Constant.DEFAULT_FILE_PATH + File.separator + "images" + File.separator + m.extension1 + m.guid + ".jpg" |
| | | imgPath + File.separator + m.extension1 + m.guid + ".jpg" |
| | | val fromFile = File(picPath) |
| | | val picName = p.problemname + "_" + p.location + "($y).jpg" |
| | | val toFile = File(pPath + File.separator + picName) |
| | |
| | | override fun downloadPic2(sceneType: Int, topTaskId: String, response: HttpServletResponse): HttpServletResponse { |
| | | //建立第一层目录,包含所有的任务 |
| | | val topTask = taskMapper.selectByPrimaryKey(topTaskId) |
| | | val time = dateUtil.DateToString(Date(), "yyyy-MM-dd_HH-mm-ss") |
| | | val time = DateUtil.DateToString(Date(), "yyyy-MM-dd_HH-mm-ss") |
| | | val basePath = |
| | | Constant.DEFAULT_FILE_PATH + File.separator + "images" + File.separator + "temp" + File.separator + topTask.name |
| | | imgPath + File.separator + "temp" + File.separator + topTask.name |
| | | val file = File(basePath) |
| | | if (!file.exists()) { |
| | | file.mkdirs() |
| | |
| | | |
| | | //建立一个子任务文件夹 |
| | | var subTaskFilePath = "${basePath}${File.separator}(${ |
| | | dateUtil.DateToString( |
| | | DateUtil.DateToString( |
| | | it.planstarttime, |
| | | DateUtil.DateStyle.YYYY_MM_DD_CN |
| | | ) |
| | |
| | | |
| | | u.forEach { f -> |
| | | val picPath = |
| | | Constant.DEFAULT_FILE_PATH + File.separator + "images" + File.separator + f.extension1 + f.guid + ".jpg" |
| | | imgPath + File.separator + f.extension1 + f.guid + ".jpg" |
| | | val fromFile = File(picPath) |
| | | val picName = f.description |
| | | val toFile = File(pPath + File.separator + picName) |
| | |
| | | ledgerSubTypeMapper, ledgerRecordMapper, userinfoMapper, userMapMapper, townMapper |
| | | ) |
| | | val task = |
| | | taskService.getByDistrictCode(config.districtCode, config.startTime)?.takeIf { it.isNotEmpty() }?.get(0) |
| | | taskService.getByDistrictCode(config.districtCode, config.startTime).takeIf { it.isNotEmpty() }?.get(0) |
| | | config.topTaskGuid = task?.tguid ?: "" |
| | | config.allScene = false |
| | | val dataSource = mutableListOf<DataSource>() |
| | | config.sceneType = Constant.SceneType.TYPE1.value.toInt() |
| | | // config.sceneType = Constant.SceneType.TYPE1.value.toInt() |
| | | dataSource.add(DataSource(config, dbMapper)) |
| | | |
| | | // val config2 = config.copy(sceneType = Constant.ScenseType.TYPE2.value.toInt()) |