add 推送通知test

master
luoyang 5 years ago
parent b80d3e8f0f
commit aef3a80bba

@ -9,7 +9,7 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId> <artifactId>manage</artifactId>
<version>1.4.31</version> <version>1.4.32</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.8.0</jib-maven-plugin.version> <jib-maven-plugin.version>1.8.0</jib-maven-plugin.version>

@ -26,4 +26,6 @@ public interface AppActService {
void published(JSONObject manager,String act_id,boolean is_valid); void published(JSONObject manager,String act_id,boolean is_valid);
void sendAnnualBillMessage(JSONObject params); void sendAnnualBillMessage(JSONObject params);
void sendTESTAnnualBillMessage(JSONObject params);
} }

@ -137,7 +137,6 @@ public class AppActServiceImp implements AppActService {
@Override @Override
public void sendAnnualBillMessage(JSONObject params) { public void sendAnnualBillMessage(JSONObject params) {
logger.debug("sendAnnualMessage Begin"); logger.debug("sendAnnualMessage Begin");
List<JSONObject> tokens = clientDeviceTokenMapper.listAllTokens(params); List<JSONObject> tokens = clientDeviceTokenMapper.listAllTokens(params);
for (JSONObject devToken : tokens) { for (JSONObject devToken : tokens) {
@ -183,6 +182,48 @@ public class AppActServiceImp implements AppActService {
} }
} }
@Override
public void sendTESTAnnualBillMessage(JSONObject params) {
logger.debug("sendAnnualMessage Begin");
JSONObject devToken = clientDeviceTokenMapper.findByDevId("cf90a252-1121-4bfd-a201-fb573b44ac11");
Runnable task = () -> {
String token = devToken.getString("token");
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"),
devToken.getIntValue("client_id"),
"annual_bill" + devToken.getString("client_type"),
token,
"年度账单"
);
try {
JSONObject type = new JSONObject();
type.put("send_type", "annual_bill");
type.put("id", devToken.getString("dev_token_id"));
AppMsgSender sender = senderMap.get((devToken.getString("client_type")));
if (StringUtils.isBlank(token) || sender == null) {
return;
}
JSONObject managerMsg = new JSONObject();
managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.annual_bill"));
managerMsg.put("body", LocaleSupport.localeMessage("app.message.body.annual_bill"));
managerMsg.put("type", type);
JSONObject messageData = new JSONObject();
messageData.put("url", PlatformEnvironment.getEnv().concatUrl("/annual_bill.html"));
System.out.println(PlatformEnvironment.getEnv().concatUrl("/annual_bill.html"));
managerMsg.put("data", messageData);
managerMsg.put("msgType", "annual_bill");
AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage();
sender.sendMessage(appMessage, devToken);
log.put("status", 2);
appMessageLogMapper.update(log);
} catch (Exception e) {
logger.error("出错了:" + e.getMessage());
appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage());
throw new ServerErrorException("Send App" + devToken.getString("client_type") + "Filed" + ",token" + token, e);
}
};
sendingAppleMsgPool.execute(task);
}
private JSONObject saveAppMessageLog(String dev_id, int client_id, String messageType, String dev_token, String remark) { private JSONObject saveAppMessageLog(String dev_id, int client_id, String messageType, String dev_token, String remark) {
JSONObject log = new JSONObject(); JSONObject log = new JSONObject();
log.put("dev_id", dev_id); log.put("dev_id", dev_id);

@ -7,10 +7,8 @@ import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -50,13 +48,13 @@ public class AppActController {
public String testSendAnnualBillMessage() { public String testSendAnnualBillMessage() {
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
params.put("client_id", 9); params.put("client_id", 9);
appActService.sendAnnualBillMessage(params); appActService.sendTESTAnnualBillMessage(params);
return "success"; return "success";
} }
@GetMapping(value = "/annual/bill/all") // @GetMapping(value = "/annual/bill/all")
public String sendAnnualBillMessage() { // public String sendAnnualBillMessage() {
appActService.sendAnnualBillMessage(null); // appActService.sendAnnualBillMessage(null);
return "success"; // return "success";
} // }
} }

Loading…
Cancel
Save