|
|
@ -5,34 +5,56 @@ import com.hchbox.exception.TaoMiCommException;
|
|
|
|
import com.hchbox.module.dao.AutoWaitForMessageRepository;
|
|
|
|
import com.hchbox.module.dao.AutoWaitForMessageRepository;
|
|
|
|
import com.hchbox.module.entity.AutoWaitMessage;
|
|
|
|
import com.hchbox.module.entity.AutoWaitMessage;
|
|
|
|
import com.hchbox.module.service.DelayRemindService;
|
|
|
|
import com.hchbox.module.service.DelayRemindService;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @author wujingtao
|
|
|
|
* @author wujingtao
|
|
|
|
* @date 2021/09/29
|
|
|
|
* @date 2021/09/29
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
public class DelayRemindServiceImpl implements DelayRemindService {
|
|
|
|
public class DelayRemindServiceImpl implements DelayRemindService {
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private AutoWaitForMessageRepository autoWaitForMessageRepository;
|
|
|
|
private AutoWaitForMessageRepository autoWaitForMessageRepository;
|
|
|
|
|
|
|
|
@Value("${timing.task.maxNum}")
|
|
|
|
|
|
|
|
private int maxNum;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 前段定时来查询消息,每次最多查询2000条,false表示还未查完,true表示已经查完了
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param sellerNick
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<AutoWaitMessage> selectDelayRemind(String sellerNick) {
|
|
|
|
public Map<String, Object> selectDelayRemind(String sellerNick) {
|
|
|
|
|
|
|
|
HashMap<String, Object> map = new HashMap<>(16);
|
|
|
|
List<AutoWaitMessage> list;
|
|
|
|
List<AutoWaitMessage> list;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
list = autoWaitForMessageRepository.findAllBySender(sellerNick);
|
|
|
|
list = autoWaitForMessageRepository.findAllBySender(sellerNick, maxNum);
|
|
|
|
|
|
|
|
map.put("data", list);
|
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
for (AutoWaitMessage info : list) {
|
|
|
|
if (list.size() >= maxNum) {
|
|
|
|
autoWaitForMessageRepository.deleteById(info.getTaskId());
|
|
|
|
map.put("isOver", false);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
map.put("isOver", true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
autoWaitForMessageRepository.deleteInBatch(list);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
map.put("isOver", true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.error("操作定时任务消息失败.{}", e.getMessage());
|
|
|
|
throw new TaoMiCommException("请求发送消息失败");
|
|
|
|
throw new TaoMiCommException("请求发送消息失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
log.info("查询出來的消息条数:{}", list.size());
|
|
|
|
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|