导出bug修改

dev^2
zjh 1 year ago
parent 3579a1aa63
commit 0258076ffb
  1. 103
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/controller/BugxController.java
  2. 9
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/entity/Bugx.java
  3. 143
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/entity/BugxExportDto.java
  4. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/mapper/BugxMapper.java
  5. 1
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/service/IBugxService.java
  6. 1
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/service/impl/BugxServiceImpl.java

@ -1,23 +1,19 @@
package org.jeecg.modules.demo.bugx.controller; package org.jeecg.modules.demo.bugx.controller;
import java.util.Arrays; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.demo.bugx.entity.Bugx; import org.jeecg.modules.demo.bugx.entity.Bugx;
import org.jeecg.modules.demo.bugx.entity.BugxExportDto;
import org.jeecg.modules.demo.bugx.service.IBugxService; import org.jeecg.modules.demo.bugx.service.IBugxService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -34,18 +30,14 @@ import org.jeecg.modules.modulex.entity.Modulex;
import org.jeecg.modules.modulex.mapper.ModulexMapper; import org.jeecg.modules.modulex.mapper.ModulexMapper;
import org.jeecg.modules.projectx.entity.Projectx; import org.jeecg.modules.projectx.entity.Projectx;
import org.jeecg.modules.projectx.mapper.ProjectxMapper; import org.jeecg.modules.projectx.mapper.ProjectxMapper;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.aspect.annotation.AutoLog;
@ -279,7 +271,92 @@ public class BugxController extends JeecgController<Bugx, IBugxService> {
*/ */
@RequestMapping(value = "/exportXls") @RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, Bugx bugx) { public ModelAndView exportXls(HttpServletRequest request, Bugx bugx) {
return super.exportXls(request, bugx, Bugx.class, "BUG管理"); return this.exportXlss(request, bugx, BugxExportDto.class, "BUG管理");
}
protected ModelAndView exportXlss(HttpServletRequest request, Bugx bugx, Class<BugxExportDto> clazz, String title) {
// Step.1 组装查询条件
QueryWrapper<Bugx> queryWrapper = QueryGenerator.initQueryWrapper(bugx, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String getRealname = "佚名";
if (sysUser != null) {
getRealname = sysUser.getRealname();
}
// Step.2 获取导出数据
List<Bugx> pageList = bugxService.list(queryWrapper);
List<BugxExportDto> exportList = null;
List<BugxExportDto> BugxExportDtoList =new ArrayList<>();
for (Bugx bugx1 : pageList) {
BugxExportDto BugxExportDto = new BugxExportDto();
BeanUtils.copyProperties(bugx1,BugxExportDto);
String projectId = bugx1.getProjectId();
Projectx projectx = projectxMapper.selectById(projectId);
if (projectx!=null)
BugxExportDto.setProjectId(projectx.getProjectName());
//模块id
String moduleId = bugx1.getModuleId();
Modulex modulex = modulexMapper.selectById(moduleId);
if (modulex!=null)
BugxExportDto.setModuleId(modulex.getModuleName());
//功能id
String functionId = bugx1.getFunctionId();
Functionx functionx = functionxMapper.selectById(functionId);
if (functionx!=null)
BugxExportDto.setFunctionId(functionx.getFunctionName());
//规则id
String ruleId = bugx1.getRuleId();
Rulex rulex = rulexMapper.selectById(ruleId);
if (rulex!=null)
BugxExportDto.setRulePm_desc(rulex.getPmDescribe());
//bug状态
Integer bugStatus = bugx1.getBugStatus();
if (bugStatus.equals(1)){
BugxExportDto.setBugStatusName("已解决");
} else if (bugStatus.equals(3))
BugxExportDto.setBugStatusName("待修改");
else if (bugStatus.equals(0))
BugxExportDto.setBugStatusName("未解决");
//bug类型
Integer type = bugx1.getType();
if (type.equals(1)){
BugxExportDto.setTypeName("模块");
} else if (type.equals(3))
BugxExportDto.setTypeName("规则");
else if (type.equals(0))
BugxExportDto.setTypeName("项目");
else if (type.equals(2))
BugxExportDto.setTypeName("功能");
BugxExportDtoList.add(BugxExportDto);
}
// 过滤选中数据
String selections = request.getParameter("selections");
if (oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(","));
exportList = BugxExportDtoList.stream().filter(item -> selectionList.contains(getId(item))).collect(Collectors.toList());
} else {
exportList = BugxExportDtoList;
}
// Step.3 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
mv.addObject(NormalExcelConstants.FILE_NAME, title); //此处设置的filename无效 ,前端会重更新设置一下
mv.addObject(NormalExcelConstants.CLASS, clazz);
//update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
ExportParams exportParams = new ExportParams(title + "报表", "导出人:" + getRealname, title);
exportParams.setImageBasePath(upLoadPath);
//update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
mv.addObject(NormalExcelConstants.PARAMS, exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
return mv;
}
protected String getId(BugxExportDto item) {
try {
return PropertyUtils.getProperty(item, "id").toString();
} catch (Exception e) {
e.printStackTrace();
return null;
}
} }
/** /**

@ -63,23 +63,24 @@ public class Bugx implements Serializable {
/**项目id*/ /**项目id*/
@Excel(name = "项目id", width = 15) @Excel(name = "项目id", width = 15)
@ApiModelProperty(value = "项目id") @ApiModelProperty(value = "项目id")
@Dict(dicText = "project_code",dicCode = "id",dictTable = "projectx") @Dict(dicCode = "id",dicText = "project_code",dictTable = "projectx")
private java.lang.String projectId; private java.lang.String projectId;
/**对应模块id*/ /**对应模块id*/
@Excel(name = "对应模块id", width = 15) @Excel(name = "对应模块id", width = 15)
@ApiModelProperty(value = "对应模块id") @ApiModelProperty(value = "对应模块id")
@Dict(dicText = "module_code",dicCode = "id",dictTable = "modulex") @Dict(dicCode = "id",dicText = "module_code",dictTable = "modulex")
private java.lang.String moduleId; private java.lang.String moduleId;
/**对应功能id*/ /**对应功能id*/
@Excel(name = "对应功能id", width = 15) @Excel(name = "对应功能id", width = 15)
@ApiModelProperty(value = "对应功能id") @ApiModelProperty(value = "对应功能id")
@Dict(dicText = "function_code",dicCode = "id",dictTable = "functionx") @Dict(dicCode = "id",dicText = "function_code",dictTable = "functionx")
private java.lang.String functionId; private java.lang.String functionId;
/**对应规则id*/ /**对应规则id*/
@Excel(name = "对应规则id", width = 15) @Excel(name = "对应规则id", width = 15)
@ApiModelProperty(value = "对应规则id") @ApiModelProperty(value = "对应规则id")
@Dict(dicText = "rule_code",dicCode = "id",dictTable = "rulex") @Dict(dicCode = "id",dicText = "rule_code",dictTable = "rulex")
private java.lang.String ruleId; private java.lang.String ruleId;
/**BUG等级*/ /**BUG等级*/
@Excel(name = "BUG等级", width = 15) @Excel(name = "BUG等级", width = 15)
@ApiModelProperty(value = "BUG等级") @ApiModelProperty(value = "BUG等级")

@ -0,0 +1,143 @@
package org.jeecg.modules.demo.bugx.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.jeecgframework.poi.excel.annotation.ExcelIgnore;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: BUG管理
* @Author: jeecg-boot
* @Date: 2023-04-11
* @Version: V1.0
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="bugx对象", description="BUG管理")
public class BugxExportDto implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@ApiModelProperty(value = "主键")
private java.lang.String id;
/**创建人*/
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private java.util.Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private java.lang.String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private java.util.Date updateTime;
/**BUG编码*/
@Excel(name = "BUG编码", width = 15)
@ApiModelProperty(value = "BUG编码")
private java.lang.String bugCode;
/**BUG类型*/
@ExcelIgnore()
@ApiModelProperty(value = "BUG类型")
@Dict(dicCode = "bug_type")
private java.lang.Integer type;
@TableField(exist = false)
@Excel(name = "BUG类型", width = 15)
private java.lang.String typeName;
/**项目id*/
@Excel(name = "项目", width = 15)
@ApiModelProperty(value = "项目id")
@Dict(dicCode = "id",dicText = "project_code",dictTable = "projectx")
private java.lang.String projectId;
/**对应模块id*/
@Excel(name = "对应模块", width = 15)
@ApiModelProperty(value = "对应模块id")
@Dict(dicCode = "id",dicText = "module_code",dictTable = "modulex")
private java.lang.String moduleId;
/**对应功能id*/
@Excel(name = "对应功能", width = 15)
@ApiModelProperty(value = "对应功能id")
@Dict(dicCode = "id",dicText = "function_code",dictTable = "functionx")
private java.lang.String functionId;
/**对应规则id*/
@ExcelIgnore
@ApiModelProperty(value = "对应规则id")
@Dict(dicCode = "id",dicText = "rule_code",dictTable = "rulex")
private java.lang.String ruleId;
@Excel(name = "对应规则", width = 15)
@TableField(exist = false)
private java.lang.String rulePm_desc;
/**BUG等级*/
@Excel(name = "BUG等级", width = 15)
@ApiModelProperty(value = "BUG等级")
@Dict(dicCode = "work_level")
private java.lang.Integer bugLevel;
/**BUG描述*/
@Excel(name = "BUG描述", width = 15)
@ApiModelProperty(value = "BUG描述")
private java.lang.String pmDesc;
/**BUG图片*/
@Excel(name = "BUG图片", width = 15)
@ApiModelProperty(value = "BUG图片")
private java.lang.String bugPic;
/**发布时间*/
@Excel(name = "发布时间", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "发布时间")
private java.util.Date publishTime;
/**提交内容*/
@Excel(name = "提交内容", width = 15)
@ApiModelProperty(value = "提交内容")
private java.lang.String submitContent;
/**提交图片*/
@Excel(name = "提交图片", width = 15)
@ApiModelProperty(value = "提交图片")
private java.lang.String submitPic;
/**责任人*/
@Excel(name = "责任人", width = 15)
@ApiModelProperty(value = "责任人")
private java.lang.String managerUsers;
/**BUG状态*/
@ExcelIgnore
@ApiModelProperty(value = "BUG状态")
@Dict(dicCode = "bug_status")
private java.lang.Integer bugStatus;
@TableField(exist = false)
@Excel(name = "BUG状态", width = 15)
private java.lang.String bugStatusName;
/**提交时间*/
@Excel(name = "提交时间", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "提交时间")
private java.util.Date submitTime;
/**审核时间*/
@Excel(name = "审核时间", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "审核时间")
private java.util.Date auditTime;
}

@ -1,12 +1,12 @@
package org.jeecg.modules.demo.bugx.mapper; package org.jeecg.modules.demo.bugx.mapper;
import java.util.Date; import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.demo.bugx.entity.Bugx; import org.jeecg.modules.demo.bugx.entity.Bugx;
import org.jeecg.modules.demo.bugx.entity.BugxExportDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/** /**

@ -2,6 +2,7 @@ package org.jeecg.modules.demo.bugx.service;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.demo.bugx.entity.Bugx; import org.jeecg.modules.demo.bugx.entity.Bugx;
import org.jeecg.modules.demo.bugx.entity.BugxExportDto;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
/** /**

@ -2,6 +2,7 @@ package org.jeecg.modules.demo.bugx.service.impl;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.demo.bugx.entity.Bugx; import org.jeecg.modules.demo.bugx.entity.Bugx;
import org.jeecg.modules.demo.bugx.entity.BugxExportDto;
import org.jeecg.modules.demo.bugx.mapper.BugxMapper; import org.jeecg.modules.demo.bugx.mapper.BugxMapper;
import org.jeecg.modules.demo.bugx.service.IBugxService; import org.jeecg.modules.demo.bugx.service.IBugxService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

Loading…
Cancel
Save