文件下载关闭流;干预列表取note优化

This commit is contained in:
cjw 2024-06-11 11:17:42 +08:00
parent bdc87a6880
commit b222b1dfec
8 changed files with 26 additions and 24 deletions

View File

@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.*;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
/** /**
@ -57,7 +56,7 @@ public class EvaluationRecordController extends BaseController {
@SaCheckPermission("evaluation:record:export") @SaCheckPermission("evaluation:record:export")
@Log(title = "个人量测记录", businessType = BusinessType.EXPORT) @Log(title = "个人量测记录", businessType = BusinessType.EXPORT)
@PostMapping("/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); String filePath = sysEvaluationRecordService.getWordTemplate(bo);
File pdf = FileUtil.createTempFile(".pdf", true); File pdf = FileUtil.createTempFile(".pdf", true);
String pdfPath = pdf.getPath(); String pdfPath = pdf.getPath();

View File

@ -42,7 +42,7 @@ public class InterveneRecordController extends BaseController {
* *
* @param userId 主键 * @param userId 主键
*/ */
@SaCheckPermission("intervene:record:pageList") //@SaCheckPermission("intervene:record:pageList")
@GetMapping("/pageList") @GetMapping("/pageList")
public TableDataInfo<SysInterveneRecordVo> list(@NotNull(message = "用户id不能为空") Long userId, PageQuery pageQuery) { public TableDataInfo<SysInterveneRecordVo> list(@NotNull(message = "用户id不能为空") Long userId, PageQuery pageQuery) {
return interveneRecordService.queryPageList(userId, pageQuery); return interveneRecordService.queryPageList(userId, pageQuery);

View File

@ -135,7 +135,7 @@ public class ScalePublishController extends BaseController {
@SaCheckPermission("scale:publish:export") @SaCheckPermission("scale:publish:export")
@Log(title = "场次量测记录", businessType = BusinessType.EXPORT) @Log(title = "场次量测记录", businessType = BusinessType.EXPORT)
@PostMapping("/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); String filePath = sysScalePublishService.getWordTemplate(bo);
File pdf = FileUtil.createTempFile(".pdf", true); File pdf = FileUtil.createTempFile(".pdf", true);
String pdfPath = pdf.getPath(); String pdfPath = pdf.getPath();

View File

@ -6,7 +6,6 @@ import org.dromara.scale.domain.bo.BaseQueryBo;
import org.dromara.scale.domain.bo.SysEvaluationRecordBo; import org.dromara.scale.domain.bo.SysEvaluationRecordBo;
import org.dromara.scale.domain.vo.SysEvaluationRecordVo; import org.dromara.scale.domain.vo.SysEvaluationRecordVo;
import java.io.IOException;
import java.util.List; import java.util.List;
/** /**
@ -33,7 +32,7 @@ public interface ISysEvaluationRecordService {
List<SysEvaluationRecordVo> queryList(SysEvaluationRecordBo bo); List<SysEvaluationRecordVo> queryList(SysEvaluationRecordBo bo);
String getWordTemplate(BaseQueryBo bo) throws IOException; String getWordTemplate(BaseQueryBo bo) throws Exception;

View File

@ -7,7 +7,6 @@ import org.dromara.scale.domain.bo.SysScalePublishBo;
import org.dromara.scale.domain.vo.EvaluationVo; import org.dromara.scale.domain.vo.EvaluationVo;
import org.dromara.scale.domain.vo.SysScalePublishVo; import org.dromara.scale.domain.vo.SysScalePublishVo;
import java.io.IOException;
import java.util.List; import java.util.List;
/** /**
@ -51,7 +50,7 @@ public interface ISysScalePublishService {
List<EvaluationVo> queryUndoneExportList(BaseQueryBo query); List<EvaluationVo> queryUndoneExportList(BaseQueryBo query);
String getWordTemplate(BaseQueryBo bo) throws IOException; String getWordTemplate(BaseQueryBo bo) throws Exception;
int checkWord(BaseQueryBo bo); int checkWord(BaseQueryBo bo);

View File

@ -34,7 +34,7 @@ import org.dromara.system.service.ISysConfigService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.FileInputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.rmi.ServerException; import java.rmi.ServerException;
import java.util.ArrayList; import java.util.ArrayList;
@ -100,7 +100,7 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
} }
@Override @Override
public String getWordTemplate(BaseQueryBo bo) throws IOException { public String getWordTemplate(BaseQueryBo bo) throws Exception {
Long userId = bo.getUserId(); Long userId = bo.getUserId();
if (userId == null) { if (userId == null) {
throw new ServerException("用户ID不能为空"); throw new ServerException("用户ID不能为空");
@ -216,13 +216,18 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
} }
wordData.setPropose(stringBuilder.toString()); wordData.setPropose(stringBuilder.toString());
File path = new File("/usr/local/mental/word/personalTemplate.docx"); 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); File docx = FileUtil.createTempFile(".docx", true);
String wordPath = docx.getPath(); String wordPath = docx.getPath();
template.writeToFile(wordPath); 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; return wordPath;
} }
} }

View File

@ -27,7 +27,6 @@ import org.dromara.system.mapper.SysUserMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -66,7 +65,7 @@ public class SysInterveneRecordServiceImpl implements ISysInterveneRecordService
SysScalePublish sysScalePublish = publishMapper.selectById(record.getBatchNo()); SysScalePublish sysScalePublish = publishMapper.selectById(record.getBatchNo());
record.setSessionName(sysScalePublish.getSessionName()); record.setSessionName(sysScalePublish.getSessionName());
SysWarnRecord warn = warnMapper.selectOne(new LambdaQueryWrapper<SysWarnRecord>() SysWarnRecord warn = warnMapper.selectOne(new LambdaQueryWrapper<SysWarnRecord>()
.select(SysWarnRecord::getNote) //.select(SysWarnRecord::getNote)
.eq(SysWarnRecord::getBatchNo, record.getBatchNo()) .eq(SysWarnRecord::getBatchNo, record.getBatchNo())
.eq(SysWarnRecord::getUserId, record.getUserId())); .eq(SysWarnRecord::getUserId, record.getUserId()));
record.setNote(warn.getNote()); record.setNote(warn.getNote());
@ -123,7 +122,7 @@ public class SysInterveneRecordServiceImpl implements ISysInterveneRecordService
throw new ServiceException("此用户状态为无需干预,无法提交干预记录"); throw new ServiceException("此用户状态为无需干预,无法提交干预记录");
} }
SysInterveneRecord add = MapstructUtils.convert(bo, SysInterveneRecord.class); SysInterveneRecord add = MapstructUtils.convert(bo, SysInterveneRecord.class);
add.setCreateTime(new Date()); //add.setCreateTime(new Date());
add.setCounselorId(loginUser.getUserId()); add.setCounselorId(loginUser.getUserId());
validEntityBeforeSave(add); validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0; boolean flag = baseMapper.insert(add) > 0;

View File

@ -42,7 +42,7 @@ import org.dromara.system.service.ISysConfigService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.FileInputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.rmi.ServerException; import java.rmi.ServerException;
@ -314,7 +314,7 @@ public class SysScalePublishServiceImpl implements ISysScalePublishService {
} }
@Override @Override
public String getWordTemplate(BaseQueryBo bo) throws IOException { public String getWordTemplate(BaseQueryBo bo) throws Exception {
Long batchNo = bo.getBatchNo(); Long batchNo = bo.getBatchNo();
if (batchNo == null) { if (batchNo == null) {
throw new ServerException("场次Id不能为空"); throw new ServerException("场次Id不能为空");
@ -450,13 +450,14 @@ public class SysScalePublishServiceImpl implements ISysScalePublishService {
} }
wordData.setWarnCharts(wordWarnList); wordData.setWarnCharts(wordWarnList);
File path = new File("/usr/local/mental/word/groupTemplate.docx"); 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); File docx = FileUtil.createTempFile(".docx", true);
String wordPath = docx.getPath(); String wordPath = docx.getPath();
template.writeToFile(wordPath); 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; return wordPath;
} }