Browse Source

菜品上传功能

授权码生成工具
liup 5 months ago
parent
commit
3b9bb33dff
32 changed files with 1480 additions and 204 deletions
  1. +15
    -0
      .idea/git_toolbox_prj.xml
  2. +7
    -2
      app/src/main/AndroidManifest.xml
  3. +8
    -0
      app/src/main/java/com/bonait/bnframework/MainApplication.java
  4. +30
    -4
      app/src/main/java/com/bonait/bnframework/business/ConfigData.java
  5. +15
    -12
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  6. +1
    -0
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  7. +6
    -3
      app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java
  8. +20
    -0
      app/src/main/java/com/bonait/bnframework/common/db/util/AttributeDBUtil.java
  9. +12
    -2
      app/src/main/java/com/bonait/bnframework/common/helper/ReceiveData.java
  10. +101
    -101
      app/src/main/java/com/bonait/bnframework/common/helper/TcpClient.java
  11. +153
    -0
      app/src/main/java/com/bonait/bnframework/common/model/DeviceInfoBean.java
  12. +29
    -0
      app/src/main/java/com/bonait/bnframework/common/model/GoodsData.java
  13. +85
    -0
      app/src/main/java/com/bonait/bnframework/common/model/upload/GoodsDataInfo.java
  14. +52
    -0
      app/src/main/java/com/bonait/bnframework/common/model/upload/MaterialDataInfo.java
  15. +67
    -0
      app/src/main/java/com/bonait/bnframework/common/model/upload/UpAttributeBean.java
  16. +60
    -0
      app/src/main/java/com/bonait/bnframework/common/model/upload/UpBaseBean.java
  17. +38
    -0
      app/src/main/java/com/bonait/bnframework/common/model/upload/UpClassifyBean.java
  18. +66
    -0
      app/src/main/java/com/bonait/bnframework/common/model/upload/UploadRes.java
  19. +5
    -8
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java
  20. +20
    -21
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java
  21. +7
    -18
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CookingActivity.java
  22. +2
    -2
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_qupenren.java
  23. +2
    -2
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebuttom.java
  24. +1
    -1
      app/src/main/java/com/bonait/bnframework/ui/dialog/AttributeSelectDialog.java
  25. +18
    -8
      app/src/main/java/com/bonait/bnframework/ui/dialog/EditGoodsDialog.java
  26. +2
    -0
      app/src/main/java/com/bonait/bnframework/ui/fragment/goods/CloudGoodsFragment.java
  27. +3
    -2
      app/src/main/java/com/bonait/bnframework/ui/viewmodel/HomeGoodsViewModel.java
  28. +292
    -0
      app/src/main/java/com/bonait/bnframework/ui/viewmodel/UpdateAllDataService.java
  29. +302
    -0
      app/src/main/java/com/bonait/bnframework/ui/viewmodel/UpdateDataService.java
  30. +59
    -0
      app/src/main/java/com/bonait/bnframework/ui/widget/WaitProcessUtil.java
  31. +0
    -16
      app/src/main/res/layout/fragment_home1.xml
  32. +2
    -2
      app/src/main/res/layout/fragment_home2.xml

+ 15
- 0
.idea/git_toolbox_prj.xml View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxProjectSettings">
<option name="commitMessageIssueKeyValidationOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
<option name="commitMessageValidationEnabledOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
</component>
</project>

+ 7
- 2
app/src/main/AndroidManifest.xml View File

@@ -97,6 +97,7 @@
tools:ignore="Instantiatable" />
<activity
android:name=".modules.home.activity.BottomNavigationNewActivity"
android:launchMode="singleTask"
android:exported="false" />
<activity
android:name=".modules.mine.fragment.UserActivity"
@@ -180,6 +181,7 @@

<activity
android:name=".modules.welcome.activity.WelcomeActivity"
android:launchMode="singleTask"
android:exported="true"
android:theme="@style/AppTheme.Launcher">
<intent-filter>
@@ -188,7 +190,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".modules.welcome.activity.LoginActivity">
<activity android:name=".modules.welcome.activity.LoginActivity"
android:launchMode="singleTask">

<!-- <intent-filter> -->
<!-- <action android:name="com.bonait.bnframework.modules.welcome.activity.LoginActivity.ACTION_START" /> -->
@@ -207,7 +210,9 @@
</intent-filter>
-->
</activity>
<activity android:name=".modules.home.activity.BottomNavigation2Activity" />
<activity android:name=".modules.home.activity.BottomNavigation2Activity"
android:launchMode="singleTask"
android:exported="true"></activity>

<receiver
android:name=".common.base.BootReceiver"


+ 8
- 0
app/src/main/java/com/bonait/bnframework/MainApplication.java View File

@@ -7,6 +7,8 @@ import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;

import androidx.core.content.ContextCompat;
@@ -32,6 +34,7 @@ import com.bonait.bnframework.common.helper.CrashHandler;
import com.bonait.bnframework.common.helper.I.IMessageLogNotify;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.SdCart;
import com.bonait.bnframework.common.thread.ThreadManager;
import com.bonait.bnframework.common.utils.NetworkUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.manager.ActivityLifecycleManager;
@@ -74,6 +77,10 @@ public class MainApplication extends Application {
return context;
}

public static Handler handler = new Handler(Looper.getMainLooper()){

};

@Override
public void onCreate() {
super.onCreate();
@@ -82,5 +89,6 @@ public class MainApplication extends Application {
context = getApplicationContext();
ConfigName.getInstance().dishesCon = this;
ConfigName.getInstance().app = this;
ThreadManager.get().inti();
}
}

+ 30
- 4
app/src/main/java/com/bonait/bnframework/business/ConfigData.java View File

@@ -15,17 +15,27 @@ import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.file.DBHelper;
import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE;
import com.bonait.bnframework.common.db.mode.BPA_CLOUDDATA;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_CLASSIFY;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP;
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_PROCESS;
import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel;
import com.bonait.bnframework.common.db.mode.BPA_SILOS;
import com.bonait.bnframework.common.db.mode.BPA_SUBATTRIBUTE;
import com.bonait.bnframework.common.db.mode.BPA_SYSTEMSET;
import com.bonait.bnframework.common.db.mode.Res_PLCADDRESS;
import com.bonait.bnframework.common.db.util.AttributeDBUtil;
import com.bonait.bnframework.common.db.util.DBListDataUtil;
import com.bonait.bnframework.common.db.util.GoodsClassifyDBUtil;
import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil;
import com.bonait.bnframework.common.db.util.SubAttributeDBUtil;
import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil;
import com.bonait.bnframework.common.helper.ConfigUtil;
import com.bonait.bnframework.common.helper.I.IRun;
import com.bonait.bnframework.common.helper.I.IRunT;
@@ -406,11 +416,23 @@ public class ConfigData {
DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODS.class,null);
DBListDataUtil.addGOODSList(rd.goods);

DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_MATERIAL.class,null);
DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODS_CLASSIFY.class,null);
GoodsClassifyDBUtil.addList(rd.classifies);

DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_ATTRIBUTE.class,null);
AttributeDBUtil.addList(rd.attributes);

DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_SUBATTRIBUTE.class,null);
SubAttributeDBUtil.addList(rd.subattributes);

DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODS_SUBATTRIBUTE_GROUP.class,null);
SubAttributeGroupDBUtil.addList(rd.groups);

DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_MATERIAL.class,"id");
DBListDataUtil.addMATERIALList(rd.material);

DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODSRECIPE.class,null);
DBListDataUtil.addGOODSRECIPEList(rd.goodsrecipes);
DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODS_PROCESS_DETAIL.class,null);
GoodsProcessDetailDBUtil.addList(rd.goodsrecipes);

DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_PROCESS.class,null);
DBListDataUtil.addPROCESSList(rd.processes);
@@ -1100,7 +1122,11 @@ public class ConfigData {
try {
String str = ConfigName.getInstance().SaasAddress + ConfigName.getInstance().UpdateGoods;
// String str="http://192.168.1.7:5000/api/CommInteface/SendGoodsInfo";
OkGo.<ResAPI<Boolean>>post(str).tag(context).upRequestBody(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(update))).headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId)).execute(new JsonDialogCallback<ResAPI<Boolean>>(context) {
OkGo.<ResAPI<Boolean>>post(str).tag(context).upRequestBody(
RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(update))).headers(
new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId)).
execute(new JsonDialogCallback<ResAPI<Boolean>>(context) {
@Override
public void onSuccess(Response<ResAPI<Boolean>> response) {
ResAPI<Boolean> allDataResAPI = response.body();


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

@@ -8,6 +8,8 @@ import android.os.Looper;
import android.util.Log;

import androidx.annotation.NonNull;

import com.apkfuns.logutils.LogUtils;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.constant.MessageName;
@@ -144,6 +146,7 @@ public class ExecuteTheRecipe {
* @return
*/
public static boolean Execute(BPA_GOODS_PROCESS_DETAIL recipe, ArrayList<BPA_GOODS_PROCESS_DETAIL> all, int index) {
LogUtils.d("ExecuteTheRecipe Execute "+recipe.processname+"--"+recipe.processvalue);
boolean status = false;
all_list = all;
selectpf = recipe;
@@ -155,7 +158,7 @@ public class ExecuteTheRecipe {
return false;
}

if (!ConfigName.getInstance().PlcIsConnect) {
if (!ConfigName.getInstance().PlcIsConnect && !ConfigName.isTEST) {
ExecuteTheRecipe.showlog("客官,检测到硬件已经断开连接,主动停止炒制!!!");
IsForcedEnd = true;
return false;
@@ -1635,7 +1638,7 @@ public class ExecuteTheRecipe {
}
}

if (ConfigName.getInstance().PlcIsConnect) {
if ( (ConfigName.getInstance().PlcIsConnect||ConfigName.isTEST)) {
TempControl();
ReadPLCStatus();

@@ -1657,7 +1660,7 @@ public class ExecuteTheRecipe {
@Override
public void Run() throws InterruptedException {
try {
if (ConfigName.getInstance().PlcIsConnect) {
if ( (ConfigName.getInstance().PlcIsConnect||ConfigName.isTEST)) {
//心跳
WritePLC("心跳位", 0, null);
Log.e("心跳", "心跳: ");
@@ -1740,7 +1743,7 @@ public class ExecuteTheRecipe {
try {
if (ConfigName.getInstance().PLC_Address.containsKey(name)) {
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name);
if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) {
if (!plcaddress.address.isEmpty() && (ConfigName.getInstance().PlcIsConnect||ConfigName.isTEST)) {
if (plcaddress.address.toUpperCase().startsWith("VD"))//int
{
ModbusTcpServer.get().WriteInt(plcaddress.address, (int) value, callback);
@@ -1774,7 +1777,7 @@ public class ExecuteTheRecipe {
try {
if (ConfigName.getInstance().PLC_Address.containsKey(name)) {
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name);
if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) {
if (!plcaddress.address.isEmpty() && (ConfigName.getInstance().PlcIsConnect||ConfigName.isTEST)) {
if (plcaddress.address.toUpperCase().startsWith("VD"))//int
{
ModbusTcpServer.get().ReadInt(plcaddress.address, 1, ints -> {
@@ -1932,7 +1935,7 @@ public class ExecuteTheRecipe {
*/
public static void ReadPLCStatus() {
try {
if (ConfigName.getInstance().PlcIsConnect) {
if ( (ConfigName.getInstance().PlcIsConnect||ConfigName.isTEST)) {
ModbusTcpServer.get().ReadStatus("VW354", 1, data -> {
for (int i = 0; i < data.length; i++) {
byte status = data[i];//0x92
@@ -2025,10 +2028,10 @@ public class ExecuteTheRecipe {
WriteMainPLC("商品数据验证", false, null);
} else {
Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成");
if (!ConfigName.getInstance().PlcIsConnect) {
if (!ConfigName.getInstance().PlcIsConnect && !ConfigName.isTEST) {
ToastUtils.warning("PLC未准备就绪!!!");
WriteMainPLC("商品数据验证", false, null);
} else if (chushiover == null || !(boolean) chushiover) {
} else if ((chushiover == null || !(boolean) chushiover) && !ConfigName.isTEST) {
ToastUtils.warning("设备未初始化,请先手动初始化设备!!!");
WriteMainPLC("商品数据验证", false, null);
} else if (ExecuteTheRecipe.IsStart) {
@@ -2174,7 +2177,7 @@ public class ExecuteTheRecipe {
NoticeAtPresentTime.Run(AtPresentTime);
}
long startTime = System.currentTimeMillis();// && ConfigName.getInstance().PlcIsConnect
while ((System.currentTimeMillis() - startTime) <= (delay * 1000) && !IsForcedEnd && ConfigName.getInstance().PlcIsConnect) {
while ((System.currentTimeMillis() - startTime) <= (delay * 1000) && !IsForcedEnd && (ConfigName.getInstance().PlcIsConnect||ConfigName.isTEST)) {
try {
Thread.sleep(100);
int mmmm = delay - (int) ((System.currentTimeMillis() - startTime) / 1000);
@@ -2210,7 +2213,7 @@ public class ExecuteTheRecipe {
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
ExecuteTheRecipe.showlog(name + ",等待中");
while (!IsComplete[0] && !IsForcedEnd && ConfigName.getInstance().PlcIsConnect) {
while (!IsComplete[0] && !IsForcedEnd && (ConfigName.getInstance().PlcIsConnect||ConfigName.isTEST)) {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
ExecuteTheRecipe.showlog(name + ",异常超时退出!");
break;
@@ -2254,7 +2257,7 @@ public class ExecuteTheRecipe {
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
ExecuteTheRecipe.showlog(name + ",等待中");
while (!IsComplete[0] && !IsForcedEnd && ConfigName.getInstance().PlcIsConnect) {
while (!IsComplete[0] && !IsForcedEnd && (ConfigName.getInstance().PlcIsConnect||ConfigName.isTEST)) {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
ExecuteTheRecipe.showlog(name + ",异常超时退出!");
break;
@@ -2293,7 +2296,7 @@ public class ExecuteTheRecipe {
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
ExecuteTheRecipe.showlog(name + ",等待中");
while (!IsComplete[0] && !IsForcedEnd && ConfigName.getInstance().PlcIsConnect) {
while (!IsComplete[0] && !IsForcedEnd && (ConfigName.getInstance().PlcIsConnect||ConfigName.isTEST)) {
if ((System.currentTimeMillis() - a) > 1000 * whileTime * k) {
ExecuteTheRecipe.showlog(name + ",异常超时退出!");
break;


+ 1
- 0
app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java View File

@@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
* 配置文件
*/
public class ConfigName {
public static boolean isTEST = true;
//region 单例模式
private static ConfigName mInstance; //实例变量设置私有,防止直接通过类名访问



+ 6
- 3
app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java View File

@@ -7,6 +7,8 @@ import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_ALERTLOG;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP;
import com.bonait.bnframework.common.db.mode.BPA_LOG;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_SILOS;
@@ -16,6 +18,7 @@ import com.bonait.bnframework.common.db.res.ResGoodsMake;
import com.bonait.bnframework.common.db.res.ResGoodsRecipe;
import com.bonait.bnframework.common.db.res.StatusMode;
import com.bonait.bnframework.common.db.res.lcMode;
import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil;
import com.bonait.bnframework.common.helper.I.IRun;
import com.bonait.bnframework.common.helper.I.IRunT;
import com.bonait.bnframework.common.helper.I.MyClickListener;
@@ -54,7 +57,7 @@ public class DataBus {
/**
* 显示主料名称
*/
public ConcurrentHashMap<Integer,String> GetMainDisplayText(String goodid)
public ConcurrentHashMap<Integer,String> GetMainDisplayText(String goodsGroupId)
{
ConcurrentHashMap<Integer,String> resultData=new ConcurrentHashMap<>();
String text1="";
@@ -63,8 +66,8 @@ public class DataBus {
String text4="";
try
{
ArrayList<BPA_GOODSRECIPE> goodsrecipes= QueryDB.GetGoodsSrecipeID(goodid);
for (BPA_GOODSRECIPE goodsrecipe:goodsrecipes)
ArrayList<BPA_GOODS_PROCESS_DETAIL> goodsrecipes= GoodsProcessDetailDBUtil.getByGroupId(goodsGroupId);
for (BPA_GOODS_PROCESS_DETAIL goodsrecipe:goodsrecipes)
{
if(goodsrecipe.processname.equals("主料"))
{


+ 20
- 0
app/src/main/java/com/bonait/bnframework/common/db/util/AttributeDBUtil.java View File

@@ -180,6 +180,26 @@ public class AttributeDBUtil {
return data;
}

/**
* 根据分类classifyId获取属性列表
*
* @param classifyId
* @return ArrayList<BPA_ATTRIBUTE>
*/
public static ArrayList<BPA_ATTRIBUTE> getAll(String classifyId) {
String orderby = QueryDB.Desc_Sort_Up;//时间
String where = "isDelete=? and classifyId=?";
String[] args = new String[]{"0",classifyId};
ArrayList<BPA_ATTRIBUTE> data = new ArrayList<>();
ArrayList<Object> obj = QueryDB.Get(BPA_ATTRIBUTE.class, where, args, orderby);
for (Object k : obj) {
data.add((BPA_ATTRIBUTE) k);
}
LogUtils.d("getByClassify 根据分类classifyId获取属性列表 data=" + data.toString());

return data;
}

/**
* 判断分类下的属性是否存在
* @param classifyId


+ 12
- 2
app/src/main/java/com/bonait/bnframework/common/helper/ReceiveData.java View File

@@ -1,21 +1,31 @@
package com.bonait.bnframework.common.helper;

import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE;
import com.bonait.bnframework.common.db.mode.BPA_CLOUDDATA;
import com.bonait.bnframework.common.db.mode.BPA_CRAFT;
import com.bonait.bnframework.common.db.mode.BPA_CRAFTPROCESS;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_CLASSIFY;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_PROCESS;
import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel;
import com.bonait.bnframework.common.db.mode.BPA_SILOS;
import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_SUBATTRIBUTE;

import java.util.ArrayList;

public class ReceiveData {
public ArrayList<BPA_GOODS> goods;//商品表
public ArrayList<BPA_MATERIAL> material;//物料表
public ArrayList<BPA_GOODSRECIPE> goodsrecipes;//商品配方明细表
public ArrayList<BPA_MATERIAL> material;//物料表
public ArrayList<BPA_GOODS_CLASSIFY> classifies;//商品配方明细表
public ArrayList<BPA_ATTRIBUTE> attributes;//商品配方明细表
public ArrayList<BPA_SUBATTRIBUTE> subattributes;//商品配方明细表
public ArrayList<BPA_GOODS_SUBATTRIBUTE_GROUP> groups;//商品配方明细表
public ArrayList<BPA_GOODS_PROCESS_DETAIL> goodsrecipes;//商品配方明细表
public ArrayList<BPA_PROCESS> processes;//工序表
public ArrayList<BPA_PROCESSModel> processModels;//工序模型表
}


+ 101
- 101
app/src/main/java/com/bonait/bnframework/common/helper/TcpClient.java View File

@@ -78,108 +78,108 @@ public class TcpClient {
private boolean CloseFlag=false;

public void Connect(String ip,int port){
IpAddress=ip;
Port=port;
new Thread(()->{
MessageLog.ShowInfo("本地IP地址:"+getHostIP());
MessageLog.ShowInfo("开始连接 TcpServie");
CloseFlag=false;
boolean ErrorFlag=false;
while(socket==null||!socket.isConnected()){
try{
socket = new Socket(IpAddress,Port);
if(CloseFlag)break;
Thread.sleep(1000);
}catch (Exception e){
if(!ErrorFlag){
MessageLog.ShowInfo("连接失败:"+e.getMessage());
ErrorFlag=true;
}
}
}
if(CloseFlag)return;
MessageLog.ShowInfo("TcpClient连接成功");
ThreadManager.Get().StartLong("TCP客户端监听", true, new IThread() {
@Override
public void Run() throws Exception {
if(CheckConnect()){
try{
if(socket.getInputStream().available()>0){
byte[] buffer = new byte[socket.getInputStream().available()];
int len = socket.getInputStream().read(buffer);
String str = new String(buffer,"UTF-8");
msg.add(str);
MessageLog.ShowInfo("接收数据完成,接收长度:"+buffer.length);
}
}catch (Exception e){MessageLog.ShowInfo("错误1:"+e.getMessage());}
}
Thread.sleep(100);
}

@Override
public void RunComplete() throws Exception {

}
});
ThreadManager.Get().StartLong("TCP客户端消息处理", true, new IThread() {
@Override
public void Run() throws Exception {
while (msg.size()>0){
String res = msg.poll();

ReceiveData rd = new Gson().fromJson(res, ReceiveData.class);

if(rd.goods!=null){
rd.goods.forEach(item->{
if(QueryDB.GetGoodsIDIs(item.id))QueryDB.UpdateGoods(item);
else QueryDB.AddGoods(item);
});
}

if(rd.material!=null){
rd.material.forEach(item->{
if(QueryDB.GetMaterialIs(item.id))QueryDB.UpdateMaterial(item);
else QueryDB.AddMaterial(item);
});
}

if(rd.goodsrecipes!=null){
// ArrayList<BPA_GOODSRECIPE> removeData = QueryDB.GetGoodsSrecipeALL();
// if(removeData!=null){
// removeData.forEach(remove->{QueryDB.DeleteGoodsSrecipe(remove);});
// IpAddress=ip;
// Port=port;
// new Thread(()->{
// MessageLog.ShowInfo("本地IP地址:"+getHostIP());
// MessageLog.ShowInfo("开始连接 TcpServie");
// CloseFlag=false;
// boolean ErrorFlag=false;
// while(socket==null||!socket.isConnected()){
// try{
// socket = new Socket(IpAddress,Port);
// if(CloseFlag)break;
// Thread.sleep(1000);
// }catch (Exception e){
// if(!ErrorFlag){
// MessageLog.ShowInfo("连接失败:"+e.getMessage());
// ErrorFlag=true;
// }
// }
// }
// if(CloseFlag)return;
// MessageLog.ShowInfo("TcpClient连接成功");
// ThreadManager.Get().StartLong("TCP客户端监听", true, new IThread() {
// @Override
// public void Run() throws Exception {
// if(CheckConnect()){
// try{
// if(socket.getInputStream().available()>0){
// byte[] buffer = new byte[socket.getInputStream().available()];
// int len = socket.getInputStream().read(buffer);
// String str = new String(buffer,"UTF-8");
// msg.add(str);
// MessageLog.ShowInfo("接收数据完成,接收长度:"+buffer.length);
// }
DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODSRECIPE.class,null);
rd.goodsrecipes.forEach(item->{
QueryDB.AddGoodsSrecipe(item);
});
}

if(rd.processes!=null){
rd.processes.forEach(item->{
if(QueryDB.GetProcessID(item.id)!=null)QueryDB.UpdateProcess(item);
else QueryDB.AddProcess(item);
});
}

if(rd.processModels!=null){
rd.processModels.forEach(item->{
if(QueryDB.GetProcessModelID(item.id)!=null)QueryDB.UpdateProcessModel(item);
else QueryDB.AddProcessModel(item);
});
}

// MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good");
}
Thread.sleep(1000);
}

@Override
public void RunComplete() throws Exception {

}
});

}).start();
// }catch (Exception e){MessageLog.ShowInfo("错误1:"+e.getMessage());}
// }
// Thread.sleep(100);
// }
//
// @Override
// public void RunComplete() throws Exception {
//
// }
// });
// ThreadManager.Get().StartLong("TCP客户端消息处理", true, new IThread() {
// @Override
// public void Run() throws Exception {
// while (msg.size()>0){
// String res = msg.poll();
//
// ReceiveData rd = new Gson().fromJson(res, ReceiveData.class);
//
// if(rd.goods!=null){
// rd.goods.forEach(item->{
// if(QueryDB.GetGoodsIDIs(item.id))QueryDB.UpdateGoods(item);
// else QueryDB.AddGoods(item);
// });
// }
//
// if(rd.material!=null){
// rd.material.forEach(item->{
// if(QueryDB.GetMaterialIs(item.id))QueryDB.UpdateMaterial(item);
// else QueryDB.AddMaterial(item);
// });
// }
//
// if(rd.goodsrecipes!=null){
//// ArrayList<BPA_GOODSRECIPE> removeData = QueryDB.GetGoodsSrecipeALL();
//// if(removeData!=null){
//// removeData.forEach(remove->{QueryDB.DeleteGoodsSrecipe(remove);});
//// }
// DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODSRECIPE.class,null);
// rd.goodsrecipes.forEach(item->{
// QueryDB.AddGoodsSrecipe(item);
// });
// }
//
// if(rd.processes!=null){
// rd.processes.forEach(item->{
// if(QueryDB.GetProcessID(item.id)!=null)QueryDB.UpdateProcess(item);
// else QueryDB.AddProcess(item);
// });
// }
//
// if(rd.processModels!=null){
// rd.processModels.forEach(item->{
// if(QueryDB.GetProcessModelID(item.id)!=null)QueryDB.UpdateProcessModel(item);
// else QueryDB.AddProcessModel(item);
// });
// }
//
//// MessageManager.getInstance().sendMessage(MessageName.ScGood, "Good");
// }
// Thread.sleep(1000);
// }
//
// @Override
// public void RunComplete() throws Exception {
//
// }
// });
//
// }).start();
}

public void Close(){


+ 153
- 0
app/src/main/java/com/bonait/bnframework/common/model/DeviceInfoBean.java View File

@@ -0,0 +1,153 @@
package com.bonait.bnframework.common.model;

/**
* @author: liup
* @description:
* @date: 2024/7/9 11:21.
*/
public class DeviceInfoBean {
private String id;
private String deviceName;
private String deviceTypeId;
private String orgId;
private String productId;
private String productName;
private String productCode;
private int autoKey;
private String productVersionId;
private String orgKey;
private String productVersionName;
private int technologyOrBom;
private String groupId;
private String stopId;
private String stopName;
private String address;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getDeviceName() {
return deviceName;
}

public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}

public String getDeviceTypeId() {
return deviceTypeId;
}

public void setDeviceTypeId(String deviceTypeId) {
this.deviceTypeId = deviceTypeId;
}

public String getOrgId() {
return orgId;
}

public void setOrgId(String orgId) {
this.orgId = orgId;
}

public String getProductId() {
return productId;
}

public void setProductId(String productId) {
this.productId = productId;
}

public String getProductName() {
return productName;
}

public void setProductName(String productName) {
this.productName = productName;
}

public String getProductCode() {
return productCode;
}

public void setProductCode(String productCode) {
this.productCode = productCode;
}

public int getAutoKey() {
return autoKey;
}

public void setAutoKey(int autoKey) {
this.autoKey = autoKey;
}

public String getProductVersionId() {
return productVersionId;
}

public void setProductVersionId(String productVersionId) {
this.productVersionId = productVersionId;
}

public String getOrgKey() {
return orgKey;
}

public void setOrgKey(String orgKey) {
this.orgKey = orgKey;
}

public String getProductVersionName() {
return productVersionName;
}

public void setProductVersionName(String productVersionName) {
this.productVersionName = productVersionName;
}

public int getTechnologyOrBom() {
return technologyOrBom;
}

public void setTechnologyOrBom(int technologyOrBom) {
this.technologyOrBom = technologyOrBom;
}

public String getGroupId() {
return groupId;
}

public void setGroupId(String groupId) {
this.groupId = groupId;
}

public String getStopId() {
return stopId;
}

public void setStopId(String stopId) {
this.stopId = stopId;
}

public String getStopName() {
return stopName;
}

public void setStopName(String stopName) {
this.stopName = stopName;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}
}

+ 29
- 0
app/src/main/java/com/bonait/bnframework/common/model/GoodsData.java View File

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

import java.util.List;

/**
* @author: liup
* @description:
* @date: 2024/7/9 11:19.
*/
public class GoodsData {
private List<GoodsClassifyBean> goodsInfoList;
private List<DeviceInfoBean> deviceInfo;

public List<GoodsClassifyBean> getGoodsInfoList() {
return goodsInfoList;
}

public void setGoodsInfoList(List<GoodsClassifyBean> goodsInfoList) {
this.goodsInfoList = goodsInfoList;
}

public List<DeviceInfoBean> getDeviceInfo() {
return deviceInfo;
}

public void setDeviceInfo(List<DeviceInfoBean> deviceInfo) {
this.deviceInfo = deviceInfo;
}
}

+ 85
- 0
app/src/main/java/com/bonait/bnframework/common/model/upload/GoodsDataInfo.java View File

@@ -0,0 +1,85 @@
package com.bonait.bnframework.common.model.upload;

import java.io.Serializable;

/**
* @author: liup
* @description:
* @date: 2024/7/25 15:58.
*/
public class GoodsDataInfo implements Serializable {

private String name;
private String descritption;
private String imgUrl;
private int price;
private boolean isWeigh;
private String goodsTypeName;
private String goodsUintName;

public GoodsDataInfo(String name, String descritption, String imgUrl, int price, boolean isWeigh, String goodsTypeName, String goodsUintName) {
this.name = name;
this.descritption = descritption;
this.imgUrl = imgUrl;
this.price = price;
this.isWeigh = isWeigh;
this.goodsTypeName = goodsTypeName;
this.goodsUintName = goodsUintName;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDescritption() {
return descritption;
}

public void setDescritption(String descritption) {
this.descritption = descritption;
}

public String getImgUrl() {
return imgUrl;
}

public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}

public int getPrice() {
return price;
}

public void setPrice(int price) {
this.price = price;
}

public boolean isWeigh() {
return isWeigh;
}

public void setWeigh(boolean weigh) {
isWeigh = weigh;
}

public String getGoodsTypeName() {
return goodsTypeName;
}

public void setGoodsTypeName(String goodsTypeName) {
this.goodsTypeName = goodsTypeName;
}

public String getGoodsUintName() {
return goodsUintName;
}

public void setGoodsUintName(String goodsUintName) {
this.goodsUintName = goodsUintName;
}
}

+ 52
- 0
app/src/main/java/com/bonait/bnframework/common/model/upload/MaterialDataInfo.java View File

@@ -0,0 +1,52 @@
package com.bonait.bnframework.common.model.upload;

/**
* @author: liup
* @description:
* @date: 2024/7/25 15:55.
*/
public class MaterialDataInfo {
private String code;
private String name;
private String typeName;
private String uintName;

public MaterialDataInfo(String code,String name,String typeName,String uintName){
this.code = code;
this.name = name;
this.typeName = typeName;
this.uintName = uintName;
}

public String getCode() {
return code;
}

public void setCode(String code) {
this.code = code;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getTypeName() {
return typeName;
}

public void setTypeName(String typeName) {
this.typeName = typeName;
}

public String getUintName() {
return uintName;
}

public void setUintName(String uintName) {
this.uintName = uintName;
}
}

+ 67
- 0
app/src/main/java/com/bonait/bnframework/common/model/upload/UpAttributeBean.java View File

@@ -0,0 +1,67 @@
package com.bonait.bnframework.common.model.upload;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
* @author: liup
* @description:
* @date: 2024/7/25 16:28.
*/
public class UpAttributeBean implements Serializable {

public String attributeName;
public String goodsTypeName;
public List<GoodsAttributeValueBean> goodsAttributeValue = new ArrayList<>();

public String getAttributeName() {
return attributeName;
}

public void setAttributeName(String attributeName) {
this.attributeName = attributeName;
}

public String getGoodsTypeName() {
return goodsTypeName;
}

public void setGoodsTypeName(String goodsTypeName) {
this.goodsTypeName = goodsTypeName;
}

public List<GoodsAttributeValueBean> getGoodsAttributeValue() {
return goodsAttributeValue;
}

public void setGoodsAttributeValue(List<GoodsAttributeValueBean> goodsAttributeValue) {
this.goodsAttributeValue = goodsAttributeValue;
}

public static class GoodsAttributeValueBean implements Serializable {
private String attributeValue;
private int sort;

public GoodsAttributeValueBean(String attributeValue, int sort) {
this.attributeValue = attributeValue;
this.sort = sort;
}

public String getAttributeValue() {
return attributeValue;
}

public void setAttributeValue(String attributeValue) {
this.attributeValue = attributeValue;
}

public int getSort() {
return sort;
}

public void setSort(int sort) {
this.sort = sort;
}
}
}

+ 60
- 0
app/src/main/java/com/bonait/bnframework/common/model/upload/UpBaseBean.java View File

@@ -0,0 +1,60 @@
package com.bonait.bnframework.common.model.upload;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
* @author: liup
* @description:
* @date: 2024/7/25 15:35.
*/
public class UpBaseBean<T> implements Serializable {

public boolean isPush;
public String callbackUrl;
public List<String> storeIdList = new ArrayList<>() ;
public List<String> deviceIdList = new ArrayList<>();
public List<T> dataInfo = new ArrayList<>();

public boolean isPush() {
return isPush;
}

public void setPush(boolean push) {
isPush = push;
}

public String getCallbackUrl() {
return callbackUrl;
}

public void setCallbackUrl(String callbackUrl) {
this.callbackUrl = callbackUrl;
}

public List<String> getStoreIdList() {
return storeIdList;
}

public void setStoreIdList(ArrayList storeIdList) {
this.storeIdList = storeIdList;
}

public List<String> getDeviceIdList() {
return deviceIdList;
}

public void setDeviceIdList(List<String> deviceIdList) {
this.deviceIdList = deviceIdList;
}

public List<T> getDataInfo() {
return dataInfo;
}

public void setDataInfo(List<T> dataInfo) {
this.dataInfo = dataInfo;
}

}

+ 38
- 0
app/src/main/java/com/bonait/bnframework/common/model/upload/UpClassifyBean.java View File

@@ -0,0 +1,38 @@
package com.bonait.bnframework.common.model.upload;

import java.io.Serializable;

/**
* @author: liup
* @description:
* @date: 2024/7/25 16:57.
*/
public class UpClassifyBean implements Serializable {
public String pid;
public String name;
public int sort;

public String getPid() {
return pid;
}

public void setPid(String pid) {
this.pid = pid;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getSort() {
return sort;
}

public void setSort(int sort) {
this.sort = sort;
}
}

+ 66
- 0
app/src/main/java/com/bonait/bnframework/common/model/upload/UploadRes.java View File

@@ -0,0 +1,66 @@
package com.bonait.bnframework.common.model.upload;

import java.io.Serializable;

/**
* @author: liup
* @description:
* @date: 2024/7/25 15:21.
*/
public class UploadRes implements Serializable {

private int statusCode;
private boolean data;
private boolean succeeded;
private String errors;
private String extras;
private int timestamp;

public int getStatusCode() {
return statusCode;
}

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

public boolean isData() {
return data;
}

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

public boolean isSucceeded() {
return succeeded;
}

public void setSucceeded(boolean 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
- 8
app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java View File

@@ -185,7 +185,7 @@ public class BottomNavigationNewActivity extends BaseActivity {
String groupId = (String) msg;
goodsGroup = SubAttributeGroupDBUtil.getById(groupId);
goods = QueryDB.GetGoodsId(goodsGroup.goodsId);
cooking.initData(goods, activity, myClickListener);
cooking.initData(goodsGroup, activity, myClickListener);
cooking.setVisibility(View.VISIBLE);
}
});
@@ -446,9 +446,8 @@ public class BottomNavigationNewActivity extends BaseActivity {

if (!ExecuteTheRecipe.IsForcedEnd) {
int ztime = time - ExecuteTheRecipe.HandTime;
//todo maketime
// goods.maketime = ztime > 0 ? ztime : time;
// QueryDB.UpdateGoodsMakeTime(goods.id, goods.maketime);
goodsGroup.maketime = ztime > 0 ? ztime : time;
SubAttributeGroupDBUtil.updateMakeTime(goodsGroup.id,goodsGroup.maketime);
}
ExecuteTheRecipe.HandTime = 0;//默认将手动操作时间复位

@@ -683,8 +682,7 @@ public class BottomNavigationNewActivity extends BaseActivity {
if (goodsGroup != null) {
cooking.SetReset();
cooking.SetZanTing(true);
// int time = goods.maketime;
int time = 60*3;
int time = goodsGroup.maketime;
SetProcess(time, 0);
if (countDownTimer == null) {
countDownTimer = new CountDownTimerExt(time * 1000, 1000) {
@@ -712,8 +710,7 @@ public class BottomNavigationNewActivity extends BaseActivity {
if (goodsGroup != null) {
cooking.SetReset();
cooking.SetRest1();
// SetProcess(goods.maketime, 0);
SetProcess(60*3, 0);
SetProcess(goodsGroup.maketime, 0);

if (countDownTimer != null) {
countDownTimer.stop();


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

@@ -68,6 +68,7 @@ import com.bonait.bnframework.modules.home.fragment.mode.LocationStatus;
import com.bonait.bnframework.modules.home.fragment.mode.MyStatus;
import com.bonait.bnframework.modules.home.fragment.mode.huoli_control;
import com.bonait.bnframework.modules.home.fragment.mode.imagebutton_control;
import com.bonait.bnframework.ui.activity.EditGoodsActivity;
import com.capton.colorfulprogressbar.ColorfulProgressbar;
import com.litao.slider.NiftySlider;
import com.litao.slider.SliderEffect;
@@ -258,10 +259,10 @@ public class Home1Fragment extends BaseFragment {
return;
}
gongxumiaoshu.setText("等待开始");
BPA_GOODS_SUBATTRIBUTE_GROUP goodsGroup = (BPA_GOODS_SUBATTRIBUTE_GROUP)data;
good = GoodsDBUtil.getById(goodsGroup.goodsId);
goodGroup = (BPA_GOODS_SUBATTRIBUTE_GROUP)data;
good = GoodsDBUtil.getById(goodGroup.goodsId);
SetBottonStatus(false);
caipumingcheng.setText(good.name);
caipumingcheng.setText(good.name+"-"+goodGroup.name);
// SetProcesssUI(good.maketime, 0);
}
});
@@ -567,9 +568,9 @@ public class Home1Fragment extends BaseFragment {
}

int gongxuIndex = 10000;
ArrayList<BPA_GOODSRECIPE> goodsrecipesL = null;
ArrayList<BPA_GOODS_PROCESS_DETAIL> goodsrecipesL = null;

BPA_GOODSRECIPE MakeCipe = null;
BPA_GOODS_PROCESS_DETAIL MakeCipe = null;

public Thread makeThread = null;
public Thread makeThreadDC = null;
@@ -596,8 +597,7 @@ public class Home1Fragment extends BaseFragment {

try {
//获取工艺
ArrayList<BPA_GOODS_PROCESS_DETAIL> goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id);
ArrayList<BPA_GOODS_PROCESS_DETAIL> goodsrecipes = GoodsProcessDetailDBUtil.getByGroupId(goods)
ArrayList<BPA_GOODS_PROCESS_DETAIL> goodsrecipes = GoodsProcessDetailDBUtil.getByGroupId(goodGroup.id);
goodsrecipesL = goodsrecipes;
gongxuIndex = 1;
int m = 0;
@@ -634,9 +634,8 @@ public class Home1Fragment extends BaseFragment {

if (!ExecuteTheRecipe.IsForcedEnd) {
int ztime = time - ExecuteTheRecipe.HandTime;
//todo good.maketime
// good.maketime = ztime > 0 ? ztime : time;
// QueryDB.UpdateGoodsMakeTime(good.id, good.maketime);
goodGroup.maketime = ztime > 0 ? ztime : time;
SubAttributeGroupDBUtil.updateMakeTime(goodGroup.id,goodGroup.maketime);
}
ExecuteTheRecipe.HandTime = 0;//默认将手动操作时间复位

@@ -653,7 +652,7 @@ public class Home1Fragment extends BaseFragment {
ToastUtils.info("客官,当前菜品已强制结束!!!");
//初始化
// ExecuteTheRecipe.BottomClick("初始化");
ExecuteTheRecipe.showlog("菜谱【" + good.name + "】已强制结束...");
ExecuteTheRecipe.showlog("菜谱【" + good.name +"-"+goodGroup.name+ "】已强制结束...");
if (ConfigName.getInstance().versionSelectionEnum.contains("一拖"))//通知任务结束
{
ExecuteTheRecipe.WriteMainPLC("强制结束任务完成", true, null);//复位
@@ -687,9 +686,9 @@ public class Home1Fragment extends BaseFragment {
if (ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本") || ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) {
//获取工艺
int k = 1;
ArrayList<BPA_GOODSRECIPE> goodsrecipes = goodsrecipesL;
BPA_GOODSRECIPE recipe = null;
for (BPA_GOODSRECIPE item : goodsrecipes) {
ArrayList<BPA_GOODS_PROCESS_DETAIL> goodsrecipes = goodsrecipesL;
BPA_GOODS_PROCESS_DETAIL recipe = null;
for (BPA_GOODS_PROCESS_DETAIL item : goodsrecipes) {
k++;
if (k > gongxuIndex) {
if (item.processname.contains("主料") && !MakeCipe.processname.equals("主料") && recipe == null) {
@@ -955,7 +954,7 @@ public class Home1Fragment extends BaseFragment {
ExecuteTheRecipe.MakeStatus = status;
if (status) {
startbutton.setImageResource(R.mipmap.tzzz);
// TimerCount(good.maketime, true);//开始计时器,记录进度条
TimerCount(goodGroup.maketime, true);//开始计时器,记录进度条
gongxumiaoshu.setText("等待开始");
} else {
startbutton.setImageResource(R.mipmap.qdzz);
@@ -963,7 +962,7 @@ public class Home1Fragment extends BaseFragment {
gongxumiaoshu.setText("等待开始");
}
if (good != null) {
// SetProcesssUI(good.maketime, 0);
SetProcesssUI(goodGroup.maketime, 0);
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
@@ -1034,7 +1033,7 @@ public class Home1Fragment extends BaseFragment {
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.xzcp://选择菜谱按钮点击
skipToActivity(CpxzActivity.class);
skipToActivity(EditGoodsActivity.class);
ToastUtils.info("打开菜谱选择界面");
break;
case R.id.startbutton:
@@ -1058,13 +1057,13 @@ public class Home1Fragment extends BaseFragment {
return;
}

if (!ConfigName.getInstance().PlcIsConnect) {
if (!ConfigName.getInstance().PlcIsConnect && !ConfigName.isTEST) {
ToastUtils.warning("PLC未准备就绪!!!");
return;
}

Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成");
if (chushiover == null || !(boolean) chushiover) {
if ((chushiover == null || !(boolean) chushiover) && !ConfigName.isTEST) {
ToastUtils.warning("设备未初始化,请先手动初始化设备!!!");
return;
}
@@ -1209,14 +1208,14 @@ public class Home1Fragment extends BaseFragment {
* @return
*/
public boolean IsMake(boolean k) {
if (!ConfigName.getInstance().PlcIsConnect) {
if (!ConfigName.getInstance().PlcIsConnect && !ConfigName.isTEST) {
ToastUtils.warning("PLC未准备就绪!!!");
return false;
}

Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成");
//Object jiting = ExecuteTheRecipe.getListingValue("设备急停");
if (chushiover == null || !(boolean) chushiover) {
if ((chushiover == null || !(boolean) chushiover) && !ConfigName.isTEST) {
ToastUtils.warning("设备未初始化,请先手动初始化设备!!!");
return false;
}


+ 7
- 18
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CookingActivity.java View File

@@ -33,6 +33,7 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_SILOS;
import com.bonait.bnframework.common.db.res.lcMode;
import com.bonait.bnframework.common.db.util.GoodsDBUtil;
import com.bonait.bnframework.common.helper.CountDownTimerExt;
import com.bonait.bnframework.common.helper.I.IRunT;
import com.bonait.bnframework.common.helper.I.MyClickListener;
@@ -130,16 +131,6 @@ public class CookingActivity extends LinearLayout {

public Activity activity = null;

/**
* 商品id
*/
private String goodId = "";
/**
* 子属性组合id 属性组合名称
*/
private String subAttributeGroupId = "";
private String subAttributeGroupName = "";
private BPA_GOODS_SUBATTRIBUTE_GROUP goodsSubattributeGroup;
//endregion

//region 界面实例
@@ -159,7 +150,8 @@ public class CookingActivity extends LinearLayout {
/**
* 初始化数据
*/
public void initData(BPA_GOODS goods, Activity ac, MyClickListener listener) {
public void initData(BPA_GOODS_SUBATTRIBUTE_GROUP goodsGroup, Activity ac, MyClickListener listener) {
BPA_GOODS good = GoodsDBUtil.getById(goodsGroup.goodsId);
//根据商品id查询
activity = ac;

@@ -175,7 +167,7 @@ public class CookingActivity extends LinearLayout {
yeliao4.setTag(ConfigName.getInstance().SilosDisplayMaterial.get(4)+"");
yeliao4.Init();

ConcurrentHashMap<Integer,String> resultData= DataBus.getInstance().GetMainDisplayText(goods.id);
ConcurrentHashMap<Integer,String> resultData= DataBus.getInstance().GetMainDisplayText(goodsGroup.id);
touliao1.setTag(resultData.get(1)+"-按钮");
touliao1.Init();

@@ -188,17 +180,14 @@ public class CookingActivity extends LinearLayout {
touliao4.setTag(resultData.get(4)+"-按钮");
touliao4.Init();

goodname.setText(goods.name + "");
goodname.setText(good.name + "-"+goodsGroup.name);
start_goodmake.mListener = listener;
zanting_goodmake.mListener = listener;
SetReset();
SetRest1();
//todo maketime
SetProcess(60*3, 0);
// SetProcess(goods.maketime, 0);
SetProcess(goodsGroup.maketime, 0);
SetMiaoShu("等待开始...");
runtime.setText(formatTime(60*3));
// runtime.setText(formatTime(goods.maketime));
runtime.setText(formatTime(goodsGroup.maketime));

if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本") || ConfigName.getInstance().versionSelectionEnum.contains("一拖")) {
touliao_k.setVisibility(View.GONE);


+ 2
- 2
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_qupenren.java View File

@@ -146,14 +146,14 @@ public class add_qupenren extends LinearLayout {
quzhizuo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (!ConfigName.getInstance().PlcIsConnect) {
if (!ConfigName.getInstance().PlcIsConnect && !ConfigName.isTEST) {
ToastUtils.warning("PLC未准备就绪!!!");
return;
}

Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成");
//Object jiting = ExecuteTheRecipe.getListingValue("设备急停");
if (chushiover == null || !(boolean) chushiover) {
if ((chushiover == null || !(boolean) chushiover)&& !ConfigName.isTEST ) {
ToastUtils.warning("设备未初始化,请先手动初始化设备!!!");
return;
}


+ 2
- 2
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebuttom.java View File

@@ -98,13 +98,13 @@ public class imagebuttom extends LinearLayout {

}else
{
if (!ConfigName.getInstance().PlcIsConnect) {
if (!ConfigName.getInstance().PlcIsConnect && !ConfigName.isTEST) {
ToastUtils.warning("PLC未准备就绪!!!");
return;
}

Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成");
if (chushiover == null || !(boolean) chushiover) {
if ((chushiover == null || !(boolean) chushiover) && !ConfigName.isTEST) {
ToastUtils.warning("设备未初始化,请先手动初始化设备!!!");
return;
}


+ 1
- 1
app/src/main/java/com/bonait/bnframework/ui/dialog/AttributeSelectDialog.java View File

@@ -41,7 +41,7 @@ import java.util.List;

/**
* @author: liup
* @description:
* @description: 选择属性组合
* @date: 2024/5/17 13:42.
*/
public class AttributeSelectDialog extends DialogFragment {


+ 18
- 8
app/src/main/java/com/bonait/bnframework/ui/dialog/EditGoodsDialog.java View File

@@ -24,6 +24,8 @@ import com.apkfuns.logutils.LogUtils;
import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.business.RecordManager;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
@@ -41,6 +43,8 @@ import com.bonait.bnframework.databinding.DialogEditGoodsBinding;
import com.bonait.bnframework.event.FreshLocalGoodPicEvent;
import com.bonait.bnframework.event.ImageSelectEvent;
import com.bonait.bnframework.glide.GlideUtil;
import com.bonait.bnframework.modules.home.activity.BottomNavigation2Activity;
import com.bonait.bnframework.modules.home.activity.BottomNavigationNewActivity;
import com.bonait.bnframework.modules.home.fragment.from.CookingActivity;
import com.bonait.bnframework.modules.home.fragment.from.ImageChooseActivity;
import com.bonait.bnframework.ui.activity.DiyProcessActivity;
@@ -466,17 +470,23 @@ public class EditGoodsDialog extends DialogFragment {
*/
private void jumpToCook(){
LogUtils.d(" jumpToCook subAttributeGroupName="+subattributeGroup.name+";subAttributeGroupId="+subattributeGroup.id+";goodI="+goodId);
// Intent intent = new Intent(getContext(), CookingActivity.class);
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// intent.putExtra("subAttributeGroupId",subattributeGroup.id);
// intent.putExtra("isTest",false);
// intent.putExtra("subAttributeGroupName",subattributeGroup.name);
// intent.putExtra("goodId",goodId);
// startActivity(intent);
LogUtils.d(" jumpToCook user="+ConfigName.getInstance().user.name+"-"+ConfigName.getInstance().user.account);
if(ConfigName.getInstance().user.account.equals("admin")){
DataBus.getInstance().mListener.clickListener(null, subattributeGroup);
Intent intent = new Intent(getContext(), BottomNavigation2Activity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}else{
MessageManager.getInstance().sendMessage(MessageName.OpenMakeGoodFrom, subattributeGroup.id);
Intent intent = new Intent(getContext(), BottomNavigationNewActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}

if (ExecuteTheRecipe.IsStart) {
ToastUtils.warning("请耐心等待商品制作结束!!!");
} else {
MessageManager.getInstance().sendMessage(MessageName.OpenMakeGoodFrom, subattributeGroup.id);
dismiss();
}



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

@@ -197,6 +197,7 @@ public class CloudGoodsFragment extends BaseFragment {
for (GoodsClassifyBean bean : Objects.requireNonNull(viewModel.cloudGoodsList.getValue())){
BPA_GOODS_CLASSIFY goodsClassify = new BPA_GOODS_CLASSIFY();
goodsClassify.id = bean.getGoodsTypeId();
LogUtils.d("dealClassifyData goodsId="+bean.getGoodsTypeId());
goodsClassify.name = bean.getGoodsTypeName();
classifyList.add(goodsClassify);
}
@@ -209,6 +210,7 @@ public class CloudGoodsFragment extends BaseFragment {
goodsList.clear();
if(!classifyList.isEmpty()){
String goodsId = classifyList.get(position).id;
LogUtils.d("dealGoodsData goodsId="+goodsId+";classifyList.size="+classifyList.size());
if(viewModel.cloudGoodsList.getValue()!=null){
for (GoodsClassifyBean bean : viewModel.cloudGoodsList.getValue()){
if(goodsId.equals(bean.getGoodsTypeId())){


+ 3
- 2
app/src/main/java/com/bonait/bnframework/ui/viewmodel/HomeGoodsViewModel.java View File

@@ -29,6 +29,7 @@ import com.bonait.bnframework.common.db.util.MaterialUtil;
import com.bonait.bnframework.common.db.util.SubAttributeDBUtil;
import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil;
import com.bonait.bnframework.common.model.GoodsClassifyBean;
import com.bonait.bnframework.common.model.GoodsData;
import com.bonait.bnframework.common.model.MaterialData;
import com.bonait.bnframework.common.model.MaterialRequestPar;
import com.bonait.bnframework.common.thread.ThreadManager;
@@ -88,13 +89,13 @@ public class HomeGoodsViewModel extends ViewModel {
String url = "https://cfv.black-pa.com/kitchbase/api/goods/Getdevicegoods?deviceId=257";
LogUtils.d("GetGoodsInfo url="+url);
RecordManager.getInstance().addLogRecord("数据接收", "请求商品信息-"+url);
APIHelper.PostT(url,null,null,new TypeReference<APIResultT<List<GoodsClassifyBean>>>(){}).OnSource(s->{
APIHelper.PostT(url,null,null,new TypeReference<APIResultT<GoodsData>>(){}).OnSource(s->{
LogUtils.d("GetGoodsInfo s.Content="+s.Content);
RecordManager.getInstance().addLogRecord("数据接收", "接收商品信息成功");
runOnUiThread(new Runnable() {
@Override
public void run() {
cloudGoodsList.setValue(s.Content);
cloudGoodsList.setValue(s.Content.getGoodsInfoList());
}
});
hasData = true;


+ 292
- 0
app/src/main/java/com/bonait/bnframework/ui/viewmodel/UpdateAllDataService.java View File

@@ -0,0 +1,292 @@
package com.bonait.bnframework.ui.viewmodel;

import com.bonait.bnframework.MainApplication;
import com.bonait.bnframework.common.API.APIHelper;
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;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_SUBATTRIBUTE;
import com.bonait.bnframework.common.db.util.AttributeDBUtil;
import com.bonait.bnframework.common.db.util.GoodsClassifyDBUtil;
import com.bonait.bnframework.common.db.util.GoodsDBUtil;
import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil;
import com.bonait.bnframework.common.db.util.MaterialUtil;
import com.bonait.bnframework.common.db.util.SubAttributeDBUtil;
import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil;
import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback;
import com.bonait.bnframework.common.model.upload.GoodsDataInfo;
import com.bonait.bnframework.common.model.upload.MaterialDataInfo;
import com.bonait.bnframework.common.model.upload.UpAttributeBean;
import com.bonait.bnframework.common.model.upload.UpBaseBean;
import com.bonait.bnframework.common.model.upload.UpClassifyBean;
import com.bonait.bnframework.common.model.upload.UploadRes;
import com.bonait.bnframework.common.utils.NetworkUtils;
import com.bonait.bnframework.ui.widget.NewToastUtil;
import com.bonait.bnframework.ui.widget.WaitProcessUtil;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpHeaders;
import com.lzy.okgo.model.Response;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
* @author: liup
* @description:
* @date: 2024/7/25 14:55.
*/
public class UpdateAllDataService {
private String path = "";
private String key = "";

public void startUpLoadAll(){
if(ConfigName.getInstance().isFast2Click()){
NewToastUtil.getInstance().showToast("点击太快了");
return;
}
if (NetworkUtils.checkNetworkAvailable(MainApplication.getContext())) {
try{

upLoadMaterial();
}catch (Exception e){
NewToastUtil.getInstance().showToastError("异常 "+e.getMessage());
}finally {

}
}else {
NewToastUtil.getInstance().showToast("无网络,请先连接网络");
}
}


private void upLoadMaterial(){
WaitProcessUtil.getInstance().show("数据上传","正在上传物料信息,请耐心稍等...");
List<BPA_MATERIAL> materials = MaterialUtil.GetMaterialALL();

UpBaseBean<MaterialDataInfo> upMaterialBean = new UpBaseBean<>();
upMaterialBean.isPush = true;
upMaterialBean.callbackUrl = "";
upMaterialBean.storeIdList = new ArrayList<>();
upMaterialBean.deviceIdList = new ArrayList<>();

for(BPA_MATERIAL material:materials){
upMaterialBean.dataInfo.add(new MaterialDataInfo(material.id,material.name,"液体料",""));
}

HttpHeaders headers = new HttpHeaders();
headers.put("key", key);
headers.put("sign", APIHelper.GetSign("",key));
OkGo.<UploadRes>post("http://"+path+"/api/ExternalPlatform/Material/AddMaterial")
.tag(MainApplication.getContext())
.upRequestBody(
RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(upMaterialBean)))
.headers(headers)
.execute(new JsonDialogCallback<UploadRes>(MainApplication.getContext()) {
@Override
public void onSuccess(Response<UploadRes> response) {
NewToastUtil.getInstance().showToast("上传物料信息成功");
upLoadClassifyInfo();
}

@Override
public void onError(Response<UploadRes> response) {
super.onError(response);
NewToastUtil.getInstance().showToastError("上传物料信息失败 "+response.message());
WaitProcessUtil.getInstance().dismiss();
}
});
}

private void upLoadClassifyInfo(){
WaitProcessUtil.getInstance().show("数据上传","正在上传所有分类信息,请耐心稍等...");
List<BPA_GOODS_CLASSIFY> classifys = GoodsClassifyDBUtil.getAll();
if(classifys.isEmpty()){
WaitProcessUtil.getInstance().dismiss();
return;
}

List<UpClassifyBean> upClassifyBeans = new ArrayList<>();

for(int i=0;i<classifys.size();i++){
UpClassifyBean upClassifyBean = new UpClassifyBean();
upClassifyBean.pid = "0";
upClassifyBean.name = classifys.get(i).name;
upClassifyBean.sort = 0;
upClassifyBeans.add(upClassifyBean);
}

HttpHeaders headers = new HttpHeaders();
headers.put("key", key);
headers.put("sign", APIHelper.GetSign("",key));
OkGo.<UploadRes>post("http://"+path+"/api/ExternalPlatform/Goods/AddGoodsType")
.tag(MainApplication.getContext())
.upRequestBody(
RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(upClassifyBeans)))
.headers(headers)
.execute(new JsonDialogCallback<UploadRes>(MainApplication.getContext()) {
@Override
public void onSuccess(Response<UploadRes> response) {
NewToastUtil.getInstance().showToast("上传分类信息成功");
upLoadAttribute();
}

@Override
public void onError(Response<UploadRes> response) {
super.onError(response);
WaitProcessUtil.getInstance().dismiss();
NewToastUtil.getInstance().showToastError("上传分类信息失败 "+response.message());
}
});
}

private void upLoadAttribute(){
WaitProcessUtil.getInstance().show("数据上传","正在上传所有分类属性,请耐心稍等...");
List<BPA_GOODS_CLASSIFY> classifys = GoodsClassifyDBUtil.getAll();
List<UpAttributeBean> upAttributeBeans = new ArrayList<>();
for(BPA_GOODS_CLASSIFY classify1:classifys){
List<BPA_ATTRIBUTE> attributes = AttributeDBUtil.getByClassify(classify1.id);
for(BPA_ATTRIBUTE bean:attributes){
UpAttributeBean upAttributeBean = new UpAttributeBean();
upAttributeBean.setAttributeName(bean.name);
upAttributeBean.setGoodsTypeName(classify1.name);
List<BPA_SUBATTRIBUTE> subattributes = SubAttributeDBUtil.getByParentAttributeId(bean.id);
for(BPA_SUBATTRIBUTE subattribute:subattributes){
upAttributeBean.goodsAttributeValue.add(new UpAttributeBean.GoodsAttributeValueBean(subattribute.name,subattribute.sort));
}
upAttributeBeans.add(upAttributeBean);
}
}

HttpHeaders headers = new HttpHeaders();
headers.put("key", key);
headers.put("sign", APIHelper.GetSign("",key));
OkGo.<UploadRes>post("http://"+path+"/api/ExternalPlatform/Goods/AddGoodsAttribute")
.tag(MainApplication.getContext())
.upRequestBody(
RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(upAttributeBeans)))
.headers(headers)
.execute(new JsonDialogCallback<UploadRes>(MainApplication.getContext()) {
@Override
public void onSuccess(Response<UploadRes> response) {
NewToastUtil.getInstance().showToast("上传分类属性信息成功");
upLoadGoodsInfo();
}

@Override
public void onError(Response<UploadRes> response) {
super.onError(response);
NewToastUtil.getInstance().showToastError("上传分类属性信息失败 "+response.message());
WaitProcessUtil.getInstance().dismiss();
}
});
}

private void upLoadGoodsInfo(){
WaitProcessUtil.getInstance().show("数据上传","正在上传所有商品信息,请耐心稍等...");
List<BPA_GOODS> goods = GoodsDBUtil.getAll();
UpBaseBean<GoodsDataInfo> upMaterialBean = new UpBaseBean<>();
upMaterialBean.isPush = true;
upMaterialBean.callbackUrl = "";
upMaterialBean.storeIdList = new ArrayList<>();
upMaterialBean.deviceIdList = new ArrayList<>();

for(BPA_GOODS good : goods){
BPA_GOODS_CLASSIFY classify = GoodsClassifyDBUtil.getById(good.classifyId);
if(classify!=null){
upMaterialBean.dataInfo.add(new GoodsDataInfo(good.name,"",good.url,0,false,classify.name,""));
}
}

HttpHeaders headers = new HttpHeaders();
headers.put("key", key);
headers.put("sign", APIHelper.GetSign("",key));
OkGo.<UploadRes>post("http://"+path+"/api/ExternalPlatform/Goods/AddGoods")
.tag(MainApplication.getContext())
.upRequestBody(
RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(upMaterialBean)))
.headers(headers)
.execute(new JsonDialogCallback<UploadRes>(MainApplication.getContext()) {
@Override
public void onSuccess(Response<UploadRes> response) {
NewToastUtil.getInstance().showToast("上传商品基础信息成功");
upLoadDetailInfo();
}

@Override
public void onError(Response<UploadRes> response) {
super.onError(response);
NewToastUtil.getInstance().showToastError("上传商品基础信息失败 "+response.message());
WaitProcessUtil.getInstance().dismiss();
}
});
}

private void upLoadDetailInfo(){
WaitProcessUtil.getInstance().show("数据上传","正在上传工艺信息,请耐心稍等...");
List<BPA_GOODS> goodsList = GoodsDBUtil.getAll();
for(BPA_GOODS goods:goodsList){
List<BPA_GOODS_SUBATTRIBUTE_GROUP> groups = SubAttributeGroupDBUtil.getByGoodsId(goods.id);
List<BPA_GOODS_PROCESS_DETAIL> goodsProcessDetails = new ArrayList<>();
for(BPA_GOODS_SUBATTRIBUTE_GROUP group:groups){
goodsProcessDetails.addAll(GoodsProcessDetailDBUtil.getByGroupId(group.id));
}
for(BPA_GOODS_PROCESS_DETAIL bean : goodsProcessDetails){
List<String> data = new ArrayList<>();
if (bean.processvalue.contains("|")) {
String[] res = bean.processvalue.split("[|]");
data.addAll(Arrays.asList(res));
} else {
data.add(bean.processvalue);
}
for (String item : data) {
if (item.contains(",")) {
String[] wl = item.split("[,]");
if (wl.length == 2) {
String name = wl[0];
String val = wl[1];

}
}
}
}
String actionJson = "";
}


// HttpHeaders headers = new HttpHeaders();
// headers.put("key", key);
// headers.put("sign", APIHelper.GetSign("",key));
// OkGo.<UploadRes>post("http://"+path+"/api/ExternalPlatform/Goods/AddGoods")
// .tag(MainApplication.getContext())
// .upRequestBody(
// RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
// new Gson().toJson(upMaterialBean)))
// .headers(headers)
// .execute(new JsonDialogCallback<UploadRes>(MainApplication.getContext()) {
// @Override
// public void onSuccess(Response<UploadRes> response) {
//
// }
//
// @Override
// public void onError(Response<UploadRes> response) {
// super.onError(response);
// NewToastUtil.getInstance().showToastError("上传商品工艺失败 "+response.message());
// }
// });
WaitProcessUtil.getInstance().dismiss();
}
}

+ 302
- 0
app/src/main/java/com/bonait/bnframework/ui/viewmodel/UpdateDataService.java View File

@@ -0,0 +1,302 @@
package com.bonait.bnframework.ui.viewmodel;

import com.bonait.bnframework.MainApplication;
import com.bonait.bnframework.common.API.APIHelper;
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;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_SUBATTRIBUTE;
import com.bonait.bnframework.common.db.util.AttributeDBUtil;
import com.bonait.bnframework.common.db.util.GoodsClassifyDBUtil;
import com.bonait.bnframework.common.db.util.GoodsDBUtil;
import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil;
import com.bonait.bnframework.common.db.util.MaterialUtil;
import com.bonait.bnframework.common.db.util.SubAttributeDBUtil;
import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil;
import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback;
import com.bonait.bnframework.common.model.upload.GoodsDataInfo;
import com.bonait.bnframework.common.model.upload.MaterialDataInfo;
import com.bonait.bnframework.common.model.upload.UpAttributeBean;
import com.bonait.bnframework.common.model.upload.UpBaseBean;
import com.bonait.bnframework.common.model.upload.UpClassifyBean;
import com.bonait.bnframework.common.model.upload.UploadRes;
import com.bonait.bnframework.common.utils.NetworkUtils;
import com.bonait.bnframework.ui.widget.NewToastUtil;
import com.bonait.bnframework.ui.widget.WaitProcessUtil;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpHeaders;
import com.lzy.okgo.model.Response;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
* @author: liup
* @description:
* @date: 2024/7/25 14:55.
*/
public class UpdateDataService {
private String path = "";
private String key = "";

public void startUpLoad(String goodsId){
if(ConfigName.getInstance().isFast2Click()){
NewToastUtil.getInstance().showToast("点击太快了");
return;
}
if (NetworkUtils.checkNetworkAvailable(MainApplication.getContext())) {
BPA_GOODS good = GoodsDBUtil.getById(goodsId);
if(good!=null){
//等待弹窗
try{
upLoadMaterial(goodsId);
}catch (Exception e){
NewToastUtil.getInstance().showToastError("异常 "+e.getMessage());
}finally {
}
}else {
NewToastUtil.getInstance().showToast("商品为空");
}
}else {
NewToastUtil.getInstance().showToast("无网络,请先连接网络");
}
}

private void upLoadMaterial(String goodsId){
WaitProcessUtil.getInstance().show("数据上传","正在上传所有分类信息,请耐心稍等...");
List<BPA_MATERIAL> materials = MaterialUtil.GetMaterialALL();

UpBaseBean<MaterialDataInfo> upMaterialBean = new UpBaseBean<>();
upMaterialBean.isPush = true;
upMaterialBean.callbackUrl = "";
upMaterialBean.storeIdList = new ArrayList<>();
upMaterialBean.deviceIdList = new ArrayList<>();

for(BPA_MATERIAL material:materials){
upMaterialBean.dataInfo.add(new MaterialDataInfo(material.id,material.name,"液体料",""));
}

HttpHeaders headers = new HttpHeaders();
headers.put("key", key);
headers.put("sign", APIHelper.GetSign("",key));
OkGo.<UploadRes>post("http://"+path+"/api/ExternalPlatform/Material/AddMaterial")
.tag(MainApplication.getContext())
.upRequestBody(
RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(upMaterialBean)))
.headers(headers)
.execute(new JsonDialogCallback<UploadRes>(MainApplication.getContext()) {
@Override
public void onSuccess(Response<UploadRes> response) {
NewToastUtil.getInstance().showToast("上传分类信息成功");
upLoadClassifyInfo(goodsId);
}

@Override
public void onError(Response<UploadRes> response) {
super.onError(response);
WaitProcessUtil.getInstance().dismiss();
NewToastUtil.getInstance().showToastError("上传物料信息失败 "+response.message());
}
});
}

private void upLoadClassifyInfo(String goodsId){
WaitProcessUtil.getInstance().show("数据上传","正在上传所有分类属性,请耐心稍等...");
BPA_GOODS goods = GoodsDBUtil.getById(goodsId);
assert goods != null;
BPA_GOODS_CLASSIFY classify = GoodsClassifyDBUtil.getById(goods.classifyId);
assert classify != null;

List<UpClassifyBean> upClassifyBeans = new ArrayList<>();
UpClassifyBean upClassifyBean = new UpClassifyBean();
upClassifyBean.pid = "0";
upClassifyBean.name = classify.name;
upClassifyBean.sort = 0;
upClassifyBeans.add(upClassifyBean);

HttpHeaders headers = new HttpHeaders();
headers.put("key", key);
headers.put("sign", APIHelper.GetSign("",key));
OkGo.<UploadRes>post("http://"+path+"/api/ExternalPlatform/Goods/AddGoodsType")
.tag(MainApplication.getContext())
.upRequestBody(
RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(upClassifyBeans)))
.headers(headers)
.execute(new JsonDialogCallback<UploadRes>(MainApplication.getContext()) {
@Override
public void onSuccess(Response<UploadRes> response) {
NewToastUtil.getInstance().showToast("上传分类属性信息成功");
List<BPA_ATTRIBUTE> attributes = AttributeDBUtil.getByClassify(classify.id);
if (!attributes.isEmpty()){
upLoadAttribute(attributes,goodsId);
}else {
upLoadGoodsInfo(goodsId);
}
}

@Override
public void onError(Response<UploadRes> response) {
super.onError(response);
NewToastUtil.getInstance().showToastError("上传分类信息失败 "+response.message());
WaitProcessUtil.getInstance().dismiss();
}
});
}

private void upLoadAttribute(List<BPA_ATTRIBUTE> attributes,String goodsId){
WaitProcessUtil.getInstance().show("数据上传","正在上传所有商品信息,请耐心稍等...");
BPA_GOODS goods = GoodsDBUtil.getById(goodsId);
assert goods != null;
BPA_GOODS_CLASSIFY classify = GoodsClassifyDBUtil.getById(goods.classifyId);
assert classify != null;

List<UpAttributeBean> upAttributeBeans = new ArrayList<>();
for(BPA_ATTRIBUTE bean:attributes){
UpAttributeBean upAttributeBean = new UpAttributeBean();
upAttributeBean.setAttributeName(bean.name);
upAttributeBean.setGoodsTypeName(classify.name);
List<BPA_SUBATTRIBUTE> subattributes = SubAttributeDBUtil.getByParentAttributeId(bean.id);
for(BPA_SUBATTRIBUTE subattribute:subattributes){
upAttributeBean.goodsAttributeValue.add(new UpAttributeBean.GoodsAttributeValueBean(subattribute.name,subattribute.sort));
}
upAttributeBeans.add(upAttributeBean);
}


HttpHeaders headers = new HttpHeaders();
headers.put("key", key);
headers.put("sign", APIHelper.GetSign("",key));
OkGo.<UploadRes>post("http://"+path+"/api/ExternalPlatform/Goods/AddGoodsAttribute")
.tag(MainApplication.getContext())
.upRequestBody(
RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(upAttributeBeans)))
.headers(headers)
.execute(new JsonDialogCallback<UploadRes>(MainApplication.getContext()) {
@Override
public void onSuccess(Response<UploadRes> response) {
upLoadGoodsInfo(goodsId);
}

@Override
public void onError(Response<UploadRes> response) {
super.onError(response);
NewToastUtil.getInstance().showToastError("上传分类属性信息失败 "+response.message());
}
});
}

private void upLoadGoodsInfo(String goodsId){
BPA_GOODS goods = GoodsDBUtil.getById(goodsId);
assert goods != null;
BPA_GOODS_CLASSIFY classify = GoodsClassifyDBUtil.getById(goods.classifyId);
assert classify != null;

UpBaseBean<GoodsDataInfo> upMaterialBean = new UpBaseBean<>();
upMaterialBean.isPush = true;
upMaterialBean.callbackUrl = "";
upMaterialBean.storeIdList = new ArrayList<>();
upMaterialBean.deviceIdList = new ArrayList<>();

upMaterialBean.dataInfo.add(new GoodsDataInfo(goods.name,"",goods.url,0,false,classify.name,""));

HttpHeaders headers = new HttpHeaders();
headers.put("key", key);
headers.put("sign", APIHelper.GetSign("",key));
OkGo.<UploadRes>post("http://"+path+"/api/ExternalPlatform/Goods/AddGoods")
.tag(MainApplication.getContext())
.upRequestBody(
RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
new Gson().toJson(upMaterialBean)))
.headers(headers)
.execute(new JsonDialogCallback<UploadRes>(MainApplication.getContext()) {
@Override
public void onSuccess(Response<UploadRes> response) {
NewToastUtil.getInstance().showToast("上传商品基础信息成功");
upLoadDetailInfo(goodsId);
}

@Override
public void onError(Response<UploadRes> response) {
super.onError(response);
NewToastUtil.getInstance().showToastError("上传商品基础信息失败 "+response.message());
WaitProcessUtil.getInstance().dismiss();
}
});
}

private void upLoadDetailInfo(String goodsId){
WaitProcessUtil.getInstance().show("数据上传","正在上传工艺信息,请耐心稍等...");
BPA_GOODS goods = GoodsDBUtil.getById(goodsId);
assert goods != null;
BPA_GOODS_CLASSIFY classify = GoodsClassifyDBUtil.getById(goods.classifyId);
assert classify != null;

List<BPA_GOODS_SUBATTRIBUTE_GROUP> groups = SubAttributeGroupDBUtil.getByGoodsId(goodsId);
List<BPA_GOODS_PROCESS_DETAIL> goodsProcessDetails = new ArrayList<>();
for(BPA_GOODS_SUBATTRIBUTE_GROUP group:groups){
goodsProcessDetails.addAll(GoodsProcessDetailDBUtil.getByGroupId(group.id));
}
//"actionJson": "[{\"actionName\":\"加热档位\",\"actionValue\":\"10档\",\"technologyactionId\":\"6c6d52e3-0389-49fe-ae82-06c87aa46e44\",\"index\":0}
// ,{\"actionName\":\"延迟(秒)\",\"actionValue\":13,\"technologyactionId\":\"d64dc9a7-5271-42f6-915e-6d993ff9b63b\",\"index\":1},
// {\"actionName\":\"加热控制\",\"actionValue\":\"启动加热\",\"technologyactionId\":\"e519b9ae-8acb-44e6-bdc3-c6f11646d12b\",\"index\":2}]",
for(BPA_GOODS_PROCESS_DETAIL bean : goodsProcessDetails){
List<String> data = new ArrayList<>();
if (bean.processvalue.contains("|")) {
String[] res = bean.processvalue.split("[|]");
data.addAll(Arrays.asList(res));
} else {
data.add(bean.processvalue);
}
for (String item : data) {
if (item.contains(",")) {
String[] wl = item.split("[,]");
if (wl.length == 2) {
String name = wl[0];
String val = wl[1];

}
}
}
}
String actionJson = "";



// HttpHeaders headers = new HttpHeaders();
// headers.put("key", key);
// headers.put("sign", APIHelper.GetSign("",key));
// OkGo.<UploadRes>post("http://"+path+"/api/ExternalPlatform/Goods/AddGoods")
// .tag(MainApplication.getContext())
// .upRequestBody(
// RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
// new Gson().toJson(upMaterialBean)))
// .headers(headers)
// .execute(new JsonDialogCallback<UploadRes>(MainApplication.getContext()) {
// @Override
// public void onSuccess(Response<UploadRes> response) {
//NewToastUtil.getInstance().showToastError("上传商品工艺成功");
// }
//
// @Override
// public void onError(Response<UploadRes> response) {
// super.onError(response);
// NewToastUtil.getInstance().showToastError("上传商品工艺失败 "+response.message());
// WaitProcessUtil.getInstance().dismiss();
// }
// });
WaitProcessUtil.getInstance().dismiss();
}

}

+ 59
- 0
app/src/main/java/com/bonait/bnframework/ui/widget/WaitProcessUtil.java View File

@@ -0,0 +1,59 @@
package com.bonait.bnframework.ui.widget;

import android.content.Context;

import com.bonait.bnframework.MainApplication;
import com.bonait.bnframework.ui.dialog.WaiteProgressDialog;

/**
* @author: liup
* @description:
* @date: 2024/7/9 9:55.
*/
public class WaitProcessUtil {
private static WaitProcessUtil instance;
private WaiteProgressDialog progressDialog;
public static synchronized WaitProcessUtil getInstance(){
if(instance == null){
synchronized (WaitProcessUtil.class){
if(instance == null){
instance = new WaitProcessUtil();
}
}
}
return instance;
}

public void show(Context context,String title, String message){
MainApplication.handler.post(() -> {
if(progressDialog!=null){
progressDialog.dismiss();
}
progressDialog = new WaiteProgressDialog(context);
progressDialog.setTitleAndMessage(title,message);
progressDialog.setCancelable(false);
progressDialog.show();
});
}

public void show(String title, String message){
MainApplication.handler.post(() -> {
if(progressDialog!=null){
progressDialog.dismiss();
}
progressDialog = new WaiteProgressDialog(MainApplication.getContext());
progressDialog.setTitleAndMessage(title,message);
progressDialog.setCancelable(false);
progressDialog.show();
});
}

public void dismiss(){
MainApplication.handler.post(()->{
if(progressDialog!=null){
progressDialog.dismiss();
progressDialog = null;
}
});
}
}

+ 0
- 16
app/src/main/res/layout/fragment_home1.xml View File

@@ -740,19 +740,6 @@
android:text="清洗位"
android:textColor="@color/white"
android:textSize="16dp" />
<!--边框分割细线-->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginEnd="2dp">

<LinearLayout
android:layout_width="1dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:background="@color/activity_background" />
</RelativeLayout>

<!--边框分割细线-->
<RelativeLayout
@@ -768,9 +755,6 @@
android:background="@color/activity_background" />
</RelativeLayout>




</LinearLayout>
</RelativeLayout>



+ 2
- 2
app/src/main/res/layout/fragment_home2.xml View File

@@ -87,7 +87,8 @@
android:layout_width="140dp"
android:layout_height="120dp"
android:layout_marginTop="10dp"
tools:visibility="gone"
android:layout_marginEnd="10dp"
android:visibility="gone"
android:background="@drawable/diy_bj">
<ImageView
android:layout_width="80dp"
@@ -102,7 +103,6 @@
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="@dimen/dp_10"
android:background="@drawable/cp_bj">
<ImageView
android:layout_width="80dp"


Loading…
Cancel
Save