Commit d3938c2e by Wyh

1、供應鏈代碼1.29

parent 67072339
...@@ -63,14 +63,8 @@ public class OrderListPresenter extends BasePresenter<OrderListContract.Model, O ...@@ -63,14 +63,8 @@ public class OrderListPresenter extends BasePresenter<OrderListContract.Model, O
} }
private List<OrderList.DataBeanX.DataBean> orderList = new ArrayList<>(); private List<OrderList.DataBeanX.DataBean> orderList = new ArrayList<>();
private Disposable disposable;
public void getOrderList(int restaurantId, int page, String status, String type, String phone) { public void getOrderList(int restaurantId, int page, String status, String type, String phone) {
if (disposable != null) {
if (!disposable.isDisposed()) {
return;
}
}
RequestBody requestBody = new FormBody.Builder() RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", restaurantId + "") .add("restaurantId", restaurantId + "")
.add("page", page + "") .add("page", page + "")
...@@ -91,13 +85,10 @@ public class OrderListPresenter extends BasePresenter<OrderListContract.Model, O ...@@ -91,13 +85,10 @@ public class OrderListPresenter extends BasePresenter<OrderListContract.Model, O
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
super.onSubscribe(d); super.onSubscribe(d);
disposable = d;
} }
@Override @Override
public void onNext(@NonNull OrderList info) { public void onNext(@NonNull OrderList info) {
disposable.dispose();
disposable = null;
if (page == 1) { if (page == 1) {
orderList.clear(); orderList.clear();
} }
......
...@@ -53,23 +53,16 @@ import com.qmuiteam.qmui.util.QMUIDisplayHelper; ...@@ -53,23 +53,16 @@ import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.QMUITopBar; import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.popup.QMUIPopup; import com.qmuiteam.qmui.widget.popup.QMUIPopup;
import com.qmuiteam.qmui.widget.popup.QMUIPopups; import com.qmuiteam.qmui.widget.popup.QMUIPopups;
import com.xuexiang.rxutil2.exception.RxException;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils; import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.subsciber.BaseSubscriber;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import butterknife.BindView; import butterknife.BindView;
import butterknife.OnClick; import butterknife.OnClick;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import static androidx.fragment.app.FragmentStatePagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT; import static androidx.fragment.app.FragmentStatePagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT;
import static com.jess.arms.utils.Preconditions.checkNotNull; import static com.jess.arms.utils.Preconditions.checkNotNull;
...@@ -85,7 +78,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre ...@@ -85,7 +78,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
TabLayout tabLayout; TabLayout tabLayout;
@BindView(R2.id.tv_balance) @BindView(R2.id.tv_balance)
TextView tvBalance; TextView tvBalance;
@BindView(R2.id.cold_chain_takeaway_progress) @BindView(R2.id.cold_chain_takeaway_progress)
ProgressBar mTakeAwayPb; ProgressBar mTakeAwayPb;
@BindView(R2.id.tv_cold_chain_takeaway_num) @BindView(R2.id.tv_cold_chain_takeaway_num)
...@@ -161,7 +153,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre ...@@ -161,7 +153,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
initService(); initService();
initHearBroadcast(); initHearBroadcast();
autoReceivingOrders.setChecked(RestaurantExpandInfoUtils.getValue(ExpandConstant.FrozenChainAutoOrder, false));
autoReceivingOrders.setOnCheckedChangeListener((buttonView, isChecked) -> { autoReceivingOrders.setOnCheckedChangeListener((buttonView, isChecked) -> {
RestaurantExpandInfoUtils.setValue(ExpandConstant.FrozenChainAutoOrder, isChecked); RestaurantExpandInfoUtils.setValue(ExpandConstant.FrozenChainAutoOrder, isChecked);
if (autoOrderDisposable != null && !autoOrderDisposable.isDisposed()) { if (autoOrderDisposable != null && !autoOrderDisposable.isDisposed()) {
...@@ -174,6 +165,7 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre ...@@ -174,6 +165,7 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
mPresenter.stopAutoReceivingOrders(); mPresenter.stopAutoReceivingOrders();
} }
}); });
autoReceivingOrders.setChecked(RestaurantExpandInfoUtils.getValue(ExpandConstant.FrozenChainAutoOrder, false));
} }
public void getNumByOrderTypeInvoke(String functionName) { public void getNumByOrderTypeInvoke(String functionName) {
...@@ -261,9 +253,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre ...@@ -261,9 +253,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
if (type == 3 || type == 6 || type == 7) { if (type == 3 || type == 6 || type == 7) {
getNumByOrderTypeInvoke("loadNumber"); getNumByOrderTypeInvoke("loadNumber");
} }
if (autoReceivingOrders.isChecked()) {
mPresenter.startToBeConfirmedOrderList(restaurantId);
}
}); });
bind.execute(aBoolean -> null); bind.execute(aBoolean -> null);
bind.setJumpActivity(ColdChainMainActivity.class); bind.setJumpActivity(ColdChainMainActivity.class);
......
...@@ -236,7 +236,7 @@ public class OrderDetailsActivity extends BaseActivity<OrderDetailsPresenter> im ...@@ -236,7 +236,7 @@ public class OrderDetailsActivity extends BaseActivity<OrderDetailsPresenter> im
if(TextUtil.isNotEmptyOrNullOrUndefined(bean.getRECEIVER())) { if(TextUtil.isNotEmptyOrNullOrUndefined(bean.getRECEIVER())) {
mTvReceiver.setText(bean.getRECEIVER()); mTvReceiver.setText(bean.getRECEIVER());
} }
mTvOrderNum.setText(bean.getBillNo()); mTvOrderNum.setText(bean.getTakeFoodCode());
mTvReceiverPhone.setText(bean.getPHONE()); mTvReceiverPhone.setText(bean.getPHONE());
mTvReceiverTime.setText(TextUtil.isNotEmptyOrNullOrUndefined(bean.getTakeTime()) ? bean.getTakeTime() : bean.getSEND_TIME()); mTvReceiverTime.setText(TextUtil.isNotEmptyOrNullOrUndefined(bean.getTakeTime()) ? bean.getTakeTime() : bean.getSEND_TIME());
mTvReceiverAddress.setText(bean.getAddressDetail()); mTvReceiverAddress.setText(bean.getAddressDetail());
......
...@@ -197,7 +197,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -197,7 +197,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
super.onResume(); super.onResume();
initFuncationData(); initFuncationData();
if (((int) SPUtils.get("isFormal", 0)) != 0) { if (((int) SPUtils.get("isFormal", 0)) != 0) {
tv_version_name.setText("v_" + DeviceUtils.getVersionName(this) + "\u1500Beta"); tv_version_name.setText("v_" + DeviceUtils.getVersionName(this) + "\u3000Beta");
} else { } else {
tv_version_name.setText("v_" + DeviceUtils.getVersionName(this)); tv_version_name.setText("v_" + DeviceUtils.getVersionName(this));
} }
......
...@@ -18,10 +18,11 @@ ...@@ -18,10 +18,11 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:maxLength="4"
android:layout_marginTop="@dimen/dp_8" android:layout_marginTop="@dimen/dp_8"
android:text="餐檯模式" android:text="餐檯模式"
android:singleLine="true" android:singleLine="true"
android:ellipsize="marquee" android:ellipsize="end"
android:textColor="@color/normal_color" android:textColor="@color/normal_color"
android:textSize="@dimen/sp_12" /> android:textSize="@dimen/sp_12" />
......
package com.gingersoft.supply_chain.mvp.bean;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/25
* Time: 11:54
* Use: 庫存消耗原因實體
*/
@Data
public class ConsumeReasonBean {
private int id;
private String description;
}
package com.gingersoft.supply_chain.mvp.bean;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/26
* Time: 11:23
* Use:庫存消耗流水
*/
@Data
public class ConsumeWareHousingBean {
private String name;
private String unitName;
private String foodCategoryName;
private String dates;
private String description;
private int quantity;
}
...@@ -41,7 +41,6 @@ public class FoodCategoryResultBean { ...@@ -41,7 +41,6 @@ public class FoodCategoryResultBean {
* createTime : 1605944097385 * createTime : 1605944097385
* updateTime : 1605944097044 * updateTime : 1605944097044
*/ */
private int id; private int id;
private int uid; private int uid;
private int brandId; private int brandId;
......
package com.gingersoft.supply_chain.mvp.bean; package com.gingersoft.supply_chain.mvp.bean;
import java.io.Serializable;
import java.util.List; import java.util.List;
import lombok.Data; import lombok.Data;
...@@ -12,7 +13,7 @@ import lombok.Data; ...@@ -12,7 +13,7 @@ import lombok.Data;
* Use: 下單頁面的分類 * Use: 下單頁面的分類
*/ */
@Data @Data
public class OrderCategoryBean { public class OrderCategoryBean implements Serializable {
private boolean success; private boolean success;
private long sysTime; private long sysTime;
...@@ -25,5 +26,13 @@ public class OrderCategoryBean { ...@@ -25,5 +26,13 @@ public class OrderCategoryBean {
private String name; private String name;
private int parentId; private int parentId;
private List<FoodCategoryTrees> foodCategoryTrees; private List<FoodCategoryTrees> foodCategoryTrees;
public FoodCategoryTrees() {
}
public FoodCategoryTrees(int id) {
this.id = id;
}
} }
} }
...@@ -2,6 +2,11 @@ package com.gingersoft.supply_chain.mvp.bean; ...@@ -2,6 +2,11 @@ package com.gingersoft.supply_chain.mvp.bean;
import com.gingersoft.supply_chain.mvp.content.Constant; import com.gingersoft.supply_chain.mvp.content.Constant;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
...@@ -18,7 +23,7 @@ import lombok.Data; ...@@ -18,7 +23,7 @@ import lombok.Data;
public class PurchaseFoodBean implements Serializable { public class PurchaseFoodBean implements Serializable {
private static final long serialVersionUID = 7084280906070243339L; private static final long serialVersionUID = 7084280906070243339L;
public static final String CATEGORY_DIVIDER = "-"; public static final String CATEGORY_DIVIDER = "-";
private int id; private Integer id;
private String supplierName; private String supplierName;
private String images; private String images;
private String foodNo; private String foodNo;
...@@ -59,12 +64,12 @@ public class PurchaseFoodBean implements Serializable { ...@@ -59,12 +64,12 @@ public class PurchaseFoodBean implements Serializable {
/** /**
* 分類id * 分類id
*/ */
private int foodCategoryId; private Integer foodCategoryId;
/** /**
* 所屬供應商id * 所屬供應商id
*/ */
private int supplierId; private Integer supplierId;
/** /**
* 是否選中 * 是否選中
*/ */
...@@ -72,7 +77,6 @@ public class PurchaseFoodBean implements Serializable { ...@@ -72,7 +77,6 @@ public class PurchaseFoodBean implements Serializable {
/** /**
* 是否刪除 * 是否刪除
* {@link Constant.DELETE,Constant.NORMAL} * {@link Constant.DELETE,Constant.NORMAL}
*
*/ */
private int deletes; private int deletes;
private int restaurantId; private int restaurantId;
...@@ -83,7 +87,7 @@ public class PurchaseFoodBean implements Serializable { ...@@ -83,7 +87,7 @@ public class PurchaseFoodBean implements Serializable {
* 預警的信息,獲取詳情接口返回的不是對象,傳遞給後台時需要轉為對象 * 預警的信息,獲取詳情接口返回的不是對象,傳遞給後台時需要轉為對象
* 所以需要在這裡建這幾個字段,用於接收 * 所以需要在這裡建這幾個字段,用於接收
*/ */
private int inventoryWarningId; private Integer inventoryWarningId;
private boolean reviews; private boolean reviews;
private int minimumInventory; private int minimumInventory;
private int shelfLife; private int shelfLife;
...@@ -93,8 +97,8 @@ public class PurchaseFoodBean implements Serializable { ...@@ -93,8 +97,8 @@ public class PurchaseFoodBean implements Serializable {
* 庫存預警 模塊 * 庫存預警 模塊
*/ */
@Data @Data
public static class InventoryAlarm { public static class InventoryAlarm implements Serializable {
private int id; private Integer id;
/** /**
* 是否審核 0否 1是 * 是否審核 0否 1是
*/ */
...@@ -125,4 +129,26 @@ public class PurchaseFoodBean implements Serializable { ...@@ -125,4 +129,26 @@ public class PurchaseFoodBean implements Serializable {
public void setChecked(boolean checked) { public void setChecked(boolean checked) {
isChecked = checked; isChecked = checked;
} }
/**
* 复制一個類
* @param old
* @return
*/
public static Object copy(Object old) {
Object clazz = null;
try {
// 写入字节流
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(old);
// 读取字节流
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
clazz = (Object) ois.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
return clazz;
}
} }
...@@ -35,7 +35,22 @@ public class PurchaseOrderDetailsBean { ...@@ -35,7 +35,22 @@ public class PurchaseOrderDetailsBean {
private double totalAmount; private double totalAmount;
private int shipping; private int shipping;
private double actualPayment; private double actualPayment;
/**
* 入库单号
*/
private String warehousingOrderNo;
/**
* 入庫備註
*/
private String warehousingRemarks;
/**
* 下採購單時的備註
*/
private String remarks;
/**
* 收貨時上傳的圖片,可以多張,用逗號隔開
*/
private String files;
/** /**
* 狀態:0全部 1待收貨 2部分收貨 3已完成 4拒收 * 狀態:0全部 1待收貨 2部分收貨 3已完成 4拒收
...@@ -101,6 +116,9 @@ public class PurchaseOrderDetailsBean { ...@@ -101,6 +116,9 @@ public class PurchaseOrderDetailsBean {
*/ */
private int foodQuantity; private int foodQuantity;
private double foodPrice; private double foodPrice;
/**
* 看上面{@link WAIT_RECEIVED}
*/
private int status; private int status;
private int purchaseFoodId; private int purchaseFoodId;
private String images; private String images;
...@@ -135,7 +153,7 @@ public class PurchaseOrderDetailsBean { ...@@ -135,7 +153,7 @@ public class PurchaseOrderDetailsBean {
/** /**
* 已入庫數量 * 已入庫數量
*/ */
private int warehousingQuantity; private double warehousingQuantity;
// List<DeputyUnitBean> deputyUnitBeans; // List<DeputyUnitBean> deputyUnitBeans;
/** /**
* 沒有入庫單號,暫時用訂單編號 * 沒有入庫單號,暫時用訂單編號
......
...@@ -83,14 +83,15 @@ public class WareHouseListBean { ...@@ -83,14 +83,15 @@ public class WareHouseListBean {
* foodAmount : 267 * foodAmount : 267
*/ */
private int id; private int id;
private String foodNo;
private String name; private String name;
private String cateName; private String foodCategoryName;
private String supplierName; // private String supplierName;
private String basicUnitName; private String unitName;
private double foodPrice; private double foodPrice;
private int foodNum; private int foodNum;
private double foodAmount; private double foodAmount;
private String images;
} }
} }
} }
package com.gingersoft.supply_chain.mvp.bean; package com.gingersoft.supply_chain.mvp.bean;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import lombok.Data; import lombok.Data;
...@@ -13,32 +14,67 @@ import lombok.Data; ...@@ -13,32 +14,67 @@ import lombok.Data;
*/ */
@Data @Data
public class WarehouseDetailsBean { public class WarehouseDetailsBean {
/** /**
* foodNum : 151 * name : 去微软
* purchaseWarehousingOrderDetailsContents : [{"name":"去微软","purchase":"採購入庫","orderNo":"JK11820389311","foodQuantity":17,"totalPrice":102,"createTime":2021,"warningDays":""},{"name":"去微软","purchase":"採購入庫","orderNo":"JK11820389311","foodQuantity":17,"totalPrice":102,"createTime":2021,"warningDays":""}] * purchase : 採購入庫
* orderNo : JK11820389311
* foodQuantity : 17
* totalPrice : 102.0
* createTime : 2021
* warningDays :
*/
private String name;
private String purchase;
private String orderNo;
private double foodQuantity;
private double totalPrice;
// private String createTime;
private String supplierName;
/**
* 單位
*/
private String unitName;
private String foodCategoryName;
/**
* 入庫時間
*/
private String warehousingTime;
/**
* 採購時間
*/ */
private String images; private String purchaseTime;
private int foodNum; /**
private List<PurchaseWarehousingOrderDetailsContentsBean> purchaseWarehousingOrderDetailsContents; * 還有多少天過期,如果是負的,則是已經過期了
*/
private int distanceExpiresTime;
/**
* 預警天數
*/
private int warningDays;
/**
* 消耗狀態,1從未被消耗,2消耗了一部分,3完全消耗
*/
private int consumeStatus;
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;
public static WarehouseDetailsBean getWarehousingByConsume(ConsumeWareHousingBean consumeWareHousingBean) {
WarehouseDetailsBean warehousingBean = new WarehouseDetailsBean();
warehousingBean.name = consumeWareHousingBean.getName();
warehousingBean.unitName = consumeWareHousingBean.getUnitName();
warehousingBean.foodCategoryName = consumeWareHousingBean.getFoodCategoryName();
warehousingBean.purchase = consumeWareHousingBean.getDescription();
warehousingBean.foodQuantity = consumeWareHousingBean.getQuantity();
warehousingBean.purchaseTime = consumeWareHousingBean.getDates();
return warehousingBean;
}
@Data public static List<WarehouseDetailsBean> getWarehousingByConsumes(List<ConsumeWareHousingBean> consumeWareHousingBeans) {
public static class PurchaseWarehousingOrderDetailsContentsBean { List<WarehouseDetailsBean> warehousings = new ArrayList<>();
/** for (ConsumeWareHousingBean consumeWareHousingBean : consumeWareHousingBeans) {
* name : 去微软 warehousings.add(getWarehousingByConsume(consumeWareHousingBean));
* purchase : 採購入庫 }
* orderNo : JK11820389311 return warehousings;
* foodQuantity : 17
* totalPrice : 102.0
* createTime : 2021
* warningDays :
*/
private String name;
private String purchase;
private String orderNo;
private int foodQuantity;
private double totalPrice;
private int createTime;
private String warningDays;
} }
} }
...@@ -6,6 +6,9 @@ import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; ...@@ -6,6 +6,9 @@ import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import java.util.Map; import java.util.Map;
import lombok.NonNull;
import okhttp3.FormBody;
/** /**
* @author 宇航. * @author 宇航.
* User: admin * User: admin
...@@ -16,8 +19,12 @@ import java.util.Map; ...@@ -16,8 +19,12 @@ import java.util.Map;
public class Constant { public class Constant {
public static final int PAGE_SIZE = 10; public static final int PAGE_SIZE = 10;
public static final int PURCHASE_FOOD_MAX = 9999; public static final int PURCHASE_FOOD_MAX = 9999;
/**
* 庫存消耗——盤點消耗的id
*/
public static final int INVENTORY_CONSUME_ID = 5;
public static final int UPDATE = 2;
public static final int DELETE = 1; public static final int DELETE = 1;
public static final int NORMAL = 0; public static final int NORMAL = 0;
/** /**
...@@ -37,7 +44,6 @@ public class Constant { ...@@ -37,7 +44,6 @@ public class Constant {
public static final String IMG_UPLOAD_LOADING = "圖片上傳中..."; public static final String IMG_UPLOAD_LOADING = "圖片上傳中...";
public static final String IMG_UPLOAD_FAIL = "圖片上傳失敗,請稍後重試"; public static final String IMG_UPLOAD_FAIL = "圖片上傳失敗,請稍後重試";
public static final String NULL_INFO_ERROR = "未獲取到數據,請退出後重試"; public static final String NULL_INFO_ERROR = "未獲取到數據,請退出後重試";
public static final String SAVE_LOADING = "保存中..."; public static final String SAVE_LOADING = "保存中...";
public static final String SAVE_SUCCESS = "保存成功"; public static final String SAVE_SUCCESS = "保存成功";
...@@ -49,14 +55,23 @@ public class Constant { ...@@ -49,14 +55,23 @@ public class Constant {
public static final String DELETE_LOADING = "刪除中..."; public static final String DELETE_LOADING = "刪除中...";
public static final String DELETE_SUCCESS = "刪除成功"; public static final String DELETE_SUCCESS = "刪除成功";
public static final String DELETE_FAIL = "刪除失敗,請稍後重試"; public static final String DELETE_FAIL = "刪除失敗,請稍後重試";
public static void addBrandId(Map<String, Object> map) {
public static void addBrandId(@NonNull Map<String, Object> map) {
map.put("brandId", RestaurantInfoManager.newInstance().getBrandId()); map.put("brandId", RestaurantInfoManager.newInstance().getBrandId());
} }
public static void addRestaurantId(Map<String, Object> map) { public static void addRestaurantId(@NonNull Map<String, Object> map) {
map.put("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId()); map.put("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId());
} }
public static void addBrandId(@NonNull FormBody.Builder builder) {
builder.add("brandId", String.valueOf(RestaurantInfoManager.newInstance().getBrandId()));
}
public static void addRestaurantId(@NonNull FormBody.Builder builder) {
builder.add("restaurantId", String.valueOf(RestaurantInfoManager.newInstance().getRestaurantId()));
}
public static void addPageSize(Map<String, Object> map) { public static void addPageSize(Map<String, Object> map) {
map.put("pageSize", PAGE_SIZE); map.put("pageSize", PAGE_SIZE);
} }
......
...@@ -22,8 +22,6 @@ public class SupplyShoppingCart { ...@@ -22,8 +22,6 @@ public class SupplyShoppingCart {
private static SupplyShoppingCart shoppingCart; private static SupplyShoppingCart shoppingCart;
private int goodsNumber = 0;
public static SupplyShoppingCart getInstance() { public static SupplyShoppingCart getInstance() {
if (shoppingCart == null) { if (shoppingCart == null) {
shoppingCart = new SupplyShoppingCart(); shoppingCart = new SupplyShoppingCart();
...@@ -35,9 +33,6 @@ public class SupplyShoppingCart { ...@@ -35,9 +33,6 @@ public class SupplyShoppingCart {
if (cartFoods == null) { if (cartFoods == null) {
cartFoods = new ArrayList<>(); cartFoods = new ArrayList<>();
} }
if (cartFoods.size() != goodsNumber) {
goodsNumber = cartFoods.size();
}
return cartFoods; return cartFoods;
} }
......
...@@ -2,6 +2,8 @@ package com.gingersoft.supply_chain.mvp.contract; ...@@ -2,6 +2,8 @@ package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.common.bean.BaseResult; import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean; import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.jess.arms.mvp.IModel; import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView; import com.jess.arms.mvp.IView;
...@@ -27,19 +29,54 @@ import okhttp3.RequestBody; ...@@ -27,19 +29,54 @@ import okhttp3.RequestBody;
public interface CategoryContract { public interface CategoryContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息 //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView { interface View extends IView {
void loadCategoryInfo(List<FoodCategoryResultBean.DataBean.FoodCategoryBean> list, int hierarchy); /**
* 加載一級級分類,用於新增、修改、刪除分類後,刷新頁面
*
* @param data 分類
*/
void loadCategoryInfo(List<OrderCategoryBean.FoodCategoryTrees> data);
void refreshInfo(int hierarchy, int position); /**
* 加載二級分類,用於新增、修改、刪除二級分類後,刷新頁面
*
* @param data 分類
*/
void loadSecondCategory(List<OrderCategoryBean.FoodCategoryTrees> data);
void loadCategoryFail(); /**
* 加載三級分類,用於新增、修改、刪除三級分類後,刷新頁面
*
* @param data 分類
*/
void loadThirdCategory(List<OrderCategoryBean.FoodCategoryTrees> data);
void loadCategoryError(); /**
* 新增分類
*
* @param categoryTrees 分類信息
* @param hierarchy 新增的是第幾級分類
*/
void addCategory(OrderCategoryBean.FoodCategoryTrees categoryTrees, int hierarchy);
/**
* 修改或刪除分類
*
* @param type 操作類型:刪除或修改 Constant.DELETE Constant.UPDATE
* @param hierarchy 第幾級分類
* @param position 分類下標
* @param categoryName 分類名稱
*/
void updateCategory(int type, int hierarchy, String categoryName, int position);
void onError();
} }
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存 //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel { interface Model extends IModel {
Observable<FoodCategoryResultBean> getFoodCategoryList(Map<String, Object> map); Observable<FoodCategoryResultBean> getFoodCategoryList(Map<String, Object> map);
Observable<OrderCategoryBean> getCategoryTrees(Map<String, Object> map);
Observable<BaseResult> createFoodCategory(RequestBody requestBody); Observable<BaseResult> createFoodCategory(RequestBody requestBody);
Observable<BaseResult> updateFoodCategory(RequestBody requestBody); Observable<BaseResult> updateFoodCategory(RequestBody requestBody);
......
...@@ -2,6 +2,7 @@ package com.gingersoft.supply_chain.mvp.contract; ...@@ -2,6 +2,7 @@ package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.ui.bean.SectionCheckItem; import com.gingersoft.gsa.cloud.ui.bean.SectionCheckItem;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean; import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.jess.arms.mvp.IModel; import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView; import com.jess.arms.mvp.IView;
import com.qmuiteam.qmui.widget.section.QMUISection; import com.qmuiteam.qmui.widget.section.QMUISection;
...@@ -27,12 +28,13 @@ import io.reactivex.Observable; ...@@ -27,12 +28,13 @@ import io.reactivex.Observable;
public interface CategorySelectContract { public interface CategorySelectContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息 //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView { interface View extends IView {
void loadFoodCategory(List<QMUISection<SectionCheckItem, SectionCheckItem>> sections); void loadFoodCategory(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees);
} }
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存 //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel { interface Model extends IModel {
Observable<FoodCategoryResultBean> getFoodCategoryList(Map<String, Object> map); Observable<FoodCategoryResultBean> getFoodCategoryList(Map<String, Object> map);
Observable<OrderCategoryBean> getCategoryTrees(Map<String, Object> map);
} }
} }
...@@ -31,8 +31,16 @@ import okhttp3.RequestBody; ...@@ -31,8 +31,16 @@ import okhttp3.RequestBody;
public interface FoodIngredientsContract { public interface FoodIngredientsContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息 //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView { interface View extends IView {
/**
* 加載左側供應商
* @param categoryBeans 供應商
*/
void loadLeftSupplierInfo(List<CategoryBean> categoryBeans); void loadLeftSupplierInfo(List<CategoryBean> categoryBeans);
/**
* 加載右側食品
* @param purchaseFoodListVOS 食品信息
*/
void loadRightFoodIngredients(List<PurchaseFoodBean> purchaseFoodListVOS); void loadRightFoodIngredients(List<PurchaseFoodBean> purchaseFoodListVOS);
/** /**
...@@ -49,8 +57,15 @@ public interface FoodIngredientsContract { ...@@ -49,8 +57,15 @@ public interface FoodIngredientsContract {
*/ */
void loadCategory(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees); void loadCategory(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees);
/**
* 加載失敗
*/
void loadFail(); void loadFail();
/**
* 修改當前供應商名稱
* @param name 供應商名稱
*/
void setCurrentSupplierName(String name); void setCurrentSupplierName(String name);
} }
......
package com.gingersoft.supply_chain.mvp.contract; package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.common.bean.BaseResult; import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.ConsumeReasonBean;
import com.gingersoft.supply_chain.mvp.bean.WareHouseListBean; import com.gingersoft.supply_chain.mvp.bean.WareHouseListBean;
import com.gingersoft.supply_chain.mvp.bean.WarehouseDetailsBean; import com.gingersoft.supply_chain.mvp.bean.WarehouseDetailsBean;
import com.jess.arms.mvp.IView; import com.jess.arms.mvp.IView;
...@@ -10,6 +11,7 @@ import java.util.List; ...@@ -10,6 +11,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import io.reactivex.Observable; import io.reactivex.Observable;
import okhttp3.RequestBody;
/** /**
...@@ -29,17 +31,50 @@ public interface WarehouseDetailsContract { ...@@ -29,17 +31,50 @@ public interface WarehouseDetailsContract {
interface View extends IView { interface View extends IView {
/** /**
* 加載入庫信息和列表 * 加載入庫信息和列表
*
* @param warehouseDetailsBean * @param warehouseDetailsBean
*/ */
void loadWarehousing(WarehouseDetailsBean warehouseDetailsBean); void loadAdapter(List<WarehouseDetailsBean> warehouseDetailsBean);
void loadAdapter(List<WarehouseDetailsBean.PurchaseWarehousingOrderDetailsContentsBean> purchaseWarehousingOrderDetailsContents); /**
* 加載消耗原因
*
* @param consumeReasonBeans
*/
void loadConsumeReason(List<ConsumeReasonBean> consumeReasonBeans);
/**
* 獲取頁面數據
*/
void getPageInfo();
/**
* 修改庫存數量
*/
void setWarehousingNum(int num);
} }
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存 //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel { interface Model extends IModel {
Observable<BaseResult> getWarehousingOrderDetails(Map<String, Object> map); Observable<BaseResult> getWarehousingOrderDetails(Map<String, Object> map);
Observable<BaseResult> getOutStockDetails(Map<String, Object> map);
Observable<BaseResult> getWarehouseInventoryReason(); Observable<BaseResult> getWarehouseInventoryReason();
/**
* 庫存消耗
*
* @param requestBody
* @return
*/
Observable<BaseResult> consumeWareHousing(RequestBody requestBody);
/**
* 獲取庫存數量
*/
Observable<BaseResult> getWarehousingNum(Map<String, Object> map);
} }
} }
package com.gingersoft.supply_chain.mvp.contract; package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.jess.arms.mvp.IView; import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel; import com.jess.arms.mvp.IModel;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/** /**
* ================================================ * ================================================
...@@ -19,11 +23,17 @@ import com.jess.arms.mvp.IModel; ...@@ -19,11 +23,17 @@ import com.jess.arms.mvp.IModel;
public interface WarehousingInventoryContract { public interface WarehousingInventoryContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息 //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView { interface View extends IView {
void updateSuccess();
} }
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存 //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel { interface Model extends IModel {
/**
* 庫存消耗
*
* @param requestBody
* @return
*/
Observable<BaseResult> consumeWareHousing(RequestBody requestBody);
} }
} }
...@@ -4,6 +4,7 @@ import android.app.Application; ...@@ -4,6 +4,7 @@ import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult; import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean; import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.contract.CategoryContract; import com.gingersoft.supply_chain.mvp.contract.CategoryContract;
import com.gingersoft.supply_chain.mvp.server.SupplierServer; import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson; import com.google.gson.Gson;
...@@ -57,6 +58,11 @@ public class CategoryModel extends BaseModel implements CategoryContract.Model { ...@@ -57,6 +58,11 @@ public class CategoryModel extends BaseModel implements CategoryContract.Model {
} }
@Override @Override
public Observable<OrderCategoryBean> getCategoryTrees(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getCategoryTrees(map);
}
@Override
public Observable<BaseResult> createFoodCategory(RequestBody requestBody) { public Observable<BaseResult> createFoodCategory(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).addFoodCategory(requestBody); return mRepositoryManager.obtainRetrofitService(SupplierServer.class).addFoodCategory(requestBody);
} }
......
...@@ -3,6 +3,7 @@ package com.gingersoft.supply_chain.mvp.model; ...@@ -3,6 +3,7 @@ package com.gingersoft.supply_chain.mvp.model;
import android.app.Application; import android.app.Application;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean; import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.contract.CategorySelectContract; import com.gingersoft.supply_chain.mvp.contract.CategorySelectContract;
import com.gingersoft.supply_chain.mvp.server.SupplierServer; import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson; import com.google.gson.Gson;
...@@ -52,4 +53,9 @@ public class CategorySelectModel extends BaseModel implements CategorySelectCont ...@@ -52,4 +53,9 @@ public class CategorySelectModel extends BaseModel implements CategorySelectCont
public Observable<FoodCategoryResultBean> getFoodCategoryList(Map<String, Object> map) { public Observable<FoodCategoryResultBean> getFoodCategoryList(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getFoodCategoryList(map); return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getFoodCategoryList(map);
} }
@Override
public Observable<OrderCategoryBean> getCategoryTrees(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getCategoryTrees(map);
}
} }
\ No newline at end of file
...@@ -17,6 +17,7 @@ import com.gingersoft.supply_chain.mvp.contract.WarehouseDetailsContract; ...@@ -17,6 +17,7 @@ import com.gingersoft.supply_chain.mvp.contract.WarehouseDetailsContract;
import java.util.Map; import java.util.Map;
import io.reactivex.Observable; import io.reactivex.Observable;
import okhttp3.RequestBody;
/** /**
...@@ -56,7 +57,24 @@ public class WarehouseDetailsModel extends BaseModel implements WarehouseDetails ...@@ -56,7 +57,24 @@ public class WarehouseDetailsModel extends BaseModel implements WarehouseDetails
} }
@Override @Override
public Observable<BaseResult> getOutStockDetails(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getOutStockDetails(map);
}
@Override
public Observable<BaseResult> getWarehouseInventoryReason() { public Observable<BaseResult> getWarehouseInventoryReason() {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getWarehouseInventoryReason(); return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getWarehouseInventoryReason();
} }
@Override
public Observable<BaseResult> consumeWareHousing(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).consumeWareHousing(requestBody);
}
@Override
public Observable<BaseResult> getWarehousingNum(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getWarehousingNum(map);
}
} }
\ No newline at end of file
...@@ -2,6 +2,8 @@ package com.gingersoft.supply_chain.mvp.model; ...@@ -2,6 +2,8 @@ package com.gingersoft.supply_chain.mvp.model;
import android.app.Application; import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager; import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel; import com.jess.arms.mvp.BaseModel;
...@@ -12,6 +14,9 @@ import javax.inject.Inject; ...@@ -12,6 +14,9 @@ import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract; import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/** /**
* ================================================ * ================================================
...@@ -43,4 +48,9 @@ public class WarehousingInventoryModel extends BaseModel implements WarehousingI ...@@ -43,4 +48,9 @@ public class WarehousingInventoryModel extends BaseModel implements WarehousingI
this.mGson = null; this.mGson = null;
this.mApplication = null; this.mApplication = null;
} }
@Override
public Observable<BaseResult> consumeWareHousing(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).consumeWareHousing(requestBody);
}
} }
\ No newline at end of file
...@@ -127,17 +127,10 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr ...@@ -127,17 +127,10 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
if (supplierId != -1) { if (supplierId != -1) {
map.put("supplierId", supplierId); map.put("supplierId", supplierId);
} }
Log.e("eee", "loadFoodIngredientsData" + android.os.Process.myTid());
mModel.getFoodIngredientsData(map) mModel.getFoodIngredientsData(map)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> { .doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
Log.e("eee", "doOnSubscribe" + android.os.Process.myTid()); .doAfterTerminate(() -> mRootView.hideLoading())
mRootView.showLoading("獲取中...");
})
.doAfterTerminate(() -> {
Log.e("eee", "doAfterTerminate" + android.os.Process.myTid());
mRootView.hideLoading();
})
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribeOn(AndroidSchedulers.mainThread()) .subscribeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView)) .compose(RxLifecycleUtils.bindToLifecycle(mRootView))
...@@ -145,7 +138,6 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr ...@@ -145,7 +138,6 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
.subscribe(new ErrorHandleSubscriber<FoodListInfoBean>(mErrorHandler) { .subscribe(new ErrorHandleSubscriber<FoodListInfoBean>(mErrorHandler) {
@Override @Override
public void onNext(@NonNull FoodListInfoBean info) { public void onNext(@NonNull FoodListInfoBean info) {
Log.e("eee", "onNext" + android.os.Process.myTid());
if (info.isSuccess() && info.getData() != null) { if (info.isSuccess() && info.getData() != null) {
categoryBeans = new ArrayList<>(); categoryBeans = new ArrayList<>();
if (supplierFoodsMap == null) { if (supplierFoodsMap == null) {
...@@ -173,8 +165,6 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr ...@@ -173,8 +165,6 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
RxJavaUtils.doInUIThread(new RxUITask<Object>(0) { RxJavaUtils.doInUIThread(new RxUITask<Object>(0) {
@Override @Override
public void doInUIThread(Object o) { public void doInUIThread(Object o) {
Log.e("eee", "doInUIThread" + android.os.Process.myTid());
mRootView.loadLeftSupplierInfo(categoryBeans); mRootView.loadLeftSupplierInfo(categoryBeans);
if (info.getData().size() > 0) { if (info.getData().size() > 0) {
mRootView.setCurrentSupplierName(info.getData().get(0).getSupplierName()); mRootView.setCurrentSupplierName(info.getData().get(0).getSupplierName());
...@@ -325,18 +315,27 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr ...@@ -325,18 +315,27 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
* *
* @param position * @param position
*/ */
public void deleteFood(int foodId, int position) { public void deleteFood(int foodId, int supplierId, int categoryId, int position) {
mModel.deleteFood(foodId) mModel.deleteFood(foodId)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("刪除中...")) .doOnSubscribe(disposable -> mRootView.showLoading("刪除中..."))
.subscribeOn(AndroidSchedulers.mainThread()) .subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading()) .doAfterNext(dis -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView)) .compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) { .subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override @Override
public void onNext(BaseResult baseResult) { public void onNext(BaseResult baseResult) {
if (baseResult.isSuccess()) { if (baseResult.isSuccess()) {
//需要在供應商和分類的緩存中這個食品移除
if (supplierFoodsMap != null) {
List<PurchaseFoodBean> purchaseFoodBeans = supplierFoodsMap.get(supplierId);
if (purchaseFoodBeans != null && position < purchaseFoodBeans.size()) {
purchaseFoodBeans.remove(position);
}
}
//移除在分類中的緩存
removeCacheByCategoryId(categoryId);
mRootView.onDeleteFoodSuccess(position); mRootView.onDeleteFoodSuccess(position);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) { } else if (TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg()); mRootView.showMessage(baseResult.getErrMsg());
...@@ -360,7 +359,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr ...@@ -360,7 +359,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
Constant.addRestaurantId(map); Constant.addRestaurantId(map);
mModel.getCategoryTrees(map) mModel.getCategoryTrees(map)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("獲取中...")) .doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
.subscribeOn(AndroidSchedulers.mainThread()) .subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading()) .doAfterTerminate(() -> mRootView.hideLoading())
...@@ -389,7 +388,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr ...@@ -389,7 +388,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
} else if (TextUtil.isNotEmptyOrNullOrUndefined(orderCategoryBean.getErrMsg())) { } else if (TextUtil.isNotEmptyOrNullOrUndefined(orderCategoryBean.getErrMsg())) {
mRootView.showMessage(orderCategoryBean.getErrMsg()); mRootView.showMessage(orderCategoryBean.getErrMsg());
} else { } else {
mRootView.showMessage("獲取失敗,請稍候重試"); mRootView.showMessage(Constant.GET_INFO_ERROR);
} }
} }
...@@ -423,21 +422,45 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr ...@@ -423,21 +422,45 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
}); });
} }
// private void getCategoryById(){
// foodCategoryTrees
// }
/** /**
* 根據分類id移除緩存 * 根據分類id移除緩存
* *
* @param categoryId * @param categoryId
*/ */
public void removeCacheByCategoryId(int categoryId) { public void removeCacheByCategoryId(int categoryId) {
RxJavaUtils.doInIOThread(new RxIOTask<Integer>(categoryId) { if (categoryFoodTreeBeans != null) {
for (CategoryFoodTreeBean categoryFoodTreeBean : categoryFoodTreeBeans) {
if (categoryFoodTreeBean.getCategoryIds().contains(categoryId)) {
//清空這個分類下所有的食材
categoryFoodTreeBean.setFoodInfo(null);
break;
}
}
}
}
/**
* 根據分類名字移除緩存
*
* @param categoryName 分類名字
*/
public void removeCacheByCategoryName(String categoryName) {
RxJavaUtils.doInIOThread(new RxIOTask<String>(categoryName) {
@Override @Override
public Void doInIOThread(Integer id) { public Void doInIOThread(String name) {
for (CategoryFoodTreeBean categoryFoodTreeBean : categoryFoodTreeBeans) { for (CategoryFoodTreeBean categoryFoodTreeBean : categoryFoodTreeBeans) {
if (categoryFoodTreeBean.getCategoryIds().contains(id)) { if (categoryFoodTreeBean.getCategoryNames().contains(name)) {
// int categoryIndex = categoryFoodTreeBean.getCategoryNames().indexOf(name);
//清空這個分類下所有的食材 //清空這個分類下所有的食材
categoryFoodTreeBean.setFoodInfo(null); categoryFoodTreeBean.setFoodInfo(null);
//重新從接口獲取 // //重新從接口獲取
// getFoodByCategory(categoryId); // if (categoryIndex != -1) {
// getFoodByCategory(categoryFoodTreeBean.getCategoryIds().get(categoryIndex));
// }
break; break;
} }
} }
...@@ -447,16 +470,19 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr ...@@ -447,16 +470,19 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
} }
/** /**
* 根據分類名字移除緩存 * 根據分類Id移除緩存
* *
* @param categoryName 分類名字 * @param categoryId 分類名字
*/ */
public void removeCacheByCategoryName(String categoryName) { public void removeCacheByCategoryId(Integer categoryId) {
RxJavaUtils.doInIOThread(new RxIOTask<String>(categoryName) { RxJavaUtils.doInIOThread(new RxIOTask<Integer>(categoryId) {
@Override @Override
public Void doInIOThread(String name) { public Void doInIOThread(Integer categoryId) {
if (categoryId == null) {
return null;
}
for (CategoryFoodTreeBean categoryFoodTreeBean : categoryFoodTreeBeans) { for (CategoryFoodTreeBean categoryFoodTreeBean : categoryFoodTreeBeans) {
if (categoryFoodTreeBean.getCategoryNames().contains(name)) { if (categoryFoodTreeBean.getCategoryIds().contains(categoryId)) {
// int categoryIndex = categoryFoodTreeBean.getCategoryNames().indexOf(name); // int categoryIndex = categoryFoodTreeBean.getCategoryNames().indexOf(name);
//清空這個分類下所有的食材 //清空這個分類下所有的食材
categoryFoodTreeBean.setFoodInfo(null); categoryFoodTreeBean.setFoodInfo(null);
...@@ -523,7 +549,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr ...@@ -523,7 +549,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
//用於提前終止循環,如果已經拿到過這個分類下的數據,後面沒有這個分類下的數據了,就終止循環 //用於提前終止循環,如果已經拿到過這個分類下的數據,後面沒有這個分類下的數據了,就終止循環
boolean hasFood = false; boolean hasFood = false;
for (PurchaseFoodBean purchaseFoodBean : foodInfo) { for (PurchaseFoodBean purchaseFoodBean : foodInfo) {
if (purchaseFoodBean.getFoodCategoryId() == id) { if (id.equals(purchaseFoodBean.getFoodCategoryId())) {
hasFood = true; hasFood = true;
foods.add(purchaseFoodBean); foods.add(purchaseFoodBean);
} else if (hasFood) { } else if (hasFood) {
...@@ -550,7 +576,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr ...@@ -550,7 +576,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
.doOnSubscribe(disposable -> mRootView.showLoading("獲取中...")) .doOnSubscribe(disposable -> mRootView.showLoading("獲取中..."))
.subscribeOn(AndroidSchedulers.mainThread()) .subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading()) .doAfterNext(dis -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView)) .compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<FoodByCategoryResultBean>(mErrorHandler) { .subscribe(new ErrorHandleSubscriber<FoodByCategoryResultBean>(mErrorHandler) {
......
...@@ -149,7 +149,7 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo ...@@ -149,7 +149,7 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo
} }
public void addDeputyUnit(List<DeputyUnitBean> data) { public void addDeputyUnit(List<DeputyUnitBean> data) {
//新增為true,修改為false //新增為false,修改為true
if (isUpdate) { if (isUpdate) {
if (data == null) { if (data == null) {
mRootView.callBackDeputyUnit(null); mRootView.callBackDeputyUnit(null);
...@@ -158,11 +158,13 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo ...@@ -158,11 +158,13 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo
} }
} else { } else {
//如果是新增食材,那麼單位返回到新增食材頁面就好,不用做其他處理 //如果是新增食材,那麼單位返回到新增食材頁面就好,不用做其他處理
Iterator<DeputyUnitBean> iterator = data.iterator(); if (data != null) {
while (iterator.hasNext()) { Iterator<DeputyUnitBean> iterator = data.iterator();
if (TextUtil.isEmptyOrNullOrUndefined(iterator.next().getDeputyUnit())) { while (iterator.hasNext()) {
//單位為空,移除掉 if (TextUtil.isEmptyOrNullOrUndefined(iterator.next().getDeputyUnit())) {
iterator.remove(); //單位為空,移除掉
iterator.remove();
}
} }
} }
mRootView.callBackDeputyUnit(data); mRootView.callBackDeputyUnit(data);
...@@ -248,12 +250,13 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo ...@@ -248,12 +250,13 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo
/** /**
* 添加基本單位-快捷輸入 * 添加基本單位-快捷輸入
* @param content 新增的基本單位 *
* @param content 新增的基本單位
* @param basicUnitBeans 已有的基本單位——需要判斷是否已經存在了 * @param basicUnitBeans 已有的基本單位——需要判斷是否已經存在了
*/ */
public void addBasicUnit(String content, List<BasicUnitBean> basicUnitBeans) { public void addBasicUnit(String content, List<BasicUnitBean> basicUnitBeans) {
for (BasicUnitBean basicUnitBean : basicUnitBeans) { for (BasicUnitBean basicUnitBean : basicUnitBeans) {
if(basicUnitBean.getContent().equals(content)){ if (basicUnitBean.getContent().equals(content)) {
mRootView.showMessage("此單位已存在,不能重複添加"); mRootView.showMessage("此單位已存在,不能重複添加");
return; return;
} }
......
...@@ -8,6 +8,7 @@ import android.view.inputmethod.EditorInfo; ...@@ -8,6 +8,7 @@ import android.view.inputmethod.EditorInfo;
import com.gingersoft.gsa.cloud.common.bean.BaseResult; import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager; 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.JsonUtils;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils; import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.inputFilter.DecimalDigitsInputFilter; import com.gingersoft.gsa.cloud.common.utils.inputFilter.DecimalDigitsInputFilter;
...@@ -21,6 +22,7 @@ import com.gingersoft.gsa.cloud.ui.adapter.bean.UploadPicMultiBean; ...@@ -21,6 +22,7 @@ import com.gingersoft.gsa.cloud.ui.adapter.bean.UploadPicMultiBean;
import com.gingersoft.gsa.cloud.ui.bean.SectionCheckItem; import com.gingersoft.gsa.cloud.ui.bean.SectionCheckItem;
import com.gingersoft.supply_chain.R; import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.DeputyUnitBean; import com.gingersoft.supply_chain.mvp.bean.DeputyUnitBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean; import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean; import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.content.Constant; import com.gingersoft.supply_chain.mvp.content.Constant;
...@@ -111,7 +113,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient ...@@ -111,7 +113,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
* 副單位集合 * 副單位集合
*/ */
private List<DeputyUnitBean> deputyUnitBeans; private List<DeputyUnitBean> deputyUnitBeans;
private String categoryName = ""; // private String categoryName = "";
private String picUrl; private String picUrl;
/** /**
* 如果是修改食材,則不為空 * 如果是修改食材,則不為空
...@@ -144,6 +146,13 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient ...@@ -144,6 +146,13 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
this.categoryNames = categoryNames; this.categoryNames = categoryNames;
} }
public String getCategoryName() {
if (categoryNames != null && categoryNames.size() > 0) {
return categoryNames.get(categoryNames.size() - 1);
}
return "";
}
/** /**
* 獲取食材詳情 * 獲取食材詳情
*/ */
...@@ -195,7 +204,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient ...@@ -195,7 +204,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "食材名稱", true, "請輸入名稱")); infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "食材名稱", true, "請輸入名稱"));
infoMultiBeans.add(new MultiSelectBean(InfoMultiBean.EDIT_FOOD_ITEM_SELECT, "食材類別", true, "請選擇食材類別", SELECT_FOOD_CATEGORY_REQUEST_CODE, CategorySelectFragment.class)); infoMultiBeans.add(new MultiSelectBean(InfoMultiBean.EDIT_FOOD_ITEM_SELECT, "食材類別", true, "請選擇食材類別", SELECT_FOOD_CATEGORY_REQUEST_CODE, CategorySelectFragment.class));
infoMultiBeans.add(new MultiSelectBean(InfoMultiBean.EDIT_FOOD_ITEM_SELECT, "基本單位", true, "請選擇食材單位", SELECT_PACKAGE_SPECIFICATION_REQUEST_CODE, FoodUnitPageFragment.class)); infoMultiBeans.add(new MultiSelectBean(InfoMultiBean.EDIT_FOOD_ITEM_SELECT, "基本單位", true, "請選擇食材單位", SELECT_PACKAGE_SPECIFICATION_REQUEST_CODE, FoodUnitPageFragment.class));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "包裝說明", false, "請輸入包裝說明")); infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "包裝說明", false, "請輸入包裝說明", new InputFilter[]{new InputFilter.LengthFilter(4)}));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "食材編號", false, "請輸入食材編號")); infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "食材編號", false, "請輸入食材編號"));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "單價($)", false, "請輸入單價,保留2位小數", new InputFilter[]{InputFilterUtils.getLengthFilter(context, 9), new DecimalDigitsInputFilter(context, 2)}, InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL)); infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "單價($)", false, "請輸入單價,保留2位小數", new InputFilter[]{InputFilterUtils.getLengthFilter(context, 9), new DecimalDigitsInputFilter(context, 2)}, InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_LINE)); infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_LINE));
...@@ -213,11 +222,8 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient ...@@ -213,11 +222,8 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
//食品名稱 //食品名稱
infoMultiBeans.get(foodNameIndex).setShowValue(purchaseFoodBean.getName()); infoMultiBeans.get(foodNameIndex).setShowValue(purchaseFoodBean.getName());
//食品分類 //食品分類
if (categoryNames != null && categoryNames.size() > 0) { categoryNames = new ArrayList<>();
categoryName = categoryNames.get(categoryNames.size() - 1); categoryNames.add(purchaseFoodBean.getFoodCategoryName());
} else {
categoryName = purchaseFoodBean.getFoodCategoryName();
}
infoMultiBeans.get(foodIngredientCategoryIndex).setShowValue(purchaseFoodBean.getFoodCategoryName()); infoMultiBeans.get(foodIngredientCategoryIndex).setShowValue(purchaseFoodBean.getFoodCategoryName());
//基本單位 //基本單位
infoMultiBeans.get(basicUnitIndex).setShowValue(purchaseFoodBean.getBasicUnitName()); infoMultiBeans.get(basicUnitIndex).setShowValue(purchaseFoodBean.getBasicUnitName());
...@@ -255,11 +261,11 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient ...@@ -255,11 +261,11 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
return infoMultiBeans.get(basicUnitIndex).getShowValue(); return infoMultiBeans.get(basicUnitIndex).getShowValue();
} }
public int getFoodId() { public Integer getFoodId() {
if (purchaseFoodBean != null) { if (purchaseFoodBean != null) {
return purchaseFoodBean.getId(); return purchaseFoodBean.getId();
} }
return 0; return null;
} }
public void setPicUrl(List<InfoMultiBean> data, List<String> picUrls) { public void setPicUrl(List<InfoMultiBean> data, List<String> picUrls) {
...@@ -300,19 +306,18 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient ...@@ -300,19 +306,18 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
mRootView.refreshAdapterByPosition(basicUnitIndex); mRootView.refreshAdapterByPosition(basicUnitIndex);
} }
public void setCategoryInfo(List<SectionCheckItem> sectionCheckItems, List<InfoMultiBean> infoMultiBeans) { public void setCategoryInfo(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees, List<InfoMultiBean> infoMultiBeans) {
StringBuilder categoryName = new StringBuilder(); StringBuilder categoryName = new StringBuilder();
if (categoryNames == null) { if (categoryNames == null) {
categoryNames = new ArrayList<>(); categoryNames = new ArrayList<>();
} }
categoryNames.clear(); categoryNames.clear();
for (SectionCheckItem sectionCheckItem : sectionCheckItems) { for (OrderCategoryBean.FoodCategoryTrees categoryTrees : foodCategoryTrees) {
categoryNames.add(sectionCheckItem.getText()); categoryNames.add(categoryTrees.getName());
categoryName.append(sectionCheckItem.getText()) categoryName.append(categoryTrees.getName())
.append(PurchaseFoodBean.CATEGORY_DIVIDER); .append(PurchaseFoodBean.CATEGORY_DIVIDER);
} }
this.categoryName = sectionCheckItems.get(sectionCheckItems.size() - 1).getText();
categoryName.deleteCharAt(categoryName.lastIndexOf(PurchaseFoodBean.CATEGORY_DIVIDER)); categoryName.deleteCharAt(categoryName.lastIndexOf(PurchaseFoodBean.CATEGORY_DIVIDER));
infoMultiBeans.get(foodIngredientCategoryIndex).setShowValue(categoryName.toString()); infoMultiBeans.get(foodIngredientCategoryIndex).setShowValue(categoryName.toString());
mRootView.refreshAdapterByPosition(foodIngredientCategoryIndex); mRootView.refreshAdapterByPosition(foodIngredientCategoryIndex);
...@@ -320,6 +325,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient ...@@ -320,6 +325,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
/** /**
* 上傳圖片 * 上傳圖片
*
* @param filePath 圖片路徑 * @param filePath 圖片路徑
*/ */
public void uploadPic(String filePath) { public void uploadPic(String filePath) {
...@@ -385,6 +391,8 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient ...@@ -385,6 +391,8 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
* @param purchaseFoodBean * @param purchaseFoodBean
*/ */
public void updateFood(PurchaseFoodBean purchaseFoodBean) { public void updateFood(PurchaseFoodBean purchaseFoodBean) {
//後台不要,不然修改供應商不成功
purchaseFoodBean.setSupplierId(null);
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(purchaseFoodBean)); RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(purchaseFoodBean));
mModel.updateFood(requestBody) mModel.updateFood(requestBody)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
...@@ -414,7 +422,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient ...@@ -414,7 +422,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
msg = "請輸入供應商名稱"; msg = "請輸入供應商名稱";
} else if (TextUtil.isEmptyOrNullOrUndefined(infoMultiBeans.get(foodNameIndex).getShowValue())) { } else if (TextUtil.isEmptyOrNullOrUndefined(infoMultiBeans.get(foodNameIndex).getShowValue())) {
msg = "請輸入食材名稱"; msg = "請輸入食材名稱";
} else if (TextUtil.isEmptyOrNullOrUndefined(categoryName)) { } else if (TextUtil.isEmptyOrNullOrUndefined(getCategoryName())) {
msg = "請選擇食材類別"; msg = "請選擇食材類別";
} else if (TextUtil.isEmptyOrNullOrUndefined(infoMultiBeans.get(basicUnitIndex).getShowValue())) { } else if (TextUtil.isEmptyOrNullOrUndefined(infoMultiBeans.get(basicUnitIndex).getShowValue())) {
msg = "請選擇基本單位"; msg = "請選擇基本單位";
...@@ -430,6 +438,8 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient ...@@ -430,6 +438,8 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
if (purchaseFoodBean == null) { if (purchaseFoodBean == null) {
purchaseFoodBean = new PurchaseFoodBean(); purchaseFoodBean = new PurchaseFoodBean();
} }
//這裡拷貝一個類出來,如果本次修改食材沒有成功,也不會影響原有數據
PurchaseFoodBean purchaseFoodBean = (PurchaseFoodBean) PurchaseFoodBean.copy(this.purchaseFoodBean);
//食材圖片 //食材圖片
if (TextUtil.isNotEmptyOrNullOrUndefined(picUrl)) { if (TextUtil.isNotEmptyOrNullOrUndefined(picUrl)) {
purchaseFoodBean.setImages(picUrl); purchaseFoodBean.setImages(picUrl);
...@@ -439,7 +449,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient ...@@ -439,7 +449,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
//食材名稱 //食材名稱
purchaseFoodBean.setName(infoMultiBeans.get(foodNameIndex).getShowValue()); purchaseFoodBean.setName(infoMultiBeans.get(foodNameIndex).getShowValue());
//食材類別名稱 //食材類別名稱
purchaseFoodBean.setFoodCategoryName(categoryName); purchaseFoodBean.setFoodCategoryName(getCategoryName());
//食材基本單位 //食材基本單位
purchaseFoodBean.setBasicUnitName(infoMultiBeans.get(basicUnitIndex).getShowValue()); purchaseFoodBean.setBasicUnitName(infoMultiBeans.get(basicUnitIndex).getShowValue());
//包裝描述 //包裝描述
...@@ -498,9 +508,10 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient ...@@ -498,9 +508,10 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
if (!isUpdateAlarm && shelfLifeWarning.equals(purchaseFoodBean.getInventoryAlarm().getWarningDays() + "")) { if (!isUpdateAlarm && shelfLifeWarning.equals(purchaseFoodBean.getInventoryAlarm().getWarningDays() + "")) {
isUpdateAlarm = true; isUpdateAlarm = true;
} }
if (!isUpdateAlarm) { if (isUpdateAlarm) {
//修改了庫存預警,並且之前的預警不為空,把id設置上 //修改了庫存預警,並且之前的預警不為空,把id設置上
inventoryAlarm.setId(purchaseFoodBean.getInventoryAlarm().getId()); inventoryAlarm.setId(purchaseFoodBean.getInventoryAlarm().getId());
purchaseFoodBean.setInventoryAlarm(inventoryAlarm);
} else { } else {
//沒修改庫存預警,就不傳給後台 //沒修改庫存預警,就不傳給後台
purchaseFoodBean.setInventoryAlarm(null); purchaseFoodBean.setInventoryAlarm(null);
......
...@@ -202,7 +202,6 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode ...@@ -202,7 +202,6 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
if (v instanceof EditText) { if (v instanceof EditText) {
if (!hasFocus) { if (!hasFocus) {
EditText editText = (EditText) v; EditText editText = (EditText) v;
if (TextUtil.isNotEmptyOrNullOrUndefined(editText)) { if (TextUtil.isNotEmptyOrNullOrUndefined(editText)) {
if(TextUtil.isNotEmptyOrNullOrUndefined(supplierName)){ if(TextUtil.isNotEmptyOrNullOrUndefined(supplierName)){
//當供應商名稱不為空時,是修改供應商 //當供應商名稱不為空時,是修改供應商
......
...@@ -38,6 +38,7 @@ import java.util.ArrayList; ...@@ -38,6 +38,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
...@@ -45,6 +46,8 @@ import java.util.Objects; ...@@ -45,6 +46,8 @@ import java.util.Objects;
import static com.gingersoft.supply_chain.mvp.content.Constant.GET_INFO_ERROR; import static com.gingersoft.supply_chain.mvp.content.Constant.GET_INFO_ERROR;
import static com.gingersoft.supply_chain.mvp.content.Constant.GET_INFO_LOADING; import static com.gingersoft.supply_chain.mvp.content.Constant.GET_INFO_LOADING;
import static com.gingersoft.supply_chain.mvp.content.Constant.NULL_INFO_ERROR; import static com.gingersoft.supply_chain.mvp.content.Constant.NULL_INFO_ERROR;
import static com.gingersoft.supply_chain.mvp.content.Constant.SAVE_FAIL;
import static com.gingersoft.supply_chain.mvp.content.Constant.SAVE_LOADING;
/** /**
...@@ -75,6 +78,10 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -75,6 +78,10 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
* 所上傳的圖片路徑集合 * 所上傳的圖片路徑集合
*/ */
private List<String> imgs; private List<String> imgs;
/**
* 逗號分隔符
*/
private final String COMMA_SEPARATED = ",";
@Inject @Inject
public OrderDetailsPresenter(OrderDetailsContract.Model model, OrderDetailsContract.View rootView) { public OrderDetailsPresenter(OrderDetailsContract.Model model, OrderDetailsContract.View rootView) {
...@@ -111,6 +118,8 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -111,6 +118,8 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
if (orderDetailsBean != null) { if (orderDetailsBean != null) {
OrderDetailsPresenter.this.orderId = orderId; OrderDetailsPresenter.this.orderId = orderId;
transformationWareHouse(orderDetailsBean); transformationWareHouse(orderDetailsBean);
//加載圖片
loadImages(orderDetailsBean.getFiles());
mRootView.loadOrderDetails(orderDetailsBean); mRootView.loadOrderDetails(orderDetailsBean);
} else { } else {
mRootView.showMessage(GET_INFO_ERROR); mRootView.showMessage(GET_INFO_ERROR);
...@@ -138,7 +147,6 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -138,7 +147,6 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
purchaseOrderDetailsInfoVO.setOrderNo(orderDetailsBean.getOrderNo()); purchaseOrderDetailsInfoVO.setOrderNo(orderDetailsBean.getOrderNo());
//單位 //單位
List<DeputyUnitBean> deputyUnitBeans = purchaseOrderDetailsInfoVO.getFoodUnits(); List<DeputyUnitBean> deputyUnitBeans = purchaseOrderDetailsInfoVO.getFoodUnits();
//計算出當前食材總金額 //計算出當前食材總金額
double warehousingAmount = MoneyUtil.priceCalculation(purchaseOrderDetailsInfoVO.getFoodPrice(), purchaseOrderDetailsInfoVO.getFoodQuantity()); double warehousingAmount = MoneyUtil.priceCalculation(purchaseOrderDetailsInfoVO.getFoodPrice(), purchaseOrderDetailsInfoVO.getFoodQuantity());
...@@ -169,6 +177,13 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -169,6 +177,13 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
if (wareHousingUnitBean != null) { if (wareHousingUnitBean != null) {
//只有一個入庫單位 //只有一個入庫單位
DeputyUnitBean warehouseUnit = DeputyUnitBean.getDeputyUnitByWareHousingUnit(wareHousingUnitBean); DeputyUnitBean warehouseUnit = DeputyUnitBean.getDeputyUnitByWareHousingUnit(wareHousingUnitBean);
if (purchaseOrderDetailsInfoVO.getStatus() == PurchaseOrderDetailsBean.COMPLETE_RECEIVED) {
//已經全部收貨,顯示已入庫數量
warehouseUnit.setDeputyValue(purchaseOrderDetailsInfoVO.getWarehousingQuantity());
} else {
//已經入庫一次的食材,數量顯示為食材總數-已入庫數量
warehouseUnit.setDeputyValue(Math.max(MoneyUtil.sub(purchaseOrderDetailsInfoVO.getFoodQuantity(), purchaseOrderDetailsInfoVO.getWarehousingQuantity()), 0));
}
purchaseOrderDetailsInfoVO.setShowUnit(warehouseUnit); purchaseOrderDetailsInfoVO.setShowUnit(warehouseUnit);
purchaseOrderDetailsInfoVO.setFoodUnits(Collections.singletonList(warehouseUnit)); purchaseOrderDetailsInfoVO.setFoodUnits(Collections.singletonList(warehouseUnit));
} }
...@@ -189,6 +204,26 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -189,6 +204,26 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
} }
/** /**
* 加載圖片
*
* @param images
*/
public void loadImages(String images) {
if (TextUtil.isNotEmptyOrNullOrUndefined(images)) {
String[] split = images.split(COMMA_SEPARATED);
if (imgs == null) {
imgs = new ArrayList<>();
}
for (String s : split) {
if (TextUtil.isNotEmptyOrNullOrUndefined(s)) {
mRootView.uploadPicSuccess(s);
imgs.add(s);
}
}
}
}
/**
* 入庫 * 入庫
* *
* @param state 入庫狀態 * @param state 入庫狀態
...@@ -205,7 +240,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -205,7 +240,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(wareHouseBean)); RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(wareHouseBean));
mModel.addWarehouse(requestBody) mModel.addWarehouse(requestBody)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(GET_INFO_LOADING)) .doOnSubscribe(disposable -> mRootView.showLoading(SAVE_LOADING))
.subscribeOn(AndroidSchedulers.mainThread()) .subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading()) .doAfterTerminate(() -> mRootView.hideLoading())
...@@ -219,7 +254,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -219,7 +254,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
} else if (TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) { } else if (TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg()); mRootView.showMessage(baseResult.getErrMsg());
} else { } else {
mRootView.showMessage(GET_INFO_ERROR); mRootView.showMessage(SAVE_FAIL);
} }
} }
}); });
...@@ -240,7 +275,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -240,7 +275,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
if (imgs != null) { if (imgs != null) {
StringBuilder files = new StringBuilder(); StringBuilder files = new StringBuilder();
for (String img : imgs) { for (String img : imgs) {
files.append(img).append(","); files.append(img).append(COMMA_SEPARATED);
} }
String substring = files.substring(0, files.length()); String substring = files.substring(0, files.length());
purchaseWarehousingOrder.setFiles(substring); purchaseWarehousingOrder.setFiles(substring);
...@@ -264,7 +299,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo ...@@ -264,7 +299,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
} }
List<OrderWareHouseBean.PurchaseWarehousingOrderDetail> purchaseWarehousingOrderDetails = new ArrayList<>(); List<OrderWareHouseBean.PurchaseWarehousingOrderDetail> purchaseWarehousingOrderDetails = new ArrayList<>();
for (PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean purchaseOrderDetailsInfoVosBean : purchaseOrderDetailsInfoVosBeans) { for (PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean purchaseOrderDetailsInfoVosBean : purchaseOrderDetailsInfoVosBeans) {
if (purchaseOrderDetailsInfoVosBean.isChecked()) { if (purchaseOrderDetailsInfoVosBean.getStatus() != PurchaseOrderDetailsBean.COMPLETE_RECEIVED && purchaseOrderDetailsInfoVosBean.isChecked()) {
OrderWareHouseBean.PurchaseWarehousingOrderDetail purchaseWarehousingOrderDetail = new OrderWareHouseBean.PurchaseWarehousingOrderDetail(); OrderWareHouseBean.PurchaseWarehousingOrderDetail purchaseWarehousingOrderDetail = new OrderWareHouseBean.PurchaseWarehousingOrderDetail();
purchaseWarehousingOrderDetail.setOrderDetailsId(purchaseOrderDetailsInfoVosBean.getId()); purchaseWarehousingOrderDetail.setOrderDetailsId(purchaseOrderDetailsInfoVosBean.getId());
purchaseWarehousingOrderDetail.setPurchaseFoodId(purchaseOrderDetailsInfoVosBean.getPurchaseFoodId()); purchaseWarehousingOrderDetail.setPurchaseFoodId(purchaseOrderDetailsInfoVosBean.getPurchaseFoodId());
......
...@@ -347,15 +347,8 @@ public class ShoppingCatPresenter extends BasePresenter<ShoppingCatContract.Mode ...@@ -347,15 +347,8 @@ public class ShoppingCatPresenter extends BasePresenter<ShoppingCatContract.Mode
ShoppingCartBean shoppingCartBean = shoppingCartBeans.get(i); ShoppingCartBean shoppingCartBean = shoppingCartBeans.get(i);
//判斷選中了多少個商品,如果這個供應商的食品一個都沒被選中,就不用管 //判斷選中了多少個商品,如果這個供應商的食品一個都沒被選中,就不用管
if (shoppingCartBean.getSelectSpeciesNum() > 0) { if (shoppingCartBean.getSelectSpeciesNum() > 0) {
//計算已選中食品的總金額
double totalAmount = 0;
for (PurchaseFoodBean purchaseFoodBean : shoppingCartBean.getFoodList()) {
if (purchaseFoodBean.isChecked()) {
totalAmount = MoneyUtil.sum(totalAmount, MoneyUtil.priceCalculation(purchaseFoodBean.getUnitPrice(), purchaseFoodBean.getFoodQuantity()));
}
}
//判斷總金額是否滿足最低採購金額 //判斷總金額是否滿足最低採購金額
if (MoneyUtil.compareTo(totalAmount, shoppingCartBean.getMinimumAmount()) == -1) { if (MoneyUtil.compareTo(shoppingCartBean.getSelectFoodAmount(), shoppingCartBean.getMinimumAmount()) == -1) {
//不滿足最低採購金額 //不滿足最低採購金額
return false; return false;
} }
......
...@@ -3,8 +3,11 @@ package com.gingersoft.supply_chain.mvp.presenter; ...@@ -3,8 +3,11 @@ package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application; import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult; import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils; import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.bean.ConsumeReasonBean;
import com.gingersoft.supply_chain.mvp.bean.ConsumeWareHousingBean;
import com.gingersoft.supply_chain.mvp.bean.WareHouseListBean; import com.gingersoft.supply_chain.mvp.bean.WareHouseListBean;
import com.gingersoft.supply_chain.mvp.bean.WarehouseDetailsBean; import com.gingersoft.supply_chain.mvp.bean.WarehouseDetailsBean;
import com.gingersoft.supply_chain.mvp.content.Constant; import com.gingersoft.supply_chain.mvp.content.Constant;
...@@ -18,6 +21,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers; ...@@ -18,6 +21,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler; import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber; import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import javax.inject.Inject; import javax.inject.Inject;
...@@ -25,6 +30,7 @@ import com.gingersoft.supply_chain.mvp.contract.WarehouseDetailsContract; ...@@ -25,6 +30,7 @@ import com.gingersoft.supply_chain.mvp.contract.WarehouseDetailsContract;
import com.jess.arms.utils.RxLifecycleUtils; import com.jess.arms.utils.RxLifecycleUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -66,12 +72,16 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon ...@@ -66,12 +72,16 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
this.mApplication = null; this.mApplication = null;
} }
public void getWarehousingOrderDetails(int foodId, String basicUnitName) { /**
* 獲取入庫訂單流水
*
* @param foodNo 食材編號
*/
public void getWarehousingOrderDetails(String foodNo) {
Map<String, Object> map = new HashMap<>(4); Map<String, Object> map = new HashMap<>(4);
Constant.addBrandId(map); Constant.addBrandId(map);
Constant.addRestaurantId(map); Constant.addRestaurantId(map);
map.put("id", foodId); map.put("foodNo", foodNo);
map.put("basicUnitName", basicUnitName);
mModel.getWarehousingOrderDetails(map) mModel.getWarehousingOrderDetails(map)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING)) .doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
...@@ -83,9 +93,41 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon ...@@ -83,9 +93,41 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
@Override @Override
public void onNext(BaseResult baseResult) { public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) { if (baseResult != null && baseResult.isSuccess()) {
WarehouseDetailsBean warehouseDetailsBean = GsonUtils.GsonToBean(baseResult.getData(), WarehouseDetailsBean.class); List<WarehouseDetailsBean> warehouseDetailsBean = GsonUtils.jsonToList(baseResult.getData(), WarehouseDetailsBean.class);
mRootView.loadWarehousing(warehouseDetailsBean); mRootView.loadAdapter(warehouseDetailsBean);
} else if(baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) { } else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(Constant.GET_INFO_ERROR);
}
}
});
}
/**
* 獲取出庫庫訂單流水
*
* @param foodNo
*/
public void getOutStockDetails(String foodNo) {
Map<String, Object> map = new HashMap<>(4);
Constant.addBrandId(map);
Constant.addRestaurantId(map);
map.put("foodNo", foodNo);
mModel.getOutStockDetails(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
List<ConsumeWareHousingBean> consumeWareHousingBeans = GsonUtils.GsonToList(baseResult.getData(), ConsumeWareHousingBean.class);
mRootView.loadAdapter(WarehouseDetailsBean.getWarehousingByConsumes(consumeWareHousingBeans));
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg()); mRootView.showMessage(baseResult.getErrMsg());
} else { } else {
mRootView.showMessage(Constant.GET_INFO_ERROR); mRootView.showMessage(Constant.GET_INFO_ERROR);
...@@ -97,7 +139,7 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon ...@@ -97,7 +139,7 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
/** /**
* 獲取庫存消耗原因 * 獲取庫存消耗原因
*/ */
public void getWarehouseInventoryReason(){ public void getWarehouseInventoryReason() {
mModel.getWarehouseInventoryReason() mModel.getWarehouseInventoryReason()
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING)) .doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
...@@ -109,8 +151,49 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon ...@@ -109,8 +151,49 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
@Override @Override
public void onNext(BaseResult baseResult) { public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) { if (baseResult != null && baseResult.isSuccess()) {
List<ConsumeReasonBean> consumeReasonBeans = GsonUtils.GsonToList(baseResult.getData(), ConsumeReasonBean.class);
mRootView.loadConsumeReason(consumeReasonBeans);
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(Constant.GET_INFO_ERROR);
}
}
});
}
} else if(baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) { /**
* 庫存消耗
*
* @param foodNo 食材編號
* @param consumeQuantity 消耗數量
* @param purchaseConsumeReasonId 原因id
* @param remarks 備註
*/
public void consumeWareHousing(String foodNo, int consumeQuantity, int purchaseConsumeReasonId, String remarks) {
FormBody.Builder formBody = new FormBody.Builder()
.add("foodNo", foodNo)
.add("consumeQuantity", String.valueOf(consumeQuantity))
.add("purchaseConsumeReasonId", String.valueOf(purchaseConsumeReasonId))
.add("remarks", remarks);
Constant.addRestaurantId(formBody);
Constant.addBrandId(formBody);
mModel.consumeWareHousing(formBody.build())
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.UPDATE_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
//消耗完之後,刷新列表
mRootView.getPageInfo();
//重新獲取庫存數量
getWarehousingNum(foodNo);
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg()); mRootView.showMessage(baseResult.getErrMsg());
} else { } else {
mRootView.showMessage(Constant.GET_INFO_ERROR); mRootView.showMessage(Constant.GET_INFO_ERROR);
...@@ -119,4 +202,33 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon ...@@ -119,4 +202,33 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
}); });
} }
/**
* 獲取庫存數量
*/
public void getWarehousingNum(String foodNo) {
Map<String, Object> map = new HashMap<>(3);
Constant.addBrandId(map);
Constant.addRestaurantId(map);
map.put("foodNo", foodNo);
mModel.getWarehousingNum(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.QUERY_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
try {
mRootView.setWarehousingNum((int) Double.parseDouble(GsonUtils.GsonString(baseResult.getData())));
} catch (NumberFormatException e) {
mRootView.killMyself();
e.printStackTrace();
}
}
}
});
}
} }
...@@ -2,16 +2,24 @@ package com.gingersoft.supply_chain.mvp.presenter; ...@@ -2,16 +2,24 @@ package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application; import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.jess.arms.integration.AppManager; import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.FragmentScope; import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.mvp.BasePresenter; import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.http.imageloader.ImageLoader; import com.jess.arms.http.imageloader.ImageLoader;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler; import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.FormBody;
import javax.inject.Inject; import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract; import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract;
import com.jess.arms.utils.RxLifecycleUtils;
/** /**
...@@ -50,4 +58,41 @@ public class WarehousingInventoryPresenter extends BasePresenter<WarehousingInve ...@@ -50,4 +58,41 @@ public class WarehousingInventoryPresenter extends BasePresenter<WarehousingInve
this.mImageLoader = null; this.mImageLoader = null;
this.mApplication = null; this.mApplication = null;
} }
/**
* 庫存消耗
*
* @param foodNo 食材編號
* @param consumeQuantity 消耗數量
*/
public void consumeWareHousing(String foodNo, int consumeQuantity) {
FormBody.Builder formBody = new FormBody.Builder()
.add("foodNo", foodNo)
.add("consumeQuantity", String.valueOf(consumeQuantity))
.add("purchaseConsumeReasonId", String.valueOf(Constant.INVENTORY_CONSUME_ID));
Constant.addRestaurantId(formBody);
Constant.addBrandId(formBody);
mModel.consumeWareHousing(formBody.build())
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.SAVE_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
//消耗完之後,關閉頁面
mRootView.showMessage(Constant.SAVE_SUCCESS);
mRootView.updateSuccess();
mRootView.killMyself();
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(Constant.SAVE_FAIL);
}
}
});
}
} }
...@@ -402,11 +402,31 @@ public interface SupplierServer { ...@@ -402,11 +402,31 @@ public interface SupplierServer {
Observable<BaseResult> getWarehousingOrderDetails(@QueryMap Map<String, Object> map); Observable<BaseResult> getWarehousingOrderDetails(@QueryMap Map<String, Object> map);
/** /**
* 查詢出庫流水
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseConsume/get/running/water" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getOutStockDetails(@QueryMap Map<String, Object> map);
/**
* 查詢庫存消耗原因 * 查詢庫存消耗原因
*/ */
@Headers({"Domain-Name: ricepon-purchase"}) @Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseConsumeReason/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2) @GET("purchaseConsumeReason/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getWarehouseInventoryReason(); Observable<BaseResult> getWarehouseInventoryReason();
/**
* 庫存消耗
*/
@Headers({"Domain-Name: ricepon-purchase"})
@POST("purchaseConsume/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> consumeWareHousing(@Body RequestBody requestBody);
/**
* 查詢庫存數量
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseConsume/get/remaining/quantity" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getWarehousingNum(@QueryMap Map<String, Object> map);
} }
...@@ -10,6 +10,7 @@ import android.widget.EditText; ...@@ -10,6 +10,7 @@ import android.widget.EditText;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.gingersoft.gsa.cloud.ui.adapter.multi.InfoMultiAdapter;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog; import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.gingersoft.supply_chain.R; import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.di.component.DaggerSupplyChainMainComponent; import com.gingersoft.supply_chain.di.component.DaggerSupplyChainMainComponent;
...@@ -54,14 +55,17 @@ public class SupplyChainMainActivity extends BaseFragmentActivity<SupplyChainMai ...@@ -54,14 +55,17 @@ public class SupplyChainMainActivity extends BaseFragmentActivity<SupplyChainMai
@Override @Override
public boolean dispatchTouchEvent(MotionEvent ev) { public boolean dispatchTouchEvent(MotionEvent ev) {
if(getTopFragment() instanceof NotDispatchListener){ if (getTopFragment() instanceof NotDispatchListener) {
return super.dispatchTouchEvent(ev); return super.dispatchTouchEvent(ev);
} }
if (ev.getAction() == MotionEvent.ACTION_DOWN) { if (ev.getAction() == MotionEvent.ACTION_DOWN) {
// 获得当前得到焦点的View,一般情况下就是EditText(特殊情况就是轨迹求或者实体案件会移动焦点) // 获得当前得到焦点的View,一般情况下就是EditText(特殊情况就是轨迹求或者实体案件会移动焦点)
View v = getCurrentFocus(); View v = getCurrentFocus();
if(v != null && v.getTag() != null && v.getTag() == InfoMultiAdapter.NOT_HIDE_KEYBOARD){
return super.dispatchTouchEvent(ev);
}
if (isShouldHideInput(v, ev)) { if (isShouldHideInput(v, ev)) {
if(v instanceof EditText){ if (v instanceof EditText) {
//不然不會觸發焦點監聽事件 //不然不會觸發焦點監聽事件
v.clearFocus(); v.clearFocus();
} }
......
package com.gingersoft.gsa.cloud.ui.adapter; package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
...@@ -11,6 +11,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter; ...@@ -11,6 +11,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder; import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.R; import com.gingersoft.gsa.cloud.common.R;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean; import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
......
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
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.supply_chain.mvp.bean.OrderCategoryBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2020/11/28
* Time: 11:45
* Use: 編輯分類,一級分類適配器
*/
public class CategoryAdapter extends BaseQuickAdapter<OrderCategoryBean.FoodCategoryTrees, BaseViewHolder> {
private int selectedIndex = 0;
private Drawable selectedBg;
private Drawable unSelectedBg;
private int selectColor = -1;
private int unSelectColor = -1;
private boolean showDelete = false;
public CategoryAdapter(@Nullable List<OrderCategoryBean.FoodCategoryTrees> data, Context context) {
super(R.layout.item_category, data);
addChildClickViewIds(R.id.iv_category_delete);
selectedBg = ContextCompat.getDrawable(context, R.drawable.shape_left_radio_shadow);
unSelectedBg = ContextCompat.getDrawable(context, R.color.trans);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, OrderCategoryBean.FoodCategoryTrees categoryBean) {
TextView tvCategoryName = viewHolder.getView(R.id.tv_category_name);
tvCategoryName.setText(categoryBean.getName());
CardView view = viewHolder.getView(R.id.layout_category);
if (viewHolder.getAdapterPosition() == selectedIndex) {
if (selectedBg != null) {
view.setBackground(selectedBg);
}
if (selectColor != -1) {
tvCategoryName.setTextColor(selectColor);
}
tvCategoryName.setSelected(true);
} else {
tvCategoryName.setSelected(false);
if (unSelectedBg != null) {
view.setBackground(unSelectedBg);
}
if (unSelectColor != -1) {
tvCategoryName.setTextColor(unSelectColor);
}
}
viewHolder.setGone(R.id.iv_category_delete, !showDelete);
}
public void setShowDelete(boolean showDelete) {
this.showDelete = showDelete;
notifyDataSetChanged();
}
public CategoryAdapter setSelectedBg(Drawable selectedBg) {
this.selectedBg = selectedBg;
return this;
}
public CategoryAdapter setUnSelectedBg(Drawable unSelectedBg) {
this.unSelectedBg = unSelectedBg;
return this;
}
public CategoryAdapter setSelectColor(int selectColor) {
this.selectColor = selectColor;
return this;
}
public CategoryAdapter setUnSelectColor(int unSelectColor) {
this.unSelectColor = unSelectColor;
return this;
}
public void setSelectedIndex(int selectedIndex) {
this.selectedIndex = selectedIndex;
notifyDataSetChanged();
}
public int getSelectedIndex() {
return selectedIndex;
}
}
package com.gingersoft.supply_chain.mvp.ui.adapter; package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import androidx.cardview.widget.CardView;
import com.chad.library.adapter.base.BaseQuickAdapter; import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder; import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.R; import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean; import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
...@@ -21,7 +24,7 @@ import java.util.List; ...@@ -21,7 +24,7 @@ import java.util.List;
* Time: 15:41 * Time: 15:41
* Use: * Use:
*/ */
public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBean.DataBean.FoodCategoryBean, BaseViewHolder> { public class FoodCategoryAdapter extends BaseQuickAdapter<OrderCategoryBean.FoodCategoryTrees, BaseViewHolder> {
private int selectIndex = 0; private int selectIndex = 0;
private Drawable checkedBg; private Drawable checkedBg;
...@@ -31,36 +34,43 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBe ...@@ -31,36 +34,43 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBe
private int unCheckedTextColor; private int unCheckedTextColor;
private boolean showDelete = false; private boolean showDelete = false;
public SecondCategoryAdapter(@Nullable List<FoodCategoryResultBean.DataBean.FoodCategoryBean> data) { public FoodCategoryAdapter(int layoutId, @Nullable List<OrderCategoryBean.FoodCategoryTrees> data) {
super(layoutId, data);
addChildClickViewIds(R.id.iv_category_delete);
}
public FoodCategoryAdapter(@Nullable List<OrderCategoryBean.FoodCategoryTrees> data) {
super(R.layout.item_second_category, data); super(R.layout.item_second_category, data);
addChildClickViewIds(R.id.iv_category_delete); addChildClickViewIds(R.id.iv_category_delete);
} }
@Override @Override
protected void convert(@NotNull BaseViewHolder viewHolder, FoodCategoryResultBean.DataBean.FoodCategoryBean categoryBean) { protected void convert(@NotNull BaseViewHolder viewHolder, OrderCategoryBean.FoodCategoryTrees categoryBean) {
viewHolder.setText(R.id.tv_second_category_title, categoryBean.getName()); viewHolder.setText(R.id.tv_second_category_title, categoryBean.getName());
TextView tvName = viewHolder.getView(R.id.tv_second_category_title); TextView tvName = viewHolder.getView(R.id.tv_second_category_title);
CardView cardView = viewHolder.getView(R.id.card_purchase_category);
if (categoryBean.getId() == -1) {
cardView.setVisibility(View.GONE);
return;
} else {
cardView.setVisibility(View.VISIBLE);
}
viewHolder.setVisible(R.id.tv_second_category_title, TextUtil.isNotEmptyOrNullOrUndefined(categoryBean.getName())); viewHolder.setVisible(R.id.tv_second_category_title, TextUtil.isNotEmptyOrNullOrUndefined(categoryBean.getName()));
if (viewHolder.getAdapterPosition() == selectIndex) { if (viewHolder.getAdapterPosition() == selectIndex) {
if (checkedBg != null) { if (checkedBg != null) {
tvName.setBackground(checkedBg); cardView.setBackground(checkedBg);
} }
if (checkedTextColor != 0) { if (checkedTextColor != 0) {
tvName.setTextColor(checkedTextColor); tvName.setTextColor(checkedTextColor);
} }
} else { } else {
if (unCheckedBg != null) { if (unCheckedBg != null) {
tvName.setBackground(unCheckedBg); cardView.setBackground(unCheckedBg);
} }
if (unCheckedTextColor != 0) { if (unCheckedTextColor != 0) {
tvName.setTextColor(unCheckedTextColor); tvName.setTextColor(unCheckedTextColor);
} }
} }
if (viewHolder.getAdapterPosition() == 0) {
viewHolder.setGone(R.id.iv_category_delete, true);
} else {
viewHolder.setGone(R.id.iv_category_delete, !showDelete);
}
} }
public void setShowDelete(boolean showDelete) { public void setShowDelete(boolean showDelete) {
...@@ -68,28 +78,34 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBe ...@@ -68,28 +78,34 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBe
notifyDataSetChanged(); notifyDataSetChanged();
} }
public SecondCategoryAdapter setCheckedBg(Drawable checkedBg) { public FoodCategoryAdapter setCheckedBg(Drawable checkedBg) {
this.checkedBg = checkedBg; this.checkedBg = checkedBg;
return this; return this;
} }
public SecondCategoryAdapter setUnCheckedBg(Drawable unCheckedBg) { public FoodCategoryAdapter setUnCheckedBg(Drawable unCheckedBg) {
this.unCheckedBg = unCheckedBg; this.unCheckedBg = unCheckedBg;
return this; return this;
} }
public SecondCategoryAdapter setSelectIndex(int selectIndex) { public FoodCategoryAdapter setSelectIndex(int selectIndex) {
int lastIndex = this.selectIndex;
this.selectIndex = selectIndex; this.selectIndex = selectIndex;
notifyDataSetChanged(); if (lastIndex >= 0 && lastIndex < getItemCount()) {
notifyItemChanged(lastIndex);
}
if (this.selectIndex >= 0 && this.selectIndex < getItemCount()) {
notifyItemChanged(this.selectIndex);
}
return this; return this;
} }
public SecondCategoryAdapter setCheckedTextColor(int checkedTextColor) { public FoodCategoryAdapter setCheckedTextColor(int checkedTextColor) {
this.checkedTextColor = checkedTextColor; this.checkedTextColor = checkedTextColor;
return this; return this;
} }
public SecondCategoryAdapter setUnCheckedTextColor(int unCheckedTextColor) { public FoodCategoryAdapter setUnCheckedTextColor(int unCheckedTextColor) {
this.unCheckedTextColor = unCheckedTextColor; this.unCheckedTextColor = unCheckedTextColor;
return this; return this;
} }
...@@ -98,7 +114,4 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBe ...@@ -98,7 +114,4 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBe
return selectIndex; return selectIndex;
} }
public FoodCategoryResultBean.DataBean.FoodCategoryBean getSelectData() {
return getData().get(selectIndex);
}
} }
...@@ -17,6 +17,7 @@ import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils; ...@@ -17,6 +17,7 @@ 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.other.TextUtil;
import com.gingersoft.supply_chain.R; import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean; import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.ui.fragment.food.FoodIngredientsFragment;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
...@@ -200,7 +201,7 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView ...@@ -200,7 +201,7 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
viewHolder.getView(R.id.btn_food_operation_sub).setOnLongClickListener(new View.OnLongClickListener() { viewHolder.getView(R.id.btn_food_operation_sub).setOnLongClickListener(new View.OnLongClickListener() {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
Log.e("eee", "長按:" + System.currentTimeMillis()); // Log.e("eee", "長按:" + System.currentTimeMillis());
return false; return false;
} }
}); });
...@@ -208,7 +209,7 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView ...@@ -208,7 +209,7 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
viewHolder.getView(R.id.btn_food_operation_add).setOnLongClickListener(new View.OnLongClickListener() { viewHolder.getView(R.id.btn_food_operation_add).setOnLongClickListener(new View.OnLongClickListener() {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
Log.e("eee", "長按:" + System.currentTimeMillis()); // Log.e("eee", "長按:" + System.currentTimeMillis());
return false; return false;
} }
}); });
...@@ -249,12 +250,18 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView ...@@ -249,12 +250,18 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
}; };
editText.setOnFocusChangeListener((v, hasFocus) -> { editText.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) { if (hasFocus) {
// if ("0".equals(editText.getText() + "")) {
// editText.setText("");
// editText.setText(null);
// editText.requestFocusFromTouch();
// editText.requestFocus();
// }
editText.addTextChangedListener(foodNumTextWatcher); editText.addTextChangedListener(foodNumTextWatcher);
} else { } else {
//當失去焦點時,輸入框沒有值,詢問是否刪除食材 //當失去焦點時,輸入框沒有值,詢問是否刪除食材
if (TextUtil.isEmptyOrNullOrUndefined(editText)) { if (TextUtil.isEmptyOrNullOrUndefined(editText)) {
PurchaseFoodBean purchaseFoodBean = getData().get(viewHolder.getAdapterPosition()); PurchaseFoodBean purchaseFoodBean = getData().get(viewHolder.getAdapterPosition());
if (onNumberChangeListener != null) { if (adapterType == FoodIngredientsFragment.ORDER_TYPE) {
//購物車走這個方法 //購物車走這個方法
onNumberChangeListener.onChanged(purchaseFoodBean.getFoodQuantity(), 0, viewHolder.getAdapterPosition()); onNumberChangeListener.onChanged(purchaseFoodBean.getFoodQuantity(), 0, viewHolder.getAdapterPosition());
} else { } else {
......
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/25
* Time: 9:20
* Use:
*/
public class SelectCategoryAdapter extends BaseQuickAdapter<OrderCategoryBean.FoodCategoryTrees, BaseViewHolder> {
private int bgColor;
/**
* 記錄當前第幾級分類
*/
private int level;
private OnChildSelectListener onChildSelectListener;
/**
* 當前選中的下標集合
*/
private int[] positions;
/**
* 標題的縮進
*/
private String indentation;
/**
* @param data 分類數據
* @param bgColor 當前背景色
* @param level 當前是第幾級分類
* @param positions 選中下標集合 positions[level]表示獲取第level級選中的分類的下標
*/
public SelectCategoryAdapter(@Nullable List<OrderCategoryBean.FoodCategoryTrees> data, int bgColor, int level, int[] positions) {
super(R.layout.item_select_category, data);
this.bgColor = bgColor;
this.level = level;
this.positions = positions;
indentation = "";
}
public SelectCategoryAdapter setIndentation(String indentation) {
this.indentation = indentation;
return this;
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, OrderCategoryBean.FoodCategoryTrees foodCategoryTrees) {
viewHolder.setText(R.id.tv_radio_section_title, indentation + foodCategoryTrees.getName());
viewHolder.setBackgroundColor(R.id.layout_item_select_category, bgColor);
CheckBox checkBox = viewHolder.getView(R.id.cb_radio_section);
if (level < positions.length) {
//當前分類已選中,要默認展開
if (viewHolder.getAdapterPosition() == positions[level]) {
checkBox.setChecked(true);
setChildState(viewHolder, foodCategoryTrees, false);
} else {
checkBox.setChecked(false);
viewHolder.setGone(R.id.rv_select_category, true);
}
} else {
checkBox.setChecked(false);
viewHolder.setGone(R.id.rv_select_category, true);
}
//選中狀態切換
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (buttonView.isPressed()) {
//將低於此級別的都設置為未選中
for (int i = level; i < positions.length; i++) {
positions[i] = -1;
}
if (isChecked) {
//沒選中的情況下,才設置為選中
//當前級別存下
positions[level] = viewHolder.getAdapterPosition();
} else {
positions[level] = -1;
}
//通知父類選中或沒選中
onChildSelectListener.onSelect(viewHolder.getAdapterPosition(), isChecked);
}
});
//設置當前item點擊顯示或隱藏
LinearLayout layout = viewHolder.getView(R.id.layout_item_select_category);
layout.setOnClickListener(v -> {
//顯示就隱藏,隱藏就顯示
RecyclerView rvNextLevelCategory = viewHolder.getView(R.id.rv_select_category);
setChildState(viewHolder, foodCategoryTrees, rvNextLevelCategory.getVisibility() == View.VISIBLE);
});
}
/**
* 子類選中時的接口
*/
public interface OnChildSelectListener {
/**
* 選中時調用
*
* @param position 分類下標
* @param isChecked 選中狀態
*/
void onSelect(int position, boolean isChecked);
}
public void setOnChildSelectListener(OnChildSelectListener onChildSelectListener) {
this.onChildSelectListener = onChildSelectListener;
}
/**
* 設置子分類顯示狀態
*
* @param viewHolder
* @param foodCategoryTrees 父分類
*/
private void setChildState(@NotNull BaseViewHolder viewHolder, OrderCategoryBean.FoodCategoryTrees foodCategoryTrees, boolean notShowChild) {
RecyclerView rvNextLevelCategory = viewHolder.getView(R.id.rv_select_category);
if (foodCategoryTrees.getFoodCategoryTrees() != null) {
viewHolder.setGone(R.id.rv_select_category, notShowChild);
SelectCategoryAdapter selectCategoryAdapter = new SelectCategoryAdapter(foodCategoryTrees.getFoodCategoryTrees(), bgColor == Color.WHITE ? ContextCompat.getColor(getContext(), R.color.color_ccc) : getBgColor(bgColor), level + 1, positions);
rvNextLevelCategory.setAdapter(selectCategoryAdapter.setIndentation(indentation + "\u3000"));
selectCategoryAdapter.setOnChildSelectListener((position, isChecked) -> {
//子類被選中了,父類也要被選中
positions[level] = viewHolder.getAdapterPosition();
onChildSelectListener.onSelect(viewHolder.getAdapterPosition(), isChecked);
});
rvNextLevelCategory.setTag(selectCategoryAdapter);
} else {
viewHolder.setGone(R.id.rv_select_category, true);
}
}
private int getBgColor(int backgroundColor) {
int alpha = Color.alpha(backgroundColor) + 20;
int red = Color.red(backgroundColor) + 20;
int green = Color.green(backgroundColor) + 20;
int blue = Color.blue(backgroundColor) + 20;
if (alpha < 0 || alpha > 255) {
alpha = 0;
}
if (red < 0 || red > 255) {
red = 0;
}
if (green < 0 || green > 255) {
green = 0;
}
if (blue < 0 || blue > 255) {
blue = 0;
}
return Color.argb(alpha, red, green, blue);
}
}
package com.gingersoft.supply_chain.mvp.ui.adapter; package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import com.chad.library.adapter.base.BaseQuickAdapter; import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder; import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.supply_chain.R; import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.WarehouseDetailsBean; import com.gingersoft.supply_chain.mvp.bean.WarehouseDetailsBean;
import com.gingersoft.supply_chain.mvp.ui.fragment.warehouse.WarehouseDetailsFragment;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
...@@ -17,27 +26,101 @@ import java.util.List; ...@@ -17,27 +26,101 @@ import java.util.List;
* Time: 14:45 * Time: 14:45
* Use: * Use:
*/ */
public class WareHousingDetailsAdapter extends BaseQuickAdapter<WarehouseDetailsBean.PurchaseWarehousingOrderDetailsContentsBean, BaseViewHolder> { public class WareHousingDetailsAdapter extends BaseQuickAdapter<WarehouseDetailsBean, BaseViewHolder> {
/**
* 入庫還是出庫
* 入庫顯示+,出庫顯示-
*/
private int type;
/**
* 已消耗的背景色
*/
private Drawable allConsumeBg;
/**
* 已過期的背景
*/
private Drawable expiredBg;
/**
* 即將過期背景
*/
private Drawable willExpireSoonBg;
public WareHousingDetailsAdapter(@Nullable List<WarehouseDetailsBean.PurchaseWarehousingOrderDetailsContentsBean> data) { public WareHousingDetailsAdapter(Context context, @Nullable List<WarehouseDetailsBean> data, int type) {
super(R.layout.item_warehouse_details, data); super(R.layout.item_warehouse_details, data);
this.type = type;
allConsumeBg = ContextCompat.getDrawable(context, R.drawable.shape_oval_48);
expiredBg = ContextCompat.getDrawable(context, R.drawable.shape_oval_red_wine);
willExpireSoonBg = ContextCompat.getDrawable(context, R.drawable.shape_oval_bright_orange);
} }
@Override @Override
protected void convert(@NotNull BaseViewHolder viewHolder, WarehouseDetailsBean.PurchaseWarehousingOrderDetailsContentsBean purchaseWarehousingOrderDetailsContentsBean) { protected void convert(@NotNull BaseViewHolder viewHolder, WarehouseDetailsBean purchaseWarehousingOrderDetailsContentsBean) {
//食品名 //食品名
viewHolder.setText(R.id.tv_warehouse_details_food_name, purchaseWarehousingOrderDetailsContentsBean.getName()); viewHolder.setText(R.id.tv_warehouse_details_food_name, purchaseWarehousingOrderDetailsContentsBean.getName());
//入庫單位 //入庫單位
viewHolder.setText(R.id.tv_warehouse_details_food_unit, "單位"); viewHolder.setText(R.id.tv_warehouse_details_food_unit, purchaseWarehousingOrderDetailsContentsBean.getUnitName());
//入庫食品數量 //入庫食品數量
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.format(getContext().getString(R.string.str_format_positive), purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity())); // if (purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity() > 0) {
if (type == WarehouseDetailsFragment.WAREHOUSE_TYPE) {
// 入庫,顯示+
if (purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity() >= 0) {
//如果大於0,前面顯示+號
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.format(getContext().getString(R.string.str_format_positive), MoneyUtil.formatDouble(purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity())));
} else {
//小於0,直接顯示負數
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.valueOf(purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity()));
}
viewHolder.setGone(R.id.tv_warehouse_time_text, false);
viewHolder.setText(R.id.tv_warehouse_order_time_text, "下單日期:");
//入庫日期
viewHolder.setText(R.id.tv_warehouse_details_time, purchaseWarehousingOrderDetailsContentsBean.getWarehousingTime());
} else {
//出庫,顯示-
if (purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity() >= 0) {
//如果大於0,前面顯示-號
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.format(getContext().getString(R.string.str_format_less), MoneyUtil.formatDouble(purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity())));
} else {
//小於0,直接顯示負數
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.valueOf(purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity()));
}
// 入庫顯示消耗日期,不顯示入庫日期
viewHolder.setGone(R.id.tv_warehouse_time_text, true);
//消耗日期
viewHolder.setText(R.id.tv_warehouse_order_time_text, "消耗日期:");
}
//下單時間 //下單時間
viewHolder.setText(R.id.tv_warehouse_details_order_time, "下單時間"); viewHolder.setText(R.id.tv_warehouse_details_order_time, purchaseWarehousingOrderDetailsContentsBean.getPurchaseTime());
//供應商 //供應商
viewHolder.setText(R.id.tv_warehouse_details_supplier, purchaseWarehousingOrderDetailsContentsBean.getName()); viewHolder.setText(R.id.tv_warehouse_details_supplier, purchaseWarehousingOrderDetailsContentsBean.getSupplierName());
//入庫日期
viewHolder.setText(R.id.tv_warehouse_details_time, "入庫日期");
//入庫來源 //入庫來源
viewHolder.setText(R.id.tv_warehouse_details_reason, purchaseWarehousingOrderDetailsContentsBean.getPurchase()); viewHolder.setText(R.id.tv_warehouse_details_reason, purchaseWarehousingOrderDetailsContentsBean.getPurchase());
//設置狀態
TextView tvState = viewHolder.getView(R.id.tv_warehouse_state);
tvState.setVisibility(View.VISIBLE);
if (purchaseWarehousingOrderDetailsContentsBean.getConsumeStatus() == WarehouseDetailsBean.WAREHOUSE_STATE_ALL_CONSUMED) {
//全部消耗了
tvState.setBackground(allConsumeBg);
tvState.setText("庫存已使用");
} else {
if (purchaseWarehousingOrderDetailsContentsBean.getDistanceExpiresTime() >= 0) {
//即將過期天數大於等於0
if (purchaseWarehousingOrderDetailsContentsBean.getWarningDays() > purchaseWarehousingOrderDetailsContentsBean.getDistanceExpiresTime()) {
//在預警天數內
//顯示即將過期
tvState.setBackground(willExpireSoonBg);
tvState.setText("即将過期:" + purchaseWarehousingOrderDetailsContentsBean.getDistanceExpiresTime() + "日");
} else {
tvState.setVisibility(View.GONE);
}
} else {
//天數為負,則是已過期
tvState.setBackground(expiredBg);
tvState.setText("已過期:" + Math.abs(purchaseWarehousingOrderDetailsContentsBean.getDistanceExpiresTime()) + "日");
}
}
}
public void setType(int type) {
this.type = type;
} }
} }
...@@ -34,9 +34,9 @@ public class WarehousingQueryAdapter extends BaseQuickAdapter<WareHouseListBean. ...@@ -34,9 +34,9 @@ public class WarehousingQueryAdapter extends BaseQuickAdapter<WareHouseListBean.
@Override @Override
protected void convert(@NotNull BaseViewHolder viewHolder, WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean item) { protected void convert(@NotNull BaseViewHolder viewHolder, WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean item) {
viewHolder.setText(R.id.tv_warehouse_item_ingredients_name, item.getName()); viewHolder.setText(R.id.tv_warehouse_item_ingredients_name, item.getName());
viewHolder.setText(R.id.tv_warehouse_item_ingredients_species, item.getCateName()); viewHolder.setText(R.id.tv_warehouse_item_ingredients_species, item.getFoodCategoryName());
viewHolder.setText(R.id.tv_warehouse_item_supplier, item.getSupplierName()); // viewHolder.setText(R.id.tv_warehouse_item_supplier, item.getSupplierName());
viewHolder.setText(R.id.tv_warehouse_item_unit, item.getBasicUnitName()); viewHolder.setText(R.id.tv_warehouse_item_unit, item.getUnitName());
viewHolder.setText(R.id.tv_warehouse_item_unit_price, item.getFoodPrice() + ""); viewHolder.setText(R.id.tv_warehouse_item_unit_price, item.getFoodPrice() + "");
viewHolder.setText(R.id.tv_warehouse_item_inventory_quantity, item.getFoodNum() + ""); viewHolder.setText(R.id.tv_warehouse_item_inventory_quantity, item.getFoodNum() + "");
viewHolder.setText(R.id.tv_warehouse_item_total_amount, item.getFoodAmount() + ""); viewHolder.setText(R.id.tv_warehouse_item_total_amount, item.getFoodAmount() + "");
......
...@@ -4,11 +4,15 @@ import android.os.Bundle; ...@@ -4,11 +4,15 @@ import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter; import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener; import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.gingersoft.gsa.cloud.common.BuildConfig;
import com.gingersoft.gsa.cloud.common.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.database.bean.Function; import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.supply_chain.R; import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2; import com.gingersoft.supply_chain.R2;
...@@ -28,8 +32,10 @@ import com.gingersoft.supply_chain.mvp.ui.fragment.food.FoodIngredientsFragment; ...@@ -28,8 +32,10 @@ import com.gingersoft.supply_chain.mvp.ui.fragment.food.FoodIngredientsFragment;
import com.gingersoft.supply_chain.mvp.ui.fragment.warehouse.WareHouseListFragment; import com.gingersoft.supply_chain.mvp.ui.fragment.warehouse.WareHouseListFragment;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.qmuiteam.qmui.widget.QMUITopBar; import com.qmuiteam.qmui.widget.QMUITopBar;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import static com.gingersoft.supply_chain.mvp.ui.fragment.food.FoodIngredientsFragment.FOOD_INGREDIENTS; import static com.gingersoft.supply_chain.mvp.ui.fragment.food.FoodIngredientsFragment.FOOD_INGREDIENTS;
...@@ -92,6 +98,9 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr ...@@ -92,6 +98,9 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr
List<Function> storage = new ArrayList<>(); List<Function> storage = new ArrayList<>();
storage.add(new Function("庫存查詢", R.drawable.ic_purchase_order)); storage.add(new Function("庫存查詢", R.drawable.ic_purchase_order));
if (BuildConfig.DEBUG) {
storage.add(new Function("切換環境", R.drawable.ic_seekbar_btn));
}
purchaseFunctionBeans.add(new PurchaseFunctionBean("庫存管理", storage)); purchaseFunctionBeans.add(new PurchaseFunctionBean("庫存管理", storage));
PurchaseFunctionAdapter purchaseFunctionAdapter = new PurchaseFunctionAdapter(mContext, purchaseFunctionBeans); PurchaseFunctionAdapter purchaseFunctionAdapter = new PurchaseFunctionAdapter(mContext, purchaseFunctionBeans);
...@@ -120,6 +129,16 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr ...@@ -120,6 +129,16 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr
case "庫存查詢": case "庫存查詢":
start(WareHouseListFragment.newInstance()); start(WareHouseListFragment.newInstance());
break; break;
case "切換環境":
int format = (int) SPUtils.get("isFormal", 3);
if (format == 3) {
showMessage("已切換到測試環境,重啟生效");
SPUtils.put("isFormal", 1);
} else {
showMessage("已切換到本地環境,重啟生效");
SPUtils.put("isFormal", 3);
}
break;
default: default:
break; break;
......
...@@ -78,18 +78,21 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr ...@@ -78,18 +78,21 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
* 食品id * 食品id
*/ */
public final static String FOOD_ID_KEY = "foodIdKey"; public final static String FOOD_ID_KEY = "foodIdKey";
/** /**
* @param basicUnit 基本單位 * @param basicUnit 基本單位
* @param deputyUnitBeans 副單位集合 * @param deputyUnitBeans 副單位集合
* @return * @return
*/ */
public static FoodUnitPageFragment newInstance(String basicUnit, List<DeputyUnitBean> deputyUnitBeans, boolean isUpdateUnit, int foodId) { public static FoodUnitPageFragment newInstance(String basicUnit, List<DeputyUnitBean> deputyUnitBeans, boolean isUpdateUnit, Integer foodId) {
FoodUnitPageFragment fragment = new FoodUnitPageFragment(); FoodUnitPageFragment fragment = new FoodUnitPageFragment();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putSerializable(DEPUTY_UNIT_KEY, (Serializable) deputyUnitBeans); bundle.putSerializable(DEPUTY_UNIT_KEY, (Serializable) deputyUnitBeans);
bundle.putString(BASIC_UNIT_KEY, basicUnit); bundle.putString(BASIC_UNIT_KEY, basicUnit);
bundle.putBoolean(UPDATE_UNIT_KEY, isUpdateUnit); bundle.putBoolean(UPDATE_UNIT_KEY, isUpdateUnit);
bundle.putInt(FOOD_ID_KEY, foodId); if (foodId != null) {
bundle.putInt(FOOD_ID_KEY, foodId);
}
fragment.setArguments(bundle); fragment.setArguments(bundle);
return fragment; return fragment;
} }
...@@ -130,25 +133,11 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr ...@@ -130,25 +133,11 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
edBasicUnit.setError("請輸入基本單位"); edBasicUnit.setError("請輸入基本單位");
return; return;
} }
if (deputyUnitAdapter != null) { if (deputyUnitAdapter != null && deputyUnitAdapter.getItemCount() > 0) {
mPresenter.addDeputyUnit(deputyUnitAdapter.getData()); mPresenter.addDeputyUnit(deputyUnitAdapter.getData());
} else {
mPresenter.addDeputyUnit(null);
} }
// Bundle result = new Bundle();
// result.putString(BASIC_UNIT_KEY, basicUnit);
// if (deputyUnitAdapter != null) {
// //拿到副單位集合
// List<DeputyUnitBean> data = deputyUnitAdapter.getData();
// Iterator<DeputyUnitBean> iterator = data.iterator();
// while (iterator.hasNext()) {
// if (TextUtil.isEmptyOrNullOrUndefined(iterator.next().getDeputyUnit())) {
// //單位為空,移除掉
// iterator.remove();
// }
// }
// result.putSerializable(DEPUTY_UNIT_KEY, (Serializable) data);
// }
// setFragmentResult(RESULT_OK, result);
// killMyself();
} }
} }
...@@ -227,7 +216,9 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr ...@@ -227,7 +216,9 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
Bundle result = new Bundle(); Bundle result = new Bundle();
result.putString(BASIC_UNIT_KEY, basicUnit); result.putString(BASIC_UNIT_KEY, basicUnit);
result.putSerializable(DEPUTY_UNIT_KEY, (Serializable) deputyUnitBeans); if (deputyUnitBeans != null) {
result.putSerializable(DEPUTY_UNIT_KEY, (Serializable) deputyUnitBeans);
}
setFragmentResult(RESULT_OK, result); setFragmentResult(RESULT_OK, result);
killMyself(); killMyself();
} }
......
...@@ -35,6 +35,7 @@ import com.gingersoft.supply_chain.R; ...@@ -35,6 +35,7 @@ import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2; import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerNewFoodIngredientsComponent; import com.gingersoft.supply_chain.di.component.DaggerNewFoodIngredientsComponent;
import com.gingersoft.supply_chain.mvp.bean.DeputyUnitBean; import com.gingersoft.supply_chain.mvp.bean.DeputyUnitBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean; import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean; import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.contract.NewFoodIngredientsContract; import com.gingersoft.supply_chain.mvp.contract.NewFoodIngredientsContract;
...@@ -55,6 +56,8 @@ import java.io.IOException; ...@@ -55,6 +56,8 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -112,11 +115,11 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI ...@@ -112,11 +115,11 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
return fragment; return fragment;
} }
public static NewFoodIngredientsFragment newInstance(String supplierName, List<String> categoryNames) { public static NewFoodIngredientsFragment newInstance(String supplierName, String categoryName) {
NewFoodIngredientsFragment fragment = new NewFoodIngredientsFragment(); NewFoodIngredientsFragment fragment = new NewFoodIngredientsFragment();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(SUPPLIER_NAME_KEY, supplierName); bundle.putString(SUPPLIER_NAME_KEY, supplierName);
bundle.putSerializable(CATEGORY_NAME_KEY, (Serializable) categoryNames); bundle.putString(CATEGORY_NAME_KEY, categoryName);
fragment.setArguments(bundle); fragment.setArguments(bundle);
return fragment; return fragment;
} }
...@@ -158,16 +161,13 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI ...@@ -158,16 +161,13 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
initTopBar(topbarNewFoodIngredients, "新增食材"); initTopBar(topbarNewFoodIngredients, "新增食材");
purchaseFoodBean = new PurchaseFoodBean(); purchaseFoodBean = new PurchaseFoodBean();
//拿到分類集合 //拿到分類集合
List<String> categoryNames = (List<String>) arguments.getSerializable(CATEGORY_NAME_KEY); String categoryName = arguments.getString(CATEGORY_NAME_KEY);
if (categoryNames != null && categoryNames.size() > 0) { if (TextUtil.isNotEmptyOrNullOrUndefined(categoryName)) {
//分類不為空,設置分類信息 //分類不為空,設置分類信息
List<String> categoryNames= new ArrayList<>();
categoryNames.add(categoryName);
mPresenter.setCategoryNames(categoryNames); mPresenter.setCategoryNames(categoryNames);
StringBuilder category = new StringBuilder(); purchaseFoodBean.setFoodCategoryName(categoryName);
for (String categoryName : categoryNames) {
category.append(categoryName).append(PurchaseFoodBean.CATEGORY_DIVIDER);
}
category.deleteCharAt(category.lastIndexOf(PurchaseFoodBean.CATEGORY_DIVIDER));
purchaseFoodBean.setFoodCategoryName(category.toString());
} }
//供應商名稱 //供應商名稱
purchaseFoodBean.setSupplierName(arguments.getString(SUPPLIER_NAME_KEY)); purchaseFoodBean.setSupplierName(arguments.getString(SUPPLIER_NAME_KEY));
...@@ -197,7 +197,7 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI ...@@ -197,7 +197,7 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
startForResult(SupplierListFragment.newInstance(true, multiBean.getShowValue()), multiBean.getRequestCode()); startForResult(SupplierListFragment.newInstance(true, multiBean.getShowValue()), multiBean.getRequestCode());
} else if (infoMultiBean.getFragment() == CategorySelectFragment.class) { } else if (infoMultiBean.getFragment() == CategorySelectFragment.class) {
//選擇分類 //選擇分類
startForResult(CategorySelectFragment.newInstance(), multiBean.getRequestCode()); startForResult(CategorySelectFragment.newInstance(mPresenter.getCategoryName()), multiBean.getRequestCode());
} else if (infoMultiBean.getFragment() == FoodUnitPageFragment.class) { } else if (infoMultiBean.getFragment() == FoodUnitPageFragment.class) {
//食品單位 //食品單位
startForResult(FoodUnitPageFragment.newInstance(mPresenter.getBasicUnit(data), mPresenter.getDeputyUnitBeans(), isUpdate, mPresenter.getFoodId()), multiBean.getRequestCode()); startForResult(FoodUnitPageFragment.newInstance(mPresenter.getBasicUnit(data), mPresenter.getDeputyUnitBeans(), isUpdate, mPresenter.getFoodId()), multiBean.getRequestCode());
...@@ -248,7 +248,7 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI ...@@ -248,7 +248,7 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
mPresenter.setPackingInfo(basicUnitName, deputyUnitBeans, infoMultiAdapter.getData()); mPresenter.setPackingInfo(basicUnitName, deputyUnitBeans, infoMultiAdapter.getData());
} else if (requestCode == SELECT_FOOD_CATEGORY_REQUEST_CODE) { } else if (requestCode == SELECT_FOOD_CATEGORY_REQUEST_CODE) {
//選擇食材類別 //選擇食材類別
List<SectionCheckItem> sectionCheckItems = (List<SectionCheckItem>) data.get(SELECT_CATEGORY_DATA_KEY); List<OrderCategoryBean.FoodCategoryTrees> sectionCheckItems = (List<OrderCategoryBean.FoodCategoryTrees>) data.get(SELECT_CATEGORY_DATA_KEY);
if (sectionCheckItems != null) { if (sectionCheckItems != null) {
mPresenter.setCategoryInfo(sectionCheckItems, infoMultiAdapter.getData()); mPresenter.setCategoryInfo(sectionCheckItems, infoMultiAdapter.getData());
} }
......
...@@ -5,6 +5,7 @@ import android.content.Intent; ...@@ -5,6 +5,7 @@ import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.InputFilter;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
...@@ -27,6 +28,7 @@ import com.chad.library.adapter.base.listener.OnItemChildClickListener; ...@@ -27,6 +28,7 @@ import com.chad.library.adapter.base.listener.OnItemChildClickListener;
import com.gingersoft.gsa.cloud.common.utils.FileUtils; import com.gingersoft.gsa.cloud.common.utils.FileUtils;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil; import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils; import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.inputFilter.InputFilterUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils; import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils; import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
...@@ -73,7 +75,6 @@ import static com.yalantis.ucrop.UCrop.REQUEST_CROP; ...@@ -73,7 +75,6 @@ import static com.yalantis.ucrop.UCrop.REQUEST_CROP;
*/ */
public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPresenter> implements OrderDetailsContract.View, View.OnClickListener { public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPresenter> implements OrderDetailsContract.View, View.OnClickListener {
@BindView(R2.id.supply_top_bar) @BindView(R2.id.supply_top_bar)
QMUITopBar supplyTopBar; QMUITopBar supplyTopBar;
@BindView(R2.id.tv_order_details_supplier_name) @BindView(R2.id.tv_order_details_supplier_name)
...@@ -147,6 +148,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr ...@@ -147,6 +148,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
initTopBar(supplyTopBar, "入庫單"); initTopBar(supplyTopBar, "入庫單");
supplyTopBar.addRightImageButton(R.drawable.ic_white_more, R.id.id_more).setOnClickListener(this); supplyTopBar.addRightImageButton(R.drawable.ic_white_more, R.id.id_more).setOnClickListener(this);
supplyTopBar.addRightImageButton(R.drawable.ic_take_pictures, R.id.id_take_pictures).setOnClickListener(this); supplyTopBar.addRightImageButton(R.drawable.ic_take_pictures, R.id.id_take_pictures).setOnClickListener(this);
edRemark.setFilters(new InputFilter[]{InputFilterUtils.getLengthFilter(requireContext(), 50)});
Bundle arguments = getArguments(); Bundle arguments = getArguments();
if (arguments != null) { if (arguments != null) {
int orderId = arguments.getInt(ORDER_DETAILS_ORDER_ID, 0); int orderId = arguments.getInt(ORDER_DETAILS_ORDER_ID, 0);
...@@ -186,7 +188,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr ...@@ -186,7 +188,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
.hasShadowBg(false) .hasShadowBg(false)
.popupPosition(PopupPosition.Left) .popupPosition(PopupPosition.Left)
.asCustom(new PurchaseListMorePopup(mContext) .asCustom(new PurchaseListMorePopup(mContext)
.setStringData(functions, new int[]{R.drawable.ic_purchase_delete, R.drawable.ic_partial_receipt, R.drawable.ic_receipt}) .setStringData(functions, new int[]{R.drawable.ic_purchase_delete, R.drawable.ic_small_partial_receipt, R.drawable.ic_receipt})
.setOnSelectListener(mOnSelectListener)) .setOnSelectListener(mOnSelectListener))
.show(); .show();
} else if (viewId == R.id.tv_order_details_partial_receipt) { } else if (viewId == R.id.tv_order_details_partial_receipt) {
...@@ -199,9 +201,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr ...@@ -199,9 +201,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
// setFragmentResult(RESULT_OK, null); // setFragmentResult(RESULT_OK, null);
} else if (viewId == R.id.layout_remarks) { } else if (viewId == R.id.layout_remarks) {
//備註,顯示備註輸入框 //備註,顯示備註輸入框
v.setVisibility(View.GONE); layoutEdRemark.setVisibility(layoutEdRemark.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
layoutEdRemark.setVisibility(View.VISIBLE);
layoutRemarks.setVisibility(View.GONE);
} }
} }
...@@ -228,28 +228,40 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr ...@@ -228,28 +228,40 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
@Override @Override
public void loadOrderDetails(PurchaseOrderDetailsBean orderDetailsBean) { public void loadOrderDetails(PurchaseOrderDetailsBean orderDetailsBean) {
if (TextUtil.isNotEmptyOrNullOrUndefined(orderDetailsBean.getWarehousingRemarks())) {
edRemark.setText(orderDetailsBean.getWarehousingRemarks());
}
tvOrderDetailsSupplierName.setText(orderDetailsBean.getSupplierName()); tvOrderDetailsSupplierName.setText(orderDetailsBean.getSupplierName());
tvOrderDetailsOrderNo.setText(String.format(getString(R.string.str_format_purchase_no), orderDetailsBean.getOrderNo())); tvOrderDetailsOrderNo.setText(String.format(getString(R.string.str_format_purchase_no), orderDetailsBean.getOrderNo()));
if (TextUtil.isNotEmptyOrNullOrUndefined(orderDetailsBean.getWarehousingOrderNo())) {
tvWarehouseOrderNo.setText(String.format(getString(R.string.str_format_warehouse_no), orderDetailsBean.getWarehousingOrderNo()));
tvWarehouseOrderNo.setVisibility(View.VISIBLE);
} else {
tvWarehouseOrderNo.setVisibility(View.GONE);
}
tvOrderDetailsCreateTime.setText(TimeUtils.getStringByFormat(orderDetailsBean.getCreateTime(), TimeUtils.DEFAULT_DATE_FORMAT_YMDHM)); tvOrderDetailsCreateTime.setText(TimeUtils.getStringByFormat(orderDetailsBean.getCreateTime(), TimeUtils.DEFAULT_DATE_FORMAT_YMDHM));
// switch (orderDetailsBean.getStatus()) { switch (orderDetailsBean.getStatus()) {
// case PurchaseOrderDetailsBean.WAIT_RECEIVED: case PurchaseOrderDetailsBean.WAIT_RECEIVED:
// ivOrderState.setImageResource(); ivOrderState.setVisibility(View.INVISIBLE);
// tvOrderDetailsOrderState.setText("待收貨"); // tvOrderDetailsOrderState.setText("待收貨");
// break; break;
// case PurchaseOrderDetailsBean.PART_RECEIVED: case PurchaseOrderDetailsBean.PART_RECEIVED:
ivOrderState.setVisibility(View.VISIBLE);
// tvOrderDetailsOrderState.setText("部分收貨"); // tvOrderDetailsOrderState.setText("部分收貨");
// ivOrderState.setImageResource(); ivOrderState.setImageResource(R.drawable.ic_partial_receipt);
// break; break;
// case PurchaseOrderDetailsBean.COMPLETE_RECEIVED: case PurchaseOrderDetailsBean.COMPLETE_RECEIVED:
// tvOrderDetailsOrderState.setText("已完成"); // tvOrderDetailsOrderState.setText("已完成");
ivOrderState.setImageResource(R.drawable.ic_all_receipt);
break;
case PurchaseOrderDetailsBean.REFUSE_RECEIVED:
//拒收
ivOrderState.setImageResource(R.drawable.ic_refuse_accept);
// ivOrderState.setImageResource(); // ivOrderState.setImageResource();
// break; break;
// case PurchaseOrderDetailsBean.REFUSE_RECEIVED: default:
// ivOrderState.setImageResource(); break;
// break; }
// default:
// break;
// }
setTypesOfFood(); setTypesOfFood();
initRecyclerView(orderDetailsBean); initRecyclerView(orderDetailsBean);
//全選按鈕狀態切換 //全選按鈕狀態切換
...@@ -258,11 +270,12 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr ...@@ -258,11 +270,12 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
//重新計算總價 //重新計算總價
totalAmount = 0; totalAmount = 0;
typesOfFood = isChecked ? orderDetailsFoodAdapter.getData().size() : 0; typesOfFood = isChecked ? orderDetailsFoodAdapter.getData().size() : 0;
//修改所有食品的選中狀態 //修改所有食品的選中狀態,計算所有實付金額
for (PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean datum : orderDetailsFoodAdapter.getData()) { for (PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean datum : orderDetailsFoodAdapter.getData()) {
datum.setChecked(isChecked); datum.setChecked(isChecked);
if (isChecked) { if (isChecked) {
totalAmount = MoneyUtil.sum(totalAmount, datum.getWarehousingAmount()); DeputyUnitBean unit = datum.getShowUnit();
totalAmount = MoneyUtil.sum(totalAmount, MoneyUtil.priceCalculation(unit.getDeputyValue(), unit.getUnitPrice()));
} }
} }
orderDetailsFoodAdapter.notifyDataSetChanged(); orderDetailsFoodAdapter.notifyDataSetChanged();
...@@ -328,20 +341,25 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr ...@@ -328,20 +341,25 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
private void initRecyclerView(PurchaseOrderDetailsBean orderDetailsBean) { private void initRecyclerView(PurchaseOrderDetailsBean orderDetailsBean) {
orderDetailsFoodAdapter = new OrderDetailsFoodAdapter(mContext, orderDetailsBean.getPurchaseOrderDetailsInfoVOS()); orderDetailsFoodAdapter = new OrderDetailsFoodAdapter(mContext, orderDetailsBean.getPurchaseOrderDetailsInfoVOS());
rvOrderDetailsFoodList.setAdapter(orderDetailsFoodAdapter); rvOrderDetailsFoodList.setAdapter(orderDetailsFoodAdapter);
orderDetailsFoodAdapter.setOnValueChangeListener((position, value) -> { orderDetailsFoodAdapter.setOnAmountChangeListener((position, value) -> {
totalAmount = MoneyUtil.sum(totalAmount, value); totalAmount = MoneyUtil.sum(totalAmount, value);
setTotalAmount(); setTotalAmount();
}); });
orderDetailsFoodAdapter.setOnItemClickListener((adapter, view, position) -> { orderDetailsFoodAdapter.setOnItemClickListener((adapter, view, position) -> {
PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean infoVosBean = orderDetailsFoodAdapter.getData().get(position); PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean infoVosBean = orderDetailsFoodAdapter.getData().get(position);
// if(infoVosBean.getStatus() == PurchaseOrderDetailsBean.COMPLETE_RECEIVED){
// //已經全部收貨的,不讓選中
// return;
// }
infoVosBean.setChecked(!infoVosBean.isChecked()); infoVosBean.setChecked(!infoVosBean.isChecked());
adapter.notifyItemChanged(position); adapter.notifyItemChanged(position);
//修改選中狀態後,重新計算入庫總價 //修改選中狀態後,重新計算入庫總價
DeputyUnitBean showUnit = infoVosBean.getShowUnit();
if (infoVosBean.isChecked()) { if (infoVosBean.isChecked()) {
totalAmount = MoneyUtil.sum(totalAmount, infoVosBean.getWarehousingAmount()); totalAmount = MoneyUtil.sum(totalAmount, MoneyUtil.priceCalculation(showUnit.getDeputyValue(), showUnit.getUnitPrice()));
typesOfFood += 1; typesOfFood += 1;
} else { } else {
totalAmount = MoneyUtil.sub(totalAmount, infoVosBean.getWarehousingAmount()); totalAmount = MoneyUtil.sub(totalAmount, MoneyUtil.priceCalculation(showUnit.getDeputyValue(), showUnit.getUnitPrice()));
typesOfFood -= 1; typesOfFood -= 1;
} }
//全選 //全選
......
...@@ -81,8 +81,8 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr ...@@ -81,8 +81,8 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
ScreenView screenView; ScreenView screenView;
@BindView(R2.id.view_load_bg) @BindView(R2.id.view_load_bg)
View loadBg; View loadBg;
@BindView(R2.id.ed_food_ingredients_search) // @BindView(R2.id.ed_food_ingredients_search)
EditText edSearch; // EditText edSearch;
@BindView(R2.id.srl_purchase_list) @BindView(R2.id.srl_purchase_list)
SmartRefreshLayout refreshPurchaseList; SmartRefreshLayout refreshPurchaseList;
...@@ -124,7 +124,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr ...@@ -124,7 +124,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
refreshPurchaseList.setPrimaryColorsId(R.color.trans, R.color.black); refreshPurchaseList.setPrimaryColorsId(R.color.trans, R.color.black);
btnNewOrder.setText("+新增訂單"); btnNewOrder.setText("+新增訂單");
edSearch.setFilters(new InputFilter[]{InputFilterUtils.getChAndEnAndNumInputFilter(mContext), InputFilterUtils.getLengthFilter(mContext, 20)}); // edSearch.setFilters(new InputFilter[]{InputFilterUtils.getChAndEnAndNumInputFilter(mContext), InputFilterUtils.getLengthFilter(mContext, 20)});
btnNewOrder.setOnClickListener(v -> { btnNewOrder.setOnClickListener(v -> {
//跳轉到下單頁面 //跳轉到下單頁面
startForResult(FoodIngredientsFragment.newInstance(ADD_ORDER), REQUEST_ORDER_DETAILS_CODE); startForResult(FoodIngredientsFragment.newInstance(ADD_ORDER), REQUEST_ORDER_DETAILS_CODE);
...@@ -144,7 +144,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr ...@@ -144,7 +144,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
} }
private void getOrderList() { private void getOrderList() {
mPresenter.getOrderList(edSearch.getText() + "", orderState[orderStateIndex], pageIndex); mPresenter.getOrderList("", orderState[orderStateIndex], pageIndex);
} }
@Override @Override
...@@ -190,7 +190,18 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr ...@@ -190,7 +190,18 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
.asCustom(new PurchaseListMorePopup(mContext) .asCustom(new PurchaseListMorePopup(mContext)
//, "再次购买" , R.drawable.ic_purchase_buy_again //, "再次购买" , R.drawable.ic_purchase_buy_again
.setStringData(new String[]{"删除", "发送"}, new int[]{R.drawable.ic_purchase_delete, R.drawable.ic_purchase_send}) .setStringData(new String[]{"删除", "发送"}, new int[]{R.drawable.ic_purchase_delete, R.drawable.ic_purchase_send})
.setOnSelectListener(mOnSelectListener)) .setOnSelectListener((popupPosition, text) -> {
if (popupPosition == 0) {
//刪除
AppDialog.getInstance().showWaringDialog(mContext, "是否刪除訂單", (view1, dialog) -> {
dialog.dismiss();
mPresenter.deleteOrder(position, purchaseOrderAdapter.getData().get(position).getId());
});
} else if (popupPosition == 1) {
//發送採購單
sendPurchase(position);
}
}))
.show(); .show();
} }
}); });
...@@ -228,22 +239,6 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr ...@@ -228,22 +239,6 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
}); });
} }
private OnSelectListener mOnSelectListener = new OnSelectListener() {
@Override
public void onSelect(int position, String text) {
if (position == 0) {
//刪除
AppDialog.getInstance().showWaringDialog(mContext, "是否刪除訂單", (view1, dialog) -> {
dialog.dismiss();
mPresenter.deleteOrder(position, purchaseOrderAdapter.getData().get(position).getId());
});
} else if (position == 1) {
//發送採購單
sendPurchase(position);
}
}
};
private void sendPurchase(int position) { private void sendPurchase(int position) {
List<OrderBean> data = purchaseOrderAdapter.getData(); List<OrderBean> data = purchaseOrderAdapter.getData();
OrderBean orderBean = data.get(position); OrderBean orderBean = data.get(position);
......
...@@ -100,10 +100,10 @@ public class ShoppingCatFragment extends BaseSupplyChainFragment<ShoppingCatPres ...@@ -100,10 +100,10 @@ public class ShoppingCatFragment extends BaseSupplyChainFragment<ShoppingCatPres
@Override @Override
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
initTopBar(topBar, "採購單");
mPresenter.organizeShopCartData();
canClick = ContextCompat.getDrawable(requireContext(), R.drawable.shape_app_btn); canClick = ContextCompat.getDrawable(requireContext(), R.drawable.shape_app_btn);
notCanClick = ContextCompat.getDrawable(requireContext(), R.drawable.shape_btn_unclick); notCanClick = ContextCompat.getDrawable(requireContext(), R.drawable.shape_btn_unclick);
initTopBar(topBar, "採購單");
mPresenter.organizeShopCartData();
cbOrderContentAllSelect.setOnCheckedChangeListener((buttonView, isChecked) -> { cbOrderContentAllSelect.setOnCheckedChangeListener((buttonView, isChecked) -> {
//全選 //全選
...@@ -214,7 +214,7 @@ public class ShoppingCatFragment extends BaseSupplyChainFragment<ShoppingCatPres ...@@ -214,7 +214,7 @@ public class ShoppingCatFragment extends BaseSupplyChainFragment<ShoppingCatPres
@Override @Override
public void setCreateBtnState(boolean checkable) { public void setCreateBtnState(boolean checkable) {
// tvConfirm.setBackground(checkable ? canClick : notCanClick); tvConfirm.setBackground(checkable ? canClick : notCanClick);
// tvConfirm.setClickable(checkable); tvConfirm.setClickable(checkable);
} }
} }
...@@ -186,6 +186,8 @@ public class SupplierListFragment extends BaseSupplyChainFragment<SupplierListPr ...@@ -186,6 +186,8 @@ public class SupplierListFragment extends BaseSupplyChainFragment<SupplierListPr
bundle.putSerializable(SELECT_SUPPLIER_DATA, supplierInfoBean); bundle.putSerializable(SELECT_SUPPLIER_DATA, supplierInfoBean);
setFragmentResult(SELECT_SUPPLIER_RESULTCODE, bundle); setFragmentResult(SELECT_SUPPLIER_RESULTCODE, bundle);
killMyself(); killMyself();
} else {
showMessage("請選擇供應商");
} }
} }
} }
...@@ -196,6 +198,7 @@ public class SupplierListFragment extends BaseSupplyChainFragment<SupplierListPr ...@@ -196,6 +198,7 @@ public class SupplierListFragment extends BaseSupplyChainFragment<SupplierListPr
super.onFragmentResult(requestCode, resultCode, data); super.onFragmentResult(requestCode, resultCode, data);
if (requestCode == SUPPLIER_LIST && resultCode == RESULT_OK) { if (requestCode == SUPPLIER_LIST && resultCode == RESULT_OK) {
//新增或編輯了供應商,重新獲取所有供應商數據 //新增或編輯了供應商,重新獲取所有供應商數據
pageIndex = 0;
getSupplierList(); getSupplierList();
} }
} }
......
...@@ -80,7 +80,10 @@ public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseList ...@@ -80,7 +80,10 @@ public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseList
*/ */
private boolean isAscending = false; private boolean isAscending = false;
private int pageIndex = 0; private int pageIndex = 0;
/**
* 調整到其他頁面,用於回來是否刷新數據
*/
private final int UPDATE_KEY = 1001;
private WarehousingQueryAdapter warehousingQueryAdapter; private WarehousingQueryAdapter warehousingQueryAdapter;
public static WareHouseListFragment newInstance() { public static WareHouseListFragment newInstance() {
...@@ -185,18 +188,27 @@ public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseList ...@@ -185,18 +188,27 @@ public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseList
warehousingQueryAdapter = new WarehousingQueryAdapter(mContext, purchaseWarehousingOrderDetailsVos); warehousingQueryAdapter = new WarehousingQueryAdapter(mContext, purchaseWarehousingOrderDetailsVos);
rvWarehouseList.setLayoutManager(new LinearLayoutManager(mContext)); rvWarehouseList.setLayoutManager(new LinearLayoutManager(mContext));
rvWarehouseList.setAdapter(warehousingQueryAdapter); rvWarehouseList.setAdapter(warehousingQueryAdapter);
warehousingQueryAdapter.setOnItemChildClickListener((adapter, view, position) -> { warehousingQueryAdapter.setOnItemChildClickListener((adapter, view, position) -> {
if(view.getId() == R.id.tv_warehouse_item_inventory_quantity){ if(view.getId() == R.id.tv_warehouse_item_inventory_quantity){
//點擊庫存數量,進入庫存盤點 //點擊庫存數量,進入庫存盤點
start(WarehousingInventoryFragment.newInstance(warehousingQueryAdapter.getItem(position))); startForResult(WarehousingInventoryFragment.newInstance(warehousingQueryAdapter.getItem(position)), UPDATE_KEY);
} }
}); });
warehousingQueryAdapter.setOnItemClickListener((adapter, view, position) -> { warehousingQueryAdapter.setOnItemClickListener((adapter, view, position) -> {
//進入庫存詳情 //進入庫存詳情
start(WarehouseDetailsFragment.newInstance(warehousingQueryAdapter.getItem(position))); startForResult(WarehouseDetailsFragment.newInstance(warehousingQueryAdapter.getItem(position)), UPDATE_KEY);
}); });
} else { } else {
warehousingQueryAdapter.setList(purchaseWarehousingOrderDetailsVos); warehousingQueryAdapter.setList(purchaseWarehousingOrderDetailsVos);
} }
} }
@Override
public void onFragmentResult(int requestCode, int resultCode, Bundle data) {
super.onFragmentResult(requestCode, resultCode, data);
if(requestCode == UPDATE_KEY && resultCode == RESULT_OK){
getWarehousing();
}
}
} }
package com.gingersoft.supply_chain.mvp.ui.fragment.warehouse; package com.gingersoft.supply_chain.mvp.ui.fragment.warehouse;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.R; import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2; import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerWarehousingInventoryComponent; import com.gingersoft.supply_chain.di.component.DaggerWarehousingInventoryComponent;
...@@ -19,7 +25,11 @@ import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract; ...@@ -19,7 +25,11 @@ import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract;
import com.gingersoft.supply_chain.mvp.presenter.WarehousingInventoryPresenter; import com.gingersoft.supply_chain.mvp.presenter.WarehousingInventoryPresenter;
import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment; import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.QMUITopBar; import com.qmuiteam.qmui.widget.QMUITopBar;
import com.zhy.autolayout.utils.ScreenUtils;
import org.w3c.dom.Text;
import butterknife.BindView; import butterknife.BindView;
...@@ -39,17 +49,20 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho ...@@ -39,17 +49,20 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
TextView tvWarehouseDifference; TextView tvWarehouseDifference;
@BindView(R2.id.ed_warehouse_loss) @BindView(R2.id.ed_warehouse_loss)
EditText edWarehouseLoss; EditText edWarehouseLoss;
/**
private final static String FOOD_NAME_KEY = "foodNameKey"; * 食品總庫存
private final static String FOOD_ID_KEY = "foodIdKey"; */
private final static String FOOD_NUM_KEY = "foodNumKey"; private int foodNum;
private String foodNo;
public static WarehousingInventoryFragment newInstance(WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean purchaseWarehousingOrderDetailsVosBean) { public static WarehousingInventoryFragment newInstance(WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean purchaseWarehousingOrderDetailsVosBean) {
WarehousingInventoryFragment fragment = new WarehousingInventoryFragment(); WarehousingInventoryFragment fragment = new WarehousingInventoryFragment();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(FOOD_NAME_KEY, purchaseWarehousingOrderDetailsVosBean.getName()); bundle.putString(WarehouseDetailsFragment.FOOD_NAME_KEY, purchaseWarehousingOrderDetailsVosBean.getName());
bundle.putInt(FOOD_ID_KEY, purchaseWarehousingOrderDetailsVosBean.getId()); bundle.putInt(WarehouseDetailsFragment.FOOD_ID_KEY, purchaseWarehousingOrderDetailsVosBean.getId());
bundle.putInt(FOOD_NUM_KEY, purchaseWarehousingOrderDetailsVosBean.getFoodNum()); bundle.putInt(WarehouseDetailsFragment.FOOD_NUM_KEY, purchaseWarehousingOrderDetailsVosBean.getFoodNum());
bundle.putString(WarehouseDetailsFragment.FOOD_NO_KEY, purchaseWarehousingOrderDetailsVosBean.getFoodNo());
bundle.putString(WarehouseDetailsFragment.FOOD_IMAGE_KEY, purchaseWarehousingOrderDetailsVosBean.getImages());
fragment.setArguments(bundle); fragment.setArguments(bundle);
return fragment; return fragment;
} }
...@@ -73,15 +86,57 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho ...@@ -73,15 +86,57 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
Bundle arguments = getArguments(); Bundle arguments = getArguments();
if (arguments != null) { if (arguments != null) {
int foodId = arguments.getInt(FOOD_ID_KEY); int foodId = arguments.getInt(WarehouseDetailsFragment.FOOD_ID_KEY);
String foodName = arguments.getString(FOOD_NAME_KEY); foodNo = arguments.getString(WarehouseDetailsFragment.FOOD_NO_KEY);
int foodNum = arguments.getInt(FOOD_NUM_KEY); String foodName = arguments.getString(WarehouseDetailsFragment.FOOD_NAME_KEY);
foodNum = arguments.getInt(WarehouseDetailsFragment.FOOD_NUM_KEY);
ivWarehouseImg.post(() -> {
ViewGroup.LayoutParams layoutParams = ivWarehouseImg.getLayoutParams();
layoutParams.height = ivWarehouseImg.getWidth();
layoutParams.width = ivWarehouseImg.getWidth();
ivWarehouseImg.setLayoutParams(layoutParams);
String foodImageUrl = arguments.getString(WarehouseDetailsFragment.FOOD_IMAGE_KEY);
if (TextUtil.isNotEmptyOrNullOrUndefined(foodImageUrl)) {
GlideUtils.display(requireContext(), ivWarehouseImg, foodImageUrl);
} else {
ivWarehouseImg.setImageResource(R.drawable.img_small_default);
}
});
//初始化標題 //初始化標題
initTopBar(supplyTopBar, foodName); initTopBar(supplyTopBar, foodName);
supplyTopBar.addRightTextButton(R.string.str_save, R.id.id_save).setOnClickListener(mOnClickListener); Button btnSave = supplyTopBar.addRightTextButton(R.string.str_save, R.id.id_save);
btnSave.setTextColor(getColor(R.color.white));
btnSave.setOnClickListener(mOnClickListener);
//庫存數量 //庫存數量
tvWarehouseTotal.setText(String.valueOf(foodNum)); tvWarehouseTotal.setText(String.valueOf(foodNum));
tvWarehouseDifference.setText(String.valueOf(foodNum));
edWarehouseLoss.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus && edWarehouseLoss.getText().toString().equals("0")) {
edWarehouseLoss.setText("");
}
});
edWarehouseLoss.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (TextUtil.isNotEmptyOrNullOrUndefined(s + "")) {
//用戶輸入的盤點數量
int inventoryNum = Integer.parseInt(s + "");
tvWarehouseDifference.setText(String.valueOf(foodNum - inventoryNum));
} else {
tvWarehouseDifference.setText(String.valueOf(foodNum));
}
}
});
} else { } else {
showMessage("獲取食材信息失敗,請稍候重試"); showMessage("獲取食材信息失敗,請稍候重試");
killMyself(); killMyself();
...@@ -90,9 +145,27 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho ...@@ -90,9 +145,27 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
private View.OnClickListener mOnClickListener = v -> { private View.OnClickListener mOnClickListener = v -> {
if(v.getId() == R.id.id_save){ if (v.getId() == R.id.id_save) {
//保存 //保存,調用庫存損耗
// edWarehouseLoss.getText() if (TextUtil.isEmptyOrNullOrUndefined(edWarehouseLoss)) {
showMessage("請輸入盤點庫存數量");
edWarehouseLoss.requestFocus();
} else {
//盤點數量
int inventoryNum = Integer.parseInt(edWarehouseLoss.getText().toString());
if (inventoryNum <= 0) {
showMessage("請輸入盤點庫存數量");
edWarehouseLoss.requestFocus();
} else {
int remainingAmount = foodNum - inventoryNum;
mPresenter.consumeWareHousing(foodNo, remainingAmount);
}
}
} }
}; };
@Override
public void updateSuccess() {
setFragmentResult(RESULT_OK, null);
}
} }
...@@ -28,6 +28,7 @@ public class CategoryPopup extends ConfirmPopupView { ...@@ -28,6 +28,7 @@ public class CategoryPopup extends ConfirmPopupView {
private EditText et_input; private EditText et_input;
private OnClickListener onDeleteListener; private OnClickListener onDeleteListener;
private String inputText; private String inputText;
private final int nameMaxLength = 4;
public CategoryPopup(@NonNull Context context, CharSequence title, CharSequence content, CharSequence hint, String inputText, boolean showDelete) { public CategoryPopup(@NonNull Context context, CharSequence title, CharSequence content, CharSequence hint, String inputText, boolean showDelete) {
super(context, R.layout.dialog_new_category); super(context, R.layout.dialog_new_category);
...@@ -44,11 +45,15 @@ public class CategoryPopup extends ConfirmPopupView { ...@@ -44,11 +45,15 @@ public class CategoryPopup extends ConfirmPopupView {
tvDelete.setVisibility(showDelete ? View.VISIBLE : GONE); tvDelete.setVisibility(showDelete ? View.VISIBLE : GONE);
tvDelete.setOnClickListener(onDeleteListener); tvDelete.setOnClickListener(onDeleteListener);
et_input = findViewById(R.id.et_input); et_input = findViewById(R.id.et_input);
et_input.setFilters(new InputFilter[]{InputFilterUtils.getLengthFilter(getContext(), 4), InputFilterUtils.getChAndEnAndNumInputFilter(getContext())});
if (TextUtil.isNotEmptyOrNullOrUndefined(inputText)) { if (TextUtil.isNotEmptyOrNullOrUndefined(inputText)) {
et_input.setText(inputText); if (inputText.length() > nameMaxLength) {
et_input.setSelection(inputText.length()); et_input.setText(inputText.substring(0, 4));
} else {
et_input.setText(inputText);
}
et_input.setSelection(et_input.length());
} }
et_input.setFilters(new InputFilter[]{InputFilterUtils.getLengthFilter(getContext(), 4), InputFilterUtils.getChAndEnAndNumInputFilter(getContext())});
} }
public EditText getEditText() { public EditText getEditText() {
......
...@@ -16,6 +16,8 @@ import com.chad.library.adapter.base.listener.OnItemClickListener; ...@@ -16,6 +16,8 @@ import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.chad.library.adapter.base.viewholder.BaseViewHolder; import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils; import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.supply_chain.R; import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.ConsumeReasonBean;
import com.lxj.xpopup.impl.ConfirmPopupView;
import com.lxj.xpopup.impl.InputConfirmPopupView; import com.lxj.xpopup.impl.InputConfirmPopupView;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
...@@ -29,61 +31,65 @@ import java.util.List; ...@@ -29,61 +31,65 @@ import java.util.List;
* Time: 10:47 * Time: 10:47
* Use: 庫存消耗彈窗 * Use: 庫存消耗彈窗
*/ */
public class InventoryConsumptionPopup extends InputConfirmPopupView { public class InventoryConsumptionPopup extends ConfirmPopupView {
/** /**
* 庫存損耗原因 * 庫存損耗原因
*/ */
private List<String> consumptionReasons; private List<ConsumeReasonBean> consumptionReasons;
private EditText edRemarks; private EditText edRemarks;
private EditText edInput;
private RecyclerView rvConsumptionReason; private RecyclerView rvConsumptionReason;
private OnConfirmClickListener onConfirmClickListener; private OnConfirmClickListener onConfirmClickListener;
private int maxConsumption; private int maxConsumption;
/** /**
* @param context * @param context
* @param consumptionReasons 庫存消耗原因 * @param consumeReasonBeans 庫存消耗原因
* @param maxConsumption 最大消耗數 * @param maxConsumption 最大消耗數
* @param onConfirmClickListener 確認按鈕回調
*/ */
public InventoryConsumptionPopup(@NonNull Context context, List<String> consumptionReasons, int maxConsumption, OnConfirmClickListener onConfirmClickListener) { public InventoryConsumptionPopup(@NonNull Context context, List<ConsumeReasonBean> consumeReasonBeans, int maxConsumption) {
super(context, R.layout.popup_inventory_consumption); super(context, R.layout.popup_inventory_consumption);
this.consumptionReasons = consumptionReasons; this.consumptionReasons = consumeReasonBeans;
this.onConfirmClickListener = onConfirmClickListener;
this.maxConsumption = maxConsumption; this.maxConsumption = maxConsumption;
} }
public void setOnConfirmClickListener(OnConfirmClickListener onConfirmClickListener) {
this.onConfirmClickListener = onConfirmClickListener;
}
@Override @Override
protected void onCreate() { protected void onCreate() {
super.onCreate(); super.onCreate();
edRemarks = findViewById(R.id.ed_inventory_consumption_remark); edRemarks = findViewById(R.id.ed_inventory_consumption_remark);
edInput = findViewById(R.id.et_input);
rvConsumptionReason = findViewById(R.id.rv_inventory_consumption_reason); rvConsumptionReason = findViewById(R.id.rv_inventory_consumption_reason);
ConsumptionReasonAdapter consumptionReasonAdapter = new ConsumptionReasonAdapter(); ConsumptionReasonAdapter consumptionReasonAdapter = new ConsumptionReasonAdapter();
consumptionReasonAdapter.setOnItemClickListener((adapter, view, position) -> consumptionReasonAdapter.setSelectIndex(position)); consumptionReasonAdapter.setOnItemChildClickListener((adapter, view, position) -> consumptionReasonAdapter.setSelectIndex(position));
rvConsumptionReason.setLayoutManager(new GridLayoutManager(getContext(), 2)); rvConsumptionReason.setLayoutManager(new GridLayoutManager(getContext(), 2));
rvConsumptionReason.setAdapter(consumptionReasonAdapter); rvConsumptionReason.setAdapter(consumptionReasonAdapter);
findViewById(R.id.tv_confirm).setOnClickListener(v -> { findViewById(R.id.tv_confirm).setOnClickListener(v -> {
if (onConfirmClickListener != null) { if (onConfirmClickListener != null) {
String s = getEditText().getText().toString(); String s = edInput.getText().toString();
try { try {
int i = Integer.parseInt(s); int i = Integer.parseInt(s);
if (i > 0) { if (i > 0) {
if (i > maxConsumption) { if (i > maxConsumption) {
getEditText().setError("不能超過當前庫存數量:" + maxConsumption); edInput.setError("不能超過當前庫存數量:" + maxConsumption);
} else { } else {
onConfirmClickListener.onConfirm(i, consumptionReasonAdapter.getSelectIndex(), edRemarks.getText().toString()); onConfirmClickListener.onConfirm(i, consumptionReasonAdapter.getSelectIndex(), edRemarks.getText().toString());
} }
} else { } else {
ToastUtils.show(getContext(), "請輸入消耗庫存數"); ToastUtils.show(getContext(), "請輸入消耗庫存數");
getEditText().setError("請輸入消耗庫存數"); edInput.setError("請輸入消耗庫存數");
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
e.printStackTrace(); e.printStackTrace();
ToastUtils.show(getContext(), "請輸入消耗庫存數"); ToastUtils.show(getContext(), "請輸入消耗庫存數");
getEditText().setError("請輸入消耗庫存數"); edInput.setError("請輸入消耗庫存數");
} }
} }
}); });
getEditText().addTextChangedListener(new TextWatcher() { edInput.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {
...@@ -99,7 +105,7 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView { ...@@ -99,7 +105,7 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView {
try { try {
int i = Integer.parseInt(s.toString()); int i = Integer.parseInt(s.toString());
if (i > maxConsumption) { if (i > maxConsumption) {
getEditText().setError("不能超過當前庫存數量:" + maxConsumption); edInput.setError("不能超過當前庫存數量:" + maxConsumption);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -111,6 +117,7 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView { ...@@ -111,6 +117,7 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView {
public interface OnConfirmClickListener { public interface OnConfirmClickListener {
/** /**
* 確認時,將消耗的庫存,原因,備註傳遞回去 * 確認時,將消耗的庫存,原因,備註傳遞回去
*
* @param consumptionNum 消耗的庫存數量 * @param consumptionNum 消耗的庫存數量
* @param reasonIndex 原因下標 * @param reasonIndex 原因下標
* @param remarks 備註 * @param remarks 備註
...@@ -118,17 +125,18 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView { ...@@ -118,17 +125,18 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView {
void onConfirm(int consumptionNum, int reasonIndex, String remarks); void onConfirm(int consumptionNum, int reasonIndex, String remarks);
} }
private class ConsumptionReasonAdapter extends BaseQuickAdapter<String, BaseViewHolder> { private class ConsumptionReasonAdapter extends BaseQuickAdapter<ConsumeReasonBean, BaseViewHolder> {
private int selectIndex = 0; private int selectIndex = 0;
public ConsumptionReasonAdapter() { public ConsumptionReasonAdapter() {
super(R.layout.item_consumption_reason, consumptionReasons); super(R.layout.item_consumption_reason, consumptionReasons);
addChildClickViewIds(R.id.cb_consumption_reason);
} }
@Override @Override
protected void convert(@NotNull BaseViewHolder viewHolder, String s) { protected void convert(@NotNull BaseViewHolder viewHolder, ConsumeReasonBean consumeReasonBean) {
AppCompatCheckBox compatCheckBox = viewHolder.getView(R.id.cb_consumption_reason); AppCompatCheckBox compatCheckBox = viewHolder.getView(R.id.cb_consumption_reason);
compatCheckBox.setText(s); compatCheckBox.setText(consumeReasonBean.getDescription());
compatCheckBox.setChecked(viewHolder.getAdapterPosition() == selectIndex); compatCheckBox.setChecked(viewHolder.getAdapterPosition() == selectIndex);
} }
...@@ -137,10 +145,11 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView { ...@@ -137,10 +145,11 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView {
} }
public void setSelectIndex(int selectIndex) { public void setSelectIndex(int selectIndex) {
if (this.selectIndex < getData().size()) { int lastSelect = this.selectIndex;
notifyItemChanged(this.selectIndex);
}
this.selectIndex = selectIndex; this.selectIndex = selectIndex;
if (lastSelect < getData().size()) {
notifyItemChanged(lastSelect);
}
if (this.selectIndex < getData().size()) { if (this.selectIndex < getData().size()) {
notifyItemChanged(this.selectIndex); notifyItemChanged(this.selectIndex);
} }
......
...@@ -137,6 +137,7 @@ ...@@ -137,6 +137,7 @@
style="@style/Second_Category_Style" style="@style/Second_Category_Style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginLeft="@dimen/dp_15" android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_8" android:layout_marginTop="@dimen/dp_8"
android:background="@drawable/shape_border_white_bg" android:background="@drawable/shape_border_white_bg"
...@@ -167,6 +168,7 @@ ...@@ -167,6 +168,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_13" android:layout_marginLeft="@dimen/dp_13"
android:layout_marginTop="@dimen/dp_8" android:layout_marginTop="@dimen/dp_8"
android:visibility="gone"
android:background="@drawable/shape_color_da_stoke_fifteen_corners" android:background="@drawable/shape_color_da_stoke_fifteen_corners"
android:gravity="center" android:gravity="center"
android:text="+新增類別" android:text="+新增類別"
......
...@@ -10,24 +10,25 @@ ...@@ -10,24 +10,25 @@
android:id="@+id/food_ingredients_category_topbar" android:id="@+id/food_ingredients_category_topbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/head_height" android:layout_height="@dimen/head_height"
android:fitsSystemWindows="true"
android:background="@color/theme_color" android:background="@color/theme_color"
android:fitsSystemWindows="true"
app:qmui_topbar_title_color="@color/theme_white_color" /> app:qmui_topbar_title_color="@color/theme_white_color" />
<com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout <androidx.recyclerview.widget.RecyclerView
android:id="@+id/food_ingredients_category_section_layout" android:id="@+id/rv_food_select_category"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1"/> android:layout_weight="1"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:orientation="horizontal" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_20"
android:layout_marginLeft="@dimen/dp_20" android:layout_marginLeft="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_10" android:layout_marginTop="@dimen/dp_10"
android:layout_height="wrap_content"> android:layout_marginRight="@dimen/dp_20"
android:layout_marginBottom="@dimen/dp_20"
android:orientation="horizontal">
<com.qmuiteam.qmui.alpha.QMUIAlphaButton <com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_food_ingredients_confirm" android:id="@+id/btn_food_ingredients_confirm"
...@@ -44,9 +45,9 @@ ...@@ -44,9 +45,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20" android:layout_marginLeft="@dimen/dp_20"
android:layout_weight="1" android:layout_weight="1"
android:textColor="@color/color_3c"
android:background="@drawable/shape_black_border_small_radius" android:background="@drawable/shape_black_border_small_radius"
android:text="取消" /> android:text="取消"
android:textColor="@color/color_3c" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dp_40" android:layout_height="@dimen/dp_40"
android:layout_margin="@dimen/dp_10" android:layout_margin="@dimen/dp_10"
android:visibility="gone"
android:background="@drawable/shape_white_eight_corners_bg" android:background="@drawable/shape_white_eight_corners_bg"
android:orientation="horizontal"> android:orientation="horizontal"
android:visibility="gone">
<ImageView <ImageView
android:layout_width="@dimen/dp_20" android:layout_width="@dimen/dp_20"
...@@ -156,14 +156,39 @@ ...@@ -156,14 +156,39 @@
android:textSize="@dimen/dp_16" android:textSize="@dimen/dp_16"
android:visibility="gone" /> android:visibility="gone" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton <FrameLayout
android:id="@+id/btn_food_ingredients_confirm"
style="@style/Save_Btn_Style"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1">
android:text="確定"
android:visibility="visible" /> <com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_food_ingredients_confirm"
style="@style/Save_Btn_Style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginRight="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
android:text="確定"
android:visibility="visible" />
<TextView
android:id="@+id/tv_ingredients_food_num"
android:layout_width="@dimen/dp_20"
android:layout_height="@dimen/dp_20"
android:layout_gravity="right"
android:autoSizeMaxTextSize="@dimen/dp_8"
android:autoSizeMinTextSize="@dimen/dp_4"
android:background="@drawable/ui_shape_red_oval"
android:gravity="center"
android:text="3"
android:textColor="@color/white"
android:textSize="@dimen/dp_12"
android:visibility="gone"
app:layout_constraintRight_toRightOf="@id/iv_shopping_cart"
app:layout_constraintTop_toTopOf="@id/iv_shopping_cart" />
</FrameLayout>
<com.qmuiteam.qmui.alpha.QMUIAlphaButton <com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_food_ingredients_cancel" android:id="@+id/btn_food_ingredients_cancel"
...@@ -171,6 +196,8 @@ ...@@ -171,6 +196,8 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20" android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
android:layout_weight="1" android:layout_weight="1"
android:text="取消" android:text="取消"
android:visibility="visible" /> android:visibility="visible" />
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_9" android:layout_marginTop="@dimen/dp_9"
android:text="採購單號:" tools:text="採購單號:"
android:textColor="@color/color_3c" android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14" /> android:textSize="@dimen/dp_14" />
...@@ -71,8 +71,9 @@ ...@@ -71,8 +71,9 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10" android:layout_marginTop="@dimen/dp_10"
android:text="入庫單號:" tools:text="入庫單號:"
android:textColor="@color/color_3c" android:textColor="@color/color_3c"
android:visibility="gone"
android:textSize="@dimen/dp_14" /> android:textSize="@dimen/dp_14" />
<LinearLayout <LinearLayout
...@@ -136,8 +137,7 @@ ...@@ -136,8 +137,7 @@
android:layout_width="@dimen/dp_52" android:layout_width="@dimen/dp_52"
android:layout_height="@dimen/dp_46" android:layout_height="@dimen/dp_46"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:layout_marginLeft="@dimen/dp_32" android:layout_marginLeft="@dimen/dp_25" />
android:src="@drawable/img_partial_receipt" />
</LinearLayout> </LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
android:paddingBottom="@dimen/dp_10"> android:paddingBottom="@dimen/dp_10">
<ImageView <ImageView
android:id="@+id/iv_warehouse_img"
android:layout_width="@dimen/dp_77" android:layout_width="@dimen/dp_77"
android:layout_height="@dimen/dp_77" android:layout_height="@dimen/dp_77"
android:layout_marginLeft="@dimen/dp_13" /> android:layout_marginLeft="@dimen/dp_13" />
...@@ -50,10 +51,11 @@ ...@@ -50,10 +51,11 @@
tools:text="100" /> tools:text="100" />
<TextView <TextView
android:id="@+id/tv_food_unit"
style="@style/WareHouse_Details_TextStyle" style="@style/WareHouse_Details_TextStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="盒" /> tools:text="盒" />
<View <View
android:layout_width="0dp" android:layout_width="0dp"
...@@ -81,7 +83,7 @@ ...@@ -81,7 +83,7 @@
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center_vertical" android:gravity="center_vertical"
tools:text="單價:$10.00" /> tools:text="最新單價:$10.00" />
<TextView <TextView
android:id="@+id/tv_warehouse_total_amount" android:id="@+id/tv_warehouse_total_amount"
......
...@@ -12,12 +12,14 @@ ...@@ -12,12 +12,14 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_36" android:layout_marginLeft="@dimen/dp_36"
android:layout_marginRight="@dimen/dp_36" android:layout_marginRight="@dimen/dp_36" />
android:scaleType="fitXY" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_20"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
...@@ -37,6 +39,11 @@ ...@@ -37,6 +39,11 @@
android:textStyle="bold" android:textStyle="bold"
tools:text="100" /> tools:text="100" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -54,11 +61,12 @@ ...@@ -54,11 +61,12 @@
tools:text="+100" /> tools:text="+100" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_15" android:layout_marginTop="@dimen/dp_15"
android:layout_marginRight="@dimen/dp_20"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
...@@ -73,9 +81,16 @@ ...@@ -73,9 +81,16 @@
android:layout_width="@dimen/dp_86" android:layout_width="@dimen/dp_86"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/shape_square_edit_border_3c" android:background="@drawable/shape_square_edit_border_3c"
android:text="2" android:gravity="center"
android:hint="請輸入"
android:inputType="number"
android:paddingTop="@dimen/dp_9"
android:paddingBottom="@dimen/dp_9"
android:text="0"
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" /> android:textCursorDrawable="@drawable/cursor_theme"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatCheckBox <androidx.appcompat.widget.AppCompatCheckBox
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:checked="true" android:checked="true"
android:layout_marginTop="@dimen/dp_15" android:layout_marginTop="@dimen/dp_10"
android:text="正常消耗" /> android:text="正常消耗" />
......
<?xml version="1.0" encoding="utf-8"?>
<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/card_purchase_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_10"
app:elevation="@dimen/dp_10">
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_second_category_title"
style="@style/Second_Category_Style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/s_3c_to_white"
android:textSize="@dimen/dp_14"
tools:text="瓜果類" />
<com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
android:id="@+id/iv_category_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="@drawable/ic_red_circular_delete"
android:visibility="gone" />
</androidx.cardview.widget.CardView>
\ No newline at end of file
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
android:layout_weight="1" android:layout_weight="1"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:visibility="gone"
android:textSize="@dimen/dp_12" android:textSize="@dimen/dp_12"
android:visibility="gone"
tools:text="SP001" /> tools:text="SP001" />
<TextView <TextView
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
android:id="@+id/ed_food_ingredient_number" android:id="@+id/ed_food_ingredient_number"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minWidth="@dimen/dp_10"
android:layout_marginLeft="@dimen/dp_10" android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10" android:layout_marginRight="@dimen/dp_10"
android:background="@null" android:background="@null"
...@@ -168,6 +169,7 @@ ...@@ -168,6 +169,7 @@
android:paddingRight="@dimen/dp_4" android:paddingRight="@dimen/dp_4"
android:text="0" android:text="0"
android:textColor="@color/black" android:textColor="@color/black"
android:textCursorDrawable="@drawable/cursor_theme"
android:textSize="@dimen/dp_22" /> android:textSize="@dimen/dp_22" />
<com.qmuiteam.qmui.layout.QMUIButton <com.qmuiteam.qmui.layout.QMUIButton
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_purchase_category"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_marginLeft="@dimen/dp_3"
android:layout_marginTop="@dimen/dp_8"
android:layout_marginRight="@dimen/dp_4"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView <com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_second_category_title" android:id="@+id/tv_second_category_title"
style="@style/Second_Category_Style" style="@style/Second_Category_Style"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_3"
android:layout_marginTop="@dimen/dp_8"
android:layout_marginRight="@dimen/dp_4"
android:background="@drawable/s_app_color_to_bf"
android:gravity="center" android:gravity="center"
android:textColor="@color/s_3c_to_white" android:textColor="@color/s_3c_to_white"
android:textSize="@dimen/dp_14" android:textSize="@dimen/dp_14"
...@@ -23,6 +22,7 @@ ...@@ -23,6 +22,7 @@
android:id="@+id/iv_category_delete" android:id="@+id/iv_category_delete"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone"
android:layout_gravity="right" android:layout_gravity="right"
android:src="@drawable/ic_red_circular_delete" /> android:src="@drawable/ic_red_circular_delete" />
</FrameLayout> </androidx.cardview.widget.CardView>
\ No newline at end of file \ No newline at end of file
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dp_55" android:layout_height="@dimen/dp_55"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_marginBottom="@dimen/dp_1"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="@dimen/dp_18" android:paddingLeft="@dimen/dp_18">
android:paddingRight="@dimen/dp_18">
<TextView <TextView
android:id="@+id/tv_radio_section_title" android:id="@+id/tv_radio_section_title"
...@@ -26,8 +26,10 @@ ...@@ -26,8 +26,10 @@
<CheckBox <CheckBox
android:id="@+id/cb_radio_section" android:id="@+id/cb_radio_section"
android:layout_width="@dimen/dp_24" android:layout_width="wrap_content"
android:layout_height="@dimen/dp_24" android:paddingRight="@dimen/dp_18"
android:gravity="center"
android:layout_height="match_parent"
android:button="@drawable/selector_radio_circle_bg" /> android:button="@drawable/selector_radio_circle_bg" />
</LinearLayout> </LinearLayout>
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10" android:layout_marginLeft="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10" android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_white_eight_corners_bg" android:background="@drawable/shape_white_eight_corners_bg"
android:elevation="@dimen/dp_10" android:elevation="@dimen/dp_10"
android:orientation="vertical"> android:orientation="vertical"
android:paddingBottom="@dimen/dp_4">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -51,17 +51,18 @@ ...@@ -51,17 +51,18 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="@dimen/dp_9" android:orientation="horizontal"
android:paddingLeft="@dimen/dp_9" android:paddingLeft="@dimen/dp_9"
android:paddingRight="@dimen/dp_9" android:paddingTop="@dimen/dp_9"
android:orientation="horizontal"> android:paddingRight="@dimen/dp_9">
<TextView <TextView
android:id="@+id/tv_warehouse_order_time_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="下單日期:"
android:textColor="@color/color_3c" android:textColor="@color/color_3c"
android:textSize="@dimen/sp_16" android:textSize="@dimen/sp_16" />
tools:text="下單日期:" />
<TextView <TextView
android:id="@+id/tv_warehouse_details_order_time" android:id="@+id/tv_warehouse_details_order_time"
...@@ -86,18 +87,19 @@ ...@@ -86,18 +87,19 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="@dimen/dp_9" android:orientation="horizontal"
android:paddingLeft="@dimen/dp_9" android:paddingLeft="@dimen/dp_9"
android:paddingRight="@dimen/dp_9" android:paddingTop="@dimen/dp_9"
android:paddingBottom="@dimen/dp_10" android:layout_marginBottom="@dimen/dp_6"
android:orientation="horizontal"> android:paddingRight="@dimen/dp_9">
<TextView <TextView
android:id="@+id/tv_warehouse_time_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="入庫日期:"
android:textColor="@color/color_3c" android:textColor="@color/color_3c"
android:textSize="@dimen/sp_16" android:textSize="@dimen/sp_16" />
tools:text="入庫日期:" />
<TextView <TextView
android:id="@+id/tv_warehouse_details_time" android:id="@+id/tv_warehouse_details_time"
...@@ -118,4 +120,21 @@ ...@@ -118,4 +120,21 @@
android:textSize="@dimen/sp_14" android:textSize="@dimen/sp_14"
tools:text="採購入庫" /> tools:text="採購入庫" />
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/tv_warehouse_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="@dimen/dp_4"
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_10"
android:paddingTop="@dimen/dp_4"
android:paddingBottom="@dimen/dp_4"
android:privateImeOptions="@dimen/dp_10"
android:textColor="@color/white"
android:textSize="@dimen/dp_14"
android:visibility="gone"
tools:text="即將過期:3日" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -51,7 +51,8 @@ ...@@ -51,7 +51,8 @@
<TextView <TextView
android:id="@+id/tv_warehouse_item_total_amount" android:id="@+id/tv_warehouse_item_total_amount"
style="@style/WareHouse_item_TextStyle" style="@style/WareHouse_item_TextStyle"
android:layout_width="@dimen/dp_55" android:layout_width="wrap_content"
android:minWidth="@dimen/dp_55"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_0" android:layout_marginRight="@dimen/dp_0"
android:text="總價" /> android:text="總價" />
......
...@@ -53,7 +53,8 @@ ...@@ -53,7 +53,8 @@
<TextView <TextView
android:id="@+id/tv_warehouse_item_total_amount" android:id="@+id/tv_warehouse_item_total_amount"
style="@style/WareHouse_item_TextStyle" style="@style/WareHouse_item_TextStyle"
android:layout_width="@dimen/dp_55" android:layout_width="wrap_content"
android:minWidth="@dimen/dp_55"
android:drawableRight="@drawable/ic_sort" android:drawableRight="@drawable/ic_sort"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_0" android:layout_marginRight="@dimen/dp_0"
......
...@@ -25,15 +25,18 @@ ...@@ -25,15 +25,18 @@
<EditText <EditText
android:id="@+id/et_input" android:id="@+id/et_input"
android:layout_width="@dimen/dp_70" android:layout_width="@dimen/dp_70"
android:layout_height="@dimen/dp_21" android:layout_height="wrap_content"
android:maxLines="1" android:maxLines="1"
android:background="@drawable/shape_login_edit_border" android:paddingTop="@dimen/dp_2"
android:drawablePadding="@dimen/dp_3" android:paddingBottom="@dimen/dp_2"
android:textCursorDrawable="@drawable/cursor_theme"
android:paddingLeft="@dimen/dp_5"
android:paddingRight="@dimen/dp_5"
android:background="@drawable/selector_edit_48_aaa_bg"
android:inputType="number" android:inputType="number"
android:text="" android:text=""
android:textColor="@color/color_3c" android:textColor="@color/color_3c"
android:textSize="@dimen/sp_16" /> android:textSize="@dimen/sp_16" />
</LinearLayout> </LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
...@@ -79,7 +82,7 @@ ...@@ -79,7 +82,7 @@
android:gravity="center" android:gravity="center"
android:paddingTop="@dimen/dp_12" android:paddingTop="@dimen/dp_12"
android:paddingBottom="@dimen/dp_12" android:paddingBottom="@dimen/dp_12"
android:text="確定" /> android:text="@string/str_determine" />
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView <com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_cancel" android:id="@+id/tv_cancel"
...@@ -91,7 +94,7 @@ ...@@ -91,7 +94,7 @@
android:gravity="center" android:gravity="center"
android:paddingTop="@dimen/dp_12" android:paddingTop="@dimen/dp_12"
android:paddingBottom="@dimen/dp_12" android:paddingBottom="@dimen/dp_12"
android:text="確定" /> android:text="@string/str_cancel" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
<string name="str_supplier">供應商</string> <string name="str_supplier">供應商</string>
<string name="str_species">種類</string> <string name="str_species">種類</string>
<string name="str_inventory_consumption">庫存消耗</string> <string name="str_inventory_consumption">庫存消耗</string>
<string name="str_consumption_inventory">消耗庫存:</string>
<string name="str_manual_input">手動輸入</string>
<string name="str_remark">備註</string> <string name="str_remark">備註</string>
<string name="str_remark_colon">備註:</string> <string name="str_remark_colon">備註:</string>
<string name="str_save">保存</string> <string name="str_save">保存</string>
...@@ -18,5 +22,14 @@ ...@@ -18,5 +22,14 @@
<string name="str_format_purchase_no">採購單號:%1$s</string> <string name="str_format_purchase_no">採購單號:%1$s</string>
<string name="str_format_warehouse_no">入庫單號:%1$s</string> <string name="str_format_warehouse_no">入庫單號:%1$s</string>
<string name="str_format_remark">備註:%1$d</string> <string name="str_format_remark">備註:%1$d</string>
<string name="str_format_positive">+%1$d</string> <string name="str_format_positive">+%1$s</string>
<string name="str_format_less">-%1$s</string>
<string name="str_unit_price_colon">單價:$%1$.2f</string>
<string name="str_latest_unit_price_colon">最新單價:$%1$.2f</string>
<string name="str_total_amount_colon">總價:$%1$.2f</string>
<string name="str_cancel">取消</string>
<string name="str_determine">確定</string>
<string name="str_delete_category_tip">是否確認刪除該類別【%1$s】,子類和食材將一同刪除?</string>
</resources> </resources>
\ No newline at end of file
...@@ -35,6 +35,7 @@ ext { ...@@ -35,6 +35,7 @@ ext {
//support //support
"appcompat-v7" : 'androidx.appcompat:appcompat:1.0.2',//不要超過1.0.2,不然android5.1.1用webview會有問題 "appcompat-v7" : 'androidx.appcompat:appcompat:1.0.2',//不要超過1.0.2,不然android5.1.1用webview會有問題
"design" : 'com.google.android.material:material:1.0.0', "design" : 'com.google.android.material:material:1.0.0',
"support-design" : 'com.android.support:design:28.0.0',
"support-v4" : 'androidx.legacy:legacy-support-v4:1.0.0', "support-v4" : 'androidx.legacy:legacy-support-v4:1.0.0',
"cardview-v7" : 'androidx.cardview:cardview:1.0.0', "cardview-v7" : 'androidx.cardview:cardview:1.0.0',
"annotations" : 'androidx.annotation:annotation:1.0.0', "annotations" : 'androidx.annotation:annotation:1.0.0',
......
...@@ -58,6 +58,7 @@ dependencies { ...@@ -58,6 +58,7 @@ dependencies {
exclude module: 'appcompat-v7' exclude module: 'appcompat-v7'
exclude module: 'support-v4' exclude module: 'support-v4'
} }
api rootProject.ext.dependencies["support-design"]
api rootProject.ext.dependencies["annotations"] api rootProject.ext.dependencies["annotations"]
//view //view
api(rootProject.ext.dependencies["autolayout"]) { api(rootProject.ext.dependencies["autolayout"]) {
......
...@@ -35,6 +35,7 @@ import java.util.Observable; ...@@ -35,6 +35,7 @@ import java.util.Observable;
import javax.inject.Inject; import javax.inject.Inject;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import io.reactivex.Observer; import io.reactivex.Observer;
...@@ -80,6 +81,9 @@ public abstract class BaseFragment<P extends IPresenter> extends Fragment implem ...@@ -80,6 +81,9 @@ public abstract class BaseFragment<P extends IPresenter> extends Fragment implem
return mCache; return mCache;
} }
public int getColor(int colorId){
return ContextCompat.getColor(requireContext(), colorId);
}
@NonNull @NonNull
@Override @Override
......
...@@ -128,7 +128,6 @@ dependencies { ...@@ -128,7 +128,6 @@ dependencies {
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.gcssloop.recyclerview:pagerlayoutmanager:2.3.8' implementation 'com.gcssloop.recyclerview:pagerlayoutmanager:2.3.8'
//陰影背景 //陰影背景
api 'com.github.lihangleo2:ShadowLayout:2.1.6' api 'com.github.lihangleo2:ShadowLayout:2.1.6'
......
...@@ -6,6 +6,7 @@ import com.google.gson.JsonArray; ...@@ -6,6 +6,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -63,7 +64,7 @@ public class GsonUtils { ...@@ -63,7 +64,7 @@ public class GsonUtils {
if (gson != null) { if (gson != null) {
t = gson.fromJson(gsonString, cls); t = gson.fromJson(gsonString, cls);
} }
} catch (JSONException e) { } catch (JSONException | JsonSyntaxException | IllegalStateException e) {
e.printStackTrace(); e.printStackTrace();
} }
return t; return t;
......
...@@ -3,8 +3,10 @@ package com.gingersoft.gsa.cloud.common.utils.inputFilter; ...@@ -3,8 +3,10 @@ package com.gingersoft.gsa.cloud.common.utils.inputFilter;
import android.content.Context; import android.content.Context;
import android.text.InputFilter; import android.text.InputFilter;
import android.util.Log; import android.util.Log;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil; import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils; import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -94,15 +96,15 @@ public class InputFilterUtils { ...@@ -94,15 +96,15 @@ public class InputFilterUtils {
public static InputFilter getMaxLengthFilterDisChAndEn(int maxLength) { public static InputFilter getMaxLengthFilterDisChAndEn(int maxLength) {
return (source, start, end, dest, dstart, dend) -> { return (source, start, end, dest, dstart, dend) -> {
if (dest != null) { if (dest != null) {
int beforeLength = TextUtil.getStringLength(dest.toString()); int beforeLength = dest.length();
int sourceLength = TextUtil.getStringLength(source.toString()); int sourceLength = source.length();
int keep = maxLength - beforeLength; int keep = maxLength - beforeLength;
if (keep <= 0) { if (keep <= 0) {
return ""; return "";
} else if (keep >= sourceLength) { } else if (keep >= sourceLength) {
return null; // keep original return null; // keep original
} else { } else {
keep += sourceLength; keep += start;
if (Character.isHighSurrogate(source.charAt(keep - 1))) { if (Character.isHighSurrogate(source.charAt(keep - 1))) {
--keep; --keep;
if (keep == sourceLength) { if (keep == sourceLength) {
......
...@@ -33,6 +33,11 @@ public class TextUtil { ...@@ -33,6 +33,11 @@ public class TextUtil {
!str.equals("null") && !str.equals("undefined"); !str.equals("null") && !str.equals("undefined");
} }
public static boolean isNotEmptyOrNullOrUndefined(CharSequence str) {
return str != null && str.length() != 0 &&
!str.equals("null") && !str.equals("undefined");
}
public static boolean isNotEmptyOrNullOrUndefined(EditText editText) { public static boolean isNotEmptyOrNullOrUndefined(EditText editText) {
if (editText != null && editText.getText() != null) { if (editText != null && editText.getText() != null) {
String str = editText.getText().toString(); String str = editText.getText().toString();
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_edit_border_48" android:state_checked="true" />
<item android:drawable="@drawable/shape_edit_border_48" android:state_focused="true" />
<item android:drawable="@drawable/shape_login_edit_border" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="@dimen/dp_1"
android:color="@color/color_48" />
<corners android:radius="@dimen/dp_4" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
>
<corners android:radius="@dimen/dp_13" />
<solid android:color="@color/color_48" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
>
<corners android:radius="@dimen/dp_13" />
<solid android:color="@color/bright_orange" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
>
<corners android:radius="@dimen/dp_13" />
<solid android:color="@color/required_color" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/Multi_Layout_Style"
android:layout_width="match_parent"
android:layout_height="@dimen/multi_height"
android:gravity="center_vertical">
<include layout="@layout/item_multi_title_layout" />
<EditText
android:id="@+id/ed_multi_value"
style="@style/Multi_Input_editStyle"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_5"
android:layout_weight="1"
android:background="@null"
tools:hint="請輸入食品組名稱" />
<ImageView
android:id="@+id/iv_clear_multi_content"
android:layout_width="@dimen/dp_30"
android:layout_height="@dimen/dp_30"
android:layout_marginLeft="@dimen/dp_5"
android:padding="@dimen/dp_5"
android:src="@drawable/ic_clear_text"
android:visibility="gone" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/Multi_Layout_Style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/dp_75">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_5"
android:layout_weight="1">
<EditText
android:id="@+id/ed_multi_value"
style="@style/Multi_Input_editStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="@id/iv_clear_multi_content"
android:background="@null"
android:gravity="left"
android:paddingTop="@dimen/dp_10"
android:scrollbars="vertical"
tools:hint="請輸入食品組名稱" />
<ImageView
android:id="@+id/iv_clear_multi_content"
android:layout_width="@dimen/dp_30"
android:layout_height="@dimen/dp_30"
android:layout_alignParentRight="true"
android:layout_marginLeft="@dimen/dp_5"
android:padding="@dimen/dp_8"
android:src="@drawable/ic_clear_text"
android:visibility="gone" />
<TextView
android:id="@+id/tv_edit_text_length"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/hint_color"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/dp_5"
android:textSize="@dimen/dp_12"
tools:text="0/50" />
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
style="@style/Multi_Layout_Style"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal">
<include
layout="@layout/item_multi_title_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<CheckBox
android:id="@+id/rb_multi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@color/trans"
android:drawableLeft="@drawable/selector_radio_hook_bg"
android:drawablePadding="@dimen/dp_5"
android:text="選擇"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_16" />
</LinearLayout>
<include layout="@layout/include_horizontal_color_eee_dividing_line" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_radio_multi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" style="@style/Multi_Layout_Style"
>
<include layout="@layout/item_multi_title_layout" />
<TextView
android:id="@+id/tv_provider_select_text"
style="@style/Multi_Input_editStyle"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_5"
android:layout_weight="1"
android:background="@null"
android:hint="請選擇" />
<ImageView
android:id="@+id/iv_provider_select"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/arrow_down_black" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_38"
xmlns:tools="http://schemas.android.com/tools"
android:gravity="center_vertical">
<TextView
android:id="@+id/tv_multi_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_18"
tools:text="基本信息"
android:textColor="@color/black"
android:textSize="@dimen/multi_marginLeft"
android:textStyle="bold" />
</LinearLayout>
\ No newline at end of file
...@@ -476,6 +476,7 @@ ...@@ -476,6 +476,7 @@
<color name="color_ee">#eee</color> <color name="color_ee">#eee</color>
<color name="color_222">#222222</color> <color name="color_222">#222222</color>
<color name="color_53">#535353</color> <color name="color_53">#535353</color>
<color name="color_48">#484848</color>
<color name="tran_twenty_send_order_btn_bg_color">#331196DB</color> <color name="tran_twenty_send_order_btn_bg_color">#331196DB</color>
<color name="tran_fifty_order_state0_color">#7F009788</color> <color name="tran_fifty_order_state0_color">#7F009788</color>
...@@ -536,4 +537,5 @@ ...@@ -536,4 +537,5 @@
<color name="brick_red">#EC6941</color> <color name="brick_red">#EC6941</color>
<color name="add_deputy_unit_bg">#F19149</color> <color name="add_deputy_unit_bg">#F19149</color>
<color name="dk_color_999999">#999</color> <color name="dk_color_999999">#999</color>
<color name="bright_orange">#FF7A0E</color>
</resources> </resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="remark_max_length">50</integer>
</resources>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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