Ver código fonte

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

zd_123 7 anos atrás
pai
commit
aedf6a2151
60 arquivos alterados com 1661 adições e 443 exclusões
  1. 9 0
      common/common-entity/src/main/java/com/yihu/figure_label/entity/FlJobConfig.java
  2. 5 4
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/medicine/PhysicalExaminationController.java
  3. 5 0
      patient-co/patient-co-figure-label/pom.xml
  4. 54 24
      patient-co/patient-co-figure-label/sql/label_es_sql
  5. 14 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/FigureLabelJpa.java
  6. 17 8
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/controller/DataOperationController.java
  7. 4 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/AddressConvert.java
  8. 4 3
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/AgeConvert.java
  9. 5 3
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/BirthConvert.java
  10. 3 4
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ConsultConvert.java
  11. 2 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/Convert.java
  12. 16 9
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ConvertHelper.java
  13. 67 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/EhrHealthProblemConvert.java
  14. 67 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/EhrICD10CMConvert.java
  15. 2 3
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/EvaluateConvert.java
  16. 2 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/FeedbackConvert.java
  17. 0 14
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/HealthConditionConvert.java
  18. 3 3
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/HealthEduArticalConvert.java
  19. 2 3
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsConsultConvert.java
  20. 1 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsDrinkingConvert.java
  21. 2 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsOnlineConvert.java
  22. 1 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsSmokingConvert.java
  23. 2 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/OnLineConsultConvert.java
  24. 3 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/OnlineAppointmentConvert.java
  25. 3 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ReplyInTimeConvert.java
  26. 3 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SexConvert.java
  27. 0 47
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SignDoctorConvert.java
  28. 0 58
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SignStateConvert.java
  29. 0 49
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SignTeamConvert.java
  30. 2 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/WxSubscribeConvert.java
  31. 1 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/ESExtracter.java
  32. 1 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/Extracter.java
  33. 137 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/HbaseExtracter.java
  34. 52 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/MutilThreadSearchSolrIndexExtracter.java
  35. 3 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/MysqlExtracter.java
  36. 3 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Es2EsJob.java
  37. 184 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Hbase2ESJob.java
  38. 2 7
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Mysql2ESJob.java
  39. 2 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Store2ES.java
  40. 12 13
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/MakeIDUtil.java
  41. 4 2
      patient-co/patient-co-figure-label/src/main/resources/application-dev.yml
  42. 1 0
      patient-co/patient-co-figure-label/src/main/resources/application.yml
  43. 2 1
      patient-co/patient-co-figure-label/src/main/resources/logback.xml
  44. 32 6
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/consult/FinishConsultJob.java
  45. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java
  46. 1 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthGuidanceService.java
  47. 170 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/health/bank/CreditLogService.java
  48. 0 83
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/rehabilitation/RehabilitationPlanningService.java
  49. 286 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/rehabilitation/RehabilitationService.java
  50. 2 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java
  51. 141 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/health/bank/CreditsLogController.java
  52. 73 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/image/ImageController.java
  53. 224 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/rehabilitation/RehabilitationController.java
  54. 0 63
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/rehabilitation/RehabilitationPlanningController.java
  55. 10 0
      patient-co/patient-co-wlyy/src/main/resources/application-dev.yml
  56. 3 0
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml
  57. 4 0
      patient-co/patient-co-wlyy/src/main/resources/application-local.yml
  58. 4 0
      patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml
  59. 4 0
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml
  60. 4 0
      patient-co/patient-co-wlyy/src/main/resources/application-test.yml

+ 9 - 0
common/common-entity/src/main/java/com/yihu/figure_label/entity/FlJobConfig.java

@ -26,6 +26,7 @@ public class FlJobConfig extends IdEntity {
    private String sourceType;
    private String source;
    private String datasource;
    private String extractField;
    public String getJobName() {
        return jobName;
@ -122,4 +123,12 @@ public class FlJobConfig extends IdEntity {
    public void setDatasource(String datasource) {
        this.datasource = datasource;
    }
    public String getExtractField() {
        return extractField;
    }
    public void setExtractField(String extractField) {
        this.extractField = extractField;
    }
}

+ 5 - 4
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/medicine/PhysicalExaminationController.java

@ -13,6 +13,7 @@ import com.yihu.mm.util.JSONUtil;
import com.yihu.wlyy.entity.patient.Patient;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -63,7 +64,7 @@ public class PhysicalExaminationController extends WeixinBaseController {
    @ApiOperation(value = "新增预约单/获取咨询编号等信息")
    @RequestMapping(value = "/insertslip",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String insertslip(@ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode, HttpServletRequest req){
    public String insertslip(@ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode, HttpServletRequest req) throws JSONException {
        Patient patient = patientService.findByCode(patientCode);
        int isSignJM = patientService.isSignJM(patientCode);
@ -95,7 +96,7 @@ public class PhysicalExaminationController extends WeixinBaseController {
    @ResponseBody
    public String findQuestion(@ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
                               @ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
                               @ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id) throws IOException {
                               @ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id) throws IOException, JSONException {
        String question = physicalExaminationService.findQuestion(examCode, pb_id, ct_id);
@ -144,7 +145,7 @@ public class PhysicalExaminationController extends WeixinBaseController {
                               @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
                                @ApiParam(name = "type", value = "试题类型(0单选 ,1多选)", required = true)@RequestParam(required = true, name = "type") String type,
                               @ApiParam(name = "dc_answer", value = "问题答案", required = true)@RequestParam(required = true, name = "dc_answer") String dc_answer,
                             @ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode){
                             @ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode) throws JSONException {
        //提交答案
        String result = physicalExaminationService.handleExam(examCode, pb_id, dc_answer, ct_id);
        JSONObject resultJson = new JSONObject(result);
@ -224,7 +225,7 @@ public class PhysicalExaminationController extends WeixinBaseController {
    public String dillphoneimgdata(@RequestParam MultipartFile file,
                              @ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
                              @ApiParam(name = "type", value = "1.脸型  2.舌像  3.声音", required = true)@RequestParam(required = true, name = "type") String type,
                             @ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id){
                             @ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id) throws JSONException {
        String uploadAttachment = physicalExaminationService.uploadAttachment(file);
        JSONObject uploadResult = new JSONObject(uploadAttachment);
        if(physicalExaminationService.getSuccess(uploadResult)){

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

@ -88,6 +88,11 @@
            <artifactId>common-data-hbase-starter</artifactId>
            <version>1.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>common-data-solr-starter</artifactId>
            <version>1.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>

+ 54 - 24
patient-co/patient-co-figure-label/sql/label_es_sql

@ -1,31 +1,61 @@
-- 新增居民标签索引映射
PUT http://172.19.103.45:9200/figure_label_index
{
  "mappings": {
    "figure_label_type": {
      "properties": {
      	"idcard":{
      		"type":"String"
      	},
      	"labelType":{
      		"type":"String"
      	},
      	"labelCode":{
      		"type":"String"
      	},
      	"labelName":{
      		"type":"String"
      	},
      	"labeValue":{
      		"type":"String"
      	},
         "createTime":{
          		"type":"date",
          		"format":"yyyy-MM-dd HH:mm:ss"
        "mappings": {
            "figure_label_type": {
                "properties": {
                    "createTime": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss"
                    },
                    "currentActive": {
                        "type": "boolean"
                    },
                    "id": {
                        "type": "string"
                    },
                    "idcard": {
                        "type": "string"
                    },
                    "labeName": {
                        "type": "string"
                    },
                    "labeValue": {
                        "type": "string"
                    },
                    "labelCode": {
                        "type": "string"
                    },
                    "labelName": {
                        "type": "string"
                    },
                    "labelType": {
                        "type": "string"
                    },
                    "labelValue": {
                        "type": "string"
                    },
                    "modelId": {
                        "type": "string"
                    },
                    "query": {
                        "properties": {
                            "match_all": {
                                "type": "object"
                            }
                        }
                    },
                    "source": {
                        "type": "string"
                    },
                    "sourceTime": {
                        "type": "string"
                    }
                }
            }
        }
      }
    }
  }
}

+ 14 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/FigureLabelJpa.java

@ -2,6 +2,8 @@ package com.yihu.wlyy.figure.label.config.db;
import com.alibaba.druid.pool.DruidDataSource;
import com.yihu.base.SolrHelper;
import com.yihu.base.SolrPool;
import com.yihu.wlyy.figure.label.config.db.properties.DataSourceProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@ -142,4 +144,16 @@ public class FigureLabelJpa {
    public JdbcTemplate thirdJdbcTemplate(@Qualifier("wlyy85DataSource") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }
    @Bean
    public SolrHelper solrHelper() {
        SolrHelper solrHelper = new SolrHelper();
        return solrHelper;
    }
    @Bean
    public SolrPool solrPool() {
        SolrPool solrPool = new SolrPool();
        return solrPool;
    }
}

+ 17 - 8
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/controller/DataOperationController.java

@ -38,19 +38,28 @@ public class DataOperationController extends BaseController{
    @Autowired
    ObjectMapper objectMapper;
    @ApiOperation(value = "根据dictCode删除es数据")
    @RequestMapping(value = "deteleByDictCode", method = RequestMethod.POST)
    public String deleteBydictCode( @ApiParam(name = "dictCode", value = "dictCode", required = true)@RequestParam(value = "dictCode", required = true) String dictCode) throws JobExecutionException {
       long count = deleteData(dictCode);
    @ApiOperation(value = "根据sql删除es数据")
    @RequestMapping(value = "deteleByQuery", method = RequestMethod.POST)
    public String deleteBySql( @ApiParam(name = "sql", value = "sql", required = true)@RequestParam(value = "sql", required = true) String sql) throws JobExecutionException {
       long count = deleteData(sql);
       if(count ==-1){
           return error(-1,"invalid sql");
       }
       return success("删除成功,共计"+ count +"条");
    }
    public long  deleteData(String dictCode){
    public long  deleteData(String sql){
        long start = System.currentTimeMillis();
        TimeUtil.start(logger,"start delete",start);
        String logTitle = "delete es data";
        TimeUtil.start(logger,logTitle,start);
        List<Map<String, Object>>  list = new ArrayList<>();
        String sql = "select * from " + ConstantUtil.figure_label_es_index + "/" +  ConstantUtil.figure_label_es_type + " where dictCode ='" + dictCode + "' limit 10000";
        if((!sql.contains("select") && !sql.contains("SELECT")) || (!sql.contains("from") && !sql.contains("FROM"))){
            return -1;
        }
        if(!sql.contains("limit")){
            sql = sql + " limit 10000";
        }
        list.addAll(elastricSearchHelper.excuceSQL(sql));
        long count = list.size();
        while (list.size() > 0){
@ -58,7 +67,7 @@ public class DataOperationController extends BaseController{
            list = elastricSearchHelper.excuceSQL(sql);
            count+= list.size();
        }
        TimeUtil.finish(logger,"finish delete",start,System.currentTimeMillis());
        TimeUtil.finish(logger,logTitle,start,System.currentTimeMillis());
        return count;
    }

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

@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @author litaohong on 2018/4/12
@ -24,12 +25,11 @@ public class AddressConvert implements Convert{
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict dict = flLabelDictList.get(0);
        for(DataModel dataModel : modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setId(MakeIDUtil.makeSaveModelID(dataModel,dataModel.getLabelValue()));
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dict.getLabelCode());
@ -41,6 +41,8 @@ public class AddressConvert implements Convert{
                return new ArrayList<>();
            }
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;

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

@ -9,7 +9,6 @@ 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.*;
@ -25,7 +24,7 @@ public class AgeConvert implements Convert {
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> models,List<FlLabelDict> flLabelDictList,String sourceType,String source) {
    public List<SaveModel> convert(List<DataModel> models, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict one = flLabelDictList.get(0);
        Map<String,String> map = new HashMap<>();
@ -40,7 +39,8 @@ public class AgeConvert implements Convert {
                    int age = IdCardUtil.getAgeForIdcard(model.getIdcard());
                    String labelCode = getAgeLabelCode(age);
                    SaveModel saveModel = new SaveModel();
                    saveModel.setId(MakeIDUtil.makeSaveModelID(model,""));
                    saveModel.setDictCode(one.getDictCode());
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabelCode(labelCode);
                    saveModel.setLabelName(map.get(labelCode));
@ -58,6 +58,7 @@ public class AgeConvert implements Convert {
                        return;
                    }
                    saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
                    saveModels.add(saveModel);
                }
        );

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

@ -9,12 +9,13 @@ 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.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @author lith on 2018.03.14
 * 生日标签转换器
@ -26,7 +27,7 @@ public class BirthConvert implements Convert {
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> models,List<FlLabelDict> flLabelDictList,String sourceType,String source) {
    public List<SaveModel> convert(List<DataModel> models, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict flLabelDict = flLabelDictList.get(0);
        models.forEach(
@ -38,8 +39,8 @@ public class BirthConvert implements Convert {
                        e.printStackTrace();
                    }
                    SaveModel saveModel = new SaveModel();
                    saveModel.setId(MakeIDUtil.makeSaveModelID(model,birth));
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setDictCode(flLabelDict.getDictCode());
                    saveModel.setLabelCode(flLabelDict.getLabelCode());
                    saveModel.setLabelType(flLabelDict.getParentCode());
                    saveModel.setLabelName(flLabelDict.getLabelName());
@ -57,6 +58,7 @@ public class BirthConvert implements Convert {
                    if(StringUtils.isEmpty(saveModel.getSource())){
                        return;
                    }
                    saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
                    saveModels.add(saveModel);
                }
        );

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

@ -8,9 +8,7 @@ import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
@ -20,18 +18,18 @@ import java.util.*;
 * 咨询问题标签
 */
@Service
public class ConsultConvert implements Convert{
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict dict = flLabelDictList.get(0);
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setId(MakeIDUtil.makeSaveModelID(dataModel,dataModel.getLabelValue()));
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dict.getLabelCode());
@ -43,6 +41,7 @@ public class ConsultConvert implements Convert{
            }
            saveModel.setSourceTime(dataModel.getSourceTime());
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;

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

@ -5,6 +5,7 @@ import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2018/3/7.
@ -12,5 +13,5 @@ import java.util.List;
 */
public interface Convert {
    List<SaveModel> convert(List<DataModel> modelList,List<FlLabelDict> flLabelDictList,String sourceType,String source);
    List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source);
}

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

@ -23,6 +23,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @author lith on 2018.03.14
@ -40,13 +41,18 @@ public class ConvertHelper {
    /**
     * 进行具体标签生成转换
     * @param dataModels
     * @param hbaseDatas
     * @param flLabelDictJob
     * @param sourceType
     * @param source
     * @return
     * @throws Exception
     */
    public List<SaveModel> convert(List<DataModel> dataModels, FlLabelDictJob flLabelDictJob,String sourceType,String source) throws Exception {
    public List<SaveModel> convert(List<DataModel> dataModels, List<Map<String,Object>> hbaseDatas,FlLabelDictJob flLabelDictJob, String sourceType, String source) throws Exception {
        List<SaveModel> saveModels = new ArrayList<>();
        //如果源数据为空
        if(CollectionUtils.isEmpty(dataModels)){
        if(CollectionUtils.isEmpty(dataModels) && CollectionUtils.isEmpty(hbaseDatas)){
            return saveModels;
        }
        //标签job未配置
@ -65,8 +71,8 @@ public class ConvertHelper {
        try {
            Class clazz = Class.forName(flLabelDictJob.getConvertClazz());
            Object obj = ApplicationContextHolderUtil.getContext().getBean(clazz);
            Method method = obj.getClass().getMethod("convert", List.class, List.class,String.class,String.class);
            saveModels = (List<SaveModel>) method.invoke(obj, dataModels, flLabelDictList,sourceType,source);
            Method method = obj.getClass().getMethod("convert", List.class, List.class,List.class,String.class,String.class);
            saveModels = (List<SaveModel>) method.invoke(obj, dataModels, hbaseDatas,flLabelDictList,sourceType,source);
        } catch (Exception e) {
          logger.error("customized class or convert() method not found:" + flLabelDictJob.getConvertClazz());
            e.printStackTrace();
@ -90,13 +96,13 @@ public class ConvertHelper {
        for(DataModel dataModel:dataModels){
            SaveModel saveModel = new SaveModel();
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setId(MakeIDUtil.makeSaveModelID(dataModel,""));
            saveModel.setDictCode(dictCode);
            //只有一种类别
            if(null == basicDictItemHelper.labelDictMap.get(dictCode)){
                logger.error("label dictCode not exist :【" + dictCode+"】");
            //找不到该类别
            if (null == basicDictItemHelper.labelDictMap.get(dictCode)) {
                logger.error("label dictCode not exist :【" + dictCode + "】");
                return new ArrayList<>();
            }
            //只有一种类别
            if(basicDictItemHelper.labelDictMap.get(dictCode).size() == 1){
                List<FlLabelDict> flLabelDictList = basicDictItemHelper.labelDictMap.get(dictCode);
                saveModel.setLabelType(flLabelDictList.get(0).getParentCode());
@ -127,6 +133,7 @@ public class ConvertHelper {
            if(StringUtils.isEmpty(dataModel.getSourceTime())){
                saveModel.setSourceTime(dataModel.getSourceTime());
            }
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;
@ -141,7 +148,7 @@ public class ConvertHelper {
     * @return
     */
    public void generateDataSource(DataModel dataModel,SaveModel saveModel,String sourceType,String sources) {
        if(!StringUtils.endsWithIgnoreCase(SourceTypeEnum.MYSQL.toString(),sourceType) && !StringUtils.endsWithIgnoreCase(SourceTypeEnum.ELASTICSEARCH.toString(),sourceType) ){
        if(!StringUtils.endsWithIgnoreCase(SourceTypeEnum.MYSQL.toString(),sourceType) && !StringUtils.endsWithIgnoreCase(SourceTypeEnum.ELASTICSEARCH.toString(),sourceType) && !StringUtils.endsWithIgnoreCase(SourceTypeEnum.HBASE.toString(),sourceType)){
            return;
        }
        StringBuilder ids = new StringBuilder();

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

@ -0,0 +1,67 @@
package com.yihu.wlyy.figure.label.convert;
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 java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @author litaohong on 2018/5/7
 * @project patient-co-management
 * 医疗云数据,健康问题标签
 */
@Component
public class EhrHealthProblemConvert implements Convert{
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict one = flLabelDictList.get(0);
        hbaseDatas.forEach(
                hbaseMap -> {
                    SaveModel saveModel = new SaveModel();
                    Object idcard = null;
                    // ehr那边 EHR_000017 demographic_id 为身份证编码,优先选择EHR_000017,demographic_id作为补录
                    if(null != hbaseMap.get("EHR_000017")){
                        idcard = hbaseMap.get("EHR_000017");
                    }else if(null != hbaseMap.get("demographic_id")){
                        idcard = hbaseMap.get("demographic_id");
                    }else{
                        return;
                    }
                    saveModel.setIdcard(String.valueOf(idcard));
                    saveModel.setDictCode(one.getDictCode());
                    Object labelCode = hbaseMap.get("health_problem");
                    if(null == labelCode){
                        return;
                    }
                    Object labelName = hbaseMap.get("health_problem_name");
                    if(null == labelName){
                        return;
                    }
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabelCode(String.valueOf(labelCode));
                    saveModel.setLabelName(String.valueOf(labelName));
                    DataModel dataModel = new DataModel();
                    dataModel.setIdstr(String.valueOf(hbaseMap.get("rowkey")));
                    convertHelper.generateDataSource(dataModel,saveModel,sourceType,source);
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
                    saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
                    saveModels.add(saveModel);
                }
        );
        return saveModels;
    }
}

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

@ -0,0 +1,67 @@
package com.yihu.wlyy.figure.label.convert;
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 java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @author litaohong on 2018/5/7
 * @project patient-co-management
 * 医疗云数据,标准疾病诊断标签
 */
@Component
public class EhrICD10CMConvert implements Convert{
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict one = flLabelDictList.get(0);
        hbaseDatas.forEach(
                hbaseMap -> {
                    SaveModel saveModel = new SaveModel();
                    Object idcard = null;
                    // ehr那边 EHR_000017 demographic_id 为身份证编码,优先选择EHR_000017,demographic_id作为补录
                    if(null != hbaseMap.get("EHR_000017")){
                        idcard = hbaseMap.get("EHR_000017");
                    }else if(null != hbaseMap.get("demographic_id")){
                        idcard = hbaseMap.get("demographic_id");
                    }else{
                        return;
                    }
                    saveModel.setIdcard(String.valueOf(idcard));
                    saveModel.setDictCode(one.getDictCode());
                    Object labelCode = hbaseMap.get("diagnosis");
                    if(null == labelCode){
                        return;
                    }
                    Object labelName = hbaseMap.get("diagnosis_name");
                    if(null == labelName){
                        return;
                    }
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabelCode(String.valueOf(labelCode));
                    saveModel.setLabelName(String.valueOf(labelName));
                    DataModel dataModel = new DataModel();
                    dataModel.setIdstr(String.valueOf(hbaseMap.get("rowkey")));
                    convertHelper.generateDataSource(dataModel,saveModel,sourceType,source);
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
                    saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
                    saveModels.add(saveModel);
                }
        );
        return saveModels;
    }
}

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

@ -9,7 +9,6 @@ import org.apache.commons.lang3.StringUtils;
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 java.util.*;
@ -25,12 +24,11 @@ public class EvaluateConvert implements Convert{
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict dict = flLabelDictList.get(0);
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setId(MakeIDUtil.makeSaveModelID(dataModel,dataModel.getLabelValue()));
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dict.getLabelCode());
@ -43,6 +41,7 @@ public class EvaluateConvert implements Convert{
            }
            saveModel.setSourceTime(dataModel.getSourceTime());
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;

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

@ -31,14 +31,13 @@ public class FeedbackConvert implements Convert {
    private Map<String,String> distinctIdcardMap = new HashMap<>();
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict dict = flLabelDictList.get(0);
        Map<String,String> mapES = countESFeedbackByIdcard(modelList);
        Map<String,DataModel> modelMap = distinctIdcard(modelList);
        for(String idcard : modelMap.keySet()){
            SaveModel saveModel = new SaveModel();
            saveModel.setId(MakeIDUtil.makeSaveModelID(modelMap.get(idcard),""));
            int value = 0;
            saveModel.setIdcard(idcard);
            saveModel.setLabelType(dict.getParentCode());
@ -57,6 +56,7 @@ public class FeedbackConvert implements Convert {
            }
            saveModel.setSourceTime(modelMap.get(idcard).getSourceTime());
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;

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

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

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

@ -9,7 +9,7 @@ import org.apache.commons.lang3.StringUtils;
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 java.util.*;
/**
@ -24,7 +24,7 @@ public class HealthEduArticalConvert implements Convert {
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict dict = flLabelDictList.get(0);
        Map<String,String> dictMap = new HashMap<>();
@ -35,7 +35,6 @@ public class HealthEduArticalConvert implements Convert {
        );
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setId(MakeIDUtil.makeSaveModelID(dataModel,dataModel.getLabelValue()));
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dataModel.getLabelCode());
@ -48,6 +47,7 @@ public class HealthEduArticalConvert implements Convert {
            }
            saveModel.setSourceTime(dataModel.getSourceTime());
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;

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

@ -9,7 +9,6 @@ import org.apache.commons.lang3.StringUtils;
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 java.util.*;
@ -25,7 +24,7 @@ public class IsConsultConvert implements Convert {
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict dict = flLabelDictList.get(0);
        // 有咨询code为0,代表有咨询问题
@ -38,7 +37,6 @@ public class IsConsultConvert implements Convert {
        );
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setId(MakeIDUtil.makeSaveModelID(dataModel,""));
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(hasConsult);
@ -49,6 +47,7 @@ public class IsConsultConvert implements Convert {
            }
            saveModel.setSourceTime(dataModel.getSourceTime());
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;

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

@ -22,7 +22,7 @@ public class IsDrinkingConvert implements Convert{
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        // 饮酒code为2,代表未知
        String hasDrinking = "2";

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

@ -24,7 +24,7 @@ public class IsOnlineConvert implements Convert {
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> models,List<FlLabelDict> flLabelDictList,String sourceType,String source) {
    public List<SaveModel> convert(List<DataModel> models, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        if(CollectionUtils.isEmpty(flLabelDictList)){
            return saveModels;
@ -39,7 +39,6 @@ public class IsOnlineConvert implements Convert {
        models.forEach(
                model -> {
                    SaveModel saveModel = new SaveModel();
                    saveModel.setId(MakeIDUtil.makeSaveModelID(model,""));
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabelCode(model.getLabelCode());
@ -51,6 +50,7 @@ public class IsOnlineConvert implements Convert {
                    if(StringUtils.isEmpty(saveModel.getSource())){
                        return;
                    }
                    saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
                    saveModels.add(saveModel);
                }
        );

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

@ -22,7 +22,7 @@ public class IsSmokingConvert implements Convert{
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        // 抽烟code为2,代表未知
        String hasSmoking = "2";

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

@ -24,7 +24,7 @@ public class OnLineConsultConvert implements Convert {
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict dict = flLabelDictList.get(0);
        Map<String,String> dictMap = new HashMap<>();
@ -35,7 +35,6 @@ public class OnLineConsultConvert implements Convert {
        );
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setId(MakeIDUtil.makeSaveModelID(dataModel,""));
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dataModel.getLabelCode());
@ -47,6 +46,7 @@ public class OnLineConsultConvert implements Convert {
            }
            saveModel.setSourceTime(dataModel.getSourceTime());
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;

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

@ -13,6 +13,7 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @author litaohong on 2018/4/12
@ -26,12 +27,11 @@ public class OnlineAppointmentConvert implements Convert{
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict dict = flLabelDictList.get(0);
        for(DataModel dataModel : modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setId(MakeIDUtil.makeSaveModelID(dataModel,dataModel.getLabelValue()));
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dataModel.getParentCode() + "," + dataModel.getLabelCode());
@ -44,6 +44,7 @@ public class OnlineAppointmentConvert implements Convert{
            }
            saveModel.setSourceTime(dataModel.getSourceTime());
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;

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

@ -12,6 +12,7 @@ import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @author litaohong on 2018/4/8
@ -28,12 +29,11 @@ public class ReplyInTimeConvert implements Convert{
    private ElastricSearchHelper elastricSearchHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict dict = flLabelDictList.get(0);
        for(DataModel model:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setId(MakeIDUtil.makeSaveModelID(model,""));
            saveModel.setIdcard(model.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dict.getLabelCode());
@ -45,6 +45,7 @@ public class ReplyInTimeConvert implements Convert{
            if(StringUtils.isEmpty(saveModel.getSource())){
                return new ArrayList<>();
            }
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;

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

@ -23,7 +23,7 @@ public class SexConvert implements Convert{
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> models,List<FlLabelDict> flLabelDictList,String sourceType,String source) {
    public List<SaveModel> convert(List<DataModel> models, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict one = flLabelDictList.get(0);
        Map<String,String> map = new HashMap<>();
@ -35,11 +35,11 @@ public class SexConvert implements Convert{
        models.forEach(
                model -> {
                    SaveModel saveModel = new SaveModel();
                    saveModel.setId(MakeIDUtil.makeSaveModelID(model,""));
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setLabelType(one.getParentCode());
                    String sex = IdCardUtil.getSexForIdcard(model.getIdcard());
                    saveModel.setDictCode(one.getDictCode());
                    saveModel.setLabelCode(sex);
                    saveModel.setLabelName(map.get(sex));
@ -55,6 +55,7 @@ public class SexConvert implements Convert{
                    if(StringUtils.isEmpty(saveModel.getSource())){
                        return;
                    }
                    saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
                    saveModels.add(saveModel);
                }
        );

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

@ -1,47 +0,0 @@
package com.yihu.wlyy.figure.label.convert;
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.StringUtils;
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 java.util.*;
/**
 * @author litaohong on 2018/4/9
 * @project patient-co-management
 * 签约医生
 */
@Component
public class SignDoctorConvert implements Convert {
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict dict = flLabelDictList.get(0);
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setId(MakeIDUtil.makeSaveModelID(dataModel,dataModel.getLabelValue()));
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dataModel.getLabelCode());
            saveModel.setLabelName(dict.getLabelName());
            saveModel.setLabelValue(dataModel.getLabelValue());
            convertHelper.generateDataSource(dataModel,saveModel,sourceType,source);
            if (StringUtils.isEmpty(saveModel.getSource())) {
                return new ArrayList<>();
            }
            saveModel.setSourceTime(dataModel.getSourceTime());
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

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

@ -1,58 +0,0 @@
package com.yihu.wlyy.figure.label.convert;
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.*;
/**
 * zd
 * 2018-03-21
 */
@Component
public class SignStateConvert implements Convert{
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    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);
        Map<String,String> map = new HashMap<>();
        flLabelDictList.forEach(
                fLlabelDict -> {
                    map.put(fLlabelDict.getLabelCode(),fLlabelDict.getLabelName());
                }
        );
        models.forEach(
                model -> {
                    SaveModel saveModel = new SaveModel();
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setId(MakeIDUtil.makeSaveModelID(model,""));
                    saveModel.setLabelCode(model.getLabelCode());
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabelName(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);
                }
        );
        return saveModels;
    }
}

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

@ -1,49 +0,0 @@
package com.yihu.wlyy.figure.label.convert;
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.StringUtils;
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 java.util.*;
/**
 * @author litaohong on 2018/4/9
 * @project patient-co-management
 * 签约团队
 */
@Component
public class SignTeamConvert implements Convert {
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict dict = flLabelDictList.get(0);
        Map<String,String> dictMap = new HashMap<>();
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setId(MakeIDUtil.makeSaveModelID(dataModel,dataModel.getLabelValue()));
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dataModel.getLabelCode());
            saveModel.setLabelName(dict.getLabelName());
            saveModel.setLabelValue(dataModel.getLabelValue());
            convertHelper.generateDataSource(dataModel,saveModel,sourceType,source);
            if (StringUtils.isEmpty(saveModel.getSource())) {
                return new ArrayList<>();
            }
            saveModel.setSourceTime(dataModel.getSourceTime());
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

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

@ -24,7 +24,7 @@ public class WxSubscribeConvert implements Convert {
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict dict = flLabelDictList.get(0);
        // 有咨询code为0,代表有咨询问题
@ -37,7 +37,6 @@ public class WxSubscribeConvert implements Convert {
        );
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setId(MakeIDUtil.makeSaveModelID(dataModel,""));
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(yes);
@ -49,6 +48,7 @@ public class WxSubscribeConvert implements Convert {
            }
            saveModel.setSourceTime(dataModel.getSourceTime());
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;

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

@ -25,7 +25,7 @@ public class ESExtracter implements Extracter{
    private ElasticsearchUtil elasticsearchUtil;
    @Override
    public List<DataModel> extractDataByJobConfigsql(String sql,String datasource){
    public  List<DataModel> extractData(String sql, String datasource){
        List<DataModel> saveModels = new ArrayList<>();
        List<Map<String,Object>> list = elasticsearchUtil.excuteDataModel(sql);
        for(Map<String,Object> tempMap:list){

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

@ -16,7 +16,7 @@ public interface Extracter {
     */
//    List<ExtractModel> extract();
    List<DataModel> extractDataByJobConfigsql(String sql,String datasource);
    List<DataModel> extractData(String sql,String datasource);
}

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

@ -0,0 +1,137 @@
package com.yihu.wlyy.figure.label.extract;
import com.yihu.base.SolrHelper;
import com.yihu.base.hbase.HBaseHelper;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.util.TimeUtil;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CollectionUtils;
import org.apache.solr.common.SolrDocumentList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.hadoop.hbase.HbaseTemplate;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/**
 * @author litaohong on 2018/5/5
 * @project patient-co-management
 * hbase数据抽取器
 */
@Component
public class HbaseExtracter implements Extracter{
    private Logger logger = LoggerFactory.getLogger(HbaseExtracter.class);
    @Autowired
    private SolrHelper solrHelper;
    @Autowired
    private HBaseHelper hBaseHelper;
    private int numPerPage = 1000; //从solr中一次性取得1000条
    @Override
    public List<DataModel> extractData(String sql, String datasource) {
        return null;
    }
    public  List<Map<String,Object>>  extractData(String core, String q, String fq,String extractColumn) {
        List<Map<String,Object>> resultList = new ArrayList<>();
        String[] arr = core.split(";");
        String solrCore = arr[0];
        String table = arr[1];
        //组装提取的列
        String basicFl = "";
        String dFl = "";
        String[] columnArr = extractColumn.split(";");
        if(null != columnArr){
            for(int i = 0;i < columnArr.length; i++){
                if (columnArr[i].contains("basic=")) {
                    basicFl = columnArr[i].split("=")[1];
                } else if (columnArr[i].contains("d=")) {
                    dFl = columnArr[i].split("=")[1];
                }
            }
        }
        List<String> rowkeys = new ArrayList<>();
        rowkeys = getRowkeys(solrCore,q,fq);
        long start = System.currentTimeMillis();
        String logTitle = "get data from hbase";
        TimeUtil.start(logger, logTitle, start);
        Result[] resultArr = hBaseHelper.getResultList(table,rowkeys,basicFl,dFl);
        for(int i = 0; i < resultArr.length; i++){
            List<Cell> ceList = resultArr[i].listCells();
            if(CollectionUtils.isEmpty(ceList)){
                continue;
            }
            Map<String, Object> map = new HashMap();
            map.put("rowkey",rowkeys.get(i));
            Iterator var5 = ceList.iterator();
            while(var5.hasNext()) {
                Cell cell = (Cell)var5.next();
                map.put(Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()), Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
            }
            resultList.add(map);
        }
        TimeUtil.finish(logger, logTitle, start, System.currentTimeMillis());
        logger.info("hbase data counts:" + resultList.size());
        return resultList;
    }
    public List<String> getRowkeys(String core, String q, String fq) {
        List<String> rowkeyList = new ArrayList<>();
        long count = 0;
        try {
            count = solrHelper.count(core, q);
            String[] fqs = {fq};
            rowkeyList = getRowkeysFromSolr(core, q, fqs, 0, count);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("get solr query error");
        }
        return rowkeyList;
    }
    /**
     * 从solr中获取rowkey
     * @param core
     * @param q
     * @param fq
     * @param start
     * @param rows
     * @return
     */
    public List<String> getRowkeysFromSolr(String core,String q,String[] fq,long start,long rows){
        List<String> rowkeyList = new ArrayList<>();
        SolrDocumentList solrDocumentList = null;
        String logTitle = "get rowkeys from solr";
        long startTime = System.currentTimeMillis();
        TimeUtil.start(logger, logTitle, startTime);
        try {
            solrDocumentList = solrHelper.queryfl(core,q,fq,null,"rowkey",start,rows);
        } catch (Exception e) {
            e.printStackTrace();
        }
        long finish = System.currentTimeMillis();
        TimeUtil.finish(logger, logTitle, startTime, finish);
        logger.info("rowkeys counts:" + solrDocumentList.size());
        solrDocumentList.forEach(
                document -> {
                    rowkeyList.add(document.get("rowkey").toString());
                }
        );
        return rowkeyList;
    }
}

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

@ -0,0 +1,52 @@
package com.yihu.wlyy.figure.label.extract;
import com.yihu.base.SolrHelper;
import com.yihu.wlyy.figure.label.model.DataModel;
import org.apache.solr.common.SolrDocumentList;
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;
/**
 * @Author lith 2018/03/23
 * 多线程分页查询mysql数据,因为mysql数据量比较大的时候,会比较慢
 */
public class MutilThreadSearchSolrIndexExtracter implements Callable {
    private Logger logger = LoggerFactory.getLogger(MysqlExtracter.class);
    private SolrHelper solrHelper;
    private String core;
    private String q;
    private String[] fq;
    private long start;
    private long rows;
    public MutilThreadSearchSolrIndexExtracter(SolrHelper solrHelper,String core,String q,String fq,long start,long rows){
        this.solrHelper = solrHelper;
        this.core = core;
        this.q = q;
        this.start = start;
        this.rows = rows;
    }
    @Override
    public Object call() throws Exception {
        List<String> rowkeyList = new ArrayList<>();
        SolrDocumentList solrDocumentList = solrHelper.queryfl(core,q,fq,null,"rowkey",start,rows);
        logger.info("job get data counts:" + solrDocumentList.size());
        solrDocumentList.forEach(
                document -> {
                    rowkeyList.add(document.get("rowkey").toString());
                }
        );
        return rowkeyList;
    }
}

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

@ -9,6 +9,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@ -54,7 +55,7 @@ public class MysqlExtracter implements Extracter {
    }
    @Override
    public List<DataModel> extractDataByJobConfigsql(String sql,String datasource) {
    public List<DataModel> extractData(String sql,String datasource) {
        JdbcTemplate jdbcTemplate = null;
        // 默认的
        if(StringUtils.isEmpty(datasource)){
@ -91,7 +92,7 @@ public class MysqlExtracter implements Extracter {
                StringBuilder limitSql = new StringBuilder();
                limitSql.append(sql)
                        .append(" limit ")
                        .append((int)(i * numPerPage))
                        .append(i * numPerPage)
                        .append(",")
                        .append(numPerPage);
                MutilThreadMysqlExtracter mutilThreadMysqlExtracter = new MutilThreadMysqlExtracter(jdbcTemplate, limitSql.toString());

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

@ -69,6 +69,7 @@ public class Es2EsJob implements Job {
     */
    private long lastDataId;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDataMap paramsMap = context.getJobDetail().getJobDataMap();
        initParams(paramsMap);
@ -132,7 +133,7 @@ public class Es2EsJob implements Job {
     * 提取数据,按数据库中配置的增量条件提取
     */
    public void extract(){
        this.dataModelList = esExtracter.extractDataByJobConfigsql(this.finalSql,"");
        this.dataModelList = esExtracter.extractData(this.finalSql,"");
    }
    /**
@ -142,7 +143,7 @@ public class Es2EsJob implements Job {
        List<SaveModel> list = new ArrayList<>();
        FlLabelDictJob flLabelDictJob = flLabelDictJobDao.findByJobId(this.flJobConfigId);
        try {
            list = convertHelper.convert(this.dataModelList, flLabelDictJob,this.sourceType,this.source);
            list = convertHelper.convert(this.dataModelList, null,flLabelDictJob,this.sourceType,this.source);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }

+ 184 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Hbase2ESJob.java

@ -0,0 +1,184 @@
package com.yihu.wlyy.figure.label.job;
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.FlLabelDictJobDao;
import com.yihu.wlyy.figure.label.enums.JobSqlFieldTypeEnum;
import com.yihu.wlyy.figure.label.extract.HbaseExtracter;
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 org.apache.commons.lang3.time.DateFormatUtils;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2018/3/7.
 */
//@Component
@Service
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class Hbase2ESJob implements Job {
    private Logger logger = LoggerFactory.getLogger(JobController.class);
    @Autowired
    private FlJobConfigDao flJobConfigDao;
    @Autowired
    private FlLabelDictJobDao flLabelDictJobDao;
    @Autowired
    private ConvertHelper convertHelper;
    @Autowired HbaseExtracter hbaseExtracter;
    @Autowired
    Store2ES store2ES;
    @Autowired
    private JobService jobService;
    private FlJobConfig flJobConfig;
    private Long flJobConfigId;
    private String sqlFiledValue;
    private String sqlFiledCondition;
    private List<Map<String,Object>> datas;
    private String sourceType;
    private String source;
    private String datasource;
    private String q;
    private String fq;
    private String extractColumn;
    /**
     * 数据表的id,有些数据是按时间增量查询,有些数据是按表的主键id增量查询
     */
    private long lastDataId;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDataMap paramsMap = context.getJobDetail().getJobDataMap();
        initParams(paramsMap);
        //根据obconfig里配置的sql提取数据
        extract();
        //数据转换
        List<SaveModel> list = convert();
        //转换后的结果
        if (!CollectionUtils.isEmpty(list)) {
            //数据保存
            boolean bool = save(list);
            //增量存储成功后,修改增量的czrq时间为当前时间或主键id为上次获取到的数据的最后的一条的id
            if(StringUtils.endsWithIgnoreCase(this.flJobConfig.getSqlFieldType().toString(), JobSqlFieldTypeEnum.TIME.toString())){
                jobService.updateFieldValuetoCurrentTimeOrId(this.flJobConfigId,null,bool);
            }else if(StringUtils.endsWithIgnoreCase(this.flJobConfig.getSqlFieldType().toString(), JobSqlFieldTypeEnum.NUM.toString())){
                int size = datas.size();
                DataModel dataModel = (DataModel)datas.get(size -1);
                lastDataId = dataModel.getId();
                jobService.updateFieldValuetoCurrentTimeOrId(this.flJobConfigId,this.lastDataId,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.datasource = flJobConfig.getDatasource();
        this.sqlFiledCondition = paramsMap.getString("sqlFiledCondition");
        this.sqlFiledValue = flJobConfig.getSqlFieldValue();
        //没有传增量值,以数据库配置的默认值为查询条件
        if(StringUtils.isEmpty(this.sqlFiledValue)){
            this.sqlFiledValue = this.flJobConfig.getSqlFieldValue();
            this.sqlFiledCondition=">";
        }
        //1抽取数据
        this.q = this.flJobConfig.getSql();
        fq = this.flJobConfig.getSqlField() + ":" + "[" + toSolrTime(this.sqlFiledValue) +" TO *]";
        //要从hbase中查询的列
        this.extractColumn = this.flJobConfig.getExtractField();
    }
    /**
     * 提取数据,按数据库中配置的增量条件提取
     */
    public void extract(){
        this.datas = hbaseExtracter.extractData(this.datasource,this.q,this.fq,this.extractColumn);
    }
    /**
     * 转换
     */
    public List<SaveModel> convert(){
        List<SaveModel> list = new ArrayList<>();
        FlLabelDictJob flLabelDictJob = flLabelDictJobDao.findByJobId(this.flJobConfigId);
        try {
            list = convertHelper.convert(null,this.datas, flLabelDictJob,this.sourceType,this.source);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
        return list;
    }
    /**
     * 保存
     * @param 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;
    }
    /**
     * 转换为Solr时间格式
     * @param datetime
     * @return
     */
    public String toSolrTime(String datetime){
        String solrTime = "";
        String[] timeArr = datetime.split(" ");
        solrTime = timeArr[0] + "T" + timeArr[1]+"Z";
        return solrTime;
    }
}

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

@ -12,21 +12,16 @@ 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;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@ -134,7 +129,7 @@ public class Mysql2ESJob implements Job {
     */
    public void extract(){
        this.dataModelList = mysqlExtracter.extractDataByJobConfigsql(this.finalSql,this.datasource);
        this.dataModelList = mysqlExtracter.extractData(this.finalSql,this.datasource);
    }
    /**
@ -144,7 +139,7 @@ public class Mysql2ESJob implements Job {
        List<SaveModel> list = new ArrayList<>();
        FlLabelDictJob flLabelDictJob = flLabelDictJobDao.findByJobId(this.flJobConfigId);
        try {
            list = convertHelper.convert(this.dataModelList, flLabelDictJob,this.sourceType,this.source);
            list = convertHelper.convert(this.dataModelList, null,flLabelDictJob,this.sourceType,this.source);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }

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

@ -34,7 +34,7 @@ public class Store2ES implements Storager {
        List<String> list = new ArrayList<>();
        int saveCount = 0;
        long start = System.currentTimeMillis();
        String logtitle = "start to loop(save) data,total size:" + modelList.size();
        String logtitle = "loop(save) data,total size:" + modelList.size();
        TimeUtil.start(logger,logtitle,start);
        for(SaveModel saveModel:modelList){
            try {
@ -54,6 +54,6 @@ public class Store2ES implements Storager {
            }
        }
        long finish = System.currentTimeMillis();
        TimeUtil.finish(logger,logtitle,start,finish);
        TimeUtil.finish(logger,"loop(save) data",start,finish);
    }
}

+ 12 - 13
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/MakeIDUtil.java

@ -2,25 +2,27 @@ package com.yihu.wlyy.figure.label.util;
import com.yihu.figure_label.entity.FlLabelDict;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import org.springframework.util.StringUtils;
public class MakeIDUtil {
    /**
     * 生成从mysql获取,后存入es的id,确保数据不会重复
     * id由 idcard,parentCode,labelName,labelCode MD5加密而成。
     * @param dataModel
     * @param labelValue
     * id由 idcard,dictCode,parentCode,labelName,labelCode MD5加密而成。
     * @param saveModel
     * @return
     */
    public static String makeSaveModelID(DataModel dataModel, String labelValue) {
    public static String makeSaveModelID(SaveModel saveModel) {
        StringBuilder idStr = new StringBuilder();
        idStr.append(dataModel.getIdcard()).append("-")
                .append(dataModel.getParentCode()).append("-")
                .append(dataModel.getLabelCode()).append("-")
                .append(dataModel.getLabelName());
       if(!StringUtils.isEmpty(labelValue)){
           idStr.append("-").append(labelValue);
        idStr.append(saveModel.getDictCode())
                .append(saveModel.getIdcard()).append("-")
                .append(saveModel.getLabelType()).append("-")
                .append(saveModel.getLabelCode()).append("-")
                .append(saveModel.getLabelName());
       if(!StringUtils.isEmpty(saveModel.getLabelValue())){
           idStr.append("-").append(saveModel.getLabelValue());
       }
        return MD5Util.GetMD5Code(idStr.toString());
    }
@ -50,9 +52,6 @@ public class MakeIDUtil {
        dataModel.setLabelCode("1");
        dataModel.setLabelName("健康人群");
        String MD5ID = makeSaveModelID(dataModel,"165cm");
//        String MD5ID = makeSaveModelID(dataModel,"");
        System.out.println(MD5ID);
        System.out.println(MD5ID.length());
    }
}

+ 4 - 2
patient-co/patient-co-figure-label/src/main/resources/application-dev.yml

@ -22,14 +22,16 @@ spring:
  data:
    elasticsearch:
      cluster-name: jkzl #es集群的名字
      cluster-nodes: http://11.1.2.28:9300,http://11.1.2.29:9300 # 172.19.103.45:9300,172.19.103.68:9300
      cluster-nodes-jest: http://11.1.2.28:9200,http://11.1.2.29:9200  # http://172.19.103.68:9200,http://172.19.103.45:9200  #多个逗号分割
      cluster-nodes: 172.19.103.45:9300,172.19.103.68:9300 # 11.1.2.28:9300,11.1.2.29:9300
      cluster-nodes-jest: http://172.19.103.68:9200,http://172.19.103.45:9200  #http://11.1.2.28:9200,http://11.1.2.29:9200   #多个逗号分割
      repositories:
        enabled: true
      properties:
        client:
          transport:
            sniff: false #开启嗅探集群  用nginx代理一层过后会出现ip解析失败问题
    solr:
      zk-host: node1.hde.h3c.com,node2.hde.h3c.com:2181/solr

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

@ -26,5 +26,6 @@ spring:
hibernate:
  dialect: org.hibernate.dialect.MySQL5Dialect
  show_sql: false
  ejb:
    naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy

+ 2 - 1
patient-co/patient-co-figure-label/src/main/resources/logback.xml

@ -24,7 +24,8 @@
    </appender>
    <root level="INFO">
    <!--<root level="debug">-->
    <root level="info">
        <!--<appender-ref ref="console" />-->
        <appender-ref ref="rollingFile"/>
    </root>

+ 32 - 6
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/consult/FinishConsultJob.java

@ -44,21 +44,47 @@ public class FinishConsultJob implements Job {
            .append("SELECT id FROM ").append(imDb).append(".doctors d where d.id<>t.patient) ")
            .append("AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(s.last_message_time) > 24*3600 ")
            .append("ORDER BY t.create_time");
            JSONObject userAgent = new JSONObject();
            userAgent.put("uid","admin");
            userAgent.put("admin_token","0a5c5258-8863-4b07-a3f9-88c768528ab4");
            userAgent.put("token","");
            userAgent.put("imei","admin_imei");
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql.toString());
            list.stream().forEach(one->{
                String topicId = one.get("topic_id").toString();
                String topicName = one.get("topic_name").toString();
                JSONObject userAgent = new JSONObject();
                userAgent.put("uid","admin");
                userAgent.put("admin_token","0a5c5258-8863-4b07-a3f9-88c768528ab4");
                userAgent.put("token","");
                userAgent.put("imei","admin_imei");
                logger.info("Got topic to terminate, " + topicId + ": " + topicName + ", last active time: " + one.get("last_message_time"));
                String response = httpUtil.sendLoginGet(server_url+"/doctor/consult/finish_consult","consult="+topicId,userAgent.toString());
                logger.info("FinishConsultJob response....."+response);
            });
            logger.info("FinishConsultJob 处理医生回复后,居民进入了咨询但是没有回复的 咨询也要自动结束.....");
            sql = new StringBuffer();
            sql.append("SELECT s.id session_id,t.id topic_id, t.name topic_name ")
             .append("FROM ").append(imDb).append(".sessions s,").append(imDb).append(".wlyy_consults t ")
             .append("WHERE s.id = t.session_id  AND t.end_message_id IS NULL AND s.last_content_type =14 ")
             .append("AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(s.last_message_time) > 24*3600 and s.type =1 ");
            StringBuffer sql2 = new StringBuffer();
            sql2.append("SELECT a.id from ( ")
             .append(" SELECT * from ").append(imDb).append(".muc_messages WHERE session_id=? ORDER BY `timestamp` desc LIMIT 1,1 ")
             .append(") a, wlyy_doctor d WHERE a.sender_id=d.code ");
            //查找超过24小时,且最后一条消息是居民进入系统的会话id
            List<Map<String,Object>> sessionIdList = jdbcTemplate.queryForList(sql.toString());
            sessionIdList.stream().forEach(one->{
                String sessionId = one.get("session_id").toString();
                String topicId = one.get("topic_id").toString();
                String topicName = one.get("topic_name").toString();
                List<Map<String,Object>> temp = jdbcTemplate.queryForList(sql2.toString(),sessionId);
                if(temp!=null&&temp.size()>=0){
                    logger.info("Got topic to terminate, " + topicId + ": " + topicName + ", last active time: " + one.get("last_message_time"));
                    String response = httpUtil.sendLoginGet(server_url+"/doctor/consult/finish_consult","consult="+topicId,userAgent.toString());
                    logger.info("FinishConsultJob response....."+response);
                }
            });
            logger.info("FinishConsultJob end.....");
        }catch (Exception e){
            logger.error("FinishConsultJob error....."+e.getMessage());

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java

@ -184,6 +184,7 @@ public class SwaggerConfig {
                        regex("/nofilter/.*"),
                        regex("/idc10/.*"),
                        regex("/iot/.*"),
                        regex("/healthBank/.*"),
                        regex("/im_new/.*"),
                        regex("/dataHandling/.*"),
                        regex("/version/.*"),

+ 1 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthGuidanceService.java

@ -4,7 +4,6 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientHealthGuidance;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientHealthGuidanceDao;
@ -112,13 +111,9 @@ public class PatientHealthGuidanceService extends BaseService {
		SignFamily signFamily = signFamilyDao.findByjiatingPatient(guidance.getPatient());
		//家庭医生不存在
		if(signFamily == null){
			 signFamily = signFamilyDao.findBySanshiPatient(guidance.getPatient());
			 if(signFamily==null){
			 	throw new RuntimeException("患者未签约!");
			 }
			 return null;
		}
		guidance.setCzrq(new Date());
		guidance.setCreateTime(new Date());
		guidance.setDel("1");

+ 170 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/health/bank/CreditLogService.java

@ -0,0 +1,170 @@
package com.yihu.wlyy.service.third.health.bank;/**
 * Created by nature of king on 2018/5/7.
 */
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.util.HttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author wangzhinan
 * @create 2018-05-07 9:24
 * @desc wlyy health bank service
 **/
@Service
@Transactional
public class CreditLogService {
    private Logger logger = LoggerFactory.getLogger(CreditLogService.class);
    @Value("${healthBank.url}")
    private String baseUrl;
    //    private String baseUrl = "http://192.168.131.24:8088/svr-iot/";
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 调用第三方积分排名接口
     *
     * @param doctorId
     * @param page
     * @param size
     * @return
     */
    public JSONObject selectByRanking(String doctorId, Integer page, Integer size){
        String sql = "SELECT * FROM wlyy_sign_family WHERE status = 1 AND doctor = '" +doctorId + "'";
        List<SignFamily> signFamilyList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamily.class));
        List<String>  patientIds = new ArrayList<>();
        if (signFamilyList != null && signFamilyList.size() != 0){
            for (SignFamily signFamily:signFamilyList){
                patientIds.add(signFamily.getPatient());
            }
        }
        JSONObject object = new JSONObject();
        object.put("filter",patientIds.toArray());
        object.put("page",page);
        object.put("size",size);
        String url = baseUrl + "selectByRanking";
        String response = null;
        JSONArray data =null;
        JSONObject object1 = null;
        try {
            response = httpClientUtil.iotPostBody(url,object.toString());
            object1 = JSONObject.parseObject(response);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return object1;
    }
    /**
     * 调用添加积分接口
     *
     * @param object
     * @return
     */
    public String insert(JSONObject object){
        String response = null;
        String url =baseUrl + "createCreditsDetail";
        Map<String,String> params = new HashMap<>();
        params.put("creditsDetail",object.toJSONString());
        try {
            response = httpClientUtil.httpPost(url,params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return response;
    }
    /**
     * 按条件查询积分
     *
     * @param object
     * @param page
     * @param size
     * @return
     */
    public JSONObject selectByCondition(JSONObject object,Integer page,Integer size){
        String response = null;
        String url =baseUrl + "findCreditsLogInfo";
        Map<String,String> params = new HashMap<>();
        params.put("creditsDetail",object.toJSONString());
        params.put("page",page.toString());
        params.put("size",size.toString());
        try {
            response = httpClientUtil.httpPost(url,params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return JSONObject.parseObject(response);
    }
    /**
     * 查询账户积分详情
     *
     * @param object
     * @return
     */
    public JSONObject selectAccount(JSONObject object){
        String response = null;
        String url =baseUrl + "selectAccount";
        Map<String,String> params = new HashMap<>();
        params.put("creditsDetail",object.toJSONString());
        try {
            response = httpClientUtil.httpPost(url,params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return JSONObject.parseObject(response);
    }
    /**
     * 查询任务完成情况
     *
     * @param object
     * @param page
     * @param size
     * @return
     */
    public JSONObject selectByTask(JSONObject object,Integer page,Integer size){
        String response = null;
        String url =baseUrl + "findTask";
        Map<String,String> params = new HashMap<>();
        params.put("task",object.toJSONString());
        params.put("page",page.toString());
        params.put("size",size.toString());
        try {
            response = httpClientUtil.httpPost(url,params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return JSONObject.parseObject(response);
    }
}

+ 0 - 83
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/rehabilitation/RehabilitationPlanningService.java

@ -1,83 +0,0 @@
package com.yihu.wlyy.service.third.rehabilitation;
import com.yihu.wlyy.service.third.iot.IotDeviceService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpUtil;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/**
 * 康复计划对接
 * @author humingfen on 2018/5/4.
 */
@Service
public class RehabilitationPlanningService {
    private Logger logger = LoggerFactory.getLogger(IotDeviceService.class);
    @Value("${rehabilitation.url}")
    private String baseUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private HttpUtil httpUtil;
    /**
     * 查询单条
     * @param id
     * @return
     */
    public String getById(String id){
        String url = baseUrl+"planning/findPlanningById?id="+id;
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /**
     * 更新
     * @param jsonData
     * @return
     */
    public String update(String jsonData){
        String url = baseUrl+"planning/updatePlanning";
        JSONObject params = new JSONObject(jsonData);
        String response = httpClientUtil.postBody(url, params);
        return response;
    }
    /**
     * 删除数据
     *
     */
    public void delete(String id) {
        String url = baseUrl+"planning/delPlanning";
        httpUtil.sendPost(url, id);
        /*if("true".equals(res.getString("obj"))){
            logger.info("删除成功!");
        }else {
            logger.error("删除失败,msg="+res.getString("errorMsg"));
        }*/
    }
    /**
     * 添加条件
     * 参数格式:[{"andOr":"and|or","condition":">|=|<|>=|<=|?","field":"<field>","value":"<value>"},<{...}>]
     * @param andOr
     * @param field
     * @param condition
     * @param value
     * @param jsonArray
     */
    /*private void field(String andOr,String field,String condition,String value,JSONArray jsonArray){
        JSONObject json = new JSONObject();
        json.put("andOr",andOr);
        json.put("field",field);
        json.put("condition",condition);
        json.put("value",value);
        jsonArray.add(json);
    }*/
}

+ 286 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/rehabilitation/RehabilitationService.java

@ -0,0 +1,286 @@
package com.yihu.wlyy.service.third.rehabilitation;
import com.yihu.wlyy.service.third.iot.IotDeviceService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
 * 康复计划对接
 * @author humingfen on 2018/5/4.
 */
@Service
public class RehabilitationService {
    private Logger logger = LoggerFactory.getLogger(IotDeviceService.class);
    @Value("${rehabilitation.url}")
    private String baseUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private HttpUtil httpUtil;
    /**
     * 查看康复计划列表
     * @param patientId
     * @param programId
     * @param page
     * @param size
     * @return
     */
    public String getPlanning(String patientId, String programId, Integer page, Integer size) {
        String url = baseUrl + "planning/findPlanningPage";
        if(StringUtils.isNotBlank(patientId)) {
            url += "?patientId=" + patientId;
        }
        if(StringUtils.isNotBlank(programId)) {
            if(url.contains("?")) {
                url += "&programId=" + programId;
            } else {
                url += "?programId=" + programId;
            }
        }
        if(page != null) {
            if(url.contains("?")) {
                url += "&page=" + page;
            } else {
                url += "?page=" + page;
            }
        }
        if(size != null) {
            if(url.contains("?")) {
                url += "&size=" + size;
            } else {
                url += "?size=" + size;
            }
        }
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /**
     * 根据id查询康复计划
     * @param id
     * @return
     */
    public String getPlanningById(String id){
        String url = baseUrl + "planning/findPlanningById?id="+id;
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /**
     * 创建康复计划
     * @param jsonData
     * @return
     */
    public String createPlanning(String jsonData) {
        String url = baseUrl + "planning/createPlanning";
        JSONObject params = new JSONObject(jsonData);
        String response = httpClientUtil.postBody(url, params);
        return response;
    }
    /**
     * 更新康复计划数据
     * @param jsonData
     * @return
     */
    public String updatePlanning(String jsonData){
        String url = baseUrl + "planning/updatePlanning";
        JSONObject params = new JSONObject(jsonData);
        String response = httpClientUtil.postBody(url, params);
        return response;
    }
    /**
     * 删除康复计划数据
     *
     */
    public void delPlanning(String id) {
        String url = baseUrl + "planning/delPlanning";
        Map<String, String> params = new HashMap<String, String>();
        params.put("id", id);
        try {
            httpClientUtil.httpPost(url, params);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /*********************************** 就诊信息 ********************************************/
    /**
     * 根据居民id查看就诊信息
     * @param patientId
     * @return
     */
    public String getInformationByPatientId(String patientId) {
        String url = baseUrl + "information/findInformationByPatientId?patientId=" + patientId;
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /**
     * 查看就诊信息列表
     * @param patientId
     * @param hospital
     * @param page
     * @param size
     * @return
     */
    public String getInformation(String hospital, String patientId, Integer page, Integer size) {
        String url = baseUrl + "information/findInformationPage";
        if(StringUtils.isNotBlank(patientId)) {
            url += "?patientId=" + patientId;
        }
        if(StringUtils.isNotBlank(hospital)) {
            if(url.contains("?")) {
                url += "&hospital=" + hospital;
            } else {
                url += "?hospital=" + hospital;
            }
        }
        if(page != null) {
            if(url.contains("?")) {
                url += "&page=" + page;
            } else {
                url += "?page=" + page;
            }
        }
        if(size != null) {
            if(url.contains("?")) {
                url += "&size=" + size;
            } else {
                url += "?size=" + size;
            }
        }
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /*********************************** 治疗方案 ********************************************/
    /**
     * 治疗方案列表
     * @param name
     * @param page
     * @param size
     * @return
     */
    public String getTreatmentProgram(String name, Integer page, Integer size) {
        String url = baseUrl + "treatmentProgram/findTreatmentProgramPage";
        if(StringUtils.isNotBlank(name)) {
            url += "?name=" + name;
        }
        if(page != null) {
            if(url.contains("?")) {
                url += "&page=" + page;
            } else {
                url += "?page=" + page;
            }
        }
        if(size != null) {
            if(url.contains("?")) {
                url += "&size=" + size;
            } else {
                url += "?size=" + size;
            }
        }
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /**
     * 创建治疗方案
     * @param jsonData
     * @return
     */
    public String createTreatmentProgram(String jsonData) {
        String url = baseUrl + "treatmentProgram/createTreatmentProgram";
        JSONObject params = new JSONObject(jsonData);
        return httpClientUtil.postBody(url, params);
    }
    /**
     * 更新治疗方案
     * @param jsonData
     */
    public String updateTreatmentProgram(String jsonData) {
        String url = baseUrl + "treatmentProgram/updateTreatmentProgram";
        JSONObject params = new JSONObject(jsonData);
        return httpClientUtil.postBody(url, params);
    }
    /*********************************** 康复计划执行情况 *****************************************/
    /**
     * 康复计划执行情况列表
     * @param patientId
     * @param page
     * @param size
     * @return
     */
    public String getPerformance(String patientId, Integer page, Integer size) {
        String url = baseUrl + "performance/findPerformancePage";
        if(StringUtils.isNotBlank(patientId)) {
            url += "?patientId=" + patientId;
        }
        if(page != null) {
            if(url.contains("?")) {
                url += "&page=" + page;
            } else {
                url += "?page=" + page;
            }
        }
        if(size != null) {
            if(url.contains("?")) {
                url += "&size=" + size;
            } else {
                url += "?size=" + size;
            }
        }
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /**
     * 根据居民id获取康复计划执行情况
     * @param patientId
     * @return
     */
    public String getPerformanceByPatientId(String patientId) {
        String url = baseUrl + "performance/findPerformanceByPatientId?patientId=" + patientId;
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /**
     * 创建康复计划执行情况
     * @param jsonData
     */
    public String createPerformance(String jsonData) {
        String url = baseUrl + "performance/createPerformance";
        JSONObject params = new JSONObject(jsonData);
        return httpClientUtil.postBody(url, params);
    }
    /**
     * 更新康复计划执行情况
     * @param jsonData
     */
    public String updatePerformance(String jsonData) {
        String url = baseUrl + "performance/updatePerformance";
        JSONObject params = new JSONObject(jsonData);
        return httpClientUtil.postBody(url, params);
    }
}

+ 2 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java

@ -13,7 +13,6 @@ import com.yihu.wlyy.service.template.DoctorGuidanceTempService;
import com.yihu.wlyy.service.template.DoctorTeamGuidanceService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.third.ylzpay.ThirdOnepayController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -194,7 +193,7 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
                    BusinessLogs.info(BusinessLogs.BusinessType.guidance, getUID(), patient, new JSONObject(guidance));
                    return success("保存成功!");
                } else {
                    return error(-1, "保存失败!");
                    return error(-1, "居民签约已到期,请使用文字回复。");
                }
            } catch (Exception e) {
                error(e);
@ -247,7 +246,7 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
                    doctorGuidanceTempService.countSend(modelCode);
                    return success("保存成功!");
                } else {
                    return error(-1, "保存失败!");
                    return error(-1, "居民签约已到期,请使用文字回复。");
                }
            } catch (Exception e) {
                error(e);

+ 141 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/health/bank/CreditsLogController.java

@ -0,0 +1,141 @@
package com.yihu.wlyy.web.third.health.bank.controller;/**
 * Created by nature of king on 2018/5/7.
 */
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.third.health.bank.CreditLogService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * @author wangzhinan
 * @create 2018-05-07 8:50
 * @desc credit log controller
 **/
@RestController
@RequestMapping(value = "/healthBank",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "积分处理机制")
public class CreditsLogController extends BaseController {
    @Autowired
    private CreditLogService service;
    /**
     * 查询积分排名
     *
     * @param doctorId
     * @param page
     * @param size
     * @return
     */
    @RequestMapping(value = "/findCreditRanking",method = RequestMethod.POST)
    @ApiOperation("查询积分排名")
    public String getById(@ApiParam(name = "doctorId",value = "医生Id")
                              @RequestParam(name = "doctorId")String doctorId,
                                @ApiParam(name = "page", value = "第几页,从1开始")
                              @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
                                @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
                              @RequestParam(value = "size", required = false)Integer size){
        try {
            return write(200,"查询成功","data",service.selectByRanking(doctorId,page,size));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    /**
     * 添加积分
     *
     * @param creditsDetail
     * @return
     */
    @RequestMapping(value = "/insertCredits",method = RequestMethod.POST)
    @ApiOperation("添加积分")
    public String insert(@ApiParam(name = "creditsDetail",value = "居民id集合")
                          @RequestParam(name = "creditsDetail") String creditsDetail){
        try {
            JSONObject object = JSONObject.parseObject(creditsDetail);
            return write(200,"添加成功","data",service.insert(object));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    /**
     * find credits log details
     *
     * @param creditsLogDo
     * @param page
     * @param size
     * @return
     */
    @RequestMapping(value = "/selectDetails",method = RequestMethod.POST)
    @ApiOperation("积分详情")
    public String selectByCondition(@ApiParam(name = "creditsLogDo",value = "积分JSON")
                                    @RequestParam(name = "creditsLogDo") String creditsLogDo,
                                    @ApiParam(name = "page", value = "第几页,从1开始")
                                    @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
                                    @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
                                    @RequestParam(value = "size", required = false)Integer size){
        try {
            JSONObject object = JSONObject.parseObject(creditsLogDo);
            return write(200,"查询成功","data",service.selectByCondition(object,page,size));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    /**
     * 账户积分详情
     *
     * @param creditsDetail
     * @return
     */
    @RequestMapping(value = "/selectAccount",method = RequestMethod.POST)
    @ApiOperation("账户积分情况")
    public String selectAccount(@ApiParam(name = "creditsDetail",value = "积分JSON")
                                    @RequestParam(name = "creditsDetail") String creditsDetail){
        try {
            JSONObject object = JSONObject.parseObject(creditsDetail);
            return write(200,"查询成功","data",service.selectAccount(object));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    /**
     * 查询任务完成情况
     *
     * @param task
     * @param page
     * @param size
     * @return
     */
    @RequestMapping(value = "/selectTasks",method = RequestMethod.POST)
    @ApiOperation("任务完成情况")
    public String selectByTask(@ApiParam(name = "task",value = "任务JSON")
                                    @RequestParam(name = "task") String task,
                                    @ApiParam(name = "page", value = "第几页,从1开始")
                                    @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
                                    @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
                                    @RequestParam(value = "size", required = false)Integer size){
        try {
            JSONObject object = JSONObject.parseObject(task);
            return write(200,"查询成功","data",service.selectByTask(object,page,size));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
}

+ 73 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/image/ImageController.java

@ -0,0 +1,73 @@
package com.yihu.wlyy.web.third.image;
import com.yihu.wlyy.util.HttpClientUtil;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.http.*;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2018/5/10 0010.
 * 这个控制器是为了前端去引入别人服务器的图片放盗取连接的
 */
@Controller
@RequestMapping("image")
public class ImageController {
    @GetMapping(value = "getRemoteByURL")
    public void getImages(
            @ApiParam(name = "imageURL", value = "图片路径", defaultValue = "350200") @RequestParam(value = "imageURL", required = true) String imageURL,
            HttpServletResponse httpServletResponse
    ) throws Exception {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            // 创建httpget.
            HttpGet httpget = new HttpGet(imageURL);
            // 执行get请求.
            CloseableHttpResponse response = httpclient.execute(httpget);
            byte[] bs = new byte[1024];
            //定义每次读取的长度
            int len = -1;
            httpServletResponse.setHeader("content-type", "image/webp");
            httpServletResponse.getOutputStream();
            //循环读取数据,如果读取的数据为-1,说明已经读取了末尾
            InputStream inputStream = response.getEntity().getContent();
            int ch;
            while ((ch = inputStream.read()) != -1) {
                httpServletResponse.getOutputStream().write(ch);
            }
            httpServletResponse.getOutputStream().flush();
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭连接,释放资源
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

+ 224 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/rehabilitation/RehabilitationController.java

@ -0,0 +1,224 @@
package com.yihu.wlyy.web.third.rehabilitation;
import com.yihu.wlyy.service.third.rehabilitation.RehabilitationService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author humingfen on 2018/5/4.
 */
@RestController
@RequestMapping(value = "/rehabilitation",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "康复计划")
public class RehabilitationController extends BaseController {
    @Autowired
    private RehabilitationService rehabilitationService;
    @RequestMapping(value = "/getPlanning", method = RequestMethod.GET)
    @ApiOperation("查看康复计划")
    public String getPlanning(@ApiParam(name = "patientId", value = "居民id", defaultValue = "")
                                     @RequestParam(value = "patientId", required = false) String patientId,
                                 @ApiParam(name = "programId", value = "康复计划id", defaultValue = "")
                                     @RequestParam(value = "programId", required = false) String programId,
                                 @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                     @RequestParam(value = "page", required = false) Integer page,
                                 @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                     @RequestParam(value = "size", required = false) Integer size) {
        try {
            return write(200, "查询成功", "data", rehabilitationService.getPlanning(patientId, programId, page, size));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/getPlanningById", method = RequestMethod.GET)
    @ApiOperation("按id查询")
    public String getPlanningById(@ApiParam(name = "id", value = "id", defaultValue = "")
                           @RequestParam(name = "id", required = true) String id) {
        try {
            return write(200, "查询成功", "data", rehabilitationService.getPlanningById(id));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/createPlanning", method = RequestMethod.POST)
    @ApiOperation("创建康复计划")
    public String createPlanning(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                 @RequestParam(value = "jsonData", required = true)String jsonData) {
        try{
            rehabilitationService.createPlanning(jsonData);
            return success("创建成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/updatePlanning",method = RequestMethod.POST)
    @ApiOperation("更新康复计划数据")
    public String updatePlanning(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                     @RequestParam(value = "jsonData", required = true)String jsonData){
        try {
            rehabilitationService.updatePlanning(jsonData);
            return success("更新成功");
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    @RequestMapping(value = "/delPlanning",method = RequestMethod.POST)
    @ApiOperation("删除康复计划")
    public String delPlanning(@ApiParam(name = "id", value = "id", defaultValue = "")
                                 @RequestParam(name = "id", required = true) String id){
        try {
            rehabilitationService.delPlanning(id);
            return success("删除成功");
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    /**************************************** 康复计划执行情况 *******************************/
    @RequestMapping(value = "/getPerformance", method = RequestMethod.GET)
    @ApiOperation("查看康复计划执行情况列表")
    public String getPerformance(@ApiParam(name = "patientId", value = "居民id", defaultValue = "")
                                     @RequestParam(value = "patientId", required = false) String patientId,
                                 @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                     @RequestParam(value = "page", required = false) Integer page,
                                 @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                     @RequestParam(value = "size", required = false) Integer size){
        try {
            return write(200, "查询成功", "data", rehabilitationService.getPerformance(patientId, page, size));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/getPerformanceByPatientId", method = RequestMethod.GET)
    @ApiOperation("根据居民Id查找康复计划执行情况信息")
    public String getPerformanceByPatientId(@ApiParam(name = "patientId", value = "patientId", defaultValue = "")
                                            @RequestParam(name = "patientId", required = true) String patientId) {
        try {
            return write(200, "查询成功", "data", rehabilitationService.getPerformanceByPatientId(patientId));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/createPerformance", method = RequestMethod.POST)
    @ApiOperation("创建康复计划执行情况")
    public String createPerformance(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                 @RequestParam(value = "jsonData", required = true)String jsonData) {
        try{
            rehabilitationService.createPerformance(jsonData);
            return success("创建成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/updatePerformance",method = RequestMethod.POST)
    @ApiOperation("更新康复计划执行情况数据")
    public String updatePerformance(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                 @RequestParam(value = "jsonData", required = true)String jsonData){
        try {
            rehabilitationService.updatePerformance(jsonData);
            return success("更新成功");
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    /**************************************** 就诊信息 *************************************/
    @RequestMapping(value = "/getInformation", method = RequestMethod.GET)
    @ApiOperation("查看就诊信息")
    public String getInformation(@ApiParam(name = "hospital", value = "就诊医院名称", defaultValue = "")
                                     @RequestParam(value = "hospital", required = false) String hospital,
                                 @ApiParam(name = "patientId", value = "居民id", defaultValue = "")
                                     @RequestParam(value = "patientId", required = false) String patientId,
                                 @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                     @RequestParam(value = "page", required = false) Integer page,
                                 @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                     @RequestParam(value = "size", required = false) Integer size){
        try {
            return write(200, "查询成功", "data", rehabilitationService.getInformation(hospital, patientId, page, size));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/getInformationByPatientId", method = RequestMethod.GET)
    @ApiOperation("根据居民Id查找就诊信息")
    public String getInformationByPatientId(@ApiParam(name = "patientId", value = "patientId", defaultValue = "")
                                            @RequestParam(name = "patientId", required = true) String patientId) {
        try {
            return write(200, "查询成功", "data", rehabilitationService.getInformationByPatientId(patientId));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    /**************************************** 治疗方案 *************************************/
    @RequestMapping(value = "/getTreatmentProgram", method = RequestMethod.GET)
    @ApiOperation("治疗方案列表")
    public String getTreatmentProgram(@ApiParam(name = "name", value = "方案名称", defaultValue = "")
                                          @RequestParam(value = "name", required = false) String name,
                                      @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                          @RequestParam(value = "page", required = false) Integer page,
                                      @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                          @RequestParam(value = "size", required = false) Integer size){
        try {
            return write(200, "查询成功", "data", rehabilitationService.getTreatmentProgram(name, page, size));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/createTreatmentProgram", method = RequestMethod.POST)
    @ApiOperation("创建治疗方案")
    public String createTreatmentProgram(@ApiParam(name = "jsonData", value = "json")
                                         @RequestParam(name = "jsonData", required = true)String jsonData){
        try {
            rehabilitationService.createTreatmentProgram(jsonData);
            return success("创建成功");
        }catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/updateTreatmentProgram", method = RequestMethod.POST)
    @ApiOperation("更新治疗方案")
    public String updateTreatmentProgram(@ApiParam(name = "jsonData", value = "json")
                                         @RequestParam(name = "jsonData", required = true)String jsonData){
        try{
            rehabilitationService.updateTreatmentProgram(jsonData);
            return success("更新成功");
        }catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

+ 0 - 63
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/rehabilitation/RehabilitationPlanningController.java

@ -1,63 +0,0 @@
package com.yihu.wlyy.web.third.rehabilitation;
import com.yihu.wlyy.service.third.rehabilitation.RehabilitationPlanningService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author humingfen on 2018/5/4.
 */
@RestController
@RequestMapping(value = "/rehabilitation",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "康复计划")
public class RehabilitationPlanningController extends BaseController {
    @Autowired
    private RehabilitationPlanningService rehabilitationPlanningService;
    @RequestMapping(value = "/findById",method = RequestMethod.GET)
    @ApiOperation("按id查询")
    public String findById(@ApiParam(name = "id",value = "id",defaultValue = "")
                           @RequestParam(name="id",required = true) String id) {
        try {
            return write(200, "查询成功", "data", rehabilitationPlanningService.getById(id));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/updatePlanning",method = RequestMethod.POST)
    @ApiOperation("修改康复计划数据")
    public String updatePlanning(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                     @RequestParam(value = "jsonData", required = true)String jsonData){
        try {
            rehabilitationPlanningService.update(jsonData);
            return success("更新成功");
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    @RequestMapping(value = "/delPlanning",method = RequestMethod.POST)
    @ApiOperation("删除康复计划")
    public String delHealthIndex(@ApiParam(name = "id",value = "id",defaultValue = "")
                                 @RequestParam(name="id",required = true) String id){
        try {
            rehabilitationPlanningService.delete(id);
            return success("删除成功");
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
}

+ 10 - 0
patient-co/patient-co-wlyy/src/main/resources/application-dev.yml

@ -36,6 +36,16 @@ im:
#物联网配置
iot:
  url: http://192.168.131.24:8088/svr-iot/
#健康银行配置
healthBank:
  url: http://localhost:10051/svr-health-bank/
#康复计划配置
rehabilitation:
  url: http://localhost:10055/svr-rehabilitation/
#康复计划配置
rehabilitation:
  url: http://localhost:10055/svr-rehabilitation/
wechat:
  appId: wxd03f859efdf0873d

+ 3 - 0
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -37,6 +37,9 @@ im:
iot:
#  url: http://192.168.131.24:8088/svr-iot/
  url: http://localhost:10050/svr-iot/
#健康银行配置
healthBank:
  url:http://localhost:10051/svr-health-bank/
#康复计划配置
rehabilitation:

+ 4 - 0
patient-co/patient-co-wlyy/src/main/resources/application-local.yml

@ -33,6 +33,10 @@ im:
iot:
  url: http://192.168.131.24:8088/svr-iot/
#康复计划配置
rehabilitation:
  url: http://localhost:10055/svr-rehabilitation/
wechat:
  appId: wxad04e9c4c5255acf
  appSecret: ae77c48ccf1af5d07069f5153d1ac8d3

+ 4 - 0
patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml

@ -33,6 +33,10 @@ im:
iot:
  url: http://192.168.131.24:8088/svr-iot/
#康复计划配置
rehabilitation:
  url: http://localhost:10055/svr-rehabilitation/
wechat:
  appId: wx1f129f7b51701428
  appSecret: 988f005d8309ed1795939e0f042431fb

+ 4 - 0
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -36,6 +36,10 @@ im:
iot:
  url: http://192.168.131.24:8088/svr-iot/
#康复计划配置
rehabilitation:
  url: http://localhost:10055/svr-rehabilitation/
wechat:
  appId: wxad04e9c4c5255acf
  appSecret: ae77c48ccf1af5d07069f5153d1ac8d3

+ 4 - 0
patient-co/patient-co-wlyy/src/main/resources/application-test.yml

@ -32,6 +32,10 @@ im:
iot:
  url: http://172.19.103.33:8088/svr-iot/
#康复计划配置
rehabilitation:
  url: http://localhost:10055/svr-rehabilitation/
wechat:
  appId: wx1f129f7b51701428
  appSecret: 988f005d8309ed1795939e0f042431fb