feiyu02
2025-09-12 61871594dfa0a5ac2c4d895d9ec4034feba57094
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt
@@ -1,9 +1,11 @@
package com.flightfeather.uav.lightshare.service.impl
import com.flightfeather.uav.domain.entity.Assessment
import com.flightfeather.uav.domain.entity.Company
import com.flightfeather.uav.domain.mapper.AssessmentMapper
import com.flightfeather.uav.domain.mapper.CompanyMapper
import com.flightfeather.uav.lightshare.bean.BaseResponse
import com.flightfeather.uav.lightshare.bean.CompanySOP
import com.flightfeather.uav.domain.mapper.ComplaintMapper
import com.flightfeather.uav.lightshare.bean.*
import com.flightfeather.uav.lightshare.service.CompanyService
import com.flightfeather.uav.lightshare.service.RealTimeDataService
import com.flightfeather.uav.model.BaseModel
@@ -14,7 +16,11 @@
@Service
class CompanyServiceImpl(
    private val companyMapper: CompanyMapper, private val realTimeDataService: RealTimeDataService) : CompanyService {
    private val companyMapper: CompanyMapper,
    private val realTimeDataService: RealTimeDataService,
    private val complaintMapper: ComplaintMapper,
    private val assessmentMapper: AssessmentMapper
) : CompanyService {
    override fun getCompanyInfo(): BaseResponse<List<Company>> {
@@ -58,11 +64,20 @@
        var page = 1
        var totalPage = -1
        while (totalPage == -1 || page <= totalPage) {
            realTimeDataService.getSecondData(deviceCode, startTime, endTime, page, 5000).apply {
            realTimeDataService.getSecondData(null, deviceCode, startTime, endTime, 0, page, 5000).apply {
                if (totalPage == -1) {
                    totalPage = head?.totalPage ?: 0
                }
                val dataList = data?: emptyList()
                val dataList = data ?: emptyList()
                // FIXME: 2021/7/13 此处为了测试暂时将站点经纬度写死,后续通过数据库配置获取
                dataList.forEach {
                    if (it.lng == 0.0 && it.lat == 0.0) {
                        it.lng = 121.235813
                        it.lat = 30.835898
                    }
                }
                epwModel.execute(dataList, companySOPList, true)
                page++
            }
@@ -70,4 +85,20 @@
        val r = epwModel.outputResult()
        return BaseResponse(true, data = r)
    }
    override fun getComplaintInfo(): BaseResponse<List<ComplaintVo>> {
        val map = mutableMapOf<String, ComplaintVo>()
        complaintMapper.getComplaintInfo().apply { percent() }.forEach {
            if (!map.containsKey(it.ciGuid)) {
                map[it.ciGuid] = ComplaintVo(it.ciGuid, it.ciName, it.ciLng.toDouble(), it.ciLat.toDouble(), it.ciIndex.toIntOrNull() ?: 0, it.ciAddress)
            }
            map[it.ciGuid]?.result?.add(ComplaintType(it.coType, it.coTypeName, it.count.toInt(), it.percent))
        }
        return BaseResponse(true, data = map.values.toList())
    }
    override fun getAssessment(): BaseResponse<List<AssessmentVo>> {
        val result = assessmentMapper.getAssessment()
        return BaseResponse(true, data = result)
    }
}