Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/chenweida/jw2.0 into dev

chenyongxing 7 years ago
parent
commit
c93fd350ed
80 changed files with 5689 additions and 82 deletions
  1. 0 8
      common/common-quartz/pom.xml
  2. 27 5
      svr-lib-parent-pom/pom.xml
  3. 3 7
      svr/svr-base/pom.xml
  4. 2 2
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxAccessTokenService.java
  5. 41 0
      svr/svr-quota/pom.xml
  6. 2 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/SvrQuotaApplication.java
  7. 50 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/config/AsyncConfig.java
  8. 25 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/config/quota/JobFactory.java
  9. 52 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/config/quota/SchedulerConfig.java
  10. 436 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/controller/BaseController.java
  11. 45 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/controller/JobController.java
  12. 0 55
      svr/svr-quota/src/main/java/com/yihu/jw/quota/controller/QuotaController.java
  13. 1 3
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/es/QuotaResultDao.java
  14. 15 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/TjQuotaDao.java
  15. 12 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/TjQuotaLogDao.java
  16. 12 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/compute/TjComputeDao.java
  17. 12 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dict/SystemDictDao.java
  18. 11 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dict/SystemDictListDao.java
  19. 12 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjDimensionMainDao.java
  20. 13 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjDimensionSlaveDao.java
  21. 12 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjQuotaDimensionMainDao.java
  22. 12 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjQuotaDimensionSlaveDao.java
  23. 11 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/rule/TjCleanRuleDao.java
  24. 12 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/rule/TjQuotaRuleDao.java
  25. 12 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/save/TjDataSaveDao.java
  26. 12 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/save/TjQuotaDataSaveDao.java
  27. 13 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/source/TjDataSourceDao.java
  28. 11 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/source/TjQuotaDataSourceDao.java
  29. 120 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/Contant.java
  30. 101 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/compute/ComputeHelper.java
  31. 135 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/compute/main/AreaCompute.java
  32. 94 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/compute/slave/SlaveCompute.java
  33. 134 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/extract/ExtractHelper.java
  34. 70 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/extract/db/DBExtract.java
  35. 162 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/extract/db/DBPageExtract.java
  36. 49 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/filter/FilterHelper.java
  37. 84 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/filter/filter/NotNullFilter.java
  38. 91 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/model/DbConfig.java
  39. 37 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/model/EsConfig.java
  40. 41 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/save/SaveHelper.java
  41. 30 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/save/es/ElasticFactory.java
  42. 51 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/save/es/ElastricSearchSave.java
  43. 196 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/job/QuotaJob.java
  44. 1 1
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/QuotaResult.java
  45. 179 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/TjQuota.java
  46. 80 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/TjQuotaLog.java
  47. 171 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/compute/TjCompute.java
  48. 117 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/dict/SystemDict.java
  49. 152 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/dict/SystemDictList.java
  50. 191 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/dimension/TjDimensionMain.java
  51. 167 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/dimension/TjDimensionSlave.java
  52. 73 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/dimension/TjQuotaDimensionMain.java
  53. 81 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/dimension/TjQuotaDimensionSlave.java
  54. 155 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/rule/TjCleanRule.java
  55. 77 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/rule/TjQuotaRule.java
  56. 171 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/save/TjDataSave.java
  57. 81 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/save/TjQuotaDataSave.java
  58. 172 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/source/TjDataSource.java
  59. 83 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/source/TjQuotaDataSource.java
  60. 1 1
      svr/svr-quota/src/main/java/com/yihu/jw/quota/service/QuotaService.java
  61. 35 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/service/compute/TjComputeService.java
  62. 17 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/service/dict/DictService.java
  63. 32 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/service/dimension/TjDimensionMainService.java
  64. 47 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/service/dimension/TjDimensionSlaveService.java
  65. 43 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/service/job/JobService.java
  66. 34 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/service/rule/TjCleanRuleService.java
  67. 34 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/service/save/TjDataSaveService.java
  68. 41 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/service/source/TjDataSourceService.java
  69. 109 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/util/QuartzHelper.java
  70. 60 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/util/SpringUtil.java
  71. 126 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/DataModel.java
  72. 25 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/DictModel.java
  73. 30 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/ErrModel.java
  74. 33 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/FilterModel.java
  75. 19 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/JobLogModel.java
  76. 202 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/MainDimensionModel.java
  77. 157 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/QuotaVo.java
  78. 302 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/SaveModel.java
  79. 89 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/SlaveDimensionModel.java
  80. 41 0
      svr/svr-quota/src/main/resources/quartz.properties

+ 0 - 8
common/common-quartz/pom.xml

@ -14,14 +14,6 @@
    <artifactId>common-quartz</artifactId>
    <version>1.0.0</version>
    <dependencies>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
        </dependency>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz-jobs</artifactId>
        </dependency>
    </dependencies>
</project>

+ 27 - 5
svr-lib-parent-pom/pom.xml

@ -68,8 +68,11 @@
        <version.quartz>2.3.0</version.quartz>
        <version.logback>1.2.3</version.logback>
        <version.spring-elasticsearch>2.1.3.RELEASE</version.spring-elasticsearch>
        <version.jest>2.4.0</version.jest>
        <version.json>20160212</version.json>
        <version.net-json>2.4</version.net-json>
        <version.springside>4.2.3-GA</version.springside>
        <version.common.lang3>3.1</version.common.lang3>
    </properties>
    <!--dependencyManagement作用子配置不写版本默认继承父配置-->
    <dependencyManagement>
@ -291,6 +294,11 @@
                <version>${version.spring}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context-support</artifactId>
                <version>${version.spring}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
@ -433,15 +441,29 @@
                <artifactId>json</artifactId>
                <version>${version.json}</version>
            </dependency>
            <dependency>
                <groupId>net.sf.json-lib</groupId>
                <artifactId>json-lib</artifactId>
                <version>${version.net-json}</version>
            </dependency>
            <!--json end -->
            <!-- springside-core start-->
            <!-- es 客户端 start-->
            <dependency>
                <groupId>io.searchbox</groupId>
                <artifactId>jest</artifactId>
                <version>${version.jest}</version>
            </dependency>
            <!-- es 客户端 end-->
            <dependency>
                <groupId>org.springside</groupId>
                <artifactId>springside-core</artifactId>
                <version>${version.springside}</version>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>${version.common.lang3}</version>
            </dependency>
            <!-- springside-core end-->
        </dependencies>
    </dependencyManagement>
    <build>

+ 3 - 7
svr/svr-base/pom.xml

@ -16,15 +16,15 @@
    <dependencies>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-swagger</artifactId>
            <artifactId>common-util</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-util</artifactId>
            <artifactId>common-rest-model</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-rest-model</artifactId>
            <artifactId>common-swagger</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
@ -112,9 +112,5 @@
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springside</groupId>
            <artifactId>springside-core</artifactId>
        </dependency>
    </dependencies>
</project>

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxAccessTokenService.java

@ -13,8 +13,8 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springside.modules.utils.Clock;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@ -74,7 +74,7 @@ public class WxAccessTokenService extends BaseJpaService<WxAccessToken, WxAccess
                newaccessToken.setAccessToken(token);
                newaccessToken.setExpiresIn(Long.parseLong(expires_in));
                newaccessToken.setAddTimestamp(System.currentTimeMillis());
                newaccessToken.setCzrq(new Clock.DefaultClock().getCurrentDate());
                newaccessToken.setCzrq(new Date());
                newaccessToken.setCode(UUID.randomUUID().toString().replace("-",""));
                newaccessToken.setWechatCode(wechatCode);
                wxAccessTokenDao.save(newaccessToken);

+ 41 - 0
svr/svr-quota/pom.xml

@ -65,5 +65,46 @@
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-elasticsearch</artifactId>
        </dependency>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
        </dependency>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz-jobs</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>4.2.2</version>
        </dependency>
        <dependency>
            <groupId>io.searchbox</groupId>
            <artifactId>jest</artifactId>
        </dependency>
    </dependencies>
</project>

+ 2 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/SvrQuotaApplication.java

@ -4,6 +4,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
/**
 * Created by chenweida on 2017/5/16.
@ -11,6 +12,7 @@ import org.springframework.data.elasticsearch.repository.config.EnableElasticsea
@SpringBootApplication
@EnableDiscoveryClient//服务注册到发现服务
@EnableElasticsearchRepositories(basePackages = "com.yihu.jw.quota.dao.es")
@EnableJpaRepositories(basePackages="com.yihu.jw.quota.dao.jpa")
public class SvrQuotaApplication {
    public static void main(String[] args) {

+ 50 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/config/AsyncConfig.java

@ -0,0 +1,50 @@
package com.yihu.jw.quota.config;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
/**
 * Created by Administrator on 2016.10.18.
 * 启用多綫程
 */
@Configuration
@EnableAsync
public class AsyncConfig {
    /** 如果池中的实际线程数小于corePoolSize,无论是否其中有空闲的线程,都会给新的任务产生新的线程 */
    private int corePoolSize = 5;
    /** 如果池中的线程数=maximumPoolSize,则有空闲线程使用空闲线程,否则新任务放入queueCapacity. */
    private int maxPoolSize = 20;
    /** 缓冲队列. */
    private int queueCapacity = 10;
    @Bean
    public Executor dbExtractExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(corePoolSize);
        executor.setMaxPoolSize(maxPoolSize);
        executor.setQueueCapacity(queueCapacity);
        // rejection-policy:当pool已经达到max size的时候,如何处理新任务
        // CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        executor.initialize();
        return executor;
    }
    @Bean
    public Executor dbStorageExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(corePoolSize);
        executor.setMaxPoolSize(maxPoolSize);
        executor.setQueueCapacity(queueCapacity);
        // rejection-policy:当pool已经达到max size的时候,如何处理新任务
        // CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        executor.initialize();
        return executor;
    }
}

+ 25 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/config/quota/JobFactory.java

@ -0,0 +1,25 @@
package com.yihu.jw.quota.config.quota;//package com.yihu.jw.config.quartz;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;
/**
 * Created by Administrator on 2016.10.12.
 * 為了讓quartz種可以使用Spring的注入
 */
@Component("jobFactory")
public class JobFactory extends AdaptableJobFactory {
    @Autowired
    private AutowireCapableBeanFactory capableBeanFactory;
    @Override
    protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
        // 调用父类的方法
        Object jobInstance = super.createJobInstance(bundle);
       // 进行注入
        capableBeanFactory.autowireBean(jobInstance);
        return jobInstance;
    }
}

+ 52 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/config/quota/SchedulerConfig.java

@ -0,0 +1,52 @@
package com.yihu.jw.quota.config.quota;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import javax.sql.DataSource;
import java.io.IOException;
import java.util.Properties;
/**
 * Created by chenweida on 2016/2/3.
 */
@Configuration
public class SchedulerConfig {
    @Autowired
    private ApplicationContext applicationContext;
    @Autowired
    private JobFactory jobFactory;
    @Autowired
    private DataSource dataSource;
    @Bean
    SchedulerFactoryBean schedulerFactoryBean() throws IOException {
        SchedulerFactoryBean bean = new SchedulerFactoryBean();
        bean.setJobFactory(jobFactory);
        bean.setApplicationContext(this.applicationContext);
        bean.setOverwriteExistingJobs(true);
        bean.setStartupDelay(20);// 延时启动
        bean.setSchedulerName("schedulerFactoryBeanCWD");
        bean.setAutoStartup(true);
        bean.setDataSource(dataSource);
        bean.setQuartzProperties(quartzProperties());
        return bean;
    }
    /**
     * quartz配置文件
     * @return
     * @throws IOException
     */
    @Bean
    public Properties quartzProperties() throws IOException {
        PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
        propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
        propertiesFactoryBean.afterPropertiesSet();
        return propertiesFactoryBean.getObject();
    }
}

+ 436 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/controller/BaseController.java

@ -0,0 +1,436 @@
package com.yihu.jw.quota.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class BaseController {
	private static Logger logger = LoggerFactory.getLogger(BaseController.class);
	@Autowired
	protected HttpServletRequest request;
	/**
	 * 獲取髮送請求用戶的uid
	 * @return
	 */
	public String getUID() {
		try {
			String userAgent = request.getHeader("userAgent");
			if(StringUtils.isEmpty(userAgent)){
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getString("uid");
			
		} catch (Exception e) {
			return null;
		}
	}
	public String getOpenid() {
		try {
			String userAgent = request.getHeader("userAgent");
			if(StringUtils.isEmpty(userAgent)){
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getString("openid");
			
		} catch (Exception e) {
			return null;
		}
	}
	
	/**
	 * 获取用户ID
	 * @return
	 */
	public long getId() {
		try {
			String userAgent = request.getHeader("userAgent");
			if(StringUtils.isEmpty(userAgent)){
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getLong("id");
		} catch (Exception e) {
			return 0;
		}
	}
	public String getIMEI() {
		try {
			String userAgent = request.getHeader("userAgent");
			if(StringUtils.isEmpty(userAgent)){
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getString("imei");
		} catch (Exception e) {
			return null;
		}
	}
	
	public String getToken() {
		try {
			String userAgent = request.getHeader("userAgent");
			if(StringUtils.isEmpty(userAgent)){
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getString("token");
		} catch (Exception e) {
			return null;
		}
	}
	public void error(Exception e) {
		logger.error(getClass().getName() + ":", e.getMessage());
		e.printStackTrace();
	}
	public void warn(Exception e) {
		logger.warn(getClass().getName() + ":", e.getMessage());
		e.printStackTrace();
	}
	/**
	 * 返回接口处理结果
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String error(int code, String msg) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return null;
		}
	}
	/**
	 * 接口处理成功
	 * @param msg
	 * @return
	 */
	public String success(String msg) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", 200);
			map.put("msg", msg);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return null;
		}
	}
	public String write(int code, String msg) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return null;
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, String key, List<?> list) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, list);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, JSONObject value) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			json.put(key, value);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, JSONArray value) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			json.put(key, value);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param total 总数
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, int total, String key, JSONArray value) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			json.put("total", total);
			json.put(key, value);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, Object value) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, value);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, String key, Page<?> list) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			// 是否为第一页
			map.put("isFirst", list.isFirst());
			// 是否为最后一页
			map.put("isLast", list.isLast());
			// 总条数
			map.put("total", list.getTotalElements());
			// 总页数
			map.put("totalPages", list.getTotalPages());
			map.put(key, list.getContent());
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 *
	 *
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, String key, Page<?> page, JSONArray array) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			// 是否为第一页
			json.put("isFirst", page.isFirst());
			// 是否为最后一页
			json.put("isLast", page.isLast());
			// 总条数
			json.put("total", page.getTotalElements());
			// 总页数
			json.put("totalPages", page.getTotalPages());
			json.put(key, array);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, Map<?, ?> value) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, value);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	* 返回接口处理结果
	*
	* @param code 结果码,成功为200
	* @param msg 结果提示信息
	* @param value 结果数据
	* @return
	*/
	public String write(int code, String msg, String key, String value) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, value);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, boolean isFirst, boolean isLast, long total, int totalPages, String key, Object values) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			// 是否为第一页
			json.put("isFirst", isFirst);
			// 是否为最后一页
			json.put("isLast", isLast);
			// 总条数
			json.put("total", total);
			// 总页数
			json.put("totalPages", totalPages);
			json.put(key, values);
			return json.toString();
		} catch (Exception e) {
			logger.error("BaseController:", e.getMessage());
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	public String trimEnd(String param, String trimChars) {
		if (param.endsWith(trimChars)) {
			param = param.substring(0, param.length() - trimChars.length());
		}
		return param;
	}
	/**
	 * 无效用户消息返回
	 * @param e
	 * @param defaultCode
	 * @param defaultMsg
	 * @return
	 */
	public String invalidUserException(Exception e, int defaultCode, String defaultMsg) {
		try {
			// if (e instanceof UndeclaredThrowableException) {
			// UndeclaredThrowableException ute = (UndeclaredThrowableException) e;
			// InvalidUserException iue = (InvalidUserException) ute.getUndeclaredThrowable();
			// if (iue != null) {
			// return error(iue.getCode(), iue.getMsg());
			// }
			// }
			return error(defaultCode, defaultMsg);
		} catch (Exception e2) {
			return null;
		}
	}
}

+ 45 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/controller/JobController.java

@ -0,0 +1,45 @@
package com.yihu.jw.quota.controller;
import com.yihu.jw.quota.service.job.JobService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
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.RestController;
/**
 * 任务启动
 *
 * @author chenweida
 */
@RestController
@RequestMapping(value = "/job", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "后台-任务控制")
public class JobController extends BaseController {
    @Autowired
    private JobService jobService;
    /**
     * 启动任务
     *
     * @param id id
     * @return
     */
    @ApiOperation(value = "根据ID立即单个任务")
    @RequestMapping(value = "startNowById", method = RequestMethod.GET)
    public String startNowById(
            @ApiParam(name = "id", value = "任务ID", required = true)@RequestParam(value = "id", required = true) String id) {
        try {
            jobService.startNowById(id);
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
}

+ 0 - 55
svr/svr-quota/src/main/java/com/yihu/jw/quota/controller/QuotaController.java

@ -1,55 +0,0 @@
package com.yihu.jw.quota.controller;
import com.yihu.jw.quota.model.QuotaResult;
import com.yihu.jw.quota.service.QuotaService;
import com.yihu.jw.restmodel.base.BaseContants;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.exception.ApiException;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
/**
 * Created by chenweida on 2017/5/23.
 */
@RestController
@RequestMapping("quota")
public class QuotaController {
    @Autowired
    private QuotaService quotaService;
    @GetMapping(value = "findBy_Id")
    public Envelop findBy_Id(
            @ApiParam(name = "id", value = "", defaultValue = "")
            @RequestParam(value = "id", required = true) String id) {
        try {
            return Envelop.getSuccess(BaseContants.Function.message_success_create, quotaService.findBy_Id(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = "findById")
    public Envelop findById(
            @ApiParam(name = "id", value = "", defaultValue = "")
            @RequestParam(value = "id", required = true) String id) {
        try {
            return Envelop.getSuccess(BaseContants.Function.message_success_create, quotaService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = "save")
    public Envelop save() {
        try {
            quotaService.save();
            return Envelop.getSuccess(BaseContants.Function.message_success_create);
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
}

+ 1 - 3
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/es/QuotaResultDao.java

@ -1,11 +1,9 @@
package com.yihu.jw.quota.dao.es;
import com.yihu.jw.quota.model.QuotaResult;
import com.yihu.jw.quota.model.es.QuotaResult;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
/**
 * Created by chenweida on 2017/5/23.
 */

+ 15 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/TjQuotaDao.java

@ -0,0 +1,15 @@
package com.yihu.jw.quota.dao.jpa;
import com.yihu.jw.quota.model.jpa.TjQuota;
import com.yihu.jw.quota.model.jpa.compute.TjCompute;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjQuotaDao extends PagingAndSortingRepository<TjQuota, Long>, JpaSpecificationExecutor<TjQuota> {
    @Query("from TjQuota j where j.code=?1 and j.status=1 ")
    TjQuota findByCode(String id);
}

+ 12 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/TjQuotaLogDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.quota.dao.jpa;
import com.yihu.jw.quota.model.jpa.TjQuota;
import com.yihu.jw.quota.model.jpa.TjQuotaLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/2.
 */
public interface TjQuotaLogDao extends PagingAndSortingRepository<TjQuotaLog, Long>, JpaSpecificationExecutor< TjQuotaLog> {
}

+ 12 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/compute/TjComputeDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.quota.dao.jpa.compute;
import com.yihu.jw.quota.model.jpa.compute.TjCompute;
import com.yihu.jw.quota.model.jpa.rule.TjCleanRule;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjComputeDao extends PagingAndSortingRepository<TjCompute, Long>, JpaSpecificationExecutor<TjCompute> {
}

+ 12 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dict/SystemDictDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.quota.dao.jpa.dict;
import com.yihu.jw.quota.model.jpa.dict.SystemDict;
import com.yihu.jw.quota.model.jpa.dimension.TjDimensionMain;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface SystemDictDao extends PagingAndSortingRepository<SystemDict, Long>, JpaSpecificationExecutor<SystemDict> {
}

+ 11 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dict/SystemDictListDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.quota.dao.jpa.dict;
import com.yihu.jw.quota.model.jpa.dict.SystemDictList;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface SystemDictListDao extends PagingAndSortingRepository<SystemDictList, Long>, JpaSpecificationExecutor<SystemDictList> {
}

+ 12 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjDimensionMainDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.quota.dao.jpa.dimension;
import com.yihu.jw.quota.model.jpa.compute.TjCompute;
import com.yihu.jw.quota.model.jpa.dimension.TjDimensionMain;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjDimensionMainDao extends PagingAndSortingRepository<TjDimensionMain, Long>, JpaSpecificationExecutor<TjDimensionMain> {
}

+ 13 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjDimensionSlaveDao.java

@ -0,0 +1,13 @@
package com.yihu.jw.quota.dao.jpa.dimension;
import com.yihu.jw.quota.model.jpa.compute.TjCompute;
import com.yihu.jw.quota.model.jpa.dimension.TjDimensionSlave;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjDimensionSlaveDao extends PagingAndSortingRepository<TjDimensionSlave, Long>, JpaSpecificationExecutor<TjDimensionSlave
        > {
}

+ 12 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjQuotaDimensionMainDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.quota.dao.jpa.dimension;
import com.yihu.jw.quota.model.jpa.compute.TjCompute;
import com.yihu.jw.quota.model.jpa.dimension.TjQuotaDimensionMain;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjQuotaDimensionMainDao extends PagingAndSortingRepository<TjQuotaDimensionMain, Long>, JpaSpecificationExecutor<TjQuotaDimensionMain> {
}

+ 12 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjQuotaDimensionSlaveDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.quota.dao.jpa.dimension;
import com.yihu.jw.quota.model.jpa.compute.TjCompute;
import com.yihu.jw.quota.model.jpa.dimension.TjQuotaDimensionSlave;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjQuotaDimensionSlaveDao extends PagingAndSortingRepository<TjQuotaDimensionSlave, Long>, JpaSpecificationExecutor<TjQuotaDimensionSlave> {
}

+ 11 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/rule/TjCleanRuleDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.quota.dao.jpa.rule;
import com.yihu.jw.quota.model.jpa.rule.TjCleanRule;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjCleanRuleDao extends PagingAndSortingRepository<TjCleanRule, Long>, JpaSpecificationExecutor<TjCleanRule> {
}

+ 12 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/rule/TjQuotaRuleDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.quota.dao.jpa.rule;
import com.yihu.jw.quota.model.jpa.compute.TjCompute;
import com.yihu.jw.quota.model.jpa.rule.TjQuotaRule;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjQuotaRuleDao extends PagingAndSortingRepository<TjQuotaRule, Long>, JpaSpecificationExecutor<TjQuotaRule> {
}

+ 12 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/save/TjDataSaveDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.quota.dao.jpa.save;
import com.yihu.jw.quota.model.jpa.compute.TjCompute;
import com.yihu.jw.quota.model.jpa.save.TjDataSave;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjDataSaveDao extends PagingAndSortingRepository<TjDataSave, Long>, JpaSpecificationExecutor<TjDataSave> {
}

+ 12 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/save/TjQuotaDataSaveDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.quota.dao.jpa.save;
import com.yihu.jw.quota.model.jpa.compute.TjCompute;
import com.yihu.jw.quota.model.jpa.source.TjQuotaDataSource;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjQuotaDataSaveDao extends PagingAndSortingRepository<TjQuotaDataSource, Long>, JpaSpecificationExecutor<TjQuotaDataSource> {
}

+ 13 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/source/TjDataSourceDao.java

@ -0,0 +1,13 @@
package com.yihu.jw.quota.dao.jpa.source;
import com.yihu.jw.quota.model.jpa.compute.TjCompute;
import com.yihu.jw.quota.model.jpa.source.TjDataSource;
import com.yihu.jw.quota.model.jpa.source.TjQuotaDataSource;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjDataSourceDao extends PagingAndSortingRepository<TjDataSource, Long>, JpaSpecificationExecutor<TjDataSource> {
}

+ 11 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/source/TjQuotaDataSourceDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.quota.dao.jpa.source;
import com.yihu.jw.quota.model.jpa.source.TjQuotaDataSource;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjQuotaDataSourceDao extends PagingAndSortingRepository<TjQuotaDataSource, Long>, JpaSpecificationExecutor<TjQuotaDataSource> {
}

+ 120 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/Contant.java

@ -0,0 +1,120 @@
package com.yihu.jw.quota.etl;
/**
 * Created by chenweida on 2017/6/1.
 */
public class Contant {
    //抽取数据的开始时间
    public static String startTime = "${start_time}";
    //抽取数据的结束时间
    public static String endTime = "${end_time}";
    //数据库类型
    public static class db_type {
        public static String oracle = "oracle";
        public static String mysql = "mysql";
    }
    /**
     * DateModel的map的key常量
     */
    public static class extract {
        public static final String computeKey1 = "oneKey";
        public static final String computeKey2 = "senondKey";
    }
    /**
     * 运算常量
     */
    public static class compute {
        public static final String add = "1"; //累加
        public static final String division = "2"; //相除
    }
    /**
     * 主维度常量
     */
    public static class main_dimension {
        public static final String time_day = "1";//时间维度 日
        public static final String time_week = "2";//时间维度  月
        public static final String time_month = "3";//时间维度 周
        public static final String time_year = "4";//时间维度 年
        public static final String area_province = "5";//行政区划 省
        public static final String area_city = "6";//行政区划 市
        public static final String area_town = "7";//行政区划 区县
        public static final String area_org = "8";//行政区划 机构
        public static final String area_team = "9";//行政区划  团队
    }
    /**
     * areaLevel 具体的值
     */
    public static class main_dimension_areaLevel {
        public static final String area_province = "1";//行政区划 省
        public static final String area_city = "2";//行政区划 市
        public static final String area_town = "3";//行政区划 区县
        public static final String area_org = "4";//行政区划 机构
        public static final String area_team = "5";//行政区划  团队
        public static String getAreaLevelByMainDimension(String key) {
            switch (key) {
                case main_dimension.area_province: {
                    return area_province;
                }
                case main_dimension.area_city: {
                    return area_city;
                }
                case main_dimension.area_town: {
                    return area_town;
                }
                case main_dimension.area_org: {
                    return area_org;
                }
                case main_dimension.area_team: {
                    return area_team;
                }
            }
            return "";
        }
    }
    /**
     * 主维度 时间维度
     */
    public static class main_dimension_timeLevel {
        public static final String year = "1";
        public static final String month = "2";
        public static final String week = "3";
        public static final String day = "4";
    }
    /**
     * 从维度常量
     */
    public static class slave_dimension {
        public static final String sex = "1";//性别
        public static final String age = "2";//年龄段
    }
    public static class save_status {
        public static final String success = "1";
        public static final String fail = "0";
    }
    /**
     * 数据过滤用到的参量
     */
    public static class role {
        public static final String not_null = "1";//非空
    }
    public static class save {
        public static final String mysql = "1";
        public static final String redis = "2";
        public static final String es = "3";
    }
}

+ 101 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/compute/ComputeHelper.java

@ -0,0 +1,101 @@
package com.yihu.jw.quota.etl.compute;
import com.yihu.jw.quota.etl.Contant;
import com.yihu.jw.quota.etl.compute.main.AreaCompute;
import com.yihu.jw.quota.etl.compute.slave.SlaveCompute;
import com.yihu.jw.quota.model.jpa.dimension.TjQuotaDimensionMain;
import com.yihu.jw.quota.model.jpa.dimension.TjQuotaDimensionSlave;
import com.yihu.jw.quota.service.dimension.TjDimensionMainService;
import com.yihu.jw.quota.service.dimension.TjDimensionSlaveService;
import com.yihu.jw.quota.util.SpringUtil;
import com.yihu.jw.quota.vo.DataModel;
import com.yihu.jw.quota.vo.MainDimensionModel;
import com.yihu.jw.quota.vo.QuotaVO;
import com.yihu.jw.quota.vo.SaveModel;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/6/1.
 */
@Component
@Scope("prototype")
public class ComputeHelper {
    @Autowired
    private TjDimensionMainService dimensionMainService;
    @Autowired
    private TjDimensionSlaveService dimensionSlaveService;
    public List<SaveModel> compute(Object dataModels, QuotaVO quotaVO,String timeLevel,String saasid,String startTime) {
        //返回的list
        List<SaveModel> saveModels=new ArrayList<>();
        //只得到地址维度的所有主维度
        List<TjQuotaDimensionMain> quotaDimensionMains = dimensionMainService.findTjQuotaDimensionMainByQuotaIncudeAddress(quotaVO.getCode());
        //得到从维度
        List<TjQuotaDimensionSlave> quotaDimensionSlaves = dimensionSlaveService.findTjQuotaDimensionSlaveByQuotaCode(quotaVO.getCode());
        if (Contant.compute.add.equals(quotaVO.getComputeType())) {
            //判断是否是累加计算 如果强转成list类型
            List<DataModel> dmList = (List<DataModel>) dataModels;
            Map<String, MainDimensionModel> one=getLastData(quotaVO, quotaDimensionMains, quotaDimensionSlaves, dmList);
            for(Map.Entry<String,MainDimensionModel> tjone:one.entrySet()){
                SaveModel saveModel=new SaveModel();
                BeanUtils.copyProperties(tjone.getValue(),saveModel);
                saveModel.setTimeLevel(timeLevel);
                saveModel.setSaasId(saasid);
                saveModel.setQuotaDate(startTime);
                saveModel.setResult(tjone.getValue().getSlaveDimensionModels().size()+"");
                saveModels.add(saveModel);
            }
        } else if (Contant.compute.division.equals(quotaVO.getComputeType())) {
            //判断是否是除法计算 如果强转成Map类型 key在Contant中
            Map<String, List<DataModel>> dmMap = (Map<String, List<DataModel>>) dataModels;
            List<DataModel> oneList = dmMap.get(Contant.extract.computeKey1);
            List<DataModel> twoList = dmMap.get(Contant.extract.computeKey2);
            //计算出分子
            Map<String, MainDimensionModel> one=getLastData(quotaVO, quotaDimensionMains, quotaDimensionSlaves, oneList);
            //计算出分母
            Map<String, MainDimensionModel> tow=getLastData(quotaVO, quotaDimensionMains, quotaDimensionSlaves, twoList);
            for(Map.Entry<String,MainDimensionModel> tjone:one.entrySet()){
                SaveModel saveModel=new SaveModel();
                BeanUtils.copyProperties(tjone.getValue(),saveModel);
                saveModel.setTimeLevel(timeLevel);
                saveModel.setSaasId(saasid);
                saveModel.setQuotaDate(startTime);
                saveModel.setResult(new StringBuffer(tjone.getValue().getSlaveDimensionModels().size()+"/"+tow.get(tjone.getKey()).getSlaveDimensionModels()).toString());
                saveModels.add(saveModel);
            }
        }
        return saveModels;
    }
    private  Map<String, MainDimensionModel> getLastData(QuotaVO quotaVO, List<TjQuotaDimensionMain> quotaDimensionMains, List<TjQuotaDimensionSlave> quotaDimensionSlaves, List<DataModel> dmList) {
        Map<String, MainDimensionModel> mainData=new HashMap<>();
        //先统计主维度的数据-----地址维度
        quotaDimensionMains.stream().forEach(one->{
            mainData.putAll(SpringUtil.getBean(AreaCompute.class).compute(
                    quotaVO,
                    dmList,//数据
                    one.getDitcSql(), //字典的sql语句
                    Contant.main_dimension_areaLevel.getAreaLevelByMainDimension(one.getType()) //维度转换
                    ));
        });
        //再统计从维度的数据
        return SpringUtil.getBean(SlaveCompute.class).compute(
                mainData,//数据
                quotaDimensionSlaves //字典的sql语句
                ) ;
    }
}

+ 135 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/compute/main/AreaCompute.java

@ -0,0 +1,135 @@
package com.yihu.jw.quota.etl.compute.main;
import com.yihu.jw.quota.etl.Contant;
import com.yihu.jw.quota.model.jpa.compute.TjCompute;
import com.yihu.jw.quota.vo.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/6/1.
 */
@Component
@Scope("prototype")
public class AreaCompute {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     *
     * @param dmList 需要统计的元数据
     * @param sql 查询字典的sql语句
     * @param areaLevel 可能是 1 省 2 市  3区  4机构 5团队
     * @return
     */
    public Map<String, MainDimensionModel> compute(QuotaVO quotaVO,List<DataModel> dmList, String sql, String areaLevel) {
        if(StringUtils.isEmpty(sql)){
            return new HashMap<>(); //没有字典返回null
        }
        //得到字典
        List<DictModel> quotaDataSources = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
        //把字典转成Map
        Map<String,String> dictModelMap=new HashMap<>();
        quotaDataSources.stream().forEach(one->{
            dictModelMap.put(one.getCode(),one.getName());
        });
        Map<String, MainDimensionModel> datas = new HashMap<>();
        //设置全部key到map中
        quotaDataSources.stream().forEach(one -> {
            datas.put(one.getCode(),null);
        });
        //只是用来是设置为空的时候填充上级
       final MainDimensionModel mainDimensionModelTemp=new MainDimensionModel();
        //数据根据key分组
        dmList.stream().forEach(one->{
            MainDimensionModel mainDimensionModel= datas.get(one.getKey(areaLevel));
            if(mainDimensionModel==null){
                mainDimensionModel=new MainDimensionModel();
                mainDimensionModel.setAreaLevel(areaLevel);
                mainDimensionModel.setProvince(one.getProvince());
                mainDimensionModel.setCity(one.getCity());
                mainDimensionModel.setTown(one.getTown());
                mainDimensionModel.setHospital(one.getHospital());
                mainDimensionModel.setTeam(one.getTeam());
                mainDimensionModel.setQuotaCode(quotaVO.getCode());
                //设置名称
                switch (areaLevel){
                    case Contant.main_dimension_areaLevel.area_province:{mainDimensionModel.setProvinceName(dictModelMap.get(one.getProvince()));break;}
                    case Contant.main_dimension_areaLevel.area_city:{mainDimensionModel.setCityName(dictModelMap.get(one.getCity()));break;}
                    case Contant.main_dimension_areaLevel.area_town:{mainDimensionModel.setTownName(dictModelMap.get(one.getTown()));break;}
                    case Contant.main_dimension_areaLevel.area_org:{mainDimensionModel.setHospitalName(dictModelMap.get(one.getHospital()));break;}
                    case Contant.main_dimension_areaLevel.area_team:{mainDimensionModel.setTeamName(dictModelMap.get(one.getTeam()));break;}
                }
                BeanUtils.copyProperties(mainDimensionModel,mainDimensionModelTemp);
            }
            //设置从维度
            mainDimensionModel.getSlaveDimensionModels().add(new SlaveDimensionModel(
                    one.getSlaveKey1(),
                    one.getSlaveKey2(),
                    one.getSlaveKey3(),
                    one.getSlaveKey4()
            ));
            datas.put(one.getKey(areaLevel),mainDimensionModel);
        });
        //如果是空的设置初始值
        initNull(quotaVO, areaLevel, quotaDataSources, datas, mainDimensionModelTemp);
        return datas;
    }
    private void initNull(QuotaVO quotaVO, String areaLevel, List<DictModel> quotaDataSources, Map<String, MainDimensionModel> datas, MainDimensionModel mainDimensionModelTemp) {
        quotaDataSources.stream().forEach(one -> {
            MainDimensionModel mainDimensionModel= datas.get(one.getCode());
            if(mainDimensionModel==null){
                mainDimensionModel=new MainDimensionModel();
                mainDimensionModel.setAreaLevel(areaLevel);
                mainDimensionModel.setQuotaCode(quotaVO.getCode());
                //设置名称
                switch (areaLevel){
                    case Contant.main_dimension_areaLevel.area_province:{
                        mainDimensionModel.setProvince(one.getCode());
                        mainDimensionModel.setProvinceName(one.getName());break;
                    }
                    case Contant.main_dimension_areaLevel.area_city:{
                        mainDimensionModel.setProvince(mainDimensionModelTemp.getProvince());
                        mainDimensionModel.setCity(one.getCode());
                        mainDimensionModel.setCityName(one.getName());break;
                    }
                    case Contant.main_dimension_areaLevel.area_town:{
                        mainDimensionModel.setProvince(mainDimensionModelTemp.getProvince());
                        mainDimensionModel.setCity(mainDimensionModelTemp.getCity());
                        mainDimensionModel.setTown(one.getCode());
                        mainDimensionModel.setTownName(one.getName());break;
                    }
                    case Contant.main_dimension_areaLevel.area_org:{
                        mainDimensionModel.setProvince(mainDimensionModelTemp.getProvince());
                        mainDimensionModel.setCity(mainDimensionModelTemp.getCity());
                        mainDimensionModel.setTown(mainDimensionModelTemp.getTown());
                        mainDimensionModel.setHospital(one.getCode());
                        mainDimensionModel.setHospitalName(one.getName());break;
                    }
                    case Contant.main_dimension_areaLevel.area_team:{
                        mainDimensionModel.setProvince(mainDimensionModelTemp.getProvince());
                        mainDimensionModel.setCity(mainDimensionModelTemp.getCity());
                        mainDimensionModel.setTown(mainDimensionModelTemp.getTown());
                        mainDimensionModel.setHospital(mainDimensionModelTemp.getHospital());
                        mainDimensionModel.setTeam(one.getCode());
                        mainDimensionModel.setTeamName(one.getName());break;
                    }
                }
                datas.put(one.getCode(),mainDimensionModel);
            }
        });
    }
}

+ 94 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/compute/slave/SlaveCompute.java

@ -0,0 +1,94 @@
package com.yihu.jw.quota.etl.compute.slave;
import com.yihu.jw.quota.model.jpa.dimension.TjQuotaDimensionSlave;
import com.yihu.jw.quota.vo.DictModel;
import com.yihu.jw.quota.vo.MainDimensionModel;
import com.yihu.jw.quota.vo.SlaveDimensionModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/6/1.
 * 从维度计算的类
 */
@Component
@Scope("prototype")
public class SlaveCompute {
    private Logger logger= LoggerFactory.getLogger(SlaveCompute.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public Map<String, MainDimensionModel> compute(Map<String, MainDimensionModel> mainData, List<TjQuotaDimensionSlave> quotaDimensionSlaves) {
        try {
            //找出所有得到字典放到里面List里面去
            List<Map<String, String>> dictList = new ArrayList<>();
            for (int i = 0; i < quotaDimensionSlaves.size(); i++) {
                Map<String, String> dictMap = new HashMap<>();
                String dictSql=quotaDimensionSlaves.get(i).getDictSql();
                if(StringUtils.isEmpty(dictSql)){
                    logger.warn("slaveDict sql is null ,quotaID:"+quotaDimensionSlaves.get(i).getQuotaCode()+",quotaSlaveId:"+quotaDimensionSlaves.get(i).getId());
                }
                List<DictModel> quotaDataSources = jdbcTemplate.query(dictSql, new BeanPropertyRowMapper(DictModel.class));
                quotaDataSources.stream().forEach(one -> {
                    dictMap.put(one.getCode(), one.getName());
                });
                dictList.add(dictMap);
            }
            //遍历从维度
            for (int i = 0; i < quotaDimensionSlaves.size(); i++) {
                Map<String, MainDimensionModel> temp = new HashMap<>();
                //得到字典
                Map<String, String> dict = dictList.get(i);
                //遍历元数据
                for (Map.Entry<String, MainDimensionModel> oneMainDimensionModel : mainData.entrySet()) {
                    //遍历字典
                    for (Map.Entry<String, String> oneDict : dict.entrySet()) {
                        List<SlaveDimensionModel> slaveDimensionModels = oneMainDimensionModel.getValue().getSlaveDimensionModels();
                        String key = new StringBuffer(oneMainDimensionModel.getKey() + "-" + oneDict.getKey()).toString();
                        List<SlaveDimensionModel> slaveDimensionModelTemps = new ArrayList<>();
                        MainDimensionModel mainDimensionModelTemp = new MainDimensionModel();
                        BeanUtils.copyProperties(oneMainDimensionModel.getValue(), mainDimensionModelTemp);
                        for (int j = 0; j < slaveDimensionModels.size(); j++) {
                            SlaveDimensionModel oneSlaveDimensionModel = slaveDimensionModels.get(j);
                            SlaveDimensionModel slaveDimensionModelTemp = new SlaveDimensionModel();
                            BeanUtils.copyProperties(oneSlaveDimensionModel, slaveDimensionModelTemp);
                            //通过反射动态调用设置
                            String oneSlaveDimensionModelKey = (String) SlaveDimensionModel.class.getMethod(new StringBuffer("getSlaveKey" + (i+1)).toString()).invoke(oneSlaveDimensionModel);
                            if (oneDict.getKey().equals(oneSlaveDimensionModelKey)) {
                                slaveDimensionModelTemps.add(slaveDimensionModelTemp);
                            }
                        }
                        MainDimensionModel.class.getMethod(new StringBuffer("setSlaveKey"+ (i+1)).toString(),String.class).invoke(mainDimensionModelTemp,oneDict.getKey());
                        MainDimensionModel.class.getMethod(new StringBuffer("setSlaveKey"+ (i+1)+"Name").toString(),String.class).invoke(mainDimensionModelTemp,oneDict.getValue());
                        mainDimensionModelTemp.setSlaveDimensionModels(slaveDimensionModelTemps);
                        temp.put(key, mainDimensionModelTemp);
                    }
                }
                mainData = temp;
            }
            return mainData;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}

+ 134 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/extract/ExtractHelper.java

@ -0,0 +1,134 @@
package com.yihu.jw.quota.etl.extract;
import com.yihu.jw.quota.etl.Contant;
import com.yihu.jw.quota.etl.extract.db.DBExtract;
import com.yihu.jw.quota.etl.model.DbConfig;
import com.yihu.jw.quota.model.jpa.source.TjDataSource;
import com.yihu.jw.quota.model.jpa.source.TjQuotaDataSource;
import com.yihu.jw.quota.service.source.TjDataSourceService;
import com.yihu.jw.quota.util.SpringUtil;
import com.yihu.jw.quota.vo.DataModel;
import com.yihu.jw.quota.vo.QuotaVO;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/6/1.
 */
@Component
@Scope("prototype")
public class ExtractHelper {
    private String startTime;
    private String endTime;
    @Autowired
    private TjDataSourceService dataSourceService;
    private Logger logger = LoggerFactory.getLogger(ExtractHelper.class);
    /**
     * 公共的抽取数据
     *
     * @param quotaVO
     * @return
     * @throws Exception
     */
    public Object extractData(QuotaVO quotaVO, String startTime, String endTime) throws Exception {
        try {
            this.startTime = startTime;
            this.endTime = endTime;
            //得到该指标的数据来源
            TjQuotaDataSource quotaDataSource = dataSourceService.findSourceByQuotaCode(quotaVO.getCode());
            //如果为空说明数据错误
            if (quotaDataSource == null) {
                throw new Exception("QuotaDataSource data error");
            }
            //判断数据源是什么类型,根据类型和数据库相关的配置信息抽取数据
            if (TjDataSource.type_mysql.equals(quotaDataSource.getType())) {
                //获取数据库配置
                DbConfig dbConfig = (DbConfig) JSONObject.toBean(JSONObject.fromObject(quotaDataSource.getConfigJson()), DbConfig.class);
                //通过配置得到数据库链接
                JdbcTemplate jdbcTemplate = initJdbcTemplate(dbConfig);
                //设置时间
                String sql = initSql(dbConfig.getSql());
                String sqlCount = initSql(dbConfig.getSqlCount());
                //抽取数据
                List<DataModel> ds1 = SpringUtil.getBean(DBExtract.class).extractByPage(
                        DataModel.class,
                        sql,
                        sqlCount,
                        true,
                        jdbcTemplate);
                if (StringUtils.isEmpty(dbConfig.getSecondSql())) {
                    return ds1;
                } else {
                    //设置时间
                    String secondSql = initSql(dbConfig.getSecondSql());
                    String secondSqlCount = initSql(dbConfig.getSecondSqlCount());
                    //抽取数据
                    List<DataModel> ds2 = SpringUtil.getBean(DBExtract.class).extractByPage(DataModel.class,
                            secondSql,
                            secondSqlCount,
                            true,
                            jdbcTemplate);
                    Map<String, List<DataModel>> params = new HashMap<String, List<DataModel>>();
                    params.put(Contant.extract.computeKey1, ds1);
                    params.put(Contant.extract.computeKey2, ds2);
                    return params;
                }
            } else if (TjDataSource.type_redis.equals(quotaDataSource.getType())) {
            }
        } catch (Exception e) {
            logger.error("extract error:" + e.getMessage());
            logger.error("quotaVOr:" + quotaVO.toString());
        }
        return null;
    }
    private String initSql(String sql) {
        try {
            if (sql.contains(Contant.endTime)) {
                sql = sql.replace(Contant.endTime, endTime);
            }
            if (sql.contains(Contant.startTime)) {
                sql = sql.replace(Contant.startTime, startTime);
            }
            logger.info("sql init :"+sql);
        }catch (Exception e){
        }
        return sql;
    }
    /**
     * 初始化数据库的链接
     *
     * @param dbConfig
     * @return
     */
    private JdbcTemplate initJdbcTemplate(DbConfig dbConfig) {
        //初始化数据库链接
        DataSource ds = DataSourceBuilder.create().
                url(dbConfig.getUrl()).
                username(dbConfig.getUsername()).
                driverClassName(dbConfig.getDriver()).
                password(dbConfig.getPassword()).build();
        return new JdbcTemplate(ds);
    }
}

+ 70 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/extract/db/DBExtract.java

@ -0,0 +1,70 @@
package com.yihu.jw.quota.etl.extract.db;
import com.yihu.jw.quota.util.SpringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.sql.DataSource;
import java.util.List;
/**
 * Created by Administrator on 2016.10.16.
 * 数据库抽取
 */
@Component
@Scope("prototype")
public class DBExtract<T> {
    /**
     * 不分页抽取
     * @param clazz
     * @param sql
     * @return
     */
    public List<T> extract(Class<T> clazz,String sql,JdbcTemplate jdbcTemplate){
        List<T> returnList= jdbcTemplate.query(sql,new BeanPropertyRowMapper(clazz));
        return returnList;
    }
    /**
     * 分页抽取
     * @param clazz
     * @param sql
     * @param pageSize 每页显示多少 默认10000
     * @param isMultithreading 是否多线程抽取 默认否
     * @return
     */
    public List<T> extractByPage(Class<T> clazz,String sql,String countSql,int pageSize,Boolean isMultithreading,JdbcTemplate jdbcTemplate)throws  Exception{
        return SpringUtil.getBean(DBPageExtract.class).extractByPage(clazz,sql,countSql,pageSize,isMultithreading,jdbcTemplate);
    }
    /**
     * 分页抽取
     * @param clazz
     * @param sql
     * @param isMultithreading 是否多线程抽取 默认否
     * @return
     */
    public List<T> extractByPage(Class<T> clazz,String sql,String countSql,Boolean isMultithreading,JdbcTemplate jdbcTemplate)throws  Exception{
        if(StringUtils.isEmpty(countSql)){
            return extract(clazz,sql,jdbcTemplate);
        }
        int pageSize=10000;
        return SpringUtil.getBean(DBPageExtract.class).extractByPage(clazz,sql,countSql,pageSize,isMultithreading,jdbcTemplate);
    }
    /**
     * 分页抽取
     * @param clazz
     * @param sql
     * @return
     */
    public List<Object> extractByPage(Class<T> clazz,String sql,JdbcTemplate jdbcTemplate)throws  Exception{
        int pageSize=10000;
        Boolean isMultithreading=false;
        String countSql="";
        return SpringUtil.getBean(DBPageExtract.class).extractByPage(clazz,sql,countSql,pageSize,isMultithreading,jdbcTemplate);
    }
}

+ 162 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/extract/db/DBPageExtract.java

@ -0,0 +1,162 @@
package com.yihu.jw.quota.etl.extract.db;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
/**
 * Created by Administrator on 2016.10.16.
 * 分页抽取器
 */
@Component
@Scope("prototype")
public class DBPageExtract<T> {
    private  List<T> returnList=new ArrayList<T>();
    public synchronized void addData( List<T> dataList) {
         returnList.addAll(dataList);
    }
    public List<T> extractByPage(Class<T> clazz, String sql, String countSql, int pageSize, Boolean isMultithreading,JdbcTemplate jdbcTemplate) throws Exception{
        if(!StringUtils.isEmpty(countSql)){
            isMultithreading=true;
        }
        if(isMultithreading){
            if(StringUtils.isEmpty(countSql)){
                throw new Exception("countSql is null");
            }
            return MultiThreadExtract(clazz, sql,countSql, pageSize,jdbcTemplate);
        }else{
            return noMultiThreadExtract(clazz, sql, pageSize,jdbcTemplate);
        }
    }
    /**
     * 不用多线程抽取
     * @param clazz
     * @param sql
     * @param pageSize
     * @return
     */
    private List<T> noMultiThreadExtract(Class<T> clazz, String sql, int pageSize,JdbcTemplate jdbcTemplate) {
        List<T> returnList=new ArrayList<T>();
        int start=0;
        int page=1;
        while (true){
            String finalSql=sql+" limit "+start+","+pageSize; //拼凑分页的语句
            List<T> listTemp= jdbcTemplate.query(finalSql,new BeanPropertyRowMapper(clazz));
            returnList.addAll(listTemp);//添加到list里面
            //判断是都是最后页面
            if(listTemp.size()!=pageSize){
                listTemp.clear();
                break;
            }else{
                start =page*pageSize;
                page++;
                listTemp.clear();
            }
        }
        return returnList;
    }
    /**
     * 多线程抽取数据
     * @param clazz
     * @param sql
     * @param pageSize
     * @return
     */
    private   List<T> MultiThreadExtract(Class<T> clazz, String sql,String countSql, int pageSize,JdbcTemplate jdbcTemplate)  {
        try{
            //得到数据的总数
            Integer dataCount=getCount(countSql,jdbcTemplate);
            //根据count 计算出 总共要执行几次
            Integer forCount=getForCount(dataCount,pageSize);
            forCount++;
            //綫程返回值的值
            List<AsyncResult<Boolean>> asyncResultPool=new ArrayList<AsyncResult<Boolean>>();
            for(int page=0;page<forCount;page++){
                //启动多线程采集数据
                AsyncResult<Boolean> future= multiExtractData(sql,page*pageSize,pageSize,clazz,jdbcTemplate);
                asyncResultPool.add(future);
            }
            ///循环判断,等待获取结果信息
            while (true){
                //得到迭代器
                Iterator<AsyncResult<Boolean>> asyncResultIterator=asyncResultPool.iterator();
                //判断有没有下一个
                while (asyncResultIterator.hasNext()){
                    AsyncResult<Boolean> asyncResult= asyncResultIterator.next();
                    if(asyncResult.isDone()){
                        //如果做完了就移除迭代器
                        asyncResultIterator.remove();
                    }else{
                        Thread.sleep(500L);
                    }
                }
                //如果一直移除到没有下一个就跳出循环 说明数据已经采集完成
                if(!asyncResultIterator.hasNext()){
                    break;
                }
            }
            return returnList;
        }catch (Exception e){
            //如果多线程错误 就改用单线程
            return noMultiThreadExtract(clazz,sql,pageSize,jdbcTemplate);
        }
    }
    private Integer getForCount(Integer dataCount, int pageSize) {
        //根据所有的数据取余数
        int yushu=dataCount%pageSize;
        int page=dataCount/pageSize;
        if(yushu==0){
            //如果没有余数 返回总的页数
            return page;
        }else{
            //如果有余数 页数多加1
            page++;
            return page;
        }
    }
    private Integer getCount(String countSql,JdbcTemplate jdbcTemplate) {
        Integer countMap= jdbcTemplate.queryForObject(countSql,Integer.class);
        return countMap;
    }
    /**
     * 多线程采集数据
     * @param sql
     * @param start
     * @param pageSize
     * @param clazz
     * @return
     */
    @Async("dbExtractExecutor")
    private AsyncResult<Boolean> multiExtractData(String sql, int start, int pageSize, Class<T> clazz,JdbcTemplate jdbcTemplate) {
        String finalSql=sql+" limit "+start+","+pageSize; //拼凑分页的语句
        List<T> listTemp= jdbcTemplate.query(finalSql,new BeanPropertyRowMapper(clazz));
        addData(listTemp);
        return new AsyncResult<>(true);
    }
}

+ 49 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/filter/FilterHelper.java

@ -0,0 +1,49 @@
package com.yihu.jw.quota.etl.filter;
import com.yihu.jw.quota.etl.Contant;
import com.yihu.jw.quota.etl.filter.filter.NotNullFilter;
import com.yihu.jw.quota.model.jpa.rule.TjQuotaRule;
import com.yihu.jw.quota.service.rule.TjCleanRuleService;
import com.yihu.jw.quota.util.SpringUtil;
import com.yihu.jw.quota.vo.FilterModel;
import com.yihu.jw.quota.vo.QuotaVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * Created by chenweida on 2017/6/1.
 */
@Component
@Scope("prototype")
public class FilterHelper {
    @Autowired
    private TjCleanRuleService cleanRuleService;
    public FilterHelper() {
    }
    /**
     * 根据过滤规则过滤数据
     *
     * @param dataModels
     * @param quotaVO
     * @return
     */
    public FilterModel filter(Object dataModels, QuotaVO quotaVO) {
        List<TjQuotaRule> rules = cleanRuleService.findByQuotaCode(quotaVO.getCode());
        FilterModel f=new FilterModel(dataModels);
        rules.stream().forEach(rule -> {
             switch (rule.getType()){
                 //非空校验
                 case Contant.role.not_null: {
                     SpringUtil.getBean(NotNullFilter.class).filter(f,quotaVO);break;}
                 //如果有其他的校验规则在这边扩展
             }
        });
        return f;
    }
}

+ 84 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/filter/filter/NotNullFilter.java

@ -0,0 +1,84 @@
package com.yihu.jw.quota.etl.filter.filter;
import com.yihu.jw.quota.etl.Contant;
import com.yihu.jw.quota.model.jpa.dimension.TjDimensionSlave;
import com.yihu.jw.quota.service.dimension.TjDimensionSlaveService;
import com.yihu.jw.quota.vo.DataModel;
import com.yihu.jw.quota.vo.ErrModel;
import com.yihu.jw.quota.vo.FilterModel;
import com.yihu.jw.quota.vo.QuotaVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/6/1.
 */
@Component
@Scope("prototype")
public class NotNullFilter {
    private Logger logger = LoggerFactory.getLogger(NotNullFilter.class);
    @Autowired
    private TjDimensionSlaveService dimensionSlaveService;
    /**
     * 不判断主维度的数据是否为空,只判断从维度额的数据是否为空
     *
     * @param filterModel
     * @param quotaVO
     * @return
     */
    public FilterModel filter(FilterModel filterModel, QuotaVO quotaVO) {
        try {
            //得到从维度
            List<TjDimensionSlave> tj = dimensionSlaveService.getDimensionSlaveByQuotaCode(quotaVO.getCode());
            if (Contant.compute.add.equals(quotaVO.getComputeType())) {
                //判断是否是累加计算 如果强转成list类型
                List<DataModel> dmList = (List<DataModel>) filterModel.getData();
                //过滤数据
                filterList(dmList, tj, filterModel.getErrorModels());
            } else if (Contant.compute.division.equals(quotaVO.getComputeType())) {
                //判断是否是除法计算 如果强转成Map类型 key在Contant中
                Map<String, List<DataModel>> dmMap = (Map<String, List<DataModel>>) filterModel.getData();
                List<DataModel> one = dmMap.get(Contant.extract.computeKey1);
                List<DataModel> two = dmMap.get(Contant.extract.computeKey2);
                filterList(one, tj, filterModel.getErrorModels());
                filterList(two, tj, filterModel.getErrorModels());
            }
            return filterModel;
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return null;
    }
    private void filterList(List<DataModel> dmList, List<TjDimensionSlave> tj, List<ErrModel> errorModels) {
        Iterator<DataModel> iterator= dmList.iterator();
        while (iterator.hasNext()) {
            DataModel dataModel = iterator.next();
            for (int i = 1; i <= tj.size(); i++) {
                try {
                    //根据反射判断字段值是否为空
                    Object obj = DataModel.class.getMethod("getSlaveKey" + i).invoke(dataModel);
                    if (StringUtils.isEmpty(obj)) {
                        dmList.iterator().remove();
                        errorModels.add(new ErrModel(dataModel.getBusinessId(), new StringBuffer("slaveKey" + i + " is null").toString()));
                    }
                } catch (Exception e) {
                    logger.error(dataModel.toString() + "," + e.getMessage());
                    e.printStackTrace();
                }
            }
        }
    }
}

+ 91 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/model/DbConfig.java

@ -0,0 +1,91 @@
package com.yihu.jw.quota.etl.model;
import  com.yihu.jw.quota.etl.Contant;
/**
 * Created by chenweida on 2017/6/1.
 */
public class DbConfig {
    private String driver;//数据库驱动
    private String url; //数据库链接
    private String username; //账号
    private String password;//密码
    private String sql;// 语句 如果是多条就是分子
    private String sqlCount;// 语句数目
    private String secondSql;// 语句 分母
    private String secondSqlCount;// 语句数目
    public String getDriver() {
        return driver;
    }
    public void setDriver(String driver) {
        this.driver = driver;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getSql() {
        return sql;
    }
    public void setSql(String sql) {
        this.sql = sql;
    }
    public String getSqlCount() {
        return sqlCount;
    }
    public void setSqlCount(String sqlCount) {
        this.sqlCount = sqlCount;
    }
    public String getSecondSql() {
        return secondSql;
    }
    public void setSecondSql(String secondSql) {
        this.secondSql = secondSql;
    }
    public String getSecondSqlCount() {
        return secondSqlCount;
    }
    public void setSecondSqlCount(String secondSqlCount) {
        this.secondSqlCount = secondSqlCount;
    }
    public String getDbType() {
        if(driver.contains(Contant.db_type.mysql)){
            return Contant.db_type.mysql;
        }
        if(driver.contains( Contant.db_type.oracle)){
            return  Contant.db_type.oracle;
        }
        return null;
    }
}

+ 37 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/model/EsConfig.java

@ -0,0 +1,37 @@
package com.yihu.jw.quota.etl.model;
/**
 * Created by chenweida on 2017/6/2.
 */
public class EsConfig {
    private String host;//地址
    private String index;// 索引 es相当与数据库
    private String type;// 类型 es 相当于表
    public String getHost() {
        return host;
    }
    public void setHost(String host) {
        this.host = host;
    }
    public String getIndex() {
        return index;
    }
    public void setIndex(String index) {
        this.index = index;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
}

+ 41 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/save/SaveHelper.java

@ -0,0 +1,41 @@
package com.yihu.jw.quota.etl.save;
import com.yihu.jw.quota.etl.Contant;
import com.yihu.jw.quota.etl.save.es.ElastricSearchSave;
import com.yihu.jw.quota.model.jpa.save.TjQuotaDataSave;
import com.yihu.jw.quota.service.save.TjDataSaveService;
import com.yihu.jw.quota.util.SpringUtil;
import com.yihu.jw.quota.vo.QuotaVO;
import com.yihu.jw.quota.vo.SaveModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * Created by chenweida on 2017/6/2.
 */
@Component
@Scope("prototype")
public class SaveHelper {
    @Autowired
    private TjDataSaveService datsSaveService;
    public Boolean save(List<SaveModel> sms, QuotaVO quotaVO) {
        //查看指标保存的数据源
        TjQuotaDataSave quotaDataSave = datsSaveService.findByQuota(quotaVO.getCode());
        switch (quotaDataSave.getType()) {
            case Contant.save.mysql: {
                break;
            }
            case Contant.save.redis: {
                break;
            }
            case Contant.save.es: {
                return SpringUtil.getBean(ElastricSearchSave.class).save(sms,quotaDataSave.getJsonConfig());
            }
        }
        return false;
    }
}

+ 30 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/save/es/ElasticFactory.java

@ -0,0 +1,30 @@
package com.yihu.jw.quota.etl.save.es;
import io.searchbox.client.JestClient;
import io.searchbox.client.JestClientFactory;
import io.searchbox.client.config.ClientConfig;
import io.searchbox.client.config.HttpClientConfig;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
/**
 * Created by chenweida on 2017/6/5.
 */
@Component
public class ElasticFactory {
    /**
     * @param hostAddress "http://localhost:9200"
     * @return
     */
    public JestClient getClient(String hostAddress) {
        // Construct a new Jest client according to configuration via factory
        JestClientFactory factory = new JestClientFactory();
        factory.setHttpClientConfig(new HttpClientConfig
                .Builder(hostAddress)
                .multiThreaded(true)
                .discoveryEnabled(true)
                .build());
        return factory.getObject();
    }
}

+ 51 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/etl/save/es/ElastricSearchSave.java

@ -0,0 +1,51 @@
package com.yihu.jw.quota.etl.save.es;
import com.yihu.jw.quota.etl.model.EsConfig;
import com.yihu.jw.quota.vo.SaveModel;
import io.searchbox.client.JestClient;
import io.searchbox.core.Bulk;
import io.searchbox.core.BulkResult;
import io.searchbox.core.Index;
import net.sf.json.JSONObject;;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * Created by chenweida on 2017/6/2.
 */
@Component
@Scope("prototype")
public class ElastricSearchSave {
    private Logger logger = LoggerFactory.getLogger(ElastricSearchSave.class);
    @Autowired
    private ElasticFactory elasticFactory;
    private EsConfig esConfig;
    public Boolean save(List<SaveModel> sms, String jsonConfig) {
        try {
            //初始化参数
            esConfig = (EsConfig) JSONObject.toBean(JSONObject.fromObject(jsonConfig), EsConfig.class);
            //得到链接
            JestClient jestClient = elasticFactory.getClient(esConfig.getHost());
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esConfig.getIndex()).defaultType(esConfig.getType());
            for (SaveModel obj : sms) {
                Index index = new Index.Builder(obj).build();
                bulk.addAction(index);
            }
            BulkResult br = jestClient.execute(bulk.build());
            return br.isSucceeded();
        } catch (Exception e) {
            logger.error(" save error :" + e.getMessage());
        }
        return null;
    }
}

+ 196 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/job/QuotaJob.java

@ -0,0 +1,196 @@
package com.yihu.jw.quota.job;
import com.yihu.jw.quota.dao.jpa.TjQuotaLogDao;
import com.yihu.jw.quota.etl.Contant;
import com.yihu.jw.quota.etl.compute.ComputeHelper;
import com.yihu.jw.quota.etl.extract.ExtractHelper;
import com.yihu.jw.quota.etl.filter.FilterHelper;
import com.yihu.jw.quota.etl.save.SaveHelper;
import com.yihu.jw.quota.model.jpa.TjQuotaLog;
import com.yihu.jw.quota.model.jpa.compute.TjCompute;
import com.yihu.jw.quota.service.compute.TjComputeService;
import com.yihu.jw.quota.service.rule.TjCleanRuleService;
import com.yihu.jw.quota.service.source.TjDataSourceService;
import com.yihu.jw.quota.util.SpringUtil;
import com.yihu.jw.quota.vo.*;
import net.sf.json.JSONObject;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Administrator on 2016.10.10.
 * 每天的签约到达量统计
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class QuotaJob implements Job {
    private Logger logger = LoggerFactory.getLogger(QuotaJob.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private TjComputeService computeService;
    @Autowired
    private TjQuotaLogDao tjQuotaLogDao;
    private String saasid;//saasid
    private QuotaVO quotaVO;//指标对象
    private String endTime;//结束时间
    private String startTime;//开始时间
    private String timeLevel;//时间
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try {
            //springz注入
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            initParams(context);
            //统计指标
            computequota();
        } catch (Exception e) {
            //如果出錯立即重新執行
            JobExecutionException e2 = new JobExecutionException(e);
            e2.setRefireImmediately(true);
            e.printStackTrace();
        }
    }
    /**
     * 初始化参数
     *
     * @param context
     */
    private void initParams(JobExecutionContext context) {
        JobDataMap map = context.getJobDetail().getJobDataMap();
        this.saasid = map.getString("saasid");
        this.endTime = map.getString("endTime");
        if (StringUtils.isEmpty(endTime)) {
            endTime = LocalDate.now().toString("yyyy-MM-dd"); //2017-06-01 默认今天
        }
        this.startTime = map.getString("startTime");
        if (StringUtils.isEmpty(startTime)) {
            startTime = new LocalDate(new DateTime().minusDays(1)).toString("yyyy-MM-dd"); //默认昨天
        }
        this.quotaVO = (QuotaVO) map.get("quota");
        if (quotaVO != null) {
            //得到算法
            TjCompute compute = computeService.findByQuotaCode(quotaVO.getCode());
            quotaVO.setComputeType(compute.getType());
        } else {
            logger.error("quotaVO is null");
            return;
        }
        this.timeLevel = (String) map.get("timeLevel");
        if (StringUtils.isEmpty(this.timeLevel)) {
            this.timeLevel = Contant.main_dimension_timeLevel.day;
        }
    }
    /**
     * 计算指标
     */
    private void computequota() {
        try {
            TjQuotaLog tjQuotaLog = new TjQuotaLog();
            tjQuotaLog.setQuotaCode(quotaVO.getCode());
            tjQuotaLog.setSaasId(saasid);
            tjQuotaLog.setStartTime(new Date());
            JobLogModel jobLogModel = new JobLogModel();
            //抽取数据 如果是累加就是 List<DataModel>  如果是相除 Map<String,List<DataModel>>
            Object dataModels = extract();
            //根据规则过滤数据
            FilterModel filterModel = filter(dataModels);
            jobLogModel.setErrorModels(filterModel.getErrorModels());
            //统计数据
            List<SaveModel> sms = compute(filterModel.getData());
            //保存数据
            Boolean success = saveDate(sms);
            tjQuotaLog.setStatus(success ? Contant.save_status.success : Contant.save_status.fail);
            tjQuotaLog.setEndTime(new Date());
            tjQuotaLog.setContent(JSONObject.fromObject(jobLogModel).toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 保存数据
     *
     * @param sms
     */
    private Boolean saveDate(List<SaveModel> sms) {
        try {
            return SpringUtil.getBean(SaveHelper.class).save(sms, quotaVO);
        } catch (Exception e) {
            logger.error("save error:" + e.getMessage());
        }
        return false;
    }
    /**
     * 根据计算规则统计数据
     *
     * @param dataModels
     */
    private List<SaveModel> compute(Object dataModels) {
        try {
            return SpringUtil.getBean(ComputeHelper.class).compute(dataModels, quotaVO, timeLevel, saasid, startTime);
        } catch (Exception e) {
            logger.error("compute error:" + e.getMessage());
        }
        return null;
    }
    /**
     * 过滤数据
     *
     * @param dataModels
     * @return
     */
    private FilterModel filter(Object dataModels) {
        try {
            return SpringUtil.getBean(FilterHelper.class).filter(dataModels, quotaVO);
        } catch (Exception e) {
            logger.error("filter error:" + e.getMessage());
        }
        return null;
    }
    /**
     * 抽取数据
     *
     * @return
     */
    private Object extract() {
        try {
            return SpringUtil.getBean(ExtractHelper.class).extractData(quotaVO, startTime, endTime);
        } catch (Exception e) {
            logger.error("extract error:" + e.getMessage());
        }
        return null;
    }
}

+ 1 - 1
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/QuotaResult.java

@ -1,4 +1,4 @@
package com.yihu.jw.quota.model;
package com.yihu.jw.quota.model.es;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.CreatedDate;

+ 179 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/TjQuota.java

@ -0,0 +1,179 @@
package com.yihu.jw.quota.model.jpa;// default package
import java.util.Date;
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
/**
 * TjQuota entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tj_quota")
public class TjQuota implements java.io.Serializable {
	// Fields
	private Integer id;
	private String code;
	private String compute; //关联表tj_compute code
	private String name;
	private String jobClazz; //类class
	private Date createTime;
	private String createUser;
	private String createUserName;
	private Date updateTime;
	private String updateUser;
	private String updateUserName;
	private String status;//1: 正常 0:不可用  -1删除
	private String remark;
	// Constructors
	/** default constructor */
	public TjQuota() {
	}
	/** minimal constructor */
	public TjQuota(Date createTime, Date updateTime) {
		this.createTime = createTime;
		this.updateTime = updateTime;
	}
	/** full constructor */
	public TjQuota(String code, String name, String jobClazz,
			Date createTime, String createUser, String createUserName,
			Date updateTime, String updateUser, String updateUserName,
			String status, String remark) {
		this.code = code;
		this.name = name;
		this.jobClazz = jobClazz;
		this.createTime = createTime;
		this.createUser = createUser;
		this.createUserName = createUserName;
		this.updateTime = updateTime;
		this.updateUser = updateUser;
		this.updateUserName = updateUserName;
		this.status = status;
		this.remark = remark;
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "code", length = 100)
	public String getCode() {
		return this.code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "name", length = 200)
	public String getName() {
		return this.name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Column(name = "job_clazz", length = 500)
	public String getJobClazz() {
		return this.jobClazz;
	}
	public void setJobClazz(String jobClazz) {
		this.jobClazz = jobClazz;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", nullable = false, length = 0)
	public Date getCreateTime() {
		return this.createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "create_user", length = 100)
	public String getCreateUser() {
		return this.createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	@Column(name = "create_user_name", length = 50)
	public String getCreateUserName() {
		return this.createUserName;
	}
	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time", nullable = false, length = 0)
	public Date getUpdateTime() {
		return this.updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Column(name = "update_user", length = 100)
	public String getUpdateUser() {
		return this.updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	@Column(name = "update_user_name", length = 50)
	public String getUpdateUserName() {
		return this.updateUserName;
	}
	public void setUpdateUserName(String updateUserName) {
		this.updateUserName = updateUserName;
	}
	@Column(name = "status", length = 1)
	public String getStatus() {
		return this.status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	@Column(name = "remark", length = 1500)
	public String getRemark() {
		return this.remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public String getCompute() {
		return compute;
	}
	public void setCompute(String compute) {
		this.compute = compute;
	}
}

+ 80 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/TjQuotaLog.java

@ -0,0 +1,80 @@
package com.yihu.jw.quota.model.jpa;
import javax.persistence.*;
import java.util.Date;
import static javax.persistence.GenerationType.IDENTITY;
/**
 * Created by chenweida on 2017/6/2.
 */
@Entity
@Table(name = "tj_quota_log")
public class TjQuotaLog {
    private Integer id;
    private String saasId;
    private String quotaCode;
    private Date startTime;
    private Date endTime;
    private String content;
    private String status;
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getQuotaCode() {
        return quotaCode;
    }
    public void setQuotaCode(String quotaCode) {
        this.quotaCode = quotaCode;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
}

+ 171 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/compute/TjCompute.java

@ -0,0 +1,171 @@
package com.yihu.jw.quota.model.jpa.compute;// default package
import java.util.Date;
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
/**
 * TjCompute entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tj_compute")
public class TjCompute implements java.io.Serializable {
	// Fields
	private Integer id;
	private String code;
	private String name;
	private Date createTime;
	private String createUser;
	private String createUserName;
	private Date modifyTime;
	private String updateUser;
	private String updateUserName;
	private String status;
	private String remark;
	private String type;
	// Constructors
	/** default constructor */
	public TjCompute() {
	}
	/** minimal constructor */
	public TjCompute(Date createTime, Date modifyTime) {
		this.createTime = createTime;
		this.modifyTime = modifyTime;
	}
	/** full constructor */
	public TjCompute(String code, String name, Date createTime,
			String createUser, String createUserName, Date modifyTime,
			String updateUser, String updateUserName, String status,
			String remark, String type) {
		this.code = code;
		this.name = name;
		this.createTime = createTime;
		this.createUser = createUser;
		this.createUserName = createUserName;
		this.modifyTime = modifyTime;
		this.updateUser = updateUser;
		this.updateUserName = updateUserName;
		this.status = status;
		this.remark = remark;
		this.type = type;
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "code", length = 100)
	public String getCode() {
		return this.code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "name", length = 200)
	public String getName() {
		return this.name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", nullable = false, length = 0)
	public Date getCreateTime() {
		return this.createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "create_user", length = 100)
	public String getCreateUser() {
		return this.createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	@Column(name = "create_user_name", length = 50)
	public String getCreateUserName() {
		return this.createUserName;
	}
	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "modify_time", nullable = false, length = 0)
	public Date getModifyTime() {
		return this.modifyTime;
	}
	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}
	@Column(name = "update_user", length = 100)
	public String getUpdateUser() {
		return this.updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	@Column(name = "update_user_name", length = 50)
	public String getUpdateUserName() {
		return this.updateUserName;
	}
	public void setUpdateUserName(String updateUserName) {
		this.updateUserName = updateUserName;
	}
	@Column(name = "status", length = 1)
	public String getStatus() {
		return this.status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	@Column(name = "remark", length = 1500)
	public String getRemark() {
		return this.remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	@Column(name = "type", length = 2)
	public String getType() {
		return this.type;
	}
	public void setType(String type) {
		this.type = type;
	}
}

+ 117 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/dict/SystemDict.java

@ -0,0 +1,117 @@
package com.yihu.jw.quota.model.jpa.dict;// default package
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;
/**
 * SystemDict entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "system_dict")
public class SystemDict implements java.io.Serializable {
	// Fields
	private Integer id;
	private String saasId;
	private String dictName;
	private String code;
	private String value;
	private String pyCode;
	private Integer sort;
	// Constructors
	/** default constructor */
	public SystemDict() {
	}
	/** minimal constructor */
	public SystemDict(String dictName, String code, String value) {
		this.dictName = dictName;
		this.code = code;
		this.value = value;
	}
	/** full constructor */
	public SystemDict(String saasId, String dictName, String code,
			String value, String pyCode, Integer sort) {
		this.saasId = saasId;
		this.dictName = dictName;
		this.code = code;
		this.value = value;
		this.pyCode = pyCode;
		this.sort = sort;
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "saas_id", length = 100)
	public String getSaasId() {
		return this.saasId;
	}
	public void setSaasId(String saasId) {
		this.saasId = saasId;
	}
	@Column(name = "dict_name", nullable = false, length = 50)
	public String getDictName() {
		return this.dictName;
	}
	public void setDictName(String dictName) {
		this.dictName = dictName;
	}
	@Column(name = "code", nullable = false, length = 50)
	public String getCode() {
		return this.code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "value", nullable = false, length = 50)
	public String getValue() {
		return this.value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	@Column(name = "py_code", length = 50)
	public String getPyCode() {
		return this.pyCode;
	}
	public void setPyCode(String pyCode) {
		this.pyCode = pyCode;
	}
	@Column(name = "sort")
	public Integer getSort() {
		return this.sort;
	}
	public void setSort(Integer sort) {
		this.sort = sort;
	}
}

+ 152 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/dict/SystemDictList.java

@ -0,0 +1,152 @@
package com.yihu.jw.quota.model.jpa.dict;// default package
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
 * SystemDictList entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "system_dict_list")
public class SystemDictList implements java.io.Serializable {
	// Fields
	private Integer id;
	private String dictName;
	private String chineseName;
	private String pyCode;
	private String pid;
	private String remark;
	private String relationTable;
	private String relationColCode;
	private String relationColValue;
	private String relationColExtend;
	// Constructors
	/** default constructor */
	public SystemDictList() {
	}
	/** minimal constructor */
	public SystemDictList(Integer id, String dictName, String chineseName,
			String pid) {
		this.id = id;
		this.dictName = dictName;
		this.chineseName = chineseName;
		this.pid = pid;
	}
	/** full constructor */
	public SystemDictList(Integer id, String dictName, String chineseName,
			String pyCode, String pid, String remark, String relationTable,
			String relationColCode, String relationColValue,
			String relationColExtend) {
		this.id = id;
		this.dictName = dictName;
		this.chineseName = chineseName;
		this.pyCode = pyCode;
		this.pid = pid;
		this.remark = remark;
		this.relationTable = relationTable;
		this.relationColCode = relationColCode;
		this.relationColValue = relationColValue;
		this.relationColExtend = relationColExtend;
	}
	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "dict_name", nullable = false, length = 50)
	public String getDictName() {
		return this.dictName;
	}
	public void setDictName(String dictName) {
		this.dictName = dictName;
	}
	@Column(name = "chinese_name", nullable = false, length = 50)
	public String getChineseName() {
		return this.chineseName;
	}
	public void setChineseName(String chineseName) {
		this.chineseName = chineseName;
	}
	@Column(name = "py_code", length = 50)
	public String getPyCode() {
		return this.pyCode;
	}
	public void setPyCode(String pyCode) {
		this.pyCode = pyCode;
	}
	@Column(name = "pid", nullable = false, length = 50)
	public String getPid() {
		return this.pid;
	}
	public void setPid(String pid) {
		this.pid = pid;
	}
	@Column(name = "remark", length = 200)
	public String getRemark() {
		return this.remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	@Column(name = "relation_table", length = 50)
	public String getRelationTable() {
		return this.relationTable;
	}
	public void setRelationTable(String relationTable) {
		this.relationTable = relationTable;
	}
	@Column(name = "relation_col_code", length = 50)
	public String getRelationColCode() {
		return this.relationColCode;
	}
	public void setRelationColCode(String relationColCode) {
		this.relationColCode = relationColCode;
	}
	@Column(name = "relation_col_value", length = 50)
	public String getRelationColValue() {
		return this.relationColValue;
	}
	public void setRelationColValue(String relationColValue) {
		this.relationColValue = relationColValue;
	}
	@Column(name = "relation_col_extend", length = 50)
	public String getRelationColExtend() {
		return this.relationColExtend;
	}
	public void setRelationColExtend(String relationColExtend) {
		this.relationColExtend = relationColExtend;
	}
}

+ 191 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/dimension/TjDimensionMain.java

@ -0,0 +1,191 @@
package com.yihu.jw.quota.model.jpa.dimension;// default package
import java.util.Date;
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
/**
 * TjDimensionMain entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tj_dimension_main")
public class TjDimensionMain implements java.io.Serializable {
    // Fields
    private Integer id;
    private String code;
    private String name;
    private Date createTime;
    private String createUser;
    private String createUserName;
    private Date updateTime;
    private String updateUser;
    private String updateUserName;
    private Integer status;//1: 正常 0:不可以用 -1 已删除
    private String remark;
    /**
     * 主维度 :
     * 1 时间维度(日)
     * 2 时间维度(周)
     * 3.时间维度(月)
     * 4时间维度(年)
     * 5 行政区划维度(省)
     * 6行政区划维度(市)
     * 7行政区划维度(区县)
     * 8行政区划维度(机构)
     * 9行政区划维度(团队)
     */
    private String type;
    // Constructors
    /**
     * default constructor
     */
    public TjDimensionMain() {
    }
    /**
     * minimal constructor
     */
    public TjDimensionMain(Date createTime, Date updateTime) {
        this.createTime = createTime;
        this.updateTime = updateTime;
    }
    /**
     * full constructor
     */
    public TjDimensionMain(String code, String name, Date createTime,
                           String createUser, String createUserName, Date updateTime,
                           String updateUser, String updateUserName, Integer status,
                           String remark, String type) {
        this.code = code;
        this.name = name;
        this.createTime = createTime;
        this.createUser = createUser;
        this.createUserName = createUserName;
        this.updateTime = updateTime;
        this.updateUser = updateUser;
        this.updateUserName = updateUserName;
        this.status = status;
        this.remark = remark;
        this.type = type;
    }
    // Property accessors
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    @Column(name = "code", length = 100)
    public String getCode() {
        return this.code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "name", length = 200)
    public String getName() {
        return this.name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_time", nullable = false, length = 0)
    public Date getCreateTime() {
        return this.createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "create_user", length = 100)
    public String getCreateUser() {
        return this.createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    @Column(name = "create_user_name", length = 50)
    public String getCreateUserName() {
        return this.createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "update_time", nullable = false, length = 0)
    public Date getUpdateTime() {
        return this.updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    @Column(name = "update_user", length = 100)
    public String getUpdateUser() {
        return this.updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    @Column(name = "update_user_name", length = 50)
    public String getUpdateUserName() {
        return this.updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return this.status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "remark", length = 1500)
    public String getRemark() {
        return this.remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "type", length = 10)
    public String getType() {
        return this.type;
    }
    public void setType(String type) {
        this.type = type;
    }
}

+ 167 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/dimension/TjDimensionSlave.java

@ -0,0 +1,167 @@
package com.yihu.jw.quota.model.jpa.dimension;// default package
import java.util.Date;
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
/**
 * TjDimensionSlave entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tj_dimension_slave")
public class TjDimensionSlave implements java.io.Serializable {
	// Fields
	private Integer id;
	private String code;
	private String name;
	private Integer status;//1: 正常 0:不可以用 -1 已删除
	private String type;//// 维度 :1 性别 2年龄
	private Date createTime;
	private String createUser;
	private String createUserName;
	private Date updateTime;
	private String updateUser;
	private String updateUserName;
	private String remark;
	// Constructors
	/** default constructor */
	public TjDimensionSlave() {
	}
	/** minimal constructor */
	public TjDimensionSlave(Date createTime, Date updateTime) {
		this.createTime = createTime;
		this.updateTime = updateTime;
	}
	/** full constructor */
	public TjDimensionSlave(String code, String name,
			Date createTime, String createUser, String createUserName,
			Date updateTime, String updateUser, String updateUserName,
			String remark) {
		this.code = code;
		this.name = name;
		this.createTime = createTime;
		this.createUser = createUser;
		this.createUserName = createUserName;
		this.updateTime = updateTime;
		this.updateUser = updateUser;
		this.updateUserName = updateUserName;
		this.remark = remark;
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "code", length = 100)
	public String getCode() {
		return this.code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "name", length = 200)
	public String getName() {
		return this.name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Column(name = "status")
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", nullable = false, length = 0)
	public Date getCreateTime() {
		return this.createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "create_user", length = 100)
	public String getCreateUser() {
		return this.createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	@Column(name = "create_user_name", length = 50)
	public String getCreateUserName() {
		return this.createUserName;
	}
	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time", nullable = false, length = 0)
	public Date getUpdateTime() {
		return this.updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Column(name = "update_user", length = 100)
	public String getUpdateUser() {
		return this.updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	@Column(name = "update_user_name", length = 50)
	public String getUpdateUserName() {
		return this.updateUserName;
	}
	public void setUpdateUserName(String updateUserName) {
		this.updateUserName = updateUserName;
	}
	@Column(name = "remark", length = 1500)
	public String getRemark() {
		return this.remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
}

+ 73 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/dimension/TjQuotaDimensionMain.java

@ -0,0 +1,73 @@
package com.yihu.jw.quota.model.jpa.dimension;// default package
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
/**
 * TjQuotaDimensionMain entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tj_quota_dimension_main")
public class TjQuotaDimensionMain implements java.io.Serializable {
	// Fields
	private Integer id;
	private String quotaCode;
	private String mainCode;
	private String ditcSql;
	private String type;
	// Constructors
	/** default constructor */
	public TjQuotaDimensionMain() {
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "quota_code", length = 100)
	public String getQuotaCode() {
		return this.quotaCode;
	}
	public void setQuotaCode(String quotaCode) {
		this.quotaCode = quotaCode;
	}
	@Column(name = "main_code", length = 100)
	public String getMainCode() {
		return this.mainCode;
	}
	public void setMainCode(String mainCode) {
		this.mainCode = mainCode;
	}
	public String getDitcSql() {
		return ditcSql;
	}
	public void setDitcSql(String ditcSql) {
		this.ditcSql = ditcSql;
	}
	@Transient
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
}

+ 81 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/dimension/TjQuotaDimensionSlave.java

@ -0,0 +1,81 @@
package com.yihu.jw.quota.model.jpa.dimension;// default package
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
/**
 * TjQuotaDimensionSlave entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tj_quota_dimension_slave")
public class TjQuotaDimensionSlave implements java.io.Serializable {
	// Fields
	private Integer id;
	private String quotaCode;
	private String slaveCode;
	private String dictSql;
	private String type;
	// Constructors
	/** default constructor */
	public TjQuotaDimensionSlave() {
	}
	/** full constructor */
	public TjQuotaDimensionSlave(String quotaCode, String slaveCode) {
		this.quotaCode = quotaCode;
		this.slaveCode = slaveCode;
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "quota_code", length = 100)
	public String getQuotaCode() {
		return this.quotaCode;
	}
	public void setQuotaCode(String quotaCode) {
		this.quotaCode = quotaCode;
	}
	@Column(name = "slave_code", length = 100)
	public String getSlaveCode() {
		return this.slaveCode;
	}
	public void setSlaveCode(String slaveCode) {
		this.slaveCode = slaveCode;
	}
	public String getDictSql() {
		return dictSql;
	}
	public void setDictSql(String dictSql) {
		this.dictSql = dictSql;
	}
	@Transient
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
}

+ 155 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/rule/TjCleanRule.java

@ -0,0 +1,155 @@
package com.yihu.jw.quota.model.jpa.rule;// default package
import java.util.Date;
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
/**
 * TjCleanRule entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tj_clean_rule")
public class TjCleanRule implements java.io.Serializable {
	// Fields
	private Integer id;
	private String code;
	private String name;
	private String type;//1非空
	private Date createTime;
	private String createUser;
	private String createUserName;
	private Date updateTime;
	private String updateUser;
	private String updateUserName;
	private String status;
	private String remark;
	// Constructors
	/** default constructor */
	public TjCleanRule() {
	}
	/** minimal constructor */
	public TjCleanRule(String code, Date createTime, Date updateTime) {
		this.code = code;
		this.createTime = createTime;
		this.updateTime = updateTime;
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "code", nullable = false, length = 100)
	public String getCode() {
		return this.code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "name", length = 200)
	public String getName() {
		return this.name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", nullable = false, length = 0)
	public Date getCreateTime() {
		return this.createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "create_user", length = 100)
	public String getCreateUser() {
		return this.createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	@Column(name = "create_user_name", length = 50)
	public String getCreateUserName() {
		return this.createUserName;
	}
	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time", nullable = false, length = 0)
	public Date getUpdateTime() {
		return this.updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Column(name = "update_user", length = 100)
	public String getUpdateUser() {
		return this.updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	@Column(name = "update_user_name", length = 50)
	public String getUpdateUserName() {
		return this.updateUserName;
	}
	public void setUpdateUserName(String updateUserName) {
		this.updateUserName = updateUserName;
	}
	@Column(name = "status", length = 1)
	public String getStatus() {
		return this.status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	@Column(name = "remark", length = 1500)
	public String getRemark() {
		return this.remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
}

+ 77 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/rule/TjQuotaRule.java

@ -0,0 +1,77 @@
package com.yihu.jw.quota.model.jpa.rule;// default package
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
import javax.transaction.Transactional;
/**
 * TjQuotaRule entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tj_quota_rule")
public class TjQuotaRule implements java.io.Serializable {
    // Fields
    private Integer id;
    private String quotaCode;
    private String ruleCode;
    private String type;// 1数据非空
    // Constructors
    /**
     * default constructor
     */
    public TjQuotaRule() {
    }
    /**
     * full constructor
     */
    public TjQuotaRule(String quotaCode, String ruleCode) {
        this.quotaCode = quotaCode;
        this.ruleCode = ruleCode;
    }
    // Property accessors
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    @Column(name = "quota_code", length = 100)
    public String getQuotaCode() {
        return this.quotaCode;
    }
    public void setQuotaCode(String quotaCode) {
        this.quotaCode = quotaCode;
    }
    @Column(name = "rule_code", length = 100)
    public String getRuleCode() {
        return this.ruleCode;
    }
    public void setRuleCode(String ruleCode) {
        this.ruleCode = ruleCode;
    }
    @Transient
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
}

+ 171 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/save/TjDataSave.java

@ -0,0 +1,171 @@
package com.yihu.jw.quota.model.jpa.save;// default package
import java.util.Date;
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
/**
 * TjDataSave entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tj_data_save")
public class TjDataSave implements java.io.Serializable {
	// Fields
	private Integer id;
	private String code;
	private String name;
	private String type;//1:mysql数据库 2:redis 3ES
	private Date createTime;
	private String createUser;
	private String createUserName;
	private Date updateTime;
	private String updateUser;
	private String updateUserName;
	private String status;//1: 正常 0:不可用  -1删除
	private String remark;
	// Constructors
	/** default constructor */
	public TjDataSave() {
	}
	/** minimal constructor */
	public TjDataSave(Date createTime, Date updateTime) {
		this.createTime = createTime;
		this.updateTime = updateTime;
	}
	/** full constructor */
	public TjDataSave(String code, String name, String type,
			Date createTime, String createUser, String createUserName,
			Date updateTime, String updateUser, String updateUserName,
			String status, String remark) {
		this.code = code;
		this.name = name;
		this.type = type;
		this.createTime = createTime;
		this.createUser = createUser;
		this.createUserName = createUserName;
		this.updateTime = updateTime;
		this.updateUser = updateUser;
		this.updateUserName = updateUserName;
		this.status = status;
		this.remark = remark;
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "code", length = 100)
	public String getCode() {
		return this.code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "name", length = 200)
	public String getName() {
		return this.name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Column(name = "type", length = 2)
	public String getType() {
		return this.type;
	}
	public void setType(String type) {
		this.type = type;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", nullable = false, length = 0)
	public Date getCreateTime() {
		return this.createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "create_user", length = 100)
	public String getCreateUser() {
		return this.createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	@Column(name = "create_user_name", length = 50)
	public String getCreateUserName() {
		return this.createUserName;
	}
	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time", nullable = false, length = 0)
	public Date getUpdateTime() {
		return this.updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Column(name = "update_user", length = 100)
	public String getUpdateUser() {
		return this.updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	@Column(name = "update_user_name", length = 50)
	public String getUpdateUserName() {
		return this.updateUserName;
	}
	public void setUpdateUserName(String updateUserName) {
		this.updateUserName = updateUserName;
	}
	@Column(name = "status", length = 1)
	public String getStatus() {
		return this.status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	@Column(name = "remark", length = 1500)
	public String getRemark() {
		return this.remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
}

+ 81 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/save/TjQuotaDataSave.java

@ -0,0 +1,81 @@
package com.yihu.jw.quota.model.jpa.save;// default package
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
/**
 * TjQuotaDataSave entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tj_quota_data_save")
public class TjQuotaDataSave implements java.io.Serializable {
	// Fields
	private Integer id;
	private String quotaCode;
	private String saveCode;
	private String jsonConfig;
	private String type;//1:mysql数据库 2:redis 3ES
	// Constructors
	/** default constructor */
	public TjQuotaDataSave() {
	}
	/** full constructor */
	public TjQuotaDataSave(String quotaCode, String saveCode, String jsonConfig) {
		this.quotaCode = quotaCode;
		this.saveCode = saveCode;
		this.jsonConfig = jsonConfig;
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "quota_code", length = 100)
	public String getQuotaCode() {
		return this.quotaCode;
	}
	public void setQuotaCode(String quotaCode) {
		this.quotaCode = quotaCode;
	}
	@Column(name = "save_code", length = 100)
	public String getSaveCode() {
		return this.saveCode;
	}
	public void setSaveCode(String saveCode) {
		this.saveCode = saveCode;
	}
	@Column(name = "json_config", length = 1500)
	public String getJsonConfig() {
		return this.jsonConfig;
	}
	public void setJsonConfig(String jsonConfig) {
		this.jsonConfig = jsonConfig;
	}
	@Transient
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
}

+ 172 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/source/TjDataSource.java

@ -0,0 +1,172 @@
package com.yihu.jw.quota.model.jpa.source;// default package
import java.util.Date;
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
/**
 * TjDataSource entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tj_data_source")
public class TjDataSource implements java.io.Serializable {
	public static String type_mysql="1";
	public static String type_redis="2";
	// Fields
	private Integer id;
	private String code;
	private String type;// 1:mysql数据库 2:redis 3 接口
	private String name;
	private Date createTime;
	private String createUser;
	private String createUserName;
	private Date updateTime;
	private String updateUser;
	private String updateUserName;
	private String status;//1: 正常 0:不可用  -1删除
	private String remark;
	// Constructors
	/** default constructor */
	public TjDataSource() {
	}
	/** minimal constructor */
	public TjDataSource(Date createTime, Date updateTime) {
		this.createTime = createTime;
		this.updateTime = updateTime;
	}
	/** full constructor */
	public TjDataSource(String code, String type, String name,
			Date createTime, String createUser, String createUserName,
			Date updateTime, String updateUser, String updateUserName,
			String status, String remark) {
		this.code = code;
		this.type = type;
		this.name = name;
		this.createTime = createTime;
		this.createUser = createUser;
		this.createUserName = createUserName;
		this.updateTime = updateTime;
		this.updateUser = updateUser;
		this.updateUserName = updateUserName;
		this.status = status;
		this.remark = remark;
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "code", length = 100)
	public String getCode() {
		return this.code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "type", length = 2)
	public String getType() {
		return this.type;
	}
	public void setType(String type) {
		this.type = type;
	}
	@Column(name = "name", length = 200)
	public String getName() {
		return this.name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", nullable = false, length = 0)
	public Date getCreateTime() {
		return this.createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "create_user", length = 100)
	public String getCreateUser() {
		return this.createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	@Column(name = "create_user_name", length = 50)
	public String getCreateUserName() {
		return this.createUserName;
	}
	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time", nullable = false, length = 0)
	public Date getUpdateTime() {
		return this.updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Column(name = "update_user", length = 100)
	public String getUpdateUser() {
		return this.updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	@Column(name = "update_user_name", length = 50)
	public String getUpdateUserName() {
		return this.updateUserName;
	}
	public void setUpdateUserName(String updateUserName) {
		this.updateUserName = updateUserName;
	}
	@Column(name = "status", length = 1)
	public String getStatus() {
		return this.status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	@Column(name = "remark", length = 1500)
	public String getRemark() {
		return this.remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
}

+ 83 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/source/TjQuotaDataSource.java

@ -0,0 +1,83 @@
package com.yihu.jw.quota.model.jpa.source;// default package
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
/**
 * TjQuotaDataSource entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tj_quota_data_source")
public class TjQuotaDataSource implements java.io.Serializable {
	// Fields
	private Integer id;
	private String quotaCode;
	private String sourceCode;
	private String configJson;
	private String type;
	// Constructors
	/** default constructor */
	public TjQuotaDataSource() {
	}
	/** full constructor */
	public TjQuotaDataSource(String quotaCode, String sourceCode,
			String configJson) {
		this.quotaCode = quotaCode;
		this.sourceCode = sourceCode;
		this.configJson = configJson;
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "quota_code", length = 100)
	public String getQuotaCode() {
		return this.quotaCode;
	}
	public void setQuotaCode(String quotaCode) {
		this.quotaCode = quotaCode;
	}
	@Column(name = "source_code", length = 100)
	public String getSourceCode() {
		return this.sourceCode;
	}
	public void setSourceCode(String sourceCode) {
		this.sourceCode = sourceCode;
	}
	@Column(name = "config_json", length = 2000)
	public String getConfigJson() {
		return this.configJson;
	}
	public void setConfigJson(String configJson) {
		this.configJson = configJson;
	}
	@Transient
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
}

+ 1 - 1
svr/svr-quota/src/main/java/com/yihu/jw/quota/service/QuotaService.java

@ -1,7 +1,7 @@
package com.yihu.jw.quota.service;
import com.yihu.jw.quota.dao.es.QuotaResultDao;
import com.yihu.jw.quota.model.QuotaResult;
import com.yihu.jw.quota.model.es.QuotaResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

+ 35 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/service/compute/TjComputeService.java

@ -0,0 +1,35 @@
package com.yihu.jw.quota.service.compute;
import com.yihu.jw.quota.dao.jpa.compute.TjComputeDao;
import com.yihu.jw.quota.model.jpa.compute.TjCompute;
import com.yihu.jw.quota.model.jpa.rule.TjQuotaRule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by chenweida on 2017/6/1.
 */
@Service
public class TjComputeService {
    @Autowired
    private TjComputeDao computeDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public TjCompute findByQuotaCode(String code) {
        String sql=" SELECT " +
                "  tc.* " +
                " FROM " +
                "  tj_compute tc, " +
                "  tj_quota_compute tqc " +
                " WHERE " +
                "  tc.`code` = tqc.compute_code " +
                " AND tqc.quota_code = ? ";
        List<TjCompute> quotaDataSources = jdbcTemplate.query(sql, new BeanPropertyRowMapper(TjCompute.class), code);
        return quotaDataSources.get(0);
    }
}

+ 17 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/service/dict/DictService.java

@ -0,0 +1,17 @@
package com.yihu.jw.quota.service.dict;
import com.yihu.jw.quota.dao.jpa.dict.SystemDictDao;
import com.yihu.jw.quota.dao.jpa.dict.SystemDictListDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * Created by chenweida on 2017/6/1.
 */
@Service
public class DictService {
    @Autowired
    private SystemDictDao systemDictDao;
    @Autowired
    private SystemDictListDao systemDictListDao;
}

+ 32 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/service/dimension/TjDimensionMainService.java

@ -0,0 +1,32 @@
package com.yihu.jw.quota.service.dimension;
import com.yihu.jw.quota.model.jpa.dimension.TjQuotaDimensionMain;
import com.yihu.jw.quota.model.jpa.dimension.TjQuotaDimensionSlave;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by chenweida on 2017/6/1.
 */
@Service
public class TjDimensionMainService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public List<TjQuotaDimensionMain> findTjQuotaDimensionMainByQuotaIncudeAddress(String code) {
        String sql = "SELECT " +
                "  qdm.*, dm.type " +
                "FROM " +
                "  tj_dimension_main dm, " +
                "  tj_quota_dimension_main qdm " +
                "WHERE " +
                "  dm.`code` = qdm.main_code " +
                "AND qdm.quota_code = ? and dm.code > 4 and dm.code <10 order by code desc";
        List<TjQuotaDimensionMain> quotaDataSources = jdbcTemplate.query(sql, new BeanPropertyRowMapper(TjQuotaDimensionMain.class), code);
        return quotaDataSources;
    }
}

+ 47 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/service/dimension/TjDimensionSlaveService.java

@ -0,0 +1,47 @@
package com.yihu.jw.quota.service.dimension;
import com.yihu.jw.quota.model.jpa.dimension.TjDimensionSlave;
import com.yihu.jw.quota.model.jpa.dimension.TjQuotaDimensionSlave;
import com.yihu.jw.quota.model.jpa.source.TjQuotaDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by chenweida on 2017/6/1.
 */
@Service
public class TjDimensionSlaveService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public List<TjDimensionSlave> getDimensionSlaveByQuotaCode(String code) {
        String sql = "SELECT " +
                "  dm.* " +
                " FROM " +
                "  tj_dimension_slave dm, " +
                "  tj_quota_dimension_slave qdm " +
                " WHERE " +
                "  dm.`code` = qdm.quota_code " +
                " AND qdm.quota_code = ? ";
        List<TjDimensionSlave> quotaDataSources = jdbcTemplate.query(sql, new BeanPropertyRowMapper(TjDimensionSlave.class), code);
        return quotaDataSources;
    }
    public List<TjQuotaDimensionSlave> findTjQuotaDimensionSlaveByQuotaCode(String code) {
        String sql = "SELECT " +
                "  qdm.*,dm.type " +
                " FROM " +
                "  tj_dimension_slave dm, " +
                "  tj_quota_dimension_slave qdm " +
                " WHERE " +
                "  dm.`code` = qdm.quota_code " +
                " AND qdm.quota_code = ? order BY" +
                " qdm.sort asc ";
        List<TjQuotaDimensionSlave> quotaDataSources = jdbcTemplate.query(sql, new BeanPropertyRowMapper(TjQuotaDimensionSlave.class), code);
        return quotaDataSources;
    }
}

+ 43 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/service/job/JobService.java

@ -0,0 +1,43 @@
package com.yihu.jw.quota.service.job;
import com.yihu.jw.quota.dao.jpa.TjQuotaDao;
import com.yihu.jw.quota.model.jpa.TjQuota;
import com.yihu.jw.quota.util.QuartzHelper;
import com.yihu.jw.quota.vo.QuotaVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * @author chenweida
 */
@Service
public class JobService {
    @Autowired
    private QuartzHelper quartzHelper;
    @Autowired
    private TjQuotaDao quotaDao;
    public void startNowById(String id) throws Exception {
        TjQuota tjQuota= quotaDao.findByCode(id);
        QuotaVO quotaVO =new QuotaVO();
        BeanUtils.copyProperties(tjQuota,quotaVO);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("quota", quotaVO);
        params.put("saasid", "testId");
        //往quartz框架添加任务
        if (!StringUtils.isEmpty(tjQuota.getJobClazz())) {
            quartzHelper.startNow(Class.forName(quotaVO.getJobClazz()),  UUID.randomUUID().toString().replace("-", ""), params);
        }
    }
}

+ 34 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/service/rule/TjCleanRuleService.java

@ -0,0 +1,34 @@
package com.yihu.jw.quota.service.rule;
import com.yihu.jw.quota.model.jpa.dimension.TjDimensionSlave;
import com.yihu.jw.quota.model.jpa.rule.TjQuotaRule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.sql.JDBCType;
import java.util.List;
/**
 * Created by chenweida on 2017/6/1.
 */
@Service
public class TjCleanRuleService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public List<TjQuotaRule> findByQuotaCode(String code) {
        String sql="SELECT " +
                "  qr.*, " +
                "cr.type " +
                "FROM " +
                "  tj_clean_rule cr, " +
                "  tj_quota_rule qr " +
                "WHERE " +
                "  cr.`code`=qr.rule_code " +
                "AND qr.quota_code = ?";
        List<TjQuotaRule> quotaDataSources = jdbcTemplate.query(sql, new BeanPropertyRowMapper(TjQuotaRule.class), code);
        return quotaDataSources;
    }
}

+ 34 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/service/save/TjDataSaveService.java

@ -0,0 +1,34 @@
package com.yihu.jw.quota.service.save;
import com.yihu.jw.quota.model.jpa.save.TjQuotaDataSave;
import com.yihu.jw.quota.model.jpa.source.TjQuotaDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by chenweida on 2017/6/1.
 */
@Service
public class TjDataSaveService {
    @Autowired
    private JdbcTemplate jdbcTmeplate;
    public TjQuotaDataSave findByQuota(String code) {
        String sql = "SELECT " +
                "  qds.*, ds.type " +
                "FROM " +
                "  tj_data_save ds, " +
                "  tj_quota_data_save qds " +
                "WHERE " +
                "  qds.quota_code = ?";
        List<TjQuotaDataSave> quotaDataSources = jdbcTmeplate.query(sql, new BeanPropertyRowMapper(TjQuotaDataSave.class), code);
        if (quotaDataSources.size() > 0) {
            return quotaDataSources.get(0);
        }
        return null;
    }
}

+ 41 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/service/source/TjDataSourceService.java

@ -0,0 +1,41 @@
package com.yihu.jw.quota.service.source;
import com.yihu.jw.quota.dao.jpa.source.TjDataSourceDao;
import com.yihu.jw.quota.dao.jpa.source.TjQuotaDataSourceDao;
import com.yihu.jw.quota.model.jpa.source.TjQuotaDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by chenweida on 2017/6/1.
 */
@Service
public class TjDataSourceService {
    @Autowired
    private TjDataSourceDao dataSourceDao;
    @Autowired
    private TjQuotaDataSourceDao quotaDataSourceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public TjQuotaDataSource findSourceByQuotaCode(String code) {
        String sql = " SELECT " +
                "  qds.*, ds.type " +
                "FROM " +
                "  tj_quota_data_source qds, " +
                "  tj_data_source ds " +
                "WHERE " +
                "  qds.source_code = ds.`code` " +
                "  and " +
                "  qds.quota_code = ?";
        List<TjQuotaDataSource> quotaDataSources = jdbcTemplate.query(sql, new BeanPropertyRowMapper(TjQuotaDataSource.class), code);
        if (quotaDataSources.size() > 0) {
            return quotaDataSources.get(0);
        }
        return null;
    }
}

+ 109 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/util/QuartzHelper.java

@ -0,0 +1,109 @@
package com.yihu.jw.quota.util;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.Map;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
@Component("quartzHelper")
public class QuartzHelper {
    @Autowired
    private SchedulerFactoryBean schedulerFactoryBean;
    private Scheduler scheduler = null;
    @PostConstruct
    public void init() {
        try {
            scheduler = schedulerFactoryBean.getScheduler();
            scheduler.start();
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
    }
    public void addJob(Class jobClass, String cronString, String jobKey,
                       Map<String, Object> params) throws Exception {
        if (!CronExpression.isValidExpression(cronString)) {
            throw new Exception("cronExpression is not a valid Expression");
        }
        try {
            JobDetail job = JobBuilder.newJob(jobClass)
                    .withIdentity("job-id:" + jobKey, "job-group:" + jobKey)
                    .build();
            JobDataMap jobDataMap = job.getJobDataMap();
            jobDataMap.putAll(params);
            CronTrigger trigger = TriggerBuilder
                    .newTrigger()
                    .withIdentity("trigger-name:" + jobKey,
                            "trigger-group:" + jobKey)
                    .withSchedule(CronScheduleBuilder.cronSchedule(cronString))
                    .build();
            scheduler.scheduleJob(job, trigger);
            scheduler.start();
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
    }
    public void removeJob(String jobKeyString) throws Exception {
        TriggerKey triggerKey = new TriggerKey("trigger-name:" + jobKeyString,
                "trigger-group:" + jobKeyString);
        JobKey jobName = new JobKey("job-group:" + jobKeyString, "job-id:"
                + jobKeyString);
        scheduler.pauseTrigger(triggerKey);// 停止触发器
        scheduler.unscheduleJob(triggerKey);// 移除触发器
        scheduler.deleteJob(jobName);// 删除任务
    }
    public boolean isExistJob(String jobKey) throws SchedulerException {
        JobKey jk = new JobKey("job-id:" + jobKey, "job-group:" + jobKey);
        if (scheduler.checkExists(jk)) {
            return true;
        } else {
            return false;
        }
    }
    /**
     * 立即执行任务。
     *
     * @param jobClass
     * @param id
     * @param params
     * @throws Exception
     */
    public void startNow(Class jobClass, String id, Map<String, Object> params) throws Exception {
        startAt(new Date(), jobClass, id, params);
    }
    /**
     * 在指定时间点执行。
     *
     * @param time
     * @param jobClass
     * @param id
     * @param params
     * @throws Exception
     */
    public void startAt(Date time, Class jobClass, String id, Map<String, Object> params) throws Exception {
        JobDetail job = JobBuilder.newJob(jobClass).
                withIdentity("job-id:" + id, "job-group:" + id)
                .build();
        JobDataMap jobDataMap = job.getJobDataMap();
        if(null != params) jobDataMap.putAll(params);
        SimpleTrigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger-id:" + id, "group-group:" + id)
                .startAt(time)
                .withSchedule(simpleSchedule().withIntervalInSeconds(10).withRepeatCount(0).withMisfireHandlingInstructionFireNow())
                .build();
        scheduler.scheduleJob(job, trigger);
        scheduler.start();
    }
}

+ 60 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/util/SpringUtil.java

@ -0,0 +1,60 @@
package com.yihu.jw.quota.util;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class SpringUtil implements ApplicationContextAware {
    private static ApplicationContext applicationContext = null;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        if (SpringUtil.applicationContext == null) {
            SpringUtil.applicationContext = applicationContext;
        }
    }
    //获取applicationContext
    public static ApplicationContext
    getApplicationContext() {
        return applicationContext;
    }
    //通过name获取 Bean.
    public static Object
    getBean(String name) {
        return getApplicationContext().getBean(name);
    }
    //通过class获取Bean.
    public static<T> T getBean(Class<T> clazz) {
        return getApplicationContext().getBean(clazz);
    }
    //通过name,以及Clazz返回指定的Bean
    public static<T> T getBean(String name, Class<T> clazz) {
        return getApplicationContext().getBean(name, clazz);
    }
}

+ 126 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/DataModel.java

@ -0,0 +1,126 @@
package com.yihu.jw.quota.vo;
import com.yihu.jw.quota.etl.Contant;
/**
 * Created by chenweida on 2017/6/1.
 */
public class DataModel {
    private String businessId;//业务id
    private String province;//省级代码 350000
    private String city;//城市代码 350200
    private String town;//区代码 350206
    private String hospital;//机构code
    private String team;//团队的code
    private String slaveKey1;//从维度  1级维度
    private String slaveKey2;//从维度  2级维度
    private String slaveKey3;//从维度  3级维度
    private String slaveKey4;//从维度  4级维度
    public String getBusinessId() {
        return businessId;
    }
    public void setBusinessId(String businessId) {
        this.businessId = businessId;
    }
    public String getTeam() {
        return team;
    }
    public void setTeam(String team) {
        this.team = team;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
    public String getCity() {
        return city;
    }
    public void setCity(String city) {
        this.city = city;
    }
    public String getSlaveKey1() {
        return slaveKey1;
    }
    public void setSlaveKey1(String slaveKey1) {
        this.slaveKey1 = slaveKey1;
    }
    public String getSlaveKey2() {
        return slaveKey2;
    }
    public void setSlaveKey2(String slaveKey2) {
        this.slaveKey2 = slaveKey2;
    }
    public String getSlaveKey3() {
        return slaveKey3;
    }
    public void setSlaveKey3(String slaveKey3) {
        this.slaveKey3 = slaveKey3;
    }
    public String getSlaveKey4() {
        return slaveKey4;
    }
    public void setSlaveKey4(String slaveKey4) {
        this.slaveKey4 = slaveKey4;
    }
    public String getProvince() {
        return province;
    }
    public void setProvince(String province) {
        this.province = province;
    }
    public String getKey(String leveltype){
        switch (leveltype){
            case Contant.main_dimension_areaLevel.area_province:{return getProvince();}
            case Contant.main_dimension_areaLevel.area_city:{return getCity();}
            case Contant.main_dimension_areaLevel.area_town:{return getTown();}
            case Contant.main_dimension_areaLevel.area_org:{return getHospital();}
            case Contant.main_dimension_areaLevel.area_team:{return getTeam();}
        }
        return "";
    }
    @Override
    public String toString() {
        return "DataModel{" +
                "businessId='" + businessId + '\'' +
                ", province='" + province + '\'' +
                ", city='" + city + '\'' +
                ", town='" + town + '\'' +
                ", hospital='" + hospital + '\'' +
                ", team='" + team + '\'' +
                ", slaveKey1='" + slaveKey1 + '\'' +
                ", slaveKey2='" + slaveKey2 + '\'' +
                ", slaveKey3='" + slaveKey3 + '\'' +
                ", slaveKey4='" + slaveKey4 + '\'' +
                '}';
    }
}

+ 25 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/DictModel.java

@ -0,0 +1,25 @@
package com.yihu.jw.quota.vo;
/**
 * Created by chenweida on 2017/6/1.
 */
public class DictModel {
    private String code;//key
    private String name;//名称
    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;
    }
}

+ 30 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/ErrModel.java

@ -0,0 +1,30 @@
package com.yihu.jw.quota.vo;
/**
 * Created by chenweida on 2017/6/1.
 */
public class ErrModel {
    private String businessId;
    private String message;
    public ErrModel(String businessId, String message) {
        this.businessId = businessId;
        this.message = message;
    }
    public String getBusinessId() {
        return businessId;
    }
    public void setBusinessId(String businessId) {
        this.businessId = businessId;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
}

+ 33 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/FilterModel.java

@ -0,0 +1,33 @@
package com.yihu.jw.quota.vo;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/6/1.
 */
public class FilterModel {
    private Object data;//可能是list 也可能是map
    private List<ErrModel> ErrorModels =new ArrayList<>();
    public FilterModel(Object data) {
        this.data = data;
    }
    public FilterModel() {
    }
    public Object getData() {
        return data;
    }
    public void setData(Object data) {
        this.data = data;
    }
    public List<ErrModel> getErrorModels() {
        return ErrorModels;
    }
    public void setErrorModels(List<ErrModel> ErrorModels) {
        this.ErrorModels = ErrorModels;
    }
}

+ 19 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/JobLogModel.java

@ -0,0 +1,19 @@
package com.yihu.jw.quota.vo;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/6/2.
 */
public class JobLogModel {
    private List<ErrModel> ErrorModels =new ArrayList<>();
    public List<ErrModel> getErrorModels() {
        return ErrorModels;
    }
    public void setErrorModels(List<ErrModel> errorModels) {
        ErrorModels = errorModels;
    }
}

+ 202 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/MainDimensionModel.java

@ -0,0 +1,202 @@
package com.yihu.jw.quota.vo;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/6/1.
 */
public class MainDimensionModel {
    private String quotaCode;//指标code
    private String province;//省级代码 350000
    private String provinceName;//省名字
    private String city;//城市代码 350200
    private String cityName;//
    private String town;//区代码 350206
    private String townName;//
    private String hospital;//机构code
    private String hospitalName;//
    private String team;//团队的code
    private String teamName;//
    private String areaLevel;// 1 省 2 市 3 区县 4 机构 5团队
    //用来计算从维度的字段--------------
    private String slaveKey1;//从维度  1级维度
    private String slaveKey1Name;
    private String slaveKey2;//从维度  2级维度
    private String slaveKey2Name;
    private String slaveKey3;//从维度  3级维度
    private String slaveKey3Name;
    private String slaveKey4;//从维度  4级维度
    private String slaveKey4Name;
    //用来计算从维度的字段--------------
    List<SlaveDimensionModel> slaveDimensionModels=new ArrayList<>();
    public String getAreaLevel() {
        return areaLevel;
    }
    public void setAreaLevel(String areaLevel) {
        this.areaLevel = areaLevel;
    }
    public String getQuotaCode() {
        return quotaCode;
    }
    public void setQuotaCode(String quotaCode) {
        this.quotaCode = quotaCode;
    }
    public String getProvince() {
        return province;
    }
    public void setProvince(String province) {
        this.province = province;
    }
    public String getProvinceName() {
        return provinceName;
    }
    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }
    public String getCity() {
        return city;
    }
    public void setCity(String city) {
        this.city = city;
    }
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getTeam() {
        return team;
    }
    public void setTeam(String team) {
        this.team = team;
    }
    public String getTeamName() {
        return teamName;
    }
    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }
    public List<SlaveDimensionModel> getSlaveDimensionModels() {
        return slaveDimensionModels;
    }
    public void setSlaveDimensionModels(List<SlaveDimensionModel> slaveDimensionModels) {
        this.slaveDimensionModels = slaveDimensionModels;
    }
    public String getSlaveKey1() {
        return slaveKey1;
    }
    public void setSlaveKey1(String slaveKey1) {
        this.slaveKey1 = slaveKey1;
    }
    public String getSlaveKey1Name() {
        return slaveKey1Name;
    }
    public void setSlaveKey1Name(String slaveKey1Name) {
        this.slaveKey1Name = slaveKey1Name;
    }
    public String getSlaveKey2() {
        return slaveKey2;
    }
    public void setSlaveKey2(String slaveKey2) {
        this.slaveKey2 = slaveKey2;
    }
    public String getSlaveKey2Name() {
        return slaveKey2Name;
    }
    public void setSlaveKey2Name(String slaveKey2Name) {
        this.slaveKey2Name = slaveKey2Name;
    }
    public String getSlaveKey3() {
        return slaveKey3;
    }
    public void setSlaveKey3(String slaveKey3) {
        this.slaveKey3 = slaveKey3;
    }
    public String getSlaveKey3Name() {
        return slaveKey3Name;
    }
    public void setSlaveKey3Name(String slaveKey3Name) {
        this.slaveKey3Name = slaveKey3Name;
    }
    public String getSlaveKey4() {
        return slaveKey4;
    }
    public void setSlaveKey4(String slaveKey4) {
        this.slaveKey4 = slaveKey4;
    }
    public String getSlaveKey4Name() {
        return slaveKey4Name;
    }
    public void setSlaveKey4Name(String slaveKey4Name) {
        this.slaveKey4Name = slaveKey4Name;
    }
}

+ 157 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/QuotaVo.java

@ -0,0 +1,157 @@
package com.yihu.jw.quota.vo;
import java.io.Serializable;
import java.util.Date;
/**
 * Created by chenweida on 2017/6/1.
 */
public class QuotaVO implements Serializable{
    private Integer id;
    private String code;
    private String compute;
    private String computeType;//计算类型
    private String name;
    private String jobClazz;
    private Date createTime;
    private String createUser;
    private String createUserName;
    private Date updateTime;
    private String updateUser;
    private String updateUserName;
    private String del;
    private String remark;
    public Integer getId() {
        return id;
    }
    public void setId(Integer 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 getJobClazz() {
        return jobClazz;
    }
    public void setJobClazz(String jobClazz) {
        this.jobClazz = jobClazz;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getUpdateUser() {
        return updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    public String getUpdateUserName() {
        return updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getComputeType() {
        return computeType;
    }
    public void setComputeType(String computeType) {
        this.computeType = computeType;
    }
    public String getCompute() {
        return compute;
    }
    public void setCompute(String compute) {
        this.compute = compute;
    }
    @Override
    public String toString() {
        return "QuotaVO{" +
                "id=" + id +
                ", code='" + code + '\'' +
                ", compute='" + compute + '\'' +
                ", computeType='" + computeType + '\'' +
                ", name='" + name + '\'' +
                ", jobClazz='" + jobClazz + '\'' +
                ", createTime=" + createTime +
                ", createUser='" + createUser + '\'' +
                ", createUserName='" + createUserName + '\'' +
                ", updateTime=" + updateTime +
                ", updateUser='" + updateUser + '\'' +
                ", updateUserName='" + updateUserName + '\'' +
                ", del='" + del + '\'' +
                ", remark='" + remark + '\'' +
                '}';
    }
}

+ 302 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/SaveModel.java

@ -0,0 +1,302 @@
package com.yihu.jw.quota.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import java.util.Date;
/**
 * Created by chenweida on 2017/6/1.
 */
@Document(indexName = "index_sex", type = "sex", shards = 2)
public class SaveModel {
    @Id
    private String id;
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String saasId;//saasId
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String quotaCode;//指标code
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String quotaDate;//统计时间
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String province;//省级代码 350000
    @Field(type = FieldType.String, index = FieldIndex.analyzed)
    private String provinceName;//省名字
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String city;//城市代码 350200
    @Field(type = FieldType.String, index = FieldIndex.analyzed)
    private String cityName;//
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String town;//区代码 350206
    @Field(type = FieldType.String, index = FieldIndex.analyzed)
    private String townName;//
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String hospital;//机构code
    @Field(type = FieldType.String, index = FieldIndex.analyzed)
    private String hospitalName;//
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String team;//团队的code
    @Field(type = FieldType.String, index = FieldIndex.analyzed)
    private String teamName;//
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String slaveKey1;//从维度  1级维度
    @Field(type = FieldType.String, index = FieldIndex.analyzed)
    private String slaveKey1Name;
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String slaveKey2;//从维度  2级维度
    @Field(type = FieldType.String, index = FieldIndex.analyzed)
    private String slaveKey2Name;
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String slaveKey3;//从维度  3级维度
    @Field(type = FieldType.String, index = FieldIndex.analyzed)
    private String slaveKey3Name;
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String slaveKey4;//从维度  4级维度
    @Field(type = FieldType.String, index = FieldIndex.analyzed)
    private String slaveKey4Name;
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String result;//统计结果
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String timeLevel;// 1 日 2 周 3 月 4 年
    @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
    private String areaLevel;// 1 省 2 市 3 区县 4 机构 5团队
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyyMMdd'T'HHmmss.SSS'Z'")
    @Field(type = FieldType.Date, format = DateFormat.basic_date_time, index = FieldIndex.not_analyzed)
    @CreatedDate
    private Date createTime;//创建时间
    public String getQuotaDate() {
        return quotaDate;
    }
    public void setQuotaDate(String quotaDate) {
        this.quotaDate = quotaDate;
    }
    public String getProvince() {
        return province;
    }
    public void setProvince(String province) {
        this.province = province;
    }
    public String getCity() {
        return city;
    }
    public void setCity(String city) {
        this.city = city;
    }
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getTeam() {
        return team;
    }
    public void setTeam(String team) {
        this.team = team;
    }
    public String getSlaveKey1() {
        return slaveKey1;
    }
    public void setSlaveKey1(String slaveKey1) {
        this.slaveKey1 = slaveKey1;
    }
    public String getSlaveKey2() {
        return slaveKey2;
    }
    public void setSlaveKey2(String slaveKey2) {
        this.slaveKey2 = slaveKey2;
    }
    public String getSlaveKey3() {
        return slaveKey3;
    }
    public void setSlaveKey3(String slaveKey3) {
        this.slaveKey3 = slaveKey3;
    }
    public String getSlaveKey4() {
        return slaveKey4;
    }
    public void setSlaveKey4(String slaveKey4) {
        this.slaveKey4 = slaveKey4;
    }
    public String getResult() {
        return result;
    }
    public void setResult(String result) {
        this.result = result;
    }
    public String getSlaveKey1Name() {
        return slaveKey1Name;
    }
    public void setSlaveKey1Name(String slaveKey1Name) {
        this.slaveKey1Name = slaveKey1Name;
    }
    public String getSlaveKey2Name() {
        return slaveKey2Name;
    }
    public void setSlaveKey2Name(String slaveKey2Name) {
        this.slaveKey2Name = slaveKey2Name;
    }
    public String getSlaveKey3Name() {
        return slaveKey3Name;
    }
    public void setSlaveKey3Name(String slaveKey3Name) {
        this.slaveKey3Name = slaveKey3Name;
    }
    public String getSlaveKey4Name() {
        return slaveKey4Name;
    }
    public void setSlaveKey4Name(String slaveKey4Name) {
        this.slaveKey4Name = slaveKey4Name;
    }
    public String getProvinceName() {
        return provinceName;
    }
    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getTeamName() {
        return teamName;
    }
    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }
    public String getQuotaCode() {
        return quotaCode;
    }
    public void setQuotaCode(String quotaCode) {
        this.quotaCode = quotaCode;
    }
    public String getTimeLevel() {
        return timeLevel;
    }
    public void setTimeLevel(String timeLevel) {
        this.timeLevel = timeLevel;
    }
    public String getAreaLevel() {
        return areaLevel;
    }
    public void setAreaLevel(String areaLevel) {
        this.areaLevel = areaLevel;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
}

+ 89 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/vo/SlaveDimensionModel.java

@ -0,0 +1,89 @@
package com.yihu.jw.quota.vo;
/**
 * Created by chenweida on 2017/6/1.
 */
public class SlaveDimensionModel {
    private String slaveKey1;//从维度  1级维度
    private String slaveKey1Name;
    private String slaveKey2;//从维度  2级维度
    private String slaveKey2Name;
    private String slaveKey3;//从维度  3级维度
    private String slaveKey3Name;
    private String slaveKey4;//从维度  4级维度
    private String slaveKey4Name;
    public SlaveDimensionModel() {
    }
    public SlaveDimensionModel(String slaveKey1, String slaveKey2, String slaveKey3, String slaveKey4) {
        this.slaveKey1 = slaveKey1;
        this.slaveKey2 = slaveKey2;
        this.slaveKey3 = slaveKey3;
        this.slaveKey4 = slaveKey4;
    }
    public String getSlaveKey1() {
        return slaveKey1;
    }
    public void setSlaveKey1(String slaveKey1) {
        this.slaveKey1 = slaveKey1;
    }
    public String getSlaveKey1Name() {
        return slaveKey1Name;
    }
    public void setSlaveKey1Name(String slaveKey1Name) {
        this.slaveKey1Name = slaveKey1Name;
    }
    public String getSlaveKey2() {
        return slaveKey2;
    }
    public void setSlaveKey2(String slaveKey2) {
        this.slaveKey2 = slaveKey2;
    }
    public String getSlaveKey2Name() {
        return slaveKey2Name;
    }
    public void setSlaveKey2Name(String slaveKey2Name) {
        this.slaveKey2Name = slaveKey2Name;
    }
    public String getSlaveKey3() {
        return slaveKey3;
    }
    public void setSlaveKey3(String slaveKey3) {
        this.slaveKey3 = slaveKey3;
    }
    public String getSlaveKey3Name() {
        return slaveKey3Name;
    }
    public void setSlaveKey3Name(String slaveKey3Name) {
        this.slaveKey3Name = slaveKey3Name;
    }
    public String getSlaveKey4() {
        return slaveKey4;
    }
    public void setSlaveKey4(String slaveKey4) {
        this.slaveKey4 = slaveKey4;
    }
    public String getSlaveKey4Name() {
        return slaveKey4Name;
    }
    public void setSlaveKey4Name(String slaveKey4Name) {
        this.slaveKey4Name = slaveKey4Name;
    }
}

+ 41 - 0
svr/svr-quota/src/main/resources/quartz.properties

@ -0,0 +1,41 @@
# Default Properties file for use by StdSchedulerFactory
# to create a Quartz Scheduler Instance, if a different
# properties file is not explicitly specified.
#
 
org.quartz.scheduler.instanceName: DefaultQuartzScheduler
org.quartz.scheduler.rmi.export: false
org.quartz.scheduler.rmi.proxy: false
org.quartz.scheduler.wrapJobExecutionInUserTransaction: false
 
org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 20
org.quartz.threadPool.threadPriority: 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true
 
org.quartz.jobStore.misfireThreshold: 60000
 
#============================================================================
# Configure JobStore
#============================================================================
 
# RAM
# org.quartz.jobStore.class: org.quartz.simpl.RAMJobStore
# Configure JobStore Cluster
org.quartz.jobStore.class:org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass:org.quartz.impl.jdbcjobstore.StdJDBCDelegate
#datasource׺
org.quartz.jobStore.tablePrefix:QRTZ_
#org.quartz.jobStore.dataSource:qzDS
#
##============================================================================
## Configure Datasources
##============================================================================
##datasource
#org.quartz.dataSource.qzDS.driver: com.mysql.jdbc.Driver
#org.quartz.dataSource.qzDS.URL: jdbc:mysql://172.19.103.85/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#org.quartz.dataSource.qzDS.user: root
#org.quartz.dataSource.qzDS.password: 123456
org.quartz.jobGroupName = RS_JOBGROUP_NAME
org.quartz.triggerGroupName = RS_TRIGGERGROUP_NAME