|
@@ -1,8 +1,6 @@
|
|
package com.bosshand.virgo.message.service;
|
|
package com.bosshand.virgo.message.service;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
-import com.bosshand.virgo.core.utils.HttpsUtils;
|
|
|
|
import com.bosshand.virgo.exception.ServiceException;
|
|
import com.bosshand.virgo.exception.ServiceException;
|
|
import com.bosshand.virgo.message.beetl.FlowMessageGenerator;
|
|
import com.bosshand.virgo.message.beetl.FlowMessageGenerator;
|
|
import com.bosshand.virgo.message.beetl.MessageGenerator;
|
|
import com.bosshand.virgo.message.beetl.MessageGenerator;
|
|
@@ -14,8 +12,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.util.*;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class MessageService {
|
|
public class MessageService {
|
|
@@ -57,86 +57,6 @@ public class MessageService {
|
|
return notificationMessageDao.getMessageByMessageType(messageType, userId);
|
|
return notificationMessageDao.getMessageByMessageType(messageType, userId);
|
|
}
|
|
}
|
|
|
|
|
|
- public Map<Integer, Integer> getByProject(long projectId, long userId) {
|
|
|
|
- Map<Integer, Integer> m = new HashMap<>();
|
|
|
|
- List<NotificationMessage> list = notificationMessageDao.getMessageByUserId(userId);
|
|
|
|
- Map<Integer, List<NotificationMessage>> map = list.stream().collect(Collectors.groupingBy(t -> t.getMessageType()));
|
|
|
|
- for (Integer key : map.keySet()) {
|
|
|
|
- if (key != 1 & key != 3 & key != 9) {
|
|
|
|
- int b = 0;
|
|
|
|
- for (NotificationMessage mss : map.get(key)) {
|
|
|
|
- if (projectId == JSONObject.parseObject(mss.getJson()).getIntValue("projectId")) {
|
|
|
|
- if (!mss.isViewed()) {
|
|
|
|
- b += 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- m.put(key, b);
|
|
|
|
- }
|
|
|
|
- if (key == 3 | key == 9) {
|
|
|
|
- int c = 0;
|
|
|
|
- for (NotificationMessage mss : map.get(key)) {
|
|
|
|
- if (-projectId == JSONObject.parseObject(mss.getJson()).getIntValue("yuiProjectId")) {
|
|
|
|
- if (!mss.isViewed()) {
|
|
|
|
- c += 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- m.put(key, c);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return m;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public Map<Integer, Integer> getByFlowType(long projectId, long userId) {
|
|
|
|
- Map<Integer, Integer> m = new HashMap<>();
|
|
|
|
- List<NotificationMessage> nms = notificationMessageDao.getMessageByUserId(userId);
|
|
|
|
- Map<Integer, List<NotificationMessage>> map = nms.stream().collect(Collectors.groupingBy(t -> t.getMessageType()));
|
|
|
|
- if (map.containsKey(7)) {
|
|
|
|
- List<NotificationMessage> notificationMessages = map.get(7);
|
|
|
|
- if (notificationMessages.size() > 0) {
|
|
|
|
- for (NotificationMessage mss : notificationMessages) {
|
|
|
|
- if (projectId == JSONObject.parseObject(mss.getJson()).getIntValue("projectId")) {
|
|
|
|
- if (!mss.isViewed()) {
|
|
|
|
- int flowType = JSONObject.parseObject(mss.getJson()).getIntValue("flowType");
|
|
|
|
- if (!m.containsKey(flowType)) {
|
|
|
|
- m.put(flowType, 1);
|
|
|
|
- } else {
|
|
|
|
- Integer i = m.get(flowType);
|
|
|
|
- m.put(flowType, i += 1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return m;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public List<NotificationMessage> getByFlowTypes(long projectId, long userId, String flowTypes) {
|
|
|
|
- List<NotificationMessage> list = new ArrayList<>();
|
|
|
|
- List<String> types = Arrays.asList(flowTypes.split(","));
|
|
|
|
- List<NotificationMessage> nms = notificationMessageDao.getMessageByUserId(userId);
|
|
|
|
- Map<Integer, List<NotificationMessage>> map = nms.stream().collect(Collectors.groupingBy(t -> t.getMessageType()));
|
|
|
|
- if (map.containsKey(7)) {
|
|
|
|
- List<NotificationMessage> notificationMessages = map.get(7);
|
|
|
|
- if (notificationMessages.size() > 0) {
|
|
|
|
- for (NotificationMessage mss : notificationMessages) {
|
|
|
|
- if (projectId == JSONObject.parseObject(mss.getJson()).getIntValue("projectId")) {
|
|
|
|
- int flowType = JSONObject.parseObject(mss.getJson()).getIntValue("flowType");
|
|
|
|
- if (types.contains(String.valueOf(flowType))) {
|
|
|
|
- list.add(mss);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (list.size() > 0) {
|
|
|
|
- list.sort((o1, o2) -> o2.getSentTime().compareTo(o1.getSentTime()));
|
|
|
|
- }
|
|
|
|
- return list;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public List<NotificationMessage> getMessageByViewed(long userId, boolean viewed) {
|
|
public List<NotificationMessage> getMessageByViewed(long userId, boolean viewed) {
|
|
return notificationMessageDao.getMessageByViewed(userId, viewed);
|
|
return notificationMessageDao.getMessageByViewed(userId, viewed);
|
|
}
|
|
}
|
|
@@ -161,35 +81,14 @@ public class MessageService {
|
|
insert(message);
|
|
insert(message);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
-
|
|
|
|
- // construction log
|
|
|
|
- JSONObject cl = new JSONObject();
|
|
|
|
-
|
|
|
|
- JSONObject json = JSON.parseObject(message.getJson());
|
|
|
|
-
|
|
|
|
- JSONObject coment = JSON.parseObject(json.getString("coment"));
|
|
|
|
- //cl.setData(coment.getString("content"));
|
|
|
|
- cl.put("data", JSONObject.toJSONString(message));
|
|
|
|
-
|
|
|
|
- JSONObject content = JSON.parseObject(coment.getString("content"));
|
|
|
|
-
|
|
|
|
- if(content.containsKey("projectId")) {
|
|
|
|
- cl.put("projectId", content.getLongValue("projectId"));
|
|
|
|
- }else if(content.containsKey("project_id")) {
|
|
|
|
- cl.put("projectId", content.getLongValue("project_id"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- cl.put("message", message.getMessage());
|
|
|
|
-
|
|
|
|
- apiClient.saveNotice(cl.toJSONString());
|
|
|
|
|
|
|
|
- List<NotificationMessage> list = notificationMessageDao.getList();
|
|
|
|
|
|
+ /*List<NotificationMessage> list = notificationMessageDao.getList();
|
|
for (NotificationMessage s : list) {
|
|
for (NotificationMessage s : list) {
|
|
if (s.isPushed() == false) {
|
|
if (s.isPushed() == false) {
|
|
messagePushService.sendMessage(s);
|
|
messagePushService.sendMessage(s);
|
|
notificationMessageDao.updatePushed(s.getId());
|
|
notificationMessageDao.updatePushed(s.getId());
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -203,57 +102,11 @@ public class MessageService {
|
|
json.getJSONArray("receiptList").forEach(id -> receiptList.add(Long.parseLong(id.toString())));
|
|
json.getJSONArray("receiptList").forEach(id -> receiptList.add(Long.parseLong(id.toString())));
|
|
pushMessage(receiptList, messageGenerator);
|
|
pushMessage(receiptList, messageGenerator);
|
|
|
|
|
|
- // update state
|
|
|
|
- updateYouJiYunFlowState(messageGenerator);
|
|
|
|
-
|
|
|
|
if (FlowMessageGenerator.MESSAGE_FLOW_COMPELETED.equals(messageGenerator.getTemplateName())) {
|
|
if (FlowMessageGenerator.MESSAGE_FLOW_COMPELETED.equals(messageGenerator.getTemplateName())) {
|
|
completeDataService.saveCompleteData(messageGenerator.getContext());
|
|
completeDataService.saveCompleteData(messageGenerator.getContext());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- private void updateYouJiYunFlowState(FlowMessageGenerator messageGenerator) {
|
|
|
|
-
|
|
|
|
- JSONObject context = JSON.parseObject(JSON.toJSONString(messageGenerator.getContext()));
|
|
|
|
-
|
|
|
|
- JSONObject projectFlow = JSON.parseObject(JSON.toJSONString(context.get("projectFlow")));
|
|
|
|
-
|
|
|
|
- JSONObject coment = JSON.parseObject(context.getString("coment"));
|
|
|
|
-
|
|
|
|
- JSONObject content = JSON.parseObject(coment.getString("content"));
|
|
|
|
-
|
|
|
|
- long projectFlowId = content.getLongValue("projectFlowId");
|
|
|
|
-
|
|
|
|
- if(projectFlowId > 0) {
|
|
|
|
-
|
|
|
|
- int state = -1;
|
|
|
|
-
|
|
|
|
- if (projectFlow.getString("statusStr").equals("待提交")) {
|
|
|
|
- state = -1;
|
|
|
|
- }
|
|
|
|
- if (projectFlow.getString("statusStr").equals("审核中")) {
|
|
|
|
- state = -2;
|
|
|
|
- }
|
|
|
|
- if (projectFlow.getString("statusStr").equals("通过")) {
|
|
|
|
- state = -3;
|
|
|
|
- }
|
|
|
|
- if (projectFlow.getString("statusStr").equals("未通过")) {
|
|
|
|
- state = -4;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- String url = JSONObject.parseObject(apiClient.get()).getString("youjiUrl") + "/workspace/common/updateIsSubmitSynergy?projectFlowId="+projectFlowId+"&state="+state;
|
|
|
|
|
|
|
|
- try {
|
|
|
|
- if (url.indexOf("https") == -1) {
|
|
|
|
- HttpsUtils.getPath(url);
|
|
|
|
- }else {
|
|
|
|
- HttpsUtils.getResult(url);
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("access youjiurl fail.", e);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private String getTemplateName(String notifyType) {
|
|
private String getTemplateName(String notifyType) {
|
|
switch (notifyType) {
|
|
switch (notifyType) {
|
|
case EVENT_SUBMITTED:
|
|
case EVENT_SUBMITTED:
|
|
@@ -283,24 +136,6 @@ public class MessageService {
|
|
message.setUserId(Long.parseLong(split[i]));
|
|
message.setUserId(Long.parseLong(split[i]));
|
|
insert(message);
|
|
insert(message);
|
|
}
|
|
}
|
|
-
|
|
|
|
- // bim审核流程
|
|
|
|
- if(message.getMessageType() == 7) {
|
|
|
|
- JSONObject cl = new JSONObject();
|
|
|
|
- cl.put("data", JSONObject.toJSONString(message));
|
|
|
|
- JSONObject json = JSON.parseObject(message.getJson());
|
|
|
|
- cl.put("projectId", (-json.getLongValue("projectId")));
|
|
|
|
- cl.put("message", message.getMessage());
|
|
|
|
- apiClient.saveNotice(cl.toJSONString());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<NotificationMessage> list = notificationMessageDao.getList();
|
|
|
|
- for (NotificationMessage s : list) {
|
|
|
|
- if (s.isPushed() == false) {
|
|
|
|
- messagePushService.sendMessage(s);
|
|
|
|
- notificationMessageDao.updatePushed(s.getId());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|