|
@@ -1,5 +1,6 @@
|
|
|
package com.bosshand.virgo.api.service;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.bosshand.virgo.api.dao.ReminderDao;
|
|
|
import com.bosshand.virgo.api.model.Reminder;
|
|
@@ -11,6 +12,7 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
@@ -21,6 +23,9 @@ public class ReminderService {
|
|
|
@Autowired
|
|
|
ReminderDao reminderDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ManagerClient managerClient;
|
|
|
+
|
|
|
public int getTotalCount(Reminder reminder) {
|
|
|
return reminderDao.getTotalCount(reminder);
|
|
|
}
|
|
@@ -44,6 +49,56 @@ public class ReminderService {
|
|
|
return reminder;
|
|
|
}
|
|
|
|
|
|
+ public void addMessage(Reminder reminder) {
|
|
|
+
|
|
|
+ long userId = reminder.getCreator();
|
|
|
+
|
|
|
+ long organizationId = reminder.getOrganizationId();
|
|
|
+ long projectId = reminder.getProjectId();
|
|
|
+
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("organizationId", organizationId);
|
|
|
+ json.put("projectId", projectId);
|
|
|
+ json.put("dataId", reminder.getId());
|
|
|
+
|
|
|
+
|
|
|
+ List<Long> userIds = new ArrayList<>();
|
|
|
+ userIds.add(userId);
|
|
|
+
|
|
|
+ String userList = reminder.getUserList();
|
|
|
+ if (StringUtil.notBlank(userList)) {
|
|
|
+ JSONArray jsonArray = JSONObject.parseArray(userList);
|
|
|
+ if (jsonArray.size() > 0) {
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ long uid = jsonArray.getJSONObject(i).getLongValue("id");
|
|
|
+ userIds.add(uid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONArray ja = new JSONArray();
|
|
|
+
|
|
|
+ for(Long d : userIds){
|
|
|
+ JSONObject js = new JSONObject();
|
|
|
+ js.put("messageType", 7);
|
|
|
+ js.put("sender", userId);
|
|
|
+ js.put("title", "提醒消息");
|
|
|
+ js.put("message","【提醒消息】");
|
|
|
+ js.put("userId",d);
|
|
|
+ js.put("viewed", false);
|
|
|
+ js.put("systemMessage", false);
|
|
|
+ js.put("pushed", false);
|
|
|
+ js.put("json", json.toJSONString());
|
|
|
+ js.put("isCC", false);
|
|
|
+ ja.add(js);
|
|
|
+ }
|
|
|
+ managerClient.pushReminderMessage(ja.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ public int updateState(long id) {
|
|
|
+ return reminderDao.updateState(id);
|
|
|
+ }
|
|
|
+
|
|
|
public List<Reminder> getList(Reminder reminder) {
|
|
|
return reminderDao.getList(reminder);
|
|
|
}
|