This commit is contained in:
parent
883d9c2e0c
commit
7b28faca3f
|
|
@ -39,6 +39,9 @@ import com.bonus.canteen.utils.MemoryUtils;
|
|||
import com.bonus.canteen.utils.OkHttpService;
|
||||
import com.bonus.canteen.utils.ThreadPoolManager;
|
||||
import com.bonus.canteen.utils.rabbitmq.RabbitMqMqttHelper;
|
||||
import com.ccb.facedevice.sdk.utils.AppUtil;
|
||||
import com.ccb.facedevice.sdk.utils.DeviceUtil;
|
||||
import com.ccb.facedevice.sdk.utils.NetworkUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.hjq.permissions.OnPermissionCallback;
|
||||
|
|
@ -55,6 +58,7 @@ import java.net.HttpURLConnection;
|
|||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.URL;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
|
@ -102,7 +106,16 @@ public class InitializationActivity extends BaseActivity<InitializationMainBindi
|
|||
|
||||
sendMessage("人员开始更新,请稍后", 0);
|
||||
sendMessage("人脸信息开始更新,请稍后", 0);
|
||||
startService(new Intent(InitializationActivity.this, DownLoadDataService.class));
|
||||
if (NetworkUtils.isNetworkConnected(this)){
|
||||
startService(new Intent(InitializationActivity.this, DownLoadDataService.class));
|
||||
}else{
|
||||
//跳转到主界面
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
Intent intentToOperation = new Intent(InitializationActivity.this, OperationActivity.class);
|
||||
startActivity(intentToOperation);
|
||||
finish();
|
||||
}, 3000);
|
||||
}
|
||||
// try {
|
||||
// activateFaceEngine();
|
||||
// }catch (Exception e){
|
||||
|
|
@ -131,6 +144,7 @@ public class InitializationActivity extends BaseActivity<InitializationMainBindi
|
|||
String tenantId = deviceInfo.getTenantId();
|
||||
mqttHelper = new RabbitMqMqttHelper(this, tenantId);
|
||||
mqttHelper.connect();
|
||||
sendMessage("MQTT初始化成功!", 0);
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -190,14 +204,8 @@ public class InitializationActivity extends BaseActivity<InitializationMainBindi
|
|||
|
||||
private void initRightDate() {
|
||||
String[] ethernetDns = getEthernetDns(this);
|
||||
String imei = "";
|
||||
try {
|
||||
imei = getImei();
|
||||
}catch (Exception e){
|
||||
imei = "获取失败IMEI";
|
||||
Log.e(TAG, "获取IMEI异常: " + e.getMessage());
|
||||
}
|
||||
binding.intRight.iniSn.setText(imei);
|
||||
binding.intRight.iniSn.setText(MessageFormat.format("SN:{0}", AppUtil.getSn(this)));
|
||||
binding.intRight.iniKey.setText(MessageFormat.format("KEY:{0}", DeviceUtil.getDeviceKey()));
|
||||
binding.intRight.iniNetworkType.setText(getNetworkType(this));
|
||||
binding.intRight.iniNetworkIp.setText(getIP(this));
|
||||
binding.intRight.iniSubMask.setText(getSubnetMask());
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
|
|||
});
|
||||
return;
|
||||
}
|
||||
if (balance.compareTo(payAmount) < 0) {
|
||||
if (balance.compareTo(payAmount.multiply(BigDecimal.valueOf(100))) < 0) {
|
||||
closePayWay();
|
||||
runOnUiThread(() -> {
|
||||
XToastUtils.warning("账户余额不足,请充值");
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import org.easydarwin.easypusher.R;
|
|||
import java.lang.ref.WeakReference;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
|
@ -142,17 +141,25 @@ public class OrderAdapter extends BaseAdapter {
|
|||
String money = new BigDecimal(offlineOrderInfo.getAmountDue()).divide(new BigDecimal(100)) + "";
|
||||
if ("0".equals(offlineOrderInfo.getIsOnline())) {
|
||||
Log.d("getOrderTime", offlineOrderInfo.getOrderTime() + "");
|
||||
Date orderDate = new Date(offlineOrderInfo.getOrderTime());
|
||||
Log.d("getOrderTime", orderDate + "");
|
||||
if (DateTimeHelper.format(orderDate, "yyyy-MM-dd").equals(DateTimeHelper.getNowDate())) {
|
||||
AppDatabase.getDatabase(context).businessDataDao().updateOffLine(money, "1", DateTimeHelper.getNowDate());
|
||||
if (ObjectUtil.isNotNull(offlineOrderInfo.getOrderTime())){
|
||||
String orderDate = offlineOrderInfo.getOrderTime().substring(0, 10);
|
||||
Log.d("退单", orderDate + "");
|
||||
if (orderDate.equals(DateTimeHelper.getNowDate())) {
|
||||
AppDatabase.getDatabase(context).businessDataDao().updateOffLine(money, "1", DateTimeHelper.getNowDate());
|
||||
}
|
||||
AppDatabase.getDatabase(context).offlineOrderDao().updatePayStatus("4", bean.getOrderId());
|
||||
runOnUiThread(() -> {
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.refund_success));
|
||||
MachineSaleActivity activity = (MachineSaleActivity) context;
|
||||
activity.refreshData();
|
||||
});
|
||||
}else{
|
||||
runOnUiThread(() -> {
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.refund_fail));
|
||||
XToastUtils.error("当前暂未获取到餐次,请连线后在进行重试");
|
||||
});
|
||||
}
|
||||
AppDatabase.getDatabase(context).offlineOrderDao().updatePayStatus("4", bean.getOrderId());
|
||||
runOnUiThread(() -> {
|
||||
SoundManager.getInstance().play(Sound.createSimpleSound(R.raw.refund_success));
|
||||
MachineSaleActivity activity = (MachineSaleActivity) context;
|
||||
activity.refreshData();
|
||||
});
|
||||
|
||||
}else {
|
||||
//调用后台退单接口
|
||||
try {
|
||||
|
|
@ -186,13 +193,12 @@ public class OrderAdapter extends BaseAdapter {
|
|||
Log.d("退单", "在当天");
|
||||
//判断是否在当餐
|
||||
CookMeetTimesInfo cookMeetTimesInfo = AppDatabase.getDatabase(context).cookMeetTimesDao().getDefaultCookMeetTime();
|
||||
if (cookMeetTimesInfo.getIntervalId().equals(cookMeetTimesInfo.getIntervalId())) {
|
||||
if (cookMeetTimesInfo.getIntervalId().equals(offlineOrderInfo.getIntervalId())) {
|
||||
Log.d("退单", "在当餐");
|
||||
//修改当餐数据
|
||||
AppDatabase.getDatabase(context).businessDataDao().updateCurrent(money, "1", DateTimeHelper.getNowDate());
|
||||
}
|
||||
AppDatabase.getDatabase(context).businessDataDao().updateToday(money, "1", DateTimeHelper.getNowDate());
|
||||
AppDatabase.getDatabase(context).businessDataDao().updateOffLine(money, "1", DateTimeHelper.getNowDate());
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
Log.d("退单", "更新UI");
|
||||
|
|
|
|||
|
|
@ -24,11 +24,9 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
public class ConfigRepository {
|
||||
private final ParamSettingInfoDao paramSettingDao;
|
||||
private final Map<String, String> configCache = new HashMap<>();
|
||||
|
||||
public ConfigRepository(ParamSettingInfoDao paramSettingDao) {
|
||||
this.paramSettingDao = paramSettingDao;
|
||||
// 异步加载配置到缓存
|
||||
new Thread(() -> {
|
||||
ParamSettingInfo paramSettingInfo = paramSettingDao.getOneInfo();
|
||||
|
|
@ -63,7 +61,4 @@ public class ConfigRepository {
|
|||
return configCache.get(key);
|
||||
}
|
||||
|
||||
public void updateConfig() {
|
||||
configCache.clear();
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +26,6 @@ import com.bonus.canteen.utils.WorkConfig;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -115,23 +114,19 @@ public class FaceServer {
|
|||
}
|
||||
|
||||
public void loadFace(Context context){
|
||||
Log.d(TAG, "开始加载人脸数据");
|
||||
Log.d(TAG, "faceEngine: " + faceEngine);
|
||||
if (faceEngine == null) {
|
||||
faceEngine = new FaceEngine();
|
||||
faceEngine.init(context, DetectMode.ASF_DETECT_MODE_IMAGE, DetectFaceOrientPriority.ASF_OP_0_ONLY, 16, 1, FaceEngine.ASF_FACE_RECOGNITION | FaceEngine.ASF_FACE_DETECT);
|
||||
}
|
||||
Log.d(TAG, "faceRegisterInfoList: " + faceRegisterInfoList.size());
|
||||
Log.d(TAG, "faceRegisterInfoList: " + faceRegisterInfoList.toString());
|
||||
if(faceRegisterInfoList == null){
|
||||
faceRegisterInfoList = new ArrayList<>();
|
||||
}
|
||||
ThreadPoolManager.getExecutor().execute(()-> {
|
||||
List<CustPhotoFulInfo> list = AppDatabase.getDatabase(context).custPhotoFulDao().getCustPhoto();
|
||||
Log.d(TAG, "list: " + list.size());
|
||||
Log.d(TAG, "list: " + list.toString());
|
||||
if (list != null && list.size() > 0) {
|
||||
for (CustPhotoFulInfo bean : list) {
|
||||
Log.d(TAG, "CustPhotoFulInfo: " + bean);
|
||||
if(!StringHelper.isEmptyAndNull(bean.getFeatures())){
|
||||
byte[] feature = Base64.decode(bean.getFeatures(), Base64.DEFAULT);
|
||||
String facePath = WorkConfig.getFileUrl() + bean.getPhotoUrl();
|
||||
|
|
@ -140,7 +135,6 @@ public class FaceServer {
|
|||
if (userInfo != null) {
|
||||
name = userInfo.getNickName();
|
||||
}
|
||||
Log.d(TAG, "initFaceList: " + name + " " + bean.getUserId() + " " + bean.getFeatures() + " " + Arrays.toString(feature));
|
||||
faceRegisterInfoList.add(new FaceRegisterInfo(feature,name , bean.getUserId() + "",
|
||||
facePath));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ import com.bonus.canteen.utils.WorkConfig;
|
|||
import org.easydarwin.easypusher.R;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
|
@ -88,7 +89,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
|
@ -129,7 +129,7 @@ public class SecondPresentation extends Presentation {
|
|||
/**
|
||||
* 用于存储活体值
|
||||
*/
|
||||
private ConcurrentHashMap<Integer, Integer> livenessMap = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<Integer, Integer> likenessMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 活体检测的开关
|
||||
|
|
@ -150,7 +150,7 @@ public class SecondPresentation extends Presentation {
|
|||
/**
|
||||
* 当FR成功,活体未成功时,FR等待活体的时间
|
||||
*/
|
||||
private static final int WAIT_LIVENESS_INTERVAL = 100;
|
||||
private static final int WAIT_LIKENESS_INTERVAL = 100;
|
||||
/**
|
||||
* 失败重试间隔时间(ms)
|
||||
*/
|
||||
|
|
@ -421,7 +421,7 @@ public class SecondPresentation extends Presentation {
|
|||
}
|
||||
|
||||
private void initCamera(String type) {
|
||||
livenessMap = new ConcurrentHashMap<>();
|
||||
likenessMap = new ConcurrentHashMap<>();
|
||||
requestFeatureStatusMap = new ConcurrentHashMap<>();
|
||||
extractErrorRetryMap = new ConcurrentHashMap<>();
|
||||
livenessErrorRetryMap = new ConcurrentHashMap<>();
|
||||
|
|
@ -436,17 +436,17 @@ public class SecondPresentation extends Presentation {
|
|||
@Override
|
||||
public void onFaceFeatureInfoGet(@Nullable byte[] nv21Data, @Nullable final FaceFeature faceFeature, Integer requestId, Integer errorCode, FaceInfo faceInfo) {
|
||||
if (faceFeature != null) {
|
||||
Integer liveness = livenessMap.get(requestId);
|
||||
Integer likeness = likenessMap.get(requestId);
|
||||
if (!livenessDetect) {
|
||||
//不做活体检测的情况,直接搜索
|
||||
searchFace(nv21Data, faceFeature, requestId, faceInfo, type);
|
||||
} else if (liveness != null && liveness == LivenessInfo.ALIVE) {
|
||||
} else if (likeness != null && likeness == LivenessInfo.ALIVE) {
|
||||
//活体检测通过,搜索特征
|
||||
searchFace(nv21Data, faceFeature, requestId, faceInfo, type);
|
||||
} else {
|
||||
//活体检测未出结果,或者非活体,延迟执行该函数
|
||||
if (requestFeatureStatusMap.containsKey(requestId)) {
|
||||
Observable.timer(WAIT_LIVENESS_INTERVAL, TimeUnit.MILLISECONDS)
|
||||
Observable.timer(WAIT_LIKENESS_INTERVAL, TimeUnit.MILLISECONDS)
|
||||
.subscribe(new Observer<Long>() {
|
||||
Disposable disposable;
|
||||
|
||||
|
|
@ -500,12 +500,12 @@ public class SecondPresentation extends Presentation {
|
|||
public void onFaceLivenessInfoGet(@Nullable LivenessInfo livenessInfo, final Integer requestId, Integer errorCode) {
|
||||
if (livenessInfo != null) {
|
||||
int liveness = livenessInfo.getLiveness();
|
||||
livenessMap.put(requestId, liveness);
|
||||
likenessMap.put(requestId, liveness);
|
||||
// 非活体,重试
|
||||
if (liveness == LivenessInfo.NOT_ALIVE) {
|
||||
// faceHelper.setName(requestId, "未通过:NOT_ALIVE");
|
||||
// 延迟 FAIL_RETRY_INTERVAL 后,将该人脸状态置为UNKNOWN,帧回调处理时会重新进行活体检测
|
||||
retryLivenessDetectDelayed(requestId);
|
||||
retryLikenessDetectDelayed(requestId);
|
||||
}
|
||||
} else {
|
||||
if (increaseAndGetValue(livenessErrorRetryMap, requestId) > MAX_RETRY_TIME) {
|
||||
|
|
@ -518,10 +518,10 @@ public class SecondPresentation extends Presentation {
|
|||
msg = "ProcessCode:" + errorCode;
|
||||
}
|
||||
faceHelper.setName(requestId, "未通过:" + msg);
|
||||
retryLivenessDetectDelayed(requestId);
|
||||
retryLikenessDetectDelayed(requestId);
|
||||
} else {
|
||||
Log.e(TAG, "onFaceLivenessInfoGet: liveness error LivenessInfo.NOT_ALIVE");
|
||||
livenessMap.put(requestId, LivenessInfo.UNKNOWN);
|
||||
likenessMap.put(requestId, LivenessInfo.UNKNOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -574,10 +574,10 @@ public class SecondPresentation extends Presentation {
|
|||
* 在活体检测开启,在人脸识别状态不为成功或人脸活体状态不为处理中(ANALYZING)且不为处理完成(ALIVE、NOT_ALIVE)时重新进行活体检测
|
||||
*/
|
||||
if (livenessDetect && (status == null || status != RequestFeatureStatus.SUCCEED)) {
|
||||
Integer liveness = livenessMap.get(facePreviewInfoList.get(i).getTrackId());
|
||||
Integer liveness = likenessMap.get(facePreviewInfoList.get(i).getTrackId());
|
||||
if (liveness == null
|
||||
|| (liveness != LivenessInfo.ALIVE && liveness != LivenessInfo.NOT_ALIVE && liveness != RequestLivenessStatus.ANALYZING)) {
|
||||
livenessMap.put(facePreviewInfoList.get(i).getTrackId(), RequestLivenessStatus.ANALYZING);
|
||||
likenessMap.put(facePreviewInfoList.get(i).getTrackId(), RequestLivenessStatus.ANALYZING);
|
||||
faceHelper.requestFaceLiveness(nv21, facePreviewInfoList.get(i).getFaceInfo(), previewSize.width, previewSize.height, FaceEngine.CP_PAF_NV21, facePreviewInfoList.get(i).getTrackId(), LivenessType.RGB);
|
||||
}
|
||||
}
|
||||
|
|
@ -664,7 +664,7 @@ public class SecondPresentation extends Presentation {
|
|||
*
|
||||
* @param requestId 人脸ID
|
||||
*/
|
||||
private void retryLivenessDetectDelayed(final Integer requestId) {
|
||||
private void retryLikenessDetectDelayed(final Integer requestId) {
|
||||
Observable.timer(FAIL_RETRY_INTERVAL, TimeUnit.MILLISECONDS)
|
||||
.subscribe(new Observer<Long>() {
|
||||
Disposable disposable;
|
||||
|
|
@ -691,7 +691,7 @@ public class SecondPresentation extends Presentation {
|
|||
if (livenessDetect) {
|
||||
faceHelper.setName(requestId, Integer.toString(requestId));
|
||||
}
|
||||
livenessMap.put(requestId, LivenessInfo.UNKNOWN);
|
||||
likenessMap.put(requestId, LivenessInfo.UNKNOWN);
|
||||
delayFaceTaskCompositeDisposable.remove(disposable);
|
||||
}
|
||||
});
|
||||
|
|
@ -738,7 +738,7 @@ public class SecondPresentation extends Presentation {
|
|||
List<DrawInfo> drawInfoList = new ArrayList<>();
|
||||
for (int i = 0; i < facePreviewInfoList.size(); i++) {
|
||||
String name = faceHelper.getName(facePreviewInfoList.get(i).getTrackId());
|
||||
Integer liveness = livenessMap.get(facePreviewInfoList.get(i).getTrackId());
|
||||
Integer liveness = likenessMap.get(facePreviewInfoList.get(i).getTrackId());
|
||||
Integer recognizeStatus = requestFeatureStatusMap.get(facePreviewInfoList.get(i).getTrackId());
|
||||
|
||||
// 根据识别结果和活体结果设置颜色
|
||||
|
|
@ -779,7 +779,7 @@ public class SecondPresentation extends Presentation {
|
|||
}
|
||||
if (facePreviewInfoList == null || facePreviewInfoList.size() == 0) {
|
||||
requestFeatureStatusMap.clear();
|
||||
livenessMap.clear();
|
||||
likenessMap.clear();
|
||||
livenessErrorRetryMap.clear();
|
||||
extractErrorRetryMap.clear();
|
||||
if (getFeatureDelayedDisposables != null) {
|
||||
|
|
@ -799,7 +799,7 @@ public class SecondPresentation extends Presentation {
|
|||
}
|
||||
if (!contained) {
|
||||
requestFeatureStatusMap.remove(key);
|
||||
livenessMap.remove(key);
|
||||
likenessMap.remove(key);
|
||||
livenessErrorRetryMap.remove(key);
|
||||
extractErrorRetryMap.remove(key);
|
||||
}
|
||||
|
|
@ -807,13 +807,10 @@ public class SecondPresentation extends Presentation {
|
|||
}
|
||||
|
||||
private void searchFace(final byte[] nv21Data, final FaceFeature frFace, final Integer requestId, final FaceInfo faceInfo, String type) {
|
||||
Observable.create(new ObservableOnSubscribe<CompareResult>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<CompareResult> emitter) {
|
||||
CompareResult compareResult = FaceServer.getInstance().getCollectionFaceLib(frFace);
|
||||
emitter.onNext(compareResult);
|
||||
}
|
||||
})
|
||||
Observable.create((ObservableOnSubscribe<CompareResult>) emitter -> {
|
||||
CompareResult compareResult = FaceServer.getInstance().getCollectionFaceLib(frFace);
|
||||
emitter.onNext(compareResult);
|
||||
})
|
||||
.subscribeOn(Schedulers.computation())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<CompareResult>() {
|
||||
|
|
@ -904,22 +901,22 @@ public class SecondPresentation extends Presentation {
|
|||
personBalancePresentation.setVisibility(View.VISIBLE);
|
||||
faceScan.setVisibility(View.GONE);
|
||||
faceImg.setVisibility(View.GONE);
|
||||
ImageView person_photo = findViewById(R.id.person_photo);
|
||||
ImageView personPhoto = findViewById(R.id.person_photo);
|
||||
TextView userName = findViewById(R.id.userName);
|
||||
TextView phone = findViewById(R.id.phone);
|
||||
TextView balanceWallet = findViewById(R.id.balance_wallet);
|
||||
TextView personalWallet = findViewById(R.id.personal_wallet);
|
||||
TextView subsidyBalance = findViewById(R.id.subsidy_balance);
|
||||
if (custPhotoFulInfo != null){
|
||||
GlideUtil.GlideWithPlaceHolder(context, WorkConfig.getFileUrl() +custPhotoFulInfo.getPhotoUrl()).into(person_photo);
|
||||
GlideUtil.GlideWithPlaceHolder(context, WorkConfig.getFileUrl() +custPhotoFulInfo.getPhotoUrl()).into(personPhoto);
|
||||
}else{
|
||||
GlideUtil.GlideWithPlaceHolder(context, R.drawable.my_photo).into(person_photo);
|
||||
GlideUtil.GlideWithPlaceHolder(context, R.drawable.my_photo).into(personPhoto);
|
||||
}
|
||||
userName.setText(userInfo.getUserName());
|
||||
phone.setText(userInfo.getPhone());
|
||||
balanceWallet.setText((new BigDecimal(userInfo.getPersonalWalletBalance()).add(new BigDecimal(userInfo.getSubsidiesBalance()))).divide(new BigDecimal(100)).toString());
|
||||
personalWallet.setText(new BigDecimal(userInfo.getPersonalWalletBalance()).divide(new BigDecimal(100)).toString());
|
||||
subsidyBalance.setText(new BigDecimal(userInfo.getSubsidiesBalance()).divide(new BigDecimal(100)).toString());
|
||||
balanceWallet.setText((new BigDecimal(userInfo.getPersonalWalletBalance()).add(new BigDecimal(userInfo.getSubsidiesBalance()))).divide(new BigDecimal(100),2, RoundingMode.HALF_UP).toString());
|
||||
personalWallet.setText(new BigDecimal(userInfo.getPersonalWalletBalance()).divide(new BigDecimal(100),2, RoundingMode.HALF_UP).toString());
|
||||
subsidyBalance.setText(new BigDecimal(userInfo.getSubsidiesBalance()).divide(new BigDecimal(100),2, RoundingMode.HALF_UP).toString());
|
||||
}else{
|
||||
personBalancePresentation.setVisibility(View.GONE);
|
||||
faceScan.setVisibility(View.GONE);
|
||||
|
|
|
|||
|
|
@ -46,9 +46,7 @@ public class DownLoadDataService extends Service {
|
|||
public String APP_ID;
|
||||
public String SDK_KEY;
|
||||
|
||||
private List<String> methodList = new ArrayList<>();
|
||||
|
||||
private WorkConfig workConfig;
|
||||
private final List<String> methodList = new ArrayList<>();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
|
|
@ -64,13 +62,10 @@ public class DownLoadDataService extends Service {
|
|||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.e(TAG, "onStartCommand:");
|
||||
Log.e(TAG, "启动服务:");
|
||||
initList();
|
||||
final Intent tempIntent = intent;
|
||||
//判断手机是否有网络
|
||||
boolean netTf = NetworkUtils.isNetworkConnected(this);
|
||||
Log.e(TAG, "netTf:" + netTf);
|
||||
if (netTf) {
|
||||
new Thread(() -> startUploadData(tempIntent)).start();
|
||||
}
|
||||
|
|
@ -89,24 +84,17 @@ public class DownLoadDataService extends Service {
|
|||
ArrayList<String> responseList = new ArrayList<>();
|
||||
while (it.hasNext()) {
|
||||
String str = it.next();
|
||||
String flage = str;
|
||||
ResponseVo responseVo = switchsMethod(flage);
|
||||
Log.e(TAG, "===========responseVo:" + responseVo.toString());
|
||||
ResponseVo responseVo = switchMethod(str);
|
||||
responseList.add(responseVo.toString());
|
||||
Log.e(TAG, flage + ":" + responseVo.isStatus());
|
||||
it.remove();
|
||||
}
|
||||
Log.e(TAG, "list.size:" + methodList.size());
|
||||
if (methodList.size() <= 0) {
|
||||
if (methodList.isEmpty()) {
|
||||
//停止服务
|
||||
Intent broad = new Intent();
|
||||
broad.setAction("action.updateUI");
|
||||
broad.putExtra("state", "success");
|
||||
broad.putStringArrayListExtra("responseList",responseList);
|
||||
Log.e("发送广播", "发送广播");
|
||||
Log.e("发送广播 responseList", responseList.toString());
|
||||
sendBroadcast(broad);
|
||||
Log.e(TAG, "系统通知");
|
||||
Utils.sendPush(this, "系统通知", "系统数据更新成功!");
|
||||
if (intent != null)
|
||||
stopService(intent);
|
||||
|
|
@ -115,15 +103,12 @@ public class DownLoadDataService extends Service {
|
|||
broad.setAction("action.updateUI");
|
||||
broad.putExtra("state", "success");
|
||||
broad.putStringArrayListExtra("responseList",responseList);
|
||||
Log.e("发送广播", "发送广播");
|
||||
Log.e("发送广播 responseList", responseList.toString());
|
||||
sendBroadcast(broad);
|
||||
//停止服务
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < methodList.size(); i++) {
|
||||
sb.append(methodList.get(i) + "-");
|
||||
sb.append(methodList.get(i)).append("-");
|
||||
}
|
||||
Log.e(TAG, "系统通知");
|
||||
Utils.sendPush(this, "系统通知", sb.toString() + "更新失败!");
|
||||
if (intent != null)
|
||||
stopService(intent);
|
||||
|
|
@ -133,14 +118,12 @@ public class DownLoadDataService extends Service {
|
|||
/**
|
||||
* 选择下载
|
||||
*
|
||||
* @param falge
|
||||
* @param flag
|
||||
* @return
|
||||
*/
|
||||
private ResponseVo switchsMethod(String falge) {
|
||||
|
||||
private ResponseVo switchMethod(String flag) {
|
||||
GetBasicDataService service = new GetBasicDataServiceImp();
|
||||
|
||||
switch (falge) {
|
||||
switch (flag) {
|
||||
case "菜谱信息":
|
||||
return service.getRecipeInformation();
|
||||
case "人脸特征值信息":
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class WorkConfig {
|
|||
protected static String prefixesUrl = "http://36.33.26.201:48380";
|
||||
protected static String fileUrl = "http://36.33.26.201:48380/lnyst/";
|
||||
private static String updateUrl = "https://www.baidu.com";
|
||||
private static String serverUri = "tcp://36.33.26.201:51883";
|
||||
private static String serverUri = "tcp://192.168.0.244:1883";
|
||||
private static String MqttUserName = "admin";
|
||||
private static String MqttPassWord = "Bonus@admin123!";
|
||||
private static String APP_ID = "52XE2dQBtdmMsfDMvyKmPCCPyFsc4jvo8TKvAdaYfr28";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.bonus.canteen.utils.rabbitmq;
|
||||
|
||||
import static com.xuexiang.xutil.XUtil.runOnUiThread;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
|
|
@ -12,6 +14,7 @@ import com.bonus.canteen.db.AppDatabase;
|
|||
import com.bonus.canteen.db.entity.base.BusinessDataInfo;
|
||||
import com.bonus.canteen.db.entity.base.CookMeetTimesInfo;
|
||||
import com.bonus.canteen.db.entity.base.CustPhotoFulInfo;
|
||||
import com.bonus.canteen.db.entity.base.OfflineOrderInfo;
|
||||
import com.bonus.canteen.db.entity.base.UserInfo;
|
||||
import com.bonus.canteen.face.util.FaceServer;
|
||||
import com.bonus.canteen.service.data.GetBasicDataService;
|
||||
|
|
@ -20,6 +23,7 @@ import com.bonus.canteen.utils.DateTimeHelper;
|
|||
import com.bonus.canteen.utils.ThreadPoolManager;
|
||||
import com.bonus.canteen.utils.WorkConfig;
|
||||
import com.ccb.facedevice.sdk.utils.AppUtil;
|
||||
import com.xuexiang.xutil.common.StringUtils;
|
||||
|
||||
import org.eclipse.paho.android.service.MqttAndroidClient;
|
||||
import org.eclipse.paho.android.service.MqttTraceHandler;
|
||||
|
|
@ -31,6 +35,8 @@ import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
|
|||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Arrays;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
|
@ -38,16 +44,11 @@ import cn.hutool.core.util.ObjectUtil;
|
|||
public class RabbitMqMqttHelper {
|
||||
private static final String TAG = "RabbitMqMqttHelper";
|
||||
Context context;
|
||||
private MqttAndroidClient mqttAndroidClient;
|
||||
/**
|
||||
* RabbitMQ 默认MQTT端口是1883,带SSL是8883
|
||||
*/
|
||||
private final String serverUri;
|
||||
private String clientId = "AndroidClient_" + System.currentTimeMillis();
|
||||
private final MqttAndroidClient mqttAndroidClient;
|
||||
String sn;
|
||||
String tenantId;
|
||||
private String[] subscriptionTopics = {};
|
||||
|
||||
private static final String UPDATE_PERSON = "updatePerson";
|
||||
private static final String UPDATE_PERSON_PHOTO = "updatePersonPhoto";
|
||||
// RabbitMQ 认证使用AMQP的用户名密码
|
||||
private final String username; // RabbitMQ管理用户
|
||||
private final String password;
|
||||
|
|
@ -57,16 +58,18 @@ public class RabbitMqMqttHelper {
|
|||
this.context = context;
|
||||
this.sn = AppUtil.getSn(context);
|
||||
this.tenantId = tenantId;
|
||||
this.serverUri = WorkConfig.getMqttUrl();
|
||||
// RabbitMQ 默认MQTT端口是1883,带SSL是8883
|
||||
String serverUri = WorkConfig.getMqttUrl();
|
||||
this.username = WorkConfig.getMqttUserName();
|
||||
this.password = WorkConfig.getMqttPassWord();
|
||||
String clientId = "AndroidClient_MQTT";
|
||||
mqttAndroidClient = new MqttAndroidClient(context, serverUri, clientId);
|
||||
}
|
||||
|
||||
private MqttConnectOptions createMqttConnectOptions() {
|
||||
MqttConnectOptions options = new MqttConnectOptions();
|
||||
options.setAutomaticReconnect(true);
|
||||
options.setCleanSession(true);
|
||||
options.setCleanSession(false); //设置持久化
|
||||
options.setConnectionTimeout(30);
|
||||
options.setKeepAliveInterval(60);
|
||||
options.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
|
||||
|
|
@ -85,6 +88,7 @@ public class RabbitMqMqttHelper {
|
|||
@Override
|
||||
public void messageArrived(String topic, MqttMessage message) {
|
||||
String payload = new String(message.getPayload());
|
||||
Log.d(TAG, "Received message: " + payload);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> handleIncomingMessage(topic, payload), 5000);
|
||||
}
|
||||
|
||||
|
|
@ -99,17 +103,17 @@ public class RabbitMqMqttHelper {
|
|||
return new MqttTraceHandler() {
|
||||
@Override
|
||||
public void traceDebug(String source, String message) {
|
||||
Log.d("MQTT_TRACE", source + ": " + message);
|
||||
Log.d(TAG, source + ": " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void traceError(String source, String message) {
|
||||
Log.e("MQTT_TRACE", source + ": " + message);
|
||||
Log.e(TAG, source + ": " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void traceException(String source, String message, Exception e) {
|
||||
Log.e("MQTT_TRACE", source + ": " + message, e);
|
||||
Log.e(TAG, source + ": " + message, e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -137,6 +141,7 @@ public class RabbitMqMqttHelper {
|
|||
}
|
||||
|
||||
public void subscribeToTopics() {
|
||||
String[] subscriptionTopics;
|
||||
try {
|
||||
if (ObjectUtil.isEmpty(tenantId)) {
|
||||
Log.d(TAG, "tenantId is null");
|
||||
|
|
@ -147,9 +152,10 @@ public class RabbitMqMqttHelper {
|
|||
"device-update-menu-config-v4." + tenantId + "." + sn,
|
||||
"device-update-info-v4." + tenantId + "." + sn,
|
||||
"device-update-system-card-v4." + tenantId,
|
||||
"time-calibration-v4." + tenantId + "." + sn
|
||||
"time-calibration-v4." + tenantId + "." + sn,
|
||||
"device-update-order-state-v4." + tenantId
|
||||
};
|
||||
mqttAndroidClient.subscribe(subscriptionTopics, new int[]{1, 1, 1, 1, 1}, null, new IMqttActionListener() {
|
||||
mqttAndroidClient.subscribe(subscriptionTopics, new int[]{1, 1, 1, 1, 1,1}, null, new IMqttActionListener() {
|
||||
@Override
|
||||
public void onSuccess(IMqttToken asyncActionToken) {
|
||||
Log.d(TAG, "Subscribed to topics: " + Arrays.toString(asyncActionToken.getTopics()));
|
||||
|
|
@ -192,6 +198,8 @@ public class RabbitMqMqttHelper {
|
|||
handlePersonConfigUpdate(jsonObject);
|
||||
} else if (topic.contains("device-update-info-v4")) {
|
||||
handleDeviceUpdateInfo(jsonObject);
|
||||
} else if (topic.contains("device-update-order-state-v4")) {
|
||||
handleOrderStateUpdate(jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -228,10 +236,12 @@ public class RabbitMqMqttHelper {
|
|||
* 处理人员配置更新(包含子操作)
|
||||
*/
|
||||
private void handlePersonConfigUpdate(JSONObject json) {
|
||||
checkAndLogUpdate(json, "updatePerson", "人员信息");
|
||||
checkAndLogUpdate(json, "updatePersonPhoto", "人员照片");
|
||||
checkAndLogUpdate(json, UPDATE_PERSON, "人员信息");
|
||||
checkAndLogUpdate(json, UPDATE_PERSON_PHOTO, "人员照片");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 通用更新检查方法
|
||||
*/
|
||||
|
|
@ -240,8 +250,8 @@ public class RabbitMqMqttHelper {
|
|||
if (json.getIntValue(field) > 0 && desc.equals("人员照片")) {
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
GetBasicDataService service = new GetBasicDataServiceImp();
|
||||
service.getFacePhoto(json.getString("currentTime"), json.getIntValue("updatePerson"));
|
||||
FaceServer.getInstance().loadFace(context);
|
||||
service.getFacePhoto(json.getString("currentTime"), json.getIntValue(UPDATE_PERSON));
|
||||
runOnUiThread(() -> FaceServer.getInstance().loadFace(context));
|
||||
});
|
||||
} else if (json.getIntValue(field) > 0 && desc.equals("人员信息")) {
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
|
|
@ -252,7 +262,7 @@ public class RabbitMqMqttHelper {
|
|||
AppDatabase.getDatabase(context).custPhotoFulDao().delete(new CustPhotoFulInfo(Long.parseLong(String.valueOf(userId))));
|
||||
} else {
|
||||
GetBasicDataService service = new GetBasicDataServiceImp();
|
||||
service.getPersonInfo(json.getString("currentTime"), "user", json.getIntValue("updatePerson"));
|
||||
service.getPersonInfo(json.getString("currentTime"), "user", json.getIntValue(UPDATE_PERSON));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -267,4 +277,27 @@ public class RabbitMqMqttHelper {
|
|||
service.getDeviceBase();
|
||||
});
|
||||
}
|
||||
private void handleOrderStateUpdate(JSONObject json) {
|
||||
String orderId = json.getString("deviceOrderId");
|
||||
if (!StringUtils.isEmpty(orderId)) {
|
||||
ThreadPoolManager.getExecutor().execute(() -> {
|
||||
OfflineOrderInfo offlineOrderInfo = AppDatabase.getDatabase(context).offlineOrderDao().getOfflineOrderById(orderId);
|
||||
AppDatabase.getDatabase(context).offlineOrderDao().updatePayStatus("4", orderId);
|
||||
String money = new BigDecimal(offlineOrderInfo.getAmountDue()).divide(new BigDecimal(100),2, RoundingMode.HALF_UP) + "";
|
||||
String orderDate = offlineOrderInfo.getOrderTime().substring(0, 10);
|
||||
Log.d("退单", orderDate);
|
||||
if (orderDate.equals(DateTimeHelper.getNowDate())) {
|
||||
Log.d("退单", "在当天");
|
||||
//判断是否在当餐
|
||||
CookMeetTimesInfo cookMeetTimesInfo = AppDatabase.getDatabase(context).cookMeetTimesDao().getDefaultCookMeetTime();
|
||||
if (cookMeetTimesInfo.getIntervalId().equals(offlineOrderInfo.getIntervalId())) {
|
||||
Log.d("退单", "在当餐");
|
||||
//修改当餐数据
|
||||
AppDatabase.getDatabase(context).businessDataDao().updateCurrent(money, "1", DateTimeHelper.getNowDate());
|
||||
}
|
||||
AppDatabase.getDatabase(context).businessDataDao().updateToday(money, "1", DateTimeHelper.getNowDate());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,14 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:textSize="@dimen/config_margin_20dp"
|
||||
android:text="SN:132465798"
|
||||
android:gravity="center"
|
||||
android:layout_weight="1">
|
||||
</TextView>
|
||||
<TextView
|
||||
android:id="@+id/ini_key"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:textSize="@dimen/config_margin_20dp"
|
||||
android:gravity="center"
|
||||
android:layout_weight="1">
|
||||
</TextView>
|
||||
|
|
|
|||
|
|
@ -41,10 +41,7 @@ public class DeviceUtil {
|
|||
String str2 = FileIOUtil.readFile2String(keyFilePath());
|
||||
String str1 = str2;
|
||||
if(StringUtil.isEmpty(str2)) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(RandomUtil.getSixRadndomNum());
|
||||
stringBuilder.append("");
|
||||
str1 = stringBuilder.toString();
|
||||
str1 = RandomUtil.getSixRandomNumb() + "";
|
||||
FileIOUtil.writeFileFromString(keyFilePath(), str1);
|
||||
}
|
||||
return str1;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.ccb.facedevice.sdk.utils;
|
||||
public class RandomUtil {
|
||||
public static int getSixRadndomNum() {
|
||||
public static int getSixRandomNumb() {
|
||||
return (int)((Math.random() * 9.0D + 1.0D) * 100000.0D);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue