Ver Fonte

4/10 登录修改

lwhhszx há 1 ano atrás
pai
commit
3a15568752
41 ficheiros alterados com 1944 adições e 40 exclusões
  1. 5 2
      src/main/java/com/example/xiaoshiweixinback/business/utils/CacheUtil.java
  2. 43 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/DataProcessHandler.java
  3. 183 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/ExcelUtils.java
  4. 68 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/FileUtils.java
  5. 9 8
      src/main/java/com/example/xiaoshiweixinback/business/utils/LoginUtils.java
  6. 281 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/ReadExcelUtils.java
  7. 46 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/DataProcessHandler.java
  8. 5 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IProcessData.java
  9. 23 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IncoPatInventorAddressHandler.java
  10. 59 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IncoPatPatentAffairHandler.java
  11. 17 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IncoPatUCMainHandler.java
  12. 15 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/IntegerHandler.java
  13. 42 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatSnapPatentAffairHandler.java
  14. 24 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatentTypeHandler.java
  15. 23 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatenticsAgencyAndAgentHandler.java
  16. 73 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatenticsPatentAffairHandler.java
  17. 18 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/PatenticsStringHandler.java
  18. 20 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/SplitBySerialNumberAndRemoveLineFeedHandler.java
  19. 28 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/SplitOriginalAndTranslationHandler.java
  20. 22 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/StringHandler.java
  21. 22 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/StringSpecialHandler.java
  22. 18 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/handler/TimeHandler.java
  23. 15 1
      src/main/java/com/example/xiaoshiweixinback/controller/PatentController.java
  24. 4 0
      src/main/java/com/example/xiaoshiweixinback/domain/Product.java
  25. 3 1
      src/main/java/com/example/xiaoshiweixinback/entity/vo/ProductVO.java
  26. 2 6
      src/main/java/com/example/xiaoshiweixinback/service/AssoPersonCategoryService.java
  27. 9 15
      src/main/java/com/example/xiaoshiweixinback/service/LoginService.java
  28. 4 3
      src/main/java/com/example/xiaoshiweixinback/service/TicketService.java
  29. 1 1
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/GetFiguresService.java
  30. 202 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/GetPatentFromExcelService.java
  31. 86 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/GetPatentPictureFromExcelService.java
  32. 37 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ExcuteDataToVOService.java
  33. 31 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ExcuteUploadSettingService.java
  34. 5 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/IProcessData.java
  35. 25 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/PatentData.java
  36. 22 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/StringSpecialHandler.java
  37. 144 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/UploadParamsVO.java
  38. 238 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/UploadPatentBatchUtil.java
  39. 68 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/UploadSettingVO.java
  40. 3 2
      src/main/resources/application-prodNetIn.yml
  41. 1 1
      src/main/resources/mapper/ProductMapper.xml

+ 5 - 2
src/main/java/com/example/xiaoshiweixinback/business/utils/CacheUtil.java

@@ -12,8 +12,11 @@ public class CacheUtil {
     private RedisUtil redisUtil;
 
 
-    public PersonnelVO getLoginUser(Object userId) {
-        String json = redisUtil.get(RedisConf.LOGIN_USER + RedisConf.SYMBOL_COLON + userId);
+    public void setLoginUser(PersonnelVO personnelVO,String token) {
+        redisUtil.set(token, JsonUtils.objectToJson(personnelVO));
+    }
+    public PersonnelVO getLoginUser(String token) {
+        String json = redisUtil.get(token);
         if (StringUtils.isEmpty(json)) {
             throw new NotLoginException("无数据", "user", "");
         } else {

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

@@ -0,0 +1,43 @@
+package com.example.xiaoshiweixinback.business.utils;
+
+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;
+    }
+
+
+}
+
+
+
+

+ 183 - 0
src/main/java/com/example/xiaoshiweixinback/business/utils/ExcelUtils.java

@@ -0,0 +1,183 @@
+package com.example.xiaoshiweixinback.business.utils;
+
+import cn.hutool.core.util.IdUtil;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.ooxml.POIXMLDocumentPart;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.*;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
+
+import java.awt.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ExcelUtils {
+
+    public static Map<String, PictureData> getDataFromExcel(String filePath) throws IOException {
+        //判断是否为excel类型文件
+        if (!filePath.endsWith(".xls") && !filePath.endsWith(".xlsx") && !filePath.endsWith(".XLS") && !filePath.endsWith(".XLSX")) {
+            System.out.println("文件不是excel类型");
+        }
+
+        FileInputStream fis = null;
+        Workbook wookbook = null;
+        Sheet sheet = null;
+        try {
+            //获取一个绝对地址的流
+            fis = new FileInputStream(filePath);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        try {
+            //2003版本的excel,用.xls结尾
+            wookbook = new HSSFWorkbook(fis);//得到工作簿
+        } catch (Exception ex) {
+            //ex.printStackTrace();
+            try {
+                //2007版本的excel,用.xlsx结尾
+                fis = new FileInputStream(filePath);
+                wookbook = new XSSFWorkbook(fis);//得到工作簿
+            } catch (IOException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+        }
+        Map<String, PictureData> maplist = null;
+        //拿到excel表格的第一个sheet工作簿
+        sheet = wookbook.getSheetAt(0);
+        // 判断用07还是03的方法获取图片
+        if (filePath.endsWith(".xls") || filePath.endsWith(".XLS")) {
+            maplist = getPictures1((HSSFSheet) sheet);
+        } else if (filePath.endsWith(".xlsx") || filePath.endsWith(".XLSX")) {
+            maplist = getPictures2((XSSFSheet) sheet);
+        }
+        wookbook.close();
+        return maplist;
+    }
+
+    /**
+     * 获取图片和位置 (xls)
+     *
+     * @param sheet
+     * @return
+     * @throws IOException
+     */
+    public static Map<String, PictureData> getPictures1(HSSFSheet sheet) throws IOException {
+        Map<String, PictureData> map = new HashMap();
+        if (sheet.getDrawingPatriarch() != null) {
+            List<HSSFShape> list = sheet.getDrawingPatriarch().getChildren();
+            for (HSSFShape shape : list) {
+                if (shape instanceof HSSFPicture) {
+                    HSSFPicture picture = (HSSFPicture) shape;
+                    HSSFClientAnchor cAnchor = (HSSFClientAnchor) picture.getAnchor();
+                    PictureData pdata = picture.getPictureData();
+                    String key = String.valueOf(cAnchor.getRow1());
+                    map.put(key, pdata);
+                }
+            }
+        }
+        return map;
+    }
+
+    /**
+     * 获取图片和位置 (xlsx)
+     *
+     * @param sheet
+     * @return
+     * @throws IOException
+     */
+    public static Map<String, PictureData> getPictures2(XSSFSheet sheet) throws IOException {
+        Map<String, PictureData> map = new HashMap();
+        List<POIXMLDocumentPart> list = sheet.getRelations();
+        for (POIXMLDocumentPart part : list) {
+            if (part instanceof XSSFDrawing) {
+                XSSFDrawing drawing = (XSSFDrawing) part;
+                List<XSSFShape> shapes = drawing.getShapes();
+                for (XSSFShape shape : shapes) {
+                    XSSFPicture picture = (XSSFPicture) shape;
+                    Dimension d = picture.getImageDimension();
+                    //解决图片空指针报错问题 lig  2021-06-03
+                    XSSFClientAnchor anchor = (XSSFClientAnchor) shape.getAnchor();
+                    //XSSFClientAnchor anchor = picture.getPreferredSize();
+                    CTMarker marker = anchor.getFrom();
+                    String key = String.valueOf(marker.getRow());
+                    map.put(key, picture.getPictureData());
+                }
+            }
+        }
+        return map;
+    }
+
+//    /**
+//     * @param pictureData 图片
+//     * @return 返回图片的文件路径和文件名称
+//     */
+//    public static Map<String, String> savePicture(PictureData pictureData) throws IOException {
+//        FileUtils fileUtils = SpringUtils.getBean(FileUtils.class);
+//        Map<String, String> result = new HashMap<>();
+//        String ext = pictureData.suggestFileExtension();
+//        byte[] data = pictureData.getData();
+//        String picName = IdUtil.simpleUUID() + "." + ext;
+//        String date = DateUtils.getNowTimeFormat("yyyyMMdd");
+//        String folderPath = fileUtils.getSavePath(date);
+//        String filePath = FileUtils.FILE_SEPARATOR + date + FileUtils.FILE_SEPARATOR + picName;
+//        File directory = new File(folderPath);
+//        if (!directory.exists()) {
+//            directory.mkdir();
+//        }
+//        FileOutputStream out = new FileOutputStream(folderPath + picName);
+//        out.write(data);
+//        out.close();
+//        result.put("path", filePath);
+//        result.put("name", picName);
+//        return result;
+//    }
+
+    /**
+     * @param
+     * @param x           单元格x轴坐标
+     * @param y           单元格y轴坐标
+     * @param pictureData 图片二进制数据
+     * @param picType     图片格式
+     */
+    public static void writePicture(Sheet sheet, int x, int y, byte[] pictureData, int picType) {
+        Drawing drawingPatriarch = sheet.createDrawingPatriarch();
+        //设置图片单元格位置
+        ClientAnchor anchor = drawingPatriarch.createAnchor(0, 0, 0, 0, x, y, x + 1, y + 1);
+        //随单元格改变位置和大小
+        anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
+        //添加图片
+        int pictureIndex = sheet.getWorkbook().addPicture(pictureData, picType);
+        drawingPatriarch.createPicture(anchor, pictureIndex);
+    }
+
+    public static void setExcelCellStyle(HSSFCellStyle cellStyle) {
+        cellStyle.setBorderBottom(BorderStyle.THIN);
+        cellStyle.setBorderLeft(BorderStyle.THIN);
+        cellStyle.setBorderRight(BorderStyle.THIN);
+        cellStyle.setBorderTop(BorderStyle.THIN);
+    }
+
+    public static String getValue(Cell cell) {
+        if (cell != null) {
+            if (cell.getCellType() == CellType.NUMERIC && HSSFDateUtil.isCellDateFormatted(cell)) {
+                Date date = cell.getDateCellValue();
+                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                String dateString = dateFormat.format(date);
+                return dateString;
+            } else {
+                return cell.toString();
+            }
+        }
+        return "";
+    }
+
+
+}

+ 68 - 0
src/main/java/com/example/xiaoshiweixinback/business/utils/FileUtils.java

@@ -56,4 +56,72 @@ public class FileUtils {
         in.close();
         return file;
     }
+    public String analysisJsonFile() {
+        ApplicationHome ah = new ApplicationHome(ToolUtil.class);
+        File file = ah.getSource();
+        String settingFilePath = file.getParentFile().toString() + FileUtils.FILE_SEPARATOR + "uploadSetting.json";
+        BufferedReader reader = null;
+        StringBuilder last = new StringBuilder();
+        InputStreamReader inputStreamReader;
+        try (FileInputStream fileInputStream = new FileInputStream(settingFilePath)) {
+            inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8);
+
+            reader = new BufferedReader(inputStreamReader);
+            String tempString;
+            while ((tempString = reader.readLine()) != null) {
+                last.append(tempString);
+            }
+            reader.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (reader != null) {
+                try {
+                    reader.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return last.toString();
+    }
+    public static   File  getFileByBytes(byte[] bytes, String prefix, String suffix) {
+        BufferedOutputStream bos = null;
+        FileOutputStream fos = null;
+        File file = null;
+        try {
+
+            file = File.createTempFile(prefix, suffix);
+
+            //输出流
+            fos = new FileOutputStream(file);
+
+            //缓冲流
+            bos = new BufferedOutputStream(fos);
+
+            //将字节数组写出
+            bos.write(bytes);
+            return file;
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (bos != null) {
+                try {
+                    bos.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (fos != null) {
+                try {
+                    fos.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            return  file;
+        }
+    }
+
+
 }

+ 9 - 8
src/main/java/com/example/xiaoshiweixinback/business/utils/LoginUtils.java

@@ -19,14 +19,15 @@ public class LoginUtils {
         ServletRequestAttributes sra = (ServletRequestAttributes) ra;
         HttpServletRequest httpRequest = sra.getRequest();
         String tem = httpRequest.getHeader("Cookie");
-        List<String> lst = StringUtils.changeStringToString(tem, ";");
-        final String[] token = {null};
-        lst.forEach(item -> {
-            if (item.contains("token")) {
-                token[0] = item;
-            }
-        });
-        return token[0].replaceAll(" ", "");
+        return   tem;
+//        List<String> lst = StringUtils.changeStringToString(tem, ";");
+//        final String[] token = {null};
+//        lst.forEach(item -> {
+//            if (item.contains("token")) {
+//                token[0] = item;
+//            }
+//        });
+//        return token[0].replaceAll(" ", "");
     }
 
     public Integer getId() {

+ 281 - 0
src/main/java/com/example/xiaoshiweixinback/business/utils/ReadExcelUtils.java

@@ -0,0 +1,281 @@
+package com.example.xiaoshiweixinback.business.utils;
+
+
+import com.example.xiaoshiweixinback.service.importPatent.excel.PatentData;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.ooxml.POIXMLDocumentPart;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.*;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @Author xiexiang
+ * @Date 2023/5/30
+ */
+@Service
+public class ReadExcelUtils {
+    /**
+     * 检测Excel文件合法性
+     *
+     * @param tempFile 临时文件
+     * @return 返回文件总行数
+     */
+    public static Integer textExcel(File tempFile, String sourceId) throws IOException {
+        //判断文件是否存在
+        if (!tempFile.exists() || tempFile.getPath().trim().equals("")) {
+        }
+
+        // 检测是否为excel文件
+        String suffix = tempFile.getPath().substring(tempFile.getPath().lastIndexOf("."));
+        if (!suffix.equals(".xls") && !suffix.equals(".xlsx") && !suffix.equals(".XLS") && !suffix.equals(".XLSX")) {
+            //删除临时文件tempFile
+            new File(tempFile.getPath()).delete();
+
+        }
+
+        InputStream fis = new FileInputStream(tempFile);
+        //使用poi框架解析处理Excel文件
+        Workbook workbook = null;
+        //区分不同版本Excel,使用各自对应的工具类
+        if (suffix.equals(".xls") || suffix.equals(".XLS")) {
+            workbook = new HSSFWorkbook(fis);
+        } else if (suffix.equals(".xlsx") || suffix.equals(".XLSX")) {
+            workbook = new XSSFWorkbook(fis);
+        }
+        //读取第几个sheet
+        Sheet sheet = workbook.getSheetAt(0);
+        //读取总行数
+        int rows = sheet.getPhysicalNumberOfRows();
+        if (rows <= 1) {
+            //删除临时文件tempFile
+            fis.close();
+            new File(tempFile.getPath()).delete();
+        }
+
+        //获取第一行抬头
+        Row firstRow = sheet.getRow(0);
+        boolean flag1 = false;  //是否有 "公开(公告)号"
+        boolean flag2 = false;  //是否有 "申请号"
+        //遍历第一行单元格抬头,检查合法性
+        String title = "", source = "";
+        if (sourceId.equals("1")) {
+            source = "智慧芽";
+            title = "公开(公告)号";
+        } else if (sourceId.equals("2")) {
+            source = "合享";
+            title = "公开(公告)号";
+        } else {
+            source = "Patentics";
+            title = "公开号";
+        }
+        for (Cell cell : firstRow) {
+            if (cell.getStringCellValue().equals(title)) {
+                flag1 = true;
+            }
+            if (cell.getStringCellValue().equals("申请号")) {
+                flag2 = true;
+            }
+        }
+        if (!flag1 || !flag2) {
+            //删除临时文件tempFile
+            fis.close();
+            new File(tempFile.getPath()).delete();
+        }
+        //关闭流
+        fis.close();
+        //返回文件总行数-1(即专利总数量)
+        return rows - 1;
+    }
+
+    /**
+     * 获取一行专利的全部数据(专利内容数据 + 摘要附图)
+     *
+     * @param tempFile Excel临时文件
+     * @param row      行数
+     * @return 返回装载专利数据(专利内容数据 + 摘要附图)的对象
+     */
+    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;
+
+        //开始装载专利数据
+        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")) {
+            pictureData = getPictures1((HSSFSheet) sheet, row);
+        } else if (suffix.equals(".xlsx") || suffix.equals(".XLSX")) {
+            pictureData = getPictures2((XSSFSheet) sheet, row);
+        }
+
+        //返回结果对象装载结果
+        patentData.setMap(map);
+        patentData.setPictureData(pictureData);
+
+        return patentData;
+    }
+
+    public static Sheet readExcel(File tempFile) {
+        Sheet sheet = null;
+
+        try {
+            InputStream inputStream = new FileInputStream(tempFile);
+            //POI可以处理Excel文件
+            Workbook workbook = null;
+            //当文件以.xls结尾时
+            String suffix = tempFile.getName().substring(tempFile.getName().lastIndexOf("."));
+            if (suffix.equals(".xls") || suffix.equals(".XLS")) {
+                workbook = new HSSFWorkbook(inputStream);
+            } else if (suffix.equals(".xlsx") || suffix.equals(".XLSX")) {
+                workbook = new XSSFWorkbook(inputStream);
+            }
+
+            //读取第几个sheet
+            sheet = workbook.getSheetAt(0);
+
+            //关闭流
+            inputStream.close();
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        return sheet;
+    }
+
+    /**
+     * 03版本Excel取附图
+     *
+     * @param sheet Excel工作簿
+     * @return 返回附图map
+     */
+    public static PictureData getPictures1(HSSFSheet sheet, Integer row) throws IOException {
+        if (sheet.getDrawingPatriarch() != null) {
+            List<HSSFShape> list = sheet.getDrawingPatriarch().getChildren();
+            for (HSSFShape shape : list) {
+                if (shape instanceof HSSFPicture) {
+                    HSSFPicture picture = (HSSFPicture) shape;
+                    HSSFClientAnchor cAnchor = (HSSFClientAnchor) picture.getAnchor();
+                    int row1 = cAnchor.getRow1();
+                    if (row1 == row) {
+                        return picture.getPictureData();
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 07版本Excel取附图
+     *
+     * @param sheet Excel工作簿
+     * @return 返回附图map
+     */
+    public static PictureData getPictures2(XSSFSheet sheet, Integer row) throws IOException {
+        List<POIXMLDocumentPart> list = sheet.getRelations();
+        for (POIXMLDocumentPart part : list) {
+            if (part instanceof XSSFDrawing) {
+                XSSFDrawing drawing = (XSSFDrawing) part;
+                List<XSSFShape> shapes = drawing.getShapes();
+                for (XSSFShape shape : shapes) {
+                    //解决图片空指针报错问题 lig  2021-06-03
+                    XSSFClientAnchor anchor = (XSSFClientAnchor) shape.getAnchor();
+                    //XSSFClientAnchor anchor = picture.getPreferredSize();
+                    CTMarker marker = anchor.getFrom();
+                    int excelRow = marker.getRow();
+                    if (excelRow == row) {
+                        XSSFPicture picture = (XSSFPicture) shape;
+                        return picture.getPictureData();
+                    }
+                }
+            }
+        }
+
+        return null;
+    }
+
+    public static String getValue(Cell cell) {
+        if (cell != null) {
+            if (cell.getCellType() == CellType.NUMERIC && HSSFDateUtil.isCellDateFormatted(cell)) {
+                Date date = cell.getDateCellValue();
+                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                String dateString = dateFormat.format(date);
+                return dateString;
+            } else {
+                return cell.toString();
+            }
+        }
+        return "";
+    }
+
+
+    /**
+     * @param sheet
+     * @return
+     * @throws IOException
+     */
+    public static List<String> getPatentNoFromExcel(Sheet sheet) throws IOException {
+        List<String> patentNos = new ArrayList<>();
+        int rows = sheet.getPhysicalNumberOfRows();
+        Integer cellId = null;
+        //开始装载专利数据
+        Row firstRow = sheet.getRow(0);
+
+        //查找列
+        int columns = firstRow.getLastCellNum();
+        for (int t = 0; t < columns; t++) {
+            if (firstRow.getCell(t).toString().equals("专利号")) {
+                cellId = t;
+            }
+        }
+        for (int i = 1; i < rows; i++) {
+            Row row = sheet.getRow(i);
+            String patentNo = row.getCell(cellId).toString();
+            patentNos.add(patentNo);
+        }
+        return patentNos;
+    }
+
+
+    public static Integer testNoImport(Sheet sheet) throws IOException {
+        int rows = sheet.getPhysicalNumberOfRows();
+        Integer cellId = null;
+        //开始装载专利数据
+        Row firstRow = sheet.getRow(0);
+
+        //查找列
+        int columns = firstRow.getLastCellNum();
+        for (int t = 0; t < columns; t++) {
+            if (firstRow.getCell(t).toString().equals("专利号")) {
+                cellId = t;
+            }
+        }
+
+        if(cellId!=null&&rows==1){
+            cellId=-1;
+        }
+        return cellId;
+    }
+
+
+}

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

@@ -0,0 +1,46 @@
+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("启动成功");
+    }
+
+}
+
+
+
+

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

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

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

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

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

@@ -0,0 +1,59 @@
+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();
+    }
+}

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

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

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

@@ -0,0 +1,15 @@
+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());
+    }
+}

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

@@ -0,0 +1,42 @@
+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();
+    }
+}

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

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

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

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

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

@@ -0,0 +1,73 @@
+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();
+    }
+}

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

@@ -0,0 +1,18 @@
+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(" ", "");
+        }
+    }
+}

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

@@ -0,0 +1,20 @@
+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());
+    }
+}

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

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

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

@@ -0,0 +1,22 @@
+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();
+        }
+    }
+}

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

@@ -0,0 +1,22 @@
+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();
+        }
+    }
+}

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

@@ -0,0 +1,18 @@
+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());
+    }
+}

+ 15 - 1
src/main/java/com/example/xiaoshiweixinback/controller/PatentController.java

@@ -11,6 +11,7 @@ import com.example.xiaoshiweixinback.entity.product.ProductIdDTO;
 import com.example.xiaoshiweixinback.entity.vo.esPicture.EsPictureNoVo;
 import com.example.xiaoshiweixinback.service.common.EsDenseVectorService;
 import com.example.xiaoshiweixinback.service.common.FileManagerService;
+import com.example.xiaoshiweixinback.service.importPatent.GetPatentFromExcelService;
 import com.example.xiaoshiweixinback.service.importPatent.ImportFromWebToEsService;
 import io.swagger.v3.oas.annotations.Operation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,7 +33,8 @@ public class PatentController {
 
     @Autowired
     private EsDenseVectorService esDenseVectorService;
-
+    @Autowired
+    private GetPatentFromExcelService getPatentFromExcelService;
     @Operation(summary = "导入专利")
     @GetMapping(value = "/importPatent")
     public Response queryPatent(@RequestBody ImportTaskAMVO importTaskAMVO) {
@@ -58,4 +60,16 @@ public class PatentController {
         List<EsPictureNoVo> pictureByNo = esDenseVectorService.getPictureByNo(pictureNoDTO);
         return Response.success(pictureByNo);
     }
+
+    @Operation(summary = "excel导入")
+    @GetMapping(value = "/importPatentE")
+    public Response importPatentE(String path) {
+        try {
+            getPatentFromExcelService.run(path);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Response.success("");
+    }
+
 }

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

@@ -59,6 +59,9 @@ public class Product extends BaseEntity<Product> {
      */
     private Boolean ifCustomized;
 
+    private String bestSellingBrand;
+    private Double price;
+    private String platformLink;
     /**
      * 
      */
@@ -69,4 +72,5 @@ public class Product extends BaseEntity<Product> {
      */
     private DateTime createTime;
 
+
 }

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

@@ -46,7 +46,9 @@ public class ProductVO {
      *
      */
     private Date createTime;
-
+    private String bestSellingBrand;
+    private Double price;
+    private String platformLink;
     @Schema(description = "文件信息")
     private List<SystemFile> systemFileList;
 }

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

@@ -27,12 +27,11 @@ import java.util.stream.Collectors;
 @RequiredArgsConstructor
 public class AssoPersonCategoryService extends ServiceImpl<AssoPersonCategoryMapper, AssoPersonCategory> {
     private final CacheUtil cacheUtil;
-    private final LoginUtils loginUtils;
 
     public List<Integer> getChoosedProductCategoryIds() {
         List<Integer> ids = new ArrayList<>();
         try {
-           PersonnelVO personnelVO =cacheUtil.getLoginUser(loginUtils.getId());
+           PersonnelVO personnelVO =cacheUtil.getLoginUser(LoginUtils.getToken());
         LambdaQueryWrapper<AssoPersonCategory> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(AssoPersonCategory::getPersonUuid, personnelVO.getUuid());
         List<AssoPersonCategory> assoPersonCategories = this.list(queryWrapper);
@@ -49,10 +48,7 @@ public class AssoPersonCategoryService extends ServiceImpl<AssoPersonCategoryMap
 
     @Transactional(rollbackFor = Exception.class)
     public void concernCategory(ConcernCategoryDTO concernCategoryDTO) {
-        //PersonnelVO personnelVO =cacheUtil.getLoginUser(loginUtils.getId());
-        PersonnelVO personnelVO = new PersonnelVO();
-        personnelVO.setId(5);
-        personnelVO.setUuid("123");
+        PersonnelVO personnelVO =cacheUtil.getLoginUser(LoginUtils.getToken());;
         List<Integer> ids = concernCategoryDTO.getCategoryIds();
 
         LambdaQueryWrapper<AssoPersonCategory> queryWrapper = new LambdaQueryWrapper<>();

+ 9 - 15
src/main/java/com/example/xiaoshiweixinback/service/LoginService.java

@@ -25,6 +25,7 @@ import com.example.xiaoshiweixinback.entity.vo.person.PersonVO;
 import com.example.xiaoshiweixinback.mapper.PersonMapper;
 import com.example.xiaoshiweixinback.okhttp.ResponseManager;
 import com.example.xiaoshiweixinback.service.common.SmsService;
+import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -53,8 +54,6 @@ public class LoginService {
     @Value("${WeChat.appSecret}")
     private String appSecret;
 
-    @Autowired
-    private CacheUtil cacheUtil;
 
     @Autowired
     private LoginUtils loginUtils;
@@ -70,9 +69,12 @@ public class LoginService {
 
     @Autowired
     private PersonMapper personMapper;
+    @Autowired
+    private CacheUtil cacheUtil;
 
     /**
      * 手机号/账号登录
+     *
      * @param dto
      * @return
      */
@@ -106,12 +108,7 @@ public class LoginService {
             person.setPhoneNum(dto.getPhoneNum());
             String uid = IdUtil.simpleUUID();
             person.setUuid(uid);
-            PersonnelVO personnelVO = cacheUtil.getLoginUser(loginUtils.getId());
-            if (ToolUtil.isNotEmpty(personnelVO)) {
-                Integer personId = personnelVO.getId();
-                person.setCreateId(personId.toString());
-            }
-            person.setCreateTime(new Date());
+
             personMapper.insert(person);
 
             loginVO.setId(person.getId());
@@ -175,12 +172,6 @@ public class LoginService {
                     person.setOpenId(jscode2SessionWo.getOpenid());
                     String uid = IdUtil.simpleUUID();
                     person.setUuid(uid);
-                    PersonnelVO personnelVO = cacheUtil.getLoginUser(loginUtils.getId());
-                    if (ToolUtil.isNotEmpty(personnelVO)) {
-                        Integer personId = personnelVO.getId();
-                        person.setCreateId(personId.toString());
-                    }
-                    person.setCreateTime(new Date());
                     person.insert();
                     wxVO.setId(person.getId());
                     wxVO.setIfFirst(true);
@@ -190,7 +181,10 @@ public class LoginService {
             wxVO.setToken(jwtTokenUtil.createToken());
             wxVO.setOpenId(jscode2SessionWo.getOpenid());
 //            redisService.set(AppCacheKeyUtil.getUserIdToken(wxVO.getId()), AppCacheKeyUtil.getTokenUserInfo(wxVO.getToken()));
-            redisService.set(wxVO.getToken(), wxVO.getId());
+            //将用户信息数据存入Redis
+            PersonnelVO personnelVO = new PersonnelVO();
+            BeanUtil.copy(person,personnelVO);
+            cacheUtil.setLoginUser(personnelVO,wxVO.getToken());
         }
         return wxVO;
     }

+ 4 - 3
src/main/java/com/example/xiaoshiweixinback/service/TicketService.java

@@ -40,6 +40,7 @@ public class TicketService extends ServiceImpl<TicketMapper, Ticket> {
 
     /**
      * 新增or更新工单
+     *
      * @param ticketDTO
      * @return
      */
@@ -135,7 +136,7 @@ public class TicketService extends ServiceImpl<TicketMapper, Ticket> {
             queryWrapper.lambda().eq(Ticket::getTicketProgress, process);
         }
         if (isAdmin != null && !isAdmin.equals(true)) {
-            PersonnelVO personnelVO = cacheUtil.getLoginUser(loginUtils.getId());
+            PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
             Integer personType = personnelVO.getPersonType();
             if (personType != null && personType.equals(0)) {
                 queryWrapper.lambda().eq(Ticket::getCreateId, personnelVO.getUuid());
@@ -145,7 +146,7 @@ public class TicketService extends ServiceImpl<TicketMapper, Ticket> {
         IPage<Ticket> ticketPage = this.page(page, queryWrapper);
         List<Ticket> tickets = ticketPage.getRecords();
         List<TicketVO> ticketVOS = this.loadTicketVO(tickets);
-        
+
         Records records = new Records();
         records.setData(ticketVOS);
         records.setCurrent((long) pageNum);
@@ -270,7 +271,7 @@ public class TicketService extends ServiceImpl<TicketMapper, Ticket> {
     }
 
     private Boolean ifHavePermission(String id) {
-        PersonnelVO personnelVO = cacheUtil.getLoginUser(loginUtils.getId());
+        PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
         personnelVO.getPersonType();
         if (personnelVO.getPersonType().equals(0) || (id != null && personnelVO.getId().equals(id))) {
             return true;

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

@@ -51,7 +51,7 @@ public class GetFiguresService {
         Patent patent = uploadPatentWebDTO.getPatent();
         if (pictureUrl != null && !pictureUrl.contains("408")) {
             File file = FileUtils.getPictureFileByUrl(pictureUrl);
-            String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getStarPatentVO().getApplicationNo())+i;
+            String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getPatent().getAppNo())+i;
             fileManagerService.uploadFileWithGuid(file, guid);
             PatentVector patentVectorOrg =  esService.getVectorByIndex(patent.getAppNo(),i);
             if(patentVectorOrg!=null){

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

@@ -0,0 +1,202 @@
+package com.example.xiaoshiweixinback.service.importPatent;
+
+import com.alibaba.fastjson.JSONArray;
+import com.example.xiaoshiweixinback.business.common.base.SystemFile;
+import com.example.xiaoshiweixinback.business.utils.ReadExcelUtils;
+import com.example.xiaoshiweixinback.business.utils.esDataForm.PatentClassifySplitter;
+import com.example.xiaoshiweixinback.domain.es.Patent;
+import com.example.xiaoshiweixinback.domain.es.PatentClassify;
+import com.example.xiaoshiweixinback.domain.es.PatentPerson;
+import com.example.xiaoshiweixinback.domain.es.Text;
+import com.example.xiaoshiweixinback.entity.dto.patent.UploadPatentWebDTO;
+import com.example.xiaoshiweixinback.service.common.FileManagerService;
+import com.example.xiaoshiweixinback.service.importPatent.excel.*;
+import org.apache.commons.compress.utils.IOUtils;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Configurable;
+import org.springframework.stereotype.Service;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+@Service
+public class GetPatentFromExcelService {
+    @Autowired
+    private FileManagerService fileManagerService;
+    @Autowired
+    private ExcuteUploadSettingService excuteUploadSettingService;
+    @Autowired
+    private ExcuteDataToVOService excuteDataToVOService;
+    @Autowired
+    private EsService esService;
+    @Autowired
+    private SavePatentToEsService savePatentToEsService;
+@Autowired
+private GetPatentPictureFromExcelService getPatentPictureFromExcelService;
+
+    public void run(String path) {
+        try {
+            File tempFile = new File("C:\\Users\\admin\\Desktop\\exce\\"+path);
+            //创建临时文件tempFile,并将文件读取到tempFile
+            Integer lastIndex = 0;
+
+            Integer sourceId = 1;
+            Integer total = ReadExcelUtils.textExcel(tempFile, sourceId.toString());
+            //解析数据源类,通过数据来源id(如1:智慧芽)解析数据源配置文件,获得数据源配置文件对象jsonData
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(sourceId.toString());
+            //解析Excel文件获得工作簿
+            Sheet sheet = ReadExcelUtils.readExcel(tempFile);
+            Integer x = 0;
+            //遍历专利总数量,在循环中将专利一个一个存入消费者专利队列
+            for (int i = lastIndex; i < total; i++) {
+
+                PatentData patentData = ReadExcelUtils.readExcelOneRow(tempFile, sheet, i + 1);
+                //调用装载数据类(根据数据源配置文件对象和专利源数据生成专利数据)
+                UploadParamsVO uploadParamsVO = excuteDataToVOService.fileToPatentVO(patentData, jsonData);
+                this.loadPatent(uploadParamsVO);
+                UploadPatentWebDTO uploadPatentWebDTO = new UploadPatentWebDTO();
+                uploadPatentWebDTO.setPictureData(uploadParamsVO.getPictureData());
+                uploadPatentWebDTO.setPatent(uploadParamsVO.getPatent());
+                savePatentToEsService.saveOrUpdate(uploadPatentWebDTO);
+                getPatentPictureFromExcelService.run(uploadPatentWebDTO);
+                x++;
+            }
+            //删除临时文件tempFile
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    public void loadPatent(UploadParamsVO uploadParamsVO) {
+        Patent patent = uploadParamsVO.getPatent();
+        String patentNo = patent.getPatentNo();
+        String appNo = patent.getAppNo();
+        String publicNo = patent.getPublicNo();
+        String grantNo = patent.getGrantNo();
+        String usedNo = null;
+        if (appNo != null) {
+            usedNo = appNo;
+        } else if (publicNo != null) {
+            usedNo = publicNo;
+        } else if (grantNo != null) {
+            usedNo = grantNo;
+        }
+        String contry = usedNo.substring(0, 2);
+        if (contry.equals("CN")) {
+            patentNo = appNo;
+        } else {
+            if (publicNo != null) {
+                patentNo = publicNo;
+            } else if (grantNo != null) {
+                patentNo = grantNo;
+            }
+        }
+        patent.setPatentNo(patentNo);
+        //装载标题
+        if (uploadParamsVO.getTitle() != null) {
+            List<Text> texts = new ArrayList<>();
+            if (uploadParamsVO.getTitle().getName() != null) {
+                Text text = new Text();
+                text.setTextContent(uploadParamsVO.getTitle().getName());
+                text.setIfOrigin(true);
+                text.setLanguage(contry);
+                texts.add(text);
+            }
+            if (uploadParamsVO.getTitle().getNameOut() != null) {
+                Text text = new Text();
+                text.setTextContent(uploadParamsVO.getTitle().getNameOut());
+                text.setIfOrigin(false);
+                text.setLanguage("CN");
+                texts.add(text);
+            }
+            if (texts.size() != 0) {
+                patent.setTitle(texts);
+            }
+
+        }
+
+        //装载摘要
+        if (uploadParamsVO.getAbstractStr() != null) {
+            List<Text> texts = new ArrayList<>();
+            if (uploadParamsVO.getAbstractStr().getName() != null) {
+                Text text = new Text();
+                text.setTextContent(uploadParamsVO.getAbstractStr().getName());
+                text.setIfOrigin(true);
+                text.setLanguage(contry);
+                texts.add(text);
+            }
+            if (uploadParamsVO.getAbstractStr().getNameOut() != null) {
+                Text text = new Text();
+                text.setTextContent(uploadParamsVO.getAbstractStr().getNameOut());
+                text.setIfOrigin(false);
+                text.setLanguage("CN");
+                texts.add(text);
+            }
+            if (texts.size() != 0) {
+                patent.setAbstractStr(texts);
+            }
+        }
+
+        //装载权利要求
+        if (uploadParamsVO.getPatentRight() != null) {
+            List<Text> texts = new ArrayList<>();
+            if (uploadParamsVO.getPatentRight().getName() != null) {
+                Text text = new Text();
+                text.setTextContent(uploadParamsVO.getPatentRight().getName());
+                text.setIfOrigin(true);
+                text.setLanguage(contry);
+                texts.add(text);
+            }
+            if (uploadParamsVO.getPatentRight().getNameOut() != null) {
+                Text text = new Text();
+                text.setTextContent(uploadParamsVO.getPatentRight().getNameOut());
+                text.setIfOrigin(false);
+                text.setLanguage("CN");
+                texts.add(text);
+            }
+            if (texts.size() != 0) {
+                patent.setClaim(texts);
+            }
+        }
+
+
+        List<String> applicantNames = uploadParamsVO.getPatentApplicantOriginalName();
+        //申请人
+        if (applicantNames != null && applicantNames.size() != 0) {
+            List<PatentPerson> patentPeople = new ArrayList<>();
+            for (int i = 0; i < applicantNames.size(); i++) {
+                PatentPerson patentPerson = new PatentPerson();
+                patentPerson.setOrder(i + 1);
+                patentPerson.setType("1");
+                patentPerson.setName(applicantNames.get(i));
+                patentPeople.add(patentPerson);
+            }
+            patent.setApplicant(patentPeople);
+
+        }
+
+
+        //装载LOC分类号
+        List<String> locList = uploadParamsVO.getLocList();
+        if (locList != null && locList.size() > 0) {
+            List<PatentClassify> patentClassifies = new ArrayList<>();
+            for (int i = 0; i < locList.size(); i++) {
+                PatentClassify patentClassify =new PatentClassify();
+                patentClassify.setLevel1(locList.get(i));
+                patentClassifies.add(patentClassify);
+            }
+            patent.setLoc(patentClassifies);
+        }
+
+
+    }
+
+
+}

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

@@ -0,0 +1,86 @@
+package com.example.xiaoshiweixinback.service.importPatent;
+
+
+import cn.hutool.core.util.IdUtil;
+import com.example.xiaoshiweixinback.business.utils.FileUtils;
+import com.example.xiaoshiweixinback.business.utils.FormatUtil;
+import com.example.xiaoshiweixinback.domain.es.Patent;
+import com.example.xiaoshiweixinback.domain.es.PatentClassify;
+import com.example.xiaoshiweixinback.domain.es.PatentVector;
+import com.example.xiaoshiweixinback.entity.dto.patent.UploadPatentWebDTO;
+import com.example.xiaoshiweixinback.service.common.FileManagerService;
+import com.example.xiaoshiweixinback.service.common.GetVectorService;
+import org.apache.poi.ss.usermodel.PictureData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Configurable;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import java.util.List;
+
+@Configurable
+@Service
+public class GetPatentPictureFromExcelService {
+
+    @Autowired
+    private FileManagerService fileManagerService;
+    @Autowired
+    private GetFiguresService getFiguresService;
+    @Autowired
+    private EsService esService;
+
+    @Autowired
+    private GetVectorService getVectorService;
+
+    public void run(UploadPatentWebDTO uploadPatentWebDTO) {
+
+        PictureData pictureData = uploadPatentWebDTO.getPictureData();
+        try {
+            if (pictureData != null) {
+                String ext = pictureData.suggestFileExtension();
+                byte[] data = pictureData.getData();
+                String picName = IdUtil.simpleUUID();
+                File file = FileUtils.getFileByBytes(data, picName, "." + ext);
+                this.tem(file, uploadPatentWebDTO, 0);
+            }
+        } catch (Exception e) {
+
+        }
+
+
+    }
+
+    private void tem(File file, UploadPatentWebDTO uploadPatentWebDTO, Integer i) throws Exception {
+        Patent patent = uploadPatentWebDTO.getPatent();
+        String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getPatent().getAppNo()) + i;
+        fileManagerService.uploadFileWithGuid(file, guid);
+        PatentVector patentVectorOrg = esService.getVectorByIndex(patent.getAppNo(), i);
+        if (patentVectorOrg != null) {
+            return;
+        }
+        PatentVector patentVector = new PatentVector();
+        patentVector.setAppNo(patent.getAppNo());
+        patentVector.setTitle(patent.getTitle());
+        patentVector.setRightHolder(patent.getApplicant());
+        patentVector.setAppDate(patent.getAppDate());
+        patentVector.setAbstractStr(patent.getAbstractStr());
+        patentVector.setAppCountry("US");
+        patentVector.setLoc(patent.getLoc());
+        patentVector.setImageIndex(i);
+        patentVector.setGuid(guid);
+        List<String> stringList = getVectorService.getVectorByFile(file);
+        List<Float> floats = new ArrayList<>();
+        stringList.forEach(item -> {
+            Float a = Float.parseFloat(item);
+            floats.add(a);
+
+        });
+        org.apache.commons.io.FileUtils.deleteQuietly(file);
+        patentVector.setMyVector(floats);
+        esService.addPatentVector(patentVector);
+
+
+    }
+}

+ 37 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ExcuteDataToVOService.java

@@ -0,0 +1,37 @@
+package com.example.xiaoshiweixinback.service.importPatent.excel;
+
+
+import org.apache.poi.ss.usermodel.PictureData;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 将专利源数据转换为专利VO实体类业务层
+ *
+ * @Author chenyu
+ * @Date 2023/5/31
+ */
+@Service
+public class ExcuteDataToVOService {
+
+    /**
+     * 将Eccel文件指定行专利数据装配转换为专利实体类
+     *
+     * @param patentData 专利数据
+     * @param jsonData   数据源配置
+     * @return 返回专利实体类
+     */
+    public UploadParamsVO fileToPatentVO(PatentData patentData, List<UploadSettingVO.Column> jsonData) {
+        //取出专利内容数据(除了摘要附图),(key:表头如 "公开(公告)号"  value:表头对应内容如 "CN1307082B")
+        Map<Object, Object> patentMap = patentData.getMap();
+        //取出专利摘要附图
+        PictureData pictureData = patentData.getPictureData();
+        //专利基础数据装配(与数据源配置文件对象进行匹配装载)
+        UploadParamsVO uploadParamsVO = UploadPatentBatchUtil.processData(patentMap,jsonData);
+        uploadParamsVO.setPictureData(pictureData);
+        return uploadParamsVO;
+    }
+
+}

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

@@ -0,0 +1,31 @@
+package com.example.xiaoshiweixinback.service.importPatent.excel;
+
+
+import com.example.xiaoshiweixinback.business.utils.FileUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 解析数据源配置文件
+ *
+ * @Author chenyu
+ * @Date 2023/5/31
+ */
+@Service
+public class ExcuteUploadSettingService {
+    /**
+     * 解析数据源配置文件并返回配置文件对象
+     *
+     * @param sourceId 数据来源id
+     * @return 返回数据源配置文件对象
+     */
+    public List<UploadSettingVO.Column> ExcuteUploadSetting(String sourceId) {
+        //获得uploadSetting.json配置文件的JSON串
+        String getSettingJson = new FileUtils().analysisJsonFile();
+        //查找并装载本次导入的专利需要的数据源(如智慧芽)的对应配置(如前台传来的数据来源id是1,即“智慧芽”,那么jsonData装载的就是智慧芽的数据源配置)
+        List<UploadSettingVO.Column> jsonData = UploadPatentBatchUtil.parsingConfigurationFiles(sourceId, getSettingJson);
+        return jsonData;
+    }
+
+}

+ 5 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/IProcessData.java

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

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

@@ -0,0 +1,25 @@
+package com.example.xiaoshiweixinback.service.importPatent.excel;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.apache.poi.ss.usermodel.PictureData;
+
+import java.util.Map;
+
+/**
+ * @Author chenyu
+ * @Date 2023/5/31
+ */
+@Accessors(chain = true)
+@Data
+public class PatentData {
+    /**
+     * 专利内容数据(除了摘要附图, key:表头如 "公开(公告)号"  value:表头对应内容如 "CN1307082B")
+     */
+    private Map<Object, Object> map;
+    /**
+     * 专利摘要附图
+     */
+    private PictureData pictureData;
+
+}

+ 22 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/StringSpecialHandler.java

@@ -0,0 +1,22 @@
+package com.example.xiaoshiweixinback.service.importPatent.excel;
+
+
+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();
+        }
+    }
+}

+ 144 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/UploadParamsVO.java

@@ -0,0 +1,144 @@
+package com.example.xiaoshiweixinback.service.importPatent.excel;
+
+
+
+
+
+import com.example.xiaoshiweixinback.domain.es.Patent;
+import com.example.xiaoshiweixinback.entity.dto.importTaskModel.*;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.apache.poi.ss.usermodel.PictureData;
+
+import java.util.List;
+/**
+ * @author 沈永艺
+ * @date 2022/7/1
+ * @description 用于批量导入数据的工具类
+ */
+@Accessors(chain = true)
+@Data
+public class UploadParamsVO {
+    /**
+     * 专利
+     */
+    private Patent patent;
+
+    /**
+     * 标题
+     */
+    private ImportTaskText title;
+
+    /**
+     * 摘要
+     */
+    private ImportTaskText abstractStr;
+    /**
+     * 法律状态
+     */
+    private String patentSimpleStatus;
+
+    /**
+     * 权利要求
+     */
+    private PatentRight patentRight;
+    /**
+     * 独立权要
+     */
+    private String selfContent;
+    /**
+     * 说明书(文本)
+     */
+    private PatentInstructionText patentInstructionText;
+
+    /**
+     * 代理人
+     */
+    private List<PatentAgent> patentAgentList;
+
+    /**
+     * 质押质权人
+     */
+    private List<PatentPledge> patentPledgeList;
+
+    /**
+     * 许可人
+     */
+    private List<PatentLicensor> patentLicensorList;
+
+    /**
+     * 简单同族
+     */
+    private List<String> simpleFamily;
+    private List<String> patSnapFamily;
+    private List<String> inpadocFamily;
+
+    /**
+     * 发明人
+     */
+    private List<PatentInventor> patentInventorList;
+    private String firstName;
+    private String firstAddress;
+
+    /**
+     * 申请人
+     */
+    private List<PatentApplicant> patentApplicantList;
+    //权利人
+    private List<String> patentApplicantCurrentName;
+    private List<String> patentApplicantStandardCurrentName;
+    //申请人
+    private List<String> patentApplicantOriginalName;
+    private List<String> patentApplicantStandardOriginalName;
+    //权利人地址
+    private List<String> patentApplicantCurrentAddress;
+    private List<String> patentApplicantCurrentCountry;
+    private String patentApplicantCurrentFirstAddress;
+    //申请人地址
+    private List<String> patentApplicantOriginalAddress;
+    private List<String> patentApplicantOriginalCountry;
+
+    /**
+     * 标签
+     */
+    private List<PatentLabel> patentLabelList;
+
+    /**
+     * 分类号关联
+     */
+    private String mainUpc;
+    /**
+     * 主分类号
+     */
+    private String mainIpc;
+    private List<String> cpcList;
+    private List<String> locList;
+    private List<String> upcList;
+    private List<String> ipcList;
+
+    /**
+     * 事务信息
+     */
+    private PatentAffair patentAffair;
+    private String simpleStatus;
+
+    /**
+     * 自定义字段
+     */
+    private List<Field> customerFieldList;
+
+    @Data
+    @Accessors(chain = true)
+    public static class Field {
+        private String key;
+        private List<String> fieldList;
+    }
+
+    /**
+     * 专利摘要附图(用于Excel导入存放附图)
+     */
+    private PictureData pictureData;
+
+
+
+}

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

@@ -0,0 +1,238 @@
+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 org.springframework.stereotype.Component;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * @date 2022/7/7
+ * @description 批量上传专利数据的数据处理工具类
+ */
+
+@Component
+public class UploadPatentBatchUtil {
+    /**
+     *
+     * @param getSettingJson        配置文件解析出的Json串
+     * @return uploadParamsVO 返回一个由processData方法填充完数据的Pojo类
+     * @date 2022/7/7
+     * @name 解析配置文件
+     * @description 通过与前段传入参数中的数据源ID进行比对从而得到对应数据源的配置项目
+     */
+    public static List<UploadSettingVO.Column> parsingConfigurationFiles(String sourceId, String getSettingJson) {
+        //将uploadSetting.json数据源配置文件的json字符串转换为UploadSettingVO对象(即实体类)集合
+        List<UploadSettingVO> uploadSettingVOs = JsonUtils.jsonToList(getSettingJson, UploadSettingVO.class);
+        //创建一个存放单一数据源的对象 这个对象存放的是 我们需要使用哪一个数据源的配置数据 所以只存一个 正常在Json文件里面会有多个数据源 也就是多条数据
+        List<UploadSettingVO.Column> jsonData = new ArrayList<>();
+        //遍历uploadSettingVOs,
+        for (int i = 0; i < Objects.requireNonNull(uploadSettingVOs).size(); i++) {
+            //提取一个常量
+            UploadSettingVO constant = Objects.requireNonNull(uploadSettingVOs).get(i);
+            //判断 如果说 Json 解析出来的 List<T> 中的 sourceId 和传入参数的 sourceId 匹配成功 则开始装配数据
+            if (constant.getSourceId().equals(sourceId)) {
+                //填充数据
+                jsonData = constant.getColumn();
+            }
+        }
+        //返回填充好的数据
+        return jsonData;
+    }
+
+    /**
+     * @param getSettingJson 配置文件解析出的Json串
+     * @return uploadParamsVO 返回一个由processData方法填充完数据的Pojo类
+     * @date 2022/7/7
+     * @name 解析配置文件
+     * @description 通过与前段传入参数中的数据源ID进行比对从而得到对应数据源的配置(parsingConfigurationFiles的兄弟方法)
+     */
+    public static List<UploadSettingVO.Column> parsingConfigurationFilesBro(String getSettingJson) {
+        //将 Json 转换为 对象数组
+        List<UploadSettingVO> test = JsonUtils.jsonToList(getSettingJson, UploadSettingVO.class);
+        //创建一个存放单一数据源的对象 这个对象存放的是 我们需要使用哪一个数据源的配置数据 所以只存一个 正常在Json文件里面会有多个数据源 也就是多条数据
+        List<UploadSettingVO.Column> jsonData = new ArrayList<>();
+        //开始将前端传入的数据源参数与 Json 中解析出来的 sourceId(数据来源ID) 进行比对 并将比对中的那一条数据放入上方定义的 jsonData 中 用于后续使用
+        for (int i = 0; i < Objects.requireNonNull(test).size(); i++) {
+            //提取一个常量
+            UploadSettingVO constant = Objects.requireNonNull(test).get(i);
+            //判断 如果说 Json 解析出来的 List<T> 中的 sourceId 和传入参数的 sourceId 匹配成功 则开始装配数据
+            if (constant.getSourceId().equals("1")) {
+                //填充数据
+                jsonData = constant.getColumn();
+            }
+        }
+        //返回填充好的数据
+        return jsonData;
+    }
+
+    private static List<UploadSettingVO.Column> getColumn(List<UploadSettingVO.Column> jsonData, String key) {
+        List<UploadSettingVO.Column> columnList = new ArrayList<>();
+
+        for (UploadSettingVO.Column jsonDatum : jsonData) {
+            if (jsonDatum.getSetName().equals(key)) {
+                columnList.add(jsonDatum);
+            }
+        }
+
+        return columnList;
+    }
+
+    /**
+     * @param obj          装配对象(UploadParamsVO)
+     * @param propertyPath 以.隔开的属性路径(配置文件中的 Column)
+     * @param value        值(row 每一行的值 在上层方法中叫 value)
+     * @name 装配对象
+     * @description 通过反射将处理后的数据赋值到装配对象的给定路径的属性值
+     */
+
+    private static void assemblyObject(Object obj, String propertyPath, Object value) {
+        //将属性的路径通过 "." 进行拆分 数据样式大致为 patentRightList.content 或者 patentInstructionText.manual
+        //"."前面的是UploadParamsVO的属性名称 可能是List或者Object
+        //"."后面的是List中的Object的属性 或者Object的属性
+        String[] splitProperty = propertyPath.split("\\.");
+        //初始化一个基类 用于存储数据
+        Object temObj = obj;
+        try {
+            //进行属性路径的循环 这里一般都是两次
+            for (int i = 0; i < splitProperty.length; i++) {
+                //如果需要为对应参数赋值 第一次循环不会进入这一分支
+                if (i == splitProperty.length - 1) {
+                    //如果是列表
+                    if (temObj instanceof List) {
+                        //取创建空数据中的第一条
+                        Object firstItem = ((List<?>) temObj).get(0);
+                        //获取该条数据的类型
+                        String listObjectType = firstItem.getClass().getTypeName();
+                        //如果列表中的数据少于给的值的列表中的数据量
+                        //添加数据以与给定的值对齐
+                        if (((List<?>) temObj).size() < ((List<?>) Objects.requireNonNull(value)).size()) {
+                            for (int iIndex = ((List<?>) temObj).size(); iIndex < ((List<?>) value).size(); iIndex++) {
+                                Object cObj = Class.forName(listObjectType).newInstance();// trueType.newInstance();
+                                ((List<Object>) temObj).add(cObj);
+                            }
+                        }
+
+                        //给列表中的对象相对应的属性赋值
+                        for (int iIndex = 0; iIndex < ((List<?>) value).size(); iIndex++) {
+
+                            Object inListObj = ((List<?>) temObj).get(iIndex);
+                            Field f = inListObj.getClass().getDeclaredField(splitProperty[i]);
+                            f.setAccessible(true);
+                            if (!((List<?>) value).isEmpty()) {
+                                f.set(inListObj, ((List<?>) value).get(iIndex));
+                            }
+                        }
+
+                    } else {
+                        Field f = temObj.getClass().getDeclaredField(splitProperty[i]);
+                        f.setAccessible(true);
+                        if (value != null) {
+                            f.set(temObj, value);
+                        }
+                    }
+                } else {
+
+                    //
+                    Field f = temObj.getClass().getDeclaredField(splitProperty[i]);
+                    //允许设置私有(private)属性
+                    f.setAccessible(true);
+                    //获取
+                    Object propertyValue = f.get(obj);
+
+                    if (propertyValue == null) {
+                        if (f.getType().getName().contains("List")) {
+                            propertyValue = createList(f);
+                        } else {
+                            propertyValue = f.getType().newInstance();
+                        }
+                        f.set(temObj, propertyValue);
+                    }
+
+                    temObj = propertyValue;
+                }
+
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    private static List<Object> createList(Field f) {
+        //如果是列表,创建一个List<Object>并添加一个对应类型的对象
+        List<Object> lst = new ArrayList<>();
+
+        //取List属性中包含的对象类型
+        Type trueType = f.getGenericType();
+        Type listArgumentObj = ((ParameterizedType) trueType).getActualTypeArguments()[0];
+        Object cObj = null;
+        try {
+            cObj = Class.forName(listArgumentObj.getTypeName()).newInstance();
+        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
+            e.printStackTrace();
+        }
+        lst.add(cObj);
+        return lst;
+    }
+    /**
+     * @param row      任务参数
+     * @param jsonData 处理好后转换为Pojo类的配置文件数据
+     * @return uploadParamsVO 返回一个填充完数据的Pojo类
+     * @date 2022/7/7
+     * @name 处理数据
+     * @description 通过配置项目中的栏位名称和通过解析Excel得到的栏位名称进行比对 并对所属栏位的数据进行分割或其他处理 最后将处理完的数据填充进类中 用于向数据库存入数据
+     */
+    public static UploadParamsVO processData(Map<Object, Object> row, List<UploadSettingVO.Column> jsonData) {
+        UploadParamsVO uploadParamsVO = new UploadParamsVO();
+        List<UploadParamsVO.Field> list = new ArrayList<>();
+        try {
+            for (Object object : row.keySet()) {
+                String key = object.toString();
+                Object value = row.get(key);
+                if (key.contains(":")) {
+                    // TODO: 2022/10/15 添加判空校验
+                    if (value != null && !value.equals("")) {
+                        UploadParamsVO.Field field = new UploadParamsVO.Field();
+                        StringSpecialHandler stringSpecialHandler = new StringSpecialHandler();
+                        field.setKey(key);
+                        field.setFieldList((List<String>) stringSpecialHandler.processData(value.toString(), "\\\n"));
+                        list.add(field);
+                    }
+                }
+                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();
+        }
+        //数据装配完毕 准备返回Service层 进行数据库操作
+        uploadParamsVO.setCustomerFieldList(list);
+        return uploadParamsVO;
+    }
+}

+ 68 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/UploadSettingVO.java

@@ -0,0 +1,68 @@
+package com.example.xiaoshiweixinback.service.importPatent.excel;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+/**
+ * uploadSetting.json数据源配置文件实体类
+ *
+ * @author 沈永艺
+ * @date 2022/7/1
+ * @description 用于存储从配置文件(Json类型)中解析出来的配置参数
+ */
+
+@Data
+@Accessors(chain = true)
+public class UploadSettingVO {
+    /**
+     * 数据来源id(1.智慧芽 2.合享 3.Patentics)
+     */
+    private String sourceId;
+
+    /**
+     * 数据来源名称
+     */
+    private String sourceName;
+
+    /**
+     * 数据来源中文名称
+     */
+    private String name;
+
+    /**
+     * 可配置属性 包含与数据来源文件(Excel文件)中的字段相对应的属性字段 是一个数组
+     */
+    private List<Column> column;
+
+    @Data
+    @Accessors(chain = true)
+    public static class Column {
+        /**
+         * 上传Excel栏位名称
+         */
+        private String setName;
+
+        /**
+         * 在代码中创建的数据库类里面的字段
+         */
+        private String column;
+
+        /**
+         * 分隔符
+         */
+        private String splitSymbol;
+
+        /**
+         * 处理方法
+         */
+        private String handler;
+
+        /**
+         * 处理方法(特殊或后期加入方法) 存放Jar包路径
+         */
+        private String jarOrClassPath;
+    }
+
+}

+ 3 - 2
src/main/resources/application-prodNetIn.yml

@@ -66,9 +66,10 @@ PCSUrl: http://localhost:8871
 #OPSUrl: http://192.168.1.24:5001
 OPSUrl: http://139.224.24.90:5001
 PASUrl: http://localhost:8877
-FMSUrl: http://localhost:8801
-FileSource: 5
+FMSUrl: http://localhost:8802
 VectorUrl: http://192.168.1.6:8000
+FileSource: 5
+
 ##################  短信 ####################
 SMS:
   regionId: cn-shanghai

+ 1 - 1
src/main/resources/mapper/ProductMapper.xml

@@ -4,7 +4,7 @@
 
     <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
+        as createName ,p.create_time as createTime,p.best_selling_brand as bestSellingBrand,p.price as price,p.platform_link as platformLink
         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