@@ -4,18 +4,18 @@ | |||
<value> | |||
<entry key="app"> | |||
<State> | |||
<runningDeviceTargetSelectedWithDropDown> | |||
<targetSelectedWithDropDown> | |||
<Target> | |||
<type value="RUNNING_DEVICE_TARGET" /> | |||
<type value="QUICK_BOOT_TARGET" /> | |||
<deviceKey> | |||
<Key> | |||
<type value="SERIAL_NUMBER" /> | |||
<value value="127.0.0.1:7555" /> | |||
<type value="VIRTUAL_DEVICE_PATH" /> | |||
<value value="C:\Users\admin\.android\avd\bpa_API_30.avd" /> | |||
</Key> | |||
</deviceKey> | |||
</Target> | |||
</runningDeviceTargetSelectedWithDropDown> | |||
<timeTargetWasSelectedWithDropDown value="2024-06-20T02:05:04.749775900Z" /> | |||
</targetSelectedWithDropDown> | |||
<timeTargetWasSelectedWithDropDown value="2024-06-26T06:23:13.717269100Z" /> | |||
</State> | |||
</entry> | |||
</value> | |||
@@ -158,6 +158,9 @@ dependencies { | |||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9' | |||
//http服务器组件 | |||
implementation 'org.nanohttpd:nanohttpd:2.3.1' | |||
//MQTT | |||
// implementation files('libs\\org.eclipse.paho.android.service-1.1.1.jar') | |||
// implementation files('libs\\org.eclipse.paho.client.mqttv3-1.2.5.jar') | |||
@@ -26,6 +26,8 @@ import com.bonait.bnframework.common.helper.ConfigUtil; | |||
import com.bonait.bnframework.common.helper.I.IRun; | |||
import com.bonait.bnframework.common.helper.I.IRunT; | |||
import com.bonait.bnframework.common.helper.Json; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.bonait.bnframework.common.helper.ReceiveData; | |||
import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback; | |||
import com.bonait.bnframework.common.image.utils.LocalCacheUtils; | |||
import com.bonait.bnframework.common.message.MessageManager; | |||
@@ -60,6 +62,7 @@ import com.bonait.bnframework.common.utils.ToastUtils; | |||
import com.bonait.bnframework.common.view.GoodEditDialog; | |||
import com.google.gson.Gson; | |||
import com.lzy.okgo.OkGo; | |||
import com.lzy.okgo.callback.StringCallback; | |||
import com.lzy.okgo.model.HttpHeaders; | |||
import com.lzy.okgo.model.Response; | |||
@@ -374,6 +377,72 @@ public class ConfigData { | |||
} | |||
} | |||
public void GetMainConsoleData(){ | |||
String url = "http://" + ConfigName.getInstance().MainAddress+":35000/api/GetMainConsoleData"; | |||
OkGo.<String>post(url).tag(this).execute(new StringCallback() { | |||
@Override | |||
public void onSuccess(Response<String> response) { | |||
ConfigData.getInstance().GoodsSync(response.body()); | |||
} | |||
@Override | |||
public void onError(Response<String> val){ | |||
ToastUtils.info("获取主控数据失败!"); | |||
} | |||
}); | |||
} | |||
public boolean GoodsSync(String goods){ | |||
try{ | |||
ReceiveData rd = new Gson().fromJson(goods, ReceiveData.class); | |||
if(rd.goods!=null){ | |||
for (BPA_GOODS item:rd.goods){ | |||
if(QueryDB.GetGoodsIDIs(item.id))QueryDB.UpdateGoods(item); | |||
else QueryDB.AddGoods(item); | |||
} | |||
} | |||
if(rd.material!=null){ | |||
for (BPA_MATERIAL item:rd.material){ | |||
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){ | |||
for(BPA_GOODSRECIPE remove:removeData){ | |||
QueryDB.DeleteGoodsSrecipe(remove); | |||
} | |||
} | |||
for(BPA_GOODSRECIPE item:rd.goodsrecipes){ | |||
QueryDB.AddGoodsSrecipe(item); | |||
} | |||
} | |||
if(rd.processes!=null){ | |||
for(BPA_PROCESS item:rd.processes){ | |||
if(QueryDB.GetProcessID(item.id)!=null)QueryDB.UpdateProcess(item); | |||
else QueryDB.AddProcess(item); | |||
} | |||
} | |||
if(rd.processModels!=null){ | |||
for(BPA_PROCESSModel item:rd.processModels){ | |||
if(QueryDB.GetProcessModelID(item.id)!=null)QueryDB.UpdateProcessModel(item); | |||
else QueryDB.AddProcessModel(item); | |||
} | |||
} | |||
ToastUtils.info("获取主控数据成功!"); | |||
return true; | |||
}catch (Exception ex){ | |||
MessageLog.ShowError("解析数据失败!,"+ex.getMessage()); | |||
ToastUtils.info("解析数据失败!,"+ex.getMessage()); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 获取组织信息 | |||
* | |||
@@ -15,7 +15,10 @@ 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_LOG; | |||
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_SILOSANDMATERIAL; | |||
import com.bonait.bnframework.common.db.mode.BPA_USER; | |||
@@ -25,6 +28,7 @@ import com.bonait.bnframework.common.helper.CrashHandler; | |||
import com.bonait.bnframework.common.helper.I.IMessageLogNotify; | |||
import com.bonait.bnframework.common.helper.LogcatHelper; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.bonait.bnframework.common.helper.ReceiveData; | |||
import com.bonait.bnframework.common.helper.SdCart; | |||
import com.bonait.bnframework.common.modbus.ModbusTcpHelper; | |||
import com.bonait.bnframework.common.modbus.ModbusTcpMainHelper; | |||
@@ -33,12 +37,16 @@ import com.bonait.bnframework.common.notification.MainNotification; | |||
import com.bonait.bnframework.common.utils.AppUtils; | |||
import com.bonait.bnframework.common.utils.NetworkUtils; | |||
import com.bonait.bnframework.common.utils.PreferenceUtils; | |||
import com.bonait.bnframework.common.utils.ToastUtils; | |||
import com.bonait.bnframework.common.utils.WifiInterceptor; | |||
import com.bonait.bnframework.manager.ActivityLifecycleManager; | |||
import com.google.gson.Gson; | |||
import com.lzy.okgo.OkGo; | |||
import com.lzy.okgo.cache.CacheEntity; | |||
import com.lzy.okgo.cache.CacheMode; | |||
import com.lzy.okgo.callback.StringCallback; | |||
import com.lzy.okgo.interceptor.HttpLoggingInterceptor; | |||
import com.lzy.okgo.model.Response; | |||
import com.orhanobut.logger.AndroidLogAdapter; | |||
import com.orhanobut.logger.FormatStrategy; | |||
import com.orhanobut.logger.Logger; | |||
@@ -0,0 +1,43 @@ | |||
package com.bonait.bnframework.common.helper; | |||
import com.bonait.bnframework.business.ConfigData; | |||
import com.google.gson.Gson; | |||
import com.lzy.okgo.model.HttpParams; | |||
import java.io.InputStream; | |||
import java.util.Map; | |||
import java.util.Scanner; | |||
import fi.iki.elonen.NanoHTTPD; | |||
public class HttpServer extends NanoHTTPD { | |||
public HttpServer() { | |||
super(36000); | |||
try{ | |||
start(NanoHTTPD.SOCKET_READ_TIMEOUT, false); | |||
}catch (Exception ex){ | |||
MessageLog.ShowError("启动服务失败!"+ex.getMessage()); | |||
} | |||
} | |||
@Override | |||
public Response serve(IHTTPSession session) { | |||
try{ | |||
if (session.getMethod()==Method.POST){ | |||
Map<String,String> headers= session.getHeaders();//获取请求头数据 | |||
if(session.getUri().contains("/api/DownGoodsData")){ | |||
InputStream inputStream = session.getInputStream(); | |||
String upString = new Scanner(inputStream).useDelimiter("\\A").next(); | |||
if (ConfigData.getInstance().GoodsSync(upString)) | |||
return newFixedLengthResponse(Response.Status.OK, HttpParams.MEDIA_TYPE_JSON.toString(), new Gson().toJson("成功")); // 返回响应 | |||
else | |||
return newFixedLengthResponse(Response.Status.INTERNAL_ERROR, HttpParams.MEDIA_TYPE_JSON.toString(), new Gson().toJson("数据解析失败")); // 返回响应 | |||
} | |||
} | |||
return newFixedLengthResponse(Response.Status.INTERNAL_ERROR, HttpParams.MEDIA_TYPE_JSON.toString(), new Gson().toJson("不是有效的请求")); // 返回响应 | |||
}catch (Exception ex){ | |||
MessageLog.ShowError("请求失败!"+ex.getMessage()); | |||
return newFixedLengthResponse(Response.Status.INTERNAL_ERROR, HttpParams.MEDIA_TYPE_JSON.toString(), new Gson().toJson(ex.getMessage())); // 返回响应 | |||
} | |||
} | |||
} |
@@ -13,13 +13,10 @@ import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL; | |||
import java.util.ArrayList; | |||
public class ReceiveData { | |||
ArrayList<BPA_GOODS> goods;//商品表 | |||
ArrayList<BPA_MATERIAL> material;//物料表 | |||
// ArrayList<BPA_SILOS> silos;//料仓管理表 | |||
// ArrayList<BPA_SILOSANDMATERIAL> silosandmaterials;//料仓物料关联表 | |||
ArrayList<BPA_GOODSRECIPE> goodsrecipes;//商品配方明细表 | |||
// ArrayList<BPA_CRAFT> crafts;//工艺基础信息表 | |||
// ArrayList<BPA_CRAFTPROCESS> craftprocesses;//工艺流程表 | |||
ArrayList<BPA_PROCESS> processes;//工序表 | |||
ArrayList<BPA_PROCESSModel> processModels;//工序模型表 | |||
public ArrayList<BPA_GOODS> goods;//商品表 | |||
public ArrayList<BPA_MATERIAL> material;//物料表 | |||
public ArrayList<BPA_GOODSRECIPE> goodsrecipes;//商品配方明细表 | |||
public ArrayList<BPA_PROCESS> processes;//工序表 | |||
public ArrayList<BPA_PROCESSModel> processModels;//工序模型表 | |||
} | |||
@@ -7,6 +7,7 @@ import androidx.annotation.NonNull; | |||
import com.bonait.bnframework.business.ConfigData; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.constant.DataBus; | |||
import com.bonait.bnframework.common.helper.HttpServer; | |||
import com.bonait.bnframework.common.helper.I.IThread; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.bonait.bnframework.common.helper.TcpClient; | |||
@@ -49,6 +50,7 @@ public class BottomNavigation2Activity extends BaseActivity { | |||
private MenuItem menuItem; | |||
private long exitTime = 0; | |||
HttpServer hs; | |||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
@@ -61,12 +63,21 @@ public class BottomNavigation2Activity extends BaseActivity { | |||
viewPager.setOffscreenPageLimit(3); | |||
bottomNavigationView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); | |||
Init(); | |||
if(ConfigName.getInstance().versionSelectionEnum.contains("一拖")) | |||
TcpClient.getInstance().Connect(ConfigName.getInstance().MainAddress,40000); | |||
if(ConfigName.getInstance().versionSelectionEnum.contains("一拖")){ | |||
hs = new HttpServer(); | |||
new Thread(()->{ | |||
try { | |||
ConfigData.getInstance(). GetMainConsoleData(); | |||
Thread.sleep(3000); | |||
}catch (Exception e){} | |||
}).start(); | |||
} | |||
} | |||
@Override | |||
protected void onDestroy() { | |||
if (hs!=null) | |||
hs.stop(); | |||
TcpClient.getInstance().Close(); | |||
ConfigData.getInstance().ColsePLC(); | |||
ConfigName.getInstance().IsShow=false; | |||
@@ -5,6 +5,7 @@ import androidx.viewpager.widget.ViewPager; | |||
import android.app.Activity; | |||
import android.os.Bundle; | |||
import android.os.Message; | |||
import android.util.Log; | |||
import android.view.KeyEvent; | |||
import android.view.MenuItem; | |||
@@ -15,23 +16,38 @@ import android.widget.TextView; | |||
import com.bonait.bnframework.R; | |||
import com.bonait.bnframework.business.ConfigData; | |||
import com.bonait.bnframework.business.ExecuteTheRecipe; | |||
import com.bonait.bnframework.business.MainInit; | |||
import com.bonait.bnframework.common.base.BaseActivity; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.constant.MessageName; | |||
import com.bonait.bnframework.common.db.QueryDB; | |||
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_MATERIAL; | |||
import com.bonait.bnframework.common.db.mode.BPA_PROCESS; | |||
import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel; | |||
import com.bonait.bnframework.common.helper.CountDownTimerExt; | |||
import com.bonait.bnframework.common.helper.HttpServer; | |||
import com.bonait.bnframework.common.helper.I.IRunT; | |||
import com.bonait.bnframework.common.helper.I.IThread; | |||
import com.bonait.bnframework.common.helper.I.MyClickListener; | |||
import com.bonait.bnframework.common.helper.Json; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.bonait.bnframework.common.helper.ReceiveData; | |||
import com.bonait.bnframework.common.helper.TcpClient; | |||
import com.bonait.bnframework.common.helper.ThreadManager; | |||
import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback; | |||
import com.bonait.bnframework.common.message.MessageLooper; | |||
import com.bonait.bnframework.common.message.MessageManager; | |||
import com.bonait.bnframework.common.modbus.ModbusTcpMainServer; | |||
import com.bonait.bnframework.common.modbus.ModbusTcpServer; | |||
import com.bonait.bnframework.common.model.ResAPI; | |||
import com.bonait.bnframework.common.model.mode.BatchingInfo; | |||
import com.bonait.bnframework.common.model.mode.GoodsTechnology; | |||
import com.bonait.bnframework.common.model.mode.ResALLData; | |||
import com.bonait.bnframework.common.model.mode.TechnologyAction; | |||
import com.bonait.bnframework.common.model.mode.TechnologyValueMode; | |||
import com.bonait.bnframework.common.utils.NetworkUtils; | |||
import com.bonait.bnframework.common.utils.ToastUtils; | |||
import com.bonait.bnframework.common.view.BottomNavigationBar; | |||
@@ -45,10 +61,16 @@ import com.bonait.bnframework.modules.home.fragment.HomeFragmentSBKZ; | |||
import com.bonait.bnframework.modules.home.fragment.from.CookingActivity; | |||
import com.bonait.bnframework.modules.mine.fragment.MyFragment; | |||
import com.google.android.material.bottomnavigation.BottomNavigationView; | |||
import com.google.gson.Gson; | |||
import com.lzy.okgo.OkGo; | |||
import com.lzy.okgo.callback.StringCallback; | |||
import com.lzy.okgo.model.HttpHeaders; | |||
import com.lzy.okgo.model.Response; | |||
import com.qmuiteam.qmui.widget.QMUIViewPager; | |||
import java.text.SimpleDateFormat; | |||
import java.util.ArrayList; | |||
import java.util.Date; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
@@ -77,17 +99,25 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
//region 界面私立 | |||
public Activity activity; | |||
HttpServer hs; | |||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
setContentView(R.layout.activity_bottom_navigation_new); | |||
ButterKnife.bind(this); | |||
activity = this; | |||
Init(); | |||
initFragment(); | |||
viewPager.addOnPageChangeListener(pageChangeListener); | |||
// 设置viewPager缓存多少个fragment | |||
viewPager.setOffscreenPageLimit(3); | |||
// HttpServer hs = new HttpServer(); | |||
bottomNavigationView.mListener = new MyClickListener() { | |||
@Override | |||
public void clickListener(View v, Object data) { | |||
@@ -102,12 +132,23 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
}; | |||
viewPager.setCurrentItem(1); | |||
if(ConfigName.getInstance().versionSelectionEnum.contains("一拖")) | |||
TcpClient.getInstance().Connect(ConfigName.getInstance().MainAddress,40000); | |||
if(ConfigName.getInstance().versionSelectionEnum.contains("一拖")){ | |||
hs = new HttpServer(); | |||
new Thread(()->{ | |||
try { | |||
ConfigData.getInstance(). GetMainConsoleData(); | |||
Thread.sleep(3000); | |||
}catch (Exception e){} | |||
}).start(); | |||
} | |||
// TcpClient.getInstance().Connect(ConfigName.getInstance().MainAddress,40000); | |||
} | |||
@Override | |||
protected void onDestroy() { | |||
if (hs!=null) | |||
hs.stop(); | |||
TcpClient.getInstance().Close(); | |||
ConfigData.getInstance().ColsePLC(); | |||
ConfigName.getInstance().IsShowNew = false; | |||
@@ -125,6 +166,10 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
return viewPager.getCurrentItem() == 0; | |||
} | |||
//endregion | |||
//region 私有函数 | |||