Browse Source

事项基本信息irs数据定时任务更新

master
CMM 3 months ago
parent
commit
58a4c39de3
30 changed files with 935 additions and 248 deletions
  1. +28
    -13
      kq-vas-api/pom.xml
  2. +1
    -1
      kq-vas-api/src/main/java/com/ningdatech/kqapi/App.java
  3. +0
    -1
      kq-vas-api/src/main/java/com/ningdatech/kqapi/common/helper/basic/AbstractMatterCacheHelper.java
  4. +26
    -7
      kq-vas-api/src/main/java/com/ningdatech/kqapi/irs/controller/IrsController.java
  5. +329
    -96
      kq-vas-api/src/main/java/com/ningdatech/kqapi/irs/manage/IrsManage.java
  6. +39
    -0
      kq-vas-api/src/main/java/com/ningdatech/kqapi/irs/model/ItemBasicInfoListQueryDTO.java
  7. +147
    -0
      kq-vas-api/src/main/java/com/ningdatech/kqapi/scheduler/task/ItemSynTask.java
  8. +175
    -0
      kq-vas-api/src/main/java/com/ningdatech/kqapi/scheduler/task/ItemSynTestTask.java
  9. +1
    -1
      kq-vas-api/src/main/java/com/ningdatech/kqapi/scheduler/task/RemoveMattersTask.java
  10. +3
    -3
      kq-vas-api/src/main/java/com/ningdatech/kqapi/scheduler/task/SynTask.java
  11. +2
    -1
      kq-vas-api/src/main/java/com/ningdatech/kqapi/security/facade/UserAuthLoginFacade.java
  12. +2
    -0
      kq-vas-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IDscSxAdsShareItemQltQlsxCommonIDVKqService.java
  13. +18
    -0
      kq-vas-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/DscSxAdsShareItemQltQlsxCommonIDVKqServiceImpl.java
  14. +12
    -12
      kq-vas-api/src/main/resources/application-dev.yml
  15. +1
    -5
      kq-vas-api/src/main/resources/application-pre.yml
  16. +2
    -6
      kq-vas-api/src/main/resources/application-prod.yml
  17. +6
    -0
      kq-vas-api/src/main/resources/httpClient-dev.properties
  18. +6
    -0
      kq-vas-api/src/main/resources/httpClient-prod.properties
  19. +28
    -0
      kq-vas-api/src/test/java/com/ningdatech/kqapi/menu/DuplicationTest.java
  20. +41
    -6
      kq-vas-api/src/test/resources/application-dev.yml
  21. +1
    -1
      kq-vas-api/src/test/resources/application-prod.yml
  22. +1
    -1
      kq-vas-api/src/test/resources/application.yml
  23. +0
    -12
      kq-vas-api/src/test/resources/integration/zwdd-dev.yml
  24. +0
    -12
      kq-vas-api/src/test/resources/integration/zwdd-prod.yml
  25. +10
    -37
      kq-vas-api/src/test/resources/security/auth-dev.yml
  26. +41
    -0
      kq-vas-api/src/test/resources/security/auth-pre.yml
  27. +10
    -33
      kq-vas-api/src/test/resources/security/auth-prod.yml
  28. BIN
      kq-vas-api/src/test/resources/template/增值服务事项配置模板.xlsx
  29. BIN
      kq-vas-api/src/test/resources/template/政务服务事项配置模板.xlsx
  30. +5
    -0
      pom.xml

+ 28
- 13
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.15.3</version>
</dependency>
<!--cache-->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
@@ -157,22 +157,30 @@
</dependency>
<dependency>
<groupId>com.ningdatech</groupId>
<artifactId>nd-irs-starter</artifactId>
<artifactId>nd-file-starter</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.kingbase8</groupId>-->
<!-- <artifactId>kingbase8-8.2.0</artifactId>-->
<!-- <version>8.2.0</version>-->
<!-- <scope>system</scope>-->
<!-- <systemPath>${basedir}/src/lib/kingbase8-8.2.0.jar</systemPath>-->
<!-- </dependency>-->
<dependency>
<groupId>com.ningdatech</groupId>
<artifactId>nd-cache-starter</artifactId>
</dependency>
<dependency>
<groupId>com.ningdatech</groupId>
<artifactId>nd-file-starter</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.kingbase8</groupId>
<artifactId>kingbase8-8.6.0</artifactId>
<version>8.6.0</version>
<artifactId>kingbase8-${kingbase.version}</artifactId>
<version>${kingbase.version}</version>
<scope>system</scope>
<systemPath>${basedir}/src/lib/kingbase8-8.6.0.jar</systemPath>
<systemPath>${basedir}/src/lib/kingbase8-${kingbase.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>com.ningdatech</groupId>
<artifactId>nd-http-client-starter</artifactId>
</dependency>
</dependencies>
<!-- 打包 -->
@@ -180,27 +188,34 @@
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!--使用${environment}获取值-->
<environment>dev</environment>
<kingbase.version>8.2.0</kingbase.version>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<environment>test</environment>
<kingbase.version>8.2.0</kingbase.version>
</properties>
</profile>
<profile>
<id>pre</id>
<properties>
<environment>pre</environment>
<kingbase.version>8.2.0</kingbase.version>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<environment>prod</environment>
<kingbase.version>8.6.0</kingbase.version>
</properties>
</profile>
</profiles>


+ 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", "com.ningdatech.irs"})
@ComponentScan(basePackages = {"com.ningdatech.kqapi", "com.ningdatech.kqapi.common"})
public class App {

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


+ 0
- 1
kq-vas-api/src/main/java/com/ningdatech/kqapi/common/helper/basic/AbstractMatterCacheHelper.java View File

@@ -66,7 +66,6 @@ public abstract class AbstractMatterCacheHelper implements InitializingBean {
DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl)
.isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl)
.isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode)
.ne(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode, "")
.notIn(!eliminatedQlNames.isEmpty(), DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, eliminatedQlNames)
// 过滤掉那些在eliminatedQlNames中的记录
.orderByDesc(DscSxAdsShareItemQltQlsxCommonIDVKq::getUpdateDate));


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

@@ -1,21 +1,25 @@
package com.ningdatech.kqapi.irs.controller;

import java.util.List;
import com.ningdatech.kqapi.common.model.PageVo;
import com.ningdatech.kqapi.common.util.NdDateUtils;
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.alibaba.fastjson.JSON;
import com.ningdatech.kqapi.irs.manage.IrsManage;
import com.ningdatech.log.annotation.WebLog;
import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq;

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

import java.time.LocalDate;
import java.util.Date;

/**
* @author CMM
* @date 2024/8/19 11:11
@@ -34,14 +38,29 @@ public class IrsController {
@GetMapping("/item-basic-info-list")
public Object itemBasicInfoList(@RequestParam(required = false) String startDate,
@RequestParam(required = false) String endDate,
@RequestParam Integer pageSize,
@RequestParam Integer pageNum) {
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) 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);
public Object itemBasicInfoDetail(@RequestParam String rowGuid) {
return irsManage.itemBasicInfoDetail(rowGuid);
}

@ApiOperation(value = "转发请求接口", notes = "转发请求接口")
@GetMapping("/transfer-request")
public PageVo<DscSxAdsShareItemQltQlsxCommonIDVKq> transferRequest(String startDate, String endDate, Integer pageSize, Integer pageNum) {
// 从5月1日开始更新 直到8月31日 循环更新 每次更新1天
LocalDate start = NdDateUtils.parse(startDate);
LocalDate end = NdDateUtils.parse(endDate);
return irsManage.transferRequest(start, end, pageSize, pageNum);
}

@ApiOperation(value = "测试任务接口", notes = "测试任务接口")
@GetMapping("/test-task")
public String testTask(String startDate, String endDate) {
return irsManage.testTask(startDate, endDate);
}
}

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

@@ -1,29 +1,51 @@
package com.ningdatech.kqapi.irs.manage;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.date.StopWatch;
import cn.hutool.json.JSONUtil;
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 com.google.common.collect.Lists;
import com.ningdatech.http.HttpClientService;
import com.ningdatech.http.HttpResponseContent;
import com.ningdatech.kqapi.common.model.PageVo;
import com.ningdatech.kqapi.common.util.NdDateUtils;
import com.ningdatech.kqapi.irs.model.ItemBasicInfoListQueryDTO;
import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq;
import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
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 com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.PropertyNamingStrategy;
import com.alibaba.fastjson.parser.ParserConfig;
import com.ningdatech.basic.exception.BizException;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.MD5;
import cn.hutool.http.ContentType;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
@@ -51,99 +73,310 @@ public class IrsManage {
@Value("${irs.item-basic-info.detailUrl}")
private String itemBasicInfoDetailUrl;

@Resource
private IRefreshTokenService refreshTokenService;

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

@Value("${irs.interface-refresh.refresh-token-url}")
private String govRefreshTokenUrl;
private final IDscSxAdsShareItemQltQlsxCommonIDVKqService kqService;
String transmitListUrl = "https://qyxspt.kq.gov.cn:33060/kq/api/v1/irs/item-basic-info-list";
String transmitDetailUrl = "https://qyxspt.kq.gov.cn:33060/kq/api/v1/irs/item-basic-info-detail";

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());
String sign = MD5.create().digestHex(appKey + appSecret + timestamp);
HttpRequest request = HttpUtil.createPost(itemBasicInfoListUrl);
request.header("requestTime", String.valueOf(timestamp));
request.header("sign", sign);
request.header("appKey", appKey);
request.contentType(ContentType.FORM_URLENCODED.getValue());

ItemBasicInfoListQueryDTO queryDTO = new ItemBasicInfoListQueryDTO();
queryDTO.setStartDate(startDate);
queryDTO.setEndDate(endDate);
queryDTO.setPageNum(pageNum);
queryDTO.setPageSize(pageSize);
queryDTO.setParamStr("update_date");
queryDTO.setViewName("v_dsc_sx_ads_share_item_qlt_qlsx_common_i_d_v_kq_insensitive");
String queryStr = JSON.toJSONString(queryDTO);
request.form("parameter", queryStr);
log.info("request headers: {}", request.headers());
log.info("request form: {}", request.form());
String responseBody;
try (HttpResponse response = request.execute()) {
if (response == null || StrUtil.isEmpty(responseBody = response.body())) {
throw BizException.wrap("事项基本信息列表接口调用失败!");
}
log.info("content: {}", responseBody);
}
HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory();
RestTemplate restTemplate;
if(Objects.nonNull(factory)){
restTemplate = new RestTemplate(factory);
}else{
restTemplate = new RestTemplate();
ParserConfig config = new ParserConfig();
config.propertyNamingStrategy = PropertyNamingStrategy.PascalCase;
try {
JSONObject contentObj = JSONObject.parseObject(responseBody, JSONObject.class, config);
JSONObject data = contentObj.getJSONObject("data");
return data.getJSONArray("data");
} catch (Exception e) {
log.error("解析事项基本信息列表接口返回数据异常:{}", e.getMessage());
}
return responseBody;
}

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 rowGuid) {
long timestamp = System.currentTimeMillis();
String sign = MD5.create().digestHex(appKey + appSecret + timestamp);
HttpRequest request = HttpUtil.createPost(itemBasicInfoDetailUrl);
request.header("requestTime", String.valueOf(timestamp));
request.header("sign", sign);
request.header("appKey", appKey);
request.contentType(ContentType.FORM_URLENCODED.getValue());

DscSxAdsShareItemQltQlsxCommonIDVKq dsc = new DscSxAdsShareItemQltQlsxCommonIDVKq();
dsc.setRowguid(rowGuid);
String paramStr = JSON.toJSONString(dsc);
ItemBasicInfoListQueryDTO queryDTO = new ItemBasicInfoListQueryDTO();
queryDTO.setViewName("v_dsc_sx_ads_share_item_qlt_qlsx_common_i_d_v_kq_insensitive");
queryDTO.setParamStr(paramStr);
String parameter = JSON.toJSONString(queryDTO);
request.form("parameter",parameter);
String responseBody;
try (HttpResponse response = request.execute()) {
if (response == null || StrUtil.isEmpty(responseBody = response.body())) {
throw BizException.wrap("事项基本信息列表接口调用失败!");
}
log.info("content: {}", responseBody);
}
ParserConfig config = new ParserConfig();
config.propertyNamingStrategy = PropertyNamingStrategy.PascalCase;
try {
JSONObject contentObj = JSONObject.parseObject(responseBody, JSONObject.class, config);
JSONObject data = contentObj.getJSONObject("data");
JSONArray dataArray = data.getJSONArray("data");
if (CollUtil.isNotEmpty(dataArray)) {
return dataArray;
}
} catch (Exception e) {
log.error("解析事项基本信息详情接口返回数据异常:{}", e.getMessage());
}
return responseBody;
}

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());
public PageVo<DscSxAdsShareItemQltQlsxCommonIDVKq> transferRequest(LocalDate startDate, LocalDate endDate, Integer pageSize, Integer pageNum) {
String transmitListUrl = "https://qyxspt.kq.gov.cn:33060/kq/api/v1/irs/item-basic-info-list";
String transmitDetailUrl = "https://qyxspt.kq.gov.cn:33060/kq/api/v1/irs/item-basic-info-detail";

List<DscSxAdsShareItemQltQlsxCommonIDVKq> records = Lists.newArrayList();
// for循环,从开始日期更新到结束日期
for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
String listUrl = transmitListUrl + "?startDate=" + date + "&endDate=" + date.plusDays(1) +
"&pageSize=" + pageSize + "&pageNum=" + pageNum;
log.info("listUrl :{}", listUrl);

try {
HttpResponseContent listContent = httpClient.doGet(listUrl, null, null);
log.info("列表接口返回值:{}", JSONUtil.toJsonStr(listContent));
String listObject = listContent.getStringBody();
if (listObject == null || StringUtils.isBlank(listObject)) {
throw new BizException("列表接口转发调用失败!" );
}
JSONObject listJsonObject = null;
try {
listJsonObject = JSONObject.parseObject(listObject);
} catch (Exception e) {
throw new RuntimeException(e);
}

JSONArray listJsonArray = null;

Object object = listJsonObject.get("data");
if (object instanceof JSONArray){
listJsonArray = listJsonObject.getJSONArray("data");
}else {
JSONObject listData = listJsonObject.getJSONObject("data");
JSONObject listJsonData = listData.getJSONObject("data");
listJsonArray = listJsonData.getJSONArray("data");
}
if (CollUtil.isNotEmpty(listJsonArray)) {
log.info("事项列表数量为:{}", listJsonArray.size());
List<DscSxAdsShareItemQltQlsxCommonIDVKq> dataList = Lists.newArrayList();
for (Object item : listJsonArray) {
JSONObject itemJsonObject = (JSONObject) item;
DscSxAdsShareItemQltQlsxCommonIDVKq itemData = null;
// 先将列表中返回的非敏感信息进行赋值
itemData = JSON.parseObject(itemJsonObject.toJSONString(), DscSxAdsShareItemQltQlsxCommonIDVKq.class);
String rowGuid = itemJsonObject.getString("rowguid" );
if (StringUtils.isNotBlank(rowGuid)) {
String detailUrl = transmitDetailUrl + "?rowGuid=" + rowGuid;
log.info("detailUrl :{}", detailUrl);

HttpResponseContent detailContent = httpClient.doGet(detailUrl, null, null);
log.info("详情接口返回值:{}", JSONUtil.toJsonStr(detailContent));
String detailObject = detailContent.getStringBody();
if (detailObject == null || StringUtils.isBlank(detailObject)) {
throw new BizException("列表接口转发调用失败!" );
}
JSONObject detailJsonObject = null;
try {
detailJsonObject = JSONObject.parseObject(detailObject);
} catch (Exception e) {
throw new RuntimeException(e);
}

JSONArray detailJsonArray = null;

if (detailJsonObject.get("data") instanceof JSONArray){
detailJsonArray = detailJsonObject.getJSONArray("data");
}else {
JSONObject detailData = detailJsonObject.getJSONObject("data" );
JSONObject detailJsonData = detailData.getJSONObject("data");
detailJsonArray = detailJsonData.getJSONArray("data");
}

List<DscSxAdsShareItemQltQlsxCommonIDVKq> idvKqList = detailJsonArray.toJavaList(DscSxAdsShareItemQltQlsxCommonIDVKq.class);
if (CollUtil.isNotEmpty(idvKqList)) {
// 如果列表不为空,则取最新的一条数据
idvKqList.sort((o1, o2) -> o2.getUpdateDate().compareTo(o1.getUpdateDate()));
DscSxAdsShareItemQltQlsxCommonIDVKq detailItemData = idvKqList.get(0);
// 将敏感数据进行赋值
CopyOptions copyOptions = CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true);
BeanUtil.copyProperties(detailItemData, itemData,copyOptions);
}
}
if (Objects.nonNull(itemData)) {
dataList.add(itemData);
}
}
// 保存数据
if (CollUtil.isNotEmpty(dataList)) {
log.info("{} 数据列表数量为:{}", date, dataList.size());
kqService.saveBatch(dataList);
records.addAll(dataList);
}
}

} catch (RestClientException e) {
throw new BizException("接口转发调用失败!" );
}
}
HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory();
RestTemplate restTemplate;
if(Objects.nonNull(factory)){
restTemplate = new RestTemplate(factory);
}else{
restTemplate = new RestTemplate();
PageVo<DscSxAdsShareItemQltQlsxCommonIDVKq> pageVo = new PageVo<>();
pageVo.setRecords(records);
pageVo.setTotal((long) records.size());
return pageVo;
}

public String testTask(String startDateStr, String endDateStr) {
log.info("事项数据 ===================== 同步开始");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
// 每天凌晨5点同步前一天新更新的数据
// 默认一页返回
int pageNum = 1;
// irs接口最大返回数据量1000条
int pageSize = 1000;

List<DscSxAdsShareItemQltQlsxCommonIDVKq> records = Lists.newArrayList();
// 循环拉取较前一天已同步数据 新更新的数据
// 根据事项表中最后更新日期 循环更新至前一天的事项数据
String start = kqService.getNewestUpdateDate();
String end = NdDateUtils.format(LocalDateTime.now().minusDays(1), NdDateUtils.DEFAULT_DATE_FORMAT);
LocalDate startDate = LocalDate.parse(start).plusDays(1);
LocalDate endDate = LocalDate.parse(end);

for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
boolean flag = true;
while (flag) {
//Object listObject = irsManage.itemBasicInfoList(startDateStr, endDateStr, pageSize, pageNum);

String listUrl = transmitListUrl + "?startDate=" + date + "&endDate=" + date.plusDays(1) +
"&pageSize=" + pageSize + "&pageNum=" + pageNum;
log.info("listUrl :{}", listUrl);
HttpResponseContent listContent = httpClient.doGet(listUrl, null, null);
log.info("列表接口返回值:{}", JSONUtil.toJsonStr(listContent));
String listObject = listContent.getStringBody();
if (listObject == null || StringUtils.isBlank(listObject)) {
throw new BizException("列表接口转发调用失败!");
}
JSONObject listJsonObject = null;
try {
listJsonObject = JSONObject.parseObject(listObject);
} catch (Exception e) {
throw new RuntimeException(e);
}

Object object = listJsonObject.get("data");
// 如果数据正常返回
if (object instanceof JSONArray) {
//JSONArray listJsonArray = (JSONArray)listObject;
JSONArray listJsonArray = listJsonObject.getJSONArray("data");
log.info("事项列表数量为:{}", listJsonArray.size());
getSaveRecords(listJsonArray, records);
// 如果listJsonArray数据量等于1000 需要继续拉取数据
if (listJsonArray.size() == pageSize) {
pageNum++;
} else {
flag = false;
}
} else {
log.error("事项列表数据异常:{}", listObject);
return "同步失败";
}
}
}
log.info("{} - {} 数据列表数量为:{}", startDate, endDate, records.size());
//kqService.saveBatch(records);
log.info("事项同步成功,更新时间:{}", endDate);
stopWatch.stop();
log.info("事项数据 ===================== 同步总共耗时 :{} s", stopWatch.getTotalTimeSeconds());
return "同步成功";
}

private void getSaveRecords(JSONArray listJsonArray, List<DscSxAdsShareItemQltQlsxCommonIDVKq> records) {
if (CollUtil.isNotEmpty(listJsonArray)) {
List<DscSxAdsShareItemQltQlsxCommonIDVKq> dataList = Lists.newArrayList();
for (Object item : listJsonArray) {
JSONObject itemJsonObject = (JSONObject) item;
DscSxAdsShareItemQltQlsxCommonIDVKq itemData = null;
// 先将列表中返回的非敏感信息进行赋值
itemData = JSON.parseObject(itemJsonObject.toJSONString(), DscSxAdsShareItemQltQlsxCommonIDVKq.class);
String rowGuid = itemJsonObject.getString("rowguid" );
if (StringUtils.isNotBlank(rowGuid)) {
//Object detailObject = irsManage.itemBasicInfoDetail(rowGuid);
String detailUrl = transmitDetailUrl + "?rowGuid=" + rowGuid;
log.info("detailUrl :{}", detailUrl);

HttpResponseContent detailContent = httpClient.doGet(detailUrl, null, null);
log.info("详情接口返回值:{}", JSONUtil.toJsonStr(detailContent));
String detailObject = detailContent.getStringBody();
if (detailObject == null || StringUtils.isBlank(detailObject)) {
throw new BizException("列表接口转发调用失败!" );
}
JSONObject detailJsonObject = null;
try {
detailJsonObject = JSONObject.parseObject(detailObject);
} catch (Exception e) {
throw new RuntimeException(e);
}

Object object = detailJsonObject.get("data");

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;
if (object instanceof JSONArray){
//JSONArray detailJsonArray = (JSONArray) detailObject;
JSONArray detailJsonArray = detailJsonObject.getJSONArray("data");
List<DscSxAdsShareItemQltQlsxCommonIDVKq> idvKqList = detailJsonArray.toJavaList(DscSxAdsShareItemQltQlsxCommonIDVKq.class);
if (CollUtil.isNotEmpty(idvKqList)) {
// 如果列表不为空,则取最新的一条数据
idvKqList.sort((o1, o2) -> o2.getUpdateDate().compareTo(o1.getUpdateDate()));
DscSxAdsShareItemQltQlsxCommonIDVKq detailItemData = idvKqList.get(0);
// 将敏感数据进行赋值
CopyOptions copyOptions = CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true);
BeanUtil.copyProperties(detailItemData, itemData,copyOptions);
}
}
}
if (Objects.nonNull(itemData)) {
dataList.add(itemData);
}
}
// 保存数据
if (CollUtil.isNotEmpty(dataList)) {
records.addAll(dataList);
}
}
}
}

+ 39
- 0
kq-vas-api/src/main/java/com/ningdatech/kqapi/irs/model/ItemBasicInfoListQueryDTO.java View File

@@ -0,0 +1,39 @@
package com.ningdatech.kqapi.irs.model;

import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
* @author CMM
* @author CMM
* @date 2024/8/23 11:37
* /
* /**
* 事项基本信息列表查询实体
* @since 2024/08/23 11:37
*/
@Data
public class ItemBasicInfoListQueryDTO {

@ApiModelProperty("查询开始时间")
private String startDate;

@ApiModelProperty("查询结束时间")
private String endDate;

@ApiModelProperty("每页显示条数")
private Integer pageSize;

@ApiModelProperty("当前页码")
private Integer pageNum;

@ApiModelProperty("固定传参字段 update_date")
private String paramStr;

@ApiModelProperty("固定传参字段 v_dsc_sx_ads_share_item_qlt_qlsx_common_i_d_v_kq_insensitive")
private String viewName;

@ApiModelProperty("事项唯一标识")
private String rowguid;
}

+ 147
- 0
kq-vas-api/src/main/java/com/ningdatech/kqapi/scheduler/task/ItemSynTask.java View File

@@ -0,0 +1,147 @@
package com.ningdatech.kqapi.scheduler.task;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

import com.ningdatech.cache.model.cache.CacheKey;
import com.ningdatech.cache.repository.CachePlusOps;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.ningdatech.kqapi.common.util.NdDateUtils;
import com.ningdatech.kqapi.irs.manage.IrsManage;
import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq;
import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.StopWatch;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
* @author CMM
* 事项同步定时任务
* @since 2024/08/21 09:53
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class ItemSynTask {

@Value("${hostname}")
public String HOST;

private final IDscSxAdsShareItemQltQlsxCommonIDVKqService kqService;
private final IrsManage irsManage;
private final CachePlusOps cachePlusOps;

String ITEM_BASIC_INFO_KEY = "kq:task:item:item_basic_info_list_update_date";

/**
* 每天凌晨5点同步数据
*/
@Scheduled(cron = "0 0 5 * * ?")
public void synData() {
log.info("事项数据 ===================== 同步开始");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
// 每天凌晨5点循环拉取较前一天新更新的数据
// 根据事项表中最后更新日期 循环更新至前一天的事项数据
// 默认一页返回
int pageNum = 1;
// irs接口最大返回数据量1000条
int pageSize = 1000;

List<DscSxAdsShareItemQltQlsxCommonIDVKq> records = Lists.newArrayList();

// 从缓存中取上次同步数据中最新的更新日期
CacheKey key = new CacheKey(ITEM_BASIC_INFO_KEY);
String start = cachePlusOps.get(key);
// 如果缓存中不存在 从表中查询
if (StringUtils.isBlank(start)){
start = kqService.getNewestUpdateDate();
}
String end = NdDateUtils.format(LocalDateTime.now().minusDays(1), NdDateUtils.DEFAULT_DATE_FORMAT);
LocalDate startDate = LocalDate.parse(start).plusDays(1);
LocalDate endDate = LocalDate.parse(end);
for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
boolean flag = true;
while (flag) {
String startDateStr = NdDateUtils.format(date, NdDateUtils.DEFAULT_DATE_FORMAT);
String endDateStr = NdDateUtils.format(date.plusDays(1), NdDateUtils.DEFAULT_DATE_FORMAT);
Object listObject = irsManage.itemBasicInfoList(startDateStr, endDateStr, pageSize, pageNum);
// 如果数据正常返回
if (listObject instanceof JSONArray) {
JSONArray listJsonArray = (JSONArray) listObject;
log.info("事项列表数量为:{}", listJsonArray.size());
getSaveRecords(listJsonArray, records);
// 如果listJsonArray数据量等于1000 需要继续拉取数据
if (listJsonArray.size() == pageSize) {
pageNum++;
} else {
flag = false;
}
} else {
log.error("事项列表数据异常:{}", listObject.toString());
return;
}
}
}
log.info("{} 数据列表数量为:{}", startDate, records.size());
kqService.saveBatch(records);
log.info("事项同步成功,更新时间:{}", startDate);
// 更新缓存中的更新时间
// 获取此次保存记录中的最新更新时间
records.sort((o1, o2) -> o2.getUpdateDate().compareTo(o1.getUpdateDate()));
LocalDateTime updateDate = records.get(0).getUpdateDate();
String updateDateStr = NdDateUtils.format(updateDate, NdDateUtils.DEFAULT_DATE_FORMAT);
cachePlusOps.set(key, updateDateStr);
stopWatch.stop();
log.info("事项数据 ===================== 同步总共耗时 :{} s", stopWatch.getTotalTimeSeconds());
}

private void getSaveRecords(JSONArray listJsonArray, List<DscSxAdsShareItemQltQlsxCommonIDVKq> records) {
if (CollUtil.isNotEmpty(listJsonArray)) {
List<DscSxAdsShareItemQltQlsxCommonIDVKq> dataList = Lists.newArrayList();
for (Object item : listJsonArray) {
JSONObject itemJsonObject = (JSONObject) item;
DscSxAdsShareItemQltQlsxCommonIDVKq itemData = null;
// 先将列表中返回的非敏感信息进行赋值
itemData = JSON.parseObject(itemJsonObject.toJSONString(), DscSxAdsShareItemQltQlsxCommonIDVKq.class);
String rowGuid = itemJsonObject.getString("rowguid" );
if (StringUtils.isNotBlank(rowGuid)) {
Object detailObject = irsManage.itemBasicInfoDetail(rowGuid);
if (detailObject instanceof JSONArray){
JSONArray detailJsonArray = (JSONArray) detailObject;
List<DscSxAdsShareItemQltQlsxCommonIDVKq> idvKqList = detailJsonArray.toJavaList(DscSxAdsShareItemQltQlsxCommonIDVKq.class);
if (CollUtil.isNotEmpty(idvKqList)) {
// 如果列表不为空,则取最新的一条数据
idvKqList.sort((o1, o2) -> o2.getUpdateDate().compareTo(o1.getUpdateDate()));
DscSxAdsShareItemQltQlsxCommonIDVKq detailItemData = idvKqList.get(0);
// 将敏感数据进行赋值
CopyOptions copyOptions = CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true);
BeanUtil.copyProperties(detailItemData, itemData,copyOptions);
}
}
}
if (Objects.nonNull(itemData)) {
dataList.add(itemData);
}
}
// 保存数据
if (CollUtil.isNotEmpty(dataList)) {
records.addAll(dataList);
}
}
}
}

+ 175
- 0
kq-vas-api/src/main/java/com/ningdatech/kqapi/scheduler/task/ItemSynTestTask.java View File

@@ -0,0 +1,175 @@
package com.ningdatech.kqapi.scheduler.task;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

import cn.hutool.json.JSONUtil;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.http.HttpClientService;
import com.ningdatech.http.HttpResponseContent;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.ningdatech.kqapi.common.util.NdDateUtils;
import com.ningdatech.kqapi.irs.manage.IrsManage;
import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq;
import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.StopWatch;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
* @author CMM
* 事项同步定时任务
* @since 2024/08/21 09:53
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class ItemSynTestTask {

@Value("${hostname}")
public String HOST;

private final IDscSxAdsShareItemQltQlsxCommonIDVKqService kqService;
private final IrsManage irsManage;
private final HttpClientService httpClient;


String transmitListUrl = "https://qyxspt.kq.gov.cn:33060/kq/api/v1/irs/item-basic-info-list";
String transmitDetailUrl = "https://qyxspt.kq.gov.cn:33060/kq/api/v1/irs/item-basic-info-detail";
/**
* 每天凌晨5点同步数据
*/
//@Scheduled(cron = "0 0 5 * * ?")
public void synData() {
log.info("事项数据 ===================== 同步开始");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
// 每天凌晨5点同步前一天新更新的数据
// 默认一页返回
int pageNum = 1;
// irs接口最大返回数据量1000条
int pageSize = 1000;

List<DscSxAdsShareItemQltQlsxCommonIDVKq> records = Lists.newArrayList();
// 根据事项表中最后更新日期 循环更新至前一天的事项数据
String start = kqService.getNewestUpdateDate();
String end = NdDateUtils.format(LocalDateTime.now().minusDays(1), NdDateUtils.DEFAULT_DATE_FORMAT);
LocalDate startDate = LocalDate.parse(start);
LocalDate endDate = LocalDate.parse(end);

for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
// 循环拉取较前一天已同步数据 新更新的数据
boolean flag = true;
while (flag) {
//Object listObject = irsManage.itemBasicInfoList(startDate, endDate, pageSize, pageNum);

String listUrl = transmitListUrl + "?startDate=" + startDate + "&endDate=" + endDate +
"&pageSize=" + pageSize + "&pageNum=" + pageNum;
log.info("listUrl :{}", listUrl);
HttpResponseContent listContent = httpClient.doGet(listUrl, null, null);
log.info("列表接口返回值:{}", JSONUtil.toJsonStr(listContent));
String listObject = listContent.getStringBody();
if (listObject == null || StringUtils.isBlank(listObject)) {
throw new BizException("列表接口转发调用失败!");
}
JSONObject listJsonObject = null;
try {
listJsonObject = JSONObject.parseObject(listObject);
} catch (Exception e) {
throw new RuntimeException(e);
}

Object object = listJsonObject.get("data");
// 如果数据正常返回
if (object instanceof JSONArray) {
//JSONArray listJsonArray = (JSONArray)listObject;
JSONArray listJsonArray = listJsonObject.getJSONArray("data");
log.info("事项列表数量为:{}", listJsonArray.size());
getSaveRecords(listJsonArray, records);
// 如果listJsonArray数据量等于1000 需要继续拉取数据
if (listJsonArray.size() == pageSize) {
pageNum++;
} else {
flag = false;
}
} else {
log.error("事项列表数据异常:{}", listObject);
return;
}
}
}
log.info("{} - {} 数据列表数量为:{}", startDate, endDate, records.size());
kqService.saveBatch(records);
log.info("事项同步成功,更新时间:{}", endDate);
stopWatch.stop();
log.info("事项数据 ===================== 同步总共耗时 :{} s", stopWatch.getTotalTimeSeconds());
}

private void getSaveRecords(JSONArray listJsonArray, List<DscSxAdsShareItemQltQlsxCommonIDVKq> records) {
if (CollUtil.isNotEmpty(listJsonArray)) {
List<DscSxAdsShareItemQltQlsxCommonIDVKq> dataList = Lists.newArrayList();
for (Object item : listJsonArray) {
JSONObject itemJsonObject = (JSONObject) item;
DscSxAdsShareItemQltQlsxCommonIDVKq itemData = null;
// 先将列表中返回的非敏感信息进行赋值
itemData = JSON.parseObject(itemJsonObject.toJSONString(), DscSxAdsShareItemQltQlsxCommonIDVKq.class);
String rowGuid = itemJsonObject.getString("rowguid" );
if (StringUtils.isNotBlank(rowGuid)) {
//Object detailObject = irsManage.itemBasicInfoDetail(rowGuid);
String detailUrl = transmitDetailUrl + "?rowGuid=" + rowGuid;
log.info("detailUrl :{}", detailUrl);

HttpResponseContent detailContent = httpClient.doGet(detailUrl, null, null);
log.info("详情接口返回值:{}", JSONUtil.toJsonStr(detailContent));
String detailObject = detailContent.getStringBody();
if (detailObject == null || StringUtils.isBlank(detailObject)) {
throw new BizException("列表接口转发调用失败!" );
}
JSONObject detailJsonObject = null;
try {
detailJsonObject = JSONObject.parseObject(detailObject);
} catch (Exception e) {
throw new RuntimeException(e);
}

Object object = detailJsonObject.get("data");

if (object instanceof JSONArray){
//JSONArray detailJsonArray = (JSONArray) detailObject;
JSONArray detailJsonArray = detailJsonObject.getJSONArray("data");
List<DscSxAdsShareItemQltQlsxCommonIDVKq> idvKqList = detailJsonArray.toJavaList(DscSxAdsShareItemQltQlsxCommonIDVKq.class);
if (CollUtil.isNotEmpty(idvKqList)) {
// 如果列表不为空,则取最新的一条数据
idvKqList.sort((o1, o2) -> o2.getUpdateDate().compareTo(o1.getUpdateDate()));
DscSxAdsShareItemQltQlsxCommonIDVKq detailItemData = idvKqList.get(0);
// 将敏感数据进行赋值
CopyOptions copyOptions = CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true);
BeanUtil.copyProperties(detailItemData, itemData,copyOptions);
}
}
}
if (Objects.nonNull(itemData)) {
dataList.add(itemData);
}
}
// 保存数据
if (CollUtil.isNotEmpty(dataList)) {
records.addAll(dataList);
}
}
}
}

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

@@ -35,7 +35,7 @@ public class RemoveMattersTask {
/**
* 每天
*/
@Scheduled(cron = "0 50 14 * * ?")
//@Scheduled(cron = "0 50 14 * * ?")
public void doTask() throws UnknownHostException {
if (!HOST.equals(InetAddress.getLocalHost().getHostName())) {
log.info("定时器没开启或者host不对! {}:{}",


+ 3
- 3
kq-vas-api/src/main/java/com/ningdatech/kqapi/scheduler/task/SynTask.java View File

@@ -22,6 +22,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.net.UnknownHostException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -65,7 +66,7 @@ public class SynTask {
private final String KQ_ZZS_BASE_URL = "https://www.zjzwfw.gov.cn/zjservice-fe/#/workguide?localInnerCode=&siteCode=330000000000";

/**
* 每天
* 每天8:30 同步数据
*/
@Scheduled(cron = "0 30 8 * * ?")
public void synData() throws UnknownHostException {
@@ -164,9 +165,8 @@ public class SynTask {
.eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, key)
.eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState, "1")
.isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl)
// 确保getQlInnerCodeItem字段不为null且不为""
// 确保getQlInnerCodeItem字段不为null
.isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode)
.ne(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCode, "")
.orderByDesc(DscSxAdsShareItemQltQlsxCommonIDVKq::getUpdateDate)
.last(BizConst.LIMIT_1));
return matter;


+ 2
- 1
kq-vas-api/src/main/java/com/ningdatech/kqapi/security/facade/UserAuthLoginFacade.java View File

@@ -44,7 +44,8 @@ public class UserAuthLoginFacade {
return null;
}
// 获取用户详情信息
UserInfo userInfo = userInfoService.getById(userAuth.getUserId());
Long userId = userAuth.getUserId();
UserInfo userInfo = userInfoService.getById(userId);
UserInfoBO user = new UserInfoBO();
user.setAccountStatus(userInfo.getAccountStatus());
user.setUserId(userInfo.getId());


+ 2
- 0
kq-vas-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/IDscSxAdsShareItemQltQlsxCommonIDVKqService.java View File

@@ -13,4 +13,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface IDscSxAdsShareItemQltQlsxCommonIDVKqService extends IService<DscSxAdsShareItemQltQlsxCommonIDVKq> {

String getNewestUpdateDate();

}

+ 18
- 0
kq-vas-api/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/DscSxAdsShareItemQltQlsxCommonIDVKqServiceImpl.java View File

@@ -1,11 +1,17 @@
package com.ningdatech.kqapi.zzsfw.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.kqapi.common.util.NdDateUtils;
import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq;
import com.ningdatech.kqapi.zzsfw.mapper.DscSxAdsShareItemQltQlsxCommonIDVKqMapper;
import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
* <p>
* 省回流_政务服务_数据共享_事项基本信息表 服务实现类
@@ -17,4 +23,16 @@ import org.springframework.stereotype.Service;
@Service
public class DscSxAdsShareItemQltQlsxCommonIDVKqServiceImpl extends ServiceImpl<DscSxAdsShareItemQltQlsxCommonIDVKqMapper, DscSxAdsShareItemQltQlsxCommonIDVKq> implements IDscSxAdsShareItemQltQlsxCommonIDVKqService {

@Override
public String getNewestUpdateDate() {
List<DscSxAdsShareItemQltQlsxCommonIDVKq> dataList = baseMapper.selectList(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class)
.select(DscSxAdsShareItemQltQlsxCommonIDVKq::getUpdateDate));
if (CollUtil.isNotEmpty(dataList)){
// 根据更新时间降序排序
dataList.sort((o1, o2) -> o2.getUpdateDate().compareTo(o1.getUpdateDate()));
LocalDateTime updateDate = dataList.get(0).getUpdateDate();
return NdDateUtils.format(updateDate, NdDateUtils.DEFAULT_DATE_FORMAT);
}
return null;
}
}

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

@@ -1,5 +1,5 @@
server:
port: 33061
port: 33060
servlet:
context-path: /kq
shutdown: graceful
@@ -46,10 +46,14 @@ spring:
ddl-auto: update
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: ENC(aMGW3+FFqxyutRz9liYjAg+A72b6IQ7/ygtxO0DmQJ/LLFZkx8r4MhN8quv9L62nQ4sH55qFg+LnQoor/t8IqBACrbfNg462YNKnRyMsBmdHHxJm7i57flIQfePLDW93Omz4LZ2PbRZTvPcLLYtnQyxXSDPwDnjexHNVXTdxwuTJPBqthsVpvyA2mnn5Szef)
username: root
password: ENC(NHFdgnNk7opRJpNnZOJs51OTXb72zU//)
# driver-class-name: com.mysql.cj.jdbc.Driver
driverClassName: com.kingbase8.Driver
# url: ENC(aMGW3+FFqxyutRz9liYjAg+A72b6IQ7/ygtxO0DmQJ/LLFZkx8r4MhN8quv9L62nQ4sH55qFg+LnQoor/t8IqBACrbfNg462YNKnRyMsBmdHHxJm7i57flIQfePLDW93Omz4LZ2PbRZTvPcLLYtnQyxXSDPwDnjexHNVXTdxwuTJPBqthsVpvyA2mnn5Szef)
url: jdbc:kingbase8://120.26.44.207:54321/kq_added_project?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
# username: root
username: SYSTEM
# password: ENC(NHFdgnNk7opRJpNnZOJs51OTXb72zU//)
password: Ndkj1234
# 数据源
hikari:
# 是客户端等待连接池连接的最大毫秒数
@@ -78,8 +82,8 @@ mybatis-plus:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
logic-delete-value: true
logic-not-delete-value: false
logic-delete-value: 1
logic-not-delete-value: 0
logic-delete-field: deleted
logging:
config: classpath:logback-spring.xml
@@ -145,14 +149,10 @@ sso:
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
listUrl: https://typt.kq.gov.cn:8888/gateway/datashare/rest/query/U0022S00160/V1?apiUuid=C9030E259C6C43BBAA89DDF36F2386B0
detailUrl: https://typt.kq.gov.cn:8888/gateway/datashare/rest/query/U0022S00159/V1?apiUuid=14ED96404A834101992F00B4F6BBC7ED



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

@@ -142,12 +142,8 @@ sso:
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
listUrl: https://typt.kq.gov.cn:8888/gateway/datashare/rest/query/U0022S00160/V1?apiUuid=C9030E259C6C43BBAA89DDF36F2386B0
detailUrl: https://typt.kq.gov.cn:8888/gateway/datashare/rest/query/U0022S00159/V1?apiUuid=14ED96404A834101992F00B4F6BBC7ED

+ 2
- 6
kq-vas-api/src/main/resources/application-prod.yml View File

@@ -124,7 +124,7 @@ log:
swagger:
enabled: false

hostname: iZut201mqskxt0mwme4tjfZ
hostname: iZr3i038ar3e2l7qn9ji2oZ

sys:
web-url: https://qyxspt.kq.gov.cn:33060
@@ -146,14 +146,10 @@ sso:
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
listUrl: https://typt.kq.gov.cn:8888/gateway/datashare/rest/query/U0022S00160/V1?apiUuid=C9030E259C6C43BBAA89DDF36F2386B0
detailUrl: https://typt.kq.gov.cn:8888/gateway/datashare/rest/query/U0022S00159/V1?apiUuid=14ED96404A834101992F00B4F6BBC7ED



+ 6
- 0
kq-vas-api/src/main/resources/httpClient-dev.properties View File

@@ -0,0 +1,6 @@
http.default.maxTotal=80
http.default.defaultMaxPerRoute=40
http.default.connectTimeout=2000
http.default.connectionRequestTimeout=3000
http.default.socketTimeout=60000
http.default.validateAfterInactivity=5000

+ 6
- 0
kq-vas-api/src/main/resources/httpClient-prod.properties View File

@@ -0,0 +1,6 @@
http.default.maxTotal=80
http.default.defaultMaxPerRoute=40
http.default.connectTimeout=2000
http.default.connectionRequestTimeout=3000
http.default.socketTimeout=60000
http.default.validateAfterInactivity=5000

+ 28
- 0
kq-vas-api/src/test/java/com/ningdatech/kqapi/menu/DuplicationTest.java View File

@@ -1,6 +1,16 @@
package com.ningdatech.kqapi.menu;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.kqapi.AppTests;
import com.ningdatech.kqapi.user.model.entity.UserAuth;
import com.ningdatech.kqapi.user.model.po.ModifyPasswordReq;
import com.ningdatech.kqapi.user.service.IUserAuthService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.time.LocalDateTime;

/**
* @Classname DuplicationTest
@@ -10,4 +20,22 @@ import com.ningdatech.kqapi.AppTests;
*/
public class DuplicationTest extends AppTests {

@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
private IUserAuthService userAuthService;
@Test
public void test() {
ModifyPasswordReq req = new ModifyPasswordReq();
req.setUserId(1L);
req.setPassword("123456Aa");
// 更新密码
String password = passwordEncoder.encode(req.getPassword());
Wrapper<UserAuth> update = Wrappers.lambdaUpdate(UserAuth.class)
.set(UserAuth::getCredential, password)
.set(UserAuth::getUpdateOn, LocalDateTime.now())
.eq(UserAuth::getUserId, req.getUserId());
userAuthService.update(update);
}

}

+ 41
- 6
kq-vas-api/src/test/resources/application-dev.yml View File

@@ -1,7 +1,11 @@
server:
port: 33060
port: 33061
servlet:
context-path: /kq
shutdown: graceful

cookie:
path: ${server.servlet.context-path}

spring:
mvc:
@@ -42,10 +46,14 @@ spring:
ddl-auto: update
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://47.98.125.47:3306/kqzzsfw?serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false
username: root
password: NingdaKeji123!
# driver-class-name: com.mysql.cj.jdbc.Driver
driverClassName: com.kingbase8.Driver
# url: ENC(aMGW3+FFqxyutRz9liYjAg+A72b6IQ7/ygtxO0DmQJ/LLFZkx8r4MhN8quv9L62nQ4sH55qFg+LnQoor/t8IqBACrbfNg462YNKnRyMsBmdHHxJm7i57flIQfePLDW93Omz4LZ2PbRZTvPcLLYtnQyxXSDPwDnjexHNVXTdxwuTJPBqthsVpvyA2mnn5Szef)
url: jdbc:kingbase8://120.26.44.207:54321/kq_added_project?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
# username: root
username: SYSTEM
# password: ENC(NHFdgnNk7opRJpNnZOJs51OTXb72zU//)
password: Ndkj1234
# 数据源
hikari:
# 是客户端等待连接池连接的最大毫秒数
@@ -61,7 +69,7 @@ spring:
# 配置从池返回的连接的默认自动提交行为。默认值为true。
auto-commit: true
# 开启连接监测泄露
leak-detection-threshold: 10000
leak-detection-threshold: 500000
# 测试连接数据库
connection-test-query: SELECT 1
#设置上传 单个文件的大小
@@ -76,6 +84,7 @@ mybatis-plus:
db-config:
logic-delete-value: true
logic-not-delete-value: false
logic-delete-field: deleted
logging:
config: classpath:logback-spring.xml
#日志配置
@@ -118,6 +127,32 @@ log:
swagger:
enabled: true

sys:
web-url: http://kqzh.ningdatech.com

hostname: iZbp13nwyvib53j4j1p2xoZ
jasypt:
encryptor:
password: CodeSheep
# 指定解密算法,需要和加密时使用的算法一致
algorithm: PBEWithMD5AndDES
# 指定initialization vector类型
iv-generator-classname: org.jasypt.iv.NoIvGenerator
sso:
access-key: BCDSGA_c2494577610c90bdc33b95514601da2c
secret-key: BCDSGS_80bf0a606c0d2fd3201bd06a4f008250
app-id: 2002399646
token:
internet-url: https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token
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
irs:
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
- 1
kq-vas-api/src/test/resources/application-prod.yml View File

@@ -118,6 +118,6 @@ log:
swagger:
enabled: true

hostname: iZut201mqskxt0mwme4tjfZ
hostname: iZr3i038ar3e2l7qn9ji2oZ



+ 1
- 1
kq-vas-api/src/test/resources/application.yml View File

@@ -1,3 +1,3 @@
spring:
profiles:
active: prod
active: dev

+ 0
- 12
kq-vas-api/src/test/resources/integration/zwdd-dev.yml View File

@@ -1,12 +0,0 @@
#专有钉钉
integration:
zwdd:
#扫码
app-auth-key: ls-rebuild_dingoa-rgeWs3YVr26z
app-auth-secret: 37qCe6ylNMW0N8K2741z0c2b9vJP2gtuMRQQtZ9P
#免登/获取信息
app-key: ls_rebuild-10c8n5X0707yFV7jURr
app-secret: gN8J3WazyXLMWKDuFmx6C4yaH5lFUY41x8rYLLo6
#专有钉钉在开发管理工作台,右键查看网页源码realmId: '31141',浙政钉固定196729
tenantId: 31141
domain: openplatform.dg-work.cn

+ 0
- 12
kq-vas-api/src/test/resources/integration/zwdd-prod.yml View File

@@ -1,12 +0,0 @@
#浙政钉
integration:
zwdd:
#扫码
app-auth-key: ls_project_managment_din-b1Y3I1g7Rr94yX76KfFkpp18Uy4WHtU0b6rINJ3
app-auth-secret: 75e8PMHv984KYF0Mcy6v4pxt480y73dbD7kB65dD
#免登/获取信息
app-key: ls_project-c32LNu87v60UiANZVja
app-secret: R14QgbBr21751LTGml3Vt8oX9doPl4Lk1ROzZNfG
#专有钉钉在开发管理工作台,右键查看网页源码realmId: '31141',浙政钉固定196729
tenantId: 196729
domain: openplatform-pro.ding.zj.gov.cn

+ 10
- 37
kq-vas-api/src/test/resources/security/auth-dev.yml View File

@@ -2,11 +2,12 @@ security:
auth:
auth-require-url: /api/v1/user/auth/auth-require
invalid-session-url: /api/v1/user/auth/invalid-session
password-login-url: /api/v1/user/auth/login
agent-login-url: /api/v1/user/auth/agent-login
password-login-url: /api/v1/user/auth/login/password
logout-url: /api/v1/user/auth/logout
common-login-url: /api/v1/user/auth/common-login
ignore-auth-urls:
- /**/anonymous/**
- /api/v1/poclicy/**
- /api/v1/zzsfw/**
- /v2/api-docs
- /swagger-ui.html
- /webjars/**
@@ -17,21 +18,15 @@ security:
- /api/v1/user/auth/invalid-session
- /api/v1/user/auth/login/password
- /api/v1/user/auth/forget-password
- /api/v1/user/auth/common-login
- /doc.html
- /ok.html
- /open/api/**
- /oa/**
- /wflow/**
- /sys/**
- /api/v1/verification/**
- /api/v1/expert/registration
- /api/v1/meta/dictionary/list
- /api/v1/meta/tag
- /api/v1/organization/tree-list
- /api/v1/organization/get-child-list
- /api/v1/region/tree
- /api/v1/wechat/**
- /api/v1/irs/**
ignore-csrf-urls:
- /**/anonymous/**
- /api/v1/poclicy/**
- /api/v1/zzsfw/**
- /api/v1/user/auth/**
- /v2/api-docs
- /swagger-ui.html
@@ -43,26 +38,4 @@ security:
- /api/v1/**
- /file/**
- /optLog/**
- /dict/**
- /oa/**
- /wflow/**
- /sys/**
- /api/v1/verification/**
- /api/v1/expert/registration
- /api/v1/meta/dictionary/list
- /api/v1/meta/tag
- /api/v1/organization/tree-list
- /api/v1/organization/get-child-list
- /api/v1/region/tree
role-map:
"engineer":
"project_manager":
- /api/v1/user-info/kick-off/**
"enterprise_admin":
"regional_general_manager":
"driver":
"super_admin":
- /api/v1/user-info/save
- /api/v1/user-info/del
- /api/v1/user-info/kick-off/**
- /api/v1/user-info/password/mod
- /dict/**

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

@@ -0,0 +1,41 @@
security:
auth:
auth-require-url: /api/v1/user/auth/auth-require
invalid-session-url: /api/v1/user/auth/invalid-session
password-login-url: /api/v1/user/auth/login/password
logout-url: /api/v1/user/auth/logout
ignore-auth-urls:
- /**/anonymous/**
- /api/v1/poclicy/**
- /api/v1/zzsfw/**
- /v2/api-docs
- /swagger-ui.html
- /webjars/**
- /swagger-resources/**
- /webjars/
- /api/v1/user/auth/register
- /api/v1/user/auth/auth-require
- /api/v1/user/auth/invalid-session
- /api/v1/user/auth/login/password
- /api/v1/user/auth/forget-password
- /doc.html
- /ok.html
- /open/api/**
- /api/v1/wechat/**
- /api/v1/irs/**
ignore-csrf-urls:
- /**/anonymous/**
- /api/v1/poclicy/**
- /api/v1/zzsfw/**
- /api/v1/user/auth/**
- /v2/api-docs
- /swagger-ui.html
- /webjars/**
- /swagger-resources/**
- /webjars/
- /doc.html
- /ok.html
- /api/v1/**
- /file/**
- /optLog/**
- /dict/**

+ 10
- 33
kq-vas-api/src/test/resources/security/auth-prod.yml View File

@@ -2,36 +2,26 @@ security:
auth:
auth-require-url: /api/v1/user/auth/auth-require
invalid-session-url: /api/v1/user/auth/invalid-session
password-login-url: /api/v1/user/auth/login
agent-login-url: /api/v1/user/auth/agent-login
password-login-url: /api/v1/user/auth/login/password
logout-url: /api/v1/user/auth/logout
common-login-url: /api/v1/user/auth/common-login
ignore-auth-urls:
- /**/anonymous/**
- /api/v1/poclicy/**
- /api/v1/zzsfw/**
- /v2/api-docs
- /swagger-ui.html
- /webjars/**
- /swagger-resources/**
- /webjars/
- /api/v1/user/auth/register
- /api/v1/user/auth/auth-require
- /api/v1/user/auth/invalid-session
- /api/v1/user/auth/login/password
- /api/v1/user/auth/forget-password
- /api/v1/user/auth/common-login
- /doc.html
- /ok.html
- /open/api/**
- /oa/**
- /wflow/**
- /sys/**
- /api/v1/verification/**
- /api/v1/expert/registration
- /api/v1/meta/dictionary/list
- /api/v1/meta/tag
- /api/v1/organization/tree-list
- /api/v1/organization/get-child-list
- /api/v1/region/tree
- /api/v1/wechat/**
- /api/v1/irs/**
ignore-csrf-urls:
- /**/anonymous/**
- /api/v1/user/auth/**
- /v2/api-docs
- /swagger-ui.html
@@ -44,25 +34,12 @@ security:
- /file/**
- /optLog/**
- /dict/**
- /oa/**
- /wflow/**
- /sys/**
- /api/v1/verification/**
- /api/v1/expert/registration
- /api/v1/meta/dictionary/list
- /api/v1/meta/tag
- /api/v1/organization/tree-list
- /api/v1/organization/get-child-list
- /api/v1/region/tree
- /api/v1/wechat/**
- /api/v1/irs/**
role-map:
"engineer":
"project_manager":
- /api/v1/user-info/kick-off/**
"enterprise_admin":
"regional_general_manager":
"driver":
"super_admin":
- /api/v1/user-info/save
- /api/v1/user-info/del
- /api/v1/user-info/kick-off/**
- /api/v1/user-info/password/mod
"super_admin":

BIN
kq-vas-api/src/test/resources/template/增值服务事项配置模板.xlsx View File


BIN
kq-vas-api/src/test/resources/template/政务服务事项配置模板.xlsx View File


+ 5
- 0
pom.xml View File

@@ -100,6 +100,11 @@
<artifactId>nd-swagger2-starter</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.ningdatech</groupId>
<artifactId>nd-http-client-starter</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>



Loading…
Cancel
Save