1. 新增信访信息获取接口
2. 新增用电量信息获取接口
3. 新增风险评估结果接口
4. 新增污染权重实时分析接口
已修改15个文件
已添加9个文件
661 ■■■■■ 文件已修改
pom.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/Assessment.java 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/Complaint.java 145 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/mapper/AssessmentMapper.kt 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/mapper/ComplaintMapper.kt 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/AssessmentVo.kt 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ComplaintVo.kt 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/DataVo.kt 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/CompanyService.kt 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ElectricityServiceImpl.kt 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/CompanyController.kt 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/ElectricityController.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/ServerHandler.kt 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/bean/AirData.kt 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/generator/generatorConfig.xml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/log4j2.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/AssessmentMapper.xml 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ComplaintMapper.xml 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/Test.kt 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/model/epw/EPWDataPrepTest.kt 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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>
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();
    }
}
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;
    }
}
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>
}
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>
}
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
)
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
    }
}
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 {
                        if (FactorType.outputFactor(it.factorName)) {
                        row.add(it.factorData ?: -1.0)
                        row.add(it.physicalQuantity ?: -1.0)
//                                row.add(it.physicalQuantity ?: -1.0)
                        }
                }
                return row.toTypedArray()
        }
@@ -52,9 +55,11 @@
                list.add("经度")
                list.add("纬度")
                values?.forEach {
                        if (FactorType.outputFactor(it.factorName)) {
                        val name = it.factorName ?: ""
                        list.add(name)
                        list.add("$name(物理量)")
//                        list.add("$name(物理量)")
                        }
                }
                return list.toTypedArray()
        }
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>>
}
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)
    }
}
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 {
                // å½“请求接口不传递起始时间,默认获取最新的数据
                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)
    }
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()
}
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(
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())
        }
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)
        }
    }
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
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
            }
        }
    }
}
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
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>
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"/>
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>
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>
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)
    }
}
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()
            }
        }
    }
}