From d640eebf6a94b2feb0e14f11be487c0a7f3145ca Mon Sep 17 00:00:00 2001 From: fyf Date: Mon, 5 Jun 2023 14:48:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=88=86=E6=94=AF=E7=AC=AC=E4=BA=8C?= =?UTF-8?q?=E6=AC=A1=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/bpa/MainActivity.java | 136 +++++++++---- .../java/com/example/bpa/Model/SuOrderA.java | 5 +- .../java/com/example/bpa/config/DataBus.java | 63 +++++- .../main/java/com/example/bpa/db/QueryDB.java | 22 +++ .../com/example/bpa/db/mode/BPA_GOODS.java | 2 + .../com/example/bpa/db/mode/BPA_SUBORDER.java | 4 + .../example/bpa/service/BusinessServer.java | 10 +- .../bpa/view/adapter/maingoods_adapter.java | 38 ++-- .../bpa/view/adapter/order_adapter.java | 113 ++++++++--- .../bpa/view/adapter/pflc_adapter.java | 187 ++++++++++++++++++ .../example/bpa/view/mode/ResGoodsRecipe.java | 4 + app/src/main/res/layout/activity_main.xml | 31 +-- .../res/layout/item/layout/order_item.xml | 158 +++++++-------- .../main/res/layout/item/layout/pllc_item.xml | 32 +++ app/src/main/res/mipmap-xhdpi/zzlb.png | Bin 0 -> 6928 bytes 15 files changed, 613 insertions(+), 192 deletions(-) create mode 100644 app/src/main/java/com/example/bpa/view/adapter/pflc_adapter.java create mode 100644 app/src/main/res/layout/item/layout/pllc_item.xml create mode 100644 app/src/main/res/mipmap-xhdpi/zzlb.png diff --git a/app/src/main/java/com/example/bpa/MainActivity.java b/app/src/main/java/com/example/bpa/MainActivity.java index 4f092a8..2da20ae 100644 --- a/app/src/main/java/com/example/bpa/MainActivity.java +++ b/app/src/main/java/com/example/bpa/MainActivity.java @@ -23,9 +23,14 @@ import androidx.recyclerview.widget.RecyclerView; import com.example.bpa.Model.OrderA; import com.example.bpa.Model.ReceiveOrder; +import com.example.bpa.Model.SuOrderA; +import com.example.bpa.app.Main; import com.example.bpa.config.ConfigName; import com.example.bpa.config.DataBus; import com.example.bpa.config.MessageName; +import com.example.bpa.db.QueryDB; +import com.example.bpa.db.mode.BPA_ORDER; +import com.example.bpa.db.mode.BPA_SUBORDER; import com.example.bpa.helper.Json; import com.example.bpa.helper.MQTT; import com.example.bpa.helper.ModbusTcpHelper; @@ -44,6 +49,9 @@ import com.example.bpa.view.fragment.HomeFragment; import com.example.bpa.view.fragment.SsjkFragment; import com.example.bpa.view.fragment.SystemCapabilitiesFragment; import com.example.bpa.view.fragment.SystemSetFragment; +import com.example.bpa.view.mode.MakeStatus; +import com.example.bpa.view.mode.ResGoodsMake; +import com.example.bpa.view.mode.ResGoodsRecipe; import java.util.ArrayList; import java.util.List; @@ -175,7 +183,8 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen ShowFragment(systemSetFragment, "系统设置"); break; case R.id.SystemHelp://系统帮助按钮 - ShowFragment(heplerFragment, "系统帮助"); + Main.getInstance().GetOrder(""); + //ShowFragment(heplerFragment, "系统帮助"); break; case R.id.HomeMain://主页 ShowFragment(homeFragment, "系统主页"); @@ -237,50 +246,103 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen ab.show(); } + AlertDialog alg = null; + /** * 显示订单窗口 + * * @param order */ - public void showOrderDialog(OrderA order) - { - DataBus.getInstance().OrderSM=order; - final AlertDialog alg = new AlertDialog.Builder(MainActivity.this).create(); - alg.show(); - Window win = alg.getWindow(); - win.setContentView(R.layout.order_dialog); - - WindowManager m = getWindowManager(); - Display d = m.getDefaultDisplay(); //为获取屏幕宽、高 - - android.view.WindowManager.LayoutParams p = win.getAttributes(); //获取对话框当前的参数值 - p.height = (int) (d.getHeight() * 1); //高度设置为屏幕的0.3 - p.width = (int) (d.getWidth() * 1); //宽度设置为屏幕的0.5 - win.setAttributes(p); //设置生效 - - - - - - ImageView gongneng_fanhui= win.findViewById(R.id.gongneng_fanhui); - TextView gongneng_title= win.findViewById(R.id.gongneng_title); - RecyclerView Order=win.findViewById(R.id.Order); - gongneng_title.setText("扫码订单详情"); - - - Order.setLayoutManager(new WrapContentLinearLayoutManager(win.getContext(), LinearLayoutManager.HORIZONTAL,false)); - order_adapter adapter = new order_adapter(win.getContext()); - Order.setAdapter(adapter); - + public void showOrderDialog(OrderA order) { + try { + if (order.orderDetail == null || order.orderDetail.size() <= 0) { + T.show(MainActivity.this, "子订单不能为空!"); + return; + } - gongneng_fanhui.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - alg.dismiss(); + if (!QueryDB.GetOrderIs(order.id)) { + BPA_ORDER order1 = new BPA_ORDER(); + order1.thirdPartyID = "扫码下单"; + order1.status = 0; + order1.deviceID = ConfigName.getInstance().DeviceId; + order1.userID = ConfigName.getInstance().user.userID; + order1.id = order.id; + QueryDB.AddOrder(order1); + for (SuOrderA item : order.orderDetail)//新增子订单 + { + BPA_SUBORDER suborder = new BPA_SUBORDER(); + suborder.deviceID = ConfigName.getInstance().DeviceId; + suborder.userID = ConfigName.getInstance().user.userID; + suborder.orderID = item.orderInfo_Id; + suborder.goodsID = "2f064965-8d63-4b00-9d14-c8d118791898";//item.goods_Id; + suborder.number = 1; + suborder.status = 0; + suborder.goodImg = item.goodImg; + suborder.originalMoney = item.originalMoney; + suborder.realMoney = item.realMoney; + QueryDB.AddSubOrder(suborder); + } } - }); - //初始化数据 + DataBus.getInstance().OrderSM = order; + ArrayList sub = QueryDB.GetSubOrderList(order.id); + DataBus.getInstance().GoodsSMMake.clear(); + for (BPA_SUBORDER k : sub) { + ResGoodsMake make = new ResGoodsMake(); + make.recipes = QueryDB.GetGoodsSrecipeList(k.goodsID); + make.good = QueryDB.GetGoodsId(k.goodsID); + make.subOrder = k; + + make.makeMs = ""; + make.makeProcess = 0; + if (k.status == 0) { + make.makeStatus = MakeStatus.等待制作; + } else if (k.status == 1) { + make.makeStatus = MakeStatus.制作中; + } else { + make.makeStatus = MakeStatus.制作完成; + make.makeMs = ""; + make.makeProcess = 100; + for (ResGoodsRecipe recipe : make.recipes) { + recipe.makeProcess = 100; + } + } + DataBus.getInstance().GoodsSMMake.add(make); + } + if (alg == null) { + alg = new AlertDialog.Builder(MainActivity.this).create(); + } + if (!alg.isShowing()) + alg.show(); + Window win = alg.getWindow(); + win.setContentView(R.layout.order_dialog); + + WindowManager m = getWindowManager(); + Display d = m.getDefaultDisplay(); //为获取屏幕宽、高 + + android.view.WindowManager.LayoutParams p = win.getAttributes(); //获取对话框当前的参数值 + p.height = (int) (d.getHeight() * 1); //高度设置为屏幕的0.3 + p.width = (int) (d.getWidth() * 1); //宽度设置为屏幕的0.5 + win.setAttributes(p); //设置生效 + + ImageView gongneng_fanhui = win.findViewById(R.id.gongneng_fanhui); + TextView gongneng_title = win.findViewById(R.id.gongneng_title); + RecyclerView Order = win.findViewById(R.id.Order); + gongneng_title.setText("扫码订单详情"); + + Order.setLayoutManager(new WrapContentLinearLayoutManager(win.getContext(), LinearLayoutManager.HORIZONTAL, false)); + DataBus.getInstance().orderadapter = new order_adapter(win.getContext()); + Order.setAdapter(DataBus.getInstance().orderadapter); + gongneng_fanhui.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + alg.dismiss(); + } + }); + //初始化数据 + } catch (Exception ex) { + } } //endregion diff --git a/app/src/main/java/com/example/bpa/Model/SuOrderA.java b/app/src/main/java/com/example/bpa/Model/SuOrderA.java index 5076b28..6c5583e 100644 --- a/app/src/main/java/com/example/bpa/Model/SuOrderA.java +++ b/app/src/main/java/com/example/bpa/Model/SuOrderA.java @@ -1,5 +1,9 @@ package com.example.bpa.Model; +import com.example.bpa.view.mode.ResGoodsRecipe; + +import java.util.ArrayList; + public class SuOrderA { public String id;//di public String beginCookTime;//开始制作时间 @@ -18,5 +22,4 @@ public class SuOrderA { public int isVaild;// public String consumeUnit;//单位 public String remark;//备注 - } diff --git a/app/src/main/java/com/example/bpa/config/DataBus.java b/app/src/main/java/com/example/bpa/config/DataBus.java index ec146d3..0ca78be 100644 --- a/app/src/main/java/com/example/bpa/config/DataBus.java +++ b/app/src/main/java/com/example/bpa/config/DataBus.java @@ -13,6 +13,7 @@ import com.example.bpa.db.mode.BPA_GOODS; import com.example.bpa.db.mode.BPA_LOG; import com.example.bpa.db.mode.BPA_SILOS; import com.example.bpa.view.adapter.makegood_adapter; +import com.example.bpa.view.adapter.order_adapter; import com.example.bpa.view.mode.MakeStatus; import com.example.bpa.view.mode.ResGoodsMake; import com.example.bpa.view.mode.ResGoodsRecipe; @@ -59,6 +60,14 @@ public class DataBus { //endregion //region 数据中心 + /** + * 商品扫码等待制作列表 + */ + public List GoodsSMMake = new ArrayList(); + /** + * 扫码商品订单制作 + */ + public order_adapter orderadapter; /** * 商品制作列表 */ @@ -130,6 +139,18 @@ public class DataBus { make.makeProcess=0; GoodsMake.add(make); goodmakeadapter.refresh(); + + for (ResGoodsMake item:GoodsSMMake) + { + if(item.subOrder.id.equals(suborder.id)) + { + item.makeStatus=MakeStatus.等待制作; + item.makeMs=""; + item.makeProcess=0; + orderadapter.refresh(); + } + } + }catch(Exception e){ } } @@ -140,7 +161,7 @@ public class DataBus { * @param makeMs * @param count */ - public void UpdateGoodsMake(String suborderID,String makeMs,int count) + public void UpdateGoodsMake(String suborderID,String makeMs,int count,int key,Boolean bz) { try { @@ -154,10 +175,38 @@ public class DataBus { QueryDB.UpdateSubOrder(GoodsMake.get(m).subOrder); } + // + for (ResGoodsMake item:GoodsSMMake) + { + if(item.subOrder.id.equals(GoodsMake.get(m).subOrder.id)) + { + item.makeStatus= MakeStatus.制作中; + item.makeMs=makeMs; + item.makeProcess=(count/ GoodsMake.get(m).recipes.size())*100; + + for (ResGoodsRecipe recipe: item.recipes) + { + if(recipe.sort==key) + { + if(bz==false) + { + recipe.makeProcess=20; + }else + { + recipe.makeProcess=100; + } + } + } + orderadapter.refresh(); + + } + } + GoodsMake.get(m).makeStatus= MakeStatus.制作中; GoodsMake.get(m).makeMs=makeMs; GoodsMake.get(m).makeProcess=(count/ GoodsMake.get(m).recipes.size())*100; goodmakeadapter.refresh(); + return; } } @@ -183,8 +232,20 @@ public class DataBus { QueryDB.UpdateSubOrder(item.subOrder); good=item; } + } + for (ResGoodsMake item:GoodsSMMake) + { + if(item.subOrder.id.equals(suborderID)) + { + item.makeStatus=MakeStatus.制作完成; + item.makeMs=""; + item.makeProcess=100; + item.subOrder.status=2; + } + orderadapter.refresh(); } + if(good!=null) { //GoodsMakeOver.add(good); diff --git a/app/src/main/java/com/example/bpa/db/QueryDB.java b/app/src/main/java/com/example/bpa/db/QueryDB.java index b3845b7..85fe03e 100644 --- a/app/src/main/java/com/example/bpa/db/QueryDB.java +++ b/app/src/main/java/com/example/bpa/db/QueryDB.java @@ -820,6 +820,24 @@ public class QueryDB { } return data; } + + /** + * 判断订单是否存在在 + * @param id + * @return + */ + public static boolean GetOrderIs(String id) { + boolean isSucess = false; + String orderby = Desc_Time_Up;//出料顺序 + String where = "isDelete=? and id=?"; + String[] args = new String[]{"0", id}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_ORDER.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_ORDER) k); + } + return data.size() > 0; + } //endregion //region BPA_SUBORDER 订单子表 @@ -1861,6 +1879,7 @@ public class QueryDB { ((BPA_GOODS) data).name = cursor.getString((int) cursor.getColumnIndex("name")); ((BPA_GOODS) data).sort = cursor.getInt((int) cursor.getColumnIndex("sort")); ((BPA_GOODS) data).status = cursor.getInt((int) cursor.getColumnIndex("status")); + ((BPA_GOODS) data).url = cursor.getString((int) cursor.getColumnIndex("url")); break; case "BPA_GOODSRECIPE": data = new BPA_GOODSRECIPE(); @@ -1884,6 +1903,9 @@ public class QueryDB { ((BPA_SUBORDER) data).goodsID = cursor.getString((int) cursor.getColumnIndex("goodsID")); ((BPA_SUBORDER) data).number = cursor.getInt((int) cursor.getColumnIndex("number")); ((BPA_SUBORDER) data).status = cursor.getInt((int) cursor.getColumnIndex("status")); + ((BPA_SUBORDER) data).goodImg = cursor.getString((int) cursor.getColumnIndex("goodImg")); + ((BPA_SUBORDER) data).originalMoney = cursor.getDouble((int) cursor.getColumnIndex("originalMoney")); + ((BPA_SUBORDER) data).realMoney = cursor.getDouble((int) cursor.getColumnIndex("realMoney")); break; case "BPA_ALERTLOG": data = new BPA_ALERTLOG(); diff --git a/app/src/main/java/com/example/bpa/db/mode/BPA_GOODS.java b/app/src/main/java/com/example/bpa/db/mode/BPA_GOODS.java index 2f4988b..3e86f37 100644 --- a/app/src/main/java/com/example/bpa/db/mode/BPA_GOODS.java +++ b/app/src/main/java/com/example/bpa/db/mode/BPA_GOODS.java @@ -7,6 +7,8 @@ package com.example.bpa.db.mode; public class BPA_GOODS extends ModeBase { //商品名称 public String name; + //商品Url + public String url; //排序 public int sort; //状态:0 禁用 1 启用 diff --git a/app/src/main/java/com/example/bpa/db/mode/BPA_SUBORDER.java b/app/src/main/java/com/example/bpa/db/mode/BPA_SUBORDER.java index 7766e51..3747554 100644 --- a/app/src/main/java/com/example/bpa/db/mode/BPA_SUBORDER.java +++ b/app/src/main/java/com/example/bpa/db/mode/BPA_SUBORDER.java @@ -13,4 +13,8 @@ public class BPA_SUBORDER extends ModeBase{ public int number; //状态:0 未开始 1 制作中 2 已制作 3 已超时 public int status; + //商品图片 + public String goodImg; + public double originalMoney;//原价 + public double realMoney;//实际金额 } diff --git a/app/src/main/java/com/example/bpa/service/BusinessServer.java b/app/src/main/java/com/example/bpa/service/BusinessServer.java index bd1336c..2705675 100644 --- a/app/src/main/java/com/example/bpa/service/BusinessServer.java +++ b/app/src/main/java/com/example/bpa/service/BusinessServer.java @@ -40,7 +40,7 @@ public class BusinessServer { /** * 商品制作队列 */ - ConcurrentLinkedQueue Commoditys = new ConcurrentLinkedQueue(); + public ConcurrentLinkedQueue Commoditys = new ConcurrentLinkedQueue(); /** * 增加一个子订单 @@ -101,7 +101,7 @@ public class BusinessServer { for (ResGoodsRecipe item : goodsRecipes) { RecipesNames += item.materialName + ","; } - DataBus.getInstance().UpdateGoodsMake(suborder.id, "步骤【" + key + "】准备下发物料:" + RecipesNames, count); + DataBus.getInstance().UpdateGoodsMake(suborder.id, "步骤【" + key + "】准备下发物料:" + RecipesNames, count,key,false); ArrayList liaochang = new ArrayList(); for (int m = 0; m < goodsRecipes.size(); m++) { ResGoodsRecipe recipe = goodsRecipes.get(m); @@ -183,7 +183,7 @@ public class BusinessServer { } //更新缓存商品制作列表状态 count += goodsRecipes.size(); - DataBus.getInstance().UpdateGoodsMake(suborder.id, "步骤【" + key + "】:" + RecipesNames + "-配料完成!", count); + DataBus.getInstance().UpdateGoodsMake(suborder.id, "步骤【" + key + "】:" + RecipesNames + "-配料完成!", count,key,true); MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + good.name + "]步骤【" + key + "】下发" + RecipesNames + "执行完成!"); } //endregion @@ -248,7 +248,7 @@ public class BusinessServer { for (ResGoodsRecipe item : goodsRecipes) { RecipesNames += item.materialName + ","; } - DataBus.getInstance().UpdateGoodsMake(suborder.id, "步骤【" + key + "】准备下发物料:" + RecipesNames, count); + DataBus.getInstance().UpdateGoodsMake(suborder.id, "步骤【" + key + "】准备下发物料:" + RecipesNames, count,key,false); for (int m = 0; m < goodsRecipes.size(); m++) { ResGoodsRecipe recipe = goodsRecipes.get(m); int materialType = recipe.materialType; @@ -314,7 +314,7 @@ public class BusinessServer { // } //更新缓存商品制作列表状态 count += goodsRecipes.size(); - DataBus.getInstance().UpdateGoodsMake(suborder.id, "步骤【" + key + "】:" + RecipesNames + "-配料完成!", count); + DataBus.getInstance().UpdateGoodsMake(suborder.id, "步骤【" + key + "】:" + RecipesNames + "-配料完成!", count,key,true); MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + good.name + "]步骤【" + key + "】下发" + RecipesNames + "执行完成!"); } //endregion diff --git a/app/src/main/java/com/example/bpa/view/adapter/maingoods_adapter.java b/app/src/main/java/com/example/bpa/view/adapter/maingoods_adapter.java index 6787b17..75a80c9 100644 --- a/app/src/main/java/com/example/bpa/view/adapter/maingoods_adapter.java +++ b/app/src/main/java/com/example/bpa/view/adapter/maingoods_adapter.java @@ -120,25 +120,25 @@ public class maingoods_adapter extends RecyclerView.Adapter private Context context; - List Modes = DataBus.getInstance().OrderSM.orderDetail; + List Modes = DataBus.getInstance().GoodsSMMake; public order_adapter(Context context) { this.context = context; @@ -40,33 +49,64 @@ public class order_adapter extends RecyclerView.Adapter @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View inflate = mLayoutInflater.inflate(R.layout.order_item, parent, false); - return new devstatus_adapter.MyViewHolder(inflate); + return new order_adapter.MyViewHolder(inflate); } @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { try { - if (holder instanceof devstatus_adapter.MyViewHolder) { - devstatus_adapter.MyViewHolder myViewHolder = (devstatus_adapter.MyViewHolder) holder; - SuOrderA statusMode= Modes.get(position); -// myViewHolder.title.setText(statusMode.Name); -// if(statusMode.Status) -// { -// myViewHolder.image.setImageResource(statusMode.Url_open); -// myViewHolder.text.setText("打开"); -// myViewHolder.text.setTextColor(ConfigName.getInstance().dishesCon.getResources().getColor(R.color.lable_color)); -// }else -// { -// myViewHolder.image.setImageResource(statusMode.Url_close); -// myViewHolder.text.setText("关闭"); -// myViewHolder.text.setTextColor(ConfigName.getInstance().dishesCon.getResources().getColor(R.color.warm_red)); -// } + if (holder instanceof order_adapter.MyViewHolder) { + order_adapter.MyViewHolder myViewHolder = (order_adapter.MyViewHolder) holder; + ResGoodsMake statusMode = Modes.get(position); + myViewHolder.title.setText(statusMode.good.name); + myViewHolder.image.setImageURL(statusMode.subOrder.goodImg); + myViewHolder.goodms.setText(statusMode.makeMs); + myViewHolder.progress_bar.setProgress(statusMode.makeProcess); + ; + myViewHolder.goodStatus.setText(statusMode.makeStatus.toString()); + + + myViewHolder.pllc.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)); + myViewHolder.adapter = new pflc_adapter(context, statusMode.recipes); + myViewHolder.pllc.setAdapter(myViewHolder.adapter); + if (statusMode.makeStatus == MakeStatus.等待制作) { + myViewHolder.goodStatus.setTextColor(ConfigName.getInstance().dishesCon.getResources().getColor(R.color.dd)); + } else if (statusMode.makeStatus == MakeStatus.制作中) { + myViewHolder.goodStatus.setTextColor(ConfigName.getInstance().dishesCon.getResources().getColor(R.color.lime)); + } else { + myViewHolder.goodStatus.setTextColor(ConfigName.getInstance().dishesCon.getResources().getColor(R.color.white)); + } + if (statusMode.makeStatus == MakeStatus.等待制作) { + myViewHolder.start_button.setVisibility(View.VISIBLE); + myViewHolder.goodStatus.setVisibility(View.GONE); + } else { + myViewHolder.start_button.setVisibility(View.GONE); + myViewHolder.goodStatus.setVisibility(View.VISIBLE); + } + myViewHolder.start_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + +// if (!DataBus.getInstance().PlcIsConnect) { +// T.show(view.getContext(), "PLC未连接,不允许下单!"); +// return; +// } + + if (BusinessServer.Get().Commoditys.size() > 0) { + T.show(view.getContext(), "请等待前一饮品制作完成!"); + return; + } + BusinessServer.Get().AddCommodity(statusMode.subOrder); + T.show(view.getContext(), "开始制作商品:" + statusMode.good.name.toString()); + } + }); } } catch (Exception e) { e.printStackTrace(); } } + private Activity findActivity(@NonNull Context context) { if (context instanceof Activity) { return (Activity) context; @@ -76,14 +116,15 @@ public class order_adapter extends RecyclerView.Adapter return null; } } + /** * 刷新 + * * @param */ - public void refresh(){ - Activity activity= findActivity(context); - if(activity!=null) - { + public void refresh() { + Activity activity = findActivity(context); + if (activity != null) { activity.runOnUiThread(new Runnable() { @Override public void run() { @@ -110,16 +151,36 @@ public class order_adapter extends RecyclerView.Adapter /** * 图片 */ - ImageView image; + MyImageView image; + /** + * 开始按钮 + */ + Button start_button; + /** + * 显示状态 + */ + TextView goodStatus; + /** + * 商品描述 + * 当前配置奶茶中..请稍后... + */ + TextView goodms; /** - * 描述 + * 制作进度 */ - TextView text; + ProgressBar progress_bar; + pflc_adapter adapter; + RecyclerView pllc; + public MyViewHolder(View view) { super(view); title = (TextView) view.findViewById(R.id.title); - image = (ImageView) view.findViewById(R.id.image); - text=(TextView) view.findViewById(R.id.text); + goodms = (TextView) view.findViewById(R.id.goodms); + progress_bar = (ProgressBar) view.findViewById(R.id.progress_bar); + image = (MyImageView) view.findViewById(R.id.image); + start_button = (Button) view.findViewById(R.id.start_button); + goodStatus = (TextView) view.findViewById(R.id.start_text); + pllc = view.findViewById(R.id.pllc); } } } \ No newline at end of file diff --git a/app/src/main/java/com/example/bpa/view/adapter/pflc_adapter.java b/app/src/main/java/com/example/bpa/view/adapter/pflc_adapter.java new file mode 100644 index 0000000..d5277ca --- /dev/null +++ b/app/src/main/java/com/example/bpa/view/adapter/pflc_adapter.java @@ -0,0 +1,187 @@ +package com.example.bpa.view.adapter; + +import android.app.Activity; +import android.content.Context; +import android.content.ContextWrapper; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ProgressBar; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.capton.colorfulprogressbar.ColorfulProgressbar; +import com.example.bpa.R; +import com.example.bpa.config.ConfigName; +import com.example.bpa.config.DataBus; +import com.example.bpa.helper.MyImageView; +import com.example.bpa.helper.T; +import com.example.bpa.view.mode.MakeStatus; +import com.example.bpa.view.mode.ResGoodsMake; +import com.example.bpa.view.mode.ResGoodsRecipe; + +import java.util.ArrayList; +import java.util.List; + + +/** + * 配方流程 + */ +public class pflc_adapter extends RecyclerView.Adapter { + + private final LayoutInflater mLayoutInflater; + + private Context context; + + List Modes = new ArrayList<>() ; + + public pflc_adapter(Context context, ArrayList recipes) { + this.context = context; + mLayoutInflater = LayoutInflater.from(context); + Modes=recipes; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View inflate = mLayoutInflater.inflate(R.layout.pllc_item, parent, false); + return new pflc_adapter.MyViewHolder(inflate); + + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + try { + if (holder instanceof pflc_adapter.MyViewHolder) { + pflc_adapter.MyViewHolder myViewHolder = (pflc_adapter.MyViewHolder) holder; + ResGoodsRecipe mode= Modes.get(position); + myViewHolder.title.setText(SortStr(mode.sort)+" "+mode.materialName +"("+mode.value+")"); + myViewHolder.progress_bar.setProgress(mode.makeProcess); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + private Activity findActivity(@NonNull Context context) { + if (context instanceof Activity) { + return (Activity) context; + } else if (context instanceof ContextWrapper) { + return findActivity(((ContextWrapper) context).getBaseContext()); + } else { + return null; + } + } + + public String SortStr(int i) + { + if(i==1) + { + return "①"; + }else if(i==2) + { + return "②"; + }else if(i==3) + { + return "③"; + }else if(i==4) + { + return "④"; + }else if(i==5) + { + return "⑤"; + }else if(i==6) + { + return "⑥"; + }else if(i==7) + { + return "⑦"; + }else if(i==8) + { + return "⑧"; + }else if(i==9) + { + return "⑨"; + }else if(i==10) + { + return "⑩"; + }else if(i==11) + { + return "⑪"; + }else if(i==12) + { + return "⑫"; + }else if(i==13) + { + return "⑬"; + }else if(i==14) + { + return "⑭"; + }else if(i==15) + { + return "⑮"; + }else if(i==16) + { + return "⑯"; + }else if(i==17) + { + return "⑰"; + }else if(i==18) + { + return "⑱"; + }else if(i==19) + { + return "⑲"; + }else if(i==20) + { + return "⑳"; + }else + { + return "①"; + } + } + + /** + * 刷新 + * @param + */ + public void refresh(){ + Activity activity= findActivity(context); + if(activity!=null) + { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + try { + notifyDataSetChanged(); + } catch (Exception e) { + + } + } + }); + } + } + + @Override + public int getItemCount() { + return Modes.size(); + } + + public static class MyViewHolder extends RecyclerView.ViewHolder { + /** + * 标题 + */ + TextView title; + /** + * 制作进度 + */ + ColorfulProgressbar progress_bar; + public MyViewHolder(View view) { + super(view); + title = (TextView) view.findViewById(R.id.title); + progress_bar=(ColorfulProgressbar) view.findViewById(R.id.progress_bar); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/bpa/view/mode/ResGoodsRecipe.java b/app/src/main/java/com/example/bpa/view/mode/ResGoodsRecipe.java index 63b72d6..3e25551 100644 --- a/app/src/main/java/com/example/bpa/view/mode/ResGoodsRecipe.java +++ b/app/src/main/java/com/example/bpa/view/mode/ResGoodsRecipe.java @@ -24,4 +24,8 @@ public class ResGoodsRecipe extends BPA_GOODSRECIPE { * 是否运行 */ public boolean IsRun=false; + /** + * 制作进度 + */ + public int makeProcess; } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 372bcab..0b2f60d 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -49,23 +49,33 @@ android:layout_centerVertical="true" android:layout_width="wrap_content" android:layout_height="wrap_content"> + + + android:src="@mipmap/zy"/> + android:src="@mipmap/zzlb"/> + - + - - + @@ -37,95 +43,69 @@ android:text="制作流程:" android:textColor="@color/white" /> - - - - - - + - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - - + + + +