diff --git a/mallplus-admin/src/main/java/com/zscat/mallplus/MallAdminApplication.java b/mallplus-admin/src/main/java/com/zscat/mallplus/MallAdminApplication.java
index ecf9746..c20d050 100644
--- a/mallplus-admin/src/main/java/com/zscat/mallplus/MallAdminApplication.java
+++ b/mallplus-admin/src/main/java/com/zscat/mallplus/MallAdminApplication.java
@@ -14,7 +14,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@MapperScan({"com.zscat.mallplus.mapper", "com.zscat.mallplus.ums.mapper", "com.zscat.mallplus.sms.mapper", "com.zscat.mallplus.cms.mapper", "com.zscat.mallplus.sys.mapper", "com.zscat.mallplus.oms.mapper", "com.zscat.mallplus.pms.mapper"})
@EnableTransactionManagement
-@EnableScheduling
+// @EnableScheduling
public class MallAdminApplication {
public static void main(String[] args) {
SpringApplication.run(MallAdminApplication.class, args);
diff --git a/mallplus-admin/src/main/java/com/zscat/mallplus/task/SchedulingTaskComponent.java b/mallplus-admin/src/main/java/com/zscat/mallplus/task/SchedulingTaskComponent.java
index 6398223..789f9a2 100644
--- a/mallplus-admin/src/main/java/com/zscat/mallplus/task/SchedulingTaskComponent.java
+++ b/mallplus-admin/src/main/java/com/zscat/mallplus/task/SchedulingTaskComponent.java
@@ -47,13 +47,13 @@ import java.util.Date;
* @version 1.0
* @since 1.0
*/
-@Component
+// @Component
public class SchedulingTaskComponent {
@Autowired
private SysMessageTaskService sysMessageTaskService;
- @Scheduled(cron = "0 */5 * * * ?")
+ // @Scheduled(cron = "0 */5 * * * ?")
public void remindVehicle() {
sysMessageTaskService.checkTask();
}
diff --git a/mallplus-portal/pom.xml b/mallplus-portal/pom.xml
index c90a4f6..1b5a753 100644
--- a/mallplus-portal/pom.xml
+++ b/mallplus-portal/pom.xml
@@ -204,12 +204,12 @@
wsdl4j
1.6.3
-
-
-
-
-
-
+
+ com.getui.push
+ restful-sdk
+ 1.0.0.11
+ compile
+
diff --git a/mallplus-portal/src/main/java/com/zscat/mallplus/sms/service/ScheduledService.java b/mallplus-portal/src/main/java/com/zscat/mallplus/sms/service/ScheduledService.java
index b6443c0..2b61f04 100644
--- a/mallplus-portal/src/main/java/com/zscat/mallplus/sms/service/ScheduledService.java
+++ b/mallplus-portal/src/main/java/com/zscat/mallplus/sms/service/ScheduledService.java
@@ -1,5 +1,6 @@
package com.zscat.mallplus.sms.service;
+import com.zscat.mallplus.unipush.SysMessageTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -19,7 +20,7 @@ public class ScheduledService {
@Autowired
private ISmsCouponHistoryService smsCouponHistoryService;
-// @Scheduled(cron = "0 0 0 * * ?")
+ // @Scheduled(cron = "0 0 0 * * ?")
// @Scheduled(cron = "0 0/5 11 * * ?")
@Scheduled(cron = "*/5 * * * * ?")
public void remindVehicle() {
@@ -31,6 +32,15 @@ public class ScheduledService {
calendar.setTime(now);
String tomorrow = sdf.format(calendar.getTime());
//查询优惠券历史记录中已超过endTime时间的
- smsCouponHistoryService.updateUseStatus(2,tomorrow);
+ smsCouponHistoryService.updateUseStatus(2, tomorrow);
+ }
+
+
+ @Autowired
+ private SysMessageTaskService sysMessageTaskService;
+
+ @Scheduled(cron = "0 */5 * * * ?")
+ public void checkSysMessageTask() {
+ sysMessageTaskService.checkTask();
}
}
diff --git a/mallplus-portal/src/main/java/com/zscat/mallplus/ums/service/ISysMessageService.java b/mallplus-portal/src/main/java/com/zscat/mallplus/ums/service/ISysMessageService.java
index 3a36f1e..ac68afa 100644
--- a/mallplus-portal/src/main/java/com/zscat/mallplus/ums/service/ISysMessageService.java
+++ b/mallplus-portal/src/main/java/com/zscat/mallplus/ums/service/ISysMessageService.java
@@ -23,4 +23,6 @@ public interface ISysMessageService extends IService {
IPage listPageByUserId(Long id, IPage page);
IPage listPageOfSys(IPage page);
+
+ void sendToAll(SysMessage sm);
}
diff --git a/mallplus-portal/src/main/java/com/zscat/mallplus/ums/service/impl/SysMessageServiceImpl.java b/mallplus-portal/src/main/java/com/zscat/mallplus/ums/service/impl/SysMessageServiceImpl.java
index 8a669e3..a117e7c 100644
--- a/mallplus-portal/src/main/java/com/zscat/mallplus/ums/service/impl/SysMessageServiceImpl.java
+++ b/mallplus-portal/src/main/java/com/zscat/mallplus/ums/service/impl/SysMessageServiceImpl.java
@@ -6,8 +6,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zscat.mallplus.ums.entity.SysMessage;
import com.zscat.mallplus.ums.mapper.SysMessageMapper;
import com.zscat.mallplus.ums.service.ISysMessageService;
+import com.zscat.mallplus.unipush.UniPushService;
+import com.zscat.mallplus.unipush.entity.PushCids;
+import com.zscat.mallplus.unipush.mapper.PushCidsMapper;
import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -21,6 +26,11 @@ import java.util.List;
@Service
public class SysMessageServiceImpl extends ServiceImpl implements ISysMessageService {
+ @Resource
+ private PushCidsMapper pushCidsMapper;
+ @Resource
+ private UniPushService uniPushService;
+
@Override
public List listByUserId(Long userId) {
QueryWrapper qw = new QueryWrapper<>();
@@ -53,4 +63,22 @@ public class SysMessageServiceImpl extends ServiceImpl cids = listPushCidAll();
+ uniPushService.sendPushAsync(sysMessage, cids);
+ }
+ private List listPushCidAll() {
+ List list = pushCidsMapper.selectList(new QueryWrapper<>());
+ List cids = new ArrayList<>();
+ list.forEach(ent -> cids.add(ent.getGetuiCid()));
+ return cids;
+ }
}
diff --git a/mallplus-portal/src/main/java/com/zscat/mallplus/unipush/SysMessageTaskService.java b/mallplus-portal/src/main/java/com/zscat/mallplus/unipush/SysMessageTaskService.java
new file mode 100644
index 0000000..d34d2dc
--- /dev/null
+++ b/mallplus-portal/src/main/java/com/zscat/mallplus/unipush/SysMessageTaskService.java
@@ -0,0 +1,40 @@
+package com.zscat.mallplus.unipush;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zscat.mallplus.ums.entity.SysMessage;
+import com.zscat.mallplus.ums.entity.SysMessageTask;
+import com.zscat.mallplus.ums.mapper.SysMessageTaskMapper;
+import com.zscat.mallplus.ums.service.ISysMessageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class SysMessageTaskService extends ServiceImpl {
+
+ @Autowired
+ private ISysMessageService messageService;
+
+ public void checkTask() {
+ QueryWrapper qw = new QueryWrapper<>();
+ qw.eq("status", 0);
+ qw.lt("sendtime", new Date());
+ List list = baseMapper.selectList(qw);
+ for (SysMessageTask task : list) {
+ SysMessage sm = new SysMessage();
+ sm.setCode("系统消息");
+ sm.setUserId(1);
+ sm.setId(null);
+ sm.setContent(task.getContent());
+ sm.setParams(task.getParams());
+ sm.setCtime(System.currentTimeMillis());
+ messageService.sendToAll(sm);
+ task.setStatus(1);
+ baseMapper.updateById(task);
+ }
+
+ }
+}
diff --git a/mallplus-portal/src/main/java/com/zscat/mallplus/unipush/UniPushService.java b/mallplus-portal/src/main/java/com/zscat/mallplus/unipush/UniPushService.java
new file mode 100644
index 0000000..b72a60b
--- /dev/null
+++ b/mallplus-portal/src/main/java/com/zscat/mallplus/unipush/UniPushService.java
@@ -0,0 +1,329 @@
+package com.zscat.mallplus.unipush;
+
+import cn.hutool.core.thread.ThreadUtil;
+import cn.hutool.json.JSONUtil;
+import com.getui.push.v2.sdk.ApiHelper;
+import com.getui.push.v2.sdk.GtApiConfiguration;
+import com.getui.push.v2.sdk.api.PushApi;
+import com.getui.push.v2.sdk.common.ApiResult;
+import com.getui.push.v2.sdk.dto.req.Audience;
+import com.getui.push.v2.sdk.dto.req.AudienceDTO;
+import com.getui.push.v2.sdk.dto.req.message.PushDTO;
+import com.getui.push.v2.sdk.dto.req.message.PushMessage;
+import com.getui.push.v2.sdk.dto.req.message.android.GTNotification;
+import com.getui.push.v2.sdk.dto.res.TaskIdDTO;
+import com.zscat.mallplus.ums.entity.SysMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class UniPushService {
+
+ private static final Logger L = LoggerFactory.getLogger(UniPushService.class);
+
+ // @Value("${unipush.appid:UBUIDJ8NQm50rGJsB6LYx1}")
+ // private String appid;
+
+ private static String apiurl = "https://restapi.getui.com/v2/";
+ private static String appid = "UBUIDJ8NQm50rGJsB6LYx1";
+ private static String appkey = "RS3UZfeS509hcNEkmfS6R";
+ private static String appsecret = "6QuFcPWFga8DQzSa03ruR7";
+ private static String mastersecret = "6fjUinwRfDA3BcEnDQvTl5";
+ private static String apppackage = "org.jbase.yxt.yyd.pyw";
+
+ private static PushApi pushApi = null;
+
+ private PushApi singlePushApi() {
+ if (pushApi == null) {
+ System.setProperty("http.maxConnections", "200");
+ GtApiConfiguration apiConfiguration = new GtApiConfiguration();
+ //填写应用配置
+ apiConfiguration.setAppId(appid);
+ apiConfiguration.setAppKey(appkey);
+ apiConfiguration.setMasterSecret(mastersecret);
+ // 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId
+ apiConfiguration.setDomain(apiurl);
+ // 实例化ApiHelper对象,用于创建接口对象
+ ApiHelper apiHelper = ApiHelper.build(apiConfiguration);
+ // 创建对象,建议复用。目前有PushApi、StatisticApi、UserApi
+ pushApi = apiHelper.creatApi(PushApi.class);
+ }
+ return pushApi;
+ }
+
+
+ public void test() {
+ // 设置httpClient最大连接数,当并发较大时建议调大此参数。或者启动参数加上 -Dhttp.maxConnections=200
+ System.setProperty("http.maxConnections", "200");
+ GtApiConfiguration apiConfiguration = new GtApiConfiguration();
+ //填写应用配置
+ apiConfiguration.setAppId("UBUIDJ8NQm50rGJsB6LYx1");
+ apiConfiguration.setAppKey("RS3UZfeS509hcNEkmfS6R");
+ apiConfiguration.setMasterSecret("6fjUinwRfDA3BcEnDQvTl5");
+ // 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId
+ apiConfiguration.setDomain("https://restapi.getui.com/v2/");
+ // 实例化ApiHelper对象,用于创建接口对象
+ ApiHelper apiHelper = ApiHelper.build(apiConfiguration);
+ // 创建对象,建议复用。目前有PushApi、StatisticApi、UserApi
+ PushApi pushApi = apiHelper.creatApi(PushApi.class);
+
+ //根据cid进行单推
+ PushDTO pushDTO = new PushDTO();
+ // 设置推送参数
+ pushDTO.setRequestId(System.currentTimeMillis() + "");
+ /**** 设置个推通道参数 *****/
+ PushMessage pushMessage = new PushMessage();
+ pushDTO.setPushMessage(pushMessage);
+ GTNotification notification = new GTNotification();
+ pushMessage.setNotification(notification);
+ notification.setTitle("测试TitleXXX");
+ notification.setBody("测试BodyXXXXXX");
+ String payload = "{\"title\":\"liutitle\",\"body\":\"liubody\",\"name\":\"hao\",\"userid\":101,\"msgtitle\":\"haha\"}";
+ notification.setPayload(payload);
+ notification.setClickType("payload");
+// notification.setClickType("url");
+// notification.setUrl("https://www.getui.com");
+ /**** 设置个推通道参数,更多参数请查看文档或对象源码 *****/
+
+// /**** 设置厂商相关参数 ****/
+// PushChannel pushChannel = new PushChannel();
+// pushDTO.setPushChannel(pushChannel);
+// /*配置安卓厂商参数*/
+// AndroidDTO androidDTO = new AndroidDTO();
+// pushChannel.setAndroid(androidDTO);
+// Ups ups = new Ups();
+// androidDTO.setUps(ups);
+// ThirdNotification thirdNotification = new ThirdNotification();
+// ups.setNotification(thirdNotification);
+// thirdNotification.setTitle("厂商title");
+// thirdNotification.setBody("厂商body");
+// thirdNotification.setClickType("url");
+// thirdNotification.setUrl("https://www.getui.com");
+// // 两条消息的notify_id相同,新的消息会覆盖老的消息,取值范围:0-2147483647
+// // thirdNotification.setNotifyId("11177");
+// /*配置安卓厂商参数结束,更多参数请查看文档或对象源码*/
+
+// /*设置ios厂商参数*/
+// IosDTO iosDTO = new IosDTO();
+// pushChannel.setIos(iosDTO);
+// // 相同的collapseId会覆盖之前的消息
+// iosDTO.setApnsCollapseId("xxx");
+// Aps aps = new Aps();
+// iosDTO.setAps(aps);
+// Alert alert = new Alert();
+// aps.setAlert(alert);
+// alert.setTitle("ios title");
+// alert.setBody("ios body");
+// /*设置ios厂商参数结束,更多参数请查看文档或对象源码*/
+
+ /*设置接收人信息*/
+ Audience audience = new Audience();
+ pushDTO.setAudience(audience);
+ audience.addCid("89e286aee78d38faf748a690e603b1a3");
+ /*设置接收人信息结束*/
+ /**** 设置厂商相关参数,更多参数请查看文档或对象源码 ****/
+
+ // 进行cid单推
+ ApiResult