master
parent
5e61db3a54
commit
5661e7b1dd
@ -0,0 +1,42 @@
|
|||||||
|
package me.zhengjie.modules.uploadnew.httpRequest;
|
||||||
|
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.TrustManager;
|
||||||
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
|
||||||
|
import org.apache.http.conn.ClientConnectionManager;
|
||||||
|
import org.apache.http.conn.scheme.Scheme;
|
||||||
|
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||||
|
import org.apache.http.conn.ssl.SSLSocketFactory;
|
||||||
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
|
|
||||||
|
//用于进行Https请求的HttpClient
|
||||||
|
public class SSLClient extends DefaultHttpClient {
|
||||||
|
public SSLClient() throws Exception {
|
||||||
|
super();
|
||||||
|
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||||
|
X509TrustManager tm = new X509TrustManager() {
|
||||||
|
@Override
|
||||||
|
public void checkClientTrusted(X509Certificate[] chain,
|
||||||
|
String authType) throws CertificateException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkServerTrusted(X509Certificate[] chain,
|
||||||
|
String authType) throws CertificateException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ctx.init(null, new TrustManager[]{tm}, null);
|
||||||
|
SSLSocketFactory ssf = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||||
|
ClientConnectionManager ccm = this.getConnectionManager();
|
||||||
|
SchemeRegistry sr = ccm.getSchemeRegistry();
|
||||||
|
sr.register(new Scheme("https", 443, ssf));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package me.zhengjie.modules.uploadnew.listener;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.lang.ObjectId;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
|
import com.alibaba.excel.event.AnalysisEventListener;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import me.zhengjie.modules.formdata.domain.Formdata;
|
||||||
|
import me.zhengjie.modules.uploadnew.service.dto.ExcelDataDTO;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wjt
|
||||||
|
* @date 2021/8/6
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class EasyExcelListener extends AnalysisEventListener<ExcelDataDTO> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于存储解析的对象数据
|
||||||
|
*/
|
||||||
|
private List<Formdata> FormDataList = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(ExcelDataDTO excelDataDTO, AnalysisContext analysisContext) {
|
||||||
|
log.info("解析到一条数据:{}", JSONUtil.toJsonStr(excelDataDTO));
|
||||||
|
Formdata formdata = new Formdata();
|
||||||
|
formdata.setSourceId((int) IdUtil.getSnowflake(1, 1).nextId());
|
||||||
|
formdata.setUploadTime(DateUtil.date().toTimestamp());
|
||||||
|
formdata.setName(excelDataDTO.getName());
|
||||||
|
formdata.setAge(excelDataDTO.getAge());
|
||||||
|
formdata.setCity(excelDataDTO.getCity());
|
||||||
|
formdata.setPhone(String.valueOf(excelDataDTO.getPhone()));
|
||||||
|
formdata.setProvince(excelDataDTO.getProvince());
|
||||||
|
FormDataList.add(formdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||||
|
log.info("解析完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Formdata> getData() {
|
||||||
|
return FormDataList;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package me.zhengjie.modules.uploadnew.service.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wjt
|
||||||
|
* @date 2021/8/6
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ExcelDataDTO {
|
||||||
|
@Column(name = "name")
|
||||||
|
@ApiModelProperty(value = "称呼")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Column(name = "phone")
|
||||||
|
@ApiModelProperty(value = "联系方式")
|
||||||
|
private Integer phone;
|
||||||
|
|
||||||
|
@Column(name = "age")
|
||||||
|
@ApiModelProperty(value = "年龄")
|
||||||
|
private Integer age;
|
||||||
|
|
||||||
|
@Column(name = "province")
|
||||||
|
@ApiModelProperty(value = "省份")
|
||||||
|
private String province;
|
||||||
|
|
||||||
|
@Column(name = "city")
|
||||||
|
@ApiModelProperty(value = "城市")
|
||||||
|
private String city;
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package me.zhengjie.modules.uploadnew.service.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wjt
|
||||||
|
* @date 2021/8/6
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OosDTO {
|
||||||
|
private Integer id;
|
||||||
|
private String name;
|
||||||
|
private Integer age;
|
||||||
|
private String province;
|
||||||
|
private String city;
|
||||||
|
private String voiceaddr;
|
||||||
|
private String phone;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package me.zhengjie.modules.uploadnew.service.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wjt
|
||||||
|
* @date 2021/8/6
|
||||||
|
* 音频文件对象
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WavDTO {
|
||||||
|
private String name;
|
||||||
|
private InputStream line;
|
||||||
|
}
|
Loading…
Reference in New Issue