浏览代码

Merge branch 'master_saas' of http://git.dayaedu.com/yonge/mec into master_saas

yonge 3 年之前
父节点
当前提交
893c0de8cd

+ 12 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/IndexBaseDto.java

@@ -6,7 +6,6 @@ import com.ym.mec.common.constant.CommonConstants;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
-import java.time.LocalDate;
 import java.util.Comparator;
 import java.util.Date;
 import java.util.List;
@@ -27,6 +26,16 @@ public class IndexBaseDto {
 
     private List<IndexBaseMonthData> indexMonthDataDetail;
 
+    private List<IndexBaseMonthData> organIndexMonthData;
+
+    public List<IndexBaseMonthData> getOrganIndexMonthData() {
+        return organIndexMonthData;
+    }
+
+    public void setOrganIndexMonthData(List<IndexBaseMonthData> organIndexMonthData) {
+        this.organIndexMonthData = organIndexMonthData;
+    }
+
     public List<IndexBaseMonthData> getIndexMonthDataDetail() {
         return indexMonthDataDetail;
     }
@@ -103,7 +112,8 @@ public class IndexBaseDto {
                     this.percent = total;
                 }
             }else{
-                this.percent = indexMonthData.stream().filter(i->currentMonth.compareTo(i.getMonth())>=0).max(Comparator.comparing(IndexBaseMonthData::getMonth)).get().getPercent();
+                this.percent = indexMonthData.stream().filter(i->currentMonth.compareTo(i.getMonth())>=0).
+                        max(Comparator.comparing(IndexBaseMonthData::getMonth)).get().getPercent();
             }
         }
     }

+ 16 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/IndexBaseMonthData.java

@@ -24,6 +24,8 @@ public class IndexBaseMonthData extends BaseEntity {
 	
 	/** 分部编号 */
 	private Integer organId;
+
+	private String organName;
 	
 	/** 总数量 */
 	private BigDecimal totalNum = BigDecimal.ZERO;
@@ -44,6 +46,14 @@ public class IndexBaseMonthData extends BaseEntity {
 
 	private Date updateTime;
 
+	public String getOrganName() {
+		return organName;
+	}
+
+	public void setOrganName(String organName) {
+		this.organName = organName;
+	}
+
 	public String getOrderType() {
 		return orderType;
 	}
@@ -63,6 +73,12 @@ public class IndexBaseMonthData extends BaseEntity {
 	public IndexBaseMonthData() {
 	}
 
+	public IndexBaseMonthData(Integer organId, String organName, BigDecimal percent) {
+		this.organId = organId;
+		this.organName = organName;
+		this.percent = percent;
+	}
+
 	public IndexBaseMonthData(Date month, Integer organId, Integer tenantId) {
 		this.month = month;
 		this.organId = organId;

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/MessageTypeEnum.java

@@ -228,6 +228,8 @@ public enum MessageTypeEnum implements BaseEnum<String, MessageTypeEnum> {
 
     //直播推送
     JIGUANG_LIVE_RESERVATION("IM_LIVE_RESERVATION","直播开播预约提醒-极光推送"),
+    JIGUANG_LIVE_CREATED("IM_LIVE_CREATED","创建直播间-极光推送"),
+    JIGUANG_LIVE_STARTED("IM_LIVE_STARTED","直播已经开始-极光推送"),
 
     //小小训练营-训练营开始训练推送
     JIGUANG_TEMP_LITTLE_ARTIST_START_TRAIN("JIGUANG_TEMP_LITTLE_ARTIST_START_TRAIN","训练营开始训练推送-极光推送"),

+ 9 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/ImLiveBroadcastRoomService.java

@@ -37,6 +37,14 @@ public interface ImLiveBroadcastRoomService extends IService<ImLiveBroadcastRoom
 
     void whetherChat(Integer id, Integer whetherChat);
 
+    /**
+     * 关闭房间-融云
+     * 获取所有直播间缓存数据并写入数据库后并清理缓存
+     *
+     * @param roomUid 直播间Uid
+     */
+    void roomDestroy(String roomUid);
+
     void roomDestroy(Integer id);
 
     void delete(Integer id);
@@ -70,7 +78,7 @@ public interface ImLiveBroadcastRoomService extends IService<ImLiveBroadcastRoom
 
     void createLiveRoom();
 
-    Map<String, Object> test(String roomUid);
+    Map<String, Object> test(String roomUid,String userFlag);
 
     /**
      * @param roomUid 直播间uid

+ 86 - 16
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveBroadcastRoomServiceImpl.java

@@ -2,7 +2,6 @@ package com.ym.mec.biz.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -32,6 +31,7 @@ import com.ym.mec.common.page.PageUtil;
 import com.ym.mec.common.page.WrapperUtil;
 import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.im.ImFeignService;
+import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.excel.POIUtil;
@@ -291,6 +291,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         obj.setCreatedBy(getSysUser().getId());
         obj.setCreatedTime(now);
         this.save(obj);
+        //推送老师端-直播已经创建
+        sendRoomLiveState(sysUser, obj, MessageTypeEnum.JIGUANG_LIVE_CREATED);
     }
 
     /**
@@ -504,11 +506,28 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
      * 关闭房间-融云
      * 获取所有直播间缓存数据并写入数据库后并清理缓存
      *
+     * @param roomUid 直播间Uid
+     */
+    @Override
+    public void roomDestroy(String roomUid) {
+        ImLiveBroadcastRoom room = this.getOne(Wrappers.<ImLiveBroadcastRoom>lambdaQuery()
+                .eq(ImLiveBroadcastRoom::getRoomUid, roomUid));
+        opsRoomDestroy(room);
+    }
+
+    /**
+     * 关闭房间-融云
+     * 获取所有直播间缓存数据并写入数据库后并清理缓存
+     *
      * @param id 直播房间表id
      */
     @Override
     public void roomDestroy(Integer id) {
         ImLiveBroadcastRoom room = this.getById(id);
+        opsRoomDestroy(room);
+    }
+
+    private void opsRoomDestroy(ImLiveBroadcastRoom room) {
         if (Objects.isNull(room)) {
             return;
         }
@@ -1073,6 +1092,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
             imFeignService.createLiveRoom(room.getRoomUid(), room.getRoomTitle());
             //推送预约直播间消息
             imLiveRoomReservationService.push(room);
+            //推送直播开始消息
+            sendRoomLiveState(sysUser, room, MessageTypeEnum.JIGUANG_LIVE_STARTED);
         } catch (Exception e) {
             log.error(">>>>>>>>>> createLiveRoom error roomUid:{} msg:{}", room.getRoomUid(), e.getMessage());
         }
@@ -1089,9 +1110,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         speakerInfo.setTenantId(sysUser.getTenantId());
         speakerInfo.setTotalLiveTime(0);
 
-        //查询房间信息是否允许录像
-        ImLiveBroadcastRoom one = this.getOne(new QueryWrapper<ImLiveBroadcastRoom>().eq("room_uid_", room.getRoomUid()));
-        boolean video = getRoomConfig(one.getRoomConfig())
+        //获取是否允许录像
+        boolean video = getRoomConfig(room.getRoomConfig())
                 .filter(c -> Objects.nonNull(c.getWhether_video()))
                 .map(c -> c.getWhether_video() == 0)
                 .orElse(false);
@@ -1102,6 +1122,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
             //不可以录制视频
             speakerInfo.setWhetherVideo(1);
         }
+        speakerInfo.setOs(room.getOs());
         //写入主讲人信息
         getRoomSpeakerInfoCache(room.getRoomUid(), room.getSpeakerId().toString()).set(speakerInfo);
 
@@ -1120,6 +1141,50 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
                 .map(c -> JSON.parseObject(c, ImLiveBroadcastRoomDto.RoomConfig.class));
     }
 
+    /**
+     * 推送老师端-直播已经创建/开始的消息
+     *
+     * @param user 用户信息
+     * @param room 房间信息
+     * @param en   直播列表地址
+     *             <P> /#/liveRoomList?t=0 未开始
+     *             <P>/#/liveRoomList 直播中
+     */
+    private void sendRoomLiveState(SysUser user, ImLiveBroadcastRoom room, MessageTypeEnum en) {
+        String teacherBaseUrl = sysConfigDao.findConfigValue(SysConfigService.TEACHER_BASE_URL);
+        if (StringUtils.isBlank(teacherBaseUrl)) {
+            log.error("sendRoomState error: teacherBaseUrl is null");
+            return;
+        }
+        teacherBaseUrl = "7?" + teacherBaseUrl;
+        Map<Integer, String> pushMap = new HashMap<>();
+        pushMap.put(user.getId(), user.getId().toString());
+        String memo;
+        Object[] objs;
+        try {
+            String liveDateStr = DateUtil.format(room.getLiveStartTime(), "yyyy年MM月dd日 HH点mm分");
+            //创建直播间
+            if (en.equals(MessageTypeEnum.JIGUANG_LIVE_CREATED)) {
+                //创建直播间-发送消息-跳到未开始页面
+                memo = teacherBaseUrl + "/#/liveRoomList?t=0";
+                SysUser createUser = getSysUser(room.getCreatedBy());
+                objs = new Object[]{createUser.getUsername(), liveDateStr, room.getLiveRemark()};
+            } else if (en.equals(MessageTypeEnum.JIGUANG_LIVE_STARTED)) {
+                //直播开始-发送消息-跳到直播中页面
+                memo = teacherBaseUrl + "/#/liveRoomList";
+                objs = new Object[]{liveDateStr, room.getRoomTitle()};
+            } else {
+                log.error("sendRoomState error: MessageTypeEnum error " + en);
+                return;
+            }
+            //发送消息
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, en, pushMap,
+                    null, 0, memo, "TEACHER", objs);
+        } catch (Exception e) {
+            log.error("sendRoomState error ", e.getCause());
+        }
+    }
+
     private void getRoomData(ImLiveBroadcastRoomVo roomVo) {
         //点赞数
         Object like = redissonClient.getBucket(LIVE_ROOM_LIKE.replace(ROOM_UID, roomVo.getRoomUid())).get();
@@ -1158,21 +1223,14 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
                 .orElseThrow(() -> new BizException("用户不存在."));
     }
 
-    @Autowired
-    private ImLiveRoomPurviewService imLiveRoomPurviewService;
-
     /**
      * 测试
      */
     public Map<String, Object> test(String roomUid) {
-//        Map<String, Object> map = new HashMap<>();
-//        TenantContextHolder.setTenantId(1);
-//        map.put("roomUid", roomUid);
-//        map.put("groupIds", "22053019304300001,1141,1");
-//        map.put("subjectIds", "2,5,4");
-//        PageInfo<SysUserDto> sysUserDtoPageInfo = imLiveRoomPurviewService.selectRoomPurviewStudent(map);
-//        System.out.println(sysUserDtoPageInfo);
+        return test(roomUid, null);
+    }
 
+    public Map<String, Object> test(String roomUid, String userFlag) {
         //test
         Map<String, Object> result = new HashMap<>();
         //校验房间心跳是否过期没续租
@@ -1211,12 +1269,14 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         if (CollectionUtils.isNotEmpty(totalUserInfo)) {
             if (CollectionUtils.isNotEmpty(inRoomUserInfo)) {
                 look = inRoomUserInfo.size();
-//                result.put("正在观看的人员信息", inRoomUserInfo);
+                Optional.ofNullable(userFlag)
+                        .ifPresent(a -> result.put("正在观看的人员信息", inRoomUserInfo));
             } else {
                 result.put("正在观看的人员信息", "没有正在观看的人员数据");
             }
             totalLook = totalUserInfo.size();
-//            result.put("总人员数据", totalUserInfo);
+            Optional.ofNullable(userFlag)
+                    .ifPresent(a -> result.put("总人员数据", totalUserInfo));
         } else {
             result.put("总人员数据", "没有人员数据");
         }
@@ -1537,6 +1597,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         private Integer whetherVideo;
         //机构
         private Integer tenantId;
+        //播出端-  pc网页端 移动端mobile
+        private String os = "pc";
 
         public Integer getSpeakerId() {
             return speakerId;
@@ -1639,6 +1701,14 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         public void setEndLiveTime(Date endLiveTime) {
             this.endLiveTime = endLiveTime;
         }
+
+        public String getOs() {
+            return os;
+        }
+
+        public void setOs(String os) {
+            this.os = os;
+        }
     }
 
 }

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -29,6 +29,7 @@ import java.time.DayOfWeek;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 import static com.ym.mec.biz.dal.enums.IndexDataType.*;
@@ -299,6 +300,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 					VIP_AMOUNT.equals(typeDateMapEntry.getKey()) ||
 					PRACTICE_AMOUNT.equals(typeDateMapEntry.getKey()) ||
 					OTHER_AMOUNT.equals(typeDateMapEntry.getKey())){
+				indexBaseData.setOrganIndexMonthData(this.getOrganIndexMonthData(value));
 				indexBaseData.setPercent(value.stream().map(IndexBaseMonthData::getPercent).reduce(BigDecimal.ZERO, BigDecimal::add));
 			}
 			if(IndexDataType.VIP_GROUP_COURSE.equals(typeDateMapEntry.getKey()) || VIP_GROUP_ONLINE_COURSE.equals(typeDateMapEntry.getKey()) ||
@@ -324,6 +326,22 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 		return result;
 	}
 
+	public List<IndexBaseMonthData> getOrganIndexMonthData(List<IndexBaseMonthData> organIndexMonthData) {
+		if (!CollectionUtils.isEmpty(organIndexMonthData)){
+			List<IndexBaseMonthData> collect = organIndexMonthData.stream().filter(e -> e.getOrganId() != null && e.getOrganId() != 0).collect(Collectors.toList());
+			if(!CollectionUtils.isEmpty(collect)){
+				Map<Integer, List<IndexBaseMonthData>> listMap = collect.stream().collect(Collectors.groupingBy(IndexBaseMonthData::getOrganId));
+				Set<Integer> organIds = listMap.keySet();
+				Map<Integer, String> organMap = organizationService.getMap("organization", "id_", "name_",
+						organIds, TenantContextHolder.getTenantId(), Integer.class, String.class);
+				Function<Integer,IndexBaseMonthData> fun = (organId) -> new IndexBaseMonthData(organId,organMap.get(organId),
+						listMap.get(organId).stream().map(e->e.getPercent()).reduce(BigDecimal.ZERO,BigDecimal::add));
+				return organIds.stream().map(fun::apply).collect(Collectors.toList());
+			}
+		}
+		return new ArrayList<>();
+	}
+
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void indexBaseDataTask(Integer tenantId, String dayStr, Set<IndexDataType> dataTypes) {

+ 0 - 1
mec-im/src/main/java/com/ym/service/Impl/LiveRoomServiceImpl.java

@@ -265,7 +265,6 @@ public class LiveRoomServiceImpl implements LiveRoomService {
             log.error("获取sessionId失败 roomId : {} returnResult:{}", roomId, resultObject);
             throw new BizException("获取sessionId失败");
         }
-
         return sessionId;
     }
 

+ 3 - 8
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherImLiveBroadcastRoomController.java

@@ -73,9 +73,9 @@ public class TeacherImLiveBroadcastRoomController extends BaseController {
     }
 
     @ApiOperation("关闭直播间")
-    @GetMapping(value = "/roomDestroy/{id}")
-    public HttpResponseResult<Object> roomDestroy(@ApiParam(value = "房间表id", required = true) @PathVariable("id") Integer id) {
-        imLiveBroadcastRoomService.roomDestroy(id);
+    @GetMapping(value = "/roomDestroy")
+    public HttpResponseResult<Object> roomDestroy(@ApiParam(value = "房间Uid", required = true) String roomUid) {
+        imLiveBroadcastRoomService.roomDestroy(roomUid);
         return succeed();
     }
 
@@ -108,11 +108,6 @@ public class TeacherImLiveBroadcastRoomController extends BaseController {
         return succeed(imLiveBroadcastRoomService.speakerJoinRoom(roomUid,"mobile"));
     }
 
-    @GetMapping("/test")
-    public Object test(String roomUid) {
-        return imLiveBroadcastRoomService.test(roomUid);
-    }
-
     @GetMapping("/shareGroup")
     public HttpResponseResult<Object> shareGroup(@ApiParam(value = "房间uid", required = true) String roomUid,
                                                  @ApiParam(value = "群编号", required = true) String groupIds) {

+ 187 - 228
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/JiguangPushPlugin.java

@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.thirdparty.exception.ThirdpartyException;
 import com.ym.mec.thirdparty.message.MessageSenderPlugin;
 import com.ym.mec.util.http.HttpUtil;
-
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.InitializingBean;
@@ -15,7 +14,7 @@ import org.springframework.stereotype.Service;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.Map;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 /**
@@ -24,164 +23,168 @@ import java.util.stream.Collectors;
 @Service
 public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean {
 
-	@Value("${push.jiguang.appKey.student}")
-	private String studentAppKey;
-	@Value("${push.jiguang.masterSecret.student}")
-	private String studentMasterSecret;
-
-	@Value("${push.jiguang.appKey.teacher}")
-	private String teacherAppKey;
-	@Value("${push.jiguang.masterSecret.teacher}")
-	private String teacherMasterSecret;
-
-	@Value("${push.jiguang.appKey.system}")
-	private String systemAppKey;
-	@Value("${push.jiguang.masterSecret.system}")
-	private String systemMasterSecret;
-
-	@Value("${push.jiguang.apns_production:false}")
-	private boolean apns_production = true; // 推送环境 True 表示推送生产环境,False 表示要推送开发环境
-
-	@Value("${push.jiguang.time_to_live:86400}")
-	private int time_to_live = 86400; // 离线保留时长 秒为单位 默认1天 最大10天
-
-	@Value("${push.jiguang.reqURL:https://api.jpush.cn/v3/push}")
-	private String reqURL = "https://api.jpush.cn/v3/push";// 请求极光地址
-
-	public static String getName() {
-		return "jiguang";
-	}
-
-	/**
-	 * 组装推送Json串
-	 *
-	 * @param alias 别名推送
-	 * @param alert 消息
-	 * @param content 消息内容
-	 * @return json对象
-	 */
-	private JSONObject generateJson(String[] alias, String alert, String content, String url,String sound,String channelId) {
-		JSONObject json = new JSONObject();
-		JSONArray platform = new JSONArray();// 平台
-		platform.add("android");
-		platform.add("ios");
-
-		JSONObject audience = new JSONObject();// 推送目标
-		JSONArray aliasJsonArr = new JSONArray();
-		for (String alia : alias) {
-			aliasJsonArr.add(alia);
-		}
-		audience.put("alias", aliasJsonArr);
-
-		JSONObject notification = new JSONObject();// 通知内容
-		JSONObject android = new JSONObject();// android通知内容
-		android.put("alert", alert);
-		android.put("sound", sound.split("\\.")[0]);
-		JSONObject options = new JSONObject();// 设置参数
-		if(StringUtils.isNotEmpty(channelId)){
-			JSONObject thirdParty = new JSONObject();
-			JSONObject xiaomi = new JSONObject();
-			xiaomi.put("distribution","secondary_push");
-			xiaomi.put("channel_id",channelId);
-			thirdParty.put("xiaomi",xiaomi);
-			options.put("third_party_channel",thirdParty);
-		}
-		android.put("builder_id", 1);
-		JSONObject android_extras = new JSONObject();// android额外参数
-		android_extras.put("type", "infomation");
-		android_extras.put("url", url);
-		android_extras.put("memo", url);
-		android.put("extras", android_extras);
-        //2022年5月27日 增加以下参数,是因为安卓无法跳转到APP中
-        JSONObject intentParam = new JSONObject();
-//        intentParam.put("url", "intent:#Intent;action=android.intent.action.MAIN;end");
-        //2022年6月3日 修改参数,安卓通知需要后台修改
-        intentParam.put("url", "intent:#Intent;action=cn.jiguang.push.customAction;component=com.daya.studaya_android/com.daya.studaya_android.ui.MainActivity;end");
-        android.put("intent", intentParam);
-
-		JSONObject ios = new JSONObject();// ios通知内容
-		ios.put("alert", alert);
-		ios.put("sound", sound);
-		ios.put("badge", "+1");
-		JSONObject ios_extras = new JSONObject();// ios额外参数
-		ios_extras.put("type", "infomation");
-		ios_extras.put("url", url);
-		ios_extras.put("memo", url);
-		ios.put("extras", ios_extras);
-		notification.put("android", android);
-		notification.put("ios", ios);
-
-		JSONObject message = new JSONObject();// 通知消息内容
-		message.put("title", alert);
-		message.put("msg_content", content);
-		message.put("content_type","text");
-
-		options.put("time_to_live", this.time_to_live);
-		options.put("apns_production", this.apns_production);
-
-		json.put("platform", platform);
-		json.put("audience", audience);
-		json.put("notification", notification);
-		json.put("options", options);
-		json.put("message", message);
-		return json;
-
-	}
-
-	/**
-	 * 调用极光api
-	 * @param alias 推送对象别名
-	 * @param alert 推送消息
-	 * @param content 推送内容
-	 */
-	private String push(String[] alias, String alert, String content, String url,String type,String sound,String channelId) {
-		String base64_auth_string = "";
-		switch (type){
-			case "STUDENT":
-				base64_auth_string = encryptBASE64(this.studentAppKey + ":" + this.studentMasterSecret);
-				break;
-			case "TEACHER":
-				base64_auth_string = encryptBASE64(this.teacherAppKey + ":" + this.teacherMasterSecret);
-				break;
-			default:
-				base64_auth_string = encryptBASE64(this.systemAppKey + ":" + this.systemMasterSecret);
-				break;
-		}
-		String authorization = "Basic " + base64_auth_string;
-		return sendPostRequest(generateJson(alias, alert, content, url,sound,channelId).toString(), authorization);
-	}
-
-	/**
-	 * 发送Post请求(json格式)
-	 *
-	 * @param data //封装的json串
-	 * @param authorization 验签
-	 * @return result 返回一个json字符串
-	 */
-	private String sendPostRequest(String data, String authorization) {
-		String result = "";
-		HashMap<String, String> reqHeader = new HashMap<>();
-		reqHeader.put("Authorization", authorization.trim());
-		try {
-			result = HttpUtil.postForHttps(this.reqURL, data, reqHeader);
-		} catch (Exception e) {
-			throw new ThirdpartyException("HttpUtil Connection Exception", e);
-		}
-		return result;
-	}
-
-	/**
-	 *     * BASE64加密工具
-	 */
-	private String encryptBASE64(String str) {
-		byte[] key = str.getBytes();
-		String strs = Base64.encodeBase64String(key);
-		return strs;
-	}
-
-	@Override
-	public void afterPropertiesSet() throws Exception {
-		// 参数检查
+    @Value("${push.jiguang.appKey.student}")
+    private String studentAppKey;
+    @Value("${push.jiguang.masterSecret.student}")
+    private String studentMasterSecret;
+
+    @Value("${push.jiguang.appKey.teacher}")
+    private String teacherAppKey;
+    @Value("${push.jiguang.masterSecret.teacher}")
+    private String teacherMasterSecret;
+
+    @Value("${push.jiguang.appKey.system}")
+    private String systemAppKey;
+    @Value("${push.jiguang.masterSecret.system}")
+    private String systemMasterSecret;
+
+    @Value("${push.jiguang.apns_production:false}")
+    private boolean apns_production = true; // 推送环境 True 表示推送生产环境,False 表示要推送开发环境
+
+    @Value("${push.jiguang.time_to_live:86400}")
+    private int time_to_live = 86400; // 离线保留时长 秒为单位 默认1天 最大10天
+
+    @Value("${push.jiguang.reqURL:https://api.jpush.cn/v3/push}")
+    private String reqURL = "https://api.jpush.cn/v3/push";// 请求极光地址
+
+    public static String getName() {
+        return "jiguang";
+    }
+
+    /**
+     * 组装推送Json串
+     *
+     * @param alias   别名推送
+     * @param alert   消息
+     * @param content 消息内容
+     * @return json对象
+     */
+    private JSONObject generateJson(String[] alias, String alert, String content, String url, String sound, String channelId, JSONObject androidIntent) {
+        JSONObject json = new JSONObject();
+        JSONArray platform = new JSONArray();// 平台
+        platform.add("android");
+        platform.add("ios");
+
+        JSONObject audience = new JSONObject();// 推送目标
+        JSONArray aliasJsonArr = new JSONArray();
+        for (String alia : alias) {
+            aliasJsonArr.add(alia);
+        }
+        audience.put("alias", aliasJsonArr);
+
+        JSONObject notification = new JSONObject();// 通知内容
+        JSONObject android = new JSONObject();// android通知内容
+        android.put("alert", alert);
+        android.put("sound", sound.split("\\.")[0]);
+        JSONObject options = new JSONObject();// 设置参数
+        if (StringUtils.isNotEmpty(channelId)) {
+            JSONObject thirdParty = new JSONObject();
+            JSONObject xiaomi = new JSONObject();
+            xiaomi.put("distribution", "secondary_push");
+            xiaomi.put("channel_id", channelId);
+            thirdParty.put("xiaomi", xiaomi);
+            options.put("third_party_channel", thirdParty);
+        }
+        android.put("builder_id", 1);
+        JSONObject android_extras = new JSONObject();// android额外参数
+        android_extras.put("type", "infomation");
+        android_extras.put("url", url);
+        android_extras.put("memo", url);
+        android.put("extras", android_extras);
+        Optional.ofNullable(androidIntent)
+                .ifPresent(intent -> android.put("intent", intent));
+
+        JSONObject ios = new JSONObject();// ios通知内容
+        ios.put("alert", alert);
+        ios.put("sound", sound);
+        ios.put("badge", "+1");
+        JSONObject ios_extras = new JSONObject();// ios额外参数
+        ios_extras.put("type", "infomation");
+        ios_extras.put("url", url);
+        ios_extras.put("memo", url);
+        ios.put("extras", ios_extras);
+        notification.put("android", android);
+        notification.put("ios", ios);
+
+        JSONObject message = new JSONObject();// 通知消息内容
+        message.put("title", alert);
+        message.put("msg_content", content);
+        message.put("content_type", "text");
+
+        options.put("time_to_live", this.time_to_live);
+        options.put("apns_production", this.apns_production);
+
+        json.put("platform", platform);
+        json.put("audience", audience);
+        json.put("notification", notification);
+        json.put("options", options);
+        json.put("message", message);
+        return json;
+
+    }
+
+    /**
+     * 调用极光api
+     *
+     * @param alias   推送对象别名
+     * @param alert   推送消息
+     * @param content 推送内容
+     */
+    private String push(String[] alias, String alert, String content, String url, String type, String sound, String channelId) {
+        String base64_auth_string = "";
+        JSONObject androidIntent = null;
+        switch (type) {
+            case "STUDENT":
+                base64_auth_string = encryptBASE64(this.studentAppKey + ":" + this.studentMasterSecret);
+                androidIntent = new JSONObject();
+                //2022年5月27日 增加以下参数,是因为安卓无法跳转到APP中
+                //intentParam.put("url", "intent:#Intent;action=android.intent.action.MAIN;end");
+                //2022年6月3日 修改参数,安卓通知需要后台修改
+                androidIntent.put("url", "intent:#Intent;action=cn.jiguang.push.customAction;component=com.daya.studaya_android/com.daya.studaya_android.ui.MainActivity;end");
+                break;
+            case "TEACHER":
+                base64_auth_string = encryptBASE64(this.teacherAppKey + ":" + this.teacherMasterSecret);
+                break;
+            default:
+                base64_auth_string = encryptBASE64(this.systemAppKey + ":" + this.systemMasterSecret);
+                break;
+        }
+        String authorization = "Basic " + base64_auth_string;
+        JSONObject jsonObject = generateJson(alias, alert, content, url, sound, channelId, androidIntent);
+        return sendPostRequest(jsonObject.toString(), authorization);
+    }
+
+    /**
+     * 发送Post请求(json格式)
+     *
+     * @param data          //封装的json串
+     * @param authorization 验签
+     * @return result 返回一个json字符串
+     */
+    private String sendPostRequest(String data, String authorization) {
+        String result = "";
+        HashMap<String, String> reqHeader = new HashMap<>();
+        reqHeader.put("Authorization", authorization.trim());
+        try {
+            result = HttpUtil.postForHttps(this.reqURL, data, reqHeader);
+        } catch (Exception e) {
+            throw new ThirdpartyException("HttpUtil Connection Exception", e);
+        }
+        return result;
+    }
+
+    /**
+     *     * BASE64加密工具
+     */
+    private String encryptBASE64(String str) {
+        byte[] key = str.getBytes();
+        String strs = Base64.encodeBase64String(key);
+        return strs;
+    }
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        // 参数检查
 		/*if (StringUtils.isBlank(appKey)) {
 			throw new RuntimeException("Init parameter [appKey] can not blank");
 		}
@@ -191,73 +194,29 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
 		if (StringUtils.isBlank(reqURL)) {
 			throw new RuntimeException("Init parameter [reqURL] can not blank");
 		}*/
-	}
-
-	@Override
-	public boolean send(String subject, String content, String receiver, String url, String type,String sound,String channelId) throws IOException {
-		String[] alias = { receiver };
-		String result = this.push(alias, subject, content, url,type,sound,channelId);
-		JSONObject json = JSONObject.parseObject(result);
-		if (json.containsKey("error")) {
-			JSONObject jsonObject = json.getJSONObject("error");
-			throw new ThirdpartyException(jsonObject.get("message").toString());
-		}
-		return true;
-	}
-
-	@Override
-	public boolean batchSend(String subject, String content, String[] receivers, String url, String type,String sound,String channelId) throws IOException {
-		String result = this.push(receivers, subject, content, url,type,sound,channelId);
-		JSONObject json = JSONObject.parseObject(result);
-		if (json.containsKey("error")) {
-			JSONObject jsonObject = json.getJSONObject("error");
-			throw new ThirdpartyException(jsonObject.get("message").toString()+"["+Arrays.stream(receivers).collect(Collectors.joining(","))+"]");
-		}
-		return true;
-	}
-
-	public void setStudentAppKey(String studentAppKey) {
-		this.studentAppKey = studentAppKey;
-	}
-
-	public void setStudentMasterSecret(String studentMasterSecret) {
-		this.studentMasterSecret = studentMasterSecret;
-	}
-
-	public void setTeacherAppKey(String teacherAppKey) {
-		this.teacherAppKey = teacherAppKey;
-	}
-
-	public void setTeacherMasterSecret(String teacherMasterSecret) {
-		this.teacherMasterSecret = teacherMasterSecret;
-	}
-
-	public String getSystemAppKey() {
-		return systemAppKey;
-	}
-
-	public void setSystemAppKey(String systemAppKey) {
-		this.systemAppKey = systemAppKey;
-	}
-
-	public String getSystemMasterSecret() {
-		return systemMasterSecret;
-	}
-
-	public void setSystemMasterSecret(String systemMasterSecret) {
-		this.systemMasterSecret = systemMasterSecret;
-	}
-
-	public void setApns_production(boolean apns_production) {
-		this.apns_production = apns_production;
-	}
-
-	public void setTime_to_live(int time_to_live) {
-		this.time_to_live = time_to_live;
-	}
-
-	public void setReqURL(String reqURL) {
-		this.reqURL = reqURL;
-	}
+    }
+
+    @Override
+    public boolean send(String subject, String content, String receiver, String url, String type, String sound, String channelId) throws IOException {
+        String[] alias = {receiver};
+        String result = this.push(alias, subject, content, url, type, sound, channelId);
+        JSONObject json = JSONObject.parseObject(result);
+        if (json.containsKey("error")) {
+            JSONObject jsonObject = json.getJSONObject("error");
+            throw new ThirdpartyException(jsonObject.get("message").toString());
+        }
+        return true;
+    }
+
+    @Override
+    public boolean batchSend(String subject, String content, String[] receivers, String url, String type, String sound, String channelId) throws IOException {
+        String result = this.push(receivers, subject, content, url, type, sound, channelId);
+        JSONObject json = JSONObject.parseObject(result);
+        if (json.containsKey("error")) {
+            JSONObject jsonObject = json.getJSONObject("error");
+            throw new ThirdpartyException(jsonObject.get("message").toString() + "[" + Arrays.stream(receivers).collect(Collectors.joining(",")) + "]");
+        }
+        return true;
+    }
 
 }

+ 2 - 2
mec-web/src/main/java/com/ym/mec/web/controller/ImLiveBroadcastRoomController.java

@@ -200,8 +200,8 @@ public class ImLiveBroadcastRoomController extends BaseController {
     }
 
     @GetMapping("/test")
-    public Object test(String roomUid) {
-        return imLiveBroadcastRoomService.test(roomUid);
+    public Object test(String roomUid, String userFlag) {
+        return imLiveBroadcastRoomService.test(roomUid, userFlag);
     }
 
     @GetMapping("/destroyExpiredLiveRoom")