From 9ec199bd6091b312265ded18a0186306a3531624 Mon Sep 17 00:00:00 2001 From: fyf Date: Wed, 1 Nov 2023 16:13:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=91=E7=AB=AF=E6=8E=A7?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bnframework/business/OrderServer.java | 367 ++++++++++++++++++ .../common/constant/ConfigName.java | 7 + .../bnframework/common/constant/DataBus.java | 3 +- .../bonait/bnframework/common/db/QueryDB.java | 38 +- .../common/db/mode/BPA_GOODPROPERTY.java | 8 + .../common/helper/mode/BPA_GoodsInfo.java | 6 + .../helper/mode/BomAttributeValueReInfo.java | 18 + .../helper/mode/GoodsAttributeInfo.java | 27 ++ .../helper/mode/GoodsAttributeValueInfo.java | 22 ++ .../common/helper/mode/GyAction.java | 8 + .../common/helper/mode/PushDeviceGoods.java | 14 +- .../common/helper/mode/TechnologyActions.java | 11 + .../BottomNavigationMainActivity.java | 5 + .../modules/home/adapter/goodpf_apapter.java | 5 +- .../modules/home/adapter/sx_adapter.java | 49 ++- .../modules/home/adapter/zsx_adapter.java | 13 +- .../fragment/from/GoodPeiFangActivity.java | 3 +- .../from/fragment/Jcsjgl_sxgl_fragment.java | 111 +++++- .../fragment/mode/add_makegood_control.java | 21 +- .../home/fragment/mode/add_pf_control.java | 28 +- app/src/main/res/drawable/input_bj.xml | 22 +- .../res/layout/datatab/layout/sx_item.xml | 41 +- .../res/layout/datatab/layout/wl_item.xml | 8 +- .../main/res/layout/fragment_jcsjgl_sxgl.xml | 29 ++ .../res/layout/item/layout/add_property.xml | 45 +++ .../layout/item/layout/dialog_add_pf_home.xml | 10 +- .../main/res/layout/item/layout/item_zsx.xml | 61 ++- 27 files changed, 934 insertions(+), 46 deletions(-) create mode 100644 app/src/main/java/com/bonait/bnframework/business/OrderServer.java create mode 100644 app/src/main/java/com/bonait/bnframework/common/helper/mode/BomAttributeValueReInfo.java create mode 100644 app/src/main/java/com/bonait/bnframework/common/helper/mode/GoodsAttributeInfo.java create mode 100644 app/src/main/java/com/bonait/bnframework/common/helper/mode/GoodsAttributeValueInfo.java create mode 100644 app/src/main/java/com/bonait/bnframework/common/helper/mode/GyAction.java create mode 100644 app/src/main/java/com/bonait/bnframework/common/helper/mode/TechnologyActions.java create mode 100644 app/src/main/res/layout/item/layout/add_property.xml diff --git a/app/src/main/java/com/bonait/bnframework/business/OrderServer.java b/app/src/main/java/com/bonait/bnframework/business/OrderServer.java new file mode 100644 index 00000000..faf7177a --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/business/OrderServer.java @@ -0,0 +1,367 @@ +package com.bonait.bnframework.business; + +import android.util.Log; + +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_GOODPROPERTY; +import com.bonait.bnframework.common.db.mode.BPA_GOODS; +import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; +import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPENAME; +import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE; +import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; +import com.bonait.bnframework.common.db.mode.BPA_MENU; +import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL; +import com.bonait.bnframework.common.helper.AES; +import com.bonait.bnframework.common.helper.I.IMessage; +import com.bonait.bnframework.common.helper.I.IRun; +import com.bonait.bnframework.common.helper.I.IThread; +import com.bonait.bnframework.common.helper.Json; +import com.bonait.bnframework.common.helper.MQTT; +import com.bonait.bnframework.common.helper.MessageLog; +import com.bonait.bnframework.common.helper.ThreadManager; +import com.bonait.bnframework.common.helper.mode.BPAPackage; +import com.bonait.bnframework.common.helper.mode.BPA_GoodsInfo; +import com.bonait.bnframework.common.helper.mode.BPA_HeartPackage; +import com.bonait.bnframework.common.helper.mode.BatchingsInfo; +import com.bonait.bnframework.common.helper.mode.Batchingstechnology; +import com.bonait.bnframework.common.helper.mode.BomAttributeValueReInfo; +import com.bonait.bnframework.common.helper.mode.GoodsAttributeInfo; +import com.bonait.bnframework.common.helper.mode.GoodsAttributeValueInfo; +import com.bonait.bnframework.common.helper.mode.GoodsBom; +import com.bonait.bnframework.common.helper.mode.GyAction; +import com.bonait.bnframework.common.helper.mode.Message_HeartModel; +import com.bonait.bnframework.common.helper.mode.PushDeviceGoods; +import com.bonait.bnframework.common.helper.mode.TechnologyActions; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; + +/** + * 订单服务 + * 收发订单、订单预警、接收云端订单信息 + */ +public class OrderServer { + + //region 私有单例 + private static volatile OrderServer _instance; + + public static OrderServer Get() { + if (_instance == null) + _instance = new OrderServer(); + return _instance; + } + + private OrderServer() { + } + //endregion + + //region 变量 + //endreigon + + //region 公共函数 + /** + * 初始化 + */ + public void Init() + { + } + + /** + * MQTT初始化 + */ + public void MqttInit() + { + //消息回调 + MQTT.get().callback=new IMessage() { + @Override + public void MessageRecive(String topic, String Message) { + try { + if(!Message.isEmpty()) + { + + String msg= new AES().Decrypt(Message); + if(!msg.isEmpty()) + { + Log.d("远程数据更新", msg); + BPAPackage model=new Json().jsonToobject(BPAPackage.class,((String)msg)); + if((model.ClientId+"").equals(ConfigName.getInstance().DeviceAutoKey) && model.ClientType==9) + { + + MessageLog.ShowInfo("收到远程更新数据通知!"); + RefreshTheData(model.Message); + } + } + } + } catch (Exception e) { + Log.d("1", "MessageRecive: "); + } + } + }; + //连接成功标志 + MQTT.get().ConnectOk=new IRun() { + @Override + public void Run() { + + String[] Str={ConfigName.getInstance().mqtt_topic+ ConfigName.getInstance().ClientAutoKey}; + MQTT.get().Subscrib(Str); + MessageLog.ShowInfo("订阅主题:" + Str); + + } + }; + //初始化MQTT连接 + MQTT.get().Connect(ConfigName.getInstance().mqtt_userName, + ConfigName.getInstance().mqtt_passWord, + ConfigName.getInstance().mqtt_ip, + ConfigName.getInstance().mqtt_post); + + ThreadManager.Get().StartLong("心跳服务", true, new IThread() { + @Override + public void Run() throws InterruptedException { + + if(MQTT.get().IsConnect) + { + try { + PushHeart(); + } catch (Exception e) { + + } + } + Thread.sleep(1000); + } + @Override + public void RunComplete() throws InterruptedException { + } + }); + } + + public void PushHeart() throws Exception { + BPA_HeartPackage heart=new BPA_HeartPackage(); + heart.MessageId=16; + heart.ClientId=Integer.parseInt(ConfigName.getInstance().DeviceAutoKey); + heart.ClientType=9; + Message_HeartModel mode=new Message_HeartModel(); + mode.DeviceType=9; + mode.Healthy=1; + heart.Message=mode; + heart.MessageVersion=0; + heart.Timestamp=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + String Message= new Json().objectToJson(BPA_HeartPackage.class,heart); + String msg= new AES().Encrypt(Message); + + MQTT.get().publish(ConfigName.getInstance().mqtt_hearttopic,msg); + } + /** + * 刷新数据 + * @param data + */ + public void RefreshTheData(PushDeviceGoods data) + { + try { + //region 更新商品类型 + List GoodType=new ArrayList<>(); + for (BPA_GOODSTYPE item: QueryDB.GetGoodsTypeALL()) + { + QueryDB.DeleteGoodsType(item); + } + for (BPA_GoodsInfo item:data.GoodsInfos) + { + if(!GoodType.contains(item.Goods_TypeID)) + { + BPA_GOODSTYPE bpa_goodstype = new BPA_GOODSTYPE(); + bpa_goodstype.id=item.TypeId; + bpa_goodstype.name =item.Goods_TypeID; + bpa_goodstype.deviceID = ConfigName.getInstance().DeviceId; + bpa_goodstype.userID = ConfigName.getInstance().user.userID; + QueryDB.AddGoodsType(bpa_goodstype); + } + GoodType.add(item.Goods_TypeID); + } + //endregion + + //region 更新规格属性 + for (BPA_GOODPROPERTY item: QueryDB.GetGoodsPropertyALL("0")) + { + ArrayList ddd=QueryDB.GetGoodsPropertyALL(item.id); + for (BPA_GOODPROPERTY item1:ddd) + { + QueryDB.DeleteGoodsProperty(item1); + } + QueryDB.DeleteGoodsProperty(item); + } + + for (GoodsAttributeInfo info :data.GoodsAttributeInfo) + { + BPA_GOODPROPERTY bpa_goodproperty = new BPA_GOODPROPERTY(); + bpa_goodproperty.id=info.Id; + bpa_goodproperty.name = info.AttributeName; + bpa_goodproperty.foreignKeyRe = ""; + bpa_goodproperty.parentid = "0"; + bpa_goodproperty.GoodsTypeId=info.GoodsTypeId; + bpa_goodproperty.sort=info.Sort; + bpa_goodproperty.deviceID = ConfigName.getInstance().DeviceId; + bpa_goodproperty.userID = ConfigName.getInstance().user.userID; + QueryDB.AddGoodsProperty(bpa_goodproperty); + for (GoodsAttributeValueInfo val: info.GoodsAttributeValue) + { + bpa_goodproperty.id=val.Id; + bpa_goodproperty.name = val.AttributeValue; + bpa_goodproperty.foreignKeyRe = val.WaiKey; + bpa_goodproperty.parentid = info.Id; + bpa_goodproperty.GoodsTypeId=""; + bpa_goodproperty.sort=val.Sort; + bpa_goodproperty.deviceID = ConfigName.getInstance().DeviceId; + bpa_goodproperty.userID = ConfigName.getInstance().user.userID; + QueryDB.AddGoodsProperty(bpa_goodproperty); + } + } + //endregion + + //region 更新商品数据 + for (BPA_GOODS item:QueryDB.GetGoodsALL()) + { + QueryDB.DeleteGoods(item); + } + + int k=1; + for (BPA_GoodsInfo item:data.GoodsInfos) + { + BPA_GOODS goodx = new BPA_GOODS(); + goodx.id=item.Id; + goodx.name = item.Goods_Name; + goodx.sort = item.Goods_Sort==0?k: item.Goods_Sort; + goodx.maketime = 180; + goodx.issc = 1; + goodx.status = item.Status==1?0:1; + goodx.url=item.Goods_ImgUrl; + goodx.deviceID = ConfigName.getInstance().DeviceId; + goodx.userID = ConfigName.getInstance().user.userID; + goodx.foreignKeyRe=item.ForeignKeyRe; + goodx.goodtype=item.TypeId; + goodx.materialids=item.materialids; + QueryDB.AddGoods(goodx); + k++; + } + //endregion + + //region 更新物料数据,料仓物料绑定关系 + for (BPA_MATERIAL item:QueryDB.GetMaterialALL()) + { + QueryDB.DeleteMaterial(item); + } + + //物料id / 物料数据 + ConcurrentHashMap Info=new ConcurrentHashMap<>(); + List bayc=data.BatchingsInfos; + Collections.sort(bayc, new Comparator() { + @Override + public int compare(BatchingsInfo o1, BatchingsInfo o2) { + + return Double.valueOf(o1.BatchingKey).compareTo(Double.valueOf(o2.BatchingKey)); + } + }); + Integer I=0; + for (BatchingsInfo item:bayc) + { + BPA_MATERIAL bpa_material=new BPA_MATERIAL(); + bpa_material.id=item.BatchingId; + bpa_material.name=item.BatchingName; + bpa_material.imgUrl=""; + bpa_material.type=0; + bpa_material.createTime=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(new Date().getTime() + I*1000));; + bpa_material.deviceID= ConfigName.getInstance().DeviceId; + bpa_material.userID=ConfigName.getInstance().user.userID; + if(!Info.containsKey(item.BatchingId)) + Info.put(item.BatchingId,bpa_material); + I++; + } + for (String item:Info.keySet()) + { + QueryDB.AddMaterial(Info.get(item)); + } + + for (BPA_SILOSANDMATERIAL item:QueryDB.GetSilosAndMaterialALL())//删除料仓关联物料 + { + BatchingsInfo info=null; + for (BatchingsInfo wl:bayc) + { + if (wl.BatchingId.equals(item.materialID)) + { + info=wl; + } + } + if(info==null) + { + item.materialID=""; + QueryDB.UpdateSilosAndMaterial(item); + } + } + //endregion + + //region 更新商品配方 配方信息 + for (BPA_GOODSRECIPENAME item:QueryDB.GetGoodsSrecipeNameALL())//商品配方表 + { + QueryDB.DeleteGoodsRecipeName(item); + } + for (BPA_GOODSRECIPE item:QueryDB.GetGoodsSrecipeALL())//删除商品配方明细 + { + QueryDB.DeleteGoodsSrecipe(item); + } + + + ConcurrentHashMap bomAttributeValueReInfo=new ConcurrentHashMap<>(); + for (BomAttributeValueReInfo item:data.BomAttributeValueReInfo)//商品配方关联表 + { + if(!Info.containsKey(item.GoodsId+","+item.BoomId)) + { + bomAttributeValueReInfo.put(item.GoodsId+","+item.BoomId,item); + } + } + + for (GoodsBom item:data.GoodsBomInfos)//商品配方信息 + { + BPA_GOODSRECIPENAME n=new BPA_GOODSRECIPENAME(); + n.id=item.GoodsBomId; + n.name=item.BomName; + n.goodsID=item.GoodsId; + BomAttributeValueReInfo km=bomAttributeValueReInfo.get(item.GoodsId+","+item.BomId); + if(km!=null) + { + n.design=km.GoodsAttributeValueId; + } + QueryDB.AddGoodsRecipeName(n); + + + BPA_GOODSRECIPE da=new BPA_GOODSRECIPE(); + da.goodsID = item.GoodsId; + da.exp=item.BomName; + da.materialType =1; + da.recipeID=item.GoodsBomId; + da.deviceID = ConfigName.getInstance().DeviceId; + da.userID = ConfigName.getInstance().user.userID; + for (BatchingsInfo info: data.BatchingsInfos) + { + if(info.GoodsBomId.equals(item.GoodsBomId)) + { + da.id=info.Id; + da.materialID = info.BatchingId; + da.value =String.format ("%.1f", info.BomQty); + da.sort =0; + QueryDB.AddGoodsSrecipe(da); + } + } + } + //endregion + } catch (Exception e) { + Log.d("TAG", "RefreshTheData: "); + } + } + //endregion +} 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 83644a07..03663d02 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 @@ -747,6 +747,10 @@ public class ConfigName { add(new Res_PLCADDRESS("手动控制11", "M52.0", 1, 1)); add(new Res_PLCADDRESS("手动控制12", "M52.1", 1, 1)); add(new Res_PLCADDRESS("手动控制13", "M52.2", 1, 1)); + add(new Res_PLCADDRESS("手动控制14", "M52.3", 1, 1)); + add(new Res_PLCADDRESS("手动控制15", "M52.4", 1, 1)); + add(new Res_PLCADDRESS("手动控制16", "M52.5", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓1反转", "M50.6", 1, 1)); add(new Res_PLCADDRESS("M_外置仓2反转", "M50.7", 1, 1)); @@ -807,6 +811,9 @@ public class ConfigName { add(new ResSilosModel("陈醋仓", 11)); add(new ResSilosModel("猪油仓", 12)); add(new ResSilosModel("牛油仓", 13)); + add(new ResSilosModel("粉料仓", 14)); + add(new ResSilosModel("粉料仓", 15)); + add(new ResSilosModel("粉料仓", 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 e8e1d80b..9f7af455 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 @@ -291,7 +291,8 @@ public class DataBus { _chid.add(m); } re.child = _chid; - + re.GoodsTypeId=item.GoodsTypeId; + re.sort= item.sort; bpa_goodproperties.add(re); } 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 7b854190..d31908d8 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 @@ -1075,7 +1075,7 @@ public class QueryDB { * @return */ public static ArrayList GetGoodsPropertyALL(String parentid) { - String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String orderby = Desc_Sort_Up + ',' +Desc_Time_Up;//先按排序 创建时间倒序 String where = "isDelete=? and parentid=?"; String[] args = new String[]{"0", parentid}; ArrayList data = new ArrayList<>(); @@ -1144,6 +1144,22 @@ public class QueryDB { Update(BPA_GOODPROPERTY.class, goodproperty); } } + + public static void UpdateGoodsPropertySort(String id, int sort) { + BPA_GOODPROPERTY goodproperty = GetGoodsPropertyID(id); + if (goodproperty != null) { + goodproperty.sort = sort; + Update(BPA_GOODPROPERTY.class, goodproperty); + } + } + + public static void UpdateGoodsPropertyType(String id, String sort) { + BPA_GOODPROPERTY goodproperty = GetGoodsPropertyID(id); + if (goodproperty != null) { + goodproperty.GoodsTypeId = sort; + Update(BPA_GOODPROPERTY.class, goodproperty); + } + } //endregion //region BPA_GOODSRECIPENAME 商品配方关联表 @@ -1180,6 +1196,23 @@ public class QueryDB { return Delete(BPA_GOODSRECIPENAME.class, data.id); } + /** + * 获取所有商品配方明细 + * + * @return + */ + public static ArrayList GetGoodsSrecipeNameALL() { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=?"; + String[] args = new String[]{"0"}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_GOODSRECIPENAME.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_GOODSRECIPENAME) k); + } + return data; + } + /** * 商品ID查询配方关联表 * @@ -3213,6 +3246,9 @@ public class QueryDB { ((BPA_GOODPROPERTY) data).name = cursor.getString((int) cursor.getColumnIndex("name")); ((BPA_GOODPROPERTY) data).foreignKeyRe = cursor.getString((int) cursor.getColumnIndex("foreignKeyRe")); ((BPA_GOODPROPERTY) data).parentid = cursor.getString((int) cursor.getColumnIndex("parentid")); + ((BPA_GOODPROPERTY) data).sort = cursor.getInt((int) cursor.getColumnIndex("sort")); + ((BPA_GOODPROPERTY) data).GoodsTypeId = cursor.getString((int) cursor.getColumnIndex("GoodsTypeId")); + break; case "BPA_GOODSRECIPENAME": data = new BPA_GOODSRECIPENAME(); diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODPROPERTY.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODPROPERTY.java index 242a978c..3c86e6de 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODPROPERTY.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODPROPERTY.java @@ -11,4 +11,12 @@ public class BPA_GOODPROPERTY extends ModeBase { public String foreignKeyRe; //父id public String parentid; + /** + * 排序 + */ + public int sort; + /** + * 商品类型id + */ + public String GoodsTypeId; } diff --git a/app/src/main/java/com/bonait/bnframework/common/helper/mode/BPA_GoodsInfo.java b/app/src/main/java/com/bonait/bnframework/common/helper/mode/BPA_GoodsInfo.java index 1fec461a..5335f463 100644 --- a/app/src/main/java/com/bonait/bnframework/common/helper/mode/BPA_GoodsInfo.java +++ b/app/src/main/java/com/bonait/bnframework/common/helper/mode/BPA_GoodsInfo.java @@ -46,4 +46,10 @@ public class BPA_GoodsInfo { public String UpdateBy; public String GroupId; + + public String ForeignKeyRe;//外键 + public String Design;//做法 + + public String TypeId;//小类id + public String materialids;//默认物料集合 } diff --git a/app/src/main/java/com/bonait/bnframework/common/helper/mode/BomAttributeValueReInfo.java b/app/src/main/java/com/bonait/bnframework/common/helper/mode/BomAttributeValueReInfo.java new file mode 100644 index 00000000..f54785f3 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/helper/mode/BomAttributeValueReInfo.java @@ -0,0 +1,18 @@ +package com.bonait.bnframework.common.helper.mode; + +public class BomAttributeValueReInfo +{ + public String Id ; + /** + * 商品id + */ + public String GoodsId ; + /** + * 配方id + */ + public String BoomId ; + /** + * 商品做法id + */ + public String GoodsAttributeValueId ; +} diff --git a/app/src/main/java/com/bonait/bnframework/common/helper/mode/GoodsAttributeInfo.java b/app/src/main/java/com/bonait/bnframework/common/helper/mode/GoodsAttributeInfo.java new file mode 100644 index 00000000..770c4575 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/helper/mode/GoodsAttributeInfo.java @@ -0,0 +1,27 @@ +package com.bonait.bnframework.common.helper.mode; + +import java.util.List; + +/** + * 规格属性表 + */ +public class GoodsAttributeInfo +{ + public String Id; + /** + * 属性名称 + */ + public String AttributeName; + /** + * 商品类型id + */ + public String GoodsTypeId; + /** + * 排序 + */ + public int Sort; + /** + * 子属性 + */ + public List GoodsAttributeValue; +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/common/helper/mode/GoodsAttributeValueInfo.java b/app/src/main/java/com/bonait/bnframework/common/helper/mode/GoodsAttributeValueInfo.java new file mode 100644 index 00000000..15cc73d4 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/helper/mode/GoodsAttributeValueInfo.java @@ -0,0 +1,22 @@ +package com.bonait.bnframework.common.helper.mode; + +public class GoodsAttributeValueInfo +{ + public String Id; + /** + * 商品属性id + */ + public String GoodsAttributeId; + /** + * 属性名称 + */ + public String AttributeValue; + /** + * 排序 + */ + public int Sort; + /** + * 外键 + */ + public String WaiKey; +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/common/helper/mode/GyAction.java b/app/src/main/java/com/bonait/bnframework/common/helper/mode/GyAction.java new file mode 100644 index 00000000..9b15854e --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/helper/mode/GyAction.java @@ -0,0 +1,8 @@ +package com.bonait.bnframework.common.helper.mode; + +public class GyAction { + public String TechnologyactionId ;//工艺id + public String ActionName ;//名称 + public String ActionValue ;//变量 + public String BatchingId ;//物料id +} diff --git a/app/src/main/java/com/bonait/bnframework/common/helper/mode/PushDeviceGoods.java b/app/src/main/java/com/bonait/bnframework/common/helper/mode/PushDeviceGoods.java index 3171274a..ca4e0f95 100644 --- a/app/src/main/java/com/bonait/bnframework/common/helper/mode/PushDeviceGoods.java +++ b/app/src/main/java/com/bonait/bnframework/common/helper/mode/PushDeviceGoods.java @@ -19,7 +19,19 @@ public class PushDeviceGoods { /// public List BatchingsInfos; /// - /// 配方绑定的工艺 + /// 配方绑定的工艺-> 单流程工艺 /// public List Batchingstechnologys; + /// + /// 商品工艺信息 -->多流程工艺 + /// + public List TechnologyActions; //暂时不使用 + /// + /// 商品属性 + /// + public List GoodsAttributeInfo ; + /// + /// 商品配方关联表 + /// + public List BomAttributeValueReInfo; } diff --git a/app/src/main/java/com/bonait/bnframework/common/helper/mode/TechnologyActions.java b/app/src/main/java/com/bonait/bnframework/common/helper/mode/TechnologyActions.java new file mode 100644 index 00000000..0d50da2f --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/helper/mode/TechnologyActions.java @@ -0,0 +1,11 @@ +package com.bonait.bnframework.common.helper.mode; + +public class TechnologyActions { + public String Id ; + public String StepName;//工艺名称 + public boolean IsBatch ;//是否批量处理 + public String BomId ;// 配方分类 id + public String ChnologyId ;//工艺模型id + public String ActionJson ;//信息json + public String Sort;//排序 +} diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java index 9dbf74e9..27c0b45f 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java @@ -12,9 +12,11 @@ import android.widget.RelativeLayout; import com.bonait.bnframework.R; import com.bonait.bnframework.business.ConfigData; +import com.bonait.bnframework.business.OrderServer; import com.bonait.bnframework.common.base.BaseActivity; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.helper.I.IThread; +import com.bonait.bnframework.common.helper.MQTT; import com.bonait.bnframework.common.helper.MediaPlayerHelper; import com.bonait.bnframework.common.helper.MessageLog; import com.bonait.bnframework.common.helper.ThreadManager; @@ -73,6 +75,7 @@ public class BottomNavigationMainActivity extends BaseActivity { //关闭PLC连接 ConfigData.getInstance().ColsePLC(); MediaPlayerHelper.getInstance().Release(); + MQTT.get().ConnMqttBroken(false);//释放mqtt super.onDestroy(); } @@ -114,6 +117,8 @@ public class BottomNavigationMainActivity extends BaseActivity { ConfigData.getInstance().ToggleEnvironment(); //2.初始化PLC ReconnectModbus(); + //MQTT数据监听 + OrderServer.Get().MqttInit(); //初始化阿里云连接 //AliyunIOTManager.getInstance().OpenDev(this); } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/goodpf_apapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/goodpf_apapter.java index f6322801..85f3c696 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/goodpf_apapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/goodpf_apapter.java @@ -6,6 +6,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; +import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; @@ -42,8 +43,8 @@ public class goodpf_apapter extends ArrayAdapter { View view = LayoutInflater.from(getContext()).inflate(resource1, parent, false); //分别获取 image view 和 textview 的实例 TextView name = view.findViewById(R.id.name); - Button button = view.findViewById(R.id.button_item); - Button button_update = view.findViewById(R.id.button_update); + ImageView button = view.findViewById(R.id.button_item); + ImageView button_update = view.findViewById(R.id.button_update); // 设置要显示的图片和文字 name.setText(bpa_goodsrecipename.name); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/sx_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/sx_adapter.java index 28773f20..a613a1cb 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/sx_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/sx_adapter.java @@ -16,6 +16,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.bonait.bnframework.R; import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_GOODPROPERTY; +import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE; import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.view.MyLayoutManager; @@ -29,13 +30,16 @@ public class sx_adapter extends ArrayAdapter { */ private MyClickListener mListener; private List datas; + + private ArrayList goodstypes; int resource1; public Context contextA; - public sx_adapter(@NonNull Context context, int resource, @NonNull List objects, MyClickListener listener) { + public sx_adapter(@NonNull Context context, int resource, @NonNull List objects, ArrayList bpa_goodstypes, MyClickListener listener) { super(context, resource, objects); mListener = listener; contextA=context; datas=objects; + goodstypes=bpa_goodstypes; this.resource1=resource; } //每个子项被滚动到屏幕内的时候会被调用 @@ -47,8 +51,12 @@ public class sx_adapter extends ArrayAdapter { View view = LayoutInflater.from(getContext()).inflate(resource1, parent, false); //分别获取 image view 和 textview 的实例 TextView name = view.findViewById(R.id.name);//属性名称 + TextView sort = view.findViewById(R.id.sort);//排序 + TextView typeS = view.findViewById(R.id.typeS);//排序 + ImageView button = view.findViewById(R.id.button_item);//删除 ImageView button_add = view.findViewById(R.id.button_add);//增加 子属性 + RecyclerView recyclerView=view.findViewById(R.id.recycler_view); ArrayList zsx= QueryDB.GetGoodsPropertyALL(bpa_goodproperty.id); @@ -62,7 +70,9 @@ public class sx_adapter extends ArrayAdapter { // 设置要显示的图片和文字 name.setText(bpa_goodproperty.name); + sort.setText(bpa_goodproperty.sort+""); + typeS.setText(GetName(bpa_goodproperty.GoodsTypeId)); name.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -70,6 +80,20 @@ public class sx_adapter extends ArrayAdapter { } }); + sort.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(mListener!=null) mListener.clickListener(view,bpa_goodproperty); + } + }); + + typeS.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(mListener!=null) mListener.clickListener(view,bpa_goodproperty); + } + }); + button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -85,4 +109,27 @@ public class sx_adapter extends ArrayAdapter { }); return view; } + + public String GetName(String ids) + { + String name=""; + if(ids==null || ids.isEmpty()) + { + return ""; + } + for (BPA_GOODSTYPE item:goodstypes) + { + if(ids.contains(item.id)) + { + name+=item.name+","; + } + } + + if(!name.isEmpty()) + { + name=name.substring(0, name.length() - 1); + } + + return name; + } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/zsx_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/zsx_adapter.java index 1ad2eb80..0892c1c3 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/zsx_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/zsx_adapter.java @@ -64,13 +64,19 @@ public class zsx_adapter extends RecyclerView.Adapter { MyLCViewHolder1 myViewHolder = (MyLCViewHolder1) holder; myViewHolder.edittext.setText(goodproperty.name+""); myViewHolder.edittext_wj.setText(goodproperty.foreignKeyRe+""); + myViewHolder.edittext_px.setText(goodproperty.sort+""); myViewHolder.save_text.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - + String xh=myViewHolder.edittext_px.getText().toString(); + if(xh==null || xh.isEmpty()) + { + ToastUtils.info("排序不能为空"); + return; + } goodproperty.name=myViewHolder.edittext.getText().toString(); goodproperty.foreignKeyRe=myViewHolder.edittext_wj.getText().toString(); - + goodproperty.sort=Integer.parseInt(xh); if (goodproperty.name.isEmpty()) { ToastUtils.info("属性名称不能为空"); return; @@ -129,6 +135,7 @@ public class zsx_adapter extends RecyclerView.Adapter { public static class MyLCViewHolder1 extends RecyclerView.ViewHolder { EditText edittext;//名称 EditText edittext_wj;//外键 + EditText edittext_px;//排序 TextView save_text; TextView delete_text; public MyLCViewHolder1(View view) { @@ -137,7 +144,7 @@ public class zsx_adapter extends RecyclerView.Adapter { edittext_wj=view.findViewById(R.id.edittext_wj); save_text=view.findViewById(R.id.save_text); delete_text=view.findViewById(R.id.delete_text); - + edittext_px=view.findViewById(R.id.edittext_px); } } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/GoodPeiFangActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/GoodPeiFangActivity.java index e5322650..48c7bd0c 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/GoodPeiFangActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/GoodPeiFangActivity.java @@ -317,7 +317,8 @@ public class GoodPeiFangActivity extends BaseActivity { _chid.add(m); } re.child = _chid; - + re.GoodsTypeId=item.GoodsTypeId; + re.sort= item.sort; bpa_goodproperties.add(re); } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_sxgl_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_sxgl_fragment.java index 451c18c8..a942f3a6 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_sxgl_fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_sxgl_fragment.java @@ -18,6 +18,7 @@ import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.DataBus; import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_GOODPROPERTY; +import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE; import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.utils.AlertDialogUtils; @@ -28,6 +29,8 @@ import com.qmuiteam.qmui.widget.dialog.QMUIDialog; import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; import butterknife.BindView; import butterknife.ButterKnife; @@ -41,6 +44,10 @@ public class Jcsjgl_sxgl_fragment extends BaseFragment implements MyClickListene * 属性数据 */ ArrayList bpa_goodproperties = new ArrayList<>(); + + ArrayList bpa_goodstypes=new ArrayList<>(); + ConcurrentHashMap itemstypes=new ConcurrentHashMap<>(); + private Context context; @Override protected View onCreateView() { @@ -61,6 +68,16 @@ public class Jcsjgl_sxgl_fragment extends BaseFragment implements MyClickListene * 初始化界面 */ public void InitView() { + bpa_goodstypes= QueryDB.GetGoodsTypeALL(); + itemstypes.clear(); + for (BPA_GOODSTYPE item:bpa_goodstypes) + { + if(!itemstypes.containsKey(item.name)) + { + itemstypes.put(item.name,item.id); + } + } + Initdata_sx(); } @@ -91,6 +108,7 @@ public class Jcsjgl_sxgl_fragment extends BaseFragment implements MyClickListene bpa_goodproperty.name = text.toString(); bpa_goodproperty.foreignKeyRe = ""; bpa_goodproperty.parentid = "0"; + bpa_goodproperty.sort=0; bpa_goodproperty.deviceID = ConfigName.getInstance().DeviceId; bpa_goodproperty.userID = ConfigName.getInstance().user.userID; QueryDB.AddGoodsProperty(bpa_goodproperty); @@ -149,6 +167,95 @@ public class Jcsjgl_sxgl_fragment extends BaseFragment implements MyClickListene }) .show(); break; + case R.id.sort: + final QMUIDialog.EditTextDialogBuilder builder1 = new QMUIDialog.EditTextDialogBuilder(context); + builder1.setTitle("排序") + .setPlaceholder("在此输入排序") + .setDefaultText(((BPA_GOODPROPERTY) data).sort+"") + .setInputType(InputType.TYPE_CLASS_NUMBER) + .addAction("取消", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + dialog.dismiss(); + } + }) + .addAction("确定", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + CharSequence text = builder1.getEditText().getText(); + if (text != null && text.length() > 0) { + QueryDB.UpdateGoodsPropertySort(((BPA_GOODPROPERTY) data).id, Integer.parseInt(text.toString())); + Initdata_sx(); + dialog.dismiss(); + } else { + //请填入昵称 + ToastUtils.info("排序不能为空!"); + } + } + }) + .show(); + break; + case R.id.typeS: + ArrayList keys=new ArrayList(); + String[] items = itemstypes.keySet().toArray(new String[itemstypes.keySet().size()]); + + + + if(((BPA_GOODPROPERTY) data).GoodsTypeId!=null && !((BPA_GOODPROPERTY) data).GoodsTypeId.isEmpty()) + { + for (int i=0;i bpa_goodproperties = new ArrayList<>(); private void initData() { //2.填充规则数据,查询所有属性大类 @@ -89,9 +90,23 @@ public class add_makegood_control extends LinearLayout{ layoutManager.setOrientation(LinearLayoutManager.VERTICAL); datatab_makesx.setLayoutManager(layoutManager); - if(DataBus.getInstance().sxadapter==null) + //if(DataBus.getInstance().sxadapter==null) { - DataBus.getInstance().sxadapter = new pfsx_adapter(contextMian,DataBus.getInstance().bpa_goodproperties); + bpa_goodproperties.clear(); + for (ResGoodProperty pro:DataBus.getInstance().bpa_goodproperties) + { + if(pro.GoodsTypeId!=null && !pro.GoodsTypeId.isEmpty()) + { + if(pro.GoodsTypeId.contains(Good.goodtype)) + { + bpa_goodproperties.add(pro); + } + }else + { + bpa_goodproperties.add(pro); + } + } + DataBus.getInstance().sxadapter = new pfsx_adapter(contextMian,bpa_goodproperties); } datatab_makesx.setAdapter(DataBus.getInstance().sxadapter); @@ -176,7 +191,7 @@ public class add_makegood_control extends LinearLayout{ public boolean DataValidation() { //1.数据名称不能为空 ggids = "";names=""; - for (ResGoodProperty item : DataBus.getInstance().bpa_goodproperties) { + for (ResGoodProperty item : bpa_goodproperties) { for (ResGoodProperty k : item.child) { if (k.isSelect) { ggids += k.id + ","; diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_control.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_control.java index cb9eb680..83243a92 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_control.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_pf_control.java @@ -126,6 +126,10 @@ public class add_pf_control extends LinearLayout implements MyClickListener { 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); adapter4.notifyDataSetChanged(); @@ -198,7 +202,7 @@ public class add_pf_control extends LinearLayout implements MyClickListener { { for(BPA_MATERIAL wl:resMaterilas) { - if(Good.materialids.contains(wl.id)) + if(Good.materialids!=null && !Good.materialids.isEmpty() && Good.materialids.contains(wl.id)) { ResGoodsRecipe cipe=new ResGoodsRecipe(); cipe.sort=0; @@ -210,6 +214,11 @@ public class add_pf_control extends LinearLayout implements MyClickListener { } } } + + 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); } @@ -222,7 +231,22 @@ public class add_pf_control extends LinearLayout implements MyClickListener { public void SetData(BPA_GOODSRECIPENAME name, BPA_GOODS good,ArrayList properties) { try { - bpa_goodproperties=properties; + //根据商品类型判断属性 + bpa_goodproperties.clear(); + for (ResGoodProperty pro:properties) + { + if(pro.GoodsTypeId!=null && !pro.GoodsTypeId.isEmpty()) + { + if(pro.GoodsTypeId.contains(good.goodtype)) + { + bpa_goodproperties.add(pro); + } + }else + { + bpa_goodproperties.add(pro); + } + } + bpaGoodsrecipename=name; Good=good; if(name!=null) diff --git a/app/src/main/res/drawable/input_bj.xml b/app/src/main/res/drawable/input_bj.xml index e2273fcd..b77ec622 100644 --- a/app/src/main/res/drawable/input_bj.xml +++ b/app/src/main/res/drawable/input_bj.xml @@ -1,12 +1,18 @@ - - - - - - \ No newline at end of file + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/layout/sx_item.xml b/app/src/main/res/layout/datatab/layout/sx_item.xml index ad1176c6..baeff89b 100644 --- a/app/src/main/res/layout/datatab/layout/sx_item.xml +++ b/app/src/main/res/layout/datatab/layout/sx_item.xml @@ -35,8 +35,43 @@ android:layout_marginLeft="20dp" android:layout_alignParentLeft="true" android:text="回锅肉" + android:textAlignment="center" android:textSize="13dp"/> + + + + + + + + + android:layout_centerInParent="true" + android:src="@mipmap/new_delete" /> + android:layout_centerInParent="true" + android:src="@mipmap/new_update" /> diff --git a/app/src/main/res/layout/fragment_jcsjgl_sxgl.xml b/app/src/main/res/layout/fragment_jcsjgl_sxgl.xml index 1ec6a3a9..a4af8ea9 100644 --- a/app/src/main/res/layout/fragment_jcsjgl_sxgl.xml +++ b/app/src/main/res/layout/fragment_jcsjgl_sxgl.xml @@ -96,7 +96,36 @@ android:textStyle="bold" android:textColor="@color/white"/> + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 07ff6560..9f5dee3e 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 @@ -133,12 +133,14 @@ android:layout_weight="1"> + android:textColor="@color/white" /> @@ -148,8 +150,8 @@ android:layout_weight="1"> + android:layout_height="150dp"> + android:orientation="vertical"> + + + + + + + + + android:textSize="12dp" + android:text="0"/> +