Browse Source

极光消息推送

wangjun 4 years ago
parent
commit
bb3f42e471

+ 11 - 5
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -11468,14 +11468,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
        jsonObject.put("platform","all");
        com.alibaba.fastjson.JSONObject audience = new com.alibaba.fastjson.JSONObject();
        audience.put("alias",userId);
        com.alibaba.fastjson.JSONArray jsonArray = new com.alibaba.fastjson.JSONArray();
        jsonArray.add(userId);
        audience.put("alias",jsonArray);
        jsonObject.put("audience",audience);
        com.alibaba.fastjson.JSONObject notification = new com.alibaba.fastjson.JSONObject();
        com.alibaba.fastjson.JSONObject android = new com.alibaba.fastjson.JSONObject();
        android.put("alert",alert);
        android.put("title",title);
        android.put("extras",extras);
        android.put("builder_id","1");
        android.put("builder_id",1);
        com.alibaba.fastjson.JSONObject ios = new com.alibaba.fastjson.JSONObject();
        ios.put("alert",alert);
        ios.put("sound","default");
@ -11484,10 +11486,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        notification.put("android",android);
        notification.put("ios",ios);
        jsonObject.put("notification",notification);
        System.out.println(notification.toString());
        String url = "https://api.jpush.cn/v3/push";
        Map<String, Object> headerMap = new HashedMap();
        headerMap.put("Authorization",auth);
        headerMap.put("Content-Type","application/json");
        /*headerMap.put("Content-Length",1024);
        headerMap.put("Host","127.0.0.1");*/
        logger.info("极光推送参数"+jsonObject);
        String response = httpClientUtil.postBodyHead(url,jsonObject,headerMap);
        logger.info("极光推送返回日志==="+response);
        WlyyHttpLogDO httpLogDO = new WlyyHttpLogDO();
@ -11621,12 +11627,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                }else if ("3".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())&&"1".equalsIgnoreCase(wlyyOutpatientDO.getType())){
                    content = baseJpushTemplateDO.getPushContent().replace("{{咨询类型}}","图文咨询").replace("{{医生姓名}}",wlyyOutpatientDO.getDoctorName());
                    title=baseJpushTemplateDO.getPushHeader().replace("{{咨询类型}}","图文咨询");
                    jsonObject.put("type",41);
                    jsonObject.put("type",18);
                }else if ("3".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())&&"2".equalsIgnoreCase(wlyyOutpatientDO.getType())){
                    content = baseJpushTemplateDO.getPushContent().replace("{{咨询类型}}","视频咨询").replace("{{医生姓名}}",wlyyOutpatientDO.getDoctorName());
                    title=baseJpushTemplateDO.getPushHeader().replace("{{咨询类型}}","视频咨询");
                    content+= "视频咨询预约时间为:"+wlyyOutpatientDO.getRegisterDate();
                    jsonObject.put("type",42);
                    jsonObject.put("type",17);
                }else if ("2".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())){
                    content = baseJpushTemplateDO.getPushContent().replace("{{咨询类型}}","协同复诊").replace("{{医生姓名}}",wlyyOutpatientDO.getDoctorName());
                    title=baseJpushTemplateDO.getPushHeader().replace("{{咨询类型}}","协同复诊");
@ -11634,7 +11640,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                }else if ("3".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())&&"3".equalsIgnoreCase(wlyyOutpatientDO.getType())){
                    content = baseJpushTemplateDO.getPushContent().replace("{{咨询类型}}","家医咨询").replace("{{医生姓名}}",wlyyOutpatientDO.getDoctorName());
                    title=baseJpushTemplateDO.getPushHeader().replace("{{咨询类型}}","家医咨询");
                    jsonObject.put("type",43);
                    jsonObject.put("type",15);
                }
            }
            userId = wlyyOutpatientDO.getDoctor();

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/dict/BaseJpushTemplateDO.java

@ -8,7 +8,7 @@ import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "base_supervise_data_dict")
@Table(name = "base_jpush_template")
public class BaseJpushTemplateDO extends UuidIdentityEntityWithOperator {
    private String code;
    private String name;