package cn.sagacloud.server.algorithm.models.excel.report

import cn.sagacloud.server.algorithm.models.excel.ExcelRowData
import cn.sagacloud.server.algorithm.models.excel.IsPassedEnum
import cn.sagacloud.server.algorithm.models.excel.PreciseCellValue
import cn.sagacloud.server.algorithm.services.excel.ExcelService
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component

/**
 *
 * 阻塞性报告 - 总体报告
 * @author jxing
 */
@Component
@Scope("prototype")
open class BlockingTotalReport : ModelQualityExcelReport() {

    // excel中sheet的索引, 从0开始
    override var sheetIndex = 0
    //open var cellValues : ArrayList<PreciseCellValue> = ArrayList()

    override var rowValue : ArrayList<ExcelRowData> = ArrayList()
    // 在excel中开始插入数据的索引(真实行数减1)
    override var excelStartRow = 5

    class Data : ExcelRowData(){
        var checkItemName = ""
        var result = IsPassedEnum.Unpass
    }

    /**
     * 写入一行数据
     */
    fun writeToRow(checkItemName : String, isPassedEnum : IsPassedEnum){
        var data = Data()
        data.checkItemName = checkItemName
        data.result = isPassedEnum
        rowValue.add(data)
    }

    /**
     * 添加任意单元格需要写入数据
      */
    fun addCellValue(rowIndex : Int, columnIndex : Int, value : Any){
        val cell = PreciseCellValue()
        cell.rowIndex = rowIndex
        cell.columnIndex = columnIndex
        cell.obj = value
        cellValues.add(cell)
    }

    /**
     * 向总体报告里面写单模型检查结果
     */
    fun writeSingleCheckResult(floorName : String?, excelService: ExcelService){
        excelService.insertReport(this)
        addCellValue(0, 1, floorName?:"")
        addCellValue(2, 1, floorName?:"")
        excelService.randomWrite(sheetIndex, cellValues)
    }

}