Commit 72663cb3 by 宁斌

1、餐牌食品組分頁調整

2、打印回調不成功處理
3、數據下載頁面調整
4、獲取支付方式接口替換
parent 6c4562f5
......@@ -39,7 +39,8 @@ allprojects {
maven { url 'http://www.idescout.com/maven/repo/' }
//阿里云仓库
maven { url "http://maven.aliyun.com/nexus/content/repositories/releases" }
// 私有仓库地址
maven { url "http://lib.gcssloop.com/repository/gcssloop-central/" }
maven{ url 'https://maven.aliyun.com/repository/google' }
maven{ url 'https://maven.aliyun.com/repository/jcenter' }
}
......
......@@ -2,10 +2,10 @@ package com.gingersoft.gsa.cloud.download.mvp.contract;
import android.content.Context;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.common.bean.FoodBean;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.ComboRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.ComboItemRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodComboRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodModifierRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.ModifierRespone;
......@@ -54,7 +54,9 @@ public interface DownloadContract {
Observable<ModifierRespone> downModifier(int restaurantId);
Observable<ComboRespone> downCombo(int restaurantId);
Observable<FoodComboRespone> downFoodCombo(int restaurantId);
Observable<ComboItemRespone> downComboItem(int restaurantId);
Observable<FoodModifierRespone> downFoodModifier(int restaurantId);
}
......
......@@ -3,11 +3,11 @@ package com.gingersoft.gsa.cloud.download.mvp.model;
import android.app.Application;
import android.content.Context;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.common.bean.FoodBean;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.ComboRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.ComboItemRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodComboRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodModifierRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.ModifierRespone;
......@@ -86,9 +86,15 @@ public class DownloadModel extends BaseModel implements DownloadContract.Model {
}
@Override
public Observable<ComboRespone> downCombo(int restaurantId) {
public Observable<FoodComboRespone> downFoodCombo(int restaurantId) {
return mRepositoryManager.obtainRetrofitService(DownloadService.class)
.downCombo(restaurantId);
.downFoodCombo(restaurantId);
}
@Override
public Observable<ComboItemRespone> downComboItem(int restaurantId) {
return mRepositoryManager.obtainRetrofitService(DownloadService.class)
.downComboItem(restaurantId);
}
@Override
......
package com.gingersoft.gsa.cloud.download.mvp.model.bean;
import com.gingersoft.gsa.cloud.database.bean.ComboItem;
import com.gingersoft.gsa.cloud.database.bean.FoodCombo;
import java.util.List;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-02-18
* 修订历史:2020-02-18
* 描述:
*/
public class ComboItemRespone {
private boolean success;
private String errMsg;
private long sysTime;
private List<ComboItem> data;
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public long getSysTime() {
return sysTime;
}
public void setSysTime(long sysTime) {
this.sysTime = sysTime;
}
public List<ComboItem> getData() {
return data;
}
public void setData(List<ComboItem> data) {
this.data = data;
}
}
......@@ -4,6 +4,17 @@ public class DataDownLoadState {
private String text;
private int state = 0;
//下載進度所占比例
private float ratio;
public float getRatio() {
return ratio;
}
public void setRatio(float ratio) {
this.ratio = ratio;
}
public DataDownLoadState() {
}
......
package com.gingersoft.gsa.cloud.download.mvp.model.bean;
import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.FoodCombo;
import java.util.List;
......@@ -11,12 +11,12 @@ import java.util.List;
* 修订历史:2020-02-18
* 描述:
*/
public class ComboRespone {
public class FoodComboRespone {
private boolean success;
private String errMsg;
private long sysTime;
private List<Combo> data;
private List<FoodCombo> data;
public boolean isSuccess() {
return success;
......@@ -42,11 +42,11 @@ public class ComboRespone {
this.sysTime = sysTime;
}
public List<Combo> getData() {
public List<FoodCombo> getData() {
return data;
}
public void setData(List<Combo> data) {
public void setData(List<FoodCombo> data) {
this.data = data;
}
}
package com.gingersoft.gsa.cloud.download.mvp.model.bean;
import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.FoodModifier;
import java.util.List;
......
package com.gingersoft.gsa.cloud.download.mvp.model.downmanager;
import android.content.Context;
import com.gingersoft.gsa.cloud.base.threadPool.ThreadPoolManager;
import com.gingersoft.gsa.cloud.base.utils.LanguageUtils;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.base.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.base.utils.okhttpUtils.OkHttp3Utils;
import com.gingersoft.gsa.cloud.download.mvp.presenter.DownloadPresenter;
import com.jess.arms.utils.ArmsUtils;
import java.net.URLEncoder;
import java.util.List;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-02-25
* 修订历史:2020-02-25
* 描述:數據下載管理類
*/
public class DownloadManager {
private static DownloadManager downloadManager;
private Context context;
//当前请求响应成功数
private int responseSuccessCount;
//当前请求响应失敗数
private int responseErrorCount;
//当前所需請求數
private int requestCount;
public static DownloadManager getInstance() {
if (downloadManager == null) {
downloadManager = new DownloadManager();
}
return downloadManager;
}
public DownloadManager takeRequestExecute(Context context, List<DownloadRequest> requests, DownloadPresenter presenter) {
this.context = context;
this.requestCount = requests.size();
//重置响应数
this.responseSuccessCount = 0;
ThreadPoolManager poolManager = ThreadPoolManager.getInstence();
for (int i = 0; i < requests.size(); i++) {
DownloadRequest request = requests.get(i);
if (request != null) {
DownloadTaskImp taskImp = new DownloadTaskImp(request,presenter);
poolManager.putExecutableTasks(taskImp);
}
}
return this;
}
public void download(DownloadRequest request) {
OkHttp3Utils.get(request.getUrl())
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<String>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(String data) {
if (listener != null) {
listener.onSuccess(data, request.getDownTag());
}
//同步响应数加+1
responseSuccessCount++;
}
@Override
public void onError(Throwable t) {
if (listener != null) {
listener.onError(t, request.getDownTag());
}
responseErrorCount++;
}
@Override
public void onComplete() {
if (responseSuccessCount == requestCount) {
if (listener != null) {
listener.noComplete();
}
}
}
});
}
private OnDownloadResultListener listener;
public void setDownloadResultListener(OnDownloadResultListener listener) {
this.listener = listener;
}
public interface OnDownloadResultListener {
void onSuccess(String respose, int downTag);
void onError(Throwable t, int downTag);
void noComplete();
}
}
package com.gingersoft.gsa.cloud.download.mvp.model.downmanager;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-02-25
* 修订历史:2020-02-25
* 描述:
*/
public class DownloadRequest {
private int downTag;
private String url;
private int restaurantId;
public int getDownTag() {
return downTag;
}
public void setDownTag(int downTag) {
this.downTag = downTag;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public int getRestaurantId() {
return restaurantId;
}
public void setRestaurantId(int restaurantId) {
this.restaurantId = restaurantId;
}
}
package com.gingersoft.gsa.cloud.download.mvp.model.downmanager;
import com.gingersoft.gsa.cloud.download.mvp.presenter.DownloadPresenter;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-02-25
* 修订历史:2020-02-25
* 描述:
*/
public class DownloadTaskImp implements Runnable {
private DownloadRequest request;
private DownloadPresenter presenter;
public DownloadTaskImp(DownloadRequest request, DownloadPresenter presenter) {
this.request = request;
this.presenter = presenter;
}
@Override
public void run() {
// DownloadManager.getInstance().download(request);
// switch (request.getDownTag()) {
// case 0:
// presenter.downFun();
// break;
// case 1:
// presenter.downFoodList();
// break;
// case 2:
// presenter.downModifier();
// break;
// case 3:
// presenter.downCombo();
// break;
// case 4:
// presenter.downFoodModifier();
// break;
// }
switch (request.getDownTag()) {
case 0:
presenter.downFun(request.getDownTag());
break;
case 1:
presenter.downFoodList(request.getDownTag());
break;
case 2:
presenter.downModifier(request.getDownTag());
break;
case 3:
presenter.downFoodCombo(request.getDownTag());
break;
case 4:
presenter.downComboItem(request.getDownTag());
break;
case 5:
presenter.downFoodModifier(request.getDownTag());
break;
}
}
}
......@@ -2,7 +2,8 @@ package com.gingersoft.gsa.cloud.download.mvp.model.service;
import com.gingersoft.gsa.cloud.base.Api;
import com.gingersoft.gsa.cloud.base.common.bean.FoodBean;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.ComboRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.ComboItemRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodComboRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodModifierRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.ModifierRespone;
......@@ -27,7 +28,10 @@ public interface DownloadService {
Observable<ModifierRespone> downModifier(@Query("restaurantId") int restaurantId);
@GET(Api.food_package_relation + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<ComboRespone> downCombo(@Query("restaurantId") int restaurantId);
Observable<FoodComboRespone> downFoodCombo(@Query("restaurantId") int restaurantId);
@GET(Api.food_comboItem + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<ComboItemRespone> downComboItem(@Query("restaurantId") int restaurantId);
@GET(Api.food_modifiere_relation + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<FoodModifierRespone> downFoodModifier(@Query("restaurantId") int restaurantId);
......
......@@ -3,23 +3,25 @@ package com.gingersoft.gsa.cloud.download.mvp.presenter;
import android.app.Application;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.Api;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.FoodBean;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.FoodModifier;
import com.gingersoft.gsa.cloud.database.bean.Modifier;
import com.gingersoft.gsa.cloud.database.utils.ComboDaoUtils;
import com.gingersoft.gsa.cloud.base.utils.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.database.bean.ComboItem;
import com.gingersoft.gsa.cloud.database.utils.ComboItemDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.FoodComboDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.FoodModifierDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.FunctionDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.ModifierDaoUtils;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.ComboRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.ComboItemRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodComboRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.DataDownLoadState;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodModifierRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.ModifierRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.downmanager.DownloadManager;
import com.gingersoft.gsa.cloud.download.mvp.model.downmanager.DownloadRequest;
import com.gingersoft.gsa.cloud.download.mvp.ui.activity.DownloadActivity;
import com.gingersoft.gsa.cloud.download.mvp.ui.adapter.DataDownLoadAdapter;
import com.jess.arms.integration.AppManager;
......@@ -27,9 +29,8 @@ import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.http.imageloader.ImageLoader;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.annotations.NonNull;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
......@@ -71,13 +72,26 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow
private DataDownLoadAdapter mAapter;
private List<DataDownLoadState> mList = new ArrayList<>();
private String[] downTitles = {"功能列表", "食品列表", "食品細項", "套餐", "食品細項關係"};
private int downLoadCount = 0; //下载数据计数
private boolean downLoadState = false;
private String[] downTitles = {"功能列表", "食品列表", "食品細項", "食品套餐", "套餐食品", "食品細項"};
//下載所佔比例
private int[] ratios = {8, 46, 22, 8, 8, 8};
private String urlList[] = {
HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL + Api.download_function_list,
HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL + Api.food_list,
HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL + Api.modifier,
HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL + Api.food_package_relation,
HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL + Api.food_comboItem,
HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL + Api.food_modifiere_relation};
//当前请求响应成功数
private int responseSuccessCount;
//当前所需請求數
private int requestCount = 6;
//當前下載進度
private float currentProgress = 0;
private List<Food> foodList;
// private String urlList[] = {HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL2 + Api.download_function_list, Api.download_food_list};
@Inject
public DownloadPresenter(DownloadContract.Model model, DownloadContract.View rootView) {
......@@ -106,80 +120,145 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow
if (!DeviceUtils.netIsConnected(mApplication)) {
mRootView.showMessage("Can not connect server, retry?");
}
//初始化下载记录标志
downLoadCount = 0;
downLoadState = false;
down_load_data();
}
public void down_load_data() {
responseSuccessCount = 0;
currentProgress = 0;
IActivity.setTvProgress(0);
initDownState();
setDownAverageRatio();
int restaurantId = GsaCloudApplication.getRestaurantId(IActivity);
Observable.mergeArray(mModel.downFunctionList(), mModel.downFoodList(restaurantId)
, mModel.downModifier(restaurantId), mModel.downCombo(restaurantId),
mModel.downFoodModifier(restaurantId))
List<DownloadRequest> requests = getDownloadRequests(getDownloadUrls(restaurantId), restaurantId);
DownloadManager.getInstance()
.takeRequestExecute(IActivity, requests, this);
// .setDownloadResultListener(new DownloadManager.OnDownloadResultListener() {
//
// @Override
// public void onSuccess(String respose, int downTag) {
// switch (downTag) {
// case 0://
// FunctionRespone functionBean = GsonUtils.GsonToBean(respose, FunctionRespone.class);
// if (functionBean != null) {
// FunctionDaoUtils functionDao = new FunctionDaoUtils(IActivity);
// functionDao.deleteAll();
// if (functionBean.isSuccess() && functionBean.getData() != null) {
// functionDao.insertMultFunction(functionBean.getData());
// }
// }
// break;
// case 1:
// FoodBean foodBean = GsonUtils.GsonToBean(respose, FoodBean.class);
// if (foodBean != null) {
// FoodDaoUtils foodDao = new FoodDaoUtils(IActivity);
// foodDao.deleteAll();
// if (foodBean.isSuccess() && foodBean.getData() != null) {
// foodDao.insertMultFood(foodBean.getData());
// }
// }
// break;
// case 2:
// ModifierRespone modifier = GsonUtils.GsonToBean(respose, ModifierRespone.class);
// if (modifier != null) {
// ModifierDaoUtils modifierDao = new ModifierDaoUtils(IActivity);
// modifierDao.deleteAll();
// if (modifier.isSuccess() && modifier.getData() != null) {
// modifierDao.insertMultModifier(modifier.getData());
// }
// }
// break;
// case 3:
// FoodComboRespone combo = GsonUtils.GsonToBean(respose, FoodComboRespone.class);
// if (combo != null) {
// FoodComboDaoUtils comboDao = new FoodComboDaoUtils(IActivity);
// comboDao.deleteAll();
// if (combo.isSuccess() && combo.getData() != null) {
// comboDao.insertMultCombo(combo.getData());
// }
// }
// break;
// case 4:
// FoodModifierRespone foodModifier = GsonUtils.GsonToBean(respose, FoodModifierRespone.class);
// if (foodModifier != null) {
// FoodModifierDaoUtils foodModifierDao = new FoodModifierDaoUtils(IActivity);
// foodModifierDao.deleteAll();
// if (foodModifier.isSuccess() && foodModifier.getData() != null) {
// foodModifierDao.insertMultFoodModifier(foodModifier.getData());
// }
// }
// break;
// }
// mList.get(downTag).setState(2);
// mAapter.notifyItemChanged(downTag);
// }
//
// @Override
// public void onError(Throwable t, int downTag) {
// mRootView.showMessage("部分下載失敗,點擊刷新按鈕重新下載");
// }
//
// @Override
// public void noComplete() {
// endDownReturn();
// }
// });
}
public void downFun(int downTag) {
mModel.downFunctionList()
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<Object>(mErrorHandler) {
@Override
public void onSubscribe(Disposable d) {
//订阅前先清空正在执行的订阅
unDispose();
//将所有 Disposable放入集中处理
addDispose(d);
.subscribe(new ErrorHandleSubscriber<FunctionRespone>(mErrorHandler) {
for (int i = 0; i < mList.size(); i++) {
mList.get(i).setState(0);
if (i == 0) {
if (DeviceUtils.netIsConnected(mApplication)) {
//初始化下载状态
mList.get(0).setState(1);
}
}
@Override
public void onNext(@NonNull FunctionRespone functionBean) {
if (functionBean.isSuccess()) {
FunctionDaoUtils functionDao = new FunctionDaoUtils(IActivity);
functionDao.deleteAll();
if (functionBean.isSuccess() && functionBean.getData() != null) {
functionDao.insertMultFunction(functionBean.getData());
}
mAapter.notifyDataSetChanged();
mRootView.getRecycleDownload().smoothScrollToPosition(0);
}
DataDownLoadState loadState = mList.get(downTag);
loadState.setState(2);
mAapter.notifyItemChanged(downTag);
@Override
public void onComplete() {
if (downLoadState) { //下载完成
if (downLoadCount >= mList.size()) {//全部下载成功 返回原来的页面
mRootView.showMessage("下載成功");
currentProgress += loadState.getRatio();
IActivity.setTvProgress(currentProgress);
responseSuccessCount++;
if (responseSuccessCount == requestCount) {
endDownReturn();
} else {//部分下载失败
mRootView.showMessage("部分下載失敗,點擊刷新按鈕重新下載");
}
}
}
@Override
public void onNext(Object o) {
if (o instanceof FunctionRespone) {
FunctionRespone functionBean = (FunctionRespone) o;
if (functionBean != null) {
FunctionDaoUtils functionDao = new FunctionDaoUtils(IActivity);
functionDao.deleteAll();
if (functionBean.isSuccess() && functionBean.getData() != null) {
functionDao.insertMultFunction(functionBean.getData());
public void onError(Throwable t) {
super.onError(t);
DataDownLoadState loadState = mList.get(downTag);
loadState.setState(0);
mRootView.showMessage("部分下載失敗,點擊刷新按鈕重新下載");
}
});
}
downLoadCount++;
mRootView.getRecycleDownload().smoothScrollToPosition(1);
mList.get(0).setState(2);
if (DeviceUtils.netIsConnected(mApplication)) {
mList.get(1).setState(1);
} else {
mRootView.showMessage("Can not connect server, retry?");
}
public void downFoodList(int downTag) {
int restaurantId = GsaCloudApplication.getRestaurantId(IActivity);
mModel.downFoodList(restaurantId)
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<FoodBean>(mErrorHandler) {
} else if (o instanceof FoodBean) {
FoodBean foodBean = (FoodBean) o;
@Override
public void onNext(@NonNull FoodBean foodBean) {
if (foodBean.isSuccess()) {
if (foodBean != null) {
FoodDaoUtils foodDao = new FoodDaoUtils(IActivity);
foodDao.deleteAll();
......@@ -188,17 +267,40 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow
}
}
downLoadCount++;
mRootView.getRecycleDownload().smoothScrollToPosition(1);
DataDownLoadState loadState = mList.get(downTag);
loadState.setState(2);
mAapter.notifyItemChanged(downTag);
mList.get(1).setState(2);
if (DeviceUtils.netIsConnected(mApplication)) {
mList.get(2).setState(1);
} else {
mRootView.showMessage("Can not connect server, retry?");
currentProgress += loadState.getRatio();
IActivity.setTvProgress(currentProgress);
responseSuccessCount++;
if (responseSuccessCount == requestCount) {
endDownReturn();
}
}
}
@Override
public void onError(Throwable t) {
super.onError(t);
DataDownLoadState loadState = mList.get(downTag);
loadState.setState(0);
mRootView.showMessage("部分下載失敗,點擊刷新按鈕重新下載");
}
});
}
} else if (o instanceof ModifierRespone) {
ModifierRespone modifier = (ModifierRespone) o;
public void downModifier(int downTag) {
int restaurantId = GsaCloudApplication.getRestaurantId(IActivity);
mModel.downModifier(restaurantId)
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<ModifierRespone>(mErrorHandler) {
@Override
public void onNext(@NonNull ModifierRespone modifier) {
if (modifier.isSuccess()) {
if (modifier != null) {
ModifierDaoUtils modifierDao = new ModifierDaoUtils(IActivity);
modifierDao.deleteAll();
......@@ -206,36 +308,123 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow
modifierDao.insertMultModifier(modifier.getData());
}
}
DataDownLoadState loadState = mList.get(downTag);
loadState.setState(2);
mAapter.notifyItemChanged(downTag);
downLoadCount++;
mRootView.getRecycleDownload().smoothScrollToPosition(1);
mList.get(2).setState(2);
if (DeviceUtils.netIsConnected(mApplication)) {
mList.get(3).setState(1);
} else {
mRootView.showMessage("Can not connect server, retry?");
currentProgress += loadState.getRatio();
IActivity.setTvProgress(currentProgress);
responseSuccessCount++;
if (responseSuccessCount == requestCount) {
endDownReturn();
}
}
}
@Override
public void onError(Throwable t) {
super.onError(t);
DataDownLoadState loadState = mList.get(downTag);
loadState.setState(0);
mRootView.showMessage("部分下載失敗,點擊刷新按鈕重新下載");
}
});
}
public void downFoodCombo(int downTag) {
int restaurantId = GsaCloudApplication.getRestaurantId(IActivity);
mModel.downFoodCombo(restaurantId)
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<FoodComboRespone>(mErrorHandler) {
@Override
public void onNext(@NonNull FoodComboRespone combo) {
if (combo.isSuccess()) {
if (combo != null) {
FoodComboDaoUtils comboDao = new FoodComboDaoUtils(IActivity);
comboDao.deleteAll();
if (combo.isSuccess() && combo.getData() != null) {
comboDao.insertMultCombo(combo.getData());
}
}
DataDownLoadState loadState = mList.get(downTag);
loadState.setState(2);
mAapter.notifyItemChanged(downTag);
currentProgress += loadState.getRatio();
IActivity.setTvProgress(currentProgress);
responseSuccessCount++;
if (responseSuccessCount == requestCount) {
endDownReturn();
}
} else if (o instanceof ComboRespone) {
ComboRespone combo = (ComboRespone) o;
}
}
@Override
public void onError(Throwable t) {
super.onError(t);
DataDownLoadState loadState = mList.get(downTag);
loadState.setState(0);
mRootView.showMessage("部分下載失敗,點擊刷新按鈕重新下載");
}
});
}
public void downComboItem(int downTag) {
int restaurantId = GsaCloudApplication.getRestaurantId(IActivity);
mModel.downComboItem(restaurantId)
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<ComboItemRespone>(mErrorHandler) {
@Override
public void onNext(@NonNull ComboItemRespone combo) {
if (combo.isSuccess()) {
if (combo != null) {
ComboDaoUtils comboDao = new ComboDaoUtils(IActivity);
ComboItemDaoUtils comboDao = new ComboItemDaoUtils(IActivity);
comboDao.deleteAll();
if (combo.isSuccess() && combo.getData() != null) {
comboDao.insertMultCombo(combo.getData());
}
}
DataDownLoadState loadState = mList.get(downTag);
loadState.setState(2);
mAapter.notifyItemChanged(downTag);
downLoadCount++;
mRootView.getRecycleDownload().smoothScrollToPosition(1);
mList.get(3).setState(2);
if (DeviceUtils.netIsConnected(mApplication)) {
mList.get(4).setState(1);
} else {
mRootView.showMessage("Can not connect server, retry?");
currentProgress += loadState.getRatio();
IActivity.setTvProgress(currentProgress);
responseSuccessCount++;
if (responseSuccessCount == requestCount) {
endDownReturn();
}
}
}
@Override
public void onError(Throwable t) {
super.onError(t);
DataDownLoadState loadState = mList.get(downTag);
loadState.setState(0);
mRootView.showMessage("部分下載失敗,點擊刷新按鈕重新下載");
}
});
}
} else if (o instanceof FoodModifierRespone) {
FoodModifierRespone foodModifier = (FoodModifierRespone) o;
public void downFoodModifier(int downTag) {
int restaurantId = GsaCloudApplication.getRestaurantId(IActivity);
mModel.downFoodModifier(restaurantId)
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<FoodModifierRespone>(mErrorHandler) {
@Override
public void onNext(@NonNull FoodModifierRespone foodModifier) {
if (foodModifier.isSuccess()) {
if (foodModifier != null) {
FoodModifierDaoUtils foodModifierDao = new FoodModifierDaoUtils(IActivity);
foodModifierDao.deleteAll();
......@@ -243,25 +432,58 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow
foodModifierDao.insertMultFoodModifier(foodModifier.getData());
}
}
downLoadCount++;
mRootView.getRecycleDownload().smoothScrollToPosition(1);
downLoadState = true;
}
DataDownLoadState loadState = mList.get(downTag);
loadState.setState(2);
mAapter.notifyItemChanged(downTag);
mAapter.notifyDataSetChanged();
currentProgress += loadState.getRatio();
IActivity.setTvProgress(currentProgress);
responseSuccessCount++;
if (responseSuccessCount == requestCount) {
endDownReturn();
}
}
}
@Override
public void onError(Throwable t) {
//这里报错需要累加一
downLoadCount++;
super.onError(t);
DataDownLoadState loadState = mList.get(downTag);
loadState.setState(0);
mRootView.showMessage("部分下載失敗,點擊刷新按鈕重新下載");
// downAllList();
}
});
}
private void initDownState() {
for (int i = 0; i < mList.size(); i++) {
//初始化下载状态
mList.get(i).setState(1);
}
mAapter.notifyDataSetChanged();
}
private String[] getDownloadUrls(int restaurantId) {
for (int i = 0; i < urlList.length; i++) {
if (i != 0) {
urlList[i] += "?restaurantId=" + restaurantId;
}
}
return urlList;
}
private List<DownloadRequest> getDownloadRequests(String[] urls, int restaurantId) {
List<DownloadRequest> requests = new ArrayList<>();
for (int i = 0; i < urls.length; i++) {
DownloadRequest request = new DownloadRequest();
request.setRestaurantId(restaurantId);
request.setDownTag(i);
request.setUrl(urls[i]);
requests.add(request);
}
return requests;
}
private void endDownReturn() {
CC.obtainBuilder("Component.Main")
.setActionName("showMainActivity")
......@@ -279,4 +501,21 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow
}
}
/**
* 設置下載進度比例
*/
public void setDownAverageRatio() {
if (ratios.length != mList.size()) {
for (int i = 0; i < mList.size(); i++) {
//初始化下载状态
mList.get(i).setRatio(100 / mList.size());
}
return;
}
for (int i = 0; i < mList.size(); i++) {
//初始化下载状态
mList.get(i).setRatio(ratios[i]);
}
}
}
package com.gingersoft.gsa.cloud.download.mvp.ui.activity;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.download.R;
......@@ -15,10 +23,13 @@ import com.jess.arms.base.BaseActivity;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.QMUITopBar;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
......@@ -45,6 +56,8 @@ public class DownloadActivity extends BaseActivity<DownloadPresenter> implements
@BindView(R2.id.recycle_download)
RecyclerView recycle_download;
@BindView(R2.id.tv_progress)
TextView tv_progress;
@Override
public void setupActivityComponent(@NonNull AppComponent appComponent) {
......@@ -58,6 +71,7 @@ public class DownloadActivity extends BaseActivity<DownloadPresenter> implements
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
setTransparent(this);
super.onCreate(savedInstanceState);
}
......@@ -79,15 +93,22 @@ public class DownloadActivity extends BaseActivity<DownloadPresenter> implements
@Override
public void initTopBar() {
// mTopBar.setBackgroundColor(ContextCompat.getColor(this, R.color.white));
mTopBar.addLeftImageButton(R.drawable.icon_back, R.id.iv_left_back).setOnClickListener(v -> finish());
mTopBar.addRightTextButton("刷新", R.id.topbar).setOnClickListener(new View.OnClickListener() {
QMUIAlphaImageButton leftButton = mTopBar.addLeftBackImageButton();
leftButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
killMyself();
}
});
QMUIAlphaImageButton rightButton = mTopBar.addRightImageButton(R.drawable.icon_refresh, R.id.btn_back);
rightButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPresenter.downAllList();
}
});
mTopBar.setTitle("數據下載");
mTopBar.setTitle("數據下載").setTextColor(ArmsUtils.getColor(this, R.color.theme_white_color));
}
@Override
......@@ -151,4 +172,54 @@ public class DownloadActivity extends BaseActivity<DownloadPresenter> implements
LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
ArmsUtils.configRecyclerView(recycle_download, manager);
}
public void setTvProgress(float progress) {
tv_progress.setText(progress + "%");
}
/**
* 设置状态栏全透明
*
* @param activity 需要设置的activity
*/
public static void setTransparent(Activity activity) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
transparentStatusBar(activity);
// setRootView(activity);
}
/**
* 使状态栏透明
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void transparentStatusBar(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//需要设置这个flag contentView才能延伸到状态栏
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
//状态栏覆盖在contentView上面,设置透明使contentView的背景透出来
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
} else {
//让contentView延伸到状态栏并且设置状态栏颜色透明
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
}
/**
* 设置根布局参数
*/
private static void setRootView(Activity activity) {
ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content);
for (int i = 0, count = parent.getChildCount(); i < count; i++) {
View childView = parent.getChildAt(i);
if (childView instanceof ViewGroup) {
childView.setFitsSystemWindows(true);
((ViewGroup) childView).setClipToPadding(true);
}
}
}
}
......@@ -2,20 +2,54 @@
<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@mipmap/down_decoration">
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/topbar"
android:layout_width="match_parent"
android:layout_height="?attr/qmui_topbar_height" />
android:layout_height="?attr/qmui_topbar_height"
android:layout_marginTop="@dimen/dp_20"
android:background="@color/trans" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@mipmap/down_cloud"/>
<TextView
android:id="@+id/tv_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="100%"
android:layout_gravity="center"
android:layout_marginTop="@dimen/dp_12"
android:textColor="#13B7F5"
android:textSize="@dimen/sp_24" />
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycle_download"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fadeScrollbars="false"
android:layout_marginTop="?attr/qmui_topbar_height"
android:listSelector="@color/theme_background_color">
</androidx.recyclerview.widget.RecyclerView>
android:background="@mipmap/down_wave"
android:paddingTop="@dimen/dp_50"
android:listSelector="@color/theme_background_color"/>
</LinearLayout>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>
\ No newline at end of file
......@@ -96,7 +96,7 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
public void initData(@Nullable Bundle savedInstanceState) {
initShadow();
initFuncationData();
setTopInfo();
setTitleInfo();
}
private void initShadow() {
......@@ -165,7 +165,7 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
rvStaffManagement.setAdapter(staffAdapter);
}
private void setTopInfo() {
private void setTitleInfo() {
String restaurantName = GsaCloudApplication.getRestaurantName(this);
String memberName = GsaCloudApplication.getMemberName(this);
if (!TextUtils.isEmpty(restaurantName)) {
......@@ -184,9 +184,17 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
new ChooseRestaurantDialog.BottomListSheetBuilder(this)
.addBrandItems(brandsBeans)
.setOnItemClickListener((dialog, item, position) -> {
LoginBean.DataBean.UserBean.BrandsBean brandsBean = getBrandByRestaurantId(brandsBeans, item.getId());
if(brandsBean != null) {
saveBrandAndRestaurantInfo(brandsBean.getBrandId(), brandsBean.getBrandName(), item.getId(), item.getText());
}
GsaCloudApplication.setRestaurantId(NewMainActivity.this, item.getId());
GsaCloudApplication.setRestaurantName(NewMainActivity.this, item.getText());
setTopInfo();
setTitleInfo();
CC.obtainBuilder("Component.Download")
.setActionName("showDownloadActivity")
.build()
......@@ -199,6 +207,26 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
}
}
private void saveBrandAndRestaurantInfo(int brandId, String brandName, int restaurantId, String restaurantName) {
GsaCloudApplication.setBrandId(this, brandId);
GsaCloudApplication.setBrandName(this, brandName);
GsaCloudApplication.setRestaurantId(this, restaurantId);
GsaCloudApplication.setRestaurantName(this, restaurantName);
}
private LoginBean.DataBean.UserBean.BrandsBean getBrandByRestaurantId(List<LoginBean.DataBean.UserBean.BrandsBean> brands, int restaurantId) {
for (int i = 0; i < brands.size(); i++) {
if (brands.get(i).getRestaurants() != null) {
for (int j = 0; j < brands.get(i).getRestaurants().size(); j++) {
if (brands.get(i).getRestaurants().get(j).getRestaurantId() == restaurantId) {
return brands.get(i);
}
}
}
}
return null;
}
@Override
public void initIntent() {
......@@ -259,7 +287,7 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
}
};
@OnClick({R2.id.layout_login_out, R2.id.iv_personal_center})
@OnClick({R2.id.layout_login_out, R2.id.iv_personal_center,R2.id.tv_restaurant_name})
@Override
public void onClick(View v) {
if (v.getId() == R.id.layout_login_out) {
......
......@@ -108,15 +108,16 @@ public class PrintComponent implements IComponent {
}
private boolean print(CC cc) {
Context context = cc.getContext();
Intent intent = new Intent(context, PrintActivity.class);
if (!(context instanceof Activity)) {
//调用方没有设置context或app间组件跳转,context为application
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
//将cc的callId传给Activity,登录完成后通过这个callId来回传结果
intent.putExtra("callId", cc.getCallId());
context.startActivity(intent);
// Context context = cc.getContext();
// Intent intent = new Intent(context, PrintActivity.class);
// if (!(context instanceof Activity)) {
// //调用方没有设置context或app间组件跳转,context为application
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// }
// //将cc的callId传给Activity,登录完成后通过这个callId来回传结果
// intent.putExtra("callId", cc.getCallId());
// context.startActivity(intent);
CCUtil.navigateTo(cc,PrintActivity.class);
//返回true,不立即调用CC.sendCCResult
return true;
}
......
......@@ -193,16 +193,20 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
* 打印失敗
*/
private void printFile() {
CC.sendCCResult(getIntent().getStringExtra("callId"), CCResult.error("print error"));
String callId = CCUtil.getNavigateCallId(this);
CC.sendCCResult(callId, CCResult.error("print error"));
finish();
}
/**
* 打印成功
*/
private void printSuccess() {
CC.sendCCResult(getIntent().getStringExtra("callId"), CCResult.success());
String callId = CCUtil.getNavigateCallId(this);
CC.sendCCResult(callId, CCResult.success());
finish();
}
//初始化打印內容
public Bitmap initPrintBitmap(int width) {
Bitmap bitmap = getIntent().getParcelableExtra("bitmap");
......
......@@ -41,7 +41,7 @@ android {
/**
* 版本号
*/
schemaVersion 13
schemaVersion 8
/**
* greendao输出dao的数据库操作实体类文件夹(相对路径 包名+自定义路径名称,包将创建于包名的直接路径下)
*/
......@@ -80,6 +80,7 @@ dependencies {
implementation rootProject.ext.dependencies["BaseRecyclerViewAdapter"]
implementation 'com.android.support:design:28.0.0'
implementation 'com.gcssloop.recyclerview:pagerlayoutmanager:2.3.8'
//陰影背景
// implementation 'com.github.Liberuman:ShadowDrawable:0.1'
api 'com.github.lihangleo2:ShadowLayout:2.1.6'
......
......@@ -20,7 +20,8 @@ public interface Api {
String modifier = "food/items";
//食品套餐關係
String food_package_relation = "food/package";
//套餐食品關係
String food_comboItem = "food/comboItem";
//食品細項關係
String food_modifiere_relation = "food/modifierDetail";
}
......@@ -23,7 +23,7 @@ public class BillTypeAdapter extends BaseQuickAdapter<PayMethod, BaseViewHolder>
@Override
protected void convert(BaseViewHolder helper, PayMethod item) {
helper.setText(R.id.tv_total_amount_text, item.getName());
helper.setText(R.id.tv_total_amount_text, item.getPayName());
helper.setText(R.id.tv_total_amount, item.getPayMoney() + "");
}
}
......@@ -32,6 +32,10 @@ public class GsaCloudApplication extends BaseApplication {
* 系统上下文
*/
private static Context mAppContext;
/**
* 设置请求超时默认20秒钟 从后台获取超时时间
*/
public static int REQUEST_TIMEOUT = 20;
public static boolean isLogin = false;
public static CurrentAndroidSetting androidSetting;
......@@ -107,6 +111,14 @@ public class GsaCloudApplication extends BaseApplication {
return (int) SPUtils.get(context, UserConstans.memberId, 0);
}
public static int getBrandId(Context context) {
return (int) SPUtils.get(context, UserConstans.brandId, 0);
}
public static String getBrandName(Context context) {
return (String) SPUtils.get(context, UserConstans.brandName, "");
}
public static int getRestaurantId(Context context) {
return (int) SPUtils.get(context, UserConstans.restaurantId, 0);
}
......@@ -135,6 +147,13 @@ public class GsaCloudApplication extends BaseApplication {
SPUtils.put(context, UserConstans.memberName, memberName);
}
public static void setBrandId(Context context, int restaurantId) {
SPUtils.put(context, UserConstans.brandId, restaurantId);
}
public static void setBrandName(Context context, String restaurantName) {
SPUtils.put(context, UserConstans.brandName, restaurantName);
}
public static void setRestaurantId(Context context, int restaurantId) {
SPUtils.put(context, UserConstans.restaurantId, restaurantId);
}
......@@ -145,5 +164,4 @@ public class GsaCloudApplication extends BaseApplication {
SPUtils.put(context, UserConstans.brandRestaurantInfos, brandRestaurantIds);
}
}
......@@ -23,6 +23,7 @@ public class OrderBean {
private int id;
private String orderNo;
private int status;
private int person;
private double totalAmount;
private double totalPoints;
private String createTime;
......@@ -31,11 +32,12 @@ public class OrderBean {
public OrderBean() {
}
public OrderBean(int id, String orderNo, int status, String createTime) {
this.id = id;
this.orderNo = orderNo;
this.status = status;
this.createTime = createTime;
public OrderBean(OrderBean orderBean) {
this.id = orderBean.id;
this.status = orderBean.status;
this.orderNo = orderBean.orderNo;
this.person = orderBean.person;
this.createTime = orderBean.createTime;
}
public int getId() {
......@@ -62,6 +64,14 @@ public class OrderBean {
this.status = status;
}
public int getPerson() {
return person;
}
public void setPerson(int person) {
this.person = person;
}
public double getTotalAmount() {
return totalAmount;
}
......
package com.gingersoft.gsa.cloud.base.common.bean;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.FoodCombo;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.Modifier;
......@@ -561,19 +561,19 @@ public class OrderDetail implements Serializable {
/**
* 套餐食品轉換
*
* @param combo
* @param foodCombo
* @param number
* @param prop
* @param isRvMealClicked
* @return
*/
public static OrderDetail comboTransOrderDetail(Combo combo, int number, String prop, boolean isRvMealClicked) {
public static OrderDetail comboTransOrderDetail(FoodCombo foodCombo, int number, String prop, boolean isRvMealClicked) {
OrderDetail orderDetail = new OrderDetail();
orderDetail.setProductName(combo.getName());
orderDetail.setId(combo.getId());
orderDetail.setProductId(combo.getComId());
orderDetail.setParentId(combo.getFid());
orderDetail.setUnit_price(combo.getPrice());
orderDetail.setProductName(foodCombo.getName());
orderDetail.setId(foodCombo.getId());
orderDetail.setProductId(foodCombo.getComId());
orderDetail.setParentId(foodCombo.getFid());
orderDetail.setUnit_price(foodCombo.getPrice());
orderDetail.setPrice(number * orderDetail.getUnit_price());
orderDetail.setNumber(number);
orderDetail.setOrderId(MyOrderManage.getInstance().getOrderId());
......@@ -582,7 +582,7 @@ public class OrderDetail implements Serializable {
orderDetail.setType(FOOD_TYPE);
orderDetail.setItemType(2);
orderDetail.setProp(prop);
// orderDetail.setComboAuto(combo.isAutoMode());
// orderDetail.setComboAuto(foodCombo.isAutoMode());
if (isRvMealClicked) {
//手动点击细项 才将子食品作为主体被选中
orderDetail.setSelected(2);
......
......@@ -2,7 +2,7 @@ package com.gingersoft.gsa.cloud.base.common.bean;
import android.graphics.Color;
import java.util.List;
import com.google.gson.annotations.SerializedName;
/**
* 作者:ELEGANT_BIN
......@@ -13,8 +13,16 @@ import java.util.List;
*/
public class PayMethod {
/**
* success : true
* sysTime : 1582865195628
* data : [{"id":11,"payName":"服務員確認","createTime":"May 7, 2018 11:47:27 AM"},{"id":1019,"payName":"轉數快支付","remarks":"","createTime":"Jul 10, 2019 4:56:21 PM"},{"id":9,"payName":"微信","createTime":"Jun 29, 2018 4:34:26 PM"},{"id":10,"payName":"Apple pay","createTime":"Aug 9, 2018 3:59:05 PM"},{"id":1010,"payName":"YedPay支付宝"},{"id":6,"payName":"支付寶HK","createTime":"Sep 12, 2017 2:45:12 PM"},{"id":8,"payName":"支付寶","createTime":"Jan 5, 2018 10:55:06 AM"},{"id":1020,"payName":"PayMe","createTime":"Nov 29, 2019 6:07:56 PM"}]
*/
private int id;
private String name;
private String payName;
private String createTime;
private String remarks;
private String NAME;
private String NAME2;
......@@ -24,13 +32,14 @@ public class PayMethod {
//*************自定義字段***************
private double payMoney = 0.0;
private double TipsPrice = 0.0;
private int payModeTextColor = android.graphics.Color.parseColor("#000000");
private int payMoneyTextColor = android.graphics.Color.parseColor("#000000");
private int payModeTextSelectColor = android.graphics.Color.parseColor("#000000");
private int payModeTextColor = Color.parseColor("#000000");
private int payMoneyTextColor = Color.parseColor("#000000");
private int payModeTextSelectColor = Color.parseColor("#000000");
private int payMoneyTextSelectColor = Color.parseColor("#000000");
private int payModeSize = 18;
private int payMoneySize = 18;
public int getId() {
return id;
}
......@@ -39,16 +48,52 @@ public class PayMethod {
this.id = id;
}
public String getName() {
return name;
public String getPayName() {
return payName;
}
public void setName(String name) {
this.name = name;
public void setPayName(String payName) {
this.payName = payName;
}
public String getPayName() {
return name;
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getNAME() {
return NAME;
}
public void setNAME(String NAME) {
this.NAME = NAME;
}
public String getNAME2() {
return NAME2;
}
public void setNAME2(String NAME2) {
this.NAME2 = NAME2;
}
public String getNAME3() {
return NAME3;
}
public void setNAME3(String NAME3) {
this.NAME3 = NAME3;
}
public String getPAYWAY() {
......
......@@ -2,14 +2,12 @@ package com.gingersoft.gsa.cloud.base.common.bean.mealManage;
import android.app.Activity;
import com.gingersoft.gsa.cloud.base.common.bean.BillMethodBean;
import com.gingersoft.gsa.cloud.base.common.bean.OrderBean;
import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
import com.gingersoft.gsa.cloud.base.common.bean.PayMethod;
import com.gingersoft.gsa.cloud.base.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.database.bean.Food;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
......@@ -89,10 +87,18 @@ public class MyOrderManage {
return 0;
}
public Date getOpenTableTime() {
if (orderBean != null) {
return new Date(orderBean.getCreateTime());
}
return new Date();
}
public void setOrderBean(OrderBean orderBean) {
this.orderBean = orderBean;
}
public void changeNumber(int number) {
if (orderFoodList.size() <= 0) {
......
......@@ -22,7 +22,7 @@ public class OpenTableManage {
//是否刷新數據
private boolean isRefresh = false;
//開台人數
private int peopleNumber;
private int peopleNumber = 0;
//是否分檯
private boolean isSplite = false;
//分檯編號
......@@ -38,6 +38,10 @@ public class OpenTableManage {
return sDefaultOpenTableManage;
}
public void clear() {
peopleNumber = 0;
}
public TableBean.DataBean getTableBean() {
return tableBean;
}
......
package com.gingersoft.gsa.cloud.base.threadPool;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019-11-18
* 修订历史:2019-11-18
* 描述:
*/
public class Test {
public static void main(String[] args) {
ThreadPoolManager threadPoolManager = ThreadPoolManager.getInstence();
}
}
package com.gingersoft.gsa.cloud.base.threadPool;
import android.util.Log;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019-11-18
* 修订历史:2019-11-18
* 描述: 線程池管理類
*/
public class ThreadPoolManager {
private String TAG =this.getClass().getSimpleName();
private static ThreadPoolManager instence = null;
private ThreadPoolExecutor mThreadPoolExecutor;
//线程数量,核心线程数
private int corePoolSize = 5;
//池中允许的最大线程数
private int maximumPoolSize = 10;
//设置空闲线程的空闲时间,如果一共有6个线程,那么超出核心线程数的两个线程就会被记录时间,超过该时间就会被杀死,如果没有超过核心线程数,那么线程是不会被倒计时的。
private long keepAliveTime = 10;
//等待执行的容器容量大小
private int capacity = 10;
//拒绝后的执行任务容器--》凉快的地方
private LinkedBlockingQueue taskQueue =new LinkedBlockingQueue();
public synchronized static ThreadPoolManager getInstence() {
if (instence == null) {
synchronized (ThreadPoolManager.class) {
if (instence == instence) {
instence = new ThreadPoolManager();
}
}
}
return instence;
}
/**
* 构造方法里面就初始化线程池
* ArrayBlockingQueue是一个执行任务的容量,当调用mThreadPoolExecutor的execute,容量加1,执行run完后,容量减1
* ArrayBlockingQueue后面传入true就是以FIFO规则存储:先进先出
*/
public ThreadPoolManager(){
if(mThreadPoolExecutor==null){
mThreadPoolExecutor = new ThreadPoolExecutor(corePoolSize,maximumPoolSize,keepAliveTime, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(capacity,true),handler);
}
//开启线程一直循环从等待队列里面取出可执行任务并执行
mThreadPoolExecutor.execute(runnable);
}
/**
* 往队列里面存入可执行任务
* @param runnable
*/
public void putExecutableTasks(Runnable runnable){
try {
taskQueue.put(runnable);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
/**
* ThreadPoolExecutor的run
*/
private Runnable runnable=new Runnable() {
@Override
public void run() {
//开启循环
while(true){
//取出等待的执行任务
Runnable taskQueueRunnable = null;
try {
Log.d(TAG,"等待队列大小:"+taskQueue.size());
taskQueueRunnable = (Runnable) taskQueue.take();
} catch (InterruptedException e) {
e.printStackTrace();
}
if(runnable!=null){
mThreadPoolExecutor.execute(taskQueueRunnable);
}
Log.d(TAG,"线程池大小"+mThreadPoolExecutor.getPoolSize());
}
}
};
/**
* 拒绝策略
* 当ArrayBlockingQueue容量过大,就要执行拒绝策略,对来的执行任务说:放不下了,先到一边凉快去,那么就要有一个凉快的容器撞他们
*
*/
private RejectedExecutionHandler handler = new RejectedExecutionHandler(){
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
try {
taskQueue.put(r);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
}
......@@ -5,8 +5,8 @@ package com.gingersoft.gsa.cloud.base.utils.constans;
*/
public class HttpsConstans {
public static String ROOT_SERVER_ADDRESS_FORMAL = "http://gingersoft.tpddns.cn:58201/ricepon-cloud-gsa/api/";// 深圳服务器
// public static String ROOT_SERVER_ADDRESS_FORMAL = "http://a.ricepon.com:58201/ricepon-cloud-gsa/api/";// 香港服务器
// public static String ROOT_SERVER_ADDRESS_FORMAL = "http://gingersoft.tpddns.cn:58201/ricepon-cloud-gsa/api/";// 深圳服务器
public static String ROOT_SERVER_ADDRESS_FORMAL = "http://a.ricepon.com:58201/ricepon-cloud-gsa/api/";// 香港服务器
public static String ROOT_SERVER_ADDRESS_FORMAL2 = "http://gingersoft.tpddns.cn:53000/mock/49/ricepon-cloud-gsa/api/";//測試服務器
......
......@@ -12,6 +12,8 @@ public class UserConstans {
/**當前餐檯ID,名稱*/
public static String restaurantId = "restaurant_id";
public static String restaurantName = "restaurant_name";
public static String brandId = "brand_id";
public static String brandName = "brand_name";
/**當前賬號下所有餐檯品牌Json*/
public static String brandRestaurantInfos = "brand_restaurant_infos";
......
package com.gingersoft.gsa.cloud.base.utils.okhttpUtils;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.constans.AppConstans;
import com.gingersoft.gsa.cloud.base.utils.encryption.Aes;
import com.gingersoft.gsa.cloud.base.utils.other.AppUtils;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Headers;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019/1/10
* 修订历史:2019/1/10
* 描述:
*/
public class OkHttp3Utils {
private static volatile OkHttpClient mOkHttpClient;
private static final MediaType MEDIA_TYPE_PNG = MediaType.parse("image/png");
public static void getOkHttpClient() {
if (mOkHttpClient == null) {
synchronized (OkHttp3Utils.class) {
if (mOkHttpClient == null) {
mOkHttpClient = new OkHttpClient.Builder()
.connectTimeout(GsaCloudApplication.REQUEST_TIMEOUT, TimeUnit.SECONDS)
.readTimeout(GsaCloudApplication.REQUEST_TIMEOUT, TimeUnit.SECONDS)
.addInterceptor(new UserAgentIntercepter())
.build();
}
}
}
}
public static Observable<String> get(String reqUrl) {
getOkHttpClient();
return Observable.create(new ObservableOnSubscribe<String>() {
@Override
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
//构建请求体
Request.Builder RequestBuilder = new Request.Builder();
RequestBuilder.url(reqUrl);// 添加URL地址
Request request = RequestBuilder.build();
mOkHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
emitter.onError(e);
emitter.onComplete();
call.cancel();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String str = response.body().string();
emitter.onNext(str);
emitter.onComplete();
call.cancel();
}
});
}
});
}
public static Observable<String> post(String reqUrl, RequestBody requestBody) {
getOkHttpClient();
return Observable.create(new ObservableOnSubscribe<String>() {
@Override
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
//构建请求体
Request.Builder RequestBuilder = new Request.Builder();
RequestBuilder.url(reqUrl);// 添加URL地址
RequestBuilder.post(requestBody);
Request request = RequestBuilder.build();
mOkHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
emitter.onError(e);
emitter.onComplete();
call.cancel();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String str = response.body().string();
emitter.onNext(str);
emitter.onComplete();
call.cancel();
}
});
}
});
}
/**
* 上传文件
*
* @param reqUrl URL地址
* @param file_key 上传文件的关键字
* @param files 文件
*/
public static Observable<String> sendFileMultipart(String reqUrl, String file_key, List<File> files) {
getOkHttpClient();
return Observable.create(new ObservableOnSubscribe<String>() {
@Override
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder();
multipartBodyBuilder.setType(MultipartBody.FORM);
//遍历paths中所有图片绝对路径到builder,并约定key如“upload”作为后台接受多张图片的key
if (files != null) {
for (int i = 0; i < files.size(); i++) {
multipartBodyBuilder.addFormDataPart(file_key + i, files.get(i).getName(), RequestBody.create(MEDIA_TYPE_PNG, files.get(i)));
}
}
//构建请求体
RequestBody requestBody = multipartBodyBuilder.build();
Request.Builder RequestBuilder = new Request.Builder();
RequestBuilder.url(reqUrl);// 添加URL地址
RequestBuilder.post(requestBody);
Request request = RequestBuilder.build();
mOkHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
emitter.onError(e);
emitter.onComplete();
call.cancel();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String str = response.body().string();
emitter.onNext(str);
emitter.onComplete();
call.cancel();
}
});
}
});
}
/**
* 上传多张图片及参数
*
* @param reqUrl URL地址
* @param params 参数
* @param pic_key 上传图片的关键字
* @param files 图片文件
*/
public static Observable<String> sendImageMultipart(String reqUrl, HashMap<String, String> params, String pic_key, List<File> files) {
getOkHttpClient();
return Observable.create(new ObservableOnSubscribe<String>() {
@Override
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder();
multipartBodyBuilder.setType(MultipartBody.FORM);
//遍历map中所有参数到builder
if (params != null) {
for (String key : params.keySet()) {
multipartBodyBuilder.addFormDataPart(key, params.get(key));
}
}
//遍历paths中所有图片绝对路径到builder,并约定key如“upload”作为后台接受多张图片的key
if (files != null) {
for (int i = 0; i < files.size(); i++) {
multipartBodyBuilder.addFormDataPart(pic_key + i, files.get(i).getName(), RequestBody.create(MEDIA_TYPE_PNG, files.get(i)));
}
}
//构建请求体
RequestBody requestBody = multipartBodyBuilder.build();
Request.Builder RequestBuilder = new Request.Builder();
RequestBuilder.url(reqUrl);// 添加URL地址
RequestBuilder.post(requestBody);
Request request = RequestBuilder.build();
mOkHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
emitter.onError(e);
emitter.onComplete();
call.cancel();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String str = response.body().string();
emitter.onNext(str);
emitter.onComplete();
call.cancel();
}
});
}
});
}
/**
* 添加请求头
*/
public static class UserAgentIntercepter implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request2 = chain.request();
String token = "";
if (GsaCloudApplication.isLogin) {
int memberId = GsaCloudApplication.getMemberId(GsaCloudApplication.getAppContext());
String loginToken = GsaCloudApplication.getLoginToken(GsaCloudApplication.getAppContext());
token = Aes.aesEncrypt("9_" + memberId + "_" + System.currentTimeMillis() + "_" + loginToken);
token = token.replaceAll("\r|\n", "");
}
Headers.Builder builder = new Headers.Builder();
builder.set("mobileVersion", android.os.Build.VERSION.RELEASE);//set表示name1是唯一的,会覆盖掉已经存在的,add不会覆盖已经存在的头,可以存在多个
builder.set("mobielModel", android.os.Build.MODEL);
builder.set("apptype", AppConstans.APP_TYPE);
builder.set("appinfo", AppUtils.getVerName(GsaCloudApplication.getAppContext()));
builder.set("mobileId", "1");
if (GsaCloudApplication.isLogin)
builder.set("token", token);
builder.set("Domain-Name", "common");
request2.newBuilder().headers(builder.build()).build();
return chain.proceed(request2);
}
}
}
package com.gingersoft.gsa.cloud.database.bean;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import java.util.Date;
import org.greenrobot.greendao.annotation.Generated;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-02-18
* 修订历史:2020-02-18
* 描述:套餐食品關係
*/
@Entity
public class ComboItem {
/**
* ID
*/
@Property(nameInDb = "_id")
@Id(autoincrement = true)
private Long id;
private Long comId;
private Long fid;
private Long qty;
private Double diffAmt;
private Long seqNo;
private Long visible;
private Date createTime;
private String createBy;
private Date updateTime;
private Long conditions;
private Long isRT;
private Byte deletes;
private Long posId;
private Long restaurant_id;
private Byte isMainAccount;
@Generated(hash = 1857315418)
public ComboItem(Long id, Long comId, Long fid, Long qty, Double diffAmt,
Long seqNo, Long visible, Date createTime, String createBy,
Date updateTime, Long conditions, Long isRT, Byte deletes, Long posId,
Long restaurant_id, Byte isMainAccount) {
this.id = id;
this.comId = comId;
this.fid = fid;
this.qty = qty;
this.diffAmt = diffAmt;
this.seqNo = seqNo;
this.visible = visible;
this.createTime = createTime;
this.createBy = createBy;
this.updateTime = updateTime;
this.conditions = conditions;
this.isRT = isRT;
this.deletes = deletes;
this.posId = posId;
this.restaurant_id = restaurant_id;
this.isMainAccount = isMainAccount;
}
@Generated(hash = 435228340)
public ComboItem() {
}
public Long getId() {
return id;
}
public Long getComId() {
return comId;
}
public Long getFid() {
return fid;
}
public Long getQty() {
return qty;
}
public Double getDiffAmt() {
return diffAmt;
}
public Long getSeqNo() {
return seqNo;
}
public Long getVisible() {
return visible;
}
public Date getCreateTime() {
return createTime;
}
public String getCreateBy() {
return createBy;
}
public Date getUpdateTime() {
return updateTime;
}
public Long getConditions() {
return conditions;
}
public Long getIsRT() {
return isRT;
}
public Byte getDeletes() {
return deletes;
}
public Long getPosId() {
return posId;
}
public Long getRestaurant_id() {
return restaurant_id;
}
public Byte getIsMainAccount() {
return isMainAccount;
}
public void setId(Long id) {
this.id = id;
}
public void setComId(Long comId) {
this.comId = comId;
}
public void setFid(Long fid) {
this.fid = fid;
}
public void setQty(Long qty) {
this.qty = qty;
}
public void setDiffAmt(Double diffAmt) {
this.diffAmt = diffAmt;
}
public void setSeqNo(Long seqNo) {
this.seqNo = seqNo;
}
public void setVisible(Long visible) {
this.visible = visible;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public void setConditions(Long conditions) {
this.conditions = conditions;
}
public void setIsRT(Long isRT) {
this.isRT = isRT;
}
public void setDeletes(Byte deletes) {
this.deletes = deletes;
}
public void setPosId(Long posId) {
this.posId = posId;
}
public void setRestaurant_id(Long restaurant_id) {
this.restaurant_id = restaurant_id;
}
public void setIsMainAccount(Byte isMainAccount) {
this.isMainAccount = isMainAccount;
}
}
......@@ -5,11 +5,17 @@ import android.graphics.Color;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.JoinEntity;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToMany;
import org.greenrobot.greendao.annotation.Transient;
import org.jetbrains.annotations.NotNull;
import java.util.Date;
import java.util.List;
import org.greenrobot.greendao.DaoException;
import com.gingersoft.gsa.cloud.database.greendao.DaoSession;
import com.gingersoft.gsa.cloud.database.greendao.ComboItemDao;
import com.gingersoft.gsa.cloud.database.greendao.FoodDao;
/**
* 作者:ELEGANT_BIN
......@@ -22,14 +28,16 @@ import java.util.Date;
@Entity
public class Food {
@Property(nameInDb = "_id")
@Id(autoincrement = true)
private Long dbid;
/**
* ID
*/
@Property(nameInDb = "_id")
@Id(autoincrement = true)
private Long id;
@ToMany
@JoinEntity(entity = FoodCombo.class, sourceProperty = "fid", targetProperty = "comId")
private List<ComboItem> comboItems;
/**
* 上級ID (如0=最高級)
*/
......@@ -293,7 +301,6 @@ public class Food {
*/
private Long isStatistic;
/**
* 自定義字段
*/
......@@ -317,17 +324,24 @@ public class Food {
/**是否组合食品*/
private boolean isComboFood = false;
/** Used to resolve relations */
@Generated(hash = 2040040024)
private transient DaoSession daoSession;
/** Used for active entity operations. */
@Generated(hash = 1296197325)
private transient FoodDao myDao;
@Generated(hash = 866324199)
public Food() {
}
@Generated(hash = 1165612351)
public Food(Long dbid, Long id, Long parentId, Long restaurantId, Byte isParent,
Long seqNo, String foodName, String foodName1, String foodName2, String plu,
String posFid, String foodDesc, Long limitAmount, Long limitType,
Long foodSummary, Long invisible, Byte autoMod, Double price, Double marketPrice,
@Generated(hash = 1640870418)
public Food(Long id, Long parentId, Long restaurantId, Byte isParent, Long seqNo,
String foodName, String foodName1, String foodName2, String plu, String posFid,
String foodDesc, Long limitAmount, Long limitType, Long foodSummary,
Long invisible, Byte autoMod, Double price, Double marketPrice,
Double lunchboxPrice, String imgUrlSmall, String imageurl, Long riceponInvisible,
Double cost, Date startDate, Date endDate, Long like, Long totalSold, Long isSold,
String createBy, Date createTime, String updateBy, Date updateTime, Long periodId,
......@@ -339,7 +353,6 @@ public class Food {
Byte serviceCharge, Long colorId, Long conditions, Long isRt, Long deletes,
Long isTimingFood, Long minLongTime, Long unitTime, Double unitPrice,
Long freeLongTime, Date freePeriodBegin, Long isStatistic) {
this.dbid = dbid;
this.id = id;
this.parentId = parentId;
this.restaurantId = restaurantId;
......@@ -946,14 +959,6 @@ public class Food {
this.isStatistic = isStatistic;
}
public Long getDbid() {
return this.dbid;
}
public void setDbid(Long dbid) {
this.dbid = dbid;
}
public int getNumber() {
return number;
}
......@@ -1001,4 +1006,82 @@ public class Food {
public void setComboFood(boolean comboFood) {
isComboFood = comboFood;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 929118398)
public List<ComboItem> getComboItems() {
if (comboItems == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
ComboItemDao targetDao = daoSession.getComboItemDao();
List<ComboItem> comboItemsNew = targetDao._queryFood_ComboItems(id);
synchronized (this) {
if (comboItems == null) {
comboItems = comboItemsNew;
}
}
}
return comboItems;
}
/** Resets a to-many relationship, making the next get call to query for a fresh result. */
@Generated(hash = 1344176234)
public synchronized void resetComboItems() {
comboItems = null;
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 128553479)
public void delete() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.delete(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 1942392019)
public void refresh() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.refresh(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 713229351)
public void update() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.update(this);
}
/** called by internal mechanisms, do not call yourself. */
@Generated(hash = 505459956)
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getFoodDao() : null;
}
}
......@@ -3,8 +3,7 @@ package com.gingersoft.gsa.cloud.database.bean;
import android.graphics.Color;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.JoinEntity;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToMany;
import org.greenrobot.greendao.annotation.Transient;
......@@ -12,35 +11,25 @@ import org.greenrobot.greendao.annotation.Generated;
import java.util.List;
import org.greenrobot.greendao.DaoException;
import com.gingersoft.gsa.cloud.database.greendao.DaoSession;
import com.gingersoft.gsa.cloud.database.greendao.FoodDao;
import com.gingersoft.gsa.cloud.database.greendao.ComboDao;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-02-18
* 修订历史:2020-02-18
* 描述:套餐關係
* 描述:食品套餐關係
*/
@Entity
public class Combo {
public class FoodCombo {
@Property(nameInDb = "_id")
@Id(autoincrement = true)
private Long dbid;
@NotNull
private Long id;
private Long fid; //食品ID
private int comId;//套餐ID
//關聯食品表
@ToMany(referencedJoinProperty = "id")
private List<Food> foods;
// @ToMany
// @JoinEntity(entity = ComboItem.class, sourceProperty = "comId", targetProperty = "fid")
// private List<ComboItem> comboItems;
/**
* 自定義字段
*/
......@@ -79,44 +68,20 @@ public class Combo {
@Transient
private Modifier modifier;
/**
* Used to resolve relations
*/
@Generated(hash = 2040040024)
private transient DaoSession daoSession;
/**
* Used for active entity operations.
*/
@Generated(hash = 1678159415)
private transient ComboDao myDao;
@Generated(hash = 1487508076)
public Combo(Long dbid, @NotNull Long id, Long fid, int comId) {
this.dbid = dbid;
@Generated(hash = 34188725)
public FoodCombo(Long id, Long fid, int comId) {
this.id = id;
this.fid = fid;
this.comId = comId;
}
@Generated(hash = 2090634475)
public Combo() {
@Generated(hash = 1913989231)
public FoodCombo() {
}
// @Generated(hash = 196636064)
// public Combo(Long dbid, @NotNull Long id, Long fid, int comId) {
// this.dbid = dbid;
// this.id = id;
// this.fid = fid;
// this.comId = comId;
// }
//
// @Generated(hash = 2090634475)
// public Combo() {
// }
public long getParentId() {
return parentId;
......@@ -126,7 +91,7 @@ public class Combo {
this.parentId = parentId;
}
public long getId() {
public Long getId() {
return id;
}
......@@ -198,14 +163,6 @@ public class Combo {
this.fontColor = fontColor;
}
public Long getDbid() {
return dbid;
}
public void setDbid(Long dbid) {
this.dbid = dbid;
}
public Modifier getModifier() {
return modifier;
}
......@@ -218,87 +175,12 @@ public class Combo {
this.id = id;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 696813942)
public List<Food> getFoods() {
if (foods == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
FoodDao targetDao = daoSession.getFoodDao();
List<Food> foodsNew = targetDao._queryCombo_Foods(dbid);
synchronized (this) {
if (foods == null) {
foods = foodsNew;
}
}
}
return foods;
}
/**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 1950966)
public synchronized void resetFoods() {
foods = null;
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 128553479)
public void delete() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.delete(this);
public static FoodCombo addFoodInfo(Food food, FoodCombo foodCombo) {
foodCombo.setName(food.getFoodName());
foodCombo.setFid(food.getId());
foodCombo.setPrice(food.getPrice());
foodCombo.setAutoMode(food.getAutoMod());
return foodCombo;
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 1942392019)
public void refresh() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.refresh(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 713229351)
public void update() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.update(this);
}
/**
* called by internal mechanisms, do not call yourself.
*/
@Generated(hash = 589205575)
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getComboDao() : null;
}
public static Combo addFoodInfo(Food food, Combo combo) {
combo.setName(food.getFoodName());
combo.setFid(food.getId());
combo.setPrice(food.getPrice());
combo.setAutoMode(food.getAutoMod());
return combo;
}
}
package com.gingersoft.gsa.cloud.database.greendao;
import java.util.List;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import org.greenrobot.greendao.query.Query;
import org.greenrobot.greendao.query.QueryBuilder;
import com.gingersoft.gsa.cloud.database.bean.FoodCombo;
import com.gingersoft.gsa.cloud.database.bean.ComboItem;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "COMBO_ITEM".
*/
public class ComboItemDao extends AbstractDao<ComboItem, Long> {
public static final String TABLENAME = "COMBO_ITEM";
/**
* Properties of entity ComboItem.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property ComId = new Property(1, Long.class, "comId", false, "COM_ID");
public final static Property Fid = new Property(2, Long.class, "fid", false, "FID");
public final static Property Qty = new Property(3, Long.class, "qty", false, "QTY");
public final static Property DiffAmt = new Property(4, Double.class, "diffAmt", false, "DIFF_AMT");
public final static Property SeqNo = new Property(5, Long.class, "seqNo", false, "SEQ_NO");
public final static Property Visible = new Property(6, Long.class, "visible", false, "VISIBLE");
public final static Property CreateTime = new Property(7, java.util.Date.class, "createTime", false, "CREATE_TIME");
public final static Property CreateBy = new Property(8, String.class, "createBy", false, "CREATE_BY");
public final static Property UpdateTime = new Property(9, java.util.Date.class, "updateTime", false, "UPDATE_TIME");
public final static Property Conditions = new Property(10, Long.class, "conditions", false, "CONDITIONS");
public final static Property IsRT = new Property(11, Long.class, "isRT", false, "IS_RT");
public final static Property Deletes = new Property(12, Byte.class, "deletes", false, "DELETES");
public final static Property PosId = new Property(13, Long.class, "posId", false, "POS_ID");
public final static Property Restaurant_id = new Property(14, Long.class, "restaurant_id", false, "RESTAURANT_ID");
public final static Property IsMainAccount = new Property(15, Byte.class, "isMainAccount", false, "IS_MAIN_ACCOUNT");
}
private Query<ComboItem> food_ComboItemsQuery;
public ComboItemDao(DaoConfig config) {
super(config);
}
public ComboItemDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}
/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"COMBO_ITEM\" (" + //
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
"\"COM_ID\" INTEGER," + // 1: comId
"\"FID\" INTEGER," + // 2: fid
"\"QTY\" INTEGER," + // 3: qty
"\"DIFF_AMT\" REAL," + // 4: diffAmt
"\"SEQ_NO\" INTEGER," + // 5: seqNo
"\"VISIBLE\" INTEGER," + // 6: visible
"\"CREATE_TIME\" INTEGER," + // 7: createTime
"\"CREATE_BY\" TEXT," + // 8: createBy
"\"UPDATE_TIME\" INTEGER," + // 9: updateTime
"\"CONDITIONS\" INTEGER," + // 10: conditions
"\"IS_RT\" INTEGER," + // 11: isRT
"\"DELETES\" INTEGER," + // 12: deletes
"\"POS_ID\" INTEGER," + // 13: posId
"\"RESTAURANT_ID\" INTEGER," + // 14: restaurant_id
"\"IS_MAIN_ACCOUNT\" INTEGER);"); // 15: isMainAccount
}
/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"COMBO_ITEM\"";
db.execSQL(sql);
}
@Override
protected final void bindValues(DatabaseStatement stmt, ComboItem entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
Long comId = entity.getComId();
if (comId != null) {
stmt.bindLong(2, comId);
}
Long fid = entity.getFid();
if (fid != null) {
stmt.bindLong(3, fid);
}
Long qty = entity.getQty();
if (qty != null) {
stmt.bindLong(4, qty);
}
Double diffAmt = entity.getDiffAmt();
if (diffAmt != null) {
stmt.bindDouble(5, diffAmt);
}
Long seqNo = entity.getSeqNo();
if (seqNo != null) {
stmt.bindLong(6, seqNo);
}
Long visible = entity.getVisible();
if (visible != null) {
stmt.bindLong(7, visible);
}
java.util.Date createTime = entity.getCreateTime();
if (createTime != null) {
stmt.bindLong(8, createTime.getTime());
}
String createBy = entity.getCreateBy();
if (createBy != null) {
stmt.bindString(9, createBy);
}
java.util.Date updateTime = entity.getUpdateTime();
if (updateTime != null) {
stmt.bindLong(10, updateTime.getTime());
}
Long conditions = entity.getConditions();
if (conditions != null) {
stmt.bindLong(11, conditions);
}
Long isRT = entity.getIsRT();
if (isRT != null) {
stmt.bindLong(12, isRT);
}
Byte deletes = entity.getDeletes();
if (deletes != null) {
stmt.bindLong(13, deletes);
}
Long posId = entity.getPosId();
if (posId != null) {
stmt.bindLong(14, posId);
}
Long restaurant_id = entity.getRestaurant_id();
if (restaurant_id != null) {
stmt.bindLong(15, restaurant_id);
}
Byte isMainAccount = entity.getIsMainAccount();
if (isMainAccount != null) {
stmt.bindLong(16, isMainAccount);
}
}
@Override
protected final void bindValues(SQLiteStatement stmt, ComboItem entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
Long comId = entity.getComId();
if (comId != null) {
stmt.bindLong(2, comId);
}
Long fid = entity.getFid();
if (fid != null) {
stmt.bindLong(3, fid);
}
Long qty = entity.getQty();
if (qty != null) {
stmt.bindLong(4, qty);
}
Double diffAmt = entity.getDiffAmt();
if (diffAmt != null) {
stmt.bindDouble(5, diffAmt);
}
Long seqNo = entity.getSeqNo();
if (seqNo != null) {
stmt.bindLong(6, seqNo);
}
Long visible = entity.getVisible();
if (visible != null) {
stmt.bindLong(7, visible);
}
java.util.Date createTime = entity.getCreateTime();
if (createTime != null) {
stmt.bindLong(8, createTime.getTime());
}
String createBy = entity.getCreateBy();
if (createBy != null) {
stmt.bindString(9, createBy);
}
java.util.Date updateTime = entity.getUpdateTime();
if (updateTime != null) {
stmt.bindLong(10, updateTime.getTime());
}
Long conditions = entity.getConditions();
if (conditions != null) {
stmt.bindLong(11, conditions);
}
Long isRT = entity.getIsRT();
if (isRT != null) {
stmt.bindLong(12, isRT);
}
Byte deletes = entity.getDeletes();
if (deletes != null) {
stmt.bindLong(13, deletes);
}
Long posId = entity.getPosId();
if (posId != null) {
stmt.bindLong(14, posId);
}
Long restaurant_id = entity.getRestaurant_id();
if (restaurant_id != null) {
stmt.bindLong(15, restaurant_id);
}
Byte isMainAccount = entity.getIsMainAccount();
if (isMainAccount != null) {
stmt.bindLong(16, isMainAccount);
}
}
@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
@Override
public ComboItem readEntity(Cursor cursor, int offset) {
ComboItem entity = new ComboItem( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // comId
cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2), // fid
cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3), // qty
cursor.isNull(offset + 4) ? null : cursor.getDouble(offset + 4), // diffAmt
cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5), // seqNo
cursor.isNull(offset + 6) ? null : cursor.getLong(offset + 6), // visible
cursor.isNull(offset + 7) ? null : new java.util.Date(cursor.getLong(offset + 7)), // createTime
cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // createBy
cursor.isNull(offset + 9) ? null : new java.util.Date(cursor.getLong(offset + 9)), // updateTime
cursor.isNull(offset + 10) ? null : cursor.getLong(offset + 10), // conditions
cursor.isNull(offset + 11) ? null : cursor.getLong(offset + 11), // isRT
cursor.isNull(offset + 12) ? null : (byte) cursor.getShort(offset + 12), // deletes
cursor.isNull(offset + 13) ? null : cursor.getLong(offset + 13), // posId
cursor.isNull(offset + 14) ? null : cursor.getLong(offset + 14), // restaurant_id
cursor.isNull(offset + 15) ? null : (byte) cursor.getShort(offset + 15) // isMainAccount
);
return entity;
}
@Override
public void readEntity(Cursor cursor, ComboItem entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setComId(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
entity.setFid(cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2));
entity.setQty(cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3));
entity.setDiffAmt(cursor.isNull(offset + 4) ? null : cursor.getDouble(offset + 4));
entity.setSeqNo(cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5));
entity.setVisible(cursor.isNull(offset + 6) ? null : cursor.getLong(offset + 6));
entity.setCreateTime(cursor.isNull(offset + 7) ? null : new java.util.Date(cursor.getLong(offset + 7)));
entity.setCreateBy(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
entity.setUpdateTime(cursor.isNull(offset + 9) ? null : new java.util.Date(cursor.getLong(offset + 9)));
entity.setConditions(cursor.isNull(offset + 10) ? null : cursor.getLong(offset + 10));
entity.setIsRT(cursor.isNull(offset + 11) ? null : cursor.getLong(offset + 11));
entity.setDeletes(cursor.isNull(offset + 12) ? null : (byte) cursor.getShort(offset + 12));
entity.setPosId(cursor.isNull(offset + 13) ? null : cursor.getLong(offset + 13));
entity.setRestaurant_id(cursor.isNull(offset + 14) ? null : cursor.getLong(offset + 14));
entity.setIsMainAccount(cursor.isNull(offset + 15) ? null : (byte) cursor.getShort(offset + 15));
}
@Override
protected final Long updateKeyAfterInsert(ComboItem entity, long rowId) {
entity.setId(rowId);
return rowId;
}
@Override
public Long getKey(ComboItem entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}
@Override
public boolean hasKey(ComboItem entity) {
return entity.getId() != null;
}
@Override
protected final boolean isEntityUpdateable() {
return true;
}
/** Internal query to resolve the "comboItems" to-many relationship of Food. */
public List<ComboItem> _queryFood_ComboItems(Long fid) {
synchronized (this) {
if (food_ComboItemsQuery == null) {
QueryBuilder<ComboItem> queryBuilder = queryBuilder();
queryBuilder.join(FoodCombo.class, FoodComboDao.Properties.ComId)
.where(FoodComboDao.Properties.Fid.eq(fid));
food_ComboItemsQuery = queryBuilder.build();
}
}
Query<ComboItem> query = food_ComboItemsQuery.forCurrentThread();
query.setParameter(0, fid);
return query.list();
}
}
......@@ -14,29 +14,31 @@ import org.greenrobot.greendao.identityscope.IdentityScopeType;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 13): knows all DAOs.
* Master of DAO (schema version 8): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 13;
public static final int SCHEMA_VERSION = 8;
/** Creates underlying database table using DAOs. */
public static void createAllTables(Database db, boolean ifNotExists) {
ComboDao.createTable(db, ifNotExists);
FoodDao.createTable(db, ifNotExists);
FoodModifierDao.createTable(db, ifNotExists);
FunctionDao.createTable(db, ifNotExists);
ModifierDao.createTable(db, ifNotExists);
PrinterDeviceBeanDao.createTable(db, ifNotExists);
ComboItemDao.createTable(db, ifNotExists);
FoodComboDao.createTable(db, ifNotExists);
}
/** Drops underlying database table using DAOs. */
public static void dropAllTables(Database db, boolean ifExists) {
ComboDao.dropTable(db, ifExists);
FoodDao.dropTable(db, ifExists);
FoodModifierDao.dropTable(db, ifExists);
FunctionDao.dropTable(db, ifExists);
ModifierDao.dropTable(db, ifExists);
PrinterDeviceBeanDao.dropTable(db, ifExists);
ComboItemDao.dropTable(db, ifExists);
FoodComboDao.dropTable(db, ifExists);
}
/**
......@@ -55,12 +57,13 @@ public class DaoMaster extends AbstractDaoMaster {
public DaoMaster(Database db) {
super(db, SCHEMA_VERSION);
registerDaoClass(ComboDao.class);
registerDaoClass(FoodDao.class);
registerDaoClass(FoodModifierDao.class);
registerDaoClass(FunctionDao.class);
registerDaoClass(ModifierDao.class);
registerDaoClass(PrinterDeviceBeanDao.class);
registerDaoClass(ComboItemDao.class);
registerDaoClass(FoodComboDao.class);
}
public DaoSession newSession() {
......
......@@ -8,19 +8,21 @@ import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.identityscope.IdentityScopeType;
import org.greenrobot.greendao.internal.DaoConfig;
import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.FoodModifier;
import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.database.bean.Modifier;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.database.bean.ComboItem;
import com.gingersoft.gsa.cloud.database.bean.FoodCombo;
import com.gingersoft.gsa.cloud.database.greendao.ComboDao;
import com.gingersoft.gsa.cloud.database.greendao.FoodDao;
import com.gingersoft.gsa.cloud.database.greendao.FoodModifierDao;
import com.gingersoft.gsa.cloud.database.greendao.FunctionDao;
import com.gingersoft.gsa.cloud.database.greendao.ModifierDao;
import com.gingersoft.gsa.cloud.database.greendao.PrinterDeviceBeanDao;
import com.gingersoft.gsa.cloud.database.greendao.ComboItemDao;
import com.gingersoft.gsa.cloud.database.greendao.FoodComboDao;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
......@@ -31,27 +33,26 @@ import com.gingersoft.gsa.cloud.database.greendao.PrinterDeviceBeanDao;
*/
public class DaoSession extends AbstractDaoSession {
private final DaoConfig comboDaoConfig;
private final DaoConfig foodDaoConfig;
private final DaoConfig foodModifierDaoConfig;
private final DaoConfig functionDaoConfig;
private final DaoConfig modifierDaoConfig;
private final DaoConfig printerDeviceBeanDaoConfig;
private final DaoConfig comboItemDaoConfig;
private final DaoConfig foodComboDaoConfig;
private final ComboDao comboDao;
private final FoodDao foodDao;
private final FoodModifierDao foodModifierDao;
private final FunctionDao functionDao;
private final ModifierDao modifierDao;
private final PrinterDeviceBeanDao printerDeviceBeanDao;
private final ComboItemDao comboItemDao;
private final FoodComboDao foodComboDao;
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
daoConfigMap) {
super(db);
comboDaoConfig = daoConfigMap.get(ComboDao.class).clone();
comboDaoConfig.initIdentityScope(type);
foodDaoConfig = daoConfigMap.get(FoodDao.class).clone();
foodDaoConfig.initIdentityScope(type);
......@@ -67,32 +68,37 @@ public class DaoSession extends AbstractDaoSession {
printerDeviceBeanDaoConfig = daoConfigMap.get(PrinterDeviceBeanDao.class).clone();
printerDeviceBeanDaoConfig.initIdentityScope(type);
comboDao = new ComboDao(comboDaoConfig, this);
comboItemDaoConfig = daoConfigMap.get(ComboItemDao.class).clone();
comboItemDaoConfig.initIdentityScope(type);
foodComboDaoConfig = daoConfigMap.get(FoodComboDao.class).clone();
foodComboDaoConfig.initIdentityScope(type);
foodDao = new FoodDao(foodDaoConfig, this);
foodModifierDao = new FoodModifierDao(foodModifierDaoConfig, this);
functionDao = new FunctionDao(functionDaoConfig, this);
modifierDao = new ModifierDao(modifierDaoConfig, this);
printerDeviceBeanDao = new PrinterDeviceBeanDao(printerDeviceBeanDaoConfig, this);
comboItemDao = new ComboItemDao(comboItemDaoConfig, this);
foodComboDao = new FoodComboDao(foodComboDaoConfig, this);
registerDao(Combo.class, comboDao);
registerDao(Food.class, foodDao);
registerDao(FoodModifier.class, foodModifierDao);
registerDao(Function.class, functionDao);
registerDao(Modifier.class, modifierDao);
registerDao(PrinterDeviceBean.class, printerDeviceBeanDao);
registerDao(ComboItem.class, comboItemDao);
registerDao(FoodCombo.class, foodComboDao);
}
public void clear() {
comboDaoConfig.clearIdentityScope();
foodDaoConfig.clearIdentityScope();
foodModifierDaoConfig.clearIdentityScope();
functionDaoConfig.clearIdentityScope();
modifierDaoConfig.clearIdentityScope();
printerDeviceBeanDaoConfig.clearIdentityScope();
}
public ComboDao getComboDao() {
return comboDao;
comboItemDaoConfig.clearIdentityScope();
foodComboDaoConfig.clearIdentityScope();
}
public FoodDao getFoodDao() {
......@@ -115,4 +121,12 @@ public class DaoSession extends AbstractDaoSession {
return printerDeviceBeanDao;
}
public ComboItemDao getComboItemDao() {
return comboItemDao;
}
public FoodComboDao getFoodComboDao() {
return foodComboDao;
}
}
......@@ -9,137 +9,119 @@ import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.FoodCombo;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "COMBO".
* DAO for table "FOOD_COMBO".
*/
public class ComboDao extends AbstractDao<Combo, Long> {
public class FoodComboDao extends AbstractDao<FoodCombo, Void> {
public static final String TABLENAME = "COMBO";
public static final String TABLENAME = "FOOD_COMBO";
/**
* Properties of entity Combo.<br/>
* Properties of entity FoodCombo.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Dbid = new Property(0, Long.class, "dbid", true, "_id");
public final static Property Id = new Property(1, Long.class, "id", false, "ID");
public final static Property Fid = new Property(2, Long.class, "fid", false, "FID");
public final static Property ComId = new Property(3, int.class, "comId", false, "COM_ID");
public final static Property Id = new Property(0, Long.class, "id", false, "_id");
public final static Property Fid = new Property(1, Long.class, "fid", false, "FID");
public final static Property ComId = new Property(2, int.class, "comId", false, "COM_ID");
}
private DaoSession daoSession;
public ComboDao(DaoConfig config) {
public FoodComboDao(DaoConfig config) {
super(config);
}
public ComboDao(DaoConfig config, DaoSession daoSession) {
public FoodComboDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
this.daoSession = daoSession;
}
/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"COMBO\" (" + //
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: dbid
"\"ID\" INTEGER NOT NULL ," + // 1: id
"\"FID\" INTEGER," + // 2: fid
"\"COM_ID\" INTEGER NOT NULL );"); // 3: comId
db.execSQL("CREATE TABLE " + constraint + "\"FOOD_COMBO\" (" + //
"\"_id\" INTEGER," + // 0: id
"\"FID\" INTEGER," + // 1: fid
"\"COM_ID\" INTEGER NOT NULL );"); // 2: comId
}
/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"COMBO\"";
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"FOOD_COMBO\"";
db.execSQL(sql);
}
@Override
protected final void bindValues(DatabaseStatement stmt, Combo entity) {
protected final void bindValues(DatabaseStatement stmt, FoodCombo entity) {
stmt.clearBindings();
Long dbid = entity.getDbid();
if (dbid != null) {
stmt.bindLong(1, dbid);
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindLong(2, entity.getId());
Long fid = entity.getFid();
if (fid != null) {
stmt.bindLong(3, fid);
stmt.bindLong(2, fid);
}
stmt.bindLong(4, entity.getComId());
stmt.bindLong(3, entity.getComId());
}
@Override
protected final void bindValues(SQLiteStatement stmt, Combo entity) {
protected final void bindValues(SQLiteStatement stmt, FoodCombo entity) {
stmt.clearBindings();
Long dbid = entity.getDbid();
if (dbid != null) {
stmt.bindLong(1, dbid);
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindLong(2, entity.getId());
Long fid = entity.getFid();
if (fid != null) {
stmt.bindLong(3, fid);
}
stmt.bindLong(4, entity.getComId());
stmt.bindLong(2, fid);
}
@Override
protected final void attachEntity(Combo entity) {
super.attachEntity(entity);
entity.__setDaoSession(daoSession);
stmt.bindLong(3, entity.getComId());
}
@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
public Void readKey(Cursor cursor, int offset) {
return null;
}
@Override
public Combo readEntity(Cursor cursor, int offset) {
Combo entity = new Combo( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // dbid
cursor.getLong(offset + 1), // id
cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2), // fid
cursor.getInt(offset + 3) // comId
public FoodCombo readEntity(Cursor cursor, int offset) {
FoodCombo entity = new FoodCombo( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // fid
cursor.getInt(offset + 2) // comId
);
return entity;
}
@Override
public void readEntity(Cursor cursor, Combo entity, int offset) {
entity.setDbid(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setId(cursor.getLong(offset + 1));
entity.setFid(cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2));
entity.setComId(cursor.getInt(offset + 3));
public void readEntity(Cursor cursor, FoodCombo entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setFid(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
entity.setComId(cursor.getInt(offset + 2));
}
@Override
protected final Long updateKeyAfterInsert(Combo entity, long rowId) {
entity.setDbid(rowId);
return rowId;
protected final Void updateKeyAfterInsert(FoodCombo entity, long rowId) {
// Unsupported or missing PK type
return null;
}
@Override
public Long getKey(Combo entity) {
if(entity != null) {
return entity.getDbid();
} else {
public Void getKey(FoodCombo entity) {
return null;
}
}
@Override
public boolean hasKey(Combo entity) {
return entity.getDbid() != null;
public boolean hasKey(FoodCombo entity) {
// TODO
return false;
}
@Override
......
package com.gingersoft.gsa.cloud.database.greendao;
import java.util.List;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;
......@@ -9,8 +8,6 @@ import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import org.greenrobot.greendao.query.Query;
import org.greenrobot.greendao.query.QueryBuilder;
import com.gingersoft.gsa.cloud.database.bean.Food;
......@@ -27,77 +24,77 @@ public class FoodDao extends AbstractDao<Food, Long> {
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Dbid = new Property(0, Long.class, "dbid", true, "_id");
public final static Property Id = new Property(1, Long.class, "id", false, "ID");
public final static Property ParentId = new Property(2, Long.class, "parentId", false, "PARENT_ID");
public final static Property RestaurantId = new Property(3, Long.class, "restaurantId", false, "RESTAURANT_ID");
public final static Property IsParent = new Property(4, Byte.class, "isParent", false, "IS_PARENT");
public final static Property SeqNo = new Property(5, Long.class, "seqNo", false, "SEQ_NO");
public final static Property FoodName = new Property(6, String.class, "foodName", false, "FOOD_NAME");
public final static Property FoodName1 = new Property(7, String.class, "foodName1", false, "FOOD_NAME1");
public final static Property FoodName2 = new Property(8, String.class, "foodName2", false, "FOOD_NAME2");
public final static Property Plu = new Property(9, String.class, "plu", false, "PLU");
public final static Property PosFid = new Property(10, String.class, "posFid", false, "POS_FID");
public final static Property FoodDesc = new Property(11, String.class, "foodDesc", false, "FOOD_DESC");
public final static Property LimitAmount = new Property(12, Long.class, "limitAmount", false, "LIMIT_AMOUNT");
public final static Property LimitType = new Property(13, Long.class, "limitType", false, "LIMIT_TYPE");
public final static Property FoodSummary = new Property(14, Long.class, "foodSummary", false, "FOOD_SUMMARY");
public final static Property Invisible = new Property(15, Long.class, "invisible", false, "INVISIBLE");
public final static Property AutoMod = new Property(16, Byte.class, "autoMod", false, "AUTO_MOD");
public final static Property Price = new Property(17, Double.class, "price", false, "PRICE");
public final static Property MarketPrice = new Property(18, Double.class, "marketPrice", false, "MARKET_PRICE");
public final static Property LunchboxPrice = new Property(19, Double.class, "lunchboxPrice", false, "LUNCHBOX_PRICE");
public final static Property ImgUrlSmall = new Property(20, String.class, "imgUrlSmall", false, "IMG_URL_SMALL");
public final static Property Imageurl = new Property(21, String.class, "imageurl", false, "IMAGEURL");
public final static Property RiceponInvisible = new Property(22, Long.class, "riceponInvisible", false, "RICEPON_INVISIBLE");
public final static Property Cost = new Property(23, Double.class, "cost", false, "COST");
public final static Property StartDate = new Property(24, java.util.Date.class, "startDate", false, "START_DATE");
public final static Property EndDate = new Property(25, java.util.Date.class, "endDate", false, "END_DATE");
public final static Property Like = new Property(26, Long.class, "like", false, "LIKE");
public final static Property TotalSold = new Property(27, Long.class, "totalSold", false, "TOTAL_SOLD");
public final static Property IsSold = new Property(28, Long.class, "isSold", false, "IS_SOLD");
public final static Property CreateBy = new Property(29, String.class, "createBy", false, "CREATE_BY");
public final static Property CreateTime = new Property(30, java.util.Date.class, "createTime", false, "CREATE_TIME");
public final static Property UpdateBy = new Property(31, String.class, "updateBy", false, "UPDATE_BY");
public final static Property UpdateTime = new Property(32, java.util.Date.class, "updateTime", false, "UPDATE_TIME");
public final static Property PeriodId = new Property(33, Long.class, "periodId", false, "PERIOD_ID");
public final static Property AbleDiscount = new Property(34, Long.class, "ableDiscount", false, "ABLE_DISCOUNT");
public final static Property Takeaway = new Property(35, Long.class, "takeaway", false, "TAKEAWAY");
public final static Property BlueEdit = new Property(36, Long.class, "blueEdit", false, "BLUE_EDIT");
public final static Property CartEdit = new Property(37, Long.class, "cartEdit", false, "CART_EDIT");
public final static Property AutoMerge = new Property(38, Long.class, "autoMerge", false, "AUTO_MERGE");
public final static Property PrintSeting = new Property(39, String.class, "printSeting", false, "PRINT_SETING");
public final static Property IsPrintQueueCode = new Property(40, Long.class, "isPrintQueueCode", false, "IS_PRINT_QUEUE_CODE");
public final static Property QueueHeadId = new Property(41, Long.class, "queueHeadId", false, "QUEUE_HEAD_ID");
public final static Property Approve = new Property(42, Long.class, "approve", false, "APPROVE");
public final static Property PrintFont = new Property(43, Long.class, "printFont", false, "PRINT_FONT");
public final static Property AdvPrice = new Property(44, Long.class, "advPrice", false, "ADV_PRICE");
public final static Property PrintToBill = new Property(45, Long.class, "printToBill", false, "PRINT_TO_BILL");
public final static Property PointsAdd = new Property(46, Double.class, "pointsAdd", false, "POINTS_ADD");
public final static Property PointsRatio = new Property(47, Long.class, "pointsRatio", false, "POINTS_RATIO");
public final static Property PointsRedeem = new Property(48, Double.class, "pointsRedeem", false, "POINTS_REDEEM");
public final static Property KtPrintMainItem = new Property(49, Long.class, "ktPrintMainItem", false, "KT_PRINT_MAIN_ITEM");
public final static Property KtShowPrice = new Property(50, Long.class, "ktShowPrice", false, "KT_SHOW_PRICE");
public final static Property PrintTo = new Property(51, Long.class, "printTo", false, "PRINT_TO");
public final static Property ToPax = new Property(52, Long.class, "toPax", false, "TO_PAX");
public final static Property FoodType = new Property(53, Long.class, "foodType", false, "FOOD_TYPE");
public final static Property MajorMainId = new Property(54, Long.class, "majorMainId", false, "MAJOR_MAIN_ID");
public final static Property DeptId = new Property(55, Long.class, "deptId", false, "DEPT_ID");
public final static Property ServiceCharge = new Property(56, Byte.class, "serviceCharge", false, "SERVICE_CHARGE");
public final static Property ColorId = new Property(57, Long.class, "colorId", false, "COLOR_ID");
public final static Property Conditions = new Property(58, Long.class, "conditions", false, "CONDITIONS");
public final static Property IsRt = new Property(59, Long.class, "isRt", false, "IS_RT");
public final static Property Deletes = new Property(60, Long.class, "deletes", false, "DELETES");
public final static Property IsTimingFood = new Property(61, Long.class, "isTimingFood", false, "IS_TIMING_FOOD");
public final static Property MinLongTime = new Property(62, Long.class, "minLongTime", false, "MIN_LONG_TIME");
public final static Property UnitTime = new Property(63, Long.class, "unitTime", false, "UNIT_TIME");
public final static Property UnitPrice = new Property(64, Double.class, "unitPrice", false, "UNIT_PRICE");
public final static Property FreeLongTime = new Property(65, Long.class, "freeLongTime", false, "FREE_LONG_TIME");
public final static Property FreePeriodBegin = new Property(66, java.util.Date.class, "freePeriodBegin", false, "FREE_PERIOD_BEGIN");
public final static Property IsStatistic = new Property(67, Long.class, "isStatistic", false, "IS_STATISTIC");
}
private Query<Food> combo_FoodsQuery;
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property ParentId = new Property(1, Long.class, "parentId", false, "PARENT_ID");
public final static Property RestaurantId = new Property(2, Long.class, "restaurantId", false, "RESTAURANT_ID");
public final static Property IsParent = new Property(3, Byte.class, "isParent", false, "IS_PARENT");
public final static Property SeqNo = new Property(4, Long.class, "seqNo", false, "SEQ_NO");
public final static Property FoodName = new Property(5, String.class, "foodName", false, "FOOD_NAME");
public final static Property FoodName1 = new Property(6, String.class, "foodName1", false, "FOOD_NAME1");
public final static Property FoodName2 = new Property(7, String.class, "foodName2", false, "FOOD_NAME2");
public final static Property Plu = new Property(8, String.class, "plu", false, "PLU");
public final static Property PosFid = new Property(9, String.class, "posFid", false, "POS_FID");
public final static Property FoodDesc = new Property(10, String.class, "foodDesc", false, "FOOD_DESC");
public final static Property LimitAmount = new Property(11, Long.class, "limitAmount", false, "LIMIT_AMOUNT");
public final static Property LimitType = new Property(12, Long.class, "limitType", false, "LIMIT_TYPE");
public final static Property FoodSummary = new Property(13, Long.class, "foodSummary", false, "FOOD_SUMMARY");
public final static Property Invisible = new Property(14, Long.class, "invisible", false, "INVISIBLE");
public final static Property AutoMod = new Property(15, Byte.class, "autoMod", false, "AUTO_MOD");
public final static Property Price = new Property(16, Double.class, "price", false, "PRICE");
public final static Property MarketPrice = new Property(17, Double.class, "marketPrice", false, "MARKET_PRICE");
public final static Property LunchboxPrice = new Property(18, Double.class, "lunchboxPrice", false, "LUNCHBOX_PRICE");
public final static Property ImgUrlSmall = new Property(19, String.class, "imgUrlSmall", false, "IMG_URL_SMALL");
public final static Property Imageurl = new Property(20, String.class, "imageurl", false, "IMAGEURL");
public final static Property RiceponInvisible = new Property(21, Long.class, "riceponInvisible", false, "RICEPON_INVISIBLE");
public final static Property Cost = new Property(22, Double.class, "cost", false, "COST");
public final static Property StartDate = new Property(23, java.util.Date.class, "startDate", false, "START_DATE");
public final static Property EndDate = new Property(24, java.util.Date.class, "endDate", false, "END_DATE");
public final static Property Like = new Property(25, Long.class, "like", false, "LIKE");
public final static Property TotalSold = new Property(26, Long.class, "totalSold", false, "TOTAL_SOLD");
public final static Property IsSold = new Property(27, Long.class, "isSold", false, "IS_SOLD");
public final static Property CreateBy = new Property(28, String.class, "createBy", false, "CREATE_BY");
public final static Property CreateTime = new Property(29, java.util.Date.class, "createTime", false, "CREATE_TIME");
public final static Property UpdateBy = new Property(30, String.class, "updateBy", false, "UPDATE_BY");
public final static Property UpdateTime = new Property(31, java.util.Date.class, "updateTime", false, "UPDATE_TIME");
public final static Property PeriodId = new Property(32, Long.class, "periodId", false, "PERIOD_ID");
public final static Property AbleDiscount = new Property(33, Long.class, "ableDiscount", false, "ABLE_DISCOUNT");
public final static Property Takeaway = new Property(34, Long.class, "takeaway", false, "TAKEAWAY");
public final static Property BlueEdit = new Property(35, Long.class, "blueEdit", false, "BLUE_EDIT");
public final static Property CartEdit = new Property(36, Long.class, "cartEdit", false, "CART_EDIT");
public final static Property AutoMerge = new Property(37, Long.class, "autoMerge", false, "AUTO_MERGE");
public final static Property PrintSeting = new Property(38, String.class, "printSeting", false, "PRINT_SETING");
public final static Property IsPrintQueueCode = new Property(39, Long.class, "isPrintQueueCode", false, "IS_PRINT_QUEUE_CODE");
public final static Property QueueHeadId = new Property(40, Long.class, "queueHeadId", false, "QUEUE_HEAD_ID");
public final static Property Approve = new Property(41, Long.class, "approve", false, "APPROVE");
public final static Property PrintFont = new Property(42, Long.class, "printFont", false, "PRINT_FONT");
public final static Property AdvPrice = new Property(43, Long.class, "advPrice", false, "ADV_PRICE");
public final static Property PrintToBill = new Property(44, Long.class, "printToBill", false, "PRINT_TO_BILL");
public final static Property PointsAdd = new Property(45, Double.class, "pointsAdd", false, "POINTS_ADD");
public final static Property PointsRatio = new Property(46, Long.class, "pointsRatio", false, "POINTS_RATIO");
public final static Property PointsRedeem = new Property(47, Double.class, "pointsRedeem", false, "POINTS_REDEEM");
public final static Property KtPrintMainItem = new Property(48, Long.class, "ktPrintMainItem", false, "KT_PRINT_MAIN_ITEM");
public final static Property KtShowPrice = new Property(49, Long.class, "ktShowPrice", false, "KT_SHOW_PRICE");
public final static Property PrintTo = new Property(50, Long.class, "printTo", false, "PRINT_TO");
public final static Property ToPax = new Property(51, Long.class, "toPax", false, "TO_PAX");
public final static Property FoodType = new Property(52, Long.class, "foodType", false, "FOOD_TYPE");
public final static Property MajorMainId = new Property(53, Long.class, "majorMainId", false, "MAJOR_MAIN_ID");
public final static Property DeptId = new Property(54, Long.class, "deptId", false, "DEPT_ID");
public final static Property ServiceCharge = new Property(55, Byte.class, "serviceCharge", false, "SERVICE_CHARGE");
public final static Property ColorId = new Property(56, Long.class, "colorId", false, "COLOR_ID");
public final static Property Conditions = new Property(57, Long.class, "conditions", false, "CONDITIONS");
public final static Property IsRt = new Property(58, Long.class, "isRt", false, "IS_RT");
public final static Property Deletes = new Property(59, Long.class, "deletes", false, "DELETES");
public final static Property IsTimingFood = new Property(60, Long.class, "isTimingFood", false, "IS_TIMING_FOOD");
public final static Property MinLongTime = new Property(61, Long.class, "minLongTime", false, "MIN_LONG_TIME");
public final static Property UnitTime = new Property(62, Long.class, "unitTime", false, "UNIT_TIME");
public final static Property UnitPrice = new Property(63, Double.class, "unitPrice", false, "UNIT_PRICE");
public final static Property FreeLongTime = new Property(64, Long.class, "freeLongTime", false, "FREE_LONG_TIME");
public final static Property FreePeriodBegin = new Property(65, java.util.Date.class, "freePeriodBegin", false, "FREE_PERIOD_BEGIN");
public final static Property IsStatistic = new Property(66, Long.class, "isStatistic", false, "IS_STATISTIC");
}
private DaoSession daoSession;
public FoodDao(DaoConfig config) {
super(config);
......@@ -105,80 +102,80 @@ public class FoodDao extends AbstractDao<Food, Long> {
public FoodDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
this.daoSession = daoSession;
}
/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"FOOD\" (" + //
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: dbid
"\"ID\" INTEGER," + // 1: id
"\"PARENT_ID\" INTEGER," + // 2: parentId
"\"RESTAURANT_ID\" INTEGER," + // 3: restaurantId
"\"IS_PARENT\" INTEGER," + // 4: isParent
"\"SEQ_NO\" INTEGER," + // 5: seqNo
"\"FOOD_NAME\" TEXT," + // 6: foodName
"\"FOOD_NAME1\" TEXT," + // 7: foodName1
"\"FOOD_NAME2\" TEXT," + // 8: foodName2
"\"PLU\" TEXT," + // 9: plu
"\"POS_FID\" TEXT," + // 10: posFid
"\"FOOD_DESC\" TEXT," + // 11: foodDesc
"\"LIMIT_AMOUNT\" INTEGER," + // 12: limitAmount
"\"LIMIT_TYPE\" INTEGER," + // 13: limitType
"\"FOOD_SUMMARY\" INTEGER," + // 14: foodSummary
"\"INVISIBLE\" INTEGER," + // 15: invisible
"\"AUTO_MOD\" INTEGER," + // 16: autoMod
"\"PRICE\" REAL," + // 17: price
"\"MARKET_PRICE\" REAL," + // 18: marketPrice
"\"LUNCHBOX_PRICE\" REAL," + // 19: lunchboxPrice
"\"IMG_URL_SMALL\" TEXT," + // 20: imgUrlSmall
"\"IMAGEURL\" TEXT," + // 21: imageurl
"\"RICEPON_INVISIBLE\" INTEGER," + // 22: riceponInvisible
"\"COST\" REAL," + // 23: cost
"\"START_DATE\" INTEGER," + // 24: startDate
"\"END_DATE\" INTEGER," + // 25: endDate
"\"LIKE\" INTEGER," + // 26: like
"\"TOTAL_SOLD\" INTEGER," + // 27: totalSold
"\"IS_SOLD\" INTEGER," + // 28: isSold
"\"CREATE_BY\" TEXT," + // 29: createBy
"\"CREATE_TIME\" INTEGER," + // 30: createTime
"\"UPDATE_BY\" TEXT," + // 31: updateBy
"\"UPDATE_TIME\" INTEGER," + // 32: updateTime
"\"PERIOD_ID\" INTEGER," + // 33: periodId
"\"ABLE_DISCOUNT\" INTEGER," + // 34: ableDiscount
"\"TAKEAWAY\" INTEGER," + // 35: takeaway
"\"BLUE_EDIT\" INTEGER," + // 36: blueEdit
"\"CART_EDIT\" INTEGER," + // 37: cartEdit
"\"AUTO_MERGE\" INTEGER," + // 38: autoMerge
"\"PRINT_SETING\" TEXT," + // 39: printSeting
"\"IS_PRINT_QUEUE_CODE\" INTEGER," + // 40: isPrintQueueCode
"\"QUEUE_HEAD_ID\" INTEGER," + // 41: queueHeadId
"\"APPROVE\" INTEGER," + // 42: approve
"\"PRINT_FONT\" INTEGER," + // 43: printFont
"\"ADV_PRICE\" INTEGER," + // 44: advPrice
"\"PRINT_TO_BILL\" INTEGER," + // 45: printToBill
"\"POINTS_ADD\" REAL," + // 46: pointsAdd
"\"POINTS_RATIO\" INTEGER," + // 47: pointsRatio
"\"POINTS_REDEEM\" REAL," + // 48: pointsRedeem
"\"KT_PRINT_MAIN_ITEM\" INTEGER," + // 49: ktPrintMainItem
"\"KT_SHOW_PRICE\" INTEGER," + // 50: ktShowPrice
"\"PRINT_TO\" INTEGER," + // 51: printTo
"\"TO_PAX\" INTEGER," + // 52: toPax
"\"FOOD_TYPE\" INTEGER," + // 53: foodType
"\"MAJOR_MAIN_ID\" INTEGER," + // 54: majorMainId
"\"DEPT_ID\" INTEGER," + // 55: deptId
"\"SERVICE_CHARGE\" INTEGER," + // 56: serviceCharge
"\"COLOR_ID\" INTEGER," + // 57: colorId
"\"CONDITIONS\" INTEGER," + // 58: conditions
"\"IS_RT\" INTEGER," + // 59: isRt
"\"DELETES\" INTEGER," + // 60: deletes
"\"IS_TIMING_FOOD\" INTEGER," + // 61: isTimingFood
"\"MIN_LONG_TIME\" INTEGER," + // 62: minLongTime
"\"UNIT_TIME\" INTEGER," + // 63: unitTime
"\"UNIT_PRICE\" REAL," + // 64: unitPrice
"\"FREE_LONG_TIME\" INTEGER," + // 65: freeLongTime
"\"FREE_PERIOD_BEGIN\" INTEGER," + // 66: freePeriodBegin
"\"IS_STATISTIC\" INTEGER);"); // 67: isStatistic
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
"\"PARENT_ID\" INTEGER," + // 1: parentId
"\"RESTAURANT_ID\" INTEGER," + // 2: restaurantId
"\"IS_PARENT\" INTEGER," + // 3: isParent
"\"SEQ_NO\" INTEGER," + // 4: seqNo
"\"FOOD_NAME\" TEXT," + // 5: foodName
"\"FOOD_NAME1\" TEXT," + // 6: foodName1
"\"FOOD_NAME2\" TEXT," + // 7: foodName2
"\"PLU\" TEXT," + // 8: plu
"\"POS_FID\" TEXT," + // 9: posFid
"\"FOOD_DESC\" TEXT," + // 10: foodDesc
"\"LIMIT_AMOUNT\" INTEGER," + // 11: limitAmount
"\"LIMIT_TYPE\" INTEGER," + // 12: limitType
"\"FOOD_SUMMARY\" INTEGER," + // 13: foodSummary
"\"INVISIBLE\" INTEGER," + // 14: invisible
"\"AUTO_MOD\" INTEGER," + // 15: autoMod
"\"PRICE\" REAL," + // 16: price
"\"MARKET_PRICE\" REAL," + // 17: marketPrice
"\"LUNCHBOX_PRICE\" REAL," + // 18: lunchboxPrice
"\"IMG_URL_SMALL\" TEXT," + // 19: imgUrlSmall
"\"IMAGEURL\" TEXT," + // 20: imageurl
"\"RICEPON_INVISIBLE\" INTEGER," + // 21: riceponInvisible
"\"COST\" REAL," + // 22: cost
"\"START_DATE\" INTEGER," + // 23: startDate
"\"END_DATE\" INTEGER," + // 24: endDate
"\"LIKE\" INTEGER," + // 25: like
"\"TOTAL_SOLD\" INTEGER," + // 26: totalSold
"\"IS_SOLD\" INTEGER," + // 27: isSold
"\"CREATE_BY\" TEXT," + // 28: createBy
"\"CREATE_TIME\" INTEGER," + // 29: createTime
"\"UPDATE_BY\" TEXT," + // 30: updateBy
"\"UPDATE_TIME\" INTEGER," + // 31: updateTime
"\"PERIOD_ID\" INTEGER," + // 32: periodId
"\"ABLE_DISCOUNT\" INTEGER," + // 33: ableDiscount
"\"TAKEAWAY\" INTEGER," + // 34: takeaway
"\"BLUE_EDIT\" INTEGER," + // 35: blueEdit
"\"CART_EDIT\" INTEGER," + // 36: cartEdit
"\"AUTO_MERGE\" INTEGER," + // 37: autoMerge
"\"PRINT_SETING\" TEXT," + // 38: printSeting
"\"IS_PRINT_QUEUE_CODE\" INTEGER," + // 39: isPrintQueueCode
"\"QUEUE_HEAD_ID\" INTEGER," + // 40: queueHeadId
"\"APPROVE\" INTEGER," + // 41: approve
"\"PRINT_FONT\" INTEGER," + // 42: printFont
"\"ADV_PRICE\" INTEGER," + // 43: advPrice
"\"PRINT_TO_BILL\" INTEGER," + // 44: printToBill
"\"POINTS_ADD\" REAL," + // 45: pointsAdd
"\"POINTS_RATIO\" INTEGER," + // 46: pointsRatio
"\"POINTS_REDEEM\" REAL," + // 47: pointsRedeem
"\"KT_PRINT_MAIN_ITEM\" INTEGER," + // 48: ktPrintMainItem
"\"KT_SHOW_PRICE\" INTEGER," + // 49: ktShowPrice
"\"PRINT_TO\" INTEGER," + // 50: printTo
"\"TO_PAX\" INTEGER," + // 51: toPax
"\"FOOD_TYPE\" INTEGER," + // 52: foodType
"\"MAJOR_MAIN_ID\" INTEGER," + // 53: majorMainId
"\"DEPT_ID\" INTEGER," + // 54: deptId
"\"SERVICE_CHARGE\" INTEGER," + // 55: serviceCharge
"\"COLOR_ID\" INTEGER," + // 56: colorId
"\"CONDITIONS\" INTEGER," + // 57: conditions
"\"IS_RT\" INTEGER," + // 58: isRt
"\"DELETES\" INTEGER," + // 59: deletes
"\"IS_TIMING_FOOD\" INTEGER," + // 60: isTimingFood
"\"MIN_LONG_TIME\" INTEGER," + // 61: minLongTime
"\"UNIT_TIME\" INTEGER," + // 62: unitTime
"\"UNIT_PRICE\" REAL," + // 63: unitPrice
"\"FREE_LONG_TIME\" INTEGER," + // 64: freeLongTime
"\"FREE_PERIOD_BEGIN\" INTEGER," + // 65: freePeriodBegin
"\"IS_STATISTIC\" INTEGER);"); // 66: isStatistic
}
/** Drops the underlying database table. */
......@@ -191,344 +188,339 @@ public class FoodDao extends AbstractDao<Food, Long> {
protected final void bindValues(DatabaseStatement stmt, Food entity) {
stmt.clearBindings();
Long dbid = entity.getDbid();
if (dbid != null) {
stmt.bindLong(1, dbid);
}
Long id = entity.getId();
if (id != null) {
stmt.bindLong(2, id);
stmt.bindLong(1, id);
}
Long parentId = entity.getParentId();
if (parentId != null) {
stmt.bindLong(3, parentId);
stmt.bindLong(2, parentId);
}
Long restaurantId = entity.getRestaurantId();
if (restaurantId != null) {
stmt.bindLong(4, restaurantId);
stmt.bindLong(3, restaurantId);
}
Byte isParent = entity.getIsParent();
if (isParent != null) {
stmt.bindLong(5, isParent);
stmt.bindLong(4, isParent);
}
Long seqNo = entity.getSeqNo();
if (seqNo != null) {
stmt.bindLong(6, seqNo);
stmt.bindLong(5, seqNo);
}
String foodName = entity.getFoodName();
if (foodName != null) {
stmt.bindString(7, foodName);
stmt.bindString(6, foodName);
}
String foodName1 = entity.getFoodName1();
if (foodName1 != null) {
stmt.bindString(8, foodName1);
stmt.bindString(7, foodName1);
}
String foodName2 = entity.getFoodName2();
if (foodName2 != null) {
stmt.bindString(9, foodName2);
stmt.bindString(8, foodName2);
}
String plu = entity.getPlu();
if (plu != null) {
stmt.bindString(10, plu);
stmt.bindString(9, plu);
}
String posFid = entity.getPosFid();
if (posFid != null) {
stmt.bindString(11, posFid);
stmt.bindString(10, posFid);
}
String foodDesc = entity.getFoodDesc();
if (foodDesc != null) {
stmt.bindString(12, foodDesc);
stmt.bindString(11, foodDesc);
}
Long limitAmount = entity.getLimitAmount();
if (limitAmount != null) {
stmt.bindLong(13, limitAmount);
stmt.bindLong(12, limitAmount);
}
Long limitType = entity.getLimitType();
if (limitType != null) {
stmt.bindLong(14, limitType);
stmt.bindLong(13, limitType);
}
Long foodSummary = entity.getFoodSummary();
if (foodSummary != null) {
stmt.bindLong(15, foodSummary);
stmt.bindLong(14, foodSummary);
}
Long invisible = entity.getInvisible();
if (invisible != null) {
stmt.bindLong(16, invisible);
stmt.bindLong(15, invisible);
}
Byte autoMod = entity.getAutoMod();
if (autoMod != null) {
stmt.bindLong(17, autoMod);
stmt.bindLong(16, autoMod);
}
Double price = entity.getPrice();
if (price != null) {
stmt.bindDouble(18, price);
stmt.bindDouble(17, price);
}
Double marketPrice = entity.getMarketPrice();
if (marketPrice != null) {
stmt.bindDouble(19, marketPrice);
stmt.bindDouble(18, marketPrice);
}
Double lunchboxPrice = entity.getLunchboxPrice();
if (lunchboxPrice != null) {
stmt.bindDouble(20, lunchboxPrice);
stmt.bindDouble(19, lunchboxPrice);
}
String imgUrlSmall = entity.getImgUrlSmall();
if (imgUrlSmall != null) {
stmt.bindString(21, imgUrlSmall);
stmt.bindString(20, imgUrlSmall);
}
String imageurl = entity.getImageurl();
if (imageurl != null) {
stmt.bindString(22, imageurl);
stmt.bindString(21, imageurl);
}
Long riceponInvisible = entity.getRiceponInvisible();
if (riceponInvisible != null) {
stmt.bindLong(23, riceponInvisible);
stmt.bindLong(22, riceponInvisible);
}
Double cost = entity.getCost();
if (cost != null) {
stmt.bindDouble(24, cost);
stmt.bindDouble(23, cost);
}
java.util.Date startDate = entity.getStartDate();
if (startDate != null) {
stmt.bindLong(25, startDate.getTime());
stmt.bindLong(24, startDate.getTime());
}
java.util.Date endDate = entity.getEndDate();
if (endDate != null) {
stmt.bindLong(26, endDate.getTime());
stmt.bindLong(25, endDate.getTime());
}
Long like = entity.getLike();
if (like != null) {
stmt.bindLong(27, like);
stmt.bindLong(26, like);
}
Long totalSold = entity.getTotalSold();
if (totalSold != null) {
stmt.bindLong(28, totalSold);
stmt.bindLong(27, totalSold);
}
Long isSold = entity.getIsSold();
if (isSold != null) {
stmt.bindLong(29, isSold);
stmt.bindLong(28, isSold);
}
String createBy = entity.getCreateBy();
if (createBy != null) {
stmt.bindString(30, createBy);
stmt.bindString(29, createBy);
}
java.util.Date createTime = entity.getCreateTime();
if (createTime != null) {
stmt.bindLong(31, createTime.getTime());
stmt.bindLong(30, createTime.getTime());
}
String updateBy = entity.getUpdateBy();
if (updateBy != null) {
stmt.bindString(32, updateBy);
stmt.bindString(31, updateBy);
}
java.util.Date updateTime = entity.getUpdateTime();
if (updateTime != null) {
stmt.bindLong(33, updateTime.getTime());
stmt.bindLong(32, updateTime.getTime());
}
Long periodId = entity.getPeriodId();
if (periodId != null) {
stmt.bindLong(34, periodId);
stmt.bindLong(33, periodId);
}
Long ableDiscount = entity.getAbleDiscount();
if (ableDiscount != null) {
stmt.bindLong(35, ableDiscount);
stmt.bindLong(34, ableDiscount);
}
Long takeaway = entity.getTakeaway();
if (takeaway != null) {
stmt.bindLong(36, takeaway);
stmt.bindLong(35, takeaway);
}
Long blueEdit = entity.getBlueEdit();
if (blueEdit != null) {
stmt.bindLong(37, blueEdit);
stmt.bindLong(36, blueEdit);
}
Long cartEdit = entity.getCartEdit();
if (cartEdit != null) {
stmt.bindLong(38, cartEdit);
stmt.bindLong(37, cartEdit);
}
Long autoMerge = entity.getAutoMerge();
if (autoMerge != null) {
stmt.bindLong(39, autoMerge);
stmt.bindLong(38, autoMerge);
}
String printSeting = entity.getPrintSeting();
if (printSeting != null) {
stmt.bindString(40, printSeting);
stmt.bindString(39, printSeting);
}
Long isPrintQueueCode = entity.getIsPrintQueueCode();
if (isPrintQueueCode != null) {
stmt.bindLong(41, isPrintQueueCode);
stmt.bindLong(40, isPrintQueueCode);
}
Long queueHeadId = entity.getQueueHeadId();
if (queueHeadId != null) {
stmt.bindLong(42, queueHeadId);
stmt.bindLong(41, queueHeadId);
}
Long approve = entity.getApprove();
if (approve != null) {
stmt.bindLong(43, approve);
stmt.bindLong(42, approve);
}
Long printFont = entity.getPrintFont();
if (printFont != null) {
stmt.bindLong(44, printFont);
stmt.bindLong(43, printFont);
}
Long advPrice = entity.getAdvPrice();
if (advPrice != null) {
stmt.bindLong(45, advPrice);
stmt.bindLong(44, advPrice);
}
Long printToBill = entity.getPrintToBill();
if (printToBill != null) {
stmt.bindLong(46, printToBill);
stmt.bindLong(45, printToBill);
}
Double pointsAdd = entity.getPointsAdd();
if (pointsAdd != null) {
stmt.bindDouble(47, pointsAdd);
stmt.bindDouble(46, pointsAdd);
}
Long pointsRatio = entity.getPointsRatio();
if (pointsRatio != null) {
stmt.bindLong(48, pointsRatio);
stmt.bindLong(47, pointsRatio);
}
Double pointsRedeem = entity.getPointsRedeem();
if (pointsRedeem != null) {
stmt.bindDouble(49, pointsRedeem);
stmt.bindDouble(48, pointsRedeem);
}
Long ktPrintMainItem = entity.getKtPrintMainItem();
if (ktPrintMainItem != null) {
stmt.bindLong(50, ktPrintMainItem);
stmt.bindLong(49, ktPrintMainItem);
}
Long ktShowPrice = entity.getKtShowPrice();
if (ktShowPrice != null) {
stmt.bindLong(51, ktShowPrice);
stmt.bindLong(50, ktShowPrice);
}
Long printTo = entity.getPrintTo();
if (printTo != null) {
stmt.bindLong(52, printTo);
stmt.bindLong(51, printTo);
}
Long toPax = entity.getToPax();
if (toPax != null) {
stmt.bindLong(53, toPax);
stmt.bindLong(52, toPax);
}
Long foodType = entity.getFoodType();
if (foodType != null) {
stmt.bindLong(54, foodType);
stmt.bindLong(53, foodType);
}
Long majorMainId = entity.getMajorMainId();
if (majorMainId != null) {
stmt.bindLong(55, majorMainId);
stmt.bindLong(54, majorMainId);
}
Long deptId = entity.getDeptId();
if (deptId != null) {
stmt.bindLong(56, deptId);
stmt.bindLong(55, deptId);
}
Byte serviceCharge = entity.getServiceCharge();
if (serviceCharge != null) {
stmt.bindLong(57, serviceCharge);
stmt.bindLong(56, serviceCharge);
}
Long colorId = entity.getColorId();
if (colorId != null) {
stmt.bindLong(58, colorId);
stmt.bindLong(57, colorId);
}
Long conditions = entity.getConditions();
if (conditions != null) {
stmt.bindLong(59, conditions);
stmt.bindLong(58, conditions);
}
Long isRt = entity.getIsRt();
if (isRt != null) {
stmt.bindLong(60, isRt);
stmt.bindLong(59, isRt);
}
Long deletes = entity.getDeletes();
if (deletes != null) {
stmt.bindLong(61, deletes);
stmt.bindLong(60, deletes);
}
Long isTimingFood = entity.getIsTimingFood();
if (isTimingFood != null) {
stmt.bindLong(62, isTimingFood);
stmt.bindLong(61, isTimingFood);
}
Long minLongTime = entity.getMinLongTime();
if (minLongTime != null) {
stmt.bindLong(63, minLongTime);
stmt.bindLong(62, minLongTime);
}
Long unitTime = entity.getUnitTime();
if (unitTime != null) {
stmt.bindLong(64, unitTime);
stmt.bindLong(63, unitTime);
}
Double unitPrice = entity.getUnitPrice();
if (unitPrice != null) {
stmt.bindDouble(65, unitPrice);
stmt.bindDouble(64, unitPrice);
}
Long freeLongTime = entity.getFreeLongTime();
if (freeLongTime != null) {
stmt.bindLong(66, freeLongTime);
stmt.bindLong(65, freeLongTime);
}
java.util.Date freePeriodBegin = entity.getFreePeriodBegin();
if (freePeriodBegin != null) {
stmt.bindLong(67, freePeriodBegin.getTime());
stmt.bindLong(66, freePeriodBegin.getTime());
}
Long isStatistic = entity.getIsStatistic();
if (isStatistic != null) {
stmt.bindLong(68, isStatistic);
stmt.bindLong(67, isStatistic);
}
}
......@@ -536,345 +528,346 @@ public class FoodDao extends AbstractDao<Food, Long> {
protected final void bindValues(SQLiteStatement stmt, Food entity) {
stmt.clearBindings();
Long dbid = entity.getDbid();
if (dbid != null) {
stmt.bindLong(1, dbid);
}
Long id = entity.getId();
if (id != null) {
stmt.bindLong(2, id);
stmt.bindLong(1, id);
}
Long parentId = entity.getParentId();
if (parentId != null) {
stmt.bindLong(3, parentId);
stmt.bindLong(2, parentId);
}
Long restaurantId = entity.getRestaurantId();
if (restaurantId != null) {
stmt.bindLong(4, restaurantId);
stmt.bindLong(3, restaurantId);
}
Byte isParent = entity.getIsParent();
if (isParent != null) {
stmt.bindLong(5, isParent);
stmt.bindLong(4, isParent);
}
Long seqNo = entity.getSeqNo();
if (seqNo != null) {
stmt.bindLong(6, seqNo);
stmt.bindLong(5, seqNo);
}
String foodName = entity.getFoodName();
if (foodName != null) {
stmt.bindString(7, foodName);
stmt.bindString(6, foodName);
}
String foodName1 = entity.getFoodName1();
if (foodName1 != null) {
stmt.bindString(8, foodName1);
stmt.bindString(7, foodName1);
}
String foodName2 = entity.getFoodName2();
if (foodName2 != null) {
stmt.bindString(9, foodName2);
stmt.bindString(8, foodName2);
}
String plu = entity.getPlu();
if (plu != null) {
stmt.bindString(10, plu);
stmt.bindString(9, plu);
}
String posFid = entity.getPosFid();
if (posFid != null) {
stmt.bindString(11, posFid);
stmt.bindString(10, posFid);
}
String foodDesc = entity.getFoodDesc();
if (foodDesc != null) {
stmt.bindString(12, foodDesc);
stmt.bindString(11, foodDesc);
}
Long limitAmount = entity.getLimitAmount();
if (limitAmount != null) {
stmt.bindLong(13, limitAmount);
stmt.bindLong(12, limitAmount);
}
Long limitType = entity.getLimitType();
if (limitType != null) {
stmt.bindLong(14, limitType);
stmt.bindLong(13, limitType);
}
Long foodSummary = entity.getFoodSummary();
if (foodSummary != null) {
stmt.bindLong(15, foodSummary);
stmt.bindLong(14, foodSummary);
}
Long invisible = entity.getInvisible();
if (invisible != null) {
stmt.bindLong(16, invisible);
stmt.bindLong(15, invisible);
}
Byte autoMod = entity.getAutoMod();
if (autoMod != null) {
stmt.bindLong(17, autoMod);
stmt.bindLong(16, autoMod);
}
Double price = entity.getPrice();
if (price != null) {
stmt.bindDouble(18, price);
stmt.bindDouble(17, price);
}
Double marketPrice = entity.getMarketPrice();
if (marketPrice != null) {
stmt.bindDouble(19, marketPrice);
stmt.bindDouble(18, marketPrice);
}
Double lunchboxPrice = entity.getLunchboxPrice();
if (lunchboxPrice != null) {
stmt.bindDouble(20, lunchboxPrice);
stmt.bindDouble(19, lunchboxPrice);
}
String imgUrlSmall = entity.getImgUrlSmall();
if (imgUrlSmall != null) {
stmt.bindString(21, imgUrlSmall);
stmt.bindString(20, imgUrlSmall);
}
String imageurl = entity.getImageurl();
if (imageurl != null) {
stmt.bindString(22, imageurl);
stmt.bindString(21, imageurl);
}
Long riceponInvisible = entity.getRiceponInvisible();
if (riceponInvisible != null) {
stmt.bindLong(23, riceponInvisible);
stmt.bindLong(22, riceponInvisible);
}
Double cost = entity.getCost();
if (cost != null) {
stmt.bindDouble(24, cost);
stmt.bindDouble(23, cost);
}
java.util.Date startDate = entity.getStartDate();
if (startDate != null) {
stmt.bindLong(25, startDate.getTime());
stmt.bindLong(24, startDate.getTime());
}
java.util.Date endDate = entity.getEndDate();
if (endDate != null) {
stmt.bindLong(26, endDate.getTime());
stmt.bindLong(25, endDate.getTime());
}
Long like = entity.getLike();
if (like != null) {
stmt.bindLong(27, like);
stmt.bindLong(26, like);
}
Long totalSold = entity.getTotalSold();
if (totalSold != null) {
stmt.bindLong(28, totalSold);
stmt.bindLong(27, totalSold);
}
Long isSold = entity.getIsSold();
if (isSold != null) {
stmt.bindLong(29, isSold);
stmt.bindLong(28, isSold);
}
String createBy = entity.getCreateBy();
if (createBy != null) {
stmt.bindString(30, createBy);
stmt.bindString(29, createBy);
}
java.util.Date createTime = entity.getCreateTime();
if (createTime != null) {
stmt.bindLong(31, createTime.getTime());
stmt.bindLong(30, createTime.getTime());
}
String updateBy = entity.getUpdateBy();
if (updateBy != null) {
stmt.bindString(32, updateBy);
stmt.bindString(31, updateBy);
}
java.util.Date updateTime = entity.getUpdateTime();
if (updateTime != null) {
stmt.bindLong(33, updateTime.getTime());
stmt.bindLong(32, updateTime.getTime());
}
Long periodId = entity.getPeriodId();
if (periodId != null) {
stmt.bindLong(34, periodId);
stmt.bindLong(33, periodId);
}
Long ableDiscount = entity.getAbleDiscount();
if (ableDiscount != null) {
stmt.bindLong(35, ableDiscount);
stmt.bindLong(34, ableDiscount);
}
Long takeaway = entity.getTakeaway();
if (takeaway != null) {
stmt.bindLong(36, takeaway);
stmt.bindLong(35, takeaway);
}
Long blueEdit = entity.getBlueEdit();
if (blueEdit != null) {
stmt.bindLong(37, blueEdit);
stmt.bindLong(36, blueEdit);
}
Long cartEdit = entity.getCartEdit();
if (cartEdit != null) {
stmt.bindLong(38, cartEdit);
stmt.bindLong(37, cartEdit);
}
Long autoMerge = entity.getAutoMerge();
if (autoMerge != null) {
stmt.bindLong(39, autoMerge);
stmt.bindLong(38, autoMerge);
}
String printSeting = entity.getPrintSeting();
if (printSeting != null) {
stmt.bindString(40, printSeting);
stmt.bindString(39, printSeting);
}
Long isPrintQueueCode = entity.getIsPrintQueueCode();
if (isPrintQueueCode != null) {
stmt.bindLong(41, isPrintQueueCode);
stmt.bindLong(40, isPrintQueueCode);
}
Long queueHeadId = entity.getQueueHeadId();
if (queueHeadId != null) {
stmt.bindLong(42, queueHeadId);
stmt.bindLong(41, queueHeadId);
}
Long approve = entity.getApprove();
if (approve != null) {
stmt.bindLong(43, approve);
stmt.bindLong(42, approve);
}
Long printFont = entity.getPrintFont();
if (printFont != null) {
stmt.bindLong(44, printFont);
stmt.bindLong(43, printFont);
}
Long advPrice = entity.getAdvPrice();
if (advPrice != null) {
stmt.bindLong(45, advPrice);
stmt.bindLong(44, advPrice);
}
Long printToBill = entity.getPrintToBill();
if (printToBill != null) {
stmt.bindLong(46, printToBill);
stmt.bindLong(45, printToBill);
}
Double pointsAdd = entity.getPointsAdd();
if (pointsAdd != null) {
stmt.bindDouble(47, pointsAdd);
stmt.bindDouble(46, pointsAdd);
}
Long pointsRatio = entity.getPointsRatio();
if (pointsRatio != null) {
stmt.bindLong(48, pointsRatio);
stmt.bindLong(47, pointsRatio);
}
Double pointsRedeem = entity.getPointsRedeem();
if (pointsRedeem != null) {
stmt.bindDouble(49, pointsRedeem);
stmt.bindDouble(48, pointsRedeem);
}
Long ktPrintMainItem = entity.getKtPrintMainItem();
if (ktPrintMainItem != null) {
stmt.bindLong(50, ktPrintMainItem);
stmt.bindLong(49, ktPrintMainItem);
}
Long ktShowPrice = entity.getKtShowPrice();
if (ktShowPrice != null) {
stmt.bindLong(51, ktShowPrice);
stmt.bindLong(50, ktShowPrice);
}
Long printTo = entity.getPrintTo();
if (printTo != null) {
stmt.bindLong(52, printTo);
stmt.bindLong(51, printTo);
}
Long toPax = entity.getToPax();
if (toPax != null) {
stmt.bindLong(53, toPax);
stmt.bindLong(52, toPax);
}
Long foodType = entity.getFoodType();
if (foodType != null) {
stmt.bindLong(54, foodType);
stmt.bindLong(53, foodType);
}
Long majorMainId = entity.getMajorMainId();
if (majorMainId != null) {
stmt.bindLong(55, majorMainId);
stmt.bindLong(54, majorMainId);
}
Long deptId = entity.getDeptId();
if (deptId != null) {
stmt.bindLong(56, deptId);
stmt.bindLong(55, deptId);
}
Byte serviceCharge = entity.getServiceCharge();
if (serviceCharge != null) {
stmt.bindLong(57, serviceCharge);
stmt.bindLong(56, serviceCharge);
}
Long colorId = entity.getColorId();
if (colorId != null) {
stmt.bindLong(58, colorId);
stmt.bindLong(57, colorId);
}
Long conditions = entity.getConditions();
if (conditions != null) {
stmt.bindLong(59, conditions);
stmt.bindLong(58, conditions);
}
Long isRt = entity.getIsRt();
if (isRt != null) {
stmt.bindLong(60, isRt);
stmt.bindLong(59, isRt);
}
Long deletes = entity.getDeletes();
if (deletes != null) {
stmt.bindLong(61, deletes);
stmt.bindLong(60, deletes);
}
Long isTimingFood = entity.getIsTimingFood();
if (isTimingFood != null) {
stmt.bindLong(62, isTimingFood);
stmt.bindLong(61, isTimingFood);
}
Long minLongTime = entity.getMinLongTime();
if (minLongTime != null) {
stmt.bindLong(63, minLongTime);
stmt.bindLong(62, minLongTime);
}
Long unitTime = entity.getUnitTime();
if (unitTime != null) {
stmt.bindLong(64, unitTime);
stmt.bindLong(63, unitTime);
}
Double unitPrice = entity.getUnitPrice();
if (unitPrice != null) {
stmt.bindDouble(65, unitPrice);
stmt.bindDouble(64, unitPrice);
}
Long freeLongTime = entity.getFreeLongTime();
if (freeLongTime != null) {
stmt.bindLong(66, freeLongTime);
stmt.bindLong(65, freeLongTime);
}
java.util.Date freePeriodBegin = entity.getFreePeriodBegin();
if (freePeriodBegin != null) {
stmt.bindLong(67, freePeriodBegin.getTime());
stmt.bindLong(66, freePeriodBegin.getTime());
}
Long isStatistic = entity.getIsStatistic();
if (isStatistic != null) {
stmt.bindLong(68, isStatistic);
stmt.bindLong(67, isStatistic);
}
}
@Override
protected final void attachEntity(Food entity) {
super.attachEntity(entity);
entity.__setDaoSession(daoSession);
}
@Override
......@@ -885,160 +878,158 @@ public class FoodDao extends AbstractDao<Food, Long> {
@Override
public Food readEntity(Cursor cursor, int offset) {
Food entity = new Food( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // dbid
cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // id
cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2), // parentId
cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3), // restaurantId
cursor.isNull(offset + 4) ? null : (byte) cursor.getShort(offset + 4), // isParent
cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5), // seqNo
cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // foodName
cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // foodName1
cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // foodName2
cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // plu
cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // posFid
cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // foodDesc
cursor.isNull(offset + 12) ? null : cursor.getLong(offset + 12), // limitAmount
cursor.isNull(offset + 13) ? null : cursor.getLong(offset + 13), // limitType
cursor.isNull(offset + 14) ? null : cursor.getLong(offset + 14), // foodSummary
cursor.isNull(offset + 15) ? null : cursor.getLong(offset + 15), // invisible
cursor.isNull(offset + 16) ? null : (byte) cursor.getShort(offset + 16), // autoMod
cursor.isNull(offset + 17) ? null : cursor.getDouble(offset + 17), // price
cursor.isNull(offset + 18) ? null : cursor.getDouble(offset + 18), // marketPrice
cursor.isNull(offset + 19) ? null : cursor.getDouble(offset + 19), // lunchboxPrice
cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // imgUrlSmall
cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // imageurl
cursor.isNull(offset + 22) ? null : cursor.getLong(offset + 22), // riceponInvisible
cursor.isNull(offset + 23) ? null : cursor.getDouble(offset + 23), // cost
cursor.isNull(offset + 24) ? null : new java.util.Date(cursor.getLong(offset + 24)), // startDate
cursor.isNull(offset + 25) ? null : new java.util.Date(cursor.getLong(offset + 25)), // endDate
cursor.isNull(offset + 26) ? null : cursor.getLong(offset + 26), // like
cursor.isNull(offset + 27) ? null : cursor.getLong(offset + 27), // totalSold
cursor.isNull(offset + 28) ? null : cursor.getLong(offset + 28), // isSold
cursor.isNull(offset + 29) ? null : cursor.getString(offset + 29), // createBy
cursor.isNull(offset + 30) ? null : new java.util.Date(cursor.getLong(offset + 30)), // createTime
cursor.isNull(offset + 31) ? null : cursor.getString(offset + 31), // updateBy
cursor.isNull(offset + 32) ? null : new java.util.Date(cursor.getLong(offset + 32)), // updateTime
cursor.isNull(offset + 33) ? null : cursor.getLong(offset + 33), // periodId
cursor.isNull(offset + 34) ? null : cursor.getLong(offset + 34), // ableDiscount
cursor.isNull(offset + 35) ? null : cursor.getLong(offset + 35), // takeaway
cursor.isNull(offset + 36) ? null : cursor.getLong(offset + 36), // blueEdit
cursor.isNull(offset + 37) ? null : cursor.getLong(offset + 37), // cartEdit
cursor.isNull(offset + 38) ? null : cursor.getLong(offset + 38), // autoMerge
cursor.isNull(offset + 39) ? null : cursor.getString(offset + 39), // printSeting
cursor.isNull(offset + 40) ? null : cursor.getLong(offset + 40), // isPrintQueueCode
cursor.isNull(offset + 41) ? null : cursor.getLong(offset + 41), // queueHeadId
cursor.isNull(offset + 42) ? null : cursor.getLong(offset + 42), // approve
cursor.isNull(offset + 43) ? null : cursor.getLong(offset + 43), // printFont
cursor.isNull(offset + 44) ? null : cursor.getLong(offset + 44), // advPrice
cursor.isNull(offset + 45) ? null : cursor.getLong(offset + 45), // printToBill
cursor.isNull(offset + 46) ? null : cursor.getDouble(offset + 46), // pointsAdd
cursor.isNull(offset + 47) ? null : cursor.getLong(offset + 47), // pointsRatio
cursor.isNull(offset + 48) ? null : cursor.getDouble(offset + 48), // pointsRedeem
cursor.isNull(offset + 49) ? null : cursor.getLong(offset + 49), // ktPrintMainItem
cursor.isNull(offset + 50) ? null : cursor.getLong(offset + 50), // ktShowPrice
cursor.isNull(offset + 51) ? null : cursor.getLong(offset + 51), // printTo
cursor.isNull(offset + 52) ? null : cursor.getLong(offset + 52), // toPax
cursor.isNull(offset + 53) ? null : cursor.getLong(offset + 53), // foodType
cursor.isNull(offset + 54) ? null : cursor.getLong(offset + 54), // majorMainId
cursor.isNull(offset + 55) ? null : cursor.getLong(offset + 55), // deptId
cursor.isNull(offset + 56) ? null : (byte) cursor.getShort(offset + 56), // serviceCharge
cursor.isNull(offset + 57) ? null : cursor.getLong(offset + 57), // colorId
cursor.isNull(offset + 58) ? null : cursor.getLong(offset + 58), // conditions
cursor.isNull(offset + 59) ? null : cursor.getLong(offset + 59), // isRt
cursor.isNull(offset + 60) ? null : cursor.getLong(offset + 60), // deletes
cursor.isNull(offset + 61) ? null : cursor.getLong(offset + 61), // isTimingFood
cursor.isNull(offset + 62) ? null : cursor.getLong(offset + 62), // minLongTime
cursor.isNull(offset + 63) ? null : cursor.getLong(offset + 63), // unitTime
cursor.isNull(offset + 64) ? null : cursor.getDouble(offset + 64), // unitPrice
cursor.isNull(offset + 65) ? null : cursor.getLong(offset + 65), // freeLongTime
cursor.isNull(offset + 66) ? null : new java.util.Date(cursor.getLong(offset + 66)), // freePeriodBegin
cursor.isNull(offset + 67) ? null : cursor.getLong(offset + 67) // isStatistic
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // parentId
cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2), // restaurantId
cursor.isNull(offset + 3) ? null : (byte) cursor.getShort(offset + 3), // isParent
cursor.isNull(offset + 4) ? null : cursor.getLong(offset + 4), // seqNo
cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // foodName
cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // foodName1
cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // foodName2
cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // plu
cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // posFid
cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // foodDesc
cursor.isNull(offset + 11) ? null : cursor.getLong(offset + 11), // limitAmount
cursor.isNull(offset + 12) ? null : cursor.getLong(offset + 12), // limitType
cursor.isNull(offset + 13) ? null : cursor.getLong(offset + 13), // foodSummary
cursor.isNull(offset + 14) ? null : cursor.getLong(offset + 14), // invisible
cursor.isNull(offset + 15) ? null : (byte) cursor.getShort(offset + 15), // autoMod
cursor.isNull(offset + 16) ? null : cursor.getDouble(offset + 16), // price
cursor.isNull(offset + 17) ? null : cursor.getDouble(offset + 17), // marketPrice
cursor.isNull(offset + 18) ? null : cursor.getDouble(offset + 18), // lunchboxPrice
cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // imgUrlSmall
cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // imageurl
cursor.isNull(offset + 21) ? null : cursor.getLong(offset + 21), // riceponInvisible
cursor.isNull(offset + 22) ? null : cursor.getDouble(offset + 22), // cost
cursor.isNull(offset + 23) ? null : new java.util.Date(cursor.getLong(offset + 23)), // startDate
cursor.isNull(offset + 24) ? null : new java.util.Date(cursor.getLong(offset + 24)), // endDate
cursor.isNull(offset + 25) ? null : cursor.getLong(offset + 25), // like
cursor.isNull(offset + 26) ? null : cursor.getLong(offset + 26), // totalSold
cursor.isNull(offset + 27) ? null : cursor.getLong(offset + 27), // isSold
cursor.isNull(offset + 28) ? null : cursor.getString(offset + 28), // createBy
cursor.isNull(offset + 29) ? null : new java.util.Date(cursor.getLong(offset + 29)), // createTime
cursor.isNull(offset + 30) ? null : cursor.getString(offset + 30), // updateBy
cursor.isNull(offset + 31) ? null : new java.util.Date(cursor.getLong(offset + 31)), // updateTime
cursor.isNull(offset + 32) ? null : cursor.getLong(offset + 32), // periodId
cursor.isNull(offset + 33) ? null : cursor.getLong(offset + 33), // ableDiscount
cursor.isNull(offset + 34) ? null : cursor.getLong(offset + 34), // takeaway
cursor.isNull(offset + 35) ? null : cursor.getLong(offset + 35), // blueEdit
cursor.isNull(offset + 36) ? null : cursor.getLong(offset + 36), // cartEdit
cursor.isNull(offset + 37) ? null : cursor.getLong(offset + 37), // autoMerge
cursor.isNull(offset + 38) ? null : cursor.getString(offset + 38), // printSeting
cursor.isNull(offset + 39) ? null : cursor.getLong(offset + 39), // isPrintQueueCode
cursor.isNull(offset + 40) ? null : cursor.getLong(offset + 40), // queueHeadId
cursor.isNull(offset + 41) ? null : cursor.getLong(offset + 41), // approve
cursor.isNull(offset + 42) ? null : cursor.getLong(offset + 42), // printFont
cursor.isNull(offset + 43) ? null : cursor.getLong(offset + 43), // advPrice
cursor.isNull(offset + 44) ? null : cursor.getLong(offset + 44), // printToBill
cursor.isNull(offset + 45) ? null : cursor.getDouble(offset + 45), // pointsAdd
cursor.isNull(offset + 46) ? null : cursor.getLong(offset + 46), // pointsRatio
cursor.isNull(offset + 47) ? null : cursor.getDouble(offset + 47), // pointsRedeem
cursor.isNull(offset + 48) ? null : cursor.getLong(offset + 48), // ktPrintMainItem
cursor.isNull(offset + 49) ? null : cursor.getLong(offset + 49), // ktShowPrice
cursor.isNull(offset + 50) ? null : cursor.getLong(offset + 50), // printTo
cursor.isNull(offset + 51) ? null : cursor.getLong(offset + 51), // toPax
cursor.isNull(offset + 52) ? null : cursor.getLong(offset + 52), // foodType
cursor.isNull(offset + 53) ? null : cursor.getLong(offset + 53), // majorMainId
cursor.isNull(offset + 54) ? null : cursor.getLong(offset + 54), // deptId
cursor.isNull(offset + 55) ? null : (byte) cursor.getShort(offset + 55), // serviceCharge
cursor.isNull(offset + 56) ? null : cursor.getLong(offset + 56), // colorId
cursor.isNull(offset + 57) ? null : cursor.getLong(offset + 57), // conditions
cursor.isNull(offset + 58) ? null : cursor.getLong(offset + 58), // isRt
cursor.isNull(offset + 59) ? null : cursor.getLong(offset + 59), // deletes
cursor.isNull(offset + 60) ? null : cursor.getLong(offset + 60), // isTimingFood
cursor.isNull(offset + 61) ? null : cursor.getLong(offset + 61), // minLongTime
cursor.isNull(offset + 62) ? null : cursor.getLong(offset + 62), // unitTime
cursor.isNull(offset + 63) ? null : cursor.getDouble(offset + 63), // unitPrice
cursor.isNull(offset + 64) ? null : cursor.getLong(offset + 64), // freeLongTime
cursor.isNull(offset + 65) ? null : new java.util.Date(cursor.getLong(offset + 65)), // freePeriodBegin
cursor.isNull(offset + 66) ? null : cursor.getLong(offset + 66) // isStatistic
);
return entity;
}
@Override
public void readEntity(Cursor cursor, Food entity, int offset) {
entity.setDbid(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setId(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
entity.setParentId(cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2));
entity.setRestaurantId(cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3));
entity.setIsParent(cursor.isNull(offset + 4) ? null : (byte) cursor.getShort(offset + 4));
entity.setSeqNo(cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5));
entity.setFoodName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
entity.setFoodName1(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
entity.setFoodName2(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
entity.setPlu(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
entity.setPosFid(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
entity.setFoodDesc(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
entity.setLimitAmount(cursor.isNull(offset + 12) ? null : cursor.getLong(offset + 12));
entity.setLimitType(cursor.isNull(offset + 13) ? null : cursor.getLong(offset + 13));
entity.setFoodSummary(cursor.isNull(offset + 14) ? null : cursor.getLong(offset + 14));
entity.setInvisible(cursor.isNull(offset + 15) ? null : cursor.getLong(offset + 15));
entity.setAutoMod(cursor.isNull(offset + 16) ? null : (byte) cursor.getShort(offset + 16));
entity.setPrice(cursor.isNull(offset + 17) ? null : cursor.getDouble(offset + 17));
entity.setMarketPrice(cursor.isNull(offset + 18) ? null : cursor.getDouble(offset + 18));
entity.setLunchboxPrice(cursor.isNull(offset + 19) ? null : cursor.getDouble(offset + 19));
entity.setImgUrlSmall(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20));
entity.setImageurl(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21));
entity.setRiceponInvisible(cursor.isNull(offset + 22) ? null : cursor.getLong(offset + 22));
entity.setCost(cursor.isNull(offset + 23) ? null : cursor.getDouble(offset + 23));
entity.setStartDate(cursor.isNull(offset + 24) ? null : new java.util.Date(cursor.getLong(offset + 24)));
entity.setEndDate(cursor.isNull(offset + 25) ? null : new java.util.Date(cursor.getLong(offset + 25)));
entity.setLike(cursor.isNull(offset + 26) ? null : cursor.getLong(offset + 26));
entity.setTotalSold(cursor.isNull(offset + 27) ? null : cursor.getLong(offset + 27));
entity.setIsSold(cursor.isNull(offset + 28) ? null : cursor.getLong(offset + 28));
entity.setCreateBy(cursor.isNull(offset + 29) ? null : cursor.getString(offset + 29));
entity.setCreateTime(cursor.isNull(offset + 30) ? null : new java.util.Date(cursor.getLong(offset + 30)));
entity.setUpdateBy(cursor.isNull(offset + 31) ? null : cursor.getString(offset + 31));
entity.setUpdateTime(cursor.isNull(offset + 32) ? null : new java.util.Date(cursor.getLong(offset + 32)));
entity.setPeriodId(cursor.isNull(offset + 33) ? null : cursor.getLong(offset + 33));
entity.setAbleDiscount(cursor.isNull(offset + 34) ? null : cursor.getLong(offset + 34));
entity.setTakeaway(cursor.isNull(offset + 35) ? null : cursor.getLong(offset + 35));
entity.setBlueEdit(cursor.isNull(offset + 36) ? null : cursor.getLong(offset + 36));
entity.setCartEdit(cursor.isNull(offset + 37) ? null : cursor.getLong(offset + 37));
entity.setAutoMerge(cursor.isNull(offset + 38) ? null : cursor.getLong(offset + 38));
entity.setPrintSeting(cursor.isNull(offset + 39) ? null : cursor.getString(offset + 39));
entity.setIsPrintQueueCode(cursor.isNull(offset + 40) ? null : cursor.getLong(offset + 40));
entity.setQueueHeadId(cursor.isNull(offset + 41) ? null : cursor.getLong(offset + 41));
entity.setApprove(cursor.isNull(offset + 42) ? null : cursor.getLong(offset + 42));
entity.setPrintFont(cursor.isNull(offset + 43) ? null : cursor.getLong(offset + 43));
entity.setAdvPrice(cursor.isNull(offset + 44) ? null : cursor.getLong(offset + 44));
entity.setPrintToBill(cursor.isNull(offset + 45) ? null : cursor.getLong(offset + 45));
entity.setPointsAdd(cursor.isNull(offset + 46) ? null : cursor.getDouble(offset + 46));
entity.setPointsRatio(cursor.isNull(offset + 47) ? null : cursor.getLong(offset + 47));
entity.setPointsRedeem(cursor.isNull(offset + 48) ? null : cursor.getDouble(offset + 48));
entity.setKtPrintMainItem(cursor.isNull(offset + 49) ? null : cursor.getLong(offset + 49));
entity.setKtShowPrice(cursor.isNull(offset + 50) ? null : cursor.getLong(offset + 50));
entity.setPrintTo(cursor.isNull(offset + 51) ? null : cursor.getLong(offset + 51));
entity.setToPax(cursor.isNull(offset + 52) ? null : cursor.getLong(offset + 52));
entity.setFoodType(cursor.isNull(offset + 53) ? null : cursor.getLong(offset + 53));
entity.setMajorMainId(cursor.isNull(offset + 54) ? null : cursor.getLong(offset + 54));
entity.setDeptId(cursor.isNull(offset + 55) ? null : cursor.getLong(offset + 55));
entity.setServiceCharge(cursor.isNull(offset + 56) ? null : (byte) cursor.getShort(offset + 56));
entity.setColorId(cursor.isNull(offset + 57) ? null : cursor.getLong(offset + 57));
entity.setConditions(cursor.isNull(offset + 58) ? null : cursor.getLong(offset + 58));
entity.setIsRt(cursor.isNull(offset + 59) ? null : cursor.getLong(offset + 59));
entity.setDeletes(cursor.isNull(offset + 60) ? null : cursor.getLong(offset + 60));
entity.setIsTimingFood(cursor.isNull(offset + 61) ? null : cursor.getLong(offset + 61));
entity.setMinLongTime(cursor.isNull(offset + 62) ? null : cursor.getLong(offset + 62));
entity.setUnitTime(cursor.isNull(offset + 63) ? null : cursor.getLong(offset + 63));
entity.setUnitPrice(cursor.isNull(offset + 64) ? null : cursor.getDouble(offset + 64));
entity.setFreeLongTime(cursor.isNull(offset + 65) ? null : cursor.getLong(offset + 65));
entity.setFreePeriodBegin(cursor.isNull(offset + 66) ? null : new java.util.Date(cursor.getLong(offset + 66)));
entity.setIsStatistic(cursor.isNull(offset + 67) ? null : cursor.getLong(offset + 67));
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setParentId(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
entity.setRestaurantId(cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2));
entity.setIsParent(cursor.isNull(offset + 3) ? null : (byte) cursor.getShort(offset + 3));
entity.setSeqNo(cursor.isNull(offset + 4) ? null : cursor.getLong(offset + 4));
entity.setFoodName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
entity.setFoodName1(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
entity.setFoodName2(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
entity.setPlu(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
entity.setPosFid(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
entity.setFoodDesc(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
entity.setLimitAmount(cursor.isNull(offset + 11) ? null : cursor.getLong(offset + 11));
entity.setLimitType(cursor.isNull(offset + 12) ? null : cursor.getLong(offset + 12));
entity.setFoodSummary(cursor.isNull(offset + 13) ? null : cursor.getLong(offset + 13));
entity.setInvisible(cursor.isNull(offset + 14) ? null : cursor.getLong(offset + 14));
entity.setAutoMod(cursor.isNull(offset + 15) ? null : (byte) cursor.getShort(offset + 15));
entity.setPrice(cursor.isNull(offset + 16) ? null : cursor.getDouble(offset + 16));
entity.setMarketPrice(cursor.isNull(offset + 17) ? null : cursor.getDouble(offset + 17));
entity.setLunchboxPrice(cursor.isNull(offset + 18) ? null : cursor.getDouble(offset + 18));
entity.setImgUrlSmall(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19));
entity.setImageurl(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20));
entity.setRiceponInvisible(cursor.isNull(offset + 21) ? null : cursor.getLong(offset + 21));
entity.setCost(cursor.isNull(offset + 22) ? null : cursor.getDouble(offset + 22));
entity.setStartDate(cursor.isNull(offset + 23) ? null : new java.util.Date(cursor.getLong(offset + 23)));
entity.setEndDate(cursor.isNull(offset + 24) ? null : new java.util.Date(cursor.getLong(offset + 24)));
entity.setLike(cursor.isNull(offset + 25) ? null : cursor.getLong(offset + 25));
entity.setTotalSold(cursor.isNull(offset + 26) ? null : cursor.getLong(offset + 26));
entity.setIsSold(cursor.isNull(offset + 27) ? null : cursor.getLong(offset + 27));
entity.setCreateBy(cursor.isNull(offset + 28) ? null : cursor.getString(offset + 28));
entity.setCreateTime(cursor.isNull(offset + 29) ? null : new java.util.Date(cursor.getLong(offset + 29)));
entity.setUpdateBy(cursor.isNull(offset + 30) ? null : cursor.getString(offset + 30));
entity.setUpdateTime(cursor.isNull(offset + 31) ? null : new java.util.Date(cursor.getLong(offset + 31)));
entity.setPeriodId(cursor.isNull(offset + 32) ? null : cursor.getLong(offset + 32));
entity.setAbleDiscount(cursor.isNull(offset + 33) ? null : cursor.getLong(offset + 33));
entity.setTakeaway(cursor.isNull(offset + 34) ? null : cursor.getLong(offset + 34));
entity.setBlueEdit(cursor.isNull(offset + 35) ? null : cursor.getLong(offset + 35));
entity.setCartEdit(cursor.isNull(offset + 36) ? null : cursor.getLong(offset + 36));
entity.setAutoMerge(cursor.isNull(offset + 37) ? null : cursor.getLong(offset + 37));
entity.setPrintSeting(cursor.isNull(offset + 38) ? null : cursor.getString(offset + 38));
entity.setIsPrintQueueCode(cursor.isNull(offset + 39) ? null : cursor.getLong(offset + 39));
entity.setQueueHeadId(cursor.isNull(offset + 40) ? null : cursor.getLong(offset + 40));
entity.setApprove(cursor.isNull(offset + 41) ? null : cursor.getLong(offset + 41));
entity.setPrintFont(cursor.isNull(offset + 42) ? null : cursor.getLong(offset + 42));
entity.setAdvPrice(cursor.isNull(offset + 43) ? null : cursor.getLong(offset + 43));
entity.setPrintToBill(cursor.isNull(offset + 44) ? null : cursor.getLong(offset + 44));
entity.setPointsAdd(cursor.isNull(offset + 45) ? null : cursor.getDouble(offset + 45));
entity.setPointsRatio(cursor.isNull(offset + 46) ? null : cursor.getLong(offset + 46));
entity.setPointsRedeem(cursor.isNull(offset + 47) ? null : cursor.getDouble(offset + 47));
entity.setKtPrintMainItem(cursor.isNull(offset + 48) ? null : cursor.getLong(offset + 48));
entity.setKtShowPrice(cursor.isNull(offset + 49) ? null : cursor.getLong(offset + 49));
entity.setPrintTo(cursor.isNull(offset + 50) ? null : cursor.getLong(offset + 50));
entity.setToPax(cursor.isNull(offset + 51) ? null : cursor.getLong(offset + 51));
entity.setFoodType(cursor.isNull(offset + 52) ? null : cursor.getLong(offset + 52));
entity.setMajorMainId(cursor.isNull(offset + 53) ? null : cursor.getLong(offset + 53));
entity.setDeptId(cursor.isNull(offset + 54) ? null : cursor.getLong(offset + 54));
entity.setServiceCharge(cursor.isNull(offset + 55) ? null : (byte) cursor.getShort(offset + 55));
entity.setColorId(cursor.isNull(offset + 56) ? null : cursor.getLong(offset + 56));
entity.setConditions(cursor.isNull(offset + 57) ? null : cursor.getLong(offset + 57));
entity.setIsRt(cursor.isNull(offset + 58) ? null : cursor.getLong(offset + 58));
entity.setDeletes(cursor.isNull(offset + 59) ? null : cursor.getLong(offset + 59));
entity.setIsTimingFood(cursor.isNull(offset + 60) ? null : cursor.getLong(offset + 60));
entity.setMinLongTime(cursor.isNull(offset + 61) ? null : cursor.getLong(offset + 61));
entity.setUnitTime(cursor.isNull(offset + 62) ? null : cursor.getLong(offset + 62));
entity.setUnitPrice(cursor.isNull(offset + 63) ? null : cursor.getDouble(offset + 63));
entity.setFreeLongTime(cursor.isNull(offset + 64) ? null : cursor.getLong(offset + 64));
entity.setFreePeriodBegin(cursor.isNull(offset + 65) ? null : new java.util.Date(cursor.getLong(offset + 65)));
entity.setIsStatistic(cursor.isNull(offset + 66) ? null : cursor.getLong(offset + 66));
}
@Override
protected final Long updateKeyAfterInsert(Food entity, long rowId) {
entity.setDbid(rowId);
entity.setId(rowId);
return rowId;
}
@Override
public Long getKey(Food entity) {
if(entity != null) {
return entity.getDbid();
return entity.getId();
} else {
return null;
}
......@@ -1046,7 +1037,7 @@ public class FoodDao extends AbstractDao<Food, Long> {
@Override
public boolean hasKey(Food entity) {
return entity.getDbid() != null;
return entity.getId() != null;
}
@Override
......@@ -1054,18 +1045,4 @@ public class FoodDao extends AbstractDao<Food, Long> {
return true;
}
/** Internal query to resolve the "foods" to-many relationship of Combo. */
public List<Food> _queryCombo_Foods(Long id) {
synchronized (this) {
if (combo_FoodsQuery == null) {
QueryBuilder<Food> queryBuilder = queryBuilder();
queryBuilder.where(Properties.Id.eq(null));
combo_FoodsQuery = queryBuilder.build();
}
}
Query<Food> query = combo_FoodsQuery.forCurrentThread();
query.setParameter(0, id);
return query.list();
}
}
package com.gingersoft.gsa.cloud.database.utils;
import android.content.Context;
import android.util.Log;
import com.gingersoft.gsa.cloud.database.DaoManager;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.ComboItem;
import com.gingersoft.gsa.cloud.database.greendao.ComboItemDao;
import com.gingersoft.gsa.cloud.database.greendao.FoodDao;
import org.greenrobot.greendao.query.QueryBuilder;
import java.util.ArrayList;
import java.util.List;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-01-02
* 修订历史:2020-01-02
* 描述:
*/
public class ComboItemDaoUtils {
private static final String TAG = ComboItemDaoUtils.class.getSimpleName();
private DaoManager mManager;
private Context mContext;
public ComboItemDaoUtils(Context context) {
mManager = DaoManager.getInstance();
mManager.init(context);
this.mContext = context;
}
/**
* 清除緩存
*/
public void detachAll(){
ComboItemDao comboItemDao = DaoManager.getInstance().getDaoSession().getComboItemDao();
comboItemDao.detachAll();
}
/**
* 完成Food记录的插入,如果表未创建,先创建Food表
*
* @param comboItem
* @return
*/
public boolean insertCombo(ComboItem comboItem) {
boolean flag = false;
flag = mManager.getDaoSession().getComboItemDao().insert(comboItem) == -1 ? false : true;
Log.i(TAG, "insert ComboItem :" + flag + "-->" + comboItem.toString());
return flag;
}
/**
* 插入多条数据,在子线程操作
*
* @param foodList
* @return
*/
public boolean insertMultCombo(final List<ComboItem> foodList) {
boolean flag = false;
try {
mManager.getDaoSession().runInTx(new Runnable() {
@Override
public void run() {
for (ComboItem Food : foodList) {
mManager.getDaoSession().insertOrReplace(Food);
}
}
});
flag = true;
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
/**
* 修改一条数据
*
* @param ComboItem
* @return
*/
public boolean updateCombo(ComboItem ComboItem) {
boolean flag = false;
try {
mManager.getDaoSession().update(ComboItem);
flag = true;
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
/**
* 删除单条记录
*
* @param food
* @return
*/
public boolean deleteCombo(ComboItem food) {
boolean flag = false;
try {
//按照id删除
mManager.getDaoSession().delete(food);
flag = true;
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
/**
* 删除所有记录
*
* @return
*/
public boolean deleteAll() {
boolean flag = false;
try {
//按照id删除
mManager.getDaoSession().deleteAll(ComboItem.class);
flag = true;
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
/**
* 查询所有记录
*
* @return
*/
public List<ComboItem> queryAllCombo() {
return mManager.getDaoSession().loadAll(ComboItem.class);
}
/**
* 根据主键id查询记录
*
* @param key
* @return
*/
public ComboItem queryComboById(long key) {
return mManager.getDaoSession().load(ComboItem.class, key);
}
/**
* 使用native sql进行查询操作
*/
public List<ComboItem> queryComboByNativeSql(String sql, String[] conditions) {
return mManager.getDaoSession().queryRaw(ComboItem.class, sql, conditions);
}
/**
* 使用queryBuilder进行查询食品
*
* @return
*/
public List<ComboItem> queryComboFoodsByQueryBuilder(long fid) {
// ComboItem comboItem = queryComboByQueryBuilder(fid);
// List<ComboItem> foodCombos = null;
// if (comboItem != null) {
// foodCombos = queryCombosByComIdQueryBuilder(comboItem.getComId());
// }
List<ComboItem> list = new ArrayList<>();
// FoodDaoUtils foodDao = new FoodDaoUtils(mContext);
// if (foodCombos != null) {
// for (int i = 0; i < foodCombos.size(); i++) {
// Food food = foodDao.queryFoodByFidQueryBuilder(foodCombos.get(i).getFid());
// if (food != null) {
// list.add(comboItem.addFoodInfo(food, foodCombos.get(i)));
// }
// }
// }
return list;
}
public List<ComboItem> queryCombosFoodsByQueryBuilder(long fid) {
QueryBuilder<ComboItem> queryBuilder = mManager.getDaoSession().queryBuilder(ComboItem.class);
// queryBuilder.where(queryBuilder.join()).orderAsc(FoodDao.Properties.SeqNo).list();
// List<ComboItem> ComboItem = queryCombosByQueryBuilder(fid);
// List<ComboItem> foodCombos = null;
// if (ComboItem != null && ComboItem.size() != 0) {
// foodCombos = queryCombosByComIdQueryBuilder(ComboItem.get(0).getComId());
// }
List<ComboItem> list = new ArrayList<>();
// FoodDaoUtils foodDao = new FoodDaoUtils(mContext);
// if (foodCombos != null) {
// for (int i = 0; i < foodCombos.size(); i++) {
// Food food = foodDao.queryFoodByFidQueryBuilder(foodCombos.get(i).getFid());
// if(food != null) {
// list.add(ComboItem.addFoodInfo(food, foodCombos.get(i)));
// }
// }
// }
return list;
}
/**
* 使用queryBuilder进行查询食品
*
* @return
*/
public ComboItem queryComboByQueryBuilder(long fid) {
QueryBuilder<ComboItem> queryBuilder = mManager.getDaoSession().queryBuilder(ComboItem.class);
return queryBuilder.where(ComboItemDao.Properties.Fid.eq(fid)).build().unique();
}
/**
* 使用queryBuilder进行查询食品
*
* @return
*/
public List<ComboItem> queryCombosByQueryBuilder(long fid) {
QueryBuilder<ComboItem> queryBuilder = mManager.getDaoSession().queryBuilder(ComboItem.class);
return queryBuilder.where(ComboItemDao.Properties.Fid.eq(fid)).build().list();
}
/**
* 使用queryBuilder进行查询食品
*
* @return
*/
public List<ComboItem> queryCombosByComIdQueryBuilder(int comId) {
QueryBuilder<ComboItem> queryBuilder = mManager.getDaoSession().queryBuilder(ComboItem.class);
return queryBuilder.where(ComboItemDao.Properties.ComId.eq(comId)).list();
}
}
......@@ -4,10 +4,9 @@ import android.content.Context;
import android.util.Log;
import com.gingersoft.gsa.cloud.database.DaoManager;
import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.FoodCombo;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.greendao.ComboDao;
import com.gingersoft.gsa.cloud.database.greendao.FoodDao;
import com.gingersoft.gsa.cloud.database.greendao.FoodComboDao;
import org.greenrobot.greendao.query.QueryBuilder;
......@@ -21,28 +20,37 @@ import java.util.List;
* 修订历史:2020-01-02
* 描述:
*/
public class ComboDaoUtils {
public class FoodComboDaoUtils {
private static final String TAG = ComboDaoUtils.class.getSimpleName();
private static final String TAG = FoodComboDaoUtils.class.getSimpleName();
private DaoManager mManager;
private Context mContext;
public ComboDaoUtils(Context context) {
public FoodComboDaoUtils(Context context) {
mManager = DaoManager.getInstance();
mManager.init(context);
this.mContext = context;
}
/**
* 清除緩存
*/
public void detachAll(){
FoodComboDao FoodComboDao = DaoManager.getInstance().getDaoSession().getFoodComboDao();
FoodComboDao.detachAll();
}
/**
* 完成Food记录的插入,如果表未创建,先创建Food表
*
* @param combo
* @param foodCombo
* @return
*/
public boolean insertCombo(Combo combo) {
public boolean insertCombo(FoodCombo foodCombo) {
boolean flag = false;
flag = mManager.getDaoSession().getComboDao().insert(combo) == -1 ? false : true;
Log.i(TAG, "insert Combo :" + flag + "-->" + combo.toString());
flag = mManager.getDaoSession().getFoodComboDao().insert(foodCombo) == -1 ? false : true;
Log.i(TAG, "insert FoodCombo :" + flag + "-->" + foodCombo.toString());
return flag;
}
......@@ -52,13 +60,13 @@ public class ComboDaoUtils {
* @param foodList
* @return
*/
public boolean insertMultCombo(final List<Combo> foodList) {
public boolean insertMultCombo(final List<FoodCombo> foodList) {
boolean flag = false;
try {
mManager.getDaoSession().runInTx(new Runnable() {
@Override
public void run() {
for (Combo Food : foodList) {
for (FoodCombo Food : foodList) {
mManager.getDaoSession().insertOrReplace(Food);
}
}
......@@ -73,13 +81,13 @@ public class ComboDaoUtils {
/**
* 修改一条数据
*
* @param combo
* @param foodCombo
* @return
*/
public boolean updateCombo(Combo combo) {
public boolean updateCombo(FoodCombo foodCombo) {
boolean flag = false;
try {
mManager.getDaoSession().update(combo);
mManager.getDaoSession().update(foodCombo);
flag = true;
} catch (Exception e) {
e.printStackTrace();
......@@ -93,7 +101,7 @@ public class ComboDaoUtils {
* @param food
* @return
*/
public boolean deleteCombo(Combo food) {
public boolean deleteCombo(FoodCombo food) {
boolean flag = false;
try {
//按照id删除
......@@ -114,7 +122,7 @@ public class ComboDaoUtils {
boolean flag = false;
try {
//按照id删除
mManager.getDaoSession().deleteAll(Combo.class);
mManager.getDaoSession().deleteAll(FoodCombo.class);
flag = true;
} catch (Exception e) {
e.printStackTrace();
......@@ -127,8 +135,8 @@ public class ComboDaoUtils {
*
* @return
*/
public List<Combo> queryAllCombo() {
return mManager.getDaoSession().loadAll(Combo.class);
public List<FoodCombo> queryAllCombo() {
return mManager.getDaoSession().loadAll(FoodCombo.class);
}
/**
......@@ -137,15 +145,15 @@ public class ComboDaoUtils {
* @param key
* @return
*/
public Combo queryComboById(long key) {
return mManager.getDaoSession().load(Combo.class, key);
public FoodCombo queryComboById(long key) {
return mManager.getDaoSession().load(FoodCombo.class, key);
}
/**
* 使用native sql进行查询操作
*/
public List<Combo> queryComboByNativeSql(String sql, String[] conditions) {
return mManager.getDaoSession().queryRaw(Combo.class, sql, conditions);
public List<FoodCombo> queryComboByNativeSql(String sql, String[] conditions) {
return mManager.getDaoSession().queryRaw(FoodCombo.class, sql, conditions);
}
/**
......@@ -153,38 +161,38 @@ public class ComboDaoUtils {
*
* @return
*/
public List<Combo> queryComboFoodsByQueryBuilder(long fid) {
Combo combo = queryComboByQueryBuilder(fid);
List<Combo> combos = null;
if (combo != null) {
combos = queryCombosByComIdQueryBuilder(combo.getComId());
public List<FoodCombo> queryComboFoodsByQueryBuilder(long fid) {
FoodCombo foodCombo = queryComboByQueryBuilder(fid);
List<FoodCombo> foodCombos = null;
if (foodCombo != null) {
foodCombos = queryCombosByComIdQueryBuilder(foodCombo.getComId());
}
List<Combo> list = new ArrayList<>();
List<FoodCombo> list = new ArrayList<>();
FoodDaoUtils foodDao = new FoodDaoUtils(mContext);
if (combos != null) {
for (int i = 0; i < combos.size(); i++) {
Food food = foodDao.queryFoodByFidQueryBuilder(combos.get(i).getFid());
if (foodCombos != null) {
for (int i = 0; i < foodCombos.size(); i++) {
Food food = foodDao.queryFoodByFidQueryBuilder(foodCombos.get(i).getFid());
if (food != null) {
list.add(Combo.addFoodInfo(food, combos.get(i)));
list.add(FoodCombo.addFoodInfo(food, foodCombos.get(i)));
}
}
}
return list;
}
public List<Combo> queryCombosFoodsByQueryBuilder(long fid) {
List<Combo> combo = queryCombosByQueryBuilder(fid);
List<Combo> combos = null;
if (combo != null && combo.size() != 0) {
combos = queryCombosByComIdQueryBuilder(combo.get(0).getComId());
public List<FoodCombo> queryCombosFoodsByQueryBuilder(long fid) {
List<FoodCombo> foodCombo = queryCombosByQueryBuilder(fid);
List<FoodCombo> foodCombos = null;
if (foodCombo != null && foodCombo.size() != 0) {
foodCombos = queryCombosByComIdQueryBuilder(foodCombo.get(0).getComId());
}
List<Combo> list = new ArrayList<>();
List<FoodCombo> list = new ArrayList<>();
FoodDaoUtils foodDao = new FoodDaoUtils(mContext);
if (combos != null) {
for (int i = 0; i < combos.size(); i++) {
Food food = foodDao.queryFoodByFidQueryBuilder(combos.get(i).getFid());
if (foodCombos != null) {
for (int i = 0; i < foodCombos.size(); i++) {
Food food = foodDao.queryFoodByFidQueryBuilder(foodCombos.get(i).getFid());
if(food != null) {
list.add(Combo.addFoodInfo(food, combos.get(i)));
list.add(FoodCombo.addFoodInfo(food, foodCombos.get(i)));
}
}
}
......@@ -196,9 +204,9 @@ public class ComboDaoUtils {
*
* @return
*/
public Combo queryComboByQueryBuilder(long fid) {
QueryBuilder<Combo> queryBuilder = mManager.getDaoSession().queryBuilder(Combo.class);
return queryBuilder.where(ComboDao.Properties.Fid.eq(fid)).build().unique();
public FoodCombo queryComboByQueryBuilder(long fid) {
QueryBuilder<FoodCombo> queryBuilder = mManager.getDaoSession().queryBuilder(FoodCombo.class);
return queryBuilder.where(FoodComboDao.Properties.Fid.eq(fid)).build().unique();
}
/**
......@@ -206,9 +214,9 @@ public class ComboDaoUtils {
*
* @return
*/
public List<Combo> queryCombosByQueryBuilder(long fid) {
QueryBuilder<Combo> queryBuilder = mManager.getDaoSession().queryBuilder(Combo.class);
return queryBuilder.where(ComboDao.Properties.Fid.eq(fid)).build().list();
public List<FoodCombo> queryCombosByQueryBuilder(long fid) {
QueryBuilder<FoodCombo> queryBuilder = mManager.getDaoSession().queryBuilder(FoodCombo.class);
return queryBuilder.where(FoodComboDao.Properties.Fid.eq(fid)).build().list();
}
/**
......@@ -216,8 +224,8 @@ public class ComboDaoUtils {
*
* @return
*/
public List<Combo> queryCombosByComIdQueryBuilder(int comId) {
QueryBuilder<Combo> queryBuilder = mManager.getDaoSession().queryBuilder(Combo.class);
return queryBuilder.where(ComboDao.Properties.ComId.eq(comId)).list();
public List<FoodCombo> queryCombosByComIdQueryBuilder(int comId) {
QueryBuilder<FoodCombo> queryBuilder = mManager.getDaoSession().queryBuilder(FoodCombo.class);
return queryBuilder.where(FoodComboDao.Properties.ComId.eq(comId)).list();
}
}
......@@ -5,10 +5,13 @@ import android.util.Log;
import com.gingersoft.gsa.cloud.database.DaoManager;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.FoodCombo;
import com.gingersoft.gsa.cloud.database.greendao.FoodComboDao;
import com.gingersoft.gsa.cloud.database.greendao.FoodDao;
import org.greenrobot.greendao.query.QueryBuilder;
import java.util.Date;
import java.util.List;
/**
......@@ -23,17 +26,27 @@ public class FoodDaoUtils {
private static final String TAG = FoodDaoUtils.class.getSimpleName();
private DaoManager mManager;
public FoodDaoUtils(Context context){
public FoodDaoUtils(Context context) {
mManager = DaoManager.getInstance();
mManager.init(context);
}
/**
* 清除緩存
*/
public void detachAll() {
FoodDao foodDao = DaoManager.getInstance().getDaoSession().getFoodDao();
foodDao.detachAll();
}
/**
* 完成Food记录的插入,如果表未创建,先创建Food表
*
* @param Food
* @return
*/
public boolean insertFood(Food Food){
public boolean insertFood(Food Food) {
boolean flag = false;
flag = mManager.getDaoSession().getFoodDao().insert(Food) == -1 ? false : true;
Log.i(TAG, "insert Food :" + flag + "-->" + Food.toString());
......@@ -42,6 +55,7 @@ public class FoodDaoUtils {
/**
* 插入多条数据,在子线程操作
*
* @param foodList
* @return
*/
......@@ -65,15 +79,16 @@ public class FoodDaoUtils {
/**
* 修改一条数据
*
* @param food
* @return
*/
public boolean updateFood(Food food){
public boolean updateFood(Food food) {
boolean flag = false;
try {
mManager.getDaoSession().update(food);
flag = true;
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
return flag;
......@@ -81,16 +96,17 @@ public class FoodDaoUtils {
/**
* 删除单条记录
*
* @param food
* @return
*/
public boolean deleteFood(Food food){
public boolean deleteFood(Food food) {
boolean flag = false;
try {
//按照id删除
mManager.getDaoSession().delete(food);
flag = true;
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
return flag;
......@@ -98,15 +114,16 @@ public class FoodDaoUtils {
/**
* 删除所有记录
*
* @return
*/
public boolean deleteAll(){
public boolean deleteAll() {
boolean flag = false;
try {
//按照id删除
mManager.getDaoSession().deleteAll(Food.class);
flag = true;
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
return flag;
......@@ -114,18 +131,20 @@ public class FoodDaoUtils {
/**
* 查询所有记录
*
* @return
*/
public List<Food> queryAllFood(){
public List<Food> queryAllFood() {
return mManager.getDaoSession().loadAll(Food.class);
}
/**
* 根据主键id查询记录
*
* @param key
* @return
*/
public Food queryFoodById(long key){
public Food queryFoodById(long key) {
return mManager.getDaoSession().load(Food.class, key);
}
......@@ -133,44 +152,72 @@ public class FoodDaoUtils {
/**
* 使用native sql进行查询操作
*/
public List<Food> queryFoodByNativeSql(String sql, String[] conditions){
public List<Food> queryFoodByNativeSql(String sql, String[] conditions) {
return mManager.getDaoSession().queryRaw(Food.class, sql, conditions);
}
/**
* 使用queryBuilder进行查询食品組
*
* @return
*/
public List<Food> queryFoodGroupByQueryBuilder(){
public List<Food> queryFoodGroupByQueryBuilder() {
QueryBuilder<Food> queryBuilder = mManager.getDaoSession().queryBuilder(Food.class);
return queryBuilder.where(FoodDao.Properties.ParentId.le(0)).list();
long currentTime = System.currentTimeMillis();
return queryBuilder.where(queryBuilder.and(
FoodDao.Properties.ParentId.eq(0),
FoodDao.Properties.StartDate.le(currentTime),
FoodDao.Properties.EndDate.ge(currentTime))).orderAsc(FoodDao.Properties.SeqNo).list();
}
/**
* 使用queryBuilder进行查询食品
*
* @return
*/
public List<Food> queryFoodByQueryBuilder(long parentId){
public List<Food> queryFoodByQueryBuilder(long parentId) {
QueryBuilder<Food> queryBuilder = mManager.getDaoSession().queryBuilder(Food.class);
return queryBuilder.where(FoodDao.Properties.ParentId.eq(parentId)).list();
long currentTime = System.currentTimeMillis();
return queryBuilder.where(queryBuilder.and(
FoodDao.Properties.ParentId.eq(parentId),
FoodDao.Properties.Invisible.notEq(1),
FoodDao.Properties.StartDate.le(currentTime),
FoodDao.Properties.EndDate.ge(currentTime))).orderAsc(FoodDao.Properties.SeqNo).list();
}
/**
* 使用queryBuilder进行查询食品
*
* @return
*/
public Food queryFoodByFidQueryBuilder(long fid){
public Food queryFoodByFidQueryBuilder(long fid) {
QueryBuilder<Food> queryBuilder = mManager.getDaoSession().queryBuilder(Food.class);
return queryBuilder.where(FoodDao.Properties.Id.eq(fid)).build().unique();
}
/**
* 使用queryBuilder进行查询食品
*
* @return
*/
public Food queryFoodByQueryBuilder(String plu){
public Food queryFoodByQueryBuilder(String plu) {
QueryBuilder<Food> queryBuilder = mManager.getDaoSession().queryBuilder(Food.class);
return queryBuilder.where(FoodDao.Properties.Plu.eq(plu)).build().unique();
}
public Food queryFoodByFidQueryBuilder2(long fid) {
QueryBuilder<Food> queryBuilder = mManager.getDaoSession().queryBuilder(Food.class);
queryBuilder.join(FoodCombo.class, FoodComboDao.Properties.ComId).where(FoodComboDao.Properties.Fid.eq(fid));
String sql;
sql = "SELECT c.*,f.FOOD_NAME,f.FOOD_NAME1,f.FOOD_NAME2 FROM COMBO_ITEM c join FOOD f on c.FID=f._id join FOOD_COMBO r on r.COMID=c.COMID ";
if (fid > 0) {
sql = sql + " where r.FID='" + fid + "'";
}
List<Food> foodList = queryFoodByNativeSql(sql, null);
return queryBuilder.where(FoodDao.Properties.Id.eq(fid)).build().unique();
}
}
......@@ -4,13 +4,9 @@ import android.content.Context;
import android.util.Log;
import com.gingersoft.gsa.cloud.database.DaoManager;
import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.FoodModifier;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.Modifier;
import com.gingersoft.gsa.cloud.database.greendao.ComboDao;
import com.gingersoft.gsa.cloud.database.greendao.FoodModifierDao;
import com.gingersoft.gsa.cloud.database.greendao.ModifierDao;
import org.greenrobot.greendao.query.QueryBuilder;
......
......@@ -4,16 +4,11 @@ import android.content.Context;
import android.util.Log;
import com.gingersoft.gsa.cloud.database.DaoManager;
import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.Modifier;
import com.gingersoft.gsa.cloud.database.greendao.ComboDao;
import com.gingersoft.gsa.cloud.database.greendao.FoodModifierDao;
import com.gingersoft.gsa.cloud.database.greendao.ModifierDao;
import org.greenrobot.greendao.query.QueryBuilder;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -36,6 +31,14 @@ public class ModifierDaoUtils {
}
/**
* 清除緩存
*/
public void detachAll(){
ModifierDao modifierDao = DaoManager.getInstance().getDaoSession().getModifierDao();
modifierDao.detachAll();
}
/**
* 完成Food记录的插入,如果表未创建,先创建Food表
* @param modifier
* @return
......
package com.gingersoft.gsa.cloud.ui.recylcler.Indicator;
import android.util.Log;
/**
* 作用:Pager配置
* 作者:GcsSloop
* 摘要:主要用于Log的显示与关闭
*/
public class PagerConfig {
private static final String TAG = "PagerGrid";
private static boolean sShowLog = false;
private static int sFlingThreshold = 1000; // Fling 阀值,滚动速度超过该阀值才会触发滚动
private static float sMillisecondsPreInch = 60f; // 每一个英寸滚动需要的微秒数,数值越大,速度越慢
/**
* 判断是否输出日志
*
* @return true 输出,false 不输出
*/
public static boolean isShowLog() {
return sShowLog;
}
/**
* 设置是否输出日志
*
* @param showLog 是否输出
*/
public static void setShowLog(boolean showLog) {
sShowLog = showLog;
}
/**
* 获取当前滚动速度阀值
*
* @return 当前滚动速度阀值
*/
public static int getFlingThreshold() {
return sFlingThreshold;
}
/**
* 设置当前滚动速度阀值
*
* @param flingThreshold 滚动速度阀值
*/
public static void setFlingThreshold(int flingThreshold) {
sFlingThreshold = flingThreshold;
}
/**
* 获取滚动速度 英寸/微秒
*
* @return 英寸滚动速度
*/
public static float getMillisecondsPreInch() {
return sMillisecondsPreInch;
}
/**
* 设置像素滚动速度 英寸/微秒
*
* @param millisecondsPreInch 英寸滚动速度
*/
public static void setMillisecondsPreInch(float millisecondsPreInch) {
sMillisecondsPreInch = millisecondsPreInch;
}
//--- 日志 -------------------------------------------------------------------------------------
public static void Logi(String msg) {
if (!PagerConfig.isShowLog()) return;
Log.i(TAG, msg);
}
public static void Loge(String msg) {
if (!PagerConfig.isShowLog()) return;
Log.e(TAG, msg);
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.ui.recylcler.Indicator;
import android.annotation.SuppressLint;
import android.graphics.PointF;
import android.graphics.Rect;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import com.gcssloop.widget.PagerGridSmoothScroller;
import androidx.annotation.IntDef;
import androidx.annotation.IntRange;
import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView;
import static android.view.View.MeasureSpec.EXACTLY;
import static android.widget.NumberPicker.OnScrollListener.SCROLL_STATE_IDLE;
import static com.gingersoft.gsa.cloud.ui.recylcler.Indicator.PagerConfig.Loge;
import static com.gingersoft.gsa.cloud.ui.recylcler.Indicator.PagerConfig.Logi;
/**
* 作用:分页的网格布局管理器
* 作者:GcsSloop
* 摘要:
* 1. 网格布局
* 2. 支持水平分页和垂直分页
* 3. 杜绝高内存占用
*/
public class PagerGridLayoutManager extends RecyclerView.LayoutManager
implements RecyclerView.SmoothScroller.ScrollVectorProvider {
private static final String TAG = PagerGridLayoutManager.class.getSimpleName();
public static final int VERTICAL = 0; // 垂直滚动
public static final int HORIZONTAL = 1; // 水平滚动
@IntDef({VERTICAL, HORIZONTAL})
public @interface OrientationType {} // 滚动类型
@OrientationType
private int mOrientation; // 默认水平滚动
private int mOffsetX = 0; // 水平滚动距离(偏移量)
private int mOffsetY = 0; // 垂直滚动距离(偏移量)
private int mRows; // 行数
private int mColumns; // 列数
private int mOnePageSize; // 一页的条目数量
private SparseArray<Rect> mItemFrames; // 条目的显示区域
private int mItemWidth = 0; // 条目宽度
private int mItemHeight = 0; // 条目高度
private int mWidthUsed = 0; // 已经使用空间,用于测量View
private int mHeightUsed = 0; // 已经使用空间,用于测量View
private int mMaxScrollX; // 最大允许滑动的宽度
private int mMaxScrollY; // 最大允许滑动的高度
private int mScrollState = SCROLL_STATE_IDLE; // 滚动状态
private boolean mAllowContinuousScroll = true; // 是否允许连续滚动
private RecyclerView mRecyclerView;
/**
* 构造函数
*
* @param rows 行数
* @param columns 列数
* @param orientation 方向
*/
public PagerGridLayoutManager(@IntRange(from = 1, to = 100) int rows,
@IntRange(from = 1, to = 100) int columns,
@OrientationType int orientation) {
mItemFrames = new SparseArray<>();
mOrientation = orientation;
mRows = rows;
mColumns = columns;
mOnePageSize = mRows * mColumns;
}
@Override
public void onAttachedToWindow(RecyclerView view) {
super.onAttachedToWindow(view);
mRecyclerView = view;
}
//--- 处理布局 ----------------------------------------------------------------------------------
/**
* 布局子View
*
* @param recycler Recycler
* @param state State
*/
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
Logi("Item onLayoutChildren");
Logi("Item onLayoutChildren isPreLayout = " + state.isPreLayout());
Logi("Item onLayoutChildren isMeasuring = " + state.isMeasuring());
Loge("Item onLayoutChildren state = " + state);
// 如果是 preLayout 则不重新布局
if (state.isPreLayout() || !state.didStructureChange()) {
return;
}
if (getItemCount() == 0) {
removeAndRecycleAllViews(recycler);
// 页面变化回调
setPageCount(0);
setPageIndex(0, false);
return;
} else {
setPageCount(getTotalPageCount());
setPageIndex(getPageIndexByOffset(), false);
}
// 计算页面数量
int mPageCount = getItemCount() / mOnePageSize;
if (getItemCount() % mOnePageSize != 0) {
mPageCount++;
}
// 计算可以滚动的最大数值,并对滚动距离进行修正
if (canScrollHorizontally()) {
mMaxScrollX = (mPageCount - 1) * getUsableWidth();
mMaxScrollY = 0;
if (mOffsetX > mMaxScrollX) {
mOffsetX = mMaxScrollX;
}
} else {
mMaxScrollX = 0;
mMaxScrollY = (mPageCount - 1) * getUsableHeight();
if (mOffsetY > mMaxScrollY) {
mOffsetY = mMaxScrollY;
}
}
// 接口回调
// setPageCount(mPageCount);
// setPageIndex(mCurrentPageIndex, false);
Logi("count = " + getItemCount());
if (mItemWidth <= 0) {
mItemWidth = getUsableWidth() / mColumns;
}
if (mItemHeight <= 0) {
mItemHeight = getUsableHeight() / mRows;
}
mWidthUsed = getUsableWidth() - mItemWidth;
mHeightUsed = getUsableHeight() - mItemHeight;
// 预存储两页的View显示区域
for (int i = 0; i < mOnePageSize * 2; i++) {
getItemFrameByPosition(i);
}
if (mOffsetX == 0 && mOffsetY == 0) {
// 预存储View
for (int i = 0; i < mOnePageSize; i++) {
if (i >= getItemCount()) break; // 防止数据过少时导致数组越界异常
View view = recycler.getViewForPosition(i);
addView(view);
measureChildWithMargins(view, mWidthUsed, mHeightUsed);
}
}
// 回收和填充布局
recycleAndFillItems(recycler, state, true);
}
/**
* 布局结束
*
* @param state State
*/
@Override
public void onLayoutCompleted(RecyclerView.State state) {
super.onLayoutCompleted(state);
if (state.isPreLayout()) return;
// 页面状态回调
setPageCount(getTotalPageCount());
setPageIndex(getPageIndexByOffset(), false);
}
/**
* 回收和填充布局
*
* @param recycler Recycler
* @param state State
* @param isStart 是否从头开始,用于控制View遍历方向,true 为从头到尾,false 为从尾到头
*/
@SuppressLint("CheckResult")
private void recycleAndFillItems(RecyclerView.Recycler recycler, RecyclerView.State state,
boolean isStart) {
if (state.isPreLayout()) {
return;
}
Logi("mOffsetX = " + mOffsetX);
Logi("mOffsetY = " + mOffsetY);
// 计算显示区域区前后多存储一列或则一行
Rect displayRect = new Rect(mOffsetX - mItemWidth, mOffsetY - mItemHeight,
getUsableWidth() + mOffsetX + mItemWidth, getUsableHeight() + mOffsetY + mItemHeight);
// 对显显示区域进行修正(计算当前显示区域和最大显示区域对交集)
displayRect.intersect(0, 0, mMaxScrollX + getUsableWidth(), mMaxScrollY + getUsableHeight());
Loge("displayRect = " + displayRect.toString());
int startPos = 0; // 获取第一个条目的Pos
int pageIndex = getPageIndexByOffset();
startPos = pageIndex * mOnePageSize;
Logi("startPos = " + startPos);
startPos = startPos - mOnePageSize * 2;
if (startPos < 0) {
startPos = 0;
}
int stopPos = startPos + mOnePageSize * 4;
if (stopPos > getItemCount()) {
stopPos = getItemCount();
}
Loge("startPos = " + startPos);
Loge("stopPos = " + stopPos);
detachAndScrapAttachedViews(recycler); // 移除所有View
if (isStart) {
for (int i = startPos; i < stopPos; i++) {
addOrRemove(recycler, displayRect, i);
}
} else {
for (int i = stopPos - 1; i >= startPos; i--) {
addOrRemove(recycler, displayRect, i);
}
}
Loge("child count = " + getChildCount());
}
/**
* 添加或者移除条目
*
* @param recycler RecyclerView
* @param displayRect 显示区域
* @param i 条目下标
*/
private void addOrRemove(RecyclerView.Recycler recycler, Rect displayRect, int i) {
View child = recycler.getViewForPosition(i);
Rect rect = getItemFrameByPosition(i);
if (!Rect.intersects(displayRect, rect)) {
removeAndRecycleView(child, recycler); // 回收入暂存区
} else {
addView(child);
measureChildWithMargins(child, mWidthUsed, mHeightUsed);
RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) child.getLayoutParams();
layoutDecorated(child,
rect.left - mOffsetX + lp.leftMargin + getPaddingLeft(),
rect.top - mOffsetY + lp.topMargin + getPaddingTop(),
rect.right - mOffsetX - lp.rightMargin + getPaddingLeft(),
rect.bottom - mOffsetY - lp.bottomMargin + getPaddingTop());
}
}
//--- 处理滚动 ----------------------------------------------------------------------------------
/**
* 水平滚动
*
* @param dx 滚动距离
* @param recycler 回收器
* @param state 滚动状态
* @return 实际滚动距离
*/
@Override
public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State
state) {
int newX = mOffsetX + dx;
int result = dx;
if (newX > mMaxScrollX) {
result = mMaxScrollX - mOffsetX;
} else if (newX < 0) {
result = 0 - mOffsetX;
}
mOffsetX += result;
setPageIndex(getPageIndexByOffset(), true);
offsetChildrenHorizontal(-result);
if (result > 0) {
recycleAndFillItems(recycler, state, true);
} else {
recycleAndFillItems(recycler, state, false);
}
return result;
}
/**
* 垂直滚动
*
* @param dy 滚动距离
* @param recycler 回收器
* @param state 滚动状态
* @return 实际滚动距离
*/
@Override
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State
state) {
int newY = mOffsetY + dy;
int result = dy;
if (newY > mMaxScrollY) {
result = mMaxScrollY - mOffsetY;
} else if (newY < 0) {
result = 0 - mOffsetY;
}
mOffsetY += result;
setPageIndex(getPageIndexByOffset(), true);
offsetChildrenVertical(-result);
if (result > 0) {
recycleAndFillItems(recycler, state, true);
} else {
recycleAndFillItems(recycler, state, false);
}
return result;
}
/**
* 监听滚动状态,滚动结束后通知当前选中的页面
*
* @param state 滚动状态
*/
@Override
public void onScrollStateChanged(int state) {
Logi("onScrollStateChanged = " + state);
mScrollState = state;
super.onScrollStateChanged(state);
if (state == SCROLL_STATE_IDLE) {
setPageIndex(getPageIndexByOffset(), false);
}
}
//--- 私有方法 ----------------------------------------------------------------------------------
/**
* 获取条目显示区域
*
* @param pos 位置下标
* @return 显示区域
*/
private Rect getItemFrameByPosition(int pos) {
Rect rect = mItemFrames.get(pos);
if (null == rect) {
rect = new Rect();
// 计算显示区域 Rect
// 1. 获取当前View所在页数
int page = pos / mOnePageSize;
// 2. 计算当前页数左上角的总偏移量
int offsetX = 0;
int offsetY = 0;
if (canScrollHorizontally()) {
offsetX += getUsableWidth() * page;
} else {
offsetY += getUsableHeight() * page;
}
// 3. 根据在当前页面中的位置确定具体偏移量
int pagePos = pos % mOnePageSize; // 在当前页面中是第几个
int row = pagePos / mColumns; // 获取所在行
int col = pagePos - (row * mColumns); // 获取所在列
offsetX += col * mItemWidth;
offsetY += row * mItemHeight;
// 状态输出,用于调试
Logi("pagePos = " + pagePos);
Logi("行 = " + row);
Logi("列 = " + col);
Logi("offsetX = " + offsetX);
Logi("offsetY = " + offsetY);
rect.left = offsetX;
rect.top = offsetY;
rect.right = offsetX + mItemWidth;
rect.bottom = offsetY + mItemHeight;
// 存储
mItemFrames.put(pos, rect);
}
return rect;
}
/**
* 获取可用的宽度
*
* @return 宽度 - padding
*/
private int getUsableWidth() {
return getWidth() - getPaddingLeft() - getPaddingRight();
}
/**
* 获取可用的高度
*
* @return 高度 - padding
*/
private int getUsableHeight() {
return getHeight() - getPaddingTop() - getPaddingBottom();
}
//--- 页面相关(私有) -----------------------------------------------------------------------------
/**
* 获取总页数
*/
private int getTotalPageCount() {
if (getItemCount() <= 0) return 0;
int totalCount = getItemCount() / mOnePageSize;
if (getItemCount() % mOnePageSize != 0) {
totalCount++;
}
return totalCount;
}
/**
* 根据pos,获取该View所在的页面
*
* @param pos position
* @return 页面的页码
*/
private int getPageIndexByPos(int pos) {
return pos / mOnePageSize;
}
/**
* 根据 offset 获取页面Index
*
* @return 页面 Index
*/
private int getPageIndexByOffset() {
int pageIndex;
if (canScrollVertically()) {
int pageHeight = getUsableHeight();
if (mOffsetY <= 0 || pageHeight <= 0) {
pageIndex = 0;
} else {
pageIndex = mOffsetY / pageHeight;
if (mOffsetY % pageHeight > pageHeight / 2) {
pageIndex++;
}
}
} else {
int pageWidth = getUsableWidth();
if (mOffsetX <= 0 || pageWidth <= 0) {
pageIndex = 0;
} else {
pageIndex = mOffsetX / pageWidth;
if (mOffsetX % pageWidth > pageWidth / 2) {
pageIndex++;
}
}
}
Logi("getPageIndexByOffset pageIndex = " + pageIndex);
return pageIndex;
}
//--- 公开方法 ----------------------------------------------------------------------------------
/**
* 创建默认布局参数
*
* @return 默认布局参数
*/
@Override
public RecyclerView.LayoutParams generateDefaultLayoutParams() {
return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
}
/**
* 处理测量逻辑
*
* @param recycler RecyclerView
* @param state 状态
* @param widthMeasureSpec 宽度属性
* @param heightMeasureSpec 高估属性
*/
@Override
public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state, int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(recycler, state, widthMeasureSpec, heightMeasureSpec);
int widthsize = View.MeasureSpec.getSize(widthMeasureSpec); //取出宽度的确切数值
int widthmode = View.MeasureSpec.getMode(widthMeasureSpec); //取出宽度的测量模式
int heightsize = View.MeasureSpec.getSize(heightMeasureSpec); //取出高度的确切数值
int heightmode = View.MeasureSpec.getMode(heightMeasureSpec); //取出高度的测量模式
// 将 wrap_content 转换为 match_parent
if (widthmode != EXACTLY && widthsize > 0) {
widthmode = EXACTLY;
}
if (heightmode != EXACTLY && heightsize > 0) {
heightmode = EXACTLY;
}
setMeasuredDimension(View.MeasureSpec.makeMeasureSpec(widthsize, widthmode),
View.MeasureSpec.makeMeasureSpec(heightsize, heightmode));
}
/**
* 是否可以水平滚动
*
* @return true 是,false 不是。
*/
@Override
public boolean canScrollHorizontally() {
return mOrientation == HORIZONTAL;
}
/**
* 是否可以垂直滚动
*
* @return true 是,false 不是。
*/
@Override
public boolean canScrollVertically() {
return mOrientation == VERTICAL;
}
/**
* 找到下一页第一个条目的位置
*
* @return 第一个搞条目的位置
*/
int findNextPageFirstPos() {
int page = mLastPageIndex;
page++;
if (page >= getTotalPageCount()) {
page = getTotalPageCount() - 1;
}
Loge("computeScrollVectorForPosition next = " + page);
return page * mOnePageSize;
}
/**
* 找到上一页的第一个条目的位置
*
* @return 第一个条目的位置
*/
int findPrePageFirstPos() {
// 在获取时由于前一页的View预加载出来了,所以获取到的直接就是前一页
int page = mLastPageIndex;
page--;
Loge("computeScrollVectorForPosition pre = " + page);
if (page < 0) {
page = 0;
}
Loge("computeScrollVectorForPosition pre = " + page);
return page * mOnePageSize;
}
/**
* 获取当前 X 轴偏移量
*
* @return X 轴偏移量
*/
public int getOffsetX() {
return mOffsetX;
}
/**
* 获取当前 Y 轴偏移量
*
* @return Y 轴偏移量
*/
public int getOffsetY() {
return mOffsetY;
}
//--- 页面对齐 ----------------------------------------------------------------------------------
/**
* 计算到目标位置需要滚动的距离{@link RecyclerView.SmoothScroller.ScrollVectorProvider}
*
* @param targetPosition 目标控件
* @return 需要滚动的距离
*/
@Override
public PointF computeScrollVectorForPosition(int targetPosition) {
PointF vector = new PointF();
int[] pos = getSnapOffset(targetPosition);
vector.x = pos[0];
vector.y = pos[1];
return vector;
}
/**
* 获取偏移量(为PagerGridSnapHelper准备)
* 用于分页滚动,确定需要滚动的距离。
* {@link PagerGridSnapHelper}
*
* @param targetPosition 条目下标
*/
int[] getSnapOffset(int targetPosition) {
int[] offset = new int[2];
int[] pos = getPageLeftTopByPosition(targetPosition);
offset[0] = pos[0] - mOffsetX;
offset[1] = pos[1] - mOffsetY;
return offset;
}
/**
* 根据条目下标获取该条目所在页面的左上角位置
*
* @param pos 条目下标
* @return 左上角位置
*/
private int[] getPageLeftTopByPosition(int pos) {
int[] leftTop = new int[2];
int page = getPageIndexByPos(pos);
if (canScrollHorizontally()) {
leftTop[0] = page * getUsableWidth();
leftTop[1] = 0;
} else {
leftTop[0] = 0;
leftTop[1] = page * getUsableHeight();
}
return leftTop;
}
/**
* 获取需要对齐的View
*
* @return 需要对齐的View
*/
public View findSnapView() {
if (null != getFocusedChild()) {
return getFocusedChild();
}
if (getChildCount() <= 0) {
return null;
}
int targetPos = getPageIndexByOffset() * mOnePageSize; // 目标Pos
for (int i = 0; i < getChildCount(); i++) {
int childPos = getPosition(getChildAt(i));
if (childPos == targetPos) {
return getChildAt(i);
}
}
return getChildAt(0);
}
//--- 处理页码变化 -------------------------------------------------------------------------------
private boolean mChangeSelectInScrolling = true; // 是否在滚动过程中对页面变化回调
private int mLastPageCount = -1; // 上次页面总数
private int mLastPageIndex = -1; // 上次页面下标
/**
* 设置页面总数
*
* @param pageCount 页面总数
*/
private void setPageCount(int pageCount) {
if (pageCount >= 0) {
if (mPageListener != null && pageCount != mLastPageCount) {
mPageListener.onPageSizeChanged(pageCount);
}
mLastPageCount = pageCount;
}
}
/**
* 设置当前选中页面
*
* @param pageIndex 页面下标
* @param isScrolling 是否处于滚动状态
*/
private void setPageIndex(int pageIndex, boolean isScrolling) {
Loge("setPageIndex = " + pageIndex + ":" + isScrolling);
if (pageIndex == mLastPageIndex) return;
// 如果允许连续滚动,那么在滚动过程中就会更新页码记录
if (isAllowContinuousScroll()) {
mLastPageIndex = pageIndex;
} else {
// 否则,只有等滚动停下时才会更新页码记录
if (!isScrolling) {
mLastPageIndex = pageIndex;
}
}
if (isScrolling && !mChangeSelectInScrolling) return;
if (pageIndex >= 0) {
if (null != mPageListener) {
mPageListener.onPageSelect(pageIndex);
}
}
}
/**
* 设置是否在滚动状态更新选中页码
*
* @param changeSelectInScrolling true:更新、false:不更新
*/
public void setChangeSelectInScrolling(boolean changeSelectInScrolling) {
mChangeSelectInScrolling = changeSelectInScrolling;
}
/**
* 设置滚动方向
*
* @param orientation 滚动方向
* @return 最终的滚动方向
*/
@OrientationType
public int setOrientationType(@OrientationType int orientation) {
if (mOrientation == orientation || mScrollState != SCROLL_STATE_IDLE) return mOrientation;
mOrientation = orientation;
mItemFrames.clear();
int x = mOffsetX;
int y = mOffsetY;
mOffsetX = y / getUsableHeight() * getUsableWidth();
mOffsetY = x / getUsableWidth() * getUsableHeight();
int mx = mMaxScrollX;
int my = mMaxScrollY;
mMaxScrollX = my / getUsableHeight() * getUsableWidth();
mMaxScrollY = mx / getUsableWidth() * getUsableHeight();
return mOrientation;
}
//--- 滚动到指定位置 -----------------------------------------------------------------------------
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
int targetPageIndex = getPageIndexByPos(position);
smoothScrollToPage(targetPageIndex);
}
/**
* 平滑滚动到上一页
*/
public void smoothPrePage() {
smoothScrollToPage(getPageIndexByOffset() - 1);
}
/**
* 平滑滚动到下一页
*/
public void smoothNextPage() {
smoothScrollToPage(getPageIndexByOffset() + 1);
}
/**
* 平滑滚动到指定页面
*
* @param pageIndex 页面下标
*/
public void smoothScrollToPage(int pageIndex) {
if (pageIndex < 0 || pageIndex >= mLastPageCount) {
Log.e(TAG, "pageIndex is outOfIndex, must in [0, " + mLastPageCount + ").");
return;
}
if (null == mRecyclerView) {
Log.e(TAG, "RecyclerView Not Found!");
return;
}
// 如果滚动到页面之间距离过大,先直接滚动到目标页面到临近页面,在使用 smoothScroll 最终滚动到目标
// 否则在滚动距离很大时,会导致滚动耗费的时间非常长
int currentPageIndex = getPageIndexByOffset();
if (Math.abs(pageIndex - currentPageIndex) > 3) {
if (pageIndex > currentPageIndex) {
scrollToPage(pageIndex - 3);
} else if (pageIndex < currentPageIndex) {
scrollToPage(pageIndex + 3);
}
}
// 具体执行滚动
LinearSmoothScroller smoothScroller = new PagerGridSmoothScroller(mRecyclerView);
int position = pageIndex * mOnePageSize;
smoothScroller.setTargetPosition(position);
startSmoothScroll(smoothScroller);
}
//=== 直接滚动 ===
@Override
public void scrollToPosition(int position) {
int pageIndex = getPageIndexByPos(position);
scrollToPage(pageIndex);
}
/**
* 上一页
*/
public void prePage() {
scrollToPage(getPageIndexByOffset() - 1);
}
/**
* 下一页
*/
public void nextPage() {
scrollToPage(getPageIndexByOffset() + 1);
}
/**
* 滚动到指定页面
*
* @param pageIndex 页面下标
*/
public void scrollToPage(int pageIndex) {
if (pageIndex < 0 || pageIndex >= mLastPageCount) {
Log.e(TAG, "pageIndex = " + pageIndex + " is out of bounds, mast in [0, " + mLastPageCount + ")");
return;
}
if (null == mRecyclerView) {
Log.e(TAG, "RecyclerView Not Found!");
return;
}
int mTargetOffsetXBy = 0;
int mTargetOffsetYBy = 0;
if (canScrollVertically()) {
mTargetOffsetXBy = 0;
mTargetOffsetYBy = pageIndex * getUsableHeight() - mOffsetY;
} else {
mTargetOffsetXBy = pageIndex * getUsableWidth() - mOffsetX;
mTargetOffsetYBy = 0;
}
Loge("mTargetOffsetXBy = " + mTargetOffsetXBy);
Loge("mTargetOffsetYBy = " + mTargetOffsetYBy);
mRecyclerView.scrollBy(mTargetOffsetXBy, mTargetOffsetYBy);
setPageIndex(pageIndex, false);
}
/**
* 是否允许连续滚动,默认为允许
*
* @return true 允许, false 不允许
*/
public boolean isAllowContinuousScroll() {
return mAllowContinuousScroll;
}
/**
* 设置是否允许连续滚动
*
* @param allowContinuousScroll true 允许,false 不允许
*/
public void setAllowContinuousScroll(boolean allowContinuousScroll) {
mAllowContinuousScroll = allowContinuousScroll;
}
//--- 对外接口 ----------------------------------------------------------------------------------
private PageListener mPageListener = null;
public void setPageListener(PageListener pageListener) {
mPageListener = pageListener;
}
public interface PageListener {
/**
* 页面总数量变化
*
* @param pageSize 页面总数
*/
void onPageSizeChanged(int pageSize);
/**
* 页面被选中
*
* @param pageIndex 选中的页面
*/
void onPageSelect(int pageIndex);
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.ui.recylcler.Indicator;
import android.util.DisplayMetrics;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView;
import static com.gingersoft.gsa.cloud.ui.recylcler.Indicator.PagerConfig.Logi;
/**
* 作用:用于处理平滑滚动
* 作者:GcsSloop
* 摘要:用于用户手指抬起后页面对齐或者 Fling 事件。
*/
public class PagerGridSmoothScroller extends LinearSmoothScroller {
private RecyclerView mRecyclerView;
public PagerGridSmoothScroller(@NonNull RecyclerView recyclerView) {
super(recyclerView.getContext());
mRecyclerView = recyclerView;
}
@Override
protected void onTargetFound(View targetView, RecyclerView.State state, Action action) {
RecyclerView.LayoutManager manager = mRecyclerView.getLayoutManager();
if (null == manager) return;
if (manager instanceof PagerGridLayoutManager) {
PagerGridLayoutManager layoutManager = (PagerGridLayoutManager) manager;
int pos = mRecyclerView.getChildAdapterPosition(targetView);
int[] snapDistances = layoutManager.getSnapOffset(pos);
final int dx = snapDistances[0];
final int dy = snapDistances[1];
Logi("dx = " + dx);
Logi("dy = " + dy);
final int time = calculateTimeForScrolling(Math.max(Math.abs(dx), Math.abs(dy)));
if (time > 0) {
action.update(dx, dy, time, mDecelerateInterpolator);
}
}
}
@Override
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return PagerConfig.getMillisecondsPreInch() / displayMetrics.densityDpi;
}
}
package com.gingersoft.gsa.cloud.ui.recylcler.Indicator;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SnapHelper;
import static com.gingersoft.gsa.cloud.ui.recylcler.Indicator.PagerConfig.Loge;
/**
* 作用:分页居中工具
* 作者:GcsSloop
* 摘要:每次只滚动一个页面
*/
public class PagerGridSnapHelper extends SnapHelper {
private RecyclerView mRecyclerView; // RecyclerView
/**
* 用于将滚动工具和 Recycler 绑定
*
* @param recyclerView RecyclerView
* @throws IllegalStateException 状态异常
*/
@Override
public void attachToRecyclerView(@Nullable RecyclerView recyclerView) throws
IllegalStateException {
super.attachToRecyclerView(recyclerView);
mRecyclerView = recyclerView;
}
/**
* 计算需要滚动的向量,用于页面自动回滚对齐
*
* @param layoutManager 布局管理器
* @param targetView 目标控件
* @return 需要滚动的距离
*/
@Nullable
@Override
public int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager,
@NonNull View targetView) {
int pos = layoutManager.getPosition(targetView);
Loge("findTargetSnapPosition, pos = " + pos);
int[] offset = new int[2];
if (layoutManager instanceof PagerGridLayoutManager) {
PagerGridLayoutManager manager = (PagerGridLayoutManager) layoutManager;
offset = manager.getSnapOffset(pos);
}
return offset;
}
/**
* 获得需要对齐的View,对于分页布局来说,就是页面第一个
*
* @param layoutManager 布局管理器
* @return 目标控件
*/
@Nullable
@Override
public View findSnapView(RecyclerView.LayoutManager layoutManager) {
if (layoutManager instanceof PagerGridLayoutManager) {
PagerGridLayoutManager manager = (PagerGridLayoutManager) layoutManager;
return manager.findSnapView();
}
return null;
}
/**
* 获取目标控件的位置下标
* (获取滚动后第一个View的下标)
*
* @param layoutManager 布局管理器
* @param velocityX X 轴滚动速率
* @param velocityY Y 轴滚动速率
* @return 目标控件的下标
*/
@Override
public int findTargetSnapPosition(RecyclerView.LayoutManager layoutManager,
int velocityX, int velocityY) {
int target = RecyclerView.NO_POSITION;
Loge("findTargetSnapPosition, velocityX = " + velocityX + ", velocityY" + velocityY);
if (null != layoutManager && layoutManager instanceof PagerGridLayoutManager) {
PagerGridLayoutManager manager = (PagerGridLayoutManager) layoutManager;
if (manager.canScrollHorizontally()) {
if (velocityX > PagerConfig.getFlingThreshold()) {
target = manager.findNextPageFirstPos();
} else if (velocityX < -PagerConfig.getFlingThreshold()) {
target = manager.findPrePageFirstPos();
}
} else if (manager.canScrollVertically()) {
if (velocityY > PagerConfig.getFlingThreshold()) {
target = manager.findNextPageFirstPos();
} else if (velocityY < -PagerConfig.getFlingThreshold()) {
target = manager.findPrePageFirstPos();
}
}
}
Loge("findTargetSnapPosition, target = " + target);
return target;
}
/**
* 一扔(快速滚动)
*
* @param velocityX X 轴滚动速率
* @param velocityY Y 轴滚动速率
* @return 是否消费该事件
*/
@Override
public boolean onFling(int velocityX, int velocityY) {
RecyclerView.LayoutManager layoutManager = mRecyclerView.getLayoutManager();
if (layoutManager == null) {
return false;
}
RecyclerView.Adapter adapter = mRecyclerView.getAdapter();
if (adapter == null) {
return false;
}
int minFlingVelocity = PagerConfig.getFlingThreshold();
Loge("minFlingVelocity = " + minFlingVelocity);
return (Math.abs(velocityY) > minFlingVelocity || Math.abs(velocityX) > minFlingVelocity)
&& snapFromFling(layoutManager, velocityX, velocityY);
}
/**
* 快速滚动的具体处理方案
*
* @param layoutManager 布局管理器
* @param velocityX X 轴滚动速率
* @param velocityY Y 轴滚动速率
* @return 是否消费该事件
*/
private boolean snapFromFling(@NonNull RecyclerView.LayoutManager layoutManager, int velocityX,
int velocityY) {
if (!(layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider)) {
return false;
}
RecyclerView.SmoothScroller smoothScroller = createSnapScroller(layoutManager);
if (smoothScroller == null) {
return false;
}
int targetPosition = findTargetSnapPosition(layoutManager, velocityX, velocityY);
if (targetPosition == RecyclerView.NO_POSITION) {
return false;
}
smoothScroller.setTargetPosition(targetPosition);
layoutManager.startSmoothScroll(smoothScroller);
return true;
}
/**
* 通过自定义 LinearSmoothScroller 来控制速度
*
* @param layoutManager 布局故哪里去
* @return 自定义 LinearSmoothScroller
*/
protected LinearSmoothScroller createSnapScroller(RecyclerView.LayoutManager layoutManager) {
if (!(layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider)) {
return null;
}
return new PagerGridSmoothScroller(mRecyclerView);
}
//--- 公开方法 ----------------------------------------------------------------------------------
/**
* 设置滚动阀值
* @param threshold 滚动阀值
*/
public void setFlingThreshold(int threshold) {
PagerConfig.setFlingThreshold(threshold);
}
}
......@@ -17,6 +17,10 @@ public interface GoldConstants {
// boolean isRefreshData = false;
int DetailColCount = 4;
int foodGriupColCount = 5;//食品組列數
int foodGriupRows = 2;//食品組行數
int foodGriupColumns = 5;//食品組列數
int foodGriupPageSize = 10;//食品組最大顯示數
}
package com.gingersoft.gsa.cloud.table.mvp.contract;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
* ================================================
......@@ -31,5 +35,7 @@ public interface BaseOrderContract {
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<BaseResult> updateOrderStatus(RequestBody formBody);
}
}
......@@ -4,17 +4,12 @@ import android.app.Activity;
import android.widget.BaseAdapter;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.FoodCombo;
import com.gingersoft.gsa.cloud.database.bean.FoodModifier;
import com.gingersoft.gsa.cloud.database.bean.Modifier;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.BaseRespose;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.request.OrderRequest;
import com.gingersoft.gsa.cloud.table.mvp.presenter.MealStandPresenter;
import com.gingersoft.gsa.cloud.table.mvp.ui.activity.MealStandActivity;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;
import java.util.List;
......@@ -115,9 +110,9 @@ public interface MealStandContract {
List<Modifier> queryDB_ModifierList(long fid);
List<Combo> queryDB_ComboList(long fid);
List<FoodCombo> queryDB_ComboList(long fid);
List<Combo> isComboFood(long fid);
List<FoodCombo> isComboFood(long fid);
List<FoodModifier> queryDB_FoodModifierList(long fid);
}
......
......@@ -53,10 +53,10 @@ public interface OrderPayContract {
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends BaseOrderContract.Model {
Observable<BaseResult> getPayMethods();
Observable<BaseResult> getPayMethods(int brandId,int restaurantId);
// Observable<Object> getN5SaleTxnId(String url);
//
Observable<BaseResult> updateOrderStatus( RequestBody formBody);
// Observable<BaseResult> updateOrderStatus( RequestBody formBody);
}
}
......@@ -4,22 +4,18 @@ import android.app.Application;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.ComboItem;
import com.gingersoft.gsa.cloud.database.bean.FoodCombo;
import com.gingersoft.gsa.cloud.database.bean.FoodModifier;
import com.gingersoft.gsa.cloud.database.bean.Modifier;
import com.gingersoft.gsa.cloud.database.greendao.ModifierDao;
import com.gingersoft.gsa.cloud.database.utils.ComboDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.FoodComboDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.FoodModifierDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.ModifierDaoUtils;
import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.BaseRespose;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
import com.gingersoft.gsa.cloud.table.mvp.contract.MealStandContract;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.request.OrderRequest;
import com.gingersoft.gsa.cloud.table.mvp.model.service.MealService;
import com.gingersoft.gsa.cloud.table.mvp.presenter.MealStandPresenter;
import com.gingersoft.gsa.cloud.table.mvp.ui.activity.MealStandActivity;
import com.gingersoft.gsa.cloud.table.mvp.model.service.OrderPayService;
import com.google.gson.Gson;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.integration.IRepositoryManager;
......@@ -30,11 +26,7 @@ import java.util.List;
import javax.inject.Inject;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Action;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import okhttp3.RequestBody;
......@@ -111,13 +103,15 @@ public class MealStandModel extends BaseModel implements MealStandContract.Model
@Override
public List<Food> queryDB_FoodGroupList() {
FoodDaoUtils foodDaoUtils = new FoodDaoUtils(mApplication);
return foodDaoUtils.queryFoodGroupByQueryBuilder();
List<Food> foods = foodDaoUtils.queryFoodGroupByQueryBuilder();
return foods;
}
@Override
public List<Food> queryDB_FoodList(long parentId) {
FoodDaoUtils foodDaoUtils = new FoodDaoUtils(mApplication);
return foodDaoUtils.queryFoodByQueryBuilder(parentId);
List<Food> foods = foodDaoUtils.queryFoodByQueryBuilder(parentId);
return foods;
}
@Override
......@@ -127,15 +121,19 @@ public class MealStandModel extends BaseModel implements MealStandContract.Model
}
@Override
public List<Combo> queryDB_ComboList(long fid) {
ComboDaoUtils comboDaoUtils = new ComboDaoUtils(mApplication);
return comboDaoUtils.queryComboFoodsByQueryBuilder(fid);
public List<FoodCombo> queryDB_ComboList(long fid) {
FoodComboDaoUtils foodComboDaoUtils = new FoodComboDaoUtils(mApplication);
List<FoodCombo> foodCombo = foodComboDaoUtils.queryCombosByQueryBuilder(fid);
FoodDaoUtils foodDaoUtils = new FoodDaoUtils(mApplication);
Food food = foodDaoUtils.queryFoodByFidQueryBuilder2(fid);
return foodCombo;
}
@Override
public List<Combo> isComboFood(long fid) {
ComboDaoUtils comboDaoUtils = new ComboDaoUtils(mApplication);
return comboDaoUtils.queryCombosFoodsByQueryBuilder(fid);
public List<FoodCombo> isComboFood(long fid) {
FoodComboDaoUtils foodComboDaoUtils = new FoodComboDaoUtils(mApplication);
return foodComboDaoUtils.queryCombosFoodsByQueryBuilder(fid);
}
@Override
......@@ -144,4 +142,9 @@ public class MealStandModel extends BaseModel implements MealStandContract.Model
}
@Override
public Observable<BaseResult> updateOrderStatus(RequestBody formBody) {
return mRepositoryManager.obtainRetrofitService(OrderPayService.class)
.updateOrderStatus(formBody);
}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import com.gingersoft.gsa.cloud.table.mvp.model.bean.BaseRespose;
import com.gingersoft.gsa.cloud.table.mvp.contract.OrderContentContract;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.request.OrderRequest;
import com.gingersoft.gsa.cloud.table.mvp.model.service.MealService;
import com.gingersoft.gsa.cloud.table.mvp.model.service.OrderPayService;
import com.google.gson.Gson;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.integration.IRepositoryManager;
......@@ -66,4 +67,10 @@ public class OrderContentModel extends BaseModel implements OrderContentContract
return mRepositoryManager.obtainRetrofitService(MealService.class)
.printOrder(request);
}
@Override
public Observable<BaseResult> updateOrderStatus(RequestBody formBody) {
return mRepositoryManager.obtainRetrofitService(OrderPayService.class)
.updateOrderStatus(formBody);
}
}
\ No newline at end of file
......@@ -48,9 +48,9 @@ public class OrderPayModel extends BaseModel implements OrderPayContract.Model {
}
@Override
public Observable<BaseResult> getPayMethods() {
public Observable<BaseResult> getPayMethods(int brandId,int restaurantId) {
return mRepositoryManager.obtainRetrofitService(OrderPayService.class)
.getPayMethods();
.getPayMethods(brandId,restaurantId);
}
@Override
......
......@@ -36,8 +36,10 @@ public interface MealService {
@POST("orderDetails/delete" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> deleteFood(@Body RequestBody requestBody);
@POST("behavior/print" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseRespose> printOrder(@Body RequestBody requestBody);
// @POST("behavior/print" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
// Observable<BaseRespose> printOrder(@Body RequestBody requestBody);
@POST("restaurantTable/print" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseRespose> printOrder(@Body RequestBody requestBody);
}
......@@ -8,6 +8,7 @@ import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
/**
* Created by Wyh on 2020/1/17.
......@@ -17,7 +18,7 @@ public interface OrderPayService {
@POST("order/update" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> updateOrderStatus(@Body RequestBody requestBody);
@GET("pay/get" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getPayMethods();
@GET("restaurant/pay/get" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getPayMethods(@Query("brandId") int brandId,@Query("restaurantId") int restaurantId);
}
......@@ -2,7 +2,9 @@ package com.gingersoft.gsa.cloud.table.mvp.presenter;
import android.app.Activity;
import android.app.Application;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.common.bean.OrderBean;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage;
......@@ -17,6 +19,8 @@ import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.ArrayList;
import java.util.Collections;
......@@ -25,7 +29,12 @@ import java.util.List;
import javax.inject.Inject;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.FormBody;
import okhttp3.RequestBody;
/**
* 作者:ELEGANT_BIN
......@@ -150,6 +159,33 @@ public class BaseOrderPresenter<M extends BaseOrderContract.Model, V extends Bas
});
}
/**
* 修改訂單
*
* @param //orderId 訂單號
* @param //person 人數
*/
public void updateOrderPerson(String peopleNumber, TextView textView) {
RequestBody requestBody = new FormBody.Builder()
.add("orderId", MyOrderManage.getInstance().getOrderId() + "")
.add("person", peopleNumber + "")
.build();
mModel.updateOrderStatus(requestBody)
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(BaseResult baseResult) {
if (baseResult.isSuccess()) {
textView.setText("人數:" + peopleNumber);
OpenTableManage.getDefault().setPeopleNumber(Integer.parseInt(peopleNumber));
}
}
});
}
public void changeNumber(int number) {
if (!changeNumberCondition(number)) {
return;
......
......@@ -12,7 +12,7 @@ import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage;
import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.FoodCombo;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.Modifier;
import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
......@@ -24,6 +24,7 @@ import com.gingersoft.gsa.cloud.table.mvp.model.constant.MealConstant;
import com.gingersoft.gsa.cloud.table.mvp.ui.activity.MealStandActivity;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.meal.ComboAdapter;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.meal.FoodAdapter;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.meal.FoodGroupAdapter;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.meal.SelectMealAdapter;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.http.imageloader.ImageLoader;
......@@ -78,12 +79,12 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
private FoodAdapter mFoodAdapter;
private ComboAdapter mComboAdapter;
//食品数据
private List<Food> mFoodGroupList;
private List<Food> mFoodGroupList = new ArrayList<>();
private List<Food> mFoodList = new ArrayList<>();
//套餐细项数据
private List<Combo> mComboList = new ArrayList<>();
private List<FoodCombo> mFoodComboList = new ArrayList<>();
private List<Combo> mCurrentComboList;
private List<FoodCombo> mCurrentFoodComboList;
private OrderDetail mCurrentOrderDetailBean;
private boolean RvMealClicked;
......@@ -106,9 +107,13 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
public void initMealData() {
mFoodGroupList = mModel.queryDB_FoodGroupList();
List<Food> foodGroupList = mModel.queryDB_FoodGroupList();
if (mFoodGroupList != null && mFoodGroupList.size() > 0) {
if (foodGroupList != null && foodGroupList.size() > 0) {
mFoodGroupList.addAll(foodGroupList);
//默認選中第一組
mFoodGroupList.get(0).setSelected(true);
IActivity.initFoodGroupView(mFoodGroupList);
......@@ -121,12 +126,16 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
mRootView.setSelectFoodAdapter(mSelectMealAdapter);
}
// myOrderManage.setSelectMealAdapter(mSelectMealAdapter);
// if (mFoodGroupAdapter == null) {
// mFoodGroupAdapter = new FoodGroupAdapter(IActivity, mFoodGroupList);
// mRootView.setFoodGroupAdapter(mFoodGroupAdapter);
// }
if (mFoodAdapter == null) {
mFoodAdapter = new FoodAdapter(IActivity, mFoodList);
mRootView.setFoodAdapter(mFoodAdapter);
}
if (mComboAdapter == null) {
mComboAdapter = new ComboAdapter(IActivity, mComboList);
mComboAdapter = new ComboAdapter(IActivity, mFoodComboList);
mRootView.setComboAdapter(mComboAdapter);
}
}
......@@ -139,7 +148,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
RvMealClicked = true;
mRootView.recordOperat(true);
mSelectMealAdapter.setMyOrderManageSelectPosition();
loadComboData(datasBean);
loadComboData(datasBean, true);
}
@Override
......@@ -169,7 +178,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
mComboAdapter.setOnItemClickListener(new ComboAdapter.OnItemClickListener() {
@Override
public void onItemClick(Combo datasBean, int position) {
public void onItemClick(FoodCombo datasBean, int position) {
mRootView.recordOperat(true);
......@@ -201,7 +210,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
private void addFoodItemBefore(OrderDetail datasBean) {
loadComboData(mCurrentOrderDetailBean);
loadComboData(mCurrentOrderDetailBean, false);
int addPosition = addFoodItem(datasBean);
......@@ -215,10 +224,10 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
if (orderDetail.getComboLevel() > 0) {
//自动添加组合子食品
if (mCurrentComboList != null && mCurrentComboList.size() > 0) {
for (int i = 0; i < mCurrentComboList.size(); i++) {
Combo comboItem = mCurrentComboList.get(i);
mCurrentOrderDetailBean = OrderDetail.comboTransOrderDetail(comboItem, 1, "combo", RvMealClicked);
if (mCurrentFoodComboList != null && mCurrentFoodComboList.size() > 0) {
for (int i = 0; i < mCurrentFoodComboList.size(); i++) {
FoodCombo foodComboItem = mCurrentFoodComboList.get(i);
mCurrentOrderDetailBean = OrderDetail.comboTransOrderDetail(foodComboItem, 1, "combo", RvMealClicked);
addPosition = addComboItem(mCurrentOrderDetailBean);
}
}
......@@ -248,18 +257,18 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
mRootView.setMealRvScrollToPosition(addPosition);
}
private void loadComboData(OrderDetail food) {
private void loadComboData(OrderDetail food, boolean isSelectedMeal) {
long fid = food.getProductId();
if (mCurrentComboList == null) {
mCurrentComboList = new ArrayList<>();
if (mCurrentFoodComboList == null) {
mCurrentFoodComboList = new ArrayList<>();
} else {
mCurrentComboList.clear();
mCurrentFoodComboList.clear();
}
if (food.getItemType() == 1) {
//获取套餐细项数据
mCurrentComboList = mModel.queryDB_ComboList(fid);
mCurrentFoodComboList = mModel.queryDB_ComboList(fid);
}
List<Modifier> modifierList = mModel.queryDB_ModifierList(fid);
......@@ -273,22 +282,24 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
//设置备注细项背景、字体颜色
modfier.setBgColor(Color.parseColor("#ffeb3b"));
Combo comboItem = new Combo();
comboItem.setModifier(true);
FoodCombo foodComboItem = new FoodCombo();
foodComboItem.setModifier(true);
// if (modfier.isParent()) {
// comboItem.setModKeyboard(modfier.isModKeyboard());
// foodComboItem.setModKeyboard(modfier.isModKeyboard());
// }
comboItem.setModifier(modfier);
foodComboItem.setModifier(modfier);
mCurrentComboList.add(comboItem);
mCurrentFoodComboList.add(foodComboItem);
}
}
//更新套餐细项数据
updateComboData(mCurrentComboList);
updateComboData(mCurrentFoodComboList);
if (food.getAutoMod() == 1) {
// if (food.getAutoMod() == 1) {
if (isSelectedMeal) {
mRootView.showViewModeVisibility(MealConstant.combo_ViewMode);
}
// }
}
public void createOrder() {
......@@ -296,7 +307,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), JsonUtils.toJson(request));
mModel.createOrder(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
......@@ -341,11 +352,21 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
}
printSendOrder(newFoods);
mRootView.killMyself();
// mRootView.launchActivity(new Intent(IActivity, MealStandActivity.class));
} else {
if (getNewOrderFoodLists().size() == 0) {
//未新增食品點擊送單 後台不讓過直接提示即可
mRootView.showMessage("送單成功");
if (OpenTableManage.getDefault() != null) {
//通知更新餐台状态
EventBus.getDefault().post(OpenTableManage.getDefault().getTableBean().getId(), "initTable_status_event");
}
printSendOrder(newFoods);
mRootView.killMyself();
} else {
mRootView.showMessage("送單失敗");
}
}
}
});
}
......@@ -408,8 +429,10 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
deleteOldFood();
if (info.getData() != null && info.getData().getOrderDetails() != null) {
OpenTableManage.getDefault().setPeopleNumber(info.getData().getPerson());
//緩存訂單信息
MyOrderManage.getInstance().setOrderBean(new OrderBean(info.getData().getId(), info.getData().getOrderNo(), info.getData().getStatus(), info.getData().getCreateTime()));
MyOrderManage.getInstance().setOrderBean(new OrderBean(info.getData()));
//緩存食品信息
List<OrderDetail> orderDetailList = OrderDetail.orderTransOrderDetails(info.getData().getOrderDetails());
orderFoodList.addAll(orderDetailList);
......@@ -624,8 +647,9 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
private boolean foodConditionFilter(Food foodBean) {
long isSold = foodBean.getIsSold();
if (isSold == 1) {
long Invisible = foodBean.getInvisible();
if (Invisible == 2) {
mRootView.showMessage("已售罄");
return false;
}
......@@ -687,7 +711,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
mFoodAdapter.notifyDataSetChanged();
}
private void setFoodGroupBtnNumber(BaseAdapter adapter, List<Food> foodGroupList) {
private void setFoodGroupBtnNumber(FoodGroupAdapter adapter, List<Food> foodGroupList) {
for (int i = 0; i < foodGroupList.size(); i++) {
Food foodBean = foodGroupList.get(i);
foodBean.setNumber(0);
......@@ -727,8 +751,8 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
private void setFoodComboListStatus(List<Food> foodList) {
for (int i = 0; i < foodList.size(); i++) {
Food datasBean = foodList.get(i);
List<Combo> foodComboList = mModel.isComboFood(datasBean.getId());
if (foodComboList.size() > 0) {
List<FoodCombo> foodFoodComboList = mModel.isComboFood(datasBean.getId());
if (foodFoodComboList.size() > 0) {
datasBean.setComboFood(true);
}
}
......@@ -740,8 +764,8 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
* @param food
*/
private void setFoodComboStatus(Food food) {
List<Combo> foodComboList = mModel.isComboFood(food.getId());
if (foodComboList.size() > 0) {
List<FoodCombo> foodFoodComboList = mModel.isComboFood(food.getId());
if (foodFoodComboList.size() > 0) {
food.setComboFood(true);
}
}
......@@ -765,11 +789,11 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
mFoodAdapter.notifyDataSetChanged();
}
private void updateComboData(List<Combo> comboList) {
mComboList.clear();
mComboList.addAll(comboList);
private void updateComboData(List<FoodCombo> foodComboList) {
mFoodComboList.clear();
mFoodComboList.addAll(foodComboList);
//根据Item个数显示每一行的个数
mRootView.setComboRecycleSpanCount(mComboList.size());
mRootView.setComboRecycleSpanCount(mFoodComboList.size());
mComboAdapter.notifyDataSetChanged();
}
......
......@@ -5,6 +5,7 @@ import android.graphics.Color;
import android.view.View;
import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCUtil;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.common.bean.OrderBean;
import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
......@@ -105,11 +106,12 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
public void onItemClick(View view, int viewType, Object data, int position) {
switch (position) {
case 0:
sendOrder();
//送單
sendOrder(false);
break;
case 1:
printOrder(OpenTableManage.getDefault().getTableBean().getId());
//打印
sendOrder(true);
break;
case 2:
//結賬
......@@ -127,7 +129,7 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
mFunctionList.addAll(Arrays.asList(functions));
}
private void createOrder() {
private void createOrder(boolean isPrint) {
OrderRequest request = getCreateOrderRequest(getOrderFoodLists());
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), JsonUtils.toJson(request));
mModel.createOrder(requestBody)
......@@ -142,19 +144,27 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null && info.isSuccess()) {
if (isPrint) {
printOrder(OpenTableManage.getDefault().getTableBean().getId());
} else {
mRootView.sendSuccess();
mRootView.showMessage("送單成功");
printSendOrder(getOrderFoodLists());
mAppManager.killActivity(MealStandActivity.class);
mRootView.killMyself();
}
} else {
if (isPrint) {
printOrder(OpenTableManage.getDefault().getTableBean().getId());
} else {
mRootView.showMessage("送單失敗");
}
}
}
});
}
private void addOrderFood() {
private void addOrderFood(boolean isPrint) {
List<OrderDetail> newFoods = getNewOrderFoodLists();
for (OrderDetail food : newFoods) {
food.setOrderId(MyOrderManage.getInstance().getOrderId());
......@@ -172,16 +182,31 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null && info.isSuccess()) {
if (isPrint) {
printOrder(OpenTableManage.getDefault().getTableBean().getId());
} else {
mRootView.showMessage("送單成功");
printSendOrder(newFoods);
mRootView.sendSuccess();
// mRootView.launchActivity(new Intent(IActivity, MealStandActivity.class));
}
} else {
if (isPrint) {
printOrder(OpenTableManage.getDefault().getTableBean().getId());
} else {
if(getNewOrderFoodLists().size() == 0){
//未新增食品點擊送單 後台不讓過直接提示即可
mRootView.showMessage("送單成功");
printSendOrder(newFoods);
mRootView.sendSuccess();
}else {
mRootView.showMessage("送單失敗");
}
}
}
}
});
}
/**
* 打印上菜紙
*/
......@@ -211,6 +236,7 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
// }
// });
}
public void printOrder(int tableId) {
RequestBody requestBody = new FormBody.Builder()
.add("tableId", tableId + "")
......@@ -229,13 +255,16 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
public void onNext(@NonNull BaseRespose info) {
if (info != null && info.isSuccess()) {
CC.obtainBuilder("Component.Print")
.setActionName("printActivity")
.addParam("type", 1)//印單
.setActionName("printActivity")
.build()
.callAsync((cc, result) -> {
if (result.isSuccess()) {
//打印成功
mRootView.printSuccess();
} else {
mRootView.printSuccess();
mRootView.showMessage("打印失敗!");
}
});
//打印
......@@ -246,11 +275,16 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
});
}
public void sendOrder() {
/**
* 送單
*
* @param isPrint 印單先調用送單接口
*/
public void sendOrder(boolean isPrint) {
if (MyOrderManage.getInstance().getOrderId() == -1) {
createOrder();
createOrder(isPrint);
} else {
addOrderFood();
addOrderFood(isPrint);
}
}
......
......@@ -5,6 +5,7 @@ import android.text.TextUtils;
import android.view.View;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage;
......@@ -149,7 +150,9 @@ public class OrderPayPresenter extends BaseOrderPresenter<OrderPayContract.Model
}
public void getPayMethods() {
mModel.getPayMethods()
int brandId = GsaCloudApplication.getBrandId(mApplication);
int restaurantId = GsaCloudApplication.getRestaurantId(mApplication);
mModel.getPayMethods(brandId, restaurantId)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
......@@ -180,11 +183,11 @@ public class OrderPayPresenter extends BaseOrderPresenter<OrderPayContract.Model
.add("orderId", MyOrderManage.getInstance().getOrderId() + "")
.add("person", OpenTableManage.getDefault().getPeopleNumber() + "")
.add("status", statius)
.add("orderPayType", mBillMoneyList.get(0).getId()+"")
.add("orderPayType", mBillMoneyList.get(0).getId() + "")
.build();
mModel.updateOrderStatus(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
......
......@@ -39,6 +39,7 @@ import okhttp3.RequestBody;
import javax.inject.Inject;
import com.gingersoft.gsa.cloud.table.mvp.contract.TableContract;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.RxLifecycleUtils;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
......@@ -145,34 +146,34 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
mRootView.setCurrentOperatType(TableOperatTypeConstant.move_table_4);
return;
}
if (mBottomFunctionList.get(position).getResName().equals("↑")) {
mBottomFunctionList.add(new Function((long) 5, 1, 2025, "skyorder", "", ""));
mBottomFunctionList.add(new Function((long) 6, 1, 2025, "上菜紙", "", ""));
for (int i = 0; i < mBottomFunctionList.size(); i++) {
boolean isMore = mBottomFunctionList.get(i).getResName().equals("↑");
if (isMore)
mBottomFunctionList.get(i).setResName("↓");
}
mBottomFunctionAdapter.notifyDataSetChanged();
} else if (mBottomFunctionList.get(position).getResName().equals("↓")) {
mBottomFunctionList.remove(mBottomFunctionList.size() - 1);
mBottomFunctionList.remove(mBottomFunctionList.size() - 1);
for (int i = 0; i < mBottomFunctionList.size(); i++) {
boolean isMore = mBottomFunctionList.get(i).getResName().equals("↓");
if (isMore)
mBottomFunctionList.get(i).setResName("↑");
}
mBottomFunctionAdapter.notifyDataSetChanged();
}
// if (mBottomFunctionList.get(position).getResName().equals("↑")) {
// mBottomFunctionList.add(new Function((long) 5, 1, 2025, "skyorder", "", ""));
// mBottomFunctionList.add(new Function((long) 6, 1, 2025, "上菜紙", "", ""));
// for (int i = 0; i < mBottomFunctionList.size(); i++) {
// boolean isMore = mBottomFunctionList.get(i).getResName().equals("↑");
// if (isMore)
// mBottomFunctionList.get(i).setResName("↓");
// }
// mBottomFunctionAdapter.notifyDataSetChanged();
// } else if (mBottomFunctionList.get(position).getResName().equals("↓")) {
// mBottomFunctionList.remove(mBottomFunctionList.size() - 1);
// mBottomFunctionList.remove(mBottomFunctionList.size() - 1);
// for (int i = 0; i < mBottomFunctionList.size(); i++) {
// boolean isMore = mBottomFunctionList.get(i).getResName().equals("↓");
// if (isMore)
// mBottomFunctionList.get(i).setResName("↑");
// }
// mBottomFunctionAdapter.notifyDataSetChanged();
// }
}
});
}
public void initBottomFunctionItem() {
mBottomFunctionList.add(new Function((long) 1, 1, 2025, "重置檯號", "", ""));
mBottomFunctionList.add(new Function((long) 2, 1, 2025, "轉檯", "", ""));
mBottomFunctionList.add(new Function((long) 3, 1, 2025, "分檯", "", ""));
mBottomFunctionList.add(new Function((long) 4, 1, 2025, "↑", "", ""));
mBottomFunctionList.add(new Function((long) 1, 1, 2025, "重置檯號", "", String.valueOf(R.mipmap.table_init)));
mBottomFunctionList.add(new Function((long) 2, 1, 2025, "轉檯", "", String.valueOf(R.mipmap.table_move)));
// mBottomFunctionList.add(new Function((long) 3, 1, 2025, "分檯", "", ""));
// mBottomFunctionList.add(new Function((long) 4, 1, 2025, "↑", "", ""));
}
public void getTables(boolean show) {
......@@ -218,7 +219,6 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
RequestBody requestBody = new FormBody.Builder()
.add("id", String.valueOf(tableId))
.build();
mModel.openTable(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
......@@ -235,11 +235,16 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
TableBean.DataBean openTableBean = getTableById(tableId);
OpenTableManage.getDefault().setTableBean(openTableBean);
if (respose.getData() != null && respose.getData().getOrderDetails() != null) {
OrderBean orderBean = respose.getData();
if (orderBean != null && respose.getData().getOrderDetails() != null) {
OpenTableManage.getDefault().setPeopleNumber(orderBean.getPerson());
List<OrderBean.OrderDetailsBean> orderDetailsBeans = respose.getData().getOrderDetails();
//緩存訂單信息
MyOrderManage.getInstance().setOrderBean(new OrderBean(respose.getData().getId(), respose.getData().getOrderNo(), respose.getData().getStatus(), respose.getData().getCreateTime()));
MyOrderManage.getInstance().setOrderBean(new OrderBean(orderBean));
//緩存食品信息
List<OrderDetail> orderDetailList = OrderDetail.orderTransOrderDetails(respose.getData().getOrderDetails());
List<OrderDetail> orderDetailList = OrderDetail.orderTransOrderDetails(orderDetailsBeans);
MyOrderManage.getInstance().setOrderFoodList(orderDetailList);
} else {
......@@ -274,7 +279,7 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
mRootView.showMessage("此檯使用中.");
return;
}
if(tableBean.getStatus() == 0){
if (tableBean.getStatus() == 0) {
mRootView.showMessage("此檯未開檯.");
return;
}
......@@ -286,10 +291,13 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
mRootView.showMessage("此檯使用中.");
return;
}
if (tableBean.getStatus() == 2 || tableBean.getStatus() == 3) {
mRootView.showMessage(tableBean.getTableName() + "檯已開檯不可轉檯");
return;
}
targetTableName = tableBean.getTableName();
targetTableId = tableBean.getId();
mRootView.setOperatContentText("由: " + originalTableName + " 轉到 " +
targetTableName + " 號檯");
mRootView.setOperatContentText("由: " + originalTableName + " 轉到 " + targetTableName + " 號檯");
showOperatTipDialog(tableBean);
}
} else {
......@@ -337,7 +345,11 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
mModel.initTable(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.doOnSubscribe(disposable -> {
if (showMessage) {
mRootView.showLoading(null);
}
})
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
......
......@@ -28,6 +28,9 @@ import com.gingersoft.gsa.cloud.base.utils.VibratorUtils;
import com.gingersoft.gsa.cloud.base.utils.view.ViewUtils;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.utils.ComboItemDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.FoodComboDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.R2;
import com.gingersoft.gsa.cloud.table.app.GoldConstants;
......@@ -36,13 +39,17 @@ import com.gingersoft.gsa.cloud.table.mvp.contract.MealStandContract;
import com.gingersoft.gsa.cloud.table.mvp.model.constant.MealConstant;
import com.gingersoft.gsa.cloud.table.mvp.presenter.MealStandPresenter;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.BaseFragmentAdapter;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.meal.HorizontalGridViewAdpter;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.MyViewPagerAdapter;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.meal.FoodGroupAdapter;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.meal.HorizontalGridViewAdpter;
import com.gingersoft.gsa.cloud.table.mvp.ui.fragment.FineItemAllFragment;
import com.gingersoft.gsa.cloud.table.mvp.ui.fragment.FineItemKindFragment;
import com.gingersoft.gsa.cloud.table.mvp.ui.widget.ChooseNumberDialog;
import com.gingersoft.gsa.cloud.ui.recylcler.Indicator.PagerConfig;
import com.gingersoft.gsa.cloud.ui.recylcler.Indicator.PagerGridLayoutManager;
import com.gingersoft.gsa.cloud.ui.recylcler.Indicator.PagerGridSnapHelper;
import com.gingersoft.gsa.cloud.ui.recylcler.decorator.GridDividerItemDecoration;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.gingersoft.gsa.cloud.ui.view.LineGridView;
import com.gingersoft.gsa.cloud.ui.view.PagerSlidingTabStrip;
import com.gingersoft.gsa.cloud.ui.view.RecyclerViewNoBugLinearLayoutManager;
import com.gingersoft.gsa.cloud.ui.view.SearchKeyBoardView;
......@@ -50,6 +57,8 @@ import com.jess.arms.base.BaseActivity;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.DeviceUtils;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;
import org.simple.eventbus.EventBus;
......@@ -86,7 +95,8 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public class MealStandActivity extends BaseActivity<MealStandPresenter> implements MealStandContract.View {
public class MealStandActivity extends BaseActivity<MealStandPresenter> implements MealStandContract.View, PagerGridLayoutManager
.PageListener {
private SparseArray<View> map = new SparseArray<>();
......@@ -98,12 +108,12 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
@BindView(R2.id.ll_food_group)
LinearLayout ll_food_group;
@BindView(R2.id.vp_food_group)
ViewPager vp_food_group;
@BindView(R2.id.ll_food_group_point)
LinearLayout ll_food_group_point;
// @BindView(R2.id.rv_food_group)
// RecyclerView rv_food_group;
@BindView(R2.id.rv_food_group)
RecyclerView rv_food_group;
@BindView(R2.id.rv_food)
RecyclerView rv_food;
@BindView(R2.id.rv_combo)
......@@ -217,15 +227,12 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
private int mCurrentViewMode;
private boolean isPluMode = false;
private HorizontalGridViewAdpter mFoodGroupGridViewAdapter;
//小圆点图片的集合
private ImageView[] ivPoints;
//总的页数
private int mPageIndex;
private int totalPage;
//每页显示的最大的数量
// private int mPageSize = 10;
//GridView作为一个View对象添加到ViewPager集合中
private List<View> viewPagerList;
private FoodGroupAdapter mFoodGroupAdapter;
private PagerGridLayoutManager mLayoutManager;
private static final int FINISH = 101;
private static final int ORDER_CONTENT_CODE = 1002;
......@@ -244,6 +251,13 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
EventBus.getDefault().registerSticky(this);
//清除食品緩存
FoodDaoUtils foodDaoUtils = new FoodDaoUtils(this);
foodDaoUtils.detachAll();
FoodComboDaoUtils foodComboDaoUtils = new FoodComboDaoUtils(this);
foodComboDaoUtils.detachAll();
ComboItemDaoUtils comboItemDaoUtils = new ComboItemDaoUtils(this);
comboItemDaoUtils.detachAll();
super.onCreate(savedInstanceState);
}
......@@ -258,7 +272,6 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
initViewMap();
//初始化Plu模式
setPluMode();
initOrderDetail();
mPresenter.initAdapter();
mPresenter.initItemClickListener();
//初始化默认食品组
......@@ -269,7 +282,12 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
return;
mPresenter.toFindMeal(inputText);
});
}
@Override
protected void onResume() {
super.onResume();
initOrderDetail();
}
private void initOrderDetail() {
......@@ -282,45 +300,79 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
public void initFoodGroupView(List<Food> foodGroupList) {
ll_food_group_point.setVisibility(View.VISIBLE);
//默認選中第一組
foodGroupList.get(0).setSelected(true);
//总的页数向上取整
totalPage = (int) Math.ceil(foodGroupList.size() * 1.0 / GoldConstants.foodGriupPageSize);
viewPagerList = new ArrayList<>();
for (int i = 0; i < totalPage; i++) {
//每个页面都是inflate出一个新实例
LineGridView gridView = (LineGridView) View.inflate(this, R.layout.meal_food_group_grid, null);
gridView.setNumColumns(GoldConstants.foodGriupColCount);
HorizontalGridViewAdpter horizontalGridViewAdpter = new HorizontalGridViewAdpter(this, foodGroupList, i, GoldConstants.foodGriupPageSize);
gridView.setAdapter(horizontalGridViewAdpter);
if (i == 0) {
mFoodGroupGridViewAdapter = horizontalGridViewAdpter;
mLayoutManager = new PagerGridLayoutManager(GoldConstants.foodGriupRows, GoldConstants.foodGriupColumns, PagerGridLayoutManager.HORIZONTAL);
// 水平分页布局管理器
mLayoutManager.setPageListener(this); //设置页面变化监听器
rv_food_group.setLayoutManager(mLayoutManager);
// 设置滚动辅助工具
PagerGridSnapHelper pageSnapHelper = new PagerGridSnapHelper();
pageSnapHelper.attachToRecyclerView(rv_food_group);
// 如果需要查看调试日志可以设置为true,一般情况忽略即可
PagerConfig.setShowLog(true);
// 使用原生的 Adapter 即可
mFoodGroupAdapter = new FoodGroupAdapter(this, foodGroupList);
mFoodGroupAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
@Override
public void onChanged() {
super.onChanged();
int count = mFoodGroupAdapter.getItemCount();
}
//添加item点击监听
horizontalGridViewAdpter.setOnItemClickListener((food, position) -> {
});
rv_food_group.setAdapter(mFoodGroupAdapter);
mFoodGroupAdapter.setOnItemClickListener(new FoodGroupAdapter.OnItemClickListener() {
@Override
public void onItemClick(Food datasBean, int position) {
recordOperat(true);
if (!ViewUtils.isFastClick2()) {
return;
}
if (!foodGroupConditionFilter(food, false)) {
if (!foodGroupConditionFilter(datasBean, false)) {
return;
}
mFoodGroupGridViewAdapter = horizontalGridViewAdpter;
mPresenter.setRvMealClicked(false);
mPresenter.changedMealByParentId(food.getId());
});
//每一个GridView作为一个View对象添加到ViewPager集合中
viewPagerList.add(gridView);
mPresenter.changedMealByParentId(datasBean.getId());
}
});
// viewPagerList = new ArrayList<>();
// for (int i = 0; i < totalPage; i++) {
// //每个页面都是inflate出一个新实例
// LineGridView gridView = (LineGridView) View.inflate(this, R.layout.meal_food_group_grid, null);
// gridView.setNumColumns(GoldConstants.foodGriupColCount);
// HorizontalGridViewAdpter horizontalGridViewAdpter = new HorizontalGridViewAdpter(this, foodGroupList, i, GoldConstants.foodGriupPageSize);
// gridView.setAdapter(horizontalGridViewAdpter);
// if (i == 0) {
// mFoodGroupAdapter = horizontalGridViewAdpter;
// }
// //添加item点击监听
// horizontalGridViewAdpter.setOnItemClickListener((food, position) -> {
// recordOperat(true);
// if (!ViewUtils.isFastClick2()) {
// return;
// }
// if (!foodGroupConditionFilter(food, false)) {
// return;
// }
// mFoodGroupAdapter = horizontalGridViewAdpter;
// mPresenter.setRvMealClicked(false);
// mPresenter.changedMealByParentId(food.getId());
// });
// //每一个GridView作为一个View对象添加到ViewPager集合中
// viewPagerList.add(gridView);
// }
//
int mParentColHeight = GsaCloudApplication.androidSetting.getLayoutFoodTypeHeight() / GsaCloudApplication.androidSetting.getFoodTypeRow() * 2;
//设置ViewPager适配器
vp_food_group.setAdapter(new MyViewPagerAdapter(viewPagerList));
vp_food_group.setLayoutParams(new LinearLayout.LayoutParams(
rv_food_group.setLayoutParams(new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
mParentColHeight));
......@@ -343,21 +395,26 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
layoutParams.width = ArmsUtils.getScreenWidth(this) / totalPage;
ivPoints[i].setLayoutParams(layoutParams);
}
//设置ViewPager的滑动监听,主要是设置点点的背景颜色的改变
vp_food_group.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
//currentPage = position;
for (int i = 0; i < totalPage; i++) {
if (i == position) {
ivPoints[i].setImageResource(R.drawable.meal_food_group_point_focuese);
} else {
ivPoints[i].setImageResource(R.drawable.meal_food_group_point_unfocused);
}
}
}
});
if(foodGroupList.size() >10){
ll_food_group_point.setVisibility(View.VISIBLE);
}else {
ll_food_group_point.setVisibility(View.GONE);
}
// //设置ViewPager的滑动监听,主要是设置点点的背景颜色的改变
// vp_food_group.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
//
// @Override
// public void onPageSelected(int position) {
// //currentPage = position;
// for (int i = 0; i < totalPage; i++) {
// if (i == position) {
// ivPoints[i].setImageResource(R.drawable.meal_food_group_point_focuese);
// } else {
// ivPoints[i].setImageResource(R.drawable.meal_food_group_point_unfocused);
// }
// }
// }
// });
}
/**
......@@ -370,8 +427,8 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
return true;
}
long isSold = foodBean.getIsSold();
if (isSold == 1) {
long Invisible = foodBean.getInvisible();
if (Invisible == 2) {
new QMUITipDialog.Builder(this)
.setTipWord("已售罄(Comm.sold)")
.create(true);
......@@ -397,7 +454,7 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
fragmentList.add(fineItemAllFragment);
// tab title
String[] tabTitles = new String[2];
tabTitles[0] ="口味";
tabTitles[0] = "口味";
tabTitles[1] = "特別信息";
BaseFragmentAdapter adapter = new BaseFragmentAdapter(this, fm, fragmentList, Arrays.asList(tabTitles));
......@@ -480,7 +537,7 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
return false;
}
@OnClick({ R2.id.btn_key1, R2.id.btn_key2, R2.id.btn_key3, R2.id.btn_key4,R2.id.btn_key5, R2.id.btn_keys,
@OnClick({R2.id.btn_key1, R2.id.btn_key2, R2.id.btn_key3, R2.id.btn_key4, R2.id.btn_key5, R2.id.btn_keys,
R2.id.btn_numberman, R2.id.btn_fid, R2.id.btn_meal_delete, R2.id.btn_send_order, R2.id.tv_no_save_return, R2.id.fl_order_content,
R2.id.btn_add_delete, R2.id.btn_msg, R2.id.btn_delete, R2.id.btn_end, R2.id.iv_fine_back})
public void onClick(View v) {
......@@ -531,6 +588,7 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
case 2:
case 3:
case 4:
case 5:
mPresenter.changeNumber(i);
break;
case 99:
......@@ -619,11 +677,7 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
@Override
public void onComfirmClick(String number) {
recordOperat(true);
//选择的人数大于0
if (Integer.parseInt(number) > 0) {
OpenTableManage.getDefault().setPeopleNumber(Integer.parseInt(number));
}
btn_numberman.setText("人數:" + number);
mPresenter.updateOrderPerson(number, btn_numberman);
}
@Override
......@@ -654,6 +708,8 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
@Override
public void setFoodGroupAdapter(DefaultAdapter adapter) {
rv_food_group.addItemDecoration(new GridDividerItemDecoration(QMUIDisplayHelper.dpToPx(1), ArmsUtils.getColor(getActivity(), R.color.black)));
rv_food_group.setAdapter(adapter);
}
@Override
......@@ -906,11 +962,10 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
map.put(MealConstant.ViewMode_keys, keyView);
}
public HorizontalGridViewAdpter getFoodGroupGridViewAdapter() {
return mFoodGroupGridViewAdapter;
public FoodGroupAdapter getFoodGroupGridViewAdapter() {
return mFoodGroupAdapter;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
......@@ -928,4 +983,20 @@ public class MealStandActivity extends BaseActivity<MealStandPresenter> implemen
public int getCurrentViewMode() {
return mCurrentViewMode;
}
@Override
public void onPageSizeChanged(int pageSize) {
}
@Override
public void onPageSelect(int pageIndex) {
mPageIndex = pageIndex;
for (int i = 0; i < totalPage; i++) {
if (i == pageIndex) {
ivPoints[i].setImageResource(R.drawable.meal_food_group_point_focuese);
} else {
ivPoints[i].setImageResource(R.drawable.meal_food_group_point_unfocused);
}
}
}
}
......@@ -9,6 +9,8 @@ import android.widget.Button;
import android.widget.Chronometer;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage;
import com.gingersoft.gsa.cloud.base.utils.VibratorUtils;
import com.gingersoft.gsa.cloud.base.utils.view.ViewUtils;
......@@ -28,6 +30,8 @@ import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import org.simple.eventbus.EventBus;
import java.util.Date;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
......@@ -100,6 +104,7 @@ public class OrderContentActivity extends BaseActivity<OrderContentPresenter> im
QMUIDisplayHelper.cancelFullScreen(this);
initOrderDetail();
initTopInfo();
mPresenter.initTopFunctionData();
mPresenter.initAdapter();
mPresenter.initOrderTopFunctionListener();
......@@ -120,6 +125,24 @@ public class OrderContentActivity extends BaseActivity<OrderContentPresenter> im
tv_total.setText("$" + total);
}
private void initTopInfo() {
Date dd = MyOrderManage.getInstance().getOpenTableTime();
String openTime = String.format("%tH:%tM", dd, dd);
String tableno = "";
if (!OpenTableManage.getDefault().isSplite()) {
tableno = OpenTableManage.getDefault().getTableBean().getTableName();
} else {//TODO 暫未分檯功能
// tableno = GSAApplication.tableContract.getTableno().trim() + "-" + GSAApplication.tableContract.getTableno_split().trim();
}
btn_table.setText(tableno);
tv_time.setText("時間:" + openTime);
btn_people_num.setText(OpenTableManage.getDefault().getPeopleNumber() + "");
tv_server_main.setText(GsaCloudApplication.getMemberName(this));
}
@OnClick({R2.id.btn_table, R2.id.btn_people_num})
public void onClick(View v) {
......@@ -204,10 +227,9 @@ public class OrderContentActivity extends BaseActivity<OrderContentPresenter> im
public void onComfirmClick(String number) {
recordOperat(true);
//选择的人数大于0
if (Integer.parseInt(number) > 0) {
OpenTableManage.getDefault().setPeopleNumber(Integer.parseInt(number));
}
btn_people_num.setText(number);
// if (Integer.parseInt(number) > 0) {
// }
mPresenter.updateOrderPerson(number,btn_people_num);
}
@Override
......@@ -217,6 +239,7 @@ public class OrderContentActivity extends BaseActivity<OrderContentPresenter> im
});
chooseNumberDialog.setCancelable(isNeedCancel);
}
chooseNumberDialog.show();
}
@Override
......@@ -237,7 +260,7 @@ public class OrderContentActivity extends BaseActivity<OrderContentPresenter> im
@Override
public void showMessage(@NonNull String message) {
checkNotNull(message);
ArmsUtils.makeText(this,message);
ArmsUtils.makeText(this, message);
}
@Override
......
......@@ -192,7 +192,7 @@ public class OrderPayActivity extends BaseActivity<OrderPayPresenter> implements
private void initTopInfo() {
Date dd = new Date(OpenTableManage.getDefault().getTableBean().getCreateTime());
Date dd = MyOrderManage.getInstance().getOpenTableTime();
String openTime = String.format("%tH:%tM", dd, dd);
String tableno = "";
......@@ -203,9 +203,9 @@ public class OrderPayActivity extends BaseActivity<OrderPayPresenter> implements
}
btn_table.setText(tableno);
tv_time.setText("開檯時間" + openTime);
tv_time.setText("時間:" + openTime);
btn_people_num.setText(OpenTableManage.getDefault().getPeopleNumber() + "");
tv_server_main.setText("waiter:" + GsaCloudApplication.getMemberName(this));
tv_server_main.setText( GsaCloudApplication.getMemberName(this));
tv_action_name.setBackgroundColor(Color.parseColor("#C50000"));
tv_action_name.setText("結賬");
......
......@@ -11,6 +11,7 @@ import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.table.R;
......@@ -31,6 +32,7 @@ import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.gingersoft.gsa.cloud.table.mvp.contract.TableContract;
import com.gingersoft.gsa.cloud.table.mvp.presenter.TablePresenter;
import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton;
import com.qmuiteam.qmui.layout.QMUIButton;
import com.qmuiteam.qmui.widget.QMUITopBar;
......@@ -154,6 +156,24 @@ public class TableActivity extends BaseActivity<TablePresenter> implements Table
killMyself();
}
});
QMUIAlphaImageButton rightButton = mTopBar.addRightImageButton(R.drawable.icon_refresh, R.id.btn_right);
QMUIAlphaImageButton rightButton2 = mTopBar.addRightImageButton(R.mipmap.meal_down, R.id.btn_fid);
rightButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPresenter.getTables(true);
}
});
rightButton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CC.obtainBuilder("Component.Download")
.setActionName("showDownloadActivity")
.build()
.call();
}
});
mTopBar.setTitle("餐檯模式");
}
......
......@@ -69,6 +69,7 @@ public class BottomFunctionAdapter extends DefaultAdapter<Function> {
private void initItemData(Function item) {
tv_name.setText(item.getResName());
iv_icon.setImageResource(Integer.parseInt(item.getImageURL()));
}
......
package com.gingersoft.gsa.cloud.table.mvp.ui.adapter.meal;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
......@@ -12,7 +10,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.FoodCombo;
import com.gingersoft.gsa.cloud.database.bean.Modifier;
import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.R2;
......@@ -33,7 +31,7 @@ import butterknife.BindView;
* 描述:
*/
public class ComboAdapter extends DefaultAdapter<Combo> {
public class ComboAdapter extends DefaultAdapter<FoodCombo> {
private Context mContext;
......@@ -45,7 +43,7 @@ public class ComboAdapter extends DefaultAdapter<Combo> {
private int OrderNumberChildFontSize;
public ComboAdapter(Context context, List<Combo> infos) {
public ComboAdapter(Context context, List<FoodCombo> infos) {
super(infos);
this.mContext = context;
......@@ -64,7 +62,7 @@ public class ComboAdapter extends DefaultAdapter<Combo> {
}
@Override
public BaseHolder<Combo> getHolder(View v, int viewType) {
public BaseHolder<FoodCombo> getHolder(View v, int viewType) {
return new ComboItemHolder(v);
}
......@@ -73,7 +71,7 @@ public class ComboAdapter extends DefaultAdapter<Combo> {
return R.layout.table_item_combo;
}
class ComboItemHolder extends BaseHolder<Combo> {
class ComboItemHolder extends BaseHolder<FoodCombo> {
@BindView(R2.id.tv_name)
TextView tv_name;
......@@ -90,7 +88,7 @@ public class ComboAdapter extends DefaultAdapter<Combo> {
}
@Override
public void setData(Combo datasBean, int position) {
public void setData(FoodCombo datasBean, int position) {
iv_qty_sold.setVisibility(View.INVISIBLE);
tv_soldout.setVisibility(View.INVISIBLE);
......@@ -190,7 +188,7 @@ public class ComboAdapter extends DefaultAdapter<Combo> {
tv_soldout.setTextSize(OrderNumberChildFontSize);
}
private void initComboName(Combo datasBean) {
private void initComboName(FoodCombo datasBean) {
String Fname = datasBean.getName();
tv_name.setText(Fname);
tv_name.setTextSize(FontSize);
......@@ -198,7 +196,7 @@ public class ComboAdapter extends DefaultAdapter<Combo> {
initComboColor(datasBean);
}
private void initComboColor(Combo datasBean) {
private void initComboColor(FoodCombo datasBean) {
GradientDrawable drawable = new GradientDrawable();
drawable.setShape(GradientDrawable.RECTANGLE);
drawable.setGradientType(GradientDrawable.RECTANGLE);
......@@ -226,7 +224,7 @@ public class ComboAdapter extends DefaultAdapter<Combo> {
public interface OnItemClickListener {
void onItemClick(Combo datasBean, int position);
void onItemClick(FoodCombo datasBean, int position);
}
}
......@@ -181,8 +181,8 @@ public class FoodAdapter extends DefaultAdapter<Food> {
tv_soldout.setVisibility(View.INVISIBLE);
iv_qtySold.setVisibility(View.INVISIBLE);
long isSold = datasBean.getIsSold();
if (isSold == 1) {
long Invisible = datasBean.getInvisible();
if (Invisible == 2) {
iv_qtySold.setVisibility(View.VISIBLE);
} else {
iv_qtySold.setVisibility(View.INVISIBLE);
......@@ -209,6 +209,9 @@ public class FoodAdapter extends DefaultAdapter<Food> {
}
return;
}
for (int i = 0; i < mInfos.size(); i++) {
mInfos.get(i).setSelected(false);
}
if (currentSelectPosition == 0 || currentSelectPosition != position) {
if (currentSelectPosition < mInfos.size()) {
......@@ -218,8 +221,9 @@ public class FoodAdapter extends DefaultAdapter<Food> {
}
//设置当前选中item颜色
if (datasBean != null)
datasBean.setSelected(true);
notifyItemChanged(position);
notifyDataSetChanged();
//保存上次操作的position
currentSelectPosition = position;
......
......@@ -7,12 +7,14 @@ import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.R2;
import com.jess.arms.base.BaseHolder;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.DeviceUtils;
import java.util.List;
......@@ -31,7 +33,7 @@ public class FoodGroupAdapter extends DefaultAdapter<Food> {
private Context mContext;
// private List<Color.DatasBean> mColorList;
// private List<Color.DatasBean> mColorList;
private int mOrderNumberShowSize;
private int mOrderNumberFontSize;
private int FoodTypeFontSize;
......@@ -47,14 +49,14 @@ public class FoodGroupAdapter extends DefaultAdapter<Food> {
super(infos);
this.mContext = context;
// this.mOrderNumberShowSize = GSAApplication.androidSetting.getOrderNumberShowSize();
// this.mOrderNumberFontSize = GSAApplication.androidSetting.getOrderNumberFontSize();
// this.FoodTypeFontSize = GSAApplication.androidSetting.getFoodTypeFontSize();
// int foodCol = GSAApplication.androidSetting.getFoodTypeCol();
// this.mParentColWidth = (int) (DeviceUtils.getScreenWidth(context) / foodCol);
//
// this.mParentColHeight = GSAApplication.androidSetting.getLayoutFoodTypeHeight() / GSAApplication.androidSetting.getFoodTypeRow();
// this.mLayoutQtyHeight = GSAApplication.androidSetting.getLayoutQtyHeight();
this.mOrderNumberShowSize = GsaCloudApplication.androidSetting.getOrderNumberShowSize();
this.mOrderNumberFontSize = GsaCloudApplication.androidSetting.getOrderNumberFontSize();
this.FoodTypeFontSize = GsaCloudApplication.androidSetting.getFoodTypeFontSize();
int foodCol = GsaCloudApplication.androidSetting.getFoodTypeCol();
this.mParentColWidth = (int) (DeviceUtils.getScreenWidth(context) / foodCol);
this.mParentColHeight = GsaCloudApplication.androidSetting.getLayoutFoodTypeHeight() / GsaCloudApplication.androidSetting.getFoodTypeRow();
this.mLayoutQtyHeight = GsaCloudApplication.androidSetting.getLayoutQtyHeight();
//
// Db_Color dc = new Db_Color(context);
// mColorList = dc.query("");
......@@ -103,19 +105,17 @@ public class FoodGroupAdapter extends DefaultAdapter<Food> {
@Override
public void onViewClick(View view, int position) {
if (mOnItemClickListener != null) {
for (int i = 0; i < mInfos.size(); i++) {
mInfos.get(i).setSelected(false);
}
if (currentSelectPosition != position) {
//设置当前选中item颜色
datasBean.setSelected(true);
tv_name.setBackgroundColor(mContext.getResources().getColor(R.color.colorAccent));
//重置上次选中item的颜色
mInfos.get(currentSelectPosition).setSelected(false);
notifyItemChanged(currentSelectPosition, 1);
tv_name.setBackgroundColor(mContext.getResources().getColor(R.color.orange_500));
//保存上次操作的position
currentSelectPosition = position;
}
notifyDataSetChanged();
mOnItemClickListener.onItemClick(datasBean, position);
}
}
......@@ -124,7 +124,7 @@ public class FoodGroupAdapter extends DefaultAdapter<Food> {
public void setFoodGroup(Food datasBean) {
// String desc = "";
// switch (GSAApplication.androidSetting.getDataLanguage()) {
// switch (GsaCloudApplication.androidSetting.getDataLanguage()) {
// case 1:
// desc = datasBean.getDesc1();
// break;
......@@ -151,7 +151,7 @@ public class FoodGroupAdapter extends DefaultAdapter<Food> {
tv_name.setHeight(mParentColHeight);
tv_name.setGravity(Gravity.CENTER);
GridLayoutManager.LayoutParams lp = (GridLayoutManager.LayoutParams) rl_container.getLayoutParams();
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) rl_container.getLayoutParams();
lp.height = mParentColHeight;
lp.width = mParentColWidth;
rl_container.setLayoutParams(lp);
......@@ -224,7 +224,7 @@ public class FoodGroupAdapter extends DefaultAdapter<Food> {
// tv_soldout.setVisibility(View.INVISIBLE);
// } else {
// tv_soldout.setVisibility(View.VISIBLE);
tv_soldout.setText(datasBean.getNumber());
// tv_soldout.setText(datasBean.getNumber());
// }
/**
......
......@@ -16,10 +16,12 @@ import com.gingersoft.gsa.cloud.table.di.component.DaggerAllTableComponent;
import com.gingersoft.gsa.cloud.table.mvp.contract.AllTableContract;
import com.gingersoft.gsa.cloud.table.mvp.presenter.AllTablePresenter;
import com.gingersoft.gsa.cloud.table.mvp.ui.activity.TableActivity;
import com.gingersoft.gsa.cloud.ui.recylcler.decorator.GridDividerItemDecoration;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import java.util.List;
......@@ -203,9 +205,7 @@ public class AllTableFragment extends BaseFragment<AllTablePresenter> implements
// } else {
mAllTableRecycleLayoutManager = new GridLayoutManager(getActivity(), 4, LinearLayoutManager.VERTICAL, false);
recycle_all_table.setLayoutManager(mAllTableRecycleLayoutManager);
recycle_all_table.setItemAnimator(new DefaultItemAnimator());
recycle_all_table.addItemDecoration(new DividerItemDecoration(getActivity(), LinearLayoutManager.HORIZONTAL));
recycle_all_table.addItemDecoration(new DividerItemDecoration(getActivity(), LinearLayoutManager.VERTICAL));
recycle_all_table.addItemDecoration(new GridDividerItemDecoration(QMUIDisplayHelper.dpToPx(1), ArmsUtils.getColor(getActivity(), R.color.theme_grey_color)));
// }
}
}
......@@ -16,10 +16,12 @@ import com.gingersoft.gsa.cloud.table.di.component.DaggerStateTableComponent;
import com.gingersoft.gsa.cloud.table.mvp.contract.StateTableContract;
import com.gingersoft.gsa.cloud.table.mvp.presenter.StateTablePresenter;
import com.gingersoft.gsa.cloud.table.mvp.ui.activity.TableActivity;
import com.gingersoft.gsa.cloud.ui.recylcler.decorator.GridDividerItemDecoration;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import java.util.List;
......@@ -109,7 +111,7 @@ public class StateTableFragment extends BaseFragment<StateTablePresenter> implem
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action){
switch (action) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE: //用户滑动 先停止刷新餐台数据
mActivity.onPauseRefreshTableData();
......@@ -137,7 +139,7 @@ public class StateTableFragment extends BaseFragment<StateTablePresenter> implem
//recycleView正在滑动
if (recycle_state_table.getScrollState() != 0) {
} else {
mPresenter.updateAllTableData(mActivity, datasBeans,status);
mPresenter.updateAllTableData(mActivity, datasBeans, status);
}
}
break;
......@@ -205,9 +207,7 @@ public class StateTableFragment extends BaseFragment<StateTablePresenter> implem
// } else {
mStateTableRecycleLayoutManager = new GridLayoutManager(getActivity(), 4, LinearLayoutManager.VERTICAL, false);
recycle_state_table.setLayoutManager(mStateTableRecycleLayoutManager);
recycle_state_table.setItemAnimator(new DefaultItemAnimator());
recycle_state_table.addItemDecoration(new DividerItemDecoration(getActivity(), LinearLayoutManager.HORIZONTAL));
recycle_state_table.addItemDecoration(new DividerItemDecoration(getActivity(), LinearLayoutManager.VERTICAL));
recycle_state_table.addItemDecoration(new GridDividerItemDecoration(QMUIDisplayHelper.dpToPx(1), ArmsUtils.getColor(getActivity(), R.color.theme_grey_color)));
// }
}
}
......@@ -64,57 +64,57 @@
android:id="@+id/btn_fid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:background="@drawable/ui_selector_item_background"
android:text="PLU"
android:drawablePadding="@dimen/dp_1"
android:drawableTop="@drawable/meal_info"
android:gravity="center"
android:textColor="@color/theme_black"
android:text="PLU"
android:textAllCaps="false"
android:layout_marginTop="@dimen/dp_5"
android:textColor="@color/theme_black"
android:textSize="@dimen/sp_12" />
<TextView
android:id="@+id/btn_meal_delete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="刪除"
android:drawablePadding="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_8"
android:background="@drawable/ui_selector_item_background"
android:drawablePadding="@dimen/dp_1"
android:drawableTop="@drawable/meal_delete"
android:gravity="center"
android:text="刪除"
android:textAllCaps="false"
android:layout_marginTop="@dimen/dp_8"
android:textColor="@color/theme_black"
android:textSize="@dimen/sp_12" />
<!-- <TextView-->
<!-- android:id="@+id/btn_food_mode"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="堂食"-->
<!-- android:background="@drawable/ui_selector_item_background"-->
<!-- android:drawablePadding="@dimen/dp_1"-->
<!-- android:textAllCaps="false"-->
<!-- android:gravity="center"-->
<!-- android:layout_marginTop="@dimen/dp_8"-->
<!-- android:drawableTop="@drawable/meal_hall_mode"-->
<!-- android:textColor="@color/theme_black"-->
<!-- android:textSize="@dimen/sp_12"/>-->
<!-- <TextView-->
<!-- android:id="@+id/btn_meal_discount"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="折扣"-->
<!-- android:drawablePadding="@dimen/dp_1"-->
<!-- android:layout_marginTop="@dimen/dp_8"-->
<!-- android:background="@drawable/ui_selector_item_background"-->
<!-- android:textAllCaps="false"-->
<!-- android:gravity="center"-->
<!-- android:drawableTop="@drawable/meal_discount"-->
<!-- android:textColor="@color/theme_black"-->
<!-- android:textSize="@dimen/sp_12"/>-->
<!-- <TextView-->
<!-- android:id="@+id/btn_food_mode"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="堂食"-->
<!-- android:background="@drawable/ui_selector_item_background"-->
<!-- android:drawablePadding="@dimen/dp_1"-->
<!-- android:textAllCaps="false"-->
<!-- android:gravity="center"-->
<!-- android:layout_marginTop="@dimen/dp_8"-->
<!-- android:drawableTop="@drawable/meal_hall_mode"-->
<!-- android:textColor="@color/theme_black"-->
<!-- android:textSize="@dimen/sp_12"/>-->
<!-- <TextView-->
<!-- android:id="@+id/btn_meal_discount"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="折扣"-->
<!-- android:drawablePadding="@dimen/dp_1"-->
<!-- android:layout_marginTop="@dimen/dp_8"-->
<!-- android:background="@drawable/ui_selector_item_background"-->
<!-- android:textAllCaps="false"-->
<!-- android:gravity="center"-->
<!-- android:drawableTop="@drawable/meal_discount"-->
<!-- android:textColor="@color/theme_black"-->
<!-- android:textSize="@dimen/sp_12"/>-->
<!-- <ImageButton-->
<!-- android:id="@+id/btn_meal_discount"-->
......@@ -124,40 +124,40 @@
<!-- android:layout_weight="1"-->
<!-- android:src="@drawable/meal_discount" />-->
<!-- <TextView-->
<!-- android:id="@+id/btn_temporary"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:background="@drawable/ui_selector_item_background"-->
<!-- android:text="暫存"-->
<!-- android:layout_marginTop="@dimen/dp_8"-->
<!-- android:gravity="center"-->
<!-- android:textAllCaps="false"-->
<!-- android:textColor="@color/theme_black"-->
<!-- android:visibility="visible"-->
<!-- android:drawableTop="@drawable/meal_temporary"-->
<!-- android:textSize="@dimen/sp_12"/>-->
<!-- <ImageButton-->
<!-- android:id="@+id/btn_meal_modify_restore"-->
<!-- style="@style/ButtonBorderless"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:src="@drawable/meal_modify_restore" />-->
<!-- <ImageButton-->
<!-- android:id="@+id/btn_change_Language"-->
<!-- style="@style/ButtonBorderless"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:src="@drawable/meal_change_language_index_1" />-->
<!-- <ImageButton-->
<!-- android:id="@+id/btn_food_merge"-->
<!-- style="@style/ButtonBorderless"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:src="@drawable/meal_food_merge" />-->
<!-- <TextView-->
<!-- android:id="@+id/btn_temporary"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:background="@drawable/ui_selector_item_background"-->
<!-- android:text="暫存"-->
<!-- android:layout_marginTop="@dimen/dp_8"-->
<!-- android:gravity="center"-->
<!-- android:textAllCaps="false"-->
<!-- android:textColor="@color/theme_black"-->
<!-- android:visibility="visible"-->
<!-- android:drawableTop="@drawable/meal_temporary"-->
<!-- android:textSize="@dimen/sp_12"/>-->
<!-- <ImageButton-->
<!-- android:id="@+id/btn_meal_modify_restore"-->
<!-- style="@style/ButtonBorderless"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:src="@drawable/meal_modify_restore" />-->
<!-- <ImageButton-->
<!-- android:id="@+id/btn_change_Language"-->
<!-- style="@style/ButtonBorderless"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:src="@drawable/meal_change_language_index_1" />-->
<!-- <ImageButton-->
<!-- android:id="@+id/btn_food_merge"-->
<!-- style="@style/ButtonBorderless"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:src="@drawable/meal_food_merge" />-->
</LinearLayout>
</ScrollView>
</LinearLayout>
......@@ -176,15 +176,15 @@
android:layout_width="match_parent"
android:layout_height="42dp">
<!-- <Button-->
<!-- android:id="@+id/btn_key0"-->
<!-- style="@style/ButtonBorderless"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_weight="0.01"-->
<!-- android:background="@drawable/meal_selector_number_keys"-->
<!-- android:tag="1"-->
<!-- android:text="@string/Key_0" />-->
<!-- <Button-->
<!-- android:id="@+id/btn_key0"-->
<!-- style="@style/ButtonBorderless"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_weight="0.01"-->
<!-- android:background="@drawable/meal_selector_number_keys"-->
<!-- android:tag="1"-->
<!-- android:text="@string/Key_0" />-->
<Button
android:id="@+id/btn_key1"
......@@ -242,8 +242,8 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.00"
android:src="@mipmap/meal_number_key"
android:background="@drawable/meal_selector_number_keys"
android:src="@mipmap/meal_number_key"
android:tag="99" />
</LinearLayout>
</LinearLayout>
......@@ -327,12 +327,35 @@
android:textColor="@drawable/ui_selector_white_press"
android:textSize="@dimen/sp_17" />
<!-- <TextView-->
<!-- android:id="@+id/tv_send_order"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_weight="1"-->
<!-- android:background="@color/Grass_green"-->
<!-- android:gravity="center"-->
<!-- android:text="send order"-->
<!-- android:textAppearance="?android:attr/textAppearanceLarge"-->
<!-- android:textColor="@drawable/selector_pressed_state_black"-->
<!-- android:textSize="@dimen/sp_17" />-->
<FrameLayout
android:id="@+id/fl_order_content"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@color/orange_500"
android:layout_weight="1">
android:layout_weight="1"
android:background="@color/orange_500">
<Button
android:id="@+id/btn_order_count"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_margin="@dimen/dp_2"
android:background="@drawable/ui_shape_red_oval"
android:singleLine="true"
android:textColor="@color/theme_white_color"
android:visibility="invisible" />
<TextView
android:id="@+id/tv_order_content"
......@@ -343,30 +366,8 @@
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@drawable/ui_selector_black_press"
android:textSize="@dimen/sp_17" />
<Button
android:id="@+id/btn_order_count"
android:layout_width="18dp"
android:layout_height="18dp"
android:background="@drawable/ui_shape_red_oval"
android:singleLine="true"
android:layout_margin="@dimen/dp_2"
android:visibility="invisible"
android:textColor="@color/theme_white_color" />
</FrameLayout>
<!-- <TextView-->
<!-- android:id="@+id/tv_send_order"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_weight="1"-->
<!-- android:background="@color/Grass_green"-->
<!-- android:gravity="center"-->
<!-- android:text="send order"-->
<!-- android:textAppearance="?android:attr/textAppearanceLarge"-->
<!-- android:textColor="@drawable/selector_pressed_state_black"-->
<!-- android:textSize="@dimen/sp_17" />-->
<FrameLayout
android:id="@+id/fl_send_order"
android:layout_width="0dp"
......@@ -378,10 +379,10 @@
android:id="@+id/btn_send_order"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:gravity="center"
android:text="送單"
android:textColor="@drawable/ui_selector_black_press"
android:background="@android:color/transparent"
android:textSize="@dimen/sp_17" />
</FrameLayout>
......@@ -391,31 +392,59 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:visibility="gone"
android:background="@color/blue_500">
android:background="@color/blue_500"
android:visibility="gone">
<Button
android:id="@+id/btn_order_printer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:gravity="center"
android:text="@string/meal_print"
android:textColor="@drawable/ui_selector_black_press"
android:background="@android:color/transparent"
android:textSize="@dimen/sp_17" />
<Button
android:id="@+id/btn_printer_machine_name"
android:layout_width="40dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/ui_shape_red_oval"
android:gravity="center"
android:singleLine="true"
android:visibility="gone"
android:textColor="@color/theme_white_color" />
android:textColor="@color/theme_white_color"
android:visibility="gone" />
</FrameLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_food_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/ll_meals"
android:orientation="vertical">
<!-- <androidx.viewpager.widget.ViewPager-->
<!-- android:id="@+id/vp_food_group"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="1"/>-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food_group"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/ll_food_group_point"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_5"
android:background="@color/theme_grey_color"
android:orientation="horizontal"
android:visibility="invisible" />
</LinearLayout>
<RelativeLayout
......@@ -452,14 +481,6 @@
app:theme="@style/AppTheme" />
</RelativeLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/pager_fine"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/ll_stand_oper"
android:layout_below="@+id/rl_fine_tabs"
android:visibility="invisible" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_combo"
android:layout_width="match_parent"
......@@ -482,36 +503,14 @@
android:orientation="vertical"
android:visibility="gone" />
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/rv_food_group"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_below="@+id/ll_meals"-->
<!-- android:divider="@null"-->
<!-- android:fadeScrollbars="false"-->
<!-- android:orientation="vertical" />-->
<LinearLayout
android:id="@+id/ll_food_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/ll_meals">
<androidx.viewpager.widget.ViewPager
android:id="@+id/vp_food_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<LinearLayout
android:id="@+id/ll_food_group_point"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_5"
android:visibility="invisible"
android:background="@color/theme_grey_color"
android:orientation="horizontal" />
</LinearLayout>
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/rv_food_group"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_below="@+id/ll_meals"-->
<!-- android:divider="@null"-->
<!-- android:fadeScrollbars="false"-->
<!-- android:orientation="vertical" />-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food"
......@@ -523,6 +522,14 @@
android:fadeScrollbars="false"
android:orientation="vertical" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/pager_fine"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/ll_stand_oper"
android:layout_below="@+id/rl_fine_tabs"
android:visibility="invisible" />
<!--鍵盤-->
<com.gingersoft.gsa.cloud.ui.view.SearchKeyBoardView
android:id="@+id/meal_stand_search_keyboard_view"
......@@ -532,5 +539,4 @@
android:layout_below="@+id/ll_meals"
android:visibility="gone" />
</RelativeLayout>
\ No newline at end of file
......@@ -91,9 +91,9 @@
android:divider="@null"
android:fadeScrollbars="false"
android:orientation="vertical"
android:background="@color/theme_white_color"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<TextView
android:id="@+id/tv_whole"
android:layout_width="match_parent"
......@@ -102,8 +102,9 @@
android:textSize="@dimen/font_large"
android:textStyle="bold"
android:textColor="@color/theme_text_color"
android:layout_marginBottom="@dimen/dp_20"
android:paddingBottom="@dimen/dp_20"
android:paddingRight="@dimen/dp_10"
android:background="@color/theme_white_color"
android:gravity="right|center_vertical"/>
......
......@@ -72,7 +72,7 @@
<com.qmuiteam.qmui.layout.QMUIButton
android:id="@+id/btn_cancel_operat"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_48"
android:layout_height="@dimen/dp_55"
android:textColor="@color/theme_white_color"
android:background="@color/theme_grey_color"
android:layout_alignParentBottom="true"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/dp_55"
android:gravity="center"
android:orientation="vertical"
android:background="@drawable/ui_selector_item_background">
......
......@@ -67,7 +67,7 @@ public class LoginPresenter extends BasePresenter<LoginContract.Model, LoginCont
if (account.equals("")) {
requestBody = new FormBody.Builder()
.add("userName", "admin")
.add("userName", "1")
.add("passWord", "123456")
.build();
// requestBody = new FormBody.Builder()
......@@ -83,7 +83,7 @@ public class LoginPresenter extends BasePresenter<LoginContract.Model, LoginCont
mModel.login(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
......@@ -114,7 +114,7 @@ public class LoginPresenter extends BasePresenter<LoginContract.Model, LoginCont
mModel.loginOut(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
......
......@@ -3,6 +3,7 @@ package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
......@@ -11,11 +12,13 @@ import android.widget.ImageView;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.ui.bean.mode.LoginBean;
import com.gingersoft.gsa.cloud.ui.bean.view.SectionTextItem;
import com.gingersoft.gsa.cloud.ui.widget.dialog.ChooseRestaurantDialog;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.gingersoft.gsa.cloud.user.login.R;
import com.gingersoft.gsa.cloud.user.login.R2;
import com.gingersoft.gsa.cloud.user.login.di.component.DaggerLoginComponent;
......@@ -26,6 +29,7 @@ import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.NonNull;
......@@ -76,6 +80,15 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
// String token = GsaCloudApplication.getLoginToken(this);
// if (!TextUtils.isEmpty(token)) {
// jumpMainActivity();
// }
super.onCreate(savedInstanceState);
}
@Override
public int initView(@Nullable Bundle savedInstanceState) {
return R.layout.user_login_activity_login; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
}
......@@ -157,19 +170,21 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login
@Override
public void showLoading(String message) {
if (message != null)
LoadingDialog.showDialogForLoading(this, message, true);
else
LoadingDialog.showDialogForLoading(this);
}
@Override
public void hideLoading() {
LoadingDialog.cancelDialogForLoading();
}
@Override
public void showMessage(@NonNull String message) {
checkNotNull(message);
// ArmsUtils.snackbarText(message);
ToastUtils.show(mContext, message);
if (message != null)
ArmsUtils.makeText(this, message);
}
@Override
......@@ -185,6 +200,9 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login
@Override
public void loginSuccess(LoginBean loginBean) {
GsaCloudApplication.setBrandRestaurantInfos(this, "");
if (loginBean.getData() != null) {
GsaCloudApplication.setLoginToken(LoginActivity.this, loginBean.getData().getToken());
......@@ -194,30 +212,45 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login
GsaCloudApplication.setMemberId(LoginActivity.this, loginBean.getData().getUser().getUserId());
GsaCloudApplication.setMemberName(LoginActivity.this, loginBean.getData().getUser().getUserName());
List<LoginBean.DataBean.UserBean.BrandsBean> brands = loginBean.getData().getUser().getBrands();
if (brands != null) {
String brandRestaurantInfos = JsonUtils.toJson(brands);
GsaCloudApplication.setBrandRestaurantInfos(this, brandRestaurantInfos);
}
int restaurantSize = 0;
List<LoginBean.DataBean.UserBean.BrandsBean> brandsBeans = new ArrayList<>();
if (loginBean.getData().getUser().getBrands() != null) {
int restaurantSize = getRestaurantSize(loginBean.getData().getUser().getBrands());
// if (restaurantSize > 1) {
restaurantSize = getRestaurantSize(loginBean.getData().getUser().getBrands());
brandsBeans.addAll(loginBean.getData().getUser().getBrands());
}
if (restaurantSize == 1) {
//只有一個品牌是直接進下載頁面
LoginBean.DataBean.UserBean.BrandsBean brandsBean = getOnlyBrand(loginBean.getData().getUser().getBrands());
LoginBean.DataBean.UserBean.BrandsBean.RestaurantsBean restaurantsBean = getOnlyRestaurant(loginBean.getData().getUser().getBrands());
if (brandsBean != null) {
saveBrandAndRestaurantInfo(brandsBean.getBrandId(), brandsBean.getBrandName(), restaurantsBean.getRestaurantId(), restaurantsBean.getRestaurantName());
}
jumpDownloadActivity();
} else {
new ChooseRestaurantDialog.BottomListSheetBuilder(this)
.addBrandItems(loginBean.getData().getUser().getBrands())
.addBrandItems(brandsBeans)
.setOnItemClickListener(new ChooseRestaurantDialog.BottomListSheetBuilder.OnItemClickListener() {
@Override
public void onItemClick(ChooseRestaurantDialog dialog, SectionTextItem item, int position) {
GsaCloudApplication.setRestaurantId(LoginActivity.this, item.getId());
GsaCloudApplication.setRestaurantName(LoginActivity.this, item.getText());
jumpActivity();
// killMyself();
LoginBean.DataBean.UserBean.BrandsBean brandsBean = getBrandByRestaurantId(brands, item.getId());
if (brandsBean != null) {
saveBrandAndRestaurantInfo(brandsBean.getBrandId(), brandsBean.getBrandName(), item.getId(), item.getText());
}
jumpDownloadActivity();
killMyself();
// dialog.dismiss();
}
})
.build()
.show();
// } else if (restaurantSize == 1) {
// LoginBean.DataBean.UserBean.BrandsBean.RestaurantsBean restaurantsBean = getOnlyRestaurant(loginBean.getData().getUser().getBrands());
// if (restaurantsBean != null) {
// GsaCloudApplication.setRestaurantId(LoginActivity.this, restaurantsBean.getRestaurantId());
// }
// }
}
}
}
......@@ -232,6 +265,13 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login
// jumpActivity();
}
private void saveBrandAndRestaurantInfo(int brandId, String brandName, int restaurantId, String restaurantName) {
GsaCloudApplication.setBrandId(LoginActivity.this, brandId);
GsaCloudApplication.setBrandName(LoginActivity.this, brandName);
GsaCloudApplication.setRestaurantId(LoginActivity.this, restaurantId);
GsaCloudApplication.setRestaurantName(LoginActivity.this, restaurantName);
}
private int getRestaurantSize(List<LoginBean.DataBean.UserBean.BrandsBean> brands) {
int size = 0;
for (int i = 0; i < brands.size(); i++) {
......@@ -241,6 +281,17 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login
return size;
}
private LoginBean.DataBean.UserBean.BrandsBean getOnlyBrand(List<LoginBean.DataBean.UserBean.BrandsBean> brands) {
for (int i = 0; i < brands.size(); i++) {
if (brands.get(i).getRestaurants() != null) {
for (int j = 0; j < brands.get(i).getRestaurants().size(); j++) {
return brands.get(i);
}
}
}
return null;
}
private LoginBean.DataBean.UserBean.BrandsBean.RestaurantsBean getOnlyRestaurant(List<LoginBean.DataBean.UserBean.BrandsBean> brands) {
for (int i = 0; i < brands.size(); i++) {
if (brands.get(i).getRestaurants() != null) {
......@@ -252,20 +303,40 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login
return null;
}
private void jumpActivity() {
private LoginBean.DataBean.UserBean.BrandsBean getBrandByRestaurantId(List<LoginBean.DataBean.UserBean.BrandsBean> brands, int restaurantId) {
for (int i = 0; i < brands.size(); i++) {
if (brands.get(i).getRestaurants() != null) {
for (int j = 0; j < brands.get(i).getRestaurants().size(); j++) {
if (brands.get(i).getRestaurants().get(j).getRestaurantId() == restaurantId) {
return brands.get(i);
}
}
}
}
return null;
}
private void jumpDownloadActivity() {
CC.obtainBuilder("Component.Download")
.setActionName("showDownloadActivity")
.build()
.call();
}
private void jumpMainActivity() {
CC.obtainBuilder("Component.Main")
.setActionName("showMainActivity")
.build()
.call();
}
@Override
public void loginOut() {
}
@Override
@OnClick({R.id.tv_gsa_user_login, R.id.iv_clear_pwd, R.id.iv_clear_account})
@OnClick({R2.id.tv_gsa_user_login, R2.id.iv_clear_pwd, R2.id.iv_clear_account})
public void onClick(View v) {
switch (v.getId()) {
case R.id.tv_gsa_user_login:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment