feiyu02
2025-09-30 6904763f0e74d9a9fa4dbc39f635d2aee39416c6
src/main/kotlin/cn/flightfeather/supervision/common/score/AutoScore.kt
@@ -38,6 +38,8 @@
//        private val SCENE_TYPE = SceneType.Restaurant
        private val SCENE_TYPE = SceneType.VehicleRepair
        private val district = "徐汇区"
    }
    @PostConstruct
@@ -94,19 +96,19 @@
    }
    fun go(_year: Int? = null, _month: Int? = null) {
        val fileName = "汽修自动评分-${DateUtil().DateToString(Date(), "yyyy-MM-ddhhmmss")}.xls"
        val filePath = "E:\\工作\\开发\\飞羽环境app\\自动评分\\汽修\\$fileName"
        val fileName = "${district}${SCENE_TYPE.des}自动评分-${DateUtil.DateToString(Date(), "yyyy-MM-ddhhmmss")}.xls"
//        val filePath = "E:\\工作\\开发\\飞羽环境app\\自动评分\\${SCENE_TYPE.des}\\$fileName"
        val filePath = "C:\\work\\工作\\第三方监管\\自动评分\\${SCENE_TYPE.des}\\$fileName"
        val out = FileOutputStream(File(filePath))
        getScoreItem()
        val userList = userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
            createCriteria().andEqualTo("usertypeid", UserType.Enterprise.value.toByte())
                // FIXME: 2021/4/28 场景类型
//                    汽修类型
                .andEqualTo("extension1", district)
                .andEqualTo("extension2", SCENE_TYPE.value.toString())
//            餐饮类型
//                .andEqualTo("extension2", SCENE_TYPE.value.toString())
                .andEqualTo("isenable", true)
            and(createCriteria().orNotEqualTo("workno", "test").orIsNull("workno"))
//            orderBy("workno")
        })
@@ -149,7 +151,7 @@
        val now = LocalDate.now()
        val year = _year ?: now.year
        val month = _month ?: now.monthValue
        val sMonth = DateUtil().getStartMonthByPeriod(month, 3) ?: 1
        val sMonth = DateUtil.getStartMonthByPeriod(month, 3) ?: 1
        val eMonth = sMonth + 2
        val period = "${year}/$sMonth-$eMonth"
@@ -161,12 +163,13 @@
            }
            val info = Info(
                it.guid,
                it.acountname,
                it.realname,
                it?.guid,
                it?.acountname,
                it?.realname,
                SCENE_TYPE,
                year,
                month
                month,
                now
            )
            var score = 0
@@ -280,21 +283,17 @@
                }
            } ?: 0
            // 写入数据库
//            if (r > 0) {
//                evaluationList.forEach { el -> evaluationMapper.insert(el) }
//                itemevaluationList.forEach { il -> itemevaluationMapper.insert(il) }
                for (e in evaluationList) {
                    if (e.ertype?.toInt()?.equals(0) == true) {
                        finalScore(e, year, eMonth, period)
                        break
                    }
                }
//            for (e in evaluationList) {
//                if (e.ertype?.toInt()?.equals(0) == true) {
//                    finalScore(e, year, eMonth, period)
//                    break
//                }
//            }
        }
        // 写入文档
//        ExcelUtil.write2(emptyList(), contents, workbook)
//        workbook.write(out)
        ExcelUtil.write2(emptyList(), contents, workbook)
        workbook.write(out)
        workbook.close()
        out.flush()
        out.close()
@@ -379,47 +378,6 @@
        name = itemRule.itemname
        value = itemRule.extension1 ?: "0"
        extension1 = (itemRule.extension1 != null).toString()
    }
    private fun write2File(info: Info, evaluations: List<Evaluation>, topItems: MutableList<Evaluationsubrule>,
                           rules: MutableList<Pair<Evaluationsubrule, MutableList<Evaluationsubrule>>>) {
        val heads = mutableListOf<Array<String>>()
        val contents = mutableListOf<Array<Any>>()
        topItems.forEach {
            val cList = mutableListOf<Any>()
            cList.add(it.itemname ?: "")
            val array1 = mutableListOf<ExcelUtil.MyCell>()
            val array2 = mutableListOf<ExcelUtil.MyCell>()
            val array3 = mutableListOf<ExcelUtil.MyCell>()
            for (r in rules) {
                if (r.first.fatherid == it.guid || r.first.guid == it.guid) {
                    array1.add(ExcelUtil.MyCell(r.first.itemname?:"", 0))
                    r.second.forEach { s ->
                        if (s.fatherid == r.first.guid) {
                            array2.add(ExcelUtil.MyCell(s.itemname?:"", 1))
                            array3.add(ExcelUtil.MyCell(s.extension1?:"", 1))
                            array1.last().rowSpan++
                        }
                    }
                }
            }
            cList.add(array1.toTypedArray())
            cList.add(array2.toTypedArray())
            cList.add(array3.toTypedArray())
            contents.add(cList.toTypedArray())
        }
        evaluations.forEach {
            if ((it.ertype?.toInt() == 0)) {
                val totalScoreList = mutableListOf<Any>()
                totalScoreList.add("总分")
                totalScoreList.add(it.resultscorebef ?: "0")
                contents.add(totalScoreList.toTypedArray())
            }
        }
        ExcelUtil.write2(heads, contents, workbook!!, info.userName ?: "未知用户")
    }
    private fun addToFile(contents: MutableList<Array<Any>>, info: Info, evaluations: List<Evaluation>, topItems: MutableList<Evaluationsubrule>,