26 changed files with 778 additions and 29 deletions
@ -0,0 +1,18 @@ |
|||
package com.elink.esua.epdc.dto.epdc; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 部门节点 |
|||
* |
|||
* @author work@yujt.net.cn |
|||
* @date 2019/11/27 10:03 |
|||
*/ |
|||
@Data |
|||
public class DeptCodeOption<T> { |
|||
|
|||
private List<T> options; |
|||
|
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.elink.esua.epdc.feign; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.admin.DeptCodeFormDTO; |
|||
import com.elink.esua.epdc.dto.epdc.DeptCodeOption; |
|||
import com.elink.esua.epdc.feign.fallback.AnalysisFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
|
|||
/** |
|||
* 数据分析模块调用 |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2020/9/9 15:41 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.EPDC_ANALYSIS_SERVER, fallback = AnalysisFeignClientFallback.class) |
|||
public interface AnalysisFeignClient { |
|||
|
|||
/** |
|||
* @Description 组织机构编码获取 |
|||
* @Author songyunpeng |
|||
* @Date 2021/1/7 |
|||
* @Param [] |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
**/ |
|||
@GetMapping(value = "analysis/admin/getDeptCode", consumes = MediaType.APPLICATION_JSON_VALUE) |
|||
Result<DeptCodeOption> getDeptCode(@RequestBody DeptCodeFormDTO deptCodeFormDTO); |
|||
|
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.elink.esua.epdc.feign.fallback; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.admin.DeptCodeFormDTO; |
|||
import com.elink.esua.epdc.dto.epdc.DeptCodeOption; |
|||
import com.elink.esua.epdc.feign.AnalysisFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Author:songyunpeg |
|||
* @Date:2020/9/9 15:42 |
|||
*/ |
|||
@Component |
|||
public class AnalysisFeignClientFallback implements AnalysisFeignClient { |
|||
|
|||
|
|||
@Override |
|||
public Result<DeptCodeOption> getDeptCode(DeptCodeFormDTO deptCodeFormDTO) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_ANALYSIS_SERVER, "homePagePlatformSummary",deptCodeFormDTO); |
|||
} |
|||
} |
@ -0,0 +1,212 @@ |
|||
package com.elink.esua.epdc.commons.tools.constant; |
|||
|
|||
/** |
|||
* 党群e事通接口配置 |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2020/8/20 13:46 |
|||
*/ |
|||
public interface EpmetConstant { |
|||
|
|||
/** |
|||
* 1、首页-平台各类总数上报 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_HOMEPAGE_PLATFORM_SUMMARY = "/data/stats/kcscreencoll/homepage/platformsummary"; |
|||
|
|||
/** |
|||
* 2、议题分析-各类总数 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_ISSUE_SUMMARY = "/data/stats/kcscreencoll/issue/summary"; |
|||
|
|||
/** |
|||
* 3、议题分析-参与趋势 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_ISSUE_TREND = "/data/stats/kcscreencoll/issue/trend"; |
|||
|
|||
/** |
|||
* 4、用户分析-各类总数 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_USER_SUMMARY = "/data/stats/kcscreencoll/user/summary"; |
|||
|
|||
/** |
|||
* 5、公益互助-志愿者公益时长排名 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_VOLUNTEER_HEART_RANK = "/data/stats/kcscreencoll/volunteer/heartrank"; |
|||
|
|||
/** |
|||
* 6、用户分析-用户趋势 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_USER_USER_HEART_RANK = "/data/stats/kcscreencoll/user/userheartrank"; |
|||
|
|||
/** |
|||
* 7、公益互助-活动各类总数 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_ACT_SUMMARY = "/data/stats/kcscreencoll/act/summary"; |
|||
|
|||
/** |
|||
* 8、公益互助-活动次数趋势 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_ACT_TREND = "/data/stats/kcscreencoll/act/trend"; |
|||
|
|||
/** |
|||
* 9、公益互助-志愿者画像 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_ACT_VOLUNTEER_SUMMARY = "/data/stats/kcscreencoll/act/volunteersummary"; |
|||
|
|||
/** |
|||
* 10、项目分析-各类总数 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_PROJECT_SUMMARY = "/data/stats/kcscreencoll/project/summary"; |
|||
|
|||
/** |
|||
* 11、项目分析-按分类统计 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_PROJECT_CATEGORY_SUMMARY = "/data/stats/kcscreencoll/project/categorysummary"; |
|||
|
|||
/** |
|||
* 12、项目分析-满意度分析 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_PROJECT_STATISTIC_ANALYSIS = "/data/stats/kcscreencoll/project/satisanalysis"; |
|||
|
|||
/** |
|||
* 13、党建声音-新闻各类总数汇总 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_NEWS_SUMMARY = "/data/stats/kcscreencoll/news/summary"; |
|||
|
|||
/** |
|||
* 14、党建声音-新闻阅读参与趋势 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_NEWS_TREND = "/data/stats/kcscreencoll/news/trend"; |
|||
|
|||
/** |
|||
* 15、党建声音-热度新闻排行 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_NEWS_HOT_RANK = "/data/stats/kcscreencoll/news/hotrank"; |
|||
|
|||
/** |
|||
* 16、党建声音-新闻按类别统计 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_NEWS_CATEGORY_ANALYSIS = "/data/stats/kcscreencoll/news/categoryanalysis"; |
|||
|
|||
/** |
|||
* 17、邻里党群-各类总数汇总 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_GROUP_SUMMARY = "/data/stats/kcscreencoll/group/summary"; |
|||
|
|||
/** |
|||
* 18、邻里党群-小组详情 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_GROUP_DETAIL = "/data/stats/kcscreencoll/group/detail"; |
|||
|
|||
/** |
|||
* 19、邻里党群-话题参与趋势 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_GROUP_TOPIC_TREND = "/data/stats/kcscreencoll/group/topictrend"; |
|||
|
|||
/** |
|||
* 09、党建引领|基层治理-居民(党员)积分排行榜 |
|||
*/ |
|||
String EPMET_KC_SCREEN_COLL_PARTY_USER_RANK_DATA = "/data/stats/screencoll/partyuserrankdata"; |
|||
|
|||
/** |
|||
* 01、党建能力-党员相关指标上报 |
|||
*/ |
|||
String EPMET_INDEX_COLLECT_GRID_PARTY_MEMBER_DATA = "/data/stats/indexcollect/gridpartymemberdata"; |
|||
|
|||
/** |
|||
* 02、党建能力-网格相关指标上报 |
|||
*/ |
|||
String EPMET_INDEX_COLLECT_GRID_PARTY_ABILITY = "/data/stats/indexcollect/gridpartyability"; |
|||
|
|||
/** |
|||
* 03、党建能力-区街道及社区相关指标 |
|||
*/ |
|||
String EPMET_INDEX_COLLECT_ORG_PARTY_ABILITY = "/data/stats/indexcollect/orgpartyability"; |
|||
|
|||
/** |
|||
* 04、服务能力-网格相关指标 |
|||
*/ |
|||
String EPMET_INDEX_COLLECT_GRID_SERVICE_ABILITY = "/data/stats/indexcollect/gridserviceability"; |
|||
|
|||
/** |
|||
* 05、服务能力-组织(街道|社区|全区)相关指标 |
|||
*/ |
|||
String EPMET_INDEX_COLLECT_ORG_SERVICE_ABILITY = "/data/stats/indexcollect/orgserviceability"; |
|||
|
|||
/** |
|||
* 06、治理能力-网格相关指标 |
|||
*/ |
|||
String EPMET_INDEX_COLLECT_GRID_GOVERN_ABILITY = "/data/stats/indexcollect/gridgovrnability"; |
|||
|
|||
/** |
|||
* 07、治理能力-区街道及社区相关指标 |
|||
*/ |
|||
String EPMET_INDEX_COLLECT_ORG_GOVERN_ABILITY = "/data/stats/indexcollect/orggovrnability"; |
|||
|
|||
/** |
|||
* 08、治理能力-部门相关指标 |
|||
*/ |
|||
String EPMET_INDEX_COLLECT_DEPT_GOVERN_ABILITY = "/data/stats/indexcollect/deptgovrnability"; |
|||
|
|||
/** |
|||
* 【按月】计算指标数据 |
|||
*/ |
|||
String EPMET_INDEX_CALCULATE_ALL = "/data/stats/indexcalculate/all"; |
|||
|
|||
/** |
|||
* 014、组织层级 |
|||
*/ |
|||
String EPMET_SCREEN_COLL_CUSTOMER_AGENCY = "/data/stats/screencoll/customeragency"; |
|||
|
|||
/** |
|||
* 015、网格信息上传 |
|||
*/ |
|||
String EPMET_SCREEN_COLL_CUSTOMER_GRID = "/data/stats/screencoll/customergrid"; |
|||
|
|||
/** |
|||
* 016、部门信息上传 |
|||
*/ |
|||
String EPMET_SCREEN_COLL_CUSTOMER_DEPT = "/data/stats/screencoll/customerdept"; |
|||
|
|||
/** |
|||
* 行政地区编码查询 |
|||
*/ |
|||
String EPMET_SCREEN_COLL_DEPT_CODE = "/data/report/screen/agency/areacodedict"; |
|||
|
|||
|
|||
/** |
|||
* 行政地区编码查询 - 锦水街道 |
|||
*/ |
|||
String DEPT_CODE_KCZ = "370124"; |
|||
|
|||
|
|||
/** |
|||
* 接口请求头 |
|||
*/ |
|||
String HEARD_KEY_AUTHORIZATION = "Authorization"; |
|||
|
|||
/** |
|||
* 接口请求头 |
|||
*/ |
|||
String HEARD_KEY_ACCESS_TOKEN = "AccessToken"; |
|||
|
|||
/** |
|||
* 接口请求头 |
|||
*/ |
|||
String HEARD_KEY_APP_ID = "AppId"; |
|||
|
|||
/** |
|||
* AccessToken key:客户ID |
|||
*/ |
|||
String ACCESS_TOKEN_KEY_CUSTOMER_ID = "customerId"; |
|||
|
|||
/** |
|||
* AccessToken key:应用ID |
|||
*/ |
|||
String ACCESS_TOKEN_KEY_APP_ID = "appId"; |
|||
|
|||
/** |
|||
* AccessToken key:时间戳 |
|||
*/ |
|||
String ACCESS_TOKEN_KEY_TS = "ts"; |
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.elink.esua.epdc.dto.admin; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author songyunpeng |
|||
* @Description 获取行政区域编码参数 |
|||
* @create 2021-01-07 |
|||
*/ |
|||
@Data |
|||
public class DeptCodeFormDTO implements Serializable { |
|||
|
|||
/** |
|||
* 部门区域编码 |
|||
*/ |
|||
private String rootAreaCode; |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.elink.esua.epdc.dto.admin; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author songyunpeng |
|||
* @Description |
|||
* @create 2021-01-07 |
|||
*/ |
|||
@Data |
|||
public class DeptCodeTree implements Serializable { |
|||
|
|||
/** |
|||
* 部门区域编码 |
|||
*/ |
|||
private String code; |
|||
|
|||
/** |
|||
* 名称 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 下一级 |
|||
*/ |
|||
private List<DeptCodeTree> children; |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,46 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.jwt; |
|||
|
|||
import com.elink.esua.epdc.properties.EpmetProperties; |
|||
import io.jsonwebtoken.Jwts; |
|||
import io.jsonwebtoken.SignatureAlgorithm; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* Jwt工具类 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Component |
|||
public class JwtUtils { |
|||
|
|||
@Autowired |
|||
private EpmetProperties epmetProperties; |
|||
|
|||
/** |
|||
* 生成上报接口accessToken |
|||
* |
|||
* @param claims |
|||
* @return java.lang.String |
|||
* @author Liuchuang |
|||
* @since 2020/9/7 14:11 |
|||
*/ |
|||
public String getEpmetAccessToken(Map<String,Object> claims){ |
|||
return Jwts.builder() |
|||
.setHeaderParam("typ", "JWT") |
|||
.setClaims(claims) |
|||
.signWith(SignatureAlgorithm.HS512, epmetProperties.getSecret()) |
|||
.compact(); |
|||
} |
|||
} |
@ -0,0 +1,38 @@ |
|||
package com.elink.esua.epdc.modules.admin.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.admin.DeptCodeFormDTO; |
|||
import com.elink.esua.epdc.dto.epdc.DeptCodeOption; |
|||
import com.elink.esua.epdc.modules.admin.service.AdminAnalysisService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @Description admin相关 |
|||
* @Author songyunpeng |
|||
* @Date 2020/2/10 16:06 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("admin") |
|||
public class AdminAnalysisController { |
|||
|
|||
@Autowired |
|||
private AdminAnalysisService adminAnalysisService; |
|||
|
|||
/** |
|||
* @Description 获取组织机构编码 |
|||
* @Author songyunpeng |
|||
* @Date 2021/1/7 |
|||
* @Param [] |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
**/ |
|||
@GetMapping("getDeptCode") |
|||
public Result<DeptCodeOption> getDeptCode(@RequestBody DeptCodeFormDTO deptCodeFormDTO){ |
|||
DeptCodeOption deptCodeOption = adminAnalysisService.getDeptCode(deptCodeFormDTO); |
|||
return new Result().ok(deptCodeOption); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.elink.esua.epdc.modules.admin.service; |
|||
|
|||
import com.elink.esua.epdc.dto.admin.DeptCodeFormDTO; |
|||
import com.elink.esua.epdc.dto.epdc.DeptCodeOption; |
|||
|
|||
/** |
|||
* @Description admin相关 |
|||
* @Author songyunpeng |
|||
* @Date 2020/2/10 16:06 |
|||
*/ |
|||
public interface AdminAnalysisService { |
|||
/** |
|||
* @Description 获取组织机构编码 |
|||
* @Author songyunpeng |
|||
* @Date 2021/1/7 |
|||
* @Param [] |
|||
* @return java.lang.String |
|||
**/ |
|||
DeptCodeOption getDeptCode(DeptCodeFormDTO deptCodeFormDTO); |
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.elink.esua.epdc.modules.admin.service.impl; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.elink.esua.epdc.commons.tools.constant.EpmetConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.admin.DeptCodeFormDTO; |
|||
import com.elink.esua.epdc.dto.admin.DeptCodeTree; |
|||
import com.elink.esua.epdc.dto.epdc.DeptCodeOption; |
|||
import com.elink.esua.epdc.dto.issue.result.IssueResultDTO; |
|||
import com.elink.esua.epdc.modules.admin.service.AdminAnalysisService; |
|||
import com.elink.esua.epdc.modules.issue.dao.IssueAnalysisDao; |
|||
import com.elink.esua.epdc.utils.EpmetUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description admin相关 |
|||
* @Author songyunpeng |
|||
* @Date 2020/2/10 16:06 |
|||
*/ |
|||
@Service |
|||
public class AdminAnalysisServiceImpl extends BaseServiceImpl<IssueAnalysisDao, IssueResultDTO> implements AdminAnalysisService { |
|||
|
|||
@Autowired |
|||
private EpmetUtils epmetUtils; |
|||
|
|||
|
|||
@Override |
|||
public DeptCodeOption getDeptCode(DeptCodeFormDTO deptCodeFormDTO) { |
|||
String dataResult = epmetUtils.httpPost(EpmetConstant.EPMET_SCREEN_COLL_DEPT_CODE, JSONObject.toJSONString(deptCodeFormDTO)); |
|||
JSONObject jsonObject = JSONObject.parseObject(dataResult); |
|||
Result deptCodeTreeResult = JSON.toJavaObject(jsonObject, Result.class ); |
|||
if(deptCodeTreeResult!=null && deptCodeTreeResult.getData()!=null){ |
|||
List<DeptCodeTree> deptCodeTreeList = JSONArray.parseArray(JSONObject.toJSONString(deptCodeTreeResult.getData()), DeptCodeTree.class); |
|||
DeptCodeOption deptCodeOption = new DeptCodeOption(); |
|||
deptCodeOption.setOptions(deptCodeTreeList); |
|||
return deptCodeOption; |
|||
} |
|||
return new DeptCodeOption(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,67 @@ |
|||
package com.elink.esua.epdc.properties; |
|||
|
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
/** |
|||
* 党群e事通接口配置 |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2020/8/20 13:22 |
|||
*/ |
|||
@Configuration |
|||
@ConfigurationProperties(prefix = "epmet.config") |
|||
public class EpmetProperties { |
|||
|
|||
/** |
|||
* 应用ID |
|||
*/ |
|||
private String appId; |
|||
|
|||
/** |
|||
* 接口前缀 |
|||
*/ |
|||
private String url; |
|||
|
|||
/** |
|||
* 生成AccessToken密钥 |
|||
*/ |
|||
private String secret; |
|||
|
|||
/** |
|||
* 客户ID |
|||
*/ |
|||
private String customerId; |
|||
|
|||
public String getAppId() { |
|||
return appId; |
|||
} |
|||
|
|||
public void setAppId(String appId) { |
|||
this.appId = appId; |
|||
} |
|||
|
|||
public String getUrl() { |
|||
return url; |
|||
} |
|||
|
|||
public void setUrl(String url) { |
|||
this.url = url; |
|||
} |
|||
|
|||
public String getSecret() { |
|||
return secret; |
|||
} |
|||
|
|||
public void setSecret(String secret) { |
|||
this.secret = secret; |
|||
} |
|||
|
|||
public String getCustomerId() { |
|||
return customerId; |
|||
} |
|||
|
|||
public void setCustomerId(String customerId) { |
|||
this.customerId = customerId; |
|||
} |
|||
} |
@ -0,0 +1,88 @@ |
|||
package com.elink.esua.epdc.utils; |
|||
|
|||
import cn.hutool.http.HttpRequest; |
|||
import cn.hutool.http.HttpResponse; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.elink.esua.epdc.commons.tools.constant.EpmetConstant; |
|||
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|||
import com.elink.esua.epdc.jwt.JwtUtils; |
|||
import com.elink.esua.epdc.properties.EpmetProperties; |
|||
import org.apache.logging.log4j.LogManager; |
|||
import org.apache.logging.log4j.Logger; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
@Component |
|||
public class EpmetUtils { |
|||
|
|||
private final Logger logger = LogManager.getLogger(getClass()); |
|||
|
|||
@Autowired |
|||
private EpmetProperties epmetProperties; |
|||
|
|||
@Autowired |
|||
private JwtUtils jwtUtils; |
|||
|
|||
/** |
|||
* 大屏数据上报 |
|||
* |
|||
* @param urlSuffix 接口地址后缀 |
|||
* @param param 入参 |
|||
* @return java.lang.String |
|||
* @author Liuchuang |
|||
* @since 2020/9/7 14:07 |
|||
*/ |
|||
public String httpPost(String urlSuffix,String param) { |
|||
|
|||
String code = "code"; |
|||
|
|||
// 应用ID
|
|||
String appId = epmetProperties.getAppId(); |
|||
// 生成AccessToken
|
|||
String accessToken = getEpmetAccessToken(); |
|||
// 接口地址
|
|||
String url = epmetProperties.getUrl().concat(urlSuffix); |
|||
HttpResponse response = null; |
|||
try { |
|||
response = HttpRequest.post(url).body(param) |
|||
.header(EpmetConstant.HEARD_KEY_ACCESS_TOKEN, accessToken) |
|||
.header(EpmetConstant.HEARD_KEY_APP_ID, appId) |
|||
.header("lan", "zh") |
|||
.header("Content-Type", "application/json") |
|||
.header("Date-Type","real") |
|||
.execute(); |
|||
if (NumConstant.TWO_HUNDRED != response.getStatus()) { |
|||
logger.error("数据上报失败, 返回状态:{}, 请求参数:{appId:{}, url:{}, accessToken:{}, param:{}}", |
|||
response.getStatus(), appId, url, accessToken, param); |
|||
} else { |
|||
JSONObject result = JSONObject.parseObject(response.body()); |
|||
if (!NumConstant.ZERO_STR.equals(result.get(code).toString())) { |
|||
logger.info("数据上报失败:{},请求地址:{},请求参数:{}", JSONObject.toJSONString(response.body()), url, param); |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return response.body(); |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 生成上报接口accessToken |
|||
* |
|||
* @return java.lang.String |
|||
* @author Liuchuang |
|||
* @since 2020/9/7 14:15 |
|||
*/ |
|||
private String getEpmetAccessToken (){ |
|||
Map<String, Object> accessTokenMap = new HashMap<>(3); |
|||
accessTokenMap.put(EpmetConstant.ACCESS_TOKEN_KEY_CUSTOMER_ID, epmetProperties.getCustomerId()); |
|||
accessTokenMap.put(EpmetConstant.ACCESS_TOKEN_KEY_APP_ID, epmetProperties.getAppId()); |
|||
accessTokenMap.put(EpmetConstant.ACCESS_TOKEN_KEY_TS, System.currentTimeMillis()); |
|||
|
|||
return jwtUtils.getEpmetAccessToken(accessTokenMap); |
|||
} |
|||
} |
Loading…
Reference in new issue