Parcourir la source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

liubing il y a 3 ans
Parent
commit
9798da104b

+ 64 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java

@ -0,0 +1,64 @@
package com.yihu.jw.care.endpoint.statistics;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.statistics.StatisticsService;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/6/16
 * @Description:
 */
@RestController
@RequestMapping(value = "open/statistics")
@Api(value = "大屏-统计相关", description = "大屏-统计相关", tags = {"大屏-统计相关"})
public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private StatisticsService statisticsService;
    @GetMapping(value = "statisticsTotalAmount")
    @ApiOperation(value = "统计总数")
    public ObjEnvelop statisticsTotalAmount(
            @RequestParam(required = true) String endDate) {
        try {
            JSONObject result = statisticsService.statisticsTotalAmount(endDate);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "serviceRankingAnalysis")
    @ApiOperation(value = "服务排名分析")
    public ListEnvelop serviceRankingAnalysis(
            @RequestParam(required = true) String endDate,@RequestParam(required = true) String orgType) {
        try {
            return success(statisticsService.serviceRankingAnalysis(endDate,orgType));
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "realTimeData")
    @ApiOperation(value = "大屏实时数据")
    public ObjEnvelop realTimeData() {
        try {
            JSONObject result = statisticsService.realTimeData();
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
}

+ 113 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java

@ -3,6 +3,7 @@ package com.yihu.jw.care.service.statistics;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.care.vo.NumVo;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -10,6 +11,7 @@ import com.yihu.jw.es.util.ElasticsearchUtil;
import com.yihu.jw.es.util.SaveModel;
import com.yihu.jw.es.util.SaveModel;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
@ -17,8 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import java.util.Calendar;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
/**
 *
 *
@ -44,6 +46,115 @@ public class StatisticsService {
    @Autowired
    @Autowired
    private StatisticsUtilService statisticsUtilService;
    private StatisticsUtilService statisticsUtilService;
    private static final String defalutArea = "330100";
    /**
     * 2 市  3区  4医院 5、科室 6医生
     */
    private static final Integer defalutLevel = 2;
    /**
     * 统计总数
     * @param endDate
     * @return
     * @throws Exception
     */
    public JSONObject statisticsTotalAmount( String endDate) throws Exception {
        JSONObject res = new JSONObject();
        String index = "28,31,35,37,39,41,43,44";
        String[] indexes = index.split(",");
        for(String ind:indexes){
            //总量
            SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, ind, SaveModel.timeLevel_DDL);
            res.put("index_"+ind,saveModel.getResult2().longValue());
        }
        //评估类型
        res.put("capacityAssessment",capacityAssessment(endDate,defalutArea,defalutLevel));
        return res;
    }
    /**
     * 服务排名分析
     * @param endDate
     * @param orgType
     */
    public List<NumVo> serviceRankingAnalysis(String endDate, String orgType) throws Exception {
        String index = "28,35";
        if("3".equals(orgType)){
            index = "31,39,44";
        }
        String[] indexes = index.split(",");
        Map<String,NumVo> map = new HashedMap();
        for(String ind:indexes){
            //总量
            List<SaveModel> saveModels = elasticsearchUtil.findDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, ind, SaveModel.timeLevel_DDL,null,SaveModel.OrgLevel);
            for (SaveModel saveModel:saveModels){
                String orgCode = saveModel.getHospital();
                if(StringUtils.isBlank(orgCode)){
                    continue;
                }
                if(map.containsKey(orgCode)){
                    NumVo numVo = map.get(orgCode);
                    Long num = saveModel.getResult2().longValue()+numVo.getNum();
                    numVo.setNum(num);
                }else{
                    NumVo numVo = new NumVo();
                    numVo.setCode(orgCode);
                    numVo.setName(saveModel.getHospitalName());
                    numVo.setNum(saveModel.getResult2().longValue());
                    map.put(orgCode,numVo);
                }
            }
        }
        List<NumVo> list = new ArrayList<>();
        for (String key:map.keySet()){
            list.add(map.get(key));
        }
        list=list.stream().sorted(Comparator.comparing(NumVo::getNum).reversed()).collect(Collectors.toList());
        return list;
    }
    /**
     * 大屏实时数据 半小时刷新一次只能查数据库
     */
    public JSONObject realTimeData() throws Exception{
        JSONObject json = new JSONObject();
        //幼儿数
        String sql = "SELECT COUNT(DISTINCT patient) from base_doctor_patient_tmp WHERE del = 1 ";
        Integer childNum = jdbcTemplate.queryForObject(sql,Integer.class);
        json.put("childNum",childNum);
        //幼儿 服务次数
        String startDate = DateUtil.getNowYear()+"-01-01 00:00:00";
        String endDate = DateUtil.getStringDate();
        String sql28 = "SELECT COUNT(o.consult) FROM wlyy_consult_team o WHERE o.type = 23 and o.czrq >='"+startDate+"' ";
        String sql35 = "SELECT COUNT(o.patient) FROM base_door_coach_order o WHERE o.`status`=6  and o.update_time>='"+startDate+"' ";
        Integer num28 = jdbcTemplate.queryForObject(sql28,Integer.class);
        Integer num35 = jdbcTemplate.queryForObject(sql35,Integer.class);
        Integer childServiceNum = num28+num35;
        json.put("childServiceNum",childServiceNum);
        //老人 服务次数
        String sql31 = "SELECT COUNT(o.consult) FROM wlyy_consult_team o WHERE o.type = 24 and o.czrq >='"+startDate+"' ";
        String sql39 = "SELECT COUNT(o.patient) FROM base_life_care_order o WHERE o.`status`=2 and o.update_time>='"+startDate+"' ";
        String sql44 = "SELECT COUNT(o.id) FROM base_life_care_order o WHERE o.`status`>0 and o.type = 3 and o.update_time>='"+startDate+"' ";
        Integer num31 = jdbcTemplate.queryForObject(sql31,Integer.class);
        Integer num39 = jdbcTemplate.queryForObject(sql39,Integer.class);
        Integer num44 = jdbcTemplate.queryForObject(sql44,Integer.class);
        Integer olderServiceNum = num31 + num39 + num44;
        json.put("olderServiceNum",olderServiceNum);
        String signSql = " SELECT COUNT(sr.id) " +
                " FROM " +
                "  base_service_package_sign_record sr " +
                " WHERE " +
                "  sr.STATUS = 1 ";
        //当前签约老人数
        Integer signNum = jdbcTemplate.queryForObject(signSql,Integer.class);
        json.put("signNum",signNum);
        return json;
    }
    /**
    /**
     * 统计总数
     * 统计总数

+ 41 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/vo/NumVo.java

@ -0,0 +1,41 @@
package com.yihu.jw.care.vo;
import java.io.Serializable;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/6/16
 * @Description:
 */
public class NumVo implements Serializable{
    private Long num;
    private String code;
    private String name;
    public Long getNum() {
        return num;
    }
    public void setNum(Long num) {
        this.num = num;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}

+ 2 - 0
svr/svr-statistics-es/doc/sql/初始统计数据.txt

@ -16,6 +16,8 @@ INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d19ec9000a', NULL, 'quota_org_type', '40', '3', '', '40', NULL, '2021-06-11 14:45:35.049', '123', NULL, '2021-06-11 14:45:35.049', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d19ec9000a', NULL, 'quota_org_type', '40', '3', '', '40', NULL, '2021-06-11 14:45:35.049', '123', NULL, '2021-06-11 14:45:35.049', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d19ec9001a', NULL, 'quota_org_type', '41', '3', '', '41', NULL, '2021-06-11 14:45:35.049', '123', NULL, '2021-06-11 14:45:35.049', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d19ec9001a', NULL, 'quota_org_type', '41', '3', '', '41', NULL, '2021-06-11 14:45:35.049', '123', NULL, '2021-06-11 14:45:35.049', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f9fbb6017a12c67cab0001', NULL, 'quota_org_type', '42', '4', '', '42', NULL, '2021-06-16 11:03:55.819', '123', NULL, '2021-06-16 11:03:55.819', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f9fbb6017a12c67cab0001', NULL, 'quota_org_type', '42', '4', '', '42', NULL, '2021-06-16 11:03:55.819', '123', NULL, '2021-06-16 11:03:55.819', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f9fbb6017a143681370005', NULL, 'quota_org_type', '43', '3', '', '43', NULL, '2021-06-16 17:45:54.231', '123', NULL, '2021-06-16 17:45:54.231', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f9fbb6017a1436b1ea0006', NULL, 'quota_org_type', '44', '3', '', '44', NULL, '2021-06-16 17:46:06.698', '123', NULL, '2021-06-16 17:46:06.698', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d2be41000c', NULL, 'quota_age', '0', '60岁以下', '', '0', NULL, '2021-06-11 14:46:48.641', '123', NULL, '2021-06-11 14:46:48.641', '123', NULL, '', '统计年龄类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d2be41000c', NULL, 'quota_age', '0', '60岁以下', '', '0', NULL, '2021-06-11 14:46:48.641', '123', NULL, '2021-06-11 14:46:48.641', '123', NULL, '', '统计年龄类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d30558000d', NULL, 'quota_age', '1', '60-65', '', '1', NULL, '2021-06-11 14:47:06.84', '123', NULL, '2021-06-11 14:47:06.84', '123', NULL, '', '统计年龄类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d30558000d', NULL, 'quota_age', '1', '60-65', '', '1', NULL, '2021-06-11 14:47:06.84', '123', NULL, '2021-06-11 14:47:06.84', '123', NULL, '', '统计年龄类型');

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/wlyy/statistics/dao/QuartzJobConfigDao.java

@ -20,7 +20,7 @@ public interface QuartzJobConfigDao extends PagingAndSortingRepository<QuartzJob
    @Query(" FROM QuartzJobConfig a WHERE a.status=?1 and a.del='1'")
    @Query(" FROM QuartzJobConfig a WHERE a.status=?1 and a.del='1'")
    List<QuartzJobConfig> findByAll(String s);
    List<QuartzJobConfig> findByAll(String s);
    @Query(" FROM QuartzJobConfig a WHERE  a.del='1' and a.id !=8 order by a.id asc")
    @Query(" FROM QuartzJobConfig a WHERE  a.del='1' and a.id >=28 order by a.id asc")
    List<QuartzJobConfig> findByIds();
    List<QuartzJobConfig> findByIds();
    @Query(" FROM QuartzJobConfig a WHERE a.id=?1 and a.del='1'")
    @Query(" FROM QuartzJobConfig a WHERE a.id=?1 and a.del='1'")