rev: 成品入库分配修改
This commit is contained in:
56
mes/hd/nladmin-system/src/test/java/Test3.java
Normal file
56
mes/hd/nladmin-system/src/test/java/Test3.java
Normal file
@@ -0,0 +1,56 @@
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Test3 {
|
||||
public static void main(String[] args) {
|
||||
JSONArray array = new JSONArray();
|
||||
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("name", "小三");
|
||||
jsonObject1.put("age", "12");
|
||||
array.add(jsonObject1);
|
||||
|
||||
JSONObject jsonObject2 = new JSONObject();
|
||||
jsonObject2.put("name", "小二");
|
||||
jsonObject2.put("age", "17");
|
||||
array.add(jsonObject2);
|
||||
|
||||
JSONObject jsonObject3 = new JSONObject();
|
||||
jsonObject3.put("name", "小二");
|
||||
jsonObject3.put("age", "17");
|
||||
array.add(jsonObject3);
|
||||
|
||||
Set<JSONObject> name = array.stream().map(row -> ((JSONObject) row)).collect(Collectors.toSet());
|
||||
HashMap<String, JSONObject> name1 = array.stream().collect(HashMap::new, (k, v) -> k.put(((JSONObject) v).getString("name"), (JSONObject) v), HashMap::putAll);
|
||||
HashSet<JSONObject> collect = array.stream().collect(HashSet::new, (k, v) -> k.add((JSONObject) v), HashSet::addAll);
|
||||
collect.stream().forEach(json -> a(json.getString("name")));
|
||||
|
||||
List<Map> maps = new ArrayList<>();
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("storagevehicle_code","1");
|
||||
map.put("storagevehicle_name","sadfs");
|
||||
maps.add(map);
|
||||
HashMap<String, String> map2 = new HashMap<>();
|
||||
map2.put("storagevehicle_code","2");
|
||||
map2.put("storagevehicle_name","sdfd");
|
||||
maps.add(map2);
|
||||
|
||||
boolean age = array.stream().filter(row -> ((JSONObject) row).getString("age").equals("18")).findAny().isPresent();
|
||||
System.out.println(age);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void a(String name) {
|
||||
}
|
||||
|
||||
public static void b(String name) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user