@@ -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<BPA_SILOS> 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); | |||
@@ -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<ResGoodsMake> GoodsMake = new ArrayList<ResGoodsMake>(); | |||
/** | |||
* 商品制作列表 | |||
*/ | |||
public List<ResGoodsMake> GoodsMakeOver = new ArrayList<ResGoodsMake>(); | |||
/** | |||
* 商品制作 | |||
*/ | |||
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> mainGoods = new ArrayList<mainGoods>(); | |||
/** | |||
* 商品图片 | |||
*/ | |||
public Map<Integer,Integer> good_picMap = new HashMap<Integer,Integer>(); | |||
/** | |||
* 更新商品主界面商品列表 | |||
*/ | |||
@@ -65,8 +161,6 @@ public class DataBus { | |||
mainGoods.add(newgood); | |||
} | |||
} | |||
} | |||
//endregion | |||
} |
@@ -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<BPA_GOODS> data = new ArrayList<>(); | |||
ArrayList<Object> 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(); | |||
} | |||
} | |||
/** | |||
* 判断商品数据是否存在 | |||
* | |||
@@ -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<RecyclerView.ViewHolder> { | |||
private final LayoutInflater mLayoutInflater; | |||
private Context context; | |||
List<ResGoodsMake> 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); | |||
} | |||
} | |||
} |
@@ -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> 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){ | |||
} | |||
@@ -0,0 +1,7 @@ | |||
package com.example.bpa.view.mode; | |||
public enum MakeStatus { | |||
等待制作, | |||
制作中, | |||
制作完成 | |||
} |
@@ -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<ResGoodsRecipe> recipes; | |||
/** | |||
* 制作状态 | |||
*/ | |||
public MakeStatus makeStatus; | |||
/** | |||
* 制作描述 | |||
*/ | |||
public String makeMs; | |||
/** | |||
* 制作进度 | |||
*/ | |||
public int makeProcess; | |||
public ResGoodsMake() | |||
{ | |||
good=new BPA_GOODS(); | |||
recipes=new ArrayList<>(); | |||
makeStatus=MakeStatus.等待制作; | |||
makeMs=""; | |||
makeProcess=0; | |||
} | |||
} | |||
@@ -19,4 +19,9 @@ public class ResGoodsRecipe extends BPA_GOODSRECIPE { | |||
* 2 为果糖 | |||
*/ | |||
public int materialType; | |||
/** | |||
* 是否运行 | |||
*/ | |||
public boolean IsRun=false; | |||
} |
@@ -12,13 +12,75 @@ | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_margin="10dp"> | |||
<androidx.recyclerview.widget.RecyclerView | |||
android:id="@+id/good_recyclerView" | |||
android:layout_marginTop="0dp" | |||
android:layout_marginLeft="10dp" | |||
android:layout_marginRight="10dp"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:scrollbarStyle="outsideOverlay"> | |||
</androidx.recyclerview.widget.RecyclerView> | |||
android:layout_height="match_parent" | |||
android:orientation="vertical"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="24dp" | |||
android:orientation="horizontal"> | |||
<ImageView | |||
android:layout_width="40dp" | |||
android:layout_height="10dp" | |||
android:layout_marginTop="8dp" | |||
android:src="@mipmap/tab"> | |||
</ImageView> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="2dp" | |||
android:text="商品列表" | |||
android:textColor="@color/titleforeground"> | |||
</TextView> | |||
</LinearLayout> | |||
<ScrollView | |||
android:layout_height="0dp" | |||
android:layout_marginTop="0dp" | |||
android:layout_width="match_parent" | |||
android:layout_weight="1.7" | |||
android:fadingEdge="vertical" | |||
tools:ignore="Suspicious0dp"> | |||
<androidx.recyclerview.widget.RecyclerView | |||
android:id="@+id/good_recyclerView" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content"> | |||
</androidx.recyclerview.widget.RecyclerView> | |||
</ScrollView> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="24dp" | |||
android:orientation="horizontal"> | |||
<ImageView | |||
android:layout_width="40dp" | |||
android:layout_height="10dp" | |||
android:layout_marginTop="8dp" | |||
android:src="@mipmap/tab"> | |||
</ImageView> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="2dp" | |||
android:text="订单制作" | |||
android:textColor="@color/titleforeground"> | |||
</TextView> | |||
</LinearLayout> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="0dp" | |||
tools:ignore="Suspicious0dp" | |||
android:layout_weight="0.8"> | |||
<androidx.recyclerview.widget.RecyclerView | |||
android:id="@+id/MakeGood" | |||
android:layout_marginLeft="15dp" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
</androidx.recyclerview.widget.RecyclerView> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<!-- <RelativeLayout--> | |||
<!-- android:layout_width="wrap_content"--> | |||
@@ -1,13 +1,17 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="200dp" | |||
android:layout_height="140dp" | |||
android:layout_height="130dp" | |||
> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:background="@mipmap/bg_f3" | |||
android:layout_margin="10dp" | |||
android:layout_marginTop="5dp" | |||
android:layout_marginRight="10dp" | |||
android:layout_marginLeft="10dp" | |||
android:layout_marginBottom="5dp" | |||
> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
@@ -0,0 +1,85 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="200dp" | |||
android:layout_height="130dp" | |||
> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:background="@mipmap/bg_f2" | |||
android:layout_marginTop="5dp" | |||
android:layout_marginRight="10dp" | |||
android:layout_marginLeft="10dp" | |||
android:layout_marginBottom="5dp"> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_marginLeft="8dp" | |||
android:layout_marginRight="7dp" | |||
android:layout_marginTop="6dp" | |||
android:layout_marginBottom="9dp"> | |||
<ImageView | |||
android:id="@+id/good_Image" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_gravity="center_vertical" | |||
android:adjustViewBounds="true" | |||
android:alpha="0.8" | |||
android:scaleType="centerCrop" | |||
android:src="@mipmap/milktea_2" /> | |||
<RelativeLayout | |||
android:layout_margin="0dp" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:background="@mipmap/bg_f1"> | |||
<TextView | |||
android:id="@+id/goodmakename" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="30dp" | |||
android:layout_marginTop="10dp" | |||
android:text="原味奶茶" | |||
android:textColor="@color/colorPrimaryDark" | |||
android:textSize="14dp" | |||
android:textStyle="bold" | |||
android:typeface="serif" /> | |||
<TextView | |||
android:id="@+id/goodms" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="30dp" | |||
android:layout_marginTop="32dp" | |||
android:layout_marginRight="30dp" | |||
android:text="当前配置奶茶中..请稍后..." | |||
android:textColor="@color/colorPrimaryDark" | |||
android:textSize="10dp" | |||
android:typeface="serif" /> | |||
<ProgressBar | |||
android:id="@+id/progress_bar" | |||
style="?android:attr/progressBarStyleHorizontal" | |||
android:layout_width="300dp" | |||
android:layout_height="wrap_content" | |||
android:layout_gravity="center" | |||
android:visibility="visible" | |||
android:layout_marginLeft="30dp" | |||
android:layout_marginTop="60dp" | |||
android:layout_marginRight="30dp" | |||
android:duration="3000" | |||
android:progress="0" | |||
android:indeterminate="false" | |||
android:max="100" /> | |||
<TextView | |||
android:id="@+id/goodStatus" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="90dp" | |||
android:layout_marginTop="70dp" | |||
android:text="制作中" | |||
android:textColor="@color/colorAccent" | |||
android:textSize="14dp" | |||
android:textStyle="bold" | |||
android:typeface="serif" /> | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
</LinearLayout> |