forked from rongchao/epmet-cloud-rizhao
8 changed files with 769 additions and 191 deletions
@ -0,0 +1,102 @@ |
|||
package com.epmet.utils; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.http.HttpEntity; |
|||
import org.apache.http.HttpResponse; |
|||
import org.apache.http.client.methods.HttpGet; |
|||
import org.apache.http.conn.ssl.NoopHostnameVerifier; |
|||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
|||
import org.apache.http.conn.ssl.TrustAllStrategy; |
|||
import org.apache.http.impl.client.CloseableHttpClient; |
|||
import org.apache.http.impl.client.HttpClients; |
|||
import org.apache.http.ssl.SSLContexts; |
|||
|
|||
import java.io.ByteArrayOutputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.util.Base64; |
|||
|
|||
/** |
|||
* @author yan Lu |
|||
* @description 日照:事件上报城管工具类 |
|||
* @create 2023/7/3 16:32 |
|||
*/ |
|||
|
|||
@Slf4j |
|||
public class IcEventReportUtils { |
|||
|
|||
/** |
|||
* 请求地址前缀 |
|||
*/ |
|||
private static final String URL_PREFIX = "https://rzzhsq.shuzirizhao.cn/eUrbanMIS/openapi/v2"; |
|||
/** |
|||
* 上报地址 |
|||
*/ |
|||
public static final String REPORT_URL = URL_PREFIX + "/upstream"; |
|||
|
|||
/** |
|||
* 处理状态地址 |
|||
*/ |
|||
public static final String REPORT_STATUS_URL = URL_PREFIX + "/downstream/recprocess"; |
|||
|
|||
/** |
|||
* 调用方法 |
|||
*/ |
|||
public static final String ACTION_TYPE = "UP_REC_REPORT"; |
|||
|
|||
/** |
|||
* 发送方标识 |
|||
*/ |
|||
public static final String SENDER_CODE = "130057"; |
|||
|
|||
/** |
|||
* 处理状态码 |
|||
*/ |
|||
|
|||
public static final String STATUS_CODE = "371100"; |
|||
|
|||
/** |
|||
* 问题来源标示 |
|||
*/ |
|||
public static final Integer EVENT_SRC_ID = 130057; |
|||
|
|||
/** |
|||
* 获取多媒体资源并转换为base64编码 |
|||
* |
|||
* @param url |
|||
* @return |
|||
* @throws IOException |
|||
*/ |
|||
public static String getFileByBase64(String url) throws IOException { |
|||
SSLConnectionSocketFactory ssl; |
|||
CloseableHttpClient client = null; |
|||
ByteArrayOutputStream outputStream = null; |
|||
InputStream stream = null; |
|||
try { |
|||
//忽略服务端证书校验
|
|||
ssl = new SSLConnectionSocketFactory(SSLContexts.custom(). |
|||
loadTrustMaterial(null, new TrustAllStrategy()).build(), NoopHostnameVerifier.INSTANCE); |
|||
client = HttpClients.custom().setSSLSocketFactory(ssl).build(); |
|||
HttpResponse response = client.execute(new HttpGet(url)); |
|||
HttpEntity entity = response.getEntity(); |
|||
stream = entity.getContent(); |
|||
outputStream = new ByteArrayOutputStream(); |
|||
byte[] bytes = new byte[1024]; |
|||
int length; |
|||
while ((length = stream.read(bytes)) != -1) { |
|||
outputStream.write(bytes, 0, length); |
|||
} |
|||
return Base64.getEncoder().encodeToString(outputStream.toByteArray()); |
|||
} catch (Exception e) { |
|||
client.close(); |
|||
stream.close(); |
|||
outputStream.close(); |
|||
return ""; |
|||
} finally { |
|||
client.close(); |
|||
stream.close(); |
|||
outputStream.close(); |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,191 @@ |
|||
package com.epmet.utils; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author yan Lu |
|||
* @description 上报城管数据封装对象 |
|||
* @create 2023/7/3 16:43 |
|||
*/ |
|||
@Data |
|||
public class ReportCityManageData implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -5492975503443321965L; |
|||
|
|||
/** |
|||
* 问题描述 |
|||
*/ |
|||
@NotBlank(message = "问题描述不能为空") |
|||
private String eventDesc; |
|||
|
|||
/** |
|||
* 第三方案件唯一标识 |
|||
*/ |
|||
@NotBlank(message = "第三方案件唯一标识不能为空:上报事件ID") |
|||
private String otherTaskNum; |
|||
|
|||
/** |
|||
* 地址描述 |
|||
*/ |
|||
@NotBlank(message = "事件发生地址不能为空") |
|||
private String address; |
|||
|
|||
/** |
|||
* x坐标 |
|||
* 跟主业务系统同坐标系 |
|||
*/ |
|||
@NotBlank(message = "x坐标不能为空:跟主业务系统同坐标系") |
|||
private Double coordinateX; |
|||
|
|||
/** |
|||
* y坐标 |
|||
* 跟主业务系统同坐标系 |
|||
*/ |
|||
@NotBlank(message = "y坐标不能为空:跟主业务系统同坐标系") |
|||
private Double coordinateY; |
|||
|
|||
/** |
|||
* 经度 |
|||
* 采用在线地图坐标系,默认为0 |
|||
*/ |
|||
private Double lontitude; |
|||
|
|||
/** |
|||
* 纬度 |
|||
* 采用在线地图坐标系,默认为0 |
|||
*/ |
|||
private Double latitude; |
|||
|
|||
/** |
|||
* 问题来源标示 |
|||
* 例:微信举报 :56 |
|||
*/ |
|||
@NotBlank(message = "问题来源标示,例:微信举报:56") |
|||
private Integer eventSrcID; |
|||
|
|||
/** |
|||
* 所属区域代码 |
|||
*/ |
|||
private String districtCode; |
|||
|
|||
/** |
|||
* 所属区域 |
|||
*/ |
|||
private String districtName; |
|||
|
|||
/** |
|||
* 所属区域代码 |
|||
*/ |
|||
private String streetCode; |
|||
|
|||
/** |
|||
* 所属区域 |
|||
*/ |
|||
private String streetName; |
|||
|
|||
/** |
|||
* 所属社区代码 |
|||
*/ |
|||
private String communityCode; |
|||
|
|||
/** |
|||
* 所属社区 |
|||
*/ |
|||
private String communityName; |
|||
|
|||
/** |
|||
* 案卷类型标识 |
|||
*/ |
|||
@NotBlank(message = "案卷类型标识:城市管理 1,社会服务类 2") |
|||
private Integer recTypeID; |
|||
|
|||
/** |
|||
* 问题级别标识 |
|||
* 按照现场要求默认为1或者2 |
|||
*/ |
|||
@NotBlank(message = "问题级别标识:按照现场要求默认为1或者2") |
|||
private Integer eventLevelID; |
|||
|
|||
/** |
|||
* 问题类型标识 |
|||
* 临时采用默认值 1 |
|||
*/ |
|||
@NotBlank(message = "问题类型标识:临时采用默认值 1") |
|||
private String eventTypeCode; |
|||
|
|||
/** |
|||
* 问题大类标识 |
|||
*/ |
|||
private String mainTypeCode; |
|||
|
|||
/** |
|||
* 问题小类标识 |
|||
*/ |
|||
private String subTypeCode; |
|||
|
|||
/** |
|||
* 上报多媒体数量,没有多媒体默认0 |
|||
*/ |
|||
private Integer mediaNum; |
|||
|
|||
/** |
|||
* 上报人 |
|||
*/ |
|||
private String humanName; |
|||
|
|||
/** |
|||
* 上报人手机号 |
|||
*/ |
|||
private String cellphone; |
|||
|
|||
/** |
|||
* 多媒体信息 |
|||
*/ |
|||
private List<Media> medias; |
|||
|
|||
@Data |
|||
public static class Media { |
|||
/** |
|||
* 案件任务号 |
|||
*/ |
|||
private String taskNum; |
|||
|
|||
/** |
|||
* 文件名 |
|||
*/ |
|||
@NotBlank(message = "文件名不能为空") |
|||
private String mediaName; |
|||
|
|||
/** |
|||
* 多媒体的完整访问路径,优先推荐 |
|||
*/ |
|||
private String mediaURL; |
|||
|
|||
/** |
|||
* 多媒体用途 |
|||
* 上报、核查、核实、处置 |
|||
*/ |
|||
@NotBlank(message = "多媒体用途不能为空:上报、核查、核实、处置") |
|||
private String mediaUsage; |
|||
|
|||
/** |
|||
* 多媒体类型 |
|||
* IMAGE、VIDEO、VOICE、ATTACH |
|||
*/ |
|||
@NotBlank(message = "多媒体类型不能为空:IMAGE、VIDEO、VOICE、ATTACH") |
|||
private String mediaType; |
|||
|
|||
/** |
|||
* 多媒体内容 |
|||
* base64编码的表示多媒体的二进制数据流。 |
|||
*/ |
|||
private String content; |
|||
|
|||
} |
|||
|
|||
|
|||
} |
Loading…
Reference in new issue