@ -24,6 +24,7 @@ import com.ccsens.util.exception.BaseException;
import com.github.pagehelper.PageHelper ;
import com.github.pagehelper.PageHelper ;
import com.github.pagehelper.PageInfo ;
import com.github.pagehelper.PageInfo ;
import com.github.pagehelper.StringUtil ;
import com.github.pagehelper.StringUtil ;
import lombok.SneakyThrows ;
import lombok.extern.slf4j.Slf4j ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.poi.ss.usermodel.Workbook ;
import org.apache.poi.ss.usermodel.Workbook ;
import org.apache.poi.xssf.usermodel.XSSFWorkbook ;
import org.apache.poi.xssf.usermodel.XSSFWorkbook ;
@ -33,7 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils ;
import org.springframework.util.CollectionUtils ;
import javax.annotation.Resource ;
import javax.annotation.Resource ;
import java.io.IOException ;
import java.io.* ;
import java.math.BigDecimal ;
import java.math.BigDecimal ;
import java.util.* ;
import java.util.* ;
import java.util.concurrent.atomic.AtomicBoolean ;
import java.util.concurrent.atomic.AtomicBoolean ;
@ -794,21 +795,22 @@ public class PatientReportService implements IPatientReportService {
row . get ( 1 ) . setValue ( DateUtil . format ( new Date ( analyse . getReportTime ( ) ) , "yyyy.MM.dd" ) ) ;
row . get ( 1 ) . setValue ( DateUtil . format ( new Date ( analyse . getReportTime ( ) ) , "yyyy.MM.dd" ) ) ;
row . get ( 2 ) . setValue ( analyse . getPatientName ( ) ) ;
row . get ( 2 ) . setValue ( analyse . getPatientName ( ) ) ;
row . get ( 3 ) . setValue ( analyse . getSex ( ) = = 0 ? "男" : "女" ) ;
row . get ( 3 ) . setValue ( analyse . getSex ( ) = = 0 ? "男" : "女" ) ;
row . get ( 4 ) . setValue ( String . valueOf ( analyse . getPatientAge ( ) ) ) ;
row . get ( 4 ) . setValue ( "'" + analyse . getPatientPhone ( ) ) ;
row . get ( 5 ) . setValue ( Constant . Ht . getEducational ( analyse . getEducationalStatus ( ) ) ) ;
row . get ( 5 ) . setValue ( String . valueOf ( analyse . getPatientAge ( ) ) ) ;
row . get ( 6 ) . setValue ( Constant . Ht . getCareer ( analyse . getCareer ( ) ) ) ;
row . get ( 6 ) . setValue ( Constant . Ht . getEducational ( analyse . getEducationalStatus ( ) ) ) ;
row . get ( 7 ) . setValue ( analyse . getClinicalDiagnosis ( ) ) ;
row . get ( 7 ) . setValue ( Constant . Ht . getCareer ( analyse . getCareer ( ) ) ) ;
row . get ( 8 ) . setValue ( Constant . Ht . getPasi ( analyse . getPasi ( ) ) ) ;
row . get ( 8 ) . setValue ( analyse . getClinicalDiagnosis ( ) ) ;
row . get ( 9 ) . setValue ( Constant . Ht . getPasi ( analyse . getPasi ( ) ) ) ;
// MMSE分数
// MMSE分数
if ( CollectionUtil . isNotEmpty ( analyse . getMmseScores ( ) ) ) {
if ( CollectionUtil . isNotEmpty ( analyse . getMmseScores ( ) ) ) {
analyse . getMmseScores ( ) . forEach ( score - > {
analyse . getMmseScores ( ) . forEach ( score - > {
switch ( score . getCode ( ) ) {
switch ( score . getCode ( ) ) {
case "DXL" : row . get ( 9 ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ; break ;
case "DXL" : row . get ( 10 ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ; break ;
case "JYL" : row . get ( 10 ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ; break ;
case "JYL" : row . get ( 11 ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ; break ;
case "ZYLHJSL" : row . get ( 11 ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ; break ;
case "ZYLHJSL" : row . get ( 12 ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ; break ;
case "HYNL" : row . get ( 12 ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ; break ;
case "HYNL" : row . get ( 13 ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ; break ;
case "YYNL" : row . get ( 13 ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ; break ;
case "YYNL" : row . get ( 14 ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ; break ;
case "JGNL" : row . get ( 14 ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ; break ;
case "JGNL" : row . get ( 15 ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ; break ;
}
}
} ) ;
} ) ;
}
}
@ -817,26 +819,26 @@ public class PatientReportService implements IPatientReportService {
for ( int i = 0 ; i < analyse . getMocaScores ( ) . size ( ) ; i + + ) {
for ( int i = 0 ; i < analyse . getMocaScores ( ) . size ( ) ; i + + ) {
PatientReportVo . MoCAScore score = analyse . getMocaScores ( ) . get ( i ) ;
PatientReportVo . MoCAScore score = analyse . getMocaScores ( ) . get ( i ) ;
if ( score . getSort ( ) < = 3 ) {
if ( score . getSort ( ) < = 3 ) {
row . get ( 15 + score . getSort ( ) ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ;
row . get ( 16 + score . getSort ( ) ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ;
} else if ( score . getSort ( ) = = 4 | | score . getSort ( ) = = 5 | | score . getSort ( ) = = 6 ) {
} else if ( score . getSort ( ) = = 4 | | score . getSort ( ) = = 5 | | score . getSort ( ) = = 6 ) {
String value = row . get ( 19 ) . getValue ( ) ;
String value = row . get ( 20 ) . getValue ( ) ;
int s = StrUtil . isEmpty ( value ) ? 0 : Integer . parseInt ( value ) ;
int s = StrUtil . isEmpty ( value ) ? 0 : Integer . parseInt ( value ) ;
row . get ( 19 ) . setValue ( String . valueOf ( s + score . getScore ( ) . intValue ( ) ) ) ;
row . get ( 20 ) . setValue ( String . valueOf ( s + score . getScore ( ) . intValue ( ) ) ) ;
} else if ( score . getSort ( ) > = 7 & & score . getSort ( ) < = 12 ) {
} else if ( score . getSort ( ) > = 7 & & score . getSort ( ) < = 12 ) {
row . get ( 13 + score . getSort ( ) ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ;
row . get ( 14 + score . getSort ( ) ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ;
} else if ( score . getSort ( ) = = 13 | | score . getSort ( ) = = 14 ) {
} else if ( score . getSort ( ) = = 13 | | score . getSort ( ) = = 14 ) {
String value = row . get ( 26 ) . getValue ( ) ;
String value = row . get ( 27 ) . getValue ( ) ;
int s = StrUtil . isEmpty ( value ) ? 0 : Integer . parseInt ( value ) ;
int s = StrUtil . isEmpty ( value ) ? 0 : Integer . parseInt ( value ) ;
row . get ( 26 ) . setValue ( String . valueOf ( s + score . getScore ( ) . intValue ( ) ) ) ;
row . get ( 27 ) . setValue ( String . valueOf ( s + score . getScore ( ) . intValue ( ) ) ) ;
} else if ( score . getSort ( ) > = 15 & & score . getSort ( ) < = 17 ) {
} else if ( score . getSort ( ) > = 15 & & score . getSort ( ) < = 17 ) {
row . get ( 12 + score . getSort ( ) ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ;
row . get ( 14 + score . getSort ( ) ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ;
} else if ( score . getSort ( ) = = 21 | | score . getSort ( ) = = 22 ) {
} else if ( score . getSort ( ) = = 21 | | score . getSort ( ) = = 22 ) {
row . get ( 9 + score . getSort ( ) ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ;
row . get ( 10 + score . getSort ( ) ) . setValue ( score . getScore ( ) . intValue ( ) + "" ) ;
} else if ( score . getSort ( ) = = 18 | | score . getSort ( ) = = 19 ) {
} else if ( score . getSort ( ) = = 18 | | score . getSort ( ) = = 19 ) {
if ( score . getScore ( ) ! = null ) {
if ( score . getScore ( ) ! = null ) {
String value = row . get ( 32 ) . getValue ( ) ;
String value = row . get ( 33 ) . getValue ( ) ;
int dxlScore = StrUtil . isEmpty ( value ) ? 0 : Integer . parseInt ( value ) ;
int dxlScore = StrUtil . isEmpty ( value ) ? 0 : Integer . parseInt ( value ) ;
row . get ( 32 ) . setValue ( dxlScore + score . getScore ( ) . intValue ( ) + "" ) ;
row . get ( 33 ) . setValue ( dxlScore + score . getScore ( ) . intValue ( ) + "" ) ;
}
}
@ -847,12 +849,12 @@ public class PatientReportService implements IPatientReportService {
if ( CollectionUtil . isNotEmpty ( analyse . getTotalScores ( ) ) ) {
if ( CollectionUtil . isNotEmpty ( analyse . getTotalScores ( ) ) ) {
analyse . getTotalScores ( ) . forEach ( totalScore - > {
analyse . getTotalScores ( ) . forEach ( totalScore - > {
switch ( totalScore . getEvaluationCode ( ) ) {
switch ( totalScore . getEvaluationCode ( ) ) {
case "MMSE" : row . get ( 15 ) . setValue ( totalScore . getTotalScore ( ) . intValue ( ) + "" ) ; break ;
case "MMSE" : row . get ( 16 ) . setValue ( totalScore . getTotalScore ( ) . intValue ( ) + "" ) ; break ;
case "MoCA" : row . get ( 33 ) . setValue ( totalScore . getTotalScore ( ) . intValue ( ) + "" ) ; break ;
case "MoCA" : row . get ( 34 ) . setValue ( totalScore . getTotalScore ( ) . intValue ( ) + "" ) ; break ;
case "ADL" : row . get ( 34 ) . setValue ( totalScore . getTotalScore ( ) . intValue ( ) + "" ) ; break ;
case "ADL" : row . get ( 35 ) . setValue ( totalScore . getTotalScore ( ) . intValue ( ) + "" ) ; break ;
case "HAMA" : row . get ( 35 ) . setValue ( totalScore . getTotalScore ( ) . intValue ( ) + "" ) ; break ;
case "HAMA" : row . get ( 36 ) . setValue ( totalScore . getTotalScore ( ) . intValue ( ) + "" ) ; break ;
case "HAMD" : row . get ( 36 ) . setValue ( totalScore . getTotalScore ( ) . intValue ( ) + "" ) ; break ;
case "HAMD" : row . get ( 37 ) . setValue ( totalScore . getTotalScore ( ) . intValue ( ) + "" ) ; break ;
case "NPI" : row . get ( 37 ) . setValue ( totalScore . getTotalScore ( ) . intValue ( ) + "" ) ; break ;
case "NPI" : row . get ( 38 ) . setValue ( totalScore . getTotalScore ( ) . intValue ( ) + "" ) ; break ;
}
}
} ) ;
} ) ;
}
}
@ -867,18 +869,18 @@ public class PatientReportService implements IPatientReportService {
Integer height = patientCanvas . get ( 0 ) . getCanvas ( ) . getHeight ( ) ;
Integer height = patientCanvas . get ( 0 ) . getCanvas ( ) . getHeight ( ) ;
QuestionVo . Parameter parameters = patientCanvas . get ( 0 ) . getParameters ( ) ;
QuestionVo . Parameter parameters = patientCanvas . get ( 0 ) . getParameters ( ) ;
// 完成总时间
// 完成总时间
row . get ( 38 ) . setValue ( parameters . getTotalDuration ( ) + "ms" ) ;
row . get ( 39 ) . setValue ( parameters . getTotalDuration ( ) + "ms" ) ;
row . get ( 39 ) . setValue ( parameters . getPaintTime ( ) + "ms" ) ;
row . get ( 40 ) . setValue ( parameters . getPaintTime ( ) + "ms" ) ;
row . get ( 40 ) . setValue ( parameters . getReflectOnTime ( ) + "ms" ) ;
row . get ( 41 ) . setValue ( parameters . getReflectOnTime ( ) + "ms" ) ;
row . get ( 44 ) . setValue ( parameters . getLineParameterList ( ) = = null ? "" : String . valueOf ( parameters . getLineParameterList ( ) . size ( ) ) ) ;
row . get ( 45 ) . setValue ( parameters . getLineParameterList ( ) = = null ? "" : String . valueOf ( parameters . getLineParameterList ( ) . size ( ) ) ) ;
row . get ( 45 ) . setValue ( String . valueOf ( parameters . getAveTimes ( ) ) ) ;
row . get ( 46 ) . setValue ( String . valueOf ( parameters . getAveTimes ( ) ) ) ;
row . get ( 46 ) . setValue ( pxToMm ( parameters . getAveLength ( ) , height ) + "mm" ) ;
row . get ( 47 ) . setValue ( pxToMm ( parameters . getAveLength ( ) , height ) + "mm" ) ;
row . get ( 47 ) . setValue ( pxToMm ( parameters . getLongLine ( ) , height ) + "mm" ) ;
row . get ( 48 ) . setValue ( pxToMm ( parameters . getLongLine ( ) , height ) + "mm" ) ;
row . get ( 50 ) . setValue ( pxToMm ( parameters . getAveSpeed ( ) * 1000 , height ) + "mm/s" ) ;
row . get ( 51 ) . setValue ( pxToMm ( parameters . getAveSpeed ( ) * 1000 , height ) + "mm/s" ) ;
row . get ( 51 ) . setValue ( pxToMm ( parameters . getLongSpeed ( ) * 1000 , height ) + "mm/s" ) ;
row . get ( 52 ) . setValue ( pxToMm ( parameters . getLongSpeed ( ) * 1000 , height ) + "mm/s" ) ;
row . get ( 52 ) . setValue ( parameters . getMinCircleAcreage ( ) = = null ? "" : pxToSquare ( parameters . getMinCircleAcreage ( ) . doubleValue ( ) , height ) + "mm²" ) ;
row . get ( 53 ) . setValue ( parameters . getMinCircleAcreage ( ) = = null ? "" : pxToSquare ( parameters . getMinCircleAcreage ( ) . doubleValue ( ) , height ) + "mm²" ) ;
row . get ( 53 ) . setValue ( parameters . getShowCentreCoordinate ( ) = = null ? "" : pxToMm ( parameters . getShowCentreCoordinate ( ) . getX ( ) , height ) + "mm" ) ;
row . get ( 54 ) . setValue ( parameters . getShowCentreCoordinate ( ) = = null ? "" : pxToMm ( parameters . getShowCentreCoordinate ( ) . getX ( ) , height ) + "mm" ) ;
row . get ( 54 ) . setValue ( parameters . getShowCentreCoordinate ( ) = = null ? "" : pxToMm ( parameters . getShowCentreCoordinate ( ) . getY ( ) , height ) + "mm" ) ;
row . get ( 55 ) . setValue ( parameters . getShowCentreCoordinate ( ) = = null ? "" : pxToMm ( parameters . getShowCentreCoordinate ( ) . getY ( ) , height ) + "mm" ) ;
}
}
Long simpleId = getQuestionId ( "EasyOne" , 4 ) ;
Long simpleId = getQuestionId ( "EasyOne" , 4 ) ;
@ -983,6 +985,7 @@ public class PatientReportService implements IPatientReportService {
titleRow . add ( new PoiUtil . PoiUtilCell ( "测评日期" ) ) ;
titleRow . add ( new PoiUtil . PoiUtilCell ( "测评日期" ) ) ;
titleRow . add ( new PoiUtil . PoiUtilCell ( "姓名" ) ) ;
titleRow . add ( new PoiUtil . PoiUtilCell ( "姓名" ) ) ;
titleRow . add ( new PoiUtil . PoiUtilCell ( "性别" ) ) ;
titleRow . add ( new PoiUtil . PoiUtilCell ( "性别" ) ) ;
titleRow . add ( new PoiUtil . PoiUtilCell ( "手机号" ) ) ;
titleRow . add ( new PoiUtil . PoiUtilCell ( "年龄" ) ) ;
titleRow . add ( new PoiUtil . PoiUtilCell ( "年龄" ) ) ;
titleRow . add ( new PoiUtil . PoiUtilCell ( "文化程度" ) ) ;
titleRow . add ( new PoiUtil . PoiUtilCell ( "文化程度" ) ) ;
titleRow . add ( new PoiUtil . PoiUtilCell ( "职业" ) ) ;
titleRow . add ( new PoiUtil . PoiUtilCell ( "职业" ) ) ;
@ -1324,26 +1327,28 @@ public class PatientReportService implements IPatientReportService {
}
}
@Override
@Override
public Workbook exportAnalyseAll ( PatientReportDto . Answer answer ) {
public List < String > exportAnalyseAll ( PatientReportDto . Answer answer ) throws Exception {
List < String > paths = new ArrayList < > ( ) ;
log . info ( "导出全部分析:{}" , answer ) ;
log . info ( "导出全部分析:{}" , answer ) ;
List < Long > reportIds = htPatientScoreDao . queryIdsByAnswer ( answer ) ;
List < Long > reportIds = htPatientScoreDao . queryIdsByAnswer ( answer ) ;
log . info ( "报告单数量:{}" , reportIds . size ( ) ) ;
log . info ( "报告单数量:{}" , reportIds . size ( ) ) ;
int size = reportIds . size ( ) ;
for ( int i = 0 ; i < size ; i + = 500 ) {
List < PatientReportVo . Analyse > analyses = htPatientReportDao . queryReportAnalyseScore ( reportIds . subList ( i , i + 500 > = size ? size : i + 500 ) ) ;
int total = 124 ;
int total = 124 ;
List < List < PoiUtil . PoiUtilCell > > rows = new ArrayList < > ( ) ;
List < List < PoiUtil . PoiUtilCell > > rows = new ArrayList < > ( ) ;
// 标题 表头
// 标题 表头
initAnalyseTitle ( rows , total ) ;
initAnalyseTitle ( rows , total ) ;
int size = reportIds . size ( ) ;
for ( int i = 0 ; i < size ; i + = 200 ) {
List < PatientReportVo . Analyse > analyses = htPatientReportDao . queryReportAnalyseScore ( reportIds . subList ( i , i + 200 > = size ? size : i + 200 ) ) ;
log . info ( "处理长度:{}" , i ) ;
// 处理MMSE的时间定向力和地点定向力
// 处理MMSE的时间定向力和地点定向力
dealMMSEScored ( analyses ) ;
dealMMSEScored ( analyses ) ;
if ( CollectionUtil . isEmpty ( analyses ) ) {
if ( CollectionUtil . isEmpty ( analyses ) ) {
Workbook workbook = new XSSFWorkbook ( ) ;
Workbook workbook = new XSSFWorkbook ( ) ;
PoiUtil . exportWB ( "报告单详情" , rows , workbook ) ;
PoiUtil . exportWB ( "报告单详情" , rows , workbook ) ;
return workbook ;
return null ;
}
}
// 填充数据
// 填充数据
for ( int j = 0 ; j < analyses . size ( ) ; j + + ) {
for ( int j = 0 ; j < analyses . size ( ) ; j + + ) {
@ -1355,11 +1360,71 @@ public class PatientReportService implements IPatientReportService {
fillAnalyse ( row , analyses . get ( j ) ) ;
fillAnalyse ( row , analyses . get ( j ) ) ;
rows . add ( row ) ;
rows . add ( row ) ;
}
}
}
Workbook workbook = new XSSFWorkbook ( ) ;
Workbook workbook = new XSSFWorkbook ( ) ;
PoiUtil . exportWB ( "报告单详情" , rows , workbook ) ;
PoiUtil . exportWB ( "报告单详情" , rows , workbook ) ;
return workbook ;
}
//生成文件
String fileName = "exportExcel/" + DateUtil . today ( ) + "/报告单信息" + System . currentTimeMillis ( ) + ".xlsx" ;
String path = PropUtil . path + fileName ;
File tmpFile = new File ( path ) ;
if ( ! tmpFile . getParentFile ( ) . exists ( ) ) {
tmpFile . getParentFile ( ) . mkdirs ( ) ;
}
log . info ( "生成流" ) ;
OutputStream stream = new FileOutputStream ( tmpFile ) ;
log . info ( "写入wbs" ) ;
workbook . write ( stream ) ;
stream . close ( ) ;
workbook . close ( ) ;
paths . add ( PropUtil . imgDomain + fileName ) ;
}
return paths ;
}
// @Override
// public Workbook exportAnalyseAll(PatientReportDto.Answer answer) {
// log.info("导出全部分析:{}", answer);
// List<Long> reportIds = htPatientScoreDao.queryIdsByAnswer(answer);
// log.info("报告单数量:{}", reportIds.size());
// int total = 124;
// List<List< PoiUtil.PoiUtilCell >> rows = new ArrayList<>();
// // 标题 表头
// initAnalyseTitle(rows, total);
//
// //查询所有报告单的详细信息
// List<PatientReportVo.Analyse> analyses = htPatientReportDao.queryReportAnalyseScore(reportIds);
// // 处理MMSE的时间定向力和地点定向力
// dealMMSEScored(analyses);
// int size = analyses.size();
//
//// for (int i = 0; i < size ; i+=200) {
//// List<PatientReportVo.Analyse> analyses = htPatientReportDao.queryReportAnalyseScore(reportIds.subList(i, i+200 >= size ? size : i+200 ));
//// log.info("处理长度:{}", i);
//// // 处理MMSE的时间定向力和地点定向力
//// dealMMSEScored(analyses);
// if (CollectionUtil.isEmpty(analyses)) {
// Workbook workbook = new XSSFWorkbook();
// PoiUtil.exportWB("报告单详情", rows, workbook);
// return workbook;
// }
//
// // 填充数据
// for (int j = 0; j < analyses.size(); j++) {
//
// List<PoiUtil.PoiUtilCell> row = new ArrayList<>();
// row.add(new PoiUtil.PoiUtilCell(String.valueOf(j+1),1,1));
// for (int m = 1; m < total; m++) {
// row.add(new PoiUtil.PoiUtilCell("",1,1));
// }
// fillAnalyse(row, analyses.get(j));
// rows.add(row);
// }
//// }
// Workbook workbook = new XSSFWorkbook();
// PoiUtil.exportWB("报告单详情", rows, workbook);
// return workbook;
// }
private void initQuestionBody ( int questionSpan , PatientReportVo . QuestionAndAnswer question , PdfUtil . Row row , boolean isLast , int optionSize ) {
private void initQuestionBody ( int questionSpan , PatientReportVo . QuestionAndAnswer question , PdfUtil . Row row , boolean isLast , int optionSize ) {
addCell ( row , question = = null ? Constant . Ht . STRING_DEFAULT : String . valueOf ( question . getSort ( ) ) , 1 , 1 ) ;
addCell ( row , question = = null ? Constant . Ht . STRING_DEFAULT : String . valueOf ( question . getSort ( ) ) , 1 , 1 ) ;