2. Let $n$ be a positive integer. If
$$
n \equiv r(\bmod 2)(r \in\{0,1\}) \text {, }
$$

find the number of integer solutions to the system of equations
$$
\left\{\begin{array}{l}
x+y+z=r, \\
|x|+|y|+|z|=n
\end{array}\right.
$$
2. Classify and discuss based on the parity of $n$.

When $n$ is a positive even number, $r=0$. Then the problem is transformed into finding the number of integer solutions for
$$
\left\{\begin{array}{l}
x+y+z=0, \\
|x|+|y|+|z|=n
\end{array}\right.
$$

Lemma (1) At least one of $x, y, z$ has an absolute value of $\frac{n}{2}$;
(2) The absolute values of $x, y, z$ are all no greater than $\frac{n}{2}$.
Proof: Clearly, one of $x, y, z$ must be greater than 0. Otherwise, it contradicts the first equation of the system (1). Without loss of generality, assume $x>0$.
In fact, if $x>\frac{n}{2}$, then by
$$
x=-(y+z),|y|+|z| \geqslant|y+z|>\frac{n}{2},
$$

it contradicts the second equation of the system (1).
If $0<x \leq \frac{n}{2}$, then $x=\frac{n}{2}, y+z=-\frac{n}{2}$.
By the lemma,
$$
\begin{array}{l}
\left(\frac{n}{2},-\frac{n}{2}, 0\right),\left(\frac{n}{2},-\frac{n}{2}+1,-1\right), \\
\left(\frac{n}{2},-\frac{n}{2}+2,-2\right), \cdots,\left(\frac{n}{2}, 0,-\frac{n}{2}\right)
\end{array}
$$

are all solutions to the system, totaling $\frac{n}{2}+1$ solutions.
In the above solutions, replacing $x$ with $y$ and $z$ respectively leads to the same discussion.
Thus, the system (1) has a total of $3\left(\frac{n}{2}+1\right)$ solutions.
If two of $x, y, z$ are positive, without loss of generality, assume $x, y>0$, then $x+y=\frac{n}{2}, z=-\frac{n}{2}$.
By the lemma,
$$
\begin{array}{l}
\left(1, \frac{n}{2}-1,-\frac{n}{2}\right),\left(2, \frac{n}{2}-2,-\frac{n}{2}\right), \\
\left(3, \frac{n}{2}-3,-\frac{n}{2}\right), \cdots,\left(\frac{n}{2}-1,1,-\frac{n}{2}\right)
\end{array}
$$

are all solutions to the system (1), totaling $\frac{n}{2}-1$ solutions.
In the above solutions, replacing $x, y$ with $z$ respectively leads to the same discussion.
Thus, the system has a total of $3\left(\frac{n}{2}-1\right)$ solutions. Therefore, the total number of solutions to the system (1) is
$$
3\left(\frac{n}{2}+1\right)+3\left(\frac{n}{2}-1\right)=3 n \text {. }
$$

When $n$ is a positive odd number, $r=1$. Then the problem is transformed into finding the number of integer solutions for
$$
\left\{\begin{array}{l}
x+y+z=1, \\
|x|+|y|+|z|=n
\end{array}\right.
$$

Similar to the discussion when $n$ is even, replace $\frac{n}{2}$ with $\frac{n+1}{2}$ to get the corresponding lemma, thus, the total number of solutions to the system (2) is
$$
3\left(\frac{n-1}{2}+1\right)+3 \times \frac{n-1}{2}=3 n \text {. }
$$