Kaynağa Gözat

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

humingfen 7 yıl önce
ebeveyn
işleme
9f7de123f5
48 değiştirilmiş dosya ile 1645 ekleme ve 257 silme
  1. BIN
      classes/production/JkEdu/com/yihu/jk/api/ArticleApi.class
  2. BIN
      classes/production/JkEdu/com/yihu/jk/dao/ArticleDao.class
  3. 19 25
      common/common-entity/src/main/java/com/yihu/wlyy/entity/device/DeviceDetail.java
  4. 84 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/device/DeviceWxMessage.java
  5. 105 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/device/vo/DeviceWxMessageDTO.java
  6. 1 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java
  7. 10 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/Patient.java
  8. 11 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Patient.java
  9. 11 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/PatientHealthIndex.java
  10. 1 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java
  11. 52 0
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/DeviceTypeConvert.java
  12. 66 0
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/UseDeviceTypeConvert.java
  13. 96 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/DeviceMeasureListener.java
  14. 17 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/StartListener.java
  15. 20 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  16. 2 0
      patient-co/patient-co-wlyy-job/src/main/resources/application-dev.yml
  17. 3 0
      patient-co/patient-co-wlyy-job/src/main/resources/application-devtest.yml
  18. 2 0
      patient-co/patient-co-wlyy-job/src/main/resources/application-prod.yml
  19. 2 0
      patient-co/patient-co-wlyy-job/src/main/resources/application-test.yml
  20. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DeviceDetailDao.java
  21. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  22. 12 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/DeviceWxMessageDao.java
  23. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java
  24. 90 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/DeviceWxMessageService.java
  25. 7 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceLogService.java
  26. 14 11
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java
  27. 25 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  28. 228 26
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  29. 81 23
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java
  30. 84 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/health/bank/CreditLogService.java
  31. 124 15
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/applets/AppletsService.java
  32. 50 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SecretUtils.java
  33. 57 12
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java
  34. 20 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java
  35. 31 15
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistController.java
  36. 44 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java
  37. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/survey/PatientQuestionnaireController.java
  38. 9 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  39. 1 72
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/health/bank/CreditsLogController.java
  40. 88 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/ylzpay/ThirdOnepayController.java
  41. 37 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/zysoft/BookingController.java
  42. 58 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/AppletsController.java
  43. 7 1
      patient-co/patient-co-wlyy/src/main/resources/application-dev.yml
  44. 7 1
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml
  45. 42 32
      patient-co/patient-co-wlyy/src/main/resources/application-local.yml
  46. 6 0
      patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml
  47. 8 1
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml
  48. 6 1
      patient-co/patient-co-wlyy/src/main/resources/application-test.yml

BIN
classes/production/JkEdu/com/yihu/jk/api/ArticleApi.class


BIN
classes/production/JkEdu/com/yihu/jk/dao/ArticleDao.class


+ 19 - 25
common/common-entity/src/main/java/com/yihu/wlyy/entity/device/DeviceDetail.java

@ -31,19 +31,20 @@ public class DeviceDetail extends IdEntity{
    private String applicantMail;
    private Integer isGrant;
    private String grantAdminTeam;
    private String grantOrgCode;
    private Integer isBinding;
    private String grantHospital;
    private String bindingCount;
    private Date grantTime;
    private String deviceActivityType;
    /** default constructor */
    public DeviceDetail() {
    }
    /** full constructor */
    public DeviceDetail(String deviceName, String deviceModel, String deviceCode, String manufacturer, String applyDate, String orgName, String linkman, String tel, String serverIp, String manufacturerCode, String address, String representative, String applicantName, String applicantIdentity, String applicantTel, String applicantMail, Integer isGrant, String grantAdminTeam, String grantOrgCode, Integer isBinding, String bindingCount, Date grantTime) {
    public DeviceDetail(String deviceName, String deviceModel, String deviceCode, String manufacturer, String applyDate
            , String orgName, String linkman, String tel, String serverIp, String manufacturerCode, String address
            , String representative, String applicantName, String applicantIdentity, String applicantTel, String applicantMail) {
        this.deviceName = deviceName;
        this.deviceModel = deviceModel;
        this.deviceCode = deviceCode;
@ -60,15 +61,8 @@ public class DeviceDetail extends IdEntity{
        this.applicantIdentity = applicantIdentity;
        this.applicantTel = applicantTel;
        this.applicantMail = applicantMail;
        this.isGrant = isGrant;
        this.grantAdminTeam = grantAdminTeam;
        this.grantOrgCode = grantOrgCode;
        this.isBinding = isBinding;
        this.bindingCount = bindingCount;
        this.grantTime = grantTime;
    }
    @Column(name = "device_name")
    public String getDeviceName() {
        return deviceName;
@ -231,22 +225,13 @@ public class DeviceDetail extends IdEntity{
        this.grantAdminTeam = grantAdminTeam;
    }
    @Column(name = "grant_org_code")
    public String getGrantOrgCode() {
        return grantOrgCode;
    }
    public void setGrantOrgCode(String grantOrgCode) {
        this.grantOrgCode = grantOrgCode;
    }
    @Column(name = "is_binding")
    public Integer getIsBinding() {
        return isBinding;
    @Column(name = "grant_hospital")
    public String getGrantHospital() {
        return grantHospital;
    }
    public void setIsBinding(Integer isBinding) {
        this.isBinding = isBinding;
    public void setGrantHospital(String grantHospital) {
        this.grantHospital = grantHospital;
    }
    @Column(name = "binding_count")
@ -266,4 +251,13 @@ public class DeviceDetail extends IdEntity{
    public void setGrantTime(Date grantTime) {
        this.grantTime = grantTime;
    }
    @Column(name = "device_activity_type")
    public String getDeviceActivityType() {
        return deviceActivityType;
    }
    public void setDeviceActivityType(String deviceActivityType) {
        this.deviceActivityType = deviceActivityType;
    }
}

+ 84 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/device/DeviceWxMessage.java

@ -0,0 +1,84 @@
package com.yihu.wlyy.entity.device;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by zd on 2018/01/10.
 */
@Entity
@Table(name = "wlyy_device_wx_message")
public class DeviceWxMessage extends IdEntity{
    private String patient;
    private String deviceName;
    private String deviceSn;
    //设备类型(1血糖仪 2血压计)
    private String categoryCode;
    private Date czrq;
    /** default constructor */
    public DeviceWxMessage() {
    }
    /** full constructor */
    public DeviceWxMessage(String patient, String deviceName, String deviceSn, String categoryCode, Date czrq) {
        this.patient = patient;
        this.deviceName = deviceName;
        this.deviceSn = deviceSn;
        this.categoryCode = categoryCode;
        this.czrq = czrq;
    }
    @Column(name = "device_name")
    public String getDeviceName() {
        return deviceName;
    }
    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }
    @Column(name = "device_sn")
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "category_code")
    public String getCategoryCode() {
        return categoryCode;
    }
    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
    }
    @Column(name = "czrq")
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 105 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/device/vo/DeviceWxMessageDTO.java

@ -0,0 +1,105 @@
package com.yihu.wlyy.entity.device.vo;
import java.util.Date;
/**
 * Created by zd on 2018/06/13.
 */
public class DeviceWxMessageDTO{
    private long id;
    //患者openId
    private String openId;
    //患者code
    private String patient;
    //患者名字
    private String patientName;
    //医生code
    private String doctor;
    //医生名称
    private String doctorName;
    //1血糖仪 2血压计
    private int deviceType;
    //创建时间
    private String czrq;
    /** default constructor */
    public DeviceWxMessageDTO() {
    }
    /** full constructor */
    public DeviceWxMessageDTO(long id, String openId, String patient, String patientName, String doctor, String doctorName, int deviceType, String czrq) {
        this.id = id;
        this.openId = openId;
        this.patient = patient;
        this.patientName = patientName;
        this.doctor = doctor;
        this.doctorName = doctorName;
        this.deviceType = deviceType;
        this.czrq = czrq;
    }
    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }
    public String getOpenId() {
        return openId;
    }
    public void setOpenId(String openId) {
        this.openId = openId;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    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 int getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(int deviceType) {
        this.deviceType = deviceType;
    }
    public String getCzrq() {
        return czrq;
    }
    public void setCzrq(String czrq) {
        this.czrq = czrq;
    }
}

+ 1 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java

@ -35,6 +35,7 @@ public class Message extends IdEntity {
	 *  113入群消息、114群解散消息、115踢出群消息、116新的网络咨询、117网络咨询追问、
	 *  201医生拒绝签约、202医生同意签约、203医生申请取消签约、204医生同意取消签约、205医生拒绝取消签约、206新的问卷随访、207新的健康干预、
	 *  208请求添加好友消息、209入群消息、210群解散消息、211踢出群消息、212聊天消息提醒、213群聊天消息、214医生回复了网络咨询、215请求添加为家人)
	 *	301解绑消息
	 */
	private Integer type;
	private Integer platform;// 消息平台,1微信端/患者端,2医生APP端

+ 10 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/Patient.java

@ -104,6 +104,8 @@ public class Patient extends IdEntity implements Serializable {
    private Integer standardStatus;
    //医疗保险号
    private String medicareNumber;
    //微信开发平台唯一标识
    private String unionid;
    public String getPrincipalCode() {
        return principalCode;
@ -467,4 +469,12 @@ public class Patient extends IdEntity implements Serializable {
    public void setMedicareNumber(String medicareNumber) {
        this.medicareNumber = medicareNumber;
    }
    public String getUnionid() {
        return unionid;
    }
    public void setUnionid(String unionid) {
        this.unionid = unionid;
    }
}

+ 11 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Patient.java

@ -80,6 +80,8 @@ public class Patient extends IdEntity implements Serializable {
	private Integer status;
    //联系方式备注【基卫】mobile_remarks
    private String mobileRemarks;
	//微信开放平台主键
	private String unionId;
	public Patient() {
	}
@ -325,7 +327,15 @@ public class Patient extends IdEntity implements Serializable {
        this.mobileRemarks = mobileRemarks;
    }
    @Transient
	public void setUnionId(String unionId) {
		this.unionId = unionId;
	}
	public String getUnionId() {
		return unionId;
	}
	@Transient
	public String getDiseaseName() {//0健康,1高血压,2糖尿病,3高血压+糖尿病
		if(disease==null){
			this.diseaseName = "";

+ 11 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/PatientHealthIndex.java

@ -50,6 +50,8 @@ public class PatientHealthIndex extends IdEntity {
	private Integer status;//状态:0为标准,1为异常
	private Integer manageResult;//异常数据处理 0未干预 1异常有效干预 2异常无效干预
	public String getUser() {
		return user;
	}
@ -192,4 +194,13 @@ public class PatientHealthIndex extends IdEntity {
	public void setStatus(Integer status) {
		this.status = status;
	}
	@Column(name = "manage_result")
	public Integer getManageResult() {
		return manageResult;
	}
	public void setManageResult(Integer manageResult) {
		this.manageResult = manageResult;
	}
}

+ 1 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java

@ -835,6 +835,7 @@ public class DeviceService extends BaseService{
            obj.setDel("1");
            obj.setRecordDate(time);    //记录时间
            obj.setSortDate(time);      //排序时间
            obj.setManageResult(0);//默认数据是医生未干预状态
            String user = device.getUser();
            obj.setUser(user);

+ 52 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/DeviceTypeConvert.java

@ -0,0 +1,52 @@
package com.yihu.wlyy.statistics.etl.convert.wlyy;
import com.yihu.wlyy.entity.dimension.WlyyDimensionQuota;
import com.yihu.wlyy.statistics.etl.convert.Convert;
import com.yihu.wlyy.statistics.util.Contant;
import com.yihu.wlyy.statistics.util.IdCardUtil;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/6/5.
 */
public class DeviceTypeConvert implements Convert {
    /**
     * @param oneList    数据
     * @param slaveLevel 从1开始
     * @return
     */
    @Override
    public List<DataModel> convert(JdbcTemplate jdbcTemplate,List<DataModel> oneList, String slaveLevel, WlyyDimensionQuota temp) {
        String sql = temp.getDictSql();
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
        for(DataModel one:oneList) {
            try {
                String key = getKey(one,result);
                DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(one, key);
            } catch (Exception e) {
                e.printStackTrace();
            }
        };
        return oneList;
    }
    public String getKey(DataModel dataModel,List<Map<String,Object>> dict){
        for (Map<String,Object> one : dict){
            String result = one.get("name")+"";
            if(dataModel.getServerType().equals(result)||dataModel.getServerType().indexOf(result)>0){
                return one.get("code")+"";
            }
        }
        return "";
    }
}

+ 66 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/UseDeviceTypeConvert.java

@ -0,0 +1,66 @@
package com.yihu.wlyy.statistics.etl.convert.wlyy;
import com.yihu.wlyy.entity.dimension.WlyyDimensionQuota;
import com.yihu.wlyy.statistics.etl.convert.Convert;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/6/5.
 */
public class UseDeviceTypeConvert implements Convert {
    /**
     * @param oneList    数据
     * @param slaveLevel 从1开始
     * @return
     */
    @Override
    public List<DataModel> convert(JdbcTemplate jdbcTemplate,List<DataModel> oneList, String slaveLevel, WlyyDimensionQuota temp) {
        String sql = temp.getDictSql();
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
        Map<String,Object> map = null;
        for(DataModel one:oneList) {
            try {
                map = getTeam(one,jdbcTemplate);
                if(map!=null){
                    one.setTeam(map.get("grant_admin_team")+"");
                    one.setServerType(map.get("device_name")+"");
                }else{
                    continue;
                }
                String key = getKey(one,result);
                DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(one, key);
            } catch (Exception e) {
                e.printStackTrace();
            }
        };
        return oneList;
    }
    public String getKey(DataModel dataModel,List<Map<String,Object>> dict){
        for (Map<String,Object> one : dict){
            String result = one.get("name")+"";
            if(dataModel.getServerType().equals(result)||dataModel.getServerType().indexOf(result)>0){
                return one.get("code")+"";
            }
        }
        return "";
    }
    public Map<String,Object> getTeam(DataModel dataModel,JdbcTemplate jdbcTemplate){
        String deviceCode =  dataModel.getHealthProblem();
        String sql = " select * from device.wlyy_devices d where d.device_code ='"+deviceCode+"' and is_grant=1";
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
        if(result.size()>0){
            return result.get(0);
        }
        return null;
    }
}

+ 96 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/DeviceMeasureListener.java

@ -0,0 +1,96 @@
package com.yihu.wlyy.activemq;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import java.util.Date;
/**
 * Created by zhangdan on 2018/06/13.
 * 设备测量监听
 */
@Component
public class DeviceMeasureListener implements MessageListener {
    private Logger logger = LoggerFactory.getLogger(DeviceMeasureListener.class);
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private PatientService patientService;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Override
    public void onMessage(Message message) {
        try {
            TextMessage textMessage = (TextMessage) message;
            JSONObject obj = JSONObject.fromObject(textMessage.getText());
            if(obj.get("patient")==null){
                return;
            }
            String patientCode = obj.get("patient")!=null?obj.get("patient").toString():null;
            Integer devcieType = obj.get("deviceType")!=null?(Integer)obj.get("deviceType"):null;
            String czrq = obj.get("czrq")!=null?(String)obj.get("czrq"):DateUtil.dateToStrLong(new Date());
            Patient patient = patientService.findByCode(patientCode);
            SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
            String doctorName = "";
            String name = "";
            String openId="";
            if (signFamily!=null){
                doctorName = signFamily.getDoctorName();
            }
            if (patient!=null){
                name = patient.getName();
                openId = patient.getOpenid();
            }
            org.json.JSONObject sendJson = new org.json.JSONObject();
            String first = "";
            String remark = "";
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_device_measure_notice","sbsltx");
            first = templateConfig.getFirst();
            first = first.replace("key1",(doctorName==null?"":doctorName+"(全科)"));
            remark = templateConfig.getRemark();
            sendJson.put("keyword1", name);
            sendJson.put("keyword2", czrq);
            if (devcieType==1){
                //血糖
                sendJson.put("keyword3", "血糖未测量");
                sendJson.put("keyword4","签约居民多采用社区发放的设备测量血糖,医生指导更准确!");
            }else if (devcieType==2){
                //血压
                sendJson.put("keyword3", "血压未测量");
                sendJson.put("keyword4","签约居民多采用社区发放的设备测量血压,医生指导更准确!");
            }
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            System.out.println(sendJson.toString());
            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 21, openId, name, sendJson);
            //返回服务器表示消息消费成功
            message.acknowledge();
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}

+ 17 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/StartListener.java

@ -26,16 +26,21 @@ public class StartListener {
    @Value("${activemq.queue.healtHarticleQueue}")
    private String healtHarticleQueue;
    @Value("${activemq.queue.deviceMeasurementRemindingQueue}")
    private String deviceMeasurementRemindingQueue;
    @Value("${activemq.consumers.count}")
    private Integer count;
    @Autowired
    private HealthArtListener healthArtListener;
    @Autowired
    private CachingConnectionFactory cachingConnectionFactory;
    @Autowired
    private DeviceMeasureListener deviceMeasureListener;
    @PostConstruct
    public void startListener() {
        startHealthArticQueueListener();
        startDeviceMeasureQueueListener();
    }
    /**
@ -51,6 +56,18 @@ public class StartListener {
        }
    }
    /**
     * 启动设备测量提醒监听
     */
    private void startDeviceMeasureQueueListener(){
        try {
            startReceiverByQueueName(deviceMeasureListener,deviceMeasurementRemindingQueue);
            logger.info("start deviceMeasureListener success");
        }catch (Exception e){
            logger.error("start deviceMeasureListener error");
        }
    }
    /**
     * 启动
     *

+ 20 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -58,6 +58,8 @@ public class PushMsgTask {
    private String template_doctor_audit;//审核结果通知
    @Value("${wechat.message.template_doctor_service}")
    private String template_doctor_service;//服务结果通知
    @Value("${wechat.message.template_device_measure_notice}")
    private String template_device_measure_notice;//设备测量提醒
    @Autowired
    private WechatPushLogDao wechatPushLogDao;
@ -650,6 +652,24 @@ public class PushMsgTask {
                keyword3.setColor("#000000");
                keyword3.setValue(json.getString("keyword3"));
                m.put("keyword3", keyword3);
            }else if (type==21){//设备测量提醒
                temp.setTemplate_id(template_device_measure_notice);
                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);
                WechatTemplateData keyword4 = new WechatTemplateData();
                keyword4.setColor("#000000");
                keyword4.setValue(json.getString("keyword4"));
                m.put("keyword4", keyword4);
            }
            temp.setData(m);

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

@ -69,6 +69,8 @@ wechat:
   template_doctor_audit:  OFyLUeBW3r9trWw-i6pbB1sPSTD4J2recCv_mc-gKxA
   #服务结果通知
   template_doctor_service:  ezr5RlX0nvh7bGU9aVsGDMJbjKDp1uMKP-AGGYXwI5g
   #设备测量提醒
   template_device_measure_notice: bzwLOFFPSe2vq74IljvVIPmvjP-C4ebEUAFORyq-2dY
yihu:
  yihu_OpenPlatform_url: http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/

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

@ -69,6 +69,8 @@ wechat:
    template_doctor_audit:  lCtOgJgL1tBJbAytqN7cn-FgCH_Usg99FENEy2TrC08
    #服务结果通知
    template_doctor_service: i34rq3xFLnpf_VN2Jor9n2YlQqJMM7oXyYvuctriISw
    #设备测量提醒
    template_device_measure_notice: bzwLOFFPSe2vq74IljvVIPmvjP-C4ebEUAFORyq-2dY
yihu:
  yihu_OpenPlatform_url: http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/
@ -105,6 +107,7 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_devtest
    deviceMeasurementRemindingQueue : deviceMeasurementChannel_test #设备测量提醒
  consumers:
    count: 10 #消费者集群数

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

@ -71,6 +71,8 @@ wechat:
   template_doctor_audit:  egrX5Larpkv8opQW67_hwsZoT0OHwwUpE1v7HeU_Jnw
   #服务结果通知
   template_doctor_service:  xhi1LEudiZwJfZylOHuZNo8EiA73GtSshPQv5XOt9Lk
   #设备测量提醒
   template_device_measure_notice: bzwLOFFPSe2vq74IljvVIPmvjP-C4ebEUAFORyq-2dY
yihu:
  yihu_OpenPlatform_url: http://api.yihu.com.cn/OpenPlatform/cgiBin/1.0/

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

@ -70,6 +70,8 @@ wechat:
   template_doctor_audit:  lCtOgJgL1tBJbAytqN7cn-FgCH_Usg99FENEy2TrC08
   #服务结果通知
   template_doctor_service:  i34rq3xFLnpf_VN2Jor9n2YlQqJMM7oXyYvuctriISw
   #设备测量提醒
   template_device_measure_notice: bzwLOFFPSe2vq74IljvVIPmvjP-C4ebEUAFORyq-2dY
yihu:
  yihu_OpenPlatform_url: http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DeviceDetailDao.java

@ -25,6 +25,6 @@ public interface DeviceDetailDao extends PagingAndSortingRepository<DeviceDetail
    void updateAfterBinding(String adminTeam, String hospital, String isFirstBinding,String deviceSn,int isBinding);
    @Modifying
    @Query("update DeviceDetail dd set dd.isBinding=0 where dd.deviceCode=?1")
    @Query("update DeviceDetail dd set dd.isBinding=?1 where dd.deviceCode=?2")
    void updateUnbindAll(int isbinding,String deviceSn);
}

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -120,4 +120,7 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Modifying
    @Query("delete from Message a   where a.receiver = ?1 and a.data = ?2 and a.type in (14,15) ")
    int setMessageDel(String doctor, String articleCode);
    @Query(" select a from Message a where a.type=?2 and a.del='1' and a.read=1 and a.receiver=?1 and a.over='1' order by a.createTime desc ")
    List<Message> findUnReadByReceiverAndType(String receiver,Integer type);
}

+ 12 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/DeviceWxMessageDao.java

@ -0,0 +1,12 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.device.DeviceWxMessage;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface DeviceWxMessageDao extends PagingAndSortingRepository<DeviceWxMessage, Long>, JpaSpecificationExecutor<DeviceWxMessage> {
}

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java

@ -82,4 +82,6 @@ public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
    //根据code获取地址
    @Query("select p.address from Patient p where p.code = ?1")
    String getAddress(String patient);
    Patient findByUnionid(String unionid);
}

+ 90 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/DeviceWxMessageService.java

@ -0,0 +1,90 @@
package com.yihu.wlyy.service.app.device;
import com.yihu.wlyy.entity.device.DeviceWxMessage;
import com.yihu.wlyy.entity.device.vo.DeviceWxMessageDTO;
import com.yihu.wlyy.repository.patient.DeviceWxMessageDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.utils.Clock;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Component
@Transactional(rollbackFor = Exception.class)
public class DeviceWxMessageService extends BaseService {
    private Clock clock = Clock.DEFAULT;
    @Autowired
    private DeviceWxMessageDao deviceWxMessageDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public List<DeviceWxMessageDTO> batchSaveAndSendActiveMq(String data)throws Exception{
        JSONArray jsonArray = new JSONArray(data);
        List<DeviceWxMessage> messageList = new ArrayList<>();
        for (int i=0;i<jsonArray.length();i++){
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            //DeviceWxMessage deviceWxMessage = (DeviceWxMessage) jsonArray.get(i);
            DeviceWxMessage deviceWxMessage = new DeviceWxMessage();
            deviceWxMessage.setPatient(jsonObject.getString("patient"));
            deviceWxMessage.setCategoryCode(jsonObject.getString("categoryCode"));
            deviceWxMessage.setDeviceName(jsonObject.getString("deviceName"));
            deviceWxMessage.setDeviceSn(jsonObject.getString("deviceSn"));
            deviceWxMessage.setCzrq(new Date());
            messageList.add(deviceWxMessage);
        }
        //批量插入数据
        deviceWxMessageDao.save(messageList);
        //放入队列的数据集
        List<DeviceWxMessageDTO> deviceWxMessageDTOS = new ArrayList<>();
        List<DeviceWxMessageDTO> deviceWxMessageDTOS1 = new ArrayList<>();
        for (DeviceWxMessage deviceWxMessage : messageList) {
            deviceWxMessageDTOS1.clear();
            deviceWxMessageDTOS1.addAll(deviceWxMessageDTOS);
            int i = 0;
            if (deviceWxMessageDTOS1.size()==0){
                DeviceWxMessageDTO deviceWxMessageDTO = new DeviceWxMessageDTO();
                deviceWxMessageDTO.setPatient(deviceWxMessage.getPatient());
                deviceWxMessageDTO.setDeviceType(Integer.valueOf(deviceWxMessage.getCategoryCode()));
                deviceWxMessageDTO.setCzrq(DateUtil.dateToStr(deviceWxMessage.getCzrq(),"yyyy-MM-dd HH:mm:ss"));
                deviceWxMessageDTOS.add(deviceWxMessageDTO);
            }else {
                for (DeviceWxMessageDTO wxMessageDto : deviceWxMessageDTOS1) {
                    i++;
                    //当居民没有重复的时候添加一条发送
                    if (i==deviceWxMessageDTOS1.size() && (!deviceWxMessage.getPatient().equals(wxMessageDto.getPatient()))){
                        DeviceWxMessageDTO deviceWxMessageDTO = new DeviceWxMessageDTO();
                        deviceWxMessageDTO.setPatient(deviceWxMessage.getPatient());
                        deviceWxMessageDTO.setDeviceType(Integer.valueOf(deviceWxMessage.getCategoryCode()));
                        deviceWxMessageDTO.setCzrq(DateUtil.dateToStr(deviceWxMessage.getCzrq(),"yyyy-MM-dd HH:mm:ss"));
                        deviceWxMessageDTOS.add(deviceWxMessageDTO);
                    }
                    //当居民code重复且设备类型不重复也添加一条发送
                    if (deviceWxMessage.getPatient().equals(wxMessageDto.getPatient()) && Integer.valueOf(deviceWxMessage.getCategoryCode())!=wxMessageDto.getDeviceType()){
                        DeviceWxMessageDTO deviceWxMessageDTO = new DeviceWxMessageDTO();
                        deviceWxMessageDTO.setPatient(deviceWxMessage.getPatient());
                        deviceWxMessageDTO.setDeviceType(Integer.valueOf(deviceWxMessage.getCategoryCode()));
                        deviceWxMessageDTO.setCzrq(DateUtil.dateToStr(deviceWxMessage.getCzrq(),"yyyy-MM-dd HH:mm:ss"));
                        deviceWxMessageDTOS.add(deviceWxMessageDTO);
                    }
                }
            }
        }
        return deviceWxMessageDTOS;
    }
}

+ 7 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceLogService.java

@ -64,7 +64,7 @@ public class PatientDeviceLogService extends BaseService {
        patientDeviceLogDao.save(patientDeviceLog);
    }
    public Map<String,Object> getDevicesList(String noGaugeDay,String isBinding,String categoryCode,int pageNo,int pageSize){
    public Map<String,Object> getDevicesList(String doctor,String noGaugeDay,String isBinding,String categoryCode,String isSend,int pageNo,int pageSize){
        List<Map<String,Object>> resultList =  new ArrayList<>();
        Map<String,Object> resultMap = new HashedMap();
        int start = (pageNo-1)*pageSize;
@ -72,8 +72,7 @@ public class PatientDeviceLogService extends BaseService {
                "  SELECT sf.name, pd.* FROM wlyy_patient_device_log pd" +
                "  LEFT JOIN wlyy_sign_family sf ON pd.patient = sf.patient" +
                "  WHERE" +
                "   pd.is_del = 1" +
                "  AND sf.`status` > 0" +
                "   pd.is_del = 1 and sf.doctor= ''" +doctor+"'"+
                "  ORDER BY" +
                "  create_time DESC) a" +
                " GROUP BY a.device_sn) b" +
@ -104,7 +103,12 @@ public class PatientDeviceLogService extends BaseService {
        if (!StringUtils.isEmpty(noGaugeDay) && StringUtils.equals("4",noGaugeDay)){
            sql += " and b.patient NOT IN (SELECT user FROM device.wlyy_patient_health_index WHERE  DATE_SUB(CURDATE(), INTERVAL 1 MONTH) > DATE(record_date))";
        }
        //发送消息要筛选未发送消息的设备
        if (StringUtils.isNotEmpty(isSend)){
            sql += " and b.device_sn NOT IN (SELECT device_sn FROM wlyy_device_wx_message WHERE TO_DAYS(czrq) = TO_DAYS(NOW()))";
        }
        sql += " limit ?,?";
        resultList = jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
        resultMap.put("data",resultList);
        return resultMap;

+ 14 - 11
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java

@ -1123,17 +1123,17 @@ public class PatientDeviceService extends BaseService {
        }
        return name;
    }
    
    /**
     * 根据病种类型,搜索已绑定设备的居民设备SN码
     * @param type 1高血压 2糖尿病
     */
    public com.alibaba.fastjson.JSONObject iotSearchPatientDeviceSN(String type,Integer page,Integer pageSize){
    
        if(page != 0){
            page = page - 1;
        }
        
        StringBuffer sql = new StringBuffer("select t.device_sn from");
        sql.append("  ( SELECT DISTINCT d.* FROM wlyy_patient_device d, wlyy_sign_family f WHERE f.`status` > 0 AND f.patient = d.`user` ) t, ");
        sql.append("    wlyy_patient p " );
@ -1141,18 +1141,18 @@ public class PatientDeviceService extends BaseService {
        sql.append("   and l.`status`=1 AND l.label_type = 3 and l.label='"+type+"'");
        sql.append(" WHERE t.user = p. CODE limit "+page+","+pageSize);
        List<String> list = jdbcTemplate.queryForList(sql.toString(),String.class);
        
        Integer count = 0;
    
        StringBuffer countsql = new StringBuffer("select count(t.device_sn) total from");
        countsql.append("  ( SELECT DISTINCT d.* FROM wlyy_patient_device d, wlyy_sign_family f WHERE f.`status` > 0 AND f.patient = d.`user` ) t, ");
        countsql.append("    wlyy_patient p " );
        countsql.append("  LEFT JOIN wlyy_sign_patient_label_info l on  p. CODE = l.patient");
        countsql.append("   and l.`status`=1 AND l.label_type = 3 and l.label='"+type+"'");
        countsql.append(" WHERE t.user = p. CODE ");
    
        count = jdbcTemplate.queryForObject(countsql.toString(),Integer.class);
    
        com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject();
        result.put("total",count);
        result.put("list",list);
@ -1201,15 +1201,18 @@ public class PatientDeviceService extends BaseService {
        if("2".equals(userType)){
            keyType = "2";
        }
        String sql = "SELECT binding_count FROM wlyy_devices WHERE device_code='"+deviceSn+"'";
        Map<String,Object> devicesMap = jdbcTemplate.queryForMap(sql);
        if (devicesMap!=null){
            JSONObject jsonObject =new JSONObject(String.valueOf(devicesMap.get("binding_count")));
        DeviceDetail deviceDetail = deviceDetailDao.findBySn(deviceSn);
        if (deviceDetail!=null && StringUtils.isNotEmpty(deviceDetail.getBindingCount())){
            JSONObject jsonObject =new JSONObject(String.valueOf(deviceDetail.getBindingCount()));
            if (jsonObject.getInt(keyType)>0){
                flag=false;
                msg="设备不是首次绑定";
                code = -20000;
            }
        }else {
            flag=false;
            msg="数据有问题!";
            code= -30000;
        }
        resultMap.put("flag",flag);
        resultMap.put("msg",msg);

+ 25 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -206,6 +206,20 @@ public class MessageService extends BaseService {
            articleMesJson.put("amount", 0);
        }
        //解绑设备消息
        List<Message> deviceUnbindList = messageDao.findUnReadByReceiverAndType(doctor,301);
        JSONObject deviceMesJson = new JSONObject();
        if (deviceUnbindList != null && deviceUnbindList.size() > 0) {
            deviceMesJson.put("amount", deviceUnbindList.size());
            JSONObject deviceJson = new JSONObject();
            deviceJson.put("title", "解绑消息");
            deviceJson.put("type", 301);
            deviceJson.put("msg", "你有"+deviceUnbindList.size()+"个居民解绑设备消息");
            deviceJson.put("msgTime", DateUtil.dateToStrLong(deviceUnbindList.get(0).getCreateTime()));
            deviceMesJson.put("lastMessage", deviceJson);
        }else{
            deviceMesJson.put("amount", 0);
        }
        JSONObject json = new JSONObject();
        json.put("imMsgCount", getImMsgAmount(doctor));//IM消息数量
@ -215,6 +229,7 @@ public class MessageService extends BaseService {
        json.put("prescription", prescriptionJson);//续方消息
        json.put("callService", callServiceMesJson);//协同服务消息
        json.put("articleCheck", articleMesJson);//健康文章审核消息
        json.put("deviceUnbind",deviceMesJson);//设备解绑消息
        return json;
    }
@ -665,4 +680,14 @@ public class MessageService extends BaseService {
            return false;
        }
    }
    public List<Map<String,Object>> getDevcieMessageByDoctorAndRead(String doctor,int read,int pageSize,int pageNo){
        /*PageRequest pageRequest = new PageRequest(pageNo, pageSize);
        Page<Message> msgs = messageDao.deviceByReceiver(doctor, 1,pageRequest);
        */
        int start = (pageNo-1)*pageSize;
        String sql = "select * from wlyy_message a where a.type = 301 and a.has_read= "+ read+" and a.receiver='"+doctor+"' order by a.czrq desc limit ?,?";
        List<Map<String,Object>> messagelist = jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
        return messagelist;
    }
}

+ 228 - 26
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -22,6 +22,7 @@ import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
@ -57,7 +58,10 @@ public class StatisticsESService {
    private SystemDictService systemDictService;
    @Autowired
    private StatisticsAllService statisticsAllService;
    @Value("${es.type.HealthEduArticlePatient}")
    private String esType;
    @Value("${es.index.HealthEduArticlePatient}")
    private String esIndex;
    @Autowired
    private StatisticsService statisticsService;
@ -937,7 +941,7 @@ public class StatisticsESService {
                json.put("amount", amount);
                result.add(json);
            }
            if (saveModels!=null && saveModels.size()==1 && saveModels.get(0).getId()==null) {
            if (saveModels!=null && saveModels.size()==1 && saveModels.get(0).getHospital()==null) {
                List<Map<String,Object>> resultList = DateUtil.findDates(dateFormat.parse(startDate), dateFormat.parse(DateUtil.getNextDay(endDate,1)));
                result.clear();
                for (Map<String,Object> map : resultList){
@ -990,7 +994,11 @@ public class StatisticsESService {
        String firstEnd = "";
        // 结束日期
        Calendar end = Calendar.getInstance();
        end.setTime(DateUtil.strToDate(endDate, DateUtil.YYYY_MM_DD));
        //因为统计时间是统计到当前时间的前一天,所以这里的时间是提前一天
        Calendar temp = Calendar.getInstance();
        temp.setTime(DateUtil.strToDate(endDate, DateUtil.YYYY_MM_DD));
        temp.add(Calendar.DAY_OF_MONTH, -1);
        end.setTime(temp.getTime());
        // 起始日期为周几
        int week = start.get(Calendar.DAY_OF_WEEK);
        int incre = 7 - week + 1;
@ -1083,7 +1091,10 @@ public class StatisticsESService {
                    range = df.format(saveModel.getQuotaDate());
                }
                JSONObject json = countResult.get(range);
                //因为上述时间集提前一天  但是前端是显示当前时间,所以这里给调整回去
                if(range.equals(df.format(temp.getTime()))){
                    json.put("range",endDate);
                }
                if (json != null) {
                    long amount = saveModel.getResult2().longValue();
                    json.put("amount", amount);
@ -1133,7 +1144,11 @@ public class StatisticsESService {
        start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
        // 结束日期
        Calendar end = Calendar.getInstance();
        end.setTime(DateUtil.strToDate(endDate, DateUtil.YYYY_MM_DD));
        //因为统计时间是统计到当前时间的前一天,所以这里的时间是提前一天
        Calendar temp = Calendar.getInstance();
        temp.setTime(DateUtil.strToDate(endDate, DateUtil.YYYY_MM_DD));
        temp.add(Calendar.DAY_OF_MONTH, -1);
        end.setTime(temp.getTime());
        // 日期集合
        List<Calendar> days = new ArrayList<>();
@ -1204,7 +1219,10 @@ public class StatisticsESService {
                    range = df.format(saveModel.getQuotaDate());
                }
                JSONObject json = countResult.get(range);
                //因为上述时间集提前一天  但是前端是显示当前时间,所以这里给调整回去
                if(range.equals(df.format(temp.getTime()))){
                    json.put("range",endDate);
                }
                if (json != null) {
                    long amount = saveModel.getResult2().longValue();
                    json.put("amount", amount);
@ -5156,31 +5174,105 @@ public class StatisticsESService {
        return saveModel.getResult2().longValue();
    }
    public Map<String,Object> getLevelDeviceAndBinding(String area, int level, int sort, String lowLevel, String year) throws Exception {
        String index_85 = "85";
        String index_86= "86";
    public Map<String,Object> getLevelDeviceAndBinding(String area, int level, int sort, String lowLevel, String year,String deviceType) throws Exception {
        String index_85 = "85";//设备发放量统计指标
        String index_86= "86";//设备绑定量统计指标
        String index_87= "87";//设备使用量统计指标
        String index_88= "88";//设备异常数据24H统计指标
        //String lastDate = year + "-06-30";
        //String timeKey = elasticsearchUtil.getQuotaTime();
        String timeKey = DateUtil.getStringDateShort();
        String timeKey = DateUtil.getStringDateShort();//当前时间
        String mondayTime = DateUtil.getMondayOfThisDate(new Date());//本周一开始时间
        String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level + 1) : lowLevel);
        List<Map<String, Object>> resultList = new ArrayList<>();
        Map<String,Object> resultMap = new HashedMap();
        DecimalFormat df = new DecimalFormat("0.00");
        List<Map<String, Object>> resultList = new ArrayList<>();
        //发放量
        List<SaveModel> allAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "", low_level);
        //绑定量
        List<SaveModel> bindingAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "", low_level);
        Integer totalAllNum = 0;
        Integer totalBindingNum = 0;
        for (SaveModel totalSaveModel : allAmountList){
            totalAllNum += totalSaveModel.getResult2().intValue();
        }
        for (SaveModel bindSaveModel : bindingAmountList){
            totalBindingNum += bindSaveModel.getResult2().intValue();
        SaveModel grantSaveModel = null;
        SaveModel bindingSaveModel = null;
        List<SaveModel> useSaveModel = null;
        SaveModel anomalySaveModel = null;
        String allCountSql = "";
        String anomalyCountSql ="";
//        List<SaveModel> grantList = null;//发放量折线图
//        List<SaveModel> bindingList = null;//绑定量折线图
        List<SaveModel> allAmountList = null;//发放量列表
        List<SaveModel> bindingAmountList = null;//绑定量列表
        switch (deviceType){
            case "1": {
                grantSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey,area,level, index_85,SaveModel.timeLevel_DDL,"hemopiezometer");
                bindingSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey,area,level, index_86,SaveModel.timeLevel_DDL,"hemopiezometer");
                allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where device_name like '%血压%'";
                useSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime,timeKey, area, level, index_87, SaveModel.timeLevel_ZL, "hemopiezometer", null, null);
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey,area,level, index_88,SaveModel.timeLevel_DDL,"hemopiezometer");
                anomalyCountSql =" SELECT COUNT(d.id) FROM device.wlyy_patient_health_index d where d.type =1 and d.status=1 and d.del=1";
//                grantList = elasticsearchUtil.findDateQuotaLevel1(timeKey,timeKey,area,level,index_85, SaveModel.timeLevel_DDL, "hemopiezometer", interval, null);
//                bindingList = elasticsearchUtil.findDateQuotaLevel1(timeKey,timeKey,area,level,index_86, SaveModel.timeLevel_DDL, "hemopiezometer", interval, null);
                allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "hemopiezometer","", low_level);
                bindingAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "hemopiezometer","", low_level);
                break;
            }
            case "2": {
                grantSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey,area,level, index_85,SaveModel.timeLevel_DDL,"glucometer");
                bindingSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey,area,level, index_86,SaveModel.timeLevel_DDL,"glucometer");
                allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where device_name like '%血糖%'";
                useSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime,timeKey, area, level, index_87, SaveModel.timeLevel_ZL, "glucometer", null, null);
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey,area,level, index_88,SaveModel.timeLevel_DDL,"glucometer");
                anomalyCountSql =" SELECT COUNT(d.id) FROM device.wlyy_patient_health_index d where d.type =2 and d.status=1 and d.del=1";
//                elasticsearchUtil.findDateQuotaLevel1(timeKey,timeKey,area,level,index_85, SaveModel.timeLevel_DDL, "glucometer", interval, null);
//                elasticsearchUtil.findDateQuotaLevel1(timeKey,timeKey,area,level,index_86, SaveModel.timeLevel_DDL, "glucometer", interval, null);
//                grantList = elasticsearchUtil.findDateQuotaLevel1(timeKey,timeKey,area,level,index_85, SaveModel.timeLevel_DDL, "hemopiezometer", interval, null);
//                bindingList = elasticsearchUtil.findDateQuotaLevel1(timeKey,timeKey,area,level,index_86, SaveModel.timeLevel_DDL, "hemopiezometer", interval, null);
                allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "glucometer","", low_level);
                bindingAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "glucometer","", low_level);
                break;
            }
            default: {
                grantSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey,area,level, index_85,SaveModel.timeLevel_DDL);
                bindingSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey,area,level, index_86,SaveModel.timeLevel_DDL);
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey,area,level, index_88,SaveModel.timeLevel_DDL);
                allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d ";
                anomalyCountSql =" SELECT COUNT(d.id) FROM device.wlyy_patient_health_index d where  d.status=1 and d.del=1";
                useSaveModel = elasticsearchUtil.findDateQuotaLevel0(mondayTime,timeKey, area, level, index_87, SaveModel.timeLevel_ZL,  null, null);
//                grantList = elasticsearchUtil.findDateQuotaLevel0(timeKey,timeKey,area,level,index_85, SaveModel.timeLevel_DDL,  interval, null);
//                bindingList = elasticsearchUtil.findDateQuotaLevel0(timeKey,timeKey,area,level,index_86, SaveModel.timeLevel_DDL,  interval, null);
                allAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL,"", low_level);
                bindingAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "", low_level);
            }
        }
        Integer allCount = jdbcTemplate.queryForObject(allCountSql,Integer.class);
//        Long total = elasticsearchUtil.excuteForLong(countSql,esIndex, esType);
        resultMap.put("totalAll",allCount);//采购量
        resultMap.put("totalGrant",grantSaveModel.getResult1());//发放量
        resultMap.put("totalBinding",bindingSaveModel.getResult1());//绑定量
        if(allCount>0){
            resultMap.put("totalGrantRange",df.format( grantSaveModel.getResult1() > 0.0? ((grantSaveModel.getResult1())/(allCount * 1.0000)*100):0.0)+"%");//发放率
            resultMap.put("totalBindingRange",df.format( bindingSaveModel.getResult1() > 0.0? ((bindingSaveModel.getResult1())/(grantSaveModel.getResult1() * 1.0000)*100):0.0)+"%");//绑定率
        }else{
            resultMap.put("totalGrantRange",0.0+"%");//发放率
            resultMap.put("totalBindingRange",0.0+"%");//绑定率
        }
        Double totalUseAccount = useSaveModel.size()>0?useSaveModel.get(0).getResult1():0.0;
        resultMap.put("totalUse",totalUseAccount);//本周使用量
        if(grantSaveModel.getResult1()>0){
            resultMap.put("totalUseRange",df.format( totalUseAccount > 0.0? ((totalUseAccount)/(grantSaveModel.getResult1() * 1.0000)*100):0.0)+"%");//本周使用率
        }else{
            resultMap.put("totalUseRange",0.0+"%");//本周使用率
        }
        Integer totalAnomaly = jdbcTemplate.queryForObject(anomalyCountSql,Integer.class);
        resultMap.put("totalAnomaly",totalAnomaly);//异常数据量
        resultMap.put("totalIntervene",anomalySaveModel.getResult1());//干预指导数
        if(totalAnomaly>0){
            resultMap.put("totalInterveneRange",df.format( anomalySaveModel.getResult1() > 0.0? ((anomalySaveModel.getResult1())/(totalAnomaly * 1.0000)*100):0.0)+"%");//异常数据24h干预指导率
        }else{
            resultMap.put("totalInterveneRange",0.0+"%");//异常数据24h干预指导率
        }
        resultMap.put("totalAll",totalAllNum);
        resultMap.put("totalBinding",totalBindingNum);
        resultMap.put("totalRange",getRange(totalBindingNum, totalAllNum, 2));
        Map<String, Integer> allMap = new HashMap<>(); //发放量的的列表转map
        if (allAmountList != null && allAmountList.size() > 0) {
@ -5202,7 +5294,6 @@ public class StatisticsESService {
        if (resultList != null && resultList.size() > 0) {
            Map<String, SaveModel> bingdingMap = new HashMap<>();
            DecimalFormat df = new DecimalFormat("0.0000");
            bindingAmountList.stream().forEach(one -> {
                if ("5".equals(low_level)) {
                    bingdingMap.put(one.getTeam(), one);
@ -5261,6 +5352,117 @@ public class StatisticsESService {
    }
//    public Map<String,Object> getLevelDeviceAndBinding(String area, int level, int sort, String lowLevel, String year) throws Exception {
//        String index_85 = "85";
//        String index_86= "86";
//        //String lastDate = year + "-06-30";
//        //String timeKey = elasticsearchUtil.getQuotaTime();
//        String timeKey = DateUtil.getStringDateShort();
//        String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level + 1) : lowLevel);
//        List<Map<String, Object>> resultList = new ArrayList<>();
//        Map<String,Object> resultMap = new HashedMap();
//
//        //发放量
//        List<SaveModel> allAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "", low_level);
//        //绑定量
//        List<SaveModel> bindingAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "", low_level);
//        Integer totalAllNum = 0;
//        Integer totalBindingNum = 0;
//        for (SaveModel totalSaveModel : allAmountList){
//            totalAllNum += totalSaveModel.getResult2().intValue();
//        }
//        for (SaveModel bindSaveModel : bindingAmountList){
//            totalBindingNum += bindSaveModel.getResult2().intValue();
//        }
//        resultMap.put("totalAll",totalAllNum);
//        resultMap.put("totalBinding",totalBindingNum);
//        resultMap.put("totalRange",getRange(totalBindingNum, totalAllNum, 2));
//
//        Map<String, Integer> allMap = new HashMap<>(); //发放量的的列表转map
//        if (allAmountList != null && allAmountList.size() > 0) {
//            for (SaveModel saveModel : allAmountList) {
//                if ("3".equals(low_level) && saveModel.getTown() != null) {
//                    allMap.put(saveModel.getTown(), saveModel.getResult2().intValue());
//                } else if ("4".equals(low_level) && saveModel.getHospital() != null) {
//                    allMap.put(saveModel.getHospital(), saveModel.getResult2().intValue());
//                } else if ("5".equals(low_level) && saveModel.getTeam() != null) {
//                    allMap.put(saveModel.getTeam(), saveModel.getResult2().intValue());
//                } else {
//                    continue;
//                }
//            }
//        }
//
//        //自建结果集
//        resultList = getLowLevelMapKey(level, low_level, area);
//
//        if (resultList != null && resultList.size() > 0) {
//            Map<String, SaveModel> bingdingMap = new HashMap<>();
//            DecimalFormat df = new DecimalFormat("0.0000");
//            bindingAmountList.stream().forEach(one -> {
//                if ("5".equals(low_level)) {
//                    bingdingMap.put(one.getTeam(), one);
//                } else if ("4".equals(low_level)) {
//                    bingdingMap.put(one.getHospital(), one);
//                } else if ("3".equals(low_level)) {
//                    bingdingMap.put(one.getTown(), one);
//                }
//            });
//            for (Map<String, Object> reMap : resultList) {
//                reMap.put("amount", reMap.get("amount") != null ? Long.valueOf(reMap.get("amount").toString()) : 0L);
//                int bindingAmount = 0;
//                Integer allAmount = 0;
//                //获取绑定数量
//                if (bingdingMap != null && bingdingMap.size() > 0) {
//                    SaveModel one = bingdingMap.get(reMap.get("code").toString());
//                    if (one != null) {
//                        bindingAmount = one.getResult2().intValue();
//                    }
//                }
//                if (allMap != null && allMap.size() > 0) {
//                    allAmount = allMap.get(reMap.get("code").toString());
//                    if (allAmount == null) {
//                        allAmount = 0;
//                    }
//                } else {
//                }
//                reMap.put("allNum", allAmount);
//                reMap.put("bindingNum", bindingAmount);
//                reMap.put("rate", getRange(bindingAmount, allAmount, 2));//续签率是 续签量/去年的签约数
//            }
//
//            if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
//                translateTeamLeaderName(resultList);
//            }
//            //对结果进行排序
//            Collections.sort(resultList, new Comparator<Map<String, Object>>() {
//                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
//                    int map1value = (int) o1.get("allNum");
//                    int map2value = (int) o2.get("allNum");
//
//                    if (map1value - map2value > 0) {
//                        return sort == 1 ? -1 : 1;
//                    } else if (map1value - map2value < 0) {
//                        return sort == 1 ? 1 : -1;
//                    } else {
//                        return 0;
//                    }
//                }
//            });
//            resultMap.put("list",resultList);
//            return resultMap;
//        } else {
//            return new HashedMap();
//        }
//    }
    /**
     * 查询签约
     *

+ 81 - 23
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java

@ -1,7 +1,10 @@
package com.yihu.wlyy.service.specialist;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
@ -13,20 +16,24 @@ import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
/**
 * Created by Trick on 2018/5/31.
 */
@Service
@Transactional
public class SpecialistService extends BaseService {
    @Autowired
@ -39,35 +46,51 @@ public class SpecialistService extends BaseService {
    private JdbcTemplate jdbcTemplate;
    @Value("${specialist.url}")
    private String specialistUrl;
    @Autowired
    private DoctorAdminTeamDao doctorAdminTeamDao;
    public String setPatientLabelInfo(List<SignPatientLabelInfo> list){
        if(list!=null&&list.size()>0){
            for(SignPatientLabelInfo signPatientLabelInfo : list){
                signPatientLabelInfo.setCzrq(new Date());
                signPatientLabelInfo.setStatus(1);
                List<SignPatientLabelInfo> s =  signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(signPatientLabelInfo.getPatient(),signPatientLabelInfo.getLabelType(),1);
                if(s==null||s.size()==0){
                    signPatientLabelInfo.setCzrq(new Date());
                    signPatientLabelInfo.setStatus(1);
                    signPatientLabelInfoDao.save(signPatientLabelInfo);
                }
            }
            signPatientLabelInfoDao.save(list);
        }
        return "1";
    }
    public List<Map<String,Object>> findHealthAssistant(){
    public List<Map<String,Object>> findHealthAssistant(String doctor){
        String sql="SELECT " +
                " d.`code`, " +
                " d.`name`, " +
                " d.photo " +
                " d.photo, " +
                " d.dept_name AS deptName, " +
                " d.dept, " +
                " d.job, " +
                " d.job_name AS jobName " +
                " FROM " +
                " wlyy_doctor d " +
                " wlyy_admin_team_member m " +
                " JOIN wlyy_doctor d ON d. CODE = m.doctor_code " +
                " WHERE " +
                " d.`level` = '4' " +
                " AND `status` = 1";
                " m.team_id = ( " +
                "  SELECT " +
                "   t.id " +
                "  FROM " +
                "   wlyy_admin_team t " +
                "  WHERE " +
                "   t.leader_code = '"+doctor+"' " +
                " )";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public List<Map<String,Object>> findHealthAssistantPatientCount()throws Exception{
        List<Map<String,Object>> list = findHealthAssistant();
    public List<Map<String,Object>> findHealthAssistantPatientCount(String doctor)throws Exception{
        List<Map<String,Object>> list = findHealthAssistant(doctor);
        if(list!=null&&list.size()>0){
            for(Map<String,Object> map:list){
                map.put("count",getAssistantPatientCount(map.get("code").toString()));
@ -78,7 +101,7 @@ public class SpecialistService extends BaseService {
    public Long getAssistantPatientCount(String doctor)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"getAssistantPatientCount",param);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/getAssistantPatientCount",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getLong("obj");
@ -86,6 +109,19 @@ public class SpecialistService extends BaseService {
        return 0L;
    }
    public JSONObject findPatientNoAssistant(String doctor,Integer page,Integer size)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        param.put("page",page);
        param.put("size",size);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/findPatientNoAssistant",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs;
        }
        return rs;
    }
    public List<SignPatientLabel> findLabelbyType(String type,Long teamCode){
        //自定义标签
@ -133,7 +169,7 @@ public class SpecialistService extends BaseService {
        param.put("doctor",doctor);
        param.put("labelType",labelType);
        param.put("labelCode",labelCode);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"getLabelpatientCount",param);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/getLabelpatientCount",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getLong("obj");
@ -145,7 +181,7 @@ public class SpecialistService extends BaseService {
    public Long findSpecialistPatientRelationCout(String doctor)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"findSpecialistPatientRelationCout",param);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/findSpecialistPatientRelationCout",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getLong("obj");
@ -156,7 +192,7 @@ public class SpecialistService extends BaseService {
    public JSONArray findNoLabelPatientRelation(String doctor)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"findNoLabelPatientRelation",param);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/findNoLabelPatientRelation",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getJSONArray("obj");
@ -169,7 +205,7 @@ public class SpecialistService extends BaseService {
        param.put("assistant",assistant);
        param.put("page",page);
        param.put("size",size);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"findPatientRelatioByAssistant",param);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/findPatientRelatioByAssistant",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getJSONArray("obj");
@ -178,15 +214,15 @@ public class SpecialistService extends BaseService {
    }
    public String saveHealthAssistant(String json)throws Exception{
    public Boolean saveHealthAssistant(String json)throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("json",json);
        HttpResponse response = HttpUtils.doPost(specialistUrl+"saveHealthAssistant",param);
        HttpResponse response = HttpUtils.doPost(specialistUrl+"svr-specialist/saveHealthAssistant",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getString("obj");
            return rs.getBoolean("obj");
        }
        return "";
        return false;
    }
    public JSONArray getPatientByLabel(String doctor,String labelType,String labelCode,Integer page,Integer size)throws Exception{
@ -196,7 +232,7 @@ public class SpecialistService extends BaseService {
        param.put("labelCode",labelCode);
        param.put("page",page);
        param.put("size",size);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"getPatientByLabel",param);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"svr-specialist/getPatientByLabel",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getJSONArray("obj");
@ -204,7 +240,14 @@ public class SpecialistService extends BaseService {
        return null;
    }
    public List<Map<String,Object>> findDoctorTeamMenmber(String doctor){
    public Map<String,Object> findDoctorTeamMenmber(String doctor){
        Map<String,Object> rs = new HashedMap();
        AdminTeam adminTeam =  doctorAdminTeamDao.findByLeaderCode(doctor);
        rs.put("adminTeam",adminTeam);
        String sql = "SELECT " +
                " d.`code`, " +
                " d. name, " +
@ -228,7 +271,9 @@ public class SpecialistService extends BaseService {
                " )";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
        rs.put("member",list);
        return rs;
    }
    public List<Map<String,Object>> getDoctorInHospital(String doctor,String name,Integer page,Integer size){
@ -263,5 +308,18 @@ public class SpecialistService extends BaseService {
        return list;
    }
    public JSONArray getDoctorPatientByName(String doctor,String nameKey,Integer page,Integer size) throws Exception{
        Map<String,Object> param = new HashedMap();
        param.put("doctor",doctor);
        param.put("nameKey",nameKey);
        param.put("page",page);
        param.put("size",size);
        HttpResponse response = HttpUtils.doGet(specialistUrl+"getDoctorPatientByName",param);
        JSONObject  rs = new JSONObject(response.getContent());
        if("succes".equals(rs.getString("message"))){
            return rs.getJSONArray("obj");
        }
        return null;
    }
}

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

@ -6,9 +6,15 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.app.device.PatientDeviceService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -46,6 +52,15 @@ public class CreditLogService {
    private StringRedisTemplate redisTemplate;
    @Autowired
    private PatientDeviceService patientDeviceService;
    
    @Autowired
    private PatientService patientService;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PatientDao patientDao;
@ -93,6 +108,9 @@ public class CreditLogService {
     * @return
     */
    public JSONObject insert(JSONObject object) throws Exception {
    
        JSONObject result = new JSONObject();
        
        init();
        String response = null;
        String integrate = getIntegrate("health:blank:integrate:"+object.getString("flag"));
@ -112,7 +130,72 @@ public class CreditLogService {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return JSONObject.parseObject(response);
    
        result = JSONObject.parseObject(response);
    
    
        String status = result.getString("status");
    
        logger.info("健康银行居民新增积分:"+result.toString());
        if ("200".equals(status)){
            List<Map<String,Object>> list = (List<Map<String,Object>>)result.get("detailModelList");
            if (list!=null && list.size()>0){
                //积分
                String integrateresult = String.valueOf(list.get(0).get("integrate"));
                String patientid = String.valueOf(list.get(0).get("patientId"));
                String total = String.valueOf(list.get(0).get("total"));
            
            
                try {
                    //@TODO 获取积分调用发送微信模板接口
                    Patient people = patientDao.findByCode(patientid);
                    String openId = people.getOpenid();
                    String name = people.getName();
                
                    org.json.JSONObject sendJson = new org.json.JSONObject();
                    String first = "";
                    String remark = "";
                    String urlresult = "";
                
                    WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_healthbank_credit","jfdztz");
                    first = templateConfig.getFirst();
                    remark = templateConfig.getRemark();
//                    String keyword1 = templateConfig.getKeyword1();
                
                    sendJson.put("keyword1", integrateresult);
                    sendJson.put("keyword2", DateUtil.getStringDate());
                    sendJson.put("keyword3", total);
                    sendJson.put("first", first);
                    sendJson.put("remark", remark);
                    urlresult = templateConfig.getUrl();
                    urlresult = urlresult.replace("key1",(integrate==null?"":integrate));
                    sendJson.put("url", urlresult);//带参数的模板跳转链接
                    System.out.println(sendJson.toString());
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 23, openId, name, sendJson);
//	                    //发送代理人
//	                    jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
//	                    if (jsonArray != null && jsonArray.length() > 0) {
//		                    for (int i = 0; i < jsonArray.length(); i++) {
//			                    org.json.JSONObject j = jsonArray.getJSONObject(i);
//			                    Patient member = (Patient) j.get("member");
//			                    int start = url.indexOf("&toUser=");
//			                    int end = url.indexOf("&", start + 1);
//			                    String touser = url.substring(start, end);
//			                    url = url.replace(touser, "&toUser=" + member.getCode());
//			                    //name患者姓名
//			                    sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
//			                    sendJson.put("url", url);
//			                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
//		                    }
//	                    }
                }catch (Exception e){
                    logger.info("健康银行居民新增积分,微信模板消息发送失败:"+e.getMessage());
//	                        e.printStackTrace();
                }
            
            }
        }
        return result;
    }

+ 124 - 15
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/applets/AppletsService.java

@ -1,13 +1,24 @@
package com.yihu.wlyy.service.weixin.applets;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientAimSports;
import com.yihu.wlyy.repository.patient.PatientAimSportsDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.SecretUtils;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
@ -15,24 +26,122 @@ import java.util.Map;
 */
@Service
@Transactional
public class AppletsService {
public class AppletsService extends BaseService {
    private String appid = "wx47ecd9a6372e7c96";
    private String appSecret ="9df49ebba7d5cdf8b9a77213bbf36807";
    @Value("${applets.appId}")
    private String appid;
    @Value("${applets.appSecret}")
    private String appSecret;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private PatientAimSportsDao patientAimSportsDao;
    public Map<String,Object> checkApplets(String code) throws Exception{
    public Map<String, Object> checkApplets(String code) throws Exception {
        HttpUtils httpUtils = new HttpUtils();
        Map<String,Object> param = new HashedMap();
        param.put("appid",appid);
        param.put("secret",appSecret);
        param.put("js_code",code);
        param.put("grant_type","authorization_code");
        HttpResponse response = httpUtils.doGet("https://api.weixin.qq.com/sns/jscode2session",param);
        Map<String, Object> param = new HashedMap();
        param.put("appid", appid);
        param.put("secret", appSecret);
        param.put("js_code", code);
        param.put("grant_type", "authorization_code");
        HttpResponse response = httpUtils.doGet("https://api.weixin.qq.com/sns/jscode2session", param);
        JSONObject rs = new JSONObject(response.getContent());
        Map<String,Object> res = new HashedMap();
        res.put("openid",rs.getString("openid"));
        res.put("sessionKey",rs.getString("session_key"));
        Map<String, Object> res = new HashedMap();
        res.put("openid", rs.getString("openid"));
        res.put("sessionKey", rs.getString("session_key"));
        return res;
    }
}
    public JSONObject getWeRunData(String encryptedData, String iv, String sessionKey) throws Exception {
        String result = SecretUtils.AES128CBCdecrypt(encryptedData, iv, appid, sessionKey);
        JSONObject obj = new JSONObject(result);
        JSONArray jsonArray = obj.getJSONArray("stepInfoList");
        JSONObject jsonObject  = (JSONObject) jsonArray.get(jsonArray.length()-1);
        return jsonObject;
    }
    public List<Map<String,Object>> getPatientRankLine(Integer size){
        String sql ="SELECT " +
                " @rownum:=@rownum+1 AS rank , " +
                " s.patientcode AS patient, " +
                " p.`name`, " +
                " p.photo, " +
                " s.daily_step_count AS stepCount " +
                " FROM " +
                " (SELECT@rowNum := 0) b, " +
                " wlyy_patient_aim_sports s " +
                "  JOIN wlyy_patient p ON s.patientcode = p.`code`  " +
                " WHERE " +
                " s.create_time > timestamp(date(sysdate())) " +
                " ORDER BY daily_step_count DESC  " +
                " LIMIT 0,"+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public Map<String,Object> getPatientRank(String patient){
        String sql = "SELECT " +
                " r.rank, " +
                " r.patientcode " +
                " FROM  " +
                " ( " +
                " SELECT " +
                " @rownum :=@rownum + 1 AS rank, " +
                " s.patientcode " +
                " FROM " +
                " wlyy_patient_aim_sports s, " +
                " (SELECT@rowNum := 0) b " +
                " WHERE " +
                " s.create_time > timestamp(date(sysdate())) " +
                " ORDER BY daily_step_count DESC " +
                " ) r  " +
                " WHERE r.patientcode = '"+patient+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list.get(0);
    }
    public Boolean setPatientStep(String patient,Integer step){
        String sql = "SELECT " +
                " s.id, " +
                " s.patientcode " +
                " FROM " +
                " wlyy_patient_aim_sports s " +
                " WHERE " +
                " s.create_time > timestamp(date(sysdate())) " +
                " AND s.patientcode='"+patient+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){
            Integer id = (Integer)list.get(0).get("id");
            PatientAimSports patientAimSports =  patientAimSportsDao.findOne(id.longValue());
            patientAimSports.setDailyStepCount(step);
            patientAimSportsDao.save(patientAimSports);
        }else{
            PatientAimSports patientAimSports = new PatientAimSports();
            patientAimSports.setCode(getCode());
            patientAimSports.setDailyStepCount(step);
            patientAimSports.setCreateTime(new Date());
            patientAimSports.setPatientcode(patient);
            patientAimSportsDao.save(patientAimSports);
        }
        return true;
    }
    public Map<String,Object> getPatientByUid(String unionid){
        Patient patient = patientDao.findByUnionid(unionid);
        Map<String,Object> map = new HashedMap();
        map.put("patient",patient.getCode());
        map.put("patientName",patient.getName());
        map.put("photo",patient.getPhoto());
        return map;
    }
}

+ 50 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SecretUtils.java

@ -0,0 +1,50 @@
package com.yihu.wlyy.util;
import net.sf.json.JSONObject;
import org.apache.commons.codec.binary.Base64;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.AlgorithmParameters;
import java.security.Security;
/**
 * Created by Trick on 2018/6/11.
 */
public class SecretUtils {
    public static String AES128CBCdecrypt(String encryptedData, String iv, String appId, String sessionKey) throws Exception {
        //System.out.println("encryptedData: "+encryptedData);
        // 被加密的数据
        byte[] dataByte = Base64.decodeBase64(encryptedData);
        // 加密秘钥
        byte[] keyByte = Base64.decodeBase64(sessionKey);
        // 偏移量
        byte[] ivByte = Base64.decodeBase64(iv);
        Security.addProvider(new BouncyCastleProvider());
        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding", "BC");
        SecretKeySpec spec = new SecretKeySpec(keyByte, "AES");
        AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES");
        parameters.init(new IvParameterSpec(ivByte));
        cipher.init(Cipher.DECRYPT_MODE, spec, parameters);// 初始化
        byte[] resultByte = cipher.doFinal(dataByte);
        if (null != resultByte && resultByte.length > 0) {
            String result = new String(resultByte, "UTF-8");
            //获取30天微信运动情况
//            JSONObject obj = JSONObject.fromObject(result);
//            JSONObject watermark = obj.getJSONObject("watermark");
//            if (!watermark.getString("appid").equals(appId)) {
//                throw new Exception("与小程序appid不符合");
//            }
//            if (System.currentTimeMillis() - watermark.getLong("timestamp") * 1000 > 10000) {
//                throw new Exception("验证时间过长");
//            }
            return result;
        }
        return null;
    }
}

+ 57 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java

@ -3,7 +3,9 @@ package com.yihu.wlyy.web.doctor.device;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.device.DeviceWxMessage;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.device.vo.DeviceWxMessageDTO;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.Patient;
@ -11,6 +13,7 @@ import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.app.device.DeviceDetailService;
import com.yihu.wlyy.service.app.device.DeviceWxMessageService;
import com.yihu.wlyy.service.app.device.PatientDeviceLogService;
import com.yihu.wlyy.service.app.device.PatientDeviceService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
@ -30,11 +33,18 @@ import org.json.JSONArray;
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.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -52,16 +62,12 @@ public class DoctorDeviceController extends BaseController {
	@Autowired
	private PatientDeviceService patientDeviceService;
	@Autowired
	private DeviceDetailService deviceDetailService;
	@Autowired
	private AdminTeamService adminTeamService;
	@Autowired
	private CreditLogService creditLogService;
	@Autowired
	private WechatTemplateConfigDao templateConfigDao;
	@Autowired
@ -76,6 +82,13 @@ public class DoctorDeviceController extends BaseController {
	private PatientDeviceLogService patientDeviceLogService;
	@Autowired
	private CommonUtil commonUtil;
	@Autowired
	private DeviceWxMessageService deviceWxMessageService;
	@Autowired
	private JmsTemplate jmsTemplate;
	@Value("${activemq.queue.deviceMeasurementRemindingQueue}")
	private String devcieChannelName;
	private ObjectMapper  objectMapper=new ObjectMapper();
@ -104,8 +117,8 @@ public class DoctorDeviceController extends BaseController {
	@RequestMapping(value = "SavePatientDeviceAndCredit",method = RequestMethod.POST)
	@ResponseBody
	@ObserverRequired
	public String SavePatientDeviceAndCredit(@ApiParam(name="data",value="设备数据json",defaultValue = "{\"user\":\"915cca0a-5b1d-11e6-834 4-fa163e8aee56\",\"deviceId\": \"3\",\"deviceName\": \"血压计-优瑞恩\",\"deviceSn\": \"16C000337\",\"categoryCode\": \"1\",\"userType\": \"-1\",\"agreementPhoto\":\"www.baidu.com\"}")
							 @RequestParam(value="data",required = true) String data) {
	public String SavePatientDeviceAndCredit(@ApiParam(name="data",value="设备数据json",defaultValue = "{\"user\":\"915cca0a-5b1d-11e6-834 4-fa163e8aee56\",\"deviceId\": \"3\",\"deviceName\": \"血压计-优瑞恩\",\"deviceSn\": \"16C000337\",\"categoryCode\": \"1\",\"userType\": \"-1\"}") @RequestParam(value="data",required = true) String data,
											 @ApiParam(name = "agreementPhoto",value = "协议图片临时路径")@RequestParam(value = "agreementPhoto",required = true)String agreementPhoto) {
		try {
			PatientDevice device = objectMapper.readValue(data,PatientDevice.class);
			// 设置操作医生标识
@ -114,8 +127,8 @@ public class DoctorDeviceController extends BaseController {
			if (doctor!=null){
				device.setDoctorName(doctor.getName());
			}
			if (StringUtils.isNotEmpty(device.getAgreementPhoto())){
				device.setAgreementPhoto(commonUtil.copyTempImage(device.getAgreementPhoto()));
			if (StringUtils.isNotEmpty(agreementPhoto)){
				device.setAgreementPhoto(commonUtil.copyTempImage(agreementPhoto));
			}
			//首绑和设备类型判断  判断是否可以增加积分
			Map<String,Object> checkMap = patientDeviceService.checkBindingFirstAndType(device);
@ -400,9 +413,10 @@ public class DoctorDeviceController extends BaseController {
	@RequestMapping(value = "/getDevicesList",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation(value = "医生端-设备管理中设备列表",notes = "设备列表")
	public String getDevicesList(@ApiParam(value = "未测量天数(1今日为测量 2七天未测量 3本月未测量 4超过一个月未测量)", name = "noGaugeDay") @RequestParam(value = "noGaugeDay",required = false)String noGaugeDay,
								 @ApiParam(value = "是否绑定(1绑定 2解绑)", name = "isBinding") @RequestParam(value = "isBinding",required = false)String isBinding,
								 @ApiParam(value = "设备类型(1血糖仪 2血压计)", name = "categoryCode") @RequestParam(value = "categoryCode",required = false)String categoryCode,
	public String getDevicesList(@ApiParam(value = "未测量天数(1今日为测量 2七天未测量 3本月未测量 4超过一个月未测量)", name = "noGaugeDay") @RequestParam(value = "noGaugeDay",required = true)String noGaugeDay,
								 @ApiParam(value = "是否绑定(1绑定 2解绑)", name = "isBinding") @RequestParam(value = "isBinding",required = true)String isBinding,
								 @ApiParam(value = "设备类型(1血糖仪 2血压计)", name = "categoryCode") @RequestParam(value = "categoryCode",required = true)String categoryCode,
								 @ApiParam(value = "今日是否发送消息(1未发送 2已发送)", name = "isSend") @RequestParam(value = "isSend",required = true)String isSend,
								 @ApiParam(name="page",value="第几页",defaultValue = "1") @RequestParam(value="page",required = true) String page,
								 @ApiParam(name="pageSize",value="",defaultValue = "10") @RequestParam(value="pageSize",required = true) String pageSize) {
		if (StringUtils.isBlank(pageSize)) {
@ -412,10 +426,41 @@ public class DoctorDeviceController extends BaseController {
			page = "1";
		}
		try {
			return  write(200,"查找成功!","data",patientDeviceLogService.getDevicesList(noGaugeDay,isBinding,categoryCode,Integer.valueOf(page),Integer.valueOf(pageSize)));
			return  write(200,"查找成功!","data",patientDeviceLogService.getDevicesList(getUID(),noGaugeDay,isBinding,categoryCode,isSend,Integer.valueOf(page),Integer.valueOf(pageSize)));
		} catch (Exception e) {
			error(e);
			return error( -1, "查询失败!");
		}
	}
	@RequestMapping(value = "/sendDeviceWxMessage",method = RequestMethod.POST)
	@ApiOperation("给没有测量的居民发送微信消息提醒")
	@ResponseBody
	public String sendDevcieWxMessage(@ApiParam(name = "data",value = "[{\"patient\":\"1\",\"deviceName\":\"同学1\",\"deviceSn\":\"123\",\"categoryCode\":\"1\"}]")
									  @RequestParam(value = "data",required = true)String data){
		try {
			List<DeviceWxMessageDTO> deviceWxMessageDTOList = deviceWxMessageService.batchSaveAndSendActiveMq(data);
			sender(deviceWxMessageDTOList);
			return write(200,"提醒成功!");
		}catch (Exception e){
			error(e);
			return error( -1, "提醒失败!");
		}
	}
	public void sender(List<DeviceWxMessageDTO> deviceWxMessageList){
		//发送到队列
		deviceWxMessageList.stream().forEach(one->{
			jmsTemplate.send(devcieChannelName, new MessageCreator() {
				@Override
				public Message createMessage(Session session) throws JMSException {
					TextMessage textMessage = session.createTextMessage();
					textMessage.setText(net.sf.json.JSONObject.fromObject(one).toString());
					return textMessage;
				}
			});
		});
	}
}

+ 20 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java

@ -13,6 +13,7 @@ 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.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -452,4 +453,23 @@ public class DoctorMessageController extends BaseController {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
    @RequestMapping(value = "deviceMessageDetailList",method = RequestMethod.GET)
    @ApiOperation("解绑消息详情列表")
    @ResponseBody
    public String deviceMessageDetailList(@ApiParam(name="page",value="第几页",defaultValue = "1") @RequestParam(value="page",required = true) String page,
                                          @ApiParam(name="pageSize",value="",defaultValue = "10") @RequestParam(value="pageSize",required = true) String pageSize){
        if (StringUtils.isBlank(pageSize)) {
            pageSize = "10";
        }
        if (page.equals("0")) {
            page = "1";
        }
        try {
           return write(200,"查询成功!","data",messageService.getDevcieMessageByDoctorAndRead(getUID(),1,Integer.valueOf(pageSize),Integer.valueOf(page)));
        }catch (Exception e){
            error(e);
            return error( -1, "查询失败!");
        }
    }
}

+ 31 - 15
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistController.java

@ -39,9 +39,9 @@ public class SpecialistController extends BaseController {
    @RequestMapping(value = "findHealthAssistant", method = RequestMethod.GET)
    @ApiOperation("获取所有计管师")
    public String findHealthAssistant() {
    public String findHealthAssistant(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor) {
        try {
            return write(200, "获取成功", "data", specialistService.findHealthAssistant());
            return write(200, "获取成功", "data", specialistService.findHealthAssistant(doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
@ -50,9 +50,9 @@ public class SpecialistController extends BaseController {
    @RequestMapping(value = "findHealthAssistantPatientCount", method = RequestMethod.GET)
    @ApiOperation("获取所有计管师下居民数目")
    public String findHealthAssistantPatientCount(){
    public String findHealthAssistantPatientCount(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor){
        try {
            return write(200, "获取成功", "data", specialistService.findHealthAssistantPatientCount());
            return write(200, "获取成功", "data", specialistService.findHealthAssistantPatientCount(doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
@ -61,7 +61,6 @@ public class SpecialistController extends BaseController {
    @RequestMapping(value = "findLabelbyType", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取标签")
    public String findLabelbyType(@ApiParam(name = "type", value = "标签类型") @RequestParam(required = true) String type,
                                  @ApiParam(name = "teamCode", value = "团队id") @RequestParam(required = false) Long teamCode) {
@ -74,7 +73,6 @@ public class SpecialistController extends BaseController {
    }
    @RequestMapping(value = "findLabelAndPatientCount", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取标签与居民数量")
    public String findLabelAndPatientCount(@ApiParam(name = "doctor", value = "医生") @RequestParam(required = true)String doctor,
                                           @ApiParam(name = "type", value = "标签类型") @RequestParam(required = true)String type,
@ -87,8 +85,7 @@ public class SpecialistController extends BaseController {
        }
    }
        @RequestMapping(value = "findSpecialistPatientRelationCout", method = RequestMethod.GET)
    @ResponseBody
    @RequestMapping(value = "findSpecialistPatientRelationCout", method = RequestMethod.GET)
    @ApiOperation("获取专科医生下未分配标签居民数目")
    public String findSpecialistPatientRelationCout(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true) String doctor) {
        try {
@ -101,7 +98,6 @@ public class SpecialistController extends BaseController {
    @RequestMapping(value = "findNoLabelPatientRelation", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取专科医生下未分配标签居民")
    public String findNoLabelPatientRelation(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true) String doctor) {
        try {
@ -113,7 +109,6 @@ public class SpecialistController extends BaseController {
    }
    @RequestMapping(value = "findPatientRelatioByAssistant", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取计管师下未分配标签居民")
    public String findPatientRelatioByAssistant(@ApiParam(name = "assistant", value = "计管师") @RequestParam(required = true) String assistant,
                                                @ApiParam(name = "page", value = "第几页,1开始") @RequestParam(required = true) Integer page,
@ -127,7 +122,6 @@ public class SpecialistController extends BaseController {
    }
    @RequestMapping(value = "saveHealthAssistant", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("分配计管师居民")
    public String saveHealthAssistant(String json) {
        try {
@ -139,7 +133,6 @@ public class SpecialistController extends BaseController {
    }
    @RequestMapping(value = "getPatientByLabel", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取标签下居民")
    public String getPatientByLabel(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor,
                                    @ApiParam(name = "labelType", value = "标签类型")@RequestParam(required = true) String labelType,
@ -155,8 +148,7 @@ public class SpecialistController extends BaseController {
    }
    @RequestMapping(value = "findDoctorTeamMenmber", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取团队成员")
    @ApiOperation("获取团队及团队成员")
    public String findDoctorTeamMenmber(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor) {
        try {
            return write(200, "获取成功", "data", specialistService.findDoctorTeamMenmber(doctor));
@ -167,7 +159,6 @@ public class SpecialistController extends BaseController {
    }
    @RequestMapping(value = "getDoctorInHospital", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取院内工作人员")
    public String getDoctorInHospital(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor,
                                      @ApiParam(name = "name", value = "医生姓名模糊") @RequestParam(required = false)String name,
@ -181,5 +172,30 @@ public class SpecialistController extends BaseController {
        }
    }
    @RequestMapping(value = "getDoctorPatientByName", method = RequestMethod.GET)
    @ApiOperation("搜索专科医生下的居民")
    public String getDoctorPatientByName(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor,
                                         @ApiParam(name = "name", value = "居民姓名模糊") @RequestParam(required = false)String nameKey,
                                         @ApiParam(name = "page", value = "第几页,1开始") @RequestParam(required = true)Integer page,
                                         @ApiParam(name = "size", value = "每页大小") @RequestParam(required = true)Integer size) {
        try {
            return write(200, "获取成功", "data", specialistService.getDoctorPatientByName(doctor,nameKey,page,size));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "findPatientNoAssistant", method = RequestMethod.GET)
    @ApiOperation(value = "获取未分配计管师居民列表")
    public String findPatientNoAssistant(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor,
                                       @ApiParam(name = "page", value = "第几页,1开始") @RequestParam(required = true)Integer page,
                                       @ApiParam(name = "size", value = "每页大小") @RequestParam(required = true)Integer size) {
        try {
            return write(200, "获取成功", "data", specialistService.findPatientNoAssistant(doctor,page,size));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
}

+ 44 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

@ -4,10 +4,14 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.device.DeviceDetail;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.device.PatientHealthTime;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.deviece.PatientHealthTimeDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.app.device.PatientDeviceLogService;
import com.yihu.wlyy.service.app.device.PatientDeviceService;
@ -17,7 +21,6 @@ import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.health.bank.CreditLogService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import io.swagger.annotations.Api;
@ -36,10 +39,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.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * 患者端:设备管理控制类
@ -74,6 +74,10 @@ public class PatientDeviceController extends BaseController {
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PatientDeviceLogService patientDeviceLogService;
    @Autowired
    private MessageDao messageDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Value("${yihu.yihu_OpenPlatform_url}")
    private String url;
@ -216,8 +220,12 @@ public class PatientDeviceController extends BaseController {
            //患者和设备是否首绑
            Map<String,Object> checkMap = patientDeviceService.checkBindingFirstAndType(device);
            boolean flag = (Boolean)checkMap.get("flag");
            int code = (Integer)checkMap.get("code");
            if (code==-30000){
                return write(-1,"设备不存在或者数据存在错误!");
            }
            Patient patient = patientService.findByCode(device.getUser());
            Patient patient = patientService.findByCode(getRepUID());
            if(!getUID().equals(getRepUID())&&device.getId()==null){
                device.setAgent(getRepUID());
                device.setAgentName(patient.getName());
@ -378,6 +386,36 @@ public class PatientDeviceController extends BaseController {
                // 删除设备
                patientDeviceService.deleteDevice(id, getRepUID());
//                patientDeviceService.deleteDevice(id, getUID());
                //居民自主解绑设备时发送消息给医生
                Patient patient = patientService.findByCode(getRepUID());
                SignFamily signFamily = signFamilyDao.findByPatient(patient.getCode());
                String messageContent =  "您的居民"+patient.getName()+"解绑了";
                if ("1".equals(pd.getCategoryCode())){
                    messageContent +="血糖仪,点击下方查看居民详情";
                }else if ("2".equals(pd.getCategoryCode())){
                    messageContent +="血压计,点击下方查看居民详情";
                }
                Message message = new Message();
                message.setCzrq(new Date());
                message.setCreateTime(new Date());
                message.setContent(messageContent);
                message.setRead(1);//设置未读
                message.setReceiver(signFamily.getDoctor());//设置接受医生的code
                message.setSender("admin");//设置发送的用户
                message.setSenderName("系统");
                message.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
                message.setSenderPhoto("");
                message.setTitle("解绑设备消息");
                message.setType(301);//解绑设备消息
                message.setReadonly(1);//是否只读消息
                message.setSex(1);
                message.setOver("1");//未处理
                message.setData("");
                message.setDel("1");
                messageDao.save(message);
                //全部解绑后去判断就更新设备表中是否绑定字段
                deviceDetailService.unBindUpdateIsBinding(pd.getDeviceSn());
                patientDeviceLogService.savePatientDeviceLog(pd,pd.getDeviceSn(),2,2);
                return success("设备已删除!");
            } else {
                return error(-1, "不存在该设备!");

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/survey/PatientQuestionnaireController.java

@ -32,7 +32,7 @@ import java.util.concurrent.ConcurrentHashMap;
@Controller
@RequestMapping(value = "/patient/questionnaire")
@Api(description = "居民端问卷调查")
public class PatientQuestionnaireController extends BaseController {
public class    PatientQuestionnaireController extends BaseController {
    @Autowired
    private PatientQuestionnaireService patientQuestionnaireService;
    @Autowired

+ 9 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -500,7 +500,14 @@ public class EsStatisticsController extends BaseController {
            level = elasticsearchUtil.changeLevel(level);
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
            if(index.indexOf("85")>0||index.indexOf("86")>0){
                if("1".equals(lowCode)){
                    lowCode="hemopiezometer";
                }else if("2".equals(lowCode)){
                    lowCode="glucometer";
                }
            }
            if (index != null) {
                for (String idx : indexes) {
                    if (org.springframework.util.StringUtils.isEmpty(year)) {
@ -2170,6 +2177,7 @@ public class EsStatisticsController extends BaseController {
    @ApiOperation("设备绑定统计")
    @ResponseBody
    public String lowlevel_device(
            @RequestParam(required = false) String deviceType,//1血压 2血糖 不传是所有设备
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) int sort,
@ -2186,7 +2194,7 @@ public class EsStatisticsController extends BaseController {
                lowLevel = level - 1 + "";
            }
            return write(200, "查询成功", "data", statisticsESService.getLevelDeviceAndBinding(area, elasticsearchUtil.changeLevel(level), sort, String.valueOf(elasticsearchUtil.changeLevel(Integer.valueOf(lowLevel))), year));
            return write(200, "查询成功", "data", statisticsESService.getLevelDeviceAndBinding(area, elasticsearchUtil.changeLevel(level), sort, String.valueOf(elasticsearchUtil.changeLevel(Integer.valueOf(lowLevel))), year,deviceType));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");

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

@ -40,16 +40,7 @@ public class CreditsLogController extends BaseController {
    @Autowired
    private CreditLogService service;
    @Autowired
    private PatientService patientService;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PatientDao patientDao;
    /**
     * 查询积分排名
@ -89,68 +80,6 @@ public class CreditsLogController extends BaseController {
        try {
            JSONObject object = JSONObject.parseObject(creditsDetail);
            JSONObject result = service.insert(object);
    
            String status = result.getString("status");
    
            logger.info("健康银行居民新增积分:"+result.toString());
            if ("200".equals(status)){
                List<Map<String,Object>> list = (List<Map<String,Object>>)result.get("detailModelList");
                if (list!=null && list.size()>0){
                    //积分
                    String integrate = String.valueOf(list.get(0).get("integrate"));
                    String patientid = String.valueOf(list.get(0).get("patientId"));
                    String total = String.valueOf(list.get(0).get("total"));
                    
                    
                    try {
                        //@TODO 获取积分调用发送微信模板接口
                        Patient people = patientDao.findByCode(patientid);
                        String openId = people.getOpenid();
                        String name = people.getName();
    
                        org.json.JSONObject sendJson = new org.json.JSONObject();
                        String first = "";
                        String remark = "";
                        String url = "";
    
                        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_healthbank_credit","jfdztz");
                        first = templateConfig.getFirst();
                        remark = templateConfig.getRemark();
//                    String keyword1 = templateConfig.getKeyword1();
    
                        sendJson.put("keyword1", integrate);
                        sendJson.put("keyword2", DateUtil.getStringDate());
                        sendJson.put("keyword3", total);
                        sendJson.put("first", first);
                        sendJson.put("remark", remark);
                        url = templateConfig.getUrl();
                        url = url.replace("key1",(integrate==null?"":integrate));
                        sendJson.put("url", url);//带参数的模板跳转链接
                        System.out.println(sendJson.toString());
                        pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 23, openId, name, sendJson);
//	                    //发送代理人
//	                    jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
//	                    if (jsonArray != null && jsonArray.length() > 0) {
//		                    for (int i = 0; i < jsonArray.length(); i++) {
//			                    org.json.JSONObject j = jsonArray.getJSONObject(i);
//			                    Patient member = (Patient) j.get("member");
//			                    int start = url.indexOf("&toUser=");
//			                    int end = url.indexOf("&", start + 1);
//			                    String touser = url.substring(start, end);
//			                    url = url.replace(touser, "&toUser=" + member.getCode());
//			                    //name患者姓名
//			                    sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
//			                    sendJson.put("url", url);
//			                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
//		                    }
//	                    }
                    }catch (Exception e){
                        logger.info("健康银行居民新增积分,微信模板消息发送失败:"+e.getMessage());
//	                        e.printStackTrace();
                    }
                }
            }
            return write(200,"添加成功","data",result);
        }catch (Exception e){
            error(e);

+ 88 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/ylzpay/ThirdOnepayController.java

@ -3,10 +3,13 @@ package com.yihu.wlyy.web.third.ylzpay;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.service.third.ylz.PayLogService;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
import com.yihu.wlyy.service.weixin.wxpay.service.OnePayService;
import com.yihu.wlyy.util.HttpClientUtil;
@ -16,13 +19,15 @@ import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.exception.PayException;
import com.ylzinfo.onepay.sdk.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -32,6 +37,7 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.List;
/**
 * Created by Reece on 2017/8/30/030.
@ -55,6 +61,8 @@ public class ThirdOnepayController extends WeixinBaseController {
    private HospitalMappingDao mappingDao;
    @Autowired
    ObjectMapper objectMapper;
    @Autowired
    private PatientDao patientDao;
    /**
     * 支付真正完成,异步回调返回支付参数 后台做数据操作
@ -123,5 +131,83 @@ public class ThirdOnepayController extends WeixinBaseController {
        //                记录log日志到数据库
        logService.saveHttpLog(isSuccess, config.getReceiveNotify(), "异步支付通知", "POST", null, params, responses, error, logService.onepayType);
    }
    
//
//    @RequestMapping(value = "bindCard", method = RequestMethod.POST)
//    @ApiOperation("查询绑卡信息")
//    @ResponseBody
//    public String bindCard(
//            @ApiParam(name = "uid", value = "居民CODE", defaultValue = "")
//            @RequestParam String uid,
//            @ApiParam(name = "repUid", value = "家人居民CODE", defaultValue = "")
//            @RequestParam String repUid) throws Exception {
//        try {
//            JSONObject json = new JSONObject();
//            String msg = null;
//
//            Patient people = patientDao.findByCode(uid);
//            String openid = people.getOpenid();
//            String ssc = people.getSsc();
//            String createType = "sicard";
//            if (!repUid.equals(uid)) {
//                createType = "family";
//                people = patientDao.findByCode(repUid);
//                ssc = people.getSsc();
//            }
//            if("undefined".equals(openid)|| StringUtils.isEmpty(openid)){
//                people.setOpenid(null);
//                patientDao.save(people);
//                return write(-1, "用户微信信息格式不正确!");
//            }
//
////            BindCard bindCard = pay.bindCard(patient, openid);
//            List<BindCard> bindCard = pay.bindCardList(openid);
//            String sicardUrl = pay.createSicard(uid, openid, createType);
//            for (BindCard cards : bindCard) {
//                String attachCardNo = cards.getAttachCardNo();
//                if (StringUtil.isNotEmpty(attachCardNo) && StringUtil.isNotEmpty(ssc) && ssc.equals(attachCardNo)) {
//                    String attachRelation = cards.getAttachRelation();
//                    String attachIdType = cards.getAttachIdType();
//                    String attachIdNo = cards.getAttachIdNo();
//                    String attachName = cards.getAttachName();
//                    json.put("attachRelation", attachRelation);
//                    json.put("attachCardNo", attachCardNo);
//                    json.put("attachIdType", attachIdType);
//                    json.put("attachIdNo", attachIdNo);
//                    json.put("attachName", attachName);
//                    json.put("bindStatus", "000000");
//                    json.put("sicardUrl", sicardUrl);
//                    msg = "查询绑卡信息成功!";
//                    return write(200, msg, "data", json);
//                } else {
//                    json.put("sicardUrl", sicardUrl);
//                    json.put("bindStatus", "030007");
//                    msg = "生成电子社保卡成功!";
//                }
//            }
//            if (bindCard.size() == 0 || bindCard == null) {
//                json.put("sicardUrl", sicardUrl);
//                json.put("bindStatus", "030007");
//                msg = "生成电子社保卡成功!";
//            }
//            return write(200, msg, "data", json);
//            /*if (bindCard != null) {
//                JSONObject json = new JSONObject(bindCard);
//                json.put("bindStatus", "000000");
//                json.put("sicardUrl", sicardUrl);
//                return write(200, "查询绑卡信息成功!", "data", json);
//            } else {
////                返回电子社保卡链接
//                JSONObject json = new JSONObject();
//                json.put("sicardUrl", sicardUrl);
//                json.put("bindStatus", "030007");
//                return write(200, "生成电子社保卡成功!", "data", json);
//            }*/
//
//        } catch (Exception e) {
//            error(e);
//            return write(-1, "查询电子社保卡失败!");
//        }
//    }
}

+ 37 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/zysoft/BookingController.java

@ -33,11 +33,9 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
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 org.springframework.web.bind.annotation.*;
import java.util.*;
@ -79,6 +77,9 @@ public class BookingController extends WeixinBaseController {
    private PushMsgTask pushMsgTask;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
@ -309,7 +310,38 @@ public class BookingController extends WeixinBaseController {
                              @ApiParam(name = "clinicCard", value = "市民卡号", defaultValue = "D57117706")
                              @RequestParam(value = "clinicCard", required = true) String clinicCard,
                              @ApiParam(name = "patientPhone", value = "患者手机", defaultValue = "13950116510")
                              @RequestParam(value = "patientPhone", required = true) String patientPhone) {
                              @RequestParam(value = "patientPhone", required = true) String patientPhone,
                              @ApiParam(name = "key", value = "验证码key")
                              @RequestParam(value = "key", required = true) String key,
                              @ApiParam(name = "openId", value = "openId")
                              @RequestParam(value = "openId", required = true) String openId,
                              @ApiParam(name = "text", value = "text")
                              @RequestParam(value = "text", required = true) String text
        ) {
    
        try{
            boolean pass = false;
            key = key.replaceFirst(":",":"+openId+"_");
        
            String captcha = redisTemplate.opsForValue().get(key);
            if (captcha != null && captcha.equals(text.toLowerCase())){
                pass = true;
                redisTemplate.delete(key);
            }
            
            if(!pass){
                return error(-1, "验证码校验失败");
            }
//            else{
//                return write(200, "ok", "pass", pass);
//            }
        
            
        } catch (Exception e){
            error(e);
            return error(-1, e.getMessage());
        }
        
        try {
            if (StringUtils.isEmpty(patientName)) {
                return error(-1, "未设置姓名!");

+ 58 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/AppletsController.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.wx;
import com.yihu.wlyy.service.weixin.applets.AppletsService;
import com.yihu.wlyy.util.SecretUtils;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -27,10 +28,66 @@ public class AppletsController extends WeixinBaseController {
    @RequestMapping(value = "/checkApplets", method = RequestMethod.GET)
    public String checkApplets(@ApiParam(name = "code", value = "小程序登录时获取的Code", required = true) @RequestParam(value = "code", required = true)String code){
        try {
            return write(200, "创建成功", "data", appletsService.checkApplets(code));
            return write(200, "请求成功", "data", appletsService.checkApplets(code));
        }catch (Exception e){
            error(e);
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "微信解密微信步数")
    @RequestMapping(value = "/getWeRunData", method = RequestMethod.GET)
    public String getWeRunData(String encryptedData,String iv,String sessionKey){
        try {
            return write(200, "请求成功", "data", appletsService.getWeRunData(encryptedData,iv,sessionKey));
        }catch (Exception e){
            error(e);
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "获取排行版列表")
    @RequestMapping(value = "/getPatientRankLine", method = RequestMethod.GET)
    public String getPatientRankLine(@ApiParam(name = "size", value = "显示前几名排行", required = true) @RequestParam(value = "size", required = true)Integer size) {
        try {
            return write(200, "请求成功", "data", appletsService.getPatientRankLine(size));
        } catch (Exception e) {
            error(e);
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "获取居民排行")
    @RequestMapping(value = "/getPatientRank", method = RequestMethod.GET)
    public String getPatientRank(@ApiParam(name = "patient", value = "居民code", required = true) @RequestParam(value = "patient", required = true)String patient) {
        try {
            return write(200, "请求成功", "data", appletsService.getPatientRank(patient));
        } catch (Exception e) {
            error(e);
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "设置居民步数")
    @RequestMapping(value = "/setPatientStep", method = RequestMethod.POST)
    public String setPatientStep(@ApiParam(name = "patient", value = "居民code", required = true) @RequestParam(value = "patient", required = true)String patient,
                                 @ApiParam(name = "step", value = "步数", required = true) @RequestParam(value = "step", required = true)Integer step) {
        try {
            return write(200, "请求成功", "data", appletsService.setPatientStep(patient,step));
        } catch (Exception e) {
            error(e);
            return error(-1, "失败");
        }
    }
    @ApiOperation(value = "根据unionId获取居民信息")
    @RequestMapping(value = "/getPatientByUid", method = RequestMethod.POST)
    public String getPatientByUid(@ApiParam(name = "unionId", value = "开放平台唯一标识", required = true) @RequestParam(value = "unionId", required = true)String unionId) {
        try {
            return write(200, "请求成功", "data", appletsService.getPatientByUid(unionId));
        } catch (Exception e) {
            error(e);
            return error(-1, "失败");
        }
    }
}

+ 7 - 1
patient-co/patient-co-wlyy/src/main/resources/application-dev.yml

@ -35,7 +35,7 @@ im:
#专病配置
specialist:
  url: http://localhost:10051/svr-specialist/
  url: http://localhost:10051/
#物联网配置
iot:
  url: http://192.168.131.24:8088/svr-iot/
@ -47,6 +47,11 @@ healthBank:
rehabilitation:
  url: http://localhost:10055/svr-rehabilitation/
#小程序
applets:
  appId: wx0e663ce069b5170c
  appSecret: 02de788ffea28f2aa3b9bf10312ab05e
wechat:
  appId: wxd03f859efdf0873d
  appSecret: 2935b54b53a957d9516c920a544f2537
@ -152,6 +157,7 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_dev  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel_dev #设备测量提醒
##如果是外网项目就是flase 内网是true
neiwang:

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

@ -35,7 +35,7 @@ im:
#专病配置
specialist:
  url: http://localhost:10051/svr-specialist/
  url: http://localhost:8070/
#物联网配置
iot:
#  url: http://192.168.131.24:8088/svr-iot/
@ -48,6 +48,11 @@ healthBank:
rehabilitation:
  url: http://localhost:10055/svr-rehabilitation/
#小程序
applets:
  appId: wx0e663ce069b5170c
  appSecret: 02de788ffea28f2aa3b9bf10312ab05e
wechat:
  appId: wx1f129f7b51701428
  appSecret: 988f005d8309ed1795939e0f042431fb
@ -155,6 +160,7 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_test  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel_test #设备测量提醒
##如果是外网项目就是flase 内网是true
neiwang:

+ 42 - 32
patient-co/patient-co-wlyy/src/main/resources/application-local.yml

@ -41,6 +41,11 @@ iot:
rehabilitation:
  url: http://localhost:10055/svr-rehabilitation/
#小程序
applets:
  appId: wx0e663ce069b5170c
  appSecret: 02de788ffea28f2aa3b9bf10312ab05e
wechat:
  appId: wxad04e9c4c5255acf
  appSecret: ae77c48ccf1af5d07069f5153d1ac8d3
@ -48,38 +53,42 @@ wechat:
  wechat_base_url: http%3a%2f%2fwww.xmtyw.cn%2fwlyy
  accId: gh_ffd64560fb21
  message:
     ##医生追加建议提醒 --签约邀请
     doctor_invitel_template: MQn79bx1ofb6hekhmRIuqLU7KjySJQzaBzrimgqVrzA
     #咨询回复
     template_consult_notice: 0mF_vHj-ILx8EH8DwzmAi7LqzjqYiU9IrSRRmziTZyc
     #签约成功
     template_sign_success: 0D2vYZVRzFz15p9Y_pkZ1DKutDq8UOsks79FXUKS0tA
     #签约失败
     template_sign_failed: My2VNERjJt4NXR4Ibh42pdrP6B6ka8rQxZeWinQh99s
     #健康指导提醒
     template_health_notice: uv31ES_VCmq3tBYtyGmEQvIwU_zh9LDhF3bFpbIUt5g
     #解约提醒
     template_termination:  C0tdXtA_8k-Cy4a1EkzQuI877vqaqAtRkc-e_Gsd7sk
     #预约成功
     template_appoint_success:  FY3Pqa66tHIE1Fv-irbFBPOh5cYP71fkOzfZKH4S-Fo
     #预约取消
     template_appoint_failed:  tldWEb9AN7p_RoHoD8ml0GxWW3V1V_mpEEhp2v6p56s
     #缴费提醒
     template_expenses_remind:  AcrlihhoGbm22A8cdFFDQ4u38ptRw0aiIPf-aGvNxMM
     #健康教育
     template_healthy_article: a5-ZGf-IUUULsuRNoHWQiBMU6pSYhLgPPqV67SjdLRo
     #医生变更
     template_doctor_change:  dtzSHImbPKfwcrjWlJEjAw3lGlvrLjsobSOE8g4adZA
     #问卷调查
     template_doctor_survey:  8ZWKJmoJ7VR7Uk4YS7aa0Z94QzCkxsyTW6R4CHhUJII
     #审核结果通知
     template_doctor_audit:  egrX5Larpkv8opQW67_hwsZoT0OHwwUpE1v7HeU_Jnw
     #服务结果通知
     template_doctor_service:  xhi1LEudiZwJfZylOHuZNo8EiA73GtSshPQv5XOt9Lk
     #体检报告提醒
     template_physical_examination:  jTsvKU3iFw0yiJi5ESyFGDTmFSVcWlMot3yHier39Vc
     #处理结果通知
     template_deal_with:  GyXCmXVYCD7PXi0IbHdPOD8apa-RQoSrSw-4-0pj9Go
   ##医生追加建议提醒 --签约邀请
   doctor_invitel_template: MQn79bx1ofb6hekhmRIuqLU7KjySJQzaBzrimgqVrzA
   #咨询回复
   template_consult_notice: 0mF_vHj-ILx8EH8DwzmAi7LqzjqYiU9IrSRRmziTZyc
   #签约成功
   template_sign_success: 0D2vYZVRzFz15p9Y_pkZ1DKutDq8UOsks79FXUKS0tA
   #签约失败
   template_sign_failed: My2VNERjJt4NXR4Ibh42pdrP6B6ka8rQxZeWinQh99s
   #健康指导提醒
   template_health_notice: uv31ES_VCmq3tBYtyGmEQvIwU_zh9LDhF3bFpbIUt5g
   #解约提醒
   template_termination:  C0tdXtA_8k-Cy4a1EkzQuI877vqaqAtRkc-e_Gsd7sk
   #预约成功
   template_appoint_success:  FY3Pqa66tHIE1Fv-irbFBPOh5cYP71fkOzfZKH4S-Fo
   #预约取消
   template_appoint_failed:  tldWEb9AN7p_RoHoD8ml0GxWW3V1V_mpEEhp2v6p56s
   #缴费提醒
   template_expenses_remind:  AcrlihhoGbm22A8cdFFDQ4u38ptRw0aiIPf-aGvNxMM
   #健康教育
   template_healthy_article: a5-ZGf-IUUULsuRNoHWQiBMU6pSYhLgPPqV67SjdLRo
   #医生变更
   template_doctor_change:  dtzSHImbPKfwcrjWlJEjAw3lGlvrLjsobSOE8g4adZA
   #代办事项
   template_doctor_survey:  8ZWKJmoJ7VR7Uk4YS7aa0Z94QzCkxsyTW6R4CHhUJII
   #审核结果通知
   template_doctor_audit:  egrX5Larpkv8opQW67_hwsZoT0OHwwUpE1v7HeU_Jnw
   #服务结果通知
   template_doctor_service:  xhi1LEudiZwJfZylOHuZNo8EiA73GtSshPQv5XOt9Lk
   #体检报告提醒
   template_physical_examination:  jTsvKU3iFw0yiJi5ESyFGDTmFSVcWlMot3yHier39Vc
   #处理结果通知
   template_deal_with:  GyXCmXVYCD7PXi0IbHdPOD8apa-RQoSrSw-4-0pj9Go
   #设备绑定结果通知
   template_patient_bind_device: 1GWPw6LFcSuz2LFTo6LhE-YY8abtmcKRvor1fUzfxBE
   #积分到账通知
   template_healthbank_credit: A2L6WBm1p6bDPYGkGnUmoMvpWlRruP2lapYwHfLV7Rg
yihu:
@ -138,6 +147,7 @@ activemq:
  url: tcp://10.95.22.168:61616
  queue:
    healtHarticleQueue: healthArticleChannel_devtest  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel_test #设备测量提醒
##如果是外网项目就是flase 内网是true
neiwang:

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

@ -40,6 +40,11 @@ iot:
rehabilitation:
  url: http://localhost:10055/svr-rehabilitation/
#小程序
applets:
  appId: wx0e663ce069b5170c
  appSecret: 02de788ffea28f2aa3b9bf10312ab05e
wechat:
  appId: wx1f129f7b51701428
  appSecret: 988f005d8309ed1795939e0f042431fb
@ -138,6 +143,7 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_devtest  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel_test #设备测量提醒
##如果是外网项目就是flase 内网是true
neiwang:

+ 8 - 1
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -34,7 +34,7 @@ im:
#专病配置
specialist:
  url: http://localhost:10051/svr-wlyy-specialist/
  url: http://127.0.0.1:10051/svr-wlyy-specialist/
#物联网配置
iot:
  url: http://192.168.131.24:8088/svr-iot/
@ -46,6 +46,11 @@ healthBank:
rehabilitation:
  url: http://localhost:10055/svr-rehabilitation/
#小程序
applets:
  appId: wx0e663ce069b5170c
  appSecret: 02de788ffea28f2aa3b9bf10312ab05e
wechat:
  appId: wxad04e9c4c5255acf
  appSecret: ae77c48ccf1af5d07069f5153d1ac8d3
@ -151,6 +156,8 @@ activemq:
  url: tcp://59.61.92.90:9103
  queue:
    healtHarticleQueue: healthArticleChannel  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel #设备测量提醒
##如果是外网项目就是flase 内网是true
neiwang:

+ 6 - 1
patient-co/patient-co-wlyy/src/main/resources/application-test.yml

@ -30,7 +30,7 @@ im:
#专病配置基础服务地址
specialist:
  url: http://172.19.103.33:10051/svr-specialist/
  url: http://172.19.103.33:9797/svr-wlyy-specialist/
#物联网配置
iot:
  url: http://172.19.103.33:8088/svr-iot/
@ -41,6 +41,10 @@ healthBank:
#康复计划配置
rehabilitation:
  url: http://localhost:10055/svr-rehabilitation/
#小程序
applets:
  appId: wx0e663ce069b5170c
  appSecret: 02de788ffea28f2aa3b9bf10312ab05e
wechat:
  appId: wx1f129f7b51701428
@ -145,6 +149,7 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_test  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel_test #设备测量提醒
##如果是外网项目就是flase,false会调用内网http接口项目提交  内网是true直接上传fastDfs
neiwang: