Browse Source

修复

master
6 years ago
parent
commit
c965afecf1
  1. 2
      ht/src/main/java/com/ccsens/ht/api/DoctorController.java
  2. 19
      ht/src/main/java/com/ccsens/ht/api/PatientReportController.java
  3. 21
      ht/src/main/java/com/ccsens/ht/bean/dto/PatientDto.java
  4. 5
      ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java
  5. 174
      ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java
  6. 19
      ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java
  7. 2
      ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java
  8. 20
      ht/src/main/java/com/ccsens/ht/service/PatientReportService.java
  9. 9
      ht/src/main/java/com/ccsens/ht/service/PatientService.java
  10. 56
      ht/src/main/java/com/ccsens/ht/service/QuestionService.java
  11. 2
      ht/src/main/resources/application-dev.yml
  12. 2
      ht/src/main/resources/application-test.yml
  13. 18
      util/pom.xml
  14. 2
      util/src/main/java/com/ccsens/util/CodeEnum.java
  15. 164
      util/src/main/java/com/ccsens/util/PdfUtil.java
  16. 42
      util/src/test/java/com/ccsens/util/PdfUtilTest.java
  17. 2
      util/src/test/java/com/ccsens/util/ZipTest.java

2
ht/src/main/java/com/ccsens/ht/api/DoctorController.java

@ -90,7 +90,7 @@ public class DoctorController {
log.info("资格认证列表:{}", params);
DoctorVo.Query dtos = doctorService.queryDoctorStatus(params.getUserId());
if (dtos == null) {
JsonResponse.newInstance().ok(CodeEnum.DOCTOR_NOT_SUBMIT);
return JsonResponse.newInstance().ok(CodeEnum.DOCTOR_NOT_SUBMIT);
}
return JsonResponse.newInstance().ok(dtos);
}

19
ht/src/main/java/com/ccsens/ht/api/PatientReportController.java

@ -9,6 +9,8 @@ import com.ccsens.ht.bean.vo.PatientReportVo;
import com.ccsens.ht.service.IPatientReportService;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.PdfUtil;
import com.ccsens.util.PropUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
@ -109,4 +111,21 @@ public class PatientReportController {
log.info("查询医生对报告单的权限结果:{}", authority);
return JsonResponse.newInstance().ok(authority);
}
// @ApiOperation(value = "导出报告单",notes = "导出报告单")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "json", value = "导出报告单", required = true)
// })
// @RequestMapping(value="/exportReport", method = RequestMethod.POST)
// public JsonResponse<PatientReportVo.Export> exportReport(@RequestBody @ApiParam @Valid QueryDto<PatientReportDto.QueryDetail> param){
// //查询报告单信息
// log.info("查询报告单详情:{}", param);
// PatientReportVo.ReprotDetail detail = patientReportService.queryReportDetail(param.getParam(), param.getUserId());
// if (detail == null) {
// return JsonResponse.newInstance().ok(CodeEnum.);
// }
// PdfUtil.credatePdf(PropUtil.path, detail.getPatient().getName(), detail.getPatient().toPdfRow(), )
// log.info("查询报告单详情结果:{}", detail);
// return JsonResponse.newInstance().ok(detail);
// }
}

21
ht/src/main/java/com/ccsens/ht/bean/dto/PatientDto.java

@ -55,45 +55,44 @@ public class PatientDto {
private Long id;
@ApiModelProperty("病人用户id")
private Long userId;
@NotNull
@NotNull(message = "请填写名字")
@ApiModelProperty("病人名字")
private String name;
@ApiModelProperty("病人门诊号")
private String patientNumber;
@ApiModelProperty("病人住院号")
private String hospitalNumber;
@NotNull
@NotNull(message="请填写身份证号")
@ApiModelProperty("病人身份证号")
@NotNull(message="身份证信息不能为空")
private String idcard;
@NotNull
@NotNull(message = "请选择性别")
@ApiModelProperty("性别(0:男 1:女)")
private Byte sex;
@NotNull
@NotNull(message = "请选择婚姻状况")
@ApiModelProperty("婚姻状况(1:未婚2:已婚 3:离异 4:分居 5:丧偶 6:同居 7:其他 )")
private Byte maritalStatus;
@NotNull
@NotNull(message = "请选择教育程度")
@ApiModelProperty("教育程度(1:文盲 2:小学 3:初中 4:高中 5:大学 6:大学以上 7:其他)")
private Byte educationalStatus;
@NotNull
@NotNull(message = "请选择受教育时间")
@ApiModelProperty("受教育时间(年或月)")
private String educationalStatusUnit;
@ApiModelProperty("民族")
private String nation;
@ApiModelProperty("籍贯")
private String nativePlace;
@NotNull
@NotNull(message="请选择职业")
@ApiModelProperty("职业(1:农林牧渔水利生产人员 2:教师 3:医务工作者 4:专业技术人员 5:生产、运输设备操作人员及有关人员6:商业、服务业人员7:国家机关、事业单位、企业负责人8:国家机关、事业单位、企业办事人员和有关人员9:军人 10:媒体、文体类工作人员 11:在校学生 12:未就业 13:家务 14:其他")
private Byte career;
@NotNull
@NotNull(message="请填写生育数量")
@ApiModelProperty("生育数量")
private Integer birthNumber;
@ApiModelProperty("绝经年龄(女)")
private Integer menopauseAge;
@NotNull
@NotNull(message="请填写联系人")
@ApiModelProperty("联系人")
private String contact;
@NotNull
@NotNull(message = "请填写手机")
@ApiModelProperty("手机")
private String mobile;
@ApiModelProperty("电话")

5
ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java

@ -41,10 +41,8 @@ public class PatientReportDto {
@ApiModelProperty("病人年龄 ")
private Byte patientAge;
@ApiModelProperty("严重程度(1:轻度 2:中度 3:重度) ")
@NotNull(message = "严重程度不能为空")
private Long pasi;
private Byte pasi;
@ApiModelProperty("科别")
@NotNull(message = "科别不允许为空")
private String department;
@ApiModelProperty("病人报告单ID")
@NotNull(message = "报告单ID不允许为空")
@ -62,7 +60,6 @@ public class PatientReportDto {
@Data
public static class QueryReports{
@ApiModelProperty("病人ID")
@NotNull(message = "病人ID不能为空")
private Long patientId;
@ApiModelProperty("第几页")
@Min(value = 1)

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

@ -1,13 +1,15 @@
package com.ccsens.ht.bean.vo;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.ccsens.util.PdfUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
/**
* @program: ptpro
@ -95,6 +97,60 @@ public class PatientReportVo {
private String educationalStatusUnit;
@ApiModelProperty("职业")
private Byte career;
public List<PdfUtil.Row> toPdfRow(){
Map<Byte, String> careerMap = new HashMap<>();
String careerMsg = "1:农林牧渔水利生产人员 2:教师 3:医务工作者 4:专业技术人员 5:生产、运输设备操作人员及有关人员 6:商业、服务业人员 7:国家机关、事业单位、企业负责人 8:国家机关、事业单位、企业办事人员和有关人员 9:军人 10:媒体、文体类工作人员 11:在校学生 12:未就业 13:家务 14:其他";
for (String careerOne: careerMsg.split(" ")) {
careerMap.put(Byte.parseByte(careerOne.split(":")[0]), careerOne.split(":")[1]);
}
List<PdfUtil.Row> rows = new ArrayList<>();
//第一栏
rows.add(
fillRow(
"姓名:" + this.patientName,
"性别:" + (this.sex == 0 ? "男" : "女"),
"年龄:" + this.patientAge + " 岁")
);
//第二栏
rows.add(
fillRow(
"文化程度(年或月):" + this.educationalStatusUnit,
"编号:" + this.serialNumber,
"职业:" + careerMap.get(this.career))
);
//第三栏
rows.add(
fillRow(
"科别:" + this.department,
"床号:" + this.bedNumber,
"病案号:" + this.hospitalNumber)
);
//第四栏
Date date = new Date();
date.setTime(this.reportTime);
rows.add(
fillRow(
"临床诊断:" + this.clinicalDiagnosis,
"检查日期:" + DateUtil.format(date, "yyyy-MM-dd"))
);
return rows;
}
private PdfUtil.Row fillRow(String... params) {
PdfUtil.Row row = new PdfUtil.Row();
for (String param: params) {
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setContent(param);
cell.setBorder(0);
row.addCell(cell);
}
return row;
}
}
/**分数类型*/
@ -123,6 +179,111 @@ public class PatientReportVo {
public void addSub(ReportScore score) {
this.subReport.add(score);
}
public List<PdfUtil.Row> toRow() {
List<PdfUtil.Row> rows = new ArrayList<>();
if (CollectionUtil.isEmpty(subReport)) {
PdfUtil.Row row = new PdfUtil.Row();
PdfUtil.Cell cell1 = new PdfUtil.Cell();
cell1.setContent(this.name + (StrUtil.isBlank(this.remark) ? "" : "("+this.remark+")"));
PdfUtil.Cell cell2 = new PdfUtil.Cell();
cell2.setContent(this.score == null ? "" : this.score + (this.totalScore > 0 ? "/" + this.totalScore : ""));
row.addCell(cell1);
row.addCell(cell2);
rows.add(row);
return rows;
} else {
String mmse = "MMSE";
String npi = "NPI";
if (mmse.equalsIgnoreCase(this.code) || npi.equalsIgnoreCase(this.code)) {
PdfUtil.Row row1 = new PdfUtil.Row();
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setContent(this.name + (StrUtil.isBlank(this.remark) ? "" : "("+this.remark+")"));
cell.setRowSpan(2);
row1.addCell(cell);
PdfUtil.Row row2 = new PdfUtil.Row();
this.subReport.forEach(reportScore -> {
fillRow(row1,row2, reportScore.getName(), reportScore.score == null ? "" : reportScore.score + (reportScore.totalScore > 0 ? "/" + reportScore.totalScore : ""));
});
if (mmse.equalsIgnoreCase(this.code)) {
fillRow(row1,row2, "总分", this.score == null ? "" : this.score + (this.totalScore > 0 ? "/" + this.totalScore : ""));
}
rows.add(row1);
rows.add(row2);
} else {
//moca
int firstIndex = 6;
PdfUtil.Row row1 = new PdfUtil.Row();
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setContent(this.name + (StrUtil.isBlank(this.remark) ? "" : "("+this.remark+")"));
cell.setRowSpan(5);
row1.addCell(cell);
PdfUtil.Row row2 = new PdfUtil.Row();
for (int i = 0; i < firstIndex; i++) {
ReportScore reportScore = this.subReport.get(i);
String jy = "JY";
if (jy.equalsIgnoreCase(reportScore.getCode())) {
fillRow(row1, row2, reportScore.getName(), "");
} else {
fillRow(row1, row2, reportScore.getName(), reportScore.score == null ? "" : reportScore.score + (reportScore.totalScore > 0 ? "/" + reportScore.totalScore : ""));
}
}
PdfUtil.Cell scoreNameCell = new PdfUtil.Cell();
scoreNameCell.setContent("总分");
row1.addCell(scoreNameCell);
PdfUtil.Cell scoreCell = new PdfUtil.Cell();
scoreNameCell.setContent("总分");
row1.addCell(scoreNameCell);
for (ReportScore score: this.subReport) {
if (firstIndex == 6) {
//设置总分
PdfUtil.Cell scoreTitleCell = new PdfUtil.Cell();
scoreTitleCell.setContent("总分");
row1.addCell(scoreTitleCell);
PdfUtil.Cell scoreScoreCell = new PdfUtil.Cell();
scoreScoreCell.setContent(this.score == null ? "" : this.score + (this.totalScore > 0 ? "/" + this.totalScore : ""));
scoreScoreCell.setRowSpan(4);
row2.addCell(scoreScoreCell);
rows.add(row1);
rows.add(row2);
//换行
row1 = new PdfUtil.Row();
row2 = new PdfUtil.Row();
}
firstIndex++;
}
rows.add(row1);
rows.add(row2);
}
}
PdfUtil.Row row = new PdfUtil.Row();
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setContent(this.description);
return rows;
}
private void fillRow(PdfUtil.Row row1, PdfUtil.Row row2, String name, String score){
//名称
PdfUtil.Cell cell1 = new PdfUtil.Cell();
cell1.setContent(name);
row1.addCell(cell1);
//分数
PdfUtil.Cell cell2 = new PdfUtil.Cell();
cell2.setContent(score);
row2.addCell(cell2);
}
}
/**医生对报告单权限*/
@ -136,4 +297,11 @@ public class PatientReportVo {
public static final int READ_WRITE = 1;
public static final int CHECK = 2;
}
@ApiModel("PatientReportVoExport")
@Data
public static class Export{
@ApiModelProperty("路径")
private String path;
}
}

19
ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import com.ccsens.ht.bean.po.HtPatientQuestionRecord;
import com.ccsens.ht.bean.po.HtQuestion;
import com.ccsens.ht.bean.po.HtQuestionIntroducer;
import com.ccsens.ht.bean.po.HtQuestionOption;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -78,6 +79,22 @@ public class QuestionVo {
private String name;
}
@Data
@ApiModel("QuestionOption")
public static class QuestionOption{
@ApiModelProperty("试题")
private Question question;
@ApiModelProperty("选项")
private List<Option> options;
public static QuestionOption toQuestionOption(HtQuestion question, List<Option> options) {
QuestionOption vo = new QuestionOption();
vo.setQuestion(Question.toQuestionVo(question));
vo.setOptions(options);
return vo;
}
}
@Data
@ApiModel("QuestionVoQuestion")
public static class Question{
@ -108,7 +125,7 @@ public class QuestionVo {
@ApiModelProperty("定时器时长")
private Integer timingLength;
@ApiModelProperty("关联试题")
List<Question> relationQuestions = new ArrayList<>();
List<QuestionOption> relationQuestions = new ArrayList<>();
/**
* 将HtQuestion转化成Question

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

@ -35,6 +35,6 @@ public interface HtPatientReportDao extends HtPatientReportMapper {
* @param id
* @return
*/
Map<String, Object> queryNPIScore(@Param("id") Long id);
List<Map<String, Object>> queryNPIScore(@Param("id") Long id);
}

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

@ -27,6 +27,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@ -155,7 +156,12 @@ public class PatientReportService implements IPatientReportService {
//分页查询报告单列表
PageHelper.startPage(query.getPageNum(), query.getPageSize());
HtPatientReportExample reportExample = new HtPatientReportExample();
if (query.getPatientId() != null) {
reportExample.createCriteria().andPatientIdEqualTo(query.getPatientId());
} else {
reportExample.createCriteria().andDoctorIdEqualTo(userId);
}
reportExample.setOrderByClause("create_time desc");
List<HtPatientReport> reports = htPatientReportDao.selectByExample(reportExample);
@ -241,12 +247,16 @@ public class PatientReportService implements IPatientReportService {
}
private void initNPI(PatientReportDto.QueryDetail queryDetail, PatientReportVo.ReportScore score) {
Map<String, Object> npiScore = htPatientReportDao.queryNPIScore(queryDetail.getId());
List<Map<String, Object>> list = htPatientReportDao.queryNPIScore(queryDetail.getId());
Map<String,Object> npiScore = new HashMap<>();
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 : (Integer)npiScore.get("carer"));
carer.setScore(npiScore == null || npiScore.get("carer") == null ? null : ((BigDecimal) npiScore.get("carer")).intValue());
carer.setType((byte)3);
carer.setParentCode("NPI");
score.addSub(carer);
@ -254,7 +264,7 @@ public class PatientReportService implements IPatientReportService {
patient.setCode("result");
patient.setName("患者");
patient.setTotalScore(-1);
patient.setScore(npiScore == null || npiScore.get("result") == null ? null : (Integer)npiScore.get("result"));
patient.setScore(npiScore == null || npiScore.get("result") == null ? null : ((BigDecimal) npiScore.get("result")).intValue());
patient.setType((byte)3);
patient.setParentCode("NPI");
score.addSub(patient);
@ -307,14 +317,14 @@ public class PatientReportService implements IPatientReportService {
*@date: 2019/11/19 15:42
*/
private Integer sumScore(PatientReportVo.ReportScore score){
AtomicReference<Integer> sum = new AtomicReference<>(0);
AtomicReference<Integer> sum = new AtomicReference<>(score.getScore() == null ? 0 : score.getScore());
AtomicBoolean hasAdd = new AtomicBoolean(false);
if (!CollectionUtils.isEmpty(score.getSubReport())) {
score.getSubReport().forEach(sub -> {
sum.updateAndGet(v -> {
Integer sumScore = sumScore(sub);
if (sumScore== null) {
return 0;
return v;
}
hasAdd.set(true);
return v += sumScore;

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

@ -59,8 +59,10 @@ public class PatientService implements IPatientService {
example.createCriteria().andRecorderEqualTo(userId);
example.setOrderByClause("create_time desc");
List<HtPatient> htPatients = htPatientMapper.selectByExample(example);
List<PatientVo.Query> copy = PatientVo.Query.copy(htPatients);
return new PageInfo<>(copy);
PageInfo pageInfo = new PageInfo(htPatients);
List<PatientVo.Query> copy = PatientVo.Query.copy(pageInfo.getList());
pageInfo.setList(copy);
return pageInfo;
}
@Override
@ -168,9 +170,10 @@ public class PatientService implements IPatientService {
}
if (oldPatient != null) {
patient.setId(oldPatient.getId());
htPatientMapper.updateByPrimaryKey(patient);
htPatientMapper.updateByPrimaryKeySelective(patient);
} else {
patient.setId(snowflake.nextId());
patient.setRecorder(userId);
htPatientMapper.insertSelective(patient);
}
return patient.getId();

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

@ -32,10 +32,7 @@ import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
/**
@ -108,8 +105,17 @@ public class QuestionService implements IQuestionService {
example.createCriteria().andParentCodeIn(CollectionUtils.arrayToList(codes));
example.setOrderByClause("id");
List<HtQuestion> relationQuestions = htQuestionDao.selectByExample(example);
List<QuestionVo.Question> vos = QuestionVo.Question.toQuestionVos(relationQuestions);
List<QuestionVo.QuestionOption> vos = new ArrayList<>();
if (CollectionUtil.isNotEmpty(relationQuestions)) {
relationQuestions.forEach(relation -> {
//试题选项
List<QuestionVo.Option> options = htQuestionOptionDao.queryOption(question.getId(), query.getPatientReportId());
QuestionVo.QuestionOption questionOption = QuestionVo.QuestionOption.toQuestionOption(relation, options);
vos.add(questionOption);
});
}
log.info("关联试题:{}", vos);
questionVo.setRelationQuestions(vos);
}
//试题引导语
@ -143,8 +149,13 @@ public class QuestionService implements IQuestionService {
@Override
public CodeEnum saveScore(QuestionDto.Score score, Long userId) throws IOException, NotSupportedFileTypeException {
log.info("保存分数");
if (score.getPatientReportId() == null || CollectionUtil.isEmpty(score.getOptions())) {
log.info("保存分数{}", score);
if (score.getPatientReportId() == null) {
log.info("没有选择病人信息");
return CodeEnum.PATIENT_NOT_CHOICE;
}
if (score.getOptions() == null) {
log.info("没有报告单ID或选项,不进行保存");
return CodeEnum.SUCCESS;
}
@ -155,6 +166,7 @@ public class QuestionService implements IQuestionService {
if (question == null) {
return CodeEnum.PARAM_ERROR;
}
String parentCode = question.getParentCode().contains("-") ? question.getParentCode().split("-")[0] : question.getParentCode();
//查询报告单
HtPatientReport report = htPatientReportMapper.selectByPrimaryKey(score.getPatientReportId());
log.info("报告单:{}", report);
@ -169,6 +181,9 @@ public class QuestionService implements IQuestionService {
//查询选项列表
Map<String, HtQuestionOption> nameOption = new HashMap<>();
Map<Long, HtQuestionOption> idOption = new HashMap<>();
//选项去重
optionUniq(score);
for(QuestionDto.Option option : score.getOptions()) {
HtQuestionOption questionOption = htQuestionOptionDao.selectByPrimaryKey(option.getId());
//未找到对应选项 或选项不是该试题的选项
@ -184,18 +199,18 @@ public class QuestionService implements IQuestionService {
if (!CollectionUtils.isEmpty(ruleList)) {
HtQuestionScoringRule rule = ruleList.get(0);
if (rule.getType() == null || rule.getType() == Constant.Ht.Rule.SMALL) {
if (rule.getType() == null || rule.getType().byteValue() == Constant.Ht.Rule.SMALL) {
JSONArray ruleDetails = JSON.parseArray(rule.getDetail());
AtomicInteger patientScore = new AtomicInteger();
for (int i = 0; i < ruleDetails.size() - 2 ; i++) {
for (int i = 0; i < ruleDetails.size() - 1; i++) {
JSONObject small = (JSONObject)ruleDetails.get(i);
JSONObject next = (JSONObject)ruleDetails.get(i+1);
if (i == 0 && scores.size() <= small.getIntValue(Constant.Ht.Rule.SMALL_NUM)) {
patientScore.set(small.getIntValue(Constant.Ht.Rule.SMALL_SCORE));
break;
}
if (scores.size() > small.getIntValue(Constant.Ht.Rule.SMALL_NUM) && scores.size() < next.getIntValue(Constant.Ht.Rule.SMALL_NUM)) {
patientScore.set(small.getIntValue(Constant.Ht.Rule.SMALL_SCORE));
if (scores.size() > small.getIntValue(Constant.Ht.Rule.SMALL_NUM) && scores.size() <= next.getIntValue(Constant.Ht.Rule.SMALL_NUM)) {
patientScore.set(next.getIntValue(Constant.Ht.Rule.SMALL_SCORE));
}
}
HtPatientScore singleScore = new HtPatientScore();
@ -203,7 +218,7 @@ public class QuestionService implements IQuestionService {
singleScore.setPatientReportId(score.getPatientReportId());
singleScore.setPatientId(report.getPatientId());
singleScore.setQuestionId(score.getQuestionId());
singleScore.setQuestionParentCode(question.getParentCode());
singleScore.setQuestionParentCode(parentCode);
singleScore.setOptionId((long)Constant.Ht.NUMBER_DEFAULT);
singleScore.setOptionName(Constant.Ht.STRING_DEFAULT);
singleScore.setScore(patientScore.get());
@ -222,10 +237,25 @@ public class QuestionService implements IQuestionService {
delScore.setIsDel(Constant.Ht.IS_DEL);
htPatientScoreDao.updateByExampleSelective(delScore, delExample);
//保存现在的答案
if (CollectionUtil.isNotEmpty(scores)) {
htPatientScoreDao.insertBatch(scores);
}
return CodeEnum.SUCCESS;
}
private void optionUniq(QuestionDto.Score score) {
List<Long> ids = new ArrayList<>();
Iterator<QuestionDto.Option> iterator = score.getOptions().iterator();
while (iterator.hasNext()) {
QuestionDto.Option next = iterator.next();
if (ids.contains(next.getId())) {
iterator.remove();
}
ids.add(next.getId());
}
}
/**
* 分数数据处理
* @param score
@ -274,7 +304,7 @@ public class QuestionService implements IQuestionService {
patientScore.setPatientReportId(score.getPatientReportId());
patientScore.setPatientId(report.getPatientId());
patientScore.setQuestionId(score.getQuestionId());
patientScore.setQuestionParentCode(question.getParentCode());
patientScore.setQuestionParentCode(question.getParentCode().contains("-") ? question.getParentCode().split("-")[0] : question.getParentCode());
patientScore.setOptionId(questionOption.getId());
patientScore.setOptionName(questionOption.getName());
if (StrUtil.isNotEmpty(questionOption.getRemark())) {

2
ht/src/main/resources/application-dev.yml

@ -34,4 +34,4 @@ file:
imgDomain: http://localhost:7040/uploads
ht:
project:
name: 阿尔兹海默症评估系统
name: 认知功能评测云平台系统

2
ht/src/main/resources/application-test.yml

@ -35,4 +35,4 @@ file:
imgDomain: https://test.tall.wiki/gateway/ht/uploads
ht:
project:
name: 阿尔兹海默症评估系统
name: 认知功能评测云平台系统

18
util/pom.xml

@ -15,6 +15,24 @@
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.xhtmlrenderer/flying-saucer-pdf -->
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf</artifactId>
<version>9.1.19</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.itextpdf/itext-asian -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-asian</artifactId>
<version>5.2.0</version>
</dependency>
</dependencies>

2
util/src/main/java/com/ccsens/util/CodeEnum.java

@ -68,6 +68,8 @@ public enum CodeEnum {
TIME_ERROR_PROJECT(53,"时间异常,任务的时间不能超出项目的时间",true),
HAS_GROUP_TIME_CHANGE(54,"分组任务不能直接修改时间,请修改其子任务时间",true),
DOCTOR_NOT_SUBMIT(55,"尚未进行资格认证",true),
REPORT_NOT_FOUND(56,"对不起,没有找到您查询的报告单,请确认报告单是否存在。",true),
PATIENT_NOT_CHOICE(57,"没有选择病人,不进行保存答案。", true),
;
public CodeEnum addMsg(String msg){

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

@ -0,0 +1,164 @@
package com.ccsens.util;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* @description:
* @author: wuHuiJuan
* @create: 2019/12/20 09:34
*/
@Slf4j
public class PdfUtil {
/**
* 生成pdf
* @param parentPath
* @param title
* @param intros
* @param content
* @return
*/
public static String credatePdf(String parentPath, String title, List<Row> intros, List<Row> content) {
String fileName = "pdf/" + DateUtil.today() + "/" + title + System.currentTimeMillis() + ".pdf";
log.info("pdf文件名:{}", fileName );
File file = new File(parentPath, fileName);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
//新建文件
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream(file));
document.open();
// 中文字体
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
// 标题字体
Font titleChinese = new Font(bfChinese, 18, Font.BOLD);
//设置标题
Paragraph par = new Paragraph(title, titleChinese);
par.setAlignment(Element.ALIGN_CENTER);
document.add(par);
// 每行加空白
fillBlankRow(document, titleChinese);
//设置介绍内容
if (CollectionUtil.isNotEmpty(intros)) {
fillRow(intros, document);
fillBlankRow(document, titleChinese);
}
if (CollectionUtil.isEmpty(content)) {
fillRow(content, document);
}
} catch (DocumentException e) {
e.printStackTrace();
log.error("导出pdf异常", e);
return null;
} catch (FileNotFoundException e) {
e.printStackTrace();
log.error("导出pdf异常", e);
return null;
} catch (IOException e) {
e.printStackTrace();
log.error("导出pdf异常", e);
return null;
} finally {
document.close();
}
return fileName;
}
/**
* 添加空白行
* @param document
* @param titleChinese
* @throws DocumentException
*/
private static void fillBlankRow(Document document, Font titleChinese) throws DocumentException {
Paragraph par;
par = new Paragraph(" ", titleChinese);
par.setAlignment(Element.ALIGN_LEFT);
document.add(par);
}
/**
* 添加内容
* @param rows
* @param document
*/
private static void fillRow(List<Row> rows, Document document) throws IOException, DocumentException {
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
rows.forEach(row -> {
PdfPTable table = new PdfPTable(row.getCells().size());
table.setWidthPercentage(100);
table.setSpacingBefore(10);
Font font = new Font(bfChinese, row.fontSize, row.fontStyle);
row.cells.forEach(cell -> {
PdfPCell pdfpCell = new PdfPCell(new Paragraph(cell.content,font));
pdfpCell.setBorder(cell.border);
pdfpCell.setColspan(cell.colSpan);
pdfpCell.setRowspan(cell.rowSpan);
table.addCell(pdfpCell);
});
try {
table.setWidthPercentage(90);
table.setHorizontalAlignment(row.align);
document.add(table);
} catch (DocumentException e) {
e.printStackTrace();
}
});
}
/**
* pdf每行的内容
*/
@Data
public static class Row{
//表格内容
private List<Cell> cells = new ArrayList<>();
//文字位置(居左)
private int align = Element.ALIGN_LEFT;
private int fontSize = 12;
private int fontStyle = Font.NORMAL;
private int height = 80;
public void addCell(Cell cell) {
cells.add(cell);
}
}
@Data
public static class Cell{
//内容
private String content;
//边框宽度
private int border = 1;
//横向合并数
private int colSpan = 1;
//纵向合并数
private int rowSpan = 1;
}
}

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

@ -0,0 +1,42 @@
package com.ccsens.util;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
/**
* @description:
* @author: wuHuiJuan
* @create: 2019/12/20 10:18
*/
public class PdfUtilTest {
@Test
public void test(){
List<PdfUtil.Row> rows = new ArrayList<>();
for (int i = 0; i < 3; i++) {
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setContent("cell" + i);
PdfUtil.Row row = new PdfUtil.Row();
row.addCell(cell);
PdfUtil.Cell cell2 = new PdfUtil.Cell();
cell2.setContent("cell--" + i);
row.addCell(cell2);
rows.add(row);
}
List<PdfUtil.Row> contents = new ArrayList<>();
for (int i = 0; i < 3; i++) {
PdfUtil.Cell cell = new PdfUtil.Cell();
cell.setContent("*******" + i);
PdfUtil.Row row = new PdfUtil.Row();
row.addCell(cell);
PdfUtil.Cell cell2 = new PdfUtil.Cell();
cell2.setContent("+++++++" + i);
PdfUtil.Row row2 = new PdfUtil.Row();
row2.addCell(cell2);
contents.add(row);
contents.add(row2);
}
PdfUtil.credatePdf("/home/", "评测", rows, contents);
}
}

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

@ -37,5 +37,7 @@ public class ZipTest {
Object result = engine.eval(expr);
System.out.println(result.getClass());
System.out.println(result);
}
}

Loading…
Cancel
Save