Browse Source

事项基本信息irs接口

master
CMM 4 months ago
parent
commit
b7c0f1a9a2
11 changed files with 248 additions and 9 deletions
  1. +13
    -5
      kq-vas-api/pom.xml
  2. +1
    -1
      kq-vas-api/src/main/java/com/ningdatech/kqapi/App.java
  3. +2
    -1
      kq-vas-api/src/main/java/com/ningdatech/kqapi/common/handler/GlobalResponseHandler.java
  4. +47
    -0
      kq-vas-api/src/main/java/com/ningdatech/kqapi/irs/controller/IrsController.java
  5. +149
    -0
      kq-vas-api/src/main/java/com/ningdatech/kqapi/irs/manage/IrsManage.java
  6. +11
    -1
      kq-vas-api/src/main/resources/application-dev.yml
  7. +11
    -1
      kq-vas-api/src/main/resources/application-pre.yml
  8. +10
    -0
      kq-vas-api/src/main/resources/application-prod.yml
  9. +1
    -0
      kq-vas-api/src/main/resources/security/auth-dev.yml
  10. +1
    -0
      kq-vas-api/src/main/resources/security/auth-pre.yml
  11. +2
    -0
      kq-vas-api/src/main/resources/security/auth-prod.yml

+ 13
- 5
kq-vas-api/pom.xml View File

@@ -90,11 +90,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.16.1</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.fasterxml.jackson.core</groupId>-->
<!-- <artifactId>jackson-databind</artifactId>-->
<!-- <version>2.16.1</version>-->
<!-- </dependency>-->
<!--cache-->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
@@ -157,6 +157,14 @@
</dependency>
<dependency>
<groupId>com.ningdatech</groupId>
<artifactId>nd-irs-starter</artifactId>
</dependency>
<dependency>
<groupId>com.ningdatech</groupId>
<artifactId>nd-cache-starter</artifactId>
</dependency>
<dependency>
<groupId>com.ningdatech</groupId>
<artifactId>nd-file-starter</artifactId>
</dependency>
<dependency>


+ 1
- 1
kq-vas-api/src/main/java/com/ningdatech/kqapi/App.java View File

@@ -24,7 +24,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableTransactionManagement
@EnableAspectJAutoProxy(exposeProxy = true)
@ComponentScan(basePackages = {"com.ningdatech.kqapi", "com.ningdatech.kqapi.common"})
@ComponentScan(basePackages = {"com.ningdatech.kqapi", "com.ningdatech.kqapi.common", "com.ningdatech.irs"})
public class App {

protected static final String MAPPER_PACKAGES = "com.ningdatech.kqapi.**.mapper";


+ 2
- 1
kq-vas-api/src/main/java/com/ningdatech/kqapi/common/handler/GlobalResponseHandler.java View File

@@ -23,7 +23,8 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
"com.ningdatech.kqapi.user.controller",
"com.ningdatech.kqapi.security.controller",
"com.ningdatech.kqapi.zzsfw.controller",
"com.ningdatech.kqapi.scheduler.controller"
"com.ningdatech.kqapi.scheduler.controller",
"com.ningdatech.kqapi.irs.controller"
})
public class GlobalResponseHandler implements ResponseBodyAdvice<Object> {



+ 47
- 0
kq-vas-api/src/main/java/com/ningdatech/kqapi/irs/controller/IrsController.java View File

@@ -0,0 +1,47 @@
package com.ningdatech.kqapi.irs.controller;

import java.util.List;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ningdatech.kqapi.irs.manage.IrsManage;
import com.ningdatech.log.annotation.WebLog;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
* @author CMM
* @date 2024/8/19 11:11
*/
@Slf4j
@Validated
@RestController
@RequestMapping("/api/v1/irs")
@Api(value = "irs", tags = "irs-信息查询")
@RequiredArgsConstructor
public class IrsController {

private final IrsManage irsManage;

@ApiOperation(value = "irs事项基本信息列表", notes = "irs事项基本信息列表")
@GetMapping("/item-basic-info-list")
public Object itemBasicInfoList(@RequestParam(required = false) String startDate,
@RequestParam(required = false) String endDate,
@RequestParam Integer pageSize,
@RequestParam Integer pageNum) {
return irsManage.itemBasicInfoList(startDate, endDate, pageSize, pageNum);
}

@ApiOperation(value = "irs事项基本信息列表", notes = "irs事项基本信息列表")
@GetMapping("/item-basic-info-detail")
public Object itemBasicInfoDetail(@RequestParam String itemId) {
return irsManage.itemBasicInfoDetail(itemId);
}
}

+ 149
- 0
kq-vas-api/src/main/java/com/ningdatech/kqapi/irs/manage/IrsManage.java View File

@@ -0,0 +1,149 @@
package com.ningdatech.kqapi.irs.manage;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ningdatech.irs.service.IRefreshTokenService;
import com.ningdatech.irs.utils.HttpUtil;
import com.ningdatech.kqapi.common.util.CryptUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
* @author CMM
* @author CMM
* @date 2024/8/19 11:27
* /
* /**
* @since 2024/08/19 11:27
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class IrsManage {

@Value("${irs.item-basic-info.appKey}")
private String appKey;

@Value("${irs.item-basic-info.appSecret}")
private String appSecret;

@Value("${irs.item-basic-info.listUrl}")
private String itemBasicInfoListUrl;

@Value("${irs.item-basic-info.detailUrl}")
private String itemBasicInfoDetailUrl;

@Resource
private IRefreshTokenService refreshTokenService;

@Value("${irs.interface-refresh.request-token-url}")
private String govRequestTokenUrl;

@Value("${irs.interface-refresh.refresh-token-url}")
private String govRefreshTokenUrl;

public Object itemBasicInfoList(String startDate, String endDate, Integer pageSize, Integer pageNum) {
long timestamp = System.currentTimeMillis();
String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl,
HttpMethod.POST.name());
String sign = null;
try{
sign = CryptUtils.MD5Encode(appKey + secret + timestamp);
}catch (Exception e){
log.error(e.getMessage());
}
HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory();
RestTemplate restTemplate;
if(Objects.nonNull(factory)){
restTemplate = new RestTemplate(factory);
}else{
restTemplate = new RestTemplate();
}

MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
map.add("pageSize",pageSize);
map.add("pageNum",pageNum);
map.add("startDate",startDate);
map.add("endDate",endDate);
map.add("paramStr","update_date");
map.add("viewName","v_dsc_sx_ads_share_item_qlt_qlsx_common_i_d_v_kq_insensitive");
map.add("appKey",appKey);
map.add("sign",sign);
map.add("requestTime",timestamp);
// 创建 HttpHeaders 对象
HttpHeaders headers = new HttpHeaders();
// 创建 HttpEntity 对象,并传入 HttpHeaders
HttpEntity<Object> httpEntity = new HttpEntity<>(map,headers);
log.info("请求参数 :{}", JSON.toJSONString(map));
JSONObject jsonObject = restTemplate.postForObject(itemBasicInfoListUrl, httpEntity, JSONObject.class);
log.info("return list data :{}",jsonObject);

JSONArray dataArray = Objects.requireNonNull(jsonObject).getJSONArray("data");
List<Object> dataList = new ArrayList<>(dataArray);
if(CollUtil.isNotEmpty(dataList)){
return dataList;
} else {
return jsonObject;
}
}

public Object itemBasicInfoDetail(String itemId) {
long timestamp = System.currentTimeMillis();
String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl,
HttpMethod.POST.name());
String sign = null;
try{
sign = CryptUtils.MD5Encode(appKey + secret + timestamp);
}catch (Exception e){
log.error(e.getMessage());
}
HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory();
RestTemplate restTemplate;
if(Objects.nonNull(factory)){
restTemplate = new RestTemplate(factory);
}else{
restTemplate = new RestTemplate();
}

MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
// 附加信息
map.add("paramStr",itemId);
map.add("viewName","v_dsc_sx_ads_share_item_qlt_qlsx_common_i_d_v_kq_insensitive");
map.add("appKey",appKey);
map.add("sign",sign);
map.add("requestTime",timestamp);
// 创建 HttpHeaders 对象
HttpHeaders headers = new HttpHeaders();
// 创建 HttpEntity 对象,并传入 HttpHeaders
HttpEntity<Object> httpEntity = new HttpEntity<>(map,headers);
log.info("请求参数 :{}", JSON.toJSONString(map));
JSONObject jsonObject = restTemplate.postForObject(itemBasicInfoDetailUrl, httpEntity, JSONObject.class);
log.info("return detail data :{}",jsonObject);

JSONArray dataArray = Objects.requireNonNull(jsonObject).getJSONArray("data");
List<Object> dataList = new ArrayList<>(dataArray);
if(CollUtil.isNotEmpty(dataList)){
return dataList;
} else {
return jsonObject;
}
}
}

+ 11
- 1
kq-vas-api/src/main/resources/application-dev.yml View File

@@ -1,5 +1,5 @@
server:
port: 33060
port: 33061
servlet:
context-path: /kq
shutdown: graceful
@@ -144,5 +144,15 @@ sso:
user-info:
internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo
zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo
irs:
interface-refresh:
method: POST
request-token-url: http://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm
refresh-token-url: http://interface.zjzwfw.gov.cn/gateway/app/refreshTokenBySec.htm
item-basic-info:
appSecret: oUu7hk5NnOBghTw
appKey: qlZDZwhFWx
listUrl: https://typt.kq.gov.cn:8888/datashare/rest/query/U0022S00160/V1?apiUuid=C9030E259C6C43BBAA89DDF36F2386B0
detailUrl: https://typt.kq.gov.cn:8888/gateway/datashare/rest/query/U0022S00159/V1?apiUuid=14ED96404A834101992F00B4F6BBC7ED



+ 11
- 1
kq-vas-api/src/main/resources/application-pre.yml View File

@@ -140,4 +140,14 @@ sso:
zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token
user-info:
internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo
zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo
zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo
irs:
interface-refresh:
method: POST
request-token-url: http://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm
refresh-token-url: http://interface.zjzwfw.gov.cn/gateway/app/refreshTokenBySec.htm
item-basic-info:
appSecret: oUu7hk5NnOBghTw
appKey: qlZDZwhFWx
listUrl: https://typt.kq.gov.cn:8888/datashare/rest/query/U0022S00160/V1?apiUuid=C9030E259C6C43BBAA89DDF36F2386B0
detailUrl: https://typt.kq.gov.cn:8888/gateway/datashare/rest/query/U0022S00159/V1?apiUuid=14ED96404A834101992F00B4F6BBC7ED

+ 10
- 0
kq-vas-api/src/main/resources/application-prod.yml View File

@@ -145,5 +145,15 @@ sso:
user-info:
internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo
zww-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo
irs:
interface-refresh:
method: POST
request-token-url: http://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm
refresh-token-url: http://interface.zjzwfw.gov.cn/gateway/app/refreshTokenBySec.htm
item-basic-info:
appSecret: oUu7hk5NnOBghTw
appKey: qlZDZwhFWx
listUrl: https://typt.kq.gov.cn:8888/datashare/rest/query/U0022S00160/V1?apiUuid=C9030E259C6C43BBAA89DDF36F2386B0
detailUrl: https://typt.kq.gov.cn:8888/gateway/datashare/rest/query/U0022S00159/V1?apiUuid=14ED96404A834101992F00B4F6BBC7ED



+ 1
- 0
kq-vas-api/src/main/resources/security/auth-dev.yml View File

@@ -22,6 +22,7 @@ security:
- /ok.html
- /open/api/**
- /api/v1/wechat/**
- /api/v1/irs/**
ignore-csrf-urls:
- /**/anonymous/**
- /api/v1/poclicy/**


+ 1
- 0
kq-vas-api/src/main/resources/security/auth-pre.yml View File

@@ -22,6 +22,7 @@ security:
- /ok.html
- /open/api/**
- /api/v1/wechat/**
- /api/v1/irs/**
ignore-csrf-urls:
- /**/anonymous/**
- /api/v1/poclicy/**


+ 2
- 0
kq-vas-api/src/main/resources/security/auth-prod.yml View File

@@ -19,6 +19,7 @@ security:
- /doc.html
- /ok.html
- /api/v1/wechat/**
- /api/v1/irs/**
ignore-csrf-urls:
- /**/anonymous/**
- /api/v1/user/auth/**
@@ -34,6 +35,7 @@ security:
- /optLog/**
- /dict/**
- /api/v1/wechat/**
- /api/v1/irs/**
role-map:
"engineer":
"project_manager":


Loading…
Cancel
Save