Compare commits

...

4 Commits

Author SHA1 Message Date
zengwh 7bff807b82 优化金域外送 2 years ago
zengwh bfe6b078eb 优化 2 years ago
zengwh 102e7c0696 增加金域外送 2 years ago
zengwh 47e87687f4 增加金域外送 2 years ago

@ -106,6 +106,26 @@
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.2</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis-jaxrpc</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
<build>
@ -114,6 +134,15 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source> <!-- 设置你期望的Java源代码版本 -->
<target>1.8</target> <!-- 设置你期望的Java目标字节码版本 -->
</configuration>
</plugin>
</plugins>
<finalName>LISInterface</finalName>
</build>

@ -1,22 +1,16 @@
package com.ann.demo.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.ann.demo.entity.constant.AliasName;
import com.ann.demo.entity.constant.InterfaceName;
import com.ann.demo.entity.filing.MessageSubordinate;
import com.ann.demo.entity.filing.dto.MessageDto;
import com.ann.demo.entity.filing.dto.PatientMainDto;
import com.ann.demo.service.AnalysisService;
import com.ann.demo.utils.XMLUtils;
import com.ann.demo.service.CollectCheckService;
import com.ann.demo.service.JAXDynamicClientFactory;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Date;
import javax.annotation.Resource;
import java.util.Objects;
/**
@ -30,6 +24,9 @@ public class TestController {
@Autowired
AnalysisService analysisService;
@Resource
private CollectCheckService collectCheckService;
@RequestMapping("/demo")
public String aa() {
return "demo";
@ -38,7 +35,7 @@ public class TestController {
/*@ResponseBody*/
@RequestMapping("/haha")
public String cc(InterfaceForm interfaceForm) {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
JAXDynamicClientFactory dcf = JAXDynamicClientFactory.newInstance();
Client client = dcf.createClient(interfaceForm.getUrl());
Object[] objects = new Object[0];
try {
@ -55,10 +52,16 @@ public class TestController {
objects = client.invoke(interfaceForm.getInterfaceName(), interfaceForm.getParameter(), interfaceForm.getContent());
}
System.out.println(objects[0]);
} catch (Exception e) {
e.printStackTrace();
}
return "redirect:/demo";
}
@RequestMapping("/demo1")
@ResponseBody
public String demo1() {
collectCheckService.downFileWithCheck("123","100041535327","GZ002WWRQAZEUXP","http://kmcs.kingmed.com.cn:8890/km-platform-web/restful/fileDownload/0df10c5e-af85-4acd-b2df-c1628f77b59c@88f14792ee4a31129fa721f85e2068bb","123");
return "demo1";
}
}

@ -1,6 +1,7 @@
package com.ann.demo.entity.filing.dto;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
@ -9,6 +10,7 @@ import java.util.Date;
* @Date 2019/7/9 16:50
* @Created by ljx
*/
@ToString
public class MessageDto<T> {
private String entity;

@ -0,0 +1,19 @@
package com.ann.demo.entity.interfaceEntity;
public class Patient
{
private String patientid;
public void setPatientid(String patientid){
this.patientid = patientid;
}
public String getPatientid(){
return this.patientid;
}
public Patient(String patientid) {
this.patientid = patientid;
}
}

@ -0,0 +1,76 @@
package com.ann.demo.entity.interfaceEntity;
import java.util.ArrayList;
import java.util.List;
public class Root
{
private String collectorid;
private String ip;
private String assortid;
private Patient patient;
private List<Scanfiles> scanfiles;
private String scanusercode;
private String scanusername;
public Root(Scanfiles scanfiles,String masterId) {
List<Scanfiles> list = new ArrayList<>();
list.add(scanfiles);
this.collectorid = "10";
this.ip = "127.0.0.1";
this.assortid = "10";
this.patient = new Patient(masterId);
this.scanfiles = list;
this.scanusercode = "zwh";
this.scanusername = "zwh";
}
public void setCollectorid(String collectorid){
this.collectorid = collectorid;
}
public String getCollectorid(){
return this.collectorid;
}
public void setIp(String ip){
this.ip = ip;
}
public String getIp(){
return this.ip;
}
public void setAssortid(String assortid){
this.assortid = assortid;
}
public String getAssortid(){
return this.assortid;
}
public void setPatient(Patient patient){
this.patient = patient;
}
public Patient getPatient(){
return this.patient;
}
public void setScanfiles(List<Scanfiles> scanfiles){
this.scanfiles = scanfiles;
}
public List<Scanfiles> getScanfiles(){
return this.scanfiles;
}
public void setScanusercode(String scanusercode){
this.scanusercode = scanusercode;
}
public String getScanusercode(){
return this.scanusercode;
}
public void setScanusername(String scanusername){
this.scanusername = scanusername;
}
public String getScanusername(){
return this.scanusername;
}
}

@ -0,0 +1,71 @@
package com.ann.demo.entity.interfaceEntity;
public class Scanfiles
{
private int taskid;
private String filetitle;
private int filesource;
private int filestoragetype;
private int filetype;
private String downurl;
private String serialnum;
public Scanfiles(String filetitle,String downurl, String serialnum) {
this.taskid = -1;
this.filetitle = filetitle;
this.filesource = 1;
this.filestoragetype = 1;
this.filetype = 2;
this.downurl = downurl;
this.serialnum = serialnum;
}
public void setTaskid(int taskid){
this.taskid = taskid;
}
public int getTaskid(){
return this.taskid;
}
public void setFiletitle(String filetitle){
this.filetitle = filetitle;
}
public String getFiletitle(){
return this.filetitle;
}
public void setFilesource(int filesource){
this.filesource = filesource;
}
public int getFilesource(){
return this.filesource;
}
public void setFilestoragetype(int filestoragetype){
this.filestoragetype = filestoragetype;
}
public int getFilestoragetype(){
return this.filestoragetype;
}
public void setFiletype(int filetype){
this.filetype = filetype;
}
public int getFiletype(){
return this.filetype;
}
public void setDownurl(String downurl){
this.downurl = downurl;
}
public String getDownurl(){
return this.downurl;
}
public void setSerialnum(String serialnum){
this.serialnum = serialnum;
}
public String getSerialnum(){
return this.serialnum;
}
}

@ -44,16 +44,16 @@ public class WebServiceConfig {
System.out.println("-----------------------LIS已发布-------------------------");
EndpointImpl endpoint = new EndpointImpl(springBus(), homepageDictionary());
endpoint.publish("HomepageDictionary");
System.out.println("在线的wsdl:http://localhost:"+port+"/services/HomepageDictionary?wsdl");
log.info("在线的wsdl:http://localhost:"+port+"/services{}?wsdl","/HomepageDictionary");
return endpoint;
}
@Bean
/*@Bean
public Endpoint userServiceEndpoint() {
EndpointImpl userEndpoint = new EndpointImpl(bus, webServiceDemo);
userEndpoint.publish(path);
System.out.println("在线的wsdl:http://localhost:"+port+"/services"+path+"?wsdl");
log.info("在线的wsdl:http://localhost:"+port+"/services{}?wsdl",path);
return userEndpoint;
}
}*/
}

@ -10,6 +10,7 @@ import com.ann.demo.entity.filing.dto.PatientMainDto;
import com.ann.demo.entity.filing.ArchiveDetail;
import com.ann.demo.entity.interfaceEntity.ExamApply;
import com.ann.demo.entity.interfaceEntity.MessageLog;
import com.ann.demo.utils.Base64Utils;
import com.ann.demo.utils.FileUtils;
import com.ann.demo.utils.PdfUtils;
import com.ann.demo.utils.XMLUtils;
@ -19,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.io.File;
import java.util.Date;
import java.util.Objects;
@ -47,6 +49,8 @@ public class AnalysisService {
@Autowired
ArchiveDetailService archiveDetailService;
@Resource
private CollectCheckService collectCheckService;
/**
* 2019-7-8
* @Param xmlStr
@ -57,6 +61,8 @@ public class AnalysisService {
public String getHIPMessageServerResult(String message, Class tClass, String parameter,String webserviceId) throws Exception{
String outContent = "失败", typeCodeValue = "AE";
ArchiveDetail archiveDetail = null;
//是否走掉接口
boolean interfaceFlag = false;
try {
long startTime = System.currentTimeMillis();
long endTime = 0;
@ -66,6 +72,7 @@ public class AnalysisService {
MessageLog messageLog = new MessageLog(message, InterfaceName.HIP_MESSAGE_SERVER, new Date(), webserviceId);
messageService.save(messageLog);
MessageDto messageDto = XMLUtils.xpathToBean(message, tClass, parameter);
logger.info("接收到信息:"+messageDto.toString());
if (messageDto != null) {
archiveMasterId = messageService.getArchiveMasterId(messageDto.getInpNo(), messageDto.getVisitId());
if (archiveMasterId != null) {
@ -77,28 +84,37 @@ public class AnalysisService {
if((!ObjectUtils.isEmpty(messageDto.getDeliveryFlag()) )&&
Objects.equals(messageDto.getDeliveryFlag(),"广州金域")){
// 直接下载并生成文件到detail
//System.out.println(messageDto.getReportAddress());
UUID uuid = UUID.randomUUID();
File pdfFile = FileUtils.createFile("pdfs", messageDto.getInpNo(), messageDto.getVisitId(), uuid.toString(), null);
if(PdfUtils.base64StringToPDF(messageDto.getReportAddress(),pdfFile)){
if(Base64Utils.isBase64(messageDto.getReportAddress())) {
//是base64
if (!PdfUtils.base64StringToPDF(messageDto.getReportAddress(), pdfFile)) {
textContentTemp = "加密字节流转换pdf失败";
}
}else{
interfaceFlag = true;
//不是base64 2023-09-05新增根据接口下载pdf
boolean downFileFlag = collectCheckService.downFileWithCheck(archiveMasterId,messageDto.getBarCode(),messageDto.getCheckReportId(), messageDto.getReportAddress(),messageDto.getApplyId());
if(!downFileFlag){
textContentTemp = "金域外送base64下载失败";
}
}
if(!interfaceFlag) {
// 查询库中是否存在 如果存在就更新
archiveDetail = archiveDetailService.isExit(archiveMasterId, messageDto.getType(), messageDto.getSource(), messageDto.getApplyId(),messageDto.getCheckReportId());
archiveDetail = archiveDetailService.isExit(archiveMasterId, messageDto.getType(), messageDto.getSource(), messageDto.getApplyId(), messageDto.getCheckReportId());
if (archiveDetail == null) {
archiveDetail = new ArchiveDetail(uuid.toString(),archiveMasterId, new Date(), messageDto.getType(), messageDto.getSource(), messageDto.getApplyId(),
messageDto.getDetailType(),messageDto.getCheckReportId());
archiveDetail = new ArchiveDetail(uuid.toString(), archiveMasterId, new Date(), messageDto.getType(), messageDto.getSource(), messageDto.getApplyId(),
messageDto.getDetailType(), messageDto.getCheckReportId());
archiveDetail.setPdfPath(pdfFile.getAbsolutePath());
archiveDetailService.save(archiveDetail);
}else{
} else {
archiveDetail.setPdfPath(pdfFile.getAbsolutePath());
archiveDetailService.save(archiveDetail);
}
}else{
textContentTemp = "加密字节流转换pdf失败";
}
// 替换消息的pdf节点
String tempMessage = XMLUtils.replaceXpath(message, pdfFile.getAbsolutePath());
if(!ObjectUtils.isEmpty(tempMessage)){
//System.out.println(tempMessage);
message = tempMessage;
messageLog.setInputContent(message);
outContent = XMLUtils.generateV3XmlStr("AA", "成功啦~");
@ -121,6 +137,7 @@ public class AnalysisService {
result = 1;
}
} else {
logger.info("患者不存在:住院号:"+messageDto.getInpNo()+",住院次数:"+messageDto.getVisitId());
textContent = "没有入院信息";
}
} else {
@ -136,8 +153,9 @@ public class AnalysisService {
}
}
}catch (Exception e){
e.printStackTrace();
// 报错删掉患者报告详情信息
if (archiveDetail != null) {
if (archiveDetail != null && !interfaceFlag) {
if (archiveDetail.getId() != null) {
archiveDetailService.delete(archiveDetail.getId());
}
@ -149,7 +167,6 @@ public class AnalysisService {
return outContent;
}
private String changeApply(ExamApply examApply,String interfaceName) throws Exception{
String textContent = null;
ExamApply examApplyTemp = examApplyService.findExamApply(examApply.getApplyId());

@ -0,0 +1,272 @@
package com.ann.demo.service;
import com.alibaba.fastjson.JSON;
import com.ann.demo.utils.HttpClientUtils;
import com.ann.demo.utils.JsonUtils;
import com.ann.demo.utils.Md5Utils;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.axis.client.Call;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.encoding.XMLType;
import org.apache.axis.client.Service;
import org.apache.axis.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.io.IOException;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @author
* @description:
* @createTime 2023/9/5 16:48
*/
@Component
@Slf4j
public class CollectCheckService {
private Map<String,String> tokenCacheMap = new HashMap<>();
private String FILENAME = "fileName";
private String FILEBASE64 = "fileBase64";
@Value("${siteCode}")
private String siteCode;
@Value("${customerCode}")
private String customerCode;
@Value("${collectionLocation}")
private String collectionLocation;
@Value("${loginUrl}")
private String loginUrl;
@Value("${namespaceURI}")
private String namespaceURI;
@Value("${webServiceMethod}")
private String webServiceMethod;
@Value("${webServiceDownMethod}")
private String webServiceDownMethod;
@Value("${downfileUrl}")
private String downfileUrl;
public boolean downFileWithCheck(String masterId,String hospBarcode,String reportOdd,String fileUrl,String applyId) {
//登录
String token = getTokenByCheckKey(siteCode, customerCode, collectionLocation);
log.info("获取token:"+token);
//下载
return downFileWithCheck(masterId,hospBarcode,reportOdd,fileUrl,token,applyId);
}
/**
*
* @param masterId
* @param hospBarcode
* @param reportOdd
* @param fileUrl
* @param token
* @return
*/
private boolean downFileWithCheck(String masterId,String hospBarcode,String reportOdd,String fileUrl,String token,String applyId){
//根据参数请求接口返回json数据
String result = reqInterfaceByParam(hospBarcode, reportOdd, fileUrl, token);
//解析返回json数据
Map<String,String> map = analysisData(result);
//唯一文件码
String serialnum = hospBarcode + "_" + reportOdd;
//根据解析的数据调用下载
String reqResult = downFile(masterId,map,serialnum,applyId);
if(!StringUtils.isEmpty(reqResult)) {
String code = JsonUtils.getValueByKey(reqResult, "code");
if(!StringUtils.isEmpty(code) && "0".equals(code)){
log.info("下载成功masterId"+masterId);
return true;
}
}
return false;
}
/**
*
* @param map
*/
private String downFile(String masterId,Map<String, String> map,String serialnum,String applyId) {
if(!CollectionUtils.isEmpty(map)){
//设置下载参数
Map rootMap = setDownReqParams(masterId, map, serialnum,applyId);
//调用下载接口
String result = HttpClientUtils.doPost(downfileUrl,JSON.toJSONString(rootMap));
log.info("上传下载服务result:"+result);
return result;
}
return null;
}
/**
*
* @param masterId
* @param map
* @param serialnum
* @return
*/
private Map setDownReqParams(String masterId, Map<String, String> map, String serialnum,String applyId) {
//设置文件信息参数
Map<String,Object> scanfilesMap = new HashMap<>();
scanfilesMap.put("taskid",-1);
scanfilesMap.put("filetitle", map.get(FILENAME));
scanfilesMap.put("filesource",1);
scanfilesMap.put("filestoragetype",1);
scanfilesMap.put("filetype",2);
scanfilesMap.put("applyId",applyId);
scanfilesMap.put("downurl", map.get(FILEBASE64));
scanfilesMap.put("serialnum", serialnum);
List<Map<String,Object>> scanfilesList = new ArrayList<>();
scanfilesList.add(scanfilesMap);
//设置患者信息参数
Map<String,Object> patientMap = new HashMap<>();
patientMap.put("patientid", masterId);
//设置全部参数
Map rootMap = new HashMap<>();
rootMap.put("collectorid","10");
rootMap.put("ip","127.0.0.1");
rootMap.put("assortid","10");
rootMap.put("patient",patientMap);
rootMap.put("scanfiles",scanfilesList);
rootMap.put("scanusercode","zwh");
rootMap.put("scanusername","zwh");
return rootMap;
}
/**
* json
* @param result
*/
private Map<String,String> analysisData(String result) {
Map<String,String> map = new HashMap<>();
if(!StringUtils.isEmpty(result)) {
ObjectMapper objectMapper = new ObjectMapper();
//解析
try {
// 将JSON字符串转换为Map对象
JsonNode jsonNode = objectMapper.readTree(result);
String fileName = jsonNode.get("result").get("fileName").asText();
if (!StringUtils.isEmpty(fileName)) {
fileName = fileName.substring(0, fileName.length() - 4);
}
map.put(FILENAME,fileName);
String fileBase64 = jsonNode.get("result").get("file").asText();
map.put(FILEBASE64,fileBase64);
} catch (IOException e) {
e.printStackTrace();
}
}
return map;
}
/**
*
* @param hospBarcode
* @param reportOdd
* @param fileUrl
* @param token
* @return
*/
private String reqInterfaceByParam(String hospBarcode, String reportOdd, String fileUrl, String token) {
Map<String,String> paramMap = new HashMap<>();
paramMap.put("siteCode",siteCode);
paramMap.put("customerCode",customerCode);
paramMap.put("collectionLocation",collectionLocation);
paramMap.put("hospBarcode", hospBarcode);
paramMap.put("reportOdd", reportOdd);
paramMap.put("fileUrl", fileUrl);
String paramStr = JSON.toJSONString(paramMap);
String jsonMd5 = Md5Utils.strToMd5(paramStr);
//调用webService
Object[] objects = {jsonMd5, token, paramStr};
String[] params ={"md5","token","postJson"};
String result = null;
try {
result = getWebService(loginUrl,namespaceURI,webServiceDownMethod,params,objects);
} catch (Exception e) {
e.printStackTrace();
log.info("调用接口失败:"+objects.toString());
}
return result;
}
/**
*
* @param siteCode
* @param customerCode
* @param collectionLocation
* @return
*/
private String getTokenByCheckKey(String siteCode,String customerCode,String collectionLocation){
//组织协定秘钥secretKey
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
String toDay = fmt.format(new Date());
//判断token是否存在
String token = tokenCacheMap.get(toDay);
if(!StringUtils.isEmpty(token)){
//取缓存
return token;
}
String secretKey = collectionLocation + customerCode + siteCode + toDay;
//MD5转换
String secretKeyMd5 = Md5Utils.strToMd5(secretKey);
//调用第三方webService接口登录
//实例化org.apache.axis.client.Service对象
//创建service调用对象
Object[] objects = {siteCode, customerCode, collectionLocation, secretKeyMd5};
String[] params ={"siteCode","customerCode","collectionLocation","secretKey"};
String result = getWebService(loginUrl,namespaceURI,webServiceMethod,params,objects);
ObjectMapper objectMapper = new ObjectMapper();
//解析
try {
// 将JSON字符串转换为Map对象
JsonNode jsonNode = objectMapper.readTree(result);
token = jsonNode.get("result").get("token").asText();
} catch (IOException e) {
e.printStackTrace();
}
if(!StringUtils.isEmpty(token)) {
//存缓存
tokenCacheMap.clear();
tokenCacheMap.put(toDay, token);
}
return token;
}
/**
* webService
* @return
*/
private String getWebService(String webServiceUrl,String namespaceURI,String webServiceMethod,String[] params,Object[] objects ){
try {
Service service = new Service();
Call call;
call=(Call) service.createCall();
QName opAddEntry = new QName(namespaceURI, webServiceMethod); //设置命名空间和需要调用的方法名
call.setTargetEndpointAddress(webServiceUrl); //设置请求路径
call.setOperationName(webServiceMethod); //调用的方法名
call.setTimeout(Integer.valueOf(2000)); //设置请求超时
//按顺序设置请求参数、请求类型,多个需多添加参数
for(String param : params){
call.addParameter(param, XMLType.XSD_STRING, ParameterMode.IN);
}
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型
return (String) call.invoke(opAddEntry,objects);
} catch (ServiceException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
return null;
}
}

@ -0,0 +1,42 @@
package com.ann.demo.service;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.CXFBusFactory;
import org.apache.cxf.endpoint.EndpointImplFactory;
import org.apache.cxf.endpoint.dynamic.DynamicClientFactory;
import org.apache.cxf.jaxws.support.JaxWsEndpointImplFactory;
import java.util.List;
public class JAXDynamicClientFactory extends DynamicClientFactory {
protected JAXDynamicClientFactory(Bus bus) {
super(bus);
}
protected EndpointImplFactory getEndpointImplFactory() {
return JaxWsEndpointImplFactory.getSingleton();
}
protected boolean allowWrapperOps() {
return true;
}
public static JAXDynamicClientFactory newInstance(Bus b) {
return new JAXDynamicClientFactory(b);
}
public static JAXDynamicClientFactory newInstance() {
Bus bus = CXFBusFactory.getThreadDefaultBus();
return new JAXDynamicClientFactory(bus);
}
public boolean compileJavaSrc(String classPath, List srcList, String dest) {
org.apache.cxf.common.util.Compiler javaCompiler
= new org.apache.cxf.common.util.Compiler();
javaCompiler.setEncoding("UTF-8");
javaCompiler.setClassPath(classPath);
javaCompiler.setOutputDir(dest);
javaCompiler.setTarget("1.8");
return javaCompiler.compileFiles(srcList);
}
}

@ -42,7 +42,6 @@ public class MessageServiceImpl implements MessageService {
@Override
public List<MessageLog> findAllMessage() {
List<MessageLog> allHaha = messageRepository.findAllHaha();
System.out.println(allHaha.size());
return allHaha;
}

@ -1,16 +1,44 @@
package com.ann.demo.utils;
import org.apache.axis.encoding.Base64;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
public class Base64Utils {
public static String jdkBase64Decode(String src) {
try {
src = src.replaceAll("\r\n","");
byte[] decode = Base64.decode(src);
return new String(decode);
} catch (Exception e) {
e.printStackTrace();
/**
* base64
* @param str
* @return
* Ascii95
* 031127(33)
* 32126(95)(32485709
* 6590269712226
*/
public static boolean isBase64(String str) {
//使用正则来判断是否符合base64编码的特征但是无法排除类似于root这种特殊情况
String base64Pattern = "^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$";
Boolean isLegal = str.matches(base64Pattern);
if (isLegal) {
//对于某些字符可能符合base64编码特征但是却不是base64编码格式进行进一步判断如果解码后含有乱码即Ascii码不在32~126,
//说明虽然符合base64编码特征但是不是base64编码,如root
try {
String decStr = new String(Base64.getDecoder().decode(str.getBytes()), StandardCharsets.UTF_8);
char[] passArr = decStr.toCharArray();
for (int i = 0; i < passArr.length; i++) {
if (charToByteAscii2(passArr[i]) < 32 || charToByteAscii2(passArr[i]) > 126) {
return false;
}
}
} catch (Exception e) {
return false;
}
}else {
return false;
}
return null;
return true;
}
private static byte charToByteAscii2(char ch){
byte byteAscii = (byte)ch;
return byteAscii;
}
}

@ -69,7 +69,6 @@ public class DateUtils {
File[] files = file.listFiles();
for (File file1 : files) {
System.out.println(file1.getName());
}
}

@ -137,7 +137,6 @@ public class FileUtils {
String a = address.substring(0, address.indexOf(".pdf"));
String emrPath = a.substring(a.lastIndexOf("_") + 1, a.length());
System.out.println(emrPath);
}

@ -0,0 +1,268 @@
/**
* Copyright (C), 2015-2019
* Author: HJL
* Date: 2019/6/13 18:49
* Description:
*/
package com.ann.demo.utils;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* HttpClient4.3
*
* @author
*/
public class HttpClientUtils {
private static Logger logger = LoggerFactory.getLogger(HttpClientUtils.class); // 日志记录
private static RequestConfig requestConfig = null;
static {
// 设置请求和传输超时时间
requestConfig = RequestConfig.custom().setSocketTimeout(600000).setConnectTimeout(600000).build();
}
/**
* postjson
*
* @param url url
* @param jsonParam
* @return
*/
public static JSONObject httpPost(String url, JSONObject jsonParam) {
// post请求返回结果
CloseableHttpClient httpClient = HttpClients.createDefault();
JSONObject jsonResult = null;
HttpPost httpPost = new HttpPost(url);
// 设置请求和传输超时时间
httpPost.setConfig(requestConfig);
try {
if (null != jsonParam) {
// 解决中文乱码问题
StringEntity entity = new StringEntity(jsonParam.toString(), "utf-8");
entity.setContentEncoding("UTF-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);
}
CloseableHttpResponse result = httpClient.execute(httpPost);
// 请求发送成功,并得到响应
if (result.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String str = "";
try {
// 读取服务器返回过来的json字符串数据
str = EntityUtils.toString(result.getEntity(), "utf-8");
// 把json字符串转换成json对象
jsonResult = JSONObject.parseObject(str);
} catch (Exception e) {
logger.error("post请求提交失败:" + url, e);
}
}
} catch (IOException e) {
logger.error("post请求提交失败:" + url, e);
} finally {
httpPost.releaseConnection();
}
return jsonResult;
}
/**
* postString name=Jack&sex=1&type=2
* Content-type:application/x-www-form-urlencoded
*
* @param url url
* @param strParam
* @return
*/
public static JSONObject httpPost(String url, String strParam) {
// post请求返回结果
CloseableHttpClient httpClient = HttpClients.createDefault();
JSONObject jsonResult = null;
HttpPost httpPost = new HttpPost(url);
httpPost.setConfig(requestConfig);
try {
if (null != strParam) {
// 解决中文乱码问题
StringEntity entity = new StringEntity(strParam, "utf-8");
entity.setContentEncoding("UTF-8");
entity.setContentType("application/x-www-form-urlencoded");
httpPost.setEntity(entity);
}
CloseableHttpResponse result = httpClient.execute(httpPost);
// 请求发送成功,并得到响应
if (result.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String str = "";
try {
// 读取服务器返回过来的json字符串数据
str = EntityUtils.toString(result.getEntity(), "utf-8");
// 把json字符串转换成json对象
jsonResult = JSONObject.parseObject(str);
} catch (Exception e) {
logger.error("post请求提交失败:" + url, e);
}
}
} catch (IOException e) {
logger.error("post请求提交失败:" + url, e);
} finally {
httpPost.releaseConnection();
}
return jsonResult;
}
/**
* get
*
* @param url
* @return
*/
public static JSONObject httpGet(String url) {
// get请求返回结果
JSONObject jsonResult = null;
CloseableHttpClient client = HttpClients.createDefault();
// 发送get请求
HttpGet request = new HttpGet(url);
request.setConfig(requestConfig);
try {
CloseableHttpResponse response = client.execute(request);
// 请求发送成功,并得到响应
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
// 读取服务器返回过来的json字符串数据
HttpEntity entity = response.getEntity();
String strResult = EntityUtils.toString(entity, "utf-8");
// 把json字符串转换成json对象
jsonResult = JSONObject.parseObject(strResult);
} else {
logger.error("get请求提交失败:" + url);
}
} catch (IOException e) {
logger.error("get请求提交失败:" + url, e);
} finally {
request.releaseConnection();
}
return jsonResult;
}
public static String doGet(String url, Map<String, String> param) {
// 创建Httpclient对象
CloseableHttpClient httpclient = HttpClients.createDefault();
String resultString = "";
CloseableHttpResponse response = null;
try {
// 创建uri
URIBuilder builder = new URIBuilder(url);
if (param != null) {
for (String key : param.keySet()) {
builder.addParameter(key, param.get(key));
}
}
URI uri = builder.build();
// 创建http GET请求
HttpGet httpGet = new HttpGet(uri);
// 执行请求
response = httpclient.execute(httpGet);
// 判断返回状态是否为200
if (response.getStatusLine().getStatusCode() == 200) {
resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (response != null) {
response.close();
}
httpclient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return resultString;
}
public static String doGet(String url) {
return doGet(url, null);
}
public static String doPost(String url,String param) {
CloseableHttpClient httpClient = HttpClients.createDefault();
try {
HttpPost httpPost = new HttpPost(url);
StringEntity requestEntity = new StringEntity(param, ContentType.APPLICATION_JSON);
httpPost.setEntity(requestEntity);
HttpResponse response = httpClient.execute(httpPost);
HttpEntity responseEntity = response.getEntity();
String responseBody = EntityUtils.toString(responseEntity);
return responseBody;
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
public static String doPost(String url) {
return doPost(url, null);
}
public static String doPostJson(String url, String json) {
// 创建Httpclient对象
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = null;
String resultString = "";
try {
// 创建Http Post请求
HttpPost httpPost = new HttpPost(url);
// 创建请求内容
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
// 执行http请求
response = httpClient.execute(httpPost);
resultString = EntityUtils.toString(response.getEntity(), "utf-8");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
response.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return resultString;
}
}

@ -0,0 +1,29 @@
package com.ann.demo.utils;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JsonUtils {
public static String getValueByKey(String jsonString, String key) {
try {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(jsonString);
JsonNode valueNode = jsonNode.get(key);
if (valueNode != null) {
return valueNode.asText();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static void main(String[] args) {
String jsonString = "{\"name\":\"John\",\"age\":30}";
String name = getValueByKey(jsonString, "name");
int age = Integer.parseInt(getValueByKey(jsonString, "age"));
}
}

@ -0,0 +1,41 @@
package com.ann.demo.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* @author
* @description: XXX
* @createTime 2023/9/5 16:57
*/
public class Md5Utils {
public static String strToMd5(String str) {
String hexString = null;
try {
// 创建MD5消息摘要对象
MessageDigest md = MessageDigest.getInstance("MD5");
// 计算消息的摘要
byte[] digest = md.digest(str.getBytes());
// 将摘要转换为十六进制字符串
hexString = bytesToHex(digest);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return hexString;
}
private static String bytesToHex(byte[] bytes) {
StringBuilder hexString = new StringBuilder();
for (byte b : bytes) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
}
}

@ -274,7 +274,6 @@ public class XMLUtils {
Node node = x.selectSingleNode(doc);
if (node != null) {
node.setText(replaceContent);
System.out.println(node.getText());
}
}catch (Exception e){
return null;

@ -12,10 +12,10 @@ spring:
# ddl-auto: update
# show-sql: true
# database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
#url: jdbc:sqlserver://10.6.1.127:1433;DatabaseName=DB_PrivilegeManagement_GYFY
url: jdbc:sqlserver://localhost:1433;DatabaseName=zj_record_new
url: jdbc:sqlserver://10.6.1.127:1433;DatabaseName=DB_PrivilegeManagement_GYFY
#url: jdbc:sqlserver://localhost:1433;DatabaseName=zj_record_new
username: sa
password: docus702
password: docus@702
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
jpa:
database: sql_server
@ -62,4 +62,33 @@ file:
# 真正部署的时候 这个要改成Z盘
pdfPath: D:/project_js
server:
port: 8080
port: 8885
logging:
config : classpath:logback-spring.xml
level:
com.example.mapper: debug
file:
#日志文件位置
name: D:/logs/toDayLog/log.log
#################################################
#登录接口
#子公司代码
siteCode: K0101
#客户代码
customerCode: 44000259
#收样点代码
collectionLocation: 44000259|003
#loginUrl
loginUrl: https://kmcs.kingmed.com.cn/km-op/cxf/v0.1.0.0/syncInfo2?wsdl
#namespaceURI
namespaceURI: http://com.org.kingmed
#webServiceMethod
webServiceMethod: login
#下载金域外送报告接口
#webServiceDownMethod
webServiceDownMethod: downloadPictureInfo
#调下载接口
#downfileUrl: http://192.168.16.85:9292/api/downplatform/report
downfileUrl: http://10.6.1.127:9291/api/downplatform/report

@ -1,47 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="10 seconds">
<contextName>logback</contextName>
<!-- 格式化输出:%date表示日期%thread表示线程名%-5level级别从左显示5个字符宽度 %msg日志消息%n是换行符-->
<property name="LOG_PATTERN" value="%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"/>
<!-- 定义日志存储的路径,不要配置相对路径 D:/logs/spring-log.%d{yyyy-MM-dd}.%i.log -->
<property name="FILE_PATH" value="D:/logs/%d{yyyy-MM-dd}/LISInterface.%i.log"/>
<!-- 控制台输出日志 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<!-- 日志级别过滤INFO以下 -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,%i索引【从数字0开始递增】,,, -->
<!-- appender是configuration的子节点是负责写日志的组件。 -->
<!-- ConsoleAppender把日志输出到控制台 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!-- 按照上面配置的LOG_PATTERN来打印日志 -->
<pattern>${LOG_PATTERN}</pattern>
<pattern>[%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%contextName] [%thread] [%X{traceId}] %-5level %logger{36} - %msg%n</pattern>
<!-- 控制台也要使用UTF-8不要使用GBK否则会中文乱码 -->
<charset>UTF-8</charset>
</encoder>
</appender>
<!--每天生成一个日志文件保存30天的日志文件。rollingFile用来切分文件的 -->
<appender name="rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- RollingFileAppender滚动记录文件先将日志记录到指定文件当符合某个条件时将日志记录到其他文件 -->
<!-- 以下的大概意思是1.先按日期存日志日期变了将前一天的日志文件名重命名为XXX%日期%索引新的日志仍然是demo.log -->
<!-- 2.如果日期没有发生变化但是当前日志的文件大小超过1KB时对当前日志进行分割 重命名-->
<appender name="demolog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>D:/logs/toDayLog/log.log</File>
<!-- rollingPolicy:当发生滚动时,决定 RollingFileAppender 的行为,涉及文件移动和重命名。 -->
<!-- TimeBasedRollingPolicy 最常用的滚动策略,它根据时间来制定滚动策略,既负责滚动也负责出发滚动 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${FILE_PATH}</fileNamePattern>
<!-- keep 15 days' worth of history -->
<maxHistory>30</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- 日志文件的最大大小 -->
<maxFileSize>2MB</maxFileSize>
<!-- 活动文件的名字会根据fileNamePattern的值每隔一段时间改变一次 -->
<!-- 文件名log/demo.2017-12-05.0.log -->
<fileNamePattern>D:/logs/log/demo.%d.%i.log</fileNamePattern>
<!-- 每产生一个日志文件该日志文件的保存期限为15天 -->
<maxHistory>15</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- maxFileSize:这是活动文件的大小默认值是10MB测试时可改成1KB看效果 -->
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- 超出删除老文件 -->
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${LOG_PATTERN}</pattern>
<!-- pattern节点用来设置日志的输入格式 -->
<pattern>
[%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%C] [%t] [%X{traceId}] [%L] [%-5p] %m%n
</pattern>
<charset>utf-8</charset>
<!-- 记录日志的编码:此处设置字符集 - -->
<charset>UTF-8</charset>
</encoder>
<bufferSize>1024</bufferSize>
</appender>
<!-- project default level -->
<logger name="com.ann" level="ERROR"/>
<!-- 日志输出级别 -->
<root level="error">
<appender-ref ref="console"/>
<appender-ref ref="rollingFile"/>
<appender name="ASYNC_FILE" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="demolog" />
</appender>
<!-- 控制台输出日志级别 -->
<root level="info">
<appender-ref ref="STDOUT" />
</root>
<!-- 指定项目中某个包,当有日志操作行为时的日志记录级别 -->
<!-- com.liyan为根包也就是只要是发生在这个根包下面的所有日志操作行为的权限都是DEBUG -->
<!-- 级别依次为【从高到低】FATAL > ERROR > WARN > INFO > DEBUG > TRACE -->
<logger name="com" level="INFO">
<appender-ref ref="ASYNC_FILE" />
</logger>
</configuration>

@ -14,7 +14,7 @@
<div class="col-sm-offset-1 col-sm-6">
<label for="url">URL</label>
<select class="form-control" id="url" name="url">
<option value="http://localhost:8080/services/HomepageDictionary?wsdl">本地</option>
<option value="http://localhost:8885/services/HomepageDictionary?wsdl">本地</option>
<option value="http://10.6.1.128:8888/AcquisitionServer/services/HomepageDictionary?wsdl">服务端</option>
</select>
</div>

@ -11,6 +11,7 @@ public class DemoApplicationTests {
@Test
public void contextLoads() {
int i = (int)Math.pow(2,3);
}
}

Loading…
Cancel
Save