Browse Source

单个量表导出

sd
zhizhi wu 4 years ago
parent
commit
edfdd1d4e7
  1. 8
      ht/src/main/java/com/ccsens/ht/api/PatientReportExportController.java
  2. 280
      ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java
  3. 16
      ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java
  4. 9
      ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java
  5. 7
      ht/src/main/java/com/ccsens/ht/service/ImportService.java
  6. 298
      ht/src/main/java/com/ccsens/ht/service/PatientReportService.java
  7. 33
      ht/src/main/java/com/ccsens/ht/service/QuestionService.java
  8. 58
      ht/src/main/java/com/ccsens/ht/uitl/Constant.java
  9. 4
      ht/src/main/resources/application.yml
  10. 57
      ht/src/main/resources/mapper_dao/HtPatientReportDao.xml
  11. 1
      ht/src/main/resources/mapper_dao/HtQuestionDao.xml
  12. 4
      ht/src/main/resources/mapper_dao/HtQuestionOptionDao.xml
  13. 3
      question/src/main/java/com/ccsens/question/service/PatientReportService.java
  14. 23
      util/src/main/java/com/ccsens/util/PdfUtil.java
  15. 2
      util/src/test/java/com/ccsens/util/PdfUtilTest.java

8
ht/src/main/java/com/ccsens/ht/api/PatientReportExportController.java

@ -1,5 +1,6 @@
package com.ccsens.ht.api;
import cn.hutool.core.util.CharsetUtil;
import com.ccsens.ht.bean.dto.PatientReportDto;
import com.ccsens.ht.bean.vo.PatientReportVo;
import com.ccsens.ht.service.IPatientReportService;
@ -7,13 +8,18 @@ import com.ccsens.util.JsonResponse;
import com.ccsens.util.bean.dto.QueryDto;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
/**
* @description:
@ -47,7 +53,7 @@ public class PatientReportExportController {
@ApiImplicitParam(name = "json", value = "导出报告单", required = true)
})
@RequestMapping(value="/export", method = RequestMethod.POST)
public JsonResponse<PatientReportVo.Export> export(@RequestBody @ApiParam @Valid QueryDto<PatientReportDto.ExportCode> param){
public JsonResponse<PatientReportVo.Export> export(@RequestBody @ApiParam @Valid QueryDto<PatientReportDto.ExportCode> param) {
//查询报告单信息
log.info("导出指定报告单:{}", param);
String path = patientReportService.export(param.getParam(), param.getUserId());

280
ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java

@ -129,10 +129,49 @@ public class PatientReportVo {
private String hospital;
public List<PdfUtil.Row> toPdfRow(){
List<PdfUtil.Row> rows = getInitRows();
//第四栏
rows.add(
fillRow(
"临床诊断:" + this.clinicalDiagnosis,
"","")
);
return rows;
}
public List<PdfUtil.Row> toPdfSimpleCodeRow(){
List<PdfUtil.Row> rows = getInitRows();
//第四栏
Date date = new Date();
if (this.reportTime != null && this.reportTime > 0) {
date.setTime(this.reportTime);
}
PdfUtil.Row fourRow = new PdfUtil.Row();
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setContent("临床诊断:" );
cell.setCenter(false);
cell.setColSpan(2);
cell.setBorderLeft(0);
cell.setBorderBottom(0);
fourRow.addCell(cell);
PdfUtil.Cell cell2 = new PdfUtil.Cell();
cell2.setContent("检查日期:" + DateUtil.format(date, "yyyy-MM-dd"));
cell2.setCenter(false);
cell2.setBorderLeft(0);
cell2.setBorderBottom(0);
fourRow.addCell(cell2);
rows.add(fourRow);
return rows;
}
private List<PdfUtil.Row> getInitRows() {
Map<Byte, String> careerMap = new HashMap<>(16);
String careerMsg = "1:农林牧渔水利生产人员 2:教师 3:医务工作者 4:专业技术人员 5:生产、运输设备操作人员及有关人员 6:商业、服务业人员 7:国家机关、事业单位、企业负责人 8:国家机关、事业单位、企业办事人员和有关人员 9:军人 10:媒体、文体类工作人员 11:在校学生 12:未就业 13:家务 14:其他";
String splitStr = " ";
for (String careerOne: careerMsg.split(splitStr)) {
for (String careerOne : careerMsg.split(splitStr)) {
String splitStr2 = ":";
careerMap.put(Byte.parseByte(careerOne.split(splitStr2)[0]), careerOne.split(splitStr2)[1]);
}
@ -161,20 +200,6 @@ public class PatientReportVo {
"床号:" + this.bedNumber,
"病案号:" + this.hospitalNumber)
);
//第四栏
// Date date = null;
// if (this.reportTime > 0) {
// date = new Date();
// date.setTime(this.reportTime);
// }
rows.add(
fillRow(
"临床诊断:" + this.clinicalDiagnosis,
"","")
// "检查日期:" + (date == null ? "" : DateUtil.format(date, "yyyy-MM-dd")))
);
return rows;
}
@ -223,14 +248,75 @@ public class PatientReportVo {
this.subReport.add(score);
}
/**
* 将mmse的多层嵌套转成一层
* @param score 报告
* @param list 转换后的list
*/
public void dealMMSE(ReportScore score, List<ReportScore> list) {
if (CollectionUtil.isEmpty(score.subReport)) {
list.add(score);
} else {
score.subReport.forEach(subScore -> dealMMSE(subScore, list));
}
}
public List<PdfUtil.Row> toRow() {
int colNum = 8;
int headNum = 2;
List<PdfUtil.Row> rows = new ArrayList<>();
if (CollectionUtil.isEmpty(subReport)) {
toRowOnlyTotal(colNum, headNum, rows);
} else {
String mmse = Constant.Ht.Report.MMSE;
String npi = Constant.Ht.Report.NPI;
switch (this.code) {
case Constant.Ht.Report.MMSE:
case Constant.Ht.Report.NPI:
fillMmseOrNpi(headNum, rows, mmse, npi);
break;
case Constant.Ht.Report.MOCA:
fillMoca(rows);
break;
case Constant.Ht.Report.HAMD:
case Constant.Ht.Report.HAMA:
case Constant.Ht.Report.ADL:
toRowOnlyTotal(colNum, headNum, rows);
break;
default:
fillCommon(rows);
break;
}
}
toDescRow(colNum, headNum, rows);
return rows;
}
private void toDescRow(int colNum, int headNum, List<PdfUtil.Row> rows) {
if (StrUtil.isBlank(this.description)) {
return ;
}
PdfUtil.Row descRow = new PdfUtil.Row();
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setColSpan(colNum);
cell.setContent(this.description);
cell.setCenter(false);
cell.setBorderRight(1);
descRow.addCell(cell);
rows.add(descRow);
// MOCA中,视直觉单独展示
fillSzj(colNum, headNum, rows);
}
private void toRowOnlyTotal(int colNum, int headNum, List<PdfUtil.Row> rows) {
PdfUtil.Row row = new PdfUtil.Row();
PdfUtil.Cell cell1 = new PdfUtil.Cell();
cell1.setContent(this.code + (StrUtil.isBlank(this.remark) ? "" : "("+this.remark+")"));
cell1.setContent(this.code + (StrUtil.isBlank(this.remark) ? "" : "(" + this.remark + ")"));
cell1.setColSpan(headNum);
PdfUtil.Cell cell2 = new PdfUtil.Cell();
cell2.setContent(this.score == null ? "" : this.score + (this.totalScore > 0 ? "/" + this.totalScore : ""));
@ -240,32 +326,139 @@ public class PatientReportVo {
row.addCell(cell2);
rows.add(row);
}
public List<PdfUtil.Row> toSingleRow() {
int colNum = Constant.Ht.Report.HAMD.equalsIgnoreCase(code) ? 9 : 8;
int headNum = 2;
List<PdfUtil.Row> rows = new ArrayList<>();
if (CollectionUtil.isEmpty(subReport)) {
toRowOnlyTotal(colNum, headNum, rows);
} else {
String mmse = Constant.Ht.Report.MMSE;
String npi = Constant.Ht.Report.NPI;
if (mmse.equalsIgnoreCase(this.code) || npi.equalsIgnoreCase(this.code)) {
switch (this.code) {
case Constant.Ht.Report.MMSE:
fillMMSE(rows);
break;
case Constant.Ht.Report.NPI:
fillMmseOrNpi(headNum, rows, mmse, npi);
} else {
break;
case Constant.Ht.Report.MOCA:
fillMoca(rows);
break;
default:
fillCommon(rows);
break;
}
}
if (StrUtil.isBlank(this.description)) {
toDescRow(colNum, headNum, rows);
return rows;
}
PdfUtil.Row descRow = new PdfUtil.Row();
private void fillMMSE(List<PdfUtil.Row> rows) {
List<ReportScore> mmseList = new ArrayList<>();
dealMMSE(this, mmseList);
PdfUtil.Row titleRow = new PdfUtil.Row();
PdfUtil.Row scoreRow = new PdfUtil.Row();
for (int i = 0; i < mmseList.size() ; i++) {
if (i == 0) {
PdfUtil.Cell cell = new PdfUtil.Cell("简明心理状况测验(MMSE)");
cell.setRowSpan(4);
titleRow.addCell(cell);
rows.add(titleRow);
rows.add(scoreRow);
} else if (i==7){
titleRow = new PdfUtil.Row();
scoreRow = new PdfUtil.Row();
rows.add(titleRow);
rows.add(scoreRow);
}
ReportScore score = mmseList.get(i);
PdfUtil.Cell titleCell = new PdfUtil.Cell(score.getName());
titleRow.addCell(titleCell);
titleCell.setBorderRight(i == 6 ? 1 : 0);
PdfUtil.Cell scoreCell = new PdfUtil.Cell(score.score == null ? "" : score.score + (score.totalScore > 0 ? "/" + score.totalScore : ""));
scoreCell.setBorderRight(i == 6 ? 1 : 0);
scoreRow.addCell(scoreCell);
if (i == mmseList.size() - 1) {
PdfUtil.Cell titleTotalCell = new PdfUtil.Cell("总分");
titleTotalCell.setColSpan(3);
titleTotalCell.setBorderRight(1);
titleRow.addCell(titleTotalCell);
PdfUtil.Cell scoreTotalCell = new PdfUtil.Cell(this.score == null ? "" : this.score + (this.totalScore > 0 ? "/" + this.totalScore : ""));
scoreTotalCell.setColSpan(3);
scoreTotalCell.setBorderRight(1);
scoreRow.addCell(scoreTotalCell);
}
}
}
/**
* 通用项目得分
* @param rows pdf的内容
*/
private void fillCommon(List<PdfUtil.Row> rows) {
//总列数
int total = Constant.Ht.Report.HAMD.equalsIgnoreCase(code) ? 9 : 8;
// 标题
PdfUtil.Row row = new PdfUtil.Row();
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setColSpan(colNum);
cell.setContent(this.description);
cell.setCenter(false);
cell.setBorderRight(1);
descRow.addCell(cell);
rows.add(descRow);
cell.setContent(this.name + "(" + this.code + ")各项目的因子分和总分");
// MOCA中,视直觉单独展示
fillSzj(colNum, headNum, rows);
cell.setColSpan(total);
cell.setBorderTop(0);
cell.setBorderRight(0);
cell.setBorderLeft(0);
row.addCell(cell);
rows.add(row);
return rows;
// 默认两行
PdfUtil.Row row1 = new PdfUtil.Row();
PdfUtil.Row row2 = new PdfUtil.Row();
// 题目
PdfUtil.Cell firstCell1 = new PdfUtil.Cell();
firstCell1.setContent("项目");
row1.addCell(firstCell1);
PdfUtil.Cell firstCell2 = new PdfUtil.Cell();
firstCell2.setContent("计分");
row2.addCell(firstCell2);
// 子类型
int colspan = (total - 1) / (this.subReport.size() + 1);
int lastSpan = total - 1 - colspan * this.subReport.size();
this.subReport.forEach(score -> {
PdfUtil.Cell cell1 = new PdfUtil.Cell();
PdfUtil.Cell cell2 = new PdfUtil.Cell();
cell1.setContent(score.name);
cell1.setColSpan(colspan);
cell2.setContent(score.score == null ? "" : score.score + (score.totalScore > 0 ? "/" + score.totalScore : ""));
cell2.setColSpan(colspan);
row1.addCell(cell1);
row2.addCell(cell2);
});
// 总分
PdfUtil.Cell lastCell1 = new PdfUtil.Cell();
lastCell1.setContent("总分");
lastCell1.setColSpan(lastSpan);
lastCell1.setBorderRight(1);
row1.addCell(lastCell1);
PdfUtil.Cell lastCell2 = new PdfUtil.Cell();
lastCell2.setContent(this.score == null ? "" : this.score + (this.totalScore > 0 ? "/" + this.totalScore : ""));
lastCell2.setColSpan(lastSpan);
lastCell2.setBorderRight(1);
row2.addCell(lastCell2);
rows.add(row1);
rows.add(row2);
}
private void fillMmseOrNpi(int headNum, List<PdfUtil.Row> rows, String mmse, String npi) {
@ -397,8 +590,8 @@ public class PatientReportVo {
//名称
PdfUtil.Cell cell1 = new PdfUtil.Cell();
cell1.setContent(name);
cell1.setBorderTop(isTop? 1 : 0);
cell1.setBorderRight(isRight? 1 : 0);
cell1.setBorderTop(isTop? 1 : null);
cell1.setBorderRight(isRight? 1 : null);
cell1.setColSpan(colspan == null || colspan.length == 0 ? 1 : colspan[0]);
row1.addCell(cell1);
@ -406,7 +599,7 @@ public class PatientReportVo {
PdfUtil.Cell cell2 = new PdfUtil.Cell();
cell2.setContent(score);
cell2.setColSpan(colspan == null || colspan.length <= 1 ? 1 : colspan[1]);
cell2.setBorderRight(isRight? 1 : 0);
cell2.setBorderRight(isRight? 1 : null);
row2.addCell(cell2);
}
}
@ -519,4 +712,27 @@ public class PatientReportVo {
@ApiModelProperty("图片路径")
private String imgPath;
}
@Data
@ApiModel("导出试题")
public static class QuestionAndAnswer{
private Long id;
@ApiModelProperty("排序")
private int sort;
@ApiModelProperty("试题")
private String question;
@ApiModelProperty("选项")
private List<Option> optionList;
}
@ApiModel("导出选项")
@Data
public static class Option{
private Long id;
@ApiModelProperty("选项内容")
private String name;
@ApiModelProperty("选中状态 0:未选中 1:选中")
private byte chooseStatus;
@ApiModelProperty("答案")
private String answer;
}
}

16
ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java

@ -105,4 +105,20 @@ public interface HtPatientReportDao extends HtPatientReportMapper {
* @return 报告单
*/
List<PatientReportSearchVo.Search> search(@Param("codes") List<PatientReportSearchDto.Search> codes);
/**
* 根据病人报告单ID查询报告单各项相关分数
* @param id 报告单ID
* @param code 量表类型
* @return
*/
List<PatientReportVo.ReportScore> queryReportScore2(@Param("id") Long id, @Param("code") String code);
/**
* 查询evaluate_code = code的所有试题选项及答案
* @param id 报告单ID
* @param code code
* @return 题目
*/
List<PatientReportVo.QuestionAndAnswer> queryQuestionAndScore(@Param("id") Long id, @Param("code") String code);
}

9
ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java

@ -8,6 +8,7 @@ import com.ccsens.ht.bean.vo.PatientReportVo;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.JsonResponse;
import com.github.pagehelper.PageInfo;
import org.apache.poi.ss.usermodel.Workbook;
import java.io.IOException;
import java.util.List;
@ -157,4 +158,12 @@ public interface IPatientReportService {
* @return 报告单
*/
PageInfo<PatientReportSearchVo.Search> search(PatientReportSearchDto.SearchList param);
/**
* 导出指定报告单
* @param param 指定报告单类型
* @param userId userId
* @return path
*/
String export(PatientReportDto.ExportCode param, Long userId);
}

7
ht/src/main/java/com/ccsens/ht/service/ImportService.java

@ -340,9 +340,9 @@ public class ImportService implements IImportService {
if (CollectionUtil.isNotEmpty(questionList)) {
HtQuestion prev = questionList.get(questionList.size() - 1);
if (prev.getRelationId() != null && prev.getRelationId() >0) {
prev.setRelationId(prev.getRelationId());
relationQuestion.setRelationId(prev.getRelationId());
} else {
prev.setRelationId(prev.getId());
relationQuestion.setRelationId(prev.getId());
}
}
questionList.add(relationQuestion);
@ -413,7 +413,7 @@ public class ImportService implements IImportService {
if (!json.containsKey(Constant.Import.RELATION_OPTION)) {
return record;
}
log.info("追加选项{}", json.getShort(Constant.Import.RELATION_OPTION));
log.info("追加选项{}", json.get(Constant.Import.RELATION_OPTION));
JSONArray options = json.getJSONArray(Constant.Import.RELATION_OPTION);
for (Object obj: options) {
HtQuestionRecordOption recordOption = JSONObject.parseObject(((JSONObject) obj).toJSONString(), HtQuestionRecordOption.class);
@ -522,6 +522,7 @@ public class ImportService implements IImportService {
JSONArray descArr = json.getJSONArray(Constant.Import.OPTION_DESC);
for (Object obj: descArr) {
HtQuestionOptionDesc desc = JSONObject.parseObject(JSON.toJSONString(obj), HtQuestionOptionDesc.class);
desc.setId(snowflake.nextId());
optionDescList.add(desc);
}
}

298
ht/src/main/java/com/ccsens/ht/service/PatientReportService.java

@ -116,7 +116,7 @@ public class PatientReportService implements IPatientReportService {
example.createCriteria().andUserIdEqualTo(userId).andAuditStateEqualTo(Constant.Ht.Doctor.CHECK_SUCCESS);
List<HtDoctor> doctors = htDoctorDao.selectByExample(example);
if (CollectionUtils.isEmpty(doctors)) {
log.info("{}医生信息尚未审核通过");
log.info("{}医生信息尚未审核通过", userId);
return CodeEnum.AUDIT_NOT_PASS;
}
HtDoctor doctor = doctors.get(0);
@ -223,54 +223,25 @@ public class PatientReportService implements IPatientReportService {
//查询报告单信息和病人信息
PatientReportVo.ReprotPatient reportPatient = htPatientReportDao.queryReportResult(queryDetail.getId());
//查询报告单分数
List<PatientReportVo.ReportScore> reportScore = htPatientReportDao.queryReportScore(queryDetail.getId(),queryDetail.getRey(), queryDetail.getReport());
List<PatientReportVo.ReportScore> reportScore = htPatientReportDao.queryReportScore(queryDetail.getId(), queryDetail.getRey(), queryDetail.getReport());
long reportId = queryDetail.getId();
//重新封装报告单信息
Map<String, PatientReportVo.ReportScore> map = new HashMap<>(32);
List<PatientReportVo.ReportScore> scores = new ArrayList<>();
reportScore.forEach(score -> {
if(ObjectUtil.isNotNull(score.getScore())){
if(BigDecimal.valueOf(score.getScore().intValue()).compareTo(score.getScore()) == 0){
score.setScore(score.getScore().setScale(0,BigDecimal.ROUND_HALF_UP));
}
}
map.put(score.getCode(), score);
//测评类(MOCA等)
if (Constant.Ht.Report.TYPE_EVALUATION == score.getType()) {
String specialCode = "NPI";
if (specialCode.equalsIgnoreCase(score.getCode())) {
initNPI(queryDetail, score);
}
scores.add(score);
} else {
log.info("score:{}", score);
map.get(score.getParentCode()).addSub(score);
}
});
scores.forEach(score -> {
if (Constant.Ht.Report.MOCA_SJZ.equalsIgnoreCase(score.getCode())) {
return;
}
sumScore(score);
});
List<PatientReportVo.ReportScore> scores = getReportScores(reportScore, reportId);
detail.setPatient(reportPatient);
detail.setScores(scores);
return detail;
}
private void initNPI(PatientReportDto.QueryDetail queryDetail, PatientReportVo.ReportScore score) {
List<Map<String, Object>> list = htPatientReportDao.queryNPIScore(queryDetail.getId());
private void initNPI(long id, PatientReportVo.ReportScore score) {
List<Map<String, Object>> list = htPatientReportDao.queryNPIScore(id);
Map<String,Object> npiScore = new HashMap<>();
list.forEach(map -> {
npiScore.put((String)map.get("optionName"), map.get("score"));
});
list.forEach(map -> npiScore.put((String)map.get("optionName"), map.get("score")));
PatientReportVo.ReportScore carer = new PatientReportVo.ReportScore();
carer.setCode("carer");
carer.setName("照顾者");
carer.setTotalScore(-1);
carer.setScore(npiScore == null || npiScore.get("carer") == null ? null : ((BigDecimal)npiScore.get("carer")));
carer.setScore(npiScore.get("carer") == null ? null : ((BigDecimal)npiScore.get("carer")));
if(ObjectUtil.isNotNull(carer.getScore())){
carer.setScore(carer.getScore().setScale(0,BigDecimal.ROUND_HALF_UP));
}
@ -281,7 +252,7 @@ public class PatientReportService implements IPatientReportService {
patient.setCode("result");
patient.setName("患者");
patient.setTotalScore(-1);
patient.setScore(npiScore == null || npiScore.get("result") == null ? null : ((BigDecimal) npiScore.get("result")));
patient.setScore(npiScore.get("result") == null ? null : ((BigDecimal) npiScore.get("result")));
if(ObjectUtil.isNotNull(patient.getScore())){
patient.setScore(patient.getScore().setScale(0,BigDecimal.ROUND_HALF_UP));
}
@ -331,17 +302,15 @@ public class PatientReportService implements IPatientReportService {
/**
* 为上级求和
* @param score
*@return: java.lang.Integer
*@Author: wuHuiJuan
* @param score 分数
*@author wuHuiJuan
*@date: 2019/11/19 15:42
*/
private BigDecimal sumScore(PatientReportVo.ReportScore score){
AtomicReference<BigDecimal> sum = new AtomicReference<>(score.getScore() == null ? BigDecimal.valueOf(0) : score.getScore());
AtomicBoolean hasAdd = new AtomicBoolean(false);
if (!CollectionUtils.isEmpty(score.getSubReport())) {
score.getSubReport().forEach(sub -> {
sum.updateAndGet(v -> {
score.getSubReport().forEach(sub -> sum.updateAndGet(v -> {
BigDecimal sumScore = sumScore(sub);
if (sumScore== null) {
return v;
@ -350,8 +319,7 @@ public class PatientReportService implements IPatientReportService {
// return v += sumScore;
v = v.add(sumScore);
return v;
});
});
}));
} else {
if (StringUtil.isNotEmpty(score.getRemark()) && score.getRemark().matches(Constant.Ht.Report.IGNORE_SCORE)) {
return score.getScore() == null ? null : BigDecimal.valueOf(0);
@ -387,9 +355,7 @@ public class PatientReportService implements IPatientReportService {
throw new BaseException(CodeEnum.REPORT_NOT_FOUND);
}
List<PdfUtil.Row> content = new ArrayList<>();
detail.getScores().forEach(reportScore -> {
content.addAll(reportScore.toRow());
});
detail.getScores().forEach(reportScore -> content.addAll(reportScore.toRow()));
PdfUtil.Row row = new PdfUtil.Row();
PdfUtil.Cell initWordCell = addCell(row, "初步印象", 2, 2);
initWordCell.setHeight(PdfUtil.Cell.defaultHeight * 2);
@ -398,16 +364,9 @@ public class PatientReportService implements IPatientReportService {
initImplCell.setBorderRight(1);
initImplCell.setCenter(false);
content.add(row);
PdfUtil.Row row2 = new PdfUtil.Row();
PdfUtil.Cell doctorCell = addCell(row2, "测评员:", 4, 1, 0);
doctorCell.setBorderBottom(null);
doctorCell.setBorderLeft(null);
PdfUtil.Cell dateCell = addCell(row2, "报告日期:", 4, 1, 0);
dateCell.setBorderBottom(null);
dateCell.setBorderLeft(null);
content.add(row2);
initLast(content, 8);
String path = PropUtil.imgDomain + "/" + PdfUtil.credatePdf(PropUtil.path, detail.getPatient().getHospital(), Constant.Ht.Report.PARENT_NAME, detail.getPatient().toPdfRow(), content, new PdfUtil.Margin());
String path = PropUtil.imgDomain + "/" + PdfUtil.createPdf(PropUtil.path, detail.getPatient().getHospital(), Constant.Ht.Report.PARENT_NAME, new PdfUtil.Margin(), detail.getPatient().toPdfRow(), content);
report.setUrl(path);
htPatientReportDao.updateByPrimaryKeySelective(report);
log.info("生成文件路径:{}", path);
@ -431,8 +390,7 @@ public class PatientReportService implements IPatientReportService {
@Override
public PatientReportVo.Complete checkComplete(Long userId) {
PatientReportVo.Complete complete = htPatientReportDao.checkComplete(userId);
return complete;
return htPatientReportDao.checkComplete(userId);
}
@Override
@ -491,9 +449,7 @@ public class PatientReportService implements IPatientReportService {
log.info("未查询到报告单");
return new PageInfo<>(reports);
}
reports.forEach(report -> {
report.setAuthority((byte)1);
});
reports.forEach(report -> report.setAuthority((byte)1));
return new PageInfo<>(reports);
}
@ -531,7 +487,7 @@ public class PatientReportService implements IPatientReportService {
}
byte prevAge = ages.get(ages.size() - 1);
PatientReportVo.AgeAndSexGroup prevGroup = groups.get(groups.size()-1);
byte nowAge = ageAndSex.getAgeLevel().byteValue();
byte nowAge = ageAndSex.getAgeLevel();
if (prevAge == nowAge) {
fillBySex(ageAndSex, prevGroup);
} else {
@ -564,8 +520,7 @@ public class PatientReportService implements IPatientReportService {
private void fillBySex(PatientReportVo.AgeAndSex ageAndSex, PatientReportVo.AgeAndSexGroup group) {
if (ageAndSex.getAgeLevel() == null) {
log.info("性别不确定");
return;
} else if (ageAndSex.getSex().byteValue() == Constant.Ht.SEX_MAN) {
} else if (ageAndSex.getSex()== Constant.Ht.SEX_MAN) {
group.setMan(ageAndSex);
} else {
group.setWoman(ageAndSex);
@ -610,5 +565,218 @@ public class PatientReportService implements IPatientReportService {
return new PageInfo<>(list);
}
@Override
public String export(PatientReportDto.ExportCode param, Long userId) {
// 详细试题
List<PdfUtil.Row> questionTable = new ArrayList<>();
if (Constant.Export.TITLE_MAP.containsKey(param.getCode())) {
List<PatientReportVo.QuestionAndAnswer> questionAndAnswerList = htPatientReportDao.queryQuestionAndScore(param.getId(), param.getCode());
// 几列试题
int cols = questionAndAnswerList.size() > 20 ? 2 : 1;
// 题目占几行
int questionSpan = 2;
// 表格头
initQuestionTitle(param.getCode(), cols, questionSpan, questionTable);
// 表格体
int rowNum = cols > 1 ? (questionAndAnswerList.size() + 1)/ 2 : questionAndAnswerList.size();
int optionSize = Constant.Export.TITLE_MAP.get(param.getCode()).optionList.size();
for (int i = 0; i < rowNum; i++) {
PatientReportVo.QuestionAndAnswer question = questionAndAnswerList.get(i);
PdfUtil.Row row = new PdfUtil.Row();
initQuestionBody(questionSpan, question, row, cols == 1, optionSize);
if (cols > 1) {
PatientReportVo.QuestionAndAnswer question2 = null;
if (rowNum + i < questionAndAnswerList.size()) {
question2 = questionAndAnswerList.get(rowNum + i);
}
initQuestionBody(questionSpan, question2, row, true, Constant.Export.TITLE_MAP.get(param.getCode()).optionList.size());
}
questionTable.add(row);
}
if (Constant.Ht.Report.ADL.equals(param.getCode())) {
List<PatientReportVo.ReportScore> reportScores = htPatientReportDao.queryReportScore2(param.getId(),param.getCode());
PdfUtil.Row row = new PdfUtil.Row();
addCell(row, "总分", questionSpan+1, 1);
int scoreSpan = 1+questionSpan + cols * optionSize;
String score = (reportScores.isEmpty() ? "" : reportScores.get(0).getScore() == null ? "" : reportScores.get(0).getScore().intValue()) + (reportScores.get(0).getTotalScore() > 0 ? "/" + reportScores.get(0).getTotalScore() : "");
PdfUtil.Cell scoreCell = addCell(row, score, scoreSpan, 1);
scoreCell.setBorderRight(1);
questionTable.add(row);
PdfUtil.Row tempRow = new PdfUtil.Row();
PdfUtil.Cell cell = addCell(tempRow, "仅供临床医生参考。", scoreSpan + questionSpan + 1, 1);
initLast(questionTable, scoreSpan + questionSpan + 1);
}
}
List<PdfUtil.Row> content = new ArrayList<>();
//查询报告单信息和病人信息
PatientReportVo.ReprotPatient reportPatient = htPatientReportDao.queryReportResult(param.getId());
//查询报告单分数
List<PatientReportVo.ReportScore> reportScores = htPatientReportDao.queryReportScore2(param.getId(),param.getCode());
if (!Constant.Ht.Report.ADL.equals(param.getCode())) {
getReportScores(param, content, reportScores);
}
String subHead = CollectionUtil.isEmpty(reportScores) ? "" : reportScores.get(0).getName() + "(" + reportScores.get(0).getCode() + ")报告单";
PdfUtil.Margin margin = new PdfUtil.Margin();
margin.setTop(12);
margin.setBottom(12);
margin.setLeft(36);
String path = PropUtil.imgDomain + "/" + PdfUtil.createPdf(PropUtil.path, reportPatient.getHospital(), subHead, margin , reportPatient.toPdfSimpleCodeRow(),questionTable, content);
log.info("{}报告单导出路径:{}", param, path);
return path;
}
private List<PatientReportVo.ReportScore> getReportScores(PatientReportDto.ExportCode param, List<PdfUtil.Row> content, List<PatientReportVo.ReportScore> reportScores) {
long reportId = param.getId();
//重新封装报告单信息
List<PatientReportVo.ReportScore> scores = getReportScores(reportScores, reportId);
// 分数汇总
int colNum = Constant.Ht.Report.HAMD.equalsIgnoreCase(param.getCode()) ? 9 : 8;
scores.forEach(reportScore -> content.addAll(reportScore.toSingleRow()));
PdfUtil.Row row = new PdfUtil.Row();
int titleSpan = 2;
PdfUtil.Cell initWordCell = addCell(row, "初步印象", titleSpan, 2);
initWordCell.setHeight(PdfUtil.Cell.defaultHeight * 2);
String initialImpression = "";
PdfUtil.Cell initImplCell = addCell(row, initialImpression, colNum - titleSpan, 2);
initImplCell.setHeight(PdfUtil.Cell.defaultHeight * 2);
initImplCell.setBorderRight(1);
initImplCell.setCenter(false);
content.add(row);
PdfUtil.Row tempRow = new PdfUtil.Row();
PdfUtil.Cell cell = addCell(tempRow, "仅供临床医生参考。", colNum, 1);
initLast(content, colNum);
return scores;
}
private List<PatientReportVo.ReportScore> getReportScores(List<PatientReportVo.ReportScore> reportScores, long reportId) {
Map<String, PatientReportVo.ReportScore> map = new HashMap<>(32);
List<PatientReportVo.ReportScore> scores = new ArrayList<>();
reportScores.forEach(score -> {
if (ObjectUtil.isNotNull(score.getScore())) {
if (BigDecimal.valueOf(score.getScore().intValue()).compareTo(score.getScore()) == 0) {
score.setScore(score.getScore().setScale(0, BigDecimal.ROUND_HALF_UP));
}
}
map.put(score.getCode(), score);
//测评类(MOCA等)
if (Constant.Ht.Report.TYPE_EVALUATION == score.getType()) {
String specialCode = "NPI";
if (specialCode.equalsIgnoreCase(score.getCode())) {
initNPI(reportId, score);
}
scores.add(score);
} else {
log.info("score:{}", score);
map.get(score.getParentCode()).addSub(score);
}
});
scores.forEach(score -> {
if (Constant.Ht.Report.MOCA_SJZ.equalsIgnoreCase(score.getCode())) {
return;
}
sumScore(score);
});
return scores;
}
private void initQuestionBody(int questionSpan, PatientReportVo.QuestionAndAnswer question, PdfUtil.Row row, boolean isLast, int optionSize) {
addCell(row, question == null ? Constant.Ht.STRING_DEFAULT : String.valueOf(question.getSort()), 1, 1);
addCell(row, question == null ? Constant.Ht.STRING_DEFAULT : question.getQuestion(), questionSpan, 1);
if (question == null) {
for (int i = 0; i < optionSize; i++) {
PdfUtil.Cell cell = addCell(row, "", 1, 1);
cell.setBorderRight(isLast && i == optionSize - 1 ? 1 : 0);
}
return ;
}
int size = question.getOptionList().size();
for (int j = 0; j < size ; j++) {
String content = question.getOptionList().get(j).getChooseStatus() == 1 ? "√" : "--";
PdfUtil.Cell cell = addCell(row, content, 1, 1);
cell.setBorderRight(isLast && j == optionSize - 1 ? 1 : 0);
}
if (size >= optionSize) {
return;
}
for (int i = size; i < optionSize; i++) {
PdfUtil.Cell cell = addCell(row, "--", 1, 1);
cell.setBorderRight(isLast && i == optionSize - 1 ? 1 : 0);
}
}
/**
* 表格头
* @param code code
* @param cols 几列题目
* @param questionSpan 题目占几列
* @param questionTable 表格
*/
private void initQuestionTitle(String code, int cols, int questionSpan, List<PdfUtil.Row> questionTable) {
Constant.ReportExportTitle title = Constant.Export.TITLE_MAP.get(code);
// 检查目的
if (StrUtil.isNotBlank(title.checkPurpose)) {
PdfUtil.Row row = new PdfUtil.Row();
PdfUtil.Cell cell = addCell(row, title.checkPurpose, (title.optionList.size() + questionSpan + 1 ) * cols, 1);
cell.setCenter(false);
cell.setBorderRight(1);
questionTable.add(row);
}
// 设置表头
PdfUtil.Row row1 = new PdfUtil.Row();
PdfUtil.Row row2 = new PdfUtil.Row();
for (int i = 0; i < cols ; i++) {
addCell(row1, "序号", 1, 2);
// addCell(row2, "", 1, 1);
if (StrUtil.isBlank(title.projectDesc)) {
addCell(row1, "项目", questionSpan, 2);
// addCell(row2, "", questionSpan, 1);
} else {
addCell(row1, title.projectDesc, questionSpan, 1);
addCell(row2, "项目", questionSpan, 1);
}
// 选项
PdfUtil.Cell optionDescCell = addCell(row1, title.optionDesc, title.optionList.size(), 1);
optionDescCell.setBorderRight(i == cols - 1 ? 1 : 0);
for (int j = 0; j < title.optionList.size() ; j++) {
PdfUtil.Cell optionCell = addCell(row2, title.optionList.get(j), 1, 1);
optionCell.setBorderRight(i == cols - 1 && j == title.optionList.size() - 1 ? 1 : 0);
}
}
questionTable.add(row1);
questionTable.add(row2);
}
private void initLast(List<PdfUtil.Row> content, int totalSpan) {
PdfUtil.Row row2 = new PdfUtil.Row();
PdfUtil.Cell doctorCell = addCell(row2, "测评员:", 4, 1, 0);
doctorCell.setBorderBottom(null);
doctorCell.setBorderLeft(null);
PdfUtil.Cell dateCell = addCell(row2, "报告日期:", totalSpan - 4, 1, 0);
dateCell.setBorderBottom(null);
dateCell.setBorderLeft(null);
content.add(row2);
}
}

33
ht/src/main/java/com/ccsens/ht/service/QuestionService.java

@ -620,12 +620,16 @@ public class QuestionService implements IQuestionService {
this.value = value;
this.line = line;
this.point = point;
this.x = x;
this.y = y;
}
public void change(int value, int line, int point, int x, int y) {
this.value = value;
this.line = line;
this.point = point;
this.x = x;
this.y = y;
}
}
@ -810,6 +814,7 @@ public class QuestionService implements IQuestionService {
question.getOperateType() == Constant.Ht.Operation.PAINT_HALF_IMG;
int centerX = half ? (canvasWidth / 2 + 30) / 2 : canvasWidth / 2;
int centerY = canvasHeight / 2;
log.info("画板中心:{},{}", centerX, centerY);
//计算图形中心
int x = (maxX.value + minX.value) / 2;
@ -831,11 +836,26 @@ public class QuestionService implements IQuestionService {
int radiusSqrt = setFourPoint(canvasPoints, minX, maxX, minY, maxY, x, y);
parameter.setMinCircleAcreage(new BigDecimal(Math.PI * radiusSqrt).setScale(2, BigDecimal.ROUND_HALF_UP));
parameter.setTop(new QuestionVo.Coordinate(minY.x - centerX, minY.y - centerY));
parameter.setBottom(new QuestionVo.Coordinate(maxY.x - centerX, maxY.y - centerY));
parameter.setLeft(new QuestionVo.Coordinate(minX.x - centerX, minX.y - centerY));
parameter.setRight(new QuestionVo.Coordinate(maxX.x - centerX, maxX.y - centerY));
log.info("half:",half);
if (half) {
// x:-y, y:x
parameter.setTop(new QuestionVo.Coordinate(maxY.y - centerY, maxY.x - centerX ));
parameter.setBottom(new QuestionVo.Coordinate(minY.y - centerY, minY.x - centerX));
parameter.setLeft(new QuestionVo.Coordinate(minX.y - centerY, minX.x - centerX));
parameter.setRight(new QuestionVo.Coordinate(maxX.y - centerY, maxX.x - centerX));
} else {
parameter.setTop(new QuestionVo.Coordinate(centerX - maxY.x , maxY.y - centerY));
parameter.setBottom(new QuestionVo.Coordinate(centerX - minY.x, minY.y - centerY));
parameter.setLeft(new QuestionVo.Coordinate(centerX - minX.x , minX.y - centerY));
parameter.setRight(new QuestionVo.Coordinate(centerX - maxX.x , maxX.y - centerY));
}
log.info("上:{},{};{},{}",maxY.x, maxY.y, parameter.getTop().getX(), parameter.getTop().getY());
log.info("下:{},{};{},{}",minY.x, minY.y, parameter.getBottom().getX(), parameter.getBottom().getY());
log.info("左:{},{};{},{}",minX.x, minX.y, parameter.getLeft().getX(), parameter.getLeft().getY());
log.info("右:{},{};{},{}",maxX.x, maxX.y, parameter.getRight().getX(), parameter.getRight().getY());
//平均长度
BigDecimal aveLength = BigDecimal.valueOf(totalLength / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP);
BigDecimal aveReflectOnTime = BigDecimal.valueOf(reflectOnTime / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP);
@ -879,6 +899,7 @@ public class QuestionService implements IQuestionService {
if (pointArr == null || pointArr.length <= 0) {
continue;
}
//1左 2右 3 上 4 下
for (int j = 0; j < pointArr.length; j++) {
String s = pointArr[j];
if (StrUtil.isEmpty(s)) {
@ -889,9 +910,9 @@ public class QuestionService implements IQuestionService {
} else if (i == maxX.line && j == maxX.point) {
pointArr[j] += ",2";
} else if (i == minY.line && j == minY.point) {
pointArr[j] += ",3";
} else if (i == maxY.line && j == maxY.point) {
pointArr[j] += ",4";
} else if (i == maxY.line && j == maxY.point) {
pointArr[j] += ",3";
} else {
pointArr[j] += ",0";
}

58
ht/src/main/java/com/ccsens/ht/uitl/Constant.java

@ -1,5 +1,7 @@
package com.ccsens.ht.uitl;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
@ -37,6 +39,54 @@ public class Constant {
public static final String OPTION_DESC = "desc";
}
public static final class Export{
public final static Map<String, ReportExportTitle> TITLE_MAP = new HashMap<>();
static {
TITLE_MAP.put("HAMA", new ReportExportTitle("检查目的:用于焦虑症的诊断及程度划分的依据。",
"近一周内", "圈出最符合病人情况的分数",
"无(0)","轻度(1)","中度(2)","重度(3)","极重度(4)"));
TITLE_MAP.put("HAMD", new ReportExportTitle("检查目的:临床评定抑郁状态。",
"", "圈出最符合病人情况的分数",
"无(0)","轻度(1)","中度(2)","重度(3)","极重度(4)"));
TITLE_MAP.put("ADL", new ReportExportTitle("检查目的:ADL量表用于评定被测试人日常生活能力(包括躯体功能和使用工具能力)。",
"", "圈出最符合的情况",
"自己可以做(1)","有些困难(2)","需要帮助(3)","根本无法做(4)"));
}
}
public static final class ReportExportTitle{
@ApiModelProperty("检查目的")
public String checkPurpose;
@ApiModelProperty("项目描述")
public String projectDesc;
@ApiModelProperty("选项描述")
public String optionDesc;
@ApiModelProperty("选项描述")
public List<String> optionList = new ArrayList<>();
public ReportExportTitle() {
}
public ReportExportTitle(String checkPurpose, String projectDesc, String optionDesc, String... options) {
this.checkPurpose = checkPurpose;
this.projectDesc = projectDesc;
this.optionDesc = optionDesc;
if (options == null || options.length <= 0) {
return;
}
for (String option: options) {
this.optionList.add(option);
}
}
public List<String> addOption(String option) {
optionList.add(option);
return optionList;
}
}
/**病友画图轨迹颜色*/
public static final class LineColour {
@ -64,6 +114,7 @@ public class Constant {
/**
* 医疗职称相关常量
*/
@ -82,6 +133,7 @@ public class Constant {
/**删除*/
public final static byte IS_DEL = 1;
public final static class QuestionRecord{
public static final byte RECORD_TYPE_CODE = 0;
public static final byte RECORD_TYPE_QUESTION = 1;
@ -174,6 +226,9 @@ public class Constant {
public final static String IGNORE_SCORE = "[个]";
public final static String MOCA_SJZ = "SZJ";
public final static String MOCA = "MoCA";
public final static String HAMD = "HAMD";
public static final String HAMA = "HAMA";
public static final String ADL = "ADL";
public final static String MMSE = "MMSE";
public final static String NPI = "NPI";
public final static String REY = "Rey";
@ -191,6 +246,9 @@ public class Constant {
/**在历史报告单中显示*/
public final static byte SHOW_HISTORY = 1;
public final static Map<String, Byte> TYPE = new HashMap<>();
static {
//1:报告单 2:测评 3:测评子类 4:二级子类
TYPE.put("报告单",(byte)1);

4
ht/src/main/resources/application.yml

@ -1,4 +1,4 @@
spring:
profiles:
active: dev
include: common, util-dev
active: prod
include: common, util-prod

57
ht/src/main/resources/mapper_dao/HtPatientReportDao.xml

@ -37,6 +37,17 @@
<result column="type" jdbcType="TINYINT" property="type"/>
<result column="score" jdbcType="INTEGER" property="score"/>
</resultMap>
<resultMap id="QuestionMap" type="com.ccsens.ht.bean.vo.PatientReportVo$QuestionAndAnswer">
<id column="id" property="id"/>
<result column="question" property="question"/>
<result column="sort" property="sort"/>
<collection property="optionList" ofType="com.ccsens.ht.bean.vo.PatientReportVo$Option">
<id column="optionId" property="id"/>
<result column="name" property="name"/>
<result column="answer" property="answer"/>
<result column="chooseStatus" property="chooseStatus"/>
</collection>
</resultMap>
<select id="queryReportResult" resultMap="BaseResultMap">
select r.*, d.name as doctor_name, p.name as patient_name, p.sex, p.educational_status, p.educational_status_unit, p.career, p.hospital_number, p.patient_number
@ -63,8 +74,9 @@
) t where ischild != '0'
) t1
left join t_ht_question q on t1.code = q.parent_code and q.is_del = 0
left join t_ht_patient_score t2
on t1.code = t2.question_parent_code and
on q.id = t2.question_id and
(
(t2.patient_report_id = #{id, jdbcType=BIGINT} and t2.type in (0,2) and t2.is_del = 0) or t2.id is null
)
@ -263,6 +275,49 @@
</foreach>
</select>
<select id="queryReportScore2" resultMap="ScoreMap">
select t1.code,t1.name, t1.description, t1.total_score, t1.remark,t1.type,t1.parent_code, sum(t2.score) as score
from
(
select code,name, description, total_score, remark, type, parent_code, sort from (
select t1.*, if (find_in_set(t1.parent_code, @pcode) > 0 or t1.code = @pcode, @pcode := concat(@pcode,',',t1.code) ,0 )as ischild
from
(select * from t_ht_report where is_show = 1 and is_del = 0
ORDER BY type, sort) t1 ,
(select @pcode:=#{code} ) t2
) t where ischild != '0'
) t1
left join t_ht_question q on t1.code = q.parent_code and q.is_del = 0
left join t_ht_patient_score t2
on q.id = t2.question_id and
(
(t2.patient_report_id = #{id, jdbcType=BIGINT} and t2.type in (0,2) and t2.is_del = 0) or t2.id is null
)
GROUP BY t1.code
order by t1.type,t1.sort
</select>
<select id="queryQuestionAndScore" resultMap="QuestionMap">
SELECT
q.id,
q.question,
q.sort,
o.id AS optionId,
o.NAME,
IF( s.id IS NULL, 0, 1 ) AS chooseStatus,
s.answer
FROM
( SELECT * FROM t_ht_question WHERE evaluation_code = #{code} AND is_del = 0 ) q
LEFT JOIN t_ht_question_option o ON q.id = o.question_id
AND o.is_del = 0
LEFT JOIN t_ht_patient_score s ON q.id = s.question_id
AND o.id = s.option_id
AND s.is_del = 0
AND s.patient_report_id = #{id}
ORDER BY
q.sort,
o.sort
</select>
</mapper>

1
ht/src/main/resources/mapper_dao/HtQuestionDao.xml

@ -92,6 +92,7 @@
WHERE
q.evaluation_code = #{code}
AND q.sort = #{num}
AND q.relation_id = 0
AND q.is_del = 0
LIMIT 1
) q

4
ht/src/main/resources/mapper_dao/HtQuestionOptionDao.xml

@ -25,7 +25,7 @@
<result column="answer" jdbcType="VARCHAR" property="answer" />
<collection property="optionDescList" ofType="com.ccsens.ht.bean.vo.QuestionVo$OptionDesc">
<id column="descId" property="id"/>
<result column="type" property="type"/>
<result column="descType" property="type"/>
<result column="content" property="content"/>
</collection>
</resultMap>
@ -49,7 +49,7 @@
select t1.id, t1.type, t1.question_id, t1.name, t1.score, t1.display,
case when t1.type = 'hidden' then 0 when t2.id is null then 0 else 1 end as choose ,
if(t2.type = 3, null, t2.answer) as answer,
t3.id as descId, t3.type, t3.content
t3.id as descId, t3.type as descType, t3.content
from t_ht_question_option t1 left join t_ht_patient_score t2 on t1.id = t2.option_id and (t2.id is null or (t2.patient_report_id = #{patientReportId,jdbcType=BIGINT} and t2.is_del = 0))
left join (select * from t_ht_question_option_desc where is_del = 0) t3 on t1.id = t3.option_id
where t1.question_id = #{questionId,jdbcType=BIGINT}

3
question/src/main/java/com/ccsens/question/service/PatientReportService.java

@ -3,7 +3,6 @@ package com.ccsens.question.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.ccsens.question.bean.dto.PatientReportDto;
@ -407,7 +406,7 @@ public class PatientReportService implements IPatientReportService {
dateCell.setBorderLeft(null);
content.add(row2);
String path = PropUtil.imgDomain + "/" + PdfUtil.credatePdf(PropUtil.path, detail.getPatient().getHospital(), Constant.Ht.Report.PARENT_NAME, detail.getPatient().toPdfRow(), content, new PdfUtil.Margin());
String path = PropUtil.imgDomain + "/" + PdfUtil.createPdf(PropUtil.path, detail.getPatient().getHospital(), Constant.Ht.Report.PARENT_NAME, new PdfUtil.Margin(), detail.getPatient().toPdfRow(), content);
report.setUrl(path);
htPatientReportDao.updateByPrimaryKeySelective(report);
log.info("生成文件路径:{}", path);

23
util/src/main/java/com/ccsens/util/PdfUtil.java

@ -28,14 +28,14 @@ public class PdfUtil {
/**
* 生成pdf
* @param parentPath
* @param title
* @param parentPath 文件夹路径
* @param title 标题
* @param subhead 副标题
* @param intros
* @param content
* @param intros 介绍
* @param contentArr 正文
* @return
*/
public static String credatePdf(String parentPath, String title, String subhead, List<Row> intros, List<Row> content, Margin margin) {
public static String createPdf(String parentPath, String title, String subhead, Margin margin, List<Row> intros, List<Row>... contentArr) {
String fileName = "pdf/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".pdf";
log.info("pdf文件名:{}", fileName );
File file = new File(parentPath, fileName);
@ -66,14 +66,19 @@ public class PdfUtil {
document.add(subheadPar);
}
// 每行加空白
fillBlankRow(document, titleChinese);
fillBlankRow(document, new Font(bfChinese, 12, Font.NORMAL));
//设置介绍内容
if (CollectionUtil.isNotEmpty(intros)) {
fillRow(intros, document);
}
if (contentArr != null && contentArr.length > 0 ) {
for (List<Row> content:contentArr) {
if (CollectionUtil.isNotEmpty(content)) {
fillRow(content, document);
}
}
}
} catch (DocumentException e) {
e.printStackTrace();
@ -131,6 +136,7 @@ public class PdfUtil {
PdfPCell pdfpCell = new PdfPCell(new Phrase(cell.content,font));
pdfpCell.setBorderWidthTop(j == 0 && cell.borderTop == null && cell.borderBottom != null ? cell.borderBottom : cell.borderTop == null ? 0 : cell.borderTop);
pdfpCell.setBorderWidthLeft(cell.borderLeft == null ? 0 : cell.borderLeft);
// pdfpCell.setBorderWidthRight(i==row.cells.size() && cell.borderRight == null && cell.borderLeft != null ? cell.borderLeft : cell.borderRight == null ? 0 : cell.borderRight);
pdfpCell.setBorderWidthRight(cell.borderRight == null ? 0 : cell.borderRight);
pdfpCell.setBorderWidthBottom(cell.borderBottom == null ? 0 : cell.borderBottom);
pdfpCell.setColspan(cell.colSpan);
@ -195,6 +201,11 @@ public class PdfUtil {
// 单元格是否居中
private boolean isCenter = true;
public Cell() {
}
public Cell(String content) {
this.content = content;
}
}
/**

2
util/src/test/java/com/ccsens/util/PdfUtilTest.java

@ -49,7 +49,7 @@ public class PdfUtilTest {
contents.add(row);
contents.add(row2);
}
PdfUtil.credatePdf("/home/", "山大一院","评测", rows, contents, new PdfUtil.Margin());
PdfUtil.createPdf("/home/", "山大一院","评测", new PdfUtil.Margin(), rows, contents);
}

Loading…
Cancel
Save