Kaynağa Gözat

居民标签数据转换修改,增加修改增量字段值

LiTaohong 7 yıl önce
ebeveyn
işleme
ed8c6f9f03
16 değiştirilmiş dosya ile 176 ekleme ve 100 silme
  1. 3 3
      common/common-entity/src/main/java/com/yihu/figure_label/entity/FLlabelDictJob.java
  2. 1 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/FigureLabelApplication.java
  3. 1 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/AgeConvert.java
  4. 4 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/BirthConvert.java
  5. 4 8
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ConvertHelper.java
  6. 1 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SexConvert.java
  7. 17 7
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FLJobConfigDao.java
  8. 1 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FLLabelDictJobDao.java
  9. 5 3
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/MysqlExtracter.java
  10. 39 17
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Mysql2ESJob.java
  11. 5 5
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/model/DataModel.java
  12. 15 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/model/SaveModel.java
  13. 40 28
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/service/JobService.java
  14. 14 4
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Store2ES.java
  15. 20 10
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/IdCardUtil.java
  16. 6 9
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/QuartzHelper.java

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

@ -13,16 +13,16 @@ import javax.persistence.Table;
@Entity
@Table(name = "fl_label_dict_job")
public class FLlabelDictJob extends IdEntity {
    private String jobId;
    private Long jobId;
    private String labelType;
    private String sql;
    private String convertClazz;
    public String getJobId() {
    public Long getJobId() {
        return jobId;
    }
    public void setJobId(String jobId) {
    public void setJobId(Long jobId) {
        this.jobId = jobId;
    }

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

@ -24,7 +24,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
//        ElasticsearchDataAutoConfiguration.class,
        RedisRepositoriesAutoConfiguration.class
})
@ComponentScan({"com.yihu.wlyy.figure"})
@ComponentScan({"com.yihu.wlyy"})
public class FigureLabelApplication {
    public static ApplicationContext ctx = null;

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

@ -29,7 +29,7 @@ public class AgeConvert implements Convert {
        );
        models.forEach(
                model -> {
                    int age = IdCardUtil.getAgeForIdcard(model.getIdCard());
                    int age = IdCardUtil.getAgeForIdcard(model.getIdcard());
                    String labelCode = getAgeLabelCode(age);
                    SaveModel saveModel = new SaveModel();
                    saveModel.setLabelType(one.getParentCode());

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

@ -22,16 +22,18 @@ public class BirthConvert implements Convert {
        FLlabelDict fLlabelDict = flLabelDictList.get(0);
        models.forEach(
                model -> {
                    String birth = null;
                    try {
                        String birth = IdCardUtil.getBirthdayForIdcard(model.getIdCard());
                        birth  = IdCardUtil.getBirthdayForIdcard(model.getIdcard());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    SaveModel saveModel = new SaveModel();
                    saveModel.setIdcard(model.getIdCard());
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setLabelCode(fLlabelDict.getLabelCode());
                    saveModel.setLabelType(fLlabelDict.getParentCode());
                    saveModel.setLabeName(fLlabelDict.getLabelName());
                    saveModel.setLabelValue(birth);
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
                    saveModels.add(saveModel);
                }

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

@ -43,20 +43,16 @@ public class ConvertHelper {
    public List<SaveModel> convert(List<DataModel> dataModels, FLlabelDictJob fLlabelDictJob) throws Exception {
        List<SaveModel> saveModels = new ArrayList<>();
            //不需要转换
            if(StringUtils.isEmpty(fLlabelDictJob.getConvertClazz())){
                return generateSaveModleWithOutConvert(dataModels);
            }
            //不需要转换
            if(StringUtils.isEmpty(fLlabelDictJob.getSql())){
            if(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("conver",List.class);
                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 not found:" + fLlabelDictJob.getConvertClazz());
                logger.error("customized class or convert(List<DataModel> modelList,List<FLlabelDict> flLabelDictList) method not found:" + fLlabelDictJob.getConvertClazz());
                return saveModels;
            }
        return saveModels;
@ -67,7 +63,7 @@ public class ConvertHelper {
        dataModels.forEach(
                dataModel -> {
                    SaveModel saveModel = new SaveModel();
                    saveModel.setIdcard(dataModel.getIdCard());
                    saveModel.setIdcard(dataModel.getIdcard());
                    saveModel.setLabelType(dataModel.getParentCode());
                    saveModel.setLabelCode(dataModel.getLabelCode());
                    saveModel.setLabeName(dataModel.getLabelName());

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

@ -22,7 +22,7 @@ public class SexConvert implements Convert{
        );
        models.forEach(
                model -> {
                    String sex = IdCardUtil.getSexForIdcard(model.getIdCard());
                    String sex = IdCardUtil.getSexForIdcard(model.getIdcard());
                    SaveModel saveModel = new SaveModel();
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabelCode(sex);

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

@ -12,20 +12,20 @@ public interface FLJobConfigDao extends PagingAndSortingRepository<FLJobConfig,
    /**
     * 根据id和状态查询job配置
     * @param code
     * @param id
     * @param status
     * @return
     */
    @Query(" FROM FLJobConfig a WHERE a.id=?1 and a.status=?2 and a.del='1'")
    FLJobConfig findByIdAndStatus(String code, String status);
    FLJobConfig findByIdAndStatus(Long id, String status);
    /**
     * 查询所有的job配置
     * @param s
     * @param status
     * @return
     */
    @Query(" FROM FLJobConfig a WHERE a.status=?1 and a.del='1'")
    List<FLJobConfig> findByAll(String s);
    List<FLJobConfig> findByAll(String status);
    /**
     * 根据id查询
@ -33,7 +33,7 @@ public interface FLJobConfigDao extends PagingAndSortingRepository<FLJobConfig,
     * @return
     */
    @Query(" FROM FLJobConfig a WHERE a.id=?1 and a.del='1'")
    FLJobConfig findById(String id);
    FLJobConfig findById(Long id);
    /**
     * 更新job的状态(状态为启动或停止)
@ -43,7 +43,7 @@ public interface FLJobConfigDao extends PagingAndSortingRepository<FLJobConfig,
     */
    @Modifying
    @Query(" update FLJobConfig a set a.status=?2 where a.id=?1 ")
    int updateStatus(String id, String status);
    int updateStatus(Long id, String status);
    /**
     * 删除job(0 正常 1 删除)
@ -52,5 +52,15 @@ public interface FLJobConfigDao extends PagingAndSortingRepository<FLJobConfig,
     */
    @Modifying
    @Query(" update FLJobConfig a set a.del = 1 where a.id=?1 ")
    int deleteJob(String id);
    int deleteJob(Long id);
    /**
     * 更新job的状态(状态为启动或停止)
     * @param id
     * @param value
     * @return
     */
    @Modifying
    @Query(" update FLJobConfig a set a.sqlFieldValue=?2 where a.id=?1 ")
    int updateSqlFildeValue(Long id, String value);
}

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

@ -16,7 +16,7 @@ public interface FLLabelDictJobDao extends PagingAndSortingRepository<FLlabelDic
     * @return
     */
    @Query(" FROM FLlabelDictJob a WHERE a.jobId=?1")
    FLlabelDictJob findByJobId(String jobId);
    FLlabelDictJob findByJobId(Long jobId);
    /**
     * 根据标签类型查询

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

@ -2,6 +2,8 @@ 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;
@ -15,8 +17,7 @@ import java.util.List;
@Component
public class MysqlExtracter implements Extracter {
    @Autowired
    private FLLabelDictDao flLabelDictDao;
    private Logger logger = LoggerFactory.getLogger(MysqlExtracter.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
@ -28,7 +29,8 @@ public class MysqlExtracter implements Extracter {
    @Override
    public List<DataModel> extractDataByJobConfigsql(String sql) {
        List<DataModel> datas = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>());
        List<DataModel> datas = jdbcTemplate.query(sql,new BeanPropertyRowMapper(DataModel.class));
        logger.info("job get data counts:" + datas.size());
        return datas;
    }

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

@ -12,6 +12,8 @@ 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.storage.Store2ES;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -21,6 +23,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@ -36,9 +39,6 @@ public class Mysql2ESJob implements Job {
    @Autowired
    private FLJobConfigDao flJobConfigDao;
    @Autowired
    private FLLabelDictDao flLabelDictDao;
    @Autowired
    private FLLabelDictJobDao flLabelDictJobDao;
@ -53,7 +53,7 @@ public class Mysql2ESJob implements Job {
    private FLJobConfig flJobConfig;
    private String flJobConfigId;
    private Long flJobConfigId;
    private String sqlFiledValue;
@ -73,17 +73,22 @@ public class Mysql2ESJob implements Job {
        extract();
        //数据转换
        List<SaveModel> list = new ArrayList<>();
        convert(list);
        list = convert();
        //数据保存
        save(list);
        boolean bool = save(list);
        //增量存储成功后,修改增量的czrq时间为当前时间
        if (bool) {
            this.flJobConfigDao.updateSqlFildeValue(this.flJobConfigId, DateFormatUtils.format(new Date(), ConstantUtil.date_format));
        }
    }
    public void initParams(JobDataMap paramsMap){
        this.flJobConfigId = paramsMap.getString("jobConfig");
        this.flJobConfigId = (Long)paramsMap.get("jobConfig");
        this.flJobConfig = flJobConfigDao.findById(this.flJobConfigId);
        this.sqlFiledValue = paramsMap.getString("sqlFiledValue");
        this.sqlFiledValue = (String)paramsMap.get(this.flJobConfig.getSqlField().toString());
        //没有传增量值,以数据库配置的默认值为查询条件
        if(StringUtils.isEmpty(this.sqlFiledValue)){
            this.sqlFiledValue = this.flJobConfig.getSqlFieldValue();
@ -105,13 +110,15 @@ public class Mysql2ESJob implements Job {
    /**
     * 转换
     */
    public void convert(List<SaveModel> list){
        FLlabelDictJob fLlabelDictJob = flLabelDictJobDao.findOne(this.flJobConfigId);
    public List<SaveModel> convert(){
        List<SaveModel> list = new ArrayList<>();
        FLlabelDictJob fLlabelDictJob = flLabelDictJobDao.findByJobId(this.flJobConfigId);
        try {
            list = convertHelper.convert(this.dataModelList, fLlabelDictJob);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
        return list;
    }
@ -119,8 +126,15 @@ public class Mysql2ESJob implements Job {
     * 保存
     * @param list
     */
    public void save(List<SaveModel> list){
        store2ES.save(list);
    public boolean save(List<SaveModel> list){
        boolean bool = true;
        try {
            store2ES.save(list);
        }catch (Exception e){
            logger.error("save to elasticsearch failed,convet data count:" + list.size());
            bool = false;
        }
        return bool;
    }
    /**
@ -131,12 +145,20 @@ public class Mysql2ESJob implements Job {
     */
    public String getJobConfigSql(String sql,String sqlFiled,String sqlFiledCondition,String sqlFiledValue){
        StringBuilder result = new StringBuilder();
        if (sqlFiledValue.contains(",")) {
        result.append(sql).append(" ");
        if(StringUtils.isEmpty(sqlFiledCondition)){
            return result.toString();
        }
        if (sqlFiledValue.contains(",") && sql.contains("where")) {
            String[] sqlFiledValues = sqlFiledValue.split(",");
            result.append("where ").append(sqlFiled).append(sqlFiledCondition).append(sqlFiledValues[0]).append(sqlFiledCondition).append(sqlFiledValues[1]);
        }else{
            result.append("where ").append(sqlFiled).append(sqlFiledCondition).append(sqlFiledValue);
            result.append("and ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValues[1]+"\'").append(sqlFiledCondition).append("\'"+sqlFiledValues[0]+"\'");
        }else if(sql.contains("where")){
            result.append("and ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValue+"\'");
        }else {
            result.append("where ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValue+"\'");
        }
        return result.toString();
    }
}

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

@ -5,7 +5,7 @@ package com.yihu.wlyy.figure.label.model;
 */
public class DataModel {
    private String idCard;
    private String idcard;
    private String sex;
    private String parentCode;
    private String labelName;
@ -14,12 +14,12 @@ public class DataModel {
    private String jobId;
    private String patient;
    public String getIdCard() {
        return idCard;
    public String getIdcard() {
        return idcard;
    }
    public void setIdCard(String idCard) {
        this.idCard = idCard;
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getSex() {

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

@ -22,10 +22,17 @@ public class SaveModel {
     * 标签code
     */
    private String labelCode;
    /**
     * 标签名称
     */
    private String labeName;
    /**
     * 标签值,仅当标签只有一个分类的时候才有此值,比如生日,体重等
     */
    private String labelValue;
    /**
     * 创建时间
     */
@ -72,6 +79,14 @@ public class SaveModel {
        this.labeName = labeName;
    }
    public String getLabelValue() {
        return labelValue;
    }
    public void setLabelValue(String labelValue) {
        this.labelValue = labelValue;
    }
    public String getCreateTime() {
        return createTime;
    }

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

@ -2,7 +2,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.wlyy.figure.label.util.QuartzHelper;
import com.yihu.wlyy.figure.label.util.IdCardUtil;
import com.yihu.wlyy.figure.label.util.QuartzHelpers;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -22,21 +23,25 @@ public class JobService {
    private Integer sleepTime;
    @Autowired
    private QuartzHelper quartzHelper;
    private IdCardUtil idCardUtil;
    @Autowired
    private FLJobConfigDao flJobConfigDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private QuartzHelpers quartzHelpers;
    @Transactional
    public void stopById(String id) throws Exception {
        FLJobConfig flJobConfig = flJobConfigDao.findByIdAndStatus(id, "1");
        FLJobConfig flJobConfig = flJobConfigDao.findByIdAndStatus(Long.valueOf(id), "1");
        if (flJobConfig != null) {
            for (int j = 1; j <= 2; j++) {
                quartzHelper.removeJob(flJobConfig.getId() + "-" + j);
                flJobConfigDao.updateStatus(flJobConfig.getId().toString(),"0") ;;
                quartzHelpers.removeJob(flJobConfig.getId() + "-" + j);
                flJobConfigDao.updateStatus(flJobConfig.getId(),"0") ;;
            }
        } else {
            throw new Exception("任务已经停止");
@ -45,7 +50,7 @@ public class JobService {
    @Transactional
    public void startById(String id) throws Exception {
        FLJobConfig FLJobConfig = flJobConfigDao.findByIdAndStatus(id, "0");
        FLJobConfig FLJobConfig = flJobConfigDao.findByIdAndStatus(Long.valueOf(id), "0");
        if (FLJobConfig != null) {
            startOneJob(FLJobConfig);
        } else {
@ -60,9 +65,9 @@ public class JobService {
        if (FLJobConfigs != null && FLJobConfigs.size() > 0) {
            for (FLJobConfig FLJobConfig : FLJobConfigs) {
                for (int j = 1; j <= 2; j++) {
                    quartzHelper.removeJob(FLJobConfig.getId() + "-" + j);
                    quartzHelpers.removeJob(FLJobConfig.getId() + "-" + j);
                    flJobConfigDao.updateStatus(FLJobConfig.getId().toString(),"0") ;;
                    flJobConfigDao.updateStatus(FLJobConfig.getId(),"0") ;;
                }
            }
        } else {
@ -102,24 +107,31 @@ public class JobService {
        }else{
            params.put(flJobConfigVO.getSqlField(), DateFormatUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
        }
        params.put("sqlFiledCondition", ">");
        if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
            //往quartz框架添加任务
            quartzHelper.addJob(getRightClass(FLJobConfig), FLJobConfig.getQuartzCron(), FLJobConfig.getId().toString(), params);
            flJobConfigDao.updateStatus(FLJobConfig.getId().toString(), "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 wlyyJobConfigVO = new FLJobConfig();
        BeanUtils.copyProperties(FLJobConfig, wlyyJobConfigVO);
        FLJobConfig flJobConfigVO = new FLJobConfig();
        BeanUtils.copyProperties(FLJobConfig, flJobConfigVO);
        Map<String, String> params = new HashMap<String, String>();
        params.put("jobConfig", wlyyJobConfigVO.getId().toString());
        Map<String, Object> params = new HashMap<>();
        params.put("jobConfig", flJobConfigVO.getId());
        if(!StringUtils.isEmpty(flJobConfigVO.getSqlFieldValue())){
            params.put(flJobConfigVO.getSqlField(),flJobConfigVO.getSqlFieldValue());
        }else{
            params.put(flJobConfigVO.getSqlField(), DateFormatUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
        }
        params.put("sqlFiledCondition", ">");
        //往quartz框架添加任务
        if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
            quartzHelper.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            Thread.sleep(sleepTime);
        }
    }
@ -152,13 +164,13 @@ public class JobService {
            FLJobConfig flJobConfig = new FLJobConfig();
            BeanUtils.copyProperties(FLJobConfig, flJobConfig);
            Map<String, String> params = new HashMap<String, String>();
            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())) {
                quartzHelper.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                Thread.sleep(sleepTime);
            }
@ -186,42 +198,42 @@ public class JobService {
        Date nowDate = calendar.getTime();   //这个时间就是日期往后推一天的结果
        String daybefore = new SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime());
        FLJobConfig FLJobConfig = flJobConfigDao.findById(id);
        FLJobConfig FLJobConfig = flJobConfigDao.findById(Long.valueOf(id));
        if (FLJobConfig == null) {
            throw new Exception("id不存在");
        }
        FLJobConfig flJobConfigVO = new FLJobConfig();
        BeanUtils.copyProperties(FLJobConfig, flJobConfigVO);
        Map<String, String> params = new HashMap<String, String>();
        Map<String, Object> params = new HashMap<>();
        params.put("jobConfig", flJobConfigVO.getId().toString());
        //往quartz框架添加任务
        params.put("sqlFiledValue", daybefore + "," + yesterday);
        params.put("sqlFiledCondition", "<");
        if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
            quartzHelper.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            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(id);
        FLJobConfig FLJobConfig = flJobConfigDao.findById(Long.valueOf(id));
        if (FLJobConfig == null) {
            throw new Exception("id不存在");
        }
        FLJobConfig flJobConfigVO = new FLJobConfig();
        BeanUtils.copyProperties(FLJobConfig, flJobConfigVO);
        Map<String, String> params = new HashMap<String, String>();
        Map<String, Object> params = new HashMap<>();
        params.put("jobConfig", flJobConfigVO.getId().toString());
        for (int i = 1; i <= day; i++) {
            //往quartz框架添加任务
            params.put("sqlFiledValue",  getYesterday(0 - i - 1)+","+getYesterday(0 - i));
            params.put("sqlFiledCondition", "<");
            if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
                quartzHelper.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                Thread.sleep(sleepTime);
            }
        }
@ -307,21 +319,21 @@ public class JobService {
        Date nowDate = calendar.getTime();   //这个时间就是日期往后推一天的结果
        String daybefore = new SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime());
        FLJobConfig FLJobConfig = flJobConfigDao.findById(id);
        FLJobConfig FLJobConfig = flJobConfigDao.findById(Long.valueOf(id));
        if (FLJobConfig == null) {
            throw new Exception("id不存在");
        }
        FLJobConfig flJobConfigVO = new FLJobConfig();
        BeanUtils.copyProperties(FLJobConfig, flJobConfigVO);
        Map<String, String> params = new HashMap<String, String>();
        Map<String, Object> params = new HashMap<>();
        params.put("jobConfig", flJobConfigVO.getId().toString());
        //往quartz框架添加任务
        params.put("sqlFiledValue", daybefore + "," + yesterday);
        params.put("sqlFiledCondition", "<");
        if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
            quartzHelper.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
        }
        Thread.sleep(sleepTime * 1000L);
    }
@ -345,14 +357,14 @@ public class JobService {
            FLJobConfig flJobConfigVO = new FLJobConfig();
            BeanUtils.copyProperties(FLJobConfig, flJobConfigVO);
            Map<String, String> params = new HashMap<String, String>();
            Map<String, Object> params = new HashMap<>();
            params.put("jobConfig", flJobConfigVO.getId().toString());
            //往quartz框架添加任务
            params.put("sqlFiledValue", daybefore + "," + yesterday);
            params.put("sqlFiledCondition", "<");
            if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
                quartzHelper.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            }
            Thread.sleep(sleepTime * 1000L);

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

@ -19,9 +19,19 @@ public class Store2ES implements Storager {
    @Override
    public void save(List<SaveModel> modelList) {
        List<Object> list = new ArrayList<>();
        modelList.forEach(
                obj-> list.add(obj)
        );
        elastricSearchHelper.save(ConstantUtil.figure_label_es_index, ConstantUtil.figure_label_es_type, list);
        int saveCount = 0;
        for(SaveModel saveModel:modelList){
            list.add(saveModel);
            //防止内存溢出,一次性存储10W条
            if(list.size() >= 100000){
                elastricSearchHelper.save(ConstantUtil.figure_label_es_index, ConstantUtil.figure_label_es_type, list);
                list.clear();
                saveCount ++;
            }else if(modelList.size() - saveCount * 100000 == list.size()){
                //剩余的零头
                elastricSearchHelper.save(ConstantUtil.figure_label_es_index, ConstantUtil.figure_label_es_type, list);
            }
        }
    }
}

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

@ -1,10 +1,13 @@
package com.yihu.wlyy.figure.label.util;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import java.util.Calendar;
/***
 * 根据居民身份证提取相对应的信息
 */
@Component
public class IdCardUtil {
    /**
@ -93,22 +96,29 @@ public class IdCardUtil {
        if(StringUtils.isEmpty(idCard)){
            return "";
        }
        String birthday = null;
        String year = "";
        String month = "";
        String day = "";
        if (idCard.length() == 18) {
            birthday = idCard.substring(6,14);
            year = idCard.substring(6,10);
            month = idCard.substring(10,12);
            day = idCard.substring(12,14);
        } else if (idCard.length() == 15) {
            birthday = "19" + idCard.substring(7,12);
            year = "19" + idCard.substring(6,8);
            month = idCard.substring(8,10);
            day = idCard.substring(10,12);
        }
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(birthday.substring(0,4)).append("-");
        stringBuilder.append(birthday.substring(4,6)).append("-");
        stringBuilder.append(birthday.substring(6,8));
        return stringBuilder.toString();
        StringBuilder birthday = new StringBuilder();
        birthday.append(year).append("-");
        birthday.append(month).append("-");
        birthday.append(day);
        return birthday.toString();
    }
    public static void main(String args[]) throws Exception {
//        System.out.println(getBirthdayForIdcard("411321198004273615"));
        System.out.println(getBirthdayForIdcard("411321198004273615"));
        System.out.println(getBirthdayForIdcard("440253850213582"));
//        System.out.println(getSexForIdcard("411321198004273615"));
        System.out.println(getAgeForIdcard("411321198004273615"));
//        System.out.println(getAgeForIdcard("411321198004273615"));
    }
}

+ 6 - 9
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/QuartzHelper.java

@ -13,23 +13,20 @@ import java.util.Map;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
@Configuration
public class QuartzHelper {
@Component
public class QuartzHelpers {
    @Autowired
    private SchedulerFactoryBean schedulerFactoryBean;
    private Scheduler scheduler = null;
    @Bean
    public SchedulerFactoryBean getSchedulerFactoryBean(){
        return new SchedulerFactoryBean();
    }
    @PostConstruct
    public void init() {
        try {
//            SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
            scheduler = schedulerFactoryBean.getScheduler();
            scheduler.clear();
            scheduler.start();
        } catch (SchedulerException e) {
            e.printStackTrace();
@ -91,7 +88,7 @@ public class QuartzHelper {
     * @param params
     * @throws Exception
     */
    public void startNow(Class jobClass, String id, Map<String, String> params) throws Exception {
    public void startNow(Class jobClass, String id, Map<String, Object> params) throws Exception {
        startAt(new Date(), jobClass, id, params);
    }
@ -104,7 +101,7 @@ public class QuartzHelper {
     * @param params
     * @throws Exception
     */
    public void startAt(Date time, Class jobClass, String id, Map<String, String> 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);