PushMessage.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. package cn.com.ty.lift.common.model;
  2. import cn.com.ty.lift.common.utils.ValuePool;
  3. import cn.hutool.core.collection.IterUtil;
  4. import lombok.Data;
  5. import lombok.extern.slf4j.Slf4j;
  6. import org.springframework.jms.core.JmsMessagingTemplate;
  7. import org.springframework.messaging.support.GenericMessage;
  8. import java.io.Serializable;
  9. import java.time.LocalDate;
  10. import java.time.LocalDateTime;
  11. import java.util.ArrayList;
  12. import java.util.List;
  13. /**
  14. * 推送消息
  15. *
  16. * @author wcz
  17. * @since 2020/4/14
  18. */
  19. @Slf4j
  20. @Data
  21. public class PushMessage implements Serializable {
  22. private String title;
  23. private String content;
  24. private ArrayList<String> toList;
  25. //the count of try again. Increase 1 for each failure, maximum times 100
  26. private int tryCount = 0;
  27. private PushMessage() {
  28. }
  29. private PushMessage(String title, String content) {
  30. this.title = title;
  31. this.content = content;
  32. }
  33. private static PushMessage create(String title, String content) {
  34. return new PushMessage(title, content);
  35. }
  36. private static PushMessage team(String content) {
  37. return create("团队消息", content);
  38. }
  39. private static PushMessage work(String content) {
  40. return create("工作消息", content);
  41. }
  42. private static PushMessage maintain(String content) {
  43. return create("保养消息", content);
  44. }
  45. private static PushMessage emergency(String content) {
  46. return create("急修消息", content);
  47. }
  48. private static PushMessage manager(String content) {
  49. return create("提醒", content);
  50. }
  51. private static PushMessage inspection(String content) {
  52. return create("年检消息", content);
  53. }
  54. /**
  55. * PC
  56. * 所有文员
  57. * 申请团队
  58. * 【申请人】申请加入【团队名称】。
  59. */
  60. public static PushMessage teamApply(String applyName, String teamName) {
  61. String message = "%s申请加入%s。";
  62. String content = String.format(message, applyName, teamName);
  63. return team(content);
  64. }
  65. /**
  66. * 移动端
  67. * 区域主管、申请人
  68. * 加入团队成功
  69. * 【申请人】已经成功加入【团队名称】。
  70. */
  71. public static PushMessage teamJoin(String applyName, String teamName) {
  72. String message = "%s已经成功加入%s。";
  73. String content = String.format(message, applyName, teamName);
  74. return team(content);
  75. }
  76. /**
  77. * 移动端
  78. * 区域主管、被踢人
  79. * 移出团队
  80. * 【被踢人】已经被移出【团队名称】
  81. */
  82. public static PushMessage teamKickOut(String kickName, String teamName) {
  83. String message = "%s已经被踢出%s。";
  84. String content = String.format(message, kickName, teamName);
  85. return team(content);
  86. }
  87. /**
  88. * PC/移动端
  89. * 区域主管(项目所属)、所有文员
  90. * 物业申请项目
  91. * 物业【申请人】申请【项目名称】【评价/查看】权限。
  92. */
  93. public static PushMessage workApplyPermission(String applyName, String projectName, String permission) {
  94. String message = "物业%s申请%s的%s权限。";
  95. String content = String.format(message, applyName, projectName, permission);
  96. return work(content);
  97. }
  98. /**
  99. * 移动端
  100. * 区域主管(项目所属)
  101. * 物业获得权限
  102. * 物业【申请人】成功获得【项目名称】【评价/查看】权限。
  103. */
  104. public static PushMessage workObtainPermission(String applyName, String projectName, String permission) {
  105. String message = "物业%s成功获得%s的%s权限。";
  106. String content = String.format(message, applyName, projectName, permission);
  107. return work(content);
  108. }
  109. /**
  110. * 移动端
  111. * 区域主管(项目所属)
  112. * 取消物业权限
  113. * 物业【申请人】失去【项目名称】【评价/查看】权限。
  114. */
  115. public static PushMessage workAbolishPermission(String applyName, String projectName, String permission) {
  116. String message = "物业%s失去%s的%s权限。";
  117. String content = String.format(message, applyName, projectName, permission);
  118. return work(content);
  119. }
  120. /**
  121. * PC/移动端
  122. * 超管、区域主管(项目所属)、所有文员(项目所属)
  123. * 新增项目
  124. * 【区域名称】新增【项目名称】项目,共计【台量】台,生效时间【生效时间】,区域主管【区域主管】。
  125. */
  126. public static PushMessage workAddProject(String areaName, String projectName, int num, String startDate, String directorName) {
  127. String message = "%s新增%s项目,共计%s台,生效时间%s,区域主管%s。";
  128. String content = String.format(message, areaName, projectName, num, startDate, directorName);
  129. return work(content);
  130. }
  131. /**
  132. * PC/移动端
  133. * 超管、区域主管(项目所属)、所有文员(项目所属)
  134. * 项目开始生效
  135. * 【区域名称】【项目名称】项目进入服务期。
  136. */
  137. public static PushMessage workStartProject(String areaName, String projectName) {
  138. String message = "%s的%s项目进入服务期。";
  139. String content = String.format(message, areaName, projectName);
  140. return work(content);
  141. }
  142. /**
  143. * PC/移动端
  144. * 超管、区域主管(项目所属)、所有文员(项目所属)
  145. * 项目逾期
  146. * 【区域名称】【项目名称】已经逾期,请尽快办理合同续签或停止服务手续。
  147. */
  148. public static PushMessage workProjectOverdue(String areaName, String projectName) {
  149. String message = "%s的%s已经逾期,请尽快办理合同续签或停止服务手续。";
  150. String content = String.format(message, areaName, projectName);
  151. return work(content);
  152. }
  153. /**
  154. * PC/移动端
  155. * 超管、区域主管(项目所属)、所有文员(项目所属)
  156. * 停止服务
  157. * 【区域名称】【项目名称】已经停止服务,共计【台量】台。
  158. */
  159. public static PushMessage workProjectStopService(String areaName, String projectName, int num) {
  160. String message = "%s的%s已经停止服务,共计%s台。";
  161. String content = String.format(message, areaName, projectName, num);
  162. return work(content);
  163. }
  164. /**
  165. * PC/移动端
  166. * 超管、区域主管(项目所属)、所有文员(项目所属)
  167. * 恢复逾期
  168. * 【区域名称】【项目名称】已经续签完毕。
  169. */
  170. public static PushMessage workProjectRecoverService(String areaName, String projectName) {
  171. String message = "%s的%s已经续签完毕。";
  172. String content = String.format(message, areaName, projectName);
  173. return work(content);
  174. }
  175. /**
  176. * PC/移动端
  177. * 超管、区域主管(项目所属)、所有文员(项目所属)
  178. * 区域更换负责人
  179. * 【区域名称】的负责人,由【原区域主管】变更为【新区域主管】
  180. */
  181. public static PushMessage workReplaceRegionCharger(String areaName, String original, String newer) {
  182. String message = "%s的负责人,由%s变更为%s";
  183. String content = String.format(message, areaName, original, newer);
  184. return work(content);
  185. }
  186. /**
  187. * PC/移动端
  188. * 超管、区域主管(项目所属)、所有文员(项目所属)
  189. * 创建电梯
  190. * 【创建人】为【项目名称】新增电梯位于【电梯位置】,注册代码【注册代码】
  191. */
  192. public static PushMessage workCreateLift(String operator, String projectName, String devicePosition, String registrationCode) {
  193. String message = "%s为%s新增电梯位于%s,注册代码%s";
  194. String content = String.format(message, operator, projectName, devicePosition, registrationCode);
  195. return work(content);
  196. }
  197. /**
  198. * PC/移动端
  199. * 超管、区域主管(项目所属)、所有文员(项目所属)
  200. * 更新电梯信息(除定位、更换负责人)
  201. * 【更新人】更新【项目名称】【电梯位置】的电梯信息,注册代码【注册代码】
  202. */
  203. public static PushMessage workModifyLift(String operator, String projectName, String devicePosition, String registrationCode) {
  204. String message = "%s更新%s的%s的电梯信息,注册代码%s";
  205. String content = String.format(message, operator, projectName, devicePosition, registrationCode);
  206. return work(content);
  207. }
  208. /**
  209. * PC/移动端
  210. * 超管、区域主管(项目所属)、所有文员(项目所属)
  211. * 更新电梯定位
  212. * 【更新人】更新【项目名称】【电梯位置】的电梯定位为【电梯位置新】,注册代码【注册代码】
  213. */
  214. public static PushMessage workModifyLiftPosition(String operator, String projectName, String devicePosition, String newPosition, String registrationCode) {
  215. String message = "%s更新%s的%s的电梯定位为%s,注册代码%s";
  216. String content = String.format(message, operator, projectName, devicePosition, newPosition, registrationCode);
  217. return work(content);
  218. }
  219. /**
  220. * PC/移动端
  221. * 超管、区域主管(项目所属)、所有文员(项目所属)、相关维保工
  222. * 电梯更换主要负责人
  223. * 【区域名称】的【项目名称】的【电梯位置】电梯,【注册代码】,主要负责人由【原负责人】更换为【新负责人】。
  224. */
  225. public static PushMessage workReplaceLiftCharger(String areaName, String projectName, String devicePosition, String registrationCode, String original, String newer) {
  226. String message = "%s的%s的%s电梯,注册代码%s,主要负责人由%s更换为%s。";
  227. String content = String.format(message, areaName, projectName, devicePosition, registrationCode, original, newer);
  228. return work(content);
  229. }
  230. //保养类型 1.半月,2.季度,3.半年,4.全年
  231. private static String getMaintainType(int type) {
  232. switch (type) {
  233. case 1:
  234. return "半月保";
  235. case 2:
  236. return "季度保";
  237. case 3:
  238. return "半年保";
  239. case 4:
  240. return "全年保";
  241. default:
  242. return "未知类型";
  243. }
  244. }
  245. /**
  246. * 移动端
  247. * 区域主管、相关维保工
  248. * 制定保养计划
  249. * 维保计划制定:【区域名称】【项目名称】的【电梯位置】电梯,【注册代码】,保养间隔时间【x】天,下次保养时间【下次保养时间】,保养类型【保养类型】,负责人【电梯负责人】。制定人【操作人】
  250. * 保养类型 1.半月,2.季度,3.半年,4.全年
  251. */
  252. public static PushMessage maintainCreatePlan(String areaName, String projectName, String devicePosition, String registrationCode, int interval, LocalDate planDate, int type, String liftCharge, String operator) {
  253. String message = "维保计划制定:%s%s的%s电梯,%s,保养间隔时间%s天,下次保养时间%tF,保养类型%s,负责人%s。制定人%s";
  254. String content = String.format(message, areaName, projectName, devicePosition, registrationCode, interval, planDate, getMaintainType(type), liftCharge, operator);
  255. return maintain(content);
  256. }
  257. /**
  258. * 移动端
  259. * 区域主管、相关维保工
  260. * 修改保养计划
  261. * 维保计划修改:【区域名称】【项目名称】的【电梯位置】电梯,【注册代码】,保养间隔时间【x】天,下次保养时间【下次保养时间】,保养类型【保养类型】,负责人【电梯负责人】。修改人【操作人】
  262. */
  263. public static PushMessage maintainModifyPlan(String areaName, String projectName, String devicePosition, String registrationCode, int interval, LocalDate planDate, int type, String liftCharge, String operator) {
  264. String message = "维保计划修改:%s%s的%s电梯,%s,保养间隔时间%s天,下次保养时间%tF,保养类型%s,负责人%s。修改人%s";
  265. String content = String.format(message, areaName, projectName, devicePosition, registrationCode, interval, planDate, getMaintainType(type), liftCharge, operator);
  266. return maintain(content);
  267. }
  268. /**
  269. * 移动端
  270. * 相关维保工
  271. * 每天有维保任务
  272. * 您今天有需要保养的电梯【x】台,请查看任务!
  273. */
  274. public static PushMessage maintainHasTaskDaily(int num) {
  275. String message = "您今天有需要保养的电梯%s台,请查看任务!";
  276. String content = String.format(message, num);
  277. return maintain(content);
  278. }
  279. private static String getTrappedDesc(int isTrapped) {
  280. return isTrapped == 1 ? "已" : "未";
  281. }
  282. /**
  283. * 移动端
  284. * 总经理、区域主管(项目所属)、相关维保工
  285. * 急修指派
  286. * 【区域名称】的【项目名称】的【电梯位置】电梯,注册代码【注册代码】,于【报修时间】接到召修信息,【已/未】困人,请【被派单人】立即响应。
  287. */
  288. public static PushMessage emergencyAssign(String areaName, String projectName, String devicePosition, String registrationCode, LocalDateTime callerDate, int isTrapped, String callerFaultDescription, String workerName) {
  289. String message = "%s的%s的%s电梯,注册代码%s,于%tF %tT接到召修信息,%s困人,召修描述:%s,请%s立即响应。";
  290. String content = String.format(message, areaName, projectName, devicePosition, registrationCode, callerDate, callerDate, getTrappedDesc(isTrapped), callerFaultDescription, workerName);
  291. return emergency(content);
  292. }
  293. /**
  294. * PC/移动端
  295. * 总经理、区域主管(项目所属)、所有文员(项目所属)、相关维保工
  296. * 物业发起急修
  297. * 【区域名称】的【项目名称】的【电梯位置】电梯,注册代码【注册代码】,物业端于【报修时间】发出召修信息,【已/未】困人,请【电梯主要负责人】立即响应。
  298. */
  299. public static PushMessage emergencyAssignByProperty(String areaName, String projectName, String devicePosition, String registrationCode, LocalDateTime callerDate, int isTrapped, String callerFaultDescription, String workerName) {
  300. String message = "%s的%s的%s电梯,注册代码%s,物业端于%tF %tT发出召修信息,%s困人,召修描述:%s,请%s立即响应。";
  301. String content = String.format(message, areaName, projectName, devicePosition, registrationCode, callerDate, callerDate, getTrappedDesc(isTrapped), callerFaultDescription, workerName);
  302. return emergency(content);
  303. }
  304. /**
  305. * 移动端
  306. * 总经理、区域主管(项目所属)、相关维保工
  307. * 转派
  308. * 【区域名称】的【项目名称】的【电梯位置】电梯,注册代码【注册代码】,物业端于【报修时间】发出召修信息,【已/未】困人,请【被派单人】立即响应。
  309. * 【原被派单人】:【区域名称】的【项目名称】的【电梯位置】电梯,注册代码【注册代码】,急修信息已经转派给【被派单人】。
  310. */
  311. public static PushMessage emergencyTransfer(String areaName, String projectName, String devicePosition, String registrationCode, LocalDateTime callerDate, int isTrapped, String callerFaultDescription, String workerName) {
  312. String message = "%s的%s的%s电梯,注册代码%s,物业端于%tF %tT发出召修信息,%s困人,召修描述:%s,请%s立即响应。";
  313. String content = String.format(message, areaName, projectName, devicePosition, registrationCode, callerDate, callerDate, getTrappedDesc(isTrapped), callerFaultDescription, workerName);
  314. return emergency(content);
  315. }
  316. /**
  317. * 移动端
  318. * 【原被派单人】收到消息:【区域名称】的【项目名称】的【电梯位置】电梯,注册代码【注册代码】,急修信息已经转派给【被派单人】。
  319. */
  320. public static PushMessage emergencyTransferForOriginal(String areaName, String projectName, String devicePosition, String registrationCode, String workerName) {
  321. String message = "%s的%s的%s电梯,注册代码%s,急修信息已经转派给%s。";
  322. String content = String.format(message, areaName, projectName, devicePosition, registrationCode, workerName);
  323. return emergency(content);
  324. }
  325. /**
  326. * PC/移动端
  327. * 总经理、区域主管(项目所属)、所有文员(项目所属)
  328. * 维保工接收急修通知
  329. * 【区域名称】的【项目名称】的【电梯位置】电梯,注册代码【注册代码】,于【报修时间】接到召修信息,维保工已确认。
  330. */
  331. public static PushMessage emergencyTaking(String areaName, String projectName, String devicePosition, String registrationCode, LocalDateTime callerDate) {
  332. String message = "%s的%s的%s电梯,注册代码%s,于%tF %tT接到召修信息,维保工已接收通知。";
  333. String content = String.format(message, areaName, projectName, devicePosition, registrationCode, callerDate, callerDate);
  334. return emergency(content);
  335. }
  336. /**
  337. * PC/移动端
  338. * 总经理、区域主管(项目所属)、所有文员(项目所属)
  339. * 维保工到达现场
  340. * 【区域名称】的【项目名称】的【电梯位置】电梯,注册代码【注册代码】,于【报修时间】接到召修信息,维保工已于【到达时间】到达现场。
  341. */
  342. public static PushMessage emergencyArrive(String areaName, String projectName, String devicePosition, String registrationCode, LocalDateTime callerDate, LocalDateTime arriveTime) {
  343. String message = "%s的%s的%s电梯,注册代码%s,于%tF %tT接到召修信息,维保工已于%tF %tT到达现场。";
  344. String content = String.format(message, areaName, projectName, devicePosition, registrationCode, callerDate, callerDate, arriveTime, arriveTime);
  345. return emergency(content);
  346. }
  347. /**
  348. * PC/移动端
  349. * 总经理、区域主管(项目所属)、所有文员(项目所属)
  350. * 维保工提交急修单
  351. * 【区域名称】的【项目名称】的【电梯位置】电梯,注册代码【注册代码】,于【报修时间】接到召修信息,电梯已于【恢复时间】恢复正常。
  352. */
  353. public static PushMessage emergencyOrder(String areaName, String projectName, String devicePosition, String registrationCode, LocalDateTime callerDate, LocalDateTime recoveryDate) {
  354. String message = "%s的%s的%s电梯,注册代码%s,于%tF %tT接到召修信息,电梯已于%tF %tT恢复正常。";
  355. String content = String.format(message, areaName, projectName, devicePosition, registrationCode, callerDate, callerDate, recoveryDate, recoveryDate);
  356. return emergency(content);
  357. }
  358. /**
  359. * PC/移动端
  360. * 所有人
  361. * 公司发送公告
  362. * 有一条公司公告,请查收
  363. */
  364. public static PushMessage announcementNotice() {
  365. return create("公司公告", "有一条公司公告,请查收");
  366. }
  367. /**
  368. * PC
  369. * 所有文员
  370. * 早上8点
  371. * 即时提醒:今天计划有X台电梯需保养,X台电梯正在维修中。
  372. */
  373. public static PushMessage managerMaintainDaily(int needs, int doings) {
  374. String message = "即时提醒:今天计划有%s台电梯需保养,%s台电梯正在维修中。";
  375. String content = String.format(message, needs, doings);
  376. return manager(content);
  377. }
  378. /**
  379. * 移动端
  380. * 区域主管(项目所属)
  381. * 下午4点
  382. * 即时提醒:【区域名称】今天共发生急修X次,已维修完毕X次,X次仍在处理中;X台电梯计划保养未完成。
  383. */
  384. public static PushMessage managerTaskForRegionChargerDaily(String areaName, int total, int finish, int doings, int todos) {
  385. String message = "即时提醒:%s今天共发生急修%s次,已维修完毕%s次,%s次仍在处理中;%s台电梯计划保养未完成。";
  386. String content = String.format(message, areaName, total, finish, doings, todos);
  387. return manager(content);
  388. }
  389. /**
  390. * 移动端
  391. * 总经理
  392. * 下午4点
  393. * 即时提醒:今天共发生急修X次,已维修完毕X次,X次仍在处理中;X台电梯计划保养未完成。
  394. */
  395. public static PushMessage managerTaskForLeaderDaily(String areaName, int total, int finish, int doings, int todos) {
  396. String message = "即时提醒:%s今天共发生急修%s次,已维修完毕%s次,%s次仍在处理中;%s台电梯计划保养未完成。";
  397. String content = String.format(message, areaName, total, finish, doings, todos);
  398. return manager(content);
  399. }
  400. /**
  401. * 移动端
  402. * 总经理,区域主管(项目所属)
  403. * 晚上8点
  404. * 日报:截止目前,今天应保养X台,已完成X台,X台即将超期;今天共发起急修X起,已处理完成X起,X起正在处理中。
  405. */
  406. public static PushMessage managerReportDaily(int needs, int finish, int overdue, int totalRepair, int finishRepair, int doingRepair) {
  407. String message = "日报:截止目前,今天应保养%s台,已完成%s台,%s台即将超期;今天共发起急修%s起,已处理完成%s起,%s起正在处理中。";
  408. String content = String.format(message, needs, finish, overdue, totalRepair, finishRepair, doingRepair);
  409. return manager(content);
  410. }
  411. /**
  412. * PC/移动端
  413. * 区域主管(项目所属),文员(所属文员),电梯主要负责人
  414. * 年检到期前45天
  415. * 【项目名称】的【电梯位置】电梯,注册代码【注册代码】,将于45日后年检到期。
  416. */
  417. public static PushMessage inspectionAdvance45daysNotice(String projectName, String devicePosition, String registrationCode) {
  418. String message = "%s的%s电梯,注册代码%s,将于45日后年检到期。";
  419. String content = String.format(message, projectName, devicePosition, registrationCode);
  420. return inspection(content);
  421. }
  422. /**
  423. * PC/移动端
  424. * 区域主管(项目所属),文员(所属文员),电梯主要负责人
  425. * 年检到期前15天
  426. * 【项目名称】的【电梯位置】电梯,注册代码【注册代码】,仍未启动年检,将于15日后年检到期。
  427. */
  428. public static PushMessage inspectionAdvance15daysNotice(String projectName, String devicePosition, String registrationCode) {
  429. String message = "%s的%s电梯,注册代码%s,仍未启动年检,将于15日后年检到期。";
  430. String content = String.format(message, projectName, devicePosition, registrationCode);
  431. return inspection(content);
  432. }
  433. /**
  434. * PC/移动端
  435. * 区域主管(项目所属),电梯负责人
  436. * 确认现场检验时间
  437. * 【项目名称】的【电梯位置】电梯,注册代码【注册代码】,已确认现场检验时间为【现场检验时间】。
  438. */
  439. public static PushMessage inspectionConfirmCheckDate(String projectName, String devicePosition, String registrationCode, LocalDate checkDate) {
  440. String message = "%s的%s电梯,注册代码%s,已确认现场检验时间为%tF。";
  441. String content = String.format(message, projectName, devicePosition, registrationCode, checkDate);
  442. return inspection(content);
  443. }
  444. /**
  445. * 移动端
  446. * 所有人
  447. * 【新闻标题】
  448. */
  449. public static PushMessage newsNotice(String title) {
  450. return create("发布新闻", title);
  451. }
  452. public boolean needSplit() {
  453. return toList != null && toList.size() > ValuePool.PUSH_MAX_SIZE;
  454. }
  455. public List<ArrayList<String>> doSplit(final int length) {
  456. List<ArrayList<String>> splits = new ArrayList<>();
  457. int size = toList.size();
  458. log.info("the size of toList is {}, need to split.", size);
  459. //0 1000 2000
  460. for (int i = 0; i < size; i += length) {
  461. if (i + length > size) {
  462. splits.add(new ArrayList<>(toList.subList(i, size)));
  463. } else {
  464. splits.add(new ArrayList<>(toList.subList(i, i + length)));
  465. }
  466. }
  467. log.info("the size of splits : {}", splits.size());
  468. return splits;
  469. }
  470. /**
  471. * list超过1000, 分批推送
  472. *
  473. * @param jmsMessagingTemplate jms
  474. * @param toAndroid android
  475. * @param toIos ios
  476. */
  477. public boolean sendTokenOnPlatform(JmsMessagingTemplate jmsMessagingTemplate, ArrayList<String> toAndroid, ArrayList<String> toIos) {
  478. try {
  479. if (IterUtil.isNotEmpty(toAndroid)) {
  480. this.setToList(toAndroid);
  481. jmsMessagingTemplate.send(ValuePool.QUEUE_ANDROID_TOKEN, new GenericMessage<>(this));
  482. } else if (IterUtil.isNotEmpty(toIos)) {
  483. this.setToList(toIos);
  484. jmsMessagingTemplate.send(ValuePool.QUEUE_IOS_TOKEN, new GenericMessage<>(this));
  485. } else {
  486. return false;
  487. }
  488. return true;
  489. } catch (Exception e) {
  490. log.error("Failed to Send pushMessage to ANDROID & IOS TOKEN Message Queue: ", e);
  491. return false;
  492. }
  493. }
  494. public boolean sendAllOnPlatform(JmsMessagingTemplate jmsMessagingTemplate) {
  495. try {
  496. jmsMessagingTemplate.send(ValuePool.QUEUE_ANDROID_ALL, new GenericMessage<>(this));
  497. jmsMessagingTemplate.send(ValuePool.QUEUE_IOS_ALL, new GenericMessage<>(this));
  498. return true;
  499. } catch (Exception e) {
  500. log.error("Failed to Send pushMessage to ANDROID & IOS ALL Message Queue: ", e);
  501. return false;
  502. }
  503. }
  504. public boolean sendTokenOnAndroid(JmsMessagingTemplate jmsMessagingTemplate, ArrayList<String> toList) {
  505. try {
  506. if (IterUtil.isEmpty(toList)) {
  507. return false;
  508. }
  509. this.setToList(toList);
  510. jmsMessagingTemplate.send(ValuePool.QUEUE_ANDROID_TOKEN, new GenericMessage<>(this));
  511. return true;
  512. } catch (Exception e) {
  513. log.error("Failed to Send pushMessage to ANDROID_TOKEN Message Queue: ", e);
  514. return false;
  515. }
  516. }
  517. public boolean sendTokenOnIos(JmsMessagingTemplate jmsMessagingTemplate, ArrayList<String> toList) {
  518. try {
  519. if (IterUtil.isEmpty(toList)) {
  520. return false;
  521. }
  522. this.setToList(toList);
  523. jmsMessagingTemplate.send(ValuePool.QUEUE_IOS_TOKEN, new GenericMessage<>(this));
  524. return true;
  525. } catch (Exception e) {
  526. log.error("Failed to Send pushMessage to IOS_TOKEN Message Queue: ", e);
  527. return false;
  528. }
  529. }
  530. }