Commit ba5ea8c8 authored by fuqi666's avatar fuqi666

新增功能:四个app可推送

parent dab9fb70
......@@ -52,7 +52,7 @@ public class MobPushService {
public CommonResult mobPushForAndroid(InformForm informForm, Constant.PushTarget target) {
log.info("开始安卓新闻消息群推......");
informForm.setAppKey(AppKeyEnum.ANDROID.getKey());
informForm.setAppKey(AppKeyEnum.KKSH_ANDROID.getKey());
CommonResult result = mobPushByAppKey(informForm, target);
log.info("安卓新闻消息群推结束,result = {}", JSONUtil.toJsonStr(result));
return result;
......@@ -60,7 +60,7 @@ public class MobPushService {
public CommonResult mobPushForIOS(InformForm informForm, Constant.PushTarget target) {
log.info("开始IOS新闻消息群推......");
informForm.setAppKey(AppKeyEnum.IOS.getKey());
informForm.setAppKey(AppKeyEnum.KKSH_IOS.getKey());
CommonResult result = mobPushByAppKey(informForm, target);
log.info("IOS新闻消息群推结束,result = {}", JSONUtil.toJsonStr(result));
return result;
......@@ -68,12 +68,20 @@ public class MobPushService {
public CommonResult mobPushForHarmony(InformForm informForm, Constant.PushTarget target) {
log.info("开始鸿蒙新闻消息群推......");
informForm.setAppKey(AppKeyEnum.HARMONY.getKey());
informForm.setAppKey(AppKeyEnum.KKSH_HARMONY.getKey());
CommonResult result = mobPushByAppKey(informForm, target);
log.info("鸿蒙新闻消息群推结束,result = {}", JSONUtil.toJsonStr(result));
return result;
}
public CommonResult mobPushForAppkey(InformForm informForm, Constant.PushTarget target , AppKeyEnum appKey) {
log.info("开始"+ appKey +"新闻消息群推......");
informForm.setAppKey(appKey.getKey());
CommonResult result = mobPushByAppKey(informForm, target);
log.info(appKey + "新闻消息群推结束,result = {}", JSONUtil.toJsonStr(result));
return result;
}
/**
* mob 推送
*
......@@ -139,7 +147,7 @@ public class MobPushService {
* @param target 推送目标类型
* @return 执行结果
*/
public CommonResult mobPush(InformForm informForm, Constant.PushTarget target) {
public CommonResult mobPush(InformForm informForm, Constant.PushTarget target,AppKeyEnum appKey) {
String pushUrl = "http://api.push.mob.com/v3/push/createPush";
Map<String, Object> request = new HashMap<>();
//枚举值 webapi
......@@ -147,7 +155,7 @@ public class MobPushService {
//自定义任务id(用户自自定义生成且唯一、不能重复)
request.put("workno", IdUtil.fastUUID());
//appkey
request.put("appkey", AppKeyEnum.ANDROID.getKey());
request.put("appkey", appKey.getKey());
informForm.setUrl(HtmlUtil.unescape(informForm.getUrl()));
Map<String, Object> pushTarget = new HashMap<>();
if (Constant.PushTarget.CITY.getKey() != target.getKey()) {
......@@ -267,7 +275,7 @@ public class MobPushService {
//枚举值 webapi
pushWork.put("source", "webapi");
//Mob-appkey
pushWork.put("appkey", AppKeyEnum.ANDROID.getKey());
pushWork.put("appkey", AppKeyEnum.KKSH_IOS.getKey());
//推送展示细节配置
InformForm informForm = new InformForm();
BeanUtils.copyProperties(form, informForm);
......@@ -400,7 +408,7 @@ public class MobPushService {
String reqUrl = "http://api.push.mob.com/v3/stats/getByWorkId";
Map<String, Object> request = new HashMap<>();
//appkey
request.put("appkey", AppKeyEnum.ANDROID.getKey());
request.put("appkey", AppKeyEnum.KKSH_ANDROID.getKey());
request.put("workId", workId);
String body = generalPost(request, reqUrl);
log.error("查询回调结果:{}", body);
......@@ -742,8 +750,8 @@ public class MobPushService {
*/
private String generalGet(String url) {
HttpRequest get = HttpUtil.createGet(url);
get.header("key", AppKeyEnum.ANDROID.getKey());
get.header("sign", getSign("", AppKeyEnum.ANDROID.getKey()));
get.header("key", AppKeyEnum.KKSH_ANDROID.getKey());
get.header("sign", getSign("", AppKeyEnum.KKSH_ANDROID.getKey()));
String body = get.execute().body();
log.info("推送结果:{}", body);
if (JSONUtil.isJson(body)) {
......
......@@ -11,6 +11,7 @@ import com.weface.dto.InformForm;
import com.weface.dto.MsgDTO;
import com.weface.dto.MultiInformForm;
import com.weface.dto.PushDTO;
import com.weface.enums.AppKeyEnum;
import com.weface.service.PushService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -21,6 +22,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author Administrator
*/
......@@ -50,7 +53,7 @@ public class PushController {
* 群推
*/
@PostMapping("/all")
public CommonResult pushAll(InformForm informForm) {
public CommonResult pushAll(@RequestBody InformForm informForm) {
log.error("群推内容:{}", JSONObject.toJSONString(informForm));
ValidatorUtils.validateEntity(informForm, InformForm.PushValid.class);
CommonResult result = ValidatorParam.validPushParams(informForm);
......@@ -64,7 +67,21 @@ public class PushController {
mobPushService.mobPushForIOS(informForm, Constant.PushTarget.RADIO);
//鸿蒙群推
mobPushService.mobPushForHarmony(informForm, Constant.PushTarget.RADIO);
}else if (informForm.getEquipmentType().equals("kksb")) {
//安卓群推
mobPushService.mobPushForAppkey(informForm, Constant.PushTarget.RADIO,AppKeyEnum.KKSB_ANDROID);
//鸿蒙群推
mobPushService.mobPushForAppkey(informForm, Constant.PushTarget.RADIO,AppKeyEnum.KKSB_HARMONY);
}else if (informForm.getEquipmentType().equals("kkmz")) {
//安卓群推
mobPushService.mobPushForAppkey(informForm, Constant.PushTarget.RADIO,AppKeyEnum.KKMZ_ANDROID);
//鸿蒙群推
mobPushService.mobPushForAppkey(informForm, Constant.PushTarget.RADIO,AppKeyEnum.KKMZ_HARMONY);
}else if (informForm.getEquipmentType().equals("kkwj")) {
//安卓群推
mobPushService.mobPushForAppkey(informForm, Constant.PushTarget.RADIO,AppKeyEnum.KKWJ_ANDROID);
}
return geTuiService.listPush(informForm);
}
......@@ -82,7 +99,9 @@ public class PushController {
if (result != null) {
return result;
}
result = mobPushService.mobPush(informForm, Constant.PushTarget.ALIAS);
result = this.mobPush(informForm, Constant.PushTarget.ALIAS);
if (result != null) {
return CommonResult.success();
}
......@@ -103,7 +122,7 @@ public class PushController {
if (result != null) {
return result;
}
result = mobPushService.mobPush(informForm, Constant.PushTarget.RIDS);
result = this.mobPush(informForm, Constant.PushTarget.RIDS);
if (result != null) {
return CommonResult.success();
}
......@@ -152,7 +171,18 @@ public class PushController {
if (result != null) {
return result;
}
return mobPushService.mobPush(informForm, Constant.PushTarget.CITY);
return this.mobPush(informForm, Constant.PushTarget.CITY);
}
public CommonResult mobPush(InformForm informForm, Constant.PushTarget target) {
List<AppKeyEnum> appKeyEnumList = AppKeyEnum.getAppKeyEnumByIdentifier(informForm.getEquipmentType());
CommonResult result = null;
Boolean flag = false;
for (AppKeyEnum appKeyEnum : appKeyEnumList) {
result = mobPushService.mobPush(informForm, target, appKeyEnum );
if (result!=null && result.getCode().equals(200)) flag =true;
}
return flag?CommonResult.success():null;
}
}
package com.weface.enums;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* 新闻消息推送APP_KEY ENUMS
......@@ -9,27 +11,30 @@ import java.math.BigDecimal;
* @date 2024/12/17
*/
public enum AppKeyEnum {
//看看生活
KKSH_ANDROID("kksh","3511c2579cad6", "f446a56b98aae09beb5721ebdbe0d2e8"),
KKSH_IOS("kksh","38b797dbbf6ec", "05883c7b9185edb99a6ded653cfe3e39"),
KKSH_HARMONY("kksh","3a69c3c5f3cc7", "78f9a9f474086eee124b2be762e356ca"),
//看看社保
KKSB_ANDROID("kksb","35e36a9bc94bd", "0a097f62ac25e0cb7a750ab293b583d1"),
KKSB_HARMONY("kksb","3af9d85326f25", "a1af59109357431608c995d16f9af2d7"),
//看看民政
KKMZ_ANDROID("kkmz","35e377d8521b0", "a6350ece59dd756aaabf40f6d8c27a9c"),
KKMZ_HARMONY("kkmz","3af9d11208742", "cdaee8d80a95b481408bda982af875f9"),
//看看卫健
KKWJ_ANDROID("kkwj","35e37131417e3", "27955f2bc52c8fc0d053375d422ced0e"),
/**
* 安卓
*/
ANDROID("3511c2579cad6", "f446a56b98aae09beb5721ebdbe0d2e8"),
/**
* IOS
*/
IOS("38b797dbbf6ec", "05883c7b9185edb99a6ded653cfe3e39"),
/**
* 鸿蒙
*/
HARMONY("3a69c3c5f3cc7", "78f9a9f474086eee124b2be762e356ca"),
;
private String identifier;
private String key;
private String secret;
AppKeyEnum(String key, String secret) {
AppKeyEnum(String identifier,String key, String secret) {
this.identifier = identifier;
this.key = key;
this.secret = secret;
}
......@@ -38,6 +43,10 @@ public enum AppKeyEnum {
return key;
}
public String getIdentifier() {
return identifier;
}
public String getSecret() {
return secret;
......@@ -58,5 +67,16 @@ public enum AppKeyEnum {
}
return null;
}
public static List<AppKeyEnum> getAppKeyEnumByIdentifier(String identifier) {
AppKeyEnum[] enums = AppKeyEnum.values();
List<AppKeyEnum> appKeyEnums = new ArrayList<>();
for (int i = 0; i < enums.length; i++) {
if (enums[i].getIdentifier().equals(identifier)) {
appKeyEnums.add(enums[i]);
}
}
return appKeyEnums;
}
}
......@@ -113,7 +113,7 @@ public class UserTagsTask {
String cid = sb.substring(0, sb.length() - 1);
form.setCid(cid);
//mob批量推送
mobPushService.mobPush(form, Constant.PushTarget.ALIAS);
// mobPushService.mobPush(form, Constant.PushTarget.ALIAS);
//个推批量推送
geTuiService.pushListMessage(form, true);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment