feiyu02
2022-07-19 b041775dae4438e428d2b70d2b22cfe8c49844fe
1. 巡查汇总报告功能编写基本完成
已修改12个文件
已添加21个文件
1784 ■■■■■ 文件已修改
src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/BaseExcel.kt 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt 296 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColGrade.kt 111 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColInspectionInfo.kt 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColLedger.kt 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColProChange.kt 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColProblemDistribution.kt 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColSceneName.kt 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStatus.kt 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTown.kt 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportOne.kt 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportThree.kt 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/file/ReportTwo.kt 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt 169 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProDetailSummary.kt 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeDetailSummary.kt 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankSummary.kt 125 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreAnalysisSummary.kt 176 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreDetailSummary.kt 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/storage/StAutoScore.kt 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/common/utils/Constant.kt 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/common/utils/FileUtil.kt 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SearchService.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt 63 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/generator/generatorConfig4ds1.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/cn/flightfeather/supervision/business/fume/AutoScoreTest.kt 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImplTest.kt 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt
@@ -18,7 +18,7 @@
    @Bean
    fun runner() = ApplicationRunner {
        fetchController.run()
//        fetchController.run()
    }
}
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)
            }
        }
    }
}
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()
    }
}
src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt
@@ -1,14 +1,101 @@
package cn.flightfeather.supervision.business.report
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.*
/**
 * æŠ¥å‘Šæ¨¡æ¿åŸºç±»
 * excel报告模板基类
 */
abstract class BaseTemplate {
// 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)
    }
}
    //固定列组合
    //名称
    //基本信息
    //问题扣分分布
    //问题整改分布
    //监管详情
}
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()
    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)
    }
    fun loop(callback: (index:Int, rowData: RowData) -> Unit) {
        reset()
        for (i in sourceList.indices) {
            rowData.clear()
            rowData.subTask = sourceList[i]
            callback(i, rowData)
        }
    }
    /**
     * æŒ‡å®šå½“前进行统计的主体对象
     * é‡ç½®
     */
    fun mainObj(subtask: Subtask) {
        this.subTask = subTask
    fun reset() {
        rowData.subTask = sourceList.first()
        rowData.clear()
    }
    /**
     * æ•°æ®ç»Ÿè®¡çš„æ—¶é—´å’ŒåŒºåŸŸåç§°
     */
    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
    //场景基本信息
    var scene: Scense? = null
        val scene: Scense?
            get() {
                if (_scene == null) {
                    _scene = dbMapper.scenseMapper.selectByPrimaryKey(subTask?.scenseid)
                }
                return _scene
            }
        private var _scene: Scense? = null
    //问题类型
    var problemTypes = mutableListOf<Problemtype>()
        //各场景特有的基本信息
        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
    //具体的问题
    var problems = mutableListOf<Problemlist>()
        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
)
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 å†³å®šæ˜¯å¦å†™h3
                            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
    }
}
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
    }
}
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("", "", "")
    }
}
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)
    }
}
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
    }
}
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 ?: "")
    }
}
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)
    }
}
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 ?: "")
    }
}
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 = "问题与整改汇总分析与动态跟踪清单"
}
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 = "问题与整改分布分析清单"
}
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 = "规范性评估与分析清单"
}
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
    }
}
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 = "问题与整改跟踪汇总表"
}
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 = "问题与整改分类统计表"
}
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}%"
                )
            )
        }
    }
}
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
    }
}
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
            }
    }
}
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
    }
}
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 = "规范性评估详情表"
}
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()
    }
    /**
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 -> ""
            }
        }
    }
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 {
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 @@
        }
    }
    /**
     * æŒ‰ç…§å›ºå®šå®½åº¦åŽ‹ç¼©å›¾ç‰‡è‡³base64形式
     */
//    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())
//    }
}
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
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)
src/main/resources/generator/generatorConfig4ds1.xml
@@ -19,7 +19,7 @@
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>
        <!--数据库链接URL,用户名、密码 -->
        <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>
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()
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))
    }
}