Browse Source

首次提交

huangzhiyong 6 years ago
parent
commit
a7dd1a4470
100 changed files with 10669 additions and 0 deletions
  1. 6 0
      .gitignore
  2. 138 0
      pom.xml
  3. 12 0
      src/main/java/com/yihu/hos/rest/HosRestApplication.java
  4. 129 0
      src/main/java/com/yihu/hos/rest/common/configuration/BeanConfiguration.java
  5. 71 0
      src/main/java/com/yihu/hos/rest/common/configuration/CrawlerConfiguration.java
  6. 71 0
      src/main/java/com/yihu/hos/rest/common/configuration/EhrUrlConfiguration.java
  7. 66 0
      src/main/java/com/yihu/hos/rest/common/configuration/MongoConfig.java
  8. 51 0
      src/main/java/com/yihu/hos/rest/common/configuration/QLCConfiguration.java
  9. 40 0
      src/main/java/com/yihu/hos/rest/common/dao/CrawlerDatasetDao.java
  10. 40 0
      src/main/java/com/yihu/hos/rest/common/dao/CrawlerFlowDao.java
  11. 32 0
      src/main/java/com/yihu/hos/rest/common/dao/CrawlerFlowHeadDao.java
  12. 250 0
      src/main/java/com/yihu/hos/rest/common/dao/DatacollectDao.java
  13. 34 0
      src/main/java/com/yihu/hos/rest/common/dao/DatacollectLogDao.java
  14. 15 0
      src/main/java/com/yihu/hos/rest/common/filter/HibernateFilter.java
  15. 56 0
      src/main/java/com/yihu/hos/rest/common/format/AdapterBase.java
  16. 72 0
      src/main/java/com/yihu/hos/rest/common/format/AdapterScheme.java
  17. 353 0
      src/main/java/com/yihu/hos/rest/common/format/DataSetTransformer.java
  18. 51 0
      src/main/java/com/yihu/hos/rest/common/format/DocumentTransformer.java
  19. 27 0
      src/main/java/com/yihu/hos/rest/common/format/IDataTransformer.java
  20. 21 0
      src/main/java/com/yihu/hos/rest/common/format/StdBase.java
  21. 194 0
      src/main/java/com/yihu/hos/rest/common/http/EHRHttpHelper.java
  22. 393 0
      src/main/java/com/yihu/hos/rest/controllers/CrawlerController.java
  23. 95 0
      src/main/java/com/yihu/hos/rest/controllers/DataCollectController.java
  24. 38 0
      src/main/java/com/yihu/hos/rest/controllers/DataPushController.java
  25. 33 0
      src/main/java/com/yihu/hos/rest/controllers/ErrorHandleController.java
  26. 32 0
      src/main/java/com/yihu/hos/rest/controllers/MetricController.java
  27. 502 0
      src/main/java/com/yihu/hos/rest/controllers/QLCController.java
  28. 111 0
      src/main/java/com/yihu/hos/rest/models/crawler/adapter/AdapterDataSet.java
  29. 54 0
      src/main/java/com/yihu/hos/rest/models/crawler/adapter/AdapterDict.java
  30. 14 0
      src/main/java/com/yihu/hos/rest/models/crawler/adapter/AdapterDictEntry.java
  31. 60 0
      src/main/java/com/yihu/hos/rest/models/crawler/adapter/AdapterMetaData.java
  32. 90 0
      src/main/java/com/yihu/hos/rest/models/crawler/adapter/StdDataSet.java
  33. 207 0
      src/main/java/com/yihu/hos/rest/models/crawler/config/SysConfig.java
  34. 66 0
      src/main/java/com/yihu/hos/rest/models/crawler/flow/CrawlerDataSetKey.java
  35. 75 0
      src/main/java/com/yihu/hos/rest/models/crawler/flow/CrawlerDataSetModel.java
  36. 65 0
      src/main/java/com/yihu/hos/rest/models/crawler/flow/CrawlerFlowHeadKey.java
  37. 65 0
      src/main/java/com/yihu/hos/rest/models/crawler/flow/CrawlerFlowHeadModel.java
  38. 109 0
      src/main/java/com/yihu/hos/rest/models/crawler/flow/CrawlerFlowModel.java
  39. 20 0
      src/main/java/com/yihu/hos/rest/models/crawler/flow/resultModel/CrawlerDatasetResultDetailModel.java
  40. 22 0
      src/main/java/com/yihu/hos/rest/models/crawler/flow/resultModel/CrawlerDatasetResultModel.java
  41. 30 0
      src/main/java/com/yihu/hos/rest/models/crawler/flow/resultModel/FlowEntrance.java
  42. 48 0
      src/main/java/com/yihu/hos/rest/models/crawler/flow/resultModel/FlowLines.java
  43. 40 0
      src/main/java/com/yihu/hos/rest/models/crawler/flow/resultModel/FlowMapping.java
  44. 47 0
      src/main/java/com/yihu/hos/rest/models/crawler/flow/resultModel/MappingDataset.java
  45. 36 0
      src/main/java/com/yihu/hos/rest/models/crawler/flow/resultModel/MappingMetadata.java
  46. 112 0
      src/main/java/com/yihu/hos/rest/models/crawler/patient/Patient.java
  47. 59 0
      src/main/java/com/yihu/hos/rest/models/crawler/patient/PatientIdentity.java
  48. 110 0
      src/main/java/com/yihu/hos/rest/models/crawler/patient/PatientIndex.java
  49. 138 0
      src/main/java/com/yihu/hos/rest/models/crawler/qc/QcDaily.java
  50. 42 0
      src/main/java/com/yihu/hos/rest/models/crawler/qc/QcPatientIndex.java
  51. 120 0
      src/main/java/com/yihu/hos/rest/models/crawler/qc/QcRuleModel.java
  52. 9 0
      src/main/java/com/yihu/hos/rest/models/crawler/transform/DictDataType.java
  53. 65 0
      src/main/java/com/yihu/hos/rest/models/crawler/transform/EhrCondition.java
  54. 15 0
      src/main/java/com/yihu/hos/rest/models/crawler/transform/IVerifier.java
  55. 12 0
      src/main/java/com/yihu/hos/rest/models/crawler/transform/LogicValues.java
  56. 45 0
      src/main/java/com/yihu/hos/rest/models/crawler/transform/MetaDataType.java
  57. 21 0
      src/main/java/com/yihu/hos/rest/models/crawler/transform/TransformType.java
  58. 35 0
      src/main/java/com/yihu/hos/rest/models/qlc/QLCPushReturnModel.java
  59. 37 0
      src/main/java/com/yihu/hos/rest/models/qlc/QLCResponseResult.java
  60. 46 0
      src/main/java/com/yihu/hos/rest/models/rs/DtoDatasetCol.java
  61. 48 0
      src/main/java/com/yihu/hos/rest/models/rs/DtoDictCol.java
  62. 35 0
      src/main/java/com/yihu/hos/rest/models/rs/DtoJobConfig.java
  63. 74 0
      src/main/java/com/yihu/hos/rest/models/rs/DtoJobDataset.java
  64. 36 0
      src/main/java/com/yihu/hos/rest/models/rs/DtoJobLog.java
  65. 75 0
      src/main/java/com/yihu/hos/rest/models/rs/RsDatapushLog.java
  66. 211 0
      src/main/java/com/yihu/hos/rest/models/rs/RsJobConfig.java
  67. 142 0
      src/main/java/com/yihu/hos/rest/models/rs/RsJobDataset.java
  68. 106 0
      src/main/java/com/yihu/hos/rest/models/rs/RsJobLog.java
  69. 234 0
      src/main/java/com/yihu/hos/rest/models/rs/RsJobLogDetail.java
  70. 106 0
      src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterDatasetModel.java
  71. 68 0
      src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterDatasetRelationModel.java
  72. 138 0
      src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterDictEntryModel.java
  73. 106 0
      src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterDictModel.java
  74. 158 0
      src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterMetadataModel.java
  75. 52 0
      src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterSchemeDispatchModel.java
  76. 151 0
      src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterSchemeModel.java
  77. 120 0
      src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterSchemeVersionModel.java
  78. 124 0
      src/main/java/com/yihu/hos/rest/models/standard/adapter/resultModel/AdapterDictEntryResultDetailModel.java
  79. 133 0
      src/main/java/com/yihu/hos/rest/models/standard/adapter/resultModel/AdapterMetadataResultDetailModel.java
  80. 154 0
      src/main/java/com/yihu/hos/rest/models/standard/adapter/resultModel/AdapterSchemeResultDetailModel.java
  81. 43 0
      src/main/java/com/yihu/hos/rest/models/standard/adapter/resultModel/AdapterSchemeResultModel.java
  82. 105 0
      src/main/java/com/yihu/hos/rest/models/standard/adapter/resultModel/AdapterSchemeVersionResultDetailModel.java
  83. 151 0
      src/main/java/com/yihu/hos/rest/models/standard/adapter/resultModel/ApiMetadataResultDetailModel.java
  84. 51 0
      src/main/java/com/yihu/hos/rest/models/standard/bo/AdapterVersion.java
  85. 184 0
      src/main/java/com/yihu/hos/rest/models/standard/bo/ObjectVersion.java
  86. 58 0
      src/main/java/com/yihu/hos/rest/models/standard/bo/StandardVersion.java
  87. 82 0
      src/main/java/com/yihu/hos/rest/models/standard/bo/SystemParam.java
  88. 147 0
      src/main/java/com/yihu/hos/rest/models/standard/standard/STDVersion.java
  89. 134 0
      src/main/java/com/yihu/hos/rest/models/standard/standard/StandardModel.java
  90. 201 0
      src/main/java/com/yihu/hos/rest/models/standard/standard/StdDataSetModel.java
  91. 122 0
      src/main/java/com/yihu/hos/rest/models/standard/standard/StdDictionaryEntryModel.java
  92. 176 0
      src/main/java/com/yihu/hos/rest/models/standard/standard/StdDictionaryModel.java
  93. 264 0
      src/main/java/com/yihu/hos/rest/models/standard/standard/StdMetaDataModel.java
  94. 27 0
      src/main/java/com/yihu/hos/rest/models/standard/standard/resultModel/StandardParamResultModel.java
  95. 78 0
      src/main/java/com/yihu/hos/rest/models/standard/standard/resultModel/StandardResultDetailModel.java
  96. 204 0
      src/main/java/com/yihu/hos/rest/services/crawler/CollectHelper.java
  97. 347 0
      src/main/java/com/yihu/hos/rest/services/crawler/CrawlerFlowManager.java
  98. 514 0
      src/main/java/com/yihu/hos/rest/services/crawler/CrawlerManager.java
  99. 663 0
      src/main/java/com/yihu/hos/rest/services/crawler/CrawlerService.java
  100. 0 0
      src/main/java/com/yihu/hos/rest/services/crawler/DataCollectDispatcher.java

+ 6 - 0
.gitignore

@ -9,6 +9,12 @@
*.war
*.ear
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

+ 138 - 0
pom.xml

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.yihu.hos</groupId>
        <artifactId>ehr-eip</artifactId>
        <version>1.3.0</version>
        <relativePath>../../pom.xml</relativePath><!-- lookup parent from repository -->
    </parent>
    <artifactId>hos-rest</artifactId>
    <version>1.3.0</version>
    <packaging>jar</packaging>
    <name>hos-rest</name>
    <description>ESB业务服务模块,实现ESB基础业务逻辑</description>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-activemq</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
        </dependency>
        <!-- test start -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- test end -->
        <dependency>
            <groupId>com.yihu.hos</groupId>
            <artifactId>hos-web-framework</artifactId>
            <version>${hos-version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-data-jpa</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.core</groupId>
            <artifactId>api-dict</artifactId>
            <version>1.6.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.core</groupId>
            <artifactId>core-rpc</artifactId>
            <version>2.2.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.core</groupId>
            <artifactId>api-config</artifactId>
            <version>2.2.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.core</groupId>
            <artifactId>core-db</artifactId>
            <version>1.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.0.12.Final</version>
        </dependency>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.core</groupId>
            <artifactId>ehr-dbhelper</artifactId>
            <version>1.1.9</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.core</groupId>
            <artifactId>html2image</artifactId>
            <version>0.9</version>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-pool</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot-version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>com.yihu.hos.rest.HosRestApplication</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

+ 12 - 0
src/main/java/com/yihu/hos/rest/HosRestApplication.java

@ -0,0 +1,12 @@
package com.yihu.hos.rest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class HosRestApplication {
	public static void main(String[] args) {
		SpringApplication.run(HosRestApplication.class, args);
	}
}

+ 129 - 0
src/main/java/com/yihu/hos/rest/common/configuration/BeanConfiguration.java

@ -0,0 +1,129 @@
package com.yihu.hos.rest.common.configuration;
import com.yihu.hos.rest.common.filter.HibernateFilter;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.orm.hibernate5.HibernateTransactionManager;
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Locale;
import java.util.Properties;
/**
 *  数据源自定义配置
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/8/5.
 */
@Configuration
@EnableTransactionManagement(proxyTargetClass = true)
@ComponentScan("com.yihu.hos.rest")
public class BeanConfiguration {
    @Autowired
    private DataSource dataSource;
    @Bean
    public HibernateFilter filterConfig() {
        return new HibernateFilter();
    }
    @Bean
    public LocalSessionFactoryBean sessionFactory() {
        LocalSessionFactoryBean localSessionFactoryBean = new LocalSessionFactoryBean();
        localSessionFactoryBean.setDataSource(this.dataSource);
        Properties properties1 = new Properties();
        properties1.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
        properties1.setProperty("hibernate.show_sql", "false");
        properties1.setProperty("hibernate.format_sql", "true");
        localSessionFactoryBean.setHibernateProperties(properties1);
        localSessionFactoryBean.setPackagesToScan("com.yihu.hos.rest.models");
        return localSessionFactoryBean;
    }
    //txManager事务开启
    @Bean
    public HibernateTransactionManager txManager() throws SQLException {
        HibernateTransactionManager hibernateTransactionManager = new HibernateTransactionManager();
        LocalSessionFactoryBean sessionFactoryBean = this.sessionFactory();
        hibernateTransactionManager.setSessionFactory(sessionFactoryBean.getObject());
        return hibernateTransactionManager;
    }
    //文经上传
    @Bean
    public CommonsMultipartResolver multipartResolver() {
        return new CommonsMultipartResolver();
    }
    //国际化配置
    @Bean
    public ResourceBundleMessageSource messageSource() {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        messageSource.setBasenames("text/message");
        messageSource.setDefaultEncoding("UTF-8");
        return messageSource;
    }
    @Bean
    public CookieLocaleResolver localeResolver() {
        CookieLocaleResolver localeResolver = new CookieLocaleResolver();
        localeResolver.setCookieName("Language");
        localeResolver.setCookieMaxAge(604800);
        localeResolver.setDefaultLocale(new Locale("zh_cn"));
        return localeResolver;
    }
    @Bean
    public LocaleChangeInterceptor localeChangeInterceptor() {
        return new LocaleChangeInterceptor();
    }
    @Bean
    public JdbcTemplate jdbcTemplate() {
        JdbcTemplate jdbcTemplate = new JdbcTemplate();
        try {
            jdbcTemplate.setDataSource(this.dataSource);
            jdbcTemplate.setLazyInit(false);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return jdbcTemplate;
    }
    //Hibernate模版配置
    @Bean
    public HibernateTemplate hibernateTemplate() throws SQLException {
        HibernateTemplate hibernateTemplate = new HibernateTemplate();
        LocalSessionFactoryBean sessionFactory = this.sessionFactory();
        hibernateTemplate.setSessionFactory(sessionFactory.getObject());
        return hibernateTemplate;
    }
    @Override
    protected void finalize() throws Throwable {
        super.finalize();
    }
}

+ 71 - 0
src/main/java/com/yihu/hos/rest/common/configuration/CrawlerConfiguration.java

@ -0,0 +1,71 @@
package com.yihu.hos.rest.common.configuration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
/**
 * @created Airhead 2016/8/4.
 */
@Configuration
public class CrawlerConfiguration {
    @Value("${crawler.upload.ip}")
    private String uploadIp;
    @Value("${crawler.upload.port}")
    private String uploadPort;
    @Value("${crawler.upload.api}")
    private String uploadApi;
    @Value("${crawler.storage.ip}")
    private String storageIp;
    @Value("${crawler.storage.port}")
    private String storagePort;
    @Value("${crawler.storage.api}")
    private String storageApi;
    public String getUploadIp() {
        return uploadIp;
    }
    public void setUploadIp(String uploadIp) {
        this.uploadIp = uploadIp;
    }
    public String getUploadPort() {
        return uploadPort;
    }
    public void setUploadPort(String uploadPort) {
        this.uploadPort = uploadPort;
    }
    public String getUploadApi() {
        return uploadApi;
    }
    public void setUploadApi(String uploadApi) {
        this.uploadApi = uploadApi;
    }
    public String getStorageIp() {
        return storageIp;
    }
    public void setStorageIp(String storageIp) {
        this.storageIp = storageIp;
    }
    public String getStoragePort() {
        return storagePort;
    }
    public void setStoragePort(String storagePort) {
        this.storagePort = storagePort;
    }
    public String getStorageApi() {
        return storageApi;
    }
    public void setStorageApi(String storageApi) {
        this.storageApi = storageApi;
    }
}

+ 71 - 0
src/main/java/com/yihu/hos/rest/common/configuration/EhrUrlConfiguration.java

@ -0,0 +1,71 @@
package com.yihu.hos.rest.common.configuration;
import com.yihu.hos.rest.common.http.EHRHttpHelper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
/**
 *  EHR连接地址配置
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/7/31.
 */
@Configuration
public class EhrUrlConfiguration {
    @Value("${service-gateway.ehrMgrUrl}")
    private String ehrMgrUrl;
    @Value("${service-gateway.ehrCouldUrl}")
    private String ehrCouldUrl;
    @Value("${service-gateway.ehrAdminUrl}")
    private String ehrAdminUrl;
    @Value("${service-gateway.sslKeystore}")
    private String sslKeystore;
    @Value("${service-gateway.sslPassword}")
    private String sslPassword;
    @Value("${service-gateway.clientId}")
    private String clientId;
    @Value("${service-gateway.clientKey}")
    private String clientKey;
    private static EhrUrlConfiguration configuration;
    @PostConstruct
    public void initValue(){
        configuration = this;
        EHRHttpHelper.initConfig(configuration);
    }
    public String getEhrMgrUrl() {
        return ehrMgrUrl;
    }
    public String getEhrCouldUrl() {
        return ehrCouldUrl;
    }
    public String getEhrAdminUrl() {
        return ehrAdminUrl;
    }
    public String getSslKeystore() {
        return sslKeystore;
    }
    public String getSslPassword() {
        return sslPassword;
    }
    public String getClientId() {
        return clientId;
    }
    public String getClientKey() {
        return clientKey;
    }
}

+ 66 - 0
src/main/java/com/yihu/hos/rest/common/configuration/MongoConfig.java

@ -0,0 +1,66 @@
package com.yihu.hos.rest.common.configuration;
import com.mongodb.Mongo;
import com.mongodb.MongoClient;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
import static java.util.Collections.singletonList;
/**
 * @created Airhead 2016/7/27.
 */
@Configuration
public class MongoConfig extends AbstractMongoConfiguration {
    @Value("${spring.data.mongodb.host}")
    private String host;
    @Value("${spring.data.mongodb.port}")
    private int port;
    @Value("${spring.data.mongodb.username}")
    private String username;
    @Value("${spring.data.mongodb.password}")
    private String password;
    @Value("${spring.data.mongodb.authenticationDatabase}")
    private String authenticationDatabase;
    @Value("${spring.data.mongodb.database}")
    private String database;
    @Override
    public String getDatabaseName() {
        return database;
    }
    @Bean
    public MongoClient mongoClient() throws Exception {
        return new MongoClient(singletonList(new ServerAddress(host, port)),
                singletonList(MongoCredential.createCredential(username, authenticationDatabase, password.toCharArray())));
    }
    @Bean
    public Mongo mongo() throws Exception {
        return new MongoClient(singletonList(new ServerAddress(host, port)),
                singletonList(MongoCredential.createCredential(username, authenticationDatabase, password.toCharArray())));
    }
    public String getHost() {
        return host;
    }
    public int getPort() {
        return port;
    }
    public String getUsername() {
        return username;
    }
    public String getPassword() {
        return password;
    }
}

+ 51 - 0
src/main/java/com/yihu/hos/rest/common/configuration/QLCConfiguration.java

@ -0,0 +1,51 @@
package com.yihu.hos.rest.common.configuration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
/**
 * @created Airhead 2016/8/4.
 */
@Configuration
public class QLCConfiguration {
    @Value("${qlc.rpc.ip}")
    private String ip;
    @Value("${qlc.rpc.port}")
    private String port;
    @Value("${qlc.rpc.appId}")
    private String appId;
    @Value("${qlc.rpc.channelId}")
    private String channelId;
    public String getIp() {
        return ip;
    }
    public void setIp(String ip) {
        this.ip = ip;
    }
    public String getPort() {
        return port;
    }
    public void setPort(String port) {
        this.port = port;
    }
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    public String getChannelId() {
        return channelId;
    }
    public void setChannelId(String channelId) {
        this.channelId = channelId;
    }
}

+ 40 - 0
src/main/java/com/yihu/hos/rest/common/dao/CrawlerDatasetDao.java

@ -0,0 +1,40 @@
package com.yihu.hos.rest.common.dao;
import com.yihu.hos.rest.models.crawler.flow.CrawlerDataSetModel;
import com.yihu.hos.web.framework.dao.SQLGeneralDAO;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import java.math.BigInteger;
import java.util.List;
/**
 * Created by HZY on 2016/4/27.
 */
@Repository("CrawlerDatasetDao")
public class CrawlerDatasetDao extends SQLGeneralDAO {
    public static final String BEAN_ID = "CrawlerDatasetDao";
    public List<CrawlerDataSetModel> getCrawlerDatasetList(Long versionId) throws Exception {
        String sql = "select * from crawler_dataset where scheme_version_id='" + versionId + "'";
        return super.queryListBySql(sql, CrawlerDataSetModel.class);
    }
    public void deleteCrawlerDatasetList(Long versionId) throws Exception {
        String sql = "delete from crawler_dataset where scheme_version_id= :scheme_version_id";
        Query query = getCurrentSession().createSQLQuery(sql);
        query.setLong("scheme_version_id", versionId);
        query.executeUpdate();
    }
    public Integer getTotalRows() throws Exception {
        String countSql = "SELECT COUNT(*) FROM (SELECT a.scheme_id, a.scheme_version_id, GROUP_CONCAT(a.dataset_id SEPARATOR ',') AS datasetId, GROUP_CONCAT(a.dataset_name SEPARATOR ',') AS datasetName" +
                "  FROM crawler_dataset a " +
                "  GROUP BY a.scheme_id, a.scheme_version_id ) b WHERE 1= 1";
        Query query = getCurrentSession().createSQLQuery(countSql);
        List<BigInteger> list = query.list();
        int count = list.get(0).intValue();
        return count;
    }
}

+ 40 - 0
src/main/java/com/yihu/hos/rest/common/dao/CrawlerFlowDao.java

@ -0,0 +1,40 @@
package com.yihu.hos.rest.common.dao;
import com.yihu.hos.rest.models.crawler.flow.CrawlerFlowModel;
import com.yihu.hos.web.framework.dao.SQLGeneralDAO;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
 * Created by HZY on 2016/4/27.
 */
@Repository("CrawlerFlowDao")
public class CrawlerFlowDao extends SQLGeneralDAO {
    public static final String BEAN_ID = "CrawlerFlowDao";
    public List<CrawlerFlowModel> getCrawlerFlowList(Long versionId) {
        String adapterVersionHql = "FROM CrawlerFlowModel where schemeVersionId= :schemeVersionId";
        Query query = getCurrentSession().createQuery(adapterVersionHql);
        query.setParameter("schemeVersionId", versionId);
        List<CrawlerFlowModel> modelList = query.list();
        return modelList;
    }
    public void deleteCrawlerFlowList(Long versionId)throws Exception  {
        String sql = "delete from crawler_flow where scheme_version_id='"+versionId+"'";
        super.execute(sql);
    }
    public List<CrawlerFlowModel> getCrawlerFlowList(Integer versionId,List<String> datasetCodes) {
        String adapterVersionHql = "FROM CrawlerFlowModel where schemeVersionId= :schemeVersionId and datasetCode in (:datasetCode) and inputDatasetCode in (:inputDatasetCode)";
        Query query = getCurrentSession().createQuery(adapterVersionHql);
        query.setParameter("schemeVersionId", versionId);
        query.setParameterList("datasetCode", datasetCodes);
        query.setParameterList("inputDatasetCode", datasetCodes);
        List<CrawlerFlowModel> modelList = query.list();
        return modelList;
    }
}

+ 32 - 0
src/main/java/com/yihu/hos/rest/common/dao/CrawlerFlowHeadDao.java

@ -0,0 +1,32 @@
package com.yihu.hos.rest.common.dao;
import com.yihu.hos.rest.models.crawler.flow.CrawlerFlowHeadModel;
import com.yihu.hos.web.framework.dao.SQLGeneralDAO;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
 * Created by HZY on 2016/4/27.
 */
@Repository("CrawlerFlowHeadDao")
public class CrawlerFlowHeadDao extends SQLGeneralDAO {
    public static final String BEAN_ID = "CrawlerFlowHeadDao";
    public void deleteCrawlerFlowHeadList(Long versionId) throws Exception {
        String sql = "delete from crawler_flow_head where scheme_version_id= :scheme_version_id";
        Query query = getCurrentSession().createSQLQuery(sql);
        query.setLong("scheme_version_id", versionId);
        query.executeUpdate();
    }
    public List<CrawlerFlowHeadModel> getCrawlerFlowHeadList(Long versionId) {
        String sql = "FROM CrawlerFlowHeadModel where schemeVersionId= :schemeVersionId";
        Query query = getCurrentSession().createQuery(sql);
        query.setParameter("schemeVersionId", versionId);
        List<CrawlerFlowHeadModel> modelList = query.list();
        return modelList;
    }
}

+ 250 - 0
src/main/java/com/yihu/hos/rest/common/dao/DatacollectDao.java

@ -0,0 +1,250 @@
package com.yihu.hos.rest.common.dao;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.rest.models.rs.DtoJobDataset;
import com.yihu.hos.rest.models.rs.RsJobDataset;
import com.yihu.hos.web.framework.constant.DateConvert;
import com.yihu.hos.web.framework.dao.SQLGeneralDAO;
import com.yihu.hos.web.framework.model.DataGridResult;
import com.yihu.hos.web.framework.model.SimpleChartItem;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Map;
/**
 * Created by hzp on 2016/1/11.
 */
@Repository("DatacollectDao")
public class DatacollectDao extends SQLGeneralDAO {
    /**
     * 通过机构代码获取版本号
     */
    public String getVersionByQLC(String orgCode) throws Exception
    {
        try{
            String sql = "select version from adapter_scheme_version v "+
                         " left join system_organization o on o.qlc_adapter_version=v.id "+
                         " where o.qlc_org_code ='"+orgCode+"'";
            return super.scalarBySql(sql, String.class);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return "";
        }
    }
    /**
     * 根据JobId获取Cron表达式
     */
    public String getCronByJobId(String jobId)
    {
        try{
            String sql = "select CRON_EXPRESSION from qrtz_cron_triggers where TRIGGER_NAME='"+jobId+"'";
            return super.scalarBySql(sql, String.class);
        }
        catch (Exception e)
        {
            return "";
        }
    }
    /**
     * 获取任务列表
     * @return
     */
    public DataGridResult getJobList(Map<String, Object> conditionMap, Integer page, Integer pageSize) throws Exception
    {
        StringBuilder sb = new StringBuilder();
        sb.append("from RsJobConfig t where 1=1 and valid=1 ");
        if (!StringUtil.isEmpty(conditionMap.get("jobName")))
        {
            sb.append(" and t.jobName like '%" + conditionMap.get("jobName") + "%'");
        }
        return getDataGridResult(sb.toString(),page,pageSize);
    }
    /**
     * 获取任务数据集
     * @return
     * @throws Exception
     */
    public List<RsJobDataset> getJobDataset(String jobId) throws Exception
    {
        String sql = "select * from rs_job_dataset where job_id='"+jobId+"'";
        return super.queryListBySql(sql, RsJobDataset.class);
    }
    /**
     * 获取版本名称
     */
    public String getSchemeAndVersion(String schemeVersionId) throws Exception
    {
        String sql = "select IFNULL( (select  CONCAT_WS(' -- ',s.name,v.name)  from adapter_scheme_version v " +
                "left join adapter_scheme s on s.id = v.scheme_id " +
                "where v.version='"+schemeVersionId+"'),'')";
        return super.scalarBySql(sql, String.class);
    }
    /**
     * 修改任务状态
     */
    public void validJob(String id,String valid) throws Exception
    {
        String sql = "update rs_job_config set valid='"+valid+"' where Id='"+id+"'";
        super.execute(sql);
    }
    /**
     * 删除任务关联数据集
     */
    public void deleteJobDatasetByJobId(String jobId) throws Exception
    {
        List<RsJobDataset> list = super.queryListBySql("select * from rs_job_dataset where job_id='"+jobId+"'",RsJobDataset.class);
        //判断是否存在数据
        if(list!=null && list.size()>0)
        {
            for(RsJobDataset obj :list)
            {
                super.deleteEntity(obj);
            }
        }
    }
    /**
     * 获取任务详细日志列表
     */
    public DataGridResult getJobLogDetail(Map<String, Object> conditionMap, Integer page, Integer pageSize) throws Exception
    {
        StringBuilder sb = new StringBuilder();
        sb.append("from RsJobLogDetail where 1=1 ");
        if (!StringUtil.isEmpty(conditionMap.get("jobId"))) {
            sb.append(" and job_id ='"+conditionMap.get("jobId")+"'");
        }
        if (!StringUtil.isEmpty(conditionMap.get("jobDatasetId"))) {
            sb.append(" and job_dataset_id ='"+conditionMap.get("jobDatasetId")+"'");
        }
        if (!StringUtil.isEmpty(conditionMap.get("jobStatus"))) {
            sb.append(" and jobStatus ='"+conditionMap.get("jobStatus")+"'");
        }
        if (!StringUtil.isEmpty(conditionMap.get("jobTimeFrom"))) {
            Date time = DateConvert.toDate(conditionMap.get("jobTimeFrom").toString());
            time.setHours(0);
            time.setMinutes(0);
            time.setSeconds(0);
            sb.append(" and startTime >= '"+DateConvert.toString(time)+"'");
        }
        if (!StringUtil.isEmpty(conditionMap.get("jobTimeTo"))) {
            Date time = DateConvert.toDate(conditionMap.get("jobTimeTo").toString());
            time.setHours(0);
            time.setMinutes(0);
            time.setSeconds(0);
            GregorianCalendar gc=new GregorianCalendar();
            gc.setTime(time);
            gc.add(5, 1);
            sb.append(" and startTime < '"+DateConvert.toString(gc.getTime())+"'");
        }
        sb.append("order by startTime desc");
        return getDataGridResult(sb.toString(),page,pageSize);
    }
    /**
     * 获取任务日志列表
     */
    public DataGridResult getJobLog(Map<String, Object> conditionMap, Integer page, Integer pageSize) throws Exception
    {
        StringBuilder sb = new StringBuilder();
        sb.append("from RsJobLog where 1=1 ");
        if (!StringUtil.isEmpty(conditionMap.get("jobId"))) {
            sb.append(" and jobId ='"+conditionMap.get("jobId")+"'");
        }
        sb.append("order by jobStartTime desc");
        return getDataGridResult(sb.toString(),page,pageSize);
    }
    /**
     * 获取采集日志统计
     */
    public List<Map<String, Object>> getJobLogCount(String logId) throws Exception
    {
        String sql ="select d.job_log_id,sum(d.Job_dataset_rows) as count,\n" +
                "sum(case d.job_status\n" +
                "    when '1' THEN\n" +
                "         d.Job_dataset_rows\n" +
                "    ELSE\n" +
                "         0\n" +
                "    END) as success,\n" +
                "sum(case d.job_status\n" +
                "    when '3' THEN\n" +
                "         d.Job_dataset_rows\n" +
                "    ELSE\n" +
                "         0\n" +
                "    END) as repeat_num\n" +
                "from rs_job_log_detail d\n";
        if(logId!=null && logId.length()>0)
        {
            sql += "where d.job_log_id ='"+logId+"'\n";
        }
        sql+="group by d.job_log_id ";
        return super.queryListBySql(sql);
    }
    /**
     * 任务详细根据数据集分组
     */
    public List<SimpleChartItem> getJobLogDataset(String logId) throws Exception
    {
        String sql ="select d.job_dataset_name as x,sum(d.Job_dataset_rows) as y1,\n" +
                "                sum(case d.job_status\n" +
                "                    when '1' THEN\n" +
                "                         d.Job_dataset_rows\n" +
                "                    ELSE\n" +
                "                         0\n" +
                "                    END) as y2,\n" +
                "                sum(case d.job_status\n" +
                "                    when '3' THEN\n" +
                "                         d.Job_dataset_rows\n" +
                "                    ELSE\n" +
                "                         0\n" +
                "                    END) as y3\n" +
                "                from rs_job_log_detail d\n" +
                "where d.job_log_id = '"+logId+"'\n" +
                "GROUP BY d.Job_dataset_name";
        return super.queryListBySql(sql,SimpleChartItem.class);
    }
    /**
     * 通过任务ID获取相关数据集
     */
    public List<DtoJobDataset> getDatacollectDataset(String jobId) throws Exception
    {
        //通过jobId获取机构版本号
        String sqlVersion ="select a.adapter_std_version\n" +
                "from rs_job_config c,(SELECT s.adapter_std_version,v.version from adapter_scheme s,adapter_scheme_version v where s.id=v.scheme_id) a\n" +
                "where a.version = c.scheme_version\n" +
                "and c.id='"+jobId+"'";
        String version = super.scalarBySql(sqlVersion,String.class);
        String sql = "select d.*,\n" +
                "t.datasource_id,t.datasource_name,t.config,t.type,t.org_code\n" +
                "from rs_job_dataset d\n" +
                "LEFT JOIN (select s.dataset_id,s.datasource_id,ss.name as datasource_name,ss.config,ss.type,ss.org_code \n" +
                "\tfrom rs_datasource_dataset s,(select ds.id,ds.name,ds.config,ds.type,o.code as org_code from system_datasource ds,system_organization o where ds.org_id=o.id) ss where s.datasource_id=ss.id and s.Std_version='"+version+"') t \n" +
                "on d.job_dataset_id = t.dataset_id \n" +
                "where d.job_id='"+jobId+"'\n" +
                "order by d.sort";
        return super.queryListBySql(sql,DtoJobDataset.class);
    }
}

+ 34 - 0
src/main/java/com/yihu/hos/rest/common/dao/DatacollectLogDao.java

@ -0,0 +1,34 @@
package com.yihu.hos.rest.common.dao;
import com.yihu.hos.rest.models.rs.RsDatapushLog;
import com.yihu.hos.web.framework.dao.SQLGeneralDAO;
import org.springframework.stereotype.Repository;
import java.util.Date;
/**
 * Created by hzp on 2016/1/11.
 */
@Repository("DatacollectLogDao")
public class DatacollectLogDao extends SQLGeneralDAO {
    /******************************** 推模式日志 ***************************************/
    /**
     * 推数据新增日志
     */
    public void addDataPushLog(String type,String success,String content) throws Exception {
        RsDatapushLog log = new RsDatapushLog();
        log.setType(type);
        log.setSuccess(success);
        log.setContent(content);
        log.setDatetime(new Date());
        this.saveEntity(log);
    }
    public void updateJobDatasetKeyvalue(String id,String jobDatasetKeyvalue) throws Exception {
        String sql = "update rs_job_dataset set job_dataset_keyvalue='"+jobDatasetKeyvalue+"' where id='"+id+"'";
        super.execute(sql);
    }
}

+ 15 - 0
src/main/java/com/yihu/hos/rest/common/filter/HibernateFilter.java

@ -0,0 +1,15 @@
package com.yihu.hos.rest.common.filter;
import org.springframework.orm.hibernate5.support.OpenSessionInViewFilter;
import javax.servlet.annotation.WebFilter;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/8/12.
 */
@WebFilter(filterName="SpringOpenSessionInViewFilter",urlPatterns="/*")
public class HibernateFilter extends OpenSessionInViewFilter {
}

+ 56 - 0
src/main/java/com/yihu/hos/rest/common/format/AdapterBase.java

@ -0,0 +1,56 @@
package com.yihu.hos.rest.common.format;
import com.yihu.hos.rest.models.standard.adapter.AdapterSchemeVersionModel;
import com.yihu.hos.rest.models.standard.bo.AdapterVersion;
import com.yihu.hos.rest.services.standard.adapter.AdapterDictService;
import com.yihu.hos.rest.services.standard.adapter.AdapterMetadataService;
import com.yihu.hos.rest.services.standard.adapter.AdapterSchemeVersionService;
/**
 * 适配器基类,DAO缓存
 *
 * @created Created by Air on 2015/6/10.
 */
public class AdapterBase {
    private static AdapterSchemeVersionService adapterSchemeVersionService;
    private static AdapterMetadataService adapterMetadataService;
    private static AdapterDictService adapterDictService;
    protected AdapterVersion adapterVersion;
    public AdapterVersion getAdapterVersion() {
        AdapterSchemeVersionModel adapterSchemeVersionModel = getAdapterSchemeVersionService().getEhrAdapterVersionLasted();
        if (adapterSchemeVersionModel == null) {
            adapterSchemeVersionModel=new AdapterSchemeVersionModel();
        }
        String version = adapterSchemeVersionModel.getVersion();
         adapterVersion = new AdapterVersion(version);
        return adapterVersion;
    }
    public static AdapterSchemeVersionService getAdapterSchemeVersionService() {
        return adapterSchemeVersionService;
    }
    public static void setAdapterSchemeVersionService(AdapterSchemeVersionService adapterSchemeVersionService) {
        AdapterBase.adapterSchemeVersionService = adapterSchemeVersionService;
    }
    public static AdapterMetadataService getAdapterMetadataService() {
        return adapterMetadataService;
    }
    public static void setAdapterMetadataService(AdapterMetadataService adapterMetadataService) {
        AdapterBase.adapterMetadataService = adapterMetadataService;
    }
    public static AdapterDictService getAdapterDictService() {
        return adapterDictService;
    }
    public static void setAdapterDictService(AdapterDictService adapterDictService) {
        AdapterBase.adapterDictService = adapterDictService;
    }
}

+ 72 - 0
src/main/java/com/yihu/hos/rest/common/format/AdapterScheme.java

@ -0,0 +1,72 @@
package com.yihu.hos.rest.common.format;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.rest.models.standard.adapter.AdapterDatasetModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterMetadataModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterSchemeVersionModel;
import com.yihu.hos.rest.models.standard.bo.AdapterVersion;
import com.yihu.hos.rest.services.standard.adapter.AdapterDatasetService;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 适配方案
 * 一个适配方案可能有一到多个机构要采集数据
 *
 * @created Created by Air on 2015/6/3.
 */
public class AdapterScheme  extends AdapterBase{
    @Resource(name = AdapterDatasetService.BEAN_ID)
    private AdapterDatasetService adapterDatasetService;
    private HashMap<String, List<AdapterMetadataModel>> adapterMetaDataMap;
    public AdapterScheme() {
    }
    public synchronized HashMap<String, List<AdapterMetadataModel>> getAdapterMetaDataMap() {
        if (adapterMetaDataMap ==null){
            AdapterSchemeVersionModel adapterSchemeVersionModel = getAdapterSchemeVersionService().getEhrAdapterVersionLasted();
            if (adapterSchemeVersionModel == null) {
                adapterSchemeVersionModel=new AdapterSchemeVersionModel();
            }
            String version = adapterSchemeVersionModel.getVersion();
            AdapterVersion adapterVersion = new AdapterVersion(version);
            adapterMetaDataMap =new HashMap<>();
            Map<String, String> condition = new HashMap<>();
            condition.put("column", "adapter_dataset_code");
            String conditionStr ="";
            ObjectMapper mapper = new ObjectMapper();
            try {
                conditionStr = mapper.writeValueAsString(condition);
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }
            List<AdapterDatasetModel> adapterDataSets = adapterDatasetService.getAdapterDatasetNotNullList(adapterVersion, conditionStr);
            for (AdapterDatasetModel adapterDataSet:adapterDataSets){
                List<AdapterMetadataModel> adapterMetaDataTList = getAdapterMetadataService().getAdapterMetadataByDataset(version, adapterDataSet.getId());
                if (adapterMetaDataTList!=null && adapterMetaDataTList.size()>0){
                    adapterMetaDataMap.put(adapterDataSet.getStdDatasetCode(), adapterMetaDataTList);
                }
            }
        }
        return adapterMetaDataMap;
    }
    public List<AdapterMetadataModel> getAdapterMetaDatas(String dataSetCode){
        if (dataSetCode==null){
            return new ArrayList<>();
        }
        return getAdapterMetaDataMap().get(dataSetCode);
    }
}

+ 353 - 0
src/main/java/com/yihu/hos/rest/common/format/DataSetTransformer.java

@ -0,0 +1,353 @@
package com.yihu.hos.rest.common.format;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
import com.yihu.hos.core.datatype.DateUtil;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.rest.controllers.DataCollectController;
import com.yihu.hos.rest.models.crawler.adapter.AdapterDataSet;
import com.yihu.hos.rest.models.crawler.adapter.AdapterDict;
import com.yihu.hos.rest.models.crawler.adapter.AdapterMetaData;
import com.yihu.hos.rest.models.crawler.adapter.StdDataSet;
import com.yihu.hos.rest.models.crawler.patient.Patient;
import com.yihu.hos.rest.models.crawler.transform.DictDataType;
import com.yihu.hos.rest.models.crawler.transform.TransformType;
import com.yihu.hos.rest.models.standard.standard.StdMetaDataModel;
import com.yihu.hos.web.framework.constant.QcResultConstant;
import com.yihu.hos.web.framework.constant.SqlConstants;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
 * 目前只处理json格式
 * <p>
 * json 格式
 * {
 * "inner_version":"xxxxx",
 * "patient_id":"xxxx",
 * "event_no":"xxxx",
 * "code":"dataset_code",
 * "org_code":"xxxx"
 * "data":
 * [{"metadata_code1":"5","metadata_code2":"6"},
 * [{"metadata_code1":"1","metadata_code2":"2"}]}
 * <p>
 * Created by Air on 2015/6/4.
 */
public class DataSetTransformer implements IDataTransformer {
    private JsonNode jsonObject;
    private Patient patient;
    private static DBHelper db;
    private JsonNode qcObject;
    private static Logger logger = LoggerFactory.getLogger(DataSetTransformer.class);
    public JsonNode getQcObject() {
        return qcObject;
    }
    public JsonNode getJsonObject() {
        return jsonObject;
    }
    public DataSetTransformer() {
        if (db == null) {
            db = new DBHelper();
        }
    }
    public boolean transfer(Map<String, AdapterDataSet> dataSetMap) {
        if (jsonObject != null) {
            String dataSetCode = jsonObject.get("code").asText();
            ArrayNode jsonArray = (ArrayNode) jsonObject.get("data");
            AdapterDataSet adapterDataSet = dataSetMap.get(dataSetCode);
            boolean transfer = transferJson(jsonArray, adapterDataSet);
            return transfer;
        }
        return false;
    }
    /**
     * 转换时间格式为utc、
     *
     * @param dataSetMap
     * @return
     */
    public boolean transferTimeFormat(Map<String, StdDataSet> dataSetMap) {
        if (jsonObject != null) {
            try {
                String dataSetCode = jsonObject.get("code").asText();
                ArrayNode jsonArray = (ArrayNode) jsonObject.get("data");
                StdDataSet stdDataSet = dataSetMap.get(dataSetCode);
                Map<Long, Map<String, StdMetaDataModel>> stdDataSetMetasMap = stdDataSet.getStdDataSetMetasMap();
                Map<String, StdMetaDataModel> stdMetaDataModelMap = stdDataSetMetasMap.get(stdDataSet.getStdDataSetId());
                for (Object objectRow : jsonArray) {
                    if (objectRow instanceof JsonNode) {
                        ObjectNode jsonObject = (ObjectNode) objectRow;
                        Iterator<Map.Entry<String, JsonNode>> fields = jsonObject.fields();
                        while (fields.hasNext()) {
                            Map.Entry<String, JsonNode> next = fields.next();
                            String key = next.getKey();
                            JsonNode jsonNode = next.getValue();
                            String value = jsonNode.asText();
                            String stdValue = transferElemTime(stdMetaDataModelMap, key, value);
                            if (stdValue==null){
                                stdValue="";
                            }
                            jsonObject.put(key, stdValue);
//                            if (jsonNode instanceof ObjectNode) {
//                                ObjectNode objectNode = (ObjectNode) next;
//                                objectNode.put(key, stdValue);
//                            }
                        }
                    }
                }
                return true;
            } catch (Exception e) {
                e.printStackTrace();
            }
            return false;
        }
        return false;
    }
    public String getData() {
        //确保文档有版本信息
        return jsonObject.asText();
    }
    public void setData(JsonNode data) {
        jsonObject = data;
        qcObject = data;
        setPatient();
    }
    @Override
    public Patient getPatient() {
        return patient;
    }
    public TransformType getTransformType() {
        return TransformType.DATA_SET_JSON;
    }
    /**
     * json 格式
     * {
     * "inner_version":"xxxxx",
     * "patient_id":"xxxx",
     * "event_no":"xxxx",
     * "code":"dataset_code",
     * "data":
     * [{"metadata_code1":"5","metadata_code2":"6"},
     * [{"metadata_code1":"1","metadata_code2":"2"}]}
     *
     * @param jsonArray
     * @param adapterDataSet
     * @return
     */
    public boolean transferJson(ArrayNode jsonArray, AdapterDataSet adapterDataSet) {
        for (Object objectRow : jsonArray) {
            if (objectRow instanceof JsonNode) {
                transferJsonRow((ObjectNode) objectRow, adapterDataSet);
            }
        }
        return false;
    }
    public void transferJsonRow(ObjectNode jsonObject, AdapterDataSet adapterDataSet) {
        Iterator<Map.Entry<String, JsonNode>> fields = jsonObject.fields();
        while (fields.hasNext()) {
            Map.Entry<String, JsonNode> next = fields.next();
            String key = next.getKey();
            JsonNode jsonNode = next.getValue();
            String value = jsonNode.asText();
            String stdValue = transferElem(adapterDataSet, key, value);
            jsonObject.put(key, stdValue);
//            if (jsonNode instanceof ObjectNode) {
//                ObjectNode objectNode = (ObjectNode) next;
//                objectNode.put(key, stdValue);
//            }
        }
    }
    /**
     * @param adapterDataSet 数据集编码
     * @param code           数据元编码
     * @param esbData        数据
     * @return String 标准值
     * @modify 2015.09.16 airhead 增加值与编码转换
     */
    public String transferElem(AdapterDataSet adapterDataSet, String code, String esbData) {
        Map<String, AdapterMetaData> adapterMetaDataMap = adapterDataSet.getAdapterMetaDataMap();
        AdapterMetaData adapterMetaData = adapterMetaDataMap.get(code);
        if (adapterMetaData==null){
            return esbData;
        }
        AdapterDict adapterDict = adapterMetaData.getAdapterDict();
        if (adapterDict == null) {
            return esbData;
        }
        String ehrData = null;
        DictDataType adapterDictDataType = adapterMetaData.getAdapterDictDataType();
        if (adapterDictDataType == DictDataType.VALUE) {
            ehrData = adapterDict.getAdapterValueToCodeMap().get(esbData) ==null? esbData: adapterDict.getAdapterValueToCodeMap().get(esbData);
        } else if (adapterDictDataType == DictDataType.CODE) {
            ehrData = adapterDict.getAdapterCodeToCodeMap().get(esbData) == null ? esbData : adapterDict.getAdapterCodeToCodeMap().get(esbData);
        }
        if (StringUtil.isEmpty(ehrData)) {
            return SqlConstants.EMPTY;
        }
        return ehrData;
    }
    public String transferElemTime(Map<String, StdMetaDataModel> stdMetaDataModelMap, String code, String esbData) {
        StdMetaDataModel stdMetaData = stdMetaDataModelMap.get(code);
        logger.info("原数据元key:"+code +",进入transferElemTime。。。。,数据元数量:"+stdMetaDataModelMap.keySet().size());
        if (stdMetaData == null ||stdMetaData.getColumnType() == null) {
            return esbData;
        }
        logger.info(esbData+" 时间转换开始11111111,数据元集合:"+ stdMetaDataModelMap.keySet().toArray().toString());
        String columnType = stdMetaData.getColumnType();
        logger.info(esbData+" 时间转换开始222222222"+ code);
        try{
            if ("DATE".equals(columnType) || "DATETIME".equals(columnType)) {
                //时间转换
                logger.info(esbData+" 时间转换开始"+ code);
                if (!StringUtil.isEmpty(esbData)){
                    logger.info(esbData+" 时间转换开始1111");
                    String utcDate = DateUtil.getUtcDate(esbData, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
                    logger.info(esbData+" 时间转换结束:"+utcDate);
                    return utcDate;
                }
            } else {
                return esbData;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return "";
    }
    /**
     * 根据DataSet信息构造Patient
     */
    private void setPatient() {
        patient = new Patient();
        patient.setPatientId(jsonObject.get("patient_id").asText());
        patient.setEventNo(jsonObject.get("event_no").asText());
        patient.setOrgCode(jsonObject.get("org_code").asText());
    }
    /* *************************** 以下为质控规则逻辑相关 **************************** add by hzy */
    public boolean genQcData(Map<String, AdapterDataSet> dataSetMap,String checkType) {
        if (jsonObject != null) {
            String dataSetCode = jsonObject.get("code").asText();
            ArrayNode jsonArray = (ArrayNode) jsonObject.get("data");
            AdapterDataSet adapterDataSet = dataSetMap.get(dataSetCode);
            //TODO 根据条件判断执行的规则
            switch (checkType){
                case  QcResultConstant.VALUE_EMPTY :checkDataIsNull(jsonArray,checkType);
                    break;
                case  QcResultConstant.VALUE_ERROR :checkDataTransfer(jsonArray, adapterDataSet, checkType);
                    break;
                default:
                    break;
            }
            return true;
        }
        return false;
    }
    //检测医院数据为空
    public void checkDataIsNull(ArrayNode jsonArray,String checkType) {
        ObjectMapper objectMapper = new ObjectMapper();
        ArrayNode arrayNode = objectMapper.createArrayNode();
        int realCount=0;
        for (Object objectRow : jsonArray) {
            if (objectRow instanceof JsonNode) {
                ObjectNode jsonObject = (ObjectNode) objectRow;
                Iterator<Map.Entry<String, JsonNode>> fields = jsonObject.fields();
                ObjectNode objectNode = objectMapper.createObjectNode();
                objectNode.put("total",jsonObject.size());
                while (fields.hasNext()) {
                    Map.Entry<String, JsonNode> next = fields.next();
                    String key = next.getKey();
                    JsonNode jsonNode = next.getValue();
                    String value = jsonNode.asText();
                    if (!StringUtil.isEmpty(value)) {
                        //医院数据是空
//                        jsonObject.remove(key);
                        logger.info("value:" + value);
                    }else {
                        realCount++;
                        objectNode.put(key,checkType);
                    }
                }
                objectNode.put("error",realCount);
                arrayNode.add(objectNode);
                realCount=0;
            }
        }
        jsonArray.removeAll();
        jsonArray.addAll(arrayNode);
    }
    //检测是否转换异常
    public void checkDataTransfer(ArrayNode jsonArray, AdapterDataSet adapterDataSet,String checkType) {
        ObjectMapper objectMapper = new ObjectMapper();
        ArrayNode arrayNode = objectMapper.createArrayNode();
        int realCount=0;
        for (Object objectRow : jsonArray) {
            if (objectRow instanceof JsonNode) {
                ObjectNode jsonObject = (ObjectNode) objectRow;
                Iterator<Map.Entry<String, JsonNode>> fields = jsonObject.fields();
                ObjectNode objectNode = objectMapper.createObjectNode();
                objectNode.put("total",jsonObject.size());
                while (fields.hasNext()) {
                    Map.Entry<String, JsonNode> next = fields.next();
                    String key = next.getKey();
                    JsonNode jsonNode = next.getValue();
                    String value = jsonNode.asText();
                    String stdValue = transferElem(adapterDataSet, key, value);
                    if (!StringUtil.isEmpty(value) && StringUtil.isEmpty(stdValue)) {
                        //转换后数据异常
                        objectNode.put(key, checkType+": org_value: " + value + " stdValue: " + stdValue);
                        logger.info("value: " + value + " stdValue:" + stdValue);
                        realCount++;
                    }
                }
                objectNode.put("error",realCount);
                arrayNode.add(objectNode);
                realCount=0;
            }
        }
        jsonArray.removeAll();
        jsonArray.addAll(arrayNode);
    }
}

+ 51 - 0
src/main/java/com/yihu/hos/rest/common/format/DocumentTransformer.java

@ -0,0 +1,51 @@
package com.yihu.hos.rest.common.format;
import com.fasterxml.jackson.databind.JsonNode;
import com.yihu.hos.rest.models.crawler.adapter.AdapterDataSet;
import com.yihu.hos.rest.models.crawler.patient.Patient;
import com.yihu.hos.rest.models.crawler.transform.TransformType;
import java.util.Map;
/**
 * Created by Administrator on 2015/10/15.
 */
public class DocumentTransformer implements IDataTransformer  {
    private JsonNode jsonObject;
    protected AdapterScheme adapterScheme;
    protected Patient patient;
    public DocumentTransformer(AdapterScheme adapterScheme) {
        this.adapterScheme = adapterScheme;
    }
    @Override
    public Patient getPatient() {
        return patient;
    }
    /**
     * 非结构化的不需要转换
     *
     * @return
     */
    public boolean transfer(Map<String, AdapterDataSet> dataSetMap) {
        return true;
    }
    public JsonNode getJsonObject() {
        return jsonObject;
    }
    public String getData() {
        return jsonObject.asText();
    }
    public void setData(JsonNode data) {
        jsonObject = data;
    }
    public TransformType getTransformType() {
        return TransformType.DOCUMENT;
    }
}

+ 27 - 0
src/main/java/com/yihu/hos/rest/common/format/IDataTransformer.java

@ -0,0 +1,27 @@
package com.yihu.hos.rest.common.format;
import com.fasterxml.jackson.databind.JsonNode;
import com.yihu.hos.rest.models.crawler.adapter.AdapterDataSet;
import com.yihu.hos.rest.models.crawler.patient.Patient;
import com.yihu.hos.rest.models.crawler.transform.TransformType;
import java.util.Map;
/**
 * @author Airhead
 * @version 1.0
 * @created 22-5月-2015 11:24:26
 */
public interface IDataTransformer {
    boolean transfer(Map<String, AdapterDataSet> dataSetMap);
    String getData();
    void setData(JsonNode data);
    Patient getPatient();
    TransformType getTransformType();
}

+ 21 - 0
src/main/java/com/yihu/hos/rest/common/format/StdBase.java

@ -0,0 +1,21 @@
package com.yihu.hos.rest.common.format;
import com.yihu.hos.rest.services.standard.standard.StdMetadataService;
/**
 * 适配器基类,DAO缓存
 *
 * @created Created by Air on 2015/6/10.
 */
public class StdBase {
    private static StdMetadataService stdMetadataService;
    public static StdMetadataService getStdMetadataService() {
        return stdMetadataService;
    }
    public static void setStdMetadataService(StdMetadataService stdMetadataService) {
        StdBase.stdMetadataService = stdMetadataService;
    }
}

+ 194 - 0
src/main/java/com/yihu/hos/rest/common/http/EHRHttpHelper.java

@ -0,0 +1,194 @@
package com.yihu.hos.rest.common.http;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.core.http.HTTPResponse;
import com.yihu.hos.core.http.HttpClientKit;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.rest.common.configuration.EhrUrlConfiguration;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.ssl.SSLContexts;
import javax.net.ssl.SSLContext;
import java.io.File;
import java.util.Map;
//TODO:对于Basic认证内容,暂时未验证,可以使用http://user:password@host的方式尝试访问
public class EHRHttpHelper {
    private static Logger logger = LoggerFactory.getLogger(EHRHttpHelper.class);
    public static String defaultHttpUrl;
    public static String httpClouddUrl;
    public static String httpAdminUrl;
    public static String sslKeystore;
    public static String sslPassword;
    public static String clientId;
    public static String clientKey;
    private static SSLConnectionSocketFactory defaultSSL;
    private static String defaultHttpUser;
    private static String defaultHttpPassword;
    public static void initConfig(EhrUrlConfiguration configuration){
        defaultHttpUrl = configuration.getEhrMgrUrl();
        httpAdminUrl = configuration.getEhrAdminUrl();
        httpClouddUrl = configuration.getEhrCouldUrl();
        sslKeystore = configuration.getSslKeystore();
        sslPassword = configuration.getSslPassword();
        clientId = configuration.getClientId();
        clientKey = configuration.getClientKey();
        initSSL();//配置ssh
    }
    static {
        //默认配置
    }
    public static void  initSSL(){
        try {
            if (StringUtil.isEmpty(sslKeystore)) {
                String home = System.getProperty("catalina.home").replace('\\', '/');
                String homeUrl = home.substring(0, home.lastIndexOf('/') + 1);
                // sslKeystore = homeUrl + "tomcat.keystore";
                sslKeystore = "E://tomcat.keystore";
            }
            if (sslKeystore.length() > 0 && sslPassword != null && sslPassword.length() > 0) {
                HttpClientKit.addKeyStore(defaultHttpUrl, sslKeystore, sslPassword);
            }
            SSLContext sslContext = SSLContexts.custom()
                    .loadTrustMaterial(new File(sslKeystore), sslPassword.toCharArray(),
                            new TrustSelfSignedStrategy())
                    .build();
            defaultSSL = new SSLConnectionSocketFactory(
                    sslContext,
                    new String[]{"TLSv1"},
                    null,
                    SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
            HttpClientKit.addKeyStoreSSL(defaultHttpUrl, defaultSSL);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("默认配置异常",e);
        }
    }
    /**************************
     * Get方法
     ******************************************/
    public static HTTPResponse get(String url) {
        return get(url, null);
    }
    public static HTTPResponse get(String url, Map<String, String> params) {
        return get(url, params, null);
    }
    public static HTTPResponse get(String url, Map<String, String> params, Map<String, String> header) {
        return get(url, params, header, false);
    }
    public static HTTPResponse get(String url, Map<String, String> params, Map<String, String> header, Boolean isCheck) {
        if (isCheck) {
            return get(url, params, header, defaultHttpUser, defaultHttpPassword);
        } else {
            return get(url, params, header, null, null);
        }
    }
    public static HTTPResponse get(String url, Map<String, String> params, Map<String, String> header, String user, String password) {
        return HttpClientKit.request("GET", url, params, header);
    }
    /**************************
     * Post方法
     ******************************************/
    public static HTTPResponse post(String url) {
        return post(url, null);
    }
    public static HTTPResponse post(String url, Map<String, String> params) {
        return post(url, params, null);
    }
    public static HTTPResponse post(String url, Map<String, String> params, Map<String, String> header) {
        return post(url, params, header, false);
    }
    public static HTTPResponse post(String url, Map<String, String> params, Map<String, String> header, Boolean isCheck) {
        if (isCheck) {
            return post(url, params, header, defaultHttpUser, defaultHttpPassword);
        } else {
            return post(url, params, header, null, null);
        }
    }
    public static HTTPResponse post(String url, Map<String, String> params, Map<String, String> header, String user, String password) {
        return HttpClientKit.request("POST", url, params, header);
    }
    public static HTTPResponse postFile(String url, Map<String, String> formParams, String filePath, Map<String, String> headers) {
        return HttpClientKit.postFile(url, filePath, formParams,headers);
    }
    public static HTTPResponse postFile(String url, Map<String, String> formParams, File file, Map<String, String> headers) {
        return HttpClientKit.postFile(url, file.getAbsolutePath(), formParams,headers);
    }
    /**************************
     * Put方法
     ******************************************/
    public static HTTPResponse put(String url) {
        return put(url, null, null);
    }
    public static HTTPResponse put(String url, Map<String, String> params) {
        return put(url, params, null);
    }
    public static HTTPResponse put(String url, Map<String, String> params, Map<String, String> header) {
        return put(url, params, header, false);
    }
    public static HTTPResponse put(String url, Map<String, String> params, Map<String, String> header, Boolean isCheck) {
        if (isCheck) {
            return put(url, params, header, defaultHttpUser, defaultHttpPassword);
        } else {
            return put(url, params, header, null, null);
        }
    }
    public static HTTPResponse put(String url, Map<String, String> params, Map<String, String> header, String user, String password) {
        return HttpClientKit.request("PUT", url, params, header);
    }
    /**************************
     * Delete方法
     **************************************/
    public static HTTPResponse delete(String url) {
        return delete(url, null, null);
    }
    public static HTTPResponse delete(String url, Map<String, String> params) {
        return delete(url, params, null);
    }
    public static HTTPResponse delete(String url, Map<String, String> params, Map<String, String> header) {
        return delete(url, params, header, false);
    }
    public static HTTPResponse delete(String url, Map<String, String> params, Map<String, String> header, Boolean isCheck) {
        if (isCheck) {
            return delete(url, params, header, defaultHttpUser, defaultHttpPassword);
        } else {
            return delete(url, params, header, null, null);
        }
    }
    public static HTTPResponse delete(String url, Map<String, String> params, Map<String, String> header, String user, String password) {
        return HttpClientKit.request("DELETE", url, params, header);
    }
}

+ 393 - 0
src/main/java/com/yihu/hos/rest/controllers/CrawlerController.java

@ -0,0 +1,393 @@
package com.yihu.hos.rest.controllers;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.rest.models.crawler.patient.Patient;
import com.yihu.hos.rest.services.crawler.*;
import com.yihu.hos.rest.services.standard.adapter.AdapterSchemeService;
import com.yihu.hos.web.framework.model.ActionResult;
import com.yihu.hos.web.framework.model.DetailModelResult;
import com.yihu.hos.web.framework.model.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.Date;
import java.util.List;
/**
 * 目前版本只需要采集,上传和注册病人档案就可了。
 * <p>
 * Created by Airhead on 2015/12/16.
 */
@RequestMapping("/crawler")
@RestController("crawlerController")
@Api(protocols = "http", value = "CrawlerController", description = "档案采集接口", tags = {"采集"})
public class CrawlerController {
    private static Logger logger = LoggerFactory.getLogger(CrawlerController.class);
    @Resource
    CrawlerService crawlerService;
    @Resource
    CrawlerManager crawlerManager;
    @Resource
    CrawlerFlowManager crawlerFlowManager;
    @Resource(name = AdapterSchemeService.BEAN_ID)
    private AdapterSchemeService adapterSchemeService;
    @Resource(name = QcRuleService.BEAN_ID)
    private QcRuleService qcRuleService;
    @RequestMapping(value = "/test", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ApiOperation(value = "测试服务器可以正常连接", produces = "application/json", notes = "测试服务器可以正常连接")
    public String test() {
        logger.info("test1111111111111111");
        return "test";
    }
    /**
    任务编排
    */
    @RequestMapping("jobLayout")
    public String jobLayout(Model model) {
        model.addAttribute("contentPage", "/crawler/jobLayout");
        return "partView";
    }
    /*
   任务编排数据映射
    */
    @RequestMapping("jobDataMapping")
    public String jobDataMapping(Model model, Integer versionId, String datasetIdStr) {
        try {
            model.addAttribute("versionId", versionId);
            model.addAttribute("datasetIdStr", datasetIdStr);
            model.addAttribute("contentPage", "/crawler/dataMapping");
            return "pageView";
        } catch (Exception ex) {
            model.addAttribute("contentPage", "/crawler/dataMapping");
            return "pageView";
        }
    }
    @RequestMapping("datasetDetail")
    public String datasetDetail(Model model, Integer schemeId, String schemeNm, String cacheDatasetId, String versionId) {
        model.addAttribute("contentPage", "/crawler/datasetDetail");
        model.addAttribute("schemeId", schemeId);
        model.addAttribute("versionId", versionId);
        model.addAttribute("schemeNm", schemeNm);
        model.addAttribute("cacheDatasetId", cacheDatasetId);
        return "pageView";
    }
    @RequestMapping(value = "patient", method = RequestMethod.POST)
    @ApiOperation(value = "采集病人健康档案", produces = "application/json", notes = "采集病人健康档案")
    @ResponseBody
    public Result crawlerPatient(
            @ApiParam(name = "patient", value = "病人索引信息", required = true)
            @RequestParam(value = "patient") String patientInfo) {
        Patient patient = crawlerManager.parsePatient(patientInfo);
        if (patient != null) {
            Boolean result = crawlerManager.collectProcess(patient,null);
            if (result) {
                return Result.success("采集上传成功");
            } else {
                return Result.error("采集上传失败");
            }
        } else {
            return Result.error("参数转换病人实体失败");
        }
    }
    @RequestMapping(value = "patient/flow", method = RequestMethod.POST)
    @ApiOperation(value = "采集病人健康档案", produces = "application/json", notes = "采集病人健康档案")
    @ResponseBody
    public Result crawlerPatientFlow(
            @ApiParam(name = "patient", value = "病人索引信息", required = true)
            @RequestParam(value = "patient") String patientInfo) {
        Patient patient = crawlerFlowManager.parsePatient(patientInfo);
        if (patient != null) {
            Boolean result = crawlerFlowManager.collectProcess(patient);
            if (result) {
                return Result.success("采集上传成功");
            } else {
                return Result.error("采集上传失败");
            }
        } else {
            return Result.error("参数转换病人实体失败");
        }
    }
    @RequestMapping(value = "patientList", method = RequestMethod.POST)
    @ApiOperation(value = "上传病人健康档案", produces = "application/json", notes = "采集病人健康档案")
    @ResponseBody
    public Result crawlerPatientList(
            @ApiParam(name = "jobId", value = "任务jobId", required = true)
            @RequestParam(value = "jobId") String jobId) {
        try {
            return crawlerManager.dataCrawlerByJobId(jobId,null);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("采集上传失败");
        }
    }
    @RequestMapping(value = "patientListFlow", method = RequestMethod.POST)
    @ApiOperation(value = "采集病人健康档案", produces = "application/json", notes = "采集病人健康档案")
    @ResponseBody
    public Result crawlerPatientListFlow(
            @ApiParam(name = "beginDate", value = "开始时间", required = true)
            @RequestParam(value = "beginDate") Date beginDate,
            @ApiParam(name = "endDate", value = "开始时间", required = true)
            @RequestParam(value = "endDate") Date endDate) {
        try {
            return crawlerFlowManager.dataCrawler(beginDate, endDate);
        } catch (Exception e) {
            return Result.error("采集上传失败");
        }
    }
    /**
     * 保存任务编排数据
     */
    @RequestMapping(value = "saveDateSet", method = RequestMethod.POST)
    @ApiOperation(value = "保存任务编排", produces = "application/json", notes = "保存任务编排")
    @ResponseBody
    public Result saveJobData(
            @ApiParam(name = "job", value = "任务编排信息", required = true)
            @RequestParam(value = "job") String jobInfo,
            @ApiParam(name = "rows", value = "当前行数", required = true)
            @RequestParam(value = "rows") Integer rows,
            @ApiParam(name = "page", value = "当前页数", required = true)
            @RequestParam(value = "page") Integer page) {
        try {
            crawlerService.saveJobData(jobInfo, rows, page);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("保存失败");
        }
        return Result.success("保存成功");
    }
    /**
     * 获取适配方案 数据集关系
     *
     * @param versionId 适配方案版本ID
     * @return
     */
    @RequestMapping("getSchemeDataSets")
    @ResponseBody
    public DetailModelResult getSchemeDataSets(
            @RequestParam(value = "versionId", required = true) Long versionId,
            @RequestParam(value = "name", required = false) String name
    ) {
        try {
            return crawlerService.getSchemeDataset(versionId, name);
        } catch (Exception e) {
            e.printStackTrace();
            return new DetailModelResult();
        }
    }
    /**
     * 保存适配方案 数据映射关系
     *
     * @param version
     * @param data    映射关系
     * @return
     */
    @RequestMapping("saveSchemeRelation")
    @ResponseBody
    public ActionResult addSchemeRelation(
            @RequestParam(value = "version", required = true) String version,
            @RequestParam(value = "data", required = true) String data
    ) {
        try {
            return crawlerService.saveDataSetRelation(version, data);
        } catch (Exception ex) {
            ex.printStackTrace();
            return new ActionResult();
        }
    }
    @RequestMapping("getRelations")
    @ResponseBody
    public String getRelations(
            @RequestParam(value = "versionId", required = true) Integer versionId,
            @RequestParam(value = "datasetIdStr", required = false) String datasetIdStr,
            @RequestParam(value = "lines", required = false) String lines) {
        try {
            return crawlerService.getRelations(versionId, datasetIdStr, lines);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    @RequestMapping("setRelationsCache")
    @ResponseBody
    public Result setRelationsCache(
            @RequestParam(value = "versionId", required = true) Integer versionId,
            @RequestParam(value = "lines", required = false) String lines
    ) {
        try {
            crawlerService.setLinesCache(versionId, lines);
            return Result.success("缓存映射关系成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return Result.error("缓存映射关系失败");
    }
    /**
     * 删除任务编排数据
     */
    @RequestMapping(value = "deleteDateSet", method = RequestMethod.POST)
    @ApiOperation(value = "删除任务编排", produces = "application/json", notes = "删除任务编排")
    @ResponseBody
    public Result deleteJobData(
            @ApiParam(name = "version", value = "版本号", required = true)
            @RequestParam(value = "version") String version) {
        if (version != null) {
            String message = crawlerService.deleteJobData(version);
            if (StringUtil.isEmpty(message)) {
                return Result.success("删除成功");
            } else {
                return Result.error(message);
            }
        } else {
            return Result.error("删除失败");
        }
    }
    /**
     * 分页显示任务编排数据
     */
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ApiOperation(value = "分页显示任务编排", produces = "application/json", notes = "分页显示任务编排")
    @ResponseBody
    public DetailModelResult listJobData(
            @ApiParam(name = "rows", value = "Limit the size of result set. Must be an integer")
            @RequestParam(value = "rows", required = false) Integer rows,
            @ApiParam(name = "page", value = "Start position of result set. Must be an integer")
            @RequestParam(value = "page", required = false) Integer page) throws Exception {
        return crawlerService.getDataSetResult(rows, page);
    }
    @RequestMapping(value = "getSchemeList", method = RequestMethod.POST)
    @ApiOperation(value = "获取适配方案-方案版本下拉框", produces = "application/json", notes = "获取适配方案-方案版本下拉框")
    @ResponseBody
    public DetailModelResult getSchemeList() {
        DetailModelResult result = adapterSchemeService.getAdapterSchemeResultModelList();
        return result;
    }
    /**
     * 获取任务编排保存数据集
     */
    @RequestMapping(value = "savedJobData", method = RequestMethod.POST)
    @ApiOperation(value = "获取保存的数据集",produces = "application/json", notes = "保存的数据集")
    @ResponseBody
    public DetailModelResult ListSavedJobData(
            @ApiParam(name = "version", value = "版本号", required = true)
            @RequestParam(value = "version") Long version
    ) {
        return crawlerService.getDataSetSavedResult(version);
    }
    /**
     * 获取任务编排保存适配方案-方案版本
     */
    @RequestMapping(value = "savedSchemeList", method = RequestMethod.POST)
    @ApiOperation(value = "获取保存的适配方案",produces = "application/json", notes = "保存的适配方案")
    @ResponseBody
    public DetailModelResult SavedSchemeList() {
        return crawlerService.getSchemeSavedResult();
    }
    /* ***************************************** 以下为 质控校验规则添加后的采集逻辑 接口*********************************************** */
    @RequestMapping(value = "/qc/patientList", method = RequestMethod.POST)
    @ApiOperation(value = "采集病人事件列表", produces = "application/json", notes = "采集病人事件列表")
    @ResponseBody
    public List<Patient> getPatientList(
            @ApiParam(name = "jobId", value = "任务jobId", required = true)
            @RequestParam(value = "jobId") String jobId) {
        try {
            return crawlerManager.PatientListByJobId(jobId);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    @RequestMapping(value = "qc/crawlerPatientList", method = RequestMethod.POST)
    @ApiOperation(value = "按任务采集质控数据", produces = "application/json", notes = "按任务采集质控数据")
    @ResponseBody
    public Result crawlerQCDataList(
            @ApiParam(name = "jobId", value = "任务jobId", required = true)
            @RequestParam(value = "jobId") String jobId,
            @ApiParam(name = "checkType", value = "质控规则类型集合,以“,”分割", required = false)
            @RequestParam(value = "checkType", required = false) String checkType) {
        try {
            return crawlerManager.dataCrawlerByJobId(jobId,checkType);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("采集上传失败");
        }
    }
    @RequestMapping(value = "/qc/patient", method = RequestMethod.POST)
    @ApiOperation(value = "采集单份档案质控数据", produces = "application/json", notes = "采集病人档案质控数据")
    public Result crawlerQcData(
            @ApiParam(name = "patient", value = "病人索引信息", required = false)
            @RequestParam(value = "patient") String patientInfo,
            @ApiParam(name = "checkType", value = "质控规则类型集合,以“,”分割", required = false)
            @RequestParam(value = "checkType") String checkType) {
        Patient patient = crawlerManager.parsePatient(patientInfo);
        //TODO 通过获取规则,获取规则类型,进行校验
        if (patient != null) {
            Boolean result = crawlerManager.collectProcess(patient, checkType);
            if (result) {
                return Result.success("上传档案质控数据成功");
            } else {
                return Result.error("上传档案质控数据失败");
            }
        } else {
            return Result.error("病人索引实体,参数转换失败!");
        }
    }
    @RequestMapping(value = "qc/rules", method = RequestMethod.POST)
    @ApiOperation(value = "获取质控规则列表", produces = "application/json", notes = "获取质控规则列表")
    public String qcRules() {
        try {
            return qcRuleService.getRuleNames();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

+ 95 - 0
src/main/java/com/yihu/hos/rest/controllers/DataCollectController.java

@ -0,0 +1,95 @@
package com.yihu.hos.rest.controllers;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.rest.services.crawler.DatacollectService;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.util.controller.BaseController;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
/**
 * 数据采集配置页面
 * Created by hzp on 2015/8/12.
 */
@RequestMapping("/crawler")
@Controller("dataCollectController")
public class DataCollectController extends BaseController {
    private static Logger logger = LoggerFactory.getLogger(DataCollectController.class);
    @Resource(name = "DatacollectService")
    DatacollectService datacollectService;
    @RequestMapping(value = "collect", method = RequestMethod.POST)
    @ApiOperation(value = "采集医院数据", produces = "application/json", notes = "采集医院数据")
    @ResponseBody
    public Result collect(
            @ApiParam(name = "jobId", value = "任务jobId", required = true)
            @RequestParam(value = "jobId") String jobId) {
        try {
            logger.info("===========进入 采集医院数据 接口1111111111==================");
            if (datacollectService.collectByJobId(jobId)) {
                return Result.success("采集成功");
            } else {
                return Result.error("采集失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("采集失败");
        }
    }
    @RequestMapping(value = "collect", method = RequestMethod.GET)
    @ApiOperation(value = "采集医院数据", produces = "application/json", notes = "采集医院数据")
    @ResponseBody
    public Result collectData(
            @ApiParam(name = "jobId", value = "任务jobId", required = true)
            @RequestParam(value = "jobId") String jobId) {
        try {
            logger.info("===========进入 采集医院数据 接口22222222222222==================");
            if (datacollectService.collectByJobId(jobId)) {
                return Result.success("采集成功");
            } else {
                return Result.error("采集失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("采集失败");
        }
    }
    @RequestMapping(value = "/testHeath", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "测试服务器可以正常连接", notes = "测试服务器可以正常连接")
    public String heartbeat() {
        return " 服务器可以正常连接";
    }
    @RequestMapping(value = "collect2", method = RequestMethod.GET)
    @ApiOperation(value = "采集医院数据2", produces = "application/json", notes = "采集医院数据")
    @ResponseBody
    public Result collect2(
            @ApiParam(name = "jobId", value = "任务jobId", required = true)
            @RequestParam(value = "jobId") String jobId) {
        try {
            logger.info("===========进入 采集医院数据 接口==================");
            if (datacollectService.collectByJobId(jobId)) {
                return Result.success("采集成功");
            } else {
                return Result.error("采集失败");
            }
        } catch (Exception e) {
            return Result.error("采集失败");
        }
    }
}

+ 38 - 0
src/main/java/com/yihu/hos/rest/controllers/DataPushController.java

@ -0,0 +1,38 @@
package com.yihu.hos.rest.controllers;
import com.yihu.hos.rest.services.crawler.DatapushService;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.util.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * 数据采集配置页面
 * Created by hzp on 2015/8/12.
 */
@RequestMapping("/crawler")
@Controller("dataPushController")
public class DataPushController extends BaseController {
    @Autowired
    DatapushService datapushService;
    /**************************** 推送数据 ************************************************/
    /*
    全流程推数据
     */
    @RequestMapping("push")
    @ResponseBody
    public Result datapush(String dataset,String data,String orgCode) {
        try {
            return datapushService.pushData(dataset, data,orgCode);
        }
        catch (Exception ex)
        {
            return Result.error(ex.getMessage());
        }
    }
}

+ 33 - 0
src/main/java/com/yihu/hos/rest/controllers/ErrorHandleController.java

@ -0,0 +1,33 @@
package com.yihu.hos.rest.controllers;
import com.yihu.hos.rest.services.gateway.ErrorHandleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/6/13.
 */
@RequestMapping("/")
@RestController("errorHandleController")
@Api(protocols = "http", value = "ErrorHandleController", description = "统一网关错误返回", tags = {"统一网关,错误返回"})
public class ErrorHandleController
{
    @Resource(name = ErrorHandleService.BEAN_ID)
    private ErrorHandleService errorHandleService;
    @RequestMapping(value = "/error/{errorCode}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation(value = "统一网关错误信息获取", produces = "application/json", notes = "统一网关错误信息获取")
    public String test(HttpServletResponse response,
                       @ApiParam(name = "errorCode", value = "错误代码", required = true)
                       @PathVariable(name = "errorCode") String errorCode) {
        return errorHandleService.getError(response,errorCode);
    }
}

+ 32 - 0
src/main/java/com/yihu/hos/rest/controllers/MetricController.java

@ -0,0 +1,32 @@
package com.yihu.hos.rest.controllers;
import com.yihu.hos.rest.services.crawler.MetricManager;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.util.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
/**
 * 应用管理
 */
@RequestMapping("/metric")
@Controller
public class MetricController extends BaseController {
    @Resource(name = MetricManager.BEAN_ID)
    private MetricManager metricManager;
    @RequestMapping("/saveToMongo")
    @ResponseBody
    public Result saveToMongo(String msg) {
        try {
            Result result = metricManager.saveToMongo(msg);
            return result;
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
}

File diff suppressed because it is too large
+ 502 - 0
src/main/java/com/yihu/hos/rest/controllers/QLCController.java


+ 111 - 0
src/main/java/com/yihu/hos/rest/models/crawler/adapter/AdapterDataSet.java

@ -0,0 +1,111 @@
package com.yihu.hos.rest.models.crawler.adapter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.core.datatype.CollectionUtil;
import com.yihu.hos.rest.common.format.AdapterBase;
import com.yihu.hos.rest.models.crawler.patient.PatientIdentity;
import com.yihu.hos.rest.models.standard.adapter.AdapterDatasetModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterDictEntryModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterMetadataModel;
import com.yihu.hos.rest.models.standard.bo.AdapterVersion;
import com.yihu.hos.rest.models.standard.standard.StdMetaDataModel;
import java.util.*;
/**
 * @author Air
 * @version 1.0
 * @created 2015.08.11 11:29
 */
public class AdapterDataSet extends AdapterBase {
    private List<AdapterMetaData> adapterMetaDataList;
    private AdapterDatasetModel adapterDatasetModel;
    private Map<String, AdapterMetaData> adapterMetaDataMap;
    private Map<String, StdMetaDataModel> stdMetaDataMap;
    private String eventNoCode;
    private AdapterVersion adapterVersion;
    public AdapterDataSet(AdapterDatasetModel adapterDatasetModel, AdapterVersion adapterVersion, Map<Long, List<AdapterDictEntryModel>> entryMap) {
        this.adapterDatasetModel = adapterDatasetModel;
        this.adapterVersion = adapterVersion;
        prepareData(entryMap);
    }
    public AdapterDatasetModel getAdapterDataSetT() {
        return adapterDatasetModel;
    }
    public void prepareData(Map<Long, List<AdapterDictEntryModel>> entryMap) {
        try {
            adapterMetaDataList = new ArrayList<>();
            adapterMetaDataMap = new HashMap<>();
            Map<String, Object> condition = new HashMap<>();
            condition.put("column", "adapter_metadata_code");
            ObjectMapper objectMapper = new ObjectMapper();
            List<StdMetaDataModel> stdMetaDataModelList = getAdapterMetadataService().getAdapterMetadataNotNullList(adapterVersion, adapterDatasetModel.getStdDatasetId(),objectMapper.writeValueAsString(condition));
            List<AdapterMetadataModel> adapterMetaDataModelList = getAdapterMetadataService().getAdapterMetadataNotNullList(adapterVersion, adapterDatasetModel.getStdDatasetId(),objectMapper.writeValueAsString(condition));
            List<Long> stdMetaDataIdList = new ArrayList<>();
            if (!CollectionUtil.isEmpty(adapterMetaDataModelList)) {
                for (AdapterMetadataModel adapterMetadataModel : adapterMetaDataModelList) {
                    stdMetaDataIdList.add(adapterMetadataModel.getStdMetadataId());
                }
                for (AdapterMetadataModel adapterMetadataModel : adapterMetaDataModelList) {
                    AdapterMetaData adapterMetaData = new AdapterMetaData(adapterMetadataModel, adapterVersion, entryMap);
                    adapterMetaDataList.add(adapterMetaData);
                    adapterMetaDataMap.put(adapterMetadataModel.getStdMetadataCode().toUpperCase(), adapterMetaData);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public Map<String, AdapterMetaData> getAdapterMetaDataMap() {
        return adapterMetaDataMap;
    }
    public List<AdapterMetaData> getAdapterMetaDataList() {
        return adapterMetaDataList;
    }
    public boolean isHavePatientID() {
        return findPatientIdentity(PatientIdentity.getPatientIDCode());
    }
    public boolean isHaveEventNo() {
        Set<String> eventNoSet = PatientIdentity.getEventNoSet();
        for (String eventNo : eventNoSet) {
            if (findPatientIdentity(eventNo)) {
                eventNoCode = eventNo;
                return true;
            }
        }
        return false;
    }
    public boolean isHaveLocalCardNo() {
        return findPatientIdentity(PatientIdentity.getLocalCardNoCode());
    }
    public boolean isHaveIdCard() {
        return findPatientIdentity(PatientIdentity.getIdCardCode());
    }
    public boolean findPatientIdentity(String code) {
        if (getAdapterMetaDataMap().get(code) == null) {
            return false;
        }
        return true;
    }
    public String getEventNoCode() {
        return eventNoCode;
    }
}

+ 54 - 0
src/main/java/com/yihu/hos/rest/models/crawler/adapter/AdapterDict.java

@ -0,0 +1,54 @@
package com.yihu.hos.rest.models.crawler.adapter;
import com.yihu.hos.rest.common.format.AdapterBase;
import com.yihu.hos.rest.models.standard.adapter.AdapterDictEntryModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterDictModel;
import com.yihu.hos.rest.models.standard.bo.AdapterVersion;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author Air
 * @version 1.0
 * @created 2015.08.11 11:31
 */
public class AdapterDict extends AdapterBase {
    private AdapterDictModel adapterDictModel;
    private AdapterDictModel adapterDictT;
    private Map<String, String> adapterValueToCodeMap;
    private Map<String, String> adapterCodeToCodeMap;
    public AdapterDict(AdapterDictModel adapterDictModel, AdapterVersion adapterVersion, Map<Long, List<AdapterDictEntryModel>> entryMap) {
        this.adapterDictModel = adapterDictModel;
        this.adapterDictT = adapterDictModel;
        prepareData(entryMap);
    }
    public void prepareData(Map<Long, List<AdapterDictEntryModel>> entryMap) {
        adapterValueToCodeMap = new HashMap<>();
        adapterCodeToCodeMap = new HashMap<>();
        List<AdapterDictEntryModel> adapterDictEntryModelList = entryMap.get(adapterDictModel.getStdDictId());
        for (AdapterDictEntryModel adapterDictEntryModel : adapterDictEntryModelList) {
            // 源数据元为key,目标数据元为value
            if (adapterDictEntryModel.getAdapterEntryValue()!= null){
                adapterValueToCodeMap.put(adapterDictEntryModel.getAdapterEntryValue(), adapterDictEntryModel.getStdEntryCode());
            }
            if (adapterDictEntryModel.getAdapterEntryCode() != null){
                adapterCodeToCodeMap.put(adapterDictEntryModel.getAdapterEntryCode(), adapterDictEntryModel.getStdEntryCode());
            }
        }
    }
    public Map<String, String> getAdapterValueToCodeMap() {
        return adapterValueToCodeMap;
    }
    public Map<String, String> getAdapterCodeToCodeMap() {
        return adapterCodeToCodeMap;
    }
}

+ 14 - 0
src/main/java/com/yihu/hos/rest/models/crawler/adapter/AdapterDictEntry.java

@ -0,0 +1,14 @@
package com.yihu.hos.rest.models.crawler.adapter;
import com.yihu.hos.rest.models.standard.adapter.AdapterDictEntryModel;
public class AdapterDictEntry {
    private AdapterDictEntryModel adapterDictEntryModel;
    private String version;
    public AdapterDictEntry(AdapterDictEntryModel adapterDictEntryModel, String version) {
        this.adapterDictEntryModel = adapterDictEntryModel;
        this.version = version;
    }
}

+ 60 - 0
src/main/java/com/yihu/hos/rest/models/crawler/adapter/AdapterMetaData.java

@ -0,0 +1,60 @@
package com.yihu.hos.rest.models.crawler.adapter;
import com.yihu.hos.core.datatype.NumberUtil;
import com.yihu.hos.rest.common.format.AdapterBase;
import com.yihu.hos.rest.models.crawler.transform.DictDataType;
import com.yihu.hos.rest.models.standard.adapter.AdapterDictEntryModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterDictModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterMetadataModel;
import com.yihu.hos.rest.models.standard.bo.AdapterVersion;
import java.util.List;
import java.util.Map;
/**
 * @author Air
 * @version 1.0
 * @created 2015.08.11 11:31
 */
public class AdapterMetaData extends AdapterBase {
    private AdapterMetadataModel adapterMetadataModel;
    private AdapterDict adapterDict;
    private AdapterVersion adapterVersion;
    public AdapterMetaData(AdapterMetadataModel adapterMetadataModel, AdapterVersion adapterVersion, Map<Long, List<AdapterDictEntryModel>> entryMap) {
        this.adapterMetadataModel = adapterMetadataModel;
        this.adapterVersion = adapterVersion;
        prepareData(entryMap);
    }
    public AdapterMetadataModel getAdapterMetadataModel() {
        return adapterMetadataModel;
    }
    public void prepareData(Map<Long, List<AdapterDictEntryModel>> entryMap) {
        if (!NumberUtil.isZero(adapterMetadataModel.getStdDictId())) {
            /**
             * 默认适配字典的id与数据元的标准id一致
             */
            AdapterDictModel adapterDictModel = (AdapterDictModel) getAdapterDictService().get(AdapterDictModel.class, adapterVersion.getDictTableName(), adapterMetadataModel.getStdDictId());
            if (adapterDictModel != null) {
                adapterDict = new AdapterDict(adapterDictModel, adapterVersion, entryMap);
            }
        }
    }
    public AdapterDict getAdapterDict() {
        return adapterDict;
    }
    public DictDataType getAdapterDictDataType() {
        Integer orgDictDataType = adapterMetadataModel.getAdapterDataType();
        if (orgDictDataType == null){
            return DictDataType.VALUE;
        }
        return DictDataType.values()[orgDictDataType];
    }
}

+ 90 - 0
src/main/java/com/yihu/hos/rest/models/crawler/adapter/StdDataSet.java

@ -0,0 +1,90 @@
package com.yihu.hos.rest.models.crawler.adapter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.core.datatype.CollectionUtil;
import com.yihu.hos.rest.common.format.StdBase;
import com.yihu.hos.rest.models.standard.bo.StandardVersion;
import com.yihu.hos.rest.models.standard.standard.StdMetaDataModel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author Air
 * @version 1.0
 * @created 2015.08.11 11:29
 */
public class StdDataSet extends StdBase {
    private  Map<Long, Map<String,StdMetaDataModel>> stdDataSetMetasMap;
    private  Map<String, StdMetaDataModel> stdMetaDataMap;
    private List<StdMetaDataModel> stdMetaDataModelList;
    private StandardVersion standardVersion;
    private Long stdDataSetId;
    public StdDataSet(Long  stdDataSetId,StandardVersion standardVersion) {
        this.stdDataSetId = stdDataSetId;
        this.standardVersion = standardVersion;
        prepareData();
    }
    public void prepareData() {
        try {
            stdMetaDataModelList = new ArrayList<>();
            stdDataSetMetasMap = new HashMap<>();
            stdMetaDataMap = new HashMap<>();
            Map<String, Object> condition = new HashMap<>();
            condition.put("column", "code");
            ObjectMapper objectMapper = new ObjectMapper();
             stdMetaDataModelList = getStdMetadataService().getStdMetadataNotNullList(standardVersion, stdDataSetId, objectMapper.writeValueAsString(condition));
            if (!CollectionUtil.isEmpty(stdMetaDataModelList)) {
                for (StdMetaDataModel stdMetadataModel : stdMetaDataModelList) {
                    stdMetaDataMap.put(stdMetadataModel.getInnerCode(),stdMetadataModel);
                }
                if (!stdDataSetMetasMap.containsKey(stdDataSetId)){
                    stdDataSetMetasMap.put(stdDataSetId,stdMetaDataMap);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public Map<Long, Map<String, StdMetaDataModel>> getStdDataSetMetasMap() {
        return stdDataSetMetasMap;
    }
    public void setStdDataSetMetasMap(Map<Long, Map<String, StdMetaDataModel>> stdDataSetMetasMap) {
        this.stdDataSetMetasMap = stdDataSetMetasMap;
    }
    public List<StdMetaDataModel> getStdMetaDataModelList() {
        return stdMetaDataModelList;
    }
    public void setStdMetaDataModelList(List<StdMetaDataModel> stdMetaDataModelList) {
        this.stdMetaDataModelList = stdMetaDataModelList;
    }
    public Map<String, StdMetaDataModel> getStdMetaDataMap() {
        return stdMetaDataMap;
    }
    public void setStdMetaDataMap(Map<String, StdMetaDataModel> stdMetaDataMap) {
        this.stdMetaDataMap = stdMetaDataMap;
    }
    public Long getStdDataSetId() {
        return stdDataSetId;
    }
    public void setStdDataSetId(Long stdDataSetId) {
        this.stdDataSetId = stdDataSetId;
    }
}

+ 207 - 0
src/main/java/com/yihu/hos/rest/models/crawler/config/SysConfig.java

@ -0,0 +1,207 @@
package com.yihu.hos.rest.models.crawler.config;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.rest.models.crawler.patient.PatientIdentity;
import com.yihu.hos.rest.models.crawler.patient.PatientIndex;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class SysConfig {
    private static Logger logger = LoggerFactory.getLogger(SysConfig.class);
    public static final String HOS_RESOURCES_CONFIG = "/config/sys.config.xml";
    private static volatile SysConfig instance = null;
    private HashMap<String, PatientIdentity> patientIdentityHashMap;
    private Map<String, PatientIndex> patientIndexMap;//病人摘要信息内容
    private Map<String, String> publicKeyMap;
    private Map<String, String> versionMap;
    public static String tempFile;
    public static String orgcode;
    public static String registerDataSet;
    public static String registerIdCardNo;
    public  List<String> eventQueue;
    private SysConfig() {
        patientIdentityHashMap = new HashMap<>();
        patientIndexMap = new HashMap<>();
        publicKeyMap = new HashMap<>();
        versionMap = new HashMap<>();
        eventQueue = new ArrayList<>();
        init();
    }
    public static SysConfig getInstance() {
        if (instance == null) {
            synchronized (SysConfig.class) {
                if (instance == null) {
                    try {
                        instance = new SysConfig();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        return instance;
    }
    public void finalize() throws Throwable {
    }
    public String getTempFile() {
        return this.tempFile;
    }
    public void setTempFile(String tempFile) {
        this.tempFile = tempFile;
    }
    public PatientIdentity getPatientIdentity(String dataSetCode) {
        return patientIdentityHashMap.get(dataSetCode);
    }
    public HashMap<String, PatientIdentity> getPatientIdentityHashMap() {
        return patientIdentityHashMap;
    }
    public String getRegisterDataSet() {
        return registerDataSet;
    }
    public String getRegisterIdCardNo() {
        return registerIdCardNo;
    }
    public Map<String, PatientIndex> getPatientIndexMap() {
        return patientIndexMap;
    }
    public Map<String, String> getPublicKeyMap() {
        return publicKeyMap;
    }
    public Map<String, String> getVersionMap() {
        return versionMap;
    }
    public List<String> getEventQueue() {
        return eventQueue;
    }
    public void setVersionMap(Map<String, String> versionMap) {
        this.versionMap = versionMap;
    }
    private Document getDocument() throws DocumentException {
        SAXReader reader = new SAXReader();
        Document document = null;
        try {
            InputStream inputStream = SysConfig.class.getResourceAsStream(HOS_RESOURCES_CONFIG);
            document = reader.read(inputStream);
            return document;
        } catch (DocumentException de) {
            logger.info("读取classpath下的xml文档路径发生异常");
            return null;
        }
    }
    private void init() {
        try {
            Document document = this.getDocument();
            Element rootElement = null;
            if (document != null) {
                rootElement = document.getRootElement();
            }
            if (rootElement == null) {
                return;
            }
            this.initCrawler(rootElement);
            this.initEventNo(rootElement);
            this.initVersion(rootElement);
            String tempFile = rootElement.elementTextTrim("temp_file");
//            this.initPatientIndex(rootElement);
        } catch (Exception e) {
            logger.error(e.getCause().toString());
        }
    }
    private void initVersion(Element rootElement){
        String tempFile = rootElement.elementTextTrim("temp_file");
        if (!StringUtil.isEmpty(tempFile)) {
            this.tempFile = tempFile;
        } else {
            String home = System.getProperty("catalina.home").replace('\\','/');
            String homeUrl = home.substring(0,home.lastIndexOf('/')+1);
            this.tempFile = homeUrl + "temp";
        }
        List queueDataSets = rootElement.element("ehr_version").elements("org_code");
        for (Object obj : queueDataSets) {
            if (obj instanceof Element) {
                Element element = (Element) obj;
                String dataSetCode = element.attributeValue("code");
                orgcode = element.attributeValue("code");
                String version = element.elementTextTrim("version");
                String ehrVersion=new String(version);
                versionMap.put(dataSetCode,ehrVersion);
            }
        }
        Element registerDataSet = rootElement.element("register").element("dataset");
        this.registerDataSet = registerDataSet.attributeValue("code");
        this.registerIdCardNo = registerDataSet.elementTextTrim("id_card");
    }
    private void initCrawler(Element rootElement) {
        String tempFile = rootElement.elementTextTrim("temp_file");
        if (!StringUtil.isEmpty(tempFile)) {
            this.tempFile = tempFile;
        } else {
            String home = System.getProperty("catalina.home").replace('\\','/');
            String homeUrl = home.substring(0,home.lastIndexOf('/')+1);
            this.tempFile = homeUrl + "temp";
        }
        List queueDataSets = rootElement.element("patient_queue").elements("dataset");
        for (Object obj : queueDataSets) {
            if (obj instanceof Element) {
                Element element = (Element) obj;
                String dataSetCode = element.attributeValue("code");
                String eventNo = element.elementTextTrim("event_no");
                String refTime = element.elementTextTrim("ref_time");
                PatientIdentity patientIdentity = new PatientIdentity(eventNo, refTime);
                patientIdentityHashMap.put(dataSetCode, patientIdentity);
                eventQueue.add(dataSetCode);
            }
        }
        Element registerDataSet = rootElement.element("register").element("dataset");
        this.registerDataSet = registerDataSet.attributeValue("code");
        this.registerIdCardNo = registerDataSet.elementTextTrim("id_card");
    }
    private void initEventNo(Element rootElement) {
        List eventItems = rootElement.element("event_no").elements("item");
        for (Object obj : eventItems) {
            if (obj instanceof Element) {
                Element element = (Element) obj;
                String eventNoCode = element.getTextTrim();
                PatientIdentity.addEventNoCode(eventNoCode);
            }
        }
    }
}//end SysConfig

+ 66 - 0
src/main/java/com/yihu/hos/rest/models/crawler/flow/CrawlerDataSetKey.java

@ -0,0 +1,66 @@
package com.yihu.hos.rest.models.crawler.flow;
import javax.persistence.Embeddable;
import java.io.Serializable;
/**
 * 任务编排-数据集关系
 *
 * @created HZY 2016/4/27.
 */
@Embeddable
public class CrawlerDataSetKey implements Serializable {
    private Long schemeId;
    private Long schemeVersionId;
    private Long datasetId;
    public Long getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(Long schemeId) {
        this.schemeId = schemeId;
    }
    public Long getSchemeVersionId() {
        return schemeVersionId;
    }
    public void setSchemeVersionId(Long schemeVersionId) {
        this.schemeVersionId = schemeVersionId;
    }
    public Long getDatasetId() {
        return datasetId;
    }
    public void setDatasetId(Long datasetId) {
        this.datasetId = datasetId;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof CrawlerDataSetKey)) return false;
        CrawlerDataSetKey that = (CrawlerDataSetKey) o;
        if (getSchemeId() != null ? !getSchemeId().equals(that.getSchemeId()) : that.getSchemeId() != null)
            return false;
        if (getSchemeVersionId() != null ? !getSchemeVersionId().equals(that.getSchemeVersionId()) : that.getSchemeVersionId() != null)
            return false;
        return getDatasetId() != null ? getDatasetId().equals(that.getDatasetId()) : that.getDatasetId() == null;
    }
    @Override
    public int hashCode() {
        int result = getSchemeId() != null ? getSchemeId().hashCode() : 0;
        result = 31 * result + (getSchemeVersionId() != null ? getSchemeVersionId().hashCode() : 0);
        result = 31 * result + (getDatasetId() != null ? getDatasetId().hashCode() : 0);
        return result;
    }
}

+ 75 - 0
src/main/java/com/yihu/hos/rest/models/crawler/flow/CrawlerDataSetModel.java

@ -0,0 +1,75 @@
package com.yihu.hos.rest.models.crawler.flow;
import com.yihu.hos.web.framework.model.Result;
import javax.persistence.*;
import java.io.Serializable;
/**
 * 任务编排-数据集关系
 *
 * @created HZY 2016/4/27.
 */
@Entity
@Table(name = "crawler_dataset")
@IdClass(CrawlerDataSetKey.class)
public class CrawlerDataSetModel extends Result implements Serializable {
    @Id
    @Column(name="scheme_id")
    private Long schemeId;
    @Id
    @Column(name="scheme_version_id")
    private Long schemeVersionId;
    @Id
    @Column(name="dataset_id")
    private Long datasetId;
    @Column(name="dataset_code")
    private String datasetCode;
    @Column(name="dataset_name")
    private String datasetName;
    public Long getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(Long schemeId) {
        this.schemeId = schemeId;
    }
    public Long getSchemeVersionId() {
        return schemeVersionId;
    }
    public void setSchemeVersionId(Long schemeVersionId) {
        this.schemeVersionId = schemeVersionId;
    }
    public Long getDatasetId() {
        return datasetId;
    }
    public void setDatasetId(Long datasetId) {
        this.datasetId = datasetId;
    }
    public String getDatasetCode() {
        return datasetCode;
    }
    public void setDatasetCode(String datasetCode) {
        this.datasetCode = datasetCode;
    }
    public String getDatasetName() {
        return datasetName;
    }
    public void setDatasetName(String datasetName) {
        this.datasetName = datasetName;
    }
}

+ 65 - 0
src/main/java/com/yihu/hos/rest/models/crawler/flow/CrawlerFlowHeadKey.java

@ -0,0 +1,65 @@
package com.yihu.hos.rest.models.crawler.flow;
import java.io.Serializable;
/**
 * 标准基本信息
 *
 * @created Airhead 2015/12/23.
 */
public class CrawlerFlowHeadKey implements Serializable {
    private Long schemeVersionId;
    private String datasetCode;
    private String metadataCode;
    public Long getSchemeVersionId() {
        return schemeVersionId;
    }
    public void setSchemeVersionId(Long schemeVersionId) {
        this.schemeVersionId = schemeVersionId;
    }
    public String getDatasetCode() {
        return datasetCode;
    }
    public void setDatasetCode(String datasetCode) {
        this.datasetCode = datasetCode;
    }
    public String getMetadataCode() {
        return metadataCode;
    }
    public void setMetadataCode(String metadataCode) {
        this.metadataCode = metadataCode;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof CrawlerFlowHeadKey)) return false;
        CrawlerFlowHeadKey that = (CrawlerFlowHeadKey) o;
        if (getSchemeVersionId() != null ? !getSchemeVersionId().equals(that.getSchemeVersionId()) : that.getSchemeVersionId() != null)
            return false;
        if (getDatasetCode() != null ? !getDatasetCode().equals(that.getDatasetCode()) : that.getDatasetCode() != null)
            return false;
        return getMetadataCode() != null ? getMetadataCode().equals(that.getMetadataCode()) : that.getMetadataCode() == null;
    }
    @Override
    public int hashCode() {
        int result = getSchemeVersionId() != null ? getSchemeVersionId().hashCode() : 0;
        result = 31 * result + (getDatasetCode() != null ? getDatasetCode().hashCode() : 0);
        result = 31 * result + (getMetadataCode() != null ? getMetadataCode().hashCode() : 0);
        return result;
    }
}

+ 65 - 0
src/main/java/com/yihu/hos/rest/models/crawler/flow/CrawlerFlowHeadModel.java

@ -0,0 +1,65 @@
package com.yihu.hos.rest.models.crawler.flow;
import com.yihu.hos.web.framework.model.Result;
import javax.persistence.*;
import java.io.Serializable;
/**
 * 标准基本信息
 *
 * @created Airhead 2015/12/23.
 */
@Entity
@Table(name = "crawler_flow_head")
@IdClass(CrawlerFlowHeadKey.class)
public class CrawlerFlowHeadModel extends Result implements Serializable {
    @Id
    @Column(name="scheme_version_id")
    private Long schemeVersionId;
    @Id
    @Column(name="dataset_code")
    private String datasetCode;
    @Id
    @Column(name="metadata_code")
    private String metadataCode;
    @Column(name="identity_code")
    private String identityCode;
    public Long getSchemeVersionId() {
        return schemeVersionId;
    }
    public void setSchemeVersionId(Long schemeVersionId) {
        this.schemeVersionId = schemeVersionId;
    }
    public String getDatasetCode() {
        return datasetCode;
    }
    public void setDatasetCode(String datasetCode) {
        this.datasetCode = datasetCode;
    }
    public String getMetadataCode() {
        return metadataCode;
    }
    public void setMetadataCode(String metadataCode) {
        this.metadataCode = metadataCode;
    }
    public String getIdentityCode() {
        return identityCode;
    }
    public void setIdentityCode(String identityCode) {
        this.identityCode = identityCode;
    }
}

+ 109 - 0
src/main/java/com/yihu/hos/rest/models/crawler/flow/CrawlerFlowModel.java

@ -0,0 +1,109 @@
package com.yihu.hos.rest.models.crawler.flow;
import com.yihu.hos.web.framework.model.Result;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.io.Serializable;
/**
 * 标准基本信息
 *
 * @created Airhead 2015/12/23.
 */
@Entity
@Table(name = "crawler_flow")
public class CrawlerFlowModel extends Result implements Serializable {
    @Id
    @Column(name="id")
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "increment")
    private Integer id;
    @Column(name="scheme_version_id")
    private Long schemeVersionId;
    @Column(name="dataset_code")
    private String datasetCode;
    @Column(name="metadata_code")
    private String metadataCode;
    @Column(name="input_dataset_code")
    private String inputDatasetCode;
    @Column(name="input_metadata_code")
    private String inputMetadataCode;
    @Column(name="input_metadata_code2")
    private String inputMetadataCode2;
    @Column(name="input_default_value")
    private String inputDefaultValue;
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public Long getSchemeVersionId() {
        return schemeVersionId;
    }
    public void setSchemeVersionId(Long schemeVersionId) {
        this.schemeVersionId = schemeVersionId;
    }
    public String getDatasetCode() {
        return datasetCode;
    }
    public void setDatasetCode(String datasetCode) {
        this.datasetCode = datasetCode;
    }
    public String getMetadataCode() {
        return metadataCode;
    }
    public void setMetadataCode(String metadataCode) {
        this.metadataCode = metadataCode;
    }
    public String getInputDatasetCode() {
        return inputDatasetCode;
    }
    public void setInputDatasetCode(String inputDatasetCode) {
        this.inputDatasetCode = inputDatasetCode;
    }
    public String getInputMetadataCode() {
        return inputMetadataCode;
    }
    public void setInputMetadataCode(String inputMetadataCode) {
        this.inputMetadataCode = inputMetadataCode;
    }
    public String getInputMetadataCode2() {
        return inputMetadataCode2;
    }
    public void setInputMetadataCode2(String inputMetadataCode2) {
        this.inputMetadataCode2 = inputMetadataCode2;
    }
    public String getInputDefaultValue() {
        return inputDefaultValue;
    }
    public void setInputDefaultValue(String inputDefaultValue) {
        this.inputDefaultValue = inputDefaultValue;
    }
}

+ 20 - 0
src/main/java/com/yihu/hos/rest/models/crawler/flow/resultModel/CrawlerDatasetResultDetailModel.java

@ -0,0 +1,20 @@
package com.yihu.hos.rest.models.crawler.flow.resultModel;
import com.yihu.hos.rest.models.crawler.flow.CrawlerDataSetModel;
/**
 * 任务编排数据集关联
 */
public class CrawlerDatasetResultDetailModel extends CrawlerDataSetModel implements java.io.Serializable {
	private String checked;
	public String getChecked() {
		return checked;
	}
	public void setChecked(String checked) {
		this.checked = checked;
	}
}

+ 22 - 0
src/main/java/com/yihu/hos/rest/models/crawler/flow/resultModel/CrawlerDatasetResultModel.java

@ -0,0 +1,22 @@
package com.yihu.hos.rest.models.crawler.flow.resultModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterSchemeVersionModel;
import java.io.Serializable;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/4/27.
 */
public class CrawlerDatasetResultModel extends AdapterSchemeVersionModel implements Serializable {
    private String dataSets;
    public String getDataSets() {
        return dataSets;
    }
    public void setDataSets(String dataSets) {
        this.dataSets = dataSets;
    }
}

+ 30 - 0
src/main/java/com/yihu/hos/rest/models/crawler/flow/resultModel/FlowEntrance.java

@ -0,0 +1,30 @@
package com.yihu.hos.rest.models.crawler.flow.resultModel;
import java.io.Serializable;
/**
 *  编排入口
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/4/27.
 */
public class FlowEntrance implements Serializable {
    private String dataSet;
    private String meta;
    public String getDataSet() {
        return dataSet;
    }
    public void setDataSet(String dataSet) {
        this.dataSet = dataSet;
    }
    public String getMeta() {
        return meta;
    }
    public void setMeta(String meta) {
        this.meta = meta;
    }
}

+ 48 - 0
src/main/java/com/yihu/hos/rest/models/crawler/flow/resultModel/FlowLines.java

@ -0,0 +1,48 @@
package com.yihu.hos.rest.models.crawler.flow.resultModel;
import java.io.Serializable;
/**
 *  编排映射关系
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/4/27.
 */
public class FlowLines implements Serializable {
    private String from;
    private String to;
    private String fromPort;
    private String toPort;
    public String getFrom() {
        return from;
    }
    public void setFrom(String from) {
        this.from = from;
    }
    public String getTo() {
        return to;
    }
    public void setTo(String to) {
        this.to = to;
    }
    public String getFromPort() {
        return fromPort;
    }
    public void setFromPort(String fromPort) {
        this.fromPort = fromPort;
    }
    public String getToPort() {
        return toPort;
    }
    public void setToPort(String toPort) {
        this.toPort = toPort;
    }
}

+ 40 - 0
src/main/java/com/yihu/hos/rest/models/crawler/flow/resultModel/FlowMapping.java

@ -0,0 +1,40 @@
package com.yihu.hos.rest.models.crawler.flow.resultModel;
import java.io.Serializable;
import java.util.List;
/**
 * 适配方案映射数据类
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/4/28.
 */
public class FlowMapping implements Serializable {
    private List<FlowEntrance> entrances;
    private List<FlowLines> lines;
    private Integer schemeVersionId;
    public List<FlowEntrance> getEntrances() {
        return entrances;
    }
    public void setEntrances(List<FlowEntrance> entrances) {
        this.entrances = entrances;
    }
    public List<FlowLines> getLines() {
        return lines;
    }
    public void setLines(List<FlowLines> lines) {
        this.lines = lines;
    }
    public Integer getSchemeVersionId() {
        return schemeVersionId;
    }
    public void setSchemeVersionId(Integer schemeVersionId) {
        this.schemeVersionId = schemeVersionId;
    }
}

+ 47 - 0
src/main/java/com/yihu/hos/rest/models/crawler/flow/resultModel/MappingDataset.java

@ -0,0 +1,47 @@
package com.yihu.hos.rest.models.crawler.flow.resultModel;
import java.util.List;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/4/29.
 */
public class MappingDataset {
    private Long id;
    private String code;
    private String name;
    private List<MappingMetadata> data;
    public List<MappingMetadata> getData() {
        return data;
    }
    public void setData(List<MappingMetadata> data) {
        this.data = data;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}

+ 36 - 0
src/main/java/com/yihu/hos/rest/models/crawler/flow/resultModel/MappingMetadata.java

@ -0,0 +1,36 @@
package com.yihu.hos.rest.models.crawler.flow.resultModel;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/4/29.
 */
public class MappingMetadata {
    private Long id;
    private String code;
    private String name;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}

+ 112 - 0
src/main/java/com/yihu/hos/rest/models/crawler/patient/Patient.java

@ -0,0 +1,112 @@
package com.yihu.hos.rest.models.crawler.patient;
/**
 * @author Air
 * @version 1.0
 * @created 2015.08.14 10:12
 */
public class Patient {
    private String patientId;
    private String eventNo;
    private String localCardNo;
    private String idCard;
    private String orgCode;
    private String latestTime;
    private String referenceTime;
    private String reUploadFlg;
    private String jobTimeStamp;
    private String failType; //采集失败类型
    private String dataSet; //从哪个数据集采集
    public Patient() {
    }
    public String getDataSet() {
        return dataSet;
    }
    public void setDataSet(String dataSet) {
        this.dataSet = dataSet;
    }
    public String getPatientId() {
        return patientId;
    }
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public String getEventNo() {
        return eventNo;
    }
    public void setEventNo(String eventNo) {
        this.eventNo = eventNo;
    }
    public String getLocalCardNo() {
        return localCardNo;
    }
    public void setLocalCardNo(String localCardNo) {
        this.localCardNo = localCardNo;
    }
    public String getIdCard() {
        return idCard;
    }
    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    public String getLatestTime() {
        return latestTime;
    }
    public void setLatestTime(String latestTime) {
        this.latestTime = latestTime;
    }
    public String getReferenceTime() {
        return referenceTime;
    }
    public void setReferenceTime(String referenceTime) {
        this.referenceTime = referenceTime;
    }
    public String getJobTimeStamp() {
        return jobTimeStamp;
    }
    public void setJobTimeStamp(String jobTimeStamp) {
        this.jobTimeStamp = jobTimeStamp;
    }
    public String getReUploadFlg() {
        return reUploadFlg;
    }
    public void setReUploadFlg(String reUploadFlg) {
        this.reUploadFlg = reUploadFlg;
    }
    public String getFailType() {
        return failType;
    }
    public void setFailType(String failType) {
        this.failType = failType;
    }
}

+ 59 - 0
src/main/java/com/yihu/hos/rest/models/crawler/patient/PatientIdentity.java

@ -0,0 +1,59 @@
package com.yihu.hos.rest.models.crawler.patient;
import java.util.HashSet;
import java.util.Set;
/**
 * 病人身份标识
 * 病人ID, 事件号(门诊号,住院号等),卡号,身份证号
 * 目前使用的是病人ID和事件号
 *
 * @author Air
 * @version 1.0
 * @created 2015.06.16 16:29
 */
public class PatientIdentity {
    public static final String PATIENT_ID = "JDSA00_01_001";
    public static final String LOCAL_CARD_NO = "CARD_NO";
    public static final String ID_CARD = "DE02_01_030_00";
    public static Set<String> EVENT_NO_SET = new HashSet<>();
    private String eventNoCode;
    private String refTimeCode;
    public PatientIdentity(String eventNoCode, String refTimeCode) {
        this.eventNoCode = eventNoCode;
        this.refTimeCode = refTimeCode;
        EVENT_NO_SET.add(eventNoCode);
    }
    public static String getPatientIDCode() {
        return PATIENT_ID;
    }
    public static String getLocalCardNoCode() {
        return LOCAL_CARD_NO;
    }
    public static String getIdCardCode() {
        return ID_CARD;
    }
    public static Set<String> getEventNoSet() {
        return EVENT_NO_SET;
    }
    public static void addEventNoCode(String eventNoCode) {
        EVENT_NO_SET.add(eventNoCode);
    }
    public String getEventNoCode() {
        return eventNoCode;
    }
    public String getRefTimeCode() {
        return refTimeCode;
    }
}

+ 110 - 0
src/main/java/com/yihu/hos/rest/models/crawler/patient/PatientIndex.java

@ -0,0 +1,110 @@
package com.yihu.hos.rest.models.crawler.patient;
/**
 * 病人摘要标识
 *
 *
 * @author HXY
 * @version 1.0
 * @created 2016.03.01 13:50
 */
public class PatientIndex {
    public static final String PATIENT_ID = "PATIENT_ID";
    private String eventNoCode;
    private String refTimeCode;
//    private String organization;
    private String officeCode;
    private String officeName;
    private String leaveTime;
    private String diagDataSet;
    private String diagCode;
    private String diagName;
    private String diagType;
    public PatientIndex() {
    }
    public String getDiagType() {
        return diagType;
    }
    public void setDiagType(String diagType) {
        this.diagType = diagType;
    }
    public static String getPatientId() {
        return PATIENT_ID;
    }
    public String getEventNoCode() {
        return eventNoCode;
    }
    public void setEventNoCode(String eventNoCode) {
        this.eventNoCode = eventNoCode;
    }
    public String getRefTimeCode() {
        return refTimeCode;
    }
    public void setRefTimeCode(String refTimeCode) {
        this.refTimeCode = refTimeCode;
    }
//    public String getOrganization() {
//        return organization;
//    }
//
//    public void setOrganization(String organization) {
//        this.organization = organization;
//    }
    public String getOfficeCode() {
        return officeCode;
    }
    public void setOfficeCode(String officeCode) {
        this.officeCode = officeCode;
    }
    public String getOfficeName() {
        return officeName;
    }
    public void setOfficeName(String officeName) {
        this.officeName = officeName;
    }
    public String getLeaveTime() {
        return leaveTime;
    }
    public void setLeaveTime(String leaveTime) {
        this.leaveTime = leaveTime;
    }
    public String getDiagDataSet() {
        return diagDataSet;
    }
    public void setDiagDataSet(String diagDataSet) {
        this.diagDataSet = diagDataSet;
    }
    public String getDiagCode() {
        return diagCode;
    }
    public void setDiagCode(String diagCode) {
        this.diagCode = diagCode;
    }
    public String getDiagName() {
        return diagName;
    }
    public void setDiagName(String diagName) {
        this.diagName = diagName;
    }
}

+ 138 - 0
src/main/java/com/yihu/hos/rest/models/crawler/qc/QcDaily.java

@ -0,0 +1,138 @@
package com.yihu.hos.rest.models.crawler.qc;
import java.util.ArrayList;
import java.util.List;
/**
 * 质控-日报
 *
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/6/1.
 */
public class QcDaily {
    private String org_code;
    private String create_date;
    private String inner_version;
    private Integer total_outpatient_num;
    private Integer real_outpatient_num;
    private Integer total_hospital_num;
    private Integer real_hospital_num;
    private List<QcPatientIndex> total_outpatient = new ArrayList<>();
    private List<QcPatientIndex> real_outpatient = new ArrayList<>();
    private List<QcPatientIndex> total_hospital = new ArrayList<>();
    private List<QcPatientIndex> real_hospital = new ArrayList<>();
    ;
    public void addTotal(QcPatientIndex patientIndex, String dataSet) {
        if ("HDSC01_02".equals(dataSet)) {
            this.total_outpatient.add(patientIndex);
        } else if ("HDSC02_09".equals(dataSet)) {
            this.total_hospital.add(patientIndex);
        } else {
            return;
        }
    }
    public void addReal(QcPatientIndex patientIndex, String dataSet) {
        if ("HDSC01_02".equals(dataSet)) {//门诊
            this.real_outpatient.add(patientIndex);
        } else if ("HDSC02_09".equals(dataSet)) {//住院
            this.real_hospital.add(patientIndex);
        } else {
            return;
        }
    }
    public String getOrg_code() {
        return org_code;
    }
    public void setOrg_code(String org_code) {
        this.org_code = org_code;
    }
    public String getCreate_date() {
        return create_date;
    }
    public void setCreate_date(String create_date) {
        this.create_date = create_date;
    }
    public String getInner_version() {
        return inner_version;
    }
    public void setInner_version(String inner_version) {
        this.inner_version = inner_version;
    }
    public Integer getTotal_outpatient_num() {
        return total_outpatient_num;
    }
    public void setTotal_outpatient_num(Integer total_outpatient_num) {
        this.total_outpatient_num = total_outpatient_num;
    }
    public Integer getReal_outpatient_num() {
        return real_outpatient_num;
    }
    public void setReal_outpatient_num(Integer real_outpatient_num) {
        this.real_outpatient_num = real_outpatient_num;
    }
    public Integer getTotal_hospital_num() {
        return total_hospital_num;
    }
    public void setTotal_hospital_num(Integer total_hospital_num) {
        this.total_hospital_num = total_hospital_num;
    }
    public Integer getReal_hospital_num() {
        return real_hospital_num;
    }
    public void setReal_hospital_num(Integer real_hospital_num) {
        this.real_hospital_num = real_hospital_num;
    }
    public List<QcPatientIndex> getTotal_outpatient() {
        return total_outpatient;
    }
    public void setTotal_outpatient(List<QcPatientIndex> total_outpatient) {
        this.total_outpatient = total_outpatient;
    }
    public List<QcPatientIndex> getReal_outpatient() {
        return real_outpatient;
    }
    public void setReal_outpatient(List<QcPatientIndex> real_outpatient) {
        this.real_outpatient = real_outpatient;
    }
    public List<QcPatientIndex> getTotal_hospital() {
        return total_hospital;
    }
    public void setTotal_hospital(List<QcPatientIndex> total_hospital) {
        this.total_hospital = total_hospital;
    }
    public List<QcPatientIndex> getReal_hospital() {
        return real_hospital;
    }
    public void setReal_hospital(List<QcPatientIndex> real_hospital) {
        this.real_hospital = real_hospital;
    }
}

+ 42 - 0
src/main/java/com/yihu/hos/rest/models/crawler/qc/QcPatientIndex.java

@ -0,0 +1,42 @@
package com.yihu.hos.rest.models.crawler.qc;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/6/1.
 */
public class QcPatientIndex {
    private String patient_id;
    private String event_no;
    private String event_time;
    public QcPatientIndex(String patient_id, String event_no, String event_time) {
        this.patient_id = patient_id;
        this.event_time = event_time;
        this.event_no = event_no;
    }
    public String getPatient_id() {
        return patient_id;
    }
    public void setPatient_id(String patient_id) {
        this.patient_id = patient_id;
    }
    public String getEvent_no() {
        return event_no;
    }
    public void setEvent_no(String event_no) {
        this.event_no = event_no;
    }
    public String getEvent_time() {
        return event_time;
    }
    public void setEvent_time(String event_time) {
        this.event_time = event_time;
    }
}

+ 120 - 0
src/main/java/com/yihu/hos/rest/models/crawler/qc/QcRuleModel.java

@ -0,0 +1,120 @@
package com.yihu.hos.rest.models.crawler.qc;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.io.Serializable;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/6/6.
 */
@Entity
@Table(name = "qc_rule")
public class QcRuleModel implements Serializable {
    @Id
    @Column(name="id",length = 50)
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    private String id;
    @Column(name="name",length = 255,nullable = true)
    private String name;//名称
    @Column(name="code",length = 50,nullable = false)
    private String code;//编码
    @Column(name="type",length = 20,nullable = true)
    private String type;//类型:完整性-1,及时性-2,准确性-3
    @Column(name="description",length = 1000,nullable = false)
    private String description;//描述
    @Column(name="rule",length = 255,nullable = true)
    private String rule; // 规则校验地址
    @Column(name="error_code",length = 50,nullable = false)
    private String errorCode;//统一错误代码
    // 临时属性
    private String typeName; // 分类名称
    private String errorCodeName; // 统一错误代码名称
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public String getRule() {
        return rule;
    }
    public void setRule(String rule) {
        this.rule = rule;
    }
    public String getErrorCode() {
        return errorCode;
    }
    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }
    @Formula("( SELECT b.value FROM qc_rule a LEFT JOIN system_dict b ON b.code = a.type WHERE a.id = id )")
    public String getTypeName() {
        return typeName;
    }
    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }
    @Formula("( SELECT b.value FROM qc_rule a LEFT JOIN system_dict b ON b.code = a.error_code WHERE a.id = id )")
    public String getErrorCodeName() {
        return errorCodeName;
    }
    public void setErrorCodeName(String errorCodeName) {
        this.errorCodeName = errorCodeName;
    }
}

+ 9 - 0
src/main/java/com/yihu/hos/rest/models/crawler/transform/DictDataType.java

@ -0,0 +1,9 @@
package com.yihu.hos.rest.models.crawler.transform;
/**
 * Created by Administrator on 2015/9/16.
 */
public enum DictDataType {
    VALUE, //值
    CODE //编码
}

+ 65 - 0
src/main/java/com/yihu/hos/rest/models/crawler/transform/EhrCondition.java

@ -0,0 +1,65 @@
package com.yihu.hos.rest.models.crawler.transform;
/**
 * 集成平台采集条件基类
 * Created by HZY on 2016/2/25.
 */
public class EhrCondition {
    private String andOr;
    private String field;
    private String condition;
    private String value;
    public EhrCondition(String condition, String field, String value){
        this.andOr=" AND ";
        this.field=field;
        this.condition=condition;
        this.value=value;
    }
    public void andQuery(String condition,String field,String value){
        this.andOr=" AND ";
        this.field=field;
        this.condition=condition;
        this.value=value;
    }
    public void orQuery(String condition,String field,String value){
        this.andOr=" OR ";
        this.field=field;
        this.condition=condition;
        this.value=value;
    }
    public String getAndOr() {
        return andOr;
    }
    public void setAndOr(String andOr) {
        this.andOr = andOr;
    }
    public String getField() {
        return field;
    }
    public void setField(String field) {
        this.field = field;
    }
    public String getCondition() {
        return condition;
    }
    public void setCondition(String condition) {
        this.condition = condition;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
}

+ 15 - 0
src/main/java/com/yihu/hos/rest/models/crawler/transform/IVerifier.java

@ -0,0 +1,15 @@
package com.yihu.hos.rest.models.crawler.transform;
/**
 * @author Airhead
 * @version 1.0
 * @created 22-5-2015 11:24:26
 */
public interface IVerifier {
    /**
     */
    boolean check();
    String getErrorInfo();
}

+ 12 - 0
src/main/java/com/yihu/hos/rest/models/crawler/transform/LogicValues.java

@ -0,0 +1,12 @@
package com.yihu.hos.rest.models.crawler.transform;
/**
 * Created by HZY on 2016/1/29.
 */
public class LogicValues {
    public static final String LOGIC_OK = "ok";
    public static final String LOGIC_NO = "no";
    public static final String LOGIC_TRUE = "true";
    public static final String LOGIC_FALSE = "false";
}

+ 45 - 0
src/main/java/com/yihu/hos/rest/models/crawler/transform/MetaDataType.java

@ -0,0 +1,45 @@
package com.yihu.hos.rest.models.crawler.transform;
/**
 * 数据元类型
 *
 * @created Created by Air on 2015/6/9.
 */
public enum MetaDataType {
    /**
     * 字符,不可枚举
     */
    S1,
    /**
     * 字符,枚举<=3个
     */
    S2,
    /**
     * 字符,代码表
     */
    S3,
    /**
     * 布尔,0(False),1(True)
     */
    L,
    /**
     * 数值,
     */
    N,
    /**
     * 日期
     */
    D,
    /**
     * 时间日期
     */
    DT,
    /**
     * 时间
     */
    T,
    /**
     * 二进制
     */
    BY
}

+ 21 - 0
src/main/java/com/yihu/hos/rest/models/crawler/transform/TransformType.java

@ -0,0 +1,21 @@
package com.yihu.hos.rest.models.crawler.transform;
/**
 * @created  Air on 2015/6/8.
 */
public enum TransformType {
    /**
     * 数据集
     */
    DATA_SET_JSON,
    DATA_SET_XML,
    /**
     * CDA
     */
    CDA_JSON,
    CDA_XML,
    /**
     * 非结构化
     */
    DOCUMENT,
}

+ 35 - 0
src/main/java/com/yihu/hos/rest/models/qlc/QLCPushReturnModel.java

@ -0,0 +1,35 @@
package com.yihu.hos.rest.models.qlc;
/**
 * Created by Administrator on 2016/6/28.
 */
public class QLCPushReturnModel {
    private String status = "0";
    private String statusInfo = "请求成功";
    private String data;
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public String getStatusInfo() {
        return statusInfo;
    }
    public void setStatusInfo(String statusInfo) {
        this.statusInfo = statusInfo;
    }
    public String getData() {
        return data;
    }
    public void setData(String data) {
        this.data = data;
    }
}

+ 37 - 0
src/main/java/com/yihu/hos/rest/models/qlc/QLCResponseResult.java

@ -0,0 +1,37 @@
package com.yihu.hos.rest.models.qlc;
/**
 * Created by Administrator on 2016/4/25.
 */
public class QLCResponseResult {
    /**
     * 0:接口数据请求正常
     * ≠0:接口响应数据异常
     */
    private String status = "0";
    /**
     * 当出错的时候,返回出错的说明,如下:
     * {
     * "status": 1,
     * "statusInfo": "传入参数错误",
     * "data": []
     * }
     */
    private String statusInfo="推送数据成功";
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public String getStatusInfo() {
        return statusInfo;
    }
    public void setStatusInfo(String statusInfo) {
        this.statusInfo = statusInfo;
    }
}

+ 46 - 0
src/main/java/com/yihu/hos/rest/models/rs/DtoDatasetCol.java

@ -0,0 +1,46 @@
package com.yihu.hos.rest.models.rs;
/**
 * 数据集字段
 */
public class DtoDatasetCol implements java.io.Serializable {
	private String code;
	private String text;
	private String type;
	private String dict;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getDict() {
		return dict;
	}
	public void setDict(String dict) {
		this.dict = dict;
	}
}

+ 48 - 0
src/main/java/com/yihu/hos/rest/models/rs/DtoDictCol.java

@ -0,0 +1,48 @@
package com.yihu.hos.rest.models.rs;
import org.json.JSONArray;
/**
 * 数据源关联字典
 */
public class DtoDictCol implements java.io.Serializable {
    private String stdMetadataCode;
    private String adapterDataType;
    private String stdDictId;
    private JSONArray dictList;
    public String getStdMetadataCode() {
        return stdMetadataCode;
    }
    public void setStdMetadataCode(String stdMetadataCode) {
        this.stdMetadataCode = stdMetadataCode;
    }
    public String getAdapterDataType() {
        return adapterDataType;
    }
    public void setAdapterDataType(String adapterDataType) {
        this.adapterDataType = adapterDataType;
    }
    public String getStdDictId() {
        return stdDictId;
    }
    public void setStdDictId(String stdDictId) {
        this.stdDictId = stdDictId;
    }
    public JSONArray getDictList() {
        return dictList;
    }
    public void setDictList(JSONArray dictList) {
        this.dictList = dictList;
    }
}

+ 35 - 0
src/main/java/com/yihu/hos/rest/models/rs/DtoJobConfig.java

@ -0,0 +1,35 @@
package com.yihu.hos.rest.models.rs;
/**
 * RsJobConfig entity. @author MyEclipse Persistence Tools
 */
public class DtoJobConfig extends RsJobConfig implements java.io.Serializable {
	private String schemeAndVersion;
	private String jobDataset;
	private String jobPlan;
	public String getSchemeAndVersion() {
		return schemeAndVersion;
	}
	public void setSchemeAndVersion(String schemeAndVersion) {
		this.schemeAndVersion = schemeAndVersion;
	}
	public String getJobDataset() {
		return jobDataset;
	}
	public void setJobDataset(String jobDataset) {
		this.jobDataset = jobDataset;
	}
	public String getJobPlan() {
		return jobPlan;
	}
	public void setJobPlan(String jobPlan) {
		this.jobPlan = jobPlan;
	}
}

+ 74 - 0
src/main/java/com/yihu/hos/rest/models/rs/DtoJobDataset.java

@ -0,0 +1,74 @@
package com.yihu.hos.rest.models.rs;
/**
 * RsJobDataset entity. @author MyEclipse Persistence Tools
 */
public class DtoJobDataset extends RsJobDataset implements java.io.Serializable {
	private String checked;
	private String jobDatasetCode;
	/** 数据源相关 **/
	private String orgCode;
	private String datasourceId;
	private String datasourceName;
	private String config;
	private String type;
	public String getOrgCode() {
		return orgCode;
	}
	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}
	public String getChecked() {
		return checked;
	}
	public void setChecked(String checked) {
		this.checked = checked;
	}
	public String getJobDatasetCode() {
		return jobDatasetCode;
	}
	public void setJobDatasetCode(String jobDatasetCode) {
		this.jobDatasetCode = jobDatasetCode;
	}
	public String getDatasourceId() {
		return datasourceId;
	}
	public void setDatasourceId(String datasourceId) {
		this.datasourceId = datasourceId;
	}
	public String getDatasourceName() {
		return datasourceName;
	}
	public void setDatasourceName(String datasourceName) {
		this.datasourceName = datasourceName;
	}
	public String getConfig() {
		return config;
	}
	public void setConfig(String config) {
		this.config = config;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
}

+ 36 - 0
src/main/java/com/yihu/hos/rest/models/rs/DtoJobLog.java

@ -0,0 +1,36 @@
package com.yihu.hos.rest.models.rs;
/**
 * add by hzp at 20160204
 */
public class DtoJobLog extends RsJobLog implements java.io.Serializable {
	private Integer count;
	private Integer success;
	private Integer repeatNum;
	public Integer getCount() {
		return count;
	}
	public void setCount(Integer count) {
		this.count = count;
	}
	public Integer getSuccess() {
		return success;
	}
	public void setSuccess(Integer success) {
		this.success = success;
	}
	public Integer getRepeatNum() {
		return repeatNum;
	}
	public void setRepeatNum(Integer repeatNum) {
		this.repeatNum = repeatNum;
	}
}

+ 75 - 0
src/main/java/com/yihu/hos/rest/models/rs/RsDatapushLog.java

@ -0,0 +1,75 @@
package com.yihu.hos.rest.models.rs;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
/**
 * RsJobLog entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "rs_datapush_log")
public class RsDatapushLog implements java.io.Serializable {
	// Fields
	@Id
	@Column(name="id",length = 50)
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid")
	private String id;
	@Column(name="type",length = 50,nullable = true)
	private String type;
	@Column(name="success",length = 50,nullable = true)
	private String success;
	@Column(name="content",length = 2000,nullable = true)
	private String content;
	@Column(name="datetime")
	private Date datetime;
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getSuccess() {
		return success;
	}
	public void setSuccess(String success) {
		this.success = success;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public Date getDatetime() {
		return datetime;
	}
	public void setDatetime(Date datetime) {
		this.datetime = datetime;
	}
}

+ 211 - 0
src/main/java/com/yihu/hos/rest/models/rs/RsJobConfig.java

@ -0,0 +1,211 @@
package com.yihu.hos.rest.models.rs;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
/**
 * RsJobConfig entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "rs_job_config")
public class RsJobConfig implements java.io.Serializable {
	// Fields
	@Id
	@Column(name="id",length = 50)
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid")
	private String id;
	@Column(name="job_name",length = 50,nullable = true)
	private String jobName;//任务名称
	@Column(name="job_info",length = 200)
	private String jobInfo;//任务描述
	@Column(name="job_type",length = 10)
	private String jobType;//任务类型(0--单次执行 1--周期执行 2--监听任务)
	@Column(name="scheme_id",length = 50)
	private String schemeId;//适配方案
	@Column(name="scheme_version",length = 50)
	private String schemeVersion;//适配方案版本
	@Column(name="job_next_time")
	private Date jobNextTime;//任务下次执行时间
	@Column(name="valid",length = 10,nullable = true)
	private String valid;//是否有效
	@Column(name="job_content",length = 50)
	private String jobContent;//任务内容
	@Column(name="job_content_type",length = 10)
	private String jobContentType;//任务内容类型
	@Column(name="repeat_start_Time")
	private Date repeatStartTime;//采集开始时间
	@Column(name="repeat_end_Time")
	private Date repeatEndTime;//采集结束时间
	@Column(name="delay_time")
	private Integer delayTime;//延迟时间
	@Column(name="flow_id")
	private Integer flowId;//流程ID
	@Column(name="flow_temp_id")
	private Integer flowTempId;//流程模板ID
	// Constructors
	/** default constructor */
	public RsJobConfig() {
	}
	public Integer getFlowTempId() {
		return flowTempId;
	}
	public void setFlowTempId(Integer flowTempId) {
		this.flowTempId = flowTempId;
	}
	public Integer getFlowId() {
		return flowId;
	}
	public void setFlowId(Integer flowId) {
		this.flowId = flowId;
	}
	public String getJobContent() {
		return jobContent;
	}
	public void setJobContent(String jobContent) {
		this.jobContent = jobContent;
	}
	public String getJobContentType() {
		return jobContentType;
	}
	public void setJobContentType(String jobContentType) {
		this.jobContentType = jobContentType;
	}
	/** minimal constructor */
	public RsJobConfig(String jobName, String valid) {
		this.jobName = jobName;
		this.valid = valid;
	}
	/** full constructor */
	public RsJobConfig(String jobName, String jobInfo, String jobType, String schemeId,String schemeVersion, String jobTimeInterval, Date jobNextTime, String valid) {
		this.jobName = jobName;
		this.jobInfo = jobInfo;
		this.jobType = jobType;
		this.schemeId = schemeId;
		this.schemeVersion = schemeVersion;
		this.jobNextTime = jobNextTime;
		this.valid = valid;
	}
	// Property accessors
	public String getId() {
		return this.id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getJobName() {
		return this.jobName;
	}
	public void setJobName(String jobName) {
		this.jobName = jobName;
	}
	public String getJobInfo() {
		return this.jobInfo;
	}
	public void setJobInfo(String jobInfo) {
		this.jobInfo = jobInfo;
	}
	public String getJobType() {
		return this.jobType;
	}
	public void setJobType(String jobType) {
		this.jobType = jobType;
	}
	public String getSchemeId() {
		return schemeId;
	}
	public void setSchemeId(String schemeId) {
		this.schemeId = schemeId;
	}
	public String getSchemeVersion() {
		return schemeVersion;
	}
	public void setSchemeVersion(String schemeVersion) {
		this.schemeVersion = schemeVersion;
	}
	public Date getJobNextTime() {
		return this.jobNextTime;
	}
	public void setJobNextTime(Date jobNextTime) {
		this.jobNextTime = jobNextTime;
	}
	public String getValid() {
		return this.valid;
	}
	public void setValid(String valid) {
		this.valid = valid;
	}
	public Date getRepeatStartTime() {
		return repeatStartTime;
	}
	public void setRepeatStartTime(Date repeatStartTime) {
		this.repeatStartTime = repeatStartTime;
	}
	public Date getRepeatEndTime() {
		return repeatEndTime;
	}
	public void setRepeatEndTime(Date repeatEndTime) {
		this.repeatEndTime = repeatEndTime;
	}
	public Integer getDelayTime() {
		return delayTime;
	}
	public void setDelayTime(Integer delayTime) {
		this.delayTime = delayTime;
	}
}

+ 142 - 0
src/main/java/com/yihu/hos/rest/models/rs/RsJobDataset.java

@ -0,0 +1,142 @@
package com.yihu.hos.rest.models.rs;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
/**
 * RsJobDataset entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "rs_job_dataset")
public class RsJobDataset implements java.io.Serializable {
	// Fields
	@Id
	@Column(name="id",length = 50)
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid")
	private String id;
	@Column(name="job_id",length = 50,nullable = true)
	private String jobId;//任务id
	@Column(name="job_dataset_id",length = 50,nullable = true)
	private String jobDatasetId;//数据集id
	@Column(name="job_dataset_name",length = 50)
	private String jobDatasetName;//数据集中文名(冗余)
	@Column(name="job_dataset_key",length = 50)
	private String jobDatasetKey;//数据集增量字段
	@Column(name="job_dataset_keytype",length = 50)
	private String jobDatasetKeytype;//数据集增量字段类型
	@Column(name="job_dataset_keyvalue",length = 50)
	private String jobDatasetKeyvalue;//数据集关联主键值(最大值)
	@Column(name="job_dataset_condition",length = 1000)
	private String jobDatasetCondition;//数据集过滤条件
	@Column(name="sort")
	private Integer sort;//排序
	// Constructors
	/** default constructor */
	public RsJobDataset() {
	}
	public String getJobDatasetKey() {
		return jobDatasetKey;
	}
	public void setJobDatasetKey(String jobDatasetKey) {
		this.jobDatasetKey = jobDatasetKey;
	}
	public String getJobDatasetKeytype() {
		return jobDatasetKeytype;
	}
	public void setJobDatasetKeytype(String jobDatasetKeytype) {
		this.jobDatasetKeytype = jobDatasetKeytype;
	}
	/** minimal constructor */
	public RsJobDataset(String jobId, String jobDatasetId) {
		this.jobId = jobId;
		this.jobDatasetId = jobDatasetId;
	}
	/** full constructor */
	public RsJobDataset(String jobId, String jobDatasetId, String jobDatasetName, String jobDatasetKeyvalue, String jobDatasetCondition, Integer sort) {
		this.jobId = jobId;
		this.jobDatasetId = jobDatasetId;
		this.jobDatasetName = jobDatasetName;
		this.jobDatasetKeyvalue = jobDatasetKeyvalue;
		this.jobDatasetCondition = jobDatasetCondition;
		this.sort = sort;
	}
	// Property accessors
	public String getId() {
		return this.id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getJobId() {
		return this.jobId;
	}
	public void setJobId(String jobId) {
		this.jobId = jobId;
	}
	public String getJobDatasetId() {
		return this.jobDatasetId;
	}
	public void setJobDatasetId(String jobDatasetId) {
		this.jobDatasetId = jobDatasetId;
	}
	public String getJobDatasetName() {
		return this.jobDatasetName;
	}
	public void setJobDatasetName(String jobDatasetName) {
		this.jobDatasetName = jobDatasetName;
	}
	public String getJobDatasetKeyvalue() {
		return this.jobDatasetKeyvalue;
	}
	public void setJobDatasetKeyvalue(String jobDatasetKeyvalue) {
		this.jobDatasetKeyvalue = jobDatasetKeyvalue;
	}
	public String getJobDatasetCondition() {
		return this.jobDatasetCondition;
	}
	public void setJobDatasetCondition(String jobDatasetCondition) {
		this.jobDatasetCondition = jobDatasetCondition;
	}
	public Integer getSort() {
		return this.sort;
	}
	public void setSort(Integer sort) {
		this.sort = sort;
	}
}

+ 106 - 0
src/main/java/com/yihu/hos/rest/models/rs/RsJobLog.java

@ -0,0 +1,106 @@
package com.yihu.hos.rest.models.rs;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
/**
 * RsJobLog entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "rs_job_log")
public class RsJobLog implements java.io.Serializable {
	// Fields
	@Id
	@Column(name="id",length = 50)
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid")
	private String id;
	@Column(name="job_start_time")
	private Date jobStartTime;//任务开始执行时间
	@Column(name="job_end_time")
	private Date jobEndTime;//任务结束执行时间
	@Column(name="job_id",length = 50,nullable = true)
	private String jobId;//任务id
	@Column(name="job_content",length = 1000)
	private String jobContent;//任务执行情况
	@Column(name="Job_dataset_count")
	private Integer jobDatasetCount;//执行数据集总数
	@Column(name="Job_dataset_success")
	private Integer jobDatasetSuccess;//成功数据集总数
	// Constructors
	/** default constructor */
	public RsJobLog() {
	}
	// Property accessors
	public String getId() {
		return this.id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public Date getJobStartTime() {
		return jobStartTime;
	}
	public void setJobStartTime(Date jobStartTime) {
		this.jobStartTime = jobStartTime;
	}
	public Date getJobEndTime() {
		return jobEndTime;
	}
	public void setJobEndTime(Date jobEndTime) {
		this.jobEndTime = jobEndTime;
	}
	public Integer getJobDatasetCount() {
		return jobDatasetCount;
	}
	public void setJobDatasetCount(Integer jobDatasetCount) {
		this.jobDatasetCount = jobDatasetCount;
	}
	public Integer getJobDatasetSuccess() {
		return jobDatasetSuccess;
	}
	public void setJobDatasetSuccess(Integer jobDatasetSuccess) {
		this.jobDatasetSuccess = jobDatasetSuccess;
	}
	public String getJobId() {
		return this.jobId;
	}
	public void setJobId(String jobId) {
		this.jobId = jobId;
	}
	public String getJobContent() {
		return this.jobContent;
	}
	public void setJobContent(String jobContent) {
		this.jobContent = jobContent;
	}
}

+ 234 - 0
src/main/java/com/yihu/hos/rest/models/rs/RsJobLogDetail.java

@ -0,0 +1,234 @@
package com.yihu.hos.rest.models.rs;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
/**
 * RsJobLogDetail entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "rs_job_log_detail")
public class RsJobLogDetail implements java.io.Serializable {
	// Fields
	@Id
	@Column(name="id",length = 50)
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid")
	private String id;
	@Column(name="start_time")
	private Date startTime;//开始执行时间
	@Column(name="end_time")
	private Date endTime;//结束执行时间
	@Column(name="job_log_id",length=10)
	private String jobLogId;//主日志ID
	@Column(name="job_status",length=10)
	private String jobStatus;//是否执行成功
	@Column(name="job_content",length = 1000)
	private String jobContent;//任务执行情况
	@Column(name="datasource_id",length = 50)
	private String datasourceId;//数据源ID
	@Column(name="config",length = 200)
	private String config;//数据源配置
	@Column(name="std_dataset_code",length = 50)
	private String stdDatasetCode;//标准数据集名称
	@Column(name="job_dataset_id",length = 50)
	private String jobDatasetId;//数据集id
	@Column(name="job_id",length = 50)
	private String jobId;//任务ID
	@Column(name="job_dataset_name",length = 50)
	private String jobDatasetName;//数据集中文名
	@Column(name="job_sql",length = 4000)
	private String jobSql;//采集sql语句
	@Column(name="job_num",length = 50)
	private Integer jobNum;//分页采集页码
	@Column(name="repeat_start_time")
	private Date repeatStartTime;//补采开始时间
	@Column(name="repeat_end_time")
	private Date repeatEndTime;//补采结束时间
	@Column(name="repeat_job_content",length = 4000)
	private String repeatJobContent;//补采执行情况
	@Column(name="scheme_version",length = 50)
	private String schemeVersion;//标准版本号
	@Column(name="job_dataset_rows")
	private Integer jobDatasetRows;//采集行数
	// Constructors
	/** default constructor */
	public RsJobLogDetail() {
	}
	// Property accessors
	public String getId() {
		return this.id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public Date getStartTime() {
		return this.startTime;
	}
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	public Date getEndTime() {
		return this.endTime;
	}
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	public String getJobLogId() {
		return jobLogId;
	}
	public void setJobLogId(String jobLogId) {
		this.jobLogId = jobLogId;
	}
	public String getJobStatus() {
		return jobStatus;
	}
	public void setJobStatus(String jobStatus) {
		this.jobStatus = jobStatus;
	}
	public String getJobContent() {
		return this.jobContent;
	}
	public void setJobContent(String jobContent) {
		this.jobContent = jobContent;
	}
	public String getDatasourceId() {
		return datasourceId;
	}
	public void setDatasourceId(String datasourceId) {
		this.datasourceId = datasourceId;
	}
	public String getConfig() {
		return config;
	}
	public void setConfig(String config) {
		this.config = config;
	}
	public String getStdDatasetCode() {
		return stdDatasetCode;
	}
	public void setStdDatasetCode(String stdDatasetCode) {
		this.stdDatasetCode = stdDatasetCode;
	}
	public String getJobDatasetId() {
		return jobDatasetId;
	}
	public void setJobDatasetId(String jobDatasetId) {
		this.jobDatasetId = jobDatasetId;
	}
	public String getJobId() {
		return jobId;
	}
	public void setJobId(String jobId) {
		this.jobId = jobId;
	}
	public String getJobDatasetName() {
		return jobDatasetName;
	}
	public void setJobDatasetName(String jobDatasetName) {
		this.jobDatasetName = jobDatasetName;
	}
	public String getJobSql() {
		return jobSql;
	}
	public void setJobSql(String jobSql) {
		this.jobSql = jobSql;
	}
	public Integer getJobNum() {
		return jobNum;
	}
	public void setJobNum(Integer jobNum) {
		this.jobNum = jobNum;
	}
	public Date getRepeatStartTime() {
		return repeatStartTime;
	}
	public void setRepeatStartTime(Date repeatStartTime) {
		this.repeatStartTime = repeatStartTime;
	}
	public Date getRepeatEndTime() {
		return repeatEndTime;
	}
	public void setRepeatEndTime(Date repeatEndTime) {
		this.repeatEndTime = repeatEndTime;
	}
	public String getRepeatJobContent() {
		return repeatJobContent;
	}
	public void setRepeatJobContent(String repeatJobContent) {
		this.repeatJobContent = repeatJobContent;
	}
	public String getSchemeVersion() {
		return schemeVersion;
	}
	public void setSchemeVersion(String schemeVersion) {
		this.schemeVersion = schemeVersion;
	}
	public Integer getJobDatasetRows() {
		return jobDatasetRows;
	}
	public void setJobDatasetRows(Integer jobDatasetRows) {
		this.jobDatasetRows = jobDatasetRows;
	}
}

+ 106 - 0
src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterDatasetModel.java

@ -0,0 +1,106 @@
package com.yihu.hos.rest.models.standard.adapter;
import com.yihu.hos.web.framework.model.Result;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;
/**
 * Created by lingfeng on 2015/9/16.
 */
public class AdapterDatasetModel extends Result implements Serializable {
    @Id
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "increment")
    @Column(name = "id")
    private Long id;
    @Column(name = "scheme_id")
    private Long schemeId;
    @Column(name = "std_dataset_id")
    private Long stdDatasetId;
    @Column(name = "std_dataset_code")
    private String stdDatasetCode;
    @Column(name = "std_dataset_name")
    private String stdDatasetName;
    @Column(name = "adapter_dataset_id")
    private String adapterDatasetId;
    @Column(name = "adapter_dataset_code")
    private String adapterDatasetCode;
    @Column(name = "adapter_dataset_name")
    private String adapterDatasetName;
    public static AdapterDatasetModel error(String message) {
        AdapterDatasetModel re= new AdapterDatasetModel();
        re.successFlg = false;
        re.message = message;
        return re;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(Long schemeId) {
        this.schemeId = schemeId;
    }
    public Long getStdDatasetId() {
        return stdDatasetId;
    }
    public void setStdDatasetId(Long stdDatasetId) {
        this.stdDatasetId = stdDatasetId;
    }
    public String getStdDatasetCode() {
        return stdDatasetCode;
    }
    public void setStdDatasetCode(String stdDatasetCode) {
        this.stdDatasetCode = stdDatasetCode;
    }
    public String getStdDatasetName() {
        return stdDatasetName;
    }
    public void setStdDatasetName(String stdDatasetName) {
        this.stdDatasetName = stdDatasetName;
    }
    public String getAdapterDatasetId() {
        return adapterDatasetId;
    }
    public void setAdapterDatasetId(String adapterDatasetId) {
        this.adapterDatasetId = adapterDatasetId;
    }
    public String getAdapterDatasetCode() {
        return adapterDatasetCode;
    }
    public void setAdapterDatasetCode(String adapterDatasetCode) {
        this.adapterDatasetCode = adapterDatasetCode;
    }
    public String getAdapterDatasetName() {
        return adapterDatasetName;
    }
    public void setAdapterDatasetName(String adapterDatasetName) {
        this.adapterDatasetName = adapterDatasetName;
    }
}

+ 68 - 0
src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterDatasetRelationModel.java

@ -0,0 +1,68 @@
package com.yihu.hos.rest.models.standard.adapter;
import com.yihu.hos.web.framework.model.Result;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;
/**
 * Created by lingfeng on 2015/9/16.
 */
public class AdapterDatasetRelationModel extends Result implements Serializable {
    @Id
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "increment")
    @Column(name = "id")
    private Integer id;
    @Column(name = "scheme_id")
    private Integer schemeId;
    @Column(name = "master_dataset_id")
    private Integer masterdatasetId;
    @Column(name = "master_metadata_id")
    private Integer masterMetadataId;
    @Column(name = "foreign_metadata_id")
    private Integer foreignMetadataId;
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public Integer getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(Integer schemeId) {
        this.schemeId = schemeId;
    }
    public Integer getMasterdatasetId() {
        return masterdatasetId;
    }
    public void setMasterdatasetId(Integer masterdatasetId) {
        this.masterdatasetId = masterdatasetId;
    }
    public Integer getMasterMetadataId() {
        return masterMetadataId;
    }
    public void setMasterMetadataId(Integer masterMetadataId) {
        this.masterMetadataId = masterMetadataId;
    }
    public Integer getForeignMetadataId() {
        return foreignMetadataId;
    }
    public void setForeignMetadataId(Integer foreignMetadataId) {
        this.foreignMetadataId = foreignMetadataId;
    }
}

+ 138 - 0
src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterDictEntryModel.java

@ -0,0 +1,138 @@
package com.yihu.hos.rest.models.standard.adapter;
import com.yihu.hos.web.framework.model.Result;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;
/**
 * Created by lingfeng on 2015/9/16.
 */
public class AdapterDictEntryModel extends Result implements Serializable {
    @Id
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "increment")
    @Column(name = "id")
    private Long id;
    @Column(name = "scheme_id")
    private Long schemeId;
    @Column(name = "std_dict_id")
    private Long stdDictId;
    @Column(name = "std_entry_id")
    private Long stdEntryId;
    @Column(name = "std_entry_code")
    private String stdEntryCode;
    @Column(name = "std_entry_value")
    private String stdEntryValue;
    @Column(name = "adapter_dict_id")
    private Long adapterDictId;
    @Column(name = "adapter_entry_id")
    private Long adapterEntryId;
    @Column(name = "adapter_entry_code")
    private String adapterEntryCode;
    @Column(name = "adapter_entry_value")
    private String adapterEntryValue;
    @Column(name = "adapter_info")
    private String adapterInfo;
    /**
     * 错误消息
     */
    public static AdapterDictEntryModel error(String message) {
        AdapterDictEntryModel re= new AdapterDictEntryModel();
        re.successFlg = false;
        re.message = message;
        return re;
    }
    public String getAdapterInfo() {
        return adapterInfo;
    }
    public void setAdapterInfo(String adapterInfo) {
        this.adapterInfo = adapterInfo;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(Long schemeId) {
        this.schemeId = schemeId;
    }
    public Long getStdDictId() {
        return stdDictId;
    }
    public void setStdDictId(Long stdDictId) {
        this.stdDictId = stdDictId;
    }
    public Long getStdEntryId() {
        return stdEntryId;
    }
    public void setStdEntryId(Long stdEntryId) {
        this.stdEntryId = stdEntryId;
    }
    public String getStdEntryCode() {
        return stdEntryCode;
    }
    public void setStdEntryCode(String stdEntryCode) {
        this.stdEntryCode = stdEntryCode;
    }
    public String getStdEntryValue() {
        return stdEntryValue;
    }
    public void setStdEntryValue(String stdEntryValue) {
        this.stdEntryValue = stdEntryValue;
    }
    public Long getAdapterDictId() {
        return adapterDictId;
    }
    public void setAdapterDictId(Long adapterDictId) {
        this.adapterDictId = adapterDictId;
    }
    public Long getAdapterEntryId() {
        return adapterEntryId;
    }
    public void setAdapterEntryId(Long adapterEntryId) {
        this.adapterEntryId = adapterEntryId;
    }
    public String getAdapterEntryCode() {
        return adapterEntryCode;
    }
    public void setAdapterEntryCode(String adapterEntryCode) {
        this.adapterEntryCode = adapterEntryCode;
    }
    public String getAdapterEntryValue() {
        return adapterEntryValue;
    }
    public void setAdapterEntryValue(String adapterEntryValue) {
        this.adapterEntryValue = adapterEntryValue;
    }
}

+ 106 - 0
src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterDictModel.java

@ -0,0 +1,106 @@
package com.yihu.hos.rest.models.standard.adapter;
import com.yihu.hos.web.framework.model.Result;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;
/**
 * Created by lingfeng on 2015/9/16.
 */
public class AdapterDictModel extends Result implements Serializable {
    @Id
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "increment")
    @Column(name = "id")
    private Long id;
    @Column(name = "scheme_id")
    private Integer schemeId;
    @Column(name = "std_dict_id")
    private Long stdDictId;
    @Column(name = "std_dict_code")
    private String stdDictCode;
    @Column(name = "std_dict_name")
    private String stdDictName;
    @Column(name = "adapter_dict_id")
    private Long adapterDictId;
    @Column(name = "adapter_dict_code")
    private String adapterDictCode;
    @Column(name = "adapter_dict_name")
    private String adapterDictName;
    public static AdapterDictModel error(String message) {
        AdapterDictModel re= new AdapterDictModel();
        re.successFlg = false;
        re.message = message;
        return re;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Integer getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(Integer schemeId) {
        this.schemeId = schemeId;
    }
    public Long getStdDictId() {
        return stdDictId;
    }
    public void setStdDictId(Long stdDictId) {
        this.stdDictId = stdDictId;
    }
    public String getStdDictCode() {
        return stdDictCode;
    }
    public void setStdDictCode(String stdDictCode) {
        this.stdDictCode = stdDictCode;
    }
    public String getStdDictName() {
        return stdDictName;
    }
    public void setStdDictName(String stdDictName) {
        this.stdDictName = stdDictName;
    }
    public Long getAdapterDictId() {
        return adapterDictId;
    }
    public void setAdapterDictId(Long adapterDictId) {
        this.adapterDictId = adapterDictId;
    }
    public String getAdapterDictCode() {
        return adapterDictCode;
    }
    public void setAdapterDictCode(String adapterDictCode) {
        this.adapterDictCode = adapterDictCode;
    }
    public String getAdapterDictName() {
        return adapterDictName;
    }
    public void setAdapterDictName(String adapterDictName) {
        this.adapterDictName = adapterDictName;
    }
}

+ 158 - 0
src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterMetadataModel.java

@ -0,0 +1,158 @@
package com.yihu.hos.rest.models.standard.adapter;
import com.yihu.hos.web.framework.model.Result;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;
/**
 * Created by lingfeng on 2015/9/16.
 */
public class AdapterMetadataModel extends Result implements Serializable {
    @Id
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "increment")
    @Column(name = "id")
    private Long id;
    @Column(name = "scheme_id")
    private Long schemeId;
    @Column(name = "std_dataset_id")
    private Long stdDatasetId;
    @Column(name = "std_metadata_id")
    private Long stdMetadataId;
    @Column(name = "std_metadata_code")
    private String stdMetadataCode;
    @Column(name = "std_metadata_name")
    private String stdMetadataName;
    @Column(name = "std_dict_id")
    private Long stdDictId;
    @Column(name = "adapter_dataset_id")
    private Long adapterDatasetId;
    @Column(name = "adapter_metadata_id")
    private Long adapterMetadataId;
    @Column(name = "adapter_metadata_code")
    private String adapterMetadataCode;
    @Column(name = "adapter_metadata_name")
    private String adapterMetadataName;
    @Column(name = "adapter_data_type")
    private Integer adapterDataType;
    @Column(name = "adapter_dict_id")
    private Long adapterDictId;
    @Column(name = "adapter_info")
    private String adapterInfo;
    public String getAdapterInfo() {
        return adapterInfo;
    }
    public void setAdapterInfo(String adapterInfo) {
        this.adapterInfo = adapterInfo;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(Long schemeId) {
        this.schemeId = schemeId;
    }
    public Long getStdDatasetId() {
        return stdDatasetId;
    }
    public void setStdDatasetId(Long stdDatasetId) {
        this.stdDatasetId = stdDatasetId;
    }
    public Long getStdMetadataId() {
        return stdMetadataId;
    }
    public void setStdMetadataId(Long stdMetadataId) {
        this.stdMetadataId = stdMetadataId;
    }
    public String getStdMetadataCode() {
        return stdMetadataCode;
    }
    public void setStdMetadataCode(String stdMetadataCode) {
        this.stdMetadataCode = stdMetadataCode;
    }
    public String getStdMetadataName() {
        return stdMetadataName;
    }
    public void setStdMetadataName(String stdMetadataName) {
        this.stdMetadataName = stdMetadataName;
    }
    public Long getStdDictId() {
        return stdDictId;
    }
    public void setStdDictId(Long stdDictId) {
        this.stdDictId = stdDictId;
    }
    public Long getAdapterDatasetId() {
        return adapterDatasetId;
    }
    public void setAdapterDatasetId(Long adapterDatasetId) {
        this.adapterDatasetId = adapterDatasetId;
    }
    public Long getAdapterMetadataId() {
        return adapterMetadataId;
    }
    public void setAdapterMetadataId(Long adapterMetadataId) {
        this.adapterMetadataId = adapterMetadataId;
    }
    public String getAdapterMetadataCode() {
        return adapterMetadataCode;
    }
    public void setAdapterMetadataCode(String adapterMetadataCode) {
        this.adapterMetadataCode = adapterMetadataCode;
    }
    public String getAdapterMetadataName() {
        return adapterMetadataName;
    }
    public void setAdapterMetadataName(String adapterMetadataName) {
        this.adapterMetadataName = adapterMetadataName;
    }
    public Integer getAdapterDataType() {
        return adapterDataType;
    }
    public void setAdapterDataType(Integer adapterDataType) {
        this.adapterDataType = adapterDataType;
    }
    public Long getAdapterDictId() {
        return adapterDictId;
    }
    public void setAdapterDictId(Long adapterDictId) {
        this.adapterDictId = adapterDictId;
    }
}

+ 52 - 0
src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterSchemeDispatchModel.java

@ -0,0 +1,52 @@
package com.yihu.hos.rest.models.standard.adapter;
import com.yihu.hos.web.framework.model.Result;
import java.io.Serializable;
/**
 * 标准版本模型
 *
 * @Created by lingfeng 2015/12/23.
 */
public class AdapterSchemeDispatchModel extends Result implements Serializable {
    private Integer id;
    private Integer schemeId;
    private String orgCode;
    private String orgName;
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public Integer getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(Integer schemeId) {
        this.schemeId = schemeId;
    }
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
}

+ 151 - 0
src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterSchemeModel.java

@ -0,0 +1,151 @@
package com.yihu.hos.rest.models.standard.adapter;
import com.yihu.hos.web.framework.model.Result;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.io.Serializable;
/**
 * 标准版本模型
 *
 * @Created by lingfeng 2015/12/23.
 */
@Entity
@Table(name = "adapter_scheme")
public class AdapterSchemeModel extends Result implements Serializable {
    @Id
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "increment")
    private Long id;
    @Column(name="parent_id")
    private Long parentId;
    @Column(name="name")
    private String name;
    @Column(name="type")
    private String type;
    @Column(name="description")
    private String description;
    @Column(name="status")
    private Integer status;
    @Column(name="std_id")
    private Long stdId;
    @Column(name="std_version")
    private String stdVersion;
    @Column(name="std_publisher_org_code")
    private String stdPublisherOrgCode;
    @Column(name="adapter_std_id")
    private Long adapterStdId;
    @Column(name="adapter_std_version")
    private String adapterStdVersion;
    @Column(name="adapter_publisher_org_code")
    private String adapterPublisherOrgCode;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getParentId() {
        return parentId;
    }
    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Long getStdId() {
        return stdId;
    }
    public void setStdId(Long stdId) {
        this.stdId = stdId;
    }
    public String getStdVersion() {
        return stdVersion;
    }
    public void setStdVersion(String stdVersion) {
        this.stdVersion = stdVersion;
    }
    public Long getAdapterStdId() {
        return adapterStdId;
    }
    public void setAdapterStdId(Long adapterStdId) {
        this.adapterStdId = adapterStdId;
    }
    public String getAdapterStdVersion() {
        return adapterStdVersion;
    }
    public void setAdapterStdVersion(String adapterStdVersion) {
        this.adapterStdVersion = adapterStdVersion;
    }
    public String getAdapterPublisherOrgCode() {
        return adapterPublisherOrgCode;
    }
    public void setAdapterPublisherOrgCode(String adapterPublisherOrgCode) {
        this.adapterPublisherOrgCode = adapterPublisherOrgCode;
    }
    public String getStdPublisherOrgCode() {
        return stdPublisherOrgCode;
    }
    public void setStdPublisherOrgCode(String stdPublisherOrgCode) {
        this.stdPublisherOrgCode = stdPublisherOrgCode;
    }
}

+ 120 - 0
src/main/java/com/yihu/hos/rest/models/standard/adapter/AdapterSchemeVersionModel.java

@ -0,0 +1,120 @@
package com.yihu.hos.rest.models.standard.adapter;
import com.yihu.hos.web.framework.model.Result;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
 * 标准版本模型
 *
 * @created lingfeng 2015/12/23.
 */
@Entity
@Table(name = "adapter_scheme_version")
public class AdapterSchemeVersionModel extends Result implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @Column(name="scheme_id")
    private Long schemeId;
    @Column(name="name")
    private String name;
    @Column(name="version")
    private String version;
    @Column(name="publish_time")
    private Date publishTime;
    @Column(name="publish_user")
    private String publishUser;
    @Column(name="base_version")
    private String baseVersion;
    @Column(name="publish_status")
    private Integer publishStatus;
    @Column(name="path")
    private String path;
    public AdapterSchemeVersionModel(){
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(Long schemeId) {
        this.schemeId = schemeId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getVersion() {
        return version;
    }
    public void setVersion(String version) {
        this.version = version;
    }
    public Date getPublishTime() {
        return publishTime;
    }
    public void setPublishTime(Date publishTime) {
        this.publishTime = publishTime;
    }
    public String getBaseVersion() {
        return baseVersion;
    }
    public void setBaseVersion(String baseVersion) {
        this.baseVersion = baseVersion;
    }
    public Integer getPublishStatus() {
        return publishStatus;
    }
    public void setPublishStatus(Integer publishStatus) {
        this.publishStatus = publishStatus;
    }
    public String getPath() {
        return path;
    }
    public void setPath(String path) {
        this.path = path;
    }
    public String getPublishUser() {
        return publishUser;
    }
    public void setPublishUser(String publishUser) {
        this.publishUser = publishUser;
    }
}

+ 124 - 0
src/main/java/com/yihu/hos/rest/models/standard/adapter/resultModel/AdapterDictEntryResultDetailModel.java

@ -0,0 +1,124 @@
package com.yihu.hos.rest.models.standard.adapter.resultModel;
/**
 * Created by lingfeng on 2015/9/16.
 */
public class AdapterDictEntryResultDetailModel {
    private Long id;
    private Long schemeId;
    private Long stdDictId;
    private Long stdEntryId;
    private String stdEntryCode;
    private String stdEntryValue;
    private Long adapterDictId;
    private Long adapterEntryId;
    private String adapterEntryCode;
    private String adapterEntryValue;
    private String adapterDictCode;
    private String adapterDictName;
    private String adapterInfo;
    public String getAdapterInfo() {
        return adapterInfo;
    }
    public void setAdapterInfo(String adapterInfo) {
        this.adapterInfo = adapterInfo;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(Long schemeId) {
        this.schemeId = schemeId;
    }
    public Long getStdDictId() {
        return stdDictId;
    }
    public void setStdDictId(Long stdDictId) {
        this.stdDictId = stdDictId;
    }
    public Long getStdEntryId() {
        return stdEntryId;
    }
    public void setStdEntryId(Long stdEntryId) {
        this.stdEntryId = stdEntryId;
    }
    public String getStdEntryCode() {
        return stdEntryCode;
    }
    public void setStdEntryCode(String stdEntryCode) {
        this.stdEntryCode = stdEntryCode;
    }
    public String getStdEntryValue() {
        return stdEntryValue;
    }
    public void setStdEntryValue(String stdEntryValue) {
        this.stdEntryValue = stdEntryValue;
    }
    public Long getAdapterDictId() {
        return adapterDictId;
    }
    public void setAdapterDictId(Long adapterDictId) {
        this.adapterDictId = adapterDictId;
    }
    public Long getAdapterEntryId() {
        return adapterEntryId;
    }
    public void setAdapterEntryId(Long adapterEntryId) {
        this.adapterEntryId = adapterEntryId;
    }
    public String getAdapterEntryCode() {
        return adapterEntryCode;
    }
    public void setAdapterEntryCode(String adapterEntryCode) {
        this.adapterEntryCode = adapterEntryCode;
    }
    public String getAdapterEntryValue() {
        return adapterEntryValue;
    }
    public void setAdapterEntryValue(String adapterEntryValue) {
        this.adapterEntryValue = adapterEntryValue;
    }
    public String getAdapterDictCode() {
        return adapterDictCode;
    }
    public void setAdapterDictCode(String adapterDictCode) {
        this.adapterDictCode = adapterDictCode;
    }
    public String getAdapterDictName() {
        return adapterDictName;
    }
    public void setAdapterDictName(String adapterDictName) {
        this.adapterDictName = adapterDictName;
    }
}

+ 133 - 0
src/main/java/com/yihu/hos/rest/models/standard/adapter/resultModel/AdapterMetadataResultDetailModel.java

@ -0,0 +1,133 @@
package com.yihu.hos.rest.models.standard.adapter.resultModel;
/**
 * Created by lingfeng on 2015/9/16.
 */
public class AdapterMetadataResultDetailModel {
    private Long id;
    private Long schemeId;
    private Long stdDatasetId;
    private Long stdMetadataId;
    private String stdMetadataCode;
    private String stdMetadataName;
    private Long stdDictId;
    private Long adapterDatasetId;
    private Long adapterMetadataId;
    private String adapterMetadataCode;
    private String adapterMetadataName;
    private Integer adapterDataType;
    private String adapterMetadataType;
    private Long adapterDictId;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(Long schemeId) {
        this.schemeId = schemeId;
    }
    public Long getStdDatasetId() {
        return stdDatasetId;
    }
    public void setStdDatasetId(Long stdDatasetId) {
        this.stdDatasetId = stdDatasetId;
    }
    public Long getStdMetadataId() {
        return stdMetadataId;
    }
    public void setStdMetadataId(Long stdMetadataId) {
        this.stdMetadataId = stdMetadataId;
    }
    public String getStdMetadataCode() {
        return stdMetadataCode;
    }
    public void setStdMetadataCode(String stdMetadataCode) {
        this.stdMetadataCode = stdMetadataCode;
    }
    public String getStdMetadataName() {
        return stdMetadataName;
    }
    public void setStdMetadataName(String stdMetadataName) {
        this.stdMetadataName = stdMetadataName;
    }
    public Long getStdDictId() {
        return stdDictId;
    }
    public void setStdDictId(Long stdDictId) {
        this.stdDictId = stdDictId;
    }
    public Long getAdapterDatasetId() {
        return adapterDatasetId;
    }
    public void setAdapterDatasetId(Long adapterDatasetId) {
        this.adapterDatasetId = adapterDatasetId;
    }
    public Long getAdapterMetadataId() {
        return adapterMetadataId;
    }
    public void setAdapterMetadataId(Long adapterMetadataId) {
        this.adapterMetadataId = adapterMetadataId;
    }
    public String getAdapterMetadataCode() {
        return adapterMetadataCode;
    }
    public void setAdapterMetadataCode(String adapterMetadataCode) {
        this.adapterMetadataCode = adapterMetadataCode;
    }
    public String getAdapterMetadataName() {
        return adapterMetadataName;
    }
    public void setAdapterMetadataName(String adapterMetadataName) {
        this.adapterMetadataName = adapterMetadataName;
    }
    public Integer getAdapterDataType() {
        return adapterDataType;
    }
    public void setAdapterDataType(Integer adapterDataType) {
        this.adapterDataType = adapterDataType;
    }
    public Long getAdapterDictId() {
        return adapterDictId;
    }
    public void setAdapterDictId(Long adapterDictId) {
        this.adapterDictId = adapterDictId;
    }
    public String getAdapterMetadataType() {
        return adapterMetadataType;
    }
    public void setAdapterMetadataType(String adapterMetadataType) {
        this.adapterMetadataType = adapterMetadataType;
    }
}

+ 154 - 0
src/main/java/com/yihu/hos/rest/models/standard/adapter/resultModel/AdapterSchemeResultDetailModel.java

@ -0,0 +1,154 @@
package com.yihu.hos.rest.models.standard.adapter.resultModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterSchemeVersionModel;
import java.io.Serializable;
import java.util.List;
public class AdapterSchemeResultDetailModel implements Serializable {
    String id;
    String pid;
    String name;
    Integer status;
    String stdName;
    String stdVersionName;
    String stdVersion;
    String stdPublisher;
    String publisher; //源发布者
    String adapterName;
    String adapterVersionName;
    String adapterStdVersion;
    String version;
    Integer type;
    String date;
    List<AdapterSchemeVersionModel> versionList;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getPid() {
        return pid;
    }
    public void setPid(String pid) {
        this.pid = pid;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getStdName() {
        return stdName;
    }
    public void setStdName(String stdName) {
        this.stdName = stdName;
    }
    public String getStdVersionName() {
        return stdVersionName;
    }
    public void setStdVersionName(String stdVersionName) {
        this.stdVersionName = stdVersionName;
    }
    public String getPublisher() {
        return publisher;
    }
    public void setPublisher(String publisher) {
        this.publisher = publisher;
    }
    public String getAdapterName() {
        return adapterName;
    }
    public void setAdapterName(String adapterName) {
        this.adapterName = adapterName;
    }
    public String getAdapterVersionName() {
        return adapterVersionName;
    }
    public void setAdapterVersionName(String adapterVersionName) {
        this.adapterVersionName = adapterVersionName;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public String getDate() {
        return date;
    }
    public void setDate(String date) {
        this.date = date;
    }
    public String getVersion() {
        return version;
    }
    public void setVersion(String version) {
        this.version = version;
    }
    public String getStdVersion() {
        return stdVersion;
    }
    public void setStdVersion(String stdVersion) {
        this.stdVersion = stdVersion;
    }
    public String getAdapterStdVersion() {
        return adapterStdVersion;
    }
    public void setAdapterStdVersion(String adapterStdVersion) {
        this.adapterStdVersion = adapterStdVersion;
    }
    public List<AdapterSchemeVersionModel> getVersionList() {
        return versionList;
    }
    public void setVersionList(List<AdapterSchemeVersionModel> versionList) {
        this.versionList = versionList;
    }
    public String getStdPublisher() {
        return stdPublisher;
    }
    public void setStdPublisher(String stdPublisher) {
        this.stdPublisher = stdPublisher;
    }
}

+ 43 - 0
src/main/java/com/yihu/hos/rest/models/standard/adapter/resultModel/AdapterSchemeResultModel.java

@ -0,0 +1,43 @@
package com.yihu.hos.rest.models.standard.adapter.resultModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterSchemeVersionModel;
import java.util.List;
/**
 * 任务编排列表
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/4/27.
 */
public class AdapterSchemeResultModel {
    private Long schemeId;
    private String name;
    List<AdapterSchemeVersionModel> versionList;
    public Long getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(Long schemeId) {
        this.schemeId = schemeId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public List<AdapterSchemeVersionModel> getVersionList() {
        return versionList;
    }
    public void setVersionList(List<AdapterSchemeVersionModel> versionList) {
        this.versionList = versionList;
    }
}

+ 105 - 0
src/main/java/com/yihu/hos/rest/models/standard/adapter/resultModel/AdapterSchemeVersionResultDetailModel.java

@ -0,0 +1,105 @@
package com.yihu.hos.rest.models.standard.adapter.resultModel;
import java.util.Date;
/**
 * 标准版本模型
 *
 * @created lingfeng 2015/12/23.
 */
public class AdapterSchemeVersionResultDetailModel {
    private Long id;
    private Long schemeId;
    private String name;
    private String schemeName;
    private String version;
    private Date publishTime;
    private String publishUser;
    private String baseVersion;
    private Integer publishStatus;
    private String path;
    public AdapterSchemeVersionResultDetailModel(){
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(Long schemeId) {
        this.schemeId = schemeId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getSchemeName() {
        return schemeName;
    }
    public void setSchemeName(String schemeName) {
        this.schemeName = schemeName;
    }
    public String getVersion() {
        return version;
    }
    public void setVersion(String version) {
        this.version = version;
    }
    public Date getPublishTime() {
        return publishTime;
    }
    public void setPublishTime(Date publishTime) {
        this.publishTime = publishTime;
    }
    public String getPublishUser() {
        return publishUser;
    }
    public void setPublishUser(String publishUser) {
        this.publishUser = publishUser;
    }
    public String getBaseVersion() {
        return baseVersion;
    }
    public void setBaseVersion(String baseVersion) {
        this.baseVersion = baseVersion;
    }
    public Integer getPublishStatus() {
        return publishStatus;
    }
    public void setPublishStatus(Integer publishStatus) {
        this.publishStatus = publishStatus;
    }
    public String getPath() {
        return path;
    }
    public void setPath(String path) {
        this.path = path;
    }
}

+ 151 - 0
src/main/java/com/yihu/hos/rest/models/standard/adapter/resultModel/ApiMetadataResultDetailModel.java

@ -0,0 +1,151 @@
package com.yihu.hos.rest.models.standard.adapter.resultModel;
/**
 * Created by lingfeng on 2015/9/18.
 */
public class ApiMetadataResultDetailModel {
    private Long id;
    private Long schemeId;
    private Long stdDatasetId;
    private Long stdMetadataId;
    private String stdMetadataCode;
    private String stdMetadataName;
    private Long stdDictId;
    private Long adapterDatasetId;
    private Long adapterMetadataId;
    private String adapterMetadataCode;
    private String adapterMetadataName;
    private Integer adapterDataType;
    private String adapterDatasetCode;
    private String adapterDatasetName;
    private Long adapterDictId;
    private String adapterInfo;
    public String getAdapterInfo() {
        return adapterInfo;
    }
    public void setAdapterInfo(String adapterInfo) {
        this.adapterInfo = adapterInfo;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(Long schemeId) {
        this.schemeId = schemeId;
    }
    public Long getStdDatasetId() {
        return stdDatasetId;
    }
    public void setStdDatasetId(Long stdDatasetId) {
        this.stdDatasetId = stdDatasetId;
    }
    public Long getStdMetadataId() {
        return stdMetadataId;
    }
    public void setStdMetadataId(Long stdMetadataId) {
        this.stdMetadataId = stdMetadataId;
    }
    public String getStdMetadataCode() {
        return stdMetadataCode;
    }
    public void setStdMetadataCode(String stdMetadataCode) {
        this.stdMetadataCode = stdMetadataCode;
    }
    public String getStdMetadataName() {
        return stdMetadataName;
    }
    public void setStdMetadataName(String stdMetadataName) {
        this.stdMetadataName = stdMetadataName;
    }
    public Long getStdDictId() {
        return stdDictId;
    }
    public void setStdDictId(Long stdDictId) {
        this.stdDictId = stdDictId;
    }
    public Long getAdapterDatasetId() {
        return adapterDatasetId;
    }
    public void setAdapterDatasetId(Long adapterDatasetId) {
        this.adapterDatasetId = adapterDatasetId;
    }
    public Long getAdapterMetadataId() {
        return adapterMetadataId;
    }
    public void setAdapterMetadataId(Long adapterMetadataId) {
        this.adapterMetadataId = adapterMetadataId;
    }
    public String getAdapterMetadataCode() {
        return adapterMetadataCode;
    }
    public void setAdapterMetadataCode(String adapterMetadataCode) {
        this.adapterMetadataCode = adapterMetadataCode;
    }
    public String getAdapterMetadataName() {
        return adapterMetadataName;
    }
    public void setAdapterMetadataName(String adapterMetadataName) {
        this.adapterMetadataName = adapterMetadataName;
    }
    public Integer getAdapterDataType() {
        return adapterDataType;
    }
    public void setAdapterDataType(Integer adapterDataType) {
        this.adapterDataType = adapterDataType;
    }
    public Long getAdapterDictId() {
        return adapterDictId;
    }
    public void setAdapterDictId(Long adapterDictId) {
        this.adapterDictId = adapterDictId;
    }
    public String getAdapterDatasetCode() {
        return adapterDatasetCode;
    }
    public void setAdapterDatasetCode(String adapterDatasetCode) {
        this.adapterDatasetCode = adapterDatasetCode;
    }
    public String getAdapterDatasetName() {
        return adapterDatasetName;
    }
    public void setAdapterDatasetName(String adapterDatasetName) {
        this.adapterDatasetName = adapterDatasetName;
    }
}

+ 51 - 0
src/main/java/com/yihu/hos/rest/models/standard/bo/AdapterVersion.java

@ -0,0 +1,51 @@
package com.yihu.hos.rest.models.standard.bo;
import com.yihu.hos.web.framework.constant.SqlConstants;
public class AdapterVersion {
    public static final String FBVersion = "000000000000";
    public final static String DataSetTablePrefix = "adapter_dataset";
    public final static String MetaDataTablePrefix = "adapter_metadata";
    public final static String DictTablePrefix = "adapter_dict";
    public final static String DictEntryTablePrefix = "adapter_dictentry";
    public final static String DatasetRelationTablePrefix = "adapter_dataset_relation";
    private ObjectVersion version;
    public AdapterVersion(String version) {
        this.version = new ObjectVersion(version);
    }
    public static AdapterVersion generateVersion() {
        ObjectVersion objectVersion = new ObjectVersion();
        return new AdapterVersion(objectVersion.toString());
    }
    public String getDataSetTableName() {
        return DataSetTablePrefix + SqlConstants.UNDERLINE + version;
    }
    public String getMetaDataTableName() {
        return MetaDataTablePrefix + SqlConstants.UNDERLINE + version;
    }
    public String getDictTableName() {
        return DictTablePrefix + SqlConstants.UNDERLINE + version;
    }
    public String getDictEntryTableName() {
        return DictEntryTablePrefix + SqlConstants.UNDERLINE + version;
    }
    public String getDatasetRelationTableName() {
        return DatasetRelationTablePrefix + SqlConstants.UNDERLINE + version;
    }
    public String getVersion() {
        return version.toString();
    }
    public void finalize() throws Throwable {
    }
}

+ 184 - 0
src/main/java/com/yihu/hos/rest/models/standard/bo/ObjectVersion.java

@ -0,0 +1,184 @@
package com.yihu.hos.rest.models.standard.bo;
import java.io.Serializable;
import java.security.SecureRandom;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2016/8/8.
 */
public final class ObjectVersion implements Comparable<ObjectVersion>, Serializable {
    private static final long serialVersionUID = 789056789654456072L;
    private static final int BYTE_ARRAY_LENGTH = 6;
    private static final AtomicInteger NEXT_COUNTER = new AtomicInteger((new SecureRandom()).nextInt());
    private static final char[] HEX_CHARS = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
    private final int timestamp;
    private final short counter;
    public static boolean isValid(String hexString) {
        if(hexString == null) {
            throw new IllegalArgumentException();
        } else {
            int len = hexString.length();
            if(len != 12) {
                return false;
            } else {
                for(int i = 0; i < len; ++i) {
                    char c = hexString.charAt(i);
                    if((c < 48 || c > 57) && (c < 97 || c > 102) && (c < 65 || c > 70)) {
                        return false;
                    }
                }
                return true;
            }
        }
    }
    public static int getCurrentCounter() {
        return NEXT_COUNTER.get();
    }
    public ObjectVersion() {
        this(new Date());
    }
    public ObjectVersion(Date date) {
        this(dateToTimestampSeconds(date), (short)NEXT_COUNTER.getAndIncrement());
    }
    public ObjectVersion(Date date, short counter) {
        this(dateToTimestampSeconds(date), counter);
    }
    public ObjectVersion(int timestamp, short counter) {
        this.timestamp = timestamp;
        this.counter = counter;
    }
    public ObjectVersion(String hexString) {
        this(parseHexString(hexString));
    }
    public ObjectVersion(byte[] bytes) {
        if(bytes == null) {
            throw new IllegalArgumentException();
        } else if(bytes.length != 6) {
            throw new IllegalArgumentException("need 6 bytes");
        } else {
            this.timestamp = makeInt(bytes[0], bytes[1], bytes[2], bytes[3]);
            this.counter = (short)makeInt((byte)0, (byte)0, bytes[4], bytes[5]);
        }
    }
    public byte[] toByteArray() {
        byte[] bytes = new byte[]{int3(this.timestamp), int2(this.timestamp), int1(this.timestamp), int0(this.timestamp), int1(this.counter), int0(this.counter)};
        return bytes;
    }
    public Date getDate() {
        return new Date((long)this.timestamp * 1000L);
    }
    public int getTimestamp() {
        return this.timestamp;
    }
    public short getCounter() {
        return this.counter;
    }
    public String toHexString() {
        char[] chars = new char[12];
        int i = 0;
        byte[] var3 = this.toByteArray();
        int var4 = var3.length;
        for(int var5 = 0; var5 < var4; ++var5) {
            byte b = var3[var5];
            chars[i++] = HEX_CHARS[b >> 4 & 15];
            chars[i++] = HEX_CHARS[b & 15];
        }
        return new String(chars);
    }
    public boolean equals(Object o) {
        if(this == o) {
            return true;
        } else if(o != null && this.getClass() == o.getClass()) {
            ObjectVersion objectId = (ObjectVersion)o;
            return this.counter != objectId.counter?false:this.timestamp == objectId.timestamp;
        } else {
            return false;
        }
    }
    public int hashCode() {
        int result = this.timestamp;
        result = 31 * result + this.counter;
        return result;
    }
    public int compareTo(ObjectVersion other) {
        if(other == null) {
            throw new NullPointerException();
        } else {
            byte[] byteArray = this.toByteArray();
            byte[] otherByteArray = other.toByteArray();
            for(int i = 0; i < 6; ++i) {
                if(byteArray[i] != otherByteArray[i]) {
                    return (byteArray[i] & 255) < (otherByteArray[i] & 255)?-1:1;
                }
            }
            return 0;
        }
    }
    public String toString() {
        return this.toHexString();
    }
    private static byte[] parseHexString(String s) {
        if(!isValid(s)) {
            throw new IllegalArgumentException("invalid hexadecimal representation of an ObjectId: [" + s + "]");
        } else {
            byte[] b = new byte[6];
            for(int i = 0; i < b.length; ++i) {
                b[i] = (byte)Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16);
            }
            return b;
        }
    }
    private static int dateToTimestampSeconds(Date time) {
        return (int)(time.getTime() / 1000L);
    }
    private static int makeInt(byte b3, byte b2, byte b1, byte b0) {
        return b3 << 24 | (b2 & 255) << 16 | (b1 & 255) << 8 | b0 & 255;
    }
    private static byte int3(int x) {
        return (byte)(x >> 24);
    }
    private static byte int2(int x) {
        return (byte)(x >> 16);
    }
    private static byte int1(int x) {
        return (byte)(x >> 8);
    }
    private static byte int0(int x) {
        return (byte)x;
    }
}

+ 58 - 0
src/main/java/com/yihu/hos/rest/models/standard/bo/StandardVersion.java

@ -0,0 +1,58 @@
package com.yihu.hos.rest.models.standard.bo;
public class StandardVersion {
    public final static String VersionBoundSymbol = "_";
    public final static String DataSetTable = "std_dataset";
    public final static String MetaDataTable = "std_metadata";
    public final static String DictTable = "std_dictionary";
    public final static String DictEntryTable = "std_dictionary_entry";
    public final static String CDADocumentTable = "std_cda_document";
    public final static String CDADatasetTable = "std_cda_dataset_relationship";
    private ObjectVersion version;
    public StandardVersion(String version) {
        this.version = new ObjectVersion(version);
    }
    public StandardVersion() {
    }
    public static StandardVersion generateVersion() {
        ObjectVersion objectVersion = new ObjectVersion();
        return new StandardVersion(objectVersion.toString());
    }
    public String getDataSetTableName() {
        return DataSetTable + VersionBoundSymbol + version;
    }
    public String getMetaDataTableName() {
        return MetaDataTable + VersionBoundSymbol + version;
    }
    public String getDictTableName() {
        return DictTable + VersionBoundSymbol + version;
    }
    public String getDictEntryTableName() {
        return DictEntryTable + VersionBoundSymbol + version;
    }
    public String getCDATableName() {
        return CDADocumentTable + VersionBoundSymbol + version;
    }
    public String getCDADatasetTableName() {
        return CDADatasetTable + VersionBoundSymbol + version;
    }
    public String getVersion() {
        return version.toString();
    }
    public void finalize() throws Throwable {
    }
}

+ 82 - 0
src/main/java/com/yihu/hos/rest/models/standard/bo/SystemParam.java

@ -0,0 +1,82 @@
package com.yihu.hos.rest.models.standard.bo;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
/**
 * SystemParam entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "system_param")
public class SystemParam implements java.io.Serializable {
    // Fields
    @Id
    @Column(name="id",length = 50)
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    private String id;
    @Column(name="param_key",length = 50,nullable = true)
    private String paramKey;//名称
    @Column(name="param_value",length = 200, nullable = true)
    private String paramValue;//值
    @Column(name="remark",length = 200)
    private String remark;//说明
    @Column(name="org_id",length = 50)
    private String orgId;//机构代码(预留)
    // Constructors
    /**
     * default constructor
     */
    public SystemParam() {
    }
    public String getParamKey() {
        return paramKey;
    }
    public void setParamKey(String paramKey) {
        this.paramKey = paramKey;
    }
    public String getParamValue() {
        return paramValue;
    }
    public void setParamValue(String paramValue) {
        this.paramValue = paramValue;
    }
    public String getId() {
        return this.id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getRemark() {
        return this.remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getOrgId() {
        return this.orgId;
    }
    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }
}

+ 147 - 0
src/main/java/com/yihu/hos/rest/models/standard/standard/STDVersion.java

@ -0,0 +1,147 @@
package com.yihu.hos.rest.models.standard.standard;
import com.yihu.hos.web.framework.model.Result;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
 * @author lincl
 * @version 1.0
 * @created 2016.2.3
 */
@Entity
@Table(name = "std_version")
@Access(value = AccessType.PROPERTY)
public class STDVersion extends Result implements Serializable {
    private Long id;
    private String version;
    private String versionName;
    private Long standardId;
    private Date commitTime;//发布时间
    private String publishUser;//发布者
    private String baseVersion;//基础版本
    private String primaryVersion;//主版本号
    private boolean inStage;
    private String path;
    private String author;
    public STDVersion(String baseVersion, String author, String versionName) {
        //this.baseVersion = baseVersion == null ? null : new ObjectVersion(baseVersion);
        this.author = author;
        this.commitTime = null;
        this.inStage = true;
        if (baseVersion == null) {
            this.versionName = versionName;
            this.baseVersion = null;
        } else {
            versionName = versionName.substring(1, versionName.length());
            double dVersion = Double.parseDouble(versionName) + 1.0;
            this.versionName = "V" + String.valueOf(dVersion);
        }
    }
    public STDVersion(){
    }
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    @Column(name = "version", unique = true, nullable = false)
    public String getVersion() {
        return version;
    }
    public void setVersion(String version) {
        this.version = version;
    }
    @Column(name = "author", unique = false, nullable = false)
    public String getAuthor() {
        return author;
    }
    public void setAuthor(String author) {
        this.author = author;
    }
    @Column(name = "base_version", unique = false, nullable = true)
    @Access(value = AccessType.PROPERTY)
    public String getBaseVersion() {
        return baseVersion;
    }
    public void setBaseVersion(String baseVersion) {
        this.baseVersion = baseVersion;
    }
    @Column(name = "commit_time", unique = false, nullable = true)
    public Date getCommitTime() {
        return commitTime;
    }
    public void setCommitTime(Date commitTime) {
        this.commitTime = commitTime;
    }
    @Column(name = "version_name", unique = false, nullable = true)
    public String getVersionName() {
        return versionName;
    }
    public void setVersionName(String versionName) {
        this.versionName = versionName;
    }
    @Column(name = "staged", unique = false, nullable = true )
    public boolean isInStage() {
        return inStage;
    }
    public void setInStage(boolean inStage) {
        this.inStage = inStage;
    }
    @Column(name = "std_id" )
    public Long getStandardId() {
        return standardId;
    }
    public void setStandardId(Long standardId) {
        this.standardId = standardId;
    }
    @Column(name = "publish_user" )
    public String getPublishUser() {
        return publishUser;
    }
    public void setPublishUser(String publishUser) {
        this.publishUser = publishUser;
    }
    @Column(name = "primary_version", unique = false, nullable = true)
    @Access(value = AccessType.PROPERTY)
    public String getPrimaryVersion() {
        return primaryVersion;
    }
    public void setPrimaryVersion(String primaryVersion) {
        this.primaryVersion = primaryVersion;
    }
    @Column(name="path")
    public String getPath() {
        return path;
    }
    public void setPath(String path) {
        this.path = path;
    }
}

+ 134 - 0
src/main/java/com/yihu/hos/rest/models/standard/standard/StandardModel.java

@ -0,0 +1,134 @@
package com.yihu.hos.rest.models.standard.standard;
import com.yihu.hos.web.framework.model.Result;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.io.Serializable;
/**
 * 标准基本信息
 *
 * @created Airhead 2015/12/23.
 */
@Entity
@Table(name = "std_info")
public class StandardModel extends Result implements Serializable {
    @Id
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "increment")
    private Long id;
    @Column(name="name")
    private String name;
    @Column(name="code")
    private String code;
    @Column(name="publisher")
    private String publisher;
    @Column(name="publisher_org_code")
    private String publisherOrgCode;
    @Column(name="summary")
    private String summary;
    @Column(name="ref_standard")
    private String refStandard;
    @Column(name="ref_standard_version")
    private String refStandardVersion;
    @Column(name="version_status")
    private Integer versionStatus;
    public StandardModel(){
    }
    public StandardModel(StandardModel standardModel){
        this.id = standardModel.id;
        this.name = standardModel.name;
        this.code = standardModel.code;
        this.publisher = standardModel.publisher;
        this.publisherOrgCode = standardModel.publisherOrgCode;
        this.summary = standardModel.summary;
        this.refStandard = standardModel.refStandard;
        this.refStandardVersion = standardModel.refStandardVersion;
        this.versionStatus = standardModel.versionStatus;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getPublisher() {
        return publisher;
    }
    public void setPublisher(String publisher) {
        this.publisher = publisher;
    }
    public String getPublisherOrgCode() {
        return publisherOrgCode;
    }
    public void setPublisherOrgCode(String publisherOrgCode) {
        this.publisherOrgCode = publisherOrgCode;
    }
    public String getSummary() {
        return summary;
    }
    public void setSummary(String summary) {
        this.summary = summary;
    }
    public String getRefStandard() {
        return refStandard;
    }
    public void setRefStandard(String refStandard) {
        this.refStandard = refStandard;
    }
    public String getRefStandardVersion() {
        return refStandardVersion;
    }
    public void setRefStandardVersion(String refStandardVersion) {
        this.refStandardVersion = refStandardVersion;
    }
    public Integer getVersionStatus() {
        return versionStatus;
    }
    public void setVersionStatus(Integer versionStatus) {
        this.versionStatus = versionStatus;
    }
}

+ 201 - 0
src/main/java/com/yihu/hos/rest/models/standard/standard/StdDataSetModel.java

@ -0,0 +1,201 @@
package com.yihu.hos.rest.models.standard.standard;
import com.yihu.hos.web.framework.model.Result;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Objects;
/**
 * Created by wq on 2015/9/16.
 */
@MappedSuperclass
public class StdDataSetModel extends Result implements Serializable {
    @Id
    @GenericGenerator(name = "generator", strategy = "increment")
    @Column(name = "id")
    private Long id;
    @Column(name="document_id")
    private Long documentId;
    @Column(name = "code")
    private String code;
    @Column(name = "name")
    private String name;
    @Column(name = "language")
    private String language;
    @Column(name = "catalog")
    private Integer catalog;
    @Column(name = "summary")
    private String summary;
    @Column(name = "class_model")
    private String classModel;
    @Column(name="ref_standard")
    private String reference;
    @Column(name = "lang", unique = false, nullable = true)
    private Integer lang;
    @Column(name = "publisher", unique = false, nullable = false)
    private Integer publisher;
    @Column(name = "multi_record", nullable = false)
    private boolean multiRecord;
    @Column(name = "std_version", unique = false, nullable = true)
    private String stdVersion;
    @Column(name = "hash", unique = false, nullable = true)
    private Integer hashCode;
    @Column(name="std_id")
    private Long standardId;
    @Transient
    private String innerVersionId;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getLanguage() {
        return language;
    }
    public void setLanguage(String language) {
        this.language = language;
    }
    public Integer getCatalog() {
        return catalog;
    }
    public void setCatalog(Integer catalog) {
        this.catalog = catalog;
    }
    public String getSummary() {
        return summary;
    }
    public void setSummary(String summary) {
        this.summary = summary;
    }
    public String getClassModel() {
        return classModel;
    }
    public void setClassModel(String classModel) {
        this.classModel = classModel;
    }
    public Integer getHashCode() {
        hashCode = Objects.hash( catalog, lang, standardId,
                publisher, stdVersion, code, name, summary);
        return hashCode;
    }
    public void setHashCode(Integer hashCode) {
        this.hashCode = hashCode;
    }
    public Integer getLang() {
        return lang;
    }
    public void setLang(Integer lang) {
        this.lang = lang;
    }
    public boolean isMultiRecord() {
        return multiRecord;
    }
    public void setMultiRecord(boolean multiRecord) {
        this.multiRecord = multiRecord;
    }
    public Integer getPublisher() {
        return publisher;
    }
    public void setPublisher(Integer publisher) {
        this.publisher = publisher;
    }
    public String getStdVersion() {
        return stdVersion;
    }
    public void setStdVersion(String stdVersion) {
        this.stdVersion = stdVersion;
    }
    public Long getDocumentId() {
        return documentId;
    }
    public void setDocumentId(Long documentId) {
        this.documentId = documentId;
    }
    public String getReference() {
        return reference;
    }
    public void setReference(String reference) {
        this.reference = reference;
    }
    public String getInnerVersionId() {
        return innerVersionId;
    }
    public void setInnerVersionId(String innerVersionId) {
        this.innerVersionId = innerVersionId;
    }
    public Long getStandardId() {
        return standardId;
    }
    public void setStandardId(Long standardId) {
        this.standardId = standardId;
    }
}

+ 122 - 0
src/main/java/com/yihu/hos/rest/models/standard/standard/StdDictionaryEntryModel.java

@ -0,0 +1,122 @@
package com.yihu.hos.rest.models.standard.standard;
import com.yihu.hos.web.framework.model.Result;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Objects;
/**
 * @created Airhead 2015/12/23.
 */
@MappedSuperclass
public class StdDictionaryEntryModel extends Result implements Serializable {
    @Id
    @GenericGenerator(name = "generator", strategy = "increment")
    @Column(name = "id")
    private Long id;
    @Column(name = "std_id")
    private Long standardId;
    @Column(name = "dict_id")
    private Long dictId;
    @Column(name = "code")
    private String code;
    @Column(name = "value")
    private String value;
    @Column(name = "description")
    private String desc;
    @Column(name = "hash", unique = false, nullable = true)
    private Integer hashCode;
    @Column(name = "std_version")
    private String stdVersion;// 标准化版本
    @Transient
    private String OperationType;
    public String getOperationType() {
        return OperationType;
    }
    public void setOperationType(String operationType) {
        OperationType = operationType;
    }
    public Integer getHashCode() {
        hashCode = Objects.hash(dictId, code, value, desc);
        return hashCode;
    }
    public void setHashCode(Integer hashCode) {
        this.hashCode = hashCode;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getStandardId() {
        return standardId;
    }
    public void setStandardId(Long standardId) {
        this.standardId = standardId;
    }
    public Long getDictId() {
        return dictId;
    }
    public void setDictId(Long dictId) {
        this.dictId = dictId;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getDesc() {
        return desc;
    }
    public void setDesc(String desc) {
        this.desc = desc;
    }
    public String getStdVersion() {
        return stdVersion;
    }
    public void setStdVersion(String stdVersion) {
        this.stdVersion = stdVersion;
    }
}

+ 176 - 0
src/main/java/com/yihu/hos/rest/models/standard/standard/StdDictionaryModel.java

@ -0,0 +1,176 @@
package com.yihu.hos.rest.models.standard.standard;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.hos.web.framework.model.Result;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
/**
 * 标准数据字典模型
 *
 * @created Airhead 2015/12/23.
 */
public class StdDictionaryModel extends Result implements Serializable {
    @Id
    @GenericGenerator(name = "generator", strategy = "increment")
    @Column(name = "id")
    private Long id;
    @Column(name = "std_id")
    private Long standardId;
    @Column(name = "code")
    private String code;
    @Column(name = "name")
    private String name;
    @Column(name = "define")
    private String define;
    @Column(name = "description")
    private String description;
    @Column(name = "parent_id")
    private Long baseDict;
    //以下为ehr新增字段
    @Column(name = "author", unique = false, nullable = true)
    private String author;// 作者
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_date", unique = false, nullable = true)
    private Date createDate;//创建日期
    @Column(name = "source", unique = false, nullable = true)
    private String sourceId;
    @Column(name = "std_version", unique = false, nullable = true)
    private String stdVersion;// 标准化版本
    @Column(name = "hash", unique = false, nullable = true)
    private Integer hashCode;
    @Transient
    private String innerVersion;
    @Transient
    private Integer inStage;
    public String getAuthor() {
        return author;
    }
    public void setAuthor(String author) {
        this.author = author;
    }
    public Date getCreateDate() {
        return createDate;
    }
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }
    public String getSourceId() {
        return sourceId;
    }
    public void setSourceId(String sourceId) {
        this.sourceId = sourceId;
    }
    public String getStdVersion() {
        return stdVersion;
    }
    public void setStdVersion(String stdVersion) {
        this.stdVersion = stdVersion;
    }
    public String getInnerVersion() {
        return innerVersion;
    }
    public void setInnerVersion(String innerVersion) {
        this.innerVersion = innerVersion;
    }
    public Integer getInStage() {
        return inStage;
    }
    public void setInStage(Integer inStage) {
        this.inStage = inStage;
    }
    public Integer getHashCode() {
        hashCode = Objects.hash(stdVersion, code, name, inStage, description, baseDict, author, createDate);
        return hashCode;
    }
    public void setHashCode(Integer hashCode) {
        this.hashCode = hashCode;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getStandardId() {
        return standardId;
    }
    public void setStandardId(Long standardId) {
        this.standardId = standardId;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDefine() {
        return define;
    }
    public void setDefine(String define) {
        this.define = define;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public Long getBaseDict() {
        return baseDict;
    }
    public void setBaseDict(Long baseDict) {
        this.baseDict = baseDict;
    }
}

+ 264 - 0
src/main/java/com/yihu/hos/rest/models/standard/standard/StdMetaDataModel.java

@ -0,0 +1,264 @@
package com.yihu.hos.rest.models.standard.standard;
import com.yihu.hos.web.framework.model.Result;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Objects;
/**
 * Created by wq on 2015/9/22.
 */
public class StdMetaDataModel extends Result implements Serializable {
    @Id
    @GenericGenerator(name = "generator", strategy = "increment")
    @Column(name = "id")
    private Long id;                    // 数据元ID
    @Column(name = "std_id")
    private Long standardId;           //标准ID
    @Column(name = "dataset_id")
    private Long dataSetId;             //数据集ID
    @Column(name = "inner_code")
    private String innerCode;           // 内部代码
    @Column(name = "code")
    private String code;                 // 标准元编码
    @Column(name = "name")
    private String name;                // 名称
    @Column(name = "type")
    private String type;                // 数据元数据类型
    @Column(name = "format")
    private String format;              // 表示格式
    @Column(name = "dict_id")
    private Long dictId;                //字典ID
    @Column(name = "definition")
    private String definition;          // 标准元定义, 即说明
    @Column(name = "nullable")
    private boolean nullable;           // 是否可为空
    @Column(name = "column_length")
    private String columnLength;         // 数据长度
    @Column(name = "column_type")
    private String columnType;          // 数据类型
    @Column(name = "column_name")
    private String columnName;          // 字段名
    @Column(name = "primary_key")
    private boolean primaryKey;         // 是否为主键
    @Column(name = "hash", unique = false, nullable = false)
    private Integer hashCode;
    @Column(name = "std_version")
    private String stdVersion;
    /************************/
    /**  Transient        ***/
    /************************/
    @Transient
    boolean isHbaseFullTextRetrieval;       // Hbase 全文检索字段
    @Transient
    boolean isHbasePrimaryKey;              // Hbase 主键字段
    @Transient
    String dictName;
    @Transient
    String dictCode;
    public Integer getHashCode() {
        hashCode = Objects.hash(dataSetId, dictId, code, definition, format, innerCode, name,
                type, columnLength, columnType, nullable, primaryKey);
        return hashCode;
    }
    public void setHashCode(Integer hashCode) {
        this.hashCode = hashCode;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getStandardId() {
        return standardId;
    }
    public void setStandardId(Long standardId) {
        this.standardId = standardId;
    }
    public Long getDataSetId() {
        return dataSetId;
    }
    public void setDataSetId(long dataSetId) {
        this.dataSetId = dataSetId;
    }
    public String getInnerCode() {
        return innerCode;
    }
    public void setInnerCode(String innerCode) {
        this.innerCode = innerCode;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getFormat() {
        return format;
    }
    public void setFormat(String format) {
        this.format = format;
    }
    public Long getDictId() {
        return dictId;
    }
    public void setDictId(Long dictId) {
        this.dictId = dictId;
    }
    public String getDefinition() {
        return definition;
    }
    public void setDefinition(String definition) {
        this.definition = definition;
    }
    public boolean getNullable() {
        return nullable;
    }
    public void setNullable(boolean nullable) {
        this.nullable = nullable;
    }
    public String getColumnLength() {
        return columnLength;
    }
    public void setColumnLength(String columnLength) {
        this.columnLength = columnLength;
    }
    public String getColumnType() {
        return columnType;
    }
    public void setColumnType(String columnType) {
        this.columnType = columnType;
    }
    public String getColumnName() {
        return columnName;
    }
    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }
    public boolean getPrimaryKey() {
        return primaryKey;
    }
    public void setPrimaryKey(boolean primaryKey) {
        this.primaryKey = primaryKey;
    }
    public boolean isHbaseFullTextRetrieval() {
        return isHbaseFullTextRetrieval;
    }
    public void setHbaseFullTextRetrieval(boolean hbaseFullTextRetrieval) {
        isHbaseFullTextRetrieval = hbaseFullTextRetrieval;
    }
    public boolean isHbasePrimaryKey() {
        return isHbasePrimaryKey;
    }
    public void setHbasePrimaryKey(boolean hbasePrimaryKey) {
        isHbasePrimaryKey = hbasePrimaryKey;
    }
    public String getDictName() {
        return dictName;
    }
    public void setDictName(String dictName) {
        this.dictName = dictName;
    }
    public String getDictCode() {
        return dictCode;
    }
    public void setDictCode(String dictCode) {
        this.dictCode = dictCode;
    }
    public boolean isNullable() {
        return nullable;
    }
    public boolean isPrimaryKey() {
        return primaryKey;
    }
    public String getStdVersion() {
        return stdVersion;
    }
    public void setStdVersion(String stdVersion) {
        this.stdVersion = stdVersion;
    }
    public void setDataSetId(Long dataSetId) {
        this.dataSetId = dataSetId;
    }
}

+ 27 - 0
src/main/java/com/yihu/hos/rest/models/standard/standard/resultModel/StandardParamResultModel.java

@ -0,0 +1,27 @@
package com.yihu.hos.rest.models.standard.standard.resultModel;
import com.yihu.hos.web.framework.model.Result;
/**
 * Created by lingfeng on 2016/4/22.
 */
public class StandardParamResultModel extends Result {
    String code;
    String orgCode;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
}

+ 78 - 0
src/main/java/com/yihu/hos/rest/models/standard/standard/resultModel/StandardResultDetailModel.java

@ -0,0 +1,78 @@
package com.yihu.hos.rest.models.standard.standard.resultModel;
import java.io.Serializable;
public class StandardResultDetailModel implements Serializable {
    String id;
    String pid;
    String name;
    String code;
    Integer status;
    String publisher;
    Integer type;
    String date;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getPid() {
        return pid;
    }
    public void setPid(String pid) {
        this.pid = pid;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPublisher() {
        return publisher;
    }
    public void setPublisher(String publisher) {
        this.publisher = publisher;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public String getDate() {
        return date;
    }
    public void setDate(String date) {
        this.date = date;
    }
}

File diff suppressed because it is too large
+ 204 - 0
src/main/java/com/yihu/hos/rest/services/crawler/CollectHelper.java


+ 347 - 0
src/main/java/com/yihu/hos/rest/services/crawler/CrawlerFlowManager.java

@ -0,0 +1,347 @@
package com.yihu.hos.rest.services.crawler;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.core.datatype.CollectionUtil;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.rest.common.dao.CrawlerDatasetDao;
import com.yihu.hos.rest.common.dao.CrawlerFlowDao;
import com.yihu.hos.rest.common.dao.CrawlerFlowHeadDao;
import com.yihu.hos.rest.common.format.AdapterBase;
import com.yihu.hos.rest.models.crawler.adapter.AdapterDataSet;
import com.yihu.hos.rest.models.crawler.config.SysConfig;
import com.yihu.hos.rest.models.crawler.flow.CrawlerDataSetModel;
import com.yihu.hos.rest.models.crawler.flow.CrawlerFlowHeadModel;
import com.yihu.hos.rest.models.crawler.flow.CrawlerFlowModel;
import com.yihu.hos.rest.models.crawler.patient.Patient;
import com.yihu.hos.rest.models.standard.adapter.AdapterDatasetModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterDictEntryModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterSchemeVersionModel;
import com.yihu.hos.rest.models.standard.bo.AdapterVersion;
import com.yihu.hos.rest.services.standard.adapter.*;
import com.yihu.hos.web.framework.model.DictItem;
import com.yihu.hos.web.framework.model.Result;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
@Service("CrawlerFlowManager")
public class CrawlerFlowManager {
    private static Logger logger = LoggerFactory.getLogger(CrawlerFlowManager.class);
    private static DataCollectDispatcher dispatch = DataCollectDispatcher.getInstance();
    private static SysConfig sysConfig = SysConfig.getInstance();
    private Map<String, AdapterDataSet> adapterDataSetMap;
    private List<CrawlerFlowHeadModel> crawlerFlowHeadModelList;
    private Map<String, List<CrawlerFlowModel>> crawlerFlowDatasetMap;
    private Map<String, List<CrawlerFlowModel>> crawlerFlowMetadataMap;
    private Boolean adapterFlg = false;
    private List<DictItem> datasetList;
    private String schemeVersion;
    @Resource
    private AdapterDatasetService adapterDatasetService;
    @Resource
    private AdapterMetadataService adapterMetadataService;
    @Resource
    private AdapterDictService adapterDictService;
    @Resource
    private AdapterSchemeVersionService adapterSchemeVersionService;
    @Resource
    CrawlerDatasetDao crawlerDatasetDao;
    @Resource
    CrawlerFlowHeadDao crawlerFlowHeadDao;
    @Resource
    CrawlerFlowDao crawlerFlowDao;
    public CrawlerFlowManager(List datasetList, String schemeVersion) {
        this.datasetList = datasetList;
        this.schemeVersion = schemeVersion;
    }
    public CrawlerFlowManager() {
    }
    public void finalize() throws Throwable {
    }
    public Result dataCrawler(Date beginDate, Date endDate) {
        Map<String, Object> condition = new HashMap<>();
        condition.put("beginDate", beginDate);
        condition.put("endDate", endDate);
        Integer count = 0;
        Integer totalCount = 0;
        String message;
        /**
         * 适配基本数据准备
         */
        if (!getDataForPrepare()) {
            message = "适配数据尚未准备";
            logger.error(message);
            return Result.error(message);
        }
        List<Patient> patientList = dispatch.getPatientList(condition, adapterDataSetMap);
        if (!CollectionUtil.isEmpty(patientList)) {
            totalCount = patientList.size();
            for (Patient patient : patientList) {
                boolean result = collectProcess(patient);
                if (result) {
                    count++;
                }
            }
        }
        message = "本次采集病人共" + totalCount + "条,成功采集信息" + count + "条";
        return Result.success(message);
    }
    public boolean collectProcess(Patient patient) {
        if (!getDataForPrepare()) {
            logger.error("适配数据尚未准备完毕");
            return false;
        }
        patient.setReUploadFlg(StringUtil.toString(false));
        logger.trace("采集->注册->打包上传,任务ID:,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
        try {
            /**
             * 获取token
             */
            if (!dispatch.getToken()) {
                logger.error("token获取失败");
                return false;
            }
            /**
             * 获取远程版本
             */
//            if (!dispatch.getRemoteVersion(patient.getOrgCode())) {
//                logger.error("远程版本获取失败");
//                return false;
//            }
            /**
             * 获取版本
             */
            if (StringUtil.isEmpty(sysConfig.getVersionMap().get(patient.getOrgCode()))) {
                logger.error("版本获取失败");
                return false;
            }
            Map<String, JsonNode> dataMap = new HashMap<>();
            for (CrawlerFlowHeadModel crawlerFlowHeadModel : crawlerFlowHeadModelList) {
                /**
                 * 采集信息
                 */
                String datasetCode = crawlerFlowHeadModel.getDatasetCode();
                AdapterDataSet adapterDataSet = adapterDataSetMap.get(datasetCode);
                String stdVersion = adapterDatasetService.getStdVersionByAdapterDataSet(this.schemeVersion);
                JsonNode data = null;
                if (!StringUtil.isEmpty(stdVersion)){
                    data = dispatch.fecthData(patient, adapterDataSet,stdVersion);
                }
                if (StringUtil.isEmpty(data)) {
                    continue;
                }
                dataMap.put(datasetCode, data);
                /**
                 * 根据采集流程递归查询
                 */
                getDataByCrawlerFlow(datasetCode, patient, dataMap);
                if (sysConfig.getRegisterDataSet().equals(adapterDataSet.getAdapterDataSetT().getStdDatasetCode())) {
                    if (!StringUtil.isEmpty(data.get("data")) && !StringUtil.isEmpty(data.get("data").get(0))) {
                        if (!StringUtil.isEmpty(data.get("data").get(0).get(SysConfig.getInstance().getRegisterIdCardNo()))) {
                            logger.info("注册病人");
                            dispatch.register(patient, data.toString());
                        }
                    }
                }
            }
            logger.info("采集病人成功,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
            /**
             * 上传档案
             */
            try {
                if (!CollectionUtil.isEmpty(dataMap.keySet())) {
                    //TODO set stdDatasetMap 2017/05/02
                    if (!dispatch.upload(dataMap, patient, adapterDataSetMap,null)) {
                        logger.error("上传档案失败");
                        return false;
                    }
                }
            } catch (Exception e) {
                logger.error("档案上传失败,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
                return false;
            }
        } catch (Exception e) {
            logger.error("采集病人失败,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo(), e);
            return false;
        }
        return true;
    }
    public Boolean getDataByCrawlerFlow(String preDatasetCode, Patient patient, Map<String, JsonNode> dataMap) {
        try {
            JsonNode preData = dataMap.get(preDatasetCode);
            Map<String, String> relationValueMap = new HashMap<>();
            List<CrawlerFlowModel> crawlerFlowDatasetList = crawlerFlowDatasetMap.get(preDatasetCode);
            for (CrawlerFlowModel crawlerFlowDataset : crawlerFlowDatasetList) {
                List<CrawlerFlowModel> crawlerFlowMetadataList = crawlerFlowMetadataMap.get(crawlerFlowDataset.getDatasetCode());
                for (CrawlerFlowModel crawlerFlowMetadata : crawlerFlowMetadataList) {
                    String metadataCode = crawlerFlowMetadata.getMetadataCode();
                    metadataCode = StringUtil.substring(metadataCode, metadataCode.indexOf("-") + 1, metadataCode.length());
                    String inputMetadataCode = crawlerFlowMetadata.getInputMetadataCode();
                    inputMetadataCode = StringUtil.substring(inputMetadataCode, inputMetadataCode.indexOf("-") + 1, inputMetadataCode.length());
                    Iterator<JsonNode> array = preData.get("data").iterator();
                    while (array.hasNext()) {
                        JsonNode dataNode = array.next();
                        relationValueMap.put(metadataCode, dataNode.get(inputMetadataCode).asText());
                    }
                }
                String datasetCode = crawlerFlowDataset.getDatasetCode();
                AdapterDataSet adapterDataSet = adapterDataSetMap.get(datasetCode);
                String data = dispatch.fecthData(patient, adapterDataSet, relationValueMap);
                if (StringUtil.isEmpty(data)) {
                    continue;
                } else {
                    ObjectMapper objectMapper = new ObjectMapper();
                    JsonNode jsonObject = objectMapper.readTree(data);
                    dataMap.put(datasetCode, jsonObject);
                }
                getDataByCrawlerFlow(datasetCode, patient, dataMap);
            }
            return true;
        } catch (Exception e) {
            return false;
        }
    }
    public Boolean getDataForPrepare() {
        if (adapterFlg) {
            return true;
        }
        AdapterBase.setAdapterMetadataService(adapterMetadataService);
        AdapterBase.setAdapterDictService(adapterDictService);
        AdapterBase.setAdapterSchemeVersionService(adapterSchemeVersionService);
        logger.info("适配基本相关数据准备");
        try {
            adapterDataSetMap = new HashMap<>();
            AdapterVersion adapterVersion;
            List<Long> datasetIdList = new ArrayList<>();
            /**
             * 推模式接口调用,默认只使用最新版本的适配
             */
            AdapterSchemeVersionModel adapterSchemeVersionModel;
            if (datasetList.isEmpty()) {
                adapterSchemeVersionModel = adapterSchemeVersionService.getEhrAdapterVersionLasted();
                if (adapterSchemeVersionModel == null) {
                    logger.error("获取最新ehr适配版本错误");
                    return false;
                } else {
                    this.schemeVersion = adapterSchemeVersionModel.getVersion();
                    adapterVersion = new AdapterVersion(schemeVersion);
                }
                /**
                 * 获取该版本下数据集
                 */
                List<CrawlerDataSetModel> crawlerDataSetModelList = crawlerDatasetDao.getCrawlerDatasetList(adapterSchemeVersionModel.getId());
                if (CollectionUtil.isEmpty(crawlerDataSetModelList)) {
                    return false;
                }
                for (CrawlerDataSetModel crawlerDataSetModel : crawlerDataSetModelList) {
                    datasetIdList.add(crawlerDataSetModel.getDatasetId());
                }
            } else {
                /**
                 * 拉模式接口调用,由任务配置决定适配版本
                 */
                adapterSchemeVersionModel = adapterSchemeVersionService.getByVersion(schemeVersion);
                adapterVersion = new AdapterVersion(schemeVersion);
                for (DictItem dictItem : datasetList) {
                    datasetIdList.add(Long.valueOf(dictItem.getCode()));
                }
            }
            /**
             * 字典项初始化
             */
            List<AdapterDictEntryModel> adapterDictEntryModelList = adapterDatasetService.getList(AdapterDictEntryModel.class, adapterVersion.getDictEntryTableName(), null, null, null, null);
            Map<Long, List<AdapterDictEntryModel>> adapterDictEntryModelMap = new HashMap<>();
            for (AdapterDictEntryModel adapterDictEntryModel : adapterDictEntryModelList) {
                List<AdapterDictEntryModel> entryModelList = adapterDictEntryModelMap.get(adapterDictEntryModel.getStdDictId());
                if (CollectionUtil.isEmpty(entryModelList)) {
                    entryModelList = new ArrayList<>();
                }
                entryModelList.add(adapterDictEntryModel);
                adapterDictEntryModelMap.put(adapterDictEntryModel.getStdDictId(), entryModelList);
            }
            /**
             * 数据集初始化
             */
            List<AdapterDatasetModel> adapterDataSetModelList = adapterDatasetService.getListByAdapterDatasetIdList(adapterVersion, datasetIdList);
            for (AdapterDatasetModel adapterDatasetModel : adapterDataSetModelList) {
                adapterDataSetMap.put(adapterDatasetModel.getStdDatasetCode(), new AdapterDataSet(adapterDatasetModel, adapterVersion, adapterDictEntryModelMap));
            }
            /**
             * 获取采集流程表头
             */
            crawlerFlowHeadModelList = crawlerFlowHeadDao.getCrawlerFlowHeadList(adapterSchemeVersionModel.getId());
            List<CrawlerFlowModel> crawlerFlowModelList = crawlerFlowDao.getCrawlerFlowList(adapterSchemeVersionModel.getId());
            crawlerFlowDatasetMap = new HashMap<>();
            crawlerFlowMetadataMap = new HashMap<>();
            /**
             * 获取关联表
             */
            for (CrawlerFlowModel crawlerFlowModel : crawlerFlowModelList) {
                List<CrawlerFlowModel> datasetList = new ArrayList<>();
                List<CrawlerFlowModel> metadataList = new ArrayList<>();
                String inputDatasetCode = crawlerFlowModel.getInputDatasetCode();
                String datasetCode = crawlerFlowModel.getDatasetCode();
                if (StringUtil.isEmpty(inputDatasetCode)) {
                    continue;
                }
                if (crawlerFlowDatasetMap.containsKey(inputDatasetCode)) {
                    datasetList = crawlerFlowDatasetMap.get(inputDatasetCode);
                }
                datasetList.add(crawlerFlowModel);
                crawlerFlowDatasetMap.put(inputDatasetCode, datasetList);
                if (crawlerFlowMetadataMap.containsKey(datasetCode)) {
                    metadataList = crawlerFlowMetadataMap.get(datasetCode);
                }
                metadataList.add(crawlerFlowModel);
                crawlerFlowMetadataMap.put(datasetCode, metadataList);
            }
//            SysConfig.getInstance().setVersionMap(new HashMap<>());
            adapterFlg = true;
            return true;
        } catch (Exception e) {
            adapterFlg = false;
            return false;
        }
    }
    /**
     * 解析病人索引信息
     *
     * @param patientInfo 病人索引信息
     * @return
     */
    public Patient parsePatient(String patientInfo) {
        try {
            ObjectMapper mapper = new ObjectMapper();
            Patient patient = mapper.readValue(patientInfo, Patient.class);
            return patient;
        } catch (Exception e) {
            logger.error("patient参数错误:" + patientInfo, e);
            return null;
        }
    }
    public void setAdapterFlg(Boolean adapterFlg) {
        this.adapterFlg = adapterFlg;
    }
}

+ 514 - 0
src/main/java/com/yihu/hos/rest/services/crawler/CrawlerManager.java

@ -0,0 +1,514 @@
package com.yihu.hos.rest.services.crawler;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.hos.core.datatype.CollectionUtil;
import com.yihu.hos.core.datatype.DateUtil;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.rest.common.format.AdapterBase;
import com.yihu.hos.rest.common.format.StdBase;
import com.yihu.hos.rest.models.crawler.adapter.AdapterDataSet;
import com.yihu.hos.rest.models.crawler.adapter.AdapterMetaData;
import com.yihu.hos.rest.models.crawler.adapter.StdDataSet;
import com.yihu.hos.rest.models.crawler.config.SysConfig;
import com.yihu.hos.rest.models.crawler.patient.Patient;
import com.yihu.hos.rest.models.crawler.patient.PatientIdentity;
import com.yihu.hos.rest.models.crawler.qc.QcDaily;
import com.yihu.hos.rest.models.crawler.qc.QcPatientIndex;
import com.yihu.hos.rest.models.crawler.transform.EhrCondition;
import com.yihu.hos.rest.models.rs.RsJobConfig;
import com.yihu.hos.rest.models.standard.adapter.AdapterDatasetModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterDictEntryModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterSchemeModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterSchemeVersionModel;
import com.yihu.hos.rest.models.standard.bo.AdapterVersion;
import com.yihu.hos.rest.models.standard.bo.StandardVersion;
import com.yihu.hos.rest.models.standard.standard.StdMetaDataModel;
import com.yihu.hos.rest.services.standard.adapter.*;
import com.yihu.hos.rest.services.standard.standard.StdMetadataService;
import com.yihu.hos.web.framework.model.DataGridResult;
import com.yihu.hos.web.framework.model.DictItem;
import com.yihu.hos.web.framework.model.Result;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
@Service("qCCrawlerManager")
public class CrawlerManager {
    public static final String BEAN_ID = "qCCrawlerManager";
    private static String unstructured = "unstructured";
    private static Logger logger = LoggerFactory.getLogger(CrawlerManager.class);
    @Resource
    private AdapterDatasetService adapterDatasetService;
    @Resource
    private AdapterMetadataService adapterMetadataService;
    @Resource
    private AdapterDictService adapterDictService;
    @Resource
    private AdapterSchemeVersionService adapterSchemeVersionService;
    @Resource
    private DatacollectManager datacollect;
    @Resource
    private StdMetadataService StdMetadataService;
    @Resource(name = AdapterSchemeService.BEAN_ID)
    private AdapterSchemeService adapterSchemeService;
    @Resource
    private ObjectMapper objectMapper;
    private static DataCollectDispatcher dispatch = DataCollectDispatcher.getInstance();
    private static SysConfig sysConfig = SysConfig.getInstance();
    private static Map<String, Map<String, AdapterDataSet>> adapterDataSetVersionMap = new HashMap<>();
    private static Map<String, Map<String, StdDataSet>> stdDataSetVersionMap = new HashMap<>();
    private static Map<Long, List<StdMetaDataModel>> stdMetaDataMap = new HashMap<>();
    private Map<String, AdapterDataSet> adapterDataSetMap;
    private Map<String, StdDataSet> stdDataSetMap;
    private Boolean adapterFlg = false;
    private Boolean stdFlg = false;
    private String schemeVersion;
    private List<DictItem> datasetList;
    public void finalize() throws Throwable {
    }
    /**
     * 病人事件列表
     *
     * @param jobId
     * @return
     * @throws Exception
     */
    public List<Patient> PatientListByJobId(String jobId) throws Exception {
        RsJobConfig rsJobConfig = datacollect.getJobById(jobId);
        logger.info("质控服务-病人列表获取jobId:" + jobId);
        Date begin = rsJobConfig.getRepeatStartTime();
        Date end = rsJobConfig.getRepeatEndTime();
        if (end == null) {
            int totalOffset = rsJobConfig.getDelayTime();
            Calendar instance = Calendar.getInstance();
            instance.setTime(new Date(DateUtil.getSysDateTime().getTime()));
            instance.add(Calendar.SECOND, -totalOffset);    //调整截止时间,当前时间-偏移量
            end = instance.getTime();
        }
        if ((end.getTime() - begin.getTime()) <= 0) {
            System.out.println("质控服务-错误:采集结束时间小于开始时间!"); //结束时间小于开始时间时,不获取
            return null;
        }
        end = DateUtil.fromatDateToTimestamp(end);
        if (!rsJobConfig.getJobType().equals("0")) {
            //调整截止时间,当前时间-偏移量
            end = DateUtil.addDate(-rsJobConfig.getDelayTime(), DateUtil.getSysDateTime());
            if ((end.getTime() - begin.getTime()) <= 0) {
                System.out.println("质控服务-错误:采集结束时间小于开始时间!"); //结束时间小于开始时间时,不获取
                return null;
            }
        }
        if (DateUtil.getDifferenceOfDays(begin, end) > 1) {
            end = DateUtil.addDate(1, begin);
            end = DateUtil.fromatDateToTimestamp(end);
        }
        DataGridResult dataGridResult = datacollect.getJobDatasetByJobId(jobId);
        this.datasetList = dataGridResult.getDetailModelList();
        this.schemeVersion = rsJobConfig.getSchemeVersion();
        List<Patient> patientList = getPatientList(begin, end);
        return patientList;
    }
    public List<Patient> getPatientList(Date beginDate, Date endDate) {
        Map<String, Object> condition = new HashMap<>();
        condition.put("beginDate", beginDate);
        condition.put("endDate", endDate);
        Integer count = 0;
        Integer totalCount = 0;
        String message;
        /**
         * 适配基本数据准备
         */
        if (!getDataForPrepare()) {
            message = "适配数据尚未准备";
            logger.error(message);
            return null;
        }
        List<Patient> patientList = dispatch.getPatientList(condition, adapterDataSetMap);
        return patientList;
    }
    /**
     * 上传档案/质控上传
     * @param jobId
     * @param checkType
     * @return
     * @throws Exception
     */
    public Result dataCrawlerByJobId(String jobId,String checkType) throws Exception {
        RsJobConfig rsJobConfig = datacollect.getJobById(jobId);
        String random = UUID.randomUUID().toString();
        logger.info("数据采集上传开始,流水号:" + random + ",jobId:"+jobId);
        Date begin = rsJobConfig.getRepeatStartTime();
        Date end = rsJobConfig.getRepeatEndTime();
        if (end == null) {
            int totalOffset = rsJobConfig.getDelayTime();
            Calendar instance = Calendar.getInstance();
            instance.setTime(new Date(DateUtil.getSysDateTime().getTime()));
            instance.add(Calendar.SECOND, - totalOffset);    //调整截止时间,当前时间-偏移量
            end = instance.getTime();
        }
        if ((end.getTime() - begin.getTime()) <= 0) {
            return Result.error("错误:采集上传结束时间小于开始时间!jobId: "+jobId +",start:"+begin.toString()+" end: "+end.toString()); //结束时间小于开始时间时,不获取
        }
        end = DateUtil.fromatDateToTimestamp(end);
        if (!rsJobConfig.getJobType().equals("0")) {
            //调整截止时间,当前时间-偏移量
            end = DateUtil.addDate(-rsJobConfig.getDelayTime(), DateUtil.getSysDateTime());
            if ((end.getTime() - begin.getTime()) <= 0) {
                return Result.error("调整截止时间偏移量错误:采集上传结束时间小于开始时间!jobId: " + jobId + ",start:" + begin.toString() + " end: " + end.toString()); //结束时间小于开始时间时,不获取
            }
        }
        if (DateUtil.getDifferenceOfDays(begin, end) > 1) {
            end = DateUtil.addDate(1, begin);
            end = DateUtil.fromatDateToTimestamp(end);
        }
        DataGridResult dataGridResult = datacollect.getJobDatasetByJobId(jobId);
        this.datasetList = dataGridResult.getDetailModelList();
        this.schemeVersion = rsJobConfig.getSchemeVersion();
        Result result = dataCrawler(begin, end,checkType);
        if (!rsJobConfig.getJobType().equals("0")) {
            rsJobConfig.setRepeatStartTime(end);
//            rsJobConfig.setRepeatEndTime(DateUtil.formatYMDToYMDHMS(DateUtil.getSysDateTime().toString()));
        }
        datacollect.updateJob(rsJobConfig);
        logger.info("采集上传结束,流水号:" + random + ",jobId:" + jobId + ",message:" + result.getMessage());
        return result;
    }
    public Result dataCrawler(Date beginDate, Date endDate,String checkType) {
        Map<String, Object> condition = new HashMap<>();
        condition.put("beginDate", beginDate);
        condition.put("endDate", endDate);
        Integer count = 0;
        Integer totalCount = 0;
        String message;
        /**
         * 适配基本数据准备
         */
        if (!getDataForPrepare()) {
            message = "适配数据尚未准备";
            logger.error(message);
            return Result.error(message);
        }
        List<Patient> patientList = dispatch.getPatientList(condition, adapterDataSetMap);
        if (!CollectionUtil.isEmpty(patientList)) {
            totalCount = patientList.size();
            QcDaily qcDaily = genQcDaily(patientList);
            QcPatientIndex qcPatientIndex =null;
            for (Patient patient : patientList) {
                Boolean result = collectProcess(patient,checkType);
                String utcTime = DateUtil.getUtcDate(patient.getReferenceTime(),DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
                qcPatientIndex = new QcPatientIndex(patient.getPatientId(),patient.getEventNo(),utcTime);
                qcDaily.addTotal(qcPatientIndex,patient.getDataSet());
                if (result) {
                    count++;
                    qcDaily.addReal(qcPatientIndex,patient.getDataSet());
                }
            }
            if (qcDaily!=null){
                qcDaily.setOrg_code(patientList.get(0).getOrgCode());
                qcDaily.setInner_version(this.schemeVersion);
                qcDaily.setCreate_date(DateUtil.getCurrentString(DateUtil.DATE_WORLD_FORMAT));
                qcDaily.setTotal_outpatient_num(qcDaily.getTotal_outpatient().size());
                qcDaily.setTotal_hospital_num(qcDaily.getTotal_hospital().size());
                qcDaily.setReal_outpatient_num(qcDaily.getReal_outpatient().size());
                qcDaily.setReal_hospital_num(qcDaily.getReal_hospital().size());
                boolean b = dispatch.uploadQcDaily(objectMapper.convertValue(qcDaily, JsonNode.class),patientList.get(0));
                if (!b){
                    logger.debug("质控服务-日报包上传失败!!!");
                }
            }
        }
        message = "本次上传病人共" + totalCount + "条,成功上传信息"+ count + "条";
        return Result.success(message);
    }
    //单个病人质控数据采集上传
    public Boolean collectProcess(Patient patient, String collectType) {
        if (!getDataForPrepare()) {
            logger.error("适配数据尚未准备");
            return false;
        }
        patient.setReUploadFlg(StringUtil.toString(false));
        logger.trace("采集->质控分析->打包上传,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
        try {
            if (StringUtil.isEmpty(sysConfig.getVersionMap().get(patient.getOrgCode()))) {
                Map.Entry<String, AdapterDataSet> next = adapterDataSetMap.entrySet().iterator().next();
                Long schemeId = next.getValue().getAdapterDataSetT().getSchemeId();
                AdapterSchemeModel schemeModel = adapterSchemeService.getEntity(AdapterSchemeModel.class, schemeId);
                if (schemeModel.getStdVersion() != null) {
                    SysConfig.getInstance().getVersionMap().put(patient.getOrgCode(), schemeModel.getStdVersion());
                } else {
                    logger.error("版本获取失败");
                    return false;
                }
            }
            Map<String, AdapterDataSet> dataSetMap = new HashMap<>();
            Map<String, JsonNode> dataMap = new HashMap<>();
            int realCount = 0;
            List<String> realList = new ArrayList<>();
            ObjectNode qcDataSet = dispatch.genQcDataSet(patient);//获取质控数据结构
            qcDataSet.put("total_num",adapterDataSetMap.size());
            for (String key : adapterDataSetMap.keySet()) {
                /**
                 * 获取数据
                 */
                AdapterDataSet adapterDataSet = adapterDataSetMap.get(key);
                String stdVersion = adapterDatasetService.getStdVersionByAdapterDataSet(this.schemeVersion);
                JsonNode jsonObject = dispatch.fecthData(patient, adapterDataSet,stdVersion);//使用配置中的版本
                if (StringUtil.isEmpty(jsonObject)) {
                    continue;
                }
                dataSetMap.put(adapterDataSet.getAdapterDataSetT().getStdDatasetCode(), adapterDataSet);
                dataMap.put(key, jsonObject);
                realCount++;
                realList.add(key);
            }
            ObjectMapper objectMapper = new ObjectMapper();
            qcDataSet.put("real_num",realCount);
            qcDataSet.set("total", objectMapper.convertValue(adapterDataSetMap.keySet().toArray(), JsonNode.class));
            qcDataSet.set("real", objectMapper.convertValue(realList, JsonNode.class));
            logger.info("上传档案流程-获取病人信息成功,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
            //上传档案
            logger.info("上传病人档案及质控数据");
            try {
                if (!CollectionUtil.isEmpty(dataMap.keySet())) {
                    if (StringUtil.isEmpty(collectType)) {
                        //采集档案
                        if (!dispatch.upload(dataMap, patient, dataSetMap, stdDataSetMap)) {
                            logger.error("上传档案失败");
                            return false;
                        }
                    } else {
                        //TODO 规则检验
                        boolean b = dispatch.toQcDataSetFile(qcDataSet, patient);//生成数据集质控文件
                        if (!dispatch.uploadQcData(dataMap, patient, dataSetMap, stdDataSetMap,collectType)) {
                            logger.error("上传质控包失败");
                            return false;
                        }
                        if (!dispatch.upload(dataMap, patient, dataSetMap, stdDataSetMap)) {
                            logger.error("上传档案失败");
                            return false;
                        }
                    }
                }
            } catch (Exception e) {
                logger.error("质控数据上传失败,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
                return false;
            }
        } catch (Exception e) {
            logger.error("采集质控数据失败,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo(), e);
            return false;
        }
        return true;
    }
    public Boolean getDataForPrepare() {
        if (adapterFlg && stdFlg) {
            return true;
        }
        AdapterBase.setAdapterMetadataService(adapterMetadataService);
        AdapterBase.setAdapterDictService(adapterDictService);
        AdapterBase.setAdapterSchemeVersionService(adapterSchemeVersionService);
        StdBase.setStdMetadataService(StdMetadataService);
        logger.info("适配基本相关数据准备");
        try {
            adapterDataSetMap = new HashMap<>();
            stdDataSetMap = new HashMap<>();
            AdapterVersion adapterVersion;
            StandardVersion standardVersion = null;
            List<AdapterDatasetModel> adapterDataSetModelList;
            if (!CollectionUtil.isEmpty(datasetList)) {
                /**
                 * 拉模式接口调用,由任务配置决定适配版本
                 */
                adapterVersion = new AdapterVersion(schemeVersion);
                List<Integer> datasetIdList = new ArrayList<>();
                for (DictItem dictItem : datasetList) {
                    Integer dataSetId = Integer.parseInt(dictItem.getCode());
                    datasetIdList.add(dataSetId);
                }
                adapterDataSetModelList = adapterDatasetService.getAdapterDatasetByAdapterIdList(adapterVersion, datasetIdList);
                if (adapterDataSetModelList != null && !adapterDataSetModelList.isEmpty()) {
                    AdapterSchemeModel adapterScheme = adapterSchemeService.getEntity(AdapterSchemeModel.class, adapterDataSetModelList.get(0).getSchemeId());
                    standardVersion = new StandardVersion(adapterScheme.getStdVersion());
                    for (DictItem dictItem : datasetList) {
                        Long dataSetId = Long.parseLong(dictItem.getCode());
                        if (!stdMetaDataMap.containsKey(dataSetId)) {
                            stdMetaDataMap.put(dataSetId, new StdDataSet(dataSetId, standardVersion).getStdMetaDataModelList());
                        }
                    }
                }
            } else {
                /**
                 * 推模式接口调用,默认只使用最新版本的适配
                 */
                AdapterSchemeVersionModel adapterSchemeVersionModel = adapterSchemeVersionService.getEhrAdapterVersionLasted();
                if (adapterSchemeVersionModel == null) {
                    logger.error("获取最新ehr适配版本错误11");
                    return false;
                } else {
                    this.schemeVersion = adapterSchemeVersionModel.getVersion();
                    adapterVersion = new AdapterVersion(schemeVersion);
                }
                if (adapterDataSetVersionMap.get(schemeVersion) != null) {
                    adapterDataSetMap = adapterDataSetVersionMap.get(schemeVersion);
                    adapterFlg = true;
                }
                //获取标准版本
                AdapterSchemeModel adapterScheme = adapterSchemeService.getEntity(AdapterSchemeModel.class,adapterSchemeVersionModel.getSchemeId());
                standardVersion = new StandardVersion(adapterScheme.getStdVersion());
                if (stdDataSetVersionMap.get(schemeVersion) != null) {
                    stdDataSetMap = stdDataSetVersionMap.get(schemeVersion);
                    stdFlg = true;
                }
                if (adapterFlg && stdFlg) {
                    return true;
                }
                Map<String, String> condition = new HashMap<>();
                condition.put("column", "adapter_dataset_code");
                ObjectMapper mapper = new ObjectMapper();
                String conditionStr = mapper.writeValueAsString(condition);
                adapterDataSetModelList = adapterDatasetService.getAdapterDatasetNotNullList(adapterVersion, conditionStr);
            }
            /**
             * 字典项初始化
             */
            List<AdapterDictEntryModel> adapterDictEntryModelList = adapterDatasetService.getList(AdapterDictEntryModel.class, adapterVersion.getDictEntryTableName(), null, null, null, null);
            Map<Long, List<AdapterDictEntryModel>> adapterDictEntryModelMap = new HashMap<>();
            for (AdapterDictEntryModel adapterDictEntryModel : adapterDictEntryModelList) {
                List<AdapterDictEntryModel> entryModelList = adapterDictEntryModelMap.get(adapterDictEntryModel.getStdDictId());
                if (CollectionUtil.isEmpty(entryModelList)) {
                    entryModelList = new ArrayList<>();
                }
                entryModelList.add(adapterDictEntryModel);
                adapterDictEntryModelMap.put(adapterDictEntryModel.getStdDictId(), entryModelList);
            }
            /**
             * 数据集初始化
             */
            for (AdapterDatasetModel adapterDatasetModel : adapterDataSetModelList) {
                adapterDataSetMap.put(adapterDatasetModel.getStdDatasetCode(), new AdapterDataSet(adapterDatasetModel, adapterVersion, adapterDictEntryModelMap));
                stdDataSetMap.put(adapterDatasetModel.getStdDatasetCode(), new StdDataSet(adapterDatasetModel.getStdDatasetId(), standardVersion));
            }
            adapterDataSetVersionMap.put(schemeVersion, adapterDataSetMap);
            stdDataSetVersionMap.put(schemeVersion, stdDataSetMap);
            adapterFlg = true;
            stdFlg = true;
            return true;
        } catch (Exception e) {
            return false;
        }
    }
    /**
     * 解析病人索引信息
     *
     * @param patientInfo 病人索引信息
     * @return
     */
    public Patient parsePatient(String patientInfo) {
        try {
            ObjectMapper mapper = new ObjectMapper();
            Patient patient = mapper.readValue(patientInfo, Patient.class);
            return patient;
        } catch (Exception e) {
            logger.error("patient参数错误:" + patientInfo, e);
            return null;
        }
    }
    public void setSchemeVersion(String schemeVersion) {
        this.schemeVersion = schemeVersion;
    }
    public void setDatasetList(List<DictItem> datasetList) {
        this.datasetList = datasetList;
    }
    public QcDaily genQcDaily(List<Patient> patients){
        QcDaily qcDaily = new QcDaily();
        if (patients!=null && patients.isEmpty()){
            qcDaily.setOrg_code(patients.get(0).getOrgCode());
            qcDaily.setInner_version(SysConfig.getInstance().getVersionMap().get(patients.get(0).getOrgCode()));
            qcDaily.setCreate_date(DateUtil.getUtcDate(new Date()));
        }
        return qcDaily;
    }
    public String getPatientIdCode(String datasetCode){
        AdapterDataSet adapterDataSet = adapterDataSetMap.get(datasetCode);
        if (adapterDataSet.isHavePatientID()) {
            AdapterMetaData adapterMetaData = adapterDataSet.getAdapterMetaDataMap().get(PatientIdentity.getPatientIDCode());
            if (adapterMetaData.getAdapterMetadataModel()!=null){
                return adapterMetaData.getAdapterMetadataModel().getStdMetadataCode();
            }else {
                return null;
            }
        }
        return null;
    }
    public String getEventNoCode(String datasetCode){
        AdapterDataSet adapterDataSet = adapterDataSetMap.get(datasetCode);
        List<EhrCondition> queryParams = new ArrayList<>();
        boolean patientIdCode = true;
        if (adapterDataSet.isHaveEventNo()) {
            AdapterMetaData adapterMetaData = adapterDataSet.getAdapterMetaDataMap().get(adapterDataSet.getEventNoCode());
            if (adapterMetaData.getAdapterMetadataModel()!=null){
                return adapterMetaData.getAdapterMetadataModel().getStdMetadataCode();
            }else {
                return null;
            }
        }
        return null;
    }
}

+ 663 - 0
src/main/java/com/yihu/hos/rest/services/crawler/CrawlerService.java

@ -0,0 +1,663 @@
package com.yihu.hos.rest.services.crawler;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.ehr.dbhelper.common.DBList;
import com.yihu.ehr.dbhelper.common.MongodbQuery;
import com.yihu.ehr.dbhelper.common.QueryCondition;
import com.yihu.ehr.dbhelper.common.QueryEntity;
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.rest.common.dao.CrawlerDatasetDao;
import com.yihu.hos.rest.common.dao.CrawlerFlowDao;
import com.yihu.hos.rest.common.dao.CrawlerFlowHeadDao;
import com.yihu.hos.rest.models.crawler.flow.CrawlerDataSetModel;
import com.yihu.hos.rest.models.crawler.flow.CrawlerFlowHeadModel;
import com.yihu.hos.rest.models.crawler.flow.CrawlerFlowModel;
import com.yihu.hos.rest.models.crawler.flow.resultModel.*;
import com.yihu.hos.rest.models.rs.DtoJobDataset;
import com.yihu.hos.rest.models.standard.adapter.AdapterDatasetModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterMetadataModel;
import com.yihu.hos.rest.models.standard.adapter.AdapterSchemeVersionModel;
import com.yihu.hos.rest.models.standard.adapter.resultModel.AdapterSchemeResultModel;
import com.yihu.hos.rest.models.standard.adapter.resultModel.AdapterSchemeVersionResultDetailModel;
import com.yihu.hos.rest.models.standard.bo.AdapterVersion;
import com.yihu.hos.rest.services.standard.adapter.AdapterDatasetService;
import com.yihu.hos.rest.services.standard.adapter.AdapterMetadataService;
import com.yihu.hos.rest.services.standard.adapter.AdapterSchemeService;
import com.yihu.hos.rest.services.standard.adapter.AdapterSchemeVersionService;
import com.yihu.hos.web.framework.constant.SqlConstants;
import com.yihu.hos.web.framework.model.ActionResult;
import com.yihu.hos.web.framework.model.DetailModelResult;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.bson.types.ObjectId;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Blob;
import java.util.*;
@Transactional
@Service("CrawlerService")
public class CrawlerService {
    public static final String BEAN_ID = "CrawlerService";
    @Resource(name = AdapterSchemeVersionService.BEAN_ID)
    private AdapterSchemeVersionService adapterSchemeVersionService;
    @Resource(name = AdapterDatasetService.BEAN_ID)
    private AdapterDatasetService adapterDatasetService;
    @Resource(name = CrawlerDatasetDao.BEAN_ID)
    private CrawlerDatasetDao crawlerDatasetDao;
    @Resource(name = CrawlerFlowDao.BEAN_ID)
    private CrawlerFlowDao crawlerFlowDao;
    @Resource(name = CrawlerFlowHeadDao.BEAN_ID)
    private CrawlerFlowHeadDao crawlerFlowHeadDao;
    @Resource(name = AdapterMetadataService.BEAN_ID)
    private AdapterMetadataService adapterMetadataService;
    private static Map<Integer, List<FlowLines>> lineCache = new HashMap<>();
    @Resource(name = AdapterSchemeService.BEAN_ID)
    private AdapterSchemeService adapterSchemeService;
    public static Map<Integer, List<FlowLines>> getLineCache() {
        return lineCache;
    }
    /**
     * 保存编排映射关系
     *
     * @param version 适配方案版本
     * @param json    映射数据
     * @return
     * @throws Exception
     */
    public ActionResult saveDataSetRelation(String version, String json) throws Exception {
        ObjectMapper mapper = new ObjectMapper();
        ObjectNode root = mapper.readValue(json,ObjectNode.class);
        ArrayNode jsonList = (ArrayNode) root.get("lines");
        ArrayNode entrances = (ArrayNode) root.get("entrances");
        AdapterSchemeVersionModel versionModel = (AdapterSchemeVersionModel) adapterSchemeVersionService.get(Long.valueOf(version));
        if (jsonList != null && jsonList.size() > 0) {
            // 删除旧关联关系
            crawlerFlowDao.deleteCrawlerFlowList(versionModel.getId());
            for (JsonNode obj : jsonList) {
                String from = obj.get("from").toString();
                String to = obj.get("to").toString();
                String fromPort = obj.get("fromPort").toString();
                String toPort = obj.get("toPort").toString();
                // 保存编排关系
                CrawlerFlowModel crawlerFlow = new CrawlerFlowModel();
                crawlerFlow.setDatasetCode(to);
                crawlerFlow.setInputDatasetCode(from);
                crawlerFlow.setMetadataCode(toPort);
                crawlerFlow.setInputMetadataCode(fromPort);
                crawlerFlow.setSchemeVersionId(versionModel.getId());
                crawlerFlowDao.saveEntity(crawlerFlow);
            }
            // 删除编排头部信息
            crawlerFlowHeadDao.deleteCrawlerFlowHeadList(versionModel.getId());
            for (JsonNode obj : entrances) {
                String dataSet = obj.get("dataSet").toString();
                String meta = obj.get("meta").toString();
                //  保存入口数据集
                CrawlerFlowHeadModel headModel = new CrawlerFlowHeadModel();
                headModel.setSchemeVersionId(versionModel.getId());
                headModel.setDatasetCode(dataSet);
                headModel.setMetadataCode(meta);
                crawlerFlowHeadDao.saveEntity(headModel);
            }
        }
        return new ActionResult(true, "保存成功!");
    }
    /**
     * 获取任务编排数据集列表
     *
     * @param schemeVersionId
     * @return
     * @throws Exception
     */
    public DetailModelResult getSchemeDataset(Long schemeVersionId, String datasetName) throws Exception {
        AdapterSchemeVersionModel versionModel = (AdapterSchemeVersionModel) adapterSchemeVersionService.get(schemeVersionId);
        //获取适配数据集总和
        Map<String, Object> map = new HashMap<String, Object>();
        String condition = null;
        if (datasetName != null && !"".equals(datasetName)) {
            map.put("name", datasetName);
            //TODO: Use Jackson
//            condition = net.sf.json.JSONObject.fromObject(map).toString();
        }
        List<AdapterDatasetModel> adapterDatasetModelList = adapterDatasetService.getDatasetList(AdapterDatasetModel.class, versionModel.getVersion(), condition, null, null, null);
        // 筛选掉 未适配数据
        List<AdapterDatasetModel> nAdapterDataSetModelList = new ArrayList<>();
        for (AdapterDatasetModel datasetModel : adapterDatasetModelList) {
            if (datasetModel.getAdapterDatasetId() != null && datasetModel.getAdapterDatasetName() != null && datasetModel.getAdapterDatasetCode() != null) {
                nAdapterDataSetModelList.add(datasetModel);
            }
        }
        //获取编排数据集
        List<CrawlerDataSetModel> crawlerDataset = crawlerDatasetDao.getCrawlerDatasetList(versionModel.getId());
        DetailModelResult re = new DetailModelResult();
        List<CrawlerDatasetResultDetailModel> list = new ArrayList<>();
        for (AdapterDatasetModel datasetModel : nAdapterDataSetModelList) {
            if (!StringUtil.isStrEmpty(datasetModel.getAdapterDatasetCode())) {
                List<AdapterMetadataModel> metadatas = adapterMetadataService.getAdapterMetadataByDataset(versionModel.getVersion(), datasetModel.getStdDatasetId());
                if (metadatas != null && metadatas.size() > 0) {
                    CrawlerDatasetResultDetailModel obj = new CrawlerDatasetResultDetailModel();
                    obj.setSchemeVersionId(schemeVersionId);
                    obj.setDatasetId(datasetModel.getStdDatasetId());
                    obj.setDatasetCode(datasetModel.getStdDatasetCode());
                    obj.setDatasetName(datasetModel.getStdDatasetName());
                    obj.setSchemeId(datasetModel.getSchemeId());
                    if (crawlerDataset != null && crawlerDataset.size() > 0) {
                        for (CrawlerDataSetModel cDataSet : crawlerDataset) {
                            if (cDataSet.getDatasetId().equals(datasetModel.getStdDatasetId())) {
                                obj.setSchemeVersionId(cDataSet.getSchemeVersionId());
                                obj.setChecked("1");
                                break;
                            }
                        }
                    }
                    list.add(obj);
                }
            }
        }
        re.setDetailModelList(list);
        return re;
    }
    /**
     * 保存任务编排数据
     *
     * @param json
     * @param rows
     * @param page @return
     * @throws Exception
     */
    public void saveJobData(String json, Integer rows, Integer page) throws Exception {
        ObjectMapper mapper = new ObjectMapper();
        ArrayNode jsonList = mapper.readValue(json,ArrayNode.class);
        //清空当页数据
        deleteCurrentPage(rows, page);
        for (JsonNode obj : jsonList) {
            if (obj.has("schemeId") && obj.has("versionId")) {
                String schemeId = obj.get("schemeId").toString();
                String versionId = obj.get("versionId").toString();
                AdapterSchemeVersionModel versionModel = (AdapterSchemeVersionModel) adapterSchemeVersionService.get(Long.valueOf(versionId));
                if (versionModel != null) {
                    AdapterVersion adapterVersion = new AdapterVersion(versionModel.getVersion());
                    //删除已存在的数据集
                    crawlerDatasetDao.deleteCrawlerDatasetList(versionModel.getId());
                    List<AdapterDatasetModel> adapterDatasetModelList;
                    //根据id字符串获取编排数据集
                    if (obj.has("dataSets")) {
                        List<Long> newDatasetIdList = new ArrayList<>();
                        String dataSetStr = obj.get("dataSets").toString();
                        if (StringUtils.isNotBlank(dataSetStr)) {
                            String[] IdList = dataSetStr.split(",");
                            for (String aIdList : IdList) {
                                if (!Objects.equals(aIdList, "")) {
                                    Long DaSetId = Long.valueOf(aIdList);
                                    newDatasetIdList.add(DaSetId);
                                }
                            }
                        }
                        adapterDatasetModelList = adapterDatasetService.getListByAdapterDatasetIdList(adapterVersion, newDatasetIdList);
                        for (AdapterDatasetModel model : adapterDatasetModelList) {
                            CrawlerDataSetModel dataSetModel = new CrawlerDataSetModel();
                            dataSetModel.setSchemeId(Long.valueOf(schemeId));
                            dataSetModel.setSchemeVersionId(versionModel.getId());
                            dataSetModel.setDatasetId(model.getStdDatasetId());
                            dataSetModel.setDatasetCode(model.getStdDatasetCode());
                            dataSetModel.setDatasetName(model.getStdDatasetName());
                            crawlerDatasetDao.saveEntity(dataSetModel);
                        }
                    }
                    //如果保存传入编排映射关系,进行保存操作
                    if (obj.has("relation") && !Objects.equals(obj.get("relation").toString(), "")) {
                        saveDataSetRelation(versionId, obj.get("relation").toString());
                    }
                }
            }
        }
    }
    public List<FlowEntrance> getFlowEntrances(Long schemeVersionId) {
        List<FlowEntrance> entrances = new ArrayList<>();
        List<CrawlerFlowHeadModel> modelList = crawlerFlowHeadDao.getCrawlerFlowHeadList(schemeVersionId);
        for (CrawlerFlowHeadModel headModel : modelList) {
            FlowEntrance entrance = new FlowEntrance();
            entrance.setDataSet(headModel.getDatasetCode());
            entrance.setMeta(headModel.getMetadataCode());
            entrances.add(entrance);
        }
        return entrances;
    }
    public List<FlowLines> getFlowLines(Long schemeVersionId) {
        List<FlowLines> lines = new ArrayList<>();
        List<CrawlerFlowModel> modelList = crawlerFlowDao.getCrawlerFlowList(schemeVersionId);
        for (CrawlerFlowModel model : modelList) {
            FlowLines line = new FlowLines();
            line.setFrom(model.getInputDatasetCode());
            line.setFromPort(model.getInputMetadataCode());
            line.setTo(model.getDatasetCode());
            line.setToPort(model.getMetadataCode());
            lines.add(line);
        }
        return lines;
    }
    /**
     * 删除编排数据
     *
     * @param version
     */
    @Transactional
    public String deleteJobData(String version) {
        try {
            AdapterSchemeVersionModel versionModel = (AdapterSchemeVersionModel) adapterSchemeVersionService.get(Long.valueOf(version));
            if (versionModel == null || versionModel.getId() == null) {
                return "删除失败";
            }
            //删除对应表记录
            crawlerDatasetDao.deleteCrawlerDatasetList(versionModel.getId());
            crawlerFlowHeadDao.deleteCrawlerFlowHeadList(versionModel.getId());
            crawlerFlowDao.deleteCrawlerFlowList(versionModel.getId());
        } catch (Exception e) {
            e.printStackTrace();
            return "删除失败";
        }
        return SqlConstants.EMPTY;
    }
    /**
     * 数据集列表
     *
     * @param limit  rows
     * @param offset page
     * @return
     */
    public DetailModelResult getDataSetResult(Integer limit, Integer offset) {
        try {
            StringBuffer stringBuffer = new StringBuffer();
            String sql = "SELECT 1 as status, a.scheme_id, a.scheme_version_id, GROUP_CONCAT(a.dataset_id SEPARATOR ',') AS datasetId, GROUP_CONCAT(a.dataset_name SEPARATOR ',') AS datasetName" +
                    " FROM crawler_dataset a " +
                    " GROUP BY a.scheme_id, a.scheme_version_id ";
            stringBuffer.append(sql);
            if (limit != null && offset != null) {
                if (limit > 0 && offset > 0) {
                    stringBuffer.append("  LIMIT " + (offset - 1) * limit + "," + limit);
                }
            }
            stringBuffer.append(" ;");
            Integer total = crawlerDatasetDao.getTotalRows();
            List<Map<String, Object>> list = crawlerDatasetDao.queryListBySql(stringBuffer.toString());
            DetailModelResult detailModelResult = DetailModelResult.success("获取数据集成功");
            detailModelResult.setDetailModelList(list);
            detailModelResult.setTotalCount(total);
            return detailModelResult;
        } catch (Exception e) {
            e.printStackTrace();
            return DetailModelResult.error("获取数据集失败");
        }
    }
    /**
     * 获取编排已选择的适配数据集
     *
     * @param schemeVersionId
     * @param datasetIdStr
     * @return
     * @throws Exception
     */
    public List<MappingDataset> getSchemeDatasetByChecked(Long schemeVersionId, String datasetIdStr) throws Exception {
        AdapterSchemeVersionModel versionModel = (AdapterSchemeVersionModel) adapterSchemeVersionService.get(schemeVersionId);
        //获取适配数据集总和
        AdapterVersion adapterVersion = new AdapterVersion(versionModel.getVersion());
        List<AdapterDatasetModel> adapterDatasetModelList = new ArrayList<>();
        if (datasetIdStr != null && !"".equals(datasetIdStr)) {
            String[] datasetIdList = datasetIdStr.split(",");
            List<Long> newDatasetIdList = new ArrayList<>();
            for (String datasetId : datasetIdList) {
                if (!StringUtil.isStrEmpty(datasetId)) {
                    Long newDatasetId = Long.parseLong(datasetId);
                    newDatasetIdList.add(newDatasetId);
                }
            }
            adapterDatasetModelList = adapterDatasetService.getListByAdapterDatasetIdList(adapterVersion, newDatasetIdList);
        } else {
            adapterDatasetModelList = adapterDatasetService.getDatasetList(AdapterDatasetModel.class, versionModel.getVersion(), null, null, null, null);
        }
        //获取编排数据集
        List<CrawlerDataSetModel> crawlerDataset = crawlerDatasetDao.getCrawlerDatasetList(versionModel.getId());
        List<MappingDataset> list = new ArrayList<>();
        for (AdapterDatasetModel datasetModel : adapterDatasetModelList) {
//            if (crawlerDataset != null && crawlerDataset.size() > 0) {
            MappingDataset obj = new MappingDataset();
//                for (CrawlerDataSetModel cDataSet : crawlerDataset) {
            if (!StringUtil.isStrEmpty(datasetModel.getAdapterDatasetCode())) {
                List<MappingMetadata> metadatas = getMappingMetaDatasByDataset(versionModel.getVersion(), datasetModel.getStdDatasetId());
                obj.setId(datasetModel.getStdDatasetId());
                obj.setCode(datasetModel.getStdDatasetCode());
                obj.setName(datasetModel.getStdDatasetName());
                obj.setData(metadatas);
//                        break;
            }
//                }
            list.add(obj);
//            }
        }
        return list;
    }
    /**
     * 返回前端映射数据元信息
     *
     * @param adapterVersion 适配版本号
     * @param dataSetId      适配数据集ID
     * @return
     */
    public List<MappingMetadata> getMappingMetaDatasByDataset(String adapterVersion, Long dataSetId) {
        List<AdapterMetadataModel> adapterMetadataModels = adapterMetadataService.getAdapterMetadataByDataset(adapterVersion, dataSetId);
        AdapterDatasetModel adapterDatasetModel = adapterMetadataService.getAdapterDataset(adapterVersion, dataSetId);
        List<MappingMetadata> resultList = new ArrayList<>();
        if (adapterMetadataModels != null && adapterMetadataModels.size() > 0) {
            for (AdapterMetadataModel metadataModel : adapterMetadataModels) {
                if (!StringUtil.isStrEmpty(metadataModel.getAdapterMetadataCode())) {
                    MappingMetadata metadata = new MappingMetadata();
                    metadata.setId(metadataModel.getAdapterMetadataId());
                    metadata.setCode(adapterDatasetModel.getAdapterDatasetCode() + "-" + metadataModel.getAdapterMetadataCode());
                    metadata.setName(metadataModel.getAdapterMetadataName());
                    resultList.add(metadata);
                }
            }
        }
        return resultList;
    }
    /**
     * 获取适配方案映射数据
     *
     * @param schemeVersionId
     * @param datasetIdStr
     * @return
     */
    public String getRelations(Integer schemeVersionId, String datasetIdStr, String lineStr) {
        return "";  //TODO: Use jackson
//        JSONObject jsonObject = new JSONObject();
//        try {
//            List<MappingDataset> datasets = getSchemeDatasetByChecked(schemeVersionId, datasetIdStr);
//            List<FlowLines> lines = getFlowLines(schemeVersionId);
//            if (StringUtil.isEmpty(lineStr)) {
//                lines = getFlowLines(schemeVersionId);
//            } else {
//                lines = lineCache.get(schemeVersionId);
//            }
//            jsonObject.put("tables", datasets);
//            jsonObject.put("rels", lines);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return jsonObject.toString();
    }
    public void setLinesCache(Integer schemeVersionId, String lines) throws IOException {
        ObjectMapper objectMapper = new ObjectMapper();
        ObjectNode rootNode = objectMapper.readValue(lines, ObjectNode.class);
        String lineJson = rootNode.get("lines").toString();
        List<FlowLines> line = objectMapper.readValue(lineJson, List.class);
        lineCache.put(schemeVersionId, line);
    }
    public void deleteCurrentPage(Integer rows, Integer page) {
        DetailModelResult currentResut = getDataSetResult(rows, page);
        List<Map<String, Object>> list = currentResut.getDetailModelList();
        for (Map<String, Object> map : list) {
            String version = String.valueOf(map.get("scheme_version_id"));
            deleteJobData(version);
        }
    }
    public DetailModelResult getDataSetSavedResult(Long version) {
        try {
            DetailModelResult checkedSchemeLs = getDataSetResult(null, null);
            List<Map<String, Object>> list = checkedSchemeLs.getDetailModelList();
            for (Map<String, Object> objectMap : list) {
                String versionID = objectMap.get("scheme_version_id").toString();
                if (versionID.equals(version.toString())) {
                    String datasetIdStr = objectMap.get("dataSetId").toString();
                    List<MappingDataset> datasetList = getSchemeDatasetByChecked(version, datasetIdStr);
                    List<DtoJobDataset>  rsJobDatasetList = new ArrayList<>();
                    for (MappingDataset dataset : datasetList) {
                        DtoJobDataset rsJobDataset = new DtoJobDataset();
                        rsJobDataset.setJobDatasetId(dataset.getId().toString());
                        rsJobDataset.setJobDatasetName(dataset.getName());
                        rsJobDataset.setJobDatasetCode(dataset.getCode());
                        rsJobDatasetList.add(rsJobDataset);
                    }
                    DetailModelResult result = new DetailModelResult();
                    result.setDetailModelList(rsJobDatasetList);
                    return result;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            return DetailModelResult.error("获取已存任务编排数据集错误");
        }
        return DetailModelResult.error("获取已存任务编排数据集错误");
    }
    public DetailModelResult getSchemeSavedResult() {
        DetailModelResult allScheme = adapterSchemeService.getAdapterSchemeResultModelList();
        List<AdapterSchemeResultModel> allSchemeLs = allScheme.getDetailModelList();
        if (allSchemeLs != null && allSchemeLs.size() > 0) {
            DetailModelResult checkedSchemeLs = getDataSetResult(null, null);
            List<Map<String, Object>> list = checkedSchemeLs.getDetailModelList();
            Set<String> schemeIdSets = new HashSet<>();
            Set<String> versionSets = new HashSet<>();
            DetailModelResult result = new DetailModelResult();
            List<AdapterSchemeVersionResultDetailModel> versionModelList = new ArrayList<>();
            if (list != null && list.size() > 0) {
                for (Map<String, Object> objectMap : list) {
                    if (objectMap.get("scheme_id") != null && objectMap.get("scheme_version_id") != null) {
                        schemeIdSets.add(objectMap.get("scheme_id").toString());
                        versionSets.add(objectMap.get("scheme_version_id").toString());
                    }
                }
                if (schemeIdSets.size() > 0 && versionSets.size() > 0) {
                    for (AdapterSchemeResultModel schemeL : allSchemeLs) {
                        String schemeID = schemeL.getSchemeId().toString();
                        if (schemeIdSets.contains(schemeID)) {
                            String name = schemeL.getName();
                            List<AdapterSchemeVersionModel> versionModels = schemeL.getVersionList();
                            for (AdapterSchemeVersionModel versionModel : versionModels) {
                                String versionID = versionModel.getId().toString();
                                if (versionSets.contains(versionID)) {
                                    AdapterSchemeVersionResultDetailModel model = new AdapterSchemeVersionResultDetailModel();
                                    model.setSchemeName(name);
                                    model.setId(versionModel.getId());
                                    model.setName(versionModel.getName());
                                    model.setSchemeId(versionModel.getSchemeId());
                                    model.setBaseVersion(versionModel.getBaseVersion());
                                    model.setPath(versionModel.getPath());
                                    model.setPublishStatus(versionModel.getPublishStatus());
                                    model.setPublishTime(versionModel.getPublishTime());
                                    model.setPublishUser(versionModel.getPublishUser());
                                    model.setVersion(versionModel.getVersion());
                                    versionModelList.add(model);
                                }
                            }
                        }
                    }
                    result.setDetailModelList(versionModelList);
                    return result;
                }
            }
        }
        return DetailModelResult.error("获取已编排任务适配方案失败!");
    }
    public static DBList getMongoDBData(String page, String rows, String tableCode, String paramJson) throws Exception {
        MongodbQuery mdb = new MongodbQuery("mydb");
        QueryEntity qe = new QueryEntity(tableCode, Integer.valueOf(page), Integer.valueOf(rows));
        //设置参数
        //设置参数
        if (!org.springframework.util.StringUtils.isEmpty(paramJson) && !"{}".equals(paramJson)) {
            JSONArray ar = JSONArray.fromObject(paramJson);
            for (int i = 0; i < ar.size(); i++) {
                JSONObject jo = (JSONObject) ar.get(i);
                String andOr = String.valueOf(jo.get("andOr"));
                String field = String.valueOf(jo.get("field"));
                String cond = String.valueOf(jo.get("condition"));
                String value = String.valueOf(jo.get("value"));
                qe.addCondition(new QueryCondition(andOr, cond, field, value));
            }
        }
        DBList list = mdb.query(qe);
        return list;
    }
//    public static void main(String[] args) {
//        try {
//        List<EhrCondition> queryParams = new ArrayList<>();
//        queryParams.add(new EhrCondition(" = ","_id","579091357a2b8f19b0000001" ));
//        ObjectMapper mapper = new ObjectMapper();
//        ObjectNode paramsNode = mapper.createObjectNode();
//        paramsNode.put("tableCode", "mydb");
//            paramsNode.put("condition", mapper.writeValueAsString(queryParams));
//
//            DBList document= getMongoDBData("1","10","fs.chunks","");
//            List<org.json.JSONObject> list=document.getList();
//            for (org.json.JSONObject jsonObject:list){
//                String name = UUID.randomUUID().toString()+".jpg";
//                Binary binary = (Binary) jsonObject.get("data");
//                byte type=binary.getType();
//                System.out.println(type);
//                byte[] fileByte= binary.getData();
//                FileUtil.writeFile("E:/test/mongoFile/"+name,fileByte,"utf-8");
//                System.out.println(fileByte);
//            }
//
//            System.out.println(document);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        testGetBlob();
//        testFetch();
//    }
    /**
     * TODO  采集测试,之后删除
     * @return
     */
    public static Map<String,List<org.json.JSONObject>> testFetch(){
        Map<String,List<org.json.JSONObject>> map=new HashMap<>();
        String tables[] ={"REPORT_MAIN","REPORT_THIN","REPORT_RELATION"};
        for (String table:tables){
            String sql ="select * from "+table;
            String config = "jdbc:oracle:thin:newhos/newhos@//172.19.103.71:1521/neworcl";
            DBHelper db = new DBHelper("blob",config);
//        db.dbType= DBType.Oracle;
            List<org.json.JSONObject> list = db.query(sql);
//        DBQuery  = new DBQuery("blob", config);
//        DBList dv = dbq.queryBySql(sql,1,10);
//        List<org.json.JSONObject> list2=dv.getList();
            for (org.json.JSONObject jsonObject:list){
                if ("REPORT_THIN".equals(table)){
                    Blob blob=(Blob)jsonObject.get("CONTENT");
                    String type= (String) jsonObject.get("REPORT_TYPE");
                    try {
                        ObjectId objectId= GridFSUtil.uploadFile( blob, type, null);
                        jsonObject.put("CONTENT",objectId);
//                        InputStream in=blob.getBinaryStream();
//                        String path="e:/test/blob/"+UUID.randomUUID().toString()+"."+type;
//                        writeFile(path,in);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    System.out.println(jsonObject.toString());
                }
            }
            map.put(table,list);
        }
        return map;
    }
    /**
     * TODO 文件采集测试 之后删除
     */
    public static void testGetBlob(){
        String sql ="select * from HOS_BLOB";
        String config = "jdbc:oracle:thin:newhos/newhos@//172.19.103.71:1521/neworcl";
        DBHelper db = new DBHelper("blob",config);
//        db.dbType= DBType.Oracle;
        List<org.json.JSONObject> list = db.query(sql);
//        DBQuery  = new DBQuery("blob", config);
//        DBList dv = dbq.queryBySql(sql,1,10);
//        List<org.json.JSONObject> list2=dv.getList();
        for (org.json.JSONObject jsonObject:list){
            Blob blob=(Blob)jsonObject.get("FILE_DATA");
            String type= (String) jsonObject.get("FILE_TYPE");
            System.out.println(blob);
            try {
                InputStream in=blob.getBinaryStream();
                String path="e:/test/blob/"+UUID.randomUUID().toString()+"."+type;
                writeFile(path,in);
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println(jsonObject.toString());
        }
    }
    public static boolean writeFile(String filePath, InputStream stream) throws IOException {
        File file = new File(filePath);
        if(!file.getParentFile().exists() && !file.getParentFile().mkdirs()) {
            return false;
        } else {
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            byte[] bbuf = new byte[1024];
            int hasRead1;
            while((hasRead1 = stream.read(bbuf)) > 0) {
                fileOutputStream.write(bbuf, 0, hasRead1);
            }
            fileOutputStream.close();
            return true;
        }
    }
}

+ 0 - 0
src/main/java/com/yihu/hos/rest/services/crawler/DataCollectDispatcher.java


Some files were not shown because too many files changed in this diff