10 changed files with 796 additions and 2 deletions
@ -0,0 +1,129 @@ |
|||||
|
package com.ccsens.ht.api; |
||||
|
|
||||
|
import com.ccsens.ht.bean.dto.StatisticsDto; |
||||
|
import com.ccsens.ht.bean.vo.PositionVo; |
||||
|
import com.ccsens.ht.bean.vo.StatisticsVo; |
||||
|
import com.ccsens.ht.service.IStatisticsService; |
||||
|
import com.ccsens.util.JsonResponse; |
||||
|
import io.swagger.annotations.*; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
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 java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author 逗 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Api(tags = "大屏查询统计数据",value = "") |
||||
|
@RestController |
||||
|
@RequestMapping("/statistics") |
||||
|
public class StatisticsController { |
||||
|
|
||||
|
@Resource |
||||
|
private IStatisticsService statisticsService; |
||||
|
|
||||
|
@ApiOperation(value = "查询医院",notes = "") |
||||
|
@ApiImplicitParams({ |
||||
|
}) |
||||
|
@RequestMapping(value="/hospital", method = RequestMethod.GET) |
||||
|
public JsonResponse<List<PositionVo.Position>> queryHospital(){ |
||||
|
log.info("查询医院"); |
||||
|
List<PositionVo.Position> positionList = statisticsService.queryHospital(); |
||||
|
log.info("返回医院信息:{}",positionList); |
||||
|
return JsonResponse.newInstance().ok(positionList); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation(value = "查询测评类型和分项",notes = "") |
||||
|
@ApiImplicitParams({ |
||||
|
}) |
||||
|
@RequestMapping(value="/queryCode", method = RequestMethod.POST) |
||||
|
public JsonResponse<List<StatisticsVo.ReportCode>> queryReportCode(@RequestBody @ApiParam @Validated StatisticsDto.HospitalId hospitalId){ |
||||
|
log.info("查询测评类型和分项"); |
||||
|
List<StatisticsVo.ReportCode> reportCodeList = statisticsService.queryReportCode(hospitalId.getId()); |
||||
|
log.info("返回查询测评类型和分项:{}",reportCodeList); |
||||
|
return JsonResponse.newInstance().ok(reportCodeList); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation(value = "测评人数实时统计",notes = "") |
||||
|
@ApiImplicitParams({ |
||||
|
}) |
||||
|
@RequestMapping(value="/realtime", method = RequestMethod.POST) |
||||
|
public JsonResponse<StatisticsVo.Realtime> realtime(@RequestBody @ApiParam @Validated StatisticsDto.HospitalId hospitalId){ |
||||
|
log.info("测评人数实时统计:{}", hospitalId); |
||||
|
StatisticsVo.Realtime realtime = statisticsService.realtime(hospitalId.getId()); |
||||
|
log.info("测评人数实时统计完成"); |
||||
|
return JsonResponse.newInstance().ok(realtime); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation(value = "查询性别年龄分布",notes = "") |
||||
|
@ApiImplicitParams({ |
||||
|
}) |
||||
|
@RequestMapping(value="/age", method = RequestMethod.POST) |
||||
|
public JsonResponse<StatisticsVo.AgeAndSex> ageAndSex(@RequestBody @ApiParam @Validated StatisticsDto.HospitalId hospitalId){ |
||||
|
log.info("查询性别年龄分布:{}", hospitalId); |
||||
|
StatisticsVo.AgeAndSex ageAndSex = statisticsService.ageAndSex(hospitalId.getId()); |
||||
|
log.info("查询性别年龄分布完成"); |
||||
|
return JsonResponse.newInstance().ok(ageAndSex); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation(value = "区域分布",notes = "") |
||||
|
@ApiImplicitParams({ |
||||
|
}) |
||||
|
@RequestMapping(value="/area", method = RequestMethod.POST) |
||||
|
public JsonResponse<StatisticsVo.AreaDistribution> areaDistribution(@RequestBody @ApiParam @Validated StatisticsDto.HospitalId hospitalId){ |
||||
|
log.info("查询区域分布:{}", hospitalId); |
||||
|
StatisticsVo.AreaDistribution areaDistribution = statisticsService.areaDistribution(hospitalId.getId()); |
||||
|
log.info("查询区域分布完成"); |
||||
|
return JsonResponse.newInstance().ok(areaDistribution); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation(value = "测评结果总评分布",notes = "") |
||||
|
@ApiImplicitParams({ |
||||
|
}) |
||||
|
@RequestMapping(value="/appraise", method = RequestMethod.POST) |
||||
|
public JsonResponse<List<StatisticsVo.Chart>> appraise(@RequestBody @ApiParam @Validated StatisticsDto.HospitalId hospitalId){ |
||||
|
log.info("查询测评结果总评分布:{}", hospitalId); |
||||
|
List<StatisticsVo.Chart> chartList = statisticsService.appraise(hospitalId.getId()); |
||||
|
log.info("查询测评结果总评分布完成"); |
||||
|
return JsonResponse.newInstance().ok(chartList); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation(value = "报告单总分分布 ",notes = "") |
||||
|
@ApiImplicitParams({ |
||||
|
}) |
||||
|
@RequestMapping(value="/report", method = RequestMethod.POST) |
||||
|
public JsonResponse<StatisticsVo.ReportDistribution> reportScore(@RequestBody @ApiParam @Validated StatisticsDto.Report report){ |
||||
|
log.info("查询报告单总分分布:{}", report); |
||||
|
StatisticsVo.ReportDistribution reportDistribution = statisticsService.reportScore(report); |
||||
|
log.info("查询报告单总分分布完成"); |
||||
|
return JsonResponse.newInstance().ok(reportDistribution); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation(value = "报告单分项分数分布 ",notes = "") |
||||
|
@ApiImplicitParams({ |
||||
|
}) |
||||
|
@RequestMapping(value="/subentry", method = RequestMethod.POST) |
||||
|
public JsonResponse<StatisticsVo.ReportDistribution> subentryScore(@RequestBody @ApiParam @Validated StatisticsDto.Report report){ |
||||
|
log.info("查询报告单分项分数分布:{}", report); |
||||
|
StatisticsVo.ReportDistribution reportDistribution = statisticsService.subentryScore(report); |
||||
|
log.info("查询报告单分项分数分布完成"); |
||||
|
return JsonResponse.newInstance().ok(reportDistribution); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation(value = "报告单分数散点图",notes = "") |
||||
|
@ApiImplicitParams({ |
||||
|
}) |
||||
|
@RequestMapping(value="/scatter", method = RequestMethod.POST) |
||||
|
public JsonResponse<StatisticsVo.ReportScatterDiagram> scatterDiagram(@RequestBody @ApiParam @Validated StatisticsDto.Report report){ |
||||
|
log.info("查询报告单分数散点图:{}", report); |
||||
|
StatisticsVo.ReportScatterDiagram reportScatterDiagram = statisticsService.scatterDiagram(report); |
||||
|
log.info("查询报告单分数散点图完成"); |
||||
|
return JsonResponse.newInstance().ok(reportScatterDiagram); |
||||
|
} |
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
package com.ccsens.ht.bean.dto; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class StatisticsDto { |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("请求-医院id") |
||||
|
public static class HospitalId{ |
||||
|
@ApiModelProperty("医院id") |
||||
|
private Long id; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("请求-报告单类型信息") |
||||
|
public static class Report{ |
||||
|
@ApiModelProperty("医院id") |
||||
|
private Long hospitalId; |
||||
|
@ApiModelProperty("报告单类型code") |
||||
|
private Long reportCode; |
||||
|
@ApiModelProperty("报告单分项code") |
||||
|
private Long subentryCode; |
||||
|
} |
||||
|
} |
@ -0,0 +1,103 @@ |
|||||
|
package com.ccsens.ht.bean.vo; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import jnr.ffi.annotations.In; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author 逗 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class StatisticsVo { |
||||
|
|
||||
|
@ApiModel("返回-测评人数实时统计") |
||||
|
@Data |
||||
|
public static class Realtime{ |
||||
|
@ApiModelProperty("累计") |
||||
|
private int totalNum; |
||||
|
@ApiModelProperty("本月") |
||||
|
private int monthNum; |
||||
|
@ApiModelProperty("本日") |
||||
|
private int dayNum; |
||||
|
@ApiModelProperty("折线图数据") |
||||
|
private List<Chart> chartList; |
||||
|
} |
||||
|
|
||||
|
@ApiModel("图表数据-类型数据") |
||||
|
@Data |
||||
|
public static class Chart{ |
||||
|
@ApiModelProperty("类型") |
||||
|
private String type; |
||||
|
@ApiModelProperty("数量") |
||||
|
private int num; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("返回-性别年龄分布") |
||||
|
public static class AgeAndSex{ |
||||
|
@ApiModelProperty("男性人数") |
||||
|
private int man; |
||||
|
@ApiModelProperty("女性人数") |
||||
|
private int woman; |
||||
|
@ApiModelProperty("年龄分布数据") |
||||
|
private List<Chart> chartList; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("返回-区域分布") |
||||
|
public static class AreaDistribution{ |
||||
|
@ApiModelProperty("当前省份") |
||||
|
private String name; |
||||
|
@ApiModelProperty("当前省份数量") |
||||
|
private int num; |
||||
|
@ApiModelProperty("省份分布数据") |
||||
|
private List<Chart> chartList; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("返回-报告单分数分布") |
||||
|
public static class ReportDistribution{ |
||||
|
@ApiModelProperty("数据类型") |
||||
|
private List<String> types; |
||||
|
@ApiModelProperty("横坐标类型") |
||||
|
private List<String> xAxis; |
||||
|
@ApiModelProperty("数据") |
||||
|
private List<ChartManWoman> chartList; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("图表数据-男女") |
||||
|
public static class ChartManWoman{ |
||||
|
@ApiModelProperty("男生数据") |
||||
|
private List<Integer> manList; |
||||
|
@ApiModelProperty("女生数据") |
||||
|
private List<Integer> womanList; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("返回-报告单分数散点图") |
||||
|
public static class ReportScatterDiagram{ |
||||
|
@ApiModelProperty("测评类型的最大分") |
||||
|
private int allMax; |
||||
|
@ApiModelProperty("分项的最大分") |
||||
|
private int mMax; |
||||
|
@ApiModelProperty("数据") |
||||
|
private List<List<Integer>> list; |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("返回-查询试题类型") |
||||
|
public static class ReportCode{ |
||||
|
@ApiModelProperty("id") |
||||
|
private Long id; |
||||
|
@ApiModelProperty("类型名") |
||||
|
private String name; |
||||
|
@ApiModelProperty("code") |
||||
|
private String code; |
||||
|
@ApiModelProperty("分项信息") |
||||
|
private List<ReportCode> subentryList; |
||||
|
} |
||||
|
} |
@ -0,0 +1,66 @@ |
|||||
|
package com.ccsens.ht.persist.dao; |
||||
|
|
||||
|
import com.ccsens.ht.bean.vo.StatisticsVo; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
import org.springframework.stereotype.Repository; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author 逗 |
||||
|
*/ |
||||
|
@Repository |
||||
|
public interface StatisticsDao { |
||||
|
|
||||
|
/** |
||||
|
* 查找总数 当月数量 当天数量 |
||||
|
* @param hospitalId 医院id |
||||
|
* @param beginOfMonth 本月开始时间 |
||||
|
* @param endOfMonth 本月结束时间 |
||||
|
* @param beginOfDay 当天开始时间 |
||||
|
* @param endOfDay 当天结束时间 |
||||
|
* @return 返回总数 本月数量 当天数量 |
||||
|
*/ |
||||
|
StatisticsVo.Realtime getTotalNum(@Param("hospitalId") long hospitalId, @Param("beginOfMonth") long beginOfMonth,@Param("endOfMonth") long endOfMonth,@Param("beginOfDay") long beginOfDay,@Param("endOfDay") long endOfDay); |
||||
|
|
||||
|
/** |
||||
|
* 查找实时数据 |
||||
|
* @param hospitalId 医院Id |
||||
|
* @return 返回实时数据 |
||||
|
*/ |
||||
|
List<StatisticsVo.Chart> getRealtimeNum(@Param("hospitalId") Long hospitalId); |
||||
|
|
||||
|
/** |
||||
|
* 查找年龄分布信息 |
||||
|
* @param hospitalId 医院id |
||||
|
* @return 返回各个年龄段的数量 |
||||
|
*/ |
||||
|
List<StatisticsVo.Chart> getWithAge(@Param("hospitalId")Long hospitalId); |
||||
|
|
||||
|
/** |
||||
|
* 查找男女占比 |
||||
|
* @param hospitalId 医院id |
||||
|
* @return 返回男女数量 |
||||
|
*/ |
||||
|
StatisticsVo.AgeAndSex getWithSex(@Param("hospitalId")Long hospitalId); |
||||
|
|
||||
|
/** |
||||
|
* 查找测评结果总评分布 |
||||
|
* @param hospitalId 医院id |
||||
|
* @return 返回总评分布 |
||||
|
*/ |
||||
|
List<StatisticsVo.Chart> getAppraise(@Param("hospitalId")Long hospitalId); |
||||
|
|
||||
|
/** |
||||
|
* 查找各省份的数据 |
||||
|
* @return 返回省份数据 |
||||
|
*/ |
||||
|
List<StatisticsVo.Chart> areaDistribution(); |
||||
|
|
||||
|
/** |
||||
|
* 查找医院所在省份的数据 |
||||
|
* @param hospitalId 医院id |
||||
|
* @return 返回医院所在省份的数据 |
||||
|
*/ |
||||
|
StatisticsVo.AreaDistribution hospitalProvince(@Param("hospitalId")Long hospitalId); |
||||
|
} |
@ -0,0 +1,76 @@ |
|||||
|
package com.ccsens.ht.service; |
||||
|
|
||||
|
import com.ccsens.ht.bean.dto.StatisticsDto; |
||||
|
import com.ccsens.ht.bean.vo.PositionVo; |
||||
|
import com.ccsens.ht.bean.vo.StatisticsVo; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author 逗 |
||||
|
*/ |
||||
|
public interface IStatisticsService { |
||||
|
|
||||
|
/** |
||||
|
* 查找医院信息 |
||||
|
* @return 返回医院信息 |
||||
|
*/ |
||||
|
List<PositionVo.Position> queryHospital(); |
||||
|
|
||||
|
/** |
||||
|
* 查找测评类型和分项 |
||||
|
* @param hospitalId 医院id |
||||
|
* @return 返回测评类型和分项 |
||||
|
*/ |
||||
|
List<StatisticsVo.ReportCode> queryReportCode(Long hospitalId); |
||||
|
|
||||
|
/** |
||||
|
* 测评人数实时统计 |
||||
|
* @param hospitalId 医院id |
||||
|
* @return 返回实时统计数据 |
||||
|
*/ |
||||
|
StatisticsVo.Realtime realtime(Long hospitalId); |
||||
|
|
||||
|
/** |
||||
|
* 查找性别年龄分布图 |
||||
|
* @param hospitalId 医院id |
||||
|
* @return 返回性别年龄分布信息 |
||||
|
*/ |
||||
|
StatisticsVo.AgeAndSex ageAndSex(Long hospitalId); |
||||
|
|
||||
|
/** |
||||
|
* 查询区域分布信息 |
||||
|
* @param hospitalId 医院id |
||||
|
* @return 返回区域分布信息 |
||||
|
*/ |
||||
|
StatisticsVo.AreaDistribution areaDistribution(Long hospitalId); |
||||
|
|
||||
|
/** |
||||
|
* 测评结果总评分布 |
||||
|
* @param hospitalId 医院id |
||||
|
* @return 返回总评分布 |
||||
|
*/ |
||||
|
List<StatisticsVo.Chart> appraise(Long hospitalId); |
||||
|
|
||||
|
/** |
||||
|
* 查询报告单总分分布 |
||||
|
* @param report 测评类型信息 |
||||
|
* @return 返回报告单总分分布 |
||||
|
*/ |
||||
|
StatisticsVo.ReportDistribution reportScore(StatisticsDto.Report report); |
||||
|
|
||||
|
/** |
||||
|
* 报告单分项分数分布 |
||||
|
* @param report 测评类型信息 |
||||
|
* @return 返回报告单分项分数分布 |
||||
|
*/ |
||||
|
StatisticsVo.ReportDistribution subentryScore(StatisticsDto.Report report); |
||||
|
|
||||
|
/** |
||||
|
* 查询报告单分数散点图 |
||||
|
* @param report 测评类型信息 |
||||
|
* @return 返回散点图信息 |
||||
|
*/ |
||||
|
StatisticsVo.ReportScatterDiagram scatterDiagram(StatisticsDto.Report report); |
||||
|
|
||||
|
} |
@ -0,0 +1,124 @@ |
|||||
|
package com.ccsens.ht.service; |
||||
|
|
||||
|
import cn.hutool.core.collection.CollectionUtil; |
||||
|
import cn.hutool.core.date.DateUtil; |
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
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.vo.PositionVo; |
||||
|
import com.ccsens.ht.bean.vo.StatisticsVo; |
||||
|
import com.ccsens.ht.persist.dao.HtPositionDao; |
||||
|
import com.ccsens.ht.persist.dao.HtReportDao; |
||||
|
import com.ccsens.ht.persist.dao.StatisticsDao; |
||||
|
import com.ccsens.ht.uitl.Constant; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Propagation; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Collection; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author 逗 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
||||
|
public class StatisticsService implements IStatisticsService { |
||||
|
|
||||
|
@Resource |
||||
|
private HtPositionDao htPositionDao; |
||||
|
@Resource |
||||
|
private HtReportDao htReportDao; |
||||
|
@Resource |
||||
|
private StatisticsDao statisticsDao; |
||||
|
|
||||
|
@Override |
||||
|
public List<PositionVo.Position> queryHospital() { |
||||
|
List<PositionVo.Position> list = null; |
||||
|
//查找所有的医院信息
|
||||
|
HtPositionExample example = new HtPositionExample(); |
||||
|
example.createCriteria().andTypeEqualTo(Constant.Ht.Position.POSITION_MAP_HOSPITAL); |
||||
|
List<HtPosition> positionList = htPositionDao.selectByExample(example); |
||||
|
if(CollectionUtil.isNotEmpty(positionList)){ |
||||
|
list = PositionVo.Position.copy(positionList); |
||||
|
} |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<StatisticsVo.ReportCode> queryReportCode(Long hospitalId) { |
||||
|
return htReportDao.queryReportAndSubentry(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public StatisticsVo.Realtime realtime(Long hospitalId) { |
||||
|
//获取当前月的开始结束时间
|
||||
|
long beginOfMonth = DateUtil.beginOfMonth(new Date()).getTime(); |
||||
|
long endOfMonth = DateUtil.endOfMonth(new Date()).getTime(); |
||||
|
//获取当前开始结束时间
|
||||
|
long beginOfDay = DateUtil.beginOfDay(new Date()).getTime(); |
||||
|
long endOfDay = DateUtil.endOfDay(new Date()).getTime(); |
||||
|
//查找总数,当月,当天数量
|
||||
|
StatisticsVo.Realtime realtime = statisticsDao.getTotalNum(hospitalId,beginOfMonth,endOfMonth,beginOfDay,endOfDay); |
||||
|
//查找折线图里的数据
|
||||
|
List<StatisticsVo.Chart> chartList = statisticsDao.getRealtimeNum(hospitalId); |
||||
|
//返回
|
||||
|
if(ObjectUtil.isNotNull(realtime)){ |
||||
|
realtime.setChartList(chartList); |
||||
|
} |
||||
|
return realtime; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public StatisticsVo.AgeAndSex ageAndSex(Long hospitalId) { |
||||
|
//查找男女分布信息
|
||||
|
StatisticsVo.AgeAndSex ageAndSex = statisticsDao.getWithSex(hospitalId); |
||||
|
//0~18未成年 19~44青年 45~59中年 60~74老人 75~89老年人 90以上长寿老年人
|
||||
|
List<StatisticsVo.Chart> chartList = statisticsDao.getWithAge(hospitalId); |
||||
|
//返回
|
||||
|
if(ObjectUtil.isNotNull(ageAndSex)){ |
||||
|
ageAndSex.setChartList(chartList); |
||||
|
} |
||||
|
return ageAndSex; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public StatisticsVo.AreaDistribution areaDistribution(Long hospitalId) { |
||||
|
//查找医院所在省的数据
|
||||
|
StatisticsVo.AreaDistribution areaDistribution = statisticsDao.hospitalProvince(hospitalId); |
||||
|
//查找各省份的数据
|
||||
|
List<StatisticsVo.Chart> chartList = statisticsDao.areaDistribution(); |
||||
|
//返回
|
||||
|
if(ObjectUtil.isNotNull(areaDistribution)){ |
||||
|
areaDistribution.setChartList(chartList); |
||||
|
} |
||||
|
return areaDistribution; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<StatisticsVo.Chart> appraise(Long hospitalId) { |
||||
|
return statisticsDao.getAppraise(hospitalId); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public StatisticsVo.ReportDistribution reportScore(StatisticsDto.Report report) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public StatisticsVo.ReportDistribution subentryScore(StatisticsDto.Report report) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public StatisticsVo.ReportScatterDiagram scatterDiagram(StatisticsDto.Report report) { |
||||
|
return null; |
||||
|
} |
||||
|
} |
@ -0,0 +1,223 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.ccsens.ht.persist.dao.StatisticsDao"> |
||||
|
|
||||
|
|
||||
|
<select id="getTotalNum" resultType="com.ccsens.ht.bean.vo.StatisticsVo$Realtime"> |
||||
|
|
||||
|
SELECT |
||||
|
MAX( CASE a.type WHEN 'total' THEN num ELSE 0 END ) as `totalNum`, |
||||
|
MAX( CASE a.type WHEN 'month' THEN num ELSE 0 END ) as `monthNum`, |
||||
|
MAX( CASE a.type WHEN 'day' THEN num ELSE 0 END ) as `dayNum` |
||||
|
FROM |
||||
|
( |
||||
|
SELECT |
||||
|
'total' as type, |
||||
|
count(r.id) as num |
||||
|
FROM |
||||
|
t_ht_position p, |
||||
|
t_ht_patient_report r |
||||
|
WHERE |
||||
|
p.`name` = r.hospital |
||||
|
and r.complete_status = 1 |
||||
|
AND r.show_status = 1 |
||||
|
and p.id = #{hospitalId} |
||||
|
and p.is_del = 0 |
||||
|
and r.is_del = 0 |
||||
|
UNION |
||||
|
SELECT |
||||
|
'month' as type, |
||||
|
count(r.id) as num |
||||
|
FROM |
||||
|
t_ht_position p, |
||||
|
t_ht_patient_report r |
||||
|
WHERE |
||||
|
p.`name` = r.hospital |
||||
|
and r.complete_status = 1 |
||||
|
AND r.show_status = 1 |
||||
|
and p.id = #{hospitalId} |
||||
|
and r.report_time >= #{beginOfMonth} |
||||
|
and r.report_time <= #{endOfMonth} |
||||
|
and p.is_del = 0 |
||||
|
and r.is_del = 0 |
||||
|
UNION |
||||
|
SELECT |
||||
|
'day' as type, |
||||
|
count(r.id) as num |
||||
|
FROM |
||||
|
t_ht_position p, |
||||
|
t_ht_patient_report r |
||||
|
WHERE |
||||
|
p.`name` = r.hospital |
||||
|
and r.complete_status = 1 |
||||
|
AND r.show_status = 1 |
||||
|
and p.id = #{hospitalId} |
||||
|
and r.report_time >= #{beginOfDay} |
||||
|
and r.report_time <= #{endOfDay} |
||||
|
and p.is_del = 0 |
||||
|
and r.is_del = 0 |
||||
|
)a |
||||
|
</select> |
||||
|
<select id="getRealtimeNum" resultType="com.ccsens.ht.bean.vo.StatisticsVo$Chart"> |
||||
|
SELECT |
||||
|
count(a.id) as num, |
||||
|
a.type as type |
||||
|
FROM |
||||
|
( |
||||
|
SELECT |
||||
|
r.id, |
||||
|
FROM_UNIXTIME(r.report_time/1000, '%Y-%m-%d') as type |
||||
|
FROM |
||||
|
t_ht_position p, |
||||
|
t_ht_patient_report r |
||||
|
WHERE |
||||
|
p.`name` = r.hospital |
||||
|
and r.complete_status = 1 |
||||
|
AND r.show_status = 1 |
||||
|
and p.id = #{hospitalId} |
||||
|
and p.is_del = 0 |
||||
|
and r.is_del = 0 |
||||
|
)a |
||||
|
GROUP BY a.type |
||||
|
order BY a.type |
||||
|
</select> |
||||
|
<select id="getWithAge" resultType="com.ccsens.ht.bean.vo.StatisticsVo$Chart"> |
||||
|
SELECT |
||||
|
count(a.id) as num, |
||||
|
a.type |
||||
|
FROM |
||||
|
( |
||||
|
SELECT |
||||
|
r.id, |
||||
|
CASE 1 |
||||
|
WHEN |
||||
|
IF( r.patient_age <= 18, 1, 0 ) THEN '0~18' |
||||
|
WHEN |
||||
|
IF( r.patient_age <= 44, 1, 0 ) THEN '19~44' |
||||
|
WHEN |
||||
|
IF( r.patient_age <= 59, 1, 0 ) THEN '45~59' |
||||
|
WHEN |
||||
|
IF( r.patient_age <= 74, 1, 0 ) THEN '60~74' |
||||
|
WHEN |
||||
|
IF( r.patient_age <= 89, 1, 0 ) THEN '75~89' ELSE '90以上' |
||||
|
END as type |
||||
|
FROM |
||||
|
t_ht_position p, |
||||
|
t_ht_patient_report r |
||||
|
WHERE |
||||
|
p.`name` = r.hospital |
||||
|
and r.complete_status = 1 |
||||
|
AND r.show_status = 1 |
||||
|
and p.id = #{hospitalId} |
||||
|
and p.is_del = 0 |
||||
|
and r.is_del = 0 |
||||
|
GROUP BY r.id |
||||
|
)a |
||||
|
GROUP BY a.type |
||||
|
</select> |
||||
|
<select id="getWithSex" resultType="com.ccsens.ht.bean.vo.StatisticsVo$AgeAndSex"> |
||||
|
SELECT |
||||
|
MAX( CASE p.sex WHEN '女' THEN p.num ELSE 0 END ) as `woman`, |
||||
|
MAX( CASE p.sex WHEN '男' THEN p.num ELSE 0 END ) as `man` |
||||
|
FROM |
||||
|
( |
||||
|
SELECT |
||||
|
if(a.sex = 0, '女', '男') as sex, |
||||
|
count(a.id) as num |
||||
|
FROM |
||||
|
( |
||||
|
SELECT |
||||
|
r.id, |
||||
|
pa.sex |
||||
|
FROM |
||||
|
t_ht_position p, |
||||
|
t_ht_patient_report r, |
||||
|
t_ht_patient pa |
||||
|
WHERE |
||||
|
p.`name` = r.hospital |
||||
|
and r.patient_id = pa.id |
||||
|
and r.complete_status = 1 |
||||
|
AND r.show_status = 1 |
||||
|
and p.id = #{hospitalId} |
||||
|
and p.is_del = 0 |
||||
|
and r.is_del = 0 |
||||
|
and pa.is_del = 0 |
||||
|
GROUP BY r.id |
||||
|
)a |
||||
|
GROUP BY a.sex |
||||
|
)p |
||||
|
</select> |
||||
|
<select id="getAppraise" resultType="com.ccsens.ht.bean.vo.StatisticsVo$Chart"> |
||||
|
SELECT |
||||
|
clinical_diagnosis AS type, |
||||
|
count(*) AS num |
||||
|
FROM |
||||
|
t_ht_position p, |
||||
|
t_ht_patient_report r |
||||
|
WHERE |
||||
|
p.`name` = r.hospital |
||||
|
and r.complete_status = 1 |
||||
|
AND r.show_status = 1 |
||||
|
and r.clinical_diagnosis != '' |
||||
|
and p.id = #{hospitalId} |
||||
|
and p.is_del = 0 |
||||
|
and r.is_del = 0 |
||||
|
GROUP BY r.clinical_diagnosis |
||||
|
ORDER BY num DESC |
||||
|
</select> |
||||
|
<select id="areaDistribution" resultType="com.ccsens.ht.bean.vo.StatisticsVo$Chart"> |
||||
|
SELECT |
||||
|
i.province as type, |
||||
|
count(r.id) as num |
||||
|
FROM |
||||
|
t_ht_patient_report r, |
||||
|
t_ht_position p, |
||||
|
t_ht_hospital_info i |
||||
|
WHERE |
||||
|
p.`name` = r.hospital |
||||
|
and p.id = i.position_id |
||||
|
and r.complete_status = 1 |
||||
|
AND r.show_status = 1 |
||||
|
and p.is_del = 0 |
||||
|
and r.is_del = 0 |
||||
|
and i.is_del = 0 |
||||
|
GROUP BY i.province |
||||
|
</select> |
||||
|
<select id="hospitalProvince" resultType="com.ccsens.ht.bean.vo.StatisticsVo$AreaDistribution"> |
||||
|
SELECT |
||||
|
count(r.id) as num, |
||||
|
p.province as `name` |
||||
|
FROM |
||||
|
( |
||||
|
SELECT |
||||
|
p.`name`, |
||||
|
a.province |
||||
|
FROM |
||||
|
( |
||||
|
SELECT |
||||
|
i.province |
||||
|
FROM |
||||
|
t_ht_position p, |
||||
|
t_ht_hospital_info i |
||||
|
WHERE |
||||
|
p.id = i.position_id |
||||
|
and p.id = #{hospitalId} |
||||
|
and p.is_del = 0 |
||||
|
and i.is_del = 0 |
||||
|
)a, |
||||
|
t_ht_hospital_info i, |
||||
|
t_ht_position p |
||||
|
WHERE |
||||
|
i.province = a.province |
||||
|
and i.position_id = p.id |
||||
|
and p.is_del = 0 |
||||
|
and i.is_del = 0 |
||||
|
)p, |
||||
|
t_ht_patient_report r |
||||
|
WHERE |
||||
|
p.`name` = r.hospital |
||||
|
and r.complete_status = 1 |
||||
|
and r.show_status = 1 |
||||
|
and r.is_del = 0 |
||||
|
</select> |
||||
|
</mapper> |
Loading…
Reference in new issue