From 21287e27ef8e28459137d3bc49156d27ac6afc84 Mon Sep 17 00:00:00 2001
From: fyf <11621@LAPTOP-04QQU0AO>
Date: Sun, 8 Oct 2023 15:05:51 +0800
Subject: [PATCH] 556
---
app/src/main/AndroidManifest.xml | 106 +-
.../bnframework/business/ConfigData.java | 1 +
.../business/ExecuteTheRecipe.java | 913 ++++--------------
.../bonait/bnframework/business/MainInit.java | 3 +
.../bnframework/common/constant/DataBus.java | 22 +-
.../bonait/bnframework/common/db/QueryDB.java | 41 +
.../common/tabbar/MainNavigateTabBar.java | 2 -
.../BottomNavigationMainActivity.java | 21 +-
.../home/adapter/loadinggood_adapter.java | 167 +++-
.../home/fragment/MakeGoodFragment.java | 174 +++-
.../fragment/mode/add_makegood_control.java | 245 +++++
app/src/main/res/drawable/progressbar.xml | 43 +
.../main/res/layout/fragment_make_good.xml | 25 +-
.../item/layout/dialog_add_makegood.xml | 122 +++
.../layout/item/layout/loadinggood_item.xml | 118 +++
app/src/main/res/values/colors.xml | 2 +-
app/src/main/res/values/styles.xml | 8 +
17 files changed, 1134 insertions(+), 879 deletions(-)
create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_makegood_control.java
create mode 100644 app/src/main/res/drawable/progressbar.xml
create mode 100644 app/src/main/res/layout/item/layout/dialog_add_makegood.xml
create mode 100644 app/src/main/res/layout/item/layout/loadinggood_item.xml
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 09568588..e89d3e1a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -35,145 +35,96 @@
tools:replace="android:icon">
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false" tools:ignore="Instantiatable"/>
+ android:exported="false"
+ tools:ignore="Instantiatable" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -217,8 +168,7 @@
-->
-
-
+
diff --git a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java
index 974eda83..21a72df8 100644
--- a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java
+++ b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java
@@ -111,6 +111,7 @@ public class ConfigData {
LoadingPZ();
//3.初始化业务
//4.初始化日志上报adad
+ PLC_Init();
}
/**
diff --git a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
index 9cd24455..49444619 100644
--- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
+++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
@@ -9,17 +9,23 @@ import android.util.Log;
import androidx.annotation.NonNull;
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_GOODSRECIPE;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS;
import com.bonait.bnframework.common.db.mode.BPA_SILOS;
+import com.bonait.bnframework.common.db.res.AlertLogEnum;
+import com.bonait.bnframework.common.db.res.ResGoodsMake;
+import com.bonait.bnframework.common.db.res.ResGoodsRecipe;
+import com.bonait.bnframework.common.db.res.UserLogEnum;
import com.bonait.bnframework.common.helper.ByteHelper;
import com.bonait.bnframework.common.helper.I.IReadCallBack;
import com.bonait.bnframework.common.helper.I.IRun;
import com.bonait.bnframework.common.helper.I.IRunT;
import com.bonait.bnframework.common.helper.I.IThread;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
+import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.RTrig;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.modbus.ModbusTcpServer;
@@ -33,6 +39,7 @@ import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.IdentityHashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -61,25 +68,9 @@ public class ExecuteTheRecipe {
public static ConcurrentHashMap IoStatus = new ConcurrentHashMap();
/**
- * 外部界面
+ * 商品是否制作
*/
- public static Context context = null;
-
- /**
- * 商品是否强制结束
- */
- public static boolean IsForcedEnd = false;
-
- /**
- * 当前配方
- */
- static ArrayList all_list=new ArrayList<>();
-
- static BPA_GOODSRECIPE selectpf;
- /**
- * 当前工序的index
- */
- static int Index_select=0;
+ public static boolean IsMakeGood = false;
/**
* 扫码信息
@@ -107,194 +98,31 @@ public class ExecuteTheRecipe {
*/
public static IRun CleaningComplete;
- //endregion
-
- //region 强制结束
/**
- * 设置强制结束
+ * 当前制作商品
*/
- public static void SetForcedEnd()
- {
- ToastUtils.info("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!");
- IsForcedEnd=true;
- }
-
- /**
- * 停止强制结束
- */
- public static void StopForcedEnd()
- {
- IsForcedEnd=false;
- }
+ public static ResGoodsMake GoodMake=null;
//endregion
//region 执行配方
/**
* 执行配方
*
- * @param recipe
+ * @param
* @return
*/
- public static boolean Execute(BPA_GOODSRECIPE recipe,ArrayList all,int index) {
- boolean status = false;
- all_list=all;
- selectpf=recipe;
- Index_select=index;
+ public static void Execute(ResGoodsMake makegood) {
try {
- //1.解析
- if(IsForcedEnd)
- {
- ToastUtils.info("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!");
- return false;
- }
- ToastUtils.info("开始执行:" + recipe.sort + "、" + recipe.processms);
- if (recipe.materialType == 0)//正常物料
- {
- ExecuteMaterialIssuance(recipe.processvalue);
- } else if (recipe.materialType == 1)//工序模型
- {
- ExecuteOperationSteps(recipe.processname, recipe.processvalue);
- }
+ GoodMake=makegood;
+ IsMakeGood=true;
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
- status = false;
} finally {
- return status;
}
}
- /**
- * 液体物料信息-配料
- *
- * @param text
- */
- private static void ExecuteMaterialIssuance(String text) {
- try {
- ToastUtils.info("准备下料!!!");
-
- if (!text.isEmpty()) {
- //仓号 值
- HashMap formulation = new HashMap<>();
- //region 获取仓号和值
- List data = new ArrayList<>();
- if (text.contains("|")) {
- String[] res = text.split("[|]");
- for (int i = 0; i < res.length; i++) {
- data.add(res[i]);
- }
- } else {
- data.add(text);
- }
- for (String item : data) {
- if (!item.isEmpty() && item.contains(",")) {
- String[] wl = item.split("[,]");
- if (wl != null && wl.length == 2) {
- String name = wl[0];
- int val = (int)Math.round((Double.parseDouble(wl[1]) * 10));
- //int val = Integer.parseInt(wl[1]);
- List bpa_silos = QueryDB.GetSolisByMaterialName(name);
- if (bpa_silos.size() > 0 && val > 0) {
- BPA_SILOS silos = bpa_silos.get(0);
- formulation.put(silos.num, val);
- }
- }
- }
- }
- //endregion
- //写入PLC,直接出料,不用等待
- for (Map.Entry entry : formulation.entrySet()) {
- Integer key = entry.getKey();
- Integer value = entry.getValue();
- Write_PLC_Material(key, value);
- }
- Thread.sleep(200);//等待写入完成
-
- //一直等待下料完成 否则就一直等待 40s超时
- for (Map.Entry entry : formulation.entrySet()) {
- Integer num = entry.getKey();
- Integer val = entry.getValue();
- String name = "料仓" + num + "下料完成";
- final boolean[] IsComplete = {false};
- long a = System.currentTimeMillis();
- while (!IsComplete[0]) {
- if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
- break;
- } else {
- Object sb = ReadPLC(name);// ListeningValue.get(name);
- if (sb != null) {
- IsComplete[0] = (boolean) (sb);
- }
- }
- Thread.sleep(100);//10 *6
- }
- ToastUtils.info(name);
- }
- }
- } catch (Exception ex) {
- ToastUtils.error("异常信息:" + ex.getMessage());
- }
- }
- /**
- * 执行工序步骤
- *
- * @param text
- */
- private static void ExecuteOperationSteps(String processname, String text) {
- try {
- if (!text.isEmpty() && !processname.isEmpty()) {
- //工序名称和值
- HashMap formulation = new HashMap<>();
- //region 获取仓号和值
- List data = new ArrayList<>();
- if (text.contains("|")) {
- String[] res = text.split("[|]");
- for (int i = 0; i < res.length; i++) {
- data.add(res[i]);
- }
- } else {
- data.add(text);
- }
- for (String item : data) {
- if (!item.isEmpty() && item.contains(",")) {
- String[] wl = item.split("[,]");
- if (wl != null && wl.length == 2) {
- String name = wl[0];
- String val = wl[1];
- formulation.put(name, val);
- }
- }
- }
- //endregion
- //写入PLC
- if (formulation.size() > 0) {
- switch (processname) {
- case "搅拌":
- Write_PLC_Stir(formulation);
- break;
- case "位置":
- Write_PLC_Location(formulation);
- break;
- case "加热":
- Write_PLC_Heating(formulation);
- break;
- case "主料":
- Write_PLC_Ingredients(formulation);
- break;
- case "延迟":
- Write_PLC_Delay(formulation);
- break;
- case "出菜":
- Write_PLC_Outdishes(formulation);
- break;
- }
- }
- }
- } catch (Exception ex) {
- ToastUtils.error("异常信息:" + ex.getMessage());
- }
- }
//endregion
//region 物料PLC控制
@@ -340,275 +168,6 @@ public class ExecuteTheRecipe {
//endregion
//region 写PLC工序
-
- /**
- * 写PLC搅拌
- *
- * @param data
- */
- private static void Write_PLC_Stir(HashMap data) {
- try {
- int val=0;
-
- for (HashMap.Entry entry : data.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- ToastUtils.info("工序:" + key + "," + value);
- if (key.contains("(秒)")) {
- val = Integer.parseInt(value);
- } else {
- int writeValue = GetMXValue(key, value);
- WritePLC(key, writeValue, new IWriteCallBack() {
- @Override
- public void onSuccess() {
- if (writeValue == 0) {
- WritePLC("搅拌", false, null);
- } else {
- WritePLC("搅拌", true, null);
- }
- }
-
- @Override
- public void onFailure(String ErrorMsg) {
- }
- });
- }
- }
-
- if(val>0)
- {
- Thread.sleep(val * 1000);
- }
- } catch (Exception ex) {
- ToastUtils.error("异常信息:" + ex.getMessage());
- }
- }
-
- /**
- * 写PLC位置
- *
- * @param data
- */
- private static void Write_PLC_Location(HashMap data) {
- try {
- int val=0;
- ToastUtils.info("准备控制炒锅移动!!!");
- for (HashMap.Entry entry : data.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- if (key.contains("(秒)")) {
- val = Integer.parseInt(value);
- } else if (key.contains("速度")) {
- int writeValue = GetMXValue(key, value);
- WritePLC(key, writeValue, null);
- }
- }
-
- for (HashMap.Entry entry : data.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- ToastUtils.info("工序:" + key + "," + value);
- if (!key.contains("(秒)") && !key.contains("速度")) {
- //原点位,等待机器移动倒响应位置
- BottomClick(value);
-
- //一直等待机器移动到该位置,否则就一直等待 6s超时
- String name = value + "反馈";
- final boolean[] IsComplete = {false};
- long a = System.currentTimeMillis();
- while (!IsComplete[0]) {
- if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
- break;
- } else {
- Object sb = ReadPLC(name);//ListeningValue.get(name);
- if (sb != null) {
- IsComplete[0] = (boolean) (sb);
- }
- }
- Thread.sleep(100);//10 *6
- }
- ToastUtils.info("炒锅到达"+value+",继续制作!!!");
- }
- }
-
- if(val>0)
- {
- Thread.sleep(val * 1000);
- }
- } catch (Exception ex) {
- ToastUtils.error("异常信息:" + ex.getMessage());
- }
- }
-
- /**
- * 写PLC主料
- *
- * @param data
- */
- private static void Write_PLC_Ingredients(HashMap data) {
- try {
- //是否手动
- boolean ishand=true;
- ToastUtils.info("准备倒入主料!");
-
- //region 判断是否手动
- if(ConfigName.getInstance().versionSelectionEnum.equals("大炒版本"))
- {
- ishand=true;
- }else
- {
- for (HashMap.Entry entry : data.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- if (key.contains("投料动作")) {
- if(value.contains("手动投料"))
- {
- ishand=true;
- }else
- {
- ishand=false;
- }
- }
- }
- }
- //endregion
-
-
-
- if(ishand)
- {
- if(ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本") || ConfigName.getInstance().versionSelectionEnum.equals("小炒版本"))
- {
- ExecuteTheRecipe.BottomClick("平移-去1号位");
- }
- String name = "";
- String zl = "";
- int val = 0;
- for (HashMap.Entry entry : data.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- if (key.contains("名称")) {
- name = value;
- } else if (key.contains("重量")) {
- zl = value;
- }
- }
- ToastUtils.info("工序:手动投料," + name + "," + zl);
- String title = "手动投料-温馨提示!";
- String message = "客官请投入主料,[" + name + "]重量" + zl + "g,投入后点击[确定]继续流程!";
-
- final boolean[] IsComplete = {false};
- Activity activity = findActivity(context);
- if (activity != null) {
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- try {
- AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() {
- @Override
- public void onClick(QMUIDialog dialog, int index) {
- IsComplete[0] = true;
- dialog.dismiss();
- }
- });
- } catch (Exception e) {
-
- }
- }
- });
- }
-
- while (!IsComplete[0]) {
- Thread.sleep(100);//10 *6
- }
- ToastUtils.info("确定完成,继续制作!");
- }else
- {
- //自动投料
- if(ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本") || ConfigName.getInstance().versionSelectionEnum.equals("小炒版本"))
- {
- String writeValue = "1号位";
- for (HashMap.Entry entry : data.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- if (key.contains("主料位置")) {
- writeValue=value;
- }
- }
-
- //1.去某一个位置
- BottomClick("平移-去"+writeValue);
- Log.d("平移", "平移-去"+writeValue);
- //一直等待机器移动到该位置,否则就一直等待 6s超时
- String name = "平移轴在"+writeValue;
- final boolean[] IsComplete = {false};
- long a = System.currentTimeMillis();
- while (!IsComplete[0]) {
- if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
- break;
- } else {
- Object sb =ReadPLC(name);// ListeningValue.get(name);
- if (sb != null) {
- IsComplete[0] = (boolean) (sb);
- }
- }
- Thread.sleep(100);//10 *6
- }
- Log.d("平移", name+"已经就位");
-
- //2.给倒菜启动
- BottomClick("主料");
- name = "倒菜完成";
- IsComplete[0]=false;
- a = System.currentTimeMillis();
- while (!IsComplete[0]) {
- if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
- break;
- } else {
- Object sb =ReadPLC(name);// ListeningValue.get(name);
- if (sb != null) {
- IsComplete[0] = (boolean) (sb);
- }
- }
- Thread.sleep(100);//10 *6
- }
- ToastUtils.info("主料倒入完成,继续制作!");
-
- }
- }
- Log.d("倒菜", "倒菜完成了");
-
- if(IsMoveYiHaoWei())
- {
- if(ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本") || ConfigName.getInstance().versionSelectionEnum.equals("小炒版本"))
- {
- ExecuteTheRecipe.BottomClick("平移-去1号位");
- Log.d("移动去", "1号位");
- }
- }
-
- //判断是否有烹饪时间
- int val=0;
- for (HashMap.Entry entry : data.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- if (key.contains("(秒)")) {
- val = Integer.parseInt(value);
- }
- }
- if(val>0)
- {
- Thread.sleep(val * 1000);
- }
-
- Log.d("烹饪时间", "烹饪时间完成了");
-
-
- } catch (Exception ex) {
- ToastUtils.error("异常信息:" + ex.getMessage());
- }
- }
-
/**
* 按下
* @param name
@@ -629,7 +188,6 @@ public class ExecuteTheRecipe {
}
}
-
private static Activity findActivity(@NonNull Context context) {
if (context instanceof Activity) {
return (Activity) context;
@@ -639,279 +197,212 @@ public class ExecuteTheRecipe {
return null;
}
}
-
- /**
- * 写PLC 加热
- *
- * @param data
- */
- private static void Write_PLC_Heating(HashMap data) {
- try {
- int val=0;
- for (HashMap.Entry entry : data.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- ToastUtils.info("工序:" + key + "," + value);
- if (key.contains("(秒)")) {
- val = Integer.parseInt(value);
- } else {
- int writeValue = GetMXValue(key, value);
- WritePLC(key, writeValue, new IWriteCallBack() {
- @Override
- public void onSuccess() {
- if (writeValue == 0) {
- WritePLC("加热", false, null);
- } else {
- WritePLC("加热", true, null);
- }
- }
-
- @Override
- public void onFailure(String ErrorMsg) {
- }
- });
- }
- }
-
- if(val>0)
- {
- Thread.sleep(val * 1000);
- }
-
- } catch (Exception ex) {
- ToastUtils.error("异常信息:" + ex.getMessage());
- }
- }
-
- /**
- * 写PLC 延迟
- *
- * @param data
- */
- private static void Write_PLC_Delay(HashMap data) {
- try {
- for (HashMap.Entry entry : data.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- ToastUtils.info("工序:" + key + "," + value);
- if (key.contains("(秒)")) {
- int val = Integer.parseInt(value);
- Thread.sleep(val * 1000);
- }
- }
- } catch (Exception ex) {
- ToastUtils.error("异常信息:" + ex.getMessage());
- }
- }
-
- /**
- * 写PLC 出菜
- *
- * @param data
- */
- private static void Write_PLC_Outdishes(HashMap data) {
- try {
- ToastUtils.info("准备出菜!");
-
- BottomClick("出菜");
-
- //一直等待机器移动到该位置,否则就一直等待 6s超时
- String name = "出餐启动反馈";
- final boolean[] IsComplete = {false};
- long a = System.currentTimeMillis();
- while (!IsComplete[0]) {
- if ((System.currentTimeMillis() - a) > 1000 * 120) {
- break;
- } else {
- Object sb =ReadPLC(name);//ListeningValue.get(name);
- if (sb != null) {
- IsComplete[0] = (boolean) (sb);
- }
- }
- Thread.sleep(100);//10 *6
- }
-
-
- for (HashMap.Entry entry : data.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- ToastUtils.info("工序:" + key + "," + value);
- if (key.contains("(秒)")) {
- int val = Integer.parseInt(value);
- Thread.sleep(val * 1000);
- }
- }
- ToastUtils.info("出菜完成,结束制作!");
- } catch (Exception ex) {
- ToastUtils.error("异常信息:" + ex.getMessage());
- }
- }
- //endregion
-
- //region 判断当前工序后是否还有 主料 不包含 手动配料
-
- /**
- * 是否还有 主料 不包含 手动配料 如果没有主料的话 那么就是对的
- * @return
- */
- public static boolean IsMoveYiHaoWei()
- {
- boolean IsMove=false;
- try{
- int k=0;
- ArrayList kkkkkk=new ArrayList<>();
- for (BPA_GOODSRECIPE item:all_list)
- {
- if(k>Index_select) //查找当前工序 后的步骤 所有主料
- {
- if(item.processname.contains("主料") && !item.processvalue.contains("手动投料"))// &&
- {
- kkkkkk.add(item);
- }
- }
- k++;
- }
-
- if(kkkkkk.size()<=0)
- {
- IsMove=true;
- }
-
- }catch (Exception ex)
- {
-
- }finally {
- return IsMove;
- }
- }
- //endregion
-
- //region 主页按钮
- /**
- * 点击摇欠按钮
- *
- * @param data
- */
- public static void Write_PLC_YaoQian(MyStatus data) {
- try {
- if (data == MyStatus.Start) {
- ToastUtils.info("点击摇浅按钮");
-
- } else if (data == MyStatus.Stop) {
- ToastUtils.info("点击停摇按钮");
- }
- } catch (Exception ex) {
- ToastUtils.error("异常信息:" + ex.getMessage());
- }
- }
-
- /**
- * 火力点击
- *
- * @param data
- */
- public static void Write_PLC_HuoLI(int data) {
- try {
- WritePLC("加热功率", data, new IWriteCallBack() {
- @Override
- public void onSuccess() {
- if (data == 0) {
- WritePLC("加热", false, null);
- } else {
- WritePLC("加热", true, null);
- }
- }
-
- @Override
- public void onFailure(String ErrorMsg) {
- }
- });
- ToastUtils.info("火力按钮点击,当前级别:" + data);
-
- } catch (Exception ex) {
- ToastUtils.error("异常信息:" + ex.getMessage());
- }
- }
//endregion
//region PLC监听线程
public static void Listening() {
- ConfigName.getInstance().PLC_Address.clear();
- ArrayList address = QueryDB.GetPlcaddressALL();
- for (BPA_PLCADDRESS item : address) {
- if (!item.address.isEmpty() && !item.address.equals("-------------")) {
- ConfigName.getInstance().PLC_Address.put(item.name, item);
- }
- }
-
- ThreadManager.Get().StartLong("PLC设备数据监听", true, new IThread() {
+// ConfigName.getInstance().PLC_Address.clear();
+// ArrayList address = QueryDB.GetPlcaddressALL();
+// for (BPA_PLCADDRESS item : address) {
+// if (!item.address.isEmpty() && !item.address.equals("-------------")) {
+// ConfigName.getInstance().PLC_Address.put(item.name, item);
+// }
+// }
+//
+// ThreadManager.Get().StartLong("PLC设备数据监听", true, new IThread() {
+// @Override
+// public void Run() throws InterruptedException {
+// try {
+// for (String item : ConfigName.getInstance().PLC_Address.keySet()) {
+// String key = item;
+// BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(item);
+// if (plcaddress.isread == 1) {
+// Object val = ReadPLC(key);
+// ListeningValue.put(key, val);
+// }
+// }
+// } catch (Exception ex) {
+// ToastUtils.error("异常信息:" + ex.getMessage());
+// }
+// Thread.sleep(100);
+// }
+//
+// @Override
+// public void RunComplete() throws InterruptedException {
+//
+// }
+// });
+//
+// ThreadManager.Get().StartLong("PLC设备数据监听-扫码信息", true, new IThread() {
+// @Override
+// public void Run() throws InterruptedException {
+// try {
+// ReadCode();
+// } catch (Exception ex) {
+// ToastUtils.error("异常信息:" + ex.getMessage());
+// }
+// Thread.sleep(100);
+// }
+//
+// @Override
+// public void RunComplete() throws InterruptedException {
+//
+// }
+// });
+//
+// ThreadManager.Get().StartLong("PLC设备数据监听-实时状态", true, new IThread() {
+// @Override
+// public void Run() throws InterruptedException {
+// try {
+// ReadPLCStatus();
+// } catch (Exception ex) {
+// ToastUtils.error("异常信息:" + ex.getMessage());
+// }
+// Thread.sleep(100);
+// }
+//
+// @Override
+// public void RunComplete() throws InterruptedException {
+//
+// }
+// });
+//
+// ThreadManager.Get().StartLong("PLC设备数据监听-信号检测", true, new IThread() {
+// @Override
+// public void Run() throws InterruptedException {
+// try {
+// ChargeSignal();
+// } catch (Exception ex) {
+// ToastUtils.error("异常信息:" + ex.getMessage());
+// }
+// Thread.sleep(10);
+// }
+// @Override
+// public void RunComplete() throws InterruptedException {
+//
+// }
+// });
+
+ ThreadManager.Get().StartLong("商品制作线程", true, new IThread() {
@Override
public void Run() throws InterruptedException {
try {
- for (String item : ConfigName.getInstance().PLC_Address.keySet()) {
- String key = item;
- BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(item);
- if (plcaddress.isread == 1) {
- Object val = ReadPLC(key);
- ListeningValue.put(key, val);
+ if(IsMakeGood && GoodMake!=null)
+ {
+ ArrayList recipes= GoodMake.recipes;
+
+ //region 根据物料配方排序Sort步骤分组
+ LinkedHashMap> rgrs = new LinkedHashMap<>();
+ for (int i = 0; i < recipes.size(); i++) {
+ if (!rgrs.containsKey(recipes.get(i).sort))
+ rgrs.put(recipes.get(i).sort, new ArrayList<>());
+ rgrs.get(recipes.get(i).sort).add(recipes.get(i));
}
- }
- } catch (Exception ex) {
- ToastUtils.error("异常信息:" + ex.getMessage());
- }
- Thread.sleep(100);
- }
+ //endregion
- @Override
- public void RunComplete() throws InterruptedException {
+ int count = 0;
+ for (LinkedHashMap.Entry> entry : rgrs.entrySet()) {
- }
- });
+ //复位完成信号
+// WritePLC("手自切换", true,null);
+// WritePLC("配料完成", false,null);
+ Thread.sleep(10);
- ThreadManager.Get().StartLong("PLC设备数据监听-扫码信息", true, new IThread() {
- @Override
- public void Run() throws InterruptedException {
- try {
- ReadCode();
- } catch (Exception ex) {
- ToastUtils.error("异常信息:" + ex.getMessage());
- }
- Thread.sleep(100);
- }
+ final Integer key = entry.getKey();
- @Override
- public void RunComplete() throws InterruptedException {
-
- }
- });
+ List goodsRecipes = entry.getValue();
- ThreadManager.Get().StartLong("PLC设备数据监听-实时状态", true, new IThread() {
- @Override
- public void Run() throws InterruptedException {
- try {
- ReadPLCStatus();
- } catch (Exception ex) {
- ToastUtils.error("异常信息:" + ex.getMessage());
- }
- Thread.sleep(100);
- }
-
- @Override
- public void RunComplete() throws InterruptedException {
+ //region 当前一次性下发物料集合
+ String RecipesNames = "";
+ for (ResGoodsRecipe item : goodsRecipes) {
+ RecipesNames += item.materialName + ",";
+ }
+ count=2;
+ DataBus.getInstance().UpdateGoodsMake(GoodMake.subOrder.id, "步骤【" + key + "】准备下发物料:" + RecipesNames, count, key, false);
+ ArrayList liaochang = new ArrayList();
+ for (int m = 0; m < goodsRecipes.size(); m++) {
+ ResGoodsRecipe recipe = goodsRecipes.get(m);
+ final String message = "[" + GoodMake.good.name + "]步骤【" + key + "】下发【" + recipe.materialName + "】";
+
+
+ //获取物料关联的料仓信息
+ BPA_SILOS silos = null;
+ List siloslist = QueryDB.GetSolisByMaterialID(recipe.materialID);
+ for (BPA_SILOS item : siloslist) {
+ if(silos==null)
+ silos = item;
+ }
+ if (silos == null) {
+ MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发失败!物料没有管理料仓!");
+ } else {
+ liaochang.add(silos.num);
+ MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value);
+ int _val = (int)Math.round((Double.parseDouble(recipe.value) * 10));
+
+// WritePLC("需求值" + silos.num, (short) _val, new IWriteCallBack() {
+// @Override
+// public void onSuccess() {
+// MessageLog.ShowInfo(message + "下发成功!");
+// }
+//
+// @Override
+// public void onFailure(String ErrorMsg) {
+// MessageLog.ShowInfo(message + "下发失败!" + ErrorMsg);
+// }
+// });
+ }
+ }
+ //endregion
+
+ //等待配料完成,一直等待
+ final boolean[] IsComplete = {false};
+ OnChargeMixtureCompleteNotify = new IRun() {
+ @Override
+ public void Run() {
+ IsComplete[0] = true;
+ MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]步骤【" + key + "】配料完成!");
+ }
+ };
+
+ //启动配料
+// WritePLC("配料启动",true,new IWriteCallBack() {
+// @Override
+// public void onSuccess() {
+// MessageLog.ShowInfo("[" + GoodMake.good.name + "]步骤【" + key + "】启动配料成功!");
+// }
+//
+// @Override
+// public void onFailure(String ErrorMsg) {
+// MessageLog.ShowInfo("[" + GoodMake.good.name + "]步骤【" + key + "】启动配料失败!");
+// MessageLog.ShowAlertMessage(AlertLogEnum.异常订单未制作日志, "[" + GoodMake.good.name + "]步骤【" + key + "】启动配料失败!");
+// }
+// });
+
+ long a = System.currentTimeMillis();
+ while (!IsComplete[0]) {
+ if ((System.currentTimeMillis() - a) > 1000 * 5) {
+ break;
+ }
+ Thread.sleep(100);//10 *6
+ }
+ //更新缓存商品制作列表状态
+ count += goodsRecipes.size();
+ DataBus.getInstance().UpdateGoodsMake(GoodMake.subOrder.id, "步骤【" + key + "】:" + RecipesNames + "-配料完成!", count, key, true);
+ MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]步骤【" + key + "】下发" + RecipesNames + "执行完成!");
+ }
- }
- });
+ DataBus.getInstance().DeleteGoodsMake(GoodMake.subOrder.id);
+ MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]-订单执行完成,请取餐!");
- ThreadManager.Get().StartLong("PLC设备数据监听-信号检测", true, new IThread() {
- @Override
- public void Run() throws InterruptedException {
- try {
- ChargeSignal();
+ GoodMake=null;
+ IsMakeGood=false;
+ }
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
+ IsMakeGood=false;
}
- Thread.sleep(10);
+ Thread.sleep(100);
}
@Override
public void RunComplete() throws InterruptedException {
diff --git a/app/src/main/java/com/bonait/bnframework/business/MainInit.java b/app/src/main/java/com/bonait/bnframework/business/MainInit.java
index f885d748..fc81f41b 100644
--- a/app/src/main/java/com/bonait/bnframework/business/MainInit.java
+++ b/app/src/main/java/com/bonait/bnframework/business/MainInit.java
@@ -31,6 +31,7 @@ import com.bonait.bnframework.common.notification.MainNotification;
import com.bonait.bnframework.common.utils.AppUtils;
import com.bonait.bnframework.common.utils.NetworkUtils;
import com.bonait.bnframework.common.utils.PreferenceUtils;
+import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.common.utils.WifiInterceptor;
import com.bonait.bnframework.manager.ActivityLifecycleManager;
import com.lzy.okgo.OkGo;
@@ -100,6 +101,7 @@ public class MainInit {
InitDBdata();
ConfigData.getInstance().LoadingCloud();//加载云端数据
+ DataBus.getInstance().GetTodayNoMake();
//设置连接到有线网络
// NetworkUtils.connetEnternet(app);
@@ -240,6 +242,7 @@ public class MainInit {
public void UserMsg(UserLogEnum type, String msg) {
BPA_LOG log = new BPA_LOG();
log.userID = ConfigName.getInstance().user.userID;
+ ToastUtils.info(msg);
switch (type.toString())
{
case "登录日志":log.type=1;
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 9f5af486..08986565 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
@@ -26,6 +26,7 @@ import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.mode.OrderA;
import com.bonait.bnframework.common.helper.mode.ResultA;
+import com.bonait.bnframework.modules.home.adapter.loadinggood_adapter;
import com.bonait.bnframework.modules.home.adapter.lsjy_adapter;
import com.bonait.bnframework.modules.home.adapter.wdsz_adapter;
import com.bonait.bnframework.modules.home.fragment.mode.sdkz_control;
@@ -94,6 +95,18 @@ public class DataBus {
* 商品制作列表
*/
public ArrayList GoodsMake = new ArrayList();
+
+ public loadinggood_adapter loadinggoodAdapter=null;
+ public void GetTodayNoMake()
+ {
+ GoodsMake.clear();
+ ArrayList suborders= QueryDB.GetSubOrdersTodayNoMake();
+ for (BPA_SUBORDER item:suborders)
+ {
+ AddGoodsMake(item);
+ }
+ }
+
/**
* 增加一个订单商品
* @param suborder
@@ -126,6 +139,7 @@ public class DataBus {
GoodsMake.add(make);
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + make.good.name + "]准备配料!");
+ if(loadinggoodAdapter!=null)loadinggoodAdapter.refresh();
}catch(Exception e){
MessageLog.ShowInfo( "增加订单异常!"+e.getMessage());
}
@@ -153,7 +167,10 @@ public class DataBus {
GoodsMake.get(m).makeStatus= MakeStatus.制作中;
GoodsMake.get(m).makeMs=makeMs;
- GoodsMake.get(m).makeProcess=(count/ GoodsMake.get(m).recipes.size())*100;
+ GoodsMake.get(m).makeProcess=(int)(((count*1.00)/ GoodsMake.get(m).recipes.size())*100);
+
+ if(loadinggoodAdapter!=null)loadinggoodAdapter.refresh();
+
return;
}
}
@@ -185,6 +202,9 @@ public class DataBus {
{
GoodsMake.remove(good);
}
+
+ if(loadinggoodAdapter!=null)loadinggoodAdapter.refresh();
+
}catch(Exception e){
}
}
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 d9e420ac..17661eaf 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
@@ -1212,6 +1212,29 @@ public class QueryDB {
return null;
}
}
+
+ /**
+ * 做法ID查询配方关联表
+ *
+ * @param
+ * @return
+ */
+ public static BPA_GOODSRECIPENAME GetGoodsRecipeNameDesignId(String zfid) {
+ try {
+ String orderby = Desc_Time_Up;//出料顺序
+ String where = "isDelete=? and design=?";
+ String[] args = new String[]{"0", zfid};
+ ArrayList data = new ArrayList<>();
+ ArrayList