0526 -wzq

master
wzqgit 4 years ago
parent 50c79307b6
commit d8bafa63f0

@ -153,5 +153,10 @@
<orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.8" level="project" />
<orderEntry type="library" name="Maven: commons-net:commons-net:3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.12" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" />
<orderEntry type="library" name="Maven: org.apache.axis:axis:1.4" level="project" />
<orderEntry type="library" name="Maven: javax.xml.rpc:javax.xml.rpc-api:1.1.2" level="project" />
</component>
</module>

@ -134,6 +134,28 @@
<version>3.8</version>
</dependency>
<!--2021/4/20-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.axis/axis -->
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.xml.rpc/javax.xml.rpc-api -->
<dependency>
<groupId>javax.xml.rpc</groupId>
<artifactId>javax.xml.rpc-api</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<build>

@ -1,11 +1,19 @@
package com.ann.demo.controller;
import com.ann.demo.entity.constant.InterfaceName;
import com.ann.demo.primaryEntity.ScanningFile;
import com.ann.demo.primaryRepository.ScanningFileRepository;
import com.ann.demo.service.AnalysisService;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
/**
@ -16,6 +24,14 @@ import java.util.Objects;
@RequestMapping("/")
public class TestController {
final Logger logger = LoggerFactory.getLogger(TestController.class);
@Autowired
private ScanningFileRepository scanningFileRepository ;
@Autowired
private AnalysisService analysisService;
@RequestMapping("/demo")
public String aa() {
return "demo";
@ -47,17 +63,14 @@ public class TestController {
return "redirect:/demo";
}
@RequestMapping("/bb")
@RequestMapping("/aa")
public String cc() {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient("http://localhost:8080/services/HomepageDictionary?wsdl");
Object[] objects = new Object[0];
try {
String outContent = "1.CDP</FFILENAME><FREMARK></FREMARK><CREATETIME>20181022091939</CREATETIME><FODATE>20180907112152</FODATE></REQUEST>";
objects = client.invoke("ScanningFile", outContent);
} catch (Exception e) {
e.printStackTrace();
}
LocalDateTime beginTime = LocalDateTime.now();
logger.error("开始时间:"+beginTime);
List<ScanningFile> scanningFiles = scanningFileRepository.findScanningFiles();
analysisService.handleScanningFile(scanningFiles);
LocalDateTime endTime = LocalDateTime.now();
logger.error("结束时间:"+endTime);
return "成功";
}

@ -42,7 +42,7 @@ public class SchedulerAllJob {
*/
public void scheduleJobs() throws SchedulerException {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
// scheduleJob1(scheduler);
scheduleJob1(scheduler);
}
/**

@ -19,6 +19,7 @@ import org.springframework.stereotype.Component;
import java.io.File;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
@ -53,6 +54,8 @@ public class AnalysisService {
private ArchiveMasterService archiveMasterService;
public void handleScanningFile(List<ScanningFile> scanningFileList) {
LocalDateTime beginTime = LocalDateTime.now();
logger.error("开始时间:"+beginTime);
//处理ScanningFile\
for (ScanningFile scanningFile: scanningFileList) {
String remark = null;
@ -72,25 +75,56 @@ public class AnalysisService {
scanningFile.setRemark(remark);
scanningFile.setStatus(status);
scanningFileRepository.save(scanningFile);
LocalDateTime handleTime = LocalDateTime.now();
logger.error("每一条处理时间:"+handleTime);
}
LocalDateTime endTime = LocalDateTime.now();
logger.error("结束时间:"+endTime);
}
public String handlePdfFile(ScanningFile scanningFile) throws Exception{
//处理ScanningFile
// 判断病案首页数据是否存在
LocalDateTime now1 = LocalDateTime.now();//删掉
CommonTable commonTable = commonTableRepository.findByInpNoAndVisitId(scanningFile.getInpNo(), scanningFile.getVisitId());
LocalDateTime end1 = LocalDateTime.now();//删掉
logger.error("判断病案首页数据是否存在耗时:"+Duration.between(now1,end1).toMillis());//删掉
if(commonTable == null){
String masterId = scanningFile.getApplyId() != null ? scanningFile.getApplyId() : UUID.randomUUID().toString();
commonTable = new CommonTable(masterId,scanningFile.getPatientId(),scanningFile.getAge(),scanningFile.getSex(),scanningFile.getVisitId(),scanningFile.getName(),
scanningFile.getAdmissDate(),scanningFile.getDisDate(),scanningFile.getDisDept(),scanningFile.getAttending(),scanningFile.getInpNo(),"扫描系统");
// //保存公共表
LocalDateTime now2 = LocalDateTime.now();//删掉
commonTableRepository.save(commonTable);
LocalDateTime end2 = LocalDateTime.now();//删掉
logger.error("保存公共表耗时:"+Duration.between(now2,end2).toMillis());//删掉
//保存公共表1
LocalDateTime now3 = LocalDateTime.now();//删掉
commonTable1Repository.save( new CommonTable1(commonTable.getMasterId(),scanningFile.getBirthday(),scanningFile.getIdCard(),scanningFile.getAdmissDept(),scanningFile.getAdmissDoctor()));
LocalDateTime end3 = LocalDateTime.now();//删掉
logger.error("保存公共表1耗时:"+Duration.between(now3,end3).toMillis());//删掉
}
Object[] objects = WebServiceUtils.connect(scanningFile.getPath() + "\\" + scanningFile.getFileName());
LocalDateTime now4 = LocalDateTime.now();//删掉
//Object[] objects = WebServiceUtils.connect(scanningFile.getPath() + "\\" + scanningFile.getFileName());
//Object[] objects = WebServiceUtil.urlConnectionUtil("http://10.6.0.224/cdms/cdmsservice.asmx?wsdl",scanningFile.getPath() + "\\" + scanningFile.getFileName());
//使用HttpURLConnection方式连接
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());//删掉
//s转Object[]
String[] strArr = s.split(",");//注意分隔符是需要转译
Object[] objects = new Object[strArr.length];
for(int i=0;i<strArr.length;i++) {
objects[i] = strArr[i];
}
if (objects == null) {
return "下载图片出错了。。。";
}
@ -107,14 +141,28 @@ public class AnalysisService {
// byte[] bytes = (byte[]) objects[0];
String applyId = commonTable.getMasterId() + "~" + (number != null ? number : "");
// 给临时图片填充内容
LocalDateTime now5 = LocalDateTime.now();//删掉
File imageTempFile = FileUtils.createFile("images", scanningFile.getInpNo(), scanningFile.getVisitId(), applyId);
LocalDateTime end5 = LocalDateTime.now();//删掉
logger.error("FileUtils.createFile生成images耗时:"+Duration.between(now5,end5).toMillis());//删掉
LocalDateTime now6 = LocalDateTime.now();//删掉
File imageFile = FileUtils.getImageFileByByteArray(objects, imageTempFile);
LocalDateTime end6 = LocalDateTime.now();//删掉
logger.error("FileUtils.getImageFileByByteArray耗时:"+Duration.between(now6,end6).toMillis());//删掉
if (imageFile == null) {
return "填充临时图片出错了。。。";
}
LocalDateTime now7 = LocalDateTime.now();//删掉
File pdfFile = FileUtils.createFile("pdfs", scanningFile.getInpNo(), scanningFile.getVisitId(), applyId);
LocalDateTime end7 = LocalDateTime.now();//删掉
logger.error("FileUtils.createFile生成pdfs耗时:"+Duration.between(now7,end7).toMillis());//删掉
LocalDateTime now8 = LocalDateTime.now();//删掉
String pdfPath = PdfUtils.imagesToPdf(imageFile, pdfFile);
LocalDateTime end8 = LocalDateTime.now();//删掉
logger.error("图片转pdf耗时:"+Duration.between(now8,end8).toMillis());//删掉
//存入pdf地址
if (pdfPath == null) {
return "image转成pdf出错了。。。";
@ -175,7 +223,10 @@ public class AnalysisService {
assortId = "18";
break;
}
LocalDateTime now9 = LocalDateTime.now();//删掉
archiveDetailService.save(new ArchiveDetail(commonTable.getMasterId(), new Date(), assortId, "扫描系统", applyId, pdfPath,Integer.valueOf(number)));
LocalDateTime end9 = LocalDateTime.now();//删掉
logger.error("保存耗时:"+Duration.between(now9,end9).toMillis());//删掉
return null;
}

@ -1,9 +1,6 @@
package com.ann.demo.utils;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Image;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.PdfWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -30,7 +27,7 @@ public class PdfUtils {
String fileName = null;
try {
// 第一步创建一个document对象。
Document document = new Document();
Document document = new Document(PageSize.A4);
document.setMargins(0, 0, 0, 0);
// 第二步:
// 创建一个PdfWriter实例

@ -0,0 +1,7 @@
package com.ann.demo.utils;
public class Test {
public static void main(String[] args) {
}
}

@ -0,0 +1,158 @@
package com.ann.demo.utils;
import org.apache.axis.transport.http.HTTPConstants;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
//import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Date;
import java.text.DateFormat;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
import java.lang.Integer;
import javax.xml.rpc.ParameterMode;
/**
* webservice
* Author:lsf
* Date:19-01-08
*/
public class WebServiceUtil {
static int socketTimeout = 30000;// 请求超时时间
static int connectTimeout = 30000;// 传输超时时间
static Logger logger = LoggerFactory.getLogger(WebServiceUtil.class);
/**
* 使SOAPHttpClient
*
* @param postUrl
* @param soapXml
* @param soapAction
* @return
*/
public static String doPostSoap(String postUrl, String soapXml,
String soapAction) {
String retStr = "";
// 创建HttpClientBuilder
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
// HttpClient
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
HttpPost httpPost = new HttpPost(postUrl);
// 设置请求和传输超时时间
RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(socketTimeout)
.setConnectTimeout(connectTimeout).build();
httpPost.setConfig(requestConfig);
try {
httpPost.setHeader("Content-Type", "text/xml;charset=UTF-8");
httpPost.setHeader("SOAPAction", soapAction);
StringEntity data = new StringEntity(soapXml,
Charset.forName("UTF-8"));
httpPost.setEntity(data);
CloseableHttpResponse response = closeableHttpClient
.execute(httpPost);
HttpEntity httpEntity = response.getEntity();
if (httpEntity != null) {
// 打印响应内容
retStr = EntityUtils.toString(httpEntity, "UTF-8");
logger.info("response:" + retStr);
}
// 释放资源
closeableHttpClient.close();
} catch (Exception e) {
logger.error("请求出错!", e);
}
return retStr;
}
/**
* 使HttpURLConnection
* @param soapurl
* @param soapXML
* @return
* @throws IOException
*/
public static String urlConnectionUtil(String soapurl,String soapXML) throws IOException {
//第一步:创建服务地址
//http://172.25.37.31:8080/PeopleSoftService/getPerson.wsdl
URL url = new URL(soapurl);
//第二步:打开一个通向服务地址的连接
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
//第三步:设置参数
//3.1发送方式设置POST必须大写
connection.setRequestMethod("POST");
//3.2设置数据格式content-type
connection.setRequestProperty("content-type", "text/xml;charset=utf-8");
//3.3设置输入输出因为默认新创建的connection没有读写权限
connection.setDoInput(true);
connection.setDoOutput(true);
//第四步组织SOAP数据发送请求
//将信息以流的方式发送出去
OutputStream os = connection.getOutputStream();
os.write(soapXML.getBytes());
StringBuilder sb = new StringBuilder();
//第五步:接收服务端响应,打印
int responseCode = connection.getResponseCode();
if(200 == responseCode){//表示服务端响应成功
//获取当前连接请求返回的数据流
InputStream is = connection.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
// StringBuilder sb = new StringBuilder();
String temp = null;
while(null != (temp = br.readLine())){
sb.append(temp);
}
is.close();
isr.close();
br.close();
}
os.close();
return sb.toString();
}
public static String TestWebService(String path){
try {
String endpoint = "http://10.6.0.224/cdms/cdmsservice.asmx?wsdl";
//直接引用远程的wsdl文件
//以下都是套路
Service service = new Service();
Call call = (Call) service.createCall();
//声明是HTTP1.1
call.setProperty(org.apache.axis.MessageContext.HTTP_TRANSPORT_VERSION, HTTPConstants.HEADER_PROTOCOL_V11);
call.setTargetEndpointAddress(endpoint);
call.setOperationName("GetImageStream");//WSDL里面描述的接口名称
call.addParameter("userName", org.apache.axis.encoding.XMLType.XSD_DATE,
javax.xml.rpc.ParameterMode.IN);//接口的参数
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型
String temp = "测试人员";
String result = (String)call.invoke(new Object[]{temp});
//给方法传递参数,并且调用方法
System.out.println("result is "+result);
return result;
}
catch (Exception e) {
System.err.println(e.toString());
return e.toString();
}
}
}
Loading…
Cancel
Save