|
@@ -4,15 +4,16 @@ import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
+import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.tofly.pms.fegin.DictItemClient;
|
|
|
import com.tofly.pms.fegin.UserClient;
|
|
|
import com.tofly.pms.fegin.vo.UserVo;
|
|
|
-import com.tofly.pms.testmanage.entity.BugInfo;
|
|
|
-import com.tofly.pms.testmanage.entity.BugLog;
|
|
|
-import com.tofly.pms.testmanage.entity.StatisticsBug;
|
|
|
+import com.tofly.pms.testmanage.entity.*;
|
|
|
import com.tofly.pms.testmanage.mapper.BugInfoMapper;
|
|
|
import com.tofly.pms.testmanage.service.BugInfoService;
|
|
|
import com.tofly.pms.testmanage.service.BugLogService;
|
|
@@ -26,6 +27,9 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
@@ -45,6 +49,8 @@ public class BugInfoServiceImpl extends ServiceImpl<BugInfoMapper, BugInfo>
|
|
|
private BugLogService bugLogService;
|
|
|
@Resource
|
|
|
private EditorlogService editorlogService;
|
|
|
+ @Resource
|
|
|
+ HttpServletResponse response;
|
|
|
|
|
|
@Override
|
|
|
public BugInfo queryById(Integer id) {
|
|
@@ -71,7 +77,7 @@ public class BugInfoServiceImpl extends ServiceImpl<BugInfoMapper, BugInfo>
|
|
|
bugInfo.setDescription(null);
|
|
|
LambdaQueryWrapper<BugInfo> wrapper = Wrappers
|
|
|
.lambdaQuery(bugInfo)
|
|
|
- .eq(BugInfo::getDeleted,0)
|
|
|
+ .eq(BugInfo::getDeleted, 0)
|
|
|
.like(BugInfo::getHeadId, tokenUserID)
|
|
|
.eq(com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(severity), BugInfo::getSeverity, severity)
|
|
|
.eq(com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(urgency), BugInfo::getUrgency, urgency)
|
|
@@ -261,6 +267,44 @@ public class BugInfoServiceImpl extends ServiceImpl<BugInfoMapper, BugInfo>
|
|
|
baseMapper.updateById(bugInfo);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void export(Integer projectId, Integer systemId, String headId, String createUser) throws IOException {
|
|
|
+ List<BugInfoExcelModel> data = baseMapper.getExportData(projectId, systemId, headId, createUser);
|
|
|
+ DictItemClient bean = SpringUtil.getBean(DictItemClient.class);
|
|
|
+ UserClient userClient = SpringUtil.getBean(UserClient.class);
|
|
|
+ for (BugInfoExcelModel datum : data) {
|
|
|
+ String status = bean.getDicItemText("RWZT", datum.getStatus());
|
|
|
+ String severity = bean.getDicItemText("YZCD", datum.getSeverity());
|
|
|
+ String urgency = bean.getDicItemText("JJCD", datum.getUrgency());
|
|
|
+ String testType = bean.getDicItemText("CSLX", datum.getTestType());
|
|
|
+ String type = bean.getDicItemText("BUGLX", datum.getType());
|
|
|
+ datum.setStatus(status);
|
|
|
+ datum.setSeverity(severity);
|
|
|
+ datum.setUrgency(urgency);
|
|
|
+ datum.setTestType(testType);
|
|
|
+ datum.setType(type);
|
|
|
+ String sureUser = datum.getSureUser();
|
|
|
+ if(StringUtils.isNotBlank(sureUser)){
|
|
|
+ String[] split = sureUser.split(",");
|
|
|
+ sureUser = Arrays.stream(split).filter(StringUtils::isNotBlank)
|
|
|
+ .map(userClient::getUserInfo)
|
|
|
+ .map(UserVo::getRealName)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ datum.setSureUser(sureUser);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+
|
|
|
+ String fileName = URLEncoder.encode("缺陷清单", "UTF-8").replaceAll("\\+", "%20");
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
|
|
+ EasyExcel.write(response.getOutputStream(), BugInfoExcelModel.class)
|
|
|
+ .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
|
|
+ .sheet("缺陷清单").doWrite(data);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean save(BugInfo entity) {
|