廖井涛
2024-03-04 eae17d27ec56a6b7887f5597335e38ca40273ef4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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;
          }
         
      }
}