Przeglądaj źródła

4/23 工单修改

lwhhszx 1 rok temu
rodzic
commit
cddaf034eb
30 zmienionych plików z 704 dodań i 129 usunięć
  1. 1 1
      src/main/java/com/example/xiaoshiweixinback/business/common/ResponseEnum.java
  2. 13 0
      src/main/java/com/example/xiaoshiweixinback/business/config/WebSocketConfig.java
  3. 114 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/WebSocketServer.java
  4. 0 40
      src/main/java/com/example/xiaoshiweixinback/controller/ImportController.java
  5. 8 0
      src/main/java/com/example/xiaoshiweixinback/controller/ImportPatentController.java
  6. 18 1
      src/main/java/com/example/xiaoshiweixinback/controller/ProductCategoryController.java
  7. 17 1
      src/main/java/com/example/xiaoshiweixinback/controller/ProductController.java
  8. 40 0
      src/main/java/com/example/xiaoshiweixinback/controller/TemplateController.java
  9. 64 0
      src/main/java/com/example/xiaoshiweixinback/domain/ImportTask.java
  10. 46 0
      src/main/java/com/example/xiaoshiweixinback/domain/Template.java
  11. 8 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/TemplateDTO.java
  12. 16 0
      src/main/java/com/example/xiaoshiweixinback/entity/product/UploadCategoryParamsVO.java
  13. 12 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/TemplateVO.java
  14. 35 0
      src/main/java/com/example/xiaoshiweixinback/entity/websocket/TaskWebSocketDTO.java
  15. 19 0
      src/main/java/com/example/xiaoshiweixinback/entity/websocket/WebSocketMessageVO.java
  16. 19 0
      src/main/java/com/example/xiaoshiweixinback/mapper/ImportTaskMapper.java
  17. 18 0
      src/main/java/com/example/xiaoshiweixinback/mapper/TemplateMapper.java
  18. 54 0
      src/main/java/com/example/xiaoshiweixinback/service/ImportTaskService.java
  19. 2 2
      src/main/java/com/example/xiaoshiweixinback/service/ProductCategoryService.java
  20. 41 0
      src/main/java/com/example/xiaoshiweixinback/service/TemplateService.java
  21. 1 3
      src/main/java/com/example/xiaoshiweixinback/service/common/FileManagerService.java
  22. 42 0
      src/main/java/com/example/xiaoshiweixinback/service/common/MessageService.java
  23. 1 1
      src/main/java/com/example/xiaoshiweixinback/service/common/OPSService.java
  24. 0 1
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/GetPatentPictureFromExcelService.java
  25. 1 1
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetOPSFileByExcelService.java
  26. 57 12
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetPatentFromSzService.java
  27. 37 19
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProductCategoryService.java
  28. 19 4
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProductService.java
  29. 1 1
      src/main/resources/application-dev.yml
  30. 0 42
      src/main/resources/jsons/uploadCategory.json

+ 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,"检索式错误");
 

+ 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();
+    }
+}

+ 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 - 40
src/main/java/com/example/xiaoshiweixinback/controller/ImportController.java

@@ -1,40 +0,0 @@
-package com.example.xiaoshiweixinback.controller;
-
-import com.example.xiaoshiweixinback.business.common.Constants;
-import com.example.xiaoshiweixinback.business.common.Response;
-import com.example.xiaoshiweixinback.business.utils.FileUtils;
-import com.example.xiaoshiweixinback.service.importPatent.excel.GetOPSFileByExcelService;
-import com.example.xiaoshiweixinback.service.importPatent.excel.GetPatentFromSzService;
-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;
-
-@Slf4j
-@RequestMapping(Constants.XIAOSHI_WEIXINBACK + "/import")
-@RestController
-@RequiredArgsConstructor
-public class ImportController {
-    private final GetOPSFileByExcelService getOPSFileByExcelService;
-private final GetPatentFromSzService getPatentFromSzService;
-private final ImportProductService importProductService;
-    @Operation(summary = "导入产品")
-    @PostMapping("/importProduct")
-    private Response importProduct(@RequestBody MultipartFile file) throws Exception {
-      File newFile=  FileUtils.multipartFileToFile(file);
-        importProductService.importProject(newFile);
-        return Response.success("records");
-    }
-
-    @Operation(summary = "导入产品类别")
-    @PostMapping("/importProductCategory")
-    private Response importProductCategory(@RequestBody MultipartFile file) throws Exception {
-        File newFile=  FileUtils.multipartFileToFile(file);
-        importProductService.importProject(newFile);
-        return Response.success("records");
-    }
-}

+ 8 - 0
src/main/java/com/example/xiaoshiweixinback/controller/ImportPatentController.java

@@ -44,4 +44,12 @@ private final GetPatentFromSzService getPatentFromSzService;
         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");
+    }
+
 }

+ 18 - 1
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,7 +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")
     public Response queryProductCategory(@RequestBody ProductCategoryDTO productCategoryDTO) {
@@ -98,4 +105,14 @@ 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);
+        return Response.success("records");
+    }
+
 }

+ 17 - 1
src/main/java/com/example/xiaoshiweixinback/controller/ProductController.java

@@ -5,19 +5,25 @@ 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.*;
 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
@@ -27,7 +33,8 @@ import java.util.List;
 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) {
@@ -127,4 +134,13 @@ public class ProductController {
         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);
+        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);
+    }
+
+
+}

+ 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;
+
+}

+ 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;
+}

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

@@ -7,4 +7,20 @@ 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;
 }

+ 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;
+}

+ 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;
+}

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

@@ -0,0 +1,19 @@
+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;
+}

+ 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/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> {
+
+}
+
+
+
+

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

@@ -0,0 +1,54 @@
+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.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.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("\\.");
+
+        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.insert();
+        return importTask;
+
+
+    }
+
+}
+
+
+
+

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

@@ -576,7 +576,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
     }
 
 
-    public Integer addCategorysByStr(List<String> categorys) {
+    public ProductCategory addCategorysByStr(List<String> categorys) {
 
         if(categorys==null||categorys.size()==0){
             return  null;
@@ -614,7 +614,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
             last = productCategory;
             parentId =last.getId();
         }
-        return last.getId();
+        return last;
 
     }
 }

+ 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();
     }
 

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

@@ -0,0 +1,42 @@
+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 {
+
+
+
+    //发送导出PDF首页消息
+    public void sendImportTaskDone(WebSocketMessageVO webSocketMessageVO) {
+        //通过WebSocket 在每一次循环结束后 向前端发送完成进度
+        //当任务状态为完成时,flag为true
+        long percentage = (long) Math.floor((webSocketMessageVO.getCurrentNum() + 0D) / webSocketMessageVO.getAllNum() * 100D);
+        boolean flag = webSocketMessageVO.getState().equals(2);
+
+        TaskWebSocketDTO taskWebSocketDTO = new TaskWebSocketDTO();
+        taskWebSocketDTO.setComplete(flag);
+        taskWebSocketDTO.setIndex(webSocketMessageVO.getCurrentNum());
+        taskWebSocketDTO.setPercentage(percentage);
+        taskWebSocketDTO.setTaskId(webSocketMessageVO.getTaskId());
+        taskWebSocketDTO.setTaskStatus(webSocketMessageVO.getState());
+        if(flag) {
+            WebSocketServer.sendInfo(Response.websocket(taskWebSocketDTO, ResponseEnum.IMPORT_TASK), webSocketMessageVO.getCreateId());
+            return;
+        }
+        WebSocketServer.sendInfo(Response.websocket(taskWebSocketDTO, ResponseEnum.IMPORT_TASK), webSocketMessageVO.getCreateId());
+    }
+
+}

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

@@ -89,7 +89,7 @@ public class OPSService {
 
 
     public void getImages(ImagesInfoVO image, String publicNo) throws Exception {
-        String rootPath = "D:\\patentImage\\202205-501-1000\\";
+        String rootPath = "D:\\patentImage\\202205-3001-3498\\";
         if (image != null) {
             Integer num = image.getNumberOfPages();
             for (int i = 1; i < num + 1; i++) {

+ 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);
 

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

@@ -45,7 +45,7 @@ public class GetOPSFileByExcelService {
 
             List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
 
-            for (int r = 332; r < total; r++) {
+            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++) {

+ 57 - 12
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);
@@ -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);
@@ -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);
             //获得总列数
 
         }

+ 37 - 19
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProductCategoryService.java

@@ -4,15 +4,20 @@ import cn.hutool.core.util.IdUtil;
 import com.example.xiaoshiweixinback.business.exception.BusinessException;
 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;
@@ -28,22 +33,20 @@ import java.util.Map;
 @Service
 public class ImportProductCategoryService {
 
-    @Autowired
-    private ProductService productService;
 
     @Autowired
     private FileManagerService fileManagerService;
-    @Autowired
-    private AssoProductFileService assoProductFileService;
+
     @Autowired
     private ExcuteUploadSettingService excuteUploadSettingService;
 
     @Autowired
     private ProductCategoryService productCategoryService;
-
-    public void importProductCategory(File tempFile) {
+   @Autowired
+   private MessageService messageService;
+    public void importProductCategory(File tempFile, ImportTask importTask) {
         try {
-            PersonnelVO personnelVO =new PersonnelVO();
+            PersonnelVO personnelVO = new PersonnelVO();
             personnelVO.setUuid("123");
             Sheet sheet = ReadExcelUtils.readExcel(tempFile);
             Integer total = ReadExcelUtils.getExcelTotal(sheet);
@@ -54,17 +57,29 @@ public class ImportProductCategoryService {
                 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) {
+                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;
+                }
 
-                HotProductAddDTO hotProductAddDTO = this.loadCategoryAddVO(uploadParamsVO, pictureDataList);
+
+
+                EditCategoryDTO editCategoryDTO = this.loadCategoryAddVO(uploadParamsVO, pictureDataList);
                 try {
-                    productService.addOrUpdateHotProduct(hotProductAddDTO,personnelVO.getUuid());
+                    productCategoryService.editCategory(editCategoryDTO);
                 } catch (Exception e) {
                     continue;
                 }
+                WebSocketMessageVO webSocketMessageVO =new WebSocketMessageVO();
+                webSocketMessageVO.setTaskId(importTask.getId());
+                webSocketMessageVO.setAllNum(total);
+                webSocketMessageVO.setState(2);
+                webSocketMessageVO.setCreateId(importTask.getCreateId());
+              messageService.sendImportTaskDone(webSocketMessageVO);
             }
         } catch (Exception e) {
         }
@@ -72,13 +87,12 @@ public class ImportProductCategoryService {
 
     }
 
-    private HotProductAddDTO loadCategoryAddVO(UploadCategoryParamsVO uploadParamsVO, List<PictureData> pictureDataList) throws Exception {
-        Integer categoryId = productCategoryService.addCategorysByStr(uploadParamsVO.getCategoryList());
+    private EditCategoryDTO loadCategoryAddVO(UploadCategoryParamsVO uploadParamsVO, List<PictureData> pictureDataList) throws Exception {
+        ProductCategory productCategory = productCategoryService.addCategorysByStr(uploadParamsVO.getCategoryList());
+
+        EditCategoryDTO editCategoryDTO = new EditCategoryDTO();
+        BeanUtils.copyProperties(uploadParamsVO, editCategoryDTO);
 
-        HotProductAddDTO hotProductAddDTO = new HotProductAddDTO();
-        BeanUtils.copyProperties(uploadParamsVO, hotProductAddDTO);
-        hotProductAddDTO.setIfHot(true);
-        hotProductAddDTO.getFileGuids();
         List<String> fileIds = new ArrayList<>();
         for (PictureData pictureData : pictureDataList) {
             String ext = pictureData.suggestFileExtension();
@@ -93,8 +107,12 @@ public class ImportProductCategoryService {
             }
 
         }
-        hotProductAddDTO.setFileGuids(fileIds);
-        hotProductAddDTO.setProductCategoryId(categoryId);
-        return hotProductAddDTO;
+        editCategoryDTO.setFileGuids(fileIds);
+       editCategoryDTO.setName(productCategory.getName());
+        if(productCategory!=null) {
+            editCategoryDTO.setId(productCategory.getId());
+            editCategoryDTO.setParentId(productCategory.getParentId());
+        }
+        return editCategoryDTO;
     }
 }

+ 19 - 4
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProductService.java

@@ -4,14 +4,18 @@ import cn.hutool.core.util.IdUtil;
 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;
@@ -25,6 +29,8 @@ 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
@@ -42,8 +48,9 @@ public class ImportProductService {
 
     @Autowired
     private ProductCategoryService productCategoryService;
-
-    public void importProject(File tempFile) {
+    @Autowired
+    private MessageService messageService;
+    public void importProject(File tempFile, ImportTask importTask) {
         try {
             PersonnelVO personnelVO =new PersonnelVO();
             personnelVO.setUuid("123");
@@ -67,6 +74,12 @@ public class ImportProductService {
                 } catch (Exception e) {
                     continue;
                 }
+                WebSocketMessageVO webSocketMessageVO =new WebSocketMessageVO();
+                webSocketMessageVO.setTaskId(importTask.getId());
+                webSocketMessageVO.setAllNum(total);
+                webSocketMessageVO.setState(2);
+                webSocketMessageVO.setCreateId(importTask.getCreateId());
+                messageService.sendImportTaskDone(webSocketMessageVO);
             }
         } catch (Exception e) {
         }
@@ -93,7 +106,7 @@ public class ImportProductService {
 
 
     private HotProductAddDTO loadProductAddVO(UploadProductParamsVO uploadParamsVO, List<PictureData> pictureDataList) throws Exception {
-        Integer categoryId = productCategoryService.addCategorysByStr(uploadParamsVO.getCategoryList());
+        ProductCategory productCategory = productCategoryService.addCategorysByStr(uploadParamsVO.getCategoryList());
 
         HotProductAddDTO hotProductAddDTO = new HotProductAddDTO();
         BeanUtils.copyProperties(uploadParamsVO, hotProductAddDTO);
@@ -114,7 +127,9 @@ public class ImportProductService {
 
         }
         hotProductAddDTO.setFileGuids(fileIds);
-        hotProductAddDTO.setProductCategoryId(categoryId);
+        if(productCategory!=null) {
+            hotProductAddDTO.setProductCategoryId(productCategory.getId());
+        }
         return hotProductAddDTO;
     }
 }

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

@@ -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

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

@@ -5,13 +5,6 @@
     "name": "亚马逊",
     "column": [
       {
-        "setName": "产品名称",
-        "column": "name",
-        "splitSymbol": "",
-        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
-        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
-      },
-      {
         "setName": "描述",
         "column": "description",
         "splitSymbol": "1,\\|",
@@ -19,41 +12,6 @@
         "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": "",