src/test/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImplTest.kt
@@ -1,6 +1,8 @@
package cn.flightfeather.supervision.lightshare.service.impl
import cn.flightfeather.supervision.SupervisionApplication
import cn.flightfeather.supervision.domain.ds1.entity.Subtask
import cn.flightfeather.supervision.domain.ds1.mapper.SubtaskMapper
import cn.flightfeather.supervision.lightshare.service.SearchService
import cn.flightfeather.supervision.lightshare.vo.ExcelConfigVo
import org.junit.Test
@@ -12,6 +14,7 @@
import org.springframework.test.context.junit.jupiter.SpringExtension
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
import org.springframework.test.context.junit4.SpringRunner
import tk.mybatis.mapper.entity.Example
import java.time.LocalDateTime
import java.time.ZoneId
import java.util.*
@@ -24,6 +27,9 @@
    @Autowired
    lateinit var searchService: SearchService
    @Autowired
    lateinit var subtaskMapper: SubtaskMapper
    @Test
    fun getExcel() {
        val localTimeS = LocalDateTime.of(2021, 3, 1, 0, 0, 0)
@@ -31,14 +37,50 @@
        val sD = Date.from(localTimeS.atZone(ZoneId.systemDefault()).toInstant())
        val eD = Date.from(localTimeE.atZone(ZoneId.systemDefault()).toInstant())
        val mode = 8
        val mode = 9
        //金山2022年6月
        searchService.writeToFile(ExcelConfigVo(
            "tgfMJWdUJqWE6bWo",
            districtCode = "310116",
            "0kG5dblu1uPqo8qW",
            districtCode = "310106",
//            townCode = "310116113",
            sceneType = 1), mode)
        //金山2021年3月
//        searchService.writeToFile(ExcelConfigVo("o7jdSzr79fe0NH3I", districtCode = "310116", sceneType = 1))
    }
    @Test
    fun getDailyReport() {
        val cal = Calendar.getInstance()
        cal.set(2022, 10, 2, 0, 0, 0)
        cal.set(Calendar.MILLISECOND, 0)
        val sDate = cal.time
        cal.add(Calendar.DAY_OF_MONTH, 1)
        val eDate = cal.time
        val r = searchService.getDailyReport(ExcelConfigVo(districtCode = "310116", startTime = sDate, endTime = eDate))
        println(r)
    }
    @Test
    fun foo1() {
        val cal = Calendar.getInstance()
        cal.set(2022, 10, 2, 0, 0, 0)
        cal.set(Calendar.MILLISECOND, 0)
        val sDate = cal.time
        cal.add(Calendar.DAY_OF_MONTH, 1)
        val eDate = cal.time
        val config = ExcelConfigVo(districtCode = "310116", startTime = sDate, endTime = eDate)
        val r = subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
            createCriteria().apply {
                if (config.subTaskIdList?.isNotEmpty() == true) {
                    andIn("stguid", config.subTaskIdList)
                }
                config.startTime?.let { andEqualTo("planstarttime", it) }
//                config.endTime?.let { andLessThanOrEqualTo("planendtime", it) }
                config.districtCode?.let { andEqualTo("districtcode", it) }
//                andEqualTo("tguid", config.topTaskGuid)
            }
        })
        println(r)
    }
}