admin
2021-03-24 c44a4296e8913080bff7ca0ee1b65356ed34ec3d
src/test/java/com/hxh/spring/test/PPTVTest.java
@@ -30,9 +30,9 @@
import java.util.*;
@RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试
@ContextConfiguration(locations = {"classpath:spring.xml"})
@WebAppConfiguration
//@RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试
//@ContextConfiguration(locations = {"classpath:spring.xml"})
//@WebAppConfiguration
public class PPTVTest {
    @Resource
@@ -80,6 +80,18 @@
        } catch (Exception e) {
            e.printStackTrace();
        }
//        List<PPTVSeries> list = PPTVApiUtil.getUpdateList();
//        System.out.println(list);
    }
    @Test
    public void syncVideo() {
        try {
            pptvVideoUpdate.syncVideo("");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @Test
@@ -90,7 +102,7 @@
    @Test
    public void getApiDetail() {
        PPTVApiUtil.getDetail("32159127,10215224,15326213");
        PPTVApiUtil.getDetail("9040633");
    }
@@ -119,8 +131,11 @@
    @Test
    public void addVideoInfo() {
        PPTVSeries series = pptvService.getSeriesDetail("26796");
//        List<PPTVSeries> seriesList = pptvSeriesDao.list("少儿", 0, 100);
//        for (PPTVSeries series : seriesList) {
        PPTVSeries series = pptvService.getSeriesDetail("381472");
        pptvService.addToVideoInfo(series);
//        }
    }
    @Test
@@ -175,7 +190,7 @@
            Sheet sheet = rwb.getSheet(sheetNum);
            for (int c = 1; c < sheet.getRows(); c++) {
                String infoId = sheet.getCell(0, c).getContents().trim();
                String name = sheet.getCell(2, c).getContents().trim();
                String name = sheet.getCell(1, c).getContents().trim();
                String del = sheet.getCell(21, c).getContents().trim();
                if (!StringUtil.isNullOrEmpty(infoId) && StringUtil.isNullOrEmpty(del)) {
                    videoList.add(new String[]{infoId, name, del});
@@ -194,31 +209,37 @@
        List<String[]> list1 = getPPTVVideos(new File("C:\\Users\\Administrator\\Desktop\\全量.xls"), 0);
        List<String[]> list2 = getPPTVVideos(new File("C:\\Users\\Administrator\\Desktop\\全量.xls"), 1);
        Map<String, String[]> map = new TreeMap<>();
        Set<String> sets = new HashSet<>();
        for (String[] sts : list1) {
            map.put(sts[0], sts);
            sets.add(sts[1]);
        }
        for (String[] sts : list2) {
            map.put(sts[0], sts);
            sets.add(sts[1]);
        }
        List<PPTVSeries> list = pptvSeriesDao.list(0, 10000);
        Set<String> infoIds = new HashSet<>();
        for (PPTVSeries s : list) {
            infoIds.add(s.getInfoID());
        }
//        List<PPTVSeries> list = pptvSeriesDao.list(0, 10000);
//        Set<String> infoIds = new HashSet<>();
//        for (PPTVSeries s : list) {
//            infoIds.add(s.getInfoID());
//        }
//
//        for (String infoId : infoIds) {
//            map.remove(infoId);
//        }
        for (String infoId : infoIds) {
            map.remove(infoId);
        }
        for (String code : sets)
            getDetail(code);
        try {
            save(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
//        try {
//            save(map);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
        System.out.println(map);
//        System.out.println(map);
    }
    private void save(Map<String, String[]> data) throws Exception {
@@ -251,11 +272,10 @@
        }
    }
    @Test
    public void getDetail() {
        PPTVSeries series = PPTVApiUtil.getDetail("32385373");
    //    @Test
    public void getDetail(String sCode) {
        PPTVSeries series = PPTVApiUtil.getDetail(sCode);
        pptvService.save(series);
        System.out.println(series);
    }