金创接口优化,改webservice处理接口

master
xuhaoxiang 4 years ago
parent d8bafa63f0
commit 1ac208953f

@ -8,6 +8,7 @@ import org.quartz.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.Trigger; import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext; import org.springframework.scheduling.TriggerContext;
@ -17,6 +18,7 @@ import org.springframework.scheduling.support.CronTrigger;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
@ -41,11 +43,22 @@ public class ScheduledJob implements Job {
@Autowired @Autowired
private Scheduler scheduler; private Scheduler scheduler;
@Value("${start}")
private int start;
@Value("${over}")
private int over;
@Override @Override
public void execute(JobExecutionContext context) { public void execute(JobExecutionContext context) {
QuartzUtils.pauseScheduleJob(scheduler, "group1", "job1"); QuartzUtils.pauseScheduleJob(scheduler, "group1", "job1");
List<ScanningFile> scanningFiles =new ArrayList<ScanningFile>();
try { try {
List<ScanningFile> scanningFiles = scanningFileRepository.findScanningFiles(); if(start==0){
scanningFiles = scanningFileRepository.findScanningFiles(over);
}else{
scanningFiles = scanningFileRepository.findScanningFilesMore(over-start,start);
}
analysisService.handleScanningFile(scanningFiles); analysisService.handleScanningFile(scanningFiles);
} catch (Exception e) { } catch (Exception e) {
// 如果报错-- 捕捉异常 继续执行 // 如果报错-- 捕捉异常 继续执行

@ -1,15 +1,25 @@
package com.ann.demo.primaryRepository; package com.ann.demo.primaryRepository;
import com.ann.demo.primaryEntity.ScanningFile; import com.ann.demo.primaryEntity.ScanningFile;
import org.apache.xml.res.XMLErrorResources_tr;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.awt.print.Pageable;
import java.util.List; import java.util.List;
@Repository @Repository
public interface ScanningFileRepository extends JpaRepository<ScanningFile,Integer> { public interface ScanningFileRepository extends JpaRepository<ScanningFile,Integer> {
// and FBIHID = '370067' and FBINCU = '4' // and FBIHID = '370067' and FBINCU = '4'
@Query(nativeQuery= true,value = "select top 70 * from scanning_file where STATUS = 0 order by id") /*@Query(nativeQuery= true,value = "select top 70 * from scanning_file where STATUS = 0 order by id")
public List<ScanningFile> findScanningFiles(); public List<ScanningFile> findScanning();*/
//@Query(nativeQuery= true,value = ":sql")n-m+1
/*@Query(nativeQuery= true,value = "SELECT DISTINCT c FROM Customer c JOIN c.partyCerts p where p.certNum=?")
public List<ScanningFile> findScanningFiles(@Param("sql") String sql);*/
@Query(nativeQuery= true,value = "select top(?1) * from scanning_file where STATUS = 0 order by id desc")
public List<ScanningFile> findScanningFiles(int over);
@Query(nativeQuery= true,value = "select top(?1) * from scanning_file where STATUS = 0 and id not in (select top(?2) id from scanning_file where STATUS = 0 order by id desc) order by id desc")
public List<ScanningFile> findScanningFilesMore(int length,int start);
} }

@ -110,21 +110,23 @@ public class AnalysisService {
} }
LocalDateTime now4 = LocalDateTime.now();//删掉 LocalDateTime now4 = LocalDateTime.now();//删掉
//Object[] objects = WebServiceUtils.connect(scanningFile.getPath() + "\\" + scanningFile.getFileName()); Object[] objects = WebServiceUtils.connect(scanningFile.getPath() + "\\" + scanningFile.getFileName());
LocalDateTime end4 = LocalDateTime.now();//删掉
logger.error("WebServiceUtils.connect耗时:"+Duration.between(now4,end4).toMillis());//删掉
//Object[] objects = WebServiceUtil.urlConnectionUtil("http://10.6.0.224/cdms/cdmsservice.asmx?wsdl",scanningFile.getPath() + "\\" + scanningFile.getFileName()); //Object[] objects = WebServiceUtil.urlConnectionUtil("http://10.6.0.224/cdms/cdmsservice.asmx?wsdl",scanningFile.getPath() + "\\" + scanningFile.getFileName());
//使用HttpURLConnection方式连接 //使用HttpURLConnection方式连接
String s = WebServiceUtil.urlConnectionUtil("http://10.6.0.224/cdms/cdmsservice.asmx?wsdl", scanningFile.getPath() + "\\" + scanningFile.getFileName()); // String s = WebServiceUtil.urlConnectionUtil("http://10.6.0.224/cdms/cdmsservice.asmx?wsdl", scanningFile.getPath() + "\\" + scanningFile.getFileName());
LocalDateTime end4 = LocalDateTime.now();//删掉
logger.error("WebServiceUtils.connect耗时:"+Duration.between(now4,end4).toMillis());//删掉 /*if(!"".equals(s)){
int w=9;
}
//s转Object[] //s转Object[]
String[] strArr = s.split(",");//注意分隔符是需要转译 String[] strArr = s.split(",");//注意分隔符是需要转译
Object[] objects = new Object[strArr.length]; Object[] objects = new Object[strArr.length];
for(int i=0;i<strArr.length;i++) { for(int i=0;i<strArr.length;i++) {
objects[i] = strArr[i]; objects[i] = strArr[i];
} }*/
if (objects == null) { if (objects == null) {
return "下载图片出错了。。。"; return "下载图片出错了。。。";
} }

@ -20,8 +20,10 @@ spring:
show-sql: false show-sql: false
hibernate: hibernate:
dialect: org.hibernate.dialect.SQLServer2008Dialect dialect: org.hibernate.dialect.SQLServer2008Dialect
file: file:
pdfPath: Z:/project_js/scanningfile/ pdfPath: Z:/project_js/scanningfile/
imagePath: Z:/images/scanningfile/ imagePath: Z:/images/scanningfile/
scanningFilePath: D:\\1\scanningFile.properties scanningFilePath: D:\\1\scanningFile.properties
#50-100,是从51条数据到第100条数据,取n到m的数据实际取的是n+1到m的数据start不能为空如果是取前50条则start为0end为50
start: 0
over: 500
Loading…
Cancel
Save