@@ -0,0 +1,43 @@ | |||
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 io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import java.io.Serializable; | |||
import java.time.LocalDateTime; | |||
/** | |||
* <p> | |||
* | |||
* </p> | |||
* | |||
* @author ZPF | |||
* @since 2023-10-27 | |||
*/ | |||
@Data | |||
@TableName("nd_kq_zzsfw_matters_deduplicate") | |||
@ApiModel(value = "NdKqZzsfwMattersDeduplicate", description = "") | |||
public class NdKqZzsfwMattersDeduplicate implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
@ApiModelProperty("id主键") | |||
@TableId(type = IdType.AUTO) | |||
private Long id; | |||
@ApiModelProperty("数据同步时间") | |||
private LocalDateTime createOn; | |||
@ApiModelProperty("事项名称") | |||
private String qlName; | |||
@ApiModelProperty("链接") | |||
private String webapplyurl; | |||
@ApiModelProperty("重复数") | |||
private Integer countNum; | |||
} |
@@ -11,10 +11,8 @@ import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.springframework.stereotype.Component; | |||
import java.util.Collections; | |||
import java.util.HashSet; | |||
import java.util.List; | |||
import java.util.Set; | |||
import java.util.*; | |||
import java.util.stream.Collectors; | |||
/** | |||
@@ -32,7 +30,6 @@ public class MatterManage { | |||
public List<TreeVO> getMatters() { | |||
List<NdKqZzsfwMenu> matters = menuService.list(Wrappers.lambdaQuery(NdKqZzsfwMenu.class) | |||
.eq(NdKqZzsfwMenu::getHasUrl, CommonEnum.YES.getCode()) | |||
.orderByAsc(NdKqZzsfwMenu::getSort)); | |||
if(CollUtil.isEmpty(matters)){ | |||
return Collections.emptyList(); | |||
@@ -76,7 +73,8 @@ public class MatterManage { | |||
} | |||
private List<TreeVO> generateMatters(NdKqZzsfwMenu menu, List<NdKqZzsfwMenu> matters) { | |||
return matters.stream().filter(m -> StringUtils.isNotBlank(m.getDepartment()) && | |||
return matters.stream().filter(m -> Objects.nonNull(m.getHasUrl()) && m.getHasUrl() == 1 && | |||
StringUtils.isNotBlank(m.getDepartment()) && | |||
m.getDepartment().equals(menu.getDepartment()) && m.getWindow().equals(menu.getWindow()) && | |||
m.getZoneName().equals(menu.getZoneName())) | |||
.map(m -> { | |||
@@ -0,0 +1,16 @@ | |||
package com.ningdatech.kqapi.zzsfw.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.ningdatech.kqapi.zzsfw.entity.entity.NdKqZzsfwMattersDeduplicate; | |||
/** | |||
* <p> | |||
* Mapper 接口 | |||
* </p> | |||
* | |||
* @author ZPF | |||
* @since 2023-10-27 | |||
*/ | |||
public interface NdKqZzsfwMatterDeduplicateMapper extends BaseMapper<NdKqZzsfwMattersDeduplicate> { | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.ningdatech.kqapi.zzsfw.service; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.ningdatech.kqapi.zzsfw.entity.entity.NdKqZzsfwMattersDeduplicate; | |||
/** | |||
* <p> | |||
* 服务类 | |||
* </p> | |||
* | |||
* @author ZPF | |||
* @since 2023-10-27 | |||
*/ | |||
public interface INdKqZzsfwMatterDeduplicateService extends IService<NdKqZzsfwMattersDeduplicate> { | |||
} |
@@ -0,0 +1,21 @@ | |||
package com.ningdatech.kqapi.zzsfw.service.impl; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.ningdatech.kqapi.zzsfw.entity.entity.NdKqZzsfwMattersDeduplicate; | |||
import com.ningdatech.kqapi.zzsfw.mapper.NdKqZzsfwMatterDeduplicateMapper; | |||
import com.ningdatech.kqapi.zzsfw.service.INdKqZzsfwMatterDeduplicateService; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* <p> | |||
* 服务实现类 | |||
* </p> | |||
* | |||
* @author ZPF | |||
* @since 2023-10-27 | |||
*/ | |||
@Service | |||
public class NdKqZzsfwMatterDeduplicateServiceImpl extends ServiceImpl<NdKqZzsfwMatterDeduplicateMapper, NdKqZzsfwMattersDeduplicate> | |||
implements INdKqZzsfwMatterDeduplicateService { | |||
} |
@@ -0,0 +1,101 @@ | |||
package com.ningdatech.kqapi.menu; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.google.common.collect.Sets; | |||
import com.ningdatech.kqapi.AppTests; | |||
import com.ningdatech.kqapi.zzsfw.entity.entity.NdKqZzsfwMattersDeduplicate; | |||
import com.ningdatech.kqapi.zzsfw.entity.entity.NdKqZzsfwMenu; | |||
import com.ningdatech.kqapi.zzsfw.service.INdKqZzsfwMatterDeduplicateService; | |||
import com.ningdatech.kqapi.zzsfw.service.INdKqZzsfwMenuService; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.apache.poi.ss.usermodel.Row; | |||
import org.apache.poi.ss.usermodel.Sheet; | |||
import org.apache.poi.ss.usermodel.Workbook; | |||
import org.apache.poi.xssf.usermodel.XSSFWorkbook; | |||
import org.junit.Assert; | |||
import org.junit.Test; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import java.io.FileInputStream; | |||
import java.io.IOException; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @Classname DuplicationTest | |||
* @Description | |||
* @Date 2023/11/17 10:42 | |||
* @Author PoffyZhang | |||
*/ | |||
public class DuplicationTest extends AppTests { | |||
@Autowired | |||
private INdKqZzsfwMatterDeduplicateService matterDeduplicateService; | |||
@Autowired | |||
private INdKqZzsfwMenuService menuService; | |||
@Test | |||
public void test() throws IOException { | |||
FileInputStream fis = new FileInputStream("C:\\Users\\PoffyZhang\\Desktop\\去重后的事项数据.xlsx"); | |||
Workbook workbook = new XSSFWorkbook(fis); | |||
Assert.assertNotNull(workbook); | |||
Row row; | |||
if (workbook != null) { | |||
//获取最大行数 | |||
Sheet sheet = workbook.getSheetAt(0); | |||
int rownum = sheet.getPhysicalNumberOfRows(); | |||
//获取第一行 | |||
row = sheet.getRow(0); | |||
//获取最大列数 | |||
Integer num = 1; | |||
matterDeduplicateService.remove(Wrappers.lambdaQuery(NdKqZzsfwMattersDeduplicate.class)); | |||
for (int i = 2; i < rownum; i++) { | |||
row = sheet.getRow(i); | |||
if(row.getZeroHeight()){ | |||
continue; | |||
} | |||
System.out.println("记数:" + (num++)); | |||
System.out.println(row.getCell(0).getStringCellValue()); | |||
System.out.println(row.getCell(1).getStringCellValue()); | |||
Double numericCellValue = row.getCell(2).getNumericCellValue(); | |||
NdKqZzsfwMattersDeduplicate menu = new NdKqZzsfwMattersDeduplicate(); | |||
menu.setWebapplyurl(row.getCell(1).getStringCellValue()); | |||
menu.setQlName(row.getCell(0).getStringCellValue()); | |||
menu.setCreateOn(LocalDateTime.now()); | |||
menu.setCountNum(numericCellValue.intValue()); | |||
matterDeduplicateService.save(menu); | |||
} | |||
} | |||
} | |||
@Test | |||
public void syncUrl(){ | |||
List<NdKqZzsfwMenu> menus = menuService.list(Wrappers.lambdaQuery(NdKqZzsfwMenu.class) | |||
.isNull(NdKqZzsfwMenu::getWebapplyurl)); | |||
List<NdKqZzsfwMattersDeduplicate> list = matterDeduplicateService.list(); | |||
Set<String> qlSet = Sets.newTreeSet(); | |||
Map<String, String> map = list.stream().filter(q -> qlSet.add(q.getQlName())) | |||
.filter(q -> StringUtils.isNotBlank(q.getWebapplyurl()) && StringUtils.isNotBlank(q.getQlName())) | |||
.collect(Collectors.toMap(q -> q.getQlName(), q -> q.getWebapplyurl())); | |||
for(NdKqZzsfwMenu menu : menus){ | |||
String itemName = menu.getItemName(); | |||
if(map.containsKey(itemName)){ | |||
String url = map.get(itemName); | |||
menu.setWebapplyurl(url); | |||
menu.setHasUrl(1); | |||
menuService.updateById(menu); | |||
} | |||
} | |||
} | |||
} |
@@ -32,7 +32,7 @@ public class MenuTest extends AppTests { | |||
@Test | |||
public void test() throws IOException { | |||
FileInputStream fis = new FileInputStream("C:\\Users\\PoffyZhang\\Desktop\\8.8柯桥区企业综合服务中心政务服务事项清单2.xlsx"); | |||
FileInputStream fis = new FileInputStream("C:\\Users\\PoffyZhang\\Desktop\\11.14柯桥.xlsx"); | |||
Workbook workbook = new XSSFWorkbook(fis); | |||
Assert.assertNotNull(workbook); | |||
Row row; | |||
@@ -44,6 +44,9 @@ public class MenuTest extends AppTests { | |||
row = sheet.getRow(0); | |||
//获取最大列数 | |||
Integer num = 1; | |||
menuService.remove(Wrappers.lambdaQuery(NdKqZzsfwMenu.class)); | |||
for (int i = 2; i < rownum; i++) { | |||
row = sheet.getRow(i); | |||
if(row.getZeroHeight()){ | |||
@@ -66,16 +69,16 @@ public class MenuTest extends AppTests { | |||
menu.setSort(numericCellValue.intValue()); | |||
//去查询 url | |||
DscSxAdsShareItemQltQlsxCommonIDVKq item = itemQltQlsxCommonIDVKqService.getOne(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class) | |||
.select(DscSxAdsShareItemQltQlsxCommonIDVKq::getRowguid, DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl, DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName) | |||
.eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, itemName) | |||
.isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl) | |||
.last("limit 1")); | |||
if(Objects.nonNull(item)){ | |||
// DscSxAdsShareItemQltQlsxCommonIDVKq item = itemQltQlsxCommonIDVKqService.getOne(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class) | |||
// .select(DscSxAdsShareItemQltQlsxCommonIDVKq::getRowguid, DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl, DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName) | |||
// .eq(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, itemName) | |||
// .isNotNull(DscSxAdsShareItemQltQlsxCommonIDVKq::getWebapplyurl) | |||
// .last("limit 1")); | |||
// if(Objects.nonNull(item)){ | |||
menu.setHasUrl(1); | |||
menu.setWebapplyurl(item.getWebapplyurl()); | |||
menu.setItemRowid(item.getRowguid()); | |||
} | |||
// menu.setWebapplyurl(item.getWebapplyurl()); | |||
// menu.setItemRowid(item.getRowguid()); | |||
// } | |||
menuService.save(menu); | |||
} | |||