feiyu02
2024-08-15 196bb14112448857a885e32dc4149e308e00b01a
src/test/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/EvaluationServiceImplTest.kt
@@ -1,5 +1,6 @@
package cn.flightfeather.supervision.lightshare.service.Impl
import cn.flightfeather.supervision.domain.mapper.OverallEvaluationMapper
import cn.flightfeather.supervision.lightshare.service.EvaluationService
import org.junit.Test
@@ -10,6 +11,11 @@
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit.jupiter.SpringExtension
import org.springframework.test.context.junit4.SpringRunner
import java.time.Instant
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.ZoneId
import java.util.*
@RunWith(SpringRunner::class)
@ExtendWith(SpringExtension::class)
@@ -19,6 +25,9 @@
    @Autowired
    lateinit var evaluationService: EvaluationService
    @Autowired
    lateinit var overallEvaluationMapper: OverallEvaluationMapper
    @Test
    fun getTotalPoints() {
        val r = evaluationService.getTotalPoints("xB32EtpuxU5bOzq5", 2, "2021-01-01", "2021-04-01",7,"3mbioCjN6XAAHveR",null)
@@ -27,7 +36,30 @@
    @Test
    fun getCreditInfo() {
        val r = evaluationService.getCreditInfo("UwTaWXneBoTby6bH")
        val r = evaluationService.getCreditInfo("UwTaWXneBoTby6bH", "2022/10-12")
        println(r)
    }
    @Test
    fun refreshCreditCodeTime() {
        overallEvaluationMapper.selectAll().forEach {
            val period = it.oePeriod
            if (period != null && period.isNotBlank()) {
                val list1 = period.split("/")
                val year = list1[0].toInt()
                val list2 = list1[1].split("-")
                val sMonth = list2[0].toInt()
                val eMonth = list2[1].toInt()
                val sTime = LocalDate.of(year, sMonth, 1)
                val eTime = LocalDate.of(year, eMonth, 1).plusMonths(1).minusDays(1)
                if (it.oeStartTime == null && it.oeEndTime == null) {
                    it.oeStartTime = Date.from(sTime.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant())
                    it.oeEndTime = Date.from(eTime.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant())
                    overallEvaluationMapper.updateByPrimaryKeySelective(it)
                }
            }
        }
    }
}