From eb3dd00b0b7fcda477229d518d250f9c842b790b Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 21 十月 2025 17:45:44 +0800
Subject: [PATCH] 2025.10.21 1. 走航季度报告相关数据计算逻辑调整
---
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt | 92 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 90 insertions(+), 2 deletions(-)
diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt
index 8e0c9af..2c3e172 100644
--- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt
+++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt
@@ -1,16 +1,104 @@
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.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
+import com.flightfeather.uav.model.epw.EPWModel
+import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Service
import tk.mybatis.mapper.entity.Example
@Service
-class CompanyServiceImpl(private val companyMapper: CompanyMapper) : CompanyService {
+class CompanyServiceImpl(
+ private val companyMapper: CompanyMapper,
+ private val realTimeDataService: RealTimeDataService,
+ private val complaintMapper: ComplaintMapper,
+ private val assessmentMapper: AssessmentMapper
+) : CompanyService {
+
+
override fun getCompanyInfo(): BaseResponse<List<Company>> {
val result = companyMapper.selectAll()
return BaseResponse(true, data = result)
}
+
+ override fun getCompany(cId: String): BaseResponse<Company> {
+ companyMapper.selectByPrimaryKey(cId)?.let {
+ return BaseResponse(true, data = it)
+ }
+ return BaseResponse(false, "浼佷笟id涓嶅瓨鍦�")
+ }
+
+ override fun getEpwModelResult(
+ deviceCode: String,
+ startTime: String,
+ endTime: String,
+ companyIds: List<String>?
+ ): BaseResponse<MutableMap<String, MutableMap<String, MutableMap<String, BaseModel.ResultCell>>>> {
+ val company = if (companyIds == null) {
+ companyMapper.selectAll()
+ } else {
+ companyMapper.selectByExample(Example(Company::class.java).apply {
+ createCriteria().apply {
+ companyIds.forEach { orEqualTo("ciGuid", it) }
+ }
+ })
+ }
+ val companySOPList = mutableListOf<CompanySOP>()
+ company.forEach {
+ val companySOP = CompanySOP(it.ciGuid, it.ciName, it.ciExtension1)
+ BeanUtils.copyProperties(it, companySOP)
+ companySOPList.add(companySOP)
+ }
+
+ val epwModel = EPWModel()
+ // TODO: 2021/7/6 閮ㄥ垎璁惧鏄浐瀹氱偣鐩戞祴璁惧锛屼笉浼氱Щ鍔紝鍥犳鏁版嵁涓病鏈夌粡绾害锛岄渶瑕侀澶栬缃洃娴嬬偣缁忕含搴�
+// epwModel.defaultLocation =
+
+ var page = 1
+ var totalPage = -1
+ while (totalPage == -1 || page <= totalPage) {
+ realTimeDataService.getSecondData(null, deviceCode, startTime, endTime, 0, page, 5000).apply {
+ if (totalPage == -1) {
+ totalPage = head?.totalPage ?: 0
+ }
+ 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++
+ }
+ }
+ 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)
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3