Explorar o código

1.4.8版本 设备统计分析功能代码提交

liuwenbin %!s(int64=7) %!d(string=hai) anos
pai
achega
a5471b9f7a
Modificáronse 46 ficheiros con 1556 adicións e 371 borrados
  1. 19 25
      common/common-entity/src/main/java/com/yihu/wlyy/entity/device/DeviceDetail.java
  2. 84 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/device/DeviceWxMessage.java
  3. 105 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/device/vo/DeviceWxMessageDTO.java
  4. 1 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java
  5. 10 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/Patient.java
  6. BIN=BIN
      edu-article/JkEdu/WebRoot/WEB-INF/classes/com/yihu/jk/api/ArticleApiTest.class
  7. BIN=BIN
      edu-article/JkEdu/WebRoot/WEB-INF/classes/com/yihu/jk/dao/ArticleDao.class
  8. 14 2
      edu-article/JkEdu/src/com/yihu/jk/api/ArticleApiTest.java
  9. 11 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Patient.java
  10. 48 17
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/compute/ComputeHelper.java
  11. 96 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/DeviceMeasureListener.java
  12. 17 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/StartListener.java
  13. 20 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  14. 2 0
      patient-co/patient-co-wlyy-job/src/main/resources/application-dev.yml
  15. 3 0
      patient-co/patient-co-wlyy-job/src/main/resources/application-devtest.yml
  16. 2 0
      patient-co/patient-co-wlyy-job/src/main/resources/application-prod.yml
  17. 2 0
      patient-co/patient-co-wlyy-job/src/main/resources/application-test.yml
  18. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DeviceDetailDao.java
  19. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  20. 12 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/DeviceWxMessageDao.java
  21. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java
  22. 90 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/DeviceWxMessageService.java
  23. 7 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceLogService.java
  24. 14 11
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java
  25. 25 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  26. 280 121
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  27. 39 18
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java
  28. 84 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/health/bank/CreditLogService.java
  29. 92 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/applets/AppletsService.java
  30. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SecretUtils.java
  31. 57 12
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java
  32. 23 15
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java
  33. 16 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistController.java
  34. 44 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java
  35. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/survey/PatientQuestionnaireController.java
  36. 111 14
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  37. 1 72
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/health/bank/CreditsLogController.java
  38. 88 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/ylzpay/ThirdOnepayController.java
  39. 37 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/zysoft/BookingController.java
  40. 47 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/AppletsController.java
  41. 2 1
      patient-co/patient-co-wlyy/src/main/resources/application-dev.yml
  42. 2 1
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml
  43. 37 32
      patient-co/patient-co-wlyy/src/main/resources/application-local.yml
  44. 1 0
      patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml
  45. 3 1
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml
  46. 2 1
      patient-co/patient-co-wlyy/src/main/resources/application-test.yml

+ 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;
    }
}

BIN=BIN
edu-article/JkEdu/WebRoot/WEB-INF/classes/com/yihu/jk/api/ArticleApiTest.class


BIN=BIN
edu-article/JkEdu/WebRoot/WEB-INF/classes/com/yihu/jk/dao/ArticleDao.class


+ 14 - 2
edu-article/JkEdu/src/com/yihu/jk/api/ArticleApiTest.java

@ -12,6 +12,9 @@ import com.coreframework.util.AppConfig;
import com.yihu.jk.utils.SecretUtil;
import com.yihu.wsgw.api.InterfaceMessage;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class ArticleApiTest {
	public static void main(String[] args) throws JSONException {
		// TODO Auto-generated method stub
@ -34,8 +37,9 @@ public class ArticleApiTest {
		// System.out.println(api.getCollectionArticalList(im));
		// System.out.println(api.getArticalById(im));
        saveBehavior();
//        saveBehavior();
//		System.out.printf("350200".substring(0,3));
		aa();
	}
	public static void initDB() {
@ -135,6 +139,14 @@ public class ArticleApiTest {
		}
	}
	public static void aa() {
		SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd");
		Calendar c = Calendar.getInstance();
		int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
		if (day_of_week == 0)
			day_of_week = 7;
		c.add(Calendar.DATE, -day_of_week + 1);
		System.out.println(df2.format(c.getTime()));
	}
}

+ 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 = "";

+ 48 - 17
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/compute/ComputeHelper.java

@ -4,6 +4,7 @@ import com.yihu.wlyy.entity.dimension.WlyyDimensionQuota;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.vo.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
@ -158,29 +159,53 @@ public class ComputeHelper {
        }
        //根据维度初始化数据
        for (int i = 0; i < dimensionQuotas.size(); i++) {
            Map<String, SaveModel> mapTemp = new HashMap<>();
            WlyyDimensionQuota dimensionQuota = dimensionQuotas.get(i);
            List<DictModel> dictModels = jdbcTemplate.query(dimensionQuota.getDictSql(), new BeanPropertyRowMapper(DictModel.class));
            for (Map.Entry<String, SaveModel> oneSaveModel : lastMaps.entrySet()) {
                for (int j = 0; j < dictModels.size(); j++) {
                    SaveModel saveModelTemp = new SaveModel();
                    DictModel dictModel = dictModels.get(j);
                    BeanUtils.copyProperties(oneSaveModel.getValue(), saveModelTemp);
                    SaveModel.class.getMethod("setSlaveKey" + (i + 1) + "Name", String.class).invoke(saveModelTemp, dictModel.getName());
                    SaveModel.class.getMethod("setSlaveKey" + (i + 1), String.class).invoke(saveModelTemp, dictModel.getCode());
                    //根据维度生成新的key
                    StringBuffer strKey = new StringBuffer(oneSaveModel.getKey() + "-" + dictModel.getCode());
                    mapTemp.put(strKey.toString(), saveModelTemp);
            for (int i = 0; i < dimensionQuotas.size(); i++) {
                Map<String, SaveModel> mapTemp = new HashMap<>();
                WlyyDimensionQuota dimensionQuota = dimensionQuotas.get(i);
//                List<DictModel> dictModels = jdbcTemplate.query(dimensionQuota.getDictSql(), new BeanPropertyRowMapper(DictModel.class));
                List<Map<String, Object>> listMap = jdbcTemplate.queryForList(dimensionQuota.getDictSql());
                for (Map.Entry<String, SaveModel> oneSaveModel : lastMaps.entrySet()) {
                    for (int j = 0; j < listMap.size(); j++) {
                        SaveModel saveModelTemp = new SaveModel();
                        Map<String, Object> dictModel = listMap.get(j);
                        BeanUtils.copyProperties(oneSaveModel.getValue(), saveModelTemp);
                        SaveModel.class.getMethod("setSlaveKey" + (i + 1) + "Name", String.class).invoke(saveModelTemp, dictModel.get("name"));
                        SaveModel.class.getMethod("setSlaveKey" + (i + 1), String.class).invoke(saveModelTemp, dictModel.get("code"));
                        //根据维度生成新的key
                        StringBuffer strKey = new StringBuffer(oneSaveModel.getKey() + "-" + dictModel.get("code"));
                        mapTemp.put(strKey.toString(), saveModelTemp);
                    }
                }
            }
            //如果字典长度是0 抛出异常
            if (dictModels.size() == 0) {
            if (listMap.size() == 0) {
                throw new Exception("dict size:0,sql:" + dimensionQuota.getDictSql());
            }
            lastMaps = mapTemp;
        }
//        for (int i = 0; i < dimensionQuotas.size(); i++) {
//            Map<String, SaveModel> mapTemp = new HashMap<>();
//            WlyyDimensionQuota dimensionQuota = dimensionQuotas.get(i);
//            List<DictModel> dictModels = jdbcTemplate.query(dimensionQuota.getDictSql(), new BeanPropertyRowMapper(DictModel.class));
//            for (Map.Entry<String, SaveModel> oneSaveModel : lastMaps.entrySet()) {
//                for (int j = 0; j < dictModels.size(); j++) {
//                    SaveModel saveModelTemp = new SaveModel();
//                    DictModel dictModel = dictModels.get(j);
//
//                    BeanUtils.copyProperties(oneSaveModel.getValue(), saveModelTemp);
//                    SaveModel.class.getMethod("setSlaveKey" + (i + 1) + "Name", String.class).invoke(saveModelTemp, dictModel.getName());
//                    SaveModel.class.getMethod("setSlaveKey" + (i + 1), String.class).invoke(saveModelTemp, dictModel.getCode());
//                    //根据维度生成新的key
//                    StringBuffer strKey = new StringBuffer(oneSaveModel.getKey() + "-" + dictModel.getCode());
//                    mapTemp.put(strKey.toString(), saveModelTemp);
//                }
//            }
//            //如果字典长度是0 抛出异常
//            if (dictModels.size() == 0) {
//                throw new Exception("dict size:0,sql:" + dimensionQuota.getDictSql());
//            }
//            lastMaps = mapTemp;
//        }
        //设置值
        for (Map.Entry<String, SaveModel> one : lastMaps.entrySet()) {
@ -196,6 +221,12 @@ public class ComputeHelper {
                SaveModel saveModel = one.getValue();
                saveModel.setResult1(result1);
                saveModel.setResult2(result2);
                if(dataModels.size()>0&& StringUtils.isNotEmpty(dataModels.get(0).getSlaveKey1())&&!StringUtils.isNotEmpty(saveModel.getSlaveKey1())){
                    saveModel.setSlaveKey1(dataModels.get(0).getSlaveKey1());
                }
                if(dataModels.size()>0&& StringUtils.isNotEmpty(dataModels.get(0).getSlaveKey2())&&!StringUtils.isNotEmpty(saveModel.getSlaveKey2())){
                    saveModel.setSlaveKey2(dataModels.get(0).getSlaveKey2());
                }
                returnList.add(saveModel);
            } else {
                returnList.add(one.getValue());

+ 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;
    }
@ -677,4 +692,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;
    }
}

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

@ -376,10 +376,10 @@ public class StatisticsESService {
            public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                long map1value = 0L;
                long map2value = 0L;
                if(o1.get("amount")!=null && o1.get("amount")+""!=""){
                     map1value = Long.valueOf(String.valueOf(o1.get("amount")));
                if (o1.get("amount") != null && o1.get("amount") + "" != "") {
                    map1value = Long.valueOf(String.valueOf(o1.get("amount")));
                }
                if(o2.get("amount")!=null && o2.get("amount")+""!=""){
                if (o2.get("amount") != null && o2.get("amount") + "" != "") {
                    map2value = Long.valueOf(String.valueOf(o2.get("amount")));
                }
@ -863,7 +863,7 @@ public class StatisticsESService {
     * @param index
     * @return
     */
    public JSONObject getDateTotal(String startDate, String endDate, int interval, String area, int level, String index, String lowCode, String year) throws Exception {
    public JSONObject getDateTotal(String startDate, String endDate, int interval, String area, int level, String index, String lowCode, String year, String timelevel) throws Exception {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        int taskNum = 0;
        JSONObject json = new JSONObject();
@ -876,7 +876,7 @@ public class StatisticsESService {
        }
//        }
        if (!org.springframework.util.StringUtils.isEmpty(lowCode)) {
             peopleNum = getPopulationBase(area, year);
            peopleNum = getPopulationBase(area, year);
            if (peopleNum != null) {
                if (lowCode.equals("3")) {
                    taskNum = peopleNum.getSixFiveTaskNum();
@ -890,15 +890,15 @@ public class StatisticsESService {
        json.put("taskNum", taskNum);
        if (interval == 1) {
            JSONArray jsonArray = dateTotalStatistics(startDate, endDate, area, level, index, lowCode);
            JSONArray jsonArray = dateTotalStatistics(startDate, endDate, area, level, index, lowCode, timelevel);
            json.put("data", jsonArray);
            return json;
        } else if (interval == 2) {
            JSONArray jsonArray = weekTotalStatistics(startDate, endDate, area, level, index, lowCode);
            JSONArray jsonArray = weekTotalStatistics(startDate, endDate, area, level, index, lowCode, timelevel);
            json.put("data", jsonArray);
            return json;
        } else if (interval == 3) {
            JSONArray jsonArray = monthTotalStatistics(startDate, endDate, area, level, index, lowCode);
            JSONArray jsonArray = monthTotalStatistics(startDate, endDate, area, level, index, lowCode, timelevel);
            json.put("data", jsonArray);
            return json;
        }
@ -917,15 +917,15 @@ public class StatisticsESService {
     * @return
     * @throws ParseException
     */
    public JSONArray dateTotalStatistics(String startDate, String endDate, String area, int level, String index, String lowCode) throws Exception {
    public JSONArray dateTotalStatistics(String startDate, String endDate, String area, int level, String index, String lowCode, String timelevel) throws Exception {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        List<SaveModel> saveModels = new ArrayList<>();
        //startDate = DateUtil.getNextDay(startDate,-1);
        if (StringUtils.isNotBlank(lowCode)) {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_DDL, SaveModel.interval_day, lowCode);
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day, lowCode);
        } else {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, area, level, index, SaveModel.timeLevel_DDL, SaveModel.interval_day);
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day);
        }
        List<JSONObject> result = new ArrayList<>();
        if (saveModels != null) {
@ -933,7 +933,7 @@ public class StatisticsESService {
            for (SaveModel saveModel : saveModels) {
                JSONObject json = new JSONObject();
                String range = null;
                if(saveModel.getQuotaDate()!=null){
                if (saveModel.getQuotaDate() != null) {
                    range = df.format(saveModel.getQuotaDate());
                }
                long amount = saveModel.getResult2().longValue();
@ -941,10 +941,10 @@ public class StatisticsESService {
                json.put("amount", amount);
                result.add(json);
            }
            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)));
            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){
                for (Map<String, Object> map : resultList) {
                    JSONObject json = new JSONObject();
                    json.put("range", map.get("date"));
                    json.put("amount", 0);
@ -984,7 +984,7 @@ public class StatisticsESService {
     * @return
     * @throws Exception
     */
    private JSONArray weekTotalStatistics(String startDate, String endDate, String area, int level, String index, String lowCode) throws Exception {
    private JSONArray weekTotalStatistics(String startDate, String endDate, String area, int level, String index, String lowCode, String timelevel) throws Exception {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        // 起始日期
@ -1078,22 +1078,22 @@ public class StatisticsESService {
        List<SaveModel> saveModels = new ArrayList<>();
        if (StringUtils.isNotBlank(lowCode)) {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_DDL, SaveModel.interval_day, lowCode);
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day, lowCode);
        } else {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, area, level, index, SaveModel.timeLevel_DDL, SaveModel.interval_day);
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day);
        }
        if (saveModels != null) {
            // 计算结果
            for (SaveModel saveModel : saveModels) {
                String range = "";
                if (saveModel.getQuotaDate()!=null){
                if (saveModel.getQuotaDate() != null) {
                    range = df.format(saveModel.getQuotaDate());
                }
                JSONObject json = countResult.get(range);
                //因为上述时间集提前一天  但是前端是显示当前时间,所以这里给调整回去
                if(range.equals(df.format(temp.getTime()))){
                    json.put("range",endDate);
                if (range.equals(df.format(temp.getTime()))) {
                    json.put("range", endDate);
                }
                if (json != null) {
                    long amount = saveModel.getResult2().longValue();
@ -1135,7 +1135,7 @@ public class StatisticsESService {
     * @return
     * @throws Exception
     */
    private JSONArray monthTotalStatistics(String startDate, String endDate, String area, int level, String index, String lowCode) throws Exception {
    private JSONArray monthTotalStatistics(String startDate, String endDate, String area, int level, String index, String lowCode, String timelevel) throws Exception {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
@ -1206,22 +1206,22 @@ public class StatisticsESService {
        }
        List<SaveModel> saveModels = new ArrayList<>();
        if (StringUtils.isNotBlank(lowCode)) {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_DDL, SaveModel.interval_day, lowCode);
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day, lowCode);
        } else {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, area, level, index, SaveModel.timeLevel_DDL, SaveModel.interval_day);
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day);
        }
        if (saveModels != null) {
            // 计算结果
            for (SaveModel saveModel : saveModels) {
                String range = "";
                if (saveModel.getQuotaDate()!=null){
                if (saveModel.getQuotaDate() != null) {
                    range = df.format(saveModel.getQuotaDate());
                }
                JSONObject json = countResult.get(range);
                //因为上述时间集提前一天  但是前端是显示当前时间,所以这里给调整回去
                if(range.equals(df.format(temp.getTime()))){
                    json.put("range",endDate);
                if (range.equals(df.format(temp.getTime()))) {
                    json.put("range", endDate);
                }
                if (json != null) {
                    long amount = saveModel.getResult2().longValue();
@ -1369,9 +1369,9 @@ public class StatisticsESService {
        if (resultList != null) {
            String signTaskNum = "";
            if ("3".equals(lowCode)) {
                if ("2017".equals(year)){
                if ("2017".equals(year)) {
                    signTaskNum = systemDictService.getDictValueNoRedis("SIGN_TASKNUM_17_65", year);//2017年65岁以上的目标量
                }else if ("2016".equals(year)){
                } else if ("2016".equals(year)) {
                    signTaskNum = systemDictService.getDictValueNoRedis("SIGN_TASKNUM_16_65", year);
                }
            } else {
@ -2298,7 +2298,7 @@ public class StatisticsESService {
            }
            resultMaps.add(rs);
        }
        if (level == 4 ||"5".equals(low_level)) {
        if (level == 4 || "5".equals(low_level)) {
            Map<Integer, Map<String, Object>> leaders = getAllTeamLeaders();
            if (resultMaps != null && resultMaps.size() > 0) {
                for (Map<String, Object> r : resultMaps) {
@ -2459,7 +2459,7 @@ public class StatisticsESService {
        //获取结果集
        List<Map<String, Object>> resultList = null;
        if ("0".equals(type)) {
            resultList = DateUtil.findDates(dateFormat.parse(startDate), dateFormat.parse(DateUtil.getNextDay(endDate,1)));
            resultList = DateUtil.findDates(dateFormat.parse(startDate), dateFormat.parse(DateUtil.getNextDay(endDate, 1)));
        } else {
            resultList = DateUtil.findDateASWeeks(dateFormat.parse(startDate), dateFormat.parse(endDate));
        }
@ -4981,8 +4981,8 @@ public class StatisticsESService {
        //83:健康文章,84:健康指导
        List<SaveModel> list_83_84 = elasticsearchUtil.findListDateQuotaLevel0( endDate, area, level, "83,84", SaveModel.timeLevel_DDL, lowLevel);
        List<SaveModel> list_read_83_84 = elasticsearchUtil.findListDateQuotaLevel1(endDate,area,level,"83,84", SaveModel.timeLevel_DDL, lowLevel, "1");
        List<SaveModel> list_83_84 = elasticsearchUtil.findListDateQuotaLevel0(endDate, area, level, "83,84", SaveModel.timeLevel_DDL, lowLevel);
        List<SaveModel> list_read_83_84 = elasticsearchUtil.findListDateQuotaLevel1(endDate, area, level, "83,84", SaveModel.timeLevel_DDL, lowLevel, "1");
//        List<SaveModel> list_84 = elasticsearchUtil.findListDateQuotaLevel0(null, endDate, area, level, "84", SaveModel.timeLevel_ZL, lowLevel);
//        List<SaveModel> list_read_84 = elasticsearchUtil.findListDateQuotaLevel1(endDate,area,level,"84", SaveModel.timeLevel_DDL, lowLevel, "1");
@ -4991,68 +4991,68 @@ public class StatisticsESService {
        String readRate = "";
        DecimalFormat df = new DecimalFormat("0.00");
        List<Map<String, Object>> resultList = new ArrayList<>();
        for(SaveModel saveModel:list_83_84){
        for (SaveModel saveModel : list_83_84) {
            Map<String, Object> map = new HashMap<>();
            if (SaveModel.OrgLevel.equals(lowLevel)) {
                map.put("code", saveModel.getHospital());
                map.put("name", saveModel.getHospitalName());
                map.put("amount", saveModel.getResult1());
                Double readNum = 0.0;
                for(SaveModel saveModel2:list_read_83_84){
                    if(saveModel.getHospital().equals(saveModel2.getHospital())){
                for (SaveModel saveModel2 : list_read_83_84) {
                    if (saveModel.getHospital().equals(saveModel2.getHospital())) {
                        //获取阅读量
                        readNum = saveModel2.getResult1();
                        break;
                    }
                }
                readRate = df.format( readNum > 0.0? ((readNum)/(saveModel.getResult1() * 1.0000)*100):0.0);
                readRate = df.format(readNum > 0.0 ? ((readNum) / (saveModel.getResult1() * 1.0000) * 100) : 0.0);
                map.put("readNum", readNum.longValue());
                map.put("readRate", readRate+"%");
                map.put("readRate", readRate + "%");
            } else if (SaveModel.townLevel.equals(lowLevel)) {
                map.put("code", saveModel.getTown());
                map.put("name", saveModel.getTownName());
                map.put("amount", saveModel.getResult1());
                Double readNum = 0.0;
                for(SaveModel saveModel2:list_read_83_84){
                    if(saveModel.getTown().equals(saveModel2.getTown())){
                for (SaveModel saveModel2 : list_read_83_84) {
                    if (saveModel.getTown().equals(saveModel2.getTown())) {
                        //获取阅读量
                        readNum = saveModel2.getResult1();
                        break;
                    }
                }
                readRate = df.format( readNum > 0.0? ((readNum)/(saveModel.getResult1() * 1.0000)*100):0.0);
                readRate = df.format(readNum > 0.0 ? ((readNum) / (saveModel.getResult1() * 1.0000) * 100) : 0.0);
                map.put("readNum", readNum.longValue());
                map.put("readRate", readRate+"%");
                map.put("readRate", readRate + "%");
            } else if (SaveModel.cityLevel.equals(lowLevel)) {
                map.put("code", saveModel.getCity());
                map.put("name", saveModel.getCityName());
                map.put("amount", saveModel.getResult1());
                Double readNum = 0.0;
                for(SaveModel saveModel2:list_read_83_84){
                    if(saveModel.getCity().equals(saveModel2.getCity())){
                for (SaveModel saveModel2 : list_read_83_84) {
                    if (saveModel.getCity().equals(saveModel2.getCity())) {
                        //获取阅读量
                        readNum = saveModel2.getResult1();
                        break;
                    }
                }
                readRate = df.format( readNum > 0.0? ((readNum)/(saveModel.getResult1() * 1.0000)*100):0.0);
                readRate = df.format(readNum > 0.0 ? ((readNum) / (saveModel.getResult1() * 1.0000) * 100) : 0.0);
                map.put("readNum", readNum.longValue());
                map.put("readRate", readRate+"%");
                map.put("readRate", readRate + "%");
            } else if (SaveModel.teamLevel.equals(lowLevel)) {
                map.put("code", saveModel.getTeam());
                map.put("name", saveModel.getTeamName());
                map.put("amount", saveModel.getResult1());
                Double readNum = 0.0;
                for(SaveModel saveModel2:list_read_83_84){
                    if(saveModel.getTeam().equals(saveModel2.getTeam())){
                for (SaveModel saveModel2 : list_read_83_84) {
                    if (saveModel.getTeam().equals(saveModel2.getTeam())) {
                        //获取阅读量
                        readNum = saveModel2.getResult1();
                        break;
                    }
                }
                readRate = df.format( readNum > 0.0? ((readNum)/(saveModel.getResult1() * 1.0000)*100):0.0);
                readRate = df.format(readNum > 0.0 ? ((readNum) / (saveModel.getResult1() * 1.0000) * 100) : 0.0);
                map.put("readNum", readNum.longValue());
                map.put("readRate", readRate+"%");
                map.put("readRate", readRate + "%");
            }
            resultList.add(map);
        }
@ -5069,7 +5069,7 @@ public class StatisticsESService {
                        obj.put("name", town.getName());
                        obj.put("amount", "0");
                        obj.put("readNum", 0);
                        obj.put("readRate", Double.valueOf("0.00")+"%");
                        obj.put("readRate", Double.valueOf("0.00") + "%");
                        resultList.add(obj);
                    }
                }
@ -5092,7 +5092,7 @@ public class StatisticsESService {
                            obj.put("name", hos.getName());
                            obj.put("amount", "0");
                            obj.put("readNum", 0);
                            obj.put("readRate", Double.valueOf("0.00")+"%");
                            obj.put("readRate", Double.valueOf("0.00") + "%");
                            resultList.add(obj);
                        }
                    }
@ -5120,7 +5120,7 @@ public class StatisticsESService {
                            obj.put("name", team.getName());
                            obj.put("amount", "0");
                            obj.put("readNum", 0);
                            obj.put("readRate", Double.valueOf("0.00")+"%");
                            obj.put("readRate", Double.valueOf("0.00") + "%");
                            resultList.add(obj);
                        }
                    }
@ -5134,11 +5134,11 @@ public class StatisticsESService {
            public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                long map1value = 0L;
                long map2value = 0L;
                if(o1.get("amount")!=null && o1.get("amount")+""!=""){
                    map1value = ((Double)o1.get("amount")).longValue();
                if (o1.get("amount") != null && o1.get("amount") + "" != "") {
                    map1value = ((Double) o1.get("amount")).longValue();
                }
                if(o2.get("amount")!=null && o2.get("amount")+""!=""){
                    map2value = ((Double)o2.get("amount")).longValue();
                if (o2.get("amount") != null && o2.get("amount") + "" != "") {
                    map2value = ((Double) o2.get("amount")).longValue();
                }
                if (map1value - map2value > 0) {
@ -5174,17 +5174,17 @@ public class StatisticsESService {
        return saveModel.getResult2().longValue();
    }
    public Map<String,Object> getLevelDeviceAndBinding(String area, int level, int sort, String lowLevel, String year,String deviceType) throws Exception {
    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 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 mondayTime = DateUtil.getMondayOfThisDate(new Date());//本周一开始时间
        String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level + 1) : lowLevel);
        Map<String,Object> resultMap = new HashedMap();
        Map<String, Object> resultMap = new HashedMap();
        DecimalFormat df = new DecimalFormat("0.00");
        List<Map<String, Object>> resultList = new ArrayList<>();
@ -5193,84 +5193,83 @@ public class StatisticsESService {
        List<SaveModel> useSaveModel = null;
        SaveModel anomalySaveModel = null;
        String allCountSql = "";
        String anomalyCountSql ="";
//        List<SaveModel> grantList = null;//发放量折线图
//        List<SaveModel> bindingList = null;//绑定量折线图
        String anomalyCountSql = "";
        List<SaveModel> allAmountList = null;//发放量列表
        List<SaveModel> bindingAmountList = null;//绑定量列表
        switch (deviceType){
        String areaCondition = "";
        if (SaveModel.OrgLevel.equals(level + "")) {
            areaCondition = " and d.grant_org_code like '" + area + "' ";
        } else if (SaveModel.townLevel.equals(level + "")) {
            areaCondition = " and d.grant_org_code like '" + area.substring(0, 4) + "%' ";
        } else if (SaveModel.cityLevel.equals(level + "")) {
            areaCondition = " and d.grant_org_code like '" + area.substring(0, 2) + "%' ";
        }
        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);
                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 '%血压%' " + areaCondition;
                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(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =1 and i.status=1 and i.del=1 " + areaCondition;
                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);
                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 '%血糖%' " + areaCondition;
                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(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =2 and i.status=1 and i.del=1 " + areaCondition;
                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);
                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 " + areaCondition;
                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where  i.status=1 and i.del=1 " + areaCondition;
                useSaveModel = elasticsearchUtil.findDateQuotaLevel0(mondayTime, timeKey, area, level, index_87, SaveModel.timeLevel_ZL, null, 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);
        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());//绑定量
        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+"%");//绑定率
        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;
        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+"%");//本周使用率
        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干预指导率
        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干预指导率
        }
@ -5344,14 +5343,174 @@ public class StatisticsESService {
                    }
                }
            });
            resultMap.put("list",resultList);
            resultMap.put("list", resultList);
            return resultMap;
        } else {
            return new HashedMap();
        }
    }
    //i健康活动统计1.4.8版本
    public Map<String, Object> statisticsActivity(String area, int level, int sort,String lowLevel,String slaveKey1) throws Exception {
        Map<String, Object> resultMap = new HashMap<>();
        String index_89 = "89";//健康银行全部活动人数统计指标
        String index_1 = "1";//签约已缴费指标(总人数按签约人数计算)
        String index_91 = "91";//健康银行活动报名数
        String index_92 = "92";//健康银行活动报名数
        String timeKey = DateUtil.getStringDateShort();//当前时间
        String areaCondition = "";
        String areaCondition2 = "";
        //发布活动数
        if (SaveModel.OrgLevel.equals(level + "")) {
            areaCondition = " and d.area like '" + area + "' ";
            areaCondition2 = " and t.org_code like '" + area + "' ";
        } else if (SaveModel.townLevel.equals(level + "")) {
            areaCondition = " and d.area like '" + area.substring(0, 4) + "%' ";
            areaCondition2 = " and t.org_code like '" + area.substring(0, 4) + "%' ";
        } else if (SaveModel.cityLevel.equals(level + "")) {
            areaCondition = " and d.area like '" + area.substring(0, 2) + "%' ";
            areaCondition2 = " and t.org_code like '" + area.substring(0, 2) + "%' ";
        }
        String activitySql = "select count(1) from wlyy_health_bank_activity d where d.status=1  " + areaCondition;
        Integer activityCount = jdbcTemplate.queryForObject(activitySql, Integer.class);//发布活动数
        //活动用户总量
        SaveModel activitySaveModel = null;
        if(StringUtils.isNotEmpty(slaveKey1)){
            activitySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_89, SaveModel.timeLevel_DDL,slaveKey1);
        }else{
            activitySaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_89, SaveModel.timeLevel_DDL);
        }
        resultMap = applyList(index_1,index_91,area,level, sort,lowLevel,slaveKey1,resultMap);//列表
        if(StringUtils.isNotEmpty(slaveKey1)){
            resultMap.put("activityCount",activityCount);//发布活动数
        }else{
            String dayStart =  DateUtil.dateToStrLong(new Date(DateUtil.getDayStartTime(new Date()).getTime()));
            String currentTime  = DateUtil.getStringDate();
            String sql = " select count(1) from health_bank.wlyy_health_bank_active_record r join wlyy.wlyy_admin_team t on r.team_id=t.id where r.create_time>='"+dayStart+"' and r.create_time<='"+currentTime+"' r.activity_id='"+slaveKey1+"' "+areaCondition2;
            Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
            resultMap.put("dayActiveCount",count!=null?count.intValue():0);//今日活跃量
        }
        resultMap.put("activityPatient",activitySaveModel.getResult1().intValue());//活动用户总量
        return resultMap;
    }
    /**
     * 获取活动信息
     *
     * @param id
     * @param area
     * @param level
     * @return
     */
    public List<Map<String, Object>> getAllAtivity(String id, String area, int level) {
        String condition = "";
        if (SaveModel.OrgLevel.equals(level + "")) {
            condition = " and a.area like '" + area + "' ";
        } else if (SaveModel.townLevel.equals(level + "")) {
            condition = " and a.area like '" + area.substring(0, 4) + "%' ";
        } else if (SaveModel.cityLevel.equals(level + "")) {
            condition = " and a.area like '" + area.substring(0, 2) + "%' ";
        }
        if (StringUtils.isNotEmpty(id)) {
            condition += " and a.id=" + id;
        }
        String sql = " select * from health_bank.wlyy_health_bank_activity a where a.status=1 " + condition;
        return jdbcTemplate.queryForList(sql);
    }
    //参与率列表
    public Map<String, Object> applyList(String index_all,String index_part,String area, int level, int sort, String lowLevel, String slaveKey1,Map<String, Object> resultMap) throws Exception {
//        String index_1 = "1";//签约已缴费指标(总人数按签约人数计算)
//        String index_91 = "91";//健康银行活动报名数
        String timeKey = DateUtil.getStringDateShort();//当前时间
        String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level + 1) : lowLevel);
//        Map<String, Object> resultMap = new HashedMap();//返回的结果
        List<SaveModel> allAmountList = null;//签约已缴费人数列表
        List<SaveModel> applyAmountList = null;//报名人数列表
        if (StringUtils.isNotEmpty(slaveKey1)) {
            allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_all, SaveModel.timeLevel_DDL, slaveKey1, "", low_level);
            applyAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_part, SaveModel.timeLevel_DDL, slaveKey1, "", low_level);
        } else {
            allAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_all, SaveModel.timeLevel_DDL, "", low_level);
            applyAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_part, SaveModel.timeLevel_DDL, "", low_level);
        }
        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;
                }
            }
        }
        //自建结果集
        List<Map<String, Object>> resultList = getLowLevelMapKey(level, low_level, area);
        if (resultList != null && resultList.size() > 0) {
            Map<String, SaveModel> applyMap = new HashMap<>();
            applyAmountList.stream().forEach(one -> {
                if ("5".equals(low_level)) {
                    applyMap.put(one.getTeam(), one);
                } else if ("4".equals(low_level)) {
                    applyMap.put(one.getHospital(), one);
                } else if ("3".equals(low_level)) {
                    applyMap.put(one.getTown(), one);
                }
            });
            for (Map<String, Object> reMap : resultList) {
                reMap.put("amount", reMap.get("amount") != null ? Long.valueOf(reMap.get("amount").toString()) : 0L);
                Integer allAmount = 0;
                int applyAmount = 0;
                //获取绑定数量
                if (applyMap != null && applyMap.size() > 0) {
                    SaveModel one = applyMap.get(reMap.get("code").toString());
                    if (one != null) {
                        applyAmount = one.getResult2().intValue();
                    }
                }
                if (allMap != null && allMap.size() > 0) {
                    allAmount = allMap.get(reMap.get("code").toString());
                    if (allAmount == null) {
                        allAmount = 0;
                    }
                }
                reMap.put("allNum", allAmount);
                reMap.put("applyNum", applyAmount);
                reMap.put("rate", getRange(applyAmount, 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();
        }
    }

+ 39 - 18
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java

@ -1,5 +1,6 @@
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;
@ -62,27 +63,34 @@ public class SpecialistService extends BaseService {
        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.dept_name AS deptName," +
                " d.dept," +
                " d.job," +
                " 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()));
@ -93,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");
@ -101,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){
        //自定义标签
@ -148,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");
@ -160,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");
@ -171,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");
@ -184,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");
@ -196,7 +217,7 @@ public class SpecialistService extends BaseService {
    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.getBoolean("obj");
@ -211,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");

+ 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;
    }

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

@ -1,15 +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;
/**
@ -17,13 +26,18 @@ import java.util.Map;
 */
@Service
@Transactional
public class AppletsService {
public class AppletsService extends BaseService {
    @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 {
        HttpUtils httpUtils = new HttpUtils();
@ -54,4 +68,80 @@ public class AppletsService {
        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;
    }
}

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

@ -17,6 +17,7 @@ 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);
        // 加密秘钥

+ 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;
				}
			});
		});
	}
}

+ 23 - 15
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;
@ -244,10 +245,9 @@ public class DoctorMessageController extends BaseController {
    @ApiOperation("获取超标指标消息--根据患者分组")
    public String getHealthIndexMessage() throws Exception {
        try {
//            List<Map<String, Object>> list = messageService.getHealthIndexMessage("xh1D2017031503333");     //"D20161008003"
            Map<String,List<Map<String, Object>>> map = messageService.getHealthIndexMessage(getUID());
            List<Map<String, Object>> list = messageService.getHealthIndexMessage(getUID());     //"D20161008003"
            return write(200, "获取超标指标消息成功", "data", map);
            return write(200, "获取超标指标消息成功", "data", list);
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
        }
@ -266,18 +266,8 @@ public class DoctorMessageController extends BaseController {
                                                 @RequestParam(value = "pagesize", required = true) Integer pagesize) throws Exception {
        try {
            List<Map<String, String>> list = messageService.getHealthIndexMessageByPatient(getUID(), patient, type, page, pagesize);
            String tzCode ="";
            for(Map<String, String> one:list){
                tzCode +=","+one.get("tzCode");
            }
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
            map.put("status", 200);
            map.put("msg", "获取超标指标消息成功");
            map.put("data", list);
            map.put("tzCode",tzCode.length()>0?tzCode.substring(1):"");
            return mapper.writeValueAsString(map);
            return write(200, "获取超标指标消息成功", "data", list);
        } catch (Exception ex) {
            ex.printStackTrace();
            return invalidUserException(ex, -1, "查询失败");
@ -466,4 +456,22 @@ public class DoctorMessageController extends BaseController {
        }
    }
    @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, "查询失败!");
        }
    }
}

+ 16 - 4
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, "请求失败");
@ -186,4 +186,16 @@ public class SpecialistController extends BaseController {
        }
    }
    @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

+ 111 - 14
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -517,7 +517,7 @@ public class EsStatisticsController extends BaseController {
                    if ("13".equals(idx)) {
                        idx = "1";
                    }
                    JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, idx, lowCode, year);
                    JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, idx, lowCode, year,SaveModel.timeLevel_DDL);
                    result.put("index_" + idx, json);
                }
            }
@ -2201,24 +2201,121 @@ public class EsStatisticsController extends BaseController {
        }
    }
    @RequestMapping("/lowlevel_activity")
    @ApiOperation("健康银行活动统计")
    @ResponseBody
    public String lowlevel_activity(@RequestParam(required = false) String activityCode,
                                    @RequestParam(required = true) String area,
                                    @RequestParam(required = true) int level,
                                    @RequestParam(required = true) int sort,
                                    @RequestParam(required = false) String lowLevel,
                                    @RequestParam(required = false) String year){
        try{
            Map<String, Object> resultMap = statisticsESService.statisticsActivity(area,level,sort,lowLevel,activityCode);
            return write(200, "查询成功", "data", resultMap);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getAllAtivity")
    @ApiOperation("获取所有活动信息")
    @ResponseBody
    public String getAllAtivity(@ApiParam(name = "id", value = "活动id")
                                @RequestParam(value = "id", required = false)String id,
                                @ApiParam(name = "area", value = "地区code")
                                @RequestParam(value = "area", required = true)String area,
                                @ApiParam(name = "level", value = "地区级别,1 团队,2 机构,3 区,4 市")
                                @RequestParam(value = "level", required = true)int level){
        try{
            List<Map<String, Object>> list = statisticsESService.getAllAtivity(id,area,level);
            return write(200, "查询成功", "data", list);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取绑定和发放量的折线图
     * 健康银行活动人数增长曲线
     *
     * @param startDate
     * @param endDate
     * @param type      0 按周,1 按月
     * @param startDate 起始日期
     * @param endDate   结束时间
     * @param interval  时间间隔
     * @param area      区域或机构
     * @param level     级别
     * @param lowCode   子维度
     * @param year      查询年份
     * @return
     *//*
    @RequestMapping("/getDeviceLine")
     */
    @RequestMapping(value = "/activity_increase")
    @ResponseBody
    public String getDeviceLine(@RequestParam(required = true) String startDate,
                                 @RequestParam(required = true) String endDate,
                                 @RequestParam(required = true) String type) {
    public String activityIncrease(@RequestParam(required = true) String startDate,
                                     @RequestParam(required = true) String endDate,
                                     @RequestParam(required = true) int interval,
                                     @RequestParam(required = true) String area,
                                     @RequestParam(required = true) int level,
                                     @RequestParam(required = false) String lowCode,
                                     @RequestParam(required = false) String year) {
        try {
            //89指标
            level = elasticsearchUtil.changeLevel(level);
            JSONObject result = new JSONObject();
            if (org.springframework.util.StringUtils.isEmpty(year)) {
                year =  Constant.getNowYearByDate(endDate);
            }
            JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, "89", lowCode, year,SaveModel.timeLevel_ZL);
            result.put("index_89", json);
            return write(200, "查询成功!", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
    /**
     * 健康银行活跃人数增长曲线
     *
     * @param startDate 起始日期
     * @param endDate   结束时间
     * @param interval  时间间隔
     * @param area      区域或机构
     * @param level     级别
     * @param lowCode   子维度
     * @param year      查询年份
     * @return
     */
    @RequestMapping(value = "/active_statistics")
    @ResponseBody
    public String activeStatistics(@RequestParam(required = true) String startDate,
                                   @RequestParam(required = true) String endDate,
                                   @RequestParam(required = true) int interval,
                                   @RequestParam(required = true) String area,
                                   @RequestParam(required = true) int level,
                                   @RequestParam(required = false) String lowCode,
                                   @RequestParam(required = false) String year) {
        try {
            return write(200, "查询成功", "data", statisticsESService.getSignCountLineByType(getUID(), type, startDate, endDate));
            //89指标
            level = elasticsearchUtil.changeLevel(level);
            JSONObject result = new JSONObject();
            if (org.springframework.util.StringUtils.isEmpty(year)) {
                year =  Constant.getNowYearByDate(endDate);
            }
            JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, "90", lowCode, year,SaveModel.timeLevel_ZL);
            result.put("index_89", json);
            return write(200, "查询成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
            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, "未设置姓名!");

+ 47 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/AppletsController.java

@ -28,7 +28,7 @@ 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, "失败");
@ -39,10 +39,55 @@ public class AppletsController extends WeixinBaseController {
    @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));
            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, "失败");
        }
    }
}

+ 2 - 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/
@ -157,6 +157,7 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_dev  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel_dev #设备测量提醒
##如果是外网项目就是flase 内网是true
neiwang:

+ 2 - 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/
@ -160,6 +160,7 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_test  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel_test #设备测量提醒
##如果是外网项目就是flase 内网是true
neiwang:

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

@ -53,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:
@ -143,6 +147,7 @@ activemq:
  url: tcp://10.95.22.168:61616
  queue:
    healtHarticleQueue: healthArticleChannel_devtest  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel_test #设备测量提醒
##如果是外网项目就是flase 内网是true
neiwang:

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

@ -143,6 +143,7 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_devtest  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel_test #设备测量提醒
##如果是外网项目就是flase 内网是true
neiwang:

+ 3 - 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/
@ -156,6 +156,8 @@ activemq:
  url: tcp://59.61.92.90:9103
  queue:
    healtHarticleQueue: healthArticleChannel  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel #设备测量提醒
##如果是外网项目就是flase 内网是true
neiwang:

+ 2 - 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/
@ -149,6 +149,7 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_test  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel_test #设备测量提醒
##如果是外网项目就是flase,false会调用内网http接口项目提交  内网是true直接上传fastDfs
neiwang: