feiyu02
2024-08-15 196bb14112448857a885e32dc4149e308e00b01a
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,17 +96,19 @@
    }
    fun go(_year: Int? = null, _month: Int? = null) {
        val fileName = "${SCENE_TYPE.des}自动评分-${DateUtil().DateToString(Date(), "yyyy-MM-ddhhmmss")}.xls"
        val filePath = "E:\\工作\\开发\\飞羽环境app\\自动评分\\${SCENE_TYPE.des}\\$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("isenable", true)
            and(createCriteria().orNotEqualTo("workno", "test").orIsNull("workno"))
//            orderBy("workno")
        })
@@ -147,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"
@@ -159,9 +163,9 @@
            }
            val info = Info(
                it.guid,
                it.acountname,
                it.realname,
                it?.guid,
                it?.acountname,
                it?.realname,
                SCENE_TYPE,
                year,
                month,
@@ -374,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>,