3 changed files with 127 additions and 0 deletions
@ -0,0 +1,43 @@ |
|||||
|
package com.elink.esua.epdc.commons.tools.enums; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @program: esua-epdc |
||||
|
* @description: 上报诉求至市中心 |
||||
|
* @author: wangtong |
||||
|
* @create: 2022-09-15 14:29 |
||||
|
**/ |
||||
|
public enum CityPushEnum implements Serializable { |
||||
|
|
||||
|
JJCD_YB("01","紧急程度-一般"), |
||||
|
JJCD_JJ("02","紧急程度-紧急"), |
||||
|
SQLY_WX("01","微信诉求"), |
||||
|
SBQS_SB("370203","市北区"),; |
||||
|
|
||||
|
|
||||
|
private String code; |
||||
|
private String name; |
||||
|
|
||||
|
|
||||
|
CityPushEnum(String code, String name) { |
||||
|
this.code = code; |
||||
|
this.name = name; |
||||
|
} |
||||
|
|
||||
|
public String getCode() { |
||||
|
return code; |
||||
|
} |
||||
|
|
||||
|
public void setCode(String code) { |
||||
|
this.code = code; |
||||
|
} |
||||
|
|
||||
|
public String getName() { |
||||
|
return name; |
||||
|
} |
||||
|
|
||||
|
public void setName(String name) { |
||||
|
this.name = name; |
||||
|
} |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
package com.elink.esua.epdc.gird.city.api; |
||||
|
|
||||
|
/** |
||||
|
* @describe: 推送项目相关信息到市平台 |
||||
|
* @author wangtong |
||||
|
* @date 2022/9/15 17:51 |
||||
|
* @params |
||||
|
* @return |
||||
|
*/ |
||||
|
public interface CityGridApi { |
||||
|
|
||||
|
/** |
||||
|
* @describe: 诉求上报 |
||||
|
* @author wangtong |
||||
|
* @date 2022/9/15 17:53 |
||||
|
* @params [data, httpUrl, interFaceName] |
||||
|
* @return void |
||||
|
*/ |
||||
|
void sendItemToCity(Object data,String httpUrl,String interFaceName); |
||||
|
} |
@ -0,0 +1,64 @@ |
|||||
|
package com.elink.esua.epdc.gird.city.api.impl; |
||||
|
|
||||
|
import cn.hutool.http.HttpRequest; |
||||
|
import cn.hutool.http.HttpResponse; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.elink.esua.epdc.gird.city.api.CityGridApi; |
||||
|
import com.elink.esua.epdc.gird.shibei.dto.result.SendEventResultDto; |
||||
|
import com.elink.esua.httpclient.HttpClientUtils; |
||||
|
import org.apache.logging.log4j.LogManager; |
||||
|
import org.apache.logging.log4j.Logger; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* @author wangtong |
||||
|
* @describe: 推送项目相关信息到市平台 |
||||
|
* @date 2022/9/15 17:54 |
||||
|
* @params |
||||
|
* @return |
||||
|
*/ |
||||
|
@Component |
||||
|
public class CityGridApiImpl implements CityGridApi { |
||||
|
|
||||
|
@Autowired |
||||
|
private HttpClientUtils httpClientUtils; |
||||
|
|
||||
|
private Logger LOGGER = LogManager.getLogger(HttpClientUtils.class); |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public void sendItemToCity(Object dataInfo, String httpUrl, String interFaceName) { |
||||
|
String data = JSONObject.toJSONString(dataInfo); |
||||
|
LOGGER.info("发送参数:" + data); |
||||
|
LOGGER.info("发送地址:" + httpUrl); |
||||
|
HttpResponse response = null; |
||||
|
try { |
||||
|
response = HttpRequest.post(httpUrl).body(data) |
||||
|
.header("lan", "zh") |
||||
|
.header("Content-type", "application/json").execute(); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
LOGGER.error(interFaceName + "信息异常:" + e.getMessage()); |
||||
|
} |
||||
|
LOGGER.info(interFaceName + "返回数据:" + response.body()); |
||||
|
JSONObject res = JSONObject.parseObject(response.body()); |
||||
|
SendEventResultDto result = null; |
||||
|
if (0 == Integer.parseInt(res.get("code").toString())) { |
||||
|
try { |
||||
|
result = (SendEventResultDto) JSONObject.toJavaObject((JSONObject) res.get("data"), SendEventResultDto.class); |
||||
|
result.setCode("0"); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
LOGGER.error(interFaceName + "返回结果处理错误:" + e.getMessage()); |
||||
|
} |
||||
|
} else { |
||||
|
try { |
||||
|
result = (SendEventResultDto) JSONObject.toJavaObject(res, SendEventResultDto.class); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
LOGGER.error(interFaceName + "返回结果处理错误:" + e.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue