瀏覽代碼

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

wangzhinan 1 年之前
父節點
當前提交
27f7309305

+ 325 - 4
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -39,14 +39,12 @@ import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.format.TextStyle;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -7351,4 +7349,327 @@ public class StatisticsEsService {
        resultMap.put("todayFree", todayFree);//今日新增
        return resultMap;
    }
    /**
     * 获取开通网络问诊的医生和科室数量
     */
    public HashMap<String, Object> getNetworkDoctorAndDeptCount() throws Exception {
        String deptSql = "SELECT\n" +
                "	count( DISTINCT b.dept_code ) \n" +
                "FROM\n" +
                "	base_doctor a\n" +
                "	INNER JOIN base_doctor_hospital b ON a.id = b.doctor_code \n" +
                "WHERE\n" +
                "	1 = 1 \n" +
                "	AND a.del='1' AND b.del='1'\n" +
                "	AND a.outpatient_type IS NOT NULL \n" +
                "	AND a.outpatient_type <> '' \n" +
                "	AND b.dept_code IS NOT NULL ";
        String doctorSql = "SELECT\n" +
                "	count( DISTINCT a.id ) \n" +
                "FROM\n" +
                "	base_doctor a \n" +
                "WHERE\n" +
                "	1 = 1 \n" +
                "	AND a.del = '1' \n" +
                "	AND a.outpatient_type IS NOT NULL \n" +
                "	AND a.outpatient_type <> ''";
        CompletableFuture<Integer> future01 = CompletableFuture.supplyAsync(() -> {
            Integer integer = jdbcTemplate.queryForObject(deptSql, Integer.class);
            return integer;
        }, execute);
        CompletableFuture<Integer> future02 = CompletableFuture.supplyAsync(() -> {
            Integer integer = jdbcTemplate.queryForObject(doctorSql, Integer.class);
            return integer;
        }, execute);
        CompletableFuture.allOf(future01, future02).get();
        Integer deptCount = future01.get();
        Integer doctorCount = future02.get();
        HashMap<String, Object> resultMap = new HashMap<>();
        resultMap.put("deptCount", deptCount);
        resultMap.put("doctorCount", doctorCount);
        return resultMap;
    }
    /**
     * 查询患者行为动态
     */
    public List<Map<String, Object>> getPatientBehavior() throws ExecutionException, InterruptedException {
        String sql01 = "SELECT q.*,CONCAT('患者',q.patientName,'发起了',q.title)'description' FROM (\n" +
                "	SELECT\n" +
                "		patient_name 'patientName',\n" +
                "		CASE \n" +
                "			WHEN outpatient_type='1' THEN '在线复诊'\n" +
                "			WHEN outpatient_type='2' THEN '协同门诊'\n" +
                "			WHEN outpatient_type='3' AND type='1' THEN '图文咨询'\n" +
                "			WHEN outpatient_type='3' AND type='2' THEN '视频咨询'\n" +
                "		END 'title',\n" +
                "		DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%S') 'createTime'\n" +
                "	FROM\n" +
                "		wlyy_outpatient \n" +
                "	WHERE\n" +
                "		1 = 1 \n" +
                "		AND pay_status IN ( '1', '2' )\n" +
                "		ORDER BY create_time DESC LIMIT 5\n" +
                ")q";
        String sql02 = "SELECT q.*,CONCAT('患者',q.patientName,'购药成功了')'description' FROM (\n" +
                "	SELECT\n" +
                "	patient_name 'patientName',\n" +
                "  CASE \n" +
                "	 WHEN `status`='30' THEN '购药成功'\n" +
                "	END 'title',\n" +
                "	DATE_FORMAT( create_time, '%Y-%m-%d %H:%i:%S' ) 'createTime' \n" +
                "FROM\n" +
                "	wlyy_prescription \n" +
                "WHERE\n" +
                "	`status` = '30' ORDER BY create_time DESC LIMIT 5\n" +
                ")q";
        String sql03 = "SELECT q.*,CONCAT('患者',q.patientName,'出院转',q.title,'诊后管理') 'description' FROM (\n" +
                "	SELECT\n" +
                "	`name` 'patientName',disease_name 'title',DATE_FORMAT( create_time, '%Y-%m-%d %H:%i:%S' ) 'createTime'  \n" +
                "FROM\n" +
                "	wlyy_patient_rehabilitation_plan \n" +
                "ORDER BY\n" +
                "	create_time DESC \n" +
                "	LIMIT 5\n" +
                ")q";
        CompletableFuture<List<Map<String, Object>>> future01 = CompletableFuture.supplyAsync(() -> {
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql01);
            return list;
        }, execute);
        CompletableFuture<List<Map<String, Object>>> future02 = CompletableFuture.supplyAsync(() -> {
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql02);
            return list;
        }, execute);
        CompletableFuture<List<Map<String, Object>>> future03 = CompletableFuture.supplyAsync(() -> {
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql03);
            return list;
        }, execute);
        CompletableFuture.allOf(future01, future02, future03).get();
        List<Map<String, Object>> list01 = future01.get();
        List<Map<String, Object>> list02 = future02.get();
        List<Map<String, Object>> list03 = future03.get();
        // 合并列表
        List<Map<String, Object>> mergedList = new ArrayList<>(list01);
        mergedList.addAll(list02);
        mergedList.addAll(list03);
        // 按 createTime 排序
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        mergedList.sort((m1, m2) -> {
            String c1 = (String) m1.get("createTime");
            String c2 = (String) m2.get("createTime");
            LocalDateTime t1 = LocalDateTime.parse(c1, formatter);
            LocalDateTime t2 = LocalDateTime.parse(c2, formatter);
            return t2.compareTo(t1);
        });
        System.out.println(mergedList);
        return mergedList;
    }
    /**
     * 查询医生服务动态
     */
    public List<Map<String, Object>> getDoctorBehavior() throws Exception {
        String sql01 = "SELECT q.*,CONCAT(q.deptName,q.doctorName,'医生接诊了',q.patientName,'患者')'description' FROM (\n" +
                "	SELECT\n" +
                "	doctor_name 'doctorName',dept_name 'deptName',patient_name 'patientName',\n" +
                "	DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%S') 'createTime'\n" +
                "FROM\n" +
                "	wlyy_outpatient \n" +
                "WHERE\n" +
                "	1 = 1 \n" +
                "	AND pay_status IN ( '1', '2' )\n" +
                "	ORDER BY create_time DESC LIMIT 5\n" +
                ")q";
        String sql02 = "SELECT q.*,CONCAT(q.deptName,q.doctorName,'医生为',q.patientName,'患者开具了处方')'description'  FROM (\n" +
                "	SELECT\n" +
                "	a.doctor_name 'doctorName',b.dept_name 'deptName',a.patient_name 'patientName',\n" +
                "	DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%S' ) 'createTime' \n" +
                "FROM\n" +
                "	wlyy_prescription a INNER JOIN base_doctor_hospital b ON a.doctor=b.doctor_code\n" +
                "WHERE\n" +
                "	a.`status` >= '30' ORDER BY a.create_time DESC LIMIT 10\n" +
                ")q";
        CompletableFuture<List<Map<String, Object>>> future01 = CompletableFuture.supplyAsync(() -> {
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql01);
            return list;
        }, execute);
        CompletableFuture<List<Map<String, Object>>> future02 = CompletableFuture.supplyAsync(() -> {
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql02);
            return list;
        }, execute);
        CompletableFuture.allOf(future01, future02).get();
        List<Map<String, Object>> list01 = future01.get();
        List<Map<String, Object>> list02 = future02.get();
        // 合并列表
        List<Map<String, Object>> mergedList = new ArrayList<>(list01);
        mergedList.addAll(list02);
        // 按 createTime 排序
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        mergedList.sort((m1, m2) -> {
            String c1 = (String) m1.get("createTime");
            String c2 = (String) m2.get("createTime");
            LocalDateTime t1 = LocalDateTime.parse(c1, formatter);
            LocalDateTime t2 = LocalDateTime.parse(c2, formatter);
            return t2.compareTo(t1);
        });
        System.out.println(mergedList);
        return mergedList;
    }
    /**
     * 图文问诊、视频问诊:两种方式,医生书写病历时有填写诊断 根据这个诊断排行
     */
    public List<Map<String, Object>> getReExaminationRanking() {
        String sql = "SELECT\n" +
                "	icd10,icd10_name,	count( 1 ) 'visitCount' \n" +
                "FROM\n" +
                "	wlyy_outpatient \n" +
                "WHERE 1=1\n" +
                "	AND pay_status IN ( '1', '2' ) \n" +
                "	AND outpatient_type='3' AND type IN('1','2')\n" +
                "	AND icd10_name IS NOT NULL \n" +
                "GROUP BY\n" +
                "	icd10,icd10_name \n" +
                "ORDER BY\n" +
                "	count(1) DESC\n" +
                "LIMIT 5";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public List<Map<String, Object>> getDeptAndDoctor(ScreenQvo qvo) {
        List<Map<String, Object>> list = null;
        if ("1".equals(qvo.getType())) {
            //查询所有科室
            String sql = "SELECT distinct dept_code 'deptCode',dept_name 'deptName' FROM base_doctor_hospital WHERE del='1'";
            if (StringUtils.isNotBlank(qvo.getDeptName())) {
                sql += " and dept_name like  '%" + qvo.getDeptName() + "%'";
            }
            list = jdbcTemplate.queryForList(sql);
        }
        //根据科室或者名称查医生
        if ("2".equals(qvo.getType())) {
            String sql = "SELECT distinct b.id 'doctorId',b.`name` 'doctorName' FROM base_doctor_hospital a \n" +
                    "INNER JOIN base_doctor  b ON a.doctor_code=b.id \n" +
                    "WHERE  1=1 ";
            if (StringUtils.isNotBlank(qvo.getDeptCode())) {
                sql += " and a.dept_code = '" + qvo.getDeptCode() + "' ";
            }
            if (StringUtils.isNotBlank(qvo.getDoctorName())) {
                sql += " and b.`name` LIKE '%" + qvo.getDoctorName() + "%'";
            }
            list = jdbcTemplate.queryForList(sql);
        }
        return list;
    }
    /**
     * 查询服务评价详情
     */
    public List<Map<String, Object>> getDoctorSeverScopeDetail(ScreenQvo qvo) {
        String limitSql = "LIMIT " + (qvo.getPage() - 1) * qvo.getPageSize() + "," + qvo.getPageSize();
        String sql = "SELECT\n" +
                "	b.dept_code 'deptCode',b.dept_name 'deptName',c.id 'doctorId',c.`name` 'doctorName', AVG(a.score) 'score' \n" +
                "FROM\n" +
                "	base_evaluate_score a\n" +
                "	INNER JOIN base_doctor_hospital b ON a.doctor = b.doctor_code \n" +
                "	INNER JOIN base_doctor c ON b.doctor_code=c.id\n" +
                "WHERE\n" +
                "	1 = 1 \n";
        if (StringUtils.isNotBlank(qvo.getStartDate()) && StringUtils.isNotBlank(qvo.getEndDate())) {
            sql += " AND a.create_time >='" + qvo.getStartDate() + "' AND a.create_time <='" + qvo.getEndDate() + " 23:59:59' \n";
        }
        if (StringUtils.isNotBlank(qvo.getDeptCode())) {
            sql += " AND b.dept_code='" + qvo.getDeptCode() + "' ";
        }
        if (StringUtils.isNotBlank(qvo.getDoctorName())) {
            sql += "  AND c.`name` LIKE '%" + qvo.getDoctorName() + "%' ";
        }
        sql += " GROUP BY b.dept_code,c.id ";
        if (StringUtils.isNotBlank(qvo.getPageSwitch()) && "1".equals(qvo.getPageSwitch())) {
            sql += limitSql;
        }
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public List<Map<String, Object>> getDoctorFreeDetail(ScreenQvo qvo) {
        String limitSql = "LIMIT " + (qvo.getPage() - 1) * qvo.getPageSize() + "," + qvo.getPageSize();
        String sql = "SELECT q.*,(q.drugFee+q.checkFree) 'totalFree' FROM (\n" +
                "SELECT\n" +
                "	p.doctor,p.doctor_name 'doctorName',a.dept_code 'deptCode',a.dept_name 'deptName', COALESCE(ROUND(SUM(p.drug_fee),2), 0) AS drugFee ,0 'checkFree'\n" +
                "FROM\n" +
                "	wlyy_prescription p\n" +
                "	INNER JOIN wlyy_outpatient o ON p.outpatient_id = o.id \n" +
                "	INNER JOIN base_doctor_hospital a ON p.doctor=a.doctor_code\n" +
                "WHERE\n" +
                "	1 = 1 \n" +
                "	AND p.STATUS >= 30\n";
        if (StringUtils.isNotBlank(qvo.getStartDate()) && StringUtils.isNotBlank(qvo.getEndDate())) {
            sql += "	AND p.create_time>='" + qvo.getStartDate() + "' AND a.create_time<='" + qvo.getEndDate() + " 23:59:59'\n";
        }
        if (StringUtils.isNotBlank(qvo.getDeptCode())) {
            sql += " AND a.dept_code='" + qvo.getDeptCode() + "' ";
        }
        if (StringUtils.isNotBlank(qvo.getDoctorName())) {
            sql += "  AND p.doctor_name LIKE '%" + qvo.getDoctorName() + "%' ";
        }
        sql += " GROUP BY a.dept_code,a.doctor_code\n" +
                "UNION ALL	\n" +
                "SELECT\n" +
                "	o.doctor,o.doctor_name 'doctorName',a.dept_code'deptCode', a.dept_name 'deptName',0 'drugFee',COALESCE(ROUND(SUM(bop.pay_price),2), 0)  AS checkFree \n" +
                "FROM\n" +
                "	wlyy_outpatient o\n" +
                "	INNER JOIN base_business_order_pay bop ON o.id = bop.relation_code \n" +
                "	INNER JOIN base_doctor_hospital a ON o.doctor=a.doctor_code\n" +
                "WHERE\n" +
                "	o.pay_status = 1 \n" +
                "	AND o.`status` IN ( 1, 2, 3 )\n";
        if (StringUtils.isNotBlank(qvo.getStartDate()) && StringUtils.isNotBlank(qvo.getEndDate())) {
            sql += "	AND o.create_time>='" + qvo.getStartDate() + "' AND o.create_time<='" + qvo.getEndDate() + " 23:59:59'\n";
        }
        if (StringUtils.isNotBlank(qvo.getDeptCode())) {
            sql += " AND a.dept_code='" + qvo.getDeptCode() + "' ";
        }
        if (StringUtils.isNotBlank(qvo.getDoctorName())) {
            sql += "  AND o.doctor_name LIKE '%" + qvo.getDoctorName() + "%' ";
        }
        sql += "	GROUP BY a.dept_code,a.doctor_code\n" +
                ")q WHERE 1=1 \n" +
                "GROUP BY q.deptCode,q.doctorName ORDER BY (q.drugFee+q.checkFree) DESC \n";
        if (StringUtils.isNotBlank(qvo.getPageSwitch()) && "1".equals(qvo.getPageSwitch())) {
            sql += limitSql;
        }
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
}

+ 66 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/statistics/ScreenQvo.java

@ -22,9 +22,34 @@ public class ScreenQvo {
   private int flag;//1本月 2近半年 3全年
   private String timeType;//查询时间范围 1 按天  3按月
   private String deptCode;//科室code
   private String deptName;//科室名称
   private String doctorName;//医生名称
   private int page;
   private int pageSize;
   private String pageSwitch;//1是0否  分页开关
   private String type;//类型
   public String getDeptName() {
      return deptName;
   }
   public void setDeptName(String deptName) {
      this.deptName = deptName;
   }
   public String getType() {
      return type;
   }
   public void setType(String type) {
      this.type = type;
   }
   public int getFlag() {
      return flag;
   }
@ -80,4 +105,44 @@ public class ScreenQvo {
   public void setTimeType(String timeType) {
      this.timeType = timeType;
   }
   public int getPage() {
      return page;
   }
   public void setPage(int page) {
      this.page = page;
   }
   public int getPageSize() {
      return pageSize;
   }
   public void setPageSize(int pageSize) {
      this.pageSize = pageSize;
   }
   public String getPageSwitch() {
      return pageSwitch;
   }
   public void setPageSwitch(String pageSwitch) {
      this.pageSwitch = pageSwitch;
   }
   public String getDeptCode() {
      return deptCode;
   }
   public void setDeptCode(String deptCode) {
      this.deptCode = deptCode;
   }
   public String getDoctorName() {
      return doctorName;
   }
   public void setDoctorName(String doctorName) {
      this.doctorName = doctorName;
   }
}

+ 36 - 39
starter/elasticsearch-starter/src/main/java/com/yihu/jw/elasticsearch/ElasticSearch7Pool.java

@ -1,7 +1,5 @@
package com.yihu.jw.elasticsearch;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.ElasticSearchDruidDataSourceFactory;
import com.alibaba.fastjson.JSON;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
@ -17,8 +15,6 @@ import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
@ -31,26 +27,21 @@ import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.CreateIndexResponse;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.common.text.Text;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TermQueryBuilder;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.sql.*;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.concurrent.TimeUnit;
/**
@ -67,11 +58,12 @@ public class ElasticSearch7Pool {
    private String password;
    @SuppressWarnings("deprecation")
    @Bean(name="restHighLevelClient")
    @Bean(name = "restHighLevelClient")
    public RestHighLevelClient restHighLevelClient() {
        String[] hosts = this.hosts.split(",");;
        String[] hosts = this.hosts.split(",");
        ;
        HttpHost[] httpHosts = new HttpHost[hosts.length];
        for(int i=0;i<hosts.length;i++) {
        for (int i = 0; i < hosts.length; i++) {
            httpHosts[i] = HttpHost.create(hosts[i]);
        }
        //设置密码
@ -100,22 +92,22 @@ public class ElasticSearch7Pool {
    }
    public ResultSet restHighLevelClientStream(String sql) throws Exception {
        Connection connection = DriverManager.getConnection("jdbc:es://http://172.26.0.55:9200","elastic","elastic");
        Connection connection = DriverManager.getConnection("jdbc:es://http://172.26.0.168:9100/","root","jkzlehr");
//        Connection connection = DriverManager.getConnection("jdbc:es://" + hosts, userName, password);
        Statement statement = connection.createStatement();
        ResultSet resultSet =  statement.executeQuery(sql);
        ResultSet resultSet = statement.executeQuery(sql);
//        connection.close();
//        statement.close();
        return resultSet;
    }
    /**
     * 创建索引
     *
     * @throws IOException
     */
    public void testCreateIndex(RestHighLevelClient restHighLevelClient,String index) throws IOException {
    public void testCreateIndex(RestHighLevelClient restHighLevelClient, String index) throws IOException {
        //1. 创建索引请求
        CreateIndexRequest request = new CreateIndexRequest(index);
        //2. 客户端执行请求 IndicesClient,请求后获得响应
@ -126,9 +118,10 @@ public class ElasticSearch7Pool {
    /**
     * 查询是否存在索引
     *
     * @throws IOException
     */
    public void testExistIndex(RestHighLevelClient restHighLevelClient,String index) throws IOException {
    public void testExistIndex(RestHighLevelClient restHighLevelClient, String index) throws IOException {
        GetIndexRequest request = new GetIndexRequest(index);
        boolean exists = restHighLevelClient.indices().exists(request, RequestOptions.DEFAULT);
        System.out.println(exists);
@ -137,7 +130,7 @@ public class ElasticSearch7Pool {
    /**
     * 删除索引
     */
    public void testDeleteIndex(RestHighLevelClient restHighLevelClient,String index) throws IOException {
    public void testDeleteIndex(RestHighLevelClient restHighLevelClient, String index) throws IOException {
        //创建删除索引请求对象
        DeleteIndexRequest request = new DeleteIndexRequest(index);
        //客户端执行请求
@ -145,10 +138,11 @@ public class ElasticSearch7Pool {
        //输出是否删除成功
        System.out.println(response.isAcknowledged());
    }
    /**
     * 添加文档
     */
    public void addDocument(RestHighLevelClient restHighLevelClient,String index) throws IOException {
    public void addDocument(RestHighLevelClient restHighLevelClient, String index) throws IOException {
//        //获取对象
//        Goods goods = goodsDao.findById(12991976L);
//        //创建请求
@ -168,10 +162,11 @@ public class ElasticSearch7Pool {
    /**
     * 删除文档
     *
     * @throws IOException
     */
    public void testDeleteDocument(RestHighLevelClient restHighLevelClient,String index) throws IOException {
        DeleteRequest request = new DeleteRequest(index,"1");
    public void testDeleteDocument(RestHighLevelClient restHighLevelClient, String index) throws IOException {
        DeleteRequest request = new DeleteRequest(index, "1");
        request.timeout("1s");
        DeleteResponse response = restHighLevelClient.delete(request, RequestOptions.DEFAULT);
        //DeleteResponse[index=siyi,type=_doc,id=1,version=3,result=deleted,shards=ShardInfo{total=2, successful=1, failures=[]}]
@ -181,8 +176,8 @@ public class ElasticSearch7Pool {
    }
    //3.3 修改文档
    public void testUpdateDocument(RestHighLevelClient restHighLevelClient,String index) throws IOException {
        UpdateRequest request = new UpdateRequest(index,"1");
    public void testUpdateDocument(RestHighLevelClient restHighLevelClient, String index) throws IOException {
        UpdateRequest request = new UpdateRequest(index, "1");
        request.timeout("1s");
//        Goods goods = goodsDao.findById(12991976L);
//        goods.setTitle("xxxx");
@ -196,7 +191,7 @@ public class ElasticSearch7Pool {
    /**
     * 批量新增文档
     */
    public void testBulkRequest(RestHighLevelClient restHighLevelClient,String index) throws IOException {
    public void testBulkRequest(RestHighLevelClient restHighLevelClient, String index) throws IOException {
        BulkRequest request = new BulkRequest();
        request.timeout("1s");
@ -216,11 +211,11 @@ public class ElasticSearch7Pool {
    /**
     *  当我们需要使用批量增删改数据时,只需要使用BulkRequest的add,delete,update中相应方法即可。
     * 当我们需要使用批量增删改数据时,只需要使用BulkRequest的add,delete,update中相应方法即可。
     * 获取文档,判断是否存在 get /index/doc/1
     */
    public void testIsExists(RestHighLevelClient restHighLevelClient,String index) throws IOException {
        GetRequest request = new GetRequest(index,"1");
    public void testIsExists(RestHighLevelClient restHighLevelClient, String index) throws IOException {
        GetRequest request = new GetRequest(index, "1");
        //不获取返回的 _source的上下文了
        request.fetchSourceContext(new FetchSourceContext(false));
        request.storedFields("_none");
@ -230,18 +225,20 @@ public class ElasticSearch7Pool {
    /**
     * 获取文档信息
     *
     * @throws IOException
     */
    public void testGetDocument(RestHighLevelClient restHighLevelClient,String index) throws IOException {
        GetRequest request = new GetRequest(index,"1");
    public void testGetDocument(RestHighLevelClient restHighLevelClient, String index) throws IOException {
        GetRequest request = new GetRequest(index, "1");
        GetResponse response = restHighLevelClient.get(request, RequestOptions.DEFAULT);
        System.out.println(response.getSourceAsString());
        System.out.println(response);
    }
    /**
     * 复杂查询
     */
    public void testSearch(RestHighLevelClient restHighLevelClient,String index) throws IOException {
    public void testSearch(RestHighLevelClient restHighLevelClient, String index) throws IOException {
        SearchRequest request = new SearchRequest(index);
        //构建搜索条件
        SearchSourceBuilder builder = new SearchSourceBuilder();
@ -264,12 +261,12 @@ public class ElasticSearch7Pool {
    }
    /**
     *     当然,我们可以向直接操作ElasticSearch一样去构建查询条件。
     *
     *     在java中有对应的类来实现我们需要构造的查询条件。
     * 当然,我们可以向直接操作ElasticSearch一样去构建查询条件。
     * <p>
     * 在java中有对应的类来实现我们需要构造的查询条件。
     * 分页查询
     */
    public void testSearch2(RestHighLevelClient restHighLevelClient,String index) throws IOException {
    public void testSearch2(RestHighLevelClient restHighLevelClient, String index) throws IOException {
        SearchRequest request = new SearchRequest(index);
        //构建搜索条件
        SearchSourceBuilder builder = new SearchSourceBuilder();

+ 126 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java

@ -13,6 +13,7 @@ import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -1526,4 +1527,129 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
    }
    /**
     * 获取开通网络问诊的医生和科室数量
     */
    @GetMapping(value = "/getNetworkDoctorAndDeptCount")
    @ApiOperation(value = "获取开通网络问诊的医生和科室数量")
    public Envelop getNetworkDoctorAndDeptCount() {
        try {
            HashMap<String, Object> result = statisticsEsService.getNetworkDoctorAndDeptCount();
            return success(result);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("系统繁忙");
        }
    }
    /**
     * 查询患者行为动态
     */
    @GetMapping(value = "/getPatientBehavior")
    @ApiOperation(value = "查询患者行为动态")
    public Envelop getPatientBehavior() {
        try {
            List<Map<String, Object>> result = statisticsEsService.getPatientBehavior();
            return success(result);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("系统繁忙");
        }
    }
    /**
     * 查询医生服务动态
     */
    @GetMapping(value = "/getDoctorBehavior")
    @ApiOperation(value = "查询医生服务动态")
    public Envelop getDoctorBehavior() {
        try {
            List<Map<String, Object>> result = statisticsEsService.getDoctorBehavior();
            return success(result);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("系统繁忙");
        }
    }
    /**
     * 患者复诊诊断排行
     * 图文问诊、视频问诊:两种方式,医生书写病历时有填写诊断 根据这个诊断排行
     */
    @GetMapping(value = "/getReExaminationRanking")
    @ApiOperation(value = "患者复诊诊断排行")
    public Envelop getReExaminationRanking() {
        try {
            List<Map<String, Object>> result = statisticsEsService.getReExaminationRanking();
            return success(result);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("系统繁忙");
        }
    }
    /**
     * 查询所有科室和医生
     * strJson={"type":"1","deptName":"心脏"}
     * strJson={"type":"2","deptCode":"0000001","doctorName":"陈淑萍"}
     */
    @GetMapping(value = "/getDeptAndDoctor")
    @ApiOperation(value = "查询所有科室")
    public Envelop getDeptAndDoctor(@RequestParam(required = true) String strJson) {
        try {
            ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
            List<Map<String, Object>> result = statisticsEsService.getDeptAndDoctor(qvo);
            return success(result);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("系统繁忙");
        }
    }
    /**
     * 查询服务评价详情
     * strJson={"startDate":"2020-07-18","endDate":"2023-11-29","deptCode":"1110000","deptName":"梁敬兴","pageSwitch":"1","page":1,"pageSize":10}
     */
    @GetMapping(value = "/getDoctorSeverScopeDetail")
    @ApiOperation(value = "查询服务评价详情")
    public Envelop getDoctorSeverScopeDetail(@RequestParam(required = true) String strJson) {
        try {
            ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
            List<Map<String, Object>> result = statisticsEsService.getDoctorSeverScopeDetail(qvo);
            return success(result);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("系统繁忙");
        }
    }
    /**
     * 全院网络门诊收入明细
     * 参数:strJson={"startDate":"2020-07-18","endDate":"2023-11-29","deptCode":"1110000","deptName":"梁敬兴","pageSwitch":"1","page":1,"pageSize":10}
     */
    @GetMapping(value = "/getDoctorFreeDetail")
    @ApiOperation(value = "全院网络门诊收入明细")
    public Envelop getDoctorFreeDetail(@RequestParam(required = true) String strJson) {
        try {
            ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
            List<Map<String, Object>> result = statisticsEsService.getDoctorFreeDetail(qvo);
            return success(result);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("系统繁忙");
        }
    }
}

+ 5 - 3
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/controller/PatientRehabilitationManageController.java

@ -337,8 +337,10 @@ public class PatientRehabilitationManageController extends EnvelopRestEndpoint {
            @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
            @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
            @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
            @ApiParam(name = "planId", value = "计划id", required = true)
            @RequestParam(value = "planId", required = true)String planId,
            @ApiParam(name = "planId", value = "false", required = true)
            @RequestParam(value = "planId", required = false)String planId,
            @ApiParam(name = "patient", value = "居民id", required = false)
            @RequestParam(value = "patient", required = false)String patient,
            @ApiParam(name = "searchTask", value = "快速查找任务:(1电话/短信关怀,2康复咨询,3健康监测,4上门服务,5康复指导,6康复随访,7康复复诊 8全部)", required = false)
            @RequestParam(value = "searchTask", required = false)Integer searchTask,
            @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false)
@ -352,7 +354,7 @@ public class PatientRehabilitationManageController extends EnvelopRestEndpoint {
            if(!StringUtils.isNotEmpty(doctorCode)){
                doctorCode = getRepUID();
            }
            return rehabilitationManageService.calendarPlanDetailList(planId, searchTask, status, doctorCode, executeStartTime, executeEndTime, taskExecutor);
            return rehabilitationManageService.calendarPlanDetailList(planId, searchTask, status, doctorCode, executeStartTime, executeEndTime, taskExecutor,patient);
        }  catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("查询失败");

+ 6 - 4
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/controller/RehabilitationManageController.java

@ -182,14 +182,15 @@ public class RehabilitationManageController extends EnvelopRestEndpoint {
    public ObjEnvelop calendarPlanDetail(
            @ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd)") @RequestParam(value = "executeStartTime", required = false) String executeStartTime,
            @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd)") @RequestParam(value = "executeEndTime", required = false) String executeEndTime,
            @ApiParam(name = "planId", value = "计划id,多个计划逗号隔开", required = true) @RequestParam(value = "planId", required = true) String planId,
            @ApiParam(name = "planId", value = "计划id,多个计划逗号隔开", required = false) @RequestParam(value = "planId", required = false) String planId,
            @ApiParam(name = "patient", value = "居民id", required = false) @RequestParam(value = "patient", required = false) String patient,
            @ApiParam(name = "searchTask", value = "快速查找任务:(1电话/短信关怀,2康复咨询,3健康监测,4上门服务,5康复指导,6康复随访,7康复复诊)", required = false) @RequestParam(value = "searchTask", required = false) Integer searchTask,
            @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false) @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false) @RequestParam(value = "doctorCode", required = false) String doctorCode,
            @ApiParam(name = "taskExecutor", value = "任务执行人:0全部;1我的任务:2他人任务", required = false) @RequestParam(value = "taskExecutor", required = false, defaultValue = "0") String taskExecutor
    ) {
        try {
            return rehabilitationManageService.calendarPlanDetail(executeStartTime, executeEndTime, planId, searchTask, status, doctorCode, taskExecutor);
            return rehabilitationManageService.calendarPlanDetail(executeStartTime, executeEndTime, planId, searchTask, status, doctorCode, taskExecutor,patient);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");
@ -202,14 +203,15 @@ public class RehabilitationManageController extends EnvelopRestEndpoint {
    public ObjEnvelop calendarPlanDetailList(
            @ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd)") @RequestParam(value = "executeStartTime", required = false) String executeStartTime,
            @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd)") @RequestParam(value = "executeEndTime", required = false) String executeEndTime,
            @ApiParam(name = "planId", value = "计划id,多个计划逗号隔开", required = true) @RequestParam(value = "planId", required = true) String planId,
            @ApiParam(name = "planId", value = "计划id,多个计划逗号隔开", required = false) @RequestParam(value = "planId", required = false) String planId,
            @ApiParam(name = "patient", value = "居民id", required = false) @RequestParam(value = "patient", required = false) String patient,
            @ApiParam(name = "searchTask", value = "快速查找任务:(1电话/短信关怀,2康复咨询,3健康监测,4上门服务,5康复指导,6康复随访,7康复复诊 8所有)") @RequestParam(value = "searchTask", required = false) Integer searchTask,
            @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)") @RequestParam(value = "doctorCode", required = false) String doctorCode,
            @ApiParam(name = "taskExecutor", value = "任务执行人:0全部;1我的任务:2他人任务", required = false) @RequestParam(value = "taskExecutor", required = false, defaultValue = "0") String taskExecutor
    ) {
        try {
            return rehabilitationManageService.calendarPlanDetailList(planId, searchTask, status, doctorCode, executeStartTime, executeEndTime, taskExecutor);
            return rehabilitationManageService.calendarPlanDetailList(planId, searchTask, status, doctorCode, executeStartTime, executeEndTime, taskExecutor,patient);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());

+ 2 - 2
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationInfoService.java

@ -1061,10 +1061,10 @@ public class RehabilitationInfoService {
                    "INNER JOIN base_doctor  b ON a.doctor_code=b.id \n" +
                    "WHERE  1=1 ";
            if (StringUtils.isNotBlank(deptCode)) {
                sql += " and dept_code = '" + deptCode + "' ";
                sql += " and a.dept_code = '" + deptCode + "' ";
            }
            if (StringUtils.isNotBlank(doctorName)) {
                sql += " and b.`name` LIKE '%" + deptName + "%'";
                sql += " and b.`name` LIKE '%" + doctorName + "%'";
            }
            list = jdbcTemplate.queryForList(sql);
        }

+ 30 - 53
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationManageService.java

@ -589,14 +589,19 @@ public class RehabilitationManageService {
     * @param taskExecutor 任务执行者 0全部;1我的任务 2他人任务
     */
    public ObjEnvelop calendarPlanDetail(String executeStartTime, String executeEndTime, String planId, Integer searchTask,
                                         Integer status, String doctorCode, String taskExecutor) throws Exception {
        String[] planIdlist = planId.split(",");
        StringBuilder planCondition = new StringBuilder();
        planCondition.append("'" + planIdlist[0] + "'");
        for (int i = 1; i < planIdlist.length; i++) {
            planCondition.append(",'" + planIdlist[i] + "'");
        }
        String sql = " select d.* from base_service_item_plan d  where d.plan_id in (" + planCondition + " ) ";
                                         Integer status, String doctorCode, String taskExecutor,String patient) throws Exception {
        String sql = " select d.* from base_service_item_plan d  where ";
        if(StringUtils.isNotBlank(patient)){
            sql += "  d.patient = '" + patient + "' ";
        }else {
            String[] planIdlist = planId.split(",");
            StringBuilder planCondition = new StringBuilder();
            planCondition.append("'" + planIdlist[0] + "'");
            for (int i = 1; i < planIdlist.length; i++) {
                planCondition.append(",'" + planIdlist[i] + "'");
            }
            sql += "  d.plan_id in (" + planCondition + " ) ";
        }
        if (StringUtils.isNotBlank(executeStartTime)) {
            sql += " and d.plan_time>='" + executeStartTime + "' ";
        }
@ -676,12 +681,6 @@ public class RehabilitationManageService {
            }
            map.put(executeTime, m);
        }
        /*List list = new ArrayList();
        for(String key : map.keySet()){
            Map<String,Object> result = map.get(key);
            result.put("executeTime", key);
            list.add(result);
        }*/
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success, map);
    }
@ -695,14 +694,21 @@ public class RehabilitationManageService {
     * @param taskExecutor 任务执行者 0全部;1我的任务 2他人任务
     */
    public ObjEnvelop calendarPlanDetailList(String planId, Integer searchTask, Integer status, String doctorCode,
                                             String executeStartTime, String executeEndTime, String taskExecutor) {
        String[] planIdlist = planId.split(",");
        StringBuilder planCondition = new StringBuilder();
        planCondition.append("'" + planIdlist[0] + "'");
        for (int i = 1; i < planIdlist.length; i++) {
            planCondition.append(",'" + planIdlist[i] + "'");
        }
        String sql = " select d.* from base_service_item_plan d  where d.plan_id in (" + planCondition + " ) ";
                                             String executeStartTime, String executeEndTime, String taskExecutor,String patient) {
        String sql = " select d.* from base_service_item_plan d  where ";
        if(StringUtils.isNotBlank(patient)){
            sql += "  d.patient = '" + patient + "' ";
        }else {
            String[] planIdlist = planId.split(",");
            StringBuilder planCondition = new StringBuilder();
            planCondition.append("'" + planIdlist[0] + "'");
            for (int i = 1; i < planIdlist.length; i++) {
                planCondition.append(",'" + planIdlist[i] + "'");
            }
            sql += "  d.plan_id in (" + planCondition + " ) ";
        }
        if (searchTask != null) {
            if (searchTask == 8) {//
                if (StringUtils.isNotBlank(doctorCode)) {
@ -1618,7 +1624,7 @@ public class RehabilitationManageService {
    public ObjEnvelop appCalendarPlanDetailList(String planId, Integer searchTask, Integer status, String executeStartTime, String executeEndTime) {
        Map<String, Object> resultMap = new HashMap<>();
        ObjEnvelop objEnvelop = calendarPlanDetailList(planId, searchTask, status, null, executeStartTime, executeEndTime, "0");
        ObjEnvelop objEnvelop = calendarPlanDetailList(planId, searchTask, status, null, executeStartTime, executeEndTime, "0",null);
        Integer finishCount = rehabilitationDetailDao.findByStatusAndPlanId(1, planId);
        Integer allCount = rehabilitationDetailDao.findAllByPlanId(planId);
        resultMap.put("planDetailList", objEnvelop.getObj());
@ -2680,7 +2686,7 @@ public class RehabilitationManageService {
        param.put("taskExecutor", taskExecutor);
        ObjEnvelop objEnvelop = calendarPlanDetailList(planIds.toString(), searchTask, status, doctorCode, executeStartTime, executeEndTime, taskExecutor);
        ObjEnvelop objEnvelop = calendarPlanDetailList(planIds.toString(), searchTask, status, doctorCode, executeStartTime, executeEndTime, taskExecutor,null);
        org.json.JSONObject result = new org.json.JSONObject(objEnvelop);
        if (result.getInt("status") == 200) {
@ -2936,33 +2942,4 @@ public class RehabilitationManageService {
        }
        return medicalRecordsDOS;
    }
    /**
     * 康复管理-康复计划按列表展示(区分我的任务他人任务)
     *
     * @param executeStartTime
     * @param executeEndTime
     * @param planId
     * @param searchTask
     * @param status
     * @param doctorCode
     * @return
     * @throws Exception
     */
    public JSONArray calendarPlanDetailListWithTaskExecutor(String executeStartTime, String executeEndTime, String planId, Integer searchTask, Integer status, String doctorCode, String taskExecutor) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("executeStartTime", executeStartTime);
        param.put("executeEndTime", executeEndTime);
        param.put("planId", planId);
        param.put("searchTask", searchTask);
        param.put("status", status);
        param.put("doctorCode", doctorCode);
        param.put("taskExecutor", taskExecutor);
        ObjEnvelop objEnvelop = calendarPlanDetailList(planId, searchTask, status, doctorCode, executeStartTime, executeEndTime, taskExecutor);
        org.json.JSONObject result = new org.json.JSONObject(objEnvelop);
        if (result.getInt("status") == 200) {
            return result.getJSONArray("obj");
        }
        throw new Exception("请求失败!");
    }
}