Commit 4bb20e93 authored by renandong's avatar renandong 🇨🇳

1.加入mob推送

parent 94f7388b
......@@ -73,4 +73,44 @@ public class Constant {
return value;
}
}
/**
* mob推送目标
*/
public enum PushTarget {
RADIO(1, "广播群推"),
ALIAS(2, "别名推送"),
TAGS(3, "标签推送"),
RIDS(4, "rid推送"),
CITY(5, "地理位置推送"),
BLOCK(6, "用户分群推送"),
AREA(9, "复杂地理位置推送"),
FILE(14, "fileId推送"),
BATCH_ALIAS(22, "别名批量推送"),
BATCH_RIDS(33, "rid批量推送");
private int key;
private String value;
PushTarget(int key, String value) {
this.key = key;
this.value = value;
}
public int getKey() {
return key;
}
public void setKey(int key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
}
This diff is collapsed.
package com.weface.controller;
import com.weface.code.CommonResult;
import com.weface.common.utils.Constant;
import com.weface.common.validator.ValidatorParam;
import com.weface.common.validator.ValidatorUtils;
import com.weface.component.GeTuiService;
import com.weface.component.MobPushService;
import com.weface.dto.InformForm;
import com.weface.dto.MsgDTO;
import com.weface.dto.PushDTO;
......@@ -25,7 +27,8 @@ public class PushController {
private PushService pushService;
@Autowired
private GeTuiService geTuiService;
@Autowired
private MobPushService mobPushService;
@PostMapping("list")
public CommonResult pushList(@RequestBody PushDTO param) throws Exception {
......@@ -40,6 +43,7 @@ public class PushController {
@PostMapping("/all")
public CommonResult pushAll(InformForm informForm) {
ValidatorUtils.validateEntity(informForm, InformForm.PushValid.class);
mobPushService.mobPush(informForm, Constant.PushTarget.RADIO);
return geTuiService.listPush(informForm);
}
......@@ -50,6 +54,10 @@ public class PushController {
if (commonResult != null) {
return commonResult;
}
CommonResult result = mobPushService.mobPush(informForm, Constant.PushTarget.ALIAS);
if (result != null) {
return CommonResult.success();
}
return geTuiService.pushSingleAlias(informForm);
}
......@@ -60,6 +68,10 @@ public class PushController {
if (commonResult != null) {
return commonResult;
}
CommonResult result = mobPushService.mobPush(informForm, Constant.PushTarget.RIDS);
if (result != null) {
return CommonResult.success();
}
return geTuiService.pushSingleCid(informForm);
}
}
......@@ -24,6 +24,10 @@ public class PushLogEntity implements Serializable {
* 应用名称
*/
private String appName;
/**
* 推送类型 1:个推 2:袤博
*/
private Integer pushType;
/**
* 任务id
*/
......
......@@ -14,7 +14,7 @@ import java.util.List;
public interface PushLogService extends IService<PushLogEntity> {
/**
* 保存日志
* 保存日志 个推
*
* @param data 返回数据
* @param informForm 推送数据
......@@ -22,6 +22,14 @@ public interface PushLogService extends IService<PushLogEntity> {
*/
public void saveLog(JSONObject data, InformForm informForm, String appId);
/**
* 保存推送日志 袤博
*
* @param data 返回数据
* @param informForm 推送数据
*/
public void saveMobLog(JSONObject data, InformForm informForm);
/**
* 查询日志
*
......
......@@ -33,31 +33,9 @@ public class PushLogServiceImpl extends ServiceImpl<PushLogDao, PushLogEntity> i
try {
List<PushLogEntity> logList = new ArrayList<>();
for (String key : data.keySet()) {
PushLogEntity pushLogEntity = new PushLogEntity();
Long id = SnowIdUtil.nextId();
pushLogEntity.setId(id);
pushLogEntity.setAppName(informForm.getEquipmentType());
pushLogEntity.setTaskId(key);
String str = data.toString();
if (str.length() > 200) {
pushLogEntity.setResult(str.substring(0, 200));
} else {
pushLogEntity.setResult(str);
}
String phone = informForm.getPhone();
if (StringUtils.isNotEmpty(phone)) {
DES des = DES.getInstanceDes();
pushLogEntity.setPhone(des.encrypt(phone));
}
Integer messageTemplate = informForm.getMessageTemplate();
if (messageTemplate != null) {
pushLogEntity.setMessageTemplate(messageTemplate);
}
pushLogEntity.setPushTarget(informForm.getCid() == null ? "all" : informForm.getCid());
pushLogEntity.setPushContent(informForm.getBody());
pushLogEntity.setArriveStatus(1001);
pushLogEntity.setUpdateTime(new Date());
logList.add(pushLogEntity);
PushLogEntity pushLog = getPushLog(id, informForm, key, data.toString(), 1);
logList.add(pushLog);
RedisUtil.HashOps.hPutEx(Constant.PUSH_TASK_INFO, key, String.valueOf(id), 2L, TimeUnit.HOURS);
}
if (!CollectionUtils.isEmpty(logList)) {
......@@ -69,6 +47,56 @@ public class PushLogServiceImpl extends ServiceImpl<PushLogDao, PushLogEntity> i
}
}
@Override
public void saveMobLog(JSONObject data, InformForm informForm) {
try {
Long id = SnowIdUtil.nextId();
String batchId = data.getJSONObject("res").getString("batchId");
PushLogEntity pushLog = getPushLog(id, informForm, batchId, data.toString(), 2);
this.save(pushLog);
} catch (Exception e) {
log.error("保存mob推送日志错误:{}", e.getMessage());
e.printStackTrace();
}
}
/**
* 推送日志存储
*
* @param id id
* @param informForm 推送内容
* @param taskId 任务编号
* @param result 推送结果
* @param pushType 推送类型 1:个推 2:袤博
* @return 执行结果
* @throws Exception 异常
*/
private PushLogEntity getPushLog(Long id, InformForm informForm, String taskId, String result, Integer pushType) throws Exception {
PushLogEntity pushLogEntity = new PushLogEntity();
pushLogEntity.setId(id);
pushLogEntity.setAppName(informForm.getEquipmentType());
pushLogEntity.setPushType(pushType);
pushLogEntity.setTaskId(taskId);
if (result.length() > 200) {
result = result.substring(0, 200);
}
pushLogEntity.setResult(result);
String phone = informForm.getPhone();
if (StringUtils.isNotEmpty(phone)) {
DES des = DES.getInstanceDes();
pushLogEntity.setPhone(des.encrypt(phone));
}
Integer messageTemplate = informForm.getMessageTemplate();
if (messageTemplate != null) {
pushLogEntity.setMessageTemplate(messageTemplate);
}
pushLogEntity.setPushTarget(informForm.getCid() == null ? "all" : informForm.getCid());
pushLogEntity.setPushContent(informForm.getBody());
pushLogEntity.setArriveStatus(1001);
pushLogEntity.setUpdateTime(new Date());
return pushLogEntity;
}
/**
* 查询日志
*
......
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