Explorar o código

add:增加码池功能v1

tujidelv %!s(int64=3) %!d(string=hai) anos
pai
achega
8b75dd8a22

+ 70 - 0
src/main/java/top/lvzhiqiang/controller/BgController.java

@@ -0,0 +1,70 @@
+package top.lvzhiqiang.controller;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+import top.lvzhiqiang.dto.R;
+import top.lvzhiqiang.exception.ParameterException;
+import top.lvzhiqiang.service.BgService;
+import top.lvzhiqiang.util.StringUtils;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+
+/**
+ * BG Controller
+ *
+ * @author lvzhiqiang
+ * 2022/4/16 16:10
+ */
+@Controller
+@RequestMapping("/bg")
+public class BgController {
+
+    @Resource
+    private BgService bgService;
+
+
+    /**
+     * 初始化骑兵数据
+     *
+     * @author lvzhiqiang
+     * 2022/4/16 16:10
+     */
+    @RequestMapping("/initQibingData")
+    @ResponseBody
+    public R initQibingData() {
+        bgService.initQibingData();
+
+        return R.ok();
+    }
+
+    @RequestMapping("/ftlIndex")
+    public String ftlIndex(Model model) {
+
+        return "ftlIndex";
+    }
+
+    /**
+     * 上传识别码文件
+     *
+     * @author lvzhiqiang
+     * 2022/4/16 16:10
+     */
+    @RequestMapping("/uploadFile4IdentificationCode")
+    @ResponseBody
+    public R uploadFile4IdentificationCode(MultipartFile file) throws IOException {
+        if (StringUtils.isEmpty(file.getOriginalFilename())) {
+            throw new ParameterException("文件为空!");
+        } else {
+            if (!file.getOriginalFilename().toLowerCase().endsWith("txt")) {
+                throw new ParameterException("文件格式不正确!!");
+            }
+        }
+
+        bgService.uploadFile4IdentificationCode(file.getInputStream());
+        return R.ok();
+    }
+}

+ 0 - 42
src/main/java/top/lvzhiqiang/controller/IndexController.java

@@ -1,42 +0,0 @@
-package top.lvzhiqiang.controller;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-import top.lvzhiqiang.dto.R;
-import top.lvzhiqiang.entity.VideoInfo;
-import top.lvzhiqiang.service.VideoInfoService;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-/**
- * INDEX Controller
- *
- * @author lvzhiqiang
- * 2022/4/4 15:28
- */
-@Controller
-public class IndexController {
-
-    @Resource
-    private VideoInfoService videoInfoService;
-
-
-    @RequestMapping("/initData")
-    @ResponseBody
-    public R initData() {
-        videoInfoService.initData();
-
-        return R.ok();
-    }
-
-    @RequestMapping("/ftlIndex")
-    public String ftlIndex(Model model) {
-        List<VideoInfo> videoInfoList = videoInfoService.findAll();
-        model.addAttribute("videoInfoList", videoInfoList);
-
-        return "ftlIndex";
-    }
-}

+ 49 - 0
src/main/java/top/lvzhiqiang/entity/IcodePool.java

@@ -0,0 +1,49 @@
+package top.lvzhiqiang.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 识别码池
+ *
+ * @author lvzhiqiang
+ * 2022/4/16 16:10
+ */
+@Data
+public class IcodePool implements Serializable {
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 识别码
+     */
+    private String identificationCode;
+
+    /**
+     * 状态(1:待爬取,2:爬取成功,3:爬取失败)
+     */
+    private Integer status;
+
+    /**
+     * 删除标志{1:正常,2:已删除}
+     */
+    private Integer deleteFlag;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+    /**
+     * 最后修改时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime modifyTime;
+}

+ 5 - 0
src/main/java/top/lvzhiqiang/exception/ParameterException.java

@@ -19,6 +19,11 @@ public class ParameterException extends RuntimeException {
         this.code = code;
     }
 
+    public ParameterException(String message) {
+        super(message);
+        this.code = ResultCodeEnum.PARAM_ERROR.getCode();
+    }
+
     public ParameterException(ResultCodeEnum resultCodeEnum) {
         super(resultCodeEnum.getMessage());
         this.code = resultCodeEnum.getCode();

+ 50 - 0
src/main/java/top/lvzhiqiang/mapper/IcodePoolMapper.java

@@ -0,0 +1,50 @@
+package top.lvzhiqiang.mapper;
+
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Select;
+import top.lvzhiqiang.entity.DicCode;
+import top.lvzhiqiang.entity.IcodePool;
+
+import java.util.List;
+
+/**
+ * 识别码池Mapper
+ *
+ * @author lvzhiqiang
+ * 2022/4/16 16:10
+ */
+public interface IcodePoolMapper {
+
+    /**
+     * 删除所有
+     */
+    @Delete("DELETE FROM icode_pool")
+    void deleteAll();
+
+    /**
+     * 批量新增
+     *
+     * @param icodePoolList
+     */
+    @Insert({"<script>" +
+            "INSERT INTO icode_pool(identification_code, create_time, modify_time) " +
+            "VALUES " +
+            "<foreach collection='list' item='ip' index=\"index\" separator=\",\">" +
+            "   (#{ip}, now(), now())" +
+            " </foreach>" +
+            "</script>"})
+    int insertList(List<String> icodePoolList);
+
+    /**
+     * 根据状态查询识别码
+     */
+    @Select("SELECT identification_code FROM icode_pool WHERE delete_flag = 1 and status = #{status}")
+    List<String> findIcodeByStatus(Integer status);
+
+    /**
+     * 查询所有识别码
+     */
+    @Select("SELECT identification_code FROM icode_pool WHERE delete_flag = 1")
+    List<String> findIcode();
+}

+ 25 - 0
src/main/java/top/lvzhiqiang/service/BgService.java

@@ -0,0 +1,25 @@
+package top.lvzhiqiang.service;
+
+import java.io.InputStream;
+
+/**
+ * Bg Service
+ *
+ * @author lvzhiqiang
+ * 2022/4/16 16:03
+ */
+public interface BgService {
+
+
+    /**
+     * 初始化骑兵数据
+     */
+    void initQibingData();
+
+    /**
+     * 上传识别码文件
+     *
+     * @param is
+     */
+    void uploadFile4IdentificationCode(InputStream is);
+}

+ 0 - 6
src/main/java/top/lvzhiqiang/service/VideoInfoService.java

@@ -3,7 +3,6 @@ package top.lvzhiqiang.service;
 import com.github.pagehelper.PageInfo;
 import top.lvzhiqiang.entity.VideoInfo;
 
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -30,11 +29,6 @@ public interface VideoInfoService {
     PageInfo<VideoInfo> findAll(int pageNo, int pageSize);
 
     /**
-     * 初始化数据
-     */
-    void initData();
-
-    /**
      * 条件查询
      *
      * @return

+ 283 - 0
src/main/java/top/lvzhiqiang/service/impl/BgServiceImpl.java

@@ -0,0 +1,283 @@
+package top.lvzhiqiang.service.impl;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+import top.lvzhiqiang.config.WebAppConfig;
+import top.lvzhiqiang.dto.JavAllInfo;
+import top.lvzhiqiang.entity.*;
+import top.lvzhiqiang.mapper.*;
+import top.lvzhiqiang.service.BgService;
+import top.lvzhiqiang.util.DateUtils;
+import top.lvzhiqiang.util.StringUtils;
+
+import javax.annotation.Resource;
+import java.io.*;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.ZoneOffset;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Bg ServiceImpl
+ *
+ * @author lvzhiqiang
+ * 2022/4/16 16:10
+ */
+@Service
+@Slf4j
+public class BgServiceImpl implements BgService {
+
+    @Resource
+    private VideoGenresMapper videoGenresMapper;
+    @Resource
+    private VideoCastMapper videoCastMapper;
+    @Resource
+    private VideoInfoCastMapper videoInfoCastMapper;
+    @Resource
+    private VideoInfoGenresMapper videoInfoGenresMapper;
+    @Resource
+    private VideoInfoMapper videoInfoMapper;
+    @Resource
+    private IcodePoolMapper icodePoolMapper;
+
+    /**
+     * 初始化骑兵数据
+     */
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    @Async
+    public void initQibingData() {
+        long startTime = System.currentTimeMillis();
+
+        DicCode dicCode = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && "qibing_path".equals(x.getCodeKey())).findFirst().get();
+        if (dicCode == null) {
+            return;
+        }
+        String picPath = dicCode.getCodeValue();
+
+        JavAllInfo javAllInfo = new JavAllInfo();
+        getAllFilePaths(picPath, javAllInfo);
+
+        saveInfo(javAllInfo);
+
+        long endTime = System.currentTimeMillis();
+        System.err.println((endTime - startTime) / 1000);
+    }
+
+    /**
+     * 上传识别码文件
+     *
+     * @param is
+     */
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    @Async
+    public void uploadFile4IdentificationCode(InputStream is) {
+        List<String> uploadIcodeList = readFromIcodeStream(is);
+        List<String> icodePoolList = icodePoolMapper.findIcode();
+
+        // 过滤库中已存在的
+        Integer beforeUploadSize = uploadIcodeList.size();
+        uploadIcodeList.removeAll(icodePoolList);
+
+        log.warn("uploadFile4IdentificationCode:beforeUpload={},icodePool={},afterUpload={}", beforeUploadSize, icodePoolList.size(), uploadIcodeList.size());
+
+        // 插入
+        int num = 0;
+        if (uploadIcodeList.size() > 0) {
+            num = icodePoolMapper.insertList(uploadIcodeList);
+        }
+        log.warn("uploadFile4IdentificationCode:success={}", num);
+    }
+
+    // 递归获取某目录下的所有子目录以及子文件
+    private void getAllFilePaths(String filePath, JavAllInfo javAllInfo) {
+        File[] files = new File(filePath).listFiles();
+        if (files == null) {
+            return;
+        }
+
+        int type = 0;
+        if (filePath.contains("骑兵")) {
+            type = 1;
+        } else if (filePath.contains("步兵")) {
+            type = 2;
+        }
+        for (File file : files) {
+            if (file.isDirectory()) {
+                // 文件夹
+                getAllFilePaths(file.getAbsolutePath(), javAllInfo);
+            } else {
+                String fileName = file.getName();
+                if (fileName.endsWith(".jpg") || (fileName.endsWith(".lnk") && fileName.contains(".jpg"))) {
+                    String parentName = file.getParentFile().getName();
+                    // 识别码
+                    String name = fileName.substring(10).replace(".jpg", "").trim();
+                    String[] nameArr = name.split("\\s+");
+                    try {
+                        boolean isMain = false;
+                        if (fileName.endsWith(".jpg")) {
+                            isMain = true;
+                            // 获取正片信息
+                            VideoInfo videoInfo = new VideoInfo();
+                            // 发行日期
+                            String issueDate = fileName.substring(0, 10);
+                            videoInfo.setIssueDate(LocalDate.parse(issueDate, DateUtils.dateFormatter));
+                            videoInfo.setIdentificationCode(nameArr[0]);
+                            // 名称
+                            if (nameArr.length > 1) {
+                                videoInfo.setName(name.substring(nameArr[0].length()).trim());
+                            } else {
+                                videoInfo.setName(nameArr[0]);
+                            }
+
+                            // 类型
+                            videoInfo.setType(type);
+                            // 图片URL
+                            videoInfo.setImgUrl(parentName.concat("/").concat(fileName));
+                            // 创建时间 TODO
+                            // 修改时间
+                            videoInfo.setCreateTime(Instant.ofEpochMilli(file.lastModified()).atZone(ZoneOffset.ofHours(8)).toLocalDateTime());
+                            // 主体是谁
+                            videoInfo.setMainWho(parentName);
+
+                            javAllInfo.getVideoInfoList().add(videoInfo);
+                        }
+
+                        if (parentName.contains("类别")) {
+                            // 获取类别
+                            String videoGenres = parentName.replace("(类别)", "");
+                            javAllInfo.getVideoGenresSet().add(videoGenres);
+
+                            VideoInfoGenres videoInfoGenres = new VideoInfoGenres();
+                            videoInfoGenres.setIdentificationCode(nameArr[0]);
+                            videoInfoGenres.setName(videoGenres);
+                            videoInfoGenres.setType(isMain ? 1 : 2);
+                            javAllInfo.getVideoInfoGenresSet().add(videoInfoGenres);
+                        } else if (parentName.contains("优)")) {
+                            // 获取演员
+                            String videoCast = "";
+                            if (parentName.contains("(男")) {
+                                videoCast = parentName.replace("(男优)", "");
+                                javAllInfo.getVideoCastMap().put(videoCast, "1");
+                            } else if (parentName.contains("(女")) {
+                                videoCast = parentName.replace("(女优)", "");
+                                javAllInfo.getVideoCastMap().put(videoCast, "2");
+                            }
+
+                            VideoInfoCast videoInfoCast = new VideoInfoCast();
+                            videoInfoCast.setIdentificationCode(nameArr[0]);
+                            videoInfoCast.setName(videoCast);
+                            videoInfoCast.setType(isMain ? 1 : 2);
+                            javAllInfo.getVideoInfoCastSet().add(videoInfoCast);
+                        }
+                    } catch (Exception e) {
+                        System.err.println("error:" + file.getAbsolutePath());
+                        System.err.println("error reason:" + e.getMessage());
+                    }
+                } else if (!fileName.endsWith(".jpg") && !fileName.endsWith(".lnk")) {
+                    String[] nameArr = fileName.substring(0, fileName.lastIndexOf(".")).split("\\s+");
+                    String parentName = file.getParentFile().getName();
+
+                    javAllInfo.getVideoUrlMap().put(nameArr[1], parentName.concat("/").concat(fileName));
+                }
+            }
+        }
+    }
+
+    // 保存所有文件
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public void saveInfo(JavAllInfo javAllInfo) {
+        // 删除所有
+        videoGenresMapper.deleteAll();
+        videoInfoMapper.deleteAll();
+        videoCastMapper.deleteAll();
+        videoGenresMapper.deleteAll();
+        videoInfoCastMapper.deleteAll();
+
+        // 保存分类
+        Set<String> videoGenresSet = javAllInfo.getVideoGenresSet();
+        //List<VideoGenres> videoGenresList = new ArrayList<>();
+        for (String s : videoGenresSet) {
+            VideoGenres videoGenres = new VideoGenres();
+            videoGenres.setName(s);
+            videoGenresMapper.insert(videoGenres);
+            System.out.println(videoGenres);
+            //videoGenresList.add(videoGenres);
+        }
+        //Map<String, VideoGenres> stringVideoGenresMap = videoGenresList.stream().collect(Collectors.toMap(VideoGenres::getName, Function.identity(), (k1, k2) -> k2));
+
+        // 保存演员
+        Map<String, String> videoCastMap = javAllInfo.getVideoCastMap();
+        //List<VideoCast> videoCastList = new ArrayList<>();
+        for (Map.Entry<String, String> entry : videoCastMap.entrySet()) {
+            VideoCast videoCast = new VideoCast();
+            videoCast.setName(entry.getKey());
+            videoCast.setType(Integer.parseInt(entry.getValue()));
+            videoCastMapper.insert(videoCast);
+            System.out.println(videoCast);
+            //videoCastList.add(videoCast);
+        }
+        // Map<String, VideoCast> stringVideoCastMap = videoCastList.stream().collect(Collectors.toMap(VideoCast::getName, Function.identity(), (k1, k2) -> k2));
+
+        // 保存影片信息
+        List<VideoInfo> videoInfoList = javAllInfo.getVideoInfoList();
+        Map<String, String> videoUrlMap = javAllInfo.getVideoUrlMap();
+        videoInfoList.parallelStream().forEach(e -> {
+            e.setVideoUrl(videoUrlMap.get(e.getIdentificationCode()));
+        });
+        //for (VideoInfo videoInfo : videoInfoList) {
+        //    try {
+        //        videoInfoMapper.insert(videoInfo);
+        //        System.out.println("success:" + videoInfo);
+        //    } catch (Exception e) {
+        //        e.printStackTrace();
+        //        System.out.println("error:" + videoInfo);
+        //    }
+        //}
+
+        int videoInfoCount = videoInfoMapper.insertList(videoInfoList);
+        System.out.println("videoInfoCount:" + videoInfoCount);
+
+        // 保存影片类别关联信息
+        Set<VideoInfoGenres> videoInfoGenresSet = javAllInfo.getVideoInfoGenresSet();
+        videoInfoGenresMapper.insertList(videoInfoGenresSet);
+        // 保存影片类别关联信息
+        Set<VideoInfoCast> videoInfoCastSet = javAllInfo.getVideoInfoCastSet();
+        videoInfoCastMapper.insertList(videoInfoCastSet);
+    }
+
+    private List<String> readFromIcodeStream(InputStream inputStream) {
+        List<String> list = new ArrayList<>();
+        BufferedReader br = null;
+        try {
+            br = new BufferedReader(new InputStreamReader(inputStream));
+            String line;
+            while ((line = br.readLine()) != null) {
+                if (StringUtils.isNotEmpty(line)) {
+                    list.add(line.trim().toUpperCase());
+                }
+            }
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (br != null) {
+                try {
+                    br.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return list.stream().distinct().collect(Collectors.toList());
+    }
+}

+ 2 - 204
src/main/java/top/lvzhiqiang/service/impl/VideoInfoServiceImpl.java

@@ -2,26 +2,15 @@ package top.lvzhiqiang.service.impl;
 
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-import top.lvzhiqiang.config.WebAppConfig;
-import top.lvzhiqiang.dto.JavAllInfo;
-import top.lvzhiqiang.entity.*;
-import top.lvzhiqiang.mapper.*;
+import top.lvzhiqiang.entity.VideoInfo;
+import top.lvzhiqiang.mapper.VideoInfoMapper;
 import top.lvzhiqiang.service.VideoInfoService;
-import top.lvzhiqiang.util.DateUtils;
 
 import javax.annotation.Resource;
-import java.io.File;
-import java.time.Instant;
-import java.time.LocalDate;
-import java.time.ZoneOffset;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 /**
  * 电影信息ServiceImpl
@@ -35,16 +24,6 @@ public class VideoInfoServiceImpl extends BaseServiceImpl<Object> implements Vid
     @Resource
     private VideoInfoMapper videoInfoMapper;
 
-    @Resource
-    private VideoGenresMapper videoGenresMapper;
-
-    @Resource
-    private VideoCastMapper videoCastMapper;
-
-    @Resource
-    private VideoInfoCastMapper videoInfoCastMapper;
-    @Resource
-    private VideoInfoGenresMapper videoInfoGenresMapper;
 
     /**
      * 查询所有
@@ -101,185 +80,4 @@ public class VideoInfoServiceImpl extends BaseServiceImpl<Object> implements Vid
         PageInfo<VideoInfo> videoInfoPageInfo = new PageInfo<>(videoInfoList);
         return videoInfoPageInfo;
     }
-
-    /**
-     * 初始化数据
-     */
-    @Override
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    @Async
-    public void initData() {
-        long startTime = System.currentTimeMillis();
-
-        DicCode dicCode = WebAppConfig.dicCodeList.stream().filter(x -> 1 == x.getType() && "qibing_path".equals(x.getCodeKey())).findFirst().get();
-        if (dicCode == null) {
-            return;
-        }
-        String picPath = dicCode.getCodeValue();
-
-        JavAllInfo javAllInfo = new JavAllInfo();
-        getAllFilePaths(picPath, javAllInfo);
-
-        saveInfo(javAllInfo);
-
-        long endTime = System.currentTimeMillis();
-        System.err.println((endTime - startTime) / 1000);
-    }
-
-    // 递归获取某目录下的所有子目录以及子文件
-    private void getAllFilePaths(String filePath, JavAllInfo javAllInfo) {
-        File[] files = new File(filePath).listFiles();
-        if (files == null) {
-            return;
-        }
-
-        int type = 0;
-        if (filePath.contains("骑兵")) {
-            type = 1;
-        } else if (filePath.contains("步兵")) {
-            type = 2;
-        }
-        for (File file : files) {
-            if (file.isDirectory()) {
-                // 文件夹
-                getAllFilePaths(file.getAbsolutePath(), javAllInfo);
-            } else {
-                String fileName = file.getName();
-                if (fileName.endsWith(".jpg") || (fileName.endsWith(".lnk") && fileName.contains(".jpg"))) {
-                    String parentName = file.getParentFile().getName();
-                    // 识别码
-                    String name = fileName.substring(10).replace(".jpg", "").trim();
-                    String[] nameArr = name.split("\\s+");
-                    try {
-                        boolean isMain = false;
-                        if (fileName.endsWith(".jpg")) {
-                            isMain = true;
-                            // 获取正片信息
-                            VideoInfo videoInfo = new VideoInfo();
-                            // 发行日期
-                            String issueDate = fileName.substring(0, 10);
-                            videoInfo.setIssueDate(LocalDate.parse(issueDate, DateUtils.dateFormatter));
-                            videoInfo.setIdentificationCode(nameArr[0]);
-                            // 名称
-                            if (nameArr.length > 1) {
-                                videoInfo.setName(name.substring(nameArr[0].length()).trim());
-                            } else {
-                                videoInfo.setName(nameArr[0]);
-                            }
-
-                            // 类型
-                            videoInfo.setType(type);
-                            // 图片URL
-                            videoInfo.setImgUrl(parentName.concat("/").concat(fileName));
-                            // 创建时间 TODO
-                            // 修改时间
-                            videoInfo.setCreateTime(Instant.ofEpochMilli(file.lastModified()).atZone(ZoneOffset.ofHours(8)).toLocalDateTime());
-                            // 主体是谁
-                            videoInfo.setMainWho(parentName);
-
-                            javAllInfo.getVideoInfoList().add(videoInfo);
-                        }
-
-                        if (parentName.contains("类别")) {
-                            // 获取类别
-                            String videoGenres = parentName.replace("(类别)", "");
-                            javAllInfo.getVideoGenresSet().add(videoGenres);
-
-                            VideoInfoGenres videoInfoGenres = new VideoInfoGenres();
-                            videoInfoGenres.setIdentificationCode(nameArr[0]);
-                            videoInfoGenres.setName(videoGenres);
-                            videoInfoGenres.setType(isMain ? 1 : 2);
-                            javAllInfo.getVideoInfoGenresSet().add(videoInfoGenres);
-                        } else if (parentName.contains("优)")) {
-                            // 获取演员
-                            String videoCast = "";
-                            if (parentName.contains("(男")) {
-                                videoCast = parentName.replace("(男优)", "");
-                                javAllInfo.getVideoCastMap().put(videoCast, "1");
-                            } else if (parentName.contains("(女")) {
-                                videoCast = parentName.replace("(女优)", "");
-                                javAllInfo.getVideoCastMap().put(videoCast, "2");
-                            }
-
-                            VideoInfoCast videoInfoCast = new VideoInfoCast();
-                            videoInfoCast.setIdentificationCode(nameArr[0]);
-                            videoInfoCast.setName(videoCast);
-                            videoInfoCast.setType(isMain ? 1 : 2);
-                            javAllInfo.getVideoInfoCastSet().add(videoInfoCast);
-                        }
-                    } catch (Exception e) {
-                        System.err.println("error:" + file.getAbsolutePath());
-                        System.err.println("error reason:" + e.getMessage());
-                    }
-                } else if (!fileName.endsWith(".jpg") && !fileName.endsWith(".lnk")) {
-                    String[] nameArr = fileName.substring(0, fileName.lastIndexOf(".")).split("\\s+");
-                    String parentName = file.getParentFile().getName();
-
-                    javAllInfo.getVideoUrlMap().put(nameArr[1], parentName.concat("/").concat(fileName));
-                }
-            }
-        }
-    }
-
-    // 保存所有文件
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void saveInfo(JavAllInfo javAllInfo) {
-        // 删除所有
-        videoGenresMapper.deleteAll();
-        videoInfoMapper.deleteAll();
-        videoCastMapper.deleteAll();
-        videoGenresMapper.deleteAll();
-        videoInfoCastMapper.deleteAll();
-
-        // 保存分类
-        Set<String> videoGenresSet = javAllInfo.getVideoGenresSet();
-        //List<VideoGenres> videoGenresList = new ArrayList<>();
-        for (String s : videoGenresSet) {
-            VideoGenres videoGenres = new VideoGenres();
-            videoGenres.setName(s);
-            videoGenresMapper.insert(videoGenres);
-            System.out.println(videoGenres);
-            //videoGenresList.add(videoGenres);
-        }
-        //Map<String, VideoGenres> stringVideoGenresMap = videoGenresList.stream().collect(Collectors.toMap(VideoGenres::getName, Function.identity(), (k1, k2) -> k2));
-
-        // 保存演员
-        Map<String, String> videoCastMap = javAllInfo.getVideoCastMap();
-        //List<VideoCast> videoCastList = new ArrayList<>();
-        for (Map.Entry<String, String> entry : videoCastMap.entrySet()) {
-            VideoCast videoCast = new VideoCast();
-            videoCast.setName(entry.getKey());
-            videoCast.setType(Integer.parseInt(entry.getValue()));
-            videoCastMapper.insert(videoCast);
-            System.out.println(videoCast);
-            //videoCastList.add(videoCast);
-        }
-        // Map<String, VideoCast> stringVideoCastMap = videoCastList.stream().collect(Collectors.toMap(VideoCast::getName, Function.identity(), (k1, k2) -> k2));
-
-        // 保存影片信息
-        List<VideoInfo> videoInfoList = javAllInfo.getVideoInfoList();
-        Map<String, String> videoUrlMap = javAllInfo.getVideoUrlMap();
-        videoInfoList.parallelStream().forEach(e -> {
-            e.setVideoUrl(videoUrlMap.get(e.getIdentificationCode()));
-        });
-        //for (VideoInfo videoInfo : videoInfoList) {
-        //    try {
-        //        videoInfoMapper.insert(videoInfo);
-        //        System.out.println("success:" + videoInfo);
-        //    } catch (Exception e) {
-        //        e.printStackTrace();
-        //        System.out.println("error:" + videoInfo);
-        //    }
-        //}
-
-        int videoInfoCount = videoInfoMapper.insertList(videoInfoList);
-        System.out.println("videoInfoCount:" + videoInfoCount);
-
-        // 保存影片类别关联信息
-        Set<VideoInfoGenres> videoInfoGenresSet = javAllInfo.getVideoInfoGenresSet();
-        videoInfoGenresMapper.insertList(videoInfoGenresSet);
-        // 保存影片类别关联信息
-        Set<VideoInfoCast> videoInfoCastSet = javAllInfo.getVideoInfoCastSet();
-        videoInfoCastMapper.insertList(videoInfoCastSet);
-    }
 }

+ 46 - 0
src/main/resources/static/bg.html

@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>BG HOME</title>
+</head>
+<style type="text/css">
+    .font {
+        color: blue;
+    }
+
+    .dynamic_hide {
+        display: block;
+    }
+</style>
+<script type="text/javascript">
+    function show() {
+        var my = document.getElementById("my");
+        if (my.className.indexOf("dynamic_hide") > -1) {
+            my.classList.remove("dynamic_hide");
+        } else {
+            my.classList.add("dynamic_hide");
+        }
+
+    }
+</script>
+<body>
+<div id="my" class="dynamic_hide">
+    <div style="margin-right:20px;">
+        <span class="font">initQibingData</span></del>
+        <form method="post" action="bg/initQibingData">
+            <input type="submit" value="提交">
+        </form>
+    </div>
+    <br/>
+    <div style="margin-right:20px;">
+        <span class="font">uploadFile4IdentificationCode</span>
+        <form method="post" action="bg/uploadFile4IdentificationCode" enctype="multipart/form-data">
+            <span>file</span>
+            <input type="file" name="file"/>
+            <input type="submit" value="提交">
+        </form>
+    </div>
+</div>
+</body>
+</html>

+ 1 - 1
src/main/resources/static/index.html

@@ -41,7 +41,7 @@
                                         <li class="">骑兵</li>
                                         <li class="">步兵</li>
                                         <li class="">流出</li>
-                                        <li class="">待处理</li>
+                                        <li class="">码池</li>
                                     </ul>
                                 </div>
                             </a>

+ 24 - 17
src/test/java/Test.java

@@ -6,9 +6,7 @@ import java.io.File;
 import java.time.Instant;
 import java.time.LocalDate;
 import java.time.ZoneOffset;
-import java.util.Comparator;
-import java.util.Set;
-import java.util.TreeSet;
+import java.util.*;
 
 public class Test {
     public static void main(String[] args) {
@@ -27,19 +25,28 @@ public class Test {
         //    }
         //}
 
-        Set<VideoInfoGenres> videoInfoGenresSet = new TreeSet<>(Comparator.comparing(o -> (o.getIdentificationCode().concat(o.getName()))));
-        VideoInfoGenres videoInfoGenres = new VideoInfoGenres();
-        videoInfoGenres.setIdentificationCode("1");
-        videoInfoGenres.setName("2");
-        VideoInfoGenres videoInfoGenres2 = new VideoInfoGenres();
-        videoInfoGenres2.setIdentificationCode("1");
-        videoInfoGenres2.setName("3");
-        VideoInfoGenres videoInfoGenres3 = new VideoInfoGenres();
-        videoInfoGenres3.setIdentificationCode("1");
-        videoInfoGenres3.setName("3");
-        videoInfoGenresSet.add(videoInfoGenres);
-        videoInfoGenresSet.add(videoInfoGenres2);
-        videoInfoGenresSet.add(videoInfoGenres3);
-        System.out.println(videoInfoGenresSet);
+        //Set<VideoInfoGenres> videoInfoGenresSet = new TreeSet<>(Comparator.comparing(o -> (o.getIdentificationCode().concat(o.getName()))));
+        //VideoInfoGenres videoInfoGenres = new VideoInfoGenres();
+        //videoInfoGenres.setIdentificationCode("1");
+        //videoInfoGenres.setName("2");
+        //VideoInfoGenres videoInfoGenres2 = new VideoInfoGenres();
+        //videoInfoGenres2.setIdentificationCode("1");
+        //videoInfoGenres2.setName("3");
+        //VideoInfoGenres videoInfoGenres3 = new VideoInfoGenres();
+        //videoInfoGenres3.setIdentificationCode("1");
+        //videoInfoGenres3.setName("3");
+        //videoInfoGenresSet.add(videoInfoGenres);
+        //videoInfoGenresSet.add(videoInfoGenres2);
+        //videoInfoGenresSet.add(videoInfoGenres3);
+        //System.out.println(videoInfoGenresSet);
+
+        List<String> s1 = new ArrayList<>();
+        s1.add("aa");
+        s1.add("bb");
+        List<String> s2 = new ArrayList<>();
+        s2.add("cc");
+        s2.add("bb");
+        s1.removeAll(s2);
+        System.out.println(s1);
     }
 }