25 lines
944 B
Groovy
25 lines
944 B
Groovy
|
|
import com.alibaba.fastjson.JSONArray
|
||
|
|
import com.alibaba.fastjson.JSONObject
|
||
|
|
|
||
|
|
def getPoints(JSONArray points,Map<String, List<Object>> materialCollent,Double inupperlimitQty){
|
||
|
|
|
||
|
|
def list = new ArrayList<>();
|
||
|
|
JSONObject point = points.getJSONObject(0)
|
||
|
|
String materialId = point.getString("material_id");
|
||
|
|
List<Object> collect = materialCollent.get(materialId);
|
||
|
|
collect.sort(Comparator.comparingDouble({ item -> ((JSONObject) item).getDouble("vehicle_qty") }).reversed());
|
||
|
|
Double qty = 0.0;
|
||
|
|
for (Object o1 : collect) {
|
||
|
|
if (qty>inupperlimitQty){
|
||
|
|
return list;
|
||
|
|
}
|
||
|
|
def item = new JSONObject()
|
||
|
|
item.put("point_code",((JSONObject) o1).getString("point_code"))
|
||
|
|
item.put("qty",((JSONObject) o1).getDouble("vehicle_qty"));
|
||
|
|
item.put("material_id",materialId);
|
||
|
|
list.add(item);
|
||
|
|
qty = qty+((JSONObject) o1).getDouble("vehicle_qty");
|
||
|
|
}
|
||
|
|
return list;
|
||
|
|
}
|