|
@@ -16,32 +16,17 @@
|
|
|
*/
|
|
|
package org.springblade.business.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
import org.springblade.business.entity.MessageWarning;
|
|
|
-import org.springblade.business.entity.Task;
|
|
|
-import org.springblade.business.entity.TaskParallel;
|
|
|
import org.springblade.business.mapper.MessageWarningMapper;
|
|
|
import org.springblade.business.service.IMessageWarningService;
|
|
|
-import org.springblade.business.service.ITaskParallelService;
|
|
|
-import org.springblade.business.service.ITaskService;
|
|
|
-import org.springblade.business.socket.WebSocket;
|
|
|
import org.springblade.business.vo.MessageWarningVO;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
-import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 服务实现类
|
|
@@ -52,31 +37,9 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class MessageWarningServiceImpl extends BaseServiceImpl<MessageWarningMapper, MessageWarning> implements IMessageWarningService {
|
|
|
|
|
|
- //@Lazy解决循环注入问题
|
|
|
- @Lazy
|
|
|
- @Autowired
|
|
|
- private ITaskService iTaskService;
|
|
|
-
|
|
|
- @Lazy
|
|
|
- @Autowired
|
|
|
- private WebSocket webSocket;
|
|
|
-
|
|
|
@Override
|
|
|
public void savePushUserMessageWarning(List<MessageWarningVO> vos) {
|
|
|
List<MessageWarning> saveList = JSONArray.parseArray(JSONObject.toJSONString(vos), MessageWarning.class);
|
|
|
-
|
|
|
- //通过WebSocket推送数量条数
|
|
|
- for (MessageWarning messageWarning : saveList) {
|
|
|
- if (ObjectUtil.isNotEmpty(messageWarning.getProjectId()) && ObjectUtil.isNotEmpty(messageWarning.getContractId()) && ObjectUtil.isNotEmpty(messageWarning.getPushUser())) {
|
|
|
- Map<String, String> stringMap = iTaskService.getTaskCount(messageWarning.getProjectId().toString(), messageWarning.getContractId().toString(), messageWarning.getPushUser().toString());
|
|
|
- try {
|
|
|
- webSocket.sendMessageByUserId(messageWarning.getPushUser().toString(), JSON.toJSONString(stringMap));
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
this.saveBatch(saveList);
|
|
|
}
|
|
|
|
|
@@ -84,17 +47,6 @@ public class MessageWarningServiceImpl extends BaseServiceImpl<MessageWarningMap
|
|
|
public void savePushUserMessageWarning(MessageWarningVO vo) {
|
|
|
MessageWarning messageWarning = new MessageWarning();
|
|
|
BeanUtils.copyProperties(vo, messageWarning);
|
|
|
-
|
|
|
- //通过WebSocket推送数量条数
|
|
|
- if (ObjectUtil.isNotEmpty(messageWarning.getProjectId()) && ObjectUtil.isNotEmpty(messageWarning.getContractId()) && ObjectUtil.isNotEmpty(messageWarning.getPushUser())) {
|
|
|
- Map<String, String> stringMap = iTaskService.getTaskCount(messageWarning.getProjectId().toString(), messageWarning.getContractId().toString(), messageWarning.getPushUser().toString());
|
|
|
- try {
|
|
|
- webSocket.sendMessageByUserId(messageWarning.getPushUser().toString(), JSON.toJSONString(stringMap));
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
this.baseMapper.insert(messageWarning);
|
|
|
}
|
|
|
|