liuwenbin 7 years ago
parent
commit
9f00b7af45
53 changed files with 2759 additions and 320 deletions
  1. 6 6
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  2. 2 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  3. 3 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/MvcConfig.java
  4. 3 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java
  5. 130 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/dict/DmExpressagePriceEntity.java
  6. 9 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/organization/Hospital.java
  7. 110 12
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java
  8. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionAdjust.java
  9. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionDiagnosis.java
  10. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionDispensaryCode.java
  11. 17 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionExpressage.java
  12. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionExpressageLog.java
  13. 185 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionInfo.java
  14. 36 12
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionLog.java
  15. 169 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionReviewed.java
  16. 51 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/wechat/WechatTag.java
  17. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/DmExpressagePriceDao.java
  18. 4 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/SystemDictDao.java
  19. 3 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorAdminTeamMemberDao.java
  20. 4 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionExpressageDao.java
  21. 25 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionExpressageLogDao.java
  22. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionLogDao.java
  23. 15 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionReviewedDao.java
  24. 24 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/wechat/WechatTagDao.java
  25. 20 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  26. 427 38
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/express/SFExpressService.java
  27. 28 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageLogService.java
  28. 149 14
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java
  29. 90 31
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  30. 119 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionNoticesService.java
  31. 2 18
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  32. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  33. 93 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  34. 31 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  35. 60 39
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SFUtils.java
  36. 21 15
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java
  37. 12 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionCodeController.java
  38. 52 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionExpressageController.java
  39. 45 49
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java
  40. 45 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionLogController.java
  41. 57 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionNoticesController.java
  42. 14 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java
  43. 49 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/express/SFExpressApiController.java
  44. 84 54
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/express/SFExpressController.java
  45. 4 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionInfoController.java
  46. 14 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionLogController.java
  47. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/PatientSignController.java
  48. 1 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatCoreController.java
  49. 119 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatMenuController.java
  50. 105 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatTagController.java
  51. 200 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/util/WeiXinTagUtil.java
  52. 0 0
      patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu.txt
  53. 92 0
      patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu_jimei.txt

+ 6 - 6
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -213,9 +213,10 @@ public class PrescriptionInfoService extends BaseService {
                " p.`name`, " +
                " TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
                " p.sex, " +
                " p.photo," +
                " pr.`status`, " +
                " pr.`code`, " +
                " pr.create_time AS createTime, " +
                " LEFT(pr.create_time,19) AS createTime, " +
                " pr.doctor " +
                " FROM " +
                " wlyy_prescription pr " +
@ -249,19 +250,18 @@ public class PrescriptionInfoService extends BaseService {
    public void setSQL(StringBuffer pre_sql,List<Object> params,String state,String startDate,String endDate,String nameKeyword){
        if(StringUtils.isNotBlank(state)){
            pre_sql.append(" AND pr.status = ?");
            params.add(state);
            pre_sql.append(" AND pr.status IN ("+state+")");
        }
        if(StringUtils.isNotBlank(startDate)){
            pre_sql.append(" AND pr.create_time >= ?");
            pre_sql.append(" AND pr.create_time >= ? ");
            params.add(startDate);
        }
        if(StringUtils.isNotBlank(endDate)){
            pre_sql.append(" AND pr.create_time <= ?");
            pre_sql.append(" AND pr.create_time <= ? ");
            params.add(endDate);
        }
        if(StringUtils.isNotBlank(nameKeyword)){
            pre_sql.append(" AND pr.patient_name like ?");
            pre_sql.append(" AND pr.patient_name like ? ");
            params.add("%"+nameKeyword+"%");
        }
        pre_sql.append(" GROUP BY pr.code ORDER BY pr.create_time DESC");

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

@ -581,6 +581,8 @@ public class DoctorController extends BaseController {
                json.put("provinceName", temp.getProvinceName());
                // 设置城市名称
                json.put("cityName", temp.getCityName());
                // 设置医院code
                json.put("hospital", temp.getHospital());
                // 设置医院名称
                json.put("hospitalName", temp.getHospitalName());
                // 设置部门名称

+ 3 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/MvcConfig.java

@ -31,9 +31,9 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**","/statistics/province/**","/statistics/**");
        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**");
        registry.addInterceptor(userInterceptor).addPathPatterns("/user/**");
//        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**","/statistics/province/**","/statistics/**");
//        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**");
//        registry.addInterceptor(userInterceptor).addPathPatterns("/user/**");
        super.addInterceptors(registry);
    }

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

@ -101,7 +101,9 @@ public class SwaggerConfig {
                        regex("/login/.*"),
                        regex("/qrcode/.*"),
                        regex("/onepay/.*"),
                        regex("/wlyy_service/.*")
                        regex("/wlyy_service/.*"),
                        regex("/wlyy_service/.*"),
                        regex("/wechat/.*")
                ))
                .build()
                .apiInfo(otherApiInfo());

+ 130 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/dict/DmExpressagePriceEntity.java

@ -0,0 +1,130 @@
package com.yihu.wlyy.entity.dict;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 快递价目表
 */
@Entity
@Table(name = "dm_expressage_price", schema = "wlyy", catalog = "")
public class DmExpressagePriceEntity extends IdEntity {
    private String code;
    private String startAddressName;
    private String endAddressName;
    private Integer firstWeight;
    private Integer firstWeightPrice;
    private Integer continueWeight;
    private Integer continueWeightPrice;
    @Basic
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Basic
    @Column(name = "start_address_name")
    public String getStartAddressName() {
        return startAddressName;
    }
    public void setStartAddressName(String startAddressName) {
        this.startAddressName = startAddressName;
    }
    @Basic
    @Column(name = "end_address_name")
    public String getEndAddressName() {
        return endAddressName;
    }
    public void setEndAddressName(String endAddressName) {
        this.endAddressName = endAddressName;
    }
    @Basic
    @Column(name = "first_weight")
    public Integer getFirstWeight() {
        return firstWeight;
    }
    public void setFirstWeight(Integer firstWeight) {
        this.firstWeight = firstWeight;
    }
    @Basic
    @Column(name = "first_weight_price")
    public Integer getFirstWeightPrice() {
        return firstWeightPrice;
    }
    public void setFirstWeightPrice(Integer firstWeightPrice) {
        this.firstWeightPrice = firstWeightPrice;
    }
    @Basic
    @Column(name = "continue_weight")
    public Integer getContinueWeight() {
        return continueWeight;
    }
    public void setContinueWeight(Integer continueWeight) {
        this.continueWeight = continueWeight;
    }
    @Basic
    @Column(name = "continue_weight_price")
    public Integer getContinueWeightPrice() {
        return continueWeightPrice;
    }
    public void setContinueWeightPrice(Integer continueWeightPrice) {
        this.continueWeightPrice = continueWeightPrice;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        DmExpressagePriceEntity that = (DmExpressagePriceEntity) o;
        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (code != null ? !code.equals(that.code) : that.code != null) return false;
        if (startAddressName != null ? !startAddressName.equals(that.startAddressName) : that.startAddressName != null)
            return false;
        if (endAddressName != null ? !endAddressName.equals(that.endAddressName) : that.endAddressName != null)
            return false;
        if (firstWeight != null ? !firstWeight.equals(that.firstWeight) : that.firstWeight != null) return false;
        if (firstWeightPrice != null ? !firstWeightPrice.equals(that.firstWeightPrice) : that.firstWeightPrice != null)
            return false;
        if (continueWeight != null ? !continueWeight.equals(that.continueWeight) : that.continueWeight != null)
            return false;
        if (continueWeightPrice != null ? !continueWeightPrice.equals(that.continueWeightPrice) : that.continueWeightPrice != null)
            return false;
        return true;
    }
    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (code != null ? code.hashCode() : 0);
        result = 31 * result + (startAddressName != null ? startAddressName.hashCode() : 0);
        result = 31 * result + (endAddressName != null ? endAddressName.hashCode() : 0);
        result = 31 * result + (firstWeight != null ? firstWeight.hashCode() : 0);
        result = 31 * result + (firstWeightPrice != null ? firstWeightPrice.hashCode() : 0);
        result = 31 * result + (continueWeight != null ? continueWeight.hashCode() : 0);
        result = 31 * result + (continueWeightPrice != null ? continueWeightPrice.hashCode() : 0);
        return result;
    }
}

+ 9 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/organization/Hospital.java

@ -31,6 +31,7 @@ public class Hospital extends IdEntity {
	private String photo;           //医院图片
	private String roadCode;        //街道编码
	private String centerSite;      //中心/站点
	private String phone;			//联系电话
	public String getDel() {
		return del;
@ -153,4 +154,12 @@ public class Hospital extends IdEntity {
	public void setCenterSite(String centerSite) {
		this.centerSite = centerSite;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
}

+ 110 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java

@ -2,10 +2,12 @@ package com.yihu.wlyy.entity.patient.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import org.springframework.util.StringUtils;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
@ -20,7 +22,7 @@ public class Prescription extends IdEntity {
    private String jwCode;                  //基卫的处方code
    private String parentCode;             //如果是续方 那就是处方的code
    private Date createTime;               //处方创建时间
    private Date reviewedTime;             //过期时间
    private Date reviewedTime;             //审核时间
    private Date payTime;                   //支付时间
    private Date dosageTime;                //配药完成时间
    private Date dispatchingTime;          //配送员领药时间
@ -28,7 +30,7 @@ public class Prescription extends IdEntity {
    private String patient;                  //关联 wlyy_patient code
    private String patientName;             //患者名称
    private Integer type;                    //1 处方 2 续方
    private Integer status;                  //状态 (-1 审核不通过 , 0 审核中, 10 审核通过/待支付 ,21支付失败  20 配药中/支付成功, 21 等待领药 ,30 配送中 ,100配送成功/已完成)
    private Integer status;                  //状态 (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败  42配送中   43配送到服务站  100配送到患者手中/已完成)
    private String doctor;                   //开处方的医生code 关联 wlyy_doctor
    private String doctorName;               //医生名称
    private Long adminTeamId;             //患者签约的行政团队
@ -48,11 +50,14 @@ public class Prescription extends IdEntity {
    private String caMessage;                   //ca指纹信息
    private String remark;                     //处方备注
    private String reason;                      //续方原因
    private String reviewedReason; //审核不通过的原因
//    private Double ybCost;                      //医保费用
    //    private Double ybCost;                      //医保费用
//    private Double myCost;                      //自己付费
    private Integer prescriptionType;          //处方类型:1、门诊处方,2、住院处方
    private String statusName; //
    @Column(name = "code", unique = true, nullable = false)
    public String getCode() {
        return code;
@ -310,14 +315,6 @@ public class Prescription extends IdEntity {
        this.caCertData = caCertData;
    }
    public String getReviewedReason() {
        return reviewedReason;
    }
    public void setReviewedReason(String reviewedReason) {
        this.reviewedReason = reviewedReason;
    }
    public Integer getPrescriptionType() {
        return prescriptionType;
    }
@ -325,4 +322,105 @@ public class Prescription extends IdEntity {
    public void setPrescriptionType(Integer prescriptionType) {
        this.prescriptionType = prescriptionType;
    }
    @Transient
    public String getTypeName() {
        switch (type) {
            case 1: {
                return "自取";
            }
            case 2: {
                return "快递配送";
            }
            case 3: {
                return "健管师配送";
            }
        }
        return "";
    }
    @Transient
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = getStatusName(status,null);
    }
    @Transient
    public static String getStatusName(Integer status, String hospitalName) {
        /**
         *  no_reviewed("审核不通过", -1),
         revieweding("待审核", 0),
         changeing("调整中",2),
         reviewed_success("审核通过/开方中", 10),
         wait_pay("开方完成/待支付", 20),
         pay_error("支付失败", 21),
         pay_success("支付成功/待配药", 30),
         wait_expressage("配药成功/待配送", 40),
         expressageing_error("配送失败", 41),
         expressageJGS("分配健管师", 42),
         expressageing("配送中", 45),
         expressage2hospital("配送到服务站", 49),
         finish("配送到患者手中/已完成", 100);
         */
        //-1 审核不通过 , 0 审核中, 10 审核通过/待支付 ,21支付失败  20 配药中/支付成功, 21 等待领药 ,30 配送中 ,100配送成功/已完成
        switch (status) {
            case -3: {
                return "支付超时";
            }
            case -2: {
                return "患者自己取消";
            }
            case -1: {
                return "审核不通过";
            }
            case 0: {
                return "待审核";
            }
            case 2: {
                return "调整处方中";
            }
            case 10: {
                return "开方中";
            }
            case 20: {
                return "开方完成";
            }
            case 21: {
                return "支付失败";
            }
            case 30: {
                return "订单已支付";
            }
            case 40: {
                return "配药完成";
            }
            case 41: {
                return "配送失败";
            }
            case 42: {
                return "分配健管师配送";
            }
            case 45: {
                return "配送中";
            }
            case 49: {
                if (StringUtils.isEmpty(hospitalName)) {
                    return "配送到服务站";
                }
                {
                    return "配送到" + hospitalName;
                }
            }
            case 100: {
                return "续方完成";
            }
        }
        return "未知";
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionAdjust.java

@ -10,7 +10,7 @@ import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
 * 处方
 * 处方调整记录表
 */
@Entity
@Table(name = "wlyy_prescription_adjust")

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionDiagnosis.java

@ -9,6 +9,7 @@ import java.util.Date;
/**
 * Created by Trick on 2017/7/28.
 * 处方诊断表
 */
@Entity
@Table(name = "wlyy_prescription_diagnosis")

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionDispensaryCode.java

@ -10,7 +10,7 @@ import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
 * 处方取码
 * 处方编码表
 */
@Entity
@Table(name = "wlyy_prescription_dispensary_code")

+ 17 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionExpressage.java

@ -37,9 +37,11 @@ public class PrescriptionExpressage extends IdEntity{
    private String expressageName;          //配送人名称
    private String expressageCode;          //配送人code
    private String expressageMobile;        //配送人电话
    private String hospitalName;            //如果配送方式是健管师那么这个字段存服务站名称,如果是快递配送那么是快递公司名称
    private String hospitalName;            // 如果配送方式是健管师那么这个字段存服务站名称,如果是快递配送那么是快递公司名称
    private String hospitalAddress;            // 机构地址
    private Date createTime;                //创建的时间
    private Integer oneselfPickupFlg;//是否自取 1是 0否
    private Integer del;    //1可用 0删除
@ -225,5 +227,19 @@ public class PrescriptionExpressage extends IdEntity{
        this.weight = weight;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getHospitalAddress() {
        return hospitalAddress;
    }
    public void setHospitalAddress(String hospitalAddress) {
        this.hospitalAddress = hospitalAddress;
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionExpressageLog.java

@ -10,7 +10,7 @@ import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
 * 处方配送
 * 处方配送流程表
 */
@Entity
@Table(name = "wlyy_prescription_expressage_log")

+ 185 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionInfo.java

@ -1,12 +1,10 @@
package com.yihu.wlyy.entity.patient.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
@ -25,8 +23,28 @@ public class PrescriptionInfo extends IdEntity{
    private Integer num;                    //药品数目
    private Integer isRefrigerate;         //是否冷藏 1是 0否
    private String direction;               //药品用法
    private Double price;                    //药品价格
    private Double price;                    //药品单价
    private Integer del;               //1可用 0删除 不填数据库默认是1
    private String jwSubCode;//智业子处方号
    private String drugNumUnit;//数量单位编码
    private String drugNumUnitName;//数量单位名称
    private Double cost;//金额
    private String charge;//自付
    private String bindFlag;//成组标志, 0.非成组,1.成组
    private Integer dayCount;//用药天数
    private String drugUsage;//用药方法编码
    private String usageName;//用药方法名称
    private String physicDose;//用药剂量
    private String physicDoseUnit;//剂量单位编码
    private String physicDoseUnitName;//剂量单位名称
    private String physicAmount;//用药总量
    private String physicAmountUnit;//总量单位编码
    private String physicAmountUnitName;//总量单位名称
    private String physicInjectPlace;//注射地点编码
    private String physicInjectPlaceName;//注射地点名称
    private String physicSkinTest;//注射地点名称
    private String physicSkinTestName;//皮试类型名称
    private String remark;//备注
    @Column(name = "code",unique = true , nullable=false)
    public String getCode() {
@ -119,4 +137,168 @@ public class PrescriptionInfo extends IdEntity{
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getJwSubCode() {
        return jwSubCode;
    }
    public void setJwSubCode(String jwSubCode) {
        this.jwSubCode = jwSubCode;
    }
    public String getDrugNumUnit() {
        return drugNumUnit;
    }
    public void setDrugNumUnit(String drugNumUnit) {
        this.drugNumUnit = drugNumUnit;
    }
    public String getDrugNumUnitName() {
        return drugNumUnitName;
    }
    public void setDrugNumUnitName(String drugNumUnitName) {
        this.drugNumUnitName = drugNumUnitName;
    }
    public Double getCost() {
        return cost;
    }
    public void setCost(Double cost) {
        this.cost = cost;
    }
    public String getCharge() {
        return charge;
    }
    public void setCharge(String charge) {
        this.charge = charge;
    }
    @Column(name = "bind_flag")
    public String getBindFlag() {
        return bindFlag;
    }
    public void setBindFlag(String bindFlag) {
        this.bindFlag = bindFlag;
    }
    @Column(name = "day_count")
    public Integer getDayCount() {
        return dayCount;
    }
    public void setDayCount(Integer dayCount) {
        this.dayCount = dayCount;
    }
    public String getDrugUsage() {
        return drugUsage;
    }
    public void setDrugUsage(String drugUsage) {
        this.drugUsage = drugUsage;
    }
    @Column(name = "usage_name")
    public String getUsageName() {
        return usageName;
    }
    public void setUsageName(String usageName) {
        this.usageName = usageName;
    }
    @Column(name = "physic_dose")
    public String getPhysicDose() {
        return physicDose;
    }
    public void setPhysicDose(String physicDose) {
        this.physicDose = physicDose;
    }
    public String getPhysicDoseUnit() {
        return physicDoseUnit;
    }
    public void setPhysicDoseUnit(String physicDoseUnit) {
        this.physicDoseUnit = physicDoseUnit;
    }
    public String getPhysicDoseUnitName() {
        return physicDoseUnitName;
    }
    public void setPhysicDoseUnitName(String physicDoseUnitName) {
        this.physicDoseUnitName = physicDoseUnitName;
    }
    public String getPhysicAmount() {
        return physicAmount;
    }
    public void setPhysicAmount(String physicAmount) {
        this.physicAmount = physicAmount;
    }
    public String getPhysicAmountUnit() {
        return physicAmountUnit;
    }
    public void setPhysicAmountUnit(String physicAmountUnit) {
        this.physicAmountUnit = physicAmountUnit;
    }
    public String getPhysicAmountUnitName() {
        return physicAmountUnitName;
    }
    public void setPhysicAmountUnitName(String physicAmountUnitName) {
        this.physicAmountUnitName = physicAmountUnitName;
    }
    public String getPhysicInjectPlace() {
        return physicInjectPlace;
    }
    public void setPhysicInjectPlace(String physicInjectPlace) {
        this.physicInjectPlace = physicInjectPlace;
    }
    public String getPhysicInjectPlaceName() {
        return physicInjectPlaceName;
    }
    public void setPhysicInjectPlaceName(String physicInjectPlaceName) {
        this.physicInjectPlaceName = physicInjectPlaceName;
    }
    public String getPhysicSkinTest() {
        return physicSkinTest;
    }
    public void setPhysicSkinTest(String physicSkinTest) {
        this.physicSkinTest = physicSkinTest;
    }
    public String getPhysicSkinTestName() {
        return physicSkinTestName;
    }
    public void setPhysicSkinTestName(String physicSkinTestName) {
        this.physicSkinTestName = physicSkinTestName;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

+ 36 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionLog.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
@ -22,7 +23,8 @@ public class PrescriptionLog extends IdEntity {
        reviewed("审核", 4),
        pay("支付", 5),
        expressage("配送", 6),
        finish("已完成", 7);
        finish("已完成", 7),
        sf("顺丰对接", 8);
        private String name;
        private int value;
@ -48,17 +50,26 @@ public class PrescriptionLog extends IdEntity {
        }
    }
    //状态枚举
    public enum PrescriptionLogStatus {
        pay_outtime("支付超时", -3),
        patient_canel("患者自己取消", -2),
        no_reviewed("审核不通过", -1),
        revieweding("审核中", 0),
        reviewed_success("审核通过/待支付", 10),
        pay_error("支付成功/配药中", 20),
        pay_success("支付失败", 21),
        wait_expressage("配药成功/等待领药", 30),
        expressageing("配送中", 31),
        expressageing_error("配送失败", 32),
        finish("结束", 100);
        revieweding("待审核", 0),
        changeing("调整中", 2),
        reviewed_success("审核通过/开方中", 10),
        wait_pay("开方完成/待支付", 20),
        pay_error("支付失败", 21),
        pay_success("支付成功/待配药", 30),
        wait_expressage("配药成功/待配送", 40),
        expressageing_error("配送失败", 41),
        expressageJGS("分配健管师", 42),
        expressageing("配送中", 45),
        expressage2hospital("配送到服务站", 49),
        finish("配送到患者手中/已完成", 100);
        private String name;
        private int value;
@ -88,15 +99,18 @@ public class PrescriptionLog extends IdEntity {
    private String code;                    //业务流程
    private String prescriptionCode;      //处方code 关联表wlyy_prescription code
    private Date createTime;               //处方创建时间
    private Integer status;                  //状态 (-1 审核不通过 , 0 审核中, 10 审核通过/待支付 ,20 配药中/支付成功  , 21支付失败  , 30 配药成功/等待领药 ,31 配送中 32 配送失败,100配送成功/已完成)
    private Integer status;                 //状态 (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成)
    private Integer type;                   //类型: 1智业对接 2易联众对接  3创建处方 4 审核  5付款 6 配送 7完成
    private String userCode;                  //医生或者患者code
    private String userName;                  //医生或者患者name
    private Integer userType;                 //1 患者 2医生
    private Integer flag;                      //操作是否成功 1成功 0失败
    private String remark;                     //备注信息
    private String hospital;//医院code
    private String hospitalName;//医院名称
    private String hospital;                //医院code
    private String hospitalName;            //医院名称
    private String statusName;  //状态名称
    @Column(name = "code")
    public String getCode() {
@ -203,4 +217,14 @@ public class PrescriptionLog extends IdEntity {
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Transient
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = Prescription.getStatusName(this.status,hospitalName);
    }
}

+ 169 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionReviewed.java

@ -0,0 +1,169 @@
package com.yihu.wlyy.entity.patient.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
 * 处方日志
 */
@Entity
@Table(name = "wlyy_prescription_reviewed")
public class PrescriptionReviewed extends IdEntity {
    //状态枚举
    public enum PrescriptionReviewedStatus {
        del("删除", -2),
        reviewed_fail("审核失败", -1),
        reviewed_wait("待审核", 0),
        reviewed_success("审核成功", 1);
        private String name;
        private int value;
        PrescriptionReviewedStatus(String name, int value) {
            this.name = name;
            this.value = value;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public int getValue() {
            return value;
        }
        public void setValue(int value) {
            this.value = value;
        }
    }
    private String code;                    //业务流程
    private String prescriptionCode;      //处方code 关联表wlyy_prescription code
    private Date createTime;               //审核时间
    private String hospital;                  //医院 关联 dm_hospital code
    private String hospitalName;              //医院 关联 dm_hospital name
    private String dept;                       //科室code
    private String deptName;                   //科室名称
    private String doctor;                  //审核医生
    private String doctorName;                  //审核医生名称
    private Integer status;               //  1审核通过1 0待审核  -1  审核通过   -2无效审核
    private String reason;                  //审核不通过原因
    private String remark;                  //备注
    private Date reviewedTime;           //审核时间
    public Date getReviewedTime() {
        return reviewedTime;
    }
    public void setReviewedTime(Date reviewedTime) {
        this.reviewedTime = reviewedTime;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    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 getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getReason() {
        return reason;
    }
    public void setReason(String reason) {
        this.reason = reason;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

+ 51 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/wechat/WechatTag.java

@ -0,0 +1,51 @@
package com.yihu.wlyy.entity.wechat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by chenweida on 2017/8/4.
 */
@Entity
@Table(name = "wx_tag")
public class WechatTag extends IdEntity {
    private Integer tagId;
    private String tagName;
    private Date createTime;
    private Integer del;
    public Integer getTagId() {
        return tagId;
    }
    public void setTagId(Integer tagId) {
        this.tagId = tagId;
    }
    public String getTagName() {
        return tagName;
    }
    public void setTagName(String tagName) {
        this.tagName = tagName;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/DmExpressagePriceDao.java

@ -0,0 +1,19 @@
package com.yihu.wlyy.repository.dict;
import com.yihu.wlyy.entity.dict.DmExpressagePriceEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 快递费用
 * @author huangwenjie 2017.08.03
 */
public interface DmExpressagePriceDao extends
        PagingAndSortingRepository<DmExpressagePriceEntity, Long>,
        JpaSpecificationExecutor<DmExpressagePriceEntity> {
    @Query("from DmExpressagePriceEntity where code = ?1 and endAddressName LIKE ?2 ")
    DmExpressagePriceEntity getExprePriceEntityByCodeAndEndAdressName(String code,String end_address_name);
}

+ 4 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/SystemDictDao.java

@ -16,7 +16,10 @@ public interface SystemDictDao extends PagingAndSortingRepository<SystemDict, Lo
    List<SystemDict> findByDictName(String name);
    @Query("select s.value from SystemDict s where s.dictName=?1 and s.code =?2")
    String findByDictNameAndCode(String dictName,String code);
    String findByDictNameAndCode(String dictName, String code);
    @Query(" from SystemDict s where s.dictName=?1 and s.value =?2")
    SystemDict findByDictNameAndValue(String dictName, String value);
    @Query("select s from SystemDict s where s.value like ?1 ")
    List<SystemDict> findByLikeName(String name);

+ 3 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorAdminTeamMemberDao.java

@ -58,5 +58,7 @@ public interface DoctorAdminTeamMemberDao extends
    @Query("select m from AdminTeamMember m,SignFamily s where m.teamId = s.adminTeamId and s.status >0 and s.patient=?1 and m.doctorCode =?2")
    List<AdminTeamMember> findByAdminTeam(String patient,String doctorCode);
    @Query("SELECT d FROM AdminTeamMember m, AdminTeam t, Doctor d WHERE t.id = ?1 AND t.id = m.teamId " +
            "AND m.doctorCode = d.code AND t.available = true AND m.available = true AND d.level=3 ORDER BY d.level")
    List<Doctor> findJGSMembers(long teamId);
}

+ 4 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionExpressageDao.java

@ -10,6 +10,9 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 * Created by chenweida on 2017/7/27.
 */
public interface PrescriptionExpressageDao extends PagingAndSortingRepository<PrescriptionExpressage, Long>, JpaSpecificationExecutor<PrescriptionExpressage> {
    @Query("from PrescriptionExpressage p where p.prescriptionCode=?1")
    @Query("from PrescriptionExpressage p where p.prescriptionCode=?1 and p.del=1")
    PrescriptionExpressage findByPrescriptionPay(String prescriptionCode);
    @Query("from PrescriptionExpressage p where p.mailno=?1")
    PrescriptionExpressage findByPrescriptionExpressMailno(String mailno);
}

+ 25 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionExpressageLogDao.java

@ -0,0 +1,25 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressageLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * 处方物流配送详情
 * @author  huangwenjie 2017.08.03
 */
public interface PrescriptionExpressageLogDao extends
        PagingAndSortingRepository<PrescriptionExpressageLog, Long>,
        JpaSpecificationExecutor<PrescriptionExpressageLog> {
    /**
     * 根据处方号获取该处方的物流配送日志,按路由节点发生的时间倒序排序
     * @param prescriptionCode
     * @return
     */
    @Query("from PrescriptionExpressageLog p where p.prescriptionCode=?1 order by p.acceptTime desc")
    List<PrescriptionExpressageLog> findByPrescriptionCode(String prescriptionCode);
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionLogDao.java

@ -1,6 +1,5 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDispensaryCode;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
@ -12,6 +11,7 @@ import java.util.List;
 * Created by chenweida on 2017/7/27.
 */
public interface PrescriptionLogDao extends PagingAndSortingRepository<PrescriptionLog, Long>, JpaSpecificationExecutor<PrescriptionLog> {
    @Query("select l.status,l.createTime from PrescriptionLog l where l.prescriptionCode=?1 and l.type in ?2 order by createTime desc")
    List<PrescriptionLog> findPrescriptionLogsByPrescriptionCode(String prescriptionCode, Integer[] types);
}

+ 15 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionReviewedDao.java

@ -0,0 +1,15 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionReviewed;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2017/8/4.
 */
public interface PrescriptionReviewedDao extends PagingAndSortingRepository<PrescriptionReviewed, Long>, JpaSpecificationExecutor<PrescriptionReviewed> {
    @Query("select p from PrescriptionReviewed p where p.prescriptionCode=?1")
    PrescriptionReviewed findByPrescriptionCode(String prescriptionCode);
}

+ 24 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/wechat/WechatTagDao.java

@ -0,0 +1,24 @@
package com.yihu.wlyy.repository.wechat;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.url.CudUrl;
import com.yihu.wlyy.entity.wechat.WechatTag;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/8/4.
 */
public interface WechatTagDao extends PagingAndSortingRepository<WechatTag, Long>, JpaSpecificationExecutor<WechatTag> {
    @Query(" from WechatTag where tagName=? and del=1")
    WechatTag findByName(String name);
    @Query(" from WechatTag where tagId=? and del=1")
    WechatTag findByTagId(Integer tagId);
    @Query(" update WechatTag set del=0 where tagId=?1 ")
    @Modifying
    void deleteTag(Integer tagId);
}

+ 20 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -1041,6 +1041,26 @@ public class ConsultTeamService extends ConsultService {
        prescriptionInfo.setDrugFormat("2.5mg*80片/盒");//药品规格
        prescriptionInfo.setNum(10);//药品数目
        prescriptionInfo.setIsRefrigerate(0);//是否冷藏 1是 0否
        prescriptionInfo.setJwSubCode("");//智业子处方号
        prescriptionInfo.setDrugNumUnit("");//数量单位编码
        prescriptionInfo.setDrugNumUnitName("");//数量单位名称
        prescriptionInfo.setCost(1.00d);//金额
        prescriptionInfo.setCharge("");//自付
        prescriptionInfo.setBindFlag("0");//成组标志, 0.非成组,1.成组
        prescriptionInfo.setDayCount(2);//用药天数
        prescriptionInfo.setDrugUsage("");//用药方法编码
        prescriptionInfo.setUsageName("");//用药方法名称
        prescriptionInfo.setPhysicDose("");//用药剂量
        prescriptionInfo.setPhysicDoseUnit("");//剂量单位编码
        prescriptionInfo.setPhysicDoseUnitName("");//剂量单位名称
        prescriptionInfo.setPhysicAmount("");//用药总量
        prescriptionInfo.setPhysicAmountUnit("");//总量单位编码
        prescriptionInfo.setPhysicAmountUnitName("");//总量单位名称
        prescriptionInfo.setPhysicInjectPlace("");//注射地点编码
        prescriptionInfo.setPhysicInjectPlaceName("");//注射地点名称
        prescriptionInfo.setPhysicSkinTest("");//注射地点名称
        prescriptionInfo.setPhysicSkinTestName("");//皮试类型名称
        prescriptionInfo.setRemark("");//备注
        prescriptionInfoDao.save(prescriptionInfo);
        PrescriptionDiagnosis diagnosis = new PrescriptionDiagnosis();

+ 427 - 38
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/express/SFExpressService.java

@ -1,7 +1,19 @@
package com.yihu.wlyy.service.app.express;
import com.yihu.wlyy.entity.dict.DmExpressagePriceEntity;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressageLog;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.dict.DmExpressagePriceDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageLogDao;
import com.yihu.wlyy.repository.prescription.PrescriptionLogDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SFUtils;
import org.apache.commons.lang3.StringUtils;
@ -10,14 +22,18 @@ import org.apache.http.message.BasicNameValuePair;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.dom.DOMDocument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
/**
@ -44,10 +60,82 @@ public class SFExpressService extends BaseService {
    @Autowired
    private HttpClientUtil HttpClientUtil;
    @Autowired
    private SFUtils SFUtils;
    @Autowired
    private JpaTransactionManager transactionManager;
    @Autowired
    private PrescriptionLogDao prescriptionLogDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private DmExpressagePriceDao dmExpressagePriceDao;
    @Autowired
    private PrescriptionExpressageLogDao prescriptionExpressageLogDao;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private HospitalDao hospitalDao;
    /**
     * 组装请求参数,发送请求
     * @param xml
     * @return
     * @throws Exception
     */
    private String SFExpressPost(String xml)throws Exception{
        String verifyCode = SFUtils.verifyCodeSFXmlStr(xml,sf_check_word);
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("xml", xml));
        params.add(new BasicNameValuePair("verifyCode", verifyCode));
        String re = HttpClientUtil.post(sf_url, params, "UTF-8");
        return re;
    }
    /**
     * 校验返回的xml报文
     * @param responseXml
     * @param title
     */
    private void verificationResponXml(String responseXml,String title) throws Exception {
        String error = "";
        if (StringUtils.isBlank(responseXml)) {
            // 如果返回的XML报文为空,请求也算失败
            //保存http日志
            error = title + ",返回的XML为空!";
            logger.info(error);
            throw new Exception(error);
        }else{
//          报错的报文示例<Response service="ScopeService"><Head>ERR</Head><ERROR code="8014">校验码错误 </ERROR></Response>
            Document doc = DocumentHelper.parseText(responseXml);
            String headvalue = doc.selectSingleNode("/Response/Head").getText();
            if(StringUtils.isNotBlank(headvalue) && "ERR".equals(headvalue)){
                //错误代码
                String errorCode = "";
                //错误代对应的文字
                String errorMessage = doc.selectSingleNode("/Response/ERROR").getText();
                Document error_doc = doc.selectSingleNode("/Response/ERROR").getDocument();
                Element root = error_doc.getRootElement();
                List<?> child = root.elements();
                for (Object o : child){
                    Element e = (Element) o;
                    errorCode = e.attributeValue("code");
                }
                error = title+","+errorCode+","+errorMessage;
                logger.info(error);
                throw new Exception(error);
            }
        }
    }
    /**
     * 查询派送地址是否属于顺丰的派送范围
@ -95,10 +183,17 @@ public class SFExpressService extends BaseService {
     * @throws Exception
     */
    public PrescriptionExpressage postSFOrderService(PrescriptionExpressage sfexpress_obj) throws Exception {
        String xml = SFUtils.postSFOrderService(sfexpress_obj,sf_code);
        //获取医生所处的医院详细地址,作为寄件人地址
        Prescription prescription = prescriptionDao.findByCode(sfexpress_obj.getPrescriptionCode());
        Hospital hospital = hospitalDao.findByCode(prescription.getHospital());
        String xml = SFUtils.postSFOrderService(sfexpress_obj,hospital,sf_code);
        String re = this.SFExpressPost(xml);
        //xml验证
        verificationResponXml(re,"向顺丰快递下订单失败!");
        Document doc = DocumentHelper.parseText(re);
        String headvalue = doc.selectSingleNode("/Response/Head").getText();
        if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
@ -120,62 +215,356 @@ public class SFExpressService extends BaseService {
                logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getPrescriptionCode());
                throw new Exception("顺丰快递下订单失败:派送地址不可派送");
            }
            if(StringUtils.isBlank(mailno)){
                logger.info("顺丰快递下订单失败:未获取到快递单号!"+sfexpress_obj.getPrescriptionCode());
                throw new Exception("顺丰快递下订单失败:未获取到快递单号!");
            }
            sfexpress_obj.setMailno(mailno);
        }
        return sfexpress_obj;
    }
    /**
     * 组装请求参数,发送请求
     * 调用顺丰接口获取物流路由日志,与本地匹配,进行增量修改,并返回完整日志列表
     * @param prescription
     * @param sfexpress_obj
     * @param sfexpresslogList
     * @return
     */
    public List<PrescriptionExpressageLog> getRoutInfos(Prescription prescription, PrescriptionExpressage sfexpress_obj, List<PrescriptionExpressageLog> sfexpresslogList) throws Exception {
        String xml = SFUtils.getRoutInfos(sfexpress_obj,sf_code);
        String re = this.SFExpressPost(xml);
        //xml验证
        verificationResponXml(re,"查询顺丰快递路由信息失败!");
        Document doc = DocumentHelper.parseText(re);
        String headvalue = doc.selectSingleNode("/Response/Head").getText();
        if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
        }
        List<Document> redocs = doc.selectNodes("/Response/Body/RouteResponse");
        String mailno = "";
        for (Document routdoc : redocs) {
            Element root = routdoc.getRootElement();
            List<?> child = root.elements();
            for (Object o : child) {
                Element e = (Element) o;
                mailno = e.attributeValue("mailno");
                //判断快递单号不为空,且和我们本地的一致
                if(StringUtils.isNotBlank(mailno) &&
                        sfexpress_obj.getMailno().equals(mailno)){
                    //解析报文,结合本地数据返回最终的日志结果
                    return this.xmltologlist(e,sfexpresslogList,sfexpress_obj);
                }else{
                    continue;
                }
            }
        }
        return null;
    }
    private List<PrescriptionExpressageLog> xmltologlist(Element e, List<PrescriptionExpressageLog> sfexpresslogList, PrescriptionExpressage sfexpress_obj)throws Exception{
        //获取本地所有路由信息的时间集
        Set<String> routAcceptTimeSet = new HashSet<>();
        for (PrescriptionExpressageLog log: sfexpresslogList) {
            routAcceptTimeSet.add(DateUtil.dateToStrLong(log.getAcceptTime()));
        }
        List<?> child = e.elements();
        List<PrescriptionExpressageLog> newroutinfolist = new ArrayList<>();
        //用于判断新节点是否包含了"已收件"的节点
        boolean isContainEndRoutInfo = false;
        for (Object o : child) {
            Element routinfoe = (Element) o;
            String accept_time = routinfoe.attributeValue("accept_time");
            String accept_address = routinfoe.attributeValue("accept_address");
            String accept_remark = routinfoe.attributeValue("remark");
            String opcode = routinfoe.attributeValue("opcode");
            //和时间集作比对,过滤已存在的
            if(!routAcceptTimeSet.contains(accept_time)){
                PrescriptionExpressageLog newlogobj = new PrescriptionExpressageLog();
                newlogobj.setAcceptTime(DateUtil.strToDate(accept_time));
                newlogobj.setAcceptAddress(accept_address);
                newlogobj.setAcceptRemark(accept_remark);
                newlogobj.setOpCode(opcode);
                newlogobj.setCode(UUID.randomUUID().toString().replace("-",""));
                newlogobj.setPrescriptionCode(sfexpress_obj.getPrescriptionCode());
                newlogobj.setExpressageCode(sfexpress_obj.getExpressageCode());
                newlogobj.setCreateTime(new Date());
                newroutinfolist.add(newlogobj);
                sfexpresslogList.add(newlogobj);
                //accept_remark为"已收件",代表派送结束
                if("已收件".equals(accept_remark)){
                    isContainEndRoutInfo = true;
                }
            }
        }
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
        TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
        try {
            //如果有新增的路由信息,则添加到数据库
            if(!newroutinfolist.isEmpty()){
                prescriptionExpressageLogDao.save(newroutinfolist);
            }
            //如果路由信息节点包含了"已收件"节点,这修改处方派送状态为完成,增加物流派送日志为完成
            if(isContainEndRoutInfo){
                //修改处方状态为完成
                prescriptionDao.updateStatus(sfexpress_obj.getPrescriptionCode(), PrescriptionLog.PrescriptionLogStatus.finish.getValue());
                //保存配送成功的日志
                PrescriptionLog prescriptionLog = new PrescriptionLog();
                prescriptionLog.setPrescriptionCode(sfexpress_obj.getPrescriptionCode());
                prescriptionLog.setCode(UUID.randomUUID().toString());
                prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.sf.getValue());
                prescriptionLog.setCreateTime(new Date());
                prescriptionLog.setFlag(1);
                prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
                prescriptionLogDao.save(prescriptionLog);
            }
            //事务提交
            transactionManager.commit(status);
        } catch (Exception ex) {
            //报错事务回滚
            transactionManager.rollback(status);
        }
        return sfexpresslogList;
    }
    /**
     * 解析顺丰推送过来的路由信息,和本地数据匹配并进行增量更新)
     * @param xml
     * @return
     * @throws Exception
     */
    private String SFExpressPost(String xml)throws Exception{
        String verifyCode = SFUtils.verifyCodeSFXmlStr(xml,sf_check_word);
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("xml", xml));
        params.add(new BasicNameValuePair("verifyCode", verifyCode));
        String re = HttpClientUtil.post(sf_url, params, "UTF-8");
        return re;
    public void SFRoutePushService(String xml) throws Exception{
        Document doc = DocumentHelper.parseText(xml);
        Document bodydoc = doc.selectSingleNode("/Request/Body").getDocument();
        Element root = bodydoc.getRootElement();
        if (root.element("WaybillRoute") != null)     //包含WaybillRoute节点
        {
            root = root.element("WaybillRoute");
        }
        List<?> child = root.elements();
        Map<String,List<PrescriptionExpressageLog>> wayroutlsit = new HashMap<>();
        for (Object o : child) {
            Element routinfoe = (Element) o;
            PrescriptionExpressageLog sflog = new PrescriptionExpressageLog();
            String accept_time = routinfoe.attributeValue("acceptTime");
            String accept_address = routinfoe.attributeValue("acceptAddress");
            String accept_remark = routinfoe.attributeValue("remark");
            String opcode = routinfoe.attributeValue("opCode");
            String mailno = routinfoe.attributeValue("mailno");
            String orderid = routinfoe.attributeValue("orderid");
            sflog.setAcceptTime(DateUtil.strToDate(accept_time));
            sflog.setAcceptAddress(accept_address);
            sflog.setAcceptRemark(accept_remark);
            sflog.setOpCode(opcode);
            sflog.setExpressageCode(orderid);
            sflog.setCode(UUID.randomUUID().toString());
            if(wayroutlsit.keySet().contains(mailno)){
                wayroutlsit.get(mailno).add(sflog);
            }else{
                List<PrescriptionExpressageLog> newsflogs = new ArrayList<>();
                newsflogs.add(sflog);
                wayroutlsit.put(mailno,newsflogs);
            }
        }
        if(!wayroutlsit.keySet().isEmpty()){
            for (String mailno:wayroutlsit.keySet()) {
                List<PrescriptionExpressageLog> pushSFLogs = wayroutlsit.get(mailno);
                //同一个快递单号的执行一个事务操作
                this.saveSFPushRoutInfos(mailno,pushSFLogs);
            }
        }
    }
    /**
     * 校验返回的xml报文
     * @param responseXml
     * @param title
     * 同一个快递单号的执行一个事务操作
     * @param mailno
     * @param pushSFLogs
     */
    private void verificationResponXml(String responseXml,String title) throws Exception {
        String error = "";
        if (StringUtils.isBlank(responseXml)) {
            // 如果返回的XML报文为空,请求也算失败
            //保存http日志
            error = title + ",返回的XML为空!";
            logger.info(error);
//            logService.saveHttpLog(isSuccess,url,content,method,null,msgBody,res,error,logService.archiveType);
            throw new Exception(error);
    public void saveSFPushRoutInfos(String mailno,List<PrescriptionExpressageLog> pushSFLogs){
        //根据快递单号获取处方配送详细信息
        PrescriptionExpressage sfexpress = prescriptionExpressageDao.findByPrescriptionExpressMailno(mailno);
        //根据快递单号获取本地的路由信息
        List<PrescriptionExpressageLog> localroutinfos = prescriptionExpressageLogDao.findByPrescriptionCode(sfexpress.getPrescriptionCode());
        //需要增量更新到本地的路由信息集合
        List<PrescriptionExpressageLog> newroutinfolist = new ArrayList<>();
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事务隔离级别,开启新事务
        TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
        try {
            //用于判断新节点是否包含了"已收件"的节点
            boolean isContainEndRoutInfo = false;
            //获取本地所有路由信息的时间集
            Set<String> routAcceptTimeSet = new HashSet<>();
            for (PrescriptionExpressageLog log: localroutinfos) {
                routAcceptTimeSet.add(DateUtil.dateToStrLong(log.getAcceptTime()));
            }
            for (PrescriptionExpressageLog pushlog: pushSFLogs) {
                //判断是否有已收件的路由节点
                if("已收件".equals(pushlog.getAcceptRemark())){
                    isContainEndRoutInfo = true;
                }
                if(routAcceptTimeSet.contains(DateUtil.dateToStrLong(pushlog.getAcceptTime()))){
                    continue;
                }else{
                    pushlog.setPrescriptionCode(sfexpress.getPrescriptionCode());
                    newroutinfolist.add(pushlog);
                }
            }
            //如果有新增的路由信息,则添加到数据库
            if(!newroutinfolist.isEmpty()){
                prescriptionExpressageLogDao.save(newroutinfolist);
            }
            //如果路由信息节点包含了"已收件"节点,则修改处方状态为完成,增加物流派送日志为完成
            if(isContainEndRoutInfo){
                //修改处方状态为完成
                prescriptionDao.updateStatus(sfexpress.getPrescriptionCode(), PrescriptionLog.PrescriptionLogStatus.finish.getValue());
                //保存配送成功的日志
                PrescriptionLog prescriptionLog = new PrescriptionLog();
                prescriptionLog.setPrescriptionCode(sfexpress.getPrescriptionCode());
                prescriptionLog.setCode(UUID.randomUUID().toString());
                prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.sf.getValue());
                prescriptionLog.setCreateTime(new Date());
                prescriptionLog.setFlag(1);
                prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
                prescriptionLogDao.save(prescriptionLog);
            }
            //事务提交
            transactionManager.commit(status);
        } catch (Exception ex) {
            //报错事务回滚
            transactionManager.rollback(status);
        }
    }
    /**
     * 根据收寄地址获取快递费用
     * @param d_province 省份名称
     * @param d_city     城市名称
     * @return
     */
    public DmExpressagePriceEntity getSFExpressPrice(String d_province, String d_city) throws Exception{
        String end_address_name = "";
        if("厦门市".equals(d_city)){
            end_address_name = "同城";
        }else{
//            <Response service="ScopeService"><Head>ERR</Head><ERROR code="8014">校验码错误 </ERROR></Response>
            Document doc = DocumentHelper.parseText(responseXml);
            if("福建省".equals(d_province)){
                end_address_name = "省内";
            }else{
                end_address_name = d_city;
            }
        }
        DmExpressagePriceEntity sfprice =  dmExpressagePriceDao.getExprePriceEntityByCodeAndEndAdressName("shunfeng",end_address_name);
        return sfprice;
    }
    /**
     * 根据处方快递订单号判断是否下单成功
     * 如果下单成功,保存处方物流记录,保存配送日志
     * @param sfexpress_obj
     * @return
     * @throws Exception
     */
    public boolean sfOrderSearchService(PrescriptionExpressage sfexpress_obj)  throws Exception{
        boolean go_on = false;
        String xml = SFUtils.sfOrderSearchService(sfexpress_obj.getCode(),sf_code);
        String re = this.SFExpressPost(xml);
        try {
            //xml验证
            verificationResponXml(re,"订单处理失败!");
            Document doc = DocumentHelper.parseText(re);
            String headvalue = doc.selectSingleNode("/Response/Head").getText();
            if(StringUtils.isNotBlank(headvalue) && "ERR".equals(headvalue)){
                //错误代码
                String errorCode = "";
            if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
                //是否能派送:1:人工确认;2:可收派;3:不可以收派
                String filter_result = "";
                String orderid = "";//业务订单号
                String mailno = "";//顺丰运单号
                //错误代对应的文字
                String errorMessage = doc.selectSingleNode("/Response/ERROR").getText();
                Document error_doc = doc.selectSingleNode("/Response/ERROR").getDocument();
                Element root = error_doc.getRootElement();
                Document redoc = doc.selectSingleNode("/Response/Body/Orderresponse").getDocument();
                Element root = redoc.getRootElement();
                List<?> child = root.elements();
                for (Object o : child){
                for (Object o : child) {
                    Element e = (Element) o;
                    errorCode = e.attributeValue("code");
                    filter_result = e.attributeValue("filter_result");
                    orderid = e.attributeValue("orderid");
                    mailno = e.attributeValue("mailno");
                }
                error = title+","+errorCode+","+errorMessage;
                logger.info(error);
                throw new Exception(error);
                if(StringUtils.isBlank(mailno)){
                    logger.info("顺丰快递下订单失败:未获取到快递单号!"+sfexpress_obj.getPrescriptionCode());
                    return true;
                }
                if(StringUtils.isNotBlank(filter_result) && "3".equals(filter_result)){
                    logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getPrescriptionCode());
                    return true;
                }
                sfexpress_obj.setMailno(mailno);
            }
            //如果成功获取到快递单号,则保存处方物流记录,保存配送日志
            //保存处方物流记录
            prescriptionExpressageDao.save(sfexpress_obj);
            //保存配送日志
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setPrescriptionCode(sfexpress_obj.getPrescriptionCode());
            prescriptionLog.setCode(UUID.randomUUID().toString());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.sf.getValue());
            prescriptionLog.setCreateTime(new Date());
            prescriptionLog.setFlag(1);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
            prescriptionLogDao.save(prescriptionLog);
        }catch (Exception ex){
            logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getPrescriptionCode());
            //如果订单处理失败,则可以继续下单
            go_on = true;
        }
    }
        return go_on;
    }
}

+ 28 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageLogService.java

@ -0,0 +1,28 @@
package com.yihu.wlyy.service.app.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressageLog;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageLogDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * 处方物流配送详情
 * @author  huangwenjie 2017.08.03
 */
@Service
public class PrescriptionExpressageLogService {
    @Autowired
    private PrescriptionExpressageLogDao prescriptionExpressageLogDao;
    /**
     * 根据处方号获取该处方的物流配送日志,按路由节点发生的时间倒序排序
     * @param prescriptionCode
     * @return
     */
    public List<PrescriptionExpressageLog> findByPrescriptionCode(String prescriptionCode){
        return prescriptionExpressageLogDao.findByPrescriptionCode(prescriptionCode);
    }
}

+ 149 - 14
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java

@ -42,12 +42,17 @@ public class PrescriptionExpressageService {
    /**
     * 确认配送成功
     *
     * @param code
     * @param code     编码code
     * @param userCode
     * @return 返回取药码或者配送码的类型  1 居民取药码 2 配送员(健管师)取药码 3 配送员(健管师)配送码
     * 前端根据这个类型去跳转
     */
    @Transactional
    public Integer expressage(String code, String userCode) throws Exception {
        Integer returnStatus = -1;
        //获取根据wlyy_prescription_dispensary_code的code处方编码
        PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(code);
        if (prescriptionDispensaryCode == null) {
            //保存配送失败的日志
            PrescriptionLog prescriptionLog = new PrescriptionLog();
@ -59,13 +64,12 @@ public class PrescriptionExpressageService {
            prescriptionLog.setUserCode(userCode);
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
            prescriptionLog.setRemark("配送失败,处方编码不存在");
            prescriptionLog.setRemark("编码不存在");
            prescriptionLogDao.save(prescriptionLog);
            return -1;
            return returnStatus;
        }
        //判断是否是取药码
        if (prescriptionDispensaryCode.getType() != 1||prescriptionDispensaryCode.getType() !=2) {
            //保存取药失败的日志
        if (prescriptionDispensaryCode.getIsUse() == 1) {
            //判断编码是否使用过
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setCode(UUID.randomUUID().toString());
            prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
@ -75,10 +79,54 @@ public class PrescriptionExpressageService {
            prescriptionLog.setUserCode(userCode);
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
            prescriptionLog.setRemark("配送失败,处方编码不是取药码");
            prescriptionLog.setRemark("编码重复扫描");
            prescriptionLogDao.save(prescriptionLog);
            return -1;
            returnStatus = -2;
            return returnStatus;
        }
        switch (prescriptionDispensaryCode.getType()) {
            case 1: {
                //判断是1 居民取药码
                returnStatus = dispensaryCode_1(userCode, prescriptionDispensaryCode);
                break;
            }
            case 2: {
                //判断是2 配送员(健管师)取药码
                returnStatus = dispensaryCode_2(userCode, prescriptionDispensaryCode);
                break;
            }
            case 3: {
                //判断是3 配送员(健管师)配送码
                returnStatus = dispensaryCode_3(userCode, prescriptionDispensaryCode);
                break;
            }
            default: {
                PrescriptionLog prescriptionLog = new PrescriptionLog();
                prescriptionLog.setCode(UUID.randomUUID().toString());
                prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
                prescriptionLog.setCreateTime(new Date());
                prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
                prescriptionLog.setFlag(1);
                prescriptionLog.setUserCode(userCode);
                prescriptionLog.setUserType(2);
                prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
                prescriptionLog.setRemark("编码类型错误");
                prescriptionLogDao.save(prescriptionLog);
                returnStatus = -3;
                return returnStatus;
            }
        }
        return returnStatus;
    }
    /**
     * 1 居民取药码 业务
     *
     * @param userCode
     * @param prescriptionDispensaryCode
     * @return
     */
    private Integer dispensaryCode_1(String userCode, PrescriptionDispensaryCode prescriptionDispensaryCode) {
        //修改处方状态为完成
        prescriptionDao.updateStatus(prescriptionDispensaryCode.getPrescriptionCode(), PrescriptionLog.PrescriptionLogStatus.finish.getValue());
@ -97,16 +145,73 @@ public class PrescriptionExpressageService {
        //修改取药码code为已经使用
        prescriptionDispensaryCode.setIsUse(1);
        return 1;
        return prescriptionDispensaryCode.getType();
    }
    /**
     * 配送员(健管师)取药码 业务
     *
     * @param userCode
     * @param prescriptionDispensaryCode
     * @return
     */
    private Integer dispensaryCode_2(String userCode, PrescriptionDispensaryCode prescriptionDispensaryCode) {
        //修改处方状态为配送中
        prescriptionDao.updateStatus(prescriptionDispensaryCode.getPrescriptionCode(), PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        //保存配送成功的日志
        PrescriptionLog prescriptionLog = new PrescriptionLog();
        prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
        prescriptionLog.setCode(UUID.randomUUID().toString());
        prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
        prescriptionLog.setCreateTime(new Date());
        prescriptionLog.setFlag(1);
        prescriptionLog.setUserCode(userCode);
        prescriptionLog.setUserType(2);
        prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        prescriptionLogDao.save(prescriptionLog);
        //修改取药码code为已经使用
        prescriptionDispensaryCode.setIsUse(1);
        return prescriptionDispensaryCode.getType();
    }
    /**
     * 配送员(健管师)配送码
     *
     * @param userCode
     * @param prescriptionDispensaryCode
     * @return
     */
    private Integer dispensaryCode_3(String userCode, PrescriptionDispensaryCode prescriptionDispensaryCode) {
        //修改处方状态为完成
        prescriptionDao.updateStatus(prescriptionDispensaryCode.getPrescriptionCode(), PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        //保存配送成功的日志
        PrescriptionLog prescriptionLog = new PrescriptionLog();
        prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
        prescriptionLog.setCode(UUID.randomUUID().toString());
        prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
        prescriptionLog.setCreateTime(new Date());
        prescriptionLog.setFlag(1);
        prescriptionLog.setUserCode(userCode);
        prescriptionLog.setUserType(2);
        prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue());
        prescriptionLogDao.save(prescriptionLog);
        //修改取药码code为已经使用
        prescriptionDispensaryCode.setIsUse(1);
        return prescriptionDispensaryCode.getType();
    }
    /**
     * 保存快递单号和增加处方物流记录为配送
     *
     * @param prescriptionExpressage
     * @param uid
     * @throws Exception
     */
    public void updatePrescriptionExpressage(PrescriptionExpressage prescriptionExpressage, String uid)throws Exception{
    public void updatePrescriptionExpressage(PrescriptionExpressage prescriptionExpressage) throws Exception {
        //保存处方物流记录
        prescriptionExpressageDao.save(prescriptionExpressage);
@ -114,12 +219,42 @@ public class PrescriptionExpressageService {
        PrescriptionLog prescriptionLog = new PrescriptionLog();
        prescriptionLog.setPrescriptionCode(prescriptionExpressage.getPrescriptionCode());
        prescriptionLog.setCode(UUID.randomUUID().toString());
        prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
        prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.sf.getValue());
        prescriptionLog.setCreateTime(new Date());
        prescriptionLog.setFlag(1);
        prescriptionLog.setUserCode(uid);
        prescriptionLog.setUserType(1);
        prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        prescriptionLogDao.save(prescriptionLog);
    }
    /**
     * 全科医生分配健管师
     *
     * @param code             健管师code
     * @param name             健管师名称
     * @param mobile           健管师联系电话
     * @param prescriptionCode 处方code
     * @param doctorQK         分配的全科
     */
    @Transactional
    public void updateExpressageJGS(String code, String name, String mobile, String prescriptionCode, String doctorQK) {
        //更新配送表 新增配送人员记录
        PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionPay(prescriptionCode);
        prescriptionExpressage.setExpressageCode(code);
        prescriptionExpressage.setExpressageMobile(mobile);
        prescriptionExpressage.setExpressageName(name);
        //新增日志
        PrescriptionLog prescriptionLog = new PrescriptionLog();
        prescriptionLog.setCode(UUID.randomUUID().toString());
        prescriptionLog.setCreateTime(new Date());
        prescriptionLog.setFlag(1);
        prescriptionLog.setPrescriptionCode(prescriptionCode);
        prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
        prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageJGS.getValue());
        prescriptionLog.setUserCode(doctorQK);
        prescriptionLog.setUserType(2);
        prescriptionLog.setRemark("团队长分配健管师配送");
        prescriptionLogDao.save(prescriptionLog);
    }
}

+ 90 - 31
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -5,20 +5,15 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionAdjust;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.PrescriptionAdjustDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.repository.prescription.PrescriptionLogDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
@ -53,6 +48,8 @@ public class PrescriptionInfoService extends BaseService {
    @Autowired
    private PrescriptionAdjustDao prescriptionAdjustDao;
    @Autowired
    private PrescriptionReviewedDao prescriptionReviewedDao;
    @Autowired
    private ImUtill imUtill;
    /**
@ -71,10 +68,15 @@ public class PrescriptionInfoService extends BaseService {
        List<SystemDict> states = systemDictDao.findByDictName("PRESCRIPTION_STATE");
        rs.put("states",states);
        List<Map<String,Object>> diseases = new ArrayList<>();
        Map<String,Object> dis = new HashMap<>();
        dis.put("1","糖尿病");
        dis.put("2","高血压");
        rs.put("diseases",dis);
        Map<String,Object> dis1 = new HashMap<>();
        dis1.put("code","1");
        dis1.put("name","高血压");
        Map<String,Object> dis2 = new HashMap<>();
        dis2.put("code","2");
        dis2.put("name","糖尿病");
        diseases.add(dis1);
        diseases.add(dis2);
        rs.put("diseases",diseases);
        return rs;
    }
@ -84,7 +86,7 @@ public class PrescriptionInfoService extends BaseService {
     * @param type
     * @return
     */
    public JSONArray getPrescriptionInfos(String type,String startDate,String endDate,String patient,String isRenewal){
    public JSONArray getPrescriptionInfos(String type,String startDate,String endDate,String patient,String isRenewal,Integer page,Integer size){
        if(StringUtils.isNotBlank(type)){
            if("1".equals(type)){
@ -106,6 +108,10 @@ public class PrescriptionInfoService extends BaseService {
                    sqlBuffer.append(" AND p.create_time <= ?");
                    params.add(endDate+" 23:59:59");
                }
                sqlBuffer.append(" ORDER BY p.create_time DESC ");
                if(page!=null&&page>0&&size!=null&&size>0){
                    sqlBuffer.append(" LIMIT "+(page-1)*size+","+size);
                }
                //本地库
                List<Map<String,Object>> rs =jdbcTemplate.queryForList(sqlBuffer.toString(),params.toArray());
                //通过缓存查找药品和疾病
@ -128,13 +134,23 @@ public class PrescriptionInfoService extends BaseService {
    public JSONObject getContinuedPrescription(String code){
        Prescription prescription = prescriptionDao.findByCode(code);
        List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
        PrescriptionReviewed reviewed =  prescriptionReviewedDao.findByPrescriptionCode(code);
        JSONObject rs = new JSONObject();
        rs.put("prescription",prescription);
        rs.put("prescriptionInfos",prescriptionInfos);
        rs.put("reviewed",reviewed);
        if(prescription!=null&&StringUtils.isNotBlank(prescription.getDoctor())){
            rs.put("doctor",doctorDao.findByCode(prescription.getDoctor()));
            Doctor doctor = doctorDao.findByCode(prescription.getDoctor());
            if(doctor.getCertifiedOvertime()!=null &&(new Date().before(doctor.getCertifiedOvertime()))){
                rs.put("isCertified",true);
                rs.put("doctorName",doctor.getName());
            }else{
                rs.put("isCertified",false);
                rs.put("doctorName",doctor.getName());
            }
        }else{
            rs.put("doctor","");
            rs.put("isCertified",false);
            rs.put("doctorName","");
        }
        return rs;
    }
@ -151,6 +167,7 @@ public class PrescriptionInfoService extends BaseService {
    public JSONObject  getPrescriptionProcess(String code){
        Prescription prescription = prescriptionDao.findByCode(code);
        List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
        PrescriptionReviewed reviewed =  prescriptionReviewedDao.findByPrescriptionCode(code);
        JSONObject rs = new JSONObject();
        if(prescription!=null&&StringUtils.isNotBlank(prescription.getPatient())){
            Patient p = patientDao.findByCode(prescription.getPatient());
@ -158,16 +175,18 @@ public class PrescriptionInfoService extends BaseService {
        }else{
            rs.put("patient","");
        }
        if(prescription.getStatus()==10){
            Long s = (prescription.getCreateTime().getTime()-new Date().getTime())/1000;
            rs.put("time",s);
            if(s>172800){
                prescription.setStatus(-3);
                prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue());
                prescriptionDao.save(prescription);
            }
        }else{
            rs.put("time","");
        }
        rs.put("reviewed",reviewed);
        rs.put("prescription",prescription);
        rs.put("prescriptionInfos",prescriptionInfos);
        return rs;
@ -180,12 +199,12 @@ public class PrescriptionInfoService extends BaseService {
     */
    public int cancelPrescriotion(String code){
        Prescription p = prescriptionDao.findByCode(code);
        p.setStatus(-2);
        p.setStatus(PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue());
        prescriptionDao.save(p);
        //患者操作日志
        PrescriptionLog log = new PrescriptionLog();
        log.setCode(getCode());
        log.setStatus(-2);
        log.setStatus(PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue());
        log.setType(-1);
        log.setCreateTime(new Date());
        log.setPrescriptionCode(p.getCode());
@ -208,14 +227,15 @@ public class PrescriptionInfoService extends BaseService {
    }
    public JSONArray getDoctorPrescription(Integer teamCode,String state,String diseases,String startDate,String endDate,String nameKeyword){
    public JSONArray getDoctorPrescription(Integer teamCode,String state,String diseases,String startDate,String endDate,String nameKeyword,String patient,Integer page,Integer size){
        StringBuffer pre_sql = new StringBuffer("SELECT " +
                " p.`name`, " +
                " TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
                " p.sex, " +
                " p.photo, " +
                " pr.`status`, " +
                " pr.`code`, " +
                " pr.create_time AS createTime, " +
                " LEFT(pr.create_time,19) AS createTime, " +
                " pr.doctor " +
                " FROM " +
                " wlyy_prescription pr " +
@ -229,12 +249,12 @@ public class PrescriptionInfoService extends BaseService {
                    " AND pr.admin_team_id =? AND s.code = ?");
            params.add(teamCode);
            params.add(diseases);
            setSQL(pre_sql,params,state,startDate,endDate,nameKeyword);
            setSQL(pre_sql,params,state,startDate,endDate,nameKeyword,patient,page,size);
        }else{
            //查询所有疾病类型表
            pre_sql.append(" WHERE pr.admin_team_id =?");
            params.add(teamCode);
            setSQL(pre_sql,params,state,startDate,endDate,nameKeyword);
            setSQL(pre_sql,params,state,startDate,endDate,nameKeyword,patient,page,size);
        }
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(pre_sql.toString(),params.toArray());
@ -247,24 +267,30 @@ public class PrescriptionInfoService extends BaseService {
        return new JSONArray(rs);
    }
    public void setSQL(StringBuffer pre_sql,List<Object> params,String state,String startDate,String endDate,String nameKeyword){
    public void setSQL(StringBuffer pre_sql,List<Object> params,String state,String startDate,String endDate,String nameKeyword,String patient,Integer page,Integer size){
        if(StringUtils.isNotBlank(state)){
            pre_sql.append(" AND pr.status = ?");
            params.add(state);
            pre_sql.append(" AND pr.status IN ("+state+") ");
        }
        if(StringUtils.isNotBlank(startDate)){
            pre_sql.append(" AND pr.create_time >= ?");
            pre_sql.append(" AND pr.create_time >= ? ");
            params.add(startDate);
        }
        if(StringUtils.isNotBlank(endDate)){
            pre_sql.append(" AND pr.create_time <= ?");
            pre_sql.append(" AND pr.create_time <= ? ");
            params.add(endDate);
        }
        if(StringUtils.isNotBlank(nameKeyword)){
            pre_sql.append(" AND pr.patient_name like ?");
            pre_sql.append(" AND pr.patient_name like ? ");
            params.add("%"+nameKeyword+"%");
        }
        if(StringUtils.isNotBlank(patient)){
            pre_sql.append(" AND pr.patient = ?");
            params.add(patient);
        }
        pre_sql.append(" GROUP BY pr.code ORDER BY pr.create_time DESC");
        if(page!=null&&page>0&&size!=null&&size>0){
            pre_sql.append(" LIMIT "+(page-1)*size+","+size);
        }
    }
    /**
@ -275,30 +301,56 @@ public class PrescriptionInfoService extends BaseService {
    public JSONObject getContinuedPrescriptionAsDoctor(String code){
        Prescription prescription = prescriptionDao.findByCode(code);
        List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
        PrescriptionReviewed reviewed  = prescriptionReviewedDao.findByPrescriptionCode(code);
        JSONObject rs = new JSONObject();
        rs.put("prescription",prescription);
        rs.put("prescriptionInfos",prescriptionInfos);
        rs.put("reviewed",reviewed);
        if(prescription!=null&&StringUtils.isNotBlank(prescription.getDoctor())){
            rs.put("doctor",doctorDao.findByCode(prescription.getDoctor()));
        }else{
            rs.put("doctor","");
        }
        if(prescription!=null&&StringUtils.isNotBlank(prescription.getPatient())){
            rs.put("patient",patientDao.findByCode(prescription.getPatient()));
        }else{
            rs.put("patient","");
        }
        return rs;
    }
    public int reviewPrescription(String code ,String reason,String state){
        if(StringUtils.isNotBlank(state)){
            Prescription p = prescriptionDao.findByCode(code);
           //更新审核记录
            PrescriptionReviewed reviewed = prescriptionReviewedDao.findByPrescriptionCode(code);
//            PrescriptionReviewed reviewed = new PrescriptionReviewed();
//            reviewed.setCode(getCode());
//            reviewed.setPrescriptionCode(code);
//            reviewed.setCreateTime(new Date());
//            reviewed.setRemark("医生审核");
//            reviewed.setDoctor(p.getDoctor());
//            reviewed.setDoctorName(p.getDoctorName());
//            reviewed.setHospital(p.getHospital());
//            reviewed.setHospitalName(p.getHospitalName());
//            reviewed.setDept(p.getDept());
//            reviewed.setDeptName(p.getDeptName());
            if("1".equals(state)){
                //审核通过
                p.setStatus(10);
                p.setStatus(PrescriptionLog.PrescriptionLogStatus.reviewed_success.getValue());
                p.setReviewedTime(new Date());
                reviewed.setReviewedTime(new Date());
                reviewed.setStatus(PrescriptionReviewed.PrescriptionReviewedStatus.reviewed_success.getValue());
            }else{
                //审核不通过
                p.setStatus(-1);
                p.setReviewedReason(reason);
                p.setStatus(PrescriptionLog.PrescriptionLogStatus.no_reviewed.getValue());
                p.setReviewedTime(new Date());
                reviewed.setReason(reason);
                reviewed.setReviewedTime(new Date());
                reviewed.setStatus(PrescriptionReviewed.PrescriptionReviewedStatus.del.getValue());
            }
            prescriptionReviewedDao.save(reviewed);
            prescriptionDao.save(p);
            //医生操作日志
@ -397,4 +449,11 @@ public class PrescriptionInfoService extends BaseService {
    public String upload(){
     return null;
    }
    public JSONArray getDrugTimes(){
        List<SystemDict> list = systemDictDao.findByLikeName("%PRES_DRUG_TIME_%");
        return new JSONArray(list);
    }
}

+ 119 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionNoticesService.java

@ -0,0 +1,119 @@
package com.yihu.wlyy.service.app.prescription;
import antlr.StringUtils;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.task.PushMsgTask;
import com.ylzinfo.onepay.sdk.utils.StringUtil;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * Created by Reece on 2017/8/3.
 */
@Service
public class PrescriptionNoticesService extends BaseService {
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private PatientDao patientDao;
    /**
     * 发送续方相关模板消息
     *
     * @param accessToken
     * @param doctor      医生code
     * @param patient     居民code
     * @param type        1:续方审核通知 2:取药代办通知 3:配送中信息变更 4:已完成服务结果
     * @param status      续方通知状态 0不通过 1通过 2调整处方  其余状态均为0
     */
    public void sendMessages(String accessToken, String doctor, String patient, String checkDoctor,String ordenTime,int type, int status) throws Exception{
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Doctor doct = doctorDao.findByCode(doctor);
        Patient people = patientDao.findByCode(patient);
        if (StringUtil.isEmpty(people.getOpenid())){
            return;
        }
        String doctName = doct.getName();
        String name = people.getName();
        String openId = people.getOpenid();
        JSONObject sendJson = new JSONObject();
        String first = "";
        String remark = "";
        if (type == 1) {
            switch (status) {
                case 0:
                    first =  name+ "您好,你的续方申请医生已审核。";
                    remark = "您可点击消息查看详情,修改续方信息后重新提交。";
                    sendJson.put("keyword1", "审核不通过");
                    sendJson.put("keyword2", doctName);
                    sendJson.put("first", first);
                    sendJson.put("remark", remark);
                    pushMsgTask.putWxMsg(accessToken, 19, openId, name, sendJson);
                    break;
                case 1:
                    first = name + "您好,你的续方申请医生已审核。";
                    remark = "您可点击消息查看详情并完成支付。";
                    sendJson.put("keyword1", "审核通过");
                    sendJson.put("keyword2", doctName);
                    sendJson.put("first", first);
                    sendJson.put("remark", remark);
                    pushMsgTask.putWxMsg(accessToken, 19, openId, name, sendJson);
                    break;
                case 2:
                    first = name + "您好,您的续方申请医生已修改处方清单并审核。";
                    remark = "您可点击消息查看详情并完成支付。";
                    sendJson.put("keyword1", "审核通过");
                    sendJson.put("keyword2", doctName);
                    sendJson.put("first", first);
                    sendJson.put("remark", remark);
                    pushMsgTask.putWxMsg(accessToken, 19, openId, name, sendJson);
                    break;
            }
        } else if (type == 2) {
            first =  name+ "您好,您的续方订单已完成配药,请尽快致社区医院取药。";
            remark = "";
            sendJson.put("keyword1", "续方订单取药");
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            pushMsgTask.putWxMsg(accessToken, 11, openId, name, sendJson);
        }
        if (type == 3) {
            first =  name+ "您好,您的续方订单配送员"+doctName+"已顺利取药,续方状态变更为配送中。";
            remark = "您可点击消息查看详情。";
            sendJson.put("keyword1", doctName);
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("keyword3", "续方状态");
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            pushMsgTask.putWxMsg(accessToken, 10, openId, name, sendJson);
        }
        if (type == 4) {
            first =  name+ ",您好!您的续方订单已成功配送。";
            remark = "感谢您的使用。";
            sendJson.put("keyword1", "续方申请");
            sendJson.put("keyword2", checkDoctor);//审核医生姓名
            sendJson.put("keyword3", ordenTime);//订单完成时间
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            pushMsgTask.putWxMsg(accessToken, 20, openId, name, sendJson);
        }
    }
}

+ 2 - 18
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -651,9 +651,8 @@ public class SignWebService extends BaseService {
     * @param signCode 签约code
     * @return
     */
    public List<JSONObject> getSignInfo(String signCode) {
    public JSONObject getSignInfo(String signCode) {
        List<JSONObject> jsonArray = new ArrayList<JSONObject>();
        // 直接查询签约缴费流水号 可能为空
        WlyyCharge charge = chargeDao.findByChargeRelation(signCode);
        //查询签约表数据
@ -725,22 +724,7 @@ public class SignWebService extends BaseService {
            String chargeCode = charge.getCode();
            jsonObject.put("chargeCode", chargeCode);
        }
        jsonArray.add(jsonObject);
        Collections.sort(jsonArray, new Comparator<JSONObject>() {
            @Override
            public int compare(JSONObject o1, JSONObject o2) {
                Date o1Date = (Date) o1.get("createTime");
                Date o2Date = (Date) o2.get("createTime");
                if (o1Date.before(o2Date)) {
                    return 1;
                } else if (o1Date.after(o2Date)) {
                    return -1;
                }
                return 0;
            }
        });
        return jsonArray;
        return jsonObject;
    }
    /**

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java

@ -494,4 +494,8 @@ public class AdminTeamService extends BaseService {
        result.put("members",doctors);
        return result;
    }
    public List<Doctor> getJGSMembers(long teamId) {
        return memberDao.findJGSMembers(teamId);
    }
}

+ 93 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -0,0 +1,93 @@
package com.yihu.wlyy.service.third.jw;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
 * 基位长处方接口
 * Created by yeshijie on 2017/8/3.
 */
@Service
public class JwPrescriptionService {
    //基卫服务地址
    @Value("${sign.check_upload}")
    private String jwUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    /**
     * 获取字典列表
     * @param dictName
     * @return
     * @throws Exception
     */
    public String getDictForI(String dictName) throws Exception{
        String url = jwUrl + "/third/prescription/getDictForI";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("dictName", dictName));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    public String getRecipeTemplate(String dictName) throws Exception{
        String url = jwUrl + "/third/prescription/getRecipeTemplate";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("dictName", dictName));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    public String getLastRecipe(String dictName) throws Exception{
        String url = jwUrl + "/third/prescription/getLastRecipe";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("dictName", dictName));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    public String saveRecipe(String dictName) throws Exception{
        String url = jwUrl + "/third/prescription/saveRecipe";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("dictName", dictName));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    public String getDispUnSettleFeeList(String dictName) throws Exception{
        String url = jwUrl + "/third/prescription/getDispUnSettleFeeList";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("dictName", dictName));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    public String executeSickSettle(String dictName) throws Exception{
        String url = jwUrl + "/third/prescription/executeSickSettle";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("dictName", dictName));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
}

+ 31 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -187,8 +187,8 @@ public class PushMsgTask {
    /**
     * 发送微信模板消息
     *
     * @param type 1:签约成功  2:签约失败  3:咨询回复通知  4:健康指导提醒  5:解约申请通知  6:预约挂号成功通知  7:预约取消通知 8 缴费提醒 9 健康教育  10 签约医生变更
     *             18 产检提醒和产检就诊提醒
     * @param type 1:签约成功  2:签约失败  3:咨询回复通知  4:健康指导提醒  5:解约申请通知  6:预约挂号成功通知  7:预约取消通知 8 缴费提醒 9 健康教育  10 签约医生变更(信息变更通知)
     *             18 产检提醒和产检就诊提醒 19:续方审核结果通知(0.不通过 1.通过 2。调整处方并通过) 20:服务结果通知 11.代办事项通知
     * @param json 当type==1||type==2时:{"first":"消息主题",”doctor":"医生code","doctorName":"医生名","date":"签约时间","content":"签约内容","remark":"消息备注"}
     *             type==3时:{"first":"消息主题","consult":"医生咨询编号","consultcontent":"咨询内容","replycontent":"回复内容","doctorName":"医生名","remark":"消息备注"}
     *             type==4时:{"first":"消息主题","date":"指导时间","orgName":"指导机构","doctorName":"指导医生名","content":"指导内容","remark":"消息备注"}
@ -199,6 +199,9 @@ public class PushMsgTask {
     *             type==10时:{"first":"消息主题","name":"患教标题","doctorName":"医生名","date":"发送时间","remark":"消息备注"}
     *             <p>
     *             type==11时:{"first":"消息主题","name":"患教标题","doctorName":"医生名","date":"发送时间","remark":"消息备注"}
     *             type==19时:{"first":"消息主题","keyword1":"审核结果","keyword2":"审核医生","remark":"消息备注"}
     *             type==20时:{"first":"消息主题","keyword1":"服务项目","keyword2":"操作医生","keyword3":"服务时间","remark":"消息备注"}
     *
     * @return
     */
//    private boolean sendWeixinMessage(String access_token, int type, String openid, String name, JSONObject json) {
@ -584,6 +587,32 @@ public class PushMsgTask {
                keyword2.setColor("#000000");
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
            }else if (type == 19) {
                temp.setUrl(url + json.getString("url"));
                temp.setTemplate_id("szpdsKDQQRDnqsoK9Oxuophb-nScXat4yy6wobnvfFw");
                WechatTemplateData keyword1 = new WechatTemplateData();
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword1"));
                m.put("keyword1", keyword1);
                WechatTemplateData keyword2 = new WechatTemplateData();
                keyword2.setColor("#000000");
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
            }else if (type == 20) {
                temp.setUrl(url + json.getString("url"));
                temp.setTemplate_id("szpdsKDQQRDnqsoK9Oxuophb-nScXat4yy6wobnvfFw");
                WechatTemplateData keyword1 = new WechatTemplateData();
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword1"));
                m.put("keyword1", keyword1);
                WechatTemplateData keyword2 = new WechatTemplateData();
                keyword2.setColor("#000000");
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
                WechatTemplateData keyword3 = new WechatTemplateData();
                keyword3.setColor("#000000");
                keyword3.setValue(json.getString("keyword3"));
                m.put("keyword3", keyword3);
            }
            temp.setData(m);

+ 60 - 39
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SFUtils.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.util;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
@ -21,18 +22,30 @@ public class SFUtils {
    private static Logger logger = LoggerFactory.getLogger(SFUtils.class);
    private String j_company;       //寄件方公司名称
    private String j_contact;       //寄件方联系人
    private String j_tel;           //寄件方联系电话
    private String j_province;      //寄件方所在省份
    private String j_city;          //寄件方所在城市名称
    private String j_county;        //寄件人所在县/区
    private String j_address;       //寄件方详细地址,包括省市县/区
    @Autowired
    private PrescriptionInfoService prescriptionInfoService;
    /**
     * 生成接口校验码
     * 1.先把XML报文与checkword前后连接。
     * 2.把连接后的字符串做 MD5 编码。
     * 3.把MD5编码后的数据进行 Base64 编码,此时编码后的字符串即为校验码。
     * @param xml   xml报文
     * @param sf_check_word  接口check_word
     * @return
     */
    public String verifyCodeSFXmlStr(String xml,String sf_check_word){
        String verifyCode = xml+sf_check_word;
        verifyCode = MD5.GetMD5Code(verifyCode);
        verifyCode = new BASE64Encoder().encode(verifyCode.getBytes());
        return verifyCode;
    }
    /**
     * 查询派送地址是否属于顺丰的派送范围
     * @param d_address     派送地址
@ -46,7 +59,7 @@ public class SFUtils {
    public String getSFOrderFilterXml(String d_address,String sf_code,String orderid,String j_tel,String j_address,String d_tel){
        //head 传入接口接入码
        StringBuilder xml = new StringBuilder("<Request service='OrderFilterService' lang='zh-cn'> <Head>"+sf_code+"</Head><Body>");
        StringBuilder xml = new StringBuilder("<Request service='OrderFilterService' lang='zh-cn'><Head>"+sf_code+"</Head><Body>");
        xml.append("<OrderFilter filter_type='1' ");
        //订单号
@ -89,11 +102,12 @@ public class SFUtils {
    /**
     * 向顺丰快递下订单
     * @param sfexpress_obj
     * @param hospital
     * @return
     */
    public String postSFOrderService(PrescriptionExpressage sfexpress_obj,String sf_code) {
    public String postSFOrderService(PrescriptionExpressage sfexpress_obj, Hospital hospital, String sf_code) {
        //head 传入接口接入码
        StringBuilder xml = new StringBuilder("<Request service='OrderService' lang='zh-cn'> <Head>"+sf_code+"</Head><Body>");
        StringBuilder xml = new StringBuilder("<Request service='OrderService' lang='zh-cn'><Head>"+sf_code+"</Head><Body>");
        xml.append("<Order ");
        //订单号(快递业务号作为订单号"SF开头的为顺丰快递")
        xml.append("orderid='"+sfexpress_obj.getCode()+"' ");
@ -101,32 +115,32 @@ public class SFUtils {
         * --------寄方参数------
         */
        //寄件方公司名称
        if(StringUtils.isNotBlank(j_company)){
            xml.append("j_company='"+j_company+"' ");
        if(StringUtils.isNotBlank(hospital.getName())){
            xml.append("j_company='"+hospital.getName()+"' ");
        }
        //寄方联系人
        if(StringUtils.isNotBlank(j_contact)){
            xml.append("j_contact='"+j_contact+"' ");
        if(StringUtils.isNotBlank(hospital.getName())){
            xml.append("j_contact='"+hospital.getName()+"' ");
        }
        //寄件方联系电话
        if(StringUtils.isNotBlank(j_tel)){
            xml.append("j_tel='"+j_tel+"' ");
        if(StringUtils.isNotBlank(hospital.getPhone())){
            xml.append("j_tel='"+hospital.getPhone()+"' ");
        }
        //寄方所在省份
        if(StringUtils.isNotBlank(j_province)){
            xml.append("j_province='"+j_province+"' ");
        if(StringUtils.isNotBlank(hospital.getProvinceName())){
            xml.append("j_province='"+hospital.getProvinceName()+"' ");
        }
        //寄方所在城市
        if(StringUtils.isNotBlank(j_city)){
            xml.append("j_city='"+j_city+"' ");
        if(StringUtils.isNotBlank(hospital.getCityName())){
            xml.append("j_city='"+hospital.getCityName()+"' ");
        }
        //寄方所在县/区
        if(StringUtils.isNotBlank(j_county)){
            xml.append("j_county='"+j_county+"' ");
        if(StringUtils.isNotBlank(hospital.getTownName())){
            xml.append("j_county='"+hospital.getTownName()+"' ");
        }
        //寄件方详细地址,包括省市县/区
        if(StringUtils.isNotBlank(j_address)){
            xml.append("j_address='"+j_address+"' ");
        if(StringUtils.isNotBlank(hospital.getAddress())){
            xml.append("j_address='"+hospital.getAddress()+"' ");
        }
        /**
         * --------收方参数------
@ -165,22 +179,29 @@ public class SFUtils {
    }
    /**
     * 生成接口校验码
     * 1.先把XML报文与checkword前后连接。
     * 2.把连接后的字符串做 MD5 编码。
     * 3.把MD5编码后的数据进行 Base64 编码,此时编码后的字符串即为校验码。
     * @param xml   xml报文
     * @param sf_check_word  接口check_word
     * 顺丰路由查询
     * @param sfexpress_obj
     * @param sf_code
     * @return
     */
    public String verifyCodeSFXmlStr(String xml,String sf_check_word){
        String verifyCode = xml+sf_check_word;
        verifyCode = MD5.GetMD5Code(verifyCode);
        verifyCode = new BASE64Encoder().encode(verifyCode.getBytes());
        return verifyCode;
    public String getRoutInfos(PrescriptionExpressage sfexpress_obj, String sf_code) {
        //head 传入接口接入码
        StringBuilder xml = new StringBuilder("<Request service='RouteService' lang='zh-cn'><Head>"+sf_code+"</Head><Body>");
        xml.append("<RouteRequest tracking_type='1' method_type='1' ").append("tracking_number='"+sfexpress_obj.getMailno()+"' />");
        xml.append("</Body></Request>");
        return xml.toString();
    }
    /**
     * 订单结果查询接口
     * @param sfexpress_objCode
     * @param sf_code
     * @return
     */
    public String sfOrderSearchService(String sfexpress_objCode, String sf_code) {
        StringBuilder xml = new StringBuilder("<Request service='OrderSearchService' lang='zh-cn'><Head>"+sf_code+"</Head><Body>");
        xml.append("<OrderSearch orderid='"+sfexpress_objCode+"'/>");
        xml.append("</Body></Request>");
        return xml.toString();
    }
}

+ 21 - 15
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java

@ -9,11 +9,14 @@ import com.yihu.wlyy.service.common.util.SignTeamAndGroupRunnable;
import com.yihu.wlyy.util.SpringUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
@ -48,7 +51,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/disease/to_redis")
    @RequestMapping(value = "/disease/to_redis", method = RequestMethod.POST)
    public String updateToRedid() {
        try {
            diseaseService.updateToRedis();
@ -63,7 +66,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/disease/to_disease")
    @RequestMapping(value = "/disease/to_disease", method = RequestMethod.POST)
    public String updateToDisease() {
        try {
            diseaseService.updateToDisease();
@ -79,7 +82,7 @@ public class ManagerUtilController extends BaseController {
     * @param patient
     * @return
     */
    @RequestMapping(value = "/disease/patient")
    @RequestMapping(value = "/disease/patient", method = RequestMethod.POST)
    public String getDiseaseFromRedis(String patient) {
        try {
            return write(200, "查询成功", "data", redisTemplate.opsForValue().get("disease:" + patient));
@ -96,7 +99,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/famous_doctor/times_update")
    @RequestMapping(value = "/famous_doctor/times_update", method = RequestMethod.POST)
    public String famousConsultTimeUpdate() {
        try {
            workTimeService.consultTimesRemain(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
@ -112,7 +115,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/people_num_to_redis")
    @RequestMapping(value = "/people_num_to_redis", method = RequestMethod.POST)
    public String peopleNumToRedis(String year) {
        try {
            statisticsService.peopleNumToRedis(year);
@ -127,7 +130,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/sign_set_group_team")
    @RequestMapping(value = "/sign_set_group_team", method = RequestMethod.POST)
    public String signSetGroupAndTeam() {
        try {
            manageUtilService.signPatientSetGroup();
@ -142,7 +145,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/sign_set_group_team_page")
    @RequestMapping(value = "/sign_set_group_team_page", method = RequestMethod.POST)
    public String signSetGroupAndTeamPage(int page) {
        try {
            manageUtilService.setSignTeamAndGroupByPage(page);
@ -157,7 +160,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/sign_set_group_team_id")
    @RequestMapping(value = "/sign_set_group_team_id", method = RequestMethod.POST)
    public String signSetGroupAndTeamId(Long id) {
        try {
            manageUtilService.setSignTeamAndGroupById(id);
@ -172,7 +175,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/sign_error_page_id")
    @RequestMapping(value = "/sign_error_page_id", method = RequestMethod.POST)
    public String getErrorPage(int type) {
        try {
            if (type == 1) {
@ -192,7 +195,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/sign_team_group_thread")
    @RequestMapping(value = "/sign_team_group_thread", method = RequestMethod.POST)
    public String getErrorPage(long start, long end) {
        try {
            new Thread(SpringUtil.getBean(SignTeamAndGroupRunnable.class)
@ -209,7 +212,7 @@ public class ManagerUtilController extends BaseController {
     *
     * @return
     */
    @RequestMapping(value = "/tranform_edu_article")
    @RequestMapping(value = "/tranform_edu_article", method = RequestMethod.POST)
    public String tranformEduArticle() {
        try {
            manageUtilService.transformEduArticle();
@ -220,12 +223,10 @@ public class ManagerUtilController extends BaseController {
    }
    /**
     * 产检提醒
     *  每天早上六点
     * 每天早上六点
     *
     * @return
     */
//    @RequestMapping(value = "/start_prenatal_inspector_job")
@ -242,4 +243,9 @@ public class ManagerUtilController extends BaseController {
//            return error(-1, "启动失败");
//        }
//    }
    //---------------------------微信标签相关 start---------------------------------
    //---------------------------微信标签相关 end---------------------------------
}

+ 12 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionCodeController.java

@ -12,6 +12,7 @@ import org.apache.axis.encoding.Base64;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@ -93,11 +94,15 @@ public class PrescriptionCodeController extends BaseController{
    @RequestMapping(value = "/expressage", method = RequestMethod.POST)
    @ApiOperation(value = "确认配送")
    public String expressage(
            @RequestParam(required = true) @ApiParam(value = "wlyy_prescription_dispensary_code的code", name = "code") String code) {
            @ApiParam(required = true, name = "code", value = " 二维码code") @RequestParam(value = "code", required = true) String code) {
        try {
            Integer status = prescriptionExpressageService.expressage(code, getUID());
            if (status == -1) {
                return error(-1, "取药码错误");
            } else if (status == -2) {
                return error(-1, "编码已使用");
            } else if (status == -3) {
                return error(-1, "编码类型错误");
            }
            return write(200, "配送成功");
        } catch (Exception e) {
@ -107,18 +112,19 @@ public class PrescriptionCodeController extends BaseController{
    /**
     * 医生端获取取药码
     *
     * @param dispensaryCode
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/getDoctorDispensaryQrcode", method = RequestMethod.GET)
    @ObserverRequired
    public String getDoctorDispensaryQrcode(@RequestParam(value = "dispensaryCode",required = true) String dispensaryCode) {
    public String getDoctorDispensaryQrcode(@RequestParam(value = "dispensaryCode", required = true) String dispensaryCode) {
        try{
            Map<String, Object> map = prescriptionDispensaryCodeService.getQrcode(dispensaryCode,getRepUID(),2);
            map.put("code", Base64.encode(map.get("code").toString().getBytes()));
            return write(200, "获取配送员取药码成功!", "data", map);
        }catch (Exception e) {
        } catch (Exception e) {
            error(e);
            return error(-1, "获取配送员取药码失败!");
        }
@ -126,18 +132,19 @@ public class PrescriptionCodeController extends BaseController{
    /**
     * 医生端获取配送码
     *
     * @param dispensaryCode
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/getDoctorDeliveryQrcode", method = RequestMethod.GET)
    @ObserverRequired
    public String getDoctorDeliveryQrcode(@RequestParam(value = "dispensaryCode",required = true) String dispensaryCode) {
    public String getDoctorDeliveryQrcode(@RequestParam(value = "dispensaryCode", required = true) String dispensaryCode) {
        try{
            Map<String, Object> map = prescriptionDispensaryCodeService.getQrcode(dispensaryCode,getRepUID(),3);
            map.put("code",Base64.encode(map.get("code").toString().getBytes()));
            return write(200, "获取配送员配送码成功!", "data", map);
        }catch (Exception e) {
        } catch (Exception e) {
            error(e);
            return error(-1, "获取配送员配送码失败!");
        }

+ 52 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionExpressageController.java

@ -0,0 +1,52 @@
package com.yihu.wlyy.web.doctor.prescription;
import com.yihu.wlyy.service.app.prescription.PatientPrescriptionPayService;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageService;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * Created by Reece on 2017/7/28.
 */
@RestController
@RequestMapping(value = "/doctor/prescription/expressage", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-长处配送相关接口")
public class PrescriptionExpressageController extends WeixinBaseController {
    @Autowired
    private PrescriptionExpressageService expressageService;
    /**
     * 健管师配送的时候分配健管师
     *
     * @return
     */
    @RequestMapping(value = "/expressageJGS", method = RequestMethod.POST)
    @ApiOperation(value = "健管师配送的时候分配健管师")
    public String expressageJGS(
            @ApiParam(required = true, name = "code", value = "健管师code") @RequestParam(value = "code", required = true) String code,
            @ApiParam(required = true, name = "name", value = "健管师name") @RequestParam(value = "name", required = true) String name,
            @ApiParam(required = true, name = "mobile", value = "健管师code") @RequestParam(value = "mobile", required = true) String mobile,
            @ApiParam(required = true, name = "prescriptionCode", value = "处方code") @RequestParam(value = "prescriptionCode", required = true) String prescriptionCode) throws Exception {
        try {
            expressageService.updateExpressageJGS(code,name,mobile,prescriptionCode,getUID());
            return success("修改成功");
        } catch (Exception e) {
            return error(-1, "获取失败");
        }
    }
}

+ 45 - 49
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -25,7 +25,7 @@ import java.util.List;
@RestController
@RequestMapping(value = "/doctor/prescriptionInfo")
@Api("医生端-长处方接口")
public class PrescriptionInfoController extends BaseController {
public class PrescriptionInfoController extends BaseController{
    @Autowired
    private PrescriptionInfoService prescriptionInfoService;
@ -36,36 +36,13 @@ public class PrescriptionInfoController extends BaseController {
    @Autowired
    private PrescriptionPayService prescriptionPayService;
    /**
     * 确认配送 二维码方式
     * 根据处方code获取处方流程
     *
     * @param code wlyy_prescription_dispensary_code的code
     * @return
     */
    @RequestMapping(value = "/expressage", method = RequestMethod.POST)
    @ApiOperation(value = "确认配送")
    @ObserverRequired
    public String expressage(
            @RequestParam(required = true) @ApiParam(value = "wlyy_prescription_dispensary_code的code", name = "code") String code) {
        try {
            Integer status = prescriptionExpressageService.expressage(code, getUID());
            if (status == -1) {
                return error(-1, "编码不存在");
            }
            return write(200, "配送成功");
        } catch (Exception e) {
            error(e);
            return error(-1, "失败");
        }
    }
    @RequestMapping(value = "/getPrescriptionFilter", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取过滤规则信息列表")
    public String getPrescriptionFilter() {
    public String getPrescriptionFilter(){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getPrescriptionFilter());
            return write(200, "查询成功!", "data",prescriptionInfoService.getPrescriptionFilter());
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -75,14 +52,17 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getDoctorPrescription", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取全科医生/建管师续方列表/搜索")
    public String getDoctorPrescription(@RequestParam(required = true) @ApiParam(value = "团队code", name = "teamCode") Integer teamCode,
                                        @RequestParam(required = false) @ApiParam(value = "续方状态", name = "state") String state,
                                        @RequestParam(required = false) @ApiParam(value = "所有诊断:1 糖尿病 2高血压", name = "dispensary") String diseases,
                                        @RequestParam(required = false) @ApiParam(name = "startDate", value = "开始时间") String startDate,
                                        @RequestParam(required = false) @ApiParam(name = "endDate", value = "结束时间") String endDate,
                                        @RequestParam(required = false) @ApiParam(name = "nameKeyword", value = "患者姓名模糊匹配") String nameKeyword) {
    public String getDoctorPrescription(@RequestParam(required = true)@ApiParam(value = "团队code", name = "teamCode") Integer teamCode,
                                        @RequestParam(required = false)@ApiParam(value = "续方状态", name = "state") String state,
                                        @RequestParam(required = false)@ApiParam(value = "所有诊断:1 糖尿病 2高血压", name = "dispensary") String diseases,
                                        @RequestParam(required = false)@ApiParam(name="startDate",value="开始时间")String startDate,
                                        @RequestParam(required = false)@ApiParam(name="endDate",value="结束时间")String endDate,
                                        @RequestParam(required = false)@ApiParam(name="nameKeyword",value="患者姓名模糊匹配")String nameKeyword,
                                        @RequestParam(required = false)@ApiParam(name="nameKeyword",value="患者姓名模糊匹配")String patient,
                                        @RequestParam(required = false)@ApiParam(name="page",value="起始页")Integer page,
                                        @RequestParam(required = false)@ApiParam(name="size",value="每页条数")Integer size){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getDoctorPrescription(teamCode, state, diseases, startDate, endDate, nameKeyword));
            return write(200, "查询成功!", "data",prescriptionInfoService.getDoctorPrescription(teamCode,state,diseases,startDate,endDate,nameKeyword,patient,page,size));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -92,10 +72,10 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getContinuedPrescriptionAsDoctor", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "续方详情")
    public String getContinuedPrescriptionAsDoctor(@RequestParam(required = true) @ApiParam(value = "续方CODE", name = "code") String code,
                                                   @RequestParam(required = true) @ApiParam(value = "团队长标识:1:是;2否", name = "type") String type) {
    public String getContinuedPrescriptionAsDoctor(@RequestParam(required = true)@ApiParam(value = "续方CODE", name = "code") String code,
                                                   @RequestParam(required = true)@ApiParam(value = "团队长标识:1:是;2否", name = "type") String type){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getContinuedPrescriptionAsDoctor(code));
            return write(200, "查询成功!", "data",prescriptionInfoService.getContinuedPrescriptionAsDoctor(code));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -105,11 +85,11 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/reviewPrescription", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "续方审核")
    public String reviewPrescription(@RequestParam(required = true) @ApiParam(value = "续方CODE", name = "code") String code,
                                     @RequestParam(required = false) @ApiParam(value = "不同意原因", name = "reason") String reason,
                                     @RequestParam(required = false) @ApiParam(value = "1同意,2不同意", name = "state") String state) {
    public String reviewPrescription(@RequestParam(required = true)@ApiParam(value = "续方CODE", name = "code") String code,
                                     @RequestParam(required = false)@ApiParam(value = "不同意原因", name = "reason") String reason,
                                     @RequestParam(required = false)@ApiParam(value = "1同意,2不同意", name = "state") String state){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.reviewPrescription(code, reason, state));
            return write(200, "查询成功!", "data",prescriptionInfoService.reviewPrescription(code,reason,state));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -120,11 +100,11 @@ public class PrescriptionInfoController extends BaseController {
    @ResponseBody
    @ApiOperation(value = "调整处方")
    @ObserverRequired
    public String updatePresInfo(@RequestParam(required = true) @ApiParam(value = "续方CODE", name = "code") String code,
                                 @RequestParam(required = true) @ApiParam(value = "续方药品JSON", name = "infos") String infos,
                                 @RequestParam(required = true) @ApiParam(value = "调整原因", name = "reason") String reason) {
    public String updatePresInfo(@RequestParam(required = true)@ApiParam(value = "续方CODE", name = "code") String code,
                                 @RequestParam(required = true)@ApiParam(value = "续方药品JSON", name = "infos") String infos,
                                 @RequestParam(required = true)@ApiParam(value = "调整原因", name = "reason") String reason ){
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.updatePresInfo(code, infos, reason));
            return write(200, "操作成功!", "data",prescriptionInfoService.updatePresInfo(code,infos,reason));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -134,9 +114,9 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getInfoTitle", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "调整处方-药品分类及种类数目")
    public String getInfoTitle() {
    public String getInfoTitle(){
        try {
            return write(200, "操作成功!", "data", "");
            return write(200, "操作成功!", "data","");
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -146,9 +126,9 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getInfoListByParentCode", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "药品类别获取药品")
    private String getInfoListByParentCode(@RequestParam(required = true) @ApiParam(value = "药品类别Code", name = "code") String code) {
    private String getInfoListByParentCode(@RequestParam(required = true)@ApiParam(value = "药品类别Code", name = "code") String code){
        try {
            return write(200, "操作成功!", "data", "");
            return write(200, "操作成功!", "data","");
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -179,12 +159,28 @@ public class PrescriptionInfoController extends BaseController {
            jo.put("prescriptionExpressage", prescriptionExpressage);
            jo.put("prescriptionInfos", prescriptionInfos);
            jo.put("prescriptionPay", prescriptionPay);
            jo.put("prescriptionType", prescription.getType());//处方配送方式
            jo.put("prescriptionHospital", prescription.getHospitalName());//出药机构
            jo.put("dispensaryDispensaryType", prescription.getType());//处方配送方式
            jo.put("dispensaryDispensaryTypeName", prescription.getTypeName());//处方配送方式
            jo.put("prescriptionStatus", prescription.getStatus());//处方状态
            jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(),""));//处方状态名称
            return write(200, "查询成功", "data", jo);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getDrugTimes", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "药品品使用频次字典")
    public String getDrugTimes(){
        try {
            return write(200, "操作成功!", "data",prescriptionInfoService.getDrugTimes());
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
}

+ 45 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionLogController.java

@ -8,6 +8,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -37,10 +38,52 @@ public class PrescriptionLogController extends BaseController {
    public String addReply(
            @RequestParam(required = true) @ApiParam(value = "处方code", name = "prescriptionCode") String prescriptionCode) {
        try {
            Integer[] types = new Integer[]{20, 30, 31,100};
            // (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 ,
            //  40配药成功/待配送  41配送失败  42配送中   43配送到服务站  100配送到患者手中/已完成)
            Integer[] types = new Integer[]{
                    PrescriptionLog.PrescriptionLogStatus.revieweding.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.changeing.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.reviewed_success.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.wait_pay.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.pay_success.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.expressageing.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.finish.getValue()};
            List<PrescriptionLog> prescriptionLogs = prescriptionLogService.findPrescriptionLogsByPrescriptionCode(prescriptionCode, types);
            if (prescriptionLogs != null) {
                return write(200, "获取处方流程成功", "data", prescriptionLogs);
                return write(200, "获取处方流程成功", "data", new JSONArray(copyBeans(prescriptionLogs, "statusName", "createTime")));
            } else {
                return error(-1, "获取失败");
            }
        } catch (Exception e) {
            return error(-1, "获取失败");
        }
    }
    /**
     * 根据处方code获取处方流程
     *
     * @param prescriptionCode
     * @return
     */
    @RequestMapping(value = "/orderFollow", method = RequestMethod.GET)
    @ApiOperation(value = "订单状态跟踪")
    public String orderFollow(
            @RequestParam(required = true) @ApiParam(value = "处方code", name = "prescriptionCode") String prescriptionCode) {
        try {
            // (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 ,
            //  40配药成功/待配送  41配送失败  42配送中   43配送到服务站  100配送到患者手中/已完成)
            Integer[] types = new Integer[]{
                    PrescriptionLog.PrescriptionLogStatus.pay_success.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.expressageing.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.finish.getValue()};
            List<PrescriptionLog> prescriptionLogs = prescriptionLogService.findPrescriptionLogsByPrescriptionCode(prescriptionCode, types);
            if (prescriptionLogs != null) {
                return write(200, "获取处方流程成功", "data", new JSONArray(copyBeans(prescriptionLogs, "statusName", "createTime")));
            } else {
                return error(-1, "获取失败");
            }

+ 57 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionNoticesController.java

@ -0,0 +1,57 @@
package com.yihu.wlyy.web.doctor.prescription;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.service.app.prescription.PrescriptionDispensaryCodeService;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageService;
import com.yihu.wlyy.service.app.prescription.PrescriptionNoticesService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.WeixinBaseController;
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.web.bind.annotation.*;
/**
 * Created by Reece on 2017/8/3.
 */
@RestController
@RequestMapping(value = "/doctor/prescriptionNotices")
@Api(description = "医生端-长处方模板消息接口")
public class PrescriptionNoticesController extends WeixinBaseController {
    @Autowired
    private PrescriptionNoticesService noticesService;
    /**
     * 医生端及基卫发送给居民的模板消息
     * @param doctor   相关医生信息
     * @param patient  目标居民信息
     * @param checkDoctor  审核医生姓名
     * @param ordenTime     订单完成时间 时间字符串格式yyyy-MM-dd HH:mm:ss
     * @param type       1:续方审核通知 2:取药代办通知 3:配送中信息变更 4:已完成服务结果
     * @param status    续方通知状态 0不通过 1通过 2调整处方  其余模板通知消息状态均为0
     * @return
     */
    @RequestMapping(value = "/sendMessage", method = RequestMethod.POST)
    @ApiOperation(value = "模板消息发送")
    public String sendMessage(
            @RequestParam() @ApiParam(value = "相关医生信息", name = "doctor")String doctor,
            @RequestParam() @ApiParam(value = "目标居民信息", name = "patient")String patient,
            @RequestParam() @ApiParam(value = "审核医生姓名", name = "checkDoctor")String checkDoctor,
            @RequestParam() @ApiParam(value = "订单完成时间 格式yyyy-MM-dd HH:mm:ss", name = "ordenTime")String ordenTime,
            @RequestParam() @ApiParam(value = "模板类型", name = "type")int type,
            @RequestParam() @ApiParam(value = "模板", name = "status")int status) {
        try {
            String accessToken = getAccessToken();
            noticesService.sendMessages(accessToken,doctor,patient,checkDoctor,ordenTime,type,status);
            return write(200, "配送成功");
        } catch (Exception e) {
            return error(-1, "失败");
        }
    }
}

+ 14 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java

@ -182,6 +182,20 @@ public class AdminTeamController extends BaseController {
        }
    }
    @RequestMapping(value = "/{team_id}/jgsmembers", method = RequestMethod.GET)
    @ApiOperation(value = "获取团队健管师")
    public String jgsmembers(@PathVariable("team_id") long teamId) {
        try {
            List<Doctor> members = memberService.getJGSMembers(teamId);
            return write(200, "OK", "data", new JSONArray(copyBeans(members, "id", "code", "name", "hospital","mobile",
                    "jobName", "level", "sex", "photo")));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    //目前没用到,之后可能会用到
//  @RequestMapping(value = "/{team_id}/members/excludedThisAndLevel3", method = RequestMethod.GET)
//  @ApiOperation(value = "获取团队成员,排除自己和专科医生")

+ 49 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/express/SFExpressApiController.java

@ -0,0 +1,49 @@
package com.yihu.wlyy.web.express;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.service.app.express.SFExpressService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.net.URLDecoder;
/**
 * 提供给顺丰快递调用的相关接口
 * @author huangwenjie 2017.08.03
 */
@Controller
@RequestMapping(value = "/express/sf")
@Api(description = "顺丰速运相关接口")
public class SFExpressApiController extends BaseController {
    @Autowired
    private SFExpressService sfexpressService;
    private String successxml = "<Response service='RoutePushService'><Head>OK</Head></Response>";
    @RequestMapping(value="/routepushservice",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("接受顺丰推送过来的路由信息")
    @ObserverRequired
    public String SFRoutePushService (
            @ApiParam(name="xml", value="入参报文") @RequestParam(value = "xml",required = true) String xml){
        try {
            xml = URLDecoder.decode(xml,"utf-8");
            sfexpressService.SFRoutePushService(xml);
            return successxml;
        }catch (Exception e){
            //日志文件中记录异常信息
            error(e);
            //返回接口异常信息处理结果
            return "<Response service='RoutePushService'><Head>ERR</Head><ERROR code='-1'>系统发生数据错误或运行时异常</ERROR></Response>";
        }
    }
}

+ 84 - 54
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/express/SFExpressController.java

@ -1,14 +1,21 @@
package com.yihu.wlyy.web.patient.express;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.dict.DmExpressagePriceEntity;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressageLog;
import com.yihu.wlyy.service.app.express.SFExpressService;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageLogService;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
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.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -16,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.UUID;
/**
@ -34,7 +42,13 @@ public class SFExpressController extends BaseController {
    @Autowired
    private PrescriptionExpressageService prescriptionExpressageService;
    @RequestMapping(value = "/SFOrderFilterService", method = RequestMethod.GET)
    @Autowired
    private PrescriptionService prescriptionService;
    @Autowired
    private PrescriptionExpressageLogService prescriptionExpressageLogService;
    @RequestMapping(value = "/sforderfilterservice", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("查询派送地址是否属于顺丰的派送范围")
    public String SFOrderFilterService(
@ -58,62 +72,40 @@ public class SFExpressController extends BaseController {
        }
    }
    @RequestMapping(value="/SFOrderService",method = RequestMethod.POST)
    @RequestMapping(value="/sforderservice",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("向顺丰快递下订单")
    @ObserverRequired
    public String SFOrderService(
            @ApiParam(name="prescriptionCode", value="处方编号") @RequestParam(value = "prescriptionCode",required = true) String prescriptionCode
//            @ApiParam(name="j_company", value="寄件方公司名称") @RequestParam(value = "j_company") String j_company,
//            @ApiParam(name="j_contact", value="寄件方联系人") @RequestParam(value = "j_contact") String j_contact,
//            @ApiParam(name="j_tel", value="寄件方联系电话") @RequestParam(value = "j_tel") String j_tel,
//            @ApiParam(name="j_mobile", value="寄件方手机") @RequestParam(value = "j_mobile") String j_mobile,
//            @ApiParam(name="j_province", value="寄件方所在省份") @RequestParam(value = "j_province") String j_province,
//            @ApiParam(name="j_city", value="寄件方所在城市名称") @RequestParam(value = "j_city") String j_city,
//            @ApiParam(name="j_county", value="寄件人所在县/区") @RequestParam(value = "j_county") String j_county,
//            @ApiParam(name="j_address", value="寄件方详细地址,不包括省市区") @RequestParam(value = "j_address") String j_address,
//            @ApiParam(name="d_company", value="到件方公司名称") @RequestParam(value = "d_company") String d_company,
//            @ApiParam(name="d_contact", value="到件方联系人") @RequestParam(value = "d_contact") String d_contact,
//            @ApiParam(name="d_tel", value="到件方联系电话") @RequestParam(value = "d_tel") String d_tel,
//            @ApiParam(name="d_mobile", value="到件方手机") @RequestParam(value = "d_mobile") String d_mobile,
//            @ApiParam(name="d_province", value="到件方所在省份") @RequestParam(value = "d_province") String d_province,
//            @ApiParam(name="d_city", value="到件方所在城市名称") @RequestParam(value = "d_city") String d_city,
//            @ApiParam(name="d_county", value="到件方所在县/区") @RequestParam(value = "d_county") String d_county,
//            @ApiParam(name="d_address", value="到件方完整的详细地址") @RequestParam(value = "d_address") String d_address
    ){
            @ApiParam(name="prescriptionCode", value="处方编号") @RequestParam(value = "prescriptionCode",required = true) String prescriptionCode){
        try {
            PrescriptionExpressage sfexpress_obj = prescriptionExpressageService.findByPrescriptionCode(prescriptionCode);
            if(sfexpress_obj == null){
                return write(-1, "顺丰快递下单失败,未找到该处方的派送地址!");
            }
            //先判断地址是否可派送
            boolean delivery = sfexpressService.getSFOrderFilterService(sfexpress_obj.getProvinceName()+sfexpress_obj.getCityName()+sfexpress_obj.getTownName()+sfexpress_obj.getAddress());
            if(delivery){
//                sfexpress_obj.setCode("SF"+UUID.randomUUID().toString().replace("-",""));
//                sfexpress_obj.setPrescriptionCode(prescriptionCode);
//                sfexpress_obj.setName(sfexpress_obj.getName());
//                sfexpress_obj.setPhone(sfexpress_obj.getPhone());
//                sfexpress_obj.setMobile(d_mobile);
//                sfexpress_obj.setProvinceName(d_province);
//                sfexpress_obj.setCityName(d_city);
//                sfexpress_obj.setTownName(d_county);
//                sfexpress_obj.setAddress(d_address);
//                sfexpress_obj.setHospitalName("顺丰速递");
//                sfexpress_obj.setOneselfPickupFlg(0);//是否自取 1是 0否
//                sfexpress_obj.setCreateTime(DateUtil.getNowDate());
                //请求顺丰接口下单,成功下单后,返回快递单号
                sfexpress_obj = sfexpressService.postSFOrderService(sfexpress_obj);
                //保存快递单号和增加处方物流记录为配送
                prescriptionExpressageService.updatePrescriptionExpressage(sfexpress_obj,getUID());
                return write(200, "顺丰快递下单成功!");
            }else{
                return write(-1, "顺丰快递下单失败,地址不可派送!");
                //如果该处方的快递单号已生成,则说明已经下单成功,不需要重复下单,直接返回成功
                if(StringUtils.isNotBlank(sfexpress_obj.getMailno())){
                    return write(200, "顺丰快递下单成功!");
                }else{
                //如果该处方的快递单号未生成,则继续下单
                    //由于下单前已经判断过是否派送,这里不再重复判断----huangwenjie-2017.08.04
                    //先判断地址是否可派送boolean delivery = sfexpressService.getSFOrderFilterService(sfexpress_obj.getProvinceName()+sfexpress_obj.getCityName()+sfexpress_obj.getTownName()+sfexpress_obj.getAddress());
                    //根据业务订单号判断是否已经下单成功
                    boolean go_on = sfexpressService.sfOrderSearchService(sfexpress_obj);
                    //如果该业务订单号未下单成功过,则重新下单
                    if(go_on){
                        //请求顺丰接口下单,成功下单后,返回快递单号
                        sfexpress_obj = sfexpressService.postSFOrderService(sfexpress_obj);
                        //保存快递单号和增加处方物流记录为配送
                        prescriptionExpressageService.updatePrescriptionExpressage(sfexpress_obj);
                    }
                    return write(200, "顺丰快递下单成功!");
                }
            }
        }catch (Exception e){
            //日志文件中记录异常信息
@ -123,18 +115,56 @@ public class SFExpressController extends BaseController {
        }
    }
    @RequestMapping(value="/SFOrderService",method = RequestMethod.GET)
    @RequestMapping(value="/sfrouteservice",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("通过快递单号或者业务订单号查询包裹路由信息")
    @ApiOperation("通过处方编码查询顺丰物流派送记录")
    @ObserverRequired
    public String SFRouteService(
            @ApiParam(name="tracking_number", value="快递单号或者订单编号") @RequestParam(value = "tracking_number",required = true) String tracking_number,
            @ApiParam(name="tracking_type", value="查询号类别:1为快递单号,2为订单编号") @RequestParam(value = "tracking_type",required = true) Integer tracking_type){
            @ApiParam(name="prescriptionCode", value="处方编号") @RequestParam(value = "prescriptionCode",required = true) String prescriptionCode){
            //1.先从本地获取
        try {
            Prescription prescription = prescriptionService.findByCode(prescriptionCode);
            List<PrescriptionExpressageLog> sfexpresslogList = prescriptionExpressageLogService.findByPrescriptionCode(prescriptionCode);
            PrescriptionExpressage sfexpress_obj = prescriptionExpressageService.findByPrescriptionCode(prescriptionCode);
        return "";
            //先判断该处方是否已完成配送,如果配送完成,则直接取本地的物流记录
            if(100 == prescription.getStatus()){
                return write(200, "查询成功","data",sfexpresslogList);
            }else{
                //如果配送未完成,则调用顺丰接口获取物流路由日志,与本地匹配,进行增量修改
                sfexpresslogList = sfexpressService.getRoutInfos(prescription,sfexpress_obj,sfexpresslogList);
                return write(200, "查询成功","data",sfexpresslogList);
            }
        }catch (Exception e){
            //日志文件中记录异常信息
            error(e);
            //返回接口异常信息处理结果
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/getsfexpressprice", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("根据收寄地址获取快递费用")
    public String SFExpressPrice(
//            @ApiParam(name = "j_city", value = "寄方地址(城市),默认为厦门", defaultValue = "厦门")
//            @RequestParam(value = "j_city", required = false) String j_city,
            @ApiParam(name = "d_province", value = "收方地址(省份)")
            @RequestParam(value = "d_province", required = false) String d_province,
            @ApiParam(name = "d_city", value = "收方地址(城市)")
            @RequestParam(value = "d_city", required = false) String d_city){
        try {
            DmExpressagePriceEntity expreprice = sfexpressService.getSFExpressPrice(d_province,d_city);
            return write(200, "查询成功","data",expreprice);
        }catch (Exception e){
            //日志文件中记录异常信息
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败,"+e.getMessage());
        }
    }
}

+ 4 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionInfoController.java

@ -36,9 +36,11 @@ public class PatientPrescriptionInfoController extends BaseController {
    public String getPrescriptionInfos(@RequestParam(required = true)@ApiParam(name="type",value="1:查询处方;2我的续方;3:续方记录")String type,
                                       @RequestParam(required = false)@ApiParam(name="isRenewal",value="处方是否可续方:1.是;2.无过滤")String isRenewal,
                                       @RequestParam(required = false)@ApiParam(name="startDate",value="开始时间")String startDate,
                                       @RequestParam(required = false)@ApiParam(name="endDate",value="结束时间")String endDate){
                                       @RequestParam(required = false)@ApiParam(name="endDate",value="结束时间")String endDate,
                                       @RequestParam(required = false)@ApiParam(name="page",value="起始页")Integer page,
                                       @RequestParam(required = false)@ApiParam(name="size",value="每页条数")Integer size){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getPrescriptionInfos(type,startDate,endDate,getRepUID(),isRenewal));
            return write(200, "查询成功!", "data", prescriptionInfoService.getPrescriptionInfos(type,startDate,endDate,getRepUID(),isRenewal,page,size));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");

+ 14 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionLogController.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -36,10 +37,21 @@ public class PatientPrescriptionLogController extends BaseController {
    public String addReply(
            @RequestParam(required = true) @ApiParam(value = "处方code", name = "prescriptionCode") String prescriptionCode) {
        try {
            Integer[] types = new Integer[]{20, 30, 31,100};
            Integer[] types = new Integer[]{
                    PrescriptionLog.PrescriptionLogStatus.revieweding.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.changeing.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.reviewed_success.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.wait_pay.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.pay_error.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.pay_success.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.expressageing.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue(),
                    PrescriptionLog.PrescriptionLogStatus.finish.getValue()};
            List<PrescriptionLog> prescriptionLogs = prescriptionLogService.findPrescriptionLogsByPrescriptionCode(prescriptionCode, types);
            if (prescriptionLogs != null) {
                return write(200, "获取处方流程成功", "data", prescriptionLogs);
                return write(200, "获取处方流程成功", "data", new JSONArray(copyBeans(prescriptionLogs, "statusName", "createTime")));
            } else {
                return error(-1, "获取失败");
            }

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/PatientSignController.java

@ -316,8 +316,8 @@ public class PatientSignController extends BaseController {
    @RequestMapping(value = "/signInfo",method = RequestMethod.GET)
    public String getSignInfo(@RequestParam String code) {
        try {
            List<JSONObject> jsonArray = signWebService.getSignInfo(code);
            return write(200, "查询成功!", "data", new JSONArray(jsonArray));
            JSONObject jsonArray = signWebService.getSignInfo(code);
            return write(200, "查询成功!", "data", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "系统错误,请联系管理员!");

+ 1 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatCoreController.java

@ -2,7 +2,6 @@ package com.yihu.wlyy.web.wx;
import com.yihu.wlyy.service.weixin.WeiXinCoreService;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
@ -161,7 +160,7 @@ public class WechatCoreController extends WeixinBaseController {
    public String createMenuTest() {
        try {
            String filePath = WechatCoreController.class.getResource("/").getPath() +
                    File.separator + "weixin_menu.txt";
                    File.separator + "wechat"+ File.separator+"weixin_menu.txt";
            String url = " https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + getAccessToken();
            // 读取微信菜单配置文件
            InputStreamReader reader = new InputStreamReader(new FileInputStream(filePath), "utf-8");

+ 119 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatMenuController.java

@ -0,0 +1,119 @@
package com.yihu.wlyy.web.wx;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinTagUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
/**
 * Created by chenweida on 2017/8/4.
 */
@RestController
@RequestMapping(value = "/wechat/menu", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "微信菜单相关管理")
public class WechatMenuController extends BaseController {
    @Autowired
    private WeiXinTagUtil weiXinTagUtil;
    @Value("${wechat.wechat_token}")
    private String wechat_token;
    @Value("${wechat.wechat_base_url}")
    private String wechat_base_url;
    @Value("${wechat.appId}")
    private String appId;
    @Autowired
    private com.yihu.wlyy.util.HttpUtil HttpUtil;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    /**
     * 微信菜单创建
     *
     * @return
     */
    @ApiOperation(value = "微信菜单创建")
    @RequestMapping(value = "/menu/create", method = RequestMethod.POST)
    public String createMenuTest() {
        try {
            String filePath = WechatCoreController.class.getResource("/").getPath() +
                    File.separator + "wechat" + File.separator + "weixin_menu.txt";
            String url = " https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + weiXinAccessTokenUtils.getAccessToken();
            // 读取微信菜单配置文件
            InputStreamReader reader = new InputStreamReader(new FileInputStream(filePath), "utf-8");
            BufferedReader bufferedReader = new BufferedReader(reader);
            String params = "";
            String readTxt = "";
            // 读取微信菜单
            while ((readTxt = bufferedReader.readLine()) != null) {
                System.out.println(readTxt);
                params += readTxt;
            }
            bufferedReader.close();
            reader.close();
            // 替换服务器地址、APPID
            params = params.replaceAll("server_url", wechat_base_url);
            params = params.replaceAll("appId", appId);
            // 请求微信接口创建菜单
            String jsonStr = HttpUtil.sendPost(url, params);
            JSONObject result = new JSONObject(jsonStr);
            if (result != null && result.get("errcode").toString().equals("0") && result.getString("errmsg").equals("ok")) {
                return write(200, "创建成功!", "data", jsonStr);
            } else {
                return write(-1, "创建失败!", "data", jsonStr);
            }
        } catch (Exception e) {
            return error(-1, "创建失败");
        }
    }
    /**
     * 集美区微信特色菜单菜单创建
     *
     * @return
     */
    @ApiOperation(value = "集美区微信特色菜单菜单创建")
    @RequestMapping(value = "/menu/create/jimei", method = RequestMethod.POST)
    public String createMenuTestJimei() {
        try {
            String filePath = WechatCoreController.class.getResource("/").getPath() +
                    File.separator + "wechat" + File.separator + "weixin_menu_jimei.txt";
            String url = " https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token=" + weiXinAccessTokenUtils.getAccessToken();
            // 读取微信菜单配置文件
            InputStreamReader reader = new InputStreamReader(new FileInputStream(filePath), "utf-8");
            BufferedReader bufferedReader = new BufferedReader(reader);
            String params = "";
            String readTxt = "";
            // 读取微信菜单
            while ((readTxt = bufferedReader.readLine()) != null) {
                System.out.println(readTxt);
                params += readTxt;
            }
            bufferedReader.close();
            reader.close();
            // 替换服务器地址、APPID
            params = params.replaceAll("server_url", wechat_base_url);
            params = params.replaceAll("appId", appId);
            // 请求微信接口创建菜单
            String jsonStr = HttpUtil.sendPost(url, params);
            return write(200, "创建成功!", "data", jsonStr);
        } catch (Exception e) {
            return error(-1, "创建失败");
        }
    }
}

+ 105 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatTagController.java

@ -0,0 +1,105 @@
package com.yihu.wlyy.web.wx;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.wechat.util.WeiXinTagUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
/**
 * Created by chenweida on 2017/8/4.
 */
@RestController
@RequestMapping(value = "/wechat/tag", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "微信标签相关管理")
public class WechatTagController extends BaseController {
    @Autowired
    private WeiXinTagUtil weiXinTagUtil;
    @ApiOperation(value = "创建微信标签")
    @RequestMapping(value = "/createTag", method = RequestMethod.POST)
    public String createTage(
            @ApiParam(name = "tagName", value = "标签名称", required = true) @RequestParam(value = "tagName", required = true) String tagName) {
        try {
            String string = weiXinTagUtil.createTag(tagName);
            return write(200, "创建成功", "date", string);
        } catch (Exception e) {
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "删除微信标签")
    @RequestMapping(value = "/deleteTag", method = RequestMethod.POST)
    public String deleteTag(
            @ApiParam(name = "tageId", value = "微信标签Id", required = true) @RequestParam(value = "tageId", required = true) Integer tageId) {
        try {
           String string= weiXinTagUtil.deleteTag(tageId);
            return write(200, "删除成功", "date", string);
        } catch (Exception e) {
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "获取已经创建的微信标签")
    @RequestMapping(value = "/queryTags", method = RequestMethod.GET)
    public String queryTags() {
        try {
            String string = weiXinTagUtil.queryTags();
            return write(200, "查询成功", "date", string);
        } catch (Exception e) {
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "根据openId获取该用户下的标签")
    @RequestMapping(value = "/queryByOpenId", method = RequestMethod.POST)
    public String queryByOpenId(
            @ApiParam(name = "openid", value = "openid", required = true) @RequestParam(value = "openid", required = true) String openid) {
        try {
            String string = weiXinTagUtil.queryTagWithOpenid(openid);
            return write(200, "查询成功", "date", string);
        } catch (Exception e) {
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "批量给openID添加标签")
    @RequestMapping(value = "/addTagsWithOpenId", method = RequestMethod.POST)
    public String addTagsWithOpenId(
            @ApiParam(name = "openids", value = "openids,多个逗号分割", required = true) @RequestParam(value = "openids", required = true) String openids,
            @ApiParam(name = "tageId", value = "微信标签Id", required = true) @RequestParam(value = "tageId", required = true) Integer tageId) {
        try {
            String[] openis = openids.split(",");
            String string = weiXinTagUtil.addTagWithOpenid(java.util.Arrays.asList(openis),tageId);
            return write(200, "查询成功", "date", string);
        } catch (Exception e) {
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "批量给openID取消标签")
    @RequestMapping(value = "deleteTagsWithOpenId", method = RequestMethod.POST)
    public String deleteTagsWithOpenId(
            @ApiParam(name = "openids", value = "openids,多个逗号分割", required = true) @RequestParam(value = "openids", required = true) String openids,
            @ApiParam(name = "tageId", value = "微信标签Id", required = true) @RequestParam(value = "tageId", required = true) Integer tageId) {
        try {
            String[] openis = openids.split(",");
            String string = weiXinTagUtil.deleteTagWithOpenid(java.util.Arrays.asList(openis),tageId);
            return write(200, "查询成功", "date", string);
        } catch (Exception e) {
            return error(-1, "失败");
        }
    }
}

+ 200 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/util/WeiXinTagUtil.java

@ -0,0 +1,200 @@
package com.yihu.wlyy.wechat.util;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.wechat.WechatTag;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.wechat.WechatTagDao;
import com.yihu.wlyy.util.HttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
/**
 * Created by chenweida on 2017/8/4.
 * 微信标签功能
 */
@Component
public class WeiXinTagUtil {
    @Autowired
    private WechatTagDao wechatTagDao;
    private Logger logger = LoggerFactory.getLogger(WeiXinTagUtil.class);
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private HttpUtil httpUtil;
    @Value("${wechat.appSecret}")
    private String appSecret;
    // 创建标签
    private static String create_tag = "https://api.weixin.qq.com/cgi-bin/tags/create?access_token=";
    //删除标签
    private static String delete_tag = "https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=";
    //查询标签
    private static String query_tag = "https://api.weixin.qq.com/cgi-bin/tags/get?access_token=";
    //给用户打标签
    private static String add_user_tag = "https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=";
    //给用户删除标签
    private static String delete_user_tag = "https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token=";
    //获取用户标签
    private static String query_user_tag = "https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=";
    /**
     * 根据openID给用户打标签,并且同步更新用户表
     *
     * @param openIds
     * @param tagId
     * @return
     */
    public String addTagWithOpenid(List<String> openIds, Integer tagId) {
        try {
            net.sf.json.JSONObject params = new net.sf.json.JSONObject();
            params.put("openid_list", net.sf.json.JSONArray.fromObject(openIds));
            params.put("tagid", tagId);
            String result = httpUtil.sendPost(add_user_tag + weiXinAccessTokenUtils.getAccessToken(), params.toString());
            net.sf.json.JSONObject resultJson = net.sf.json.JSONObject.fromObject(result);
            if (resultJson.containsKey("errcode")) {
                Integer status = resultJson.getInt("errcode");
                if (status != 0) {
                    throw new Exception("创建失败," + result);
                }
            }
            return result;
        } catch (Exception e) {
            logger.error(e.getMessage());
            return null;
        }
    }
    /**
     * 根据openID给用户取消标签,并且同步更新用户表
     *
     * @param openIds
     * @param tagId
     * @return
     */
    public String deleteTagWithOpenid(List<String> openIds, Integer tagId) {
        try {
            net.sf.json.JSONObject params = new net.sf.json.JSONObject();
            params.put("openid_list", net.sf.json.JSONArray.fromObject(openIds));
            params.put("tagid", tagId);
            String result = httpUtil.sendPost(delete_user_tag + weiXinAccessTokenUtils.getAccessToken(), params.toString());
            net.sf.json.JSONObject resultJson = net.sf.json.JSONObject.fromObject(result);
            if (resultJson.containsKey("errcode")) {
                Integer status = resultJson.getInt("errcode");
                if (status != 0) {
                    throw new Exception("创建失败," + result);
                }
            }
            return result;
        } catch (Exception e) {
            logger.error(e.getMessage());
            return null;
        }
    }
    /**
     * 获取用户身上的标签列表
     *
     * @param openId
     * @return
     */
    public String queryTagWithOpenid(String openId) {
        try {
            net.sf.json.JSONObject params = new net.sf.json.JSONObject();
            params.put("openid", openId);
            String result = httpUtil.sendGet(query_user_tag + weiXinAccessTokenUtils.getAccessToken(), params.toString());
            net.sf.json.JSONObject resultJson = net.sf.json.JSONObject.fromObject(result);
            return result;
        } catch (Exception e) {
            logger.error(e.getMessage());
            return null;
        }
    }
    /**
     * 新增标签
     *
     * @param name
     * @return
     */
    public String createTag(String name) throws Exception {
        JSONObject params = new JSONObject();
        JSONObject tagName = new JSONObject();
        tagName.put("name", name);
        params.put("tag", tagName);
        // 发送模板消息
        String result = httpUtil.sendPost(create_tag + weiXinAccessTokenUtils.getAccessToken(), params.toJSONString());
        logger.info("create tag resutl:" + result);
        net.sf.json.JSONObject resultJson = net.sf.json.JSONObject.fromObject(result);
        if (resultJson.containsKey("errcode")) {
            Integer status = resultJson.getInt("errcode");
            if (status != 0) {
                throw new Exception("创建失败," + result);
            }
        }
        Integer tag = resultJson.getJSONObject("tag").getInt("id");
        WechatTag newWechatTag = new WechatTag();
        newWechatTag.setCreateTime(new Date());
        newWechatTag.setTagName(name);
        newWechatTag.setDel(1);
        newWechatTag.setTagId(tag);
        wechatTagDao.save(newWechatTag);
        return result;
    }
    /**
     * 删除标签
     *
     * @param tagId
     * @return
     */
    public String deleteTag(Integer tagId) throws Exception {
        JSONObject params = new JSONObject();
        JSONObject tagName = new JSONObject();
        tagName.put("id", tagId);
        params.put("tag", tagName);
        // 发送模板消息
        String result = httpUtil.sendPost(delete_tag + weiXinAccessTokenUtils.getAccessToken(), params.toJSONString());
        logger.info("delete tag resutl:" + result);
        net.sf.json.JSONObject resultJson = net.sf.json.JSONObject.fromObject(result);
        if (resultJson.containsKey("errcode")) {
            Integer status = resultJson.getInt("errcode");
            if (status != 0) {
                throw new Exception("创建失败," + result);
            }
        }
        //删除我们自己表的标签表数据
        wechatTagDao.deleteTag(tagId);
        return result;
    }
    public String queryTags() {
        String result = httpUtil.sendGet(query_tag + weiXinAccessTokenUtils.getAccessToken() + "&secret=" + appSecret, "");
        return result;
    }
}

patient-co/patient-co-wlyy/src/main/resources/weixin_menu.txt → patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu.txt


+ 92 - 0
patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu_jimei.txt

@ -0,0 +1,92 @@
{
"button":[
   {
	  "name":"家庭医生",
	  "sub_button":[
		  {
			"type":"view",
			"name":"签约管理",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fqygl%2fhtml%2fsigning_management.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		  },
		  {
			"type":"view",
			"name":"医生咨询",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fyszx%2fhtml%2fdoctor-consultation.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		  },
		  {
			"type":"view",
			"name":"医生指导",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fyszd%2fhtml%2fdoctor-guidance.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		  },
		  {
            "type":"view",
            "name":"健康文章",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkjy%2fhtml%2farticle_list.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
          }
	  ]
   },
   {
	  "name":"健康管理",
	  "sub_button":[
		 {
			  "type":"view",
			  "name":"预约挂号",
			  "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fwdyy%2fhtml%2fappointment-register.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		 },
		 {
               "type":"view",
               "name":"健康记录",
               "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkjl%2fhtml%2fhealth-record.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
		{
			"type":"click",
			"name":"健康档案",
			"key":"jiankangdangan"
		},
         {
            "type":"view",
            "name":"疾病社区",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjbsq%2fhtml%2fdisease-community.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        },
        {
            "type":"view",
            "name":"热量查询",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2frlcx%2fhtml%2fserach-index.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        }
	  ]
   },
   {
	  "name":"我的",
	  "sub_button":[
		{
		   "type":"view",
		   "name":"我的资料",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fgrzx%2fhtml%2fmy-detail.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
        {
           "type":"view",
           "name":"我的家庭",
           "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjtgx%2fhtml%2ffamily.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        },
		{
		   "type":"view",
		   "name":"我的设备",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fwdsb%2fhtml%2fmy-equipments.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
        {
         	"type":"click",
         	"name":"操作说明",
         	"key":"caozuoshuoming"
        },
        {
        	 "type":"view",
        	 "name":"集美反馈",
        	 "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fyjfk%2fhtml%2ffeedback.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        }
	 ]
  }],
    "matchrule":{
      "tag_id":"105"
      }
}