Compass pipeline export to Java not producing same results

I tried this in a similar Java and Spring setup as yours:

Input collection documents:

{
        "_id" : "-1693282609",
        "comments" : "mongoupload",
        "date" : "2019-11-01",
        "site" : "T",
        "country" : "",
        "pdg" : "PD",
        "type" : "type1",
        "resources" : 1
}
{
        "_id" : "-1694086966",
        "comments" : "mongoupload",
        "date" : "2019-05-01",
        "site" : "T",
        "country" : "",
        "pdg" : "PD",
        "type" : "type1",
        "resources" : 2
}

Spring Data MongoDB code (same Java code from your posting):

	MongoCollection<Document> coll = mongoTemplate.getCollection("sample");

	List<Bson> pipeline = Arrays.asList(
            match(and(eq("pdg", "PD"), eq("type", "type1"),
            and(gte("date", "2019-01-01"), lte("date", "2019-12-01")))),
            sort(orderBy(ascending("pdg"), ascending("date"))),
            group(eq("site", "$site"),
                    push("wf", and(eq("site", "$site"), eq("date", "$date"), eq("resources", "$resources"))),
                    sum("tresources", "$resources")),
            match(gt("tresources", 0L)));
	
	List<Document> result = coll.aggregate(pipeline).into(new ArrayList<Document>());
	result.forEach(doc -> System.out.println(doc.toJson()));;

I get the same result from the aggregation run from the mongo shell query and the Spring Java code.

{
   "_id":{
      "site":"T"
   },
   "wf":[
      {
         "site":"T",
         "date":"2019-05-01",
         "resources":2.0
      },
      {
         "site":"T",
         "date":"2019-11-01",
         "resources":1.0
      }
   ],
   "tresources":3.0
}

Let me know if you are getting the same results, else what is it you are expecting.

[ EDIT ADD ]: I have a correction in this post.

The above output is from the MongoDB Java Driver code , not from the Spring Java code. The output from Spring Java code is (as you had posted, different):

{
   "_id":{
      "site":"T"
   },
   "wf":[
      true,
      true
   ],
   "tresources":3.0
}