package Optimize;
|
|
import org.json.JSONArray;
|
import org.json.JSONException;
|
import org.json.JSONObject;
|
|
public class OptimizationState {
|
public String State;
|
public TongDaoState[] TongDaoInfos;
|
|
public OptimizationState(JSONObject obj) throws JSONException{
|
|
this.State=obj.getString("State");
|
if(obj.has("TongDaoInfos")){
|
if(obj.isNull("TongDaoInfos")==false){
|
JSONArray arr=obj.getJSONArray("TongDaoInfos");
|
this.TongDaoInfos=new TongDaoState[arr.length()];
|
for(int i=0;i<arr.length();i++){
|
this.TongDaoInfos[i]=new TongDaoState(arr.getJSONObject(i));
|
}
|
}
|
}
|
}
|
|
public JSONObject toJson() throws JSONException{
|
JSONObject obj=new JSONObject();
|
obj.put("State",this.State);
|
JSONArray arr=new JSONArray();
|
for(int i=0;i<this.TongDaoInfos.length;i++){
|
arr.put(this.TongDaoInfos[i].toJson());
|
}
|
obj.put("TongDaoInfos", arr);
|
return obj;
|
}
|
|
|
|
public class TongDaoState{
|
public int OptCount;
|
public int value;
|
public int max;
|
public int TotalCount;
|
public UseStock[] UseStocks;
|
public boolean NotEnough;
|
|
|
public TongDaoState(JSONObject obj) throws JSONException{
|
this.OptCount=obj.getInt("OptCount");
|
this.value=obj.getInt("value");
|
this.max=obj.getInt("max");
|
this.TotalCount=obj.getInt("TotalCount");
|
this.NotEnough=obj.getBoolean("NotEnough");
|
if(obj.has("UseStocks")){
|
if(obj.isNull("UseStocks")==false){
|
JSONArray a=obj.getJSONArray("UseStocks");
|
UseStocks=new UseStock[a.length()];
|
for(int i=0;i<this.UseStocks.length;i++){
|
this.UseStocks[i]=new UseStock(a.getJSONObject(i));
|
}
|
}
|
}
|
}
|
|
public JSONObject toJson() throws JSONException{
|
JSONObject obj=new JSONObject();
|
obj.put("OptCount",this.OptCount);
|
obj.put("value",this.value);
|
obj.put("max", max);
|
obj.put("TotalCount", this.TotalCount);
|
obj.put("NotEnough", this.NotEnough);
|
JSONArray arr=new JSONArray();
|
if(this.UseStocks!=null){
|
for(int i=0;i<this.UseStocks.length;i++){
|
arr.put(this.UseStocks[i].toJson());
|
}
|
}
|
obj.put("UseStocks",arr);
|
return obj;
|
}
|
}
|
|
|
public class UseStock
|
{
|
public int width;
|
public int height;
|
public int count;
|
public double UseArea;
|
|
public UseStock(JSONObject obj) throws JSONException{
|
this.width=obj.getInt("width");
|
this.height=obj.getInt("height");
|
this.count=obj.getInt("count");
|
this.UseArea=obj.getDouble("UseArea");
|
|
}
|
|
public JSONObject toJson() throws JSONException{
|
JSONObject ret=new JSONObject();
|
ret.put("width", width);
|
ret.put("height", height);
|
ret.put("count",count);
|
ret.put("UseArea", UseArea);
|
return ret;
|
}
|
|
}
|
}
|