Преглед изворни кода

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

Conflicts:
	patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamDao.java
trick9191 пре 7 година
родитељ
комит
8f1503d5c6
27 измењених фајлова са 594 додато и 75 уклоњено
  1. 9 0
      common/common-entity/src/main/java/com/yihu/figure_label/entity/FlJobConfig.java
  2. BIN
      data/elasticsearch/nodes/0/_state/global-17.st
  3. 0 0
      data/elasticsearch/nodes/0/node.lock
  4. 20 20
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionProCAServiceImp.java
  5. 0 0
      patient-co/patient-co-figure-label/patient-co-figure-label.iml___jb_tmp___
  6. 1 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/DruidConfig.java
  7. 37 18
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/WlyyJpa.java
  8. 11 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/properties/DataSourceProperties.java
  9. 15 6
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ConvertHelper.java
  10. 60 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsDrinkingConvert.java
  11. 60 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsSmokingConvert.java
  12. 4 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SexConvert.java
  13. 1 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FlJobConfigDao.java
  14. 2 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/enums/SourceTypeEnum.java
  15. 75 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/ESExtracter.java
  16. 1 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/Extracter.java
  17. 36 7
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/MysqlExtracter.java
  18. 167 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Es2EsJob.java
  19. 4 3
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Mysql2ESJob.java
  20. 31 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/model/DataModel.java
  21. 3 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/service/JobService.java
  22. 20 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/MakeIDUtil.java
  23. 16 1
      patient-co/patient-co-figure-label/src/main/resources/application-dev.yml
  24. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/GateWayAOP.java
  25. 5 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java
  26. 9 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  27. 5 7
      patient-co/patient-co-wlyy/src/main/resources/application.yml

+ 9 - 0
common/common-entity/src/main/java/com/yihu/figure_label/entity/FlJobConfig.java

@ -25,6 +25,7 @@ public class FlJobConfig extends IdEntity {
    private String del;
    private String sourceType;
    private String source;
    private String datasource;
    public String getJobName() {
        return jobName;
@ -113,4 +114,12 @@ public class FlJobConfig extends IdEntity {
    public void setSource(String source) {
        this.source = source;
    }
    public String getDatasource() {
        return datasource;
    }
    public void setDatasource(String datasource) {
        this.datasource = datasource;
    }
}

BIN
data/elasticsearch/nodes/0/_state/global-17.st


+ 0 - 0
data/elasticsearch/nodes/0/node.lock


+ 20 - 20
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionProCAServiceImp.java

@ -46,23 +46,23 @@ public class PrescriptionProCAServiceImp extends ZysoftBaseService implements Pr
    private String getHeaderXml(String api,String srcBusinessStreamNO,String srcRequestStreamNO)
    {
        return "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
            "<root>\n" +
            "   <serverName>"+api+"</serverName>\n" +
            "   <format>xml</format>\n" +
            "   <callOperator></callOperator>\n" +
            "   <certificate></certificate>\n" +
            "   <srcIP>10.95.22.10</srcIP >\n" +
            "   <srcUserMac>00:50:56:85:39:82</srcUserMac>\n" +
            "   <srcSystemCode>1</srcSystemCode>\n" +
            "   <srcSystemName>厦门i健康</srcSystemName>\n" +
            "   <srcBusinessNodeCode>node01</srcBusinessNodeCode>\n" +
            "   <srcBusinessNodeName>审核</srcBusinessNodeName>\n" +
            "   <srcOperatorAccount>"+srcBusinessStreamNO+"</srcOperatorAccount>\n" +
            "   <srcBusinessStreamNO>"+srcBusinessStreamNO+"</srcBusinessStreamNO>\n" +
            "   <srcRequestStreamNO>"+srcRequestStreamNO+"</srcRequestStreamNO>\n" +
            "   <srcDataExtProperty></srcDataExtProperty>\n" +
        return "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
            "<root>" +
            "   <serverName>"+api+"</serverName>" +
            "   <format>xml</format>" +
            "   <callOperator></callOperator>" +
            "   <certificate></certificate>" +
            "   <srcIP>10.95.22.10</srcIP >" +
            "   <srcUserMac>00:50:56:85:39:82</srcUserMac>" +
            "   <srcSystemCode>1</srcSystemCode>" +
            "   <srcSystemName>厦门i健康</srcSystemName>" +
            "   <srcBusinessNodeCode>node01</srcBusinessNodeCode>" +
            "   <srcBusinessNodeName>审核</srcBusinessNodeName>" +
            "   <srcOperatorAccount>"+srcBusinessStreamNO+"</srcOperatorAccount>" +
            "   <srcBusinessStreamNO>"+srcBusinessStreamNO+"</srcBusinessStreamNO>" +
            "   <srcRequestStreamNO>"+srcRequestStreamNO+"</srcRequestStreamNO>" +
            "   <srcDataExtProperty></srcDataExtProperty>" +
            "</root>";
    }
@ -77,13 +77,12 @@ public class PrescriptionProCAServiceImp extends ZysoftBaseService implements Pr
    private String postZyCaServer(String api, Map<String,String> params,String srcBusinessStreamNO,String content) throws Exception{
        String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                "<root>\n";
        String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?><root>";
        if(params!=null && params.size()>0)
        {
            for(String key : params.keySet())
            {
                msgBody += "    <"+key+">"+params.get(key)+"</"+key+">\n";
                msgBody += "    <"+key+">"+params.get(key)+"</"+key+">";
            }
        }
        msgBody += "</root>";
@ -126,6 +125,7 @@ public class PrescriptionProCAServiceImp extends ZysoftBaseService implements Pr
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            ex.printStackTrace();
            System.out.println("error1:"+ex.getMessage());
            error = sw.toString();
            System.out.println("error2:"+error);

+ 0 - 0
patient-co/patient-co-figure-label/patient-co-figure-label.iml___jb_tmp___


+ 1 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/DruidConfig.java

@ -39,6 +39,7 @@ public class DruidConfig {
        //忽略过滤的形式
        filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
        return filterRegistrationBean;
    }
    @Bean

+ 37 - 18
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/WlyyJpa.java

@ -10,6 +10,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
@ -32,7 +33,7 @@ import java.util.Properties;
        entityManagerFactoryRef = "wlyyEntityManagerFactory",
        transactionManagerRef = "wlyyTransactionManager",
        basePackages = {"com.yihu.wlyy.figure.label.dao"})   //设置Repository所在位置
public class WlyyJpa {
public class FigureLabelJpa {
    @Autowired
    private HibernateProperties hibernateProperties;
@ -41,15 +42,7 @@ public class WlyyJpa {
    @Autowired
    private DruidConfig druidConfig;
    @Bean(name = "wlyyDataSource")
    @Primary
    public DataSource wlyyDataSource() throws SQLException {
        DruidDataSource datasource = new DruidDataSource();
        datasource.setUrl(dataSourceProperties.getWlyy().getUrl());
        datasource.setUsername(dataSourceProperties.getWlyy().getUsername());
        datasource.setPassword(dataSourceProperties.getWlyy().getPassword());
        datasource.setDriverClassName(dataSourceProperties.getDriverClassName());
    private DataSource buildDataSource(DruidDataSource datasource) throws SQLException{
        //configuration
        datasource.setInitialSize(dataSourceProperties.getInitialSize());
        datasource.setMinIdle(dataSourceProperties.getMinIdle());
@ -76,12 +69,31 @@ public class WlyyJpa {
        return datasource;
    }
    @Bean(name = "wlyyDataSource")
    @Primary
    public DataSource wlyyDataSource() throws SQLException {
        DruidDataSource datasource = new DruidDataSource();
        datasource.setUrl(dataSourceProperties.getWlyy().getUrl());
        datasource.setUsername(dataSourceProperties.getWlyy().getUsername());
        datasource.setPassword(dataSourceProperties.getWlyy().getPassword());
        datasource.setDriverClassName(dataSourceProperties.getDriverClassName());
        return buildDataSource(datasource);
    }
    @Bean(name = "healtharchiveDataSource")
    public DataSource healtharchiveDataSource() throws SQLException {
        DruidDataSource datasource = new DruidDataSource();
        datasource.setUrl(dataSourceProperties.getHealtharchive().getUrl());
        datasource.setUsername(dataSourceProperties.getHealtharchive().getUsername());
        datasource.setPassword(dataSourceProperties.getHealtharchive().getPassword());
        datasource.setDriverClassName(dataSourceProperties.getDriverClassName());
        return buildDataSource(datasource);
    }
    @Bean(name = "wlyyEntityManagerFactory")
    @Primary
    public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary(
            @Qualifier("wlyyDataSource") DataSource dataSource) {
    public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary(@Qualifier("wlyyDataSource") DataSource dataSource) {
        LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
        emfb.setDataSource(dataSource);
        emfb.setPackagesToScan("com.yihu.figure_label.entity");
@ -89,17 +101,13 @@ public class WlyyJpa {
        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        emfb.setJpaVendorAdapter(vendorAdapter);
        emfb.setJpaProperties(hibernateProperties.hibProperties());
        return emfb;
    }
    @Bean(name = "wlyyTransactionManager")
    @Primary
    JpaTransactionManager transactionManagerSecondary(
            @Qualifier("wlyyEntityManagerFactory") EntityManagerFactory builder) {
    JpaTransactionManager transactionManagerSecondary(@Qualifier("wlyyEntityManagerFactory") EntityManagerFactory builder) {
        return new JpaTransactionManager(builder);
    }
@ -109,4 +117,15 @@ public class WlyyJpa {
        properties.put("slowSqlMillis", "1000");
        return properties;
    }
    @Bean
    public JdbcTemplate jdbcTemplate(@Qualifier("wlyyDataSource") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }
    @Bean(name = "healtharchiveTemplate")
    public JdbcTemplate secondJdbcTemplate(@Qualifier("healtharchiveDataSource") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }
}

+ 11 - 1
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/properties/DataSourceProperties.java

@ -27,7 +27,9 @@ public class DataSourceProperties {
    private Boolean logAbandoned;
    private String filters;
    private DataSourceLoginProperties wlyy=new DataSourceLoginProperties();
    private DataSourceLoginProperties wlyy = new DataSourceLoginProperties();
    private DataSourceLoginProperties healtharchive = new DataSourceLoginProperties();
    public String getDriverClassName() {
        return driverClassName;
@ -172,4 +174,12 @@ public class DataSourceProperties {
    public void setWlyy(DataSourceLoginProperties wlyy) {
        this.wlyy = wlyy;
    }
    public DataSourceLoginProperties getHealtharchive() {
        return healtharchive;
    }
    public void setHealtharchive(DataSourceLoginProperties healtharchive) {
        this.healtharchive = healtharchive;
    }
}

+ 15 - 6
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ConvertHelper.java

@ -105,26 +105,35 @@ public class ConvertHelper {
     * @return
     */
    public void generateDataSource(DataModel dataModel,SaveModel saveModel,String sourceType,String sources) {
        if(!StringUtils.endsWithIgnoreCase(SourceTypeEnum.MYSQL.toString(),sourceType)){
        if(!StringUtils.endsWithIgnoreCase(SourceTypeEnum.MYSQL.toString(),sourceType) && !StringUtils.endsWithIgnoreCase(SourceTypeEnum.ELASTICSEARCH.toString(),sourceType) ){
            return;
        }
        StringBuilder ids = new StringBuilder();
        // 默认值为0
        if(dataModel.getId() != 0){
        if(dataModel.getId() != null && dataModel.getId() != 0 ){
            ids.append(dataModel.getId()).append(",");
        }
        if(dataModel.getId1() != 0){
        if(dataModel.getId1() != null && dataModel.getId1() != 0 ){
            ids.append(dataModel.getId1()).append(",");
        }
        if(dataModel.getId2() != 0){
        if(dataModel.getId2() != null && dataModel.getId2() != 0 ){
            ids.append(dataModel.getId2()).append(",");
        }
        if(dataModel.getId3() != 0){
        if(dataModel.getId3() != null && dataModel.getId3() != 0 ){
            ids.append(dataModel.getId3()).append(",");
        }
        if(dataModel.getId4() != 0){
        if(dataModel.getId4() != null && dataModel.getId4() != 0 ){
            ids.append(dataModel.getId4());
        }
        if(!StringUtils.isEmpty(dataModel.getIdstr())){
            ids.append(dataModel.getIdstr());
        }
        if(!StringUtils.isEmpty(dataModel.getIdstr1())){
            ids.append(dataModel.getIdstr1());
        }
        if(!StringUtils.isEmpty(dataModel.getIdstr2())){
            ids.append(dataModel.getIdstr2());
        }
        String[] idArr = ids.toString().split(",");
        String[]sourceArr = sources.split(",");
        if(idArr.length != sourceArr.length){

+ 60 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsDrinkingConvert.java

@ -0,0 +1,60 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.figure_label.entity.FlLabelDict;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
/**
 * @author humingfen on 2018.04.19
 * 是否饮酒标签转换器
 */
@Component
public class IsDrinkingConvert implements Convert{
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        // 饮酒code为2,代表未知
        String hasDrinking = "2";
        /*Map<String,String> dictMap = new HashMap<>();
        flLabelDictList.forEach(
                one ->{
                    dictMap.put(one.getLabelCode(),one.getLabelName());
                }
        );*/
        for(DataModel dataModel:modelList){
            if(StringUtils.isNotBlank(dataModel.getLabelValue())) {
                float dailyDrinking = Float.parseFloat(dataModel.getLabelValue());
                if(dailyDrinking > 0){
                    hasDrinking = "0";
                }else if(dailyDrinking <= 0) {
                    hasDrinking = "1";
                }
            }
            SaveModel saveModel = new SaveModel();
            FlLabelDict dict = flLabelDictList.get(Integer.parseInt(hasDrinking));
            saveModel.setId(MakeIDUtil.makeEsSaveModelID(dataModel,dict));
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(hasDrinking);
            saveModel.setLabelName(dict.getLabelName());
            convertHelper.generateDataSource(dataModel,saveModel,sourceType,source);
            //如果fl_job_config表配置的id和数据来源不一致,则不保存数据
            if (StringUtils.isEmpty(saveModel.getSource())) {
                return new ArrayList<>();
            }
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

+ 60 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsSmokingConvert.java

@ -0,0 +1,60 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.figure_label.entity.FlLabelDict;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
/**
 * @author humingfen on 2018.03.14
 * 是否抽烟标签转换器
 */
@Component
public class IsSmokingConvert implements Convert{
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        // 抽烟code为2,代表未知
        String hasSmoking = "2";
        Map<String,String> dictMap = new HashMap<>();
        flLabelDictList.forEach(
                one ->{
                    dictMap.put(one.getLabelCode(),one.getLabelName());
                }
        );
        for(DataModel dataModel:modelList){
            if(StringUtils.isNotBlank(dataModel.getLabelValue())) {
                float dailySmoking = Float.parseFloat(dataModel.getLabelValue());
                if(dailySmoking > 0){
                    hasSmoking = "0";
                }else if(dailySmoking <= 0) {
                    hasSmoking = "1";
                }
            }
            SaveModel saveModel = new SaveModel();
            FlLabelDict dict = flLabelDictList.get(Integer.parseInt(hasSmoking));
            saveModel.setId(MakeIDUtil.makeEsSaveModelID(dataModel,dict));
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(hasSmoking);
            saveModel.setLabelName(dictMap.get(hasSmoking));
            convertHelper.generateDataSource(dataModel,saveModel,sourceType,source);
            //如果fl_job_config表配置的id和数据来源不一致,则不保存数据
            if (StringUtils.isEmpty(saveModel.getSource())) {
                return new ArrayList<>();
            }
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

+ 4 - 1
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SexConvert.java

@ -34,10 +34,13 @@ public class SexConvert implements Convert{
        );
        models.forEach(
                model -> {
                    String sex = IdCardUtil.getSexForIdcard(model.getIdcard());
                    SaveModel saveModel = new SaveModel();
                    saveModel.setId(MakeIDUtil.makeSaveModelID(model,""));
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setLabelType(one.getParentCode());
                    String sex = IdCardUtil.getSexForIdcard(model.getIdcard());
                    saveModel.setLabelCode(sex);
                    saveModel.setLabelName(map.get(sex));
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));

+ 1 - 1
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FlJobConfigDao.java

@ -11,7 +11,7 @@ import java.util.List;
 * @author lith on 2018.03.14
 * 定时任务配置
 */
public interface FlJobConfigDao extends PagingAndSortingRepository<FlJobConfig, String>, JpaSpecificationExecutor<FlJobConfig> {
public interface FlJobConfigDao extends PagingAndSortingRepository<FlJobConfig, Long>, JpaSpecificationExecutor<FlJobConfig> {
    /**
     * 根据id和状态查询job配置

+ 2 - 1
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/enums/SourceTypeEnum.java

@ -7,5 +7,6 @@ package com.yihu.wlyy.figure.label.enums;
public enum SourceTypeEnum {
    MYSQL,
    HBASE,
    FILE;
    FILE,
    ELASTICSEARCH;
}

+ 75 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/ESExtracter.java

@ -0,0 +1,75 @@
package com.yihu.wlyy.figure.label.extract;
import com.yihu.base.es.config.ElasticsearchUtil;
import com.yihu.wlyy.figure.label.model.DataModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @author humingfen on 2018.04.19
 * ES数据抽取器
 */
@Component
public class ESExtracter implements Extracter{
    private Logger logger = LoggerFactory.getLogger(ESExtracter.class);
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    public List<DataModel> extractDataByJobConfigsql(String sql){
        List<DataModel> saveModels = new ArrayList<>();
        List<Map<String,Object>> list = elasticsearchUtil.excuteDataModel(sql);
        for(Map<String,Object> tempMap:list){
            try {
                DataModel dataModel = new DataModel();
                for (String s : tempMap.keySet()) {
                    String key = null;
                    Object value = tempMap.get(s);
                    if (s.startsWith("_")) {
                        continue;
                    }else if((s.equals("id") || s.equals("id1") || s.equals("id2")) && value != null) {
                        value = Integer.parseInt(String.valueOf(value));
                    }
                    key = "set" + UpFirstStr(s);
                    try {
                        if (value instanceof String) {
                            DataModel.class.getMethod(key, String.class).invoke(dataModel, value);
                        } else if (value instanceof Integer) {
                            DataModel.class.getMethod(key, Integer.class).invoke(dataModel, value);
                        } else if (value instanceof Double) {
                            DataModel.class.getMethod(key, Double.class).invoke(dataModel, value);
                        } else if (value instanceof java.util.Date) {
                            DataModel.class.getMethod(key, java.util.Date.class).invoke(dataModel, value);
                        }
                    } catch (Exception e) {
                        logger.error(e.getMessage());
                    }
                }
                saveModels.add(dataModel);
            }catch (Exception e) {
                e.printStackTrace();
            }
        }
        return saveModels;
    }
    /**
     * 首字母大写
     *
     * @param str
     * @return
     */
    private String UpFirstStr(String str) {
        return str.replaceFirst(str.substring(0, 1), str.substring(0, 1).toUpperCase());
    }
}

+ 1 - 1
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/Extracter.java

@ -16,7 +16,7 @@ public interface Extracter {
     */
//    List<ExtractModel> extract();
    List<DataModel> extractDataByJobConfigsql(String sql);
    List<DataModel> extractDataByJobConfigsql(String sql,String datasource);
}

+ 36 - 7
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/MysqlExtracter.java

@ -4,10 +4,16 @@ import com.yihu.wlyy.figure.label.model.DataModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.*;
/**
@ -21,12 +27,36 @@ public class MysqlExtracter implements Extracter {
    private int numPerPage = 100000; //一次性最多查询10万条
    private Map<String,JdbcTemplate> templateMap = new HashMap<>();
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Qualifier("jdbcTemplate")
    private JdbcTemplate wlyydefaultJdbcTemplate;
    @Autowired
    @Qualifier("healtharchiveTemplate")
    private JdbcTemplate healtharchiveTemplate;
    @PostConstruct
    public void initTemplateMap(){
        templateMap.put("wlyy",wlyydefaultJdbcTemplate);
        templateMap.put("healtharchive",healtharchiveTemplate);
    }
    @Override
    public List<DataModel> extractDataByJobConfigsql(String sql) {
        return  getDataByThread(sql);
    public List<DataModel> extractDataByJobConfigsql(String sql,String datasource) {
        JdbcTemplate jdbcTemplate = null;
        // 默认的
        if(StringUtils.isEmpty(datasource)){
            jdbcTemplate = templateMap.get("wlyy");
            return  getDataByThread(sql,jdbcTemplate);
        }
        jdbcTemplate = templateMap.get(datasource);
        if(null == jdbcTemplate){
            logger.error("datasource not exist,check in fl_job_config: "+ datasource);
            return null;
        }
        return  getDataByThread(sql,jdbcTemplate);
    }
    /**
@ -34,9 +64,9 @@ public class MysqlExtracter implements Extracter {
     * @param sql
     * @return
     */
    public List<DataModel> getDataByThread(String sql){
    public List<DataModel> getDataByThread(String sql,JdbcTemplate jdbcTemplate){
        List<DataModel> datas = new ArrayList<>();
        int size = this.getCount(sql);
        int size = this.getCount(sql,jdbcTemplate);
        int number = size / numPerPage + 1;
        ExecutorService fixedThreadPool =  Executors.newFixedThreadPool(number);
        List<Callable<List<DataModel>>> threadList = new ArrayList<>();
@ -72,10 +102,9 @@ public class MysqlExtracter implements Extracter {
     * @param sql
     * @return
     */
    public Integer getCount(String sql){
    public Integer getCount(String sql,JdbcTemplate jdbcTemplate){
        String countSql = "select count(*) from " + sql.split("from|FROM")[1];
        Integer count = jdbcTemplate.queryForObject(countSql,Integer.class);
        return count;
    }
}

+ 167 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Es2EsJob.java

@ -0,0 +1,167 @@
package com.yihu.wlyy.figure.label.job;
import com.yihu.figure_label.entity.FlJobConfig;
import com.yihu.figure_label.entity.FlLabelDictJob;
import com.yihu.wlyy.figure.label.controller.JobController;
import com.yihu.wlyy.figure.label.convert.ConvertHelper;
import com.yihu.wlyy.figure.label.dao.FlJobConfigDao;
import com.yihu.wlyy.figure.label.dao.FlLabelDictJobDao;
import com.yihu.wlyy.figure.label.enums.JobSqlFieldTypeEnum;
import com.yihu.wlyy.figure.label.extract.ESExtracter;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.service.JobService;
import com.yihu.wlyy.figure.label.storage.Store2ES;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
@Service
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class Es2EsJob implements Job {
    private Logger logger = LoggerFactory.getLogger(JobController.class);
    @Autowired
    private FlJobConfigDao flJobConfigDao;
    @Autowired
    private FlLabelDictJobDao flLabelDictJobDao;
    @Autowired
    private ESExtracter esExtracter;
    @Autowired
    private ConvertHelper convertHelper;
    @Autowired
    Store2ES store2ES;
    @Autowired
    private JobService jobService;
    private FlJobConfig flJobConfig;
    private Long flJobConfigId;
    private String sqlFiledValue;
    private String sqlFiledCondition;
    private String finalSql;
    private List<DataModel> dataModelList;
    private String sourceType;
    private String source;
    /**
     * 数据表的id,有些数据是按时间增量查询,有些数据是按表的主键id增量查询
     */
    private long lastDataId;
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDataMap paramsMap = context.getJobDetail().getJobDataMap();
        initParams(paramsMap);
        //提取数据
        extract();
        //数据转换
        List<SaveModel> list = new ArrayList<>();
        list = convert();
        //数据保存
        boolean bool = save(list);
        //增量存储成功后,修改增量的czrq时间为当前时间或主键id为上次获取到的数据的最后的一条的id
        if(StringUtils.endsWithIgnoreCase(this.flJobConfig.getSqlFieldType().toString(), JobSqlFieldTypeEnum.TIME.toString())){
            jobService.updateFieldValuetoCurrentTimeOrId(this.flJobConfigId,null,bool);
        }else if(StringUtils.endsWithIgnoreCase(this.flJobConfig.getSqlFieldType().toString(), JobSqlFieldTypeEnum.NUM.toString())){
            int index = dataModelList.size();
            lastDataId = dataModelList.get(index -1).getId();
            jobService.updateFieldValuetoCurrentTimeOrId(this.flJobConfigId,this.lastDataId,bool);
        }
    }
    public void initParams(JobDataMap paramsMap){
        this.flJobConfigId = (Long)paramsMap.get("jobConfig");
        this.sourceType = String.valueOf(paramsMap.get("sourceType"));
        this.source = String.valueOf(paramsMap.get("source"));
        this.flJobConfig = flJobConfigDao.findById(this.flJobConfigId);
        this.sqlFiledValue = String.valueOf(paramsMap.get("sqlFiledValue"));
        this.sqlFiledCondition = paramsMap.getString("sqlFiledCondition");
        //没有传增量值,以数据库配置的默认值为查询条件
        if(org.springframework.util.StringUtils.isEmpty(this.sqlFiledValue)){
            this.sqlFiledValue = this.flJobConfig.getSqlFieldValue();
            this.sqlFiledCondition=">";
        }
        //1抽取数据
        String sql = this.flJobConfig.getSql();
        String sqlFiled = this.flJobConfig.getSqlField();
        this.finalSql = getFinalSql(sql,sqlFiled,sqlFiledCondition,sqlFiledValue);
    }
    public String getFinalSql(String sql, String sqlFiled, String sqlFiledCondition, String sqlFiledValue) {
        StringBuilder result = new StringBuilder();
        result.append(sql).append(" ");
        if (sqlFiledValue.contains(",") && sql.contains("where")) {
            String[] sqlFiledValues = sqlFiledValue.split(",");
            result.append("and ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValues[1]+"\'").append(" and ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValues[0]+"\'");
        }else if(sql.contains("where")){
            result.append("and ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValue+"\'");
        }else if (sql.contains("$")){
            StringBuffer otherCondition = new StringBuffer();
            otherCondition.append("where ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValue+"\'");
            result.replace(result.indexOf("$"),result.indexOf("$")+1,otherCondition.toString());
        }else {
            result.append("where ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValue+"\'");
        }
        return result.toString();
    }
    /**
     * 提取数据,按数据库中配置的增量条件提取
     */
    public void extract(){
        this.dataModelList = esExtracter.extractDataByJobConfigsql(this.finalSql);
    }
    /**
     * 转换
     */
    public List<SaveModel> convert(){
        List<SaveModel> list = new ArrayList<>();
        FlLabelDictJob flLabelDictJob = flLabelDictJobDao.findByJobId(this.flJobConfigId);
        try {
            list = convertHelper.convert(this.dataModelList, flLabelDictJob,this.sourceType,this.source);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
        return list;
    }
    /**
     * 保存
     * @param list
     */
    public boolean save(List<SaveModel> list){
        boolean bool = true;
        try {
            store2ES.save(list);
        }catch (Exception e){
            logger.error("save to elasticsearch failed,convet data count:" + list.size());
            bool = false;
        }
        return bool;
    }
}

+ 4 - 3
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Mysql2ESJob.java

@ -74,6 +74,8 @@ public class Mysql2ESJob implements Job {
    private String source;
    private String datasource;
    /**
     * 数据表的id,有些数据是按时间增量查询,有些数据是按表的主键id增量查询
     */
@ -111,10 +113,9 @@ public class Mysql2ESJob implements Job {
        this.source = String.valueOf(paramsMap.get("source"));
        this.flJobConfig = flJobConfigDao.findById(this.flJobConfigId);
//        this.sqlFiledValue = String.valueOf(paramsMap.get("sqlFiledValue"));
        this.datasource = flJobConfig.getDatasource();
        this.sqlFiledCondition = paramsMap.getString("sqlFiledCondition");
        this.sqlFiledValue = flJobConfig.getSqlFieldValue();
        this.sqlFiledCondition = ">";
        //没有传增量值,以数据库配置的默认值为查询条件
        if(StringUtils.isEmpty(this.sqlFiledValue)){
            this.sqlFiledValue = this.flJobConfig.getSqlFieldValue();
@ -131,7 +132,7 @@ public class Mysql2ESJob implements Job {
     * 提取数据,按数据库中配置的增量条件提取
     */
    public void extract(){
        this.dataModelList = mysqlExtracter.extractDataByJobConfigsql(this.finalSql);
        this.dataModelList = mysqlExtracter.extractDataByJobConfigsql(this.finalSql,this.datasource);
    }
    /**

+ 31 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/model/DataModel.java

@ -13,6 +13,13 @@ public class DataModel {
    private int id2;
    private int id3;
    private int id4;
    /**
     * 有些表的id为uuid,是string类型,所以为了兼容所有的,此种类型id命名为idstr,进行数据抽取时需多注意
     */
    private String idstr;
    private String idstr1;
    private String idstr2;
    /**
     * 居民身份证号
     */
@ -96,6 +103,30 @@ public class DataModel {
        this.id4 = id4;
    }
    public String getIdstr() {
        return idstr;
    }
    public void setIdstr(String idstr) {
        this.idstr = idstr;
    }
    public String getIdstr1() {
        return idstr1;
    }
    public void setIdstr1(String idstr1) {
        this.idstr1 = idstr1;
    }
    public String getIdstr2() {
        return idstr2;
    }
    public void setIdstr2(String idstr2) {
        this.idstr2 = idstr2;
    }
    public String getIdcard() {
        return idcard;
    }

+ 3 - 1
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/service/JobService.java

@ -120,13 +120,15 @@ public class JobService {
    }
    public void startNowById(String id) throws Exception {
        FlJobConfig FlJobConfig = flJobConfigDao.findOne(id);
        FlJobConfig FlJobConfig = flJobConfigDao.findOne(Long.parseLong(id));
        FlJobConfig flJobConfigVO = new FlJobConfig();
        BeanUtils.copyProperties(FlJobConfig, flJobConfigVO);
        Map<String, Object> params = new HashMap<>();
        params.put("jobConfig", flJobConfigVO.getId());
        params.put("sourceType", flJobConfigVO.getSourceType());
        params.put("source", flJobConfigVO.getSource());
        if(!StringUtils.isEmpty(flJobConfigVO.getSqlFieldValue())){
            params.put(flJobConfigVO.getSqlField(),flJobConfigVO.getSqlFieldValue());
        }else{

+ 20 - 2
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/MakeIDUtil.java

@ -1,13 +1,14 @@
package com.yihu.wlyy.figure.label.util;
import com.yihu.figure_label.entity.FlLabelDict;
import com.yihu.wlyy.figure.label.model.DataModel;
import org.springframework.util.StringUtils;
public class MakeIDUtil {
    /**
     * 生成存入es的id,确保数据不会重复
     * id由 idcard,parentCode,labelName,labelCode MD5加密而成。不用es自动生成的_id,实现数据插入排重
     * 生成从mysql获取,后存入es的id,确保数据不会重复
     * id由 idcard,parentCode,labelName,labelCode MD5加密而成。
     * @param dataModel
     * @param labelValue
     * @return
@ -24,6 +25,23 @@ public class MakeIDUtil {
        return MD5Util.GetMD5Code(idStr.toString());
    }
    /**
     * 生成从es获取,后存入es的id,确保数据不会重复
     * id由 id,id1,parentCode,labelName,labelCode MD5加密而成。
     * @param dataModel
     * @param flLabelDict
     * @return
     */
    public static String makeEsSaveModelID(DataModel dataModel, FlLabelDict flLabelDict) {
        StringBuilder idStr = new StringBuilder();
        idStr.append(dataModel.getId() + "").append("-")
                .append(dataModel.getId1() + "").append("-")
                .append(flLabelDict.getParentCode()).append("-")
                .append(flLabelDict.getLabelCode()).append("-")
                .append(flLabelDict.getLabelName());
        return MD5Util.GetMD5Code(idStr.toString());
    }
    public static void main(String[] args) {
        DataModel dataModel = new DataModel();

+ 16 - 1
patient-co/patient-co-figure-label/src/main/resources/application-dev.yml

@ -11,11 +11,26 @@ spring:
      url: jdbc:mysql://172.19.103.77/figure_lable?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: root
      password: 123456
    healtharchive:
      url: jdbc:mysql://172.19.103.50:3306/healtharchive?useUnicode=true&characterEncoding=UTF-8&useSSL=false
      username: chenweishan
      password: chenweishan
  data:
    elasticsearch:
      cluster-nodes-jest: http://172.19.103.45:9200,http://172.19.103.68:9200  #多个逗号分割
      cluster-name: jkzl #es集群的名字
      cluster-nodes: 172.19.103.68:9300
#      ,172.19.103.45:9300, #多个逗号分割
      cluster-nodes-jest: http://172.19.103.68:9200
#      ,http://172.19.103.45:9200  #多个逗号分割
      repositories:
        enabled: true
      properties:
        client:
          transport:
            sniff: false #开启嗅探集群  用nginx代理一层过后会出现ip解析失败问题
quartz:
  namespace: patient-co-figure-label ##quartz的命名空间,名称一样实现消费负载

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/GateWayAOP.java

@ -25,7 +25,7 @@ import java.io.PrintWriter;
public class GateWayAOP {
    private Logger logger = LoggerFactory.getLogger(GateWayAOP.class);
    //Controller层切点路径
    //Controller层切点路径1
    @Pointcut("execution(* com.yihu.wlyy.web..*.*(..))")
    public void controllerAspect() {
    }
@ -44,7 +44,7 @@ public class GateWayAOP {
            request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            obj = point.proceed();
        } catch (Exception e) {
            logger.error(e.getMessage());
           // logger.error(e.getMessage());
        }
        if (request != null) {
            request.setAttribute("returnObj", obj);

+ 5 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java

@ -128,6 +128,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
                data = json.getJSONObject("data").getJSONArray("DATA");
            }
            Map<String, String> map = new HashMap<>();//存储产检号,用于去除预建卡信息中重复记录
            Map<String, String> mensesLastMap = new HashMap<>();//末次月经,用于去除预建卡信息中重复记录
            if (data != null && data.size() > 0) {//有建卡信息
                for (int i = 0; i < data.size(); i++) {
                    JSONObject planJson = new JSONObject();
@ -148,7 +149,8 @@ public class PrenatalInspectorPreCardService extends BaseService {
                    planJson.put("mensesLast", MENSES_LAST);
                    planJson.put("expectedTime", EXPECTED_TIME);
                    Date date = new Date();
                    map.put("PREGNANCY_NO", "PREGNANCY_NO");
                    map.put(PREGNANCY_NO, PREGNANCY_NO);
                    mensesLastMap.put(MENSES_LAST, MENSES_LAST);
                    if (StringUtils.isBlank(END_TIME)) {
                        checkFlag = checkFlag ? false : checkFlag;
                        //未结束妊娠,生成待产检计划
@ -265,13 +267,13 @@ public class PrenatalInspectorPreCardService extends BaseService {
                            JSONObject planJson = new JSONObject();
                            JSONObject pregnancy = preData.getJSONObject(i);
                            String PREGNANCY_NO = pregnancy.getString("PREGNANCY_NO");//智业产检号
                            if (map.containsKey(PREGNANCY_NO)) {
                            String MENSES_LAST = pregnancy.getString("MENSES_LAST");//末次月经
                            if (map.containsKey(PREGNANCY_NO)||mensesLastMap.containsKey(MENSES_LAST)) {
                                continue;//去重
                            }
                            String END_MANNER = pregnancy.getString("END_MANNER");//妊娠终止方式
                            String END_TIME = pregnancy.getString("END_TIME");//结束妊娠
                            String MENSES_LAST = pregnancy.getString("MENSES_LAST");//末次月经
                            Date dueday = DateUtil.getDueDate(DateUtil.strToDateLong(MENSES_LAST));//预产期
                            planJson.put("pregnancyNo", PREGNANCY_NO);
                            planJson.put("pregnancyStatus", "0");

+ 9 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -2100,6 +2100,15 @@ public class SignWebService extends BaseService {
                }
            }
        }
        if(StringUtils.isBlank(doctorCodeSql)){
            //找不到服务团队,取签约表的医生
            doctorCodeSql = "'" + signFamily.getDoctor() + "'";
            if(!signFamily.getDoctor().equals(signFamily.getDoctorHealth())){
                doctorCodeSql += ",'" + signFamily.getDoctorHealth() + "'";
            }
        }
//        Calendar cal = Calendar.getInstance();
//        int year = cal.get(Calendar.YEAR);
        //咨询量

+ 5 - 7
patient-co/patient-co-wlyy/src/main/resources/application.yml

@ -52,7 +52,11 @@ spring:
      max-wait: -1  # 连接池最大阻塞等待时间(使用负值表示没有限制)
      max-idle: 20  # 连接池中的最大空闲连接
      min-idle: 5  # 连接池中的最小空闲连接
  http:
    multipart:
      enabled: true
      max-file-size: 50mb
      max-request-size: 50mb
logging:
  level:
    root: INFO
@ -69,12 +73,6 @@ hibernate:
    naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy
multipart:
  enabled: true
  max-file-size: 50mb
  max-request-size: 50mb
security:
  basic:
    username: jkzl