pom.xml
@@ -116,35 +116,48 @@ <artifactId>spring-boot-starter-log4j2</artifactId> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.poi/poi --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>4.1.2</version> </dependency> <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson --> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.75</version> </dependency> </dependencies> <build> <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory> <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-plugin</artifactId> <configuration> <args> <arg>-Xjsr305=strict</arg> </args> <compilerPlugins> <plugin>spring</plugin> </compilerPlugins> </configuration> <dependencies> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-allopen</artifactId> <version>${kotlin.version}</version> </dependency> </dependencies> </plugin> <!-- <plugin>--> <!-- <groupId>org.springframework.boot</groupId>--> <!-- <artifactId>spring-boot-maven-plugin</artifactId>--> <!-- </plugin>--> <!-- <plugin>--> <!-- <groupId>org.jetbrains.kotlin</groupId>--> <!-- <artifactId>kotlin-maven-plugin</artifactId>--> <!-- <configuration>--> <!-- <args>--> <!-- <arg>-Xjsr305=strict</arg>--> <!-- </args>--> <!-- <compilerPlugins>--> <!-- <plugin>spring</plugin>--> <!-- </compilerPlugins>--> <!-- </configuration>--> <!-- <dependencies>--> <!-- <dependency>--> <!-- <groupId>org.jetbrains.kotlin</groupId>--> <!-- <artifactId>kotlin-maven-allopen</artifactId>--> <!-- <version>${kotlin.version}</version>--> <!-- </dependency>--> <!-- </dependencies>--> <!-- </plugin>--> <!-- mybatis generator èªå¨çæä»£ç æä»¶ --> <plugin> <groupId>org.mybatis.generator</groupId> src/main/kotlin/com/flightfeather/uav/common/utils/ExcelUtil.kt
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,157 @@ package com.flightfeather.uav.common.utils import org.apache.poi.hssf.usermodel.HSSFWorkbook import org.apache.poi.ss.util.CellRangeAddress import java.time.LocalDate import java.util.* import kotlin.math.max /** * @author riku * Date: 2020/6/12 */ object ExcelUtil { class MyCell( var text: String, var rowSpan: Int = 1 ) /** * èªå¨å¤çè¡åå¹¶æ°æ® */ fun write2(heads: List<String>, contents: List<Array<Any>>, workbook: HSSFWorkbook, sheetName:String) { val sheet = workbook.createSheet(sheetName) var rowIndex = 0 if (heads.isNotEmpty()) { val rows = sheet.createRow(rowIndex) for (i in 0 until heads.size) { rows.createCell(i).setCellValue(heads[i]) } rowIndex++ } contents.forEach { val maxRow = getMaxRows(it) var rows = sheet.getRow(rowIndex) ?: sheet.createRow(rowIndex) val arrayMap = mutableMapOf<Int, Array<*>>() for (i in it.indices) { val cell = it[i] var rowspan = maxRow//åå¹¶çè¡ç跨度 val c = if (cell is Array<*>) { //彿°æ®ä¸ºæ°ç»æ¶ï¼éè¦æ ¹æ®æå¤§è¡æ°éæ°è®¡ç®è¯¥åå æ ¼çè¡è·¨åº¦ arrayMap[i] = cell rowspan = maxRow / if (cell.size == 0) 1 else cell.size val c = cell[0] if (c is MyCell) { rowspan = c.rowSpan } if (rowspan > 1) { println("åå¹¶1-1ï¼$rowIndex;${rowIndex + rowspan - 1};$i") sheet.addMergedRegion(CellRangeAddress(rowIndex, rowIndex + rowspan - 1, i, i)) } if (cell.isEmpty()) { "" } else { cell[0] } } else { //彿°æ®ä¸æ¯æ°ç»æ¶ï¼éè¦ææå¤§è¡æ°åå¹¶åå æ ¼ if (rowspan > 1) { println("åå¹¶1-2ï¼$rowIndex;${rowIndex + rowspan - 1};$i") sheet.addMergedRegion(CellRangeAddress(rowIndex, rowIndex + rowspan - 1, i, i)) } cell } when (c) { is MyCell -> { rows.createCell(i).setCellValue(c.text) println("write1-1: ${c.text};($rowIndex, ${i})") } is String -> { rows.createCell(i).setCellValue(c) println("write1-2: ${c};($rowIndex, ${i})") } is Double -> rows.createCell(i).setCellValue(c) is Boolean -> rows.createCell(i).setCellValue(c) is Date -> rows.createCell(i).setCellValue(c) is Calendar -> rows.createCell(i).setCellValue(c) is LocalDate -> rows.createCell(i).setCellValue(c) } } for (i in 1 until maxRow) { rowIndex++ arrayMap.forEach { map -> rows = sheet.getRow(rowIndex) ?: sheet.createRow(rowIndex) val array = map.value if (i < array.size) { // var rowspan = maxRow / array.size var lastRowSpan = 1 var rowspan = 1 val c = array[i] if (c is MyCell) { rowspan = c.rowSpan } val _c = array[i-1] if (_c is MyCell) { lastRowSpan = _c.rowSpan } var _rowIndex = rowIndex var index = rowIndex if (lastRowSpan > 1) { index = rowIndex + (i * lastRowSpan) - 1 _rowIndex = index rows = sheet.getRow(_rowIndex) ?: sheet.createRow(_rowIndex) } if (rowspan > 1) { println("åå¹¶2ï¼${index};${index + rowspan - 1};$i") sheet.addMergedRegion(CellRangeAddress(index, index + rowspan - 1, i, i)) } when (c) { is MyCell -> { rows.createCell(map.key).setCellValue(c.text) println("write2-1: ${c.text};($_rowIndex, ${map.key})") } is String -> { rows.createCell(map.key).setCellValue(c) println("write2-2: ${c};($_rowIndex, ${map.key})") } is Double -> rows.createCell(map.key).setCellValue(c) is Boolean -> rows.createCell(map.key).setCellValue(c) is Date -> rows.createCell(map.key).setCellValue(c) is Calendar -> rows.createCell(map.key).setCellValue(c) is LocalDate -> rows.createCell(map.key).setCellValue(c) } } } } rowIndex++ } // workbook.write(out) // workbook.close() // out.flush() // out.close() } private fun getMaxRows(rowArray: Array<Any>): Int { var maxRows = 1 rowArray.forEach { if (it is Array<*>) { maxRows = max(it.size, maxRows) } } return maxRows } } src/main/kotlin/com/flightfeather/uav/common/utils/FileExchange.kt
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,176 @@ package com.flightfeather.uav.common.utils import com.alibaba.fastjson.JSONObject 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.text.SimpleDateFormat import java.util.* class FileExchange { companion object { private const val TMP = "65536" private const val SPCOND = "65548" private const val TUR = "65702" private const val DO = "65542" private const val PH = "65558" private val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") } fun doTask() { //source val path = "E:\\å·¥ä½\\é山走èª\\MissionData.xls" val workbook = HSSFWorkbook(FileInputStream(path)) val sheet = workbook.getSheetAt(0) //target val fileName = "æ äººè¹æ°æ®.xls" val filePath = "e:/$fileName" val out = FileOutputStream(File(filePath)) val heads = listOf("æ¶é´", "ç»åº¦", "纬度", "Temperature(°C)", "spCond(uS/cm)", "Turbidity(NTU)", "DO(mg/L)", "PH") val contents = mutableListOf<Array<Any>>() val lastRow = mutableListOf<Any>() 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 cList = mutableListOf<Any>() //æ¶é´ val date = Date(time) val d = format.format(date) cList.add(d) //ç»åº¦ cList.add(lng) cList.add(lat) // val jO = JSONObject.parseObject(value) cList.add((jO[TMP] ?: "0").toString()) cList.add((jO[SPCOND] ?: "0").toString()) cList.add((jO[TUR] ?: "0").toString()) cList.add((jO[DO] ?: "0").toString()) cList.add((jO[PH] ?: "0").toString()) // if (lastRow.isEmpty()) { // lastRow.addAll(cList) // } else { // for (i in cList.indices) { // if (cList[i] == "") { // cList[i] = lastRow[i] // } // } // lastRow.clear() // lastRow.addAll(cList) // } contents.add(cList.toTypedArray()) } val newWorkBook = HSSFWorkbook() ExcelUtil.write2(heads, contents, newWorkBook, "data") newWorkBook.write(out) newWorkBook.close() workbook.close() out.flush() out.close() } fun doTask2() { //source val path = "E:\\å·¥ä½\\é山走èª\\æ äººè¹æ°æ®-è¡¥å 空ç½å¼.xls" val workbook = HSSFWorkbook(FileInputStream(path)) val sheet = workbook.getSheetAt(0) //target val fileName = "æ 人è¹èµ°èªæ°æ®.xls" val filePath = "e:/$fileName" val out = FileOutputStream(File(filePath)) val heads = listOf("id", "device_code", "latitude", "longitude", "altitude", "height", "factors", "data_time", "create_time") val contents = mutableListOf<Array<Any>>() for (i in 1..sheet.lastRowNum) { val row = sheet.getRow(i) val deviceCode = "0c" val latitude = row.getCell(2).numericCellValue val longitude = row.getCell(1).numericCellValue val altitude = "" val height = "" val dataTime = row.getCell(0).stringCellValue val createTime = dataTime val factorsList = mutableListOf<AirData>() val tmp = row.getCell(3).numericCellValue val spC = row.getCell(4).numericCellValue val tur = row.getCell(5).numericCellValue val dO = row.getCell(6).numericCellValue val ph = row.getCell(7).numericCellValue 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() val cList = mutableListOf<Any>() cList.add("") cList.add(deviceCode) cList.add(latitude) cList.add(longitude) cList.add(altitude) cList.add(height) cList.add(factors) cList.add(dataTime) cList.add(createTime) contents.add(cList.toTypedArray()) } val newWorkBook = HSSFWorkbook() ExcelUtil.write2(heads, contents, newWorkBook, "data") newWorkBook.write(out) newWorkBook.close() workbook.close() out.flush() out.close() } } src/main/kotlin/com/flightfeather/uav/domain/entity/Company.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,915 @@ package com.flightfeather.uav.domain.entity; import com.fasterxml.jackson.annotation.JsonInclude; import javax.persistence.Column; import javax.persistence.Id; import javax.persistence.Table; import java.math.BigDecimal; import java.util.Date; @Table(name = "ea_companyinfo") @JsonInclude(JsonInclude.Include.NON_NULL) public class Company { @Id @Column(name = "CI_GUID") private String ciGuid; /** * åä½åç§° */ @Column(name = "CI_Name") private String ciName; /** * 主è¦ä»äºä¸å¡ */ @Column(name = "CI_Main_Business") private String ciMainBusiness; /** * æå±éå¢ */ @Column(name = "CI_Member_Group") private String ciMemberGroup; /** * ç份ç¼ç */ @Column(name = "CI_Province_Code") private String ciProvinceCode; /** * ç份åç§° */ @Column(name = "CI_Province_Name") private String ciProvinceName; /** * å°å¸ç¼ç */ @Column(name = "CI_City_Code") private String ciCityCode; /** * å°å¸åç§° */ @Column(name = "CI_City_Name") private String ciCityName; /** * åºå¿ç¼å· */ @Column(name = "CI_District_Code") private String ciDistrictCode; /** * åºå¿åç§° */ @Column(name = "CI_District_Name") private String ciDistrictName; /** * è¡éç¼ç */ @Column(name = "CI_Town_Code") private String ciTownCode; /** * è¡éåç§° */ @Column(name = "CI_Town_Name") private String ciTownName; /** * æå¨å·¥ä¸åº */ @Column(name = "CI_Ind_District") private String ciIndDistrict; /** * åä½å°å */ @Column(name = "CI_Address") private String ciAddress; /** * ä¸å¿ç»åº¦ */ @Column(name = "CI_Longitude") private BigDecimal ciLongitude; /** * ä¸å¿çº¬åº¦ */ @Column(name = "CI_Latitude") private BigDecimal ciLatitude; /** * ç»ç»æºæä»£ç */ @Column(name = "CI_Org_Code") private String ciOrgCode; /** * æ³äºº */ @Column(name = "CI_Juridical_Person") private String ciJuridicalPerson; /** * è¡ä¸ç±»å« */ @Column(name = "CI_Ind_Classification") private String ciIndClassification; /** * è¡ä¸ä»£ç */ @Column(name = "CI_Industry_Code") private String ciIndustryCode; /** * ç»è®°æ³¨åç±»å */ @Column(name = "CI_Registration_Type") private String ciRegistrationType; /** * 注åèµæ¬ï¼ä¸å ï¼ */ @Column(name = "CI_Registered_Capital") private Integer ciRegisteredCapital; /** * 建åå¹´æ */ @Column(name = "CI_Build_Date") private Date ciBuildDate; /** * ææ°æ¹æ©å»ºå¹´æ */ @Column(name = "CI_Expansion_Date") private Date ciExpansionDate; /** * èå·¥äººæ° */ @Column(name = "CI_Workers_Number") private Integer ciWorkersNumber; /** * ä¼ä¸è§æ¨¡ */ @Column(name = "CI_Scale") private Byte ciScale; /** * 忬¡ç¯è¯å®¡æ¹å¹´æ */ @Column(name = "CI_Eia_Approval_Date") private String ciEiaApprovalDate; /** * ææ±¡è®¸å¯è¯ç¼å· */ @Column(name = "CI_Plt_Permit_Code") private String ciPltPermitCode; /** * ææ±¡æäº¤ææä»¶ */ @Column(name = "CI_Trading_Files") private String ciTradingFiles; /** * 鮿¿ç¼ç */ @Column(name = "CI_Postal_Code") private String ciPostalCode; /** * è系人å§å */ @Column(name = "CI_Contact_Name") private String ciContactName; /** * èç³»çµè¯ */ @Column(name = "CI_Telephone") private String ciTelephone; /** * èç³»å¾®ä¿¡å· */ @Column(name = "CI_Contacts_WX") private String ciContactsWx; /** * ä¼ ç */ @Column(name = "CI_Fax") private String ciFax; /** * çµåé®ç®± */ @Column(name = "CI_Email") private String ciEmail; @Column(name = "CI_Extension1") private String ciExtension1; @Column(name = "CI_Extension2") private String ciExtension2; @Column(name = "CI_Extension3") private String ciExtension3; @Column(name = "CI_Remark") private String ciRemark; /** * @return CI_GUID */ public String getCiGuid() { return ciGuid; } /** * @param ciGuid */ 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(); } /** * è·å主è¦ä»äºä¸å¡ * * @return CI_Main_Business - 主è¦ä»äºä¸å¡ */ public String getCiMainBusiness() { return ciMainBusiness; } /** * 设置主è¦ä»äºä¸å¡ * * @param ciMainBusiness 主è¦ä»äºä¸å¡ */ public void setCiMainBusiness(String ciMainBusiness) { this.ciMainBusiness = ciMainBusiness == null ? null : ciMainBusiness.trim(); } /** * è·åæå±éå¢ * * @return CI_Member_Group - æå±éå¢ */ public String getCiMemberGroup() { return ciMemberGroup; } /** * 设置æå±éå¢ * * @param ciMemberGroup æå±éå¢ */ public void setCiMemberGroup(String ciMemberGroup) { this.ciMemberGroup = ciMemberGroup == null ? null : ciMemberGroup.trim(); } /** * è·åç份ç¼ç * * @return CI_Province_Code - ç份ç¼ç */ public String getCiProvinceCode() { return ciProvinceCode; } /** * 设置ç份ç¼ç * * @param ciProvinceCode ç份ç¼ç */ public void setCiProvinceCode(String ciProvinceCode) { this.ciProvinceCode = ciProvinceCode == null ? null : ciProvinceCode.trim(); } /** * è·åç份åç§° * * @return CI_Province_Name - ç份åç§° */ public String getCiProvinceName() { return ciProvinceName; } /** * 设置ç份åç§° * * @param ciProvinceName ç份åç§° */ public void setCiProvinceName(String ciProvinceName) { this.ciProvinceName = ciProvinceName == null ? null : ciProvinceName.trim(); } /** * è·åå°å¸ç¼ç * * @return CI_City_Code - å°å¸ç¼ç */ public String getCiCityCode() { return ciCityCode; } /** * 设置å°å¸ç¼ç * * @param ciCityCode å°å¸ç¼ç */ public void setCiCityCode(String ciCityCode) { this.ciCityCode = ciCityCode == null ? null : ciCityCode.trim(); } /** * è·åå°å¸åç§° * * @return CI_City_Name - å°å¸åç§° */ public String getCiCityName() { return ciCityName; } /** * 设置å°å¸åç§° * * @param ciCityName å°å¸åç§° */ public void setCiCityName(String ciCityName) { this.ciCityName = ciCityName == null ? null : ciCityName.trim(); } /** * è·ååºå¿ç¼å· * * @return CI_District_Code - åºå¿ç¼å· */ public String getCiDistrictCode() { return ciDistrictCode; } /** * 设置åºå¿ç¼å· * * @param ciDistrictCode åºå¿ç¼å· */ public void setCiDistrictCode(String ciDistrictCode) { this.ciDistrictCode = ciDistrictCode == null ? null : ciDistrictCode.trim(); } /** * è·ååºå¿åç§° * * @return CI_District_Name - åºå¿åç§° */ public String getCiDistrictName() { return ciDistrictName; } /** * 设置åºå¿åç§° * * @param ciDistrictName åºå¿åç§° */ public void setCiDistrictName(String ciDistrictName) { this.ciDistrictName = ciDistrictName == null ? null : ciDistrictName.trim(); } /** * è·åè¡éç¼ç * * @return CI_Town_Code - è¡éç¼ç */ public String getCiTownCode() { return ciTownCode; } /** * 设置è¡éç¼ç * * @param ciTownCode è¡éç¼ç */ public void setCiTownCode(String ciTownCode) { this.ciTownCode = ciTownCode == null ? null : ciTownCode.trim(); } /** * è·åè¡éåç§° * * @return CI_Town_Name - è¡éåç§° */ public String getCiTownName() { return ciTownName; } /** * 设置è¡éåç§° * * @param ciTownName è¡éåç§° */ public void setCiTownName(String ciTownName) { this.ciTownName = ciTownName == null ? null : ciTownName.trim(); } /** * è·åæå¨å·¥ä¸åº * * @return CI_Ind_District - æå¨å·¥ä¸åº */ public String getCiIndDistrict() { return ciIndDistrict; } /** * 设置æå¨å·¥ä¸åº * * @param ciIndDistrict æå¨å·¥ä¸åº */ public void setCiIndDistrict(String ciIndDistrict) { this.ciIndDistrict = ciIndDistrict == null ? null : ciIndDistrict.trim(); } /** * è·ååä½å°å * * @return CI_Address - åä½å°å */ public String getCiAddress() { return ciAddress; } /** * 设置åä½å°å * * @param ciAddress åä½å°å */ public void setCiAddress(String ciAddress) { this.ciAddress = ciAddress == null ? null : ciAddress.trim(); } /** * è·åä¸å¿ç»åº¦ * * @return CI_Longitude - ä¸å¿ç»åº¦ */ public BigDecimal getCiLongitude() { return ciLongitude; } /** * 设置ä¸å¿ç»åº¦ * * @param ciLongitude ä¸å¿ç»åº¦ */ public void setCiLongitude(BigDecimal ciLongitude) { this.ciLongitude = ciLongitude; } /** * è·åä¸å¿çº¬åº¦ * * @return CI_Latitude - ä¸å¿çº¬åº¦ */ public BigDecimal getCiLatitude() { return ciLatitude; } /** * 设置ä¸å¿çº¬åº¦ * * @param ciLatitude ä¸å¿çº¬åº¦ */ public void setCiLatitude(BigDecimal ciLatitude) { this.ciLatitude = ciLatitude; } /** * è·åç»ç»æºæä»£ç * * @return CI_Org_Code - ç»ç»æºæä»£ç */ public String getCiOrgCode() { return ciOrgCode; } /** * 设置ç»ç»æºæä»£ç * * @param ciOrgCode ç»ç»æºæä»£ç */ public void setCiOrgCode(String ciOrgCode) { this.ciOrgCode = ciOrgCode == null ? null : ciOrgCode.trim(); } /** * è·åæ³äºº * * @return CI_Juridical_Person - æ³äºº */ public String getCiJuridicalPerson() { return ciJuridicalPerson; } /** * 设置æ³äºº * * @param ciJuridicalPerson æ³äºº */ public void setCiJuridicalPerson(String ciJuridicalPerson) { this.ciJuridicalPerson = ciJuridicalPerson == null ? null : ciJuridicalPerson.trim(); } /** * è·åè¡ä¸ç±»å« * * @return CI_Ind_Classification - è¡ä¸ç±»å« */ public String getCiIndClassification() { return ciIndClassification; } /** * 设置è¡ä¸ç±»å« * * @param ciIndClassification è¡ä¸ç±»å« */ public void setCiIndClassification(String ciIndClassification) { this.ciIndClassification = ciIndClassification == null ? null : ciIndClassification.trim(); } /** * è·åè¡ä¸ä»£ç * * @return CI_Industry_Code - è¡ä¸ä»£ç */ public String getCiIndustryCode() { return ciIndustryCode; } /** * 设置è¡ä¸ä»£ç * * @param ciIndustryCode è¡ä¸ä»£ç */ public void setCiIndustryCode(String ciIndustryCode) { this.ciIndustryCode = ciIndustryCode == null ? null : ciIndustryCode.trim(); } /** * è·åç»è®°æ³¨åç±»å * * @return CI_Registration_Type - ç»è®°æ³¨åç±»å */ public String getCiRegistrationType() { return ciRegistrationType; } /** * 设置ç»è®°æ³¨åç±»å * * @param ciRegistrationType ç»è®°æ³¨åç±»å */ public void setCiRegistrationType(String ciRegistrationType) { this.ciRegistrationType = ciRegistrationType == null ? null : ciRegistrationType.trim(); } /** * è·å注åèµæ¬ï¼ä¸å ï¼ * * @return CI_Registered_Capital - 注åèµæ¬ï¼ä¸å ï¼ */ public Integer getCiRegisteredCapital() { return ciRegisteredCapital; } /** * 设置注åèµæ¬ï¼ä¸å ï¼ * * @param ciRegisteredCapital 注åèµæ¬ï¼ä¸å ï¼ */ public void setCiRegisteredCapital(Integer ciRegisteredCapital) { this.ciRegisteredCapital = ciRegisteredCapital; } /** * è·å建åå¹´æ * * @return CI_Build_Date - 建åå¹´æ */ public Date getCiBuildDate() { return ciBuildDate; } /** * 设置建åå¹´æ * * @param ciBuildDate 建åå¹´æ */ public void setCiBuildDate(Date ciBuildDate) { this.ciBuildDate = ciBuildDate; } /** * è·åææ°æ¹æ©å»ºå¹´æ * * @return CI_Expansion_Date - ææ°æ¹æ©å»ºå¹´æ */ public Date getCiExpansionDate() { return ciExpansionDate; } /** * è®¾ç½®ææ°æ¹æ©å»ºå¹´æ * * @param ciExpansionDate ææ°æ¹æ©å»ºå¹´æ */ public void setCiExpansionDate(Date ciExpansionDate) { this.ciExpansionDate = ciExpansionDate; } /** * è·åèå·¥äººæ° * * @return CI_Workers_Number - èå·¥äººæ° */ public Integer getCiWorkersNumber() { return ciWorkersNumber; } /** * 设置èå·¥äººæ° * * @param ciWorkersNumber èå·¥äººæ° */ public void setCiWorkersNumber(Integer ciWorkersNumber) { this.ciWorkersNumber = ciWorkersNumber; } /** * è·åä¼ä¸è§æ¨¡ * * @return CI_Scale - ä¼ä¸è§æ¨¡ */ public Byte getCiScale() { return ciScale; } /** * 设置ä¼ä¸è§æ¨¡ * * @param ciScale ä¼ä¸è§æ¨¡ */ public void setCiScale(Byte ciScale) { this.ciScale = ciScale; } /** * è·å忬¡ç¯è¯å®¡æ¹å¹´æ * * @return CI_Eia_Approval_Date - 忬¡ç¯è¯å®¡æ¹å¹´æ */ public String getCiEiaApprovalDate() { return ciEiaApprovalDate; } /** * è®¾ç½®åæ¬¡ç¯è¯å®¡æ¹å¹´æ * * @param ciEiaApprovalDate 忬¡ç¯è¯å®¡æ¹å¹´æ */ public void setCiEiaApprovalDate(String ciEiaApprovalDate) { this.ciEiaApprovalDate = ciEiaApprovalDate == null ? null : ciEiaApprovalDate.trim(); } /** * è·åææ±¡è®¸å¯è¯ç¼å· * * @return CI_Plt_Permit_Code - ææ±¡è®¸å¯è¯ç¼å· */ public String getCiPltPermitCode() { return ciPltPermitCode; } /** * è®¾ç½®ææ±¡è®¸å¯è¯ç¼å· * * @param ciPltPermitCode ææ±¡è®¸å¯è¯ç¼å· */ public void setCiPltPermitCode(String ciPltPermitCode) { this.ciPltPermitCode = ciPltPermitCode == null ? null : ciPltPermitCode.trim(); } /** * è·åææ±¡æäº¤ææä»¶ * * @return CI_Trading_Files - ææ±¡æäº¤ææä»¶ */ public String getCiTradingFiles() { return ciTradingFiles; } /** * è®¾ç½®ææ±¡æäº¤ææä»¶ * * @param ciTradingFiles ææ±¡æäº¤ææä»¶ */ public void setCiTradingFiles(String ciTradingFiles) { this.ciTradingFiles = ciTradingFiles == null ? null : ciTradingFiles.trim(); } /** * è·å鮿¿ç¼ç * * @return CI_Postal_Code - 鮿¿ç¼ç */ public String getCiPostalCode() { return ciPostalCode; } /** * è®¾ç½®é®æ¿ç¼ç * * @param ciPostalCode 鮿¿ç¼ç */ public void setCiPostalCode(String ciPostalCode) { this.ciPostalCode = ciPostalCode == null ? null : ciPostalCode.trim(); } /** * è·åè系人å§å * * @return CI_Contact_Name - è系人å§å */ public String getCiContactName() { return ciContactName; } /** * 设置è系人å§å * * @param ciContactName è系人å§å */ public void setCiContactName(String ciContactName) { this.ciContactName = ciContactName == null ? null : ciContactName.trim(); } /** * è·åèç³»çµè¯ * * @return CI_Telephone - èç³»çµè¯ */ public String getCiTelephone() { return ciTelephone; } /** * 设置èç³»çµè¯ * * @param ciTelephone èç³»çµè¯ */ public void setCiTelephone(String ciTelephone) { this.ciTelephone = ciTelephone == null ? null : ciTelephone.trim(); } /** * è·åèç³»å¾®ä¿¡å· * * @return CI_Contacts_WX - èç³»å¾®ä¿¡å· */ public String getCiContactsWx() { return ciContactsWx; } /** * 设置èç³»å¾®ä¿¡å· * * @param ciContactsWx èç³»å¾®ä¿¡å· */ public void setCiContactsWx(String ciContactsWx) { this.ciContactsWx = ciContactsWx == null ? null : ciContactsWx.trim(); } /** * è·åä¼ ç * * @return CI_Fax - ä¼ ç */ public String getCiFax() { return ciFax; } /** * è®¾ç½®ä¼ ç * * @param ciFax ä¼ ç */ public void setCiFax(String ciFax) { this.ciFax = ciFax == null ? null : ciFax.trim(); } /** * è·åçµåé®ç®± * * @return CI_Email - çµåé®ç®± */ public String getCiEmail() { return ciEmail; } /** * 设置çµåé®ç®± * * @param ciEmail çµåé®ç®± */ public void setCiEmail(String ciEmail) { this.ciEmail = ciEmail == null ? null : ciEmail.trim(); } /** * @return CI_Extension1 */ public String getCiExtension1() { return ciExtension1; } /** * @param ciExtension1 */ public void setCiExtension1(String ciExtension1) { this.ciExtension1 = ciExtension1 == null ? null : ciExtension1.trim(); } /** * @return CI_Extension2 */ public String getCiExtension2() { return ciExtension2; } /** * @param ciExtension2 */ public void setCiExtension2(String ciExtension2) { this.ciExtension2 = ciExtension2 == null ? null : ciExtension2.trim(); } /** * @return CI_Extension3 */ public String getCiExtension3() { return ciExtension3; } /** * @param ciExtension3 */ public void setCiExtension3(String ciExtension3) { this.ciExtension3 = ciExtension3 == null ? null : ciExtension3.trim(); } /** * @return CI_Remark */ public String getCiRemark() { return ciRemark; } /** * @param ciRemark */ public void setCiRemark(String ciRemark) { this.ciRemark = ciRemark == null ? null : ciRemark.trim(); } } src/main/kotlin/com/flightfeather/uav/domain/mapper/CompanyMapper.kt
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,8 @@ package com.flightfeather.uav.domain.mapper import com.flightfeather.uav.domain.MyMapper import com.flightfeather.uav.domain.entity.Company import org.apache.ibatis.annotations.Mapper @Mapper interface CompanyMapper : MyMapper<Company> src/main/kotlin/com/flightfeather/uav/lightshare/service/CompanyService.kt
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,10 @@ package com.flightfeather.uav.lightshare.service import com.flightfeather.uav.domain.entity.Company import com.flightfeather.uav.lightshare.bean.BaseResponse import com.flightfeather.uav.lightshare.bean.DataVo interface CompanyService { fun getCompanyInfo(): BaseResponse<List<Company>> } src/main/kotlin/com/flightfeather/uav/lightshare/service/RealTimeDataService.kt
@@ -6,4 +6,6 @@ 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>> } src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,16 @@ package com.flightfeather.uav.lightshare.service.impl 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.service.CompanyService import org.springframework.stereotype.Service import tk.mybatis.mapper.entity.Example @Service class CompanyServiceImpl(private val companyMapper: CompanyMapper) : CompanyService { override fun getCompanyInfo(): BaseResponse<List<Company>> { val result = companyMapper.selectAll() return BaseResponse(true, data = result) } } src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt
@@ -32,7 +32,12 @@ sTime?.let { andGreaterThanOrEqualTo("dataTime", it) } eTime?.let { andLessThanOrEqualTo("dataTime", it) } } orderBy("dataTime").desc() orderBy("dataTime").apply { // å½è¯·æ±æ¥å£ä¸ä¼ éèµ·å§æ¶é´ï¼é»è®¤è·åææ°çæ°æ® if (startTime == null && endTime == null) { desc() } } }).forEach { result.add(DataVo( dateFormatter.format(it.dataTime), @@ -41,7 +46,29 @@ it.longitude.toDouble(), it.latitude.toDouble() )) } // result.reverse() if (startTime == null && endTime == null) { result.reverse() } return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages), data = result) } override fun getNextData(deviceCode: String, updateTime: String, page: Int?, perPage: Int?): BaseResponse<List<DataVo>> { val _perPage = perPage ?: 60 val _page = page ?: 1 val pageInfo = PageHelper.startPage<RealTimeData>(_page, _perPage) val result = mutableListOf<DataVo>() realTimeDataMapper.selectByExample(Example(RealTimeData::class.java).apply { createCriteria().andEqualTo("deviceCode", deviceCode) .andGreaterThan("dataTime", updateTime) orderBy("dataTime") }).forEach { result.add(DataVo( dateFormatter.format(it.dataTime), it.deviceCode, GsonUtils.parserJsonToArrayBeans(it.factors, AirData::class.java), it.longitude.toDouble(), it.latitude.toDouble() )) } return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages), data = result) } } src/main/kotlin/com/flightfeather/uav/lightshare/web/CompanyController.kt
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,14 @@ package com.flightfeather.uav.lightshare.web import com.flightfeather.uav.lightshare.service.CompanyService import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("air/company") class CompanyController(private val companyService: CompanyService) { @GetMapping("/info") fun getCompanyInfo() = companyService.getCompanyInfo() } src/main/kotlin/com/flightfeather/uav/lightshare/web/RealTimeDataController.kt
@@ -18,4 +18,12 @@ @RequestParam(value = "page", required = false) page: Int?, @RequestParam(value = "perPage", required = false) perPage: Int? ) = realTimeDataService.getSecondData(deviceCode, startTime, endTime, page, perPage) @GetMapping("/sec/next") fun getNextData( @RequestParam(value = "deviceCode") deviceCode: String, @RequestParam(value = "updateTime") updateTime: String, @RequestParam(value = "page", required = false) page: Int?, @RequestParam(value = "perPage", required = false) perPage: Int? ) = realTimeDataService.getNextData(deviceCode, updateTime, page, perPage) } src/main/resources/application.yml
@@ -1,9 +1,9 @@ spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver # url: jdbc:mysql://47.100.191.150:3306/uav?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false # username: uav # password: obd2019 # url: jdbc:mysql://192.168.0.200:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false # username: root # 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 src/test/kotlin/com/flightfeather/uav/Test.kt
@@ -1,5 +1,6 @@ package com.flightfeather.uav import com.flightfeather.uav.common.utils.FileExchange import com.flightfeather.uav.socket.bean.DataUnit import com.flightfeather.uav.socket.decoder.AirDataDecoder import com.flightfeather.uav.socket.eunm.AirCommandUnit @@ -41,4 +42,9 @@ out.flush() out.close() } @Test fun dataChange() { FileExchange().doTask2() } } src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImplTest.kt
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,24 @@ package com.flightfeather.uav.lightshare.service.impl import com.flightfeather.uav.lightshare.service.CompanyService import org.junit.Test import org.junit.Assert.* 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 @RunWith(SpringRunner::class) @SpringBootTest class CompanyServiceImplTest { @Autowired lateinit var companyService: CompanyService @Test fun getCompanyInfo() { val r = companyService.getCompanyInfo() println(r) } }