From b77a69357da82a965cd63e76e8ceaf625ec4009b Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期四, 15 七月 2021 16:37:47 +0800 Subject: [PATCH] 1. 新增信访信息获取接口 2. 新增用电量信息获取接口 3. 新增风险评估结果接口 4. 新增污染权重实时分析接口 --- src/main/kotlin/com/flightfeather/uav/domain/entity/Assessment.java | 58 ++++ src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt | 37 ++ src/main/kotlin/com/flightfeather/uav/domain/entity/Complaint.java | 145 ++++++++++++ src/main/resources/mapper/AssessmentMapper.xml | 41 +++ src/main/kotlin/com/flightfeather/uav/socket/ServerHandler.kt | 6 src/main/kotlin/com/flightfeather/uav/lightshare/bean/ComplaintVo.kt | 65 +++++ src/main/resources/mapper/ComplaintMapper.xml | 51 ++++ pom.xml | 2 src/main/kotlin/com/flightfeather/uav/lightshare/bean/DataVo.kt | 15 src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ElectricityServiceImpl.kt | 10 src/main/resources/log4j2.xml | 2 src/main/kotlin/com/flightfeather/uav/domain/mapper/ComplaintMapper.kt | 12 + src/main/kotlin/com/flightfeather/uav/lightshare/bean/AssessmentVo.kt | 14 + src/test/kotlin/com/flightfeather/uav/model/epw/EPWDataPrepTest.kt | 103 ++++++++ src/main/resources/generator/generatorConfig.xml | 4 src/test/kotlin/com/flightfeather/uav/Test.kt | 34 ++ src/main/kotlin/com/flightfeather/uav/lightshare/web/ElectricityController.kt | 2 src/main/kotlin/com/flightfeather/uav/lightshare/service/CompanyService.kt | 7 src/main/kotlin/com/flightfeather/uav/domain/mapper/AssessmentMapper.kt | 12 + src/main/kotlin/com/flightfeather/uav/lightshare/web/CompanyController.kt | 11 src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt | 18 + src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt | 3 src/main/kotlin/com/flightfeather/uav/socket/bean/AirData.kt | 3 src/main/resources/application.yml | 12 24 files changed, 643 insertions(+), 24 deletions(-) diff --git a/pom.xml b/pom.xml index ae1c2f8..0e3974e 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ <artifactId>uav</artifactId> <version>1.0.0</version> <packaging>war</packaging> - <name>obd</name> + <name>uav</name> <description>Uav data server</description> <properties> diff --git a/src/main/kotlin/com/flightfeather/uav/domain/entity/Assessment.java b/src/main/kotlin/com/flightfeather/uav/domain/entity/Assessment.java new file mode 100644 index 0000000..b305a10 --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/domain/entity/Assessment.java @@ -0,0 +1,58 @@ +package com.flightfeather.uav.domain.entity; + +import javax.persistence.*; + +@Table(name = "co_assessment") +public class Assessment { + @Id + @Column(name = "ID") + private Integer id; + + @Column(name = "CI_GUID") + private String ciGuid; + + @Column(name = "AS_Risk") + private String asRisk; + + /** + * @return ID + */ + public Integer getId() { + return id; + } + + /** + * @param id + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * @return CI_GUID + */ + public String getCiGuid() { + return ciGuid; + } + + /** + * @param ciGuid + */ + public void setCiGuid(String ciGuid) { + this.ciGuid = ciGuid == null ? null : ciGuid.trim(); + } + + /** + * @return AS_Risk + */ + public String getAsRisk() { + return asRisk; + } + + /** + * @param asRisk + */ + public void setAsRisk(String asRisk) { + this.asRisk = asRisk == null ? null : asRisk.trim(); + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/domain/entity/Complaint.java b/src/main/kotlin/com/flightfeather/uav/domain/entity/Complaint.java new file mode 100644 index 0000000..a160059 --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/domain/entity/Complaint.java @@ -0,0 +1,145 @@ +package com.flightfeather.uav.domain.entity; + +import java.util.Date; +import javax.persistence.*; + +@Table(name = "co_complaint") +public class Complaint { + @Id + @Column(name = "ID") + private Integer id; + + /** + * 浼佷笟id + */ + @Column(name = "CI_GUID") + private String ciGuid; + + /** + * 浼佷笟鍚嶇О + */ + @Column(name = "CI_Name") + private String ciName; + + /** + * 淇¤鎶曡瘔姹℃煋绫诲瀷id + */ + @Column(name = "CO_Type") + private Integer coType; + + /** + * 淇¤鎶曡瘔姹℃煋绫诲瀷 + */ + @Column(name = "CO_Type_Name") + private String coTypeName; + + /** + * 淇¤鏃舵 + */ + @Column(name = "CO_Time") + private Date coTime; + + /** + * @return ID + */ + public Integer getId() { + return id; + } + + /** + * @param id + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * 鑾峰彇浼佷笟id + * + * @return CI_GUID - 浼佷笟id + */ + public String getCiGuid() { + return ciGuid; + } + + /** + * 璁剧疆浼佷笟id + * + * @param ciGuid 浼佷笟id + */ + public void setCiGuid(String ciGuid) { + this.ciGuid = ciGuid == null ? null : ciGuid.trim(); + } + + /** + * 鑾峰彇浼佷笟鍚嶇О + * + * @return CI_Name - 浼佷笟鍚嶇О + */ + public String getCiName() { + return ciName; + } + + /** + * 璁剧疆浼佷笟鍚嶇О + * + * @param ciName 浼佷笟鍚嶇О + */ + public void setCiName(String ciName) { + this.ciName = ciName == null ? null : ciName.trim(); + } + + /** + * 鑾峰彇淇¤鎶曡瘔姹℃煋绫诲瀷id + * + * @return CO_Type - 淇¤鎶曡瘔姹℃煋绫诲瀷id + */ + public Integer getCoType() { + return coType; + } + + /** + * 璁剧疆淇¤鎶曡瘔姹℃煋绫诲瀷id + * + * @param coType 淇¤鎶曡瘔姹℃煋绫诲瀷id + */ + public void setCoType(Integer coType) { + this.coType = coType; + } + + /** + * 鑾峰彇淇¤鎶曡瘔姹℃煋绫诲瀷 + * + * @return CO_Type_Name - 淇¤鎶曡瘔姹℃煋绫诲瀷 + */ + public String getCoTypeName() { + return coTypeName; + } + + /** + * 璁剧疆淇¤鎶曡瘔姹℃煋绫诲瀷 + * + * @param coTypeName 淇¤鎶曡瘔姹℃煋绫诲瀷 + */ + public void setCoTypeName(String coTypeName) { + this.coTypeName = coTypeName == null ? null : coTypeName.trim(); + } + + /** + * 鑾峰彇淇¤鏃舵 + * + * @return CO_Time - 淇¤鏃舵 + */ + public Date getCoTime() { + return coTime; + } + + /** + * 璁剧疆淇¤鏃舵 + * + * @param coTime 淇¤鏃舵 + */ + public void setCoTime(Date coTime) { + this.coTime = coTime; + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/domain/mapper/AssessmentMapper.kt b/src/main/kotlin/com/flightfeather/uav/domain/mapper/AssessmentMapper.kt new file mode 100644 index 0000000..4bb981a --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/domain/mapper/AssessmentMapper.kt @@ -0,0 +1,12 @@ +package com.flightfeather.uav.domain.mapper + +import com.flightfeather.uav.domain.MyMapper +import com.flightfeather.uav.domain.entity.Assessment +import com.flightfeather.uav.lightshare.bean.AssessmentVo +import org.apache.ibatis.annotations.Mapper + +@Mapper +interface AssessmentMapper : MyMapper<Assessment> { + + fun getAssessment(): List<AssessmentVo> +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/domain/mapper/ComplaintMapper.kt b/src/main/kotlin/com/flightfeather/uav/domain/mapper/ComplaintMapper.kt new file mode 100644 index 0000000..63cae8a --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/domain/mapper/ComplaintMapper.kt @@ -0,0 +1,12 @@ +package com.flightfeather.uav.domain.mapper + +import com.flightfeather.uav.domain.MyMapper +import com.flightfeather.uav.domain.entity.Complaint +import com.flightfeather.uav.lightshare.bean.ComplaintRecord +import org.apache.ibatis.annotations.Mapper + +@Mapper +interface ComplaintMapper : MyMapper<Complaint?> { + + fun getComplaintInfo(townCode: String? = null): List<ComplaintRecord> +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/bean/AssessmentVo.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/AssessmentVo.kt new file mode 100644 index 0000000..36f653d --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/AssessmentVo.kt @@ -0,0 +1,14 @@ +package com.flightfeather.uav.lightshare.bean + +import java.math.BigDecimal + + +data class AssessmentVo( + var ciGuid: String, + var ciName: String, + var ciLng: BigDecimal, + var ciLat: BigDecimal, + var ciIndex: String, + var ciAddress: String, + var risk: String +) \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/bean/ComplaintVo.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/ComplaintVo.kt new file mode 100644 index 0000000..5402c7f --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/ComplaintVo.kt @@ -0,0 +1,65 @@ +package com.flightfeather.uav.lightshare.bean + +import java.math.BigDecimal +import kotlin.math.round + +/** + * 浼佷笟淇¤鎶曡瘔缁熻淇℃伅 + */ +data class ComplaintVo( + val ciGuid: String, + val ciName: String, + var ciLng: Double, + var ciLat: Double, + val index: Int, + val ciAddress: String? = null, + val result: MutableList<ComplaintType> = mutableListOf() +) + +/** + * 淇¤鎶曡瘔绫诲瀷淇℃伅 + */ +data class ComplaintType( + // 姹℃煋绫诲瀷id + val type: Int, + // 姹℃煋绫诲瀷鍚嶇О + val typeName: String, + // 淇¤鎶曡瘔璁℃暟 + val count: Int, + // 鍗犳瘮 + val percent: Double = .0 +) + +/** + * 淇¤鎶曡瘔缁熻锛堟暟鎹簱杩斿洖缁撴瀯浣擄級 + */ +data class ComplaintRecord( + var ciGuid: String, + var ciName: String, + var ciLng: BigDecimal, + var ciLat: BigDecimal, + var ciIndex: String, + var ciAddress: String, + var coType: Int, + var coTypeName: String, + var count: Long +) { + var percent: Double = .0 +} + +/** + * 姹備俊璁胯褰曚腑姣忕鎶曡瘔绫诲瀷鐨勫悇鑷崰姣� + */ +fun List<ComplaintRecord>.percent() { + val cMap = mutableMapOf<Int, Int>() + this.forEach { + if (!cMap.containsKey(it.coType)) { + cMap[it.coType] = 0 + } + cMap[it.coType] = cMap[it.coType]?.plus(it.count)?.toInt() ?: 0 + } + this.forEach { + val t = cMap[it.coType] + it.percent = if (t != null && t != 0) round(it.count / t.toDouble() * 10000) / 10000 else .0 + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/bean/DataVo.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/DataVo.kt index 9696b02..7ac9d4b 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/bean/DataVo.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/DataVo.kt @@ -1,5 +1,6 @@ package com.flightfeather.uav.lightshare.bean +import com.fasterxml.jackson.annotation.JsonIgnore import com.fasterxml.jackson.annotation.JsonInclude import com.flightfeather.uav.model.BaseMData import com.flightfeather.uav.socket.bean.AirData @@ -39,8 +40,10 @@ row.add(lng ?: -1.0) row.add(lat ?: -1.0) values?.forEach { - row.add(it.factorData ?: -1.0) - row.add(it.physicalQuantity ?: -1.0) + if (FactorType.outputFactor(it.factorName)) { + row.add(it.factorData ?: -1.0) +// row.add(it.physicalQuantity ?: -1.0) + } } return row.toTypedArray() } @@ -52,9 +55,11 @@ list.add("缁忓害") list.add("绾害") values?.forEach { - val name = it.factorName ?: "" - list.add(name) - list.add("$name(鐗╃悊閲�)") + if (FactorType.outputFactor(it.factorName)) { + val name = it.factorName ?: "" + list.add(name) +// list.add("$name(鐗╃悊閲�)") + } } return list.toTypedArray() } diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/CompanyService.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/CompanyService.kt index 25754b3..8a69f45 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/CompanyService.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/CompanyService.kt @@ -1,7 +1,10 @@ package com.flightfeather.uav.lightshare.service +import com.flightfeather.uav.domain.entity.Assessment import com.flightfeather.uav.domain.entity.Company +import com.flightfeather.uav.lightshare.bean.AssessmentVo import com.flightfeather.uav.lightshare.bean.BaseResponse +import com.flightfeather.uav.lightshare.bean.ComplaintVo import com.flightfeather.uav.model.BaseModel interface CompanyService { @@ -19,4 +22,8 @@ endTime: String, companyIds: List<String>? = null ): BaseResponse<MutableMap<String, MutableMap<String, MutableMap<String, BaseModel.ResultCell>>>> + + fun getComplaintInfo(): BaseResponse<List<ComplaintVo>> + + fun getAssessment(): BaseResponse<List<AssessmentVo>> } \ No newline at end of file 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 9dab0f0..5e5da20 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,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>> { @@ -63,6 +69,15 @@ 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++ } @@ -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) + } } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ElectricityServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ElectricityServiceImpl.kt index afe80b0..0d933f4 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ElectricityServiceImpl.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ElectricityServiceImpl.kt @@ -39,10 +39,18 @@ sTime?.let { andGreaterThanOrEqualTo("mvDataTime", it) } eTime?.let { andLessThanOrEqualTo("mvDataTime", it) } } - orderBy("mvDataTime") + orderBy("mvDataTime").apply { + // 褰撹姹傛帴鍙d笉浼犻�掕捣濮嬫椂闂达紝榛樿鑾峰彇鏈�鏂扮殑鏁版嵁 + if (startTime == null && endTime == null) { + desc() + } + } }).forEach { it?.let { result.add(it) } } + if (startTime == null && endTime == null) { + result.reverse() + } return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages), data = result) } diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/web/CompanyController.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/web/CompanyController.kt index 9e5afbe..c1ee1ed 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/web/CompanyController.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/web/CompanyController.kt @@ -2,10 +2,7 @@ import com.flightfeather.uav.lightshare.service.CompanyService import io.swagger.annotations.Api -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.RestController +import org.springframework.web.bind.annotation.* @Api(tags = ["宸ヤ笟浼佷笟淇℃伅API鎺ュ彛"]) @RestController @@ -27,4 +24,10 @@ @RequestParam(value = "endTime", required = true) endTime: String, @RequestParam(value = "companyIds", required = false) companyIds: List<String>?, ) = companyService.getEpwModelResult(deviceCode, startTime, endTime, companyIds) + + @GetMapping("/complaint") + fun getComplaintInfo() = companyService.getComplaintInfo() + + @GetMapping("/assessment") + fun getAssessment() = companyService.getAssessment() } diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/web/ElectricityController.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/web/ElectricityController.kt index 2bccb1c..4d88c9d 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/web/ElectricityController.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/web/ElectricityController.kt @@ -32,7 +32,7 @@ @ApiParam(value = "缁撴潫鏃堕棿", example = "yyyy-MM-dd HH:mm:ss") @RequestParam(value = "endTime", required = false) endTime: String?, @RequestParam(value = "page", required = false) page: Int?, @RequestParam(value = "perPage", required = false) perPage: Int? - ) = electricityService.getMinuteData(deviceCode, startTime, endTime, page, perPage) + ) = electricityService.getMinuteData2(deviceCode, startTime, endTime, page, perPage) @GetMapping("/company") fun getByCompany( diff --git a/src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt b/src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt index 3f23d11..5da6409 100644 --- a/src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt +++ b/src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt @@ -86,7 +86,8 @@ } lastData.clear() - mDataList.subList(mDataList.lastIndex - ncal + 1, mDataList.lastIndex + 1).forEach { + val s = if ((mDataList.lastIndex - ncal + 1) < 0) 0 else mDataList.lastIndex - ncal + 1 + mDataList.subList(s, mDataList.lastIndex + 1).forEach { lastData.add(it.copy()) } diff --git a/src/main/kotlin/com/flightfeather/uav/socket/ServerHandler.kt b/src/main/kotlin/com/flightfeather/uav/socket/ServerHandler.kt index d08948c..27954b2 100644 --- a/src/main/kotlin/com/flightfeather/uav/socket/ServerHandler.kt +++ b/src/main/kotlin/com/flightfeather/uav/socket/ServerHandler.kt @@ -4,6 +4,7 @@ import io.netty.channel.ChannelHandlerContext import io.netty.channel.ChannelInboundHandlerAdapter import io.netty.util.AttributeKey +import org.ietf.jgss.MessageProp import java.lang.StringBuilder import java.text.SimpleDateFormat import java.util.* @@ -57,7 +58,12 @@ println(str) + if (str == "01 04 00 00 00 00 00 00 00 00 00") { + ctx?.writeAndFlush("trigger") + return + } if (str.isNotEmpty()) { + ctx?.writeAndFlush("data") processor.dealStringMsg(str, ctx) } } diff --git a/src/main/kotlin/com/flightfeather/uav/socket/bean/AirData.kt b/src/main/kotlin/com/flightfeather/uav/socket/bean/AirData.kt index ed21640..3e1667e 100644 --- a/src/main/kotlin/com/flightfeather/uav/socket/bean/AirData.kt +++ b/src/main/kotlin/com/flightfeather/uav/socket/bean/AirData.kt @@ -1,9 +1,12 @@ package com.flightfeather.uav.socket.bean +import com.fasterxml.jackson.annotation.JsonInclude + /** * @author riku * Date: 2020/6/10 */ +@JsonInclude(JsonInclude.Include.NON_NULL) class AirData : DataUnit() { var factorId: String? = null var factorName: String? = null diff --git a/src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt b/src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt index 572420e..81c0d6f 100644 --- a/src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt +++ b/src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt @@ -133,5 +133,23 @@ HEIGHT -> 0.0 else -> null } + + fun outputFactor(factorName: String?): Boolean { + return when (factorName) { + NO2.des, + CO.des, + H2S.des, + SO2.des, + O3.des, + PM25.des, + PM10.des, + TEMPERATURE.des, + HUMIDITY.des, + VOC.des, + WIND_SPEED.des, + WIND_DIRECTION.des -> true + else -> false + } + } } } \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1087cd6..e03ad45 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -7,9 +7,9 @@ # password: cn.FLIGHTFEATHER # 绾夸笂鏈嶅姟鍣� -# url: jdbc:mysql://localhost:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false -# username: dronemonitor -# password: dronemonitor_hackxrnomxm + url: jdbc:mysql://localhost:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false + username: dronemonitor + password: dronemonitor_hackxrnomxm # 寮�鍙戞湰鍦版湇鍔″櫒 # url: jdbc:mysql://localhost:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false @@ -17,9 +17,9 @@ # password: 123456 # 寮�鍙戣繙绋嬫湇鍔″櫒 - url: jdbc:mysql://47.100.191.150:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false - username: remoteU1 - password: eSoF8DnzfGTlhAjE +# url: jdbc:mysql://47.100.191.150:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false +# username: remoteU1 +# password: eSoF8DnzfGTlhAjE hikari: maximum-pool-size: 500 minimum-idle: 20 diff --git a/src/main/resources/generator/generatorConfig.xml b/src/main/resources/generator/generatorConfig.xml index a138b99..a75f4aa 100644 --- a/src/main/resources/generator/generatorConfig.xml +++ b/src/main/resources/generator/generatorConfig.xml @@ -48,6 +48,8 @@ <!-- <table tableName="air_real_time_data" domainObjectName="RealTimeData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> <!-- <table tableName="mission" domainObjectName="Mission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> <!-- <table tableName="el_minutevalue" domainObjectName="ElectricMinuteValue" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> - <table tableName="el_company_device" domainObjectName="CompanyDevice" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> +<!-- <table tableName="el_company_device" domainObjectName="CompanyDevice" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> +<!-- <table tableName="co_complaint" domainObjectName="Complaint" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> + <table tableName="co_assessment" domainObjectName="Assessment" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> </context> </generatorConfiguration> \ No newline at end of file diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml index b19d1e8..b7ef49b 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -57,7 +57,7 @@ <!--root 榛樿鍔犺浇--> <loggers> <root level="INFO"> -<!-- <appender-ref ref="Console"/>--> + <appender-ref ref="Console"/> <!-- <appender-ref ref="allLog"/>--> <!-- <appender-ref ref="debugLog"/>--> <appender-ref ref="errorLog"/> diff --git a/src/main/resources/mapper/AssessmentMapper.xml b/src/main/resources/mapper/AssessmentMapper.xml new file mode 100644 index 0000000..a54845a --- /dev/null +++ b/src/main/resources/mapper/AssessmentMapper.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.flightfeather.uav.domain.mapper.AssessmentMapper"> + <resultMap id="BaseResultMap" type="com.flightfeather.uav.domain.entity.Assessment"> + <!-- + WARNING - @mbg.generated + --> + <id column="ID" jdbcType="INTEGER" property="id" /> + <result column="CI_GUID" jdbcType="VARCHAR" property="ciGuid" /> + <result column="AS_Risk" jdbcType="VARCHAR" property="asRisk" /> + </resultMap> + <sql id="Base_Column_List"> + <!-- + WARNING - @mbg.generated + --> + ID, CI_GUID, AS_Risk + </sql> + + <resultMap id="AssessmentVo" type="com.flightfeather.uav.lightshare.bean.AssessmentVo"> + <result column="CI_GUID" jdbcType="VARCHAR" property="ciGuid" /> + <result column="CI_Name" jdbcType="VARCHAR" property="ciName" /> + <result column="CI_Longitude" jdbcType="DECIMAL" property="ciLng" /> + <result column="CI_Latitude" jdbcType="DECIMAL" property="ciLat" /> + <result column="ciIndex" jdbcType="VARCHAR" property="ciIndex" /> + <result column="CI_Address" jdbcType="VARCHAR" property="ciAddress" /> + <result column="AS_Risk" jdbcType="VARCHAR" property="risk" /> + </resultMap> + <select id="getAssessment" resultMap="AssessmentVo"> + SELECT + b.CI_GUID, + b.CI_Name, + b.CI_Longitude, + b.CI_Latitude, + b.CI_Extension1 as ciIndex, + b.CI_Address, + a.AS_Risk + FROM + co_assessment AS a + LEFT JOIN ea_companyinfo AS b ON a.CI_GUID = b.CI_GUID + </select> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/ComplaintMapper.xml b/src/main/resources/mapper/ComplaintMapper.xml new file mode 100644 index 0000000..fe3ff59 --- /dev/null +++ b/src/main/resources/mapper/ComplaintMapper.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.flightfeather.uav.domain.mapper.ComplaintMapper"> + <resultMap id="BaseResultMap" type="com.flightfeather.uav.domain.entity.Complaint"> + <!-- + WARNING - @mbg.generated + --> + <id column="ID" jdbcType="INTEGER" property="id" /> + <result column="CI_GUID" jdbcType="VARCHAR" property="ciGuid" /> + <result column="CI_Name" jdbcType="VARCHAR" property="ciName" /> + <result column="CO_Type" jdbcType="INTEGER" property="coType" /> + <result column="CO_Type_Name" jdbcType="VARCHAR" property="coTypeName" /> + <result column="CO_Time" jdbcType="TIMESTAMP" property="coTime" /> + </resultMap> + <resultMap id="ComplaintRecord" type="com.flightfeather.uav.lightshare.bean.ComplaintRecord"> + <result column="CI_GUID" jdbcType="VARCHAR" property="ciGuid" /> + <result column="CI_Name" jdbcType="VARCHAR" property="ciName" /> + <result column="CI_Longitude" jdbcType="DECIMAL" property="ciLng" /> + <result column="CI_Latitude" jdbcType="DECIMAL" property="ciLat" /> + <result column="ciIndex" jdbcType="VARCHAR" property="ciIndex" /> + <result column="CI_Address" jdbcType="VARCHAR" property="ciAddress" /> + <result column="CO_Type" jdbcType="INTEGER" property="coType" /> + <result column="CO_Type_Name" jdbcType="VARCHAR" property="coTypeName" /> + <result column="count" jdbcType="INTEGER" property="count" /> + </resultMap> + <sql id="Base_Column_List"> + <!-- + WARNING - @mbg.generated + --> + ID, CI_GUID, CI_Name, CO_Type, CO_Type_Name, CO_Time + </sql> + + <select id="getComplaintInfo" resultMap="ComplaintRecord"> + SELECT + a.CI_GUID, + a.CI_Name, + b.CI_Longitude, + b.CI_Latitude, + b.CI_Extension1 as ciIndex, + b.CI_Address, + a.CO_Type, + a.CO_Type_Name, + COUNT(*) as count + FROM + co_complaint AS a + LEFT JOIN ea_companyinfo AS b ON a.CI_GUID = b.CI_GUID + GROUP BY + a.CO_Type, + a.CI_GUID + </select> +</mapper> \ No newline at end of file diff --git a/src/test/kotlin/com/flightfeather/uav/Test.kt b/src/test/kotlin/com/flightfeather/uav/Test.kt index 456ec0c..52fc02f 100644 --- a/src/test/kotlin/com/flightfeather/uav/Test.kt +++ b/src/test/kotlin/com/flightfeather/uav/Test.kt @@ -66,4 +66,38 @@ val list = listOf(1, 2, 3, 4, 5, 0) println(list.average()) } + + @Test + fun get_crc16(){ + val dataSegment = "QN=20210713115502858;ST=22;CN=2011;PW=555555;MN=FYHB0MH0300045;Flag=1;CP=&&DataTime=20210713115000;a34001-Avg=0.025,a34001-CPM=5.9,a34001-Flag=N;a50001-Avg=0.0,a50001-Flag=D;a01001-Avg=33.0,a01001-Flag=N;a01002-Avg=68.2,a01002-Flag=N;a01007-Avg=0.0,a01007-Flag=N;a01008-Avg=0.0,a01008-Flag=N;Period=5;Scale=0.0;SelfTemp=0.0;SelfHum=0.0;IsReplacement=N&&" + var CRC = 0x0000ffff + val POLYNOMIAL = 0x0000a001 + var i: Int + var j: Int + val bufData = dataSegment.toByteArray() + val buflen = bufData.size + if (buflen == 0) { + return + } + i = 0 + while (i < buflen) { + CRC = CRC xor (bufData[i].toInt() and 0x000000ff) + j = 0 + while (j < 8) { + if (CRC and 0x00000001 != 0) { + CRC = CRC shr 1 + CRC = CRC xor POLYNOMIAL + } else { + CRC = CRC shr 1 + } + j++ + } + i++ + } + var strCRC = Integer.toHexString(CRC).toString() + if (strCRC.length < 4) { + strCRC += "0" + } + println(strCRC) + } } \ No newline at end of file diff --git a/src/test/kotlin/com/flightfeather/uav/model/epw/EPWDataPrepTest.kt b/src/test/kotlin/com/flightfeather/uav/model/epw/EPWDataPrepTest.kt new file mode 100644 index 0000000..c060c14 --- /dev/null +++ b/src/test/kotlin/com/flightfeather/uav/model/epw/EPWDataPrepTest.kt @@ -0,0 +1,103 @@ +package com.flightfeather.uav.model.epw + +import com.flightfeather.uav.common.utils.DateUtil +import com.flightfeather.uav.common.utils.ExcelUtil +import com.flightfeather.uav.lightshare.bean.DataVo +import com.flightfeather.uav.lightshare.service.RealTimeDataService +import org.apache.poi.hssf.usermodel.HSSFWorkbook +import org.junit.Assert.* +import org.junit.Test +import org.junit.runner.RunWith +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.context.junit4.SpringRunner +import java.io.File +import java.io.FileOutputStream +import java.util.* + +@RunWith(SpringRunner::class) +@SpringBootTest +class EPWDataPrepTest { + + @Autowired + lateinit var realTimeDataService: RealTimeDataService + + @Test + fun foo1() { + val timeSet = listOf( +// 缃戞牸鍖栫洃娴嬫瘡鏃� +// Pair("2021-06-18 15:00:00", "2021-06-18 23:59:59"), +// Pair("2021-06-19 00:00:00", "2021-06-19 23:59:59"), +// Pair("2021-06-20 00:00:00", "2021-06-20 23:59:59"), +// Pair("2021-06-21 00:00:00", "2021-06-21 23:59:59"), +// Pair("2021-06-22 00:00:00", "2021-06-22 23:59:59"), +// Pair("2021-06-23 00:00:00", "2021-06-23 23:59:59"), +// Pair("2021-06-24 00:00:00", "2021-06-24 23:59:59"), +// Pair("2021-06-25 00:00:00", "2021-06-25 23:59:59"), +// Pair("2021-06-26 00:00:00", "2021-06-26 23:59:59"), +// Pair("2021-06-27 00:00:00", "2021-06-27 23:59:59"), +// Pair("2021-06-28 00:00:00", "2021-06-28 23:59:59"), +// Pair("2021-06-29 00:00:00", "2021-06-29 23:59:59"), +// Pair("2021-06-30 00:00:00", "2021-06-30 23:59:59"), +// Pair("2021-07-01 00:00:00", "2021-07-01 23:59:59"), +// Pair("2021-07-02 00:00:00", "2021-07-02 23:59:59"), +// Pair("2021-07-03 00:00:00", "2021-07-03 23:59:59"), +// Pair("2021-07-04 00:00:00", "2021-07-04 23:59:59"), +// Pair("2021-07-05 00:00:00", "2021-07-05 23:59:59"), +// Pair("2021-07-06 00:00:00", "2021-07-06 23:59:59"), +// Pair("2021-07-07 00:00:00", "2021-07-07 23:59:59"), + Pair("2021-07-08 00:00:00", "2021-07-08 23:59:59"), + Pair("2021-07-09 00:00:00", "2021-07-09 23:59:59"), + Pair("2021-07-10 00:00:00", "2021-07-10 23:59:59"), + Pair("2021-07-11 00:00:00", "2021-07-11 23:59:59"), + Pair("2021-07-12 00:00:00", "2021-07-12 23:59:59"), + Pair("2021-07-13 00:00:00", "2021-07-13 23:59:59"), + +// Pair("2021-06-18 15:00:00", "2021-07-13 23:59:59"), + ) + + val prep = EPWDataPrep() + val deviceCode = "0d0000000001" + + for (i in timeSet.indices) { + val it = timeSet[i] + var page = 1 + var totalPage = -1 + val dataList = mutableListOf<DataVo>() + while (totalPage == -1 || page <= totalPage) { + realTimeDataService.getSecondData(deviceCode, it.first, it.second, page, 50000).apply { + if (totalPage == -1) { + totalPage = head?.totalPage ?: 0 + } + + val list = data?: emptyList() + + val prepList = prep.mDataPrep(list) + + dataList.addAll(prepList) + + page++ + } + } + + if (dataList.isNotEmpty()) { + val workbook = HSSFWorkbook() + val heads = mutableListOf<Array<String>>() + heads.add(dataList[0].toRowTitle()) + val contents = mutableListOf<Array<Any>>() + dataList.forEach { + contents.add(it.toRowContent()) + } + ExcelUtil.write(heads, contents, workbook) + + val fileName = "缃戞牸鍖栭澶勭悊鏁版嵁${it.first.substring(0, 10)}.xls" + val filePath = "E:\\work\\export\\棰勫鐞哱\$fileName" + val out = FileOutputStream(File(filePath)) + workbook.write(out) + workbook.close() + out.flush() + out.close() + } + } + } +} \ No newline at end of file -- Gitblit v1.9.3