| | |
| | | import com.yeshi.buwan.pptv.entity.PPTVSeries; |
| | | import com.yeshi.buwan.service.inter.LoginUserService; |
| | | import com.yeshi.buwan.service.inter.juhe.PPTVService; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.log.LoggerUtil; |
| | | import jxl.Sheet; |
| | | import jxl.Workbook; |
| | | import jxl.write.Label; |
| | | import jxl.write.WritableCell; |
| | | import jxl.write.WritableSheet; |
| | | import jxl.write.WritableWorkbook; |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | |
| | | import org.yeshi.utils.HtmlToolUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.util.*; |
| | | |
| | | |
| | | @RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试 |
| | |
| | | @Test |
| | | public void saveAll() { |
| | | List<PPTVSeries> list = PPTVApiUtil.getTotalList(); |
| | | pptvService.save(list); |
| | | // pptvService.save(list); |
| | | } |
| | | |
| | | @Test |
| | |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void getDetail() { |
| | | PPTVSeries pptvSeries = pptvService.getSeriesDetail("201161"); |
| | | System.out.println(pptvSeries); |
| | | } |
| | | |
| | | @Test |
| | | public void test() { |
| | |
| | | } |
| | | |
| | | @Test |
| | | public void reAddVideo(){ |
| | | public void reAddVideo() { |
| | | reAdd("武林外传"); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private List<String[]> getPPTVVideos(File f, int sheetNum) { |
| | | List<String[]> videoList = new ArrayList<>(); |
| | | try { |
| | | jxl.Workbook rwb = Workbook.getWorkbook(new FileInputStream(f)); |
| | | 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(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}); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return videoList; |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void checkPPTVVideos() { |
| | | 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()); |
| | | // } |
| | | // |
| | | // for (String infoId : infoIds) { |
| | | // map.remove(infoId); |
| | | // } |
| | | |
| | | for (String code : sets) |
| | | getDetail(code); |
| | | |
| | | // try { |
| | | // save(map); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | |
| | | // System.out.println(map); |
| | | } |
| | | |
| | | private void save(Map<String, String[]> data) throws Exception { |
| | | WritableWorkbook wwb = Workbook.createWorkbook(new File("C:\\Users\\Administrator\\Desktop\\布丸输出片单_缺失.xls")); |
| | | WritableSheet sheet = wwb.createSheet("缺失", 0); |
| | | sheet.addCell((WritableCell) new Label(0, 0, "百科ID")); |
| | | sheet.addCell((WritableCell) new Label(1, 0, "名称")); |
| | | int row = 1; |
| | | for (Iterator<String> its = data.keySet().iterator(); its.hasNext(); ) { |
| | | String key = its.next(); |
| | | sheet.addCell((WritableCell) new Label(0, row, key)); |
| | | sheet.addCell((WritableCell) new Label(1, row, data.get(key)[1])); |
| | | row++; |
| | | } |
| | | wwb.write(); |
| | | wwb.close(); |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void logs() { |
| | | LoggerUtil.getVIPLogger().info("123123"); |
| | | // LoggerUtil.getVIPLogger().info("123123"); |
| | | |
| | | Map<String, String[]> data = new TreeMap<>(); |
| | | data.put("4234234", new String[]{"4234234", "测试"}); |
| | | try { |
| | | save(data); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | // @Test |
| | | public void getDetail(String sCode) { |
| | | PPTVSeries series = PPTVApiUtil.getDetail(sCode); |
| | | pptvService.save(series); |
| | | } |
| | | |
| | | |