diff --git a/father.txt b/father.txt deleted file mode 100644 index 83a008c..0000000 --- a/father.txt +++ /dev/null @@ -1,16 +0,0 @@ - [ - "古井贡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 deleted file mode 100644 index 2c95bc2..0000000 --- a/springbootstart.ipr +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/springbootstart.iws b/springbootstart.iws deleted file mode 100644 index 57de9a0..0000000 --- a/springbootstart.iws +++ /dev/null @@ -1,418 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 116c5c9..da266fc 100644 --- a/web/src/main/java/com/zhehekeji/web/config/WebSocketConfig.java +++ b/web/src/main/java/com/zhehekeji/web/config/WebSocketConfig.java @@ -2,6 +2,7 @@ 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 { @@ -9,4 +10,8 @@ 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 b060109..db68c7a 100644 --- a/web/src/main/java/com/zhehekeji/web/controller/CategoryController.java +++ b/web/src/main/java/com/zhehekeji/web/controller/CategoryController.java @@ -13,16 +13,12 @@ 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") @@ -43,33 +39,18 @@ public class CategoryController { @ApiOperation("分页列表") @PostMapping("/page") public Result> page(@RequestBody PageSearch pageSearch){ - PageInfo list =categoryService.list(pageSearch); - for (Category category : list.getList()) { - category.setFatherName(fatherList.get(category.getFather())); - } - return Result.success(list); + return Result.success(categoryService.list(pageSearch)); } @ApiOperation("列表") @GetMapping("/list") public Result> list(@RequestParam String 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); + return Result.success(categoryService.list(name)); } @ApiOperation("修改") @PutMapping() public Result edit(@RequestBody Category category){ - editOrSave(category); categoryService.edit(category); return Result.success(); } @@ -77,38 +58,12 @@ 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 56d3799..bafbc90 100644 --- a/web/src/main/java/com/zhehekeji/web/entity/Category.java +++ b/web/src/main/java/com/zhehekeji/web/entity/Category.java @@ -1,10 +1,12 @@ package com.zhehekeji.web.entity; -import com.baomidou.mybatisplus.annotation.*; +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.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; @@ -22,33 +24,6 @@ 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 3f7df32..4c3b61b 100644 --- a/web/src/main/java/com/zhehekeji/web/service/CategoryService.java +++ b/web/src/main/java/com/zhehekeji/web/service/CategoryService.java @@ -4,7 +4,6 @@ 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; @@ -43,7 +42,7 @@ import java.util.stream.Collectors; @Service @Slf4j -public class CategoryService extends ServiceImpl { +public class CategoryService { @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 79af5de..351da81 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,14 +2,12 @@ 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; @@ -20,11 +18,8 @@ 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; @@ -42,44 +37,20 @@ public class AlgorithmService { System.out.println(null=="111"); } - public static Map classIdMap = new HashMap<>(); - public static List fatherList = new ArrayList<>(); + static Map classIdMap = new HashMap<>(); 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(); -// } - } - @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); + 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(); - return new ArrayList<>(); } } @@ -147,6 +118,7 @@ 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);