Bladeren bron

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

huangwenjie 7 jaren geleden
bovenliggende
commit
ebb1efb7d1
27 gewijzigde bestanden met toevoegingen van 312 en 79 verwijderingen
  1. 2 2
      patient-co-service/wlyy_sign/pom.xml
  2. 5 0
      patient-co/patient-co-figure-label/pom.xml
  3. 3 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/AgeConvert.java
  4. 2 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/BirthConvert.java
  5. 0 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ConvertHelper.java
  6. 2 3
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsOnlineConvert.java
  7. 2 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SexConvert.java
  8. 2 3
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SignStateConvert.java
  9. 39 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/MutilThreadMysqlExtracter.java
  10. 54 7
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/MysqlExtracter.java
  11. 10 4
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Mysql2ESJob.java
  12. 2 13
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/model/SaveModel.java
  13. 3 7
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/service/JobService.java
  14. 3 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Store2ES.java
  15. 47 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Store2Hbase.java
  16. 63 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/BeanUtil.java
  17. 3 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/ConstantUtil.java
  18. 4 4
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/MakeModelIDUtil.java
  19. 9 1
      patient-co/patient-co-figure-label/src/main/resources/application-dev.yml
  20. 13 7
      patient-co/patient-co-wlyy/pom.xml
  21. 3 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/Application.java
  22. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java
  23. 13 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/iot/IotDeviceService.java
  24. 20 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java
  25. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  26. 2 1
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml
  27. 4 4
      patient-co/patient-co-wlyy/src/main/resources/logback.xml

+ 2 - 2
patient-co-service/wlyy_sign/pom.xml

@ -128,12 +128,12 @@
        <dependency>
            <groupId>com.zoesoft</groupId>
            <artifactId>phip-ssp-sdk</artifactId>
            <version>1.4.0</version>
            <version>1.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.zoesoft</groupId>
            <artifactId>zoe-crypto</artifactId>
            <version>1.4.0</version>
            <version>1.0-PK</version>
        </dependency>
        <!-- 智业接口引用 END -->

+ 5 - 0
patient-co/patient-co-figure-label/pom.xml

@ -83,6 +83,11 @@
            <artifactId>common-data-es-starter</artifactId>
            <version>1.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>common-data-hbase-starter</artifactId>
            <version>1.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>

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

@ -5,7 +5,7 @@ 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.MakeModelIDUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@ -23,6 +23,7 @@ public class AgeConvert implements Convert {
        }
        FLlabelDict one = flLabelDictList.get(0);
        Map<String,String> map = new HashMap<>();
        flLabelDictList.forEach(
                fLlabelDict -> {
                    map.put(fLlabelDict.getLabelCode(),fLlabelDict.getLabelName());
@ -33,7 +34,7 @@ public class AgeConvert implements Convert {
                    int age = IdCardUtil.getAgeForIdcard(model.getIdcard());
                    String labelCode = getAgeLabelCode(age);
                    SaveModel saveModel = new SaveModel();
                    saveModel.setModelId(MakeModelIDUtil.makeModelID(model,""));
                    saveModel.setId(MakeIDUtil.makeSaveModelID(model,""));
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabelCode(labelCode);
                    saveModel.setLabeName(map.get(labelCode));

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

@ -5,7 +5,7 @@ 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.MakeModelIDUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.util.CollectionUtils;
@ -30,7 +30,7 @@ public class BirthConvert implements Convert {
                        e.printStackTrace();
                    }
                    SaveModel saveModel = new SaveModel();
                    saveModel.setModelId(MakeModelIDUtil.makeModelID(model,birth));
                    saveModel.setId(MakeIDUtil.makeSaveModelID(model,birth));
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setLabelCode(fLlabelDict.getLabelCode());
                    saveModel.setLabelType(fLlabelDict.getParentCode());

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

@ -6,8 +6,6 @@ import com.yihu.wlyy.figure.label.dao.FLLabelDictDao;
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.MD5Util;
import com.yihu.wlyy.figure.label.util.MakeModelIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

@ -4,8 +4,7 @@ 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.MakeModelIDUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@ -35,7 +34,7 @@ public class IsOnlineConvert implements Convert {
        models.forEach(
                model -> {
                    SaveModel saveModel = new SaveModel();
                    saveModel.setModelId(MakeModelIDUtil.makeModelID(model,""));
                    saveModel.setId(MakeIDUtil.makeSaveModelID(model,""));
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabelCode(model.getLabelCode());

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

@ -5,7 +5,7 @@ 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.MakeModelIDUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.util.*;
@ -25,7 +25,7 @@ public class SexConvert implements Convert{
                model -> {
                    String sex = IdCardUtil.getSexForIdcard(model.getIdcard());
                    SaveModel saveModel = new SaveModel();
                    saveModel.setModelId(MakeModelIDUtil.makeModelID(model,""));
                    saveModel.setId(MakeIDUtil.makeSaveModelID(model,""));
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabelCode(sex);
                    saveModel.setLabeName(map.get(sex));

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

@ -4,8 +4,7 @@ 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.MakeModelIDUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.util.CollectionUtils;
@ -33,7 +32,7 @@ public class SignStateConvert implements Convert{
                model -> {
                    SaveModel saveModel = new SaveModel();
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setModelId(MakeModelIDUtil.makeModelID(model,""));
                    saveModel.setId(MakeIDUtil.makeSaveModelID(model,""));
                    saveModel.setLabelCode(model.getLabelCode());
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabeName(map.get(model.getLabelCode()));

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

@ -0,0 +1,39 @@
package com.yihu.wlyy.figure.label.extract;
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 java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
/**
 * @Author lith 2018/03/23
 * 多线程分页查询mysql数据,因为mysql数据量比较大的时候,会比较慢
 */
public class MutilThreadMysqlExtracter implements Callable {
    private Logger logger = LoggerFactory.getLogger(MysqlExtracter.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    private String sql;
    public MutilThreadMysqlExtracter(JdbcTemplate jdbcTemplate,String sql){
        this.jdbcTemplate = jdbcTemplate;
        this.sql = sql;
    }
    @Override
    public Object call() throws Exception {
        List<DataModel> datas = jdbcTemplate.query(sql,new BeanPropertyRowMapper(DataModel.class));
        logger.info("job get data counts:" + datas.size());
        return datas;
    }
}

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

@ -9,7 +9,9 @@ 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.
@ -19,19 +21,64 @@ public class MysqlExtracter implements Extracter {
    private Logger logger = LoggerFactory.getLogger(MysqlExtracter.class);
    private int numPerPage = 100000; //一次性最多查询10万条
    @Autowired
    private JdbcTemplate jdbcTemplate;
   /* @Override
    public List<ExtractModel> extract() {
        return null;
    }*/
    @Override
    public List<DataModel> extractDataByJobConfigsql(String sql) {
        List<DataModel> datas = jdbcTemplate.query(sql,new BeanPropertyRowMapper(DataModel.class));
        logger.info("job get data counts:" + datas.size());
        List<DataModel> datas = new ArrayList<>();
        getDataByThread(sql);
        return datas;
    }
    /**
     * 根据数据量采用多线程分页查询数据
     * @param sql
     * @return
     */
    public List<DataModel> getDataByThread(String sql){
        List<DataModel> datas = new ArrayList<>();
        int size = this.getCount(sql);
        int number = size / numPerPage + 1;
        ExecutorService fixedThreadPool =  Executors.newFixedThreadPool(number);
        List<Callable<List<DataModel>>> threadList = new ArrayList<>();
        try {
            for (int i = 0; i < number; i++) {
                StringBuilder limitSql = new StringBuilder();
                limitSql.append(sql)
                        .append(" limit ")
                        .append((int)(i * numPerPage))
                        .append(",")
                        .append(numPerPage);
                MutilThreadMysqlExtracter mutilThreadMysqlExtracter = new MutilThreadMysqlExtracter(jdbcTemplate, limitSql.toString());
                threadList.add(mutilThreadMysqlExtracter);
            }
            long start = System.currentTimeMillis();
            logger.info("start time:" + String.valueOf(start));
            List<Future<List<DataModel>>> futureList = fixedThreadPool.invokeAll(threadList);
            //取回线程执行的结果
            for (Future future : futureList) {
                datas.addAll((List<DataModel>) future.get());
            }
            logger.info("coast time:" + String.valueOf(System.currentTimeMillis() - start));
        } catch (Exception e) {
            logger.error("MutilThreadMysqlExtracter call failed!");
        }finally {
            fixedThreadPool.shutdown();
        }
        return datas;
    }
    /**
     * 统计有多少条数据
     * @param sql
     * @return
     */
    public Integer getCount(String sql){
        String countSql = "select count(*) from " + sql.split("from")[1];
        Integer count = jdbcTemplate.queryForObject(countSql,Integer.class);
        return count;
    }
}

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

@ -99,7 +99,8 @@ public class Mysql2ESJob implements Job {
        //1抽取数据
        String sql = this.flJobConfig.getSql();
        String sqlFiled = this.flJobConfig.getSqlField();
        this.finalSql = getJobConfigSql(sql,sqlFiled,sqlFiledCondition,sqlFiledValue);
//        this.finalSql = getJobConfigSql(sql,sqlFiled,sqlFiledCondition,sqlFiledValue);
        this.finalSql = getFinalSql(sql,sqlFiled,sqlFiledCondition,sqlFiledValue);
    }
    /**
@ -178,7 +179,13 @@ public class Mysql2ESJob implements Job {
            result.append(" where ").append(sqlFiledString.toString());
        }
        /*if (sqlFiledValue.contains(",") && sql.contains("where")) {
        return result.toString();
    }
    public String getFinalSql(String sql, String sqlFiled, String sqlFiledCondition, String sqlFiledValue) {
        StringBuilder result = new StringBuilder();
        result.append(sql).append(" ");
        if (sqlFiledValue.contains(",") && sql.contains("where")) {
            String[] sqlFiledValues = sqlFiledValue.split(",");
            result.append("and ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValues[1]+"\'").append(" and ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValues[0]+"\'");
        }else if(sql.contains("where")){
@ -189,9 +196,8 @@ public class Mysql2ESJob implements Job {
            result.replace(result.indexOf("$"),result.indexOf("$")+1,otherCondition.toString());
        }else {
            result.append("where ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValue+"\'");
        }*/
        }
        return result.toString();
    }
}

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

@ -10,12 +10,10 @@ import java.io.Serializable;
public class SaveModel implements Serializable{
    @JestId
    private String id;
    /**
     * 存入elasticsearch的id由 idcard,sex,parentCode,labelName,labelCode MD5加密而成。不用es自动生成的_id,实现数据插入排重
     * 存入elasticsearch的id由 idcard,parentCode,labelName,labelCode MD5加密而成。不用es自动生成的_id,实现数据插入排重
     */
    private String modelId;
    private String id;
    /**
     * 身份证
@ -43,17 +41,8 @@ public class SaveModel implements Serializable{
    /**
     * 创建时间
     */
    private String createTime;
    public String getModelId() {
        return modelId;
    }
    public void setModelId(String modelId) {
        this.modelId = modelId;
    }
    public String getIdcard() {
        return idcard;
    }

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

@ -104,10 +104,8 @@ public class JobService {
        //表里设置的增量查询类型和增量查询初始值,如果值没有配置,以当前时间为准
        if(!StringUtils.isEmpty(flJobConfigVO.getSqlFieldValue())){
            params.put("sqlFiledValue",flJobConfigVO.getSqlFieldValue());
            //params.put(flJobConfigVO.getSqlField(),flJobConfigVO.getSqlFieldValue());
        }else{
            params.put("sqlFiledValue", DateFormatUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
            //params.put(flJobConfigVO.getSqlField(), DateFormatUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
        }
        params.put("sqlFiledCondition", ">");
        if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
@ -118,7 +116,7 @@ public class JobService {
    }
    public void startNowById(String id) throws Exception {
        FLJobConfig FLJobConfig = flJobConfigDao.findById(Long.valueOf(id));
        FLJobConfig FLJobConfig = flJobConfigDao.findOne(id);
        FLJobConfig flJobConfigVO = new FLJobConfig();
        BeanUtils.copyProperties(FLJobConfig, flJobConfigVO);
@ -126,11 +124,9 @@ public class JobService {
        Map<String, Object> params = new HashMap<>();
        params.put("jobConfig", flJobConfigVO.getId());
        if(!StringUtils.isEmpty(flJobConfigVO.getSqlFieldValue())){
            params.put("sqlFiledValue",flJobConfigVO.getSqlFieldValue());
            //params.put(flJobConfigVO.getSqlField(),flJobConfigVO.getSqlFieldValue());
            params.put(flJobConfigVO.getSqlField(),flJobConfigVO.getSqlFieldValue());
        }else{
            params.put("sqlFiledValue", DateFormatUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
            //params.put(flJobConfigVO.getSqlField(), DateFormatUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
            params.put(flJobConfigVO.getSqlField(), DateFormatUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
        }
        params.put("sqlFiledCondition", ">");
        //往quartz框架添加任务

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

@ -11,7 +11,9 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
 *@author lith on 2018.03.23
 */
@Component
public class Store2ES implements Storager {

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

@ -1,12 +1,57 @@
package com.yihu.wlyy.figure.label.storage;
import com.yihu.base.hbase.HBaseAdmin;
import com.yihu.base.hbase.HBaseHelper;
import com.yihu.base.hbase.TableBundle;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.BeanUtil;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * lith 2018.03.23
 */
public class Store2Hbase implements Storager {
    private Logger logger = LoggerFactory.getLogger(Store2Hbase.class);
    @Autowired
    private HBaseHelper hBaseHelper;
    @Autowired
    private HBaseAdmin hBaseAdmin;
    @Override
    public void save(List<SaveModel> modelList) {
        if(CollectionUtils.isEmpty(modelList)){
            return;
        }
        String[] fieldName = BeanUtil.getFiledName(modelList.get(0));
        try {
            if(!hBaseAdmin.isTableExists(ConstantUtil.figure_label_hbase_table)){
                hBaseAdmin.createTable(ConstantUtil.figure_label_hbase_table,fieldName);
            }
        }catch (Exception e){
            logger.error("invalid hbase table:" + ConstantUtil.figure_label_hbase_table);
        }
        TableBundle tableBundle = new TableBundle();
        for (SaveModel saveModel : modelList) {
            tableBundle.addFamily(saveModel.getId(), ConstantUtil.figure_label_familyA);
            tableBundle.addColumns(saveModel.getId(), ConstantUtil.figure_label_familyA,fieldName);
            Map<String,String> map = BeanUtil.beanToMap(saveModel);
            tableBundle.addValues(saveModel.getId(), ConstantUtil.figure_label_familyA,map);
        }
        hBaseHelper.save(ConstantUtil.figure_label_hbase_table,tableBundle);
        logger.info("save to hbase count:" + modelList.size());
    }
}
}

+ 63 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/BeanUtil.java

@ -0,0 +1,63 @@
package com.yihu.wlyy.figure.label.util;
import org.apache.commons.lang3.StringUtils;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
/**
 * @project patient-co-figure-label
 * @author litaohong on 2018/3/27
 */
public class BeanUtil {
    /**
     * 获取类字段名
     * @param obj
     * @return
     */
    public static String[] getFiledName(Object obj) {
        try {
            Field[] fields = obj.getClass().getDeclaredFields();
            String[] fieldNames = new String[fields.length];
            for (int i = 0; i < fields.length; i++) {
                //id字段去掉
                if(StringUtils.equals("id",fields[i].getName())){
                    continue;
                }
                fieldNames[i] = fields[i].getName();
            }
            return fieldNames;
        } catch (SecurityException e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 将对象转换成map
     * @param obj
     * @return
     * @throws IllegalAccessException
     */
    public static Map<String, String> beanToMap(Object obj) {
        Map<String, String> map = new HashMap<>();
        try {
            Class<?> clazz = obj.getClass();
            for (Field field : clazz.getDeclaredFields()) {
                //id字段去掉
                if (StringUtils.equals("id", field.getName())) {
                    continue;
                }
                field.setAccessible(true);
                String fieldName = field.getName();
                Object value = field.get(obj);
                map.put(fieldName, value.toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return map;
    }
}

+ 3 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/ConstantUtil.java

@ -4,4 +4,7 @@ public class ConstantUtil {
    public static final String figure_label_es_index = "figure_label_index";
    public static final String figure_label_es_type = "figure_label_type";
    public static final String date_format = "yyyy-MM-dd HH:mm:ss";
    public static final String figure_label_hbase_table = "figure_label";
    public static final String figure_label_familyA = "label_cloumn";
}

+ 4 - 4
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/MakeModelIDUtil.java

@ -3,7 +3,7 @@ package com.yihu.wlyy.figure.label.util;
import com.yihu.wlyy.figure.label.model.DataModel;
import org.springframework.util.StringUtils;
public class MakeModelIDUtil {
public class MakeIDUtil {
    /**
     * 生成存入es的id,确保数据不会重复
@ -12,7 +12,7 @@ public class MakeModelIDUtil {
     * @param labelValue
     * @return
     */
    public static String makeModelID(DataModel dataModel,String labelValue) {
    public static String makeSaveModelID(DataModel dataModel, String labelValue) {
        StringBuilder idStr = new StringBuilder();
        idStr.append(dataModel.getIdcard()).append("-")
                .append(dataModel.getParentCode()).append("-")
@ -32,8 +32,8 @@ public class MakeModelIDUtil {
        dataModel.setLabelCode("1");
        dataModel.setLabelName("健康人群");
        String MD5ID = makeModelID(dataModel,"165cm");
//        String MD5ID = makeModelID(dataModel,"");
        String MD5ID = makeSaveModelID(dataModel,"165cm");
//        String MD5ID = makeSaveModelID(dataModel,"");
        System.out.println(MD5ID);
        System.out.println(MD5ID.length());
    }

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

@ -23,4 +23,12 @@ quartz:
JobService:
  sleepTime: 40000
  sleepTime: 40000
hadoop:
  hbase-properties:
    hbase.zookeeper.property.clientPort: 2181
    zookeeper.znode.parent: /hbase-unsecure
    hbase.zookeeper.quorum:  node1.hde.h3c.com,node2.hde.h3c.com,node3.hde.h3c.com
  user:
    name: root

+ 13 - 7
patient-co/patient-co-wlyy/pom.xml

@ -28,11 +28,6 @@
    <dependencies>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>common-logback-starter</artifactId>
            <version>1.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>common-entity</artifactId>
@ -431,7 +426,7 @@
            <version>2.4.1.0</version>
        </dependency>
        <!--elasticsearch start-->
        <dependency>
  <!--      <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>2.4.4</version>
@ -440,7 +435,7 @@
            <groupId>io.searchbox</groupId>
            <artifactId>jest</artifactId>
            <version>2.4.0</version>
        </dependency>
        </dependency>-->
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
@ -482,6 +477,17 @@
            <version>4.3.10.RELEASE</version>
        </dependency>
        <!--拼音https://mvnrepository.com/artifact/org.clojars.cbilson/pinyin4j end-->
        <dependency>
            <groupId>com.googlecode.log4jdbc</groupId>
            <artifactId>log4jdbc</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>wlyy</finalName>

+ 3 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/Application.java

@ -7,6 +7,7 @@ import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAu
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.elasticsearch.jest.JestAutoConfiguration;
import org.springframework.context.ApplicationContext;
/**
@ -17,7 +18,8 @@ import org.springframework.context.ApplicationContext;
        ElasticsearchAutoConfiguration.class,
        ElasticsearchRepositoriesAutoConfiguration.class,
        ElasticsearchDataAutoConfiguration.class,
        RedisRepositoriesAutoConfiguration.class
        RedisRepositoriesAutoConfiguration.class,
        JestAutoConfiguration.class
})
public class Application {
    public static ApplicationContext ctx = null;

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -1584,7 +1584,7 @@ public class DoctorInfoService extends BaseService {
        Doctor doctor = doctorDao.findByCode(doctorCode);
        boolean b = updateAuthenticationPassword(doctor.getIdcard(),doctor.getCheckPassword(),"11111111",doctorCode);
        boolean b = updateAuthenticationPassword(doctor.getIdcard(),Base64Utils.decryptBASE64(doctor.getCheckPassword()),"11111111",doctorCode);
        if(b){
            doctor.setCheckPassword("");
            doctor.setIscertified(0);

+ 13 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/iot/IotDeviceService.java

@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.stereotype.Service;
@ -201,7 +202,8 @@ public class IotDeviceService {
    public String upload(JSONObject json){
        json.put("access_token",accessToken);
        json.put("data_source",dataSource);
        String url = baseUrl+"/dataInput/input";
//        String url = baseUrl+"/dataInput/input";
        String url = baseUrl+"input";
        String response = httpClientUtil.iotPostBody(url, json.toString());
        return response;
    }
@ -544,13 +546,18 @@ public class IotDeviceService {
     * @return
     */
    public String initData(){
        Integer page = 1;
        Integer page = 2;
        Integer size = 1000;
        Integer start = (page-1)*size;
//        String sql = "SELECT i.id,i.user,i.value1,i.value2,i.value3,i.value4,i.type,i.record_date,i.device_sn,i.status,i.del,d.device_name,d.user_type,p.name,p.idcard " +
//                "from device.wlyy_patient_health_index i " +
//                "LEFT JOIN wlyy_patient_device d on i.`user` = d.`user` and i.device_sn = d.device_sn " +
//                "LEFT JOIN wlyy_patient p on i.`user` = p.code order by i.id limit ?,1000";
        String sql = "SELECT i.id,i.user,i.value1,i.value2,i.value3,i.value4,i.type,i.record_date,i.device_sn,i.status,i.del,d.device_name,d.user_type,p.name,p.idcard " +
                "from device.wlyy_patient_health_index i " +
                "LEFT JOIN wlyy_patient_device d on i.`user` = d.`user` and i.device_sn = d.device_sn " +
                "LEFT JOIN wlyy_patient p on i.`user` = p.code order by i.id limit ?,1000";
                "LEFT JOIN wlyy_patient_device_copy d on i.`user` = d.`user` and i.device_sn = d.device_sn " +
                "LEFT JOIN wlyy_patient_copy p on i.`user` = p.code order by i.id limit ?,1000";
        List<JSONObject> list = jdbcTemplate.query(sql,new Object[]{start}, new ResultSetExtractor<List<JSONObject>>() {
            @Override
            public List<JSONObject> extractData(ResultSet resultSet) throws SQLException, DataAccessException {
@ -586,7 +593,7 @@ public class IotDeviceService {
                    DeviceHealthyInfoMapping info = new DeviceHealthyInfoMapping();
                    info.setCreateTime(new Date());
                    info.setIndexId(one.getLong("id"));
                    info.setRid(one.getJSONObject("obj").getJSONArray("rid").getString(0));
                    info.setRid(re.getJSONObject("obj").getJSONArray("rid").getString(0));
                    infos.add(info);
                }
            });
@ -595,7 +602,7 @@ public class IotDeviceService {
            //下一次
            page++;
            start = (page-1)*size;
            list = jdbcTemplate.queryForList(sql,new Object[]{start},JSONObject.class);
            list = jdbcTemplate.query(sql,new Object[]{start},new BeanPropertyRowMapper(JSONObject.class));
        }
        return null;

+ 20 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java

@ -22,10 +22,13 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
/**
@ -200,11 +203,25 @@ public class DataHandingService {
        boolean flag = true;
        try {
            String sql = " select * from wlyy_doctor where check_password is not null and check_password <> ''";
            List<Doctor> list =  jdbcTemplate.queryForList(sql,Doctor.class);
//            List<Doctor> list =  jdbcTemplate.query(sql, new RowMapper<Doctor>() {
//                @Override
//                public Doctor mapRow(ResultSet resultSet, int i) throws SQLException {
//                    Doctor doctor = new Doctor();
//                    doctor.setId(resultSet.getLong("id"));
//                    doctor.setCode(resultSet.getString("code"));
//                    doctor.setCheckPassword(resultSet.getString("check_password"));
//                    return doctor;
//                }
//            });
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
            List<Doctor> result = new ArrayList<>();
            list.stream().forEach(one->{
                one.setCheckPassword(Base64Utils.encryptBASE64(one.getCheckPassword()));
                result.add(one);
                Doctor d = doctorDao.findByCode(one.get("code")!=null?one.get("code").toString():"");
                if(d!=null){
                    d.setCheckPassword(Base64Utils.encryptBASE64(d.getCheckPassword()));
                    result.add(d);
                }
            });
            doctorDao.save(result);
        }catch (Exception e){

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -2008,7 +2008,7 @@ public class DoctorController extends BaseController {
    public String resetAuthenticationPassword(@RequestParam(value = "strNewCalledPasswd",required = true) String strNewCalledPasswd){
        try {
            Doctor doctor = doctorInfoService.findDoctorByCode(getUID());
            boolean b = doctorInfoService.updateAuthenticationPassword(doctor.getIdcard(),doctor.getCheckPassword(),strNewCalledPasswd,getUID());
            boolean b = doctorInfoService.updateAuthenticationPassword(doctor.getIdcard(),Base64Utils.decryptBASE64(doctor.getCheckPassword()),strNewCalledPasswd,getUID());
            if(b){
                return write(200, "重置密码成功!", "data", b);
            }

+ 2 - 1
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -35,7 +35,8 @@ im:
#物联网配置
iot:
  url: http://192.168.131.24:8088/svr-iot/
#  url: http://192.168.131.24:8088/svr-iot/
  url: http://localhost:10050/svr-iot/
wechat:
  appId: wx1f129f7b51701428

+ 4 - 4
patient-co/patient-co-wlyy/src/main/resources/logback.xml

@ -23,7 +23,7 @@
        </encoder>
    </appender>
    <appender name="business_m" class="com.yihu.base.es.ElasticsearchAppender">
  <!--  <appender name="business_m" class="com.yihu.base.es.ElasticsearchAppender">
        <hosts>http://172.19.103.68:9200</hosts>
        <index>business</index>
        <type>business</type>
@ -36,7 +36,7 @@
        <type>interface</type>
        <clusterName>jkzl</clusterName>
        <rolling>year</rolling>
    </appender>
    </appender>-->
    <!-- project default level -->
    <logger name="com.yihu.wlyy" level="INFO"/>
@ -44,12 +44,12 @@
    <logger name="jdbc.sqltiming" level="INFO"/>
    <logger name="com.yihu.wlyy.logs.BusinessLogs" level="INFO" additivity="false">
   <!-- <logger name="com.yihu.wlyy.logs.BusinessLogs" level="INFO" additivity="false">
        <appender-ref ref="business_m"/>
    </logger>
    <logger name="com.yihu.wlyy.logs.InterfaceCallLogs" level="INFO" additivity="false">
        <appender-ref ref="interface_call_m"/>
    </logger>
    </logger>-->
    <!--处方支付日志 start-->