From 4fb3c9ae2fa1eb7802d33a93d079d09b4284da6c Mon Sep 17 00:00:00 2001 From: zhizhi wu <2377881365@qq.com> Date: Wed, 31 Mar 2021 15:19:41 +0800 Subject: [PATCH 01/30] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ccsens/ht/api/ImportController.java | 72 ++++++++++++------- .../ccsens/ht/bean/dto/PatientReportDto.java | 2 + .../ht/persist/dao/HtPatientReportDao.java | 5 +- .../com/ccsens/ht/service/IImportService.java | 8 ++- .../com/ccsens/ht/service/ImportService.java | 8 ++- .../ht/service/PatientReportService.java | 4 +- .../java/com/ccsens/ht/uitl/Constant.java | 5 +- ht/src/main/resources/application.yml | 4 +- .../mapper_dao/HtPatientReportDao.xml | 17 +++-- 9 files changed, 82 insertions(+), 43 deletions(-) diff --git a/ht/src/main/java/com/ccsens/ht/api/ImportController.java b/ht/src/main/java/com/ccsens/ht/api/ImportController.java index acb3e011..efee911e 100644 --- a/ht/src/main/java/com/ccsens/ht/api/ImportController.java +++ b/ht/src/main/java/com/ccsens/ht/api/ImportController.java @@ -1,5 +1,6 @@ package com.ccsens.ht.api; +import cn.hutool.core.collection.CollectionUtil; import com.ccsens.ht.service.IImportService; import com.ccsens.ht.uitl.Constant; import com.ccsens.util.JsonResponse; @@ -18,6 +19,8 @@ import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.Part; import java.io.File; +import java.util.Collections; +import java.util.List; /** @@ -54,19 +57,26 @@ public class ImportController { String allowedExts = "xls,xlsx"; String dir = WebConstant.UPLOAD_PROJECT_WBS + File.separator; String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExts, dir); - File execlFile = new File(dir+path); + File excelFile = new File(dir+path); long time2 = System.currentTimeMillis(); log.info("解析文件耗时:{}", (time2 - time1)); - importService.importPosition(execlFile, 0); + importService.importPosition(excelFile, 0); long time3 = System.currentTimeMillis(); log.info("导入职务耗时:{}", (time3 - time2)); - importService.importTitle(execlFile, 1); + importService.importTitle(excelFile, 1); long time4 = System.currentTimeMillis(); log.info("导入职称耗时:{}", (time4 - time3)); - importService.importReport(execlFile, 2); + List codes = importService.importReport(excelFile, 2); long time5 = System.currentTimeMillis(); log.info("导入报告单耗时:{}", (time5 - time4)); - importService.importQuestion(execlFile, Constant.Ht.Question.ALL); + + if (CollectionUtil.isNotEmpty(codes)) { + for (String code: codes) { + importService.importQuestion(excelFile, code); + log.info("{}导入完成",code); + } + } + return JsonResponse.newInstance().ok(); } @@ -89,19 +99,37 @@ public class ImportController { String allowedExts = "xls,xlsx"; String dir = WebConstant.UPLOAD_PROJECT_WBS + File.separator; String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExts, dir); - File execlFile = new File(dir+path); + File excelFile = new File(dir+path); long time2 = System.currentTimeMillis(); log.info("解析文件耗时:{}", (time2 - time1)); -// importService.importPosition(execlFile, 0); +// importService.importPosition(excelFile, 0); // long time3 = System.currentTimeMillis(); // log.info("导入职务耗时:{}", (time3 - time2)); -// importService.importTitle(execlFile, 1); +// importService.importTitle(excelFile, 1); long time4 = System.currentTimeMillis(); // log.info("导入职称耗时:{}", (time4 - time3)); - importService.importReport(execlFile, 2); + importService.importReport(excelFile, 2); long time5 = System.currentTimeMillis(); log.info("导入报告单耗时:{}", (time5 - time4)); -// importService.importQuestion(execlFile, Constant.Ht.Question.ALL); +// importService.importQuestion(excelFile, Constant.Ht.Question.ALL); + return JsonResponse.newInstance().ok(); + } + + @ApiOperation(value = "导入指定测评类型",notes = "文件大小不能超过20M,支持后缀:.xls|.xlsx") + @ApiImplicitParams({ + @ApiImplicitParam(name = "file", value = "医疗项目表", required = true, paramType = "form",dataType = "__file"), + @ApiImplicitParam(name = "code", value = "测评类型", required = true, paramType = "form",dataType = "__file") + }) + @RequestMapping(value = "/importEvaluation", method = RequestMethod.POST) + public JsonResponse importEvaluation(@RequestParam(required = true) Part file, @RequestParam(required = true) String code) throws Exception{ + + //1.上传文件 + String allowedExts = "xls,xlsx"; + String dir = WebConstant.UPLOAD_PROJECT_WBS + File.separator; + String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExts, dir); + File excelFile = new File(dir+path); + importService.importQuestion(excelFile, code); + log.info("导入{}",code); return JsonResponse.newInstance().ok(); } @@ -120,14 +148,12 @@ public class ImportController { @RequestMapping(value = "/importMoca", method = RequestMethod.POST) public JsonResponse importMoca(@RequestParam(required = true) Part file) throws Exception{ - long time1 = System.currentTimeMillis(); //1.上传文件 String allowedExts = "xls,xlsx"; String dir = WebConstant.UPLOAD_PROJECT_WBS + File.separator; String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExts, dir); - File execlFile = new File(dir+path); - long time2 = System.currentTimeMillis(); - importService.importQuestion(execlFile, Constant.Ht.Report.MOCA); + File excelFile = new File(dir+path); + importService.importQuestion(excelFile, Constant.Ht.Report.MOCA); log.info("导入moca"); return JsonResponse.newInstance().ok(); } @@ -146,14 +172,12 @@ public class ImportController { @RequestMapping(value = "/importMMSE", method = RequestMethod.POST) public JsonResponse importMMSE(@RequestParam(required = true) Part file) throws Exception{ - long time1 = System.currentTimeMillis(); //1.上传文件 String allowedExts = "xls,xlsx"; String dir = WebConstant.UPLOAD_PROJECT_WBS + File.separator; String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExts, dir); - File execlFile = new File(dir+path); - long time2 = System.currentTimeMillis(); - importService.importQuestion(execlFile, Constant.Ht.Report.MMSE); + File excelFile = new File(dir+path); + importService.importQuestion(excelFile, Constant.Ht.Report.MMSE); log.info("导入mmse"); return JsonResponse.newInstance().ok(); } @@ -172,14 +196,12 @@ public class ImportController { @RequestMapping(value = "/importRey", method = RequestMethod.POST) public JsonResponse importRey(@RequestParam(required = true) Part file) throws Exception{ - long time1 = System.currentTimeMillis(); //1.上传文件 String allowedExts = "xls,xlsx"; String dir = WebConstant.UPLOAD_PROJECT_WBS + File.separator; String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExts, dir); - File execlFile = new File(dir+path); - long time2 = System.currentTimeMillis(); - importService.importQuestion(execlFile, Constant.Ht.Report.REY); + File excelFile = new File(dir+path); + importService.importQuestion(excelFile, Constant.Ht.Report.REY); log.info("导入Rey"); return JsonResponse.newInstance().ok(); } @@ -199,14 +221,12 @@ public class ImportController { @RequestMapping(value = "/importXFXPD", method = RequestMethod.POST) public JsonResponse importXFXPD(@RequestParam(required = true) Part file) throws Exception{ - long time1 = System.currentTimeMillis(); //1.上传文件 String allowedExts = "xls,xlsx"; String dir = WebConstant.UPLOAD_PROJECT_WBS + File.separator; String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExts, dir); - File execlFile = new File(dir+path); - long time2 = System.currentTimeMillis(); - importService.importQuestion(execlFile, Constant.Ht.Report.XFXPD); + File excelFile = new File(dir+path); + importService.importQuestion(excelFile, Constant.Ht.Report.XFXPD); log.info("导入XFXPD"); return JsonResponse.newInstance().ok(); } diff --git a/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java b/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java index 5f82f7aa..b3c18771 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java +++ b/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java @@ -83,6 +83,8 @@ public class PatientReportDto { private Long id; @ApiModelProperty("是否需要rey 默认为0 0全部查询导出 1不导出rey 2只导出rey") private int rey = 0; + @ApiModelProperty("报告单类型") + private String report = "REPORT1.0"; } diff --git a/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java b/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java index c6c9c691..8da3b631 100644 --- a/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java +++ b/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java @@ -26,12 +26,13 @@ public interface HtPatientReportDao extends HtPatientReportMapper { PatientReportVo.ReprotPatient queryReportResult(@Param("id") Long id); /** * 根据病人报告单ID查询报告单各项相关分数 - * @param id + * @param id 报告单ID + * @param report 报告单类型 *@return: com.ccsens.ht.bean.vo.PatientReportVo.ReportScore *@Author: wuHuiJuan *@date: 2019/11/19 11:46 */ - List queryReportScore(@Param("id") Long id,@Param("rey") int rey); + List queryReportScore(@Param("id") Long id,@Param("rey") int rey, @Param("report") String report); /** * 查询NPI的分数 diff --git a/ht/src/main/java/com/ccsens/ht/service/IImportService.java b/ht/src/main/java/com/ccsens/ht/service/IImportService.java index 4e496659..4cdb3e47 100644 --- a/ht/src/main/java/com/ccsens/ht/service/IImportService.java +++ b/ht/src/main/java/com/ccsens/ht/service/IImportService.java @@ -1,6 +1,7 @@ package com.ccsens.ht.service; import java.io.File; +import java.util.List; /** * @program: ptpro @@ -30,13 +31,14 @@ public interface IImportService { String importTitle(File file, int sheetIndex) throws Exception; /** *@Description:导入测评报告单分类 - *@param file - *@param sheetIndex + *@param file 文件 + *@param sheetIndex 第几个sheet *@return: void *@Author: wuhuijuan *@date: 2019/10/21 15:08 + * @return 报告单类型 */ - void importReport(File file, int sheetIndex) throws Exception; + List importReport(File file, int sheetIndex) throws Exception; /** *@Description:导入测评报告单分类 diff --git a/ht/src/main/java/com/ccsens/ht/service/ImportService.java b/ht/src/main/java/com/ccsens/ht/service/ImportService.java index 3097e9f9..a230d548 100644 --- a/ht/src/main/java/com/ccsens/ht/service/ImportService.java +++ b/ht/src/main/java/com/ccsens/ht/service/ImportService.java @@ -189,7 +189,8 @@ public class ImportService implements IImportService { } @Override - public void importReport(File file, int sheetIndex) throws Exception{ + public List importReport(File file, int sheetIndex) throws Exception{ + List codes = new ArrayList<>(); List reports = PoiUtil.readExce(file, sheetIndex, null,1, false); log.info("导入职务,读取数据完成"); List reportList = new ArrayList<>(); @@ -200,10 +201,14 @@ public class ImportService implements IImportService { } HtReport report = initReport(objs); reportList.add(report); + if (report.getType() == Constant.Ht.Report.TYPE_EVALUATION) { + codes.add(report.getCode()); + } } if (!reportList.isEmpty()) { htReportDao.insertBatch(reportList); } + return codes; } @Override @@ -216,7 +221,6 @@ public class ImportService implements IImportService { types.add(type); } log.info("导入试题类型:{}", types); - StringBuilder builder = new StringBuilder(); for (String sheetName: types) { List questions = PoiUtil.readExce(file, -1, sheetName,1, true); saveQuestions(questions, sheetName); diff --git a/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java b/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java index ba91682b..d1a83c0f 100644 --- a/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java +++ b/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java @@ -223,7 +223,7 @@ public class PatientReportService implements IPatientReportService { //查询报告单信息和病人信息 PatientReportVo.ReprotPatient reportPatient = htPatientReportDao.queryReportResult(queryDetail.getId()); //查询报告单分数 - List reportScore = htPatientReportDao.queryReportScore(queryDetail.getId(),queryDetail.getRey()); + List reportScore = htPatientReportDao.queryReportScore(queryDetail.getId(),queryDetail.getRey(), queryDetail.getReport()); //重新封装报告单信息 Map map = new HashMap<>(32); List scores = new ArrayList<>(); @@ -235,7 +235,7 @@ public class PatientReportService implements IPatientReportService { } map.put(score.getCode(), score); //测评类(MOCA等) - if (Constant.Ht.Report.TYPE_EVALUATION.equals(score.getType())) { + if (Constant.Ht.Report.TYPE_EVALUATION == score.getType()) { String specialCode = "NPI"; if (specialCode.equalsIgnoreCase(score.getCode())) { initNPI(queryDetail, score); diff --git a/ht/src/main/java/com/ccsens/ht/uitl/Constant.java b/ht/src/main/java/com/ccsens/ht/uitl/Constant.java index 93199c3a..763e6c2a 100644 --- a/ht/src/main/java/com/ccsens/ht/uitl/Constant.java +++ b/ht/src/main/java/com/ccsens/ht/uitl/Constant.java @@ -127,7 +127,7 @@ public class Constant { public static class Report{ public final static String PARENT_CODE = "REPORT1.0"; public final static String PARENT_NAME = "认知功能神经心理量表检查报告单"; - public final static Byte TYPE_EVALUATION = 2; + public final static byte TYPE_EVALUATION = 2; public final static String IGNORE_SCORE = "[个]"; public final static String MOCA_SJZ = "SZJ"; public final static String MOCA = "MoCA"; @@ -142,6 +142,9 @@ public class Constant { /**忽略报告单*/ public final static Byte COMPLETE_IGNORE = 2; + + + /**在历史报告单中显示*/ public final static byte SHOW_HISTORY = 1; public final static Map TYPE = new HashMap<>(); diff --git a/ht/src/main/resources/application.yml b/ht/src/main/resources/application.yml index 5889ff7f..d082c0ea 100644 --- a/ht/src/main/resources/application.yml +++ b/ht/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: - active: test - include: common, util-test \ No newline at end of file + active: prod + include: common, util-prod \ No newline at end of file diff --git a/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml b/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml index acf5782d..7426b0cc 100644 --- a/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml +++ b/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml @@ -47,14 +47,21 @@ + \ No newline at end of file diff --git a/ht/src/main/resources/mapper_raw/HtPatientReportRecordDescMapper.xml b/ht/src/main/resources/mapper_raw/HtPatientReportRecordDescMapper.xml new file mode 100644 index 00000000..10073a09 --- /dev/null +++ b/ht/src/main/resources/mapper_raw/HtPatientReportRecordDescMapper.xml @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, patient_report_id, record_id, answer, remark, create_time, update_time, is_del, + answer_time + + + + + delete from t_ht_patient_report_record_desc + where id = #{id,jdbcType=BIGINT} + + + delete from t_ht_patient_report_record_desc + + + + + + insert into t_ht_patient_report_record_desc (id, patient_report_id, record_id, + answer, remark, create_time, + update_time, is_del, answer_time + ) + values (#{id,jdbcType=BIGINT}, #{patientReportId,jdbcType=BIGINT}, #{recordId,jdbcType=BIGINT}, + #{answer,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, + #{updateTime,jdbcType=TIMESTAMP}, #{isDel,jdbcType=TINYINT}, #{answerTime,jdbcType=BIGINT} + ) + + + insert into t_ht_patient_report_record_desc + + + id, + + + patient_report_id, + + + record_id, + + + answer, + + + remark, + + + create_time, + + + update_time, + + + is_del, + + + answer_time, + + + + + #{id,jdbcType=BIGINT}, + + + #{patientReportId,jdbcType=BIGINT}, + + + #{recordId,jdbcType=BIGINT}, + + + #{answer,jdbcType=VARCHAR}, + + + #{remark,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{isDel,jdbcType=TINYINT}, + + + #{answerTime,jdbcType=BIGINT}, + + + + + + update t_ht_patient_report_record_desc + + + id = #{record.id,jdbcType=BIGINT}, + + + patient_report_id = #{record.patientReportId,jdbcType=BIGINT}, + + + record_id = #{record.recordId,jdbcType=BIGINT}, + + + answer = #{record.answer,jdbcType=VARCHAR}, + + + remark = #{record.remark,jdbcType=VARCHAR}, + + + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + + + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + + + is_del = #{record.isDel,jdbcType=TINYINT}, + + + answer_time = #{record.answerTime,jdbcType=BIGINT}, + + + + + + + + update t_ht_patient_report_record_desc + set id = #{record.id,jdbcType=BIGINT}, + patient_report_id = #{record.patientReportId,jdbcType=BIGINT}, + record_id = #{record.recordId,jdbcType=BIGINT}, + answer = #{record.answer,jdbcType=VARCHAR}, + remark = #{record.remark,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + is_del = #{record.isDel,jdbcType=TINYINT}, + answer_time = #{record.answerTime,jdbcType=BIGINT} + + + + + + update t_ht_patient_report_record_desc + + + patient_report_id = #{patientReportId,jdbcType=BIGINT}, + + + record_id = #{recordId,jdbcType=BIGINT}, + + + answer = #{answer,jdbcType=VARCHAR}, + + + remark = #{remark,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + is_del = #{isDel,jdbcType=TINYINT}, + + + answer_time = #{answerTime,jdbcType=BIGINT}, + + + where id = #{id,jdbcType=BIGINT} + + + update t_ht_patient_report_record_desc + set patient_report_id = #{patientReportId,jdbcType=BIGINT}, + record_id = #{recordId,jdbcType=BIGINT}, + answer = #{answer,jdbcType=VARCHAR}, + remark = #{remark,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = #{updateTime,jdbcType=TIMESTAMP}, + is_del = #{isDel,jdbcType=TINYINT}, + answer_time = #{answerTime,jdbcType=BIGINT} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/ht/src/main/resources/mapper_raw/HtQuestionMapper.xml b/ht/src/main/resources/mapper_raw/HtQuestionMapper.xml index 8675e6b5..bbcd9f56 100644 --- a/ht/src/main/resources/mapper_raw/HtQuestionMapper.xml +++ b/ht/src/main/resources/mapper_raw/HtQuestionMapper.xml @@ -11,6 +11,7 @@ + @@ -82,8 +83,8 @@ id, evaluation_code, parent_code, sort, question, type, record_type, record_content, - relation_code, operate_type, recode_starttime, time_wabei, allow_clear, clear_times, - timing_length, remark, create_time, update_time, is_del + relation_code, relation_id, operate_type, recode_starttime, time_wabei, allow_clear, + clear_times, timing_length, remark, create_time, update_time, is_del + select + + distinct + + + from t_ht_question_option_desc + + + + + order by ${orderByClause} + + + + + delete from t_ht_question_option_desc + where id = #{id,jdbcType=BIGINT} + + + delete from t_ht_question_option_desc + + + + + + insert into t_ht_question_option_desc (id, option_id, sort, + type, content, remark, + create_time, update_time, is_del + ) + values (#{id,jdbcType=BIGINT}, #{optionId,jdbcType=BIGINT}, #{sort,jdbcType=INTEGER}, + #{type,jdbcType=TINYINT}, #{content,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, + #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{isDel,jdbcType=TINYINT} + ) + + + insert into t_ht_question_option_desc + + + id, + + + option_id, + + + sort, + + + type, + + + content, + + + remark, + + + create_time, + + + update_time, + + + is_del, + + + + + #{id,jdbcType=BIGINT}, + + + #{optionId,jdbcType=BIGINT}, + + + #{sort,jdbcType=INTEGER}, + + + #{type,jdbcType=TINYINT}, + + + #{content,jdbcType=VARCHAR}, + + + #{remark,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{isDel,jdbcType=TINYINT}, + + + + + + update t_ht_question_option_desc + + + id = #{record.id,jdbcType=BIGINT}, + + + option_id = #{record.optionId,jdbcType=BIGINT}, + + + sort = #{record.sort,jdbcType=INTEGER}, + + + type = #{record.type,jdbcType=TINYINT}, + + + content = #{record.content,jdbcType=VARCHAR}, + + + remark = #{record.remark,jdbcType=VARCHAR}, + + + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + + + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + + + is_del = #{record.isDel,jdbcType=TINYINT}, + + + + + + + + update t_ht_question_option_desc + set id = #{record.id,jdbcType=BIGINT}, + option_id = #{record.optionId,jdbcType=BIGINT}, + sort = #{record.sort,jdbcType=INTEGER}, + type = #{record.type,jdbcType=TINYINT}, + content = #{record.content,jdbcType=VARCHAR}, + remark = #{record.remark,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + is_del = #{record.isDel,jdbcType=TINYINT} + + + + + + update t_ht_question_option_desc + + + option_id = #{optionId,jdbcType=BIGINT}, + + + sort = #{sort,jdbcType=INTEGER}, + + + type = #{type,jdbcType=TINYINT}, + + + content = #{content,jdbcType=VARCHAR}, + + + remark = #{remark,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + is_del = #{isDel,jdbcType=TINYINT}, + + + where id = #{id,jdbcType=BIGINT} + + + update t_ht_question_option_desc + set option_id = #{optionId,jdbcType=BIGINT}, + sort = #{sort,jdbcType=INTEGER}, + type = #{type,jdbcType=TINYINT}, + content = #{content,jdbcType=VARCHAR}, + remark = #{remark,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = #{updateTime,jdbcType=TIMESTAMP}, + is_del = #{isDel,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/ht/src/main/resources/mapper_raw/HtQuestionRecordMapper.xml b/ht/src/main/resources/mapper_raw/HtQuestionRecordMapper.xml new file mode 100644 index 00000000..496d8ea1 --- /dev/null +++ b/ht/src/main/resources/mapper_raw/HtQuestionRecordMapper.xml @@ -0,0 +1,338 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, record_type, question_id, sort, calc_type, show_title, show_form, default_value, + type, remark, create_time, update_time, is_del + + + + + delete from t_ht_question_record + where id = #{id,jdbcType=BIGINT} + + + delete from t_ht_question_record + + + + + + insert into t_ht_question_record (id, record_type, question_id, + sort, calc_type, show_title, + show_form, default_value, type, + remark, create_time, update_time, + is_del) + values (#{id,jdbcType=BIGINT}, #{recordType,jdbcType=TINYINT}, #{questionId,jdbcType=BIGINT}, + #{sort,jdbcType=INTEGER}, #{calcType,jdbcType=TINYINT}, #{showTitle,jdbcType=VARCHAR}, + #{showForm,jdbcType=VARCHAR}, #{defaultValue,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, + #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, + #{isDel,jdbcType=TINYINT}) + + + insert into t_ht_question_record + + + id, + + + record_type, + + + question_id, + + + sort, + + + calc_type, + + + show_title, + + + show_form, + + + default_value, + + + type, + + + remark, + + + create_time, + + + update_time, + + + is_del, + + + + + #{id,jdbcType=BIGINT}, + + + #{recordType,jdbcType=TINYINT}, + + + #{questionId,jdbcType=BIGINT}, + + + #{sort,jdbcType=INTEGER}, + + + #{calcType,jdbcType=TINYINT}, + + + #{showTitle,jdbcType=VARCHAR}, + + + #{showForm,jdbcType=VARCHAR}, + + + #{defaultValue,jdbcType=VARCHAR}, + + + #{type,jdbcType=TINYINT}, + + + #{remark,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{isDel,jdbcType=TINYINT}, + + + + + + update t_ht_question_record + + + id = #{record.id,jdbcType=BIGINT}, + + + record_type = #{record.recordType,jdbcType=TINYINT}, + + + question_id = #{record.questionId,jdbcType=BIGINT}, + + + sort = #{record.sort,jdbcType=INTEGER}, + + + calc_type = #{record.calcType,jdbcType=TINYINT}, + + + show_title = #{record.showTitle,jdbcType=VARCHAR}, + + + show_form = #{record.showForm,jdbcType=VARCHAR}, + + + default_value = #{record.defaultValue,jdbcType=VARCHAR}, + + + type = #{record.type,jdbcType=TINYINT}, + + + remark = #{record.remark,jdbcType=VARCHAR}, + + + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + + + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + + + is_del = #{record.isDel,jdbcType=TINYINT}, + + + + + + + + update t_ht_question_record + set id = #{record.id,jdbcType=BIGINT}, + record_type = #{record.recordType,jdbcType=TINYINT}, + question_id = #{record.questionId,jdbcType=BIGINT}, + sort = #{record.sort,jdbcType=INTEGER}, + calc_type = #{record.calcType,jdbcType=TINYINT}, + show_title = #{record.showTitle,jdbcType=VARCHAR}, + show_form = #{record.showForm,jdbcType=VARCHAR}, + default_value = #{record.defaultValue,jdbcType=VARCHAR}, + type = #{record.type,jdbcType=TINYINT}, + remark = #{record.remark,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + is_del = #{record.isDel,jdbcType=TINYINT} + + + + + + update t_ht_question_record + + + record_type = #{recordType,jdbcType=TINYINT}, + + + question_id = #{questionId,jdbcType=BIGINT}, + + + sort = #{sort,jdbcType=INTEGER}, + + + calc_type = #{calcType,jdbcType=TINYINT}, + + + show_title = #{showTitle,jdbcType=VARCHAR}, + + + show_form = #{showForm,jdbcType=VARCHAR}, + + + default_value = #{defaultValue,jdbcType=VARCHAR}, + + + type = #{type,jdbcType=TINYINT}, + + + remark = #{remark,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + is_del = #{isDel,jdbcType=TINYINT}, + + + where id = #{id,jdbcType=BIGINT} + + + update t_ht_question_record + set record_type = #{recordType,jdbcType=TINYINT}, + question_id = #{questionId,jdbcType=BIGINT}, + sort = #{sort,jdbcType=INTEGER}, + calc_type = #{calcType,jdbcType=TINYINT}, + show_title = #{showTitle,jdbcType=VARCHAR}, + show_form = #{showForm,jdbcType=VARCHAR}, + default_value = #{defaultValue,jdbcType=VARCHAR}, + type = #{type,jdbcType=TINYINT}, + remark = #{remark,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = #{updateTime,jdbcType=TIMESTAMP}, + is_del = #{isDel,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/ht/src/main/resources/mapper_raw/HtQuestionRecordOptionMapper.xml b/ht/src/main/resources/mapper_raw/HtQuestionRecordOptionMapper.xml new file mode 100644 index 00000000..d7974c20 --- /dev/null +++ b/ht/src/main/resources/mapper_raw/HtQuestionRecordOptionMapper.xml @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, question_record_id, sort, data_key, data_value, remark, create_time, update_time, + is_del + + + + + delete from t_ht_question_record_option + where id = #{id,jdbcType=BIGINT} + + + delete from t_ht_question_record_option + + + + + + insert into t_ht_question_record_option (id, question_record_id, sort, + data_key, data_value, remark, + create_time, update_time, is_del + ) + values (#{id,jdbcType=BIGINT}, #{questionRecordId,jdbcType=BIGINT}, #{sort,jdbcType=INTEGER}, + #{dataKey,jdbcType=VARCHAR}, #{dataValue,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, + #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{isDel,jdbcType=TINYINT} + ) + + + insert into t_ht_question_record_option + + + id, + + + question_record_id, + + + sort, + + + data_key, + + + data_value, + + + remark, + + + create_time, + + + update_time, + + + is_del, + + + + + #{id,jdbcType=BIGINT}, + + + #{questionRecordId,jdbcType=BIGINT}, + + + #{sort,jdbcType=INTEGER}, + + + #{dataKey,jdbcType=VARCHAR}, + + + #{dataValue,jdbcType=VARCHAR}, + + + #{remark,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + #{isDel,jdbcType=TINYINT}, + + + + + + update t_ht_question_record_option + + + id = #{record.id,jdbcType=BIGINT}, + + + question_record_id = #{record.questionRecordId,jdbcType=BIGINT}, + + + sort = #{record.sort,jdbcType=INTEGER}, + + + data_key = #{record.dataKey,jdbcType=VARCHAR}, + + + data_value = #{record.dataValue,jdbcType=VARCHAR}, + + + remark = #{record.remark,jdbcType=VARCHAR}, + + + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + + + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + + + is_del = #{record.isDel,jdbcType=TINYINT}, + + + + + + + + update t_ht_question_record_option + set id = #{record.id,jdbcType=BIGINT}, + question_record_id = #{record.questionRecordId,jdbcType=BIGINT}, + sort = #{record.sort,jdbcType=INTEGER}, + data_key = #{record.dataKey,jdbcType=VARCHAR}, + data_value = #{record.dataValue,jdbcType=VARCHAR}, + remark = #{record.remark,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + is_del = #{record.isDel,jdbcType=TINYINT} + + + + + + update t_ht_question_record_option + + + question_record_id = #{questionRecordId,jdbcType=BIGINT}, + + + sort = #{sort,jdbcType=INTEGER}, + + + data_key = #{dataKey,jdbcType=VARCHAR}, + + + data_value = #{dataValue,jdbcType=VARCHAR}, + + + remark = #{remark,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + is_del = #{isDel,jdbcType=TINYINT}, + + + where id = #{id,jdbcType=BIGINT} + + + update t_ht_question_record_option + set question_record_id = #{questionRecordId,jdbcType=BIGINT}, + sort = #{sort,jdbcType=INTEGER}, + data_key = #{dataKey,jdbcType=VARCHAR}, + data_value = #{dataValue,jdbcType=VARCHAR}, + remark = #{remark,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = #{updateTime,jdbcType=TIMESTAMP}, + is_del = #{isDel,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file From 48410cdf032b0587c2a29fbcf154cf4dafc109b8 Mon Sep 17 00:00:00 2001 From: zhizhi wu <2377881365@qq.com> Date: Wed, 21 Apr 2021 19:04:59 +0800 Subject: [PATCH 12/30] =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ccsens/ht/api/ImportController.java | 23 ++- .../ht/api/PatientReportController.java | 18 +- .../ht/api/PatientReportExportController.java | 59 +++++++ .../ccsens/ht/bean/dto/PatientReportDto.java | 12 +- .../com/ccsens/ht/bean/vo/QuestionVo.java | 16 +- .../ccsens/ht/persist/dao/HtQuestionDao.java | 9 + .../ccsens/ht/persist/dao/HtReportDao.java | 10 +- .../com/ccsens/ht/service/IImportService.java | 13 +- .../com/ccsens/ht/service/ImportService.java | 155 +++++++++++------- .../ccsens/ht/service/QuestionService.java | 42 ++--- .../resources/mapper_dao/HtQuestionDao.xml | 97 +++++++++-- .../mapper_dao/HtQuestionOptionDao.xml | 15 +- .../main/resources/mapper_dao/HtReportDao.xml | 61 +++++-- 13 files changed, 379 insertions(+), 151 deletions(-) create mode 100644 ht/src/main/java/com/ccsens/ht/api/PatientReportExportController.java diff --git a/ht/src/main/java/com/ccsens/ht/api/ImportController.java b/ht/src/main/java/com/ccsens/ht/api/ImportController.java index 6e9a82c8..c6cd339e 100644 --- a/ht/src/main/java/com/ccsens/ht/api/ImportController.java +++ b/ht/src/main/java/com/ccsens/ht/api/ImportController.java @@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.Part; import java.io.File; -import java.util.Collections; import java.util.List; @@ -69,7 +68,8 @@ public class ImportController { List codes = importService.importReport(excelFile, 2); long time5 = System.currentTimeMillis(); log.info("导入报告单耗时:{}", (time5 - time4)); - + importService.importReportRecord(excelFile, 3); + log.info("导入报告单其他记录耗时:{}", System.currentTimeMillis() - time5); if (CollectionUtil.isNotEmpty(codes)) { for (String code: codes) { importService.importQuestion(excelFile, code); @@ -99,11 +99,22 @@ public class ImportController { String dir = WebConstant.UPLOAD_PROJECT_WBS + File.separator; String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExts, dir); File excelFile = new File(dir+path); - long time2 = System.currentTimeMillis(); - long time4 = System.currentTimeMillis(); importService.importReport(excelFile, 2); - long time5 = System.currentTimeMillis(); - log.info("导入报告单耗时:{}", (time5 - time4)); + return JsonResponse.newInstance().ok(); + } + + @ApiOperation(value = "单独导入报告单类型",notes = "文件大小不能超过20M,支持后缀:.xls|.xlsx") + @ApiImplicitParams({ + @ApiImplicitParam(name = "file", value = "医疗项目表", required = true, paramType = "form",dataType = "__file") + }) + @RequestMapping(value = "/importReportTypeRecord", method = RequestMethod.POST) + public JsonResponse importReportTypeRecord(@RequestParam(required = true) Part file) throws Exception{ + //1.上传文件 + String allowedExts = "xls,xlsx"; + String dir = WebConstant.UPLOAD_PROJECT_WBS + File.separator; + String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExts, dir); + File excelFile = new File(dir+path); + importService.importReportRecord(excelFile, 3); return JsonResponse.newInstance().ok(); } diff --git a/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java b/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java index 55edf517..771d4df3 100644 --- a/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java +++ b/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java @@ -143,20 +143,10 @@ public class PatientReportController { return JsonResponse.newInstance().ok(authority); } - @ApiOperation(value = "导出报告单",notes = "导出报告单") - @ApiImplicitParams({ - @ApiImplicitParam(name = "json", value = "导出报告单", required = true) - }) - @RequestMapping(value="/exportReport", method = RequestMethod.POST) - public JsonResponse exportReport(@RequestBody @ApiParam @Valid QueryDto param){ - //查询报告单信息 - log.info("查询报告单详情:{}", param); - String path = patientReportService.exportReport(param.getParam(), param.getUserId()); - log.info("文件路径:{}", path); - PatientReportVo.Export export = new PatientReportVo.Export(); - export.setPath(path); - return JsonResponse.newInstance().ok(export); - } + + + + @ApiOperation(value = "分享报告单",notes = "分享报告单") @ApiImplicitParams({ diff --git a/ht/src/main/java/com/ccsens/ht/api/PatientReportExportController.java b/ht/src/main/java/com/ccsens/ht/api/PatientReportExportController.java new file mode 100644 index 00000000..6cb35235 --- /dev/null +++ b/ht/src/main/java/com/ccsens/ht/api/PatientReportExportController.java @@ -0,0 +1,59 @@ +package com.ccsens.ht.api; + +import com.ccsens.ht.bean.dto.PatientReportDto; +import com.ccsens.ht.bean.vo.PatientReportVo; +import com.ccsens.ht.service.IPatientReportService; +import com.ccsens.util.JsonResponse; +import com.ccsens.util.bean.dto.QueryDto; +import io.swagger.annotations.*; +import lombok.extern.slf4j.Slf4j; +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.validation.Valid; + +/** + * @description: + * @author: whj + * @time: 2021/4/21 19:01 + */ +@Slf4j +@Api(tags = "报告单导出",value = "报告单导出") +@RestController +public class PatientReportExportController { + @Resource + private IPatientReportService patientReportService; + + @ApiOperation(value = "导出报告单",notes = "导出报告单") + @ApiImplicitParams({ + @ApiImplicitParam(name = "json", value = "导出报告单", required = true) + }) + @RequestMapping(value="/exportReport", method = RequestMethod.POST) + public JsonResponse exportReport(@RequestBody @ApiParam @Valid QueryDto param){ + //查询报告单信息 + log.info("查询报告单详情:{}", param); + String path = patientReportService.exportReport(param.getParam(), param.getUserId()); + log.info("文件路径:{}", path); + PatientReportVo.Export export = new PatientReportVo.Export(); + export.setPath(path); + return JsonResponse.newInstance().ok(export); + } + + @ApiOperation(value = "导出指定报告单",notes = "导出报告单") + @ApiImplicitParams({ + @ApiImplicitParam(name = "json", value = "导出报告单", required = true) + }) + @RequestMapping(value="/export", method = RequestMethod.POST) + public JsonResponse export(@RequestBody @ApiParam @Valid QueryDto param){ + //查询报告单信息 + log.info("导出指定报告单:{}", param); + String path = patientReportService.export(param.getParam(), param.getUserId()); + log.info("文件路径:{}", path); + PatientReportVo.Export export = new PatientReportVo.Export(); + export.setPath(path); + return JsonResponse.newInstance().ok(export); + } +} diff --git a/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java b/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java index b3c18771..78c735a6 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java +++ b/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java @@ -86,7 +86,17 @@ public class PatientReportDto { @ApiModelProperty("报告单类型") private String report = "REPORT1.0"; } - + + @ApiModel("导出指定某一种报告单") + @Data + public static class ExportCode{ + @ApiModelProperty("病人报告单ID") + @NotNull(message = "病人报告单ID不能为空") + private Long id; + @ApiModelProperty("报告单类型") + private String code; + } + /**医生对报告单权限*/ @ApiModel("PatientReportDtoAuthority") diff --git a/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java b/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java index e57226d1..33daf6da 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java +++ b/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java @@ -117,6 +117,8 @@ public class QuestionVo { public static class Question{ @ApiModelProperty("试题ID") private Long id; + @ApiModelProperty("一级评测类型") + private String evaluationCode; @ApiModelProperty("评测类型") private String parentCode; @ApiModelProperty("排序") @@ -141,8 +143,8 @@ public class QuestionVo { private Integer clearTimes; @ApiModelProperty("定时器时长") private Integer timingLength; - @ApiModelProperty("答案路径") - private String path; +// @ApiModelProperty("答案路径") +// private String path; @ApiModelProperty("共享答案的试题Id") private List shareAnswerIds; @ApiModelProperty("是否展示关联的试题的答案 0否 1是") @@ -186,9 +188,6 @@ public class QuestionVo { public static final class QuestionRecord{ @ApiModelProperty("id") private Long id; - private Byte recordType; - private Long questionId; - private Integer sort; @ApiModelProperty("0:点击过程 1:自动计算 2:手动计算") private Byte calcType; @ApiModelProperty("显示内容") @@ -201,6 +200,8 @@ public class QuestionVo { private Byte type; @ApiModelProperty("备注") private String remark; + @ApiModelProperty("答案") + private List answers; } @Data @@ -251,8 +252,13 @@ public class QuestionVo { private String answer; @ApiModelProperty("是否选中") private Byte choose; + @ApiModelProperty("选项补充") + private List optionDescList; + } + + @Data @ApiModel("QuestionVoIntroduce") public static class Introduce { diff --git a/ht/src/main/java/com/ccsens/ht/persist/dao/HtQuestionDao.java b/ht/src/main/java/com/ccsens/ht/persist/dao/HtQuestionDao.java index 400b2231..50bd2dda 100644 --- a/ht/src/main/java/com/ccsens/ht/persist/dao/HtQuestionDao.java +++ b/ht/src/main/java/com/ccsens/ht/persist/dao/HtQuestionDao.java @@ -28,4 +28,13 @@ public interface HtQuestionDao extends HtQuestionMapper { * 查询可以共享答案的试题id */ List queryShareAnswer(@Param("questionId")Long questionId, @Param("patientReportId") Long patientReportId); + + /** + * 查询试题和其他记录,以及其他记录的答案 + * @param code evaluation_code + * @param num sort + * @param patientReportId 报告单ID + * @return 试题 + */ + QuestionVo.Question queryQuestionAndRecord(@Param("code") String code, @Param("num") int num, @Param("patientReportId") Long patientReportId); } diff --git a/ht/src/main/java/com/ccsens/ht/persist/dao/HtReportDao.java b/ht/src/main/java/com/ccsens/ht/persist/dao/HtReportDao.java index 68e84f72..010b8dc1 100644 --- a/ht/src/main/java/com/ccsens/ht/persist/dao/HtReportDao.java +++ b/ht/src/main/java/com/ccsens/ht/persist/dao/HtReportDao.java @@ -2,10 +2,10 @@ package com.ccsens.ht.persist.dao; import com.ccsens.ht.bean.po.HtReport; import com.ccsens.ht.bean.vo.PatientReportSearchVo; +import com.ccsens.ht.bean.vo.QuestionVo; import com.ccsens.ht.persist.mapper.HtReportMapper; import org.apache.ibatis.annotations.Param; -import java.util.Collection; import java.util.List; /** @@ -45,4 +45,12 @@ public interface HtReportDao extends HtReportMapper { * @return code */ List queryCode(@Param("type") byte type); + + /** + * 查询报告单和记录 + * @param code code + * @param patientReportId patientReportId + * @return report+record + */ + QuestionVo.Report queryReportAndRecord(@Param("code") String code, @Param("patientReportId") Long patientReportId); } diff --git a/ht/src/main/java/com/ccsens/ht/service/IImportService.java b/ht/src/main/java/com/ccsens/ht/service/IImportService.java index 4cdb3e47..2af8951f 100644 --- a/ht/src/main/java/com/ccsens/ht/service/IImportService.java +++ b/ht/src/main/java/com/ccsens/ht/service/IImportService.java @@ -31,14 +31,14 @@ public interface IImportService { String importTitle(File file, int sheetIndex) throws Exception; /** *@Description:导入测评报告单分类 - *@param file 文件 - *@param sheetIndex 第几个sheet *@return: void *@Author: wuhuijuan *@date: 2019/10/21 15:08 * @return 报告单类型 + * @param file 文件 + * @param index report是第几个sheet */ - List importReport(File file, int sheetIndex) throws Exception; + List importReport(File file, int index) throws Exception; /** *@Description:导入测评报告单分类 @@ -49,4 +49,11 @@ public interface IImportService { *@date: 2019/10/21 15:08 */ void importQuestion(File file, String type) throws Exception; + + /** + * 导入报告单其他记录 + * @param excelFile excel + * @param sheetIndex 第几个 + */ + void importReportRecord(File excelFile, int sheetIndex) throws Exception; } diff --git a/ht/src/main/java/com/ccsens/ht/service/ImportService.java b/ht/src/main/java/com/ccsens/ht/service/ImportService.java index f89ac511..9d162fa6 100644 --- a/ht/src/main/java/com/ccsens/ht/service/ImportService.java +++ b/ht/src/main/java/com/ccsens/ht/service/ImportService.java @@ -9,9 +9,11 @@ import com.alibaba.fastjson.JSONObject; import com.ccsens.ht.bean.po.*; import com.ccsens.ht.persist.dao.*; import com.ccsens.ht.uitl.Constant; +import com.ccsens.util.CodeEnum; import com.ccsens.util.PoiUtil; import com.ccsens.util.PropUtil; import com.ccsens.util.StringUtil; +import com.ccsens.util.exception.BaseException; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -237,6 +239,40 @@ public class ImportService implements IImportService { } } + @Override + public void importReportRecord(File excelFile, int sheetIndex) throws Exception { + + List reports = PoiUtil.readExce(excelFile, sheetIndex, null,1, false); + log.info("导入报告单其他记录,读取数据完成"); + List htReports = htReportDao.selectByExample(new HtReportExample()); + Map reportMap = new HashMap<>(); + htReports.forEach(htReport -> reportMap.put(htReport.getCode(), htReport.getId())); + log.info("报告单类型查询完成"); + + List reportRecordList = new ArrayList<>(); + List optionList = new ArrayList<>(); + for (Object[] objs: reports) { + if (!pageData(objs)) { + log.info("测评报告单数据不足,跳转下一行"); + continue; + } + Long id = reportMap.get(String.valueOf(objs[0])); + if (id == null) { + log.info("报告单类型不存在:{}", objs[0]); + throw new BaseException(CodeEnum.PARAM_ERROR); + } + HtQuestionRecord record = initRecord(objs, id , optionList, Constant.Ht.QuestionRecord.RECORD_TYPE_CODE, 1); + reportRecordList.add(record); + + } + if (!reportRecordList.isEmpty()) { + htQuestionRecordDao.insertBatch(reportRecordList); + } + if (!optionList.isEmpty()) { + htQuestionRecordOptionDao.insertBatch(optionList); + } + } + /** * 保存试题 * */ @@ -259,60 +295,7 @@ public class ImportService implements IImportService { int sort = objs.length > 3 && StringUtil.checkNum(String.valueOf(objs[3]), false) ? Integer.parseInt(String.valueOf(objs[3])) : 1; String type = String.valueOf(objs[0]); - switch (type) { - case Constant.Import.EVALUATION_QUESTION : - HtQuestion question = initQuestion(objs, evaluationCode, sort); - question.setEvaluationCode(parentCode.getOrDefault(question.getParentCode(), question.getEvaluationCode())); - questionList.add(question); - break; - case Constant.Import.EVALUATION_RELATION: - HtQuestion relationQuestion = initQuestion(objs, evaluationCode, sort); - relationQuestion.setEvaluationCode(parentCode.getOrDefault(relationQuestion.getParentCode(), relationQuestion.getEvaluationCode())); - if (CollectionUtil.isNotEmpty(questionList)) { - HtQuestion prev = questionList.get(questionList.size() - 1); - if (prev.getRelationId() != null && prev.getRelationId() >0) { - prev.setRelationId(prev.getRelationId()); - } else { - prev.setRelationId(prev.getId()); - } - } - questionList.add(relationQuestion); - break; - case Constant.Import.EVALUATION_OPTION : - if (questionList.isEmpty()) { - break; - } - HtQuestionOption option = initOption(objs, questionList.get(questionList.size()-1).getId(), sort, optionDescList, optionDescDelList); - optionList.add(option); - break; - case Constant.Import.EVALUATION_PARSE : - if (questionList.isEmpty()) { - break; - } - HtQuestionIntroducer introduce = initIntroduce(objs, questionList.get(questionList.size()-1).getId(), sort); - introduceList.add(introduce); - break; - case Constant.Import.EVALUATION_RULE : - if (questionList.isEmpty()) { - break; - } - HtQuestionScoringRule rule = initRule(objs, questionList.get(questionList.size() - 1).getId()); - ruleList.add(rule); - break; - case Constant.Import.EVALUATION_RECORD: - if (questionList.isEmpty()) { - break; - } - HtQuestionRecord record = initRecord(objs, questionList.get(questionList.size() - 1).getId(), questionRecordOptionList); - questionRecordList.add(record); - break; - default: - log.info("{}类型未知,不解析", type); - break; - } - - - + initData(evaluationCode, questionList, optionList, introduceList, ruleList, questionRecordList, questionRecordOptionList, optionDescList, optionDescDelList, parentCode, objs, sort, type); } if (!questionList.isEmpty()) { @@ -341,6 +324,63 @@ public class ImportService implements IImportService { } } + /** + * 试题导入:将obj[] 转换成 对应的data + */ + private void initData(String evaluationCode, List questionList, List optionList, List introduceList, List ruleList, List questionRecordList, List questionRecordOptionList, List optionDescList, List optionDescDelList, Map parentCode, Object[] objs, int sort, String type) { + switch (type) { + case Constant.Import.EVALUATION_QUESTION : + HtQuestion question = initQuestion(objs, evaluationCode, sort); + question.setEvaluationCode(parentCode.getOrDefault(question.getParentCode(), question.getEvaluationCode())); + questionList.add(question); + break; + case Constant.Import.EVALUATION_RELATION: + HtQuestion relationQuestion = initQuestion(objs, evaluationCode, sort); + relationQuestion.setEvaluationCode(parentCode.getOrDefault(relationQuestion.getParentCode(), relationQuestion.getEvaluationCode())); + if (CollectionUtil.isNotEmpty(questionList)) { + HtQuestion prev = questionList.get(questionList.size() - 1); + if (prev.getRelationId() != null && prev.getRelationId() >0) { + prev.setRelationId(prev.getRelationId()); + } else { + prev.setRelationId(prev.getId()); + } + } + questionList.add(relationQuestion); + break; + case Constant.Import.EVALUATION_OPTION : + if (questionList.isEmpty()) { + break; + } + HtQuestionOption option = initOption(objs, questionList.get(questionList.size()-1).getId(), sort, optionDescList, optionDescDelList); + optionList.add(option); + break; + case Constant.Import.EVALUATION_PARSE : + if (questionList.isEmpty()) { + break; + } + HtQuestionIntroducer introduce = initIntroduce(objs, questionList.get(questionList.size()-1).getId(), sort); + introduceList.add(introduce); + break; + case Constant.Import.EVALUATION_RULE : + if (questionList.isEmpty()) { + break; + } + HtQuestionScoringRule rule = initRule(objs, questionList.get(questionList.size() - 1).getId()); + ruleList.add(rule); + break; + case Constant.Import.EVALUATION_RECORD: + if (questionList.isEmpty()) { + break; + } + HtQuestionRecord record = initRecord(objs, questionList.get(questionList.size() - 1).getId(), questionRecordOptionList, Constant.Ht.QuestionRecord.RECORD_TYPE_QUESTION, (byte)3); + questionRecordList.add(record); + break; + default: + log.info("{}类型未知,不解析", type); + break; + } + } + /** * 封装record 及 option * @param objs 一列 @@ -348,16 +388,16 @@ public class ImportService implements IImportService { * @param questionRecordOptions record选项 * @return record */ - private HtQuestionRecord initRecord(Object[] objs, Long id, List questionRecordOptions) { + private HtQuestionRecord initRecord(Object[] objs, Long id, List questionRecordOptions, byte recordType, int sortIndex ) { HtQuestionRecord record = new HtQuestionRecord(); String content = (String)objs[2]; JSONObject json = JSONObject.parseObject(content); BeanUtils.copyProperties(json, record); - record.setRecordType(Constant.Ht.QuestionRecord.RECORD_TYPE_QUESTION); + record.setRecordType(recordType); // 判断是否存在,设置id - int sortIndex = 3; int sort = StringUtil.checkNum(String.valueOf(objs[sortIndex]), false) ? Integer.parseInt(String.valueOf(objs[sortIndex])) : Constant.Ht.Question.RULE_TYPE_DEFAULT; + record.setSort(sort); HtQuestionRecordExample recordExample = new HtQuestionRecordExample(); recordExample.createCriteria().andQuestionIdEqualTo(id).andSortEqualTo(sort); List questionRecords = htQuestionRecordDao.selectByExample(recordExample); @@ -368,6 +408,7 @@ public class ImportService implements IImportService { record.setId(questionRecords.get(0).getId()); } + log.info("添加record:{}", record); if (!json.containsKey(Constant.Import.RELATION_OPTION)) { return record; diff --git a/ht/src/main/java/com/ccsens/ht/service/QuestionService.java b/ht/src/main/java/com/ccsens/ht/service/QuestionService.java index b3c7ca30..89988e81 100644 --- a/ht/src/main/java/com/ccsens/ht/service/QuestionService.java +++ b/ht/src/main/java/com/ccsens/ht/service/QuestionService.java @@ -75,25 +75,19 @@ public class QuestionService implements IQuestionService { @Override public QuestionVo.Query queryQuestion(QuestionDto.Query query, Long userId) { log.info("请求参数:{},{}", query, userId); - //TODO 1.根据类型和题号,查询试题 和 补充内容(含code的补充内容) - HtQuestionExample questionExample = new HtQuestionExample(); - questionExample.createCriteria().andEvaluationCodeEqualTo(query.getCode()).andSortEqualTo(query.getNum()); - List questionList = htQuestionDao.selectByExample(questionExample); - log.info("测评试题:{}", questionList); - - if (CollectionUtils.isEmpty(questionList)) { + //1.根据类型和题号,查询试题 和 补充内容 + QuestionVo.Question questionVo = htQuestionDao.queryQuestionAndRecord(query.getCode(), query.getNum(), query.getPatientReportId()); + if (questionVo == null) { throw new BaseException(CodeEnum.QUESTION_NOT_FOUND); } - HtQuestion question = questionList.get(0); - QuestionVo.Question questionVo = QuestionVo.Question.toQuestionVo(question); - - // TODO 查询code的补充内容,做缓存 + //获取code信息及补充信息 + QuestionVo.Report reportVo = htReportDao.queryReportAndRecord(questionVo.getParentCode(), query.getPatientReportId()); //检查当前试题是否有答案,共享答案的试题是否有答案 boolean f = false; if(ObjectUtil.isNotNull(query.getPatientReportId())){ HtPatientScoreExample scoreExample = new HtPatientScoreExample(); - scoreExample.createCriteria().andPatientReportIdEqualTo(query.getPatientReportId()).andQuestionIdEqualTo(question.getId()) + scoreExample.createCriteria().andPatientReportIdEqualTo(query.getPatientReportId()).andQuestionIdEqualTo(questionVo.getId()) .andTypeBetween((byte)0,(byte)1); if(htPatientScoreDao.countByExample(scoreExample) > 0){ f = true; @@ -103,7 +97,7 @@ public class QuestionService implements IQuestionService { //查询可以共享答案的试题的id List shareAnswerIds = new ArrayList<>(); - List shareAnswers = htQuestionDao.queryShareAnswer(question.getId(),query.getPatientReportId()); + List shareAnswers = htQuestionDao.queryShareAnswer(questionVo.getId(),query.getPatientReportId()); log.info("答案关联的试题id:{}", shareAnswers); if(CollectionUtil.isNotEmpty(shareAnswers)){ for(QuestionVo.ShareAnswer shareAnswer : shareAnswers){ @@ -122,22 +116,10 @@ public class QuestionService implements IQuestionService { - //TODO 获取评测信息及补充信息 - HtReportExample reportExample = new HtReportExample(); - reportExample.createCriteria().andCodeEqualTo(question.getEvaluationCode()); - List htReports = htReportDao.selectByExample(reportExample); - QuestionVo.Report reportVo = new QuestionVo.Report(); - if (CollectionUtil.isNotEmpty(htReports)) { - HtReport htReport = htReports.get(0); - reportVo.setCode(htReport.getCode()); - reportVo.setName(htReport.getName()); - } - - Integer maxSort = htQuestionDao.selectMaxSort(query.getCode()); //查询关联题目 HtQuestionExample example = new HtQuestionExample(); - example.createCriteria().andRelationIdEqualTo(question.getId()); + example.createCriteria().andRelationIdEqualTo(questionVo.getId()); example.setOrderByClause("id"); List relationQuestions = htQuestionDao.selectByExample(example); List vos = new ArrayList<>(); @@ -154,18 +136,18 @@ public class QuestionService implements IQuestionService { //试题引导语 HtQuestionIntroducerExample introduceExample = new HtQuestionIntroducerExample(); - introduceExample.createCriteria().andQuestionIdEqualTo(question.getId()); + introduceExample.createCriteria().andQuestionIdEqualTo(questionVo.getId()); introduceExample.setOrderByClause("sort"); List introduces = htQuestionIntroducerDao.selectByExample(introduceExample); List introduceVos = QuestionVo.Introduce.toIntroduces(introduces); - //TODO 试题选项 及补充 - List optionList = htQuestionOptionDao.queryOption(question.getId(), query.getPatientReportId()); + + List optionList = htQuestionOptionDao.queryOption(questionVo.getId(), query.getPatientReportId()); //答题记录 List recordVos; if (query.getPatientReportId() != null && query.getPatientReportId() != 0) { HtPatientQuestionRecordExample recordExample = new HtPatientQuestionRecordExample(); - recordExample.createCriteria().andPatientReportIdEqualTo(query.getPatientReportId()).andQuestionIdEqualTo(question.getId()); + recordExample.createCriteria().andPatientReportIdEqualTo(query.getPatientReportId()).andQuestionIdEqualTo(questionVo.getId()); recordExample.setOrderByClause("record_time"); List records = htPatientQuestionRecordMapper.selectByExample(recordExample); recordVos = QuestionVo.Record.toRecords(records); diff --git a/ht/src/main/resources/mapper_dao/HtQuestionDao.xml b/ht/src/main/resources/mapper_dao/HtQuestionDao.xml index 52cde333..9dd63370 100644 --- a/ht/src/main/resources/mapper_dao/HtQuestionDao.xml +++ b/ht/src/main/resources/mapper_dao/HtQuestionDao.xml @@ -1,29 +1,36 @@ - + - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + replace into t_ht_question (id, evaluation_code, parent_code, sort, question, type, record_type, record_content, relation_code, @@ -60,4 +67,60 @@ r.question_id = #{questionId} GROUP BY r.relevance_id + \ No newline at end of file diff --git a/ht/src/main/resources/mapper_dao/HtQuestionOptionDao.xml b/ht/src/main/resources/mapper_dao/HtQuestionOptionDao.xml index 296ed4a8..3a8c3294 100644 --- a/ht/src/main/resources/mapper_dao/HtQuestionOptionDao.xml +++ b/ht/src/main/resources/mapper_dao/HtQuestionOptionDao.xml @@ -23,9 +23,14 @@ + + + + + - + replace into t_ht_question_option (id, question_id, sort, type, name, score, display, remark, create_time, @@ -41,11 +46,15 @@ \ No newline at end of file diff --git a/ht/src/main/resources/mapper_dao/HtReportDao.xml b/ht/src/main/resources/mapper_dao/HtReportDao.xml index 68da8ab4..33ac4736 100644 --- a/ht/src/main/resources/mapper_dao/HtReportDao.xml +++ b/ht/src/main/resources/mapper_dao/HtReportDao.xml @@ -1,23 +1,24 @@ - - + - - - - - - - - - - + + + + + + + + + + + + - + replace into t_ht_report (id, code, name, parent_code, description, total_score, type, is_show, sort, @@ -32,7 +33,7 @@ - select * from t_ht_report where is_show = 1 and is_del = 0 order by type,sort select code from t_ht_report where type = #{type} and is_del = 0 + \ No newline at end of file From edfdd1d4e718cb5cec451b257936cbf72d40ae25 Mon Sep 17 00:00:00 2001 From: zhizhi wu <2377881365@qq.com> Date: Sun, 25 Apr 2021 10:34:44 +0800 Subject: [PATCH 13/30] =?UTF-8?q?=E5=8D=95=E4=B8=AA=E9=87=8F=E8=A1=A8?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ht/api/PatientReportExportController.java | 8 +- .../ccsens/ht/bean/vo/PatientReportVo.java | 288 ++++++++++++++-- .../ht/persist/dao/HtPatientReportDao.java | 16 + .../ht/service/IPatientReportService.java | 9 + .../com/ccsens/ht/service/ImportService.java | 7 +- .../ht/service/PatientReportService.java | 312 ++++++++++++++---- .../ccsens/ht/service/QuestionService.java | 33 +- .../java/com/ccsens/ht/uitl/Constant.java | 58 ++++ ht/src/main/resources/application.yml | 4 +- .../mapper_dao/HtPatientReportDao.xml | 57 +++- .../resources/mapper_dao/HtQuestionDao.xml | 1 + .../mapper_dao/HtQuestionOptionDao.xml | 4 +- .../service/PatientReportService.java | 3 +- .../main/java/com/ccsens/util/PdfUtil.java | 27 +- .../java/com/ccsens/util/PdfUtilTest.java | 2 +- 15 files changed, 695 insertions(+), 134 deletions(-) diff --git a/ht/src/main/java/com/ccsens/ht/api/PatientReportExportController.java b/ht/src/main/java/com/ccsens/ht/api/PatientReportExportController.java index 6cb35235..c758480b 100644 --- a/ht/src/main/java/com/ccsens/ht/api/PatientReportExportController.java +++ b/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 export(@RequestBody @ApiParam @Valid QueryDto param){ + public JsonResponse export(@RequestBody @ApiParam @Valid QueryDto param) { //查询报告单信息 log.info("导出指定报告单:{}", param); String path = patientReportService.export(param.getParam(), param.getUserId()); diff --git a/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java b/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java index 5a371bda..b777a8c7 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java +++ b/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java @@ -129,10 +129,49 @@ public class PatientReportVo { private String hospital; public List toPdfRow(){ + List rows = getInitRows(); + //第四栏 + rows.add( + fillRow( + "临床诊断:" + this.clinicalDiagnosis, + "","") + ); + + return rows; + } + + + public List toPdfSimpleCodeRow(){ + List 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 getInitRows() { Map 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,35 +248,57 @@ public class PatientReportVo { this.subReport.add(score); } + /** + * 将mmse的多层嵌套转成一层 + * @param score 报告 + * @param list 转换后的list + */ + public void dealMMSE(ReportScore score, List list) { + if (CollectionUtil.isEmpty(score.subReport)) { + list.add(score); + } else { + score.subReport.forEach(subScore -> dealMMSE(subScore, list)); + } + } + public List toRow() { - int colNum = 8; + int colNum = 8; int headNum = 2; List rows = new ArrayList<>(); if (CollectionUtil.isEmpty(subReport)) { - PdfUtil.Row row = new PdfUtil.Row(); - PdfUtil.Cell cell1 = new PdfUtil.Cell(); - 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 : "")); - cell2.setColSpan(colNum - headNum); - cell2.setBorderRight(1); - row.addCell(cell1); - row.addCell(cell2); - - rows.add(row); + 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)) { - fillMmseOrNpi(headNum, rows, mmse, npi); - } else { - fillMoca(rows); + 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 rows) { if (StrUtil.isBlank(this.description)) { - return rows; + return ; } PdfUtil.Row descRow = new PdfUtil.Row(); PdfUtil.Cell cell = new PdfUtil.Cell(); @@ -264,10 +311,156 @@ public class PatientReportVo { // MOCA中,视直觉单独展示 fillSzj(colNum, headNum, rows); + } + + private void toRowOnlyTotal(int colNum, int headNum, List rows) { + PdfUtil.Row row = new PdfUtil.Row(); + PdfUtil.Cell cell1 = new PdfUtil.Cell(); + 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 : "")); + cell2.setColSpan(colNum - headNum); + cell2.setBorderRight(1); + row.addCell(cell1); + row.addCell(cell2); + + rows.add(row); + } + + public List toSingleRow() { + int colNum = Constant.Ht.Report.HAMD.equalsIgnoreCase(code) ? 9 : 8; + int headNum = 2; + List 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: + fillMMSE(rows); + break; + case Constant.Ht.Report.NPI: + fillMmseOrNpi(headNum, rows, mmse, npi); + break; + case Constant.Ht.Report.MOCA: + fillMoca(rows); + break; + default: + fillCommon(rows); + break; + } + + + + } + toDescRow(colNum, headNum, rows); return rows; } + private void fillMMSE(List rows) { + List 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 rows) { + //总列数 + int total = Constant.Ht.Report.HAMD.equalsIgnoreCase(code) ? 9 : 8; + // 标题 + PdfUtil.Row row = new PdfUtil.Row(); + PdfUtil.Cell cell = new PdfUtil.Cell(); + cell.setContent(this.name + "(" + this.code + ")各项目的因子分和总分"); + + cell.setColSpan(total); + cell.setBorderTop(0); + cell.setBorderRight(0); + cell.setBorderLeft(0); + row.addCell(cell); + rows.add(row); + + // 默认两行 + 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 rows, String mmse, String npi) { PdfUtil.Row row1 = new PdfUtil.Row(); PdfUtil.Cell cell = new PdfUtil.Cell(); @@ -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