Просмотр исходного кода

Merge remote-tracking branch 'origin/master' into test

# Conflicts:
#	src/main/resources/application.yml
lwhhszx 1 год назад
Родитель
Сommit
cfa22d85a5
100 измененных файлов с 3049 добавлено и 784 удалено
  1. 1 1
      src/main/java/com/example/xiaoshiweixinback/business/common/ResponseEnum.java
  2. 30 0
      src/main/java/com/example/xiaoshiweixinback/business/config/AsyncConfiguration.java
  3. 13 0
      src/main/java/com/example/xiaoshiweixinback/business/config/WebSocketConfig.java
  4. 3 2
      src/main/java/com/example/xiaoshiweixinback/business/exception/ExceptionEnum.java
  5. 20 12
      src/main/java/com/example/xiaoshiweixinback/business/utils/FileUtils.java
  6. 47 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/ImageUtil.java
  7. 47 1
      src/main/java/com/example/xiaoshiweixinback/business/utils/ReadExcelUtils.java
  8. 114 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/WebSocketServer.java
  9. 0 46
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/DataProcessHandler.java
  10. 0 5
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IProcessData.java
  11. 0 23
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IncoPatInventorAddressHandler.java
  12. 0 59
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IncoPatPatentAffairHandler.java
  13. 0 17
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IncoPatUCMainHandler.java
  14. 0 15
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IntegerHandler.java
  15. 0 42
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatSnapPatentAffairHandler.java
  16. 0 24
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatentTypeHandler.java
  17. 0 23
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatenticsAgencyAndAgentHandler.java
  18. 0 73
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatenticsPatentAffairHandler.java
  19. 0 18
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatenticsStringHandler.java
  20. 0 20
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/SplitBySerialNumberAndRemoveLineFeedHandler.java
  21. 0 28
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/SplitOriginalAndTranslationHandler.java
  22. 0 22
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/StringHandler.java
  23. 0 22
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/StringSpecialHandler.java
  24. 0 18
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/TimeHandler.java
  25. 2 2
      src/main/java/com/example/xiaoshiweixinback/business/utils/parseQueryToTree/expressManager.java
  26. 18 1
      src/main/java/com/example/xiaoshiweixinback/controller/ImportPatentController.java
  27. 66 0
      src/main/java/com/example/xiaoshiweixinback/controller/MonitoringController.java
  28. 20 0
      src/main/java/com/example/xiaoshiweixinback/controller/ProductCategoryController.java
  29. 55 21
      src/main/java/com/example/xiaoshiweixinback/controller/ProductController.java
  30. 40 0
      src/main/java/com/example/xiaoshiweixinback/controller/TemplateController.java
  31. 1 1
      src/main/java/com/example/xiaoshiweixinback/domain/AssoproductCategory.java
  32. 64 0
      src/main/java/com/example/xiaoshiweixinback/domain/ImportTask.java
  33. 39 0
      src/main/java/com/example/xiaoshiweixinback/domain/Monitor.java
  34. 45 0
      src/main/java/com/example/xiaoshiweixinback/domain/MonitorRecord.java
  35. 1 1
      src/main/java/com/example/xiaoshiweixinback/domain/Product.java
  36. 2 1
      src/main/java/com/example/xiaoshiweixinback/domain/ProductCategory.java
  37. 46 0
      src/main/java/com/example/xiaoshiweixinback/domain/Template.java
  38. 8 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/TemplateDTO.java
  39. 41 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/monitoring/AddMonitoringDTO.java
  40. 15 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/monitoring/CancelMonitoringDTO.java
  41. 9 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/monitoring/MonitoringIdDTO.java
  42. 13 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/monitoring/SelectMonitoringDTO.java
  43. 3 0
      src/main/java/com/example/xiaoshiweixinback/entity/product/HotProductAddDTO.java
  44. 15 0
      src/main/java/com/example/xiaoshiweixinback/entity/product/HotProductDeleteDTO.java
  45. 26 0
      src/main/java/com/example/xiaoshiweixinback/entity/product/UploadCategoryParamsVO.java
  46. 62 0
      src/main/java/com/example/xiaoshiweixinback/entity/product/UploadProductParamsVO.java
  47. 80 0
      src/main/java/com/example/xiaoshiweixinback/entity/quartz/QrtzTaskDTO.java
  48. 14 0
      src/main/java/com/example/xiaoshiweixinback/entity/quartz/QuartzVO.java
  49. 3 4
      src/main/java/com/example/xiaoshiweixinback/entity/vo/ProductCategoryVO.java
  50. 8 1
      src/main/java/com/example/xiaoshiweixinback/entity/vo/ProductVO.java
  51. 12 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/TemplateVO.java
  52. 13 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/esPicture/GetImageVO.java
  53. 7 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/monitoring/SelectMonitoringRecordVO.java
  54. 7 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/monitoring/SelectMonitoringVO.java
  55. 2 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/person/LoginVO.java
  56. 7 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/productCategory/SelectCategoryVO.java
  57. 35 0
      src/main/java/com/example/xiaoshiweixinback/entity/websocket/TaskWebSocketDTO.java
  58. 21 0
      src/main/java/com/example/xiaoshiweixinback/entity/websocket/WebSocketMessageVO.java
  59. 19 0
      src/main/java/com/example/xiaoshiweixinback/mapper/ImportTaskMapper.java
  60. 18 0
      src/main/java/com/example/xiaoshiweixinback/mapper/MonitorMapper.java
  61. 18 0
      src/main/java/com/example/xiaoshiweixinback/mapper/MonitorRecordMapper.java
  62. 2 1
      src/main/java/com/example/xiaoshiweixinback/mapper/ProductMapper.java
  63. 18 0
      src/main/java/com/example/xiaoshiweixinback/mapper/TemplateMapper.java
  64. 34 8
      src/main/java/com/example/xiaoshiweixinback/service/AssoPersonProductService.java
  65. 31 5
      src/main/java/com/example/xiaoshiweixinback/service/AssoproductCategoryService.java
  66. 65 0
      src/main/java/com/example/xiaoshiweixinback/service/ImportTaskService.java
  67. 34 0
      src/main/java/com/example/xiaoshiweixinback/service/MonitorRecordService.java
  68. 154 0
      src/main/java/com/example/xiaoshiweixinback/service/MonitorService.java
  69. 294 46
      src/main/java/com/example/xiaoshiweixinback/service/ProductCategoryService.java
  70. 185 46
      src/main/java/com/example/xiaoshiweixinback/service/ProductService.java
  71. 41 0
      src/main/java/com/example/xiaoshiweixinback/service/TemplateService.java
  72. 1 3
      src/main/java/com/example/xiaoshiweixinback/service/common/FileManagerService.java
  73. 39 0
      src/main/java/com/example/xiaoshiweixinback/service/common/MessageService.java
  74. 32 18
      src/main/java/com/example/xiaoshiweixinback/service/common/OPSService.java
  75. 82 25
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/EsDenseVectorService.java
  76. 1 1
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/GetPatentFromExcelService.java
  77. 0 1
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/GetPatentPictureFromExcelService.java
  78. 0 1
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/ImportFromWebToEsService.java
  79. 2 2
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ExcuteUploadSettingService.java
  80. 2 2
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetFilesFromOPSService.java
  81. 72 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetOPSFileByExcelService.java
  82. 59 14
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetPatentFromSzService.java
  83. 0 87
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProduct.java
  84. 128 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProductCategoryService.java
  85. 142 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProductService.java
  86. 2 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/PatentData.java
  87. 70 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/UploadPatentBatchUtil.java
  88. 13 0
      src/main/java/com/example/xiaoshiweixinback/service/quartzService/ImportJobService.java
  89. 127 0
      src/main/java/com/example/xiaoshiweixinback/service/quartzService/JobService.java
  90. 28 0
      src/main/java/com/example/xiaoshiweixinback/service/quartzService/TaskAddJob.java
  91. 6 6
      src/main/resources/application-dev.yml
  92. 5 1
      src/main/resources/application-prodNetIn.yml
  93. 5 1
      src/main/resources/application-prodNetOut.yml
  94. 30 0
      src/main/resources/jsons/uploadCategory.json
  95. 79 0
      src/main/resources/jsons/uploadProduct.json
  96. 77 10
      src/main/resources/mapper/ProductMapper.xml
  97. 59 0
      src/test/java/com/example/xiaoshiweixinback/ImportProductTests.java
  98. 0 2
      src/test/java/com/example/xiaoshiweixinback/NoticeServiceTest.java
  99. 0 1
      src/test/java/com/example/xiaoshiweixinback/TicketServiceTests.java
  100. 0 0
      src/test/java/com/example/xiaoshiweixinback/XiaoshiWeixinbackApplicationTests.java

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/business/common/ResponseEnum.java

@@ -21,7 +21,7 @@ public enum ResponseEnum {
     PATENT_PDF_EXPORT_TASK_DONE(605,"导出PDF首页完成"),
     LOGIN_ERROR(606,"登录错误"),
     BUSINESS_ERROR(607,"业务错误"),
-
+    IMPORT_TASK(111,"导入任务"),
     //es检索业务错误异常
     THE_RETRIEVAL_ERROR(608,"检索式错误");
 

+ 30 - 0
src/main/java/com/example/xiaoshiweixinback/business/config/AsyncConfiguration.java

@@ -0,0 +1,30 @@
+package com.example.xiaoshiweixinback.business.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+
+@Configuration
+@EnableAsync  // 启用异步任务
+public class AsyncConfiguration {
+    // 声明一个线程池(并指定线程池的名字)
+    @Bean("taskExecutor")
+    public Executor asyncExecutor() {
+        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+        //核心线程数5:线程池创建时候初始化的线程数
+        executor.setCorePoolSize(5);
+        //最大线程数5:线程池最大的线程数,只有在缓冲队列满了之后才会申请超过核心线程数的线程
+        executor.setMaxPoolSize(5);
+        //缓冲队列500:用来缓冲执行任务的队列
+        executor.setQueueCapacity(500);
+        //允许线程的空闲时间60秒:当超过了核心线程出之外的线程在空闲时间到达之后会被销毁
+        executor.setKeepAliveSeconds(60);
+        //线程池名的前缀:设置好了之后可以方便我们定位处理任务所在的线程池
+        executor.setThreadNamePrefix("DailyAsync-");
+        executor.initialize();
+        return executor;
+	}
+}

+ 13 - 0
src/main/java/com/example/xiaoshiweixinback/business/config/WebSocketConfig.java

@@ -0,0 +1,13 @@
+package com.example.xiaoshiweixinback.business.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 {
+    @Bean
+    public ServerEndpointExporter serverEndpointExporter() {
+        return new ServerEndpointExporter();
+    }
+}

+ 3 - 2
src/main/java/com/example/xiaoshiweixinback/business/exception/ExceptionEnum.java

@@ -19,11 +19,12 @@ public enum ExceptionEnum {
 
     //异常20000
     THE_PARAMETER_EXCEPTION("20001", "参数异常,请传入数据"),
-    THE_GET_INFORMATION_TOKEN_INVALID("20002", "获取用信息token失效"),
+    THE_GET_INFORMATION_TOKEN_INVALID("20002", "获取用信息token失效"),
     THE_FAIL_TO_DELETE("20003", "删除失败"),
 
     //业务异常
-    THE_PRODUCT_CATEGORY_NAME_IS_EXIST("608", "产品类别名称已存在"),
+    THE_PRODUCT_CATEGORY_NAME_IS_EXIST("607", "产品类别名称已存在"),
+    THE_LOG_INVALID_NEED_LOGIN_AGAIN("606","登录失效,请重新登录"),
 
 
 

+ 20 - 12
src/main/java/com/example/xiaoshiweixinback/business/utils/FileUtils.java

@@ -23,13 +23,11 @@ public class FileUtils {
         //获取 applicationHome 内的路径 ...\target\classes 到这一层级下
         File file = ah.getSource();
         //获取 file的parentFile 即最后一级之前的所有层级路径(包括盘符) 这里能获得到的最终层级为  ...\target 后续用FILE_SEPARATOR(系统路径分割通配符 即 "\") 以及fileName拼接生成存放文件的目录层级 即为根目录 root
-        String rootPath =null;
+        String rootPath = null;
 
-        if (fileName!=null&&!fileName.equals(""))
-        {
-            rootPath= file.getParentFile().toString() + FILE_SEPARATOR + fileName;
-        }
-        else {
+        if (fileName != null && !fileName.equals("")) {
+            rootPath = file.getParentFile().toString() + FILE_SEPARATOR + fileName;
+        } else {
             rootPath = file.getParentFile().toString();
         }
         //根据上方生成的根目录路径 生成对应文件夹 没有就新建
@@ -40,7 +38,8 @@ public class FileUtils {
         //返回的最终形式为 盘符:\项目层级\target\file
         return rootPath;
     }
-    public static  File getPictureFileByUrl(String dataUrl) throws IOException {
+
+    public static File getPictureFileByUrl(String dataUrl) throws IOException {
 
         URL url = new URL(dataUrl);  //想要读取的url地址
         InputStream in = url.openStream();
@@ -57,10 +56,16 @@ public class FileUtils {
         in.close();
         return file;
     }
-    public String analysisJsonFile() {
+
+    public String analysisJsonFile(String configName) {
+
+        if (configName == null) {
+            configName = "uploadSetting.json";
+        }
+
         ApplicationHome ah = new ApplicationHome(ToolUtil.class);
         File file = ah.getSource();
-        String settingFilePath = file.getParentFile().toString() + FileUtils.FILE_SEPARATOR + "uploadSetting.json";
+        String settingFilePath = file.getParentFile().toString() + FileUtils.FILE_SEPARATOR + configName;
         BufferedReader reader = null;
         StringBuilder last = new StringBuilder();
         InputStreamReader inputStreamReader;
@@ -86,7 +91,8 @@ public class FileUtils {
         }
         return last.toString();
     }
-    public static   File  getFileByBytes(byte[] bytes, String prefix, String suffix) {
+
+    public static File getFileByBytes(byte[] bytes, String prefix, String suffix) {
         BufferedOutputStream bos = null;
         FileOutputStream fos = null;
         File file = null;
@@ -120,12 +126,13 @@ public class FileUtils {
                     e.printStackTrace();
                 }
             }
-            return  file;
+            return file;
         }
     }
+
     public static File multipartFileToFile(MultipartFile file) throws Exception {
         File toFile = null;
-        if (file == null ||file.equals("") || file.getSize() <= 0) {
+        if (file == null || file.equals("") || file.getSize() <= 0) {
             file = null;
         } else {
             InputStream ins = null;
@@ -136,6 +143,7 @@ public class FileUtils {
         }
         return toFile;
     }
+
     //获取流文件
     private static void inputStreamToFile(InputStream ins, File file) {
         try {

+ 47 - 0
src/main/java/com/example/xiaoshiweixinback/business/utils/ImageUtil.java

@@ -0,0 +1,47 @@
+package com.example.xiaoshiweixinback.business.utils;
+
+import com.example.xiaoshiweixinback.business.properties.BaseProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+@Component
+public class ImageUtil {
+
+    public BufferedImage getByUrl(String imageUrl) throws Exception {
+        URL url = new URL(imageUrl);
+        HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+        /**设置请求方式为"GET"*/
+        httpConn.setRequestMethod("GET");
+        /**超时响应时间为5秒*/
+        httpConn.setConnectTimeout(5 * 1000);
+        httpConn.connect();
+        InputStream is = httpConn.getInputStream();
+        // 读取图片
+        BufferedImage bufImage = ImageIO.read(is);
+        return bufImage;
+    }
+    public static BufferedImage getByByte( byte[] b) throws Exception {
+        ByteArrayInputStream in = new ByteArrayInputStream(b);    //将b作为输入流;
+        BufferedImage image = ImageIO.read(in);
+        return image;
+    }
+    public static File cutImage(BufferedImage bufferedImage, Integer x, Integer y, String name) throws Exception {
+       if(bufferedImage==null){
+           return null;
+       }
+        BufferedImage newBufferedImage = bufferedImage.getSubimage(x, y, bufferedImage.getWidth(), bufferedImage.getHeight()-300);
+        File imgCutFile = new File(name);
+        ImageIO.write(newBufferedImage, "jpeg", imgCutFile);
+        return imgCutFile;
+
+    }
+
+}

+ 47 - 1
src/main/java/com/example/xiaoshiweixinback/business/utils/ReadExcelUtils.java

@@ -106,7 +106,6 @@ public class ReadExcelUtils {
     public static PatentData readExcelOneRow(File tempFile, Sheet sheet, int row) throws IOException {
         //创建返回最终结果的对象 patentData
         PatentData patentData = new PatentData();
-        //装载专利数据(除了摘要附图)的map:(key:表头如 "公开(公告)号"  value:表头对应内容如 "CN1307082B")
         Map<Object, Object> map = new HashMap<>();
         //装载摘要附图的对象
         PictureData pictureData = null;
@@ -301,4 +300,51 @@ System.out.println("daoru");
         return pictureDatas;
     }
 
+
+    public static Integer getExcelTotal(Sheet sheet) throws IOException {
+        //读取总行数
+        int rows = sheet.getPhysicalNumberOfRows();
+
+        //返回文件总行数-1(即专利总数量)
+        return rows - 1;
+    }
+
+
+    /**
+     * 获取一行专利的全部数据(专利内容数据 + 摘要附图)
+     *
+     * @param tempFile Excel临时文件
+     * @param row      行数
+     * @return 返回装载专利数据(专利内容数据 + 摘要附图)的对象
+     */
+    public static PatentData readExcelOneRow2(File tempFile, Sheet sheet, int row) throws IOException {
+        //创建返回最终结果的对象 patentData
+        PatentData patentData = new PatentData();
+        Map<Object, Object> map = new HashMap<>();
+        //装载摘要附图的对象
+        List<PictureData> pictureDatas = new ArrayList<>();
+
+        //开始装载专利数据
+        Row firstRow = sheet.getRow(0);
+        Row needRow = sheet.getRow(row);
+        //获得总列数
+        int columns = firstRow.getLastCellNum();
+        for (int i = 0; i < columns; i++) {
+            map.put(firstRow.getCell(i) + "", ExcelUtils.getValue(needRow.getCell(i)) + "");
+        }
+
+        //开始装载专利摘要附图(判断用07还是03的方法获取图片)
+        String suffix = tempFile.getName().substring(tempFile.getName().lastIndexOf("."));
+        if (suffix.equals(".xls") || suffix.equals(".XLS")) {
+        } else if (suffix.equals(".xlsx") || suffix.equals(".XLSX")) {
+            pictureDatas = getPictures((XSSFSheet) sheet, row);
+        }
+
+        //返回结果对象装载结果
+        patentData.setMap(map);
+        patentData.setPictureDataList(pictureDatas);
+
+        return patentData;
+    }
+
 }

+ 114 - 0
src/main/java/com/example/xiaoshiweixinback/business/utils/WebSocketServer.java

@@ -0,0 +1,114 @@
+package com.example.xiaoshiweixinback.business.utils;
+
+
+import com.example.xiaoshiweixinback.business.common.Constants;
+import com.example.xiaoshiweixinback.business.common.Response;
+import jakarta.websocket.*;
+import jakarta.websocket.server.PathParam;
+import jakarta.websocket.server.ServerEndpoint;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+@Slf4j
+@Component
+@ServerEndpoint("/"+Constants.XIAOSHI_WEIXINBACK + "/ws/{sid}")
+public class WebSocketServer {
+
+    //静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
+    private static int onlineCount = 0;
+    //concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
+    private static CopyOnWriteArraySet<WebSocketServer> webSocketSet
+            = new CopyOnWriteArraySet<WebSocketServer>();
+    //与某个客户端的连接会话,需要通过它来给客户端发送数据
+    private Session session;
+    //接收sid
+    private String sid = "";
+
+    /**
+     * 连接建立成功调用的方法
+     */
+    @OnOpen
+    public void onOpen(Session session, @PathParam("sid") String sid) {
+        this.session = session;
+        webSocketSet.add(this);     //加入set中
+        addOnlineCount();           //在线数加1
+        log.info("有新窗口开始监听:" + sid + ",当前在线人数为" + getOnlineCount());
+        this.sid = sid;
+        try {
+            sendMessage(Response.success("连接成功").toString());
+        } catch (IOException e) {
+            log.error("websocket IO异常");
+        }
+    }
+
+    /**
+     * 连接关闭调用的方法
+     */
+    @OnClose
+    public void onClose() {
+        webSocketSet.remove(this);  //从set中删除
+        subOnlineCount();           //在线数减1
+        log.info("有一连接关闭!当前在线人数为" + getOnlineCount());
+    }
+
+    /**
+     * 收到客户端消息后调用的方法
+     *
+     * @param message 客户端发送过来的消息
+     */
+    @OnMessage
+    public void onMessage(String message, Session session) {
+        log.info("收到来自窗口" + sid + "的信息:" + message);
+        //群发消息
+        for (WebSocketServer item : webSocketSet) {
+            try {
+                item.sendMessage(message);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    @OnError
+    public void onError(Session session, Throwable error) {
+        log.error("发生错误");
+        error.printStackTrace();
+    }
+
+    //实现服务器主动推送
+    public synchronized void sendMessage(String message) throws IOException {
+        this.session.getBasicRemote().sendText(message);
+    }
+
+    //群发自定义消息
+    public synchronized static void sendInfo(String message, @PathParam("sid") String sid) {
+        log.info("推送消息到窗口" + sid + ",推送内容:" + message);
+        for (WebSocketServer item : webSocketSet) {
+            try {
+                //这里可以设定只推送给这个sid的,为null则全部推送
+                if (sid == null || "null".equals(sid)) {
+                    item.sendMessage(message);
+                } else if (item.sid.equals(sid)) {
+                    item.sendMessage(message);
+                }
+            } catch (IOException e) {
+                continue;
+            }
+        }
+    }
+
+    public static synchronized int getOnlineCount() {
+        return onlineCount;
+    }
+
+    public static synchronized void addOnlineCount() {
+        WebSocketServer.onlineCount++;
+    }
+
+    public static synchronized void subOnlineCount() {
+        WebSocketServer.onlineCount--;
+    }
+}

+ 0 - 46
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/DataProcessHandler.java

@@ -1,46 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-
-public class DataProcessHandler {
-    public interface IProcessData {
-        Object processData(Object data, Object code);
-    }
-
-    public DataProcessHandler() {
-    }
-
-    public static Object getData(String typeName, String jarOrClassPath) {
-
-        if (jarOrClassPath != null) {
-            try {
-                //用路径创建Url
-                URL url = new URL("file:" + jarOrClassPath);
-                //通过Url加载外部的jar包
-                URLClassLoader urlClassLoader = new URLClassLoader(new URL[]{url});
-                Class<?> clazz = urlClassLoader.loadClass(typeName);
-                return clazz.newInstance();
-            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | MalformedURLException e) {
-                e.printStackTrace();
-            }
-        } else {
-            try {
-                return Class.forName(typeName).newInstance();
-            } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
-                e.printStackTrace();
-            }
-        }
-        return null;
-    }
-
-    public static void main(String[] args) {
-        System.out.println("启动成功");
-    }
-
-}
-
-
-
-

+ 0 - 5
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IProcessData.java

@@ -1,5 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-public interface IProcessData {
-    Object processData(Object data, Object code);
-}

+ 0 - 23
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IncoPatInventorAddressHandler.java

@@ -1,23 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-
-
-import com.example.xiaoshiweixinback.business.utils.StringUtils;
-
-import java.util.List;
-
-public class IncoPatInventorAddressHandler implements IProcessData {
-    public IncoPatInventorAddressHandler() {
-    }
-
-    @Override
-    public Object processData(Object data, Object code) {
-        List<String> splitStr = StringUtils.changeStringToString(data.toString().replaceAll(" ", ""), ";");
-        if (code.toString().equals("1")) {
-            return splitStr;
-        } else if (code.toString().equals("2")) {
-            return splitStr.get(0);
-        }
-        return null;
-    }
-}

+ 0 - 59
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IncoPatPatentAffairHandler.java

@@ -1,59 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-
-import com.example.xiaoshiweixinback.business.utils.StringUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class IncoPatPatentAffairHandler implements IProcessData {
-    public IncoPatPatentAffairHandler() {
-    }
-
-    @Override
-    public Object processData(Object data, Object code) {
-        String processedData = data.toString().replaceAll("\r\n", "");
-        List<String> contentList = StringUtils.changeStringToString(processedData, "([\\u4e00-\\u9fa5]+):");
-        contentList.remove(0);
-
-        List<String> tableList = new ArrayList<>();
-        Pattern p = Pattern.compile("([\\u4e00-\\u9fa5]+):");
-        Matcher m = p.matcher(data.toString());
-        while (m.find()) {
-            tableList.add(m.group(1));
-        }
-
-        StringBuilder all = new StringBuilder();
-        StringBuilder one = new StringBuilder();
-        for (int i = 0; i < tableList.size(); i++) {
-            if (tableList.get(i).contains("法律状态公告日")) {
-                if (!one.toString().equals("")) {
-                    if (!all.toString().equals("")) {
-                        all.append(",{").append(one).append("]").append("}");
-                    } else {
-                        all = new StringBuilder("{" + one + "]}");
-                    }
-                }
-                one = new StringBuilder();
-            }
-
-            if (one.toString().equals("")) {
-                one = new StringBuilder("\"inpadocData\"" + ":[" + "{" + "\"name\"" + ":" + "\"" + tableList.get(i) + "\"" + ",\"" + "content\"" + ":" + "\"" + contentList.get(i).replaceAll(";", "") + "\"" + "}");
-            } else {
-                one.append(",").append("{" + "\"name\"" + ":").append("\"").append(tableList.get(i)).append("\"" + "," + "\"" + "content\"" + ":" + "\"").append(contentList.get(i).replaceAll(";", "")).append("\"" + "}");
-            }
-
-        }
-        if (!one.toString().equals("")) {
-            if (!all.toString().equals("")) {
-                all.append(",{").append(one).append("]").append("}");
-            } else {
-                all = new StringBuilder("{" + one + "]}");
-            }
-        }
-        all = new StringBuilder("[" + all + "]");
-        return all.toString();
-    }
-}

+ 0 - 17
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IncoPatUCMainHandler.java

@@ -1,17 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-
-import com.example.xiaoshiweixinback.business.utils.StringUtils;
-
-import java.util.List;
-
-public class IncoPatUCMainHandler implements IProcessData {
-    public IncoPatUCMainHandler() {
-    }
-
-    @Override
-    public Object processData(Object data, Object splitSymbol) {
-        List<String> splitList = StringUtils.changeStringToString(data.toString(), splitSymbol.toString());
-        return splitList.get(0);
-    }
-}

+ 0 - 15
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IntegerHandler.java

@@ -1,15 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-/**
- * @name 数字处理类
- * @description 1.传入的字符型数字数据转换为int型
- */
-public class IntegerHandler implements IProcessData {
-    public IntegerHandler() {
-    }
-
-    @Override
-    public Object processData(Object data, Object splitSymbol) {
-        return Integer.parseInt(data.toString());
-    }
-}

+ 0 - 42
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatSnapPatentAffairHandler.java

@@ -1,42 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-
-import com.example.xiaoshiweixinback.business.utils.StringUtils;
-
-import java.util.List;
-
-public class PatSnapPatentAffairHandler implements IProcessData {
-    public PatSnapPatentAffairHandler() {
-    }
-
-    @Override
-    public Object processData(Object data, Object code) {
-        List<String> splitStr = StringUtils.changeStringToString(data.toString(), "\\|");
-        if (splitStr.size() % 3 != 0) {
-            return null;
-        }
-        StringBuilder all = new StringBuilder();
-        StringBuilder one = new StringBuilder();
-        for (int i = 0; i < splitStr.size(); i += 3) {
-            if (one.toString().equals("")) {
-                one = new StringBuilder("\"inpadocData\"" + ":[" + "{" + "\"name\"" + ":" + "\"发生日期\"" + "," + "\"content\"" + ":" + "\"" + splitStr.get(i).trim() + "\"" + "}");
-            } else {
-                one.append("," + "{" + "\"name\"" + ":" + "\"发生日期\"" + "," + "\"content\"" + ":" + "\"").append(splitStr.get(i).trim()).append("\"").append("}");
-            }
-            one.append(",{").append("\"name\":\"国家\"").append(",").append("\"content\":").append("\"").append(splitStr.get(i + 2).trim()).append("\"").append("}");
-            one.append("," + "{" + "\"name\"" + ":" + "\"内容\"" + "," + "\"content\"" + ":" + "\"").append(splitStr.get(i + 1).trim()).append("\"").append("}]");
-
-            if (!one.toString().equals("")) {
-                if (!all.toString().equals("")) {
-                    all.append(",{").append(one).append("}");
-                } else {
-                    all = new StringBuilder("{" + one + "}");
-                }
-            }
-            one = new StringBuilder();
-        }
-
-        all = new StringBuilder("[" + all + "]");
-        return all.toString();
-    }
-}

+ 0 - 24
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatentTypeHandler.java

@@ -1,24 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-/**
- * @name 专利类型处理类
- * @description 1.将传入的专利类型转换成不同的ID 2.目前这个没有用字典项的原因是因为不同数据源的叫法不一致 无法统一进行分类
- */
-public class PatentTypeHandler implements IProcessData {
-    public PatentTypeHandler() {
-    }
-
-    @Override
-    public Object processData(Object data, Object ob) {
-        if (data.toString().contains("实用新型")) {
-            return "2";
-        } else if (data.toString().contains("发明申请") || data.toString().contains("发明公布")) {
-            return "1";
-        } else if (data.toString().contains("外观设计")) {
-            return "3";
-        } else if (data.toString().contains("授权")) {
-            return "4";
-        }
-        return null;
-    }
-}

+ 0 - 23
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatenticsAgencyAndAgentHandler.java

@@ -1,23 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-
-import com.example.xiaoshiweixinback.business.utils.StringUtils;
-
-import java.util.List;
-
-public class PatenticsAgencyAndAgentHandler implements IProcessData {
-    public PatenticsAgencyAndAgentHandler() {
-    }
-
-    @Override
-    public Object processData(Object data, Object code) {
-        List<String> splitStr = StringUtils.changeStringToString(data.toString().replaceAll(" ", ""), ";");
-        if (code.toString().equals("1")) {
-            return splitStr.get(0);
-        } else if (code.toString().equals("2")) {
-            splitStr.remove(0);
-            return splitStr;
-        }
-        return null;
-    }
-}

+ 0 - 73
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatenticsPatentAffairHandler.java

@@ -1,73 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-
-import com.example.xiaoshiweixinback.business.utils.StringUtils;
-
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
-public class PatenticsPatentAffairHandler implements IProcessData {
-    public PatenticsPatentAffairHandler() {
-    }
-
-    @Override
-    public Object processData(Object data, Object code) {
-        List<String> splitStr = StringUtils.changeStringToString(data.toString(), "\n");
-        splitStr.removeIf(item -> item.equals(""));
-
-        List<String> processList = splitStr.stream().map(item -> item.replaceAll(" ", "\\|")).collect(Collectors.toList());
-
-        StringBuilder all = new StringBuilder();
-        StringBuilder one = new StringBuilder();
-        List<String> messageList;
-        Pattern p = Pattern.compile("[\\d]*");
-        int flag1 = 0;
-        for (int j = 0; j < processList.size(); j++) {
-            if (j < processList.size() - 1) {
-                Matcher m = p.matcher(processList.get(j).substring(0, 4));
-                if (m.matches()) {
-                    flag1 = j;
-                }
-                if (!m.matches()) {
-                    String replace = processList.get(j).replaceAll("\\|", " ");
-                    processList.set(flag1, processList.get(flag1) + "<br>" + replace);
-                    processList.set(j, replace);
-                }
-            }
-        }
-
-        for (String s : processList) {
-            messageList = StringUtils.changeStringToString(s, "\\|");
-
-            if (messageList.size() == 4 && messageList.contains("授权")) {
-                messageList.remove(0);
-            } else if (messageList.size() % 3 != 0) {
-                continue;
-            }
-
-            for (int i = 0; i < messageList.size(); i += 3) {
-                if (one.toString().equals("")) {
-                    one = new StringBuilder("\"inpadocData\"" + ":[" + "{" + "\"name\"" + ":" + "\"发生日期\"" + "," + "\"content\"" + ":" + "\"" + messageList.get(i).trim() + "\"" + "}");
-                } else {
-                    one.append("," + "{" + "\"name\"" + ":" + "\"发生日期\"" + "," + "\"content\"" + ":" + "\"").append(messageList.get(i).trim()).append("\"").append("}");
-                }
-                one.append(",{").append("\"name\":\"法律状态\"").append(",").append("\"content\":").append("\"").append(messageList.get(i + 1).trim()).append("\"").append("}");
-                one.append("," + "{" + "\"name\"" + ":" + "\"描述信息\"" + "," + "\"content\"" + ":" + "\"").append(messageList.get(i + 2).trim()).append("\"").append("}]");
-
-                if (!one.toString().equals("")) {
-                    if (!all.toString().equals("")) {
-                        all.append(",{").append(one).append("}");
-                    } else {
-                        all = new StringBuilder("{" + one + "}");
-                    }
-                }
-                one = new StringBuilder();
-            }
-
-        }
-        all = new StringBuilder("[" + all + "]");
-        return all.toString();
-    }
-}

+ 0 - 18
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatenticsStringHandler.java

@@ -1,18 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-
-import com.example.xiaoshiweixinback.business.utils.StringUtils;
-
-public class PatenticsStringHandler implements IProcessData {
-    public PatenticsStringHandler() {
-    }
-
-    @Override
-    public Object processData(Object data, Object splitSymbol) {
-        if (!"".equals(splitSymbol)) {
-            return StringUtils.changeStringToString(data.toString().replaceAll(" ", "").replaceAll("\n", ""), splitSymbol.toString());
-        } else {
-            return data.toString().replaceAll(" ", "");
-        }
-    }
-}

+ 0 - 20
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/SplitBySerialNumberAndRemoveLineFeedHandler.java

@@ -1,20 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-
-
-import com.example.xiaoshiweixinback.business.utils.StringUtils;
-
-import java.util.Arrays;
-import java.util.stream.Collectors;
-
-public class SplitBySerialNumberAndRemoveLineFeedHandler implements IProcessData {
-    public SplitBySerialNumberAndRemoveLineFeedHandler() {
-    }
-
-    @Override
-    public Object processData(Object data, Object splitSymbol) {
-        return Arrays.stream(data.toString().replaceAll("\n", "").split(splitSymbol.toString()))
-                .filter(StringUtils::isNotEmpty)
-                .collect(Collectors.toList());
-    }
-}

+ 0 - 28
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/SplitOriginalAndTranslationHandler.java

@@ -1,28 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-
-import com.example.xiaoshiweixinback.business.utils.StringUtils;
-
-import java.util.List;
-
-/**
- * @name
- * @description
- */
-public class SplitOriginalAndTranslationHandler implements IProcessData {
-    public SplitOriginalAndTranslationHandler() {
-    }
-
-    @Override
-    public Object processData(Object data, Object splitSymbol) {
-        List<String> splitList = StringUtils.changeStringToString(splitSymbol.toString(), ",");
-        if (splitList.get(0).equals("1")) {
-            return StringUtils.changeStringToString(data.toString(), splitList.get(1)).get(0);
-        } else if (splitList.get(0).equals("2")) {
-            if (StringUtils.changeStringToString(data.toString(), splitList.get(1)).size() == 2) {
-                return StringUtils.changeStringToString(data.toString(), splitList.get(1)).get(1);
-            }
-        }
-        return null;
-    }
-}

+ 0 - 22
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/StringHandler.java

@@ -1,22 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-
-import com.example.xiaoshiweixinback.business.utils.StringUtils;
-
-/**
- * @name 一般字符串处理类
- * @description 1.带有分隔符按照分隔符拆分(去除所有空格) 2.不带分隔符直接返回原数据
- */
-public class StringHandler implements IProcessData {
-    public StringHandler() {
-    }
-
-    @Override
-    public Object processData(Object data, Object splitSymbol) {
-        if (!"".equals(splitSymbol)) {
-            return StringUtils.changeStringToString(data.toString().trim(), splitSymbol.toString());
-        } else {
-            return data.toString();
-        }
-    }
-}

+ 0 - 22
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/StringSpecialHandler.java

@@ -1,22 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-
-import com.example.xiaoshiweixinback.business.utils.StringUtils;
-
-/**
- * @name 特殊字符串处理类
- * @description 1.带有分隔符按照分隔符拆分(去除 '>' 符号) 2.不带分隔符直接返回原数据 3.目前只有两个字段会使用 (1)标签(2)自定义字段
- */
-public class StringSpecialHandler implements IProcessData {
-    public StringSpecialHandler() {
-    }
-
-    @Override
-    public Object processData(Object data, Object splitSymbol) {
-        if (!"".equals(splitSymbol)) {
-            return StringUtils.changeStringToString(data.toString().replaceAll(">", ""), splitSymbol.toString());
-        } else {
-            return data.toString();
-        }
-    }
-}

+ 0 - 18
src/main/java/com/example/xiaoshiweixinback/business/utils/handler/TimeHandler.java

@@ -1,18 +0,0 @@
-package com.example.xiaoshiweixinback.business.utils.handler;
-
-
-import com.example.xiaoshiweixinback.business.utils.DateUtils;
-
-/**
- * @name 时间处理类
- * @description 1.将时间类型数据转换为int型 2.现支持格式为 yyyy-MM-dd yyyy/MM/dd 可后需添加
- */
-public class TimeHandler implements IProcessData {
-    public TimeHandler() {
-    }
-
-    @Override
-    public Object processData(Object data, Object splitSymbol) {
-        return DateUtils.getDateTime(data.toString());
-    }
-}

+ 2 - 2
src/main/java/com/example/xiaoshiweixinback/business/utils/parseQueryToTree/expressManager.java

@@ -32,8 +32,8 @@ public class expressManager {
         oOR.Code = "NOT";
         oOR.ShowName = "NOT";
         oOR.type = enuType.Logic;
-        oOR.priorityVale = 12;
-        oOR.operateValue = 1;
+        oOR.priorityVale = 11;
+        oOR.operateValue = 2;
         hSymbols.put(oOR.Code, oOR);
 
         oOR = new operate();

+ 18 - 1
src/main/java/com/example/xiaoshiweixinback/controller/ImportPatentController.java

@@ -7,6 +7,7 @@ import com.example.xiaoshiweixinback.entity.vip.ActiveVipDTO;
 import com.example.xiaoshiweixinback.entity.vip.PersonFunctionVO;
 import com.example.xiaoshiweixinback.entity.weixinPay.FunctionRightVO;
 import com.example.xiaoshiweixinback.service.VipService;
+import com.example.xiaoshiweixinback.service.importPatent.excel.GetOPSFileByExcelService;
 import com.example.xiaoshiweixinback.service.importPatent.excel.GetPatentFromSzService;
 import io.swagger.v3.oas.annotations.Operation;
 import lombok.RequiredArgsConstructor;
@@ -20,7 +21,7 @@ import java.util.List;
 @RestController
 @RequiredArgsConstructor
 public class ImportPatentController {
-    private final VipService vipService;
+    private final GetOPSFileByExcelService getOPSFileByExcelService;
 private final GetPatentFromSzService getPatentFromSzService;
     @Operation(summary = "查询会员")
     @GetMapping("/import")
@@ -35,4 +36,20 @@ private final GetPatentFromSzService getPatentFromSzService;
         getPatentFromSzService.test2(path);
         return Response.success("records");
     }
+
+
+    @Operation(summary = "根据专利号获取图片")
+    @GetMapping("/import3")
+    private Response importPatent3(String path) throws Exception {
+        getOPSFileByExcelService.test(path);
+        return Response.success("records");
+    }
+
+    @Operation(summary = "根据专利号获取图片")
+    @GetMapping("/import4")
+    private Response importPatent4(String path) throws Exception {
+        getPatentFromSzService.test3(path);
+        return Response.success("records");
+    }
+
 }

+ 66 - 0
src/main/java/com/example/xiaoshiweixinback/controller/MonitoringController.java

@@ -0,0 +1,66 @@
+package com.example.xiaoshiweixinback.controller;
+
+import com.example.xiaoshiweixinback.business.common.Constants;
+import com.example.xiaoshiweixinback.business.common.Response;
+import com.example.xiaoshiweixinback.business.common.base.Records;
+import com.example.xiaoshiweixinback.business.exception.BusinessException;
+import com.example.xiaoshiweixinback.domain.MonitorRecord;
+import com.example.xiaoshiweixinback.entity.dto.monitoring.AddMonitoringDTO;
+import com.example.xiaoshiweixinback.entity.dto.monitoring.CancelMonitoringDTO;
+import com.example.xiaoshiweixinback.entity.dto.monitoring.MonitoringIdDTO;
+import com.example.xiaoshiweixinback.entity.dto.monitoring.SelectMonitoringDTO;
+import com.example.xiaoshiweixinback.service.MonitorRecordService;
+import com.example.xiaoshiweixinback.service.MonitorService;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@Slf4j
+@RequestMapping(Constants.XIAOSHI_WEIXINBACK + "/monitoring")
+@RestController
+@RequiredArgsConstructor
+public class MonitoringController {
+
+    private final MonitorService monitorService;
+    private final MonitorRecordService monitorRecordService;
+    @Operation(summary = "添加监控")
+    @PostMapping("/addMonitoring")
+    public Response addMonitoring(@RequestBody AddMonitoringDTO monitoringDTO) {
+        Integer projectId = null;
+        try {
+            projectId = monitorService.addMonitoring(monitoringDTO);
+        } catch (BusinessException e) {
+            return Response.error(e.getErrorCode(), e.getMessage());
+        }
+        return Response.success(projectId);
+    }
+
+    @Operation(summary = "查询监控")
+    @PostMapping("/selectMonitoring")
+    public Response selectMonitoring(@RequestBody SelectMonitoringDTO selectMonitoringDTO) {
+       Records records= monitorService.selectMonitoring(selectMonitoringDTO);
+        return Response.success(records);
+    }
+
+    @Operation(summary = "取消监控")
+    @PostMapping("/cancelMonitoring")
+    public Response cancelMonitoring(@RequestBody CancelMonitoringDTO monitoringDTO) {
+       List<Integer> productIds=  monitorService.cancelMonitoring(monitoringDTO);
+        return Response.success(productIds);
+    }
+
+    @Operation(summary = "查询监控详情记录")
+    @PostMapping("/selectMonitoringRecord")
+    public Response selectMonitoringRecord(@RequestBody MonitoringIdDTO monitoringDTO) {
+        Integer id =monitoringDTO.getId();
+        Records records =  monitorRecordService.getMonitorRecords(id);
+        return Response.success(records);
+    }
+
+}

+ 20 - 0
src/main/java/com/example/xiaoshiweixinback/controller/ProductCategoryController.java

@@ -4,8 +4,10 @@ package com.example.xiaoshiweixinback.controller;
 import com.example.xiaoshiweixinback.business.common.Constants;
 import com.example.xiaoshiweixinback.business.common.Response;
 import com.example.xiaoshiweixinback.business.common.base.Records;
+import com.example.xiaoshiweixinback.business.utils.FileUtils;
 import com.example.xiaoshiweixinback.checkLogin.checkLogin;
 import com.example.xiaoshiweixinback.domain.AssoCategoryFile;
+import com.example.xiaoshiweixinback.domain.ImportTask;
 import com.example.xiaoshiweixinback.entity.dto.ConcernCategoryDTO;
 import com.example.xiaoshiweixinback.entity.dto.ProductCategoryDTO;
 import com.example.xiaoshiweixinback.entity.dto.productCategory.AddCategoryDTO;
@@ -14,7 +16,9 @@ import com.example.xiaoshiweixinback.entity.dto.productCategory.CategoryIdsDTO;
 import com.example.xiaoshiweixinback.entity.dto.productCategory.EditCategoryDTO;
 import com.example.xiaoshiweixinback.entity.vo.productCategory.SelectCategoryVO;
 import com.example.xiaoshiweixinback.service.AssoPersonCategoryService;
+import com.example.xiaoshiweixinback.service.ImportTaskService;
 import com.example.xiaoshiweixinback.service.ProductCategoryService;
+import com.example.xiaoshiweixinback.service.importPatent.excel.ImportProductCategoryService;
 import io.swagger.v3.oas.annotations.Operation;
 import jakarta.validation.Valid;
 import lombok.RequiredArgsConstructor;
@@ -24,7 +28,9 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.File;
 import java.util.List;
 
 @Slf4j
@@ -35,6 +41,8 @@ public class ProductCategoryController {
 
     private final ProductCategoryService productCategoryService;
     private final AssoPersonCategoryService assoPersonCategoryService;
+    private final ImportProductCategoryService importProductCategoryService;
+    private final ImportTaskService importTaskService;
 
     @Operation(summary = "查询产品类别列表")
     @PostMapping("/queryCategory")
@@ -98,4 +106,16 @@ public class ProductCategoryController {
         records.setData("关注成功");
         return Response.success(records);
     }
+
+    @Operation(summary = "导入产品类别")
+    @PostMapping("/importCategory")
+    public Response importProductCategory(@RequestBody MultipartFile file) throws Exception {
+        File newFile=  FileUtils.multipartFileToFile(file);
+        ImportTask importTask =importTaskService.addImportTask(newFile,1);
+        importProductCategoryService.importProductCategory(newFile,importTask);
+        Records records =new Records();
+        records.setData(importTask);
+        return Response.success(records);
+    }
+
 }

+ 55 - 21
src/main/java/com/example/xiaoshiweixinback/controller/ProductController.java

@@ -5,20 +5,26 @@ import com.example.xiaoshiweixinback.business.common.Constants;
 import com.example.xiaoshiweixinback.business.common.Response;
 import com.example.xiaoshiweixinback.business.common.base.Records;
 import com.example.xiaoshiweixinback.business.exception.BusinessException;
+import com.example.xiaoshiweixinback.business.utils.FileUtils;
 import com.example.xiaoshiweixinback.checkLogin.checkLogin;
 import com.example.xiaoshiweixinback.domain.AssoPersonProduct;
+import com.example.xiaoshiweixinback.domain.ImportTask;
 import com.example.xiaoshiweixinback.entity.dto.AssoPersonProductDTO;
-import com.example.xiaoshiweixinback.entity.product.HotProductAddDTO;
-import com.example.xiaoshiweixinback.entity.product.ProductAddDTO;
-import com.example.xiaoshiweixinback.entity.product.ProductDTO;
+import com.example.xiaoshiweixinback.entity.product.*;
 import com.example.xiaoshiweixinback.entity.vo.ProductVO;
 import com.example.xiaoshiweixinback.service.AssoPersonProductService;
+import com.example.xiaoshiweixinback.service.ImportTaskService;
 import com.example.xiaoshiweixinback.service.ProductService;
+import com.example.xiaoshiweixinback.service.importPatent.excel.ImportProductService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.models.security.SecurityScheme;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.util.List;
 
 @Slf4j
 @RequestMapping(Constants.XIAOSHI_WEIXINBACK + "/product")
@@ -27,7 +33,8 @@ import org.springframework.web.bind.annotation.*;
 public class ProductController {
     private final ProductService productService;
     private final AssoPersonProductService assoPersonProductService;
-
+    private final ImportProductService importProductService;
+    private final ImportTaskService importTaskService;
     @Operation(summary = "查询爆款产品")
     @PostMapping("/queryHotProduct")
     public Response queryHotProduct(@RequestBody ProductDTO productDTO) {
@@ -42,24 +49,29 @@ public class ProductController {
         try {
             Integer id = productService.addOrUpdateProduct(productAddDTO);
             records.setData(id);
+        } catch (BusinessException e) {
+            return Response.error(e.getErrorCode(), e.getMessage());
         }
-      catch (BusinessException e){
-            return Response.error(e.getErrorCode(),e.getMessage());
-      }
         return Response.success(records);
     }
 
     @checkLogin
     @Operation(summary = "关注产品")
     @PostMapping("/follow")
-    public Response follow(@RequestBody AssoPersonProductDTO assoPersonProductDTO){
+    public Response follow(@RequestBody AssoPersonProductDTO assoPersonProductDTO) {
         Records records = new Records();
-        Integer id = assoPersonProductService.add(assoPersonProductDTO);
-    if(id ==null){
-        return Response.noPermissions("已超过可关注数量");
-    }
-    if(id.equals(-2)){
-        return Response.noPermissions("无关注产品的权益");
+        Integer id =null;
+        try {
+             id = assoPersonProductService.add(assoPersonProductDTO);
+            if (id == null) {
+                return Response.noPermissions("已超过可关注数量");
+            }
+            if (id.equals(-2)) {
+                return Response.noPermissions("无关注产品的权益");
+            }
+        }
+    catch (BusinessException e){
+            return Response.error(e.getErrorCode(),e.getMessage());
     }
         records.setData(id);
         return Response.success(records);
@@ -68,7 +80,7 @@ public class ProductController {
 
     @Operation(summary = "取消关注产品")
     @GetMapping("/unFollow")
-    public Response unFollow(Integer productId){
+    public Response unFollow(Integer productId) {
         Records records = new Records();
         Integer id = assoPersonProductService.cancel(productId);
         if (id.equals(-1)) {
@@ -93,7 +105,12 @@ public class ProductController {
     @Operation(summary = "添加或更新爆款产品")
     @PostMapping("/addOrUpdateHotProduct")
     public Response addOrUpdateHotProduct(@RequestBody HotProductAddDTO hotProductAddDTO) {
-        Integer id = productService.addOrUpdateHotProduct(hotProductAddDTO);
+        Integer id =null;
+        try {
+             id = productService.addOrUpdateHotProduct(hotProductAddDTO,null);
+        } catch (BusinessException e) {
+            return Response.error(e.getErrorCode(),e.getMessage());
+        }
         return Response.success(id);
     }
 
@@ -102,19 +119,36 @@ public class ProductController {
     @PostMapping("/queryHotProductDetail")
     public Response queryHotProductDetail(Integer id) {
         ProductVO productVO = productService.queryHotProductDetail(id);
-        Records records =new Records();
+        Records records = new Records();
         records.setData(productVO);
         return Response.success(records);
     }
 
 
     @checkLogin
-    @Operation(summary = "查看单个产品详情")
+    @Operation(summary = "上下架产品")
     @PostMapping("/updateProductIfShow")
-    public Response updateProductIfShow(Integer id) {
-        ProductVO productVO = productService.updateProductIfShow(id);
+    public Response updateProductIfShow(@RequestBody UpdateProductShowDTO updateProductShowDTO) {
+        List<Integer> ids = productService.updateProductIfShow(updateProductShowDTO);
+        return Response.success(ids);
+    }
+
+    @checkLogin
+    @Operation(summary = "删除产品")
+    @PostMapping("/deleteHotProduct")
+    public Response deleteHotProduct(@RequestBody HotProductDeleteDTO hotProductDeleteDTO) {
+        List<Integer> ids = productService.deleteHotProduct(hotProductDeleteDTO);
+        return Response.success(ids);
+    }
+
+    @Operation(summary = "导入产品")
+    @PostMapping("/ImportProductBatch")
+    public Response importProduct(@RequestBody MultipartFile file) throws Exception {
+        File newFile=  FileUtils.multipartFileToFile(file);
+        ImportTask importTask =importTaskService.addImportTask(newFile,2);
+        importProductService.importProject(newFile,importTask);
         Records records =new Records();
-        records.setData(productVO);
+        records.setData(importTask);
         return Response.success(records);
     }
 }

+ 40 - 0
src/main/java/com/example/xiaoshiweixinback/controller/TemplateController.java

@@ -0,0 +1,40 @@
+package com.example.xiaoshiweixinback.controller;
+
+import com.example.xiaoshiweixinback.business.common.Constants;
+import com.example.xiaoshiweixinback.business.common.Response;
+import com.example.xiaoshiweixinback.business.common.base.Records;
+import com.example.xiaoshiweixinback.business.utils.FileUtils;
+import com.example.xiaoshiweixinback.entity.dto.TemplateDTO;
+import com.example.xiaoshiweixinback.entity.vo.TemplateVO;
+import com.example.xiaoshiweixinback.service.TemplateService;
+import com.example.xiaoshiweixinback.service.importPatent.excel.GetOPSFileByExcelService;
+import com.example.xiaoshiweixinback.service.importPatent.excel.GetPatentFromSzService;
+import com.example.xiaoshiweixinback.service.importPatent.excel.ImportProductCategoryService;
+import com.example.xiaoshiweixinback.service.importPatent.excel.ImportProductService;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.util.List;
+
+@Slf4j
+@RequestMapping(Constants.XIAOSHI_WEIXINBACK + "/template")
+@RestController
+@RequiredArgsConstructor
+public class TemplateController {
+    private final TemplateService templateService;
+
+    @Operation(summary = "导入产品")
+    @PostMapping("/getTemplate")
+    private Response importProduct(@RequestBody TemplateDTO templateDTO) throws Exception {
+       List<TemplateVO> templateVOList= templateService.getTemplate(templateDTO);
+        Records records =new Records();
+        records.setData(templateVOList);
+        return Response.success(records);
+    }
+
+
+}

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/domain/AssoproductCategory.java

@@ -28,6 +28,6 @@ public class AssoproductCategory extends BaseEntity<AssoproductCategory> {
     /**
      * 
      */
-    private Integer categoryId;
+    private Integer productCategoryId;
 
 }

+ 64 - 0
src/main/java/com/example/xiaoshiweixinback/domain/ImportTask.java

@@ -0,0 +1,64 @@
+package com.example.xiaoshiweixinback.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 导入任务表
+ * @TableName import_task
+ */
+@TableName(value ="import_task")
+@Data
+public class ImportTask extends BaseEntity<ImportTask> {
+    /**
+     * ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 
+     */
+    private Integer allNum;
+
+    /**
+     * 
+     */
+    private Integer startNum;
+
+    /**
+     * 
+     */
+    private Integer endNum;
+
+    /**
+     * 
+     */
+    private Integer importType;
+
+    /**
+     * 
+     */
+    private String fileGuid;
+
+    /**
+     * 
+     */
+    private String taskName;
+
+    /**
+     * 创建人uuid
+     */
+    private String createId;
+
+    /**
+     * 
+     */
+    private Date createTime;
+
+}

+ 39 - 0
src/main/java/com/example/xiaoshiweixinback/domain/Monitor.java

@@ -0,0 +1,39 @@
+package com.example.xiaoshiweixinback.domain;
+
+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 java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * 产品监控表
+ * @TableName monitor
+ */
+@TableName(value ="monitor")
+@Data
+public class Monitor extends BaseEntity<Monitor> {
+
+    /**
+     * 
+     */
+    private Integer productId;
+
+    /**
+     * 
+     */
+    private String monitorPeriod;
+
+    /**
+     * 
+     */
+    private String createId;
+
+    /**
+     * 
+     */
+    private Date createTime;
+
+}

+ 45 - 0
src/main/java/com/example/xiaoshiweixinback/domain/MonitorRecord.java

@@ -0,0 +1,45 @@
+package com.example.xiaoshiweixinback.domain;
+
+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 java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * 监控记录
+ * @TableName monitor_record
+ */
+@TableName(value ="monitor_record")
+@Data
+public class MonitorRecord extends BaseEntity<MonitorRecord> {
+
+    /**
+     * 
+     */
+    private Integer monitorId;
+
+    /**
+     * 
+     */
+    private Date startDate;
+
+    /**
+     * 
+     */
+    private Date endDate;
+
+    /**
+     * 
+     */
+    private Date createTime;
+
+    /**
+     * 
+     */
+    private Integer num;
+    private String searchCondition;
+
+}

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/domain/Product.java

@@ -73,7 +73,7 @@ public class Product extends BaseEntity<Product> {
     /**
      * 
      */
-    private DateTime createTime;
+    private Date createTime;
     private String locNum;
 
 

+ 2 - 1
src/main/java/com/example/xiaoshiweixinback/domain/ProductCategory.java

@@ -60,6 +60,7 @@ public class ProductCategory extends BaseEntity<ProductCategory> {
     /**
      * 
      */
-    private DateTime createTime;
+    @TableField(value = "create_time")
+    private Date createTime;
 
 }

+ 46 - 0
src/main/java/com/example/xiaoshiweixinback/domain/Template.java

@@ -0,0 +1,46 @@
+package com.example.xiaoshiweixinback.domain;
+
+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 lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 模板表
+ * @TableName template
+ */
+@TableName(value ="template")
+@Data
+public class Template implements Serializable {
+    /**
+     * ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 
+     */
+    private String name;
+
+    /**
+     * 
+     */
+    private String fileGuid;
+
+    /**
+     * 
+     */
+    private String createId;
+
+    /**
+     * 
+     */
+    private Date createTime;
+
+   private Integer templateType;
+}

+ 8 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/TemplateDTO.java

@@ -0,0 +1,8 @@
+package com.example.xiaoshiweixinback.entity.dto;
+
+import lombok.Data;
+
+@Data
+public class TemplateDTO {
+    private Integer type;
+}

+ 41 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/monitoring/AddMonitoringDTO.java

@@ -0,0 +1,41 @@
+package com.example.xiaoshiweixinback.entity.dto.monitoring;
+
+import com.example.xiaoshiweixinback.entity.product.ProductAddDTO;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class AddMonitoringDTO {
+
+    //产品id
+    private Integer productId;
+
+    private String name;
+
+    /**
+     *
+     */
+    private String description;
+
+    /**
+     * 检索条件
+     */
+    private String searchCondition;
+
+    /**
+     * 来源
+     */
+    private String sourceFrom;
+
+    /**
+     * 售卖平台
+     */
+    private String sellPlatform;
+
+    private String competitorCom;
+    private String competitorLink;
+    private List<String> fileGuids;
+    private Integer concernType;
+    private String monitorPeriod;
+}

+ 15 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/monitoring/CancelMonitoringDTO.java

@@ -0,0 +1,15 @@
+package com.example.xiaoshiweixinback.entity.dto.monitoring;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class CancelMonitoringDTO {
+
+    //监控ids
+    private List<Integer> productIds;
+
+    //是否取消关注
+    private Boolean ifCancelConcern;
+}

+ 9 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/monitoring/MonitoringIdDTO.java

@@ -0,0 +1,9 @@
+package com.example.xiaoshiweixinback.entity.dto.monitoring;
+
+import lombok.Data;
+
+@Data
+public class MonitoringIdDTO {
+
+    private Integer id;
+}

+ 13 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/monitoring/SelectMonitoringDTO.java

@@ -0,0 +1,13 @@
+package com.example.xiaoshiweixinback.entity.dto.monitoring;
+
+import lombok.Data;
+
+@Data
+public class SelectMonitoringDTO {
+
+    //页码
+    private Long current;
+
+    //页数
+    private Long size;
+}

+ 3 - 0
src/main/java/com/example/xiaoshiweixinback/entity/product/HotProductAddDTO.java

@@ -52,4 +52,7 @@ public class HotProductAddDTO {
     private List<String> fileGuids;
     private Boolean ifShow;
     private Integer productCategoryId;
+    private Boolean ifHot;
+
+
 }

+ 15 - 0
src/main/java/com/example/xiaoshiweixinback/entity/product/HotProductDeleteDTO.java

@@ -0,0 +1,15 @@
+package com.example.xiaoshiweixinback.entity.product;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class HotProductDeleteDTO {
+
+    /**
+     * ID
+     */
+    private List<Integer> ids;
+
+}

+ 26 - 0
src/main/java/com/example/xiaoshiweixinback/entity/product/UploadCategoryParamsVO.java

@@ -0,0 +1,26 @@
+package com.example.xiaoshiweixinback.entity.product;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class UploadCategoryParamsVO {
+    private List<String> categoryList;
+    private Integer id;
+
+    //类别描述
+    private String description;
+
+    //产品类别名称
+    private String name;
+
+    //上级产品类别
+    private Integer parentId;
+
+    //关键词/检索条件
+    private String searchCondition;
+
+    //图s
+    private List<String> fileGuids;
+}

+ 62 - 0
src/main/java/com/example/xiaoshiweixinback/entity/product/UploadProductParamsVO.java

@@ -0,0 +1,62 @@
+package com.example.xiaoshiweixinback.entity.product;
+
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class UploadProductParamsVO {
+    /**
+     * ID
+     */
+    private Integer id;
+
+    /**
+     *
+     */
+    private String name;
+
+    /**
+     *
+     */
+    private String description;
+
+    /**
+     * 检索条件
+     */
+    private String searchCondition;
+
+    /**
+     * 来源
+     */
+    private String sourceFrom;
+
+    /**
+     * 售卖平台
+     */
+    private String sellPlatform;
+
+    /**
+     *
+     */
+    private Boolean ifHot;
+
+    /**
+     * 是否显示(上架)
+     */
+    private Boolean ifShow;
+
+    /**
+     *  是否自定义
+     */
+    private Boolean ifCustomized;
+    private String bestSellingBrand;
+    private Double price;
+    private String platformLink;
+    private String competitorCom;
+    private String competitorLink;
+    private String locNum;
+    private String priceStr;
+    private List<String> categoryList;
+}

+ 80 - 0
src/main/java/com/example/xiaoshiweixinback/entity/quartz/QrtzTaskDTO.java

@@ -0,0 +1,80 @@
+package com.example.xiaoshiweixinback.entity.quartz;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 任务条件表的实体类
+ *
+ * @Author chenyu
+ * @Date 2023/3/27
+ */
+@Accessors(chain = true)
+@Data
+public class QrtzTaskDTO {
+    private Integer id;
+    private Integer projectId;
+
+    private String taskName;
+
+
+    private Integer taskType;
+    /**
+     * 状态(0等待中 1进行中 2成功 3失败 4等待下一次执行 5取消 6暂停)
+     */
+    @TableField(value = "task_state")
+    private Integer taskState;
+    /**
+     * 检索信息
+     */
+    @TableField(value = "conditions")
+    private String conditions;
+    /**
+     * cron表达式
+     */
+    @TableField(value = "crons")
+    private String crons;
+    /**
+     * 下载字段
+     */
+    @TableField(value = "config_cells")
+    private String configCells;
+    /**
+     * 网站id
+     */
+    @TableField(value = "config_id")
+    private Integer configId;
+    /**
+     * 创建人id
+     */
+    @TableField(value = "create_person_id")
+    private Integer createPersonId;
+    /**
+     * 创建人名称
+     */
+    @TableField(value = "create_person_name")
+    private String createName;
+    @TableField(value = "tenant_id")
+    private Integer tenantId;
+    /**
+     * 创建时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @TableField(value = "create_time")
+    private Date createTime;
+    /**
+     * 最后修改时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @TableField(value = "modified_time")
+    private Date modifiedTime;
+
+}

+ 14 - 0
src/main/java/com/example/xiaoshiweixinback/entity/quartz/QuartzVO.java

@@ -0,0 +1,14 @@
+package com.example.xiaoshiweixinback.entity.quartz;
+
+import lombok.Data;
+
+@Data
+public class QuartzVO {
+    /**
+     * 任务名称
+     */
+    private String jobName;
+    private String jobGroupName;
+    private String triggerName;
+    private String triggerGroupName;
+}

+ 3 - 4
src/main/java/com/example/xiaoshiweixinback/entity/vo/ProductCategoryVO.java

@@ -1,12 +1,9 @@
 package com.example.xiaoshiweixinback.entity.vo;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.example.xiaoshiweixinback.business.common.base.SystemFile;
 import com.example.xiaoshiweixinback.entity.vo.productCategory.SelectCategoryLevelVO;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
-import org.joda.time.DateTime;
 
 import java.util.Date;
 import java.util.List;
@@ -23,12 +20,14 @@ public class ProductCategoryVO {
     private String searchCondition;
 
     private String path;
+    //回显路径
+    private String echoPath;
 
     private Integer level;  //层级
 
     private String createName;
 
-    private DateTime createTime;
+    private Date createTime;
 
     private String createId;
 

+ 8 - 1
src/main/java/com/example/xiaoshiweixinback/entity/vo/ProductVO.java

@@ -36,7 +36,6 @@ public class ProductVO {
     private String sellPlatform;
 
 
-
     /**
      *
      */
@@ -54,4 +53,12 @@ public class ProductVO {
     private Integer concernType;
     private Boolean ifHot;
     private Integer assoId;
+    private Integer productCategoryId;
+    private String sourceFrom;
+    private String categoryName;
+    private String categoryPath;
+    private String path;
+    private Boolean ifShow;
+    private String monitorPeriod;
+    private Boolean ifMonitor;
 }

+ 12 - 0
src/main/java/com/example/xiaoshiweixinback/entity/vo/TemplateVO.java

@@ -0,0 +1,12 @@
+package com.example.xiaoshiweixinback.entity.vo;
+
+import lombok.Data;
+
+@Data
+public class TemplateVO {
+
+    private String guid;
+    private String fileName;
+    private String originalName;
+    private Integer type;
+}

+ 13 - 0
src/main/java/com/example/xiaoshiweixinback/entity/vo/esPicture/GetImageVO.java

@@ -0,0 +1,13 @@
+package com.example.xiaoshiweixinback.entity.vo.esPicture;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class GetImageVO {
+
+    private List<Float> imageList;
+
+    private List<String> getGuids;
+}

+ 7 - 0
src/main/java/com/example/xiaoshiweixinback/entity/vo/monitoring/SelectMonitoringRecordVO.java

@@ -0,0 +1,7 @@
+package com.example.xiaoshiweixinback.entity.vo.monitoring;
+
+import lombok.Data;
+
+@Data
+public class SelectMonitoringRecordVO {
+}

+ 7 - 0
src/main/java/com/example/xiaoshiweixinback/entity/vo/monitoring/SelectMonitoringVO.java

@@ -0,0 +1,7 @@
+package com.example.xiaoshiweixinback.entity.vo.monitoring;
+
+import lombok.Data;
+
+@Data
+public class SelectMonitoringVO {
+}

+ 2 - 0
src/main/java/com/example/xiaoshiweixinback/entity/vo/person/LoginVO.java

@@ -21,4 +21,6 @@ public class LoginVO {
     private String token;
 
     private Boolean ifFirst = false;
+
+    private String uuid;
 }

+ 7 - 0
src/main/java/com/example/xiaoshiweixinback/entity/vo/productCategory/SelectCategoryVO.java

@@ -1,5 +1,7 @@
 package com.example.xiaoshiweixinback.entity.vo.productCategory;
 
+import com.example.xiaoshiweixinback.business.common.base.SystemFile;
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import org.joda.time.DateTime;
 
@@ -20,6 +22,8 @@ public class SelectCategoryVO {
     private String searchCondition;   //关键词/检索条件
 
     private String path;   //路径
+    //回显路径
+    private String echoPath;
 
     private Integer level;  //层级
 
@@ -32,4 +36,7 @@ public class SelectCategoryVO {
     private SelectCategoryLevelVO categoryLevelVo;  //父类类别信息
 
     private Boolean ifChild = false;  //是否有子集
+
+    @Schema(description = "文件信息")
+    private List<SystemFile> systemFileList;
 }

+ 35 - 0
src/main/java/com/example/xiaoshiweixinback/entity/websocket/TaskWebSocketDTO.java

@@ -0,0 +1,35 @@
+package com.example.xiaoshiweixinback.entity.websocket;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+public class TaskWebSocketDTO {
+    /**
+     * 专题库id
+     */
+    private Integer projectId;
+    /**
+     * 报告id
+     */
+    private Integer reportId;
+    /**
+     * 产品id
+     */
+    private Integer productId;
+    private Integer total;
+    private Integer index;
+    private Integer taskId;
+    private Integer taskStatus;
+    private Boolean complete;
+    private String url;
+    private String fileName;
+    private Integer taskType;
+    private Long percentage;
+    private String oldName;
+    /**
+     * 0专利信息 1图片
+     */
+    private Integer doneType;
+}

+ 21 - 0
src/main/java/com/example/xiaoshiweixinback/entity/websocket/WebSocketMessageVO.java

@@ -0,0 +1,21 @@
+package com.example.xiaoshiweixinback.entity.websocket;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 拆分保存特征的前端传输DTO类
+ */
+@Data
+@Accessors(chain = true)
+public class WebSocketMessageVO {
+    private Integer projectId;
+    private Integer allNum;
+    private Integer currentNum;
+    private Integer code;
+    private Integer state;
+    private String createId;
+    private Integer taskId;
+    private Integer type;
+    private Boolean ifComplete;
+}

+ 19 - 0
src/main/java/com/example/xiaoshiweixinback/mapper/ImportTaskMapper.java

@@ -0,0 +1,19 @@
+package com.example.xiaoshiweixinback.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.xiaoshiweixinback.domain.ImportTask;
+
+/**
+* @author admin
+* @description 针对表【import_task(导入任务表)】的数据库操作Mapper
+* @createDate 2024-04-27 21:26:06
+* @Entity xiaoshiweixinback.domain.ImportTask
+*/
+public interface ImportTaskMapper extends BaseMapper<ImportTask> {
+
+}
+
+
+
+

+ 18 - 0
src/main/java/com/example/xiaoshiweixinback/mapper/MonitorMapper.java

@@ -0,0 +1,18 @@
+package com.example.xiaoshiweixinback.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.xiaoshiweixinback.domain.Monitor;
+
+/**
+* @author admin
+* @description 针对表【monitor(产品监控表)】的数据库操作Mapper
+* @createDate 2024-04-28 16:29:49
+* @Entity xiaoshiweixinback.domain.Monitor
+*/
+public interface MonitorMapper extends BaseMapper<Monitor> {
+
+}
+
+
+
+

+ 18 - 0
src/main/java/com/example/xiaoshiweixinback/mapper/MonitorRecordMapper.java

@@ -0,0 +1,18 @@
+package com.example.xiaoshiweixinback.mapper;
+
+import com.example.xiaoshiweixinback.domain.MonitorRecord;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author admin
+* @description 针对表【monitor_record(监控记录)】的数据库操作Mapper
+* @createDate 2024-04-28 18:01:54
+* @Entity xiaoshiweixinback.domain.MonitorRecord
+*/
+public interface MonitorRecordMapper extends BaseMapper<MonitorRecord> {
+
+}
+
+
+
+

+ 2 - 1
src/main/java/com/example/xiaoshiweixinback/mapper/ProductMapper.java

@@ -25,7 +25,8 @@ public interface ProductMapper extends BaseMapper<Product> {
     public List<ProductVO> getConcernProduct(@Param("getProductDTO") GetProductDTO getProductDTO);
 
     public Long getConcernProductCount(@Param("getProductDTO") GetProductDTO getProductDTO);
-
+    public List<ProductVO> getMonitoringProduct(@Param("getProductDTO") GetProductDTO getProductDTO);
+    public Long getMonitoringProductCount(@Param("getProductDTO") GetProductDTO getProductDTO);
 }
 
 

+ 18 - 0
src/main/java/com/example/xiaoshiweixinback/mapper/TemplateMapper.java

@@ -0,0 +1,18 @@
+package com.example.xiaoshiweixinback.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.xiaoshiweixinback.domain.Template;
+
+/**
+* @author admin
+* @description 针对表【template(模板表)】的数据库操作Mapper
+* @createDate 2024-04-27 21:28:47
+* @Entity xiaoshiweixinback.domain.Template
+*/
+public interface TemplateMapper extends BaseMapper<Template> {
+
+}
+
+
+
+

+ 34 - 8
src/main/java/com/example/xiaoshiweixinback/service/AssoPersonProductService.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.example.xiaoshiweixinback.business.exception.BusinessException;
+import com.example.xiaoshiweixinback.business.exception.XiaoShiException;
 import com.example.xiaoshiweixinback.business.utils.CacheUtil;
 import com.example.xiaoshiweixinback.business.utils.LoginUtils;
 import com.example.xiaoshiweixinback.business.utils.ToolUtil;
@@ -18,6 +19,8 @@ import lombok.RequiredArgsConstructor;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @author admin
  * @description 针对表【asso_person_product(人员产品关联表)】的数据库操作Service实现
@@ -30,13 +33,18 @@ public class AssoPersonProductService extends ServiceImpl<AssoPersonProductMappe
     private final VipService vipService;
 
     public Integer add(AssoPersonProductDTO assoPersonProductDTO) {
+        Integer productId =assoPersonProductDTO.getProductId();
         PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
-        checkAdmin();
+      AssoPersonProduct assoPersonProduct =  checkAdmin(productId);
+
         if (ToolUtil.isNotEmpty(personnelVO)) {
-            AssoPersonProduct assoPersonProduct = new AssoPersonProduct();
-            BeanUtils.copyProperties(assoPersonProductDTO, assoPersonProduct);
-            assoPersonProduct.setPersonUuid(personnelVO.getUuid());
-            assoPersonProduct.insert();
+            if(assoPersonProduct==null) {
+                 assoPersonProduct = new AssoPersonProduct();
+                BeanUtils.copyProperties(assoPersonProductDTO, assoPersonProduct);
+                assoPersonProduct.setPersonUuid(personnelVO.getUuid());
+                assoPersonProduct.insert();
+            }
+
             return assoPersonProduct.getProductId();
         }
         return -1;
@@ -60,7 +68,8 @@ public class AssoPersonProductService extends ServiceImpl<AssoPersonProductMappe
         return -1;
     }
 
-    public void checkAdmin() {
+    public AssoPersonProduct checkAdmin(Integer productId) {
+       AssoPersonProduct assoPersonProduct =null;
         PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
         AssoPersonFunction assoPersonFunction = vipService.getAssoPersonFunction("6");
         if (assoPersonFunction == null) {
@@ -69,7 +78,13 @@ public class AssoPersonProductService extends ServiceImpl<AssoPersonProductMappe
         Integer totalNum = 5;
         FunctionConfig functionConfig = JSON.parseObject(assoPersonFunction.getFunctionParameter(), FunctionConfig.class);
         totalNum = functionConfig.getCanGetNum();
-
+        LambdaQueryWrapper<AssoPersonProduct> queryWrapper1 =new LambdaQueryWrapper<>();
+        queryWrapper1.eq(AssoPersonProduct::getProductId,productId)
+                .eq(AssoPersonProduct::getPersonUuid,personnelVO.getUuid());
+        AssoPersonProduct org =this.getOne(queryWrapper1,false);
+        if(org!=null){
+            return org;
+        }
         //查看关注的数量
         LambdaQueryWrapper<AssoPersonProduct> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(AssoPersonProduct::getPersonUuid, personnelVO.getUuid());
@@ -79,7 +94,7 @@ public class AssoPersonProductService extends ServiceImpl<AssoPersonProductMappe
             throw new BusinessException("606", "已超过可关注数量");
         }
 
-
+       return assoPersonProduct;
     }
 
     public Integer addAsso(AssoPersonProductDTO assoPersonProductDTO) {
@@ -93,6 +108,17 @@ public class AssoPersonProductService extends ServiceImpl<AssoPersonProductMappe
         }
         return -1;
     }
+
+
+    public List<Integer> cancelConcern(List<Integer> productIds) {
+        PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
+        LambdaQueryWrapper<AssoPersonProduct> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(AssoPersonProduct::getProductId, productIds);
+        queryWrapper.eq(AssoPersonProduct::getPersonUuid, personnelVO.getUuid());
+            this.remove(queryWrapper);
+            return productIds;
+        }
+
 }
 
 

+ 31 - 5
src/main/java/com/example/xiaoshiweixinback/service/AssoproductCategoryService.java

@@ -1,19 +1,45 @@
 package com.example.xiaoshiweixinback.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.xiaoshiweixinback.domain.AssoProductFile;
 import com.example.xiaoshiweixinback.domain.AssoproductCategory;
 import com.example.xiaoshiweixinback.mapper.AssoproductCategoryMapper;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
 
 /**
-* @author admin
-* @description 针对表【asso_ product_category(产品-产品类别关联表)】的数据库操作Service实现
-* @createDate 2024-03-29 15:28:16
-*/
+ * @author admin
+ * @description 针对表【asso_ product_category(产品-产品类别关联表)】的数据库操作Service实现
+ * @createDate 2024-03-29 15:28:16
+ */
 @Service
 public class AssoproductCategoryService extends ServiceImpl<AssoproductCategoryMapper, AssoproductCategory> {
-
+    public void addOrUpdate(Integer productId, Integer productCategoryId) {
+        if (productCategoryId == null) {
+            LambdaQueryWrapper<AssoproductCategory> queryWrapper2 = new LambdaQueryWrapper<>();
+            queryWrapper2.eq(AssoproductCategory::getProductId, productId);
+            this.remove(queryWrapper2);
+            return;
+        }
+        LambdaQueryWrapper<AssoproductCategory> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(AssoproductCategory::getProductId, productId);
+        AssoproductCategory assoproductCategor = this.getOne(queryWrapper, false);
+        if (assoproductCategor == null) {
+            AssoproductCategory assoproductCategory = new AssoproductCategory();
+            assoproductCategory.setProductId(productId);
+            assoproductCategory.setProductCategoryId(productCategoryId);
+            assoproductCategory.insert();
+        } else {
+            assoproductCategor.setProductCategoryId(productCategoryId);
+            assoproductCategor.updateById();
+        }
+        return;
+    }
 }
 
 

+ 65 - 0
src/main/java/com/example/xiaoshiweixinback/service/ImportTaskService.java

@@ -0,0 +1,65 @@
+package com.example.xiaoshiweixinback.service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.xiaoshiweixinback.business.exception.BusinessException;
+import com.example.xiaoshiweixinback.business.utils.CacheUtil;
+import com.example.xiaoshiweixinback.business.utils.LoginUtils;
+import com.example.xiaoshiweixinback.business.utils.ReadExcelUtils;
+import com.example.xiaoshiweixinback.domain.ImportTask;
+import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
+import com.example.xiaoshiweixinback.mapper.ImportTaskMapper;
+import com.example.xiaoshiweixinback.service.common.FileManagerService;
+import lombok.RequiredArgsConstructor;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author admin
+ * @description 针对表【import_task(导入任务表)】的数据库操作Service实现
+ * @createDate 2024-04-27 21:26:06
+ */
+@Service
+@RequiredArgsConstructor
+public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask> {
+    private final CacheUtil cacheUtil;
+    private final FileManagerService fileManagerService;
+
+    public ImportTask addImportTask(File file, Integer type) {
+        PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
+        String[] names = file.getName().split("\\.");
+        Sheet sheet = ReadExcelUtils.readExcel(file);
+        Integer total =0;
+        try {
+             total = ReadExcelUtils.getExcelTotal(sheet);
+        }catch (Exception e ){
+            throw new BusinessException("607","获取文件错误");
+        }
+
+        String name = names[0] + "导入任务";
+        ImportTask importTask = new ImportTask();
+        try {
+            List<String> ids =   fileManagerService.uploadFileGetGuid2(Arrays.asList(file));
+     importTask.setFileGuid(ids.get(0));
+        } catch (Exception e) {
+            throw  new BusinessException("607","上传文件错误");
+        }
+        importTask.setTaskName(name);
+        importTask.setImportType(type);
+        importTask.setCreateId(personnelVO.getUuid());
+        importTask.setAllNum(total);
+        importTask.setStartNum(0);
+        importTask.insert();
+        return importTask;
+
+
+    }
+
+}
+
+
+
+

+ 34 - 0
src/main/java/com/example/xiaoshiweixinback/service/MonitorRecordService.java

@@ -0,0 +1,34 @@
+package com.example.xiaoshiweixinback.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.xiaoshiweixinback.business.common.base.Records;
+import com.example.xiaoshiweixinback.domain.MonitorRecord;
+import com.example.xiaoshiweixinback.mapper.MonitorRecordMapper;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author admin
+ * @description 针对表【monitor_record(监控记录)】的数据库操作Service实现
+ * @createDate 2024-04-28 18:01:54
+ */
+@Service
+public class MonitorRecordService extends ServiceImpl<MonitorRecordMapper, MonitorRecord> {
+
+    public Records getMonitorRecords(Integer monitorId) {
+        LambdaQueryWrapper<MonitorRecord> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(MonitorRecord::getMonitorId, monitorId);
+        Page<MonitorRecord> monitorRecords = this.page(new Page<>(1, 10), queryWrapper);
+        Records records = new Records();
+        records.setData(monitorRecords.getRecords());
+        records.setTotal(monitorRecords.getTotal());
+        return records;
+    }
+}
+
+
+
+

+ 154 - 0
src/main/java/com/example/xiaoshiweixinback/service/MonitorService.java

@@ -0,0 +1,154 @@
+package com.example.xiaoshiweixinback.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.xiaoshiweixinback.business.common.base.Records;
+import com.example.xiaoshiweixinback.business.exception.BusinessException;
+import com.example.xiaoshiweixinback.business.utils.CacheUtil;
+import com.example.xiaoshiweixinback.business.utils.LoginUtils;
+import com.example.xiaoshiweixinback.domain.Monitor;
+
+import com.example.xiaoshiweixinback.entity.dto.AssoPersonProductDTO;
+import com.example.xiaoshiweixinback.entity.dto.GetProductDTO;
+import com.example.xiaoshiweixinback.entity.dto.monitoring.AddMonitoringDTO;
+import com.example.xiaoshiweixinback.entity.dto.monitoring.CancelMonitoringDTO;
+import com.example.xiaoshiweixinback.entity.dto.monitoring.SelectMonitoringDTO;
+import com.example.xiaoshiweixinback.entity.product.ProductAddDTO;
+import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
+import com.example.xiaoshiweixinback.entity.vo.ProductVO;
+import com.example.xiaoshiweixinback.mapper.MonitorMapper;
+import com.example.xiaoshiweixinback.mapper.ProductMapper;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.CachedIntrospectionResults;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * @author admin
+ * @description 针对表【monitor(产品监控表)】的数据库操作Service实现
+ * @createDate 2024-04-28 16:29:49
+ */
+@Service
+@RequiredArgsConstructor
+public class MonitorService extends ServiceImpl<MonitorMapper, Monitor> {
+
+    private final AssoPersonProductService assoPersonProductService;
+    @Lazy
+    @Autowired
+    private  ProductService productService;
+    private final CacheUtil cacheUtil;
+    private final ProductMapper productMapper;
+    /**
+     * 添加监控
+     *
+     * @param addMonitoringDTO
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public Integer addMonitoring(AddMonitoringDTO addMonitoringDTO) {
+        PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
+        Integer productId = addMonitoringDTO.getProductId();
+        String monitorPeriod = addMonitoringDTO.getMonitorPeriod();
+        Integer concernType = addMonitoringDTO.getConcernType();
+
+        //关注产品
+        if (productId != null) {
+            AssoPersonProductDTO assoPersonProductDTO = new AssoPersonProductDTO();
+            assoPersonProductDTO.setProductId(productId);
+            assoPersonProductDTO.setConcernType(concernType);
+            assoPersonProductService.add(assoPersonProductDTO);
+        } else if (productId == null) {
+            ProductAddDTO productAddDTO = new ProductAddDTO();
+            BeanUtils.copyProperties(addMonitoringDTO, productAddDTO);
+            productId = productService.addOrUpdateProduct(productAddDTO);
+        }
+          LambdaQueryWrapper<Monitor> queryWrapper =new LambdaQueryWrapper<>();
+        queryWrapper.eq(Monitor::getCreateId,personnelVO.getUuid())
+                    .eq(Monitor::getProductId,productId);
+        Monitor monitor =this.getOne(queryWrapper,false);
+        if(monitor!=null){
+            return productId;
+        }
+        //添加监控
+         monitor = new Monitor();
+        monitor.setCreateId(personnelVO.getUuid());
+        monitor.setMonitorPeriod(monitorPeriod);
+        monitor.setProductId(productId);
+        monitor.insert();
+        //TODO 添加定时任务
+
+        return productId;
+    }
+
+    /**
+     * 取消监控
+     *
+     * @param cancelMonitoringDTO
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public List<Integer> cancelMonitoring(CancelMonitoringDTO cancelMonitoringDTO) {
+        List<Integer> productIds = cancelMonitoringDTO.getProductIds();
+        Boolean ifCancelConcern = cancelMonitoringDTO.getIfCancelConcern();
+        //取消监控
+        this.cancelMonitorByProductIds(productIds);
+        if (ifCancelConcern != null && ifCancelConcern.equals(true)) {
+            //取消关注
+            assoPersonProductService.cancelConcern(productIds);
+        }
+        //TODO 添加定时任务
+
+        return productIds;
+    }
+
+    private List<Integer> cancelMonitorByProductIds(List<Integer> productIds) {
+        PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
+        LambdaQueryWrapper<Monitor> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(Monitor::getProductId, productIds)
+                .eq(Monitor::getCreateId, personnelVO.getUuid());
+        this.remove(queryWrapper);
+        return productIds;
+
+    }
+
+    /**
+     * 查询监控信息
+     * @param selectMonitoringDTO
+     * @return
+     */
+    public Records selectMonitoring(SelectMonitoringDTO selectMonitoringDTO) {
+        Long current =selectMonitoringDTO.getCurrent();
+        Long size =selectMonitoringDTO.getSize();
+        PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
+        GetProductDTO getProductDTO =new GetProductDTO();
+        getProductDTO.setSize(size);
+        getProductDTO.setCurrent(current);
+        getProductDTO.setPersonUuid(personnelVO.getUuid());
+        List<ProductVO> productVOS = productMapper.getMonitoringProduct(getProductDTO);
+          Long total =productMapper.getMonitoringProductCount(getProductDTO);
+          try {
+              productService.loadProduct(productVOS, false);
+
+          }
+          catch (Exception e){
+              throw new BusinessException("607","装载错误");
+          }
+        Records records =new Records();
+        records.setTotal(total);
+        records.setData(productVOS);
+        records.setSize(size);
+        records.setCurrent(current);
+        return records;
+    }
+
+
+}
+
+
+
+

+ 294 - 46
src/main/java/com/example/xiaoshiweixinback/service/ProductCategoryService.java

@@ -12,6 +12,7 @@ import com.example.xiaoshiweixinback.business.exception.ExceptionEnum;
 import com.example.xiaoshiweixinback.business.utils.BeanUtil;
 import com.example.xiaoshiweixinback.business.utils.CacheUtil;
 import com.example.xiaoshiweixinback.business.utils.LoginUtils;
+import com.example.xiaoshiweixinback.business.utils.ToolUtil;
 import com.example.xiaoshiweixinback.domain.*;
 import com.example.xiaoshiweixinback.entity.dto.ProductCategoryDTO;
 import com.example.xiaoshiweixinback.entity.dto.productCategory.AddCategoryDTO;
@@ -20,13 +21,11 @@ import com.example.xiaoshiweixinback.entity.dto.productCategory.CategoryIdsDTO;
 import com.example.xiaoshiweixinback.entity.dto.productCategory.EditCategoryDTO;
 import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
 import com.example.xiaoshiweixinback.entity.vo.ProductCategoryVO;
-import com.example.xiaoshiweixinback.entity.vo.ProductVO;
 import com.example.xiaoshiweixinback.entity.vo.productCategory.SelectCategoryLevelVO;
 import com.example.xiaoshiweixinback.entity.vo.productCategory.SelectCategoryVO;
 import com.example.xiaoshiweixinback.mapper.AssoCategoryFileMapper;
 import com.example.xiaoshiweixinback.mapper.ProductCategoryMapper;
 import com.example.xiaoshiweixinback.service.common.FileManagerService;
-import io.swagger.v3.oas.models.security.SecurityScheme;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -37,7 +36,9 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -53,6 +54,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
     private final PersonService personService;
     private final FileManagerService fileManagerService;
     private final ProductCategoryMapper productCategoryMapper;
+    private final CacheUtil cacheUtil;
     @Autowired
     private AssoCategoryFileMapper assoCategoryFileMapper;
 
@@ -77,13 +79,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
         if (StringUtils.isNotEmpty(name)) {
             queryWrapper.like(ProductCategory::getName, name);
         }
-
-        if (parentId == null) {
-            queryWrapper.isNull(ProductCategory::getParentId);
-        } else {
-            queryWrapper.eq(ProductCategory::getParentId, parentId);
-        }
-
+        queryWrapper.eq(ProductCategory::getParentId, parentId);
         if (ifConcern != null && ifConcern) {
             //获取关注的
             List<Integer> ids = assoPersonCategoryService.getChoosedProductCategoryIds();
@@ -92,6 +88,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
             }
             queryWrapper.in(ProductCategory::getId, ids);
         }
+        queryWrapper.orderByDesc(ProductCategory::getCreateTime);
 
         List<ProductCategory> productCategoryList = new ArrayList<>();
         if (size != null && current != null) {
@@ -142,7 +139,6 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
                 }
             } catch (Exception e) {
             }
-
         }
 
         //装载登录人信息,装载
@@ -165,7 +161,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
                 }
             }
             //装载父类产品类别
-            if (productCategory.getParentId() != null) {
+            if (productCategory.getParentId() != 0) {
                 ProductCategory parentCategory = this.getById(productCategory.getParentId());
                 SelectCategoryLevelVO levelVO = new SelectCategoryLevelVO();
                 levelVO.setId(parentCategory.getId());
@@ -174,8 +170,19 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
                 levelVO.setLevel(parentCategory.getLevel());
                 productCategoryVO.setCategoryLevelVo(levelVO);
             }
+            //回显路径
+            if (StringUtils.isNotEmpty(productCategory.getPath())) {
+                String echoPath = this.getEchoPath(productCategory.getPath());
+                productCategoryVO.setEchoPath(echoPath);
+            }
             //装载产品图
-            productCategoryVO.setFileGuids(guids);
+            List<AssoCategoryFile> files = assoCategoryFileMapper.selectList(new LambdaQueryWrapper<AssoCategoryFile>()
+                    .eq(AssoCategoryFile::getProductCategoryId, productCategory.getId()));
+            List<String> fileGuids = new ArrayList<>();
+            if (!CollectionUtils.isEmpty(files)) {
+                fileGuids = files.stream().map(AssoCategoryFile::getFileGuid).collect(Collectors.toList());
+            }
+            productCategoryVO.setFileGuids(fileGuids);
             //判断是否有子集
             Long count = productCategoryMapper.selectCount(new LambdaQueryWrapper<ProductCategory>()
                     .eq(ProductCategory::getParentId, productCategory.getId()));
@@ -195,24 +202,40 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
      */
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
     public Integer addCategory(AddCategoryDTO categoryDTO) {
-        Long count = productCategoryMapper.selectCount(new LambdaQueryWrapper<ProductCategory>()
-                .eq(ProductCategory::getName, categoryDTO.getName()));
-        if (count > 0) {
-            throw new BusinessException(ExceptionEnum.THE_PRODUCT_CATEGORY_NAME_IS_EXIST);
-        }
         ProductCategory category = new ProductCategory();
-        category.setName(categoryDTO.getName());
-        category.setDescription(categoryDTO.getDescription());
-        category.setSearchCondition(categoryDTO.getSearchCondition());
-        if (categoryDTO.getParentId() != null) {
+        if (categoryDTO.getParentId() != null && categoryDTO.getParentId() != 0) {
             category.setParentId(categoryDTO.getParentId());
             ProductCategory parentCategory = this.getById(categoryDTO.getParentId());
             Integer level = parentCategory.getLevel();
+            if (level == null) {
+                parentCategory.setLevel(1);
+                parentCategory.updateById();
+                level = parentCategory.getLevel();
+            }
             category.setLevel(level + 1);
-            category.setPath(this.getPath(level));
+            if (parentCategory.getParentId() != 0) {
+                category.setPath(this.getPath(parentCategory.getParentId()) + "/" + parentCategory.getId() + "/");
+            } else {
+                category.setPath(parentCategory.getId() + "/");
+            }
         } else {
+            category.setParentId(0);
             category.setLevel(1);
         }
+        Long count = productCategoryMapper.selectCount(new LambdaQueryWrapper<ProductCategory>()
+                .eq(ProductCategory::getName, categoryDTO.getName())
+                .eq(ProductCategory::getLevel, category.getLevel()));
+        if (count > 0) {
+            throw new BusinessException(ExceptionEnum.THE_PRODUCT_CATEGORY_NAME_IS_EXIST);
+        }
+        category.setName(categoryDTO.getName());
+        category.setDescription(categoryDTO.getDescription());
+        category.setSearchCondition(categoryDTO.getSearchCondition());
+        PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
+        if (ToolUtil.isEmpty(personnelVO)) {
+            throw new BusinessException(ExceptionEnum.THE_LOG_INVALID_NEED_LOGIN_AGAIN);
+        }
+        category.setCreateId(personnelVO.getId().toString());
         category.insert();
         Integer categoryId = category.getId();
         if (!CollectionUtils.isEmpty(categoryDTO.getFileGuids())) {
@@ -234,28 +257,41 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
      */
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
     public Integer editCategory(EditCategoryDTO categoryDTO) {
-        Long count = productCategoryMapper.selectCount(new LambdaQueryWrapper<ProductCategory>()
-                .eq(ProductCategory::getName, categoryDTO.getName()));
-        if (count > 0) {
-            throw new BusinessException(ExceptionEnum.THE_PRODUCT_CATEGORY_NAME_IS_EXIST);
-        }
         Integer categoryId = categoryDTO.getId();
         ProductCategory category = this.getById(categoryId);
-        if (StringUtils.isNotEmpty(categoryDTO.getName())) {
-            category.setName(categoryDTO.getName());
-        }
-        if (StringUtils.isNotEmpty(categoryDTO.getDescription())) {
-            category.setDescription(categoryDTO.getDescription());
-        }
-        if (StringUtils.isNotEmpty(categoryDTO.getSearchCondition())) {
-            category.setSearchCondition(categoryDTO.getSearchCondition());
-        }
-        if (categoryDTO.getParentId() != null) {
+        category.setName(categoryDTO.getName());
+        category.setDescription(categoryDTO.getDescription());
+        category.setSearchCondition(categoryDTO.getSearchCondition());
+        if (categoryDTO.getParentId() != null && categoryDTO.getParentId() != 0) {
             category.setParentId(categoryDTO.getParentId());
             ProductCategory parentCategory = this.getById(categoryDTO.getParentId());
             Integer level = parentCategory.getLevel();
+            if (level == null) {
+                parentCategory.setLevel(1);
+                parentCategory.updateById();
+                level = parentCategory.getLevel();
+            }
             category.setLevel(level + 1);
-            category.setPath(this.getPath(level));
+            if (parentCategory.getParentId() != 0) {
+                category.setPath(this.getPath(parentCategory.getParentId()) + "/" + parentCategory.getId() + "/");
+            } else {
+                category.setPath(parentCategory.getId() + "/");
+            }
+            this.getParentPath(category.getId(), category.getPath(), category.getLevel());
+        } else {
+            Integer parentId = category.getParentId();
+            Integer level = category.getLevel();
+            category.setParentId(0);
+            category.setLevel(level - 1);
+            category.setPath(null);
+            this.getChildPath(category.getId(), parentId, level);
+        }
+        Long count = productCategoryMapper.selectCount(new LambdaQueryWrapper<ProductCategory>()
+                .ne(ProductCategory::getId, categoryDTO.getId())
+                .eq(ProductCategory::getLevel, category.getLevel())
+                .eq(ProductCategory::getName, categoryDTO.getName()));
+        if (count > 0) {
+            throw new BusinessException(ExceptionEnum.THE_PRODUCT_CATEGORY_NAME_IS_EXIST);
         }
         category.updateById();
 
@@ -290,7 +326,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
         BeanUtil.copy(category, categoryVO);
         //获取父类产品类别
         Integer parentId = category.getParentId();
-        if (parentId != null) {
+        if (parentId != 0) {
             ProductCategory parentCategory = this.getById(parentId);
             SelectCategoryLevelVO levelVO = new SelectCategoryLevelVO();
             levelVO.setId(parentCategory.getId());
@@ -299,6 +335,11 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
             levelVO.setLevel(parentCategory.getLevel());
             categoryVO.setCategoryLevelVo(levelVO);
         }
+        //回显路径
+        if (StringUtils.isNotEmpty(category.getPath())) {
+            String echoPath = this.getEchoPath(category.getPath());
+            categoryVO.setEchoPath(echoPath);
+        }
         //获取guids
         List<AssoCategoryFile> assoCategoryFiles = assoCategoryFileMapper.selectList(new LambdaQueryWrapper<AssoCategoryFile>()
                 .eq(AssoCategoryFile::getProductCategoryId, categoryId));
@@ -307,6 +348,29 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
             fileGuids = assoCategoryFiles.stream().map(AssoCategoryFile::getFileGuid).collect(Collectors.toList());
         }
         categoryVO.setFileGuids(fileGuids);
+        //查询文件
+        List<SystemFile> systemFiles = new ArrayList<>();
+        if (fileGuids.size() != 0) {
+            try {
+                String res = fileManagerService.getSystemFileFromFMS(fileGuids);
+                systemFiles = JSONObject.parseArray(res, SystemFile.class);
+                if (systemFiles == null) {
+                    systemFiles = new ArrayList<>();
+                }
+            } catch (Exception e) {
+            }
+        }
+        //装载文件信息
+        List<AssoCategoryFile> assoCategoryFilesTemp = assoCategoryFiles.stream().filter(item -> item.getProductCategoryId().equals(category.getId())).collect(Collectors.toList());
+        if (assoCategoryFilesTemp.size() != 0) {
+            List<String> guidTemp = assoCategoryFilesTemp.stream().map(AssoCategoryFile::getFileGuid).collect(Collectors.toList());
+            if (guidTemp.size() != 0) {
+                List<SystemFile> systemFileTemp = systemFiles.stream().filter(item -> guidTemp.contains(item.getGuid())).collect(Collectors.toList());
+                if (systemFileTemp.size() != 0) {
+                    categoryVO.setSystemFileList(systemFileTemp);
+                }
+            }
+        }
         //判断是否有子集
         Long count = productCategoryMapper.selectCount(new LambdaQueryWrapper<ProductCategory>()
                 .eq(ProductCategory::getParentId, categoryId));
@@ -324,10 +388,12 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
      */
     public boolean deleteCategory(CategoryIdsDTO categoryIdsDTO) {
         List<Integer> ids = categoryIdsDTO.getIds();
+        List<Integer> list = new ArrayList<>();
         for (Integer id : ids) {
             List<Integer> productCategoryIds = this.getProductCategoryIds(id);
-            ids.addAll(productCategoryIds);
+            list.addAll(productCategoryIds);
         }
+        ids.addAll(list);
         List<AssoCategoryFile> assoCategoryFiles = assoCategoryFileMapper.selectList(new LambdaQueryWrapper<AssoCategoryFile>()
                 .in(AssoCategoryFile::getProductCategoryId, ids));
         if (!CollectionUtils.isEmpty(assoCategoryFiles)) {
@@ -352,23 +418,205 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
         return list;
     }
 
+//    public void getParentPath(Integer id, String path, Integer level) {
+//        List<ProductCategory> categories = productCategoryMapper.selectList(new LambdaQueryWrapper<ProductCategory>()
+//                .eq(ProductCategory::getParentId, id));
+//        if (ToolUtil.isNotEmpty(categories)) {
+//            for (ProductCategory category : categories) {
+//                ProductCategory productCategory = productCategoryMapper.selectById(category.getId());
+//                String productCategoryPath = productCategory.getPath();
+//                if (StringUtils.isNotEmpty(productCategoryPath)) {
+//                    productCategory.setPath(path + productCategoryPath);
+//                } else {
+//                    productCategory.setPath(path);
+//                }
+//                productCategory.setLevel(level + 1);
+//                productCategory.updateById();
+//                //循环
+//                this.getParentPath(productCategory.getId(), productCategory.getPath(), productCategory.getLevel());
+//            }
+//        }
+//    }
+
     /**
-     * 获取路径
+     * 修改产品类别高层级变低层级
      *
+     * @param id
+     * @param path
      * @param level
+     */
+    public void getParentPath(Integer id, String path, Integer level) {
+        LambdaQueryWrapper<ProductCategory> wrapper = new LambdaQueryWrapper<>();
+        if (level > 2) {
+            wrapper.like(ProductCategory::getPath, "/" + id + "/");
+        } else {
+            wrapper.likeRight(ToolUtil.isNotEmpty(id), ProductCategory::getPath, id + "/");
+        }
+        List<ProductCategory> categories = productCategoryMapper.selectList(wrapper);
+        if (ToolUtil.isNotEmpty(categories)) {
+            for (ProductCategory category : categories) {
+                ProductCategory productCategory = productCategoryMapper.selectById(category.getId());
+                String productCategoryPath = productCategory.getPath();
+                if (StringUtils.isNotEmpty(productCategoryPath)) {
+                    productCategory.setPath(path + productCategoryPath);
+                } else {
+                    productCategory.setPath(path);
+                }
+                productCategory.setLevel(productCategory.getLevel() + 1);
+                productCategory.updateById();
+            }
+        }
+    }
+
+    /**
+     * 修改产品类别低层级变高层级
+     *
+     * @param id
+     * @param parentId
+     * @param level
+     */
+    public void getChildPath(Integer id, Integer parentId, Integer level) {
+        LambdaQueryWrapper<ProductCategory> wrapper = new LambdaQueryWrapper<>();
+        if (level >= 2) {
+            wrapper.like(ProductCategory::getPath, "/" + id + "/");
+        } else {
+            wrapper.likeRight(ToolUtil.isNotEmpty(id), ProductCategory::getPath, id + "/");
+        }
+        List<ProductCategory> categories = productCategoryMapper.selectList(wrapper);
+        for (ProductCategory category : categories) {
+            ProductCategory productCategory = productCategoryMapper.selectById(category.getId());
+            String categoryPath = productCategory.getPath();
+            Integer categoryLevel = productCategory.getLevel();
+            productCategory.setPath(categoryPath.replace(parentId + "/", ""));
+            productCategory.setLevel(categoryLevel - 1);
+            productCategory.updateById();
+        }
+    }
+
+    /**
+     * 获取路径
+     *
+     * @param parentId
      * @return
      */
-    public String getPath(Integer level) {
+    public String getPath(Integer parentId) {
         String s = "";
-        for (int i = 1; i < level; i++) {
-            if (i != level - 1) {
-                s = s + i + "/";
+        ProductCategory parentCategory = this.getById(parentId);
+        if (ToolUtil.isNotEmpty(parentCategory)) {
+            if (parentCategory.getParentId() != 0) {
+                String pathId = this.getPath(parentCategory.getParentId());
+                s = s + "/" + pathId;
             } else {
-                s = s + i;
+                s = parentCategory.getId().toString();
             }
         }
         return s;
     }
+
+    /**
+     * 获取回显路径
+     *
+     * @param path
+     * @return
+     */
+    public String getEchoPath(String path) {
+        String str = "";
+        String[] split = path.split("/");
+        for (int i = 0; i < split.length; i++) {
+            String s = split[i];
+            ProductCategory category = productCategoryMapper.selectById(Integer.valueOf(s));
+            if (i != split.length - 1) {
+                str = str + category.getName() + "/";
+            } else {
+                str = str + category.getName() + "/";
+            }
+        }
+        return str;
+    }
+
+
+    /**
+     * 查询产品类别
+     *
+     * @param ids
+     * @param ifContentPath
+     * @return
+     */
+    public List<ProductCategory> getProductCategory(List<Integer> ids, Boolean ifContentPath) {
+        if (ids == null || ids.size() == 0) {
+            return new ArrayList<>();
+        }
+
+        LambdaQueryWrapper<ProductCategory> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(ProductCategory::getId, ids);
+        List<ProductCategory> productCategories = this.list(queryWrapper);
+
+        if (ifContentPath) {
+            List<String> paths = productCategories.stream().map(ProductCategory::getPath).collect(Collectors.toList());
+            List<Integer> trueIds = productCategories.stream().map(ProductCategory::getId).collect(Collectors.toList());
+            Set<Integer> set = new HashSet<>();
+            set.addAll(trueIds);
+            paths.forEach(item -> {
+                if (item != null) {
+                    String[] arr = item.split("/");
+                    for (int i = 0; i > arr.length; i++) {
+                        set.add(Integer.parseInt(arr[i]));
+                    }
+                }
+            });
+
+            if (set.size() != 0) {
+                LambdaQueryWrapper<ProductCategory> queryWrapper1 = new LambdaQueryWrapper<>();
+                queryWrapper1.in(ProductCategory::getId, ids);
+                productCategories = this.list(queryWrapper1);
+            }
+        }
+
+        return productCategories;
+    }
+
+
+    public ProductCategory addCategorysByStr(List<String> categorys) {
+
+        if(categorys==null||categorys.size()==0){
+            return  null;
+        }
+        Integer parentId = 0;
+        ProductCategory last = null;
+        for (int i = 0; i < categorys.size(); i++) {
+            Integer level = i + 1;
+            //根据 层级和名称查询
+            LambdaQueryWrapper<ProductCategory> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(ProductCategory::getName, categorys.get(i))
+                    .eq(ProductCategory::getLevel, level)
+                    .eq(ProductCategory::getParentId, parentId);
+            ProductCategory productCategory = this.getOne(queryWrapper, false);
+
+            if (productCategory == null) {
+                productCategory = new ProductCategory();
+                productCategory.setLevel(level);
+                productCategory.setName(categorys.get(i));
+
+                if (last != null) {
+                    if (last.getPath() != null) {
+                        productCategory.setPath(last.getPath() + last.getId() + "/");
+                    } else {
+                        productCategory.setPath(last.getId() + "/");
+                    }
+                    productCategory.setParentId(parentId);
+                }
+                else {
+                    productCategory.setParentId(0);
+                }
+                productCategory.insert();
+
+            }
+            last = productCategory;
+            parentId =last.getId();
+        }
+        return last;
+
+    }
 }
 
 

+ 185 - 46
src/main/java/com/example/xiaoshiweixinback/service/ProductService.java

@@ -9,25 +9,26 @@ import com.example.xiaoshiweixinback.business.common.base.SystemFile;
 import com.example.xiaoshiweixinback.business.exception.BusinessException;
 import com.example.xiaoshiweixinback.business.utils.CacheUtil;
 import com.example.xiaoshiweixinback.business.utils.LoginUtils;
-import com.example.xiaoshiweixinback.domain.AssoPersonFunction;
-import com.example.xiaoshiweixinback.domain.AssoPersonProduct;
-import com.example.xiaoshiweixinback.domain.AssoProductFile;
-import com.example.xiaoshiweixinback.domain.Product;
+import com.example.xiaoshiweixinback.business.utils.StringUtils;
+import com.example.xiaoshiweixinback.domain.*;
 import com.example.xiaoshiweixinback.entity.dto.AssoPersonProductDTO;
 import com.example.xiaoshiweixinback.entity.dto.GetProductDTO;
-import com.example.xiaoshiweixinback.entity.product.HotProductAddDTO;
-import com.example.xiaoshiweixinback.entity.product.ProductAddDTO;
-import com.example.xiaoshiweixinback.entity.product.ProductDTO;
+import com.example.xiaoshiweixinback.entity.product.*;
 import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
 import com.example.xiaoshiweixinback.entity.vo.ProductVO;
 import com.example.xiaoshiweixinback.mapper.ProductMapper;
 import com.example.xiaoshiweixinback.service.common.FileManagerService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.File;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -45,7 +46,11 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
     private final AssoProductFileService assoProductFileService;
     private final FileManagerService fileManagerService;
     private final AssoPersonProductService assoPersonProductService;
-    private final VipService vipService;
+    private final ProductCategoryService productCategoryService;
+    private final AssoproductCategoryService assoproductCategoryService;
+    @Lazy
+    @Autowired
+    private final MonitorService monitorService;
 
     /**
      * 查询爆款产品
@@ -62,27 +67,38 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
         records.setData(new ArrayList<>());
         records.setTotal(0L);
         String name = productDTO.getName();
+        PersonnelVO personnelVO = null;
+        try {
+            if (LoginUtils.getToken() != null) {
+                personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
+            }
+        } catch (Exception e) {
 
+        }
         //查询登录人关联的产品类别id
         List<Integer> ids = assoPersonCategoryService.getChoosedProductCategoryIds();
 
         GetProductDTO getProductDTO = new GetProductDTO();
-        BeanUtils.copyProperties(productDTO,getProductDTO);
+        BeanUtils.copyProperties(productDTO, getProductDTO);
         getProductDTO.setName(name);
         getProductDTO.setCurrent(current);
         getProductDTO.setSize(size);
         getProductDTO.setCategoryIds(ids);
+        if (personnelVO != null && !personnelVO.getPersonType().equals(0)) {
+            getProductDTO.setIfShow(true);
+        }
         if (ids != null) {
             List<ProductVO> productVOs = this.getBaseMapper().getProductByCategory(getProductDTO);
             Long count = this.getBaseMapper().getProductCount(getProductDTO);
-            this.loadProduct(productVOs);
+            this.loadProduct(productVOs, false);
             records.setData(productVOs);
             records.setTotal(count);
         }
         return records;
     }
 
-    private void loadProduct(List<ProductVO> productVOS) {
+
+    public void loadProduct(List<ProductVO> productVOS, Boolean ifCotentCategoryPath) {
         PersonnelVO personnelVO = null;
         try {
             personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
@@ -102,7 +118,9 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
             return;
         }
         List<Integer> ids = productVOS.stream().map(ProductVO::getId).collect(Collectors.toList());
+        List<Integer> projectCategoryIds = productVOS.stream().map(ProductVO::getProductCategoryId).collect(Collectors.toList());
         List<SystemFile> systemFiles = new ArrayList<>();
+        List<Monitor> monitors = new ArrayList<>();
         if (ids.size() != 0) {
             //根据产品类别id获得产品类别与文件关联表
             LambdaQueryWrapper<AssoProductFile> queryWrapper = new LambdaQueryWrapper<>();
@@ -110,6 +128,13 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
             assoProductFiles = assoProductFileService.list(queryWrapper);
             guids = assoProductFiles.stream().map(AssoProductFile::getFileGuid).collect(Collectors.toList());
 
+            //
+            if (personnelVO != null) {
+                LambdaQueryWrapper<Monitor> monitorLambdaQueryWrapper = new LambdaQueryWrapper<>();
+                monitorLambdaQueryWrapper.in(Monitor::getProductId, ids)
+                        .eq(Monitor::getCreateId, personnelVO.getUuid());
+                monitors = monitorService.list(monitorLambdaQueryWrapper);
+            }
         }
 
         //查询文件
@@ -124,6 +149,11 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
             }
 
         }
+        List<ProductCategory> productCategories = new ArrayList<>();
+        if (projectCategoryIds.size() != 0) {
+            productCategories = productCategoryService.getProductCategory(projectCategoryIds, ifCotentCategoryPath);
+
+        }
 
         for (ProductVO productVO : productVOS) {
 //装载文件信息
@@ -138,45 +168,85 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
                 }
             }
 
+            //装载关注类型
             if (assoPersonProducts.size() != 0) {
                 AssoPersonProduct assoPersonProduct = assoPersonProducts.stream().filter(item -> item.getProductId().equals(productVO.getId())).findFirst().orElse(null);
                 if (assoPersonProduct != null) {
                     productVO.setConcernType(assoPersonProduct.getConcernType());
                 }
             }
+
+            //装载产品类别
+            if (productVO.getProductCategoryId() != null && productCategories.size() > 0) {
+                ProductCategory productCategory = productCategories.stream().filter(item -> item.getId().equals(productVO.getProductCategoryId())).findFirst().orElse(null);
+
+                if (productCategory != null) {
+                    productVO.setCategoryName(productCategory.getName());
+                    productVO.setPath(productCategory.getPath());
+                    if (ifCotentCategoryPath == true) {
+                        String path = productCategory.getPath();
+                        if (path != null) {
+                            String[] cIdArrs = path.split("/");
+                            List<String> names = new ArrayList<>();
+                            for (int i = 0; i < cIdArrs.length; i++) {
+                                Integer cId = Integer.parseInt(cIdArrs[i]);
+                                ProductCategory temCategory = productCategories.stream().filter(item -> item.getId().equals(cId)).findFirst().orElse(null);
+                                if (temCategory != null) {
+                                    names.add(temCategory.getName());
+                                }
+                            }
+                            String pathName = StringUtils.join(names, "/");
+                            productVO.setCategoryPath(pathName);
+                        }
+                    }
+                }
+            }
+            //装载是否被监控
+            if (monitors.size() > 0) {
+                Monitor monitor = monitors.stream().filter(item -> item.getProductId().equals(productVO.getId())).findFirst().orElse(null);
+                if (monitor != null) {
+                    productVO.setIfMonitor(true);
+                } else {
+                    productVO.setIfMonitor(false);
+                }
+            }
         }
     }
 
+
     @Transactional(rollbackFor = Exception.class)
     public Integer addOrUpdateProduct(ProductAddDTO productAddDTO) {
         Product product = new Product();
         if (productAddDTO.getId() == null) {
-            assoPersonProductService.checkAdmin();
-            product = this.addProduct(productAddDTO);
+            product = this.addProduct(productAddDTO, null);
             AssoPersonProductDTO assoPersonProductDTO = new AssoPersonProductDTO();
             assoPersonProductDTO.setProductId(product.getId());
             assoPersonProductDTO.setConcernType(productAddDTO.getConcernType());
             Integer flag = assoPersonProductService.addAsso(assoPersonProductDTO);
         } else {
-            product = this.updateProduct(productAddDTO,productAddDTO.getId());
+            product = this.updateProduct(productAddDTO, productAddDTO.getId());
         }
         assoProductFileService.addOrUpdateProductFile(product.getId(), productAddDTO.getFileGuids());
         return product.getId();
     }
 
     @Transactional(rollbackFor = Exception.class)
-    public Product addProduct(Object productAddDTO) {
+    public Product addProduct(Object productAddDTO, String createUuid) {
         Product product = new Product();
         BeanUtils.copyProperties(productAddDTO, product);
-        PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
-        product.setCreateId(personnelVO.getUuid());
+        if (createUuid == null) {
+            PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
+            product.setCreateId(personnelVO.getUuid());
+        } else {
+            product.setCreateId(createUuid);
+        }
         product.setIfCustomized(true);
         product.insert();
         return product;
     }
 
     @Transactional(rollbackFor = Exception.class)
-    public Product updateProduct(Object productAddDTO,Integer id) {
+    public Product updateProduct(Object productAddDTO, Integer id) {
         Product product = new Product();
         Product orgProduct = this.getById(id);
         BeanUtils.copyProperties(productAddDTO, product);
@@ -215,67 +285,136 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
         getProductDTO.setConcernTypes(productDTO.getConcernTypes());
         List<ProductVO> productVOs = this.getBaseMapper().getConcernProduct(getProductDTO);
         Long count = this.getBaseMapper().getConcernProductCount(getProductDTO);
-        this.loadProduct(productVOs);
+        this.loadProduct(productVOs, false);
         records.setData(productVOs);
         records.setTotal(count);
         return records;
     }
 
 
-
     @Transactional(rollbackFor = Exception.class)
-    public Integer addOrUpdateHotProduct(HotProductAddDTO hotProductAddDTO) {
+    public Integer addOrUpdateHotProduct(HotProductAddDTO hotProductAddDTO, String createId) {
         Product product = new Product();
+        String name = hotProductAddDTO.getName();
+        Integer categoryId = hotProductAddDTO.getProductCategoryId();
+        if (name == null) {
+            throw new BusinessException("608", "产品名称不可为空");
+        }
+        LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(Product::getName, name)
+                .eq(Product::getIfHot, true);
+        if (hotProductAddDTO.getId() != null) {
+            queryWrapper.ne(Product::getId, hotProductAddDTO.getId());
+        }
+        Product orgProject = this.getOne(queryWrapper, false);
+        if (orgProject != null) {
+            throw new BusinessException("607", "产品名称不可重复");
+        }
+
         if (hotProductAddDTO.getId() == null) {
-            assoPersonProductService.checkAdmin();
-            product = this.addProduct(hotProductAddDTO);
+            hotProductAddDTO.setIfHot(true);
+            product = this.addProduct(hotProductAddDTO, createId);
         } else {
-            product = this.updateProduct(hotProductAddDTO,hotProductAddDTO.getId());
+            product = this.updateProduct(hotProductAddDTO, hotProductAddDTO.getId());
         }
         assoProductFileService.addOrUpdateProductFile(product.getId(), hotProductAddDTO.getFileGuids());
+
+        assoproductCategoryService.addOrUpdate(product.getId(), categoryId);
         return product.getId();
     }
 
 
-
     /**
-     * 根据id查询爆款专利
+     * 查询产品详情
      *
-     * @param id
+     * @param
      * @return
      */
     public ProductVO queryHotProductDetail(Integer id) {
-        ProductVO productVO =new ProductVO();
-        Product product =this.getById(id);
-        if(product ==null){
-            return  productVO;
+        ProductVO productVO = new ProductVO();
+        Product product = this.getById(id);
+        if (product == null) {
+            return productVO;
         }
-        BeanUtils.copyProperties(product,productVO);
-        List<ProductVO> productVOS =new ArrayList<>();
+        BeanUtils.copyProperties(product, productVO);
+
+        //查询相关产品类别id
+        LambdaQueryWrapper<AssoproductCategory> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(AssoproductCategory::getProductId, product.getId());
+        AssoproductCategory assoproductCategory = assoproductCategoryService.getOne(queryWrapper, false);
+        if (assoproductCategory != null) {
+            productVO.setProductCategoryId(assoproductCategory.getProductCategoryId());
+        }
+        List<ProductVO> productVOS = new ArrayList<>();
         productVOS.add(productVO);
-        this.loadProduct(productVOS);
+        this.loadProduct(productVOS, true);
         return productVO;
     }
 
 
     /**
-     * 根据id查询爆款专利
+     * 上下架产品
      *
-     * @param id
+     * @param updateProductShowDTO
      * @return
      */
-    public ProductVO updateProductIfShow(Integer id) {
-        ProductVO productVO =new ProductVO();
-        Product product =this.getById(id);
-        if(product ==null){
-            return  productVO;
+    public List<Integer> updateProductIfShow(UpdateProductShowDTO updateProductShowDTO) {
+        List<Integer> ids = updateProductShowDTO.getIds();
+        Boolean ifShow = updateProductShowDTO.getIfShow();
+        if (ids == null || ids.size() == 0) {
+            return ids;
         }
-        BeanUtils.copyProperties(product,productVO);
-        List<ProductVO> productVOS =new ArrayList<>();
-        productVOS.add(productVO);
-        this.loadProduct(productVOS);
-        return productVO;
+        LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(Product::getId, ids);
+        List<Product> products = this.list(queryWrapper);
+        if (products.size() != 0) {
+            products.forEach(item -> item.setIfShow(ifShow));
+            this.updateBatchById(products);
+        }
+        return ids;
+    }
+
+
+    /**
+     * 批量删除产品
+     *
+     * @param hotProductDeleteDTO
+     * @return
+     */
+    public List<Integer> deleteHotProduct(HotProductDeleteDTO hotProductDeleteDTO) {
+        List<Integer> ids = hotProductDeleteDTO.getIds();
+        if (ids == null || ids.size() == 0) {
+            return ids;
+        }
+        this.removeBatchByIds(ids);
+        return ids;
+    }
+
+
+    public void ImportProduct(MultipartFile multipartFile) {
+        String guid = "";
+
+        //上传文件
+        try {
+            List<String> guids = fileManagerService.uploadFileGetGuid(Arrays.asList(multipartFile));
+            if (guids == null | guids.size() == 0) {
+                throw new BusinessException("607", "上传文件错误");
+            }
+            guid = guids.get(0);
+        } catch (Exception e) {
+            throw new BusinessException("607", "上传文件错误");
+        }
+
+        //创建导入产品任务
+
+
+        //导入产品
+
+
+        //发送消息
+
     }
+
 }
 
 

+ 41 - 0
src/main/java/com/example/xiaoshiweixinback/service/TemplateService.java

@@ -0,0 +1,41 @@
+package com.example.xiaoshiweixinback.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.xiaoshiweixinback.domain.Template;
+import com.example.xiaoshiweixinback.entity.dto.TemplateDTO;
+import com.example.xiaoshiweixinback.entity.vo.TemplateVO;
+import com.example.xiaoshiweixinback.mapper.TemplateMapper;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+* @author admin
+* @description 针对表【template(模板表)】的数据库操作Service实现
+* @createDate 2024-04-27 21:28:47
+*/
+@Service
+public class TemplateService extends ServiceImpl<TemplateMapper, Template> {
+
+    public List<TemplateVO> getTemplate(TemplateDTO templateDTO){
+        Integer type =templateDTO.getType();
+        LambdaQueryWrapper<Template> queryWrapper =new LambdaQueryWrapper<>();
+        queryWrapper.eq(Template::getTemplateType,type);
+        List<Template> templateList =this.list(queryWrapper);
+List<TemplateVO> templateVOS =new ArrayList<>();
+templateList.forEach(item->{
+    TemplateVO templateVO =new TemplateVO();
+    templateVO.setGuid(item.getFileGuid());
+    templateVO.setFileName(item.getName());
+    templateVO.setType(item.getTemplateType());
+    templateVOS.add(templateVO);
+});
+return templateVOS;
+    }
+}
+
+
+
+

+ 1 - 3
src/main/java/com/example/xiaoshiweixinback/service/common/FileManagerService.java

@@ -199,9 +199,7 @@ public class FileManagerService {
         Response response = null;
         response = okHttpClient.newCall(request).execute();
         // 最后记得删除临时文件
-        for (File file : files) {
-            FileUtils.deleteQuietly(file);
-        }
+
         return Objects.requireNonNull(response.body()).string();
     }
 

+ 39 - 0
src/main/java/com/example/xiaoshiweixinback/service/common/MessageService.java

@@ -0,0 +1,39 @@
+package com.example.xiaoshiweixinback.service.common;
+
+
+import com.example.xiaoshiweixinback.business.common.Response;
+import com.example.xiaoshiweixinback.business.common.ResponseEnum;
+import com.example.xiaoshiweixinback.business.utils.WebSocketServer;
+import com.example.xiaoshiweixinback.entity.websocket.TaskWebSocketDTO;
+import com.example.xiaoshiweixinback.entity.websocket.WebSocketMessageVO;
+import org.springframework.stereotype.Service;
+
+/**
+ * 处理消息通知
+ *
+ * @Author 李仁杰
+ */
+@Service
+public class MessageService {
+
+
+    //发送任务信息
+    public void sendImportTaskDone(WebSocketMessageVO webSocketMessageVO) {
+        //通过WebSocket 在每一次循环结束后 向前端发送完成进度
+        //当任务状态为完成时,flag为true
+        long percentage = (long) Math.floor((webSocketMessageVO.getCurrentNum() + 0D) / webSocketMessageVO.getAllNum() * 100D);
+        boolean flag = webSocketMessageVO.getIfComplete();
+
+        TaskWebSocketDTO taskWebSocketDTO = new TaskWebSocketDTO();
+        taskWebSocketDTO.setComplete(flag);
+        taskWebSocketDTO.setIndex(webSocketMessageVO.getCurrentNum());
+        taskWebSocketDTO.setPercentage(percentage);
+        taskWebSocketDTO.setTaskId(webSocketMessageVO.getTaskId());
+        taskWebSocketDTO.setTotal(webSocketMessageVO.getAllNum());
+        taskWebSocketDTO.setTaskType(webSocketMessageVO.getType());
+
+        WebSocketServer.sendInfo(Response.websocket(taskWebSocketDTO, ResponseEnum.IMPORT_TASK), webSocketMessageVO.getCreateId());
+
+    }
+
+}

+ 32 - 18
src/main/java/com/example/xiaoshiweixinback/service/common/OPSService.java

@@ -1,6 +1,8 @@
 package com.example.xiaoshiweixinback.service.common;
 
 import com.alibaba.fastjson.JSONObject;
+import com.example.xiaoshiweixinback.business.utils.FileUtil;
+import com.example.xiaoshiweixinback.business.utils.ImageUtil;
 import com.example.xiaoshiweixinback.business.utils.PatentNoUtil;
 import com.example.xiaoshiweixinback.entity.ops.*;
 import okhttp3.OkHttpClient;
@@ -8,7 +10,10 @@ import okhttp3.Request;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.awt.image.BufferedImage;
+import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.TimeUnit;
@@ -23,6 +28,7 @@ public class OPSService {
      */
     @Value("${OPSUrl}")
     private String OPSUrl;
+
     public byte[] getPatentFile(GetFuTuParamsDTO getFuTuParamsDTO) throws IOException {
         //String param = new Gson().toJson(getFuTuParamsDTO);
         //RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
@@ -32,12 +38,13 @@ public class OPSService {
                 .readTimeout(60, TimeUnit.SECONDS)
                 .build();
         Request request = new Request.Builder()
-                .url(OPSUrl + "/api/OPSQuery/GetPatentFile?link=" + getFuTuParamsDTO .getLink() + "&page=" + getFuTuParamsDTO.getPage() + "&type=" + getFuTuParamsDTO.getType())
+                .url(OPSUrl + "/api/OPSQuery/GetPatentFile?link=" + getFuTuParamsDTO.getLink() + "&page=" + getFuTuParamsDTO.getPage() + "&type=" + getFuTuParamsDTO.getType())
                 .get()
                 .build();
         byte[] buffer = okHttpClient.newCall(request).execute().body().bytes();
         return buffer;
     }
+
     /**
      * 远程调用获取Image信息的接口
      *
@@ -53,15 +60,19 @@ public class OPSService {
                 .readTimeout(60, TimeUnit.SECONDS)
                 .build();
         Request request = new Request.Builder()
-                .url(OPSUrl + "/api/OPSQuery/GetImagesInfo?Pn=" + "USD942334S")
+                .url(OPSUrl + "/api/OPSQuery/GetImagesInfo?Pn=" + pn)
                 .get()
                 .build();
         return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
     }
 
-    public byte[] getImages(String publicNo) throws IOException {
+    public List<ImagesInfoVO> getImageInfos(String publicNo) throws Exception {
+        List<ImagesInfoVO> images = new ArrayList<>();
         String res = this.getImagesInfo(publicNo);
         JSONObject jsonObject = JSONObject.parseObject(res);
+        if (res.equals("")) {
+            return images;
+        }
         String imageInfo = jsonObject.getString("data");
         // 删除第一个 `[`
         if (imageInfo.startsWith("[")) {
@@ -72,26 +83,29 @@ public class OPSService {
             imageInfo = imageInfo.substring(0, imageInfo.length() - 1);
         }
         GetImagesInfoVO getImagesInfoVO = JSONObject.parseObject(imageInfo, GetImagesInfoVO.class);
-        List<ImagesInfoVO> images = getImagesInfoVO.getImages();
-        if (!images.isEmpty()) {
-            ImagesInfoVO infoVO = images.stream().filter(item -> item.getImageType().equals("FirstPageClipping")).findFirst().orElse(null);
-            if (infoVO != null) {
+        images = getImagesInfoVO.getImages();
+        return images;
+    }
+
+
+    public void getImages(ImagesInfoVO image, String publicNo) throws Exception {
+        String rootPath = "D:\\patentImage\\202205-3001-3498\\";
+        if (image != null) {
+            Integer num = image.getNumberOfPages();
+            for (int i = 1; i < num + 1; i++) {
                 GetFuTuParamsDTO getFuTuParamsDTO = new GetFuTuParamsDTO();
-                getFuTuParamsDTO.setPage(1);
-                getFuTuParamsDTO.setType("image/png");
-                getFuTuParamsDTO.setLink(infoVO.getUrlLink());
+                getFuTuParamsDTO.setPage(i);
+                getFuTuParamsDTO.setType("application/tiff");
+                getFuTuParamsDTO.setLink(image.getUrlLink());
                 byte[] buffer = this.getPatentFile(getFuTuParamsDTO);
-                if (buffer != null) {
-                    return buffer;
-                } else {
-                    return null;
-                }
-            } else {
-                return null;
+               BufferedImage bufferedImage= ImageUtil.getByByte(buffer);
+               String name =rootPath + publicNo + "_" + (i - 1) + ".jpg";
+                ImageUtil.cutImage(bufferedImage,0,300,name);
             }
         } else {
-            return null;
+            return;
         }
+
     }
 
 

+ 82 - 25
src/main/java/com/example/xiaoshiweixinback/service/importPatent/EsDenseVectorService.java

@@ -1,5 +1,6 @@
 package com.example.xiaoshiweixinback.service.importPatent;
 
+import cn.hutool.core.util.IdUtil;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
 import co.elastic.clients.elasticsearch._types.InlineScript;
 import co.elastic.clients.elasticsearch._types.Script;
@@ -13,18 +14,19 @@ import co.elastic.clients.elasticsearch.core.SearchResponse;
 import co.elastic.clients.elasticsearch.core.search.FieldCollapse;
 import co.elastic.clients.elasticsearch.core.search.Hit;
 import co.elastic.clients.json.JsonData;
-import com.example.xiaoshiweixinback.business.common.ResponseEnum;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.example.xiaoshiweixinback.business.common.base.Records;
-import com.example.xiaoshiweixinback.business.common.base.RedisConf;
+import com.example.xiaoshiweixinback.business.common.base.SystemFile;
 import com.example.xiaoshiweixinback.business.exception.BusinessException;
 import com.example.xiaoshiweixinback.business.redis.RedisService;
 import com.example.xiaoshiweixinback.business.utils.BeanUtil;
+import com.example.xiaoshiweixinback.business.utils.FileUtils;
 import com.example.xiaoshiweixinback.business.utils.JSONUtil;
 import com.example.xiaoshiweixinback.business.utils.RegexUtil;
 import com.example.xiaoshiweixinback.business.utils.parseQueryToTree.expressManager;
 import com.example.xiaoshiweixinback.business.utils.parseQueryToTree.operateNode;
 import com.example.xiaoshiweixinback.business.utils.parseQueryToTree.treeNode;
-import com.example.xiaoshiweixinback.domain.AssoPersonFunction;
+import com.example.xiaoshiweixinback.domain.AssoProductFile;
 import com.example.xiaoshiweixinback.domain.Product;
 import com.example.xiaoshiweixinback.domain.es.PatentVector;
 import com.example.xiaoshiweixinback.entity.dto.esPicture.EsPictureNoDTO;
@@ -34,13 +36,15 @@ import com.example.xiaoshiweixinback.entity.dto.searchRecord.AddSearchRecordDTO;
 import com.example.xiaoshiweixinback.entity.dto.searchRecord.SearchRecordConditionDTO;
 import com.example.xiaoshiweixinback.entity.vo.esPicture.EsPictureNoVo;
 import com.example.xiaoshiweixinback.entity.vo.esPicture.EsPatentVectorVo;
+import com.example.xiaoshiweixinback.entity.vo.esPicture.GetImageVO;
+import com.example.xiaoshiweixinback.mapper.AssoProductFileMapper;
 import com.example.xiaoshiweixinback.mapper.ProductMapper;
 import com.example.xiaoshiweixinback.service.SearchRecordService;
 import com.example.xiaoshiweixinback.service.VipService;
 import com.example.xiaoshiweixinback.service.common.FileManagerService;
 import com.example.xiaoshiweixinback.service.common.GetVectorService;
-import com.example.xiaoshiweixinback.service.importPatent.FormatQueryService;
 import lombok.RequiredArgsConstructor;
+import org.apache.commons.compress.utils.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -50,8 +54,7 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
-import java.io.File;
-import java.io.IOException;
+import java.io.*;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -75,6 +78,9 @@ public class EsDenseVectorService {
     private ProductMapper productMapper;
 
     @Autowired
+    private AssoProductFileMapper assoProductFileMapper;
+
+    @Autowired
     private FileManagerService fileManagerService;
 
     @Lazy
@@ -86,10 +92,11 @@ public class EsDenseVectorService {
 
     @Autowired
     private RedisService redisService;
-   @Value("${ES.patentVector}")
-   private  String patentVectorName;
-   @Value("${ES.patent}")
-   private String patentMapName;
+    @Value("${ES.patentVector}")
+    private String patentVectorName;
+    @Value("${ES.patent}")
+    private String patentMapName;
+
     /**
      * 根据图片排序获取列表
      *
@@ -118,22 +125,11 @@ public class EsDenseVectorService {
             q = formatQueryService.EsQueryToQuery((operateNode) tree, "patentVector", null);
         }
         if (q == null) {
-            throw new BusinessException("608","检索式错误,请重新输入");
-        }
-        //获取图片向量
-        List<Float> imageList = new ArrayList<>();
-        List<String> stringList = new ArrayList<>();
-        List<String> getGuids = new ArrayList<>();
-        if (file != null && file.exists() && file.length() != 0) {
-            stringList = getVectorService.getVectorByFile(file);
-            getGuids = fileManagerService.uploadFileGetGuid2(Collections.singletonList(file));
-        } else if (StringUtils.isNotEmpty(dto.getDescription())) {
-            stringList = getVectorService.getVectorByText(dto.getDescription());
+            throw new BusinessException("608", "检索式错误,请重新输入");
         }
-        stringList.forEach(item -> {
-            Float a = Float.parseFloat(item);
-            imageList.add(a);
-        });
+        GetImageVO imageVO = this.getImageList(dto.getProductId(), file, dto.getDescription());
+        List<Float> imageList = imageVO.getImageList();
+        List<String> getGuids = imageVO.getGetGuids();
         if (!CollectionUtils.isEmpty(imageList)) {
             String source = "cosineSimilarity(params.queryVector, 'my_vector') + 1.0";
             InlineScript inlineScript = InlineScript.of(i -> i.lang("painless").params("queryVector", JsonData.of(imageList)).source(source));
@@ -233,6 +229,58 @@ public class EsDenseVectorService {
     }
 
     /**
+     * 获取图片矢量
+     *
+     * @param productId
+     * @param file
+     * @param description
+     * @return
+     * @throws IOException
+     */
+    public GetImageVO getImageList(Integer productId, File file, String description) throws IOException {
+        GetImageVO imageVO = new GetImageVO();
+        //获取图片向量
+        List<Float> imageList = new ArrayList<>();
+        List<String> stringList = new ArrayList<>();
+        List<String> getGuids = new ArrayList<>();
+        if (productId != null) {
+            List<AssoProductFile> productFiles = assoProductFileMapper.selectList(new LambdaQueryWrapper<AssoProductFile>()
+                    .eq(AssoProductFile::getProductId, productId));
+            if (!CollectionUtils.isEmpty(productFiles)) {
+                String fileGuid = productFiles.get(0).getFileGuid();
+                if (StringUtils.isNotEmpty(fileGuid)) {
+                    //获取文件信息
+                    byte[] bytes = fileManagerService.downloadSystemFileFromFMS(fileGuid);
+                    getGuids.add(fileGuid);
+                    List<SystemFile> systemFileByGuids = fileManagerService.getSystemFileByGuids(getGuids);
+                    if (!CollectionUtils.isEmpty(systemFileByGuids)) {
+                        SystemFile systemFile = systemFileByGuids.get(0);
+                        String suffix = systemFile.getFileName().substring(systemFile.getFileName().lastIndexOf("."));
+                        String prefix = IdUtil.simpleUUID();
+                        File tempFile = FileUtils.getFileByBytes(bytes, prefix, suffix);
+                        stringList = getVectorService.getVectorByFile(tempFile);
+                    }
+                }
+            }
+        } else {
+            if (file != null && file.exists() && file.length() != 0) {
+                stringList = getVectorService.getVectorByFile(file);
+                getGuids = fileManagerService.uploadFileGetGuid2(Collections.singletonList(file));
+            } else if (StringUtils.isNotEmpty(description)) {
+                stringList = getVectorService.getVectorByText(description);
+            }
+        }
+
+        stringList.forEach(item -> {
+            Float a = Float.parseFloat(item);
+            imageList.add(a);
+        });
+        imageVO.setImageList(imageList);
+        imageVO.setGetGuids(getGuids);
+        return imageVO;
+    }
+
+    /**
      * 拼接检索条件
      *
      * @param productId
@@ -250,6 +298,15 @@ public class EsDenseVectorService {
         if (productId != null) {
             Product product = productMapper.selectById(productId);
             searchCondition = product.getSearchCondition();
+            String locNum = product.getLocNum();
+            if (StringUtils.isNotEmpty(locNum)) {
+                String s = this.appendStr(locNum);
+                if (StringUtils.isEmpty(searchCondition)) {
+                    searchCondition = "LOC = " + "(" + s + ")";
+                } else {
+                    searchCondition = searchCondition + " AND " + "LOC = " + "(" + s + ")";
+                }
+            }
 
 //            Date now = new Date();
 //            String nowFormat = format.format(now);

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/service/importPatent/GetPatentFromExcelService.java

@@ -49,7 +49,7 @@ private GetPatentPictureFromExcelService getPatentPictureFromExcelService;
             Integer sourceId = 1;
             Integer total = ReadExcelUtils.textExcel(tempFile, sourceId.toString());
             //解析数据源类,通过数据来源id(如1:智慧芽)解析数据源配置文件,获得数据源配置文件对象jsonData
-            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(sourceId.toString());
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(sourceId.toString(),null);
             //解析Excel文件获得工作簿
             Sheet sheet = ReadExcelUtils.readExcel(tempFile);
             Integer x = 0;

+ 0 - 1
src/main/java/com/example/xiaoshiweixinback/service/importPatent/GetPatentPictureFromExcelService.java

@@ -78,7 +78,6 @@ public class GetPatentPictureFromExcelService {
             floats.add(a);
 
         });
-        org.apache.commons.io.FileUtils.deleteQuietly(file);
         patentVector.setMyVector(floats);
         esService.addPatentVector(patentVector);
 

+ 0 - 1
src/main/java/com/example/xiaoshiweixinback/service/importPatent/ImportFromWebToEsService.java

@@ -61,7 +61,6 @@ private GetFiguresService getFiguresService;
                     .setDBType(dbType), patentNum);
 
 
-            //下载字段
             int index = taskStartNum;
 
             //已经跳过的数量

+ 2 - 2
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ExcuteUploadSettingService.java

@@ -20,9 +20,9 @@ public class ExcuteUploadSettingService {
      * @param sourceId 数据来源id
      * @return 返回数据源配置文件对象
      */
-    public List<UploadSettingVO.Column> ExcuteUploadSetting(String sourceId) {
+    public List<UploadSettingVO.Column> ExcuteUploadSetting(String sourceId,String configName) {
         //获得uploadSetting.json配置文件的JSON串
-        String getSettingJson = new FileUtils().analysisJsonFile();
+        String getSettingJson = new FileUtils().analysisJsonFile(configName);
         //查找并装载本次导入的专利需要的数据源(如智慧芽)的对应配置(如前台传来的数据来源id是1,即“智慧芽”,那么jsonData装载的就是智慧芽的数据源配置)
         List<UploadSettingVO.Column> jsonData = UploadPatentBatchUtil.parsingConfigurationFiles(sourceId, getSettingJson);
         return jsonData;

+ 2 - 2
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetFilesFromOPSService.java

@@ -42,7 +42,7 @@ public class GetFilesFromOPSService {
             Row firstRow = sheet.getRow(0);
             int columns = firstRow.getLastCellNum();
 
-            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "");
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
 
             for (int r = 0; r < total; r++) {
                 Row needRow = sheet.getRow(r + 1);
@@ -76,7 +76,7 @@ public class GetFilesFromOPSService {
             Row firstRow = sheet.getRow(0);
             int columns = firstRow.getLastCellNum();
 
-            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "");
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
 
             for (int r = 0; r < total; r++) {
                 Row needRow = sheet.getRow(r + 1);

+ 72 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetOPSFileByExcelService.java

@@ -0,0 +1,72 @@
+package com.example.xiaoshiweixinback.service.importPatent.excel;
+
+import cn.hutool.core.util.IdUtil;
+import com.example.xiaoshiweixinback.business.utils.ExcelUtils;
+import com.example.xiaoshiweixinback.business.utils.FileUtils;
+import com.example.xiaoshiweixinback.business.utils.ReadExcelUtils;
+import com.example.xiaoshiweixinback.entity.dto.patent.UploadPatentWebDTO;
+import com.example.xiaoshiweixinback.entity.ops.ImagesInfoVO;
+import com.example.xiaoshiweixinback.service.common.OPSService;
+import com.example.xiaoshiweixinback.service.importPatent.GetPatentFromExcelService;
+import com.example.xiaoshiweixinback.service.importPatent.GetPatentPictureFromExcelService;
+import com.example.xiaoshiweixinback.service.importPatent.SavePatentToEsService;
+import org.apache.poi.ss.usermodel.PictureData;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class GetOPSFileByExcelService {
+    @Autowired
+    private ExcuteUploadSettingService excuteUploadSettingService;
+    @Autowired
+    private GetPatentFromExcelService getPatentFromExcelService;
+    @Autowired
+    private OPSService opsService;
+
+    public void test(String pathStr) throws Exception {
+        String[] paths = pathStr.split(",");
+        String rootPath = "D:\\usa_patent\\202205-3498\\";
+        for (int t = 0; t < paths.length; t++) {
+            String path = paths[t];
+            File tempFile = new File(rootPath + path);
+
+            Sheet sheet = ReadExcelUtils.readExcel(tempFile);
+            int total = sheet.getPhysicalNumberOfRows() - 1;
+            Row firstRow = sheet.getRow(0);
+            int columns = firstRow.getLastCellNum();
+
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
+
+            for (int r = 425; r < total; r++) {
+                Row needRow = sheet.getRow(r + 1);
+                Map<Object, Object> map = new HashMap<>();
+                for (int i = 0; i < columns; i++) {
+                    map.put(firstRow.getCell(i) + "", ExcelUtils.getValue(needRow.getCell(i)) + "");
+                }
+                UploadParamsVO uploadParamsVO = UploadPatentBatchUtil.processData(map, jsonData);
+                getPatentFromExcelService.loadPatent(uploadParamsVO);
+                String publicNo = uploadParamsVO.getPatent().getPublicNo();
+                String appNo = uploadParamsVO.getPatent().getAppNo();
+                if (publicNo == null) {
+                    System.out.println("no patent");
+                } else {
+                    List<ImagesInfoVO> imagesInfoVOS = opsService.getImageInfos(publicNo);
+                    ImagesInfoVO infoVO = imagesInfoVOS.stream().filter(item -> item.getImageType().equals("Drawing")).findFirst().orElse(null);
+                    opsService.getImages(infoVO, appNo);
+                }
+                System.out.println(r);
+            }
+        }
+
+    }
+
+
+}

+ 59 - 14
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetPatentFromSzService.java

@@ -24,10 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class GetPatentFromSzService {
@@ -42,8 +40,9 @@ public class GetPatentFromSzService {
 
     public void test(String pathStr) throws Exception {
         String[] paths = pathStr.split(",");
-        for (int t=0;t<paths.length;t++) {
-            String path =paths[t];
+        for (int t = 0; t < paths.length; t++) {
+            String path = paths[t];
+
             File tempFile = new File(path);
 
             Sheet sheet = ReadExcelUtils.readExcel(tempFile);
@@ -51,7 +50,7 @@ public class GetPatentFromSzService {
             Row firstRow = sheet.getRow(0);
             int columns = firstRow.getLastCellNum();
 
-            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "");
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
 
             for (int r = 0; r < total; r++) {
                 Row needRow = sheet.getRow(r + 1);
@@ -77,19 +76,17 @@ public class GetPatentFromSzService {
                 savePatentToEsService.saveOrUpdate(uploadPatentWebDTO);
                 System.out.println(r);
             }
-            System.out.println("完成"+t);
-
+            System.out.println("完成" + t);
             //获得总列数
 
         }
     }
 
 
-
     public void test2(String pathStr) throws Exception {
         String[] paths = pathStr.split(",");
-        for (int t=0;t<paths.length;t++) {
-            String path =paths[t];
+        for (int t = 0; t < paths.length; t++) {
+            String path = paths[t];
             File tempFile = new File(path);
 
             Sheet sheet = ReadExcelUtils.readExcel(tempFile);
@@ -97,7 +94,7 @@ public class GetPatentFromSzService {
             Row firstRow = sheet.getRow(0);
             int columns = firstRow.getLastCellNum();
 
-            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "");
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
 
             for (int r = 0; r < total; r++) {
                 Row needRow = sheet.getRow(r + 1);
@@ -118,8 +115,56 @@ public class GetPatentFromSzService {
                 savePatentToEsService.saveOrUpdate(uploadPatentWebDTO);
                 System.out.println(r);
             }
-            System.out.println("done"+t);
+            System.out.println("done" + t);
+
+            //获得总列数
+
+        }
+    }
 
+
+    public void test3(String pathStr) throws Exception {
+        String[] paths = pathStr.split(",");
+        for (int t = 0; t < paths.length; t++) {
+            String path = paths[t];
+            String rootPath = "D:\\usa_patent\\202205-3498\\";
+            String a =path.replace(".xlsx","");
+            path =rootPath+path;
+            File tempFile = new File(path);
+
+            Sheet sheet = ReadExcelUtils.readExcel(tempFile);
+            int total = sheet.getPhysicalNumberOfRows() - 1;
+            Row firstRow = sheet.getRow(0);
+            int columns = firstRow.getLastCellNum();
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
+
+            String picturePath= "D:\\patentImage\\";
+
+       File temFile =new File(picturePath+a);
+            File[] files = temFile.listFiles();
+            for (int r =0; r < total; r++) {
+                Row needRow = sheet.getRow(r + 1);
+                Map<Object, Object> map = new HashMap<>();
+                for (int i = 0; i < columns; i++) {
+                    map.put(firstRow.getCell(i) + "", ExcelUtils.getValue(needRow.getCell(i)) + "");
+                }
+                UploadParamsVO uploadParamsVO = UploadPatentBatchUtil.processData(map, jsonData);
+                getPatentFromExcelService.loadPatent(uploadParamsVO);
+                String appNo = uploadParamsVO.getPatent().getAppNo();
+           List<File> files1=     Arrays.stream(files).filter(item -> item.getName().contains(appNo)).collect(Collectors.toList());
+
+                for (int i = 0; i < files1.size(); i++) {
+                    File file = files1.get(i);
+                 String numStr=   file.getName().substring(file.getName().indexOf("_")+1,file.getName().indexOf("."));
+                 Integer index =Integer.parseInt(numStr);
+                    getPatentPictureFromExcelService.tem(file, uploadParamsVO.getPatent(),index+1 );
+                }
+                UploadPatentWebDTO uploadPatentWebDTO = new UploadPatentWebDTO();
+                uploadPatentWebDTO.setPatent(uploadParamsVO.getPatent());
+                savePatentToEsService.saveOrUpdate(uploadPatentWebDTO);
+                System.out.println(r);
+            }
+            System.out.println("完成" + t);
             //获得总列数
 
         }

+ 0 - 87
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProduct.java

@@ -1,87 +0,0 @@
-package com.example.xiaoshiweixinback.service.importPatent.excel;
-
-import cn.hutool.core.util.IdUtil;
-import com.example.xiaoshiweixinback.business.utils.ExcelUtils;
-import com.example.xiaoshiweixinback.business.utils.FileUtils;
-import com.example.xiaoshiweixinback.business.utils.ReadExcelUtils;
-import com.example.xiaoshiweixinback.business.utils.RedisUtil;
-import com.example.xiaoshiweixinback.domain.AssoProductFile;
-import com.example.xiaoshiweixinback.domain.Product;
-import com.example.xiaoshiweixinback.service.AssoProductFileService;
-import com.example.xiaoshiweixinback.service.ProductService;
-import com.example.xiaoshiweixinback.service.common.FileManagerService;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.ss.usermodel.PictureData;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-@Service
-public class ImportProduct {
-
-    @Autowired
-    private ProductService productService;
-
-    @Autowired
-    private FileManagerService fileManagerService;
-    @Autowired
-    private AssoProductFileService assoProductFileService;
-    public void importProject() {
-        try {
-            File tempFile = new File("C:\\Users\\admin\\Desktop\\exce\\product.xlsx");
-
-            Sheet sheet = ReadExcelUtils.readExcel(tempFile);
-            for (int i = 2; i < 80; i++) {
-                PatentData patentData = ReadExcelUtils.readExcelOneRow(tempFile, sheet, i);
-                Map<Object, Object> map = patentData.getMap();
-                Object o = map.get("序号");
-                System.out.println(o);
-                if (map.get("序号").equals("")) {
-                    continue;
-                }
-                PictureData pictureData = patentData.getPictureData();
-
-                String ext = pictureData.suggestFileExtension();
-                byte[] data = pictureData.getData();
-                String picName = IdUtil.simpleUUID();
-                File file = FileUtils.getFileByBytes(data, picName, "." + ext);
-        String c =   fileManagerService.uploadFileWithGuid(file,picName);
-Product product =this.loadProduct(map);
-product.insert();
-                AssoProductFile assoProductFile =new AssoProductFile();
-                assoProductFile.setProductId(product.getId());
-                assoProductFile.setFileGuid(picName);
-                assoProductFile.insert();
-            }
-        } catch (Exception e) {
-        }
-
-
-    }
-
-    private Product loadProduct(Map<Object,Object> map){
-         Product product =new Product();
-         product.setName(map.get("产品名称").toString());
-         product.setSearchCondition(map.get("关键词").toString());
-         product.setSourceFrom(map.get("卖家").toString());
-         product.setSellPlatform(map.get("网站名").toString());
-         product.setIfHot(true);
-         product.setIfCustomized(false);
-         product.setBestSellingBrand(map.get("销冠品牌").toString());
-         String p =map.get("金额").toString().replace("$","");
-       Double price =  Double.parseDouble(p);
-         product.setPrice(price);
-         product.setPlatformLink(map.get("产品网页链接").toString());
-        product.setLocNum(map.get("LOC分类号").toString());
-        return product;
-    }
-
-}

+ 128 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProductCategoryService.java

@@ -0,0 +1,128 @@
+package com.example.xiaoshiweixinback.service.importPatent.excel;
+
+import cn.hutool.core.util.IdUtil;
+import com.example.xiaoshiweixinback.business.exception.BusinessException;
+import com.example.xiaoshiweixinback.business.utils.CacheUtil;
+import com.example.xiaoshiweixinback.business.utils.FileUtils;
+import com.example.xiaoshiweixinback.business.utils.ReadExcelUtils;
+import com.example.xiaoshiweixinback.domain.ImportTask;
+import com.example.xiaoshiweixinback.domain.Product;
+import com.example.xiaoshiweixinback.domain.ProductCategory;
+import com.example.xiaoshiweixinback.entity.dto.productCategory.EditCategoryDTO;
+import com.example.xiaoshiweixinback.entity.product.HotProductAddDTO;
+import com.example.xiaoshiweixinback.entity.product.UploadCategoryParamsVO;
+import com.example.xiaoshiweixinback.entity.product.UploadProductParamsVO;
+import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
+import com.example.xiaoshiweixinback.entity.websocket.WebSocketMessageVO;
+import com.example.xiaoshiweixinback.service.AssoProductFileService;
+import com.example.xiaoshiweixinback.service.ProductCategoryService;
+import com.example.xiaoshiweixinback.service.ProductService;
+import com.example.xiaoshiweixinback.service.common.FileManagerService;
+import com.example.xiaoshiweixinback.service.common.MessageService;
+import org.apache.poi.ss.usermodel.PictureData;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class ImportProductCategoryService {
+
+
+    @Autowired
+    private FileManagerService fileManagerService;
+
+    @Autowired
+    private ExcuteUploadSettingService excuteUploadSettingService;
+
+    @Autowired
+    private ProductCategoryService productCategoryService;
+    @Autowired
+    private MessageService messageService;
+    @Autowired
+    private CacheUtil cacheUtil;
+
+    @Async("taskExecutor")
+    public void importProductCategory(File tempFile, ImportTask importTask) {
+        try {
+            Sheet sheet = ReadExcelUtils.readExcel(tempFile);
+            Integer total = ReadExcelUtils.getExcelTotal(sheet);
+
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting("1", "uploadCategory.json");
+
+            WebSocketMessageVO webSocketMessageVO = new WebSocketMessageVO();
+            webSocketMessageVO.setType(importTask.getImportType());
+            webSocketMessageVO.setCreateId(importTask.getCreateId());
+            webSocketMessageVO.setTaskId(importTask.getId());
+            webSocketMessageVO.setAllNum(total);
+            for (int i = 1; i < total; i++) {
+                PatentData patentData = ReadExcelUtils.readExcelOneRow2(tempFile, sheet, i);
+                Map<Object, Object> map = patentData.getMap();
+                UploadCategoryParamsVO uploadParamsVO = UploadPatentBatchUtil.processCategoryData(map, jsonData);
+                if (uploadParamsVO.getCategoryList() == null || uploadParamsVO.getCategoryList().size() == 0) {
+                    continue;
+                }
+                List<PictureData> pictureDataList = patentData.getPictureDataList();
+                List<String> names = uploadParamsVO.getCategoryList();
+                if (names == null || names.size() == 0) {
+                    return;
+                }
+
+
+                EditCategoryDTO editCategoryDTO = this.loadCategoryAddVO(uploadParamsVO, pictureDataList);
+                try {
+                    productCategoryService.editCategory(editCategoryDTO);
+                } catch (Exception e) {
+                    continue;
+                }
+
+                webSocketMessageVO.setIfComplete(false);
+                webSocketMessageVO.setCurrentNum(i);
+                messageService.sendImportTaskDone(webSocketMessageVO);
+            }
+
+            webSocketMessageVO.setIfComplete(true);
+            webSocketMessageVO.setCurrentNum(total);
+            messageService.sendImportTaskDone(webSocketMessageVO);
+        } catch (Exception e) {
+        }
+
+
+    }
+
+    private EditCategoryDTO loadCategoryAddVO(UploadCategoryParamsVO uploadParamsVO, List<PictureData> pictureDataList) throws Exception {
+        ProductCategory productCategory = productCategoryService.addCategorysByStr(uploadParamsVO.getCategoryList());
+
+        EditCategoryDTO editCategoryDTO = new EditCategoryDTO();
+        BeanUtils.copyProperties(uploadParamsVO, editCategoryDTO);
+
+        List<String> fileIds = new ArrayList<>();
+        for (PictureData pictureData : pictureDataList) {
+            String ext = pictureData.suggestFileExtension();
+            byte[] data = pictureData.getData();
+            String picName = IdUtil.simpleUUID();
+            File file = FileUtils.getFileByBytes(data, picName, "." + ext);
+            try {
+                List<String> guids = fileManagerService.uploadFileGetGuid2(Arrays.asList(file));
+                fileIds.add(guids.get(0));
+            } catch (Exception e) {
+                throw new BusinessException("607", "上传错误");
+            }
+
+        }
+        editCategoryDTO.setFileGuids(fileIds);
+        editCategoryDTO.setName(productCategory.getName());
+        if (productCategory != null) {
+            editCategoryDTO.setId(productCategory.getId());
+            editCategoryDTO.setParentId(productCategory.getParentId());
+        }
+        return editCategoryDTO;
+    }
+}

+ 142 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProductService.java

@@ -0,0 +1,142 @@
+package com.example.xiaoshiweixinback.service.importPatent.excel;
+
+import cn.hutool.core.util.IdUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.example.xiaoshiweixinback.business.exception.BusinessException;
+import com.example.xiaoshiweixinback.business.utils.*;
+import com.example.xiaoshiweixinback.domain.AssoProductFile;
+import com.example.xiaoshiweixinback.domain.ImportTask;
+import com.example.xiaoshiweixinback.domain.Product;
+import com.example.xiaoshiweixinback.domain.ProductCategory;
+import com.example.xiaoshiweixinback.entity.product.HotProductAddDTO;
+import com.example.xiaoshiweixinback.entity.product.UploadProductParamsVO;
+import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
+import com.example.xiaoshiweixinback.entity.websocket.WebSocketMessageVO;
+import com.example.xiaoshiweixinback.service.AssoProductFileService;
+import com.example.xiaoshiweixinback.service.ProductCategoryService;
+import com.example.xiaoshiweixinback.service.ProductService;
+import com.example.xiaoshiweixinback.service.common.FileManagerService;
+import com.example.xiaoshiweixinback.service.common.MessageService;
+import io.swagger.v3.oas.models.security.SecurityScheme;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.ss.usermodel.PictureData;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.io.File;
+import java.io.IOException;
+import java.security.MessageDigest;
+import java.security.MessageDigestSpi;
+import java.util.*;
+
+@Service
+public class ImportProductService {
+
+    @Autowired
+    private ProductService productService;
+
+    @Autowired
+    private FileManagerService fileManagerService;
+
+    @Autowired
+    private AssoProductFileService assoProductFileService;
+
+    @Autowired
+    private ExcuteUploadSettingService excuteUploadSettingService;
+
+    @Autowired
+    private ProductCategoryService productCategoryService;
+
+    @Autowired
+    private MessageService messageService;
+
+    @Async("taskExecutor")
+    public void importProject(File tempFile, ImportTask importTask) {
+        try {
+            PersonnelVO personnelVO = new PersonnelVO();
+            personnelVO.setUuid("123");
+            Sheet sheet = ReadExcelUtils.readExcel(tempFile);
+            Integer total = ReadExcelUtils.getExcelTotal(sheet);
+
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting("1", "uploadProduct.json");
+            WebSocketMessageVO webSocketMessageVO =new WebSocketMessageVO();
+            webSocketMessageVO.setType(importTask.getImportType());
+            webSocketMessageVO.setCreateId(importTask.getCreateId());
+            webSocketMessageVO.setTaskId(importTask.getId());
+            webSocketMessageVO.setAllNum(total);
+            for (int i = 1; i < total; i++) {
+                PatentData patentData = ReadExcelUtils.readExcelOneRow2(tempFile, sheet, i);
+                Map<Object, Object> map = patentData.getMap();
+                UploadProductParamsVO uploadParamsVO = UploadPatentBatchUtil.processProductData(map, jsonData);
+                if (uploadParamsVO.getName() == null) {
+                    continue;
+                }
+                List<PictureData> pictureDataList = patentData.getPictureDataList();
+
+                HotProductAddDTO hotProductAddDTO = this.loadProductAddVO(uploadParamsVO, pictureDataList);
+                try {
+                    productService.addOrUpdateHotProduct(hotProductAddDTO, personnelVO.getUuid());
+                } catch (Exception e) {
+                    continue;
+                }
+
+                webSocketMessageVO.setIfComplete(false);
+                webSocketMessageVO.setCurrentNum(total);
+                messageService.sendImportTaskDone(webSocketMessageVO);
+            }
+
+            webSocketMessageVO.setIfComplete(true);
+            webSocketMessageVO.setCurrentNum(total);
+            messageService.sendImportTaskDone(webSocketMessageVO);
+        } catch (Exception e) {
+        }
+
+
+    }
+
+
+    private HotProductAddDTO loadProductAddVO(UploadProductParamsVO uploadParamsVO, List<PictureData> pictureDataList) throws Exception {
+        ProductCategory productCategory = productCategoryService.addCategorysByStr(uploadParamsVO.getCategoryList());
+        String priceStr = uploadParamsVO.getPriceStr();
+         uploadParamsVO.setPrice(Double.parseDouble(priceStr));
+        HotProductAddDTO hotProductAddDTO = new HotProductAddDTO();
+        BeanUtils.copyProperties(uploadParamsVO, hotProductAddDTO);
+        hotProductAddDTO.setIfHot(true);
+        hotProductAddDTO.setIfShow(true);
+        hotProductAddDTO.getFileGuids();
+        List<String> fileIds = new ArrayList<>();
+        for (PictureData pictureData : pictureDataList) {
+            String ext = pictureData.suggestFileExtension();
+            byte[] data = pictureData.getData();
+            String picName = IdUtil.simpleUUID();
+            File file = FileUtils.getFileByBytes(data, picName, "." + ext);
+            try {
+                List<String> guids = fileManagerService.uploadFileGetGuid2(Arrays.asList(file));
+                fileIds.add(guids.get(0));
+            } catch (Exception e) {
+                throw new BusinessException("607", "上传错误");
+            }
+
+        }
+        hotProductAddDTO.setFileGuids(fileIds);
+        if (productCategory != null) {
+            hotProductAddDTO.setProductCategoryId(productCategory.getId());
+        }
+
+        //根据名称查询
+        LambdaQueryWrapper<Product> queryWrapper =new LambdaQueryWrapper<>();
+        queryWrapper.eq(Product::getName,hotProductAddDTO.getName())
+                     .eq(Product::getIfHot,true);
+        Product  product =productService.getOne(queryWrapper,false);
+        if(product!=null){
+            hotProductAddDTO.setId(product.getId());
+        }
+        return hotProductAddDTO;
+    }
+}

+ 2 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/PatentData.java

@@ -4,6 +4,7 @@ import lombok.Data;
 import lombok.experimental.Accessors;
 import org.apache.poi.ss.usermodel.PictureData;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -21,5 +22,6 @@ public class PatentData {
      * 专利摘要附图
      */
     private PictureData pictureData;
+    private List<PictureData> pictureDataList;
 
 }

+ 70 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/UploadPatentBatchUtil.java

@@ -4,6 +4,8 @@ package com.example.xiaoshiweixinback.service.importPatent.excel;
 import com.example.xiaoshiweixinback.business.utils.DataProcessHandler;
 import com.example.xiaoshiweixinback.business.utils.JsonUtils;
 import com.example.xiaoshiweixinback.business.utils.StringUtils;
+import com.example.xiaoshiweixinback.entity.product.UploadCategoryParamsVO;
+import com.example.xiaoshiweixinback.entity.product.UploadProductParamsVO;
 import org.springframework.stereotype.Component;
 
 import java.lang.reflect.Field;
@@ -235,4 +237,72 @@ public class UploadPatentBatchUtil {
         uploadParamsVO.setCustomerFieldList(list);
         return uploadParamsVO;
     }
+
+
+
+    public static UploadProductParamsVO processProductData(Map<Object, Object> row, List<UploadSettingVO.Column> jsonData) {
+        UploadProductParamsVO uploadParamsVO = new UploadProductParamsVO();
+        try {
+            for (Object object : row.keySet()) {
+                String key = object.toString();
+                Object value = row.get(key);
+
+                if (StringUtils.isNotNull(value) && !value.equals("") && !value.equals("-") && !value.equals("\\")) {
+                    //将配置项与Excel栏位进行比对
+                    List<UploadSettingVO.Column> temVOColumn = getColumn(jsonData, key);
+                    for (UploadSettingVO.Column column : temVOColumn) {
+                        //创建处理对象
+                        Object processData = DataProcessHandler.getData(column.getHandler(), column.getJarOrClassPath());
+                        //调用处理对象中的对应处理方法对Excel中的数据进行处理
+                        Object getProcessData = null;
+                        if (processData != null) {
+                            Method method = processData.getClass().getMethod("processData", Object.class, Object.class);
+                            getProcessData = method.invoke(processData, value.toString(), column.getSplitSymbol());
+                        }
+                        //将格式化后的数据装配到VO类
+                        assemblyObject(uploadParamsVO, column.getColumn(), getProcessData);
+
+                    }
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return uploadParamsVO;
+    }
+
+
+
+    public static UploadCategoryParamsVO processCategoryData(Map<Object, Object> row, List<UploadSettingVO.Column> jsonData) {
+        UploadCategoryParamsVO uploadParamsVO = new UploadCategoryParamsVO();
+        try {
+            for (Object object : row.keySet()) {
+                String key = object.toString();
+                Object value = row.get(key);
+
+                if (StringUtils.isNotNull(value) && !value.equals("") && !value.equals("-") && !value.equals("\\")) {
+                    //将配置项与Excel栏位进行比对
+                    List<UploadSettingVO.Column> temVOColumn = getColumn(jsonData, key);
+                    for (UploadSettingVO.Column column : temVOColumn) {
+                        //创建处理对象
+                        Object processData = DataProcessHandler.getData(column.getHandler(), column.getJarOrClassPath());
+                        //调用处理对象中的对应处理方法对Excel中的数据进行处理
+                        Object getProcessData = null;
+                        if (processData != null) {
+                            Method method = processData.getClass().getMethod("processData", Object.class, Object.class);
+                            getProcessData = method.invoke(processData, value.toString(), column.getSplitSymbol());
+                        }
+                        //将格式化后的数据装配到VO类
+                        assemblyObject(uploadParamsVO, column.getColumn(), getProcessData);
+
+                    }
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return uploadParamsVO;
+    }
 }

+ 13 - 0
src/main/java/com/example/xiaoshiweixinback/service/quartzService/ImportJobService.java

@@ -0,0 +1,13 @@
+package com.example.xiaoshiweixinback.service.quartzService;
+
+public class ImportJobService {
+
+    /**
+     * 定时导入专利
+     */
+    public  void timingImportPatent(){
+       //获取上次导入的信息
+
+
+    }
+}

+ 127 - 0
src/main/java/com/example/xiaoshiweixinback/service/quartzService/JobService.java

@@ -0,0 +1,127 @@
+package com.example.xiaoshiweixinback.service.quartzService;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.example.xiaoshiweixinback.entity.quartz.QrtzTaskDTO;
+import com.example.xiaoshiweixinback.entity.quartz.QuartzVO;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.*;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+@Slf4j
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
+public class JobService {
+
+    private final Scheduler scheduler;
+
+
+    /**
+     * 删除job
+     *
+     * @throws SchedulerException
+     */
+    public void deleteJob(Integer taskId) throws SchedulerException {
+        QuartzVO quartzVO = this.generateQuartzVO(taskId);
+        TriggerKey triggerKey = TriggerKey.triggerKey(quartzVO.getTriggerName(), quartzVO.getTriggerGroupName());
+        scheduler.pauseTrigger(triggerKey);
+        scheduler.unscheduleJob(triggerKey);
+        JobKey jobKey = JobKey.jobKey(quartzVO.getJobName(), quartzVO.getJobGroupName());
+        scheduler.deleteJob(jobKey);
+    }
+
+    /**
+     * 暂停job
+     *
+     * @throws SchedulerException
+     */
+    public void pauseJob(Integer taskId) throws SchedulerException {
+        QuartzVO quartzVO = this.generateQuartzVO(taskId);
+        //更新任务条件状态
+        JobKey jobKey = JobKey.jobKey(quartzVO.getJobName(), quartzVO.getJobGroupName());
+        scheduler.pauseJob(jobKey);
+    }
+
+    /**
+     * 恢复job
+     *
+     * @throws SchedulerException
+     */
+    public void resumeJob(Integer taskId) throws SchedulerException {
+        QuartzVO quartzVO = this.generateQuartzVO(taskId);
+        JobKey jobKey = JobKey.jobKey(quartzVO.getJobName(), quartzVO.getJobGroupName());
+        scheduler.resumeJob(jobKey);
+    }
+
+    /**
+     * 修改定时任务
+     *
+     * @param
+     */
+    public void updateJob(QrtzTaskDTO qrtzTask) {
+        //更新任务
+
+        QuartzVO quartzVO = this.generateQuartzVO(qrtzTask.getId());
+        JobDataMap jobDataMap = new JobDataMap();
+        jobDataMap.put("qrtzTask", qrtzTask);
+        TriggerKey oldTriggerKey = TriggerKey.triggerKey(quartzVO.getTriggerName(), quartzVO.getTriggerGroupName());
+        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(qrtzTask.getCrons());
+        CronTrigger cronTrigger = TriggerBuilder.newTrigger()
+                .withIdentity(oldTriggerKey).usingJobData(jobDataMap).withSchedule(scheduleBuilder).build();
+        try {
+            scheduler.rescheduleJob(oldTriggerKey, cronTrigger);
+        } catch (SchedulerException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 新增job任务
+     *
+     * @throws SchedulerException
+     */
+    @Transactional
+    public void addJob(QrtzTaskDTO qrtzTask) throws SchedulerException {
+        //添加一条任务记录
+        QuartzVO quartzVO = this.generateQuartzVO(qrtzTask.getId());
+        JobDataMap jobDataMap = new JobDataMap();
+        jobDataMap.put("qrtzTask", qrtzTask);
+        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(qrtzTask.getCrons());
+        JobDetail jobDetail = JobBuilder
+                .newJob(TaskAddJob.class)
+                .withIdentity(quartzVO.getJobName(), quartzVO.getJobGroupName())
+                .build();
+        Trigger trigger = TriggerBuilder
+                .newTrigger()
+                .withIdentity(quartzVO.getTriggerName(), quartzVO.getTriggerGroupName())
+                .withSchedule(cronScheduleBuilder)
+                .usingJobData(jobDataMap)
+                .build();
+        scheduler.scheduleJob(jobDetail, trigger);
+
+    }
+
+
+    public QuartzVO generateQuartzVO(Integer taskId) {
+        QuartzVO quartzVO = new QuartzVO();
+        quartzVO.setJobName("Job_" + taskId);
+        quartzVO.setJobGroupName("Default");
+        quartzVO.setTriggerName("Trigger_" + taskId);
+        quartzVO.setTriggerGroupName("Default");
+        return quartzVO;
+
+    }
+
+    /**
+     * 停止正在进行的job
+     *
+     * @throws SchedulerException
+     */
+    public void interruptJob(Integer taskId) throws SchedulerException {
+        QuartzVO quartzVO = this.generateQuartzVO(taskId);
+        JobKey jobKey = JobKey.jobKey(quartzVO.getJobName(), quartzVO.getJobGroupName());
+        scheduler.interrupt(jobKey);
+    }
+}

+ 28 - 0
src/main/java/com/example/xiaoshiweixinback/service/quartzService/TaskAddJob.java

@@ -0,0 +1,28 @@
+package com.example.xiaoshiweixinback.service.quartzService;
+
+import com.example.xiaoshiweixinback.entity.quartz.QuartzVO;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.*;
+import org.springframework.scheduling.quartz.QuartzJobBean;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 定义任务
+ */
+@DisallowConcurrentExecution
+public class TaskAddJob extends   QuartzJobBean {
+
+    private static final Log logger = LogFactory.getLog(TaskAddJob.class);
+      private  boolean flag =true;
+    @Override
+    public void executeInternal(JobExecutionContext context) throws JobExecutionException {
+        JobDataMap jobDataMap = context.getTrigger().getJobDataMap();
+        QuartzVO qrtzTask = (QuartzVO) jobDataMap.get("qrtzTask");
+
+
+        logger.info("添加任务" + "信息是" + "1");
+    }
+
+}

+ 6 - 6
src/main/resources/application-dev.yml

@@ -1,12 +1,12 @@
 spring:
   rabbitmq:
-    host: 192.168.1.24
+    host: 192.168.2.24
     port: 5672
     username: admin
     password: 123456
   data:
    redis:
-     host: 192.168.1.24
+     host: 192.168.2.24
      port: 6379
      database: 3
      password: Xx0GWxdWQJxx6Swe
@@ -18,7 +18,7 @@ spring:
          max-wait: -1ms
      timeout: 2000ms
   datasource:
-    url: jdbc:mysql://192.168.1.24:3306/ecs?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8
+    url: jdbc:mysql://192.168.2.24:3306/ecs?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8
     userName: root
     password: rrzTwWAYX8Gxh5JH
     driver-class-name: com.mysql.cj.jdbc.Driver
@@ -51,7 +51,7 @@ spring:
             threadsInheritContextClassLoaderOfInitializingThread: true
           dataSource:
             default:
-              URL: jdbc:mysql://192.168.1.24:3306/ecs?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8
+              URL: jdbc:mysql://192.168.2.24:3306/ecs?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8
               user: root
               password: rrzTwWAYX8Gxh5JH
               driver: com.mysql.jdbc.Driver
@@ -63,7 +63,7 @@ spring:
       initialize-schema: always
 authorUrl: http://localhost:8871
 PCSUrl: http://localhost:8871
-OPSUrl: http://192.168.1.24:5001
+OPSUrl: http://139.224.24.90:5001
 #OPSUrl: http://139.224.24.90:5001
 PASUrl: http://localhost:8877
 FMSUrl: http://localhost:8802
@@ -86,4 +86,4 @@ queueName: emailProd.queue
 ES:
   patentVector: patent_vector
   patent: wxpatent
-  config: es-cn-em93o8856000ho9e7.elasticsearch.aliyuncs.com
+  config: es-cn-em93o8856000ho9e7.public.elasticsearch.aliyuncs.com

+ 5 - 1
src/main/resources/application-prodNetIn.yml

@@ -80,4 +80,8 @@ SMS:
 WeChat:
   appId: wxaefb842bd0b93ff0
   appSecret: 89fe0fb96472548d48f63b2f5c956537
-Keypath: apiclient_key.pem
+Keypath: apiclient_key.pem
+ES:
+  patentVector: patent_vector
+  patent: wxpatent
+  config: es-cn-em93o8856000ho9e7.public.elasticsearch.aliyuncs.com

+ 5 - 1
src/main/resources/application-prodNetOut.yml

@@ -34,4 +34,8 @@ WeChat:
   appSecret: 89fe0fb96472548d48f63b2f5c956537
 
 Keypath: C:\Users\admin\Desktop\小程序证书\1673179188_20240408_cert\apiclient_key.pem
-queueName: emailProd.queue
+queueName: emailProd.queue
+ES:
+  patentVector: patent_vector
+  patent: wxpatent
+  config: es-cn-em93o8856000ho9e7.public.elasticsearch.aliyuncs.com

+ 30 - 0
src/main/resources/jsons/uploadCategory.json

@@ -0,0 +1,30 @@
+[
+  {
+    "sourceId": "1",
+    "sourceName": "Amazson",
+    "name": "亚马逊",
+    "column": [
+      {
+        "setName": "描述",
+        "column": "description",
+        "splitSymbol": "1,\\|",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "关键词",
+        "column": "searchCondition",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "产品分类",
+        "column": "categoryList",
+        "splitSymbol": ">",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      }
+    ]
+  }
+]

+ 79 - 0
src/main/resources/jsons/uploadProduct.json

@@ -0,0 +1,79 @@
+[
+  {
+    "sourceId": "1",
+    "sourceName": "Amazson",
+    "name": "亚马逊",
+    "column": [
+      {
+        "setName": "产品名称",
+        "column": "name",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "描述",
+        "column": "description",
+        "splitSymbol": "1,\\|",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "销冠品牌",
+        "column": "bestSellingBrand",
+        "splitSymbol": " ",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "卖家",
+        "column": "sourceFrom",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "金额",
+        "column": "priceStr",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "网站名",
+        "column": "sellPlatform",
+        "splitSymbol": "\\|",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "产品网页链接",
+        "column": "platformLink",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "关键词",
+        "column": "searchCondition",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "LOC分类号",
+        "column": "locNum",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "产品分类",
+        "column": "categoryList",
+        "splitSymbol": ">",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      }
+    ]
+  }
+]

+ 77 - 10
src/main/resources/mapper/ProductMapper.xml

@@ -5,12 +5,12 @@
     <select id="getProductByCategory" resultType="com.example.xiaoshiweixinback.entity.vo.ProductVO">
         select distinct p.id as id,p.name as name,p.description as description,p.sell_platform as sellPlatform,pe.name
         as createName ,p.create_time as createTime,p.best_selling_brand as bestSellingBrand,p.price as
-        price,p.platform_link as platformLink
+        price,p.platform_link as platformLink,apc.product_category_id as productCategoryId,p.if_show as ifShow
         from product as p
         left join asso_product_category as apc on p.id =product_id
         left join person as pe on p.create_id =pe.uuid
         <where>
-            p.if_hot = true and p.if_show = true and p.search_condition IS NOT NULL and p.search_condition != ''
+            p.if_hot = true  and p.search_condition IS NOT NULL and p.search_condition != ''
             <if test="getProductDTO.name!=null and getProductDTO.name!=''">
                 and p.name like CONCAT('%',#{getProductDTO.name},'%')
             </if>
@@ -20,12 +20,6 @@
                     #{item}
                 </foreach>
             </if>
-            <if test="getProductDTO.current!=null and getProductDTO.size!=null">
-                limit ${(getProductDTO.current -1)*getProductDTO.size},${getProductDTO.size}
-            </if>
-            <if test="getProductDTO.ifShow!=null">
-                and p.if_show =#{getProductDTO.ifShow}
-            </if>
             <if test="getProductDTO.ifShow!=null">
                 and p.if_show =#{getProductDTO.ifShow}
             </if>
@@ -42,6 +36,11 @@
             <if test="getProductDTO.bestSellingBrand!=null and getProductDTO.bestSellingBrand!=''">
                 and p.best_selling_brand like CONCAT('%',#{getProductDTO.bestSellingBrand},'%')
             </if>
+            order by p.create_time desc
+            <if test="getProductDTO.current!=null and getProductDTO.size!=null">
+                limit ${(getProductDTO.current -1)*getProductDTO.size},${getProductDTO.size}
+            </if>
+
 
         </where>
 
@@ -53,7 +52,7 @@
         asso_product_category as apc on p.id =product_id
         left join person as pe on p.create_id =pe.uuid
         <where>
-            p.if_hot = true and p.if_show =true and p.search_condition IS NOT NULL and p.search_condition != ''
+            p.if_hot = true  and p.search_condition IS NOT NULL and p.search_condition != ''
             <if test="getProductDTO.name!=null and getProductDTO.name!=''">
                 and p.name like CONCAT('%',#{getProductDTO.name},'%')
             </if>
@@ -63,6 +62,22 @@
                     #{item}
                 </foreach>
             </if>
+            <if test="getProductDTO.ifShow!=null">
+                and p.if_show =#{getProductDTO.ifShow}
+            </if>
+
+            <if test="getProductDTO.productCategoryIds!=null and getProductDTO.productCategoryIds.size()>0">
+                and apc.product_category_id in
+                <foreach collection="getProductDTO.productCategoryIds" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="getProductDTO.sourceFrom!=null and getProductDTO.sourceFrom!=''">
+                and p.source_from like CONCAT('%',#{getProductDTO.sourceFrom},'%')
+            </if>
+            <if test="getProductDTO.bestSellingBrand!=null and getProductDTO.bestSellingBrand!=''">
+                and p.best_selling_brand like CONCAT('%',#{getProductDTO.bestSellingBrand},'%')
+            </if>
         </where>
         ) as c
 
@@ -101,7 +116,7 @@
         select count(*) from ( select distinct p.id as id,p.name as name,p.description as description,p.sell_platform as
         sellPlatform,pe.name
         as createName ,p.create_time as createTime,p.best_selling_brand as bestSellingBrand,p.price as
-        price,p.platform_link as platformLink
+        price,p.platform_link as platformLink,p.source_from as sourceFrom
         from
         asso_person_product as app
         left join product as p on app.product_id =p.id
@@ -119,4 +134,56 @@
         ) as c
 
     </select>
+
+
+    <select id="getMonitoringProduct" resultType="com.example.xiaoshiweixinback.entity.vo.ProductVO">
+        select distinct p.id as id,p.name as name,p.description as description,p.sell_platform as sellPlatform,pe.name
+        as createName ,p.create_time as createTime,p.best_selling_brand as bestSellingBrand,p.price as
+        price,p.platform_link as platformLink,p.if_hot as ifHot,app.id as assoId,app.monitor_period as monitorPeriod
+        from
+        monitor as app
+        left join product as p on app.product_id =p.id
+        left join person as pe on p.create_id =pe.uuid
+        <where>
+            app.create_id  = #{getProductDTO.personUuid}
+            <if test="getProductDTO.name!=null and getProductDTO.name!=''">
+                and p.name like CONCAT('%',#{getProductDTO.name},'%')
+            </if>
+
+            <if test="getProductDTO.concernTypes!=null and getProductDTO.concernTypes.size()>0">
+                and app.concern_type in
+                <foreach collection="getProductDTO.concernTypes" index="index" item="item" open="(" separator="," close=") ">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="getProductDTO.current!=null and getProductDTO.size!=null">
+                limit ${(getProductDTO.current -1)*getProductDTO.size},${getProductDTO.current*getProductDTO.size}
+            </if>
+        </where>
+
+    </select>
+
+
+    <select id="getMonitoringProductCount" resultType="java.lang.Long">
+        select count(*) from ( select distinct p.id as id,p.name as name,p.description as description,p.sell_platform as
+        sellPlatform,pe.name
+        as createName ,p.create_time as createTime,p.best_selling_brand as bestSellingBrand,p.price as
+        price,p.platform_link as platformLink,p.source_from as sourceFrom
+        from
+        monitor as app
+        left join product as p on app.product_id =p.id
+        left join person as pe on p.create_id =pe.uuid
+        <where>
+            app.create_id = #{getProductDTO.personUuid}
+            <if test="getProductDTO.name!=null and getProductDTO.name!=''">
+                and p.name like CONCAT('%',#{getProductDTO.name},'%')
+            </if>
+
+            <if test="getProductDTO.current!=null and getProductDTO.size!=null">
+                limit ${(getProductDTO.current -1)*getProductDTO.size},${getProductDTO.current*getProductDTO.size}
+            </if>
+        </where>
+        ) as c
+
+    </select>
 </mapper>

+ 59 - 0
src/test/java/com/example/xiaoshiweixinback/ImportProductTests.java

@@ -0,0 +1,59 @@
+package com.example.xiaoshiweixinback;
+
+import com.example.xiaoshiweixinback.business.utils.parseQueryToTree.expressManager;
+import com.example.xiaoshiweixinback.business.utils.parseQueryToTree.treeNode;
+import com.example.xiaoshiweixinback.entity.ops.ImagesInfoVO;
+import com.example.xiaoshiweixinback.entity.ops.PubNo;
+import com.example.xiaoshiweixinback.service.common.OPSService;
+import com.example.xiaoshiweixinback.service.importPatent.excel.GetPatentFromSzService;
+import com.example.xiaoshiweixinback.service.importPatent.excel.ImportProductService;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Lazy;
+
+import java.util.List;
+
+
+@SpringBootTest
+class ImportProductTests {
+
+    @Autowired
+    @Lazy
+    private ImportProductService importProduct;
+
+    @Autowired
+    private GetPatentFromSzService getPatentFromSzService;
+    @Autowired
+    private OPSService opsService;
+    @Test
+    void contextLoads() {
+        String condition ="TI=ni $W5 (hao OR ya)";
+        try {
+            treeNode tree = expressManager.getInstance().Parse(condition, false);
+System.out.println(tree);
+        }
+        catch (Exception e){}
+    }
+
+    @Test
+    public void test1() {
+        PubNo pubNo =new PubNo();
+        pubNo.setCountry("US");
+        pubNo.setNumber("D942334");
+        pubNo.setKind("S");
+
+
+//        USD942334S
+try {
+    List<ImagesInfoVO>  imagesInfoVOS =opsService.getImageInfos("USD942334S");
+    ImagesInfoVO infoVO = imagesInfoVOS.stream().filter(item -> item.getImageType().equals("Drawing")).findFirst().orElse(null);
+ opsService.getImages(infoVO,"USD942334S");
+
+    System.out.println(imagesInfoVOS);
+}
+    catch (Exception e){
+    e.printStackTrace();
+    }
+    }
+}

+ 0 - 2
src/test/java/com/example/xiaoshiweixinback/NoticeServiceTest.java

@@ -2,11 +2,9 @@ package com.example.xiaoshiweixinback;
 
 import com.example.xiaoshiweixinback.entity.shortMessage.ShortMessageVO;
 import com.example.xiaoshiweixinback.service.common.NoticeService;
-import com.example.xiaoshiweixinback.service.importPatent.excel.ImportProduct;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Lazy;
 
 @SpringBootTest
 public class NoticeServiceTest {

+ 0 - 1
src/test/java/com/example/xiaoshiweixinback/TicketServiceTests.java

@@ -2,7 +2,6 @@ package com.example.xiaoshiweixinback;
 
 import com.example.xiaoshiweixinback.service.OrderService;
 import com.example.xiaoshiweixinback.service.importPatent.excel.GetPatentFromSzService;
-import com.example.xiaoshiweixinback.service.importPatent.excel.ImportProduct;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;

+ 0 - 0
src/test/java/com/example/xiaoshiweixinback/XiaoshiWeixinbackApplicationTests.java


Некоторые файлы не были показаны из-за большого количества измененных файлов