diff --git a/app/src/main/java/com/example/bpa/MainActivity.java b/app/src/main/java/com/example/bpa/MainActivity.java index 0300b6c..cb3e271 100644 --- a/app/src/main/java/com/example/bpa/MainActivity.java +++ b/app/src/main/java/com/example/bpa/MainActivity.java @@ -148,7 +148,7 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen clist_title.setText(ConfigName.getInstance().Shop_Name); version.setText(ConfigName.getInstance().Version); ShowFragment(homeFragment, "系统主页"); - DataBus.getInstance().UpdateMainGoods(); + DataBus.getInstance().UpdateMainGoods(""); mUpdateManager = new UpdateManager(MainActivity.this,this); ConfigName.getInstance().activity=this; Speech.initTTS(this); 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 4a81c2a..11f1b52 100644 --- a/app/src/main/java/com/example/bpa/config/DataBus.java +++ b/app/src/main/java/com/example/bpa/config/DataBus.java @@ -9,6 +9,7 @@ import com.example.bpa.Model.OrderStatusChange; import com.example.bpa.Model.ResultA; import com.example.bpa.R; import com.example.bpa.app.Main; +import com.example.bpa.db.mode.BPA_MENU; import com.example.bpa.db.mode.BPA_SUBORDER; import com.example.bpa.helper.MessageLog; import com.example.bpa.message.MessageManager; @@ -359,9 +360,21 @@ public class DataBus { /** * 更新商品主界面商品列表 */ - public void UpdateMainGoods(){ + public void UpdateMainGoods(String lx){ mainGoods.clear(); - ArrayList res = QueryDB.GetGoodsStateALL(); + if(lx.isEmpty()) + { + ArrayList foodTypes= QueryDB.GetMenuALL(); + if(foodTypes.size()>0) + { + lx=foodTypes.get(0).name; + }else + { + lx="其他"; + } + } + + ArrayList res = QueryDB.GetGoodsStateALL(lx); if (res.size()>0){ for (BPA_GOODS good:res){ mainGoods newgood = new mainGoods(); 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 664d8d1..427bead 100644 --- a/app/src/main/java/com/example/bpa/db/QueryDB.java +++ b/app/src/main/java/com/example/bpa/db/QueryDB.java @@ -578,10 +578,18 @@ public class QueryDB { * * @return */ - public static ArrayList GetGoodsStateALL() { + public static ArrayList GetGoodsStateALL(String lx) { String orderby = Desc_Sort_Up + ',' + Desc_Time_Up;//先按排序 创建时间倒序 - String where = "isDelete=? and status=?"; - String[] args = new String[]{"0", "1"}; + String where=""; + if(lx.equals("其他")) + { + where = "isDelete=? and status=? and (exp=? or exp is null)"; + + }else + { + where = "isDelete=? and status=? and exp=?"; + } + String[] args = new String[]{"0", "1",lx}; ArrayList data = new ArrayList<>(); ArrayList obj = Get(BPA_GOODS.class, where, args, orderby); for (Object k : obj) { diff --git a/app/src/main/java/com/example/bpa/view/adapter/MyAdapter.java b/app/src/main/java/com/example/bpa/view/adapter/MyAdapter.java new file mode 100644 index 0000000..baa9141 --- /dev/null +++ b/app/src/main/java/com/example/bpa/view/adapter/MyAdapter.java @@ -0,0 +1,61 @@ +package com.example.bpa.view.adapter; + +import android.content.Context; +import android.graphics.Color; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.TextView; + +import com.example.bpa.R; +import com.example.bpa.view.fragment.HomeFragment; + +public class MyAdapter extends BaseAdapter { + + private Context context; + private String[] strings; + public static int mPosition; + + public MyAdapter(Context context, String[] strings){ + this.context =context; + this.strings = strings; + } + + @Override + public int getCount() { + // TODO Auto-generated method stub + return strings.length; + } + + @Override + public Object getItem(int position) { + // TODO Auto-generated method stub + return strings[position]; + } + + @Override + public long getItemId(int position) { + // TODO Auto-generated method stub + return position; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + // TODO Auto-generated method stub + convertView = LayoutInflater.from(context).inflate(R.layout.listview_item, null); + TextView tv = (TextView) convertView.findViewById(R.id.tv_zcd); + mPosition = position; + tv.setText(strings[position]); + if (position == HomeFragment.mPosition) { + //convertView.setBackgroundColor(Color.parseColor("#FF074B92")); + + convertView.setBackgroundResource(R.mipmap.selectk); + } else { + //convertView.setBackgroundColor(Color.parseColor("#8f723c")); + + convertView.setBackgroundResource(R.mipmap.noselectk); + } + return convertView; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/bpa/view/control/clsf_control.java b/app/src/main/java/com/example/bpa/view/control/clsf_control.java index b91c7c6..daf847f 100644 --- a/app/src/main/java/com/example/bpa/view/control/clsf_control.java +++ b/app/src/main/java/com/example/bpa/view/control/clsf_control.java @@ -160,7 +160,7 @@ public class clsf_control extends LinearLayout { double finalZl = zl; //将其余料仓出料设置为0,重置 - for (int k = 1; k <= 12; k++) { + for (int k = 1; k <= 13; k++) { if (k!=index) { DeviceData.Get().setDemandValue((short) 0, k,null); } 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 7d4870b..c13dea8 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 @@ -17,8 +17,10 @@ import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; +import android.widget.AdapterView; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.ListView; import android.widget.TextView; import com.capton.colorfulprogressbar.ColorfulProgressbar; @@ -32,12 +34,14 @@ 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_GOODS; +import com.example.bpa.db.mode.BPA_MENU; import com.example.bpa.db.mode.BPA_SUBORDER; import com.example.bpa.helper.T; import com.example.bpa.helper.WrapContentLinearLayoutManager; import com.example.bpa.message.MessageLooper; import com.example.bpa.message.MessageManager; import com.example.bpa.service.DeviceData; +import com.example.bpa.view.adapter.MyAdapter; import com.example.bpa.view.adapter.maingoods_adapter; import com.example.bpa.view.adapter.makegood_adapter; import com.example.bpa.view.adapter.order_adapter; @@ -67,6 +71,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl * 商品制作列表 */ RecyclerView MakeGood; + public ListView foods_types_name;//导航 /** * 自动控制按钮 */ @@ -79,6 +84,18 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl * 界面实例 */ public View view; + + /** + * 商品类型集合 + */ + public List foodTypes=new ArrayList<>(); + /** + * 当前菜品集合 + */ + public List types_key; + + public static int mPosition; + private MyAdapter adapter; //endregion //region 私有函数 @@ -96,7 +113,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl * 初始化 */ private void Init(){ - + foods_types_name= view.findViewById(R.id.tv_typename); good_recyclerView = view.findViewById(R.id.good_recyclerView); makesp=view.findViewById(R.id.makesp); nohelp=view.findViewById(R.id.nohelp); @@ -146,17 +163,30 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl try{ if( ConfigName.getInstance().IsUserDownOrder) { - MyLayoutManager layout = new MyLayoutManager(); - layout.setAutoMeasureEnabled(true); - good_recyclerView.setLayoutManager(layout); + foodTypes= QueryDB.GetMenuALL(); + types_key=new ArrayList<>(); + for (BPA_MENU type:foodTypes) + { + types_key.add(type.name); + } + + types_key.add("其他"); + + adapter = new MyAdapter(this.getContext(), types_key.toArray(new String[0])); + foods_types_name.setAdapter(adapter); + foods_types_name.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + ItemClick(adapterView,view,i,l); + } + }); + ItemClick(null,null,0,0); - goodadapter = new maingoods_adapter( getContext()); - good_recyclerView.setAdapter(goodadapter); - DataBus.getInstance().UpdateMainGoods();//更新商品 - } + } + // MakeGood.setLayoutManager(new WrapContentLinearLayoutManager(view.getContext(), LinearLayoutManager.HORIZONTAL,false)); // DataBus.getInstance().goodmakeadapter = new makegood_adapter(getContext()); // MakeGood.setAdapter(DataBus.getInstance().goodmakeadapter); @@ -167,6 +197,43 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl //endregion //region 点击事件 + /** + * Item 点击事件 + * @param adapterView + * @param view + * @param position + * @param id + */ + public void ItemClick(AdapterView adapterView, View view, int position, long id) { + //即使刷新adapter + mPosition=position; + String str=""; + adapter.notifyDataSetChanged(); + if(view==null) + { + String[] key= types_key.toArray(new String[0]); + if(types_key.size()>0) + { + str=key[0]; + } + }else + { + TextView _text=view.findViewById(R.id.tv_zcd); + if(_text!=null && !_text.getText().toString().isEmpty()) + str=_text.getText().toString(); + } + + if(!str.isEmpty()) + { + MyLayoutManager layout = new MyLayoutManager(); + layout.setAutoMeasureEnabled(true); + good_recyclerView.setLayoutManager(layout); + + goodadapter = new maingoods_adapter( getContext()); + good_recyclerView.setAdapter(goodadapter); + DataBus.getInstance().UpdateMainGoods(str);//更新商品 + } + } /** * 本页面点击事件监听22 * diff --git a/app/src/main/java/com/example/bpa/view/from/lsjy_activity.java b/app/src/main/java/com/example/bpa/view/from/lsjy_activity.java index 7844243..e66546b 100644 --- a/app/src/main/java/com/example/bpa/view/from/lsjy_activity.java +++ b/app/src/main/java/com/example/bpa/view/from/lsjy_activity.java @@ -61,6 +61,10 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList Button savecanshu; //重量 TextView zhongliang; + + EditText bc_text4; + Button cl_botton; + //endregion //region 私有函数 @@ -142,6 +146,9 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList ClearText = findViewById(R.id.ClearText); zhongliang = findViewById(R.id.zhongliang); + + bc_text4=this.findViewById(R.id.bc_text4); + cl_botton=this.findViewById(R.id.cl_botton); } /** @@ -153,6 +160,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList SaveButton.setOnClickListener(this); ClearText.setOnClickListener(this); savecanshu.setOnClickListener(this); + cl_botton.setOnClickListener(this); } /** @@ -240,6 +248,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList if (!isClicked) { isClicked = true; StartButton.setEnabled(false); // 禁用按钮防止重复点击 + DeviceData.Get().setHandOrAutoSwitch(false, null); // 在2秒后执行按钮操作 new Handler().postDelayed(new Runnable() { @@ -366,6 +375,77 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList }, 500); } break; + case R.id.cl_botton: + String zltext = bc_text4.getText().toString(); + if (zltext.equals("")) { + T.show(lsjy_activity.this, "出料重量不能为空!"); + return; + } + double zl = 0; + try { + zl = Double.parseDouble(zltext); + } catch (Exception e) { + T.show(lsjy_activity.this, "出料重量获取异常!" + e.getMessage()); + return; + } + + if(zl<=1) + { + T.show(lsjy_activity.this, "出料重量至少大于1g!"); + return; + } + + int index=-1; + for (int i = 0; i < 13; i++) { + if (switchLists.get(i).isChecked() == true)//校准开关打开后,允许校准 + { + if(index<=-1) + { + index=i+1; + } + } + } + + if (index<=0) + { + T.show(lsjy_activity.this, "请打开通道开关!"); + return; + } + DeviceData.Get().setHandOrAutoSwitch(true, null); + + double finalZl = zl; + //将其余料仓出料设置为0,重置 + for (int k = 1; k <= 13; k++) { + if (k!=index) { + DeviceData.Get().setDemandValue((short) 0, k,null); + } + } + DeviceData.Get().setDemandValue((short) ((int)(zl*10)), index, new IWriteCallBack() { + @Override + public void onSuccess() { + + MessageLog.ShowInfo( "模拟物料下发成功!克数:"+ finalZl +"g"); + T.show(lsjy_activity.this, "模拟物料下发成功!克数:"+ finalZl +"g"); + DeviceData.Get().setChargeMixtureStart(new IWriteCallBack() { + @Override + public void onSuccess() { + MessageLog.ShowInfo( "开始出料!克数:"+ finalZl +"g"); + T.show(lsjy_activity.this, "开始出料!克数:"+ finalZl +"g"); + } + @Override + public void onFailure(String ErrorMsg) { + MessageLog.ShowInfo( "出料失败!克数:"+ finalZl +"g"); + T.show(lsjy_activity.this, "出料失败!克数:"+ finalZl +"g"); + } + }); + } + + @Override + public void onFailure(String ErrorMsg) { + MessageLog.ShowInfo( "模拟物料下发失败!"); + } + }); + break; } } //endregion diff --git a/app/src/main/java/com/example/bpa/view/from/pflb_activity.java b/app/src/main/java/com/example/bpa/view/from/pflb_activity.java index c7eeb6b..4b47271 100644 --- a/app/src/main/java/com/example/bpa/view/from/pflb_activity.java +++ b/app/src/main/java/com/example/bpa/view/from/pflb_activity.java @@ -80,7 +80,7 @@ public class pflb_activity extends AppCompatActivity implements View.OnClickList datatab= this.findViewById(R.id.datatab); //通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据 String msg=getIntent().getStringExtra("data"); - gongneng_title.setText(msg); + gongneng_title.setText("配方分组"); Initdata(); } diff --git a/app/src/main/res/layout/from/layout/activity_lsjy.xml b/app/src/main/res/layout/from/layout/activity_lsjy.xml index 330409b..bef9ef8 100644 --- a/app/src/main/res/layout/from/layout/activity_lsjy.xml +++ b/app/src/main/res/layout/from/layout/activity_lsjy.xml @@ -504,6 +504,36 @@ android:track="@drawable/switch_custom_track_selector"/> + + + +