1. 新增走航任务增删改查相关功能
2. 新增无人船数据excel导入功能
3. 优化多参数接收逻辑,解决单个数据头导致数据包结构判断错误问题
| | |
| | | package com.flightfeather.uav.common.utils |
| | | |
| | | import com.alibaba.fastjson.JSONObject |
| | | import com.flightfeather.uav.domain.entity.RealTimeData |
| | | import com.flightfeather.uav.socket.bean.AirData |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook |
| | | import java.io.File |
| | | import java.io.FileInputStream |
| | | import java.io.FileOutputStream |
| | | import java.io.InputStream |
| | | import java.text.SimpleDateFormat |
| | | import java.util.* |
| | | |
| | |
| | | private val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") |
| | | } |
| | | |
| | | fun exchangeBoatData(deviceCode: String, file: InputStream): List<RealTimeData> { |
| | | val workbook = HSSFWorkbook(file) |
| | | val sheet = workbook.getSheetAt(0) |
| | | |
| | | val dataList = mutableListOf<RealTimeData>() |
| | | |
| | | for (i in 1 until sheet.lastRowNum) { |
| | | val row = sheet.getRow(i) |
| | | val time = row.getCell(2).numericCellValue.toLong() * 1000 |
| | | val lat = row.getCell(4).numericCellValue |
| | | val lng = row.getCell(5).numericCellValue |
| | | val value = row.getCell(6).stringCellValue |
| | | |
| | | //æ¶é´ |
| | | val datetime = Date(time) |
| | | //çæµå å |
| | | val jO = JSONObject.parseObject(value) |
| | | val tmp = jO.getDoubleValue(TMP) |
| | | val spC = jO.getDoubleValue(SPCOND) |
| | | val tur = jO.getDoubleValue(TUR) |
| | | val dO = jO.getDoubleValue(DO) |
| | | val ph = jO.getDoubleValue(PH) |
| | | |
| | | val factorsList = mutableListOf<AirData>() |
| | | |
| | | factorsList.apply { |
| | | add(AirData().apply { |
| | | factorId = "1" |
| | | factorName = "TMP" |
| | | factorData = tmp |
| | | physicalQuantity = 0.0 |
| | | }) |
| | | add(AirData().apply { |
| | | factorId = "2" |
| | | factorName = "spC" |
| | | factorData = spC |
| | | physicalQuantity = 0.0 |
| | | }) |
| | | add(AirData().apply { |
| | | factorId = "3" |
| | | factorName = "tur" |
| | | factorData = tur |
| | | physicalQuantity = 0.0 |
| | | }) |
| | | add(AirData().apply { |
| | | factorId = "4" |
| | | factorName = "DO" |
| | | factorData = dO |
| | | physicalQuantity = 0.0 |
| | | }) |
| | | add(AirData().apply { |
| | | factorId = "5" |
| | | factorName = "PH" |
| | | factorData = ph |
| | | physicalQuantity = 0.0 |
| | | }) |
| | | } |
| | | |
| | | val factors = JSONObject.toJSON(factorsList).toString() |
| | | |
| | | dataList.add(RealTimeData().apply { |
| | | this.deviceCode = deviceCode |
| | | latitude = lat.toBigDecimal() |
| | | longitude = lng.toBigDecimal() |
| | | dataTime = datetime |
| | | createTime = Date() |
| | | this.factors = factors |
| | | }) |
| | | } |
| | | |
| | | return dataList |
| | | } |
| | | |
| | | fun doTask() { |
| | | //source |
| | | val path = "E:\\å·¥ä½\\é山走èª\\MissionData.xls" |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.domain.entity; |
| | | |
| | | import java.util.Date; |
| | | import javax.persistence.*; |
| | | |
| | | public class Mission { |
| | | @Id |
| | | @Column(name = "mission_code") |
| | | private String missionCode; |
| | | |
| | | @Column(name = "device_type") |
| | | private String deviceType; |
| | | |
| | | @Column(name = "device_code") |
| | | private String deviceCode; |
| | | |
| | | @Column(name = "start_time") |
| | | private Date startTime; |
| | | |
| | | @Column(name = "end_time") |
| | | private Date endTime; |
| | | |
| | | /** |
| | | * @return mission_code |
| | | */ |
| | | public String getMissionCode() { |
| | | return missionCode; |
| | | } |
| | | |
| | | /** |
| | | * @param missionCode |
| | | */ |
| | | public void setMissionCode(String missionCode) { |
| | | this.missionCode = missionCode == null ? null : missionCode.trim(); |
| | | } |
| | | |
| | | /** |
| | | * @return device_type |
| | | */ |
| | | public String getDeviceType() { |
| | | return deviceType; |
| | | } |
| | | |
| | | /** |
| | | * @param deviceType |
| | | */ |
| | | public void setDeviceType(String deviceType) { |
| | | this.deviceType = deviceType == null ? null : deviceType.trim(); |
| | | } |
| | | |
| | | /** |
| | | * @return device_code |
| | | */ |
| | | public String getDeviceCode() { |
| | | return deviceCode; |
| | | } |
| | | |
| | | /** |
| | | * @param deviceCode |
| | | */ |
| | | public void setDeviceCode(String deviceCode) { |
| | | this.deviceCode = deviceCode == null ? null : deviceCode.trim(); |
| | | } |
| | | |
| | | /** |
| | | * @return start_time |
| | | */ |
| | | public Date getStartTime() { |
| | | return startTime; |
| | | } |
| | | |
| | | /** |
| | | * @param startTime |
| | | */ |
| | | public void setStartTime(Date startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | |
| | | /** |
| | | * @return end_time |
| | | */ |
| | | public Date getEndTime() { |
| | | return endTime; |
| | | } |
| | | |
| | | /** |
| | | * @param endTime |
| | | */ |
| | | public void setEndTime(Date endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.domain.mapper |
| | | |
| | | import com.flightfeather.uav.domain.MyMapper |
| | | import com.flightfeather.uav.domain.entity.Mission |
| | | import org.apache.ibatis.annotations.Mapper |
| | | |
| | | @Mapper |
| | | interface MissionMapper : MyMapper<Mission?> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.lightshare.bean |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude |
| | | |
| | | /** |
| | | * çæµæ°æ®å¯¼å
¥å¤çç»æ |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | data class DataImportResult( |
| | | val result: String |
| | | ) |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.lightshare.service |
| | | |
| | | import com.flightfeather.uav.domain.entity.Mission |
| | | import com.flightfeather.uav.lightshare.bean.BaseResponse |
| | | |
| | | interface MissionService { |
| | | |
| | | fun getMission(type: String?, page: Int?, perPage: Int?): BaseResponse<List<Mission>> |
| | | |
| | | fun createMission(mission: Mission): BaseResponse<Boolean> |
| | | |
| | | fun deleteMission(missionCode: String): BaseResponse<Boolean> |
| | | } |
| | |
| | | package com.flightfeather.uav.lightshare.service |
| | | |
| | | import com.flightfeather.uav.lightshare.bean.BaseResponse |
| | | import com.flightfeather.uav.lightshare.bean.DataImportResult |
| | | import com.flightfeather.uav.lightshare.bean.DataVo |
| | | import org.springframework.web.multipart.MultipartFile |
| | | |
| | | interface RealTimeDataService { |
| | | |
| | | fun getSecondData(deviceCode: String?, startTime: String?, endTime: String?, page: Int?, perPage: Int?): BaseResponse<List<DataVo>> |
| | | |
| | | fun getNextData(deviceCode: String, updateTime: String, page: Int?, perPage: Int?): BaseResponse<List<DataVo>> |
| | | |
| | | fun importData(file: MultipartFile): BaseResponse<DataImportResult> |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.lightshare.service.impl |
| | | |
| | | import com.flightfeather.uav.domain.entity.Mission |
| | | import com.flightfeather.uav.domain.mapper.MissionMapper |
| | | import com.flightfeather.uav.lightshare.bean.BaseResponse |
| | | import com.flightfeather.uav.lightshare.bean.DataHead |
| | | import com.flightfeather.uav.lightshare.service.MissionService |
| | | import com.github.pagehelper.PageHelper |
| | | import org.springframework.stereotype.Service |
| | | import tk.mybatis.mapper.entity.Example |
| | | |
| | | @Service |
| | | class MissionServiceImpl(private val missionMapper: MissionMapper) : MissionService { |
| | | override fun getMission(type: String?, page: Int?, perPage: Int?): BaseResponse<List<Mission>> { |
| | | val _perPage = perPage ?: 60 |
| | | val _page = page ?: 1 |
| | | val pageInfo = PageHelper.startPage<Mission>(_page, _perPage) |
| | | val result = mutableListOf<Mission>() |
| | | missionMapper.selectByExample(Example(Mission::class.java).apply { |
| | | type?.let { |
| | | createCriteria().andEqualTo("deviceType", type) |
| | | } |
| | | orderBy("startTime").desc() |
| | | }).forEach { it?.let { result.add(it) } } |
| | | return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages),data = result) |
| | | } |
| | | |
| | | override fun createMission(mission: Mission): BaseResponse<Boolean> { |
| | | missionMapper.selectByPrimaryKey(mission.missionCode)?.run { |
| | | return BaseResponse(false, "ä»»å¡ç¼å·å·²åå¨") |
| | | } |
| | | missionMapper.insert(mission).let { |
| | | return BaseResponse(it == 1) |
| | | } |
| | | } |
| | | |
| | | override fun deleteMission(missionCode: String): BaseResponse<Boolean> { |
| | | missionMapper.deleteByPrimaryKey(missionCode).let { |
| | | return BaseResponse(it == 1) |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.flightfeather.uav.lightshare.service.impl |
| | | |
| | | import com.flightfeather.uav.common.utils.FileExchange |
| | | import com.flightfeather.uav.common.utils.GsonUtils |
| | | import com.flightfeather.uav.domain.entity.RealTimeData |
| | | import com.flightfeather.uav.domain.mapper.RealTimeDataMapper |
| | | import com.flightfeather.uav.lightshare.bean.BaseResponse |
| | | import com.flightfeather.uav.lightshare.bean.DataHead |
| | | import com.flightfeather.uav.lightshare.bean.DataImportResult |
| | | import com.flightfeather.uav.lightshare.bean.DataVo |
| | | import com.flightfeather.uav.lightshare.service.RealTimeDataService |
| | | import com.flightfeather.uav.socket.bean.AirData |
| | | import com.github.pagehelper.PageHelper |
| | | import org.springframework.stereotype.Service |
| | | import org.springframework.web.multipart.MultipartFile |
| | | import tk.mybatis.mapper.entity.Example |
| | | import java.io.ByteArrayInputStream |
| | | import java.io.FileInputStream |
| | | import java.io.InputStream |
| | | import java.text.DateFormat |
| | | import java.text.SimpleDateFormat |
| | | |
| | |
| | | class RealTimeDataServiceImpl(val realTimeDataMapper: RealTimeDataMapper) : RealTimeDataService { |
| | | |
| | | private var dateFormatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") |
| | | private val fileExchange = FileExchange() |
| | | |
| | | override fun getSecondData(deviceCode: String?, startTime: String?, endTime: String?, page: Int?, perPage: Int?): BaseResponse<List<DataVo>> { |
| | | val _perPage = perPage ?: 60 |
| | |
| | | } |
| | | return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages), data = result) |
| | | } |
| | | |
| | | override fun importData(file: MultipartFile): BaseResponse<DataImportResult> { |
| | | val f = ByteArrayInputStream(file.bytes) |
| | | fileExchange.exchangeBoatData("0c0000000001", f).forEach { |
| | | realTimeDataMapper.insert(it) |
| | | } |
| | | return BaseResponse(true, data = DataImportResult("")) |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.lightshare.web |
| | | |
| | | import com.flightfeather.uav.domain.entity.Mission |
| | | import com.flightfeather.uav.lightshare.service.MissionService |
| | | import org.springframework.web.bind.annotation.* |
| | | |
| | | @RestController |
| | | @RequestMapping("air/mission") |
| | | class MissionController(private val missionService: MissionService) { |
| | | |
| | | @GetMapping("/type") |
| | | fun getMission( |
| | | @RequestParam(value = "type", required = false) type: String?, |
| | | @RequestParam(value = "page", required = false) page: Int?, |
| | | @RequestParam(value = "perPage", required = false) perPage: Int? |
| | | ) = missionService.getMission(type, page, perPage) |
| | | |
| | | @PostMapping("/create") |
| | | fun createMission( |
| | | @RequestBody mission: Mission |
| | | ) = missionService.createMission(mission) |
| | | |
| | | @PostMapping("/delete") |
| | | fun deleteMission( |
| | | @RequestParam("missionCode") missionCode: String |
| | | ) = missionService.deleteMission(missionCode) |
| | | } |
| | |
| | | package com.flightfeather.uav.lightshare.web |
| | | |
| | | import com.flightfeather.uav.lightshare.service.RealTimeDataService |
| | | 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.* |
| | | import org.springframework.web.multipart.MultipartFile |
| | | |
| | | @RestController |
| | | @RequestMapping("air/realtime") |
| | |
| | | @RequestParam(value = "page", required = false) page: Int?, |
| | | @RequestParam(value = "perPage", required = false) perPage: Int? |
| | | ) = realTimeDataService.getNextData(deviceCode, updateTime, page, perPage) |
| | | |
| | | @PostMapping("/import") |
| | | fun importData( |
| | | @RequestPart("excel") file: MultipartFile |
| | | ) = realTimeDataService.importData(file) |
| | | } |
| | |
| | | const val BASE_LENGTH = DataPackageDecoderImpl.HEAD_BYTES + DataPackageDecoderImpl.COMMAND_UNIT_BYTES + |
| | | DataPackageDecoderImpl.DEVICE_CODE_BYTES + DataPackageDecoderImpl.DATA_LENGTH + DataPackageDecoderImpl.BCC_BYTES |
| | | const val HEAD1 = 0x01.toByte() |
| | | const val COMMAND_1 = 0x01.toByte() |
| | | const val COMMAND_2 = 0x01.toByte() |
| | | const val HEAD_LENGTH = DataPackageDecoderImpl.HEAD_BYTES + DataPackageDecoderImpl.COMMAND_UNIT_BYTES + |
| | | DataPackageDecoderImpl.DEVICE_CODE_BYTES |
| | | } |
| | |
| | | // 读å°äºåè®®çå¼å§æ å¿ï¼ç»æwhileå¾ªç¯ |
| | | val b = ByteArray(HEAD_LENGTH) |
| | | it.readBytes(b) |
| | | if (b[0] == HEAD1) { |
| | | if (b[0] == HEAD1 && |
| | | (b[1] == COMMAND_1 || b[2] == COMMAND_2)) { |
| | | b.forEach {b -> |
| | | dataList.add(b) |
| | | } |
| | |
| | | jmx: |
| | | enabled: false |
| | | |
| | | #æä»¶ä¸ä¼ éå¶ |
| | | servlet: |
| | | multipart: |
| | | max-file-size: 25MB |
| | | max-request-size: 100MB |
| | | |
| | | |
| | | mybatis: |
| | |
| | | <property name="suppressAllComments" value="true"/> |
| | | </commentGenerator> |
| | | <!--æ°æ®åºé¾æ¥URLï¼ç¨æ·åãå¯ç --> |
| | | <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://114.215.109.124:3306/dronemonitor" |
| | | <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/dronemonitor" |
| | | userId="root" |
| | | password="123456"> |
| | | </jdbcConnection> |
| | |
| | | <property name="enableSubPackages" value="true"/> |
| | | </javaClientGenerator> |
| | | <!-- è¦çæç表 tableNameæ¯æ°æ®åºä¸ç表åæè§å¾å domainObjectNameæ¯å®ä½ç±»å--> |
| | | <!--<table tableName="obd_data" domainObjectName="ObdData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!--<table tableName="obd_user" domainObjectName="ObdUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!--<table tableName="obd_threshold_value" domainObjectName="ThresholdValue" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!--<table tableName="obd_alarm_data" domainObjectName="AlarmData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!--<table tableName="obd_origin_data" domainObjectName="OriginData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!--<table tableName="obd_car_login" domainObjectName="CarLogin" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!--<table tableName="obd_car_logout" domainObjectName="CarLogout" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!--<table tableName="obd_data_stream" domainObjectName="DataStream" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!--<table tableName="obd_info" domainObjectName="ObdInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <table tableName="air_real_time_data" domainObjectName="RealTimeData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> |
| | | <!-- <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"/> |
| | | </context> |
| | | </generatorConfiguration> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.MissionMapper"> |
| | | <resultMap id="BaseResultMap" type="com.flightfeather.uav.domain.entity.Mission"> |
| | | <!-- |
| | | WARNING - @mbg.generated |
| | | --> |
| | | <id column="mission_code" jdbcType="VARCHAR" property="missionCode" /> |
| | | <result column="device_type" jdbcType="VARCHAR" property="deviceType" /> |
| | | <result column="device_code" jdbcType="VARCHAR" property="deviceCode" /> |
| | | <result column="start_time" jdbcType="TIMESTAMP" property="startTime" /> |
| | | <result column="end_time" jdbcType="TIMESTAMP" property="endTime" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!-- |
| | | WARNING - @mbg.generated |
| | | --> |
| | | mission_code, device_type, device_code, start_time, end_time |
| | | </sql> |
| | | </mapper> |