|
|
@ -11,7 +11,9 @@ import com.ccsens.tall.bean.po.SysOperation; |
|
|
|
import com.ccsens.tall.bean.po.SysOperationMessage; |
|
|
|
import com.ccsens.tall.bean.vo.MessageVo; |
|
|
|
import com.ccsens.tall.bean.vo.ProjectMessageVo; |
|
|
|
import com.ccsens.tall.bean.vo.UserVo; |
|
|
|
import com.ccsens.tall.persist.dao.ProMemberDao; |
|
|
|
import com.ccsens.tall.persist.dao.SysAuthDao; |
|
|
|
import com.ccsens.tall.persist.dao.SysMessageSendDao; |
|
|
|
import com.ccsens.tall.persist.dao.SysOperationDao; |
|
|
|
import com.ccsens.tall.persist.mapper.SysOperationMessageMapper; |
|
|
@ -56,6 +58,8 @@ public class ProjectMessageService implements IProjectMessageService { |
|
|
|
private SysOperationMessageMapper sysOperationMessageMapper; |
|
|
|
@Resource |
|
|
|
private SysMessageSendDao sysMessageSendDao; |
|
|
|
@Resource |
|
|
|
private SysAuthDao sysAuthDao; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private AmqpTemplate rabbitTemplate; |
|
|
@ -75,10 +79,16 @@ public class ProjectMessageService implements IProjectMessageService { |
|
|
|
log.info("模板:{}", newMessages); |
|
|
|
// 查询项目内所有成员ID
|
|
|
|
List<Long> userIds = proMemberDao.queryUserIdsByProjectId(inform.getProjectId()); |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(userIds)) { |
|
|
|
log.info("项目{}下没有用户,未发送消息", inform.getProjectId()); |
|
|
|
return; |
|
|
|
} |
|
|
|
//保存消息记录
|
|
|
|
Long operationId = initMessage(operateType, inform, newMessages, userIds); |
|
|
|
|
|
|
|
//mq-->ws
|
|
|
|
// 操作发送
|
|
|
|
initMessageSend(userIds, operationId, WebConstant.Message.SEND_WS); |
|
|
|
InMessage inMessage = new InMessage(); |
|
|
|
inMessage.setTos(InMessage.transTos(userIds)); |
|
|
|
inMessage.setData(JSONObject.toJSONString(newMessages)); |
|
|
@ -86,6 +96,26 @@ public class ProjectMessageService implements IProjectMessageService { |
|
|
|
log.info("mq通知消息:{}", inMessage); |
|
|
|
//更新ws消息发送成功
|
|
|
|
updateStatus(operationId, WebConstant.Message.SEND_WS); |
|
|
|
|
|
|
|
//查询关注公众号的用户
|
|
|
|
List<UserVo.Oauth2WX> oauths = sysAuthDao.queryOauth2WX(userIds); |
|
|
|
if (CollectionUtil.isEmpty(oauths)) { |
|
|
|
log.info("项目{}下没有关注公众号的用户,未发送公众号关注", inform.getProjectId()); |
|
|
|
return; |
|
|
|
} |
|
|
|
List<String> openids = new ArrayList<>(); |
|
|
|
List<Long> oauthUserIds = new ArrayList<>(); |
|
|
|
oauths.forEach(oauth2WX -> { |
|
|
|
openids.add(oauth2WX.getOpenid()); |
|
|
|
oauthUserIds.add(oauth2WX.getUserId()); |
|
|
|
}); |
|
|
|
|
|
|
|
initMessageSend(oauthUserIds, operationId, WebConstant.Message.SEND_WX_OFFICIAL); |
|
|
|
//TODO 公众号通知消息
|
|
|
|
|
|
|
|
//更新ws消息发送成功
|
|
|
|
updateStatus(operationId, WebConstant.Message.SEND_WX_OFFICIAL); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -135,10 +165,7 @@ public class ProjectMessageService implements IProjectMessageService { |
|
|
|
sysOperationMessageMapper.insertSelective(operationMessage); |
|
|
|
} |
|
|
|
} |
|
|
|
// 操作发送
|
|
|
|
if (CollectionUtil.isNotEmpty(userIds)) { |
|
|
|
initMessageSend(userIds, operation.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
return operation.getId(); |
|
|
|
} |
|
|
|
|
|
|
@ -147,7 +174,7 @@ public class ProjectMessageService implements IProjectMessageService { |
|
|
|
* @param userIds |
|
|
|
* @param operationId |
|
|
|
*/ |
|
|
|
private void initMessageSend(List<Long> userIds, Long operationId) { |
|
|
|
private void initMessageSend(List<Long> userIds, Long operationId, byte sendType) { |
|
|
|
TransactionStatus transactionStatus = TransactionUtil.getTransactionStatus(transactionManager); |
|
|
|
int length = userIds.size() -1; |
|
|
|
try { |
|
|
@ -158,7 +185,7 @@ public class ProjectMessageService implements IProjectMessageService { |
|
|
|
send.setId(snowflake.nextId()); |
|
|
|
send.setOperationId(operationId); |
|
|
|
send.setReceiverId(userId); |
|
|
|
send.setSendType(WebConstant.Message.SEND_WS); |
|
|
|
send.setSendType(sendType); |
|
|
|
sysMessageSendDao.insertSelective(send); |
|
|
|
log.info("消息发送:{}", send); |
|
|
|
// 判断是否需要提交事务,并开启新事务
|
|
|
|