diff --git a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java index 0dddd08e..8da08bb5 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java +++ b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java @@ -950,6 +950,8 @@ public class ConfigData { silo.warningValue=50; silo.silosmargin=0; silo.siloszl=1000; + silo.exp=item.ShowNum+""; + silo.bValue=5; BPA_SILOSANDMATERIAL sm = new BPA_SILOSANDMATERIAL(); sm.silosID = silo.id; sm.materialID = ""; diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java index 7d5d20b6..8561c1e5 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java @@ -231,20 +231,20 @@ public class ConfigName { * 奶茶机料仓模型 */ public List Silos_味魔方 = new ArrayList() {{ - add(new ResSilosModel("粉料仓", 1)); - add(new ResSilosModel("粉料仓", 2)); - add(new ResSilosModel("粉料仓", 3)); - add(new ResSilosModel("粉料仓", 4)); - add(new ResSilosModel("粉料仓", 5)); - add(new ResSilosModel("粉料仓", 6)); - add(new ResSilosModel("外置仓", 7)); - add(new ResSilosModel("外置仓", 8)); - add(new ResSilosModel("外置仓", 9)); - add(new ResSilosModel("外置仓", 10)); - add(new ResSilosModel("外置仓", 11)); - add(new ResSilosModel("外置仓", 12)); - add(new ResSilosModel("外置仓", 13)); - add(new ResSilosModel("外置仓", 14)); + add(new ResSilosModel("粉料仓",1 , 1 )); + add(new ResSilosModel("粉料仓",2 , 2 )); + add(new ResSilosModel("粉料仓",3 , 3 )); + add(new ResSilosModel("粉料仓",4 , 4 )); + add(new ResSilosModel("粉料仓",5 , 5 )); + add(new ResSilosModel("粉料仓",6 , 6 )); + add(new ResSilosModel("外置仓",7 , 7 )); + add(new ResSilosModel("外置仓",8 , 8 )); + add(new ResSilosModel("外置仓",9 , 9 )); + add(new ResSilosModel("外置仓",10, 10)); + add(new ResSilosModel("外置仓",11, 11)); + add(new ResSilosModel("外置仓",12, 12)); + add(new ResSilosModel("外置仓",13, 13)); + add(new ResSilosModel("外置仓",14, 14)); }}; @@ -500,18 +500,18 @@ public class ConfigName { * 奶茶机料仓模型 */ public List Silos_奶茶机 = new ArrayList() {{ - add(new ResSilosModel("液体仓", 1)); - add(new ResSilosModel("液体仓", 2)); - add(new ResSilosModel("液体仓", 3)); - add(new ResSilosModel("液体仓", 4)); - add(new ResSilosModel("液体仓", 5)); - add(new ResSilosModel("液体仓", 6)); - add(new ResSilosModel("液体仓", 7)); - add(new ResSilosModel("液体仓", 8)); - add(new ResSilosModel("液体仓", 9)); - add(new ResSilosModel("液体仓", 10)); - add(new ResSilosModel("果糖仓", 11)); - add(new ResSilosModel("果糖仓", 12)); + add(new ResSilosModel("液体仓",1 , 1 )); + add(new ResSilosModel("液体仓",2 , 2 )); + add(new ResSilosModel("液体仓",3 , 3 )); + add(new ResSilosModel("液体仓",4 , 4 )); + add(new ResSilosModel("液体仓",5 , 5 )); + add(new ResSilosModel("液体仓",6 , 6 )); + add(new ResSilosModel("液体仓",7 , 7 )); + add(new ResSilosModel("液体仓",8 , 8 )); + add(new ResSilosModel("液体仓",9 , 9 )); + add(new ResSilosModel("液体仓",10, 10)); + add(new ResSilosModel("果糖仓",11, 11)); + add(new ResSilosModel("果糖仓",12, 12)); }}; /** @@ -792,22 +792,22 @@ public class ConfigName { * 配料吧台料仓模型 */ public List Silos_配料吧台 = new ArrayList() {{ - add(new ResSilosModel("外置仓", 1)); - add(new ResSilosModel("外置仓", 2)); - add(new ResSilosModel("外置仓", 3)); - add(new ResSilosModel("外置仓", 4)); - add(new ResSilosModel("外置仓", 5)); - add(new ResSilosModel("外置仓", 6)); - add(new ResSilosModel("粉料仓", 7)); - add(new ResSilosModel("粉料仓", 8)); - add(new ResSilosModel("粉料仓", 9)); - add(new ResSilosModel("液料仓", 10)); - add(new ResSilosModel("液料仓", 11)); - add(new ResSilosModel("加热仓", 12)); - add(new ResSilosModel("加热仓", 13)); - add(new ResSilosModel("粉料仓", 14)); - add(new ResSilosModel("粉料仓", 15)); - add(new ResSilosModel("粉料仓", 16)); + add(new ResSilosModel("外置仓",1 , 1 )); + add(new ResSilosModel("外置仓",2 , 2 )); + add(new ResSilosModel("外置仓",3 , 3 )); + add(new ResSilosModel("外置仓",4 , 4 )); + add(new ResSilosModel("外置仓",5 , 5 )); + add(new ResSilosModel("外置仓",6 , 6 )); + add(new ResSilosModel("粉料仓",7 , 7 )); + add(new ResSilosModel("粉料仓",8 , 8 )); + add(new ResSilosModel("粉料仓",9 , 9 )); + add(new ResSilosModel("液料仓",13, 10)); + add(new ResSilosModel("液料仓",14, 11)); + add(new ResSilosModel("加热仓",15, 12)); + add(new ResSilosModel("加热仓",16, 13)); + add(new ResSilosModel("粉料仓",10, 14)); + add(new ResSilosModel("粉料仓",11, 15)); + add(new ResSilosModel("粉料仓",12, 16)); }}; /** diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java b/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java index 6d2aaf39..7d2f6510 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java @@ -29,6 +29,7 @@ import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.helper.MessageLog; import com.bonait.bnframework.common.helper.mode.OrderA; import com.bonait.bnframework.common.helper.mode.ResultA; +import com.bonait.bnframework.common.linktab.LinkMode; import com.bonait.bnframework.modules.home.adapter.loadinggood_adapter; import com.bonait.bnframework.modules.home.adapter.pfsx_adapter; import com.bonait.bnframework.modules.home.adapter.wdsz_adapter; @@ -38,6 +39,7 @@ import com.bonait.bnframework.modules.home.fragment.mode.tab_control; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -62,6 +64,39 @@ public class DataBus { //endregion //region 数据中心 + /** + * 料仓数据 + */ + public ArrayList SilosData = new ArrayList<>(); + /** + * 获取料仓数据 + */ + public void RefreshSilos() + { + ArrayList lcModes = DataBus.getInstance().ResGetLc(); + SilosData.clear(); + LinkedHashMap> map = new LinkedHashMap<>(); + for (lcMode item : lcModes) { + if (map.containsKey(item.name)) { + map.get(item.name).add(item); + } else { + List lc = new ArrayList<>(); + lc.add(item); + map.put(item.name, lc); + } + } + + /** + * 编例HashMap中所有key跟value的值 + */ + int i = 0; + for (Object key : map.keySet()) { + List value = map.get(key); + LinkMode linkMode = new LinkMode(key.toString(), value, i == 0 ? true : false); + SilosData.add(linkMode); + i++; + } + } /** * 获取料仓数据 diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/MessageName.java b/app/src/main/java/com/bonait/bnframework/common/constant/MessageName.java index da82be02..73dedf75 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/MessageName.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/MessageName.java @@ -32,4 +32,6 @@ public interface MessageName { String ClickSilos="ClickSilos";//点击料仓 + String RefreshSilos="RefreshSilos";//刷新料仓 + } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java index 8817e4e0..3cbfc95c 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java @@ -328,66 +328,6 @@ public class QueryDB { return data; } - /** - * 获取料仓数据 - * - * @return - */ - public static ArrayList GetSilos() { - ArrayList data = new ArrayList<>(); - //1.获取料仓数据 - ArrayList silos = GetSilosALL(); - //2.获取物料 - ArrayList materials = GetMaterialALL(); - //3.获取返回数据 - for (BPA_SILOS k : silos) { - ResSilosMode par = new ResSilosMode(); - par.id = k.id; - par.createTime = k.createTime; - par.updateTime = k.updateTime; - par.deleteTime = k.deleteTime; - par.deviceID = k.deviceID; - par.userID = k.userID; - par.isDelete = k.isDelete; - par.exp = k.exp; - - par.num = k.num; - par.name = k.name; - par.warningValue = k.warningValue; - par.thrsoleValue = k.thrsoleValue; - par.silosmargin = k.silosmargin; - par.siloszl = k.siloszl; - - par.plcValue = k.plcValue; - par.bValue = k.bValue; - par.jValue = k.jValue; - par.status = k.status; - par.Sort = k.Sort; - - ArrayList gx = GetMaterialList(k.id); - if (!gx.isEmpty() && gx.size() > 0) { - String wlid = gx.get(0); - if (!wlid.isEmpty()) { - BPA_MATERIAL wl = null; - for (BPA_MATERIAL m : materials) { - if (m.id.equals(wlid)) { - wl = m; - break; - } - } - if (wl != null) { - par.materialID = wl.id; - par.materialimgUrl = wl.imgUrl; - par.materialname = wl.name; - } - } - } - - par.dvalue = 0; - data.add(par); - } - return data; - } /** * 根据ID查询料仓管理 diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS.java index cad54c0e..38dfb59a 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS.java @@ -15,7 +15,7 @@ public class BPA_SILOS extends ModeBase { public int thrsoleValue; //PLC控制信号量 public String plcValue;// 20s - //满管 需要时间 例如 10s + //满管 需要时间 例如 10s //放大了10位 public int bValue; //校准值 实际校准值 public String jValue; //100 g diff --git a/app/src/main/java/com/bonait/bnframework/common/model/mode/ResSilosModel.java b/app/src/main/java/com/bonait/bnframework/common/model/mode/ResSilosModel.java index fef3b187..6639ddf5 100644 --- a/app/src/main/java/com/bonait/bnframework/common/model/mode/ResSilosModel.java +++ b/app/src/main/java/com/bonait/bnframework/common/model/mode/ResSilosModel.java @@ -6,9 +6,12 @@ public class ResSilosModel { public String name; public int num; - public ResSilosModel(String _name, int _val) + public int ShowNum; + + public ResSilosModel(String _name,int _ShowNum, int _val) { this.name=_name; this.num=_val; + this.ShowNum=_ShowNum; } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/liaochang_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/liaochang_adapter.java index 09d2a455..93732a4f 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/liaochang_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/liaochang_adapter.java @@ -66,7 +66,7 @@ public class liaochang_adapter extends RecyclerView.Adapter() { + ExecuteTheRecipe.OnScanTheCodeInformationT = new IRunT() { @Override public void Run(String msg) { @@ -448,29 +450,23 @@ public class MakeGoodFragment extends BaseFragment { String ggid = res[2];//A001,M002,T001 配方ids String ggids = "";//规格id集合 - String names=""; + String names = ""; - if( QueryDB.GetOrderthirdPartyIDIs(orderid)) - { - message="已有订单,重复扫码!"; + if (QueryDB.GetOrderthirdPartyIDIs(orderid)) { + message = "已有订单,重复扫码!"; mHandler.sendEmptyMessage(1); return; } int num = 1; try { num = Integer.parseInt(res[3]); - for(String item:ggid.split("[,]")) - { - for(ResGoodProperty k :DataBus.getInstance().bpa_goodproperties) - { - if(k.child!=null && k.child.size()>0) - { - for (ResGoodProperty chd:k.child) - { - if(chd.foreignKeyRe!=null && !chd.foreignKeyRe.isEmpty() && chd.foreignKeyRe.equals(item)) - { + for (String item : ggid.split("[,]")) { + for (ResGoodProperty k : DataBus.getInstance().bpa_goodproperties) { + if (k.child != null && k.child.size() > 0) { + for (ResGoodProperty chd : k.child) { + if (chd.foreignKeyRe != null && !chd.foreignKeyRe.isEmpty() && chd.foreignKeyRe.equals(item)) { ggids += chd.id + ","; - names+="/"+chd.name; + names += "/" + chd.name; } } } @@ -484,50 +480,47 @@ public class MakeGoodFragment extends BaseFragment { } catch (Exception ex) { } - BPA_GOODS good=QueryDB.GetGoodsforeignKeyId(goodid); - if(good==null) - { - message="没有查询到该商品!"; + BPA_GOODS good = QueryDB.GetGoodsforeignKeyId(goodid); + if (good == null) { + message = "没有查询到该商品!"; mHandler.sendEmptyMessage(1); - }else - { - BPA_GOODSRECIPENAME goodsrecipename = QueryDB.GetGoodsRecipeNameDesignId(ggids,good.id); + } else { + BPA_GOODSRECIPENAME goodsrecipename = QueryDB.GetGoodsRecipeNameDesignId(ggids, good.id); if (goodsrecipename != null) { BPA_ORDER order = new BPA_ORDER(); - order.thirdPartyID =orderid; + order.thirdPartyID = orderid; order.status = 0; order.deviceID = ConfigName.getInstance().DeviceId; order.userID = ConfigName.getInstance().user.userID; QueryDB.AddOrder(order); - for (int mm=0;mm lcModes = new ArrayList<>(); Activity activity; @Override @@ -89,7 +97,7 @@ public class SilosNewActivity extends BaseActivity { @Override public void clickListenerNew(View v, int k, Object data) { if (k == 0) { - InitData(); + MessageManager.getInstance().sendMessage(MessageName.RefreshSilos,"RefreshSilos"); add_yijian.setVisibility(View.GONE); } else if (k == 1) { } else if (k == 2) { @@ -118,7 +126,7 @@ public class SilosNewActivity extends BaseActivity { @Override public void clickListenerNew(View v, int k, Object data) { if (k == 0) { - InitData(); + MessageManager.getInstance().sendMessage(MessageName.RefreshSilos,"RefreshSilos"); add_silos.setVisibility(View.GONE); } else if (k == 1) { ToastUtils.info("补充原料成功!!!"); @@ -147,7 +155,7 @@ public class SilosNewActivity extends BaseActivity { @Override public void clickListenerNew(View v, int k, Object data) { if (k == 0) { - InitData(); + MessageManager.getInstance().sendMessage(MessageName.RefreshSilos,"RefreshSilos"); silos_jz.setVisibility(View.GONE); } } @@ -155,65 +163,30 @@ public class SilosNewActivity extends BaseActivity { } //list 界面 - public List Fdata = new ArrayList<>(); - /** * 初始化数据 */ public void InitData() { - lcModes = DataBus.getInstance().ResGetLc(); - Fdata.clear(); - LinkedHashMap> map = new LinkedHashMap<>(); - for (lcMode item : lcModes) { - if (map.containsKey(item.name)) { - map.get(item.name).add(item); - } else { - List lc = new ArrayList<>(); - lc.add(item); - map.put(item.name, lc); - } - } - /** - * 编例HashMap中所有key跟value的值 - */ - int i = 0; - for (Object key : map.keySet()) { - List value = map.get(key); - LinkMode linkMode = new LinkMode(key.toString(), value, i == 0 ? true : false); - Fdata.add(linkMode); - i++; - } + //1.刷新料仓 + DataBus.getInstance().RefreshSilos(); QMUIFragmentPagerAdapter adapter = new QMUIFragmentPagerAdapter(getSupportFragmentManager()) { @Override public int getCount() { - return Fdata.size(); + return DataBus.getInstance().SilosData.size(); } - @Override public QMUIFragment createFragment(int position) { - //显示数元 Silos_item_fragment fragment = new Silos_item_fragment(); - fragment.SetData(Fdata.get(position).content); + fragment.SetData(position); return fragment; } - @Override public CharSequence getPageTitle(int position) { - return Fdata.get(position).type.toString(); + return DataBus.getInstance().SilosData.get(position).type.toString(); } }; viewpager_silos.setAdapter(adapter); tabs.setupWithViewPager(viewpager_silos, true); -// tabs.selectTab(0); -// viewpager_silos.setCurrentItem(0); - adapter.notifyDataSetChanged(); - - -// for (int l=0;l Types = new ArrayList<>(); + /** + * 当前物料数据 + */ + public ArrayList resMaterilas = new ArrayList<>(); + /** + * 属性数据 + */ + ArrayList bpa_goodproperties = new ArrayList<>(); + /** + * 确定文本和取消文本的显示内容 + */ + private String yesStr; + /** + * 取消按钮 + */ + public Button close_from, xinjian; + /** + * 图片 + */ + public ImageView cpfm; + /** + * 文本输入框 + */ + + public EditText edittext, edittext1,edittext_wl; + /** + * 商品分类 + */ + public Spinner editsp_fl; + + /** + * 点击事件 + */ + public MyClickListener mListener = null; + private View root; + + + @BindView(R.id.datatab_pf) + ListView datatab_pf; + + + @BindView(R.id.recycler_view_wl_click) + RecyclerView recycler_view_wl_click; + + public BPA_GOODSRECIPENAME bpaGoodsrecipename=null; + + @BindView(R.id.edittext_pfmingc) + EditText edittext_pfmingc;//配方名称 + @BindView(R.id.datatab_sx) + RecyclerView datatab_sx; + @BindView(R.id.datatab_xxpf) + ListView datatab_xxpf; + + //endregion + + //region 私例 + public GoodInformation(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + root = LayoutInflater.from(context).inflate(R.layout.dialog_gooddetails, this); + ButterKnife.bind(this, root); + } + //endregion + + //region 数据校准 + + /** + * 数据验证 + * + * @return + */ + public boolean DataVerification() { + boolean IsSucees = false; + try { + if (edittext.getText().toString().isEmpty()) { + ToastUtils.info("名称不能为空!"); + return false; + } + boolean issc = false; + GetWuLiaoSelect(resMaterilas); + + //resMaterilas + if (issc == false) { + ToastUtils.info("必须选择一个物料!"); + return false; + } + return true; + } catch (Exception ex) { + ToastUtils.error("数据验证异常!" + ex.getMessage()); + return IsSucees; + } + } + //endregion + + //region 初始化设置数据 + /** + * 数据接口:商品数据 + */ + public BPA_GOODS Data = null; + /** + * 上一层界面 + */ + Activity activity_ma=null; + /** + * 图片URL + */ + public String url = ""; + /** + * 商品类别分类 + */ + Map map_fl = new LinkedHashMap<>(); + + /** + * 从外界Activity为Dialog 设置数据 + * + * @param data + */ + public void setData(String str, BPA_GOODS data, ArrayList types, Activity activity,ArrayList properties) { + if (str != null) { + yesStr = str; + } + Data = data; + Types = types; + activity_ma = activity; + + for (ResGoodProperty pro:properties) + { + if(pro.GoodsTypeId!=null && !pro.GoodsTypeId.isEmpty()) + { + if(pro.GoodsTypeId.contains(Data.goodtype)) + { + bpa_goodproperties.add(pro); + } + }else + { + bpa_goodproperties.add(pro); + } + } + + //初始化界面控件 + initView(); + //初始化界面数据 + initData(); + //初始化界面控件的事件 + initEvent(); + //初始化配方 + Initdata_pf(); + } + //endregion + + //region 初始化函数 + /** + * 初始化界面控件 + */ + private void initView() { + close_from = (Button) findViewById(R.id.close_from); + xinjian = (Button) findViewById(R.id.xinjian); + cpfm = findViewById(R.id.cpfm); + + edittext = findViewById(R.id.edittext); + edittext1 = findViewById(R.id.edittext1); + editsp_fl = findViewById(R.id.editsp_fl); + edittext_wl = findViewById(R.id.edittext_wl); + } + + /** + * 初始化界面控件的显示数据 + */ + private void initData() { + + map_fl.clear(); + for (BPA_GOODSTYPE item : Types) { + map_fl.put(item.name, item.id); + } + SetAdapter(editsp_fl, map_fl); + //如果设置按钮的文字 + if (yesStr != null) { + xinjian.setText(yesStr); + } + + //数据不为空 那么就是修改 + if (Data != null) { + edittext.setText(Data.name); + edittext1.setText(Data.foreignKeyRe); + new MyBitmapUtils().disPlay(cpfm, Data.url); + url = Data.url; + int index = 0; + for (Map.Entry entry : map_fl.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + if (value.equals(Data.goodtype)) { + editsp_fl.setSelection(index); + } + index++; + } + } else { + edittext.setText(""); + edittext1.setText(""); + new MyBitmapUtils().disPlay(cpfm, ""); + url = ""; + } + + //查询物料数据 + ArrayList materials = QueryDB.GetMaterialALL(); + + + if (materials != null && materials.size() > 0) { + resMaterilas.clear(); + for (BPA_MATERIAL item : materials) { + ResMaterilas mk = new ResMaterilas(); + mk.name = item.name; + mk.id = item.id; + mk.isSelect = false; + if (Data != null && !Data.materialids.isEmpty()) { + if (Data.materialids.contains(item.id)) { + mk.isSelect = true; + } + } + resMaterilas.add(mk); + } + } + GetWuLiaoSelect(resMaterilas); + + MyLayoutManager layout = new MyLayoutManager(); + layout.setAutoMeasureEnabled(true); + recycler_view_wl_click.setLayoutManager(layout); + newneatril_adapter adapter = new newneatril_adapter(getContext(), QueryDB.GetMaterialALL(), new MyClickListener() { + @Override + public void clickListener(View v, Object data) { + BPA_MATERIAL m=(BPA_MATERIAL)data; + + ResGoodsRecipe cipe=new ResGoodsRecipe(); + cipe.sort=0; + cipe.materialID=m.id; + cipe.materialName=m.name; + cipe.value="0"; + if (DataBus.getInstance().Recipe==null) + { + DataBus.getInstance().Recipe=new ArrayList<>(); + } + DataBus.getInstance().Recipe.add(cipe); + + if(adapter4!=null) + { + adapter4.notifyDataSetChanged(); + } + } + + @Override + public void clickListenerNew(View v, int k, Object data) { + + } + }); + recycler_view_wl_click.setAdapter(adapter); + + +// MyLayoutManager layout = new MyLayoutManager(); +// layout.setAutoMeasureEnabled(true); +// recycler_view_wl.setLayoutManager(layout); +// newmeatrilselect_adapter adapter = new newmeatrilselect_adapter(getContext(), resMaterilas); +// recycler_view_wl.setAdapter(adapter); + } + + xxpf_adapter adapter4=null; + public void InitTab() + { + DataBus.getInstance().Recipe.clear(); + if(bpaGoodsrecipename!=null) + { + DataBus.getInstance().Recipe = QueryDB.GetGoodsSreciperecipeList(bpaGoodsrecipename.id); + + }else + { + for(BPA_MATERIAL wl:resMaterilas) + { + if(Data.materialids!=null && !Data.materialids.isEmpty() && Data.materialids.contains(wl.id)) + { + ResGoodsRecipe cipe=new ResGoodsRecipe(); + cipe.sort=0; + cipe.materialID=wl.id; + cipe.materialName=wl.name; + cipe.value="0"; + cipe.goodsID=Data.id; + DataBus.getInstance().Recipe.add(cipe); + } + } + } + + if( DataBus.getInstance().Recipe==null) + { + DataBus.getInstance().Recipe=new ArrayList<>(); + } + adapter4= new xxpf_adapter(getContext(), R.layout.xxpf_item, DataBus.getInstance().Recipe,this); + datatab_pf.setAdapter(adapter4); + } + + + /** + * 初始化界面的确定和取消监听器 + */ + private void initEvent() { + /** + * 设置确定按钮被点击后,向外界提供监听 + */ + xinjian.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (DataVerification()) { + + ArrayList goods = QueryDB.GetGoodsALL(); + if (Data == null)//新增 + { + boolean isSucess = QueryDB.GetGoodsIs(edittext.getText().toString()); + if (isSucess) { + ToastUtils.info("菜谱名称已存在!"); + return; + } + Data = new BPA_GOODS(); + Data.name = edittext.getText().toString(); + Data.status = 1; + Data.sort = goods.size() + 1; + Data.maketime = 180; + Data.issc = 1; + Data.url = url; + Data.foreignKeyRe = edittext1.getText().toString(); + Data.goodtype = map_fl.get(editsp_fl.getSelectedItem().toString()); + Data.materialids = ids; + QueryDB.AddGoods(Data); + if (mListener != null) { + mListener.clickListenerNew(v, 1, Data); + } + } else //修改 + { + Data.name = edittext.getText().toString(); + Data.status = 1; + Data.sort = goods.size() + 1; + Data.maketime = 180; + Data.issc = 1; + Data.url = url; + Data.foreignKeyRe = edittext1.getText().toString(); + Data.goodtype = map_fl.get(editsp_fl.getSelectedItem().toString()); + Data.materialids = ids; + QueryDB.UpdateGoods(Data); + if (mListener != null) { + mListener.clickListenerNew(v, 1, Data); + } + } + + } + } + }); + /** + * 关闭窗体 + */ + close_from.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mListener != null) { + mListener.clickListenerNew(v, 0, null); + } + } + }); + /** + * 选择图片资源 + */ + cpfm.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(getContext(), ImageChooseActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + activity_ma.startActivity(intent); + } + }); + /** + * 图标选择之后 + */ + MessageManager.getInstance().registerMessageReceiver(activity_ma, MessageName.ClickImage, new MessageLooper.OnMessageListener() { + @Override + public void onMessage(Object msg) { + if (msg != null) { + url = (String) msg; + new MyBitmapUtils().disPlay(cpfm, url); + } + } + }); + + /** + * 下拉框选择之后 + */ + edittext_wl.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + checkboxEdit(edittext_wl); + } + }); + + MessageManager.getInstance().registerMessageReceiver(activity_ma, MessageName.ClickProperty, new MessageLooper.OnMessageListener() { + @Override + public void onMessage(Object msg) { + if (msg != null) { + activity_ma.runOnUiThread(new Runnable() { + @Override + public void run() { + try { + edittext_pfmingc.setText(GetSelectName()); + } catch (Exception e) { + + } + } + }); + } + } + }); + } + + /** + * 初始化配方 + */ + public void Initdata_pf() + { + if(Data!=null) + { + //根据商品查询配方 + ArrayList goodsrecipenames=QueryDB.GetGoodsRecipeNameGoodId(Data.id); + goodpf_apapter adapter = new goodpf_apapter(getContext(), R.layout.wl_item, goodsrecipenames, this); + datatab_pf.setAdapter(adapter); + } + } + //endregion + + //region 界面事件 + /** + * 设置下拉框 + * @param spinner + * @param map + */ + public void SetAdapter(Spinner spinner, Map map) { + ArrayAdapter adapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(map.keySet())); + adapter.setDropDownViewResource(R.layout.spinner_dropdown_item); + spinner.setAdapter(adapter); + } + + /** + * 多选下拉框 + */ + private void checkboxEdit(EditText edit) { + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + builder.setTitle("物料列表"); + DialogInterface.OnMultiChoiceClickListener multiChoiceClickListener = new DialogInterface.OnMultiChoiceClickListener() { + @Override + public void onClick(DialogInterface dialog, int i, boolean isChecked) { + resMaterilas.get(i).isSelect= isChecked; + } + }; + + // 下拉项选中状态 + boolean[] selected = new boolean[resMaterilas.size()]; + // 下拉框数据源 + String[] str = new String[resMaterilas.size()]; + + for (int i = 0; i < resMaterilas.size(); i++) { + str[i] = resMaterilas.get(i).name; + selected[i] = resMaterilas.get(i).isSelect; + } + + builder.setMultiChoiceItems(str, selected, multiChoiceClickListener); + DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + GetWuLiaoSelect(resMaterilas); + edit.setText(names); + } + }; + builder.setCancelable(false); + builder.setNegativeButton("取消", null); + builder.setPositiveButton("确定", clickListener); + AlertDialog dialog = builder.create(); + dialog.show(); + } + + public String ids = ""; + public String names=""; + + /** + * 获取物料选择 + */ + public void GetWuLiaoSelect(ArrayList materilas) + { + ids = "";names=""; + for (ResMaterilas item:materilas) + { + if (item.isSelect) { + if (TextUtils.isEmpty(names)) { + names = names + item.name; + ids = ids + item.id; + } else { + names = names + "," + item.name; + ids = ids + "," + item.id; + } + } + } + edittext_wl.setText(names); + } + + /** + * 获取选中名称 + * @return + */ + public String GetSelectName() + { + String names=Data.name+"_"; + for(ResGoodProperty item:bpa_goodproperties) + { + for(ResGoodProperty k:item.child) + { + if(k.isSelect) + { + names+=k.name+"_"; + } + } + } + return names.substring(0, names.length() - 1); + } + + /** + * 点击事件 + * + * @param v + * @param data + */ + @Override + public void clickListener(View v, Object data) { + switch (v.getId()) { + case R.id.button_update://点击 修改 + bpaGoodsrecipename =(BPA_GOODSRECIPENAME)data; + break; + case R.id.button_item://删除按钮 + ArrayList re= QueryDB.GetGoodsSreciperecipeList(((BPA_GOODSRECIPENAME) data).id); + for(ResGoodsRecipe item:re) + { + QueryDB.DeleteGoodsSrecipe(item); + } + QueryDB.DeleteGoodsRecipeName((BPA_GOODSRECIPENAME) data); + Initdata_pf(); + ToastUtils.info("删除成功"); + break; + } + } + + @Override + public void clickListenerNew(View v, int k, Object data) { + + } + //endregion +} diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/Silos_item_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/Silos_item_fragment.java index bac0c4b9..14917908 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/Silos_item_fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/Silos_item_fragment.java @@ -14,8 +14,11 @@ import android.view.View; import com.bonait.bnframework.R; import com.bonait.bnframework.common.base.BaseFragment; import com.bonait.bnframework.common.constant.DataBus; +import com.bonait.bnframework.common.constant.MessageName; import com.bonait.bnframework.common.db.res.lcMode; import com.bonait.bnframework.common.linktab.LinkMode; +import com.bonait.bnframework.common.message.MessageLooper; +import com.bonait.bnframework.common.message.MessageManager; import com.bonait.bnframework.common.view.MyLayoutManager; import com.bonait.bnframework.modules.home.adapter.liaochang_adapter; import com.orhanobut.logger.Logger; @@ -46,39 +49,43 @@ public class Silos_item_fragment extends BaseFragment { super.onViewCreated(view, savedInstanceState); Logger.d("我的fragment创建"); InitView(); + InitEvent(); } - public List dataA=null; - public void SetData(List data) + + //当前集合数据 + public int index = -1; + + public void SetData(int _index) { + index = _index; + } + + public void InitEvent() { - dataA=data; + MessageManager.getInstance().registerMessageReceiver(getActivity(), MessageName.RefreshSilos, new MessageLooper.OnMessageListener() { + @Override + public void onMessage(Object msg) { + if (msg != null) { + DataBus.getInstance().RefreshSilos(); + InitView(); + } + } + }); } + /** * 初始化界面 */ public void InitView() { - if(dataA!=null) - { -// -// LinearLayoutManager layoutManager = new LinearLayoutManager(context ); -// recycler_view_lll.setLayoutManager(layoutManager); - - // 创建一个LinearLayoutManager对象 -// LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); -// -// MyLayoutManager layout = new MyLayoutManager(); -// layout.setAutoMeasureEnabled(true); -// + if (index != -1) { StaggeredGridLayoutManager layout11 = new StaggeredGridLayoutManager - (4,StaggeredGridLayoutManager.VERTICAL); - + (4, StaggeredGridLayoutManager.VERTICAL); recycler_view_lll.setLayoutManager(layout11); - liaochang_adapter adapter = new liaochang_adapter(context,dataA); + liaochang_adapter adapter = new liaochang_adapter(context, DataBus.getInstance().SilosData.get(index).content); recycler_view_lll.setAdapter(adapter); adapter.notifyDataSetChanged(); } - } @Override diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_ck.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_ck.java index c18c5c66..2bbb2a73 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_ck.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_ck.java @@ -88,6 +88,9 @@ public class add_silos_ck extends LinearLayout { @BindView(R.id.control_switch_shoudong) Button control_switch_shoudong; + @BindView(R.id.control_huishou) + Button control_huishou; + @BindView(R.id.liaochang_sz) RelativeLayout liaochang_sz; @@ -359,12 +362,35 @@ public class add_silos_ck extends LinearLayout { return false; } }); + + control_huishou.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + Log.e("鼠标", "按下: "); + ExecuteTheRecipe.WritePLC("手自切换", false, new IWriteCallBack() { + @Override + public void onSuccess() { + ExecuteTheRecipe.WritePLC("M_外置仓" + lcMode.num + "反转", true, null); + } + @Override + public void onFailure(String ErrorMsg) { + } + }); + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + Log.e("鼠标", "松开: "); + ExecuteTheRecipe.WritePLC("M_外置仓" + lcMode.num + "反转", false, null); + } + return false; + } + }); + control_switch.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(SwitchButton view, boolean isChecked) { //设置 - lcMode.status=isChecked?0:1; - QueryDB.UpdateSilosStatus(lcMode.id,isChecked); + lcMode.status = isChecked ? 0 : 1; + QueryDB.UpdateSilosStatus(lcMode.id, isChecked); } }); } @@ -373,9 +399,16 @@ public class add_silos_ck extends LinearLayout { public void SetData(lcMode _good) { lcMode = _good; - control_switch.setChecked(_good.status==0?true:false); + control_switch.setChecked(_good.status == 0 ? true : false); title.setText("查看料仓-(" + lcMode.name + ")"); - xuhao.setText(lcMode.num + ""); + xuhao.setText(lcMode.exp + ""); + + if (lcMode.name.equals("外置仓")) { + control_huishou.setVisibility(View.VISIBLE); + } else { + control_huishou.setVisibility(View.GONE); + } + name.setText(lcMode.materialName.isEmpty() ? "未设置" : (lcMode.materialName + "")); if (lcMode.materialName.isEmpty() || lcMode.materialName.equals("未设置")) { wuliaoimage.setImageResource(R.mipmap.newsilos); @@ -417,7 +450,7 @@ public class add_silos_ck extends LinearLayout { long elapsedMillis = SystemClock.elapsedRealtime() - runtime.getBase(); runtime.stop(); - int time=(int) (elapsedMillis / 1000); - return time;//当前点击多少秒 + int time = (int) (elapsedMillis / 1000); + return time;//当前点击多少秒 } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_yijian_controlextends.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_yijian_controlextends.java index 07d8da20..0173301d 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_yijian_controlextends.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_yijian_controlextends.java @@ -2,6 +2,7 @@ package com.bonait.bnframework.modules.home.fragment.mode; import android.content.Context; import android.os.Handler; +import android.os.Looper; import android.os.Message; import android.os.SystemClock; import android.util.AttributeSet; @@ -288,7 +289,7 @@ public class add_yijian_controlextends extends LinearLayout { { int time=item.bValue<=0?5:item.bValue;//默认5秒 ExecuteTheRecipe.WritePLC("手动控制"+item.num,true,null); - new Handler().postDelayed(new Runnable() { + new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { @Override public void run() { ExecuteTheRecipe.WritePLC("手动控制"+item.num,false,null); diff --git a/app/src/main/res/layout/activity_goodpeifang.xml b/app/src/main/res/layout/activity_goodpeifang.xml index a200f66b..cf228b56 100644 --- a/app/src/main/res/layout/activity_goodpeifang.xml +++ b/app/src/main/res/layout/activity_goodpeifang.xml @@ -97,7 +97,6 @@ app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" android:layout_height="match_parent"/> - + android:text="商品封面" + android:textSize="18dp"/> + android:text="商品名称:" + android:textSize="18dp"/> + android:textSize="18dp" /> + android:text="商品外键:" + android:textSize="18dp"/> + android:textSize="18dp" /> + android:layout_height="30dp"> + android:layout_height="30dp" + android:text="商品分类:" + android:textSize="18dp"/> + android:layout_centerVertical="true" + android:textSize="18dp"/> diff --git a/app/src/main/res/layout/item/layout/dialog_add_pf.xml b/app/src/main/res/layout/item/layout/dialog_add_pf.xml index afc23ebc..bcb7d386 100644 --- a/app/src/main/res/layout/item/layout/dialog_add_pf.xml +++ b/app/src/main/res/layout/item/layout/dialog_add_pf.xml @@ -87,7 +87,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="配方名称:" - android:textSize="16dp"/> + android:textSize="18dp"/> + android:textSize="18dp" /> diff --git a/app/src/main/res/layout/item/layout/dialog_add_pf_home.xml b/app/src/main/res/layout/item/layout/dialog_add_pf_home.xml index 9f5dee3e..5e3a8acc 100644 --- a/app/src/main/res/layout/item/layout/dialog_add_pf_home.xml +++ b/app/src/main/res/layout/item/layout/dialog_add_pf_home.xml @@ -70,7 +70,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="商品分类" - android:textSize="@dimen/text_size_16"/> + android:textSize="18dp"/> + android:textColor="@color/tab_text_normal" + android:textSize="18dp"/> @@ -91,7 +92,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="商品配方" - android:textSize="@dimen/text_size_16"/> + android:textSize="18dp"/> diff --git a/app/src/main/res/layout/item/layout/dialog_add_silos_ck.xml b/app/src/main/res/layout/item/layout/dialog_add_silos_ck.xml index a6e21c4c..df33e1d0 100644 --- a/app/src/main/res/layout/item/layout/dialog_add_silos_ck.xml +++ b/app/src/main/res/layout/item/layout/dialog_add_silos_ck.xml @@ -146,6 +146,18 @@ android:text="出料" android:textColor="@color/white" android:textSize="18sp"/> + +