Bladeren bron

Merge branch 'dev' of http://192.168.1.220:10080/jiwei/wlyy2.0 into dev

wangzhinan 6 jaren geleden
bovenliggende
commit
f872f16912
63 gewijzigde bestanden met toevoegingen van 2543 en 332 verwijderingen
  1. 2 1
      .gitignore
  2. 9 0
      app/app-iot-server/pom.xml
  3. 9 0
      app/public-health-server/pom.xml
  4. 1 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/function/FunctionDO.java
  5. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WechatTemplateDO.java
  6. 113 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxPushLogDO.java
  7. 188 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxTemplateConfigDO.java
  8. 20 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/PatientRehabilitationPlanDO.java
  9. 11 11
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationDetailDO.java
  10. 5 6
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationTemplateDetailDO.java
  11. 1 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/WechatRequestMapping.java
  12. 16 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/specialist/SpecialistMapping.java
  13. 62 74
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/base/FunctionVO.java
  14. 188 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/specialist/SignFamilyDoctorVO.java
  15. 1 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/Envelop.java
  16. 2 2
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/ListEnvelop.java
  17. 2 2
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/MixEnvelop.java
  18. 1 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/ObjEnvelop.java
  19. 1 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/PageEnvelop.java
  20. 2 2
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/endpoint/EnvelopRestEndpoint.java
  21. 24 0
      common/common-util/pom.xml
  22. 80 0
      common/common-util/src/main/java/com/yihu/jw/util/common/QrcodeUtil.java
  23. 0 23
      common/common-util/src/main/java/com/yihu/jw/util/wechat/PushMsgTask.java
  24. 223 0
      common/common-util/src/main/java/com/yihu/jw/util/wechat/WeixinMessagePushUtils.java
  25. 213 0
      common/common-util/src/main/java/com/yihu/jw/util/wechat/wxhttp/HttpUtil.java
  26. 0 1
      common/common-web/src/main/java/com/yihu/jw/web/handler/GlobalExceptionHandler.java
  27. 4 0
      gateway/ag-basic/pom.xml
  28. 9 2
      gateway/ag-basic/src/main/resources/application.yml
  29. 1 1
      server/svr-configuration/src/main/resources/application.yml
  30. 14 1
      server/svr-configuration/src/main/resources/bootstrap.yml
  31. 0 46
      server/svr-log-server/src/main/resources/bootstrap.yml
  32. 25 27
      server/svr-log-server/pom.xml
  33. 0 0
      server/svr-zipkin/readme.MD
  34. 3 5
      server/svr-log-server/src/main/java/com/yihu/jw/LogServerApplication.java
  35. 3 4
      server/svr-log-server/src/main/resources/application.yml
  36. 0 0
      server/svr-zipkin/src/main/resources/banner.txt
  37. 26 0
      server/svr-zipkin/src/main/resources/bootstrap.yml
  38. 4 0
      svr/svr-base/pom.xml
  39. 35 0
      svr/svr-base/src/main/java/com/yihu/jw/base/config/SwaggerDocs.java
  40. 14 11
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/function/FunctionEndpoint.java
  41. 5 5
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/controller/WechatCoreController.java
  42. 32 42
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/controller/WxTemplateController.java
  43. 15 0
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/dao/WxTemplateConfigDao.java
  44. 47 6
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WechatCoreService.java
  45. 94 0
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WechatFansService.java
  46. 2 2
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WxAccessTokenService.java
  47. 37 38
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WxTemplateService.java
  48. 1 4
      svr/svr-base/src/main/resources/application.yml
  49. 10 2
      svr/svr-base/src/main/resources/bootstrap.yml
  50. 10 1
      svr/svr-wlyy-health-bank/src/main/resources/bootstrap.yml
  51. 7 0
      svr/svr-wlyy-specialist/pom.xml
  52. 49 2
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/SpecialistController.java
  53. 268 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/common/FileUploadController.java
  54. 196 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationPlanController.java
  55. 3 1
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/PatientRehabilitationPlanDao.java
  56. 14 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationPlanTemplateDao.java
  57. 14 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationTemplateDetailDao.java
  58. 91 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/FileUploadService.java
  59. 102 3
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java
  60. 180 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationPlanService.java
  61. 32 0
      svr/svr-wlyy-specialist/src/main/resources/application.yml
  62. 17 1
      svr/svr-wlyy-specialist/src/main/resources/bootstrap.yml
  63. 4 2
      wlyy-parent-pom/pom.xml

+ 2 - 1
.gitignore

@ -10,7 +10,6 @@
.idea/
data/*
.idea_modules/
build/*.jar
.settings
.cache
.generated-mima*
@ -79,3 +78,5 @@ sql/hive-thriftserver/test_warehouses
# For R session data
.RHistory
.RData
build/
docs/

+ 9 - 0
app/app-iot-server/pom.xml

@ -148,6 +148,15 @@
            <artifactId>fastdfs-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
        </dependency>
        <dependency>
            <groupId>eu.medsea.mimeutil</groupId>
            <artifactId>mime-util</artifactId>
            <version>2.1.3</version>
        </dependency>
    </dependencies>
    <build>

+ 9 - 0
app/public-health-server/pom.xml

@ -127,6 +127,15 @@
            <artifactId>swagger-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>eu.medsea.mimeutil</groupId>
            <artifactId>mime-util</artifactId>
            <version>2.1.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
        </dependency>
    </dependencies>
    <build>

+ 1 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/function/FunctionDO.java

@ -9,6 +9,7 @@ import javax.persistence.Table;
import javax.persistence.Transient;
/**
 * 功能 - Entity
 * WlyyFunction entity. @author MyEclipse Persistence Tools
 */
@Entity

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WechatTemplateDO.java

@ -17,7 +17,7 @@ public class WechatTemplateDO implements Serializable {
    private String url;//URL置空,则在发送后,点击模板消息会进入一个空白页面(ios),或无法点击(android)
    private Miniprogram miniprogram;
    private Miniprogram miniprogram; //小程序跳转
    private Map<String,WechatTemplateDataDO> data;//详细内容

+ 113 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxPushLogDO.java

@ -0,0 +1,113 @@
package com.yihu.jw.entity.base.wx;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import java.util.Date;
/**
 * Created by Trick on 2018/8/21.
 */
public class WxPushLogDO extends UuidIdentityEntity {
    private String wechatId;//推送类型
    private String tempName;//模板名称
    private String scene;//场景值
    private String openid;//接收者openid
    private String receiver;//接收者code
    private String receiverName;//接收者姓名
    private String request;//请求入参
    private String response;//返回值
    private String status;//状态(0失败,1成功)
    private Date createTime;//创建时间
    @Column(name = "wechat_id")
    public String getWechatId() {
        return wechatId;
    }
    public void setWechatId(String wechatId) {
        this.wechatId = wechatId;
    }
    @Column(name = "temp_name")
    public String getTempName() {
        return tempName;
    }
    public void setTempName(String tempName) {
        this.tempName = tempName;
    }
    @Column(name = "scene")
    public String getScene() {
        return scene;
    }
    public void setScene(String scene) {
        this.scene = scene;
    }
    @Column(name = "openid")
    public String getOpenid() {
        return openid;
    }
    public void setOpenid(String openid) {
        this.openid = openid;
    }
    @Column(name = "receiver")
    public String getReceiver() {
        return receiver;
    }
    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }
    @Column(name = "receiver_name")
    public String getReceiverName() {
        return receiverName;
    }
    public void setReceiverName(String receiverName) {
        this.receiverName = receiverName;
    }
    @Column(name = "request")
    public String getRequest() {
        return request;
    }
    public void setRequest(String request) {
        this.request = request;
    }
    @Column(name = "response")
    public String getResponse() {
        return response;
    }
    public void setResponse(String response) {
        this.response = response;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 188 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxTemplateConfigDO.java

@ -0,0 +1,188 @@
package com.yihu.jw.entity.base.wx;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Trick on 2018/8/21.
 */
@Entity
@Table(name = "wx_template_config")
public class WxTemplateConfigDO extends UuidIdentityEntityWithOperator implements java.io.Serializable{
    private String wechatId;//微信id
    private String templateId;//微信模板id
    private String templateName;//自定义模板名称
    private String scene;//使用场景值
    private String sceneDescription;//使用场景描述
    private String first;//头部,
    private String url;//跳转链接
    private String remark;//备注
    private String keyword1;//项目
    private String keyword2;//项目
    private String keyword3;//项目
    private String keyword4;//项目
    private String keyword5;//项目
    private String keyword6;//项目
    private String keyword7;//项目
    private String appid;//跳转小程序的appid
    private String pagepath;//跳转小程序路径
    @Column(name = "wechat_id")
    public String getWechatId() {
        return wechatId;
    }
    public void setWechatId(String wechatId) {
        this.wechatId = wechatId;
    }
    @Column(name = "template_id")
    public String getTemplateId() {
        return templateId;
    }
    public void setTemplateId(String templateId) {
        this.templateId = templateId;
    }
    @Column(name = "template_name")
    public String getTemplateName() {
        return templateName;
    }
    public void setTemplateName(String templateName) {
        this.templateName = templateName;
    }
    @Column(name = "scene")
    public String getScene() {
        return scene;
    }
    public void setScene(String scene) {
        this.scene = scene;
    }
    @Column(name = "scene_description")
    public String getSceneDescription() {
        return sceneDescription;
    }
    public void setSceneDescription(String sceneDescription) {
        this.sceneDescription = sceneDescription;
    }
    @Column(name = "first")
    public String getFirst() {
        return first;
    }
    public void setFirst(String first) {
        this.first = first;
    }
    @Column(name = "url")
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "keyword1")
    public String getKeyword1() {
        return keyword1;
    }
    public void setKeyword1(String keyword1) {
        this.keyword1 = keyword1;
    }
    @Column(name = "keyword2")
    public String getKeyword2() {
        return keyword2;
    }
    public void setKeyword2(String keyword2) {
        this.keyword2 = keyword2;
    }
    @Column(name = "keyword3")
    public String getKeyword3() {
        return keyword3;
    }
    public void setKeyword3(String keyword3) {
        this.keyword3 = keyword3;
    }
    @Column(name = "keyword4")
    public String getKeyword4() {
        return keyword4;
    }
    public void setKeyword4(String keyword4) {
        this.keyword4 = keyword4;
    }
    @Column(name = "keyword5")
    public String getKeyword5() {
        return keyword5;
    }
    public void setKeyword5(String keyword5) {
        this.keyword5 = keyword5;
    }
    @Column(name = "keyword6")
    public String getKeyword6() {
        return keyword6;
    }
    public void setKeyword6(String keyword6) {
        this.keyword6 = keyword6;
    }
    @Column(name = "keyword7")
    public String getKeyword7() {
        return keyword7;
    }
    public void setKeyword7(String keyword7) {
        this.keyword7 = keyword7;
    }
    @Column(name = "appid")
    public String getAppid() {
        return appid;
    }
    public void setAppid(String appid) {
        this.appid = appid;
    }
    @Column(name = "pagepath")
    public String getPagepath() {
        return pagepath;
    }
    public void setPagepath(String pagepath) {
        this.pagepath = pagepath;
    }
}

+ 20 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/PatientRehabilitationPlanDO.java

@ -30,6 +30,10 @@ public class PatientRehabilitationPlanDO extends UuidIdentityEntityWithOperator
    private Integer planType;//安排类型(1康复计划,2转社区医院,3转家庭病床)
    @Column(name = "service_package_id")
    private String servicePackageId;//服务包id
    @Column(name = "status")
    private Integer status;//状态(0已中止,1进行中,2已完成)
    @Column(name = "service_qr_code")
    private String serviceQrCode;//服务码
    public String getSaasId() {
        return saasId;
@ -94,4 +98,20 @@ public class PatientRehabilitationPlanDO extends UuidIdentityEntityWithOperator
    public void setServicePackageId(String servicePackageId) {
        this.servicePackageId = servicePackageId;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getServiceQrCode() {
        return serviceQrCode;
    }
    public void setServiceQrCode(String serviceQrCode) {
        this.serviceQrCode = serviceQrCode;
    }
}

+ 11 - 11
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationDetailDO.java

@ -13,13 +13,13 @@ import java.util.Date;
 * Created by humingfen on 2018/8/15.
 */
@Entity
@Table(name = "wlyy_rehabilitation_detail")
@Table(name = "wlyy_rehabilitation_plan_detail")
public class RehabilitationDetailDO extends UuidIdentityEntityWithOperator implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "program_id")
    private String programId;//居民康复套餐code
    @Column(name = "plan_id")
    private String planId;//居民康复套餐code
    @Column(name = "service_item_id")
    private String serviceItemId;//服务项目id
    @Column(name = "hospital")
@ -33,9 +33,9 @@ public class RehabilitationDetailDO extends UuidIdentityEntityWithOperator imple
    @Column(name = "doctor_name")
    private String doctorName;//计划完成者标识
    @Column(name = "execute_time")
    private String executeTime;//服务项目执行时间
    private Date executeTime;//服务项目执行时间
    @Column(name = "status")
    private Integer status;//状态(0未开始,1进行中,2已完成)
    private Integer status;//状态(0已中止,1进行中,2已完成)
    public String getSaasId() {
        return saasId;
@ -45,12 +45,12 @@ public class RehabilitationDetailDO extends UuidIdentityEntityWithOperator imple
        this.saasId = saasId;
    }
    public String getProgramId() {
        return programId;
    public String getPlanId() {
        return planId;
    }
    public void setProgramId(String programId) {
        this.programId = programId;
    public void setPlanId(String planId) {
        this.planId = planId;
    }
    public String getServiceItemId() {
@ -69,11 +69,11 @@ public class RehabilitationDetailDO extends UuidIdentityEntityWithOperator imple
        this.hospital = hospital;
    }
    public String getExecuteTime() {
    public Date getExecuteTime() {
        return executeTime;
    }
    public void setExecuteTime(String executeTime) {
    public void setExecuteTime(Date executeTime) {
        this.executeTime = executeTime;
    }

+ 5 - 6
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationTemplateDetailDO.java

@ -19,7 +19,7 @@ public class RehabilitationTemplateDetailDO extends UuidIdentityEntityWithOperat
    @Column(name = "template_id")
    private String templateId;//康复套餐模板id
    @Column(name = "service_item_id")
    private String serviceId;//服务项目id
    private String serviceItemId;//服务项目id
    public String getSaasId() {
        return saasId;
@ -37,12 +37,11 @@ public class RehabilitationTemplateDetailDO extends UuidIdentityEntityWithOperat
        this.templateId = templateId;
    }
    public String getServiceId() {
        return serviceId;
    public String getServiceItemId() {
        return serviceItemId;
    }
    public void setServiceId(String serviceId) {
        this.serviceId = serviceId;
    public void setServiceItemId(String serviceItemId) {
        this.serviceItemId = serviceItemId;
    }
}

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

@ -66,6 +66,7 @@ public class WechatRequestMapping {
        public static final String api_getWxTemplates="/template/list";
        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 message_success_create="wxTemplate create success";
        public static final String message_success_update="wxTemplate update success";

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

@ -33,11 +33,18 @@ public class SpecialistMapping {
        public static final String findPatientTeamList ="/findPatientTeamList";
        public static final String findPatientSignSpecialist ="/findPatientSignSpecialist";
        public static final String findPatientSignSpecialistInfo ="/findPatientSignSpecialistInfo";
        public static final String findDoctorAndDoctorHealthBySpecialDoctor ="/findDoctorAndDoctorHealthBySpecialDoctor";
        public static final String findSpecialistSignFamilyPatientCout ="/findSpecialistSignFamilyPatientCout";
        public static final String getSpecialistSignFamilyPatientByName ="/getSpecialistSignFamilyPatientByName";
    }
    public static  class common{
        public static final String file_upload =  "/fileUpload";
    }
    public static class screen{
@ -48,6 +55,15 @@ public class SpecialistMapping {
    public static class rehabilitation{
        public static final String findRehabilitationPlan = "/findRehabilitationPlan";
        public static final String createRehabilitationPlanTemplate = "/createRehabilitationPlanTemplate";
        public static final String createRehabilitationTemplateDetail = "/createRehabilitationTemplateDetail";
        public static final String findRehabilitationPlanTemplate = "/findRehabilitationPlanTemplate";
        public static final String findTemplateDetailByTemplateId = "/findTemplateDetailByTemplateId";
        public static final String updateRehabilitationTemplateDetail = "/updateRehabilitationTemplateDetail";
        public static final String createPatientRehabilitationPlan = "/createPatientRehabilitationPlan";
        public static final String createServiceQrCode ="/createServiceQrCode";
        public static final String checkAfterQrCode = "checkAfterQrCode";
    }
    public static class serviceItem{

+ 62 - 74
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/base/FunctionVO.java

@ -1,65 +1,60 @@
package com.yihu.jw.restmodel.base.base;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.*;
/**
 * Created by chenweida on 2017/5/19.
 */
public class FunctionVO {
    private String id;
    private String name; //功能名称
    private String saasId; // saasid
    private String parentCode; //父功能code
    private Integer status; //状态 -1 删除 0 禁用 可用
@ApiModel(value = "FunctionVO", description = "功能")
public class FunctionVO implements Serializable {
    @ApiModelProperty(value = "id", example = "1" )
    protected Integer id;
    @ApiModelProperty(value = "创建日期", example = "2018-03-14 11:35:34" )
    protected Date createTime;
    @ApiModelProperty(value = "创建者", example = "0dae0003590016e5b3865e377b2f8615" )
    protected String createUser;
    @ApiModelProperty(value = "创建者用户名", example = "Progr1mmer" )
    protected String createUserName;
    @ApiModelProperty(value = "修改日期", example = "2018-03-14 11:35:34" )
    protected Date updateTime;
    @ApiModelProperty(value = "修改者", example = "0dae0003590016e5b3865e377b2f8615" )
    protected String updateUser;
    @ApiModelProperty(value = "修改者用户名", example = "Progr1mmer" )
    protected String updateUserName;
    //功能名称
    @ApiModelProperty(value = "名称", example = "功能1" )
    private String name;
    //网关url前缀
    @ApiModelProperty(value = "网关url前缀", example = "/base" )
    private String prefix;
    //功能对应的后台url路径
    @ApiModelProperty(value = "功能对应的后台url路径", example = "/function/list" )
    private String url;
    private String createUser;
    private String createUserName;
    private Date createTime;
    private String updateUser;
    private String updateUserName;
    private Date updateTime;
    private String remark; //备注
    private List<FunctionVO> children = new ArrayList<>();
    private String text;
    public String getId() {
    //备注
    @ApiModelProperty(value = "备注", example = "我是备注" )
    private String remark;
    public Integer getId() {
        return id;
    }
    public void setId(String id) {
    public void setId(Integer id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getParentCode() {
        return parentCode;
    }
    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }
    public Integer getStatus() {
        return status;
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    public Date getCreateTime() {
        return createTime;
    }
    public void setStatus(Integer status) {
        this.status = status;
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getCreateUser() {
@ -78,12 +73,13 @@ public class FunctionVO {
        this.createUserName = createUserName;
    }
    public Date getCreateTime() {
        return createTime;
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getUpdateUser() {
@ -102,36 +98,20 @@ public class FunctionVO {
        this.updateUserName = updateUserName;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public List<FunctionVO> getChildren() {
        return children;
    public String getName() {
        return name;
    }
    public void setChildren(List<FunctionVO> children) {
        this.children = children;
    public void setName(String name) {
        this.name = name;
    }
    public String getText() {
        return name;
    public String getPrefix() {
        return prefix;
    }
    public void setText(String text) {
        this.text = text;
    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }
    public String getUrl() {
@ -141,4 +121,12 @@ public class FunctionVO {
    public void setUrl(String url) {
        this.url = url;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

+ 188 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/specialist/SignFamilyDoctorVO.java

@ -0,0 +1,188 @@
package com.yihu.jw.restmodel.specialist;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * @author huangwenjie
 * @date 2018/8/20 15:40
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "专病医生关联的家庭医生信息", description = "专病医生关联的家庭医生信息")
public class SignFamilyDoctorVO {
	@ApiModelProperty("医生Code")
	private String code;
	@ApiModelProperty("姓名")
	private String name;
	@ApiModelProperty("性别(1男,2女)")
	private Integer sex;
	@ApiModelProperty("生日")
	private Date birthday;
	@ApiModelProperty("头像http地址")
	private String photo;
	@ApiModelProperty("手机号")
	private String mobile;
	@ApiModelProperty("医院代码")
	private String hospital;
	@ApiModelProperty("医院名称")
	private String hospitalName;
	@ApiModelProperty("科室代码")
	private String dept;
	@ApiModelProperty("科室名称")
	private String deptName;
	@ApiModelProperty("职称代码")
	private String job;
	@ApiModelProperty("职称名称")
	private String jobName;
	@ApiModelProperty("类型:1专科医生,2全科医生,3健康管理师")
	private Integer level;
	@ApiModelProperty("类二维码")
	private String qrcode;
	@ApiModelProperty("更新时间")
	private Date czrq;
	@ApiModelProperty("状态(1正常,0删除)")
	private Integer del;
	@ApiModelProperty("身份证号")
	private String idcard;
	
	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 Integer getSex() {
		return sex;
	}
	
	public void setSex(Integer sex) {
		this.sex = sex;
	}
	
	public Date getBirthday() {
		return birthday;
	}
	
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	
	public String getPhoto() {
		return photo;
	}
	
	public void setPhoto(String photo) {
		this.photo = photo;
	}
	
	public String getMobile() {
		return mobile;
	}
	
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	
	public String getHospital() {
		return hospital;
	}
	
	public void setHospital(String hospital) {
		this.hospital = hospital;
	}
	
	public String getHospitalName() {
		return hospitalName;
	}
	
	public void setHospitalName(String hospitalName) {
		this.hospitalName = hospitalName;
	}
	
	public String getDept() {
		return dept;
	}
	
	public void setDept(String dept) {
		this.dept = dept;
	}
	
	public String getDeptName() {
		return deptName;
	}
	
	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}
	
	public String getJob() {
		return job;
	}
	
	public void setJob(String job) {
		this.job = job;
	}
	
	public String getJobName() {
		return jobName;
	}
	
	public void setJobName(String jobName) {
		this.jobName = jobName;
	}
	
	public Integer getLevel() {
		return level;
	}
	
	public void setLevel(Integer level) {
		this.level = level;
	}
	
	public String getQrcode() {
		return qrcode;
	}
	
	public void setQrcode(String qrcode) {
		this.qrcode = qrcode;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	
	public Integer getDel() {
		return del;
	}
	
	public void setDel(Integer del) {
		this.del = del;
	}
	
	public String getIdcard() {
		return idcard;
	}
	
	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
}

+ 1 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/Envelop.java

@ -12,7 +12,7 @@ import java.io.Serializable;
 * 快速集成 {@link com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint}
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(description = "基础实体")
@ApiModel(value = "Envelop", description = "基础实体")
public class Envelop implements Serializable {
    @ApiModelProperty("信息")

+ 2 - 2
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/ListEnvelop.java

@ -22,10 +22,10 @@ import java.util.List;
 * @author llh
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "ListResult", description = "获取实体列表返回定义")
@ApiModel(value = "ListEnvelop<T>", description = "获取实体列表返回")
public class ListEnvelop<T> extends Envelop {
    @ApiModelProperty("列表内容")
    @ApiModelProperty(value = "列表内容")
    private List<T> detailModelList = new ArrayList<>(0);
    public List<T> getDetailModelList() {

+ 2 - 2
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/MixEnvelop.java

@ -23,7 +23,7 @@ import java.util.List;
 * @author llh
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "ListResult", description = "通用的实体")
@ApiModel(value = "MixEnvelop<T, J>", description = "通用的实体")
public class MixEnvelop<T, J> extends Envelop {
    private static final long serialVersionUID = 2076324875575488461L;
@ -43,7 +43,7 @@ public class MixEnvelop<T, J> extends Envelop {
    @ApiModelProperty("列表内容")
    private List<T> detailModelList = new ArrayList<>(0);
    @ApiModelProperty("内容")
    @ApiModelProperty("实体内容")
    private J obj = (J)new HashMap<>(0);
    public int getCurrPage() {

+ 1 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/ObjEnvelop.java

@ -21,7 +21,7 @@ import java.util.HashMap;
 * @author llh
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(description = "获取单个实体信息返回")
@ApiModel(value = "ObjEnvelop<J>", description = "获取单个实体信息返回")
public class ObjEnvelop<J> extends Envelop {
    @ApiModelProperty("内容")

+ 1 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/PageEnvelop.java

@ -23,7 +23,7 @@ import java.util.List;
 * @author llh
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "EnvelopPage<T>", description = "分页查询返回")
@ApiModel(value = "PageEnvelop<T>", description = "分页查询返回")
public class PageEnvelop<T> extends Envelop implements Serializable {
    private static final long serialVersionUID = 2076324875575488461L;

+ 2 - 2
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/endpoint/EnvelopRestEndpoint.java

@ -119,11 +119,11 @@ public abstract class EnvelopRestEndpoint {
        return mixEnvelop;
    }
    protected <E extends Envelop> Envelop failed(String message, Class<E> clazz) {
    protected <E extends Envelop> E failed(String message, Class<E> clazz) {
        return failed(message, -10000, clazz);
    }
    protected <E extends Envelop> Envelop failed(String message, int status, Class<E> clazz) {
    protected <E extends Envelop> E failed(String message, int status, Class<E> clazz) {
        try {
            E envelop = clazz.newInstance();
            envelop.setMessage(message);

+ 24 - 0
common/common-util/pom.xml

@ -37,5 +37,29 @@
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <!--二维码生成 start-->
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>core</artifactId>
            <version>${version.zxing}</version>
        </dependency>
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>javase</artifactId>
            <version>${version.zxing}</version>
        </dependency>
        <!--二维码生成 end-->
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-util</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-entity</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>utils</artifactId> <!-- 此依赖包含大部分常用工具类 -->
        </dependency>
    </dependencies>
</project>

+ 80 - 0
common/common-util/src/main/java/com/yihu/jw/util/common/QrcodeUtil.java

@ -0,0 +1,80 @@
package com.yihu.jw.util.common;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by lyr on 2016/08/10.
 */
public class QrcodeUtil {
    /**
     * 二维码图片生成
     *
     * @param content 二维码内容
     * @param imgType 图片类型
     * @param size    图片尺寸
     * @return
     */
    public static File QrcodeEncode(String content, String fileName, String path, String imgType, int size) throws Exception {
        File pathFile = new File(path);
        File outputFile = new File(path + File.separator + fileName + ".png");
        if (!pathFile.exists()) {
            pathFile.mkdir();
        }
        if (outputFile.exists()) {
            outputFile.delete();
        }
        outputFile.createNewFile();
        Map<EncodeHintType, String> hints = new HashMap<EncodeHintType, String>();
        // 内容所使用字符集编码
        hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
        BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, size, size, hints);
        // 生成二维码
        MatrixToImageWriter.writeToFile(bitMatrix, imgType, outputFile);
        return outputFile;
    }
    /**
     * 创建二维码
     * @param content
     * @return
     */
    public static InputStream createQrcode(String content,int size,String imgType) {
        byte[] imagesStream=null;
        ByteArrayOutputStream os = null;
        try {
            HashMap<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>();
            hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
            hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
            hints.put(EncodeHintType.MARGIN, 0);
            BitMatrix bitMatrix = new MultiFormatWriter().encode(content,
              BarcodeFormat.QR_CODE, size, size, hints);
             os = new ByteArrayOutputStream();
            MatrixToImageWriter.writeToStream(bitMatrix, imgType, os);
            return new ByteArrayInputStream(os.toByteArray());
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
            if(os!=null){
                try {
                    os.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }
}

+ 0 - 23
common/common-util/src/main/java/com/yihu/jw/util/wechat/PushMsgTask.java

@ -1,23 +0,0 @@
package com.yihu.jw.util.wechat;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.LinkedBlockingQueue;
/**
 * Created by Trick on 2018/8/20.
 */
@Component
public class PushMsgTask {
    private static Logger logger = LoggerFactory.getLogger(PushMsgTask.class);
    private static LinkedBlockingQueue<JSONObject> queue = new LinkedBlockingQueue<JSONObject>();
}

+ 223 - 0
common/common-util/src/main/java/com/yihu/jw/util/wechat/WeixinMessagePushUtils.java

@ -0,0 +1,223 @@
package com.yihu.jw.util.wechat;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.wx.*;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.utils.network.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
/**
 * 微信模板消息工具类
 * 调用putWxMsg 发送模板消息
 * 微信文档地址
 * https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1445241432
 * Created by Trick on 2018/8/21.
 */
@Component
public class WeixinMessagePushUtils {
    private static Logger logger = LoggerFactory.getLogger(WeixinMessagePushUtils.class);
    private static LinkedBlockingQueue<Map<String,Object>> queue = new LinkedBlockingQueue<Map<String,Object>>();
    public void putWxMsg(String accessToken,String opennid,WxTemplateConfigDO wxTemplateConfigDO){
        try {
            Map<String,Object> mes = new HashMap();
            if(StringUtils.isBlank(opennid)){
                logger.info("wechat queue put opennid is null ");
                return;
            }
            if(StringUtils.isBlank(accessToken)){
                logger.info("wechat queue put accessToken is null ");
                return;
            }
            mes.put("accessToken",accessToken);
            mes.put("openid",opennid);
            mes.put("wxTemplateConfig",wxTemplateConfigDO);
            queue.put(mes);
        }catch (Exception e){
            logger.info("wechat queue put error :",e);
        }
    }
    @PostConstruct
    private void run() {
        new Thread(new ConsumerTask()).start();
    }
    // 消费者
    class ConsumerTask implements Runnable {
        @Override
        public void run() {
            while (true) {
                try {
                    // 如果queue为空,则当前线程会堵塞,直到有新数据加入
                    Map<String,Object> mes = queue.take();
                    //发送微信模板消息
                    sendWeixinMessage(mes);
                }catch (Exception e){
                    logger.info("wechat ConsumerTask run:",e);
                }
            }
        }
    }
    /**
     * 发送微信模板消息
     * @param mes
     * @return
     */
    public boolean sendWeixinMessage(Map<String,Object> mes){
        WxTemplateConfigDO wxtemp = (WxTemplateConfigDO)mes.get("wxTemplateConfig");
        String token = (String)mes.get("accessToken");
        //发送微信模板地址
        String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+token;
        //微信消息参数
        String params = getWxParam(mes);
        if(StringUtils.isBlank(params)){
            logger.info("wechat params is null");
            return false;
        }
        //发送微信模板消息
        String result = HttpUtil.sendPost(url, params);
        JSONObject jsonResult = new JSONObject(result);
        if (Integer.parseInt(jsonResult.get("errcode").toString()) == 0) {
            logger.info("wechat temp send success");
            return true;
        } else {
            logger.error("wechat temp send fail:"+result);
            return false;
        }
    }
    /**
     * 构造微信模板参数
     *
     * @param mes
     * @return
     */
    public String getWxParam(Map<String,Object> mes){
        try{
            String toUser = (String)mes.get("openid");
            //微信模板消息实体
            WxTemplateConfigDO wxtemp = (WxTemplateConfigDO)mes.get("wxTemplateConfig");
            //创建微信模板实体,设置参数及内容
            WechatTemplateDO wechatTemp = new WechatTemplateDO();
            //接收者的openid
            wechatTemp.setTouser(toUser);
            //设置模板ID
            wechatTemp.setTemplate_id(wxtemp.getTemplateId());
            //设置跳转路径
            if(StringUtils.isNotBlank(wxtemp.getUrl())){
                wechatTemp.setUrl(wxtemp.getUrl());
            }
            //设置小程序跳转
            if(StringUtils.isNotBlank(wxtemp.getAppid())){
                Miniprogram miniprogram = new Miniprogram();
                miniprogram.setAppid(wxtemp.getAppid());
                miniprogram.setPagepath(wxtemp.getPagepath());
                wechatTemp.setMiniprogram(miniprogram);
            }
            //配置微信模板内容
            setWechatTemplateData(wechatTemp,wxtemp);
            ObjectMapper mapper = new ObjectMapper();
            String strJson = mapper.writeValueAsString(wechatTemp);
            logger.info("--------wechat param json message --------:" + strJson);
            return strJson;
        }catch (Exception e){
            logger.info("--------wechat param json message --------:" + e);
        }
        return "";
    }
    /**
     * 设置微信模板内容
     * @param wechatTemp 微信待发送模板
     * @param wxtemp 读取数据配置
     */
    public void setWechatTemplateData(WechatTemplateDO wechatTemp,WxTemplateConfigDO wxtemp){
        //设置模板内容
        Map<String,WechatTemplateDataDO> data = new HashedMap();
        //设置头部
        WechatTemplateDataDO first = new WechatTemplateDataDO();
        first.setValue(wxtemp.getFirst());
        first.setColor("#000000");
        data.put("first",first);
        //设置备注
        WechatTemplateDataDO remark = new WechatTemplateDataDO();
        remark.setValue(wxtemp.getRemark());
        remark.setColor("#000000");
        data.put("remark",remark);
        //配置keyword,微信最多可配置7个项目
        //设置keyword1
        if(StringUtils.isNotBlank(wxtemp.getKeyword1())){
            WechatTemplateDataDO keyword1 = new WechatTemplateDataDO();
            keyword1.setValue(wxtemp.getRemark());
            keyword1.setColor("#000000");
            data.put("keyword1",keyword1);
        }
        //设置keyword2
        if(StringUtils.isNotBlank(wxtemp.getKeyword2())){
            WechatTemplateDataDO keyword2 = new WechatTemplateDataDO();
            keyword2.setValue(wxtemp.getKeyword2());
            keyword2.setColor("#000000");
            data.put("keyword2",keyword2);
        }
        //设置keyword3
        if(StringUtils.isNotBlank(wxtemp.getKeyword3())){
            WechatTemplateDataDO keyword3 = new WechatTemplateDataDO();
            keyword3.setValue(wxtemp.getKeyword3());
            keyword3.setColor("#000000");
            data.put("keyword3",keyword3);
        }
        //设置keyword4
        if(StringUtils.isNotBlank(wxtemp.getKeyword4())){
            WechatTemplateDataDO keyword4 = new WechatTemplateDataDO();
            keyword4.setValue(wxtemp.getKeyword4());
            keyword4.setColor("#000000");
            data.put("keyword4",keyword4);
        }
        //设置keyword5
        if(StringUtils.isNotBlank(wxtemp.getKeyword5())){
            WechatTemplateDataDO keyword5 = new WechatTemplateDataDO();
            keyword5.setValue(wxtemp.getKeyword5());
            keyword5.setColor("#000000");
            data.put("keyword5",keyword5);
        }
        //设置keyword6
        if(StringUtils.isNotBlank(wxtemp.getKeyword6())){
            WechatTemplateDataDO keyword6 = new WechatTemplateDataDO();
            keyword6.setValue(wxtemp.getKeyword6());
            keyword6.setColor("#000000");
            data.put("keyword1",keyword6);
        }
        //设置keyword7
        if(StringUtils.isNotBlank(wxtemp.getKeyword7())){
            WechatTemplateDataDO keyword7 = new WechatTemplateDataDO();
            keyword7.setValue(wxtemp.getKeyword7());
            keyword7.setColor("#000000");
            data.put("keyword7",keyword7);
        }
        //设置微信内容,头部,备注,项目参数
        wechatTemp.setData(data);
    }
}

+ 213 - 0
common/common-util/src/main/java/com/yihu/jw/util/wechat/wxhttp/HttpUtil.java

@ -0,0 +1,213 @@
package com.yihu.jw.util.wechat.wxhttp;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
/**
 * Created by Trick on 2018/8/21.
 */
public class HttpUtil {
    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
    /**
     * 向指定URL发送GET方法的请求
     *
     * @param url
     *            发送请求的URL
     * @param param
     *            请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
     * @return URL 所代表远程资源的响应结果
     */
    public static String sendGet(String url, String param) {
        String result = "";
        BufferedReader in = null;
        try {
            String urlNameString = url + "?" + param;
            URL realUrl = new URL(urlNameString);
            // 打开和URL之间的连接
            URLConnection connection = realUrl.openConnection();
            // 设置通用的请求属性
            connection.setRequestProperty("accept", "*/*");
            connection.setRequestProperty("connection", "Keep-Alive");
            connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            // 建立实际的连接
            connection.connect();
            // 定义 BufferedReader输入流来读取URL的响应
            in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                result += line;
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
        return result;
    }
    /**
     * 向指定URL发送GET方法的请求
     *
     * @param url
     *            发送请求的URL
     *            请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
     * @return URL 所代表远程资源的响应结果
     */
    public static String sendGet(String url) {
        String result = "";
        BufferedReader in = null;
        try {
            String urlNameString = url;
            URL realUrl = new URL(urlNameString);
            // 打开和URL之间的连接
            URLConnection connection = realUrl.openConnection();
            // 设置通用的请求属性
            connection.setRequestProperty("accept", "*/*");
            connection.setRequestProperty("connection", "Keep-Alive");
            connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            // 建立实际的连接
            connection.connect();
            // 定义 BufferedReader输入流来读取URL的响应
            in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                result += line;
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
        return result;
    }
    /**
     * 向指定 URL 发送POST方法的请求
     *
     * @param url
     *            发送请求的 URL带上参数
     * @param param
     *            POST参数。
     * @return 所代表远程资源的响应结果
     */
    public static String sendPost(String url, String param) {
        StringBuffer buffer = new StringBuffer();
        PrintWriter out = null;
        BufferedReader in = null;
        HttpURLConnection conn = null;
        try {
            URL realUrl = new URL(url);
            // 打开和URL之间的连接
            conn = (HttpURLConnection) realUrl.openConnection();
            conn.setRequestMethod("POST");
            conn.setConnectTimeout(5000);
            conn.setDoOutput(true);
            conn.setDoInput(true);
            conn.setUseCaches(false);
            conn.setRequestProperty("Content-Type", "application/text");
            conn.setRequestProperty("accept", "*/*");
            conn.setRequestProperty("connection", "Keep-Alive");
            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
            osw.write(param.toString());
            osw.flush();
            // 读取返回内容
            BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
            String temp;
            while ((temp = br.readLine()) != null) {
                buffer.append(temp);
                buffer.append("\n");
            }
        } catch (Exception e) {
            logger.error("push message error:", e);
        } finally {
            try {
                if (out != null) {
                    out.close();
                }
                if (in != null) {
                    in.close();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        return buffer.toString();
    }
    /**
     * 向指定 URL 发送POST方法的请求
     *
     * @param url 发送请求的 URL带上参数
     * @param param POST参数。
     * @param charset 编码格式
     * @return 所代表远程资源的响应结果
     */
    public static String sendPost(String url, String param, String charset) {
        StringBuffer buffer = new StringBuffer();
        PrintWriter out = null;
        BufferedReader in = null;
        HttpURLConnection conn = null;
        try {
            URL realUrl = new URL(url);
            // 打开和URL之间的连接
            conn = (HttpURLConnection) realUrl.openConnection();
            conn.setRequestMethod("POST");
            conn.setDoOutput(true);
            conn.setDoInput(true);
            conn.setUseCaches(false);
            conn.setRequestProperty("Content-Type", "application/text");
            conn.setRequestProperty("accept", "*/*");
            conn.setRequestProperty("connection", "Keep-Alive");
            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), charset);
            osw.write(param.toString());
            osw.flush();
            // 读取返回内容
            BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), charset));
            String temp;
            while ((temp = br.readLine()) != null) {
                buffer.append(temp);
                buffer.append("\n");
            }
        } catch (Exception e) {
            logger.error("push message error:", e);
        } finally {
            try {
                if (out != null) {
                    out.close();
                }
                if (in != null) {
                    in.close();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        return buffer.toString();
    }
}

+ 0 - 1
common/common-web/src/main/java/com/yihu/jw/web/handler/GlobalExceptionHandler.java

@ -5,7 +5,6 @@ import com.yihu.jw.restmodel.web.Envelop;
import feign.FeignException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MissingServletRequestParameterException;

+ 4 - 0
gateway/ag-basic/pom.xml

@ -53,6 +53,10 @@
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <!--<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
        </dependency>-->
        <!-- 安全认证中心-->
        <dependency>

+ 9 - 2
gateway/ag-basic/src/main/resources/application.yml

@ -10,7 +10,14 @@ zuul:
      serviceId: svr-iot
    svr-base:
      path: /base/**
      serviceId: svr-base
      serviceId: svr-base-sxy
    demo:
      path: /baidu/**
      url: https://www.baidu.com
      url: https://www.baidu.com
spring:
  zipkin:
    base-url: http://localhost:9411
  sleuth:
    sampler:
      percentage: 1.0

+ 1 - 1
server/svr-configuration/src/main/resources/application.yml

@ -15,7 +15,7 @@ eureka:
    healthcheck:
      enabled: false #启动监控检查
    serviceUrl:
      defaultZone: http://jw:jkzl@172.19.103.33:8761/eureka
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka
  instance:
    #eurika使用IP不使用host
    prefer-ip-address: true

+ 14 - 1
server/svr-configuration/src/main/resources/bootstrap.yml

@ -25,4 +25,17 @@ spring:
        git:
          uri: ${wlyy.spring.config.git.uri:http://192.168.1.220:10080/jiwei/wlyy2.0.config.git}
          basedir: /usr/local/wlyy2.0-config
        default-label: ${wlyy.spring.config.git.label:jwdev}
        default-label: ${wlyy.spring.config.git.label:jwdev}
---
spring:
  profiles: prod
##git配置
  cloud:
    config:
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      server:
        git:
          uri: ${wlyy.spring.config.git.uri:http://192.168.120.153:3000/jiwei/wlyy2.0.config.git}
          basedir: /usr/local/wlyy2.0-config
        default-label: ${wlyy.spring.config.git.label:prod}

+ 0 - 46
server/svr-log-server/src/main/resources/bootstrap.yml

@ -1,46 +0,0 @@
##优先读取 boostarap配置 然后在读取application。yml的配置
spring:
  #从发现服务里面取配置服务的信息
  cloud:
    config:
      failFast: true ##启动快速失败 即链接不到配置服务就启动失败
      username: jw
      password: jkzl
      discovery:
        enabled: true ##使用发现服务
        service-id: svr-configurations ##配置服务的名字
---
spring:
  profiles: jwdev
##发现服务的地址
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@172.19.103.33:8761/eureka/
---
spring:
  profiles: jwtest
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@172.19.103.33:8761/eureka/
---
spring:
  profiles: jwprod
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka/

+ 25 - 27
server/svr-log-server/pom.xml

@ -9,11 +9,28 @@
        <version>2.0.0</version>
        <relativePath>../../wlyy-parent-pom/pom.xml</relativePath>
    </parent>
    <groupId>com.yih.jw</groupId>
    <artifactId>svr-log-server</artifactId>
    <version>${parent.version}</version>
    <artifactId>svr-zipkin</artifactId>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-server</artifactId>
@ -33,39 +50,20 @@
            <version>1.21.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
    </dependencies>
    <build>
        <finalName>svr-logServer</finalName>
        <finalName>svr-zipkin</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <mainClass>com.yihu.jw.LogServerApplication</mainClass>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
                </configuration>
            </plugin>
        </plugins>

server/svr-log-server/readme.MD → server/svr-zipkin/readme.MD


+ 3 - 5
server/svr-log-server/src/main/java/com/yihu/jw/LogServerApplication.java

@ -1,19 +1,17 @@
package com.yihu.jw;
package com.yihu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import zipkin.server.EnableZipkinServer;
/**
 * Created by chenweida on 2017/5/18.
 */
@SpringBootApplication
@EnableDiscoveryClient
@EnableZipkinServer
public class LogServerApplication {
public class SvrZipkin {
    public static void main(String[] args) {
        SpringApplication.run(LogServerApplication.class, args);
        SpringApplication.run(SvrZipkin.class, args);
    }
}

+ 3 - 4
server/svr-log-server/src/main/resources/application.yml

@ -1,12 +1,11 @@
spring:
  application:
    name: svr-logServer
server:
  port: 9411
---
spring:
  profiles: jwdev
##分布式日志存在es里面
#分布式日志存在es里面
zipkin:
  storage:
    type: elasticsearch

server/svr-log-server/src/main/resources/banner.txt → server/svr-zipkin/src/main/resources/banner.txt


+ 26 - 0
server/svr-zipkin/src/main/resources/bootstrap.yml

@ -0,0 +1,26 @@
##优先读取 boostarap配置 然后在读取application。yml的配置
spring:
  application:
    name: svr-zipkin
  #从发现服务里面取配置服务的信息
  cloud:
    config:
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      username: jw
      password: jkzl
---
spring:
  profiles: jwdev
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://172.17.110.212:1221}
      label: ${wlyy.spring.config.label:jwdev}
---
spring:
  profiles: jwtest
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://172.17.110.212:1221}
      label: ${wlyy.spring.config.label:jwdev}

+ 4 - 0
svr/svr-base/pom.xml

@ -54,6 +54,10 @@
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <!--<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
        </dependency>-->
        <dependency>
            <groupId>org.json</groupId>

+ 35 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/config/SwaggerDocs.java

@ -0,0 +1,35 @@
package com.yihu.jw.base.config;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
 * Created by progr1mmer on 2018/8/21.
 */
public class SwaggerDocs {
    public static void main(String[] args) throws Exception {
        //1.请求 http://ip:port/swagger-resources获取group
        String group = "Default";
        //2.定义请求地址 new URL("http://ip:port/v2/api-docs?group=" + groupName)
        URL remoteSwaggerFile = new URL("http://127.0.0.1:10020/v2/api-docs?group=" + group); //项目的swagger-ui地址
        //3.定义文件输出路径
        String prefix = Thread.currentThread().getContextClassLoader().getResource("").getPath();
        Path outputFile = Paths.get(prefix.substring(prefix.lastIndexOf(":") + 1, prefix.indexOf("target") - 1) + "/build/" + group); //文档输出地址
//        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);
    }
}

+ 14 - 11
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/function/FunctionEndpoint.java

@ -2,6 +2,8 @@ package com.yihu.jw.base.endpoint.function;
import com.yihu.jw.base.service.FunctionService;
import com.yihu.jw.entity.base.function.FunctionDO;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.base.base.FunctionVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -15,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
@ -30,12 +33,12 @@ public class FunctionEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.Function.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建")
    public ObjEnvelop<FunctionDO> create (
    public ObjEnvelop<FunctionVO> create (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        FunctionDO functionDO = toEntity(jsonData, FunctionDO.class);
        functionDO = functionService.save(functionDO);
        return success(functionDO);
        return success(convertToModel(functionDO, FunctionVO.class));
    }
    @PostMapping(value = BaseRequestMapping.Function.DELETE)
@ -44,25 +47,25 @@ public class FunctionEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids) {
        functionService.delete(ids);
        return success("删除成功");
        throw new ApiException("f", 200);
    }
    @PostMapping(value = BaseRequestMapping.Function.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新")
    public Envelop update (
    public ObjEnvelop<FunctionVO> update (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        FunctionDO functionDO = toEntity(jsonData, FunctionDO.class);
        if (null == functionDO.getId()) {
            return failed("ID不能为空", Envelop.class);
            return failed("ID不能为空", ObjEnvelop.class);
        }
        functionDO = functionService.save(functionDO);
        return success(functionDO);
        return success(convertToModel(functionDO, FunctionVO.class));
    }
    @GetMapping(value = BaseRequestMapping.Function.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<FunctionDO> page (
    public PageEnvelop<FunctionVO> page (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
@ -73,14 +76,14 @@ public class FunctionEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        List<FunctionDO> functionDOS = functionService.search(fields, filters, sorts, page, size);
        List<FunctionVO> functionDOS = functionService.search(fields, filters, sorts, page, size);
        int count = (int)functionService.getCount(filters);
        return success(functionDOS, count, page, size);
        return success(convertToModels(functionDOS, new ArrayList<>(), FunctionVO.class), count, page, size);
    }
    @GetMapping(value = BaseRequestMapping.Function.LIST)
    @ApiOperation(value = "获取列表")
    public ListEnvelop<FunctionDO> list (
    public ListEnvelop<FunctionVO> list (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
@ -88,7 +91,7 @@ public class FunctionEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<FunctionDO> functionDOS = functionService.search(fields, filters, sorts);
        return success(functionDOS);
        return success(convertToModels(functionDOS, new ArrayList<>(), FunctionVO.class));
    }
}

+ 5 - 5
svr/svr-base/src/main/java/com/yihu/jw/business/wx/controller/WechatCoreController.java

@ -174,9 +174,9 @@ public class WechatCoreController extends EnvelopRestEndpoint {
        return strDigest;
    }
//    @RequestMapping(value ="test", method = RequestMethod.POST)
//    @ResponseBody
//    public String  testProcess() throws Exception{
//        return wechatCoreService.testProcess();
//    }
    @RequestMapping(value ="test", method = RequestMethod.POST)
    @ResponseBody
    public String  testProcess() throws Exception{
        return wechatCoreService.testProcess();
    }
}

+ 32 - 42
svr/svr-base/src/main/java/com/yihu/jw/business/wx/controller/WxTemplateController.java

@ -1,44 +1,34 @@
//package com.yihu.jw.business.wx.controller;
//
//import com.yihu.jw.business.wx.WechatResponse;
//import com.yihu.jw.base.wx.Miniprogram;
//import com.yihu.jw.base.wx.WxTemplateDO;
//import com.yihu.jw.base.wx.WxWechatDO;
//import com.yihu.jw.business.wx.service.WechatService;
//import com.yihu.jw.business.wx.service.WxTemplateService;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//import com.yihu.jw.restmodel.base.wx.WxTemplateVO;
//import com.yihu.jw.restmodel.base.wx.WxWechatVO;
//import com.yihu.jw.rm.base.WechatRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang.StringUtils;
//import org.json.JSONObject;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by Administrator on 2017/5/19 0019.
// */
//@RestController
//@RequestMapping(WechatRequestMapping.api_common)
//@Api(value = "微信模版相关操作", description = "微信模版相关操作")
//public class WxTemplateController extends EnvelopRestController {
//    @Autowired
//    private WxTemplateService wxTemplateService;
//
//    @Autowired
//    private WechatService wechatService;
//
package com.yihu.jw.business.wx.controller;
import com.yihu.jw.business.wx.service.WxTemplateService;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.WechatRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
@RestController
@RequestMapping(WechatRequestMapping.api_common)
@Api(value = "微信模版相关操作", description = "微信模版相关操作")
public class WxTemplateController extends EnvelopRestEndpoint {
    @Autowired
    private WxTemplateService wxTemplateService;
    @PostMapping(value = WechatRequestMapping.WxTemplate.api_test_template, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "测试发送微信模板", notes = "测试发送微信模板")
    public String sendWeTempMesTest(String wechatId,String openid)throws Exception{
        return wxTemplateService.sendWeTempMesTest(wechatId,openid);
    }
//    @PostMapping(value = WechatRequestMapping.WxTemplate.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "创建微信模版", notes = "创建微信模版")
//    public Envelop createWxTemplate(
@ -185,4 +175,4 @@
//            return Envelop.getSuccess("error", exception);
//        }
//    }
//}
}

+ 15 - 0
svr/svr-base/src/main/java/com/yihu/jw/business/wx/dao/WxTemplateConfigDao.java

@ -0,0 +1,15 @@
package com.yihu.jw.business.wx.dao;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/8/21.
 */
public interface WxTemplateConfigDao extends PagingAndSortingRepository<WxTemplateConfigDO, String>, JpaSpecificationExecutor<WxTemplateConfigDO> {
    WxTemplateConfigDO findByWechatIdAndTemplateNameAndScene(String wechatId,String templateName,String scene);
}

+ 47 - 6
svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WechatCoreService.java

@ -88,12 +88,11 @@ public class WechatCoreService {
        String returnStr = "";
        Map<String, String> message = new HashMap();
        message.put("Content","1");
        message.put("CreateTime","1534486843");
        message.put("Event","subscribe");
        message.put("CreateTime","1534495338");
        message.put("ToUserName","gh_73959f6e996b");
        message.put("FromUserName","oVH-2uJdhNrcAMt0Jhp3PMarDdaM");
        message.put("MsgType","text");
        message.put("MsgId","6590570807493983575");
        message.put("MsgType","event");
        returnStr = messageProcess(message);
@ -165,7 +164,30 @@ public class WechatCoreService {
        return result;
    }
    public String scanEventProcess(Map<String, String> message){
    /**
     * 扫描二维码事件
     * 1. 用户未关注时,进行关注后的事件推送
     * <xml><ToUserName>< ![CDATA[toUser] ]></ToUserName><FromUserName>< ![CDATA[FromUser] ]></FromUserName><CreateTime>123456789</CreateTime><MsgType>< ![CDATA[event] ]></MsgType><Event>< ![CDATA[subscribe] ]></Event><EventKey>< ![CDATA[qrscene_123123] ]></EventKey><Ticket>< ![CDATA[TICKET] ]></Ticket></xml>
     * 2. 用户已关注时的事件推送
     * <xml> <ToUserName>< ![CDATA[toUser] ]></ToUserName> <FromUserName>< ![CDATA[FromUser] ]></FromUserName> <CreateTime>123456789</CreateTime> <MsgType>< ![CDATA[event] ]></MsgType> <Event>< ![CDATA[SCAN] ]></Event> <EventKey>< ![CDATA[SCENE_VALUE] ]></EventKey> <Ticket>< ![CDATA[TICKET] ]></Ticket> </xml>
     * @param message
     * @return
     */
    public String scanEventProcess(Map<String, String> message) throws Exception{
        //获取原始id
        String toUserName = message.get("ToUserName");
        //如果为已经关注,EventKey值为带参二维码值,如果是未关注 qrscene_为前缀,后面为二维码的参数值
        String eventKey = message.get("EventKey");
        //查询需要对应匹配的带参二维码事件值
        List<WxReplySceneDO> scenes = wxReplySceneDao.findByAppOriginIdAndMsgTypeAndEventAndStatus(toUserName,WeiXinMessageUtils.REQ_MESSAGE_TYPE_EVENT,WeiXinMessageUtils.EVENT_TYPE_SCAN,1);
        if(scenes!=null&&scenes.size()>0){
            for(WxReplySceneDO scene:scenes){
                //判断带参二维码中前缀是否包该场景值
                if(StringUtils.isNotBlank(scene.getScene())&&eventKey.indexOf(scene.getScene())!=-1){
                    return getGraphicXMl(scene.getScene(),scene.getWechatId(),message);
                }
            }
        }
        return "";
    }
@ -176,8 +198,9 @@ public class WechatCoreService {
     * @return
     */
    public String subscribeEventProcess(Map<String, String> message) throws Exception{
        //获取原始id
        String toUserName = message.get("ToUserName");
        List<WxReplySceneDO> scenes = wxReplySceneDao.findByAppOriginIdAndMsgTypeAndEventAndStatus(toUserName,WeiXinMessageUtils.RESP_MESSAGE_TYPE_TEXT,WeiXinMessageUtils.EVENT_TYPE_SUBSCRIBE,1);
        List<WxReplySceneDO> scenes = wxReplySceneDao.findByAppOriginIdAndMsgTypeAndEventAndStatus(toUserName,WeiXinMessageUtils.REQ_MESSAGE_TYPE_EVENT,WeiXinMessageUtils.EVENT_TYPE_SUBSCRIBE,1);
        if(scenes!=null&&scenes.size()>0){
            WxReplySceneDO scene = scenes.get(0);
            if(StringUtils.isNotBlank(scene.getScene())){
@ -187,10 +210,20 @@ public class WechatCoreService {
        return "";
    }
    /**
     * 取消关注事件,根据需求开发
     * @param message
     * @return
     */
    public String unsubscribeEventProcess(Map<String, String> message){
        return "";
    }
    /**
     * 点击事件,根据需求开发
     * @param message
     * @return
     */
    public String clickProcess(Map<String, String> message){
        return "";
    }
@ -232,6 +265,7 @@ public class WechatCoreService {
    public String getGraphicXMl(String secene,String wxId,Map<String, String> message)throws Exception{
        List<Map<String,Object>> group = getGraphicGroupByScene(secene,wxId);
        String result = "";
        String eventKey = message.get("EventKey");
        if(group!=null&&group.size()>0){
            List<Map<String, String>> articles = new ArrayList<>();
@ -251,6 +285,13 @@ public class WechatCoreService {
                if(url.indexOf("{appId}")!=-1){
                    url = url.replace("{appId}",appId);
                }
                //传递带参二维码给前端页面
                if(url.indexOf("{EventKey}")!=-1){
                    if(eventKey.indexOf("qrscene_")!=-1){
                        eventKey = eventKey.replace("qrscene_","");
                    }
                    url = url.replace("{EventKey}",eventKey);
                }
                article.put("Url", url);
                article.put("Title", title);

+ 94 - 0
svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WechatFansService.java

@ -0,0 +1,94 @@
package com.yihu.jw.business.wx.service;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * 微信粉丝管理
 * Created by Trick on 2018/8/22.
 */
@Service
public class WechatFansService {
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    /**
     * 创建分组
     * @param wxId
     * @param param
     * @return
     */
    public String createWxTag(String wxId,String param){
        String url = "https://api.weixin.qq.com/cgi-bin/tags/create?access_token="+wxAccessTokenService.getWxAccessTokenById(wxId).getAccessToken();
        return HttpUtil.sendPost(url,param);
    }
    /**
     * 查询分组
     * @param wxId
     * @return
     */
    public String findWxTag(String wxId){
        String url = "https://api.weixin.qq.com/cgi-bin/tags/get?access_token="+wxAccessTokenService.getWxAccessTokenById(wxId).getAccessToken();
        return HttpUtil.sendGet(url);
    }
    /**
     * 更新分组
     * @param wxId
     * @param param
     * @return
     */
    public String updateWxTag(String wxId,String param){
        String url = "https://api.weixin.qq.com/cgi-bin/tags/update?access_token="+wxAccessTokenService.getWxAccessTokenById(wxId).getAccessToken();
        return HttpUtil.sendPost(url,param);
    }
    /**
     * 删除分组
     * @param wxId
     * @param param
     * @return
     */
    public String deleteWxTag(String wxId,String param){
        String url = "https://api.weixin.qq.com/cgi-bin/tags/delete?access_token="+wxAccessTokenService.getWxAccessTokenById(wxId).getAccessToken();
        return HttpUtil.sendPost(url,param);
    }
    /**
     *  批量为用户打标签
     * @param wxId
     * @param param
     * @return
     */
    public String createBatchtagging(String wxId,String param){
        String url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token="+wxAccessTokenService.getWxAccessTokenById(wxId).getAccessToken();
        return HttpUtil.sendPost(url,param);
    }
    /**
     * 批量为用户取消标签
     * @param wxId
     * @param param
     * @return
     */
    public String cancelBatchuntagging(String wxId,String param){
        String url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token="+wxAccessTokenService.getWxAccessTokenById(wxId).getAccessToken();
        return HttpUtil.sendPost(url,param);
    }
    /**
     * 获取用户身上的标签列表
     * @param wxId
     * @param param
     * @return
     */
    public String getidlist(String wxId,String param){
        String url = "https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token="+wxAccessTokenService.getWxAccessTokenById(wxId).getAccessToken();
        return HttpUtil.sendPost(url,param);
    }
}

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WxAccessTokenService.java

@ -74,7 +74,7 @@ public class WxAccessTokenService extends BaseJpaService<WxAccessTokenDO, WxAcce
            params.put("appid", appId);
            params.put("secret", appSecret);
            String result = HttpUtils.doGet(token_url, params).getContent();
            logger.info("--------------微信返回结果:"+result+"---------------");
            logger.info("--------------wechat token return :"+result+"---------------");
            JSONObject json = new JSONObject(result);
            if (json.has("access_token")) {
                String token = json.get("access_token").toString();
@ -132,7 +132,7 @@ public class WxAccessTokenService extends BaseJpaService<WxAccessTokenDO, WxAcce
            params.put("appid", appId);
            params.put("secret", appSecret);
            String result = HttpUtils.doGet(token_url, params).getContent();
            logger.info("--------------微信返回结果:"+result+"---------------");
            logger.info("--------------wechat token return:"+result+"---------------");
            JSONObject json = new JSONObject(result);
            if (json.has("access_token")) {
                String token = json.get("access_token").toString();

+ 37 - 38
svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WxTemplateService.java

@ -1,40 +1,39 @@
//package com.yihu.jw.business.wx.service;
//
//import com.fasterxml.jackson.core.type.TypeReference;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.yihu.jw.base.wx.*;
//import com.yihu.jw.business.wx.dao.WxTemplateDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.base.mysql.query.BaseJpaService;
//import com.yihu.jw.rm.base.WechatRequestMapping;
//import com.yihu.jw.util.HttpUtil;
//import org.json.JSONObject;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.util.StringUtils;
//
//import java.util.*;
//
///**
// * Created by Administrator on 2017/5/19 0019.
// */
//@Service
//public class WxTemplateService extends BaseJpaService<WxTemplateDO, WxTemplateDao> {
//
//    private Logger logger= LoggerFactory.getLogger(WxTemplateService.class);
//
//    @Autowired
//    private WxTemplateDao wxTemplateDao;
//
//    @Autowired
//    private WxAccessTokenService wxAccessTokenService;
//
//    @Autowired
//    private WechatService wechatService;
//
package com.yihu.jw.business.wx.service;
import com.yihu.jw.business.wx.dao.WxTemplateConfigDao;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
@Service
public class WxTemplateService {
    private Logger logger= LoggerFactory.getLogger(WxTemplateService.class);
    @Autowired
    private WxTemplateConfigDao wxTemplateConfigDao;
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    @Autowired
    private WeixinMessagePushUtils weixinMessagePushUtils;
    public String sendWeTempMesTest(String wechatId,String openid)throws Exception{
        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndScene(wechatId,"template_survey","test");
        config.setFirst(config.getFirst().replace("key1","小明"));
        config.setKeyword2("2018-08-21");
        weixinMessagePushUtils.putWxMsg(wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken(),openid,config);
        return "success";
    }
//    public WxTemplateDO createWxTemplate(WxTemplateDO wxTemplate) {
//        if (StringUtils.isEmpty(wxTemplate.getTemplateId())) {
//            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_templateid_is_null, ExceptionCode.common_error_params_code);
@ -154,4 +153,4 @@
//    public List<WxTemplateDO> findByWxId(String code) {
//        return wxTemplateDao.findByWxId(code);
//    }
//}
}

+ 1 - 4
svr/svr-base/src/main/resources/application.yml

@ -22,7 +22,6 @@ spring:
    min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
hibernate:
  dialect: org.hibernate.dialect.MySQL5Dialect
  show_sql: true
@ -44,13 +43,11 @@ spring:
    username: root
    password: 123456
  zipkin:
    base-url: http://192.168.131.173:${server.svr-logServer-port} #日志追踪的地址
    base-url: http://localhost:9411 #日志追踪的地址
  sleuth:
    sampler:
      percentage: 1.0 #采用需要的请求的百分比 默认是0.1 即 10%
---
spring:
  profiles: jwtest

+ 10 - 2
svr/svr-base/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name: svr-base-lyx
    name: svr-base
  cloud:
    config:
      failFast: true
@ -21,4 +21,12 @@ spring:
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://172.17.110.212:1221}
      label: ${wlyy.spring.config.label:jwdev}
      label: ${wlyy.spring.config.label:jwdev}
---
spring:
  profiles: jwprod
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://172.17.110.212:1221}
      label: ${wlyy.spring.config.label:jwprod}

+ 10 - 1
svr/svr-wlyy-health-bank/src/main/resources/bootstrap.yml

@ -21,4 +21,13 @@ spring:
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://172.17.110.212:1221}
      label: ${wlyy.spring.config.label:jwdev}
      label: ${wlyy.spring.config.label:jwdev}
---
spring:
  profiles: prod
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://192.168.120.153:1221}
      label: ${wlyy.spring.config.label:prod}

+ 7 - 0
svr/svr-wlyy-specialist/pom.xml

@ -107,6 +107,13 @@
            <!--<artifactId>commons-util</artifactId>-->
            <!--<version>1.1.0</version>-->
        <!--</dependency>-->
        <!-- jkzl starter -->
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>fastdfs-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
    </dependencies>
    <build>

+ 49 - 2
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/SpecialistController.java

@ -205,9 +205,11 @@ public class SpecialistController extends EnvelopRestEndpoint {
    @ApiOperation(value = "专科医生审核")
    public MixEnvelop<Boolean, Boolean> agreeSpecialistTeam(@ApiParam(name = "state", value = "状态0为拒绝,1为同意") @RequestParam(required = true)String state,
                                                   @ApiParam(name = "relationCode", value = "关联code") @RequestParam(required = true)String relationCode,
                                                   @ApiParam(name = "remark", value = "审核失败原因") @RequestParam(required = false)String remark) {
                                                   @ApiParam(name = "remark", value = "审核失败原因") @RequestParam(required = false)String remark,
                                                   @ApiParam(name = "health_assistant", value = "计管医生CODE") @RequestParam(required = false)String health_assistant,
                                                   @ApiParam(name = "health_assistant_name", value = "计管医生名称") @RequestParam(required = false)String health_assistant_name) {
        try {
            return specialistService.agreeSpecialistTeam(state,relationCode,remark);
            return specialistService.agreeSpecialistTeam(state,relationCode,remark,health_assistant,health_assistant_name);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
@ -263,6 +265,51 @@ public class SpecialistController extends EnvelopRestEndpoint {
            return MixEnvelop.getError(e.getMessage());
        }
    }
    
    @GetMapping(value = SpecialistMapping.specialist.findDoctorAndDoctorHealthBySpecialDoctor)
    @ApiOperation(value = "获取当前专科医生有关联的家庭医生和健管师列表")
    public MixEnvelop findDoctorAndDoctorHealthBySpecialDoctor(
            @ApiParam(name = "doctor", value = "专科医生code") @RequestParam(required = true)String doctor){
        try {
            return specialistService.findDoctorAndDoctorHealthBySpecialDoctor(doctor);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }
    
    @GetMapping(value = SpecialistMapping.specialist.findSpecialistSignFamilyPatientCout)
    @ApiOperation(value = "获取专科医生家庭医生共管居民数目")
    public MixEnvelop<Long, Long> findSpecialistSignFamilyPatientCout(
            @ApiParam(name = "specialdoctor", value = "专科医生") @RequestParam(required = true)String specialdoctor,
            @ApiParam(name = "familydoctor", value = "家庭医生") @RequestParam(required = true)String familydoctor
    ){
        try {
            return specialistService.findSpecialistSignFamilyPatientCout(specialdoctor,familydoctor);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }
    
    @GetMapping(value = SpecialistMapping.specialist.getSpecialistSignFamilyPatientByName)
    @ApiOperation(value = "搜索专科医生家庭医生共管居民")
    public MixEnvelop<PatientRelationVO, PatientRelationVO> getSpecialistSignFamilyPatientByName(
            @ApiParam(name = "specialdoctor", value = "专科医生") @RequestParam(required = true)String specialdoctor,
            @ApiParam(name = "familydoctor", value = "家庭医生") @RequestParam(required = true)String familydoctor,
            @ApiParam(name = "nameKey", value = "居民姓名模糊") @RequestParam(required = false)String nameKey,
            @ApiParam(name = "page", value = "第几页,1开始") @RequestParam(required = true)Integer page,
            @ApiParam(name = "size", value = "每页大小") @RequestParam(required = true)Integer size) {
        try {
            return specialistService.getSpecialistSignFamilyPatientByName(specialdoctor,familydoctor,nameKey,page,size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }

+ 268 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/common/FileUploadController.java

@ -0,0 +1,268 @@
package com.yihu.jw.controller.common;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.jw.service.FileUploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.net.URLDecoder;
import java.util.Base64;
import java.util.Map;
/**
 * @author yeshijie on 2017/12/7.
 */
@RestController
@RequestMapping(SpecialistMapping.common.file_upload)
@Api(tags = "文件上传相关操作", description = "文件上传相关操作")
public class FileUploadController {
    @Autowired
    private FastDFSUtil fastDFSHelper;
    @Value("${fast-dfs.public-server}")
    private String fastdfs_file_url;
    @Autowired
    private FileUploadService fileUploadService;
    @Value("${neiwang.enable}")
    private Boolean isneiwang;  //如果不是内网项目要转到到内网在上传
    @Autowired
    protected HttpServletRequest request;
    /*@PostMapping(value = IotRequestMapping.FileUpload.api_upload_stream_img)
    @ApiOperation(value = "文件流上传图片", notes = "文件流上传图片")
    public MixEnvelop<UploadVO, UploadVO> uploadImg(@ApiParam(value = "文件", required = true)
                                       @RequestParam(value = "file", required = true) MultipartFile file){
        try {
            // 得到文件的完整名称  xxx.txt
            String fullName = file.getOriginalFilename();
            if(StringUtils.isBlank(fullName)){
                return MixEnvelop.getError(IotRequestMapping.FileUpload.message_fail_upload_format,IotRequestMapping.api_iot_fail);
            }
            //得到文件类型
            String fileType = fullName.substring(fullName.lastIndexOf(".") + 1).toLowerCase();
            if(StringUtils.isBlank(fileType)||!"jpg,jpeg,png".contains(fileType)){
                return MixEnvelop.getError(IotRequestMapping.FileUpload.message_fail_upload_format,IotRequestMapping.api_iot_fail);
            }
            long size = file.getSize();
            long max = 5*1024*1024;
            if(size>max){
                return MixEnvelop.getError("文件大小不超过5M",IotRequestMapping.api_iot_fail);
            }
            String fileName = fullName.substring(0, fullName.lastIndexOf("."));
            //上传到fastdfs
            ObjectNode objectNode = null;
            //解析返回的objectNode
            UploadVO uploadVO = null;
            if(isneiwang){
                objectNode = fastDFSHelper.upload(file.getInputStream(), fileType, "");
                uploadVO = new UploadVO();
                uploadVO.setFileName(fileName);
                uploadVO.setFileType(fileType);
                uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
                uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
            }else {
                uploadVO = fileUploadService.request(request,file.getInputStream(),fullName);
                if(uploadVO==null){
                    return MixEnvelop.getError("文件上传失败",IotRequestMapping.api_iot_fail);
                }
            }
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_create, uploadVO);
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(IotRequestMapping.FileUpload.message_fail_upload, IotRequestMapping.api_iot_fail);
        }
    }
    @PostMapping(value = IotRequestMapping.FileUpload.api_upload_stream_attachment)
    @ApiOperation(value = "文件流上传附件", notes = "文件流上传附件")
    public MixEnvelop<UploadVO, UploadVO> uploadAttachment(@ApiParam(value = "文件", required = true)
                                              @RequestParam(value = "file", required = true) MultipartFile file){
        try {
            // 得到文件的完整名称  xxx.txt
            String fullName = file.getOriginalFilename();
            if(StringUtils.isBlank(fullName)){
                return MixEnvelop.getError(IotRequestMapping.FileUpload.message_fail_upload_format,IotRequestMapping.api_iot_fail);
            }
            //得到文件类型
            String fileType = fullName.substring(fullName.lastIndexOf(".") + 1).toLowerCase();
            if(StringUtils.isBlank(fileType)||!"doc、docx、pdf、xls、xlsx、jpg、jpeg、png".contains(fileType)){
                return MixEnvelop.getError(IotRequestMapping.FileUpload.message_fail_upload_format,IotRequestMapping.api_iot_fail);
            }
            long size = file.getSize();
            long max = 5*1024*1024;
            if(size>max){
                return MixEnvelop.getError("文件大小不超过5M",IotRequestMapping.api_iot_fail);
            }
            String fileName = fullName.substring(0, fullName.lastIndexOf("."));
            //上传到fastdfs
            ObjectNode objectNode = null;
            //解析返回的objectNode
            UploadVO uploadVO = null;
            if(isneiwang){
                objectNode = fastDFSHelper.upload(file.getInputStream(), fileType, "");
                uploadVO = new UploadVO();
                uploadVO.setFileName(fileName);
                uploadVO.setFileType(fileType);
                uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
                uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
            }else {
                uploadVO = fileUploadService.request(request,file.getInputStream(),fullName);
                if(uploadVO==null){
                    return MixEnvelop.getError("文件上传失败",IotRequestMapping.api_iot_fail);
                }
            }
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_create, uploadVO);
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(IotRequestMapping.FileUpload.message_fail_upload, IotRequestMapping.api_iot_fail);
        }
    }
    @PostMapping(value = IotRequestMapping.FileUpload.api_upload_stream)
    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
    public MixEnvelop<UploadVO, UploadVO> uploadStream(@ApiParam(value = "文件", required = true) @RequestParam(value = "file", required = true) MultipartFile file) {
        try {
            // 得到文件的完整名称  xxx.txt
            String fullName = file.getOriginalFilename();
            //得到文件类型
            String fileType = fullName.substring(fullName.lastIndexOf(".") + 1).toLowerCase();
            String fileName = fullName.substring(0, fullName.lastIndexOf("."));
            //上传到fastdfs
            ObjectNode objectNode = null;
            //解析返回的objectNode
            UploadVO uploadVO = null;
            if(isneiwang){
                objectNode = fastDFSHelper.upload(file.getInputStream(), fileType, "");
                uploadVO = new UploadVO();
                uploadVO.setFileName(fileName);
                uploadVO.setFileType(fileType);
                uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
                uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
            }else {
                uploadVO = fileUploadService.request(request,file.getInputStream(),fullName);
                if(uploadVO==null){
                    return MixEnvelop.getError("文件上传失败",IotRequestMapping.api_iot_fail);
                }
            }
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_create, uploadVO);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(IotRequestMapping.FileUpload.message_fail_upload, IotRequestMapping.api_iot_fail);
        }
    }
    @PostMapping(value = IotRequestMapping.FileUpload.api_upload_string)
    @ApiOperation(value = "base64上传图片",notes = "base64上传图片")
    public MixEnvelop<UploadVO, UploadVO> uploadImages(@ApiParam(name = "jsonData", value = "头像转化后的输入流") @RequestBody String jsonData) throws Exception {
        try {
            String date = URLDecoder.decode(jsonData,"UTF-8");
            String[] fileStreams = date.split(",");
            String is = URLDecoder.decode(fileStreams[1],"UTF-8").replace(" ","+");
            byte[] in = Base64.getDecoder().decode(is);
            InputStream inputStream = new ByteArrayInputStream(in);
            ObjectNode objectNode = null;
            //上传到fastdfs
            String fileType = "png";
            //解析返回的objectNode
            UploadVO uploadVO = null;
            if(isneiwang){
                objectNode = fastDFSHelper.upload(inputStream, fileType, "");
                String groupName = objectNode.get("groupName").toString();
                String remoteFileName = objectNode.get("remoteFileName").toString();
                uploadVO = new UploadVO();
                uploadVO.setFileName(remoteFileName);
                uploadVO.setFileType(groupName);
                uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
                uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
            }else {
                uploadVO = fileUploadService.request(request,inputStream,"");
                if(uploadVO ==null){
                    return MixEnvelop.getError("文件上传失败",IotRequestMapping.api_iot_fail);
                }
            }
            //返回文件路径
            return MixEnvelop.getSuccess(IotRequestMapping.FileUpload.message_success_upload, uploadVO);
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(IotRequestMapping.FileUpload.message_fail_upload, IotRequestMapping.api_iot_fail);
        }
    }*/
    @RequestMapping(value = "commonUpload", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("公共的文件上传")
    public MixEnvelop<UploadVO, UploadVO> commonUpload(HttpServletRequest request) {
        InputStream in = null;
        try {
            String paths = request.getParameter("filePaths");
            ObjectNode result = null;
            if (StringUtils.isBlank(paths)) {
                //为空是文件上传
                MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
                // 文件保存的临时路径
                Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
                String fileName = null;
                for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                    // 上传文件
                    MultipartFile mf = entity.getValue();
                    fileName = mf.getOriginalFilename();
                    in = mf.getInputStream();
                    result = fastDFSHelper.upload(in, fileName.substring(fileName.lastIndexOf(".") + 1), "");
                }
            } else {
                String[] pathArr = paths.split(",");
                for (String path : pathArr) {
                    //传路径自己去路径上传
                    File file = new File(path);
                    String fileName = null;
                    if (file.exists()) {
                        fileName = file.getName();
                        in = new FileInputStream(file);
                        result = fastDFSHelper.upload(in, fileName.substring(fileName.lastIndexOf(".") + 1), "");
                    }
                }
            }
            //解析返回的objectNode
            UploadVO uploadVO = new UploadVO();
            uploadVO.setFullUri(result.get("fileId").toString().replaceAll("\"", ""));
            uploadVO.setFullUrl(fastdfs_file_url + result.get("fileId").toString().replaceAll("\"", ""));
            return MixEnvelop.getSuccess(IotRequestMapping.FileUpload.message_success_upload, result);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(IotRequestMapping.FileUpload.message_fail_upload, IotRequestMapping.api_iot_fail);
        }finally {
            if(in!=null){
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

+ 196 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationPlanController.java

@ -0,0 +1,196 @@
package com.yihu.jw.controller.rehabilitation;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.specialist.rehabilitation.PatientRehabilitationPlanDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationDetailDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationPlanTemplateDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationTemplateDetailDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.jw.service.rehabilitation.RehabilitationPlanService;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by humingfen on 2018/8/17.
 */
@RestController
@RequestMapping(SpecialistMapping.api_specialist_common)
@Api(tags = "康复服务套餐管理相关操作", description = "康复服务套餐管理相关操作")
public class RehabilitationPlanController extends EnvelopRestEndpoint {
    @Autowired
    private RehabilitationPlanService rehabilitationPlanService;
    @Autowired
    private Tracer tracer;
    @PostMapping(value = SpecialistMapping.rehabilitation.createRehabilitationPlanTemplate)
    @ApiOperation(value = "康复服务套餐模板创建")
    public MixEnvelop<String, String> createRehabilitationPlanTemplate(@ApiParam(name = "rehabilitationTemplate", value = "实体JSON")
                                                             @RequestParam(value = "rehabilitationTemplate", required = true)String rehabilitationTemplate){
        try {
            RehabilitationPlanTemplateDO templateDO = toEntity(rehabilitationTemplate, RehabilitationPlanTemplateDO.class);
            return rehabilitationPlanService.createRehabilitationTemplate(templateDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = SpecialistMapping.rehabilitation.createRehabilitationTemplateDetail)
    @ApiOperation(value = "康复服务套餐模板明细创建")
    public MixEnvelop<Boolean, Boolean> createRehabilitationTemplateDetail(@ApiParam(name = "rehabilitationTemplateDetail", value = "实体JSON")
                                                             @RequestParam(value = "rehabilitationTemplateDetail", required = true)String rehabilitationTemplateDetail){
        try {
            List<RehabilitationTemplateDetailDO> details = new ObjectMapper().readValue(rehabilitationTemplateDetail, new TypeReference<List<RehabilitationTemplateDetailDO>>(){});
            return rehabilitationPlanService.createRehabilitationTemplateDetail(details);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = SpecialistMapping.rehabilitation.findRehabilitationPlanTemplate)
    @ApiOperation(value = "获取康复服务套餐模板列表")
    public MixEnvelop<RehabilitationPlanTemplateDO, RehabilitationPlanTemplateDO> findRehabilitationPlanTemplate(@ApiParam(name = "adminTeamCode", value = "行政团队id")
                                                                                   @RequestParam(value = "adminTeamCode", required = true)Integer adminTeamCode,
                                                                               @ApiParam(name = "page", value = "第几页,从1开始")
                                                                              @RequestParam(value = "page", required = false)Integer page,
                                                                              @ApiParam(name = "size", value = ",每页分页大小")
                                                                              @RequestParam(value = "size", required = false)Integer size){
        try {
            return rehabilitationPlanService.findRehabilitationPlanTemplate(adminTeamCode, page, size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = SpecialistMapping.rehabilitation.findTemplateDetailByTemplateId)
    @ApiOperation(value = "获取康复服务套餐模板明细")
    public MixEnvelop<RehabilitationTemplateDetailDO, RehabilitationTemplateDetailDO> findTemplateDetailByTemplateId(@ApiParam(name = "templateId", value = "模板id")
                                                                                      @RequestParam(value = "templateId", required = true)String templateId){
        try {
            return rehabilitationPlanService.findTemplateDetailByTemplateId(templateId);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = SpecialistMapping.rehabilitation.updateRehabilitationTemplateDetail)
    @ApiOperation(value = "编辑康复服务套餐模板明细")
    public MixEnvelop<Boolean, Boolean> updateRehabilitationTemplateDetail(@ApiParam(name = "rehabilitationTemplateDetail", value = "实体JSON")
                                                                           @RequestParam(value = "rehabilitationTemplateDetail", required = true)String rehabilitationTemplateDetail){
        try {
            List<RehabilitationTemplateDetailDO> details = new ObjectMapper().readValue(rehabilitationTemplateDetail, new TypeReference<List<RehabilitationTemplateDetailDO>>(){});
            return rehabilitationPlanService.updateRehabilitationTemplateDetail(details);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }
    /******************************** 居民康复计划 ***************************************/
    @PostMapping(value = SpecialistMapping.rehabilitation.createPatientRehabilitationPlan)
    @ApiOperation(value = "居民康复服务套餐创建")
    public MixEnvelop<String, String> createPatientRehabilitationPlan(@ApiParam(name = "rehabilitationPlan", value = "实体JSON")
                                                                       @RequestParam(value = "rehabilitationPlan", required = true)String rehabilitationPlan){
        try {
            JSONObject json = new JSONObject(rehabilitationPlan);
            JSONArray array = new JSONArray();
            for(Object planDetail : json.getJSONArray("detail")) {
                JSONObject j = (JSONObject)planDetail;
                String executeTime = j.get("executeTime").toString();
                String[] result = null;
                if(executeTime.contains(",")){
                    result = executeTime.split(",");
                }else {
                    result = new String[1];
                    result[0] = executeTime;
                }
                int len =  result.length;
                while(len > 0){
                    len --;
                    JSONObject temp = new JSONObject(j.toString());
                    temp.put("executeTime", result[len]);
                    temp.put("createUser", json.get("createUser"));
                    temp.put("createUserName", json.get("createUserName"));
                    array.put(temp);
                }
            }
            String planDetails = array.toString();
            ObjectMapper object = new ObjectMapper();
            object.setDateFormat(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"));
            List<RehabilitationDetailDO> details = object.readValue(planDetails, new TypeReference<List<RehabilitationDetailDO>>(){});
            PatientRehabilitationPlanDO planDO = toEntity(rehabilitationPlan, PatientRehabilitationPlanDO.class);
            planDO = rehabilitationPlanService.createPatientRehabilitationPlan(planDO);
            details = rehabilitationPlanService.createRehabilitationDetail(details, planDO.getId());
            return MixEnvelop.getSuccess(SpecialistMapping.api_success);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = SpecialistMapping.rehabilitation.createServiceQrCode)
    @ApiOperation(value = "根据康复计划id和居民code生成服务码")
    public MixEnvelop<String,String> createServiceQrCode(@ApiParam(name = "planId", value = "计划居民关系唯一标识")@RequestParam(value = "planId", required = true)String planId,
                                                         @ApiParam(name = "patientCode", value = "居民code")@RequestParam(value = "patientCode", required = true)String patientCode){
        try {
            return rehabilitationPlanService.createServiceQrCode(planId,patientCode);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = SpecialistMapping.rehabilitation.checkAfterQrCode)
    @ApiOperation(value = "居民扫码后验证是否是关联的居民扫码")
    public MixEnvelop<Boolean,Boolean> checkAfterQrCode(@ApiParam(name = "planId", value = "计划居民关系唯一标识")@RequestParam(value = "planId", required = true)String planId,
                                                         @ApiParam(name = "patientCode", value = "居民端登录的居民code")@RequestParam(value = "patientCode", required = true)String patientCode){
        try {
            String message="";
            Boolean flag = true;
            if (rehabilitationPlanService.checkAfterQrCode(planId,patientCode)==1){
                message = "验证成功!";
            }
            if (rehabilitationPlanService.checkAfterQrCode(planId,patientCode)==-1){
                message = "请相关居民扫描二维码";
                flag=false;
            }
            if (rehabilitationPlanService.checkAfterQrCode(planId,patientCode)==-10000){
                message = "相关康复管理数据错误,请联系工作人员!";
                flag=false;
            }
            return MixEnvelop.getSuccess(message,flag);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 3 - 1
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/PatientRehabilitationPlanDao.java

@ -1,7 +1,9 @@
package com.yihu.jw.dao.rehabilitation;
import com.yihu.jw.entity.specialist.PatientHospitalRecordDO;
import com.yihu.jw.entity.specialist.rehabilitation.PatientRehabilitationPlanDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
@ -9,5 +11,5 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface PatientRehabilitationPlanDao extends PagingAndSortingRepository<PatientRehabilitationPlanDO, Long>,JpaSpecificationExecutor<PatientRehabilitationPlanDO> {
    PatientRehabilitationPlanDO findById(String id);
}

+ 14 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationPlanTemplateDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.dao.rehabilitation;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationPlanTemplateDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface RehabilitationPlanTemplateDao extends PagingAndSortingRepository<RehabilitationPlanTemplateDO, Long>,JpaSpecificationExecutor<RehabilitationPlanTemplateDO> {
    @Query("select t from RehabilitationPlanTemplateDO t where t.adminTeamCode = ?1 ORDER BY t.createTime DESC ")
    List<RehabilitationPlanTemplateDO> findByAdminTeamCode(Integer adminTeamCode);
}

+ 14 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationTemplateDetailDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.dao.rehabilitation;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationTemplateDetailDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface RehabilitationTemplateDetailDao extends PagingAndSortingRepository<RehabilitationTemplateDetailDO, Long>,JpaSpecificationExecutor<RehabilitationTemplateDetailDO> {
    List<RehabilitationTemplateDetailDO> findTemplateDetailByTemplateId(String templateId);
    void deleteByTemplateId(String templateId);
}

+ 91 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/FileUploadService.java

@ -0,0 +1,91 @@
package com.yihu.jw.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
/**
 * @author zhangdan on 2018/08/22.
 */
@Service
public class FileUploadService{
    @Value("${neiwang.wlyy}")
    private String neiwangWlyy;  //内网的项目地址
    /**
     * 通用的文件上传
     * @param request
     * @param in
     * @param fileName
     * @return
     */
    public UploadVO request(HttpServletRequest request, InputStream in, String fileName) {
        String url = neiwangWlyy + "/fileUpload/commonUpload";//uri请求路径 http://172.19.103.88/wlyy/upload/chat
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();
        String result = "";
        UploadVO uploadVO = null;
        try {
            HttpPost httpPost = new HttpPost(url);
            MultipartEntityBuilder builder = MultipartEntityBuilder.create();
            builder.addBinaryBody("file", in, ContentType.MULTIPART_FORM_DATA, fileName);// 文件流
            builder.addTextBody("filename", fileName);// 类似浏览器表单提交,对应input的name和value
            if (!org.springframework.util.StringUtils.isEmpty(request.getParameter("type"))) {
                builder.addTextBody("type", request.getParameter("type")); //发送类型
            }
            HttpEntity entity = builder.build();
            httpPost.setEntity(entity);
            HttpResponse response = httpClient.execute(httpPost);// 执行提交
            HttpEntity responseEntity = response.getEntity();
            if (responseEntity != null) {
                // 将响应内容转换为字符串
                result = EntityUtils.toString(responseEntity, Charset.forName("UTF-8"));
            }
            JSONObject jsonObject = JSONObject.parseObject(result);
            if(jsonObject.getInteger("status")==200){
                JSONObject obj = jsonObject.getJSONObject("obj");
                uploadVO = new UploadVO();
                uploadVO.setFileName(obj.getString("groupName"));
                uploadVO.setFileType(obj.getString("remoteFileName"));
                uploadVO.setFullUri(obj.getString("fileId"));
                uploadVO.setFullUrl(obj.getString("fileUrl"));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                httpClient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return uploadVO;
    }
}

+ 102 - 3
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java

@ -5,6 +5,7 @@ import com.yihu.jw.entity.specialist.*;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.specialist.*;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -179,6 +180,8 @@ public class SpecialistService{
    public MixEnvelop<PatientLabelVO, PatientLabelVO> getPatientByLabel(String doctor, String labelType, String labelCode, Integer page, Integer size){
    
    
        String sql="SELECT " +
                " p. NAME, " +
                " p. CODE, " +
@ -226,6 +229,27 @@ public class SpecialistService{
                " ) h ON h.patient = lb.patient " +
                " WHERE s.doctor ='"+doctor+"' AND s.status >=0  AND s.sign_status >0"+
                " LIMIT "+(page-1)*size+","+size;
        
        if("7".equals(labelType)){
            sql = "SELECT " +
                    "c.CODE," +
                    "c.NAME," +
                    "c.sex," +
                    "IFNULL(YEAR (from_days(datediff(now(),c.birthday))),'未知') age," +
                    "c.photo,b.disease AS label," +
                    "b.disease_name AS labelName," +
                    "d.label_name AS health," +
                    "d.label AS healthcode," +
                    "a.health_assistant AS healthAssistant," +
                    "a.health_assistant_name AS healthAssistantName " +
                    "FROM wlyy_specialist.wlyy_specialist_patient_relation a " +
                    "JOIN "+basedb+".wlyy_patient_disease_server b ON a.patient=b.patient AND b.disease=" +labelCode+" and b.del=1 "+
                    "JOIN "+basedb+".wlyy_patient c ON a.patient=c.CODE " +
                    "LEFT JOIN "+basedb+".wlyy_sign_patient_label_info d ON a.patient=d.patient AND d.label_type=8 AND d.`status`=1" +
                    " WHERE a.sign_status> 0 AND a.`status`>=0 AND a.doctor='"+doctor+"'"+
                    " LIMIT "+(page-1)*size+","+size;
        }
        List<PatientLabelVO> PatientLabelVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientLabelVO.class));
@ -461,7 +485,7 @@ public class SpecialistService{
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,relationDO.getId());
    }
    public MixEnvelop<Boolean, Boolean> agreeSpecialistTeam(String state, String relationCode, String remark){
    public MixEnvelop<Boolean, Boolean> agreeSpecialistTeam(String state, String relationCode, String remark,String health_assistant,String health_assistant_name){
        SpecialistPatientRelationDO relation = specialistPatientRelationDao.findOne(relationCode);
@ -472,6 +496,9 @@ public class SpecialistService{
            specialistPatientRelationDao.save(relation);
        }else{
            relation.setSignStatus("1");
            relation.setHealthAssistant(health_assistant);
            relation.setHealthAssistant(health_assistant_name);
            relation.setSignDate(new Date());
            specialistPatientRelationDao.save(relation);
        }
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,relation);
@ -492,7 +519,8 @@ public class SpecialistService{
                " t.id As teamCode, " +
                " r.create_time AS createTime," +
                " r.status," +
                " r.sign_status AS signStatus  " +
                " r.sign_status AS signStatus,  " +
                " r.team_code AS teamCode  " +
                " FROM " +
                " wlyy_specialist_patient_relation r " +
                " JOIN "+basedb+".wlyy_doctor d ON r.doctor = d.code " +
@ -594,7 +622,78 @@ public class SpecialistService{
        List<PatientSignInfoVO> patientSignInfoVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientSignInfoVO.class));
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientSignInfoVOs.get(0));
    }
    
    public MixEnvelop findDoctorAndDoctorHealthBySpecialDoctor(String doctor) {
        String sql = "SELECT " +
                "doctor.CODE AS CODE," +
                "doctor.NAME AS NAME," +
                "doctor.sex AS sex," +
                "doctor.birthday AS birthday," +
                "doctor.photo AS photo," +
                "doctor.mobile AS mobile," +
                "doctor.hospital AS hospital," +
                "doctor.hospital_name AS hospitalName," +
                "doctor.dept AS dept," +
                "doctor.dept_name AS deptName," +
                "doctor.job AS job," +
                "doctor.job_name AS jobName," +
                "doctor.LEVEL AS LEVEL," +
                "doctor.qrcode AS qrcode," +
                "doctor.czrq AS czrq," +
                "doctor.del AS del," +
                "doctor.idcard AS idcard " +
                "FROM wlyy.wlyy_doctor doctor RIGHT JOIN ( " +
                "SELECT a.doctor AS doctorcode FROM wlyy.wlyy_sign_family a RIGHT JOIN ( " +
                "SELECT patient FROM wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 AND doctor='"+doctor+"') b ON a.patient=b.patient WHERE a.`status`=1 AND a.expenses_status = 1 " +
                "UNION  " +
                "SELECT a.doctor_health AS doctorcode FROM wlyy.wlyy_sign_family a RIGHT JOIN ( " +
                "SELECT patient FROM wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 AND doctor='"+doctor+"') b ON a.patient=b.patient WHERE a.`status`=1 AND a.expenses_status = 1 " +
                ") " +
                "t ON doctor.CODE=t.doctorcode";
        List<SignFamilyDoctorVO> patientSignInfoVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamilyDoctorVO.class));
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientSignInfoVOs);
    }
    
    public MixEnvelop<Long,Long> findSpecialistSignFamilyPatientCout(String specialdoctor, String familydoctor) {
    
        String sql = "SELECT count(1) AS total " +
                "FROM wlyy.wlyy_sign_family a WHERE a.`status`=1 AND a.expenses_status=1 " +
                "AND patient IN (" +
                "SELECT patient FROM wlyy_specialist.wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 " +
                "AND doctor='"+specialdoctor+"') " +
                "AND (a.doctor='"+familydoctor+"' OR a.doctor_health='"+familydoctor+"') ";
    
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sql);
        Long count = 0L;
        if(rstotal!=null&&rstotal.size()>0){
            count = (Long) rstotal.get(0).get("total");
        }
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,count);
    }
    
    public MixEnvelop<PatientRelationVO,PatientRelationVO> getSpecialistSignFamilyPatientByName(String specialdoctor, String familydoctor, String nameKey, Integer page, Integer size) {
        String sql ="SELECT " +
                "p.CODE AS patient," +
                "p.`name` AS patientName," +
                "p.photo," +
                "IFNULL(YEAR (from_days(datediff(now(),p.birthday))),'未知') age," +
                "p.sex " +
                "FROM wlyy.wlyy_patient p " +
                "JOIN ( " +
                " SELECT a.patient FROM wlyy.wlyy_sign_family a WHERE patient IN (" +
                "  SELECT patient FROM wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 " +
                "  AND doctor='"+specialdoctor+"') " +
                "  AND (a.doctor='"+familydoctor+"' OR a.doctor_health='"+familydoctor+"') ";
        if(StringUtils.isNotBlank(nameKey)){
            sql= sql + "  AND a.NAME LIKE '%"+nameKey+"%' ";
        }
        sql= sql +" AND a.`status`=1 AND a.expenses_status=1) s ON p.CODE=s.patient" +
                " LIMIT "+(page-1)*size+","+size;
    
        List<PatientRelationVO> patientRelationVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientRelationVO.class));
    
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientRelationVOs);
    }
//    public Envelop<Boolean> createSpecialists(List<SpecialistDO> info){

+ 180 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationPlanService.java

@ -0,0 +1,180 @@
package com.yihu.jw.service.rehabilitation;
import com.yihu.jw.dao.rehabilitation.PatientRehabilitationPlanDao;
import com.yihu.jw.dao.rehabilitation.RehabilitationDetailDao;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.jw.dao.rehabilitation.PatientRehabilitationPlanDao;
import com.yihu.jw.dao.rehabilitation.RehabilitationPlanTemplateDao;
import com.yihu.jw.dao.rehabilitation.RehabilitationTemplateDetailDao;
import com.yihu.jw.entity.specialist.rehabilitation.PatientRehabilitationPlanDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationDetailDO;
import com.yihu.jw.entity.specialist.rehabilitation.PatientRehabilitationPlanDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationPlanTemplateDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationTemplateDetailDO;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.jw.service.FileUploadService;
import com.yihu.jw.util.common.QrcodeUtil;
import com.yihu.fastdfs.FastDFSUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * Created by humingfen on 2018/8/17.
 */
@Service
@Transactional
public class RehabilitationPlanService {
    @Value("${neiwang.enable}")
    private Boolean isneiwang;  //如果不是内网项目要转到到内网wlyy在上传
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Autowired
    private RehabilitationPlanTemplateDao templateDao;
    @Autowired
    private RehabilitationTemplateDetailDao templateDetailDao;
    @Autowired
    private PatientRehabilitationPlanDao patientRehabilitationPlanDao;
    @Autowired
    private RehabilitationDetailDao rehabilitationDetailDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private FastDFSUtil fastDFSHelper;
    @Autowired
    private FileUploadService fileUploadService;
    @Autowired
    protected HttpServletRequest request;
    public MixEnvelop<String, String> createRehabilitationTemplate(RehabilitationPlanTemplateDO templateDO) {
        templateDO.setCreateTime(new Date());
        templateDO = templateDao.save(templateDO);
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,templateDO.getId());
    }
    public MixEnvelop<Boolean, Boolean> createRehabilitationTemplateDetail(List<RehabilitationTemplateDetailDO> details) {
        for(RehabilitationTemplateDetailDO detail : details){
            detail.setCreateTime(new Date());
            templateDetailDao.save(detail);
        }
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,true);
    }
    public MixEnvelop<Boolean,Boolean> updateRehabilitationTemplateDetail(List<RehabilitationTemplateDetailDO> details) {
        String templateId = details.get(0).getTemplateId();
        if(templateId != null && templateId.length() > 0){
            templateDetailDao.deleteByTemplateId(templateId);
        }
        for(RehabilitationTemplateDetailDO detail : details){
            detail.setCreateTime(new Date());
            templateDetailDao.save(detail);
        }
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,true);
    }
    public MixEnvelop<RehabilitationPlanTemplateDO, RehabilitationPlanTemplateDO> findRehabilitationPlanTemplate(Integer adminTeamCode, Integer page, Integer size) {
        if(page != null && size != null){
            String sql = "select * from wlyy_rehabilitation_plan_template t where t.admin_team_code = '" + adminTeamCode + "' ORDER BY t.create_time DESC LIMIT "+(page-1)*size+","+size;
            List<RehabilitationPlanTemplateDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(RehabilitationPlanTemplateDO.class));
            String countSql = "select count(1) from wlyy_rehabilitation_plan_template t where t.admin_team_code = '" + adminTeamCode + "'";
            Long count = jdbcTemplate.queryForObject(countSql, Long.class);
            return MixEnvelop.getSuccessListWithPage(SpecialistMapping.api_success,list,page,size,count);
        }else {
            List<RehabilitationPlanTemplateDO> list = templateDao.findByAdminTeamCode(adminTeamCode);
            return MixEnvelop.getSuccess(SpecialistMapping.api_success,list, list.size());
        }
    }
    public MixEnvelop<RehabilitationTemplateDetailDO, RehabilitationTemplateDetailDO> findTemplateDetailByTemplateId(String templateId) {
        List<RehabilitationTemplateDetailDO> list = templateDetailDao.findTemplateDetailByTemplateId(templateId);
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,list, list.size());
    }
    public PatientRehabilitationPlanDO createPatientRehabilitationPlan(PatientRehabilitationPlanDO planDO) {
        planDO.setCreateTime(new Date());
        planDO.setStatus(1);
        return patientRehabilitationPlanDao.save(planDO);
    }
    public List<RehabilitationDetailDO> createRehabilitationDetail(List<RehabilitationDetailDO> details, String planId) {
        for(RehabilitationDetailDO detail : details) {
            detail.setPlanId(planId);
            detail.setStatus(1);
        }
        return (List<RehabilitationDetailDO>)rehabilitationDetailDao.save(details);
    }
    public MixEnvelop<String,String> createServiceQrCode(String planId,String patientCode){
        PatientRehabilitationPlanDO patientRehabilitationPlanDO = patientRehabilitationPlanDao.findById(planId);
        String fileUrl = "";
        if (patientRehabilitationPlanDO!=null) {
            if (org.apache.commons.lang3.StringUtils.isNotBlank(patientRehabilitationPlanDO.getServiceQrCode())) {
                fileUrl = patientRehabilitationPlanDO.getServiceQrCode();
            } else {
                InputStream ipt = QrcodeUtil.createQrcode(planId+"|"+patientCode, 300, "png");
                isneiwang = false;
                if (isneiwang) {
                    // 圖片列表
                    List<String> tempPaths = new ArrayList<String>();
                    try {
                        ObjectNode imgNode = fastDFSHelper.upload(ipt, "png", "plan_service_qrcode" + System.currentTimeMillis());
                        com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(imgNode.toString());
                        tempPaths.add(json.getString("fileId"));
                        String urls = "";
                        for (String image : tempPaths) {
                            if (urls.length() == 0) {
                                urls = image;
                            } else {
                                urls += "," + image;
                            }
                        }
                        fileUrl = fastdfs_file_url + urls;
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else {
                    try {
                        UploadVO uploadVO = fileUploadService.request(request, ipt, "png");
                        if (uploadVO!=null){
                            fileUrl = uploadVO.getFullUrl();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                //更新到康复计划居民关系表中
                String sql = "update wlyy_patient_rehabilitation_plan set service_qr_code='" + fileUrl + "' where id='" + planId + "'";
                jdbcTemplate.update(sql);
            }
        }
        return MixEnvelop.getSuccess("获取二维码成功!",fileUrl);
    }
    public Integer checkAfterQrCode(String planId,String patietCode){
        int result = 0;
        PatientRehabilitationPlanDO patientRehabilitationPlanDO =  patientRehabilitationPlanDao.findById(planId);
        if (patientRehabilitationPlanDO!=null){
            if (StringUtils.pathEquals(patientRehabilitationPlanDO.getPatient(),patietCode)){
                result =200;
            }else {
                result = -1;
            }
        }else {
            result = -10000;
        }
        return result;
    }
}

+ 32 - 0
svr/svr-wlyy-specialist/src/main/resources/application.yml

@ -77,6 +77,14 @@ spring:
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
fast-dfs:
  tracker-server: 172.19.103.54:22122
  public-server: http://172.19.103.54:80/
neiwang:
  enable: true
  wlyy: http://localhost:10051/
---
spring:
  profiles: jwtest
@ -87,6 +95,14 @@ spring:
    password: ssgg
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
fast-dfs:
  tracker-server: 172.19.103.54:22122
  public-server: http://172.19.103.54:80/
neiwang:
  enable: false
  wlyy: http://59.61.92.90:10051/
---
spring:
  profiles: jwdevtest
@ -97,6 +113,14 @@ spring:
    password: linzhou
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
fast-dfs:
  tracker-server: 172.19.103.54:22122
  public-server: http://172.19.103.54:80/
neiwang:
  enable: true
  wlyy: http://172.19.103.88:10051/svr-slyy-specialist/
---
spring:
  profiles: prod
@ -106,3 +130,11 @@ spring:
    password: jkzlehr@123
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
fast-dfs:
  #tracker-server: 172.19.103.54:22122
  #public-server: http://172.19.103.54:80/
neiwang:
  enable: false
  #wlyy: http://59.61.92.90:9099/iot/

+ 17 - 1
svr/svr-wlyy-specialist/src/main/resources/bootstrap.yml

@ -21,4 +21,20 @@ spring:
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://172.17.110.212:1221}
      label: ${wlyy.spring.config.label:jwdev}
      label: ${wlyy.spring.config.label:jwdev}
---
spring:
  profiles: jwdevtest
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://172.17.110.212:1221}
      label: ${wlyy.spring.config.label:jwdev}
---
spring:
  profiles: prod
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://192.168.120.153:1221}
      label: ${wlyy.spring.config.label:prod}

+ 4 - 2
wlyy-parent-pom/pom.xml

@ -56,7 +56,7 @@
        <module>../server/svr-discovery</module><!--发现服务-->
        <!-- 暂时保留 -->
        <!--<module>../server/svr-dashboard</module>--><!--监控服务-->
        <!--<module>../server/svr-log-server</module>--><!--分布式追踪服务-->
        <module>../server/svr-zipkin</module> <!--分布式追踪服务-->
        <!-- 暂时保留 -->
        <!-- 网关服务 -->
@ -93,6 +93,8 @@
        <version.joda-time>2.8.2</version.joda-time>
        <version.yihu.admin>1.2.0</version.yihu.admin>
        <version.spring-boot-admin>1.5.7</version.spring-boot-admin>
        <version.zxing>3.2.0</version.zxing>
        <version.fastdfs>1.25</version.fastdfs>
        <!-- Version end -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -371,7 +373,7 @@
                <version>${asciidoctor.maven.plugin.version}</version>
                <configuration>
                    <sourceDirectory>build</sourceDirectory>
                    <outputDirectory>build/asciidoc/${project.version}</outputDirectory>
                    <outputDirectory>docs/${project.version}</outputDirectory>
                    <headerFooter>true</headerFooter>
                    <doctype>book</doctype>
                    <sourceHighlighter>coderay</sourceHighlighter>