123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- package com.sinosoft.cm.job;
- import java.util.List;
- import org.springframework.scheduling.annotation.Scheduled;
- import org.springframework.stereotype.Component;
- import com.cockpit.dao.Tran;
- import com.cockpit.util.ConfigManager;
- import com.cockpit.util.FtpUtil;
- import com.cockpit.util.SFTPUtil;
- /**
- *
- * @描述 解析变电站视频设备树xml
- * @auther liuyuliang
- * @filename SyncVideoTreeJob.java
- * @createDate 2016年3月25日 下午3:53:21
- */
- @Component
- public class SyncVideoTreeJob {
-
- public FtpUtil ftpUtil = new FtpUtil();
- public SFTPUtil sftpUtil = new SFTPUtil();
- // private FtpUtil ftpUtil = new FtpUtil();
- private Tran tran = new Tran();
- private ConfigManager cm = ConfigManager.getInstance();
-
- /**
- * 删除并添加ECM_CM_SYNCVIDEOTREE
- * @param list
- * @return
- */
- public void insertDateCoun(List<SyncVideoTreeEntity> list){
- String delSql = "delete ECM_CM_SYNCVIDEOTREE; " ;
- String addSql = "insert into ECM_CM_SYNCVIDEOTREE values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?);" ;
- tran.transactionBatchSync(list, delSql, addSql) ;
- }
-
- @Scheduled(cron = "0 0 0 * * * ?") // 每天午夜执行更新
- public void syncDeviceInfo() {
- List<SyncVideoTreeEntity> list;
-
- if(cm.getProper("video.ftp").equals("prev")){
- // if(sftpUtil.SftpDownFile()){
- if(ftpUtil.FtpDownFile()){
- list = ftpUtil.analysisXMLBySub();
- this.insertDateCoun(list);
- }
- }else{
- // TODO 如果解析成功,清空数据库中数据,并插入解析内容
- if(ftpUtil.FtpDownFile()){
- list = ftpUtil.analysisXML();
- this.insertDateCoun(list);
- }
- }
-
- }
-
-
- public static void main(String[] args) {
- //new SyncVideoTreeJob().syncDeviceInfo();
- List list = new SyncVideoTreeJob().ftpUtil.analysisXML();
- new SyncVideoTreeJob().insertDateCoun(list);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
|