Browse Source

判断重复点击

桌面小炒机
liup 5 months ago
parent
commit
74279341a9
40 changed files with 938 additions and 65 deletions
  1. +2
    -2
      .idea/deploymentTargetSelector.xml
  2. +16
    -7
      app/src/main/java/com/bonait/bnframework/CrashHandler.java
  3. +48
    -0
      app/src/main/java/com/bonait/bnframework/HBL/API/APIResultT.java
  4. +5
    -1
      app/src/main/java/com/bonait/bnframework/HBL/Communication/Modbus/ModbusMaster.java
  5. +0
    -2
      app/src/main/java/com/bonait/bnframework/Service/ModbusHelper.java
  6. +23
    -23
      app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigationNewActivity.java
  7. +40
    -0
      app/src/main/java/com/bonait/bnframework/api/Api.java
  8. +118
    -0
      app/src/main/java/com/bonait/bnframework/api/CmsResponse.java
  9. +104
    -0
      app/src/main/java/com/bonait/bnframework/api/CommonResponse.java
  10. +43
    -0
      app/src/main/java/com/bonait/bnframework/api/Constant.java
  11. +11
    -0
      app/src/main/java/com/bonait/bnframework/api/IApi.kt
  12. +29
    -0
      app/src/main/java/com/bonait/bnframework/api/IHttpCallBack.java
  13. +47
    -0
      app/src/main/java/com/bonait/bnframework/api/ServerManager.java
  14. +1
    -1
      app/src/main/java/com/bonait/bnframework/business/MainInit.java
  15. +66
    -3
      app/src/main/java/com/bonait/bnframework/business/RecordManager.java
  16. +3
    -0
      app/src/main/java/com/bonait/bnframework/common/image/utils/LocalCacheUtils.java
  17. +14
    -3
      app/src/main/java/com/bonait/bnframework/ui/activity/CookingActivity.java
  18. +62
    -0
      app/src/main/java/com/bonait/bnframework/ui/activity/DiyProcessActivity.java
  19. +33
    -0
      app/src/main/java/com/bonait/bnframework/ui/activity/EditClassifyActivity.java
  20. +10
    -0
      app/src/main/java/com/bonait/bnframework/ui/activity/EditGoodsActivity.java
  21. +6
    -0
      app/src/main/java/com/bonait/bnframework/ui/activity/ErrorInfoActivity.java
  22. +14
    -0
      app/src/main/java/com/bonait/bnframework/ui/activity/LogRecordActivity.java
  23. +74
    -4
      app/src/main/java/com/bonait/bnframework/ui/activity/MainActivity.java
  24. +10
    -1
      app/src/main/java/com/bonait/bnframework/ui/activity/RecProcessActivity.java
  25. +6
    -0
      app/src/main/java/com/bonait/bnframework/ui/adapter/OrderAdapter.java
  26. +6
    -0
      app/src/main/java/com/bonait/bnframework/ui/adapter/SubOrderAdapter.java
  27. +6
    -0
      app/src/main/java/com/bonait/bnframework/ui/adapter/classify/AttributeAdapter.java
  28. +6
    -0
      app/src/main/java/com/bonait/bnframework/ui/adapter/classify/ClassifyAdapter.java
  29. +6
    -0
      app/src/main/java/com/bonait/bnframework/ui/adapter/classify/SelectSubAttributeAdapter.java
  30. +10
    -0
      app/src/main/java/com/bonait/bnframework/ui/adapter/classify/SubattributeAdapter.java
  31. +10
    -0
      app/src/main/java/com/bonait/bnframework/ui/adapter/goods/CloudGoodsAdapter.java
  32. +20
    -1
      app/src/main/java/com/bonait/bnframework/ui/adapter/goods/LocalGoodsAdapter.java
  33. +6
    -0
      app/src/main/java/com/bonait/bnframework/ui/adapter/silos/MaterialAdapter.java
  34. +6
    -0
      app/src/main/java/com/bonait/bnframework/ui/adapter/silos/SilosAdapter.java
  35. +29
    -15
      app/src/main/java/com/bonait/bnframework/ui/fragment/HomeDevicesFragment.java
  36. +9
    -0
      app/src/main/java/com/bonait/bnframework/ui/fragment/HomeFoodsFragment.java
  37. +21
    -0
      app/src/main/java/com/bonait/bnframework/ui/fragment/HomeMainFragment.java
  38. +4
    -0
      app/src/main/java/com/bonait/bnframework/ui/fragment/goods/CloudGoodsFragment.java
  39. +12
    -0
      app/src/main/java/com/bonait/bnframework/ui/fragment/goods/LocalGoodsFragment.java
  40. +2
    -2
      build.gradle

+ 2
- 2
.idea/deploymentTargetSelector.xml View File

@@ -4,10 +4,10 @@
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-06-11T02:32:44.238613300Z">
<DropdownSelection timestamp="2024-06-12T06:34:07.909871700Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="Default" identifier="serial=10.24.61.102:5555;connection=0070276e" />
<DeviceId pluginId="Default" identifier="serial=127.0.0.1:7555;connection=9b650491" />
</handle>
</Target>
</DropdownSelection>


app/src/main/java/com/bonait/bnframework/common/helper/CrashHandler.java → app/src/main/java/com/bonait/bnframework/CrashHandler.java View File

@@ -1,7 +1,8 @@
package com.bonait.bnframework.common.helper;
package com.bonait.bnframework;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -14,7 +15,12 @@ import android.widget.Toast;

import com.apkfuns.logutils.LogUtils;
import com.bonait.bnframework.HBL.Thread.ThreadManager;
import com.bonait.bnframework.Service.ModbusHelper;
import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.business.NewExecuteTheRecipe;
import com.bonait.bnframework.business.RecordManager;
import com.bonait.bnframework.common.helper.DateUtil;
import com.bonait.bnframework.common.helper.FileUtil;

import java.io.File;
import java.io.FileOutputStream;
@@ -90,6 +96,10 @@ public class CrashHandler implements UncaughtExceptionHandler {
private boolean handleException(Throwable ex) {
ThreadManager.get().Stop("Modbus变量状态");
ThreadManager.get().Stop("日志信息保存");
ThreadManager.get().Stop("PLC断线重连线程");
NewExecuteTheRecipe.IsStart = false;
ModbusHelper.get().setCookStatus(false);
ConfigData.getInstance().ColsePLC();
// if(!ConfigName.ERROR_ROOT) return false;
if (ex == null)
return false;
@@ -109,15 +119,14 @@ public class CrashHandler implements UncaughtExceptionHandler {
collectDeviceInfo(mContext);
saveCrashInfoFile(ex);

// Intent intent = mContext.getPackageManager().getLaunchIntentForPackage(mContext.getPackageName());
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// mContext.startActivity(intent);
// SystemClock.sleep(3000);
Intent intent = mContext.getPackageManager().getLaunchIntentForPackage(mContext.getPackageName());
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mContext.startActivity(intent);
SystemClock.sleep(3000);
} catch (Exception e) {
e.printStackTrace();
}
return false;
// return true;
return true;
}

/**

+ 48
- 0
app/src/main/java/com/bonait/bnframework/HBL/API/APIResultT.java View File

@@ -18,4 +18,52 @@ public class APIResultT<T> {
public String toString(){
return new GsonBuilder().serializeNulls().create().toJson(this);//保留为空的属性
}

public int getStatusCode() {
return statusCode;
}

public void setStatusCode(int statusCode) {
this.statusCode = statusCode;
}

public T getData() {
return data;
}

public void setData(T data) {
this.data = data;
}

public String getSucceeded() {
return succeeded;
}

public void setSucceeded(String succeeded) {
this.succeeded = succeeded;
}

public String getErrors() {
return errors;
}

public void setErrors(String errors) {
this.errors = errors;
}

public String getExtras() {
return extras;
}

public void setExtras(String extras) {
this.extras = extras;
}

public int getTimestamp() {
return timestamp;
}

public void setTimestamp(int timestamp) {
this.timestamp = timestamp;
}
}

+ 5
- 1
app/src/main/java/com/bonait/bnframework/HBL/Communication/Modbus/ModbusMaster.java View File

@@ -107,7 +107,7 @@ public class ModbusMaster implements IRead,IWrite ,IModbusMaster{
.setStopBits(1) // 停止位
.setTimeout(500).setRetries(0); // 不重试
AtomicReference<String> errorInfo=new AtomicReference<>("");
while (!IsConnected)
while (!IsConnected&&IsReconnection)
{
mw.init(param, new ModbusCallback<com.serotonin.modbus4j.ModbusMaster>() {
@Override
@@ -141,6 +141,10 @@ public class ModbusMaster implements IRead,IWrite ,IModbusMaster{
return IsConnected;
}

public void setConnected(boolean connected) {
IsConnected = connected;
}

public <T> OperateResultT<T> Read(String address, int length){
// if(!getConnected()){ return OperateResultT.CreateFailedT("设备未连接");}
AtomicReference<OperateResultT<T>>resultValue=new AtomicReference<OperateResultT<T>>();


+ 0
- 2
app/src/main/java/com/bonait/bnframework/Service/ModbusHelper.java View File

@@ -572,8 +572,6 @@ public class ModbusHelper extends ModbusMaster {
*/
private void GetLooperStatus(){
ThreadManager.get().StartLong("Modbus变量状态",true,()->{


WriteShort(getPLC(ControlAdress.心跳).PlcAddress, (short) 0);

PLCModel<Boolean> statusModel1 = controlAddress.get(ControlAdress.掉线标志);


+ 23
- 23
app/src/main/java/com/bonait/bnframework/ViewModel/ActivityViewModel/BottomNavigationNewActivity.java View File

@@ -267,29 +267,29 @@ public class BottomNavigationNewActivity extends BaseActivity {
// ThreadManager.get().StartLong("PLC断线重连线程", true, new IThread() {
// @Override
// public void Run() throws InterruptedException {
//// try {
//// if (ConfigName.getInstance().PlcIsConnect) {
//// //ping 不通
//// boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1);
//// if (!status) //ping 不通 连接
//// {
//// MessageLog.ShowInfo("PLC状态断开,尝试连接...");
//// ConfigName.getInstance().PlcIsConnect = false;
//// }
//// } else {
//// boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1);
//// if (status) {
//// MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " PLC通讯正常,准备连接!");
//// ModbusTcpServer.ConnectPLC();
//// } else {
//// MessageLog.ShowInfo("PLC状态断开,尝试连接...");
//// ConfigName.getInstance().PlcIsConnect = false;
//// }
//// }
//// Thread.sleep(10000);
//// } catch (Exception e) {
//// Log.i("PLC", "PLC重连接失败!" + e.getMessage());
//// }
// try {
// if (ConfigName.getInstance().PlcIsConnect) {
// //ping 不通
// boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1);
// if (!status) //ping 不通 连接
// {
// MessageLog.ShowInfo("PLC状态断开,尝试连接...");
// ConfigName.getInstance().PlcIsConnect = false;
// }
// } else {
// boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1);
// if (status) {
// MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " PLC通讯正常,准备连接!");
// ModbusTcpServer.ConnectPLC();
// } else {
// MessageLog.ShowInfo("PLC状态断开,尝试连接...");
// ConfigName.getInstance().PlcIsConnect = false;
// }
// }
// Thread.sleep(10000);
// } catch (Exception e) {
// Log.i("PLC", "PLC重连接失败!" + e.getMessage());
// }
// }
//
//


+ 40
- 0
app/src/main/java/com/bonait/bnframework/api/Api.java View File

@@ -0,0 +1,40 @@
package com.bonait.bnframework.api;


import com.bonait.bnframework.HBL.API.APIResultT;

import okhttp3.MultipartBody;
import retrofit2.Call;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Query;
import retrofit2.http.Url;

/**
* 接口服务
*/
public interface Api {

/**
* 上报日志文件
*
* @param url
* @param account 账号
* @param device 设备
* @param faultCode 故障代码
* @param sceneCode 场景code
* @param serialNo 序列号
* @param file 文件
* @return
*/
@Multipart
@POST
Call<APIResultT<String>> upLoadLogFile(@Url String url,
@Query("account") String account,
@Query("device") String device,
@Query("faultCode") String faultCode,
@Query("sceneCode") String sceneCode,
@Query("serialNo") String serialNo,
@Part MultipartBody.Part file);
}

+ 118
- 0
app/src/main/java/com/bonait/bnframework/api/CmsResponse.java View File

@@ -0,0 +1,118 @@
package com.bonait.bnframework.api;


import com.bonait.bnframework.HBL.API.APIResultT;

import java.net.SocketTimeoutException;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
* @author Nov
* @date 19.11.25
*/
public class CmsResponse implements Callback<APIResultT> {

/**
* 回调
*/
private IHttpCallBack callback;


public CmsResponse(IHttpCallBack callback) {
this.callback = callback;
}


@Override
public void onResponse(Call<APIResultT> call, Response<APIResultT> response) {
APIResultT data = response.body();
if (null == response) {
callError("response=null", Constant.APP_DATA_ERROR, "response =null");
return;
}
if (null == data) {
callError("body=null", Constant.APP_DATA_ERROR, response.message());
return;
}
if (data.getStatusCode() != Constant.CMS_STATUS_OK&&data.getStatusCode() != Constant.DP_STATUS_OK) {
callError("code!=200", data.getStatusCode(), data.getErrors());
return;
}
Object t = data.getData();
// if (null == t) {
// LogUtil.d("CmsResponse---> onResponse : 4");
// callError("data=null", Constant.APP_DATA_NULL, data.getMessage());
// return;
// }

callSuccess(t);
}

@Override
public void onFailure(Call<APIResultT> call, Throwable t) {
//LogUtils.d("接口出错....."+t.getMessage() + " "+call.request().url());
callFail(Constant.APP_NET_ERROR, t);

}

/**
* 回调失败
*
* @param code
* @param e
*/
private void callFail(final int code, final Throwable e) {
if (null == callback) {
return;
}
if (e instanceof SocketTimeoutException) {
callback.onFailed(code, e, "请求超时");
} else {
callback.onFailed(code, e, "接口请求错误");
}

e.printStackTrace();
reportErrorInfo(code + "", e.getMessage());

}

/**
* 回调错误
*
* @param code
*/
private void callError(String type, final int code, String msg) {
if (null == callback) {
return;
}
//LogUtils.d("请求数据处理错误.....");
callback.onError(code);
reportErrorInfo(code + "", msg);
}

/**
* 回调成功
*
* @param t
*/
private void callSuccess(final Object t) {
if (null == callback) {
return;
}
callback.onSuccess(t);
}

/**
* 上报错误信息
*
* @param code
* @param description
*/
private void reportErrorInfo(String code, String description) {

}

}

+ 104
- 0
app/src/main/java/com/bonait/bnframework/api/CommonResponse.java View File

@@ -0,0 +1,104 @@
package com.bonait.bnframework.api;

import java.net.SocketTimeoutException;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
* @author Nov
* @date 19.11.25
*/
public class CommonResponse<T> implements Callback<T> {

/**
* 回调
*/
private IHttpCallBack callback;


public CommonResponse(IHttpCallBack callback) {
this.callback = callback;
}


@Override
public void onResponse(Call<T> call, Response<T> response) {
T data = response.body();
if (null == response) {
callError("response=null", Constant.APP_DATA_ERROR, "response =null");
return;
}
if (null == data) {
callError("data=null", Constant.APP_DATA_ERROR, response.message());
return;
}
callSuccess(data);
}

@Override
public void onFailure(Call<T> call, Throwable t) {
//LogUtils.d("接口出错....."+t.getMessage() + " "+call.request().url());
callFail(Constant.APP_NET_ERROR, t);

}

/**
* 回调失败
*
* @param code
* @param e
*/
private void callFail(final int code, final Throwable e) {
if (null == callback) {
return;
}
if (e instanceof SocketTimeoutException) {
callback.onFailed(code, e, "请求超时");
} else {
callback.onFailed(code, e, "接口请求错误");
}

e.printStackTrace();
reportErrorInfo(code + "", e.getMessage());

}

/**
* 回调错误
*
* @param code
*/
private void callError(String type, final int code, String msg) {
if (null == callback) {
return;
}
//LogUtils.d("请求数据处理错误.....");
callback.onError(code);
reportErrorInfo(code + "", msg);
}

/**
* 回调成功
*
* @param t
*/
private void callSuccess(final Object t) {
if (null == callback) {
return;
}
callback.onSuccess(t);
}

/**
* 上报错误信息
*
* @param code
* @param description
*/
private void reportErrorInfo(String code, String description) {

}

}

+ 43
- 0
app/src/main/java/com/bonait/bnframework/api/Constant.java View File

@@ -0,0 +1,43 @@
package com.bonait.bnframework.api;

/**
* @author Nov
* @date 19.11.25
* 常量类
*/
public class Constant {

/**
* 服务器请求失败
*/
public static final int APP_NET_ERROR = 99999;

/**
* 服务器请求成功,但是数据返回为空
*/
public static final int APP_DATA_NULL = 99998;

/**
* 服务器请求成功,但是数据返回错误
*/
public static final int APP_DATA_ERROR = 99997;

/**
* 服务器请求成功,但是HTTP响应状态码异常
*/
public static final int APP_HTTP_STATUS_CODE_EXCEPTION = 99996;

/*******************桌面平台******************/
public static final int DP_STATUS_OK = 1;

/*******************cms******************/
/**
* 操作成功
*/
public static final int CMS_STATUS_OK = 200;


public static final String testVodUrls = "https://vt1.doubanio.com/202105061054/c77450cc7c02175c1485231c0140bffd/view/movie/M/402700799.mp4";


}

+ 11
- 0
app/src/main/java/com/bonait/bnframework/api/IApi.kt View File

@@ -0,0 +1,11 @@
package com.amt.module_common.api

interface IApi {
companion object {
/**
* 获取直播分组、直播列表
*/
const val CHANNEL_PATH = "/liveChannel/getNewLiveChannelList"

}
}

+ 29
- 0
app/src/main/java/com/bonait/bnframework/api/IHttpCallBack.java View File

@@ -0,0 +1,29 @@
package com.bonait.bnframework.api;

/**
* @author Nov
* @date 19.11.25
*/
public interface IHttpCallBack<T> {
/**
* 请求成功
*
* @param t 成功返回参数
*/
public void onSuccess(T t);

/**
* 请求成功,但是返回数据处理中发现异常
*
* @param failCode 失败原因Code 非法请求:ServerUtil.CODE_FAIL_ILLEGAL;其它失败:ServerUtil.CODE_FAIL; 等
*/
public void onError(int failCode);

/**
* Http请求失败
*
* @param throwable 异常,可能为空
* @param message 其它错误信息
*/
public void onFailed(int failCode, Throwable throwable, String message);
}

+ 47
- 0
app/src/main/java/com/bonait/bnframework/api/ServerManager.java View File

@@ -0,0 +1,47 @@
package com.bonait.bnframework.api;

import retrofit2.Call;

public class ServerManager {
// /**
// * 热搜
// *
// * @param callback
// */
// public static void hotSearchKey(IHttpCallBack<ArrayList<SearchHotBean>> callback) {
// String url = Config.getCMSDomain() + "/epg_api/epgHotSearch/getSearchWord";
// Call call = HttpUtil.getService(Api.class).getSearchWord(url);
// cmsEnqueue(call, callback);
// }
//
// /**
// * 获取消息数据
// *
// * @param device 设备
// * @param faultCode 故障代码
// * @param sceneCode 场景code
// * @param file 文件
// * @param callback
// */
// public static void upLoadLogFile(String device, String faultCode, String sceneCode, MultipartBody.Part file, IHttpCallBack<BaseResp<String>> callback) {
// String url = Config.getUploadFileDomain() + "/logfile/upload";
// String itvName = LocalDataManager.INSTANCE.userId();
// String serialNo = LocalDataManager.INSTANCE.sn();
// Call<BaseResp<String>> call = HttpUtil.getService(Api.class).upLoadLogFile(url, itvName, device, faultCode, sceneCode, serialNo, file);
// CommonResponse<BaseResp<String>> response = new CommonResponse<>(callback);
// call.enqueue(response);
// }

/**
* >>>>>>> .merge_file_a00276
* cms同步请求
*
* @param call
* @param callBack
*/
private static void cmsEnqueue(Call call, IHttpCallBack callBack) {
CmsResponse hrh = new CmsResponse(callBack);
call.enqueue(hrh);
}

}

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

@@ -27,7 +27,7 @@ import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_SILOS_CALIBRATE;
import com.bonait.bnframework.common.db.mode.BPA_SUBORDER_RECORD;
import com.bonait.bnframework.common.db.mode.BPA_USER;
import com.bonait.bnframework.common.helper.CrashHandler;
import com.bonait.bnframework.CrashHandler;
import com.bonait.bnframework.common.helper.SdCart;
import com.bonait.bnframework.common.notification.MainNotification;
import com.bonait.bnframework.common.utils.AppUtils;


+ 66
- 3
app/src/main/java/com/bonait/bnframework/business/RecordManager.java View File

@@ -8,10 +8,15 @@ import com.bonait.bnframework.common.db.mode.BPA_LOG_RECORD;
import com.bonait.bnframework.common.db.mode.BPA_ORDER_RECORD;
import com.bonait.bnframework.common.db.mode.BPA_SUBORDER_RECORD;
import com.bonait.bnframework.common.db.util.GoodsDBUtil;
import com.bonait.bnframework.common.db.util.OrderRecordUtil;
import com.bonait.bnframework.common.db.util.LogRecordUtil;
import com.bonait.bnframework.common.db.util.OrderRecordUtil;
import com.bonait.bnframework.common.db.util.SubOrderRecordUtil;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
* @author: liup
* @description: 记录管理 日志记录 订单记录
@@ -80,6 +85,7 @@ public class RecordManager {
try{
BPA_ORDER_RECORD bean = OrderRecordUtil.getByGoodsId(group.goodsId);
bean.Count = bean.Count+1;

BPA_GOODS goods = GoodsDBUtil.getById(group.goodsId);
if(goods==null){
return;
@@ -98,7 +104,15 @@ public class RecordManager {
bean.errorCount = bean.errorCount+1;
break;
}
OrderRecordUtil.add(bean);
if(bean.Count == 1){
OrderRecordUtil.add(bean);
}else {
if(compareTime(bean.createTime)){
OrderRecordUtil.update(bean);
}else {
OrderRecordUtil.add(bean);
}
}
}catch (Exception e){
e.printStackTrace();
}
@@ -138,10 +152,59 @@ public class RecordManager {
bean.subErrorCount = bean.subErrorCount+1;
break;
}
SubOrderRecordUtil.add(bean);
if(bean.subCount == 1){
SubOrderRecordUtil.add(bean);
}else {
if(compareTime(bean.createTime)){
SubOrderRecordUtil.update(bean);
}else {
SubOrderRecordUtil.add(bean);
}
}
}catch (Exception e){
e.printStackTrace();
}
}));
}


private boolean compareTime(String createTime) {
try {
// 使用 SimpleDateFormat 解析字符串为 Date 对象
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = sdf.parse(createTime);

// 获取今天的日期(只包含日期部分,时间为 00:00:00)
Calendar today = Calendar.getInstance();
today.set(Calendar.HOUR_OF_DAY, 0);
today.set(Calendar.MINUTE, 0);
today.set(Calendar.SECOND, 0);
today.set(Calendar.MILLISECOND, 0);

// 比较两个日期(只比较日期部分)
if (isSameDay(date, today.getTime())) {
return true;
} else {
return false;
}

} catch (ParseException e) {
e.printStackTrace();
return false;
}
}

// 辅助方法:检查两个日期对象是否是同一天(只比较日期部分)
private static boolean isSameDay(Date date1, Date date2) {
Calendar cal1 = Calendar.getInstance();
cal1.setTime(date1);

Calendar cal2 = Calendar.getInstance();
cal2.setTime(date2);

// 比较年份、月份和日期
return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
&& cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH)
&& cal1.get(Calendar.DAY_OF_MONTH) == cal2.get(Calendar.DAY_OF_MONTH);
}
}

+ 3
- 0
app/src/main/java/com/bonait/bnframework/common/image/utils/LocalCacheUtils.java View File

@@ -41,6 +41,9 @@ public class LocalCacheUtils {
* @return
*/
public boolean SetBitmapFile(ImageView ivPic, String name, String url) {
if(name.contains(CACHE_PATH)){
name = name.replace(CACHE_PATH,"");
}
File file = new File(CACHE_PATH, name);
String imgUrl = null;
if(url!=null && url.startsWith("http")){


+ 14
- 3
app/src/main/java/com/bonait/bnframework/ui/activity/CookingActivity.java View File

@@ -19,6 +19,7 @@ import com.bonait.bnframework.Service.ModbusHelper;
import com.bonait.bnframework.business.NewExecuteTheRecipe;
import com.bonait.bnframework.business.RecordManager;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP;
@@ -138,6 +139,10 @@ public class CookingActivity extends BaseActivity {
NewExecuteTheRecipe.IsForcedEnd = false;
onRecordStart();
}else {
if (isFastClick()) {
NewToastUtil.getInstance().showToastBottom("点击太快了,请重试");
return;
}
if(NewExecuteTheRecipe.IsStart){
if(progressDialog ==null){
progressDialog = new WaiteProgressDialog(this);
@@ -252,15 +257,17 @@ public class CookingActivity extends BaseActivity {
}
if(!isTest){
if(ModbusHelper.get().isBtnStop()){
NewToastUtil.getInstance().showToastBottom("设备已急停,请关闭急停按钮再调试!");
RecordManager.getInstance().addLogRecord("订单处理日志",goodsSubattributeGroup.name+"-制作异常-急停按下");
NewToastUtil.getInstance().showToastError("设备已急停,请关闭急停按钮再调试!");
Thread.sleep(2000);
hasError = true;
break;
}
if(ModbusHelper.get().hasErrorInfo()){
RecordManager.getInstance().addLogRecord("订单处理日志",goodsSubattributeGroup.name+"-制作异常-传感器报警");
String tip = ModbusHelper.get().isBtnStop()?"设备已急停,请关闭急停按钮再调试!":"设备有报警,请前往设备故障页检查!";
Thread.sleep(2000);
NewToastUtil.getInstance().showToastBottom(tip);
NewToastUtil.getInstance().showToastError(tip);
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -297,7 +304,7 @@ public class CookingActivity extends BaseActivity {
}
} finally {
isMaking = false;
if(isTest){
if(!isTest){
if(!isError){
if(NewExecuteTheRecipe.IsForcedEnd){
RecordManager.getInstance().addLogRecord("订单处理日志",goodsSubattributeGroup.name+"-制作强行停止");
@@ -466,6 +473,10 @@ public class CookingActivity extends BaseActivity {
AlertDialogUtils.showTipDialog(this, "温馨提示!", "是否停止制作?", new AlertDialogUtils.DialogClickListener() {
@Override
public void onConfirm() {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
setReset();
onRecordStop();
finish();


+ 62
- 0
app/src/main/java/com/bonait/bnframework/ui/activity/DiyProcessActivity.java View File

@@ -237,21 +237,51 @@ public class DiyProcessActivity extends BaseActivity {
viewBinding.recycleStep.setAdapter(stepAdapter);
}

/**
* 判断重复点击
*/
private long lastTime;

public boolean isFastClick(){
long curTime = System.currentTimeMillis();
if(curTime - lastTime < 100){
return true;
}
lastTime = curTime;
return false;
}

/**
* 按钮点击监听
*/
private void initBtnListener(){
viewBinding.btnAdd.setOnClickListener(view -> {
if(isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
addProcess();
});
viewBinding.btnUpdate.setOnClickListener(view -> {
if(isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
updateProcess();
});
viewBinding.btnDelete.setOnClickListener(view -> {
if(isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
deleteProcess();
});
//模拟炒制
viewBinding.btnSimulation.setOnClickListener(view -> {
if(isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
Intent intent = new Intent(DiyProcessActivity.this, CookingActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("subAttributeGroupId",subAttributeGroupId);
@@ -262,6 +292,10 @@ public class DiyProcessActivity extends BaseActivity {
});
//录制工序
viewBinding.btnJumpRecordProcess.setOnClickListener(view -> {
if(isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
Intent intent = new Intent(DiyProcessActivity.this, RecProcessActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("subAttributeGroupId",subAttributeGroupId);
@@ -272,6 +306,10 @@ public class DiyProcessActivity extends BaseActivity {
});
viewBinding.llInsert.setVisibility(View.GONE);
viewBinding.btnInsert.setOnClickListener(view -> {
if(isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
if(viewBinding.llInsert.getVisibility() == View.VISIBLE){
viewBinding.llInsert.setVisibility(View.GONE);
viewBinding.llInsert.animate()
@@ -287,15 +325,31 @@ public class DiyProcessActivity extends BaseActivity {
}
});
viewBinding.btnInsertUp.setOnClickListener(view -> {
if(isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
insertUpProcess();
});
viewBinding.btnInsertDown.setOnClickListener(view -> {
if(isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
insertDownProcess();
});
/**
*导入工序
*/
viewBinding.btnCopyProcess.setOnClickListener(view -> {
if(isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
if(attributeSelectDialog == null){
attributeSelectDialog = new AttributeSelectDialog();
}
@@ -306,6 +360,10 @@ public class DiyProcessActivity extends BaseActivity {
attributeSelectDialog.setListener(new AttributeSelectDialog.DialogCallBack() {
@Override
public void submit() {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
processDetails.clear();
processDetails.addAll(GoodsProcessDetailDBUtil.getByGroupId(subAttributeGroupId));
changeMainFoods();
@@ -561,6 +619,10 @@ public class DiyProcessActivity extends BaseActivity {
viewBinding.topbar.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.topbj1));
viewBinding.topbar.setTitle("编辑工序");
viewBinding.back.setOnClickListener(v->{
if(isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
AlertDialogUtils.showCancelAndConfirmDialog(this,R.layout.dialog_with_cancel_confirm, new XComDialog.OnDialogListener(){

@Override


+ 33
- 0
app/src/main/java/com/bonait/bnframework/ui/activity/EditClassifyActivity.java View File

@@ -14,6 +14,7 @@ import com.apkfuns.logutils.LogUtils;
import com.bonait.bnframework.R;
import com.bonait.bnframework.business.RecordManager;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_CLASSIFY;
@@ -165,6 +166,10 @@ public class EditClassifyActivity extends BaseActivity {
binding.edit.setHint("请输入子属性名称");
binding.edit.setText(data.name);
binding.submit.setOnClickListener(view1 -> {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
String input = String.valueOf(binding.edit.getText());
if(!input.isEmpty()){
for(BPA_SUBATTRIBUTE bean:subattributeList){
@@ -247,6 +252,10 @@ public class EditClassifyActivity extends BaseActivity {
R.id.btn_delete_attribute,R.id.btn_add_subattribute,R.id.btn_delete_classify})
public void onViewClicked(View view) {

if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
switch (view.getId()){
case R.id.btn_add_classify://添加分类
addClassify();
@@ -282,6 +291,10 @@ public class EditClassifyActivity extends BaseActivity {
binding.title.setText("新增分类名称");
binding.edit.setHint("请输入分类名称");
binding.submit.setOnClickListener(view1 -> {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
String input = String.valueOf(binding.edit.getText());
if(!input.isEmpty()){
for (Map.Entry<String, String> entry : classifyList.entrySet()) {
@@ -328,6 +341,10 @@ public class EditClassifyActivity extends BaseActivity {
binding.title.setText("修改分类名称");
binding.edit.setText(classifyName);
binding.submit.setOnClickListener(view1 -> {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
String input = String.valueOf(binding.edit.getText());
if(!input.isEmpty()){
for (Map.Entry<String, String> entry : classifyList.entrySet()) {
@@ -373,6 +390,10 @@ public class EditClassifyActivity extends BaseActivity {
xCom.dismissX();
});
binding.submit.setOnClickListener(view1 -> {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
if(GoodsClassifyDBUtil.deleteById(classifyId)){
GoodsClassifyDBUtil.DeleteList(GoodsClassifyDBUtil.getListByName(classifyName));
AttributeDBUtil.deleteByClassifyId(classifyId);
@@ -428,6 +449,10 @@ public class EditClassifyActivity extends BaseActivity {
binding.title.setText("新增属性名称");
binding.edit.setHint("请输入属性名称");
binding.submit.setOnClickListener(view1 -> {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
String input = String.valueOf(binding.edit.getText());
if(!input.isEmpty()){
for(BPA_ATTRIBUTE bean:attributeList){
@@ -521,6 +546,10 @@ public class EditClassifyActivity extends BaseActivity {
binding.edit.setHint("请输入属性名称");
binding.edit.setText(attributeList.get(attributePosition).name);
binding.submit.setOnClickListener(view1 -> {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
String input = String.valueOf(binding.edit.getText());
if(!input.isEmpty()){
for(BPA_ATTRIBUTE bean:attributeList){
@@ -560,6 +589,10 @@ public class EditClassifyActivity extends BaseActivity {
binding.title.setText("新增子属性名称");
binding.edit.setHint("请输入子属性名称");
binding.submit.setOnClickListener(view1 -> {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
BPA_ATTRIBUTE attribute = attributeList.get(attributePosition);
String input = String.valueOf(binding.edit.getText());
if(!input.isEmpty()){


+ 10
- 0
app/src/main/java/com/bonait/bnframework/ui/activity/EditGoodsActivity.java View File

@@ -14,6 +14,7 @@ import com.apkfuns.logutils.LogUtils;
import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.common.utils.NetworkUtils;
import com.bonait.bnframework.databinding.FragmentHomeFoodsBinding;
@@ -70,6 +71,11 @@ public class EditGoodsActivity extends BaseActivity {
viewBinding.topbar.setBackgroundColor(ContextCompat.getColor(this, R.color.topbj1));
viewBinding.topbar.setTitle("菜品管理");
viewBinding.back.setOnClickListener(v->{

if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
finish();
});
}
@@ -113,6 +119,10 @@ public class EditGoodsActivity extends BaseActivity {
*/
@OnClick({R.id.localFoods, R.id.cloudFoods,R.id.search_view})
public void onViewClicked(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
switch (view.getId()) {
case R.id.localFoods:
LogUtils.d("//////1");


+ 6
- 0
app/src/main/java/com/bonait/bnframework/ui/activity/ErrorInfoActivity.java View File

@@ -22,9 +22,11 @@ import com.bonait.bnframework.R;
import com.bonait.bnframework.Service.ModbusHelper;
import com.bonait.bnframework.business.RecordManager;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.databinding.ActivityErrorInfoBinding;
import com.bonait.bnframework.ui.widget.NewToastUtil;

/**
* @author: liup
@@ -72,6 +74,10 @@ public class ErrorInfoActivity extends BaseActivity {

private void initView(){
viewBinding.btnReset.setOnClickListener(v->{
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
AlertDialogUtils.showTipDialog(this, "温馨提示!", "请观察升降台和搅拌爪情况再点击复位哦!", new AlertDialogUtils.DialogClickListener() {
@Override
public void onConfirm() {


+ 14
- 0
app/src/main/java/com/bonait/bnframework/ui/activity/LogRecordActivity.java View File

@@ -11,6 +11,7 @@ import android.widget.TextView;
import com.bigkoo.pickerview.TimePickerView;
import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_LOG_RECORD;
import com.bonait.bnframework.common.db.util.LogRecordUtil;
import com.bonait.bnframework.common.helper.DateUtils;
@@ -18,6 +19,7 @@ import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.databinding.ActivityLogBinding;
import com.bonait.bnframework.ui.adapter.LocalLogAdapter;
import com.bonait.bnframework.ui.widget.NewToastUtil;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -77,6 +79,10 @@ public class LogRecordActivity extends BaseActivity {
typeMap.add("页面上报日志");

viewBinding.btnQuery.setOnClickListener(v->{
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
Initdata();
});

@@ -88,6 +94,10 @@ public class LogRecordActivity extends BaseActivity {
viewBinding.starttime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
if (pvTime != null) {
pvTime.show(viewBinding.starttime);
}
@@ -96,6 +106,10 @@ public class LogRecordActivity extends BaseActivity {
viewBinding.stoptime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
if (pvTime != null) {
pvTime.show(viewBinding.stoptime);
}


+ 74
- 4
app/src/main/java/com/bonait/bnframework/ui/activity/MainActivity.java View File

@@ -2,23 +2,32 @@ package com.bonait.bnframework.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;

import com.apkfuns.logutils.LogUtils;
import com.bonait.bnframework.HBL.Logs.MessageLog;
import com.bonait.bnframework.HBL.Thread.IThread;
import com.bonait.bnframework.HBL.Thread.ThreadManager;
import com.bonait.bnframework.MainApplication;
import com.bonait.bnframework.Service.ModbusHelper;
import com.bonait.bnframework.ViewModel.Adapter.FragmentAdapter;
import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.business.NewExecuteTheRecipe;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.file.DBHelper;
import com.bonait.bnframework.common.db.mode.BPA_LOG_RECORD;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.helper.MQTT;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.utils.NetworkUtils;
import com.bonait.bnframework.common.utils.PreferenceUtils;
@@ -35,6 +44,18 @@ public class MainActivity extends BaseActivity {

private HomeFoodsFragment homeFoodsFragment;
private ActivityMainBinding viewBinding;
private Handler handler = new Handler(Looper.getMainLooper()){
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
if (msg.what == 1){
if(!ModbusHelper.get().getConnected()){
ModbusHelper.get().RtuInit("/dev/ttyCOM0",9600);
}
handler.sendEmptyMessageDelayed(1,3000);
}
}
};

@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -63,6 +84,17 @@ public class MainActivity extends BaseActivity {
@Override
protected void onResume() {
super.onResume();
if(handler!=null){
handler.sendEmptyMessageDelayed(1,1000);
}
}

@Override
protected void onPause() {
super.onPause();
if(handler!=null){
handler.removeCallbacksAndMessages(null);
}
}

private void initView(){
@@ -86,11 +118,16 @@ public class MainActivity extends BaseActivity {

@Override
protected void onDestroy() {
ExecuteTheRecipe.IsStart = false;
if(handler!=null){
handler.removeCallbacksAndMessages(null);
handler = null;
}
NewExecuteTheRecipe.IsStart = false;
ModbusHelper.get().setCookStatus(false);
ConfigData.getInstance().ColsePLC();
MessageManager.getInstance().unRegisterMessageReceiver(this);
ThreadManager.get().Stop("Modbus变量状态");
ThreadManager.get().Stop("PLC断线重连线程");
super.onDestroy();
}

@@ -170,15 +207,48 @@ public class MainActivity extends BaseActivity {
// ConfigData.getInstance().GetOrganize(this);
//判断连接环境
ConfigData.getInstance().ToggleEnvironment();
// //2.初始化PLC
// ReconnectModbus();
//初始化modbus
ModbusHelper.get().RtuInit("/dev/ttyCOM0",9600);
// ReconnectModbus();

//初始化阿里云连接
//AliyunIOTManager.getInstance().OpenDev(this);
}

public void ReconnectModbus() {
try {
ThreadManager.get().StartLong("PLC断线重连线程", true, new IThread() {
@Override
public void Run() throws InterruptedException {
try {
if (ModbusHelper.get().getConnected()) {
//ping 不通
boolean status = MQTT.ping2(ConfigName.getInstance().Address, 1, 1);
if (!status) //ping 不通 连接
{
ModbusHelper.get().setConnected(false);
}
} else {
boolean status = MQTT.ping2(ConfigName.getInstance().Address, 1, 1);
if (status) {
ModbusHelper.get().RtuInit("/dev/ttyCOM0",9600);
}else {
ModbusHelper.get().setConnected(false);
}
}
Thread.sleep(5000);
} catch (Exception e) {
Log.i("PLC", "PLC重连接失败!" + e.getMessage());
}
}


});
} catch (Exception e) {
MessageLog.ShowInfo("重新连接Modbus异常," + e.getMessage());
}
}

public static final int REQUEST_CLASSIFY_ACTIVITY = 1000;
public static final int REQUEST_GOODS_ACTIVITY = 1001;
@Override


+ 10
- 1
app/src/main/java/com/bonait/bnframework/ui/activity/RecProcessActivity.java View File

@@ -134,6 +134,10 @@ public class RecProcessActivity extends BaseActivity {
viewBinding.topbar.setBackgroundColor(ContextCompat.getColor(this, R.color.topbj1));
viewBinding.topbar.setTitle("录制工序");
viewBinding.back.setOnClickListener(v->{
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
AlertDialogUtils.showTipDialog(this, "温馨提示!", "退出将丢弃当前录制的工序", new AlertDialogUtils.DialogClickListener() {
@Override
public void onConfirm() {
@@ -171,6 +175,10 @@ public class RecProcessActivity extends BaseActivity {
viewBinding.title.setText(subAttributeGroupName.isEmpty()? goods.name :(goods.name+"-"+subAttributeGroupName));
}
viewBinding.pauseGoodmake.setOnClickListener(v->{
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
if (!IsPause) {
onRecordPause();
viewBinding.pauseGoodmake.setImageResource(R.mipmap.zhizuo_jx1);
@@ -439,7 +447,8 @@ public class RecProcessActivity extends BaseActivity {
* @param type 1加热 2液体 3主料 4搅拌
*/
private void showControlDialog(int type){
if (ConfigName.getInstance().isFastClick()){
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
if(ModbusHelper.get().isBtnStop()){


+ 6
- 0
app/src/main/java/com/bonait/bnframework/ui/adapter/OrderAdapter.java View File

@@ -8,9 +8,11 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bonait.bnframework.common.base.BaseAdapter;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_ORDER_RECORD;
import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.databinding.ItemOrderBinding;
import com.bonait.bnframework.ui.widget.NewToastUtil;

/**
* @author: liup
@@ -38,6 +40,10 @@ public abstract class OrderAdapter extends BaseAdapter<BPA_ORDER_RECORD, OrderAd
holder.binding.complete.setText(order.completeCount+"");
holder.binding.error.setText(order.errorCount+"");
holder.binding.root.setOnClickListener(view -> {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
onItemClick(view,position);
});
}


+ 6
- 0
app/src/main/java/com/bonait/bnframework/ui/adapter/SubOrderAdapter.java View File

@@ -8,9 +8,11 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bonait.bnframework.common.base.BaseAdapter;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_SUBORDER_RECORD;
import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.databinding.ItemOrderBinding;
import com.bonait.bnframework.ui.widget.NewToastUtil;

/**
* @author: liup
@@ -42,6 +44,10 @@ public abstract class SubOrderAdapter extends BaseAdapter<BPA_SUBORDER_RECORD, S
holder.binding.complete.setText(order.subCompleteCount+"");
holder.binding.error.setText(order.subErrorCount+"");
holder.binding.root.setOnClickListener(view -> {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
onItemClick(view,position);
});
}


+ 6
- 0
app/src/main/java/com/bonait/bnframework/ui/adapter/classify/AttributeAdapter.java View File

@@ -11,9 +11,11 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.ui.widget.NewToastUtil;

import java.util.List;

@@ -66,6 +68,10 @@ public class AttributeAdapter extends ArrayAdapter<BPA_ATTRIBUTE> {
name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
selectPosition = position;
notifyDataSetChanged();
if(mListener!=null) mListener.clickListenerNew(view,position,bean);


+ 6
- 0
app/src/main/java/com/bonait/bnframework/ui/adapter/classify/ClassifyAdapter.java View File

@@ -10,9 +10,11 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bonait.bnframework.common.base.BaseAdapter;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_CLASSIFY;
import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.databinding.ItemClassifyBinding;
import com.bonait.bnframework.ui.widget.NewToastUtil;

/**
* @author: liup
@@ -47,6 +49,10 @@ public abstract class ClassifyAdapter extends BaseAdapter<BPA_GOODS_CLASSIFY,Cla
holder.binding.name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
int lastPos = mCurrentPosition;
mCurrentPosition= position;
notifyItemChanged(lastPos);


+ 6
- 0
app/src/main/java/com/bonait/bnframework/ui/adapter/classify/SelectSubAttributeAdapter.java View File

@@ -10,9 +10,11 @@ import androidx.recyclerview.widget.RecyclerView;

import com.apkfuns.logutils.LogUtils;
import com.bonait.bnframework.common.base.BaseAdapter;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_SUBATTRIBUTE;
import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.databinding.ItemSelectSubattributeBinding;
import com.bonait.bnframework.ui.widget.NewToastUtil;

/**
* @author: liup
@@ -69,6 +71,10 @@ public class SelectSubAttributeAdapter extends BaseAdapter<BPA_SUBATTRIBUTE,Sele
holder.binding.name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
int last = mCurrentPosition;
mCurrentPosition = position;
notifyItemChanged(last);


+ 10
- 0
app/src/main/java/com/bonait/bnframework/ui/adapter/classify/SubattributeAdapter.java View File

@@ -11,8 +11,10 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_SUBATTRIBUTE;
import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.ui.widget.NewToastUtil;

import java.util.List;

@@ -49,12 +51,20 @@ public class SubattributeAdapter extends ArrayAdapter<BPA_SUBATTRIBUTE> {
name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
if(mListener!=null) mListener.clickName(view,position,bean);
}
});
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
if(mListener!=null) mListener.clickDelete(view,position,bean);
}
});


+ 10
- 0
app/src/main/java/com/bonait/bnframework/ui/adapter/goods/CloudGoodsAdapter.java View File

@@ -11,12 +11,14 @@ import androidx.recyclerview.widget.RecyclerView;
import com.apkfuns.logutils.LogUtils;
import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseAdapter;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.util.GoodsDBUtil;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.databinding.ItemCloudGoodsBinding;
import com.bonait.bnframework.ui.widget.NewToastUtil;

/**
* @author: liup
@@ -64,6 +66,10 @@ public abstract class CloudGoodsAdapter extends BaseAdapter<BPA_GOODS,CloudGoods
holder.binding.downLoad.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
if(downLoadGoods(view,position)){
ToastUtils.info("下载成功");
holder.binding.downLoad.setVisibility(View.GONE);
@@ -75,6 +81,10 @@ public abstract class CloudGoodsAdapter extends BaseAdapter<BPA_GOODS,CloudGoods
holder.binding.image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
if (GoodsDBUtil.getByName(goods.name)==null) {
ToastUtils.warning("请先下载该商品!");
} else {


+ 20
- 1
app/src/main/java/com/bonait/bnframework/ui/adapter/goods/LocalGoodsAdapter.java View File

@@ -10,10 +10,13 @@ import androidx.recyclerview.widget.RecyclerView;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseAdapter;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.glide.GlideUtil;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.databinding.ItemLocalGoodsBinding;
import com.bonait.bnframework.ui.widget.NewToastUtil;

/**
* @author: liup
@@ -52,6 +55,10 @@ public abstract class LocalGoodsAdapter extends BaseAdapter<BPA_GOODS,LocalGoods
holder.binding.add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
addGoods();
}
});
@@ -64,7 +71,7 @@ public abstract class LocalGoodsAdapter extends BaseAdapter<BPA_GOODS,LocalGoods
if(url!=null && !url.isEmpty() &&!url.equals("未知"))
{
myBitmapUtils.disPlay(holder.binding.image,url);
// GlideUtil.showImage(holder.binding.image.getContext(),url,holder.binding.image,R.mipmap.loading123);
GlideUtil.showImage(holder.binding.image.getContext(),url,holder.binding.image,R.mipmap.loading123);
}else {
holder.binding.image.setImageResource(R.mipmap.loading123);
}
@@ -72,6 +79,10 @@ public abstract class LocalGoodsAdapter extends BaseAdapter<BPA_GOODS,LocalGoods
holder.binding.upload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
// ConfigData.getInstance().UploadGoods(holder.itemView.getContext(), goods.id);
uploadGoods(view,position);
}
@@ -81,6 +92,10 @@ public abstract class LocalGoodsAdapter extends BaseAdapter<BPA_GOODS,LocalGoods
holder.binding.delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
deleteGoods(view,position);
}
});
@@ -89,6 +104,10 @@ public abstract class LocalGoodsAdapter extends BaseAdapter<BPA_GOODS,LocalGoods
holder.binding.image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
onItemClick(view,position);
}
});


+ 6
- 0
app/src/main/java/com/bonait/bnframework/ui/adapter/silos/MaterialAdapter.java View File

@@ -12,9 +12,11 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.ui.widget.NewToastUtil;

import java.util.List;

@@ -54,6 +56,10 @@ public class MaterialAdapter extends ArrayAdapter<BPA_MATERIAL> {
name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
if(mListener!=null) mListener.clickListener(view,bpa_material);
}
});


+ 6
- 0
app/src/main/java/com/bonait/bnframework/ui/adapter/silos/SilosAdapter.java View File

@@ -11,9 +11,11 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.res.lcMode;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.ui.widget.NewToastUtil;

import java.util.List;

@@ -56,6 +58,10 @@ public class SilosAdapter extends ArrayAdapter<lcMode> {
name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
if(mListener!=null) mListener.clickListenerNew(view,position,lc);
}
});


+ 29
- 15
app/src/main/java/com/bonait/bnframework/ui/fragment/HomeDevicesFragment.java View File

@@ -110,7 +110,24 @@ public class HomeDevicesFragment extends BaseFragment {
isUp = true;
isStir = false;
changeDevicePic();
ModbusHelper.get().reset();
close();
}

/**
* 关闭所有接口
*/
private void close(){
ThreadManager.get().execute(new Thread(()->{
ModbusHelper.get().reset();
ModbusHelper.get().setCookStatus(false);
}));
ThreadManager.get().execute(new Thread(() -> {
ModbusHelper.get().addWater(0f,true);
ModbusHelper.get().addThickenWater(0f,true);
for(int i =1;i<=9;i++){
ModbusHelper.get().addMaterial(0f,i,true);
}
}));
}

@Override
@@ -154,6 +171,10 @@ public class HomeDevicesFragment extends BaseFragment {
NewToastUtil.getInstance().showToast("复位完成");
});
viewBinding.deviceRecord.setOnClickListener(v->{
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
Intent intent = new Intent(getContext(), DeviceRecordActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
@@ -294,15 +315,21 @@ public class HomeDevicesFragment extends BaseFragment {
*/
private void showControlDialog(int type){
if(ConfigName.getInstance().user.name.contains("一般用户")){
NewToastUtil.getInstance().showToast("当前用户权限无法操作");
return;
}
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快");
return;
}
if(ModbusHelper.get().isBtnStop()){
NewToastUtil.getInstance().showToast("设备已急停,请关闭急停按钮再调试!");
return;
}
if(ModbusHelper.get().hasErrorInfo()){
NewToastUtil.getInstance().showToast("设备有报警,请前往设备报警页检查复位!");
return;
}
if(getActivity()!=null){
if(deviceControlDialog == null){
deviceControlDialog = new DeviceControlDialog();
@@ -391,19 +418,6 @@ public class HomeDevicesFragment extends BaseFragment {
handler = null;
}
deviceCallBack = null;
ThreadManager.get().execute(new Thread(() -> ModbusHelper.get().setStirMotor(0,2)));
ThreadManager.get().execute(new Thread(() -> ModbusHelper.get().setUpdDownMotor(1)));
ThreadManager.get().execute(new Thread(() -> ModbusHelper.get().Heating(0,false)));
ThreadManager.get().execute(new Thread(() -> {
ModbusHelper.get().addWater(0f,true);
}));
ThreadManager.get().execute(new Thread(() -> {
ModbusHelper.get().addThickenWater(0f,true);
}));
ThreadManager.get().execute(new Thread(() -> {
for(int i =1;i<=9;i++){
ModbusHelper.get().addMaterial(0f,i,true);
}
}));
close();
}
}

+ 9
- 0
app/src/main/java/com/bonait/bnframework/ui/fragment/HomeFoodsFragment.java View File

@@ -18,6 +18,7 @@ import com.apkfuns.logutils.LogUtils;
import com.bonait.bnframework.R;
import com.bonait.bnframework.Service.ModbusHelper;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.common.utils.NetworkUtils;
import com.bonait.bnframework.databinding.FragmentHomeFoodsBinding;
@@ -141,10 +142,18 @@ public class HomeFoodsFragment extends BaseFragment {
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.localFoods:
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
LogUtils.d("//////1");
SelectTab(1);
break;
case R.id.cloudFoods:
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
LogUtils.d("//////2");
SelectTab(2);
requestData();


+ 21
- 0
app/src/main/java/com/bonait/bnframework/ui/fragment/HomeMainFragment.java View File

@@ -68,6 +68,9 @@ public class HomeMainFragment extends BaseFragment {
*/
private void initView() {
binding.llClassify.setOnClickListener(v->{
if(ConfigName.getInstance().isFastClick()){
return;
}
if(!isManagerUser()){
return;
}
@@ -76,6 +79,9 @@ public class HomeMainFragment extends BaseFragment {
}
});
binding.llYanfa.setOnClickListener(v->{
if(ConfigName.getInstance().isFastClick()){
return;
}
if(!isManagerUser()){
return;
}
@@ -84,18 +90,30 @@ public class HomeMainFragment extends BaseFragment {
}
});
binding.llSilos.setOnClickListener(v->{
if(ConfigName.getInstance().isFastClick()){
return;
}
if(!isManagerUser()){
return;
}
OpenActivity(SetSeasoningActivity.class);
});
binding.llError.setOnClickListener(v->{
if(ConfigName.getInstance().isFastClick()){
return;
}
OpenActivity(ErrorInfoActivity.class);
});
binding.llLog.setOnClickListener(v->{
if(ConfigName.getInstance().isFastClick()){
return;
}
OpenActivity(LogRecordActivity.class);
});
binding.llOrder.setOnClickListener(v->{
if(ConfigName.getInstance().isFastClick()){
return;
}
OpenActivity(OrderRecordActivity.class);
});
binding.logout.setOnClickListener(v->{
@@ -117,6 +135,9 @@ public class HomeMainFragment extends BaseFragment {
binding.tvConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ConfigName.getInstance().isFastClick()){
return;
}
skipToLoginActivity();
RecordManager.getInstance().addLogRecord("角色操作日志",ConfigName.getInstance().user.name+"-退出登录");
xCom.dismissX();


+ 4
- 0
app/src/main/java/com/bonait/bnframework/ui/fragment/goods/CloudGoodsFragment.java View File

@@ -123,6 +123,10 @@ public class CloudGoodsFragment extends BaseFragment {
AlertDialogUtils.showTipDialog((AppCompatActivity) getActivity(), "数据同步", "下载云端所有菜品到本地,拥有相同的分类将会被覆盖,请确认?", new AlertDialogUtils.DialogClickListener() {
@Override
public void onConfirm() {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
RecordManager.getInstance().addLogRecord("角色操作日志", "数据同步");
if(progressDialog ==null){
progressDialog = new WaiteProgressDialog(getContext());


+ 12
- 0
app/src/main/java/com/bonait/bnframework/ui/fragment/goods/LocalGoodsFragment.java View File

@@ -112,6 +112,10 @@ public class LocalGoodsFragment extends BaseFragment {
viewBinding.addClassify.setVisibility(isEdit?View.VISIBLE:View.GONE);

viewBinding.addClassify.setOnClickListener(view -> {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
jumpClassify();
});
viewBinding.deleteAll.setVisibility(isEdit?View.VISIBLE:View.GONE);
@@ -119,6 +123,10 @@ public class LocalGoodsFragment extends BaseFragment {
AlertDialogUtils.showTipDialog((AppCompatActivity) getActivity(), "请确认", "确认删除所有商品信息?", new AlertDialogUtils.DialogClickListener() {
@Override
public void onConfirm() {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
MainInit.clearGoodsInfo();
updateData();
RecordManager.getInstance().addLogRecord("角色操作日志","删除所有商品信息");
@@ -166,6 +174,10 @@ public class LocalGoodsFragment extends BaseFragment {
xCom.dismissX();
});
binding.submit.setOnClickListener(view1 -> {
if(ConfigName.getInstance().isFastClick()){
NewToastUtil.getInstance().showToast("点击过快!");
return;
}
GoodsProcessDetailDBUtil.deleteByGoodsId(bean.id);
SubAttributeGroupDBUtil.deleteByGoodsId(bean.id);
if(GoodsDBUtil.delete(bean)){


+ 2
- 2
build.gradle View File

@@ -35,8 +35,8 @@ task clean(type: Delete) {

ext { // 统一版本入口
//App版本号
versionCode = 208
versionName = "2.0.8"
versionCode = 209
versionName = "2.0.9"

// 支持Android版本
buildToolsVersion = "33.0.0"


Loading…
Cancel
Save