Browse Source

1、excel导入异常,pom版本导致

dev
mh 4 months ago
parent
commit
d93f91037c
  1. 30
      algorithm/pom.xml
  2. 4
      algorithm/src/test/java/com/mh/algorithm/bpnn/bpnnTest.java
  3. 92
      algorithm/src/test/java/com/mh/algorithm/knn/knnTest.java
  4. 46
      common/pom.xml
  5. 26
      common/src/main/java/com/mh/common/annotation/SysLogger.java
  6. 84
      common/src/main/java/com/mh/common/utils/FileUtils.java
  7. 27
      pom.xml
  8. 50
      user-service/pom.xml
  9. 2
      user-service/src/main/java/com/mh/user/aspect/SysLogAspect.java
  10. 4
      user-service/src/main/java/com/mh/user/controller/BuildingController.java
  11. 8
      user-service/src/main/java/com/mh/user/controller/DeviceFloorController.java
  12. 4
      user-service/src/main/java/com/mh/user/controller/DeviceInstallController.java
  13. 6
      user-service/src/main/java/com/mh/user/job/DealDataJob.java
  14. 4
      user-service/src/main/java/com/mh/user/service/NowDataService.java
  15. 1
      user-service/src/main/java/com/mh/user/utils/CacheTools.java

30
algorithm/pom.xml

@ -46,7 +46,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.9.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
@ -107,20 +107,20 @@
</executions>
</plugin>
<!--签名插件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-gpg-plugin</artifactId>-->
<!-- <version>1.4</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>sign-artifacts</id>-->
<!-- <phase>verify</phase>-->
<!-- <goals>-->
<!-- <goal>sign</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>

4
algorithm/src/test/java/com/mh/algorithm/bpnn/bpnnTest.java

@ -51,7 +51,7 @@ public class bpnnTest {
double correctRate = Double.valueOf(correct) / Double.valueOf(total);
System.out.println(correctRate);
}
/**
* 使用示例
* @throws Exception
@ -67,5 +67,5 @@ public class bpnnTest {
Matrix result = factory.computeBP(bpModel1, data);
CsvUtil.createCsvFile(null,result,"D:\\ljf\\my_pro\\top-algorithm-set-dev\\src\\computeResult.csv");
}
}

92
algorithm/src/test/java/com/mh/algorithm/knn/knnTest.java

@ -1,46 +1,46 @@
package com.mh.algorithm.knn;
import com.mh.algorithm.matrix.Matrix;
import com.mh.algorithm.utils.CsvInfo;
import com.mh.algorithm.utils.CsvUtil;
import com.mh.algorithm.utils.DoubleUtil;
import org.junit.Test;
/**
* @program: top-algorithm-set
* @description:
* @author: Mr.Zhao
* @create: 2020-10-26 22:04
**/
public class knnTest {
@Test
public void test() throws Exception {
// 训练集
CsvInfo csvInfo = CsvUtil.getCsvInfo(false, "E:\\jarTest\\trainData.csv");
Matrix trainSet = csvInfo.toMatrix();
Matrix trainSetLabels = trainSet.getColOfIdx(trainSet.getMatrixColCount() - 1);
Matrix trainSetData = trainSet.subMatrix(0, trainSet.getMatrixRowCount(), 0, trainSet.getMatrixColCount() - 1);
CsvInfo csvInfo1 = CsvUtil.getCsvInfo(false, "E:\\jarTest\\testData.csv");
Matrix testSet = csvInfo1.toMatrix();
Matrix testSetData = trainSet.subMatrix(0, testSet.getMatrixRowCount(), 0, testSet.getMatrixColCount() - 1);
Matrix testSetLabels = trainSet.getColOfIdx(testSet.getMatrixColCount() - 1);
// 分类
long startTime = System.currentTimeMillis();
Matrix result = KNN.classify(testSetData, trainSetData, trainSetLabels, 5);
long endTime = System.currentTimeMillis();
System.out.println("run time:" + (endTime - startTime));
// 正确率
Matrix error = result.subtract(testSetLabels);
int total = error.getMatrixRowCount();
int correct = 0;
for (int i = 0; i < error.getMatrixRowCount(); i++) {
if (DoubleUtil.equals(error.getValOfIdx(i, 0), 0.0)) {
correct++;
}
}
double correctRate = Double.valueOf(correct) / Double.valueOf(total);
System.out.println("correctRate:"+ correctRate);
}
}
//package com.mh.algorithm.knn;
//
//import com.mh.algorithm.matrix.Matrix;
//import com.mh.algorithm.utils.CsvInfo;
//import com.mh.algorithm.utils.CsvUtil;
//import com.mh.algorithm.utils.DoubleUtil;
//import org.junit.Test;
//
///**
// * @program: top-algorithm-set
// * @description:
// * @author: Mr.Zhao
// * @create: 2020-10-26 22:04
// **/
//public class knnTest {
// @Test
// public void test() throws Exception {
// // 训练集
// CsvInfo csvInfo = CsvUtil.getCsvInfo(false, "E:\\jarTest\\trainData.csv");
// Matrix trainSet = csvInfo.toMatrix();
// Matrix trainSetLabels = trainSet.getColOfIdx(trainSet.getMatrixColCount() - 1);
// Matrix trainSetData = trainSet.subMatrix(0, trainSet.getMatrixRowCount(), 0, trainSet.getMatrixColCount() - 1);
//
// CsvInfo csvInfo1 = CsvUtil.getCsvInfo(false, "E:\\jarTest\\testData.csv");
// Matrix testSet = csvInfo1.toMatrix();
// Matrix testSetData = trainSet.subMatrix(0, testSet.getMatrixRowCount(), 0, testSet.getMatrixColCount() - 1);
// Matrix testSetLabels = trainSet.getColOfIdx(testSet.getMatrixColCount() - 1);
//
// // 分类
// long startTime = System.currentTimeMillis();
// Matrix result = KNN.classify(testSetData, trainSetData, trainSetLabels, 5);
// long endTime = System.currentTimeMillis();
// System.out.println("run time:" + (endTime - startTime));
// // 正确率
// Matrix error = result.subtract(testSetLabels);
// int total = error.getMatrixRowCount();
// int correct = 0;
// for (int i = 0; i < error.getMatrixRowCount(); i++) {
// if (DoubleUtil.equals(error.getValOfIdx(i, 0), 0.0)) {
// correct++;
// }
// }
// double correctRate = Double.valueOf(correct) / Double.valueOf(total);
// System.out.println("correctRate:"+ correctRate);
// }
//}

46
common/pom.xml

@ -34,13 +34,24 @@
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.7</version>
</dependency>
<!-- web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- commons-beanutils -->
<dependency>
<groupId>commons-beanutils</groupId>
@ -59,32 +70,11 @@
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<!-- poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.4</version>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.3</version>
<version>4.1.2</version>
</dependency>
</dependencies>
</project>

26
common/src/main/java/com/mh/common/annotation/SysLogger.java

@ -1,13 +1,13 @@
package com.mh.common.annotation;
import java.lang.annotation.*;
/**
* Created by fangzhipeng on 2017/7/12.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface SysLogger {
String value() default "";
}
//package com.mh.common.annotation;
//
//import java.lang.annotation.*;
//
///**
// * Created by fangzhipeng on 2017/7/12.
// */
//@Target(ElementType.METHOD)
//@Retention(RetentionPolicy.RUNTIME)
//@Documented
//public @interface SysLogger {
// String value() default "";
//}

84
common/src/main/java/com/mh/common/utils/FileUtils.java

@ -1,42 +1,42 @@
package com.mh.common.utils;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
/**
* 文件相关操作
* @author Louis
* @date Jan 14, 2019
*/
public class FileUtils {
/**
* 下载文件
* @param response
* @param file
* @param newFileName
*/
public static void downloadFile(HttpServletResponse response, File file, String newFileName) {
try {
response.setHeader("Content-Disposition", "attachment; filename=" + new String(newFileName.getBytes("ISO-8859-1"), "UTF-8"));
BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream());
InputStream is = new FileInputStream(file.getAbsolutePath());
BufferedInputStream bis = new BufferedInputStream(is);
int length = 0;
byte[] temp = new byte[1 * 1024 * 10];
while ((length = bis.read(temp)) != -1) {
bos.write(temp, 0, length);
}
bos.flush();
bis.close();
bos.close();
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
//package com.mh.common.utils;
//
//import javax.servlet.http.HttpServletResponse;
//import java.io.BufferedInputStream;
//import java.io.BufferedOutputStream;
//import java.io.File;
//import java.io.FileInputStream;
//import java.io.InputStream;
//
///**
// * 文件相关操作
// * @author Louis
// * @date Jan 14, 2019
// */
//public class FileUtils {
//
// /**
// * 下载文件
// * @param response
// * @param file
// * @param newFileName
// */
// public static void downloadFile(HttpServletResponse response, File file, String newFileName) {
// try {
// response.setHeader("Content-Disposition", "attachment; filename=" + new String(newFileName.getBytes("ISO-8859-1"), "UTF-8"));
// BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream());
// InputStream is = new FileInputStream(file.getAbsolutePath());
// BufferedInputStream bis = new BufferedInputStream(is);
// int length = 0;
// byte[] temp = new byte[1 * 1024 * 10];
// while ((length = bis.read(temp)) != -1) {
// bos.write(temp, 0, length);
// }
// bos.flush();
// bis.close();
// bos.close();
// is.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//}

27
pom.xml

@ -30,37 +30,10 @@
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
<!-- 添加consul依赖-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-consul-discovery</artifactId>-->
<!-- </dependency>-->
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-aop -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.rxtx</groupId>
<artifactId>rxtx</artifactId>

50
user-service/pom.xml

@ -35,34 +35,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-config -->
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-config</artifactId>-->
<!-- <version>2.2.2.RELEASE</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- mybatis配置-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.3.0</version>
</dependency>
<!-- &lt;!&ndash; mysql数据库链接&ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>mysql</groupId>-->
<!-- <artifactId>mysql-connector-java</artifactId>-->
<!-- </dependency>-->
<!-- druid配置-->
<dependency>
<groupId>com.alibaba</groupId>
@ -74,11 +52,6 @@
<artifactId>mssql-jdbc</artifactId>
<scope>runtime</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.netty</groupId>-->
<!-- <artifactId>netty-all</artifactId>-->
<!-- <version>5.0.0.Alpha2</version>-->
<!-- </dependency>-->
<!-- 登录验证码-->
<dependency>
<groupId>com.github.penggle</groupId>
@ -105,17 +78,22 @@
<version>0.0.1-SNAPSHOT</version>
</dependency>
<!-- 添加consul依赖-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-consul-discovery</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
<!--spring-boot-admin -->
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-aop -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.2.2</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<!-- Lombok-->
<dependency>

2
user-service/src/main/java/com/mh/user/aspect/SysLogAspect.java

@ -16,6 +16,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
@ -27,6 +28,7 @@ import java.util.Date;
*/
@Aspect
@Component
@Lazy(value = false)
public class SysLogAspect {
@Autowired

4
user-service/src/main/java/com/mh/user/controller/BuildingController.java

@ -78,14 +78,14 @@ public class BuildingController {
// 删除多
@PostMapping(value="/deletes")
public HttpResult delete(@RequestBody List<BuildingEntity> records) {
public HttpResult deleteDevices(@RequestBody List<BuildingEntity> records) {
return HttpResult.ok(buildingService.deleteBuilding(records));
}
// 删除单个
@SysLogger(title="楼栋信息",optDesc = "删除楼栋信息")
@PostMapping(value="/delete")
public HttpResult delete(@RequestParam String id ) {
public HttpResult deleteDevice(@RequestParam String id ) {
return HttpResult.ok(buildingService.deleteBuilding(id));
}

8
user-service/src/main/java/com/mh/user/controller/DeviceFloorController.java

@ -7,7 +7,6 @@ import com.mh.user.entity.*;
import com.mh.user.model.DeviceModel;
import com.mh.user.service.BuildingService;
import com.mh.user.service.DeviceFloorService;
import com.mh.user.service.DeviceInstallService;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@ -19,12 +18,9 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("floor")
@ -87,9 +83,9 @@ public class DeviceFloorController {
}
// 删除单个
@SysLogger(title="楼面设备",optDesc = "删除楼面设备信息")
@PostMapping(value="/delete")
public HttpResult delete(@RequestParam String id ) {
@SysLogger(title="楼面设备",optDesc = "删除楼面设备信息")
public HttpResult deleteDevice(@RequestParam String id ) {
return HttpResult.ok(deviceFloorService.deleteDevice(id));
}

4
user-service/src/main/java/com/mh/user/controller/DeviceInstallController.java

@ -92,14 +92,14 @@ public class DeviceInstallController {
// 删除多
@PostMapping(value="/deletes")
public HttpResult delete(@RequestBody List<DeviceInstallEntity> records) {
public HttpResult deleteDevices(@RequestBody List<DeviceInstallEntity> records) {
return HttpResult.ok(deviceInstallService.deleteDevice(records));
}
// 删除单个
@SysLogger(title="基表信息",optDesc = "删除基表信息")
@PostMapping(value="/delete")
public HttpResult delete(@RequestParam String id ) {
public HttpResult deleteDevice(@RequestParam String id ) {
return HttpResult.ok(deviceInstallService.deleteDevice(id));
}

6
user-service/src/main/java/com/mh/user/job/DealDataJob.java

@ -50,7 +50,7 @@ public class DealDataJob {
/**
* 定时处理汇总数据每15分钟处理一次,十分钟(0 0/10 * * * ?)
*/
@Scheduled(cron = "0 0/15 * * * ?")
// @Scheduled(cron = "0 0/15 * * * ?")
public void ProEnergy() {
try {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
@ -73,7 +73,7 @@ public class DealDataJob {
/**
* 采集
*/
@Scheduled(cron = "35 0/2 * * * ?")
// @Scheduled(cron = "35 0/2 * * * ?")
// @Scheduled(cron = "0/10 * * * * ?") 0 0/5 * * * ?
// @Scheduled(cron = "0 0/5 * * * ?") //5分钟
public void collect() {
@ -148,7 +148,7 @@ public class DealDataJob {
/**
* 定时处理数据每十五分钟处理一次
*/
@Scheduled(cron = "0 0/15 * * * ?")
// @Scheduled(cron = "0 0/15 * * * ?")
public void dealData() {
try {
StopWatch stopWatch = new StopWatch();

4
user-service/src/main/java/com/mh/user/service/NowDataService.java

@ -1,6 +1,6 @@
package com.mh.user.service;
import com.mh.common.annotation.SysLogger;
import com.mh.user.annotation.SysLogger;
import com.mh.user.entity.NowDataEntity;
import com.mh.user.entity.PumpMinutesEntity;
import com.mh.user.entity.WaterLevelEntity;
@ -86,7 +86,7 @@ public interface NowDataService {
void upTempSet2(String buildingId,String tempSet,String pumpID);
//查询每天24小时每个热泵温度变化情况
@SysLogger
@SysLogger(optDesc = "查询每天24小时每个热泵温度变化情况",title = "查询每天24小时每个热泵温度变化情况")
List<WaterTempEntity> queryWaterTemp(String buildingID,String curDate,int page,int limit);
int queryWaterTempCount(String buildingID,String curDate);

1
user-service/src/main/java/com/mh/user/utils/CacheTools.java

@ -3,7 +3,6 @@ package com.mh.user.utils;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import io.micrometer.core.instrument.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import java.util.Objects;

Loading…
Cancel
Save