feiyu02
2024-09-10 6c7f45871b93ef26d353a5a3596701ac2f39ed9c
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
package cn.flightfeather.supervision.lightshare.service.impl
 
import cn.flightfeather.supervision.common.exception.BizException
import cn.flightfeather.supervision.domain.ds1.repository.SceneRep
import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
import cn.flightfeather.supervision.domain.ds1.repository.UserInfoSVRep
import cn.flightfeather.supervision.domain.ds2.repository.ComplaintAndPunishmentRep
import cn.flightfeather.supervision.domain.ds2.repository.UserInfoTZRep
import cn.flightfeather.supervision.domain.ds2.repository.UserMapRep
import cn.flightfeather.supervision.lightshare.service.ComplaintService
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import cn.flightfeather.supervision.lightshare.vo.ComplaintVo
import cn.flightfeather.supervision.lightshare.vo.PunishmentVo
import org.springframework.stereotype.Service
 
@Service
class ComplaintServiceImpl(
    private val complaintAndPunishmentRep: ComplaintAndPunishmentRep,
    private val sceneRep: SceneRep,
    private val taskRep: TaskRep,
    private val userInfoSVRep: UserInfoSVRep,
    private val userInfoTZRep: UserInfoTZRep,
    private val userMapRep: UserMapRep,
) : ComplaintService {
 
    private fun getTZUserId(areaVo: AreaVo): List<String?> {
        return when (areaVo.sourceType) {
            //以飞羽环境系统中的用户为主体
            1 -> {
                val u = userInfoTZRep.findEnterpriseUser(areaVo.districtname, areaVo.scensetypeid?.toInt())
                u.map { it?.guid }
            }
            //以飞羽监管系统中的用户为主体
            2 -> {
                val task = taskRep.findOneTask(areaVo) ?: throw BizException("当前查询条件下未找到对应顶层任务")
                val scenes = sceneRep.findScene(task.tguid!!, areaVo.scensetypeid?.toInt(), areaVo.towncode)
                    .map { it?.guid }
                val idList = userInfoSVRep.findUser(scenes).map { it?.guid }
                userMapRep.findBySVUserId(idList).map { it?.tzUserId }
            }
            else -> emptyList()
        }
    }
 
    override fun findComplaints(areaVo: AreaVo): List<ComplaintVo?> {
        val userIdList = getTZUserId(areaVo)
        return complaintAndPunishmentRep.findComplaint(userIdList, areaVo.starttime, areaVo.endtime)
    }
 
    override fun findPunishment(areaVo: AreaVo): List<PunishmentVo?> {
        val userIdList = getTZUserId(areaVo)
        return complaintAndPunishmentRep.findPunishment(userIdList, areaVo.starttime, areaVo.endtime)
    }
}