wu
2024-12-31 1edefcae08fe7c8df6a177e5dbbc8ab8f8194187
nglib/src/Optimize/OptimizationInput.java
New file
@@ -0,0 +1,214 @@
package Optimize;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class OptimizationInput {
      public Param Param;
       public Polygon_Info[] Polygons;
       public Stock_Info[] Stocks;
       public String GongCheng;
       public OptimizationInput(){
       }
       public JSONObject toJson() throws JSONException{
          JSONObject obj=new JSONObject();
          obj.put("GongCheng",this.GongCheng);
          obj.put("Param",this.Param.toJson());
          JSONArray arr=new JSONArray();
          for(int i=0;i<this.Polygons.length;i++){
             arr.put(this.Polygons[i].toJson());
          }
          obj.put("Polygons", arr);
           arr=new JSONArray();
          for(int i=0;i<this.Stocks.length;i++){
             arr.put(this.Stocks[i].toJson());
          }
          obj.put("Stocks", arr);
          return obj;
       }
       public OptimizationInput(JSONObject obj) throws JSONException{
          this.Param=new Param(obj.getJSONObject("Param"));
          JSONArray arr=obj.getJSONArray("Polygons");
          this.Polygons=new Polygon_Info[arr.length()];
          for(int i=0;i<arr.length();i++){
            this.Polygons[i]=new Polygon_Info(arr.getJSONObject(i));
          }
          arr=obj.getJSONArray("Stocks");
          this.Stocks=new Stock_Info[arr.length()];
          for(int i=0;i<arr.length();i++){
             this.Stocks[i]=new Stock_Info( arr.getJSONObject(i));
          }
          this.GongCheng=obj.getString("GongCheng");
       }
       public static class Param{
          public boolean AutoMatch=false;
           public boolean RotateAble=false;
           public int MaxRack=0;
           public double BaiBian=12;
           public double ZhengGongCha=0;
           public double FuGongCha=0;
           public int YuanDianWeiZhi=0;
           public int XiuBianMode=0;
           public int TongDaoShu=1;
           public int YouHuaCiShu=9;
           public int MobianMinSize=0;
           public Param(JSONObject obj) throws JSONException{
              this.AutoMatch=obj.getBoolean("AutoMatch");
              this.RotateAble=obj.getBoolean("RotateAble");
              this.MaxRack=obj.getInt("MaxRack");
              this.BaiBian=obj.getDouble("BaiBian");
              this.ZhengGongCha=obj.getDouble("ZhengGongCha");
              this.FuGongCha=obj.getDouble("FuGongCha");
              this.YuanDianWeiZhi=obj.getInt("YuanDianWeiZhi");
              this.XiuBianMode=obj.getInt("XiuBianMode");
              this.TongDaoShu=obj.getInt("TongDaoShu");
              this.YouHuaCiShu=obj.getInt("YouHuaCiShu");
              this.MobianMinSize=obj.getInt("MobianMinSize");
           }
           public Param(){
           }
           public JSONObject toJson() throws JSONException{
              JSONObject ret=new JSONObject();
              ret.put("AutoMatch", this.AutoMatch);
              ret.put("RotateAble", this.RotateAble);
              ret.put("MaxRack", this.MaxRack);
              ret.put("BaiBian", this.BaiBian);
              ret.put("ZhengGongCha", this.ZhengGongCha);
              ret.put("FuGongCha", this.FuGongCha);
              ret.put("YuanDianWeiZhi", this.YuanDianWeiZhi);
              ret.put("XiuBianMode", this.XiuBianMode);
              ret.put("TongDaoShu", this.TongDaoShu);
              ret.put("YouHuaCiShu", this.YouHuaCiShu);
              ret.put("MobianMinSize", this.MobianMinSize);
              return ret;
           }
       }
       public static  class Polygon_Info{
          public double width;
           public double height;
           public double thickness;
           public double LM1;
           public double LM2;
           public double DM1;
           public double DM2;
           public String JiaHao;
           public String CustomName;
           public String orderid;      //架号+/+层
           public String xuhao;        //序号
           public int count;
           public String gongcheng;
           public int rownumber;
           public String liuchengka;
           public Polygon_Info(){
           }
           public Polygon_Info(JSONObject obj) throws JSONException{
              this.width=obj.getDouble("width");
              this.height=obj.getDouble("height");
              this.thickness=obj.getDouble("thickness");
              this.LM1=obj.getDouble("LM1");
              this.LM2=obj.getDouble("LM2");
              this.DM1=obj.getDouble("DM1");
              this.DM2=obj.getDouble("DM2");
              this.JiaHao=obj.getString("JiaHao");
              this.CustomName=obj.getString("CustomName");
              this.orderid=obj.getString("orderid");
              this.xuhao=obj.getString("xuhao");
              this.count=obj.getInt("count");
              this.gongcheng=obj.getString("gongcheng");
              this.rownumber=obj.getInt("rownumber");
              this.liuchengka=obj.getString("liuchengka");
           }
           public JSONObject toJson() throws JSONException{
              JSONObject ret=new JSONObject();
              ret.put("width", this.width);
              ret.put("height", this.height);
              ret.put("thickness", this.thickness);
              ret.put("LM1", this.LM1);
              ret.put("LM2", this.LM2);
              ret.put("DM1", this.DM1);
              ret.put("DM2", this.DM2);
              ret.put("JiaHao", this.JiaHao);
              ret.put("CustomName", this.CustomName);
              ret.put("orderid", this.orderid);
              ret.put("xuhao", this.xuhao);
              ret.put("count", this.count);
              ret.put("gongcheng", this.gongcheng);
              ret.put("rownumber", this.rownumber);
              ret.put("liuchengka", this.liuchengka);
              return ret;
           }
       }
       public static  class Stock_Info{
          public double up;
           public double down;
           public double left;
           public double right;
           public double width;
           public double height;
           public int count;
           public String libposition;
           public String Color;
           public double thickness;
           public String supplyer;
           public String wuliao_number;
           public Stock_Info(JSONObject obj) throws JSONException{
              this.up=obj.getDouble("up");
              this.down=obj.getDouble("down");
              this.left=obj.getDouble("left");
              this.right=obj.getDouble("right");
              this.width=obj.getDouble("width");
              this.height=obj.getDouble("height");
              this.count=obj.getInt("count");
              this.libposition=obj.getString("libposition");
              this.Color=obj.getString("Color");
              this.thickness=obj.getDouble("thickness");
              this.supplyer=obj.getString("supplyer");
              this.wuliao_number=obj.getString("wuliao_number");
           }
           public Stock_Info(){
           }
           public JSONObject toJson() throws JSONException{
              JSONObject ret=new JSONObject();
              ret.put("up", this.up);
              ret.put("down", this.down);
              ret.put("left", this.left);
              ret.put("right", this.right);
              ret.put("width", this.width);
              ret.put("height", this.height);
              ret.put("count", this.count);
              ret.put("libposition", this.libposition);
              ret.put("count", this.count);
              ret.put("thickness", this.thickness);
              ret.put("supplyer", this.supplyer);
              ret.put("wuliao_number", this.wuliao_number);
              return ret;
           }
       }
}