suxiaoyang 6 年之前
父节点
当前提交
a555f729c3
共有 100 个文件被更改,包括 7497 次插入344 次删除
  1. 2 1
      common/common-entity/src/main/java/com/yihu/jw/entity/UuidIdentityEntityWithOperator.java
  2. 37 128
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictMedicineDO.java
  3. 17 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictMedicineDistributeOrgDO.java
  4. 48 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictMedicineDosageFormDO.java
  5. 61 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictMedicineSubjectDO.java
  6. 302 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/message/BaseMessageDO.java
  7. 61 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/message/BaseMessageTypeDO.java
  8. 34 28
      common/common-entity/src/main/java/com/yihu/jw/entity/base/user/BaseMenuDO.java
  9. 11 16
      common/common-entity/src/main/java/com/yihu/jw/entity/base/user/BaseRoleMenuDO.java
  10. 24 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/HospitalServiceItemDO.java
  11. 11 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistEvaluateScoreDO.java
  12. 9 9
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistServiceItemDO.java
  13. 32 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  14. 1 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/WechatRequestMapping.java
  15. 65 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/health/house/HealthyHouseMapping.java
  16. 4 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/specialist/SpecialistMapping.java
  17. 17 3
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictMedicineDistributeOrgVO.java
  18. 51 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictMedicineDosageFormVO.java
  19. 64 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictMedicineSubjectVO.java
  20. 43 140
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictMedicineVO.java
  21. 64 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/message/BaseMessageTypeVO.java
  22. 287 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/message/BaseMessageVO.java
  23. 2 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/servicePackage/ServicePackageLogVO.java
  24. 12 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wlyy/HouseUserContant.java
  25. 34 0
      common/common-tracer/pom.xml
  26. 50 0
      common/common-tracer/src/main/java/com/yihu/jw/advice/HttpAdvice.java
  27. 1 1
      server/svr-authentication/pom.xml
  28. 53 0
      server/svr-authentication/readme.md
  29. 8 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyAuthorizationEndpoint.java
  30. 2 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  31. 2 1
      server/svr-zipkin/src/main/java/com/yihu/ZipkinTrackServer.java
  32. 73 15
      sql/init.sql
  33. 92 0
      svr/figure-label/pom.xml
  34. 63 0
      svr/figure-label/sql/label_es_sql
  35. 54 0
      svr/figure-label/sql/mysql.sql
  36. 32 0
      svr/figure-label/src/main/java/com/yihu/FigureLabelApplication.java
  37. 55 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/DruidConfig.java
  38. 159 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/FigureLabelJpa.java
  39. 27 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/HibernateProperties.java
  40. 36 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/properties/DataSourceLoginProperties.java
  41. 195 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/properties/DataSourceProperties.java
  42. 92 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/config/swagger/SwaggerConfig.java
  43. 21 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/config/war/ServletInitializer.java
  44. 17 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/constant/BusinessConstant.java
  45. 46 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/constant/ConstantUtil.java
  46. 440 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/controller/BaseController.java
  47. 77 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/controller/ESDataOperationController.java
  48. 131 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/controller/JobController.java
  49. 50 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/AddressConvert.java
  50. 56 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/AgeConvert.java
  51. 88 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/AgeRangeConvert.java
  52. 91 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/BasicDictItemHelper.java
  53. 67 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/BirthConvert.java
  54. 49 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ConsultConvert.java
  55. 17 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/Convert.java
  56. 246 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ConvertHelper.java
  57. 70 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/EhrHealthProblemConvert.java
  58. 216 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/EhrICD10CMConvert.java
  59. 49 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/EvaluateConvert.java
  60. 122 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/FeedbackConvert.java
  61. 21 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/FollowupStatusConvert.java
  62. 57 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/HealthEduArticalConvert.java
  63. 76 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/HealthEduArticleReceiveConvert.java
  64. 55 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsConsultConvert.java
  65. 60 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsDrinkingConvert.java
  66. 59 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsOnlineConvert.java
  67. 60 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsSmokingConvert.java
  68. 114 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/MutilThreadConvert.java
  69. 54 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/OnLineConsultConvert.java
  70. 56 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/OnlineAppointmentConvert.java
  71. 77 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ReplyInTimeConvert.java
  72. 64 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SexConvert.java
  73. 56 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/WxSubscribeConvert.java
  74. 31 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FLLabelDictDao.java
  75. 69 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FlJobConfigDao.java
  76. 30 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FlLabelDictJobDao.java
  77. 142 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/entity/FlJobConfig.java
  78. 52 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/entity/FlLabelDict.java
  79. 60 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/entity/FlLabelDictJob.java
  80. 38 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/entity/IdEntity.java
  81. 34 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/enums/JobSqlFieldTypeEnum.java
  82. 12 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/enums/SourceTypeEnum.java
  83. 77 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/ESExtracter.java
  84. 22 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/Extracter.java
  85. 150 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/HbaseExtracter.java
  86. 39 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/MutilThreadMysqlExtracter.java
  87. 52 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/MutilThreadSearchSolrIndexExtracter.java
  88. 137 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/MysqlExtracter.java
  89. 155 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Es2EsJob.java
  90. 171 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Hbase2ESJob.java
  91. 239 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Mysql2ESJob.java
  92. 248 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/model/DataModel.java
  93. 170 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/model/SaveModel.java
  94. 100 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/search/controller/SearchController.java
  95. 273 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/search/service/SearchService.java
  96. 5 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/service/ExtractService.java
  97. 170 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/service/JobService.java
  98. 14 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Storager.java
  99. 58 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Store2ES.java
  100. 0 0
      svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Store2Hbase.java

+ 2 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/UuidIdentityEntityWithOperator.java

@ -5,11 +5,12 @@
 *******************************************************************************/
package com.yihu.jw.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Column;

+ 37 - 128
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictMedicineDO.java

@ -9,7 +9,7 @@ import javax.persistence.Table;
/**
 * 药品字典实体
 * 
 * @author Administrator on  2018年09月07日
 * @author litaohong on  2018年09月11日
 *
 */
@Entity
@ -22,69 +22,34 @@ public class DictMedicineDO extends IntegerIdentityEntity {
	private String code;
    /**
	 * 药品名称
	 * 药品中文名
	 */
	private String name;
    /**
	 * 药品规格
	 */
	private String physicSpec;
    /**
	 * 药品科目  科目类别字典中定义
	 */
	private String subjectClass;
    /**
	 * 剂量单位 计量单位字典中定义
	 */
	private String doseUnit;
    /**
	 * 数量单位  计量单位字典中定义
	 */
	private String quantityUnit;
    /**
	 * 包装单位   计量单位字典中定义
	 */
	private String packUnit;
    /**
	 * 最小剂量
	 */
	private double minDose;
    /**
	 * 
	 */
	private double packSpec;
    /**
	 * 零售价
	 * 药品所属科目代码
	 */
	private double retailPrice;
	private String subjectCode;
    /**
	 * 
	 * 药品剂型
	 */
	private String physicForm;
	private String dosageForm;
    /**
	 * 毒理分类  药品毒理分类字典中定义
	 * 药品规格
	 */
	private String toxicologyType;
	private String specification;
    /**
	 * 基本药物标志  0:否;1:是
	 * 包装规格
	 */
	private String basicFlag;
	private String packingSpecification;
    /**
	 * 有效标志 0:无效;1:有效
	 * 适应症
	 */
	private String validFlag;
	private String indication;
    /**
	 * 拼音首码
@ -123,100 +88,44 @@ public class DictMedicineDO extends IntegerIdentityEntity {
        this.name = name;
    }
	@Column(name = "physic_spec")
    public String getPhysicSpec() {
        return physicSpec;
    }
    public void setPhysicSpec(String physicSpec) {
        this.physicSpec = physicSpec;
    }
	@Column(name = "subject_class")
    public String getSubjectClass() {
        return subjectClass;
    }
    public void setSubjectClass(String subjectClass) {
        this.subjectClass = subjectClass;
    }
	@Column(name = "dose_unit")
    public String getDoseUnit() {
        return doseUnit;
    }
    public void setDoseUnit(String doseUnit) {
        this.doseUnit = doseUnit;
    }
	@Column(name = "quantity_unit")
    public String getQuantityUnit() {
        return quantityUnit;
    }
    public void setQuantityUnit(String quantityUnit) {
        this.quantityUnit = quantityUnit;
    }
	@Column(name = "pack_unit")
    public String getPackUnit() {
        return packUnit;
    }
    public void setPackUnit(String packUnit) {
        this.packUnit = packUnit;
    }
	@Column(name = "min_dose")
    public double getMinDose() {
        return minDose;
    }
    public void setMinDose(double minDose) {
        this.minDose = minDose;
    }
	@Column(name = "pack_spec")
    public double getPackSpec() {
        return packSpec;
    }
    public void setPackSpec(double packSpec) {
        this.packSpec = packSpec;
    }
	@Column(name = "retail_price")
    public double getRetailPrice() {
        return retailPrice;
	@Column(name = "subject_code")
    public String getSubjectCode() {
        return subjectCode;
    }
    public void setRetailPrice(double retailPrice) {
        this.retailPrice = retailPrice;
    public void setSubjectCode(String subjectCode) {
        this.subjectCode = subjectCode;
    }
	@Column(name = "physic_form")
    public String getPhysicForm() {
        return physicForm;
	@Column(name = "dosage_form")
    public String getDosageForm() {
        return dosageForm;
    }
    public void setPhysicForm(String physicForm) {
        this.physicForm = physicForm;
    public void setDosageForm(String dosageForm) {
        this.dosageForm = dosageForm;
    }
	@Column(name = "toxicology_type")
    public String getToxicologyType() {
        return toxicologyType;
	@Column(name = "specification")
    public String getSpecification() {
        return specification;
    }
    public void setToxicologyType(String toxicologyType) {
        this.toxicologyType = toxicologyType;
    public void setSpecification(String specification) {
        this.specification = specification;
    }
	@Column(name = "basic_flag")
    public String getBasicFlag() {
        return basicFlag;
	@Column(name = "packing_specification")
    public String getPackingSpecification() {
        return packingSpecification;
    }
    public void setBasicFlag(String basicFlag) {
        this.basicFlag = basicFlag;
    public void setPackingSpecification(String packingSpecification) {
        this.packingSpecification = packingSpecification;
    }
	@Column(name = "valid_flag")
    public String getValidFlag() {
        return validFlag;
	@Column(name = "indication")
    public String getIndication() {
        return indication;
    }
    public void setValidFlag(String validFlag) {
        this.validFlag = validFlag;
    public void setIndication(String indication) {
        this.indication = indication;
    }
	@Column(name = "spell_code")

+ 17 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictMedicineDistributeOrgDO.java

@ -9,7 +9,7 @@ import javax.persistence.Table;
/**
 * 机构药品分发字典实体
 * 
 * @author Administrator on  2018年09月07日
 * @author litaohong on  2018年09月11日
 *
 */
@Entity
@ -26,6 +26,12 @@ public class DictMedicineDistributeOrgDO extends IntegerIdentityEntity {
	 */
	private String medicineCode;
    /**
	 * 分发数量
	 */
	private Integer quantity;
	@Column(name = "org_id")
    public String getOrgId() {
        return orgId;
@ -42,4 +48,14 @@ public class DictMedicineDistributeOrgDO extends IntegerIdentityEntity {
        this.medicineCode = medicineCode;
    }
	@Column(name = "quantity")
    public Integer getQuantity() {
        return quantity;
    }
    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }
}

+ 48 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictMedicineDosageFormDO.java

@ -0,0 +1,48 @@
package com.yihu.jw.entity.base.dict;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 药品剂型字典实体
 * 
 * @author litaohong on  2018年09月11日
 *
 */
@Entity
@Table(name = "dict_medicine_dosage_form")
public class DictMedicineDosageFormDO extends IntegerIdentityEntity {
    /**
	 * 剂型代码
	 */
	private String code;
    /**
	 * 剂型名称(颗粒型,注射液,胶囊等)
	 */
	private String name;
	@Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}

+ 61 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictMedicineSubjectDO.java

@ -0,0 +1,61 @@
package com.yihu.jw.entity.base.dict;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 药品科目类别字典实体
 * 
 * @author litaohong on  2018年09月11日
 *
 */
@Entity
@Table(name = "dict_medicine_subject")
public class DictMedicineSubjectDO extends IntegerIdentityEntity {
    /**
	 * 类别代码
	 */
	private String code;
    /**
	 * 类别名称
	 */
	private String name;
    /**
	 * 父类code
	 */
	private String parentCode;
	@Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "parent_code")
    public String getParentCode() {
        return parentCode;
    }
    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }
}

文件差异内容过多而无法显示
+ 302 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/message/BaseMessageDO.java


文件差异内容过多而无法显示
+ 61 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/message/BaseMessageTypeDO.java


+ 34 - 28
common/common-entity/src/main/java/com/yihu/jw/entity/base/user/BaseMenuDO.java

@ -1,4 +1,4 @@
package com.yihu.jw.entity.base.user;
package com.yihu.jw.entity.base.role;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
@ -8,36 +8,42 @@ import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * BaseMenu entity. @author MyEclipse Persistence Tools
 * @author progr1mmer
 * @date 2018/09/20
 */
@Entity
@Table(name = "base_menu")
public class BaseMenuDO extends UuidIdentityEntityWithOperator implements java.io.Serializable {
public class BaseMenuDO extends UuidIdentityEntityWithOperator {
	private String saasId;
	private String parentId; //父级ID
	private String name; //名称
	private String url; //请求路径
	private String method; //请求方式 get post
	private Integer sort; //排序
	private Integer status; //状态
	private String remark; //备注
	// Constructors
	/** default constructor */
	public BaseMenuDO() {
	}
	/** minimal constructor */
	public BaseMenuDO(String id, Timestamp createTime, Timestamp updateTime) {
		this.id = id;
		this.createTime = createTime;
		this.updateTime = updateTime;
	}
	// Property accessors
	/**
	 * 名称
	 */
	private String name;
	/**
	 * 请求路径
	 */
	private String url;
	/**
	 * 请求方式
	 */
	private String method;
	/**
	 * 排序
	 */
	private Integer sort;
	/**
	 * 父级ID
	 */
	private String parentId;
	/**
	 * 状态
	 */
	private Integer status;
	/**
	 * 备注
	 */
	private String remark;
	@Column(name = "saas_id", length = 50)
	public String getSaasId() {
@ -93,7 +99,7 @@ public class BaseMenuDO extends UuidIdentityEntityWithOperator implements java.i
		this.remark = remark;
	}
	@Column(name = "url", length = 255)
	@Column(name = "url")
	public String getUrl() {
		return url;
	}
@ -102,7 +108,7 @@ public class BaseMenuDO extends UuidIdentityEntityWithOperator implements java.i
		this.url = url;
	}
	@Column(name = "method", length = 255)
	@Column(name = "method")
	public String getMethod() {
		return method;
	}

+ 11 - 16
common/common-entity/src/main/java/com/yihu/jw/entity/base/user/BaseRoleMenuDO.java

@ -1,33 +1,28 @@
package com.yihu.jw.entity.base.user;
package com.yihu.jw.entity.base.role;
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * BaseRoleMenu entity. @author MyEclipse Persistence Tools
 * @author progr1mmer
 * @date 2018/09/20
 */
@Entity
@Table(name = "base_role_menu")
public class BaseRoleMenuDO extends UuidIdentityEntity implements java.io.Serializable {
public class BaseRoleMenuDO extends IntegerIdentityEntity {
	// Fields
	/**
	 * 角色ID
	 */
	private String roleId;
	/**
	 * 菜单ID
	 */
	private String menuId;
	/** default constructor */
	public BaseRoleMenuDO() {
	}
	/** minimal constructor */
	public BaseRoleMenuDO(String id) {
		this.id = id;
	}
	@Column(name = "role_id", length = 50)
	public String getRoleId() {
		return this.roleId;

+ 24 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/HospitalServiceItemDO.java

@ -41,6 +41,12 @@ public class HospitalServiceItemDO extends UuidIdentityEntityWithOperator implem
    @Column(name = "expense")
    private Integer expense;//价格
    @Transient
    private String title;//服务项目名称
    @Transient
    private String content;//服务项目内容
    @Transient
    private Integer flag;//标识(1:社区,2、医院,3、社区、医院)
@ -139,4 +145,22 @@ public class HospitalServiceItemDO extends UuidIdentityEntityWithOperator implem
    public void setImediate(Integer imediate) {
        this.imediate = imediate;
    }
    @Transient
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @Transient
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
}

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistEvaluateScoreDO.java

@ -33,6 +33,8 @@ public class SpecialistEvaluateScoreDO extends UuidIdentityEntityWithOperator im
    @Column(name = "score")
    private Double score;//评论得分
    @Column(name = "patient")
    private String patient;//居民code
    @Column(name = "saas_id")
    public String getSaasId() {
@ -78,4 +80,13 @@ public class SpecialistEvaluateScoreDO extends UuidIdentityEntityWithOperator im
    public void setScore(Double score) {
        this.score = score;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
}

+ 9 - 9
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistServiceItemDO.java

@ -53,13 +53,13 @@ public class SpecialistServiceItemDO extends UuidIdentityEntityWithOperator impl
    private Integer hospitalGrade; //医院等级
    @Column(name = "three_hospitals")
    private Double threeHospitals; //三级医院收费标准
    private Integer threeHospitals; //三级医院收费标准
    @Column(name = "two_hospitals")
    private Double twoHospitals; //二级医院收费标准
    private Integer twoHospitals; //二级医院收费标准
    @Column(name = "one_hospitals")
    private Double oneHospitals;//一级医院以及一级以下的社区医院
    private Integer oneHospitals;//一级医院以及一级以下的社区医院
    @Column(name = "unit")
    private String unit; //计价单位
@ -177,29 +177,29 @@ public class SpecialistServiceItemDO extends UuidIdentityEntityWithOperator impl
    }
    @Column(name = "three_hospitals")
    public Double getThreeHospitals() {
    public Integer getThreeHospitals() {
        return threeHospitals;
    }
    public void setThreeHospitals(Double threeHospitals) {
    public void setThreeHospitals(Integer threeHospitals) {
        this.threeHospitals = threeHospitals;
    }
    @Column(name = "two_hospitals")
    public Double getTwoHospitals() {
    public Integer getTwoHospitals() {
        return twoHospitals;
    }
    public void setTwoHospitals(Double twoHospitals) {
    public void setTwoHospitals(Integer twoHospitals) {
        this.twoHospitals = twoHospitals;
    }
    @Column(name = "one_hospitals")
    public Double getOneHospitals() {
    public Integer getOneHospitals() {
        return oneHospitals;
    }
    public void setOneHospitals(Double oneHospitals) {
    public void setOneHospitals(Integer oneHospitals) {
        this.oneHospitals = oneHospitals;
    }

+ 32 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -372,6 +372,24 @@ public class BaseRequestMapping {
    public static class DictMedicine extends Basic {
        public static final String PREFIX  = "/dictMedicine";
    }
   /**
     * 药品剂型
     */
    public static class DictMedicineDosageForm extends Basic {
        public static final String PREFIX  = "/dictMedicineDosageForm";
    }
   /**
     * 药品字典科目类别
     */
    public static class DictMedicineSubject extends Basic {
        public static final String PREFIX  = "/dictMedicineSubject";
    }
   /**
     * 药品分发机构
     */
    public static class DictMedicineDistributeOrg extends Basic {
        public static final String PREFIX  = "/dictMedicineDistributeOrg";
    }
    /**
     * app版本升级
@ -380,6 +398,20 @@ public class BaseRequestMapping {
        public static final String PREFIX  = "/appVersion";
    }
    /**
     * 基础消息
     */
    public static class BaseMessage extends Basic {
        public static final String PREFIX  = "/baseMessage";
    }
    /**
     * 基础消息类型
     */
    public static class BaseMessageType extends Basic {
        public static final String PREFIX  = "/baseMessageType";
    }
    /**
     * 基于MQ的消息推送
     */

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/WechatRequestMapping.java

@ -71,6 +71,7 @@ public class WechatRequestMapping {
        public static final String api_getById="/template/{id}";
        public static final String api_sendTemplateMessage="/sendTemplateMessage";
        public static final String api_test_template="/test_template";
        public static final String api_getAllTemplate="/api_getAllTemplate";
        public static final String message_success_create="wxTemplate create success";
        public static final String message_success_update="wxTemplate update success";

+ 65 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/health/house/HealthyHouseMapping.java

@ -0,0 +1,65 @@
package com.yihu.jw.rm.health.house;
/**
 * Created by Trick on 2018/2/7.
 */
public class HealthyHouseMapping {
    public static final String api_healthyHouse_common = "svr-healthy-house";
    public static final String api_success = "succes";
    public static class HealthyHouse {
        //系统字典
        public static class SystemDict {
            public static final String CREATE = "/create/systemDict";
            public static final String DELETE = "/delete/systemDict";
            public static final String UPDATE = "/update/systemDict";
            public static final String PAGE = "/page/systemDicts";
            public static final String LIST = "/list/systemDicts";
            public static final String GETDICTBYID = "/getDictionaryById";
            public static final String GETDICTBYPHONETICCODE = "/getDictionaryByPhoneticCode";
            public static final String ISDICTNAMEEXISTS = "/isDictNameExists";
            public static final String ISDICTCODEEXISTS = "/isDictCodeExists";
        }
        //系统字典项
        public static class SystemDictEntry {
            public static final String CREATE = "/create/systemDictEntry";
            public static final String DELETE = "/delete/systemDictEntry";
            public static final String UPDATE = "/update/systemDictEntry";
            public static final String PAGE = "/page/systemDictEntrys";
            public static final String LIST = "/list/systemDictEntrys";
            public static final String GETDICTENTRYBYDICTIDANDCODE = "/getDictEntryByDictIdAndCode";
            public static final String GETDICTENTRYBYDICTIDANDNAME = "/getDictEntryByDictIdAndName";
            public static final String DELETEBYDICTIDANDCODE = "/deleteByDictIdAndCode";
            public static final String ISEXISTSDICTENTRYBYDICTIDANDCODE = "/isExistsDictEntryByDictIdAndCode";
        }
        //设施
        public static class Facilities {
            public static final String CREATE = "/create/facilities";
            public static final String DELETE = "/delete/facilities";
            public static final String UPDATE = "/update/facilities";
            public static final String PAGE = "/page/facilities";
            public static final String LIST = "/list/facilities";
            public static final String GET_FACILITIES_BY_ID = "/getFacilitiesById";
            public static final String GET_FACILITIES_BY_FIELD = "/getFacilitiesByField";
        }
        //设施服务
        public static class FacilitiesServer {
            public static final String CREATE = "/create/facilitieServers";
            public static final String DELETE = "/delete/facilitieServers";
            public static final String UPDATE = "/update/facilitieServers";
            public static final String PAGE = "/page/facilitieServers";
            public static final String LIST = "/list/facilitieServers";
            public static final String GET_FACILITIESERVERS_BY_ID = "/getFacilitieServersById";
            public static final String GET_FACILITIESERVERS_BY_FIELD = "/getFacilitieServersByField";
        }
    }
}

+ 4 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/specialist/SpecialistMapping.java

@ -79,11 +79,14 @@ public class SpecialistMapping {
        public static final String findServiceItemsByHospital = "/findServiceItemsByHospital";
        public static final String serviceDoctorList = "/serviceDoctorList";
        public static final String dailyJob = "/dailyJob";
        public static final String dailyJobReserve = "/dailyJobReserve";
        public static final String appCalendarPlanDetailList = "/appCalendarPlanDetailList";
        public static final String updatePlanDetailStatusById = "/updatePlanDetailStatusById";
        public static final String updatePlanStatusById = "/updatePlanStatusById";
        public static final String planSchedule = "/planSchedule";
        public static final String planListByPatient = "/planListByPatient";
        public static final String patientCount = "/patientCount";
        public static final String selectByIds = "/selectByIds";
    }
    public static class serviceItem{
@ -104,5 +107,6 @@ public class SpecialistMapping {
        public static final String selectByHospital1 = "/selectByHospital1";
        public static final String importData1 = "/importData1";
        public static final String importData2 = "/importData2";
        public static final String selectByDoctor = "/selectByDoctor";
    }
}

+ 17 - 3
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictMedicineDistributeOrgVO.java

@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty;
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * Administrator 	1.0  2018年09月07日 Created
 * litaohong 	1.0  2018年09月11日 Created
 *
 * </pre>
 * @since 1.
@ -23,15 +23,21 @@ public class DictMedicineDistributeOrgVO extends IntegerIdentityVO{
    /**
	 * 机构编码
	 */
	@ApiModelProperty(value = "机构编码", example = "")
	@ApiModelProperty(value = "机构编码", example = "模块1")
    private String orgId;
    /**
	 * 药品代码
	 */
	@ApiModelProperty(value = "药品代码", example = "")
	@ApiModelProperty(value = "药品代码", example = "模块1")
    private String medicineCode;
    /**
	 * 分发数量
	 */
	@ApiModelProperty(value = "分发数量", example = "模块1")
    private Integer quantity;
    public String getOrgId() {
        return orgId;
@ -47,4 +53,12 @@ public class DictMedicineDistributeOrgVO extends IntegerIdentityVO{
        this.medicineCode = medicineCode;
    }
    public Integer getQuantity() {
        return quantity;
    }
    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }
}

+ 51 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictMedicineDosageFormVO.java

@ -0,0 +1,51 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.IntegerIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * 
 * 药品剂型字典vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年09月11日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "DictMedicineDosageFormVO", description = "药品剂型字典")
public class DictMedicineDosageFormVO extends IntegerIdentityVO{
    /**
	 * 剂型代码
	 */
	@ApiModelProperty(value = "剂型代码", example = "模块1")
    private String code;
    /**
	 * 剂型名称(颗粒型,注射液,胶囊等)
	 */
	@ApiModelProperty(value = "剂型名称(颗粒型,注射液,胶囊等)", example = "模块1")
    private String name;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}

+ 64 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictMedicineSubjectVO.java

@ -0,0 +1,64 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.IntegerIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * 
 * 药品科目类别字典vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年09月11日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "DictMedicineSubjectVO", description = "药品科目类别字典")
public class DictMedicineSubjectVO extends IntegerIdentityVO{
    /**
	 * 类别代码
	 */
	@ApiModelProperty(value = "类别代码", example = "模块1")
    private String code;
    /**
	 * 类别名称
	 */
	@ApiModelProperty(value = "类别名称", example = "模块1")
    private String name;
    /**
	 * 父类code
	 */
	@ApiModelProperty(value = "父类code", example = "模块1")
    private String parentCode;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getParentCode() {
        return parentCode;
    }
    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }
}

+ 43 - 140
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictMedicineVO.java

@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty;
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * Administrator 	1.0  2018年09月07日 Created
 * litaohong 	1.0  2018年09月11日 Created
 *
 * </pre>
 * @since 1.
@ -20,118 +20,70 @@ import io.swagger.annotations.ApiModelProperty;
@ApiModel(value = "DictMedicineVO", description = "药品字典")
public class DictMedicineVO extends IntegerIdentityVO{
    /**
     * 药品代码
     */
    @ApiModelProperty(value = "分发药品的机构名称", example = "")
    private String orgName;
    /**
	 * 药品代码
	 */
	@ApiModelProperty(value = "药品代码", example = "")
	@ApiModelProperty(value = "药品代码", example = "模块1")
    private String code;
    /**
	 * 药品名称
	 * 药品中文名
	 */
	@ApiModelProperty(value = "药品名称", example = "")
	@ApiModelProperty(value = "药品中文名", example = "模块1")
    private String name;
    /**
	 * 药品规格
	 */
	@ApiModelProperty(value = "药品规格", example = "")
    private String physicSpec;
    /**
	 * 药品科目  科目类别字典中定义
	 */
	@ApiModelProperty(value = "药品科目  科目类别字典中定义", example = "")
    private String subjectClass;
    /**
	 * 剂量单位 计量单位字典中定义
	 */
	@ApiModelProperty(value = "剂量单位 计量单位字典中定义", example = "")
    private String doseUnit;
    /**
	 * 数量单位  计量单位字典中定义
	 */
	@ApiModelProperty(value = "数量单位  计量单位字典中定义", example = "")
    private String quantityUnit;
    /**
	 * 包装单位   计量单位字典中定义
	 */
	@ApiModelProperty(value = "包装单位   计量单位字典中定义", example = "")
    private String packUnit;
    /**
	 * 最小剂量
	 */
	@ApiModelProperty(value = "最小剂量", example = "")
    private double minDose;
    /**
	 * 
	 */
	@ApiModelProperty(value = "", example = "")
    private double packSpec;
    /**
	 * 零售价
	 * 药品所属科目代码
	 */
	@ApiModelProperty(value = "零售价", example = "")
    private double retailPrice;
	@ApiModelProperty(value = "药品所属科目代码", example = "模块1")
    private String subjectCode;
    /**
	 * 
	 * 药品剂型
	 */
	@ApiModelProperty(value = "", example = "")
    private String physicForm;
	@ApiModelProperty(value = "药品剂型", example = "模块1")
    private String dosageForm;
    /**
	 * 毒理分类  药品毒理分类字典中定义
	 * 药品规格
	 */
	@ApiModelProperty(value = "毒理分类  药品毒理分类字典中定义", example = "")
    private String toxicologyType;
	@ApiModelProperty(value = "药品规格", example = "模块1")
    private String specification;
    /**
	 * 基本药物标志  0:否;1:是
	 * 包装规格
	 */
	@ApiModelProperty(value = "基本药物标志  0:否;1:是", example = "1")
    private String basicFlag;
	@ApiModelProperty(value = "包装规格", example = "模块1")
    private String packingSpecification;
    /**
	 * 有效标志 0:无效;1:有效
	 * 适应症
	 */
	@ApiModelProperty(value = "有效标志 0:无效;1:有效", example = "0")
    private String validFlag;
	@ApiModelProperty(value = "适应症", example = "模块1")
    private String indication;
    /**
	 * 拼音首码
	 */
	@ApiModelProperty(value = "拼音首码", example = "")
	@ApiModelProperty(value = "拼音首码", example = "模块1")
    private String spellCode;
    /**
	 * 五笔首码
	 */
	@ApiModelProperty(value = "五笔首码", example = "")
	@ApiModelProperty(value = "五笔首码", example = "模块1")
    private String wbzxCode;
    /**
	 * 排序号
	 */
	@ApiModelProperty(value = "排序号", example = "")
	@ApiModelProperty(value = "排序号", example = "模块1")
    private Integer sequence;
    /**
	 * 2表示需要冷藏,其他表示不需要冷藏
	 */
	@ApiModelProperty(value = "2表示需要冷藏,其他表示不需要冷藏", example = "2")
	@ApiModelProperty(value = "2表示需要冷藏,其他表示不需要冷藏", example = "模块1")
    private String storageConditions;
@ -149,88 +101,39 @@ public class DictMedicineVO extends IntegerIdentityVO{
        this.name = name;
    }
    public String getPhysicSpec() {
        return physicSpec;
    }
    public void setPhysicSpec(String physicSpec) {
        this.physicSpec = physicSpec;
    }
    public String getSubjectClass() {
        return subjectClass;
    }
    public void setSubjectClass(String subjectClass) {
        this.subjectClass = subjectClass;
    }
    public String getDoseUnit() {
        return doseUnit;
    }
    public void setDoseUnit(String doseUnit) {
        this.doseUnit = doseUnit;
    }
    public String getQuantityUnit() {
        return quantityUnit;
    }
    public void setQuantityUnit(String quantityUnit) {
        this.quantityUnit = quantityUnit;
    }
    public String getPackUnit() {
        return packUnit;
    }
    public void setPackUnit(String packUnit) {
        this.packUnit = packUnit;
    }
    public double getMinDose() {
        return minDose;
    }
    public void setMinDose(double minDose) {
        this.minDose = minDose;
    }
    public double getPackSpec() {
        return packSpec;
    }
    public void setPackSpec(double packSpec) {
        this.packSpec = packSpec;
    }
    public double getRetailPrice() {
        return retailPrice;
    public String getSubjectCode() {
        return subjectCode;
    }
    public void setRetailPrice(double retailPrice) {
        this.retailPrice = retailPrice;
    public void setSubjectCode(String subjectCode) {
        this.subjectCode = subjectCode;
    }
    public String getPhysicForm() {
        return physicForm;
    public String getDosageForm() {
        return dosageForm;
    }
    public void setPhysicForm(String physicForm) {
        this.physicForm = physicForm;
    public void setDosageForm(String dosageForm) {
        this.dosageForm = dosageForm;
    }
    public String getToxicologyType() {
        return toxicologyType;
    public String getSpecification() {
        return specification;
    }
    public void setToxicologyType(String toxicologyType) {
        this.toxicologyType = toxicologyType;
    public void setSpecification(String specification) {
        this.specification = specification;
    }
    public String getBasicFlag() {
        return basicFlag;
    public String getPackingSpecification() {
        return packingSpecification;
    }
    public void setBasicFlag(String basicFlag) {
        this.basicFlag = basicFlag;
    public void setPackingSpecification(String packingSpecification) {
        this.packingSpecification = packingSpecification;
    }
    public String getValidFlag() {
        return validFlag;
    public String getIndication() {
        return indication;
    }
    public void setValidFlag(String validFlag) {
        this.validFlag = validFlag;
    public void setIndication(String indication) {
        this.indication = indication;
    }
    public String getSpellCode() {

文件差异内容过多而无法显示
+ 64 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/message/BaseMessageTypeVO.java


文件差异内容过多而无法显示
+ 287 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/message/BaseMessageVO.java


+ 2 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/servicePackage/ServicePackageLogVO.java

@ -1,5 +1,6 @@
package com.yihu.jw.restmodel.base.servicePackage;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -105,6 +106,7 @@ public class ServicePackageLogVO implements Serializable {
        this.id = id;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }

+ 12 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wlyy/HouseUserContant.java

@ -0,0 +1,12 @@
package com.yihu.jw.restmodel.wlyy;
/**
 * @author HZY
 * @created 2018/9/18 20:19
 */
public class HouseUserContant {
    public static Integer activated_del=-1;
    public static Integer activated_lock=0;
    public static Integer activated_active =1;
    public static Integer activated_offline=2;
}

+ 34 - 0
common/common-tracer/pom.xml

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>wlyy-parent-pom</artifactId>
        <groupId>com.yihu.jw</groupId>
        <version>2.0.0</version>
        <relativePath>../../wlyy-parent-pom/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>common-tracer</artifactId>
    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
    </dependencies>
</project>

+ 50 - 0
common/common-tracer/src/main/java/com/yihu/jw/advice/HttpAdvice.java

@ -0,0 +1,50 @@
package com.yihu.jw.advice;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
/**
 * Created by yeshijie on 2018/9/14
 */
@Aspect
@Component
public class HttpAdvice {
    @Autowired
    private Tracer tracer;
    @Autowired
    private ObjectMapper objectMapper;
    private Logger logger = LoggerFactory.getLogger(HttpAdvice.class);
    @Around("within(@org.springframework.web.bind.annotation.RestController *)")
    public Object process(ProceedingJoinPoint point) throws Throwable {
        //保存入参
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        tracer.getCurrentSpan().logEvent(objectMapper.writeValueAsString(request.getParameterMap()));
        //访问目标方法的参数:
        Object[] args = point.getArgs();
        Long strartTime = System.currentTimeMillis();
        Object returnValue = point.proceed(args);
        Long endTime = System.currentTimeMillis();
        //保存响应
        tracer.getCurrentSpan().logEvent(objectMapper.writeValueAsString(returnValue));
        //保存响应时间
        tracer.getCurrentSpan().logEvent("executeTime:"+(endTime - strartTime));
        return returnValue;
    }
}

+ 1 - 1
server/svr-authentication/pom.xml

@ -10,7 +10,7 @@
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>svr-authentication</artifactId>
    <artifactId>svr-authentication</artifactId>rred
    <dependencies>
        <!-- 支持Tomcat启动 -->

+ 53 - 0
server/svr-authentication/readme.md

@ -0,0 +1,53 @@
授权码模式 authorization_code
1.GET http://localhost:10260/oauth/authorize?response_type=code&client_id=uzs5G0HgTp&state=sxy&scope=read&redirect_uri=http://192.168.1.221:8010/ehr/browser/common/login/signin&ak=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDjgKCe2zFmYSjHZz93cO17A0Hj6H5XdfwP2I5Qu1UJbmhGG/wPu409r9TABXblcxC9uPVR3PJ5dPrWPLuQ/r7tq16vSa5GF4iCcSlLyx/IDA5bq8ZnafS/RjPiKDtdZAx5uCNLog9GkVHNZIhK9cS9MI4QNuOJzOXaAVwnP2wIDAQAB
    HTTP/1.1 302 Found
    Location: http://localhost:9000/info?code=Ar0mp5&state=sxy
2.POST  http://localhost:10260/oauth/token
    
    HTTP/1.1 200 OK
    Content-Type: application/json;charset=UTF-8
    Cache-Control: no-store
    Pragma: no-cache
    {
      "accessToken":"4c5c7f4f-158a-4f73-9c14-ecbe78671872",
      "tokenType":"bearer",
      "expiresIn":3600,
      "refreshToken":"4c5c7f4f-158a-4f73-9c14-ecbe78671873",
      "state":"example_value"
    }
简化模式 implicit
1.GET http://localhost:10260/oauth/authorize?response_type=token&client_id=EwC0iRSrc4&state=sxy&scope=read&ak=xxxxxxxxxxxxxxxxxxxxxxxxxxx
    HTTP/1.1 302 Found
    Location: https://www.baidu.com/#access_token=4c5c7f4f-158a-4f73-9c14-ecbe78671872&token_type=bearer&state=sxy&expires_in=2418755
   
密码模式 password
1.POST http://localhost:10260/oauth/token
    grant_type=password&username=admin&password=123456789&scope=read&client_id=uzs5G0HgTp
    HTTP/1.1 200 OK
    Content-Type: application/json;charset=UTF-8
    Cache-Control: no-store
    Pragma: no-cache
    {
      "accessToken":"8ce77011-87c9-48f3-8e4f-5cf945f047c7",
      "tokenType":"example",
      "expiresIn":3600,
      "refreshToken":"6b010e33-8bc3-4f3f-8123-66df589dc82f",
      "state":"example_value",
      "user":"admin"
     }
更新令牌 refresh_token
1.POST http://localhost:10260/oauth/token
    grant_type=refresh_token&refresh_token=6b010e33-8bc3-4f3f-8123-66df589dc82f&client_id=uzs5G0HgTp
单点登陆 sso
//A 应用发起请求
1.GET http://localhost:10260/oauth/sso?response_type=token&client_id=EwC0iRSrcS&state=sxy&scope=read&redirect_uri=https://www.jd.com?idCardNo=362321200108017313&access_token=40db969a-5fa0-444e-a0e0-36ba86e7a9ed
//B应用 验证token
2.post http://localhost:10260/oauth/sso?client_id=EwC0iRSrcS&access_token=26502c29-6ba8-4986-8feb-723b8288356d

+ 8 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyAuthorizationEndpoint.java

@ -120,6 +120,14 @@ public class WlyyAuthorizationEndpoint extends AbstractEndpoint {
        this.errorPage = errorPage;
    }
    /**
     *
     * @param model
     * @param parameters
     * @param sessionStatus
     * @param principal
     * @return
     */
    @RequestMapping(value = "/oauth/authorize", method = RequestMethod.GET)
    public ModelAndView authorize(Map<String, Object> model, @RequestParam Map<String, String> parameters,
                                  SessionStatus sessionStatus, Principal principal) {

+ 2 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -111,6 +111,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        }
        if (StringUtils.isEmpty(parameters.get("captcha"))) {
            parameters.put("grant_type", "password");
            //解密密码
//            if (parameters.get("password") != null) {
//                RSAPrivateKey rsaPrivateKey = (RSAPrivateKey)httpSession.getAttribute("privateKey");
//                parameters.put("password", RSAUtils.decryptByPrivateKey(new String(Base64.decodeBase64(parameters.get("password"))), rsaPrivateKey));
@ -280,7 +281,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            Map<String, Object> sms =  (Map)result.get("obj");
            String captcha = (String) sms.get("captcha");
            Date deadline = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse((String) sms.get("deadline"));
            Long expire = (deadline.getTime() - new Date().getTime()) / 1000;
            Long expire = (deadline.getTime() - System.currentTimeMillis()) / 1000;
            Captcha _captcha = new Captcha();
            _captcha.setCode(captcha);
            _captcha.setExpiresIn(expire.intValue());

+ 2 - 1
server/svr-zipkin/src/main/java/com/yihu/ZipkinTrackServer.java

@ -2,7 +2,8 @@ package com.yihu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import zipkin.server.EnableZipkinServer;
import zipkin.server.internal.EnableZipkinServer;
/**
 * @author chenweida

文件差异内容过多而无法显示
+ 73 - 15
sql/init.sql


+ 92 - 0
svr/figure-label/pom.xml

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>com.yihu.jw</groupId>
        <artifactId>wlyy-parent-pom</artifactId>
        <version>2.0.0</version>
        <relativePath>../../wlyy-parent-pom/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>figure-label</artifactId>
    <dependencies>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>common-quartz-starter</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>common-logback-starter</artifactId>
            <version>1.0.2</version>
            <exclusions>
                <exclusion>
                    <artifactId>servlet-api</artifactId>
                    <groupId>javax.servlet</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>common-swagger-starter</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator-docs</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>4.3.10.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.0.15</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>common-data-es-starter</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <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>
        </dependency>
    </dependencies>
</project>

+ 63 - 0
svr/figure-label/sql/label_es_sql

@ -0,0 +1,63 @@
-- 新增居民标签索引映射
PUT http://172.19.103.45:9200/figure_label_index
{
        "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"
                    }
                }
            }
        }
}
-- 给索引建立别名
PUT http://172.19.103.45:9200/figure_label_index/figure_label_index_a

+ 54 - 0
svr/figure-label/sql/mysql.sql

@ -0,0 +1,54 @@
# job配置表
DROP TABLE IF EXISTS `fl_job_config`;
CREATE TABLE `fl_job_config` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `job_name` varchar(200) DEFAULT NULL COMMENT '任务名称',
  `job_class` varchar(200) DEFAULT NULL COMMENT '任务执行的class',
  `query_sql` varchar(2000) DEFAULT NULL COMMENT '抽取数据的sql语句',
  `sql_field_type` int(2) DEFAULT NULL COMMENT '增量字段类型 1时间 (yyyy-mm-dd  HH:MM:ss)2数字',
  `sql_field_value` varchar(255) DEFAULT NULL COMMENT '增量字段值',
  `sql_field` varchar(255) DEFAULT NULL COMMENT '增量字段',
  `quartz_cron` varchar(200) DEFAULT NULL COMMENT 'quartz表达式',
  `status` varchar(1) DEFAULT NULL COMMENT '1 启动 0停止',
  `del` varchar(1) DEFAULT NULL COMMENT '1 正常    0 删除',
  `source_type` varchar(20) DEFAULT NULL COMMENT '来源类型(mysql,hbase,file等)',
  `source` varchar(100) DEFAULT NULL COMMENT '数据来源',
  `datasource` varchar(200) NOT NULL DEFAULT '' COMMENT '数据库连接,格式为:url-database',
  `extract_field` varchar(255) DEFAULT '' COMMENT '查询的字段',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
# 标签具体字典表
DROP TABLE IF EXISTS `fl_label_dict`;
CREATE TABLE `fl_label_dict` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `dict_code` varchar(64) DEFAULT NULL COMMENT 'code一致的标签属于同一类',
  `parent_code` varchar(255) DEFAULT '0' COMMENT '字典父类代码,没有父类默认为0',
  `label_code` varchar(200) DEFAULT NULL COMMENT '标签code',
  `label_name` varchar(200) DEFAULT NULL COMMENT '标签名称',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=115 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
# 标签分类表
DROP TABLE IF EXISTS `fl_label_dict_category`;
CREATE TABLE `fl_label_dict_category` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `dict_code` varchar(255) NOT NULL COMMENT '标签字典代码',
  `dict_name` varchar(255) NOT NULL COMMENT '标签字典名称',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8 COMMENT='标签字典分类表';
# 标签转换器表
DROP TABLE IF EXISTS `fl_label_dict_job`;
CREATE TABLE `fl_label_dict_job` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `job_id` int(10) NOT NULL COMMENT '任务id',
  `category_id` int(10) NOT NULL COMMENT '标签分类id',
  `label_type` varchar(10) DEFAULT NULL COMMENT '标签类型 1 个人基本信息 2人群属性 3行政区域 4互联网行为 5签约分析 6咨询分析 7随访记录 8生活环境 9健康档案分析',
  `query_sql` varchar(2000) DEFAULT NULL COMMENT '抽取数据的sql语句',
  `convert_clazz` varchar(255) DEFAULT NULL COMMENT '需要转换的类',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

+ 32 - 0
svr/figure-label/src/main/java/com/yihu/FigureLabelApplication.java

@ -0,0 +1,32 @@
package com.yihu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
/**
 * Created by chenweida on 2018/3/5.
 */
@SpringBootApplication
@EnableJpaRepositories(
        entityManagerFactoryRef = "EntityManagerFactory",
        transactionManagerRef = "TransactionManager")
@EnableAutoConfiguration(exclude = {
//        ElasticsearchAutoConfiguration.class,
        ElasticsearchRepositoriesAutoConfiguration.class,
//        ElasticsearchDataAutoConfiguration.class,
        RedisRepositoriesAutoConfiguration.class
})
public class FigureLabelApplication {
    public static ApplicationContext ctx = null;
    public static void main(String[] args) {
        ctx = SpringApplication.run(FigureLabelApplication.class, args);
    }
}

+ 55 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/DruidConfig.java

@ -0,0 +1,55 @@
package com.yihu.wlyy.figure.label.config.db;
import com.alibaba.druid.filter.stat.StatFilter;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * Created by chenweida on 2018/3/5.
 */
//@Configuration
public class DruidConfig {
   /* //------------------------------------druid 监控----------------------------------------------
    @Bean
    public ServletRegistrationBean statViewServlet() {
        //创建servlet注册实体
        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
        //设置ip白名单
        //servletRegistrationBean.addInitParameter("allow","127.0.0.1");
        //设置ip黑名单,如果allow与deny共同存在时,deny优先于allow
        // servletRegistrationBean.addInitParameter("deny","192.168.0.19");
        //设置控制台管理用户
        servletRegistrationBean.addInitParameter("loginUsername", "jkzl");
        servletRegistrationBean.addInitParameter("loginPassword", "jkzlehr");
        //是否可以重置数据
        servletRegistrationBean.addInitParameter("resetEnable", "false");
        return servletRegistrationBean;
    }
    @Bean
    public FilterRegistrationBean filterRegistrationBean(WebStatFilter webStatFilter) {
        //创建过滤器
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(webStatFilter);
        //设置过滤器过滤路径
        filterRegistrationBean.addUrlPatterns("/*");
        //忽略过滤的形式
        filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
        return filterRegistrationBean;
    }
    @Bean
    public StatFilter statFilter() {
        return new StatFilter();
    }
    @Bean
    public WebStatFilter webStatFilter() {
        return new WebStatFilter();
    }*/
    //------------------------------------druid 监控----------------------------------------------
}

+ 159 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/FigureLabelJpa.java

@ -0,0 +1,159 @@
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;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
/**
 * Created by chenweida on 2017/4/6.
 */
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
        entityManagerFactoryRef = "EntityManagerFactory",
        transactionManagerRef = "TransactionManager",
        basePackages = {"com.yihu.wlyy.figure.label.dao"})   //设置Repository所在位置
public class FigureLabelJpa {
    @Autowired
    private HibernateProperties hibernateProperties;
    @Autowired
    private DataSourceProperties dataSourceProperties;
//    @Autowired
//    private DruidConfig druidConfig;
    private DataSource buildDataSource(DruidDataSource datasource) throws SQLException{
        //configuration
        datasource.setInitialSize(dataSourceProperties.getInitialSize());
        datasource.setMinIdle(dataSourceProperties.getMinIdle());
        datasource.setMaxActive(dataSourceProperties.getMaxActive());
        datasource.setMaxWait(dataSourceProperties.getMaxWait());
        datasource.setTimeBetweenEvictionRunsMillis(dataSourceProperties.getTimeBetweenEvictionRunsMillis());
        datasource.setMinEvictableIdleTimeMillis(dataSourceProperties.getMinEvictableIdleTimeMillis());
        datasource.setValidationQuery(dataSourceProperties.getValidationQuery());
        datasource.setTestWhileIdle(dataSourceProperties.getTestWhileIdle());
        datasource.setTestOnBorrow(dataSourceProperties.getTestOnBorrow());
        datasource.setTestOnReturn(dataSourceProperties.getTestOnReturn());
        datasource.setPoolPreparedStatements(dataSourceProperties.getPoolPreparedStatements());
        datasource.setMaxPoolPreparedStatementPerConnectionSize(dataSourceProperties.getMaxPoolPreparedStatementPerConnectionSize());
        datasource.setRemoveAbandoned(dataSourceProperties.getRemoveAbandoned());
        datasource.setRemoveAbandonedTimeout(dataSourceProperties.getRemoveAbandonedTimeout());
        datasource.setLogAbandoned(dataSourceProperties.getLogAbandoned());
        datasource.setFilters(dataSourceProperties.getFilters());
        datasource.setConnectProperties(properties());//;# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
        datasource.setUseGlobalDataSourceStat(true);// 合并多个DruidDataSource的监控数据
        List proxyFilters = new ArrayList<>();
//        proxyFilters.add(druidConfig.statFilter());
//        datasource.setProxyFilters(proxyFilters);
        return datasource;
    }
    @Bean(name = "wlyyDataSource")
    @Primary
    public DataSource wlyyDataSource() throws SQLException {
        DruidDataSource datasource = new DruidDataSource();
        datasource.setUrl(dataSourceProperties.getWlyy().getUrl());
        datasource.setUsername(dataSourceProperties.getWlyy().getUsername());
        datasource.setPassword(dataSourceProperties.getWlyy().getPassword());
        datasource.setDriverClassName(dataSourceProperties.getDriverClassName());
        return buildDataSource(datasource);
    }
    @Bean(name = "healtharchiveDataSource")
    public DataSource healtharchiveDataSource() throws SQLException {
        DruidDataSource datasource = new DruidDataSource();
        datasource.setUrl(dataSourceProperties.getHealtharchive().getUrl());
        datasource.setUsername(dataSourceProperties.getHealtharchive().getUsername());
        datasource.setPassword(dataSourceProperties.getHealtharchive().getPassword());
        datasource.setDriverClassName(dataSourceProperties.getDriverClassName());
        return buildDataSource(datasource);
    }
    @Bean(name = "wlyy85DataSource")
    public DataSource wlyy85DataSource() throws SQLException {
        DruidDataSource datasource = new DruidDataSource();
        datasource.setUrl(dataSourceProperties.getWlyy85().getUrl());
        datasource.setUsername(dataSourceProperties.getWlyy85().getUsername());
        datasource.setPassword(dataSourceProperties.getWlyy85().getPassword());
        datasource.setDriverClassName(dataSourceProperties.getDriverClassName());
        return buildDataSource(datasource);
    }
    @Bean(name = "EntityManagerFactory")
    @Primary
    public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary(@Qualifier("wlyyDataSource") DataSource dataSource) {
        LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
        emfb.setDataSource(dataSource);
        emfb.setPackagesToScan("com.yihu.wlyy.figure.label.entity");
        emfb.setPersistenceUnitName("wlyy");
        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        emfb.setJpaVendorAdapter(vendorAdapter);
        emfb.setJpaProperties(hibernateProperties.hibProperties());
        return emfb;
    }
    @Bean(name = "TransactionManager")
    @Primary
    JpaTransactionManager transactionManagerSecondary(@Qualifier("EntityManagerFactory") EntityManagerFactory builder) {
        return new JpaTransactionManager(builder);
    }
    private Properties properties() {
        Properties properties = new Properties();
        properties.put("druid.stat.mergeSql", "true");
        properties.put("slowSqlMillis", "1000");
        return properties;
    }
    @Bean
    public JdbcTemplate jdbcTemplate(@Qualifier("wlyyDataSource") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }
    @Bean(name = "healtharchiveTemplate")
    public JdbcTemplate secondJdbcTemplate(@Qualifier("healtharchiveDataSource") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }
    @Bean(name = "wlyy85Template")
    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;
    }
}

+ 27 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/HibernateProperties.java

@ -0,0 +1,27 @@
package com.yihu.wlyy.figure.label.config.db;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Properties;
/**
 * Created by chenweida on 2017/4/6.
 */
@Component
public class HibernateProperties {
    @Value("${hibernate.dialect}")
    private String dialect;
    @Value("${hibernate.show_sql}")
    private String show_sql;
    @Value("${hibernate.ejb.naming_strategy}")
    private String naming_strategy;
    public  Properties hibProperties() {
        Properties properties = new Properties();
        properties.put("hibernate.dialect",dialect);
        properties.put("hibernate.show_sql", show_sql);
        properties.put("hibernate.ejb.naming_strategy", naming_strategy);
        return properties;
    }
}

+ 36 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/properties/DataSourceLoginProperties.java

@ -0,0 +1,36 @@
package com.yihu.wlyy.figure.label.config.db.properties;
/**
 * Created by chenweida on 2018/3/5.
 */
public class DataSourceLoginProperties {
    private String username;
    private String password;
    private String url;
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
}

+ 195 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/config/db/properties/DataSourceProperties.java

@ -0,0 +1,195 @@
package com.yihu.wlyy.figure.label.config.db.properties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
 * Created by chenweida on 2018/3/5.
 */
@ConfigurationProperties(prefix = "spring.datasource")
@Component
public class DataSourceProperties {
    private String driverClassName;
    private Integer initialSize;
    private Integer minIdle;
    private Integer maxActive;
    private Integer maxWait;
    private Integer timeBetweenEvictionRunsMillis;
    private Integer minEvictableIdleTimeMillis;
    private String validationQuery;
    private Boolean testWhileIdle;
    private Boolean testOnBorrow;
    private Boolean testOnReturn;
    private Boolean poolPreparedStatements;
    private Integer maxPoolPreparedStatementPerConnectionSize;
    private Boolean removeAbandoned;
    private Integer removeAbandonedTimeout;
    private Boolean logAbandoned;
    private String filters;
    private DataSourceLoginProperties wlyy = new DataSourceLoginProperties();
    private DataSourceLoginProperties healtharchive = new DataSourceLoginProperties();
    private DataSourceLoginProperties wlyy85 = new DataSourceLoginProperties();
    public String getDriverClassName() {
        return driverClassName;
    }
    public void setDriverClassName(String driverClassName) {
        this.driverClassName = driverClassName;
    }
    public Integer getInitialSize() {
        return initialSize;
    }
    public void setInitialSize(Integer initialSize) {
        this.initialSize = initialSize;
    }
    public Integer getMinIdle() {
        return minIdle;
    }
    public void setMinIdle(Integer minIdle) {
        this.minIdle = minIdle;
    }
    public Integer getMaxActive() {
        return maxActive;
    }
    public void setMaxActive(Integer maxActive) {
        this.maxActive = maxActive;
    }
    public Integer getMaxWait() {
        return maxWait;
    }
    public void setMaxWait(Integer maxWait) {
        this.maxWait = maxWait;
    }
    public Integer getTimeBetweenEvictionRunsMillis() {
        return timeBetweenEvictionRunsMillis;
    }
    public void setTimeBetweenEvictionRunsMillis(Integer timeBetweenEvictionRunsMillis) {
        this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
    }
    public Integer getMinEvictableIdleTimeMillis() {
        return minEvictableIdleTimeMillis;
    }
    public void setMinEvictableIdleTimeMillis(Integer minEvictableIdleTimeMillis) {
        this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
    }
    public String getValidationQuery() {
        return validationQuery;
    }
    public void setValidationQuery(String validationQuery) {
        this.validationQuery = validationQuery;
    }
    public Boolean getTestWhileIdle() {
        return testWhileIdle;
    }
    public void setTestWhileIdle(Boolean testWhileIdle) {
        this.testWhileIdle = testWhileIdle;
    }
    public Boolean getTestOnBorrow() {
        return testOnBorrow;
    }
    public void setTestOnBorrow(Boolean testOnBorrow) {
        this.testOnBorrow = testOnBorrow;
    }
    public Boolean getTestOnReturn() {
        return testOnReturn;
    }
    public void setTestOnReturn(Boolean testOnReturn) {
        this.testOnReturn = testOnReturn;
    }
    public Boolean getPoolPreparedStatements() {
        return poolPreparedStatements;
    }
    public void setPoolPreparedStatements(Boolean poolPreparedStatements) {
        this.poolPreparedStatements = poolPreparedStatements;
    }
    public Integer getMaxPoolPreparedStatementPerConnectionSize() {
        return maxPoolPreparedStatementPerConnectionSize;
    }
    public void setMaxPoolPreparedStatementPerConnectionSize(Integer maxPoolPreparedStatementPerConnectionSize) {
        this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize;
    }
    public Boolean getRemoveAbandoned() {
        return removeAbandoned;
    }
    public void setRemoveAbandoned(Boolean removeAbandoned) {
        this.removeAbandoned = removeAbandoned;
    }
    public Integer getRemoveAbandonedTimeout() {
        return removeAbandonedTimeout;
    }
    public void setRemoveAbandonedTimeout(Integer removeAbandonedTimeout) {
        this.removeAbandonedTimeout = removeAbandonedTimeout;
    }
    public Boolean getLogAbandoned() {
        return logAbandoned;
    }
    public void setLogAbandoned(Boolean logAbandoned) {
        this.logAbandoned = logAbandoned;
    }
    public String getFilters() {
        return filters;
    }
    public void setFilters(String filters) {
        this.filters = filters;
    }
    public DataSourceLoginProperties getWlyy() {
        return wlyy;
    }
    public void setWlyy(DataSourceLoginProperties wlyy) {
        this.wlyy = wlyy;
    }
    public DataSourceLoginProperties getHealtharchive() {
        return healtharchive;
    }
    public void setHealtharchive(DataSourceLoginProperties healtharchive) {
        this.healtharchive = healtharchive;
    }
    public DataSourceLoginProperties getWlyy85() {
        return wlyy85;
    }
    public void setWlyy85(DataSourceLoginProperties wlyy85) {
        this.wlyy85 = wlyy85;
    }
}

+ 92 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/config/swagger/SwaggerConfig.java

@ -0,0 +1,92 @@
package com.yihu.wlyy.figure.label.config.swagger;
import io.github.swagger2markup.GroupBy;
import io.github.swagger2markup.Language;
import io.github.swagger2markup.Swagger2MarkupConfig;
import io.github.swagger2markup.Swagger2MarkupConverter;
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
import io.github.swagger2markup.markup.builder.MarkupLanguage;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.async.DeferredResult;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;
@EnableSwagger2
@Configuration
public class SwaggerConfig {
    private static final String Other_API = "other";
    @Bean
    public Docket otherAPI() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(Other_API)
                .genericModelSubstitutes(DeferredResult.class)
                .useDefaultResponseMessages(false)
                .forCodeGeneration(true)
                .pathMapping("/")
                .select()
                .paths(or(
                        regex("/.*")
                ))
                .build()
                .apiInfo(otherApiInfo());
    }
    private ApiInfo otherApiInfo() {
        ApiInfo apiInfo = new ApiInfo("居民画像平台API",
                "居民画像平台API",
                "1.0",
                "No terms of service",
                "admin@jkzl.com",
                "The Apache License, Version 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0.html"
        );
        return apiInfo;
    }
    /**
     * 生成html文章专用
     *
     private static final String Doctor_API = "doctor";
     private static final String Patient_API = "patient";
     private static final String Other_API = "other";
     private static final String GateWay_API = "gateway";
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        String groupName="doctor";
        //String groupName="patient";
        //String groupName="other";
        // String groupName="gateway";
        URL remoteSwaggerFile = new URL("http://127.0.0.1:8080//v2/api-docs?group="+groupName);
        Path outputFile = Paths.get("patient-co/patient-co-figure-label/build/"+groupName);
        Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
                .withMarkupLanguage(MarkupLanguage.ASCIIDOC)
                .withOutputLanguage(Language.ZH)
                .withPathsGroupedBy(GroupBy.TAGS)
                .withGeneratedExamples()
                .withoutInlineSchema()
                .withBasePathPrefix()
                .build();
        Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(remoteSwaggerFile)
                .withConfig(config)
                .build();
        converter.toFile(outputFile);
    }
}

+ 21 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/config/war/ServletInitializer.java

@ -0,0 +1,21 @@
package com.yihu.wlyy.figure.label.config.war;//package com.yihu.wlyy.config.war;
import com.yihu.FigureLabelApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
/**
 *
 */
public class ServletInitializer extends SpringBootServletInitializer {
    public ServletInitializer() {
        super();
        setRegisterErrorPageFilter(false); //报错不跳到错误页
    }
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(FigureLabelApplication.class);
    }
}

+ 17 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/constant/BusinessConstant.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.figure.label.constant;
/**
 * @author litaohong on 2018/5/31
 * @project patient-co-management
 * 业务相关的常量
 */
public class BusinessConstant {
    public static final String SQLFIELDCONDITION = "sqlFieldCondition";
    public static final String sqlFieldValue = "sqlFieldValue";
    public static final String sourceType = "sourceType";
    public static final String source = "source";
    public static final String gt = ">";
    public static final String separator = "/";
    public static final String sql_field_str = "@sql_field@";
    public static final String sql_field_value_str = "@sql_field_value@";
}

+ 46 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/constant/ConstantUtil.java

@ -0,0 +1,46 @@
package com.yihu.wlyy.figure.label.constant;
public class ConstantUtil {
    public static final String figure_label_es_index = "figure_label_index";
    public static final String figure_label_es_type = "figure_label_type";
    public static final String date_format = "yyyy-MM-dd HH:mm:ss";
    public static final String figure_label_hbase_table = "figure_label";
    public static final String figure_label_familyA = "label_cloumn";
    // solr字表core
    public static final String subcore = "HealthProfileSub";
    public static final String address_dict = "address_dict";
    public static final String age_dict = "age_dict";
    public static final String birth_dict = "birth_dict";
    public static final String consult_dict = "consult_dict";
    public static final String consult_evaluate_dict = "consult_evaluate_dict";
    public static final String feedback_dict = "feedback_dict";
    public static final String health_edu_artical_dict = "health_edu_artical_dict";
    public static final String health_edu_artical_receive_dict = "health_edu_artical_receive_dict";
    public static final String height_dict = "height_dict";
    public static final String is_consult_dict = "is_consult_dict";
    public static final String is_drinking_dict = "is_drinking_dict";
    public static final String is_pay_online_dict = "is_pay_online_dict";
    public static final String is_sign_online_dict = "is_sign_online_dict";
    public static final String is_smoking_dict = "is_smoking_dict";
    public static final String name_dict = "name_dict";
    public static final String online_appoinment_dict = "online_appoinment_dict";
    public static final String online_consult_dict = "online_consult_dict";
    public static final String people_category_dict = "people_category_dict";
    public static final String renew_dict = "renew_dict";
    public static final String reply_intime_dict = "reply_intime_dict";
    public static final String sex_dict = "sex_dict";
    public static final String sign_doctor_dict = "sign_doctor_dict";
    public static final String sign_server_type_dict = "sign_server_type_dict";
    public static final String sign_team_dict = "sign_team_dict";
    public static final String sign_state_dict = "sign_state_dict";
    public static final String weight_dict = "weight_dict";
    public static final String wx_subscribe_acc_dict = "wx_subscribe_acc_dict";
    public static final String ICD10_dict = "ICD-10-CM_dict";
    public static final String health_problem_dict = "health_problem_dict";
    public static final String followup_dict = "followup_dict";
}

+ 440 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/controller/BaseController.java

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

+ 77 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/controller/ESDataOperationController.java

@ -0,0 +1,77 @@
package com.yihu.wlyy.figure.label.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.base.es.config.ElastricSearchHelper;
import com.yihu.wlyy.figure.label.constant.ConstantUtil;
import com.yihu.wlyy.figure.label.util.TimeUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @author litaohong on 2018/5/3
 * @project patient-co-management
 */
@RestController
@RequestMapping(value = "/data", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "ES数据操作控制器")
public class ESDataOperationController extends BaseController{
    private Logger logger = LoggerFactory.getLogger(ESDataOperationController.class);
    @Autowired
    private ElastricSearchHelper elastricSearchHelper;
    @Autowired
    ObjectMapper objectMapper;
    @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 sql){
        long start = System.currentTimeMillis();
        String logTitle = "delete es data";
        TimeUtil.start(logger,logTitle,start);
        List<Map<String, Object>>  list = new ArrayList<>();
        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){
            delete(list);
            list = elastricSearchHelper.excuceSQL(sql);
            count+= list.size();
        }
        TimeUtil.finish(logger,logTitle,start,System.currentTimeMillis());
        return count;
    }
    public void delete(List<Map<String, Object>> list){
        elastricSearchHelper.delete(ConstantUtil.figure_label_es_index,ConstantUtil.figure_label_es_type,list);
    }
}

+ 131 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/controller/JobController.java

@ -0,0 +1,131 @@
package com.yihu.wlyy.figure.label.controller;
import com.yihu.wlyy.figure.label.service.JobService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 lith on 2018.03.14
 * 定时任务控制器
 */
@RestController
@RequestMapping(value = "/job", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "定时任务控制器")
public class JobController extends BaseController{
    private Logger logger = LoggerFactory.getLogger(JobController.class);
    @Autowired
    private JobService jobService;
    /**
     * 启动任务
     * @param id
     * @return
     */
    @ApiOperation(value = "根据ID立即单个任务")
    @RequestMapping(value = "startNowById", method = RequestMethod.GET)
    public String startNowById(
            @ApiParam(name = "id", value = "任务ID", required = true)@RequestParam(value = "id", required = true) String id) {
        try {
            jobService.startNowById(id);
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /**
     * 启动任务
     *
     * @param id id
     * @return
     */
    @ApiOperation(value = "根据id启动任务,逗号分隔")
    @RequestMapping(value = "startById", method = RequestMethod.GET)
    public String startById(
            @ApiParam(name="id",value="任务id",required=true)@RequestParam(value = "id", required = true) String id) {
        try {
            jobService.startById(id);
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /**
     * 停止任务
     *
     * @param id id
     * @return
     */
    @ApiOperation(value = "根据id停止任务,逗号分隔")
    @RequestMapping(value = "stopById", method = RequestMethod.GET)
    public String stopById(@ApiParam(name="id",value="任务id",required=true)@RequestParam(value = "id", required = true)String id) {
        try {
            jobService.stopById(id);
            return success("停止成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /**
     * 停止所有任务
     *
     * @return
     */
    @ApiOperation(value = "停止所有任务")
    @RequestMapping(value = "stopAll", method = RequestMethod.GET)
    public String stopAll() {
        try {
            jobService.stopAll();
            return success("停止成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /**
     * 启动所有任务
     *
     * @return
     */
    @ApiOperation(value = "启动所有任务")
    @RequestMapping(value = "startAll", method = RequestMethod.GET)
    public String startAll() {
        try {
            jobService.startAll();
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    @ApiOperation(value = "清除緩存")
    @RequestMapping(value = "cleanCache", method = RequestMethod.GET)
    public String cleanCache() {
        try {
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
}

+ 50 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/AddressConvert.java

@ -0,0 +1,50 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.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 java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @author litaohong on 2018/4/12
 * @project patient-co-management
 * 地址标签转换器
 */
@Component
public class AddressConvert 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 dict = flLabelDictList.get(0);
        for(DataModel dataModel : modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dict.getLabelCode());
            saveModel.setLabelName(dict.getLabelName());
            saveModel.setLabelValue(dataModel.getLabelValue());
            convertHelper.generateDataSource(dataModel,saveModel,sourceType,source);
            if(StringUtils.isEmpty(saveModel.getSource())){
                return new ArrayList<>();
            }
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

+ 56 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/AgeConvert.java

@ -0,0 +1,56 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.ConstantUtil;
import com.yihu.wlyy.figure.label.util.IdCardUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.*;
/**
 * @author lith on 2018.03.14
 * 年龄标签转换器
 */
@Component
public class AgeConvert implements Convert {
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    public List<SaveModel> convert(List<DataModel> models, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        List<SaveModel> saveModels = new ArrayList<>();
        FlLabelDict one = flLabelDictList.get(0);
        models.forEach(
                model -> {
                    int age = IdCardUtil.getAgeForIdcard(model.getIdcard());
                    SaveModel saveModel = new SaveModel();
                    saveModel.setDictCode(one.getDictCode());
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabelCode(one.getLabelCode());
                    saveModel.setLabelName(String.valueOf(age) + "岁");
                    //源数据来源时间
                    saveModel.setSourceTime(model.getSourceTime());
                    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;
                    }
                    saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
                    saveModels.add(saveModel);
                }
        );
        return saveModels;
    }
}

+ 88 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/AgeRangeConvert.java

@ -0,0 +1,88 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.ConstantUtil;
import com.yihu.wlyy.figure.label.util.IdCardUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.*;
/**
 * @author lith on 2018.03.14
 * 年龄标签转换器
 */
@Component
public class AgeRangeConvert implements Convert {
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    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<>();
        flLabelDictList.forEach(
                fLlabelDict -> {
                    map.put(fLlabelDict.getLabelCode(),fLlabelDict.getLabelName());
                }
        );
        models.forEach(
                model -> {
                    int age = IdCardUtil.getAgeForIdcard(model.getIdcard());
                    String labelCode = getAgeLabelCode(age);
                    SaveModel saveModel = new SaveModel();
                    saveModel.setDictCode(one.getDictCode());
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabelCode(one.getLabelCode());
                    saveModel.setLabelName(map.get(labelCode));
                    //源数据来源时间
                    if(null != model.getSourceTime()){
                        saveModel.setSourceTime(model.getSourceTime());
                    }
                    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;
                    }
                    saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
                    saveModels.add(saveModel);
                }
        );
        return saveModels;
    }
    /**
     * fl_label_dict配置的code
     * @param age
     * @return
     */
    public String getAgeLabelCode(int age) {
        if (age <= 6) {
            return "10";
        }else if(age <=18){
            return "11";
        }else if(age <=30){
            return "12";
        }else if(age <=50){
            return "13";
        }else if(age <=65){
            return "14";
        }else{
            return "15";
        }
    }
}

+ 91 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/BasicDictItemHelper.java

@ -0,0 +1,91 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.figure.label.entity.FlLabelDict;
import io.swagger.annotations.Scope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author litaohong on 2018/4/27
 * @project patient-co-management
 * 一些基础字典信息载入内存
 */
@Component
public class BasicDictItemHelper {
    public  Map<String,String> dictCategoryMap = new HashMap<>();
    public  Map<String,List<FlLabelDict>> labelDictMap = new HashMap<>();
    @Autowired
    JdbcTemplate jdbcTemplate;
    @PostConstruct
    public void init(){
        loadCategoryMap();
        loadLabelDictMap();
    }
    /**
     * 加载标签分类表
     * @return
     */
    public Map<String,String> loadCategoryMap(){
        if(!CollectionUtils.isEmpty(dictCategoryMap)){
            return dictCategoryMap;
        }
        String sql = "select * from fl_label_dict_category";
        List<Map<String, Object>> dictCategoryList = jdbcTemplate.queryForList(sql);
        dictCategoryList.forEach(
                one -> {
                    dictCategoryMap.put(String.valueOf(one.get("id")),String.valueOf(one.get("dict_code")));
                }
        );
        return dictCategoryMap;
    }
    /**
     * 加载标签字典表
     * @return
     */
    public Map<String,List<FlLabelDict>> loadLabelDictMap(){
        if(!CollectionUtils.isEmpty(labelDictMap)){
            return labelDictMap;
        }
        String sql = "select * from fl_label_dict";
        List<FlLabelDict> labelDictList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(FlLabelDict.class));
        labelDictList.forEach(
                one -> {
                    List list = new ArrayList();
                    if(labelDictMap.containsKey(one.getDictCode())){
                        labelDictMap.get(one.getDictCode()).add(one);
                        return;
                    }
                    list.add(one);
                    labelDictMap.put(one.getDictCode(), list);
                }
        );
        return labelDictMap;
    }
//    public Map<String,FlLabelDict> getOneDictMap(String dictCode){
//        Map<String,FlLabelDict> map = new HashMap<>();
//        if(this.labelDictMap.get(dictCode).size() > 1){
//            List<FlLabelDict> list = this.labelDictMap.get(dictCode);
//            list.forEach(
//                    one -> {
//                        map.put()
//                    }
//            );
//        }
//    }
}

+ 67 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/BirthConvert.java

@ -0,0 +1,67 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.ConstantUtil;
import com.yihu.wlyy.figure.label.util.IdCardUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
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
 * 生日标签转换器
 */
@Component
public class BirthConvert implements Convert {
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    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(
                model -> {
                    String birth = null;
                    try {
                        birth  = IdCardUtil.getBirthdayForIdcard(model.getIdcard());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    SaveModel saveModel = new SaveModel();
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setDictCode(flLabelDict.getDictCode());
                    saveModel.setLabelCode(flLabelDict.getLabelCode());
                    saveModel.setLabelType(flLabelDict.getParentCode());
                    saveModel.setLabelName(flLabelDict.getLabelName());
                    saveModel.setLabelValue(birth);
                    //源数据来源时间
                    if(null != model.getSourceTime()){
                        saveModel.setSourceTime(model.getSourceTime());
                    }
                    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;
                    }
                    saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
                    saveModels.add(saveModel);
                }
        );
        return saveModels;
    }
}

+ 49 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ConsultConvert.java

@ -0,0 +1,49 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.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.Service;
import java.util.*;
/**
 * @author litaohong on 2018/4/8
 * @project patient-co-management
 * 咨询问题标签
 */
@Service
public class ConsultConvert 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 dict = flLabelDictList.get(0);
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dict.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));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

+ 17 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/Convert.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.figure.label.entity.FlLabelDict;
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.
 * 数据转换
 */
public interface Convert {
    List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source);
}

+ 246 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ConvertHelper.java

@ -0,0 +1,246 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.figure.label.entity.FlLabelDict;
import com.yihu.wlyy.figure.label.entity.FlLabelDictJob;
import com.yihu.wlyy.figure.label.enums.SourceTypeEnum;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ApplicationContextHolderUtil;
import com.yihu.wlyy.figure.label.constant.ConstantUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/**
 * @author lith on 2018.03.14
 * 维度的key值转换器
 */
@Component
@Scope("prototype")
public class ConvertHelper {
    private Logger logger = LoggerFactory.getLogger(ConvertHelper.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BasicDictItemHelper basicDictItemHelper;
    private ExecutorService executorService = Executors.newCachedThreadPool();
    private int numPerPage = 50000; //分页,一次性最多循环100000万条
    /**
     * 进行具体标签生成转换
     * @param dataModels
     * @param hbaseDatas
     * @param flLabelDictJob
     * @param sourceType
     * @param source
     * @return
     * @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) && CollectionUtils.isEmpty(hbaseDatas)){
            return saveModels;
        }
        //标签job未配置
        if(null == flLabelDictJob){
            return saveModels;
        }
        //转换器为空表示不需要转换
        if (StringUtils.isEmpty(flLabelDictJob.getConvertClazz())) {
            if(dataModels.size() >= numPerPage){
                int number = dataModels.size() / numPerPage + 1;
                for(int i = 0; i < number; i++){
                    MutilThreadConvert mutilThreadConvert = new MutilThreadConvert(dataModels.subList(i*numPerPage,(i+1)*numPerPage),flLabelDictJob.getCategoryId(),sourceType,source);
                    Future<List<SaveModel>> future = executorService.submit(mutilThreadConvert);
                    saveModels.addAll(future.get());
                }
            }else{
                return generateSaveModleWithOutConvert(dataModels,flLabelDictJob.getCategoryId(),sourceType,source);
            }
            return saveModels;
        }
        //转换器不为空,判断配置的字典是否存在,字典不存在则表示此条数据错误
        List<FlLabelDict> flLabelDictList = jdbcTemplate.query(flLabelDictJob.getSql(), new BeanPropertyRowMapper(FlLabelDict.class));
        if(CollectionUtils.isEmpty(flLabelDictList)){
            return saveModels;
        }
        try {
            // 加载转换器类
            Class clazz = Class.forName(flLabelDictJob.getConvertClazz());
            Object obj = ApplicationContextHolderUtil.getContext().getBean(clazz);
            Method method = obj.getClass().getMethod("convert", List.class, List.class,List.class,String.class,String.class);
            // 调用转换方法,数据量大,分批次调用
            if(null != dataModels && dataModels.size() >= numPerPage){
                int number = dataModels.size() / numPerPage + 1;
                for(int i = 0; i < number; i++){
                    List<SaveModel> list = new ArrayList<>();
                    if (i == number - 1) {
                        int size = dataModels.size();
                        list = (List<SaveModel>) method.invoke(obj, dataModels.subList(i * numPerPage, size), hbaseDatas, flLabelDictList, sourceType, source);
                    } else {
                        list = (List<SaveModel>) method.invoke(obj, dataModels.subList(i * numPerPage, (i + 1) * numPerPage), hbaseDatas, flLabelDictList, sourceType, source);
                    }
                    saveModels.addAll(list);
                }
                return saveModels;
            } else if(null != hbaseDatas && hbaseDatas.size() >= numPerPage){
                int number = hbaseDatas.size() / numPerPage + 1;
                for(int i = 0; i < number; i++){
                    List<SaveModel> list = new ArrayList<>();
                    if (i == number - 1) {
                        int size = hbaseDatas.size();
                        list = (List<SaveModel>) method.invoke(obj, dataModels, hbaseDatas.subList(i * numPerPage, size), flLabelDictList, sourceType, source);
                    }else {
                        list = (List<SaveModel>) method.invoke(obj, dataModels, hbaseDatas.subList(i*numPerPage,(i+1)*numPerPage),flLabelDictList,sourceType,source);
                    }
                    saveModels.addAll(list);
                }
                return saveModels;
            }
            else{
                 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();
            return saveModels;
        }
        return saveModels;
    }
    /**
     * 无需转换器直接转换,此种情况为源数据已经分类好标签
     * @param dataModels
     * @param categoryId
     * @param sourceType
     * @param source
     *
     * @return
     */
    public List<SaveModel> generateSaveModleWithOutConvert(List<DataModel> dataModels,Long categoryId,String sourceType,String source){
        String dictCode = basicDictItemHelper.dictCategoryMap.get(String.valueOf(categoryId));
        List<SaveModel> saveModels = new ArrayList<>();
        //lambda无法跳出循环
        for(DataModel dataModel:dataModels){
            SaveModel saveModel = new SaveModel();
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setDictCode(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());
                saveModel.setLabelCode(flLabelDictList.get(0).getLabelCode());
                saveModel.setLabelName(flLabelDictList.get(0).getLabelName());
                if(!StringUtils.isEmpty(dataModel.getLabelValue())){
                    if(StringUtils.endsWithIgnoreCase("height_dict",dictCode)){
                        saveModel.setLabelValue(dataModel.getLabelValue()+"cm");
                    }
                    else if(StringUtils.endsWithIgnoreCase("weight_dict",dictCode)){
                        saveModel.setLabelValue(dataModel.getLabelValue()+"kg");
                    }else{
                        saveModel.setLabelValue(dataModel.getLabelValue());
                    }
                }
            }else{
                //当有多种类别,sql里构造好需要格式,例如不同code对应不同的label_name
                saveModel.setLabelType(dataModel.getParentCode());
                saveModel.setLabelCode(dataModel.getLabelCode());
                saveModel.setLabelName(dataModel.getLabelName());
            }
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            this.generateDataSource(dataModel,saveModel,sourceType,source);
            //如果fl_job_config表配置的id和数据来源不一致,则不保存数据,原子性,全部不保存,不然部分存了部分没存不好剔除数据
            if(StringUtils.isEmpty(saveModel.getSource())){
                return new ArrayList<>();
            }
            if(!StringUtils.isEmpty(dataModel.getSourceTime())){
                saveModel.setSourceTime(dataModel.getSourceTime());
            }
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
    /**
     * 生成数据来源
     * @param dataModel
     * @param saveModel
     * @param sourceType
     * @param sources
     * @return
     */
    public void generateDataSource(DataModel dataModel,SaveModel saveModel,String sourceType,String sources) {
        if(!StringUtils.endsWithIgnoreCase(SourceTypeEnum.MYSQL.toString(),sourceType) && !StringUtils.endsWithIgnoreCase(SourceTypeEnum.ELASTICSEARCH.toString(),sourceType) && !StringUtils.endsWithIgnoreCase(SourceTypeEnum.HBASE.toString(),sourceType)){
            return;
        }
        StringBuilder ids = new StringBuilder();
        // 默认值为0
        if(dataModel.getId() != null && dataModel.getId() != 0 ){
            ids.append(dataModel.getId()).append(",");
        }
        if(dataModel.getId1() != null && dataModel.getId1() != 0 ){
            ids.append(dataModel.getId1()).append(",");
        }
        if(dataModel.getId2() != null && dataModel.getId2() != 0 ){
            ids.append(dataModel.getId2()).append(",");
        }
        if(dataModel.getId3() != null && dataModel.getId3() != 0 ){
            ids.append(dataModel.getId3()).append(",");
        }
        if(dataModel.getId4() != null && dataModel.getId4() != 0 ){
            ids.append(dataModel.getId4());
        }
        if(!StringUtils.isEmpty(dataModel.getIdstr())){
            ids.append(dataModel.getIdstr());
        }
        if(!StringUtils.isEmpty(dataModel.getIdstr1())){
            ids.append(dataModel.getIdstr1());
        }
        if(!StringUtils.isEmpty(dataModel.getIdstr2())){
            ids.append(dataModel.getIdstr2());
        }
        String[] idArr = ids.toString().split(",");
        String[]sourceArr = sources.split(",");
        if(idArr.length != sourceArr.length){
            logger.error("number of id is not compatible with table's setted in fl_job_config[sql,source],model do not save!");
            return;
        }
        StringBuilder source = new StringBuilder();
        for(int i = 0; i < idArr.length;i++){
            source.append(sourceType).append(".").append(sourceArr[i]).append(".").append(idArr[i]);
            if(i != idArr.length -1){
                source.append(",");
            }
        }
        saveModel.setSource(source.toString());
        return ;
    }
}

+ 70 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/EhrHealthProblemConvert.java

@ -0,0 +1,70 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.ConstantUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import com.yihu.wlyy.figure.label.util.TimeUtil;
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);
                    String javaTime = TimeUtil.toJavaTime(String.valueOf(hbaseMap.get("event_date")));
                    saveModel.setSourceTime(javaTime);
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
                    saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
                    saveModels.add(saveModel);
                }
        );
        return saveModels;
    }
}

+ 216 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/EhrICD10CMConvert.java

@ -0,0 +1,216 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.base.SolrHelper;
import com.yihu.wlyy.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.constant.ConstantUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import com.yihu.wlyy.figure.label.util.TimeUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.solr.common.SolrDocumentList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
 * @author litaohong on 2018/5/7
 * @project patient-co-management
 * 医疗云数据,标准疾病诊断标签
 */
@Component
public class EhrICD10CMConvert implements Convert{
    public static final int solrFqSize = 1000;
    @Autowired
    private ConvertHelper convertHelper;
    @Autowired
    private SolrHelper solrHelper;
    @Autowired
    @Qualifier("healtharchiveTemplate")
    private JdbcTemplate healtharchiveTemplate;
    @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<>();
        if(CollectionUtils.isEmpty(hbaseDatas)){
            return saveModels;
        }
        FlLabelDict one = flLabelDictList.get(0);
        StringBuilder code = new StringBuilder();
        List<String> rowkeyList = new ArrayList<>();
        //此次循环,先剔除无用数据
        for (int i = 0; i < hbaseDatas.size(); i++) {
            if (null == hbaseDatas.get(i).get("diagnosis")) {
                continue;
            }
            Object labelName = hbaseDatas.get(i).get("diagnosis_name");
            if (null == labelName) {
                continue;
            }
            String labelCodeStr = String.valueOf(hbaseDatas.get(i).get("diagnosis"));
            if (labelCodeStr.contains(";")) {
                labelCodeStr = labelCodeStr.replace(";", "");
            }
            code.append("'").append(labelCodeStr).append("',");
            rowkeyList.add(String.valueOf(hbaseDatas.get(i).get("rowkey")));
        }
        // 根据rowkey去solr查子表的rowkey,因为rowkey含有字典集,根据字典集即可判断是否新生儿,孕妇等
        String q = "*:*";
        // 返回指定的字段
        String fl = "rowkey,profile_id";
        int num = rowkeyList.size()/solrFqSize + 1;
        List<SolrDocumentList> documentList = new ArrayList<>();
        for(int i = 0; i < num; i++){
            List<String> subList = null;
            if(i == num - 1){
                subList = rowkeyList.subList(i*solrFqSize,rowkeyList.size());
            }else{
                subList = rowkeyList.subList(i*solrFqSize,(i+1)*solrFqSize);
            }
            StringBuilder rowkeyFq = new StringBuilder("profile_id:(");
            for(int j = 0; j < subList.size();j++){
                if(j == subList.size() - 1){
                    rowkeyFq.append(rowkeyList.get(j)).append(")");
                }else{
                    rowkeyFq.append(rowkeyList.get(j)).append(" OR ");
                }
            }
            // 构造过滤查询参数
            String[] fq = {rowkeyFq.toString()};
            long count = 0;
            SolrDocumentList result = null;
            try {
                count = solrHelper.count(ConstantUtil.subcore,q);
                result = solrHelper.queryfl(ConstantUtil.subcore,q,fq,null,fl,0,count);
            } catch (Exception e) {
                e.printStackTrace();
            }
            if(!CollectionUtils.isEmpty(result)){
                documentList.add(result);
            }
        }
        Map<String,String> rowkwy2ProfileIdmap = new HashMap<>();
        if(CollectionUtils.isEmpty(documentList)){
            return saveModels;
        }
        for(SolrDocumentList sdl:documentList){
            sdl.forEach(
                    oneDocument -> {
                        String rowkey = String.valueOf(oneDocument.get("profile_id"));
                        String Subrowkey = String.valueOf(oneDocument.get("rowkey"));
                        if (rowkwy2ProfileIdmap.containsKey(rowkey) && rowkwy2ProfileIdmap.get(rowkey).contains(Subrowkey.split("\\$")[1])) {
                            return;
                        }
                        rowkwy2ProfileIdmap.put(rowkey, Subrowkey);
                    }
            );
        }
        String sql = "select code,chronic_flag,infectious_flag from icd10_dict where code in (" + code.substring(0,code.lastIndexOf(",")) + ")";
        List<Map<String,Object>> icd10Map = healtharchiveTemplate.queryForList(sql);
        Map<String,String> chronicMap = new HashMap<>();
        Map<String,String> infectiousMap = new HashMap<>();
        icd10Map.forEach(
                map -> {
                    if(null != map.get("chronic_flag")){
                        chronicMap.put(String.valueOf(map.get("code")),String.valueOf(map.get("chronic_flag")));
                    }
                    if(null != map.get("infectious_flag")){
                        infectiousMap.put(String.valueOf(map.get("code")),String.valueOf(map.get("infectious_flag")));
                    }
                }
        );
        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());
                    String labelCode = String.valueOf(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));
                    String labelValue = "";
                    String[] codearr = labelCode.split(";");
                    for (String codeStr : codearr) {
                        if (null != chronicMap.get(codeStr) && null != infectiousMap.get(codeStr)) {
                            labelValue = "慢病;传染病";
                        } else if (null != chronicMap.get(codeStr)) {
                            labelValue = "慢病";
                        } else if (null != infectiousMap.get(codeStr)) {
                            labelValue = "传染病";
                        }
                    }
                    if(rowkwy2ProfileIdmap.containsKey(hbaseMap.get("rowkey")) && (rowkwy2ProfileIdmap.get(hbaseMap.get("rowkey")).contains("HDSB02_04") || rowkwy2ProfileIdmap.get(hbaseMap.get("rowkey")).contains("HDSB02_07") || rowkwy2ProfileIdmap.get(hbaseMap.get("rowkey")).contains("HDSB02_87"))){
                        labelValue = labelValue + ";孕妇";
                    }else if(rowkwy2ProfileIdmap.containsKey(hbaseMap.get("rowkey")) && (rowkwy2ProfileIdmap.get(hbaseMap.get("rowkey")).contains("HDSB01_01")) || (rowkwy2ProfileIdmap.containsKey(hbaseMap.get("rowkey")) && rowkwy2ProfileIdmap.get(hbaseMap.get("rowkey")).contains("HDSB01_03")) || (rowkwy2ProfileIdmap.containsKey(hbaseMap.get("rowkey")) && rowkwy2ProfileIdmap.get(hbaseMap.get("rowkey")).contains("HDSD00_89"))){
                        labelValue = labelValue + ";新生儿";
                    }
                    saveModel.setLabelValue(labelValue);
                    DataModel dataModel = new DataModel();
                    dataModel.setIdstr(String.valueOf(hbaseMap.get("rowkey")));
                    convertHelper.generateDataSource(dataModel,saveModel,sourceType,source);
                    String javaTime = TimeUtil.toJavaTime(String.valueOf(hbaseMap.get("event_date")));
                    saveModel.setSourceTime(javaTime);
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
                    saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
                    saveModels.add(saveModel);
                }
        );
        return saveModels;
    }
    class ThreadSolrSearch implements Callable {
        private String q;
        private String[] fq;
        private String fl;
        public ThreadSolrSearch(String q,String[] fq,String fl){
            this.q = q;
            this.fq = fq;
            this.fl = fl;
        }
        @Override
        public Object call() throws Exception {
            long count = 0;
            SolrDocumentList documentList = null;
            try {
                count = solrHelper.count(ConstantUtil.subcore,q);
                documentList = solrHelper.queryfl(ConstantUtil.subcore,q,fq,null,fl,0,count);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return documentList;
        }
    }
}

+ 49 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/EvaluateConvert.java

@ -0,0 +1,49 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.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 java.util.*;
/**
 * @author litaohong on 2018/4/9
 * @project patient-co-management
 * 评价行为标签
 */
@Component
public class EvaluateConvert 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 dict = flLabelDictList.get(0);
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dict.getLabelCode());
            saveModel.setLabelName(dataModel.getLabelName());
            // 评价相关的问题的code(业务id)
            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));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

+ 122 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/FeedbackConvert.java

@ -0,0 +1,122 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.base.es.config.ElastricSearchHelper;
import com.yihu.wlyy.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.constant.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 FeedbackConvert implements Convert {
    @Autowired
    private ConvertHelper convertHelper;
    @Autowired
    private ElastricSearchHelper elastricSearchHelper;
    private Map<String,String> distinctIdcardMap = new HashMap<>();
    @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 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();
            int value = 0;
            saveModel.setIdcard(idcard);
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dict.getLabelCode());
            saveModel.setLabelName(dict.getLabelName());
            if(mapES.containsKey(idcard)){
                value = Integer.parseInt(mapES.get(idcard));
            }
            if(distinctIdcardMap.containsKey(idcard)){
                value = Integer.parseInt(distinctIdcardMap.get(idcard)) + value;
            }
            saveModel.setLabelValue(String.valueOf(value));
            convertHelper.generateDataSource(modelMap.get(idcard),saveModel,sourceType,source);
            if (StringUtils.isEmpty(saveModel.getSource())) {
                return new ArrayList<>();
            }
            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;
    }
    /**
     * 累加es中每个用户反馈的次数
     * @return
     */
    public Map<String,String> countESFeedbackByIdcard(List<DataModel> modelList){
        Map<String, String> result = new HashMap<>();
        List<Map<String,Object>> list = new ArrayList<>();
        StringBuilder idcardStr = new StringBuilder();
        idcardStr.append("(");
        for (int i = 0; i < modelList.size(); i++) {
            idcardStr.append("'").append(modelList.get(i).getIdcard()).append("'");
            if (i != modelList.size() - 1) {
                idcardStr.append(",");
            }
        }
        idcardStr.append(")");
        //先查找出es中已有的用户的反馈次数
        String querySql = "select labelValue from " + ConstantUtil.figure_label_es_index + "/" + ConstantUtil.figure_label_es_type + " where lableType = 'feedback_dict' and idcard in " + idcardStr.toString();
        list = elastricSearchHelper.excuceSQL(querySql);
        //组装以idcard为key的map
        if(!CollectionUtils.isEmpty(list)){
            list.forEach(
                    data -> {
                        result.put(data.get("idcard").toString(), data.get("lableValue").toString());
                    }
            );
        }
        return result;
    }
    /**
     * 统计从数据库中查询出来的idcard的反馈记录次数,一个人可能会有多条反馈
     * @param modelList
     * @return
     */
    public Map<String,DataModel> distinctIdcard(List<DataModel> modelList){
        Map<String,DataModel> result = new HashMap<>();
        modelList.forEach(
                model ->{
                    if(distinctIdcardMap.containsKey(model.getIdcard())){
                        int count = Integer.parseInt(distinctIdcardMap.get(model.getIdcard())) + 1;
                        distinctIdcardMap.put(model.getIdcard(),String.valueOf(count));
                    }else {
                        distinctIdcardMap.put(model.getIdcard(),"1");
                    }
                    if(result.containsKey(model.getIdcard())){
                        return;
                    }else{
                        result.put(model.getIdcard(),model);
                    }
                }
        );
        return result;
    }
}

+ 21 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/FollowupStatusConvert.java

@ -0,0 +1,21 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.figure.label.entity.FlLabelDict;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import java.util.List;
import java.util.Map;
/**
 * @author litaohong on 2018/6/15
 * @project patient-co-management
 * 居民随访状态转换器
 */
public class FollowupStatusConvert implements Convert {
    @Override
    public List<SaveModel> convert(List<DataModel> modelList, List<Map<String, Object>> hbaseDatas, List<FlLabelDict> flLabelDictList, String sourceType, String source) {
        return null;
    }
}

+ 57 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/HealthEduArticalConvert.java

@ -0,0 +1,57 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.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 java.util.*;
/**
 * @author litaohong on 2018/4/4
 * @project patient-co-management
 * 健康教育文章阅读行为标签转换器
 */
@Component
public class HealthEduArticalConvert 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 dict = flLabelDictList.get(0);
        Map<String,String> dictMap = new HashMap<>();
        flLabelDictList.forEach(
                one ->{
                    dictMap.put(one.getLabelCode(),one.getLabelName());
                }
        );
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dataModel.getLabelCode());
            saveModel.setLabelName(dictMap.get(dataModel.getLabelCode()));
            // 健康文章的code(业务表id)
            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));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

+ 76 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/HealthEduArticleReceiveConvert.java

@ -0,0 +1,76 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.figure.label.constant.BusinessConstant;
import com.yihu.wlyy.figure.label.constant.ConstantUtil;
import com.yihu.wlyy.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.MakeIDUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.annotation.PostConstruct;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
 * @author litaohong on 2018/5/31
 * @project patient-co-management
 */
public class HealthEduArticleReceiveConvert implements Convert{
    public Map<String,String> code2IdcardMap = new ConcurrentHashMap<>();
    @Autowired
    private ConvertHelper convertHelper;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @PostConstruct
    public void initMap(){
        String sql = "select code,idcard from wlyy.wlyy_patient";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        list.forEach(
                map -> {
                    code2IdcardMap.put(String.valueOf(map.get("code")),String.valueOf(map.get("idcard")));
                }
        );
    }
    @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 dict = flLabelDictList.get(0);
        Map<String,String> dictMap = new HashMap<>();
        flLabelDictList.forEach(
                one ->{
                    dictMap.put(one.getLabelCode(),one.getLabelName());
                }
        );
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setIdcard(code2IdcardMap.get(dataModel.getIdcard()));
            saveModel.setDictCode(dict.getDictCode());
            saveModel.setLabelType(dataModel.getParentCode());
            saveModel.setLabelCode(dataModel.getLabelCode());
            saveModel.setLabelName(dataModel.getLabelName());
            saveModel.setLabelValue(dataModel.getFirstLevelCategoryName() + BusinessConstant.separator + dataModel.getSecondLevelCategoryName());
            // 文章推送人名字
            saveModel.setSendName(dataModel.getSendName());
            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));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

+ 55 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsConsultConvert.java

@ -0,0 +1,55 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.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 java.util.*;
/**
 * @author litaohong on 2018/4/9
 * @project patient-co-management
 * 是否有咨询问题标签
 */
@Component
public class IsConsultConvert 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 dict = flLabelDictList.get(0);
        // 有咨询code为0,代表有咨询问题
        String hasConsult = "0";
        Map<String,String> dictMap = new HashMap<>();
        flLabelDictList.forEach(
                one ->{
                    dictMap.put(one.getLabelCode(),one.getLabelName());
                }
        );
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(hasConsult);
            saveModel.setLabelName(dictMap.get(hasConsult));
            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));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

+ 60 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsDrinkingConvert.java

@ -0,0 +1,60 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.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 java.util.*;
/**
 * @author humingfen on 2018.04.19
 * 是否饮酒标签转换器
 */
@Component
public class IsDrinkingConvert 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<>();
        // 饮酒code为2,代表未知
        String hasDrinking = "2";
        /*Map<String,String> dictMap = new HashMap<>();
        flLabelDictList.forEach(
                one ->{
                    dictMap.put(one.getLabelCode(),one.getLabelName());
                }
        );*/
        for(DataModel dataModel:modelList){
            if(StringUtils.isNotBlank(dataModel.getLabelValue())) {
                float dailyDrinking = Float.parseFloat(dataModel.getLabelValue());
                if(dailyDrinking > 0){
                    hasDrinking = "0";
                }else if(dailyDrinking <= 0) {
                    hasDrinking = "1";
                }
            }
            SaveModel saveModel = new SaveModel();
            FlLabelDict dict = flLabelDictList.get(Integer.parseInt(hasDrinking));
            saveModel.setId(MakeIDUtil.makeEsSaveModelID(dataModel,dict));
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(hasDrinking);
            saveModel.setLabelName(dict.getLabelName());
            convertHelper.generateDataSource(dataModel,saveModel,sourceType,source);
            //如果fl_job_config表配置的id和数据来源不一致,则不保存数据
            if (StringUtils.isEmpty(saveModel.getSource())) {
                return new ArrayList<>();
            }
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

+ 59 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsOnlineConvert.java

@ -0,0 +1,59 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.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.*;
/**
 * 适用于线上/线下的签约、缴费
 */
@Component
public class IsOnlineConvert implements Convert {
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    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;
        }
        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.setLabelType(one.getParentCode());
                    saveModel.setLabelCode(model.getLabelCode());
                    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;
                    }
                    saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
                    saveModels.add(saveModel);
                }
        );
        return saveModels;
    }
}

+ 60 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsSmokingConvert.java

@ -0,0 +1,60 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.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 java.util.*;
/**
 * @author humingfen on 2018.03.14
 * 是否抽烟标签转换器
 */
@Component
public class IsSmokingConvert 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<>();
        // 抽烟code为2,代表未知
        String hasSmoking = "2";
        Map<String,String> dictMap = new HashMap<>();
        flLabelDictList.forEach(
                one ->{
                    dictMap.put(one.getLabelCode(),one.getLabelName());
                }
        );
        for(DataModel dataModel:modelList){
            if(StringUtils.isNotBlank(dataModel.getLabelValue())) {
                float dailySmoking = Float.parseFloat(dataModel.getLabelValue());
                if(dailySmoking > 0){
                    hasSmoking = "0";
                }else if(dailySmoking <= 0) {
                    hasSmoking = "1";
                }
            }
            SaveModel saveModel = new SaveModel();
            FlLabelDict dict = flLabelDictList.get(Integer.parseInt(hasSmoking));
            saveModel.setId(MakeIDUtil.makeEsSaveModelID(dataModel,dict));
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(hasSmoking);
            saveModel.setLabelName(dictMap.get(hasSmoking));
            convertHelper.generateDataSource(dataModel,saveModel,sourceType,source);
            //如果fl_job_config表配置的id和数据来源不一致,则不保存数据
            if (StringUtils.isEmpty(saveModel.getSource())) {
                return new ArrayList<>();
            }
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

+ 114 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/MutilThreadConvert.java

@ -0,0 +1,114 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.ConstantUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import com.yihu.wlyy.figure.label.util.TimeUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Callable;
/**
 * @Author lith 2018/03/23
 * 多线程分页查询mysql数据,因为mysql数据量比较大的时候,会比较慢
 */
public class MutilThreadConvert implements Callable {
    private Logger logger = LoggerFactory.getLogger(MutilThreadConvert.class);
    @Autowired
    private ConvertHelper convertHelper;
    @Autowired
    private BasicDictItemHelper basicDictItemHelper;
    private List<DataModel> dataModels;
    private Long categoryId;
    private String sourceType;
    private String source;
    public MutilThreadConvert(List<DataModel> dataModels,Long categoryId, String sourceType, String source){
        this.dataModels = dataModels;
        this.categoryId = categoryId;
        this.sourceType = sourceType;
        this.source = source;
    }
    @Override
    public Object call() throws Exception {
        String title = Thread.currentThread().getName() + " generate savemodel";
        long start = System.currentTimeMillis();
        TimeUtil.start(logger,title,start);
        List<SaveModel> list = generateSaveModleWithOutConvert(dataModels,categoryId,sourceType,source);
        TimeUtil.finish(logger,title,start,System.currentTimeMillis());
        return list;
    }
    /**
     * 无需转换器直接转换,此种情况为源数据已经分类好标签
     * @param dataModels
     * @param categoryId
     * @param sourceType
     * @param source
     *
     * @return
     */
    public List<SaveModel> generateSaveModleWithOutConvert(List<DataModel> dataModels, Long categoryId, String sourceType, String source){
        String dictCode = basicDictItemHelper.dictCategoryMap.get(String.valueOf(categoryId));
        List<SaveModel> saveModels = new ArrayList<>();
        //lambda无法跳出循环
        for(DataModel dataModel:dataModels){
            SaveModel saveModel = new SaveModel();
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setDictCode(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());
                saveModel.setLabelCode(flLabelDictList.get(0).getLabelCode());
                saveModel.setLabelName(flLabelDictList.get(0).getLabelName());
                if(!StringUtils.isEmpty(dataModel.getLabelValue())){
                    if(StringUtils.endsWithIgnoreCase("height_dict",dictCode)){
                        saveModel.setLabelValue(dataModel.getLabelValue()+"cm");
                    }
                    else if(StringUtils.endsWithIgnoreCase("weight_dict",dictCode)){
                        saveModel.setLabelValue(dataModel.getLabelValue()+"kg");
                    }else{
                        saveModel.setLabelValue(dataModel.getLabelValue());
                    }
                }
            }else{
                //当有多种类别,sql里构造好需要格式,例如不同code对应不同的label_name
                saveModel.setLabelType(dataModel.getParentCode());
                saveModel.setLabelCode(dataModel.getLabelCode());
                saveModel.setLabelName(dataModel.getLabelName());
            }
            saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
            convertHelper.generateDataSource(dataModel,saveModel,sourceType,source);
            //如果fl_job_config表配置的id和数据来源不一致,则不保存数据,原子性,全部不保存,不然部分存了部分没存不好剔除数据
            if(StringUtils.isEmpty(saveModel.getSource())){
                return new ArrayList<>();
            }
            if(!StringUtils.isEmpty(dataModel.getSourceTime())){
                saveModel.setSourceTime(dataModel.getSourceTime());
            }
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

+ 54 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/OnLineConsultConvert.java

@ -0,0 +1,54 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.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 java.util.*;
/**
 * @author litaohong on 2018/03/27
 * @project patient-co-management
 * 线上咨询问题标签(包括续方咨询,续方咨询只是线上咨询的一种类型)
 */
@Component
public class OnLineConsultConvert 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 dict = flLabelDictList.get(0);
        Map<String,String> dictMap = new HashMap<>();
        flLabelDictList.forEach(
                one ->{
                    dictMap.put(one.getLabelCode(),one.getLabelName());
                }
        );
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dataModel.getLabelCode());
            saveModel.setLabelName(dictMap.get(dataModel.getLabelCode()));
            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));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

+ 56 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/OnlineAppointmentConvert.java

@ -0,0 +1,56 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.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 java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @author litaohong on 2018/4/12
 * @project patient-co-management
 * 网上预约行为标签
 */
@Component
public class OnlineAppointmentConvert 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 dict = flLabelDictList.get(0);
        for(DataModel dataModel : modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setDictCode(dict.getDictCode());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dataModel.getLabelCode());
            saveModel.setLabelName(dataModel.getParentName() + "-" + dataModel.getLabelName());
            saveModel.setLabelValue(dataModel.getLabelValue());
            //如果有医生代预约
            if(!StringUtils.isEmpty(dataModel.getDoctor())){
                saveModel.setDoctor(dataModel.getDoctor());
            }
            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));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

+ 77 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ReplyInTimeConvert.java

@ -0,0 +1,77 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.base.es.config.ElastricSearchHelper;
import com.yihu.wlyy.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.MakeIDUtil;
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.List;
import java.util.Map;
/**
 * @author litaohong on 2018/4/8
 * @project patient-co-management
 * 医生咨询分析--及时回复标签
 */
@Component
public class ReplyInTimeConvert implements Convert{
    @Autowired
    private ConvertHelper convertHelper;
    @Autowired
    private ElastricSearchHelper elastricSearchHelper;
    @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 dict = flLabelDictList.get(0);
        for(DataModel model:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setIdcard(model.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(dict.getLabelCode());
            saveModel.setLabelName(dict.getLabelName());
            saveModel.setLabelValue(model.getLabelValue());
            //记录回复时间,方便以后统计一定时间内的回复率
            saveModel.setSourceTime(model.getSourceTime());
            convertHelper.generateDataSource(model,saveModel,sourceType,source);
            if(StringUtils.isEmpty(saveModel.getSource())){
                return new ArrayList<>();
            }
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
    //lambda无法跳出循环
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5};
        List list = new ArrayList();
        list.addAll(CollectionUtils.arrayToList(arr));
        list.forEach(
                one ->{
                    if(StringUtils.endsWithIgnoreCase(one.toString(),"3")){
                        return;
                    }
                    System.out.println(one);
                }
        );
        System.out.println("*********************************************************");
        for(Object one:list){
            if(StringUtils.endsWithIgnoreCase(one.toString(),"3")){
                return;
            }
            System.out.println(one);
        }
    }
}

+ 64 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SexConvert.java

@ -0,0 +1,64 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.ConstantUtil;
import com.yihu.wlyy.figure.label.util.IdCardUtil;
import com.yihu.wlyy.figure.label.util.MakeIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.*;
/**
 * @author lith on 2018.03.14
 * 性别标签转换器
 */
@Component
public class SexConvert implements Convert{
    @Autowired
    private ConvertHelper convertHelper;
    @Override
    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<>();
        flLabelDictList.forEach(
                fLlabelDict -> {
                    map.put(fLlabelDict.getLabelCode(),fLlabelDict.getLabelName());
                }
        );
        models.forEach(
                model -> {
                    SaveModel saveModel = new SaveModel();
                    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));
                    //源数据来源时间
                    if(null != model.getSourceTime()){
                        saveModel.setSourceTime(model.getSourceTime());
                    }
                    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;
                    }
                    saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
                    saveModels.add(saveModel);
                }
        );
        return saveModels;
    }
}

+ 56 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/WxSubscribeConvert.java

@ -0,0 +1,56 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.wlyy.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.constant.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 java.util.*;
/**
 * @author litaohong on 2018/03/27
 * @project patient-co-management
 * 是否有关注i健康微信公众号
 */
@Component
public class WxSubscribeConvert 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 dict = flLabelDictList.get(0);
        // 有咨询code为0,代表有咨询问题
        String yes = "0";
        Map<String,String> dictMap = new HashMap<>();
        flLabelDictList.forEach(
                one ->{
                    dictMap.put(one.getLabelCode(),one.getLabelName());
                }
        );
        for(DataModel dataModel:modelList){
            SaveModel saveModel = new SaveModel();
            saveModel.setIdcard(dataModel.getIdcard());
            saveModel.setLabelType(dict.getParentCode());
            saveModel.setLabelCode(yes);
            saveModel.setLabelName(dictMap.get(yes));
            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));
            saveModel.setId(MakeIDUtil.makeSaveModelID(saveModel));
            saveModels.add(saveModel);
        }
        return saveModels;
    }
}

+ 31 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FLLabelDictDao.java

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

+ 69 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/dao/FlJobConfigDao.java

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

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

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

+ 142 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/entity/FlJobConfig.java

@ -0,0 +1,142 @@
package com.yihu.wlyy.figure.label.entity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * @author lith on 2018.03.07
 *
 */
@Entity
@Table(name = "fl_job_config")
public class FlJobConfig extends IdEntity {
    private String jobName;
    private String jobClass;
    private String query_sql;
    private String countSql;
    private Integer sqlFieldType;
    private String sqlFieldValue;
    private String sqlField;
    private String quartzCron;
    private String status;
    private String del;
    private String sourceType;
    private String source;
    private String datasource;
    private String extractField;
    public String getJobName() {
        return jobName;
    }
    public void setJobName(String jobName) {
        this.jobName = jobName;
    }
    public String getJobClass() {
        return jobClass;
    }
    public void setJobClass(String jobClass) {
        this.jobClass = jobClass;
    }
    public String getQuery_sql() {
        return query_sql;
    }
    public void setQuery_sql(String query_sql) {
        this.query_sql = query_sql;
    }
    public Integer getSqlFieldType() {
        return sqlFieldType;
    }
    public void setSqlFieldType(Integer sqlFieldType) {
        this.sqlFieldType = sqlFieldType;
    }
    public String getSqlFieldValue() {
        return sqlFieldValue;
    }
    public void setSqlFieldValue(String sqlFieldValue) {
        this.sqlFieldValue = sqlFieldValue;
    }
    public String getSqlField() {
        return sqlField;
    }
    public void setSqlField(String sqlField) {
        this.sqlField = sqlField;
    }
    public String getQuartzCron() {
        return quartzCron;
    }
    public void setQuartzCron(String quartzCron) {
        this.quartzCron = quartzCron;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
    public String getSourceType() {
        return sourceType;
    }
    public void setSourceType(String sourceType) {
        this.sourceType = sourceType;
    }
    public String getSource() {
        return source;
    }
    public void setSource(String source) {
        this.source = source;
    }
    public String getDatasource() {
        return datasource;
    }
    public void setDatasource(String datasource) {
        this.datasource = datasource;
    }
    public String getExtractField() {
        return extractField;
    }
    public void setExtractField(String extractField) {
        this.extractField = extractField;
    }
    public String getCountSql() {
        return countSql;
    }
    public void setCountSql(String countSql) {
        this.countSql = countSql;
    }
}

+ 52 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/entity/FlLabelDict.java

@ -0,0 +1,52 @@
package com.yihu.wlyy.figure.label.entity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * @author lith on 2018.03.07
 *
 */
@Entity
@Table(name = "fl_label_dict")
public class FlLabelDict extends IdEntity {
    private String parentCode;
    private String labelName;
    private String labelCode;
    private String dictCode;
    public String getDictCode() {
        return dictCode;
    }
    public void setDictCode(String dictCode) {
        this.dictCode = dictCode;
    }
    public String getParentCode() {
        return parentCode;
    }
    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }
    public String getLabelName() {
        return labelName;
    }
    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }
    public String getLabelCode() {
        return labelCode;
    }
    public void setLabelCode(String labelCode) {
        this.labelCode = labelCode;
    }
}

+ 60 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/entity/FlLabelDictJob.java

@ -0,0 +1,60 @@
package com.yihu.wlyy.figure.label.entity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * @author lith on 2018.03.07
 *
 */
@Entity
@Table(name = "fl_label_dict_job")
public class FlLabelDictJob extends IdEntity {
    private Long jobId;
    private String labelType;
    private String sql;
    private String convertClazz;
    private Long categoryId;
    public Long getCategoryId() {
        return categoryId;
    }
    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }
    public Long getJobId() {
        return jobId;
    }
    public void setJobId(Long jobId) {
        this.jobId = jobId;
    }
    public String getLabelType() {
        return labelType;
    }
    public void setLabelType(String labelType) {
        this.labelType = labelType;
    }
    public String getSql() {
        return sql;
    }
    public void setSql(String sql) {
        this.sql = sql;
    }
    public String getConvertClazz() {
        return convertClazz;
    }
    public void setConvertClazz(String convertClazz) {
        this.convertClazz = convertClazz;
    }
}

+ 38 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/entity/IdEntity.java

@ -0,0 +1,38 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.figure.label.entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
/**
 * 统一定义id的entity基类.
 * 
 * 基类统一定义id的属性名称、数据类型、列名映射及生成策略.
 * Oracle需要每个Entity独立定义id的SEQUCENCE时,不继承于本类而改为实现一个Idable的接口。
 * 
 * @author calvin
 */
// JPA 基类的标识
@MappedSuperclass
public abstract class IdEntity implements Serializable {
	private static final long serialVersionUID = 3673803562328635206L;
	protected Long id;  // 非业务主键
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
}

+ 34 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/enums/JobSqlFieldTypeEnum.java

@ -0,0 +1,34 @@
package com.yihu.wlyy.figure.label.enums;
/**
 * @author litaohong on 2018/4/11
 * @project patient-co-management
 *
 * 增量字段类型枚举 1时间 (yyyy-mm-dd  HH:MM:ss)2数字
 */
public enum JobSqlFieldTypeEnum {
    TIME(1,"时间"),
    NUM(2,"数字");
    private int value;
    private String desc;
    private JobSqlFieldTypeEnum(int value,String desc){
        this.value = value;
        this.desc = desc;
    }
    public int getValue() {
        return value;
    }
    public String getDesc() {
        return desc;
    }
    @Override
    public String toString() {
        return String.valueOf(this.getValue());
    }
}

+ 12 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/enums/SourceTypeEnum.java

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

+ 77 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/ESExtracter.java

@ -0,0 +1,77 @@
package com.yihu.wlyy.figure.label.extract;
import com.yihu.base.es.config.ElasticsearchUtil;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.util.BeanUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @author humingfen on 2018.04.19
 * ES数据抽取器
 */
@Component
public class ESExtracter implements Extracter{
    private Logger logger = LoggerFactory.getLogger(ESExtracter.class);
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    @Override
    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){
            try {
                DataModel dataModel = (DataModel)BeanUtil.mapToBean(tempMap,DataModel.class);
               /* for (String s : tempMap.keySet()) {
                    String key = null;
                    Object value = tempMap.get(s);
                    if (s.startsWith("_")) {
                        continue;
                    }else if((s.equals("id") || s.equals("id1") || s.equals("id2")) && value != null) {
                        value = Integer.parseInt(String.valueOf(value));
                    }
                    key = "set" + UpFirstStr(s);
                    try {
                        if (value instanceof String) {
                            DataModel.class.getMethod(key, String.class).invoke(dataModel, value);
                        } else if (value instanceof Integer) {
                            DataModel.class.getMethod(key, Integer.class).invoke(dataModel, value);
                        } else if (value instanceof Double) {
                            DataModel.class.getMethod(key, Double.class).invoke(dataModel, value);
                        } else if (value instanceof java.util.Date) {
                            DataModel.class.getMethod(key, java.util.Date.class).invoke(dataModel, value);
                        }
                    } catch (Exception e) {
                        logger.error(e.getMessage());
                    }
                }*/
                saveModels.add(dataModel);
            }catch (Exception e) {
                e.printStackTrace();
            }
        }
        return saveModels;
    }
    /**
     * 首字母大写
     *
     * @param str
     * @return
     */
    private String UpFirstStr(String str) {
        return str.replaceFirst(str.substring(0, 1), str.substring(0, 1).toUpperCase());
    }
}

+ 22 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/Extracter.java

@ -0,0 +1,22 @@
package com.yihu.wlyy.figure.label.extract;
import com.yihu.wlyy.figure.label.model.DataModel;
import java.util.List;
/**
 * @author lith on 2018.03.14 -- Created by chenweida on 2018/3/7.
 * 数据抽取器
 */
public interface Extracter {
    /**
     * 数据抽取
     *
     * @return
     */
//    List<ExtractModel> extract();
    List<DataModel> extractData(String sql,String datasource);
}

+ 150 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/HbaseExtracter.java

@ -0,0 +1,150 @@
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.Get;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.filter.BinaryComparator;
import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.filter.QualifierFilter;
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.data.hadoop.hbase.TableCallback;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
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 HBaseHelper hBaseHelper;
    @Autowired
    private SolrHelper solrHelper;
    @Autowired
    private HbaseTemplate hbaseTemplate;
    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);
        if(CollectionUtils.isEmpty(rowkeys)){
            return resultList;
        }
        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, "rowkey",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, String fl,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,fl,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;
    }
}

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

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

+ 52 - 0
svr/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;
    }
}

+ 137 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/extract/MysqlExtracter.java

@ -0,0 +1,137 @@
package com.yihu.wlyy.figure.label.extract;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.util.TimeUtil;
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.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.*;
/**
 * @author lith on 2018.03.14 -- Created by chenweida on 2018/3/7.
 * mysql数据抽取器
 */
@Component
public class MysqlExtracter implements Extracter {
    private Logger logger = LoggerFactory.getLogger(MysqlExtracter.class);
    private ExecutorService threadPoolService = Executors.newCachedThreadPool();
    private int numPerPage = 100000; //一次性最多查询10万条
    private Map<String,JdbcTemplate> templateMap = new HashMap<>();
    @Autowired
    @Qualifier("jdbcTemplate")
    private JdbcTemplate wlyydefaultJdbcTemplate;
    @Autowired
    @Qualifier("healtharchiveTemplate")
    private JdbcTemplate healtharchiveTemplate;
    @Autowired
    @Qualifier("wlyy85Template")
    private JdbcTemplate wlyy85Template;
    @PostConstruct
    public void initTemplateMap(){
        templateMap.put("wlyy",wlyydefaultJdbcTemplate);
        templateMap.put("healtharchive",healtharchiveTemplate);
        templateMap.put("wlyy85",wlyy85Template);
    }
    @Override
    public List<DataModel> extractData(String sql, String datasource) {
        return null;
    }
    public List<DataModel> extractData(String sql,String countSql,String datasource) {
        if(StringUtils.isEmpty(countSql)){
            return null;
        }
        JdbcTemplate jdbcTemplate = null;
        // 默认的
        if(StringUtils.isEmpty(datasource)){
            jdbcTemplate = templateMap.get("wlyy");
            return  getDataByThread(sql,countSql,jdbcTemplate);
        }
        String [] arr = datasource.split("-");
        if(null == arr || arr.length <= 1){
            logger.error("invalid datasource format,check in fl_job_config: "+ datasource);
            return null;
        }
        jdbcTemplate = templateMap.get(arr[1]);
        if(null == jdbcTemplate){
            logger.error("datasource not exist,check in fl_job_config: "+ datasource);
            return null;
        }
        return  getDataByThread(sql,countSql,jdbcTemplate);
    }
    /**
     * 根据数据量采用多线程分页查询数据
     * @param sql
     * @return
     */
    public List<DataModel> getDataByThread(String sql,String countSql,JdbcTemplate jdbcTemplate){
        List<DataModel> datas = new ArrayList<>();
        int size = 0;
        // 统计出有多少条数据
        size = jdbcTemplate.queryForObject(countSql, Integer.class);
        logger.info("data count:" + size);
        int number = size / numPerPage + 1;
        List<Callable<List<DataModel>>> threadList = new ArrayList<>();
        // 计时
        long start = System.currentTimeMillis();
        String logTitle = "therad get data";
        TimeUtil.start(logger,logTitle,start);
        // 循环,拼凑分页sql
        try {
            for (int i = 0; i < number; i++) {
                StringBuilder limitSql = new StringBuilder();
                if(sql.contains("limitNumber") && i == 0){
                    String replacedSql = sql.replace("limitNumber",String.valueOf(1));
                    limitSql.append(replacedSql);
                }else if(sql.contains("limitNumber") && number > 1 && i > 0){
                    String replacedSql = sql.replace("limitNumber",String.valueOf(i * numPerPage));
                    limitSql.append(replacedSql);
                }else{
                    limitSql.append(sql);
                }
                limitSql.append(" limit ")
                        .append(numPerPage);
                MutilThreadMysqlExtracter mutilThreadMysqlExtracter = new MutilThreadMysqlExtracter(jdbcTemplate, limitSql.toString());
                threadList.add(mutilThreadMysqlExtracter);
//                Future<List<DataModel>> future = threadPoolService.submit(mutilThreadMysqlExtracter);
//                datas.addAll(future.get());
            }
            List<Future<List<DataModel>>> futureList = threadPoolService.invokeAll(threadList);
            for(Future<List<DataModel>> future : futureList){
                datas.addAll(future.get());
            }
            TimeUtil.finish(logger,logTitle,start,System.currentTimeMillis());
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("MutilThreadConvert call failed!");
        }
        return datas;
    }
}

+ 155 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Es2EsJob.java

@ -0,0 +1,155 @@
package com.yihu.wlyy.figure.label.job;
import com.yihu.wlyy.figure.label.constant.BusinessConstant;
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.entity.FlJobConfig;
import com.yihu.wlyy.figure.label.entity.FlLabelDictJob;
import com.yihu.wlyy.figure.label.enums.JobSqlFieldTypeEnum;
import com.yihu.wlyy.figure.label.extract.ESExtracter;
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.TimeUtil;
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;
@Service
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class Es2EsJob implements Job {
    private Logger logger = LoggerFactory.getLogger(JobController.class);
    @Autowired
    private FlJobConfigDao flJobConfigDao;
    @Autowired
    private FlLabelDictJobDao flLabelDictJobDao;
    @Autowired
    private ESExtracter esExtracter;
    @Autowired
    private ConvertHelper convertHelper;
    @Autowired
    Store2ES store2ES;
    @Autowired
    private JobService jobService;
    private FlJobConfig flJobConfig;
    private Long flJobConfigId;
    private String sqlFiledValue;
    private String sqlFiledCondition;
    private String finalSql;
    private List<DataModel> dataModelList;
    private String sourceType;
    private String source;
    /**
     * 数据表的id,有些数据是按时间增量查询,有些数据是按表的主键id增量查询
     */
    private long lastDataId;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDataMap paramsMap = context.getJobDetail().getJobDataMap();
        initParams(paramsMap);
        //提取数据
        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 index = dataModelList.size();
                lastDataId = dataModelList.get(index - 1).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.sqlFiledValue = flJobConfig.getSqlFieldValue();
        this.sqlFiledCondition = paramsMap.getString(BusinessConstant.SQLFIELDCONDITION);
        //没有传增量值,以数据库配置的默认值为查询条件
        if(org.springframework.util.StringUtils.isEmpty(this.sqlFiledValue)){
            this.sqlFiledValue = this.flJobConfig.getSqlFieldValue();
            this.sqlFiledCondition= BusinessConstant.gt;
        }
        //1抽取数据
        String sql = this.flJobConfig.getQuery_sql();
        String sqlFiled = this.flJobConfig.getSqlField();
        this.finalSql = sql + " where " + sqlFiled + BusinessConstant.gt + "'" + TimeUtil.toEsTime(flJobConfig.getSqlFieldValue()) + "'";
    }
    /**
     * 提取数据,按数据库中配置的增量条件提取
     */
    public void extract(){
        this.dataModelList = esExtracter.extractData(this.finalSql,"");
    }
    /**
     * 转换
     */
    public List<SaveModel> convert(){
        List<SaveModel> list = new ArrayList<>();
        FlLabelDictJob flLabelDictJob = flLabelDictJobDao.findByJobId(this.flJobConfigId);
        try {
            list = convertHelper.convert(this.dataModelList, null,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;
    }
}

+ 171 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Hbase2ESJob.java

@ -0,0 +1,171 @@
package com.yihu.wlyy.figure.label.job;
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.entity.FlJobConfig;
import com.yihu.wlyy.figure.label.entity.FlLabelDictJob;
import com.yihu.wlyy.figure.label.enums.JobSqlFieldTypeEnum;
import com.yihu.wlyy.figure.label.extract.HbaseExtracter;
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.TimeUtil;
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.getQuery_sql();
        fq = this.flJobConfig.getSqlField() + ":" + "[" + TimeUtil.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;
    }
}

+ 239 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Mysql2ESJob.java

@ -0,0 +1,239 @@
package com.yihu.wlyy.figure.label.job;
import com.yihu.wlyy.figure.label.constant.BusinessConstant;
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.entity.FlJobConfig;
import com.yihu.wlyy.figure.label.entity.FlLabelDictJob;
import com.yihu.wlyy.figure.label.enums.JobSqlFieldTypeEnum;
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.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;
/**
 * Created by chenweida on 2018/3/7.
 */
//@Component
@Service
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class Mysql2ESJob implements Job {
    private Logger logger = LoggerFactory.getLogger(JobController.class);
    @Autowired
    private FlJobConfigDao flJobConfigDao;
    @Autowired
    private FlLabelDictJobDao flLabelDictJobDao;
    @Autowired
    private MysqlExtracter mysqlExtracter;
    @Autowired
    private ConvertHelper convertHelper;
    @Autowired
    Store2ES store2ES;
    @Autowired
    private JobService jobService;
    private FlJobConfig flJobConfig;
    private Long flJobConfigId;
    private String sqlFieldValue;
    private String sqlFieldCondition;
    private String finalSql;
    private String countSql;
    private List<DataModel> dataModelList;
    private String sourceType;
    private String source;
    private String datasource;
    /**
     * 数据表的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 index = dataModelList.size();
                lastDataId = dataModelList.get(index -1).getId();
                jobService.updateFieldValuetoCurrentTimeOrId(this.flJobConfigId,this.lastDataId,bool);
            }
        }
    }
    public void initParams(JobDataMap paramsMap){
        this.flJobConfigId = (Long)paramsMap.get("jobConfig");
        this.flJobConfig = flJobConfigDao.findById(this.flJobConfigId);
        this.sourceType = flJobConfig.getSourceType();
        this.source = flJobConfig.getSource();
        this.datasource = flJobConfig.getDatasource();
        this.sqlFieldCondition = paramsMap.getString(BusinessConstant.SQLFIELDCONDITION);
        this.sqlFieldValue = flJobConfig.getSqlFieldValue();
        //没有传增量值,以数据库配置的默认值为查询条件
        if(StringUtils.isEmpty(this.sqlFieldValue)){
            this.sqlFieldValue = this.flJobConfig.getSqlFieldValue();
            this.sqlFieldCondition =">";
        }
        //1抽取数据
        String sql = this.flJobConfig.getQuery_sql();
        String sqlFiled = this.flJobConfig.getSqlField();
        this.finalSql = getFinalSql(sql,sqlFiled,sqlFieldValue);
        this.countSql = getTotalCountSql(flJobConfig.getCountSql(),sqlFiled, sqlFieldValue);
    }
    /**
     * 提取数据,按数据库中配置的增量条件提取
     */
    public void extract(){
        this.dataModelList = mysqlExtracter.extractData(this.finalSql,this.countSql,this.datasource);
    }
    /**
     * 转换
     */
    public List<SaveModel> convert(){
        List<SaveModel> list = new ArrayList<>();
        FlLabelDictJob flLabelDictJob = flLabelDictJobDao.findByJobId(this.flJobConfigId);
        try {
            list = convertHelper.convert(this.dataModelList, null,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;
    }
    /**
     * 拼凑获取增量数据的sql
     * @param sql
     * @param sqlFiledValue
     * @return
     */
    public String getJobConfigSql(String sql,String sqlFiled,String sqlFiledCondition,String sqlFiledValue){
        StringBuilder result = new StringBuilder();
        result.append(sql).append(" ");
        if(StringUtils.isEmpty(sqlFiledCondition)){
            return result.toString();
        }
        String[] sqlFiledConditionStr = {};
        if (sqlFiledCondition.contains(",")){
            sqlFiledConditionStr = sqlFiledCondition.split(",");
        }
        StringBuffer sqlFiledString = new StringBuffer();
        if (sqlFiledConditionStr.length>0 && sqlFiledValue.contains(",")){
            String[] sqlFiledValues = sqlFiledValue.split(",");
            sqlFiledString.append(sqlFiled).append(sqlFiledConditionStr[0]).append("\'"+sqlFiledValues[0]+"\'").append(" and ").append(sqlFiled).append(sqlFiledConditionStr[1]).append("\'"+sqlFiledValues[1]+"\'");
        }else{
            sqlFiledString.append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValue+"\'");
        }
        if (sql.contains("where") &&  !sql.contains("$")) {
            result.append(" and ").append(sqlFiledString.toString());
        }else if (sql.contains("$")){
            StringBuffer otherCondition = new StringBuffer();
            if (sql.contains("where")){
                otherCondition.append(" and ").append(sqlFiledString.toString());
            }else{
                otherCondition.append(" where ").append(sqlFiledString.toString());
            }
            result.replace(result.indexOf("$"),result.indexOf("$")+1,otherCondition.toString());
        }else {
            result.append(" where ").append(sqlFiledString.toString());
        }
        return result.toString();
    }
    /**
     * 最终执行获取数据的sql,替换增量字段为具体值
     * @param sql
     * @param sqlfield
     * @param sqlfieldValue
     * @return
     */
    public String getFinalSql(String sql, String sqlfield, String sqlfieldValue) {
        String firstReplaceSql = sql.replace(BusinessConstant.sql_field_str,sqlfield);
        String result = firstReplaceSql.replace(BusinessConstant.sql_field_value_str,sqlfieldValue);
        return result.toString();
    }
    /**
     * 统计增量数据的条数
     * @param countSql
     * @param sqlfield
     * @param sqlfieldValue
     * @return
     */
    public String getTotalCountSql(String countSql, String sqlfield, String sqlfieldValue) {
        if(StringUtils.isEmpty(countSql)){
            logger.error("countSql is null,job_config id = :" + this.flJobConfigId);
            return "";
        }
       String firstReplaceSql = countSql.replace(BusinessConstant.sql_field_str,sqlfield);
       String result = firstReplaceSql.replace(BusinessConstant.sql_field_value_str,sqlfieldValue);
        return result.toString();
    }
}

+ 248 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/model/DataModel.java

@ -0,0 +1,248 @@
package com.yihu.wlyy.figure.label.model;
/**
 * jboConfig配置里sql查询出的数据
 */
public class DataModel {
    /**
     * 这些id用作记录数据来源,当有多个表时,记录多个表的id,并依据fl_job_config里的sourceTyep,source来区别
     */
    private Integer id;
    private Integer id1;
    private Integer id2;
    private Integer id3;
    private Integer id4;
    /**
     * 有些表的id为uuid,是string类型,所以为了兼容所有的,此种类型id命名为idstr,进行数据抽取时需多注意
     */
    private String idstr;
    private String idstr1;
    private String idstr2;
    /**
     * 居民身份证号
     */
    private String idcard;
    /**
     * 父类标签码
     */
    private String parentCode;
    /**
     * 父类标签名
     */
    private String parentName;
    /**
     * 标签码
     */
    private String labelCode;
    /**
     * 标签名
     */
    private String labelName;
    /**
     * 标签值,某个单独的值,如及时回复中的问题id
     */
    private String labelValue;
    /**
     * 转换类
     */
    private String convertClazz;
    /**
     * 定时任务的表id
     */
    private String jobId;
    /**
     * 原数据来源时间
     */
    private String sourceTime;
    /**
     * 代预约的医生姓名
     */
    private String doctor;
    /**
     * 健康教育文章一级类别名称
     */
    private String firstLevelCategoryName;
    /**
     * 健康教育文章二级类别名称
     */
    private String secondLevelCategoryName;
    /**
     * 健康教育文章推送人名称
     */
    private String sendName;
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public Integer getId1() {
        return id1;
    }
    public void setId1(Integer id1) {
        this.id1 = id1;
    }
    public Integer getId2() {
        return id2;
    }
    public void setId2(Integer id2) {
        this.id2 = id2;
    }
    public Integer getId3() {
        return id3;
    }
    public void setId3(Integer id3) {
        this.id3 = id3;
    }
    public Integer getId4() {
        return id4;
    }
    public void setId4(Integer id4) {
        this.id4 = id4;
    }
    public String getIdstr() {
        return idstr;
    }
    public void setIdstr(String idstr) {
        this.idstr = idstr;
    }
    public String getIdstr1() {
        return idstr1;
    }
    public void setIdstr1(String idstr1) {
        this.idstr1 = idstr1;
    }
    public String getIdstr2() {
        return idstr2;
    }
    public void setIdstr2(String idstr2) {
        this.idstr2 = idstr2;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getParentCode() {
        return parentCode;
    }
    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }
    public String getParentName() {
        return parentName;
    }
    public void setParentName(String parentName) {
        this.parentName = parentName;
    }
    public String getLabelName() {
        return labelName;
    }
    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }
    public String getLabelCode() {
        return labelCode;
    }
    public void setLabelCode(String labelCode) {
        this.labelCode = labelCode;
    }
    public String getConvertClazz() {
        return convertClazz;
    }
    public void setConvertClazz(String convertClazz) {
        this.convertClazz = convertClazz;
    }
    public String getJobId() {
        return jobId;
    }
    public void setJobId(String jobId) {
        this.jobId = jobId;
    }
    public String getSourceTime() {
        return sourceTime;
    }
    public void setSourceTime(String sourceTime) {
        this.sourceTime = sourceTime;
    }
    public String getLabelValue() {
        return labelValue;
    }
    public void setLabelValue(String labelValue) {
        this.labelValue = labelValue;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getFirstLevelCategoryName() {
        return firstLevelCategoryName;
    }
    public void setFirstLevelCategoryName(String firstLevelCategoryName) {
        this.firstLevelCategoryName = firstLevelCategoryName;
    }
    public String getSecondLevelCategoryName() {
        return secondLevelCategoryName;
    }
    public void setSecondLevelCategoryName(String secondLevelCategoryName) {
        this.secondLevelCategoryName = secondLevelCategoryName;
    }
    public String getSendName() {
        return sendName;
    }
    public void setSendName(String sendName) {
        this.sendName = sendName;
    }
}

+ 170 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/model/SaveModel.java

@ -0,0 +1,170 @@
package com.yihu.wlyy.figure.label.model;
import io.searchbox.annotations.JestId;
import java.io.Serializable;
/**
 * Created by chenweida on 2018/3/7.
 */
public class SaveModel implements Serializable{
    @JestId
    /**
     * 存入elasticsearch的id由 idcard,parentCode,labelName,labelCode MD5加密而成。不用es自动生成的_id,实现数据插入排重
     */
    private String id;
    /**
     * 身份证
     */
    private String idcard;
    /**
     * 标签字典码
     */
    private String dictCode;
    /**
     * 标签类型
     */
    private String labelType;
    /**
     * 标签code
     */
    private String labelCode;
    /**
     * 标签名称
     */
    private String labelName;
    /**
     * 标签值,仅当标签只有一个分类的时候才有此值,比如生日,体重等
     */
    private String labelValue;
    /**
     * 创建时间
     */
    private String createTime;
    /**
     * 当前标签是否激活
     */
    /**
     * 标签生成来源
     */
    private String source;
    /**
     * 标签源数据来源时间
     */
    private String sourceTime;
    /**
     * 代预约的医生姓名
     */
    private String doctor;
    /**
     * 健康教育文章推送人名称
     */
    private String sendName;
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getLabelType() {
        return labelType;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getDictCode() {
        return dictCode;
    }
    public void setDictCode(String dictCode) {
        this.dictCode = dictCode;
    }
    public void setLabelType(String labelType) {
        this.labelType = labelType;
    }
    public String getLabelCode() {
        return labelCode;
    }
    public void setLabelCode(String labelCode) {
        this.labelCode = labelCode;
    }
    public String getLabelName() {
        return labelName;
    }
    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }
    public String getLabelValue() {
        return labelValue;
    }
    public void setLabelValue(String labelValue) {
        this.labelValue = labelValue;
    }
    public String getCreateTime() {
        return createTime;
    }
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
    public String getSource() {
        return source;
    }
    public void setSource(String source) {
        this.source = source;
    }
    public String getSourceTime() {
        return sourceTime;
    }
    public void setSourceTime(String sourceTime) {
        this.sourceTime = sourceTime;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getSendName() {
        return sendName;
    }
    public void setSendName(String sendName) {
        this.sendName = sendName;
    }
}

+ 100 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/search/controller/SearchController.java

@ -0,0 +1,100 @@
package com.yihu.wlyy.figure.label.search.controller;
import com.yihu.wlyy.figure.label.controller.JobController;
import com.yihu.wlyy.figure.label.search.service.SearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
import static sun.management.Agent.error;
/**
 * @author litaohong on 2018/5/17
 * @project patient-co-management
 */
@RestController
@RequestMapping(value = "/label", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "标签查询控制器")
public class SearchController {
    private Logger logger = LoggerFactory.getLogger(JobController.class);
    @Autowired
    private SearchService searchService;
    /**
     * @param idcard
     * @return
     */
    @ApiOperation(value = "根据idcard查询基本信息标签")
    @RequestMapping(value = "searchBaseInfo", method = RequestMethod.GET)
    public String searchBaseInfo(
            @ApiParam(name = "idcard", value = "身份证号", required = true)@RequestParam(value = "idcard", required = true) String idcard) {
        try {
            return searchService.getBaseInfo(idcard).toJSONString();
        } catch (Exception e) {
            error(e);
            return "error";
        }
    }
    /**
     * @param idcard
     * @return
     */
    @ApiOperation(value = "根据idcard查询病种信息标签")
    @RequestMapping(value = "searchDieaseInfo", method = RequestMethod.GET)
    public String searchDieaseInfo(
            @ApiParam(name = "idcard", value = "身份证号", required = true)@RequestParam(value = "idcard", required = true) String idcard) {
        try {
            return searchService.getDiseaseInfo(idcard).toJSONString();
        } catch (Exception e) {
            error(e);
            return "error";
        }
    }
    /**
     * @param idcard
     * @return
     */
    @ApiOperation(value = "根据idcard查询代预约情况")
    @RequestMapping(value = "searchAppointmentInfo", method = RequestMethod.GET)
    public String searchAppointmentInfo(
            @ApiParam(name = "idcard", value = "身份证号", required = true)@RequestParam(value = "idcard", required = true) String idcard) {
        try {
            return searchService.getAppointmentInfo(idcard).toJSONString();
        } catch (Exception e) {
            error(e);
            return "error";
        }
    }
    /**
     * @param idcard
     * @return
     */
    @ApiOperation(value = "根据idcard查询ehr基本档案信息")
    @RequestMapping(value = "searchehrbaseinfo", method = RequestMethod.GET)
    public String searchEHRRecordInfo(
            @ApiParam(name = "idcard", value = "身份证号", required = true)@RequestParam(value = "idcard", required = true) String idcard) {
        try {
            return searchService.getEHRRecordInfo(idcard);
        } catch (Exception e) {
            error(e);
            return "error";
        }
    }
}

+ 273 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/search/service/SearchService.java

@ -0,0 +1,273 @@
package com.yihu.wlyy.figure.label.search.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.base.es.config.ElastricSearchHelper;
import com.yihu.base.hbase.HBaseHelper;
import com.yihu.wlyy.figure.label.constant.BusinessConstant;
import com.yihu.wlyy.figure.label.constant.ConstantUtil;
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.Service;
import org.springframework.util.StringUtils;
import java.util.*;
/**
 * @author litaohong on 2018/5/17
 * @project patient-co-management
 * 标签搜索服务
 */
@Service
public class SearchService {
    private Logger logger = LoggerFactory.getLogger(Service.class);
    @Autowired
    private ElastricSearchHelper elastricSearchHelper;
    @Autowired
    private HBaseHelper hBaseHelper;
    @Autowired
    private HbaseTemplate hbaseTemplate;
    /**
     * 用户基本信息
     * @param idcard
     * @return
     */
    public JSONObject getBaseInfo(String idcard){
        List<Map<String, Object>> result = new ArrayList<>();
        JSONObject jsonObject = new JSONObject();
        String sql = "select * from " + ConstantUtil.figure_label_es_index + "/" + ConstantUtil.figure_label_es_type + " where idcard = '" + idcard + "'" ;
        result = elastricSearchHelper.excuceSQL(sql);
        result.forEach(
                map -> {
                    if(StringUtils.endsWithIgnoreCase(String.valueOf(map.get("dictCode")),ConstantUtil.name_dict)){
                        jsonObject.put("name",String.valueOf(map.get("labelValue")));
                    }
                    if(StringUtils.endsWithIgnoreCase(String.valueOf(map.get("dictCode")),ConstantUtil.sex_dict)){
                        jsonObject.put("sex",String.valueOf(map.get("labelName")));
                    }
                    if(StringUtils.endsWithIgnoreCase(String.valueOf(map.get("dictCode")),ConstantUtil.age_dict)){
                        jsonObject.put("age",String.valueOf(map.get("labelName")));
                    }
                    if(StringUtils.endsWithIgnoreCase(String.valueOf(map.get("dictCode")),ConstantUtil.birth_dict)){
                        jsonObject.put("birth",String.valueOf(map.get("labelValue")));
                    }
                    if(StringUtils.endsWithIgnoreCase(String.valueOf(map.get("dictCode")),ConstantUtil.height_dict)){
                        String height = String.valueOf(map.get("labelName")) + String.valueOf(map.get("labelValue"));
                        jsonObject.put("height",height);
                    }
                    if(StringUtils.endsWithIgnoreCase(String.valueOf(map.get("dictCode")),ConstantUtil.weight_dict)){
                        String weight = String.valueOf(map.get("labelName")) + String.valueOf(map.get("labelValue"));
                        jsonObject.put("weight",weight);
                    }
                }
        );
        if(null == jsonObject.get("name")){
            jsonObject.put("name","");
        }
        if(null == jsonObject.get("sex")){
            jsonObject.put("sex","");
        }
        if(null == jsonObject.get("age")){
            jsonObject.put("age","");
        }
        if(null == jsonObject.get("birth")){
            jsonObject.put("birth","");
        }
        if(null == jsonObject.get("height")){
            jsonObject.put("height","");
        }
        if(null == jsonObject.get("weight")){
            jsonObject.put("weight","");
        }
        return jsonObject;
    }
    /**
     * 用户病种信息
     * @param idcard
     * @return
     */
    public JSONObject getDiseaseInfo(String idcard) {
        JSONObject jsonObject = new JSONObject();
        String sql = "select * from " + ConstantUtil.figure_label_es_index + "/" + ConstantUtil.figure_label_es_type + " where idcard = '" + idcard + "' and dictCode in ('" + ConstantUtil.ICD10_dict + "','" + ConstantUtil.health_problem_dict + "')";
        List<Map<String, Object>> result = elastricSearchHelper.excuceSQL(sql);
        Set<String> set = new HashSet<>();
        result.forEach(
                map -> {
                    if (!StringUtils.isEmpty(map.get("labelValue"))) {
                        set.add(map.get("labelValue").toString());
                    }
                });
        jsonObject.put("label",set);
        return jsonObject;
    }
    /**
     * 用户就诊记录
     * @param idcard
     * @return
     */
    public JSONObject getAppointmentInfo(String idcard) {
        JSONObject result = new JSONObject();
        result.put("idcard",idcard);
        StringBuilder sqlBuilder = new StringBuilder();
        String sql = "select * from " + ConstantUtil.figure_label_es_index + "/" + ConstantUtil.figure_label_es_type + " where idcard = '" + idcard + "' and dictCode = '" + ConstantUtil.online_appoinment_dict + "',";
        List<Map<String, Object>> list = elastricSearchHelper.excuceSQL(sql);
        JSONArray jsonArray = new JSONArray();
        list.forEach(
                map -> {
                    //如果有医生姓名,表示是医生代预约
                    if(null == map.get("doctor")){
                            return;
                    }
                    JSONObject jsonObject = new JSONObject();
                    String labelName = String.valueOf(map.get("labelName"));
                    jsonObject.put("hospitalName", labelName.split("-")[0]);
                    jsonObject.put("deptName", labelName.split("-")[1]);
                    jsonObject.put("apponinementTime", map.get("sourceTime"));
                    jsonObject.put("doctor",map.get("doctor"));
                    jsonArray.add(jsonObject);
                }
        );
        JSONObject appoint = new JSONObject();
        appoint.put("appointdata",jsonArray);
        result.putAll(appoint);
        return result;
    }
    /**
     * 获取历史健康问题,默认获取所有
     * @param idcard
     * @param date
     * @return
     */
    public String getHistoryHealthProblem(String idcard,String date){
        JSONObject result = new JSONObject();
        StringBuilder sqlBuilder = new StringBuilder();
        String sql = "select * from " + ConstantUtil.figure_label_es_index + "/" + ConstantUtil.figure_label_es_type + " where idcard = '" + idcard + "' and dictCode = '" + ConstantUtil.health_problem_dict;
        sqlBuilder.append(sql);
        if(!StringUtils.isEmpty(date)){
            sqlBuilder.append(" and sourceTime <= '").append(date).append("'");
        }
        List<Map<String, Object>> list = elastricSearchHelper.excuceSQL(sqlBuilder.toString());
        Set<String> set = new HashSet<>();
        list.forEach(
                map -> {
                    String name = String.valueOf(map.get("labelName"));
                    if(name.contains(";")){
                        for(String str : name.split(";")){
                            set.add(str);
                        }
                    }else{
                        set.add(name);
                    }
                }
        );
        result.put("historyHealthProblem",set);
        return result.toJSONString();
    }
    /**
     * 医疗云档案查询接口(包括基本信息,疾病标签如慢病新生儿等,就诊记录信息)
     * @param idcard
     * @return
     */
    public String getEHRRecordInfo(String idcard) {
        JSONObject result = new JSONObject();
        // 基础信息标签
        JSONObject baseinfo = getBaseInfo(idcard);
        baseinfo.put("idcard",idcard);
        result.putAll(baseinfo);
        //疾病标签
        JSONObject diesase = getDiseaseInfo(idcard);
        result.putAll(diesase);
        //就诊记录标签
        JSONObject appointmentinfo = getAppointmentInfo(idcard);
        if(appointmentinfo.getJSONArray("appointdata").size() > 0){
            result.putAll(appointmentinfo);
        }
        return result.toJSONString();
    }
    /**
     * 获取健康教育文章记录
     * @return
     */
    public String getHealthArticle(String idcard){
        JSONArray jsonArray = new JSONArray();
        String sql = "select * from " + ConstantUtil.figure_label_es_index + "/" + ConstantUtil.figure_label_es_type + "where dictCode = '" + ConstantUtil.health_edu_artical_receive_dict + "' and idcard ='" + idcard + "'";
        List<Map<String, Object>> list = elastricSearchHelper.excuceSQL(sql.toString());
        list.forEach(
                map -> {
                    JSONObject result = new JSONObject();
                    // 文章标题
                    String title = String.valueOf(map.get("labelName"));
                    result.put("title",title);
                    // 文章分类标题
                    String name = String.valueOf(map.get("labelValue"));
                    if (!StringUtils.isEmpty(name) && name.contains(BusinessConstant.separator)) {
                        String[] nameArr = name.split(BusinessConstant.separator);
                        result.put("firstCategoryName", nameArr[0]);
                        result.put("secondCategoryName", nameArr[1]);
                    }
                    // 文章推送时间
                    Object sendTime = map.get("sourceTime");
                    result.put("sendTime",sendTime);
                    // 文章推送人
                    Object sender = map.get("sendName");
                    result.put("sender",sender);
                    jsonArray.add(result);
                }
        );
        return jsonArray.toJSONString();
    }
    /**
     *
     * 获取随访记录
     * @return
     */
    public String getFollowupRecord(String idcard){
        JSONArray jsonArray = new JSONArray();
        String sql = "select * from " + ConstantUtil.figure_label_es_index + "/" + ConstantUtil.figure_label_es_type + "where dictCode = '" + ConstantUtil.followup_dict + "' and idcard ='" + idcard + "'";
        List<Map<String, Object>> list = elastricSearchHelper.excuceSQL(sql.toString());
        list.forEach(
                map -> {
                    JSONObject result = new JSONObject();
                    // 随访疾病名称
                    String followupName = String.valueOf(map.get("labelName"));
                    result.put("followupName", followupName);
                    // 随访方式
                    String followupStyle = String.valueOf(map.get("labelValue"));
                    result.put("followupStyle", followupStyle);
                    // 随访时间
                    Object followupTime = map.get("sourceTime");
                    result.put("followupTime", followupTime);
                    // 随访医生
                    Object followupDoctor = map.get("sendName");
                    result.put("followupDoctor", followupDoctor);
                    // 随访评价
                    Object followupEvaluate = map.get("followupEvaluate");
                    result.put("followupDoctor", followupEvaluate);
                    jsonArray.add(result);
                }
        );
        return jsonArray.toJSONString();
    }
}

+ 5 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/service/ExtractService.java

@ -0,0 +1,5 @@
package com.yihu.wlyy.figure.label.service;
public class ExtractService {
}

+ 170 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/service/JobService.java

@ -0,0 +1,170 @@
package com.yihu.wlyy.figure.label.service;
import com.yihu.wlyy.figure.label.constant.BusinessConstant;
import com.yihu.wlyy.figure.label.dao.FlJobConfigDao;
import com.yihu.wlyy.figure.label.constant.ConstantUtil;
import com.yihu.wlyy.figure.label.entity.FlJobConfig;
import com.yihu.wlyy.figure.label.util.QuartzHelpers;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.*;
import static com.yihu.wlyy.figure.label.constant.BusinessConstant.gt;
/**
 *@author lith on 2018.03.23
 */
@Service
public class JobService {
    @Value("${JobService.sleepTime}")
    private Integer sleepTime;
    @Autowired
    private FlJobConfigDao flJobConfigDao;
    @Autowired
    private QuartzHelpers quartzHelpers;
    @Transactional(rollbackFor = Exception.class)
    public void stopById(String id) throws Exception {
        String[] idarr = id.split(",");
        for(String oneId : idarr){
        FlJobConfig flJobConfig = flJobConfigDao.findByIdAndStatus(Long.valueOf(oneId), "1");
        if (flJobConfig != null) {
            quartzHelpers.removeJob(flJobConfig.getId().toString());
            flJobConfigDao.updateStatus(flJobConfig.getId(), "0");
            ;
        } else {
            throw new Exception("任务已经停止");
        }
        }
    }
    @Transactional(rollbackFor = Exception.class)
    public void startById(String id) throws Exception {
        String[] idarr = id.split(",");
        for(String oneId : idarr){
            FlJobConfig flJobConfig = flJobConfigDao.findByIdAndStatus(Long.valueOf(oneId), "0");
            if (flJobConfig != null) {
                startOneJob(flJobConfig);
            } else {
                throw new Exception("任务已经启动");
            }
        }
    }
    @Transactional(rollbackFor = Exception.class)
    public void stopAll() throws Exception {
        List<FlJobConfig> FlJobConfigs = flJobConfigDao.findByAll("1");
        if (FlJobConfigs != null && FlJobConfigs.size() > 0) {
            for (FlJobConfig FlJobConfig : FlJobConfigs) {
                quartzHelpers.removeJob(FlJobConfig.getId().toString());
                flJobConfigDao.updateStatus(FlJobConfig.getId(), "0");
            }
        } else {
            throw new Exception("任务已经全部停止");
        }
    }
    @Transactional(rollbackFor = Exception.class)
    public void startAll() throws Exception {
        List<FlJobConfig> FlJobConfigs = flJobConfigDao.findByAll("0");
        if (FlJobConfigs != null && FlJobConfigs.size() > 0) {
            for (FlJobConfig FlJobConfig : FlJobConfigs) {
                startOneJob(FlJobConfig);
            }
        } else {
            throw new Exception("任务已经全部启动");
        }
    }
    /**
     * 启动单个任务
     *
     * @param FlJobConfig
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    public void startOneJob(FlJobConfig FlJobConfig) throws Exception {
        FlJobConfig flJobConfigVO = new FlJobConfig();
        BeanUtils.copyProperties(FlJobConfig, flJobConfigVO);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("jobConfig", flJobConfigVO.getId());
        params.put(BusinessConstant.sourceType, flJobConfigVO.getSourceType());
        params.put(BusinessConstant.sourceType, flJobConfigVO.getSource());
        //表里设置的增量查询类型和增量查询初始值,如果值没有配置,以当前时间为准
        if(!StringUtils.isEmpty(flJobConfigVO.getSqlFieldValue())){
            params.put(BusinessConstant.sqlFieldValue,flJobConfigVO.getSqlFieldValue());
        }else{
            params.put(BusinessConstant.sqlFieldValue, DateFormatUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
        }
        params.put(BusinessConstant.SQLFIELDCONDITION, BusinessConstant.gt);
        if (!StringUtils.isEmpty(FlJobConfig.getJobClass())) {
            //往quartz框架添加任务
            quartzHelpers.addJob(getRightClass(FlJobConfig), FlJobConfig.getQuartzCron(), FlJobConfig.getId().toString(), params);
            flJobConfigDao.updateStatus(FlJobConfig.getId(), "1");//设置任务状态是启动 }
        }
    }
    public void startNowById(String id) throws Exception {
        FlJobConfig FlJobConfig = flJobConfigDao.findOne(Long.parseLong(id));
        FlJobConfig flJobConfigVO = new FlJobConfig();
        BeanUtils.copyProperties(FlJobConfig, flJobConfigVO);
        Map<String, Object> params = new HashMap<>();
        params.put("jobConfig", flJobConfigVO.getId());
        params.put(BusinessConstant.sourceType, flJobConfigVO.getSourceType());
        params.put(BusinessConstant.source, flJobConfigVO.getSource());
        if(!StringUtils.isEmpty(flJobConfigVO.getSqlFieldValue())){
            params.put(flJobConfigVO.getSqlField(),flJobConfigVO.getSqlFieldValue());
        }else{
            params.put(flJobConfigVO.getSqlField(), DateFormatUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
        }
        params.put(BusinessConstant.SQLFIELDCONDITION, BusinessConstant.gt);
        //往quartz框架添加任务
        if (!StringUtils.isEmpty(FlJobConfig.getJobClass())) {
            quartzHelpers.startNow(getRightClass(FlJobConfig), FlJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            Thread.sleep(sleepTime);
        }
    }
    /**
     * @param FlJobConfig
     * @return
     * @throws ClassNotFoundException
     */
    private Class getRightClass(FlJobConfig FlJobConfig) throws ClassNotFoundException {
        return Class.forName(FlJobConfig.getJobClass());
    }
        /**
         * 增量查询数据成功后,将增量时间改为当前时间
         * @param id
         * @param lastDataId
         * @param bool
         */
    @Transactional(rollbackFor = Exception.class)
    public void updateFieldValuetoCurrentTimeOrId(Long id,Long lastDataId,boolean bool) {
        if (!bool) {
            return;
        }
        if(null != lastDataId && lastDataId != 0){
            this.flJobConfigDao.updateSqlFildeValue(id,String.valueOf(lastDataId));
            return;
        }
        this.flJobConfigDao.updateSqlFildeValue(id, DateFormatUtils.format(new Date(), ConstantUtil.date_format));
    }
}

+ 14 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Storager.java

@ -0,0 +1,14 @@
package com.yihu.wlyy.figure.label.storage;
import com.yihu.wlyy.figure.label.model.SaveModel;
import java.util.List;
/**
 * @author lith on 2018.03.14 -- Created by chenweida on 2018/3/7.
 * 存储器
 */
public interface Storager {
    void save(List<SaveModel> modelList);
}

+ 58 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Store2ES.java

@ -0,0 +1,58 @@
package com.yihu.wlyy.figure.label.storage;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.base.es.config.ElastricSearchHelper;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.constant.ConstantUtil;
import com.yihu.wlyy.figure.label.util.TimeUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
 *@author lith on 2018.03.23
 */
@Component
public class Store2ES implements Storager {
    private Logger logger = LoggerFactory.getLogger(Store2ES.class);
    @Autowired
    private ElastricSearchHelper elastricSearchHelper;
    @Autowired
    ObjectMapper objectMapper;
    @Override
    public void save(List<SaveModel> modelList) {
        List<String> list = new ArrayList<>();
        int saveCount = 0;
        long start = System.currentTimeMillis();
        String logtitle = "loop(save) data,total size:" + modelList.size();
        TimeUtil.start(logger,logtitle,start);
        for(SaveModel saveModel:modelList){
            try {
                String str =  objectMapper.writeValueAsString(saveModel);
                list.add(str);
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }
            //防止内存溢出,一次性存储10W条
            if(list.size() >= 100000){
                elastricSearchHelper.saveBulkWithCustomId(ConstantUtil.figure_label_es_index, ConstantUtil.figure_label_es_type, list,"id");
                list.clear();
                saveCount ++;
            }else if(modelList.size() - saveCount * 100000 == list.size()){
                //剩余的零头
                elastricSearchHelper.saveBulkWithCustomId(ConstantUtil.figure_label_es_index, ConstantUtil.figure_label_es_type, list,"id");
            }
        }
        long finish = System.currentTimeMillis();
        TimeUtil.finish(logger,"loop(save) data",start,finish);
    }
}

+ 0 - 0
svr/figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Store2Hbase.java


部分文件因为文件数量过多而无法显示