Pārlūkot izejas kodu

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

zd_123 7 gadi atpakaļ
vecāks
revīzija
869743e795
16 mainītis faili ar 299 papildinājumiem un 197 dzēšanām
  1. 11 9
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/DiseaseConvert.java
  2. 16 4
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/save/es/ElastricSearchSave.java
  3. 8 3
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/MysqlToEsQuotaJob.java
  4. 1 0
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/service/JobService.java
  5. 9 1
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/vo/DataModel.java
  6. 8 8
      patient-co/patient-co-statistics/src/main/resources/application.yml
  7. 31 26
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/config/es/ElastricSearchSave.java
  8. 3 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  9. 8 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/es/ElastricSearchSave.java
  10. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/EncodingFilter.java
  11. 137 103
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  12. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  13. 56 36
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  14. 7 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  15. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  16. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

+ 11 - 9
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/DiseaseConvert.java

@ -29,19 +29,21 @@ public class DiseaseConvert implements Convert {
        List<String> keyList = null;
        for(DataModel one:oneList){
            try {
                keyList = initHealthLabesMap(jdbcTemplate, temp, one);
                for(String key:keyList){
                if("63".equals(temp.getQuotaCode())){
                    DataModel dataModelTemp = new DataModel();
                    BeanUtils.copyProperties(one, dataModelTemp);
                    if("63".equals(temp.getQuotaCode())){
                    DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(dataModelTemp, one.getHealthProblem());
                    returnList.add(dataModelTemp);
                }else{
                        if(tempMap.containsKey(String.valueOf(one.getPatient()))){
                            continue;
                        }
                        tempMap.put(String.valueOf(one.getPatient()),one);
                    keyList = initHealthLabesMap(jdbcTemplate, temp, one);
                    for(String key:keyList){
                        DataModel dataModelTemp = new DataModel();
                        BeanUtils.copyProperties(one, dataModelTemp);
                        DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(dataModelTemp, key);
                        returnList.add(dataModelTemp);
                    }
                    DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(dataModelTemp, key);
                    returnList.add(dataModelTemp);
                }
            }catch (Exception e) {

+ 16 - 4
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/save/es/ElastricSearchSave.java

@ -36,9 +36,10 @@ public class ElastricSearchSave {
    private ElasticFactory elasticFactory;
    public Boolean save(List<SaveModel> sms) {
        JestClient jestClient = null;
        try {
            //得到链接
            JestClient jestClient = elasticFactory.getJestClient();
            jestClient = elasticFactory.getJestClient();
            int success = 0;
            int error = 0;
@ -55,21 +56,27 @@ public class ElastricSearchSave {
                }
            }
            BulkResult br = jestClient.execute(bulk.build());
            logger.info("save flag:" + br.isSucceeded());
            logger.info("save success:" + success);
            logger.info("save error:" + error);
            return br.isSucceeded();
        } catch (Exception e) {
            logger.error(" save error :" + e.getMessage());
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return null;
    }
    public Boolean update(List<SaveModel> sms) {
        JestClient jestClient = null;
        try {
            //得到链接
            JestClient jestClient = elasticFactory.getJestClient();
            jestClient = elasticFactory.getJestClient();
            int success = 0;
            int error = 0;
@ -77,8 +84,8 @@ public class ElastricSearchSave {
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (SaveModel obj : sms) {
                try {
                    JSONObject jo=new JSONObject();
                    jo.put("doc",obj);
                    JSONObject jo = new JSONObject();
                    jo.put("doc", obj);
                    Update index = new Update.Builder(jo.toString()).index(esIndex).type(esType).id(obj.getId()).build();
                    bulk.addAction(index);
                    success++;
@ -92,9 +99,14 @@ public class ElastricSearchSave {
            logger.info("update flag:" + br.isSucceeded());
            logger.info("update success:" + success);
            logger.info("update error:" + error);
            jestClient.shutdownClient();
            return isSuccessed;
        } catch (Exception e) {
            logger.error(" update error :" + e.getMessage());
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return null;
    }

+ 8 - 3
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/MysqlToEsQuotaJob.java

@ -132,7 +132,7 @@ public class MysqlToEsQuotaJob implements Job {
        this.quotaDate = DateUtil.strToDate(endTime, "yyyy-MM-dd");
        this.wlyyJobCongId = map.getString("jobConfig");
        this.quartzJobConfig=quartzJobConfigDao.findById(wlyyJobCongId);
        this.quartzJobConfig = quartzJobConfigDao.findById(wlyyJobCongId);
    }
    /**
@ -180,8 +180,9 @@ public class MysqlToEsQuotaJob implements Job {
     * @param timeLevel
     */
    private void deleteData(Date quotaDate, String quotaCode, String timeLevel) {
        JestClient jestClient = null;
        try {
            JestClient jestClient = elasticFactory.getJestClient();
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
@ -208,6 +209,10 @@ public class MysqlToEsQuotaJob implements Job {
            logger.info("delete flag:" + br.isSucceeded());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
    }
@ -284,7 +289,7 @@ public class MysqlToEsQuotaJob implements Job {
                dataModels = SpringUtil.getBean(ExtractHelper.class).extractData(quartzJobConfig, startTime, endTime, year, timeLevel);
            } else {
                //缓存的key 是 时间+timelevel+key
                StringBuffer bu = new StringBuffer(DateUtil.dateToStr(quotaDate, "yyyy-MM-dd") + "-" + timeLevel + "-" +quartzJobConfig.getCacheKey());
                StringBuffer bu = new StringBuffer(DateUtil.dateToStr(quotaDate, "yyyy-MM-dd") + "-" + timeLevel + "-" + quartzJobConfig.getCacheKey());
                //支持的话判断缓存有没有值
                dataModels = Cache.getCache(bu.toString());
                if (dataModels == null) {

+ 1 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/service/JobService.java

@ -343,6 +343,7 @@ public class JobService {
        }
        int day = daysBetween(startDate, endDate);
        for (int i = 0; i < day; i++) {
            Cache.cleanCache();//清空缓存
            productDataByOneDayWithId(getYesterday(i, startDate), id);
        }
    }

+ 9 - 1
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/vo/DataModel.java

@ -23,7 +23,7 @@ public class DataModel {
    private String healthLable;//健康标签
    private Double num=1.0;//分数 如果是累加的计算 默认是1 如果是分数从数据库拿
    private String prescriptionCode;//处方code
    private String healthProblem;//诊断标签
    public String getHealthLable() {
        return healthLable;
@ -181,4 +181,12 @@ public class DataModel {
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    public String getHealthProblem() {
        return healthProblem;
    }
    public void setHealthProblem(String healthProblem) {
        this.healthProblem = healthProblem;
    }
}

+ 8 - 8
patient-co/patient-co-statistics/src/main/resources/application.yml

@ -170,14 +170,14 @@ spring:
       url: jdbc:mysql://59.61.92.90:9069/wlyy?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
       username: wlyy
       password: jkzlehr@123
     primaryRead:
       url: jdbc:mysql://59.61.92.90:8079/wlyy?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
       username: wlyy
       password: jkzlehr@123
     im: #im库:
       url: jdbc:mysql://59.61.92.90:8079/im?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
       username: im
       password: im!)123
    primaryRead:
      url: jdbc:mysql://59.61.92.90:8079/wlyy?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: wlyy
      password: jkzlehr@123
    im: #im库:
      url: jdbc:mysql://59.61.92.90:8079/im?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: im
      password: im!)123
  redis:
    host: 10.95.22.142 # Redis server host.

+ 31 - 26
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/config/es/ElastricSearchSave.java

@ -20,30 +20,35 @@ import java.util.List;
@Component
@Scope("prototype")
public class ElastricSearchSave {
	
	private Logger logger = LoggerFactory.getLogger(ElastricSearchSave.class);
	@Autowired
	private ElasticFactory elasticFactory;
	
	public Boolean save(List  sms,String esIndex,String esType) {
		try {
			//得到链接
			JestClient jestClient = elasticFactory.getJestClient();
			
			Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
			for (Object obj : sms) {
				Index index = new Index.Builder(obj).build();
				bulk.addAction(index);
			}
			BulkResult br = jestClient.execute(bulk.build());
			logger.info("save data count:" + sms.size());
			logger.info("save flag:" + br.isSucceeded());
			return br.isSucceeded();
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(" save error :" + e.getMessage());
		}
		return null;
	}
	
    private Logger logger = LoggerFactory.getLogger(ElastricSearchSave.class);
    @Autowired
    private ElasticFactory elasticFactory;
    public Boolean save(List sms, String esIndex, String esType) {
        JestClient jestClient = null;
        try {
            //得到链接
            jestClient = elasticFactory.getJestClient();
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (Object obj : sms) {
                Index index = new Index.Builder(obj).build();
                bulk.addAction(index);
            }
            BulkResult br = jestClient.execute(bulk.build());
            logger.info("save data count:" + sms.size());
            logger.info("save flag:" + br.isSucceeded());
            return br.isSucceeded();
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(" save error :" + e.getMessage());
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return null;
    }
}

+ 3 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -1161,7 +1161,8 @@ public class JwPrescriptionService {
        SearchResult result = jestClient.execute(search);
        
        List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
        
        jestClient.shutdownClient();
        return followupContentESDOList;
    }
    
@ -1185,6 +1186,7 @@ public class JwPrescriptionService {
        this.esDeleteFollowUpContent(dataList);
        //保存新的随访详情记录
        elastricSearchSave.save(newdatalist,esIndex,esType);
        jestClient.shutdownClient();
    }
    
    public HashMap<String,String> operaESFollowUpContentData(List<FollowupContentESDO> esdataList){

+ 8 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/es/ElastricSearchSave.java

@ -27,10 +27,12 @@ public class ElastricSearchSave {
    @Autowired
    private ElasticFactory elasticFactory;
    public Boolean save(List  sms,String esIndex,String esType) {
    public Boolean save(List sms, String esIndex, String esType) {
        JestClient jestClient = null;
        try {
            //得到链接
            JestClient jestClient = elasticFactory.getJestClient();
            jestClient = elasticFactory.getJestClient();
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (Object obj : sms) {
@ -44,6 +46,10 @@ public class ElastricSearchSave {
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(" save error :" + e.getMessage());
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return null;
    }

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/EncodingFilter.java

@ -39,7 +39,7 @@ public class EncodingFilter implements Filter {
                newRequest.addParameter(key, URLDecoder.decode((value),"utf-8"));
            }
        }
        logger.debug("reqURL:"+request.getRequestURI());
        //logger.debug("reqURL:"+request.getRequestURI());
        chain.doFilter(newRequest, response);
    }

+ 137 - 103
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -903,50 +903,59 @@ public class FollowUpService extends BaseService {
     */
    @Transactional
    public void esSaveFollowupProjectData(String id, String followupProject, String followupProjectData) throws Exception {
        JestClient jestClient = null;
        try {
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(
                new BoolQueryBuilder()
                        .must(QueryBuilders.matchQuery("followup_id", id))
                        .must(QueryBuilders.matchQuery("followup_project", followupProject))
        );
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
        List<FollowupContentESDO> dataList = result.getSourceAsObjectList(FollowupContentESDO.class);
        //删除原有记录
        this.esDeleteFollowUpContent(dataList);
        //保存新的随访详情信息
        List<FollowupContentESDO> newdatalist = new ArrayList<>();
        FollowupContentESDO followupContentESDO = new FollowupContentESDO();
        followupContentESDO = JSON.parseObject(followupProjectData, FollowupContentESDO.class);
        followupContentESDO.setFollowup_id(id);
        followupContentESDO.setFollowup_project(followupProject);
        followupContentESDO.setCreate_time(new Date());
        newdatalist.add(followupContentESDO);
        elastricSearchSave.save(newdatalist, esIndex, esType);
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("followup_id", id))
                            .must(QueryBuilders.matchQuery("followup_project", followupProject))
            );
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            List<FollowupContentESDO> dataList = result.getSourceAsObjectList(FollowupContentESDO.class);
            //删除原有记录
            this.esDeleteFollowUpContent(dataList);
            //保存新的随访详情信息
            List<FollowupContentESDO> newdatalist = new ArrayList<>();
            FollowupContentESDO followupContentESDO = new FollowupContentESDO();
            followupContentESDO = JSON.parseObject(followupProjectData, FollowupContentESDO.class);
            followupContentESDO.setFollowup_id(id);
            followupContentESDO.setFollowup_project(followupProject);
            followupContentESDO.setCreate_time(new Date());
            newdatalist.add(followupContentESDO);
            elastricSearchSave.save(newdatalist, esIndex, esType);
            //如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
            Followup followup = followupDao.findOne(Long.valueOf(id));
            if ("1".equals(followup.getStatus())) {
                FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(id));
                if (followupMapping == null) {
                    followupMapping = new FollowupMapping();
                    followupMapping.setCode(UUID.randomUUID().toString());
                    followupMapping.setFollowupId(Integer.parseInt(id));
                    followupMapping.setUpdateTime(DateUtil.getNowTimestamp());
                    followupMapping.setCreateTime(DateUtil.getNowTimestamp());
                }
                followupMapping.setNeedUpload(1);
                followUpMappingDao.save(followupMapping);
            }
        //如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if ("1".equals(followup.getStatus())) {
            FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(id));
            if (followupMapping == null) {
                followupMapping = new FollowupMapping();
                followupMapping.setCode(UUID.randomUUID().toString());
                followupMapping.setFollowupId(Integer.parseInt(id));
                followupMapping.setUpdateTime(DateUtil.getNowTimestamp());
                followupMapping.setCreateTime(DateUtil.getNowTimestamp());
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
            followupMapping.setNeedUpload(1);
            followUpMappingDao.save(followupMapping);
        }
    }
@ -954,21 +963,28 @@ public class FollowUpService extends BaseService {
     * ES获取面访项目数据
     */
    public FollowupContentESDO esGetFollowupProjectData(String id, String followupProject) throws Exception {
        //根据随访ID、分类ID获取随访记录详情
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(
                new BoolQueryBuilder()
                        .must(QueryBuilders.matchQuery("followup_id", id))
                        .must(QueryBuilders.matchQuery("followup_project", followupProject))
        );
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
        FollowupContentESDO followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
        JestClient jestClient = null;
        FollowupContentESDO followupContentESDO = null;
        try {
            //根据随访ID、分类ID获取随访记录详情
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("followup_id", id))
                            .must(QueryBuilders.matchQuery("followup_project", followupProject))
            );
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return followupContentESDO;
    }
@ -979,8 +995,9 @@ public class FollowUpService extends BaseService {
     * @date 2017/11/1 15:17
     */
    public void esDeleteFollowUpContent(List<FollowupContentESDO> datalist) throws Exception {
        JestClient jestClient = null;
        try {
            JestClient jestClient = elasticFactory.getJestClient();
            jestClient = elasticFactory.getJestClient();
            //根据id批量删除
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (FollowupContentESDO obj : datalist) {
@ -991,8 +1008,11 @@ public class FollowUpService extends BaseService {
            logger.info("delete data count:" + datalist.size());
            logger.info("delete flag:" + br.isSucceeded());
        } catch (Exception e) {
            e.printStackTrace();
            jestClient.shutdownClient();
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
    }
@ -1004,31 +1024,37 @@ public class FollowUpService extends BaseService {
     * @date 2017/11/1 19:41
     */
    public List<String> esfindProjectByFollowupId(String id) throws Exception {
        //根据随访ID、分类ID获取随访记录详情
        JestClient jestClient = null;
        List<String> resultList = new ArrayList<>();
        try {
            //根据随访ID、分类ID获取随访记录详情
            elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("followup_id", id))
            );
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
            followupContentESDOList = result.getSourceAsObjectList(FollowupContentESDO.class);
            if (!followupContentESDOList.isEmpty()) {
                for (FollowupContentESDO followupContentESDO : followupContentESDOList) {
                    resultList.add(followupContentESDO.getFollowup_project());
                }
            }
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(
                new BoolQueryBuilder()
                        .must(QueryBuilders.matchQuery("followup_id", id))
        );
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
        List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
        followupContentESDOList = result.getSourceAsObjectList(FollowupContentESDO.class);
        if (!followupContentESDOList.isEmpty()) {
            for (FollowupContentESDO followupContentESDO : followupContentESDOList) {
                resultList.add(followupContentESDO.getFollowup_project());
            jestClient.shutdownClient();
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return resultList;
    }
@ -1039,29 +1065,36 @@ public class FollowUpService extends BaseService {
     * @date 2017/11/1 19:41
     */
    public List<FollowupContentESDO> esfindFollowUpContestsByFollowupId(String id) throws Exception {
        //根据随访ID、分类ID获取随访记录详情
        List<String> resultList = new ArrayList<>();
        JestClient jestClient = null;
        List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
        try {
            //根据随访ID、分类ID获取随访记录详情
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(
                new BoolQueryBuilder()
                        .must(QueryBuilders.matchQuery("followup_id", id))
        );
            List<String> resultList = new ArrayList<>();
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("followup_id", id))
            );
        List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return followupContentESDOList;
    }
    /**
     * 根据续方CODE获取随访记录信息
     *
     * @param prescriptionCode
     * @return
     */
@ -1076,6 +1109,7 @@ public class FollowUpService extends BaseService {
    /**
     * 获取随访详情记录分类记录数
     *
     * @param followupid
     * @param type
     * @return
@ -1084,25 +1118,25 @@ public class FollowUpService extends BaseService {
        int count = 0;
        String[] typelist = null;
        if(type.contains(",")){
        if (type.contains(",")) {
            typelist = type.split(",");
        }else{
        } else {
            typelist = new String[]{type};
        }
        for (String typekey: typelist) {
            if(!"drug".equals(type)){
        for (String typekey : typelist) {
            if (!"drug".equals(type)) {
                FollowupContentESDO followupContentESDO = this.esGetFollowupProjectData(followupid,typekey);
                if(followupContentESDO != null){
                    count ++;
                FollowupContentESDO followupContentESDO = this.esGetFollowupProjectData(followupid, typekey);
                if (followupContentESDO != null) {
                    count++;
                }
            }else{
            } else {
                //获取用药记录
                List<FollowupDrugs> drugsList = followupDrugsDao.findByFollowupId(Long.valueOf(followupid));
                if(!drugsList.isEmpty()){
                    count = count +drugsList.size();
                if (!drugsList.isEmpty()) {
                    count = count + drugsList.size();
                }
            }
        }

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -1626,7 +1626,7 @@ public class PrescriptionInfoService extends BaseService {
    }
    public JSONArray getIcd10Info(String nameKey) {
        StringBuffer stringBuffer = new StringBuffer(" SELECT t.code,t.name FROM icd10_dict t WHERE t.name LIKE ?");
        StringBuffer stringBuffer = new StringBuffer(" SELECT t.code,t.name FROM icd10_dict t WHERE t.name LIKE ? and t.chronic_flag='1' ");
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(stringBuffer.toString(), new Object[]{"%" + nameKey + "%"});
        return new JSONArray(rs);
    }

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

@ -2967,7 +2967,7 @@ public class StatisticsESService {
    public List<Map<String, Object>> getPrescriptionAgeLowLevel(String level, String lowlevel, String area, String disease) throws Exception {
        String quotaDate = elasticsearchUtil.getQuotaTime();
        List<SaveModel> list = elasticsearchUtil.findListDateQuotaLevel1(quotaDate, area, Integer.parseInt(level), "58", "2", lowlevel, disease);
        List<SaveModel> list = elasticsearchUtil.findListDateQuotaLevel1(quotaDate, area, Integer.parseInt(level), "63", "2", lowlevel, disease);
        Map<String, Object> map = null;
        List<Map<String, Object>> rs = new ArrayList<>();
        if (list.size() > 0) {
@ -3063,18 +3063,28 @@ public class StatisticsESService {
        Long num = (Long) count.get("num");
        Map<String, Object> map = new HashMap<>();
        DecimalFormat decimalFormat = new DecimalFormat("0.00");//构造方法的字符格式这里如果小数不足2位,会以0补足.
        Double ageRate = list.get(0).getResult2() / num;
        map.put("0ageRate", decimalFormat.format(ageRate));
        ageRate = list.get(1).getResult2() / num;
        map.put("7ageRate", decimalFormat.format(ageRate));
        ageRate = list.get(2).getResult2() / num;
        map.put("19ageRate", decimalFormat.format(ageRate));
        ageRate = list.get(3).getResult2() / num;
        map.put("31ageRate", decimalFormat.format(ageRate));
        ageRate = list.get(4).getResult2() / num;
        map.put("51ageRate", decimalFormat.format(ageRate));
        ageRate = list.get(5).getResult2() / num;
        map.put("65ageRate", decimalFormat.format(ageRate));
        if(num==0){
            map.put("0ageRate", 0.0);
            map.put("7ageRate", 0.0);
            map.put("19ageRate", 0.0);
            map.put("31ageRate", 0.0);
            map.put("51ageRate", 0.0);
            map.put("65ageRate", 0.0);
        }else{
            Double ageRate = list.get(0).getResult2() / num;
            map.put("0ageRate", decimalFormat.format(ageRate));
            ageRate = list.get(1).getResult2() / num;
            map.put("7ageRate", decimalFormat.format(ageRate));
            ageRate = list.get(2).getResult2() / num;
            map.put("19ageRate", decimalFormat.format(ageRate));
            ageRate = list.get(3).getResult2() / num;
            map.put("31ageRate", decimalFormat.format(ageRate));
            ageRate = list.get(4).getResult2() / num;
            map.put("51ageRate", decimalFormat.format(ageRate));
            ageRate = list.get(5).getResult2() / num;
            map.put("65ageRate", decimalFormat.format(ageRate));
        }
        return map;
    }
@ -3289,13 +3299,14 @@ public class StatisticsESService {
     * @return
     */
    public Map<String, Object> getPrescriptionAgeTotal(String level, String area, String disease) throws Exception {
        //统计长处方总数疾病和状态维度(去重相同患者)
        String index ="63";
        String quotaDate = elasticsearchUtil.getQuotaTime();
        //统计年龄分布
        List<SaveModel> list = elasticsearchUtil.findOneDateQuotaLevel2(quotaDate, area, Integer.parseInt(level), "60", "2", disease);
        List<SaveModel> list = elasticsearchUtil.findOneDateQuotaLevel2(quotaDate, area, Integer.parseInt(level), index, "2", disease);
        //总数量
        SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(quotaDate, area, Integer.parseInt(level), "60", "2");
        SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(quotaDate, area, Integer.parseInt(level), index, "2");
        Double num = saveModel.getResult2();
        Map<String, Object> map = new HashMap<>();
@ -3325,44 +3336,46 @@ public class StatisticsESService {
    }
    public Map<String, Object> getPrescriptionDispatchingTotal(int level, String area, String disease) throws Exception {
        List<SaveModel> seltList = null;//自取集合
        List<SaveModel> deliveryList = null;//物流配送集合
        List<SaveModel> healthDoctorList = null;//健管师配送集合
        String index = "62";
        SaveModel selt = null;//自取集合
        SaveModel delivery = null;//物流配送集合
        SaveModel healthDoctor = null;//健管师配送集合
        String quotaTime = elasticsearchUtil.getQuotaTime();
        //type二级指标,disease一级指标
        if (StringUtils.isNotBlank(disease)) {
            //自取
            seltList = elasticsearchUtil.findListDateQuotaLevel2(quotaTime, area, level, "62", "2", "", "1", disease);
            selt = elasticsearchUtil.findOneDateQuotaLevel2(quotaTime,area, level, index, "2", disease, "1");
            //物流配送
            deliveryList = elasticsearchUtil.findListDateQuotaLevel2(quotaTime, area, level, "62", "2", "", "2", disease);
            delivery = elasticsearchUtil.findOneDateQuotaLevel2(quotaTime,area, level, index, "2", disease, "2");
            //健管师配送
            healthDoctorList = elasticsearchUtil.findListDateQuotaLevel2(quotaTime, area, level, "62", "2", "", "2", disease);
            healthDoctor = elasticsearchUtil.findOneDateQuotaLevel2(quotaTime,area, level, index, "2", disease, "3");
        } else {
            //自取
            seltList = elasticsearchUtil.findListDateQuotaLevel1(quotaTime, area, level, "62", "2", "", "1");
            selt = elasticsearchUtil.findOneDateQuotaLevel1Key2(quotaTime, area, level, index, "2", "1");
            //物流配送
            deliveryList = elasticsearchUtil.findListDateQuotaLevel1(quotaTime, area, level, "62", "2", "", "2");
            delivery = elasticsearchUtil.findOneDateQuotaLevel1Key2(quotaTime, area, level, index, "2", "2");
            //健管师配送
            healthDoctorList = elasticsearchUtil.findListDateQuotaLevel1(quotaTime, area, level, "62", "2", "", "2");
            healthDoctor = elasticsearchUtil.findOneDateQuotaLevel1Key2(quotaTime, area, level, index, "2", "3");
        }
        Map<String, Object> rs = new HashedMap();
        //自取数目
        if (seltList != null && seltList.size() > 0) {
            rs.put("seltTotal", seltList.get(0).getResult2());
        if (selt != null) {
            rs.put("seltTotal", selt.getResult2());
        } else {
            rs.put("seltTotal", 0);
        }
        //快递配送
        if (deliveryList != null && deliveryList.size() > 0) {
            rs.put("deliveryTotal", deliveryList.get(0).getResult2());
        if (delivery != null) {
            rs.put("deliveryTotal", delivery.getResult2());
        } else {
            rs.put("deliveryTotal", 0);
        }
        //健管师配送
        if (healthDoctorList != null && healthDoctorList.size() > 0) {
            rs.put("doctorTotal", healthDoctorList.get(0).getResult2());
        if (healthDoctor != null) {
            rs.put("doctorTotal", healthDoctor.getResult2());
        } else {
            rs.put("doctorTotal", 0);
        }
@ -3398,9 +3411,9 @@ public class StatisticsESService {
        List<SaveModel> resultList = new ArrayList<>();
        if (StringUtils.isNotBlank(disease)) {
            resultList = elasticsearchUtil.findLineChartDateQuotaLevel2(startTime, endTime, area, level, "62", "2", "3", type, disease);
            resultList = elasticsearchUtil.findLineChartDateQuotaLevel2(startTime, endTime, area, level, "62", "2", "3",disease , type);
        } else {
            resultList = elasticsearchUtil.findLineChartDateQuotaLevel1(startTime, endTime, area, level, "62", "2", "3", type);
            resultList = elasticsearchUtil.findLineChartDateQuotaLevel1Key2(startTime, endTime, area, level, "62", "2", "3", type);
        }
        for (Map<String, Object> m : rs) {
@ -3435,9 +3448,9 @@ public class StatisticsESService {
        List<Map<String, Object>> rs = new ArrayList<>();
        if (StringUtils.isNotBlank(disease)) {
            //类型 1.自取,2.快递配送,3.健管师配送
            saveModels = elasticsearchUtil.findListDateQuotaLevel2(quotaDate, area, level, index, "2", lowlevel, type, disease);
            saveModels = elasticsearchUtil.findListDateQuotaLevel2(quotaDate, area, level, index, "2", lowlevel, disease, type);
        } else {
            saveModels = elasticsearchUtil.findListDateQuotaLevel1(quotaDate, area, level, index, "2", lowlevel, type);
            saveModels = elasticsearchUtil.findListDateQuotaLevel1Key2(quotaDate, area, level, index, "2", lowlevel, type);
        }
        if ("5".equals(lowlevel)) {
            translateTeamLeaderName2(saveModels);
@ -3605,7 +3618,14 @@ public class StatisticsESService {
            }
            map = new HashMap<>();
            map.put("avg", avg);
            map.put("date", dateFormat.format(one.getQuotaDate()));
            if("1".equals(type)){
                map.put("date", dateFormat.format(one.getQuotaDate()));
            }else if("2".equals(type)){
                map.put("date", DateUtil.getWeekOfMonth(dateFormat.format(one.getQuotaDate())));
            }else{
                map.put("date", DateUtil.getMonth(dateFormat.format(one.getQuotaDate())));
            }
            countList.add(map);
        }
        return countList;

+ 7 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -1107,4 +1107,11 @@ public class DateUtil {
		calendar.setTime(date);
		return calendar.get(Calendar.YEAR)+"";
	}
	public static String getMonth(String dateString){
		Date date = strToDate(dateString);
		return new SimpleDateFormat(YYYY_MM).format(date);
	}
}

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

@ -32,7 +32,7 @@ import java.util.TreeMap;
 * Created by chenweida on 2017/10/13.
 */
@Controller
@RequestMapping(value = "/esstatistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = {RequestMethod.GET, RequestMethod.POST})
@RequestMapping(value = "/statistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = {RequestMethod.GET, RequestMethod.POST})
@Api(description = "ES统计查询")
public class EsStatisticsController extends BaseController {

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

@ -29,7 +29,7 @@ import java.util.*;
 * Created by lyr on 2016/08/16.
 */
@Controller
@RequestMapping(value = "/statistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
@RequestMapping(value = "/oldstatistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
@Api(description = "统计")
public class StatisticsController extends BaseController {