huangfuli 2 năm trước cách đây
mục cha
commit
7f46d3d40e

+ 5 - 0
winsea-haixin-platform-backend/src/main/resources/application.yml

@@ -22,6 +22,11 @@ spring:
     prefix: classpath:/templates/
     suffix: .html
 
+#运行环境 1.开发环境 2.测试环境 3.生产环境
+com:
+  yiliangyiyun:
+    env: 1
+
 auth:
   anon-methods:
     - GET

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 382 - 389
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/WarehousingOrderServiceImpl.java


+ 108 - 103
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/GeTuiUtils.java

@@ -35,6 +35,7 @@ import com.yh.saas.plugin.yiliangyiyun.mapper.CommonUserMapper;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.http.HttpResponse;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import java.io.*;
@@ -58,6 +59,8 @@ public class GeTuiUtils {
     private static String appKey = "L0gnzFQa2O8aFW15lPRzh2";
     private static String masterSecret = "NhuCKHZJhp877ofHWtlQWA";
     PushApi pushApi = null;
+    @Value("${com.yiliangyiyun.env}")
+    private String ENV;
 
     //别名推送方式
     static String host = "http://sdk.open.api.igexin.com/apiex.htm";
@@ -77,114 +80,116 @@ public class GeTuiUtils {
     }
 
     public void pushByCid(String title,String content,String userId){
-        try{
-            CommonUser userDO =  commonUserMapper.selectById(userId);
-            String cid = userDO.getCid();
-            //根据cid进行单推
-            PushDTO<Audience> pushDTO = new PushDTO<Audience>();
-            // 设置推送参数
-            pushDTO.setRequestId(System.currentTimeMillis() + "");//requestid需要每次变化唯一
-            //配置推送条件
-            // 1: 表示该消息在用户在线时推送个推通道,用户离线时推送厂商通道;
-            // 2: 表示该消息只通过厂商通道策略下发,不考虑用户是否在线;
-            // 3: 表示该消息只通过个推通道下发,不考虑用户是否在线;
-            // 4: 表示该消息优先从厂商通道下发,若消息内容在厂商通道代发失败后会从个推通道下发。
-            Strategy strategy=new Strategy();
-            strategy.setDef(1);
-            Settings settings=new Settings();
-            settings.setStrategy(strategy);
-            pushDTO.setSettings(settings);
-            settings.setTtl(3600000);//消息有效期,走厂商消息需要设置该值
-            //推送苹果离线通知标题内容
-            Alert alert=new Alert();
-            alert.setTitle(title);
-            alert.setBody(content);
-            Aps aps = new Aps();
-            //1表示静默推送(无通知栏消息),静默推送时不需要填写其他参数。
-            //苹果建议1小时最多推送3条静默消息
-            aps.setContentAvailable(0);
-            aps.setSound("default");
-            aps.setAlert(alert);
-            IosDTO iosDTO = new IosDTO();
-            iosDTO.setAps(aps);
-            iosDTO.setType("notify");
-            PushChannel pushChannel = new PushChannel();
-            pushChannel.setIos(iosDTO);
-            //安卓离线厂商通道推送消息体
+        if ("3".equals(ENV)) {
+            try {
+                CommonUser userDO = commonUserMapper.selectById(userId);
+                String cid = userDO.getCid();
+                //根据cid进行单推
+                PushDTO<Audience> pushDTO = new PushDTO<Audience>();
+                // 设置推送参数
+                pushDTO.setRequestId(System.currentTimeMillis() + "");//requestid需要每次变化唯一
+                //配置推送条件
+                // 1: 表示该消息在用户在线时推送个推通道,用户离线时推送厂商通道;
+                // 2: 表示该消息只通过厂商通道策略下发,不考虑用户是否在线;
+                // 3: 表示该消息只通过个推通道下发,不考虑用户是否在线;
+                // 4: 表示该消息优先从厂商通道下发,若消息内容在厂商通道代发失败后会从个推通道下发。
+                Strategy strategy = new Strategy();
+                strategy.setDef(1);
+                Settings settings = new Settings();
+                settings.setStrategy(strategy);
+                pushDTO.setSettings(settings);
+                settings.setTtl(3600000);//消息有效期,走厂商消息需要设置该值
+                //推送苹果离线通知标题内容
+                Alert alert = new Alert();
+                alert.setTitle(title);
+                alert.setBody(content);
+                Aps aps = new Aps();
+                //1表示静默推送(无通知栏消息),静默推送时不需要填写其他参数。
+                //苹果建议1小时最多推送3条静默消息
+                aps.setContentAvailable(0);
+                aps.setSound("default");
+                aps.setAlert(alert);
+                IosDTO iosDTO = new IosDTO();
+                iosDTO.setAps(aps);
+                iosDTO.setType("notify");
+                PushChannel pushChannel = new PushChannel();
+                pushChannel.setIos(iosDTO);
+                //安卓离线厂商通道推送消息体
 //            PushChannel pushChannel = new PushChannel();
-            AndroidDTO androidDTO = new AndroidDTO();
-            Ups ups = new Ups();
-            ThirdNotification notification1 = new ThirdNotification();;
-            notification1.setTitle(title);
-            notification1.setBody(content);
-            notification1.setClickType("intent");
-            notification1.setIntent("intent:#Intent;launchFlags=0x04000000;action=android.intent.action.oppopush;component=uni.UNI7297DA2/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title="+title+";S.content="+content+";S.payload=test;end");
-            ups.setNotification(notification1);
-            //各厂商自有功能单项设置
-            ups.addOption("HW", "/message/android/notification/badge/class", "io.dcloud.PandoraEntry ");
-            ups.addOption("HW", "/message/android/notification/badge/add_num", 1);
-            ups.addOption("HW", "/message/android/notification/sound", "/raw/ring");
-            ups.addOption("HW", "/message/android/notification/channel_id", "task2");
-            ups.addOption("HW", "/message/android/notification/importance", "NORMAL");
-            ups.addOption("HW", "/message/android/notification/category", "WORK");
-            ups.addOption("HW", "/message/android/notification/default_sound", false);
-            ups.addOption("XM", "/extra.sound_uri", "android.resource://uni.UNI7297DA2/raw/task1");
-            ups.addOption("XM", "/extra.channel_id", "high_custom_5");
-            //ups.addOption("VV","classification",1);
-            androidDTO.setUps(ups);
-            pushChannel.setAndroid(androidDTO);
-            pushDTO.setPushChannel(pushChannel);
-            // PushMessage在线走个推通道才会起作用的消息体
-            PushMessage pushMessage = new PushMessage();
-            GTNotification gtNotification = new GTNotification();
-            gtNotification.setTitle(title);
-            gtNotification.setBody(content);
-            gtNotification.setRingName("ring");
-            gtNotification.setChannelId("task1");
-            gtNotification.setChannelName("工作事项提醒");
-            gtNotification.setChannelLevel("4");
-            gtNotification.setClickType("startapp");
-            gtNotification.setLogo("logo.png");
-            pushMessage.setNotification(gtNotification);
+                AndroidDTO androidDTO = new AndroidDTO();
+                Ups ups = new Ups();
+                ThirdNotification notification1 = new ThirdNotification();
+                ;
+                notification1.setTitle(title);
+                notification1.setBody(content);
+                notification1.setClickType("intent");
+                notification1.setIntent("intent:#Intent;launchFlags=0x04000000;action=android.intent.action.oppopush;component=uni.UNI7297DA2/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title=" + title + ";S.content=" + content + ";S.payload=test;end");
+                ups.setNotification(notification1);
+                //各厂商自有功能单项设置
+                ups.addOption("HW", "/message/android/notification/badge/class", "io.dcloud.PandoraEntry ");
+                ups.addOption("HW", "/message/android/notification/badge/add_num", 1);
+                ups.addOption("HW", "/message/android/notification/sound", "/raw/ring");
+                ups.addOption("HW", "/message/android/notification/channel_id", "task2");
+                ups.addOption("HW", "/message/android/notification/importance", "NORMAL");
+                ups.addOption("HW", "/message/android/notification/category", "WORK");
+                ups.addOption("HW", "/message/android/notification/default_sound", false);
+                ups.addOption("XM", "/extra.sound_uri", "android.resource://uni.UNI7297DA2/raw/task1");
+                ups.addOption("XM", "/extra.channel_id", "high_custom_5");
+                //ups.addOption("VV","classification",1);
+                androidDTO.setUps(ups);
+                pushChannel.setAndroid(androidDTO);
+                pushDTO.setPushChannel(pushChannel);
+                // PushMessage在线走个推通道才会起作用的消息体
+                PushMessage pushMessage = new PushMessage();
+                GTNotification gtNotification = new GTNotification();
+                gtNotification.setTitle(title);
+                gtNotification.setBody(content);
+                gtNotification.setRingName("ring");
+                gtNotification.setChannelId("task1");
+                gtNotification.setChannelName("工作事项提醒");
+                gtNotification.setChannelLevel("4");
+                gtNotification.setClickType("startapp");
+                gtNotification.setLogo("logo.png");
+                pushMessage.setNotification(gtNotification);
 //            pushMessage.setTransmission(" {title:\""+title+"\",content:\""+content+"\",payload:\"test\"}");
-            pushDTO.setPushMessage(pushMessage);
+                pushDTO.setPushMessage(pushMessage);
 //            pushMessage.setTransmission(" {title:\"标题\",content:\"内容\",payload:\"自定义数据\"}");
-            // 设置接收人信息
-            Audience audience = new Audience();
-            pushDTO.setAudience(audience);
-            audience.addCid(cid);
+                // 设置接收人信息
+                Audience audience = new Audience();
+                pushDTO.setAudience(audience);
+                audience.addCid(cid);
 
-            // 进行cid单推
-            ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushToSingleByCid(pushDTO);
-            if (apiResult.isSuccess()) {
-                // success
-                System.out.println("个推 通知消息3:"+apiResult.getData());
-            } else {
-                // failed
-                System.out.println("code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
-            }
-            //推送穿透消息
-            IGtPush push = new IGtPush(host, appKey, masterSecret);
-            TransmissionTemplate template = genTransmissionTemplate(content, title);// 设定消息模式为透传
-            SingleMessage msg = new SingleMessage();// 个人推送
-            msg.setOffline(true);
-            msg.setOfflineExpireTime(2 * 1000 * 3600);
-            msg.setData(template);
-            Target target = new Target();// 设定接收人
-            target.setAppId(appId);
-            target.setClientId(cid);
-            try {
-                IPushResult ret = push.pushMessageToSingle(msg, target);
-                System.out.println("个推 通知消息1:"+ret.getResponse().toString());
-            } catch (RequestException e) {
-                String requstId = e.getRequestId();
-                IPushResult ret = push.pushMessageToSingle(msg, target, requstId);
-                System.out.println("个推 通知消息2:"+ret.getResponse().toString());
+                // 进行cid单推
+                ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushToSingleByCid(pushDTO);
+                if (apiResult.isSuccess()) {
+                    // success
+                    System.out.println("个推 通知消息3:" + apiResult.getData());
+                } else {
+                    // failed
+                    System.out.println("code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
+                }
+                //推送穿透消息
+                IGtPush push = new IGtPush(host, appKey, masterSecret);
+                TransmissionTemplate template = genTransmissionTemplate(content, title);// 设定消息模式为透传
+                SingleMessage msg = new SingleMessage();// 个人推送
+                msg.setOffline(true);
+                msg.setOfflineExpireTime(2 * 1000 * 3600);
+                msg.setData(template);
+                Target target = new Target();// 设定接收人
+                target.setAppId(appId);
+                target.setClientId(cid);
+                try {
+                    IPushResult ret = push.pushMessageToSingle(msg, target);
+                    System.out.println("个推 通知消息1:" + ret.getResponse().toString());
+                } catch (RequestException e) {
+                    String requstId = e.getRequestId();
+                    IPushResult ret = push.pushMessageToSingle(msg, target, requstId);
+                    System.out.println("个推 通知消息2:" + ret.getResponse().toString());
+                }
+                System.out.println("推送成功:" + userDO.getUserName() + "," + title + "," + content);
+            } catch (Exception e) {
+                System.out.println("推送异常:" + e.getMessage());
             }
-            System.out.println("推送成功:" + userDO.getUserName()+","+title+","+content);
-        }
-        catch (Exception e){
-            System.out.println("推送异常:" + e.getMessage());
         }
     }
 

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác