Ver código fonte

es代码提交

Conflicts:
	patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
ES代码提交
liuwenbin 7 anos atrás
pai
commit
becbba7405

+ 56 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -62,6 +62,7 @@ public class StatisticsESService {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXX");
    SimpleDateFormat dateFormat3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    DecimalFormat decimalFormat = new DecimalFormat("0.00");
    /**
     * 获取上次统计时间
     *
@ -3175,7 +3176,7 @@ public class StatisticsESService {
     * @return
     */
    public List<Map<String,Object>> getPrescriptionCostLowLevel(String level,String lowlevel,String area,String disease,String type) throws Exception{
        DecimalFormat decimalFormat=new DecimalFormat("0.00");
        String quotaDate = elasticsearchUtil.getQuotaTime();
        //1.总量
        List<SaveModel> list = elasticsearchUtil.findListDateQuotaLevel1(quotaDate,area,Integer.parseInt(level),"61","2",lowlevel,disease);
@ -3200,8 +3201,9 @@ public class StatisticsESService {
        }else{
            //2.平均值
            //去重获取总人数,计算人均费用
            String sql = "  select count(DISTINCT(s.patient)) as num from wlyy_prescription_pay p left join wlyy_prescription s on p.prescription_code = s. CODE  ";
            String sql = "";
            for(SaveModel one:list){
                sql = "  select count(DISTINCT(s.patient)) as num from wlyy_prescription_pay p left join wlyy_prescription s on p.prescription_code = s. CODE  ";
                sql +=" and  p.trace_time <= "+one.getQuotaDate();
                Map<String, Object> count = jdbcTemplate.queryForMap(sql);
                map = new HashMap<>();
@ -3233,9 +3235,59 @@ public class StatisticsESService {
     * @param endDate
     * @param type 1.按日,2.按周,3.按月
     */
    public List<Map<String,Object>> getPrescriptionCostAvgLine(String level,String area,String disease,String startDate,String endDate,String type){
    public List<Map<String,Object>> getPrescriptionCostAvgLine(String level,String area,String disease,String startDate,String endDate,String type) throws Exception{
        startDate = elasticsearchUtil.changeTime(startDate += " 00:00:00");
        endDate = elasticsearchUtil.changeTime(endDate += " 23:59:59");
        List<SaveModel> list = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate,endDate,area,Integer.parseInt(level),"61","2",type,disease);
        String sql = "";
        Map<String,Object> map = null;
        List<Map<String,Object>> countList = new ArrayList<>();
        for(SaveModel one:list){
            sql = "  select count(DISTINCT(s.patient)) as num from wlyy_prescription_pay p left join wlyy_prescription s on p.prescription_code = s. CODE  ";
            sql += " and  p.trace_time <= "+one.getQuotaDate();
            if(SaveModel.townLevel.equals(level)||SaveModel.cityLevel.equals(level)){
                sql += " and LEFT(s.hospital,6) ='" + area+ "' ";
            }else if(SaveModel.OrgLevel.equals(level)){
                sql += " and s.hospital ='" + area+ "' ";
            }else if(SaveModel.teamLevel.equals(level)){
                sql += " and s.admin_team_id ='" + area+ "' ";
            }
            Map<String, Object> count = jdbcTemplate.queryForMap(sql);
            Long num = (Long)count.get("num");
            String avg = decimalFormat.format(one.getResult1()/num);
            map = new HashMap<>();
            map.put("avg",avg);
            map.put("date",dateFormat.format(one.getQuotaDate()));
            countList.add(map);
        }
        return countList;
    }
        return null;
    public Map<String,Object> getPrescriptionCost(String level,String area,String disease) throws Exception{
        SaveModel saveModel = null;
        String quotaDate = elasticsearchUtil.getQuotaTime();
        if(StringUtils.isNotEmpty(disease)){
            saveModel = elasticsearchUtil.findOneDateQuotaLevel1(quotaDate,area,Integer.parseInt(level),"61","2",disease);
        }else{
            saveModel = elasticsearchUtil.findOneDateQuotaLevel0(quotaDate,area,Integer.parseInt(level),"61","2");
        }
        String sql = "  select count(DISTINCT(s.patient)) as num from wlyy_prescription_pay p left join wlyy_prescription s on p.prescription_code = s. CODE  ";
        sql += " and  p.trace_time <= "+dateFormat3.parse(quotaDate);
        if(SaveModel.townLevel.equals(level)||SaveModel.cityLevel.equals(level)){
            sql += " and LEFT(s.hospital,6) ='" + area+ "' ";
        }else if(SaveModel.OrgLevel.equals(level)){
            sql += " and s.hospital ='" + area+ "' ";
        }else if(SaveModel.teamLevel.equals(level)){
            sql += " and s.admin_team_id ='" + area+ "' ";
        }
        Map<String, Object> count = jdbcTemplate.queryForMap(sql);
        Long num = (Long)count.get("num");
        Map<String,Object> rs = new HashedMap();
        BigDecimal s = BigDecimal.valueOf(num);
        BigDecimal a = BigDecimal.valueOf(saveModel.getResult2()/num);
        rs.put("sum",s.divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP));
        rs.put("avg",a.divide((new BigDecimal(100))).setScale(2,BigDecimal.ROUND_HALF_UP));
        return rs;
    }
}

+ 16 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -1752,7 +1752,22 @@ public class EsStatisticsController extends BaseController {
                                             @ApiParam(name="endDate", value="结束时间") @RequestParam(required = false)String endDate,
                                             @ApiParam(name="type", value="1.按日,2.按周,3.按月") @RequestParam(required = false)String type){
        try{
            return write(200, "查询成功", "data", statisticsService.getPrescriptionCostAvgLine(level,area,disease,startDate,endDate,type));
            level = elasticsearchUtil.changeLevel(Integer.parseInt(level))+"";
            return write(200, "查询成功", "data", statisticsESService.getPrescriptionCostAvgLine(level,area,disease,startDate,endDate,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getPrescriptionCost")
    @ResponseBody
    @ApiOperation("费用统计-顶部部头部接口")
    public String getPrescriptionCost(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                      @ApiParam(name="area", value="界别编码") @RequestParam(required = true)String area,
                                      @ApiParam(name="disease", value="疾病") @RequestParam(required = false)String disease){
        try{
            return write(200, "查询成功", "data", statisticsESService.getPrescriptionCost(level,area,disease));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");