diff --git a/father.txt b/father.txt
new file mode 100644
index 0000000..83a008c
--- /dev/null
+++ b/father.txt
@@ -0,0 +1,16 @@
+ [
+ "古井贡5年",
+ "g8",
+ "g8y",
+ "g16",
+ "g20",
+ "g5(2)",
+ "gxl",
+ "g7",
+ "v6",
+ "gjyy",
+ "lcg",
+ "v6",
+ "v60",
+ "D8"
+ ]
\ No newline at end of file
diff --git a/springbootstart.ipr b/springbootstart.ipr
new file mode 100644
index 0000000..2c95bc2
--- /dev/null
+++ b/springbootstart.ipr
@@ -0,0 +1,111 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/springbootstart.iws b/springbootstart.iws
new file mode 100644
index 0000000..57de9a0
--- /dev/null
+++ b/springbootstart.iws
@@ -0,0 +1,418 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/src/main/java/com/zhehekeji/web/config/WebSocketConfig.java b/web/src/main/java/com/zhehekeji/web/config/WebSocketConfig.java
index da266fc..116c5c9 100644
--- a/web/src/main/java/com/zhehekeji/web/config/WebSocketConfig.java
+++ b/web/src/main/java/com/zhehekeji/web/config/WebSocketConfig.java
@@ -2,7 +2,6 @@ package com.zhehekeji.web.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.web.socket.server.standard.ServerEndpointExporter;
@Configuration
public class WebSocketConfig {
@@ -10,8 +9,4 @@ public class WebSocketConfig {
* 如果使用Springboot默认内置的tomcat容器,则必须注入ServerEndpoint的bean;
* 如果使用外置的web容器,则不需要提供ServerEndpointExporter,下面的注入可以注解掉
*/
- @Bean
- public ServerEndpointExporter serverEndpointExporter(){
- return new ServerEndpointExporter();
- }
}
diff --git a/web/src/main/java/com/zhehekeji/web/controller/CategoryController.java b/web/src/main/java/com/zhehekeji/web/controller/CategoryController.java
index db68c7a..b060109 100644
--- a/web/src/main/java/com/zhehekeji/web/controller/CategoryController.java
+++ b/web/src/main/java/com/zhehekeji/web/controller/CategoryController.java
@@ -13,12 +13,16 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.List;
+import static com.zhehekeji.web.service.algorithm.AlgorithmService.*;
+import static com.zhehekeji.web.service.algorithm.AlgorithmService.fatherList;
+
@Api(value = "category",tags = "分类管理")
@RestController
@RequestMapping("/category")
@@ -39,18 +43,33 @@ public class CategoryController {
@ApiOperation("分页列表")
@PostMapping("/page")
public Result> page(@RequestBody PageSearch pageSearch){
- return Result.success(categoryService.list(pageSearch));
+ PageInfo list =categoryService.list(pageSearch);
+ for (Category category : list.getList()) {
+ category.setFatherName(fatherList.get(category.getFather()));
+ }
+ return Result.success(list);
}
@ApiOperation("列表")
@GetMapping("/list")
public Result> list(@RequestParam String name){
- return Result.success(categoryService.list(name));
+ List list = categoryService.list(name);
+ for (Category category : list) {
+ category.setFatherName(fatherList.get(category.getFather()));
+ }
+ return Result.success();
+ }
+
+ @ApiOperation("列表")
+ @GetMapping("/fatherList")
+ public Result> fatherList(){
+ return Result.success(fatherList);
}
@ApiOperation("修改")
@PutMapping()
public Result edit(@RequestBody Category category){
+ editOrSave(category);
categoryService.edit(category);
return Result.success();
}
@@ -58,12 +77,38 @@ public class CategoryController {
@ApiOperation("新增")
@PostMapping()
public Result add(@RequestBody Category category){
+
+// category.getImageFile()
+ editOrSave(category);
return Result.success(categoryService.add(category));
}
+ String setFile(Category category){
+ MultipartFile imageFile = category.getImageFile();
+ if(imageFile != null){
+ String fileName = imageFile.getOriginalFilename();
+ try {
+ imageFile.transferTo(new File("D:/git/hzleaper/lia-monitor-backend/web/src/main/resources/static/images/"+fileName));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ category.setImage("/images/"+fileName);
+ }
+ return null;
+ }
+
+
+ static void editOrSave(Category category){
+
+ classIdMap.put(category.getCode(), category.getFather());
+ countLayersMap.put(category.getCode(), category.getCount());
+ }
@ApiOperation("删除")
@DeleteMapping("/{id}")
public Result del(@PathVariable Integer id){
+ Category category = categoryService.getById( id);
+ classIdMap.remove(category.getCode());
+ countLayersMap.remove(category.getCode());
categoryService.del(id);
return Result.success();
}
diff --git a/web/src/main/java/com/zhehekeji/web/entity/Category.java b/web/src/main/java/com/zhehekeji/web/entity/Category.java
index bafbc90..56d3799 100644
--- a/web/src/main/java/com/zhehekeji/web/entity/Category.java
+++ b/web/src/main/java/com/zhehekeji/web/entity/Category.java
@@ -1,12 +1,10 @@
package com.zhehekeji.web.entity;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;
import java.util.ArrayList;
@@ -24,6 +22,33 @@ public class Category {
private String name;
+ private Integer father;
+
+ @TableField(value = "`number`")
+ private Integer number;
+
+ private Integer degree;
+
+ private String image;
+ private Integer milliliter;
+
+
+
+
+
+
+
+ @TableField(exist = false)
+ private MultipartFile imageFile;
+
+
+
+
+
+@TableField(exist = false)
+ private String fatherName;
+ private Integer count;
+
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
diff --git a/web/src/main/java/com/zhehekeji/web/service/CategoryService.java b/web/src/main/java/com/zhehekeji/web/service/CategoryService.java
index 4c3b61b..3f7df32 100644
--- a/web/src/main/java/com/zhehekeji/web/service/CategoryService.java
+++ b/web/src/main/java/com/zhehekeji/web/service/CategoryService.java
@@ -4,6 +4,7 @@ import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.builder.ExcelReaderBuilder;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhehekeji.core.util.Assert;
@@ -42,7 +43,7 @@ import java.util.stream.Collectors;
@Service
@Slf4j
-public class CategoryService {
+public class CategoryService extends ServiceImpl {
@Resource
private CategoryMapper categoryMapper;
diff --git a/web/src/main/java/com/zhehekeji/web/service/algorithm/AlgorithmService.java b/web/src/main/java/com/zhehekeji/web/service/algorithm/AlgorithmService.java
index 351da81..79af5de 100644
--- a/web/src/main/java/com/zhehekeji/web/service/algorithm/AlgorithmService.java
+++ b/web/src/main/java/com/zhehekeji/web/service/algorithm/AlgorithmService.java
@@ -2,12 +2,14 @@ package com.zhehekeji.web.service.algorithm;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
-import com.google.gson.Gson;
import com.zhehekeji.core.pojo.Result;
import com.zhehekeji.web.config.ConfigProperties;
import com.zhehekeji.web.entity.AlgorithmPojo;
+import com.zhehekeji.web.entity.Category;
import com.zhehekeji.web.entity.Street;
import com.zhehekeji.web.entity.yolo.Calculate;
+import com.zhehekeji.web.mapper.CategoryMapper;
+import com.zhehekeji.web.service.CategoryService;
import com.zhehekeji.web.service.ksec.KsecDataInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.ParameterizedTypeReference;
@@ -18,8 +20,11 @@ import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
+import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@@ -37,20 +42,44 @@ public class AlgorithmService {
System.out.println(null=="111");
}
- static Map classIdMap = new HashMap<>();
+ public static Map classIdMap = new HashMap<>();
+ public static List fatherList = new ArrayList<>();
public static Map countLayersMap = new HashMap<>();
static {
String fileName = "ca.txt"; // 当前文件夹下的文件名
+ String fatherPath = "father.txt"; // 当前文件夹下的文件名
+ fatherList = readJsonArrayFile(fatherPath);
+//
+// try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
+// String line;
+// while ((line = br.readLine()) != null) {
+// String[] parts = line.split(" ");
+// classIdMap.put(parts[0], Integer.parseInt(parts[1]));
+// countLayersMap.put(parts[0], Integer.parseInt(parts[2]));
+// }
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+ }
- try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
- String line;
- while ((line = br.readLine()) != null) {
- String[] parts = line.split(" ");
- classIdMap.put(parts[0], Integer.parseInt(parts[1]));
- countLayersMap.put(parts[0], Integer.parseInt(parts[2]));
- }
+ @Resource
+ private CategoryService categoryService;
+ @PostConstruct
+ public void init() {
+ List categories = categoryService.list();
+ for (Category category : categories) {
+ classIdMap.put(category.getCode(), category.getFather());
+ countLayersMap.put(category.getCode(), category.getCount());
+ }
+ }
+
+ public static List readJsonArrayFile(String fileName) {
+ try {
+ String content = new String(Files.readAllBytes(Paths.get(fileName)));
+ return JSON.parseArray(content, String.class);
} catch (IOException e) {
e.printStackTrace();
+ return new ArrayList<>();
}
}
@@ -118,7 +147,6 @@ public class AlgorithmService {
try {
System.out.println(algorithmPojo);
- Gson gson = new Gson();
// String jsonString = gson.toJson(algorithmPojo);
body = restTemplate.postForEntity(url, algorithmPojo, String.class);
algorithmPojo = JSONObject.parseObject(body.getBody(), AlgorithmPojo.class);