Commit 6e44e6cb by xmh

添加导出标注结果功能

1 parent 254f5339
......@@ -117,6 +117,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.10</version>
</dependency>
</dependencies>
<build>
......
package com.viontech.label.platform.controller.web;
import com.alibaba.excel.EasyExcel;
import com.github.pagehelper.PageInfo;
import com.viontech.keliu.util.DateUtil;
import com.viontech.keliu.util.JsonMessageUtil;
import com.viontech.label.platform.mapper.LogMapper;
import com.viontech.label.platform.mapper.PicMapper;
import com.viontech.label.platform.model.Pic;
import com.viontech.label.platform.service.adapter.PicService;
import com.viontech.label.platform.service.main.ReidService;
import com.viontech.label.platform.vo.LogVo;
import com.viontech.label.platform.vo.ReidUploadData;
import org.apache.commons.io.FileUtils;
import org.springframework.http.MediaType;
......@@ -14,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.*;
/**
......@@ -208,4 +213,21 @@ public class ReidController {
file.deleteOnExit();
}
}
@GetMapping("export")
public void exportLabelResult(@RequestParam Long packId, @RequestParam Date start, @RequestParam Date end, HttpServletResponse response) throws IOException {
LogMapper mapper = (LogMapper) reidService.getLogService().getMapper();
List<LogVo> logs = mapper.exportLogByDateAndPack(packId, start, end);
HashSet<String> includeColumn = new HashSet<>();
includeColumn.add("username");
includeColumn.add("personUnid");
includeColumn.add("picNum");
includeColumn.add("finishTime");
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader("Content-Disposition",
"attachment;filename=" + packId + "-" + DateUtil.format("yyyyMMdd", start) + "-" + DateUtil.format("yyyyMMdd", end) + ".xlsx");
EasyExcel.write(response.getOutputStream(), LogVo.class).includeColumnFiledNames(includeColumn).sheet().doWrite(logs);
}
}
......@@ -3,8 +3,12 @@ package com.viontech.label.platform.mapper;
import com.viontech.label.platform.base.BaseMapper;
import com.viontech.label.platform.model.Log;
import com.viontech.label.platform.model.LogExample;
import java.util.List;
import com.viontech.label.platform.vo.LogVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.Date;
import java.util.List;
public interface LogMapper extends BaseMapper {
int countByExample(LogExample example);
......@@ -28,4 +32,9 @@ public interface LogMapper extends BaseMapper {
int updateByPrimaryKeySelective(Log record);
int updateByPrimaryKey(Log record);
@Select("select operate as personUnid,count as picNum,u.name as username,log.create_time as finishTime from " +
"(select person_unid,count(*) from d_pic where pack_id=#{packId} and status=3 group by person_unid) as pic left join " +
"(select * from (select *,row_number() over (partition by operate order by create_time desc) row_id from s_log where operate_type=5 and operate_date between #{start} and #{end} ) t where t.row_id=1 ) as log on pic.person_unid=log.operate left join s_user u on log.operate_user=u.id where operate_user is not null")
List<LogVo> exportLogByDateAndPack(Long packId, Date start, Date end);
}
\ No newline at end of file
package com.viontech.label.platform.service.main;
import cn.dev33.satoken.stp.StpUtil;
import com.alibaba.excel.EasyExcel;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
......@@ -10,6 +11,7 @@ import com.viontech.keliu.websocket.AlgApiClient;
import com.viontech.label.core.constant.Constants;
import com.viontech.label.core.constant.LogOperateType;
import com.viontech.label.core.constant.PicStatus;
import com.viontech.label.platform.mapper.LogMapper;
import com.viontech.label.platform.mapper.PicMapper;
import com.viontech.label.platform.model.*;
import com.viontech.label.platform.service.adapter.LogService;
......@@ -17,6 +19,7 @@ import com.viontech.label.platform.service.adapter.PackService;
import com.viontech.label.platform.service.adapter.PicService;
import com.viontech.label.platform.service.adapter.UserService;
import com.viontech.label.platform.utils.StorageUtils;
import com.viontech.label.platform.vo.LogVo;
import com.viontech.label.platform.vo.PicVo;
import com.viontech.label.platform.vo.ReidUploadData;
import com.viontech.label.platform.websocket.ReidWebsocket;
......@@ -31,6 +34,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
......@@ -574,4 +578,8 @@ public class ReidService {
}
return tempFile;
}
public LogService getLogService() {
return logService;
}
}
package com.viontech.label.platform.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.viontech.label.platform.model.Log;
import com.viontech.label.platform.vobase.LogVoBase;
import java.util.Date;
public class LogVo extends LogVoBase {
@ExcelProperty("账号")
private String username;
@ExcelProperty("文件夹ID")
private String personUnid;
@ExcelProperty("图片数量")
private Integer picNum;
@ExcelProperty("完成标注时间")
private Date finishTime;
public LogVo() {
super();
}
......@@ -12,4 +25,40 @@ public class LogVo extends LogVoBase {
public LogVo(Log log) {
super(log);
}
public String getPersonUnid() {
return personUnid;
}
public LogVo setPersonUnid(String personUnid) {
this.personUnid = personUnid;
return this;
}
public Date getFinishTime() {
return finishTime;
}
public LogVo setFinishTime(Date finishTime) {
this.finishTime = finishTime;
return this;
}
public String getUsername() {
return username;
}
public LogVo setUsername(String username) {
this.username = username;
return this;
}
public Integer getPicNum() {
return picNum;
}
public LogVo setPicNum(Integer picNum) {
this.picNum = picNum;
return this;
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!