Parcourir la source

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

chenweida il y a 7 ans
Parent
commit
042edbbe3f
34 fichiers modifiés avec 1289 ajouts et 85 suppressions
  1. 9 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/dict/Icd10Dict.java
  2. 16 3
      common/common-entity/src/main/java/com/yihu/wlyy/entity/wechat/WechatPushLog.java
  3. 147 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/wechat/WechatTemplateConfig.java
  4. 71 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/wechat/WeixinTemplate.java
  5. 1 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/user/ManageRangeService.java
  6. 0 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java
  7. 13 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/Icd10DictDao.java
  8. 18 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/wechat/WechatTemplateConfigDao.java
  9. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/wechat/WeixinTemplateDao.java
  10. 0 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java
  11. 379 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java
  12. 0 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java
  13. 0 11
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java
  14. 0 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionNoticesService.java
  15. 13 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  16. 0 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  17. 0 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/message/SendMessageService.java
  18. 0 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java
  19. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java
  20. 0 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/ImmuneService.java
  21. 292 11
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  22. 25 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  23. 81 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/MyJdbcTemplate.java
  24. 0 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/feedback/DoctorFeedbackTemplateController.java
  25. 0 12
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java
  26. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/intervene/DoctorInterveneController.java
  27. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/medical/DoctorMedicalRecordController.java
  28. 0 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/booking/PatientBookingController.java
  29. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultCommunicationController.java
  30. 4 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java
  31. 190 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/iot/IotMonitoringHealthController.java
  32. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/template/ThirdTemplateController.java
  33. 1 1
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml
  34. 2 2
      patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu.txt

+ 9 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/dict/Icd10Dict.java

@ -21,6 +21,7 @@ public class Icd10Dict {
    private Date createDate;
    private String updateUser;
    private Date updateDate;
    private String type;//类型(1高血压,2糖尿病)
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
@ -111,4 +112,12 @@ public class Icd10Dict {
    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
}

+ 16 - 3
common/common-entity/src/main/java/com/yihu/wlyy/entity/wechat/WechatPushLog.java

@ -9,15 +9,20 @@ import java.util.Date;
/**
 * 微信模板推送日志
 * Created by yeshijie on 2017/10/18.
 * modify by wujunjie 原type=11-18统一为11  19更新为12  20更新为13  21更新为14 version v1.4.3
 */
@Entity
@Table(name = "wlyy_wx_push_log")
public class WechatPushLog extends IdEntity {
    private Integer type;// '推送类型',
    //1:签约成功  2:签约失败  3:咨询回复通知  4:健康指导提醒  5:解约申请通知  6:预约挂号成功通知  7:预约取消通知 8 缴费提醒 9 健康教育  10 签约医生变更(信息变更通知)续方订单配送员已顺利取药
    //12.添加家人申请 13.添加家人申请成功 14.添加家人申请失败 16.续签家庭医生 17.医生评价 91.医生助手 92.医生助手项目gcMessageController发送
    //18 产检提醒和产检就诊提醒 19:续方审核结果通知(0.不通过 1.通过 2。调整处方并通过) 20:服务结果通知(续方订单已成功配送) 11.代办事项通知(完成配药)
    //1:template_sign_success  2:template_sign_failed  3:template_consult_notice  4:template_health_notice  5:template_termination
    // 6:template_appoint_success 7:template_appoint_failed 8 template_expenses_remind 9 template_healthy_article  10 template_doctor_change
    //11-18:template_doctor_survey
    //19:template_doctor_audit 20:template_doctor_service 21:template_physical_examination
    //91.医生助手 92.医生助手项目gcMessageController发送
    //15:doctor_invitel_template(签约单独使用) 16:template_deal_with(第三方使用)
    private String scene;//模板使用场景
    private String openid;
    private String patient;//'居民code',
    private String name;//'居民姓名',
@ -26,6 +31,14 @@ public class WechatPushLog extends IdEntity {
    private Integer status;//'状态(0失败,1成功)',
    private Date createTime;
    public String getScene() {
        return scene;
    }
    public void setScene(String scene) {
        this.scene = scene;
    }
    public Integer getType() {
        return type;
    }

+ 147 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/wechat/WechatTemplateConfig.java

@ -0,0 +1,147 @@
package com.yihu.wlyy.entity.wechat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 微信消息模板按场景区分消息内容
 * @author WuJunjie
 */
@Entity
@Table(name = "weixin_template_config")
public class WechatTemplateConfig extends IdEntity {
	private static final long serialVersionUID = -7399054549159698617L;
	private String templateId; //'模板ID
    private String scene;//使用场景值
    private String sceneDescription;//'使用场景描述'
    private String first;
    private String url;//模板消息'跳转链接'
    private String remark;
    private String keyword1;
    private String keyword2;
    private String keyword3;
    private String keyword4;
    private String keyword5;
    private String keyword6;
    private String keyword7;
    private Integer status;//状态 1:正常 0:删除
    public static long getSerialVersionUID() {
        return serialVersionUID;
    }
    public String getTemplateId() {
        return templateId;
    }
    public void setTemplateId(String templateId) {
        this.templateId = templateId;
    }
    public String getScene() {
        return scene;
    }
    public void setScene(String scene) {
        this.scene = scene;
    }
    public String getSceneDescription() {
        return sceneDescription;
    }
    public void setSceneDescription(String sceneDescription) {
        this.sceneDescription = sceneDescription;
    }
    public String getFirst() {
        return first;
    }
    public void setFirst(String first) {
        this.first = first;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getKeyword1() {
        return keyword1;
    }
    public void setKeyword1(String keyword1) {
        this.keyword1 = keyword1;
    }
    public String getKeyword2() {
        return keyword2;
    }
    public void setKeyword2(String keyword2) {
        this.keyword2 = keyword2;
    }
    public String getKeyword3() {
        return keyword3;
    }
    public void setKeyword3(String keyword3) {
        this.keyword3 = keyword3;
    }
    public String getKeyword4() {
        return keyword4;
    }
    public void setKeyword4(String keyword4) {
        this.keyword4 = keyword4;
    }
    public String getKeyword5() {
        return keyword5;
    }
    public void setKeyword5(String keyword5) {
        this.keyword5 = keyword5;
    }
    public String getKeyword6() {
        return keyword6;
    }
    public void setKeyword6(String keyword6) {
        this.keyword6 = keyword6;
    }
    public String getKeyword7() {
        return keyword7;
    }
    public void setKeyword7(String keyword7) {
        this.keyword7 = keyword7;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
}

+ 71 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/wechat/WeixinTemplate.java

@ -0,0 +1,71 @@
package com.yihu.wlyy.entity.wechat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * @Description: 记录各公众号模板详情及自定义类型
 * @Author: WuJunjie
 * @Date: Created in 2018/2/24 17:38
 */
@Entity
@Table(name = "weixin_template")
public class WeixinTemplate  extends IdEntity {
    private String accId;//'微信公众号原始ID'
    private String templateName;//'自定义模板名称'
    private String templateId;//'模板ID'
    private Integer type;//'自定义模板类型'
    private String format;//'模板内容格式'
    private Integer status;//'模板状态 1:正常  0:删除'
    public String getAccId() {
        return accId;
    }
    public void setAccId(String accId) {
        this.accId = accId;
    }
    public String getTemplateName() {
        return templateName;
    }
    public void setTemplateName(String templateName) {
        this.templateName = templateName;
    }
    public String getTemplateId() {
        return templateId;
    }
    public void setTemplateId(String templateId) {
        this.templateId = templateId;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public String getFormat() {
        return format;
    }
    public void setFormat(String format) {
        this.format = format;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
}

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/user/ManageRangeService.java

@ -69,7 +69,7 @@ public class ManageRangeService extends BaseJpaService<Doctor, DoctorDao> {
        } else if (StringUtils.isNotEmpty(name) && StringUtils.isEmpty(idcard)) {
            sql += " AND p.name = '" + name+"' ";
        }
        sql += " ORDER BY p.id ASC  limit " +(page-1) +", " + pageSize;
        sql += " ORDER BY p.id ASC  limit " +((page-1)*pageSize) +", " + pageSize;
        userList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Doctor.class));
        return userList;

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

@ -180,7 +180,6 @@ public class SwaggerConfig {
                        regex("/qrcode/.*"),
                        regex("/onepay/.*"),
                        regex("/wlyy_service/.*"),
                        regex("/wlyy_service/.*"),
                        regex("/wechat/.*"),
                        regex("/nofilter/.*"),
                        regex("/idc10/.*"),

+ 13 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/Icd10DictDao.java

@ -0,0 +1,13 @@
package com.yihu.wlyy.repository.dict;
import com.yihu.wlyy.entity.dict.Icd10Dict;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2018/2/24.
 */
public interface Icd10DictDao extends PagingAndSortingRepository<Icd10Dict, Long>, JpaSpecificationExecutor<Icd10Dict> {
    Icd10Dict findByCode(String code);
}

+ 18 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/wechat/WechatTemplateConfigDao.java

@ -0,0 +1,18 @@
package com.yihu.wlyy.repository.wechat;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @Description: 分场景值查询模板文案内容
 * @Author: WuJunjie
 * @Date: Created in 2018/2/23 11:51
 */
public interface WechatTemplateConfigDao extends PagingAndSortingRepository<WechatTemplateConfig, Long>, JpaSpecificationExecutor<WechatTemplateConfig> {
    //根据模板id、场景值查询有效模板内容
    @Query("select t  from WechatTemplateConfig t where t.templateId=?1 and t.scene=?2 and t.status = 1 ")
    WechatTemplateConfig findByScene(String templateId,String scene);
}

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/wechat/WeixinTemplateDao.java

@ -0,0 +1,19 @@
package com.yihu.wlyy.repository.wechat;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.entity.wechat.WeixinTemplate;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @Description: 模板记录信息
 * @Author: WuJunjie
 * @Date: Created in 2018/2/23 11:51
 */
public interface WeixinTemplateDao extends PagingAndSortingRepository<WeixinTemplate, Long>, JpaSpecificationExecutor<WeixinTemplate> {
    //根据自定义模板名称、微信公众号原始ID获取模板ID等信息
    @Query("select t  from WeixinTemplate t where t.accId=?1 and t.templateName=?2 and t.status = 1 ")
    WeixinTemplate findByName(String accId, String templateName);
}

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

@ -1,6 +1,5 @@
package com.yihu.wlyy.service.app.account;
import com.alibaba.fastjson.JSON;
import com.yihu.wlyy.entity.address.City;
import com.yihu.wlyy.entity.address.Province;
import com.yihu.wlyy.entity.address.Town;
@ -54,12 +53,9 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import org.springside.modules.security.utils.Digests;
import org.springside.modules.utils.Encodes;
import java.text.SimpleDateFormat;
import java.util.*;

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

@ -5,21 +5,30 @@ import com.yihu.wlyy.entity.device.Device;
import com.yihu.wlyy.entity.device.PatientBloodSugger;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.device.PatientHealthTime;
import com.yihu.wlyy.entity.dict.Icd10Dict;
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.SignPatientLabelInfo;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientEvent;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.health.repository.DeviceDetailDao;
import com.yihu.wlyy.repository.deviece.DeviceDao;
import com.yihu.wlyy.repository.deviece.PatientBloodSuggerDao;
import com.yihu.wlyy.repository.deviece.PatientHealthTimeDao;
import com.yihu.wlyy.repository.dict.Icd10DictDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.MyJdbcTemplate;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -30,6 +39,7 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
@ -37,6 +47,7 @@ import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import org.springside.modules.utils.Clock;
import javax.annotation.PostConstruct;
import java.util.*;
@Component
@ -53,10 +64,14 @@ public class PatientDeviceService extends BaseService {
    @Autowired
    private DeviceDao deviceDao;
    @Autowired
    private PatientHealthIndexService healthIndexService;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private SignPatientLabelInfoDao signPatientLabelInfoDao;
    @Autowired
    private DoctorAdminTeamMemberDao doctorAdminTeamMemberDao;
    @Autowired
@ -68,6 +83,8 @@ public class PatientDeviceService extends BaseService {
    @Autowired
    private PatientHealthTimeDao patientHealthTimeDao;
    @Autowired
    private PatientHealthStandardDao patientHealthStandardDao;
    @Autowired
    private HttpClientUtil HttpClientUtil;
    @Value("${yihu.yihu_OpenPlatform_url}")
@ -77,7 +94,31 @@ public class PatientDeviceService extends BaseService {
    @Value("${yihu.yihu_OpenPlatform_secret}")
    private String secret;
    private String registerDevice = "DeviceGateway/DeviceApi/registerDevice";//注册设备
    @Autowired
    private MyJdbcTemplate myJdbcTemplate;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private JwSmjkService jwSmjkService;
    @Autowired
    private PatientEventDao patientEventDao;
    @Autowired
    private Icd10DictDao icd10DictDao;
    Map<Integer, String> relations = new HashMap<>();
    @PostConstruct
    public void init() {
        relations.put(0, "其他");
        relations.put(1, "父亲");
        relations.put(2, "母亲");
        relations.put(3, "老公");
        relations.put(4, "老婆");
        relations.put(5, "儿子");
        relations.put(6, "女儿");
        relations.put(7, "未知");
        relations.put(8, "免疫关联");
    }
    /**
     * 验证sn码 先调总部接口 未注册才查询本地数据库,如果也没有才不能绑定
@ -612,4 +653,337 @@ public class PatientDeviceService extends BaseService {
    }
    /**************************远程健康监测平台*********************************************/
    /**
     * 设备发放情况
     */
    public List<com.alibaba.fastjson.JSONObject> equipmentDistribution(){
        StringBuffer sql = new StringBuffer("SELECT t.`code`,t.name,IFNULL(a.num,0) num from dm_town t ");
        sql.append("LEFT JOIN (SELECT h.town,COUNT(*) num ");
        sql.append("from ( SELECT DISTINCT f.* from wlyy_patient_device d,wlyy_sign_family f  ");
        sql.append("WHERE f.`status`>0 and f.patient = d.`user`) t,dm_hospital h ");
        sql.append("WHERE t.hospital = h.code GROUP BY h.town) a on t.code = a.town ");
        sql.append(" WHERE city = '350200' ORDER BY num desc ");
        return myJdbcTemplate.queryJson(sql.toString());
    }
    /**
     * 慢病患者情况-统计
     * @param type 类型(2糖尿病,1高血压)
     * @return
     */
    public List<com.alibaba.fastjson.JSONObject> chronicDiseaseCount(String type){
        StringBuffer sql = new StringBuffer("SELECT p.disease_condition diseaseCondition,COUNT(*) num ");
        sql.append("from ( SELECT DISTINCT f.* from wlyy_patient_device d,wlyy_sign_family f  ");
        sql.append("WHERE f.`status`>0 and f.patient = d.`user`) t,wlyy_patient p ");
        if(StringUtils.isNotBlank(type)){
            sql.append(",wlyy_sign_patient_label_info l ");
        }
        sql.append("WHERE t.patient = p.code ");
        if(StringUtils.isNotBlank(type)){
            sql.append("and p.code = l.patient and l.label =? and l.label_type = 3 ");
        }
        sql.append(" GROUP BY p.disease_condition");
        if(StringUtils.isNotBlank(type)){
            return myJdbcTemplate.queryJson(sql.toString(),new Object[]{type});
        }else {
            return myJdbcTemplate.queryJson(sql.toString());
        }
    }
    /**
     * 设备绑定情况
     * @param type 类型(1血糖仪,2血压计)
     * @return
     */
    public List<com.alibaba.fastjson.JSONObject> deviceBinding(String type){
        StringBuffer sql = new StringBuffer("SELECT IFNULL(p.standard_status,0) standardStatus,COUNT(*) num ");
        sql.append("from ( SELECT DISTINCT f.* from wlyy_patient_device d,wlyy_sign_family f  ");
        sql.append("WHERE f.`status`>0 and f.patient = d.`user` ");
        if(StringUtils.isNotBlank(type)){
            sql.append("and d.category_code = ? ");
        }
        sql.append(") t,wlyy_patient p WHERE t.patient = p.code ");
        sql.append(" GROUP BY IFNULL(p.standard_status,0)");
        if(StringUtils.isNotBlank(type)){
            return myJdbcTemplate.queryJson(sql.toString(),new Object[]{type});
        }else {
            return myJdbcTemplate.queryJson(sql.toString());
        }
    }
    /**
     * 预警信息警报
     * @param page
     * @param pageSize
     * @return
     */
    public List<com.alibaba.fastjson.JSONObject> warningInformationAlarm(Integer page,Integer pageSize){
        StringBuffer sql = new StringBuffer("SELECT m.sender,m.sender_name,m.create_time,m.value1,m.value2,m.tz_type,p.address ");
        sql.append("from wlyy_message m LEFT JOIN wlyy_patient p on m.sender=p.code ");
        sql.append("WHERE m.type = 2  ORDER BY m.id desc LIMIT ?,?");
        List<com.alibaba.fastjson.JSONObject> list = myJdbcTemplate.queryJson(sql.toString(),new Object[]{(page-1)*pageSize,pageSize});
        return list;
    }
    /**
     * 判断当前值是否在区间内
     */
    private String checkHealthIndex(Double current, Double max) {
        if (current > max ) {
            return "偏高";
        }
        return "偏低";
    }
    /**
     * 个人信息
     * @param patientCode
     */
    public com.alibaba.fastjson.JSONObject persionalInfo(String patientCode){
        com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
        SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
        if(signFamily==null){
            jsonObject.put("status",-1);
            return jsonObject;
        }
        Patient patient = patientDao.findByCode(patientCode);
        //标签
        List<SignPatientLabelInfo> labelInfoList = signPatientLabelInfoDao.findByPatientAndStatus(patientCode,1);
        com.alibaba.fastjson.JSONArray jsonArray = new com.alibaba.fastjson.JSONArray();
        labelInfoList.forEach(labelInfo->{
            com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
            json.put("label",labelInfo.getLabel());
            json.put("labelName",labelInfo.getLabelName());
            json.put("labelType",labelInfo.getLabelType());
            jsonArray.add(json);
        });
        switch (patient.getDiseaseCondition()){
            case 0:
                com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject();
                json1.put("label","0");
                json1.put("labelName","绿标");
                json1.put("labelType","99");
                jsonArray.add(json1);
                break;
            case 1:
                com.alibaba.fastjson.JSONObject json2 = new com.alibaba.fastjson.JSONObject();
                json2.put("label",1);
                json2.put("labelName","黄标");
                json2.put("labelType","99");
                jsonArray.add(json2);
                break;
            case 2:
                com.alibaba.fastjson.JSONObject json3 = new com.alibaba.fastjson.JSONObject();
                json3.put("label",2);
                json3.put("labelName","红标");
                json3.put("labelType","99");
                jsonArray.add(json3);
                break;
            default:break;
        }
        jsonObject.put("labelList",jsonArray);
        //个人信息
        jsonObject.put("sex",patient.getSex());//性別,1男,2女
        jsonObject.put("name",patient.getName());
        jsonObject.put("doctorName",signFamily.getDoctorName());//全科医生
        jsonObject.put("hospitalName",signFamily.getHospitalName());//社区
        jsonObject.put("address",patient.getAddress());
        jsonObject.put("age", IdCardUtil.getAgeForIdcard(patient.getIdcard()));
        jsonObject.put("status",1);
        return jsonObject;
    }
    /**
     * 获取居民的家庭成员
     * @param patient 居民
     * @return
     */
    public JSONArray familyMember(String patient) {
        JSONArray resultArray = new JSONArray();
        String sql = "select * " +
                " from " +
                "    wlyy_patient_family_member t1, " +
                "    wlyy_patient t2 " +
                " where " +
                "    t2.code in (select family_member from wlyy_patient_family_member where patient = ? ) " +
                "    and t1.patient = ? " +
                "    and t1.family_member = t2.code ";
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{patient, patient});
        if (result != null && result.size() > 0) {
            for (Map<String, Object> map : result) {
                JSONObject obj = new JSONObject();
                obj.put("code", map.get("code"));
                obj.put("name", map.get("name"));
                obj.put("sex", map.get("sex"));
                obj.put("birthday", map.get("birthday"));
                obj.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
                obj.put("photo", map.get("photo"));
                obj.put("mobile", map.get("mobile"));
                obj.put("address", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
                obj.put("familyRelation", map.get("family_relation"));
                obj.put("familyRelationName", relations.get(map.get("family_relation")));
                resultArray.put(obj);
            }
        }
        return resultArray;
    }
    /**
     * 健康设备
     * @param patient
     * @return
     */
    public JSONArray healthDevice(String patient){
        List<PatientDevice> list = patientDeviceDao.findByPatient(patient);
        JSONArray jsonArray = new JSONArray();
        list.forEach(device->{
            JSONObject json = new JSONObject();
            json.put("deviceName",device.getDeviceName());
            json.put("deviceSn",device.getDeviceSn());
            json.put("categoryCode",device.getCategoryCode());
            Device d = deviceDao.findOne(device.getDeviceId());
            json.put("photo",d.getPhoto());
            jsonArray.put(json);
        });
        return jsonArray;
    }
    /**
     * 获取门/急诊记录 + 住院记录
     * @param patientCode
     * @param type (1血糖,2血压)
     * @param page
     * @param pageSize
     * @return
     * @throws Exception
     */
    public com.alibaba.fastjson.JSONObject getAllEvent(String patientCode, String type, String page, String pageSize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
        //获取患者
        Patient patient = patientDao.findByCode(patientCode);
        //获取基卫数据
        String response = jwSmjkService.getResidentEventListJson(patient.getSsc(), null, page, pageSize);
        //获取app数据
        List<PatientEvent> eventList = new ArrayList<>();
        eventList = patientEventDao.findByPatient(patientCode);
        int year = 0;//患病年数
        int eventSize = 0;//就诊次数
        int times = 0;//住院次数
        if (!StringUtils.isEmpty(response)) {
            JSONArray array = new JSONArray(response);
            if (!"[{}]".equals(response)) {
                for (int i = 0; i < array.length(); i++) {
                    JSONObject item = array.getJSONObject(i);
                    Map<String, String> map = new HashMap<>();
                    map.put("id", item.optString("EVENT"));
                    map.put("patient", patientCode);
                    map.put("eventDate", item.optString("END_TIME"));
                    map.put("eventType", item.optString("TYPE"));
                    map.put("orgName", item.optString("ORG_NAME"));
                    map.put("dianosis", item.optString("DIAGNOSIS"));
                    map.put("createTime", item.optString("END_TIME"));
                    map.put("dataFrom", "1");//基卫数据
                    if(StringUtils.isNotBlank(type)){
                        //根据icd10过滤数据
                        String icdCode = item.optString("ICD_CODE");
                        Icd10Dict icd10Dict = icd10DictDao.findByCode(icdCode);
                        if(icd10Dict==null){
                            continue;
                        }
                        if("1".equals(type)){
                            //血糖
                            if(!"2".equals(icd10Dict.getType())){
                                continue;
                            }
                        }else {
                            //血压
                            if(!"1".equals(icd10Dict.getType())){
                                continue;
                            }
                        }
                    }
                    if("2".equals(item.optString("TYPE"))){
                        times++;
                    }
                    re.add(map);
                }
            }
        }
        if(StringUtils.isEmpty(type)){
            for (PatientEvent item : eventList) {
                Map<String, String> map = new HashMap<>();
                map.put("id", item.getId().toString());
                map.put("patient", item.getPatient());
                map.put("eventDate", DateUtil.dateToStrLong(item.getEventDate()));
                map.put("eventType", item.getEventType());
                map.put("orgName", item.getOrgName());
                map.put("dianosis", item.getDianosis());
                map.put("createTime", DateUtil.dateToStrLong(item.getCreateTime()));
                map.put("dataFrom", "2");   //APP数据
                re.add(map);
            }
            //排序
            re = sortMapList(re, "eventDate", "DESC");
        }
        eventSize = re.size();
        if(eventSize>0){
            //计算患病年数
            Date startTime = DateUtil.strToDateLong(re.get(0).get("eventDate"));
            Date endTime = DateUtil.strToDateLong(re.get(eventSize-1).get("eventDate"));
            year = DateUtil.compareYear(startTime,endTime);
        }
        //统计
        com.alibaba.fastjson.JSONObject statistics = new com.alibaba.fastjson.JSONObject();
        statistics.put("year",year);
        statistics.put("eventSize",eventSize);
        statistics.put("times",times);
        json.put("statistics",statistics);
        json.put("list",re);
        return json;
    }
    /**
     * 字符串List排序
     */
    public List<Map<String, String>> sortMapList(List<Map<String, String>> mapList, final String sort, final String order) {
        Collections.sort(mapList, new Comparator<Map<String, String>>() {
            @Override
            public int compare(Map<String, String> o1, Map<String, String> o2) {
                String map1value = o1.get(sort);
                String map2value = o2.get(sort);
                if ("DESC".equals(order.toUpperCase())) {
                    return map2value.compareTo(map1value);
                } else {
                    return map1value.compareTo(map2value);
                }
            }
        });
        return mapList;
    }
}

+ 0 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java

@ -3,7 +3,6 @@ package com.yihu.wlyy.service.app.prenatalInspector;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;

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

@ -3,21 +3,16 @@ package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.charge.PatientPopups;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.entity.zydict.ZyPushLog;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.charge.PopupsDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.message.MessageDao;
@ -29,18 +24,14 @@ import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.repository.prescription.PrescriptionPayDao;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.repository.zydict.ZyPushLogDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.message.MessageService;
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.task.PushMsgTask;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.MessageType;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.wx.OnePayController;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
@ -54,7 +45,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.access.method.P;
import org.springframework.stereotype.Service;
import org.springframework.util.StreamUtils;
@ -64,7 +54,6 @@ import javax.transaction.Transactional;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.*;

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

@ -1,17 +1,11 @@
package com.yihu.wlyy.service.app.prescription;
import antlr.StringUtils;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import com.ylzinfo.onepay.sdk.utils.StringUtil;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;

+ 13 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -24,9 +24,7 @@ import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MessageType;
import io.swagger.models.auth.In;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -104,8 +102,13 @@ public class PrescriptionService extends BaseService {
     * @param type 1:确认收药 2:延长收药
     * @return
     */
    public void confirmReceipt(String prescriptionCode, Integer type) throws Exception{
    public Map<String,Object> confirmReceipt(String prescriptionCode, Integer type) throws Exception{
        Map<String,Object> result = new HashedMap();
        try {
            result.put("code",200);
            result.put("msg","确认成功");
            Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
            if (type == 1){
                //直接更改状态为已完成
@ -113,6 +116,12 @@ public class PrescriptionService extends BaseService {
            }else if (type == 2){
                //不更改状态只添加延长收药时间
                int extendCount = prescription.getExtendCount();
                if (extendCount>=1){
                    result.put("code",-1);
                    result.put("msg","每笔订单只能延长一次");
                   return  result;
                }
                prescription.setExtendTime(new Date());
                prescription.setExtendCount(prescription.getExtendCount()+1);
            }
@ -120,6 +129,7 @@ public class PrescriptionService extends BaseService {
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

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

@ -1,6 +1,5 @@
package com.yihu.wlyy.service.app.sign;
import com.yihu.es.entity.HealthEduArticleES;
import com.yihu.wlyy.entity.address.Country;
import com.yihu.wlyy.entity.address.Street;
import com.yihu.wlyy.entity.address.Town;

+ 0 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/message/SendMessageService.java

@ -1,9 +1,6 @@
package com.yihu.wlyy.service.message;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.SMSService;

+ 0 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java

@ -23,7 +23,6 @@ import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import springfox.documentation.spring.web.json.Json;
import java.text.SimpleDateFormat;
import java.util.*;

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java

@ -2,8 +2,10 @@ package com.yihu.wlyy.service.template;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.ImUtill;
@ -18,7 +20,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**

+ 0 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/ImmuneService.java

@ -3,16 +3,10 @@ package com.yihu.wlyy.service.third.guahao;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.security.AccessToken;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.service.common.account.AccessTokenService;
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.util.HttpUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
@ -23,7 +17,6 @@ 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.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;

+ 292 - 11
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -12,6 +12,7 @@ import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -23,6 +24,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
@ -37,12 +39,20 @@ public class PushMsgTask {
    private HttpUtil httpUtil;
    @Value("${server.server_url}")
    private String server_url;
    @Value("${wechat.message.template_consult_notice}")
    private String template_consult_notice;
    @Value("${pushMes.method}")
    private String putMesMethod;
    @Value("${pushMes.redis_prescription_title}")
    private String redisQueue;
    @Value("${putMesType.wechat}")
    private String putMesType;
    //模板id
    @Value("${wechat.message.template_sign_success}")
    private String template_sign_success;
    @Value("${wechat.message.template_sign_failed}")
    private String template_sign_failed;
    @Value("${wechat.message.template_consult_notice}")
    private String template_consult_notice;
    @Value("${wechat.message.template_health_notice}")
    private String template_health_notice;
    @Value("${wechat.message.template_termination}")
@ -61,16 +71,15 @@ public class PushMsgTask {
    private String template_doctor_survey;
    @Value("${wechat.message.template_doctor_audit}")
    private String template_doctor_audit;//审核结果通知
    @Value("${wechat.message.template_physical_examination}")
    private String template_physical_examination;//体检提醒
    @Value("${wechat.message.template_doctor_service}")
    private String template_doctor_service;//服务结果通知
    @Value("${pushMes.method}")
    private String putMesMethod;
    @Value("${pushMes.redis_prescription_title}")
    private String redisQueue;
    @Value("${putMesType.wechat}")
    private String putMesType;
    @Value("${wechat.message.template_physical_examination}")
    private String template_physical_examination;//体检提醒
    @Value("${wechat.message.doctor_invitel_template}")
    private String doctor_invitel_template;
    @Value("${wechat.message.template_deal_with}")
    private String template_deal_with;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
@ -137,6 +146,41 @@ public class PushMsgTask {
        }
    }
    /**
     * 根据type及场景值添加微信消息
     * @param access_token
     * @param type
     * @param scene
     * @param openid
     * @param name
     * @param data  packageTemplate方法打包后的模板数据
     */
    public void putWxMsg(String access_token, int type,String scene, String openid, String name, JSONObject data) {
        try {
            JSONObject json = new JSONObject();
            json.put("wx", true);
            json.put("access_token", access_token);
            json.put("type", type);
            json.put("scene", scene);
            json.put("openid", openid);
            json.put("name", name);
            json.put("data", data);
            //如果是内网推送到redis,如果是外网推送到内存队列
            if (putMesMethod.equals("1")) {
                JSONObject mes = new JSONObject();
                mes.put("title", putMesType);
                mes.put("value", json.toString());
                redisTemplate.opsForList().leftPush(redisQueue, mes.toString());
            } else {
                queue.put(json);
            }
        } catch (Exception e) {
            logger.error("添加到微信消息列队列失败!", e);
            e.printStackTrace();
        }
    }
    public void put(JSONArray array) {
        if (array == null || array.length() == 0) {
            return;
@ -186,12 +230,14 @@ public class PushMsgTask {
                        if (type == -1) {
                            continue;
                        }
                        String scene = json.has("scene") ? json.getString("scene") : "";
                        String access_token = json.has("access_token") ? json.getString("access_token") : "";
                        String openid = json.has("openid") ? json.getString("openid") : "";
                        String name = json.has("name") ? json.getString("name") : "";
//                        String name = data.has("name") ? json.getString("name") : "";
                        // 发送消息到微信端
                        sendWeixinMessage(access_token, type, openid, name, data);
//                        sendWeixinMessage(access_token, type,scene, openid, name, data);
                    } else {
                        // 推送平台消息
                        String receiver = json.has("receiver") ? json.getString("receiver") : "";
@ -242,7 +288,6 @@ public class PushMsgTask {
     *             type==20时:{"first":"消息主题","keyword1":"服务项目","keyword2":"操作医生","keyword3":"服务时间","remark":"消息备注"}
     * @return
     */
//    private boolean sendWeixinMessage(String access_token, int type, String openid, String name, JSONObject json) {
    public boolean sendWeixinMessage(String access_token, int type, String openid, String name, JSONObject json) {
        try {
            if (StringUtils.isEmpty(openid)) {
@ -290,6 +335,64 @@ public class PushMsgTask {
        }
    }
    /**
     *
     * @param access_token
     * @param type
     * @param openid
     * @param name
     * @param json
     * @return
     */
    public boolean sendWeixinMessage(String access_token, int type,String scene, String openid, String name, JSONObject json) {
        try {
            if (StringUtils.isEmpty(openid)) {
                logger.error("send wechat message failed:openid is empty");
                return false;
            }
            if (access_token != null) {
                String token_url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + access_token;
                String params = json.toString();
                if (params == "") {
                    logger.error("参数错误!error");
                    return false;
                }
                WechatPushLog log = new WechatPushLog();
                log.setType(type);
                log.setScene(scene);
                log.setCreateTime(new Date());
                log.setName(name);
                log.setOpenid(openid);
                if (!json.isNull("toUser")) {
                    log.setPatient(json.getString("toUser"));
                }
                log.setRequest(json.toString());
                String result = httpUtil.sendPost(token_url, params);
                JSONObject jsonResult = new JSONObject(result);
                log.setResponse(result);
                if (Integer.parseInt(jsonResult.get("errcode").toString()) == 0) {
                    logger.info("微信信息推送成功!success");
                    log.setStatus(1);
                    wechatPushLogDao.save(log);
                    return true;
                } else {
                    log.setStatus(0);
                    wechatPushLogDao.save(log);
                    logger.error("错误编码:" + jsonResult.get("errcode").toString() + "  错误提示:" + jsonResult.get("errmsg").toString());
                    return false;
                }
            } else {
                logger.error("获取access_token失败!");
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("微信信息推送失败!");
            return false;
        }
    }
    /**
     * 拼接参数
     *
@ -757,4 +860,182 @@ public class PushMsgTask {
        return flag;
    }
    /**
     * 添加含发送代理人微信消息
     *
     * @param code 发送对象code
     * @param type 模板类型
     * @param scene 模板场景值
     * @param wechatTemplate 微信消息模板推送内容
     * @return
     */
    public Boolean putAgentWxMsg(String code, int type,String scene, WechatTemplate wechatTemplate) {
        Boolean flag = false;
        try {
            Patient patient = patientDao.findByCode(code);
            String name = patient.getName();
            String openId = patient.getOpenid();
             ObjectMapper mapper = new ObjectMapper();
            String data = mapper.writeValueAsString(wechatTemplate);
            JSONObject wechatContent = new JSONObject(data);
            if (StringUtils.isNotEmpty(openId) && !("undefined".equals(openId))) {
                putWxMsg(accessTokenUtils.getAccessToken(), type, scene, openId, name, wechatContent);
                flag = true;
            } else {
                //发送代理人
                org.json.JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(code, 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");
                        Map<String, WechatTemplateData> contentData = wechatTemplate.getData();
                        WechatTemplateData firstData = contentData.get("first");
                        String url = wechatTemplate.getUrl();
                        String first = firstData.getValue();
                        WechatTemplateData firstKeyword = new WechatTemplateData();
                        firstKeyword.setColor("#000000");
                        firstKeyword.setValue(weiXinOpenIdUtils.getTitleMes(patient, j.getInt("relation"), name) + first);
                        contentData.put("first", firstKeyword);
                        //替换掉原toUser、toName的值
                        int start = url.indexOf("&toUser=");
                        int end = url.indexOf("&", start + 1);
                        String touser = url.substring(start, end);
                        url = url.replace(touser, "&toUser=" + member.getCode());
                        wechatTemplate.setTouser(member.getOpenid());
                        wechatTemplate.setUrl(url);
                        wechatTemplate.setData(contentData);
                        String data1 = mapper.writeValueAsString(wechatTemplate);
                        JSONObject wechatContent1 = new JSONObject(data1);
                        if (StringUtils.isNotEmpty(member.getOpenid()) && !("undefined".equals(member.getOpenid()))) {
                            putWxMsg(accessTokenUtils.getAccessToken(), type, scene, openId, name, wechatContent1);
                            flag = true;
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }
    /**
     * 根据type 匹配对应模板ID
     *
     * @param type 见WechatPushLog说明
     * @return
     */
    private String getTemplateId(int type) throws Exception {
        String templateId = null;
        switch (type) {
            case 1:
                templateId = template_sign_success;
                break;
            case 2:
                templateId = template_sign_failed;
                break;
            case 3:
                templateId = template_consult_notice;
                break;
            case 4:
                templateId = template_health_notice;
                break;
            case 5:
                templateId = template_termination;
                break;
            case 6:
                templateId = template_appoint_success;
                break;
            case 7:
                templateId = template_appoint_failed;
                break;
            case 8:
                templateId = template_expenses_remind;
                break;
            case 9:
                templateId = template_healthy_article;
                break;
            case 10:
                templateId = template_doctor_change;
                break;
            case 11:
                templateId = template_doctor_survey;
                break;
            case 12:
                templateId = template_doctor_audit;
                break;
            case 13:
                templateId = template_doctor_service;
                break;
            case 14:
                templateId = template_physical_examination;
                break;
            case 15:
                templateId = doctor_invitel_template;
                break;
            case 16:
                templateId = template_deal_with;
                break;
        }
        return templateId;
    }
    /**
     * 构建微信模板数据 默认字体黑色
     *
     * @param type      模板类型见日志实体类
     * @param openid    发送对象openid
     * @param first    消息头
     * @param remark   备注
     * @param url   带参全路径跳转链接
     * @param keywords 消息体
     * @return
     */
    public WechatTemplate packageTemplate(int type,String openid, String first, String remark, String url, List<String> keywords) throws Exception{
        WechatTemplate temp = new WechatTemplate();
        try {
            String templateId = getTemplateId(type);
            Map<String, WechatTemplateData> m = new HashMap<String, WechatTemplateData>();
            WechatTemplateData firstKeyword = new WechatTemplateData();
            firstKeyword.setColor("#000000");
            firstKeyword.setValue(first);
            m.put("first", firstKeyword);
            WechatTemplateData remarkKeyword = new WechatTemplateData();
            remarkKeyword.setColor("#000000");
            remarkKeyword.setValue(remark);
            m.put("remark", remarkKeyword);
            for (int i=0;i<keywords.size();i++){
                WechatTemplateData tempKeyword = new WechatTemplateData();
                tempKeyword.setColor("#000000");
                tempKeyword.setValue(keywords.get(i));
                m.put("keyword"+(i+1), tempKeyword);
            }
            temp.setTouser(openid);
            temp.setTemplate_id(templateId);
            temp.setTopcolor("#000000");
            temp.setUrl(url);
            temp.setData(m);
           /* ObjectMapper mapper = new ObjectMapper();
            String data = mapper.writeValueAsString(temp);
            result = new JSONObject(data);*/
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return temp;
    }
}

+ 25 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -1273,4 +1273,29 @@ public class DateUtil {
		 return new Timestamp(calendar.getTimeInMillis());
	 }
	/**
	 * 比较2个时间相差月份
	 * @return
     */
	public static int compareYear(Date start,Date end){
		int re = 1;
		Calendar cal1 = Calendar.getInstance();
		Calendar cal2 = Calendar.getInstance();
		cal1.setTime(start);
		cal2.setTime(end);
		int year = cal2.get(Calendar.YEAR)-cal1.get(Calendar.YEAR);
		int month = cal2.get(Calendar.MONTH)-cal1.get(Calendar.MONTH);
		int day = cal2.get(Calendar.DAY_OF_MONTH)-cal1.get(Calendar.DAY_OF_MONTH);
		if(year>0){
			re = year;
			if(month>0){
				re++;
			}else if(month==0&&day>=0){
				re++;
			}
		}
		return re;
	}
}

+ 81 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/MyJdbcTemplate.java

@ -0,0 +1,81 @@
package com.yihu.wlyy.util;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.stereotype.Component;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
 * @author yeshijie on 2018/2/12.
 */
@Component
public class MyJdbcTemplate {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * jdbc查询返回json
     * @param sql
     * @param args
     * @return
     * @throws DataAccessException
     */
    public List<JSONObject> queryJson(String sql, Object[] args) throws DataAccessException {
        return jdbcTemplate.query(sql, args, new ResultSetExtractor<List<JSONObject>>() {
            @Override
            public List<JSONObject> extractData(ResultSet rs) throws SQLException, DataAccessException {
                ResultSetMetaData rsd = rs.getMetaData();
                int clength = rsd.getColumnCount();
                List<JSONObject> li = new ArrayList<JSONObject>();
                try {
                    while (rs.next()) {
                        JSONObject jo = new JSONObject();
                        for (int i = 0; i < clength; i++) {
                            String columnName = rsd.getColumnLabel(i + 1);
                            jo.put(columnName, rs.getObject(i + 1));
                        }
                        li.add(jo);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return li;
            }
        });
    }
    public List<JSONObject> queryJson(String sql) throws DataAccessException {
        return jdbcTemplate.query(sql, new ResultSetExtractor<List<JSONObject>>() {
            @Override
            public List<JSONObject> extractData(ResultSet rs) throws SQLException, DataAccessException {
                ResultSetMetaData rsd = rs.getMetaData();
                int clength = rsd.getColumnCount();
                List<JSONObject> li = new ArrayList<JSONObject>();
                try {
                    while (rs.next()) {
                        JSONObject jo = new JSONObject();
                        for (int i = 0; i < clength; i++) {
                            String columnName = rsd.getColumnLabel(i + 1);
                            jo.put(columnName, rs.getObject(i + 1));
                        }
                        li.add(jo);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return li;
            }
        });
    }
}

+ 0 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/feedback/DoctorFeedbackTemplateController.java

@ -1,16 +1,11 @@
package com.yihu.wlyy.web.doctor.feedback;
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.feedback.Feedback;
import com.yihu.wlyy.service.app.feedback.FeedbackService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.CommonUtil;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

+ 0 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java

@ -13,15 +13,10 @@ import com.yihu.wlyy.service.app.health.*;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.third.gateway.service.GcEduArticleService;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
import com.yihu.wlyy.web.third.gateway.vo.base.ResultPageListModel;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -36,18 +31,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
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.*;
/**

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/intervene/DoctorInterveneController.java

@ -6,6 +6,7 @@ import java.util.Iterator;
import java.util.List;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.task.PushMsgTask;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.json.JSONArray;
@ -27,7 +28,6 @@ import com.yihu.wlyy.entity.patient.PatientSelfInspectionItem;
import com.yihu.wlyy.service.app.device.PatientDeviceService;
import com.yihu.wlyy.service.app.intervene.PatientInspectionService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MessageType;
import com.yihu.wlyy.web.BaseController;

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/medical/DoctorMedicalRecordController.java

@ -4,6 +4,7 @@ import java.util.Date;
import java.util.List;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.task.PushMsgTask;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
@ -24,7 +25,6 @@ import com.yihu.wlyy.entity.patient.PatientMedicalRecords;
import com.yihu.wlyy.entity.patient.PatientMedicalRecordsItem;
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
import com.yihu.wlyy.service.app.medicines.MedicalRecordsService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MessageType;
import com.yihu.wlyy.web.BaseController;

+ 0 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/booking/PatientBookingController.java

@ -21,11 +21,9 @@ import com.yihu.wlyy.service.third.guahao.ImmuneService;
import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.NetworkUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.third.zysoft.BookingController;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultCommunicationController.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.patient.consult;
import java.util.Date;
//import io.swagger.annotations.Api;
import com.yihu.wlyy.task.PushMsgTask;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
@ -20,7 +21,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.yihu.wlyy.entity.consult.ConsultCommunication;
import com.yihu.wlyy.entity.consult.ConsultCommunicationReply;
import com.yihu.wlyy.service.app.consult.ConsultCommunicationService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MessageType;

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

@ -269,8 +269,10 @@ public class PatientPrescriptionController extends WeixinBaseController {
            @RequestParam(required = true) @ApiParam(value = "处方code", name = "prescriptionCode") String prescriptionCode,
            @RequestParam(required = true) @ApiParam(value = "收药方式", name = "type") Integer type) {
        try {
            prescriptionService.confirmReceipt(prescriptionCode,type);
            return write(200, "确认成功");
            Map<String,Object> result = prescriptionService.confirmReceipt(prescriptionCode,type);
            int code = Integer.parseInt(result.get("code").toString());
            String msg = result.get("msg").toString();
            return write(code, msg);
        } catch (Exception e) {
            return error(-1, "确认失败");
        }

+ 190 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/iot/IotMonitoringHealthController.java

@ -0,0 +1,190 @@
package com.yihu.wlyy.web.third.gateway.controller.iot;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.app.device.PatientDeviceService;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * 提供 物联网 - 远程健康监测平台 新增接口
 * @author yeshijie on 2018/2/11.
 */
@RestController
@RequestMapping(value = "/wlyygc/iot_monitoring",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "远程健康监测平台")
public class IotMonitoringHealthController extends BaseController {
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Autowired
    private PatientHealthIndexService healthIndexService;
    @RequestMapping(value = "/equipmentDistribution",method = RequestMethod.GET)
    @ApiOperation("设备发放情况")
    public String equipmentDistribution(){
        try {
            return write(200,"查询成功","data",patientDeviceService.equipmentDistribution());
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/chronicDiseaseCount",method = RequestMethod.GET)
    @ApiOperation("慢病患者情况-统计")
    public String chronicDiseaseCount(
            @ApiParam(name="type",value="类型(2糖尿病,1高血压)",defaultValue = "")
            @RequestParam(value="type",required = false) String type){
        try {
            return write(200,"查询成功","data",patientDeviceService.chronicDiseaseCount(type));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/warningInformationAlarm",method = RequestMethod.GET)
    @ApiOperation("预警信息警报")
    public String warningInformationAlarm(
            @ApiParam(name="page",value="第几页(默认第一页)",defaultValue = "1")
            @RequestParam(value="page",required = false) Integer page,
            @ApiParam(name="pageSize",value="每页几行(默认10条记录)",defaultValue = "10")
            @RequestParam(value="pageSize",required = false) Integer pageSize){
        try {
            if(page==null){
                page = 1;
            }
            if(pageSize==null){
                pageSize = 10;
            }
            return write(200,"查询成功","data",patientDeviceService.warningInformationAlarm(page,pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/deviceBinding",method = RequestMethod.GET)
    @ApiOperation("设备绑定情况")
    public String deviceBinding(
            @ApiParam(name="type",value="设备类型(1血糖仪,2血压计)",defaultValue = "")
            @RequestParam(value="type",required = false) String type){
        try {
            return write(200,"查询成功","data",patientDeviceService.deviceBinding(type));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/persionalInfo",method = RequestMethod.GET)
    @ApiOperation("个人信息")
    public String persionalInfo(@ApiParam(name="patient",value="居民code",defaultValue = "")
                                @RequestParam(value="patient",required = true) String patient){
        try {
            JSONObject jsonObject = patientDeviceService.persionalInfo(patient);
            Integer status = jsonObject.getInteger("status");
            if(status==-1){
                return error(-1,"居民未签约");
            }
            jsonObject.remove("status");
            return write(200,"查询成功","data",jsonObject);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/familyMember",method = RequestMethod.GET)
    @ApiOperation("家人信息")
    public String familyMember(@ApiParam(name="patient",value="居民code",defaultValue = "")
                                @RequestParam(value="patient",required = true) String patient){
        try {
            return write(200,"查询成功","data",patientDeviceService.familyMember(patient));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/healthDevice",method = RequestMethod.GET)
    @ApiOperation("健康设备")
    public String healthDevice(@ApiParam(name="patient",value="居民code",defaultValue = "")
                               @RequestParam(value="patient",required = true) String patient){
        try {
            return write(200,"查询成功","data",patientDeviceService.healthDevice(patient));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "chart", method = RequestMethod.GET)
    @ApiOperation("根据患者标志获取健康指标(图表)")
    public String getHealthIndexChartByPatient(@ApiParam(name="patient",value="居民code",defaultValue = "")
                                               @RequestParam(value="patient",required = true) String patient,
                                               @ApiParam(name = "type", value = "指标类型(1血糖,2血压,3体重,4腰围)", defaultValue = "1")
                                               @RequestParam(value = "type", required = true) int type,
                                               @ApiParam(name = "gi_type", value = "就餐类型0全部", defaultValue = "1")
                                               @RequestParam(value = "gi_type", required = false) int gi_type,
                                               @ApiParam(name = "begin", value = "开始时间", defaultValue = "2017-05-22 00:00:00")
                                               @RequestParam(value = "begin", required = true) String begin,
                                               @ApiParam(name = "end", value = "结束时间", defaultValue = "2017-06-02 00:00:00")
                                               @RequestParam(value = "end", required = true) String end) {
        try {
            JSONArray jsonArray = healthIndexService.findChartByPatient(patient, type, gi_type, begin, end);
            if (jsonArray.length()==0) {
                return success("查询成功!");
            }
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    @ApiOperation("获取门诊记录/住院记录(基卫+APP)")
    @RequestMapping(value = "/event", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public String getAllEvent(@ApiParam(name = "patient", value = "患者代码", defaultValue = "")
                              @RequestParam(value = "patient", required = true) String patient,
                              @ApiParam(name = "type", value = "类型(1血糖,2血压)", defaultValue = "")
                              @RequestParam(value = "type", required = false) String type,
                              @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) {
        try {
            JSONObject jsonObject = patientDeviceService.getAllEvent(patient, type, page, pageSize);
            return write(200, "获取就诊记录成功!", "data", jsonObject);
        } catch (Exception e) {
            error(e);
            if (e.getMessage().indexOf("卡号尚未在医疗机构注册过") > 0) {
                return error(-1, "对不起,您的社保卡有变更,请改天再试");
            } else if (e.getMessage().startsWith("error")) {
                return error(-1, e.getMessage());
            } else {
                return error(-1, "获取门/急诊数据失败!");
            }
        }
    }
}

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/template/ThirdTemplateController.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.third.template;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.service.template.DoctorFeldsherTemplateService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.wechat.util.WeiXinTempMsgSendUtils;

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

@ -61,7 +61,7 @@ wechat:
   template_healthy_article: a5-ZGf-IUUULsuRNoHWQiBMU6pSYhLgPPqV67SjdLRo
   #医生变更
   template_doctor_change:  dtzSHImbPKfwcrjWlJEjAw3lGlvrLjsobSOE8g4adZA
   #问卷调查
   #代办事项
   template_doctor_survey:  8ZWKJmoJ7VR7Uk4YS7aa0Z94QzCkxsyTW6R4CHhUJII
   #审核结果通知
   template_doctor_audit:  egrX5Larpkv8opQW67_hwsZoT0OHwwUpE1v7HeU_Jnw

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

@ -81,8 +81,8 @@
        },
        {
        	 "type":"view",
        	 "name":"意见反馈",
        	 "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fyjfk%2fhtml%2ffeedback.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        	 "name":"电子健康卡",
        	 "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fgrzx%2fhtml%2fmy-health-card.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        }
	 ]
  }