7. Given the sets
$$
\begin{array}{l}
A=\left\{(x, y) \mid x=m, y=-3 m+2, m \in \mathbf{Z}_{+}\right\}, \\
B=\left\{(x, y) \mid x=n, y=a\left(a^{2}-n+1\right), n \in \mathbf{Z}_{+}\right\} .
\end{array}
$$

Then the number of integers $a$ such that $A \cap B \neq \varnothing$ is $\qquad$.
7. 10 .

Let $(x, y) \in A \cap B$. Then
\[
\begin{array}{l}
x=n, \\
y=-3 n+2=a\left(a^{2}-n+1\right)\left(n \in \mathbf{Z}_{+}\right) .
\end{array}
\]

Thus, $(a-3) n=a^{3}+a-2$.
If $a=3$, then in equation (1),
the left side $=0$,
the right side $=27+3-2>0$, a contradiction.
Therefore, $a \neq 3$.
Hence, $n=\frac{a^{3}+a-2}{a-3}=\frac{(a-1)\left(a^{2}+a+2\right)}{a-3}$ $=a^{2}+3 a+10+\frac{28}{a-3}$.
Since $a \in \mathbf{Z}, n \in \mathbf{Z}_{+}$, it follows that $(a-3) \mid 28$.
Thus, $a-3= \pm 1, \pm 2, \pm 4, \pm 7, \pm 14, \pm 28$.
By $n \in \mathbf{Z}_{+}$, we know $a>3$ or $a<1$.
In summary, there are 10 integers $a$ such that $A \cap B \neq \varnothing$.