@@ -69,7 +69,7 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen | |||||
*/ | */ | ||||
@Override | @Override | ||||
protected void onDestroy() { | protected void onDestroy() { | ||||
MQTT.get().ConnMqttBroken(false);//释放mqtt | |||||
//MQTT.get().ConnMqttBroken(false);//释放mqtt | |||||
ModbusTcpHelper.get().release();//释放modbus | ModbusTcpHelper.get().release();//释放modbus | ||||
super.onDestroy(); | super.onDestroy(); | ||||
} | } | ||||
@@ -7,10 +7,12 @@ import android.util.Log; | |||||
import com.example.bpa.Model.IMessageLogNotify; | import com.example.bpa.Model.IMessageLogNotify; | ||||
import com.example.bpa.config.ConfigName; | import com.example.bpa.config.ConfigName; | ||||
import com.example.bpa.db.QueryDB; | import com.example.bpa.db.QueryDB; | ||||
import com.example.bpa.db.file.DBHelper; | |||||
import com.example.bpa.db.mode.BPA_ALERTLOG; | import com.example.bpa.db.mode.BPA_ALERTLOG; | ||||
import com.example.bpa.db.mode.BPA_LOG; | import com.example.bpa.db.mode.BPA_LOG; | ||||
import com.example.bpa.db.mode.BPA_SILOS; | import com.example.bpa.db.mode.BPA_SILOS; | ||||
import com.example.bpa.db.mode.BPA_SILOSANDMATERIAL; | import com.example.bpa.db.mode.BPA_SILOSANDMATERIAL; | ||||
import com.example.bpa.db.mode.BPA_SUBORDER; | |||||
import com.example.bpa.db.mode.BPA_SUGAR; | import com.example.bpa.db.mode.BPA_SUGAR; | ||||
import com.example.bpa.db.mode.BPA_USER; | import com.example.bpa.db.mode.BPA_USER; | ||||
import com.example.bpa.helper.MessageLog; | import com.example.bpa.helper.MessageLog; | ||||
@@ -210,4 +212,9 @@ public class ICSApp extends Application { | |||||
// QueryDB.AddSugar(sugar_B_2); | // QueryDB.AddSugar(sugar_B_2); | ||||
// } | // } | ||||
} | } | ||||
public void DBdelete() | |||||
{ | |||||
DBHelper.getInstance(ConfigName.getInstance().dishesCon).DeleteCreateTables(BPA_SUBORDER.class,null); | |||||
} | |||||
} | } |
@@ -2,6 +2,7 @@ package com.example.bpa.config; | |||||
import com.example.bpa.Model.ResultA; | import com.example.bpa.Model.ResultA; | ||||
import com.example.bpa.R; | import com.example.bpa.R; | ||||
import com.example.bpa.db.mode.BPA_SUBORDER; | |||||
import com.example.bpa.service.DeviceData; | import com.example.bpa.service.DeviceData; | ||||
import com.example.bpa.db.QueryDB; | import com.example.bpa.db.QueryDB; | ||||
import com.example.bpa.db.mode.BPA_ALERTLOG; | import com.example.bpa.db.mode.BPA_ALERTLOG; | ||||
@@ -65,16 +66,17 @@ public class DataBus { | |||||
*/ | */ | ||||
public makegood_adapter goodmakeadapter; | public makegood_adapter goodmakeadapter; | ||||
/** | /** | ||||
* 增加一个商品 | |||||
* @param id | |||||
* 增加一个订单商品 | |||||
* @param suborder | |||||
*/ | */ | ||||
public void AddGoodsMake(String id) | |||||
public void AddGoodsMake(BPA_SUBORDER suborder) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
ResGoodsMake make=new ResGoodsMake(); | ResGoodsMake make=new ResGoodsMake(); | ||||
make.recipes=QueryDB.GetGoodsSrecipeList(id); | |||||
make.good=QueryDB.GetGoodsId(id); | |||||
make.recipes=QueryDB.GetGoodsSrecipeList(suborder.goodsID); | |||||
make.good=QueryDB.GetGoodsId(suborder.goodsID); | |||||
make.subOrder=suborder; | |||||
make.makeStatus= MakeStatus.等待制作; | make.makeStatus= MakeStatus.等待制作; | ||||
make.makeMs=""; | make.makeMs=""; | ||||
make.makeProcess=0; | make.makeProcess=0; | ||||
@@ -85,19 +87,25 @@ public class DataBus { | |||||
} | } | ||||
/** | /** | ||||
* 根据商品id,物料id修改制作进度 | |||||
* @param id | |||||
* 根据子订单id,物料id修改制作进度 | |||||
* @param suborderID | |||||
* @param makeMs | * @param makeMs | ||||
* @param count | * @param count | ||||
*/ | */ | ||||
public void UpdateGoodsMake(String id,String makeMs,int count) | |||||
public void UpdateGoodsMake(String suborderID,String makeMs,int count) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
for (int m=0;m<GoodsMake.size();m++) | for (int m=0;m<GoodsMake.size();m++) | ||||
{ | { | ||||
if(GoodsMake.get(m).good.id.equals(id)) | |||||
if(GoodsMake.get(m).subOrder.id.equals(suborderID)) | |||||
{ | { | ||||
if(GoodsMake.get(m).subOrder.status==0) | |||||
{ | |||||
GoodsMake.get(m).subOrder.status=1; | |||||
QueryDB.UpdateSubOrder(GoodsMake.get(m).subOrder); | |||||
} | |||||
GoodsMake.get(m).makeStatus= MakeStatus.制作中; | GoodsMake.get(m).makeStatus= MakeStatus.制作中; | ||||
GoodsMake.get(m).makeMs=makeMs; | GoodsMake.get(m).makeMs=makeMs; | ||||
GoodsMake.get(m).makeProcess=(count/ GoodsMake.get(m).recipes.size())*100; | GoodsMake.get(m).makeProcess=(count/ GoodsMake.get(m).recipes.size())*100; | ||||
@@ -109,20 +117,22 @@ public class DataBus { | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* 根据商品id,设置商品制作完成 | |||||
* 根据子订单id,设置订单制作完成 | |||||
*/ | */ | ||||
public void DeleteGoodsMake(String id) | |||||
public void DeleteGoodsMake(String suborderID) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
ResGoodsMake good=null; | ResGoodsMake good=null; | ||||
for (ResGoodsMake item:GoodsMake) | for (ResGoodsMake item:GoodsMake) | ||||
{ | { | ||||
if(item.good.id.equals(id)) | |||||
if(item.subOrder.id.equals(suborderID)) | |||||
{ | { | ||||
item.makeStatus=MakeStatus.制作完成; | item.makeStatus=MakeStatus.制作完成; | ||||
item.makeMs=""; | item.makeMs=""; | ||||
item.makeProcess=100; | item.makeProcess=100; | ||||
item.subOrder.status=2; | |||||
QueryDB.UpdateSubOrder(item.subOrder); | |||||
good=item; | good=item; | ||||
} | } | ||||
} | } | ||||
@@ -1783,8 +1783,8 @@ public class QueryDB { | |||||
data = new BPA_SUBORDER(); | data = new BPA_SUBORDER(); | ||||
//私有 | //私有 | ||||
((BPA_SUBORDER) data).orderID = cursor.getString((int) cursor.getColumnIndex("orderID")); | ((BPA_SUBORDER) data).orderID = cursor.getString((int) cursor.getColumnIndex("orderID")); | ||||
((BPA_SUBORDER) data).goodsID = cursor.getInt((int) cursor.getColumnIndex("goodsID")); | |||||
((BPA_SUBORDER) data).number = cursor.getString((int) cursor.getColumnIndex("number")); | |||||
((BPA_SUBORDER) data).goodsID = cursor.getString((int) cursor.getColumnIndex("goodsID")); | |||||
((BPA_SUBORDER) data).number = cursor.getInt((int) cursor.getColumnIndex("number")); | |||||
((BPA_SUBORDER) data).status = cursor.getInt((int) cursor.getColumnIndex("status")); | ((BPA_SUBORDER) data).status = cursor.getInt((int) cursor.getColumnIndex("status")); | ||||
break; | break; | ||||
case "BPA_ALERTLOG": | case "BPA_ALERTLOG": | ||||
@@ -180,6 +180,38 @@ public class DBHelper extends SQLiteOpenHelper { | |||||
db.endTransaction(); | db.endTransaction(); | ||||
} | } | ||||
/** | |||||
* 删除在创建 | |||||
* @param c | |||||
* @param premarykey | |||||
*/ | |||||
public void DeleteCreateTables(Class c,String premarykey) | |||||
{ | |||||
if (premarykey == null){ | |||||
premarykey=""; | |||||
} | |||||
SQLiteDatabase db =this.getWritableDatabase(); | |||||
db.beginTransaction(); | |||||
String TabName= c.getSimpleName();//表名称 | |||||
ArrayList<Table> tables = new ArrayList<Table>(); | |||||
Table t; | |||||
t = new Table(TabName); // 创建表名称 | |||||
for (Field field : c.getFields()){ | |||||
String name=field.getName(); | |||||
String type=field.getType().getSimpleName(); | |||||
if(type.equals("String") || type.equals("Date")) | |||||
{ | |||||
type="text"; | |||||
} | |||||
t.addFeild(new Feild(name, type)); // 字段名称 | |||||
} | |||||
tables.add(t); | |||||
for (Table table : tables) { | |||||
db.execSQL(table.deleteSql()); | |||||
db.execSQL(table.createSQL(premarykey)); | |||||
} | |||||
db.setTransactionSuccessful(); | |||||
db.endTransaction(); | |||||
} | |||||
} | } |
@@ -81,4 +81,13 @@ public class Table { | |||||
Log.i("sql:",sb.toString()); | Log.i("sql:",sb.toString()); | ||||
return sb.toString(); | return sb.toString(); | ||||
} | } | ||||
/** | |||||
* 删除表 | |||||
* @return | |||||
*/ | |||||
public String deleteSql() | |||||
{ | |||||
return "drop table "+this.name; | |||||
} | |||||
} | } |
@@ -8,9 +8,9 @@ public class BPA_SUBORDER extends ModeBase{ | |||||
//主订单ID | //主订单ID | ||||
public String orderID; | public String orderID; | ||||
//商品ID | //商品ID | ||||
public int goodsID; | |||||
public String goodsID; | |||||
//数量:例如 *1 *2 | //数量:例如 *1 *2 | ||||
public String number; | |||||
//状态:0 未开始 1 已制作 2 已超时 | |||||
public int number; | |||||
//状态:0 未开始 1 制作中 2 已制作 3 已超时 | |||||
public int status; | public int status; | ||||
} | } |
@@ -54,6 +54,7 @@ public class MQTT { | |||||
public IMessage callback=null;//消息回调 | public IMessage callback=null;//消息回调 | ||||
public IRun ConnectOk=null; | public IRun ConnectOk=null; | ||||
public IRun Disconnect=null; | public IRun Disconnect=null; | ||||
public boolean IsConnect=false; | |||||
//endregion | //endregion | ||||
//region 公有函数 | //region 公有函数 | ||||
@@ -82,6 +83,7 @@ public class MQTT { | |||||
mqttClient.setCallback(new MqttCallback() { | mqttClient.setCallback(new MqttCallback() { | ||||
@Override//连接丢失后,会执行这里 | @Override//连接丢失后,会执行这里 | ||||
public void connectionLost(Throwable throwable) { | public void connectionLost(Throwable throwable) { | ||||
IsConnect=false; | |||||
MessageLog.ShowInfo("mqtt断开连接,尝试重新连接..."); | MessageLog.ShowInfo("mqtt断开连接,尝试重新连接..."); | ||||
if(Disconnect!=null) | if(Disconnect!=null) | ||||
{ | { | ||||
@@ -122,6 +124,7 @@ public class MQTT { | |||||
mqttClient.connect(options);//连接服务器,连接不上会阻塞在这 | mqttClient.connect(options);//连接服务器,连接不上会阻塞在这 | ||||
} | } | ||||
MessageLog.ShowInfo("mqtt连接成功!"); | MessageLog.ShowInfo("mqtt连接成功!"); | ||||
IsConnect=true; | |||||
if(ConnectOk!=null) | if(ConnectOk!=null) | ||||
{ | { | ||||
ConnectOk.Run(); | ConnectOk.Run(); | ||||
@@ -134,6 +137,7 @@ public class MQTT { | |||||
if (mqttClient!=null && mqttClient.isConnected()) { | if (mqttClient!=null && mqttClient.isConnected()) { | ||||
mqttClient.disconnect(); | mqttClient.disconnect(); | ||||
} | } | ||||
IsConnect=false; | |||||
MessageLog.ShowInfo("mqtt断开成功!"); | MessageLog.ShowInfo("mqtt断开成功!"); | ||||
} catch (MqttException e) { | } catch (MqttException e) { | ||||
MessageLog.ShowError("mqtt断开失败!"+e.getMessage()); | MessageLog.ShowError("mqtt断开失败!"+e.getMessage()); | ||||
@@ -8,6 +8,7 @@ import com.example.bpa.config.DataBus; | |||||
import com.example.bpa.db.QueryDB; | import com.example.bpa.db.QueryDB; | ||||
import com.example.bpa.db.mode.BPA_GOODS; | import com.example.bpa.db.mode.BPA_GOODS; | ||||
import com.example.bpa.db.mode.BPA_SILOS; | import com.example.bpa.db.mode.BPA_SILOS; | ||||
import com.example.bpa.db.mode.BPA_SUBORDER; | |||||
import com.example.bpa.db.mode.BPA_SUGAR; | import com.example.bpa.db.mode.BPA_SUGAR; | ||||
import com.example.bpa.helper.MessageLog; | import com.example.bpa.helper.MessageLog; | ||||
import com.example.bpa.helper.ModbusTcpServer; | import com.example.bpa.helper.ModbusTcpServer; | ||||
@@ -39,14 +40,14 @@ public class BusinessServer { | |||||
/** | /** | ||||
* 商品制作队列 | * 商品制作队列 | ||||
*/ | */ | ||||
ConcurrentLinkedQueue<String> Commoditys = new ConcurrentLinkedQueue<String>(); | |||||
ConcurrentLinkedQueue<BPA_SUBORDER> Commoditys = new ConcurrentLinkedQueue<BPA_SUBORDER>(); | |||||
/** | /** | ||||
* 增加一个订单 | |||||
* 增加一个子订单 | |||||
* | * | ||||
* @param info 配方信息 | * @param info 配方信息 | ||||
*/ | */ | ||||
public void AddCommodity(String info) { | |||||
public void AddCommodity(BPA_SUBORDER info) { | |||||
//1.添加制作队列 | //1.添加制作队列 | ||||
Commoditys.offer(info); | Commoditys.offer(info); | ||||
//2.数据中心添加制作队列商品数据 | //2.数据中心添加制作队列商品数据 | ||||
@@ -62,7 +63,8 @@ public class BusinessServer { | |||||
public void Run() throws InterruptedException { | public void Run() throws InterruptedException { | ||||
while (Commoditys.size() > 0) { | while (Commoditys.size() > 0) { | ||||
//1.取出需要制作的订单商品 验证物料是否充足 | //1.取出需要制作的订单商品 验证物料是否充足 | ||||
String GoodId = Commoditys.poll(); | |||||
BPA_SUBORDER suborder=Commoditys.poll(); | |||||
String GoodId = suborder.goodsID; | |||||
// boolean IsMake=true; | // boolean IsMake=true; | ||||
ResultA resultA= DataBus.getInstance().InspectMaterial(GoodId); | ResultA resultA= DataBus.getInstance().InspectMaterial(GoodId); | ||||
// if(resultA.IsMake==false)//如果商品物料不足 | // if(resultA.IsMake==false)//如果商品物料不足 | ||||
@@ -96,7 +98,7 @@ public class BusinessServer { | |||||
List<ResGoodsRecipe> goodsRecipes= entry.getValue(); | List<ResGoodsRecipe> goodsRecipes= entry.getValue(); | ||||
String RecipesNames=""; | String RecipesNames=""; | ||||
for (ResGoodsRecipe item:goodsRecipes ){RecipesNames+=item.materialName+",";} | for (ResGoodsRecipe item:goodsRecipes ){RecipesNames+=item.materialName+",";} | ||||
DataBus.getInstance().UpdateGoodsMake(good.id,"步骤【" + key+ "】准备下发物料:"+RecipesNames,count); | |||||
DataBus.getInstance().UpdateGoodsMake(suborder.id,"步骤【" + key+ "】准备下发物料:"+RecipesNames,count); | |||||
for (int m = 0; m < goodsRecipes.size(); m++) { | for (int m = 0; m < goodsRecipes.size(); m++) { | ||||
ResGoodsRecipe recipe=goodsRecipes.get(m); | ResGoodsRecipe recipe=goodsRecipes.get(m); | ||||
int materialType = recipe.materialType; | int materialType = recipe.materialType; | ||||
@@ -166,12 +168,12 @@ public class BusinessServer { | |||||
} | } | ||||
//更新缓存商品制作列表状态 | //更新缓存商品制作列表状态 | ||||
count+=goodsRecipes.size(); | count+=goodsRecipes.size(); | ||||
DataBus.getInstance().UpdateGoodsMake(good.id,"步骤【" + key+ "】:"+RecipesNames+"-配料完成!",count); | |||||
DataBus.getInstance().UpdateGoodsMake(suborder.id,"步骤【" + key+ "】:"+RecipesNames+"-配料完成!",count); | |||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]步骤【" + key + "】下发"+RecipesNames+"执行完成!"); | MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]步骤【" + key + "】下发"+RecipesNames+"执行完成!"); | ||||
} | } | ||||
//endregion | //endregion | ||||
//5.设置数据中心商品已制作完成 | //5.设置数据中心商品已制作完成 | ||||
DataBus.getInstance().DeleteGoodsMake(GoodId); | |||||
DataBus.getInstance().DeleteGoodsMake(suborder.id); | |||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]-订单执行完成,请取餐!"); | MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]-订单执行完成,请取餐!"); | ||||
} | } | ||||
Thread.sleep(1000); | Thread.sleep(1000); | ||||
@@ -190,7 +192,8 @@ public class BusinessServer { | |||||
public void Run() throws InterruptedException { | public void Run() throws InterruptedException { | ||||
while (Commoditys.size() > 0) { | while (Commoditys.size() > 0) { | ||||
//1.取出需要制作的订单商品 验证物料是否充足 | //1.取出需要制作的订单商品 验证物料是否充足 | ||||
String GoodId = Commoditys.poll(); | |||||
BPA_SUBORDER suborder=Commoditys.poll(); | |||||
String GoodId = suborder.goodsID; | |||||
// boolean IsMake=true; | // boolean IsMake=true; | ||||
// ResultA resultA= DataBus.getInstance().InspectMaterial(GoodId); | // ResultA resultA= DataBus.getInstance().InspectMaterial(GoodId); | ||||
// if(resultA.IsMake==false)//如果商品物料不足 | // if(resultA.IsMake==false)//如果商品物料不足 | ||||
@@ -223,7 +226,7 @@ public class BusinessServer { | |||||
List<ResGoodsRecipe> goodsRecipes= entry.getValue(); | List<ResGoodsRecipe> goodsRecipes= entry.getValue(); | ||||
String RecipesNames=""; | String RecipesNames=""; | ||||
for (ResGoodsRecipe item:goodsRecipes ){RecipesNames+=item.materialName+",";} | for (ResGoodsRecipe item:goodsRecipes ){RecipesNames+=item.materialName+",";} | ||||
DataBus.getInstance().UpdateGoodsMake(good.id,"步骤【" + key+ "】准备下发物料:"+RecipesNames,count); | |||||
DataBus.getInstance().UpdateGoodsMake(suborder.id,"步骤【" + key+ "】准备下发物料:"+RecipesNames,count); | |||||
for (int m = 0; m < goodsRecipes.size(); m++) { | for (int m = 0; m < goodsRecipes.size(); m++) { | ||||
ResGoodsRecipe recipe=goodsRecipes.get(m); | ResGoodsRecipe recipe=goodsRecipes.get(m); | ||||
int materialType = recipe.materialType; | int materialType = recipe.materialType; | ||||
@@ -292,12 +295,12 @@ public class BusinessServer { | |||||
// } | // } | ||||
//更新缓存商品制作列表状态 | //更新缓存商品制作列表状态 | ||||
count+=goodsRecipes.size(); | count+=goodsRecipes.size(); | ||||
DataBus.getInstance().UpdateGoodsMake(good.id,"步骤【" + key+ "】:"+RecipesNames+"-配料完成!",count); | |||||
DataBus.getInstance().UpdateGoodsMake(suborder.id,"步骤【" + key+ "】:"+RecipesNames+"-配料完成!",count); | |||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]步骤【" + key + "】下发"+RecipesNames+"执行完成!"); | MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]步骤【" + key + "】下发"+RecipesNames+"执行完成!"); | ||||
} | } | ||||
//endregion | //endregion | ||||
//5.设置数据中心商品已制作完成 | //5.设置数据中心商品已制作完成 | ||||
DataBus.getInstance().DeleteGoodsMake(GoodId); | |||||
DataBus.getInstance().DeleteGoodsMake(suborder.id); | |||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]-订单执行完成,请取餐!"); | MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]-订单执行完成,请取餐!"); | ||||
} | } | ||||
Thread.sleep(1000); | Thread.sleep(1000); | ||||
@@ -3,9 +3,15 @@ package com.example.bpa.service; | |||||
import com.example.bpa.Model.IMessage; | import com.example.bpa.Model.IMessage; | ||||
import com.example.bpa.Model.IRun; | import com.example.bpa.Model.IRun; | ||||
import com.example.bpa.Model.IThread; | import com.example.bpa.Model.IThread; | ||||
import com.example.bpa.db.QueryDB; | |||||
import com.example.bpa.db.mode.BPA_SUBORDER; | |||||
import com.example.bpa.helper.Json; | |||||
import com.example.bpa.helper.MQTT; | import com.example.bpa.helper.MQTT; | ||||
import com.example.bpa.helper.MessageLog; | import com.example.bpa.helper.MessageLog; | ||||
import com.example.bpa.helper.ThreadManager; | import com.example.bpa.helper.ThreadManager; | ||||
import com.example.bpa.view.mode.ResReceiveOrder; | |||||
import java.util.concurrent.ConcurrentLinkedQueue; | |||||
/** | /** | ||||
* 订单服务 | * 订单服务 | ||||
@@ -26,7 +32,14 @@ public class OrderServer { | |||||
} | } | ||||
//endregion | //endregion | ||||
//region | |||||
//region 变量 | |||||
/** | |||||
* 订单接收队列 | |||||
*/ | |||||
ConcurrentLinkedQueue<ResReceiveOrder> Commoditys = new ConcurrentLinkedQueue<ResReceiveOrder>(); | |||||
//endreigon | |||||
//region 公共函数 | |||||
/** | /** | ||||
* 初始化 | * 初始化 | ||||
@@ -57,6 +70,14 @@ public class OrderServer { | |||||
@Override | @Override | ||||
public void MessageRecive(String topic, String Message) { | public void MessageRecive(String topic, String Message) { | ||||
MessageLog.ShowInfo("收到主题:"+topic+",数据:"+Message); | MessageLog.ShowInfo("收到主题:"+topic+",数据:"+Message); | ||||
try { | |||||
if(!Message.isEmpty()) | |||||
{ | |||||
ResReceiveOrder model=new Json<ResReceiveOrder>().jsonToobject(ResReceiveOrder.class,((String)Message)); | |||||
Commoditys.offer(model); | |||||
} | |||||
} catch (Exception e) { | |||||
} | |||||
} | } | ||||
}; | }; | ||||
//连接成功标志 | //连接成功标志 | ||||
@@ -69,6 +90,33 @@ public class OrderServer { | |||||
}; | }; | ||||
//初始化MQTT连接 | //初始化MQTT连接 | ||||
MQTT.get().Connect("emqx_u_block","emqx_p_admin8765490789","10.2.1.21",1883); | MQTT.get().Connect("emqx_u_block","emqx_p_admin8765490789","10.2.1.21",1883); | ||||
ThreadManager.Get().StartLong("云订单接收处理", true, new IThread() { | |||||
@Override | |||||
public void Run() throws InterruptedException { | |||||
if(MQTT.get().IsConnect) | |||||
{ | |||||
while (Commoditys.size() > 0) { | |||||
//1.取出订单 | |||||
ResReceiveOrder order = Commoditys.poll(); | |||||
if(order.order!=null && order.subOrder!=null) | |||||
{ | |||||
QueryDB.AddOrder(order.order); | |||||
for(BPA_SUBORDER suborder: order.subOrder) | |||||
{ | |||||
QueryDB.AddSubOrder(suborder); | |||||
//向订单执行队列增加子订单 | |||||
BusinessServer.Get().AddCommodity(suborder); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
Thread.sleep(2000); | |||||
} | |||||
@Override | |||||
public void RunComplete() throws InterruptedException { | |||||
} | |||||
}); | |||||
} | } | ||||
//endregion | //endregion | ||||
} | } |
@@ -12,6 +12,10 @@ import androidx.annotation.NonNull; | |||||
import androidx.recyclerview.widget.RecyclerView; | import androidx.recyclerview.widget.RecyclerView; | ||||
import com.example.bpa.R; | import com.example.bpa.R; | ||||
import com.example.bpa.config.ConfigName; | |||||
import com.example.bpa.db.QueryDB; | |||||
import com.example.bpa.db.mode.BPA_ORDER; | |||||
import com.example.bpa.db.mode.BPA_SUBORDER; | |||||
import com.example.bpa.service.BusinessServer; | import com.example.bpa.service.BusinessServer; | ||||
import com.example.bpa.config.DataBus; | import com.example.bpa.config.DataBus; | ||||
import com.example.bpa.helper.T; | import com.example.bpa.helper.T; | ||||
@@ -85,8 +89,22 @@ public class maingoods_adapter extends RecyclerView.Adapter<RecyclerView.ViewHol | |||||
T.show(view.getContext(),"PLC未连接,不允许下单!"); | T.show(view.getContext(),"PLC未连接,不允许下单!"); | ||||
return; | return; | ||||
} | } | ||||
BusinessServer.Get().AddCommodity(id); | |||||
BPA_ORDER order=new BPA_ORDER(); | |||||
order.thirdPartyID="手动下单"; | |||||
order.status=0; | |||||
order.deviceID = ConfigName.getInstance().DeviceId; | |||||
order.userID = ConfigName.getInstance().user.userID; | |||||
QueryDB.AddOrder(order); | |||||
BPA_SUBORDER suborder=new BPA_SUBORDER(); | |||||
suborder.deviceID = ConfigName.getInstance().DeviceId; | |||||
suborder.userID = ConfigName.getInstance().user.userID; | |||||
suborder.orderID = order.id; | |||||
suborder.goodsID = id; | |||||
suborder.number = 1; | |||||
suborder.status=0; | |||||
QueryDB.AddSubOrder(suborder); | |||||
BusinessServer.Get().AddCommodity(suborder); | |||||
T.show(view.getContext(),"开始制作商品:"+goodname.getText().toString()); | T.show(view.getContext(),"开始制作商品:"+goodname.getText().toString()); | ||||
} | } | ||||
@@ -14,7 +14,10 @@ import android.widget.ListView; | |||||
import android.widget.TextView; | import android.widget.TextView; | ||||
import com.example.bpa.R; | import com.example.bpa.R; | ||||
import com.example.bpa.config.ConfigName; | |||||
import com.example.bpa.config.DataBus; | import com.example.bpa.config.DataBus; | ||||
import com.example.bpa.db.mode.BPA_ORDER; | |||||
import com.example.bpa.db.mode.BPA_SUBORDER; | |||||
import com.example.bpa.service.BusinessServer; | import com.example.bpa.service.BusinessServer; | ||||
import com.example.bpa.config.MessageName; | import com.example.bpa.config.MessageName; | ||||
import com.example.bpa.db.QueryDB; | import com.example.bpa.db.QueryDB; | ||||
@@ -180,7 +183,22 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList | |||||
T.show(this,"PLC未连接,不允许下单!"); | T.show(this,"PLC未连接,不允许下单!"); | ||||
return; | return; | ||||
} | } | ||||
BusinessServer.Get().AddCommodity(((BPA_GOODS) data).id); | |||||
BPA_ORDER order=new BPA_ORDER(); | |||||
order.thirdPartyID="手动下单"; | |||||
order.status=0; | |||||
order.deviceID = ConfigName.getInstance().DeviceId; | |||||
order.userID = ConfigName.getInstance().user.userID; | |||||
QueryDB.AddOrder(order); | |||||
BPA_SUBORDER suborder=new BPA_SUBORDER(); | |||||
suborder.deviceID = ConfigName.getInstance().DeviceId; | |||||
suborder.userID = ConfigName.getInstance().user.userID; | |||||
suborder.orderID = order.id; | |||||
suborder.goodsID = ((BPA_GOODS) data).id; | |||||
suborder.number = 1; | |||||
suborder.status=0; | |||||
QueryDB.AddSubOrder(suborder); | |||||
BusinessServer.Get().AddCommodity(suborder); | |||||
T.show(this, "下发成功!"); | T.show(this, "下发成功!"); | ||||
break; | break; | ||||
case R.id.button_qy://启用按钮 | case R.id.button_qy://启用按钮 | ||||
@@ -1,6 +1,7 @@ | |||||
package com.example.bpa.view.mode; | package com.example.bpa.view.mode; | ||||
import com.example.bpa.db.mode.BPA_GOODS; | import com.example.bpa.db.mode.BPA_GOODS; | ||||
import com.example.bpa.db.mode.BPA_SUBORDER; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
@@ -17,6 +18,10 @@ public class ResGoodsMake { | |||||
* 商品制作配方 | * 商品制作配方 | ||||
*/ | */ | ||||
public ArrayList<ResGoodsRecipe> recipes; | public ArrayList<ResGoodsRecipe> recipes; | ||||
/** | |||||
* 商品订单数据 | |||||
*/ | |||||
public BPA_SUBORDER subOrder; | |||||
/** | /** | ||||
* 制作状态 | * 制作状态 | ||||
*/ | */ | ||||
@@ -36,6 +41,7 @@ public class ResGoodsMake { | |||||
public ResGoodsMake() | public ResGoodsMake() | ||||
{ | { | ||||
good=new BPA_GOODS(); | good=new BPA_GOODS(); | ||||
subOrder=new BPA_SUBORDER(); | |||||
recipes=new ArrayList<>(); | recipes=new ArrayList<>(); | ||||
makeStatus=MakeStatus.等待制作; | makeStatus=MakeStatus.等待制作; | ||||
makeMs=""; | makeMs=""; | ||||
@@ -0,0 +1,20 @@ | |||||
package com.example.bpa.view.mode; | |||||
import com.example.bpa.db.mode.BPA_ORDER; | |||||
import com.example.bpa.db.mode.BPA_SUBORDER; | |||||
import java.util.List; | |||||
/** | |||||
* 接收订单Model | |||||
*/ | |||||
public class ResReceiveOrder { | |||||
/** | |||||
* 主订单 | |||||
*/ | |||||
public BPA_ORDER order; | |||||
/** | |||||
* 子订单 | |||||
*/ | |||||
public List<BPA_SUBORDER> subOrder; | |||||
} |