src/main/kotlin/cn/flightfeather/supervision/business/storage/StAutoScore.kt
@@ -2,6 +2,7 @@
import cn.flightfeather.supervision.business.Info
import cn.flightfeather.supervision.business.ScoreItem
import cn.flightfeather.supervision.business.storage.item.*
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.common.utils.DateUtil
import cn.flightfeather.supervision.common.utils.ExcelUtil
@@ -17,8 +18,6 @@
import tk.mybatis.mapper.entity.Example
import java.io.File
import java.io.FileOutputStream
import java.time.LocalDate
import java.time.LocalDateTime
import java.util.*
import javax.annotation.PostConstruct
import kotlin.math.abs
@@ -29,8 +28,16 @@
 * 工地自动评分
 */
@Component
class StAutoScore(
    stScoreItem_1: ScoreItem,
    csScoreItem_1: CsScoreItem_1,
    csScoreItem_2: CsScoreItem_2,
    mpScoreItem_1: MpScoreItem_1,
    mpScoreItem_2: MpScoreItem_2,
    stScoreItem_1: StScoreItem_1,
    whScoreItem_1: WhScoreItem_1,
    whScoreItem_2: WhScoreItem_2,
    val jinAnScore: JinAnScore,
    var sceneType: Constant.ScenseType = Constant.ScenseType.TYPE1, )
{
    companion object {
@@ -92,7 +99,15 @@
    private val rows = mutableListOf<Array<Any>>()
    init {
        itemList.add(stScoreItem_1)
        itemList.apply {
            add(csScoreItem_1)
            add(csScoreItem_2)
            add(mpScoreItem_1)
            add(mpScoreItem_2)
            add(stScoreItem_1)
            add(whScoreItem_1)
            add(whScoreItem_2)
        }
    }
    @PostConstruct
@@ -109,11 +124,12 @@
     */
    fun topTaskGrade(topTaskId:String) {
        rows.clear()
        getScoreItem()
        subtaskMapper.selectByTopTask2(topTaskId, sceneType.value.toInt()).forEach {
//            sceneGrade(it)
            sceneGradeToFile(it)
            sceneGradeP(it)
//            sceneGradeToFile(it)
        }
        toFile()
//        toFile()
    }
    /**
@@ -124,9 +140,14 @@
        // 获取评分规则
        getScoreItem()
        sceneGradeP(subtask)
    }
    private fun sceneGradeP(subtask: Subtask) {
        val info = itemGrade(subtask)
        val result = totalGrade(info) ?: return
        val result = totalGrade(info, subtask) ?: return
        toDb(info, result)
//        jinAnScore.toDb(result.first, info)
//        addToFile(rows, info, result.first)
//        toFile()
    }
@@ -136,8 +157,11 @@
        getScoreItem()
        val info = itemGrade(subtask)
        val result = totalGrade(info) ?: return
        val result = totalGrade(info, subtask) ?: return
        addToFile(rows, info, result.first)
    }
    fun grade(subtask: Subtask) {
    }
@@ -164,7 +188,15 @@
        val scene = scenseMapper.selectByPrimaryKey(subtask.scenseid)
        val info =
            Info(userInfo?.guid, tzUserId, subtask.scenseid, subtask.scensename, sceneType, subTask = subtask, sceneIndex = scene.index)
            Info(userInfo?.guid,
                tzUserId,
                subtask.scenseid,
                subtask.scensename,
                sceneType,
                subTask = subtask,
                sceneIndex = scene.index,
                online = scene.extension1 != "0"
            )
        /** 1. 根据评分规则对应的问题自动判断是否扣分***************************************************************/
        // 获取该次巡查任务下的所有问题
@@ -178,6 +210,7 @@
            // 具体评分选项
            val subRule = r.second
            subRule.forEach { sr ->
                // 存在多个评分项和同一个问题关联,因此必须全部评分项都判定一遍
                sr.problemlist?.split(",")?.forEach { pId ->
                    if (pList.contains(pId)) {
                        sr.extension1 = (0 - (sr.maxscore ?: 0)).toString()
@@ -226,7 +259,7 @@
    /**
     * 计算总分
     */
    private fun totalGrade(info: Info): Pair<Evaluation, List<Itemevaluation>>? {
    private fun totalGrade(info: Info, subtask: Subtask): Pair<Evaluation, List<Itemevaluation>>? {
        /** 4. 计算总分*************************************************************************/
        val scene = scenseMapper.selectByPrimaryKey(info.subTask?.scenseid) ?: return null
        val inspection = inspectionMapper.selectByExample(Example(Inspection::class.java).apply {
@@ -258,12 +291,12 @@
                townname = scene.townname
                scensename = scene.name
                scenseaddress = scene.location
                evaluatetime = Date()
                evaluatetime = subtask.planstarttime
                evaluatorguid = "admin"
                evaluatorusername = "admin"
                evaluatorrealname = "admin"
                resultscorebef = (totalScore - abs(total)).toString()
                createdate = Date()
                createdate = subtask.planstarttime
                updatedate = Date()
            }
        }