7163794d6a24a820277b3888ea3ba3489cbb787b.svn-base 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package com.sinosoft.cm.job;
  2. import java.util.List;
  3. import org.springframework.scheduling.annotation.Scheduled;
  4. import org.springframework.stereotype.Component;
  5. import com.cockpit.dao.Tran;
  6. import com.cockpit.util.ConfigManager;
  7. import com.cockpit.util.FtpUtil;
  8. import com.cockpit.util.SFTPUtil;
  9. /**
  10. *
  11. * @描述 解析变电站视频设备树xml
  12. * @auther liuyuliang
  13. * @filename SyncVideoTreeJob.java
  14. * @createDate 2016年3月25日 下午3:53:21
  15. */
  16. @Component
  17. public class SyncVideoTreeJob {
  18. public FtpUtil ftpUtil = new FtpUtil();
  19. public SFTPUtil sftpUtil = new SFTPUtil();
  20. // private FtpUtil ftpUtil = new FtpUtil();
  21. private Tran tran = new Tran();
  22. private ConfigManager cm = ConfigManager.getInstance();
  23. /**
  24. * 删除并添加ECM_CM_SYNCVIDEOTREE
  25. * @param list
  26. * @return
  27. */
  28. public void insertDateCoun(List<SyncVideoTreeEntity> list){
  29. String delSql = "delete ECM_CM_SYNCVIDEOTREE; " ;
  30. String addSql = "insert into ECM_CM_SYNCVIDEOTREE values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?);" ;
  31. tran.transactionBatchSync(list, delSql, addSql) ;
  32. }
  33. @Scheduled(cron = "0 0 0 * * * ?") // 每天午夜执行更新
  34. public void syncDeviceInfo() {
  35. List<SyncVideoTreeEntity> list;
  36. if(cm.getProper("video.ftp").equals("prev")){
  37. // if(sftpUtil.SftpDownFile()){
  38. if(ftpUtil.FtpDownFile()){
  39. list = ftpUtil.analysisXMLBySub();
  40. this.insertDateCoun(list);
  41. }
  42. }else{
  43. // TODO 如果解析成功,清空数据库中数据,并插入解析内容
  44. if(ftpUtil.FtpDownFile()){
  45. list = ftpUtil.analysisXML();
  46. this.insertDateCoun(list);
  47. }
  48. }
  49. }
  50. public static void main(String[] args) {
  51. //new SyncVideoTreeJob().syncDeviceInfo();
  52. List list = new SyncVideoTreeJob().ftpUtil.analysisXML();
  53. new SyncVideoTreeJob().insertDateCoun(list);
  54. }
  55. }