hcong
2024-12-10 82baf5d28ce79aa4d3b64956207d247596726924
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
import org.junit.jupiter.api.extension.ExtendWith
 
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
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.*
 
@RunWith(SpringRunner::class)
@ExtendWith(SpringExtension::class)
@SpringBootTest
class SearchServiceImplTest {
 
    @Autowired
    lateinit var searchService: SearchService
 
    @Autowired
    lateinit var subtaskMapper: SubtaskMapper
 
    @Test
    fun getExcel() {
        val localTimeS = LocalDateTime.of(2021, 3, 1, 0, 0, 0)
        val localTimeE = LocalDateTime.of(2021, 3, 31, 23, 59, 59)
        val sD = Date.from(localTimeS.atZone(ZoneId.systemDefault()).toInstant())
        val eD = Date.from(localTimeE.atZone(ZoneId.systemDefault()).toInstant())
 
        val mode = 9
        //金山2022年6月
        searchService.writeToFile(ExcelConfigVo(
            "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)
    }
}