|
|
@ -3,9 +3,12 @@ package com.ccsens.ht.service; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.ccsens.ht.bean.dto.StatisticsDto; |
|
|
|
import com.ccsens.ht.bean.po.HtPosition; |
|
|
|
import com.ccsens.ht.bean.po.HtPositionExample; |
|
|
|
import com.ccsens.ht.bean.po.HtReport; |
|
|
|
import com.ccsens.ht.bean.po.HtReportExample; |
|
|
|
import com.ccsens.ht.bean.vo.PositionVo; |
|
|
|
import com.ccsens.ht.bean.vo.StatisticsVo; |
|
|
|
import com.ccsens.ht.persist.dao.HtPositionDao; |
|
|
@ -23,6 +26,7 @@ import java.util.ArrayList; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author 逗 |
|
|
@ -109,16 +113,173 @@ public class StatisticsService implements IStatisticsService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public StatisticsVo.ReportDistribution reportScore(StatisticsDto.Report report) { |
|
|
|
return null; |
|
|
|
if(StrUtil.isEmpty(report.getReportCode())){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
//生成横坐标(年龄分类 0~18未成年 19~44青年 45~59中年 60~74老人 75~89老年人 90以上长寿老年人)
|
|
|
|
List<String> xAxis = new ArrayList<>(); |
|
|
|
xAxis.add("0~18"); |
|
|
|
xAxis.add("19~44"); |
|
|
|
xAxis.add("45~59"); |
|
|
|
xAxis.add("60~74"); |
|
|
|
xAxis.add("75~89"); |
|
|
|
xAxis.add("90以上"); |
|
|
|
//查找该类型下的总分
|
|
|
|
HtReportExample htReportExample = new HtReportExample(); |
|
|
|
htReportExample.createCriteria().andCodeEqualTo(report.getReportCode()).andTotalScoreGreaterThan(0); |
|
|
|
List<HtReport> reports = htReportDao.selectByExample(htReportExample); |
|
|
|
if(CollectionUtil.isEmpty(reports)){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
int totalScore = reports.get(0).getTotalScore(); |
|
|
|
//TODO 暂时将分数分为三个阶段
|
|
|
|
List<Integer> scoreTypes = new ArrayList<>(); |
|
|
|
int i = totalScore / 3; |
|
|
|
if (i != 0) { |
|
|
|
scoreTypes.add(i); |
|
|
|
scoreTypes.add((totalScore - i)); |
|
|
|
} |
|
|
|
scoreTypes.add(totalScore); |
|
|
|
//根据类型和医院id查询各个类型分数的人数
|
|
|
|
List<StatisticsVo.SundryNum> sundryNumList = statisticsDao.querySundryNumList(report.getReportCode(),report.getHospitalId(),scoreTypes); |
|
|
|
//封装数据
|
|
|
|
List<StatisticsVo.ChartManWoman> chartList = new ArrayList<>(); |
|
|
|
xAxis.forEach(ageType ->{ |
|
|
|
StatisticsVo.ChartManWoman chartManWoman = new StatisticsVo.ChartManWoman(); |
|
|
|
List<Integer> manList = new ArrayList<>(); |
|
|
|
List<Integer> womanList = new ArrayList<>(); |
|
|
|
scoreTypes.forEach(scoreType -> { |
|
|
|
int manNum = 0; |
|
|
|
int womanNum = 0; |
|
|
|
for (StatisticsVo.SundryNum sundryNum : sundryNumList) { |
|
|
|
if(ageType.equals(sundryNum.getAgeType()) && scoreType.toString().equals(sundryNum.getScoreType())){ |
|
|
|
if(sundryNum.getSexType() == 0){ |
|
|
|
manNum = sundryNum.getNum(); |
|
|
|
}else if(sundryNum.getSexType() == 1){ |
|
|
|
womanNum = sundryNum.getNum(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
manList.add(manNum); |
|
|
|
womanList.add(womanNum); |
|
|
|
}); |
|
|
|
chartManWoman.setManList(manList); |
|
|
|
chartManWoman.setWomanList(womanList); |
|
|
|
chartList.add(chartManWoman); |
|
|
|
}); |
|
|
|
//修改分数分类返回
|
|
|
|
List<String> types = new ArrayList<>(); |
|
|
|
String type1 = "0~" + scoreTypes.get(0); |
|
|
|
types.add(type1); |
|
|
|
for (int j = 1; j < scoreTypes.size(); j++) { |
|
|
|
int t = scoreTypes.get(j); |
|
|
|
String type = (scoreTypes.get(j - 1) + 1) + "~" + t; |
|
|
|
types.add(type); |
|
|
|
} |
|
|
|
//返回
|
|
|
|
StatisticsVo.ReportDistribution reportDistribution = new StatisticsVo.ReportDistribution(); |
|
|
|
reportDistribution.setTypes(types); |
|
|
|
reportDistribution.setXAxis(xAxis); |
|
|
|
reportDistribution.setChartList(chartList); |
|
|
|
return reportDistribution; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public StatisticsVo.ReportDistribution subentryScore(StatisticsDto.Report report) { |
|
|
|
return null; |
|
|
|
//生成年龄类型(年龄分类 0~18未成年 19~44青年 45~59中年 60~74老人 75~89老年人 90以上长寿老年人)
|
|
|
|
List<String> types = new ArrayList<>(); |
|
|
|
types.add("0~18"); |
|
|
|
types.add("19~44"); |
|
|
|
types.add("45~59"); |
|
|
|
types.add("60~74"); |
|
|
|
types.add("75~89"); |
|
|
|
types.add("90以上"); |
|
|
|
//查找该类型下的总分
|
|
|
|
HtReportExample htReportExample = new HtReportExample(); |
|
|
|
htReportExample.createCriteria().andCodeEqualTo(report.getSubentryCode()).andTotalScoreGreaterThan(0); |
|
|
|
List<HtReport> reports = htReportDao.selectByExample(htReportExample); |
|
|
|
if(CollectionUtil.isEmpty(reports)){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
int totalScore = reports.get(0).getTotalScore(); |
|
|
|
//生成坐标
|
|
|
|
List<String> axis = new ArrayList<>(); |
|
|
|
for (int i = 0; i <= totalScore; i++) { |
|
|
|
axis.add(i + ""); |
|
|
|
} |
|
|
|
//查找该类型的所有子类
|
|
|
|
List<String> reportList = statisticsDao.getReportSubCode(report.getSubentryCode()); |
|
|
|
if(CollectionUtil.isEmpty(reportList)){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
//通过医院code和子类查询所有类型的人数
|
|
|
|
List<StatisticsVo.SundryNum> sundryNumList = statisticsDao.querySundryNumListBySubentry(report.getHospitalId(),reportList); |
|
|
|
//封装数据
|
|
|
|
List<StatisticsVo.ChartManWoman> chartList = new ArrayList<>(); |
|
|
|
axis.forEach(scoreType ->{ |
|
|
|
StatisticsVo.ChartManWoman chartManWoman = new StatisticsVo.ChartManWoman(); |
|
|
|
List<Integer> manList = new ArrayList<>(); |
|
|
|
List<Integer> womanList = new ArrayList<>(); |
|
|
|
types.forEach(ageType -> { |
|
|
|
int manNum = 0; |
|
|
|
int womanNum = 0; |
|
|
|
for (StatisticsVo.SundryNum sundryNum : sundryNumList) { |
|
|
|
if(ageType.equals(sundryNum.getAgeType()) && scoreType.equals(sundryNum.getScoreType())){ |
|
|
|
if(sundryNum.getSexType() == 0){ |
|
|
|
manNum = sundryNum.getNum(); |
|
|
|
}else if(sundryNum.getSexType() == 1){ |
|
|
|
womanNum = -sundryNum.getNum(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
manList.add(manNum); |
|
|
|
womanList.add(womanNum); |
|
|
|
}); |
|
|
|
chartManWoman.setManList(manList); |
|
|
|
chartManWoman.setWomanList(womanList); |
|
|
|
chartList.add(chartManWoman); |
|
|
|
}); |
|
|
|
//返回
|
|
|
|
StatisticsVo.ReportDistribution reportDistribution = new StatisticsVo.ReportDistribution(); |
|
|
|
reportDistribution.setTypes(types); |
|
|
|
reportDistribution.setXAxis(axis); |
|
|
|
reportDistribution.setChartList(chartList); |
|
|
|
return reportDistribution; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public StatisticsVo.ReportScatterDiagram scatterDiagram(StatisticsDto.Report report) { |
|
|
|
return null; |
|
|
|
StatisticsVo.ReportScatterDiagram scatterDiagram = new StatisticsVo.ReportScatterDiagram(); |
|
|
|
//查找类型和子项的分数
|
|
|
|
HtReportExample codeExample = new HtReportExample(); |
|
|
|
codeExample.createCriteria().andCodeEqualTo(report.getReportCode()).andTotalScoreGreaterThan(0); |
|
|
|
List<HtReport> codeReport = htReportDao.selectByExample(codeExample); |
|
|
|
if(CollectionUtil.isNotEmpty(codeReport)){ |
|
|
|
scatterDiagram.setAllMax(codeReport.get(0).getTotalScore()); |
|
|
|
} |
|
|
|
HtReportExample subentryExample = new HtReportExample(); |
|
|
|
subentryExample.createCriteria().andCodeEqualTo(report.getSubentryCode()).andTotalScoreGreaterThan(0); |
|
|
|
List<HtReport> subentryReport = htReportDao.selectByExample(subentryExample); |
|
|
|
if(CollectionUtil.isNotEmpty(subentryReport)){ |
|
|
|
scatterDiagram.setMMax(subentryReport.get(0).getTotalScore()); |
|
|
|
} |
|
|
|
//查找子项的下属分类(包括自己)
|
|
|
|
List<String> reportList = statisticsDao.getReportSubCode(report.getSubentryCode()); |
|
|
|
if(CollectionUtil.isEmpty(reportList)){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
//查找各个分数的人数
|
|
|
|
List<StatisticsVo.CodeAndSubentryNum> codeAndSubentryNums = statisticsDao.getCodeAndSubentryNums(report.getHospitalId(),report.getReportCode(),reportList); |
|
|
|
//封装数据
|
|
|
|
List<List<Integer>> lists = new ArrayList<>(); |
|
|
|
codeAndSubentryNums.forEach(codeAndSubentryNum -> { |
|
|
|
List<Integer> l = new ArrayList<>(); |
|
|
|
l.add(codeAndSubentryNum.getSubentryScore()); |
|
|
|
l.add(codeAndSubentryNum.getCodeScore()); |
|
|
|
l.add(codeAndSubentryNum.getNum()); |
|
|
|
lists.add(l); |
|
|
|
}); |
|
|
|
scatterDiagram.setList(lists); |
|
|
|
return scatterDiagram; |
|
|
|
} |
|
|
|
} |
|
|
|