From b041775dae4438e428d2b70d2b22cfe8c49844fe Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 19 七月 2022 16:22:36 +0800 Subject: [PATCH] 1. 巡查汇总报告功能编写基本完成 --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SearchService.kt | 2 src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportOne.kt | 12 src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportThree.kt | 11 src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportTwo.kt | 12 src/main/kotlin/cn/flightfeather/supervision/business/report/BaseExcel.kt | 36 + src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt | 2 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt | 128 ++++ src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColProChange.kt | 24 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreAnalysisSummary.kt | 176 +++++ src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColLedger.kt | 19 src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStatus.kt | 39 + src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColInspectionInfo.kt | 112 +++ src/main/kotlin/cn/flightfeather/supervision/business/storage/StAutoScore.kt | 6 src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt | 82 ++ src/main/kotlin/cn/flightfeather/supervision/common/utils/FileUtil.kt | 38 + src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt | 48 + src/test/kotlin/cn/flightfeather/supervision/business/fume/AutoScoreTest.kt | 4 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankSummary.kt | 125 ++++ src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColSceneName.kt | 18 src/test/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImplTest.kt | 7 src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTown.kt | 15 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeDetailSummary.kt | 12 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreDetailSummary.kt | 13 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProDetailSummary.kt | 12 src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt | 8 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt | 169 +++++ src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt | 306 +++++++++ src/main/kotlin/cn/flightfeather/supervision/common/utils/Constant.kt | 19 src/main/resources/generator/generatorConfig4ds1.xml | 12 src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt | 109 +++ src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColGrade.kt | 111 +++ src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColProblemDistribution.kt | 54 + src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt | 63 + 33 files changed, 1,746 insertions(+), 58 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt b/src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt index 821485c..6bd2f4e 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt @@ -18,7 +18,7 @@ @Bean fun runner() = ApplicationRunner { - fetchController.run() +// fetchController.run() } } diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt new file mode 100644 index 0000000..c12a5cc --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt @@ -0,0 +1,82 @@ +package cn.flightfeather.supervision.business.report + +import cn.flightfeather.supervision.common.utils.ExcelUtil +import kotlin.math.max + +/** + * 缁熻鏁版嵁鍒楀熀绫� + */ +abstract class BaseCols(){ + + protected var heads = mutableListOf<MutableList<ExcelUtil.MyCell>>() + + //鐢熸垚琛ㄥご + fun getHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> { + heads = onHeads(dataSource) + return heads + } + + abstract fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> + + //鐢熸垚涓�琛屽唴瀹� + fun getOneRow(rowData: DataSource.RowData): List<Any> { + return if (rowData.noRecord()) { + val r = mutableListOf<String>() + repeat(heads.last().size) { r.add(("")) } + r + } else { + onOneRow(rowData) + } + } + + abstract fun onOneRow(rowData: DataSource.RowData): List<Any> + + fun emptyJudge() { + + } + + /** + * 鏂拌�佽〃澶村悎骞� + */ + fun combineHead(oldHeads: MutableList<MutableList<ExcelUtil.MyCell>>, dataSource: DataSource) { + //鍚堝苟琛ㄥご锛岄噰鍙栫畝鍖栭�昏緫锛屽彧鏈夌涓�琛岀殑琛ㄥご浼氳繘琛屽崟鍏冩牸鐨勮法琛屽悎骞� + val newHeads = getHeads(dataSource) + if (oldHeads.isEmpty()) { + newHeads.forEach { oldHeads.add(it) } + } else { + val maxRow = max(oldHeads.size, newHeads.size) + for (i in 0 until maxRow) { + val oH = + //鍙栧凡鏈夎〃澶翠腑鐨勮 + if (i < oldHeads.size) { + oldHeads[i] + } + //鍙栨柊涓�琛岋紝鍚屾椂绗竴琛岃〃澶磋法琛屾暟鍔犱竴 + else { + if (i > 0) { + oldHeads.first().forEach { it.rowSpan++ } + } + val h = mutableListOf<ExcelUtil.MyCell>() + repeat(oldHeads.size) { h.add(ExcelUtil.MyCell("")) } + oldHeads.add(h) + h + } + + val nH = + if (i < newHeads.size) { + newHeads[i] + } else { + if (i > 0) { + newHeads.first().forEach { it.rowSpan++ } + } + val h = mutableListOf<ExcelUtil.MyCell>() + repeat(newHeads.size) { h.add(ExcelUtil.MyCell("")) } + newHeads.add(h) + h + } + + oH.addAll(nH) + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseExcel.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseExcel.kt new file mode 100644 index 0000000..6f4c5b7 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseExcel.kt @@ -0,0 +1,36 @@ +package cn.flightfeather.supervision.business.report + +import org.apache.poi.hssf.usermodel.HSSFWorkbook +import java.io.FileOutputStream +import java.io.OutputStream +import java.util.* + +/** + * 鍚勬ā鏉垮悎骞惰緭鍑轰负鏁翠綋鏂囨。 + */ +abstract class BaseExcel(val dataSource: DataSource) { + + abstract val templates: List<BaseTemplate> + + abstract val fileName: String + + // excel鏂囨。 + private var workbook = HSSFWorkbook() + + fun toFile(path: String) { + val fileName = "${dataSource.areaName()}-${fileName}-${Date().time}.xls" + val out = FileOutputStream(path + fileName) + toOutputStream(out) + } + + fun toOutputStream(out: OutputStream) { + templates.forEach { + it.execute() + it.toWorkBook(workbook) + } + workbook.write(out) + workbook.close() + out.flush() + out.close() + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt index 5e0d3d4..f10a5be 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt @@ -1,14 +1,101 @@ package cn.flightfeather.supervision.business.report -/** - * 鎶ュ憡妯℃澘鍩虹被 - */ -abstract class BaseTemplate { +import cn.flightfeather.supervision.common.utils.Constant +import cn.flightfeather.supervision.common.utils.DateUtil +import cn.flightfeather.supervision.common.utils.ExcelUtil +import cn.flightfeather.supervision.domain.ds1.entity.Problemlist +import org.apache.poi.hssf.usermodel.HSSFWorkbook +import tk.mybatis.mapper.entity.Example +import java.io.FileOutputStream +import java.io.OutputStream +import java.util.* - //鍥哄畾鍒楃粍鍚� - //鍚嶇О - //鍩烘湰淇℃伅 - //闂鎵e垎鍒嗗竷 - //闂鏁存敼鍒嗗竷 - //鐩戠璇︽儏 -} \ No newline at end of file +/** + * excel鎶ュ憡妯℃澘鍩虹被 + */ +// FIXME: 2022/7/15 妯℃澘绠�鍖栵細鍙湁琛ㄥご浼氭秹鍙婂崟鍏冩牸鍚堝苟锛岄粯璁よ〃鍐呭涓病鏈夊悎骞� +abstract class BaseTemplate(val dataSource: DataSource){ + + //鍒楃粍鍚� + abstract val cols: List<BaseCols> + + //妯℃澘鍚嶇О + abstract val templateName: String + + //琛ㄥご + val head = mutableListOf<MutableList<ExcelUtil.MyCell>>() + //鍐呭 + val contents = mutableListOf<MutableList<Any>>() + + + open fun execute() { + //鏁版嵁婧愰噸缃� + dataSource.reset() + //鍚堟垚琛ㄥご + cols.forEach { + it.combineHead(head,dataSource) + } + //鍚堟垚鏁版嵁 + dataSource.loop { index, rowData -> + cols.forEach {col -> + val r = col.getOneRow(rowData) + if (index >= contents.size) { + contents.add(mutableListOf()) + } + contents[index].addAll(r) + } + } + } + + fun toWorkBook(wb: HSSFWorkbook) { + val f = tableFormat() + ExcelUtil.write(f.first, f.second, wb, templateName) + } + + fun toOutputStream(out: OutputStream, sheetName: String? = null) { + val f = tableFormat() + ExcelUtil.write2(out, f.first, f.second, sheetName ?: templateName) + } + + /** + * 杈撳嚭涓烘枃妗� + */ + fun toFile(path: String) { + val fileName = "${dataSource.areaName()}-${templateName}-${Date().time}.xls" + val out = FileOutputStream(path + fileName) + toOutputStream(out) + } + + /** + * 琛ㄥご鍜岃〃鍐呭鏍煎紡杞寲 + */ + private fun tableFormat(): Pair<MutableList<Array<Any>>, MutableList<Array<Any>>> { + val h = mutableListOf<Array<Any>>() + val c = mutableListOf<Array<Any>>() + head.forEach { h.add(it.toTypedArray()) } + contents.forEach { c.add(it.toTypedArray()) } + val index = c[0][0] + if (index is Int) { + c.sortBy { + if (it[0] is Int) { + it[0] as Int + } else { + 0 + } + } + } else { + c.sortBy { + it[0].toString() + } + } + return Pair(h, c) + } +} + +//鍥哄畾鍒楃粍鍚� + + +//鍩烘湰淇℃伅 +//闂鎵e垎鍒嗗竷 + + diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt index 0e23fd0..77154e7 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt @@ -1,31 +1,299 @@ package cn.flightfeather.supervision.business.report -import cn.flightfeather.supervision.domain.ds1.entity.Problemlist -import cn.flightfeather.supervision.domain.ds1.entity.Problemtype -import cn.flightfeather.supervision.domain.ds1.entity.Scense -import cn.flightfeather.supervision.domain.ds1.entity.Subtask +import cn.flightfeather.supervision.common.utils.Constant +import cn.flightfeather.supervision.common.utils.DateUtil +import cn.flightfeather.supervision.domain.ds1.entity.* +import cn.flightfeather.supervision.domain.ds1.mapper.* +import cn.flightfeather.supervision.lightshare.vo.ExcelConfigVo +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.stereotype.Component +import tk.mybatis.mapper.entity.Example +import javax.annotation.PostConstruct /** * 鎶ュ憡鎵�闇�婧愭暟鎹� - * 鐢熸垚鎶ュ憡鏃讹紝鎵�闇�瑕佺殑鏁版嵁婧� + * 鐢熸垚鎶ュ憡鏃讹紝缁熶竴鑾峰彇鍚勫熀纭�鏁版嵁 + * @param config 鐢熸垚鎶ュ憡鐨勫弬鏁� */ -class DataSource { +class DataSource(val config: ExcelConfigVo, val dbMapper: DbMapper){ - private var subTask: Subtask? = null + private val dateUtil = DateUtil() - /** - * 鎸囧畾褰撳墠杩涜缁熻鐨勪富浣撳璞� - */ - fun mainObj(subtask: Subtask) { - this.subTask = subTask + private val sourceList = mutableListOf<Subtask>() + + val rowData = RowData() + + init { + if (config.districtCode == null) { + throw IllegalStateException("鍙傛暟缂哄皯鍖哄幙缂栫爜:[districtCode]") + } + if (config.sceneType == null) { + throw IllegalStateException("鍙傛暟缂哄皯鍦烘櫙绫诲瀷:[sceneType]") + } + getSource(config) } - //鍦烘櫙鍩烘湰淇℃伅 - var scene: Scense? = null + fun loop(callback: (index:Int, rowData: RowData) -> Unit) { + reset() + for (i in sourceList.indices) { + rowData.clear() + rowData.subTask = sourceList[i] + callback(i, rowData) + } + } - //闂绫诲瀷 - var problemTypes = mutableListOf<Problemtype>() + /** + * 閲嶇疆 + */ + fun reset() { + rowData.subTask = sourceList.first() + rowData.clear() + } - //鍏蜂綋鐨勯棶棰� - var problems = mutableListOf<Problemlist>() -} \ No newline at end of file + /** + * 鏁版嵁缁熻鐨勬椂闂村拰鍖哄煙鍚嶇О + */ + fun areaName(): String { + val t = dbMapper.taskMapper.selectByPrimaryKey(config.topTaskGuid) + return "${dateUtil.DateToString(t.starttime, DateUtil.DateStyle.YYYY_MM_CN)}${t.districtname}${Constant.ScenseType.getDes(config.sceneType)}" + } + + /** + * 鑾峰彇鎶ュ憡鏁版嵁婧� + */ + private fun getSource(config: ExcelConfigVo) { + if (config.sceneType == null) return + + val result = mutableListOf<Subtask>() + + //1. 鏌ユ壘鐗瑰畾鐨勫贰鏌ヤ换鍔℃垨鑰呮墍鏈夌殑璁″垝宸℃煡浠诲姟 + var taskSceneIdList = listOf<String>() + val subTaskList = if (config.subTaskIdList?.isNotEmpty() == true || + (config.startTime != null || config.endTime != null) + ) { + dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply { + createCriteria().apply { + if (config.subTaskIdList?.isNotEmpty() == true) { + andIn("stguid", config.subTaskIdList) + } + config.startTime?.let { andGreaterThanOrEqualTo("planstarttime", it) } + config.endTime?.let { andLessThanOrEqualTo("planendtime", it) } + } + }) + } else { + taskSceneIdList = dbMapper.monitorobjectversionMapper.getSceneByType(config.topTaskGuid, config.sceneType) + dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply { + createCriteria().andIn("scenseid", taskSceneIdList) + .andEqualTo("tguid", config.topTaskGuid) + }) + } + + if (taskSceneIdList.isNotEmpty()) { + taskSceneIdList.forEach { + var subtask: Subtask? = null + for (s in subTaskList) { + if (s.scenseid == it) { + subtask = s + break + } + } + if (subtask == null) subtask = Subtask().apply { scenseid = it } + result.add(subtask) + } + } else { + result.addAll(subTaskList) + } + + sourceList.addAll(result) + } + + + inner class RowData(){ + var subTask: Subtask? = null + + //鍦烘櫙鍩烘湰淇℃伅 + val scene: Scense? + get() { + if (_scene == null) { + _scene = dbMapper.scenseMapper.selectByPrimaryKey(subTask?.scenseid) + } + return _scene + } + private var _scene: Scense? = null + + //鍚勫満鏅壒鏈夌殑鍩烘湰淇℃伅 + val baseScene: BaseScene? + get() { + if (_baseScene == null) { + _baseScene = when (this.scene?.typeid.toString()) { + Constant.ScenseType.TYPE1.value -> { + dbMapper.sceneConstructionSiteMapper.selectByPrimaryKey(scene?.guid) + } + Constant.ScenseType.TYPE2.value -> { + dbMapper.sceneWharfMapper.selectByPrimaryKey(scene?.guid) + } + Constant.ScenseType.TYPE3.value -> { + dbMapper.sceneMixingPlantMapper.selectByPrimaryKey(scene?.guid) + } + Constant.ScenseType.TYPE14.value -> { + dbMapper.sceneStorageYardMapper.selectByPrimaryKey(scene?.guid) + } + else -> null + } + } + return _baseScene + } + private var _baseScene: BaseScene? = null + + //鍏蜂綋鐨勯棶棰� + val problems: MutableList<Problemlist> + get() { + if (noRecord()) return mutableListOf() + + if (_problems.isEmpty()) { + val r = dbMapper.problemlistMapper.selectByExample(Example(Problemlist::class.java).apply { + createCriteria().andEqualTo("stguid", subTask?.stguid) + }) + _problems.addAll(r) + } + return _problems + } + private var _problems = mutableListOf<Problemlist>() + + val evaluation: Evaluation? + get() { + if (_evaluation == null) { + if (noRecord()) return null + + dbMapper.evaluationMapper.selectByExample(Example(Evaluation::class.java).apply { + createCriteria().andEqualTo("stguid", subTask?.stguid) + })?.takeIf { it.isNotEmpty() }?.let { _evaluation = it[0] } + } + return _evaluation + } + private var _evaluation: Evaluation? = null + + val itemevaluationList: MutableList<Itemevaluation> + get() { + if (_itemevaluationList.isEmpty()) { + val r = dbMapper.itemevaluationMapper.selectByExample(Example(Itemevaluation::class.java).apply { + createCriteria().andEqualTo("stguid", subTask?.stguid) + }) + _itemevaluationList.addAll(r) + println("-------------------itemevaluationList--------------------------------") + } + return _itemevaluationList + } + private var _itemevaluationList = mutableListOf<Itemevaluation>() + + //闂绫诲瀷 + val problemTypes: MutableList<Problemtype> + get() { + if (_problemTypes.isEmpty()) { + val r = dbMapper.problemtypeMapper.selectByExample(Example(Problemtype::class.java).apply { + createCriteria().andEqualTo("scensetypeid", config.sceneType) + .andEqualTo("districtcode", config.districtCode) + orderBy("extension1") + }) + _problemTypes.addAll(r) + } + return _problemTypes + } + private var _problemTypes = mutableListOf<Problemtype>() + + //鑷姩璇勫垎瑙勫垯涓�绾у垎绫� + val topItems: MutableList<Evaluationsubrule2> + get() { + if (_topItems.isEmpty()) { + val rule = dbMapper.evaluationruleMapper.selectByExample(Example(Evaluationrule::class.java).apply { + createCriteria() + .andEqualTo("tasktypeid", 99) + .andEqualTo("scensetypeid", config.sceneType) + }) + if (rule.isNotEmpty()) { + val ruleId = rule[0].guid + val rules = dbMapper.evaluationsubruleMapper.selectByExample(Example(Evaluationsubrule2::class.java).apply { + createCriteria().andEqualTo("erguid", ruleId) + }) + rules.forEach { + if (it.ertype == 2) { + _topItems.add(it) + } + } + _topItems.sortBy { it.displayid } + + var t = 0 + _topItems.forEach { + t += it.maxscore ?: 0 + val tempRules = mutableListOf<Evaluationsubrule2>() + for (i in rules) { + if (i.fatherid == it.guid && i.ertype == 3) { + tempRules.add(i) + } + } + //璇勫垎澶ч」濡傛灉娌℃湁鎵惧埌璇勫垎灏忛」锛屽垯璇存槑鍏剁洿鎺ュ搴旀渶灏忚瘎鍒嗛」锛屽叾鏈韩鍙樻垚璇勫垎椤� + if (tempRules.isEmpty()) { + tempRules.add(it) + } + tempRules.sortBy { t -> t.displayid } + tempRules.forEach { temp -> + val tempSubRules = mutableListOf<Evaluationsubrule2>() + for (i in rules) { + if (i.fatherid == temp.guid && i.ertype == 4) { + tempSubRules.add(i) + } + } + tempSubRules.sortBy { ts -> ts.displayid } + this._rules.add(Pair(temp, tempSubRules)) + } + } + } + } + return _topItems + } + private var _topItems = mutableListOf<Evaluationsubrule2>() + + //鑷姩璇勫垎瑙勫垯浜岀骇鍜屼笁绾у垎绫� + val rules: MutableList<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>> + get() { + if (_rules.isEmpty()) { + this.topItems + } + return _rules + } + private var _rules = mutableListOf<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>>() + + /** + * 娓呯┖褰撳墠澶勭悊鐨勫璞$殑鐩稿叧鏁版嵁婧� + */ + fun clear() { + _scene = null + _baseScene = null + _problems.clear() + _evaluation = null + _itemevaluationList.clear() + } + + /** + * 鍒ゆ柇鍦烘櫙鏄惁宸℃煡鐩戠锛屾湁鏃犲贰鏌ヨ褰� + */ + fun noRecord() = subTask?.stguid == null + } +} + +data class DbMapper( + val scenseMapper: ScenseMapper, + val problemlistMapper: ProblemlistMapper, + val problemtypeMapper: ProblemtypeMapper, + val subtaskMapper: SubtaskMapper, + val monitorobjectversionMapper: MonitorobjectversionMapper, + val sceneConstructionSiteMapper: SceneConstructionSiteMapper, + val sceneMixingPlantMapper: SceneMixingPlantMapper, + val sceneStorageYardMapper: SceneStorageYardMapper, + val sceneWharfMapper: SceneWharfMapper, + val taskMapper: TaskMapper, + val evaluationruleMapper: EvaluationruleMapper, + val evaluationsubruleMapper: EvaluationsubruleMapper2, + val evaluationMapper: EvaluationMapper, + val itemevaluationMapper: ItemevaluationMapper +) diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColGrade.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColGrade.kt new file mode 100644 index 0000000..271e082 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColGrade.kt @@ -0,0 +1,111 @@ +package cn.flightfeather.supervision.business.report.cols + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.common.utils.ExcelUtil +import cn.flightfeather.supervision.domain.ds1.entity.Itemevaluation +import org.apache.poi.hssf.util.HSSFColor + +class ColGrade(private val hasHead3: Boolean = true) : BaseCols() { + + override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> { + val h1 = mutableListOf<ExcelUtil.MyCell>() + h1.add(ExcelUtil.MyCell("鐜俊鐮�", 3, 1)) + h1.add(ExcelUtil.MyCell("闃叉不瑙勮寖鎬�", 3, 1)) + h1.add(ExcelUtil.MyCell("鎬诲垎", 3, 1)) + val h2 = mutableListOf<ExcelUtil.MyCell>() + h2.add(ExcelUtil.MyCell("")) + h2.add(ExcelUtil.MyCell("")) + h2.add(ExcelUtil.MyCell("")) + val h3 = mutableListOf<ExcelUtil.MyCell>() + h3.add(ExcelUtil.MyCell("")) + h3.add(ExcelUtil.MyCell("")) + h3.add(ExcelUtil.MyCell("")) + dataSource.rowData.topItems.forEach { + h1.add(ExcelUtil.MyCell(it.itemname ?: "", 1, 0)) + for (r in dataSource.rowData.rules) { + if (r.first.fatherid == it.guid || r.first.guid == it.guid) { + h2.add(ExcelUtil.MyCell(r.first.itemname ?: "", 1, 0)) + if (hasHead3) { + r.second.forEach { s -> + h3.add(ExcelUtil.MyCell(s.itemname ?: "")) + h2.last().colSpan++ + h1.last().colSpan++ + } + } else { + h2.last().colSpan++ + h1.last().colSpan++ + } + } + } + } + + return mutableListOf(h1, h2, h3) + } + + override fun onOneRow(rowData: DataSource.RowData): List<Any> { + val row = mutableListOf<Any>() + + if (rowData.noRecord()) { + repeat(heads.last().size) { row.add(("")) } + } else { + row.apply { + //鎬诲垎鍜岀幆淇$爜 + rowData.evaluation.let { e -> + val s = e?.resultscorebef?.toIntOrNull() ?: "" + val code = when (s) { + in 0..59 -> ExcelUtil.MyCell("绾㈢爜", fontColor = HSSFColor.HSSFColorPredefined.RED.index) + in 60..89 -> ExcelUtil.MyCell("榛勭爜", fontColor = HSSFColor.HSSFColorPredefined.GOLD.index) + in 90..100 -> ExcelUtil.MyCell("缁跨爜", fontColor = HSSFColor.HSSFColorPredefined.BRIGHT_GREEN.index) + "" -> ExcelUtil.MyCell("", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index) + else -> ExcelUtil.MyCell("瓒呭嚭鑼冨洿锛�${s}", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index) + } + val normalization = when (s) { + in 0..59 -> ExcelUtil.MyCell("涓ラ噸涓嶈鑼�", fontColor = HSSFColor.HSSFColorPredefined.ROSE.index) + in 60..89 -> ExcelUtil.MyCell("涓嶈鑼�", fontColor = HSSFColor.HSSFColorPredefined.RED.index) + in 90..99 -> ExcelUtil.MyCell("鍩烘湰瑙勮寖", fontColor = HSSFColor.HSSFColorPredefined.GOLD.index) + 100 -> ExcelUtil.MyCell("瑙勮寖", fontColor = HSSFColor.HSSFColorPredefined.BRIGHT_GREEN.index) + "" -> ExcelUtil.MyCell("", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index) + else -> ExcelUtil.MyCell("瓒呭嚭鑼冨洿锛�${s}", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index) + } + add(code) + add(normalization) + add(s) + } + + + //姣忎竴椤瑰叿浣撳緱鍒� + rowData.topItems.forEach { + for (r in rowData.rules) { + if (r.first.fatherid == it.guid || r.first.guid == it.guid) { + // FIXME: 2021/4/25 鍐冲畾鏄惁鍐檋3 + if (hasHead3) { + r.second.forEach { s -> + val v = searchScore(s.guid, rowData.itemevaluationList) + add(v.toIntOrNull() ?: "") + } + } else { + val v = searchScore(r.first.guid, rowData.itemevaluationList) + add(v.toIntOrNull() ?: "") + } + } + } + } + } + } + + return row + } + + //鏌ユ壘寰楀垎璁板綍鍐呭搴旇鍒欑殑寰楀垎 + private fun searchScore(ruleId: String?, itemevaluations: List<Itemevaluation>): String { + var score = "" + for (e in itemevaluations) { + if (ruleId == e.esrguid) { + score = e.value ?: "" + break + } + } + return score + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColInspectionInfo.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColInspectionInfo.kt new file mode 100644 index 0000000..da2bfe8 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColInspectionInfo.kt @@ -0,0 +1,112 @@ +package cn.flightfeather.supervision.business.report.cols + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.common.utils.Constant +import cn.flightfeather.supervision.common.utils.DateUtil +import cn.flightfeather.supervision.common.utils.ExcelUtil + +//鐩戠璇︽儏 +class ColInspectionInfo() : BaseCols() { + override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> { + return mutableListOf(mutableListOf( + ExcelUtil.MyCell("鐩戠鏃堕棿"), + ExcelUtil.MyCell("宸℃煡浜哄憳"), + ExcelUtil.MyCell("闂绫诲瀷"), + ExcelUtil.MyCell("闂鎻忚堪"), + ExcelUtil.MyCell("闂浣嶇疆"), + ExcelUtil.MyCell("闂鏁�"), + ExcelUtil.MyCell("鏁存敼鏃堕棿"), + ExcelUtil.MyCell("鏁存敼鎯呭喌"), + ExcelUtil.MyCell("鏁存敼闂"), + ExcelUtil.MyCell("鏁存敼鏁�"), + ExcelUtil.MyCell("鏈暣鏀归棶棰�"), + ExcelUtil.MyCell("鏈暣鏀规暟"), + ExcelUtil.MyCell("瀹℃牳鎯呭喌"), + ExcelUtil.MyCell("闂瀹℃牳鏃堕棿"), + ExcelUtil.MyCell("鏁存敼瀹℃牳鏃堕棿"), + ExcelUtil.MyCell("闂鏁存敼鐜�"), + )) + } + + override fun onOneRow(rowData: DataSource.RowData): List<Any> { + val dateUtil = DateUtil() + val row = mutableListOf<Any>() + if (rowData.noRecord()) { + repeat(heads.last().size) { row.add(("")) } + } else { + row.apply { + // 琛ㄥご锛氬贰鏌ユ儏鍐靛強闂銆佹暣鏀圭粺璁� + //鐩戠鏃堕棿 + add(dateUtil.DateToString(rowData.subTask?.planstarttime, DateUtil.DateStyle.MM_DD) ?: "") + //宸℃煡浜哄憳 + add(rowData.subTask?.executorrealtimes?.replace("#", "銆�") ?: "") + //鏌ヨ瀛愪换鍔″搴旂殑闂锛屽苟涓旀牴鎹潯浠惰繘琛岀瓫閫� + var y = 1 + var pType = ""//闂绫诲瀷 + var pDes = ""//闂鎻忚堪 + var pLoc = ""//闂浣嶇疆 + var pNum = 0//闂鏁� + var changeTime = ""//鏁存敼鏃堕棿 + var pChanged = ""//鏁存敼鎯呭喌 + var changedProblem = ""//鏁存敼闂 + var cNum = 0//鏁存敼鏁� + var unChangedProblem = ""//鏈暣鏀归棶棰� + var unChangeNum = 0//鏈暣鏀规暟 + var checkStatus = ""//瀹℃牳鎯呭喌 + var pCheckTime = ""//闂瀹℃牳鏃堕棿 + var cCheckTime = ""//鏁存敼瀹℃牳鏃堕棿 + var changePercent = ""//闂鏁存敼鐜� + rowData.problems.forEach { p -> + var typeName = "" + for (t in rowData.problemTypes) { + if (t.guid == p.ptguid) { + typeName = t.typename ?: "" + break + } + } + val lr = if (y > 1) "\n" else "" + //宸℃煡鎯呭喌鍙婇棶棰樸�佹暣鏀圭粺璁� + pType += "${lr}$y銆�${typeName}" + pDes += "${lr}$y銆�${p.problemname}" + pLoc += "${lr}$y銆�${p.location}" + pNum++ + changeTime = "${lr}$y銆�${dateUtil.DateToString(p.changedtime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_CN)}" + pChanged += "${lr}$y銆�${if (p.ischanged == true) "鉁�" else "脳"}" + if (p.ischanged == true) { + if (changedProblem.isNotBlank()) { + changedProblem += "\n" + } + changedProblem += "$y銆�${p.problemname}" + cNum++ + } else { + if (unChangedProblem.isNotBlank()) { + unChangedProblem += "\n" + } + unChangedProblem += "$y銆�${p.problemname}" + unChangeNum++ + } + val status = when (p.extension3) { + Constant.PROBLEM_CHECK_PASS -> "闂瀹℃牳閫氳繃"// + Constant.PROBLEM_CHECK_FAIL -> "闂瀹℃牳鏈�氳繃"// + Constant.PROBLEM_UNCHECKED -> "闂鏈鏍�"// + Constant.CHANGE_UNCHECKED -> "鏁存敼鏈鏍�"// + Constant.CHANGE_CHECK_PASS -> "鏁存敼瀹℃牳閫氳繃"// + Constant.CHANGE_CHECK_FAIL -> "鏁存敼瀹℃牳鏈�氳繃"// + else -> "闂鏈鏍�" + } + checkStatus += "${lr}$y銆�${status}" + changePercent = if (pNum == 0) "" else "${(cNum * 100 / pNum)}%" + y++ + } + addAll( + listOf( + pType, pDes, pLoc, pNum, changeTime, pChanged, changedProblem, cNum, + unChangedProblem, unChangeNum, checkStatus, pCheckTime, cCheckTime, changePercent + ) + ) + } + } + return row + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColLedger.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColLedger.kt new file mode 100644 index 0000000..9f2b23f --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColLedger.kt @@ -0,0 +1,19 @@ +package cn.flightfeather.supervision.business.report.cols + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.common.utils.ExcelUtil + +class ColLedger : BaseCols() { + override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> { + return mutableListOf(mutableListOf( + ExcelUtil.MyCell("鍙拌处鎻愪氦鐧惧垎姣�"), + ExcelUtil.MyCell("鍙拌处鎻愪氦鏃堕棿"), + ExcelUtil.MyCell("鍙拌处瀹℃牳鏃堕棿"), + )) + } + + override fun onOneRow(rowData: DataSource.RowData): List<Any> { + return listOf("", "", "") + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColProChange.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColProChange.kt new file mode 100644 index 0000000..c491e61 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColProChange.kt @@ -0,0 +1,24 @@ +package cn.flightfeather.supervision.business.report.cols + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.common.utils.ExcelUtil + +class ColProChange : BaseCols() { + override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> { + return mutableListOf( + mutableListOf(ExcelUtil.MyCell("闂涓庢暣鏀�", colSpan = 2)), + mutableListOf(ExcelUtil.MyCell("闂鏁�"), ExcelUtil.MyCell("鏁存敼鏁�")) + ) + } + + override fun onOneRow(rowData: DataSource.RowData): List<Any> { + var pNum = 0//闂鏁� + var cNum = 0//鏁存敼鏁� + rowData.problems.forEach { + pNum++ + if (it.ischanged == true) cNum++ + } + return listOf(pNum, cNum) + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColProblemDistribution.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColProblemDistribution.kt new file mode 100644 index 0000000..440512e --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColProblemDistribution.kt @@ -0,0 +1,54 @@ +package cn.flightfeather.supervision.business.report.cols + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.common.utils.ExcelUtil + +//闂鏁存敼鍒嗗竷 +class ColProblemDistribution() : BaseCols() { + private var h2 = mutableListOf<ExcelUtil.MyCell>() + private val currentProblemType = mutableMapOf<String, String>() + private val currentProblemHead = mutableListOf<String>() + + override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> { + val h1 = mutableListOf<ExcelUtil.MyCell>() + + dataSource.rowData.problemTypes.forEach { + if (!currentProblemHead.contains(it.typename)) { + currentProblemHead.add(it.typename ?: "") + h1.add(ExcelUtil.MyCell(it.typename ?: "", colSpan = 0)) + } + currentProblemType[it.guid ?: ""] = it.description ?: "" + if (currentProblemHead.contains(it.typename)) { + h2.add(ExcelUtil.MyCell(it.description ?: "")) + h1.last().colSpan++ + + h2.add(ExcelUtil.MyCell("鏄惁鏁存敼")) + h1.last().colSpan++ + } + } + + return mutableListOf(h1, h2) + } + + override fun onOneRow(rowData: DataSource.RowData): List<Any> { + val pDis = mutableListOf<Any>()//鍏蜂綋闂鍒嗗竷鍙婃暣鏀规儏鍐� + repeat(h2.size) { pDis.add("")} + rowData.problems.forEach {p -> + val des = currentProblemType[p.ptguid] + + //鍏蜂綋闂鍒嗗竷 + for (t in h2.indices) { + if (des == h2[t].text) { + //鍏蜂綋闂杩欎竴鍒楁坊鍔犳枃鏈紝琛ㄧず闂瀛樺湪 + pDis[t] = 1 + //闂鍒楃殑涓嬩竴鍒楁槸璇ラ棶棰樼殑鏁存敼鎯呭喌 + pDis[t + 1] = if (p.ischanged == true) 1 else 0 + break + } + } + } + + return pDis + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColSceneName.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColSceneName.kt new file mode 100644 index 0000000..7e2cc48 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColSceneName.kt @@ -0,0 +1,18 @@ +package cn.flightfeather.supervision.business.report.cols + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.common.utils.ExcelUtil + +//鍚嶇О +class ColSceneName() : BaseCols() { + override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> { + return mutableListOf( + mutableListOf(ExcelUtil.MyCell("琛ㄥ崟缂栧彿"), ExcelUtil.MyCell("鍞竴搴忓彿"), ExcelUtil.MyCell("鍦烘櫙鍚嶇О")) + ) + } + + override fun onOneRow(rowData: DataSource.RowData): List<Any> { + return listOf(rowData.scene?.index ?: -99, rowData.scene?.extension2 ?: "", rowData.scene?.name ?: "") + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStatus.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStatus.kt new file mode 100644 index 0000000..da630da --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStatus.kt @@ -0,0 +1,39 @@ +package cn.flightfeather.supervision.business.report.cols + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.common.utils.Constant +import cn.flightfeather.supervision.common.utils.ExcelUtil +import cn.flightfeather.supervision.domain.ds1.entity.SceneConstructionSite +import cn.flightfeather.supervision.domain.ds1.entity.SceneMixingPlant +import cn.flightfeather.supervision.domain.ds1.entity.SceneStorageYard +import cn.flightfeather.supervision.domain.ds1.entity.SceneWharf + +class ColStatus : BaseCols() { + override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> { + return mutableListOf(mutableListOf( + ExcelUtil.MyCell("鏂藉伐/钀ヨ繍鐘舵��"), + ExcelUtil.MyCell("鏂藉伐闃舵") + )) + } + + override fun onOneRow(rowData: DataSource.RowData): List<Any> { + val status = when (rowData.scene?.typeid.toString()) { + Constant.ScenseType.TYPE1.value -> { + (rowData.baseScene as SceneConstructionSite?)?.csStatus + } + Constant.ScenseType.TYPE2.value -> { + (rowData.baseScene as SceneWharf?)?.getwStatus() + } + Constant.ScenseType.TYPE3.value -> { + (rowData.baseScene as SceneMixingPlant?)?.mpStatus + } + Constant.ScenseType.TYPE14.value -> { + (rowData.baseScene as SceneStorageYard?)?.syStatus + } + else -> "" + } + val s = status ?: "" + return listOf(s, s) + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTown.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTown.kt new file mode 100644 index 0000000..e1a73bb --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTown.kt @@ -0,0 +1,15 @@ +package cn.flightfeather.supervision.business.report.cols + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.common.utils.ExcelUtil + +class ColTown : BaseCols() { + override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> { + return mutableListOf(mutableListOf(ExcelUtil.MyCell("琛楅晣/宸ヤ笟鍖�"))) + } + + override fun onOneRow(rowData: DataSource.RowData): List<Any> { + return listOf(rowData.scene?.townname ?: "") + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportOne.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportOne.kt new file mode 100644 index 0000000..c14adac --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportOne.kt @@ -0,0 +1,12 @@ +package cn.flightfeather.supervision.business.report.file + +import cn.flightfeather.supervision.business.report.BaseExcel +import cn.flightfeather.supervision.business.report.BaseTemplate +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.business.report.template.ProAnalysisSummary +import cn.flightfeather.supervision.business.report.template.ProDetailSummary + +class ReportOne(dataSource: DataSource) : BaseExcel(dataSource) { + override val templates: List<BaseTemplate> = listOf(ProDetailSummary(dataSource), ProAnalysisSummary(dataSource)) + override val fileName: String = "闂涓庢暣鏀规眹鎬诲垎鏋愪笌鍔ㄦ�佽窡韪竻鍗�" +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportThree.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportThree.kt new file mode 100644 index 0000000..86cf9ff --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportThree.kt @@ -0,0 +1,11 @@ +package cn.flightfeather.supervision.business.report.file + +import cn.flightfeather.supervision.business.report.BaseExcel +import cn.flightfeather.supervision.business.report.BaseTemplate +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.business.report.template.* + +class ReportThree(dataSource: DataSource) : BaseExcel(dataSource) { + override val templates: List<BaseTemplate> = listOf(ProTypeDetailSummary(dataSource), ProTypeRankSummary(dataSource), ProTypeRankMainSummary(dataSource), ProTypeStatusSummary(dataSource)) + override val fileName: String = "闂涓庢暣鏀瑰垎甯冨垎鏋愭竻鍗�" +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportTwo.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportTwo.kt new file mode 100644 index 0000000..f5b8137 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportTwo.kt @@ -0,0 +1,12 @@ +package cn.flightfeather.supervision.business.report.file + +import cn.flightfeather.supervision.business.report.BaseExcel +import cn.flightfeather.supervision.business.report.BaseTemplate +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.business.report.template.ScoreAnalysisSummary +import cn.flightfeather.supervision.business.report.template.ScoreDetailSummary + +class ReportTwo(dataSource: DataSource) : BaseExcel(dataSource) { + override val templates: List<BaseTemplate> = listOf(ScoreDetailSummary(dataSource), ScoreAnalysisSummary(dataSource)) + override val fileName: String = "瑙勮寖鎬ц瘎浼颁笌鍒嗘瀽娓呭崟" +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt new file mode 100644 index 0000000..8317647 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt @@ -0,0 +1,169 @@ +package cn.flightfeather.supervision.business.report.template + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.BaseTemplate +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.business.report.cols.ColInspectionInfo +import cn.flightfeather.supervision.common.utils.Constant +import cn.flightfeather.supervision.common.utils.ExcelUtil +import cn.flightfeather.supervision.domain.ds1.entity.SceneConstructionSite +import cn.flightfeather.supervision.domain.ds1.entity.SceneMixingPlant +import cn.flightfeather.supervision.domain.ds1.entity.SceneStorageYard +import cn.flightfeather.supervision.domain.ds1.entity.SceneWharf +import kotlin.math.round + +/** + * 鍒嗚闀囬棶棰樻暣鏀瑰垎鏋愭眹鎬昏〃 + */ +class ProAnalysisSummary(dataSource: DataSource) : BaseTemplate(dataSource) { + override val cols: List<BaseCols> = listOf(ColInspectionInfo()) + + override val templateName: String = "鍒嗚闀囬棶棰樻暣鏀瑰垎鏋愭眹鎬昏〃" + + override fun execute() { + //鏁版嵁婧愰噸缃� + dataSource.reset() + + cols.forEach { it.combineHead(head,dataSource) } + + val districtMap = mutableMapOf<String?, Summary>() + dataSource.loop { _, rowData -> + if (rowData.noRecord()) return@loop + + val r = cols[0].getOneRow(rowData) + + val k = rowData.scene?.townname + if (!districtMap.containsKey(k)) { + districtMap[k] = Summary().apply { + townCode = rowData.scene?.towncode ?: "" + townName = rowData.scene?.townname ?: "" + type = rowData.scene?.type ?: "" + } + } + districtMap[k]?.apply { + sceneCount++ + val status = when (dataSource.config.sceneType.toString()) { + Constant.ScenseType.TYPE1.value -> { + (rowData.baseScene as SceneConstructionSite?)?.csStatus + } + Constant.ScenseType.TYPE2.value -> { + (rowData.baseScene as SceneWharf?)?.getwStatus() + } + Constant.ScenseType.TYPE3.value -> { + (rowData.baseScene as SceneMixingPlant?)?.mpStatus + } + Constant.ScenseType.TYPE14.value -> { + (rowData.baseScene as SceneStorageYard?)?.syStatus + } + else -> "" + } + // FIXME: 2022/7/18 鍚庣画鍦烘櫙鐨勬柦宸ョ姸鎬佹敼涓哄竷灏斿�煎瓨鍌� + if ((status?.contains("瀹屽伐") == true) || (status?.contains("鏈柦宸�") == true) || (status?.contains("鍋�") == true) + || (status?.contains("鍏�") == true) + ) { + inactiveScenes++ + } else { + activeScenes++ + } + val pNum = r[5] as Int + val cNum = r[9] as Int + if (pNum > 0 && cNum > 0) changeScenes++ + proNum += pNum + changeNum += cNum + } + } + + val summarys = mutableListOf<Summary>() + var totalPro = 0 + districtMap.forEach { + summarys.add(it.value) + totalPro += it.value.proNum + } + districtMap.forEach { + val v = it.value + v.changeScenePer = round(v.changeScenes.toDouble() / v.sceneCount * 1000) / 1000 + v.proPer = round(v.proNum.toDouble() / totalPro * 1000) / 1000 + v.changePer = round(v.changeNum.toDouble() / v.proNum * 1000) / 1000 + } + //鏁存敼鍗曚綅姣旀帓鍚� + summarys.sortByDescending { + it.changeScenePer + } + for (i in summarys.indices) { + summarys[i].changeSceneRank = i + 1 + } + //闂鏁存敼鐜囨帓鍚� + summarys.sortByDescending { + it.changePer + } + for (i in summarys.indices) { + summarys[i].proChangeRank = i + 1 + } + + //鏇存柊琛ㄥご + head.clear() + head.add(mutableListOf( + ExcelUtil.MyCell("琛楅晣搴忓彿", rowSpan = 2), + ExcelUtil.MyCell("鍖哄煙"), + ExcelUtil.MyCell("鍦烘櫙绫诲埆", rowSpan = 2), + ExcelUtil.MyCell("鍦烘櫙鐘舵��", colSpan = 3), + ExcelUtil.MyCell("鏁存敼鍗曚綅", colSpan = 2), + ExcelUtil.MyCell("闂涓庢暣鏀�", colSpan = 4), + ExcelUtil.MyCell("鎺掑悕", colSpan = 2), + ExcelUtil.MyCell("鍖哄煙鐩戠绛栫暐", colSpan = 2), + )) + head.add(mutableListOf( + ExcelUtil.MyCell(""), + ExcelUtil.MyCell("琛楅晣/宸ヤ笟鍖�"), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell("鍦烘櫙鏁�"), + ExcelUtil.MyCell("瀹屽伐銆佹湭鏂藉伐銆佸仠宸ユ垨鍋滀笟銆佸叧闂瓑"), + ExcelUtil.MyCell("鏂藉伐涓�佽繍钀ヤ腑鎬绘暟"), + ExcelUtil.MyCell("鏁存敼鍗曚綅鏁�"), + ExcelUtil.MyCell("鏁存敼鍗曚綅鍗犳瘮"), + ExcelUtil.MyCell("闂鏁�"), + ExcelUtil.MyCell("闂鍗犳瘮"), + ExcelUtil.MyCell("鏁存敼鏁�"), + ExcelUtil.MyCell("鏁存敼鐜�"), + ExcelUtil.MyCell("鏁存敼鍗曚綅姣旀帓鍚�"), + ExcelUtil.MyCell("闂鏁存敼鐜囨帓鍚�"), + ExcelUtil.MyCell("鎷熷垪鍏ラ噸鐐圭洃绠℃暟"), + ExcelUtil.MyCell("鎷熷垪鍏ラ噸鐐圭洃绠″崰姣�"), + )) + //鏇存柊鍐呭 + summarys.forEach { + contents.add( + mutableListOf( + it.townCode, it.townName, it.type, it.sceneCount, it.inactiveScenes, it.activeScenes, it.changeScenes, + "${round(it.changeScenePer * 1000) / 10}%", + it.proNum, "${round(it.proPer * 1000) / 10}%", it.changeNum, "${round(it.changePer * 1000) / 10}%", it.changeSceneRank, it.proChangeRank + ) + ) + } + } + + inner class Summary(){ + var townCode = "" + var townName = "" + var type = "" + var sceneCount = 0 + //鍋滆繍鐨勫満鏅暟 + var inactiveScenes = 0 + var activeScenes = 0 + + var changeScenes = 0 + var changeScenePer = .0 + set(value) { field = if (value.isNaN()) .0 else value } + + var proNum = 0 + var proPer = .0 + set(value) { field = if (value.isNaN()) .0 else value } + + var changeNum = 0 + var changePer = .0 + set(value) { field = if (value.isNaN()) .0 else value } + + var changeSceneRank = 0 + var proChangeRank = 0 + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProDetailSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProDetailSummary.kt new file mode 100644 index 0000000..edc0440 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProDetailSummary.kt @@ -0,0 +1,12 @@ +package cn.flightfeather.supervision.business.report.template + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.BaseTemplate +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.business.report.cols.ColInspectionInfo +import cn.flightfeather.supervision.business.report.cols.ColSceneName + +class ProDetailSummary(dataSource: DataSource) : BaseTemplate(dataSource) { + override val cols: List<BaseCols> = listOf(ColSceneName(), ColInspectionInfo()) + override val templateName: String = "闂涓庢暣鏀硅窡韪眹鎬昏〃" +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeDetailSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeDetailSummary.kt new file mode 100644 index 0000000..faf72d7 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeDetailSummary.kt @@ -0,0 +1,12 @@ +package cn.flightfeather.supervision.business.report.template + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.BaseTemplate +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.business.report.cols.* + +class ProTypeDetailSummary(dataSource: DataSource) : BaseTemplate(dataSource) { + override val cols: List<BaseCols> = listOf(ColSceneName(), ColTown(), ColStatus(), ColProChange(), ColProblemDistribution()) + + override val templateName: String = "闂涓庢暣鏀瑰垎绫荤粺璁¤〃" +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt new file mode 100644 index 0000000..688d2e2 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt @@ -0,0 +1,48 @@ +package cn.flightfeather.supervision.business.report.template + +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.common.utils.ExcelUtil +import kotlin.math.round + +class ProTypeRankMainSummary(dataSource: DataSource) : ProTypeRankSummary(dataSource) { + override val templateName: String = "鏈堝害涓昏鎴栧吀鍨嬮棶棰樺垎鏋愯〃" + + override fun formatTable(summarys: List<Summary>) { + summarys.sortedByDescending { it.count } + + head.clear() + head.add( + mutableListOf( + ExcelUtil.MyCell("搴忓彿", rowSpan = 2), + ExcelUtil.MyCell("骞村害", rowSpan = 2), + ExcelUtil.MyCell("鏈堜唤", rowSpan = 2), + ExcelUtil.MyCell("鍦烘櫙绫诲埆", rowSpan = 2), + ExcelUtil.MyCell("鍖哄煙", rowSpan = 2), + ExcelUtil.MyCell("闂鏁�", rowSpan = 2), + ExcelUtil.MyCell("涓昏鎴栧吀鍨嬮棶棰樺垎鏋�", colSpan = 3), + ) + ) + head.add( + mutableListOf( + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell("涓昏闂绫诲埆锛堜笁绾ф寚鏍囷級"), + ExcelUtil.MyCell("涓昏闂鍚堣鏁�"), + ExcelUtil.MyCell("涓昏闂鍗犳瘮"), + ) + ) + for (i in summarys.indices) { + val s = summarys[i] + contents.add( + mutableListOf( + i + 1, "", "", dataSource.rowData.scene?.type ?: "", "", s.count, + s.proDes, s.count, "${round(s.countPer * 1000) / 10}%" + ) + ) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankSummary.kt new file mode 100644 index 0000000..0eec5f3 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankSummary.kt @@ -0,0 +1,125 @@ +package cn.flightfeather.supervision.business.report.template + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.BaseTemplate +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.business.report.cols.* +import cn.flightfeather.supervision.common.utils.ExcelUtil +import kotlin.math.round + +open class ProTypeRankSummary(dataSource: DataSource) : BaseTemplate(dataSource) { + override val cols: List<BaseCols> = listOf() + override val templateName: String = "闂涓庢暣鏀瑰垎绫绘帓鍚�" + + override fun execute() { + dataSource.reset() + + val proMap = mutableMapOf<String?, Summary>() + dataSource.loop { _, rowData -> + rowData.problems.forEach { + val k = it.ptguid + if (!proMap.containsKey(k)) { + proMap[k] = Summary().apply { + for (p in rowData.problemTypes) { + if (p.guid == k) { + proType = p.typename ?: "" + proDes = p.description ?: "" + break + } + } + } + } + proMap[k]?.apply { + count++ + if (it.ischanged == true) changeNum++ + } + } + } + + //鍗犳瘮缁熻 + val summarys = mutableListOf<Summary>() + var tPros = 0 + proMap.forEach { + val v = it.value + summarys.add(v) + tPros += v.count + } + summarys.sortByDescending { it.count } + for (i in summarys.indices) { + val it = summarys[i] + it.countPer = it.count.toDouble() / tPros + it.countRank = i + 1 + it.changePer = it.changeNum.toDouble() / it.count + } + summarys.sortByDescending { it.changePer } + for (i in summarys.indices) { + val it = summarys[i] + it.changeRank = i + 1 + } + + formatTable(summarys) + } + + open fun formatTable(summarys: List<Summary>) { + head.clear() + head.add( + mutableListOf( + ExcelUtil.MyCell("搴忓彿", rowSpan = 2), + ExcelUtil.MyCell("骞村害", rowSpan = 2), + ExcelUtil.MyCell("鏈堜唤", rowSpan = 2), + ExcelUtil.MyCell("鍦烘櫙绫诲埆", rowSpan = 2), + ExcelUtil.MyCell("鍖哄煙", rowSpan = 2), + ExcelUtil.MyCell("闂澶х被锛堜簩绾ф寚鏍囷級", rowSpan = 2), + ExcelUtil.MyCell("闂灏忕被锛堜笁绾ф寚鏍囷級", rowSpan = 2), + ExcelUtil.MyCell("闂鍗犳瘮鎺掑悕鍒嗘瀽", colSpan = 3), + ExcelUtil.MyCell("鏁存敼鐜囨帓鍚嶅垎鏋�", colSpan = 3), + ) + ) + head.add( + mutableListOf( + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell("鍚堣闂鏁�"), + ExcelUtil.MyCell("闂鍗犳瘮"), + ExcelUtil.MyCell("闂鎺掑悕"), + ExcelUtil.MyCell("鏁存敼鏁�"), + ExcelUtil.MyCell("鏁存敼鐜�"), + ExcelUtil.MyCell("鏁存敼鎺掑悕"), + ) + ) + for (i in summarys.indices) { + val s = summarys[i] + contents.add( + mutableListOf( + i + 1, "", "", dataSource.rowData.scene?.type ?: "", "", + s.proType, s.proDes, + s.count, "${round(s.countPer * 1000) / 10}%", s.countRank, + s.changeNum, "${round(s.changePer * 1000) / 10}%", s.changeRank + ) + ) + } + } + + inner class Summary() { + var proType = "" + var proDes = "" + var count = 0 + var countPer = .0 + set(value) { + field = if (value.isNaN()) .0 else value + } + var countRank = 0 + + var changeNum = 0 + var changePer = .0 + set(value) { + field = if (value.isNaN()) .0 else value + } + var changeRank = 0 + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt new file mode 100644 index 0000000..b63af99 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt @@ -0,0 +1,128 @@ +package cn.flightfeather.supervision.business.report.template + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.BaseTemplate +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.common.utils.Constant +import cn.flightfeather.supervision.common.utils.ExcelUtil +import cn.flightfeather.supervision.domain.ds1.entity.SceneConstructionSite +import kotlin.math.round + +class ProTypeStatusSummary(dataSource: DataSource) : BaseTemplate(dataSource) { + override val cols: List<BaseCols> = listOf() + override val templateName: String = "宸ュ湴鏂藉伐闃舵闂鍒嗙被鍒嗘瀽琛�" + + @Throws(Exception::class) + override fun execute() { + if (dataSource.config.sceneType.toString() != Constant.ScenseType.TYPE1.value) { + throw IllegalStateException("${templateName}鍙兘閽堝宸ュ湴杩涜鍒嗘瀽锛屽綋鍓嶄紶鍏ュ満鏅被鍨嬬紪鍙蜂负${dataSource.config.sceneType}") + } + + dataSource.reset() + + val proMap = mutableMapOf<String?, MutableMap<String?, Summary>>() + dataSource.loop { _, rowData -> + rowData.problems.forEach { + val s = (rowData.baseScene as SceneConstructionSite?)?.csStatus + if (!proMap.containsKey(s)) { + proMap[s] = mutableMapOf() + } + val pt = it.ptguid + if (proMap[s]?.containsKey(pt) == false) { + proMap[s]?.put(pt, Summary().apply { + for (p in rowData.problemTypes) { + if (p.guid == pt) { + status = s ?: "" + proType = p.typename ?: "" + proDes = p.description ?: "" + break + } + } + }) + } + proMap[s]?.get(pt)?.apply { + count++ + if (it.ischanged == true) changeNum++ + } + } + } + + //鍗犳瘮缁熻 + val summarys = mutableListOf<Summary>() + var tPros = 0 + proMap.forEach { + it.value.forEach {e -> + val v = e.value + summarys.add(v) + tPros += v.count + } + } + summarys.forEach { + it.countPer = it.count.toDouble() / tPros + it.changePer = it.changeNum.toDouble() / it.count + } + + + head.clear() + head.add( + mutableListOf( + ExcelUtil.MyCell("搴忓彿", rowSpan = 2), + ExcelUtil.MyCell("骞村害", rowSpan = 2), + ExcelUtil.MyCell("鏈堜唤", rowSpan = 2), + ExcelUtil.MyCell("鍦烘櫙绫诲埆", rowSpan = 2), + ExcelUtil.MyCell("鍖哄煙", rowSpan = 2), + ExcelUtil.MyCell("鏂藉伐鎴栬繍钀ョ姸鎬�", rowSpan = 2), + ExcelUtil.MyCell("鏂藉伐闃舵", rowSpan = 2), + ExcelUtil.MyCell("闂澶х被锛堜簩绾ф寚鏍囷級", rowSpan = 2), + ExcelUtil.MyCell("闂灏忕被锛堜笁绾ф寚鏍囷級", rowSpan = 2), + ExcelUtil.MyCell("闂鍗犳瘮鎺掑悕鍒嗘瀽", colSpan = 2), + ExcelUtil.MyCell("鏁存敼鐜囨帓鍚嶅垎鏋�", colSpan = 2), + ) + ) + head.add( + mutableListOf( + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell("鍚堣闂鏁�"), + ExcelUtil.MyCell("闂鍗犳瘮"), + ExcelUtil.MyCell("鏁存敼鏁�"), + ExcelUtil.MyCell("鏁存敼鐜�"), + ) + ) + for (i in summarys.indices) { + val s = summarys[i] + contents.add( + mutableListOf( + i + 1, "", "", dataSource.rowData.scene?.type ?: "", "", s.status, s.status, + s.proType, s.proDes, + s.count, "${round(s.countPer * 1000) / 10}%", + s.changeNum, "${round(s.changePer * 1000) / 10}%", + ) + ) + } + } + + inner class Summary() { + var status = "" + var proType = "" + var proDes = "" + var count = 0 + var countPer = .0 + set(value) { + field = if (value.isNaN()) .0 else value + } + + var changeNum = 0 + var changePer = .0 + set(value) { + field = if (value.isNaN()) .0 else value + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreAnalysisSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreAnalysisSummary.kt new file mode 100644 index 0000000..e6bf6cb --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreAnalysisSummary.kt @@ -0,0 +1,176 @@ +package cn.flightfeather.supervision.business.report.template + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.BaseTemplate +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.business.report.cols.ColGrade +import cn.flightfeather.supervision.common.utils.ExcelUtil +import kotlin.math.round + +class ScoreAnalysisSummary(dataSource: DataSource) : BaseTemplate(dataSource) { + override val cols: List<BaseCols> = listOf(ColGrade()) + + override val templateName: String = "鍒嗚闀囪鑼冩�у垎鏋愯〃" + + override fun execute() { + dataSource.reset() + cols.forEach { it.combineHead(head,dataSource) } + + val districtMap = mutableMapOf<String?, Summary>() + dataSource.loop { index, rowData -> + + val r = cols[0].getOneRow(rowData) + + val k = rowData.scene?.townname + if (!districtMap.containsKey(k)) { + districtMap[k] = Summary().apply { + townCode = rowData.scene?.towncode ?: "" + townName = rowData.scene?.townname ?: "" + type = rowData.scene?.type ?: "" + } + } + if (r[1] is String) { + val s = r[1] + } + districtMap[k]?.apply { + sceneCount++ + rowData.evaluation?.run { gradeCount++ } + if ((r[1] is String) && (r[1] as String).isBlank()) return@loop + when ((r[1] as ExcelUtil.MyCell).text) { + "瑙勮寖" -> { + level1++ + standard++ + } + "鍩烘湰瑙勮寖" -> { + level2++ + standard++ + } + "涓嶈鑼�" -> { + level3++ + nonstandard++ + } + "涓ラ噸涓嶈鑼�" -> { + level4++ + nonstandard++ + } + } + } + } + + //鍗犳瘮缁熻 + val summarys = mutableListOf<Summary>() + var tLevel1 = 0 + var tLevel2 = 0 + var tLevel3 = 0 + var tLevel4 = 0 + var tNonstandard = 0 + var tStandard = 0 + districtMap.forEach { + val v = it.value + summarys.add(v) + tLevel1 += v.level1 + tLevel2 += v.level2 + tLevel3 += v.level3 + tLevel4 += v.level4 + tNonstandard += v.nonstandard + tStandard += v.standard + } + summarys.sortByDescending { it.standardPer } + for (i in summarys.indices) { + val it = summarys[i] + //鍙傝瘎鐧惧垎姣� + it.gradePer = it.gradeCount.toDouble() / it.sceneCount + //瑙勮寖銆佸熀鏈鑼冦�佷笉瑙勮寖鍜屼弗閲嶄笉瑙勮寖鍖哄煙鍗犳瘮 + it.level1Per = it.level1.toDouble() / tLevel1 + it.level2Per = it.level2.toDouble() / tLevel2 + it.level3Per = it.level3.toDouble() / tLevel3 + it.level4Per = it.level4.toDouble() / tLevel4 + //涓嶈鑼冨尯鍩熷崰姣� + it.nonstandardPer = it.nonstandard.toDouble() / tNonstandard + //瑙勮寖鍖哄煙鍗犳瘮 + it.standardPer = it.standard.toDouble() / tStandard + //瑙勮寖鍗犳瘮鎺掑悕 + it.rank = i + 1 + } + + head.clear() + head.add(mutableListOf( + ExcelUtil.MyCell("琛楅晣搴忓彿", rowSpan = 2), + ExcelUtil.MyCell("琛楅晣/宸ヤ笟鍖�", rowSpan = 2), + ExcelUtil.MyCell("鍦烘櫙绫诲埆", rowSpan = 2), + ExcelUtil.MyCell("鍙傝瘎鎯呭喌", colSpan = 3), + ExcelUtil.MyCell("瑙勮寖鎬у垎绫诲垎鏋�", colSpan = 8), + ExcelUtil.MyCell("瑙勮寖鎬ф眹鎬诲垎鏋�", colSpan = 5), + )) + head.add(mutableListOf( + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell(""), + ExcelUtil.MyCell("鍦烘櫙鎬绘暟"), + ExcelUtil.MyCell("鍙傝瘎鏁�"), + ExcelUtil.MyCell("鍙傝瘎鐧惧垎姣�"), + ExcelUtil.MyCell("闃叉不瑙勮寖"), + ExcelUtil.MyCell("鍖哄煙鍗犳瘮"), + ExcelUtil.MyCell("闃叉不鍩烘湰瑙勮寖"), + ExcelUtil.MyCell("鍖哄煙鍗犳瘮"), + ExcelUtil.MyCell("闃叉不涓嶈鑼�"), + ExcelUtil.MyCell("鍖哄煙鍗犳瘮"), + ExcelUtil.MyCell("闃叉不涓ラ噸涓嶈鑼�"), + ExcelUtil.MyCell("鍖哄煙鍗犳瘮"), + ExcelUtil.MyCell("鍚勭被涓嶈鑼冨悎璁�"), + ExcelUtil.MyCell("鍚勭被涓嶈鑼冨悎璁″尯鍩熷崰姣�"), + ExcelUtil.MyCell("鍚勭被瑙勮寖鍚堣"), + ExcelUtil.MyCell("鍚勭被瑙勮寖鍚堣鍖哄煙鍗犳瘮"), + ExcelUtil.MyCell("瑙勮寖鎬ф帓鍚�"), + )) + + summarys.forEach { + contents.add( + mutableListOf( + it.townCode, it.townName, it.type, it.sceneCount, it.gradeCount, "${round(it.gradePer * 1000) / 10}%", + it.level1, "${round(it.level1Per * 1000) / 10}%", + it.level2, "${round(it.level2Per * 1000) / 10}%", + it.level3, "${round(it.level3Per * 1000) / 10}%", + it.level4, "${round(it.level4Per * 1000) / 10}%", + it.nonstandard, "${round(it.nonstandardPer * 1000) / 10}%", + it.standard, "${round(it.standardPer * 1000) / 10}%", + it.rank + ) + ) + } + } + + inner class Summary(){ + var townCode = "" + var townName = "" + var type = "" + var sceneCount = 0 + //鍙傝瘎鏁� + var gradeCount = 0 + var gradePer = .0 + set(value) { field = if (value.isNaN()) .0 else value } + //瑙勮寖銆佸熀鏈鑼冦�佷笉瑙勮寖鍜屼弗閲嶄笉瑙勮寖鏁伴噺鍙婂尯鍩熷崰姣� + var level1 = 0 + var level1Per = .0 + set(value) { field = if (value.isNaN()) .0 else value } + var level2 = 0 + var level2Per = .0 + set(value) { field = if (value.isNaN()) .0 else value } + var level3 = 0 + var level3Per = .0 + set(value) { field = if (value.isNaN()) .0 else value } + var level4 = 0 + var level4Per = .0 + set(value) { field = if (value.isNaN()) .0 else value } + //涓嶈鑼冨悎璁″強鍖哄煙鍗犳瘮 + var nonstandard = 0 + var nonstandardPer = .0 + set(value) { field = if (value.isNaN()) .0 else value } + //瑙勮寖鍚堣鍙婂尯鍩熷崰姣� + var standard = 0 + var standardPer = .0 + set(value) { field = if (value.isNaN()) .0 else value } + //瑙勮寖鍗犳瘮鎺掑悕 + var rank = 0 + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreDetailSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreDetailSummary.kt new file mode 100644 index 0000000..25b3c7a --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreDetailSummary.kt @@ -0,0 +1,13 @@ +package cn.flightfeather.supervision.business.report.template + +import cn.flightfeather.supervision.business.report.BaseCols +import cn.flightfeather.supervision.business.report.BaseTemplate +import cn.flightfeather.supervision.business.report.DataSource +import cn.flightfeather.supervision.business.report.cols.ColGrade +import cn.flightfeather.supervision.business.report.cols.ColSceneName +import cn.flightfeather.supervision.business.report.cols.ColTown + +class ScoreDetailSummary(dataSource: DataSource) : BaseTemplate(dataSource) { + override val cols: List<BaseCols> = listOf(ColSceneName(), ColTown(), ColGrade()) + override val templateName: String = "瑙勮寖鎬ц瘎浼拌鎯呰〃" +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/storage/StAutoScore.kt b/src/main/kotlin/cn/flightfeather/supervision/business/storage/StAutoScore.kt index c776371..00721c7 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/storage/StAutoScore.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/storage/StAutoScore.kt @@ -110,10 +110,10 @@ fun topTaskGrade(topTaskId:String) { rows.clear() subtaskMapper.selectByTopTask2(topTaskId, sceneType.value.toInt()).forEach { -// sceneGrade(it) - sceneGradeToFile(it) + sceneGrade(it) +// sceneGradeToFile(it) } - toFile() +// toFile() } /** diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/utils/Constant.kt b/src/main/kotlin/cn/flightfeather/supervision/common/utils/Constant.kt index d75f106..921170e 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/common/utils/Constant.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/common/utils/Constant.kt @@ -40,6 +40,25 @@ TYPE14.value -> 4 else -> sceneTypeId } + + fun getDes(value: Int?) = when (value.toString()) { + "1" -> TYPE1.text + "2" -> TYPE2.text + "3" -> TYPE3.text + "4" -> TYPE4.text + "5" -> TYPE5.text + "6" -> TYPE6.text + "7" -> TYPE7.text + "8" -> TYPE8.text + "9" -> TYPE9.text + "10" -> TYPE10.text + "11" -> TYPE11.text + "12" -> TYPE12.text + "13" -> TYPE13.text + "14" -> TYPE14.text + "99" -> TYPE99.text + else -> "" + } } } diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt b/src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt index 8bb0aeb..3bd21a9 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt @@ -181,11 +181,11 @@ /** * 鑷姩澶勭悊琛屽悎骞舵暟鎹� */ - fun write2(out: OutputStream, heads: List<Array<Any>>, contents: MutableList<Array<Any>>) { + fun write2(out: OutputStream, heads: List<Array<Any>>, contents: MutableList<Array<Any>>, sheetName: String = "sheet1") { val workbook = HSSFWorkbook() - write(heads, contents, workbook) + write(heads, contents, workbook, sheetName) workbook.write(out) workbook.close() @@ -193,6 +193,10 @@ out.close() } + fun write3() { + + } + private fun getMaxRows(rowArray: Array<Any>): Int { var maxRows = 1 rowArray.forEach { diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/utils/FileUtil.kt b/src/main/kotlin/cn/flightfeather/supervision/common/utils/FileUtil.kt index 2cd72f0..f96d545 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/common/utils/FileUtil.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/common/utils/FileUtil.kt @@ -1,10 +1,10 @@ package cn.flightfeather.supervision.common.utils -import java.io.File -import java.io.FileOutputStream -import java.io.FileInputStream - - +import java.awt.Image +import java.awt.image.BufferedImage +import java.io.* +import java.util.* +import javax.imageio.ImageIO object FileUtil { @@ -116,4 +116,32 @@ } } + + /** + * 鎸夌収鍥哄畾瀹藉害鍘嬬缉鍥剧墖鑷砨ase64褰㈠紡 + */ +// fun compressImage2(bytes: ByteArray): String { +// val length = 1440//鍥剧墖闀胯竟鍥哄畾鍘嬬缉涓�1440鍍忕礌 +// +// val input = ByteArrayInputStream(bytes) +// val srcImg = ImageIO.read(input) +// var srcLong = 0 +// var srcShort = 0 +// if (srcImg.width <= srcImg.height) { +// srcLong = srcImg.height +// srcShort = srcImg.width +// +// } else { +// +// } +// val scale = w.toFloat() / srcW +// val h = (srcImg.height * scale).toInt() +// +// val buffImg = BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB) +// buffImg.graphics.drawImage(srcImg.getScaledInstance(w, h, Image.SCALE_SMOOTH), 0, 0, null) +// val out = ByteArrayOutputStream() +// ImageIO.write(buffImg, "PNG", out) +// +// return SCHEME_PNG + Base64.getEncoder().encodeToString(out.toByteArray()) +// } } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SearchService.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SearchService.kt index 8c84af7..214eb3a 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SearchService.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SearchService.kt @@ -9,7 +9,7 @@ */ interface SearchService { - fun writeToFile(config: ExcelConfigVo) + fun writeToFile(config: ExcelConfigVo, mode: Int) fun getExcel(config: ExcelConfigVo, response: HttpServletResponse): HttpServletResponse 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..647b09e 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,5 +1,11 @@ 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.* @@ -36,19 +42,58 @@ val scoreMapper: ScoreMapper, val inspectionMapper: InspectionMapper, val taskMapper: TaskMapper, - val monitorobjectversionMapper: MonitorobjectversionMapper + val monitorobjectversionMapper: MonitorobjectversionMapper, + val evaluationruleMapper: EvaluationruleMapper, + val evaluationsubruleMapper: EvaluationsubruleMapper2, + val evaluationMapper: EvaluationMapper, + val itemevaluationMapper: ItemevaluationMapper ) : 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 + ) + 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 { @@ -517,7 +562,7 @@ //鍘熸湁鐨勭涓�琛岃〃澶村鍔�1琛岃璺ㄥ害,鍚屾椂鏂扮殑绗簩琛岃〃澶存坊鍔犵┖浣� head[0].forEach { (it as ExcelUtil.MyCell).rowSpan++ - h2.add(0, "") +// h2.add(0, "") } //鍚堝苟琛ㄥご head[0].addAll(h1) diff --git a/src/main/resources/generator/generatorConfig4ds1.xml b/src/main/resources/generator/generatorConfig4ds1.xml index d162ed8..b694f3e 100644 --- a/src/main/resources/generator/generatorConfig4ds1.xml +++ b/src/main/resources/generator/generatorConfig4ds1.xml @@ -19,7 +19,7 @@ <property name="suppressAllComments" value="true"/> </commentGenerator> <!--鏁版嵁搴撻摼鎺RL锛岀敤鎴峰悕銆佸瘑鐮� --> - <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://47.100.191.150:3306/ledger?serverTimezone=Asia/Shanghai" + <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://47.100.191.150:3306/supervision?serverTimezone=Asia/Shanghai" userId="remoteU1" password="eSoF8DnzfGTlhAjE"> </jdbcConnection> @@ -27,16 +27,16 @@ <property name="forceBigDecimals" value="false"/> </javaTypeResolver> <!-- 鐢熸垚妯″瀷鐨勫寘鍚嶅拰浣嶇疆--> - <javaModelGenerator targetPackage="cn.flightfeather.supervision.domain.ds2.entity" targetProject="src/main/kotlin"> + <javaModelGenerator targetPackage="cn.flightfeather.supervision.domain.ds1.entity" targetProject="src/main/kotlin"> <property name="enableSubPackages" value="true"/> <property name="trimStrings" value="true"/> </javaModelGenerator> <!-- 鐢熸垚鏄犲皠鏂囦欢鐨勫寘鍚嶅拰浣嶇疆--> - <sqlMapGenerator targetPackage="ds2" targetProject="src/main/resources/mapper"> + <sqlMapGenerator targetPackage="ds1" targetProject="src/main/resources/mapper"> <property name="enableSubPackages" value="true"/> </sqlMapGenerator> <!-- 鐢熸垚DAO鐨勫寘鍚嶅拰浣嶇疆--> - <javaClientGenerator type="XMLMAPPER" targetPackage="cn.flightfeather.supervision.domain.ds2.mapper" targetProject="src/main/kotlin"> + <javaClientGenerator type="XMLMAPPER" targetPackage="cn.flightfeather.supervision.domain.ds1.mapper" targetProject="src/main/kotlin"> <property name="enableSubPackages" value="true"/> </javaClientGenerator> <!-- 瑕佺敓鎴愮殑琛� tableName鏄暟鎹簱涓殑琛ㄥ悕鎴栬鍥惧悕 domainObjectName鏄疄浣撶被鍚�--> @@ -77,6 +77,8 @@ <!-- <table tableName="sm_t_night_construction" domainObjectName="NightConstruction" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>--> <!-- <table tableName="sm_t_score" domainObjectName="Score" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> <!-- <table tableName="sm_t_scense" domainObjectName="Scense" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> - <table tableName="ea_t_mediafile" domainObjectName="LedgerMediaFile" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> +<!-- <table tableName="ea_t_mediafile" domainObjectName="LedgerMediaFile" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> + <table tableName="ea_t_dust_data_result" domainObjectName="DustDataResult" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" + enableSelectByExample="false" selectByExampleQueryId="false"/> </context> </generatorConfiguration> \ No newline at end of file diff --git a/src/test/kotlin/cn/flightfeather/supervision/business/fume/AutoScoreTest.kt b/src/test/kotlin/cn/flightfeather/supervision/business/fume/AutoScoreTest.kt index bd46631..f02583c 100644 --- a/src/test/kotlin/cn/flightfeather/supervision/business/fume/AutoScoreTest.kt +++ b/src/test/kotlin/cn/flightfeather/supervision/business/fume/AutoScoreTest.kt @@ -39,7 +39,9 @@ @Test fun go() { autoScore.sceneType = Constant.ScenseType.TYPE1 - autoScore.topTaskGrade("Z3RwJ5jF123sjDsj") + autoScore.topTaskGrade("tgfMJWdUJqWE6bWo") +// val subtask = subtaskMapper.selectByPrimaryKey("1DxdkFdVAdQD5Mce") +// autoScore.sceneGrade(subtask) // autoScore3.go(2022, 1, 2) // val t = problemlistMapper.getStatisticalResult("310116", "2021-09-01 00:00:00", "2021-09-30 00:00:00", "1") // println() diff --git a/src/test/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImplTest.kt b/src/test/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImplTest.kt index 9b6ce43..498bc47 100644 --- a/src/test/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImplTest.kt +++ b/src/test/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImplTest.kt @@ -30,6 +30,11 @@ val localTimeE = LocalDateTime.of(2021, 3, 31, 23, 59, 59) val sD = Date.from(localTimeS.atZone(ZoneId.systemDefault()).toInstant()) val eD = Date.from(localTimeE.atZone(ZoneId.systemDefault()).toInstant()) - searchService.writeToFile(ExcelConfigVo("Z3RwJ5jF123sjDsj", districtCode = "310106", sceneType = 1)) + + val mode = 10 + //閲戝北2022骞�6鏈� + searchService.writeToFile(ExcelConfigVo("tgfMJWdUJqWE6bWo", districtCode = "310116", sceneType = 1), mode) + //閲戝北2021骞�3鏈� +// searchService.writeToFile(ExcelConfigVo("o7jdSzr79fe0NH3I", districtCode = "310116", sceneType = 1)) } } \ No newline at end of file -- Gitblit v1.9.3