Przeglądaj źródła

政策条例

master
PoffyZhang 1 rok temu
rodzic
commit
154e2dfc6b
8 zmienionych plików z 347 dodań i 0 usunięć
  1. +36
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/PolicyRegulationsController.java
  2. +64
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/entity/entity/NdKqZzsfwPolicy.java
  3. +59
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/entity/vo/NdKqZzsfwPolicyVO.java
  4. +45
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/PolicyManage.java
  5. +17
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/NdKqZzsfwPolicyMapper.java
  6. +16
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/INdKqZzsfwPolicyService.java
  7. +21
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/NdKqZzsfwPolicyServiceImpl.java
  8. +89
    -0
      kqapi/src/test/java/com/ningdatech/kqapi/menu/PolicyTest.java

+ 36
- 0
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/PolicyRegulationsController.java Wyświetl plik

@@ -0,0 +1,36 @@
package com.ningdatech.kqapi.zzsfw.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.kqapi.zzsfw.entity.vo.NdKqZzsfwPolicyVO;
import com.ningdatech.kqapi.zzsfw.manage.PolicyManage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
* @Classname PolicyRegulationsController
* @Description
* @Date 2023/11/2 9:55
* @Author PoffyZhang
*/
@Slf4j
@Validated
@RestController
@RequestMapping("/api/v1/poclicy/")
@Api(value = "PolicyRegulationsController", tags = "柯桥-政策条例")
@RequiredArgsConstructor
public class PolicyRegulationsController {
private final PolicyManage policyManage;

@ApiOperation(value = "政策条例分页列表", notes = "政策条例分页列表")
@GetMapping("/list")
public PageVo<NdKqZzsfwPolicyVO> list(@RequestParam(defaultValue = "1") int pageNumber, @RequestParam(defaultValue = "10") int pageSize) {
return policyManage.list(pageNumber,pageSize);
}
}

+ 64
- 0
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/entity/entity/NdKqZzsfwPolicy.java Wyświetl plik

@@ -0,0 +1,64 @@
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-11-02
*/
@Data
@TableName("nd_kq_zzsfw_policy")
@ApiModel(value = "NdKqZzsfwPolicy对象", description = "")
public class NdKqZzsfwPolicy implements Serializable {

private static final long serialVersionUID = 1L;

@ApiModelProperty("id主键")
@TableId(type = IdType.AUTO)
private Long id;

@ApiModelProperty("数据同步时间")
private LocalDateTime createOn;

@ApiModelProperty("抬头")
private String header;

@ApiModelProperty("标题")
private String title;

@ApiModelProperty("二级标题")
private String secondTitle;

@ApiModelProperty("适用地区")
private String regionName;

@ApiModelProperty("责任部门")
private String department;

@ApiModelProperty("发文日期")
private String issueDate;

@ApiModelProperty("状态")
private String status;

@ApiModelProperty("申报时间")
private String applyTime;

@ApiModelProperty("在线咨询url")
private String onlineConsultationUrl;

@ApiModelProperty("排序")
private Integer sort;
}

+ 59
- 0
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/entity/vo/NdKqZzsfwPolicyVO.java Wyświetl plik

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

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-11-02
*/
@Data
@ApiModel(value = "NdKqZzsfwPolicy VO", description = "")
public class NdKqZzsfwPolicyVO implements Serializable {

private static final long serialVersionUID = 1L;

@ApiModelProperty("id主键")
private Long id;

@ApiModelProperty("数据同步时间")
private LocalDateTime createOn;

@ApiModelProperty("抬头")
private String header;

@ApiModelProperty("标题")
private String title;

@ApiModelProperty("二级标题")
private String secondTitle;

@ApiModelProperty("适用地区")
private String regionName;

@ApiModelProperty("责任部门")
private String department;

@ApiModelProperty("发文日期")
private String issueDate;

@ApiModelProperty("状态")
private String status;

@ApiModelProperty("申报时间")
private String applyTime;

@ApiModelProperty("在线咨询url")
private String onlineConsultationUrl;

@ApiModelProperty("排序")
private Integer sort;
}

+ 45
- 0
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/PolicyManage.java Wyświetl plik

@@ -0,0 +1,45 @@
package com.ningdatech.kqapi.zzsfw.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.kqapi.zzsfw.entity.entity.NdKqZzsfwPolicy;
import com.ningdatech.kqapi.zzsfw.entity.vo.NdKqZzsfwPolicyVO;
import com.ningdatech.kqapi.zzsfw.service.INdKqZzsfwPolicyService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

/**
* @Classname PolicyManage
* @Description
* @Date 2023/11/02 14:55
* @Author PoffyZhang
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class PolicyManage {

private final INdKqZzsfwPolicyService policyService;


public PageVo<NdKqZzsfwPolicyVO> list(int pageNumber, int pageSize) {
Page<NdKqZzsfwPolicy> page = Page.of(pageNumber,pageSize);
policyService.page(page,Wrappers.lambdaQuery(NdKqZzsfwPolicy.class)
.orderByAsc(NdKqZzsfwPolicy::getSort));

if(CollUtil.isEmpty(page.getRecords())){
return PageVo.empty();
}
List<NdKqZzsfwPolicyVO> res = page.getRecords().stream()
.map(p -> BeanUtil.copyProperties(p,NdKqZzsfwPolicyVO.class))
.collect(Collectors.toList());
return PageVo.of(res,page.getTotal());
}
}

+ 17
- 0
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/mapper/NdKqZzsfwPolicyMapper.java Wyświetl plik

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

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

/**
* <p>
* Mapper 接口
* </p>
*
* @author ZPF
* @since 2023-10-27
*/
public interface NdKqZzsfwPolicyMapper extends BaseMapper<NdKqZzsfwPolicy> {

}

+ 16
- 0
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/INdKqZzsfwPolicyService.java Wyświetl plik

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

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

/**
* <p>
* 服务类
* </p>
*
* @author ZPF
* @since 2023-10-27
*/
public interface INdKqZzsfwPolicyService extends IService<NdKqZzsfwPolicy> {

}

+ 21
- 0
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/service/impl/NdKqZzsfwPolicyServiceImpl.java Wyświetl plik

@@ -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.NdKqZzsfwPolicy;
import com.ningdatech.kqapi.zzsfw.mapper.NdKqZzsfwPolicyMapper;
import com.ningdatech.kqapi.zzsfw.service.INdKqZzsfwPolicyService;
import org.springframework.stereotype.Service;

/**
* <p>
* 服务实现类
* </p>
*
* @author ZPF
* @since 2023-10-27
*/
@Service
public class NdKqZzsfwPolicyServiceImpl extends ServiceImpl<NdKqZzsfwPolicyMapper, NdKqZzsfwPolicy>
implements INdKqZzsfwPolicyService {

}

+ 89
- 0
kqapi/src/test/java/com/ningdatech/kqapi/menu/PolicyTest.java Wyświetl plik

@@ -0,0 +1,89 @@
package com.ningdatech.kqapi.menu;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.kqapi.AppTests;
import com.ningdatech.kqapi.zzsfw.entity.entity.DscSxAdsShareItemQltQlsxCommonIDVKq;
import com.ningdatech.kqapi.zzsfw.entity.entity.NdKqZzsfwMenu;
import com.ningdatech.kqapi.zzsfw.entity.entity.NdKqZzsfwPolicy;
import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService;
import com.ningdatech.kqapi.zzsfw.service.INdKqZzsfwMenuService;
import com.ningdatech.kqapi.zzsfw.service.INdKqZzsfwPolicyService;
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.Objects;

/**
* @Classname MenuTest
* @Description
* @Date 2023/10/27 9:51
* @Author PoffyZhang
*/
public class PolicyTest extends AppTests {

@Autowired
private INdKqZzsfwPolicyService policyService;

@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;

policyService.remove(Wrappers.lambdaQuery(NdKqZzsfwPolicy.class));

if (workbook != null) {
//获取最大行数
Sheet sheet = workbook.getSheetAt(0);
int rownum = sheet.getPhysicalNumberOfRows();
//获取第一行
row = sheet.getRow(0);
//获取最大列数
Integer sort = 1;
for (int i = 2; i < rownum; i++) {
row = sheet.getRow(i);
if(row.getZeroHeight()){
continue;
}

String header = Objects.nonNull(row.getCell(0)) ? row.getCell(0).getStringCellValue() : null;
String title = Objects.nonNull(row.getCell(1)) ? row.getCell(1).getStringCellValue() : null;
String secondTitle = Objects.nonNull(row.getCell(2)) ? row.getCell(2).getStringCellValue() : null;
String regionName = Objects.nonNull(row.getCell(3)) ? row.getCell(3).getStringCellValue() : null;
String department = Objects.nonNull(row.getCell(4)) ? row.getCell(4).getStringCellValue() : null;
String issueDate = Objects.nonNull(row.getCell(5)) ? DateUtil.format(row.getCell(5).getDateCellValue(),"yyyy/MM/dd") : null;
String status = Objects.nonNull(row.getCell(7)) ? row.getCell(7).getStringCellValue() : null;
String applyTime = Objects.nonNull(row.getCell(8)) ? row.getCell(8).getStringCellValue() : null;
String url = Objects.nonNull(row.getCell(9)) ? row.getCell(9).getStringCellValue() : null;

NdKqZzsfwPolicy policy = new NdKqZzsfwPolicy();
policy.setHeader(header);
policy.setTitle(title);
policy.setSecondTitle(secondTitle);
policy.setRegionName(regionName);
policy.setDepartment(department);
policy.setIssueDate(issueDate);
policy.setStatus(status);
policy.setApplyTime(applyTime);
policy.setOnlineConsultationUrl(url);
policy.setCreateOn(LocalDateTime.now());
policy.setSort(sort);

policyService.save(policy);

System.out.println("记数:" + (sort++));
}
}
}

}

Ładowanie…
Anuluj
Zapisz