From d8e58c07ebdf3e21831fea3ae249b625998e5c04 Mon Sep 17 00:00:00 2001 From: fyf Date: Mon, 24 Apr 2023 12:25:25 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=85=8D=E6=96=B9=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/bpa/config/MessageName.java | 12 + .../main/java/com/example/bpa/db/QueryDB.java | 1260 +++++++++-------- .../example/bpa/view/adapter/pf_adapter.java | 108 +- .../example/bpa/view/adapter/sp_adapter.java | 13 + .../bpa/view/from/add_pf_activity.java | 69 +- .../example/bpa/view/from/yfpf_activity.java | 60 +- .../res/layout/datatab/layout/pf_item.xml | 8 +- .../res/layout/datatab/layout/sp_item.xml | 13 +- 8 files changed, 918 insertions(+), 625 deletions(-) create mode 100644 app/src/main/java/com/example/bpa/config/MessageName.java diff --git a/app/src/main/java/com/example/bpa/config/MessageName.java b/app/src/main/java/com/example/bpa/config/MessageName.java new file mode 100644 index 0000000..9212624 --- /dev/null +++ b/app/src/main/java/com/example/bpa/config/MessageName.java @@ -0,0 +1,12 @@ +package com.example.bpa.config; + +/** + * 消息名称管理枚举 + */ +public enum MessageName { + + Common,//通用消息 + PF_From_Close,//配方界面关闭通知 + + Click +} 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 c676d23..0551236 100644 --- a/app/src/main/java/com/example/bpa/db/QueryDB.java +++ b/app/src/main/java/com/example/bpa/db/QueryDB.java @@ -43,1016 +43,1070 @@ public class QueryDB { /** * 数据库链接 */ - private static DBHelper helper=DBHelper.getInstance(ConfigName.getInstance().dishesCon); + private static DBHelper helper = DBHelper.getInstance(ConfigName.getInstance().dishesCon); /** * 时间倒序 */ - public static String Desc_Time_Down="createTime desc"; + public static String Desc_Time_Down = "createTime desc"; /** * 时间正序 */ - public static String Desc_Time_Up="createTime"; + public static String Desc_Time_Up = "createTime"; /** * 排序、优先顺序 */ - public static String Desc_Sort_Up="Sort"; + public static String Desc_Sort_Up = "Sort"; //endregion //region BPA_MATERIAL 物料表 + /** * 新增物料数据 * add fengyoufu 20230413 + * * @param data 物料数据 * @return 是否成功 */ - public static boolean AddMaterial(BPA_MATERIAL data) - { - return Add(BPA_MATERIAL.class,data); + public static boolean AddMaterial(BPA_MATERIAL data) { + + return Add(BPA_MATERIAL.class, data); } + /** * 修改物料数据 * add fengyoufu 20230413 + * * @param data */ - public static void UpdateMaterial(BPA_MATERIAL data) - { - Update(BPA_MATERIAL.class,data); + public static void UpdateMaterial(BPA_MATERIAL data) { + Update(BPA_MATERIAL.class, data); } + /** * 删除物料数据 * add fengyoufu 20230413 + * * @param data 物料数据 * @return 是否成功 */ - public static boolean DeleteMaterial(BPA_MATERIAL data) - { - return Delete(BPA_MATERIAL.class,data.id); + public static boolean DeleteMaterial(BPA_MATERIAL data) { + return Delete(BPA_MATERIAL.class, data.id); } + /** * 获取所有物料信息 + * * @return */ - public static ArrayList GetMaterialALL() - { - String orderby=Desc_Time_Up;//出料顺序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_MATERIAL.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_MATERIAL)k); + public static ArrayList GetMaterialALL() { + String orderby = Desc_Time_Up;//出料顺序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_MATERIAL.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_MATERIAL) k); } return data; } /** * 判断物料数据是否存在 + * * @param name * @return */ - public static boolean GetMaterialIs(String name) - { - boolean isSucess=false; - String orderby=Desc_Time_Up;//出料顺序 - String where="isDelete=? and name=?"; - String[] args=new String[] { "0" ,name}; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_MATERIAL.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_MATERIAL)k); + public static boolean GetMaterialIs(String name) { + boolean isSucess = false; + String orderby = Desc_Time_Up;//出料顺序 + String where = "isDelete=? and name=?"; + String[] args = new String[]{"0", name}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_MATERIAL.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_MATERIAL) k); } - return data.size()>0; + return data.size() > 0; } /** * 物料ID查询物料信息 + * * @param id * @return */ - public static BPA_MATERIAL GetMaterialID(String id) - { - BPA_MATERIAL bpa_material=null; - 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_MATERIAL.class,where,args,orderby); - for (Object k:obj) { - bpa_material=(BPA_MATERIAL)k; + public static BPA_MATERIAL GetMaterialID(String id) { + BPA_MATERIAL bpa_material = null; + 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_MATERIAL.class, where, args, orderby); + for (Object k : obj) { + bpa_material = (BPA_MATERIAL) k; } return bpa_material; } //endregion //region BPA_SILOS 料仓管理表 + /** * 新增料仓管理 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean AddSilos(BPA_SILOS data) - { - return Add(BPA_SILOS.class,data); + public static boolean AddSilos(BPA_SILOS data) { + return Add(BPA_SILOS.class, data); } + /** * 修改料仓管理 * add fengyoufu 20230413 + * * @param data */ - public static void UpdateSilos(BPA_SILOS data) - { - Update(BPA_SILOS.class,data); + public static void UpdateSilos(BPA_SILOS data) { + Update(BPA_SILOS.class, data); } + /** * 删除料仓管理 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean DeleteSilos(BPA_SILOS data) - { - return Delete(BPA_SILOS.class,data.id); + public static boolean DeleteSilos(BPA_SILOS data) { + return Delete(BPA_SILOS.class, data.id); } + /** * 获取所有料仓管理 + * * @return */ - public static ArrayList GetSilosALL() - { - String orderby=Desc_Sort_Up+','+Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_SILOS.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_SILOS)k); + public static ArrayList GetSilosALL() { + String orderby = Desc_Sort_Up + ',' + Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_SILOS.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_SILOS) k); } return data; } + /** * 获取料仓数据 + * * @return */ - public static ArrayList GetSilos() - { - ArrayList data=new ArrayList<>(); + public static ArrayList GetSilos() { + ArrayList data = new ArrayList<>(); //1.获取料仓数据 - ArrayList silos=GetSilosALL(); + ArrayList silos = GetSilosALL(); //2.获取物料 - ArrayList materials= GetMaterialALL(); + 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.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; - } - } + 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.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; + par.dvalue = 0; data.add(par); } return data; } + /** * 根据ID查询料仓管理 + * * @return */ - public static BPA_SILOS GetSilosID(String id) - { - BPA_SILOS data=null; - String orderby=Desc_Sort_Up+','+Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=? and id=?"; - String[] args=new String[] { "0",id }; - ArrayList obj=Get(BPA_SILOS.class,where,args,orderby); - for (Object k:obj) { - data=(BPA_SILOS)k; + public static BPA_SILOS GetSilosID(String id) { + BPA_SILOS data = null; + String orderby = Desc_Sort_Up + ',' + Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=? and id=?"; + String[] args = new String[]{"0", id}; + ArrayList obj = Get(BPA_SILOS.class, where, args, orderby); + for (Object k : obj) { + data = (BPA_SILOS) k; } return data; } /** * 修改校准值 + * * @param id * @param data */ - public static void UpdateJYZ(String id, int data) - { - BPA_SILOS silos= GetSilosID(id); - if(silos!=null) - { - silos.jValue=data; - Update(BPA_SILOS.class,silos); + public static void UpdateJYZ(String id, int data) { + BPA_SILOS silos = GetSilosID(id); + if (silos != null) { + silos.jValue = data; + Update(BPA_SILOS.class, silos); } } //endregion //region BPA_SILOSANDMATERIAL 料仓物料关联表 + /** * 新增料仓物料关联 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean AddSilosAndMaterial(BPA_SILOSANDMATERIAL data) - { - return Add(BPA_SILOSANDMATERIAL.class,data); + public static boolean AddSilosAndMaterial(BPA_SILOSANDMATERIAL data) { + return Add(BPA_SILOSANDMATERIAL.class, data); } + /** * 修改料仓物料关联 * add fengyoufu 20230413 + * * @param data */ - public static void UpdateSilosAndMaterial(BPA_SILOSANDMATERIAL data) - { - Update(BPA_SILOSANDMATERIAL.class,data); + public static void UpdateSilosAndMaterial(BPA_SILOSANDMATERIAL data) { + Update(BPA_SILOSANDMATERIAL.class, data); } + /** * 删除料仓物料关联 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean DeleteSilosAndMaterial(BPA_SILOSANDMATERIAL data) - { - return Delete(BPA_SILOSANDMATERIAL.class,data.id); + public static boolean DeleteSilosAndMaterial(BPA_SILOSANDMATERIAL data) { + return Delete(BPA_SILOSANDMATERIAL.class, data.id); } + /** * 获取所有料仓物料关联 + * * @return */ - public static ArrayList GetSilosAndMaterialALL() - { - String orderby=Desc_Sort_Up+','+Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_SILOSANDMATERIAL.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_SILOSANDMATERIAL)k); + public static ArrayList GetSilosAndMaterialALL() { + String orderby = Desc_Sort_Up + ',' + Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_SILOSANDMATERIAL.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_SILOSANDMATERIAL) k); } return data; } + /** * 根据料仓id查询物料 + * * @param id * @return */ - public static ArrayList GetMaterialList(String id) - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=? and silosID=?"; - String[] args=new String[] { "0",id }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_SILOSANDMATERIAL.class,where,args,orderby); - for (Object k:obj) { - data.add(((BPA_SILOSANDMATERIAL)k).materialID); + public static ArrayList GetMaterialList(String id) { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=? and silosID=?"; + String[] args = new String[]{"0", id}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_SILOSANDMATERIAL.class, where, args, orderby); + for (Object k : obj) { + data.add(((BPA_SILOSANDMATERIAL) k).materialID); } return data; } //endregion //region BPA_GOODS 商品表 + /** * 新增商品表 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean AddGoods(BPA_GOODS data) - { - return Add(BPA_GOODS.class,data); + public static boolean AddGoods(BPA_GOODS data) { + return Add(BPA_GOODS.class, data); } + /** * 修改商品 * add fengyoufu 20230413 + * * @param data */ - public static void UpdateGoods(BPA_GOODS data) - { - Update(BPA_GOODS.class,data); + public static void UpdateGoods(BPA_GOODS data) { + Update(BPA_GOODS.class, data); } + /** * 删除商品 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean DeleteGoods(BPA_GOODS data) - { - return Delete(BPA_GOODS.class,data.id); + public static boolean DeleteGoods(BPA_GOODS data) { + return Delete(BPA_GOODS.class, data.id); } + /** * 获取所有商品 + * * @return */ - public static ArrayList GetGoodsALL() - { - String orderby=Desc_Sort_Up+','+Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_GOODS.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_GOODS)k); + public static ArrayList GetGoodsALL() { + String orderby = Desc_Sort_Up + ',' + Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_GOODS.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_GOODS) k); } return data; } + /** * 判断商品数据是否存在 + * * @param name * @return */ - public static boolean GetGoodsIs(String name) - { - boolean isSucess=false; - String orderby=Desc_Time_Up;//出料顺序 - String where="isDelete=? and name=?"; - String[] args=new String[] { "0" ,name}; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_GOODS.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_GOODS)k); + public static boolean GetGoodsIs(String name) { + boolean isSucess = false; + String orderby = Desc_Time_Up;//出料顺序 + String where = "isDelete=? and name=?"; + String[] args = new String[]{"0", name}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_GOODS.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_GOODS) k); } - return data.size()>0; + return data.size() > 0; } /** * 根据排序查询商品 + * * @param sort * @return */ - public static BPA_GOODS GetGoodsSortIs(int sort) - { - boolean isSucess=false; - String orderby=Desc_Time_Up;//出料顺序 - String where="isDelete=? and sort=?"; - String[] args=new String[] { "0" ,sort+""}; - BPA_GOODS data=null; - ArrayList obj=Get(BPA_GOODS.class,where,args,orderby); - for (Object k:obj) { - data=(BPA_GOODS)k; + public static BPA_GOODS GetGoodsSortIs(int sort) { + boolean isSucess = false; + String orderby = Desc_Time_Up;//出料顺序 + String where = "isDelete=? and sort=?"; + String[] args = new String[]{"0", sort + ""}; + BPA_GOODS data = null; + ArrayList obj = Get(BPA_GOODS.class, where, args, orderby); + for (Object k : obj) { + data = (BPA_GOODS) k; } return data; } /** * 商品数据排序 + * * @param data 数据 * @param type 0 下移动 1 上移动 * @return */ - public static void GetGoodsSort(BPA_GOODS data,int type) - { - if(type==0) - { - BPA_GOODS q_data= data; - BPA_GOODS h_data= GetGoodsSortIs(data.sort+1); - if(h_data!=null) - { - h_data.sort=h_data.sort-1; + public static void GetGoodsSort(BPA_GOODS data, int type) { + if (type == 0) { + BPA_GOODS q_data = data; + BPA_GOODS h_data = GetGoodsSortIs(data.sort + 1); + if (h_data != null) { + h_data.sort = h_data.sort - 1; UpdateGoods(h_data); } - q_data.sort=q_data.sort+1; + q_data.sort = q_data.sort + 1; UpdateGoods(q_data); - }else - { - BPA_GOODS q_data= GetGoodsSortIs(data.sort-1); - BPA_GOODS h_data= data; - if(q_data!=null) - { - q_data.sort=q_data.sort+1; + } else { + BPA_GOODS q_data = GetGoodsSortIs(data.sort - 1); + BPA_GOODS h_data = data; + if (q_data != null) { + q_data.sort = q_data.sort + 1; UpdateGoods(q_data); } - h_data.sort=h_data.sort-1; + h_data.sort = h_data.sort - 1; UpdateGoods(h_data); } } //endregion //region BPA_GOODSRECIPE 商品配方明细表 + /** * 新增商品配方明细 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean AddGoodsSrecipe(BPA_GOODSRECIPE data) - { - return Add(BPA_GOODSRECIPE.class,data); + public static boolean AddGoodsSrecipe(BPA_GOODSRECIPE data) { + return Add(BPA_GOODSRECIPE.class, data); } + /** * 修改商品配方明细 * add fengyoufu 20230413 + * * @param data */ - public static void UpdateGoodsSrecipe(BPA_GOODSRECIPE data) - { - Update(BPA_GOODSRECIPE.class,data); + public static void UpdateGoodsSrecipe(BPA_GOODSRECIPE data) { + Update(BPA_GOODSRECIPE.class, data); } + /** * 删除商品配方明细 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean DeleteGoodsSrecipe(BPA_GOODSRECIPE data) - { - return Delete(BPA_GOODSRECIPE.class,data.id); + public static boolean DeleteGoodsSrecipe(BPA_GOODSRECIPE data) { + return Delete(BPA_GOODSRECIPE.class, data.id); } + /** * 获取所有商品配方明细 + * * @return */ - public static ArrayList GetGoodsSrecipeALL() - { - String orderby=Desc_Sort_Up+','+Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_GOODSRECIPE.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_GOODSRECIPE)k); + public static ArrayList GetGoodsSrecipeALL() { + String orderby = Desc_Sort_Up + ',' + Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_GOODSRECIPE.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_GOODSRECIPE) k); } return data; } /** * 根据商品id查询配方信息 + * * @param id * @return */ - public static ArrayList GetGoodsSrecipeList(String id) - { - String orderby=Desc_Sort_Up+','+Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=? and goodsID=?"; - String[] args=new String[] { "0",id }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_GOODSRECIPE.class,where,args,orderby); - for (Object item:obj) { - BPA_GOODSRECIPE k=(BPA_GOODSRECIPE)item; - BPA_MATERIAL ma= GetMaterialID(k.materialID); - if(ma!=null) - { - ResGoodsRecipe par=new ResGoodsRecipe(); - 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.materialName=ma.name; - - par.goodsID=k.goodsID; - par.materialID=k.materialID; - par.value=k.value; - par.sort=k.sort; + public static ArrayList GetGoodsSrecipeList(String id) { + String orderby = Desc_Sort_Up + ',' + Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=? and goodsID=?"; + String[] args = new String[]{"0", id}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_GOODSRECIPE.class, where, args, orderby); + for (Object item : obj) { + BPA_GOODSRECIPE k = (BPA_GOODSRECIPE) item; + BPA_MATERIAL ma = GetMaterialID(k.materialID); + if (ma != null) { + ResGoodsRecipe par = new ResGoodsRecipe(); + 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.materialName = ma.name; + + par.goodsID = k.goodsID; + par.materialID = k.materialID; + par.value = k.value; + par.sort = k.sort; data.add(par); } } return data; } + /** * 根据商品id删除配料信息 + * * @param id * @return */ - public static Boolean DeleteGoodsSrecipeList(String id) - { + public static Boolean DeleteGoodsSrecipeList(String id) { if (id.isEmpty()) return false; SQLiteDatabase db = helper.getWritableDatabase(); - long delete=db.delete(BPA_GOODSRECIPE.class.getSimpleName(), "goodsID=?", - new String[] { id }); + long delete = db.delete(BPA_GOODSRECIPE.class.getSimpleName(), "goodsID=?", + new String[]{id}); db.close(); - return delete>0; + return delete > 0; } //endregion //region BPA_ORDER 订单表 + /** * 新增订单 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean AddOrder(BPA_ORDER data) - { - return Add(BPA_ORDER.class,data); + public static boolean AddOrder(BPA_ORDER data) { + return Add(BPA_ORDER.class, data); } + /** * 修改订单 * add fengyoufu 20230413 + * * @param data */ - public static void UpdateOrder(BPA_ORDER data) - { - Update(BPA_ORDER.class,data); + public static void UpdateOrder(BPA_ORDER data) { + Update(BPA_ORDER.class, data); } + /** * 删除订单 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean DeleteOrder(BPA_ORDER data) - { - return Delete(BPA_ORDER.class,data.id); + public static boolean DeleteOrder(BPA_ORDER data) { + return Delete(BPA_ORDER.class, data.id); } + /** * 获取所有订单 + * * @return */ - public static ArrayList GetOrderALL() - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_ORDER.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_ORDER)k); + public static ArrayList GetOrderALL() { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_ORDER.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_ORDER) k); } return data; } //endregion //region BPA_SUBORDER 订单子表 + /** * 新增订单子表 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean AddSubOrder(BPA_SUBORDER data) - { - return Add(BPA_SUBORDER.class,data); + public static boolean AddSubOrder(BPA_SUBORDER data) { + return Add(BPA_SUBORDER.class, data); } + /** * 修改订单子表 * add fengyoufu 20230413 + * * @param data */ - public static void UpdateSubOrder(BPA_SUBORDER data) - { - Update(BPA_SUBORDER.class,data); + public static void UpdateSubOrder(BPA_SUBORDER data) { + Update(BPA_SUBORDER.class, data); } + /** * 删除订单子表 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean DeleteSubOrder(BPA_SUBORDER data) - { - return Delete(BPA_SUBORDER.class,data.id); + public static boolean DeleteSubOrder(BPA_SUBORDER data) { + return Delete(BPA_SUBORDER.class, data.id); } + /** * 获取所有订单子表 + * * @return */ - public static ArrayList GetSubOrderALL() - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_SUBORDER.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_SUBORDER)k); + public static ArrayList GetSubOrderALL() { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_SUBORDER.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_SUBORDER) k); } return data; } + /** * 根据主订单id查询子订单列表 + * * @param id * @return */ - public static ArrayList GetSubOrderList(String id) - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=? and orderID=?"; - String[] args=new String[] { "0",id }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_SUBORDER.class,where,args,orderby); - for (Object k:obj) { - data.add(((BPA_SUBORDER)k)); + public static ArrayList GetSubOrderList(String id) { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=? and orderID=?"; + String[] args = new String[]{"0", id}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_SUBORDER.class, where, args, orderby); + for (Object k : obj) { + data.add(((BPA_SUBORDER) k)); } return data; } //endregion //region BPA_ALERTLOG 预警日志表 + /** * 新增预警日志 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean AddAlertlog(BPA_ALERTLOG data) - { - return Add(BPA_ALERTLOG.class,data); + public static boolean AddAlertlog(BPA_ALERTLOG data) { + return Add(BPA_ALERTLOG.class, data); } + /** * 修改预警日志 * add fengyoufu 20230413 + * * @param data */ - public static void UpdateAlertlog(BPA_ALERTLOG data) - { - Update(BPA_ALERTLOG.class,data); + public static void UpdateAlertlog(BPA_ALERTLOG data) { + Update(BPA_ALERTLOG.class, data); } + /** * 删除预警日志 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean DeleteAlertlog(BPA_ALERTLOG data) - { - return Delete(BPA_ALERTLOG.class,data.id); + public static boolean DeleteAlertlog(BPA_ALERTLOG data) { + return Delete(BPA_ALERTLOG.class, data.id); } + /** * 获取所有预警日志 + * * @return */ - public static ArrayList GetAlertlogALL() - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_ALERTLOG.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_ALERTLOG)k); + public static ArrayList GetAlertlogALL() { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_ALERTLOG.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_ALERTLOG) k); } return data; } + /** * 获取所有今日预警日志 + * * @return */ - public static ArrayList GetAlertlogTodan() - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=? and createTime>?"; - String[] args=new String[] { "0",new SimpleDateFormat("yyyy-MM-dd").format(new Date())+" 00:00:00" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_ALERTLOG.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_ALERTLOG)k); + public static ArrayList GetAlertlogTodan() { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=? and createTime>?"; + String[] args = new String[]{"0", new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + " 00:00:00"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_ALERTLOG.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_ALERTLOG) k); } return data; } //endregion //region BPA_LOG 日志表 + /** * 新增日志 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean Addlog(BPA_LOG data) - { - return Add(BPA_LOG.class,data); + public static boolean Addlog(BPA_LOG data) { + return Add(BPA_LOG.class, data); } + /** * 修改日志 * add fengyoufu 20230413 + * * @param data */ - public static void Updatelog(BPA_LOG data) - { - Update(BPA_LOG.class,data); + public static void Updatelog(BPA_LOG data) { + Update(BPA_LOG.class, data); } + /** * 删除日志 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean Deletelog(BPA_LOG data) - { - return Delete(BPA_LOG.class,data.id); + public static boolean Deletelog(BPA_LOG data) { + return Delete(BPA_LOG.class, data.id); } + /** * 获取日志 + * * @return */ - public static ArrayList GetlogALL() - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_LOG.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_LOG)k); + public static ArrayList GetlogALL() { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_LOG.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_LOG) k); } return data; } + /** * 获取所有今日日志 + * * @return */ - public static ArrayList GetlogTodan() - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=? and createTime>?"; - String[] args=new String[] { "0",new SimpleDateFormat("yyyy-MM-dd").format(new Date())+" 00:00:00" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_LOG.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_LOG)k); + public static ArrayList GetlogTodan() { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=? and createTime>?"; + String[] args = new String[]{"0", new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + " 00:00:00"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_LOG.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_LOG) k); } return data; } //endregion //region BPA_ORDERLOG 订单制作记录表 + /** * 新增订单制作记录 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean AddOrderlog(BPA_ORDERLOG data) - { - return Add(BPA_ORDERLOG.class,data); + public static boolean AddOrderlog(BPA_ORDERLOG data) { + return Add(BPA_ORDERLOG.class, data); } + /** * 修改订单制作记录 * add fengyoufu 20230413 + * * @param data */ - public static void UpdateOrderlog(BPA_ORDERLOG data) - { - Update(BPA_ORDERLOG.class,data); + public static void UpdateOrderlog(BPA_ORDERLOG data) { + Update(BPA_ORDERLOG.class, data); } + /** * 删除订单制作记录 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean DeleteOrderlog(BPA_ORDERLOG data) - { - return Delete(BPA_ORDERLOG.class,data.id); + public static boolean DeleteOrderlog(BPA_ORDERLOG data) { + return Delete(BPA_ORDERLOG.class, data.id); } + /** * 获取所有订单制作记录 + * * @return */ - public static ArrayList GetOrderlogALL() - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_ORDERLOG.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_ORDERLOG)k); + public static ArrayList GetOrderlogALL() { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_ORDERLOG.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_ORDERLOG) k); } return data; } + /** * 根据子订单id查询子订单制作记录 + * * @param id * @return */ - public static ArrayList GetOrderlogList(String id) - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=? and suborderID=?"; - String[] args=new String[] { "0",id }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_ORDERLOG.class,where,args,orderby); - for (Object k:obj) { - data.add(((BPA_ORDERLOG)k)); + public static ArrayList GetOrderlogList(String id) { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=? and suborderID=?"; + String[] args = new String[]{"0", id}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_ORDERLOG.class, where, args, orderby); + for (Object k : obj) { + data.add(((BPA_ORDERLOG) k)); } return data; } //endregion //region BPA_ORDERLOGDESC 订单制作记录描述表 + /** * 新增订单制作记录描述 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean AddOrderlogdesc(BPA_ORDERLOGDESC data) - { - return Add(BPA_ORDERLOGDESC.class,data); + public static boolean AddOrderlogdesc(BPA_ORDERLOGDESC data) { + return Add(BPA_ORDERLOGDESC.class, data); } + /** * 修改订单制作记录描述 * add fengyoufu 20230413 + * * @param data */ - public static void UpdateOrderlogdesc(BPA_ORDERLOGDESC data) - { - Update(BPA_ORDERLOGDESC.class,data); + public static void UpdateOrderlogdesc(BPA_ORDERLOGDESC data) { + Update(BPA_ORDERLOGDESC.class, data); } + /** * 删除订单制作记录描述 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean DeleteOrderlogdesc(BPA_ORDERLOGDESC data) - { - return Delete(BPA_ORDERLOGDESC.class,data.id); + public static boolean DeleteOrderlogdesc(BPA_ORDERLOGDESC data) { + return Delete(BPA_ORDERLOGDESC.class, data.id); } + /** * 获取订单制作记录描述 + * * @return */ - public static ArrayList GetOrderlogdescALL() - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_ORDERLOGDESC.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_ORDERLOGDESC)k); + public static ArrayList GetOrderlogdescALL() { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_ORDERLOGDESC.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_ORDERLOGDESC) k); } return data; } + /** * 根据子订单id查询子订单订单制作记录描述 + * * @param id * @return */ - public static ArrayList GetOrderlogdescList(String id) - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=? and suborderID=?"; - String[] args=new String[] { "0",id }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_ORDERLOGDESC.class,where,args,orderby); - for (Object k:obj) { - data.add(((BPA_ORDERLOGDESC)k)); + public static ArrayList GetOrderlogdescList(String id) { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=? and suborderID=?"; + String[] args = new String[]{"0", id}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_ORDERLOGDESC.class, where, args, orderby); + for (Object k : obj) { + data.add(((BPA_ORDERLOGDESC) k)); } return data; } //endregion //region BPA_SYSTEMSET 系统设置表 + /** * 新增系统设置 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean AddSystemset(BPA_SYSTEMSET data) - { - return Add(BPA_SYSTEMSET.class,data); + public static boolean AddSystemset(BPA_SYSTEMSET data) { + return Add(BPA_SYSTEMSET.class, data); } + /** * 修改系统设置 * add fengyoufu 20230413 + * * @param data */ - public static void UpdateSystemset(BPA_SYSTEMSET data) - { - Update(BPA_SYSTEMSET.class,data); + public static void UpdateSystemset(BPA_SYSTEMSET data) { + Update(BPA_SYSTEMSET.class, data); } + /** * 删除系统设置 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean DeleteSystemset(BPA_SYSTEMSET data) - { - return Delete(BPA_SYSTEMSET.class,data.id); + public static boolean DeleteSystemset(BPA_SYSTEMSET data) { + return Delete(BPA_SYSTEMSET.class, data.id); } + /** * 获取系统设置 + * * @return */ - public static ArrayList GetSystemsetALL() - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_SYSTEMSET.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_SYSTEMSET)k); + public static ArrayList GetSystemsetALL() { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_SYSTEMSET.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_SYSTEMSET) k); } return data; } //endregion //region BPA_USER 账户表 + /** * 新增账户 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean AddUser(BPA_USER data) - { - return Add(BPA_USER.class,data); + public static boolean AddUser(BPA_USER data) { + return Add(BPA_USER.class, data); } + /** * 修改账户 * add fengyoufu 20230413 + * * @param data */ - public static void UpdateUser(BPA_USER data) - { - Update(BPA_USER.class,data); + public static void UpdateUser(BPA_USER data) { + Update(BPA_USER.class, data); } + /** * 删除账户 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean DeleteUser(BPA_USER data) - { - return Delete(BPA_USER.class,data.id); + public static boolean DeleteUser(BPA_USER data) { + return Delete(BPA_USER.class, data.id); } + /** * 获取账户 + * * @return */ - public static ArrayList GetUserALL() - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_USER.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_USER)k); + public static ArrayList GetUserALL() { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_USER.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_USER) k); } return data; } + /** * 用户登录 + * * @param Name * @param Pass * @return */ - public static BPA_USER UserLogin(String Name,String Pass) - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=? and (account=? or name=?) and pass=?"; - String[] args=new String[] { "0",Name,Name,Pass }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_USER.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_USER)k); + public static BPA_USER UserLogin(String Name, String Pass) { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=? and (account=? or name=?) and pass=?"; + String[] args = new String[]{"0", Name, Name, Pass}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_USER.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_USER) k); } - if(data.size()<=0) + if (data.size() <= 0) return null; else return data.get(0); @@ -1060,134 +1114,137 @@ public class QueryDB { //endregion //region BPA_MENU 菜单表 + /** * 新增菜单 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean AddMenu(BPA_MENU data) - { - return Add(BPA_MENU.class,data); + public static boolean AddMenu(BPA_MENU data) { + return Add(BPA_MENU.class, data); } + /** * 修改菜单 * add fengyoufu 20230413 + * * @param data */ - public static void UpdateMenu(BPA_MENU data) - { - Update(BPA_MENU.class,data); + public static void UpdateMenu(BPA_MENU data) { + Update(BPA_MENU.class, data); } + /** * 删除菜单 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean DeleteMenu(BPA_MENU data) - { - return Delete(BPA_MENU.class,data.id); + public static boolean DeleteMenu(BPA_MENU data) { + return Delete(BPA_MENU.class, data.id); } + /** * 获取菜单 + * * @return */ - public static ArrayList GetMenuALL() - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_MENU.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_MENU)k); + public static ArrayList GetMenuALL() { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_MENU.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_MENU) k); } return data; } //endregion //region BPA_MENUANDUSER 菜单用户关联表 + /** * 新增菜单用户关联表 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean AddMenuAndUser(BPA_MENUANDUSER data) - { - return Add(BPA_MENUANDUSER.class,data); + public static boolean AddMenuAndUser(BPA_MENUANDUSER data) { + return Add(BPA_MENUANDUSER.class, data); } + /** * 修改菜单用户关联表 * add fengyoufu 20230413 + * * @param data */ - public static void UpdateMenuAndUser(BPA_MENUANDUSER data) - { - Update(BPA_MENUANDUSER.class,data); + public static void UpdateMenuAndUser(BPA_MENUANDUSER data) { + Update(BPA_MENUANDUSER.class, data); } + /** * 删除菜单用户关联表 * add fengyoufu 20230413 + * * @param data * @return 是否成功 */ - public static boolean DeleteMenuAndUser(BPA_MENUANDUSER data) - { - return Delete(BPA_MENUANDUSER.class,data.id); + public static boolean DeleteMenuAndUser(BPA_MENUANDUSER data) { + return Delete(BPA_MENUANDUSER.class, data.id); } + /** * 获取菜单用户关联表 + * * @return */ - public static ArrayList GetMenuAndUserALL() - { - String orderby=Desc_Time_Up;//先按排序 创建时间倒序 - String where="isDelete=?"; - String[] args=new String[] { "0" }; - ArrayList data=new ArrayList<>(); - ArrayList obj=Get(BPA_MENUANDUSER.class,where,args,orderby); - for (Object k:obj) { - data.add((BPA_MENUANDUSER)k); + public static ArrayList GetMenuAndUserALL() { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_MENUANDUSER.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_MENUANDUSER) k); } return data; } //endregion //region 私有 + /** * 新增 + * * @param c * @param data * @return */ - private static boolean Add(Class c,Object data) - { + private static boolean Add(Class c, Object data) { ContentValues cv = new ContentValues(); - Map map= Tools.getObjValue(data); + Map map = Tools.getObjValue(data); if (map.get("id").toString().isEmpty()) return false; for (String key : map.keySet()) { Object value = map.get(key); - if(value instanceof String) - { + if (value instanceof String) { cv.put(key, (String) value); - }else if (value instanceof Integer) - { + } else if (value instanceof Integer) { cv.put(key, ((Integer) value).intValue()); - }else if (value instanceof Double) - { - cv.put(key, ((Double) value).doubleValue()); - }else if (value instanceof Float) - { - cv.put(key, ((Float) value).floatValue()); - }else if (value instanceof Long) - { - cv.put(key, ((Long) value).longValue()); - }else if (value instanceof Boolean) - { - cv.put(key, ((Boolean) value).booleanValue()); + } else if (value instanceof Double) { + cv.put(key, ((Double) value).doubleValue()); + } else if (value instanceof Float) { + cv.put(key, ((Float) value).floatValue()); + } else if (value instanceof Long) { + cv.put(key, ((Long) value).longValue()); + } else if (value instanceof Boolean) { + cv.put(key, ((Boolean) value).booleanValue()); } // else if (value instanceof Date) // { @@ -1197,43 +1254,37 @@ public class QueryDB { SQLiteDatabase db = helper.getWritableDatabase(); long insert = db.insert(c.getSimpleName(), null, cv); db.close(); - return insert>0; + return insert > 0; } + /** * 修改 + * * @param c * @param data * @return */ - private static boolean Update(Class c,Object data) - { + private static boolean Update(Class c, Object data) { ContentValues cv = new ContentValues(); - Map map= Tools.getObjValue(data); - String id=map.get("id").toString(); + Map map = Tools.getObjValue(data); + String id = map.get("id").toString(); if (id.isEmpty()) return false; for (String key : map.keySet()) { - if(!key.equals("id")) - { + if (!key.equals("id")) { Object value = map.get(key); - if(value instanceof String) - { + if (value instanceof String) { cv.put(key, (String) value); - }else if (value instanceof Integer) - { + } else if (value instanceof Integer) { cv.put(key, ((Integer) value).intValue()); - }else if (value instanceof Double) - { - cv.put(key, ((Double) value).doubleValue()); - }else if (value instanceof Float) - { - cv.put(key, ((Float) value).floatValue()); - }else if (value instanceof Long) - { - cv.put(key, ((Long) value).longValue()); - }else if (value instanceof Boolean) - { - cv.put(key, ((Boolean) value).booleanValue()); + } else if (value instanceof Double) { + cv.put(key, ((Double) value).doubleValue()); + } else if (value instanceof Float) { + cv.put(key, ((Float) value).floatValue()); + } else if (value instanceof Long) { + cv.put(key, ((Long) value).longValue()); + } else if (value instanceof Boolean) { + cv.put(key, ((Boolean) value).booleanValue()); } } // else if (value instanceof Date) @@ -1242,161 +1293,162 @@ public class QueryDB { // } } SQLiteDatabase db = helper.getWritableDatabase(); - db.update(c.getSimpleName(),cv,"id = ?", new String[] { id }); + db.update(c.getSimpleName(), cv, "id = ?", new String[]{id}); db.close(); return true; } + /** * 删除 + * * @param c * @param id * @return */ - private static boolean Delete(Class c,String id) - { + private static boolean Delete(Class c, String id) { if (id.isEmpty()) return false; SQLiteDatabase db = helper.getWritableDatabase(); - long delete=db.delete(c.getSimpleName(), "id = ?", - new String[] { id }); + long delete = db.delete(c.getSimpleName(), "id = ?", + new String[]{id}); db.close(); - return delete>0; + return delete > 0; } + /** * 获取数据 + * * @param c - * @param whereClause "id = ? and id=?" "sys_pre>? and dia_pre?" - * @param Args new String[] { id,id } - * @param orderby "date("+COLUMN_DATE+") desc" "TYPE desc"; desc 倒序 + * @param whereClause "id = ? and id=?" "sys_pre>? and dia_pre?" + * @param Args new String[] { id,id } + * @param orderby "date("+COLUMN_DATE+") desc" "TYPE desc"; desc 倒序 * @return */ - private static ArrayList Get(Class c,String whereClause,String[] Args,String orderby) - { + private static ArrayList Get(Class c, String whereClause, String[] Args, String orderby) { ArrayList rlts = new ArrayList(); SQLiteDatabase db = helper.getReadableDatabase(); //String orderby = "TYPE desc"; - List col=new ArrayList<>(); - for (Field field : c.getFields()){ + List col = new ArrayList<>(); + for (Field field : c.getFields()) { col.add(field.getName()); } - String[] columns= (String[]) col.toArray(new String[col.size()]); + String[] columns = (String[]) col.toArray(new String[col.size()]); Cursor cursor = db.query(c.getSimpleName(), columns, whereClause, Args, null, null, orderby, null); - Object data=new Object(); + Object data = new Object(); while (cursor.moveToNext()) { - switch (c.getSimpleName()) - { + switch (c.getSimpleName()) { case "BPA_MATERIAL": data = new BPA_MATERIAL(); //私有 - ((BPA_MATERIAL)data).imgUrl=cursor.getString((int)cursor.getColumnIndex("imgUrl")); - ((BPA_MATERIAL)data).name=cursor.getString((int)cursor.getColumnIndex("name")); + ((BPA_MATERIAL) data).imgUrl = cursor.getString((int) cursor.getColumnIndex("imgUrl")); + ((BPA_MATERIAL) data).name = cursor.getString((int) cursor.getColumnIndex("name")); break; case "BPA_SILOS": data = new BPA_SILOS(); //私有 - ((BPA_SILOS)data).num=cursor.getInt((int)cursor.getColumnIndex("num")); - ((BPA_SILOS)data).name=cursor.getString((int)cursor.getColumnIndex("name")); - ((BPA_SILOS)data).warningValue=cursor.getInt((int)cursor.getColumnIndex("warningValue")); - ((BPA_SILOS)data).thrsoleValue=cursor.getInt((int)cursor.getColumnIndex("thrsoleValue")); - ((BPA_SILOS)data).plcValue=cursor.getString((int)cursor.getColumnIndex("plcValue")); - ((BPA_SILOS)data).bValue=cursor.getInt((int)cursor.getColumnIndex("bValue")); - ((BPA_SILOS)data).jValue=cursor.getInt((int)cursor.getColumnIndex("jValue")); - ((BPA_SILOS)data).status=cursor.getInt((int)cursor.getColumnIndex("status")); - ((BPA_SILOS)data).Sort=cursor.getInt((int)cursor.getColumnIndex("Sort")); + ((BPA_SILOS) data).num = cursor.getInt((int) cursor.getColumnIndex("num")); + ((BPA_SILOS) data).name = cursor.getString((int) cursor.getColumnIndex("name")); + ((BPA_SILOS) data).warningValue = cursor.getInt((int) cursor.getColumnIndex("warningValue")); + ((BPA_SILOS) data).thrsoleValue = cursor.getInt((int) cursor.getColumnIndex("thrsoleValue")); + ((BPA_SILOS) data).plcValue = cursor.getString((int) cursor.getColumnIndex("plcValue")); + ((BPA_SILOS) data).bValue = cursor.getInt((int) cursor.getColumnIndex("bValue")); + ((BPA_SILOS) data).jValue = cursor.getInt((int) cursor.getColumnIndex("jValue")); + ((BPA_SILOS) data).status = cursor.getInt((int) cursor.getColumnIndex("status")); + ((BPA_SILOS) data).Sort = cursor.getInt((int) cursor.getColumnIndex("Sort")); break; case "BPA_SILOSANDMATERIAL": data = new BPA_SILOSANDMATERIAL(); //私有 - ((BPA_SILOSANDMATERIAL)data).silosID=cursor.getString((int)cursor.getColumnIndex("silosID")); - ((BPA_SILOSANDMATERIAL)data).materialID=cursor.getString((int)cursor.getColumnIndex("materialID")); + ((BPA_SILOSANDMATERIAL) data).silosID = cursor.getString((int) cursor.getColumnIndex("silosID")); + ((BPA_SILOSANDMATERIAL) data).materialID = cursor.getString((int) cursor.getColumnIndex("materialID")); break; case "BPA_GOODS": data = new BPA_GOODS(); //私有 - ((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).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")); break; case "BPA_GOODSRECIPE": data = new BPA_GOODSRECIPE(); //私有 - ((BPA_GOODSRECIPE)data).goodsID=cursor.getString((int)cursor.getColumnIndex("goodsID")); - ((BPA_GOODSRECIPE)data).materialID=cursor.getString((int)cursor.getColumnIndex("materialID")); - ((BPA_GOODSRECIPE)data).value=cursor.getInt((int)cursor.getColumnIndex("value")); - ((BPA_GOODSRECIPE)data).sort=cursor.getInt((int)cursor.getColumnIndex("sort")); + ((BPA_GOODSRECIPE) data).goodsID = cursor.getString((int) cursor.getColumnIndex("goodsID")); + ((BPA_GOODSRECIPE) data).materialID = cursor.getString((int) cursor.getColumnIndex("materialID")); + ((BPA_GOODSRECIPE) data).value = cursor.getInt((int) cursor.getColumnIndex("value")); + ((BPA_GOODSRECIPE) data).sort = cursor.getInt((int) cursor.getColumnIndex("sort")); break; case "BPA_ORDER": data = new BPA_ORDER(); //私有 - ((BPA_ORDER)data).thirdPartyID=cursor.getString((int)cursor.getColumnIndex("thirdPartyID")); - ((BPA_ORDER)data).status=cursor.getInt((int)cursor.getColumnIndex("status")); + ((BPA_ORDER) data).thirdPartyID = cursor.getString((int) cursor.getColumnIndex("thirdPartyID")); + ((BPA_ORDER) data).status = cursor.getInt((int) cursor.getColumnIndex("status")); break; case "BPA_SUBORDER": data = new BPA_SUBORDER(); //私有 - ((BPA_SUBORDER)data).orderID=cursor.getString((int)cursor.getColumnIndex("orderID")); - ((BPA_SUBORDER)data).goodsID=cursor.getInt((int)cursor.getColumnIndex("goodsID")); - ((BPA_SUBORDER)data).number=cursor.getString((int)cursor.getColumnIndex("number")); - ((BPA_SUBORDER)data).status=cursor.getInt((int)cursor.getColumnIndex("status")); + ((BPA_SUBORDER) data).orderID = cursor.getString((int) cursor.getColumnIndex("orderID")); + ((BPA_SUBORDER) data).goodsID = cursor.getInt((int) cursor.getColumnIndex("goodsID")); + ((BPA_SUBORDER) data).number = cursor.getString((int) cursor.getColumnIndex("number")); + ((BPA_SUBORDER) data).status = cursor.getInt((int) cursor.getColumnIndex("status")); break; case "BPA_ALERTLOG": data = new BPA_ALERTLOG(); //私有 - ((BPA_ALERTLOG)data).type=cursor.getInt((int)cursor.getColumnIndex("type")); - ((BPA_ALERTLOG)data).text=cursor.getString((int)cursor.getColumnIndex("text")); + ((BPA_ALERTLOG) data).type = cursor.getInt((int) cursor.getColumnIndex("type")); + ((BPA_ALERTLOG) data).text = cursor.getString((int) cursor.getColumnIndex("text")); break; case "BPA_LOG": data = new BPA_LOG(); //私有 - ((BPA_LOG)data).type=cursor.getInt((int)cursor.getColumnIndex("type")); - ((BPA_LOG)data).text=cursor.getString((int)cursor.getColumnIndex("text")); + ((BPA_LOG) data).type = cursor.getInt((int) cursor.getColumnIndex("type")); + ((BPA_LOG) data).text = cursor.getString((int) cursor.getColumnIndex("text")); break; case "BPA_ORDERLOG": data = new BPA_ORDERLOG(); //私有 - ((BPA_ORDERLOG)data).suborderID=cursor.getString((int)cursor.getColumnIndex("suborderID")); - ((BPA_ORDERLOG)data).prewStatus=cursor.getInt((int)cursor.getColumnIndex("prewStatus")); - ((BPA_ORDERLOG)data).currentStatus=cursor.getInt((int)cursor.getColumnIndex("currentStatus")); + ((BPA_ORDERLOG) data).suborderID = cursor.getString((int) cursor.getColumnIndex("suborderID")); + ((BPA_ORDERLOG) data).prewStatus = cursor.getInt((int) cursor.getColumnIndex("prewStatus")); + ((BPA_ORDERLOG) data).currentStatus = cursor.getInt((int) cursor.getColumnIndex("currentStatus")); break; case "BPA_ORDERLOGDESC": data = new BPA_ORDERLOGDESC(); //私有 - ((BPA_ORDERLOGDESC)data).suborderID=cursor.getString((int)cursor.getColumnIndex("suborderID")); - ((BPA_ORDERLOGDESC)data).text=cursor.getString((int)cursor.getColumnIndex("text")); + ((BPA_ORDERLOGDESC) data).suborderID = cursor.getString((int) cursor.getColumnIndex("suborderID")); + ((BPA_ORDERLOGDESC) data).text = cursor.getString((int) cursor.getColumnIndex("text")); break; case "BPA_SYSTEMSET": data = new BPA_SYSTEMSET(); //私有 - ((BPA_SYSTEMSET)data).type=cursor.getInt((int)cursor.getColumnIndex("type")); - ((BPA_SYSTEMSET)data).value=cursor.getString((int)cursor.getColumnIndex("value")); + ((BPA_SYSTEMSET) data).type = cursor.getInt((int) cursor.getColumnIndex("type")); + ((BPA_SYSTEMSET) data).value = cursor.getString((int) cursor.getColumnIndex("value")); break; case "BPA_USER": data = new BPA_USER(); //私有 - ((BPA_USER)data).name=cursor.getString((int)cursor.getColumnIndex("name")); - ((BPA_USER)data).account=cursor.getString((int)cursor.getColumnIndex("account")); - ((BPA_USER)data).pass=cursor.getString((int)cursor.getColumnIndex("pass")); + ((BPA_USER) data).name = cursor.getString((int) cursor.getColumnIndex("name")); + ((BPA_USER) data).account = cursor.getString((int) cursor.getColumnIndex("account")); + ((BPA_USER) data).pass = cursor.getString((int) cursor.getColumnIndex("pass")); break; case "BPA_MENU": data = new BPA_MENU(); //私有 - ((BPA_MENU)data).name=cursor.getString((int)cursor.getColumnIndex("name")); + ((BPA_MENU) data).name = cursor.getString((int) cursor.getColumnIndex("name")); break; case "BPA_MENUANDUSER": data = new BPA_MENUANDUSER(); //私有 - ((BPA_MENUANDUSER)data).menuID=cursor.getString((int)cursor.getColumnIndex("menuID")); + ((BPA_MENUANDUSER) data).menuID = cursor.getString((int) cursor.getColumnIndex("menuID")); break; } - ((ModeBase)data).id=cursor.getString((int)cursor.getColumnIndex("id")); - ((ModeBase)data).createTime=cursor.getString((int)cursor.getColumnIndex("createTime")); - ((ModeBase)data).updateTime=cursor.getString((int)cursor.getColumnIndex("updateTime")); - ((ModeBase)data).deleteTime=cursor.getString((int)cursor.getColumnIndex("deleteTime")); - ((ModeBase)data).deviceID=cursor.getString((int)cursor.getColumnIndex("deviceID")); - ((ModeBase)data).userID=cursor.getString((int)cursor.getColumnIndex("userID")); - ((ModeBase)data).isDelete=cursor.getInt((int)cursor.getColumnIndex("isDelete")); - ((ModeBase)data).exp=cursor.getString((int)cursor.getColumnIndex("exp")); + ((ModeBase) data).id = cursor.getString((int) cursor.getColumnIndex("id")); + ((ModeBase) data).createTime = cursor.getString((int) cursor.getColumnIndex("createTime")); + ((ModeBase) data).updateTime = cursor.getString((int) cursor.getColumnIndex("updateTime")); + ((ModeBase) data).deleteTime = cursor.getString((int) cursor.getColumnIndex("deleteTime")); + ((ModeBase) data).deviceID = cursor.getString((int) cursor.getColumnIndex("deviceID")); + ((ModeBase) data).userID = cursor.getString((int) cursor.getColumnIndex("userID")); + ((ModeBase) data).isDelete = cursor.getInt((int) cursor.getColumnIndex("isDelete")); + ((ModeBase) data).exp = cursor.getString((int) cursor.getColumnIndex("exp")); rlts.add(data); } cursor.close(); diff --git a/app/src/main/java/com/example/bpa/view/adapter/pf_adapter.java b/app/src/main/java/com/example/bpa/view/adapter/pf_adapter.java index cfb7d2b..8589a80 100644 --- a/app/src/main/java/com/example/bpa/view/adapter/pf_adapter.java +++ b/app/src/main/java/com/example/bpa/view/adapter/pf_adapter.java @@ -1,11 +1,15 @@ package com.example.bpa.view.adapter; import android.content.Context; +import android.text.Editable; +import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; +import android.widget.EditText; import android.widget.Spinner; import android.widget.SpinnerAdapter; import android.widget.TextView; @@ -30,11 +34,11 @@ public class pf_adapter extends ArrayAdapter { * 内部点击事件 */ private MyClickListener mListener; - private List datas; + private ArrayList datas= new ArrayList<>(); ArrayList wuliao=new ArrayList<>(); - - public pf_adapter(@NonNull Context context, int resource, @NonNull List objects, ArrayList wl, MyClickListener listener) { + ArrayList wllist=new ArrayList<>(); + public pf_adapter(@NonNull Context context, int resource, @NonNull ArrayList objects, ArrayList wl, MyClickListener listener) { super(context, resource, objects); mListener = listener; datas=objects; @@ -45,6 +49,7 @@ public class pf_adapter extends ArrayAdapter { { wuliao.add(me.name); } + wllist=wl; } } //每个子项被滚动到屏幕内的时候会被调用 @@ -56,8 +61,8 @@ public class pf_adapter extends ArrayAdapter { View view = LayoutInflater.from(getContext()).inflate(R.layout.pf_item, parent, false); //分别获取 image view 和 textview 的实例 Spinner name = view.findViewById(R.id.name); - TextView sort = view.findViewById(R.id.sort); - TextView value = view.findViewById(R.id.value); + EditText sort = view.findViewById(R.id.sort); + EditText value = view.findViewById(R.id.value); Button button = view.findViewById(R.id.button_item); // 设置要显示的图片和文字 ArrayAdapter mAdapter = new android.widget.ArrayAdapter(view.getContext(), @@ -76,8 +81,10 @@ public class pf_adapter extends ArrayAdapter { } } } + value.setText(resGoodsRecipe.value+""); sort.setText(resGoodsRecipe.sort+""); + sort.setTag(resGoodsRecipe.id); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -90,6 +97,97 @@ public class pf_adapter extends ArrayAdapter { } } }); + + sort.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + } + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + @Override + public void afterTextChanged(Editable editable) { + String so=sort.getText().toString().trim().toString(); + if(so.isEmpty()) + { + T.show(view.getContext(), "不能为空!"); + return; + } + resGoodsRecipe.sort=Integer.parseInt(so); + datas.set(position,resGoodsRecipe); + } + }); + + value.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void afterTextChanged(Editable editable) { + String so=value.getText().toString().trim().toString(); + if(so.isEmpty()) + { + T.show(view.getContext(), "不能为空!"); + return; + } + resGoodsRecipe.value=Integer.parseInt(so); + datas.set(position,resGoodsRecipe); + } + }); + + name.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView adapterView, View view, int i, long l) { + int index=name.getSelectedItemPosition(); + if(index>=0) + { + BPA_MATERIAL wljh= wllist.get(name.getSelectedItemPosition()); + resGoodsRecipe.materialName=wljh.name; + resGoodsRecipe.materialID=wljh.id; + datas.set(position,resGoodsRecipe); + }else + { + T.show(view.getContext(), "不能为空!"); + return; + } + } + + @Override + public void onNothingSelected(AdapterView adapterView) { + int index=name.getSelectedItemPosition(); + if(index>=0) + { + BPA_MATERIAL wljh= wllist.get(name.getSelectedItemPosition()); + resGoodsRecipe.materialName=wljh.name; + resGoodsRecipe.materialID=wljh.id; + datas.set(position,resGoodsRecipe); + }else + { + resGoodsRecipe.materialName=""; + resGoodsRecipe.materialID=""; + datas.set(position,resGoodsRecipe); + T.show(view.getContext(), "不能为空!"); + return; + } + } + }); return view; } + + /** + * 获取数据 + * @return + */ + public ArrayList GetDatas() + { + return datas; + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/bpa/view/adapter/sp_adapter.java b/app/src/main/java/com/example/bpa/view/adapter/sp_adapter.java index 90e1245..71cf5cd 100644 --- a/app/src/main/java/com/example/bpa/view/adapter/sp_adapter.java +++ b/app/src/main/java/com/example/bpa/view/adapter/sp_adapter.java @@ -48,6 +48,7 @@ public class sp_adapter extends ArrayAdapter { Button button_up = view.findViewById(R.id.button_item_Up); Button button_down = view.findViewById(R.id.button_item_Down); Button button_update = view.findViewById(R.id.button_item_update); + Button button_xf = view.findViewById(R.id.button_xf); // 设置要显示的图片和文字 name.setText(bpa_goods.name); @@ -101,6 +102,18 @@ public class sp_adapter extends ArrayAdapter { } } }); + button_xf.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + try + { + mListener.clickListener(view,bpa_goods); + } catch (Exception e) + { + T.show(view.getContext(),"商品下发出错:"+e.getMessage()); + } + } + }); return view; } } \ No newline at end of file diff --git a/app/src/main/java/com/example/bpa/view/from/add_pf_activity.java b/app/src/main/java/com/example/bpa/view/from/add_pf_activity.java index 63414bc..ab18b99 100644 --- a/app/src/main/java/com/example/bpa/view/from/add_pf_activity.java +++ b/app/src/main/java/com/example/bpa/view/from/add_pf_activity.java @@ -6,24 +6,30 @@ import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; +import android.widget.EditText; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.ListView; +import android.widget.Spinner; import android.widget.TextView; import com.example.bpa.R; import com.example.bpa.config.ConfigName; +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_GOODSRECIPE; import com.example.bpa.db.mode.BPA_MATERIAL; import com.example.bpa.helper.Json; import com.example.bpa.helper.T; +import com.example.bpa.message.MessageManager; import com.example.bpa.view.adapter.pf_adapter; import com.example.bpa.view.adapter.sp_adapter; import com.example.bpa.view.inteface.MyClickListener; import com.example.bpa.view.mode.ResGoodsRecipe; import java.util.ArrayList; +import java.util.List; public class add_pf_activity extends AppCompatActivity implements View.OnClickListener, MyClickListener { //region 变量 @@ -67,6 +73,7 @@ public class add_pf_activity extends AppCompatActivity implements View.OnClickLi * wulaipo */ ArrayList wuliao=new ArrayList<>(); + pf_adapter adapter=null; //endregion //region 私有函数 @@ -95,13 +102,15 @@ public class add_pf_activity extends AppCompatActivity implements View.OnClickLi String msg = getIntent().getStringExtra("title"); String data = getIntent().getStringExtra("data"); if (!data.isEmpty()) { + T.show(this, data); + good = new Json().jsonToobject(BPA_GOODS.class, data); edittext.setText(good.name); } gongneng_title.setText(msg); - Initdata(); bpa_goods= QueryDB.GetGoodsALL(); wuliao=QueryDB.GetMaterialALL(); + Initdata(); } /** @@ -121,7 +130,9 @@ public class add_pf_activity extends AppCompatActivity implements View.OnClickLi try { if (good != null)//修改 { - bpa_pf= QueryDB.GetGoodsSrecipeList(good.id); + T.show(this, "查询物料数据" +good.id); + bpa_pf= QueryDB.GetGoodsSrecipeList(good.id); + DataTab(); } } catch (Exception e) { @@ -133,7 +144,7 @@ public class add_pf_activity extends AppCompatActivity implements View.OnClickLi */ public void DataTab() { - pf_adapter adapter = new pf_adapter(add_pf_activity.this, R.layout.pf_item, bpa_pf,wuliao,this); + adapter = new pf_adapter(add_pf_activity.this, R.layout.pf_item, bpa_pf,wuliao,this); datatab.setAdapter(adapter); } //endregion @@ -152,13 +163,29 @@ public class add_pf_activity extends AppCompatActivity implements View.OnClickLi this.finish(); break; case R.id.buttonaddwuliao://新增空白行 - ResGoodsRecipe recipe=new ResGoodsRecipe(); + ResGoodsRecipe recipe=new ResGoodsRecipe();//new 一个空对象 + if(adapter!=null) bpa_pf=adapter.GetDatas(); recipe.sort=bpa_pf.size()+1; bpa_pf.add(recipe); DataTab(); break; case R.id.buttonsave://保存按钮点击 - if(bpa_pf.size()<=0) + if(adapter==null || bpa_pf.size()<=0) + { + T.show(this, "配方不能为空!"); + return; + } + bpa_pf=adapter.GetDatas(); + for (int i=0;i kd= bpa_pf; + if(kd.size()<=0) { T.show(this, "配方信息不能为空!"); return; @@ -188,7 +215,7 @@ public class add_pf_activity extends AppCompatActivity implements View.OnClickLi QueryDB.DeleteGoodsSrecipeList(good.id); } - for (ResGoodsRecipe item:bpa_pf) + for (ResGoodsRecipe item:kd) { BPA_GOODSRECIPE da=new BPA_GOODSRECIPE(); da.goodsID = good.id; @@ -200,6 +227,7 @@ public class add_pf_activity extends AppCompatActivity implements View.OnClickLi QueryDB.AddGoodsSrecipe(da); } T.show(this, "操作成功!"); + MessageManager.getInstance().sendMessage(MessageName.PF_From_Close.name(),"Close"); this.finish(); break; } @@ -210,16 +238,39 @@ public class add_pf_activity extends AppCompatActivity implements View.OnClickLi */ @Override public void clickListener(View v, Object data) { + ResGoodsRecipe wl=(ResGoodsRecipe)data; switch (v.getId()) { case R.id.button_item://删除 - bpa_pf.remove(data); + bpa_pf.remove(wl); DataTab(); break; case R.id.button_item_Up://上移动 - + if(wl.sort==1) + { + T.show(this, "已是最顶部!"); + return; + } + int dq=wl.sort; + ResGoodsRecipe qt= bpa_pf.get(dq-1); + qt.sort=dq; + wl.sort=dq-1; + bpa_pf.set(dq,qt); + bpa_pf.set(dq-1,wl); + DataTab(); break; case R.id.button_item_Down://下移动 - + if(wl.sort==bpa_pf.size()) + { + T.show(this, "已是最底部!"); + return; + } + int dq1=wl.sort; + ResGoodsRecipe qt1= bpa_pf.get(dq1+1); + qt1.sort=dq1; + wl.sort=dq1+1; + bpa_pf.set(dq1,qt1); + bpa_pf.set(dq1+1,wl); + DataTab(); break; } } diff --git a/app/src/main/java/com/example/bpa/view/from/yfpf_activity.java b/app/src/main/java/com/example/bpa/view/from/yfpf_activity.java index e07aa53..53bfb76 100644 --- a/app/src/main/java/com/example/bpa/view/from/yfpf_activity.java +++ b/app/src/main/java/com/example/bpa/view/from/yfpf_activity.java @@ -6,17 +6,22 @@ import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; +import android.widget.AdapterView; import android.widget.Button; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import com.example.bpa.R; +import com.example.bpa.app.BusinessServer; import com.example.bpa.config.ConfigName; +import com.example.bpa.config.MessageName; import com.example.bpa.db.QueryDB; import com.example.bpa.db.mode.BPA_GOODS; import com.example.bpa.helper.Json; import com.example.bpa.helper.T; +import com.example.bpa.message.MessageLooper; +import com.example.bpa.message.MessageManager; import com.example.bpa.view.adapter.sp_adapter; import com.example.bpa.view.inteface.MyClickListener; @@ -75,7 +80,8 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList //通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据 String msg=getIntent().getStringExtra("data"); gongneng_title.setText(msg); - Initdata(); + Initdata();//初始化数据 + RegisterMessage();//消息中心事件接收 } /** @@ -165,11 +171,61 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList break; case R.id.button_item_update://修改按钮 Intent intent = new Intent(this, add_pf_activity.class); - intent.putExtra("title", "新建配方"); + intent.putExtra("title", "修改配方"); intent.putExtra("data",new Json().objectToJson(BPA_GOODS.class,data)); startActivity(intent); break; + case R.id.button_xf://下发按钮 + BusinessServer.get().AddCommodity(((BPA_GOODS)data).id); + T.show(this, "下发成功!"); + break; } } //endregion + + //region 接收事件 + public void RegisterMessage() + { + //配方界面关闭事件 + MessageManager.getInstance().registerMessageReceiver(this, MessageName.PF_From_Close.name(), new MessageLooper.OnMessageListener() { + @Override + public void onMessage(Object msg) { + if (msg != null) { + if(msg.equals("Close")) + { + Initdata(); + } + }else + { + runOnUiThread(new Runnable() { + @Override + public void run() { + T.show(yfpf_activity.this,"服务器异常,请稍后重试!"); + } + }); + } + } + }); + + MessageManager.getInstance().registerMessageReceiver(this, MessageName.PF_From_Close.name(), new MessageLooper.OnMessageListener() { + @Override + public void onMessage(Object msg) { + if (msg != null) { + if(msg.equals("Close")) + { + Initdata(); + } + }else + { + runOnUiThread(new Runnable() { + @Override + public void run() { + T.show(yfpf_activity.this,"服务器异常,请稍后重试!"); + } + }); + } + } + }); + } + //endregion } \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/layout/pf_item.xml b/app/src/main/res/layout/datatab/layout/pf_item.xml index 3ebbb12..c11a00b 100644 --- a/app/src/main/res/layout/datatab/layout/pf_item.xml +++ b/app/src/main/res/layout/datatab/layout/pf_item.xml @@ -22,17 +22,15 @@ + android:layout_weight="2.3"> @@ -111,6 +111,17 @@ android:layout_width="60dp" android:layout_height="26dp" /> +