LiTaohong пре 7 година
родитељ
комит
99aa4c4ef4
26 измењених фајлова са 451 додато и 231 уклоњено
  1. 21 2
      common/common-entity/src/main/java/com/yihu/figure_label/entity/FLJobConfig.java
  2. 3 2
      common/common-entity/src/main/java/com/yihu/figure_label/entity/FLlabelDict.java
  3. 3 2
      common/common-entity/src/main/java/com/yihu/figure_label/entity/FLlabelDictJob.java
  4. 2 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/controller/JobController.java
  5. 19 3
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/AgeConvert.java
  6. 22 7
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/BirthConvert.java
  7. 2 3
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/Convert.java
  8. 88 53
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ConvertHelper.java
  9. 2 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/HealthConditionConvert.java
  10. 14 3
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsOnlineConvert.java
  11. 19 4
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SexConvert.java
  12. 14 3
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SignStateConvert.java
  13. 10 8
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FLLabelDictDao.java
  14. 0 29
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FLLabelDictJobDao.java
  15. 16 13
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FLJobConfigDao.java
  16. 30 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FlLabelDictJobDao.java
  17. 11 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/enums/SourceTypeEnum.java
  18. 1 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/Extracter.java
  19. 4 8
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/MysqlExtracter.java
  20. 24 16
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Mysql2ESJob.java
  21. 46 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/model/DataModel.java
  22. 13 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/model/SaveModel.java
  23. 84 68
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/service/JobService.java
  24. 1 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Storager.java
  25. 1 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Store2ES.java
  26. 1 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Store2Hbase.java

+ 21 - 2
common/common-entity/src/main/java/com/yihu/figure_label/entity/FLJobConfig.java

@ -7,12 +7,13 @@ import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by lith on 2018/03/07.
 * @author lith on 2018.03.07
 *
 */
@Entity
@Table(name = "fl_job_config")
public class FLJobConfig extends IdEntity {
public class FlJobConfig extends IdEntity {
    private String jobName;
    private String jobClass;
    private String sql;
@ -22,6 +23,8 @@ public class FLJobConfig extends IdEntity {
    private String quartzCron;
    private String status;
    private String del;
    private String sourceType;
    private String source;
    public String getJobName() {
        return jobName;
@ -94,4 +97,20 @@ public class FLJobConfig extends IdEntity {
    public void setDel(String del) {
        this.del = del;
    }
    public String getSourceType() {
        return sourceType;
    }
    public void setSourceType(String sourceType) {
        this.sourceType = sourceType;
    }
    public String getSource() {
        return source;
    }
    public void setSource(String source) {
        this.source = source;
    }
}

+ 3 - 2
common/common-entity/src/main/java/com/yihu/figure_label/entity/FLlabelDict.java

@ -7,12 +7,13 @@ import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by lith on 2018/03/07.
 * @author lith on 2018.03.07
 *
 */
@Entity
@Table(name = "fl_label_dict")
public class FLlabelDict extends IdEntity {
public class FlLabelDict extends IdEntity {
    private String parentCode;
    private String labelName;
    private String labelCode;

+ 3 - 2
common/common-entity/src/main/java/com/yihu/figure_label/entity/FLlabelDictJob.java

@ -7,12 +7,13 @@ import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by lith on 2018/03/07.
 * @author lith on 2018.03.07
 *
 */
@Entity
@Table(name = "fl_label_dict_job")
public class FLlabelDictJob extends IdEntity {
public class FlLabelDictJob extends IdEntity {
    private Long jobId;
    private String labelType;
    private String sql;

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

@ -14,7 +14,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * 启动job
 * @author lith on 2018.03.14
 * 定时任务控制器
 */
@RestController
@RequestMapping(value = "/job", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)

+ 19 - 3
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/AgeConvert.java

@ -1,27 +1,37 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.figure_label.entity.FLlabelDict;
import com.yihu.figure_label.entity.FlLabelDict;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import com.yihu.wlyy.figure.label.util.IdCardUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
/**
 * @author lith on 2018.03.14
 * 年龄标签转换器
 */
@Component
public class AgeConvert implements Convert {
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> models,List<FLlabelDict> flLabelDictList) {
    public List<SaveModel> convert(List<DataModel> models,List<FlLabelDict> flLabelDictList,String sourceType,String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        if(CollectionUtils.isEmpty(flLabelDictList)){
            return saveModels;
        }
        FLlabelDict one = flLabelDictList.get(0);
        FlLabelDict one = flLabelDictList.get(0);
        Map<String,String> map = new HashMap<>();
        flLabelDictList.forEach(
@ -39,6 +49,12 @@ public class AgeConvert implements Convert {
                    saveModel.setLabelCode(labelCode);
                    saveModel.setLabeName(map.get(labelCode));
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
                    convertHelper.generateDataSource(model,saveModel,sourceType,source);
                    //如果fl_job_config表配置的id和数据来源不一致,则不保存数据
                    if(StringUtils.isEmpty(saveModel.getSource())){
                        return;
                    }
                    saveModels.add(saveModel);
                }
        );

+ 22 - 7
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/BirthConvert.java

@ -1,26 +1,35 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.figure_label.entity.FLlabelDict;
import com.yihu.figure_label.entity.FlLabelDict;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import com.yihu.wlyy.figure.label.util.IdCardUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * @author lith on 2018.03.14
 * 生日标签转换器
 */
public class BirthConvert implements Convert {
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> models,List<FLlabelDict> flLabelDictList) {
    public List<SaveModel> convert(List<DataModel> models,List<FlLabelDict> flLabelDictList,String sourceType,String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        if(CollectionUtils.isEmpty(flLabelDictList)){
            return saveModels;
        }
        FLlabelDict fLlabelDict = flLabelDictList.get(0);
        FlLabelDict flLabelDict = flLabelDictList.get(0);
        models.forEach(
                model -> {
                    String birth = null;
@ -32,11 +41,17 @@ public class BirthConvert implements Convert {
                    SaveModel saveModel = new SaveModel();
                    saveModel.setId(MakeIDUtil.makeSaveModelID(model,birth));
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setLabelCode(fLlabelDict.getLabelCode());
                    saveModel.setLabelType(fLlabelDict.getParentCode());
                    saveModel.setLabeName(fLlabelDict.getLabelName());
                    saveModel.setLabelCode(flLabelDict.getLabelCode());
                    saveModel.setLabelType(flLabelDict.getParentCode());
                    saveModel.setLabeName(flLabelDict.getLabelName());
                    saveModel.setLabelValue(birth);
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
                    convertHelper.generateDataSource(model,saveModel,sourceType,source);
                    //如果fl_job_config表配置的id和数据来源不一致,则不保存数据
                    if(StringUtils.isEmpty(saveModel.getSource())){
                        return;
                    }
                    saveModels.add(saveModel);
                }
        );

+ 2 - 3
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/Convert.java

@ -1,7 +1,6 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.figure_label.entity.FLlabelDict;
import com.yihu.figure_label.entity.FLlabelDictJob;
import com.yihu.figure_label.entity.FlLabelDict;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
@ -13,5 +12,5 @@ import java.util.List;
 */
public interface Convert {
    List<SaveModel> convert(List<DataModel> modelList,List<FLlabelDict> flLabelDictList);
    List<SaveModel> convert(List<DataModel> modelList,List<FlLabelDict> flLabelDictList,String sourceType,String source);
}

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

@ -1,11 +1,13 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.figure_label.entity.FLlabelDict;
import com.yihu.figure_label.entity.FLlabelDictJob;
import com.yihu.figure_label.entity.FlLabelDict;
import com.yihu.figure_label.entity.FlLabelDictJob;
import com.yihu.wlyy.figure.label.dao.FLLabelDictDao;
import com.yihu.wlyy.figure.label.enums.SourceTypeEnum;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -22,7 +24,7 @@ import java.util.Date;
import java.util.List;
/**
 * Created by chenweida on 2017/6/5.
 * @author lith on 2018.03.14
 * 维度的key值转换器
 */
@Component
@ -32,68 +34,101 @@ public class ConvertHelper {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private FLLabelDictDao flLabelDictDao;
    /**
     * 进行具体标签生成转换
     * @return
     * @throws Exception
     */
    public List<SaveModel> convert(List<DataModel> dataModels, FLlabelDictJob fLlabelDictJob) throws Exception {
    public List<SaveModel> convert(List<DataModel> dataModels, FlLabelDictJob flLabelDictJob,String sourceType,String source) throws Exception {
        List<SaveModel> saveModels = new ArrayList<>();
            //不需要转换
            if(fLlabelDictJob==null || StringUtils.isEmpty(fLlabelDictJob.getConvertClazz()) || StringUtils.isEmpty(fLlabelDictJob.getSql())){
                return generateSaveModleWithOutConvert(dataModels);
            }
            List<FLlabelDict> flLabelDictList = jdbcTemplate.query(fLlabelDictJob.getSql(),new BeanPropertyRowMapper(FLlabelDict.class));
            try {
                Object obj = Class.forName(fLlabelDictJob.getConvertClazz()).newInstance();
                Method method = obj.getClass().getMethod("convert",List.class,List.class);
                saveModels = (List<SaveModel>)method.invoke(obj,dataModels,flLabelDictList);
            } catch (Exception e) {
                logger.error("customized class or convert(List<DataModel> modelList,List<FLlabelDict> flLabelDictList) method not found:" + fLlabelDictJob.getConvertClazz());
                return saveModels;
            }
        //不需要转换
        if (flLabelDictJob == null || StringUtils.isEmpty(flLabelDictJob.getConvertClazz()) || StringUtils.isEmpty(flLabelDictJob.getSql())) {
            return generateSaveModleWithOutConvert(dataModels,sourceType,source);
        }
        List<FlLabelDict> flLabelDictList = jdbcTemplate.query(flLabelDictJob.getSql(), new BeanPropertyRowMapper(FlLabelDict.class));
        try {
            Object obj = Class.forName(flLabelDictJob.getConvertClazz()).newInstance();
            Method method = obj.getClass().getMethod("convert", List.class, List.class);
            saveModels = (List<SaveModel>) method.invoke(obj, dataModels, flLabelDictList);
        } catch (Exception e) {
            logger.error("customized class or convert(List<DataModel> modelList,List<FlLabelDict> flLabelDictList) method not found:" + flLabelDictJob.getConvertClazz());
            return saveModels;
        }
        return saveModels;
    }
    public List<SaveModel> generateSaveModleWithOutConvert(List<DataModel> dataModels){
    /**
     * 无需转换器直接转换,此种情况为源数据已经分类好标签
     * @param dataModels
     * @param sourceType
     * @param source
     * @return
     */
    public List<SaveModel> generateSaveModleWithOutConvert(List<DataModel> dataModels,String sourceType,String source){
        List<SaveModel> saveModels = new ArrayList<>();
        dataModels.forEach(
                dataModel -> {
                    SaveModel saveModel = new SaveModel();
                    saveModel.setIdcard(dataModel.getIdcard());
                    saveModel.setModelId(MakeModelIDUtil.makeModelID(dataModel,""));
                    saveModel.setLabelType(dataModel.getParentCode());
                    saveModel.setLabelCode(dataModel.getLabelCode());
                    saveModel.setLabeName(dataModel.getLabelName());
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
                    saveModels.add(saveModel);
                }
        );
        //lambda无法跳出循环
        for(DataModel dataModel:dataModels){
            SaveModel saveModel = new SaveModel();
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setId(MakeIDUtil.makeSaveModelID(dataModel,""));
            saveModel.setLabelType(dataModel.getParentCode());
            saveModel.setLabelCode(dataModel.getLabelCode());
            saveModel.setLabeName(dataModel.getLabelName());
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            this.generateDataSource(dataModel,saveModel,sourceType,source);
            //如果fl_job_config表配置的id和数据来源不一致,则不保存数据,原子性,全部不保存,不然部分存了部分没存不好剔除数据
            if(StringUtils.isEmpty(saveModel.getSource())){
                return new ArrayList<>();
            }
            saveModels.add(saveModel);
        }
        return saveModels;
    }
    /**
     * 生成数据来源
     * @param dataModel
     * @param saveModel
     * @param sourceType
     * @param sources
     * @return
     */
    public void generateDataSource(DataModel dataModel,SaveModel saveModel,String sourceType,String sources) {
        if(!StringUtils.endsWithIgnoreCase(SourceTypeEnum.MYSQL.toString(),sourceType)){
            return;
        }
        StringBuilder ids = new StringBuilder();
        // 默认值为0
        if(dataModel.getId() != 0){
            ids.append(dataModel.getId()).append(",");
        }
        if(dataModel.getId1() != 0){
            ids.append(dataModel.getId1()).append(",");
        }
        if(dataModel.getId2() != 0){
            ids.append(dataModel.getId2()).append(",");
        }
        if(dataModel.getId3() != 0){
            ids.append(dataModel.getId3()).append(",");
        }
        if(dataModel.getId4() != 0){
            ids.append(dataModel.getId4());
        }
        String[] idArr = ids.toString().split(",");
        String[]sourceArr = sources.split(",");
        if(idArr.length != sourceArr.length){
            logger.error("number of id is not compatible with table's setted in fl_job_config[sql,source],model do not save!");
            return;
        }
        StringBuilder source = new StringBuilder();
        for(int i = 0; i < idArr.length;i++){
            source.append(sourceType).append(".").append(sourceArr[i]).append(".").append(idArr[i]);
            if(i != idArr.length -1){
                source.append(",");
            }
        }
        saveModel.setSource(source.toString());
        return ;
    }
}

+ 2 - 2
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/HealthConditionConvert.java

@ -1,6 +1,6 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.figure_label.entity.FLlabelDict;
import com.yihu.figure_label.entity.FlLabelDict;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
@ -8,7 +8,7 @@ import java.util.List;
public class HealthConditionConvert implements Convert {
    @Override
    public List<SaveModel> convert(List<DataModel> models,List<FLlabelDict> flLabelDictList) {
    public List<SaveModel> convert(List<DataModel> models,List<FlLabelDict> flLabelDictList,String sourceType,String source) {
        return null;
    }
}

+ 14 - 3
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsOnlineConvert.java

@ -1,13 +1,15 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.figure_label.entity.FLlabelDict;
import com.yihu.figure_label.entity.FlLabelDict;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
@ -18,13 +20,16 @@ import java.util.*;
@Component
public class IsOnlineConvert implements Convert {
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> models,List<FLlabelDict> flLabelDictList) {
    public List<SaveModel> convert(List<DataModel> models,List<FlLabelDict> flLabelDictList,String sourceType,String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        if(CollectionUtils.isEmpty(flLabelDictList)){
            return saveModels;
        }
        FLlabelDict one = flLabelDictList.get(0);
        FlLabelDict one = flLabelDictList.get(0);
        Map<String,String> map = new HashMap<>();
        flLabelDictList.forEach(
                fLlabelDict -> {
@ -40,6 +45,12 @@ public class IsOnlineConvert implements Convert {
                    saveModel.setLabelCode(model.getLabelCode());
                    saveModel.setLabeName(map.get(model.getLabelCode()));
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
                    convertHelper.generateDataSource(model,saveModel,sourceType,source);
                    //如果fl_job_config表配置的id和数据来源不一致,则不保存数据
                    if(StringUtils.isEmpty(saveModel.getSource())){
                        return;
                    }
                    saveModels.add(saveModel);
                }
        );

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

@ -1,20 +1,29 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.figure_label.entity.FLlabelDict;
import com.yihu.figure_label.entity.FlLabelDict;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import com.yihu.wlyy.figure.label.util.IdCardUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import java.util.*;
/**
 * @author lith on 2018.03.14
 * 性别标签转换器
 */
public class SexConvert implements Convert{
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> models,List<FLlabelDict> flLabelDictList) {
    public List<SaveModel> convert(List<DataModel> models,List<FlLabelDict> flLabelDictList,String sourceType,String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FLlabelDict one = flLabelDictList.get(0);
        FlLabelDict one = flLabelDictList.get(0);
        Map<String,String> map = new HashMap<>();
        flLabelDictList.forEach(
                fLlabelDict -> {
@ -30,6 +39,12 @@ public class SexConvert implements Convert{
                    saveModel.setLabelCode(sex);
                    saveModel.setLabeName(map.get(sex));
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
                    convertHelper.generateDataSource(model,saveModel,sourceType,source);
                    //如果fl_job_config表配置的id和数据来源不一致,则不保存数据
                    if(StringUtils.isEmpty(saveModel.getSource())){
                        return;
                    }
                    saveModels.add(saveModel);
                }
        );

+ 14 - 3
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SignStateConvert.java

@ -1,12 +1,14 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.figure_label.entity.FLlabelDict;
import com.yihu.figure_label.entity.FlLabelDict;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
@ -15,13 +17,17 @@ import java.util.*;
 * 2018-03-21
 */
public class SignStateConvert implements Convert{
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> models,List<FLlabelDict> flLabelDictList) {
    public List<SaveModel> convert(List<DataModel> models,List<FlLabelDict> flLabelDictList,String sourceType,String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        if(CollectionUtils.isEmpty(flLabelDictList)){
            return saveModels;
        }
        FLlabelDict one = flLabelDictList.get(0);
        FlLabelDict one = flLabelDictList.get(0);
        Map<String,String> map = new HashMap<>();
        flLabelDictList.forEach(
                fLlabelDict -> {
@ -37,6 +43,11 @@ public class SignStateConvert implements Convert{
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabeName(map.get(model.getLabelCode()));
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
                    convertHelper.generateDataSource(model,saveModel,sourceType,source);
                    //如果fl_job_config表配置的id和数据来源不一致,则不保存数据
                    if(StringUtils.isEmpty(saveModel.getSource())){
                        return;
                    }
                    saveModels.add(saveModel);
                }
        );

+ 10 - 8
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FLLabelDictDao.java

@ -1,21 +1,23 @@
package com.yihu.wlyy.figure.label.dao;
import com.yihu.figure_label.entity.FLlabelDict;
import com.yihu.figure_label.entity.FlLabelDict;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface FLLabelDictDao extends PagingAndSortingRepository<FLlabelDict, String>, JpaSpecificationExecutor<FLlabelDict> {
/**
 * @author lith on 2018.03.14
 * 标签字典
 */
public interface FLLabelDictDao extends PagingAndSortingRepository<FlLabelDict, String>, JpaSpecificationExecutor<FlLabelDict> {
    /**
     * 根据父类标签查询字典信息
     * @param parentCode
     * @return
     */
    @Query(" FROM FLlabelDict a WHERE a.parentCode=?1")
    FLlabelDict findByParentCode(String parentCode);
    @Query(" FROM FlLabelDict a WHERE a.parentCode=?1")
    FlLabelDict findByParentCode(String parentCode);
    /**
     * 根据父类code和标签code查询标签字典信息
@ -23,7 +25,7 @@ public interface FLLabelDictDao extends PagingAndSortingRepository<FLlabelDict,
     * @param labelCode
     * @return
     */
    @Query(" FROM FLlabelDict a WHERE a.parentCode=?1 and labelCode = ?2")
    FLlabelDict findByParentCodeAndLabelCode(String parentCode,String labelCode);
    @Query(" FROM FlLabelDict a WHERE a.parentCode=?1 and labelCode = ?2")
    FlLabelDict findByParentCodeAndLabelCode(String parentCode, String labelCode);
}

+ 0 - 29
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FLLabelDictJobDao.java

@ -1,29 +0,0 @@
package com.yihu.wlyy.figure.label.dao;
import com.yihu.figure_label.entity.FLlabelDictJob;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface FLLabelDictJobDao extends PagingAndSortingRepository<FLlabelDictJob, String>, JpaSpecificationExecutor<FLlabelDictJob> {
    /**
     * 根据jobId查询
     * @param jobId
     * @return
     */
    @Query(" FROM FLlabelDictJob a WHERE a.jobId=?1")
    FLlabelDictJob findByJobId(Long jobId);
    /**
     * 根据标签类型查询
     * @param type
     * @return
     */
    @Query(" FROM FLlabelDictJob a WHERE a.labelType=?1")
    FLlabelDictJob findByLabelType(String type);
}

+ 16 - 13
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FLJobConfigDao.java

@ -1,14 +1,17 @@
package com.yihu.wlyy.figure.label.dao;
import com.yihu.figure_label.entity.FLJobConfig;
import com.yihu.figure_label.entity.FlJobConfig;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface FLJobConfigDao extends PagingAndSortingRepository<FLJobConfig, String>, JpaSpecificationExecutor<FLJobConfig> {
/**
 * @author lith on 2018.03.14
 * 定时任务配置
 */
public interface FlJobConfigDao extends PagingAndSortingRepository<FlJobConfig, String>, JpaSpecificationExecutor<FlJobConfig> {
    /**
     * 根据id和状态查询job配置
@ -16,24 +19,24 @@ public interface FLJobConfigDao extends PagingAndSortingRepository<FLJobConfig,
     * @param status
     * @return
     */
    @Query(" FROM FLJobConfig a WHERE a.id=?1 and a.status=?2 and a.del='1'")
    FLJobConfig findByIdAndStatus(Long id, String status);
    @Query(" FROM FlJobConfig a WHERE a.id=?1 and a.status=?2 and a.del='1'")
    FlJobConfig findByIdAndStatus(Long id, String status);
    /**
     * 查询所有的job配置
     * @param status
     * @return
     */
    @Query(" FROM FLJobConfig a WHERE a.status=?1 and a.del='1'")
    List<FLJobConfig> findByAll(String status);
    @Query(" FROM FlJobConfig a WHERE a.status=?1 and a.del='1'")
    List<FlJobConfig> findByAll(String status);
    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Query(" FROM FLJobConfig a WHERE a.id=?1 and a.del='1'")
    FLJobConfig findById(Long id);
    @Query(" FROM FlJobConfig a WHERE a.id=?1 and a.del='1'")
    FlJobConfig findById(Long id);
    /**
     * 更新job的状态(状态为启动或停止)
@ -42,7 +45,7 @@ public interface FLJobConfigDao extends PagingAndSortingRepository<FLJobConfig,
     * @return
     */
    @Modifying
    @Query(" update FLJobConfig a set a.status=?2 where a.id=?1 ")
    @Query(" update FlJobConfig a set a.status=?2 where a.id=?1 ")
    int updateStatus(Long id, String status);
    /**
@ -51,16 +54,16 @@ public interface FLJobConfigDao extends PagingAndSortingRepository<FLJobConfig,
     * @return
     */
    @Modifying
    @Query(" update FLJobConfig a set a.del = 1 where a.id=?1 ")
    @Query(" update FlJobConfig a set a.del = 1 where a.id=?1 ")
    int deleteJob(Long id);
    /**
     * 更新job的状态(状态为启动或停止)
     * 更新增量时间
     * @param id
     * @param value
     * @return
     */
    @Modifying
    @Query(" update FLJobConfig a set a.sqlFieldValue=?2 where a.id=?1 ")
    @Query(" update FlJobConfig a set a.sqlFieldValue=?2 where a.id=?1 ")
    int updateSqlFildeValue(Long id, String value);
}

+ 30 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FlLabelDictJobDao.java

@ -0,0 +1,30 @@
package com.yihu.wlyy.figure.label.dao;
import com.yihu.figure_label.entity.FlLabelDictJob;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author lith on 2018.03.14
 * 定时任务具体字典维度
 */
public interface FlLabelDictJobDao extends PagingAndSortingRepository<FlLabelDictJob, String>, JpaSpecificationExecutor<FlLabelDictJob> {
    /**
     * 根据jobId查询
     * @param jobId
     * @return
     */
    @Query(" FROM FlLabelDictJob a WHERE a.jobId=?1")
    FlLabelDictJob findByJobId(Long jobId);
    /**
     * 根据标签类型查询
     * @param type
     * @return
     */
    @Query(" FROM FlLabelDictJob a WHERE a.labelType=?1")
    FlLabelDictJob findByLabelType(String type);
}

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

@ -0,0 +1,11 @@
package com.yihu.wlyy.figure.label.enums;
/**
 * @author litaohong on 2018/3/29
 * @project patient-co-management
 */
public enum SourceTypeEnum {
    MYSQL,
    HBASE,
    FILE;
}

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

@ -1,12 +1,11 @@
package com.yihu.wlyy.figure.label.extract;
import com.yihu.figure_label.entity.FLlabelDictJob;
import com.yihu.wlyy.figure.label.model.DataModel;
import java.util.List;
/**
 * Created by chenweida on 2018/3/7.
 * @author lith on 2018.03.14 -- Created by chenweida on 2018/3/7.
 * 数据抽取器
 */
public interface Extracter {

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

@ -1,20 +1,18 @@
package com.yihu.wlyy.figure.label.extract;
import com.yihu.wlyy.figure.label.dao.FLLabelDictDao;
import com.yihu.wlyy.figure.label.model.DataModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
/**
 * Created by chenweida on 2018/3/7.
 * @author lith on 2018.03.14 -- Created by chenweida on 2018/3/7.
 * mysql数据抽取器
 */
@Component
public class MysqlExtracter implements Extracter {
@ -28,9 +26,7 @@ public class MysqlExtracter implements Extracter {
    @Override
    public List<DataModel> extractDataByJobConfigsql(String sql) {
        List<DataModel> datas = new ArrayList<>();
        getDataByThread(sql);
        return datas;
        return  getDataByThread(sql);
    }
    /**
@ -77,7 +73,7 @@ public class MysqlExtracter implements Extracter {
     * @return
     */
    public Integer getCount(String sql){
        String countSql = "select count(*) from " + sql.split("from")[1];
        String countSql = "select count(*) from " + sql.split("from|FROM")[1];
        Integer count = jdbcTemplate.queryForObject(countSql,Integer.class);
        return count;
    }

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

@ -1,16 +1,15 @@
package com.yihu.wlyy.figure.label.job;
import com.yihu.figure_label.entity.FLJobConfig;
import com.yihu.figure_label.entity.FLlabelDict;
import com.yihu.figure_label.entity.FLlabelDictJob;
import com.yihu.figure_label.entity.FlJobConfig;
import com.yihu.figure_label.entity.FlLabelDictJob;
import com.yihu.wlyy.figure.label.controller.JobController;
import com.yihu.wlyy.figure.label.convert.ConvertHelper;
import com.yihu.wlyy.figure.label.dao.FLJobConfigDao;
import com.yihu.wlyy.figure.label.dao.FLLabelDictDao;
import com.yihu.wlyy.figure.label.dao.FLLabelDictJobDao;
import com.yihu.wlyy.figure.label.dao.FlJobConfigDao;
import com.yihu.wlyy.figure.label.dao.FlLabelDictJobDao;
import com.yihu.wlyy.figure.label.extract.MysqlExtracter;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.service.JobService;
import com.yihu.wlyy.figure.label.storage.Store2ES;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
@ -20,6 +19,8 @@ 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
@ -29,7 +30,8 @@ import java.util.List;
/**
 * Created by chenweida on 2018/3/7.
 */
@Component
//@Component
@Service
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class Mysql2ESJob implements Job {
@ -37,10 +39,10 @@ public class Mysql2ESJob implements Job {
    private Logger logger = LoggerFactory.getLogger(JobController.class);
    @Autowired
    private FLJobConfigDao flJobConfigDao;
    private FlJobConfigDao flJobConfigDao;
    @Autowired
    private FLLabelDictJobDao flLabelDictJobDao;
    private FlLabelDictJobDao flLabelDictJobDao;
    @Autowired
    private MysqlExtracter mysqlExtracter;
@ -51,7 +53,10 @@ public class Mysql2ESJob implements Job {
    @Autowired
    Store2ES store2ES;
    private FLJobConfig flJobConfig;
    @Autowired
    private JobService jobService;
    private FlJobConfig flJobConfig;
    private Long flJobConfigId;
@ -63,6 +68,10 @@ public class Mysql2ESJob implements Job {
    private List<DataModel> dataModelList;
    private String sourceType;
    private String source;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
@ -78,14 +87,13 @@ public class Mysql2ESJob implements Job {
        boolean bool = save(list);
        //增量存储成功后,修改增量的czrq时间为当前时间
        if (bool) {
                this.flJobConfigDao.updateSqlFildeValue(this.flJobConfigId, DateFormatUtils.format(new Date(), ConstantUtil.date_format));
        }
        jobService.updateFieldValuetoCurrentTime(this.flJobConfigId,bool);
    }
    public void initParams(JobDataMap paramsMap){
        this.flJobConfigId = (Long)paramsMap.get("jobConfig");
        this.sourceType = String.valueOf(paramsMap.get("sourceType"));
        this.source = String.valueOf(paramsMap.get("source"));
        this.flJobConfig = flJobConfigDao.findById(this.flJobConfigId);
        //this.sqlFiledValue = (String)paramsMap.get(this.flJobConfig.getSqlField().toString());
@ -115,9 +123,9 @@ public class Mysql2ESJob implements Job {
     */
    public List<SaveModel> convert(){
        List<SaveModel> list = new ArrayList<>();
        FLlabelDictJob fLlabelDictJob = flLabelDictJobDao.findByJobId(this.flJobConfigId);
        FlLabelDictJob flLabelDictJob = flLabelDictJobDao.findByJobId(this.flJobConfigId);
        try {
            list = convertHelper.convert(this.dataModelList, fLlabelDictJob);
            list = convertHelper.convert(this.dataModelList, flLabelDictJob,this.sourceType,this.source);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }

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

@ -5,6 +5,12 @@ package com.yihu.wlyy.figure.label.model;
 */
public class DataModel {
    //这些id用作记录数据来源,当有多个表时,记录多个表的id,并依据fl_job_config里的sourceTyep,source来区别
    private int id;
    private int id1;
    private int id2;
    private int id3;
    private int id4;
    private String idcard;
    private String sex;
    private String parentCode;
@ -14,6 +20,46 @@ public class DataModel {
    private String jobId;
    private String patient;
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public int getId1() {
        return id1;
    }
    public void setId1(int id1) {
        this.id1 = id1;
    }
    public int getId2() {
        return id2;
    }
    public void setId2(int id2) {
        this.id2 = id2;
    }
    public int getId3() {
        return id3;
    }
    public void setId3(int id3) {
        this.id3 = id3;
    }
    public int getId4() {
        return id4;
    }
    public void setId4(int id4) {
        this.id4 = id4;
    }
    public String getIdcard() {
        return idcard;
    }

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

@ -43,6 +43,11 @@ public class SaveModel implements Serializable{
     */
    private String createTime;
    /**
     * 标签生成来源
     */
    private String source;
    public String getIdcard() {
        return idcard;
    }
@ -99,4 +104,12 @@ public class SaveModel implements Serializable{
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
    public String getSource() {
        return source;
    }
    public void setSource(String source) {
        this.source = source;
    }
}

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

@ -1,7 +1,8 @@
package com.yihu.wlyy.figure.label.service;
import com.yihu.figure_label.entity.FLJobConfig;
import com.yihu.wlyy.figure.label.dao.FLJobConfigDao;
import com.yihu.figure_label.entity.FlJobConfig;
import com.yihu.wlyy.figure.label.dao.FlJobConfigDao;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import com.yihu.wlyy.figure.label.util.IdCardUtil;
import com.yihu.wlyy.figure.label.util.QuartzHelpers;
import org.apache.commons.lang3.time.DateFormatUtils;
@ -16,7 +17,9 @@ import org.springframework.util.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 *@author lith on 2018.03.23
 */
@Service
public class JobService {
    @Value("${JobService.sleepTime}")
@ -26,7 +29,7 @@ public class JobService {
    private IdCardUtil idCardUtil;
    @Autowired
    private FLJobConfigDao flJobConfigDao;
    private FlJobConfigDao flJobConfigDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
@ -34,10 +37,9 @@ public class JobService {
    @Autowired
    private QuartzHelpers quartzHelpers;
    @Transactional
    @Transactional(rollbackFor = Exception.class)
    public void stopById(String id) throws Exception {
        FLJobConfig flJobConfig = flJobConfigDao.findByIdAndStatus(Long.valueOf(id), "1");
        FlJobConfig flJobConfig = flJobConfigDao.findByIdAndStatus(Long.valueOf(id), "1");
        if (flJobConfig != null) {
            for (int j = 1; j <= 2; j++) {
                quartzHelpers.removeJob(flJobConfig.getId() + "-" + j);
@ -48,26 +50,26 @@ public class JobService {
        }
    }
    @Transactional
    @Transactional(rollbackFor = Exception.class)
    public void startById(String id) throws Exception {
        FLJobConfig FLJobConfig = flJobConfigDao.findByIdAndStatus(Long.valueOf(id), "0");
        if (FLJobConfig != null) {
            startOneJob(FLJobConfig);
        FlJobConfig flJobConfig = flJobConfigDao.findByIdAndStatus(Long.valueOf(id), "0");
        if (flJobConfig != null) {
            startOneJob(flJobConfig);
        } else {
            throw new Exception("任务已经启动");
        }
    }
    @Transactional
    @Transactional(rollbackFor = Exception.class)
    public void stopAll() throws Exception {
        List<FLJobConfig> FLJobConfigs = flJobConfigDao.findByAll("1");
        if (FLJobConfigs != null && FLJobConfigs.size() > 0) {
            for (FLJobConfig FLJobConfig : FLJobConfigs) {
        List<FlJobConfig> FlJobConfigs = flJobConfigDao.findByAll("1");
        if (FlJobConfigs != null && FlJobConfigs.size() > 0) {
            for (FlJobConfig FlJobConfig : FlJobConfigs) {
                for (int j = 1; j <= 2; j++) {
                    quartzHelpers.removeJob(FLJobConfig.getId() + "-" + j);
                    quartzHelpers.removeJob(FlJobConfig.getId() + "-" + j);
                    flJobConfigDao.updateStatus(FLJobConfig.getId(),"0") ;;
                    flJobConfigDao.updateStatus(FlJobConfig.getId(),"0") ;;
                }
            }
        } else {
@ -75,12 +77,12 @@ public class JobService {
        }
    }
    @Transactional
    @Transactional(rollbackFor = Exception.class)
    public void startAll() throws Exception {
        List<FLJobConfig> FLJobConfigs = flJobConfigDao.findByAll("0");
        if (FLJobConfigs != null && FLJobConfigs.size() > 0) {
            for (FLJobConfig FLJobConfig : FLJobConfigs) {
                startOneJob(FLJobConfig);
        List<FlJobConfig> FlJobConfigs = flJobConfigDao.findByAll("0");
        if (FlJobConfigs != null && FlJobConfigs.size() > 0) {
            for (FlJobConfig FlJobConfig : FlJobConfigs) {
                startOneJob(FlJobConfig);
            }
        } else {
            throw new Exception("任务已经全部启动");
@ -90,17 +92,19 @@ public class JobService {
    /**
     * 启动单个任务
     *
     * @param FLJobConfig
     * @param FlJobConfig
     * @throws Exception
     */
    @Transactional
    public void startOneJob(FLJobConfig FLJobConfig) throws Exception {
    @Transactional(rollbackFor = Exception.class)
    public void startOneJob(FlJobConfig FlJobConfig) throws Exception {
        FLJobConfig flJobConfigVO = new FLJobConfig();
        BeanUtils.copyProperties(FLJobConfig, flJobConfigVO);
        FlJobConfig flJobConfigVO = new FlJobConfig();
        BeanUtils.copyProperties(FlJobConfig, flJobConfigVO);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("jobConfig", flJobConfigVO.getId());
        params.put("sourceType", flJobConfigVO.getSourceType());
        params.put("source", flJobConfigVO.getSource());
        //表里设置的增量查询类型和增量查询初始值,如果值没有配置,以当前时间为准
        if(!StringUtils.isEmpty(flJobConfigVO.getSqlFieldValue())){
            params.put("sqlFiledValue",flJobConfigVO.getSqlFieldValue());
@ -108,18 +112,18 @@ public class JobService {
            params.put("sqlFiledValue", DateFormatUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
        }
        params.put("sqlFiledCondition", ">");
        if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
        if (!StringUtils.isEmpty(FlJobConfig.getJobClass())) {
            //往quartz框架添加任务
            quartzHelpers.addJob(getRightClass(FLJobConfig), FLJobConfig.getQuartzCron(), FLJobConfig.getId().toString(), params);
            flJobConfigDao.updateStatus(FLJobConfig.getId(), "1");//设置任务状态是启动 }
            quartzHelpers.addJob(getRightClass(FlJobConfig), FlJobConfig.getQuartzCron(), FlJobConfig.getId().toString(), params);
            flJobConfigDao.updateStatus(FlJobConfig.getId(), "1");//设置任务状态是启动 }
        }
    }
    public void startNowById(String id) throws Exception {
        FLJobConfig FLJobConfig = flJobConfigDao.findOne(id);
        FlJobConfig FlJobConfig = flJobConfigDao.findOne(id);
        FLJobConfig flJobConfigVO = new FLJobConfig();
        BeanUtils.copyProperties(FLJobConfig, flJobConfigVO);
        FlJobConfig flJobConfigVO = new FlJobConfig();
        BeanUtils.copyProperties(FlJobConfig, flJobConfigVO);
        Map<String, Object> params = new HashMap<>();
        params.put("jobConfig", flJobConfigVO.getId());
@ -130,8 +134,8 @@ public class JobService {
        }
        params.put("sqlFiledCondition", ">");
        //往quartz框架添加任务
        if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
            quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
        if (!StringUtils.isEmpty(FlJobConfig.getJobClass())) {
            quartzHelpers.startNow(getRightClass(FlJobConfig), FlJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            Thread.sleep(sleepTime);
        }
    }
@ -158,19 +162,19 @@ public class JobService {
        calendar.add(Calendar.DATE, -1);//把日期往后增加一天.整数往后推,负数往前移动
        Date nowDate = calendar.getTime();   //这个时间就是日期往后推一天的结果
        String daybefore = new SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime());
        List<FLJobConfig> FLJobConfigs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(FLJobConfig.class));
        for (FLJobConfig FLJobConfig : FLJobConfigs) {
        List<FlJobConfig> FlJobConfigs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(FlJobConfig.class));
        for (FlJobConfig FlJobConfig : FlJobConfigs) {
            FLJobConfig flJobConfig = new FLJobConfig();
            BeanUtils.copyProperties(FLJobConfig, flJobConfig);
            FlJobConfig flJobConfig = new FlJobConfig();
            BeanUtils.copyProperties(FlJobConfig, flJobConfig);
            Map<String, Object> params = new HashMap<>();
            params.put("jobConfig", flJobConfig.getId().toString());
            //往quartz框架添加任务
            params.put("sqlFiledValue", daybefore+","+yesterday);
            params.put("sqlFiledCondition", ">,<");
            if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
                quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            if (!StringUtils.isEmpty(FlJobConfig.getJobClass())) {
                quartzHelpers.startNow(getRightClass(FlJobConfig), FlJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                Thread.sleep(sleepTime);
            }
@ -178,12 +182,12 @@ public class JobService {
    }
    /**
     * @param FLJobConfig
     * @param FlJobConfig
     * @return
     * @throws ClassNotFoundException
     */
    private Class getRightClass(FLJobConfig FLJobConfig) throws ClassNotFoundException {
        return Class.forName(FLJobConfig.getJobClass());
    private Class getRightClass(FlJobConfig FlJobConfig) throws ClassNotFoundException {
        return Class.forName(FlJobConfig.getJobClass());
    }
    public void productDataByOneDayWithId(String yesterday, String id) throws Exception {
@ -198,12 +202,12 @@ public class JobService {
        Date nowDate = calendar.getTime();   //这个时间就是日期往后推一天的结果
        String daybefore = new SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime());
        FLJobConfig FLJobConfig = flJobConfigDao.findById(Long.valueOf(id));
        if (FLJobConfig == null) {
        FlJobConfig FlJobConfig = flJobConfigDao.findById(Long.valueOf(id));
        if (FlJobConfig == null) {
            throw new Exception("id不存在");
        }
        FLJobConfig flJobConfigVO = new FLJobConfig();
        BeanUtils.copyProperties(FLJobConfig, flJobConfigVO);
        FlJobConfig flJobConfigVO = new FlJobConfig();
        BeanUtils.copyProperties(FlJobConfig, flJobConfigVO);
        Map<String, Object> params = new HashMap<>();
        params.put("jobConfig", Long.valueOf(flJobConfigVO.getId()));
@ -211,20 +215,20 @@ public class JobService {
        //往quartz框架添加任务
        params.put("sqlFiledValue", daybefore + "," + yesterday);
        params.put("sqlFiledCondition", ">,<");
        if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
            quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
        if (!StringUtils.isEmpty(FlJobConfig.getJobClass())) {
            quartzHelpers.startNow(getRightClass(FlJobConfig), FlJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            Thread.sleep(sleepTime);
        }
    }
    public void productDataByDayAndId(Integer day, String id) throws Exception {
        FLJobConfig FLJobConfig = flJobConfigDao.findById(Long.valueOf(id));
        if (FLJobConfig == null) {
        FlJobConfig FlJobConfig = flJobConfigDao.findById(Long.valueOf(id));
        if (FlJobConfig == null) {
            throw new Exception("id不存在");
        }
        FLJobConfig flJobConfigVO = new FLJobConfig();
        BeanUtils.copyProperties(FLJobConfig, flJobConfigVO);
        FlJobConfig flJobConfigVO = new FlJobConfig();
        BeanUtils.copyProperties(FlJobConfig, flJobConfigVO);
        Map<String, Object> params = new HashMap<>();
        params.put("jobConfig", flJobConfigVO.getId().toString());
@ -232,8 +236,8 @@ public class JobService {
            //往quartz框架添加任务
            params.put("sqlFiledValue",  getYesterday(0 - i - 1)+","+getYesterday(0 - i));
            params.put("sqlFiledCondition", ">,<");
            if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
                quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            if (!StringUtils.isEmpty(FlJobConfig.getJobClass())) {
                quartzHelpers.startNow(getRightClass(FlJobConfig), FlJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                Thread.sleep(sleepTime);
            }
        }
@ -319,12 +323,12 @@ public class JobService {
        Date nowDate = calendar.getTime();   //这个时间就是日期往后推一天的结果
        String daybefore = new SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime());
        FLJobConfig FLJobConfig = flJobConfigDao.findById(Long.valueOf(id));
        if (FLJobConfig == null) {
        FlJobConfig FlJobConfig = flJobConfigDao.findById(Long.valueOf(id));
        if (FlJobConfig == null) {
            throw new Exception("id不存在");
        }
        FLJobConfig flJobConfigVO = new FLJobConfig();
        BeanUtils.copyProperties(FLJobConfig, flJobConfigVO);
        FlJobConfig flJobConfigVO = new FlJobConfig();
        BeanUtils.copyProperties(FlJobConfig, flJobConfigVO);
        Map<String, Object> params = new HashMap<>();
        params.put("jobConfig", flJobConfigVO.getId().toString());
@ -332,8 +336,8 @@ public class JobService {
        //往quartz框架添加任务
        params.put("sqlFiledValue", daybefore + "," + yesterday);
        params.put("sqlFiledCondition", ">,<");
        if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
            quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
        if (!StringUtils.isEmpty(FlJobConfig.getJobClass())) {
            quartzHelpers.startNow(getRightClass(FlJobConfig), FlJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
        }
        Thread.sleep(sleepTime * 1000L);
    }
@ -352,10 +356,10 @@ public class JobService {
        calendar.add(Calendar.DATE, -1);//把日期往后增加一天.整数往后推,负数往前移动
        Date nowDate = calendar.getTime();   //这个时间就是日期往后推一天的结果
        String daybefore = new SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime());
        List<FLJobConfig> FLJobConfigs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(FLJobConfig.class));
        for (FLJobConfig FLJobConfig : FLJobConfigs) {
            FLJobConfig flJobConfigVO = new FLJobConfig();
            BeanUtils.copyProperties(FLJobConfig, flJobConfigVO);
        List<FlJobConfig> FlJobConfigs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(FlJobConfig.class));
        for (FlJobConfig FlJobConfig : FlJobConfigs) {
            FlJobConfig flJobConfigVO = new FlJobConfig();
            BeanUtils.copyProperties(FlJobConfig, flJobConfigVO);
            Map<String, Object> params = new HashMap<>();
            params.put("jobConfig", flJobConfigVO.getId().toString());
@ -363,8 +367,8 @@ public class JobService {
            params.put("sqlFiledValue", daybefore + "," + yesterday);
            params.put("sqlFiledCondition", ">,<");
            if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
                quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            if (!StringUtils.isEmpty(FlJobConfig.getJobClass())) {
                quartzHelpers.startNow(getRightClass(FlJobConfig), FlJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            }
            Thread.sleep(sleepTime * 1000L);
@ -372,6 +376,18 @@ public class JobService {
    }
    /**
     * 增量查询数据成功后,将增量时间改为当前时间
     * @param id
     * @param bool
     */
    @Transactional(rollbackFor = Exception.class)
    public void updateFieldValuetoCurrentTime(Long id,boolean bool) {
        if (bool) {
            this.flJobConfigDao.updateSqlFildeValue(id, DateFormatUtils.format(new Date(), ConstantUtil.date_format));
        }
    }
   /* public void startCleanCacheJob() throws Exception {
        if (!quartzHelper.isExistJob(CacheCleanJob.jobKey)) {
            quartzHelper.addJob(CacheCleanJob.class, CacheCleanJob.cron, CacheCleanJob.jobKey, new HashMap<>());

+ 1 - 1
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Storager.java

@ -5,7 +5,7 @@ import com.yihu.wlyy.figure.label.model.SaveModel;
import java.util.List;
/**
 * Created by chenweida on 2018/3/7.
 * @author lith on 2018.03.14 -- Created by chenweida on 2018/3/7.
 * 存储器
 */
public interface Storager {

+ 1 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Store2ES.java

@ -44,4 +44,5 @@ public class Store2ES implements Storager {
        }
    }
}

+ 1 - 1
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Store2Hbase.java

@ -18,7 +18,7 @@ import java.util.List;
import java.util.Map;
/**
 * lith 2018.03.23
 * @author lith 2018.03.23
 */
public class Store2Hbase implements Storager {