@@ -360,7 +360,7 @@ public class APIHelper { | |||
//设置请求头 | |||
connection.setRequestProperty("key", signkey); | |||
connection.setRequestProperty("sign", sign); | |||
// connection.setRequestProperty("sign", sign); | |||
//设置请求 body | |||
@@ -170,7 +170,6 @@ public class MainActivity extends AppCompatActivity { | |||
WeightHelper.Open(ConfigName.getInstance().Dishes_Com_Name, ConfigName.getInstance().Dishes_Com_Port,"8N1").OnSource(()->{ | |||
mRunning = true; | |||
WeightHelper.WeightNotify.ChangeNotify=((s)->{ | |||
// DataBus.getInstance().weight=s; | |||
this.runOnUiThread(()->{ | |||
if (s<50){ | |||
welcome.setVisibility(View.VISIBLE); | |||
@@ -180,17 +179,6 @@ public class MainActivity extends AppCompatActivity { | |||
} | |||
}); | |||
}); | |||
// WeightHelper.DataUpdate=(s)->{ | |||
// DataBus.getInstance().weight=s; | |||
// this.runOnUiThread(()->{ | |||
// if (DataBus.getInstance().weight<50){ | |||
// welcome.setVisibility(View.VISIBLE); | |||
// }else{ | |||
// welcome.setVisibility(View.GONE); | |||
// RefreshConsumption(); | |||
// } | |||
// }); | |||
// }; | |||
}).OnFailed(()->{ | |||
DialogManager.showError(this, "称重台通讯失败", AlertDialogButton.OK,null); | |||
mRunning = false; | |||
@@ -203,6 +191,7 @@ public class MainActivity extends AppCompatActivity { | |||
this.runOnUiThread(()->{ | |||
if(!code.isEmpty()&&!code.equals("无卡")){ | |||
DataBus.getInstance().CartNo=code; | |||
DataBus.getInstance().CurrentCart=code; | |||
ReadApiUserInformation(); | |||
MessageLog.ShowInfo("执行用户信息获取"); | |||
}else{ | |||
@@ -272,7 +261,8 @@ public class MainActivity extends AppCompatActivity { | |||
String orderId = DataBus.getInstance().weighOrderDto.id; | |||
String goodId = DataBus.getInstance().SelectFood.id; | |||
String goodsName=DataBus.getInstance().SelectFood.name; | |||
APIServer.CreateOrder(new AddGoodInfo(orderId,goodId,goodsName,DataBus.getInstance().xf_weight),null); | |||
String chipCode = DataBus.getInstance().CurrentCart; | |||
APIServer.CreateOrder(new AddGoodInfo(orderId,goodId,goodsName,DataBus.getInstance().xf_weight,chipCode),null,(error)->{T.show(MainActivity.this,error);}); | |||
}else | |||
{ | |||
DataBus.getInstance().xf_weight=0; | |||
@@ -307,6 +297,6 @@ public class MainActivity extends AppCompatActivity { | |||
DataBus.getInstance().xf_sjprice=0; | |||
RefreshConsumption(); | |||
}); | |||
}); | |||
},(error)->{T.show(MainActivity.this,error);}); | |||
} | |||
} |
@@ -96,26 +96,7 @@ public class MenuSelectionActivity extends AppCompatActivity{ | |||
} | |||
title.setText(ConfigName.getInstance().Shop_Name); | |||
}); | |||
// MessageLog.ShowInfo(s.toString()); | |||
// Convert.TryToList(s.data,FoodTypes[].class).OnSource(res->{ | |||
// DataBus.getInstance().foodTypes=res.Content; | |||
// types_key=new ArrayList<>(); | |||
// res.Content.forEach(item->{types_key.add(item.name);}); | |||
// this.runOnUiThread(()->{ | |||
// if(types_key.size()>0){ | |||
// adapter = new MyAdapter(DataBus.getInstance().dishesCon, types_key.toArray(new String[0])); | |||
// foods_types_name.setAdapter(adapter); | |||
// foods_types_name.setOnItemClickListener((adapterView, view, i, l)->{ | |||
// ItemClick(adapterView,view,i,l); | |||
// }); | |||
// ItemClick(null,null,0,0); | |||
// } | |||
// title.setText(ConfigName.getInstance().Shop_Name); | |||
// }); | |||
// }); | |||
}); | |||
},(error)->{T.show(MenuSelectionActivity.this,error);}); | |||
} | |||
@@ -11,6 +11,7 @@ import com.bpa.scalage.HBL.Interface.IRun; | |||
import com.bpa.scalage.HBL.Interface.IRunT; | |||
import com.bpa.scalage.HBL.Logs.MessageLog; | |||
import com.bpa.scalage.MainActivity; | |||
import com.bpa.scalage.MenuSelectionActivity; | |||
import com.bpa.scalage.R; | |||
import com.bpa.scalage.app.Main; | |||
import com.bpa.scalage.config.ConfigName; | |||
@@ -35,12 +36,15 @@ public class APIServer { | |||
/** | |||
* 获取菜品信息 | |||
*/ | |||
public static void GetDishInformation(IRunT<List<String>> callback){ | |||
public static void GetDishInformation(IRunT<List<String>> callback,IRunT<String> faultCallback){ | |||
String url = "http://192.168.1.50:5001/api/ExternalPlatform/WeighingService/GetGoodsInfo"; | |||
String key = "64059261-1599-472c-b418-3c18b4e3883e"; | |||
APIHelper.Post(url,new Object(),key,(s)->{ | |||
MessageLog.ShowInfo(s.toString()); | |||
if(s.errors!=null&&!s.errors.isEmpty()){ | |||
if(faultCallback!=null)faultCallback.Run(s.errors); | |||
} | |||
Convert.fromJson(s.data, FoodTypes[].class).OnSource(res->{ | |||
DataBus.getInstance().foodTypes= Arrays.asList(res.Content); | |||
List<String> types_key=new ArrayList<>(); | |||
@@ -53,13 +57,16 @@ public class APIServer { | |||
/** | |||
* 获取RFID和订单的信息 | |||
*/ | |||
public static void GetOrderInfo(String ChipCode,IRunT<WeighOrderDto> callback){ | |||
public static void GetOrderInfo(String ChipCode,IRunT<WeighOrderDto> callback,IRunT<String> faultCallback){ | |||
String url = "http://192.168.1.50:5003/api/ExternalPlatform/WeighOrder/GetWeighOrderByChipCode"; | |||
String key = "1bef8f66-1896-46ae-a724-101a709d5a26"; | |||
ChipCodeRequiredModel crm = new ChipCodeRequiredModel(ChipCode); | |||
APIHelper.Post(url,crm,key,(s)->{ | |||
MessageLog.ShowInfo(s.toString()); | |||
if(s.errors!=null&&!s.errors.isEmpty()){ | |||
if(faultCallback!=null)faultCallback.Run(s.errors); | |||
} | |||
Convert.fromJson(s.data, WeighOrderDto.class).OnSource(res->{ | |||
MessageLog.ShowInfo("解析数据成功"); | |||
DataBus.getInstance().weighOrderDto=res.Content; | |||
@@ -71,13 +78,16 @@ public class APIServer { | |||
/** | |||
* 添加商品子订单 | |||
*/ | |||
public static void CreateOrder(AddGoodInfo agi, IRun callback){ | |||
public static void CreateOrder(AddGoodInfo agi, IRun callback,IRunT<String> faultCallback){ | |||
String url = "http://192.168.1.50:5003/api/ExternalPlatform/WeighOrder/AddWeighOrderGoods"; | |||
String key = "1bef8f66-1896-46ae-a724-101a709d5a26"; | |||
AddGoodModel agm = new AddGoodModel(); | |||
agm.data.add(agi); | |||
APIHelper.Post(url,agm,key,(s)->{ | |||
MessageLog.ShowInfo(s.toString()); | |||
if(s.errors!=null&&!s.errors.isEmpty()){ | |||
if(faultCallback!=null)faultCallback.Run(s.errors); | |||
} | |||
if(callback!=null)callback.Run(); | |||
} ); | |||
} | |||
@@ -7,12 +7,14 @@ public class AddGoodInfo { | |||
public String goodsId; | |||
public String goodsName; | |||
public float goodsWeight; | |||
public String chipCode; | |||
public AddGoodInfo(String orderid, String goodsid, String goodsname, float goodsweight){ | |||
public AddGoodInfo(String orderid, String goodsid, String goodsname, float goodsweight,String chipcode){ | |||
orderId=orderid; | |||
goodsId=goodsid; | |||
goodsName=goodsname; | |||
goodsWeight=goodsweight; | |||
MessageLog.ShowInfo("通知子订单更新:orderId:"+orderid+",goodsId:"+goodsid+",goodsName:"+goodsname+",goodsWeight:"+goodsweight); | |||
chipCode=chipcode; | |||
MessageLog.ShowInfo("通知子订单更新:orderId:"+orderid+",goodsId:"+goodsid+",goodsName:"+goodsname+",goodsWeight:"+goodsweight+",chipCode:"+chipcode); | |||
} | |||
} |
@@ -49,6 +49,11 @@ public class DataBus { | |||
* 选中菜品 | |||
*/ | |||
public FoodModel SelectFood; | |||
/** | |||
* 当前餐盘卡号 | |||
*/ | |||
public String CurrentCart; | |||
//endregion | |||
//region 当前操作卡号 | |||