Browse Source

试题查询

master
6 years ago
parent
commit
540cd7fcb0
  1. 1
      ht/src/main/java/com/ccsens/ht/api/QuestionController.java
  2. 3
      ht/src/main/java/com/ccsens/ht/bean/dto/QuestionDto.java
  3. 54
      ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java
  4. 6
      ht/src/main/java/com/ccsens/ht/config/SpringConfig.java
  5. 92
      ht/src/main/java/com/ccsens/ht/intercept/MybatisInterceptor.java
  6. 7
      ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java
  7. 8
      ht/src/main/java/com/ccsens/ht/persist/dao/HtQuestionDao.java
  8. 5
      ht/src/main/java/com/ccsens/ht/service/IDoctorService.java
  9. 8
      ht/src/main/java/com/ccsens/ht/service/ImportService.java
  10. 9
      ht/src/main/java/com/ccsens/ht/service/PatientReportService.java
  11. 150
      ht/src/main/java/com/ccsens/ht/service/QuestionService.java
  12. 13
      ht/src/main/java/com/ccsens/ht/uitl/Constant.java
  13. 7
      ht/src/main/resources/application-dev.yml
  14. 7
      ht/src/main/resources/application-test.yml
  15. 2
      ht/src/main/resources/mapper_dao/HtDoctorAuditDao.xml
  16. 18
      ht/src/main/resources/mapper_dao/HtPatientReportDao.xml
  17. 7
      ht/src/main/resources/mapper_dao/HtQuestionDao.xml
  18. 13
      tall/src/main/java/com/ccsens/tall/service/ProMemberRoleService.java
  19. 22
      util/src/main/java/com/ccsens/util/PoiUtil.java
  20. 5
      util/src/main/java/com/ccsens/util/PropUtil.java
  21. 13
      util/src/test/java/com/ccsens/util/ZipTest.java

1
ht/src/main/java/com/ccsens/ht/api/QuestionController.java

@ -43,6 +43,7 @@ public class QuestionController {
@RequestMapping(value="/queryQuestion", method = RequestMethod.POST)
public JsonResponse<QuestionVo.Query> query(@RequestBody @ApiParam @Valid QueryDto<QuestionDto.Query> queryDto){
log.info("查询试题:{}", queryDto);
QuestionVo.Query query = questionService.queryQuestion(queryDto.getParam(), queryDto.getUserId());
log.info("查询试题结果:{}", query);
return JsonResponse.newInstance().ok(query);

3
ht/src/main/java/com/ccsens/ht/bean/dto/QuestionDto.java

@ -34,13 +34,11 @@ public class QuestionDto {
@ApiModel("QuestionDtoScore")
public static class Score{
@ApiModelProperty("病人报告单ID")
@NotNull(message = "病人报告单ID不能为空")
private Long patientReportId;
@ApiModelProperty("试题ID")
@NotNull(message = "试题ID不能为空")
private Long questionId;
@ApiModelProperty("选项集合")
@NotNull(message = "选项集合不能为空")
private List<Option> options;
}
@Data
@ -52,6 +50,7 @@ public class QuestionDto {
@NotNull(message = "病友画图或录音不能为空")
@ApiModelProperty("病友画图或录音")
private Part part;
}
}

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

@ -1,5 +1,6 @@
package com.ccsens.ht.bean.vo;
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;
@ -10,7 +11,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @description:
@ -27,21 +30,54 @@ public class QuestionVo {
@ApiModelProperty("引导语")
private List<Introduce> introduces;
@ApiModelProperty("选项")
private List<Option> options;
private List<OptionJson> optionJsons;
@ApiModelProperty("记录")
private List<Record> records;
@ApiModelProperty("报告单类型")
private Report report;
@ApiModelProperty("是否是最后一道题")
private boolean isLast;
@ApiModelProperty("是否是第一道题")
private boolean isFirst;
public Query(){
super();
}
public Query(Question question, List<Option> options, List<Introduce> introduces, List<Record> records) {
public Query(Question question, List<Option> options, List<Introduce> introduces, List<Record> records, int maxSort) {
this.question = question;
this.introduces = introduces;
this.options = options;
this.optionJsons = new ArrayList<>();
if (CollectionUtil.isNotEmpty(options)) {
//方便后续把相同属性的选项放到一个对象的List中
Map<String, OptionJson> map = new HashMap<>();
options.forEach(option -> {
if (map.get(option.getName()) == null) {
OptionJson json = new OptionJson();
json.setName(option.getName());
map.put(json.getName(), json);
//相同属性的选项放在同一个optionJson里
this.optionJsons.add(json);
}
OptionJson json = map.get(option.getName());
json.addOption(option);
});
}
this.records = records;
this.isLast = question.getSort().intValue() == maxSort;
this.isFirst = question.getSort().intValue() == 1;
}
}
@Data
@ApiModel("QuestionVoReport")
public static class Report{
@ApiModelProperty("报告单编码")
private String code;
@ApiModelProperty("")
private String name;
}
@Data
@ApiModel("QuestionVoQuestion")
public static class Question{
@ -53,7 +89,7 @@ public class QuestionVo {
private Integer sort;
@ApiModelProperty("题目")
private String question;
@ApiModelProperty("展示类型 1文本,2图片,3语音,4选项,5连线且文字倒转,6文本倒转,7:图片且题目和选项位置互换,选项文字颠倒")
@ApiModelProperty("展示类型 1文本,2图片,3语音,4选项,5连线且文字倒转,6文本倒转,7:图片且题目和选项位置互换 8:图片,且图片颠倒")
private Byte type;
@ApiModelProperty("额外记录类型(errorMsg:错误信息,otherMsg:其他内容)")
private String recordType;
@ -104,6 +140,16 @@ public class QuestionVo {
}
}
@Data
@ApiModel("QuestionVoOptionOptionJson")
public static class OptionJson {
private String name;
private List<Option> options = new ArrayList<>();
public void addOption(Option option){
options.add(option);
}
}
@Data
@ApiModel("QuestionVoOption")
public static class Option {

6
ht/src/main/java/com/ccsens/ht/config/SpringConfig.java

@ -89,4 +89,10 @@ public class SpringConfig implements WebMvcConfigurer {
public Snowflake snowflake(){
return IdUtil.createSnowflake(Long.valueOf(workerId),Long.valueOf(datacenterId));
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/uploads/**")
.addResourceLocations("file:///home/cloud/ht/uploads/");
}
}

92
ht/src/main/java/com/ccsens/ht/intercept/MybatisInterceptor.java

@ -12,8 +12,10 @@ import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import java.util.Properties;
/**
@ -41,36 +43,10 @@ public class MybatisInterceptor implements Interceptor {
if (statement.getId().endsWith(selectByExample)) {
//XXXExample
Object example = args[1];
Method method = example.getClass().getMethod("getOredCriteria", null);
//获取到条件数组,第一个是Criteria
List list = (List)method.invoke(example);
if (CollectionUtil.isEmpty(list)) {
Class clazz = ((ResultMap)statement.getResultMaps().get(0)).getType();
String exampleName = clazz.getName() + "Example";
Object paramExample = Class.forName(exampleName).newInstance();
Method createCriteria = paramExample.getClass().getMethod("createCriteria");
Object criteria = createCriteria.invoke(paramExample);
Method andIsDelEqualTo = criteria.getClass().getMethod("andIsDelEqualTo", Byte.class);
andIsDelEqualTo.invoke(criteria, Constant.Ht.NUMBER_DEFAULT);
list.add(criteria);
} else {
Object criteria = list.get(0);
Method getCriteria = criteria.getClass().getMethod("getCriteria");
List params = (List)getCriteria.invoke(criteria);
boolean hasDel = false;
for(Object param: params) {
Method getCondition = param.getClass().getMethod("getCondition");
Object condition = getCondition.invoke(param);
if ("iis_del =".equals(condition)) {
hasDel = true;
}
}
if (!hasDel) {
Method andIsDelEqualTo = criteria.getClass().getMethod("andIsDelEqualTo", Byte.class);
andIsDelEqualTo.invoke(criteria, Constant.Ht.NUMBER_DEFAULT);
}
}
addCondition(statement, example);
} else if (statement.getId().endsWith(selectByPrimaryKey)) {
@ -85,6 +61,45 @@ public class MybatisInterceptor implements Interceptor {
return invocation.proceed();
}
private void addCondition(MappedStatement statement, Object example) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, ClassNotFoundException {
if (example instanceof Map) {
example = ((Map) example).get("_ORIGINAL_PARAMETER_OBJECT");
}
Method method = example.getClass().getMethod("getOredCriteria", null);
//获取到条件数组,第一个是Criteria
List list = (List) method.invoke(example);
if (CollectionUtil.isEmpty(list)) {
Class clazz = ((ResultMap) statement.getResultMaps().get(0)).getType();
String exampleName = clazz.getName() + "Example";
Object paramExample = Class.forName(exampleName).newInstance();
Method createCriteria = paramExample.getClass().getMethod("createCriteria");
Object criteria = createCriteria.invoke(paramExample);
Method andIsDelEqualTo = criteria.getClass().getMethod("andIsDelEqualTo", Byte.class);
andIsDelEqualTo.invoke(criteria, Constant.Ht.NUMBER_DEFAULT);
list.add(criteria);
} else {
Object criteria = list.get(0);
Method getCriteria = criteria.getClass().getMethod("getCriteria");
List params = (List) getCriteria.invoke(criteria);
boolean hasDel = false;
for (Object param : params) {
Method getCondition = param.getClass().getMethod("getCondition");
Object condition = getCondition.invoke(param);
if ("is_del =".equals(condition)) {
hasDel = true;
}
}
if (!hasDel) {
Method andIsDelEqualTo = criteria.getClass().getMethod("andIsDelEqualTo", Byte.class);
andIsDelEqualTo.invoke(criteria, Constant.Ht.NUMBER_DEFAULT);
}
}
}
@Override
public Object plugin(Object target) {
return Plugin.wrap(target, this);
@ -121,24 +136,7 @@ public class MybatisInterceptor implements Interceptor {
return builder.build();
}
private String getOperateType(Invocation invocation) {
final Object[] args = invocation.getArgs();
MappedStatement ms = (MappedStatement) args[0];
SqlCommandType commondType = ms.getSqlCommandType();
if (commondType.compareTo(SqlCommandType.SELECT) == 0) {
return "select";
}
if (commondType.compareTo(SqlCommandType.INSERT) == 0) {
return "insert";
}
if (commondType.compareTo(SqlCommandType.UPDATE) == 0) {
return "update";
}
if (commondType.compareTo(SqlCommandType.DELETE) == 0) {
return "delete";
}
return null;
}
// 定义一个内部辅助类,作用是包装sq
class BoundSqlSqlSource implements SqlSource {
private BoundSql boundSql;

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

@ -29,4 +29,11 @@ public interface HtPatientReportDao extends HtPatientReportMapper {
*/
List<PatientReportVo.ReportScore> queryReportScore(@Param("id") Long id);
/**
* 查询NPI的分数
* @param id
* @return
*/
List<PatientReportVo.ReportScore> queryNPIScore(@Param("id") Long id);
}

8
ht/src/main/java/com/ccsens/ht/persist/dao/HtQuestionDao.java

@ -2,6 +2,7 @@ package com.ccsens.ht.persist.dao;
import com.ccsens.ht.bean.po.HtQuestion;
import com.ccsens.ht.persist.mapper.HtQuestionMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -15,4 +16,11 @@ public interface HtQuestionDao extends HtQuestionMapper {
*/
void insertBatch(List<HtQuestion> questitons);
/**
* 查询code类型的最大题目
* @param code
* @return
*/
Integer selectMaxSort(@Param("code") String code);
}

5
ht/src/main/java/com/ccsens/ht/service/IDoctorService.java

@ -49,6 +49,11 @@ public interface IDoctorService {
*/
PageInfo<DoctorVo.Query> queryDoctors(DoctorDto.Query query, Long userId);
/**
* 根据条件查询dotor
* @param doctorExample
* @return
*/
List<HtDoctor> selectByExample(HtDoctorExample doctorExample);
}

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

@ -8,6 +8,7 @@ import com.ccsens.ht.bean.po.*;
import com.ccsens.ht.persist.dao.*;
import com.ccsens.ht.uitl.Constant;
import com.ccsens.util.PoiUtil;
import com.ccsens.util.PropUtil;
import com.ccsens.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -217,7 +218,7 @@ public class ImportService implements IImportService {
log.info("导入试题类型:{}", types);
StringBuilder builder = new StringBuilder();
for (String sheetName: types) {
List<Object[]> questions = PoiUtil.readExce(file, -1, sheetName,1, false);
List<Object[]> questions = PoiUtil.readExce(file, -1, sheetName,1, true);
saveQuestions(questions, sheetName);
}
}
@ -378,9 +379,12 @@ public class ImportService implements IImportService {
}
question.setEvaluationCode(evaluationCode);
question.setParentCode(StringUtils.isEmpty(objs[1]) ? Constant.Ht.STRING_DEFAULT : String.valueOf(objs[1]));
question.setQuestion(StringUtils.isEmpty(objs[2]) ? Constant.Ht.STRING_DEFAULT : String.valueOf(objs[2]));
question.setSort(sort);
question.setType(objs.length>4 && StringUtil.checkNum(String.valueOf(objs[4]), false) ? Byte.parseByte(String.valueOf(objs[4])) : Constant.Ht.Question.QUESTION_SHOW_TYPE);
String questionStr = StringUtils.isEmpty(objs[2]) ? Constant.Ht.STRING_DEFAULT : String.valueOf(objs[2]);
byte imgType = 2;
questionStr = question.getType().byteValue() == imgType && StrUtil.isNotEmpty(questionStr) ? PropUtil.imgDomain + questionStr : questionStr;
question.setQuestion(questionStr);
question.setRecordType(objs.length > 5 && !StringUtils.isEmpty(objs[5]) ? String.valueOf(objs[5]) : Constant.Ht.STRING_DEFAULT);
question.setRecordContent(objs.length > 6 && !StringUtils.isEmpty(objs[6]) ? String.valueOf(objs[6]) : Constant.Ht.STRING_DEFAULT);
question.setRelationCode(objs.length > 7 && !StringUtils.isEmpty(objs[7]) ? String.valueOf(objs[7]) : Constant.Ht.STRING_DEFAULT);

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

@ -200,9 +200,18 @@ public class PatientReportService implements IPatientReportService {
List<PatientReportVo.ReportScore> scores = new ArrayList<>();
reportScore.forEach(score -> {
map.put(score.getCode(), score);
//测评类(MOCA等)
if (Constant.Ht.Report.TYPE_EVALUATION.equals(score.getType())) {
String specialCode = "NPI";
if (specialCode.equalsIgnoreCase(score.getCode())) {
List<PatientReportVo.ReportScore> reportScores = htPatientReportDao.queryNPIScore(queryDetail.getId());
score.setSubReport(reportScores);
score.setScore(null);
}
scores.add(score);
} else {
log.info("score:{}", score);
map.get(score.getParentCode()).addSub(score);
}
});

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

@ -1,6 +1,8 @@
package com.ccsens.ht.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -23,10 +25,15 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.script.ScriptEngine;
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.concurrent.atomic.AtomicInteger;
/**
@ -56,6 +63,8 @@ public class QuestionService implements IQuestionService {
private HtPatientReportMapper htPatientReportMapper;
@Autowired
private HtQuestionScoringRuleDao htQuestionScoringRuleDao;
@Autowired
private HtReportDao htReportDao;
@ -69,12 +78,27 @@ public class QuestionService implements IQuestionService {
questionExample.createCriteria().andEvaluationCodeEqualTo(query.getCode()).andSortEqualTo(query.getNum());
List<HtQuestion> questionList = htQuestionDao.selectByExample(questionExample);
log.info("测评试题:{}", questionList);
if (CollectionUtils.isEmpty(questionList)) {
throw new BaseException(CodeEnum.QUESTION_NOT_FOUND);
}
HtQuestion question = questionList.get(0);
QuestionVo.Question questionVo = QuestionVo.Question.toQuestionVo(question);
log.info("试题:{}", questionVo);
//获取评测信息
HtReportExample reportExample = new HtReportExample();
reportExample.createCriteria().andCodeEqualTo(question.getEvaluationCode());
List<HtReport> 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());
//查询关联题目
if (!StringUtils.isEmpty(question.getRelationCode())) {
String[] codes = question.getRelationCode().split(Constant.COMMA);
@ -94,6 +118,7 @@ public class QuestionService implements IQuestionService {
List<QuestionVo.Introduce> introduceVos = QuestionVo.Introduce.toIntroduces(introduces);
//试题选项
List<QuestionVo.Option> options = htQuestionOptionDao.queryOption(question.getId(), query.getPatientReportId());
//答题记录
List<QuestionVo.Record> recordVos;
if (query.getPatientReportId() != null && query.getPatientReportId() != 0) {
@ -107,7 +132,8 @@ public class QuestionService implements IQuestionService {
}
//封装返回
QuestionVo.Query data = new QuestionVo.Query(questionVo, options, introduceVos, recordVos);
QuestionVo.Query data = new QuestionVo.Query(questionVo, options, introduceVos, recordVos,maxSort);
data.setReport(reportVo);
log.info("试题信息:{}", data);
return data;
}
@ -115,6 +141,11 @@ 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("没有报告单ID或选项,不进行保存");
return CodeEnum.SUCCESS;
}
//查询试题
HtQuestion question = htQuestionDao.selectByPrimaryKey(score.getQuestionId());
@ -132,8 +163,10 @@ public class QuestionService implements IQuestionService {
HtQuestionScoringRuleExample ruleExample = new HtQuestionScoringRuleExample();
ruleExample.createCriteria().andQuestionIdEqualTo(question.getId());
List<HtQuestionScoringRule> ruleList = htQuestionScoringRuleDao.selectByExample(ruleExample);
//生成分数列表
List<HtPatientScore> scores = new ArrayList<>();
//查询选项列表
Map<String, HtQuestionOption> nameOption = new HashMap<>();
Map<Long, HtQuestionOption> idOption = new HashMap<>();
for(QuestionDto.Option option : score.getOptions()) {
HtQuestionOption questionOption = htQuestionOptionDao.selectByPrimaryKey(option.getId());
//未找到对应选项 或选项不是该试题的选项
@ -141,23 +174,11 @@ public class QuestionService implements IQuestionService {
log.info("选项不存在或不是对应试题的选项");
return CodeEnum.PARAM_ERROR;
}
String path = null;
if (option.getPart() != null) {
path = UploadFileUtil_Servlet3.uploadFile(option.getPart(), Constant.IMG + "," + Constant.VIDEO, PropUtil.path + "answer" + File.separator + question.getEvaluationCode());
}
HtPatientScore patientScore = new HtPatientScore();
patientScore.setId(snowflake.nextId());
patientScore.setPatientReportId(score.getPatientReportId());
patientScore.setPatientId(report.getPatientId());
patientScore.setQuestionId(score.getQuestionId());
patientScore.setQuestionParentCode(question.getParentCode());
patientScore.setOptionId(option.getId());
patientScore.setOptionName(questionOption.getName());
patientScore.setScore(questionOption.getScore());
patientScore.setType(ruleList.size() > 0 ? Constant.Ht.Score.ANSWER : Constant.Ht.Score.ANSWER_SCORE);
patientScore.setAnswer(StringUtils.isEmpty(path) ? Constant.Ht.STRING_DEFAULT : path);
scores.add(patientScore);
nameOption.put(questionOption.getName(), questionOption);
idOption.put(questionOption.getId(), questionOption);
}
//生成分数列表
List<HtPatientScore> scores = getHtPatientScores(score, question, report, ruleList, nameOption, idOption);
if (!CollectionUtils.isEmpty(ruleList)) {
HtQuestionScoringRule rule = ruleList.get(0);
@ -202,4 +223,95 @@ public class QuestionService implements IQuestionService {
htPatientScoreDao.insertBatch(scores);
return CodeEnum.SUCCESS;
}
/**
* 分数数据处理
* @param score
* @param question
* @param report
* @param ruleList
* @param nameOption
* @param idOption
* @return
* @throws IOException
* @throws NotSupportedFileTypeException
*/
private List<HtPatientScore> getHtPatientScores(QuestionDto.Score score, HtQuestion question, HtPatientReport report, List<HtQuestionScoringRule> ruleList, Map<String, HtQuestionOption> nameOption, Map<Long, HtQuestionOption> idOption) throws IOException, NotSupportedFileTypeException {
List<HtPatientScore> scores = new ArrayList<>();
for(QuestionDto.Option option : score.getOptions()) {
HtQuestionOption questionOption = idOption.get(option.getId());
String path = null;
if (option.getPart() != null) {
path = PropUtil.imgDomain + UploadFileUtil_Servlet3.uploadFile(option.getPart(), Constant.IMG + "," + Constant.VIDEO, PropUtil.path);
}
assembleScore(score, question, report, ruleList, nameOption, scores, questionOption, path);
}
String special = "NPI";
if (special.equalsIgnoreCase(question.getEvaluationCode())) {
HtQuestionOptionExample example = new HtQuestionOptionExample();
example.createCriteria().andQuestionIdEqualTo(question.getId()).andNameEqualTo("result");
List<HtQuestionOption> htQuestionOptions = htQuestionOptionDao.selectByExample(example);
for (HtQuestionOption option: htQuestionOptions) {
assembleScore(score, question, report, ruleList, nameOption, scores, option, null);
}
}
return scores;
}
/**
* 组装分数对象
* @param score
* @param question
* @param report
* @param ruleList
* @param nameOption
* @param scores
* @param questionOption
* @param path
*/
private void assembleScore(QuestionDto.Score score, HtQuestion question, HtPatientReport report, List<HtQuestionScoringRule> ruleList, Map<String, HtQuestionOption> nameOption, List<HtPatientScore> scores, HtQuestionOption questionOption, String path) {
HtPatientScore patientScore = new HtPatientScore();
patientScore.setId(snowflake.nextId());
patientScore.setPatientReportId(score.getPatientReportId());
patientScore.setPatientId(report.getPatientId());
patientScore.setQuestionId(score.getQuestionId());
patientScore.setQuestionParentCode(question.getParentCode());
patientScore.setOptionId(questionOption.getId());
patientScore.setOptionName(questionOption.getName());
if (StrUtil.isNotEmpty(questionOption.getRemark())) {
JSONObject remark = JSONObject.parseObject(questionOption.getRemark());
countScoreByFormula(nameOption, questionOption, patientScore, remark);
} else {
patientScore.setScore(questionOption.getScore());
}
patientScore.setType(CollectionUtil.isNotEmpty(ruleList) ? Constant.Ht.Score.ANSWER : Constant.Ht.Score.ANSWER_SCORE);
patientScore.setAnswer(StringUtils.isEmpty(path) ? Constant.Ht.STRING_DEFAULT : path);
scores.add(patientScore);
}
private void countScoreByFormula(Map<String, HtQuestionOption> nameOption, HtQuestionOption questionOption, HtPatientScore patientScore, JSONObject remark) {
switch (remark.getIntValue("isAutoformula")) {
case 1:
String formulaSymbol = remark.getString("formulaSymbol");
String[] params = remark.getString("formulaName").split(",");
StringBuilder formula = new StringBuilder();
for (String param: params) {
formula.append(formulaSymbol).append(nameOption.get(param) == null ? 0 : nameOption.get(param) .getScore());
}
String substring = formula.substring(formulaSymbol.length());
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine js = manager.getEngineByName("js");
try {
Integer result = (Integer)js.eval(substring);
patientScore.setScore(result);
} catch (ScriptException e) {
log.error("计算出现异常",e);
throw new BaseException(CodeEnum.PARAM_ERROR) ;
}
break;
default: patientScore.setScore(questionOption.getScore());break;
}
}
}

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

@ -19,18 +19,10 @@ public class Constant {
public static final String IMG = ".png,.jpg,.jpeg,.gif,.bmp";
/**视频音频*/
public static final String VIDEO = ".flv,swf,mkv,avi,rm,rmvb,mpeg,mpg,.ogg,ogv,mov,wmv,mp4,webm,mp3,wav,mid,.wma";
/**上传图片访问路径*/
public static final String UPLOAD_URL = "uploads/";
/**请求路径*/
public static class Url {
/**添加角色*/
public final static String ASSIGN_ROLE = PropUtil.domain + PropUtil.contextPath +"/assignRoles";
/**删除角色*/
public final static String DELETE_ROLE = PropUtil.domain + PropUtil.contextPath +"/deleteRoles";
/**注册用户*/
public final static String REGIST = PropUtil.domain + PropUtil.contextPath + "/defaultRegister";
}
/**注册来源*/
public static final class Regist {
public final static byte SOURCE = 0;
@ -95,6 +87,7 @@ public class Constant {
QUESTION_TYPE.add("NPI");
QUESTION_TYPE.add("MMSE");
QUESTION_TYPE.add("MoCA");
QUESTION_TYPE.add("Rey");
}
}

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

@ -28,9 +28,10 @@ swagger:
enable: true
file:
path: /home/www-test/
path: /home/cloud/ht/uploads/
#domain: https://api.ccsens.com/test/
domain: http://localhost:7971/
domain: http://localhost:7040/
imgDomain: http://localhost:7040/uploads/
ht:
project:
name: HT pro项目管理
name: 阿尔兹海默症评估系统

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

@ -29,9 +29,10 @@ spring:
swagger:
enable: true
file:
path: /home/www-test/
path: /home/cloud/ht/uploads/
#domain: https://api.ccsens.com/test/
domain: http://localhost:7971/
domain: https://test.tall.wiki/gateway/ht/
imgDomain: https://test.tall.wiki/gateway/ht/uploads/
ht:
project:
name: HT pro项目管理
name: 阿尔兹海默症评估系统

2
ht/src/main/resources/mapper_dao/HtDoctorAuditDao.xml

@ -61,7 +61,7 @@
) t3 where t3.type &lt;&gt; 3 and ischild != 0
)
</if>
order by d.audit_state, d.create_time desc
</select>
</mapper>

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

@ -47,11 +47,23 @@
select t1.code,t1.name, t1.description, t1.total_score, t1.remark,t1.type,t1.parent_code, sum(t2.score) as score
from
(select code,name, description, total_score, remark, type, parent_code, sort from t_ht_report where is_show = 1 and is_del = 0) t1
left join t_ht_patient_score t2 on t1.code = t2.question_parent_code
where (t2.patient_report_id = #{id, jdbcType=BIGINT} and t2.type in (0,2) and t2.is_del = 0)
or (t2.id is null and t2.is_del = 0)
left join t_ht_patient_score t2
on t1.code = t2.question_parent_code
where (t2.patient_report_id = #{id, jdbcType=BIGINT} and t2.type in (0,2) and t2.is_del = 0) or t2.id is null
GROUP BY t1.code
order by t1.type,t1.sort
</select>
<select id="queryNPIScore" resultMap="ScoreMap">
select if(t2.option_name = 'carer', 'ZGZ','HZ' ) as code,if(t2.option_name = 'carer', '照顾者','患者' ) as name, '' as description,
t1.total_score, t2.option_name, t1.remark,t1.type,'NPI' as parent_code, sum(t2.score) as score
from
(select code,name, description, total_score, remark, type, parent_code, sort from t_ht_report where is_show = 1 and is_del = 0) t1
left join t_ht_patient_score t2 on t1.code = t2.question_parent_code and t2.option_name in ('carer','result')
where (t2.patient_report_id =#{id, jdbcType=BIGINT} and t2.question_parent_code = 'NPI' and t2.type in (0,2) and t2.is_del = 0)
or (t2.id is null and t2.is_del = 0)
GROUP BY t1.code,t2.option_name
order by t1.type,t1.sort
</select>
</mapper>

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

@ -41,5 +41,10 @@
#{question.remark,jdbcType=VARCHAR}, #{question.createTime,jdbcType=TIMESTAMP}, now(), 0 )
</foreach>
</insert>
<select id="selectMaxSort" resultType="Integer">
select
max(sort)
from t_ht_question
where evaluation_code = #{code, jdbcType=VARCHAR}
</select>
</mapper>

13
tall/src/main/java/com/ccsens/tall/service/ProMemberRoleService.java

@ -153,11 +153,14 @@ public class ProMemberRoleService implements IProMemberRoleService{
}
//查询项目下是否有用户
MemberVo.MemberInfo memberInfo = proMemberDao.selectByProjectIdAndUserId(projectId, deleteDto.getUserId());
ProMemberRoleExample whereExample = new ProMemberRoleExample();
whereExample.createCriteria().andMemberIdEqualTo(memberInfo.getId()).andRoleIdIn(roleIds);
ProMemberRole role = new ProMemberRole();
role.setRecStatus(WebConstant.STATUS_DELETE);
proMemberRoleDao.updateByExampleSelective(role, whereExample);
if (memberInfo != null) {
ProMemberRoleExample whereExample = new ProMemberRoleExample();
whereExample.createCriteria().andMemberIdEqualTo(memberInfo.getId()).andRoleIdIn(roleIds);
ProMemberRole role = new ProMemberRole();
role.setRecStatus(WebConstant.STATUS_DELETE);
proMemberRoleDao.updateByExampleSelective(role, whereExample);
}
return CodeEnum.SUCCESS;
}
}

22
util/src/main/java/com/ccsens/util/PoiUtil.java

@ -58,16 +58,22 @@ public class PoiUtil {
}
Object[] objects = new Object[row.getLastCellNum()];
if (hasImg && imgMap != null) {
if (imgMap.containsKey(i + "")) {
objects[0] = imgMap.get(i + "");
for (String key: imgMap.keySet()) {
if (key.startsWith(i+"-")) {
int index = Integer.parseInt(key.split("-")[1]);
objects[index] = imgMap.get(key);
}
}
}
for (int j = hasImg && imgMap != null ? 1 : 0; j < row.getLastCellNum(); j++) {
for (int j = 0; j < row.getLastCellNum(); j++) {
Cell cell = row.getCell(j);
if (cell == null) {
continue;
}
objects[j] = getCallValue(cell);
if (objects[j] == null) {
objects[j] = getCallValue(cell);
}
}
list.add(objects);
}
@ -135,8 +141,8 @@ public class PoiUtil {
HSSFPicture picture = (HSSFPicture) shape;
HSSFClientAnchor cAnchor = picture.getClientAnchor();
// 行号
String key = String.valueOf(cAnchor.getRow1());
// 行号-列号
String key = cAnchor.getRow1() + "-" + cAnchor.getCol1();
HSSFPictureData pictureData = picture.getPictureData();
@ -168,7 +174,7 @@ public class PoiUtil {
}
out = new FileOutputStream(path);
out.write(data);
return PropUtil.domain + fileName;
return fileName;
} catch (IOException e) {
log.error("文件解析发生异常", e);
if (out != null) {
@ -201,7 +207,7 @@ public class PoiUtil {
XSSFPicture picture = (XSSFPicture) shape;
XSSFClientAnchor anchor = picture.getPreferredSize();
CTMarker marker = anchor.getFrom();
String key = String.valueOf(marker.getRow());
String key = marker.getRow() + "-" + marker.getCol();
map.put(key, createImgPath(picture.getPictureData()));
}
}

5
util/src/main/java/com/ccsens/util/PropUtil.java

@ -13,6 +13,7 @@ import org.springframework.stereotype.Component;
public class PropUtil {
public static String path;
public static String domain;
public static String imgDomain;
public static String projectName;
public static String contextPath;
@ -24,6 +25,10 @@ public class PropUtil {
public void setDomain(String domain) {
PropUtil.domain = domain;
}
@Value("${file.imgDomain:}")
public void setImgDomain(String imgDomain) {
PropUtil.imgDomain = imgDomain;
}
@Value("${ht.project.name:}")
public void setProjectName(String projectName) {

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

@ -4,6 +4,9 @@ import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.ZipUtil;
import org.junit.Test;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.UnsupportedEncodingException;
/**
@ -25,4 +28,14 @@ public class ZipTest {
System.out.println("ungzip:" + new String(bytes, "UTF-8") );
System.out.println("length:" + new String(bytes, "UTF-8").length());
}
@Test
public void test2() throws ScriptException {
String expr = "(1+2/5)*3";
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("js");
Object result = engine.eval(expr);
System.out.println(result.getClass());
System.out.println(result);
}
}

Loading…
Cancel
Save