From d978297ae85b2d7453054e616bbbe87bfabe9cbe Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期一, 12 七月 2021 17:38:09 +0800
Subject: [PATCH] 1. 新增用电量数据查询接口 2. 调整污染权重算法

---
 src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 58 insertions(+), 1 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..9dab0f0 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
@@ -3,14 +3,71 @@
 import com.flightfeather.uav.domain.entity.Company
 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.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) : 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(deviceCode, startTime, endTime, page, 5000).apply {
+                if (totalPage == -1) {
+                    totalPage = head?.totalPage ?: 0
+                }
+                val dataList = data?: emptyList()
+                epwModel.execute(dataList, companySOPList, true)
+                page++
+            }
+        }
+        val r = epwModel.outputResult()
+        return BaseResponse(true, data = r)
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3