Commit bc11e1a2 by Wyh

1、供應鏈SN食材代碼提交 2、自動登錄加上餐廳人數校驗 3、baseCategory類

parent 9427843b
......@@ -138,9 +138,7 @@ public class BaseLoginPresenter<M extends BaseLoginContract.Model, V extends Bas
@Override
public void onNext(BaseResult s) {
if (s != null && s.isSuccess()) {
List<LoginLimitBean> loginLimitBeans = new Gson().fromJson(GsonUtils.GsonString(s.getData()), new TypeToken<List<LoginLimitBean>>() {
}.getType());
// List<LoginLimitBean> logins = GsonUtils.GsonToList("", LoginLimitBean.class);
List<LoginLimitBean> loginLimitBeans = GsonUtils.jsonToList(s.getData(), LoginLimitBean.class);
if (loginLimitBeans == null || loginLimitBeans.size() <= 0) {
if (isDownload) {
mRootView.jumpDownloadActivity();
......
......@@ -4,14 +4,12 @@ import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.ImageView;
......@@ -33,27 +31,19 @@ import com.gingersoft.gsa.cloud.login.mvp.contract.LoginInterfaceImpl;
import com.gingersoft.gsa.cloud.login.mvp.presenter.LoginPresenter;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.google.android.material.textfield.TextInputEditText;
import com.gyf.immersionbar.BarHide;
import com.gyf.immersionbar.ImmersionBar;
import com.gyf.immersionbar.OnKeyboardListener;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.integration.AppManager;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.StatusBarUtil;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.OnClick;
import me.jessyan.autosize.utils.LogUtils;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -361,6 +351,7 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
}
@OnClick({R2.id.btn_gsa_user_login, R2.id.iv_clear_pwd, R2.id.iv_clear_account, R2.id.ic_look_pwd, R2.id.tv_forget_pwd})
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.ic_look_pwd:
......
......@@ -142,7 +142,9 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
int restaurantId = RestaurantInfoManager.newInstance().getRestaurantId();
if (restaurantId != 0) {
//已经选择过餐厅 直接进入
jumpDownloadActivity();
// jumpDownloadActivity();
//需要驗證登陸人數
mPresenter.getLoginLimit(restaurantId, true);
return;
}
//调整选择餐厅页面
......
......@@ -94,40 +94,6 @@ public class SalesPresenter extends BasePresenter<SalesContract.Model, SalesCont
});
}
/**
* 獲取微信公眾號的報表數據
*
* @param startTime
*/
public void getSalesReportInfo(String startTime) {
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", "26")
.add("startTime", startTime)
.add("endTime", TimeUtils.getOldDate(1))
.build();
mModel.getSalesReportInfo(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<SalesFoodsBean>(mErrorHandler) {
@Override
public void onNext(@NonNull SalesFoodsBean info) {
if (info != null && info.isSuccess()) {
if (info.getData() != null) {
// info.getData().removeAll(Collections.singleton(null));
// mRootView.loadInfo(info.getData());
}
} else {
mRootView.showMessage("銷售信息獲取失敗");
}
}
});
}
public void getDeliveryOrderCurveInfo(String restaurantId, String startTime, String endTime) {
Map<String, Object> map = new HashMap<>();
map.put("restaurantId", restaurantId);
......
......@@ -127,11 +127,17 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override
public void connectionSuccess() {
if(printerLoadingDialog == null){
return;
}
printerLoadingDialog.setStep(PrinterLoadingDialog.PROGRESS_PRINTING, PrinterLoadingDialog.STATUS_SUCCESS, null);
}
@Override
public void connectionError(Exception e) {
if(printerLoadingDialog == null){
return;
}
printerLoadingDialog.setStep(PrinterLoadingDialog.PROGRESS_PRINTING, PrinterLoadingDialog.STATUS_ERROR, e.getMessage());
printFail();
}
......@@ -142,23 +148,35 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override
public void onPrinterDataBefore(int orderType, int printType, String printerData, String printerDeviceInfo) {
if(printerLoadingDialog == null){
return;
}
printerLoadingDialog.setStep(PrinterLoadingDialog.PROGRESS_CONNECTING, PrinterLoadingDialog.STATUS_SUCCESS, null);
}
@Override
public void onPrinterBitmapBefore(int orderType, int printType, String directoryName, List<Bitmap> bitmaps) {
if(printerLoadingDialog == null){
return;
}
printerLoadingDialog.setStep(PrinterLoadingDialog.PROGRESS_CONNECTING, PrinterLoadingDialog.STATUS_SUCCESS, null);
}
@Override
public void onPrintSuccess() {
printerResult = true;
if(printerLoadingDialog == null){
return;
}
printerLoadingDialog.setStep(PrinterLoadingDialog.PROGRESS_RESULT, PrinterLoadingDialog.STATUS_SUCCESS, null);
printSuccess();
}
@Override
public void onPrintError(Exception e, int errorCode) {
if(printerLoadingDialog == null){
return;
}
printerLoadingDialog.setStep(PrinterLoadingDialog.PROGRESS_RESULT, PrinterLoadingDialog.STATUS_ERROR, e.getMessage());
printFail();
}
......
......@@ -7,6 +7,7 @@
<!--相机权限-->
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
......@@ -27,15 +28,15 @@
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
<!-- <provider-->
<!-- android:name="androidx.core.content.FileProvider"-->
<!-- android:authorities="${applicationId}.fileprovider"-->
<!-- android:exported="false"-->
<!-- android:grantUriPermissions="true">-->
<!-- <meta-data-->
<!-- android:name="android.support.FILE_PROVIDER_PATHS"-->
<!-- android:resource="@xml/gsa_purchase_paths" />-->
<!-- </provider>-->
<provider
android:name="com.gingersoft.supply_chain.mvp.utils.PurchaseFileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/gsa_purchase_paths" />
</provider>
</application>
</manifest>
\ No newline at end of file
package com.gingersoft.supply_chain.mvp.bean;
import java.util.List;
import java.util.Objects;
/**
* @author 宇航.
......@@ -26,4 +27,28 @@ public class BuyIngredientsBean {
* 食材信息
*/
public List<PurchaseFoodBean> purchaseFoodList;
public BuyIngredientsBean() {
}
public BuyIngredientsBean(int id, String categoryName, int parentId) {
this.id = id;
this.categoryName = categoryName;
this.parentId = parentId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BuyIngredientsBean that = (BuyIngredientsBean) o;
return id == that.id &&
parentId == that.parentId &&
Objects.equals(categoryName, that.categoryName);
}
@Override
public int hashCode() {
return Objects.hash(id, categoryName, parentId);
}
}
......@@ -3,6 +3,7 @@ package com.gingersoft.supply_chain.mvp.bean;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
import com.gingersoft.supply_chain.mvp.content.Constant;
import java.io.Serializable;
import java.util.List;
......@@ -52,8 +53,8 @@ public class ConfirmOrderBean {
PurchaseOrder purchaseOrder = new PurchaseOrder();
purchaseOrder.setSupplierId(shoppingCartBean.getSupplierId());
purchaseOrder.setSupplierName(shoppingCartBean.getSupplierName());
purchaseOrder.setBrandId(RestaurantInfoManager.newInstance().getBrandId());
purchaseOrder.setRestaurantId(RestaurantInfoManager.newInstance().getRestaurantId());
purchaseOrder.setBrandId(Constant.getBrandId());
purchaseOrder.setRestaurantId(Constant.getRestaurantId());
purchaseOrder.setRemarks(shoppingCartBean.getRemarks());
purchaseOrder.setInitialShippingTime(shoppingCartBean.getInitialShippingTime());
purchaseOrder.setShipping(shoppingCartBean.getShipping());
......
......@@ -2,6 +2,7 @@ package com.gingersoft.supply_chain.mvp.bean;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
import lombok.Data;
......@@ -25,6 +26,7 @@ public class OrderCategoryBean implements Serializable {
private int id;
private String name;
private int parentId;
private int size;
private List<FoodCategoryTrees> foodCategoryTrees;
/**
* 該分類下的食材信息,需要從接口獲取
......@@ -33,11 +35,32 @@ public class OrderCategoryBean implements Serializable {
public FoodCategoryTrees() {
}
public FoodCategoryTrees(int id, String name, int parentId) {
this.id = id;
this.name = name;
this.parentId = parentId;
}
public FoodCategoryTrees(int id) {
this.id = id;
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FoodCategoryTrees that = (FoodCategoryTrees) o;
return id == that.id &&
parentId == that.parentId &&
Objects.equals(name, that.name);
}
@Override
public int hashCode() {
return Objects.hash(id, name, parentId);
}
}
}
......@@ -59,6 +59,12 @@ public class WarehouseDetailsBean {
* 入庫詳情ids,逗號分隔
*/
private String warehousingOrderDetailsIds;
/**
* 出庫詳情ids,逗號分隔
*/
private String purchaseConsumeNoId;
public final static int WAREHOUSE_STATE_NEVER_CONSUMED = 1;
public final static int WAREHOUSE_STATE_PART_CONSUMED = 2;
public final static int WAREHOUSE_STATE_ALL_CONSUMED = 3;
......
......@@ -3,6 +3,7 @@ package com.gingersoft.supply_chain.mvp.content;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.BuildConfig;
import java.util.Map;
......@@ -60,22 +61,33 @@ public class Constant {
public static final String DELETE_SUCCESS = "刪除成功";
public static final String DELETE_FAIL = "刪除失敗,請稍後重試";
public static int getBrandId() {
// return RestaurantInfoManager.newInstance().getBrandId();
return BuildConfig.DEBUG ? 1 : RestaurantInfoManager.newInstance().getBrandId();
}
public static int getRestaurantId() {
// return RestaurantInfoManager.newInstance().getRestaurantId();
return BuildConfig.DEBUG ? 26 : RestaurantInfoManager.newInstance().getRestaurantId();
}
public static void addBrandId(@NonNull Map<String, Object> map) {
map.put("brandId", RestaurantInfoManager.newInstance().getBrandId());
map.put("brandId", getBrandId());
}
public static void addRestaurantId(@NonNull Map<String, Object> map) {
map.put("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId());
map.put("restaurantId", getRestaurantId());
}
public static void addBrandId(@NonNull FormBody.Builder builder) {
builder.add("brandId", String.valueOf(RestaurantInfoManager.newInstance().getBrandId()));
builder.add("brandId", String.valueOf(getBrandId()));
}
public static void addRestaurantId(@NonNull FormBody.Builder builder) {
builder.add("restaurantId", String.valueOf(RestaurantInfoManager.newInstance().getRestaurantId()));
builder.add("restaurantId", String.valueOf(getRestaurantId()));
}
public static void addPageSize(Map<String, Object> map) {
map.put("pageSize", PAGE_SIZE);
}
......
......@@ -51,9 +51,16 @@ public interface BuyIngredientsContract {
/**
* 加載食品
* @param food
* @param index 需要滾動到的位置
* @param buyIngredientsBeans 顯示的食材
*/
void loadFood(List<BuyIngredientsBean> buyIngredientsBeans);
void loadFood(int index, List<BuyIngredientsBean> buyIngredientsBeans);
/**
* 食材列表滾動到指定位置
* @param index 指定位置
*/
void scrollToPosition(int index);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
......
package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application;
import android.util.Log;
import com.gingersoft.gsa.cloud.common.utils.CollectionUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean;
......@@ -72,6 +74,11 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
*/
private boolean isLoadFood = false;
/**
* 用戶選購的食材列表
*/
private List<PurchaseFoodBean> purchaseFoodBeans = new ArrayList<>();
@Inject
public BuyIngredientsPresenter(BuyIngredientsContract.Model model, BuyIngredientsContract.View rootView) {
super(model, rootView);
......@@ -114,6 +121,13 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
categoryFoodTreeBeans = new ArrayList<>();
}
List<OrderCategoryBean.FoodCategoryTrees> data = orderCategoryBean.getData();
if (data != null) {
//將分類食品的list容量設置為一級分類的數量,這樣就不用擔心之後加載不同position的分類數據時,計算位置了
categoryFoods = new ArrayList<>(data.size());
for (OrderCategoryBean.FoodCategoryTrees ignored : data) {
categoryFoods.add(null);
}
}
conversionCategoryTree(data);
foodCategoryTrees = new ArrayList<>();
foodCategoryTrees.addAll(data);
......@@ -178,12 +192,61 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
// }
}
private List<List<BuyIngredientsBean>> categoryFoods = new ArrayList<>();
private List<List<BuyIngredientsBean>> supplierFoods = new ArrayList<>();
public void clearCategoryFoods() {
int categorySize = categoryFoods.size();
for (int i = 0; i < categorySize; i++) {
categoryFoods.set(i, null);
}
}
public boolean isHasLocationCategoryFoodInfo(int position) {
if (position >= categoryFoods.size()) {
return false;
}
return categoryFoods.get(position) != null;
}
/**
* 根據分類的下標獲得他的一級分類
*/
public int getFirstCategoryByIndex(int index) {
int progress = 0;
//一級分類的下標
int categoryIndex = 0;
for (List<BuyIngredientsBean> categoryFood : categoryFoods) {
if (CollectionUtils.isNotNullOrEmpty(categoryFood)) {
if (progress <= index) {
progress += categoryFood.size();
if (progress > index) {
return categoryIndex;
}
} else {
return categoryIndex;
}
}
categoryIndex++;
}
return -1;
}
// public void getLocationFood(){
// if (categoryFoods.get(position) != null) {
// Log.e("eee", "本地獲取");
// //將所有的兩層集合轉為一層
// List<BuyIngredientsBean> allShowFood = getAllShowFood();
// mRootView.scrollToPosition(getIndexInAllFood(allShowFood, categoryTrees));
// return;
// }
// }
/**
* 根據一級分類獲取下面所有包括子分類的食品
*/
public void getFoodByCategory(OrderCategoryBean.FoodCategoryTrees categoryTrees) {
public void getFoodByCategory(int position, OrderCategoryBean.FoodCategoryTrees categoryTrees) {
//先看看這個分類的食材有沒有緩存,沒有緩衝再加載
Map<String, Object> map = new HashMap<>(5);
map.put("pageSize", 1000);
map.put("pageIndex", 0);
......@@ -192,7 +255,9 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
map.put("parentId", categoryTrees.getId());
mModel.getFoodByCategory(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
.doOnSubscribe(disposable -> {
// mRootView.showLoading(Constant.GET_INFO_LOADING)
})
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterNext(dis -> mRootView.hideLoading())
......@@ -201,24 +266,21 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
@Override
public void onNext(@NonNull FoodByCategoryResultBean info) {
Log.e("eee", "網絡獲取:" + info.isSuccess() + "分類名:" + categoryTrees.getName());
if (info.isSuccess()) {
//保存分類下食品
savFoodToCategory(info);
List<BuyIngredientsBean> buyIngredientsBeans = new ArrayList<>();
//拿到所有食品
List<PurchaseFoodBean> foodBeans = info.getData();
if(foodBeans != null){
}
//
//這個接口是一級分類才調用,所以直接顯示所有食材,讓用戶可以滾動列表
//將食品和分類整合到一起,List<QMUISection<CategoryBean, PurchaseFoodBean>>
// val sections = foodToList(info.getData());
// foodSectionMap.put(parentCategoryId, sections);
// mRootView.loadFood(parentCategoryId, sections);
// mRootView.loadRightFoodIngredients(filterThisCategoryFood(categoryId, info.getData()));
//初始化分類和食品的顯示集合
List<BuyIngredientsBean> buyIngredientsBeans = new ArrayList<>();
conversionShowInfo(foodBeans, categoryTrees, buyIngredientsBeans, 0);
//將數據插入緩衝中
categoryFoods.set(position, buyIngredientsBeans);
//將所有的兩層集合轉為一層
List<BuyIngredientsBean> allShowFood = getAllShowFood();
//加載食品
mRootView.loadFood(getIndexInAllFood(allShowFood, categoryTrees), allShowFood);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
mRootView.loadFail();
......@@ -227,6 +289,41 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
}
}
@Override
public void onError(Throwable t) {
super.onError(t);
Log.e("eee", "網絡獲取出錯:分類名:" + categoryTrees.getName());
}
private void conversionShowInfo(List<PurchaseFoodBean> foodBeans, OrderCategoryBean.FoodCategoryTrees foodCategoryTree, List<BuyIngredientsBean> buyIngredientsBeans, int foodSize) {
BuyIngredientsBean buyIngredientsBean = new BuyIngredientsBean();
buyIngredientsBean.id = foodCategoryTree.getId();
buyIngredientsBean.parentId = foodCategoryTree.getParentId();
buyIngredientsBean.categoryName = foodCategoryTree.getName();
buyIngredientsBean.purchaseFoodList = new ArrayList<>();
if (foodBeans != null && foodSize != foodBeans.size()) {
boolean haveThisCategoryBean = true;
for (PurchaseFoodBean foodBean : foodBeans) {
if (foodBean.getFoodCategoryId() == foodCategoryTree.getId()) {
buyIngredientsBean.purchaseFoodList.add(foodBean);
haveThisCategoryBean = false;
foodSize++;
} else if (!haveThisCategoryBean) {
//因為食品是按順序排列,如果之前已經有這個分類的食品,後來沒了,之後的數據就不用遍歷了
break;
}
}
}
buyIngredientsBeans.add(buyIngredientsBean);
List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees = foodCategoryTree.getFoodCategoryTrees();
if (foodCategoryTrees != null) {
for (OrderCategoryBean.FoodCategoryTrees categoryTree : foodCategoryTrees) {
conversionShowInfo(foodBeans, categoryTree, buyIngredientsBeans, foodSize);
}
}
}
/**
* 保存食品信息到分類數據中
* @param info
......@@ -249,6 +346,26 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
});
}
private List<BuyIngredientsBean> getAllShowFood() {
List<BuyIngredientsBean> buyIngredientsBeans = new ArrayList<>();
for (List<BuyIngredientsBean> categoryFood : categoryFoods) {
if (categoryFood != null) {
buyIngredientsBeans.addAll(categoryFood);
}
}
return buyIngredientsBeans;
}
private int getIndexInAllFood(List<BuyIngredientsBean> allShowFood, OrderCategoryBean.FoodCategoryTrees categoryTrees) {
//從一層中找到當前分類的位置
int index = allShowFood.indexOf(new BuyIngredientsBean(categoryTrees.getId(), categoryTrees.getName(), categoryTrees.getParentId()));
int position = index;
for (int i = 0; i < index; i++) {
position += allShowFood.get(i).purchaseFoodList.size();
}
return position;
}
/**
* 將食品列表轉為帶分類用於顯示的列表
*
......
......@@ -162,8 +162,8 @@ public class CategoryPresenter extends BasePresenter<CategoryContract.Model, Cat
*/
public FoodCategoryResultBean.DataBean.FoodCategoryBean toFoodCategoryBean(int parentId, String categoryName, int id) {
FoodCategoryResultBean.DataBean.FoodCategoryBean foodCategoryBean = new FoodCategoryResultBean.DataBean.FoodCategoryBean();
foodCategoryBean.setBrandId(RestaurantInfoManager.newInstance().getBrandId());
foodCategoryBean.setRestaurantId(RestaurantInfoManager.newInstance().getRestaurantId());
foodCategoryBean.setBrandId(Constant.getBrandId());
foodCategoryBean.setRestaurantId(Constant.getRestaurantId());
foodCategoryBean.setName(categoryName);
foodCategoryBean.setParentId(parentId);
foodCategoryBean.setId(id);
......@@ -180,8 +180,8 @@ public class CategoryPresenter extends BasePresenter<CategoryContract.Model, Cat
public void deleteFoodCategory(OrderCategoryBean.FoodCategoryTrees foodCategoryTrees, int hierarchy, int position) {
RequestBody requestBody = new FormBody.Builder()
.add("id", foodCategoryTrees.getId() + "")
.add("brandId", RestaurantInfoManager.newInstance().getBrandId() + "")
.add("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId() + "")
.add("brandId", Constant.getBrandId() + "")
.add("restaurantId", Constant.getRestaurantId() + "")
.build();
mModel.deleteFoodCategory(requestBody)
.subscribeOn(Schedulers.io())
......
......@@ -122,8 +122,8 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
Map<String, Object> map = new HashMap<>(5);
map.put("pageSize", 1000);
map.put("pageIndex", 0);
map.put("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId());
map.put("brandId", RestaurantInfoManager.newInstance().getBrandId());
Constant.addBrandId(map);
Constant.addRestaurantId(map);
if (supplierId != -1) {
map.put("supplierId", supplierId);
}
......@@ -222,8 +222,8 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
Map<String, Object> map = new HashMap<>(5);
map.put("pageSize", 1000);
map.put("pageIndex", 0);
map.put("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId());
map.put("brandId", RestaurantInfoManager.newInstance().getBrandId());
Constant.addBrandId(map);
Constant.addRestaurantId(map);
if (supplierId != -1) {
map.put("supplierId", supplierId);
}
......
......@@ -125,7 +125,7 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo
* 獲取副單位 快捷輸入列表數據集合
*/
public void getDeputyUnitList() {
mModel.getDeputyUnitList(RestaurantInfoManager.newInstance().getBrandId(), RestaurantInfoManager.newInstance().getRestaurantId())
mModel.getDeputyUnitList(Constant.getBrandId(), Constant.getRestaurantId())
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(GET_INFO_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
......@@ -245,8 +245,8 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo
}
}
DeputyUnitBean unitBean = new DeputyUnitBean();
unitBean.setBrandId(RestaurantInfoManager.newInstance().getBrandId());
unitBean.setRestaurantId(RestaurantInfoManager.newInstance().getRestaurantId());
unitBean.setBrandId(Constant.getBrandId());
unitBean.setRestaurantId(Constant.getRestaurantId());
unitBean.setPurchaseFoodId(foodId);
deputyUnitBeans.add(unitBean);
mRootView.loadDeputyUnitAdapter(deputyUnitBeans);
......@@ -268,8 +268,8 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("content", content);
jsonObject.put("brandId", RestaurantInfoManager.newInstance().getBrandId() + "");
jsonObject.put("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId() + "");
jsonObject.put("brandId", Constant.getBrandId() + "");
jsonObject.put("restaurantId", Constant.getRestaurantId() + "");
} catch (JSONException e) {
e.printStackTrace();
}
......
......@@ -7,6 +7,7 @@ import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.bean.MeasurementUnitBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.contract.MeasurementUnitContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
......@@ -75,8 +76,8 @@ public class MeasurementUnitPresenter extends BasePresenter<MeasurementUnitContr
if (!TextUtil.isEmptyOrNullOrUndefined(unitContent)) {
map.put("unitContent", unitContent);
}
map.put("brandId", RestaurantInfoManager.newInstance().getBrandId());
map.put("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId());
map.put("brandId", Constant.getBrandId());
map.put("restaurantId", Constant.getRestaurantId());
map.put("pageIndex", pageIndex);
mModel.getMeasurementUnitList(map)
.subscribeOn(Schedulers.io())
......
......@@ -309,8 +309,8 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
infoMultiBeans.get(basicUnitIndex).setShowValue(basicUnitName);
if (deputyUnitBeans != null) {
for (DeputyUnitBean deputyUnitBean : deputyUnitBeans) {
deputyUnitBean.setRestaurantId(RestaurantInfoManager.newInstance().getRestaurantId());
deputyUnitBean.setBrandId(RestaurantInfoManager.newInstance().getBrandId());
deputyUnitBean.setRestaurantId(Constant.getRestaurantId());
deputyUnitBean.setBrandId(Constant.getBrandId());
}
}
this.deputyUnitBeans = deputyUnitBeans;
......@@ -318,6 +318,9 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
}
public void setCategoryInfo(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees, List<InfoMultiBean> infoMultiBeans) {
if (CollectionUtils.isNullOrEmpty(foodCategoryTrees)) {
return;
}
StringBuilder categoryName = new StringBuilder();
if (categoryNames == null) {
categoryNames = new ArrayList<>();
......@@ -329,7 +332,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
categoryName.append(categoryTrees.getName())
.append(PurchaseFoodBean.CATEGORY_DIVIDER);
}
if (purchaseFoodBean != null) {
if (purchaseFoodBean != null && foodCategoryTrees.size() > 0) {
//食材信息不為空,設置分類id為最後一個分類的id
//例如:選擇了一個三級分類,下標0為父類,1為子類,2位當前分類
purchaseFoodBean.setFoodCategoryId(foodCategoryTrees.get(foodCategoryTrees.size() - 1).getId());
......@@ -552,9 +555,9 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
purchaseFoodBean.setFoodUnits(deputyUnitBeans);
}
//品牌id
purchaseFoodBean.setBrandId(RestaurantInfoManager.newInstance().getBrandId());
purchaseFoodBean.setBrandId(Constant.getBrandId());
//餐廳id
purchaseFoodBean.setRestaurantId(RestaurantInfoManager.newInstance().getRestaurantId());
purchaseFoodBean.setRestaurantId(Constant.getRestaurantId());
return purchaseFoodBean;
}
}
......@@ -8,6 +8,7 @@ import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.ui.adapter.bean.InfoMultiBean;
import com.gingersoft.supply_chain.mvp.bean.MeasurementUnitBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.contract.NewFoodUnitContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
......@@ -129,8 +130,8 @@ public class NewFoodUnitPresenter extends BasePresenter<NewFoodUnitContract.Mode
if (foodUnit == null) {
foodUnit = new MeasurementUnitBean.DataBean.Unit();
}
foodUnit.setBrandId(RestaurantInfoManager.newInstance().getBrandId());
foodUnit.setRestaurantId(RestaurantInfoManager.newInstance().getRestaurantId());
foodUnit.setBrandId(Constant.getBrandId());
foodUnit.setRestaurantId(Constant.getRestaurantId());
List<InfoMultiBean> units = infoMultiBeans.get(0).getInfoMultiBeans();
for (int i = 0; i < units.size(); i++) {
if (units.get(i).isChecked()) {
......
......@@ -519,8 +519,8 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
//地址
supplierInfoBean.setAddress(infoMultiBeans.get(addressIndex).getShowValue());
//餐廳信息
supplierInfoBean.setRestaurantId(RestaurantInfoManager.newInstance().getRestaurantId());
supplierInfoBean.setBrandId(RestaurantInfoManager.newInstance().getBrandId());
supplierInfoBean.setRestaurantId(Constant.getRestaurantId());
supplierInfoBean.setBrandId(Constant.getBrandId());
//最低採購金額
String minimumAmount = infoMultiBeans.get(lowPurchaseAmount).getShowValue();
if (TextUtil.isNotEmptyOrNullOrUndefined(minimumAmount)) {
......
......@@ -4,6 +4,7 @@ import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.utils.CollectionUtils;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
......@@ -202,6 +203,12 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
}
purchaseOrderDetailsInfoVO.setShowUnit(warehouseUnit);
purchaseOrderDetailsInfoVO.setFoodUnits(Collections.singletonList(warehouseUnit));
} else {
wareHousingUnitBean = new WareHousingUnitBean(purchaseOrderDetailsInfoVO.getId(), purchaseOrderDetailsInfoVO.getBasicUnitName(), purchaseOrderDetailsInfoVO.getWarehousingQuantity(), 0);
purchaseOrderDetailsInfoVO.setPurchaseWarehousingUnit(wareHousingUnitBean);
purchaseOrderDetailsInfoVO.setShowUnit(new DeputyUnitBean(purchaseOrderDetailsInfoVO.getBasicUnitName(), purchaseOrderDetailsInfoVO.getWarehousingQuantity()));
mRootView.showMessage("沒有入庫單位,請聯繫開發人員");
mRootView.killMyself();
}
}
purchaseOrderDetailsInfoVO.setWarehousingAmount(warehousingAmount);
......@@ -252,6 +259,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
List<OrderWareHouseBean.PurchaseWarehousingOrderDetail> purchaseWarehousingOrderDetails = transformWareHoses(wareHouseBean, purchaseOrderDetailsInfoVosBeans);
wareHouseBean = getWareHouseBean(state, remark, totalAmount, wareHouseBean, purchaseWarehousingOrderDetails);
if (wareHouseBean == null) {
mRootView.killMyself();
return;
}
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(wareHouseBean));
......@@ -296,7 +304,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(GET_INFO_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.doAfterNext(disposable -> mRootView.hideLoading())
.doAfterTerminate(() -> mRootView.hideLoading())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
......@@ -327,7 +335,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
* 生成入庫對象
*/
private OrderWareHouseBean getWareHouseBean(int state, String remark, double totalAmount, OrderWareHouseBean orderWareHouseBean, List<OrderWareHouseBean.PurchaseWarehousingOrderDetail> purchaseWarehousingOrderDetails) {
if (purchaseWarehousingOrderDetails == null) {
if (CollectionUtils.isNullOrEmpty(purchaseWarehousingOrderDetails)) {
return null;
}
orderWareHouseBean.setStatus(state);
......@@ -342,13 +350,17 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
String substring = files.substring(0, files.length());
purchaseWarehousingOrder.setFiles(substring);
}
purchaseWarehousingOrder.setRestaurantId(RestaurantInfoManager.newInstance().getRestaurantId());
purchaseWarehousingOrder.setBrandId(RestaurantInfoManager.newInstance().getBrandId());
purchaseWarehousingOrder.setRestaurantId(Constant.getRestaurantId());
purchaseWarehousingOrder.setBrandId(Constant.getBrandId());
purchaseWarehousingOrder.setRemarks(remark);
purchaseWarehousingOrder.setTotalPrice(totalAmount);
orderWareHouseBean.setPurchaseWarehousingOrder(purchaseWarehousingOrder);
orderWareHouseBean.setPurchaseWarehousingOrderDetailsTOS(purchaseWarehousingOrderDetails);
if (purchaseWarehousingOrderDetails.size() <= 0) {
mRootView.showMessage("請選擇需要操作的食品");
return null;
}
return orderWareHouseBean;
}
......@@ -372,12 +384,16 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
purchaseWarehousingOrderDetail.setTotalPrice(MoneyUtil.priceCalculation(purchaseOrderDetailsInfoVosBean.getFoodPrice(), purchaseOrderDetailsInfoVosBean.getFoodQuantity()));
DeputyUnitBean deputyUnitBean = purchaseOrderDetailsInfoVosBean.getShowUnit();
WareHousingUnitBean wareHousingUnitBean = DeputyUnitBean.getWareHousingUnitByDeputyUnit(deputyUnitBean);
// if(wareHousingUnitBean.getUnitValue()<=0){
// //如果入庫數量小於等於0,就不管這個食品
// continue;
// }
if (purchaseOrderDetailsInfoVosBean.getStatus() != PurchaseOrderDetailsBean.WAIT_RECEIVED && deputyUnitBean.getId() != null) {
//不是待收貨狀態才設置id,因為如果已經收過貨才有id
wareHousingUnitBean.setId(deputyUnitBean.getId());
}
wareHousingUnitBean.setBrandId(RestaurantInfoManager.newInstance().getBrandId());
wareHousingUnitBean.setRestaurantId(RestaurantInfoManager.newInstance().getRestaurantId());
wareHousingUnitBean.setBrandId(Constant.getBrandId());
wareHousingUnitBean.setRestaurantId(Constant.getRestaurantId());
purchaseWarehousingOrderDetail.setPurchaseWarehousingUnit(wareHousingUnitBean);
//sn碼
List<PurchaseFoodEncodeSn> snList = null;
......@@ -398,10 +414,6 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
purchaseWarehousingOrderDetails.add(purchaseWarehousingOrderDetail);
}
}
if (purchaseWarehousingOrderDetails.size() <= 0) {
mRootView.showMessage("請選擇需要操作的食品");
return null;
}
return purchaseWarehousingOrderDetails;
}
......@@ -446,6 +458,24 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
}
/**
* 是否有sn食材
*
* @param purchaseOrderDetailsInfoVOS 食材信息
* @return
*/
public boolean hasSnFood(List<PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean> purchaseOrderDetailsInfoVOS) {
if (purchaseOrderDetailsInfoVOS != null) {
for (PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean datum : purchaseOrderDetailsInfoVOS) {
if (datum.getFoodMarkSn() == PurchaseFoodBean.HAS_SN) {
return true;
}
}
return false;
}
return false;
}
/**
* 刪除Sn碼
*/
public void deleteSn(String enCodeOrderNo, String encodeFoodNo, String encodeSnNo) {
......
......@@ -15,6 +15,7 @@ import com.gingersoft.supply_chain.mvp.bean.NewPurchaseOrderBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.bean.ShoppingCartBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.content.SupplyShoppingCart;
import com.gingersoft.supply_chain.mvp.contract.ShoppingCatContract;
import com.jess.arms.di.scope.FragmentScope;
......@@ -225,8 +226,8 @@ public class ShoppingCatPresenter extends BasePresenter<ShoppingCatContract.Mode
@SuppressLint("CheckResult")
public void addNewPurchaseOrder(List<PurchaseFoodBean> purchaseFoodBeans, String remarks) {
NewPurchaseOrderBean newPurchaseOrderBean = new NewPurchaseOrderBean();
newPurchaseOrderBean.setBrandId(RestaurantInfoManager.newInstance().getBrandId());
newPurchaseOrderBean.setRestaurantId(RestaurantInfoManager.newInstance().getRestaurantId());
newPurchaseOrderBean.setBrandId(Constant.getBrandId());
newPurchaseOrderBean.setRestaurantId(Constant.getRestaurantId());
double totalAmount = 0;
for (PurchaseFoodBean purchaseFoodBean : purchaseFoodBeans) {
totalAmount = MoneyUtil.sum(totalAmount, MoneyUtil.priceCalculation(purchaseFoodBean.getUnitPrice(), purchaseFoodBean.getFoodQuantity()));
......
......@@ -7,6 +7,7 @@ import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.bean.WareHousingOrderBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.contract.StorageListContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
......@@ -70,8 +71,8 @@ public class StorageListPresenter extends BasePresenter<StorageListContract.Mode
Map<String, Object> map = new HashMap<>(6);
map.put("pageSize", 10);
map.put("pageIndex", pageIndex);
map.put("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId());
map.put("brandId", RestaurantInfoManager.newInstance().getBrandId());
Constant.addBrandId(map);
Constant.addRestaurantId(map);
map.put("status", status);
if (TextUtil.isNotEmptyOrNullOrUndefined(orderNo)) {
map.put("orderNo", orderNo);
......
......@@ -93,8 +93,8 @@ public class SupplierListPresenter extends BasePresenter<SupplierListContract.Mo
Map<String, Object> map = new HashMap<>(5);
map.put("pageSize", Constant.PAGE_SIZE);
map.put("pageIndex", pageIndex * Constant.PAGE_SIZE);
map.put("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId());
map.put("brandId", RestaurantInfoManager.newInstance().getBrandId());
Constant.addRestaurantId(map);
Constant.addBrandId(map);
if (!TextUtil.isEmptyOrNullOrUndefined(content)) {
map.put("content", content);
}
......
......@@ -181,8 +181,8 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
*/
public void consumeWareHousing(PurchaseWarehousingOrderDetailsVO purchaseWarehousingOrderDetailsVO, int consumeQuantity, ConsumeReasonBean consumeReasonBean, String remarks, List<String> snCodes, boolean whetherPrint) {
PurchaseConsumeSnBean purchaseConsumeSnBean = new PurchaseConsumeSnBean();
purchaseConsumeSnBean.brandId = RestaurantInfoManager.newInstance().getBrandId();
purchaseConsumeSnBean.restaurantId = RestaurantInfoManager.newInstance().getRestaurantId();
purchaseConsumeSnBean.brandId = Constant.getBrandId();
purchaseConsumeSnBean.restaurantId = Constant.getRestaurantId();
purchaseConsumeSnBean.foodNo = purchaseWarehousingOrderDetailsVO.getFoodNo();
purchaseConsumeSnBean.purchaseConsumeReasonId = consumeReasonBean.getId();
purchaseConsumeSnBean.remarks = remarks;
......
......@@ -3,6 +3,7 @@ package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.util.SparseArray;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
......@@ -11,11 +12,13 @@ import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.recyclerview.widget.RecyclerView;
import org.w3c.dom.Text;
/**
* 通用的RecyclerView.ViewHolder。提供了根据viewId获取View的方法。
* 提供了对View、TextView、ImageView的常用设置方法。
*/
public class BaseViewHolder extends RecyclerView.ViewHolder {
public class BaseViewHolder<VH extends RecyclerView.ViewHolder> extends RecyclerView.ViewHolder {
private SparseArray<View> mViews;
......@@ -58,6 +61,13 @@ public class BaseViewHolder extends RecyclerView.ViewHolder {
return this;
}
public BaseViewHolder setText(int viewId, CharSequence text, TextView.BufferType type) {
TextView tv = get(viewId);
tv.setText(text, type);
return this;
}
public BaseViewHolder setText(int viewId, int textRes) {
TextView tv = get(viewId);
tv.setText(textRes);
......@@ -119,4 +129,45 @@ public class BaseViewHolder extends RecyclerView.ViewHolder {
view.setVisibility(visible);
return this;
}
public BaseViewHolder setInvisible(int viewId, boolean invisible) {
View view = get(viewId);
view.setVisibility(invisible ? View.INVISIBLE : View.VISIBLE);
return this;
}
public BaseViewHolder setInvisible(int viewId, int invisible) {
View view = get(viewId);
view.setVisibility(invisible);
return this;
}
public BaseViewHolder setOnClickListener(int viewId, View.OnClickListener onClickListener) {
View view = get(viewId);
view.setOnClickListener(onClickListener);
return this;
}
public BaseViewHolder setOnLongClickListener(int viewId, View.OnLongClickListener l) {
View view = get(viewId);
view.setOnLongClickListener(l);
return this;
}
public BaseViewHolder setOnTouchListener(int viewId, View.OnTouchListener l) {
View view = get(viewId);
view.setOnTouchListener(l);
return this;
}
public BaseViewHolder setOnFocusChangeListener(int viewId, View.OnFocusChangeListener onFocusChangeListener) {
View view = get(viewId);
view.setOnFocusChangeListener(onFocusChangeListener);
return this;
}
public <T extends TextView> CharSequence getText(int viewId) {
T view = get(viewId);
return view.getText();
}
}
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.text.Editable;
import android.os.Looper;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.arch.core.executor.TaskExecutor;
import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.threadPool.ThreadPoolManager;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.google.android.material.textfield.TextInputEditText;
import com.qmuiteam.qmui.layout.QMUIButton;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxIOTask;
import com.xuexiang.rxutil2.rxjava.task.RxUITask;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* @author 宇航.
* User: admin
......@@ -31,6 +35,9 @@ public class BuyIngredientsAdapter extends GroupedRecyclerViewAdapter {
private List<BuyIngredientsBean> buyIngredientsBeans;
private boolean isSinger = true;
private OnFoodNumberChangeListener onFoodNumberChangeListener;
private boolean longClick = false;
private int delayTime = 500;
public BuyIngredientsAdapter(Context context, List<BuyIngredientsBean> buyIngredientsBeans) {
super(context);
......@@ -41,14 +48,11 @@ public class BuyIngredientsAdapter extends GroupedRecyclerViewAdapter {
isSinger = showType;
}
/**
* 設置減少按鈕和輸入框的顯示或隱藏
*
* @param showOrHide 顯示或隱藏
*/
private void setSubAndNumShow(ItemViewHolder itemViewHolder, boolean showOrHide) {
itemViewHolder.btnFoodOperationSub.setVisibility(showOrHide ? View.GONE : View.VISIBLE);
itemViewHolder.edFoodIngredientNumber.setVisibility(showOrHide ? View.INVISIBLE : View.VISIBLE);
public BuyIngredientsBean getHeaderDataByPosition(int position) {
if (position < buyIngredientsBeans.size()) {
return buyIngredientsBeans.get(position);
}
return null;
}
@Override
......@@ -98,54 +102,170 @@ public class BuyIngredientsAdapter extends GroupedRecyclerViewAdapter {
}
@Override
public void onBindChildViewHolder(BaseViewHolder holder, int groupPosition, int childPosition) {
ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
public void onBindChildViewHolder(BaseViewHolder itemViewHolder, int groupPosition, int childPosition) {
PurchaseFoodBean purchaseFoodBean = buyIngredientsBeans.get(groupPosition).purchaseFoodList.get(childPosition);
itemViewHolder.tvSupplierName.setText(purchaseFoodBean.getSupplierName());
itemViewHolder.ivFoodIngredientImg.setImageResource(R.drawable.img_small_default);
itemViewHolder.setText(R.id.tv_food_item_supplier_name, purchaseFoodBean.getSupplierName());
itemViewHolder.setImageResource(R.id.iv_food_ingredient_img, R.drawable.img_small_default);
if (TextUtil.isNotEmptyOrNullOrUndefined(purchaseFoodBean.getImages())) {
GlideUtils.display(itemViewHolder.ivFoodIngredientImg.getContext(), itemViewHolder.ivFoodIngredientImg, purchaseFoodBean.getImages());
GlideUtils.display(mContext, (ImageView) itemViewHolder.get(R.id.iv_food_ingredient_img), purchaseFoodBean.getImages());
}
itemViewHolder.tvFoodItemNo.setText(purchaseFoodBean.getFoodNo());
itemViewHolder.tvFoodItemName.setText(purchaseFoodBean.getName());
itemViewHolder.setText(R.id.tv_food_item_no, purchaseFoodBean.getFoodNo());
itemViewHolder.setText(R.id.tv_food_item_name, purchaseFoodBean.getName());
//如果有包裝描述就顯示包裝描述,沒有包裝描述顯示基本單位
if (TextUtil.isNotEmptyOrNullOrUndefined(purchaseFoodBean.getPackingDescription())) {
itemViewHolder.tvFoodItemUnit.setText(purchaseFoodBean.getPackingDescription());
itemViewHolder.setText(R.id.tv_food_item_unit, purchaseFoodBean.getPackingDescription());
} else {
itemViewHolder.tvFoodItemUnit.setText(purchaseFoodBean.getBasicUnitName());
itemViewHolder.setText(R.id.tv_food_item_unit, purchaseFoodBean.getBasicUnitName());
}
itemViewHolder.tvFoodItemPrice.setText(String.format(mContext.getString(R.string.amount_string), purchaseFoodBean.getUnitPrice()));
itemViewHolder.edFoodIngredientNumber.setText(String.valueOf(purchaseFoodBean.getFoodQuantity()), TextView.BufferType.EDITABLE);
itemViewHolder.setText(R.id.tv_food_item_price, String.format(mContext.getString(R.string.amount_string), purchaseFoodBean.getUnitPrice()));
itemViewHolder.setText(R.id.ed_food_ingredient_number, String.valueOf(purchaseFoodBean.getFoodQuantity()), TextView.BufferType.EDITABLE);
EditText edNumberInput = (EditText) itemViewHolder.get(R.id.ed_food_ingredient_number);
//如果數量小於等於0,就不顯示減號和數量
setSubAndNumShow(itemViewHolder, purchaseFoodBean.getFoodQuantity() <= 0);
//編輯數量
itemViewHolder.btnFoodOperationSub.setOnClickListener(v -> {
itemViewHolder.setOnClickListener(R.id.btn_food_operation_sub, v -> {
//食材數量減少
if (purchaseFoodBean.getFoodQuantity() > 0) {
purchaseFoodBean.setFoodQuantity(purchaseFoodBean.getFoodQuantity() - 1);
itemViewHolder.edFoodIngredientNumber.setText(String.valueOf(purchaseFoodBean.getFoodQuantity()));
itemViewHolder.setText(R.id.ed_food_ingredient_number, String.valueOf(purchaseFoodBean.getFoodQuantity()));
}
if (onFoodNumberChangeListener != null) {
onFoodNumberChangeListener.onChange(groupPosition, childPosition, purchaseFoodBean.getFoodQuantity() + 1, purchaseFoodBean.getFoodQuantity());
}
//改變減號和數量的顯示
setSubAndNumShow(itemViewHolder, purchaseFoodBean.getFoodQuantity() <= 0);
});
itemViewHolder.btnFoodOperationAdd.setOnClickListener(v -> {
}).setOnClickListener(R.id.btn_food_operation_add, v -> {
//食材數量增加
purchaseFoodBean.setFoodQuantity(purchaseFoodBean.getFoodQuantity() + 1);
itemViewHolder.edFoodIngredientNumber.setText(String.valueOf(purchaseFoodBean.getFoodQuantity()));
itemViewHolder.setText(R.id.ed_food_ingredient_number, String.valueOf(purchaseFoodBean.getFoodQuantity()));
setSubAndNumShow(itemViewHolder, false);
if (onFoodNumberChangeListener != null) {
onFoodNumberChangeListener.onChange(groupPosition, childPosition, purchaseFoodBean.getFoodQuantity() - 1, purchaseFoodBean.getFoodQuantity());
}
}).setOnTouchListener(R.id.btn_food_operation_sub, onBtnTouchListener).setOnLongClickListener(R.id.btn_food_operation_sub, v -> {
//開啟線程
setLongClick(itemViewHolder, edNumberInput, purchaseFoodBean, false);
return true;
}).setOnTouchListener(R.id.btn_food_operation_add, onBtnTouchListener).setOnLongClickListener(R.id.btn_food_operation_add, v -> {
setLongClick(itemViewHolder, edNumberInput, purchaseFoodBean, true);
return true;
});
//輸入框焦點監聽
itemViewHolder.edFoodIngredientNumber.setOnFocusChangeListener((v, hasFocus) -> {
Editable text = itemViewHolder.edFoodIngredientNumber.getText();
if (!hasFocus) {
//當失去焦點時,如果沒有食品數量了,就隱藏減號和輸入框
if (TextUtil.isEmptyOrNullOrUndefined(text) || Integer.parseInt(text.toString()) == 0) {
setSubAndNumShow(itemViewHolder, false);
// itemViewHolder.setOnFocusChangeListener(R.id.ed_food_ingredient_number, (v, hasFocus) -> {
// CharSequence text = itemViewHolder.getText(R.id.ed_food_ingredient_number);
// if (!hasFocus) {
// //當失去焦點時,如果沒有食品數量了,就隱藏減號和輸入框
// if (TextUtil.isEmptyOrNullOrUndefined(text) || Integer.parseInt(text.toString()) == 0) {
// setSubAndNumShow(itemViewHolder, false);
// }
// }
// });
}
/**
* 設置減少按鈕和輸入框的顯示或隱藏
*
* @param showOrHide 顯示或隱藏 true隱藏,false顯示
*/
private void setSubAndNumShow(BaseViewHolder viewHolder, boolean showOrHide) {
viewHolder.setVisible(R.id.btn_food_operation_sub, !showOrHide);
viewHolder.setInvisible(R.id.ed_food_ingredient_number, showOrHide);
}
/**
* + - 按鈕觸摸事件
*/
private View.OnTouchListener onBtnTouchListener = (v, event) -> {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
longClick = true;
} else if (event.getAction() == MotionEvent.ACTION_UP) {
longClick = false;
}
return false;
};
/**
* 按鈕長按事件
*
* @param edNumberInput 輸入框
* @param purchaseFoodBean 商品信息
* @param addOrSub 是+ or -
*/
public void setLongClick(BaseViewHolder itemViewHolder, EditText edNumberInput, PurchaseFoodBean purchaseFoodBean, boolean addOrSub) {
//開啟線程
ThreadPoolManager.getInstence().putExecutableTasks(() -> {
int number = 0;
if (TextUtil.isNotEmptyOrNullOrUndefined(edNumberInput)) {
number = Integer.parseInt(edNumberInput.getText().toString());
}
delayTime = 500;
if (addOrSub) {
//+
if (number == 0) {
//如果數量為0,先把減號和數量顯示出來
edNumberInput.post(() -> setSubAndNumShow(itemViewHolder, false));
}
while (longClick) {
if (number < 9999) {
try {
Thread.sleep(delayTime);
number++;
if (delayTime > 100) {
delayTime -= 100;
}
int finalNumber = number;
edNumberInput.post(() -> edNumberInput.setText(String.valueOf(finalNumber)));
Log.e("eee", "食材數量加加減減:" + finalNumber);
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
longClick = false;
}
}
} else {
//-
while (longClick) {
if (number > 0) {
try {
Thread.sleep(delayTime);
number--;
if (delayTime > 100) {
delayTime -= 100;
}
int finalNumber = number;
edNumberInput.post(() -> edNumberInput.setText(String.valueOf(finalNumber)));
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
longClick = false;
edNumberInput.post(() -> setSubAndNumShow(itemViewHolder, true));
}
}
}
purchaseFoodBean.setFoodQuantity(number);
});
}
public interface OnFoodNumberChangeListener {
/**
* 數量改變
*
* @param parentCategoryIndex 所屬分類下標
* @param categoryIndex 食材在分類中的下標
* @param beforeNum 之前的數量
* @param currentNum 現在的數量
*/
void onChange(int parentCategoryIndex, int categoryIndex, int beforeNum, int currentNum);
}
public void setOnFoodNumberChangeListener(OnFoodNumberChangeListener onFoodNumberChangeListener) {
this.onFoodNumberChangeListener = onFoodNumberChangeListener;
}
public int getLayoutId() {
if (isSinger) {
return R.layout.item_buy_food_ingredient;
......@@ -157,30 +277,4 @@ public class BuyIngredientsAdapter extends GroupedRecyclerViewAdapter {
this.buyIngredientsBeans = buyIngredientsBeans;
notifyDataSetChanged();
}
public static class ItemViewHolder extends com.gingersoft.supply_chain.mvp.ui.adapter.BaseViewHolder {
@BindView(R2.id.iv_food_ingredient_img)
ImageView ivFoodIngredientImg;
@BindView(R2.id.tv_food_item_no)
TextView tvFoodItemNo;
@BindView(R2.id.tv_food_item_supplier_name)
TextView tvSupplierName;
@BindView(R2.id.tv_food_item_name)
TextView tvFoodItemName;
@BindView(R2.id.tv_food_item_unit)
TextView tvFoodItemUnit;
@BindView(R2.id.tv_food_item_price)
TextView tvFoodItemPrice;
@BindView(R2.id.btn_food_operation_sub)
QMUIButton btnFoodOperationSub;
@BindView(R2.id.ed_food_ingredient_number)
TextInputEditText edFoodIngredientNumber;
@BindView(R2.id.btn_food_operation_add)
QMUIButton btnFoodOperationAdd;
public ItemViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
}
}
......@@ -47,6 +47,12 @@ public class FirstLevelCategoryAdapter extends BaseQuickAdapter<OrderCategoryBea
TextView tvCategoryName = viewHolder.getView(R.id.tv_category_name);
tvCategoryName.setText(categoryBean.getName());
CardView view = viewHolder.getView(R.id.layout_category);
if (categoryBean.getSize() > 0) {
viewHolder.setText(R.id.tv_category_number, String.valueOf(categoryBean.getSize()));
viewHolder.setGone(R.id.tv_category_number, false);
} else {
viewHolder.setGone(R.id.tv_category_number, true);
}
//選中時的背景和文字顏色
if (viewHolder.getAdapterPosition() == selectedIndex) {
if (selectedBg != null) {
......
......@@ -26,7 +26,7 @@ public class ImageAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, String s) {
GlideUtils.display(getContext(), viewHolder.getView(R.id.iv_img), s);
GlideUtils.display(getContext(), viewHolder.getView(R.id.iv_img), s, R.drawable.img_small_default);
viewHolder.setGone(R.id.iv_img_delete, notShowDelete);
}
}
......@@ -24,6 +24,7 @@ import com.gingersoft.gsa.cloud.common.utils.inputFilter.MoneyInputFilter;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.DeputyUnitBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseOrderDetailsBean;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
......@@ -111,6 +112,14 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai
viewHolder.setText(R.id.tv_order_details_item_warehouse_total_amount, String.format(formatAmount, item.getTotalAmount()));
//食品數量
EditText edFoodNum = viewHolder.getView(R.id.ed_food_num);
//SN食材不可編輯數量
if(item.getFoodMarkSn() == PurchaseFoodBean.HAS_SN){
edFoodNum.setEnabled(false);
edFoodNum.setTextColor(ContextCompat.getColor(getContext(), R.color.color_aaa));
} else {
edFoodNum.setTextColor(ContextCompat.getColor(getContext(), R.color.color_3c));
edFoodNum.setEnabled(true);
}
edFoodNum.setFilters(inputFilters);
//已入庫數量
viewHolder.setText(R.id.tv_order_details_item_warehouse_warehousing_num, MoneyUtil.formatDouble(item.getWarehousingQuantity()));
......@@ -157,7 +166,7 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai
edFoodNum.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
edFoodNum.addTextChangedListener(watcher);
if("0".equals(edFoodNum.getText().toString())){
if ("0".equals(edFoodNum.getText().toString())) {
edFoodNum.setText("");
}
} else {
......@@ -208,7 +217,7 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai
if (hasFocus) {
if (TextUtil.isNotEmptyOrNullOrUndefined(edUnitPrice)) {
double price = Double.parseDouble(edUnitPrice.getText().toString());
if(price == 0){
if (price == 0) {
edUnitPrice.setText("");
}
}
......
......@@ -12,6 +12,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.gingersoft.gsa.cloud.common.BuildConfig;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.supply_chain.R;
......@@ -113,8 +114,8 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr
start(SupplierListFragment.newInstance(false, null));
break;
case "食材":
start(FoodIngredientsFragment.newInstance(FOOD_INGREDIENTS));
// start(BuyIngredientsFragment.newInstance());
// start(FoodIngredientsFragment.newInstance(FOOD_INGREDIENTS));
start(BuyIngredientsFragment.newInstance());
break;
case "種類":
start(CategoryFragment.newInstance());
......
package com.gingersoft.supply_chain.mvp.ui.fragment.food;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -16,6 +17,7 @@ import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.OnScrollListener;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
......@@ -36,7 +38,9 @@ import com.gingersoft.supply_chain.mvp.ui.adapter.SecondCategoryAdapter;
import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
import com.gingersoft.supply_chain.mvp.ui.widget.CenterLayoutManager;
import com.gingersoft.supply_chain.mvp.ui.widget.GroupedGridLayoutManager;
import com.gingersoft.supply_chain.mvp.ui.widget.LoadRefreshHeader;
import com.gingersoft.supply_chain.mvp.ui.widget.ShowSecondCategoryPopup;
import com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout;
import com.gingersoft.supply_chain.mvp.utils.ViewUtils;
import com.jess.arms.di.component.AppComponent;
import com.kingja.loadsir.callback.Callback;
......@@ -51,6 +55,10 @@ import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.section.QMUISection;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.constant.RefreshState;
import com.scwang.smartrefresh.layout.listener.SimpleMultiPurposeListener;
import org.jetbrains.annotations.NotNull;
......@@ -64,7 +72,8 @@ import lombok.val;
/**
* Description: 選購食材
*/
public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredientsPresenter> implements BuyIngredientsContract.View, View.OnClickListener {
public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredientsPresenter>
implements BuyIngredientsContract.View, View.OnClickListener {
@BindView(R2.id.topbar_food_ingredients)
QMUITopBar topbarFoodIngredients;
......@@ -113,9 +122,18 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
ImageView ivUnfoldArrow;
@BindView(R2.id.tv_unfold_category)
TextView tvUnfoldCategory;
TextView tvShoppingCart;
@BindView(R2.id.refreshLayout)
SmartRefreshLayout refreshLayout;
@BindView(R2.id.view_stick_head)
StickyHeaderLayout stickyHeaderLayout;
@BindView(R2.id.fresh_header)
LoadRefreshHeader header;
//購物車數量textview
TextView tvShoppingCart;
/**
* 購物車中商品數量
*/
int shoppingCartNum = 0;
/**
* 0單列
* 1雙列
......@@ -151,32 +169,31 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
// });
fullRegister = LoadSir.getDefault().register(layoutContent, (Callback.OnReloadListener) v -> {
});
// refreshLayout.setEnableOverScrollBounce(false);
// refreshLayout.setEnableOverScrollDrag(false);
// refreshLayout.setEnablePureScrollMode(true);
// refreshLayout.resetNoMoreData();
refreshLayout.setEnableOverScrollBounce(false)
.setFooterTriggerRate(0.1f);
// refreshLayout.setOnRefreshListener(refreshLayout -> {
// //在這裡不是刷新,而是獲取上一個分類的數據
// int i = firstLevelCategoryAdapter.getSelectedIndex() - 1;
// if (i >= 0) {
// firstLevelCategoryAdapter.getOnItemClickListener().onItemClick(firstLevelCategoryAdapter, null, i);
// } else {
// refreshLayout.finishRefreshWithNoMoreData();
// }
// });
// refreshLayout.setOnLoadMoreListener(refreshLayout -> {
// //加載下一個分類
// int itemCount = firstLevelCategoryAdapter.getItemCount();
// int i = firstLevelCategoryAdapter.getSelectedIndex() + 1;
// if (i < itemCount) {
// firstLevelCategoryAdapter.getOnItemClickListener().onItemClick(firstLevelCategoryAdapter, null, i);
// } else {
// refreshLayout.finishLoadMoreWithNoMoreData();
// }
// });
.setFooterTriggerRate(0.1f)
.setHeaderTriggerRate(0.1f)
.setEnableClipHeaderWhenFixedBehind(false)
.setEnableClipFooterWhenFixedBehind(false)
.setReboundDuration(1);
refreshLayout.setOnRefreshListener(refreshLayout -> {
//在這裡不是刷新,而是獲取上一個分類的數據
int i = firstLevelCategoryAdapter.getSelectedIndex() - 1;
if (i >= 0) {
loadFirstCategoryInfo(i);
} else {
refreshLayout.finishRefreshWithNoMoreData();
}
});
refreshLayout.setOnLoadMoreListener(refreshLayout -> {
//加載下一個分類
int i = firstLevelCategoryAdapter.getSelectedIndex() + 1;
if (i < firstLevelCategoryAdapter.getItemCount()) {
Log.e("eee", i + "加載更多");
loadFirstCategoryInfo(i);
} else {
refreshLayout.finishLoadMoreWithNoMoreData();
}
});
//獲取一級分類
mPresenter.getCategoryTrees();
}
......@@ -185,6 +202,8 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
initTopBar(topbarFoodIngredients, "食材管理");
View view = View.inflate(requireContext(), R.layout.view_shopping_car, null);
tvShoppingCart = view.findViewById(R.id.tv_purchase_cart_number);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
view.setLayoutParams(layoutParams);
topbarFoodIngredients.addRightView(view, R.id.qmui_shopping_cart);
}
......@@ -246,122 +265,53 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
private void setLayoutManager() {
LinearLayoutManager linearLayoutManager = isSinger ? new LinearLayoutManager(requireContext()) : getDoubleRowManager();
rvFoodIngredients.setLayoutManager(linearLayoutManager);
// rvFoodIngredients.getRecyclerView().clearOnScrollListeners();
//
// rvFoodIngredients.getRecyclerView().addOnScrollListener(new RecyclerView.OnScrollListener() {
// @Override
// public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
// super.onScrollStateChanged(recyclerView, newState);
// if (newState == RecyclerView.SCROLL_STATE_IDLE) {
// int firstVisibleItemPosition = linearLayoutManager.findFirstVisibleItemPosition();
// int lastVisibleItemPosition = linearLayoutManager.findLastVisibleItemPosition();
// //手指往上滑動,獲取下一個分類數據
// //記錄當前滑動到哪個header,如果和上次不一致,頂部的分類就切換選中
// if (!mPresenter.isLoadFood()) {
// if (lastVisibleItemPosition == adapter.getItemCount() - 1) {
// //最後一個,獲取下一個一級分類的數據
// //當前一級分類不是最後一個
// if (firstLevelCategoryAdapter.getSelectedIndex() != firstLevelCategoryAdapter.getItemCount() - 1) {
// isTailOrHead = 1;
// mPresenter.setLoadFood(true);
// mPresenter.getFood(firstLevelCategoryAdapter.getItem(firstLevelCategoryAdapter.getSelectedIndex() + 1).getId());
// }
// } else if (firstVisibleItemPosition == 0) {
// //第一個,獲取上一個一級分類的數據
// //當前一級分類不是第一個
// if (firstLevelCategoryAdapter.getSelectedIndex() != 0) {
// isTailOrHead = 0;
// mPresenter.setLoadFood(true);
// mPresenter.getFood(firstLevelCategoryAdapter.getItem(firstLevelCategoryAdapter.getSelectedIndex() - 1).getId());
// }
// }
// }
// }
// }
//
//
// @Override
// public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
// super.onScrolled(recyclerView, dx, dy);
// int firstVisibleItemPosition = linearLayoutManager.findFirstVisibleItemPosition();
//// int lastVisibleItemPosition = linearLayoutManager.findLastVisibleItemPosition();
// int sectionIndex = adapter.getSectionIndex(firstVisibleItemPosition);
//// //手指往上滑動,獲取下一個分類數據
//// //記錄當前滑動到哪個header,如果和上次不一致,頂部的分類就切換選中
//// if (!mPresenter.isLoadFood()) {
//// if (lastVisibleItemPosition == adapter.getItemCount() - 1) {
//// //最後一個,獲取下一個一級分類的數據
//// //當前一級分類不是最後一個
//// if (firstLevelCategoryAdapter.getSelectedIndex() != firstLevelCategoryAdapter.getItemCount() - 1) {
//// isTailOrHead = 1;
//// mPresenter.setLoadFood(true);
//// mPresenter.getFood(firstLevelCategoryAdapter.getItem(firstLevelCategoryAdapter.getSelectedIndex() + 1).getId());
//// }
//// } else if (firstVisibleItemPosition == 0) {
//// //第一個,獲取上一個一級分類的數據
//// //當前一級分類不是第一個
//// if (firstLevelCategoryAdapter.getSelectedIndex() != 0) {
//// isTailOrHead = 0;
//// mPresenter.setLoadFood(true);
//// mPresenter.getFood(firstLevelCategoryAdapter.getItem(firstLevelCategoryAdapter.getSelectedIndex() - 1).getId());
//// }
//// }
//// }
// if (sectionIndex != lastIndex) {
// QMUISection<CategoryBean, PurchaseFoodBean> sectionDirectly = adapter.getSectionDirectly(sectionIndex);
// if (sectionDirectly != null && sectionDirectly.getHeader() != null) {
// Integer id = sectionDirectly.getHeader().getId();
// List<OrderCategoryBean.FoodCategoryTrees> data = secondCategoryAdapter.getData();
// for (int i = lastIndex; i < data.size(); i = dy > 0 ? i + 1 : i - 1) {
// if (i < 0) {
// break;
// }
// if (data.get(i).getId() == id) {
// secondCategoryAdapter.setSelectedIndex(i);
// CenterLayoutManager layoutManager = (CenterLayoutManager) rvSecondCategory.getLayoutManager();
// layoutManager.smoothScrollToPosition(rvSecondCategory, new RecyclerView.State(), i);
// break;
// }
// }
// lastIndex = sectionIndex;
// }
// }
// }
// });
rvFoodIngredients.removeOnScrollListener(mFoodScrollListener);
rvFoodIngredients.addOnScrollListener(mFoodScrollListener);
}
private void switchCategory(BaseQuickAdapter<OrderCategoryBean.FoodCategoryTrees, ? extends RecyclerView.ViewHolder> adapter, RecyclerView recyclerView, Integer id) {
List<OrderCategoryBean.FoodCategoryTrees> data = adapter.getData();
for (int i = 0; i < data.size(); i++) {
if (data.get(i).getId() == id) {
if (adapter instanceof SecondCategoryAdapter) {
((SecondCategoryAdapter) adapter).setSelectedIndex(i);
} else if (adapter instanceof FirstLevelCategoryAdapter) {
((FirstLevelCategoryAdapter) adapter).setSelectedIndex(i);
private RecyclerView.OnScrollListener mFoodScrollListener = new OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int currentStickyGroup = stickyHeaderLayout.getCurrentStickyGroup();
//手指往上滑動,獲取下一個分類數據
//記錄當前滑動到哪個header,如果和上次不一致,頂部的分類就切換選中
if (currentStickyGroup != lastIndex) {
if (currentStickyGroup == -1) {
currentStickyGroup = 0;
}
CenterLayoutManager layoutManager = (CenterLayoutManager) recyclerView.getLayoutManager();
layoutManager.smoothScrollToPosition(recyclerView, new RecyclerView.State(), i);
if (i == data.size() - 1) {
if (adapter instanceof FirstLevelCategoryAdapter) {
lastIndex = currentStickyGroup;
//拿到當前顯示的分類
BuyIngredientsBean headerDataByPosition = adapter.getHeaderDataByPosition(currentStickyGroup);
if (headerDataByPosition == null) {
return;
}
if (headerDataByPosition.parentId == 0) {
//一級分類
int firstLevelCategoryIndex = firstLevelCategoryAdapter.getItemPosition(new OrderCategoryBean.FoodCategoryTrees(headerDataByPosition.id, headerDataByPosition.categoryName, headerDataByPosition.parentId));
if (firstLevelCategoryIndex > -1) {
//切換一級分類,二級分類也要變
loadFirstCategoryInfo(firstLevelCategoryIndex);
} else {
}
//現在是最後一個二級分類,這時候去獲取下一個一級分類的內容
if (!isNextCategory) {
isNextCategory = true;
} else {
//二級或三級分類,同時也要判斷是否要切換一級分類
int secondLevelCategoryIndex = secondCategoryAdapter.getItemPosition(new OrderCategoryBean.FoodCategoryTrees(headerDataByPosition.id, headerDataByPosition.categoryName, headerDataByPosition.parentId));
if (secondLevelCategoryIndex >= 0) {
secondCategoryAdapter.setSelectedIndex(secondLevelCategoryIndex);
ViewUtils.moveToCenterByHorizontal(rvSecondCategory, secondLevelCategoryIndex);
} else {
//是一級分類最後一個
refreshLayout.setNoMoreData(true);
//沒有這個二級或三級分類,判斷是否切換了一級分類
int firstCategoryByIndex = mPresenter.getFirstCategoryByIndex(currentStickyGroup);
if (firstCategoryByIndex >= 0 && firstCategoryByIndex < firstLevelCategoryAdapter.getItemCount()) {
loadFirstCategoryInfo(firstCategoryByIndex);
}
}
} else {
isNextCategory = false;
}
return;
}
}
}
};
/**
* 切換顯示分類或供應商
......@@ -403,12 +353,7 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
firstLevelCategoryAdapter = new FirstLevelCategoryAdapter(foodCategoryTrees, requireContext());
rvFirstCategory.setAdapter(firstLevelCategoryAdapter);
firstLevelCategoryAdapter.setOnItemClickListener((adapter, view, position) -> {
//切換右側顯示的二級分類和食材
firstLevelCategoryAdapter.setSelectedIndex(position);
ViewUtils.moveToCenterByVertical(rvFirstCategory, position);
loadSecondCategory(firstLevelCategoryAdapter.getData().get(position).getFoodCategoryTrees());
//獲取當前分類所有食材
mPresenter.getFoodByCategory(firstLevelCategoryAdapter.getItem(position));
firstCategoryClick(position);
});
//默認選中第0個分類
firstLevelCategoryAdapter.getOnItemClickListener().onItemClick(firstLevelCategoryAdapter, null, 0);
......@@ -420,6 +365,34 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
}
}
/**
* 加載一級分類數據
*
* @param position 一級分類下標
*/
private void loadFirstCategoryInfo(int position) {
//切換右側顯示的二級分類和食材
firstLevelCategoryAdapter.setSelectedIndex(position);
ViewUtils.moveToCenterByVertical(rvFirstCategory, position);
loadSecondCategory(firstLevelCategoryAdapter.getData().get(position).getFoodCategoryTrees());
if (!mPresenter.isHasLocationCategoryFoodInfo(position)) {
//本地沒有緩衝才去查找
//獲取點擊的分類的所有食材
mPresenter.getFoodByCategory(position, firstLevelCategoryAdapter.getItem(position));
}
}
/**
* 一級分類點擊
*
* @param position 分類下標
*/
private void firstCategoryClick(int position) {
//清空食材列表,重新加載當前下標分類的食品數據
mPresenter.clearCategoryFoods();
loadFirstCategoryInfo(position);
}
@Override
public void loadRightFoodIngredients(List<PurchaseFoodBean> purchaseFoodListVOS) {
// 點擊一二三級分類,都是清空當前頁面所有食材,然後顯示當前級別分類下的食材
......@@ -429,7 +402,7 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
@Override
public void loadFail() {
// loadService.showCallback(EmptyCallback.class);
}
/**
......@@ -446,6 +419,8 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
secondCategoryAdapter.setSelectedIndex(position);
ViewUtils.moveToCenterByHorizontal(rvSecondCategory, position);
//加載當前分類下的食品
//二級分類點擊
//列表要定位到指定位置
};
secondCategoryAdapter.setOnItemClickListener(onItemClickListener);
......@@ -454,7 +429,8 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
}
//默認選中第0個
if (foodCategoryTrees != null && foodCategoryTrees.size() > 0) {
secondCategoryAdapter.getOnItemClickListener().onItemClick(secondCategoryAdapter, rvSecondCategory, 0);
secondCategoryAdapter.setSelectedIndex(0);
ViewUtils.moveToCenterByHorizontal(rvSecondCategory, 0);
}
}
......@@ -462,34 +438,51 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
* 加載食品,找到這些食品最近的上一個分類,將數據添加到這個分類下面,如果沒有,就添加到最頂部
*/
@Override
public void loadFood(List<BuyIngredientsBean> buyIngredientsBeans) {
public void loadFood(int index, List<BuyIngredientsBean> buyIngredientsBeans) {
refreshLayout.finishRefresh();
refreshLayout.finishLoadMore();
refreshLayout.setNoMoreData(true);
if (adapter == null) {
adapter = new BuyIngredientsAdapter(requireContext(), buyIngredientsBeans);
rvFoodIngredients.setAdapter(adapter);
adapter.setOnFoodNumberChangeListener((parentCategoryIndex, categoryIndex, beforeNum, currentNum) -> {
int firstCategoryByIndex = mPresenter.getFirstCategoryByIndex(parentCategoryIndex);
//找到一級分類下標
if (beforeNum == 0 || currentNum == 0) {
OrderCategoryBean.FoodCategoryTrees item = firstLevelCategoryAdapter.getItem(firstCategoryByIndex);
//正
if (beforeNum == 0) {
item.setSize(item.getSize() + 1);
} else {
item.setSize(item.getSize() - 1);
}
firstLevelCategoryAdapter.notifyItemChanged(firstCategoryByIndex);
}
shoppingCartNum += currentNum - beforeNum;
tvShoppingCart.setText(String.valueOf(shoppingCartNum));
});
setLayoutManager();
// mPresenter.setLoadFood(false);
} else {
// if (isTailOrHead == 2) {
adapter.setData(buyIngredientsBeans);
// } else {
// List<QMUISection<CategoryBean, PurchaseFoodBean>> currentData = CollectionUtils.deepCopy(adapter.getCurrentData());
// if (isTailOrHead == 0) {
// currentData.addAll(0, food);
// } else {
// currentData.addAll(food);
// }
// adapter.setData(currentData);
// }
// mPresenter.setLoadFood(false);
scrollToPosition(index);
}
}
@Override
public void scrollToPosition(int index) {
refreshLayout.finishRefresh();
refreshLayout.finishLoadMore();
scrollToPosition(index, (LinearLayoutManager) rvFoodIngredients.getLayoutManager());
}
@NotNull
private GroupedGridLayoutManager getDoubleRowManager() {
val gridLayoutManager = new GroupedGridLayoutManager(requireContext(), 2, adapter);
return gridLayoutManager;
}
public void scrollToPosition(int n, LinearLayoutManager linearLayoutManager) {
linearLayoutManager.scrollToPositionWithOffset(n, 0);
}
}
......@@ -17,7 +17,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.loadsir.EmptyCallback;
import com.gingersoft.gsa.cloud.common.loadsir.ErrorCallback;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.ui.adapter.BaseCategoryAdapter;
import com.gingersoft.gsa.cloud.ui.adapter.BaseCategoryAdapter;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
import com.gingersoft.supply_chain.R;
......@@ -358,7 +358,7 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
supplierId = categoryBeans.get(0).getId();
}
if (listSelectAdapter == null) {
listSelectAdapter = new BaseCategoryAdapter(categoryBeans);
listSelectAdapter = new BaseCategoryAdapter(R.layout.item_base_category, categoryBeans);
listSelectAdapter.setUnSelectColor(ContextCompat.getColor(mContext, R.color.color_3c))
.setSelectColor(ContextCompat.getColor(mContext, R.color.theme_color));
listSelectAdapter.setOnItemClickListener((adapter, view, position) -> {
......
......@@ -223,6 +223,11 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
}
}
/**
* 收貨操作
*
* @param state 狀態,全部收貨還是部分收貨
*/
private void addWarehouse(int state) {
AppDialog.getInstance().showWaringDialog(requireContext(), "是否確認收貨?", (view, dialog) -> {
mPresenter.addWarehouse(state, edRemark.getText() + "", totalAmount, orderDetailsFoodAdapter.getData());
......@@ -250,8 +255,19 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
}
};
/**
* 加載訂單詳情
*
* @param orderDetailsBean 訂單詳情
*/
@Override
public void loadOrderDetails(PurchaseOrderDetailsBean orderDetailsBean) {
//判斷有沒有SN食材,如果沒有,就顯示全選按妞
if (orderDetailsBean.getStatus() == PurchaseOrderDetailsBean.COMPLETE_RECEIVED) {
cbOrderDetailsAllSelected.setVisibility(View.VISIBLE);
} else {
cbOrderDetailsAllSelected.setVisibility(mPresenter.hasSnFood(orderDetailsBean.getPurchaseOrderDetailsInfoVOS()) ? View.GONE : View.VISIBLE);
}
if (TextUtil.isNotEmptyOrNullOrUndefined(orderDetailsBean.getWarehousingRemarks())) {
edRemark.setText(orderDetailsBean.getWarehousingRemarks());
}
......@@ -302,6 +318,9 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
});
}
/**
* 全選,以前的需求,全選時要一個一個遍歷,掃SN碼的就彈窗,掃完一個又彈下一個
*/
private void checkAllForEach() {
int itemCount = orderDetailsFoodAdapter.getItemCount();
if (currentFoodIndex >= itemCount) {
......@@ -309,26 +328,33 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
cbOrderDetailsAllSelected.setChecked(typesOfFood == itemCount);
setTypesOfFood();
}
for (int i = currentFoodIndex; i < itemCount; i++) {
PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean datum = orderDetailsFoodAdapter.getItem(i);
// 如果是sn,判斷這個食品是否已選中,並且本次狀態要為選中
// 判斷不是已經全部收貨的食品
// 再判斷這個食品的sn數量和入庫數量是否一致,不一致則再次選擇
// 判斷是否需要去查詢已經保存的sn碼。
if (datum.getFoodMarkSn() == PurchaseFoodBean.HAS_SN && checkState && datum.getStatus() != PurchaseOrderDetailsBean.COMPLETE_RECEIVED) {
DeputyUnitBean showUnit = datum.getShowUnit();
int newSnCodeSize = mPresenter.getNewSnCodeSize(datum.getPurchaseFoodEncodeSns());
if(showUnit.getDeputyValue() != newSnCodeSize){
isNeedQuerySn(orderDetailsFoodAdapter.getItemPosition(datum), datum, false);
currentFoodIndex = i;
if (mPresenter.orderState == PurchaseOrderDetailsBean.COMPLETE_RECEIVED) {
//全部收貨的全選
for (PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean datum : orderDetailsFoodAdapter.getData()) {
selectFood(datum);
}
} else {
for (int i = currentFoodIndex; i < itemCount; i++) {
PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean datum = orderDetailsFoodAdapter.getItem(i);
// 如果是sn,判斷這個食品是否已選中,並且本次狀態要為選中
// 判斷不是已經全部收貨的食品
// 再判斷這個食品的sn數量和入庫數量是否一致,不一致則再次選擇
// 判斷是否需要去查詢已經保存的sn碼。
if (datum.getFoodMarkSn() == PurchaseFoodBean.HAS_SN && checkState && datum.getStatus() != PurchaseOrderDetailsBean.COMPLETE_RECEIVED) {
DeputyUnitBean showUnit = datum.getShowUnit();
int newSnCodeSize = mPresenter.getNewSnCodeSize(datum.getPurchaseFoodEncodeSns());
if (showUnit.getDeputyValue() != newSnCodeSize) {
isNeedQuerySn(orderDetailsFoodAdapter.getItemPosition(datum), datum, false);
currentFoodIndex = i;
} else {
selectFood(datum);
//收貨數量等於sn數量,就不用再彈窗了
nextFood();
}
break;
} else {
selectFood(datum);
//收貨數量等於sn數量,就不用再彈窗了
nextFood();
}
break;
} else {
selectFood(datum);
}
}
}
......@@ -506,14 +532,14 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
}
}
})
.setMinCodeSize((int) infoVosBean.getShowUnit().getDeputyValue())
// .setMinCodeSize((int) infoVosBean.getShowUnit().getDeputyValue())
.setOnScanResultListener((popup, scanResult) -> {
//當前食材infoVosBean裡面有個sn碼集合,將scanResult添加進去
if (scanResult != null && scanResult.size() > 0) {
//过滤出新增的
List<PurchaseFoodEncodeSn> newAddSnCodes = new ArrayList<>(scanResult.size());
for (PurchaseFoodEncodeSn purchaseFoodEncodeSn : scanResult) {
if (purchaseFoodEncodeSn.newAdd) {
if (foodEncodeSns == null || (purchaseFoodEncodeSn.newAdd && !foodEncodeSns.contains(purchaseFoodEncodeSn))) {
//判斷這個snCode是不是已經收過貨了,沒收過貨,新增的就為true
PurchaseFoodEncodeSn newSnCodeBean = new PurchaseFoodEncodeSn();
newSnCodeBean.setEncodeFoodNo(infoVosBean.getFoodNo());
......@@ -549,10 +575,11 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
}
//本次收貨數量=新增掃sn碼數量
DeputyUnitBean showUnit = infoVosBean.getShowUnit();
if (newAddSize != showUnit.getDeputyValue()) {
showMessage("新增SN数量必须和入库数一致");
return;
}
// if (newAddSize != showUnit.getDeputyValue()) {
// showMessage("新增SN数量必须和入库数一致");
// return;
// }
showUnit.setDeputyValue(newAddSize);
setFoodCheckState(orderDetailsFoodAdapter, position, infoVosBean);
popup.dismiss();
......
......@@ -151,6 +151,7 @@ public class ShoppingCatFragment extends BaseSupplyChainFragment<ShoppingCatPres
if (foodListVosBean.isChecked()) {
totalSpecies = MoneyUtil.sub(totalSpecies, 1);
totalAmount = MoneyUtil.sub(totalAmount, MoneyUtil.priceCalculation(foodListVosBean.getUnitPrice(), foodListVosBean.getFoodQuantity()));
totalAmount = MoneyUtil.sub(totalAmount, foodListVosBean.getShipping());
setTotalInfo(totalSpecies, totalAmount);
}
}
......
......@@ -249,7 +249,11 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
if (view.getId() == R.id.tv_warehouse_details_food_num) {
WarehouseDetailsBean item = wareHousingDetailsAdapter.getItem(position);
//查詢消耗,收貨Sn碼詳情
mPresenter.querySnCodeList(vpWarehouseViewpager.getCurrentItem(), item.getFoodQuantity(), "", item.getWarehousingOrderDetailsIds());
if (vpWarehouseViewpager.getCurrentItem() == WAREHOUSE_TYPE) {
mPresenter.querySnCodeList(vpWarehouseViewpager.getCurrentItem(), item.getFoodQuantity(), "", item.getWarehousingOrderDetailsIds());
} else {
mPresenter.querySnCodeList(vpWarehouseViewpager.getCurrentItem(), item.getFoodQuantity(), "", item.getPurchaseConsumeNoId());
}
}
}
});
......@@ -439,6 +443,7 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
public void showList(int visible) {
vpWarehouseViewpager.setVisibility(visible);
layoutTitle.setVisibility(visible);
loadService.showSuccess();
if (visible == View.VISIBLE) {
removeInventoryView();
} else {
......
package com.gingersoft.supply_chain.mvp.ui.widget;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
/**
* @author 宇航.
* User: admin
* Date: 2021/4/6
* Time: 10:08
* Use:
*/
public class LoadRefreshHeader extends ClassicsHeader implements RefreshHeader {
public LoadRefreshHeader(Context context) {
super(context);
}
public LoadRefreshHeader(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public ClassicsHeader setArrowDrawable(Drawable drawable) {
return super.setArrowDrawable(drawable);
}
public ClassicsHeader setTitle(String text) {
mTitleText.setText(text);
return this;
}
}
......@@ -47,9 +47,9 @@ public class ScanSnPopup extends BottomPopupView {
*/
private int maxCodeSize = -1;
/**
* 最少掃碼數量
* 最少掃碼數量,-1不判斷
*/
private int minCodeSize = 0;
private int minCodeSize = -1;
public ScanSnPopup(@NonNull Fragment fragment, String foodName, List<PurchaseFoodEncodeSn> purchaseFoodEncodeSns, boolean operable) {
super(fragment.requireContext());
......
......@@ -87,7 +87,7 @@ public class ScanSnView extends FrameLayout {
/**
* 最少掃碼數量
*/
private int minCodeSize = 0;
private int minCodeSize = -1;
public ScanSnView(Fragment fragment, List<PurchaseFoodEncodeSn> purchaseFoodEncodeSns, ScanSnPopup.OnScanResultListener onScanResultListener) {
super(fragment.requireContext());
......@@ -97,7 +97,7 @@ public class ScanSnView extends FrameLayout {
this.purchaseFoodEncodeSns = purchaseFoodEncodeSns;
}
initCodeSize = this.purchaseFoodEncodeSns.size();
for (PurchaseFoodEncodeSn purchaseFoodEncodeSn : purchaseFoodEncodeSns) {
for (PurchaseFoodEncodeSn purchaseFoodEncodeSn : this.purchaseFoodEncodeSns) {
if (purchaseFoodEncodeSn.newAdd) {
newCodeSize++;
}
......@@ -197,7 +197,7 @@ public class ScanSnView extends FrameLayout {
}
public void setConfirmBtnState() {
if (minCodeSize > 0 && newCodeSize == minCodeSize) {
if (minCodeSize == -1 || newCodeSize == minCodeSize) {
btnFoodIngredientsConfirm.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_app_btn));
} else {
btnFoodIngredientsConfirm.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_btn_unclick));
......@@ -206,12 +206,14 @@ public class ScanSnView extends FrameLayout {
private void commitSnCode(SnCodeAdapter adapter) {
if (TextUtil.isNotEmptyOrNullOrUndefined(edInputSn)) {
if (adapter.getData().contains(edInputSn.getText().toString())) {
ToastUtils.show(getContext(), "商品已存在,不能重複添加");
} else {
String snCode = edInputSn.getText().toString();
addSnCode(adapter, snCode);
String snCode = edInputSn.getText().toString();
for (PurchaseFoodEncodeSn datum : adapter.getData()) {
if (datum.getEncodeSnNo().equals(snCode)) {
ToastUtils.show(getContext(), "商品已存在,不能重複添加");
return;
}
}
addSnCode(adapter, snCode);
} else {
ToastUtils.show(getContext(), "請輸入SN碼");
}
......
......@@ -15,7 +15,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.supply_chain.mvp.ui.adapter.BaseViewHolder;
import com.gingersoft.supply_chain.mvp.ui.adapter.GroupedRecyclerViewAdapter;
import java.lang.reflect.Method;
......@@ -85,15 +85,15 @@ public class StickyHeaderLayout extends FrameLayout {
* 添加滚动监听
*/
private void addOnScrollListener() {
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
// 在滚动的时候,需要不断的更新吸顶布局。
if (isSticky) {
if (isSticky) {
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
// 在滚动的时候,需要不断的更新吸顶布局。
updateStickyView(false);
}
}
});
});
}
}
/**
......@@ -173,7 +173,7 @@ public class StickyHeaderLayout extends FrameLayout {
}
}
if (mRecyclerView.computeVerticalScrollOffset() == 0){
if (mRecyclerView.computeVerticalScrollOffset() == 0) {
// 滑动到顶部
recycle();
}
......@@ -249,6 +249,13 @@ public class StickyHeaderLayout extends FrameLayout {
return null;
}
/***
* @return 當前吸頂的view下標
*/
public int getCurrentStickyGroup() {
return mCurrentStickyGroup;
}
/**
* 回收并移除吸顶布局
*/
......@@ -320,8 +327,9 @@ public class StickyHeaderLayout extends FrameLayout {
private int getMin(int[] arr) {
int min = arr[0];
for (int x = 1; x < arr.length; x++) {
if (arr[x] < min)
if (arr[x] < min) {
min = arr[x];
}
}
return min;
}
......
package com.gingersoft.supply_chain.mvp.utils;
import androidx.core.content.FileProvider;
/**
* @author 宇航.
* User: admin
* Date: 2021/4/2
* Time: 11:15
* Use:
*/
public class PurchaseFileProvider extends FileProvider {
}
......@@ -8,6 +8,7 @@ import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;
import android.provider.OpenableColumns;
......@@ -16,6 +17,7 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.gingersoft.gsa.cloud.common.utils.FileUtils;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
import com.permissionx.guolindev.PermissionX;
......@@ -45,7 +47,7 @@ public class SelectPicture {
* 當前圖片的絕對路徑
*/
// private String currentPhotoPath;
final String[] items = new String[]{"拍照", "從相冊選擇", "取消"};
final String[] items = new String[]{"拍照", "從相冊選擇"};
public static final int CHOOSE_PHOTO = 101;
public static final int TAKE_PHOTO = 102;
public static final int PHOTO_CROP = 103;
......@@ -164,7 +166,7 @@ public class SelectPicture {
*/
public File createImageFile(Context mContext) {
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String timeStamp = TimeUtils.DEFAULT_DATE_FORMAT_YMDHM.format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File cacheDir = mContext.getCacheDir();
File image = null;
......@@ -183,6 +185,18 @@ public class SelectPicture {
return image;
}
/**
* 創建照片保存路徑,然後再進行拍照
*/
public File createImageFile2(Context mContext) {
String image = mContext.getCacheDir() + File.separator + "purchase" + File.separator + "images" + File.separator + System.currentTimeMillis() + ".jpg";
File outputFile = new File(image);
if (!outputFile.exists()) {
outputFile.mkdir();
}
return outputFile;
}
/**
* uri轉換為文件路徑,適配android Q
......
......@@ -120,8 +120,7 @@
<!-- 二級分類 -->
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways">
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food_ingredients_second_category"
......@@ -172,7 +171,17 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.gingersoft.supply_chain.mvp.ui.widget.LoadRefreshHeader
android:id="@+id/fresh_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srlAccentColor="#aaa"
app:srlTextPulling="@string/str_purchase_loading"
app:srlDrawableArrow="@drawable/brvah_sample_footer_loading"
app:srlPrimaryColor="@color/trans" />
<com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout
android:id="@+id/view_stick_head"
android:layout_width="match_parent"
android:layout_height="match_parent">
......@@ -180,7 +189,6 @@
android:id="@+id/rv_food_ingredients"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_5"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout>
......
......@@ -62,19 +62,19 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_9"
tools:text="採購單號:"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14" />
android:textSize="@dimen/dp_14"
tools:text="採購單號:" />
<TextView
android:id="@+id/tv_warehouse_order_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
tools:text="入庫單號:"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14"
android:visibility="gone"
android:textSize="@dimen/dp_14" />
tools:text="入庫單號:" />
<LinearLayout
android:id="@+id/layout_ed_remark"
......@@ -150,8 +150,8 @@
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginTop="@dimen/dp_10">
android:layout_marginTop="@dimen/dp_10"
android:visibility="gone">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_order_details_food_name"
......@@ -180,18 +180,19 @@
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingRight="@dimen/dp_25">
android:paddingTop="@dimen/dp_5"
android:paddingRight="@dimen/dp_25"
android:paddingBottom="@dimen/dp_5">
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/cb_order_details_all_selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_25"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
android:text="全選"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14" />
android:textSize="@dimen/dp_14"
android:visibility="gone" />
<TextView
style="@style/supplier_chain_222_16"
......
......@@ -3,13 +3,17 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout_shopping_cart"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content">
<ImageView
android:id="@+id/iv_shopping_cart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_shopping_car" />
android:src="@drawable/ic_shopping_car"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_purchase_cart_number"
......@@ -19,7 +23,8 @@
android:autoSizeMinTextSize="@dimen/dp_4"
android:background="@drawable/ui_shape_red_oval"
android:gravity="center"
android:text="3"
android:includeFontPadding="false"
android:text="0"
android:textColor="@color/white"
android:textSize="@dimen/dp_6"
app:layout_constraintRight_toRightOf="@id/iv_shopping_cart"
......
......@@ -35,4 +35,5 @@
<string name="str_device_not_print">您的設備不支持打印</string>
<string name="str_sn_codes">SN嗎:%1$s</string>
<string name="str_en_num_digits">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789</string>
<string name="str_purchase_loading">飛速加載中</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- <root-path/> :代表设备的根目录new File("/")
<?xml version="1.0" encoding="utf-8"?><!-- <root-path/> :代表设备的根目录new File("/")
<files-path/> : 代表context.getFilesDir()
<cache-path/> : 代表context.getCacheDir()
<external-path/> : 代表Environment.getExternalStorageDirectory()
......@@ -37,6 +36,12 @@
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name=""
path="purchase_image" />
name="purchase_images"
path="purchase" />
<cache-path
name="purchase_images"
path="*" />
<root-path
name="root-path"
path="" />
</paths>
......@@ -57,43 +57,6 @@ android {
}
}
////dokit 扩展
//dokitExt {
// //通用设置
// comm {
// //地图经纬度开关
// gpsSwitch true
// //网络开关
// networkSwitch true
// //大图开关
// bigImgSwitch true
// //webView js 抓包
// webViewSwitch true
// }
//
// slowMethod {
// //调用栈模式配置
// stackMethod {
// //默认值为 5ms 小于该值的函数在调用栈中不显示
// thresholdTime 5
// //调用栈函数入口
// enterMethods = ["com.didichuxing.doraemondemo.MainDebugActivity.test1"]
// //黑名单 粒度最小到类 暂不支持到方法
// methodBlacklist = ["com.facebook.drawee.backends.pipeline.Fresco"]
// }
// //普通模式配置
// normalMethod {
// //默认值为 500ms 小于该值的函数在运行时不会在控制台中被打印
// thresholdTime 100
// //需要针对函数插装的包名
// packageNames = ["com.didichuxing.doraemondemo"]
// //不需要针对函数插装的包名和类名
// methodBlacklist = ["com.didichuxing.doraemondemo.dokit"]
// }
// }
//}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/javabase64-1.2.jar')
......
......@@ -47,7 +47,24 @@ public class GlideUtils {
.imageView(imageView)
.build());
}
public static void display(Context context, ImageView imageView, String url, int placeholder) {
if (imageView == null) {
throw new IllegalArgumentException("argument error");
}
//可以在任何可以拿到 Context 的地方,拿到 AppComponent,从而得到用 Dagger 管理的单例对象
AppComponent mAppComponent = ArmsUtils.obtainAppComponentFromContext(context);
ImageLoader mImageLoader = mAppComponent.imageLoader();//用于加载图片的管理类,默认使用 Glide,使用策略模式,可替换框架
mImageLoader.loadImage(context,
ImageConfigImpl
.builder()
.url(url)
.placeholder(placeholder)
.imageView(imageView)
.build());
}
public static void display(Context context, ImageView imageView, String url, int placeholder, int error, int fallback) {
......
package com.gingersoft.gsa.cloud.common.utils.gson;
import com.alibaba.fastjson.JSONException;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
......@@ -116,6 +116,7 @@ public class GsonUtils {
// }
// return list;
// }
/**
* json字符串转成list
*
......@@ -125,6 +126,7 @@ public class GsonUtils {
public static <T> List<T> jsonToList(Object object, Class<T> cls) {
return jsonToList(GsonString(object), cls);
}
/**
* json字符串转成list
*
......@@ -133,7 +135,9 @@ public class GsonUtils {
*/
public static <T> List<T> jsonToList(String json, Class<T> cls) {
ArrayList<T> mList = new ArrayList<>();
if (TextUtil.isEmptyOrNullOrUndefined(json)) {
return null;
}
JsonArray array = new JsonParser().parse(json).getAsJsonArray();
for (final JsonElement elem : array) {
mList.add(gson.fromJson(elem, cls));
......
......@@ -2,7 +2,7 @@
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_category"
android:id="@+id/item_layout_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="@dimen/dp_5"
......@@ -17,7 +17,7 @@
android:paddingBottom="@dimen/dp_5">
<TextView
android:id="@+id/tv_category_name"
android:id="@+id/tv_base_item_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
......
......@@ -32,17 +32,19 @@
tools:text="果蔬類看書福利卡駕駛的垃圾死了阿斯蘭大家啦款手機愛上了的框架拉三季度阿薩德科技拉屎" />
<TextView
android:id="@+id/tv_category_number"
android:layout_width="@dimen/dp_14"
android:layout_height="@dimen/dp_14"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginLeft="@dimen/dp_2"
android:layout_marginRight="@dimen/dp_2"
android:autoSizeMaxTextSize="@dimen/dp_12"
android:autoSizeMinTextSize="@dimen/dp_6"
android:background="@drawable/ui_shape_theme_oval"
android:gravity="center"
android:includeFontPadding="false"
android:textColor="@color/white"
android:textSize="@dimen/dp_12"
android:visibility="gone"
tools:text="6" />
</LinearLayout>
......
package com.gingersoft.supply_chain.mvp.ui.adapter;
package com.gingersoft.gsa.cloud.ui.adapter;
import android.view.View;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import androidx.core.content.ContextCompat;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.R;
import com.gingersoft.gsa.cloud.ui.R;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import org.jetbrains.annotations.NotNull;
......@@ -28,8 +28,8 @@ public class BaseCategoryAdapter extends BaseQuickAdapter<CategoryBean, BaseView
private int selectedBg;
private int unSelectedBg;
private int selectColor = -1;
private int unSelectColor = -1;
private int selectColor;
private int unSelectColor;
private boolean showDelete = false;
public BaseCategoryAdapter(@Nullable List<CategoryBean> data) {
......@@ -37,27 +37,47 @@ public class BaseCategoryAdapter extends BaseQuickAdapter<CategoryBean, BaseView
addChildClickViewIds(R.id.iv_category_delete);
selectedBg = R.drawable.shape_left_radio_shadow;
unSelectedBg = R.color.trans;
selectColor = R.color.s_btn_blue_3c_text;
unSelectColor = R.color.color_ccc;
}
public BaseCategoryAdapter(int layoutRes, @Nullable List<CategoryBean> data) {
super(layoutRes, data);
addChildClickViewIds(R.id.iv_category_delete);
selectedBg = R.drawable.shape_left_radio_shadow;
unSelectedBg = R.color.trans;
selectColor = R.color.s_btn_blue_3c_text;
unSelectColor = R.color.color_ccc;
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, CategoryBean categoryBean) {
TextView tvCategoryName = viewHolder.getView(R.id.tv_category_name);
tvCategoryName.setText(categoryBean.getCategoryName());
CardView view = viewHolder.getView(R.id.layout_category);
if (viewHolder.getAdapterPosition() == selectedIndex) {
viewHolder.setText(R.id.tv_base_item_title, categoryBean.getCategoryName());
notifyCheckState(viewHolder.getAdapterPosition(), viewHolder.getView(R.id.tv_base_item_title), viewHolder.getView(R.id.item_layout_root));
viewHolder.setGone(R.id.iv_category_delete, !showDelete);
}
@Override
public void onBindViewHolder(@NotNull BaseViewHolder holder, int position, @NotNull List<Object> payloads) {
super.onBindViewHolder(holder, position, payloads);
//list为空时,必须调用两个参数的onBindViewHolder(@NonNull LabelHolder holder, int position)
if (payloads.isEmpty()) {
onBindViewHolder(holder, position);
} else {
notifyCheckState(position, holder.getView(R.id.tv_base_item_title), holder.getView(R.id.item_layout_root));
}
}
private void notifyCheckState(int position, TextView tvName, View view) {
if (position == selectedIndex) {
view.setBackground(ContextCompat.getDrawable(getContext(), selectedBg));
if (selectColor != -1) {
tvCategoryName.setTextColor(selectColor);
}
tvCategoryName.setSelected(true);
tvName.setTextColor(selectColor);
tvName.setSelected(true);
} else {
tvCategoryName.setSelected(false);
view.setBackground(ContextCompat.getDrawable(getContext(), unSelectedBg));
if (unSelectColor != -1) {
tvCategoryName.setTextColor(unSelectColor);
}
tvName.setTextColor(unSelectColor);
tvName.setSelected(false);
}
viewHolder.setGone(R.id.iv_category_delete, !showDelete);
}
public void setShowDelete(boolean showDelete) {
......@@ -85,9 +105,10 @@ public class BaseCategoryAdapter extends BaseQuickAdapter<CategoryBean, BaseView
return this;
}
public void setSelectedIndex(int selectedIndex) {
public BaseCategoryAdapter setSelectedIndex(int selectedIndex) {
this.selectedIndex = selectedIndex;
notifyDataSetChanged();
return this;
}
public int getSelectedIndex() {
......
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