Browse Source

增加日志输出

master
fyf 11 months ago
parent
commit
dade2d5b1c
5 changed files with 382 additions and 16 deletions
  1. +108
    -15
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  2. +5
    -0
      app/src/main/java/com/bonait/bnframework/business/MainInit.java
  3. +253
    -0
      app/src/main/java/com/bonait/bnframework/common/helper/LogcatHelper.java
  4. +9
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java
  5. +7
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java

+ 108
- 15
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java View File

@@ -24,6 +24,7 @@ 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.LogcatHelper;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.modbus.ModbusTcpMainServer;
@@ -137,9 +138,12 @@ public class ExecuteTheRecipe {
//1.解析
if (IsForcedEnd) {
ToastUtils.info("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!");
ExecuteTheRecipe.showlog("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!");
return false;
}
ToastUtils.info("开始执行:" + recipe.sort + "、" + recipe.processms);
ExecuteTheRecipe.showlog("开始执行:" + recipe.sort + "、" + recipe.processms);

if (recipe.materialType == 0)//正常物料
{
//先到达抽料位
@@ -231,6 +235,8 @@ public class ExecuteTheRecipe {
BPA_SILOS silos = entry.getKey();
Integer val = entry.getValue();
String name = "料仓" + silos.num + "下料完成";
ExecuteTheRecipe.showlog("等待"+name);

final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0] && !IsForcedEnd) {
@@ -240,11 +246,14 @@ public class ExecuteTheRecipe {
Object sb = ReadPLC(name);// ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
ExecuteTheRecipe.showlog("正常等待结束");
}
}
Thread.sleep(100);//10 *6
}
ToastUtils.info(name);
ExecuteTheRecipe.showlog(name);

}
}
} catch (Exception ex) {
@@ -351,6 +360,7 @@ public class ExecuteTheRecipe {
ExecuteCurrentOperation.Run("液体料|" + silos.num);
}
ToastUtils.info("准备写入PLC仓号需求:" + silos.num + "," + val / 10.0);
ExecuteTheRecipe.showlog("准备写入PLC仓号需求:" + silos.num + "," + val / 10.0);

String name = "料仓" + silos.num + "下料完成";
ExecuteTheRecipe.WritePLC(name, false, null);
@@ -360,12 +370,15 @@ public class ExecuteTheRecipe {
WritePLC("料仓" + silos.num + "需求值", val, new IWriteCallBack() {
@Override
public void onSuccess() {
BottomClick("料仓" + silos.num + "下料");
ExecuteTheRecipe.showlog("需求值写入成功!");
IsComplete[0] = true;
}

@Override
public void onFailure(String ErrorMsg) {
ExecuteTheRecipe.showlog("需求值写入失败!尝试再次写入...错误原因:"+ErrorMsg);
WritePLC("料仓" + silos.num + "需求值", val,null);
IsComplete[0] = true;
}
});
long a = System.currentTimeMillis();
@@ -376,6 +389,9 @@ public class ExecuteTheRecipe {
Thread.sleep(100);//10 *6
}

BottomClick("料仓" + silos.num + "下料");
ExecuteTheRecipe.showlog("料仓" + silos.num + "下料");

//減去料仓数量
int otherG = silos.silosmargin - (val / 10);
QueryDB.UpdateYL(silos.id, otherG >= 0 ? otherG : 0);
@@ -396,6 +412,7 @@ public class ExecuteTheRecipe {
private static void Write_PLC_Stir(HashMap<String, String> data) {
try {
int val = 0;
ExecuteTheRecipe.showlog( "准备写入工序-------搅拌");

for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
@@ -411,10 +428,13 @@ public class ExecuteTheRecipe {
WritePLC(key, writeValue, new IWriteCallBack() {
@Override
public void onSuccess() {
ExecuteTheRecipe.showlog( "成功写入工序-------搅拌,挡位-"+writeValue);
if (writeValue == 0) {
WritePLC("搅拌", false, null);
ExecuteTheRecipe.showlog( "成功写入工序-------搅拌,开关-false");
} else {
WritePLC("搅拌", true, null);
ExecuteTheRecipe.showlog( "成功写入工序-------搅拌,开关-true");
}
}

@@ -441,6 +461,8 @@ public class ExecuteTheRecipe {
*/
private static void Write_PLC_Location(HashMap<String, String> data) {
try {
ExecuteTheRecipe.showlog( "准备写入工序-------锅口朝向");

int val = 0;
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
@@ -465,11 +487,14 @@ public class ExecuteTheRecipe {
}
//原点位,等待机器移动倒响应位置
BottomClick1(value);
ExecuteTheRecipe.showlog( "成功写入工序-------锅口朝向-"+value+"-等待锅口移动中...");

//一直等待机器移动到该位置,否则就一直等待 6s超时
String name = value + "反馈";
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
Log.e("等待反馈", name + ",等待中");
ExecuteTheRecipe.showlog( name + ",等待中");

while (!IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
break;
@@ -477,12 +502,12 @@ public class ExecuteTheRecipe {
Object sb = ReadPLC(name);//ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
ExecuteTheRecipe.showlog( "正常等待反馈信号结束");
}
}
Thread.sleep(100);//10 *6
}
Log.e("等待反馈", name + ",等待结束");

ExecuteTheRecipe.showlog( name + ",等待结束。"+"炒锅到达" + value + ",继续制作!!!");
ToastUtils.info("炒锅到达" + value + ",继续制作!!!");
}
}
@@ -503,6 +528,8 @@ public class ExecuteTheRecipe {
*/
private static void Write_PLC_Ingredients(HashMap<String, String> data) {
try {
ExecuteTheRecipe.showlog( "准备写入工序-------主料");

//是否手动
boolean ishand = true;
ToastUtils.info("准备倒入主料!");
@@ -546,6 +573,7 @@ public class ExecuteTheRecipe {
String title = "手动投料-温馨提示!";
String message = "客官请投入主料,[" + name + "]重量" + zl + "g,投入后点击[确定]继续流程!";
//ExecuteTheRecipe.WritePLC("暂停开关", true, null);
ExecuteTheRecipe.showlog( "等待手动投入主料:"+name);

final boolean[] IsComplete = {false};
Activity activity = findActivity(context);
@@ -575,6 +603,7 @@ public class ExecuteTheRecipe {
}
//ExecuteTheRecipe.WritePLC("暂停开关", false, null);
ToastUtils.info("确定完成,继续制作!");
ExecuteTheRecipe.showlog( "手动已确认投入主料:"+name+"-继续流程");
} else {
//自动投料
if (ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本") || ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) {
@@ -593,9 +622,12 @@ public class ExecuteTheRecipe {

//1.去某一个位置
BottomClick1("平移-去" + writeValue);
ExecuteTheRecipe.showlog( "平移-去" + writeValue);


Log.d("平移", "平移-去" + writeValue);
ExecuteTheRecipe.showlog( "等待:" + "平移轴在" + writeValue);

//一直等待机器移动到该位置,否则就一直等待 6s超时
String name = "平移轴在" + writeValue;
final boolean[] IsComplete = {false};
@@ -607,14 +639,19 @@ public class ExecuteTheRecipe {
Object sb = ReadPLC(name);// ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
ExecuteTheRecipe.showlog( "正常等待反馈信号结束");
}
}
Thread.sleep(100);//10 *6
}
Log.d("平移", name + "已经就位");
ExecuteTheRecipe.showlog( name + "已经就位");

//2.给倒菜启动
BottomClick1("主料");
ExecuteTheRecipe.showlog( "到菜启动");
ExecuteTheRecipe.showlog( "等待:" + "倒菜完成");

name = "倒菜完成";
IsComplete[0] = false;
a = System.currentTimeMillis();
@@ -625,10 +662,14 @@ public class ExecuteTheRecipe {
Object sb = ReadPLC(name);// ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
ExecuteTheRecipe.showlog( "正常等待反馈信号结束");
}
}
Thread.sleep(100);//10 *6
}

ExecuteTheRecipe.showlog( "主料倒入完成,继续制作!");

ToastUtils.info("主料倒入完成,继续制作!");

}
@@ -671,7 +712,7 @@ public class ExecuteTheRecipe {
}

Log.d("烹饪时间", "烹饪时间完成了");
ExecuteTheRecipe.showlog( "烹饪时间完成了");

} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
@@ -734,6 +775,8 @@ public class ExecuteTheRecipe {
*/
private static void Write_PLC_Heating(HashMap<String, String> data) {
try {
ExecuteTheRecipe.showlog( "准备写入工序-------加热");

int val = 0;
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
@@ -747,14 +790,32 @@ public class ExecuteTheRecipe {
ExecuteCurrentOperation.Run("加热" + "|" + writeValue);
}
//写加热挡位
WritePLC(key, writeValue, null);
if (writeValue == 0) {
ConfigName.getInstance().IsOpenHuoLi = false;
WritePLC("加热", false, null);
} else {
ConfigName.getInstance().IsOpenHuoLi = true;
WritePLC("加热", true, null);
}
WritePLC(key, writeValue, new IWriteCallBack() {
@Override
public void onSuccess() {
ExecuteTheRecipe.showlog( "写加热挡位:"+writeValue+"成功");
if (writeValue == 0) {
ConfigName.getInstance().IsOpenHuoLi = false;
WritePLC("加热", false, null);
} else {
ConfigName.getInstance().IsOpenHuoLi = true;
WritePLC("加热", true, null);
}
}

@Override
public void onFailure(String ErrorMsg) {
ExecuteTheRecipe.showlog( "写加热挡位:"+writeValue+"失败,错误原因:"+ErrorMsg);
if (writeValue == 0) {
ConfigName.getInstance().IsOpenHuoLi = false;
WritePLC("加热", false, null);
} else {
ConfigName.getInstance().IsOpenHuoLi = true;
WritePLC("加热", true, null);
}
}
});

}
}

@@ -818,6 +879,8 @@ public class ExecuteTheRecipe {
*/
private static void Write_PLC_ParallelDischarge(HashMap<String, String> data) {
try {
ExecuteTheRecipe.showlog( "准备写入工序-------并行出料");

int val = 0;int cl_value=0;
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
@@ -854,10 +917,14 @@ public class ExecuteTheRecipe {

Thread.sleep(200);//等待写入完成


//一直等待下料完成 否则就一直等待 40s超时
for (Map.Entry<BPA_SILOS, Integer> entry : formulation.entrySet()) {
BPA_SILOS silos = entry.getKey();

String name = "料仓" + silos.num + "下料完成";
ExecuteTheRecipe.showlog( "等待:"+name);

final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0] && !IsForcedEnd) {
@@ -867,10 +934,12 @@ public class ExecuteTheRecipe {
Object sb = ReadPLC(name);// ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
ExecuteTheRecipe.showlog( "正常等待反馈信号结束");
}
}
Thread.sleep(100);//10 *6
}
ExecuteTheRecipe.showlog( name);
ToastUtils.info(name);
}

@@ -914,6 +983,7 @@ public class ExecuteTheRecipe {
private static void Write_PLC_Outdishes(HashMap<String, String> data) {
try {
ToastUtils.info("准备出菜!");
ExecuteTheRecipe.showlog("准备出菜!");

//先延迟
for (HashMap.Entry<String, String> entry : data.entrySet()) {
@@ -935,6 +1005,8 @@ public class ExecuteTheRecipe {

//一直等待机器移动到该位置,否则就一直等待 6s超时
String name = "出餐启动反馈";
ExecuteTheRecipe.showlog("等待:出餐启动反馈");

final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0] && !IsForcedEnd) {
@@ -944,12 +1016,13 @@ public class ExecuteTheRecipe {
Object sb = ReadPLC(name);//ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
ExecuteTheRecipe.showlog( "正常等待反馈信号结束");
}
}
Thread.sleep(100);//10 *6
}

ToastUtils.info("出菜完成,锅体准备回到原位!");
ExecuteTheRecipe.showlog("出菜完成,锅体准备回到原位!");
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
@@ -963,6 +1036,7 @@ public class ExecuteTheRecipe {
private static void Write_PLC_CleanPan(HashMap<String, String> data) {
try {
ToastUtils.info("准备清洗!");
ExecuteTheRecipe.showlog("准备清洗!");
//先延迟
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
@@ -982,6 +1056,7 @@ public class ExecuteTheRecipe {
ExecuteTheRecipe.WritePLC(name,false,null);

BottomClick1("炒锅清洗");
ExecuteTheRecipe.showlog("等待:炒锅清洗反馈!");

final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
@@ -992,11 +1067,13 @@ public class ExecuteTheRecipe {
Object sb = ReadPLC(name);//ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
ExecuteTheRecipe.showlog( "正常等待反馈信号结束");

}
}
Thread.sleep(100);//10 *6
}
ExecuteTheRecipe.showlog("炒锅清洗完成!");
ToastUtils.info("炒锅清洗完成!");
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
@@ -2066,6 +2143,8 @@ public class ExecuteTheRecipe {
* @param delay
*/
public static void ThreadDelay(int delay) {
ExecuteTheRecipe.showlog( "工序线程等待-------时长:"+delay+"秒,请耐心等待,开始计时!");

long startTime = System.currentTimeMillis();
while ((System.currentTimeMillis() - startTime) <= (delay * 1000) && !IsForcedEnd) //
{
@@ -2074,6 +2153,20 @@ public class ExecuteTheRecipe {
} catch (InterruptedException ex) {
}
}

long endTime = System.currentTimeMillis(); //结束时间
int time = (int) ((endTime - startTime) / 1000);
ExecuteTheRecipe.showlog( "工序线程等待结束-------总耗时:"+time);
}
//endregion

//region 显示日志
/**
* 显示日志
*/
public static void showlog(String msg)
{
Log.e("hbl", msg);
}
//endregion
}

+ 5
- 0
app/src/main/java/com/bonait/bnframework/business/MainInit.java View File

@@ -23,6 +23,7 @@ import com.bonait.bnframework.common.db.res.AlertLogEnum;
import com.bonait.bnframework.common.db.res.UserLogEnum;
import com.bonait.bnframework.common.helper.CrashHandler;
import com.bonait.bnframework.common.helper.I.IMessageLogNotify;
import com.bonait.bnframework.common.helper.LogcatHelper;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.SdCart;
import com.bonait.bnframework.common.modbus.ModbusTcpHelper;
@@ -108,6 +109,10 @@ public class MainInit {
//text();

//cx_cp();

//日志
LogcatHelper.getInstance(app).start();
ExecuteTheRecipe.showlog("程序启动中...");
}




+ 253
- 0
app/src/main/java/com/bonait/bnframework/common/helper/LogcatHelper.java View File

@@ -0,0 +1,253 @@
package com.bonait.bnframework.common.helper;

import android.content.Context;
import android.os.Environment;
import android.os.StatFs;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
* log日志统计保存
* 日志最多保存3天,如果内存不足,逐个删除近3+i 天日志
*
* @author songjing
*/

public class LogcatHelper {
private static LogcatHelper instance = null;
private int order = 0;
private int mPId;
private String pathLogcat;
private LogThread mLogThread = null;
private String mylogfilename = ".log";// 本类输出的日志文件名称
private int SDCARD_LOG_FILE_SAVE_DAYS = 3;// sd卡中日志文件的最多保存天数
private static SimpleDateFormat myLogSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 日志的输出格式
private static SimpleDateFormat logfile = new SimpleDateFormat("yyyyMMdd HH:mm:ss");// 日志文件格式

/**
* 初始化目录
*/
public void init(Context context) {
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
// 优先保存到SD卡中
pathLogcat = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "HBL_Log";
} else {
// 如果SD卡不存在,就保存到本应用的目录下
pathLogcat = context.getFilesDir().getAbsolutePath() + File.separator + "HBL_Log";
}
File file = new File(pathLogcat);
if (!file.exists()) {
file.mkdirs();
} else {
if (availableSpace()) {
delFile(order);
} else {
deleteDirectory(pathLogcat);
}
}
}

/**
* 内存可用空间大小
*
* @return
*/
private boolean availableSpace() {
File root = Environment.getRootDirectory();
StatFs sf = new StatFs(root.getPath());
long blockSize = sf.getBlockSize();
long blockCount = sf.getBlockCount();
long availCount = sf.getAvailableBlocks();
//总大小
long totalBlocks = blockSize * blockCount / 1024;
//可用大小
long availableBlocks = availCount * blockSize / 1024;
if (availableBlocks < totalBlocks) {
return true;
} else {
return false;
}
}

public static LogcatHelper getInstance(Context context) {
if (instance == null) {
instance = new LogcatHelper(context);
}
return instance;
}

private LogcatHelper(Context context) {
init(context);
mPId = android.os.Process.myPid();
}

public void start() {
if (mLogThread == null)
mLogThread = new LogThread(String.valueOf(mPId), pathLogcat);
mLogThread.start();
}

public void stop() {
if (mLogThread != null) {
mLogThread.stopLogs();
mLogThread = null;
}
}

private class LogThread extends Thread {
private Process logcatProc;
private BufferedReader mReader = null;
private boolean mRunning = true;
String cmds = null;
private String mPID;
private FileOutputStream out = null;

public LogThread(String pid, String dir) {
mPID = pid;
try {
out = new FileOutputStream(new File(dir, MyDate.getFileName() + mylogfilename));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
// cmds = "logcat | grep \"(" + mPID + ")\"";//打印所有日志信息
cmds = "logcat -s hbl";//打印标签过滤信息
//cmds = "logcat *:e *:i | grep \"(" + mPID + ")\"";

}

public void stopLogs() {
mRunning = false;
this.interrupt();
}

@Override
public void run() {
try {
logcatProc = Runtime.getRuntime().exec(cmds);
mReader = new BufferedReader(new InputStreamReader(logcatProc.getInputStream()), 1024);
String line = null;
while (mRunning && (line = mReader.readLine()) != null) {
if (!availableSpace()) {
delFile(order);
}
if (!mRunning) {
break;
}
if (line.length() == 0) {
continue;
}
if (out != null && line.contains(mPID)) {
out.write((MyDate.getDateEN() + " " + line + "\n").getBytes());
}
}

} catch (IOException e) {
e.printStackTrace();
} finally {
if (logcatProc != null) {
logcatProc.destroy();
logcatProc = null;
}
if (mReader != null) {
try {
mReader.close();
mReader = null;
} catch (IOException e) {
e.printStackTrace();
}
}
if (out != null) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
out = null;
}
}
}
}

public static class MyDate {
public static String getFileName() {
String date = logfile.format(new Date(System.currentTimeMillis()));
return date;
}

public static String getDateEN() {
String date1 = myLogSdf.format(new Date(System.currentTimeMillis()));
return date1;
}
}

public void delFile(int order) {
try {
String needDelFiel = logfile.format(getDateBefore(order));
needDelFiel = needDelFiel.substring(0, 8);
int needDelTime = Integer.parseInt(needDelFiel);

File dirFile = new File(pathLogcat);
if (dirFile.exists() || dirFile.isDirectory()) {
File[] files = dirFile.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isFile()) {
String fileName = files[i] + "";
fileName = fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length());
fileName = fileName.substring(0, 8);
int filetime = Integer.parseInt(fileName);
if (filetime <= needDelTime) {
files[i].delete();
}
}
}
}
} catch (Exception e) {
e.printStackTrace();

}
}

/**
* 得到现在时间前的几天日期,用来得到需要删除的日志文件名
*/
private Date getDateBefore(int order) {
Date nowtime = new Date();
Calendar now = Calendar.getInstance();
now.setTime(nowtime);
now.set(Calendar.DATE, now.get(Calendar.DATE) - SDCARD_LOG_FILE_SAVE_DAYS + order);
order++;
if (order == SDCARD_LOG_FILE_SAVE_DAYS) {
order = 0;
}
return now.getTime();
}

public void deleteDirectory(String filePath) {
//如果filePath不以文件分隔符结尾,自动添加文件分隔符
if (!filePath.endsWith(File.separator)) {
filePath = filePath + File.separator;
}
File dirFile = new File(filePath);
if (dirFile.exists() || dirFile.isDirectory()) {
File[] files = dirFile.listFiles();
//遍历删除文件夹下的所有文件(包括子目录)
for (int i = 0; i < files.length; i++) {
if (files[i].isFile()) {
//删除子文件
files[i].delete();
}
}
}
//删除当前空目录
dirFile.delete();
}
}


+ 9
- 0
app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java View File

@@ -364,6 +364,10 @@ public class BottomNavigationNewActivity extends BaseActivity {
try {
if (ExecuteTheRecipe.IsStart && goods != null) {
long startTime = System.currentTimeMillis(); //起始时间
ExecuteTheRecipe.showlog("--------------------------------------");

ExecuteTheRecipe.showlog("开始烹饪菜谱【"+goods.name+"】");

try {
//获取工艺
ArrayList<BPA_GOODSRECIPE> goodsrecipes = QueryDB.GetGoodsSrecipeID(goods.id);
@@ -401,6 +405,7 @@ public class BottomNavigationNewActivity extends BaseActivity {
long endTime = System.currentTimeMillis(); //结束时间
int time = (int) ((endTime - startTime) / 1000);
Log.e("运行时长", String.format("方法使用时间 %d s", time));
ExecuteTheRecipe.showlog("结束烹饪菜谱【"+goods.name+"】,关闭搅拌、关闭加热,"+String.format("方法使用时间 %d s", time));

if (!ExecuteTheRecipe.IsForcedEnd) {
QueryDB.UpdateGoodsMakeTime(goods.id, time);
@@ -416,6 +421,8 @@ public class BottomNavigationNewActivity extends BaseActivity {
ToastUtils.info("客官,当前菜品已强制结束!!!");
//初始化
ExecuteTheRecipe.BottomClick("初始化");
ExecuteTheRecipe.showlog("菜谱【"+goods.name+"】已强制结束...");

if (ConfigName.getInstance().versionSelectionEnum.contains("一拖"))//通知任务结束
{
ExecuteTheRecipe.WriteMainPLC("强制结束任务完成", true, null);//复位
@@ -424,6 +431,8 @@ public class BottomNavigationNewActivity extends BaseActivity {
}
}
});
ExecuteTheRecipe.showlog("--------------------------------------");

}
}
Thread.sleep(1000);


+ 7
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java View File

@@ -572,6 +572,9 @@ public class Home1Fragment extends BaseFragment {

if ( ExecuteTheRecipe.MakeStatus && good != null) {
long startTime = System.currentTimeMillis(); //起始时间
ExecuteTheRecipe.showlog("--------------------------------------");
ExecuteTheRecipe.showlog("开始烹饪菜谱【"+good.name+"】");

try {
//获取工艺
ArrayList<BPA_GOODSRECIPE> goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id);
@@ -589,7 +592,6 @@ public class Home1Fragment extends BaseFragment {
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
} finally {

ExecuteTheRecipe.WritePLC("搅拌", false, null);
ExecuteTheRecipe.WritePLC("加热", false, null);
ConfigName.getInstance().IsOpenHuoLi = false;
@@ -601,6 +603,7 @@ public class Home1Fragment extends BaseFragment {
long endTime = System.currentTimeMillis(); //结束时间
int time = (int) ((endTime - startTime) / 1000);
Log.e("运行时长", String.format("方法使用时间 %d s", time));
ExecuteTheRecipe.showlog("结束烹饪菜谱【"+good.name+"】,关闭搅拌、关闭加热,"+String.format("方法使用时间 %d s", time));

if (!ExecuteTheRecipe.IsForcedEnd) {
QueryDB.UpdateGoodsMakeTime(good.id, time);
@@ -619,6 +622,7 @@ public class Home1Fragment extends BaseFragment {
ToastUtils.info("客官,当前菜品已强制结束!!!");
//初始化
ExecuteTheRecipe.BottomClick("初始化");
ExecuteTheRecipe.showlog("菜谱【"+good.name+"】已强制结束...");
if (ConfigName.getInstance().versionSelectionEnum.contains("一拖"))//通知任务结束
{
ExecuteTheRecipe.WriteMainPLC("强制结束任务完成", true, null);//复位
@@ -628,6 +632,8 @@ public class Home1Fragment extends BaseFragment {
}
});
}
ExecuteTheRecipe.showlog("--------------------------------------");

}
}
Thread.sleep(1000);


Loading…
Cancel
Save