|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.supervision.police.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
@ -9,6 +10,7 @@ import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.alibaba.druid.sql.ast.SQLStatement;
|
|
|
|
|
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.deepoove.poi.XWPFTemplate;
|
|
|
|
|
import com.supervision.common.domain.R;
|
|
|
|
|
import com.supervision.common.utils.StringUtils;
|
|
|
|
|
import com.supervision.neo4j.dto.ResultDTO;
|
|
|
|
@ -26,13 +28,21 @@ import com.supervision.police.service.CaseStatusManageService;
|
|
|
|
|
import com.supervision.police.service.ModelIndexService;
|
|
|
|
|
import com.supervision.police.service.ModelService;
|
|
|
|
|
import com.supervision.utils.SqlParserUtil;
|
|
|
|
|
import jakarta.servlet.ServletOutputStream;
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.neo4j.driver.Driver;
|
|
|
|
|
import org.neo4j.driver.Result;
|
|
|
|
|
import org.neo4j.driver.Session;
|
|
|
|
|
import org.springframework.core.io.Resource;
|
|
|
|
|
import org.springframework.core.io.ResourceLoader;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@ -40,6 +50,8 @@ import java.util.*;
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class ModelServiceImpl implements ModelService {
|
|
|
|
|
|
|
|
|
|
private final ResourceLoader resourceLoader;
|
|
|
|
|
|
|
|
|
|
private final Driver driver;
|
|
|
|
|
|
|
|
|
|
private final ModelCaseMapper modelCaseMapper;
|
|
|
|
@ -172,6 +184,33 @@ public class ModelServiceImpl implements ModelService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void exportCaseScoreDetail(String caseId, HttpServletResponse response) {
|
|
|
|
|
CaseScoreDetailDTO caseScoreDetailDTO = caseScoreDetail(caseId);
|
|
|
|
|
caseScoreDetailDTO.buildDesc();
|
|
|
|
|
|
|
|
|
|
// 加载模板
|
|
|
|
|
Resource resource = resourceLoader.getResource("classpath:template/case_detail.docx");
|
|
|
|
|
InputStream inputStream = null;
|
|
|
|
|
try {
|
|
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(caseScoreDetailDTO.getCaseName()+".docx", StandardCharsets.UTF_8));
|
|
|
|
|
inputStream = resource.getInputStream();
|
|
|
|
|
XWPFTemplate template = XWPFTemplate.compile(inputStream).render(caseScoreDetailDTO);
|
|
|
|
|
template.writeAndClose(response.getOutputStream());
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}finally {
|
|
|
|
|
if (inputStream != null){
|
|
|
|
|
try {
|
|
|
|
|
inputStream.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
log.error("exportCaseScoreDetail: inputStream.close() error", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 最终计算得分
|
|
|
|
|
*/
|
|
|
|
|