ソースを参照

Merge branch 'dev' of chenweida/patient-co-management into dev

chenweida 7 年 前
コミット
7d3c5d07f0

+ 6 - 1
patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/config/quartz/SchedulerConfig.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.statistics.config.quartz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
@ -23,12 +24,16 @@ public class SchedulerConfig {
    private JobFactory jobFactory;
    @Autowired
    private DataSource dataSource;
    @Value("${quartz.name}")
    private String quartzName;
    @Bean
    SchedulerFactoryBean schedulerFactoryBean_cwd() throws IOException {
    SchedulerFactoryBean schedulerFactoryBean() throws IOException {
        SchedulerFactoryBean bean = new SchedulerFactoryBean();
        bean.setJobFactory(jobFactory);
        bean.setApplicationContext(this.applicationContext);
        bean.setOverwriteExistingJobs(true);
        bean.setBeanName(quartzName);
        bean.setStartupDelay(20);// 延时启动
        bean.setAutoStartup(true);
        bean.setDataSource(dataSource);

+ 71 - 0
patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/DiseaseLableConvert.java

@ -0,0 +1,71 @@
package com.yihu.wlyy.statistics.etl.convert.wlyy;
import com.yihu.wlyy.statistics.etl.convert.Convert;
import com.yihu.wlyy.statistics.etl.convert.wlyy.model.HealthLable;
import com.yihu.wlyy.statistics.model.dimension.WlyyDimensionQuota;
import com.yihu.wlyy.statistics.util.IdCardUtil;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/6/5.
 */
public class DiseaseLableConvert implements Convert {
    /**
     * @param oneList    数据
     * @param slaveLevel 从1开始
     * @return
     */
    public List<DataModel> convert(JdbcTemplate jdbcTemplate, List<DataModel> oneList, String slaveLevel, WlyyDimensionQuota temp) {
        List<DataModel> returnList = new ArrayList<>();
        //得到全部的服务标签
        String sql = "SELECT " +
                "  spli.label AS health_lable, " +
                "  spli.patient " +
                "FROM " +
                "  wlyy_sign_patient_label_info spli " +
                "WHERE " +
                "  spli.label_type = '3' " +
                "AND spli. STATUS = '1'";
        List<HealthLable> healthLables = jdbcTemplate.query(sql, new BeanPropertyRowMapper(HealthLable.class));
        //疾病标签可能有多个
        Map<String, List<String>> healthLablesMap = new HashMap<>();
        healthLables.stream().forEach(one -> {
            List<String> value = new ArrayList<String>();
            if (healthLablesMap.containsKey(one.getPatient())) {
                value = healthLablesMap.get(one.getPatient());
            }
            value.add(one.getHealthLable());
        });
        oneList.stream().forEach(one -> {
            try {
                List<String> value = healthLablesMap.get(one.getPatient());
                if(value==null||value.size()==0){
                    value=new ArrayList<String>();
                    value.add("0");
                }
                for (int i = 0; i < value.size(); i++) {
                    DataModel dataModelTemp = new DataModel();
                    BeanUtils.copyProperties(one, dataModelTemp);
                    DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(dataModelTemp, value.get(i));
                    returnList.add(dataModelTemp);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        return returnList;
    }
}

+ 5 - 2
patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/HealthLableConvert.java

@ -8,6 +8,7 @@ import com.yihu.wlyy.statistics.util.IdCardUtil;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
@ -44,8 +45,10 @@ public class HealthLableConvert implements Convert {
        oneList.stream().forEach(one -> {
            try {
                Object value = healthLablesMap.get(one.getPatient());
                String sex = IdCardUtil.getSexForIdcard(String.valueOf(value));
                DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(one, sex);
                if (StringUtils.isEmpty(value)) {
                    value="0";
                }
                DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(one, value);
            } catch (Exception e) {
                e.printStackTrace();
            }

+ 2 - 1
patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentMysqlToEsQuotaJob.java

@ -180,7 +180,8 @@ public class CurrentMysqlToEsQuotaJob implements Job {
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("quotaCode", quotaCode))
                            .must(QueryBuilders.matchQuery("timeLevel", timeLevel))
                            .must(QueryBuilders.matchQuery("quotaDate", quotaDate))).size(10000);
                            .must(QueryBuilders.matchQuery("quotaDate", quotaDate)))
                    .size(100000);
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();

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

@ -183,7 +183,8 @@ public class MysqlToEsQuotaJob implements Job {
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("quotaCode", quotaCode))
                            .must(QueryBuilders.matchQuery("timeLevel", timeLevel))
                            .must(QueryBuilders.matchQuery("quotaDate", quotaDate))).size(10000);//一次取10000条
                            .must(QueryBuilders.matchQuery("quotaDate", quotaDate))
            ).size(100000);//一次取10000条
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();

+ 9 - 0
patient-co-statistics-es/src/main/resources/application.yml

@ -153,6 +153,9 @@ wlyy:
  im:
    databaseName: im_new
quartz:
  name: schedulerFactoryBean_test
---
spring:
@ -200,6 +203,9 @@ wlyy:
  im:
    databaseName: im
quartz:
  name: schedulerFactoryBean_prod
---
spring:
@ -257,6 +263,9 @@ wlyy:
  im:
    databaseName: im_new
quartz:
  name: schedulerFactoryBean_dev
---
  spring: