Browse Source

新增考核项目导入 并增加文件名称字段

ops-management-platform-backend-dev
gjh 2 weeks ago
parent
commit
51aeea7899
  1. 20
      ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/controller/PerformanceManagementController.java
  2. 18
      ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/controller/TestController.java
  3. 2
      ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/domain/NoticeInfo.java
  4. 14
      ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/domain/PerformanceManagement.java
  5. 1
      ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/domain/bo/NoticeInfoBo.java
  6. 2
      ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/domain/vo/NoticeInfoVo.java
  7. 68
      ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/listener/PerformanceManagementListener.java
  8. 6
      ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/IPerformanceManagementService.java
  9. 7
      ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/impl/PerformanceManagementServiceImpl.java

20
ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/controller/PerformanceManagementController.java

@ -1,11 +1,16 @@
package org.dromara.platform.controller; package org.dromara.platform.controller;
import java.io.IOException;
import java.util.List; import java.util.List;
import com.alibaba.excel.EasyExcel;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*; import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import lombok.extern.slf4j.Slf4j;
import org.dromara.platform.domain.PerformanceManagement;
import org.dromara.platform.listener.PerformanceManagementListener;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit; import org.dromara.common.idempotent.annotation.RepeatSubmit;
@ -21,6 +26,7 @@ import org.dromara.platform.domain.vo.PerformanceManagementVo;
import org.dromara.platform.domain.bo.PerformanceManagementBo; import org.dromara.platform.domain.bo.PerformanceManagementBo;
import org.dromara.platform.service.IPerformanceManagementService; import org.dromara.platform.service.IPerformanceManagementService;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/** /**
* 考核管理 * 考核管理
@ -31,6 +37,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
@Validated @Validated
@RequiredArgsConstructor @RequiredArgsConstructor
@RestController @RestController
@Slf4j
@RequestMapping("/platform/management") @RequestMapping("/platform/management")
public class PerformanceManagementController extends BaseController { public class PerformanceManagementController extends BaseController {
@ -102,4 +109,17 @@ public class PerformanceManagementController extends BaseController {
@PathVariable String[] ids) { @PathVariable String[] ids) {
return toAjax(performanceManagementService.deleteWithValidByIds(List.of(ids), true)); return toAjax(performanceManagementService.deleteWithValidByIds(List.of(ids), true));
} }
@PostMapping("/uploadFromExcel")
public void uploadPerformanceManagement(MultipartFile file, HttpServletResponse response) throws IOException {
long t1 = System.currentTimeMillis();
EasyExcel.read(file.getInputStream(), PerformanceManagement.class, new PerformanceManagementListener(performanceManagementService)).sheet().doRead();
response.setContentType("text/html;charset=utf8");
long t2 = System.currentTimeMillis();
response.getWriter().println("导入数据成功!,共用时:"+(t2-t1)+"ms");
log.info("导入考核项目成功! 共用时:{}ms",(t2-t1));
}
} }

18
ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/controller/TestController.java

@ -5,8 +5,11 @@ import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.dromara.platform.domain.PerformanceManagement;
import org.dromara.platform.domain.ProjectManager; import org.dromara.platform.domain.ProjectManager;
import org.dromara.platform.listener.PerformanceManagementListener;
import org.dromara.platform.listener.ProjectManagerListener; import org.dromara.platform.listener.ProjectManagerListener;
import org.dromara.platform.service.IPerformanceManagementService;
import org.dromara.platform.service.ProjectManagerService; import org.dromara.platform.service.ProjectManagerService;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -67,4 +70,19 @@ public class TestController {
.sheet("项目联系人信息"+currentDate) .sheet("项目联系人信息"+currentDate)
.doWrite(projectManagerService.getData()); .doWrite(projectManagerService.getData());
} }
@Resource
private IPerformanceManagementService performanceManagementService;
@PostMapping("/uploadPerformanceManagement")
public void uploadPerformanceManagement(MultipartFile file, HttpServletResponse response) throws IOException {
long t1 = System.currentTimeMillis();
EasyExcel.read(file.getInputStream(), PerformanceManagement.class, new PerformanceManagementListener(performanceManagementService)).sheet().doRead();
response.setContentType("text/html;charset=utf8");
long t2 = System.currentTimeMillis();
response.getWriter().println("导入数据成功!,共用时:"+(t2-t1));
log.info("导入项目负责人数据成功! 共用时:{}ms",(t2-t1));
}
} }

2
ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/domain/NoticeInfo.java

@ -57,6 +57,8 @@ public class NoticeInfo extends TenantEntity {
*/ */
private String attachment; private String attachment;
private String fileName;
/** /**
* 当前状态 * 当前状态
*/ */

14
ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/domain/PerformanceManagement.java

@ -1,5 +1,7 @@
package org.dromara.platform.domain; package org.dromara.platform.domain;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import org.dromara.common.tenant.core.TenantEntity; import org.dromara.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import lombok.Data; import lombok.Data;
@ -24,42 +26,50 @@ public class PerformanceManagement extends TenantEntity {
/** /**
* 唯一标识符 * 唯一标识符
*/ */
@ExcelIgnore
@TableId(value = "id") @TableId(value = "id")
private String id; private String id;
/** /**
* 类型 * 类型(暂未使用)
*/ */
@ExcelIgnore
private String type; private String type;
/** /**
* 评分大类 * 评分大类
*/ */
@ExcelProperty("评分大类")
private String largeRating; private String largeRating;
/** /**
* 评分小类 * 评分小类
*/ */
@ExcelProperty("评分小类")
private String smallRating; private String smallRating;
/** /**
* 分值 * 分值
*/ */
@ExcelProperty("分值")
private Long rating; private Long rating;
/** /**
* 扣分标准 * 扣分标准
*/ */
@ExcelProperty("扣分标准")
private String standards; private String standards;
/** /**
* 考核类型 *
*/ */
@ExcelProperty("考核类型")
private String checkType; private String checkType;
/** /**
* 当前状态 * 当前状态
*/ */
@ExcelIgnore
private Long status; private Long status;
/** /**

1
ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/domain/bo/NoticeInfoBo.java

@ -44,6 +44,7 @@ public class NoticeInfoBo extends BaseEntity {
@NotBlank(message = "类型不能为空", groups = { AddGroup.class, EditGroup.class }) @NotBlank(message = "类型不能为空", groups = { AddGroup.class, EditGroup.class })
private String type; private String type;
private String fileName;
/** /**
* 操作人 * 操作人
*/ */

2
ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/domain/vo/NoticeInfoVo.java

@ -82,7 +82,7 @@ public class NoticeInfoVo implements Serializable {
* 创建者 * 创建者
*/ */
private Long createBy; private Long createBy;
private String fileName;
/** /**
* 创建时间 * 创建时间
*/ */

68
ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/listener/PerformanceManagementListener.java

@ -0,0 +1,68 @@
package org.dromara.platform.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.platform.domain.PerformanceManagement;
import org.dromara.platform.domain.ProjectManager;
import org.dromara.platform.mapper.PerformanceManagementMapper;
import org.dromara.platform.service.IPerformanceManagementService;
import org.dromara.platform.service.ProjectManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
/**
* 自定义监听器读数据
* @author gjh
*/
@Slf4j
public class PerformanceManagementListener implements ReadListener<PerformanceManagement> {
private List<PerformanceManagement> list = new ArrayList<>();
/**
* 自己定义一个缓冲量
*/
private static final int BATCH_COUNT = 20;
@Resource
private PerformanceManagementMapper performanceManagementMapper;
@Resource
private IPerformanceManagementService performanceManagementService;
public PerformanceManagementListener(IPerformanceManagementService performanceManagementService) {
this.performanceManagementService = performanceManagementService;
}
/**
* 每读一行数据都会调用这个方法
*
* @param performanceManagement
* @param analysisContext
*/
@Override
public void invoke(PerformanceManagement performanceManagement, AnalysisContext analysisContext) {
// 读取一行数据就添加到集合
list.add(performanceManagement);
// 判断是否到达缓存量了
if (list.size() >= BATCH_COUNT){
// 操作数据库
performanceManagementService.addData(list);
list = new ArrayList<>(BATCH_COUNT);
}
}
/**
* 读完整个excel之后再调用这个方法
*
* @param analysisContext
*/
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
if (list.size()>0){
performanceManagementService.addData(list);
}
}
}

6
ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/IPerformanceManagementService.java

@ -1,5 +1,8 @@
package org.dromara.platform.service; package org.dromara.platform.service;
import org.dromara.platform.domain.AgreementInfo;
import org.dromara.platform.domain.PerformanceManagement;
import org.dromara.platform.domain.ProjectManager;
import org.dromara.platform.domain.vo.PerformanceManagementVo; import org.dromara.platform.domain.vo.PerformanceManagementVo;
import org.dromara.platform.domain.bo.PerformanceManagementBo; import org.dromara.platform.domain.bo.PerformanceManagementBo;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -65,4 +68,7 @@ public interface IPerformanceManagementService {
* @return 是否删除成功 * @return 是否删除成功
*/ */
Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid); Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid);
void addData(List<PerformanceManagement> list);
} }

7
ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/service/impl/PerformanceManagementServiceImpl.java

@ -132,4 +132,11 @@ public class PerformanceManagementServiceImpl implements IPerformanceManagementS
} }
return baseMapper.deleteByIds(ids) > 0; return baseMapper.deleteByIds(ids) > 0;
} }
@Override
public void addData(List<PerformanceManagement> list) {
baseMapper.insert(list);
}
} }

Loading…
Cancel
Save