I have been working with piecewise functions in sympy and it does not seem to be integrating them correctly with their context.
Piecewise function

Correct Integration

sympy output

from sympy import *
init_printing(use_unicode=False, wrap_line=False)
x = Symbol('x')
f = Function('f')
a1 = 4
a2 = 8
a3 = 12
G = Piecewise((x,And(x<=a1,x>=0)),(4,And(x>a1,x<=a2)),((x-a3)**2/4,And(x>a2,x<=a3)))
diffeq1= Eq(f(x).diff(x),G)
gg1 = dsolve(diffeq1,f(x))
Am I missing something in my input concerning the creation of the piecewise function or in the differential equation solver?
Edit 2/24/2021
I have included an example of what g(x) would look like with the boundary condition of g(0)=0. Sympy used this boundary condition, with its answer describing the function as 4x between 4<x<8, which is almost there, but it doesn't include the context of what occurs at x = 4. What should occur is g(3.999) ~= g(4.0001), but instead sympy is saying g(3.999) ~= 8 and g(4.0001)~= 16.