扫码支付
This commit is contained in:
parent
e016000bfc
commit
81a92c8b4f
|
|
@ -89,7 +89,7 @@ import com.ccb.facedevice.sdk.RecognizeCallback;
|
|||
import com.ccb.facedevice.sdk.data.ScanResult;
|
||||
import com.ccb.facedevice.sdk.utils.AppUtil;
|
||||
import com.ccb.facedevice.sdk.utils.FaceScanUtil;
|
||||
import com.ccb.facedevice.sdk.utils.UUIDUtil;
|
||||
import com.ccb.facedevice.sdk.utils.NetworkUtils;
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
import com.google.gson.Gson;
|
||||
import com.xuexiang.xui.XUI;
|
||||
|
|
@ -102,7 +102,6 @@ import org.easydarwin.easypusher.R;
|
|||
import org.easydarwin.easypusher.databinding.ActivityCanteenOperationBinding;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -112,7 +111,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.MediaType;
|
||||
|
|
@ -120,7 +118,7 @@ import okhttp3.Request;
|
|||
import okhttp3.RequestBody;
|
||||
|
||||
public class OperationActivity extends BaseActivity<ActivityCanteenOperationBinding> implements BottomNavigationView.OnNavigationItemSelectedListener,
|
||||
ClickUtils.OnClick2ExitListener, Toolbar.OnMenuItemClickListener{
|
||||
ClickUtils.OnClick2ExitListener, Toolbar.OnMenuItemClickListener {
|
||||
|
||||
private final String TAG = "OperationActivity_log";
|
||||
|
||||
|
|
@ -141,6 +139,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
private ListView salesListView;
|
||||
private GridView dishListView;
|
||||
AlertDialog alertDialog, pickUpYourMealDialog;
|
||||
|
||||
@Override
|
||||
protected ActivityCanteenOperationBinding viewBindingInflate(LayoutInflater inflater) {
|
||||
return ActivityCanteenOperationBinding.inflate(inflater);
|
||||
|
|
@ -176,7 +175,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
Log.d(TAG, "combineData: 开始组合支付数据");
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
String macOrderId = DateTimeHelper.getCurrentTimeStr() + AppUtil.getSn(this);
|
||||
|
||||
Log.d(TAG, "combineData macOrderId" + macOrderId);
|
||||
List<OrderPayAndroidDTO> orderList = new ArrayList<>();
|
||||
//获取所有餐单数据
|
||||
amount = getOrderData(amount, orderList);
|
||||
|
|
@ -197,12 +196,11 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
json.put("serialNum", carryGinseng);
|
||||
break;
|
||||
case 2:
|
||||
json.put("openid", carryGinseng);
|
||||
json.put("custId", "379163979848617984");
|
||||
json.put("openid", "000000" + custId);
|
||||
json.put("custId", custId);
|
||||
break;
|
||||
case 3:
|
||||
json.put("qrCode", carryGinseng);
|
||||
|
||||
json.put("custId", custId);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -221,62 +219,107 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
.addHeader("Authorization", "Bear " + OkHttpService.getToken())
|
||||
.addHeader("machine-sn", Objects.requireNonNull(AppUtil.getSn(this)))
|
||||
.addHeader("machine-num", AppDatabase.getDatabase(this).deviceBaseDao().getDeviceBase().get(0).getDeviceNum())
|
||||
.addHeader("MERCHANT-ID", AppDatabase.getDatabase(this).secretKeyDao().geSecretKey().get(0).getTenantId())
|
||||
.addHeader("source-type", "20")
|
||||
.post(body).build();
|
||||
|
||||
Log.d(TAG, "combineData: " + url);
|
||||
Log.d(TAG, "combineData:getSn " + Objects.requireNonNull(AppUtil.getSn(this)));
|
||||
Log.d(TAG, "combineData:getDeviceNum " + AppDatabase.getDatabase(this).deviceBaseDao().getDeviceBase().get(0).getDeviceNum());
|
||||
Log.d(TAG, "combineData:NetworkUtils.isNetworkConnected " + NetworkUtils.isNetworkConnected(this));
|
||||
boolean isConnected = NetworkUtils.isNetworkConnected(this);
|
||||
if (isConnected){
|
||||
//请求后台
|
||||
String result = service.httpPost(url, body, OperationActivity.this, request);
|
||||
Log.i("getPersonMessage result", result);
|
||||
if (!StringHelper.isEmptyAndNull(result)) {
|
||||
JSONObject firstJson = JSONObject.parseObject(result);
|
||||
String code = firstJson.getString("code");
|
||||
if (code.equals("200")) {
|
||||
runOnUiThread(() -> XToastUtils.success("支付成功"));
|
||||
FaceScanUtil.stopQrcodeScan(OperationActivity.this);
|
||||
myPresentation.unInitEngine();
|
||||
runOnUiThread(() -> {
|
||||
salesMenuEntityList.clear();
|
||||
setViewData(salesMenuEntityList,false);
|
||||
mSalesMenuAdapter.notifyDataSetChanged();
|
||||
});
|
||||
alertDialog.dismiss();
|
||||
}else{
|
||||
runOnUiThread(() -> XToastUtils.error(firstJson.getString("msg")));
|
||||
}
|
||||
}else{
|
||||
runOnUiThread(() -> XToastUtils.error("支付出错"));
|
||||
}
|
||||
}else{
|
||||
// TODO存储本地
|
||||
}
|
||||
|
||||
// String result = service.httpPost(url, body, OperationActivity.this, request);
|
||||
// Log.i("getPersonMessage result", result);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "支付出错:" + e.getMessage());
|
||||
XToastUtils.error("支付出错");
|
||||
runOnUiThread(() -> XToastUtils.error("支付出错"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private BigDecimal getOrderData(BigDecimal amount, List<OrderPayAndroidDTO> orderList) {
|
||||
String canteenId = AppDatabase.getDatabase(this).deviceBaseDao().getDeviceBase().get(0).getCanteenId();
|
||||
String canteenName = AppDatabase.getDatabase(this).deviceBaseDao().getDeviceBase().get(0).getCanteenName();
|
||||
String recipeList = AppDatabase.getDatabase(this).deviceBaseDao().getDeviceBase().get(0).getRecipeList();
|
||||
Log.d(TAG, "combineData: 开始获取订单数据");
|
||||
DeviceBaseInfo deviceBaseInfo = AppDatabase.getDatabase(this).deviceBaseDao().getDeviceBaseOne();
|
||||
Log.d(TAG, "combineData: deviceBaseInfo:" + deviceBaseInfo.toString());
|
||||
String canteenId = AppDatabase.getDatabase(this).deviceBaseDao().getDeviceBaseOne().getCanteenId();
|
||||
String canteenName = AppDatabase.getDatabase(this).deviceBaseDao().getDeviceBaseOne().getCanteenName();
|
||||
String recipeList = AppDatabase.getDatabase(this).deviceBaseDao().getDeviceBaseOne().getRecipeList();
|
||||
Log.d(TAG, "combineData canteenId" + canteenId);
|
||||
Log.d(TAG, "combineData canteenName" + canteenName);
|
||||
Log.d(TAG, "combineData recipeList" + recipeList);
|
||||
String stallId = "";
|
||||
String stallName = "";
|
||||
JSONArray jsonArray = JSON.parseArray(recipeList);
|
||||
if (jsonArray != null) {
|
||||
stallId = jsonArray.getJSONObject(0).getString("stallId");
|
||||
stallName = jsonArray.getJSONObject(0).getString("stallName");
|
||||
if (!Objects.isNull(recipeList)) {
|
||||
JSONArray jsonArray = JSON.parseArray(recipeList);
|
||||
if (jsonArray != null) {
|
||||
stallId = jsonArray.getJSONObject(0).getString("stallId");
|
||||
stallName = jsonArray.getJSONObject(0).getString("stallName");
|
||||
}
|
||||
}
|
||||
|
||||
Log.d(TAG, "combineData stallId" + stallId);
|
||||
Log.d(TAG, "combineData stallName" + stallName);
|
||||
//获取当前餐次
|
||||
CookMeetTimesInfo cookMeetTimesInfo = AppDatabase.getDatabase(this).cookMeetTimesDao().getDefaultCookMeetTime();
|
||||
OrderPayAndroidDTO orderPayAndroidDTO = new OrderPayAndroidDTO();
|
||||
orderPayAndroidDTO.setCanteenId(Long.parseLong(canteenId));
|
||||
orderPayAndroidDTO.setCanteenName(canteenName);
|
||||
//配送关联id(位置/取餐柜id)
|
||||
orderPayAndroidDTO.setDeliveryRelatedId(0L);
|
||||
//餐次类型(1:早餐 2:午餐 3:下午茶 4:晚餐 5:宵夜)
|
||||
orderPayAndroidDTO.setMealtimeName("早餐");
|
||||
orderPayAndroidDTO.setMealtimeType(1);
|
||||
orderPayAndroidDTO.setOrderTime(LocalDateTime.now());
|
||||
orderPayAndroidDTO.setMealtimeName(cookMeetTimesInfo.getIntervalName());
|
||||
orderPayAndroidDTO.setMealtimeType(Integer.valueOf(cookMeetTimesInfo.getIntervalId()));
|
||||
orderPayAndroidDTO.setOrderTime(DateTimeHelper.getTime());
|
||||
orderPayAndroidDTO.setPlaceId(0);
|
||||
orderPayAndroidDTO.setStallId(Objects.equals(stallId, "") ? 0 : Long.parseLong(stallId));
|
||||
orderPayAndroidDTO.setStallName(stallName);
|
||||
Log.d(TAG, "combineData: " + orderPayAndroidDTO.toString());
|
||||
List<OrderDetailPayDTO> orderDetailList = new ArrayList<>();
|
||||
for (SalesMenuEntity bean : salesMenuEntityList) {
|
||||
CookMeetMealInfo cookMeetMealInfo = AppDatabase.getDatabase(this).cookMeetMealDao().getCookMeetMealById(bean.getId());
|
||||
CookMeetDetailInfo cookMeetDetailInfo = AppDatabase.getDatabase(this).cookMeetDetailDao().getCookMeetDetailByDishId(bean.getId());
|
||||
int isKeyboard = bean.getName().equals("按键金额") ? 1 : 0;
|
||||
amount = amount.add(bean.getSubtotal());
|
||||
OrderDetailPayDTO orderDetailPayDTO = new OrderDetailPayDTO();
|
||||
orderDetailPayDTO.setDetailType(1);
|
||||
orderDetailPayDTO.setGoodsDishesId(Long.parseLong(bean.getId()));
|
||||
orderDetailPayDTO.setDetailType(isKeyboard == 1 ? 4 : 1);
|
||||
orderDetailPayDTO.setGoodsDishesId(isKeyboard == 1 ? -1 : Long.parseLong(bean.getId()));
|
||||
orderDetailPayDTO.setGoodsDishesName(bean.getName());
|
||||
orderDetailPayDTO.setMenuDetailId(Long.parseLong(bean.getId()));
|
||||
orderDetailPayDTO.setMenuDetailId(isKeyboard == 1 ? -1 : Long.valueOf(cookMeetDetailInfo.getDetailId()));
|
||||
orderDetailPayDTO.setQuantity(bean.getNum().intValue());
|
||||
orderDetailPayDTO.setSalePrice(bean.getPrice());
|
||||
orderDetailPayDTO.setSalesMode(1);
|
||||
orderDetailPayDTO.setWeightUnit(100);
|
||||
orderDetailPayDTO.setSalePrice(bean.getPrice().multiply(BigDecimal.valueOf(100)));
|
||||
orderDetailPayDTO.setSalesMode(isKeyboard == 1 ? 1 : Integer.valueOf(cookMeetMealInfo.getSalseMode()));
|
||||
orderDetailPayDTO.setWeightUnit(isKeyboard == 1 ? 100 :Integer.valueOf(cookMeetMealInfo.getWeight()));
|
||||
orderDetailList.add(orderDetailPayDTO);
|
||||
}
|
||||
orderPayAndroidDTO.setOrderDetailList(orderDetailList);
|
||||
Log.d(TAG, "combineData: orderPayAndroidDTO.toString()" + orderPayAndroidDTO.toString());
|
||||
Log.d(TAG, "combineData: amount" + amount);
|
||||
orderList.add(orderPayAndroidDTO);
|
||||
return amount;
|
||||
}
|
||||
|
|
@ -297,10 +340,11 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
//组合数据
|
||||
com.alibaba.fastjson2.JSONObject jsonObject = null;
|
||||
try {
|
||||
jsonObject = JSON.parseObject(scanResult.getQRCodeString().replace("xnzn", ""));
|
||||
jsonObject = JSON.parseObject(scanResult.getQRCodeString().replaceAll("xnzn", ""));
|
||||
Log.d(TAG, "onRecognized: 扫码 onRecognized--jsonObject:" + jsonObject.toJSONString());
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "onRecognized: 扫码 onRecognized--jsonObject: 不是一个json");
|
||||
return;
|
||||
}
|
||||
Long custId = 0L;
|
||||
try {
|
||||
|
|
@ -309,6 +353,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
if (custId == null) {
|
||||
XToastUtils.error("请使用正确的二维码");
|
||||
Log.e(TAG, "onRecognized:解析数据获取custId--scanResult : json中不包含custId");
|
||||
return;
|
||||
}
|
||||
Log.e(TAG, "onRecognized:解析数据获取custId--custId :" + custId);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -316,14 +361,15 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
Log.e(TAG, "onRecognized:解析数据获取custId--scanResult :" + scanResult.getQRCodeString());
|
||||
Log.e(TAG, "onRecognized:解析数据获取custId--scanResult : json中不包含custId");
|
||||
XToastUtils.error("请使用正确的二维码");
|
||||
return;
|
||||
}
|
||||
combineData(3, scanResult.getQRCodeString(), custId);
|
||||
Long finalCustId = custId;
|
||||
ThreadPoolManager.getExecutor().execute(() -> combineData(3, scanResult.getQRCodeString(), finalCustId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String errCode, String errMsg) {
|
||||
//关闭扫码
|
||||
FaceScanUtil.stopQrcodeScan(OperationActivity.this);
|
||||
Log.e(TAG, "onRecognized: 扫码 onError:" + errMsg);
|
||||
}
|
||||
|
||||
|
|
@ -336,6 +382,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
public void onCancel() {
|
||||
//关闭扫码
|
||||
FaceScanUtil.stopQrcodeScan(OperationActivity.this);
|
||||
myPresentation.unInitEngine();
|
||||
Log.e(TAG, "onRecognized: 扫码:onCancel");
|
||||
}
|
||||
});
|
||||
|
|
@ -409,9 +456,9 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
FormBody body = new FormBody.Builder()
|
||||
.build();
|
||||
// String result = service.httpPost(WorkConfig.getBaseUrl() + UrlConfig.BIND_INFO_CONFIG, body, OperationActivity.this);
|
||||
// String result = AppDatabase.getDatabase(OperationActivity.this).cookBookDao().getCookBook().get(0).getJsonStr();
|
||||
List<CookBookInfo> cookBookInfoList = AppDatabase.getDatabase(OperationActivity.this).cookBookDao().getCookBook();
|
||||
// String result = service.httpPost(WorkConfig.getBaseUrl() + UrlConfig.BIND_INFO_CONFIG, body, OperationActivity.this);
|
||||
// String result = AppDatabase.getDatabase(OperationActivity.this).cookBookDao().getCookBook().get(0).getJsonStr();
|
||||
List<CookBookInfo> cookBookInfoList = AppDatabase.getDatabase(OperationActivity.this).cookBookDao().getCookBook();
|
||||
String result = "";
|
||||
String recipeId = "";
|
||||
String recipeType = "";
|
||||
|
|
@ -424,60 +471,60 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
List<String> mealList = new ArrayList<>();
|
||||
|
||||
Map allMap = new HashMap();
|
||||
if(cookBookInfoList !=null && cookBookInfoList.size()>0){
|
||||
if (cookBookInfoList != null && cookBookInfoList.size() > 0) {
|
||||
recipeId = cookBookInfoList.get(0).getRecipeId();
|
||||
recipeType = cookBookInfoList.get(0).getRecipeType();
|
||||
uptime = cookBookInfoList.get(0).getUptime();
|
||||
allMap.put("recipeId",recipeId);
|
||||
allMap.put("recipeType",recipeType);
|
||||
allMap.put("uptime",uptime);
|
||||
allMap.put("recipeId", recipeId);
|
||||
allMap.put("recipeType", recipeType);
|
||||
allMap.put("uptime", uptime);
|
||||
|
||||
Map dateListMap = new HashMap();
|
||||
List<Map> dateList = new ArrayList<>();
|
||||
CookMeetTimesInfo cookMeetTimesInfo = AppDatabase.getDatabase(OperationActivity.this).cookMeetTimesDao().getDefaultCookMeetTime();
|
||||
if(cookMeetTimesInfo !=null ){
|
||||
dateListMap.put("applyDate",nowDate);
|
||||
if (cookMeetTimesInfo != null) {
|
||||
dateListMap.put("applyDate", nowDate);
|
||||
intervalId = cookMeetTimesInfo.getIntervalId();
|
||||
intervalName = cookMeetTimesInfo.getIntervalName();
|
||||
startTime = cookMeetTimesInfo.getStartTime();
|
||||
endTime = cookMeetTimesInfo.getEndTime();
|
||||
Map intervalListMap = new HashMap();
|
||||
List<Map> iproductList = new ArrayList<>();
|
||||
List<CookMeetDetailInfo> cookMeetDetailInfoList = AppDatabase.getDatabase(OperationActivity.this).cookMeetDetailDao().getCookMeetDetailByIntervalId(intervalId,nowDate);
|
||||
for (CookMeetDetailInfo b:cookMeetDetailInfoList) {
|
||||
String detailId = b.getDetailId();
|
||||
List<CookMeetDetailInfo> cookMeetDetailInfoList = AppDatabase.getDatabase(OperationActivity.this).cookMeetDetailDao().getCookMeetDetailByIntervalId(intervalId, nowDate);
|
||||
for (CookMeetDetailInfo b : cookMeetDetailInfoList) {
|
||||
String detailId = b.getDetailId();
|
||||
String dishesId = b.getDishesId();
|
||||
String prefPrice = b.getPrefPrice();
|
||||
String salePrice = b.getSalePrice();
|
||||
Map productListMap = new HashMap();
|
||||
productListMap.put("detailId",detailId);
|
||||
productListMap.put("dishesId",dishesId);
|
||||
productListMap.put("prefPrice",prefPrice);
|
||||
productListMap.put("salePrice",salePrice);
|
||||
productListMap.put("detailId", detailId);
|
||||
productListMap.put("dishesId", dishesId);
|
||||
productListMap.put("prefPrice", prefPrice);
|
||||
productListMap.put("salePrice", salePrice);
|
||||
mealList.add(dishesId);
|
||||
iproductList.add(productListMap);
|
||||
}
|
||||
intervalListMap.put("intervalId",intervalId);
|
||||
intervalListMap.put("intervalName",intervalName);
|
||||
intervalListMap.put("startTime",startTime);
|
||||
intervalListMap.put("endTime",endTime);
|
||||
intervalListMap.put("productList",iproductList);
|
||||
dateListMap.put("intervalList",intervalListMap);
|
||||
intervalListMap.put("intervalId", intervalId);
|
||||
intervalListMap.put("intervalName", intervalName);
|
||||
intervalListMap.put("startTime", startTime);
|
||||
intervalListMap.put("endTime", endTime);
|
||||
intervalListMap.put("productList", iproductList);
|
||||
dateListMap.put("intervalList", intervalListMap);
|
||||
dateList.add(dateListMap);
|
||||
allMap.put("dateList",dateList);
|
||||
allMap.put("dateList", dateList);
|
||||
List<CookMeetMealInfo> cookMeetMealInfoList = new ArrayList<>();
|
||||
for(String str : mealList){
|
||||
CookMeetMealInfo cookMeetMealInfo = AppDatabase.getDatabase(OperationActivity.this).cookMeetMealDao().getCookMeetMealById(str);
|
||||
for (String str : mealList) {
|
||||
CookMeetMealInfo cookMeetMealInfo = AppDatabase.getDatabase(OperationActivity.this).cookMeetMealDao().getCookMeetMealById(str);
|
||||
cookMeetMealInfoList.add(cookMeetMealInfo);
|
||||
}
|
||||
allMap.put("mealList",cookMeetMealInfoList);
|
||||
allMap.put("mealList", cookMeetMealInfoList);
|
||||
Gson gson = new Gson();
|
||||
result = gson.toJson(allMap);
|
||||
Log.e("result",result);
|
||||
}else {
|
||||
result = gson.toJson(allMap);
|
||||
Log.e("result", result);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "initMenuData result:" + result);
|
||||
|
|
@ -534,6 +581,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
}
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "initMenuData dishEntityList:" + dishEntityList.toString());
|
||||
mDishListAdapter = new DishListAdapter(OperationActivity.this, dishEntityList, salesMenuEntityList, mSalesMenuAdapter);
|
||||
dishListView.setAdapter(mDishListAdapter);
|
||||
mDishListAdapter.notifyDataSetChanged();
|
||||
|
|
@ -556,7 +604,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
textView.setTextColor(getResources().getColor(R.color.app_color_grey));
|
||||
if (originalTypeId == -1 && item.getTypeId() == 0) {
|
||||
textView.setTextColor(getResources().getColor(R.color.app_color_theme_2));
|
||||
}else{
|
||||
} else {
|
||||
if (item.getTypeId().equals(originalTypeId)) {
|
||||
textView.setTextColor(getResources().getColor(R.color.app_color_theme_2));
|
||||
}
|
||||
|
|
@ -696,7 +744,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
orderInfo.setOrderDate(orderDate);
|
||||
orderInfo.setCanteenId(deviceBaseInfo.getCanteenId());
|
||||
orderInfo.setCanteenName(deviceBaseInfo.getCanteenName());
|
||||
|
||||
|
||||
|
||||
OrderListEntity orderList ;
|
||||
if(orderListEntities !=null && orderListEntities.size()>0){
|
||||
|
|
@ -789,8 +837,9 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
binding.keyboardMain.findViewById(R.id.tv_ok).setOnClickListener(view -> {
|
||||
if (premiumAmount.toString().isEmpty() && !salesMenuEntityList.isEmpty()) {
|
||||
//弹出支付弹窗 可取消支付 或 记账
|
||||
openScan();
|
||||
openDialog();
|
||||
openScan();
|
||||
myPresentation.startScan();
|
||||
return;
|
||||
} else if (premiumAmount.toString().isEmpty() && salesMenuEntityList.isEmpty()) {
|
||||
XToastUtils.warning("请先点餐!");
|
||||
|
|
@ -804,7 +853,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
}
|
||||
sum = Double.parseDouble(String.format("%.2f", sum));
|
||||
SalesMenuEntity salesMenuEntity = new SalesMenuEntity();
|
||||
salesMenuEntity.setId(UUID.randomUUID().toString());
|
||||
salesMenuEntity.setId("-1");
|
||||
salesMenuEntity.setName("按键金额");
|
||||
salesMenuEntity.setNum(BigDecimal.valueOf(1));
|
||||
salesMenuEntity.setPrice(BigDecimal.valueOf(sum));
|
||||
|
|
@ -842,7 +891,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
if (".".equals(currentNum)) {
|
||||
handleDecimalPoint();
|
||||
} else {
|
||||
if (premiumAmount.length() > 5){
|
||||
if (premiumAmount.length() > 5) {
|
||||
return;
|
||||
}
|
||||
// 直接添加数字
|
||||
|
|
@ -863,7 +912,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
}
|
||||
|
||||
private void handleDecimalPoint() {
|
||||
if (premiumAmount.length() > 5){
|
||||
if (premiumAmount.length() > 5) {
|
||||
return;
|
||||
}
|
||||
int lastPlusIndex = premiumAmount.lastIndexOf("+");
|
||||
|
|
@ -938,7 +987,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
}
|
||||
// BigDecimal dueMoney = salesAmountDueMoney.subtract(salesDiscountAmountMoney);
|
||||
BigDecimal dueMoney = salesAmountDueMoney;
|
||||
if (dueMoney.compareTo(BigDecimal.ZERO) < 0){
|
||||
if (dueMoney.compareTo(BigDecimal.ZERO) < 0) {
|
||||
dueMoney = BigDecimal.ZERO;
|
||||
}
|
||||
binding.salesNumber.setText("总数量:" + salesNumber + "份");
|
||||
|
|
@ -995,7 +1044,12 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
tipTitle.setText("支付失败");
|
||||
});
|
||||
//取消支付
|
||||
payCancel.setOnClickListener(v -> alertDialog.dismiss());
|
||||
payCancel.setOnClickListener(v -> {
|
||||
FaceScanUtil.stopQrcodeScan(OperationActivity.this);
|
||||
myPresentation.unInitEngine();
|
||||
alertDialog.dismiss();
|
||||
|
||||
});
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.show();
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class DishListAdapter extends BaseAdapter {
|
|||
|
||||
SalesMenuAdapter mSalesMenuAdapter;
|
||||
|
||||
public DishListAdapter(Context ctx, List<DishEntity> lst, List<SalesMenuEntity> salesMenuEntityList, SalesMenuAdapter mSalesMenuAdapter) {
|
||||
public DishListAdapter(Context ctx, List<DishEntity> lst, List<SalesMenuEntity> salesMenuEntityList, SalesMenuAdapter mSalesMenuAdapter) {
|
||||
super();
|
||||
this.context = ctx;
|
||||
this.list = lst;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ public class DateTimeHelper {
|
|||
public static String getNowTime(){
|
||||
return format(new Date(),"HH:mm:ss");
|
||||
}
|
||||
public static String getTime(){
|
||||
return format(new Date(),"YYYY-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
public static String getNowDate(){
|
||||
return format(new Date(),"YYYY-MM-dd");
|
||||
|
|
|
|||
|
|
@ -1,21 +1,23 @@
|
|||
package com.bonus.canteen.db.dao.base;
|
||||
|
||||
|
||||
import com.bonus.canteen.db.entity.base.CookMeetDetailInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Delete;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Update;
|
||||
|
||||
import com.bonus.canteen.db.entity.base.CookMeetDetailInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface CookMeetDetailDao {
|
||||
|
||||
@Query("select * from cook_meet_detail_info where id=:id")
|
||||
CookMeetDetailInfo getCookMeetDetailById(String id);
|
||||
@Query("select * from cook_meet_detail_info where dishesId=:dishesId")
|
||||
CookMeetDetailInfo getCookMeetDetailByDishId(String dishesId);
|
||||
|
||||
@Query("select * from cook_meet_detail_info")
|
||||
List<CookMeetDetailInfo> getCookMeetDetail();
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
package com.bonus.canteen.db.dao.base;
|
||||
|
||||
|
||||
import com.bonus.canteen.db.entity.base.DeviceBaseInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Delete;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Update;
|
||||
|
||||
import com.bonus.canteen.db.entity.base.DeviceBaseInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface DeviceBaseDao {
|
||||
|
||||
|
|
@ -20,6 +20,9 @@ public interface DeviceBaseDao {
|
|||
@Query("select * from device_base")
|
||||
List<DeviceBaseInfo> getDeviceBase();
|
||||
|
||||
@Query("select * from device_base limit 1")
|
||||
DeviceBaseInfo getDeviceBaseOne();
|
||||
|
||||
@Insert
|
||||
void insert(DeviceBaseInfo device); // 插入数据
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.bonus.canteen.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public class OrderPayAndroidDTO {
|
||||
|
|
@ -13,7 +12,7 @@ public class OrderPayAndroidDTO {
|
|||
private Long deliveryRelatedId;
|
||||
private List<OrderDetailPayDTO> orderDetailList;
|
||||
|
||||
private LocalDateTime orderTime;
|
||||
private String orderTime;
|
||||
|
||||
private Integer placeId;
|
||||
|
||||
|
|
@ -89,11 +88,27 @@ public class OrderPayAndroidDTO {
|
|||
this.orderDetailList = orderDetailList;
|
||||
}
|
||||
|
||||
public LocalDateTime getOrderTime() {
|
||||
public String getOrderTime() {
|
||||
return orderTime;
|
||||
}
|
||||
|
||||
public void setOrderTime(LocalDateTime orderTime) {
|
||||
public void setOrderTime(String orderTime) {
|
||||
this.orderTime = orderTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderPayAndroidDTO{" +
|
||||
"canteenId=" + canteenId +
|
||||
", canteenName='" + canteenName + '\'' +
|
||||
", stallId=" + stallId +
|
||||
", stallName='" + stallName + '\'' +
|
||||
", mealtimeType=" + mealtimeType +
|
||||
", mealtimeName='" + mealtimeName + '\'' +
|
||||
", deliveryRelatedId=" + deliveryRelatedId +
|
||||
", orderDetailList=" + orderDetailList +
|
||||
", orderTime=" + orderTime +
|
||||
", placeId=" + placeId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package com.bonus.canteen.presentation;
|
||||
|
||||
import static com.xuexiang.xutil.XUtil.runOnUiThread;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Presentation;
|
||||
|
|
@ -32,11 +34,13 @@ import android.view.Surface;
|
|||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.arcsoft.face.AgeInfo;
|
||||
import com.arcsoft.face.ErrorInfo;
|
||||
|
|
@ -47,6 +51,7 @@ import com.arcsoft.face.GenderInfo;
|
|||
import com.arcsoft.face.LivenessInfo;
|
||||
import com.arcsoft.face.enums.DetectFaceOrientPriority;
|
||||
import com.arcsoft.face.enums.DetectMode;
|
||||
import com.bonus.canteen.activity.OperationActivity;
|
||||
import com.bonus.canteen.adapter.menu.PayMenuAdapter;
|
||||
import com.bonus.canteen.adapter.menu.entity.SalesMenuEntity;
|
||||
import com.bonus.canteen.db.AppDatabase;
|
||||
|
|
@ -182,9 +187,13 @@ public class MyPresentation extends Presentation {
|
|||
private List<CompareResult> compareResultList;
|
||||
private FaceSearchResultAdapter adapter;
|
||||
|
||||
private TextView tvPayNum, tvPayTotalPrice, tvPayDiscount, tvPayTotalPricePay,payTips,
|
||||
private TextView tvPayNum, tvPayTotalPrice, tvPayDiscount, tvPayTotalPricePay, payTips,
|
||||
tvCalories, tvProtein, tvFat, tvSodium, tvCarbohydrate;
|
||||
|
||||
private ImageView faceImg;
|
||||
|
||||
private ConstraintLayout faceScan;
|
||||
|
||||
|
||||
public void setSalesData(List<SalesMenuEntity> rawData) {
|
||||
Log.d(TAG, "setViewData: 进入副屏");
|
||||
|
|
@ -211,7 +220,6 @@ public class MyPresentation extends Presentation {
|
|||
BigDecimal carbohydrate = new BigDecimal(0);
|
||||
|
||||
|
||||
|
||||
for (SalesMenuEntity entity : rawData) {
|
||||
Log.d(TAG, "setMoneyAndNutrition: " + entity.toString());
|
||||
num = num.add(entity.getNum());
|
||||
|
|
@ -224,7 +232,7 @@ public class MyPresentation extends Presentation {
|
|||
carbohydrate = carbohydrate.add(entity.getCarbohydrate());
|
||||
}
|
||||
BigDecimal payMoney = money.subtract(preferential);
|
||||
if (payMoney.compareTo(BigDecimal.ZERO) < 0){
|
||||
if (payMoney.compareTo(BigDecimal.ZERO) < 0) {
|
||||
payMoney = BigDecimal.ZERO;
|
||||
}
|
||||
tvPayNum.setText("总数量:" + num + "份");
|
||||
|
|
@ -305,6 +313,9 @@ public class MyPresentation extends Presentation {
|
|||
tvFat = findViewById(R.id.tv_fat);
|
||||
tvSodium = findViewById(R.id.tv_sodium);
|
||||
tvCarbohydrate = findViewById(R.id.tv_carbohydrate);
|
||||
|
||||
faceImg = findViewById(R.id.face_img);
|
||||
faceScan = findViewById(R.id.face_scan);
|
||||
}
|
||||
|
||||
private void checkPermissions(String[] neededPermissions) {
|
||||
|
|
@ -375,8 +386,6 @@ public class MyPresentation extends Presentation {
|
|||
int code = FaceEngine.activeOnline(context, APP_ID, SDK_KEY);
|
||||
if (code == ErrorInfo.MOK) {
|
||||
Log.i(TAG, "activeOnline success");
|
||||
initEngine();
|
||||
initCamera();
|
||||
// if (cameraHelper != null) {
|
||||
// boolean success = cameraHelper.switchCamera();
|
||||
// if (!success) {
|
||||
|
|
@ -395,18 +404,21 @@ public class MyPresentation extends Presentation {
|
|||
}
|
||||
|
||||
private void initEngine() {
|
||||
ftEngine = new FaceEngine();
|
||||
ftInitCode = ftEngine.init(context, DetectMode.ASF_DETECT_MODE_VIDEO, DetectFaceOrientPriority.ASF_OP_0_ONLY,
|
||||
16, MAX_DETECT_NUM, FaceEngine.ASF_FACE_DETECT);
|
||||
|
||||
frEngine = new FaceEngine();
|
||||
frInitCode = frEngine.init(context, DetectMode.ASF_DETECT_MODE_IMAGE, DetectFaceOrientPriority.ASF_OP_0_ONLY,
|
||||
16, MAX_DETECT_NUM, FaceEngine.ASF_FACE_RECOGNITION);
|
||||
|
||||
flEngine = new FaceEngine();
|
||||
flInitCode = flEngine.init(context, DetectMode.ASF_DETECT_MODE_IMAGE, DetectFaceOrientPriority.ASF_OP_0_ONLY,
|
||||
16, MAX_DETECT_NUM, FaceEngine.ASF_LIVENESS);
|
||||
|
||||
if (ftInitCode == -1) {
|
||||
ftEngine = new FaceEngine();
|
||||
ftInitCode = ftEngine.init(context, DetectMode.ASF_DETECT_MODE_VIDEO, DetectFaceOrientPriority.ASF_OP_0_ONLY,
|
||||
16, MAX_DETECT_NUM, FaceEngine.ASF_FACE_DETECT);
|
||||
}
|
||||
if (frInitCode == -1) {
|
||||
frEngine = new FaceEngine();
|
||||
frInitCode = frEngine.init(context, DetectMode.ASF_DETECT_MODE_IMAGE, DetectFaceOrientPriority.ASF_OP_0_ONLY,
|
||||
16, MAX_DETECT_NUM, FaceEngine.ASF_FACE_RECOGNITION);
|
||||
}
|
||||
if (flInitCode == -1) {
|
||||
flEngine = new FaceEngine();
|
||||
flInitCode = flEngine.init(context, DetectMode.ASF_DETECT_MODE_IMAGE, DetectFaceOrientPriority.ASF_OP_0_ONLY,
|
||||
16, MAX_DETECT_NUM, FaceEngine.ASF_LIVENESS);
|
||||
}
|
||||
Log.i(TAG, "initEngine: ftInitCode: " + ftInitCode);
|
||||
Log.i(TAG, "initEngine: frInitCode: " + frInitCode);
|
||||
Log.i(TAG, "initEngine: flInitCode: " + flInitCode);
|
||||
|
|
@ -425,19 +437,49 @@ public class MyPresentation extends Presentation {
|
|||
}
|
||||
}
|
||||
|
||||
private void unInitEngine() {
|
||||
public void unInitEngine() {
|
||||
|
||||
if (afCode == 0) {
|
||||
runOnUiThread(() -> {
|
||||
faceImg.setVisibility(View.VISIBLE);
|
||||
faceScan.setVisibility(View.GONE);
|
||||
});
|
||||
|
||||
int afCode = -1;
|
||||
Log.i("scan", "卸载人脸引擎");
|
||||
if (ftInitCode == 0) {
|
||||
Log.i("scan", "开始卸载人脸引擎-ftInitCode");
|
||||
afCode = ftEngine.unInit();
|
||||
afCode = frEngine.unInit();
|
||||
afCode = flEngine.unInit();
|
||||
ftInitCode = -1;
|
||||
Log.i(TAG, "unInitEngine: " + afCode);
|
||||
}
|
||||
if (frInitCode == 0) {
|
||||
Log.i("scan", "开始卸载人脸引擎-frInitCode");
|
||||
afCode = frEngine.unInit();
|
||||
frInitCode = -1;
|
||||
Log.i(TAG, "unInitEngine: " + afCode);
|
||||
}
|
||||
if (flInitCode == 0) {
|
||||
Log.i("scan", "开始卸载人脸引擎-flInitCode");
|
||||
afCode = flEngine.unInit();
|
||||
flInitCode = -1;
|
||||
Log.i(TAG, "unInitEngine: " + afCode);
|
||||
}
|
||||
|
||||
cameraHelper.release();
|
||||
cameraHelper = null;
|
||||
faceHelper = null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initCamera() {
|
||||
livenessMap = new ConcurrentHashMap<>();
|
||||
requestFeatureStatusMap = new ConcurrentHashMap<>();
|
||||
extractErrorRetryMap = new ConcurrentHashMap<>();
|
||||
livenessErrorRetryMap = new ConcurrentHashMap<>();
|
||||
delayFaceTaskCompositeDisposable = new CompositeDisposable();
|
||||
getFeatureDelayedDisposables = new CompositeDisposable();
|
||||
Log.i(TAG, "initCamera: 开始初始化");
|
||||
|
||||
final FaceListener faceListener = new FaceListener() {
|
||||
@Override
|
||||
public void onFail(Exception e) {
|
||||
|
|
@ -556,7 +598,6 @@ public class MyPresentation extends Presentation {
|
|||
|
||||
};
|
||||
|
||||
|
||||
CameraListener cameraListener = new CameraListener() {
|
||||
@Override
|
||||
public void onCameraOpened(Camera camera, int cameraId, int displayOrientation, boolean isMirror) {
|
||||
|
|
@ -692,6 +733,19 @@ public class MyPresentation extends Presentation {
|
|||
cameraHelper.start();
|
||||
}
|
||||
|
||||
public void startScan() {
|
||||
if (ftInitCode == 0) {
|
||||
return;
|
||||
}
|
||||
faceImg.setVisibility(View.GONE);
|
||||
faceScan.setVisibility(View.VISIBLE);
|
||||
Log.i("scan", "开启人脸扫描");
|
||||
initEngine();
|
||||
initCamera();
|
||||
Log.i("scan", "开启人脸扫描结束");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将map中key对应的value增1回传
|
||||
*
|
||||
|
|
@ -926,6 +980,8 @@ public class MyPresentation extends Presentation {
|
|||
if (faceHelper != null) {
|
||||
String name = AppDatabase.getDatabase(context).custInfoDao().getCustInfoByCustId(compareResult.getCustId()).getCustName();
|
||||
faceHelper.setName(requestId, "通过:" + name);
|
||||
OperationActivity operationActivity = (OperationActivity) context;
|
||||
operationActivity.combineData(2, compareResult.getCustId(), Long.valueOf(compareResult.getCustId()));
|
||||
Log.d(TAG, requestId + " 通过:" + name);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 89 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 404 KiB |
|
|
@ -23,6 +23,13 @@
|
|||
android:baselineAligned="false">
|
||||
|
||||
<!-- 左侧商品明细 -->
|
||||
<Switch
|
||||
android:id="@+id/switch1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Switch" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/left_panel"
|
||||
android:layout_width="0dp"
|
||||
|
|
@ -330,11 +337,19 @@
|
|||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/face_img"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="TODO"
|
||||
android:src="@drawable/mask_presentation_bg"
|
||||
/>
|
||||
<!-- 扫描框 -->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/face_scan"
|
||||
android:visibility="gone"
|
||||
android:background="#4DA9A9A9">
|
||||
<!-- 支付提示 -->
|
||||
<TextView
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.READ_BASIC_PHONE_STATE" />
|
||||
</manifest>
|
||||
|
|
@ -6,7 +6,6 @@ import android.text.TextUtils;
|
|||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
|
|
@ -99,15 +98,21 @@ public class SerialQrManage {
|
|||
return;
|
||||
}
|
||||
|
||||
index =0;
|
||||
while (isWorking) {
|
||||
try {
|
||||
int recv = mFileInputStream.read(buffer, index, buffer.length - index);
|
||||
Log.d("buffer",""+buffer.length);
|
||||
Log.d("buffer2",""+buffer2.length);
|
||||
Log.d("buffer recv",""+recv);
|
||||
Log.d("buffer index",""+index);
|
||||
if (recv > 0) {
|
||||
if (buffer[index + recv - 1] == 0x0D || buffer[index + recv - 1] == 0x0A) {
|
||||
//回车符
|
||||
byte[] temp = new byte[index + recv];
|
||||
System.arraycopy(buffer, 0, temp, 0, temp.length - 1);
|
||||
String barCode = new String(temp);
|
||||
Log.d("buffer barCode",""+barCode);
|
||||
//清空缓冲区
|
||||
index = 0;
|
||||
System.arraycopy(buffer2, 0, buffer, 0, buffer.length);
|
||||
|
|
@ -121,6 +126,7 @@ public class SerialQrManage {
|
|||
}
|
||||
sleep(50);
|
||||
} catch (Exception e) {
|
||||
Log.d("buffer Exception",""+e.getMessage());
|
||||
index = 0;
|
||||
try {
|
||||
for (int i = 0; i < buffer.length; ++i) {
|
||||
|
|
@ -145,6 +151,7 @@ public class SerialQrManage {
|
|||
|
||||
}
|
||||
try {
|
||||
mFileOutputStream.flush();
|
||||
mFileOutputStream.close();
|
||||
} catch (Exception ex) {
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import android.content.Context;
|
|||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.ccb.facedevice.sdk.RecognizeCallback;
|
||||
|
||||
import com.ccb.facedevice.sdk.cardreader.base.IReader;
|
||||
import com.ccb.facedevice.sdk.cardreader.config.ReaderConfig;
|
||||
import com.ccb.facedevice.sdk.cardreader.constant.ReaderConstant;
|
||||
|
|
@ -119,9 +119,6 @@ public class FaceScanUtil {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void initFace(Context context) {
|
||||
ThreadUtil.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
|
|
@ -228,12 +225,14 @@ public class FaceScanUtil {
|
|||
|
||||
private static synchronized void maybeCreateQrCodeScanner() {
|
||||
if (serialQrManage == null) {
|
||||
Log.e("onRecognized", "maybeCreateQrCodeScanner: serialQrManage == null" );
|
||||
String path = "/dev/ttyS4";
|
||||
int baudrate = 9600;
|
||||
serialQrManage = new SerialQrManage(path, baudrate);
|
||||
serialQrManage.setListener(new OnQrValueListener() {
|
||||
@Override
|
||||
public void onScan(String barCode) {
|
||||
Log.e("onRecognized", "onScan: " + barCode);
|
||||
ThreadUtil.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
@ -251,6 +250,8 @@ public class FaceScanUtil {
|
|||
|
||||
}
|
||||
});
|
||||
}else{
|
||||
Log.d("onRecognized", "maybeCreateQrCodeScanner: serialQrManage!= null" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.ccb.facedevice.sdk.utils;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.text.format.Formatter;
|
||||
|
||||
|
|
@ -58,4 +60,15 @@ public class NetworkUtils {
|
|||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean isNetworkConnected(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
if (cm != null) {
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
return activeNetwork != null && activeNetwork.isConnected();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
package com.ccb.facedevice;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue