Sfoglia il codice sorgente

增加事项剔除和事项刷新接口

master
wangrenkang 11 mesi fa
parent
commit
42c3358006
8 ha cambiato i file con 205 aggiunte e 4 eliminazioni
  1. +16
    -2
      kqapi/src/main/java/com/ningdatech/kqapi/common/helper/basic/AbstractMatterCacheHelper.java
  2. +15
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/scheduler/controller/TaskController.java
  3. +90
    -2
      kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/SynTask.java
  4. +44
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/entity/entity/ComponentsMatterEliminateEntity.java
  5. +11
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.java
  6. +5
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.xml
  7. +8
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/ComponentsMatterEliminateService.java
  8. +16
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/ComponentsMatterEliminateServiceImpl.java

+ 16
- 2
kqapi/src/main/java/com/ningdatech/kqapi/common/helper/basic/AbstractMatterCacheHelper.java Vedi File

@@ -5,6 +5,8 @@ import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import com.google.common.collect.Lists;
import com.ningdatech.kqapi.common.constant.BizConst;
import com.ningdatech.kqapi.zzsfw.entity.entity.ComponentsMatterEliminateEntity;
import com.ningdatech.kqapi.zzsfw.service.ComponentsMatterEliminateService;
import com.ningdatech.kqapi.zzsfw.entity.entity.DscSxAdsShareItemQltQlsxCommonIDVKq;
import com.ningdatech.kqapi.zzsfw.entity.entity.MatterKey;
import com.ningdatech.kqapi.zzsfw.entity.entity.NdKqZzsfwMattersDeduplicate;
@@ -18,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
* <p>
@@ -40,11 +43,22 @@ public abstract class AbstractMatterCacheHelper implements InitializingBean {

protected LoadingCache<String, String> mattersUrlCache;

@Autowired
private ComponentsMatterEliminateService componentsMatterEliminateService;

private final String KQ_ZZS_BASE_URL = "https://www.zjzwfw.gov.cn/zjservice-fe/#/workguide?localInnerCode=&siteCode=330000000000";

private Boolean initMatterCache() {
// 首先,查询ComponentsMatterEliminateEntity中isDelete不为1的qlName列表, 未被剔除
List<String> eliminatedQlNames = componentsMatterEliminateService.list(
Wrappers.<ComponentsMatterEliminateEntity>lambdaQuery()
.select(ComponentsMatterEliminateEntity::getQlName)
.ne(ComponentsMatterEliminateEntity::getIsDelete, 1)
).stream().map(ComponentsMatterEliminateEntity::getQlName).collect(Collectors.toList());

// 然后,使用eliminatedQlNames来过滤DscSxAdsShareItemQltQlsxCommonIDVKq查询
List<DscSxAdsShareItemQltQlsxCommonIDVKq> allMatters = kqService
.list(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class)
.list(Wrappers.<DscSxAdsShareItemQltQlsxCommonIDVKq>lambdaQuery()
.select(DscSxAdsShareItemQltQlsxCommonIDVKq::getRowguid,
DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName,
DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState,
@@ -52,9 +66,9 @@ public abstract class AbstractMatterCacheHelper implements InitializingBean {
DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl)
.eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState, "1")
.isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl)
// 确保getQlInnerCodeItem字段不为null且不为""
.isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCodeItem)
.ne(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCodeItem, "")
.notIn(!eliminatedQlNames.isEmpty(), DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, eliminatedQlNames) // 过滤掉那些在eliminatedQlNames中的记录
.orderByDesc(DscSxAdsShareItemQltQlsxCommonIDVKq::getUpdateDate));
if (allMatters.isEmpty()) {
log.warn("事项数据未初始化");


+ 15
- 0
kqapi/src/main/java/com/ningdatech/kqapi/scheduler/controller/TaskController.java Vedi File

@@ -13,10 +13,12 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.List;

/**
@@ -59,6 +61,19 @@ public class TaskController {
return "同步成功";
}

@ApiOperation(value = "剔除某个菜单组件名称数据", notes = "英文逗号','分割")
@GetMapping("/synEliminate")
public String synEliminate(String keys){
return synTask.synEliminate(Arrays.asList(keys.split(",")));
}

@ApiOperation(value = "同步单个菜单组件名称", notes = "同步菜单链接数据")
@GetMapping("/synSingle")
public String synSingle(String key){
synTask.synSingle(key);
return "同步成功";
}

@ApiOperation(value = "同步菜单链接数据", notes = "同步菜单链接数据")
@GetMapping("/syn-menu")
public String synMenuData() throws UnknownHostException {


+ 90
- 2
kqapi/src/main/java/com/ningdatech/kqapi/scheduler/task/SynTask.java Vedi File

@@ -1,10 +1,16 @@
package com.ningdatech.kqapi.scheduler.task;

import cn.hutool.core.date.StopWatch;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.benmanes.caffeine.cache.LoadingCache;
import com.ningdatech.kqapi.common.constant.BizConst;
import com.ningdatech.kqapi.common.enumeration.CommonEnum;
import com.ningdatech.kqapi.common.helper.MatterCacheHelper;
import com.ningdatech.kqapi.scheduler.contants.TaskContant;
import com.ningdatech.kqapi.zzsfw.entity.entity.ComponentsMatterEliminateEntity;
import com.ningdatech.kqapi.zzsfw.service.ComponentsMatterEliminateService;
import com.ningdatech.kqapi.zzsfw.entity.entity.DscSxAdsShareItemQltQlsxCommonIDVKq;
import com.ningdatech.kqapi.zzsfw.entity.entity.MatterKey;
import com.ningdatech.kqapi.zzsfw.entity.entity.NdKqZzsfwMattersDeduplicate;
import com.ningdatech.kqapi.zzsfw.entity.entity.NdKqZzsfwMenu;
import com.ningdatech.kqapi.zzsfw.manage.MatterManage;
@@ -19,9 +25,10 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
* @Classname SynTask
@@ -51,6 +58,16 @@ public class SynTask {
@Autowired
private INdKqZzsfwMenuService menuService;

@Autowired
private IDscSxAdsShareItemQltQlsxCommonIDVKqService kqService;

@Autowired
private ComponentsMatterEliminateService componentsMatterEliminateService;

protected LoadingCache<MatterKey, NdKqZzsfwMattersDeduplicate> mattersDupCache;

private final String KQ_ZZS_BASE_URL = "https://www.zjzwfw.gov.cn/zjservice-fe/#/workguide?localInnerCode=&siteCode=330000000000";

/**
* 每天
*/
@@ -117,4 +134,75 @@ public class SynTask {
}
}
}

public String synEliminate(List<String> keys){
// kqService.remove(new LambdaQueryWrapper<DscSxAdsShareItemQltQlsxCommonIDVKq>()
// .in(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, keys));
// 添加剔除信息
List<ComponentsMatterEliminateEntity> entityList = new ArrayList<>();
keys.forEach(key ->{
ComponentsMatterEliminateEntity one = componentsMatterEliminateService.getOne(Wrappers.lambdaQuery(ComponentsMatterEliminateEntity.class)
.eq(ComponentsMatterEliminateEntity::getQlName, key));
if (Objects.isNull(one)){
entityList.add(new ComponentsMatterEliminateEntity(key,"1"));
}
// 删除缓存
DscSxAdsShareItemQltQlsxCommonIDVKq matter = getSynUrl(key);
String url = KQ_ZZS_BASE_URL.replace("localInnerCode=", "localInnerCode=" + matter.getQlInnerCodeItem());
MatterKey matterKey = MatterKey.of(matter.getQlName(),url);
try {
mattersDupCache.invalidate(matterKey);
}catch (Exception e){
log.error("mattersDupCache is null", e.getMessage());
}
});
componentsMatterEliminateService.saveBatch(entityList);

// 删除menu表
menuService.remove(new LambdaQueryWrapper<NdKqZzsfwMenu>()
.in(NdKqZzsfwMenu::getItemName, keys));

// 删除deduplicate表
matterDeduplicateService.remove(new LambdaQueryWrapper<NdKqZzsfwMattersDeduplicate>()
.in(NdKqZzsfwMattersDeduplicate::getQlName, keys));

return "剔除成功";
}
public DscSxAdsShareItemQltQlsxCommonIDVKq getSynUrl(String key){
DscSxAdsShareItemQltQlsxCommonIDVKq matter = kqService
.getOne(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class)
.select(DscSxAdsShareItemQltQlsxCommonIDVKq::getRowguid,
DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName,
DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState,
DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCodeItem,
DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl)
.eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, key)
.eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlState, "1")
.isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl)
// 确保getQlInnerCodeItem字段不为null且不为""
.isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCodeItem)
.ne(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlInnerCodeItem, "")
.orderByDesc(DscSxAdsShareItemQltQlsxCommonIDVKq::getUpdateDate)
.last(BizConst.LIMIT_1));
return matter;
}

public String synSingle(String key){
DscSxAdsShareItemQltQlsxCommonIDVKq matter = getSynUrl(key);
String url = KQ_ZZS_BASE_URL.replace("localInnerCode=", "localInnerCode=" + matter.getQlInnerCodeItem());
List<NdKqZzsfwMenu> menus = menuService.list(Wrappers.lambdaQuery(NdKqZzsfwMenu.class)
.eq(NdKqZzsfwMenu::getItemName, key));
menus.forEach(menu->{
menuService.update(Wrappers.lambdaUpdate(NdKqZzsfwMenu.class)
.eq(NdKqZzsfwMenu::getId,menu.getId())
.set(NdKqZzsfwMenu::getWebapplyurl,url)
.set(NdKqZzsfwMenu::getHasUrl,CommonEnum.YES.getCode()));
});
// 更新缓存
MatterKey matterKey = MatterKey.of(matter.getQlName(),url);
mattersDupCache.invalidate(matterKey);
mattersDupCache.put(matterKey,NdKqZzsfwMattersDeduplicate.of(matter.getQlName(),url));
return "更新成功,rul:" + url;
}
}

+ 44
- 0
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/entity/entity/ComponentsMatterEliminateEntity.java Vedi File

@@ -0,0 +1,44 @@
package com.ningdatech.kqapi.zzsfw.entity.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.security.Timestamp;

// ComponentsMatterEliminateEntity.java
@Data
@TableName("components_matter_eliminate")
public class ComponentsMatterEliminateEntity {

/**
* 事项名称剔除表,主要剔除事项url报错404链接
*/

@ApiModelProperty("id主键")
@TableId(type = IdType.AUTO)
private Long id;
/**
* 组件名称
*/
private String qlName;

/**
* 剔除时间
*/
private Timestamp eliminateTime;

/**
* 剔除标识,0未剔除,1已剔除
*/
private String isDelete;

public ComponentsMatterEliminateEntity(String qlName,String isDelete) {
this.qlName = qlName;
this.isDelete = isDelete;
}
}


+ 11
- 0
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.java Vedi File

@@ -0,0 +1,11 @@
package com.ningdatech.kqapi.zzsfw.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ningdatech.kqapi.zzsfw.entity.entity.ComponentsMatterEliminateEntity;

/**
* @author wangrenkang
* @date 2024-01-15 10:53:17
*/
public interface ComponentsMatterEliminateMapper extends BaseMapper<ComponentsMatterEliminateEntity> {
}

+ 5
- 0
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/ComponentsMatterEliminateMapper.xml Vedi File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ningdatech.kqapi.zzsfw.mapper.ComponentsMatterEliminateMapper">

</mapper>

+ 8
- 0
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/ComponentsMatterEliminateService.java Vedi File

@@ -0,0 +1,8 @@
package com.ningdatech.kqapi.zzsfw.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ningdatech.kqapi.zzsfw.entity.entity.ComponentsMatterEliminateEntity;

// ComponentsMatterEliminateService.java
public interface ComponentsMatterEliminateService extends IService<ComponentsMatterEliminateEntity> {
}

+ 16
- 0
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/ComponentsMatterEliminateServiceImpl.java Vedi File

@@ -0,0 +1,16 @@
package com.ningdatech.kqapi.zzsfw.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.kqapi.zzsfw.entity.entity.ComponentsMatterEliminateEntity;
import com.ningdatech.kqapi.zzsfw.mapper.ComponentsMatterEliminateMapper;
import com.ningdatech.kqapi.zzsfw.service.ComponentsMatterEliminateService;
import org.springframework.stereotype.Service;

/**
* @author wangrenkang
* @date 2024-01-15 10:54:49
*/
@Service
public class ComponentsMatterEliminateServiceImpl extends ServiceImpl<ComponentsMatterEliminateMapper, ComponentsMatterEliminateEntity> implements ComponentsMatterEliminateService {

}

Loading…
Annulla
Salva