编辑代码


def list1 = [["x":3,"name":"李四"],["x":2,"name":"张三"],["x":1,"name":"李六"]]
def list2 = [["x":3,"name":"李四"],["x":4,"name":"王五"]]

def objNameList = list2.name.intersect(list1.name)

def objInsert = []
def objUpdate = []

list2.each{
    if (objNameList.contains(it.name)){
        objUpdate.add(it)
    }else{
        objInsert.add(it)
    }
}
def result = {
    "objInsert" : objInsert,
    "objUpdate" : objUpdate
}