文件下载关闭流;干预列表取note优化
This commit is contained in:
parent
bdc87a6880
commit
b222b1dfec
|
@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
|
@ -57,7 +56,7 @@ public class EvaluationRecordController extends BaseController {
|
|||
@SaCheckPermission("evaluation:record:export")
|
||||
@Log(title = "个人量测记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(BaseQueryBo bo, HttpServletResponse response) throws IOException {
|
||||
public void export(BaseQueryBo bo, HttpServletResponse response) throws Exception {
|
||||
String filePath = sysEvaluationRecordService.getWordTemplate(bo);
|
||||
File pdf = FileUtil.createTempFile(".pdf", true);
|
||||
String pdfPath = pdf.getPath();
|
||||
|
|
|
@ -42,7 +42,7 @@ public class InterveneRecordController extends BaseController {
|
|||
*
|
||||
* @param userId 主键
|
||||
*/
|
||||
@SaCheckPermission("intervene:record:pageList")
|
||||
//@SaCheckPermission("intervene:record:pageList")
|
||||
@GetMapping("/pageList")
|
||||
public TableDataInfo<SysInterveneRecordVo> list(@NotNull(message = "用户id不能为空") Long userId, PageQuery pageQuery) {
|
||||
return interveneRecordService.queryPageList(userId, pageQuery);
|
||||
|
|
|
@ -135,7 +135,7 @@ public class ScalePublishController extends BaseController {
|
|||
@SaCheckPermission("scale:publish:export")
|
||||
@Log(title = "场次量测记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(BaseQueryBo bo, HttpServletResponse response) throws IOException {
|
||||
public void export(BaseQueryBo bo, HttpServletResponse response) throws Exception {
|
||||
String filePath = sysScalePublishService.getWordTemplate(bo);
|
||||
File pdf = FileUtil.createTempFile(".pdf", true);
|
||||
String pdfPath = pdf.getPath();
|
||||
|
|
|
@ -6,7 +6,6 @@ import org.dromara.scale.domain.bo.BaseQueryBo;
|
|||
import org.dromara.scale.domain.bo.SysEvaluationRecordBo;
|
||||
import org.dromara.scale.domain.vo.SysEvaluationRecordVo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -33,7 +32,7 @@ public interface ISysEvaluationRecordService {
|
|||
List<SysEvaluationRecordVo> queryList(SysEvaluationRecordBo bo);
|
||||
|
||||
|
||||
String getWordTemplate(BaseQueryBo bo) throws IOException;
|
||||
String getWordTemplate(BaseQueryBo bo) throws Exception;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.dromara.scale.domain.bo.SysScalePublishBo;
|
|||
import org.dromara.scale.domain.vo.EvaluationVo;
|
||||
import org.dromara.scale.domain.vo.SysScalePublishVo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -51,7 +50,7 @@ public interface ISysScalePublishService {
|
|||
|
||||
List<EvaluationVo> queryUndoneExportList(BaseQueryBo query);
|
||||
|
||||
String getWordTemplate(BaseQueryBo bo) throws IOException;
|
||||
String getWordTemplate(BaseQueryBo bo) throws Exception;
|
||||
|
||||
int checkWord(BaseQueryBo bo);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.dromara.system.service.ISysConfigService;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.FileInputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.rmi.ServerException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -100,7 +100,7 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getWordTemplate(BaseQueryBo bo) throws IOException {
|
||||
public String getWordTemplate(BaseQueryBo bo) throws Exception {
|
||||
Long userId = bo.getUserId();
|
||||
if (userId == null) {
|
||||
throw new ServerException("用户ID不能为空");
|
||||
|
@ -216,13 +216,18 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
|
|||
}
|
||||
wordData.setPropose(stringBuilder.toString());
|
||||
File path = new File("/usr/local/mental/word/personalTemplate.docx");
|
||||
Configure config = Configure.builder()
|
||||
.bind("factors", new LoopRowTableRenderPolicy()).useSpringEL().build();
|
||||
XWPFTemplate template = XWPFTemplate.compile(path, config).render(wordData);
|
||||
|
||||
File docx = FileUtil.createTempFile(".docx", true);
|
||||
String wordPath = docx.getPath();
|
||||
try (FileInputStream fileInputStream = new FileInputStream(path)) {
|
||||
Configure config = Configure.builder()
|
||||
.bind("warnCharts", new LoopRowTableRenderPolicy()).useSpringEL().build();
|
||||
XWPFTemplate template = XWPFTemplate.compile(fileInputStream, config).render(wordData);
|
||||
template.writeToFile(wordPath);
|
||||
}
|
||||
Configure config = Configure.builder()
|
||||
.bind("factors", new LoopRowTableRenderPolicy()).useSpringEL().build();
|
||||
XWPFTemplate template = XWPFTemplate.compile(path, config).render(wordData);
|
||||
return wordPath;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.dromara.system.mapper.SysUserMapper;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -66,7 +65,7 @@ public class SysInterveneRecordServiceImpl implements ISysInterveneRecordService
|
|||
SysScalePublish sysScalePublish = publishMapper.selectById(record.getBatchNo());
|
||||
record.setSessionName(sysScalePublish.getSessionName());
|
||||
SysWarnRecord warn = warnMapper.selectOne(new LambdaQueryWrapper<SysWarnRecord>()
|
||||
.select(SysWarnRecord::getNote)
|
||||
//.select(SysWarnRecord::getNote)
|
||||
.eq(SysWarnRecord::getBatchNo, record.getBatchNo())
|
||||
.eq(SysWarnRecord::getUserId, record.getUserId()));
|
||||
record.setNote(warn.getNote());
|
||||
|
@ -123,7 +122,7 @@ public class SysInterveneRecordServiceImpl implements ISysInterveneRecordService
|
|||
throw new ServiceException("此用户状态为无需干预,无法提交干预记录");
|
||||
}
|
||||
SysInterveneRecord add = MapstructUtils.convert(bo, SysInterveneRecord.class);
|
||||
add.setCreateTime(new Date());
|
||||
//add.setCreateTime(new Date());
|
||||
add.setCounselorId(loginUser.getUserId());
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
|
|
|
@ -42,7 +42,7 @@ import org.dromara.system.service.ISysConfigService;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.FileInputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.rmi.ServerException;
|
||||
|
@ -314,7 +314,7 @@ public class SysScalePublishServiceImpl implements ISysScalePublishService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getWordTemplate(BaseQueryBo bo) throws IOException {
|
||||
public String getWordTemplate(BaseQueryBo bo) throws Exception {
|
||||
Long batchNo = bo.getBatchNo();
|
||||
if (batchNo == null) {
|
||||
throw new ServerException("场次Id不能为空");
|
||||
|
@ -450,13 +450,14 @@ public class SysScalePublishServiceImpl implements ISysScalePublishService {
|
|||
}
|
||||
wordData.setWarnCharts(wordWarnList);
|
||||
File path = new File("/usr/local/mental/word/groupTemplate.docx");
|
||||
Configure config = Configure.builder()
|
||||
.bind("warnCharts", new LoopRowTableRenderPolicy()).useSpringEL().build();
|
||||
XWPFTemplate template = XWPFTemplate.compile(path, config).render(wordData);
|
||||
|
||||
File docx = FileUtil.createTempFile(".docx", true);
|
||||
String wordPath = docx.getPath();
|
||||
try (FileInputStream fileInputStream = new FileInputStream(path)) {
|
||||
Configure config = Configure.builder()
|
||||
.bind("warnCharts", new LoopRowTableRenderPolicy()).useSpringEL().build();
|
||||
XWPFTemplate template = XWPFTemplate.compile(fileInputStream, config).render(wordData);
|
||||
template.writeToFile(wordPath);
|
||||
}
|
||||
return wordPath;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue