From 8057c0b0c21ced5bb1c1b135c0325c40bd58e218 Mon Sep 17 00:00:00 2001 From: fyf Date: Thu, 11 May 2023 18:28:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=B3=BB=E7=BB=9F=E4=B8=BB?= =?UTF-8?q?=E9=A1=B5=20=E5=95=86=E5=93=81=E5=88=B6=E4=BD=9C=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/bpa/app/BusinessServer.java | 18 ++- .../java/com/example/bpa/config/DataBus.java | 102 +++++++++++++++- .../main/java/com/example/bpa/db/QueryDB.java | 23 ++++ .../bpa/view/adapter/makegood_adapter.java | 109 ++++++++++++++++++ .../bpa/view/fragment/HomeFragment.java | 25 ++-- .../com/example/bpa/view/mode/MakeStatus.java | 7 ++ .../example/bpa/view/mode/ResGoodsMake.java | 41 +++++++ .../example/bpa/view/mode/ResGoodsRecipe.java | 5 + .../res/layout/from/layout/fragment_home.xml | 74 +++++++++++- .../main/res/layout/item/layout/maingoods.xml | 8 +- .../main/res/layout/item/layout/makegoods.xml | 85 ++++++++++++++ app/src/main/res/mipmap-xhdpi/tab.png | Bin 0 -> 313 bytes 12 files changed, 468 insertions(+), 29 deletions(-) create mode 100644 app/src/main/java/com/example/bpa/view/adapter/makegood_adapter.java create mode 100644 app/src/main/java/com/example/bpa/view/mode/MakeStatus.java create mode 100644 app/src/main/java/com/example/bpa/view/mode/ResGoodsMake.java create mode 100644 app/src/main/res/layout/item/layout/makegoods.xml create mode 100644 app/src/main/res/mipmap-xhdpi/tab.png diff --git a/app/src/main/java/com/example/bpa/app/BusinessServer.java b/app/src/main/java/com/example/bpa/app/BusinessServer.java index a348f3b..e5a470b 100644 --- a/app/src/main/java/com/example/bpa/app/BusinessServer.java +++ b/app/src/main/java/com/example/bpa/app/BusinessServer.java @@ -4,6 +4,7 @@ import com.example.bpa.Model.IRun; import com.example.bpa.Model.IRunT; import com.example.bpa.Model.IThread; import com.example.bpa.Model.IWriteCallBack; +import com.example.bpa.config.DataBus; import com.example.bpa.db.QueryDB; import com.example.bpa.db.mode.BPA_SILOS; import com.example.bpa.db.mode.BPA_SUGAR; @@ -11,7 +12,9 @@ import com.example.bpa.helper.MessageLog; import com.example.bpa.helper.ThreadManager; import com.example.bpa.view.mode.ResGoodsRecipe; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; @@ -41,6 +44,7 @@ public class BusinessServer { */ public void AddCommodity(String info) { Commoditys.offer(info); + DataBus.getInstance().AddGoodsMake(info); } /** @@ -68,7 +72,7 @@ public class BusinessServer { int materialType = entry.getValue().get(m).materialType; //1.正常物料 if (materialType == 1) { - //获取料仓信息 + //1.获取物料关联的料仓信息 List bss = QueryDB.GetSolisByMaterialID(entry.getValue().get(m).materialID); //GetsugarId for (int x = 0; x < bss.size(); x++) { @@ -87,7 +91,6 @@ public class BusinessServer { }); //} } - DeviceData.Get().setChargeMixtureStart(new IWriteCallBack() { @Override public void onSuccess() { @@ -100,17 +103,21 @@ public class BusinessServer { } });//启动配料 final boolean[] IsComplete = {false}; + final String goodsID=entry.getValue().get(m).goodsID; + final String materialID=entry.getValue().get(m).materialID; + final String materialName=entry.getValue().get(m).materialName; DeviceData.Get().OnChargeMixtureCompleteNotify = new IRun() { @Override public void Run() { IsComplete[0] = true; - MessageLog.ShowInfo("通道配料完成!"); + MessageLog.ShowInfo(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+":"+materialName+"配料完成!"); } }; - while (!IsComplete[0]) { Thread.sleep(100); } + //更新缓存商品制作列表状态 + DataBus.getInstance().UpdateGoodsMake(goodsID,materialID,m); MessageLog.ShowInfo("步骤【" + entry.getKey() + "】执行完成"); } //2.果糖 @@ -122,8 +129,9 @@ public class BusinessServer { MessageLog.ShowInfo("步骤【" + entry.getKey() + "】下发"+entry.getValue().get(m).materialName+"执行完成"); } } - } + //设置商品已制作完成 + DataBus.getInstance().DeleteGoodsMake(GoodId); MessageLog.ShowInfo("配方执行完成"); } Thread.sleep(1000); 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 63389ec..f01b0f4 100644 --- a/app/src/main/java/com/example/bpa/config/DataBus.java +++ b/app/src/main/java/com/example/bpa/config/DataBus.java @@ -3,6 +3,12 @@ package com.example.bpa.config; import com.example.bpa.R; import com.example.bpa.db.QueryDB; import com.example.bpa.db.mode.BPA_GOODS; +import com.example.bpa.view.adapter.maingoods_adapter; +import com.example.bpa.view.adapter.makegood_adapter; +import com.example.bpa.view.control.MyLayoutManager; +import com.example.bpa.view.mode.MakeStatus; +import com.example.bpa.view.mode.ResGoodsMake; +import com.example.bpa.view.mode.ResGoodsRecipe; import com.example.bpa.view.mode.mainGoods; import java.util.ArrayList; @@ -43,13 +49,103 @@ public class DataBus { //endregion //region 数据中心 + /** + * 商品制作列表 + */ + public List GoodsMake = new ArrayList(); + /** + * 商品制作列表 + */ + public List GoodsMakeOver = new ArrayList(); + /** + * 商品制作 + */ + public makegood_adapter goodmakeadapter; + /** + * 增加一个商品 + * @param id + */ + public void AddGoodsMake(String id) + { + try + { + ResGoodsMake make=new ResGoodsMake(); + make.recipes=QueryDB.GetGoodsSrecipeList(id); + make.good=QueryDB.GetGoodsId(id); + make.makeStatus= MakeStatus.等待制作; + make.makeMs=""; + make.makeProcess=0; + GoodsMake.add(make); + goodmakeadapter.refresh(); + }catch(Exception e){ + } + } + + /** + * 根据商品id,物料id修改制作进度 + * @param wlid + */ + public void UpdateGoodsMake(String id, String wlid,int m) + { + try + { + for (ResGoodsMake item:GoodsMake) + { + if(item.good.id.equals(id)) + { + for (ResGoodsRecipe pf:item.recipes) + { + if(pf.id.equals(wlid)) + { + pf.IsRun=true; + item.makeStatus= MakeStatus.制作中; + item.makeMs="当前配置["+pf.materialName+"]中..请稍后..."; + item.makeProcess=(m/ item.recipes.size())*100; + goodmakeadapter.refresh(); + return; + } + } + } + } + }catch(Exception e){ + } + } + /** + * 根据商品id,设置商品制作完成 + */ + public void DeleteGoodsMake(String id) + { + try + { + ResGoodsMake good=null; + for (ResGoodsMake item:GoodsMake) + { + if(item.good.id.equals(id)) + { + item.makeStatus=MakeStatus.制作完成; + item.makeMs=""; + item.makeProcess=100; + good=item; + } + } + if(good!=null) + { + GoodsMakeOver.add(good); + GoodsMake.remove(good); + goodmakeadapter.refresh(); + } + }catch(Exception e){ + } + } + /** * 主界面商品列表 */ public List mainGoods = new ArrayList(); - + /** + * 商品图片 + */ public Map good_picMap = new HashMap(); - /** * 更新商品主界面商品列表 */ @@ -65,8 +161,6 @@ public class DataBus { mainGoods.add(newgood); } } - } - //endregion } 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 bde9f4c..ab018c1 100644 --- a/app/src/main/java/com/example/bpa/db/QueryDB.java +++ b/app/src/main/java/com/example/bpa/db/QueryDB.java @@ -559,6 +559,29 @@ public class QueryDB { return data; } + /** + * 根据id查询商品 + * + * @return + */ + public static BPA_GOODS GetGoodsId(String id) { + String orderby = Desc_Sort_Up + ',' + Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=? and id=?"; + String[] args = new String[]{"0",id}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_GOODS.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_GOODS) k); + } + if(data.size()>0) + { + return data.get(0); + }else + { + return new BPA_GOODS(); + } + } + /** * 判断商品数据是否存在 * diff --git a/app/src/main/java/com/example/bpa/view/adapter/makegood_adapter.java b/app/src/main/java/com/example/bpa/view/adapter/makegood_adapter.java new file mode 100644 index 0000000..06473a1 --- /dev/null +++ b/app/src/main/java/com/example/bpa/view/adapter/makegood_adapter.java @@ -0,0 +1,109 @@ +package com.example.bpa.view.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.example.bpa.R; +import com.example.bpa.app.BusinessServer; +import com.example.bpa.config.DataBus; +import com.example.bpa.helper.T; +import com.example.bpa.view.mode.ResGoodsMake; +import com.example.bpa.view.mode.mainGoods; + +import java.util.List; +import java.util.Random; + +/** + * 制作商品 + */ +public class makegood_adapter extends RecyclerView.Adapter { + + private final LayoutInflater mLayoutInflater; + + private Context context; + + List mainGoods = DataBus.getInstance().GoodsMake; + + public makegood_adapter(Context context) { + this.context = context; + mLayoutInflater = LayoutInflater.from(context); + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View inflate = mLayoutInflater.inflate(R.layout.makegoods, parent, false); + return new makegood_adapter.MyGoodLCViewHolder(inflate); + + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + try { + if (holder instanceof makegood_adapter.MyGoodLCViewHolder) { + makegood_adapter.MyGoodLCViewHolder myViewHolder = (makegood_adapter.MyGoodLCViewHolder) holder; + ResGoodsMake goodsMake= mainGoods.get(position); + myViewHolder.goodmakename.setText(goodsMake.good.name); + myViewHolder.goodms.setText(goodsMake.makeMs); + myViewHolder.goodStatus.setText(goodsMake.makeStatus.toString()); + myViewHolder.progress_bar.setProgress(goodsMake.makeProcess);; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 刷新 + * @param + */ + public void refresh(){ + notifyDataSetChanged(); + } + + @Override + public int getItemCount() { + return mainGoods.size(); + } + + public static class MyGoodLCViewHolder extends RecyclerView.ViewHolder { + /** + * 商品名称 + */ + TextView goodmakename; + /** + * 商品描述 + * 当前配置奶茶中..请稍后... + */ + TextView goodms; + /** + * 商品制作状态 + */ + TextView goodStatus; + /** + * 制作进度 + */ + ProgressBar progress_bar; + /** + * 商品背景图片 + */ + ImageView good_Image; + public MyGoodLCViewHolder(View view) { + super(view); + goodmakename = (TextView) view.findViewById(R.id.goodmakename); + goodms = (TextView) view.findViewById(R.id.goodms); + progress_bar=(ProgressBar) view.findViewById(R.id.progress_bar); + good_Image = (ImageView)view.findViewById(R.id.good_Image); + goodStatus=(TextView) view.findViewById(R.id.goodStatus); + } + } +} diff --git a/app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java b/app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java index 46c068f..02be7e8 100644 --- a/app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java +++ b/app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java @@ -23,11 +23,13 @@ import com.example.bpa.db.mode.BPA_GOODS; import com.example.bpa.helper.Json; import com.example.bpa.helper.T; import com.example.bpa.view.adapter.maingoods_adapter; +import com.example.bpa.view.adapter.makegood_adapter; import com.example.bpa.view.adapter.sp_adapter; import com.example.bpa.view.control.MyLayoutManager; import com.example.bpa.view.from.add_pf_activity; import com.example.bpa.view.from.yfpf_activity; import com.example.bpa.view.inteface.MyClickListener; +import com.example.bpa.view.mode.mainGoods; import java.util.ArrayList; @@ -42,17 +44,13 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl */ RecyclerView good_recyclerView; /** - * 界面实例 + * 商品制作列表 */ - public View view; + RecyclerView MakeGood; /** - * 表格显示 - */ - public ListView datatab; - /** - * 商品数据 + * 界面实例 */ - public ArrayList bpa_goods=new ArrayList<>(); + public View view; //endregion //region 私有函数 @@ -70,8 +68,8 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl * 初始化 */ private void Init(){ -// datatab= view.findViewById(R.id.datatab); good_recyclerView = view.findViewById(R.id.good_recyclerView); + MakeGood=view.findViewById(R.id.MakeGood); Initdata();//初始化数据 RegisterMessage();//消息中心事件接收 } @@ -94,9 +92,12 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl maingoods_adapter goodadapter = new maingoods_adapter( getContext()); good_recyclerView.setAdapter(goodadapter); DataBus.getInstance().UpdateMainGoods();//更新商品 -// bpa_goods= QueryDB.GetGoodsALL(); -// sp_adapter adapter = new sp_adapter(view.getContext(), R.layout.sp_item, bpa_goods,this); -// datatab.setAdapter(adapter); + + + MakeGood.setLayoutManager(new LinearLayoutManager(view.getContext(), LinearLayoutManager.HORIZONTAL,false)); + DataBus.getInstance().goodmakeadapter = new makegood_adapter(getContext()); + MakeGood.setAdapter(DataBus.getInstance().goodmakeadapter); + }catch(Exception e){ } diff --git a/app/src/main/java/com/example/bpa/view/mode/MakeStatus.java b/app/src/main/java/com/example/bpa/view/mode/MakeStatus.java new file mode 100644 index 0000000..4ae7f4a --- /dev/null +++ b/app/src/main/java/com/example/bpa/view/mode/MakeStatus.java @@ -0,0 +1,7 @@ +package com.example.bpa.view.mode; + +public enum MakeStatus { + 等待制作, + 制作中, + 制作完成 +} diff --git a/app/src/main/java/com/example/bpa/view/mode/ResGoodsMake.java b/app/src/main/java/com/example/bpa/view/mode/ResGoodsMake.java new file mode 100644 index 0000000..22745d0 --- /dev/null +++ b/app/src/main/java/com/example/bpa/view/mode/ResGoodsMake.java @@ -0,0 +1,41 @@ +package com.example.bpa.view.mode; + +import com.example.bpa.db.mode.BPA_GOODS; + +import java.util.ArrayList; +import java.util.List; + +/** + * 商品制作列表 + */ +public class ResGoodsMake { + /** + * 商品数据 + */ + public BPA_GOODS good; + /** + * 商品制作配方 + */ + public ArrayList recipes; + /** + * 制作状态 + */ + public MakeStatus makeStatus; + /** + * 制作描述 + */ + public String makeMs; + /** + * 制作进度 + */ + public int makeProcess; + public ResGoodsMake() + { + good=new BPA_GOODS(); + recipes=new ArrayList<>(); + makeStatus=MakeStatus.等待制作; + makeMs=""; + makeProcess=0; + } +} + 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 8651848..63b72d6 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 @@ -19,4 +19,9 @@ public class ResGoodsRecipe extends BPA_GOODSRECIPE { * 2 为果糖 */ public int materialType; + + /** + * 是否运行 + */ + public boolean IsRun=false; } diff --git a/app/src/main/res/layout/from/layout/fragment_home.xml b/app/src/main/res/layout/from/layout/fragment_home.xml index 8d02365..dd2a6b5 100644 --- a/app/src/main/res/layout/from/layout/fragment_home.xml +++ b/app/src/main/res/layout/from/layout/fragment_home.xml @@ -12,13 +12,75 @@ - + - + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/item/layout/maingoods.xml b/app/src/main/res/layout/item/layout/maingoods.xml index b6eecd1..0410e4f 100644 --- a/app/src/main/res/layout/item/layout/maingoods.xml +++ b/app/src/main/res/layout/item/layout/maingoods.xml @@ -1,13 +1,17 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/mipmap-xhdpi/tab.png b/app/src/main/res/mipmap-xhdpi/tab.png new file mode 100644 index 0000000000000000000000000000000000000000..f3ad8684e417e39e429ab40651bedfb510c08f3b GIT binary patch literal 313 zcmV-90mlA`P)TCnsB z8@LH%-*BG5*uiQ5qg-qf#|exj91O!Kl8dQc;3^3B7+kD3^SBMdoi;5tVD_5eis~FS z#!3?7?yoV5zUNV5JS8#ak{J6*jFUP>Q45VL##s_$w~kSV(1&pyEbU>e2eSVbV-SQ2 zqn*U)jx$Dik7x>(3m#!QSX=@g;v`b3N<00000 LNkvXXu0mjf