From b6c29718e10e25a6a49fe9538f554371e1560720 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期一, 25 七月 2022 15:50:22 +0800 Subject: [PATCH] 1. 调试监管统计文件下载接口; 2. 新增自动评分刷新接口; 3. 针对前端页面,调整部分接口 --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt | 145 +++++++++++++++++++++++++++++++++++++----------- 1 files changed, 112 insertions(+), 33 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt index dbcdd84..4aee9a5 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt @@ -1,8 +1,17 @@ package cn.flightfeather.supervision.lightshare.service.impl +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.business.report.template.* import cn.flightfeather.supervision.common.utils.* import cn.flightfeather.supervision.domain.ds1.entity.* import cn.flightfeather.supervision.domain.ds1.mapper.* +import cn.flightfeather.supervision.domain.ds2.mapper.LedgerRecordMapper +import cn.flightfeather.supervision.domain.ds2.mapper.LedgerSubTypeMapper +import cn.flightfeather.supervision.domain.ds2.mapper.UserMapMapper import cn.flightfeather.supervision.lightshare.service.SearchService import cn.flightfeather.supervision.lightshare.vo.* import com.github.pagehelper.PageHelper @@ -12,6 +21,9 @@ import java.io.File import java.io.FileInputStream import java.io.FileOutputStream +import java.io.OutputStream +import java.net.URLEncoder +import java.nio.charset.Charset import java.nio.charset.StandardCharsets import java.util.* import javax.servlet.http.HttpServletResponse @@ -22,54 +34,121 @@ */ @Service class SearchServiceImpl( - val userinfoMapper: UserinfoMapper, - val subtaskMapper: SubtaskMapper, - val scenseMapper: ScenseMapper, - val sceneConstructionSiteMapper: SceneConstructionSiteMapper, - val sceneMixingPlantMapper: SceneMixingPlantMapper, - val sceneStorageYardMapper: SceneStorageYardMapper, - val sceneWharfMapper: SceneWharfMapper, - val problemlistMapper: ProblemlistMapper, - val problemtypeMapper: ProblemtypeMapper, - val townMapper: TownMapper, - val mediafileMapper: MediafileMapper, - val scoreMapper: ScoreMapper, - val inspectionMapper: InspectionMapper, - val taskMapper: TaskMapper, - val monitorobjectversionMapper: MonitorobjectversionMapper + val userinfoMapper: UserinfoMapper, + val subtaskMapper: SubtaskMapper, + val scenseMapper: ScenseMapper, + val sceneConstructionSiteMapper: SceneConstructionSiteMapper, + val sceneMixingPlantMapper: SceneMixingPlantMapper, + val sceneStorageYardMapper: SceneStorageYardMapper, + val sceneWharfMapper: SceneWharfMapper, + val problemlistMapper: ProblemlistMapper, + val problemtypeMapper: ProblemtypeMapper, + val townMapper: TownMapper, + val mediafileMapper: MediafileMapper, + val scoreMapper: ScoreMapper, + val inspectionMapper: InspectionMapper, + val taskMapper: TaskMapper, + val monitorobjectversionMapper: MonitorobjectversionMapper, + val evaluationruleMapper: EvaluationruleMapper, + val evaluationsubruleMapper: EvaluationsubruleMapper2, + val evaluationMapper: EvaluationMapper, + val itemevaluationMapper: ItemevaluationMapper, + val ledgerSubTypeMapper: LedgerSubTypeMapper, + val ledgerRecordMapper: LedgerRecordMapper, + val userMapMapper: UserMapMapper, ) : SearchService { private val dateUtil = DateUtil() - override fun writeToFile(config: ExcelConfigVo) { - val fileName = "target/${dateUtil.DateToString(Date(), "yyyy-MM-ddhhmmss")}.xls" + override fun writeToFile(config: ExcelConfigVo, mode:Int) { + 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 (mode) { +// //闂涓庢暣鏀硅窡韪眹鎬昏〃 +// 0 -> ProDetailSummary(dataSource) +// //鍒嗚闀囬棶棰樻暣鏀瑰垎鏋愭眹鎬昏〃 +// 1 -> ProAnalysisSummary(dataSource) +// +// //瑙勮寖鎬ц瘎浼拌鎯呰〃 +// 2 -> ScoreDetailSummary(dataSource) +// //鍒嗚闀囪鑼冩�у垎鏋愯〃 +// 3 -> ScoreAnalysisSummary(dataSource) +// +// //闂涓庢暣鏀瑰垎绫荤粺璁¤〃 +// 4 -> ProTypeDetailSummary(dataSource) +// //闂涓庢暣鏀瑰垎绫绘帓鍚� +// 5 -> ProTypeRankSummary(dataSource) +// //鏈堝害涓昏鎴栧吀鍨嬮棶棰樺垎鏋愯〃 +// 6 -> ProTypeRankMainSummary(dataSource) +// //宸ュ湴鏂藉伐闃舵闂鍒嗙被鍒嗘瀽琛� +// 7 -> ProTypeStatusSummary(dataSource) - val out = FileOutputStream(fileName) -// val heads = getTableTitles(config.sceneType, config.districtCode) -// val contents = getTableContents(config, heads.size) - val r = getTable(2, config) - ExcelUtil.write2(out, r.first, r.second) + 8 -> ReportOne(dataSource) + 9 -> ReportTwo(dataSource) + 10 -> ReportThree(dataSource) + + else -> null + } +// t?.execute() + t?.toFile("target/") } - override fun getExcel(config: ExcelConfigVo, response: HttpServletResponse): HttpServletResponse { + 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) + 2 -> ReportTwo(dataSource) + 3 -> ReportThree(dataSource) - val fileName = "${dateUtil.DateToString(Date(), "yyyy-MM-dd hh:mm:ss")}.xls" + else -> ReportOne(dataSource) + } + val fileName = t.getReportName() + val fName = URLEncoder.encode(fileName, "UTF-8") response.apply { - setHeader("Content-Disposition", "attachment;filename=$fileName") - setHeader("fileName", fileName) + 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 heads = getTableTitles(config.sceneType, config.districtCode) -// val contents = getTableContents(config, heads.size) - val r = getTable(1, config) - val out = response.outputStream - ExcelUtil.write2(out, r.first, r.second) + val p = Constant.DEFAULT_FILE_PATH + "/files/autoscore/" + val file = File(p + fileName) + if (config.forceUpdate || !file.exists()) { + t.toFile(p) + } + response.outputStream.write(file.readBytes()) - return response + return true } override fun getSubTaskDetail(config: ExcelConfigVo): SubTaskTableVo { @@ -517,7 +596,7 @@ //鍘熸湁鐨勭涓�琛岃〃澶村鍔�1琛岃璺ㄥ害,鍚屾椂鏂扮殑绗簩琛岃〃澶存坊鍔犵┖浣� head[0].forEach { (it as ExcelUtil.MyCell).rowSpan++ - h2.add(0, "") +// h2.add(0, "") } //鍚堝苟琛ㄥご head[0].addAll(h1) -- Gitblit v1.9.3